| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693 |
- <?php
- namespace ghs\controllers;
- use biz\admin\classes\AdminClass;
- use biz\pt\classes\AgreementClass;
- use biz\shop\classes\ShopClass;
- use bizGhs\item\classes\LabelClass;
- use bizHd\admin\classes\ShopAdminClass;
- use bizGhs\shop\services\ShopAdminService;
- use bizGhs\admin\services\AdminService;
- use bizHd\wx\classes\WxOpenClass;
- use common\components\dict;
- use common\components\httpUtil;
- use common\components\imgUtil;
- use common\components\jwt;
- use common\components\noticeUtil;
- use common\components\util;
- use Yii;
- use common\components\stringUtil;
- use biz\sj\services\MerchantService;
- use bizHd\user\services\UserService;
- use common\services\xhMerchantService;
- use common\components\wxUtil;
- use linslin\yii2\curl;
- use yii\helpers\Json;
- //用户登陆
- class AuthController extends PublicController
- {
- //微信手机号一键登录 ssh 20210121
- public function actionWxMobileLogin()
- {
- $post = Yii::$app->request->post();
- $iv = $post['iv'];
- $encryptedData = $post['encryptedData'];
- $merchant = WxOpenClass::getGhsWxInfo();
- $appId = $merchant['miniAppId'];
- $miniOpenId = $post['miniOpenId'] ?? '';
- if (empty($miniOpenId)) {
- util::success(['hasNoOpenId' => 1], '登录失败,没有miniOpenId');
- }
- $cacheKey = 'GHS_SHOP_MINI_SESSION_KEY_' . $miniOpenId;
- $sessionKey = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
- if (empty($sessionKey)) {
- Yii::$app->redis->executeCommand('DEL', [$cacheKey]);
- noticeUtil::push($cacheKey . " 登录失败!!sessionKey空的", '15280215347');
- util::success(['hasNoOpenId' => 1], '登录失败。');
- }
- $wxMiniSecret = Yii::getAlias("@vendor/weixinMiniSecret");
- require_once($wxMiniSecret . '/wxBizDataCrypt.php');
- $pc = new \WXBizDataCrypt($appId, $sessionKey);
- $errCode = $pc->decryptData($encryptedData, $iv, $result);
- if ($errCode != 0) {
- Yii::$app->redis->executeCommand('DEL', [$cacheKey]);
- noticeUtil::push($cacheKey . " 批发商 登录失败!!!!sessionKey异常", '15280215347');
- util::success(['hasNoOpenId' => 1], '登录失败!');
- }
- $arr = Json::decode($result);
- $phoneNumber = isset($arr['purePhoneNumber']) ? $arr['purePhoneNumber'] : '';
- if (empty($phoneNumber)) {
- Yii::$app->redis->executeCommand('DEL', [$cacheKey]);
- noticeUtil::push($cacheKey . "批发商 登录失败了!获取手机号失败", '15280215347');
- util::success(['hasNoOpenId' => 1], '登录失败了哦');
- }
- $admin = AdminClass::getByCondition(['mobile' => $phoneNumber]);
- if (empty($admin)) {
- util::fail('请先注册或请店长添加自己为员工');
- }
- $currentShopId = $admin['currentGhsShopId'] ?? 0;
- $openShop = $admin['openGhsShop'] ?? 1;
- if (empty($currentShopId)) {
- if ($openShop == 2) {
- util::fail('审核中');
- }
- util::fail('请先注册..');
- }
- $currentShop = ShopClass::getById($currentShopId, true);
- if (empty($currentShop)) {
- util::fail('没有找到门店');
- }
- $mainId = $currentShop->mainId ?? 0;
- $adminId = $admin['id'] ?? 0;
- if (isset($admin['ghsMiniOpenId']) && empty($admin['ghsMiniOpenId'])) {
- AdminClass::updateById($adminId, ['ghsMiniOpenId' => $miniOpenId]);
- }
- $admin['miniOpenId'] = $miniOpenId;
- //1没有开店 2已申请待审核 3已开店
- $openShop = $admin['openGhsShop'] ?? 1;
- if ($openShop == 2) {
- util::fail('帐号审核中');
- }
- $shopAdmin = ShopAdminClass::getByCondition(['adminId' => $adminId, 'mainId' => $mainId], true);
- if (empty($shopAdmin)) {
- util::fail('请先注册...');
- }
- $shopAdmin->lastLogin = date("Y-m-d H:i:s");
- $shopAdmin->save();
- $shopAdminId = $shopAdmin->id ?? 0;
- //是否有切换门店的权限
- $switchShop = \biz\shop\classes\ShopAdminClass::hasSwitchShopRight($shopAdmin);
- $admin['avatar'] = imgUtil::getPrefix() . '/retail/default-img.png';
- $token = jwt::getNewToken($adminId);
- $showDemo = 1;
- $remind = getenv('GHS_UPDATE_REMIND') == false ? 0 : getenv('GHS_UPDATE_REMIND');
- $shop = ShopClass::getById($currentShopId, true);
- $skCustomId = $shop->skCustomId ?? 0;
- $apiHost = Yii::$app->params['ghsHost'];
- $imgUploadApi = $apiHost . '/upload/save-file';
- //使用手册
- $cacheKey = 'close_book_' . $shopAdminId;
- $hasClose = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
- $showBook = !empty($hasClose) ? 0 : 1;
- $cacheKey = 'has_hit_navigate_' . $shopAdminId;
- $hasHit = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
- $hasHitNavigate = !empty($hasHit) ? 1 : 0;
- $ghsUpgrading = getenv('GHS_UPGRADING') == false ? 0 : getenv('GHS_UPGRADING');
- if ($ghsUpgrading == 1) {
- util::fail('系统升级中,稍后再试');
- }
- $lookAllShop = 0;
- if (getenv('YII_ENV') == 'production') {
- if ($adminId == 4 || $adminId == 51 || $adminId == 7335) {
- $lookAllShop = 1;
- }
- } else {
- $lookAllShop = 1;
- }
- //惠雅鲜花员工不能看收入情况
- if (in_array($adminId, [2366, 2812, 4004])) {
- $shopAdmin->super = 0;
- }
- $labelList = LabelClass::getMyUnUseLabelList($mainId);
- //注意这里的输出内容有多个地方一样,要修改需要同步修改,请搜索关键词loginOK!!!!!!!!
- util::success([
- 'token' => $token,
- 'admin' => $admin,
- 'shopAdminId' => $shopAdminId,
- 'shopId' => $currentShopId,
- 'switchShop' => $switchShop,
- 'openShop' => $openShop,
- 'showDemo' => $showDemo,
- //有小程序新版本提示更新
- 'update' => $remind,
- 'skCustomId' => $skCustomId,
- 'apiHost' => $apiHost,
- 'imgUploadApi' => $imgUploadApi,
- 'showBook' => $showBook,
- 'hasHitNavigate' => $hasHitNavigate,
- 'staff' => $shopAdmin,
- 'lookAllShop' => $lookAllShop,
- 'labelList' => $labelList,
- ]);
- }
- //本机号码一键登录 ssh 20210117
- public function actionPhoneLogin()
- {
- $get = Yii::$app->request->get();
- $access_token = $get['access_token'] ?? '';
- $openid = $get['openid'] ?? '';
- if (empty($access_token) || empty($openid)) {
- util::fail('参数错误');
- }
- //密钥,需要和uniCloud里的一致
- $secret = 'XHB2021198819640123';
- $params = ['access_token' => $access_token, 'openid' => $openid];
- $stringSignTemp = '';
- foreach ($params as $k => $v) {
- $stringSignTemp .= $k . '=' . $v . '&';
- }
- $stringSignTemp = rtrim($stringSignTemp, '&');
- $sign = hash_hmac('sha256', $stringSignTemp, $secret);
- $url = Yii::$app->params['ghsUniCloudHost'] . "/getMobileNumber?access_token=" . $access_token . "&sign=" . $sign . "&" . $stringSignTemp;
- $curl = new curl\Curl();
- $respond = $curl->get($url);
- Yii::info($respond);
- $result = json_decode($respond, true);
- if (isset($result['code']) == false || $result['code'] != 1) {
- util::fail('获取手机号失败');
- }
- $phoneNumber = $result['data']['phoneNumber'] ?? '';
- if (empty($phoneNumber)) {
- util::fail('没有获取到手机号');
- }
- $ptStyle = dict::getDict('ptStyle', 'ghs');
- $admin = AdminClass::getByCondition(['mobile' => $phoneNumber, 'style' => $ptStyle]);
- if (empty($admin)) {
- $adminInfo = [
- 'name' => $phoneNumber,
- 'mobile' => $phoneNumber,
- 'style' => $ptStyle,
- ];
- $fromApp = dict::getDict('userSourceGetId', 'app', 'id');
- $admin = \bizGhs\admin\classes\AdminClass::replaceAdmin($adminInfo, $fromApp);
- }
- $currentShopId = $admin['currentGhsShopId'] ?? 0;
- $openShop = $admin['openGhsShop'] ?? 1;
- if (empty($currentShopId)) {
- if ($openShop == 2) {
- util::fail('审核中');
- }
- util::fail('请先注册');
- }
- $adminId = $admin['id'] ?? 0;
- //1没有开店 2已申请待审核 3已开店
- $openShop = $admin['openGhsShop'] ?? 1;
- if ($openShop == 2) {
- util::fail('帐号审核中');
- }
- $currentShop = ShopClass::getById($currentShopId, true);
- if (empty($currentShop)) {
- util::fail('没有找到门店');
- }
- $mainId = $currentShop->mainId ?? 0;
- $shopAdmin = ShopAdminClass::getByCondition(['mainId' => $mainId, 'adminId' => $adminId], true);
- if (empty($shopAdmin)) {
- util::fail('请先注册');
- }
- $shopAdmin->lastLogin = date("Y-m-d H:i:s");
- $shopAdmin->save();
- $shopAdminId = $shopAdmin->id ?? 0;
- //是否有切换门店的权限
- $switchShop = \biz\shop\classes\ShopAdminClass::hasSwitchShopRight($shopAdmin);
- $admin['avatar'] = imgUtil::getPrefix() . '/retail/default-img.png';
- $token = jwt::getNewToken($adminId);
- $showDemo = 1;
- $remind = getenv('GHS_UPDATE_REMIND') == false ? 0 : getenv('GHS_UPDATE_REMIND');
- $shop = ShopClass::getById($currentShopId, true);
- $skCustomId = $shop->skCustomId ?? 0;
- $apiHost = Yii::$app->params['ghsHost'];
- $imgUploadApi = $apiHost . '/upload/save-file';
- //使用手册
- $cacheKey = 'close_book_' . $shopAdminId;
- $hasClose = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
- $showBook = !empty($hasClose) ? 0 : 1;
- $cacheKey = 'has_hit_navigate_' . $shopAdminId;
- $hasHit = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
- $hasHitNavigate = !empty($hasHit) ? 1 : 0;
- $ghsUpgrading = getenv('GHS_UPGRADING') == false ? 0 : getenv('GHS_UPGRADING');
- if ($ghsUpgrading == 1) {
- util::fail('系统升级中,稍后再试');
- }
- $lookAllShop = 0;
- if (getenv('YII_ENV') == 'production') {
- if ($adminId == 4 || $adminId == 51 || $adminId == 7335) {
- $lookAllShop = 1;
- }
- } else {
- $lookAllShop = 1;
- }
- //惠雅鲜花员工不能看收入情况
- if (in_array($adminId, [2366, 2812, 4004])) {
- $shopAdmin->super = 0;
- }
- $labelList = LabelClass::getMyUnUseLabelList($mainId);
- //注意这里的输出内容有多个地方一样,要修改需要同步修改,请搜索关键词loginOK!!!!!!!!
- util::success([
- 'token' => $token,
- 'admin' => $admin,
- 'shopAdminId' => $shopAdminId,
- 'shopId' => $currentShopId,
- 'switchShop' => $switchShop,
- 'openShop' => $openShop,
- 'showDemo' => $showDemo,
- //有小程序新版本提示更新
- 'update' => $remind,
- 'skCustomId' => $skCustomId,
- 'apiHost' => $apiHost,
- 'imgUploadApi' => $imgUploadApi,
- 'showBook' => $showBook,
- 'hasHitNavigate' => $hasHitNavigate,
- 'staff' => $shopAdmin,
- 'lookAllShop' => $lookAllShop,
- 'labelList' => $labelList,
- ]);
- util::success(['admin' => $admin]);
- }
- //准备授权 ssh 2019.11.19
- public function actionPrepare()
- {
- $get = Yii::$app->request->get();
- $url = isset($get['url']) && !empty($get['url']) ? $get['url'] : '';
- if (empty($url)) {
- util::fail('没有网址');
- }
- $account = httpUtil::getAccount($url);
- if (empty($account)) {
- util::fail('没有商家帐号');
- }
- $merchant = MerchantService::getById($account);
- if (empty($merchant)) {
- util::fail('商家无效');
- }
- /**
- * authScope 参数的说明
- * 1.用户通过公众号菜单打开网页,因为已经关注过了公众号,已经生成过用户信息,所以只要使用snsapi_base静默方式拿到openid就可以
- * 2.为了保证付款页的访问速度,暂时只要通过snsapi_base静默方式拿到openid先生成可以用的用户信息即可
- * 3.其它情况需要获取用户完整信息的,使用snsapi_userinfo让用户授权获取信息即可
- * 4.snsapi_base静默方式使用的场景更多,所以参数authScope默认使用snsapi_base
- */
- $authScope = isset($get['authScope']) ? $get['authScope'] : 'snsapi_base';
- $urlEncode = stringUtil::urlSafeB64Encode($url);
- //微信授权获取code ssh 2019.11.24
- $isOpen = 2;
- wxUtil::getCode($urlEncode, $merchant, $authScope, $isOpen);
- util::end();
- }
- //微信授权获取用户信息 ssh 2019.11.20
- public function actionGetUserInfo()
- {
- $get = Yii::$app->request->get();
- $code = isset($get['code']) ? $get['code'] : '';
- if (empty($code)) {
- util::fail('没有获取用户code');
- }
- if (isset($get['state']) && $get['state'] == 'authdeny') {
- util::fail('auth fail');
- }
- $urlEncode = $get['url'];
- $url = stringUtil::urlSafeBase64Decode($urlEncode);
- $account = httpUtil::getAccount($url);
- if (empty($account)) {
- util::stop('商店ID无效!!');
- }
- $merchant = xhMerchantService::getByAccount($account);
- if (empty($merchant)) {
- util::stop('商店无效');
- }
- $sjId = $merchant['id'];
- $authScope = isset($get['authScope']) ? $get['authScope'] : '';
- if (empty($authScope)) {
- util::stop('没有授权类型');
- }
- $data = wxUtil::getOpenId($code, $merchant, 2);
- if ($data === false) {
- //微信授权获取code ssh 2019.11.24
- wxUtil::getCode($urlEncode, $merchant, $authScope, 2);
- util::end();
- }
- $openId = $data['openid'];
- $access_token = $data['access_token'];
- $user = UserService::getByOpenId($openId);
- //用户来源
- $userSource = Yii::$app->dict->getValue('userSourceGetId', 'official');
- $source = $userSource['name'];
- if (empty($user)) {
- //$authScope 默认是 snsapi_base 公众号菜单打开网页(已经关注公众号,有完整信息)、打开付款页(有些客户只付款,没有后续可以不用登记完整信息),只需要获取openid
- $originalInfo = [];
- $originalInfo['openId'] = $openId;
- $originalInfo['sjId'] = $sjId;
- //没有关注公众号,需要获取用户完整信息的情况,则通过弹框授权
- if ($authScope == 'snsapi_userinfo') {
- $baseInfo = wxUtil::authGetUserInfo($openId, $access_token);
- $originalInfo = array_merge($baseInfo, $originalInfo);
- $originalInfo['isFull'] = 1;
- $originalInfo['unionId'] = $baseInfo['unionid'];
- $originalInfo['headImgUrl'] = $baseInfo['headimgurl'];
- $originalInfo['nickName'] = $baseInfo['nickName'];
- }
- $user = UserService::replaceUser($originalInfo, $source, $sjId);
- } else {
- if ($user['isFull'] == 0) {
- if ($authScope == 'snsapi_userinfo') {
- $baseInfo = wxUtil::authGetUserInfo($openId, $access_token);
- $originalInfo = $baseInfo;
- $originalInfo['isFull'] = 1;
- $originalInfo['unionId'] = $baseInfo['unionid'];
- $originalInfo['headImgUrl'] = $baseInfo['headimgurl'];
- $originalInfo['openId'] = $baseInfo['openid'];
- $originalInfo['nickName'] = $baseInfo['nickName'];
- $originalInfo['sjId'] = $sjId;
- $user = UserService::replaceUser($originalInfo, $source, $sjId);
- }
- }
- }
- //这个的基类没有设置统一的全局变量,这里进行设置一次
- $userId = $user['id'];
- $admin = AdminService::getByCondition(['userId' => $userId]);
- if (empty($admin)) {
- util::fail('您无法访问');
- }
- $adminId = $admin['id'];
- //获取token
- $token = jwt::getNewToken($adminId);
- $url = strpos($url, '?') === false ? $url . '?token=' . $token : $url . '&token=' . $token;
- $this->redirect($url);
- }
- //登陆并拿到token ssh 2019.11.23
- public function actionLogin()
- {
- $get = Yii::$app->request->get();
- $mobile = isset($get['mobile']) ? $get['mobile'] : 0;
- if (stringUtil::isMobile($mobile) == false) {
- util::fail('请填写正常的手机号');
- }
- $password = isset($get['password']) && !empty($get['password']) ? $get['password'] : '';
- if (empty($password)) {
- util::fail('请输入密码');
- }
- $admin = AdminService::getByCondition(['mobile' => $mobile, 'style' => AdminClass::STYLE_GHS]);
- if (empty($admin)) {
- util::fail('请先注册哦');
- }
- if (password_verify($password, $admin['password']) == false) {
- util::fail('密码错误');
- }
- $adminId = $admin['id'];
- $shopAdmin = ShopAdminService::getByCondition(['adminId' => $adminId, 'delStatus' => 0]);
- $sjId = $shopAdmin['sjId'] ?? 0;
- $shopId = $admin['currentGhsShopId'] ?? 0;
- if (empty($shopId)) {
- util::fail('没有权限登录');
- }
- //获取token
- $token = jwt::getNewToken($adminId);
- util::success(['token' => $token, 'account' => $sjId, 'shopId' => $shopId]);
- }
- //静默获取小程序用户信息
- public function actionMiniInfo()
- {
- //供货商平台
- Yii::$app->params['ptStyle'] = dict::getDict('ptStyle', 'ghs');
- $code = Yii::$app->request->get('code', '');
- $wxMiniBase = WxOpenClass::getGhsWxInfo();
- $appId = $wxMiniBase['miniAppId'];
- $appSecret = $wxMiniBase['miniAppSecret'];
- if (empty($appSecret)) {
- //没有管理店铺不允许登录
- util::success(['token' => '', 'number' => 1]);
- }
- $url = "https://api.weixin.qq.com/sns/jscode2session?appid={$appId}&secret={$appSecret}&js_code={$code}&grant_type=authorization_code";
- $curl = new curl\Curl();
- $curl->setOption(CURLOPT_SSL_VERIFYPEER, false);
- $result = $curl->get($url);
- $arr = Json::decode($result);
- $sessionKey = isset($arr['session_key']) ? $arr['session_key'] : '';
- $openid = $arr['openid'] ?? '';
- if (empty($openid)) {
- //没有管理店铺不允许登录
- util::success(['token' => '', 'currentMiniOpenId' => $openid, 'number' => 2]);
- }
- $cacheKey = 'GHS_SHOP_MINI_SESSION_KEY_' . $openid;
- Yii::$app->redis->executeCommand('SET', [$cacheKey, $sessionKey]);
- $admin = AdminClass::getByCondition(['ghsMiniOpenId' => $openid]);
- if (empty($admin)) {
- //没有管理店铺不允许登录
- util::success(['token' => '', 'currentMiniOpenId' => $openid, 'number' => 3]);
- }
- $adminId = $admin['id'];
- $openShop = $admin['openGhsShop'] ?? 1;
- $currentShopId = $admin['currentGhsShopId'] ?? 0;
- if (empty($currentShopId)) {
- //没有管理店铺不允许登录
- util::success(['token' => '', 'currentMiniOpenId' => $openid, 'number' => 4]);
- }
- $currentShop = ShopClass::getById($currentShopId, true);
- if (empty($currentShop)) {
- util::success(['token' => '', 'currentMiniOpenId' => $openid, 'number' => 4]);
- }
- $mainId = $currentShop->mainId ?? 0;
- $shopAdmin = ShopAdminClass::getByCondition(['mainId' => $mainId, 'adminId' => $adminId], true);
- if (empty($shopAdmin)) {
- //没有管理店铺不允许登录
- util::success(['token' => '', 'currentMiniOpenId' => $openid, 'number' => 5]);
- }
- $shopAdmin->lastLogin = date("Y-m-d H:i:s");
- $shopAdmin->save();
- $shopAdminId = $shopAdmin->id ?? 0;
- //是否有切换门店的权限
- $switchShop = \biz\shop\classes\ShopAdminClass::hasSwitchShopRight($shopAdmin);
- $admin['avatar'] = imgUtil::getPrefix() . '/retail/default-img.png';
- $token = jwt::getNewToken($adminId);
- $showDemo = 1;
- $remind = getenv('GHS_UPDATE_REMIND') == false ? 0 : getenv('GHS_UPDATE_REMIND');
- $shop = ShopClass::getById($currentShopId, true);
- $skCustomId = $shop->skCustomId ?? 0;
- $mainId = $shop->mainId ?? 0;
- $apiHost = Yii::$app->params['ghsHost'];
- $imgUploadApi = $apiHost . '/upload/save-file';
- //使用手册
- $cacheKey = 'close_book_' . $shopAdminId;
- $hasClose = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
- $showBook = !empty($hasClose) ? 0 : 1;
- $cacheKey = 'has_hit_navigate_' . $shopAdminId;
- $hasHit = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
- $hasHitNavigate = !empty($hasHit) ? 1 : 0;
- $ghsUpgrading = getenv('GHS_UPGRADING') == false ? 0 : getenv('GHS_UPGRADING');
- if ($ghsUpgrading == 1) {
- util::fail('系统升级中,稍后再试');
- }
- $lookAllShop = 0;
- if (getenv('YII_ENV') == 'production') {
- if ($adminId == 4 || $adminId == 51 || $adminId == 7335) {
- $lookAllShop = 1;
- }
- } else {
- $lookAllShop = 1;
- }
- //惠雅鲜花员工不能看收入情况
- if (in_array($adminId, [2366, 2812, 4004])) {
- $shopAdmin->super = 0;
- }
- $labelList = LabelClass::getMyUnUseLabelList($mainId);
- //注意这里的输出内容有多个地方一样,要修改需要同步修改,请搜索关键词loginOK!!!!!!!!
- util::success([
- 'token' => $token,
- 'admin' => $admin,
- 'shopAdminId' => $shopAdminId,
- 'shopId' => $currentShopId,
- 'switchShop' => $switchShop,
- 'openShop' => $openShop,
- 'showDemo' => $showDemo,
- //有小程序新版本提示更新
- 'update' => $remind,
- 'skCustomId' => $skCustomId,
- 'apiHost' => $apiHost,
- 'imgUploadApi' => $imgUploadApi,
- 'showBook' => $showBook,
- 'hasHitNavigate' => $hasHitNavigate,
- 'staff' => $shopAdmin,
- 'lookAllShop' => $lookAllShop,
- 'labelList' => $labelList,
- ]);
- }
- //app登陆 ssh 20211219
- public function actionAppLogin()
- {
- $get = Yii::$app->request->get();
- $mobile = isset($get['mobile']) ? $get['mobile'] : 0;
- if (stringUtil::isMobile($mobile) == false) {
- util::fail('请填写正确手机号');
- }
- $password = isset($get['password']) && !empty($get['password']) ? $get['password'] : '';
- if (empty($password)) {
- util::fail('请输入密码');
- }
- $admin = AdminService::getByCondition(['mobile' => $mobile], true);
- if (empty($admin)) {
- util::fail('请先注册哦...');
- }
- if (password_verify($password, $admin->password) == false) {
- util::fail('密码错误');
- }
- $openShop = $admin->openGhsShop ?? 1;
- $currentShopId = $admin->currentGhsShopId ?? 0;
- if (empty($currentShopId)) {
- if ($openShop == 2) {
- util::fail('审核中');
- }
- util::fail('请先注册');
- }
- $currentShop = \bizGhs\shop\classes\ShopClass::getById($currentShopId, true);
- if (empty($currentShop)) {
- util::fail('没有找到门店');
- }
- $mainId = $currentShop->mainId ?? 0;
- $adminId = $admin->id;
- $shopAdmin = ShopAdminService::getByCondition(['mainId' => $mainId, 'adminId' => $adminId], true);
- if (empty($shopAdmin)) {
- util::fail('您没有权限');
- }
- if ($shopAdmin->delStatus == 1) {
- util::fail('您没有权限哦');
- }
- if ($shopAdmin->status == 0) {
- util::fail("您的账号已被冻结");
- }
- $token = jwt::getNewToken($adminId);
- $shopAdminId = $shopAdmin->id ?? 0;
- //是否有切换门店的权限
- $switchShop = \biz\shop\classes\ShopAdminClass::hasSwitchShopRight($shopAdmin);
- //1没有开店 2已申请待审核 3已开店
- $openShop = $admin['openGhsShop'] ?? 1;
- $showDemo = 1;
- $shop = ShopClass::getById($currentShopId, true);
- $skCustomId = $shop->skCustomId ?? 0;
- $apiHost = Yii::$app->params['ghsHost'];
- $imgUploadApi = $apiHost . '/upload/save-file';
- //使用手册
- $cacheKey = 'close_book_' . $shopAdminId;
- $hasClose = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
- $showBook = !empty($hasClose) ? 0 : 1;
- $cacheKey = 'has_hit_navigate_' . $shopAdminId;
- $hasHit = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
- $hasHitNavigate = !empty($hasHit) ? 1 : 0;
- $ghsUpgrading = getenv('GHS_UPGRADING') == false ? 0 : getenv('GHS_UPGRADING');
- if ($ghsUpgrading == 1) {
- util::fail('系统升级中,稍后再试');
- }
- $lookAllShop = 0;
- if (getenv('YII_ENV') == 'production') {
- if ($adminId == 4 || $adminId == 51 || $adminId == 7335) {
- $lookAllShop = 1;
- }
- } else {
- $lookAllShop = 1;
- }
- //惠雅鲜花员工不能看收入情况
- if (in_array($adminId, [2366, 2812, 4004])) {
- $shopAdmin->super = 0;
- }
- $labelList = LabelClass::getMyUnUseLabelList($mainId);
- //注意这里的输出内容有多个地方一样,要修改需要同步修改,请搜索关键词loginOK!!!!!!!!
- util::success([
- 'token' => $token,
- 'admin' => $admin,
- 'shopAdminId' => $shopAdminId,
- 'shopId' => $currentShopId,
- 'switchShop' => $switchShop,
- 'openShop' => $openShop,
- 'showDemo' => $showDemo,
- //有小程序新版本提示更新
- 'update' => 0,
- 'skCustomId' => $skCustomId,
- 'apiHost' => $apiHost,
- 'imgUploadApi' => $imgUploadApi,
- 'showBook' => $showBook,
- 'hasHitNavigate' => $hasHitNavigate,
- 'staff' => $shopAdmin,
- 'lookAllShop' => $lookAllShop,
- 'labelList' => $labelList,
- ]);
- }
- //最新版本 ssh 20220211
- public function actionGetApkVersion()
- {
- $version = getenv('GHS_NEW_APK_VERSION') == false ? '100' : getenv('GHS_NEW_APK_VERSION');
- $mustUpdate = getenv('GHS_NEW_APK_VERSION_MUST_UPDATE') == false ? 0 : getenv('GHS_NEW_APK_VERSION_MUST_UPDATE');
- $updateText = '重要功能优化';
- util::success(['version' => $version, 'mustUpdate' => $mustUpdate, 'updateText' => $updateText]);
- }
- //收银台apk更新 ssh 20220310
- public function actionGetPadApkVersion()
- {
- $version = getenv('GHS_NEW_PAD_APK_VERSION') == false ? '100' : getenv('GHS_NEW_PAD_APK_VERSION');
- $mustUpdate = getenv('GHS_NEW_PAD_APK_VERSION_MUST_UPDATE') == false ? 0 : getenv('GHS_NEW_PAD_APK_VERSION_MUST_UPDATE');
- util::success(['version' => $version, 'mustUpdate' => $mustUpdate]);
- }
- //注册使用协议 ssh 20220327
- public function actionRegister()
- {
- $html = AgreementClass::xhbRegister(0);
- util::success(['html' => $html]);
- }
- //隐私政策 ssh 20220327
- public function actionPrivacy()
- {
- $html = AgreementClass::xhbPrivacy(0);
- util::success(['html' => $html]);
- }
- }
|