From 816d66254d5afd5d24e551cbd993bc7434e8d356 Mon Sep 17 00:00:00 2001 From: lqmac Date: Mon, 27 May 2024 20:58:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E4=BB=B7=E5=92=8C=E8=AE=A2=E5=8D=95bu?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/Goods.php | 2 +- app/api/controller/Goods.php | 1 + app/api/model/Order.php | 10 ++++++++++ app/job/service/goods/GoodsAddPrice.php | 7 ++++--- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/admin/controller/Goods.php b/app/admin/controller/Goods.php index 63099b90..6d5d6715 100644 --- a/app/admin/controller/Goods.php +++ b/app/admin/controller/Goods.php @@ -357,7 +357,7 @@ class Goods extends Controller ->where('g.is_delete',0) ->whereIn('c.category_id',$categoryIds) ->whereIn('g.channel', $channels) - ->field(['g.goods_id']) + ->field(['g.goods_id','g.cost_price_min']) ->group('g.goods_id') ->order("g.goods_id asc") // ->limit(100) diff --git a/app/api/controller/Goods.php b/app/api/controller/Goods.php index c1fe2ced..0ef059ad 100644 --- a/app/api/controller/Goods.php +++ b/app/api/controller/Goods.php @@ -148,6 +148,7 @@ class Goods extends Controller ]; break; default: + if ($goods->stock_total >= ($value['num'] ?? 1)) { $res = "有货"; } diff --git a/app/api/model/Order.php b/app/api/model/Order.php index 2b187e09..3fa55aae 100644 --- a/app/api/model/Order.php +++ b/app/api/model/Order.php @@ -141,6 +141,11 @@ class Order extends OrderModel $info = $info['storeInfo']->toArray(); foreach ($list['data'] as &$v) { $v['storeInfo'] = $info; + $total_num = 0; + foreach ($v['goods'] as $value) { + $total_num += $value['total_num'] ?? 0; + } + $v['total_num'] = $total_num; $v['delivery'] = DeliveryModel::where('order_id', $v['order_id'])->find(); } } @@ -491,6 +496,11 @@ class Order extends OrderModel if (!empty($info['storeInfo'])) { $order->storeInfo = $info['storeInfo']->toArray(); } + $total_num = 0; + foreach ($order->goods as $value) { + $total_num += $value->total_num ?? 0; + } + $order->total_num = $total_num; return $order; } diff --git a/app/job/service/goods/GoodsAddPrice.php b/app/job/service/goods/GoodsAddPrice.php index c9d9cc24..dabd7ded 100644 --- a/app/job/service/goods/GoodsAddPrice.php +++ b/app/job/service/goods/GoodsAddPrice.php @@ -69,9 +69,10 @@ class GoodsAddPrice extends BaseService continue; } $item = $goods_list[0]; - if ($item['markup_rate'] > 0) { - $item['cost_price_min'] = round($item['cost_price_min'] * (1 - ($rate / 100)), 0); - } + // if ($item['markup_rate'] > 0) { + // $item['cost_price_min'] = round($item['cost_price_min'] * (1 - ($rate / 100)), 0); + // } + $item['cost_price_min'] = $value['cost_price_min'];//设置原始数据的成本价 $cost_price = round($item['cost_price_min'] / (1 - ($rate / 100)), 0); $profit = (float)$item['goods_price_min'] - (float)$cost_price; $profit_rate = (float)$item['goods_price_min'] > 0 ? bcmul((string)($profit / (float)$item['goods_price_min']) , (string)100, 2) : 0.00;