admin; $admin->miniOpenId = ''; $admin->ghsMiniOpenId = ''; $admin->save(); util::complete(); } //个人信息 ssh 20230505 public function actionInfo() { $admin = $this->admin; util::success(['info' => $admin]); } //修改个人信息 ssh 20230505 public function actionUpdateAdmin() { $post = Yii::$app->request->post(); $ghsOpenId = $post['ghsOpenId'] ?? ''; $name = $post['name'] ?? ''; $admin = $this->admin; $admin->ghsOpenId = $ghsOpenId; if (!empty($name)) { $admin->name = $name; } $admin->save(); if (!empty($name)) { $adminId = $this->adminId; ShopAdminClass::updateByCondition(['adminId' => $adminId], ['name' => $name]); } util::complete(); } //绑定帐号自动登录 ssh 20210121 public function actionBindAutoLogin() { $post = Yii::$app->request->post(); $iv = isset($post['iv']) ? $post['iv'] : ''; $encryptedData = isset($post['encryptedData']) ? $post['encryptedData'] : ''; $merchant = WxOpenClass::getGhsWxInfo(); $appId = $merchant['miniAppId']; $miniOpenId = $post['miniOpenId']; if (empty($miniOpenId)) { util::fail('绑定失败'); } $cacheKey = 'GHS_SHOP_MINI_SESSION_KEY_' . $miniOpenId; $sessionKey = Yii::$app->redis->executeCommand('GET', [$cacheKey]); $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::info($result . ' ' . $errCode); util::fail('绑定失败了'); } Yii::info('小程序获取用户信息:' . $result); $wxInfo = Json::decode($result); $nickName = $wxInfo['nickName'] ?? ''; if (empty($nickName)) { util::fail('绑定失败'); } $admin = $this->admin ?? []; if (empty($admin)) { util::fail('绑定失败'); } $admin->ghsMiniOpenId = $miniOpenId; $admin->save(); util::complete(); } //修改保存安卓clientId public function actionReplaceClientId() { $get = Yii::$app->request->get(); $id = $get['id'] ?? ''; if (empty($id)) { util::success(['returnStatus' => 'FAILURE']); } $this->admin->clientId = $id; $this->admin->save(); //noticeUtil::push("保存客户端ID:" . $id, '15280215347'); util::complete(); } //修改密码 ssh 20220106 public function actionModifyPassword() { $get = Yii::$app->request->get(); $password = $get['password'] ?? ''; if (empty($password)) { util::fail('请填写密码'); } stringUtil::passwordCheck($password); $adminId = $this->adminId; $password = password_hash($password, PASSWORD_BCRYPT); AdminClass::updateById($adminId, ['password' => $password]); util::complete('操作成功'); } //最近店铺 ssh 2021.2.27 public function actionRecentShop() { $respond = AdminClass::getRecentShop($this->admin); util::success($respond); } //获取登陆员工的权限 ssh 2019.11.24 public function actionLoginAuth() { $auth = AdminService::getAuth($this->adminId, $this->sjId); util::success($auth); } //添加员工 ssh 2019.12.8 public function actionAdd() { $post = Yii::$app->request->post(); $post['sjId'] = $this->sjId; $admin = AdminService::addAdmin($post); $id = $admin['id']; $info = AdminService::getDetail($id); util::success($info); } //删除员工 ssh 2019.12.9 public function actionDelete() { Yii::$app->end(); $id = Yii::$app->request->post('id'); $admin = AdminClass::getById($id); AdminService::valid($admin, $this->sjId); AdminService::deleteAdmin($admin, $this->adminId); util::complete(); } //查看员工详情 ssh 2019.12.9 public function actionDetail() { $id = Yii::$app->request->get('id'); $admin = AdminService::getDetail($id); AdminService::valid($admin, $this->sjId); util::success($admin); } //密码修改 public function actionPassword() { $post = Yii::$app->request->post(); $old = isset($post['old']) ? $post['old'] : ''; $new = isset($post['new']) ? $post['new'] : ''; $confirm = isset($post['confirm']) ? $post['confirm'] : ''; if (empty($new)) { util::fail('请输入新密码'); } if ($new != $confirm) { util::fail('二次密码不一致'); } $admin = $this->admin->attributes; $adminId = $this->adminId; if (!empty($admin['password'])) { if (empty($old)) { util::fail('请填写旧密码'); } if (password_verify($old, $admin['password']) == false) { util::fail('旧密码错误'); } } AdminService::updateById($adminId, ['password' => password_hash($new, PASSWORD_BCRYPT)]); util::complete('修改成功'); } //支付密码修改 public function actionConfirmPassword() { $post = Yii::$app->request->post(); $old = isset($post['old']) ? $post['old'] : ''; $new = isset($post['new']) ? $post['new'] : ''; $confirm = isset($post['confirm']) ? $post['confirm'] : ''; if (empty($new)) { util::fail('请输入新密码'); } if ($new != $confirm) { util::fail('二次密码不一致'); } $admin = $this->admin->attributes; $adminId = $this->adminId; if (!empty($admin['payPassword'])) { if (empty($old)) { util::fail('请填写旧密码'); } if (password_verify($old, $admin['payPassword']) == false) { util::fail('旧密码错误'); } } AdminService::updateById($adminId, ['payPassword' => password_hash($new, PASSWORD_BCRYPT)]); util::complete('修改成功'); } //登陆员工的详情 ssh 2019.12.26 public function actionLoginDetail() { $detail = AdminService::getDetail($this->adminId); util::success($detail); } //小程序用户完整信息 ssh 2019.12.12 public function actionMiniFullInfo() { $post = Yii::$app->request->post(); $iv = isset($post['iv']) ? $post['iv'] : ''; $encryptedData = isset($post['encryptedData']) ? $post['encryptedData'] : ''; $merchant = WxOpenClass::getGhsWxInfo(); $appId = $merchant['miniAppId']; $admin = $this->admin; $adminId = $this->adminId; $miniOpenId = $admin->ghsMiniOpenId; if (empty($miniOpenId)) { util::fail('没有找到管理员信息(miniOpenId)'); } $unionId = $admin->unionId ?? ''; if (empty($unionId)) { util::fail('没有找到管理员信息(unionId)'); } $cacheKey = 'GHS_SHOP_MINI_SESSION_KEY_' . $miniOpenId; $sessionKey = Yii::$app->redis->executeCommand('GET', [$cacheKey]); $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::info($result . ' ' . $errCode); util::fail('获取用户信息失败'); } Yii::info('小程序获取用户信息:' . $result); $wxInfo = Json::decode($result); $source = UserClass::$userSourceId['mini']['name']; $wxInfo['ghsMiniOpenId'] = $admin->ghsMiniOpenId ?? ''; $wxInfo['unionId'] = $unionId; $wxInfo['mainId'] = $this->mainId; //更新 AdminClass::replaceAdmin($wxInfo, $source); $admin = AdminService::getAdminById($adminId); util::success($admin); } //小程序用户手机号 public function actionMiniMobile() { $post = Yii::$app->request->post(); $iv = $post['iv']; $encryptedData = $post['encryptedData']; $merchant = WxOpenClass::getGhsWxInfo(); $appId = $merchant['miniAppId']; $admin = $this->admin->attributes; $miniOpenId = $admin['miniOpenId']; if (empty($miniOpenId)) { util::fail('没有找到管理员信息(miniOpenId)'); } $cacheKey = 'GHS_SHOP_MINI_SESSION_KEY_' . $miniOpenId; $sessionKey = Yii::$app->redis->executeCommand('GET', [$cacheKey]); if (empty($sessionKey)) { util::fail('sesstion key empty'); } $wxMiniSecret = Yii::getAlias("@vendor/weixinMiniSecret"); require_once($wxMiniSecret . '/wxBizDataCrypt.php'); $pc = new \WXBizDataCrypt($appId, $sessionKey); $errCode = $pc->decryptData($encryptedData, $iv, $result); if ($errCode != 0) { util::fail('解密失败'); } $arr = Json::decode($result); $mobile = isset($arr['purePhoneNumber']) ? $arr['purePhoneNumber'] : ''; $originalMobile = $admin['mobile'] ?? ''; if (empty($originalMobile)) { \biz\admin\classes\AdminClass::updateById($this->adminId, ['mobile' => $mobile]); } util::success(['mobile' => $mobile]); } //已经存有token,但没有store信息重新获取 //注意这里的输出内容有多个地方一样,要修改需要同步修改,请搜索关键词loginOK!!!!!!!! public function actionHasTokenAutoLogin() { $admin = $this->admin; $currentGhsShopId = $admin->currentGhsShopId ?? 0; $switchShop = \biz\shop\classes\ShopAdminClass::hasSwitchShopRight($this->shopAdmin); $openShop = $admin['openGhsShop'] ?? 1; $showDemo = 1; $skCustomId = $this->shop->skCustomId ?? 0; $mainId = $this->shop->mainId ?? 0; $apiHost = Yii::$app->params['ghsHost']; $imgUploadApi = $apiHost . '/upload/save-file'; //使用手册 $cacheKey = 'close_book_' . $this->shopAdminId; $hasClose = Yii::$app->redis->executeCommand('GET', [$cacheKey]); $showBook = !empty($hasClose) ? 0 : 1; $cacheKey = 'has_hit_navigate_' . $this->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; $adminId = $admin['id'] ?? 0; if (getenv('YII_ENV') == 'production') { $couldLookAllShop = dict::getDict('couldLookAllShop'); if (in_array($adminId, $couldLookAllShop)) { $lookAllShop = 1; } } else { $lookAllShop = 1; } //惠雅鲜花员工不能看收入情况 if (in_array($adminId, [2366, 2812, 4004])) { $this->shopAdmin->super = 0; } $labelList = LabelClass::getMyUnUseLabelList($mainId); util::success([ 'token' => '', 'admin' => $admin, 'shopAdminId' => $this->shopAdminId, 'shopId' => $currentGhsShopId, 'switchShop' => $switchShop, 'openShop' => $openShop, 'showDemo' => $showDemo, //有小程序新版本提示更新 'update' => 0, 'skCustomId' => $skCustomId, 'apiHost' => $apiHost, 'imgUploadApi' => $imgUploadApi, 'showBook' => $showBook, 'hasHitNavigate' => $hasHitNavigate, 'staff' => $this->shopAdmin, 'lookAllShop' => $lookAllShop, 'labelList' => $labelList, ]); } }