ソースを参照

bugfix: EK-1569: 报单时无法使用PayStack支付.

kevinElken 8 ヶ月 前
コミット
c08c83b8da

+ 17 - 37
common/models/forms/ApproachDeclarationForm.php

@@ -5,8 +5,6 @@ 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\Reconsume;
 use common\helpers\user\Info;
 use common\models\ApproachDecOrder;
@@ -15,16 +13,10 @@ use common\models\ApproachOrderGoods;
 use common\models\Countries;
 use common\models\CurrencyConversions;
 use common\models\DeclarationPackage;
-use common\models\DecOrder;
 use common\models\EmployLevel;
 use common\models\Language;
-use common\models\Order;
-use common\models\OrderGoods;
 use common\models\Period;
 use common\models\ReceiveAddress;
-use common\models\ReconsumePool;
-use common\models\ReconsumePoolFlow;
-use common\models\DeclarationLevel;
 use common\models\Region;
 use common\models\ShopGoods;
 use common\models\ShopGoodsNature;
@@ -140,8 +132,8 @@ class ApproachDeclarationForm extends Model
             [['insertUserName'], 'isCanAddUser'],
             [['decUserName', 'decType'], 'issetDec'],
             [['conUserName'], 'isConUserName'],
-//            [['recUserName'], 'isRecUserName'],
-//            [['location'], 'isLocation'],
+            [['recUserName'], 'isRecUserName'],
+            [['location'], 'isLocation'],
 //            [['insertUserIdCard'], 'isSameSystem'],
         ];
     }
@@ -211,19 +203,6 @@ class ApproachDeclarationForm extends Model
                 $this->addError($attribute, Yii::t('app', 'stockistDoesNotExist'));
                 return false;
             } else {
-//                if ($this->decType !== 'ba') {
-                    // 判断报单中心是否在新加入会员的安置网上级中
-//                    $this->loopFindParentToNetwork($this->insertUserName);
-                    //反转数组,in_array搜索错误
-                    //in_array($this->decUserName, $this->_tempNetworkParentUser[$this->insertUserName]);
-//                    $flipParent = array_flip(array_filter($this->_tempNetworkParentUser[$this->insertUserName]));
-//                    if (!isset($flipParent[$this->decUserName])) {
-//                        //$this->addError($attribute, '为' . $this->insertUserName . '报单,报单中心' . $this->decUserName . '不在' . $this->insertUserName . '的安置网上级中');
-//                        $this->addError($attribute, 'To' . $this->insertUserName . 'Entry, Stockist' . $this->decUserName . 'not in exist' . $this->insertUserName . 'in the placement superiors');
-//                        return ;
-//                    }
-//                }
-
                 $this->_decId = $decUser['ID'];
             }
         }
@@ -270,10 +249,10 @@ class ApproachDeclarationForm extends Model
             if($conUser['CON_NUM'] >= 3){
                 if($this->insertUserName){
                    // $this->addError($attribute, '为'.$this->insertUserName.'报单,指导老师'.$this->conUserName.'下级点位已满');
-                    $this->addError($attribute, 'To'.$this->insertUserName.'Entry,Instructor'.$this->conUserName.'lower level is full');
+//                    $this->addError($attribute, 'To'.$this->insertUserName.'Entry,Instructor'.$this->conUserName.'lower level is full');
                 } else {
                     //$this->addError($attribute, '指导老师'.$this->conUserName.'下级点位已满');
-                    $this->addError($attribute, 'Instructor'.$this->conUserName.'lower level is full');
+//                    $this->addError($attribute, 'Instructor'.$this->conUserName.'lower level is full');
                 }
                 return;
             }
@@ -340,14 +319,11 @@ class ApproachDeclarationForm extends Model
             $this->_tempParentUser[$this->recUserName]['REC_NUM'] += 1;
 
             // 存在新加入会员时查看开拓人是否在新加入会员的安置网上级中
-            if($this->decType !== 'ba' && $this->insertUserName) {
-                $this->loopFindParentToNetwork($this->insertUserName);
-                if (!$this->recUserIsInNetworkParent()) {
-                   // $this->addError($attribute, '为' . $this->insertUserName . '报单,开拓人' . $this->recUserName . '不在' . $this->insertUserName . '的安置网上级中');
-                    $this->addError($attribute, 'To' . $this->insertUserName . 'Entry, Sponsor' . $this->recUserName . 'not in exist' . $this->insertUserName . 'in the placement superiors');
-                    return ;
-                }
-            }
+            $this->loopFindParentToNetwork($this->insertUserName);
+//            if (!$this->recUserIsInNetworkParent()) {
+//                $this->addError($attribute, 'To' . $this->insertUserName . 'Entry, Sponsor' . $this->recUserName . 'not in exist' . $this->insertUserName . 'in the placement superiors');
+//                return ;
+//            }
 
             // 把自己加入到临时上级会员数组中
             $this->_tempParentUser[$this->insertUserName] = [
@@ -523,13 +499,13 @@ class ApproachDeclarationForm extends Model
             // 判断接点会员的下级会员是否大于三个,如果大于三个则不允许
             if($conUser['CON_NUM'] >= 3){
 //                $this->addError($attribute, '为'.$this->insertUserName.'报单,指导老师'.$this->conUserName.'下级点位已满');
-                $this->addError($attribute, 'To'.$this->insertUserName.'Entry, Sponsor'.$this->conUserName.'lower level is full');
+//                $this->addError($attribute, 'To'.$this->insertUserName.'Entry, Sponsor'.$this->conUserName.'lower level is full');
                 return;
             }
             // 判断指导老师相应的区位是否已满
             if($conUser['LOCATION'.$this->location]){
 //                $this->addError($attribute, '为'.$this->insertUserName.'报单,指导老师'.$this->conUserName.'该市场已存在会员');
-                $this->addError($attribute, 'To'.$this->insertUserName.'Entry, Sponsor'.$this->conUserName.'Members already exist in this market');
+//                $this->addError($attribute, 'To'.$this->insertUserName.'Entry, Sponsor'.$this->conUserName.'Members already exist in this market');
                 return;
             }
 //            if($conUser['CON_NUM'] == 0 && $this->location != 1){
@@ -806,6 +782,7 @@ class ApproachDeclarationForm extends Model
         if (!$user->save()) {
             throw new Exception(Form::formatErrorsForApi($user->getErrors()));
         }
+
         $this->_insertUserId = $user->ID;
         $userForm = new UserForm();
         $this->_userForm = $userForm;
@@ -876,10 +853,12 @@ class ApproachDeclarationForm extends Model
         }
 
         // 升级会员
-        $userCountry = User::getEnCodeInfo($this->_insertUserId);
+        $userCountryId = User::getEnCodeInfo($this->_insertUserId)['COUNTRY_ID'];
+        $userCountry = Countries::getById($userCountryId);
         $userCurrencyRate = CurrencyConversions::getToUSDRate($userCountry['LOCAL_CURRENCY_ID']);
         // 报单中心汇率
-        $decCountry = User::getEnCodeInfo(\Yii::$app->user->id)['COUNTRY_ID'];
+        $decCountryId = User::getEnCodeInfo(\Yii::$app->user->id)['COUNTRY_ID'];
+        $decCountry = Countries::getById($decCountryId);
         $decUserCurrencyRate = CurrencyConversions::getToUSDRate($decCountry['LOCAL_CURRENCY_ID']);
 
         $orderModel = new ApproachOrder();
@@ -915,6 +894,7 @@ class ApproachDeclarationForm extends Model
         $orderModel->EXCHANGE_RATE = $userCurrencyRate;
         $orderModel->COUNTRY_ID = $userCountry['COUNTRY_ID'];
         $orderModel->CURRENCY_ID = $userCountry['LOCAL_CURRENCY_ID'] ?? 0;
+        $orderModel->DEC_USER_ID = Info::getUserNameByUserId(\Yii::$app->user->id);
         if ($this->province==1) {
             $orderModel->EXPRESS_TYPE = 1;
         }

+ 3 - 21
common/models/forms/DeclarationForm.php

@@ -208,27 +208,10 @@ class DeclarationForm extends Model
         if(!$this->decUserName){
             $this->_decId = '';
         } else {
-
-
             if (!$decUser = User::find()->select('ID')->where('IS_DEC=1 AND USER_NAME=:USER_NAME', [':USER_NAME' => $this->decUserName])->asArray()->one()) {
                 $this->addError($attribute, Yii::t('app', 'stockistDoesNotExist'));
                 return false;
             } else {
-                if ($this->decType !== 'ba') {
-                    // 判断报单中心是否在新加入会员的安置网上级中
-                    $this->loopFindParentToNetwork($this->insertUserName);
-                    //反转数组,in_array搜索错误
-                    //in_array($this->decUserName, $this->_tempNetworkParentUser[$this->insertUserName]);
-                    $flipParent = array_flip(array_filter($this->_tempNetworkParentUser[$this->insertUserName]));
-//            var_dump($flipParent);
-//            echo $this->insertUserName.'=='.$this->decUserName;
-//            exit;
-//                    if (!isset($flipParent[$this->decUserName])) {
-//                        //$this->addError($attribute, '为' . $this->insertUserName . '报单,报单中心' . $this->decUserName . '不在' . $this->insertUserName . '的安置网上级中');
-//                        $this->addError($attribute, 'To' . $this->insertUserName . 'Entry, Stockist' . $this->decUserName . 'not in exist' . $this->insertUserName . 'in the placement superiors');
-//                        return;
-//                    }
-                }
                 $this->_decId = $decUser['ID'];
             }
         }
@@ -346,14 +329,12 @@ class DeclarationForm extends Model
 
             // 存在新加入会员时查看开拓人是否在新加入会员的安置网上级中
             if($this->insertUserName) {
-                if ($this->decType !== 'ba') {
                     $this->loopFindParentToNetwork($this->insertUserName);
-                    if (!$this->recUserIsInNetworkParent()) {
+//                    if (!$this->recUserIsInNetworkParent()) {
                         // $this->addError($attribute, '为' . $this->insertUserName . '报单,开拓人' . $this->recUserName . '不在' . $this->insertUserName . '的安置网上级中');
 //                        $this->addError($attribute, 'To' . $this->insertUserName . 'Entry, Sponsor' . $this->recUserName . 'not in exist' . $this->insertUserName . 'in the placement superiors');
 //                        return ;
-                    }
-                }
+//                    }
             }
 
             // 把自己加入到临时上级会员数组中
@@ -961,6 +942,7 @@ class DeclarationForm extends Model
         $orderModel->EXCHANGE_RATE = $userCurrencyRate;
         $orderModel->COUNTRY_ID = $userCountryId;
         $orderModel->CURRENCY_ID = $userCountry['LOCAL_CURRENCY_ID'] ?? 0;
+        $orderModel->DEC_USER_ID = Info::getUserNameByUserId(\Yii::$app->user->id);
         if($this->province==1){
             $orderModel->EXPRESS_TYPE = 1;
         }