feat: 添加会员待返回金额计算逻辑

This commit is contained in:
mkm 2024-07-03 16:51:32 +08:00
parent 5ac195ccfb
commit c668f34f29
2 changed files with 19 additions and 18 deletions

View File

@ -99,6 +99,7 @@ class OrderLogic extends BaseLogic
$cart_select[$k]['price'] = $price;
$cart_select[$k]['cost'] = $find['cost'];
$cart_select[$k]['vip'] = 0;
$cart_select[$k]['unit_name'] = StoreProductUnit::where(['id' => $find['unit']])->value('name')??''; //单位名称
//利润
// $cart_select[$k]['profit'] = bcmul($v['cart_num'], $onePrice, 2); //利润
@ -114,9 +115,17 @@ class OrderLogic extends BaseLogic
$cart_select[$k]['old_cart_id'] = $v['id'];
$cart_select[$k]['cart_num'] = $v['cart_num'];
$cart_select[$k]['verify_code'] = $params['verify_code'] ?? '';
//vip1待返回金额
$cart_select[$k]['vip_frozen_price'] = bcsub($cart_select[$k]['pay_price'], $cart_select[$k]['vip_price'], 2);
$cart_select[$k]['vip_frozen_price']=0;
//会员待返回金额
if ($user && $off_activity==0){
if($user['user_ship']==4){
//商户
$cart_select[$k]['vip_frozen_price'] = bcsub($cart_select[$k]['pay_price'], $cart_select[$k]['purchase'], 2);
}else{
//其他会员
$cart_select[$k]['vip_frozen_price'] = bcsub($cart_select[$k]['pay_price'],$cart_select[$k]['vip_price'], 2);
}
}
// d($cart_select[$k]['pay_price'],$cart_select[$k]['store_price'],$cart_select[$k]['vip_price'] );
$cartInfo = $cart_select[$k];
$cartInfo['name'] = $find['store_name'];
@ -136,17 +145,12 @@ class OrderLogic extends BaseLogic
// self::$profit = bcadd(self::$profit, $cart_select[$k]['profit'], 2);
}
//加支付方式限制
$pay_type = isset($params['pay_type']) ? $params['pay_type'] : 0;
if ($user && $user['user_ship'] == 1 && $pay_type != 17) {
$pay_price = self::$pay_price;
} else {
// $pay_type = isset($params['pay_type']) ? $params['pay_type'] : 0;
// if ($user && $user['user_ship'] == 1 && $pay_type != 17) {
// $pay_price = self::$pay_price;
// } else {
$pay_price = bcsub(self::$pay_price, self::$activity_price, 2); //减去活动优惠金额
}
// if($pay_price < 500){
// throw new Exception('金额低于500');
// }
// }
//成本价 收益
$order = [
'create_time' => time(),

View File

@ -744,11 +744,8 @@ class PayNotifyLogic extends BaseLogic
return false;
}
//纯在分销关系的时候要去判断分销出来的用户的采购款的额度 (只有会员按照这个逻辑拆分,其余的还是按照正常的支付金额)
if ($user_ship== 1 && $order['pay_type'] != PayEnum::CASH_PAY) {
$vipFrozenAmount = self::dealFrozenPrice($order['id']);
//为1的时候要去减活动价
$order['pay_price'] = bcsub($order['pay_price'], $vipFrozenAmount, 2);
//如果是会员需要返回会员金额
if ($user_ship>0 && $order['pay_type'] != PayEnum::CASH_PAY) {
self::dealVipAmount($order, $order['pay_type']);
}
if ($order['spread_uid'] > 0 || $user_ship > 0) {