From 7eaa1db32eba0c366da3644d85dc34a0239dee72 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 10 Aug 2024 19:48:18 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=BA=93=E5=AD=98=E9=80=BB=E8=BE=91=EF=BC=8C=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=BA=93=E5=AD=98=E6=A3=80=E6=9F=A5=E4=B8=8E=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E5=A4=84=E7=90=86=EF=BC=8C=E5=A2=9E=E5=BC=BA=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=AE=89=E5=85=A8=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store_product/StoreProductController.php | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/app/admin/controller/store_product/StoreProductController.php b/app/admin/controller/store_product/StoreProductController.php index b4f1ecd2..2849be26 100644 --- a/app/admin/controller/store_product/StoreProductController.php +++ b/app/admin/controller/store_product/StoreProductController.php @@ -7,6 +7,7 @@ use app\admin\controller\BaseAdminController; use app\admin\lists\store_product\StoreProductLists; use app\admin\logic\store_product\StoreProductLogic; use app\admin\validate\store_product\StoreProductValidate; +use app\common\model\store_product\StoreProduct; use app\common\model\warehouse_product_storege\WarehouseProductStorege; use Webman\RedisQueue\Redis; @@ -101,26 +102,31 @@ class StoreProductController extends BaseAdminController $store_arr = $this->request->post('store_arr'); $stock_type = $this->request->post('stock_type', 1); $warehouse_id = $this->request->post('warehouse_id'); - $count=count($store_arr); + $count = count($store_arr); foreach ($product_arr as $key => $arr) { - $stock=bcmul($arr['stock'],$count); - $nums=WarehouseProductStorege::where('warehouse_id',$warehouse_id)->where('product_id',$arr['id'])->value('nums'); - if($nums<$stock){ + $stock = bcmul($arr['stock'], $count); + $nums = WarehouseProductStorege::where('warehouse_id', $warehouse_id)->where('product_id', $arr['id'])->value('nums'); + if ($nums < $stock) { return $this->fail('商品库存不足'); } } if ($count == 1) { $store_id = $store_arr[0]; foreach ($product_arr as $key => $arr) { - Redis::send('store-storage', ['product_arr' => $arr, 'store_id' => $store_id, 'stock_type' => $stock_type, 'admin_id' => $this->adminId, 'warehouse_id' => $warehouse_id]); + $find = StoreProduct::where('id', $product_arr['id'])->findOrEmpty()->toArray(); + StoreProductLogic::ordinary($arr, $store_id, $this->adminId, $find, $warehouse_id); + + // Redis::send('store-storage', ['product_arr' => $arr, 'store_id' => $store_id, 'stock_type' => $stock_type, 'admin_id' => $this->adminId, 'warehouse_id' => $warehouse_id]); } } else { foreach ($product_arr as $key => $arr) { foreach ($store_arr as $k => $store_id) { - Redis::send('store-storage', ['product_arr' => $arr, 'store_id' => $store_id, 'stock_type' => $stock_type, 'admin_id' => $this->adminId, 'warehouse_id' => $warehouse_id]); + $find = StoreProduct::where('id', $product_arr['id'])->findOrEmpty()->toArray(); + StoreProductLogic::ordinary($arr, $store_id, $this->adminId, $find, $warehouse_id); + // Redis::send('store-storage', ['product_arr' => $arr, 'store_id' => $store_id, 'stock_type' => $stock_type, 'admin_id' => $this->adminId, 'warehouse_id' => $warehouse_id]); } } } - return $this->success('已导入后台队列,请在门店入库记录中查看',[],1,1); + return $this->success('已导入后台队列,请在门店入库记录中查看', [], 1, 1); } }