diff --git a/app/admin/controller/store_branch_product/StoreBranchProductController.php b/app/admin/controller/store_branch_product/StoreBranchProductController.php index 155c7274..2d3b59dd 100644 --- a/app/admin/controller/store_branch_product/StoreBranchProductController.php +++ b/app/admin/controller/store_branch_product/StoreBranchProductController.php @@ -70,13 +70,8 @@ class StoreBranchProductController extends BaseAdminController public function edit() { $params = $this->request->post(); - foreach ($params['data'] as $k => $v) { - StoreProductLogic::stock($v); - if (StoreProductLogic::hasError()) { - return $this->fail(StoreProductLogic::getError()); - } - } - return $this->success('操作成功,等待门店确认', [], 1, 1); + + return $this->fail('不能编辑'); } /** diff --git a/app/admin/lists/store_extract/StoreExtractLists.php b/app/admin/lists/store_extract/StoreExtractLists.php index 96677434..12c55043 100644 --- a/app/admin/lists/store_extract/StoreExtractLists.php +++ b/app/admin/lists/store_extract/StoreExtractLists.php @@ -60,7 +60,7 @@ class StoreExtractLists extends BaseAdminDataLists implements ListsSearchInterfa }else{ $name=$find['mobile']; } - $openid=UserAuth::where('uid',$find['id'])->value('openid'); + $openid=UserAuth::where('user_id',$find['id'])->value('openid'); $user_ship=UserShip::where('id',$find['user_ship'])->value('title'); $item->nickname=$name.'('.$user_ship.')'; $item->id_card=$find['id_card']; diff --git a/app/admin/logic/store_branch_product/StoreBranchProductLogic.php b/app/admin/logic/store_branch_product/StoreBranchProductLogic.php index dd1effd6..71dd4de2 100644 --- a/app/admin/logic/store_branch_product/StoreBranchProductLogic.php +++ b/app/admin/logic/store_branch_product/StoreBranchProductLogic.php @@ -65,25 +65,7 @@ class StoreBranchProductLogic extends BaseLogic 'unit'=>$params['unit'], 'status'=>$params['status'], ]; - if(isset($params['cate_id'])){ - if ($StoreProduct['cate_id'] != $params['cate_id']) { - self::store_product_cate_update($params['id'], $StoreProduct['cate_id'], $StoreProduct['store_id']); - } - $data['cate_id']=$params['cate_id']; - }else{ - if($params['status']!=$StoreProduct['status']){ - if($params['status']==1){ - StoreProductLogic::updateGoodsclass($StoreProduct['cate_id'],$StoreProduct['store_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); - Db::commit(); return true; } catch (\Exception $e) { @@ -92,22 +74,6 @@ class StoreBranchProductLogic extends BaseLogic return false; } } - - 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 &&$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,$store_id); - } - } /** * @notes 删除门店商品 * @param array $params diff --git a/app/admin/logic/store_product/StoreProductLogic.php b/app/admin/logic/store_product/StoreProductLogic.php index cb192b49..29a8b1e2 100644 --- a/app/admin/logic/store_product/StoreProductLogic.php +++ b/app/admin/logic/store_product/StoreProductLogic.php @@ -84,7 +84,6 @@ class StoreProductLogic extends BaseLogic foreach ($store_arr as $store_id) { Redis::send('store-storage', ['product_arr' => ['id' => $res['id'], 'stock' => 0], 'store_id' => $store_id, 'stock_type' => 1, 'admin_id' => Request()->adminId]); } - // Redis::send('copy-product', ['product_id' => $res['id'], 'store_arr' => $store_arr]); } else { if (is_array($params['store_arr']) && count($params['store_arr']) > 0) { foreach ($params['store_arr'] as $key => $store_id) { @@ -92,7 +91,6 @@ class StoreProductLogic extends BaseLogic Redis::send('store-storage', ['product_arr' => ['id' => $res['id'], 'stock' => 0], 'store_id' => $store_id, 'stock_type' => 1, 'admin_id' => Request()->adminId]); } } - // Redis::send('copy-product', ['product_id' => $res['id'], 'store_arr' => $params['store_arr']]); } } if (getenv('STORE_ID')) { @@ -267,90 +265,6 @@ class StoreProductLogic extends BaseLogic return $data; } - /** - * 更新商品分类 - */ - public static function updateGoodsclass($cate_id, $store_id = 0, $type = 0) - { - $one = StoreCategory::where('id', $cate_id)->find(); - if ($one) { - //查二级分类 - $two = StoreCategory::where('id', $one['pid'])->find(); - if ($two) { - if ($two['pid'] != 0) { - self::cate_update($cate_id, $two['id'], $store_id, 3); - self::cate_update($two['id'], $two['pid'], $store_id, 2); - self::cate_update($two['pid'], 0, $store_id, 1); - } else { - if ($one['pid'] == 0) { - self::cate_update($one['id'], 0, $store_id, 1); - } else { - self::cate_update($one['id'], $one['pid'], $store_id, 2); - self::cate_update($one['pid'], 0, $store_id, 1); - } - } - } - } - } - - public static function cate_update($cate_id = 0, $pid = 0, $store_id = 0, $level = 1) - { - $find = Db::name('store_product_cate')->where(['store_id' => $store_id, 'cate_id' => $cate_id, 'level' => $level])->find(); - if ($find) { - Db::name('store_product_cate')->where('id', $find['id'])->inc('count', 1)->update(); - } else { - Db::name('store_product_cate')->insert(['pid' => $pid, 'store_id' => $store_id, 'cate_id' => $cate_id, 'count' => 1, 'level' => $level, 'create_time' => time(), 'update_time' => time()]); - } - } - - /** - * 复制商品到门店 - */ - public static function copy($id, $store_id, $stock = 0) - { - $find = StoreProduct::where('id', $id)->findOrEmpty()->toArray(); - $store_find = StoreBranchProduct::where(['product_id' => $id, 'store_id' => $store_id])->findOrEmpty()->toArray(); - if ($find && !$store_find) { - $attr_value = StoreProductAttrValue::where('product_id', $id)->findOrEmpty(); - Db::startTrans(); - try { - $dealCate = self::dealChangeCate($find['cate_id']); - $product = [ - 'product_id' => $find['id'], - 'image' => $find['image'], - 'store_name' => $find['store_name'], - 'store_info' => $find['store_info'], - 'keyword' => $find['keyword'], - 'bar_code' => $find['bar_code'], - 'cate_id' => $find['cate_id'], - 'top_cate_id' => $dealCate['top_cate_id'], - 'two_cate_id' => $dealCate['two_cate_id'], - 'price' => $find['price'], - 'unit' => $find['unit'], - 'store_id' => $store_id, - 'sales' => 0, - 'stock' => $stock, - 'manufacturer_information' => $find['manufacturer_information'] ?? '', - ]; - StoreBranchProduct::create($product); - $arr = [ - 'product_id' => $id, - 'store_id' => $store_id, - 'sales' => 0, - 'type' => 0, - 'bar_code' => $attr_value['bar_code'] - ]; - StoreBranchProductAttrValue::create($arr); - Db::commit(); - return true; - } catch (\Exception $e) { - Db::rollback(); - self::setError($e->getMessage()); - return false; - } - } - } - /** * 删除门店商品 */ @@ -370,83 +284,47 @@ class StoreProductLogic extends BaseLogic } } - /** - * 增加库存 - */ - public static function stock($data) - { - Db::startTrans(); - try { - $find = StoreBranchProduct::where(['id' => $data['id']])->find(); - SystemStoreStorage::create([ - 'product_id' => $find['product_id'], - 'store_id' => $find['store_id'], - 'nums' => $data['stock'], - 'admin_id' => Request()->adminId, - ]); - Db::commit(); - return true; - } catch (\Exception $e) { - Db::rollback(); - self::setError($e->getMessage()); - return false; - } - } - /**普通 */ public static function ordinary($product_arr, $store_id, $admin_id, $find) { - $store_find = StoreBranchProduct::where(['product_id' => $product_arr['id'], 'store_id' => $store_id])->findOrEmpty()->toArray(); - if ($find && !$store_find) { - //创建门店商品 - $attr_value = StoreProductAttrValue::where('product_id', $product_arr['id'])->findOrEmpty(); - Db::startTrans(); - try { - $dealCate = self::dealChangeCate($find['cate_id']); - $product = [ - 'product_id' => $find['id'], - 'image' => $find['image'], - 'store_name' => $find['store_name'], - 'store_info' => $find['store_info'], - 'keyword' => $find['keyword'], - 'bar_code' => $find['bar_code'], - 'cate_id' => $find['cate_id'], - 'top_cate_id' => $dealCate['top_cate_id'], - 'two_cate_id' => $dealCate['two_cate_id'], - 'price' => $find['price'], - // 'cost' => $find['cost'], //v1.0 - 'cost' => $find['cost'], - 'purchase' => $find['purchase'], - 'vip_price' => $find['vip_price'], - 'manufacturer_information' => $find['manufacturer_information'] ?? '', - 'unit' => $find['unit'], - 'batch' => $find['batch'], - 'store_batch' => $find['store_batch'], - 'store_id' => $store_id, - 'sales' => 0, - 'product_type' => $find['product_type'], - 'stock' => 0, - 'rose' => $find['rose'], - ]; - $branch = StoreBranchProduct::create($product); - $arr = [ - 'product_id' => $product_arr['id'], - 'store_id' => $store_id, - 'unique' => setUnique($branch['id'], '', 0), - 'sales' => 0, - 'type' => 0, - 'bar_code' => $attr_value['bar_code'] - ]; - StoreBranchProductAttrValue::create($arr); - Db::commit(); - return $branch; - } catch (\Throwable $e) { - Db::rollback(); - Log::error('store-storage队列消费失败: ' . $e->getMessage() . ',line:' . $e->getLine() . ',file:' . $e->getFile()); - return false; - } - } + $dealCate = self::dealChangeCate($find['cate_id']); + $product = [ + 'product_id' => $find['id'], + 'image' => $find['image'], + 'store_name' => $find['store_name'], + 'store_info' => $find['store_info'], + 'keyword' => $find['keyword'], + 'bar_code' => $find['bar_code'], + 'cate_id' => $find['cate_id'], + 'top_cate_id' => $dealCate['top_cate_id'], + 'two_cate_id' => $dealCate['two_cate_id'], + 'price' => $find['price'], + // 'cost' => $find['cost'], //v1.0 + 'cost' => $find['cost'], + 'purchase' => $find['purchase'], + 'vip_price' => $find['vip_price'], + 'manufacturer_information' => $find['manufacturer_information'] ?? '', + 'unit' => $find['unit'], + 'batch' => $find['batch'], + 'store_batch' => $find['store_batch'], + 'store_id' => $store_id, + 'sales' => 0, + 'product_type' => $find['product_type'], + 'stock' => 0, + 'rose' => $find['rose'], + ]; + $branch = StoreBranchProduct::create($product); + $arr = [ + 'product_id' => $product_arr['id'], + 'store_id' => $store_id, + 'unique' => setUnique($branch['id'], '', 0), + 'sales' => 0, + 'type' => 0, + 'bar_code' => $find['bar_code'] + ]; + StoreBranchProductAttrValue::create($arr); + return $branch; } /**兑换 */ diff --git a/app/queue/redis/CopyProductSend.php b/app/queue/redis/CopyProductSend.php deleted file mode 100644 index c0854bdf..00000000 --- a/app/queue/redis/CopyProductSend.php +++ /dev/null @@ -1,48 +0,0 @@ - $id) { - StoreProductLogic::copy($data['product_id'],$id,0); - if($stock>0){ - $stocks=StoreProduct::where('id',$data['product_id'])->value('stock'); - if($stocks>=$stock){ - SystemStoreStorage::create(['product_id'=>$data['product_id'],'store_id'=>$id,'nums'=>$stock,'admin_id'=>$admin_id]);//设置库存 - StoreProduct::where('id',$data['product_id'])->dec('stock',$stock)->update();//减少库存 - }else{ - SystemStoreStorage::create(['product_id'=>$data['product_id'],'store_id'=>$id,'nums'=>$stock,'admin_id'=>$admin_id,'status'=>-1,'mark'=>'库存不足']);//设置库存 - - } - } - } - } - public function onConsumeFailure(\Throwable $e, $package) - { - $package['max_attempts']=0; - Log::error('复制商品失败product_id:'.$package['data']['product_id']); - return $package; - } -} \ No newline at end of file