UserController.php 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: leo
  5. * Date: 2018/2/24
  6. * Time: 下午12:48
  7. */
  8. namespace frontendApi\modules\v1\controllers;
  9. use common\helpers\bonus\CalcCache;
  10. use common\helpers\Cache;
  11. use common\helpers\Form;
  12. use common\helpers\LoggerTool;
  13. use common\helpers\Tool;
  14. use common\helpers\user\Info;
  15. use common\models\BaUser;
  16. use common\models\Config;
  17. use common\models\Countries;
  18. use common\models\Currency;
  19. use common\models\CurrencyConversions;
  20. use common\models\DeclarationLevel;
  21. use common\models\DeclarationPackage;
  22. use common\models\DecOrder;
  23. use common\models\forms\ApproachDeclarationLoopForm;
  24. use common\models\forms\BaApproachDeclarationLoopForm;
  25. use common\models\forms\ApproachDeclarationUpgradeForm;
  26. use common\models\forms\BaUserForm;
  27. use common\models\forms\DeclarationForm;
  28. use common\models\forms\BaDeclarationForm;
  29. use common\models\forms\DeclarationLoopForm;
  30. use common\models\forms\BaDeclarationLoopForm;
  31. use common\models\forms\UploadForm;
  32. use common\models\forms\UserBindForm;
  33. use common\models\forms\UserForm;
  34. use common\models\Instalment;
  35. use common\models\OpenBank;
  36. use common\models\Period;
  37. use common\models\ReceiveAddress;
  38. use common\models\Region;
  39. use common\models\ShopGoods;
  40. use common\models\ShopGoodsNature;
  41. use common\models\UpgradeType;
  42. use common\models\User;
  43. use common\models\UserBind;
  44. use common\models\UserBonus;
  45. use common\models\UserInfo;
  46. use common\models\BaUserInfo;
  47. use common\models\UserNetwork;
  48. use common\models\forms\DeclarationUpgradeForm;
  49. use common\models\UserWallet;
  50. use frontendApi\modules\v1\models\Relation;
  51. use Yii;
  52. use yii\db\Exception;
  53. use yii\web\UploadedFile;
  54. class UserController extends BaseController {
  55. public $modelClass = UserInfo::class;
  56. const LOOP_FINISH = 1;
  57. /**
  58. * 会员资料
  59. * @return mixed
  60. * @throws \yii\web\HttpException
  61. */
  62. public function actionIndex() {
  63. $allNation = \Yii::$app->params['nation'];
  64. $allOpenBank = OpenBank::findAllAsArray('STATUS=1');
  65. $data['allNation'] = $allNation;
  66. $data['allOpenBank'] = $allOpenBank;
  67. $data['userInfo'] = User::getEnCodeInfo(\Yii::$app->user->id);
  68. $data['userInfo']['NATION'] = $data['userInfo']['NATION_ID'];
  69. return static::notice($data);
  70. }
  71. /**
  72. * 编辑会员资料
  73. * @return mixed
  74. * @throws \yii\web\HttpException
  75. */
  76. public function actionEdit() {
  77. if(\Yii::$app->request->isPost){
  78. $form = new UserForm();
  79. $post = \Yii::$app->request->post();
  80. $form->scenario = 'modifyProfile';
  81. if($form->load($post, '') && $result = $form->modifyProfile()){
  82. return static::notice(Yii::t('app', 'personalDataModifiedSuccessfully'), 400);
  83. } else {
  84. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  85. }
  86. }
  87. return static::notice(Yii::t('app', 'illegalRequest'), 400);
  88. }
  89. /**
  90. * 修改登录密码
  91. */
  92. public function actionPassword(){
  93. if(\Yii::$app->request->isPost){
  94. $form = new UserForm();
  95. $form->scenario = 'modifyPassword';
  96. $post = \Yii::$app->request->post();
  97. if($form->load($post, '') && $result = $form->modifyPassword()){
  98. return static::notice(Yii::t('app', 'passwordModifiedSuccessfully'), 400);
  99. } else {
  100. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  101. }
  102. }
  103. return static::notice(Yii::t('app', 'illegalRequest'), 400);
  104. }
  105. /**
  106. * 修改支付密码
  107. */
  108. public function actionPayPassword(){
  109. if(\Yii::$app->request->isPost){
  110. $form = new UserForm();
  111. $form->scenario = 'modifyPasswordPay';
  112. $post = \Yii::$app->request->post();
  113. $form->userId = \Yii::$app->user->id;
  114. if($form->load($post, '') && $result = $form->modifyPasswordPay()){
  115. return static::notice(Yii::t('app', 'passwordModifiedSuccessfully'));
  116. } else {
  117. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  118. }
  119. }
  120. return static::notice(Yii::t('app', 'illegalRequest'), 400);
  121. }
  122. /**
  123. * 直推会员列表
  124. * @return mixed
  125. * @throws \yii\web\HttpException
  126. */
  127. public function actionRecUser() {
  128. $allData = UserInfo::lists('AND REC_UID=:REC_UID', [':REC_UID' => \Yii::$app->user->id], ['useSlaves' => true, 'select'=>'USER_ID,CREATED_AT']);
  129. foreach ($allData['list'] as $key => $data) {
  130. $userBaseInfo = User::getEnCodeInfo($data['USER_ID']);
  131. $userBaseInfo['NATION'] = \Yii::$app->params['nation'][$userBaseInfo['NATION']]['name'] ?? '';
  132. $allData['list'][$key]['BASE_INFO'] = $userBaseInfo;
  133. }
  134. return static::notice($allData);
  135. }
  136. /**
  137. * 上传身份证
  138. * @return mixed
  139. * @throws \yii\base\Exception
  140. * @throws \yii\web\HttpException
  141. */
  142. public function actionIdCard() {
  143. if (\Yii::$app->request->isPost) {
  144. $formModel = new UploadForm();
  145. $formModel->scenario = 'idCardFront';
  146. $formModel->file = UploadedFile::getInstanceByName('file');
  147. //$formModel->token = \Yii::$app->request->post('uploadToken');
  148. $formModel->token = \Yii::$app->request->request('uploadToken');
  149. if ($formModel->file && $formModel->upload()) {
  150. return static::notice(Yii::t('app', 'successfully'));
  151. } else {
  152. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  153. }
  154. }
  155. // 查看该用户是否已经上传过身份证
  156. $oneData = User::find()->select('ID_IMAGE')->where('ID=:ID', [':ID' => \Yii::$app->user->id])->asArray()->one();
  157. if ($oneData['ID_IMAGE']) {
  158. return static::notice($oneData);
  159. } else {
  160. $token = Cache::setUploadToken();
  161. return static::notice($token);
  162. }
  163. }
  164. /**
  165. * 点位绑定
  166. * @return mixed
  167. * @throws \yii\base\Exception
  168. * @throws \yii\web\HttpException
  169. */
  170. public function actionBind() {
  171. $userBind = UserBind::findOneAsArray('USER_ID=:USER_ID AND IS_DEL=0', [':USER_ID' => \Yii::$app->user->id]);
  172. $allData['list']=UserBind::findAllAsArray('MAIN_UID=:MAIN_UID AND IS_DEL=0', [':MAIN_UID' => $userBind['MAIN_UID']], 'ID,USER_ID,MAIN_UID,CREATED_AT,UPDATED_AT');
  173. foreach ($allData['list'] as $key => $value) {
  174. $baseInfo = Info::baseInfoZh($value['USER_ID']);
  175. if ($baseInfo['STATUS'] != 1) {
  176. unset($allData['list'][$key]);
  177. continue;
  178. }
  179. $allData['list'][$key]['USER_NAME'] = $baseInfo['USER_NAME'];
  180. $allData['list'][$key]['REAL_NAME'] = $baseInfo['REAL_NAME'];
  181. $allData['list'][$key]['BANK_PROVINCE_NAME'] = $baseInfo['BANK_PROVINCE_NAME'];
  182. $allData['list'][$key]['BANK_CITY_NAME'] = $baseInfo['BANK_CITY_NAME'];
  183. $allData['list'][$key]['BANK_COUNTY_NAME'] = $baseInfo['BANK_COUNTY_NAME'];
  184. $allData['list'][$key]['OPEN_BANK_NAME'] = $baseInfo['OPEN_BANK_NAME'];
  185. $allData['list'][$key]['BANK_NO'] = $baseInfo['BANK_NO'];
  186. $allData['list'][$key]['MAIN_USER_NAME'] =Info::getUserNameByUserId($value['MAIN_UID']);
  187. }
  188. $allData['list'] = array_values($allData['list']);
  189. return static::notice($allData);
  190. }
  191. /**
  192. * 编辑点位绑定
  193. * @return mixed
  194. * @throws \yii\web\HttpException
  195. */
  196. public function actionBindEdit(){
  197. $id = \Yii::$app->request->get('id');
  198. if(\Yii::$app->request->isPost) {
  199. return parent::edit(UserBindForm::class, Yii::t('app', 'successfully'), 'frontEdit', ['frontEdit'], null, function($form, $result){
  200. //log
  201. });
  202. }
  203. // 获得当前会员的用户名等信息
  204. $userBind = UserBind::findOneAsArray('ID=:ID AND IS_DEL=0', [':ID' => $id]);
  205. $userBinds = UserBind::findAllAsArray('MAIN_UID=:MAIN_UID AND IS_DEL=0',[':MAIN_UID'=>$userBind['MAIN_UID']], 'ID,USER_ID,MAIN_UID,CREATED_AT,UPDATED_AT');
  206. foreach($userBinds as $key=>$value){
  207. $status = Info::getStatusByUserId($value['USER_ID']);
  208. if ($status != 1) {
  209. unset($userBinds[$key]);
  210. continue;
  211. }
  212. $userBinds[$key]['USER_NAME'] = Info::getUserNameByUserId($value['USER_ID']);
  213. }
  214. $userBinds = array_values($userBinds);
  215. return static::notice(['userBinds' => $userBinds,'mainUid'=>$userBind['MAIN_UID']]);
  216. }
  217. // 会员升级,通过会员的编号,获取会员信息
  218. public function actionUpgradeInfo() {
  219. $isSwitchUpgrade = Config::find()
  220. ->where("CONFIG_NAME='isOpenUpgrade'")
  221. ->asArray()
  222. ->one();
  223. $isOpen = !empty($isSwitchUpgrade) && isset($isSwitchUpgrade['VALUE']) ? $isSwitchUpgrade['VALUE'] : 0;
  224. if ($isOpen < 1) {
  225. return static::notice(Yii::t('app', 'theFunctionIsNotAvailable'), 400);
  226. }
  227. $userNumber = \Yii::$app->request->request('userName');
  228. $baseInfo = Info::baseInfoZhByUserName($userNumber);
  229. if ($baseInfo['STATUS'] != 1) {
  230. return static::notice(Yii::t('app', 'inactiveUser'), 400);
  231. }
  232. // 1. 如果是最高级别,则只显示用户基本信息
  233. // 2. 如果不是最高级别,如果用户累计报单数据是0, 或者用户累计报单业绩不符合级别信息,则提示 请联系客服核对业绩
  234. $userId = $baseInfo['ID'];
  235. $userDecId = $baseInfo['DEC_LV'];// 用户当前的级别
  236. // 获取系统中的DEC 报单级别配置
  237. $decConfig = Cache::getDecLevelConfig();
  238. $userDecInfo = $decConfig[$userDecId]; // 会员的级别具体信息
  239. $maxPerfInfo = DeclarationLevel::getMaxDecPref();
  240. $maxDecId = $maxPerfInfo['ID']; // 级别配置中最高级别ID
  241. $observe = Config::getConfigByType('observe'); // 获取观察期配置信息
  242. $observeLimit = $observe['observePeriodLimit']['value']; // 月份限制
  243. $isObserve = User::checkIsObserve($baseInfo['CREATED_AT'], $observeLimit); // 判断用户是否再观察期中
  244. // 如果用户已经是最高级别,则只展示用户信息
  245. $isMax = false;
  246. if ($maxDecId == $userDecId) {
  247. $isMax = true;
  248. }
  249. // 分期的总期数
  250. $instalmentConfig = intval(Cache::getSystemConfig()['instalment']['VALUE'] ?? 3);
  251. // 查询是否有FX的分期订单
  252. $stageFX = Instalment::getOneStage($baseInfo['ID'], 'FX');
  253. if ($stageFX && $stageFX < $instalmentConfig) {
  254. $instalment = false;
  255. } else {
  256. // 是否有未完成的BD类型的分期订单
  257. $stage = Instalment::getOneStage($userId, 'BD');
  258. if ($stage && $stage < $instalmentConfig) {
  259. $instalment = true;
  260. } else if ($isMax && $stage == $instalmentConfig) {
  261. $instalment = false;
  262. } else {
  263. $instalment = false;
  264. }
  265. }
  266. // 如果用户已经是最高级别,则只展示用户信息
  267. $userInfo = [
  268. 'DEC_NAME' => $baseInfo['DEC_LV_NAME'], // 用户级别中文
  269. 'DEC_ID' => $userDecId, // 用户级别id
  270. 'REAL_NAME' => $baseInfo['REAL_NAME'], // 真实姓名
  271. 'ADD_AT' => date('Y-m-d', $baseInfo['CREATED_AT']), // 加入时间
  272. 'COUNTRY_NAME' => $baseInfo['COUNTRY_NAME'], // 国家
  273. 'IS_OBSERVE' => $isObserve, // 是否是观察期 true为是观察期
  274. 'IS_MAX' => $isMax, // 是否已是最大级别 最大级别不需要判断报单总PV是多少 只展示基本信息
  275. 'INSTALMENT' => $instalment,
  276. 'NOW_PERF' => User::sumDevPvByUserId($userId), // 用户所有报单PV总和
  277. ];
  278. // 如果是最高级别了,则无需升级
  279. if ($isMax) {
  280. return static::notice(['baseInfo' => $userInfo]);
  281. }
  282. $levelPerf = $userDecInfo['PERF'];// 用户当前级别对应的业绩值
  283. if (!$isMax) {
  284. $userDecPvSum = User::sumDevPvByUserId($userId); // 用户所有报单PV总和
  285. // // 如果总和小于级别业绩 去掉这校验直接补比如3000-980的差值
  286. // if ($userDecPvSum < $levelPerf) {
  287. // return static::notice('请联系客服人员核对业绩',400);
  288. // }
  289. // 下一级业绩
  290. $nextLevelPerf = DeclarationLevel::getNextDecPref($levelPerf)['PERF'];
  291. // 如果总和超过了下一级业绩
  292. if ($userDecPvSum >= $nextLevelPerf) {
  293. return static::notice(Yii::t('app', 'checkPerformance'), 400);
  294. }
  295. $type = $isObserve ? 1 : 2;
  296. $userInfo['UPGRADE_FUNC'] = $isObserve ? Yii::t('app', 'fillingUpOfADeficit') : Yii::t('app', 'fullPayment');
  297. $upgradeType = UpgradeType::getOneByType($type);
  298. // 如果用户不是最大级别,则需要获取是否观察期,算出PV是否有问题,应该补多少,
  299. $userInfo['UPGRADE_TYPE'] = $upgradeType;
  300. $userInfo['NOW_PERF'] = $userDecPvSum;
  301. $userInfo['NEXT_PERF'] = $nextLevelPerf;
  302. // 用户可选择的级别列表
  303. $userInfo['LEVEL_LIST'] = DeclarationLevel::getNextAll($levelPerf);// 用户可选择的级别列表
  304. // 如果用户正处于报单分期中,则可以升级到Elite
  305. $userInstalmentInfo = Instalment::getInfo($userId);
  306. if($userInstalmentInfo){
  307. if ($userInstalmentInfo['ORDER_TYPE']=='BD' && $userInstalmentInfo['STAGE'] < 3){
  308. $userInfo['LEVEL_LIST'] = DeclarationLevel::getNextAll(12);// 用户可选择的级别列表
  309. unset($userInfo['LEVEL_LIST'][$userDecId]);
  310. }
  311. }
  312. // 循环列表,补充升级所需要的补差
  313. foreach ($userInfo['LEVEL_LIST'] as &$v) {
  314. $v['REPAIR_PV'] = $isObserve ? $v['PERF'] - $userInfo['NOW_PERF'] : $v['PERF'];
  315. }
  316. }
  317. return static::notice(['baseInfo' => $userInfo]);
  318. }
  319. // 会员升级管理
  320. public function actionUpgrade() {
  321. $isMax = \Yii::$app->request->get('isMax');
  322. $userNumber = \Yii::$app->request->get('userName');
  323. $isSwitchUpgrade = Config::find()
  324. ->where("CONFIG_NAME='isOpenUpgrade'")
  325. ->asArray()
  326. ->one();
  327. $isOpen = !empty($isSwitchUpgrade) && isset($isSwitchUpgrade['VALUE']) ? $isSwitchUpgrade['VALUE'] : 0;
  328. if ($isOpen < 1) {
  329. return static::notice(Yii::t('app', 'theFunctionIsNotAvailable'), 400);
  330. }
  331. // 开始升级
  332. if (\Yii::$app->request->isPost) {
  333. $post = \Yii::$app->request->post();
  334. // 根据支付方式区分逻辑
  335. $payMethod = \Yii::$app->request->post('payType', '');
  336. if ($payMethod === 'pay_stack') {
  337. $formModel = new ApproachDeclarationUpgradeForm();
  338. } else {
  339. unset($post['payType']);
  340. $formModel = new DeclarationUpgradeForm();
  341. }
  342. $post['type'] = DeclarationForm::TYPE_ZC;
  343. if ($formModel->load($post, '') && $result = $formModel->add($post)) {
  344. return static::notice($result);// Upgrade declaration succeeded升级报单成功
  345. } else {
  346. return static::notice(Form::formatErrorsForApi($formModel->getErrors()),400);
  347. }
  348. }
  349. // 升级的会员
  350. $userName = \Yii::$app->request->get('userName');
  351. // 会员信息
  352. $user = User::findOneAsArray('USER_NAME=:USER_NAME', [':USER_NAME' => trim($userName)]);
  353. if (!$user) {
  354. return static::notice(Yii::t('app', 'memberNumberDoesNotExist'), 400);
  355. }
  356. //所有报单套餐
  357. $allDecPackage = DeclarationPackage::getAllData();
  358. $decLevels = Cache::getDecLevelConfig();
  359. foreach ($allDecPackage as $k=>$v){
  360. $levelName = $decLevels[$v['LEVEL_ID']]['LEVEL_NAME'] ?? '';
  361. $allDecPackage[$k]['LEVEL_NAME'] = $levelName;
  362. }
  363. $baseInfo = Info::baseInfoZhByUserName($userNumber);
  364. // 分期的总期数
  365. $instalmentConfig = intval(Cache::getSystemConfig()['instalment']['VALUE'] ?? 3);
  366. // 查询是否有FX的分期订单
  367. $stageFX = Instalment::getOneStage($baseInfo['ID'], 'FX');
  368. if ($stageFX && $stageFX < $instalmentConfig) {
  369. if ($isMax === "true") {
  370. $condition = ") AND S.INSTALMENT = 1000";
  371. } else {
  372. $condition = ") AND (S.INSTALMENT = 0 OR S.INSTALMENT = 1000)";
  373. }
  374. } else {
  375. // 是否有未完成的BD类型的分期订单
  376. $stageBD = Instalment::getOneStage($baseInfo['ID'], 'BD');
  377. if ($isMax === "true") {
  378. if ($stageBD > 0 && $stageBD < $instalmentConfig) {
  379. $condition = ") AND (S.INSTALMENT = " . ($stageBD + 1) . ")";
  380. } else {
  381. $condition = ") AND S.INSTALMENT = 0";
  382. }
  383. } else {
  384. if ($stageBD > 0 && $stageBD < $instalmentConfig) {
  385. $condition = ") AND (S.INSTALMENT = 0 OR S.INSTALMENT = " . ($stageBD + 1) . ")";
  386. } else {
  387. $condition = ") AND (S.INSTALMENT = 0 OR S.INSTALMENT = 1)";
  388. }
  389. }
  390. }
  391. //所有自选商品
  392. $isDecReg = Cache::getSystemConfig()['isDecReg']['VALUE'];
  393. $isDec = User::getEnCodeInfo(\Yii::$app->user->id)['IS_DEC'];
  394. $isStudio = User::getEnCodeInfo(\Yii::$app->user->id)['IS_STUDIO'];
  395. $decUserName = User::getEnCodeInfo(\Yii::$app->user->id)['USER_NAME'];
  396. $query_condition= " AND (1<>1";
  397. if(!$isDecReg || ($isDecReg && $isDec==1)){
  398. $query_condition = " AND (FIND_IN_SET(1, S.GIFT_TYPE)>0";
  399. }
  400. if($isStudio==1){
  401. $query_condition .= " OR FIND_IN_SET(3, S.GIFT_TYPE)>0";
  402. }
  403. $query_condition .= $condition . ' AND N.COUNTRY_ID=:COUNTRY_ID ';
  404. $allGoods = ShopGoods::find()
  405. ->alias('S')
  406. ->select('S.*,N.MARKET_PRICE,N.SELL_PRICE,N.TAX_RATE,N.LOCAL_CURRENCY_ID,N.COUNTRY_ID,C.CODE')
  407. ->join('INNER JOIN', ShopGoodsNature::tableName() . ' AS N', 'N.GOODS_ID=S.ID')
  408. ->join('INNER JOIN', Currency::tableName() . ' AS C', 'C.ID=N.LOCAL_CURRENCY_ID')
  409. ->where("STATUS=1 AND CATEGORY_TYPE=1 " . $query_condition, [':COUNTRY_ID' => $user['COUNTRY_ID']])
  410. ->orderBy('SORT ASC')
  411. ->asArray()
  412. ->all();
  413. foreach ($allGoods as &$goods) {
  414. $goods['TAX'] = Tool::calculateTax($goods['SELL_PRICE'], $goods['TAX_RATE']);
  415. }
  416. // 报单中心汇率
  417. $decCountryId = User::getEnCodeInfo(\Yii::$app->user->id)['COUNTRY_ID'];
  418. $decCountry = Countries::getById($decCountryId);
  419. $decUserCurrencyRate = CurrencyConversions::getToUSDRate($decCountry['LOCAL_CURRENCY_ID']);
  420. // 升级会员汇率
  421. $country = Countries::getById($user['COUNTRY_ID']);
  422. $currencyRate = CurrencyConversions::getToUSDRate($country['LOCAL_CURRENCY_ID']);
  423. // 升级会员币种
  424. $currency = Currency::getById($country['LOCAL_CURRENCY_ID']);
  425. $userBalance = [
  426. 'cash' => 0,
  427. 'localCash' => 0,
  428. 'coin' => '',
  429. ];
  430. $userCash = UserWallet::findOneAsArray(['USER_ID' => \Yii::$app->user->id]);
  431. if ($userCash) {
  432. $userBalance['cash'] = $userCash['CASH'];
  433. $userBalance['coin'] = $currency['CODE'] ?? '';
  434. $userBalance['localCash'] = Tool::convertAmount($userCash['CASH'], $decUserCurrencyRate, $currencyRate);
  435. }
  436. // 行政区划
  437. $region = Region::getByCountryId($user['COUNTRY_ID']);
  438. return static::notice([
  439. 'allDecPackage' => $allDecPackage,
  440. 'allGoods' => $allGoods,
  441. 'decUserName'=>$decUserName,
  442. 'payList' => ShopGoods::payTypes(),
  443. 'sellType' => ShopGoods::getCategoryType(),
  444. 'categoryType' => ShopGoods::getCategoryType()[0]['id'],
  445. 'userBalance' => $userBalance,
  446. 'decUserCurrencyRate' => $decUserCurrencyRate,
  447. 'userCurrencyRate' => $currencyRate,
  448. 'region' => $region,
  449. ]);
  450. }
  451. /**
  452. * 报单管理
  453. */
  454. public function actionDec() {
  455. $redis = \Yii::$app->redis;
  456. $post = \Yii::$app->request->post();
  457. if (\Yii::$app->request->isPost) {
  458. $userInfo = User::getEnCodeInfo(\Yii::$app->user->id);
  459. if($userInfo['IS_DEC'] == 1 && !empty($post['decUserName']) && $post['decUserName'] != $userInfo['USER_NAME']){
  460. return static::notice(Yii::t('app', 'decUserNameIsWrong'), 400);
  461. }
  462. if($userInfo['IS_DEC'] == 0 && $post['decUserName']){
  463. //查询报单编号是否存在
  464. $userId = Info::getUserIdByUserName($post['decUserName']);
  465. if(!$userId){
  466. return static::notice(Yii::t('app', 'decUserNameIsWrong'), 400);
  467. }
  468. $isDec = User::getEnCodeInfo($userId)['IS_DEC'];
  469. if(!$isDec){
  470. return static::notice(Yii::t('app', 'decUserNameIsWrong'), 400);
  471. }
  472. }
  473. // 根据支付方式区分逻辑
  474. $payMethod = \Yii::$app->request->post('payType', '');
  475. if ($payMethod === 'pay_stack') {
  476. $formModel = new ApproachDeclarationLoopForm();
  477. } else {
  478. unset($post['payType']);
  479. $formModel = new DeclarationLoopForm();
  480. }
  481. $formModel->scenario = 'userDec';
  482. $post['province'] = $post['province'] ? :1;
  483. $post['city'] = $post['city'] ? :1;
  484. $post['county'] = $post['county'] ? :1;
  485. $conUserName = trim($post['conUserName']); // 实际推荐人
  486. $recUserName = trim($post['recUserName']);
  487. $post['cityName'] = trim($post['cityName']);
  488. $post['lgaName'] = trim($post['lgaName']);
  489. // 针对那群沙雕移除安置网络的行为,强制增加自动安置左侧
  490. $recUserId = Info::getUserIdByUserName($conUserName);
  491. $bottomPlace = UserNetwork::getBottomPlace($recUserId,'', 'left');
  492. $bottomUser = UserNetwork::find()->select('USER_ID')->where('LOCATION_TAG=:LOCATION_TAG', ['LOCATION_TAG' => $bottomPlace])->asArray()->one();
  493. $bottomUser = User::findOneAsArray('ID=:ID', [':ID' => $bottomUser['USER_ID']], 'USER_NAME');
  494. $bottomUser = $bottomUser['USER_NAME']; // 推算出的安置人
  495. $post['conUserName'] = $bottomUser; // 安置人
  496. $post['recUserName'] = $conUserName; // 实际推荐人
  497. $post['bottomUserName'] = $recUserName; // 推荐人
  498. $post['location'] = 1;
  499. // 针对于会员编号的判断
  500. if($post['decType']=='normal'){ // 普通报单,判断Redis中的用户名是否一致
  501. $insertUserName = strtoupper($post['insertUserName']);
  502. $getRedisUserName = $redis->get('key_' . $insertUserName);
  503. if (!$getRedisUserName){
  504. return static::notice(Yii::t('app', 'memberNumberExpired'), 400);
  505. }
  506. if ($insertUserName != $getRedisUserName){
  507. return static::notice(Yii::t('app', 'memberNumberDoesNotConformTo'), 400);
  508. }
  509. }else{ // BA升级,需要判断BA用户是否存在
  510. $insertUserName = $post['insertUserName'];
  511. }
  512. $post['insertUserName'] = $insertUserName;
  513. $post['type'] = DeclarationForm::TYPE_ZC;
  514. $allData['data'][] = $post;
  515. if ($formModel->load($allData, '') && $result = $formModel->add()) {
  516. return static::notice($result);//报单成功
  517. } else {
  518. return static::notice(Form::formatErrorsForApi($formModel->getErrors()),400);
  519. }
  520. }
  521. // 默认国家
  522. $countryId = \Yii::$app->request->get('countryId');
  523. if (!$countryId) {
  524. return static::notice(Yii::t('app', 'countryDoesNotSelect'), 400);
  525. }
  526. // 生成随机码 , 初始化redis
  527. $userName = Info::generateWebName($countryId);
  528. //所有报单套餐
  529. $allDecPackage = DeclarationPackage::getAllData();
  530. $decLevels = Cache::getDecLevelConfig();
  531. foreach ($allDecPackage as $k=>$v){
  532. $levelName = $decLevels[$v['LEVEL_ID']]['LEVEL_NAME'] ?? '';
  533. $allDecPackage[$k]['LEVEL_NAME'] = $levelName;
  534. }
  535. //所有自选商品
  536. $isDecReg = Cache::getSystemConfig()['isDecReg']['VALUE'];
  537. $isDec = User::getEnCodeInfo(\Yii::$app->user->id)['IS_DEC'];
  538. $isStudio = User::getEnCodeInfo(\Yii::$app->user->id)['IS_STUDIO'];
  539. $query_condition = " AND (1<>1";
  540. if(!$isDecReg || ($isDecReg && $isDec==1)){
  541. $query_condition = " AND (FIND_IN_SET(1, S.GIFT_TYPE)>0";
  542. }
  543. if($isStudio==1){
  544. $query_condition .= " OR FIND_IN_SET(3, S.GIFT_TYPE)>0";
  545. }
  546. $query_condition .= ") AND (S.INSTALMENT=0 OR S.INSTALMENT=1) AND N.COUNTRY_ID=:COUNTRY_ID";
  547. // 只查询普通商品
  548. $allGoods = ShopGoods::find()
  549. ->alias('S')
  550. ->select('S.*,N.MARKET_PRICE,N.SELL_PRICE,N.TAX_RATE,N.LOCAL_CURRENCY_ID,N.COUNTRY_ID,C.CODE')
  551. ->join('INNER JOIN', ShopGoodsNature::tableName() . ' AS N', 'N.GOODS_ID=S.ID')
  552. ->join('INNER JOIN', Currency::tableName() . ' AS C', 'C.ID=N.LOCAL_CURRENCY_ID')
  553. ->where("STATUS=1 AND CATEGORY_TYPE=1 " . $query_condition, [':COUNTRY_ID' => $countryId])
  554. ->orderBy('SORT ASC')
  555. ->asArray()
  556. ->all();
  557. // 银行开户行
  558. $allOpenBank = OpenBank::find()
  559. ->where('STATUS=:STATUS AND COUNTRY_ID=:COUNTRY_ID', [':STATUS' => 1, ':COUNTRY_ID' => $countryId])
  560. ->orderBy('BANK_NAME ASC')
  561. ->asArray()
  562. ->all();
  563. if (!$userName) {
  564. return static::notice(Yii::t('app', 'failedToGenerateMemberNumber'), 400);
  565. }
  566. //随机码保存在redis中方便进行比对
  567. $redis->setex('key_'.$userName , 3600 , $userName);
  568. // 报单中心会员的本地汇率
  569. $decCountryId = User::getEnCodeInfo(\Yii::$app->user->id)['COUNTRY_ID'];
  570. $decCountry = Countries::getById($decCountryId);
  571. $decUserCurrencyRate = CurrencyConversions::getToUSDRate($decCountry['LOCAL_CURRENCY_ID']);
  572. // 新会员的本地汇率
  573. $country = Countries::getById($countryId);
  574. $currencyRate = CurrencyConversions::getToUSDRate($country['LOCAL_CURRENCY_ID']);
  575. // 新会员币种
  576. $currency = Currency::getById($country['LOCAL_CURRENCY_ID']);
  577. // 会员账户
  578. $userBalance = [
  579. 'cash' => 0,
  580. 'localCash' => 0,
  581. 'coin' => '',
  582. ];
  583. $userCash = UserWallet::findOneAsArray(['USER_ID' => \Yii::$app->user->id]);
  584. if ($userCash) {
  585. $userBalance['cash'] = $userCash['CASH'];
  586. $userBalance['localCash'] = Tool::convertAmount($userCash['CASH'], $decUserCurrencyRate, $currencyRate);
  587. $userBalance['coin'] = $currency['CODE'] ?? '';
  588. }
  589. // 行政区划
  590. $region = Region::getByCountryId($countryId);
  591. return static::notice([
  592. 'allDecPackage' => $allDecPackage,
  593. 'allGoods' => $allGoods,
  594. 'allOpenBank' => $allOpenBank,
  595. 'userName' => $userName,
  596. 'payList' => ShopGoods::payTypes(),
  597. 'sellType' => ShopGoods::getCategoryType(),
  598. 'categoryType' => ShopGoods::getCategoryType()[0]['id'],
  599. 'userBalance' => $userBalance,
  600. 'isDec' => $isDec,
  601. 'decUserCurrencyRate' => $decUserCurrencyRate,
  602. 'userCurrencyRate' => $currencyRate,
  603. 'region' => $region,
  604. ]);
  605. }
  606. /**
  607. * 报单级别套餐
  608. */
  609. public function actionDecPackage() {
  610. $decLv = \Yii::$app->request->get('id');
  611. //所有报单级别套餐
  612. $allDecPackage = DeclarationPackage::getPackageFromLevelId($decLv);
  613. return static::notice(['allDecPackage' => $allDecPackage]);
  614. }
  615. /*
  616. * 从会员名和左右,获取底部安置人
  617. *
  618. */
  619. public function actionGetAutoPlace() {
  620. $userName = \Yii::$app->request->get('userName');
  621. $side = \Yii::$app->request->get('side');
  622. $userId = Info::getUserIdByUserName($userName);
  623. $bottomPlace = UserNetwork::getBottomPlace($userId,'', $side);
  624. $bottomUser = UserNetwork::find()->select('USER_ID')->where('LOCATION_TAG=:LOCATION_TAG', ['LOCATION_TAG' => $bottomPlace])->asArray()->one();
  625. $bottomUser = User::findOneAsArray('ID=:ID', [':ID' => $bottomUser['USER_ID']], 'USER_NAME');
  626. return static::notice($bottomUser);
  627. }
  628. /**
  629. * 会员信息查询
  630. * @return mixed
  631. * @throws \yii\web\HttpException
  632. */
  633. public function actionFullInfo()
  634. {
  635. $userName = \Yii::$app->request->get('userName');
  636. $userId = Info::getUserIdByUserName($userName);
  637. $userInfo['REAL_NAME'] = '';
  638. $user = User::findOneAsArray('ID=:ID', [':ID' => $userId]);
  639. if($user){
  640. $userInfo['REAL_NAME'] = $user['REAL_NAME'];
  641. $allChildUser = UserNetwork::getFirstFloorChildren($userId);
  642. $isLocation = [1 => 'Left-Null', 2 => 'Right-Null'];
  643. if($allChildUser) {
  644. foreach ($allChildUser as $child) {
  645. if ($child['RELATIVE_LOCATION']<'3'){
  646. // $isLocation[$child['RELATIVE_LOCATION']].= 'Full';
  647. $isLocation[$child['RELATIVE_LOCATION']] = str_replace('Null', 'Full', $isLocation[$child['RELATIVE_LOCATION']]);
  648. }
  649. }
  650. }
  651. $userInfo['countryId'] = $user['COUNTRY_ID'];
  652. $userInfo['userId'] = $userId;
  653. $userInfo['isLocation'] = '('.implode(',',$isLocation).')';
  654. return static::notice($userInfo);
  655. }else{
  656. return static::notice(Yii::t('app', 'memberNumberDoesNotExist'), 400);
  657. }
  658. }
  659. public function actionInspectNetwork()
  660. {
  661. // 推荐人信息
  662. $recommenderName= \Yii::$app->request->get('recommenderName');
  663. $userId = Info::getUserIdByUserName($recommenderName);
  664. $recommender = User::findOneAsArray('ID=:ID', [':ID' => $userId]);
  665. if (!$recommender) {
  666. return static::notice(Yii::t('app', 'memberNumberDoesNotExist'), 400);
  667. }
  668. // 实际推荐人信息
  669. $recommenderActualName= \Yii::$app->request->get('recommenderActualName');
  670. $actualId = Info::getUserIdByUserName($recommenderActualName);
  671. $recommenderActual = User::findOneAsArray('ID=:ID', [':ID' => $actualId]);
  672. if (!$recommenderActual) {
  673. return static::notice(Yii::t('app', 'memberNumberDoesNotExist'), 400);
  674. }
  675. // 实际推荐人是否是推荐人本人
  676. if ($actualId == $userId) {
  677. return static::notice([
  678. 'REAL_NAME' => $recommenderActual['REAL_NAME'],
  679. 'userId' => $recommenderActual['ID'],
  680. ]);
  681. }
  682. // 实际推荐人必须是推荐人的推荐网上级
  683. $sqlUp =<<<SQL
  684. WITH recursive t_rec AS
  685. (
  686. SELECT
  687. m.USER_ID,
  688. U.USER_NAME,
  689. m.PARENT_UID,
  690. U2.USER_NAME AS PARENT_NAME,
  691. 1 AS node_level
  692. FROM
  693. AR_USER_RELATION_NEW m
  694. LEFT JOIN AR_USER U ON U.ID = m.USER_ID
  695. LEFT JOIN AR_USER U2 ON U2.ID = m.PARENT_UID
  696. WHERE
  697. U.USER_NAME = :USER_NAME
  698. UNION ALL
  699. SELECT
  700. t1.USER_ID,
  701. U.USER_NAME,
  702. t1.PARENT_UID,
  703. U2.USER_NAME AS PARENT_NAME,
  704. t2.node_level + 1 -- 结点层级
  705. FROM
  706. AR_USER_RELATION_NEW t1
  707. JOIN t_rec t2 ON t2.PARENT_UID = t1.USER_ID
  708. LEFT JOIN AR_USER U ON U.ID = t1.USER_ID
  709. LEFT JOIN AR_USER U2 ON U2.ID = t1.PARENT_UID
  710. )
  711. SELECT
  712. *
  713. FROM
  714. t_rec
  715. SQL;
  716. // 查询推荐人的所有上级
  717. $relationNodeUp = \Yii::$app->db->createCommand($sqlUp)
  718. ->bindValue(':USER_NAME' , $recommenderName)
  719. ->queryAll();
  720. $relationNodeUp = array_column($relationNodeUp, 'USER_NAME');
  721. unset($relationNodeUp[$recommenderName]);
  722. if (in_array($recommenderActualName, $relationNodeUp)) {
  723. return static::notice([
  724. 'REAL_NAME' => $recommenderActual['REAL_NAME'],
  725. 'userId' => $recommenderActual['ID'],
  726. ]);
  727. }
  728. return static::notice(Yii::t('ctx', 'fillSponsorUpline'), 400);
  729. }
  730. /**
  731. * 复消会员信息查询
  732. * @return mixed
  733. * @throws \yii\web\HttpException
  734. */
  735. public function actionUserBaseInfo()
  736. {
  737. $userName = \Yii::$app->request->get('userName');
  738. $userId = Info::getUserIdByUserName($userName);
  739. if($userId){
  740. $allAddress = ReceiveAddress::findAllAsArray('USER_ID=:USER_ID', [':USER_ID'=>$userId]);
  741. if($allAddress) {
  742. foreach ($allAddress as $key => $row) {
  743. $allAddress[$key]['PROVINCE_NAME'] = Region::getCnName($row['PROVINCE']);
  744. $allAddress[$key]['CITY_NAME'] = Region::getCnName($row['CITY']);
  745. $allAddress[$key]['COUNTY_NAME'] = Region::getCnName($row['COUNTY']);
  746. }
  747. }
  748. $userInfo = Info::baseInfoWithNet($userId);
  749. // $decLevelConfig = Cache::getDecLevelConfig();
  750. // $empLevelConfig = Cache::getEmpLevelConfig();
  751. $arr = [
  752. 'REAL_NAME'=>$userInfo['REAL_NAME'],
  753. // 'DEC_LEVEL_NAME' => $decLevelConfig[$userInfo['DEC_LV']]['LEVEL_NAME'],
  754. // 'EMP_LEVEL_NAME'=>$empLevelConfig[$userInfo['EMP_LV']]['LEVEL_NAME'],
  755. // 'REC_UID'=>$userInfo['REC_USER_NAME'].'('.$userInfo['REC_REAL_NAME'].')',
  756. // 'CON_UID'=>$userInfo['CON_USER_NAME'].'('.$userInfo['CON_REAL_NAME'].')',
  757. 'allAddress'=>$allAddress
  758. ];
  759. return static::notice($arr);
  760. }else{
  761. return static::notice(Yii::t('app', 'repeatSalesMemberNoDoesNotExist'), 400);
  762. }
  763. }
  764. /**
  765. * 会员资料
  766. * @return mixed
  767. * @throws \yii\web\HttpException
  768. */
  769. public function actionBaInfo()
  770. {
  771. $data['userInfo'] = BaUser::getEnCodeInfo(\Yii::$app->user->id);
  772. $data['userInfo']['NATION'] = $data['userInfo']['NATION_ID'];
  773. // 推荐人
  774. $baUserInfo = BaUserInfo::findOneAsArray('USER_ID=:USER_ID', [':USER_ID' => \Yii::$app->user->id]);
  775. $sponsor = User::findOneAsArray('ID=:USER_ID', [':USER_ID' => $baUserInfo['REC_UID']]);
  776. $data['userInfo']['SponsorCode'] = $sponsor['USER_NAME'];
  777. $data['userInfo']['SponsorName'] = $sponsor['REAL_NAME'];
  778. return static::notice($data);
  779. }
  780. /**
  781. * 编辑会员资料
  782. * @return mixed
  783. * @throws \yii\web\HttpException
  784. */
  785. public function actionBaEdit()
  786. {
  787. if(\Yii::$app->request->isPost)
  788. {
  789. $form = new BaUserForm();
  790. $post = \Yii::$app->request->post();
  791. $form->scenario = 'modifyProfile';
  792. if ($form->load($post, '') && $result = $form->modifyProfile()){
  793. return static::notice(Yii::t('app', 'personalDataModifiedSuccessfully'), 400);
  794. } else {
  795. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  796. }
  797. }
  798. return static::notice(Yii::t('app', 'illegalRequest'), 400);
  799. }
  800. /**
  801. * 修改登录密码
  802. */
  803. public function actionBaPassword(){
  804. if(\Yii::$app->request->isPost) {
  805. $form = new BaUserForm();
  806. $form->scenario = 'modifyPassword';
  807. $post = \Yii::$app->request->post();
  808. if($form->load($post, '') && $result = $form->modifyPassword()){
  809. return static::notice(Yii::t('app', 'passwordModifiedSuccessfully'), 400);
  810. } else {
  811. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  812. }
  813. }
  814. return static::notice(Yii::t('app', 'illegalRequest'), 400);
  815. }
  816. /**
  817. * 修改支付密码
  818. */
  819. public function actionBaPayPassword(){
  820. if(\Yii::$app->request->isPost){
  821. $form = new BaUserForm();
  822. $form->scenario = 'modifyPasswordPay';
  823. $post = \Yii::$app->request->post();
  824. $form->userId = \Yii::$app->user->id;
  825. if($form->load($post, '') && $result = $form->modifyPasswordPay()){
  826. return static::notice(Yii::t('app', 'passwordModifiedSuccessfully'), 400);
  827. } else {
  828. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  829. }
  830. }
  831. return static::notice(Yii::t('app', 'illegalRequest'), 400);
  832. }
  833. /**
  834. * BA报单管理
  835. */
  836. public function actionBaDec() {
  837. // 生成随机码 , 初始化redis
  838. $userName = Info::generateWebUserName('NG',9);
  839. $redis = \Yii::$app->redis;
  840. $post = \Yii::$app->request->post();
  841. if (\Yii::$app->request->isPost) {
  842. // 根据支付方式区分逻辑
  843. $payMethod = \Yii::$app->request->post('payType', '');
  844. if ($payMethod === 'pay_stack') {
  845. $formModel = new BaApproachDeclarationLoopForm();
  846. } else {
  847. unset($post['payType']);
  848. $formModel = new BaDeclarationLoopForm();
  849. }
  850. $formModel->scenario = 'userDec';
  851. $post['province'] = $post['province'] ? :1;
  852. $post['city'] = $post['city'] ? :1;
  853. $post['county'] = $post['county'] ? :1;
  854. // $post['conUserName'] = trim($post['conUserName']);
  855. $post['recUserName'] = trim($post['recUserName']);
  856. $post['cityName'] = trim($post['cityName']);
  857. $post['lgaName'] = trim($post['lgaName']);
  858. // 针对于会员编号的判断
  859. $insertUserName = strtoupper($post['insertUserName']);
  860. $getRedisUserName = $redis->get('key_' . $insertUserName);
  861. if (!$getRedisUserName){
  862. return static::notice(Yii::t('app', 'memberNumberExpired'), 400);
  863. }
  864. if ($insertUserName != $getRedisUserName){
  865. return static::notice(Yii::t('app', 'memberNumberDoesNotConformTo'), 400);
  866. }
  867. $post['insertUserName'] = $insertUserName;
  868. $post['type'] = BaDeclarationForm::TYPE_ZC;
  869. $allData['data'][] = $post;
  870. if ($formModel->load($allData, '') && $result = $formModel->add()) {
  871. return static::notice($result); // 报单成功
  872. } else {
  873. return static::notice(Form::formatErrorsForApi($formModel->getErrors()),400);
  874. }
  875. }
  876. // 只查询普通商品
  877. $allGoods = ShopGoods::find()->where("ID='375895243322691584'")->orderBy('SORT ASC')->asArray()->all();
  878. if (!$userName) {
  879. return static::notice(Yii::t('app', 'failedToGenerateMemberNumber'), 400);
  880. }
  881. //随机码保存在redis中方便进行比对
  882. $redis->setex('key_'.$userName , 3600 , $userName);
  883. // 会员账户
  884. $userBalance = [
  885. 'cash' => 0,
  886. // 'tourism_points' => 0,
  887. // 'garage_points' => 0,
  888. // 'villa_points' => 0,
  889. ];
  890. $userCash = UserWallet::findOneAsArray(['USER_ID' => \Yii::$app->user->id]);
  891. if ($userCash) {
  892. $userBalance['cash'] = $userCash['CASH'];
  893. }
  894. return static::notice([
  895. 'allGoods' => $allGoods,
  896. 'userName' => $userName,
  897. 'payList' => ShopGoods::payTypes(),
  898. 'sellType' => ShopGoods::getCategoryType(),
  899. 'categoryType' => ShopGoods::getCategoryType()[0]['id'],
  900. 'userBalance' => $userBalance,
  901. ]);
  902. }
  903. /**
  904. * BA会员信息
  905. * @return mixed
  906. * @throws \yii\web\HttpException
  907. */
  908. public function actionBaUserInfo()
  909. {
  910. $userName = \Yii::$app->request->get('userName');
  911. $userId = Info::getBaUserIdByUserName($userName);
  912. $userInfo['REAL_NAME'] = '';
  913. $user = BaUser::findOneAsArray('ID=:ID', [':ID' => $userId], 'REAL_NAME');
  914. $uInfo = BaUserInfo::findOneAsArray('USER_ID=:USER_ID', [':USER_ID' => $userId], 'REC_UID');
  915. if($user){
  916. $rec_user = UserInfo::findOneAsArray('USER_ID=:USER_ID',[':USER_ID' => $uInfo['REC_UID']], 'USER_ID, USER_NAME');
  917. $userInfo['REAL_NAME'] = $user['REAL_NAME'];
  918. $userInfo['REC_USER_ID'] = $rec_user['USER_ID'];
  919. $userInfo['REC_USER_NAME'] = $rec_user['USER_NAME'];
  920. return static::notice($userInfo);
  921. }else{
  922. return static::notice(Yii::t('app', 'memberNumberDoesNotExist'), 400);
  923. }
  924. }
  925. }