Explorar el Código

Merge branch 'feature/3146-joway-4'

joway hace 2 años
padre
commit
86f635ea18

+ 1 - 0
backendApi/modules/v1/models/lists/log/AdminHandleList.php

@@ -162,6 +162,7 @@ class AdminHandleList extends \common\libs\dataList\DataList implements DataList
                 ['id'=>'恢复体系','name'=>\Yii::t('ctx', 'recoverySystem')],
                 ['id'=>'perf adjustment','name'=>'perf adjustment'],
                 ['id'=>'调整订单期数','name'=>\Yii::t('ctx', 'shopOrderPeriodAdjust')],
+                ['id'=>'调整会员最高聘级','name'=>\Yii::t('ctx', 'memberHighestEmpLvAdjust')],
                 ['id'=>'调整会员最高聘级','name'=> \Yii::t('ctx', 'adjustMemberHighestDirector')],
             ];
             $this->filterTypes = [

+ 2 - 0
common/messages/en-US/app.php

@@ -215,6 +215,8 @@ return [
     'brandAmbassadorUpgradeError' => 'Brand Ambassador upgrade error',
     'changeUserStatusError' => 'change user status error',
     'dataFormatError' => 'Data format error',
+    'decUserNameDoesNotExist' => '请输入报单中心编号',
+    'decUserNameIsWrong' => '报单中心编号输入错误',
 
 
 

+ 2 - 0
common/messages/en-US/ctx.php

@@ -388,6 +388,7 @@ return [
     'recoverySystem'  => 'Recovery system',
     'systemLog'  => 'System log',
     'shopOrderPeriodAdjust' => 'Order Period Adjust',
+    'memberHighestEmpLvAdjust' => 'Member Highest Director Adjustment',
     'call'  => 'Transfer',
     'beCcalled'  => 'called',
     'userOperatingLog'  => 'Member operation log',
@@ -724,6 +725,7 @@ return [
     'dbConfigExchangeRate' => '汇率配置',
     'dbConfigFlowBonusSwitch' => '奖金明细',
     'dbConfigFreeShipping' => '商品免运费阈值',
+    'dbConfigInstalmentQty' => '分期商品期数',
     'dbConfigFreight' => '商品运费',
     'dbConfigFwCoefficientFromFxCash' => '服务奖现金复消系数',
     'dbConfigFwCoefficientFromFxPoint' => '服务奖积分复消系数',

+ 3 - 1
common/messages/zh-CN/app.php

@@ -219,6 +219,8 @@ return [
     'membersExchangePointPayment' => '会员复销积分兑换',
     'brandAmbassadorUpgradeError' => 'BA会员升级错误',
     'changeUserStatusError' => '修改会员状态错误',
+    'decUserNameDoesNotExist' => '请输入报单中心编号',
+    'decUserNameIsWrong' => '报单中心编号输入错误',
 
 
     # 奖金
@@ -311,4 +313,4 @@ return [
     'invalidParameter' => '无效参数',
     'dataDoesNotExists' => '数据不存在',
 
-];
+];

+ 2 - 0
common/messages/zh-CN/ctx.php

@@ -388,6 +388,7 @@ return [
     'recoverySystem'  => '恢复体系',
     'systemLog'  => '系统日志',
     'shopOrderPeriodAdjust' => '订单期数调整',
+    'memberHighestEmpLvAdjust' => '调整会员总监级别',
     'call'  => '调用',
     'beCcalled'  => '被调用',
     'userOperatingLog'  => '会员操作日志',
@@ -728,6 +729,7 @@ return [
     'dbConfigExchangeRate' => '汇率配置',
     'dbConfigFlowBonusSwitch' => '奖金明细',
     'dbConfigFreeShipping' => '商品免运费阈值',
+    'dbConfigInstalmentQty' => '分期商品期数',
     'dbConfigFreight' => '商品运费',
     'dbConfigFwCoefficientFromFxCash' => '服务奖现金复消系数',
     'dbConfigFwCoefficientFromFxPoint' => '服务奖积分复消系数',

+ 1 - 1
common/models/ApproachOrder.php

@@ -70,7 +70,7 @@ class ApproachOrder extends \common\components\ActiveRecord
     public function rules()
     {
         return [
-            [['USER_ID', 'USER_NAME', 'ORDER_TYPE', 'CREATE_USER'], 'required'],
+            [['USER_ID',  'ORDER_TYPE', 'CREATE_USER'], 'required'],
             [['ORDER_AMOUNT', 'PV', 'PAY_AMOUNT', 'PAY_PV', 'FREIGHT', 'PAY_FREIGHT'], 'number'],
             [['PAY_AT', 'DELIVERY_STATUS', 'DELIVERY_PERIOD', 'DELIVERY_AT', 'EXPRESS_TYPE', 'PERIOD_NUM', 'STATUS', 'PROVINCE', 'CITY', 'COUNTY', 'CREATED_AT', 'UPDATED_AT', 'IS_DELETE', 'DELETED_AT'], 'integer'],
             [['ID','SN', 'DEC_SN', 'USER_ID', 'ORDER_TRACK_NO','PAY_TYPE'], 'string', 'max' => 32],

+ 1 - 1
common/models/DecOrder.php

@@ -47,7 +47,7 @@ class DecOrder extends \common\components\ActiveRecord
     public function rules()
     {
         return [
-            [['USER_ID', 'TO_USER_ID','REC_USER_ID','CON_USER_ID','DEC_ID', 'TYPE', 'PAID_WALLET', 'PERIOD_NUM', 'P_CALC_MONTH', 'CREATED_AT'], 'required'],
+            [['USER_ID', 'TO_USER_ID','REC_USER_ID','CON_USER_ID',/*'DEC_ID',*/ 'TYPE', 'PAID_WALLET', 'PERIOD_NUM', 'P_CALC_MONTH', 'CREATED_AT'], 'required'],
             [['IS_ADMIN', 'IS_BATCH', 'PERIOD_NUM', 'CALC_MONTH', 'CREATED_AT', 'IS_DEL', 'DELETED_AT'], 'integer'],
             [['DEC_AMOUNT', 'DEC_PV'], 'number'],
             [['ID', 'DEC_SN', 'ORDER_SN', 'USER_ID', 'TO_USER_ID','REC_USER_ID','CON_USER_ID','DEC_ID', 'TYPE', 'UPDATER', 'UPDATED_AT'], 'string', 'max' => 32],

+ 1 - 1
common/models/Order.php

@@ -70,7 +70,7 @@ class Order extends \common\components\ActiveRecord
     public function rules()
     {
         return [
-            [['USER_ID', 'USER_NAME', 'ORDER_TYPE', 'CREATE_USER'/*, 'EMAIL'*/], 'required'],
+            [['USER_ID', 'ORDER_TYPE', 'CREATE_USER'/*, 'EMAIL'*/], 'required'],
             [['ORDER_AMOUNT', 'PV', 'PAY_AMOUNT', 'PAY_PV', 'FREIGHT', 'PAY_FREIGHT', 'ORDER_AMOUNT_STANDARD', 'PAY_AMOUNT_STANDARD', 'EXCHANGE_RATE'], 'number'],
             [['PAY_AT', 'DELIVERY_STATUS', 'DELIVERY_PERIOD', 'DELIVERY_AT', 'EXPRESS_TYPE', 'PERIOD_NUM', 'STATUS', 'PROVINCE', /*'CITY', 'COUNTY', */'CREATED_AT', 'UPDATED_AT', 'IS_DELETE', 'DELETED_AT'], 'integer'],
             [['ID','SN', 'DEC_SN', 'USER_ID', 'ORDER_TRACK_NO','PAY_TYPE'], 'string', 'max' => 32],

+ 9 - 11
common/models/forms/ApproachDeclarationForm.php

@@ -127,10 +127,10 @@ class ApproachDeclarationForm extends Model
     {
         return [
             [['type','decLv','decWay','packageId', 'insertUserName', 'realName',/* 'insertUserIdCard',*/ 'mobile', 'address', 'openBank', 'bankAddress', 'bankNo','bankProvince','bankCity','bankCounty','consignee','acceptMobile','province','city','county','cityName','lgaName','decUserName', 'conUserName', 'recUserName', 'location'], 'trim'],
-            [['type','decLv','decWay','insertUserName',/* 'insertUserIdCard',*/'password','payPassword','decUserName'], 'required'],
+            [['type','decLv','decWay','insertUserName',/* 'insertUserIdCard',*/'password','payPassword'], 'required'],
             [['type'], 'isType', 'on'=>['userDec', 'canDec']],
             [['insertUserName'], 'isCanAddUser'],
-            [['decUserName', 'decType'], 'issetDec'],
+//            [['decUserName', 'decType'], 'issetDec'],
             [['conUserName'], 'isConUserName'],
             [['recUserName'], 'isRecUserName'],
             [['location'], 'isLocation'],
@@ -615,6 +615,7 @@ class ApproachDeclarationForm extends Model
             return null;
         }
 
+        $hasInstalment = 0;
         // 首购单,需要添加会员操作
         if($this->type == self::TYPE_ZC) {
             try {
@@ -649,7 +650,6 @@ class ApproachDeclarationForm extends Model
                     $totalAmount = 0;
                     $totalAmountStandard = 0;
                     $totalPv = 0;
-                    $hasInstalment = 0;
                     $exchangeRate = floatval(Cache::getSystemConfig()['exchangeRate']['VALUE'] ?? 0); // 汇率
                     foreach ($this->goodsNum as $k => $v) {
                         if ($v) {
@@ -682,10 +682,10 @@ class ApproachDeclarationForm extends Model
                         }
                     }
                     if($totalPv<$decLevel['PERF']){
-                        if ($hasInstalment && $decLevel['LEVEL_NAME'] == 'Elite'){
-                        }else{
+//                        if ($hasInstalment && $decLevel['LEVEL_NAME'] == 'Elite'){
+//                        }else{
                             throw new Exception(Yii::t('app', 'totalBVCanNotLessThanSelectedBV'));
-                        }
+//                        }
                     }
                     foreach ($decLevelConfig as $key => $val) {
                         if ($totalPv >= $val['PERF']) {
@@ -693,10 +693,10 @@ class ApproachDeclarationForm extends Model
                         }
                     }
                     if ($this->decLv != $toDecLevel) {
-                        if ($hasInstalment && $decLevel['LEVEL_NAME'] == 'Elite'){
-                        }else{
+//                        if ($hasInstalment && $decLevel['LEVEL_NAME'] == 'Elite'){
+//                        }else{
                             throw new Exception(Yii::t('app', 'totalBVCanNotLessThanNextSelectedLevelBV'));
-                        }
+//                        }
                     }
                     $this->_decAmount = $totalAmount;
                     $this->_decPv = $totalPv;
@@ -770,11 +770,9 @@ class ApproachDeclarationForm extends Model
         $user->VERIFIED = 1;
         $user->VERIFIED_AT = Date::nowTime();
         $user->IS_RECHARGE = 1;
-
         if (!$user->save()) {
             throw new Exception(Form::formatErrorsForApi($user->getErrors()));
         }
-
         $this->_insertUserId = $user->ID;
         $userForm = new UserForm();
         $this->_userForm = $userForm;

+ 0 - 3
common/models/forms/ApproachDeclarationLoopForm.php

@@ -177,7 +177,6 @@ class ApproachDeclarationLoopForm extends Model
                     }
 
                 }
-				
                 if (is_array($value)) {
                     foreach($value as $key=>$decFormData){
                         $model->$key = $decFormData;
@@ -201,9 +200,7 @@ class ApproachDeclarationLoopForm extends Model
                     throw new Exception(Yii::t('app', 'reportFormatIncorrect'));
                 }
             }
-
             $transaction->commit();
-
             return $result;
         } catch (\Exception $e){
             $transaction->rollBack();

+ 16 - 13
common/models/forms/ApproachOrderForm.php

@@ -1,6 +1,7 @@
 <?php
 namespace common\models\forms;
 
+use Codeception\Module\Db;
 use common\helpers\Cache;
 use common\helpers\Date;
 use common\components\Model;
@@ -51,6 +52,7 @@ class ApproachOrderForm extends Model
     public $email;
 
     public $userName;
+    public $decUserName;
     public $consignee;
     public $acceptMobile;
     public $province;
@@ -68,6 +70,7 @@ class ApproachOrderForm extends Model
     private $_orderGoods;
     private $_standardAmount;
     private $_decAmountStandard;
+    private $_userName;
 
     /**
      * @var ApproachOrder
@@ -347,13 +350,13 @@ class ApproachOrderForm extends Model
                         }
                     }
                     // 修改BA会员升级状态
-                    if ($orderType === 'baUpgrade') {
-                        // 查询BA会员名
-                        $userInfo = User::findOneAsArray('ID=:USER_ID', [':USER_ID' => $approachDecOrder['TO_USER_ID']]);
-                        if (!BaUser::updateAll(['WHETHER_UPGRADE' => 1, 'BA_UPGRADE_AT' => time()], 'USER_NAME=:USER_NAME', [':USER_NAME' => $userInfo['USER_NAME']])) {
-                            throw new Exception(Form::formatErrorsForApi(Yii::t('app', 'brandAmbassadorUpgradeError')));
-                        }
-                    }
+//                    if ($orderType === 'baUpgrade') {
+//                        // 查询BA会员名
+//                        $userInfo = User::findOneAsArray('ID=:USER_ID', [':USER_ID' => $approachDecOrder['TO_USER_ID']]);
+//                        if (!BaUser::updateAll(['WHETHER_UPGRADE' => 1, 'BA_UPGRADE_AT' => time()], 'USER_NAME=:USER_NAME', [':USER_NAME' => $userInfo['USER_NAME']])) {
+//                            throw new Exception(Form::formatErrorsForApi(Yii::t('app', 'brandAmbassadorUpgradeError')));
+//                        }
+//                    }
 
                     // 正式会员-升级单
                     if ($orderType === 'userUpgrade') {
@@ -405,13 +408,13 @@ class ApproachOrderForm extends Model
         if(!$this->validate()){
             return null;
         }
-
         $ids = $this->goodsId;
         $totalAmount = 0;
         $totalPv = 0;
         $totalAmountStandard = 0;
         $goodsType = ShopGoods::getGoodType();
         $hasInstalment = 0;
+        $loginUserId = \Yii::$app->user->id;
         $exchangeRate = floatval(Cache::getSystemConfig()['exchangeRate']['VALUE'] ?? 0); // 汇率
         foreach ($this->goodsNum as $k => $v) {
             if ($v) {
@@ -458,9 +461,11 @@ class ApproachOrderForm extends Model
                     if($v>1){ // 不可以购买多个
                         throw new Exception(Yii::t('app', 'allowOnlyOne'));
                     }
-                    $loginUserId = \Yii::$app->user->id;
+
                     $userStage = Instalment::getStage($loginUserId);
-                    if ($userStage==0 || $userStage == 3){
+                    // 分期的总期数
+                    $instalment = floatval(Cache::getSystemConfig()['instalment']['VALUE'] ?? 3);
+                    if ($userStage==0 || $userStage == $instalment){
 
                     }else{
                         if($userStage + 1 != $goods['INSTALMENT']){ // 若用户分期阶段+1不等于商品的分期阶段,则报异常
@@ -472,8 +477,6 @@ class ApproachOrderForm extends Model
             }
         }
 
-        // 汇率
-        $exchangeRate = floatval(Cache::getSystemConfig()['exchangeRate']['VALUE'] ?? 0);
         // 运费.奈拉
         $freight = floatval(Cache::getSystemConfig()['freight']['VALUE'] ?? 0);
         // 普通商品免运费阈值.奈拉
@@ -551,7 +554,7 @@ class ApproachOrderForm extends Model
         $orderModel->DEC_SN = 'DS' . $ordNo;
         $orderModel->ORDER_TYPE = $this->type;
         $orderModel->USER_ID = $userId;
-        $orderModel->USER_NAME = $userName;
+        $orderModel->USER_NAME = $this->decUserName;
         $orderModel->ORDER_AMOUNT = $this->_decAmount;
         $orderModel->PV = $_hasPV;
         $orderModel->PAY_AMOUNT = $this->_payAmount;

+ 5 - 4
common/models/forms/ApproachReconsumeOrderForm.php

@@ -415,6 +415,7 @@ class ApproachReconsumeOrderForm extends Model
         $totalAmountStandard = 0;
         $goodsType = ShopGoods::GOODS_TYPE;
         $hasInstalment = 0;
+        $loginUserId = \Yii::$app->user->id;
         $exchangeRate = floatval(Cache::getSystemConfig()['exchangeRate']['VALUE'] ?? 0); // 汇率
         foreach ($this->goodsNum as $k => $v) {
             if ($v) {
@@ -461,9 +462,11 @@ class ApproachReconsumeOrderForm extends Model
                     if($v>1){ // 不可以购买多个
                         throw new Exception(Yii::t('app', 'allowOnlyOne'));
                     }
-                    $loginUserId = \Yii::$app->user->id;
+
                     $userStage = Instalment::getStage($loginUserId);
-                    if ($userStage==0 || $userStage == 3){
+                    // 分期的总期数
+                    $instalment = floatval(Cache::getSystemConfig()['instalment']['VALUE'] ?? 3);
+                    if ($userStage==0 || $userStage == $instalment){
 
                     }else{
                         if($userStage + 1 != $goods['INSTALMENT']){ // 若用户分期阶段+1不等于商品的分期阶段,则报异常
@@ -475,8 +478,6 @@ class ApproachReconsumeOrderForm extends Model
             }
         }
 
-        // 汇率
-        $exchangeRate = floatval(Cache::getSystemConfig()['exchangeRate']['VALUE'] ?? 0);
         // 运费.奈拉
         $freight = floatval(Cache::getSystemConfig()['freight']['VALUE'] ?? 0);
         // 普通商品免运费阈值.奈拉

+ 14 - 14
common/models/forms/DeclarationForm.php

@@ -123,10 +123,10 @@ class DeclarationForm extends Model
     {
         return [
             [['type','decLv','decWay','packageId', 'insertUserName', 'realName',/* 'insertUserIdCard',*/ 'mobile', 'address', 'openBank', 'bankAddress', 'bankNo','bankProvince','bankCity','bankCounty','consignee','acceptMobile','province','city','county','cityName','lgaName','decUserName', 'conUserName', 'recUserName', 'location'], 'trim'],
-            [['type','decLv','decWay','insertUserName',/* 'insertUserIdCard',*/'password','payPassword','decUserName'], 'required'],
+            [['type','decLv','decWay','insertUserName',/* 'insertUserIdCard',*/'password','payPassword'], 'required'],
             [['type'], 'isType', 'on'=>['userDec', 'canDec']],
             [['insertUserName'], 'isCanAddUser'],
-            [['decUserName'], 'issetDec'],
+//            [['decUserName'], 'issetDec'],
             [['conUserName'], 'isConUserName'],
             [['recUserName'], 'isRecUserName'],
             [['location'], 'isLocation'],
@@ -180,7 +180,7 @@ class DeclarationForm extends Model
     {
         $parentScenarios =  parent::scenarios();
         $customScenarios = [
-            'userDec' => ['type','allData', 'decLv','decWay','insertUserName','password','payPassword', 'realName',/* 'insertUserIdCard',*/ 'mobile', 'address', 'openBank', 'bankAddress', 'bankNo', 'bankProvince','bankCity','bankCounty', 'consignee','acceptMobile','province',/*'city','county',*/ 'conUserName', 'recUserName','decUserName', 'location', 'email'],
+            'userDec' => ['type','allData', 'decLv','decWay','insertUserName','password','payPassword', 'realName',/* 'insertUserIdCard',*/ 'mobile', 'address', 'openBank', 'bankAddress', 'bankNo', 'bankProvince','bankCity','bankCounty', 'consignee','acceptMobile','province',/*'city','county',*/ 'conUserName', 'recUserName',/*'decUserName',*/ 'location', 'email'],
             'canDec' => ['type', 'insertUserName',/* 'insertUserIdCard',*/ 'conUserName', 'recUserName', 'location'],
             'notFull' => ['type', 'insertUserName', 'conUserName', 'recUserName', 'location'],
         ];
@@ -630,6 +630,7 @@ class DeclarationForm extends Model
             return null;
         }
 
+        $hasInstalment = 0;
         // 首购单,需要添加会员操作
         if($this->type == self::TYPE_ZC){
             if (preg_match("/[\x7f-\xff]/", $this->insertUserName)) {  //判断字符串中是否有中文
@@ -670,7 +671,6 @@ class DeclarationForm extends Model
                 $totalAmount = 0;
                 $totalAmountStandard = 0;
                 $totalPv = 0;
-                $hasInstalment = 0;
                 $exchangeRate = floatval(Cache::getSystemConfig()['exchangeRate']['VALUE'] ?? 0); // 汇率
                 foreach ($this->goodsNum as $k => $v) {
                     if ($v) {
@@ -711,10 +711,10 @@ class DeclarationForm extends Model
                     }
                 }
                 if($totalPv<$decLevel['PERF']){
-                    if ($hasInstalment && $decLevel['LEVEL_NAME'] == 'Elite'){
-                    }else{
+//                    if ($hasInstalment && $decLevel['LEVEL_NAME'] == 'Elite'){
+//                    }else{
                         throw new Exception(Yii::t('app', 'totalBVCanNotLessThanSelectedBV'));
-                    }
+//                    }
                 }
                 foreach ($decLevelConfig as $key=>$val){
                     if($totalPv>=$val['PERF']){
@@ -722,14 +722,14 @@ class DeclarationForm extends Model
                     }
                 }
                 if ($this->decLv != $toDecLevel) {
-                    if ($hasInstalment && $decLevel['LEVEL_NAME'] == 'Elite'){
-                    }else{
-                        throw new Exception(Yii::t('app', 'totalBVCanNotLessThanNextSelectedLevelBV'));
-                    }
-                }
-                if ($hasInstalment && $decLevel['LEVEL_NAME'] == 'BA'){
-                    throw new Exception(Yii::t('app', 'totalBVCanNotLessThanNextSelectedLevelBV'));
+//                    if ($hasInstalment && $decLevel['LEVEL_NAME'] == 'Elite'){
+//                    }else{
+                        throw new Exception(Yii::t('app', 'totalBVCanNotLessThanNextSelectedLevelBV') . '-1');
+//                    }
                 }
+//                if ($hasInstalment && $decLevel['LEVEL_NAME'] == 'BA'){
+//                    throw new Exception(Yii::t('app', 'totalBVCanNotLessThanNextSelectedLevelBV'));
+//                }
                 $this->_decAmount = $totalAmount;
                 $this->_decPv = $totalPv;
                 $this->_decAmountStandard = $totalAmountStandard;

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

@@ -112,6 +112,7 @@ class DeclarationUpgradeForm extends Model
             return null;
         }
         $loginUserId = \Yii::$app->user->id;
+        $hasInstalment = 0;
         // 首购单
         if($this->type == self::TYPE_ZC){
             //报单商品及PV判断
@@ -155,7 +156,6 @@ class DeclarationUpgradeForm extends Model
                 $totalAmount = 0;
                 $totalAmountStandard = 0;
                 $totalPv = 0;
-                $hasInstalment = 0;
                 $exchangeRate = floatval(Cache::getSystemConfig()['exchangeRate']['VALUE'] ?? 0); // 汇率
                 foreach ($this->goodsNum as $k => $v) {
                     if ($v) {
@@ -190,11 +190,13 @@ class DeclarationUpgradeForm extends Model
                                 throw new Exception(Yii::t('app', 'allowOnlyOne'));
                             }
 
+                            // 分期的总期数
+                            $instalment = floatval(Cache::getSystemConfig()['instalment']['VALUE'] ?? 3);
                             $userStage = Instalment::getStage($userId);
                             $userInstalmentInfo = Instalment::getInfo($userId);
                             if (!$userInstalmentInfo){ // 如果没有分期付款记录
                                 throw new Exception(Yii::t('app', 'canNotBuy'));
-                            } else if ($userInstalmentInfo['ORDER_TYPE']!='BD' || $userStage == 3) { // 如果分期付款记录中,不是报单,或已是3
+                            } else if ($userInstalmentInfo['ORDER_TYPE']!='BD' || $userStage == $instalment) { // 如果分期付款记录中,不是报单,或已是最后一期
                                 throw new Exception(Yii::t('app', 'canNotBuy'));
                             }
                             if($userStage + 1 != $goods['INSTALMENT']){ // 若用户分期阶段+1不等于商品的分期阶段,则报异常
@@ -204,11 +206,13 @@ class DeclarationUpgradeForm extends Model
                         }
                     }
                 }
+
                 // 这里特殊是用户原报单PV之和+用户购买的商品总PV
                 $checkPv = $totalPv + $diffPerf;
                 if ($hasInstalment){ // 如果买了分期付款商品,则不判断总pv
                     $allData['hasInstalment'] = 1;
-                }else if($checkPv < $decLevel['PERF']) {
+                }
+                if($checkPv < $decLevel['PERF']) {
                     throw new Exception(Yii::t('app', 'totalPVLessThan'), 400);
                 }
                 foreach ($decLevelConfig as $key=>$val){

+ 11 - 7
common/models/forms/OrderForm.php

@@ -45,6 +45,7 @@ class OrderForm extends Model
     public $email;
 
     public $userName;
+    public $decUserName;
     public $consignee;
     public $acceptMobile;
     public $province;
@@ -467,6 +468,7 @@ class OrderForm extends Model
         $goodsType = ShopGoods::getGoodType();
         $this->_remainPv = 0;
         $hasInstalment = 0;
+        $loginUserId = \Yii::$app->user->id;
         $exchangeRate = floatval(Cache::getSystemConfig()['exchangeRate']['VALUE'] ?? 0); // 汇率
         foreach ($this->goodsNum as $k => $v) {
             if ($v) {
@@ -538,11 +540,12 @@ class OrderForm extends Model
                     if($v>1){ // 不可以购买多个
                         throw new Exception(Yii::t('app', 'allowOnlyOne'));
                     }
-                    $loginUserId = \Yii::$app->user->id;
                     $userStage = Instalment::getStage($loginUserId);
                     $userInstalmentInfo = Instalment::getInfo($loginUserId);
 
-                    if ($userStage != 3){
+                    // 分期的总期数
+                    $instalment = floatval(Cache::getSystemConfig()['instalment']['VALUE'] ?? 3);
+                    if ($userStage != $instalment){
                         if($userInstalmentInfo){
                             if($userInstalmentInfo['STAGE']>0 && $userInstalmentInfo['ORDER_TYPE']!='FX'){
                                 throw new Exception(Yii::t('app', 'canNotBuy'));
@@ -557,8 +560,6 @@ class OrderForm extends Model
             }
         }
 
-        // 汇率
-        $exchangeRate = floatval(Cache::getSystemConfig()['exchangeRate']['VALUE'] ?? 0);
         // 运费.美元转奈拉
         $freight = floatval(Cache::getSystemConfig()['freight']['VALUE'] ?? 0);
         // 普通商品免运费阈值.美元转奈拉
@@ -710,7 +711,7 @@ class OrderForm extends Model
         $orderModel->DEC_SN = 'DS'.$ordNo;
         $orderModel->ORDER_TYPE = $this->type;
         $orderModel->USER_ID = $userId;
-        $orderModel->USER_NAME = $userName;
+        $orderModel->USER_NAME = $this->decUserName;;
         $orderModel->ORDER_AMOUNT = $this->_decAmount;
         $orderModel->PV = $_hasPV;
         $orderModel->PAY_AMOUNT = $this->_payAmount;
@@ -838,6 +839,7 @@ class OrderForm extends Model
         $totalPv = 0;
         $goodsType = ShopGoods::getGoodType();
         $hasInstalment = 0;
+        $userId = Info::getUserIdByUserName($this->userName);
         foreach ($this->goodsNum as $k => $v) {
             if ($v) {
                 $goods = ShopGoods::findOneAsArray('ID=:ID AND STATUS=1',[':ID'=> $ids[$k]]);
@@ -872,10 +874,12 @@ class OrderForm extends Model
                     if($v>1){ // 不可以购买多个
                         throw new Exception(Yii::t('app', 'allowOnlyOne'));
                     }
-                    $userId = Info::getUserIdByUserName($this->userName);
+
                     $userStage = Instalment::getStage($userId);
                     $userInstalmentInfo = Instalment::getInfo($userId);
-                    if ($userStage == 3){
+                    // 分期的总期数
+                    $instalment = floatval(Cache::getSystemConfig()['instalment']['VALUE'] ?? 3);
+                    if ($userStage == $instalment){
 
                     }else{
                         if($userInstalmentInfo){

+ 2 - 2
frontendApi/config/menu.php

@@ -39,7 +39,7 @@ return [
         'show'=>1,
         'wiki' => 'memberManagement',
         'child'=>[
-            ['name'=>'Member Welcome Pack', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'dec', 'routePath'=>'user/dec', 'show'=>1, 'allow'=>'declarer', 'wiki' => 'welcomePack',], // 会员报单
+            ['name'=>'Member Welcome Pack', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'dec', 'routePath'=>'user/dec', 'show'=>1,  'wiki' => 'welcomePack',], // 会员报单
             ['name'=>'Member Repeat Purchase', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'reconsume', 'routePath'=>'shop/reconsume', 'show'=>1, 'allow'=>'declarer','wiki' => 'memberRepeatPurchase',],//会员复消
             ['name'=>'Member Upgrade', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'dec', 'routePath'=>'user/upgrade', 'show'=>1,'allow'=>'declarer', 'wiki' => 'memberUpgrade',],//会员升级
             ['name'=>'Member Order', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'member-order', 'routePath'=>'shop/member-order', 'show'=>1, 'wiki' => 'memberOrder',],//会员订单
@@ -113,4 +113,4 @@ return [
 //            ['name'=>'Reset Password', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'password', 'routePath'=>'user/password', 'show'=>1, 'wiki' => 'resetPassword',],//重设密码
         ]
     ],
-];
+];

+ 6 - 6
frontendApi/modules/v1/controllers/BaController.php

@@ -232,7 +232,7 @@ class BaController extends BaseController {
         // 获取系统中的DEC 报单级别配置
         $decConfig = Cache::getDecLevelConfig();
         $userDecInfo = $decConfig[$userDecId]; // 会员的级别具体信息
-        $maxPerfInfo = DeclarationLevel::getMaxDecPref(); 
+        $maxPerfInfo = DeclarationLevel::getMaxDecPref();
         $maxDecId = $maxPerfInfo['ID']; // 级别配置中最高级别ID
         $observe = Config::getConfigByType('observe'); // 获取观察期配置信息
         $observeLimit = $observe['observePeriodLimit']['value']; // 月份限制
@@ -251,7 +251,7 @@ class BaController extends BaseController {
             'IS_OBSERVE' => $isObserve, // 是否是观察期  true为是观察期
             'IS_MAX' => $isMax, // 是否已是最大级别 最大级别不需要判断报单总PV是多少 只展示基本信息
         ];
-        
+
         // 如果是最高级别了,则无需升级
         if ($isMax) {
             return static::notice(['baseInfo' => $userInfo]);
@@ -282,12 +282,12 @@ class BaController extends BaseController {
             // 循环列表,补充升级所需要的补差
             foreach ($userInfo['LEVEL_LIST'] as &$v) {
                 $v['REPAIR_PV'] = $isObserve ? $v['PERF'] - $userInfo['NOW_PERF'] : $v['PERF'];
-            }   
+            }
         }
-        
+
         return static::notice(['baseInfo' => $userInfo]);
     }
-    
+
     // 会员升级管理
     public function actionUpgrade() {
         $isSwitchUpgrade = Config::find()
@@ -576,4 +576,4 @@ class BaController extends BaseController {
 
         return static::notice(Yii::t('app', 'illegalRequest'), 400);
     }
-}
+}

+ 37 - 3
frontendApi/modules/v1/controllers/ShopController.php

@@ -31,6 +31,7 @@ use common\models\forms\ApproachReconsumeOrderForm;
 use common\models\forms\BaApproachOrderForm;
 use common\models\forms\DeclarationForm;
 use common\models\forms\OrderForm;
+use common\models\Instalment;
 use common\models\Order;
 use common\models\OrderGoods;
 use common\models\ReceiveAddress;
@@ -134,7 +135,7 @@ class ShopController extends BaseController {
         $freight = floatval(Cache::getSystemConfig()['freight']['VALUE'] ?? 0);
         // 普通商品免运费阈值.奈拉
         $freeShipping = floatval(Cache::getSystemConfig()['freeShipping']['VALUE'] ?? 0);
-
+        $isDec = User::getEnCodeInfo(\Yii::$app->user->id)['IS_DEC'];
         return static::notice(
             [
                 'payList'=>$payList,
@@ -143,6 +144,7 @@ class ShopController extends BaseController {
                 'sellType' => ShopGoods::getCategoryType(),
                 'freight' => $freight,
                 'freeShipping' => $freeShipping,
+                'isDec' => $isDec,
             ]);
     }
 
@@ -156,6 +158,23 @@ class ShopController extends BaseController {
             $formModel->remark = 'FX';//复销备注
             $post = \Yii::$app->request->post();
             $post['type'] = DeclarationForm::TYPE_FX;
+            $userInfo = User::getEnCodeInfo(\Yii::$app->user->id);
+            if($userInfo['IS_DEC'] == 1 && !empty($post['userName']) && $post['userName'] != $userInfo['USER_NAME']){
+                return static::notice(Yii::t('app', 'stockistDoesNotExist'), 400);
+            }
+            if($post['userName'] && $userInfo['IS_DEC'] == 0){
+                //查询报单编号是否存在
+                $userId = Info::getUserIdByUserName($post['userName']);
+                if(!$userId){
+                    return static::notice(Yii::t('app', 'stockistDoesNotExist'), 400);
+                }
+                $isDec = User::getEnCodeInfo($userId)['IS_DEC'];
+                if(!$isDec){
+                    return static::notice(Yii::t('app', 'decUserNameIsWrong'), 400);
+                }
+            }
+
+            $formModel->decUserName = $post['userName'];
             if ($formModel->load($post, '') && $order = $formModel->add()) {
                 return static::notice($order);
             } else {
@@ -187,6 +206,22 @@ class ShopController extends BaseController {
             $formModel->remark = '复销备注';
             $post = \Yii::$app->request->post();
             $post['type'] = DeclarationForm::TYPE_FX;
+            $userInfo = User::getEnCodeInfo(\Yii::$app->user->id);
+            if($userInfo['IS_DEC'] == 1 && !empty($post['userName']) && $post['userName'] != $userInfo['USER_NAME']){
+                return static::notice(Yii::t('app', 'stockistDoesNotExist'), 400);
+            }
+            //查询报单编号是否存在
+            if($post['userName'] && $userInfo['IS_DEC'] == 0){
+                $userId = Info::getUserIdByUserName($post['userName']);
+                if(!$userId){
+                    return static::notice(Yii::t('app', 'stockistDoesNotExist'), 400);
+                }
+                $isDec = User::getEnCodeInfo($userId)['IS_DEC'];
+                if(!$isDec){
+                    return static::notice(Yii::t('app', 'decUserNameIsWrong'), 400);
+                }
+            }
+            $formModel->decUserName = $post['userName'];
             if ($formModel->load($post, '') && $order = $formModel->add()) {
                 return static::notice($order);
             } else {
@@ -236,8 +271,7 @@ class ShopController extends BaseController {
                 $customFields = $data['metadata']['custom_fields'] ?? [];
                 $oderSn = $customFields[0]['value'] ?? '';
                 $orderType = $customFields[1]['value'] ?? false;
-                // 订单类型区分:baOrder(BA订单)、baDec(BA报单)
-                $formModel = in_array($orderType, ['baOrder', 'baDec']) ? new BaApproachOrderForm() : new ApproachOrderForm();
+                $formModel = new ApproachOrderForm();
                 $formModel->scenario = 'verifyPayStack';
                 $load = [
                     'sn' => $oderSn,

+ 6 - 6
frontendApi/modules/v1/controllers/SiteController.php

@@ -247,16 +247,16 @@ class SiteController extends BaseController
         }
 
         if($menu['allow']=='pastBonusSwitch'){
-            $pastBonusSwitch = isset(Cache::getSystemConfig()['pastBonusSwitch']) 
-                ? Cache::getSystemConfig()['pastBonusSwitch']['VALUE'] 
+            $pastBonusSwitch = isset(Cache::getSystemConfig()['pastBonusSwitch'])
+                ? Cache::getSystemConfig()['pastBonusSwitch']['VALUE']
                 : '';
             if($pastBonusSwitch) return false;
         }
 
         if($menu['allow']=='newBonusSwitch'){
-            // ??? 
-            $newBonusSwitch = isset(Cache::getSystemConfig()['newBonusSwitch']) 
-                ? Cache::getSystemConfig()['newBonusSwitch']['VALUE'] 
+            // ???
+            $newBonusSwitch = isset(Cache::getSystemConfig()['newBonusSwitch'])
+                ? Cache::getSystemConfig()['newBonusSwitch']['VALUE']
                 : '';
             if($newBonusSwitch) return false;
         }
@@ -382,4 +382,4 @@ class SiteController extends BaseController
 
         return static::notice('成功', 0);
     }
-}
+}

+ 17 - 2
frontendApi/modules/v1/controllers/UserController.php

@@ -385,8 +385,22 @@ class UserController extends BaseController {
         $userName = Info::generateWebUserName('NG',9);
         $redis = \Yii::$app->redis;
         $post = \Yii::$app->request->post();
-
         if (\Yii::$app->request->isPost) {
+            $userInfo = User::getEnCodeInfo(\Yii::$app->user->id);
+            if($userInfo['IS_DEC'] == 1 && !empty($post['decUserName']) && $post['decUserName'] != $userInfo['USER_NAME']){
+                return static::notice(Yii::t('app', 'decUserNameIsWrong'), 400);
+            }
+            if($userInfo['IS_DEC'] == 0 && $post['decUserName']){
+                //查询报单编号是否存在
+                $userId = Info::getUserIdByUserName($post['decUserName']);
+                if(!$userId){
+                    return static::notice(Yii::t('app', 'decUserNameIsWrong'), 400);
+                }
+                $isDec = User::getEnCodeInfo($userId)['IS_DEC'];
+                if(!$isDec){
+                    return static::notice(Yii::t('app', 'decUserNameIsWrong'), 400);
+                }
+            }
             // 根据支付方式区分逻辑
             $payMethod = \Yii::$app->request->post('payType', '');
 
@@ -458,7 +472,7 @@ class UserController extends BaseController {
         // 所有开户行
         $allOpenBank = OpenBank::find()->where('STATUS=1')->orderBy('LIST_ORDER ASC')->asArray()->all();
         if (!$userName) {
-            return static::notice(Yii::t('app', 'failedToGenerateMemberNumber'), 400);
+            return static::notice(Yii::t('app',  'failedToGenerateMemberNumber'), 400);
         }
         //随机码保存在redis中方便进行比对
         $redis->setex('key_'.$userName , 3600 , $userName);
@@ -479,6 +493,7 @@ class UserController extends BaseController {
             'sellType' => ShopGoods::getCategoryType(),
             'categoryType' => ShopGoods::getCategoryType()[0]['id'],
             'userBalance' => $userBalance,
+            'isDec' => $isDec,
         ]);
     }