WIN-2308041133\Administrator преди 5 месеца
родител
ревизия
5ea14c1438
променени са 1 файла, в които са добавени 48 реда и са изтрити 48 реда
  1. 48 48
      app/models/store/StoreOrder.php

+ 48 - 48
app/models/store/StoreOrder.php

@@ -383,76 +383,76 @@ class StoreOrder extends BaseModel
             }
 //            if ($is_type==4||$is_type==5){
                 //佣金抵扣
-                $res2 = true;
-                $SurplusIntegral = $userInfo['brokerage_price'];
-                if ($payIntegral > 0) {
-                    if ($userInfo['brokerage_price'] < $payIntegral) {
-                        return self::setErrorInfo('健康币不足', true);
-                    } else {
-                        $res2 = false !== User::bcDec($userInfo['uid'], 'brokerage_price', $payIntegral, 'uid');
-                    }
-                    $SurplusIntegral = bcsub($userInfo['brokerage_price'], $payIntegral, 2);
-                    $res2 = $res2 && false != UserBill::expend('积分商品', $uid, 'brokerage_price', 'brokerage_product', $payIntegral, $key, $SurplusIntegral, '购买健康商品使用' . $payIntegral . '健康币');
-                }
-//                健康币抵扣  $other['integralRatio']是积分抵扣比例
-                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(['brokerage_price' => 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'], 'brokerage_price', $usedIntegral, 'uid');
-                        $payPrice = 0;
-                    }
-                    $res2 = $res2 && false != UserBill::expend('健康币抵扣', $uid, 'brokerage_price', 'deduction', $usedIntegral, $key, $SurplusIntegral, '购买商品使用' . floatval($usedIntegral) . '健康币抵扣' . floatval($deductionPrice) . '元');
-                } else {
-                    $deductionPrice = 0;
-                    $usedIntegral = 0;
-                }
-                if (!$res2) return self::setErrorInfo('使用健康币抵扣失败!', true);
-                if ($payPrice <= 0) $payPrice = 0;
-
-//            }else{
-//                //积分抵扣
 //                $res2 = true;
-//                $SurplusIntegral = $userInfo['integral'];
+//                $SurplusIntegral = $userInfo['brokerage_price'];
 //                if ($payIntegral > 0) {
-//                    if ($userInfo['integral'] < $payIntegral) {
-//                        return self::setErrorInfo('健康不足', true);
+//                    if ($userInfo['brokerage_price'] < $payIntegral) {
+//                        return self::setErrorInfo('健康币不足', true);
 //                    } else {
-//                        $res2 = false !== User::bcDec($userInfo['uid'], 'integral', $payIntegral, 'uid');
+//                        $res2 = false !== User::bcDec($userInfo['uid'], 'brokerage_price', $payIntegral, 'uid');
 //                    }
-//                    $SurplusIntegral = bcsub($userInfo['integral'], $payIntegral, 2);
-//                    $res2 = $res2 && false != UserBill::expend('积分商品', $uid, 'integral', 'integral_product', $payIntegral, $key, $SurplusIntegral, '购买积分商品使用' . $payIntegral . '积分');
+//                    $SurplusIntegral = bcsub($userInfo['brokerage_price'], $payIntegral, 2);
+//                    $res2 = $res2 && false != UserBill::expend('积分商品', $uid, 'brokerage_price', 'brokerage_product', $payIntegral, $key, $SurplusIntegral, '购买健康商品使用' . $payIntegral . '健康币');
 //                }
-//
-//                //积分抵扣
+////                健康币抵扣  $other['integralRatio']是积分抵扣比例
 //                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');
+//                        $res2 = false !== User::edit(['brokerage_price' => 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');
+//                        $res2 = false !== User::bcDec($userInfo['uid'], 'brokerage_price', $usedIntegral, 'uid');
 //                        $payPrice = 0;
 //                    }
-//                    $res2 = $res2 && false != UserBill::expend('积分抵扣', $uid, 'integral', 'deduction', $usedIntegral, $key, $SurplusIntegral, '购买商品使用' . floatval($usedIntegral) . '积分抵扣' . floatval($deductionPrice) . '元');
+//                    $res2 = $res2 && false != UserBill::expend('健康币抵扣', $uid, 'brokerage_price', 'deduction', $usedIntegral, $key, $SurplusIntegral, '购买商品使用' . floatval($usedIntegral) . '健康币抵扣' . floatval($deductionPrice) . '元');
 //                } else {
 //                    $deductionPrice = 0;
 //                    $usedIntegral = 0;
 //                }
-//                if (!$res2) return self::setErrorInfo('使用积分抵扣失败!', true);
+//                if (!$res2) return self::setErrorInfo('使用健康币抵扣失败!', true);
 //                if ($payPrice <= 0) $payPrice = 0;
+
+//            }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 . '积分');
+                }
+
+                //积分抵扣
+                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 {
+                    $deductionPrice = 0;
+                    $usedIntegral = 0;
+                }
+                if (!$res2) return self::setErrorInfo('使用积分抵扣失败!', true);
+                if ($payPrice <= 0) $payPrice = 0;
 //
 //            }
             @file_put_contents('quanju.txt', $deductionPrice . "-抵扣金额\r\n", 8);