/**
  * 获取第三方用户信息
  *
  * @param siteMark
  * @param openId
  * @param accessToken
  * @return
  */
 public static BindSite getBindSite(SiteMark siteMark, String openId, String accessToken) {
   BindSite bs = new BindSite();
   bs.setSiteMark(siteMark);
   bs.setOpenId(openId);
   bs.setAccessToken(accessToken);
   String nickName = null;
   if (SiteMark.QQ.equals(siteMark)) {
     UserInfo ui = new UserInfo(accessToken, openId);
     UserInfoBean uib = null;
     try {
       uib = ui.getUserInfo();
     } catch (QQConnectException e) {
       logger.error(e);
       throw new ServiceException(ErrService.UserS.ACC_108, "QQ_API调用异常", "第三方平台异常,请从新尝试!");
     }
     nickName = uib.getNickname();
   } else if (SiteMark.SINA.equals(siteMark)) {
     Users um = new Users();
     um.client.setToken(accessToken);
     try {
       weibo4j.model.User user = um.showUserById(openId);
       nickName = user.getScreenName();
     } catch (WeiboException e) {
       logger.error(e);
       throw new ServiceException(ErrService.UserS.ACC_108, "SINA_API调用异常", "第三方平台异常,请从新尝试!");
     }
   }
   bs.setNickName(nickName);
   return bs;
 }
  @Override
  public BindSite bindSiteUser(
      Long userId,
      SiteMark siteMark,
      String openId,
      String accessToken,
      long tokenExpireIn,
      boolean regFlag) {
    if (userId == null || userId <= 0) {
      throw new IllegalArgumentException();
    }

    BindSite bs3 = bindSiteDao.queryByOpenId(siteMark, openId);
    if (bs3 != null) {
      throw new ServiceException(ErrService.UserS.ACC_108, "当前第三方账号已经被其他账号绑定!");
    }
    // 当前用户是否已经绑定
    BindSite bs = bindSiteDao.queryByUserId(siteMark, userId);
    // 获取第三方用户信息
    BindSite bsOther = UserServiceImpl.getBindSite(siteMark, openId, accessToken);

    if (bs != null) {
      // 更新token等信息
      bsOther.setBindSiteId(bs.getBindSiteId());
      this.changeToken(bsOther, tokenExpireIn);
    } else {
      // 绑定平台
      bs = new BindSite();
      bs.setAccessToken(accessToken);
      bs.setOpenId(openId);
      bs.setNickName(bsOther.getNickName());
      bs.setRegFlag(regFlag);
      bs.setSiteMark(siteMark);
      bs.setUserId(userId);
      bs.setStartDate(new Date());
      bs.setEndDate(new Date(bs.getStartDate().getTime() + tokenExpireIn));
      bs.setPhotoPath(bsOther.getPhotoPath());
      bindSiteDao.insert(bs);
    }
    return bs;
  }