diff --git a/app/admin/lists/beforehand_order_cart_info/BeforehandOrderCartInfoLists.php b/app/admin/lists/beforehand_order_cart_info/BeforehandOrderCartInfoLists.php index 2a3c2497d..c962dbe26 100644 --- a/app/admin/lists/beforehand_order_cart_info/BeforehandOrderCartInfoLists.php +++ b/app/admin/lists/beforehand_order_cart_info/BeforehandOrderCartInfoLists.php @@ -36,6 +36,7 @@ class BeforehandOrderCartInfoLists extends BaseAdminDataLists implements ListsSe { return [ '=' => ['bhoid', 'uid', 'product_id'], + 'between_time' => 'create_time' ]; } @@ -51,30 +52,30 @@ 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']; + $id = $this->request->get('bhoid'); + $system_store = ''; + $order_mark = ''; + if ($this->request->get('export') == 2 && $id) { + $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'); - if($ids){ - $this->searchWhere[] = ['product_id','in',$ids]; + 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'); + if ($ids) { + $this->searchWhere[] = ['product_id', 'in', $ids]; } } $list = BeforehandOrderCartInfo::where($this->searchWhere) - ->field(['id', 'bhoid','package','store_info','marques','gross_weight','net_weight','accept_num','after_sales','loss', 'uid','pay_price', 'is_buyer', 'buyer_uid', 'product_id', 'attr_value_id', 'purchase', 'price', 'total_price', 'cart_num', 'mark']) + ->field(['id', 'bhoid', 'package', 'store_info', 'marques', 'gross_weight', 'net_weight', 'accept_num', 'after_sales', 'loss', 'uid', 'pay_price', 'is_buyer', 'buyer_uid', 'product_id', 'attr_value_id', 'purchase', 'price', 'total_price', 'cart_num', 'mark','create_time']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) - ->select()->each(function ($item) use($system_store,$order_mark) { + ->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; @@ -84,7 +85,7 @@ class BeforehandOrderCartInfoLists extends BaseAdminDataLists implements ListsSe $item['image'] = $find['image']; $item['unit'] = $find['unit']; $item['top_cate_id'] = $find['top_cate_id']; - $item['top_cate_name']=StoreCategory::where('id',$item['top_cate_id'])->value('name'); + $item['top_cate_name'] = StoreCategory::where('id', $item['top_cate_id'])->value('name'); if ($item->bhoid) { $status = PurchaseProductOffer::where('order_id', $item->bhoid)->where('product_id', $item->product_id)->value('status'); if ($status == 1) { @@ -93,6 +94,14 @@ class BeforehandOrderCartInfoLists extends BaseAdminDataLists implements ListsSe $item->status_name = '采购中'; } } + $item->is_buyer_name = ''; + if ($item->is_buyer == 1) { + $item->is_buyer_name = '采购'; + } elseif ($item->is_buyer == 0) { + $item->status_name = '待处理'; + } elseif ($item->is_buyer == -1) { + $item->is_buyer_name = '不采购'; + } return $item; }) ->toArray(); @@ -120,10 +129,10 @@ class BeforehandOrderCartInfoLists extends BaseAdminDataLists implements ListsSe */ public function setFileName(): string { - if($this->fileName!=''){ + if ($this->fileName != '') { return $this->fileName; - }else{ - return '预订单商品'; + } else { + return '预订单商品列表'; } } @@ -136,26 +145,47 @@ class BeforehandOrderCartInfoLists extends BaseAdminDataLists implements ListsSe */ public function setExcelFields(): array { - $data = [ - 'bhoid' => '订单id', - 'store_name' => '商品名称', - 'system_store' => '门店', - 'marques' => '型号', - 'package' => '包装', - 'top_cate_name' => '分类', - 'unit_name' => '单位', - 'gross_weight' => '毛重', - 'net_weight' => '净重', - 'warehouse_stock' => '仓库数量', - 'cart_num' => '需求数量', - 'price' => '单价', - 'total_price' => '总价', - 'after_sales' => '售后', - 'loss' => '损耗', - 'mark' => '备注', - 'order_mark' => '订单备注', - ]; + if($this->request->get('id')){ + $data = [ + 'bhoid' => '订单id', + 'store_name' => '商品名称', + 'system_store' => '门店', + 'marques' => '型号', + 'package' => '包装', + 'top_cate_name' => '分类', + 'unit_name' => '单位', + 'gross_weight' => '毛重', + 'net_weight' => '净重', + 'warehouse_stock' => '仓库数量', + 'cart_num' => '需求数量', + 'price' => '单价', + 'total_price' => '总价', + 'after_sales' => '售后', + 'loss' => '损耗', + 'mark' => '备注', + 'order_mark' => '订单备注', + + ]; + }else{ + $data = [ + 'bhoid' => '订单id', + 'store_name' => '商品名称', + 'marques' => '型号', + 'package' => '包装', + 'top_cate_name' => '分类', + 'unit_name' => '单位', + 'gross_weight' => '毛重', + 'net_weight' => '净重', + 'warehouse_stock' => '仓库数量', + 'cart_num' => '需求数量', + 'price' => '单价', + 'total_price' => '总价', + 'after_sales' => '售后', + 'loss' => '损耗', + 'mark' => '备注', + ]; + } return $data; } -} \ No newline at end of file +}