CustomController.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  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. $searchStyle = $get['searchStyle'] ?? 0;
  220. $where = ['shopId' => $this->shopId];
  221. if ($type == 1) {
  222. //消费排行
  223. $sort = 'buyAmount DESC';
  224. } else if ($type == 2) {
  225. //余额客户
  226. $sort = 'balance DESC';
  227. } else if ($type == 3) {
  228. //生日
  229. $sort = 'birthdayTime ASC';
  230. $where['birthdayTime>'] = 0;
  231. } else {
  232. $sort = 'visitTime DESC';
  233. }
  234. $name = $get['name'] ?? '';
  235. if (empty($name)) {
  236. $name = $get['keyword'] ?? '';
  237. }
  238. if (empty($name)) {
  239. $name = $get['searchText'] ?? '';
  240. }
  241. if (!empty($name)) {
  242. if ($searchStyle == 0) {
  243. $where['mobile'] = ['like', $name];
  244. } else {
  245. if (stringUtil::isLetter($name)) {
  246. $where['py'] = ['like', $name];
  247. } else {
  248. $where['name'] = ['like', $name];
  249. }
  250. }
  251. }
  252. $list = CustomService::getCustomList($where, $sort);
  253. util::success($list);
  254. }
  255. //获取客户信息 ssh 20250510
  256. public function actionInfo()
  257. {
  258. $get = Yii::$app->request->get();
  259. $id = $get['id'] ?? 0;
  260. $custom = CustomClass::getById($id, true);
  261. if (empty($custom)) {
  262. util::fail('没有找到客户信息');
  263. }
  264. if ($custom->shopId != $this->shopId) {
  265. util::fail('不是你的客户');
  266. }
  267. util::success(['custom' => $custom]);
  268. }
  269. //获取客户基本和资产信息 ssh 2019.11.30
  270. public function actionDetail()
  271. {
  272. $userId = Yii::$app->request->get('userId');
  273. $info = CustomClass::getCustomInfo($userId);
  274. CustomClass::valid($info, $this->shopId);
  275. util::success($info);
  276. }
  277. //获取客户详情,包括基本信息、资产、订单和备注 2019.11.30
  278. public function actionUserDetail()
  279. {
  280. $userId = Yii::$app->request->get('userId');
  281. $info = UserService::getFullUserInfo($userId);
  282. UserService::valid($info, $this->sjId);
  283. $list = MerchantRemarkService::getRemarkList($userId);
  284. $info['remarkList'] = $list;
  285. util::success($info);
  286. }
  287. //添加客户,申请会员时会自动同步资产 ssh 2019.11.30
  288. public function actionAdd()
  289. {
  290. $post = Yii::$app->request->post();
  291. if (isset($post['mobile']) == false || stringUtil::isMobile($post['mobile']) == false) {
  292. util::fail('请输入手机号');
  293. }
  294. if ($post['mobile'] != $post['confirmMobile']) {
  295. util::fail('二次输入手机号不一样');
  296. }
  297. $payPassword = isset($post['payPassword']) ? $post['payPassword'] : '';
  298. AdminService::verifyPayPassword($this->adminId, $payPassword);
  299. $mobile = $post['mobile'];
  300. $user = UserService::getByMobile($mobile, $this->sjId);
  301. if (!empty($user)) {
  302. util::fail('手机号已使用');
  303. }
  304. $post['sjId'] = $this->sjId;
  305. $post['member'] = $post['memberLevel'];
  306. UserService::addUser($post);
  307. util::complete();
  308. }
  309. //充值 ssh 2019.12.1
  310. public function actionRecharge()
  311. {
  312. $post = Yii::$app->request->post();
  313. $payPassword = isset($post['payPassword']) ? $post['payPassword'] : '';
  314. AdminService::verifyPayPassword($this->adminId, $payPassword);
  315. $userId = isset($post['userId']) ? $post['userId'] : 0;
  316. $rechargeAmount = isset($post['rechargeAmount']) ? $post['rechargeAmount'] : 1;
  317. $user = UserService::getById($userId);
  318. if (empty($user)) {
  319. util::fail('找不到客户');
  320. }
  321. if ($user['sjId'] != $this->sjId) {
  322. util::fail('您无法操作');
  323. }
  324. $userAsset = UserAssetService::getByUserId($userId);
  325. $totalBalance = $userAsset['balance'] + $rechargeAmount;
  326. $totalRecharge = $userAsset['totalRecharge'] + $rechargeAmount;
  327. $upData['balance'] = $totalBalance;
  328. $upData['totalRecharge'] = $totalRecharge;
  329. $merchantAsset = MerchantAssetService::getBySjId($this->sjId);
  330. $return = xhRechargeService::recharge($rechargeAmount, $user, $this->adminId, $this->sj->attributes, $this->sjExtend->attributes, $merchantAsset);
  331. if ($return['code'] == 'A0001') {
  332. util::complete();
  333. }
  334. util::fail();
  335. }
  336. //升级 ssh 2019.12.1
  337. public function actionUpgrade()
  338. {
  339. $post = Yii::$app->request->post();
  340. $userId = isset($post['userId']) ? $post['userId'] : 0;
  341. $member = isset($post['member']) ? $post['member'] : 0;
  342. $user = UserService::getById($userId);
  343. if (empty($user)) {
  344. util::fail('客户不存在');
  345. }
  346. //验证是否商家客户
  347. UserService::valid($user, $this->sjId);
  348. //验证确认密码
  349. $payPassword = $post['payPassword'];
  350. AdminService::verifyPayPassword($this->adminId, $payPassword);
  351. $grade = xhMerchantExtendService::getGradeList($this->sjExtend->attributes, 'desc');
  352. //升级后的成长值
  353. $newLevelGrowth = $grade[$member]['growth'];
  354. $newDiscount = $grade[$member]['discount'];
  355. $userAsset = UserAssetService::getByUserId($userId);
  356. if ($userAsset['member'] >= $member) {
  357. util::fail('客户已经达到此级别了');
  358. }
  359. $now = time();
  360. $date = date("Y-m-d H:i", $now);
  361. $connection = Yii::$app->db;
  362. $transaction = $connection->beginTransaction();
  363. try {
  364. $addGrowth = $newLevelGrowth - $userAsset['growth'];
  365. $upData['growth'] = $newLevelGrowth;
  366. $upData['member'] = $member;
  367. $upData['discount'] = $newDiscount;
  368. UserAssetService::updateByUserId($userId, $upData);
  369. UserService::updateById($userId, ['member' => $member]);
  370. $upgradeData = [
  371. 'member' => $member,
  372. 'prevMember' => $userAsset['member'],
  373. 'sjId' => $this->sjId,
  374. 'gainType' => 0,
  375. 'addTime' => $now,
  376. 'userId' => $userId,
  377. ];
  378. $upgradeRespond = UserUpgradeService::add($upgradeData);
  379. $growthData = [
  380. 'userId' => $userId,
  381. 'userName' => $user['userName'],
  382. 'sjId' => $this->sjId,
  383. 'relateId' => $upgradeRespond['id'],
  384. 'growth' => $newLevelGrowth,
  385. 'num' => $addGrowth,
  386. 'io' => 1,
  387. 'payWay' => 4,
  388. 'alipayId' => '',
  389. 'event' => '管理员操作升到' . $member . '级增加成长值',
  390. 'operatorId' => $userId,
  391. 'createTime' => $date,
  392. 'gainType' => 0,
  393. 'addTime' => $now,
  394. ];
  395. UserGrowthService::add($growthData);
  396. $transaction->commit();
  397. } catch (\Exception $e) {
  398. $transaction->rollBack();
  399. util::fail();
  400. }
  401. $allTM = xhTMessageService::getList($this->sjId);
  402. $openId = isset($user['openId']) ? $user['openId'] : '';
  403. if (empty($openId)) {
  404. util::complete();
  405. }
  406. $shortTempId = 'OPENTM205211943';//升级通知
  407. if (isset($allTM[$shortTempId]) == false) {
  408. util::complete();
  409. }
  410. $tempId = $allTM[$shortTempId];
  411. $data = [
  412. "touser" => $openId, "template_id" => $tempId, "url" => '',
  413. "data" => [
  414. "first" => ["value" => "恭喜,您已经升为{$member}级会员。", "color" => "#173177"],
  415. "keyword1" => ["value" => $user['userName'], "color" => "#173177"],
  416. "keyword2" => ["value" => $date, "color" => "#173177"],
  417. "remark" => ["value" => "点击查看会员权益", "color" => "#173177"],
  418. ]];
  419. wxUtil::sendTaskInform($data, $this->sj);
  420. util::complete();
  421. }
  422. //重置客户密码
  423. public function actionResetPayPassword()
  424. {
  425. $post = Yii::$app->request->post();
  426. $userId = isset($post['userId']) ? $post['userId'] : 0;
  427. $password = isset($post['password']) ? $post['password'] : 0;
  428. $info = UserService::getById($userId);
  429. UserService::valid($info, $this->sjId);
  430. UserService::updateById($userId, ['payPassword' => password_hash($password, PASSWORD_BCRYPT)]);
  431. util::complete();
  432. }
  433. //获取登陆客户的资产 ssh 2019.11.22
  434. public function actionAsset()
  435. {
  436. $asset = UserAssetService::getByUserId($this->adminId);
  437. util::success($asset);
  438. }
  439. //获取登陆客户的优惠情况 ssh 2019.12.3
  440. public function actionDiscount()
  441. {
  442. $discount = UserAssetService::getDiscount($this->adminId);
  443. util::success($discount);
  444. }
  445. //小程序用户完整信息 ssh 2019.12.12
  446. public function actionMiniFullInfo()
  447. {
  448. $post = Yii::$app->request->post();
  449. $iv = isset($post['iv']) ? $post['iv'] : '';
  450. $encryptedData = isset($post['encryptedData']) ? $post['encryptedData'] : '';
  451. $appId = $this->sj['miniAppId'];
  452. $sjId = $this->sjId;
  453. $miniOpenId = $this->user['miniOpenId'];
  454. if (empty($miniOpenId)) {
  455. util::fail('mini_open_id empty');
  456. }
  457. $cacheKey = 'MALL_MINI_SESSION_KEY_' . $miniOpenId;
  458. $sessionKey = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
  459. $wxMiniSecret = Yii::getAlias("@vendor/weixinMiniSecret");
  460. require_once($wxMiniSecret . '/wxBizDataCrypt.php');
  461. $pc = new \WXBizDataCrypt($appId, $sessionKey);
  462. $errCode = $pc->decryptData($encryptedData, $iv, $result);
  463. if ($errCode != 0) {
  464. Yii::info($result . ' ' . $errCode);
  465. util::fail('获取用户信息失败');
  466. }
  467. Yii::info('小程序获取用户信息:' . $result);
  468. $originalInfo = Json::decode($result);
  469. $source = UserClass::$userSourceId['mini']['name'];
  470. $user = UserService::replaceUser($originalInfo, $source, $sjId);
  471. $userId = $user['id'];
  472. $userInfo = UserService::getUserInfo($userId);
  473. util::success($userInfo);
  474. }
  475. //小程序用户手机号
  476. public function actionMiniMobile()
  477. {
  478. $post = Yii::$app->request->post();
  479. $iv = $post['iv'];
  480. $encryptedData = $post['encryptedData'];
  481. $sjId = $this->sjId;
  482. $merchant = $this->sj->attributes;
  483. $appId = $merchant['miniAppId'];
  484. $miniOpenId = $this->user['miniOpenId'];
  485. $user = $this->user;
  486. if (!empty($user) && !empty($user['mobile'])) {
  487. $userId = $user['id'];
  488. util::success(['mobile' => $user['mobile']]);
  489. }
  490. $cacheKey = 'MALL_MINI_SESSION_KEY_' . $miniOpenId;
  491. $sessionKey = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
  492. if (empty($sessionKey)) {
  493. util::fail('系统错误,sesstion empty');
  494. }
  495. $wxMiniSecret = Yii::getAlias("@vendor/weixinMiniSecret");
  496. require_once($wxMiniSecret . '/wxBizDataCrypt.php');
  497. $pc = new \WXBizDataCrypt($appId, $sessionKey);
  498. $errCode = $pc->decryptData($encryptedData, $iv, $result);
  499. if ($errCode != 0) {
  500. util::fail('解密失败');
  501. }
  502. $arr = Json::decode($result);
  503. $mobile = isset($arr['purePhoneNumber']) ? $arr['purePhoneNumber'] : '';
  504. if (empty($mobile)) {
  505. util::fail('没有获取手机号,请重试');
  506. }
  507. $userId = $user['id'];
  508. UserService::becomeMember($user, $merchant, ['mobile' => $mobile]);
  509. util::success(['mobile' => $mobile]);
  510. }
  511. //密码修改
  512. public function actionPassword()
  513. {
  514. $post = Yii::$app->request->post();
  515. $old = isset($post['old']) ? $post['old'] : '';
  516. $new = isset($post['new']) ? $post['new'] : '';
  517. $confirm = isset($post['confirm']) ? $post['confirm'] : '';
  518. if (empty($new)) {
  519. util::fail('请输入新密码');
  520. }
  521. if ($new != $confirm) {
  522. util::fail('二次密码不一致');
  523. }
  524. $userId = $this->adminId;
  525. $user = UserService::getUserInfo($userId);
  526. if (isset($user['hasPayPwd']) && $user['hasPayPwd'] == 1) {
  527. if (empty($old)) {
  528. util::fail('请填写旧密码');
  529. }
  530. if (password_verify($old, $user['payPassword']) == false) {
  531. util::fail('旧密码错误');
  532. }
  533. }
  534. UserService::updateById($userId, ['payPassword' => password_hash($new, PASSWORD_BCRYPT), 'hasPayPwd' => 1]);
  535. util::complete('修改成功');
  536. }
  537. //申请会员 ssh 2019.12.18
  538. public function actionApplyMember()
  539. {
  540. $post = Yii::$app->request->post();
  541. $mobile = isset($post['mobile']) ? $post['mobile'] : 0;
  542. if (stringUtil::isMobile($mobile) == false) {
  543. util::fail('请输入手机号');
  544. }
  545. $userId = $this->adminId;
  546. $asset = UserAssetService::getByUserId($userId);
  547. if (isset($asset['member']) && $asset['member'] != -1) {
  548. util::fail('已经是会员了');
  549. }
  550. $code = isset($post['code']) ? $post['code'] : '';
  551. $cacheCode = SmsService::getApplyMemberCode($userId, $mobile);
  552. if (empty($cacheCode) || $cacheCode != $code) {
  553. util::fail('验证码错误');
  554. }
  555. $update = [];
  556. if (isset($post['realName']) && !empty($post['realName'])) {
  557. $update['realName'] = $post['realName'];
  558. }
  559. if (isset($post['birthday']) && !empty($post['birthday'])) {
  560. $update['birthday'] = $post['birthday'];
  561. }
  562. $user = UserService::getByCondition(['sjId' => $this->sjId, 'mobile' => $mobile]);
  563. if ($userId == $user['id']) {
  564. util::fail('手机号已验证');
  565. }
  566. if (!empty($user)) {
  567. util::fail('手机号已经注册过了');
  568. }
  569. $update['mobile'] = $mobile;
  570. UserService::becomeMember($this->user, $this->sj->attributes, $update);
  571. util::complete('注册成功');
  572. }
  573. //用户基本信息和资产 ssh 2019.12.19
  574. public function actionMyProfile()
  575. {
  576. $custom = $this->custom;
  577. $user = UserService::getUserInfo($this->adminId);
  578. $growth = $custom['growth'] ?? 0;
  579. $extend = $this->sjExtend->attributes;
  580. $grade = MerchantExtendService::getGradeList($extend, 'asc');
  581. //下个等级的积分
  582. $nextLevelGrowth = 0;
  583. foreach ($grade as $val) {
  584. $currentGrowth = $val['growth'];
  585. if ($currentGrowth > $growth) {
  586. $nextLevelGrowth = $currentGrowth;
  587. break;
  588. }
  589. }
  590. $user['userAsset']['nextLevelGrowth'] = $nextLevelGrowth;
  591. util::success($user);
  592. }
  593. //登陆客户的信息 ssh 2020.3.12
  594. public function actionLoginDetail()
  595. {
  596. $user = $this->user;
  597. util::success($user);
  598. }
  599. //总赊账和总余额汇总 ssh 20250620
  600. public function actionShowTotalBalance()
  601. {
  602. $lookMoney = \bizGhs\shop\classes\ShopAdminClass::lookMoneyPower($this->shopAdmin, $this->shop);
  603. if ($lookMoney == 0) {
  604. util::fail('无法查看哦');
  605. }
  606. $lsShop = $this->shop;
  607. $pfShopId = $lsShop->pfShopId;
  608. $lsShopId = $this->shopId;
  609. $respond = \bizGhs\custom\classes\CustomClass::showTotalBalance($pfShopId, $lsShopId);
  610. $respond['pfShopId'] = $pfShopId;
  611. $respond['lsShopId'] = $lsShopId;
  612. util::success($respond);
  613. }
  614. }