wesmiler hace 9 horas
padre
commit
7ca7e24f12
Se han modificado 1 ficheros con 3 adiciones y 2 borrados
  1. 3 2
      app/Services/Api/GoodsService.php

+ 3 - 2
app/Services/Api/GoodsService.php

@@ -360,10 +360,11 @@ class GoodsService extends BaseService
                     }
                     $item['price'] = $price;
                     $item['bd_score'] = $bdScore;
-                    $item['cost_price'] = $costPrice;
                     $item['total'] = $price;
+                    $costTotal = round(max(0,($costPrice) * $num),2);
                     $profitTotal = round(max(0,($price-$costPrice) * $num),2);
                     $netProfit = round($profitTotal * $profitRate/100, 2);
+                    $item['cost_price'] = $costTotal;
                     $item['profit_total'] = $profitTotal; // 毛利
                     $item['net_profit'] = $netProfit; // 净利润
                     $item['num'] = $num;
@@ -375,7 +376,7 @@ class GoodsService extends BaseService
                     $result['order_total'] += $total;
                     $result['bd_score_total'] += $bdScore;
                     $result['profit_total'] += $profitTotal;
-                    $result['cost_total'] += $costPrice;
+                    $result['cost_total'] += $costTotal;
                     $result['net_profit'] += $netProfit;
                     $result['count']++;
                 }