Browse Source

feat: NG-15: 新会员注册时增加国家与语言选项.

zhangl 1 year ago
parent
commit
ad0fa9a479

+ 3 - 3
common/models/UserInfo.php

@@ -13,9 +13,9 @@ use common\libs\logging\operate\valueType\Config as ValueTypeConfig;
  * @property string $USER_ID 会员ID
  * @property string $USER_NAME 会员名
  * @property string $ZC_PV 注册单PV
- * @property string $CON_UID 实际推荐人ID
- * @property string $CON_UID_ACTUAL 推荐人ID
- * @property string $REC_UID 安置人ID
+ * @property string $CON_UID 安置人ID
+ * @property string $REC_UID 实际推荐人ID
+ * @property string $REC_UID_ACTUAL 推荐人ID
  * @property int $CON_NUM 下级节点数量
  * @property int $REC_NUM 开拓会员数量
  * @property int $NETWORK_DEEP 安置网络深度

+ 66 - 64
common/models/forms/DeclarationForm.php

@@ -61,6 +61,7 @@ class DeclarationForm extends Model
     public $bankCity;
     public $bankCounty;
     public $conUserName;
+    public $bottomUserName;
     public $recUserName;
     public $decUserName;
     public $location;
@@ -137,8 +138,8 @@ class DeclarationForm extends Model
             [['insertUserName'], 'isCanAddUser'],
             [['decUserName'], 'issetDec'],
             [['conUserName'], 'isConUserName'],
-//            [['recUserName'], 'isRecUserName'],
-//            [['location'], 'isLocation'],
+            [['recUserName'], 'isRecUserName'],
+            [['location'], 'isLocation'],
 //            [['insertUserIdCard'], 'isSameSystem'],
         ];
     }
@@ -211,12 +212,12 @@ class DeclarationForm extends Model
                 $this->addError($attribute, Yii::t('app', 'stockistDoesNotExist'));
                 return false;
             } else {
-//                if ($this->decType !== 'ba') {
+                if ($this->decType !== 'ba') {
                     // 判断报单中心是否在新加入会员的安置网上级中
-//                    $this->loopFindParentToNetwork($this->insertUserName);
+                    $this->loopFindParentToNetwork($this->insertUserName);
                     //反转数组,in_array搜索错误
                     //in_array($this->decUserName, $this->_tempNetworkParentUser[$this->insertUserName]);
-//                    $flipParent = array_flip(array_filter($this->_tempNetworkParentUser[$this->insertUserName]));
+                    $flipParent = array_flip(array_filter($this->_tempNetworkParentUser[$this->insertUserName]));
 //            var_dump($flipParent);
 //            echo $this->insertUserName.'=='.$this->decUserName;
 //            exit;
@@ -225,7 +226,7 @@ class DeclarationForm extends Model
 //                        $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,13 +271,13 @@ class DeclarationForm extends Model
             $conUser = $this->_tempParentUser[$this->conUserName];
             // 判断接点会员的下级会员是否大于三个,如果大于三个则不允许
             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');
-//                } else {
-//                    //$this->addError($attribute, '指导老师'.$this->conUserName.'下级点位已满');
-//                    $this->addError($attribute, 'Instructor'.$this->conUserName.'lower level is full');
-//                }
+                if($this->insertUserName){
+                   // $this->addError($attribute, '为'.$this->insertUserName.'报单,指导老师'.$this->conUserName.'下级点位已满');
+                    $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');
+                }
                 return;
             }
             if($this->insertUserName){
@@ -513,44 +514,44 @@ class DeclarationForm extends Model
             $conUser = $this->_tempParentUser[$this->conUserName];
 
             // 开拓人
-//            if(!isset($this->_tempParentUser[$this->recUserName])){
-//                $recUserTemp = UserInfo::findOneAsArray('USER_NAME=:USER_NAME', [':USER_NAME' => $this->recUserName]);
-//                if(!$recUserTemp){
-////                    $this->addError($attribute, '为'.$this->insertUserName.'报单,开拓人'.$this->recUserName.'不存在');
-//                    $this->addError($attribute, 'To'.$this->insertUserName.'Entry, Sponsor'.$this->recUserName.'not in exist');
-//                    return ;
-//                }
-//                $recUserTemp['CON_NUM'] = UserNetwork::firstFloorChildNum($recUserTemp['USER_ID']);
-//                $recUserTemp['REC_NUM'] = UserRelation::firstFloorChildNum($recUserTemp['USER_ID']);
-//                $this->_tempParentUser[$this->recUserName] = [
-//                    'USER_NAME' => $this->recUserName,
-//                    //'ZC_PV' => $recUserTemp['ZC_PV'],
-//                    'CON_USER_NAME' => Info::getUserNameByUserId($recUserTemp['CON_UID']),
-//                    'REC_USER_NAME' => Info::getUserNameByUserId($recUserTemp['REC_UID']),
-//                    'CON_NUM' => $recUserTemp['CON_NUM'],
-//                    'REC_NUM' => $recUserTemp['REC_NUM'],
-//                    'SYSTEM_ID' => $recUserTemp['SYSTEM_ID'],
-//                    'LOCATION' => UserNetwork::getLocation($recUserTemp['USER_ID'], $recUserTemp['CON_UID']),
-//                ];
-//                // 把该会员下面的5个区是否存在会员都付上
-//                for($i=1;$i<=5;$i++){
-//                    $this->_tempParentUser[$this->recUserName]["LOCATION$i"] = UserNetwork::issetUserInLocation($recUserTemp['USER_ID'], $i);
-//                }
-//            }
-//            $recUser = $this->_tempParentUser[$this->recUserName];
+            if(!isset($this->_tempParentUser[$this->recUserName])){
+                $recUserTemp = UserInfo::findOneAsArray('USER_NAME=:USER_NAME', [':USER_NAME' => $this->recUserName]);
+                if(!$recUserTemp){
+//                    $this->addError($attribute, '为'.$this->insertUserName.'报单,开拓人'.$this->recUserName.'不存在');
+                    $this->addError($attribute, 'To'.$this->insertUserName.'Entry, Sponsor'.$this->recUserName.'not in exist');
+                    return ;
+                }
+                $recUserTemp['CON_NUM'] = UserNetwork::firstFloorChildNum($recUserTemp['USER_ID']);
+                $recUserTemp['REC_NUM'] = UserRelation::firstFloorChildNum($recUserTemp['USER_ID']);
+                $this->_tempParentUser[$this->recUserName] = [
+                    'USER_NAME' => $this->recUserName,
+                    //'ZC_PV' => $recUserTemp['ZC_PV'],
+                    'CON_USER_NAME' => Info::getUserNameByUserId($recUserTemp['CON_UID']),
+                    'REC_USER_NAME' => Info::getUserNameByUserId($recUserTemp['REC_UID']),
+                    'CON_NUM' => $recUserTemp['CON_NUM'],
+                    'REC_NUM' => $recUserTemp['REC_NUM'],
+                    'SYSTEM_ID' => $recUserTemp['SYSTEM_ID'],
+                    'LOCATION' => UserNetwork::getLocation($recUserTemp['USER_ID'], $recUserTemp['CON_UID']),
+                ];
+                // 把该会员下面的5个区是否存在会员都付上
+                for($i=1;$i<=5;$i++){
+                    $this->_tempParentUser[$this->recUserName]["LOCATION$i"] = UserNetwork::issetUserInLocation($recUserTemp['USER_ID'], $i);
+                }
+            }
+            $recUser = $this->_tempParentUser[$this->recUserName];
 
             // 判断接点会员的下级会员是否大于三个,如果大于三个则不允许
-//            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');
-//                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');
-//                return;
-//            }
+            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');
+                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');
+                return;
+            }
 //            if($conUser['CON_NUM'] == 0 && $this->location != 1){
 //                $this->addError($attribute, '为'.$this->insertUserName.'报单,市场必须为指导老师'.$this->conUserName.'下第一市场');
 //                return;
@@ -562,21 +563,21 @@ class DeclarationForm extends Model
 //            $this->_tempParentUser[$this->recUserName]['REC_NUM'] += 1;
 
             // 把自己加入到临时上级会员数组中
-//            $this->_tempParentUser[$this->insertUserName] = [
-//                'USER_NAME' => $this->insertUserName,
-//                //'ZC_PV' => $this->decPv,
-//                'CON_USER_NAME' => $this->conUserName,
-//                'REC_USER_NAME' => $this->recUserName,
-//                'CON_NUM' => 0,
-//                'REC_NUM' => 0,
-//                'SYSTEM_ID' => $recUser['SYSTEM_ID'],
-//                'LOCATION' => $this->location,
-//                'LOCATION1' => 0,
-//                'LOCATION2' => 0,
-//                'LOCATION3' => 0,
-//                'LOCATION4' => 0,
-//                'LOCATION5' => 0,
-//            ];
+            $this->_tempParentUser[$this->insertUserName] = [
+                'USER_NAME' => $this->insertUserName,
+                //'ZC_PV' => $this->decPv,
+                'CON_USER_NAME' => $this->conUserName,
+                'REC_USER_NAME' => $this->recUserName,
+                'CON_NUM' => 0,
+                'REC_NUM' => 0,
+                'SYSTEM_ID' => $recUser['SYSTEM_ID'],
+                'LOCATION' => $this->location,
+                'LOCATION1' => 0,
+                'LOCATION2' => 0,
+                'LOCATION3' => 0,
+                'LOCATION4' => 0,
+                'LOCATION5' => 0,
+            ];
         }
     }
 
@@ -856,6 +857,7 @@ class DeclarationForm extends Model
         $userForm->zcAmount = $this->_decAmount;
         $userForm->conUserName = $this->conUserName;
         $userForm->recUserName = $this->recUserName;
+        $userForm->bottomUserName = $this->bottomUserName;
         $userForm->location = $this->location;
         $userForm->idCard = $this->mobile;
         $userForm->allData = $allData;

+ 1 - 0
common/models/forms/DeclarationLoopForm.php

@@ -90,6 +90,7 @@ class DeclarationLoopForm extends Model
                 $model->insertUserIdCard = null;
                 $model->conUserName = null;
                 $model->recUserName = null;
+                $model->bottomUserName = null;
                 $model->location = null;
                 $model->decType = null;
             } else {

+ 17 - 13
common/models/forms/UserForm.php

@@ -28,9 +28,10 @@ class UserForm extends Model
     public $zcPv;
     public $zcAmount;
     public $conUserName;
-    public $conUserNameActual;
+    public $bottomUserName;
     public $recUserName;
     public $conUid;
+    public $bottomUid;
     public $recUid;
     public $location;
     public $idCard;
@@ -53,6 +54,7 @@ class UserForm extends Model
 
     private $_conUid;
     private $_recUid;
+    private $_bottomUid;
     private $_limit = 1000;
 
     private $_conTopUid;
@@ -101,7 +103,7 @@ class UserForm extends Model
             [['recUserName'], 'exist', 'targetClass'=>UserInfo::class, 'targetAttribute'=>'USER_NAME', 'on' => ['addWithUserName', 'addWithUid', 'addByAdmin']],
             [['conUserName'], 'isCon', 'on' => ['addWithUserName', 'addWithUid', 'addByAdmin']],
             [['recUserName'], 'isRec', 'on' => ['addWithUserName', 'addWithUid', 'addByAdmin']],
-//            [['location'], 'isLocation', 'on' => ['addWithUserName', 'addWithUid', 'addByAdmin']],
+            [['location'], 'isLocation', 'on' => ['addWithUserName', 'addWithUid', 'addByAdmin']],
             //[['idCard'], 'isSameNetwork'],
             [['zcPv', 'zcAmount'], 'price', 'on' => ['addWithUserName', 'addWithUid', 'addByAdmin']],
             [['zcPv'], 'isMinDecLevel', 'on' => ['addWithUserName', 'addWithUid', 'addByAdmin']],
@@ -138,10 +140,10 @@ class UserForm extends Model
     public function isConUid($attribute, $params){
         $this->_conUid = $this->conUid;
         // 查看该接点人在安置网络中的推荐人数量是否达到上限
-//        $childNum = UserNetwork::firstFloorChildNum($this->_conUid);
-//        if($childNum >= 3){
-//            $this->addError($attribute, '注册'.$this->userName.'时,接点人'.$this->conUserName.'点位已满无法继续添加');
-//        }
+        $childNum = UserNetwork::firstFloorChildNum($this->_conUid);
+        if($childNum >= 3){
+            $this->addError($attribute, '注册'.$this->userName.'时,接点人'.$this->conUserName.'点位已满无法继续添加');
+        }
     }
 
     /**
@@ -172,10 +174,10 @@ class UserForm extends Model
         if($oneConUserInfo){
             $this->_conUid = $oneConUserInfo['USER_ID'];
             // 查看该接点人在安置网络中的推荐人数量是否达到上限
-//            $childNum = UserNetwork::firstFloorChildNum($this->_conUid);
-//            if($childNum >= 3){
-//                $this->addError($attribute, $this->userName.'的接点人'.$this->conUserName.'点位已满无法继续添加');
-//            }
+            $childNum = UserNetwork::firstFloorChildNum($this->_conUid);
+            if($childNum >= 3){
+                $this->addError($attribute, $this->userName.'的接点人'.$this->conUserName.'点位已满无法继续添加');
+            }
         } else {
             $this->addError($attribute, '注册'.$this->userName.'时,接点人'.$this->conUserName.'帐号无效');
         }
@@ -296,8 +298,10 @@ class UserForm extends Model
         $insertUid = $this->userId;
         $insertUserName = $this->userName;
         $zcPv = $this->zcPv;
-        $conUid = $this->_conUid;
-        $recUid = $this->_recUid;
+        $conUid = $this->_conUid;   // 安置人
+        $recUid = $this->_recUid;   // 推荐人
+        // 实际推荐人
+        $recUidActual = User::findOneAsArray('USER_NAME=:USER_NAME', [':USER_NAME' => $this->bottomUserName]);
 //        $location = $this->location;
 
 //        $db = \Yii::$app->db;
@@ -314,8 +318,8 @@ class UserForm extends Model
             $userInfoModel->ZC_PV = $zcPv;
             $userInfoModel->ZC_AMOUNT = $this->zcAmount;
             $userInfoModel->CON_UID = $conUid;
-            $userInfoModel->CON_UID_ACTUAL = $recUid;
             $userInfoModel->REC_UID = $recUid;
+            $userInfoModel->REC_UID_ACTUAL = $recUidActual['ID'];
             $userInfoModel->SYSTEM_ID = $conUserInfo['SYSTEM_ID'];
             //$userInfoModel->PERIOD_NUM = $nowPeriodNum;
             $userInfoModel->CREATED_AT = Date::nowTime();

+ 15 - 4
frontendApi/modules/v1/controllers/UserController.php

@@ -513,11 +513,24 @@ class UserController extends BaseController {
             $post['province'] = $post['province'] ? :1;
             $post['city'] = $post['city'] ? :1;
             $post['county'] = $post['county'] ? :1;
-            $post['conUserName'] = trim($post['conUserName']);  // 推荐人编号 trim($post['conUserName']);
-            $post['recUserName'] = trim($post['recUserName']);  // 实际推荐人编号(原安置人编号) trim($post['recUserName']);
+            $conUserName = trim($post['conUserName']); // 实际推荐人
+
             $post['cityName'] = trim($post['cityName']);
             $post['lgaName'] = trim($post['lgaName']);
 
+            // 针对那群沙雕移除安置网络的行为,强制增加自动安置左侧
+            $recUserId = Info::getUserIdByUserName($conUserName);
+            $bottomPlace = UserNetwork::getBottomPlace($recUserId,'', 'left');
+            $bottomUser = UserNetwork::find()->select('USER_ID')->where('LOCATION_TAG=:LOCATION_TAG', ['LOCATION_TAG' => $bottomPlace])->asArray()->one();
+            $bottomUser = User::findOneAsArray('ID=:ID', [':ID' => $bottomUser['USER_ID']], 'USER_NAME');
+            $bottomUser = $bottomUser['USER_NAME']; // 推算出的安置人
+
+            $post['conUserName'] = $bottomUser; // 安置人
+            $post['recUserName'] = $conUserName; // 实际推荐人
+            $post['bottomUser'] = trim($post['recUserName']); // 推荐人
+
+            $post['location'] = 1;
+
             // 针对于会员编号的判断
             if($post['decType']=='normal'){ // 普通报单,判断Redis中的用户名是否一致
                 $insertUserName = strtoupper($post['insertUserName']);
@@ -650,11 +663,9 @@ class UserController extends BaseController {
         $userName = \Yii::$app->request->get('userName');
         $side = \Yii::$app->request->get('side');
         $userId = Info::getUserIdByUserName($userName);
-//        print_r($userId);
         $bottomPlace = UserNetwork::getBottomPlace($userId,'', $side);
         $bottomUser = UserNetwork::find()->select('USER_ID')->where('LOCATION_TAG=:LOCATION_TAG', ['LOCATION_TAG' => $bottomPlace])->asArray()->one();
         $bottomUser = User::findOneAsArray('ID=:ID', [':ID' => $bottomUser['USER_ID']], 'USER_NAME');
-//        print_r($bottomUser);
         return static::notice($bottomUser);
     }