diff --git a/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php b/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php index 0259c9ff5..be9419832 100644 --- a/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php +++ b/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php @@ -127,10 +127,13 @@ class BeforehandOrderCartInfoLogic extends BaseLogic if($params['bhoid']<=0){ throw new BusinessException('参数错误'); } - $count = PurchaseProductOffer::where(['order_id' => $params['bhoid'], 'is_storage' => 0, 'buyer_nums' => 0])->count('id'); + $count = PurchaseProductOffer::where(['order_id' => $params['bhoid'], 'buyer_confirm' => 0])->count('id'); $beforehandOrder = BeforehandOrder::where('id', $params['bhoid'])->field('order_type,warehousing_id')->find(); - if ($count > 0 || $beforehandOrder['warehousing_id'] > 0) { + if ($count > 0) { + throw new BusinessException('还有商品正在采购中,请先设置采购信息在入库'); + } + if ($beforehandOrder['warehousing_id'] > 0) { throw new BusinessException('请勿重复入库'); } $offer_list = PurchaseProductOffer::where(['order_id' => $params['bhoid'], 'is_storage' => 0])->select(); diff --git a/app/admin/logic/warehouse_product/WarehouseProductLogic.php b/app/admin/logic/warehouse_product/WarehouseProductLogic.php index 756dccfaa..e528840ed 100644 --- a/app/admin/logic/warehouse_product/WarehouseProductLogic.php +++ b/app/admin/logic/warehouse_product/WarehouseProductLogic.php @@ -130,7 +130,13 @@ class WarehouseProductLogic extends BaseLogic $total_price = bcmul($after_nums, $params['purchase'], 2); WarehouseProductStorege::update(['nums' => bcsub($storege['nums'], $params['nums']), 'total_price' => $total_price], ['id' => $storege['id']]); } else { - throw new BusinessException('仓库商品不存在' . '|' . $params['product_id']); + $data = [ + 'warehouse_id' => $params['warehouse_id'], + 'product_id' => $params['product_id'], + 'nums' => -$params['nums'], + 'total_price' => 0 + ]; + $storege = WarehouseProductStorege::create($data); } } else { $storege['nums'] = 0;