Browse Source

会员升级

Kirin 7 months ago
parent
commit
fcc65d7a45

+ 3 - 0
app/services/order/StoreCartServices.php

@@ -456,6 +456,7 @@ class StoreCartServices extends BaseServices
             if ($type == 8) $info['is_luck'] = true;
             $info['trueStock'] = $info['productInfo']['attrInfo']['stock'] ?? 0;
             $info['costPrice'] = $info['productInfo']['attrInfo']['cost'] ?? 0;
+            $info['awardPrice'] = $info['productInfo']['attrInfo']['award_price'] ?? 0;
             try {
                 CacheService::redisHandler()->set($key, $info, 3600);
             } catch (\Throwable $e) {
@@ -1008,6 +1009,7 @@ class StoreCartServices extends BaseServices
 
             if (isset($productInfo['attrInfo']['product_id']) && $item['product_attr_unique']) {
                 $item['costPrice'] = $productInfo['attrInfo']['cost'] ?? 0;
+                $item['awardPrice'] = $productInfo['attrInfo']['award_price'] ?? 0;
                 $item['trueStock'] = $item['branch_stock'] = $productInfo['attrInfo']['stock'] ?? 0;
                 $item['branch_sales'] = $productInfo['attrInfo']['sales'] ?? 0;
                 $item['truePrice'] = $productInfo['attrInfo']['price'] ?? 0;
@@ -1020,6 +1022,7 @@ class StoreCartServices extends BaseServices
                 }
             } else {
                 $item['costPrice'] = $item['productInfo']['cost'] ?? 0;
+                $item['awardPrice'] = $item['productInfo']['award_price'] ?? 0;
                 $item['trueStock'] = $item['branch_sales'] = $item['productInfo']['stock'] ?? 0;
                 $item['branch_sales'] = $item['productInfo']['sales'] ?? 0;
                 $item['truePrice'] = $item['productInfo']['price'] ?? 0;

+ 33 - 32
app/services/order/StoreOrderComputedServices.php

@@ -353,37 +353,37 @@ class StoreOrderComputedServices extends BaseServices
         $deductionPrice = 0;
         $usedIntegral = 0;
         if ($userInfo && $useIntegral && $userInfo['integral'] > 0 && $payPrice) {
-			$integralMaxType = sys_config('integral_max_type', 1);//积分抵用上限类型1:积分、2:订单金额比例
-			if ($integralMaxType == 1) {//最多抵用积分
-				$integralMaxNum = sys_config('integral_max_num', 200);
-				if ($integralMaxNum > 0 && $userInfo['integral'] > $integralMaxNum) {
-					$integral = $integralMaxNum;
-				} else {
-					$integral = $userInfo['integral'];
-				}
-				$deductionPrice = (float)bcmul((string)$integral, (string)$other['integralRatio'], 2);
-				if ($deductionPrice < $payPrice) {
-					$payPrice = bcsub((string)$payPrice, (string)$deductionPrice, 2);
-					$usedIntegral = $integral;
-				} else {
-					if ($other['integralRatio']) {
-						$deductionPrice = $payPrice;
-						$usedIntegral = (int)ceil(bcdiv((string)$payPrice, (string)$other['integralRatio'], 2));
-					}
-					$payPrice = 0;
-				}
-			} else {//最高抵用比率
-				$integralMaxRate = sys_config('integral_max_rate', 0);
-				$deductionPrice = (float)bcmul((string)$userInfo['integral'], (string)$other['integralRatio'], 2);
-				if ($integralMaxRate > 0 && $integralMaxRate <= 100) {
-					$integralMaxPrice = (float)bcmul((string)$payPrice, (string)bcdiv((string)$integralMaxRate, '100', 2), 2);
-				} else {
-					$integralMaxPrice = $payPrice;
-				}
-				$deductionPrice = min($deductionPrice, $integralMaxPrice);
-				$payPrice = bcsub((string)$payPrice, (string)$deductionPrice, 2);
-				$usedIntegral = ceil(bcdiv((string)$deductionPrice, (string)$other['integralRatio'], 2));
-			}
+            $integralMaxType = sys_config('integral_max_type', 1);//积分抵用上限类型1:积分、2:订单金额比例
+            if ($integralMaxType == 1) {//最多抵用积分
+                $integralMaxNum = sys_config('integral_max_num', 200);
+                if ($integralMaxNum > 0 && $userInfo['integral'] > $integralMaxNum) {
+                    $integral = $integralMaxNum;
+                } else {
+                    $integral = $userInfo['integral'];
+                }
+                $deductionPrice = (float)bcmul((string)$integral, (string)$other['integralRatio'], 2);
+                if ($deductionPrice < $payPrice) {
+                    $payPrice = bcsub((string)$payPrice, (string)$deductionPrice, 2);
+                    $usedIntegral = $integral;
+                } else {
+                    if ($other['integralRatio']) {
+                        $deductionPrice = $payPrice;
+                        $usedIntegral = (int)ceil(bcdiv((string)$payPrice, (string)$other['integralRatio'], 2));
+                    }
+                    $payPrice = 0;
+                }
+            } else {//最高抵用比率
+                $integralMaxRate = sys_config('integral_max_rate', 0);
+                $deductionPrice = (float)bcmul((string)$userInfo['integral'], (string)$other['integralRatio'], 2);
+                if ($integralMaxRate > 0 && $integralMaxRate <= 100) {
+                    $integralMaxPrice = (float)bcmul((string)$payPrice, (string)bcdiv((string)$integralMaxRate, '100', 2), 2);
+                } else {
+                    $integralMaxPrice = $payPrice;
+                }
+                $deductionPrice = min($deductionPrice, $integralMaxPrice);
+                $payPrice = bcsub((string)$payPrice, (string)$deductionPrice, 2);
+                $usedIntegral = ceil(bcdiv((string)$deductionPrice, (string)$other['integralRatio'], 2));
+            }
             if ($payPrice <= 0) $payPrice = 0;
         }
         $SurplusIntegral = (int)bcsub((string)$userInfo['integral'], (string)$usedIntegral, 0);
@@ -457,6 +457,7 @@ class StoreOrderComputedServices extends BaseServices
         $sumPrice = $this->getOrderSumPrice($cartInfo, 'sum_price');//获取订单原总金额
         $totalPrice = $this->getOrderSumPrice($cartInfo, 'truePrice');//获取订单svip、用户等级优惠之后总金额
         $costPrice = $this->getOrderSumPrice($cartInfo, 'costPrice');//获取订单成本价
+        $awardPrice = $this->getOrderSumPrice($cartInfo, 'awardPrice');//获取订单成本价
         $vipPrice = $this->getOrderSumPrice($cartInfo, 'vip_truePrice');//获取订单会员优惠金额
 
         //如果满额包邮等于0
@@ -679,7 +680,7 @@ class StoreOrderComputedServices extends BaseServices
             }
 
         }
-        return compact('storePostage', 'storeFreePostage', 'isStoreFreePostage', 'sumPrice', 'totalPrice', 'costPrice', 'vipPrice', 'storePostageDiscount', 'cartInfo');
+        return compact('storePostage', 'awardPrice', 'storeFreePostage', 'isStoreFreePostage', 'sumPrice', 'totalPrice', 'costPrice', 'vipPrice', 'storePostageDiscount', 'cartInfo');
     }
 
     /**

+ 2 - 0
app/services/order/StoreOrderCreateServices.php

@@ -141,6 +141,7 @@ class StoreOrderCreateServices extends BaseServices
         $priceData = $computedServices->computedOrder($uid, $userInfo, $cartGroup, $addressId, $payType, $useIntegral, $couponId, $shippingType);
         $cartInfo = $cartGroup['cartInfo'];
         $priceGroup = $cartGroup['priceGroup'];
+        if ($priceGroup['awardPrice'] > 0 && $useIntegral) throw new ValidateException('增值商品不能使用消费分抵扣!');
         $cartIds = [];
         $totalNum = 0;
         $gainIntegral = 0;
@@ -217,6 +218,7 @@ class StoreOrderCreateServices extends BaseServices
             'activity_id' => $activity_id,
             'pink_id' => $pinkId,
             'cost' => $priceGroup['costPrice'],
+            'award_price' => $priceGroup['awardPrice'],
             'is_channel' => $isChannel,
             'add_time' => time(),
             'unique' => $key,