加价和订单bug

es
lqmac 8 months ago
parent 1978607b17
commit 816d66254d
  1. 2
      app/admin/controller/Goods.php
  2. 1
      app/api/controller/Goods.php
  3. 10
      app/api/model/Order.php
  4. 7
      app/job/service/goods/GoodsAddPrice.php

@ -357,7 +357,7 @@ class Goods extends Controller
->where('g.is_delete',0) ->where('g.is_delete',0)
->whereIn('c.category_id',$categoryIds) ->whereIn('c.category_id',$categoryIds)
->whereIn('g.channel', $channels) ->whereIn('g.channel', $channels)
->field(['g.goods_id']) ->field(['g.goods_id','g.cost_price_min'])
->group('g.goods_id') ->group('g.goods_id')
->order("g.goods_id asc") ->order("g.goods_id asc")
// ->limit(100) // ->limit(100)

@ -148,6 +148,7 @@ class Goods extends Controller
]; ];
break; break;
default: default:
if ($goods->stock_total >= ($value['num'] ?? 1)) { if ($goods->stock_total >= ($value['num'] ?? 1)) {
$res = "有货"; $res = "有货";
} }

@ -141,6 +141,11 @@ class Order extends OrderModel
$info = $info['storeInfo']->toArray(); $info = $info['storeInfo']->toArray();
foreach ($list['data'] as &$v) { foreach ($list['data'] as &$v) {
$v['storeInfo'] = $info; $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(); $v['delivery'] = DeliveryModel::where('order_id', $v['order_id'])->find();
} }
} }
@ -491,6 +496,11 @@ class Order extends OrderModel
if (!empty($info['storeInfo'])) { if (!empty($info['storeInfo'])) {
$order->storeInfo = $info['storeInfo']->toArray(); $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; return $order;
} }

@ -69,9 +69,10 @@ class GoodsAddPrice extends BaseService
continue; continue;
} }
$item = $goods_list[0]; $item = $goods_list[0];
if ($item['markup_rate'] > 0) { // if ($item['markup_rate'] > 0) {
$item['cost_price_min'] = round($item['cost_price_min'] * (1 - ($rate / 100)), 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); $cost_price = round($item['cost_price_min'] / (1 - ($rate / 100)), 0);
$profit = (float)$item['goods_price_min'] - (float)$cost_price; $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; $profit_rate = (float)$item['goods_price_min'] > 0 ? bcmul((string)($profit / (float)$item['goods_price_min']) , (string)100, 2) : 0.00;

Loading…
Cancel
Save