|
@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.constant.CacheConstants;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.constant.MqConstants;
|
|
|
+import com.qunzhixinxi.hnqz.admin.api.dto.OladingCommonRequest;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.SysDept;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.entity.SysUser;
|
|
|
import com.qunzhixinxi.hnqz.admin.entity.SysUserSub;
|
|
@@ -17,6 +18,7 @@ import com.qunzhixinxi.hnqz.admin.enums.DelEnum;
|
|
|
import com.qunzhixinxi.hnqz.admin.enums.GigCallBackStatus;
|
|
|
import com.qunzhixinxi.hnqz.admin.enums.GigTypeEnum;
|
|
|
import com.qunzhixinxi.hnqz.admin.enums.LockEnum;
|
|
|
+import com.qunzhixinxi.hnqz.admin.enums.OladingCertStatus;
|
|
|
import com.qunzhixinxi.hnqz.admin.enums.YeeCertStatus;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.SysDeptService;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.SysUserService;
|
|
@@ -66,39 +68,39 @@ public class GigSignCertReceiver extends BaseRabbiMqHandler<String> {
|
|
|
*/
|
|
|
private static final String YEE_SUCCESS_CODE = "200";
|
|
|
|
|
|
- @RabbitHandler
|
|
|
- public void onMessage(String jsonStr, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long deliveryTag) {
|
|
|
- super.onMessageAck(jsonStr, deliveryTag, channel, (MqListener<String>) (String result, Channel channel1) -> {
|
|
|
+ @RabbitHandler
|
|
|
+ public void onMessage(String jsonStr, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long deliveryTag) {
|
|
|
+ super.onMessageAck(jsonStr, deliveryTag, channel, (MqListener<String>) (String result, Channel channel1) -> {
|
|
|
|
|
|
log.info("直接队列:接收用户签约认证的结果,手动ACK,接收消息TAG:{},消息内容:{}", deliveryTag, result);
|
|
|
|
|
|
Map<String, String> resMap = MapUtil.newHashMap(2);
|
|
|
+ try {
|
|
|
+ JSONObject jsonResult = JSONUtil.parseObj(result);
|
|
|
+ String username = jsonResult.getStr("username");
|
|
|
+ String entpriseCode = jsonResult.getStr("enterpriseCode");
|
|
|
+ JSONObject subjectTypes = jsonResult.getJSONObject("subjectTypes");
|
|
|
|
|
|
- JSONObject jsonResult = JSONUtil.parseObj(result);
|
|
|
- String username = jsonResult.getStr("username");
|
|
|
- String entpriseCode = jsonResult.getStr("enterpriseCode");
|
|
|
- JSONObject subjectTypes = jsonResult.getJSONObject("subjectTypes");
|
|
|
-
|
|
|
- if (StrUtil.isBlank(username) || StrUtil.isBlank(entpriseCode) || subjectTypes.isEmpty()) {
|
|
|
- log.error("必传参数空!");
|
|
|
- resMap.put("key", String.format("%s_%s_%s", CacheConstants.USER_SIGN_CERT_RESPONSE_MQ_KEY, username, entpriseCode));
|
|
|
- resMap.put("res", JSONUtil.toJsonStr(subjectTypes));
|
|
|
- return resMap;
|
|
|
- }
|
|
|
+ if (StrUtil.isBlank(username) || StrUtil.isBlank(entpriseCode) || subjectTypes.isEmpty()) {
|
|
|
+ log.error("必传参数空!");
|
|
|
+ resMap.put("key", String.format("%s_%s_%s", CacheConstants.USER_SIGN_CERT_RESPONSE_MQ_KEY, username, entpriseCode));
|
|
|
+ resMap.put("res", JSONUtil.toJsonStr(subjectTypes));
|
|
|
+ return resMap;
|
|
|
+ }
|
|
|
// 加redis锁 TODO
|
|
|
// redisTemplate.opsForValue().setIfAbsent()
|
|
|
|
|
|
- List<SysDept> deptList = sysDeptService.list(Wrappers.<SysDept>lambdaQuery()
|
|
|
- .eq(SysDept::getTaxCode, entpriseCode)
|
|
|
- .eq(SysDept::getDelFlag, DelEnum.NOT_DEL.val())
|
|
|
- .orderByDesc(SysDept::getCreateTime));
|
|
|
- if (CollUtil.isNotEmpty(deptList)) {
|
|
|
- SysDept dept = deptList.get(0);
|
|
|
- SysUser user = sysUserService.getOne(Wrappers.<SysUser>lambdaQuery()
|
|
|
- .eq(SysUser::getDeptId, dept.getDeptId())
|
|
|
- .eq(SysUser::getUsername, username)
|
|
|
- .eq(SysUser::getDelFlag, DelEnum.NOT_DEL.val())
|
|
|
- .eq(SysUser::getLockFlag, LockEnum.UN_LOCK.val()));
|
|
|
+ List<SysDept> deptList = sysDeptService.list(Wrappers.<SysDept>lambdaQuery()
|
|
|
+ .eq(SysDept::getTaxCode, entpriseCode)
|
|
|
+ .eq(SysDept::getDelFlag, DelEnum.NOT_DEL.val())
|
|
|
+ .orderByDesc(SysDept::getCreateTime));
|
|
|
+ if (CollUtil.isNotEmpty(deptList)) {
|
|
|
+ SysDept dept = deptList.get(0);
|
|
|
+ SysUser user = sysUserService.getOne(Wrappers.<SysUser>lambdaQuery()
|
|
|
+ .eq(SysUser::getDeptId, dept.getDeptId())
|
|
|
+ .eq(SysUser::getUsername, username)
|
|
|
+ .eq(SysUser::getDelFlag, DelEnum.NOT_DEL.val())
|
|
|
+ .eq(SysUser::getLockFlag, LockEnum.UN_LOCK.val()));
|
|
|
if (user == null) {
|
|
|
log.error("用户不存在!");
|
|
|
return null;
|
|
@@ -108,37 +110,39 @@ public class GigSignCertReceiver extends BaseRabbiMqHandler<String> {
|
|
|
GigTypeEnum gigTypeEnum = Enum.valueOf(GigTypeEnum.class, s);
|
|
|
JSONObject subjectResult = (JSONObject) o;
|
|
|
|
|
|
- switch (gigTypeEnum) {
|
|
|
- case TAX_HELPOR:
|
|
|
- taxHelperHandler(user, dept, subjectResult);
|
|
|
- // 本次结果存入redis
|
|
|
- redisTemplate.opsForValue().set(CacheConstants.USER_SIGN_CERT_RESPONSE_KEY + user.getUserId(),
|
|
|
- JSONUtil.toJsonStr(subjectTypes), 1, TimeUnit.MINUTES);
|
|
|
- break;
|
|
|
- case REN_LI_JIA:
|
|
|
- // TODO
|
|
|
- break;
|
|
|
- case OLADING:
|
|
|
- oladingHandler(user, dept, subjectResult);
|
|
|
- break;
|
|
|
- case YEE:
|
|
|
- yeeHandler(user, dept, subjectResult);
|
|
|
- // 本次结果存入redis
|
|
|
- redisTemplate.opsForValue().set(CacheConstants.USER_SIGN_CERT_RESPONSE_KEY + user.getUserId(),
|
|
|
- JSONUtil.toJsonStr(subjectTypes), 1, TimeUnit.MINUTES);
|
|
|
- break;
|
|
|
- default:
|
|
|
- }
|
|
|
- });
|
|
|
+ switch (gigTypeEnum) {
|
|
|
+ case TAX_HELPOR:
|
|
|
+ this.taxHelperHandler(user, dept, subjectResult);
|
|
|
+ // 本次结果存入redis
|
|
|
+ redisTemplate.opsForValue().set(CacheConstants.USER_SIGN_CERT_RESPONSE_KEY + user.getUserId(),
|
|
|
+ JSONUtil.toJsonStr(subjectTypes), 1, TimeUnit.MINUTES);
|
|
|
+ break;
|
|
|
+ case REN_LI_JIA:
|
|
|
+ // TODO
|
|
|
+ break;
|
|
|
+ case OLADING:
|
|
|
+ this.oladingHandler(user, dept, subjectResult);
|
|
|
+ break;
|
|
|
+ case YEE:
|
|
|
+ yeeHandler(user, dept, subjectResult);
|
|
|
+ // 本次结果存入redis
|
|
|
+ redisTemplate.opsForValue().set(CacheConstants.USER_SIGN_CERT_RESPONSE_KEY + user.getUserId(),
|
|
|
+ JSONUtil.toJsonStr(subjectTypes), 1, TimeUnit.MINUTES);
|
|
|
+ default:
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- resMap.put("key", String.format("%s_%s_%s", CacheConstants.USER_SIGN_CERT_RESPONSE_MQ_KEY, username, entpriseCode));
|
|
|
- resMap.put("res", JSONUtil.toJsonStr(subjectTypes));
|
|
|
+ resMap.put("key", String.format("%s_%s_%s", CacheConstants.USER_SIGN_CERT_RESPONSE_MQ_KEY, username, entpriseCode));
|
|
|
+ resMap.put("res", JSONUtil.toJsonStr(subjectTypes));
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("mq回调处理失败", e);
|
|
|
+ }
|
|
|
|
|
|
return resMap;
|
|
|
- });
|
|
|
- }
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 税邦云数据处理
|
|
@@ -246,7 +250,19 @@ public class GigSignCertReceiver extends BaseRabbiMqHandler<String> {
|
|
|
* @param subjectResult
|
|
|
*/
|
|
|
private void oladingHandler(SysUser user, SysDept dept, JSONObject subjectResult) {
|
|
|
+ String certStatus = subjectResult.getStr("certStatus");
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
+
|
|
|
+ // 查询当前认证状态
|
|
|
+ SysUserSub userSub = sysUserSubService.getOne(Wrappers.<SysUserSub>lambdaQuery()
|
|
|
+ .eq(SysUserSub::getDeptId, dept.getDeptId())
|
|
|
+ .eq(SysUserSub::getUserId, user.getUserId())
|
|
|
+ .eq(SysUserSub::getCallbackStatus, GigCallBackStatus.IN_PROGRESS)
|
|
|
+ .eq(SysUserSub::getGigType, GigTypeEnum.OLADING));
|
|
|
+ if (userSub == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
// 拼接更新条件
|
|
|
LambdaUpdateWrapper<SysUserSub> updateWrapper = Wrappers.<SysUserSub>lambdaUpdate()
|
|
|
.eq(SysUserSub::getUserId, user.getUserId())
|
|
@@ -255,6 +271,25 @@ public class GigSignCertReceiver extends BaseRabbiMqHandler<String> {
|
|
|
.set(SysUserSub::getUpdateTime, now)
|
|
|
.set(SysUserSub::getUpdateUser, 0)
|
|
|
.set(SysUserSub::getCertRemark, JSONUtil.toJsonStr(subjectResult));
|
|
|
+
|
|
|
+ // 如果是已签约并且当前不是已认证,则设置一下状态(处理阿拉丁没有回调的情况)
|
|
|
+ if (OladingCommonRequest.SignUpStatus.SIGN.name().equals(certStatus)
|
|
|
+ && !OladingCertStatus.CERT.getCode().equals(String.valueOf(userSub.getCertStatus()))) {
|
|
|
+ updateWrapper.set(SysUserSub::getCallbackStatus, GigCallBackStatus.RETURNED);
|
|
|
+ }
|
|
|
+ // 如果是签约中,则判断'阿拉丁签约方法'状态
|
|
|
+ if (OladingCommonRequest.SignUpStatus.SIGNING.name().equals(certStatus)) {
|
|
|
+ JSONObject stageResult = subjectResult.getJSONObject("stageResult");
|
|
|
+ JSONObject oladingSignUpResult = stageResult.getJSONObject("阿拉丁签约方法");
|
|
|
+ if (oladingSignUpResult == null || StrUtil.equals("1005", oladingSignUpResult.getStr("code"))) {
|
|
|
+ updateWrapper.set(SysUserSub::getCallbackStatus, GigCallBackStatus.RETURNED);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 已认证,则设置回调状态
|
|
|
+ if (OladingCertStatus.CERT.getCode().equals(String.valueOf(userSub.getCertStatus()))) {
|
|
|
+ updateWrapper.set(SysUserSub::getCallbackStatus, GigCallBackStatus.RETURNED);
|
|
|
+ }
|
|
|
+
|
|
|
sysUserSubService.update(updateWrapper);
|
|
|
}
|
|
|
|