Explorar o código

feat: 福建企赋结算回调

lixuesong hai 1 ano
pai
achega
c15b5a00e4

+ 32 - 8
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/controller/GigThirdApiController.java

@@ -110,16 +110,40 @@ public class GigThirdApiController {
 			return "fail";
 		}
 
-		// 请求记录到数据库
-		QifuInputRecord inputRecord = new QifuInputRecord();
-		inputRecord.setReqId(reqId);
-		inputRecord.setReqType(QifuInputRecord.ReqType.SETTLE_NOTIFY.getType());
-		inputRecord.setReqBody(body);
-		inputRecord.setDecryptBody(body);
-		qifuInputRecordMapper.insert(inputRecord);
+		String decryptDataStr = null;
+		com.alibaba.fastjson.JSONObject unPackMessage = null;
+		try {
+			// 查询deptSub获取desKey
+			SysDeptSub deptSub = sysDeptSubService.getOne(Wrappers.<SysDeptSub>lambdaQuery()
+					.eq(SysDeptSub::getEnableFlag, "1")
+					.eq(SysDeptSub::getSubjectLocation, SubjectLocation.QI_FU)
+					.last("limit 1"));
+			if (deptSub == null || StrUtil.isBlank(deptSub.getAppId())) {
+				log.warn("未配置福建企赋deptSub reqId={}", reqId);
+				return "fail";
+			}
+
+			String publicKey = deptSub.getRsaPublicKey();
+
+			// 验签/解密
+			unPackMessage =
+					SaasApiDemoV2.unPackMessage(JSON.parseObject(body), com.alibaba.fastjson.JSONObject.class, publicKey);
+			decryptDataStr = com.alibaba.fastjson.JSONObject.toJSONString(unPackMessage);
+		} catch (Exception e) {
+			log.error("福建企赋结算回调参数异常", e);
+			return "fail";
+		} finally {
+			// 请求记录到数据库
+			QifuInputRecord inputRecord = new QifuInputRecord();
+			inputRecord.setReqId(reqId);
+			inputRecord.setReqType(QifuInputRecord.ReqType.SETTLE_NOTIFY.getType());
+			inputRecord.setReqBody(body);
+			inputRecord.setDecryptBody(decryptDataStr);
+			qifuInputRecordMapper.insert(inputRecord);
+		}
 
 		// 业务处理
-		gigThirdApiService.qiFuSettleNotify(bodyJson);
+		gigThirdApiService.qiFuSettleNotify(unPackMessage);
 
 		return "success";
 	}

+ 1 - 1
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/gig/GigThirdApiService.java

@@ -20,7 +20,7 @@ public interface GigThirdApiService {
 	 * @param bodyJson
 	 * @return
 	 */
-	boolean qiFuSettleNotify(JSONObject bodyJson);
+	boolean qiFuSettleNotify(com.alibaba.fastjson.JSONObject bodyJson);
 
 	/**
 	 * 福建企赋签约回调业务处理

+ 3 - 3
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/gig/impl/GigThirdApiServiceImpl.java

@@ -96,9 +96,9 @@ public class GigThirdApiServiceImpl implements GigThirdApiService {
 	 * @return
 	 */
 	@Override
-	public boolean qiFuSettleNotify(JSONObject bodyJson) {
-		String reqId = bodyJson.getStr("reqId");
-		String state = bodyJson.getStr("state");
+	public boolean qiFuSettleNotify(com.alibaba.fastjson.JSONObject bodyJson) {
+		String reqId = bodyJson.getString("reqId");
+		String state = bodyJson.getString("state");
 
 		// 根据orderNo查询结算单
 		List<WmScorePackageSettleNote> settleNoteList = scorePackageSettleNoteService.list(Wrappers.<WmScorePackageSettleNote>lambdaQuery()