refactor(OrderLogic): 重构订单逻辑,移除VIP价格计算,修改支付价格计算方式

This commit is contained in:
mkm 2024-06-09 15:39:03 +08:00
parent ad9c637c50
commit b1e86f9249

View File

@ -88,11 +88,11 @@ class OrderLogic extends BaseLogic
$cartInfo['name'] = $find['store_name'];
$cartInfo['image'] = $find['image'];
//计算好vip价格
$vipPrice = self::dealVip($find['price']);
if ($vipPrice) {
$cartInfo['price'] = $vipPrice;
}
$cartInfo['vip_price'] = $cart_select[$k]['total'] - $vipPrice ?? 0;
// $vipPrice = self::dealVip($find['price']);
// if ($vipPrice) {
// $cartInfo['price'] = $vipPrice;
// }
$cartInfo['vip_price'] = 0;//$cart_select[$k]['total'] - $vipPrice ?? 0;
$cart_select[$k]['cart_info'] = json_encode($cartInfo);
//理论上每笔都是拆分了
$cart_select[$k]['name'] = $find['store_name'];
@ -106,13 +106,13 @@ class OrderLogic extends BaseLogic
$pay_price = self::$total;
// $check = StoreOrder::where('uid',\request()->userId)->count();//首单逻辑
$vipPrice = 0;
if (isset($check) && $check['status'] == 1) {
// if (isset($check) && $check['status'] == 1) {
// $discountRate = '0.99';//首单逻辑
// $pay_price 是价格
$discountRate = $check['remark'];//折扣
$discountRate = bcdiv($discountRate, '10', 2);
$pay_price = bcdiv(bcmul($pay_price, $discountRate, 4), '1', 2);
} else {
// $discountRate = $check['remark'];//折扣
// $discountRate = bcdiv($discountRate, '10', 2);
// $pay_price = bcdiv(bcmul($pay_price, $discountRate, 4), '1', 2);
// } else {
/* $userVip = User::where('id', \request()->userId)->value('user_ship');
if ($userVip) {
switch ($userVip) {
@ -137,11 +137,11 @@ class OrderLogic extends BaseLogic
$discountRate = bcdiv($discountRate, '100', 2);
$pay_price = bcdiv(bcmul($pay_price, $discountRate, 4), '1', 2);
}*/
}
if (!empty(self::$total) && !empty($pay_price)) {
bcscale(2);
$vipPrice = bcsub(self::$total, $pay_price, 2);
}
// }
// if (!empty(self::$total) && !empty($pay_price)) {
// bcscale(2);
// $vipPrice = bcsub(self::$total, $pay_price, 2);
// }
//成本价 收益
$order = [