Эх сурвалжийг харах

bugfix:会员升级,对下一级所需业绩与当前会员总业绩判定

kevin_zhangl 2 жил өмнө
parent
commit
83dc092722

+ 14 - 0
common/models/DeclarationLevel.php

@@ -159,6 +159,20 @@ class DeclarationLevel extends \common\components\ActiveRecord
         return static::find()->where('1=1')->indexBy('ID')->orderBy('SORT ASC')->asArray()->all();
     }
 
+    public static function getNextDecLv($decLvID)
+    {
+        $result = [];
+        $decLv = static::find()->where('1=1')->indexBy('ID')->orderBy('SORT ASC')->asArray()->all();
+        foreach ($decLv as $id => $item) {
+            if ($decLvID == $id) {
+                $result = next($decLv);
+                break;
+            }
+        }
+
+        return $result;
+    }
+
     /**
      *  更新缓存
      * @return array|\yii\db\ActiveRecord[]

+ 7 - 6
common/models/forms/DeclarationUpgradeForm.php

@@ -5,6 +5,7 @@ use common\components\Model;
 use common\helpers\Cache;
 use common\helpers\Date;
 use common\helpers\Form;
+use common\helpers\LoggerTool;
 use common\helpers\user\Cash;
 use common\helpers\user\Info;
 use common\models\Config;
@@ -223,14 +224,14 @@ class DeclarationUpgradeForm extends Model
                 }else if($checkPv < $decLevel['PERF']) {
                     throw new Exception(Yii::t('app', 'totalPVLessThan'), 400);
                 }
-                foreach ($decLevelConfig as $key=>$val){
-                    if($checkPv>=$val['PERF']){
-                        $toDecLevel = $key;
-                    }
-                }
-                if($this->decLv!=$toDecLevel){
+
+                // 会员已有PV+本次订单PV 不能多于 下一个级别所需PV
+                $nextDecLv = DeclarationLevel::getNextDecLv($toDecLevel);
+                LoggerTool::debug(['Ats', $nextDecLv, $checkPv]);
+                if ($nextDecLv && ($checkPv >= $nextDecLv['PERF'])) {
                     throw new Exception(Yii::t('app', 'totalPvExceedPv'), 400);
                 }
+
                 $this->_decAmount = $totalAmount;
                 $this->_decPv = $totalPv;
                 $this->_decAmountStandard = $totalAmountStandard;

+ 1 - 0
frontendApi/modules/v1/controllers/UserController.php

@@ -292,6 +292,7 @@ class UserController extends BaseController {
             if($userInstalmentInfo){
                 if ($userInstalmentInfo['ORDER_TYPE']=='BD' && $userInstalmentInfo['STAGE'] < 3){
                     $userInfo['LEVEL_LIST'] = DeclarationLevel::getNextAll(12);// 用户可选择的级别列表
+                    unset($userInfo['LEVEL_LIST'][$userDecId]);
                 }
             }
             // 循环列表,补充升级所需要的补差