AuthController.php 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002
  1. <?php
  2. namespace hd\controllers;
  3. use biz\admin\classes\AdminClass;
  4. use biz\pt\classes\AgreementClass;
  5. use biz\shop\classes\ShopClass;
  6. use bizHd\admin\classes\ShopAdminClass;
  7. use bizHd\admin\services\ShopAdminService;
  8. use bizHd\admin\services\AdminService;
  9. use bizHd\member\classes\MemberLevelClass;
  10. use bizHd\recharge\classes\RechargeSqClass;
  11. use bizHd\shop\classes\ShopExtClass;
  12. use bizHd\wx\services\WxOpenService;
  13. use common\components\dict;
  14. use common\components\httpUtil;
  15. use common\components\imgUtil;
  16. use common\components\jwt;
  17. use common\components\sms;
  18. use common\components\util;
  19. use Yii;
  20. use common\components\stringUtil;
  21. use biz\sj\services\MerchantService;
  22. use bizHd\user\services\UserService;
  23. use common\services\xhMerchantService;
  24. use common\components\wxUtil;
  25. use linslin\yii2\curl;
  26. use yii\helpers\Json;
  27. /**
  28. * 用户登陆
  29. */
  30. class AuthController extends PublicController
  31. {
  32. //获取手机号 ssh 20250217
  33. public function actionGetMobile()
  34. {
  35. $post = Yii::$app->request->post();
  36. $iv = $post['iv'];
  37. $encryptedData = $post['encryptedData'];
  38. $merchant = WxOpenService::getWxMiniBase();
  39. $appId = $merchant['miniAppId'];
  40. $miniOpenId = $post['miniOpenId'] ?? '';
  41. if (empty($miniOpenId)) {
  42. util::success(['hasNoOpenId' => 1], '登录失败,没有miniOpenId');
  43. }
  44. $cacheKey = 'SHOP_MINI_SESSION_KEY_' . $miniOpenId;
  45. $sessionKey = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
  46. if (empty($sessionKey)) {
  47. Yii::$app->redis->executeCommand('DEL', [$cacheKey]);
  48. //noticeUtil::push($cacheKey . " 登录失败!!sessionKey空的", '15280215347');
  49. util::success(['hasNoOpenId' => 1], '登录失败!');
  50. }
  51. $wxMiniSecret = Yii::getAlias("@vendor/weixinMiniSecret");
  52. require_once($wxMiniSecret . '/wxBizDataCrypt.php');
  53. $pc = new \WXBizDataCrypt($appId, $sessionKey);
  54. $errCode = $pc->decryptData($encryptedData, $iv, $result);
  55. if ($errCode != 0) {
  56. Yii::$app->redis->executeCommand('DEL', [$cacheKey]);
  57. //noticeUtil::push($cacheKey . " 登录失败!!!!sessionKey异常", '15280215347');
  58. util::success(['hasNoOpenId' => 1], '登录失败...');
  59. }
  60. $arr = Json::decode($result);
  61. $phoneNumber = isset($arr['purePhoneNumber']) ? $arr['purePhoneNumber'] : '';
  62. if (empty($phoneNumber)) {
  63. Yii::$app->redis->executeCommand('DEL', [$cacheKey]);
  64. //noticeUtil::push($cacheKey . " 登录失败了!获取手机号失败", '15280215347');
  65. util::success(['hasNoOpenId' => 1], '登录失败了哦');
  66. }
  67. $cacheKey = 'getMobile_' . $phoneNumber;
  68. Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 300, 1]);
  69. util::success(['mobile' => $phoneNumber]);
  70. }
  71. //获取微信昵称
  72. public function actionGetNickname()
  73. {
  74. $post = Yii::$app->request->post();
  75. $iv = $post['iv'] ?? '';
  76. $encryptedData = $post['encryptedData'] ?? '';
  77. $merchant = WxOpenService::getWxMiniBase();
  78. $appId = $merchant['miniAppId'];
  79. $miniOpenId = $post['miniOpenId'] ?? '';
  80. if (empty($miniOpenId)) {
  81. util::fail('获取失败,请重新打开小程序');
  82. }
  83. $cacheKey = 'SHOP_MINI_SESSION_KEY_' . $miniOpenId;
  84. $sessionKey = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
  85. if (empty($sessionKey)) {
  86. util::fail('获取失败,请重新打开小程序');
  87. }
  88. $wxMiniSecret = Yii::getAlias("@vendor/weixinMiniSecret");
  89. require_once($wxMiniSecret . '/wxBizDataCrypt.php');
  90. $pc = new \WXBizDataCrypt($appId, $sessionKey);
  91. $errCode = $pc->decryptData($encryptedData, $iv, $result);
  92. if ($errCode != 0) {
  93. util::fail('获取微信昵称失败');
  94. }
  95. $arr = Json::decode($result);
  96. $nickName = $arr['nickName'] ?? '';
  97. if (empty($nickName)) {
  98. util::fail('没获取到微信昵称');
  99. }
  100. util::success(['name' => $nickName, 'nickName' => $nickName]);
  101. }
  102. //微信手机号一键登录 ssh 20210121
  103. public function actionWxMobileLogin()
  104. {
  105. $post = Yii::$app->request->post();
  106. $iv = $post['iv'];
  107. $encryptedData = $post['encryptedData'];
  108. $merchant = WxOpenService::getWxMiniBase();
  109. $appId = $merchant['miniAppId'];
  110. $miniOpenId = $post['miniOpenId'] ?? '';
  111. if (empty($miniOpenId)) {
  112. util::success(['hasNoOpenId' => 1], '登录失败,没有miniOpenId');
  113. }
  114. $cacheKey = 'SHOP_MINI_SESSION_KEY_' . $miniOpenId;
  115. $sessionKey = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
  116. if (empty($sessionKey)) {
  117. Yii::$app->redis->executeCommand('DEL', [$cacheKey]);
  118. //noticeUtil::push($cacheKey . " 登录失败!!sessionKey空的", '15280215347');
  119. util::success(['hasNoOpenId' => 1], '登录失败!');
  120. }
  121. $wxMiniSecret = Yii::getAlias("@vendor/weixinMiniSecret");
  122. require_once($wxMiniSecret . '/wxBizDataCrypt.php');
  123. $pc = new \WXBizDataCrypt($appId, $sessionKey);
  124. $errCode = $pc->decryptData($encryptedData, $iv, $result);
  125. if ($errCode != 0) {
  126. Yii::$app->redis->executeCommand('DEL', [$cacheKey]);
  127. //noticeUtil::push($cacheKey . " 登录失败!!!!sessionKey异常", '15280215347');
  128. util::success(['hasNoOpenId' => 1], '登录失败...');
  129. }
  130. $arr = Json::decode($result);
  131. $phoneNumber = isset($arr['purePhoneNumber']) ? $arr['purePhoneNumber'] : '';
  132. if (empty($phoneNumber)) {
  133. Yii::$app->redis->executeCommand('DEL', [$cacheKey]);
  134. //noticeUtil::push($cacheKey . " 登录失败了!获取手机号失败", '15280215347');
  135. util::success(['hasNoOpenId' => 1], '登录失败了哦');
  136. }
  137. $admin = AdminService::getByCondition(['mobile' => $phoneNumber]);
  138. if (empty($admin)) {
  139. util::fail('请先注册');
  140. }
  141. $adminId = $admin['id'];
  142. AdminClass::updateById($adminId, ['miniOpenId' => $miniOpenId]);
  143. $admin['miniOpenId'] = $miniOpenId;
  144. $openShop = $admin['openShop'] ?? 1;
  145. $currentShopId = $admin['currentShopId'] ?? 0;
  146. if (empty($currentShopId)) {
  147. if ($openShop == 2) {
  148. util::fail('审核中');
  149. }
  150. util::fail('请先注册');
  151. }
  152. $currentShop = ShopClass::getById($currentShopId, true);
  153. if (empty($currentShop)) {
  154. util::fail('没有找到门店36');
  155. }
  156. $pfShopId = $currentShop->pfShopId ?? 0;
  157. $onlyCg = $currentShop->onlyCg ?? 1;
  158. $mainId = $currentShop->mainId ?? 0;
  159. $shareLogo = imgUtil::groupImg('buy_logo.jpg');
  160. if (isset($currentShop->shareLogo) && !empty($currentShop->shareLogo)) {
  161. $shareLogo = imgUtil::groupImg($currentShop->shareLogo);
  162. }
  163. $shopAdmin = ShopAdminService::getByCondition(['adminId' => $adminId, 'mainId' => $mainId], true);
  164. if (empty($shopAdmin)) {
  165. util::fail('无法操作');
  166. }
  167. if ($shopAdmin->status == 0) {
  168. util::fail("您的账号已被冻结");
  169. }
  170. $token = jwt::getNewToken($adminId);
  171. $shopAdmin->lastLogin = date("Y-m-d H:i:s");
  172. $shopAdmin->save();
  173. $shopAdminId = $shopAdmin->id ?? 0;
  174. //是否有切换门店的权限
  175. $switchShop = \biz\shop\classes\ShopAdminClass::hasSwitchShopRight($shopAdmin);
  176. $prefix = imgUtil::getPrefix();
  177. $avatar = isset($admin['avatar']) && !empty($admin['avatar']) ? $prefix . $admin['avatar'] : $prefix . '/retail/default-img.png';
  178. $admin['avatar'] = $avatar;
  179. $showDemo = 1;
  180. $remind = getenv('HD_UPDATE_REMIND') == false ? 0 : getenv('HD_UPDATE_REMIND');
  181. $hdUpgrading = getenv('HD_UPGRADING') == false ? 0 : getenv('HD_UPGRADING');
  182. if ($hdUpgrading == 1) {
  183. $allowShopAdminIdsStr = getenv('HD_UPGRADE_ALLOW_SHOP_ADMIN_IDS') ?: '';
  184. $allowShopAdminIds = !empty($allowShopAdminIdsStr) ? explode(',', $allowShopAdminIdsStr) : [];
  185. if (!in_array($shopAdminId, $allowShopAdminIds)) {
  186. util::fail('系统升级中,稍后再试');
  187. }
  188. }
  189. $apiHost = Yii::$app->params['hdHost'];
  190. $imgUploadApi = $apiHost . '/upload/save-file';
  191. //惠雅鲜花员工不能看收入情况
  192. if (in_array($adminId, [2366, 2812, 4004])) {
  193. $shopAdmin->super = 0;
  194. }
  195. //充值送钱有没设置,没有设置则进行设置,临时方法,后面需要去掉,有多处,关键词recharge_sq_init ssh 20251229
  196. RechargeSqClass::initData($currentShop);
  197. //会员等级有没设置,没有设置则进行设置,临时方法,后面需要去掉,有多处,关键词member_level_init ssh 20251229
  198. MemberLevelClass::initData($currentShop);
  199. //涉及几个登录的地方,需要同步修改,请搜索关键词uni_login_info
  200. util::success([
  201. 'token' => $token,
  202. 'admin' => $admin,
  203. 'shopId' => $currentShopId,
  204. 'shopAdminId' => $shopAdminId,
  205. 'switchShop' => $switchShop,
  206. 'pfShopId' => $pfShopId,
  207. 'onlyCg' => $onlyCg,
  208. 'shareLogo' => $shareLogo,
  209. 'showDemo' => $showDemo,
  210. 'imgUploadApi' => $imgUploadApi,
  211. //有小程序新版本提示更新
  212. 'update' => $remind,
  213. 'staff' => $shopAdmin,
  214. ]);
  215. }
  216. //app登陆 ssh 20211219
  217. public function actionAppLogin()
  218. {
  219. $getParams = Yii::$app->request->get();
  220. $postParams = Yii::$app->request->post();
  221. $allParams = array_merge($getParams, $postParams);
  222. $mobile = $allParams['mobile'] ?? 0;
  223. if (!stringUtil::isMobile($mobile)) {
  224. util::fail('请填写正确手机号');
  225. }
  226. $password = !empty($allParams['password']) ? $allParams['password'] : '';
  227. if (empty($password)) {
  228. util::fail('请输入密码');
  229. }
  230. $admin = AdminService::getByCondition(['mobile' => $mobile]);
  231. if (empty($admin)) {
  232. util::fail('请先注册...');
  233. }
  234. if (!password_verify($password, $admin['password'])) {
  235. util::fail('密码错误');
  236. }
  237. $openShop = $admin['openShop'] ?? 1;
  238. $currentShopId = $admin['currentShopId'] ?? 0;
  239. if (empty($currentShopId)) {
  240. if ($openShop == 2) {
  241. util::fail('审核中');
  242. }
  243. util::fail('请先注册');
  244. }
  245. $currentShop = \bizHd\shop\classes\ShopClass::getById($currentShopId, true);
  246. if (empty($currentShop)) {
  247. util::fail('没有找到门店37');
  248. }
  249. $mainId = $currentShop->mainId ?? 0;
  250. $pfShopId = $currentShop->pfShopId ?? 0;
  251. $onlyCg = $currentShop->onlyCg ?? 1;
  252. $shopExt = ShopExtClass::getByCondition(['shopId' => $currentShop->id], false, false, 'reachVip');
  253. $shareLogo = imgUtil::groupImg('buy_logo.jpg');
  254. if (isset($currentShop->shareLogo) && !empty($currentShop->shareLogo)) {
  255. $shareLogo = imgUtil::groupImg($currentShop->shareLogo);
  256. }
  257. $adminId = $admin['id'];
  258. $shopAdmin = ShopAdminService::getByCondition(['mainId' => $mainId, 'adminId' => $adminId], true);
  259. if (empty($shopAdmin)) {
  260. util::fail('无法操作');
  261. }
  262. if ($shopAdmin->status == 0) {
  263. util::fail("您的账号已被冻结");
  264. }
  265. if ($shopAdmin->delStatus == 1) {
  266. util::fail("您的账号已删除");
  267. }
  268. $token = jwt::getNewToken($adminId);
  269. $shopAdmin->lastLogin = date("Y-m-d H:i:s");
  270. $shopAdmin->save();
  271. $shopAdminId = $shopAdmin->id ?? 0;
  272. //是否有切换门店的权限
  273. $switchShop = \biz\shop\classes\ShopAdminClass::hasSwitchShopRight($shopAdmin);
  274. $prefix = imgUtil::getPrefix();
  275. $avatar = isset($admin['avatar']) && !empty($admin['avatar']) ? $prefix . $admin['avatar'] : $prefix . '/retail/default-img.png';
  276. $admin['avatar'] = $avatar;
  277. $showDemo = 1;
  278. $remind = getenv('HD_UPDATE_REMIND') == false ? 0 : getenv('HD_UPDATE_REMIND');
  279. $hdUpgrading = getenv('HD_UPGRADING') == false ? 0 : getenv('HD_UPGRADING');
  280. if ($hdUpgrading == 1) {
  281. $allowShopAdminIdsStr = getenv('HD_UPGRADE_ALLOW_SHOP_ADMIN_IDS') ?: '';
  282. $allowShopAdminIds = !empty($allowShopAdminIdsStr) ? explode(',', $allowShopAdminIdsStr) : [];
  283. if (!in_array($shopAdminId, $allowShopAdminIds)) {
  284. util::fail('系统升级中,稍后再试');
  285. }
  286. }
  287. $apiHost = Yii::$app->params['hdHost'];
  288. $imgUploadApi = $apiHost . '/upload/save-file';
  289. //惠雅鲜花员工不能看收入情况
  290. if (in_array($adminId, [2366, 2812, 4004])) {
  291. $shopAdmin->super = 0;
  292. }
  293. //充值送钱有没设置,没有设置则进行设置,临时方法,后面需要去掉,有多处,关键词recharge_sq_init ssh 20251229
  294. RechargeSqClass::initData($currentShop);
  295. //会员等级有没设置,没有设置则进行设置,临时方法,后面需要去掉,有多处,关键词member_level_init ssh 20251229
  296. MemberLevelClass::initData($currentShop);
  297. //把设备状态更新为登录
  298. if (isset($allParams['deviceId']) && $allParams['deviceId'] != '') {
  299. $device = \bizHd\device\classes\HdDeviceClass::getByCondition(['shopId' => $currentShopId, 'deviceId' => $allParams['deviceId']], true);
  300. if ($device) {
  301. $device->status = 1;
  302. $device->save();
  303. }
  304. }
  305. unset($admin['password']); //返回的用户数据删除密码字段,防止密码加密方法被反查
  306. //涉及几个登录的地方,需要同步修改,请搜索关键词uni_login_info
  307. util::success([
  308. 'token' => $token,
  309. 'admin' => $admin,
  310. 'shopId' => $currentShopId,
  311. 'shopAdminId' => $shopAdminId,
  312. 'switchShop' => $switchShop,
  313. 'pfShopId' => $pfShopId,
  314. 'onlyCg' => $onlyCg,
  315. 'shareLogo' => $shareLogo,
  316. 'imgUploadApi' => $imgUploadApi,
  317. 'showDemo' => $showDemo,
  318. //有小程序新版本提示更新
  319. 'update' => $remind,
  320. 'staff' => $shopAdmin,
  321. 'reachVip' => $shopExt['reachVip'] //用于判断是否开启vip
  322. ]);
  323. }
  324. //本机号码一键登录 ssh 20210117
  325. public function actionPhoneLogin()
  326. {
  327. $get = Yii::$app->request->get();
  328. $access_token = $get['access_token'] ?? '';
  329. $openid = $get['openid'] ?? '';
  330. if (empty($access_token) || empty($openid)) {
  331. util::fail('参数错误');
  332. }
  333. //密钥,需要和uniCloud里的一致
  334. $secret = 'XHB2021198819640123';
  335. $params = ['access_token' => $access_token, 'openid' => $openid];
  336. $stringSignTemp = '';
  337. foreach ($params as $k => $v) {
  338. $stringSignTemp .= $k . '=' . $v . '&';
  339. }
  340. $stringSignTemp = rtrim($stringSignTemp, '&');
  341. $sign = hash_hmac('sha256', $stringSignTemp, $secret);
  342. $url = Yii::$app->params['hdUniCloudHost'] . "/getMobileNumber?access_token=" . $access_token . "&sign=" . $sign . "&" . $stringSignTemp;
  343. $curl = new curl\Curl();
  344. $respond = $curl->get($url);
  345. Yii::info($respond);
  346. $result = json_decode($respond, true);
  347. if (isset($result['code']) == false || $result['code'] != 1) {
  348. util::fail('获取手机号失败');
  349. }
  350. $phoneNumber = $result['data']['phoneNumber'] ?? '';
  351. if (empty($phoneNumber)) {
  352. util::fail('没有获取到手机号');
  353. }
  354. $admin = AdminService::getByCondition(['mobile' => $phoneNumber]);
  355. if (empty($admin)) {
  356. util::fail('请先注册');
  357. }
  358. $openShop = $admin['openShop'] ?? 1;
  359. $currentShopId = $admin['currentShopId'] ?? 0;
  360. if (empty($currentShopId)) {
  361. if ($openShop == 2) {
  362. util::fail('审核中');
  363. }
  364. util::fail('请先注册');
  365. }
  366. $currentShop = ShopClass::getById($currentShopId, true);
  367. if (empty($currentShop)) {
  368. util::fail('登录失败,没有找到门店38');
  369. }
  370. $pfShopId = $currentShop->pfShopId ?? 0;
  371. $onlyCg = $currentShop->onlyCg ?? 1;
  372. $shareLogo = imgUtil::groupImg('buy_logo.jpg');
  373. if (isset($currentShop->shareLogo) && !empty($currentShop->shareLogo)) {
  374. $shareLogo = imgUtil::groupImg($currentShop->shareLogo);
  375. }
  376. $adminId = $admin['id'];
  377. $mainId = $currentShop->mainId ?? 0;
  378. $shopAdmin = ShopAdminService::getByCondition(['mainId' => $mainId, 'adminId' => $adminId], true);
  379. if (empty($shopAdmin)) {
  380. util::fail('无法操作');
  381. }
  382. if ($shopAdmin->status == 0) {
  383. util::fail("您的账号已被冻结");
  384. }
  385. if ($shopAdmin->delStatus == 1) {
  386. util::fail("您的账号已删除");
  387. }
  388. $token = jwt::getNewToken($adminId);
  389. $shopAdmin->lastLogin = date("Y-m-d H:i:s");
  390. $shopAdmin->save();
  391. $shopAdminId = $shopAdmin->id ?? 0;
  392. //是否有切换门店的权限
  393. $switchShop = \biz\shop\classes\ShopAdminClass::hasSwitchShopRight($shopAdmin);
  394. $prefix = imgUtil::getPrefix();
  395. $avatar = isset($admin['avatar']) && !empty($admin['avatar']) ? $prefix . $admin['avatar'] : $prefix . '/retail/default-img.png';
  396. $admin['avatar'] = $avatar;
  397. $showDemo = 1;
  398. $remind = getenv('HD_UPDATE_REMIND') == false ? 0 : getenv('HD_UPDATE_REMIND');
  399. $hdUpgrading = getenv('HD_UPGRADING') == false ? 0 : getenv('HD_UPGRADING');
  400. if ($hdUpgrading == 1) {
  401. $allowShopAdminIdsStr = getenv('HD_UPGRADE_ALLOW_SHOP_ADMIN_IDS') ?: '';
  402. $allowShopAdminIds = !empty($allowShopAdminIdsStr) ? explode(',', $allowShopAdminIdsStr) : [];
  403. if (!in_array($shopAdminId, $allowShopAdminIds)) {
  404. util::fail('系统升级中,稍后再试');
  405. }
  406. }
  407. $apiHost = Yii::$app->params['hdHost'];
  408. $imgUploadApi = $apiHost . '/upload/save-file';
  409. //惠雅鲜花员工不能看收入情况
  410. if (in_array($adminId, [2366, 2812, 4004])) {
  411. $shopAdmin->super = 0;
  412. }
  413. //涉及几个登录的地方,需要同步修改,请搜索关键词uni_login_info
  414. util::success([
  415. 'token' => $token,
  416. 'admin' => $admin,
  417. 'shopId' => $currentShopId,
  418. 'shopAdminId' => $shopAdminId,
  419. 'pfShopId' => $pfShopId,
  420. 'onlyCg' => $onlyCg,
  421. 'shareLogo' => $shareLogo,
  422. 'switchShop' => $switchShop,
  423. 'showDemo' => $showDemo,
  424. 'imgUploadApi' => $imgUploadApi,
  425. //有小程序新版本提示更新
  426. 'update' => $remind,
  427. 'staff' => $shopAdmin,
  428. ]);
  429. }
  430. //准备授权 ssh 2019.11.19
  431. public function actionPrepare()
  432. {
  433. $get = Yii::$app->request->get();
  434. $url = isset($get['url']) && !empty($get['url']) ? $get['url'] : '';
  435. if (empty($url)) {
  436. util::fail('没有网址');
  437. }
  438. $account = httpUtil::getAccount($url);
  439. if (empty($account)) {
  440. util::fail('没有商家帐号');
  441. }
  442. $merchant = MerchantService::getById($account);
  443. if (empty($merchant)) {
  444. util::fail('商家无效');
  445. }
  446. /**
  447. * authScope 参数的说明
  448. * 1.用户通过公众号菜单打开网页,因为已经关注过了公众号,已经生成过用户信息,所以只要使用snsapi_base静默方式拿到openid就可以
  449. * 2.为了保证付款页的访问速度,暂时只要通过snsapi_base静默方式拿到openid先生成可以用的用户信息即可
  450. * 3.其它情况需要获取用户完整信息的,使用snsapi_userinfo让用户授权获取信息即可
  451. * 4.snsapi_base静默方式使用的场景更多,所以参数authScope默认使用snsapi_base
  452. */
  453. $authScope = isset($get['authScope']) ? $get['authScope'] : 'snsapi_base';
  454. $urlEncode = stringUtil::urlSafeB64Encode($url);
  455. //微信授权获取code ssh 2019.11.24
  456. $isOpen = 1;
  457. wxUtil::getCode($urlEncode, $merchant, $authScope, $isOpen);
  458. util::end();
  459. }
  460. //微信授权获取用户信息 ssh 2019.11.20
  461. public function actionGetUserInfo()
  462. {
  463. $get = Yii::$app->request->get();
  464. $code = isset($get['code']) ? $get['code'] : '';
  465. if (empty($code)) {
  466. util::fail('没有获取用户code');
  467. }
  468. if (isset($get['state']) && $get['state'] == 'authdeny') {
  469. util::fail('auth fail');
  470. }
  471. $urlEncode = $get['url'];
  472. $url = stringUtil::urlSafeBase64Decode($urlEncode);
  473. $account = httpUtil::getAccount($url);
  474. if (empty($account)) {
  475. util::stop('商店ID无效!!');
  476. }
  477. $merchant = xhMerchantService::getByAccount($account);
  478. if (empty($merchant)) {
  479. util::stop('商店无效');
  480. }
  481. $sjId = $merchant['id'];
  482. $authScope = isset($get['authScope']) ? $get['authScope'] : '';
  483. if (empty($authScope)) {
  484. util::stop('没有授权类型');
  485. }
  486. $data = wxUtil::getOpenId($code, $merchant, 1);
  487. if ($data === false) {
  488. //微信授权获取code ssh 2019.11.24
  489. wxUtil::getCode($urlEncode, $merchant, $authScope, 1);
  490. util::end();
  491. }
  492. $openId = $data['openid'];
  493. $access_token = $data['access_token'];
  494. $user = UserService::getByOpenId($openId);
  495. //用户来源
  496. $userSource = Yii::$app->dict->getValue('userSourceGetId', 'official');
  497. $source = $userSource['name'];
  498. if (empty($user)) {
  499. //$authScope 默认是 snsapi_base 公众号菜单打开网页(已经关注公众号,有完整信息)、打开付款页(有些客户只付款,没有后续可以不用登记完整信息),只需要获取openid
  500. $originalInfo = [];
  501. $originalInfo['openId'] = $openId;
  502. $originalInfo['sjId'] = $sjId;
  503. //没有关注公众号,需要获取用户完整信息的情况,则通过弹框授权
  504. if ($authScope == 'snsapi_userinfo') {
  505. $baseInfo = wxUtil::authGetUserInfo($openId, $access_token);
  506. $originalInfo = array_merge($baseInfo, $originalInfo);
  507. $originalInfo['isFull'] = 1;
  508. $originalInfo['unionId'] = $baseInfo['unionid'];
  509. $originalInfo['headImgUrl'] = $baseInfo['headimgurl'];
  510. $originalInfo['nickName'] = $baseInfo['nickName'];
  511. }
  512. $user = UserService::replaceUser($originalInfo, $source, $sjId);
  513. } else {
  514. if ($user['isFull'] == 0) {
  515. if ($authScope == 'snsapi_userinfo') {
  516. $baseInfo = wxUtil::authGetUserInfo($openId, $access_token);
  517. $originalInfo = $baseInfo;
  518. $originalInfo['isFull'] = 1;
  519. $originalInfo['unionId'] = $baseInfo['unionid'];
  520. $originalInfo['headImgUrl'] = $baseInfo['headimgurl'];
  521. $originalInfo['openId'] = $baseInfo['openid'];
  522. $originalInfo['nickName'] = $baseInfo['nickName'];
  523. $originalInfo['sjId'] = $sjId;
  524. $user = UserService::replaceUser($originalInfo, $source, $sjId);
  525. }
  526. }
  527. }
  528. //这个的基类没有设置统一的全局变量,这里进行设置一次
  529. $userId = $user['id'];
  530. $admin = AdminService::getByCondition(['userId' => $userId]);
  531. if (empty($admin)) {
  532. util::fail('您无法访问');
  533. }
  534. $adminId = $admin['id'];
  535. //获取token
  536. $token = jwt::getNewToken($adminId);
  537. $url = strpos($url, '?') === false ? $url . '?token=' . $token : $url . '&token=' . $token;
  538. $this->redirect($url);
  539. }
  540. //登陆并拿到token ssh 2019.11.23
  541. public function actionLogin()
  542. {
  543. $get = Yii::$app->request->get();
  544. $mobile = isset($get['mobile']) ? $get['mobile'] : 0;
  545. if (stringUtil::isMobile($mobile) == false) {
  546. util::fail('请填写正常的手机号');
  547. }
  548. $password = isset($get['password']) && !empty($get['password']) ? $get['password'] : '';
  549. if (empty($password)) {
  550. util::fail('请输入密码');
  551. }
  552. $admin = AdminService::getByCondition(['mobile' => $mobile]);
  553. if (empty($admin)) {
  554. util::fail('请先注册哦。');
  555. }
  556. if (password_verify($password, $admin['password']) == false) {
  557. util::fail('密码错误');
  558. }
  559. $adminId = $admin['id'];
  560. $openShop = $admin['openShop'] ?? 1;
  561. $currentShopId = $admin['currentShopId'] ?? 0;
  562. if (empty($currentShopId)) {
  563. if ($openShop == 2) {
  564. util::fail('审核中');
  565. }
  566. util::fail('请先注册');
  567. }
  568. $currentShop = ShopClass::getById($currentShopId, true);
  569. if (empty($currentShop)) {
  570. util::fail('没有找到门店39');
  571. }
  572. $pfShopId = $currentShop->pfShopId ?? 0;
  573. if (!empty($pfShopId)) {
  574. //util::fail('批发店请不要在零售端登录');
  575. }
  576. $sjId = $currentShop->sjId ?? 0;
  577. $mainId = $currentShop->mainId ?? 0;
  578. $shopAdmin = ShopAdminService::getByCondition(['adminId' => $adminId, 'mainId' => $mainId], true);
  579. if (empty($shopAdmin)) {
  580. util::fail('无法操作');
  581. }
  582. if ($shopAdmin->status == 0) {
  583. util::fail("您的账号已被冻结");
  584. }
  585. $token = jwt::getNewToken($adminId);
  586. $shopAdmin->lastLogin = date("Y-m-d H:i:s");
  587. $shopAdmin->save();
  588. $shopAdminId = $shopAdmin->id ?? 0;
  589. //是否有切换门店的权限
  590. $switchShop = \biz\shop\classes\ShopAdminClass::hasSwitchShopRight($shopAdmin);
  591. $prefix = imgUtil::getPrefix();
  592. $avatar = isset($admin['avatar']) && !empty($admin['avatar']) ? $prefix . $admin['avatar'] : $prefix . '/retail/default-img.png';
  593. $admin['avatar'] = $avatar;
  594. $hdUpgrading = getenv('HD_UPGRADING') == false ? 0 : getenv('HD_UPGRADING');
  595. if ($hdUpgrading == 1) {
  596. $allowShopAdminIdsStr = getenv('HD_UPGRADE_ALLOW_SHOP_ADMIN_IDS') ?: '';
  597. $allowShopAdminIds = !empty($allowShopAdminIdsStr) ? explode(',', $allowShopAdminIdsStr) : [];
  598. if (!in_array($shopAdminId, $allowShopAdminIds)) {
  599. util::fail('系统升级中,稍后再试');
  600. }
  601. }
  602. $apiHost = Yii::$app->params['hdHost'];
  603. $imgUploadApi = $apiHost . '/upload/save-file';
  604. util::success(['token' => $token, 'account' => $sjId, 'shopId' => $currentShopId, 'imgUploadApi' => $imgUploadApi, 'switchShop' => $switchShop,]);
  605. }
  606. /**
  607. * 静默获取小程序用户信息
  608. * 职责:通过微信小程序 code 换取 openid 和 session_key 并自动登录
  609. * 入参:GET 传参 code (微信临时登录凭证)
  610. * 返回:登录成功返回 token、用户信息、店铺 ID 等;失败返回空 token
  611. * 副作用:会更新管理员的最后登录时间,并将 session_key 写入 Redis 缓存
  612. */
  613. public function actionMiniInfo()
  614. {
  615. //花店平台
  616. Yii::$app->params['ptStyle'] = dict::getDict('ptStyle', 'hd');
  617. $code = Yii::$app->request->get('code', '');
  618. $wxMiniBase = WxOpenService::getWxMiniBase();
  619. $appId = $wxMiniBase['miniAppId'];
  620. $appSecret = $wxMiniBase['miniAppSecret'];
  621. if (empty($appSecret)) {
  622. Yii::info('没有找到小程序的密钥');
  623. //没有管理店铺不允许登录
  624. util::success(['token' => '']);
  625. }
  626. $url = "https://api.weixin.qq.com/sns/jscode2session?appid={$appId}&secret={$appSecret}&js_code={$code}&grant_type=authorization_code";
  627. $curl = new curl\Curl();
  628. $curl->setOption(CURLOPT_SSL_VERIFYPEER, false);
  629. // 复杂分支/关键逻辑:设置 cURL 连接和执行超时,并强制使用 IPv4,防止因微信接口卡顿或 DNS 解析慢拖垮 PHP-FPM 进程
  630. $curl->setOption(CURLOPT_CONNECTTIMEOUT, 2); // 连接超时限制为 2 秒,避免网络握手长时间卡死
  631. $curl->setOption(CURLOPT_TIMEOUT, 3); // 总执行时间限制为 3 秒,避免请求挂起时间过长
  632. $curl->setOption(CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); // 强制 IPv4 解析,防止 IPv6 解析超时重试
  633. $result = $curl->get($url);
  634. $arr = Json::decode($result);
  635. $sessionKey = isset($arr['session_key']) ? $arr['session_key'] : '';
  636. $openid = $arr['openid'] ?? '';
  637. $cacheKey = 'SHOP_MINI_SESSION_KEY_' . $openid;
  638. Yii::$app->redis->executeCommand('SET', [$cacheKey, $sessionKey]);
  639. if (empty($openid)) {
  640. Yii::info(json_encode($arr));
  641. //没有管理店铺不允许登录
  642. util::success(['token' => '', 'currentMiniOpenId' => $openid, 'sn' => 1]);
  643. }
  644. $admin = AdminService::getByCondition(['miniOpenId' => $openid]);
  645. if (empty($admin)) {
  646. //没有管理店铺不允许登录
  647. util::success(['token' => '', 'currentMiniOpenId' => $openid, 'sn' => 2]);
  648. }
  649. $adminId = $admin['id'];
  650. //切换账号,多个地方要同步修改,关键词 change_account
  651. // if (getenv('YII_ENV') == 'production') {
  652. // if ($adminId == 4) {
  653. // $adminId = 28276;
  654. // $adminId = 27522;
  655. // $admin = AdminClass::getById($adminId);
  656. // }
  657. // } else {
  658. // if ($adminId == 919) {
  659. // $adminId = 1109;
  660. // $admin = AdminClass::getById($adminId);
  661. // }
  662. // }
  663. $currentShopId = $admin['currentShopId'] ?? 0;
  664. if (empty($currentShopId)) {
  665. //没有管理店铺不允许登录
  666. util::success(['token' => '', 'currentMiniOpenId' => $openid, 'sn' => 3]);
  667. }
  668. $currentShop = ShopClass::getById($currentShopId, true);
  669. if (empty($currentShop)) {
  670. //没有管理店铺不允许登录
  671. util::success(['token' => '', 'currentMiniOpenId' => $openid, 'sn' => 4]);
  672. }
  673. $mainId = $currentShop->mainId ?? 0;
  674. $pfShopId = $currentShop->pfShopId ?? 0;
  675. $onlyCg = $currentShop->onlyCg ?? 1;
  676. $shareLogo = imgUtil::groupImg('buy_logo.jpg');
  677. if (isset($currentShop->shareLogo) && !empty($currentShop->shareLogo)) {
  678. $shareLogo = imgUtil::groupImg($currentShop->shareLogo);
  679. }
  680. $shopAdmin = ShopAdminClass::getByCondition(['mainId' => $mainId, 'adminId' => $adminId], true);
  681. if (empty($shopAdmin)) {
  682. //没有管理店铺不允许登录
  683. util::success(['token' => '', 'currentMiniOpenId' => $openid, 'sn' => 5]);
  684. }
  685. if (isset($shopAdmin->status) == false || $shopAdmin->status == 0) {
  686. //账号冻结不再自动登录
  687. util::success(['token' => '', 'currentMiniOpenId' => $openid, 'sn' => 6]);
  688. }
  689. $shopAdminId = $shopAdmin->id ?? 0;
  690. //是否有切换门店的权限
  691. $switchShop = \biz\shop\classes\ShopAdminClass::hasSwitchShopRight($shopAdmin);
  692. $prefix = imgUtil::getPrefix();
  693. $avatar = isset($admin['avatar']) && !empty($admin['avatar']) ? $prefix . $admin['avatar'] : $prefix . '/retail/default-img.png';
  694. $admin['avatar'] = $avatar;
  695. $token = jwt::getNewToken($adminId);
  696. $showDemo = 1;
  697. $remind = getenv('HD_UPDATE_REMIND') == false ? 0 : getenv('HD_UPDATE_REMIND');
  698. $hdUpgrading = getenv('HD_UPGRADING') == false ? 0 : getenv('HD_UPGRADING');
  699. if ($hdUpgrading == 1) {
  700. $allowShopAdminIdsStr = getenv('HD_UPGRADE_ALLOW_SHOP_ADMIN_IDS') ?: '';
  701. $allowShopAdminIds = !empty($allowShopAdminIdsStr) ? explode(',', $allowShopAdminIdsStr) : [];
  702. if (!in_array($shopAdminId, $allowShopAdminIds)) {
  703. util::fail('系统升级中,稍后再试');
  704. }
  705. }
  706. $apiHost = Yii::$app->params['hdHost'];
  707. $imgUploadApi = $apiHost . '/upload/save-file';
  708. //惠雅鲜花员工不能看收入情况
  709. if (in_array($adminId, [2366, 2812, 4004])) {
  710. $shopAdmin->super = 0;
  711. }
  712. //涉及几个登录的地方,需要同步修改,请搜索关键词uni_login_info
  713. util::success([
  714. 'token' => $token,
  715. 'admin' => $admin,
  716. 'shopId' => $currentShopId,
  717. 'shopAdminId' => $shopAdminId,
  718. 'switchShop' => $switchShop,
  719. 'pfShopId' => $pfShopId,
  720. 'onlyCg' => $onlyCg,
  721. 'shareLogo' => $shareLogo,
  722. 'showDemo' => $showDemo,
  723. 'imgUploadApi' => $imgUploadApi,
  724. //有小程序新版本提示更新
  725. 'update' => $remind,
  726. 'currentMiniOpenId' => $openid,
  727. 'staff' => $shopAdmin,
  728. ]);
  729. }
  730. //获取收款码的二维码图片 ssh 20210602
  731. public function actionGatheringImgUrl()
  732. {
  733. $id = Yii::$app->request->get('id', 0);
  734. $shop = ShopClass::getById($id, true);
  735. if (empty($shop)) {
  736. util::fail('没有找到门店40');
  737. }
  738. $sjId = $shop->sjId;
  739. $imgUrl = ShopClass::generateGatheringCode($sjId, $id);
  740. $fileResource = file_get_contents($imgUrl);
  741. header('Content-type: image/jpeg');
  742. echo $fileResource;
  743. }
  744. //最新版本 ssh 20220211
  745. public function actionGetApkVersion()
  746. {
  747. $version = getenv('HD_NEW_APK_VERSION') == false ? '1.0.0' : getenv('HD_NEW_APK_VERSION');
  748. $mustUpdate = getenv('HD_NEW_APK_VERSION_MUST_UPDATE') == false ? 0 : getenv('HD_NEW_APK_VERSION_MUST_UPDATE');
  749. util::success(['version' => $version, 'mustUpdate' => $mustUpdate]);
  750. }
  751. //收银台apk更新 ssh 20220310
  752. public function actionGetPadApkVersion()
  753. {
  754. $version = getenv('HD_NEW_PAD_APK_VERSION') == false ? '1.0.0' : getenv('HD_NEW_PAD_APK_VERSION');
  755. $mustUpdate = getenv('HD_NEW_PAD_APK_VERSION_MUST_UPDATE') == false ? 0 : getenv('HD_NEW_PAD_APK_VERSION_MUST_UPDATE');
  756. util::success(['version' => $version, 'mustUpdate' => $mustUpdate]);
  757. }
  758. //注册使用协议 ssh 20220327
  759. public function actionRegister()
  760. {
  761. $html = AgreementClass::hzgRegister(1);
  762. util::success(['html' => $html]);
  763. }
  764. //隐私政策 ssh 20220327
  765. public function actionPrivacy()
  766. {
  767. $html = AgreementClass::hzgPrivacy(1);
  768. util::success(['html' => $html]);
  769. }
  770. /**
  771. * 【用途】发送登录短信验证码
  772. * 【为什么】供短信登录功能获取验证码,并包含防刷安全限制(单手机号60秒锁、每日上限5条)
  773. */
  774. public function actionSendLoginSms()
  775. {
  776. $getParams = Yii::$app->request->get();
  777. $postParams = Yii::$app->request->post();
  778. $allParams = array_merge($getParams, $postParams);
  779. $mobile = $allParams['mobile'] ?? '';
  780. if (!stringUtil::isMobile($mobile)) {
  781. util::fail('请填写正确手机号');
  782. }
  783. // 1. 安全检查:单手机号 60 秒防刷
  784. $lockKey = 'LOGIN_SMS_LOCK_' . $mobile;
  785. if (Yii::$app->redis->executeCommand('GET', [$lockKey])) {
  786. util::fail('发送过于频繁,请稍后再试');
  787. }
  788. // 2. 安全检查:单手机号每日上限 5 条
  789. $dayKey = 'LOGIN_SMS_COUNT_' . date('Ymd') . '_' . $mobile;
  790. $sendCount = (int)Yii::$app->redis->executeCommand('GET', [$dayKey]);
  791. if ($sendCount >= 5) {
  792. util::fail('该手机号今日获取验证码已达上限');
  793. }
  794. // 3. 生成 6 位随机验证码并保存至 Redis(有效期 5 分钟)
  795. $code = (string)rand(100000, 999999);
  796. $codeCacheKey = 'LOGIN_SMS_CODE_' . $mobile;
  797. Yii::$app->redis->executeCommand('SETEX', [$codeCacheKey, 300, $code]);
  798. // 4. 调用系统自带的限流发送组件 (内置了 IP 60秒锁和每日15条限制)
  799. $minute = 5;
  800. sms::send($mobile . ',' . $code . ',' . $minute, '登录验证码:{$var},{$var}分钟内有效');
  801. // 5. 写入单手机号限制锁
  802. Yii::$app->redis->executeCommand('SETEX', [$lockKey, 60, '1']);
  803. Yii::$app->redis->executeCommand('SETEX', [$dayKey, 86400, $sendCount + 1]);
  804. util::complete('验证码发送成功');
  805. }
  806. /**
  807. * 【用途】短信验证码登录
  808. * 【为什么】提供免密码快捷登录方式,验证通过后自动签发 JWT Token 并返回商家后台所需的所有初始化数据
  809. */
  810. public function actionSmsLogin()
  811. {
  812. $getParams = Yii::$app->request->get();
  813. $postParams = Yii::$app->request->post();
  814. $allParams = array_merge($getParams, $postParams);
  815. $mobile = $allParams['mobile'] ?? '';
  816. $code = $allParams['code'] ?? '';
  817. if (empty($mobile) || empty($code)) {
  818. util::fail('手机号和验证码不能为空');
  819. }
  820. if (!stringUtil::isMobile($mobile)) {
  821. util::fail('请填写正确手机号');
  822. }
  823. // 1. 校验验证码
  824. $codeCacheKey = 'LOGIN_SMS_CODE_' . $mobile;
  825. $savedCode = Yii::$app->redis->executeCommand('GET', [$codeCacheKey]);
  826. if (empty($savedCode) || $savedCode !== $code) {
  827. util::fail('验证码错误或已过期');
  828. }
  829. // 2. 验证通过,立即销毁验证码以确保一次性使用
  830. Yii::$app->redis->executeCommand('DEL', [$codeCacheKey]);
  831. // 3. 查找用户并执行登录
  832. $admin = AdminService::getByCondition(['mobile' => $mobile]);
  833. if (empty($admin)) {
  834. util::fail('请先注册哦...');
  835. }
  836. $openShop = $admin['openShop'] ?? 1;
  837. $currentShopId = $admin['currentShopId'] ?? 0;
  838. if (empty($currentShopId)) {
  839. if ($openShop == 2) {
  840. util::fail('审核中');
  841. }
  842. util::fail('请先注册');
  843. }
  844. $currentShop = \bizHd\shop\classes\ShopClass::getById($currentShopId, true);
  845. if (empty($currentShop)) {
  846. util::fail('没有找到门店37');
  847. }
  848. $mainId = $currentShop->mainId ?? 0;
  849. $pfShopId = $currentShop->pfShopId ?? 0;
  850. $onlyCg = $currentShop->onlyCg ?? 1;
  851. $shopExt = ShopExtClass::getByCondition(['shopId' => $currentShop->id], false, false, 'reachVip');
  852. $shareLogo = imgUtil::groupImg('buy_logo.jpg');
  853. if (isset($currentShop->shareLogo) && !empty($currentShop->shareLogo)) {
  854. $shareLogo = imgUtil::groupImg($currentShop->shareLogo);
  855. }
  856. $adminId = $admin['id'];
  857. $shopAdmin = ShopAdminService::getByCondition(['mainId' => $mainId, 'adminId' => $adminId], true);
  858. if (empty($shopAdmin)) {
  859. util::fail('无法操作');
  860. }
  861. if ($shopAdmin->status == 0) {
  862. util::fail("您的账号已被冻结");
  863. }
  864. if ($shopAdmin->delStatus == 1) {
  865. util::fail("您的账号已删除");
  866. }
  867. $token = jwt::getNewToken($adminId);
  868. $shopAdmin->lastLogin = date("Y-m-d H:i:s");
  869. $shopAdmin->save();
  870. $shopAdminId = $shopAdmin->id ?? 0;
  871. //是否有切换门店的权限
  872. $switchShop = \biz\shop\classes\ShopAdminClass::hasSwitchShopRight($shopAdmin);
  873. $prefix = imgUtil::getPrefix();
  874. $avatar = isset($admin['avatar']) && !empty($admin['avatar']) ? $prefix . $admin['avatar'] : $prefix . '/retail/default-img.png';
  875. $admin['avatar'] = $avatar;
  876. $showDemo = 1;
  877. $remind = getenv('HD_UPDATE_REMIND') == false ? 0 : getenv('HD_UPDATE_REMIND');
  878. $hdUpgrading = getenv('HD_UPGRADING') == false ? 0 : getenv('HD_UPGRADING');
  879. if ($hdUpgrading == 1) {
  880. $allowShopAdminIdsStr = getenv('HD_UPGRADE_ALLOW_SHOP_ADMIN_IDS') ?: '';
  881. $allowShopAdminIds = !empty($allowShopAdminIdsStr) ? explode(',', $allowShopAdminIdsStr) : [];
  882. if (!in_array($shopAdminId, $allowShopAdminIds)) {
  883. util::fail('系统升级中,稍后再试');
  884. }
  885. }
  886. $apiHost = Yii::$app->params['hdHost'];
  887. $imgUploadApi = $apiHost . '/upload/save-file';
  888. //惠雅鲜花员工不能看收入情况
  889. if (in_array($adminId, [2366, 2812, 4004])) {
  890. $shopAdmin->super = 0;
  891. }
  892. //充值送钱有没设置,没有设置则进行设置,临时方法,后面需要去掉,有多处,关键词recharge_sq_init ssh 20251229
  893. RechargeSqClass::initData($currentShop);
  894. //会员等级有没设置,没有设置则进行设置,临时方法,后面需要去掉,有多处,关键词member_level_init ssh 20251229
  895. MemberLevelClass::initData($currentShop);
  896. //把设备状态更新为登录
  897. if (isset($allParams['deviceId']) && $allParams['deviceId'] != '') {
  898. $device = \bizHd\device\classes\HdDeviceClass::getByCondition(['shopId' => $currentShopId, 'deviceId' => $allParams['deviceId']], true);
  899. if ($device) {
  900. $device->status = 1;
  901. $device->save();
  902. }
  903. }
  904. unset($admin['password']); //返回的用户数据删除密码字段,防止密码加密方法被反查
  905. //涉及几个登录的地方,需要同步修改,请搜索关键词uni_login_info
  906. util::success([
  907. 'token' => $token,
  908. 'admin' => $admin,
  909. 'shopId' => $currentShopId,
  910. 'shopAdminId' => $shopAdminId,
  911. 'switchShop' => $switchShop,
  912. 'pfShopId' => $pfShopId,
  913. 'onlyCg' => $onlyCg,
  914. 'shareLogo' => $shareLogo,
  915. 'imgUploadApi' => $imgUploadApi,
  916. 'showDemo' => $showDemo,
  917. //有小程序新版本提示更新
  918. 'update' => $remind,
  919. 'staff' => $shopAdmin,
  920. 'reachVip' => $shopExt['reachVip'] //用于判断是否开启vip
  921. ]);
  922. }
  923. }