WIN-2308041133\Administrator 3 veckor sedan
förälder
incheckning
d6cf340cfc
2 ändrade filer med 42 tillägg och 13 borttagningar
  1. 3 3
      app/admin/view/store/store_product/create.php
  2. 39 10
      app/models/store/StoreOrder.php

+ 3 - 3
app/admin/view/store/store_product/create.php

@@ -343,7 +343,7 @@
                                                         <tr>
                                                             <th>图片<i class="red">*</i></th>
                                                             <th>售价<i class="red">*</i></th>
-                                                            <th>积分<i class="red">*</i></th>
+<!--                                                            <th>积分<i class="red">*</i></th>-->
                                                             <th>成本价</th>
                                                             <th>原价<i class="red">*</i></th>
                                                             <th>库存<i class="red">*</i></th>
@@ -487,7 +487,7 @@
                                                             <tr>
                                                                 <th>图片<i class="red">*</i></th>
                                                                 <th>售价<i class="red">*</i></th>
-                                                                <th>积分<i class="red">*</i></th>
+<!--                                                                <th>积分<i class="red">*</i></th>-->
                                                                 <th>成本价</th>
                                                                 <th>原价<i class="red">*</i></th>
                                                                 <th>库存<i class="red">*</i></th>
@@ -742,7 +742,7 @@
                                                         <tr>
                                                             <th>图片</th>
                                                             <th>售价</th>
-                                                            <th>积分</th>
+<!--                                                            <th>积分</th>-->
                                                             <th>成本价</th>
                                                             <th>原价</th>
                                                             <th>库存</th>

+ 39 - 10
app/models/store/StoreOrder.php

@@ -399,27 +399,56 @@ class StoreOrder extends BaseModel
                 $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 ($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);
+            $SurplusBrokerage = $userInfo['integral'];
+            //奖金抵扣
+            if ($useIntegral && $SurplusBrokerage > 0) {
+                $deductionPrice = (float)bcmul($SurplusBrokerage, $other['integralRatio'], 2);
                 if ($deductionPrice < $payPrice) {
                     $payPrice = bcsub($payPrice, $deductionPrice, 2);
-                    $usedIntegral = $SurplusIntegral;
-                    $SurplusIntegral = 0;
-                    $res2 = false !== User::edit(['integral' => 0], $userInfo['uid'], 'uid');
+                    $usedIntegral = $SurplusBrokerage;
+                    $SurplusBrokerage = 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');
+                    $SurplusBrokerage = bcsub($SurplusBrokerage, $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, 'integral', 'deduction', $usedIntegral, $key, $SurplusBrokerage, '购买商品使用' . floatval($usedIntegral) . '积分抵扣' . floatval($deductionPrice) . '元');
+                $res2 = $res2 && false != UserBill::expend('奖金抵扣', $uid, 'brokerage_price', 'deduction', $usedIntegral, $key, $SurplusBrokerage, '购买商品使用' . 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;
             if ($test) {
                 self::rollbackTrans();