记得上下班打卡 | git大法好,push需谨慎

Commit ca33f56e authored by jiangxiulong's avatar jiangxiulong

Merge remote-tracking branch 'origin/dev' into dev

parents 09b2eb12 41116eaf
......@@ -3,6 +3,7 @@ package com.liquidnet.service.adam.service;
import com.liquidnet.service.adam.dto.AdamThirdPartParam;
import com.liquidnet.service.adam.dto.vo.AdamRealInfoVo;
import com.liquidnet.service.adam.dto.vo.AdamUserInfoVo;
import com.liquidnet.service.base.ResponseDto;
/**
* <p>
......@@ -26,9 +27,9 @@ public interface IAdamUserService {
* 第三方账号注册
*
* @param param
* @return AdamUserInfoVo
* @return ResponseDto<AdamUserInfoVo>
*/
AdamUserInfoVo register(AdamThirdPartParam param);
ResponseDto<AdamUserInfoVo> register(AdamThirdPartParam param);
/**
* 第三方账号绑定(不存在已绑定账号)
......
......@@ -69,7 +69,7 @@ spring:
profiles:
include: common-service #这里加载management相关公共配置
redis:
database: 9
database: 15
port: ${liquidnet.redis.port}
host: ${liquidnet.redis.host}
password: ${liquidnet.redis.password}
......
......@@ -281,14 +281,16 @@ public class AdamLoginController {
if (!checkSmsCodeDto.isSuccess()) {
return checkSmsCodeDto;
}
AdamUserInfoVo registerUserInfo = adamUserService.register(parameter);
if (null == registerUserInfo) {
return ResponseDto.failure(ErrorMapping.get("10000"));
ResponseDto<AdamUserInfoVo> registerRespDto = adamUserService.register(parameter);
if (!registerRespDto.isSuccess()) {
return ResponseDto.failure(registerRespDto.getCode(), registerRespDto.getMessage());
} else {
AdamUserInfoVo registerUserInfo = registerRespDto.getData();
loginInfoVo.setUserInfo(registerUserInfo);
loginInfoVo.setThirdPartInfo(adamRdmService.getThirdPartVoListByUid(registerUserInfo.getUid()));
// loginInfoVo.setMemberVo(adamRdmService.getMemberSimpleVo());
}
toRegister = true;
loginInfoVo.setUserInfo(registerUserInfo);
loginInfoVo.setThirdPartInfo(adamRdmService.getThirdPartVoListByUid(registerUserInfo.getUid()));
// loginInfoVo.setMemberVo(adamRdmService.getMemberSimpleVo());
}
loginInfoVo.setToken(this.ssoProcess(loginInfoVo.getUserInfo()));
loginInfoVo.getUserInfo().setMobile(SensitizeUtil.custom(loginInfoVo.getUserInfo().getMobile(), 3, 4));
......
......@@ -197,6 +197,24 @@ public class AdamRdmService {
return redisUtil.set(AdamRedisConst.INFO_THIRD_PARTY + uid, vos);
}
public boolean rmvThirdPartVoListByUid(String uid, List<AdamThirdPartInfoVo> vos, String platform) {
if (CollectionUtils.isEmpty(vos)) {
return true;
}
vos.removeIf(r -> r.getPlatform().equals(platform));
return redisUtil.set(AdamRedisConst.INFO_THIRD_PARTY + uid, vos);
}
public AdamThirdPartInfoVo getThirdPartVoByUidPlatform(List<AdamThirdPartInfoVo> vos, String platform) {
if (!CollectionUtils.isEmpty(vos)) {
Optional<AdamThirdPartInfoVo> any = vos.stream().filter(r -> r.getPlatform().equals(platform)).findAny();
if (any.isPresent()) {
return any.get();
}
}
return null;
}
public AdamThirdPartInfoVo getThirdPartVoByUidPlatform(String uid, String platform) {
List<AdamThirdPartInfoVo> vos = this.getThirdPartVoListByUid(uid);
if (!CollectionUtils.isEmpty(vos)) {
......
......@@ -15,6 +15,7 @@ import com.liquidnet.service.adam.service.IAdamUserService;
import com.liquidnet.service.adam.util.NknameUtil;
import com.liquidnet.service.adam.util.QueueUtils;
import com.liquidnet.service.base.ErrorMapping;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.base.SqlMapping;
import com.liquidnet.service.base.constant.MQConst;
import lombok.extern.slf4j.Slf4j;
......@@ -64,126 +65,116 @@ public class AdamUserServiceImpl implements IAdamUserService {
LocalDateTime now = LocalDateTime.now();
AdamUserInfoVo userInfoVo = null;
// if (RedisLockUtil.tryLock(LOCK_KEY_UREGISTER + mobile, 1, 5)) {
String uid = adamRdmService.getUidByMobile(mobile);
if (StringUtils.isEmpty(uid)) {
userInfoVo = AdamUserInfoVo.getNew();
userInfoVo.setUid(IDGenerator.nextSnowId() + "");
userInfoVo.setMobile(mobile);
userInfoVo.setNickname(NknameUtil.randomNkname());
userInfoVo.setIsComplete(0);
userInfoVo.setState(1);
userInfoVo.setQrCode("lN".concat(userInfoVo.getUid()).concat(RandomStringUtils.randomAlphanumeric(5).toUpperCase()));
userInfoVo.setCreateAt(now);
userInfoVo = AdamUserInfoVo.getNew();
userInfoVo.setUid(IDGenerator.nextSnowId() + "");
userInfoVo.setMobile(mobile);
userInfoVo.setNickname(NknameUtil.randomNkname());
userInfoVo.setIsComplete(0);
userInfoVo.setState(1);
userInfoVo.setQrCode("lN".concat(userInfoVo.getUid()).concat(RandomStringUtils.randomAlphanumeric(5).toUpperCase()));
userInfoVo.setCreateAt(now);
// long s = System.currentTimeMillis();
// mongoTemplate.insert(userInfoVo, AdamUserInfoVo.class.getSimpleName());
// log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
long s = System.currentTimeMillis();
adamRdmService.setUidByMobile(mobile, userInfoVo.getUid());
adamRdmService.setUserInfoVoByUid(userInfoVo.getUid(), userInfoVo);
log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s);
long s = System.currentTimeMillis();
adamRdmService.setUidByMobile(mobile, userInfoVo.getUid());
adamRdmService.setUserInfoVoByUid(userInfoVo.getUid(), userInfoVo);
log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s);
LinkedList<String> toMqSqls = CollectionUtil.linkedListString();
LinkedList<Object[]> initUserObjs = CollectionUtil.linkedListObjectArr(),
initUserInfoObjs = CollectionUtil.linkedListObjectArr();
LinkedList<String> toMqSqls = CollectionUtil.linkedListString();
LinkedList<Object[]> initUserObjs = CollectionUtil.linkedListObjectArr(),
initUserInfoObjs = CollectionUtil.linkedListObjectArr();
s = System.currentTimeMillis();
toMqSqls.add(SqlMapping.get("adam_user.add"));
initUserObjs.add(new Object[]{userInfoVo.getUid(), userInfoVo.getMobile(), userInfoVo.getState(), 0, now});
toMqSqls.add(SqlMapping.get("adam_user_info.add"));
initUserInfoObjs.add(new Object[]{userInfoVo.getUid(), userInfoVo.getNickname(), null, userInfoVo.getQrCode()});
log.debug("#SQL.GET耗时:{}ms", System.currentTimeMillis() - s);
queueUtils.sendMsgByRedis(MQConst.AdamQueue.SQL_UREGISTER.getKey(),
SqlMapping.gets(toMqSqls, initUserObjs, initUserInfoObjs)
);
log.debug("#MQ耗时:{}ms", System.currentTimeMillis() - s);
} else {
userInfoVo = adamRdmService.getUserInfoVoByUid(uid);
}
// RedisLockUtil.unlock(LOCK_KEY_UREGISTER + mobile);
// }
s = System.currentTimeMillis();
toMqSqls.add(SqlMapping.get("adam_user.add"));
initUserObjs.add(new Object[]{userInfoVo.getUid(), userInfoVo.getMobile(), userInfoVo.getState(), 0, now});
toMqSqls.add(SqlMapping.get("adam_user_info.add"));
initUserInfoObjs.add(new Object[]{userInfoVo.getUid(), userInfoVo.getNickname(), null, userInfoVo.getQrCode()});
log.debug("#SQL.GET耗时:{}ms", System.currentTimeMillis() - s);
queueUtils.sendMsgByRedis(MQConst.AdamQueue.SQL_UREGISTER.getKey(),
SqlMapping.gets(toMqSqls, initUserObjs, initUserInfoObjs)
);
log.debug("#MQ耗时:{}ms", System.currentTimeMillis() - s);
return userInfoVo;
}
@Override
// @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public AdamUserInfoVo register(AdamThirdPartParam param) {
public ResponseDto<AdamUserInfoVo> register(AdamThirdPartParam param) {
LocalDateTime now = LocalDateTime.now();
AdamUserInfoVo userInfoVo = null;
// if (RedisLockUtil.tryLock(LOCK_KEY_UREGISTER + param.getOpenId() + param.getPlatform(), 1, 5)) {
String uid = adamRdmService.getUidByPlatformOpenId(param.getPlatform(), param.getOpenId());
if (StringUtils.isEmpty(uid)) {
long s = System.currentTimeMillis();
uid = adamRdmService.getUidByMobile(param.getMobile());
log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s);
LinkedList<String> toMqSqls = CollectionUtil.linkedListString();
LinkedList<Object[]> initUserObjs = CollectionUtil.linkedListObjectArr(),
initUserInfoObjs = CollectionUtil.linkedListObjectArr(),
initThirdPartObjs = CollectionUtil.linkedListObjectArr();
if (StringUtils.isEmpty(uid)) {// 手机号未注册
userInfoVo = AdamUserInfoVo.getNew();
userInfoVo.setUid(IDGenerator.nextSnowId() + "");
userInfoVo.setMobile(param.getMobile());
userInfoVo.setNickname(param.getNickname());
userInfoVo.setAvatar(param.getAvatar());
userInfoVo.setIsComplete(0);
userInfoVo.setState(1);
userInfoVo.setQrCode("lN".concat(userInfoVo.getUid()).concat(RandomStringUtils.randomAlphanumeric(5).toUpperCase()));
userInfoVo.setCreateAt(now);
long s = System.currentTimeMillis();
String uid = adamRdmService.getUidByMobile(param.getMobile());
log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s);
LinkedList<String> toMqSqls = CollectionUtil.linkedListString();
LinkedList<Object[]> initUserObjs = CollectionUtil.linkedListObjectArr(),
initUserInfoObjs = CollectionUtil.linkedListObjectArr(),
initThirdPartObjs = CollectionUtil.linkedListObjectArr();
if (StringUtils.isEmpty(uid)) {// 手机号未注册
userInfoVo = AdamUserInfoVo.getNew();
userInfoVo.setUid(IDGenerator.nextSnowId() + "");
userInfoVo.setMobile(param.getMobile());
userInfoVo.setNickname(param.getNickname());
userInfoVo.setAvatar(param.getAvatar());
userInfoVo.setIsComplete(0);
userInfoVo.setState(1);
userInfoVo.setQrCode("lN".concat(userInfoVo.getUid()).concat(RandomStringUtils.randomAlphanumeric(5).toUpperCase()));
userInfoVo.setCreateAt(now);
// s = System.currentTimeMillis();
// mongoTemplate.insert(userInfoVo, AdamUserInfoVo.class.getSimpleName());
// log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
userInfoVo.setMobile(SensitizeUtil.custom(param.getMobile(), 3, 4));
adamRdmService.setUserInfoVoByUid(userInfoVo.getUid(), userInfoVo);
toMqSqls.add(SqlMapping.get("adam_user.add"));
initUserObjs.add(new Object[]{userInfoVo.getUid(), userInfoVo.getMobile(), userInfoVo.getState(), now});
toMqSqls.add(SqlMapping.get("adam_user_info.add"));
initUserInfoObjs.add(new Object[]{userInfoVo.getUid(), userInfoVo.getNickname(), userInfoVo.getAvatar(), userInfoVo.getQrCode()});
} else {
s = System.currentTimeMillis();
userInfoVo = adamRdmService.getUserInfoVoByUid(uid);
log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s);
toMqSqls.add(SqlMapping.get("adam_user.add"));
toMqSqls.add(SqlMapping.get("adam_user_info.add"));
}
AdamThirdPartInfoVo thirdPartInfoVo = AdamThirdPartInfoVo.getNew();
BeanUtils.copyProperties(param, thirdPartInfoVo);
thirdPartInfoVo.setCreatedAt(now);
thirdPartInfoVo.setUid(userInfoVo.getUid());
thirdPartInfoVo.setState(1);// 1-绑定
// s = System.currentTimeMillis();
// mongoTemplate.insert(thirdPartInfoVo, AdamThirdPartInfoVo.class.getSimpleName());
// log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
userInfoVo.setMobile(SensitizeUtil.custom(param.getMobile(), 3, 4));
toMqSqls.add(SqlMapping.get("adam_third_party.add"));
initThirdPartObjs.add(new Object[]{thirdPartInfoVo.getUid(), thirdPartInfoVo.getOpenId(), thirdPartInfoVo.getAvatar(), thirdPartInfoVo.getNickname(), thirdPartInfoVo.getPlatform(), thirdPartInfoVo.getState(), thirdPartInfoVo.getCreatedAt()});
adamRdmService.setUserInfoVoByUid(userInfoVo.getUid(), userInfoVo);
s = System.currentTimeMillis();
adamRdmService.setUidByPlatformOpenId(param.getPlatform(), param.getOpenId(), uid);
log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s);
toMqSqls.add(SqlMapping.get("adam_user.add"));
initUserObjs.add(new Object[]{userInfoVo.getUid(), userInfoVo.getMobile(), userInfoVo.getState(), now});
toMqSqls.add(SqlMapping.get("adam_user_info.add"));
initUserInfoObjs.add(new Object[]{userInfoVo.getUid(), userInfoVo.getNickname(), userInfoVo.getAvatar(), userInfoVo.getQrCode()});
s = System.currentTimeMillis();
queueUtils.sendMsgByRedis(MQConst.AdamQueue.SQL_UREGISTER.getKey(),
SqlMapping.gets(toMqSqls, initUserObjs, initUserInfoObjs, initThirdPartObjs)
);
log.debug("#MQ耗时:{}ms", System.currentTimeMillis() - s);
} else {
AdamThirdPartInfoVo thirdPartInfoVo = AdamThirdPartInfoVo.getNew();
BeanUtils.copyProperties(param, thirdPartInfoVo);
thirdPartInfoVo.setCreatedAt(now);
thirdPartInfoVo.setUid(userInfoVo.getUid());
thirdPartInfoVo.setState(1);// 1-绑定
// s = System.currentTimeMillis();
// mongoTemplate.insert(thirdPartInfoVo, AdamThirdPartInfoVo.class.getSimpleName());
// log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
toMqSqls.add(SqlMapping.get("adam_third_party.add"));
initThirdPartObjs.add(new Object[]{thirdPartInfoVo.getUid(), thirdPartInfoVo.getOpenId(), thirdPartInfoVo.getAvatar(), thirdPartInfoVo.getNickname(), thirdPartInfoVo.getPlatform(), thirdPartInfoVo.getState(), thirdPartInfoVo.getCreatedAt()});
s = System.currentTimeMillis();
adamRdmService.setUidByPlatformOpenId(param.getPlatform(), param.getOpenId(), uid);
log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s);
s = System.currentTimeMillis();
queueUtils.sendMsgByRedis(MQConst.AdamQueue.SQL_UREGISTER.getKey(),
SqlMapping.gets(toMqSqls, initUserObjs, initUserInfoObjs, initThirdPartObjs)
);
log.debug("#MQ耗时:{}ms", System.currentTimeMillis() - s);
} else {// 手机号已注册
// 判断已注册用户是否绑定同平台的第三方账号
AdamThirdPartInfoVo thirdPartVo = adamRdmService.getThirdPartVoByUidPlatform(uid, param.getPlatform());
if (null == thirdPartVo) {// 未绑定
this.bindTpa(uid, param);
userInfoVo = adamRdmService.getUserInfoVoByUid(uid);
} else if (thirdPartVo.getOpenId().equals(param.getOpenId())) {
userInfoVo = adamRdmService.getUserInfoVoByUid(uid);
} else {
return ResponseDto.failure(ErrorMapping.get("10007"));
}
// RedisLockUtil.unlock(LOCK_KEY_UREGISTER + param.getOpenId() + param.getPlatform());
// }
return userInfoVo;
}
return ResponseDto.success(userInfoVo);
}
@Override
......@@ -206,7 +197,8 @@ public class AdamUserServiceImpl implements IAdamUserService {
log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s);
s = System.currentTimeMillis();
adamRdmService.delThirdPartVoListByUid(uid);
// adamRdmService.delThirdPartVoListByUid(uid);
adamRdmService.addThirdPartVoListByUid(uid, adamRdmService.getThirdPartVoListByUid(uid), thirdPartInfoVo);
log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s);
s = System.currentTimeMillis();
......@@ -226,22 +218,24 @@ public class AdamUserServiceImpl implements IAdamUserService {
LocalDateTime now = LocalDateTime.now();
AdamThirdPartInfoVo thirdPartInfoVo = AdamThirdPartInfoVo.getNew();
BeanUtils.copyProperties(param, thirdPartInfoVo);
thirdPartInfoVo.setCreatedAt(now);
thirdPartInfoVo.setUid(bindUid);
thirdPartInfoVo.setState(1);// 1-绑定
AdamThirdPartInfoVo bindThirdPartVo = AdamThirdPartInfoVo.getNew();
BeanUtils.copyProperties(param, bindThirdPartVo);
bindThirdPartVo.setCreatedAt(now);
bindThirdPartVo.setUid(bindUid);
bindThirdPartVo.setState(1);// 1-绑定
// mongoTemplate.insert(thirdPartInfoVo, AdamThirdPartInfoVo.class.getSimpleName());
// mongoTemplate.insert(bindThirdPartVo, AdamThirdPartInfoVo.class.getSimpleName());
adamRdmService.setUidByPlatformOpenId(param.getPlatform(), param.getOpenId(), bindUid);
adamRdmService.delThirdPartVoListByUid(bindUid);
// adamRdmService.delThirdPartVoListByUid(bindUid);
adamRdmService.rmvThirdPartVoListByUid(unBindUid, adamRdmService.getThirdPartVoListByUid(unBindUid), param.getPlatform());
adamRdmService.addThirdPartVoListByUid(bindUid, adamRdmService.getThirdPartVoListByUid(bindUid), bindThirdPartVo);
queueUtils.sendMsgByRedis(MQConst.AdamQueue.SQL_UCENTER.getKey(),
SqlMapping.get(
"adam_third_party.add",
thirdPartInfoVo.getUid(), thirdPartInfoVo.getOpenId(), thirdPartInfoVo.getAvatar(), thirdPartInfoVo.getNickname(), thirdPartInfoVo.getPlatform(), thirdPartInfoVo.getState(), thirdPartInfoVo.getCreatedAt()
bindThirdPartVo.getUid(), bindThirdPartVo.getOpenId(), bindThirdPartVo.getAvatar(), bindThirdPartVo.getNickname(), bindThirdPartVo.getPlatform(), bindThirdPartVo.getState(), bindThirdPartVo.getCreatedAt()
)
);
}
......@@ -272,18 +266,22 @@ public class AdamUserServiceImpl implements IAdamUserService {
// adamRdmService.delUidByPlatformOpenId(platform, doc.getString("openId"));
// }
long s = System.currentTimeMillis();
AdamThirdPartInfoVo unBindTpaVo = adamRdmService.getThirdPartVoByUidPlatform(uid, platform);
if (null != unBindTpaVo) {
adamRdmService.delUidByPlatformOpenId(platform, unBindTpaVo.getOpenId());
List<AdamThirdPartInfoVo> vos = adamRdmService.getThirdPartVoListByUid(uid);
if (!CollectionUtils.isEmpty(vos)) {
AdamThirdPartInfoVo unBindTpaVo = adamRdmService.getThirdPartVoByUidPlatform(vos, platform);
if (null != unBindTpaVo) {
adamRdmService.delUidByPlatformOpenId(platform, unBindTpaVo.getOpenId());
adamRdmService.rmvThirdPartVoListByUid(uid, vos, platform);
s = System.currentTimeMillis();
queueUtils.sendMsgByRedis(MQConst.AdamQueue.SQL_UCENTER.getKey(),
SqlMapping.get("adam_third_party.unbind", now, uid, platform)
);
log.debug("#MQ耗时:{}ms", System.currentTimeMillis() - s);
}
}
adamRdmService.delThirdPartVoListByUid(uid);
log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s);
s = System.currentTimeMillis();
queueUtils.sendMsgByRedis(MQConst.AdamQueue.SQL_UCENTER.getKey(),
SqlMapping.get("adam_third_party.unbind", now, uid, platform)
);
log.debug("#MQ耗时:{}ms", System.currentTimeMillis() - s);
}
@Override
......@@ -336,8 +334,8 @@ public class AdamUserServiceImpl implements IAdamUserService {
// deleteResult = mongoTemplate.remove(Query.query(Criteria.where("uid").is(uid)), AdamUserMemberVo.class.getSimpleName());
// log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
// if (deleteResult.getDeletedCount() > 0) {
toMqSqls.add(SqlMapping.get("adam_user_member.close"));
objsThirdPart.add(new Object[]{now, uid});
toMqSqls.add(SqlMapping.get("adam_user_member.close"));
objsThirdPart.add(new Object[]{now, uid});
// }
/* ---------------------- 收货地址信息 */
......@@ -345,8 +343,8 @@ public class AdamUserServiceImpl implements IAdamUserService {
// deleteResult = mongoTemplate.remove(Query.query(Criteria.where("uid").is(uid)), AdamAddressesVo.class.getSimpleName());
// log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
// if (deleteResult.getDeletedCount() > 0) {
toMqSqls.add(SqlMapping.get("adam_addresses.close"));
objsAddresses.add(new Object[]{now, now, uid});
toMqSqls.add(SqlMapping.get("adam_addresses.close"));
objsAddresses.add(new Object[]{now, now, uid});
// }
/* ---------------------- 入场人信息 */
......@@ -354,8 +352,8 @@ public class AdamUserServiceImpl implements IAdamUserService {
// deleteResult = mongoTemplate.remove(Query.query(Criteria.where("uid").is(uid)).getQueryObject(), AdamEnters.class.getSimpleName());
// log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
// if (deleteResult.getDeletedCount() > 0) {
toMqSqls.add(SqlMapping.get("adam_enters.close"));
objsAddresses.add(new Object[]{now, now, uid});
toMqSqls.add(SqlMapping.get("adam_enters.close"));
objsAddresses.add(new Object[]{now, now, uid});
// }
s = System.currentTimeMillis();
......@@ -370,10 +368,7 @@ public class AdamUserServiceImpl implements IAdamUserService {
// @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public AdamRealInfoVo identity(String uid, String name, String idCard) {
AdamRealInfoVo vo = null;
// if (RedisLockUtil.tryLock(AdamRedisConst.LOCK_KEY_UIDENTITY + uid, 1, 3)) {
// vo = adamRdmService.getRealInfoVoByUid(uid);
// if (null == vo) {
if (!adamRdmService.isCertification(1, idCard, name)) {
if (!adamRdmService.isCertification(1, idCard, name)) {
// String respStr = null;
// try {
// LinkedMultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
......@@ -394,39 +389,36 @@ public class AdamUserServiceImpl implements IAdamUserService {
// ErrorMapping.ErrorMessage errorMessage = ErrorMapping.get("10102");
// throw new LiquidnetServiceException(errorMessage.getCode(), errorMessage.getMessage());
// }
String respStr = IdentityUtils.aliThird(name, idCard);
JsonNode respJNode = JsonUtils.fromJson(respStr, JsonNode.class);
if (null == respJNode || !"0".equals(respJNode.get("error_code").asText())) {
log.info("###实名认证失败[{}]", respStr);
ErrorMapping.ErrorMessage errorMessage = ErrorMapping.get("10102");
throw new LiquidnetServiceException(errorMessage.getCode(), errorMessage.getMessage());
}
adamRdmService.setCertification(1, idCard, name);
}
AdamRealName realName = new AdamRealName();
realName.setRealNameId(IDGenerator.nextSnowId() + "");
realName.setUid(uid);
realName.setType(1);
realName.setName(name);
realName.setIdCard(idCard);
realName.setState(1);
realName.setCreatedAt(LocalDateTime.now());
adamRealNameService.add(realName);
vo = AdamRealInfoVo.getNew();
vo.setUid(uid);
vo.setName(name);
vo.setIdCard(idCard);
vo.setType(realName.getType());
vo.setState(1);
long s = System.currentTimeMillis();
adamRdmService.setRealInfoVoByUid(uid, vo);
log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s);
// }
// RedisLockUtil.unlock(AdamRedisConst.LOCK_KEY_UIDENTITY + uid);
// }
String respStr = IdentityUtils.aliThird(name, idCard);
JsonNode respJNode = JsonUtils.fromJson(respStr, JsonNode.class);
if (null == respJNode || !"0".equals(respJNode.get("error_code").asText())) {
log.info("###实名认证失败[{}]", respStr);
ErrorMapping.ErrorMessage errorMessage = ErrorMapping.get("10102");
throw new LiquidnetServiceException(errorMessage.getCode(), errorMessage.getMessage());
}
adamRdmService.setCertification(1, idCard, name);
}
AdamRealName realName = new AdamRealName();
realName.setRealNameId(IDGenerator.nextSnowId() + "");
realName.setUid(uid);
realName.setType(1);
realName.setName(name);
realName.setIdCard(idCard);
realName.setState(1);
realName.setCreatedAt(LocalDateTime.now());
adamRealNameService.add(realName);
vo = AdamRealInfoVo.getNew();
vo.setUid(uid);
vo.setName(name);
vo.setIdCard(idCard);
vo.setType(realName.getType());
vo.setState(1);
long s = System.currentTimeMillis();
adamRdmService.setRealInfoVoByUid(uid, vo);
log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s);
return vo;
}
}
......@@ -34,8 +34,8 @@ public class QueueUtils {
* @param jsonMsg Json字符串
*/
public void sendMsgByRedis(String streamKey, String jsonMsg) {
// HashMap<String, String> map = CollectionUtil.mapStringString();
// map.put("message", jsonMsg);
// stringRedisTemplate.opsForStream().add(StreamRecords.mapBacked(map).withStreamKey(streamKey));
HashMap<String, String> map = CollectionUtil.mapStringString();
map.put("message", jsonMsg);
stringRedisTemplate.opsForStream().add(StreamRecords.mapBacked(map).withStreamKey(streamKey));
}
}
......@@ -2,9 +2,16 @@ package com.liquidnet.service.dragon.utils;
import com.alipay.api.internal.util.file.IOUtils;
import com.liquidnet.commons.lang.util.MD5Utils;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.DefaultHttpRequestRetryHandler;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.ssl.SSLContexts;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.dom4j.Document;
......@@ -24,6 +31,9 @@ public class PayWepayUtils {
private CloseableHttpClient httpClient;
private static PayWepayUtils instance = new PayWepayUtils();
// 池化管理
private static PoolingHttpClientConnectionManager poolConnManager =null;
private final String merchantId = "1551961491";
private final String partnerKey = "itIuO65O9yKmemOu3S8g1S4orqvCGwXK";
......@@ -65,9 +75,41 @@ public class PayWepayUtils {
return merchantId;
}
// public CloseableHttpClient getHttpClient() {
// try {
// if (httpClient == null) {
// InputStream certStream = PayWepayUtils.class.getClassLoader().getResourceAsStream("payCert/wepay/wepay_apiclient_cert.p12");
// byte[] certData = IOUtils.toByteArray(certStream);
// certStream.read(certData);
// certStream.close();
//
// KeyStore keyStore = KeyStore.getInstance("PKCS12");
// ByteArrayInputStream inputStream = new ByteArrayInputStream(certData);
// try {
// keyStore.load(inputStream, merchantId.toCharArray());
// } finally {
// inputStream.close();
// }
// SSLContext sslcontext = SSLContexts.custom()
// .loadKeyMaterial(keyStore, merchantId.toCharArray())
// .build();
// SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
// sslcontext,
// SSLConnectionSocketFactory.getDefaultHostnameVerifier());
// httpClient = HttpClients.custom()
// .setSSLSocketFactory(sslsf)
// .build();
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
// return httpClient;
// }
public CloseableHttpClient getHttpClient() {
try {
if (httpClient == null) {
InputStream certStream = PayWepayUtils.class.getClassLoader().getResourceAsStream("payCert/wepay/wepay_apiclient_cert.p12");
byte[] certData = IOUtils.toByteArray(certStream);
certStream.read(certData);
......@@ -86,9 +128,17 @@ public class PayWepayUtils {
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
sslcontext,
SSLConnectionSocketFactory.getDefaultHostnameVerifier());
httpClient = HttpClients.custom()
.setSSLSocketFactory(sslsf)
.build();
// 配置同时支持 HTTP 和 HTPPS
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create().register("http", PlainConnectionSocketFactory.getSocketFactory()).register("https", sslsf).build();
// 初始化连接管理器
poolConnManager =new PoolingHttpClientConnectionManager(socketFactoryRegistry);
poolConnManager.setMaxTotal(4000);// 同时最多连接数
// 设置最大路由
poolConnManager.setDefaultMaxPerRoute(2000);
// 初始化httpClient
httpClient = getConnection();
}
} catch (Exception e) {
e.printStackTrace();
......@@ -96,6 +146,17 @@ public class PayWepayUtils {
return httpClient;
}
public static CloseableHttpClient getConnection() {
RequestConfig config = RequestConfig.custom().setConnectTimeout(5000).setConnectionRequestTimeout(5000).setSocketTimeout(5000).build();
CloseableHttpClient httpClient = HttpClients.custom()
// 设置连接池管理
.setConnectionManager(poolConnManager)
.setDefaultRequestConfig(config)
// 设置重试次数
.setRetryHandler(new DefaultHttpRequestRetryHandler(2,false)).build();
return httpClient;
}
//生成随机字符串nonce_str
public String getNonceStr() {
String base = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
......
......@@ -28,8 +28,18 @@ public class SweetAppletController {
@GetMapping("timeSelect")
@ApiOperation("场次选择")
public ResponseDto<List<SweetManualAppletDto>> timeSelect() {
return ResponseDto.success(redisDataUtils.getPushList());
@ApiImplicitParams({
@ApiImplicitParam(type = "query", dataType = "String", name = "name", value = "名称", required = true),
})
public ResponseDto<List<SweetManualAppletDto>> timeSelect(@RequestParam String name) {
List<SweetManualAppletDto> dto = redisDataUtils.getPushList();
List<SweetManualAppletDto> vo = new ArrayList<>();
for (SweetManualAppletDto item : dto) {
if (item.getTitle().contains(name)) {
vo.add(item);
}
}
return ResponseDto.success(vo);
}
@GetMapping("details")
......
......@@ -25,6 +25,15 @@
<result column="time_end" property="timeEnd"/>
</resultMap>
<resultMap id="getManualAppletDtoResult" type="com.liquidnet.service.sweet.dto.SweetManualAppletDto">
<result column="manual_id" property="manualId"/>
<result column="performances_id" property="performancesId"/>
<result column="title" property="title"/>
<result column="field_id" property="fieldId"/>
<result column="time_start" property="timeStart"/>
<result column="time_end" property="timeEnd"/>
</resultMap>
<!-- 电子手册列表 -->
<select id="getManualList" parameterType="java.util.Map" resultMap="partnerPerformanceListResult">
SELECT
......@@ -113,4 +122,37 @@
where sw.`status` = 1
and sw.is_release = 1
</select>
<select id="getManualAppletDto" resultMap="getManualAppletDtoResult">
SELECT
IFNULL(sm.manual_id , 0) AS 'manual_id' ,
p.performances_id ,
p.title ,
pr.field_id ,
p.time_start ,
p.time_end
FROM
kylin_performances AS p
LEFT JOIN kylin_performance_status AS ps ON p.performances_id = ps.performance_id
LEFT JOIN kylin_performance_relations AS pr ON p.performances_id = pr.performance_id
LEFT JOIN sweet_manual AS sm ON p.performances_id = sm.performance_id
LEFT JOIN(
SELECT
ttr.performance_id ,
MIN(
DATE_SUB(
t.time_start ,
INTERVAL pay_countdown_minute MINUTE
)
) AS 'time_sell' ,
MAX(t.time_end) AS 'time_stop'
FROM
kylin_ticket_status AS ts
LEFT JOIN kylin_ticket_relations AS tr ON tr.ticket_id = ts.ticket_id
LEFT JOIN kylin_tickets AS t ON t.tickets_id = ts.ticket_id
LEFT JOIN kylin_ticket_time_relation AS ttr ON tr.times_id = ttr.times_id
GROUP BY
ttr.performance_id
) AS t ON p.performances_id = t.performance_id where sm.`status` = 1 and sm.is_release = 1
</select>
</mapper>
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