diff --git a/app/admin/controller/beforehand_order_cart_info/BeforehandOrderCartInfoController.php b/app/admin/controller/beforehand_order_cart_info/BeforehandOrderCartInfoController.php index 68aa3537c..3f43f7acc 100644 --- a/app/admin/controller/beforehand_order_cart_info/BeforehandOrderCartInfoController.php +++ b/app/admin/controller/beforehand_order_cart_info/BeforehandOrderCartInfoController.php @@ -7,6 +7,7 @@ use app\admin\controller\BaseAdminController; use app\admin\lists\beforehand_order_cart_info\BeforehandOrderCartInfoLists; use app\admin\logic\beforehand_order_cart_info\BeforehandOrderCartInfoLogic; use app\common\model\beforehand_order_cart_info\BeforehandOrderCartInfo; +use app\common\model\purchase_product_offer\PurchaseProductOffer; /** * 预订单购物详情表控制器 @@ -61,7 +62,17 @@ class BeforehandOrderCartInfoController extends BaseAdminController */ public function procurement_status(){ $id=$this->request->post('id'); - $res=BeforehandOrderCartInfo::where('id',$id)->update(['is_buyer'=>-1]); + + $res=BeforehandOrderCartInfo::where('id',$id)->find(); + $find=PurchaseProductOffer::where(['product_id'=>$res['product_id'],'order_id'=>$res['bhoid']])->find(); + if($find){ + if($find['buyer_confirm']==1){ + return $this->fail('该商品已采购完成,无法更改状态'); + }else{ + PurchaseProductOffer::where('id',$find['id'])->update(['delete_time'=>time()]); + } + } + $res->save(['is_buyer'=>-1]); if($res){ return $this->success('操作成功',[],1,1); }else{ diff --git a/app/admin/lists/beforehand_order_cart_info/BeforehandOrderCartInfoLists.php b/app/admin/lists/beforehand_order_cart_info/BeforehandOrderCartInfoLists.php index 838354948..7e8ed2422 100644 --- a/app/admin/lists/beforehand_order_cart_info/BeforehandOrderCartInfoLists.php +++ b/app/admin/lists/beforehand_order_cart_info/BeforehandOrderCartInfoLists.php @@ -11,6 +11,7 @@ use app\common\model\store_product\StoreProduct; use app\common\model\warehouse_product_storege\WarehouseProductStorege; use app\common\lists\ListsExcelInterface; use app\common\model\beforehand_order\BeforehandOrder; +use app\common\model\store_category\StoreCategory; use app\common\model\store_product_unit\StoreProductUnit; use app\common\model\system_store\SystemStore; @@ -23,6 +24,7 @@ class BeforehandOrderCartInfoLists extends BaseAdminDataLists implements ListsSe { public $list; + public $fileName; /** * @notes 设置搜索条件 @@ -49,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'); @@ -56,18 +69,22 @@ 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']; + $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) { @@ -103,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; } @@ -128,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; }