|
@@ -89,80 +89,50 @@ public class GigThirdApiServiceImpl implements GigThirdApiService {
|
|
|
|
|
|
private final HuiqiyunInputRecordService huiqiyunInputRecordService;
|
|
|
|
|
|
- private final QifuInputRecordMapper qifuInputRecordMapper;
|
|
|
-
|
|
|
/**
|
|
|
- * 福建企赋回调业务处理
|
|
|
+ * 福建企赋结算回调业务处理
|
|
|
*
|
|
|
- * @param reqMsgId 报文流水号
|
|
|
- * @param reqBody 请求总的body
|
|
|
- * @param inputId 记录id
|
|
|
- * @return 结果
|
|
|
+ * @param bodyJson
|
|
|
+ * @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public boolean qifuNotify(String reqMsgId, JSONObject reqBody, Integer inputId) {
|
|
|
+ public boolean qiFuSettleNotify(JSONObject bodyJson) {
|
|
|
+ String reqId = bodyJson.getStr("reqId");
|
|
|
+ String state = bodyJson.getStr("state");
|
|
|
|
|
|
- // 查询privateKey
|
|
|
- List<SysDeptSub> deptSubList = sysDeptSubService.list(Wrappers.<SysDeptSub>lambdaQuery()
|
|
|
- .eq(SysDeptSub::getEnableFlag, SubjectTypeEnum.ENABLE_FLAG_TRUE.getCode())
|
|
|
- .eq(SysDeptSub::getSubjectLocation, SubjectLocation.QI_FU)
|
|
|
- .isNotNull(SysDeptSub::getAppSecret));
|
|
|
- if (CollUtil.isEmpty(deptSubList)) {
|
|
|
- log.warn("汇企云privateKey不存在");
|
|
|
+ // 根据orderNo查询结算单
|
|
|
+ List<WmScorePackageSettleNote> settleNoteList = scorePackageSettleNoteService.list(Wrappers.<WmScorePackageSettleNote>lambdaQuery()
|
|
|
+ .eq(WmScorePackageSettleNote::getStreamId, reqId));
|
|
|
+ if (CollUtil.isEmpty(settleNoteList)) {
|
|
|
+ log.warn("订单reqId={}对应结算单不存在", reqId);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- // 解密body
|
|
|
- Map<String, Object> decryptData = this.decryptData(reqBody, deptSubList.get(0).getAppSecret());
|
|
|
- log.info("汇企云解密后body={}", decryptData);
|
|
|
-
|
|
|
- // 保存解密后的body
|
|
|
- QifuInputRecord inputRecord = new QifuInputRecord();
|
|
|
- inputRecord.setId(inputId);
|
|
|
- inputRecord.setDecryptBody(JSONUtil.toJsonStr(decryptData));
|
|
|
- qifuInputRecordMapper.updateById(inputRecord);
|
|
|
-
|
|
|
- // 内层body
|
|
|
- String bodyStr = (String) decryptData.get("body");
|
|
|
- JSONObject bodyJson = JSONUtil.parseObj(bodyStr);
|
|
|
-
|
|
|
- // 批次出款流水号
|
|
|
- String batchNo = bodyJson.getStr("batchNo");
|
|
|
- // 批次成功总笔数
|
|
|
- Integer totalSuccessNum = bodyJson.getInt("totalSuccessNum");
|
|
|
- // 批次成功总金额
|
|
|
- String totalSuccessAmt = bodyJson.getStr("totalSuccessAmt");
|
|
|
- // 批次失败总笔数
|
|
|
- Integer totalFailNum = bodyJson.getInt("totalFailNum");
|
|
|
- // 批次失败总金额
|
|
|
- String totalFailAmt = bodyJson.getStr("totalFailAmt");
|
|
|
- // 批次请求总笔数
|
|
|
- Integer totalNum = bodyJson.getInt("totalNum");
|
|
|
- // 批次请求总金额
|
|
|
- String totalAmt = bodyJson.getStr("totalAmt");
|
|
|
+ WmScorePackageSettleNote tmp = settleNoteList.get(0);
|
|
|
|
|
|
- int yaoyiStatus;
|
|
|
- if (totalSuccessNum.equals(totalNum)) {
|
|
|
- // 批次成功笔数=批次总笔数,则认为是成功
|
|
|
+ int yaoyiStatus = 0;
|
|
|
+ // state取值:
|
|
|
+ // SETSUCC结算成功;
|
|
|
+ // SETFAIL:结算失败;
|
|
|
+ // TICREF:已退票
|
|
|
+ if ("SETSUCC".equals(state)) {
|
|
|
+ // 对应要易结算成功状态
|
|
|
yaoyiStatus = 1;
|
|
|
- } else {
|
|
|
+ } else if ("SETFAIL".equals(state)) {
|
|
|
yaoyiStatus = 2;
|
|
|
- }
|
|
|
-
|
|
|
- // 根据orderNo查询结算单
|
|
|
- List<WmScorePackageSettleNote> settleNoteList = scorePackageSettleNoteService.list(Wrappers.<WmScorePackageSettleNote>lambdaQuery()
|
|
|
- .eq(WmScorePackageSettleNote::getStreamId, batchNo));
|
|
|
- if (CollUtil.isEmpty(settleNoteList)) {
|
|
|
- log.warn("订单batchNo={}对应结算单不存在", batchNo);
|
|
|
+ } else {
|
|
|
+ log.warn("当前结算state不处理");
|
|
|
+ redisTemplate.delete(CacheConstants.SETTLE_PACKAGE_KEY + tmp.getId());
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
// 修改结算状态
|
|
|
+ final int finalYaoyiStatus = yaoyiStatus;
|
|
|
List<WmScorePackageSettleNote> updateList = settleNoteList.stream().map(note -> {
|
|
|
WmScorePackageSettleNote updateEntity = new WmScorePackageSettleNote();
|
|
|
updateEntity.setId(note.getId());
|
|
|
- updateEntity.setSettleNoteStatus(yaoyiStatus);
|
|
|
- if (yaoyiStatus == 1){
|
|
|
+ updateEntity.setSettleNoteStatus(finalYaoyiStatus);
|
|
|
+ if (finalYaoyiStatus == 1){
|
|
|
updateEntity.setNotifyTime(LocalDateTime.now());
|
|
|
}
|
|
|
updateEntity.setUpdateTime(LocalDateTime.now());
|
|
@@ -171,7 +141,6 @@ public class GigThirdApiServiceImpl implements GigThirdApiService {
|
|
|
|
|
|
scorePackageSettleNoteService.updateBatchById(updateList);
|
|
|
|
|
|
- WmScorePackageSettleNote tmp = settleNoteList.get(0);
|
|
|
WmScorePackage scorePackage = scorePackageService.getById(tmp.getPackageId());
|
|
|
|
|
|
// 遥领不修改
|
|
@@ -190,6 +159,60 @@ public class GigThirdApiServiceImpl implements GigThirdApiService {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 福建企赋签约回调业务处理
|
|
|
+ *
|
|
|
+ * @param newBodyJson
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public boolean qiFuSignNotify(JSONObject newBodyJson) {
|
|
|
+
|
|
|
+ String idCard = newBodyJson.getStr("idCard");
|
|
|
+ String mobile = newBodyJson.getStr("mobile");
|
|
|
+ String name = newBodyJson.getStr("name");
|
|
|
+ String state = newBodyJson.getStr("state");
|
|
|
+ String resMsg = newBodyJson.getStr("resMsg");
|
|
|
+
|
|
|
+ // 查询当前用户
|
|
|
+ SysUser sysUser = sysUserService.getOne(Wrappers.<SysUser>lambdaQuery()
|
|
|
+ .eq(SysUser::getRealname, name)
|
|
|
+ .eq(SysUser::getIdCardNumber, idCard)
|
|
|
+ .eq(SysUser::getUsername, mobile)
|
|
|
+ .eq(SysUser::getDelFlag, DelEnum.NOT_DEL.val()));
|
|
|
+ if (sysUser == null) {
|
|
|
+ log.warn("用户不存在name={},idCard={},mobile={}", name, idCard, mobile);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询对应userSub数据
|
|
|
+ SysUserSub userSub = sysUserSubService.getOne(Wrappers.<SysUserSub>lambdaQuery()
|
|
|
+ .eq(SysUserSub::getUserId, sysUser.getUserId())
|
|
|
+ .eq(SysUserSub::getSubjectLocation, SubjectLocation.QI_FU));
|
|
|
+ if (userSub == null) {
|
|
|
+ log.warn("没有查到对应userSub数据 userId={}", sysUser.getUserId());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新userSub
|
|
|
+ SysUserSub updateUserSub = new SysUserSub();
|
|
|
+ updateUserSub.setId(userSub.getId());
|
|
|
+ if ("SIGN".equals(state)) {
|
|
|
+ // 已签约对应要易已认证
|
|
|
+ updateUserSub.setCertStatus(ZhongYiYunCertStatus.CERT.getCode());
|
|
|
+ }
|
|
|
+ updateUserSub.setCertRemark(String.format("%s;%s", userSub.getCertRemark(), String.format("签约回调:%s;", resMsg)));
|
|
|
+ updateUserSub.setFailReason(String.format("签约回调:%s;", resMsg));
|
|
|
+ updateUserSub.setCallbackStatus(GigCallBackStatus.RETURNED);
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ updateUserSub.setUpdateTime(now);
|
|
|
+ updateUserSub.setCallbackTime(now);
|
|
|
+ updateUserSub.setUpdateUser(0);
|
|
|
+ sysUserSubService.updateById(updateUserSub);
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 中智结算回调业务处理
|
|
|
*
|