CustomController.php 23 KB

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