Commit 94b1099c authored by 技术部-任文超's avatar 技术部-任文超

Merge branch '20180525-innerApi-update' into 'master'

20180525 inner api update

用户信息全量查询接口升级

See merge request !11
parents fbe49235 e0af3c19
...@@ -8,7 +8,11 @@ public enum IncomeEnum { ...@@ -8,7 +8,11 @@ public enum IncomeEnum {
CASH("现金计算"), CASH("现金计算"),
PAY_CARD("工资卡"), PAY_CARD("工资卡"),
CASH_AND_PAY_CARD("混合"); CASH_AND_PAY_CARD("混合");
private String desc; private String desc;
public String getDesc() {
return desc;
}
IncomeEnum(String desc) { IncomeEnum(String desc) {
this.desc = desc; this.desc = desc;
......
...@@ -15,6 +15,9 @@ public enum IncomeRangeEnum { ...@@ -15,6 +15,9 @@ public enum IncomeRangeEnum {
ABOVE_20000("大于20000元"); ABOVE_20000("大于20000元");
private String desc; private String desc;
public String getDesc() {
return desc;
}
IncomeRangeEnum(String desc) { IncomeRangeEnum(String desc) {
this.desc = desc; this.desc = desc;
......
/**
* Copyright 2016 SmartBear Software
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.quantgroup.xyqb.model;
import javax.xml.bind.annotation.XmlTransient;
@javax.xml.bind.annotation.XmlRootElement
public class ApiResponse {
public static final int ERROR = 1;
public static final int WARNING = 2;
public static final int INFO = 3;
public static final int OK = 4;
public static final int TOO_BUSY = 5;
int code;
String type;
String message;
public ApiResponse(){}
public ApiResponse(int code, String message){
this.code = code;
switch(code){
case ERROR:
setType("error");
break;
case WARNING:
setType("warning");
break;
case INFO:
setType("info");
break;
case OK:
setType("ok");
break;
case TOO_BUSY:
setType("too busy");
break;
default:
setType("unknown");
break;
}
this.message = message;
}
@XmlTransient
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
package cn.quantgroup.xyqb.model; package cn.quantgroup.xyqb.model;
import cn.quantgroup.user.enums.EducationEnum;
import cn.quantgroup.user.enums.IncomeEnum;
import cn.quantgroup.user.enums.IncomeRangeEnum;
import cn.quantgroup.user.enums.OccupationEnum;
import cn.quantgroup.xyqb.entity.Address; import cn.quantgroup.xyqb.entity.Address;
import cn.quantgroup.xyqb.entity.Contact; import cn.quantgroup.xyqb.entity.Contact;
import lombok.Data; import lombok.Data;
import javax.persistence.Column;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -24,12 +29,28 @@ public class UserAssociationModel implements Serializable { ...@@ -24,12 +29,28 @@ public class UserAssociationModel implements Serializable {
private String idNo; private String idNo;
private String name; private String name;
private String gender; private String gender;
private String marryStatus;
private String educationEnum;
private String occupationEnum;
private String qq; private String qq;
private String email;
private Long registerFrom; private Long registerFrom;
private Long merchantId; private Long merchantId;
// 婚姻状态
private String marryStatus;
// 受教育程度
private String educationEnum;
// 职业
private String occupationEnum;
// 收入水平范围
private String incomeRangeEnum;
// 收入方式
private String incomeEnum;
// 是否有车
private Boolean hasCar;
// 是否有社保
private Boolean hasSocialSecurity;
// 是否有房
private Boolean hasHouse;
// 是否有信用卡
private Boolean hasCreditCard;
private List<AddressModel> addressList; private List<AddressModel> addressList;
private List<ContactModel> contactList; private List<ContactModel> contactList;
......
Merchant merchant = merchantService.findMerchantByName(systemKey);
AccessTokenResponse token = wechatService.getToken(code);
if (token == null) {
// 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl(response, merchant, registerFrom,protocol);
return;
}
WechatUserInfo userInfo =
wechatService.getWechatUserInfoFromWechatServer(token.getAccessToken(),
token.getOpenId());
if (userInfo == null || StringUtils.isEmpty(userInfo.getOpenId())) {
// 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl(response, merchant, registerFrom,protocol);
return;
}
WechatUserInfo userInfoInDb = wechatService.findWechatUserInfoFromDb(userInfo.getOpenId());
// welcome 首次登录
if (userInfoInDb == null) {
// 微信用户首次登录界面, 首先保存userInfo, 跳入到微信注册登录界面
if (StringUtils.isNotBlank(userInfo.getNickName())) {
String nickName = EmojiUtil.filter(userInfo.getNickName());
userInfo.setNickName(nickName);
}
userInfo = wechatService.saveWechatUserInfo(userInfo);
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfo, registerFrom,protocol);
return;
}
if (userInfoInDb.getUserId() == null) {
// 用户已经微信登录了,但是没有关联信用钱包,跳转到注册页面
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb, registerFrom,protocol);
return;
}
User user = userService.findById(userInfoInDb.getUserId());
if (user == null) {
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb, registerFrom,protocol);
return;
}
// 已经关联了用户
// create session, 登进去,该怎么玩怎么玩。
String redirectUrl = createUserSession(user, merchant, redirect, schema, registerFrom);
LOGGER.info("Location:[{}]",redirectUrl);
response.setHeader("Location", redirectUrl);
response.setStatus(301);
\ No newline at end of file
// 从code获取token
Merchant merchant = merchantService.findMerchantByName(systemKey);
AccessTokenResponse token = wechatService.getToken(code);
if (token == null) {
// 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl(response, merchant, Constants.Channel.WECHAT,domain);
return;
}
WechatUserInfo userInfo =
wechatService.getWechatUserInfoFromWechatServer(token.getAccessToken(),
token.getOpenId());
if (userInfo == null || StringUtils.isEmpty(userInfo.getOpenId())) {
// 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl(response, merchant, Constants.Channel.WECHAT,domain);
return;
}
WechatUserInfo userInfoInDb =
wechatService.findWechatUserInfoFromDb(userInfo.getOpenId());
// welcome 首次登录
if (userInfoInDb == null) {
// 微信用户首次登录界面, 首先保存userInfo, 跳入到微信注册登录界面
if (StringUtils.isNotBlank(userInfo.getNickName())) {
String nickName = EmojiUtil.filter(userInfo.getNickName());
userInfo.setNickName(nickName);
}
userInfo = wechatService.saveWechatUserInfo(userInfo);
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfo,
Constants.Channel.WECHAT,domain);
return;
}
if (userInfoInDb.getUserId() == null) {
// 用户已经微信登录了,但是没有关联信用钱包,跳转到注册页面
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb,
Constants.Channel.WECHAT,domain);
return;
}
User user = userService.findById(userInfoInDb.getUserId());
if (user == null) {
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb,
Constants.Channel.WECHAT,domain);
return;
}
// 已经关联了用户
// create session, 登进去,该怎么玩怎么玩。
String redirectUrl =
createUserSession(user, merchant, "", schema, Constants.Channel.WECHAT);
response.setHeader("Location", redirectUrl);
response.setStatus(301);
return;
\ No newline at end of file
try {
String schema = getProtocol();
String domain = userUiDomain;
if(Objects.equals(schema, "https:")){
domain = userUiDomainS;
}
try {
extData = new String(Base64.decodeBase64(extData), "UTF-8");
} catch (Exception ex) {
extData = "";
}
LOGGER.info("从微信extdata版本接口进入:{}, extData:{}", schema, extData);
if (StringUtils.isEmpty(extData)) {
// 从code获取token
Merchant merchant = merchantService.findMerchantByName(systemKey);
AccessTokenResponse token = wechatService.getToken(code);
if (token == null) {
// 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl(response, merchant, Constants.Channel.WECHAT,domain);
return;
}
WechatUserInfo userInfo =
wechatService.getWechatUserInfoFromWechatServer(token.getAccessToken(),
token.getOpenId());
if (userInfo == null || StringUtils.isEmpty(userInfo.getOpenId())) {
// 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl(response, merchant, Constants.Channel.WECHAT,domain);
return;
}
WechatUserInfo userInfoInDb = wechatService.findWechatUserInfoFromDb(userInfo.getOpenId());
// welcome 首次登录
if (userInfoInDb == null) {
// 微信用户首次登录界面, 首先保存userInfo, 跳入到微信注册登录界面
if (StringUtils.isNotBlank(userInfo.getNickName())) {
String nickName = EmojiUtil.filter(userInfo.getNickName());
userInfo.setNickName(nickName);
}
userInfo = wechatService.saveWechatUserInfo(userInfo);
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfo,
Constants.Channel.WECHAT,domain);
return;
}
if (userInfoInDb.getUserId() == null) {
// 用户已经微信登录了,但是没有关联信用钱包,跳转到注册页面
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb,
Constants.Channel.WECHAT,domain);
return;
}
User user = userService.findById(userInfoInDb.getUserId());
if (user == null) {
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb,
Constants.Channel.WECHAT,domain);
return;
}
// 已经关联了用户
// create session, 登进去,该怎么玩怎么玩。
String redirectUrl =
createUserSession(user, merchant, "", schema, Constants.Channel.WECHAT);
response.setHeader("Location", redirectUrl);
response.setStatus(301);
} else {
HashMap<String, Object> extDataObj;
try {
extDataObj = JSON.parseObject(extData, new TypeReference<HashMap<String, Object>>(){});
} catch (Exception ex) {
LOGGER.error("解析extData发生错误", ex);
}
schema = extDataObj.getOrDefault("protocol", "http:").toString();
domain = userUiDomain;
if(Objects.equals(schema, "https:")){
domain = userUiDomainS;
}
LOGGER.info("从微信登录extData中获得协议信息,protocol:{}", schema);
Long registerFrom = Long.valueOf(extDataObj.getOrDefault("registerFrom", "1").toString());
String redirect = (String) extDataObj.getOrDefault("redirect", "redirect");
LOGGER.info("从微信登录,registerFrom:{}, redirect:{}", registerFrom, redirect);
}
} catch (Exception ex) {
LOGGER.error("发生异常", ex);
throw ex;
}
\ No newline at end of file
// 从code获取token
Merchant merchant = merchantService.findMerchantByName(systemKey);
AccessTokenResponse token = wechatService.getToken(code);
if (token == null) {
// 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl(response, merchant, Constants.Channel.WECHAT, domain);
return;
}
WechatUserInfo userInfo = wechatService.getWechatUserInfoFromWechatServer(token.getAccessToken(), token.getOpenId());
if (userInfo == null || StringUtils.isEmpty(userInfo.getOpenId())) {
// 让用户登录,不关联微信, 构造不关联微信的url
redirectNormalUrl(response, merchant, Constants.Channel.WECHAT, domain);
return;
}
WechatUserInfo userInfoInDb = wechatService.findWechatUserInfoFromDb(userInfo.getOpenId());
// welcome 首次登录
if (userInfoInDb == null) {
// 微信用户首次登录界面, 首先保存userInfo, 跳入到微信注册登录界面
if (StringUtils.isNotBlank(userInfo.getNickName())) {
String nickName = EmojiUtil.filter(userInfo.getNickName());
userInfo.setNickName(nickName);
}
userInfo = wechatService.saveWechatUserInfo(userInfo);
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfo, Constants.Channel.WECHAT, domain);
return;
}
if (userInfoInDb.getUserId() == null) {
// 用户已经微信登录了,但是没有关联信用钱包,跳转到注册页面
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb, Constants.Channel.WECHAT, domain);
return;
}
User user = userService.findById(userInfoInDb.getUserId());
if (user == null) {
redirectWechatLoginUrlWithoutLogin(response, merchant, userInfoInDb, Constants.Channel.WECHAT, domain);
return;
}
// 已经关联了用户
// create session, 登进去,该怎么玩怎么玩。
String redirectUrl = createUserSession(user, merchant, "", schema, Constants.Channel.WECHAT);
LOGGER.info("HTTP协议no redirect:{}, Location=[{}]", schema, redirectUrl);
response.setHeader("Location", redirectUrl);
response.setStatus(301);
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment