CustomController.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. <?php
  2. namespace hd\controllers;
  3. use bizHd\admin\services\AdminService;
  4. use bizHd\custom\classes\CustomClass;
  5. use bizHd\custom\classes\HdClass;
  6. use bizHd\custom\services\CustomService;
  7. use biz\sj\services\MerchantAssetService;
  8. use biz\sj\services\MerchantRemarkService;
  9. use bizHd\member\classes\MemberWealClass;
  10. use bizHd\order\classes\OrderClass;
  11. use bizHd\user\services\UserAssetService;
  12. use bizHd\user\services\UserGrowthService;
  13. use bizHd\user\services\UserService;
  14. use bizHd\user\services\UserUpgradeService;
  15. use common\components\wxUtil;
  16. use common\services\xhMerchantExtendService;
  17. use common\services\xhRechargeService;
  18. use common\services\xhTMessageService;
  19. use common\services\xhUserIntegralService;
  20. use Yii;
  21. use common\components\stringUtil;
  22. use common\components\util;
  23. use biz\sj\services\MerchantExtendService;
  24. use bizHd\message\services\SmsService;
  25. use bizHd\user\classes\UserClass;
  26. use yii\helpers\Json;
  27. use Overtrue\ChineseCalendar\Calendar;
  28. class CustomController extends BaseController
  29. {
  30. public $guestAccess = ['list'];
  31. //修改生日 ssh 20250814
  32. public function actionModifyBirthday()
  33. {
  34. date_default_timezone_set('PRC');
  35. $get = Yii::$app->request->get();
  36. $customId = $get['customId'];
  37. $custom = CustomClass::getById($customId, true);
  38. if (empty($custom)) {
  39. util::fail('没有找到客户');
  40. }
  41. $shopId = $this->shopId;
  42. if ($custom->shopId != $shopId) {
  43. util::fail('不是你的客户');
  44. }
  45. $lunar = $get['lunar'] ?? 0;
  46. $birthdayMonth = $get['birthdayMonth'] ?? 1;
  47. if ($birthdayMonth > 12 || $birthdayMonth < 1) {
  48. util::fail('月份必须1到12月');
  49. }
  50. $birthdayDate = $get['birthdayDate'] ?? 1;
  51. if ($birthdayDate > 31 || $birthdayDate < 1) {
  52. util::fail('日期必须1到31号');
  53. }
  54. $userId = $custom->userId;
  55. $user = UserClass::getById($userId, true);
  56. if (empty($user)) {
  57. util::fail('客户信息缺失');
  58. }
  59. if ($lunar == 1 && $custom->birthdayDate == 31) {
  60. util::fail('农历没有31号');
  61. }
  62. $calendar = new Calendar();
  63. if ($lunar == 1) {
  64. $result = $calendar->lunar(date("Y"), $birthdayMonth, $birthdayDate);
  65. $month = $result['gregorian_month'] ?? 1;
  66. $date = $result['gregorian_day'] ?? 1;
  67. $birthday = date("Y") . '-' . $month . '-' . $date;
  68. } else {
  69. $birthday = date("Y") . '-' . $birthdayMonth . '-' . $birthdayDate;
  70. }
  71. $birthdayTime = strtotime($birthday);
  72. $custom->lunar = $lunar;
  73. $custom->birthdayDate = $birthdayDate;
  74. $custom->birthdayMonth = $birthdayMonth;
  75. $custom->birthday = $birthday;
  76. $custom->birthdayTime = $birthdayTime;
  77. $custom->save();
  78. $user->lunar = $lunar;
  79. $user->birthdayDate = $birthdayDate;
  80. $user->birthdayMonth = $birthdayMonth;
  81. $user->birthday = $birthday;
  82. $user->birthdayTime = $birthdayTime;
  83. $user->save();
  84. util::complete('修改成功');
  85. }
  86. public function actionChangeLevel()
  87. {
  88. $get = Yii::$app->request->get();
  89. $customId = $get['customId'];
  90. $level = $get['level'] ?? 0;
  91. if ($level < 0) {
  92. util::fail('等级选择错误');
  93. }
  94. $custom = CustomClass::getById($customId, true);
  95. if (empty($custom)) {
  96. util::fail('没有找到客户');
  97. }
  98. $shopId = $this->shopId;
  99. if ($custom->shopId != $shopId) {
  100. util::fail('不是你的客户');
  101. }
  102. $hdId = $custom->hdId;
  103. $hd = HdClass::getById($hdId, true);
  104. if (empty($hd)) {
  105. util::fail('客户信息缺失,编号3445');
  106. }
  107. $staff = $this->shopAdmin;
  108. $staffId = $staff->id;
  109. $staffName = $staff->name;
  110. $params = [
  111. 'style' => 1,//手动修改
  112. 'staffId' => $staffId,
  113. 'staffName' => $staffName,
  114. ];
  115. $shop = $this->shop;
  116. $connection = Yii::$app->db;
  117. $transaction = $connection->beginTransaction();
  118. try {
  119. $beforeLevel = $custom->member ?? 0;
  120. CustomClass::levelChange($beforeLevel, $level, $shop, $custom, $hd, $params);
  121. $transaction->commit();
  122. util::complete('修改成功');
  123. } catch (\Exception $exception) {
  124. $transaction->rollBack();
  125. Yii::info("修改失败:" . $exception->getMessage());
  126. util::fail('修改失败');
  127. }
  128. }
  129. //修改客户地址 ssh 20231109
  130. public function actionModifyAddress()
  131. {
  132. $post = Yii::$app->request->post();
  133. $id = $post['id'] ?? 0;
  134. unset($post['id']);
  135. $custom = CustomClass::getById($id, true);
  136. if (empty($custom)) {
  137. util::fail('没有找到客户信息');
  138. }
  139. $userId = $custom->userId ?? 0;
  140. $city = $post['city'] ?? '';
  141. $dist = $post['dist'] ?? '';
  142. $address = $post['address'] ?? '';
  143. $floor = $post['floor'] ?? '';
  144. $post['fullAddress'] = $city . $dist . $address . $floor;
  145. UserClass::updateByCondition(['id' => $userId], $post);
  146. CustomClass::updateByCondition(['id' => $id], $post);
  147. util::complete('修改成功');
  148. }
  149. //修改名称 ssh 2022096
  150. public function actionChangeName()
  151. {
  152. $get = Yii::$app->request->get();
  153. $name = $get['name'] ?? '';
  154. $id = $get['id'] ?? 0;
  155. if (empty($name)) {
  156. util::fail('请填写名称');
  157. }
  158. $py = stringUtil::py($name);
  159. $custom = CustomClass::getById($id, true);
  160. CustomClass::valid($custom, $this->shopId);
  161. $custom->name = $name;
  162. $custom->py = $py;
  163. $custom->save();
  164. OrderClass::updateByCondition(['customId' => $id], ['customName' => $name, 'customNamePy' => $py]);
  165. util::complete();
  166. }
  167. //批量添加客户 ssh 20220919
  168. public function actionBatchAddCustom()
  169. {
  170. $post = Yii::$app->request->post();
  171. $connection = Yii::$app->db;
  172. $transaction = $connection->beginTransaction();
  173. try {
  174. for ($i = 1; $i <= 5; $i++) {
  175. $name = $post['name' . $i] ?? '';
  176. $mobile = $post['mobile' . $i] ?? '';
  177. $confirmMobile = $post['confirmMobile' . $i] ?? '';
  178. if (empty($name) && empty($mobile) && empty($confirmMobile)) {
  179. continue;
  180. }
  181. if (empty($name)) {
  182. util::fail('客户名称不能为空');
  183. }
  184. if (stringUtil::getWordNum($name) > 15) {
  185. util::fail('名称不能超过15个汉字');
  186. }
  187. if (empty($mobile)) {
  188. util::fail($name . " 手机号不能为空");
  189. }
  190. if (stringUtil::isMobile($mobile) == false) {
  191. util::fail($name . " 手机号格式不正确");
  192. }
  193. if ($mobile != $confirmMobile) {
  194. util::fail($name . " 二次手机号不一致");
  195. }
  196. $user = \bizMall\user\classes\UserClass::replaceUser(['name' => $name, 'mobile' => $mobile]);
  197. if (isset($this->shop) && !empty($this->shop)) {
  198. //花店增加客户,散客增加门店
  199. CustomClass::buildRelation($this->shop, $user);
  200. }
  201. }
  202. $transaction->commit();
  203. util::complete();
  204. } catch (\Exception $e) {
  205. $transaction->rollBack();
  206. util::fail('添加失败');
  207. }
  208. }
  209. //客户列表 ssh 2019.11.30
  210. public function actionList()
  211. {
  212. $get = Yii::$app->request->get();
  213. $type = $get['type'] ?? 0;
  214. $name = $get['name'] ?? '';
  215. if (empty($name)) {
  216. $name = $get['keyword'] ?? '';
  217. }
  218. $where = ['shopId' => $this->shopId];
  219. if ($type == 1) {
  220. //消费排行
  221. $sort = 'buyAmount DESC';
  222. } else if ($type == 2) {
  223. //余额客户
  224. $sort = 'balance DESC';
  225. } else if ($type == 3) {
  226. //生日
  227. $sort = 'birthdayTime ASC';
  228. $where['birthdayTime>'] = 0;
  229. } else {
  230. $sort = 'visitTime DESC';
  231. }
  232. if (!empty($name)) {
  233. if (is_numeric($name) && strlen($name) == 4) {
  234. $where['mobile'] = ['like', $name];
  235. } else if (stringUtil::isLetter($name)) {
  236. $where['py'] = ['like', $name];
  237. } else {
  238. $where['name'] = ['like', $name];
  239. }
  240. }
  241. $list = CustomService::getCustomList($where, $sort);
  242. util::success($list);
  243. }
  244. //获取客户信息 ssh 20250510
  245. public function actionInfo()
  246. {
  247. $get = Yii::$app->request->get();
  248. $id = $get['id'] ?? 0;
  249. $custom = CustomClass::getById($id, true);
  250. if (empty($custom)) {
  251. util::fail('没有找到客户信息');
  252. }
  253. if ($custom->shopId != $this->shopId) {
  254. util::fail('不是你的客户');
  255. }
  256. util::success(['custom' => $custom]);
  257. }
  258. //获取客户基本和资产信息 ssh 2019.11.30
  259. public function actionDetail()
  260. {
  261. $userId = Yii::$app->request->get('userId');
  262. $info = CustomClass::getCustomInfo($userId);
  263. CustomClass::valid($info, $this->shopId);
  264. util::success($info);
  265. }
  266. //获取客户详情,包括基本信息、资产、订单和备注 2019.11.30
  267. public function actionUserDetail()
  268. {
  269. $userId = Yii::$app->request->get('userId');
  270. $info = UserService::getFullUserInfo($userId);
  271. UserService::valid($info, $this->sjId);
  272. $list = MerchantRemarkService::getRemarkList($userId);
  273. $info['remarkList'] = $list;
  274. util::success($info);
  275. }
  276. //添加客户,申请会员时会自动同步资产 ssh 2019.11.30
  277. public function actionAdd()
  278. {
  279. $post = Yii::$app->request->post();
  280. if (isset($post['mobile']) == false || stringUtil::isMobile($post['mobile']) == false) {
  281. util::fail('请输入手机号');
  282. }
  283. if ($post['mobile'] != $post['confirmMobile']) {
  284. util::fail('二次输入手机号不一样');
  285. }
  286. $payPassword = isset($post['payPassword']) ? $post['payPassword'] : '';
  287. AdminService::verifyPayPassword($this->adminId, $payPassword);
  288. $mobile = $post['mobile'];
  289. $user = UserService::getByMobile($mobile, $this->sjId);
  290. if (!empty($user)) {
  291. util::fail('手机号已使用');
  292. }
  293. $post['sjId'] = $this->sjId;
  294. $post['member'] = $post['memberLevel'];
  295. UserService::addUser($post);
  296. util::complete();
  297. }
  298. //充值 ssh 2019.12.1
  299. public function actionRecharge()
  300. {
  301. $post = Yii::$app->request->post();
  302. $payPassword = isset($post['payPassword']) ? $post['payPassword'] : '';
  303. AdminService::verifyPayPassword($this->adminId, $payPassword);
  304. $userId = isset($post['userId']) ? $post['userId'] : 0;
  305. $rechargeAmount = isset($post['rechargeAmount']) ? $post['rechargeAmount'] : 1;
  306. $user = UserService::getById($userId);
  307. if (empty($user)) {
  308. util::fail('找不到客户');
  309. }
  310. if ($user['sjId'] != $this->sjId) {
  311. util::fail('您无法操作');
  312. }
  313. $userAsset = UserAssetService::getByUserId($userId);
  314. $totalBalance = $userAsset['balance'] + $rechargeAmount;
  315. $totalRecharge = $userAsset['totalRecharge'] + $rechargeAmount;
  316. $upData['balance'] = $totalBalance;
  317. $upData['totalRecharge'] = $totalRecharge;
  318. $merchantAsset = MerchantAssetService::getBySjId($this->sjId);
  319. $return = xhRechargeService::recharge($rechargeAmount, $user, $this->adminId, $this->sj->attributes, $this->sjExtend->attributes, $merchantAsset);
  320. if ($return['code'] == 'A0001') {
  321. util::complete();
  322. }
  323. util::fail();
  324. }
  325. //升级 ssh 2019.12.1
  326. public function actionUpgrade()
  327. {
  328. $post = Yii::$app->request->post();
  329. $userId = isset($post['userId']) ? $post['userId'] : 0;
  330. $member = isset($post['member']) ? $post['member'] : 0;
  331. $user = UserService::getById($userId);
  332. if (empty($user)) {
  333. util::fail('客户不存在');
  334. }
  335. //验证是否商家客户
  336. UserService::valid($user, $this->sjId);
  337. //验证确认密码
  338. $payPassword = $post['payPassword'];
  339. AdminService::verifyPayPassword($this->adminId, $payPassword);
  340. $grade = xhMerchantExtendService::getGradeList($this->sjExtend->attributes, 'desc');
  341. //升级后的成长值
  342. $newLevelGrowth = $grade[$member]['growth'];
  343. $newDiscount = $grade[$member]['discount'];
  344. $userAsset = UserAssetService::getByUserId($userId);
  345. if ($userAsset['member'] >= $member) {
  346. util::fail('客户已经达到此级别了');
  347. }
  348. $now = time();
  349. $date = date("Y-m-d H:i", $now);
  350. $connection = Yii::$app->db;
  351. $transaction = $connection->beginTransaction();
  352. try {
  353. $addGrowth = $newLevelGrowth - $userAsset['growth'];
  354. $upData['growth'] = $newLevelGrowth;
  355. $upData['member'] = $member;
  356. $upData['discount'] = $newDiscount;
  357. UserAssetService::updateByUserId($userId, $upData);
  358. UserService::updateById($userId, ['member' => $member]);
  359. $upgradeData = [
  360. 'member' => $member,
  361. 'prevMember' => $userAsset['member'],
  362. 'sjId' => $this->sjId,
  363. 'gainType' => 0,
  364. 'addTime' => $now,
  365. 'userId' => $userId,
  366. ];
  367. $upgradeRespond = UserUpgradeService::add($upgradeData);
  368. $growthData = [
  369. 'userId' => $userId,
  370. 'userName' => $user['userName'],
  371. 'sjId' => $this->sjId,
  372. 'relateId' => $upgradeRespond['id'],
  373. 'growth' => $newLevelGrowth,
  374. 'num' => $addGrowth,
  375. 'io' => 1,
  376. 'payWay' => 4,
  377. 'alipayId' => '',
  378. 'event' => '管理员操作升到' . $member . '级增加成长值',
  379. 'operatorId' => $userId,
  380. 'createTime' => $date,
  381. 'gainType' => 0,
  382. 'addTime' => $now,
  383. ];
  384. UserGrowthService::add($growthData);
  385. $transaction->commit();
  386. } catch (\Exception $e) {
  387. $transaction->rollBack();
  388. util::fail();
  389. }
  390. $allTM = xhTMessageService::getList($this->sjId);
  391. $openId = isset($user['openId']) ? $user['openId'] : '';
  392. if (empty($openId)) {
  393. util::complete();
  394. }
  395. $shortTempId = 'OPENTM205211943';//升级通知
  396. if (isset($allTM[$shortTempId]) == false) {
  397. util::complete();
  398. }
  399. $tempId = $allTM[$shortTempId];
  400. $data = [
  401. "touser" => $openId, "template_id" => $tempId, "url" => '',
  402. "data" => [
  403. "first" => ["value" => "恭喜,您已经升为{$member}级会员。", "color" => "#173177"],
  404. "keyword1" => ["value" => $user['userName'], "color" => "#173177"],
  405. "keyword2" => ["value" => $date, "color" => "#173177"],
  406. "remark" => ["value" => "点击查看会员权益", "color" => "#173177"],
  407. ]];
  408. wxUtil::sendTaskInform($data, $this->sj);
  409. util::complete();
  410. }
  411. //重置客户密码
  412. public function actionResetPayPassword()
  413. {
  414. $post = Yii::$app->request->post();
  415. $userId = isset($post['userId']) ? $post['userId'] : 0;
  416. $password = isset($post['password']) ? $post['password'] : 0;
  417. $info = UserService::getById($userId);
  418. UserService::valid($info, $this->sjId);
  419. UserService::updateById($userId, ['payPassword' => password_hash($password, PASSWORD_BCRYPT)]);
  420. util::complete();
  421. }
  422. //获取登陆客户的资产 ssh 2019.11.22
  423. public function actionAsset()
  424. {
  425. $asset = UserAssetService::getByUserId($this->adminId);
  426. util::success($asset);
  427. }
  428. //获取登陆客户的优惠情况 ssh 2019.12.3
  429. public function actionDiscount()
  430. {
  431. $discount = UserAssetService::getDiscount($this->adminId);
  432. util::success($discount);
  433. }
  434. //小程序用户完整信息 ssh 2019.12.12
  435. public function actionMiniFullInfo()
  436. {
  437. $post = Yii::$app->request->post();
  438. $iv = isset($post['iv']) ? $post['iv'] : '';
  439. $encryptedData = isset($post['encryptedData']) ? $post['encryptedData'] : '';
  440. $appId = $this->sj['miniAppId'];
  441. $sjId = $this->sjId;
  442. $miniOpenId = $this->user['miniOpenId'];
  443. if (empty($miniOpenId)) {
  444. util::fail('mini_open_id empty');
  445. }
  446. $cacheKey = 'MALL_MINI_SESSION_KEY_' . $miniOpenId;
  447. $sessionKey = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
  448. $wxMiniSecret = Yii::getAlias("@vendor/weixinMiniSecret");
  449. require_once($wxMiniSecret . '/wxBizDataCrypt.php');
  450. $pc = new \WXBizDataCrypt($appId, $sessionKey);
  451. $errCode = $pc->decryptData($encryptedData, $iv, $result);
  452. if ($errCode != 0) {
  453. Yii::info($result . ' ' . $errCode);
  454. util::fail('获取用户信息失败');
  455. }
  456. Yii::info('小程序获取用户信息:' . $result);
  457. $originalInfo = Json::decode($result);
  458. $source = UserClass::$userSourceId['mini']['name'];
  459. $user = UserService::replaceUser($originalInfo, $source, $sjId);
  460. $userId = $user['id'];
  461. $userInfo = UserService::getUserInfo($userId);
  462. util::success($userInfo);
  463. }
  464. //小程序用户手机号
  465. public function actionMiniMobile()
  466. {
  467. $post = Yii::$app->request->post();
  468. $iv = $post['iv'];
  469. $encryptedData = $post['encryptedData'];
  470. $sjId = $this->sjId;
  471. $merchant = $this->sj->attributes;
  472. $appId = $merchant['miniAppId'];
  473. $miniOpenId = $this->user['miniOpenId'];
  474. $user = $this->user;
  475. if (!empty($user) && !empty($user['mobile'])) {
  476. $userId = $user['id'];
  477. util::success(['mobile' => $user['mobile']]);
  478. }
  479. $cacheKey = 'MALL_MINI_SESSION_KEY_' . $miniOpenId;
  480. $sessionKey = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
  481. if (empty($sessionKey)) {
  482. util::fail('系统错误,sesstion empty');
  483. }
  484. $wxMiniSecret = Yii::getAlias("@vendor/weixinMiniSecret");
  485. require_once($wxMiniSecret . '/wxBizDataCrypt.php');
  486. $pc = new \WXBizDataCrypt($appId, $sessionKey);
  487. $errCode = $pc->decryptData($encryptedData, $iv, $result);
  488. if ($errCode != 0) {
  489. util::fail('解密失败');
  490. }
  491. $arr = Json::decode($result);
  492. $mobile = isset($arr['purePhoneNumber']) ? $arr['purePhoneNumber'] : '';
  493. if (empty($mobile)) {
  494. util::fail('没有获取手机号,请重试');
  495. }
  496. $userId = $user['id'];
  497. UserService::becomeMember($user, $merchant, ['mobile' => $mobile]);
  498. util::success(['mobile' => $mobile]);
  499. }
  500. //密码修改
  501. public function actionPassword()
  502. {
  503. $post = Yii::$app->request->post();
  504. $old = isset($post['old']) ? $post['old'] : '';
  505. $new = isset($post['new']) ? $post['new'] : '';
  506. $confirm = isset($post['confirm']) ? $post['confirm'] : '';
  507. if (empty($new)) {
  508. util::fail('请输入新密码');
  509. }
  510. if ($new != $confirm) {
  511. util::fail('二次密码不一致');
  512. }
  513. $userId = $this->adminId;
  514. $user = UserService::getUserInfo($userId);
  515. if (isset($user['hasPayPwd']) && $user['hasPayPwd'] == 1) {
  516. if (empty($old)) {
  517. util::fail('请填写旧密码');
  518. }
  519. if (password_verify($old, $user['payPassword']) == false) {
  520. util::fail('旧密码错误');
  521. }
  522. }
  523. UserService::updateById($userId, ['payPassword' => password_hash($new, PASSWORD_BCRYPT), 'hasPayPwd' => 1]);
  524. util::complete('修改成功');
  525. }
  526. //申请会员 ssh 2019.12.18
  527. public function actionApplyMember()
  528. {
  529. $post = Yii::$app->request->post();
  530. $mobile = isset($post['mobile']) ? $post['mobile'] : 0;
  531. if (stringUtil::isMobile($mobile) == false) {
  532. util::fail('请输入手机号');
  533. }
  534. $userId = $this->adminId;
  535. $asset = UserAssetService::getByUserId($userId);
  536. if (isset($asset['member']) && $asset['member'] != -1) {
  537. util::fail('已经是会员了');
  538. }
  539. $code = isset($post['code']) ? $post['code'] : '';
  540. $cacheCode = SmsService::getApplyMemberCode($userId, $mobile);
  541. if (empty($cacheCode) || $cacheCode != $code) {
  542. util::fail('验证码错误');
  543. }
  544. $update = [];
  545. if (isset($post['realName']) && !empty($post['realName'])) {
  546. $update['realName'] = $post['realName'];
  547. }
  548. if (isset($post['birthday']) && !empty($post['birthday'])) {
  549. $update['birthday'] = $post['birthday'];
  550. }
  551. $user = UserService::getByCondition(['sjId' => $this->sjId, 'mobile' => $mobile]);
  552. if ($userId == $user['id']) {
  553. util::fail('手机号已验证');
  554. }
  555. if (!empty($user)) {
  556. util::fail('手机号已经注册过了');
  557. }
  558. $update['mobile'] = $mobile;
  559. UserService::becomeMember($this->user, $this->sj->attributes, $update);
  560. util::complete('注册成功');
  561. }
  562. //用户基本信息和资产 ssh 2019.12.19
  563. public function actionMyProfile()
  564. {
  565. $custom = $this->custom;
  566. $user = UserService::getUserInfo($this->adminId);
  567. $growth = $custom['growth'] ?? 0;
  568. $extend = $this->sjExtend->attributes;
  569. $grade = MerchantExtendService::getGradeList($extend, 'asc');
  570. //下个等级的积分
  571. $nextLevelGrowth = 0;
  572. foreach ($grade as $val) {
  573. $currentGrowth = $val['growth'];
  574. if ($currentGrowth > $growth) {
  575. $nextLevelGrowth = $currentGrowth;
  576. break;
  577. }
  578. }
  579. $user['userAsset']['nextLevelGrowth'] = $nextLevelGrowth;
  580. util::success($user);
  581. }
  582. //登陆客户的信息 ssh 2020.3.12
  583. public function actionLoginDetail()
  584. {
  585. $user = $this->user;
  586. util::success($user);
  587. }
  588. //总赊账和总余额汇总 ssh 20250620
  589. public function actionShowTotalBalance()
  590. {
  591. $lookMoney = \bizGhs\shop\classes\ShopAdminClass::lookMoneyPower($this->shopAdmin, $this->shop);
  592. if ($lookMoney == 0) {
  593. util::fail('无法查看哦');
  594. }
  595. $lsShop = $this->shop;
  596. $pfShopId = $lsShop->pfShopId;
  597. $lsShopId = $this->shopId;
  598. $respond = \bizGhs\custom\classes\CustomClass::showTotalBalance($pfShopId, $lsShopId);
  599. $respond['pfShopId'] = $pfShopId;
  600. $respond['lsShopId'] = $lsShopId;
  601. util::success($respond);
  602. }
  603. }