refactor(OrderLogic): 修改订单逻辑以支持新活动与库存计算, 重构利润计算方式

This commit is contained in:
mkm 2024-06-09 15:53:17 +08:00
parent 49b49590c2
commit 067b9e1911

View File

@ -74,7 +74,7 @@ class OrderLogic extends BaseLogic
// $productBase = StoreProduct::where('id', $find['product_id'])->withTrashed()->field('price,ot_price,cost')->find();
if (isset($check) && $check['status'] == 1) {
self::$activity_price = bcadd(self::$activity_price, bcmul($find['price'],$find['cost'],2), 2);
self::$activity_price = bcadd(self::$activity_price, bcsub($find['price'],$find['cost'],2), 2);
$find['price'] = $find['cost'];
}
//利润
@ -162,7 +162,7 @@ class OrderLogic extends BaseLogic
'cart_id' => implode(',', $cartId),
'store_id' => $params['store_id'] ?? 0,
'shipping_type' => $params['shipping_type'] ?? 1,//配送方式 1=快递 2=门店自提
'activity' =>'九折',
'activity' =>'减免',
'activity_price' =>self::$activity_price,
'activities'=>$check,
];