From e67ae33478d266b7058c423685b9a88dbe81a0f9 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 7 Feb 2025 10:49:23 +0800 Subject: [PATCH] =?UTF-8?q?feat(warehouse):=20=E6=B7=BB=E5=8A=A0=E5=95=86?= =?UTF-8?q?=E5=93=81=E7=8A=B6=E6=80=81=E4=BF=AE=E6=94=B9=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=B9=B6=E4=BC=98=E5=8C=96=E5=BA=93=E5=AD=98=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 WarehouseProductStoregeController 中添加 verify 方法,用于修改商品状态 - 在 WarehouseProductStoregeLists 中添加 is_verify 字段,用于显示商品状态 - 在 BeforehandOrderLogic 中重新启用并优化库存校验逻辑,提高系统稳定性 --- .../WarehouseProductStoregeController.php | 13 +++++++++++-- .../WarehouseProductStoregeLists.php | 3 ++- .../beforehand_order/BeforehandOrderLogic.php | 19 ++++++++++--------- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/app/admin/controller/warehouse_product_storege/WarehouseProductStoregeController.php b/app/admin/controller/warehouse_product_storege/WarehouseProductStoregeController.php index 103b4de6c..96e072939 100644 --- a/app/admin/controller/warehouse_product_storege/WarehouseProductStoregeController.php +++ b/app/admin/controller/warehouse_product_storege/WarehouseProductStoregeController.php @@ -7,7 +7,7 @@ use app\admin\controller\BaseAdminController; use app\admin\lists\warehouse_product_storege\WarehouseProductStoregeLists; use app\admin\logic\warehouse_product_storege\WarehouseProductStoregeLogic; use app\admin\validate\warehouse_product_storege\WarehouseProductStoregeValidate; - +use app\common\model\warehouse_product_storege\WarehouseProductStorege; /** * 仓库商品存储控制器 @@ -88,6 +88,15 @@ class WarehouseProductStoregeController extends BaseAdminController // $result = WarehouseProductStoregeLogic::detail($params); // return $this->data($result); // } - + /** + * @notes 修改商品状态 + * @return \think\response\Json + * @date 2024/05/31 10:53 + */ + public function verify(){ + $params=$this->request->post(); + WarehouseProductStorege::where('id',$params['id'])->update(['is_verify'=>$params['is_verify']]); + return $this->success('操作成功',[],1,1); + } } \ No newline at end of file diff --git a/app/admin/lists/warehouse_product_storege/WarehouseProductStoregeLists.php b/app/admin/lists/warehouse_product_storege/WarehouseProductStoregeLists.php index b5f7646cb..3e245892c 100644 --- a/app/admin/lists/warehouse_product_storege/WarehouseProductStoregeLists.php +++ b/app/admin/lists/warehouse_product_storege/WarehouseProductStoregeLists.php @@ -85,7 +85,7 @@ class WarehouseProductStoregeLists extends BaseAdminDataLists implements ListsSe } } return WarehouseProductStorege::where($this->searchWhere) - ->field(['id', 'warehouse_id', 'product_id', 'nums', 'price', 'total_price', 'status']) + ->field(['id','is_verify','warehouse_id', 'product_id', 'nums', 'price', 'total_price', 'status']) ->limit($this->limitOffset, $this->limitLength) ->order($this->sortOrder) ->select()->each(function ($item) { @@ -96,6 +96,7 @@ class WarehouseProductStoregeLists extends BaseAdminDataLists implements ListsSe $item->image = $find->image; $item->bar_code = $find->bar_code; $item->price = $find->price; + $item->vip_price = $find->vip_price; $item->cost = $find->cost; $item->purchase = $find->purchase; $item->store_info = $find->store_info; diff --git a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php index edd1f6a04..e7bbc14ad 100644 --- a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php +++ b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php @@ -377,19 +377,20 @@ class BeforehandOrderLogic extends BaseLogic throw new BusinessException('该订单已创建出库单'); } $info = BeforehandOrderCartInfo::where('bhoid', $params['bhoid'])->select()->toArray(); - // $product_column = array_column($info, 'product_id'); - // $storege_arr=WarehouseProductStorege::where('warehouse_id', $params['warehouse_id'])->where('product_id','in',$product_column)->select(); + $product_column = array_column($info, 'product_id'); + $storege_arr=WarehouseProductStorege::where('warehouse_id', $params['warehouse_id'])->where('product_id','in',$product_column)->select(); foreach ($info as $k => $v) { if ($v['pay_price'] <= 0) { throw new BusinessException('商品价格为空 不能生成出库订单,对应id:' . $v['id']); } - // foreach ($storege_arr as $key => $value) { - // if ($value['is_verify']==1 && $v['product_id'] == $value['product_id']) { - // if ($v['cart_num'] > $value['nums']) { - // throw new BusinessException('仓库库存不足 不能生成出库订单,对应id:' . $v['id']); - // } - // } - // } + foreach ($storege_arr as $key => $value) { + if ($value['is_verify']==1 && $v['product_id'] == $value['product_id']) { + if ($v['cart_num'] < $value['nums']) { + $store_name=StoreProduct::where('id', $v['product_id'])->withTrashed()->value('store_name'); + throw new BusinessException('商品:'.$store_name.'已开启强制库存校验,库存不足,库存数量' . $value['nums'].',需求数量:' . $v['cart_num']); + } + } + } } $count = BeforehandOrderCartInfo::where('bhoid', $params['bhoid'])->where('cart_num', 0)->count('id'); if ($count > 0) {