From 02d6cd5e94d1e6326ecc867ef66feab25c08ad0f Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 13 Jan 2025 16:00:43 +0800 Subject: [PATCH] =?UTF-8?q?fix(admin):=20=E4=BC=98=E5=8C=96=E9=A2=84?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E4=BB=B7=E6=A0=BC=E8=AE=A1=E7=AE=97=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改了商品价格的计算方式,优先使用 vip_price - 如果 vip_price 为 0,则使用 StoreProductGroupPrice 中的价格 - 如果 StoreProductGroupPrice 中的价格也为 0,则使用商品的成本价 - 更新了 WarehouseProduct 表中的 vip_price 字段 --- .../beforehand_order/BeforehandOrderLogic.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php index 2590ec6a3..79b78a775 100644 --- a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php +++ b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php @@ -897,16 +897,24 @@ class BeforehandOrderLogic extends BaseLogic $pay_price = 0; $total_profit = 0; foreach ($data as $k => &$v) { - $find = StoreProduct::where('id', $v['product_id'])->field('top_cate_id,store_name,unit,after_sales')->withTrashed()->find(); + $find = StoreProduct::where('id', $v['product_id'])->field('top_cate_id,store_name,unit,after_sales,cost')->withTrashed()->find(); $v['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name'); $v['store_name'] = $find['store_name']; $v['mark'] = $find['after_sales']; - $v['purchase'] = $v['vip_price'];//StoreProductGroupPrice::where('product_id', $v['product_id'])->where('group_id', $user_ship)->value('price'); - if ($v['purchase']) { - $v['pay_price'] = bcmul($v['purchase'], $v['nums'], 2); + if ($v['vip_price'] > 0) { + $v['pay_price'] = bcmul($v['vip_price'], $v['nums'], 2); } else { - $v['pay_price'] = 0; + $price = StoreProductGroupPrice::where('product_id', $v['product_id'])->where('group_id', $user_ship)->value('price'); + if ($price > 0) { + $v['pay_price'] = bcmul($price, $v['nums'], 2); + } else { + $price = $find['cost']; + $v['pay_price'] = bcmul($price, $v['nums'], 2); + } + WarehouseProduct::where('id', $v['id'])->update(['vip_price' => $price]); } + + $v['purchase'] = $price; $v['profit'] = bcsub($v['total_price'], $v['pay_price'], 2); $total_profit = bcadd($total_profit, $v['profit'], 2); $pay_price = bcadd($pay_price, $v['pay_price'], 2);