AuthController.php 41 KB

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