|
@@ -44,53 +44,61 @@ class ExportOrder implements Consumer
|
|
|
|
|
|
|
|
public function consume($data): bool
|
|
public function consume($data): bool
|
|
|
{
|
|
{
|
|
|
- if(empty($data['logId'])) return true;
|
|
|
|
|
- $spreadsheet = new Spreadsheet();
|
|
|
|
|
- $title = ['店铺名称','下单人昵称','订单编号','订单状态','发货状态', '收件人', '手机号码', '收货地址', '创建时间'];
|
|
|
|
|
- $sheet = $spreadsheet->getActiveSheet();
|
|
|
|
|
- $titCol = 'A';
|
|
|
|
|
- foreach ($title as $key => $value) {
|
|
|
|
|
- // 单元格内容写入
|
|
|
|
|
- $sheet->setCellValue($titCol . '1', $value);
|
|
|
|
|
- $titCol++;
|
|
|
|
|
- }
|
|
|
|
|
- $row = 2; // 从第二行开始
|
|
|
|
|
- $searchKey = (new OrderService)->searchFilter($data['param']);
|
|
|
|
|
- $orderData = (new SaasOrder)->where($searchKey)->with(['address','poi','user'])->select();
|
|
|
|
|
- if ($orderData->isEmpty()) {
|
|
|
|
|
- (new SystemExport)->where("id",$data['logId'])->update(['status' => 2]);
|
|
|
|
|
- return true;
|
|
|
|
|
- }
|
|
|
|
|
- foreach ($orderData as $item) {
|
|
|
|
|
- $dataCol = 'A';
|
|
|
|
|
- $address = "-";
|
|
|
|
|
- if (!empty($item['address'])) {
|
|
|
|
|
- $address = $item['address']['city_text'].$item['address']['address'];
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ if(empty($data['logId'])) return true;
|
|
|
|
|
+ $spreadsheet = new Spreadsheet();
|
|
|
|
|
+ $title = ['店铺名称','下单人昵称','订单编号','订单状态','发货状态', '收件人', '手机号码', '收货地址', '创建时间'];
|
|
|
|
|
+ $sheet = $spreadsheet->getActiveSheet();
|
|
|
|
|
+ $titCol = 'A';
|
|
|
|
|
+ foreach ($title as $key => $value) {
|
|
|
|
|
+ // 单元格内容写入
|
|
|
|
|
+ $sheet->setCellValue($titCol . '1', $value);
|
|
|
|
|
+ $titCol++;
|
|
|
|
|
+ }
|
|
|
|
|
+ $row = 2; // 从第二行开始
|
|
|
|
|
+ $searchKey = (new OrderService)->searchFilter($data['param']);
|
|
|
|
|
+ $orderData = (new SaasOrder)->where($searchKey)->with(['address','poi','user'])->select();
|
|
|
|
|
+ if ($orderData->isEmpty()) {
|
|
|
|
|
+ (new SystemExport)->where("id",$data['logId'])->update(['status' => 2]);
|
|
|
|
|
+ return true;
|
|
|
}
|
|
}
|
|
|
- $newData = [
|
|
|
|
|
- "shop" => $item['poi']['poi_name']??'-', // 店铺名称
|
|
|
|
|
- "nickname" => $item['user']['nickname']??'-', // 下单人昵称
|
|
|
|
|
- "order" => $item['order_sn']??'-', // 订单编号
|
|
|
|
|
- "status" => $this->status[$item['status']], // 订单状态
|
|
|
|
|
- "express" => $this->express[$item['express_status']], // 订单状态
|
|
|
|
|
- "user" => $item['address']['nickname']??'-',
|
|
|
|
|
- "mobile" => $item['address']['mobile']??'-',
|
|
|
|
|
- "address" => $address,
|
|
|
|
|
- "create_at" => $item['create_at'],
|
|
|
|
|
- ];
|
|
|
|
|
- foreach ($newData as $value) {
|
|
|
|
|
- $sheet->setCellValue($dataCol . $row, ' '.$value);
|
|
|
|
|
- $dataCol++;
|
|
|
|
|
|
|
+ foreach ($orderData as $item) {
|
|
|
|
|
+ $dataCol = 'A';
|
|
|
|
|
+ $address = "-";
|
|
|
|
|
+ if (!empty($item['address'])) {
|
|
|
|
|
+ $address = $item['address']['city_text'].$item['address']['address'];
|
|
|
|
|
+ }
|
|
|
|
|
+ $newData = [
|
|
|
|
|
+ "shop" => $item['poi']['poi_name']??'-', // 店铺名称
|
|
|
|
|
+ "nickname" => $item['user']['nickname']??'-', // 下单人昵称
|
|
|
|
|
+ "order" => $item['order_sn']??'-', // 订单编号
|
|
|
|
|
+ "status" => $this->status[$item['status']], // 订单状态
|
|
|
|
|
+ "express" => $this->express[$item['express_status']], // 订单状态
|
|
|
|
|
+ "user" => $item['address']['nickname']??'-',
|
|
|
|
|
+ "mobile" => $item['address']['mobile']??'-',
|
|
|
|
|
+ "address" => $address,
|
|
|
|
|
+ "create_at" => $item['create_at'],
|
|
|
|
|
+ ];
|
|
|
|
|
+ foreach ($newData as $value) {
|
|
|
|
|
+ $sheet->setCellValue($dataCol . $row, ' '.$value);
|
|
|
|
|
+ $dataCol++;
|
|
|
|
|
+ }
|
|
|
|
|
+ $row++;
|
|
|
}
|
|
}
|
|
|
- $row++;
|
|
|
|
|
|
|
+ $write = new Xlsx($spreadsheet);
|
|
|
|
|
+ $pathName = public_path().DIRECTORY_SEPARATOR."download".DIRECTORY_SEPARATOR.$data['param']['fileName'];
|
|
|
|
|
+ echo $pathName."\n";
|
|
|
|
|
+ (new SystemExport)->where("id",$data['logId'])->update([
|
|
|
|
|
+ "down_url" => "https://tran.jsshuita.cn/download/".$data['param']['fileName'],
|
|
|
|
|
+ "status" => 1
|
|
|
|
|
+ ]);
|
|
|
|
|
+ $write->save($pathName);
|
|
|
|
|
+ } catch (\Throwable $throwable) {
|
|
|
|
|
+ echo getDateFull()."==导出订单报错===\n";
|
|
|
|
|
+ echo $throwable->getFile()."\n";
|
|
|
|
|
+ echo $throwable->getLine()."\n";
|
|
|
|
|
+ echo $throwable->getMessage()."\n";
|
|
|
}
|
|
}
|
|
|
- $write = new Xlsx($spreadsheet);
|
|
|
|
|
- $pathName = public_path().DIRECTORY_SEPARATOR."download".DIRECTORY_SEPARATOR.$data['param']['fileName'];
|
|
|
|
|
- (new SystemExport)->where("id",$data['logId'])->update([
|
|
|
|
|
- "down_url" => "https://tran.jsshuita.cn/download/".$data['param']['fileName'],
|
|
|
|
|
- "status" => 1
|
|
|
|
|
- ]);
|
|
|
|
|
- $write->save($pathName);
|
|
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|