user; $user->miniOpenId = ''; $user->save(); util::complete(); } //修改信息 ssh 20221015 public function actionUpdate() { $post = Yii::$app->request->post(); $user = $this->user; if (empty($user)) { util::fail('请先登录'); } $userId = $user->id ?? 0; $address = $post['address'] ?? ''; $floor = $post['floor'] ?? ''; $fullAddress = $address . $floor; $post['fullAddress'] = $fullAddress; UserClass::updateById($userId, $post); util::complete(); } //获取当前登录用户的信息 ssh 20221014 public function actionCurrentInfo() { $user = $this->user; util::success(['info' => $user]); } //使用账号登录 ssh 20220920 public function actionAccountLogin() { $get = Yii::$app->request->get(); $mobile = $get['mobile'] ?? ''; $password = $get['password'] ?? ''; if ($password != 'a.1234') { util::fail('密码错误'); } $user = UserClass::getByCondition(['mobile' => $mobile], true); if (empty($user)) { util::fail('账号无效'); } $userId = $user->id ?? 0; $token = !empty($userId) ? jwt::getNewToken($userId) : ''; util::success(['user' => $user, 'token' => $token]); } //生成用户和花店增加客户 ssh 20250307 public function actionCreate() { $post = Yii::$app->request->post(); $user = UserClass::replaceUser($post); if (!empty($this->shop)) { //花店增加客户 CustomClass::buildRelation($this->shop, $user); } $userId = $user->id ?? 0; $token = !empty($userId) ? jwt::getNewToken($userId) : ''; $fullUser = UserClass::getById($userId, true); util::success(['user' => $fullUser, 'token' => $token]); } //最近店铺 ssh 2021.2.27 public function actionRecentShop() { $list = []; //显示国兰的信息 0不是 1是 $showGlInfo = getenv('SHOW_GL_INFO'); $info = $showGlInfo === false ? 1 : $showGlInfo; util::success(['list' => $list, 'showGlInfo' => $info]); } //获取登陆客户的资产 ssh 2019.11.22 public function actionAsset() { $asset = UserAssetService::getByUserId($this->userId); util::success($asset); } //获取登陆客户的优惠情况 ssh 2019.12.3 public function actionDiscount() { $discount = UserAssetService::getDiscount($this->userId); util::success($discount); } //小程序用户完整信息 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::getMallWxMiniBase(); $appId = $merchant['miniAppId']; $miniOpenId = $post['miniOpenId']; if (empty($miniOpenId)) { util::success(['hasNoOpenId' => 1], '登录失败'); } $cacheKey = 'MALL_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); $originalInfo = Json::decode($result); util::success($originalInfo); } //小程序用户手机号 public function actionMiniMobile() { $post = Yii::$app->request->post(); $iv = $post['iv']; $encryptedData = $post['encryptedData']; $merchant = WxOpenClass::getMallWxMiniBase(); $appId = $merchant['miniAppId']; $miniOpenId = $post['miniOpenId']; if (empty($miniOpenId)) { util::success(['hasNoOpenId' => 1], '登录失败'); } $cacheKey = 'MALL_MINI_SESSION_KEY_' . $miniOpenId; $sessionKey = Yii::$app->redis->executeCommand('GET', [$cacheKey]); if (empty($sessionKey)) { util::fail('系统错误,session 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'] : ''; if (empty($mobile)) { util::fail('没有取到手机号,请重试'); } util::success(['mobile' => $mobile]); } //密码修改 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('二次密码不一致'); } $userId = $this->userId; $user = UserService::getUserInfo($userId); if (isset($user['hasPayPwd']) && $user['hasPayPwd'] == 1) { if (empty($old)) { util::fail('请填写旧密码'); } if (password_verify($old, $user['payPassword']) == false) { util::fail('旧密码错误'); } } UserService::updateById($userId, ['payPassword' => password_hash($new, PASSWORD_BCRYPT), 'hasPayPwd' => 1]); util::complete('修改成功'); } //申请会员 ssh 2019.12.18 public function actionApplyMember() { $post = Yii::$app->request->post(); $mobile = isset($post['mobile']) ? $post['mobile'] : 0; if (stringUtil::isMobile($mobile) == false) { util::fail('请输入手机号'); } $userId = $this->userId; $asset = UserAssetService::getByUserId($userId); if (isset($asset['member']) && $asset['member'] != -1) { util::fail('已经是会员了'); } $code = isset($post['code']) ? $post['code'] : ''; $cacheCode = SmsService::getApplyMemberCode($userId, $mobile); if (empty($cacheCode) || $cacheCode != $code) { util::fail('验证码错误'); } $update = []; if (isset($post['realName']) && !empty($post['realName'])) { $update['realName'] = $post['realName']; } if (isset($post['birthday']) && !empty($post['birthday'])) { $update['birthday'] = $post['birthday']; } $user = UserService::getByCondition(['sjId' => $this->sjId, 'mobile' => $mobile]); if ($userId == $user['id']) { util::fail('手机号已验证'); } if (!empty($user)) { util::fail('手机号已经注册过了'); } $update['mobile'] = $mobile; $userInfo = isset($this->user->attributes) ? $this->user->attributes : []; UserService::becomeMember($userInfo, $this->sj->attributes, $update); util::complete('注册成功'); } //登陆客户的信息 ssh 2020.3.12 public function actionLoginDetail() { $user = isset($this->user->attributes) ? $this->user->attributes : []; util::success($user); } }