AuthController.php 22 KB

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