From 0b26b8cfb2ed2211c6ce0e9a9190b67140f364a7 Mon Sep 17 00:00:00 2001 From: lewis <604446095@qq.com> Date: Thu, 9 Jan 2025 17:40:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AE=9A=E6=97=B6=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E5=87=BA=E5=BA=93=E5=95=86=E5=93=81=E4=BE=9B=E8=B4=A7?= =?UTF-8?q?=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../beforehand_order/BeforehandOrderLogic.php | 1 + .../WarehouseProductLogic.php | 1 + process/Task.php | 29 +++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php index c9bb6ffe8..f45fc4131 100644 --- a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php +++ b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php @@ -391,6 +391,7 @@ class BeforehandOrderLogic extends BaseLogic 'financial_pm' => 0, 'batch' => 0, 'mark' => $mark, + 'order_type' => $order['order_type'] ?? '', ]; $arr['delivery_time'] = strtotime($delivery_time); $res = WarehouseOrder::create($arr); diff --git a/app/admin/logic/warehouse_product/WarehouseProductLogic.php b/app/admin/logic/warehouse_product/WarehouseProductLogic.php index b7fc65f92..a1aa5a254 100644 --- a/app/admin/logic/warehouse_product/WarehouseProductLogic.php +++ b/app/admin/logic/warehouse_product/WarehouseProductLogic.php @@ -180,6 +180,7 @@ class WarehouseProductLogic extends BaseLogic 'unit' => $params['unit'] ?? 0, 'status' => 1, 'mark' => $params['mark'] ?? '', + 'order_type' => $params['order_type'] ?? '', ]; $res = WarehouseProduct::create($data); SqlChannelLog('WarehouseProduct', $res->id, $params['nums'], $params['financial_pm'] == 1 ? 1 : -1, Request()->url(),$admin_id); diff --git a/process/Task.php b/process/Task.php index fec68c71a..3206a152b 100644 --- a/process/Task.php +++ b/process/Task.php @@ -11,6 +11,7 @@ use app\common\model\store_order_cart_info\StoreOrderCartInfo; use app\common\model\store_product\StoreProduct; use app\common\model\store_product_price\StoreProductPrice; use app\common\model\user_recharge\UserRecharge; +use app\common\model\warehouse_product\WarehouseProduct; use support\Cache; use think\facade\Db; use Webman\RedisQueue\Redis; @@ -68,6 +69,7 @@ class Task $this->updateProductPrice(); $this->confirmProductPrice(); + $this->setPurchase(); } /** @@ -127,4 +129,31 @@ class Task }); } + /** + * 设置出库商品的供货价 + * @return void + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function setPurchase() + { + $list = WarehouseProduct::where('purchase', 0)->order('id desc')->limit(100)->select()->toArray(); + $productIds = array_unique(array_column($list, 'product_id')); + $products = StoreProduct::whereIn('id', $productIds)->field('id,purchase')->select()->toArray(); + $products = reset_index($products, 'id'); + $update = []; + foreach ($list as $item) { + $product = $products[$item['product_id']] ?? []; + if (empty($product) || empty($product['purchase'])) { + continue; + } + $update[] = [ + 'id' => $item['id'], + 'purchase' => min($product['purchase'], $item['price']), + ]; + } + (new WarehouseProduct())->saveAll($update); + } + }