AuthController.php 22 KB

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