Browse Source

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

zhangl 1 năm trước cách đây
mục cha
commit
a89ee4b557

+ 2 - 2
backendApi/config/menu.php

@@ -166,11 +166,11 @@ return [
             ['name'=>'开拓网络图', 'class'=>'', 'icon'=>'', 'controller'=>'atlas', 'action'=>'relation', 'routePath'=>'atlas/relation', 'show'=>0,],
             ['name'=>'开拓网络列表', 'class'=>'', 'icon'=>'', 'controller'=>'atlas', 'action'=>'relation-list', 'routePath'=>'atlas/relation-list', 'show'=>0,],
             ['name'=>'开拓网络列表导出', 'class'=>'', 'icon'=>'', 'controller'=>'atlas', 'action'=>'relation-list-export', 'routePath'=>'atlas/relation-list-export', 'show'=>0,],
-            ['name'=>'Placement network', 'class'=>'', 'icon'=>'', 'controller'=>'atlas', 'action'=>'network-opt', 'routePath'=>'atlas/network-opt', 'show'=>1, 'wiki' => 'placementNetwork'],//安置网络
+//            ['name'=>'Placement network', 'class'=>'', 'icon'=>'', 'controller'=>'atlas', 'action'=>'network-opt', 'routePath'=>'atlas/network-opt', 'show'=>1, 'wiki' => 'placementNetwork'],//安置网络
             ['name'=>'安置网络图', 'class'=>'', 'icon'=>'', 'controller'=>'atlas', 'action'=>'network', 'routePath'=>'atlas/network', 'show'=>0,],
             ['name'=>'安置网络列表', 'class'=>'', 'icon'=>'', 'controller'=>'atlas', 'action'=>'network-list', 'routePath'=>'atlas/network-list', 'show'=>0,],
             ['name'=>'安置网络列表导出', 'class'=>'', 'icon'=>'', 'controller'=>'atlas', 'action'=>'network-list-export', 'routePath'=>'atlas/network-list-export', 'show'=>0,],
-            ['name'=>'Placement Network Ex', 'class'=>'', 'icon'=>'', 'controller'=>'atlas', 'action'=>'network-ex', 'routePath'=>'atlas/relation-list', 'show'=>1, 'wiki' => 'placementNetworkEx',],//安置网络ex
+//            ['name'=>'Placement Network Ex', 'class'=>'', 'icon'=>'', 'controller'=>'atlas', 'action'=>'network-ex', 'routePath'=>'atlas/relation-list', 'show'=>1, 'wiki' => 'placementNetworkEx',],//安置网络ex
             ['name'=>'Sponsor Network Ex', 'class'=>'', 'icon'=>'', 'controller'=>'atlas', 'action'=>'relation-ex', 'routePath'=>'atlas/network-list', 'show'=>1, 'wiki' => 'sponsorNetworkEx',],//推荐网路ex
         ]
     ],

+ 12 - 12
backendApi/modules/v1/models/lists/user/IndexList.php

@@ -239,18 +239,18 @@ class IndexList extends \common\libs\dataList\DataList implements DataListInterf
                     'header' => Yii::t('ctx', 'recommendedName'),
                     'headerOther' => ['width' => '160'],
                 ],
-                'CON_USER_NAME' => [
-                    'header' => Yii::t('ctx', 'placementNo'),
-                    'headerOther' => ['width' => '140'],
-                ],
-                'CON_REAL_NAME' => [
-                    'header' => Yii::t('ctx', 'placementName'),
-                    'headerOther' => ['width' => '140'],
-                ],
-                'RELATIVE_LOCATION' => [
-                    'header' => Yii::t('ctx', 'resettlementArea'),
-                    'headerOther' => ['width' => '140'],
-                ],
+//                'CON_USER_NAME' => [
+//                    'header' => Yii::t('ctx', 'placementNo'),
+//                    'headerOther' => ['width' => '140'],
+//                ],
+//                'CON_REAL_NAME' => [
+//                    'header' => Yii::t('ctx', 'placementName'),
+//                    'headerOther' => ['width' => '140'],
+//                ],
+//                'RELATIVE_LOCATION' => [
+//                    'header' => Yii::t('ctx', 'resettlementArea'),
+//                    'headerOther' => ['width' => '140'],
+//                ],
                 'MOBILE' => [
                     'header' => Yii::t('ctx', 'phoneNumber'),
                     'value' => function($row) {

+ 4 - 3
common/messages/en-US/ctx.php

@@ -568,9 +568,10 @@ return [
     'latestCrown' => 'Highest Crown',
     'recommendationNo' => 'Sponsor Code',
     'recommendedName' => 'Sponsor Name',
-    'placementNo' => 'Placement No',
-    'placementName' => 'Placement Name',
-    'resettlementArea' => 'Resettlement Area',
+    'placementNo' => 'Placement Sponsor ID',    // Placement No
+    'placementName' => 'Placement Sponsor Name', // Placement Name
+    'resettlementArea' => 'Placement Sponsor Area', // Resettlement Area
+    'fillSponsorUpline' => "Please fill in the sponsor's upline.",
     'phoneNumber' => 'Phone Number',
     'alternatePhoneNumber' => 'Alternate Phone Number',
     'stockistCode' => 'Stockist Code',

+ 4 - 3
common/messages/zh-CN/ctx.php

@@ -566,9 +566,10 @@ return [
     'latestCrown' => '最新皇冠星级',
     'recommendationNo' => '推荐编号',
     'recommendedName' => '推荐姓名',
-    'placementNo' => '安置编号',
-    'placementName' => '安置姓名',
-    'resettlementArea' => '安置区域',
+    'placementNo' => '实际推荐人编号',    // 安置编号
+    'placementName' => '实际推荐人姓名',   // 安置姓名
+    'resettlementArea' => '实际推荐区域', // 安置区域
+    'fillSponsorUpline' => '实际推荐人必须是推荐人的上级',
     'phoneNumber' => '手机号码',
     'alternatePhoneNumber' => '备用手机号码',
     'stockistCode' => '所属报单中心编号',

+ 2 - 2
frontendApi/config/menu.php

@@ -55,9 +55,9 @@ return [
         'show'=>1,
         'wiki' => 'networkChart',
         'child'=>[
-            ['name'=>'Placement Network', 'class'=>'', 'icon'=>'', 'controller'=>'atlas', 'action'=>'network', 'routePath'=>'atlas/network', 'show'=>1, 'wiki' => 'placementNetwork',],//安置网络
+//            ['name'=>'Placement Network', 'class'=>'', 'icon'=>'', 'controller'=>'atlas', 'action'=>'network', 'routePath'=>'atlas/network', 'show'=>1, 'wiki' => 'placementNetwork',],//安置网络
             ['name'=>'Sponsor Network', 'class'=>'', 'icon'=>'', 'controller'=>'atlas', 'action'=>'relation', 'routePath'=>'atlas/relation', 'show'=>1, 'wiki' => 'sponsorNetwork',],//推荐网路
-            ['name'=>'Placement Network Ex', 'class'=>'', 'icon'=>'', 'controller'=>'atlas', 'action'=>'network-ex', 'routePath'=>'atlas/network', 'show'=>1, 'wiki' => 'placementNetworkEx',],//安置网络ex
+//            ['name'=>'Placement Network Ex', 'class'=>'', 'icon'=>'', 'controller'=>'atlas', 'action'=>'network-ex', 'routePath'=>'atlas/network', 'show'=>1, 'wiki' => 'placementNetworkEx',],//安置网络ex
             ['name'=>'Sponsor Network Ex', 'class'=>'', 'icon'=>'', 'controller'=>'atlas', 'action'=>'relation-ex', 'routePath'=>'atlas/relation', 'show'=>1, 'wiki' => 'sponsorNetworkEx',],//推荐网路ex
         ]
     ],

+ 1 - 1
frontendApi/config/urlManagerRules.php

@@ -118,7 +118,7 @@ return [
             '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',
             'POST ba-edit' => 'ba-edit',
             'POST ba-password' => 'ba-password',

+ 61 - 3
frontendApi/modules/v1/controllers/UserController.php

@@ -8,6 +8,7 @@
 
 namespace frontendApi\modules\v1\controllers;
 
+use common\helpers\bonus\CalcCache;
 use common\helpers\Cache;
 use common\helpers\Form;
 use common\helpers\LoggerTool;
@@ -33,6 +34,7 @@ use common\models\forms\UserBindForm;
 use common\models\forms\UserForm;
 use common\models\Instalment;
 use common\models\OpenBank;
+use common\models\Period;
 use common\models\ReceiveAddress;
 use common\models\Region;
 use common\models\ShopGoods;
@@ -46,6 +48,7 @@ use common\models\BaUserInfo;
 use common\models\UserNetwork;
 use common\models\forms\DeclarationUpgradeForm;
 use common\models\UserWallet;
+use frontendApi\modules\v1\models\Relation;
 use Yii;
 use yii\db\Exception;
 use yii\web\UploadedFile;
@@ -53,6 +56,8 @@ use yii\web\UploadedFile;
 class UserController extends BaseController {
     public $modelClass = UserInfo::class;
 
+    const LOOP_FINISH = 1;
+
     /**
      * 会员资料
      * @return mixed
@@ -432,8 +437,6 @@ class UserController extends BaseController {
             ->asArray()
             ->all();
 
-        LoggerTool::info(json_encode(["STATUS=1 AND CATEGORY_TYPE=1 " . $query_condition]));
-
         foreach ($allGoods as &$goods) {
             $goods['TAX'] = Tool::calculateTax($goods['SELL_PRICE'], $goods['TAX_RATE']);
         }
@@ -636,7 +639,6 @@ class UserController extends BaseController {
         //所有报单级别套餐
         $allDecPackage = DeclarationPackage::getPackageFromLevelId($decLv);
         return static::notice(['allDecPackage' => $allDecPackage]);
-
     }
 
     /*
@@ -688,6 +690,62 @@ class UserController extends BaseController {
         }
     }
 
+    public function actionInspectNetwork()
+    {
+        // 推荐人信息
+        $recommenderName= \Yii::$app->request->get('recommenderName');
+        $userId = Info::getUserIdByUserName($recommenderName);
+        $recommender = User::findOneAsArray('ID=:ID', [':ID' => $userId]);
+        if (!$recommender) {
+            return static::notice(Yii::t('app', 'memberNumberDoesNotExist'), 400);
+        }
+
+        // 实际推荐人信息
+        $recommenderActualName= \Yii::$app->request->get('recommenderActualName');
+        $actualId = Info::getUserIdByUserName($recommenderActualName);
+        $recommenderActual = User::findOneAsArray('ID=:ID', [':ID' => $actualId]);
+        if (!$recommenderActual) {
+            return static::notice(Yii::t('app', 'memberNumberDoesNotExist'), 400);
+        }
+
+        // 实际推荐人是否是推荐人本人
+        if ($actualId == $userId) {
+            return static::notice([
+                'REAL_NAME' => $recommenderActual['REAL_NAME'],
+                'userId' => $recommenderActual['ID'],
+                'countryId' => $recommenderActual['countryId'],
+            ]);
+        }
+
+        // 实际推荐人是否是推荐人的推荐网上级
+        $periodNum = Period::instance()->getNowPeriodNum();
+
+        $relation = new Relation();
+        $allowable = $relation->loopRelationParentDo(
+            /**
+            * @throws \Exception
+            */
+            $userId, function ($parent) use ($actualId, $periodNum) {
+            $parentUser = CalcCache::getUserInfo($parent['PARENT_UID'], $periodNum);
+            if ($parentUser['ID'] == $actualId) {
+                return self::LOOP_FINISH;
+            }
+
+            unset($parent);
+        });
+
+        if ($allowable) {
+            return static::notice([
+                'REAL_NAME' => $recommenderActual['REAL_NAME'],
+                'userId' => $recommenderActual['ID'],
+                'countryId' => $recommenderActual['countryId'],
+            ]);
+        }
+
+
+        return static::notice(Yii::t('ctx', 'fillSponsorUpline'), 400);
+    }
+
     /**
      * 复消会员信息查询
      * @return mixed

+ 41 - 0
frontendApi/modules/v1/models/Relation.php

@@ -0,0 +1,41 @@
+<?php
+
+namespace frontendApi\modules\v1\models;
+
+use common\helpers\Cache;
+
+class Relation extends \common\components\ActiveRecord
+{
+    const LOOP_FINISH = 1;
+    const LOOP_CONTINUE = 2;
+    private $_limit = 5000;
+
+    /**
+     * 循环推荐网络的父级
+     * @param $userId
+     * @param callable $callbackFunc
+     * @param int $offset
+     * @return bool
+     */
+    public function loopRelationParentDo($userId, callable $callbackFunc, int $offset = 0): bool
+    {
+        $allParents = Cache::getAllRelationParents($userId);
+        $allData = array_slice($allParents, $offset, $this->_limit);
+        unset($allParents);
+        if ($allData) {
+            foreach ($allData as $data) {
+                $funcResult = $callbackFunc($data);
+                if ($funcResult === self::LOOP_FINISH) {
+                    return true;
+                } elseif ($funcResult === self::LOOP_CONTINUE) {
+                    continue;
+                }
+                unset($data, $funcResult);
+            }
+
+            unset($allData);
+            return $this->loopRelationParentDo($userId, $callbackFunc, $offset + $this->_limit);
+        }
+        return true;
+    }
+}