From 9760d34129fcb0de7e488e780af8ce5008952acf Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 1 Jun 2024 18:02:02 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E9=97=A8=E5=BA=97?= =?UTF-8?q?=E5=95=86=E5=93=81=E8=BE=85=E5=8A=A9=E6=8E=A7=E5=88=B6=E5=99=A8?= =?UTF-8?q?=E5=8F=8A=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StoreBranchProductController.php | 95 +++++++++++++++++++ .../logic/store_product/StoreProductLogic.php | 5 +- app/queue/redis/CopyProductSend.php | 3 +- 3 files changed, 99 insertions(+), 4 deletions(-) create mode 100644 app/admin/controller/store_branch_product/StoreBranchProductController.php diff --git a/app/admin/controller/store_branch_product/StoreBranchProductController.php b/app/admin/controller/store_branch_product/StoreBranchProductController.php new file mode 100644 index 000000000..de64c7069 --- /dev/null +++ b/app/admin/controller/store_branch_product/StoreBranchProductController.php @@ -0,0 +1,95 @@ +dataLists(new StoreProductLists()); + } + + + /** + * @notes 添加门店商品辅助列表 + * @return \think\response\Json + * @author likeadmin + * @date 2024/05/31 10:53 + */ + public function add() + { + $params = (new StoreProductValidate())->post()->goCheck('add'); + $result = StoreProductLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(StoreProductLogic::getError()); + } + + + /** + * @notes 编辑门店商品辅助列表 + * @return \think\response\Json + * @author likeadmin + * @date 2024/05/31 10:53 + */ + public function edit() + { + $params = (new StoreProductValidate())->post()->goCheck('edit'); + $result = StoreProductLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(StoreProductLogic::getError()); + } + + + /** + * @notes 删除门店商品辅助列表 + * @return \think\response\Json + * @author likeadmin + * @date 2024/05/31 10:53 + */ + public function delete() + { + $params = (new StoreProductValidate())->post()->goCheck('delete'); + StoreProductLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取门店商品辅助列表详情 + * @return \think\response\Json + * @author likeadmin + * @date 2024/05/31 10:53 + */ + public function detail() + { + $params = (new StoreProductValidate())->goCheck('detail'); + $result = StoreProductLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/admin/logic/store_product/StoreProductLogic.php b/app/admin/logic/store_product/StoreProductLogic.php index 53cb197c7..a74942a9b 100644 --- a/app/admin/logic/store_product/StoreProductLogic.php +++ b/app/admin/logic/store_product/StoreProductLogic.php @@ -195,7 +195,7 @@ class StoreProductLogic extends BaseLogic /** * 复制商品到门店 */ - public static function copy($id, $store_id) + 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(); @@ -214,14 +214,13 @@ class StoreProductLogic extends BaseLogic 'price' => $find['price'], 'store_id' => $store_id, 'sales' => 0, - 'stock' => 0, + 'stock' => $stock, ]; StoreBranchProduct::create($product); $arr = [ 'product_id' => $id, 'store_id' => $store_id, 'sales' => 0, - 'stock' => 0, 'type' => 0, 'bar_code' => $attr_value['bar_code'] ]; diff --git a/app/queue/redis/CopyProductSend.php b/app/queue/redis/CopyProductSend.php index c3c58fc22..05866eadb 100644 --- a/app/queue/redis/CopyProductSend.php +++ b/app/queue/redis/CopyProductSend.php @@ -21,8 +21,9 @@ class CopyProductSend implements Consumer public function consume($data) { $store_arr=$data['store_arr']; + $stock=$data['stock']??0; foreach ($store_arr as $key => $id) { - StoreProductLogic::copy($data['product_id'],$id); + StoreProductLogic::copy($data['product_id'],$id,$stock); } } public function onConsumeFailure(\Throwable $e, $package)