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;