feat(admin): 优化预订单导出功能
- 添加订单 ID 和 备注 到导出的 Excel 表格 - 优化文件名生成逻辑,使用门店名称和订单 ID - 调整订单商品备注显示 - 修复导出功能中的相关问题
This commit is contained in:
parent
25eaaab509
commit
dbc97dca98
@ -24,6 +24,7 @@ class BeforehandOrderCartInfoLists extends BaseAdminDataLists implements ListsSe
|
||||
{
|
||||
|
||||
public $list;
|
||||
public $fileName;
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
@ -50,6 +51,17 @@ class BeforehandOrderCartInfoLists extends BaseAdminDataLists implements ListsSe
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$id=$this->request->get('bhoid');
|
||||
$system_store='';
|
||||
$order_mark='';
|
||||
if($this->request->get('export')==2){
|
||||
$find=BeforehandOrder::where('id',$id)->field('store_id,order_id,mark')->find();
|
||||
$system_store=SystemStore::where('id',$find['store_id'])->value('name');
|
||||
$this->fileName=$system_store.'-'.$find['order_id'].'.xlsx';
|
||||
$order_mark=$find['mark'];
|
||||
}
|
||||
|
||||
|
||||
if($this->request->get('top_cate')){
|
||||
$product_id=BeforehandOrderCartInfo::where($this->searchWhere)->column('product_id');
|
||||
$ids=StoreProduct::where('id', 'in', $product_id)->where('top_cate_id',$this->request->get('top_cate'))->column('id');
|
||||
@ -57,15 +69,18 @@ class BeforehandOrderCartInfoLists extends BaseAdminDataLists implements ListsSe
|
||||
$this->searchWhere[] = ['product_id','in',$ids];
|
||||
}
|
||||
}
|
||||
|
||||
$list = BeforehandOrderCartInfo::where($this->searchWhere)
|
||||
->field(['id', 'bhoid', 'uid', 'is_buyer', 'buyer_uid', 'product_id', 'attr_value_id', 'purchase', 'price', 'total_price', 'cart_num', 'mark'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function ($item) {
|
||||
->select()->each(function ($item) use($system_store,$order_mark) {
|
||||
$find = StoreProduct::where('id', $item['product_id'])->field('top_cate_id,store_name,image,unit')->withTrashed()->find();
|
||||
$item->unit_name = StoreProductUnit::where('id', $find->unit)->value('name');
|
||||
$item['warehouse_stock'] = WarehouseProductStorege::where('product_id', $item['product_id'])->value('nums') ?? 0;
|
||||
$item['store_name'] = $find['store_name'];
|
||||
$item['system_store'] = $system_store;
|
||||
$item['order_mark'] = $order_mark;
|
||||
$item['image'] = $find['image'];
|
||||
$item['unit'] = $find['unit'];
|
||||
$item['top_cate_id'] = $find['top_cate_id'];
|
||||
@ -105,19 +120,11 @@ class BeforehandOrderCartInfoLists extends BaseAdminDataLists implements ListsSe
|
||||
*/
|
||||
public function setFileName(): string
|
||||
{
|
||||
$id=$this->request->get('bhoid');
|
||||
$find=BeforehandOrder::where('id',$id)->field('store_id,mark')->find();
|
||||
$name='';
|
||||
if($find['store_id']>0){
|
||||
$name=SystemStore::where('id',$find['store_id'])->value('name');
|
||||
if($this->fileName!=''){
|
||||
return $this->fileName;
|
||||
}else{
|
||||
return '预订单商品';
|
||||
}
|
||||
if($find['mark']!=''){
|
||||
$originalString = $find['mark'];
|
||||
$length = 15; // 截断长度
|
||||
$mark = substr($originalString, 0, $length);
|
||||
$name.='-'.$mark;
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
|
||||
|
||||
@ -130,13 +137,18 @@ class BeforehandOrderCartInfoLists extends BaseAdminDataLists implements ListsSe
|
||||
public function setExcelFields(): array
|
||||
{
|
||||
$data = [
|
||||
'bhoid' => '订单id',
|
||||
'store_name' => '商品名称',
|
||||
'system_store' => '门店',
|
||||
'warehouse_stock' => '仓库数量',
|
||||
'cart_num' => '需求数量',
|
||||
'top_cate_name' => '分类',
|
||||
'unit_name' => '单位',
|
||||
'price' => '单价',
|
||||
'total_price' => '总价',
|
||||
'mark' => '备注',
|
||||
'order_mark' => '订单备注',
|
||||
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user