BaController.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  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\Cache;
  10. use common\helpers\Form;
  11. use common\helpers\Tool;
  12. use common\helpers\user\Info;
  13. use common\models\Config;
  14. use common\models\DeclarationLevel;
  15. use common\models\DeclarationPackage;
  16. use common\models\DecOrder;
  17. use common\models\forms\ApproachDeclarationLoopForm;
  18. use common\models\forms\ApproachDeclarationUpgradeForm;
  19. use common\models\forms\DeclarationForm;
  20. use common\models\forms\DeclarationLoopForm;
  21. use common\models\forms\UploadForm;
  22. use common\models\forms\UserBindForm;
  23. use common\models\forms\UserForm;
  24. use common\models\OpenBank;
  25. use common\models\ReceiveAddress;
  26. use common\models\Region;
  27. use common\models\ShopGoods;
  28. use common\models\UpgradeType;
  29. use common\models\User;
  30. use common\models\UserBind;
  31. use common\models\UserInfo;
  32. use common\models\UserNetwork;
  33. use common\models\forms\DeclarationUpgradeForm;
  34. use yii\db\Exception;
  35. use yii\web\UploadedFile;
  36. class BaController extends BaseController {
  37. public $modelClass = BaUserInfo::class;
  38. /**
  39. * 会员资料
  40. * @return mixed
  41. * @throws \yii\web\HttpException
  42. */
  43. public function actionIndex() {
  44. $allNation = \Yii::$app->params['nation'];
  45. $allOpenBank = OpenBank::findAllAsArray('STATUS=1');
  46. $data['allNation'] = $allNation;
  47. $data['allOpenBank'] = $allOpenBank;
  48. $data['userInfo'] = User::getEnCodeInfo(\Yii::$app->user->id);
  49. $data['userInfo']['NATION'] = $data['userInfo']['NATION_ID'];
  50. return static::notice($data);
  51. }
  52. /**
  53. * 编辑会员资料
  54. * @return mixed
  55. * @throws \yii\web\HttpException
  56. */
  57. public function actionEdit() {
  58. if(\Yii::$app->request->isPost){
  59. $form = new UserForm();
  60. $post = \Yii::$app->request->post();
  61. $form->scenario = 'modifyProfile';
  62. if($form->load($post, '') && $result = $form->modifyProfile()){
  63. return static::notice('Personal data modified successfully');//个人资料修改成功
  64. } else {
  65. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  66. }
  67. }
  68. return static::notice('Illegal request', 400); // 非法请求
  69. }
  70. /**
  71. * 修改登录密码
  72. */
  73. public function actionPassword(){
  74. if(\Yii::$app->request->isPost){
  75. $form = new UserForm();
  76. $form->scenario = 'modifyPassword';
  77. $post = \Yii::$app->request->post();
  78. if($form->load($post, '') && $result = $form->modifyPassword()){
  79. return static::notice('Password modified successfully');//密码修改成功
  80. } else {
  81. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  82. }
  83. }
  84. return static::notice('Illegal request', 400); // 非法请求
  85. }
  86. /**
  87. * 修改支付密码
  88. */
  89. public function actionPayPassword(){
  90. if(\Yii::$app->request->isPost){
  91. $form = new UserForm();
  92. $form->scenario = 'modifyPasswordPay';
  93. $post = \Yii::$app->request->post();
  94. $form->userId = \Yii::$app->user->id;
  95. if($form->load($post, '') && $result = $form->modifyPasswordPay()){
  96. return static::notice('支付密码修改成功');
  97. } else {
  98. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  99. }
  100. }
  101. return static::notice('Illegal request', 400); // 非法请求
  102. }
  103. /**
  104. * 直推会员列表
  105. * @return mixed
  106. * @throws \yii\web\HttpException
  107. */
  108. public function actionRecUser() {
  109. $allData = UserInfo::lists('AND REC_UID=:REC_UID', [':REC_UID' => \Yii::$app->user->id], ['useSlaves' => true, 'select'=>'USER_ID,CREATED_AT']);
  110. foreach ($allData['list'] as $key => $data) {
  111. $userBaseInfo = User::getEnCodeInfo($data['USER_ID']);
  112. $userBaseInfo['NATION'] = \Yii::$app->params['nation'][$userBaseInfo['NATION']]['name'] ?? '';
  113. $allData['list'][$key]['BASE_INFO'] = $userBaseInfo;
  114. }
  115. return static::notice($allData);
  116. }
  117. /**
  118. * 上传身份证
  119. * @return mixed
  120. * @throws \yii\base\Exception
  121. * @throws \yii\web\HttpException
  122. */
  123. public function actionIdCard() {
  124. if (\Yii::$app->request->isPost) {
  125. $formModel = new UploadForm();
  126. $formModel->scenario = 'idCardFront';
  127. $formModel->file = UploadedFile::getInstanceByName('file');
  128. //$formModel->token = \Yii::$app->request->post('uploadToken');
  129. $formModel->token = \Yii::$app->request->request('uploadToken');
  130. if ($formModel->file && $formModel->upload()) {
  131. return static::notice('Successful');
  132. } else {
  133. return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
  134. }
  135. }
  136. // 查看该用户是否已经上传过身份证
  137. $oneData = User::find()->select('ID_IMAGE')->where('ID=:ID', [':ID' => \Yii::$app->user->id])->asArray()->one();
  138. if ($oneData['ID_IMAGE']) {
  139. return static::notice($oneData);
  140. } else {
  141. $token = Cache::setUploadToken();
  142. return static::notice($token);
  143. }
  144. }
  145. /**
  146. * 点位绑定
  147. * @return mixed
  148. * @throws \yii\base\Exception
  149. * @throws \yii\web\HttpException
  150. */
  151. public function actionBind() {
  152. $userBind = UserBind::findOneAsArray('USER_ID=:USER_ID AND IS_DEL=0', [':USER_ID' => \Yii::$app->user->id]);
  153. $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');
  154. foreach ($allData['list'] as $key => $value) {
  155. $baseInfo = Info::baseInfoZh($value['USER_ID']);
  156. if ($baseInfo['STATUS'] != 1) {
  157. unset($allData['list'][$key]);
  158. continue;
  159. }
  160. $allData['list'][$key]['USER_NAME'] = $baseInfo['USER_NAME'];
  161. $allData['list'][$key]['REAL_NAME'] = $baseInfo['REAL_NAME'];
  162. $allData['list'][$key]['BANK_PROVINCE_NAME'] = $baseInfo['BANK_PROVINCE_NAME'];
  163. $allData['list'][$key]['BANK_CITY_NAME'] = $baseInfo['BANK_CITY_NAME'];
  164. $allData['list'][$key]['BANK_COUNTY_NAME'] = $baseInfo['BANK_COUNTY_NAME'];
  165. $allData['list'][$key]['OPEN_BANK_NAME'] = $baseInfo['OPEN_BANK_NAME'];
  166. $allData['list'][$key]['BANK_NO'] = $baseInfo['BANK_NO'];
  167. $allData['list'][$key]['MAIN_USER_NAME'] =Info::getUserNameByUserId($value['MAIN_UID']);
  168. }
  169. $allData['list'] = array_values($allData['list']);
  170. return static::notice($allData);
  171. }
  172. /**
  173. * 编辑点位绑定
  174. * @return mixed
  175. * @throws \yii\web\HttpException
  176. */
  177. public function actionBindEdit(){
  178. $id = \Yii::$app->request->get('id');
  179. if(\Yii::$app->request->isPost) {
  180. return parent::edit(UserBindForm::class, '修改主点位成功', 'frontEdit', ['frontEdit'], null, function($form, $result){
  181. //log
  182. });
  183. }
  184. // 获得当前会员的用户名等信息
  185. $userBind = UserBind::findOneAsArray('ID=:ID AND IS_DEL=0', [':ID' => $id]);
  186. $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');
  187. foreach($userBinds as $key=>$value){
  188. $status = Info::getStatusByUserId($value['USER_ID']);
  189. if ($status != 1) {
  190. unset($userBinds[$key]);
  191. continue;
  192. }
  193. $userBinds[$key]['USER_NAME'] = Info::getUserNameByUserId($value['USER_ID']);
  194. }
  195. $userBinds = array_values($userBinds);
  196. return static::notice(['userBinds' => $userBinds,'mainUid'=>$userBind['MAIN_UID']]);
  197. }
  198. // 会员升级,通过会员的编号,获取会员信息
  199. public function actionUpgradeInfo() {
  200. $isSwitchUpgrade = Config::find()
  201. ->where("CONFIG_NAME='isOpenUpgrade'")
  202. ->asArray()
  203. ->one();
  204. $isOpen = !empty($isSwitchUpgrade) && isset($isSwitchUpgrade['VALUE']) ? $isSwitchUpgrade['VALUE'] : 0;
  205. if ($isOpen < 1) {
  206. return static::notice('The function is not available',400); // 功能暂未开放
  207. }
  208. $userNumber = \Yii::$app->request->request('userName');
  209. $baseInfo = Info::baseInfoZhByUserName($userNumber);
  210. if ($baseInfo['STATUS'] != 1) {
  211. return static::notice('Inactive user. Please contact customer service.',400);// 非激活用户,请联系客服
  212. }
  213. // 1. 如果是最高级别,则只显示用户基本信息
  214. // 2. 如果不是最高级别,如果用户累计报单数据是0, 或者用户累计报单业绩不符合级别信息,则提示 请联系客服核对业绩
  215. $userId = $baseInfo['ID'];
  216. $userDecId = $baseInfo['DEC_LV'];// 用户当前的级别
  217. // 获取系统中的DEC 报单级别配置
  218. $decConfig = Cache::getDecLevelConfig();
  219. $userDecInfo = $decConfig[$userDecId]; // 会员的级别具体信息
  220. $maxPerfInfo = DeclarationLevel::getMaxDecPref();
  221. $maxDecId = $maxPerfInfo['ID']; // 级别配置中最高级别ID
  222. $observe = Config::getConfigByType('observe'); // 获取观察期配置信息
  223. $observeLimit = $observe['observePeriodLimit']['value']; // 月份限制
  224. $isObserve = User::checkIsObserve($baseInfo['CREATED_AT'], $observeLimit); // 判断用户是否再观察期中
  225. // 如果用户已经是最高级别,则只展示用户信息
  226. $isMax = false;
  227. if ($maxDecId == $userDecId) {
  228. $isMax = true;
  229. }
  230. // 如果用户已经是最高级别,则只展示用户信息
  231. $userInfo = [
  232. 'DEC_NAME' => $baseInfo['DEC_LV_NAME'], // 用户级别中文
  233. 'DEC_ID' => $userDecId, // 用户级别id
  234. 'REAL_NAME' => $baseInfo['REAL_NAME'], // 真实姓名
  235. 'ADD_AT' => date('Y-m-d', $baseInfo['CREATED_AT']), // 加入时间
  236. 'IS_OBSERVE' => $isObserve, // 是否是观察期 true为是观察期
  237. 'IS_MAX' => $isMax, // 是否已是最大级别 最大级别不需要判断报单总PV是多少 只展示基本信息
  238. ];
  239. // 如果是最高级别了,则无需升级
  240. if ($isMax) {
  241. return static::notice(['baseInfo' => $userInfo]);
  242. }
  243. $levelPerf = $userDecInfo['PERF'];// 用户当前级别对应的业绩值
  244. if (!$isMax) {
  245. $userDecPvSum = User::sumDevPvByUserId($userId); // 用户所有报单PV总和
  246. // // 如果总和小于级别业绩 去掉这校验直接补比如3000-980的差值
  247. // if ($userDecPvSum < $levelPerf) {
  248. // return static::notice('请联系客服人员核对业绩',400);
  249. // }
  250. // 下一级业绩
  251. $nextLevelPerf = DeclarationLevel::getNextDecPref($levelPerf)['PERF'];
  252. // 如果总和超过了下一级业绩
  253. if ($userDecPvSum >= $nextLevelPerf) {
  254. return static::notice('Please contact customer service to check performance.',400);// 请联系客服人员核对业绩
  255. }
  256. $type = $isObserve ? 1 : 2;
  257. $userInfo['UPGRADE_FUNC'] = $isObserve ? 'filling up of a deficit' : 'full payment';// 升级方式
  258. $upgradeType = UpgradeType::getOneByType($type);
  259. // 如果用户不是最大级别,则需要获取是否观察期,算出PV是否有问题,应该补多少,
  260. $userInfo['UPGRADE_TYPE'] = $upgradeType;
  261. $userInfo['NOW_PERF'] = $userDecPvSum;
  262. $userInfo['NEXT_PERF'] = $nextLevelPerf;
  263. // 用户可选择的级别列表
  264. $userInfo['LEVEL_LIST'] = DeclarationLevel::getNextAll($levelPerf);// 用户可选择的级别列表
  265. // 循环列表,补充升级所需要的补差
  266. foreach ($userInfo['LEVEL_LIST'] as &$v) {
  267. $v['REPAIR_PV'] = $isObserve ? $v['PERF'] - $userInfo['NOW_PERF'] : $v['PERF'];
  268. }
  269. }
  270. return static::notice(['baseInfo' => $userInfo]);
  271. }
  272. // 会员升级管理
  273. public function actionUpgrade() {
  274. $isSwitchUpgrade = Config::find()
  275. ->where("CONFIG_NAME='isOpenUpgrade'")
  276. ->asArray()
  277. ->one();
  278. $isOpen = !empty($isSwitchUpgrade) && isset($isSwitchUpgrade['VALUE']) ? $isSwitchUpgrade['VALUE'] : 0;
  279. if ($isOpen < 1) {
  280. return static::notice('功能暂未开放',400);
  281. }
  282. // 开始升级
  283. if (\Yii::$app->request->isPost) {
  284. $post = \Yii::$app->request->post();
  285. // 根据支付方式区分逻辑
  286. $payMethod = \Yii::$app->request->post('payType', '');
  287. if ($payMethod === 'pay_stack') {
  288. $formModel = new ApproachDeclarationUpgradeForm();
  289. } else {
  290. unset($post['payType']);
  291. $formModel = new DeclarationUpgradeForm();
  292. }
  293. $post['type'] = DeclarationForm::TYPE_ZC;
  294. if ($formModel->load($post, '') && $result = $formModel->add($post)) {
  295. return static::notice($result);// Upgrade declaration succeeded升级报单成功
  296. } else {
  297. return static::notice(Form::formatErrorsForApi($formModel->getErrors()),400);
  298. }
  299. }
  300. //所有报单套餐
  301. $allDecPackage = DeclarationPackage::getAllData();
  302. $decLevels = Cache::getDecLevelConfig();
  303. foreach ($allDecPackage as $k=>$v){
  304. $levelName = $decLevels[$v['LEVEL_ID']]['LEVEL_NAME'] ?? '';
  305. $allDecPackage[$k]['LEVEL_NAME'] = $levelName;
  306. }
  307. //所有自选商品
  308. $isDecReg = Cache::getSystemConfig()['isDecReg']['VALUE'];
  309. $isDec = User::getEnCodeInfo(\Yii::$app->user->id)['IS_DEC'];
  310. $isStudio = User::getEnCodeInfo(\Yii::$app->user->id)['IS_STUDIO'];
  311. $decUserName = User::getEnCodeInfo(\Yii::$app->user->id)['USER_NAME'];
  312. $query_condition= " AND (1<>1";
  313. if(!$isDecReg || ($isDecReg && $isDec==1)){
  314. $query_condition = " AND (FIND_IN_SET(1,GIFT_TYPE)>0";
  315. }
  316. if($isStudio==1){
  317. $query_condition.= " OR FIND_IN_SET(3,GIFT_TYPE)>0";
  318. }
  319. $query_condition.= ")";
  320. $allGoods = ShopGoods::find()->where("STATUS=1 AND CATEGORY_TYPE=1 " . $query_condition)->orderBy('SORT ASC')->asArray()->all();
  321. foreach ($allGoods as &$goods) {
  322. $goods['TAX'] = Tool::calculateTax($goods['SELL_PRICE'], $goods['TAX_RATE']);
  323. }
  324. return static::notice([
  325. 'allDecPackage' => $allDecPackage,
  326. 'allGoods' => $allGoods,
  327. 'decUserName'=>$decUserName,
  328. 'payList' => ShopGoods::payTypes(),
  329. 'sellType' => ShopGoods::CATEGORY_TYPE,
  330. 'categoryType' => ShopGoods::CATEGORY_TYPE[0]['id'],
  331. ]);
  332. }
  333. /**
  334. * 报单管理
  335. */
  336. public function actionDec() {
  337. // 生成随机码 , 初始化redis
  338. $userName = Info::generateWebUserName('NG',9);
  339. $redis = \Yii::$app->redis;
  340. $post = \Yii::$app->request->post();
  341. if (\Yii::$app->request->isPost) {
  342. // 根据支付方式区分逻辑
  343. $payMethod = \Yii::$app->request->post('payType', '');
  344. if ($payMethod === 'pay_stack') {
  345. $formModel = new ApproachDeclarationLoopForm();
  346. } else {
  347. unset($post['payType']);
  348. $formModel = new DeclarationLoopForm();
  349. }
  350. $formModel->scenario = 'userDec';
  351. $post['province'] = $post['province'] ? :1;
  352. $post['city'] = $post['city'] ? :1;
  353. $post['county'] = $post['county'] ? :1;
  354. $post['conUserName'] = trim($post['conUserName']);
  355. $post['recUserName'] = trim($post['recUserName']);
  356. $post['cityName'] = trim($post['cityName']);
  357. $post['lgaName'] = trim($post['lgaName']);
  358. // 针对于会员编号的判断
  359. $insertUserName = strtoupper($post['insertUserName']);
  360. $getRedisUserName = $redis->get('key_' . $insertUserName);
  361. if (!$getRedisUserName){
  362. return static::notice('Membership number expired',400);//会员编号过期
  363. }
  364. if ($insertUserName != $getRedisUserName){
  365. return static::notice('Member number does not conform to',400);//会员编号不符合
  366. }
  367. $post['insertUserName'] = $insertUserName;
  368. $post['type'] = DeclarationForm::TYPE_ZC;
  369. $allData['data'][] = $post;
  370. if ($formModel->load($allData, '') && $result = $formModel->add()) {
  371. return static::notice($result);//报单成功
  372. } else {
  373. return static::notice(Form::formatErrorsForApi($formModel->getErrors()),400);
  374. }
  375. }
  376. //所有报单套餐
  377. $allDecPackage = DeclarationPackage::getAllData();
  378. $decLevels = Cache::getDecLevelConfig();
  379. foreach ($allDecPackage as $k=>$v){
  380. $levelName = $decLevels[$v['LEVEL_ID']]['LEVEL_NAME'] ?? '';
  381. $allDecPackage[$k]['LEVEL_NAME'] = $levelName;
  382. }
  383. //所有自选商品
  384. $isDecReg = Cache::getSystemConfig()['isDecReg']['VALUE'];
  385. $isDec = User::getEnCodeInfo(\Yii::$app->user->id)['IS_DEC'];
  386. $isStudio = User::getEnCodeInfo(\Yii::$app->user->id)['IS_STUDIO'];
  387. $query_condition= " AND (1<>1";
  388. if(!$isDecReg || ($isDecReg && $isDec==1)){
  389. $query_condition = " AND (FIND_IN_SET(1,GIFT_TYPE)>0";
  390. }
  391. if($isStudio==1){
  392. $query_condition.= " OR FIND_IN_SET(3,GIFT_TYPE)>0";
  393. }
  394. $query_condition.= ")";
  395. // 只查询普通商品
  396. $allGoods = ShopGoods::find()->where("STATUS=1 AND CATEGORY_TYPE=1".$query_condition)->orderBy('SORT ASC')->asArray()->all();
  397. //$allGoods = ShopGoods::findAllAsArray('STATUS=1');
  398. // 所有开户行
  399. $allOpenBank = OpenBank::find()->where('STATUS=1')->orderBy('LIST_ORDER ASC')->asArray()->all();
  400. if (!$userName) {
  401. return static::notice('Failed to generate member number', 400);//会员编号生成失败
  402. }
  403. //随机码保存在redis中方便进行比对
  404. $redis->setex('key_'.$userName , 3600 , $userName);
  405. return static::notice([
  406. 'allDecPackage' => $allDecPackage,
  407. 'allGoods' => $allGoods,
  408. 'allOpenBank' => $allOpenBank,
  409. 'userName' => $userName,
  410. 'payList' => ShopGoods::payTypes(),
  411. 'sellType' => ShopGoods::CATEGORY_TYPE,
  412. 'categoryType' => ShopGoods::CATEGORY_TYPE[0]['id'],
  413. ]);
  414. }
  415. /**
  416. * 报单级别套餐
  417. */
  418. public function actionDecPackage() {
  419. $decLv = \Yii::$app->request->get('id');
  420. //所有报单级别套餐
  421. $allDecPackage = DeclarationPackage::getPackageFromLevelId($decLv);
  422. return static::notice(['allDecPackage' => $allDecPackage]);
  423. }
  424. /*
  425. * 从会员名和左右,获取底部安置人
  426. *
  427. */
  428. public function actionGetAutoPlace() {
  429. $userName = \Yii::$app->request->get('userName');
  430. $side = \Yii::$app->request->get('side');
  431. $userId = Info::getUserIdByUserName($userName);
  432. // print_r($userId);
  433. $bottomPlace = UserNetwork::getBottomPlace($userId,'', $side);
  434. $bottomUser = UserNetwork::find()->select('USER_ID')->where('LOCATION_TAG=:LOCATION_TAG', ['LOCATION_TAG' => $bottomPlace])->asArray()->one();
  435. $bottomUser = User::findOneAsArray('ID=:ID', [':ID' => $bottomUser['USER_ID']], 'USER_NAME');
  436. // print_r($bottomUser);
  437. return static::notice($bottomUser);
  438. }
  439. /**
  440. * 会员信息查询
  441. * @return mixed
  442. * @throws \yii\web\HttpException
  443. */
  444. public function actionFullInfo()
  445. {
  446. $userName = \Yii::$app->request->get('userName');
  447. $userId = Info::getUserIdByUserName($userName);
  448. $userInfo['REAL_NAME'] = '';
  449. $user = User::findOneAsArray('ID=:ID', [':ID' => $userId], 'REAL_NAME');
  450. if($user){
  451. $userInfo['REAL_NAME'] = $user['REAL_NAME'];
  452. $allChildUser = UserNetwork::getFirstFloorChildren($userId);
  453. $isLocation = [1 => 'Left-', 2 => 'Right-'];
  454. if($allChildUser) {
  455. foreach ($allChildUser as $child) {
  456. if ($child['RELATIVE_LOCATION']<'3'){
  457. $isLocation[$child['RELATIVE_LOCATION']].= 'Full';
  458. }
  459. }
  460. }
  461. $userInfo['isLocation'] = '('.implode(',',$isLocation).')';
  462. return static::notice($userInfo);
  463. }else{
  464. return static::notice('Member number does not exist', 400);//会员编号不存在
  465. }
  466. }
  467. /**
  468. * 复消会员信息查询
  469. * @return mixed
  470. * @throws \yii\web\HttpException
  471. */
  472. public function actionUserBaseInfo()
  473. {
  474. $userName = \Yii::$app->request->get('userName');
  475. $userId = Info::getUserIdByUserName($userName);
  476. if($userId){
  477. $allAddress = ReceiveAddress::findAllAsArray('USER_ID=:USER_ID', [':USER_ID'=>$userId]);
  478. if($allAddress) {
  479. foreach ($allAddress as $key => $row) {
  480. $allAddress[$key]['PROVINCE_NAME'] = Region::getCnName($row['PROVINCE']);
  481. $allAddress[$key]['CITY_NAME'] = Region::getCnName($row['CITY']);
  482. $allAddress[$key]['COUNTY_NAME'] = Region::getCnName($row['COUNTY']);
  483. }
  484. }
  485. $userInfo = Info::baseInfoWithNet($userId);
  486. // $decLevelConfig = Cache::getDecLevelConfig();
  487. // $empLevelConfig = Cache::getEmpLevelConfig();
  488. $arr = [
  489. 'REAL_NAME'=>$userInfo['REAL_NAME'],
  490. // 'DEC_LEVEL_NAME' => $decLevelConfig[$userInfo['DEC_LV']]['LEVEL_NAME'],
  491. // 'EMP_LEVEL_NAME'=>$empLevelConfig[$userInfo['EMP_LV']]['LEVEL_NAME'],
  492. // 'REC_UID'=>$userInfo['REC_USER_NAME'].'('.$userInfo['REC_REAL_NAME'].')',
  493. // 'CON_UID'=>$userInfo['CON_USER_NAME'].'('.$userInfo['CON_REAL_NAME'].')',
  494. 'allAddress'=>$allAddress
  495. ];
  496. return static::notice($arr);
  497. }else{
  498. return static::notice('Repeat sales Member No. does not exist', 400);//复消会员编号不存在
  499. }
  500. }
  501. /**
  502. * 会员资料
  503. * @return mixed
  504. * @throws \yii\web\HttpException
  505. */
  506. public function actionBaInfo()
  507. {
  508. $allNation = \Yii::$app->params['nation'];
  509. $allOpenBank = OpenBank::findAllAsArray('STATUS=1');
  510. $data['allNation'] = $allNation;
  511. $data['allOpenBank'] = $allOpenBank;
  512. $data['userInfo'] = User::getEnCodeInfo(\Yii::$app->user->id); // TODO
  513. $data['userInfo']['NATION'] = $data['userInfo']['NATION_ID'];
  514. return static::notice($data);
  515. }
  516. /**
  517. * 编辑会员资料
  518. * @return mixed
  519. * @throws \yii\web\HttpException
  520. */
  521. public function actionBaEdit()
  522. {
  523. if(\Yii::$app->request->isPost)
  524. {
  525. $form = new UserForm();
  526. $post = \Yii::$app->request->post();
  527. $form->scenario = 'modifyProfile';
  528. if ($form->load($post, '') && $result = $form->modifyProfile()){
  529. return static::notice('Personal data modified successfully');//个人资料修改成功
  530. } else {
  531. return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
  532. }
  533. }
  534. return static::notice('Illegal request', 400); // 非法请求
  535. }
  536. }