ryan 3 viikkoa sitten
vanhempi
commit
79bdb90f6b

+ 2 - 0
frontendApi/config/params.php

@@ -19,6 +19,8 @@ return [
         'v1/shop/verify-approach-order',
         'v1/user/guest-dec',
         'v1/user/guest-dec-status',
+        'v1/user/guest-full-info',
+        'v1/user/guest-inspect-network',
         'v1/finance/prove-add',
         'v1/site/get-instance',
         'v1/site/languages',

+ 8 - 6
frontendApi/config/urlManagerRules.php

@@ -119,12 +119,14 @@ return [
             'GET guest-dec-status' => 'guest-dec-status',
             'GET,POST upgrade' => 'upgrade',
             'POST upgrade-info' => 'upgrade-info',
-            'GET dec-package' => 'dec-package',
-            'GET full-info' => 'full-info',
-            'GET get-auto-place' => 'get-auto-place',
-            'GET user-base-info' => 'user-base-info',
-            'GET inspect-network' => 'inspect-network',
-            'GET ba-info' => 'ba-info',
+            'GET dec-package' => 'dec-package',
+            'GET full-info' => 'full-info',
+            'GET guest-full-info' => 'guest-full-info',
+            'GET get-auto-place' => 'get-auto-place',
+            'GET user-base-info' => 'user-base-info',
+            'GET inspect-network' => 'inspect-network',
+            'GET guest-inspect-network' => 'guest-inspect-network',
+            'GET ba-info' => 'ba-info',
             'POST ba-edit' => 'ba-edit',
             'POST ba-password' => 'ba-password',
             'POST ba-pay-password' => 'ba-pay-password',

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

@@ -903,6 +903,37 @@ SQL;
         }
     }
 
+    /**
+     * Public member information lookup for guest declaration flows.
+     * @return mixed
+     */
+    public function actionGuestFullInfo()
+    {
+        $userName = trim((string) \Yii::$app->request->get('userName', ''));
+        $userId = Info::getUserIdByUserName($userName);
+        $user = $userId ? User::findOneAsArray('ID=:ID', [':ID' => $userId]) : null;
+        if (!$user) {
+            return static::notice(Yii::t('app', 'memberNumberDoesNotExist'), 400);
+        }
+
+        $allChildUser = UserNetwork::getFirstFloorChildren($userId);
+        $isLocation = [1 => 'Left-Null', 2 => 'Right-Null'];
+        if ($allChildUser) {
+            foreach ($allChildUser as $child) {
+                if ($child['RELATIVE_LOCATION'] < '3' && isset($isLocation[$child['RELATIVE_LOCATION']])) {
+                    $isLocation[$child['RELATIVE_LOCATION']] = str_replace('Null', 'Full', $isLocation[$child['RELATIVE_LOCATION']]);
+                }
+            }
+        }
+
+        return static::notice([
+            'REAL_NAME' => $user['REAL_NAME'],
+            'countryId' => $user['COUNTRY_ID'],
+            'userId' => $userId,
+            'isLocation' => '(' . implode(',', $isLocation) . ')',
+        ]);
+    }
+
     public function actionInspectNetwork()
     {
         // 推荐人信息
@@ -984,6 +1015,73 @@ SQL;
         return static::notice(Yii::t('ctx', 'fillSponsorUpline'), 400);
     }
 
+    /**
+     * Public sponsor relationship validation for guest declaration flows.
+     * @return mixed
+     */
+    public function actionGuestInspectNetwork()
+    {
+        $recommenderName = trim((string) \Yii::$app->request->get('recommenderName', ''));
+        $recommenderActualName = trim((string) \Yii::$app->request->get('recommenderActualName', ''));
+        if ($recommenderName === '' || $recommenderActualName === '') {
+            return static::notice(Yii::t('app', 'memberNumberDoesNotExist'), 400);
+        }
+
+        $userId = Info::getUserIdByUserName($recommenderName);
+        $recommender = $userId ? User::findOneAsArray('ID=:ID', [':ID' => $userId]) : null;
+        if (!$recommender) {
+            return static::notice(Yii::t('app', 'memberNumberDoesNotExist'), 400);
+        }
+
+        $actualId = Info::getUserIdByUserName($recommenderActualName);
+        $recommenderActual = $actualId ? User::findOneAsArray('ID=:ID', [':ID' => $actualId]) : null;
+        if (!$recommenderActual) {
+            return static::notice(Yii::t('app', 'memberNumberDoesNotExist'), 400);
+        }
+
+        if ($actualId == $userId) {
+            return static::notice([
+                'REAL_NAME' => $recommenderActual['REAL_NAME'],
+                'userId' => $recommenderActual['ID'],
+            ]);
+        }
+
+        $sqlUp = <<<SQL
+            WITH recursive t_rec AS
+            (
+                SELECT m.USER_ID, U.USER_NAME, m.PARENT_UID, U2.USER_NAME AS PARENT_NAME, 1 AS node_level
+                FROM AR_USER_RELATION_NEW m
+                LEFT JOIN AR_USER U ON U.ID = m.USER_ID
+                LEFT JOIN AR_USER U2 ON U2.ID = m.PARENT_UID
+                WHERE U.USER_NAME = :USER_NAME
+
+                UNION ALL
+
+                SELECT t1.USER_ID, U.USER_NAME, t1.PARENT_UID, U2.USER_NAME AS PARENT_NAME,
+                       t2.node_level + 1
+                FROM AR_USER_RELATION_NEW t1
+                JOIN t_rec t2 ON t2.PARENT_UID = t1.USER_ID
+                LEFT JOIN AR_USER U ON U.ID = t1.USER_ID
+                LEFT JOIN AR_USER U2 ON U2.ID = t1.PARENT_UID
+            )
+            SELECT * FROM t_rec
+SQL;
+
+        $relationNodeUp = \Yii::$app->db->createCommand($sqlUp)
+            ->bindValue(':USER_NAME', $recommenderName)
+            ->queryAll();
+        $relationNodeUp = array_column($relationNodeUp, 'USER_NAME');
+
+        if (in_array($recommenderActualName, $relationNodeUp, true)) {
+            return static::notice([
+                'REAL_NAME' => $recommenderActual['REAL_NAME'],
+                'userId' => $recommenderActual['ID'],
+            ]);
+        }
+
+        return static::notice(Yii::t('ctx', 'fillSponsorUpline'), 400);
+    }
+
     /**
      * 复消会员信息查询
      * @return mixed