Ejemplo n.º 1
0
 /**
  * 获取有效的city信息(city不为0, repair_status为0)
  */
 public function getCitys()
 {
     $arr = null;
     $result = UserBaseInfo::find()->select('city')->where(['!=', 'city', 0])->andWhere(['repair_status' => 0])->asArray()->all();
     //获取数组中某一列的值
     $arr = ArrayHelper::getColumn($result, 'city');
     return $arr;
 }
Ejemplo n.º 2
0
 /**
  * weixin/qq/weibo第三方登录绑定判断
  */
 public function actionThirdParty()
 {
     $params = Yii::$app->getRequest()->post();
     $params = array_map('htmlEntityString', $params);
     $openid = isset($params['open_id']) ? $params['open_id'] : '';
     $type = isset($params['type']) ? $params['type'] : '';
     if (!$openid) {
         return responseArray(1101, 'openid_params_missing', '缺失用户身份唯一标识openid参数');
     }
     if (!$type) {
         return responseArray(1102, 'type_params_missing', '缺失第三方登录类型参数');
     }
     try {
         $user = UserBaseInfo::find()->select(['id'])->where(['open_id' => $openid, 'status' => UserBaseInfo::USER_NORMAL_STATUS])->one();
         if (!$user) {
             return responseArray(2101, 'user_not_exists', '用户不存在或被禁用');
         }
         $thridParty = new UserThirdPartyLogin();
         $thridParty = $thridParty->getByUserId($user->id, UserThirdPartyLogin::BIND_API_CHANNEL, $type);
         if ($thridParty && $thridParty['status'] == UserThirdPartyLogin::STATUS_LOGIN_BIND) {
             return responseArray(0, 'user_bind_thirdparty', '用户已绑定该类型第三方登录', ['open_id' => $thridParty->open_id, 'type' => $thridParty->type, 'profile_info' => $thridParty->profile_info]);
         } else {
             return responseArray(1103, 'user_notbind_thirdparty', '用户未绑定该类型第三方登录');
         }
     } catch (Exception $ex) {
         return responseArray(1, 'network_anomaly', '网络异常,请稍后重试');
     }
 }
Ejemplo n.º 3
0
 public function getUserBindInfo($username, $type, $openId)
 {
     $third = new UserThirdPartyLogin();
     $channel = UserThirdPartyLogin::BIND_API_CHANNEL;
     if (!$username) {
         return responseArray(1101, 'username_pwd_params_missing', '用户标识丢失');
     }
     if (!$type) {
         return responseArray(1201, 'third_type_not_found', '第三方类型不能为空');
     }
     if (!$openId) {
         return responseArray(1202, 'third_openId_not_found', '第三方账号关联open_id丢失');
     }
     $user = UserBaseInfo::find()->where(['mobile' => $username])->orWhere(['email' => $username])->one();
     $userOpenId['open_id'] = $user['open_id'];
     if ($user == null) {
         return responseArray(1102, 'user_not_exists', '用户不存在');
     }
     $info = $third->checkBindByUAT($user['id'], $channel, $type, true);
     $beenBind = $third->checkBeenBindUAT($user['id'], $channel, $type, true);
     if ($info && is_array($info) || $beenBind) {
         if ($beenBind['open_id'] == $openId) {
             return responseArray(0, 'success', '用户已绑定并与现操作绑定号一致', $beenBind['open_id']);
         }
         $beenBind['profile_info'] = json_decode($beenBind['profile_info']);
         $oldBind = [];
         if (isset($beenBind['profile_info'])) {
             foreach ($beenBind['profile_info'] as $key => $value) {
                 $oldBind[$key] = $value;
             }
         }
         $oldBind['open_id'] = $beenBind['open_id'];
         return responseArray(1401, 'has_been_bind', '用户已绑定但与现操作绑定号不一致', $oldBind);
     }
     if (!is_array($info)) {
         return responseArray(1301, 'user_not_bind', '用户未绑定', $user->attributes);
     }
 }