AuthController.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. <?php
  2. namespace hd\controllers;
  3. use biz\admin\classes\AdminClass;
  4. use biz\shop\classes\ShopClass;
  5. use bizHd\admin\classes\ShopAdminClass;
  6. use bizHd\admin\services\ShopAdminService;
  7. use bizHd\admin\services\AdminService;
  8. use bizHd\user\classes\UserClass;
  9. use bizHd\wx\services\WxOpenService;
  10. use common\components\dict;
  11. use common\components\httpUtil;
  12. use common\components\imgUtil;
  13. use common\components\jwt;
  14. use common\components\util;
  15. use Yii;
  16. use common\components\stringUtil;
  17. use biz\sj\services\MerchantService;
  18. use bizHd\user\services\UserService;
  19. use common\services\xhMerchantService;
  20. use common\components\wxUtil;
  21. use linslin\yii2\curl;
  22. use yii\helpers\Json;
  23. /**
  24. * 用户登陆
  25. */
  26. class AuthController extends PublicController
  27. {
  28. //微信手机号一键登录 ssh 20210121
  29. public function actionWxMobileLogin()
  30. {
  31. $post = Yii::$app->request->post();
  32. $iv = $post['iv'];
  33. $encryptedData = $post['encryptedData'];
  34. $merchant = WxOpenService::getWxMiniBase();
  35. $appId = $merchant['miniAppId'];
  36. $miniOpenId = $post['miniOpenId'] ?? '';
  37. if (empty($miniOpenId)) {
  38. util::fail('登录失败...');
  39. }
  40. $cacheKey = 'SHOP_MINI_SESSION_KEY_' . $miniOpenId;
  41. $sessionKey = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
  42. if (empty($sessionKey)) {
  43. util::fail('登录失败了哦');
  44. }
  45. $wxMiniSecret = Yii::getAlias("@vendor/weixinMiniSecret");
  46. require_once($wxMiniSecret . '/wxBizDataCrypt.php');
  47. $pc = new \WXBizDataCrypt($appId, $sessionKey);
  48. $errCode = $pc->decryptData($encryptedData, $iv, $result);
  49. if ($errCode != 0) {
  50. util::fail('登录失败..');
  51. }
  52. $arr = Json::decode($result);
  53. $phoneNumber = isset($arr['purePhoneNumber']) ? $arr['purePhoneNumber'] : '';
  54. if (empty($phoneNumber)) {
  55. util::fail('登录失败了');
  56. }
  57. $admin = AdminService::getByCondition(['mobile' => $phoneNumber, 'style' => AdminClass::STYLE_HD]);
  58. if (empty($admin)) {
  59. util::fail('请先注册');
  60. }
  61. $openShop = $admin['openShop'] ?? 1;
  62. $currentShopId = $admin['currentShopId'] ?? 0;
  63. if (empty($currentShopId)) {
  64. if ($openShop == 2) {
  65. util::fail('审核中');
  66. }
  67. util::fail('请先注册');
  68. }
  69. $currentShop = ShopClass::getById($currentShopId, true);
  70. if (empty($currentShop)) {
  71. util::fail('没有找到门店');
  72. }
  73. $mainId = $currentShop->mainId ?? 0;
  74. $adminId = $admin['id'];
  75. $shopAdmin = ShopAdminService::getByCondition(['adminId' => $adminId, 'mainId' => $mainId], true);
  76. if (empty($shopAdmin)) {
  77. util::fail('没有权限操作');
  78. }
  79. if ($shopAdmin->status == 0) {
  80. util::fail("您的账号已冻结");
  81. }
  82. $shopId = $shopAdmin->shopId ?? 0;
  83. if (empty($shopId)) {
  84. util::fail('您不是管理员');
  85. }
  86. $token = jwt::getNewToken($adminId);
  87. $shopAdmin->lastLogin = date("Y-m-d H:i:s");
  88. $shopAdmin->save();
  89. $shopAdminId = $shopAdmin->id ?? 0;
  90. //是否有切换门店的权限
  91. $switchShop = \biz\shop\classes\ShopAdminClass::hasSwitchShopRight($shopAdmin);
  92. $prefix = imgUtil::getPrefix();
  93. $avatar = isset($admin['avatar']) && !empty($admin['avatar']) ? $prefix . $admin['avatar'] : $prefix . '/retail/default-img.png';
  94. $admin['avatar'] = $avatar;
  95. $showDemo = 1;
  96. $remind = getenv('HD_UPDATE_REMIND') == false ? 0 : getenv('HD_UPDATE_REMIND');
  97. $hdUpgrading = getenv('HD_UPGRADING') == false ? 0 : getenv('HD_UPGRADING');
  98. if ($hdUpgrading == 1) {
  99. util::fail('系统升级中,稍后再试');
  100. }
  101. $apiHost = Yii::$app->params['hdHost'];
  102. $imgUploadApi = $apiHost . '/upload/save-file';
  103. //涉及几个登录的地方,需要同步修改,请搜索关键词uni_login_info
  104. util::success([
  105. 'token' => $token,
  106. 'admin' => $admin,
  107. 'shopId' => $currentShopId,
  108. 'shopAdminId' => $shopAdminId,
  109. 'switchShop' => $switchShop,
  110. 'showDemo' => $showDemo,
  111. 'imgUploadApi' => $imgUploadApi,
  112. //有小程序新版本提示更新
  113. 'update' => $remind,
  114. ]);
  115. }
  116. //app登陆 ssh 20211219
  117. public function actionAppLogin()
  118. {
  119. $get = Yii::$app->request->get();
  120. $mobile = isset($get['mobile']) ? $get['mobile'] : 0;
  121. if (stringUtil::isMobile($mobile) == false) {
  122. util::fail('请填写正确手机号');
  123. }
  124. $password = isset($get['password']) && !empty($get['password']) ? $get['password'] : '';
  125. if (empty($password)) {
  126. util::fail('请输入密码');
  127. }
  128. $admin = AdminService::getByCondition(['mobile' => $mobile, 'style' => AdminClass::STYLE_HD]);
  129. if (password_verify($password, $admin['password']) == false) {
  130. util::fail('密码错误');
  131. }
  132. $openShop = $admin['openShop'] ?? 1;
  133. $currentShopId = $admin['currentShopId'] ?? 0;
  134. if (empty($currentShopId)) {
  135. if ($openShop == 2) {
  136. util::fail('审核中');
  137. }
  138. util::fail('请先注册');
  139. }
  140. $adminId = $admin['id'];
  141. $shopAdmin = ShopAdminService::getByCondition(['adminId' => $adminId, 'shopId' => $currentShopId, 'delStatus' => 0], true);
  142. if (empty($shopAdmin)) {
  143. util::fail('没有权限操作');
  144. }
  145. if ($shopAdmin->status == 0) {
  146. util::fail("您的账号已冻结");
  147. }
  148. $shopId = $shopAdmin->shopId ?? 0;
  149. if (empty($shopId)) {
  150. util::fail('您不是管理员');
  151. }
  152. $token = jwt::getNewToken($adminId);
  153. $shopAdmin->lastLogin = date("Y-m-d H:i:s");
  154. $shopAdmin->save();
  155. $shopAdminId = $shopAdmin->id ?? 0;
  156. //是否有切换门店的权限
  157. $switchShop = \biz\shop\classes\ShopAdminClass::hasSwitchShopRight($shopAdmin);
  158. $prefix = imgUtil::getPrefix();
  159. $avatar = isset($admin['avatar']) && !empty($admin['avatar']) ? $prefix . $admin['avatar'] : $prefix . '/retail/default-img.png';
  160. $admin['avatar'] = $avatar;
  161. $showDemo = 1;
  162. $remind = getenv('HD_UPDATE_REMIND') == false ? 0 : getenv('HD_UPDATE_REMIND');
  163. $hdUpgrading = getenv('HD_UPGRADING') == false ? 0 : getenv('HD_UPGRADING');
  164. if ($hdUpgrading == 1) {
  165. util::fail('系统升级中,稍后再试');
  166. }
  167. $apiHost = Yii::$app->params['hdHost'];
  168. $imgUploadApi = $apiHost . '/upload/save-file';
  169. //涉及几个登录的地方,需要同步修改,请搜索关键词uni_login_info
  170. util::success([
  171. 'token' => $token,
  172. 'admin' => $admin,
  173. 'shopId' => $currentShopId,
  174. 'shopAdminId' => $shopAdminId,
  175. 'switchShop' => $switchShop,
  176. 'imgUploadApi' => $imgUploadApi,
  177. 'showDemo' => $showDemo,
  178. //有小程序新版本提示更新
  179. 'update' => $remind,
  180. ]);
  181. }
  182. //本机号码一键登录 ssh 20210117
  183. public function actionPhoneLogin()
  184. {
  185. $get = Yii::$app->request->get();
  186. $access_token = $get['access_token'] ?? '';
  187. $openid = $get['openid'] ?? '';
  188. if (empty($access_token) || empty($openid)) {
  189. util::fail('参数错误');
  190. }
  191. //密钥,需要和uniCloud里的一致
  192. $secret = 'XHB2021198819640123';
  193. $params = ['access_token' => $access_token, 'openid' => $openid];
  194. $stringSignTemp = '';
  195. foreach ($params as $k => $v) {
  196. $stringSignTemp .= $k . '=' . $v . '&';
  197. }
  198. $stringSignTemp = rtrim($stringSignTemp, '&');
  199. $sign = hash_hmac('sha256', $stringSignTemp, $secret);
  200. $url = Yii::$app->params['hdUniCloudHost'] . "/getMobileNumber?access_token=" . $access_token . "&sign=" . $sign . "&" . $stringSignTemp;
  201. $curl = new curl\Curl();
  202. $respond = $curl->get($url);
  203. Yii::info($respond);
  204. $result = json_decode($respond, true);
  205. if (isset($result['code']) == false || $result['code'] != 1) {
  206. util::fail('获取手机号失败');
  207. }
  208. $phoneNumber = $result['data']['phoneNumber'] ?? '';
  209. if (empty($phoneNumber)) {
  210. util::fail('没有获取到手机号');
  211. }
  212. $admin = AdminService::getByCondition(['mobile' => $phoneNumber, 'style' => AdminClass::STYLE_HD]);
  213. if (empty($admin)) {
  214. util::fail('请先注册');
  215. }
  216. $openShop = $admin['openShop'] ?? 1;
  217. $currentShopId = $admin['currentShopId'] ?? 0;
  218. if (empty($currentShopId)) {
  219. if ($openShop == 2) {
  220. util::fail('审核中');
  221. }
  222. util::fail('请先注册');
  223. }
  224. $adminId = $admin['id'];
  225. $shopAdmin = ShopAdminService::getByCondition(['adminId' => $adminId, 'shopId' => $currentShopId, 'delStatus' => 0], true);
  226. if (empty($shopAdmin)) {
  227. util::fail('没有权限操作');
  228. }
  229. if ($shopAdmin->status == 0) {
  230. util::fail("您的账号已冻结");
  231. }
  232. $shopId = $shopAdmin->shopId ?? 0;
  233. if (empty($shopId)) {
  234. util::fail('您不是管理员');
  235. }
  236. $token = jwt::getNewToken($adminId);
  237. $shopAdmin->lastLogin = date("Y-m-d H:i:s");
  238. $shopAdmin->save();
  239. $shopAdminId = $shopAdmin->id ?? 0;
  240. //是否有切换门店的权限
  241. $switchShop = \biz\shop\classes\ShopAdminClass::hasSwitchShopRight($shopAdmin);
  242. $prefix = imgUtil::getPrefix();
  243. $avatar = isset($admin['avatar']) && !empty($admin['avatar']) ? $prefix . $admin['avatar'] : $prefix . '/retail/default-img.png';
  244. $admin['avatar'] = $avatar;
  245. $showDemo = 1;
  246. $remind = getenv('HD_UPDATE_REMIND') == false ? 0 : getenv('HD_UPDATE_REMIND');
  247. $hdUpgrading = getenv('HD_UPGRADING') == false ? 0 : getenv('HD_UPGRADING');
  248. if ($hdUpgrading == 1) {
  249. util::fail('系统升级中,稍后再试');
  250. }
  251. $apiHost = Yii::$app->params['hdHost'];
  252. $imgUploadApi = $apiHost . '/upload/save-file';
  253. //涉及几个登录的地方,需要同步修改,请搜索关键词uni_login_info
  254. util::success([
  255. 'token' => $token,
  256. 'admin' => $admin,
  257. 'shopId' => $currentShopId,
  258. 'shopAdminId' => $shopAdminId,
  259. 'switchShop' => $switchShop,
  260. 'showDemo' => $showDemo,
  261. 'imgUploadApi' => $imgUploadApi,
  262. //有小程序新版本提示更新
  263. 'update' => $remind,
  264. ]);
  265. }
  266. //准备授权 ssh 2019.11.19
  267. public function actionPrepare()
  268. {
  269. $get = Yii::$app->request->get();
  270. $url = isset($get['url']) && !empty($get['url']) ? $get['url'] : '';
  271. if (empty($url)) {
  272. util::fail('没有网址');
  273. }
  274. $account = httpUtil::getAccount($url);
  275. if (empty($account)) {
  276. util::fail('没有商家帐号');
  277. }
  278. $merchant = MerchantService::getById($account);
  279. if (empty($merchant)) {
  280. util::fail('商家无效');
  281. }
  282. /**
  283. * authScope 参数的说明
  284. * 1.用户通过公众号菜单打开网页,因为已经关注过了公众号,已经生成过用户信息,所以只要使用snsapi_base静默方式拿到openid就可以
  285. * 2.为了保证付款页的访问速度,暂时只要通过snsapi_base静默方式拿到openid先生成可以用的用户信息即可
  286. * 3.其它情况需要获取用户完整信息的,使用snsapi_userinfo让用户授权获取信息即可
  287. * 4.snsapi_base静默方式使用的场景更多,所以参数authScope默认使用snsapi_base
  288. */
  289. $authScope = isset($get['authScope']) ? $get['authScope'] : 'snsapi_base';
  290. $urlEncode = stringUtil::urlSafeB64Encode($url);
  291. //微信授权获取code ssh 2019.11.24
  292. $isOpen = 1;
  293. wxUtil::getCode($urlEncode, $merchant, $authScope, $isOpen);
  294. util::end();
  295. }
  296. //微信授权获取用户信息 ssh 2019.11.20
  297. public function actionGetUserInfo()
  298. {
  299. $get = Yii::$app->request->get();
  300. $code = isset($get['code']) ? $get['code'] : '';
  301. if (empty($code)) {
  302. util::fail('没有获取用户code');
  303. }
  304. if (isset($get['state']) && $get['state'] == 'authdeny') {
  305. util::fail('auth fail');
  306. }
  307. $urlEncode = $get['url'];
  308. $url = stringUtil::urlSafeBase64Decode($urlEncode);
  309. $account = httpUtil::getAccount($url);
  310. if (empty($account)) {
  311. util::stop('商店ID无效!!');
  312. }
  313. $merchant = xhMerchantService::getByAccount($account);
  314. if (empty($merchant)) {
  315. util::stop('商店无效');
  316. }
  317. $sjId = $merchant['id'];
  318. $authScope = isset($get['authScope']) ? $get['authScope'] : '';
  319. if (empty($authScope)) {
  320. util::stop('没有授权类型');
  321. }
  322. $data = wxUtil::getOpenId($code, $merchant, 1);
  323. if ($data === false) {
  324. //微信授权获取code ssh 2019.11.24
  325. wxUtil::getCode($urlEncode, $merchant, $authScope, 1);
  326. util::end();
  327. }
  328. $openId = $data['openid'];
  329. $access_token = $data['access_token'];
  330. $user = UserService::getByOpenId($openId);
  331. //用户来源
  332. $userSource = Yii::$app->dict->getValue('userSourceGetId', 'official');
  333. $source = $userSource['name'];
  334. if (empty($user)) {
  335. //$authScope 默认是 snsapi_base 公众号菜单打开网页(已经关注公众号,有完整信息)、打开付款页(有些客户只付款,没有后续可以不用登记完整信息),只需要获取openid
  336. $originalInfo = [];
  337. $originalInfo['openId'] = $openId;
  338. $originalInfo['sjId'] = $sjId;
  339. //没有关注公众号,需要获取用户完整信息的情况,则通过弹框授权
  340. if ($authScope == 'snsapi_userinfo') {
  341. $baseInfo = wxUtil::authGetUserInfo($openId, $access_token);
  342. $originalInfo = array_merge($baseInfo, $originalInfo);
  343. $originalInfo['isFull'] = 1;
  344. $originalInfo['unionId'] = $baseInfo['unionid'];
  345. $originalInfo['headImgUrl'] = $baseInfo['headimgurl'];
  346. $originalInfo['nickName'] = $baseInfo['nickName'];
  347. }
  348. $user = UserService::replaceUser($originalInfo, $source, $sjId);
  349. } else {
  350. if ($user['isFull'] == 0) {
  351. if ($authScope == 'snsapi_userinfo') {
  352. $baseInfo = wxUtil::authGetUserInfo($openId, $access_token);
  353. $originalInfo = $baseInfo;
  354. $originalInfo['isFull'] = 1;
  355. $originalInfo['unionId'] = $baseInfo['unionid'];
  356. $originalInfo['headImgUrl'] = $baseInfo['headimgurl'];
  357. $originalInfo['openId'] = $baseInfo['openid'];
  358. $originalInfo['nickName'] = $baseInfo['nickName'];
  359. $originalInfo['sjId'] = $sjId;
  360. $user = UserService::replaceUser($originalInfo, $source, $sjId);
  361. }
  362. }
  363. }
  364. //这个的基类没有设置统一的全局变量,这里进行设置一次
  365. $userId = $user['id'];
  366. $admin = AdminService::getByCondition(['userId' => $userId]);
  367. if (empty($admin)) {
  368. util::fail('您没有权限访问');
  369. }
  370. $adminId = $admin['id'];
  371. //获取token
  372. $token = jwt::getNewToken($adminId);
  373. $url = strpos($url, '?') === false ? $url . '?token=' . $token : $url . '&token=' . $token;
  374. $this->redirect($url);
  375. }
  376. //登陆并拿到token ssh 2019.11.23
  377. public function actionLogin()
  378. {
  379. $get = Yii::$app->request->get();
  380. $mobile = isset($get['mobile']) ? $get['mobile'] : 0;
  381. if (stringUtil::isMobile($mobile) == false) {
  382. util::fail('请填写正常的手机号');
  383. }
  384. $password = isset($get['password']) && !empty($get['password']) ? $get['password'] : '';
  385. if (empty($password)) {
  386. util::fail('请输入密码');
  387. }
  388. $admin = AdminService::getByCondition(['mobile' => $mobile, 'style' => AdminClass::STYLE_HD]);
  389. if (password_verify($password, $admin['password']) == false) {
  390. util::fail('密码错误');
  391. }
  392. $adminId = $admin['id'];
  393. $shopAdmin = ShopAdminService::getByCondition(['adminId' => $adminId, 'delStatus' => 0]);
  394. $sjId = isset($shopAdmin['sjId']) ? $shopAdmin['sjId'] : 0;
  395. $shopId = $shopAdmin['shopId'] ?? 0;
  396. if (empty($shopId)) {
  397. util::fail('您不是管理员');
  398. }
  399. //获取token
  400. $token = jwt::getNewToken($adminId);
  401. util::success(['token' => $token, 'account' => $sjId, 'shopId' => $shopId]);
  402. }
  403. //静默获取小程序用户信息
  404. public function actionMiniInfo()
  405. {
  406. //花店平台
  407. Yii::$app->params['ptStyle'] = dict::getDict('ptStyle', 'hd');
  408. $code = Yii::$app->request->get('code', '');
  409. $wxMiniBase = WxOpenService::getWxMiniBase();
  410. $appId = $wxMiniBase['miniAppId'];
  411. $appSecret = $wxMiniBase['miniAppSecret'];
  412. if (empty($appSecret)) {
  413. Yii::info('没有找到小程序的密钥');
  414. //没有管理店铺不允许登录
  415. util::success(['token' => '']);
  416. }
  417. $url = "https://api.weixin.qq.com/sns/jscode2session?appid={$appId}&secret={$appSecret}&js_code={$code}&grant_type=authorization_code";
  418. $curl = new curl\Curl();
  419. $curl->setOption(CURLOPT_SSL_VERIFYPEER, false);
  420. $result = $curl->get($url);
  421. $arr = Json::decode($result);
  422. $sessionKey = isset($arr['session_key']) ? $arr['session_key'] : '';
  423. $openid = $arr['openid'] ?? '';
  424. $cacheKey = 'SHOP_MINI_SESSION_KEY_' . $openid;
  425. Yii::$app->redis->executeCommand('SET', [$cacheKey, $sessionKey]);
  426. if (empty($openid)) {
  427. Yii::info(json_encode($arr));
  428. //没有管理店铺不允许登录
  429. util::success(['token' => '', 'currentMiniOpenId' => $openid]);
  430. }
  431. $admin = AdminService::getByCondition(['miniOpenId' => $openid]);
  432. if (empty($admin)) {
  433. //没有管理店铺不允许登录
  434. util::success(['token' => '', 'currentMiniOpenId' => $openid]);
  435. }
  436. $adminId = $admin['id'];
  437. $currentShopId = $admin['currentShopId'] ?? 0;
  438. if (empty($currentShopId)) {
  439. //没有管理店铺不允许登录
  440. util::success(['token' => '', 'currentMiniOpenId' => $openid]);
  441. }
  442. $currentShop = ShopClass::getById($currentShopId, true);
  443. if (empty($currentShop)) {
  444. //没有管理店铺不允许登录
  445. util::success(['token' => '', 'currentMiniOpenId' => $openid]);
  446. }
  447. $mainId = $currentShop->mainId ?? 0;
  448. $shopAdmin = ShopAdminClass::getByCondition(['mainId' => $mainId, 'adminId' => $adminId], true);
  449. if (empty($shopAdmin)) {
  450. //没有管理店铺不允许登录
  451. util::success(['token' => '', 'currentMiniOpenId' => $openid]);
  452. }
  453. if (isset($shopAdmin->status) == false || $shopAdmin->status == 0) {
  454. //账号冻结不再自动登录
  455. util::success(['token' => '', 'currentMiniOpenId' => $openid]);
  456. }
  457. $shopAdmin->lastLogin = date("Y-m-d H:i:s");
  458. $shopAdmin->save();
  459. $shopAdminId = $shopAdmin->id ?? 0;
  460. //是否有切换门店的权限
  461. $switchShop = \biz\shop\classes\ShopAdminClass::hasSwitchShopRight($shopAdmin);
  462. $prefix = imgUtil::getPrefix();
  463. $avatar = isset($admin['avatar']) && !empty($admin['avatar']) ? $prefix . $admin['avatar'] : $prefix . '/retail/default-img.png';
  464. $admin['avatar'] = $avatar;
  465. $token = jwt::getNewToken($adminId);
  466. $showDemo = 1;
  467. $remind = getenv('HD_UPDATE_REMIND') == false ? 0 : getenv('HD_UPDATE_REMIND');
  468. $hdUpgrading = getenv('HD_UPGRADING') == false ? 0 : getenv('HD_UPGRADING');
  469. if ($hdUpgrading == 1) {
  470. util::fail('系统升级中,稍后再试');
  471. }
  472. $apiHost = Yii::$app->params['hdHost'];
  473. $imgUploadApi = $apiHost . '/upload/save-file';
  474. //涉及几个登录的地方,需要同步修改,请搜索关键词uni_login_info
  475. util::success([
  476. 'token' => $token,
  477. 'admin' => $admin,
  478. 'shopId' => $currentShopId,
  479. 'shopAdminId' => $shopAdminId,
  480. 'switchShop' => $switchShop,
  481. 'showDemo' => $showDemo,
  482. 'imgUploadApi' => $imgUploadApi,
  483. //有小程序新版本提示更新
  484. 'update' => $remind,
  485. ]);
  486. }
  487. //获取收款码的二维码图片 ssh 20210602
  488. public function actionGatheringImgUrl()
  489. {
  490. $id = Yii::$app->request->get('id', 0);
  491. $shop = ShopClass::getById($id, true);
  492. if (empty($shop)) {
  493. util::fail('没有找到门店');
  494. }
  495. $sjId = $shop->sjId;
  496. $imgUrl = ShopClass::generateGatheringCode($sjId, $id);
  497. $fileResource = file_get_contents($imgUrl);
  498. header('Content-type: image/jpeg');
  499. echo $fileResource;
  500. }
  501. //最新版本 ssh 20220211
  502. public function actionGetApkVersion()
  503. {
  504. $version = getenv('HD_NEW_APK_VERSION') == false ? '1.0.0' : getenv('HD_NEW_APK_VERSION');
  505. $mustUpdate = getenv('HD_NEW_APK_VERSION_MUST_UPDATE') == false ? 0 : getenv('HD_NEW_APK_VERSION_MUST_UPDATE');
  506. util::success(['version' => $version, 'mustUpdate' => $mustUpdate]);
  507. }
  508. //收银台apk更新 ssh 20220310
  509. public function actionGetPadApkVersion()
  510. {
  511. $version = getenv('HD_NEW_PAD_APK_VERSION') == false ? '1.0.0' : getenv('HD_NEW_PAD_APK_VERSION');
  512. $mustUpdate = getenv('HD_NEW_PAD_APK_VERSION_MUST_UPDATE') == false ? 0 : getenv('HD_NEW_PAD_APK_VERSION_MUST_UPDATE');
  513. util::success(['version' => $version, 'mustUpdate' => $mustUpdate]);
  514. }
  515. }