feat(StoreOrderLogic): 修改订单逻辑,简化折扣计算,调整利润计算方法
This commit is contained in:
parent
ae5f0044b3
commit
a1b54043d2
@ -48,7 +48,7 @@ class StoreOrderLogic extends BaseLogic
|
||||
/** 计算价格 */
|
||||
$check = DictType::where('type', 'activities')->find();
|
||||
foreach ($cart_select as $k => $v) {
|
||||
$find = StoreBranchProduct::where(['product_id' => $v['product_id'],'store_id'=>$params['store_id']])->field('id branch_product_id,store_name,image,unit,price,cost,product_id')->find();
|
||||
$find = StoreBranchProduct::where(['product_id' => $v['product_id'],'store_id'=>$params['store_id']])->field('id branch_product_id,store_name,image,unit,cost price,cost,product_id')->find();
|
||||
if (!$find) {
|
||||
continue;
|
||||
}
|
||||
@ -57,17 +57,9 @@ class StoreOrderLogic extends BaseLogic
|
||||
$cart_select[$k]['price'] = $find['price'];
|
||||
$cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价
|
||||
$cart_select[$k]['deduction_price'] =self::$activity_price;//抵扣金额
|
||||
if (isset($check) && $check['status'] == 1) {
|
||||
//零售价*折扣率
|
||||
$activity_price = bcmul($find['price'], 0.9, 2);
|
||||
$deduction_price_count=bcmul(bcsub($find['price'], $activity_price, 2),$v['cart_num'], 2);
|
||||
$cart_select[$k]['deduction_price'] =$deduction_price_count;
|
||||
self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2);
|
||||
$find['price'] = $activity_price;
|
||||
}
|
||||
|
||||
//利润
|
||||
$onePrice = bcsub($find['price'], $find['cost'], 2);
|
||||
$cart_select[$k]['profit'] = bcmul($v['cart_num'], $onePrice, 2); //利润
|
||||
$cart_select[$k]['profit'] = bcmul($cart_select[$k]['total_price'],0.05,2); //利润
|
||||
$cart_select[$k]['cost'] = bcmul($v['cart_num'], $find['cost'], 2) ?? 0; //成本
|
||||
$cart_select[$k]['pay_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单支付金额
|
||||
$cart_select[$k]['product_id'] = $find['product_id'];
|
||||
|
Loading…
x
Reference in New Issue
Block a user