|
@@ -3,10 +3,14 @@ package com.yinjie.heating.webcore.servlet;
|
|
|
import com.dySweetFishPlugin.tool.lang.DateUtil;
|
|
import com.dySweetFishPlugin.tool.lang.DateUtil;
|
|
|
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
|
|
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
|
|
|
import com.sweetfish.net.http.*;
|
|
import com.sweetfish.net.http.*;
|
|
|
|
|
+import com.sweetfish.service.RetResult;
|
|
|
import com.sweetfish.util.AnyValue;
|
|
import com.sweetfish.util.AnyValue;
|
|
|
import com.sweetfish.util.AutoLoad;
|
|
import com.sweetfish.util.AutoLoad;
|
|
|
-import com.yinjie.heating.common.api.HeatingDocService;
|
|
|
|
|
|
|
+import com.yinjie.heating.common.api.heating.CallThirdAppService;
|
|
|
|
|
+import com.yinjie.heating.common.api.heating.HeatingDocService;
|
|
|
import com.yinjie.heating.common.base.ERPAdminHttpServlet;
|
|
import com.yinjie.heating.common.base.ERPAdminHttpServlet;
|
|
|
|
|
+import com.yinjie.heating.common.entity.callthird.BaseRequest;
|
|
|
|
|
+import com.yinjie.heating.common.entity.callthird.BaseResponse;
|
|
|
import com.yinjie.heating.common.entity.ceb.CEBInvokeHeader;
|
|
import com.yinjie.heating.common.entity.ceb.CEBInvokeHeader;
|
|
|
import com.yinjie.heating.common.entity.ceb.CEBRequestItem;
|
|
import com.yinjie.heating.common.entity.ceb.CEBRequestItem;
|
|
|
import com.yinjie.heating.common.entity.ceb.CEBResponseItem;
|
|
import com.yinjie.heating.common.entity.ceb.CEBResponseItem;
|
|
@@ -30,11 +34,17 @@ import java.util.concurrent.CompletableFuture;
|
|
|
public class ThirdInvokeServlet extends ERPAdminHttpServlet {
|
|
public class ThirdInvokeServlet extends ERPAdminHttpServlet {
|
|
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
|
- HeatingDocService gasDocService;
|
|
|
|
|
|
|
+ HeatingDocService heatingDocService;
|
|
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ CallThirdAppService callThirdAppService;
|
|
|
|
|
|
|
|
private XmlMapper xmlMapper;
|
|
private XmlMapper xmlMapper;
|
|
|
|
|
|
|
|
|
|
+ //写死算了,没啥用
|
|
|
|
|
+ private final String DATA_SOURCE_ID = "erp001";
|
|
|
|
|
+ private final long SUPPLIER_CODE = 1000L;
|
|
|
|
|
+
|
|
|
//光大appId,写死算了,没有这个id获取不到解密key,不解密就获取不到他传过来的appId.....
|
|
//光大appId,写死算了,没有这个id获取不到解密key,不解密就获取不到他传过来的appId.....
|
|
|
private static final String CEB_APP_ID = "CEB20240909";
|
|
private static final String CEB_APP_ID = "CEB20240909";
|
|
|
private static final String CEB_SM4_KEY = "a63e5f89caed5d17b62553d0725d47da";
|
|
private static final String CEB_SM4_KEY = "a63e5f89caed5d17b62553d0725d47da";
|
|
@@ -54,18 +64,19 @@ public class ThirdInvokeServlet extends ERPAdminHttpServlet {
|
|
|
// String reqStr = request.getBody(StandardCharsets.UTF_8); //测试
|
|
// String reqStr = request.getBody(StandardCharsets.UTF_8); //测试
|
|
|
try {
|
|
try {
|
|
|
Map<String, Object> respBody = new HashMap<>();
|
|
Map<String, Object> respBody = new HashMap<>();
|
|
|
- HeatingApp gasApp = gasDocService.getRedisGasApp(CEB_APP_ID);
|
|
|
|
|
- boolean errorFlag = false;
|
|
|
|
|
- if (gasApp == null) {
|
|
|
|
|
- //本地配置错误,但是也无法解密了
|
|
|
|
|
- logger.error("未找到应用APPID");
|
|
|
|
|
- return "未找到应用APPID";
|
|
|
|
|
- }
|
|
|
|
|
- if (gasApp.getStatus() > 0) {
|
|
|
|
|
- respBody.put("ErrorCode", "DEF0006");
|
|
|
|
|
- respBody.put("ErrorInfo", "应用APPID已禁用,请联系服务开发商");
|
|
|
|
|
- errorFlag = true;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 此系统当前仅支持光大一家平台商就行了,以后有需要再说
|
|
|
|
|
+// HeatingApp gasApp = gasDocService.getRedisGasApp(CEB_APP_ID);
|
|
|
|
|
+// boolean errorFlag = false;
|
|
|
|
|
+// if (gasApp == null) {
|
|
|
|
|
+// //本地配置错误,但是也无法解密了
|
|
|
|
|
+// logger.error("未找到应用APPID");
|
|
|
|
|
+// return "未找到应用APPID";
|
|
|
|
|
+// }
|
|
|
|
|
+// if (gasApp.getStatus() > 0) {
|
|
|
|
|
+// respBody.put("ErrorCode", "DEF0006");
|
|
|
|
|
+// respBody.put("ErrorInfo", "应用APPID已禁用,请联系服务开发商");
|
|
|
|
|
+// errorFlag = true;
|
|
|
|
|
+// }
|
|
|
|
|
|
|
|
//解密
|
|
//解密
|
|
|
// String decodeStr = SM4Utils.decryptEcb(gasApp.getAppPublicKey(), reqStr, SM4Utils.ENCODING);
|
|
// String decodeStr = SM4Utils.decryptEcb(gasApp.getAppPublicKey(), reqStr, SM4Utils.ENCODING);
|
|
@@ -73,22 +84,25 @@ public class ThirdInvokeServlet extends ERPAdminHttpServlet {
|
|
|
String decodeStr = reqStr;
|
|
String decodeStr = reqStr;
|
|
|
CEBRequestItem requestItem = xmlMapper.readValue(decodeStr, CEBRequestItem.class);
|
|
CEBRequestItem requestItem = xmlMapper.readValue(decodeStr, CEBRequestItem.class);
|
|
|
|
|
|
|
|
- //todo 业务代码
|
|
|
|
|
- if (!errorFlag) {
|
|
|
|
|
- Map<String, Object> bodyMap = requestItem.getBody();
|
|
|
|
|
-
|
|
|
|
|
- switch (requestItem.getInvokeHeader().getfTranCode()) {
|
|
|
|
|
- case "BJ01":
|
|
|
|
|
- respBody = queryBillsToPay(bodyMap, gasApp);
|
|
|
|
|
- break;
|
|
|
|
|
- case "BJ02":
|
|
|
|
|
- respBody = payBill(bodyMap, gasApp);
|
|
|
|
|
- break;
|
|
|
|
|
- case "BJ05":
|
|
|
|
|
- respBody = reqInvoice(bodyMap, gasApp);
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// if (!errorFlag) {
|
|
|
|
|
+ //获取光大请求过来的appId
|
|
|
|
|
+ String appId = requestItem.getInvokeHeader().getInstID();
|
|
|
|
|
+ HeatingApp heatingApp = heatingDocService.getRedisHeatingApp(appId, SUPPLIER_CODE);
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Object> bodyMap = requestItem.getBody();
|
|
|
|
|
+
|
|
|
|
|
+ switch (requestItem.getInvokeHeader().getfTranCode()) {
|
|
|
|
|
+ case "BJ01":
|
|
|
|
|
+ respBody = queryBillsToPay(bodyMap, heatingApp);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case "BJ02":
|
|
|
|
|
+ respBody = payBill(bodyMap, heatingApp);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case "BJ05":
|
|
|
|
|
+ respBody = reqInvoice(bodyMap, heatingApp);
|
|
|
|
|
+ break;
|
|
|
}
|
|
}
|
|
|
|
|
+// }
|
|
|
|
|
|
|
|
CEBResponseItem responseItem = new CEBResponseItem();
|
|
CEBResponseItem responseItem = new CEBResponseItem();
|
|
|
if (respBody.containsKey("ErrorCode")) {
|
|
if (respBody.containsKey("ErrorCode")) {
|
|
@@ -121,7 +135,7 @@ public class ThirdInvokeServlet extends ERPAdminHttpServlet {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//查询待缴费
|
|
//查询待缴费
|
|
|
- private Map<String, Object> queryBillsToPay(Map<String, Object> reqBody, HeatingApp gasApp) {
|
|
|
|
|
|
|
+ private Map<String, Object> queryBillsToPay(Map<String, Object> reqBody, HeatingApp heatingApp) {
|
|
|
Map<String, Object> respBody = new HashMap<>();
|
|
Map<String, Object> respBody = new HashMap<>();
|
|
|
if (!reqBody.containsKey("billKey")) {
|
|
if (!reqBody.containsKey("billKey")) {
|
|
|
respBody.put("ErrorCode", "DEF0010");
|
|
respBody.put("ErrorCode", "DEF0010");
|
|
@@ -130,28 +144,31 @@ public class ThirdInvokeServlet extends ERPAdminHttpServlet {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
String billKey = reqBody.get("billKey").toString();
|
|
String billKey = reqBody.get("billKey").toString();
|
|
|
- QueryOrderResult orderResult = gasFeeService.apiQueryFeeInfo(billKey);
|
|
|
|
|
- if (!orderResult.getErrCode().equals("00000")) {
|
|
|
|
|
|
|
+ BaseResponse orderResult = callThirdAppService.callQueryFee(billKey, heatingApp, DATA_SOURCE_ID, SUPPLIER_CODE).getResult();
|
|
|
|
|
+ if (!orderResult.getRespCode().equals("00000")) {
|
|
|
//将我们的错误代码翻译成光大的
|
|
//将我们的错误代码翻译成光大的
|
|
|
- switch (orderResult.getErrCode()) {
|
|
|
|
|
- case "10005":
|
|
|
|
|
- respBody.put("ErrorCode", "DEF0002");
|
|
|
|
|
- respBody.put("ErrorInfo", "用户未欠费");
|
|
|
|
|
- break;
|
|
|
|
|
- case "10001":
|
|
|
|
|
- respBody.put("ErrorCode", "DEF0005");
|
|
|
|
|
- respBody.put("ErrorInfo", "超过缴费时间");
|
|
|
|
|
- break;
|
|
|
|
|
- case "10002":
|
|
|
|
|
- respBody.put("ErrorCode", "DEF0010");
|
|
|
|
|
- respBody.put("ErrorInfo", "用户不存在");
|
|
|
|
|
- break;
|
|
|
|
|
- case "10003":
|
|
|
|
|
- case "10004":
|
|
|
|
|
- respBody.put("ErrorCode", "DEF0012");
|
|
|
|
|
- respBody.put("ErrorInfo", "该用户不支持网上缴费,请联系公共事业单位");
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// switch (orderResult.getErrCode()) {
|
|
|
|
|
+// case "10005":
|
|
|
|
|
+// respBody.put("ErrorCode", "DEF0002");
|
|
|
|
|
+// respBody.put("ErrorInfo", "用户未欠费");
|
|
|
|
|
+// break;
|
|
|
|
|
+// case "10001":
|
|
|
|
|
+// respBody.put("ErrorCode", "DEF0005");
|
|
|
|
|
+// respBody.put("ErrorInfo", "超过缴费时间");
|
|
|
|
|
+// break;
|
|
|
|
|
+// case "10002":
|
|
|
|
|
+// respBody.put("ErrorCode", "DEF0010");
|
|
|
|
|
+// respBody.put("ErrorInfo", "用户不存在");
|
|
|
|
|
+// break;
|
|
|
|
|
+// case "10003":
|
|
|
|
|
+// case "10004":
|
|
|
|
|
+// respBody.put("ErrorCode", "DEF0012");
|
|
|
|
|
+// respBody.put("ErrorInfo", "该用户不支持网上缴费,请联系公共事业单位");
|
|
|
|
|
+// break;
|
|
|
|
|
+// }
|
|
|
|
|
+ //我们自己将错误代码定的和光大一样即可
|
|
|
|
|
+ respBody.put("ErrorCode", orderResult.getRespCode());
|
|
|
|
|
+ respBody.put("ErrorInfo", orderResult.getRespMsg());
|
|
|
|
|
|
|
|
return respBody;
|
|
return respBody;
|
|
|
} else {
|
|
} else {
|
|
@@ -161,9 +178,13 @@ public class ThirdInvokeServlet extends ERPAdminHttpServlet {
|
|
|
|
|
|
|
|
Map<String, Object> frame = new HashMap<>();
|
|
Map<String, Object> frame = new HashMap<>();
|
|
|
frame.put("contractNo", billKey);
|
|
frame.put("contractNo", billKey);
|
|
|
- frame.put("customerName", orderResult.getCustomerName());
|
|
|
|
|
- frame.put("balance", CommonUtils.money(orderResult.getCustomerBalance()));
|
|
|
|
|
- frame.put("payAmount", CommonUtils.money(orderResult.getTotalOweAmt()));
|
|
|
|
|
|
|
+
|
|
|
|
|
+ //三方返回 customerName 用户名称
|
|
|
|
|
+ frame.put("customerName", orderResult.getRespData().get("customerName"));
|
|
|
|
|
+ //三方返回 customerBalance 用户余额(分)
|
|
|
|
|
+ frame.put("balance", CommonUtils.money(Long.parseLong(orderResult.getRespData().get("customerBalance").toString())));
|
|
|
|
|
+ //三方返回 customerPayAmount 用户欠款(分)
|
|
|
|
|
+ frame.put("payAmount", CommonUtils.money(Long.parseLong(orderResult.getRespData().get("customerPayAmount").toString())));
|
|
|
|
|
|
|
|
respBody.put("Frame", frame);
|
|
respBody.put("Frame", frame);
|
|
|
}
|
|
}
|
|
@@ -171,7 +192,7 @@ public class ThirdInvokeServlet extends ERPAdminHttpServlet {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//缴费销账
|
|
//缴费销账
|
|
|
- private Map<String, Object> payBill(Map<String, Object> reqBody, HeatingApp gasApp) {
|
|
|
|
|
|
|
+ private Map<String, Object> payBill(Map<String, Object> reqBody, HeatingApp heatingApp) {
|
|
|
Map<String, Object> respBody = new HashMap<>();
|
|
Map<String, Object> respBody = new HashMap<>();
|
|
|
if (!reqBody.containsKey("billKey")) {
|
|
if (!reqBody.containsKey("billKey")) {
|
|
|
respBody.put("ErrorCode", "DEF0010");
|
|
respBody.put("ErrorCode", "DEF0010");
|
|
@@ -198,32 +219,35 @@ public class ThirdInvokeServlet extends ERPAdminHttpServlet {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//光大要求缴费金额必须等于欠费金额
|
|
//光大要求缴费金额必须等于欠费金额
|
|
|
- QueryOrderResult orderResult = gasFeeService.apiQueryFeeInfo(billKey);
|
|
|
|
|
- if (!orderResult.getErrCode().equals("00000")) {
|
|
|
|
|
|
|
+ BaseResponse orderResult = callThirdAppService.callQueryFee(billKey, heatingApp, DATA_SOURCE_ID, SUPPLIER_CODE).getResult();
|
|
|
|
|
+ if (!orderResult.getRespCode().equals("00000")) {
|
|
|
//将我们的错误代码翻译成光大的
|
|
//将我们的错误代码翻译成光大的
|
|
|
- switch (orderResult.getErrCode()) {
|
|
|
|
|
- case "10005":
|
|
|
|
|
- respBody.put("ErrorCode", "DEF0002");
|
|
|
|
|
- respBody.put("ErrorInfo", "用户未欠费");
|
|
|
|
|
- break;
|
|
|
|
|
- case "10001":
|
|
|
|
|
- respBody.put("ErrorCode", "DEF0005");
|
|
|
|
|
- respBody.put("ErrorInfo", "超过缴费时间");
|
|
|
|
|
- break;
|
|
|
|
|
- case "10002":
|
|
|
|
|
- respBody.put("ErrorCode", "DEF0010");
|
|
|
|
|
- respBody.put("ErrorInfo", "用户不存在");
|
|
|
|
|
- break;
|
|
|
|
|
- case "10003":
|
|
|
|
|
- case "10004":
|
|
|
|
|
- respBody.put("ErrorCode", "DEF0012");
|
|
|
|
|
- respBody.put("ErrorInfo", "该用户不支持网上缴费,请联系公共事业单位");
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// switch (orderResult.getErrCode()) {
|
|
|
|
|
+// case "10005":
|
|
|
|
|
+// respBody.put("ErrorCode", "DEF0002");
|
|
|
|
|
+// respBody.put("ErrorInfo", "用户未欠费");
|
|
|
|
|
+// break;
|
|
|
|
|
+// case "10001":
|
|
|
|
|
+// respBody.put("ErrorCode", "DEF0005");
|
|
|
|
|
+// respBody.put("ErrorInfo", "超过缴费时间");
|
|
|
|
|
+// break;
|
|
|
|
|
+// case "10002":
|
|
|
|
|
+// respBody.put("ErrorCode", "DEF0010");
|
|
|
|
|
+// respBody.put("ErrorInfo", "用户不存在");
|
|
|
|
|
+// break;
|
|
|
|
|
+// case "10003":
|
|
|
|
|
+// case "10004":
|
|
|
|
|
+// respBody.put("ErrorCode", "DEF0012");
|
|
|
|
|
+// respBody.put("ErrorInfo", "该用户不支持网上缴费,请联系公共事业单位");
|
|
|
|
|
+// break;
|
|
|
|
|
+// }
|
|
|
|
|
+ //我们自己将错误代码定的和光大一样即可
|
|
|
|
|
+ respBody.put("ErrorCode", orderResult.getRespCode());
|
|
|
|
|
+ respBody.put("ErrorInfo", orderResult.getRespMsg());
|
|
|
|
|
|
|
|
return respBody;
|
|
return respBody;
|
|
|
}
|
|
}
|
|
|
- BigDecimal debtMoney = CommonUtils.money(orderResult.getTotalOweAmt());
|
|
|
|
|
|
|
+ BigDecimal debtMoney = CommonUtils.money(Long.parseLong(orderResult.getRespData().get("customerPayAmount").toString()));
|
|
|
|
|
|
|
|
if (chargeMoney.compareTo(debtMoney) != 0) {
|
|
if (chargeMoney.compareTo(debtMoney) != 0) {
|
|
|
respBody.put("ErrorCode", "DEF0013");
|
|
respBody.put("ErrorCode", "DEF0013");
|
|
@@ -231,37 +255,42 @@ public class ThirdInvokeServlet extends ERPAdminHttpServlet {
|
|
|
return respBody;
|
|
return respBody;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- GasPeriodCharge customerCharge = new GasPeriodCharge();
|
|
|
|
|
-
|
|
|
|
|
- customerCharge.setCustomerId(billKey);
|
|
|
|
|
- customerCharge.setChargeMoney(chargeMoney);
|
|
|
|
|
- customerCharge.setBankSerial(bankBillNo);
|
|
|
|
|
- customerCharge.setBankDate(DateUtil.asDate(payDate, "yyyyMMdd"));
|
|
|
|
|
- customerCharge.setBankDateLong(customerCharge.getBankDate().getTime());
|
|
|
|
|
- //todo 不知道写啥
|
|
|
|
|
-// customerCharge.setPayMode(chargeOrder.getPayMode());
|
|
|
|
|
- customerCharge.setCustomerCount(1);
|
|
|
|
|
-
|
|
|
|
|
- ChargeOrderResult chargeResult = gasFeeService.apiChargeFee(customerCharge, gasApp);
|
|
|
|
|
- if (!chargeResult.getErrCode().equals("00000")) {
|
|
|
|
|
- switch (chargeResult.getErrCode()) {
|
|
|
|
|
- case "00003":
|
|
|
|
|
- respBody.put("ErrorCode", "DEF0001");
|
|
|
|
|
- respBody.put("ErrorInfo", "无相应记录");
|
|
|
|
|
- break;
|
|
|
|
|
- case "10001":
|
|
|
|
|
- respBody.put("ErrorCode", "DEF0005");
|
|
|
|
|
- respBody.put("ErrorInfo", "超过缴费时间");
|
|
|
|
|
- break;
|
|
|
|
|
- case "10002":
|
|
|
|
|
- respBody.put("ErrorCode", "DEF0010");
|
|
|
|
|
- respBody.put("ErrorInfo", "用户不存在");
|
|
|
|
|
- break;
|
|
|
|
|
- case "00002":
|
|
|
|
|
- respBody.put("ErrorCode", "DEF0006");
|
|
|
|
|
- respBody.put("ErrorInfo", "业务状态异常");
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// GasPeriodCharge customerCharge = new GasPeriodCharge();
|
|
|
|
|
+//
|
|
|
|
|
+// customerCharge.setCustomerId(billKey);
|
|
|
|
|
+// customerCharge.setChargeMoney(chargeMoney);
|
|
|
|
|
+// customerCharge.setBankSerial(bankBillNo);
|
|
|
|
|
+// customerCharge.setBankDate(DateUtil.asDate(payDate, "yyyyMMdd"));
|
|
|
|
|
+// customerCharge.setBankDateLong(customerCharge.getBankDate().getTime());
|
|
|
|
|
+// //todo 不知道写啥
|
|
|
|
|
+//// customerCharge.setPayMode(chargeOrder.getPayMode());
|
|
|
|
|
+// customerCharge.setCustomerCount(1);
|
|
|
|
|
+
|
|
|
|
|
+ BaseResponse chargeResult = callThirdAppService.callRequestPay(billKey, DateUtil.asDate(payDate, "yyyyMMdd"), bankBillNo,
|
|
|
|
|
+ payAmount, heatingApp, DATA_SOURCE_ID, SUPPLIER_CODE).getResult();
|
|
|
|
|
+ if (!chargeResult.getRespCode().equals("00000")) {
|
|
|
|
|
+// switch (chargeResult.getErrCode()) {
|
|
|
|
|
+// case "00003":
|
|
|
|
|
+// respBody.put("ErrorCode", "DEF0001");
|
|
|
|
|
+// respBody.put("ErrorInfo", "无相应记录");
|
|
|
|
|
+// break;
|
|
|
|
|
+// case "10001":
|
|
|
|
|
+// respBody.put("ErrorCode", "DEF0005");
|
|
|
|
|
+// respBody.put("ErrorInfo", "超过缴费时间");
|
|
|
|
|
+// break;
|
|
|
|
|
+// case "10002":
|
|
|
|
|
+// respBody.put("ErrorCode", "DEF0010");
|
|
|
|
|
+// respBody.put("ErrorInfo", "用户不存在");
|
|
|
|
|
+// break;
|
|
|
|
|
+// case "00002":
|
|
|
|
|
+// respBody.put("ErrorCode", "DEF0006");
|
|
|
|
|
+// respBody.put("ErrorInfo", "业务状态异常");
|
|
|
|
|
+// break;
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+ //我们自己将错误代码定的和光大一样即可
|
|
|
|
|
+ respBody.put("ErrorCode", orderResult.getRespCode());
|
|
|
|
|
+ respBody.put("ErrorInfo", orderResult.getRespMsg());
|
|
|
return respBody;
|
|
return respBody;
|
|
|
} else {
|
|
} else {
|
|
|
respBody.put("companyNo", CommonUtils.generateSerialCode());
|
|
respBody.put("companyNo", CommonUtils.generateSerialCode());
|