feat: 修改了导出订单功能,优化了代码逻辑,增加了异常处理,并更新了文档。
This commit is contained in:
parent
1f2863ff97
commit
7f62e89ecb
@ -159,13 +159,18 @@ class StoreOrderController extends BaseAdminController
|
||||
$total_price=0;
|
||||
foreach ($data as $key => &$value) {
|
||||
$find=StoreProduct::where('id',$value->product_id)->find();
|
||||
$value->store_name=$find['store_name'];
|
||||
$value->store_info=$find['store_info'];
|
||||
$value->unit_name=StoreProductUnit::where('id',$value->unit_id)->value('name');
|
||||
$value->store_name=$find['store_name']??'';
|
||||
$value->store_info=$find['store_info']??'';
|
||||
if(!empty($find['unit_id'])){
|
||||
$value->unit_name=StoreProductUnit::where('id',$find['unit_id'])->value('name');
|
||||
}else{
|
||||
$value->unit_name='';
|
||||
}
|
||||
$total_num+=$value->cart_num;
|
||||
$total_price+=$value->total_price;
|
||||
}
|
||||
$file_path = $xlsx->export($data,$system_store,$total_num,$total_price);
|
||||
return response()->download($file_path, $system_store.'.xlsx');
|
||||
|
||||
return $this->success('导出成功', ['url' => $file_path]);
|
||||
}
|
||||
}
|
||||
|
@ -96,6 +96,6 @@ class StoreOrderCartInfoController extends BaseAdminController
|
||||
$total_price+=$value->total_price;
|
||||
}
|
||||
$file_path = $xlsx->export($data,$system_store,$total_num,$total_price);
|
||||
return response()->download($file_path, $system_store.'.xlsx');
|
||||
return $this->success('导出成功', ['url' => $file_path]);
|
||||
}
|
||||
}
|
@ -126,9 +126,10 @@ class OrderDetail
|
||||
// 保存文件到 public 下
|
||||
|
||||
$writer = new Xlsx($spreadsheet);
|
||||
$file_path = public_path() . '/export/' . date('Y-m') . '/' . $system_store . '.xlsx';
|
||||
$url = '/export/' . date('Y-m') . '/' . $system_store . '.xlsx';
|
||||
$file_path = public_path() . $url;
|
||||
// 保存文件到 public 下
|
||||
$writer->save($file_path);
|
||||
return $file_path;
|
||||
return getenv('APP_URL').$url;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user