kevin пре 1 година
родитељ
комит
c4624b5cf1
1 измењених фајлова са 16 додато и 12 уклоњено
  1. 16 12
      frontendApi/modules/v1/controllers/UserController.php

+ 16 - 12
frontendApi/modules/v1/controllers/UserController.php

@@ -513,8 +513,13 @@ class UserController extends BaseController {
                 }
             }
 
-            // 实际推荐人必须是推荐人的推荐网上级
-            $sqlUp =<<<SQL
+            $conUserName = trim($post['conUserName']); // 实际推荐人
+            $recUserName = trim($post['recUserName']);
+
+            // 如果推荐人和实际推荐人是同一人,则跳过检查
+            if ($recUserName != $conUserName) {
+                // 实际推荐人必须是推荐人的推荐网上级
+                $sqlUp = <<<SQL
             WITH recursive t_rec AS 
             (
                 SELECT
@@ -550,16 +555,17 @@ class UserController extends BaseController {
             FROM
                 t_rec
 SQL;
-            // 查询推荐人的所有上级
-            $relationNodeUp = \Yii::$app->db->createCommand($sqlUp)
-                ->bindValue(':USER_NAME' , $post['recUserName'])
-                ->queryAll();
+                // 查询推荐人的所有上级
+                $relationNodeUp = \Yii::$app->db->createCommand($sqlUp)
+                    ->bindValue(':USER_NAME', $post['recUserName'])
+                    ->queryAll();
 
-            $relationNodeUp = array_column($relationNodeUp, 'USER_NAME');
-            unset($relationNodeUp[$post['recUserName']]);
+                $relationNodeUp = array_column($relationNodeUp, 'USER_NAME');
+                unset($relationNodeUp[$post['recUserName']]);
 
-            if (!in_array($post['conUserName'], $relationNodeUp)) {
-                return static::notice(Yii::t('app', 'fillSponsorUpline'), 400);
+                if (!in_array($post['conUserName'], $relationNodeUp)) {
+                    return static::notice(Yii::t('app', 'fillSponsorUpline'), 400);
+                }
             }
 
             // 根据支付方式区分逻辑
@@ -577,8 +583,6 @@ SQL;
             $post['province'] = $post['province'] ? :1;
             $post['city'] = $post['city'] ? :1;
             $post['county'] = $post['county'] ? :1;
-            $conUserName = trim($post['conUserName']); // 实际推荐人
-            $recUserName = trim($post['recUserName']);
 
             $post['cityName'] = trim($post['cityName']);
             $post['lgaName'] = trim($post['lgaName']);