diff --git a/app/admin/lists/store_branch_product/StoreBranchProductLists.php b/app/admin/lists/store_branch_product/StoreBranchProductLists.php index ef57faf8d..a68875c98 100644 --- a/app/admin/lists/store_branch_product/StoreBranchProductLists.php +++ b/app/admin/lists/store_branch_product/StoreBranchProductLists.php @@ -28,7 +28,7 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI public function setSearch(): array { return [ - '=' => ['product_id', 'cate_id','store_id'], + '=' => ['product_id', 'cate_id','store_id','status'], '%pipe_like%' => ['store_name_code'=>'store_name|bar_code'], ]; } diff --git a/app/admin/logic/store_branch_product/StoreBranchProductLogic.php b/app/admin/logic/store_branch_product/StoreBranchProductLogic.php index 81a64a4ef..7222a920a 100644 --- a/app/admin/logic/store_branch_product/StoreBranchProductLogic.php +++ b/app/admin/logic/store_branch_product/StoreBranchProductLogic.php @@ -2,7 +2,7 @@ namespace app\admin\logic\store_branch_product; - +use app\admin\logic\store_product\StoreProductLogic; use app\common\model\store_branch_product\StoreBranchProduct; use app\common\logic\BaseLogic; use think\facade\Db; @@ -57,26 +57,26 @@ class StoreBranchProductLogic extends BaseLogic 'store_name'=>$params['store_name'], 'image'=>$params['image'], 'price'=>$params['price'], - 'bar_code'=>$params['bar_code'], 'unit'=>$params['unit'], 'status'=>$params['status'], ]; + $StoreProduct=StoreBranchProduct::where('id', $params['id'])->find(); if(isset($params['cate_id'])){ - $StoreProduct=StoreBranchProduct::where('id', $params['id'])->find(); if ($StoreProduct['cate_id'] != $params['cate_id']) { - $find=Db::name('store_product_cate')->where(['cate_id'=>$params['cate_id'],'store_id'=>$StoreProduct['store_id']])->find(); - if($find['pid']>0){ - $two=Db::name('store_product_cate')->where(['cate_id'=>$find['pid'],'store_id'=>$StoreProduct['store_id']])->find(); - Db::name('store_product_cate')->where('id',$find['id'])->dec('count',1)->update(); - Db::name('store_product_cate')->where('id',$two['id'])->dec('count',1)->update(); - if($two['pid']>0){ - Db::name('store_product_cate')->where('id',$two['pid'])->dec('count',1)->update(); - } - } - Redis::send('store-storage', ['product_arr' => ['id' => $params['id'], 'stock' => 0], 'store_id' =>$StoreProduct['store_id'], 'admin_id' => Request()->adminId]); - + self::store_product_cate_update($params['id'], $StoreProduct['cate_id'], $StoreProduct['store_id']); } $data['cate_id']=$params['cate_id']; + }else{ + if($params['statis']!=$StoreProduct['statis']){ + if($params['statis']==1){ + StoreProductLogic::updateGoodsclass($params['cate_id']); + }else{ + self::store_product_cate_update($params['id'], $StoreProduct['cate_id'], $StoreProduct['store_id'],0); + + } + } + self::store_product_cate_update($params['id'], $StoreProduct['cate_id'], $StoreProduct['store_id']); + } StoreBranchProduct::where('id', $params['id'])->update($data); @@ -89,7 +89,21 @@ class StoreBranchProductLogic extends BaseLogic } } - + public static function store_product_cate_update($id,$cate_id,$store_id,$type=1) + { + $find=Db::name('store_product_cate')->where(['cate_id'=>$cate_id,'store_id'=>$store_id])->find(); + if($find['pid']>0){ + $two=Db::name('store_product_cate')->where(['cate_id'=>$find['pid'],'store_id'=>$store_id])->find(); + Db::name('store_product_cate')->where('id',$find['id'])->dec('count',1)->update(); + Db::name('store_product_cate')->where('id',$two['id'])->dec('count',1)->update(); + if($two['pid']>0){ + Db::name('store_product_cate')->where('id',$two['pid'])->dec('count',1)->update(); + } + } + if($type==1){ + StoreProductLogic::updateGoodsclass($cate_id); + } + } /** * @notes 删除门店商品 * @param array $params