|
|
|
|
@ -9,6 +9,12 @@ use App\Services\OrderService;
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
|
use PhpOffice\PhpSpreadsheet\IOFactory;
|
|
|
|
|
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
|
|
|
|
|
|
|
|
|
class OrderController extends Controller
|
|
|
|
|
{
|
|
|
|
|
public function GetList()
|
|
|
|
|
@ -26,6 +32,20 @@ class OrderController extends Controller
|
|
|
|
|
if (isset($searchInfo['order_number'])) {
|
|
|
|
|
$list = $list->where('order_number', $searchInfo['order_number']);
|
|
|
|
|
}
|
|
|
|
|
if (isset($searchInfo['order_title'])) {
|
|
|
|
|
$list = $list->where('title', 'like', '%' . $searchInfo['order_title'] . '%');
|
|
|
|
|
}
|
|
|
|
|
if (isset($searchInfo['create_date'])) {
|
|
|
|
|
$searchInfo['create_date'][0]=$searchInfo['create_date'][0].' 00:00:00';
|
|
|
|
|
$searchInfo['create_date'][1]=$searchInfo['create_date'][1].' 23:59:59';
|
|
|
|
|
$list = $list->whereBetween('created_at', $searchInfo['create_date']);
|
|
|
|
|
}
|
|
|
|
|
if (isset($searchInfo['appointment_date'])) {
|
|
|
|
|
$list = $list->whereBetween('appointment_date', $searchInfo['appointment_date']);
|
|
|
|
|
}
|
|
|
|
|
if (isset($searchInfo['youxiaoqi_date'])) {
|
|
|
|
|
$list = $list->whereBetween('youxiaoqi_end', $searchInfo['youxiaoqi_date']);
|
|
|
|
|
}
|
|
|
|
|
$count = $list->count();
|
|
|
|
|
$list = $list->orderBy('id', 'desc')
|
|
|
|
|
->skip(($page - 1) * $pageSize) // 跳过前9999条记录
|
|
|
|
|
@ -182,4 +202,125 @@ class OrderController extends Controller
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public function ExportExcel()
|
|
|
|
|
{
|
|
|
|
|
$searchInfo = request('searchInfo');
|
|
|
|
|
$list = DB::table('orders')
|
|
|
|
|
->select('*',
|
|
|
|
|
DB::raw("
|
|
|
|
|
CASE
|
|
|
|
|
WHEN type = 1 THEN '个检'
|
|
|
|
|
WHEN type = 2 THEN '团检'
|
|
|
|
|
ELSE '未知'
|
|
|
|
|
END AS type_text
|
|
|
|
|
"),
|
|
|
|
|
DB::raw("
|
|
|
|
|
CASE
|
|
|
|
|
WHEN status = 1 THEN '待支付'
|
|
|
|
|
WHEN status = 2 THEN '已支付'
|
|
|
|
|
WHEN status = 3 THEN '交易关闭'
|
|
|
|
|
WHEN status = 4 THEN '已完成'
|
|
|
|
|
WHEN status = 5 THEN '已退款'
|
|
|
|
|
WHEN status = 6 THEN '已转赠'
|
|
|
|
|
ELSE '未知'
|
|
|
|
|
END AS status_text
|
|
|
|
|
"),
|
|
|
|
|
DB::raw("
|
|
|
|
|
CASE
|
|
|
|
|
WHEN check_status = 1 THEN '待检'
|
|
|
|
|
WHEN check_status = 2 THEN '已到检'
|
|
|
|
|
ELSE '未知'
|
|
|
|
|
END AS check_status_text
|
|
|
|
|
"),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (isset($searchInfo['name'])) {
|
|
|
|
|
$list = $list->where('name', 'like', '%' . $searchInfo['name'] . '%');
|
|
|
|
|
}
|
|
|
|
|
if (isset($searchInfo['id_number'])) {
|
|
|
|
|
$list = $list->where('id_number', $searchInfo['id_number']);
|
|
|
|
|
}
|
|
|
|
|
if (isset($searchInfo['order_number'])) {
|
|
|
|
|
$list = $list->where('order_number', $searchInfo['order_number']);
|
|
|
|
|
}
|
|
|
|
|
if (isset($searchInfo['order_title'])) {
|
|
|
|
|
$list = $list->where('title', 'like', '%' . $searchInfo['order_title'] . '%');
|
|
|
|
|
}
|
|
|
|
|
if (isset($searchInfo['create_date'])) {
|
|
|
|
|
$searchInfo['create_date'][0]=$searchInfo['create_date'][0].' 00:00:00';
|
|
|
|
|
$searchInfo['create_date'][1]=$searchInfo['create_date'][1].' 23:59:59';
|
|
|
|
|
$list = $list->whereBetween('created_at', $searchInfo['create_date']);
|
|
|
|
|
}
|
|
|
|
|
if (isset($searchInfo['appointment_date'])) {
|
|
|
|
|
$list = $list->whereBetween('appointment_date', $searchInfo['appointment_date']);
|
|
|
|
|
}
|
|
|
|
|
if (isset($searchInfo['youxiaoqi_date'])) {
|
|
|
|
|
$list = $list->whereBetween('youxiaoqi_end', $searchInfo['youxiaoqi_date']);
|
|
|
|
|
}
|
|
|
|
|
$count = $list->count();
|
|
|
|
|
$list = $list->orderBy('id', 'desc')->get();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ini_set('memory_limit', '512M');
|
|
|
|
|
$template_path = Storage::path('public/excel/kong.xlsx');
|
|
|
|
|
$spreadsheet = IOFactory::load($template_path);
|
|
|
|
|
$worksheet = $spreadsheet->getActiveSheet();
|
|
|
|
|
$styleArray = [
|
|
|
|
|
'borders' => [
|
|
|
|
|
'allBorders' => [
|
|
|
|
|
'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
|
|
|
|
|
'color' => ['argb' => 'FF000000'],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$worksheet->setCellValueExplicit('A1' , '姓名', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
|
|
|
|
|
$worksheet->setCellValueExplicit('B1' , '证件号', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
|
|
|
|
|
$worksheet->setCellValueExplicit('C1' , '电话', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
|
|
|
|
|
$worksheet->setCellValueExplicit('D1' , '订单号', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
|
|
|
|
|
$worksheet->setCellValueExplicit('E1' , '标题', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
|
|
|
|
|
$worksheet->setCellValueExplicit('F1' , '类型', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
|
|
|
|
|
$worksheet->setCellValueExplicit('G1' , '价格', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
|
|
|
|
|
$worksheet->setCellValueExplicit('H1' , '使用积分', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
|
|
|
|
|
$worksheet->setCellValueExplicit('I1' , '使用预存款', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
|
|
|
|
|
$worksheet->setCellValueExplicit('G1' , '状态', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
|
|
|
|
|
$worksheet->setCellValueExplicit('K1' , '有效期', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
|
|
|
|
|
$worksheet->setCellValueExplicit('L1' , '到检状态', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
|
|
|
|
|
$worksheet->setCellValueExplicit('M1' , '创建时间', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
|
|
|
|
|
|
|
|
|
|
$row = 2;
|
|
|
|
|
$col = [
|
|
|
|
|
'A' => 'name',
|
|
|
|
|
'B' => 'id_number',
|
|
|
|
|
'C' => 'phone',
|
|
|
|
|
'D' => 'order_number', // 新增列
|
|
|
|
|
'E' => 'title', // 原 phone 列往后移动
|
|
|
|
|
'F' => 'type_text',
|
|
|
|
|
'G' => 'price',
|
|
|
|
|
'H' => 'jifen',
|
|
|
|
|
'I' => 'yucunkuan',
|
|
|
|
|
'J' => 'status_text',
|
|
|
|
|
'K' => 'youxiaoqi_end',
|
|
|
|
|
'L' => 'check_status_text',
|
|
|
|
|
'M' => 'created_at',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
foreach ($list as $table_item) {
|
|
|
|
|
foreach ($col as $index => $key) {
|
|
|
|
|
$worksheet->setCellValueExplicit($index . $row, $table_item->$key, \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);}
|
|
|
|
|
$row++;
|
|
|
|
|
}
|
|
|
|
|
$worksheet->getStyle('A3:T' . ($row - 1))->applyFromArray($styleArray);
|
|
|
|
|
$file_name = Str::orderedUuid();
|
|
|
|
|
$dir_path = "public/excel/" . date('Ym') . '/' . $file_name;
|
|
|
|
|
Storage::makeDirectory($dir_path);
|
|
|
|
|
|
|
|
|
|
$excel_path = $dir_path . "/订单列表.xlsx";
|
|
|
|
|
$writer = new Xlsx($spreadsheet);
|
|
|
|
|
$writer->save(Storage::path($excel_path));
|
|
|
|
|
$url = Storage::url($excel_path);
|
|
|
|
|
return \Yz::Return(true,'完成',['url'=> env('APP_URL').$url]);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|