From de148080fd464a275c9beea6045383af88471f4b Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Mon, 10 Jul 2023 16:45:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=95=86=E5=93=81=E5=85=A5?= =?UTF-8?q?=E5=BA=93=E6=95=B0=E9=87=8F=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store/product/ProductRepository.php | 51 ++++++++++--------- .../merchant/MerchantUpdateValidate.php | 3 +- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/app/common/repositories/store/product/ProductRepository.php b/app/common/repositories/store/product/ProductRepository.php index d8dc8b82..c8e718b7 100644 --- a/app/common/repositories/store/product/ProductRepository.php +++ b/app/common/repositories/store/product/ProductRepository.php @@ -2311,31 +2311,32 @@ class ProductRepository extends BaseRepository $price = $orderProduct['product_price'] ?? 0; $supplierMerId = $orderMerId ?? 0; } - if ($stockIn > 0) { - $attrValue->stock = $attrValue->stock + $stockIn; - $attrValue->save(); - $product->stock = $stockIn + $product->stock; - if (!$product->save()) { - throw new \Exception('商品库存保存失败'); - } - $model = new PurchaseRecord(); - $data = [ - 'order_id' => $params['order_id'] ?? 0, - 'order_product_id' => $params['order_product_id'] ?? 0, - 'product_id' => $product->product_id, - 'number' => $stockIn, - 'order_unique' => $params['order_unique'] ?? '', - 'unique' => $attrValue['unique'], - 'price' => $price, - 'mer_id' => $product->mer_id, - 'supplier_mer_id' => $supplierMerId, - ]; - if (!$model->save($data)) { - throw new \Exception('入库失败'); - } - if (isset($orderProduct) && !$orderProduct->save(['is_imported' => 1])) { - throw new \Exception('订单商品更新出错'); - } + if ($stockIn <= 0) { + throw new \Exception('入库数量不能小于等于0'); + } + $attrValue->stock = $attrValue->stock + $stockIn; + $attrValue->save(); + $product->stock = $stockIn + $product->stock; + if (!$product->save()) { + throw new \Exception('商品库存保存失败'); + } + $model = new PurchaseRecord(); + $data = [ + 'order_id' => $params['order_id'] ?? 0, + 'order_product_id' => $params['order_product_id'] ?? 0, + 'product_id' => $product->product_id, + 'number' => $stockIn, + 'order_unique' => $params['order_unique'] ?? '', + 'unique' => $attrValue['unique'], + 'price' => $price, + 'mer_id' => $product->mer_id, + 'supplier_mer_id' => $supplierMerId, + ]; + if (!$model->save($data)) { + throw new \Exception('入库失败'); + } + if (isset($orderProduct) && !$orderProduct->save(['is_imported' => 1])) { + throw new \Exception('订单商品更新出错'); } Db::commit(); } catch (\Exception $e) { diff --git a/app/validate/merchant/MerchantUpdateValidate.php b/app/validate/merchant/MerchantUpdateValidate.php index 80c6a53a..a70038cf 100644 --- a/app/validate/merchant/MerchantUpdateValidate.php +++ b/app/validate/merchant/MerchantUpdateValidate.php @@ -29,7 +29,8 @@ class MerchantUpdateValidate extends Validate 'mer_address|店铺地址' => 'require|max:128', 'long|店铺经度' => 'max:24', 'lat|店铺纬度' => 'max:24', - 'interest_rate|利率' => 'max:0.05', + 'interest_rate|利率' => 'min:0.01|max:0.1', + 'settle_cycle|结算周期' => 'min:15|max:90', ]; protected function isPhone($val)