WIN-2308041133\Administrator 4 months ago
parent
commit
0910822236
2 changed files with 46 additions and 34 deletions
  1. 44 31
      app/models/store/StoreOrder.php
  2. 2 3
      app/models/store/StoreProduct.php

+ 44 - 31
app/models/store/StoreOrder.php

@@ -287,6 +287,7 @@ class StoreOrder extends BaseModel
             $userInfo = User::getUserInfo($uid);
             $userInfo = User::getUserInfo($uid);
             if (!$userInfo) return self::setErrorInfo('用户不存在!', true);
             if (!$userInfo) return self::setErrorInfo('用户不存在!', true);
             $cartGroup = self::getCacheOrderInfo($uid, $key);
             $cartGroup = self::getCacheOrderInfo($uid, $key);
+            @file_put_contents('cart.txt', json_encode($cartGroup) . "-购物车内容\r\n", 8);
             if (!$cartGroup) return self::setErrorInfo('订单已过期,请刷新当前页面!', true);
             if (!$cartGroup) return self::setErrorInfo('订单已过期,请刷新当前页面!', true);
             $cartInfo = $cartGroup['cartInfo'];
             $cartInfo = $cartGroup['cartInfo'];
             $priceGroup = $cartGroup['priceGroup'];
             $priceGroup = $cartGroup['priceGroup'];
@@ -316,6 +317,7 @@ class StoreOrder extends BaseModel
             $cartIds = [];
             $cartIds = [];
             $totalNum = 0;
             $totalNum = 0;
             $gainIntegral = 0;
             $gainIntegral = 0;
+            $is_type = 0;
             foreach ($cartInfo as $cart) {
             foreach ($cartInfo as $cart) {
                 $cartIds[] = $cart['id'];
                 $cartIds[] = $cart['id'];
                 $totalNum += $cart['cart_num'];
                 $totalNum += $cart['cart_num'];
@@ -324,6 +326,11 @@ class StoreOrder extends BaseModel
                 if (!$combinationId) $combinationId = $cart['combination_id'];
                 if (!$combinationId) $combinationId = $cart['combination_id'];
                 $cartInfoGainIntegral = isset($cart['productInfo']['give_integral']) ? bcmul($cart['cart_num'], $cart['productInfo']['give_integral'], 2) : 0;
                 $cartInfoGainIntegral = isset($cart['productInfo']['give_integral']) ? bcmul($cart['cart_num'], $cart['productInfo']['give_integral'], 2) : 0;
                 $gainIntegral = bcadd($gainIntegral, $cartInfoGainIntegral, 2);
                 $gainIntegral = bcadd($gainIntegral, $cartInfoGainIntegral, 2);
+                if ($cart['productInfo']['is_health']==1){
+                    $is_type = 4;
+                }elseif($cart['productInfo']['is_life']){
+                    $is_type = 5;
+                }
             }
             }
             $deduction = $seckill_id || $bargain_id || $combinationId;
             $deduction = $seckill_id || $bargain_id || $combinationId;
             if ($deduction) {
             if ($deduction) {
@@ -373,42 +380,48 @@ class StoreOrder extends BaseModel
                     return self::setErrorInfo('请选择门店', true);
                     return self::setErrorInfo('请选择门店', true);
                 }
                 }
             }
             }
-
-            //积分抵扣
-            $res2 = true;
-            $SurplusIntegral = $userInfo['integral'];
-            if ($payIntegral > 0) {
-                if ($userInfo['integral'] < $payIntegral) {
-                    return self::setErrorInfo('积分不足', true);
-                } else {
-                    $res2 = false !== User::bcDec($userInfo['uid'], 'integral', $payIntegral, 'uid');
+            if ($is_type==4||$is_type==5){
+                //佣金抵扣
+                $res2 = true;
+                $SurplusIntegral = $userInfo['brokerage_price'];
+            }else{
+                //积分抵扣
+                $res2 = true;
+                $SurplusIntegral = $userInfo['integral'];
+                if ($payIntegral > 0) {
+                    if ($userInfo['integral'] < $payIntegral) {
+                        return self::setErrorInfo('积分不足', true);
+                    } else {
+                        $res2 = false !== User::bcDec($userInfo['uid'], 'integral', $payIntegral, 'uid');
+                    }
+                    $SurplusIntegral = bcsub($userInfo['integral'], $payIntegral, 2);
+                    $res2 = $res2 && false != UserBill::expend('积分商品', $uid, 'integral', 'integral_product', $payIntegral, $key, $SurplusIntegral, '购买积分商品使用' . $payIntegral . '积分');
                 }
                 }
-                $SurplusIntegral = bcsub($userInfo['integral'], $payIntegral, 2);
-                $res2 = $res2 && false != UserBill::expend('积分商品', $uid, 'integral', 'integral_product', $payIntegral, $key, $SurplusIntegral, '购买积分商品使用' . $payIntegral . '积分');
-            }
 
 
-            //积分抵扣
-            if ($useIntegral && $SurplusIntegral > 0) {
-                $deductionPrice = (float)bcmul($SurplusIntegral, $other['integralRatio'], 2);
-                if ($deductionPrice < $payPrice) {
-                    $payPrice = bcsub($payPrice, $deductionPrice, 2);
-                    $usedIntegral = $SurplusIntegral;
-                    $SurplusIntegral = 0;
-                    $res2 = false !== User::edit(['integral' => 0], $userInfo['uid'], 'uid');
+                //积分抵扣
+                if ($useIntegral && $SurplusIntegral > 0) {
+                    $deductionPrice = (float)bcmul($SurplusIntegral, $other['integralRatio'], 2);
+                    if ($deductionPrice < $payPrice) {
+                        $payPrice = bcsub($payPrice, $deductionPrice, 2);
+                        $usedIntegral = $SurplusIntegral;
+                        $SurplusIntegral = 0;
+                        $res2 = false !== User::edit(['integral' => 0], $userInfo['uid'], 'uid');
+                    } else {
+                        $deductionPrice = $payPrice;
+                        $usedIntegral = (float)bcdiv($payPrice, $other['integralRatio'], 2);
+                        $SurplusIntegral = bcsub($SurplusIntegral, $usedIntegral, 2);
+                        $res2 = false !== User::bcDec($userInfo['uid'], 'integral', $usedIntegral, 'uid');
+                        $payPrice = 0;
+                    }
+                    $res2 = $res2 && false != UserBill::expend('积分抵扣', $uid, 'integral', 'deduction', $usedIntegral, $key, $SurplusIntegral, '购买商品使用' . floatval($usedIntegral) . '积分抵扣' . floatval($deductionPrice) . '元');
                 } else {
                 } else {
-                    $deductionPrice = $payPrice;
-                    $usedIntegral = (float)bcdiv($payPrice, $other['integralRatio'], 2);
-                    $SurplusIntegral = bcsub($SurplusIntegral, $usedIntegral, 2);
-                    $res2 = false !== User::bcDec($userInfo['uid'], 'integral', $usedIntegral, 'uid');
-                    $payPrice = 0;
+                    $deductionPrice = 0;
+                    $usedIntegral = 0;
                 }
                 }
-                $res2 = $res2 && false != UserBill::expend('积分抵扣', $uid, 'integral', 'deduction', $usedIntegral, $key, $SurplusIntegral, '购买商品使用' . floatval($usedIntegral) . '积分抵扣' . floatval($deductionPrice) . '元');
-            } else {
-                $deductionPrice = 0;
-                $usedIntegral = 0;
+                if (!$res2) return self::setErrorInfo('使用积分抵扣失败!', true);
+                if ($payPrice <= 0) $payPrice = 0;
+
             }
             }
-            if (!$res2) return self::setErrorInfo('使用积分抵扣失败!', true);
-            if ($payPrice <= 0) $payPrice = 0;
 
 
 
 
             if ($test) {
             if ($test) {

+ 2 - 3
app/models/store/StoreProduct.php

@@ -120,15 +120,14 @@ class StoreProduct extends BaseModel
                     $model->where('is_explosive', 1); //报单商品
                     $model->where('is_explosive', 1); //报单商品
                     break;
                     break;
                 case 4:
                 case 4:
-                    $model->where('is_bargain', 1);  //健康商品
+                    $model->where('is_health', 1);  //健康商品
                     break;
                     break;
                 case 5:
                 case 5:
-                    $model->where('is_seckill', 1);  //生活商品
+                    $model->where('is_life', 1);  //生活商品
                     break;
                     break;
 
 
             }
             }
         }
         }
-        
         $baseOrder = '';
         $baseOrder = '';
         if ($priceOrder) $baseOrder = $priceOrder == 'desc' ? 'price DESC' : 'price ASC';
         if ($priceOrder) $baseOrder = $priceOrder == 'desc' ? 'price DESC' : 'price ASC';
 //        if($salesOrder) $baseOrder = $salesOrder == 'desc' ? 'sales DESC' : 'sales ASC';//真实销量
 //        if($salesOrder) $baseOrder = $salesOrder == 'desc' ? 'sales DESC' : 'sales ASC';//真实销量