记得上下班打卡 | 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; ...@@ -3,6 +3,7 @@ package com.liquidnet.service.adam.service;
import com.liquidnet.service.adam.dto.AdamThirdPartParam; import com.liquidnet.service.adam.dto.AdamThirdPartParam;
import com.liquidnet.service.adam.dto.vo.AdamRealInfoVo; import com.liquidnet.service.adam.dto.vo.AdamRealInfoVo;
import com.liquidnet.service.adam.dto.vo.AdamUserInfoVo; import com.liquidnet.service.adam.dto.vo.AdamUserInfoVo;
import com.liquidnet.service.base.ResponseDto;
/** /**
* <p> * <p>
...@@ -26,9 +27,9 @@ public interface IAdamUserService { ...@@ -26,9 +27,9 @@ public interface IAdamUserService {
* 第三方账号注册 * 第三方账号注册
* *
* @param param * @param param
* @return AdamUserInfoVo * @return ResponseDto<AdamUserInfoVo>
*/ */
AdamUserInfoVo register(AdamThirdPartParam param); ResponseDto<AdamUserInfoVo> register(AdamThirdPartParam param);
/** /**
* 第三方账号绑定(不存在已绑定账号) * 第三方账号绑定(不存在已绑定账号)
......
...@@ -69,7 +69,7 @@ spring: ...@@ -69,7 +69,7 @@ spring:
profiles: profiles:
include: common-service #这里加载management相关公共配置 include: common-service #这里加载management相关公共配置
redis: redis:
database: 9 database: 15
port: ${liquidnet.redis.port} port: ${liquidnet.redis.port}
host: ${liquidnet.redis.host} host: ${liquidnet.redis.host}
password: ${liquidnet.redis.password} password: ${liquidnet.redis.password}
......
...@@ -281,14 +281,16 @@ public class AdamLoginController { ...@@ -281,14 +281,16 @@ public class AdamLoginController {
if (!checkSmsCodeDto.isSuccess()) { if (!checkSmsCodeDto.isSuccess()) {
return checkSmsCodeDto; return checkSmsCodeDto;
} }
AdamUserInfoVo registerUserInfo = adamUserService.register(parameter); ResponseDto<AdamUserInfoVo> registerRespDto = adamUserService.register(parameter);
if (null == registerUserInfo) { if (!registerRespDto.isSuccess()) {
return ResponseDto.failure(ErrorMapping.get("10000")); 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; toRegister = true;
loginInfoVo.setUserInfo(registerUserInfo);
loginInfoVo.setThirdPartInfo(adamRdmService.getThirdPartVoListByUid(registerUserInfo.getUid()));
// loginInfoVo.setMemberVo(adamRdmService.getMemberSimpleVo());
} }
loginInfoVo.setToken(this.ssoProcess(loginInfoVo.getUserInfo())); loginInfoVo.setToken(this.ssoProcess(loginInfoVo.getUserInfo()));
loginInfoVo.getUserInfo().setMobile(SensitizeUtil.custom(loginInfoVo.getUserInfo().getMobile(), 3, 4)); loginInfoVo.getUserInfo().setMobile(SensitizeUtil.custom(loginInfoVo.getUserInfo().getMobile(), 3, 4));
......
...@@ -197,6 +197,24 @@ public class AdamRdmService { ...@@ -197,6 +197,24 @@ public class AdamRdmService {
return redisUtil.set(AdamRedisConst.INFO_THIRD_PARTY + uid, vos); 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) { public AdamThirdPartInfoVo getThirdPartVoByUidPlatform(String uid, String platform) {
List<AdamThirdPartInfoVo> vos = this.getThirdPartVoListByUid(uid); List<AdamThirdPartInfoVo> vos = this.getThirdPartVoListByUid(uid);
if (!CollectionUtils.isEmpty(vos)) { if (!CollectionUtils.isEmpty(vos)) {
......
...@@ -15,6 +15,7 @@ import com.liquidnet.service.adam.service.IAdamUserService; ...@@ -15,6 +15,7 @@ import com.liquidnet.service.adam.service.IAdamUserService;
import com.liquidnet.service.adam.util.NknameUtil; import com.liquidnet.service.adam.util.NknameUtil;
import com.liquidnet.service.adam.util.QueueUtils; import com.liquidnet.service.adam.util.QueueUtils;
import com.liquidnet.service.base.ErrorMapping; import com.liquidnet.service.base.ErrorMapping;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.base.SqlMapping; import com.liquidnet.service.base.SqlMapping;
import com.liquidnet.service.base.constant.MQConst; import com.liquidnet.service.base.constant.MQConst;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -64,126 +65,116 @@ public class AdamUserServiceImpl implements IAdamUserService { ...@@ -64,126 +65,116 @@ public class AdamUserServiceImpl implements IAdamUserService {
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
AdamUserInfoVo userInfoVo = null; AdamUserInfoVo userInfoVo = null;
// if (RedisLockUtil.tryLock(LOCK_KEY_UREGISTER + mobile, 1, 5)) { userInfoVo = AdamUserInfoVo.getNew();
String uid = adamRdmService.getUidByMobile(mobile); userInfoVo.setUid(IDGenerator.nextSnowId() + "");
if (StringUtils.isEmpty(uid)) { userInfoVo.setMobile(mobile);
userInfoVo = AdamUserInfoVo.getNew(); userInfoVo.setNickname(NknameUtil.randomNkname());
userInfoVo.setUid(IDGenerator.nextSnowId() + ""); userInfoVo.setIsComplete(0);
userInfoVo.setMobile(mobile); userInfoVo.setState(1);
userInfoVo.setNickname(NknameUtil.randomNkname()); userInfoVo.setQrCode("lN".concat(userInfoVo.getUid()).concat(RandomStringUtils.randomAlphanumeric(5).toUpperCase()));
userInfoVo.setIsComplete(0); userInfoVo.setCreateAt(now);
userInfoVo.setState(1);
userInfoVo.setQrCode("lN".concat(userInfoVo.getUid()).concat(RandomStringUtils.randomAlphanumeric(5).toUpperCase()));
userInfoVo.setCreateAt(now);
// long s = System.currentTimeMillis(); // long s = System.currentTimeMillis();
// mongoTemplate.insert(userInfoVo, AdamUserInfoVo.class.getSimpleName()); // mongoTemplate.insert(userInfoVo, AdamUserInfoVo.class.getSimpleName());
// log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s); // log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
long s = System.currentTimeMillis(); long s = System.currentTimeMillis();
adamRdmService.setUidByMobile(mobile, userInfoVo.getUid()); adamRdmService.setUidByMobile(mobile, userInfoVo.getUid());
adamRdmService.setUserInfoVoByUid(userInfoVo.getUid(), userInfoVo); adamRdmService.setUserInfoVoByUid(userInfoVo.getUid(), userInfoVo);
log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s); log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s);
LinkedList<String> toMqSqls = CollectionUtil.linkedListString(); LinkedList<String> toMqSqls = CollectionUtil.linkedListString();
LinkedList<Object[]> initUserObjs = CollectionUtil.linkedListObjectArr(), LinkedList<Object[]> initUserObjs = CollectionUtil.linkedListObjectArr(),
initUserInfoObjs = CollectionUtil.linkedListObjectArr(); initUserInfoObjs = CollectionUtil.linkedListObjectArr();
s = System.currentTimeMillis(); s = System.currentTimeMillis();
toMqSqls.add(SqlMapping.get("adam_user.add")); toMqSqls.add(SqlMapping.get("adam_user.add"));
initUserObjs.add(new Object[]{userInfoVo.getUid(), userInfoVo.getMobile(), userInfoVo.getState(), 0, now}); initUserObjs.add(new Object[]{userInfoVo.getUid(), userInfoVo.getMobile(), userInfoVo.getState(), 0, now});
toMqSqls.add(SqlMapping.get("adam_user_info.add")); toMqSqls.add(SqlMapping.get("adam_user_info.add"));
initUserInfoObjs.add(new Object[]{userInfoVo.getUid(), userInfoVo.getNickname(), null, userInfoVo.getQrCode()}); initUserInfoObjs.add(new Object[]{userInfoVo.getUid(), userInfoVo.getNickname(), null, userInfoVo.getQrCode()});
log.debug("#SQL.GET耗时:{}ms", System.currentTimeMillis() - s); log.debug("#SQL.GET耗时:{}ms", System.currentTimeMillis() - s);
queueUtils.sendMsgByRedis(MQConst.AdamQueue.SQL_UREGISTER.getKey(), queueUtils.sendMsgByRedis(MQConst.AdamQueue.SQL_UREGISTER.getKey(),
SqlMapping.gets(toMqSqls, initUserObjs, initUserInfoObjs) SqlMapping.gets(toMqSqls, initUserObjs, initUserInfoObjs)
); );
log.debug("#MQ耗时:{}ms", System.currentTimeMillis() - s); log.debug("#MQ耗时:{}ms", System.currentTimeMillis() - s);
} else {
userInfoVo = adamRdmService.getUserInfoVoByUid(uid);
}
// RedisLockUtil.unlock(LOCK_KEY_UREGISTER + mobile);
// }
return userInfoVo; return userInfoVo;
} }
@Override @Override
// @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) // @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public AdamUserInfoVo register(AdamThirdPartParam param) { public ResponseDto<AdamUserInfoVo> register(AdamThirdPartParam param) {
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
AdamUserInfoVo userInfoVo = null; AdamUserInfoVo userInfoVo = null;
// if (RedisLockUtil.tryLock(LOCK_KEY_UREGISTER + param.getOpenId() + param.getPlatform(), 1, 5)) { long s = System.currentTimeMillis();
String uid = adamRdmService.getUidByPlatformOpenId(param.getPlatform(), param.getOpenId()); String uid = adamRdmService.getUidByMobile(param.getMobile());
if (StringUtils.isEmpty(uid)) { log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s);
long s = System.currentTimeMillis(); LinkedList<String> toMqSqls = CollectionUtil.linkedListString();
uid = adamRdmService.getUidByMobile(param.getMobile()); LinkedList<Object[]> initUserObjs = CollectionUtil.linkedListObjectArr(),
log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s); initUserInfoObjs = CollectionUtil.linkedListObjectArr(),
LinkedList<String> toMqSqls = CollectionUtil.linkedListString(); initThirdPartObjs = CollectionUtil.linkedListObjectArr();
LinkedList<Object[]> initUserObjs = CollectionUtil.linkedListObjectArr(), if (StringUtils.isEmpty(uid)) {// 手机号未注册
initUserInfoObjs = CollectionUtil.linkedListObjectArr(), userInfoVo = AdamUserInfoVo.getNew();
initThirdPartObjs = CollectionUtil.linkedListObjectArr();
if (StringUtils.isEmpty(uid)) {// 手机号未注册 userInfoVo.setUid(IDGenerator.nextSnowId() + "");
userInfoVo = AdamUserInfoVo.getNew(); userInfoVo.setMobile(param.getMobile());
userInfoVo.setNickname(param.getNickname());
userInfoVo.setUid(IDGenerator.nextSnowId() + ""); userInfoVo.setAvatar(param.getAvatar());
userInfoVo.setMobile(param.getMobile()); userInfoVo.setIsComplete(0);
userInfoVo.setNickname(param.getNickname()); userInfoVo.setState(1);
userInfoVo.setAvatar(param.getAvatar()); userInfoVo.setQrCode("lN".concat(userInfoVo.getUid()).concat(RandomStringUtils.randomAlphanumeric(5).toUpperCase()));
userInfoVo.setIsComplete(0); userInfoVo.setCreateAt(now);
userInfoVo.setState(1);
userInfoVo.setQrCode("lN".concat(userInfoVo.getUid()).concat(RandomStringUtils.randomAlphanumeric(5).toUpperCase()));
userInfoVo.setCreateAt(now);
// s = System.currentTimeMillis(); // s = System.currentTimeMillis();
// mongoTemplate.insert(userInfoVo, AdamUserInfoVo.class.getSimpleName()); // mongoTemplate.insert(userInfoVo, AdamUserInfoVo.class.getSimpleName());
// log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s); // log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
userInfoVo.setMobile(SensitizeUtil.custom(param.getMobile(), 3, 4)); 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);
toMqSqls.add(SqlMapping.get("adam_third_party.add")); adamRdmService.setUserInfoVoByUid(userInfoVo.getUid(), userInfoVo);
initThirdPartObjs.add(new Object[]{thirdPartInfoVo.getUid(), thirdPartInfoVo.getOpenId(), thirdPartInfoVo.getAvatar(), thirdPartInfoVo.getNickname(), thirdPartInfoVo.getPlatform(), thirdPartInfoVo.getState(), thirdPartInfoVo.getCreatedAt()});
s = System.currentTimeMillis(); toMqSqls.add(SqlMapping.get("adam_user.add"));
adamRdmService.setUidByPlatformOpenId(param.getPlatform(), param.getOpenId(), uid); initUserObjs.add(new Object[]{userInfoVo.getUid(), userInfoVo.getMobile(), userInfoVo.getState(), now});
log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s); toMqSqls.add(SqlMapping.get("adam_user_info.add"));
initUserInfoObjs.add(new Object[]{userInfoVo.getUid(), userInfoVo.getNickname(), userInfoVo.getAvatar(), userInfoVo.getQrCode()});
s = System.currentTimeMillis(); AdamThirdPartInfoVo thirdPartInfoVo = AdamThirdPartInfoVo.getNew();
queueUtils.sendMsgByRedis(MQConst.AdamQueue.SQL_UREGISTER.getKey(), BeanUtils.copyProperties(param, thirdPartInfoVo);
SqlMapping.gets(toMqSqls, initUserObjs, initUserInfoObjs, initThirdPartObjs) thirdPartInfoVo.setCreatedAt(now);
); thirdPartInfoVo.setUid(userInfoVo.getUid());
log.debug("#MQ耗时:{}ms", System.currentTimeMillis() - s); thirdPartInfoVo.setState(1);// 1-绑定
} else {
// 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); userInfoVo = adamRdmService.getUserInfoVoByUid(uid);
} else {
return ResponseDto.failure(ErrorMapping.get("10007"));
} }
// RedisLockUtil.unlock(LOCK_KEY_UREGISTER + param.getOpenId() + param.getPlatform()); }
// } return ResponseDto.success(userInfoVo);
return userInfoVo;
} }
@Override @Override
...@@ -206,7 +197,8 @@ public class AdamUserServiceImpl implements IAdamUserService { ...@@ -206,7 +197,8 @@ public class AdamUserServiceImpl implements IAdamUserService {
log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s); log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s);
s = System.currentTimeMillis(); s = System.currentTimeMillis();
adamRdmService.delThirdPartVoListByUid(uid); // adamRdmService.delThirdPartVoListByUid(uid);
adamRdmService.addThirdPartVoListByUid(uid, adamRdmService.getThirdPartVoListByUid(uid), thirdPartInfoVo);
log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s); log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s);
s = System.currentTimeMillis(); s = System.currentTimeMillis();
...@@ -226,22 +218,24 @@ public class AdamUserServiceImpl implements IAdamUserService { ...@@ -226,22 +218,24 @@ public class AdamUserServiceImpl implements IAdamUserService {
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
AdamThirdPartInfoVo thirdPartInfoVo = AdamThirdPartInfoVo.getNew(); AdamThirdPartInfoVo bindThirdPartVo = AdamThirdPartInfoVo.getNew();
BeanUtils.copyProperties(param, thirdPartInfoVo); BeanUtils.copyProperties(param, bindThirdPartVo);
thirdPartInfoVo.setCreatedAt(now); bindThirdPartVo.setCreatedAt(now);
thirdPartInfoVo.setUid(bindUid); bindThirdPartVo.setUid(bindUid);
thirdPartInfoVo.setState(1);// 1-绑定 bindThirdPartVo.setState(1);// 1-绑定
// mongoTemplate.insert(thirdPartInfoVo, AdamThirdPartInfoVo.class.getSimpleName()); // mongoTemplate.insert(bindThirdPartVo, AdamThirdPartInfoVo.class.getSimpleName());
adamRdmService.setUidByPlatformOpenId(param.getPlatform(), param.getOpenId(), bindUid); 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(), queueUtils.sendMsgByRedis(MQConst.AdamQueue.SQL_UCENTER.getKey(),
SqlMapping.get( SqlMapping.get(
"adam_third_party.add", "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 { ...@@ -272,18 +266,22 @@ public class AdamUserServiceImpl implements IAdamUserService {
// adamRdmService.delUidByPlatformOpenId(platform, doc.getString("openId")); // adamRdmService.delUidByPlatformOpenId(platform, doc.getString("openId"));
// } // }
long s = System.currentTimeMillis(); long s = System.currentTimeMillis();
AdamThirdPartInfoVo unBindTpaVo = adamRdmService.getThirdPartVoByUidPlatform(uid, platform); List<AdamThirdPartInfoVo> vos = adamRdmService.getThirdPartVoListByUid(uid);
if (null != unBindTpaVo) { if (!CollectionUtils.isEmpty(vos)) {
adamRdmService.delUidByPlatformOpenId(platform, unBindTpaVo.getOpenId()); 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); 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 @Override
...@@ -336,8 +334,8 @@ public class AdamUserServiceImpl implements IAdamUserService { ...@@ -336,8 +334,8 @@ public class AdamUserServiceImpl implements IAdamUserService {
// deleteResult = mongoTemplate.remove(Query.query(Criteria.where("uid").is(uid)), AdamUserMemberVo.class.getSimpleName()); // deleteResult = mongoTemplate.remove(Query.query(Criteria.where("uid").is(uid)), AdamUserMemberVo.class.getSimpleName());
// log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s); // log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
// if (deleteResult.getDeletedCount() > 0) { // if (deleteResult.getDeletedCount() > 0) {
toMqSqls.add(SqlMapping.get("adam_user_member.close")); toMqSqls.add(SqlMapping.get("adam_user_member.close"));
objsThirdPart.add(new Object[]{now, uid}); objsThirdPart.add(new Object[]{now, uid});
// } // }
/* ---------------------- 收货地址信息 */ /* ---------------------- 收货地址信息 */
...@@ -345,8 +343,8 @@ public class AdamUserServiceImpl implements IAdamUserService { ...@@ -345,8 +343,8 @@ public class AdamUserServiceImpl implements IAdamUserService {
// deleteResult = mongoTemplate.remove(Query.query(Criteria.where("uid").is(uid)), AdamAddressesVo.class.getSimpleName()); // deleteResult = mongoTemplate.remove(Query.query(Criteria.where("uid").is(uid)), AdamAddressesVo.class.getSimpleName());
// log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s); // log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
// if (deleteResult.getDeletedCount() > 0) { // if (deleteResult.getDeletedCount() > 0) {
toMqSqls.add(SqlMapping.get("adam_addresses.close")); toMqSqls.add(SqlMapping.get("adam_addresses.close"));
objsAddresses.add(new Object[]{now, now, uid}); objsAddresses.add(new Object[]{now, now, uid});
// } // }
/* ---------------------- 入场人信息 */ /* ---------------------- 入场人信息 */
...@@ -354,8 +352,8 @@ public class AdamUserServiceImpl implements IAdamUserService { ...@@ -354,8 +352,8 @@ public class AdamUserServiceImpl implements IAdamUserService {
// deleteResult = mongoTemplate.remove(Query.query(Criteria.where("uid").is(uid)).getQueryObject(), AdamEnters.class.getSimpleName()); // deleteResult = mongoTemplate.remove(Query.query(Criteria.where("uid").is(uid)).getQueryObject(), AdamEnters.class.getSimpleName());
// log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s); // log.debug("#MDB耗时:{}ms", System.currentTimeMillis() - s);
// if (deleteResult.getDeletedCount() > 0) { // if (deleteResult.getDeletedCount() > 0) {
toMqSqls.add(SqlMapping.get("adam_enters.close")); toMqSqls.add(SqlMapping.get("adam_enters.close"));
objsAddresses.add(new Object[]{now, now, uid}); objsAddresses.add(new Object[]{now, now, uid});
// } // }
s = System.currentTimeMillis(); s = System.currentTimeMillis();
...@@ -370,10 +368,7 @@ public class AdamUserServiceImpl implements IAdamUserService { ...@@ -370,10 +368,7 @@ public class AdamUserServiceImpl implements IAdamUserService {
// @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) // @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public AdamRealInfoVo identity(String uid, String name, String idCard) { public AdamRealInfoVo identity(String uid, String name, String idCard) {
AdamRealInfoVo vo = null; AdamRealInfoVo vo = null;
// if (RedisLockUtil.tryLock(AdamRedisConst.LOCK_KEY_UIDENTITY + uid, 1, 3)) { if (!adamRdmService.isCertification(1, idCard, name)) {
// vo = adamRdmService.getRealInfoVoByUid(uid);
// if (null == vo) {
if (!adamRdmService.isCertification(1, idCard, name)) {
// String respStr = null; // String respStr = null;
// try { // try {
// LinkedMultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); // LinkedMultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
...@@ -394,39 +389,36 @@ public class AdamUserServiceImpl implements IAdamUserService { ...@@ -394,39 +389,36 @@ public class AdamUserServiceImpl implements IAdamUserService {
// ErrorMapping.ErrorMessage errorMessage = ErrorMapping.get("10102"); // ErrorMapping.ErrorMessage errorMessage = ErrorMapping.get("10102");
// throw new LiquidnetServiceException(errorMessage.getCode(), errorMessage.getMessage()); // throw new LiquidnetServiceException(errorMessage.getCode(), errorMessage.getMessage());
// } // }
String respStr = IdentityUtils.aliThird(name, idCard); String respStr = IdentityUtils.aliThird(name, idCard);
JsonNode respJNode = JsonUtils.fromJson(respStr, JsonNode.class); JsonNode respJNode = JsonUtils.fromJson(respStr, JsonNode.class);
if (null == respJNode || !"0".equals(respJNode.get("error_code").asText())) { if (null == respJNode || !"0".equals(respJNode.get("error_code").asText())) {
log.info("###实名认证失败[{}]", respStr); log.info("###实名认证失败[{}]", respStr);
ErrorMapping.ErrorMessage errorMessage = ErrorMapping.get("10102"); ErrorMapping.ErrorMessage errorMessage = ErrorMapping.get("10102");
throw new LiquidnetServiceException(errorMessage.getCode(), errorMessage.getMessage()); throw new LiquidnetServiceException(errorMessage.getCode(), errorMessage.getMessage());
} }
adamRdmService.setCertification(1, idCard, name); adamRdmService.setCertification(1, idCard, name);
} }
AdamRealName realName = new AdamRealName(); AdamRealName realName = new AdamRealName();
realName.setRealNameId(IDGenerator.nextSnowId() + ""); realName.setRealNameId(IDGenerator.nextSnowId() + "");
realName.setUid(uid); realName.setUid(uid);
realName.setType(1); realName.setType(1);
realName.setName(name); realName.setName(name);
realName.setIdCard(idCard); realName.setIdCard(idCard);
realName.setState(1); realName.setState(1);
realName.setCreatedAt(LocalDateTime.now()); realName.setCreatedAt(LocalDateTime.now());
adamRealNameService.add(realName); adamRealNameService.add(realName);
vo = AdamRealInfoVo.getNew(); vo = AdamRealInfoVo.getNew();
vo.setUid(uid); vo.setUid(uid);
vo.setName(name); vo.setName(name);
vo.setIdCard(idCard); vo.setIdCard(idCard);
vo.setType(realName.getType()); vo.setType(realName.getType());
vo.setState(1); vo.setState(1);
long s = System.currentTimeMillis(); long s = System.currentTimeMillis();
adamRdmService.setRealInfoVoByUid(uid, vo); adamRdmService.setRealInfoVoByUid(uid, vo);
log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s); log.debug("#RDS耗时:{}ms", System.currentTimeMillis() - s);
// }
// RedisLockUtil.unlock(AdamRedisConst.LOCK_KEY_UIDENTITY + uid);
// }
return vo; return vo;
} }
} }
...@@ -34,8 +34,8 @@ public class QueueUtils { ...@@ -34,8 +34,8 @@ public class QueueUtils {
* @param jsonMsg Json字符串 * @param jsonMsg Json字符串
*/ */
public void sendMsgByRedis(String streamKey, String jsonMsg) { public void sendMsgByRedis(String streamKey, String jsonMsg) {
// HashMap<String, String> map = CollectionUtil.mapStringString(); HashMap<String, String> map = CollectionUtil.mapStringString();
// map.put("message", jsonMsg); map.put("message", jsonMsg);
// stringRedisTemplate.opsForStream().add(StreamRecords.mapBacked(map).withStreamKey(streamKey)); stringRedisTemplate.opsForStream().add(StreamRecords.mapBacked(map).withStreamKey(streamKey));
} }
} }
...@@ -2,9 +2,16 @@ package com.liquidnet.service.dragon.utils; ...@@ -2,9 +2,16 @@ package com.liquidnet.service.dragon.utils;
import com.alipay.api.internal.util.file.IOUtils; import com.alipay.api.internal.util.file.IOUtils;
import com.liquidnet.commons.lang.util.MD5Utils; 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.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.client.CloseableHttpClient; 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.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.ssl.SSLContexts; import org.apache.http.ssl.SSLContexts;
import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.dom4j.Document; import org.dom4j.Document;
...@@ -24,6 +31,9 @@ public class PayWepayUtils { ...@@ -24,6 +31,9 @@ public class PayWepayUtils {
private CloseableHttpClient httpClient; private CloseableHttpClient httpClient;
private static PayWepayUtils instance = new PayWepayUtils(); private static PayWepayUtils instance = new PayWepayUtils();
// 池化管理
private static PoolingHttpClientConnectionManager poolConnManager =null;
private final String merchantId = "1551961491"; private final String merchantId = "1551961491";
private final String partnerKey = "itIuO65O9yKmemOu3S8g1S4orqvCGwXK"; private final String partnerKey = "itIuO65O9yKmemOu3S8g1S4orqvCGwXK";
...@@ -65,9 +75,41 @@ public class PayWepayUtils { ...@@ -65,9 +75,41 @@ public class PayWepayUtils {
return merchantId; 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() { public CloseableHttpClient getHttpClient() {
try { try {
if (httpClient == null) { if (httpClient == null) {
InputStream certStream = PayWepayUtils.class.getClassLoader().getResourceAsStream("payCert/wepay/wepay_apiclient_cert.p12"); InputStream certStream = PayWepayUtils.class.getClassLoader().getResourceAsStream("payCert/wepay/wepay_apiclient_cert.p12");
byte[] certData = IOUtils.toByteArray(certStream); byte[] certData = IOUtils.toByteArray(certStream);
certStream.read(certData); certStream.read(certData);
...@@ -86,9 +128,17 @@ public class PayWepayUtils { ...@@ -86,9 +128,17 @@ public class PayWepayUtils {
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory( SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
sslcontext, sslcontext,
SSLConnectionSocketFactory.getDefaultHostnameVerifier()); SSLConnectionSocketFactory.getDefaultHostnameVerifier());
httpClient = HttpClients.custom()
.setSSLSocketFactory(sslsf) // 配置同时支持 HTTP 和 HTPPS
.build(); 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) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -96,6 +146,17 @@ public class PayWepayUtils { ...@@ -96,6 +146,17 @@ public class PayWepayUtils {
return httpClient; 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 //生成随机字符串nonce_str
public String getNonceStr() { public String getNonceStr() {
String base = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; String base = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
......
...@@ -28,8 +28,18 @@ public class SweetAppletController { ...@@ -28,8 +28,18 @@ public class SweetAppletController {
@GetMapping("timeSelect") @GetMapping("timeSelect")
@ApiOperation("场次选择") @ApiOperation("场次选择")
public ResponseDto<List<SweetManualAppletDto>> timeSelect() { @ApiImplicitParams({
return ResponseDto.success(redisDataUtils.getPushList()); @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") @GetMapping("details")
......
...@@ -25,6 +25,15 @@ ...@@ -25,6 +25,15 @@
<result column="time_end" property="timeEnd"/> <result column="time_end" property="timeEnd"/>
</resultMap> </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 id="getManualList" parameterType="java.util.Map" resultMap="partnerPerformanceListResult">
SELECT SELECT
...@@ -113,4 +122,37 @@ ...@@ -113,4 +122,37 @@
where sw.`status` = 1 where sw.`status` = 1
and sw.is_release = 1 and sw.is_release = 1
</select> </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> </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