|
|
@@ -117,7 +117,24 @@ public class DepositService {
|
|
|
return MyRet.fail("查询通联支付状态失败:" + queryResult.getMessage());
|
|
|
}
|
|
|
|
|
|
- // 验证金额一致性
|
|
|
+ // 根据通联返回状态处理
|
|
|
+ String tlStatus = mapTlStatus(queryResult.getTrxstatus());
|
|
|
+
|
|
|
+ // 只有支付成功才验证金额并进行充值
|
|
|
+ if (!"0000".equals(queryResult.getTrxstatus())) {
|
|
|
+ // 更新订单状态并返回对应的状态描述
|
|
|
+ deposit.setTlStatus(tlStatus);
|
|
|
+ deposit.setDescription("通联支付状态:" + getStatusDescription(queryResult.getTrxstatus()));
|
|
|
+ deposit.update();
|
|
|
+
|
|
|
+ Map<String, Object> resultData = new HashMap<>();
|
|
|
+ resultData.put("tl_status", tlStatus);
|
|
|
+ resultData.put("message", getStatusDescription(queryResult.getTrxstatus()));
|
|
|
+
|
|
|
+ return MyRet.ok("状态更新成功").setData(resultData);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 支付成功,验证金额一致性
|
|
|
Integer queryAmount = Integer.parseInt(queryResult.getTrxamt());
|
|
|
if (!queryAmount.equals(deposit.getAmount())) {
|
|
|
deposit.setTlStatus("AMOUNT_MISMATCH");
|
|
|
@@ -125,9 +142,6 @@ public class DepositService {
|
|
|
return MyRet.fail("金额校验失败:订单金额与实际支付金额不符");
|
|
|
}
|
|
|
|
|
|
- // 根据通联返回状态处理
|
|
|
- String tlStatus = mapTlStatus(queryResult.getTrxstatus());
|
|
|
-
|
|
|
if ("SUCCESS".equals(tlStatus)) {
|
|
|
// 支付成功,执行充值
|
|
|
boolean rechargeResult = addUserBalance(deposit.getUserId(), deposit.getAmount(), tlOrderNo);
|
|
|
@@ -167,6 +181,7 @@ public class DepositService {
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
return MyRet.fail("查询支付状态失败:" + e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
@@ -278,6 +293,63 @@ public class DepositService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取通联支付状态的中文描述
|
|
|
+ *
|
|
|
+ * @param trxstatus 通联返回的状态码
|
|
|
+ * @return 中文状态描述
|
|
|
+ */
|
|
|
+ private String getStatusDescription(String trxstatus) {
|
|
|
+ if (trxstatus == null || trxstatus.isEmpty()) {
|
|
|
+ return "状态未知";
|
|
|
+ }
|
|
|
+
|
|
|
+ switch (trxstatus) {
|
|
|
+ case "0000":
|
|
|
+ return "交易成功";
|
|
|
+ case "1001":
|
|
|
+ return "交易不存在";
|
|
|
+ case "2008":
|
|
|
+ case "2000":
|
|
|
+ return "交易处理中,请稍后再试";
|
|
|
+ case "2001":
|
|
|
+ return "支付已取消";
|
|
|
+ case "3888":
|
|
|
+ return "流水号重复,请重新下单";
|
|
|
+ case "3889":
|
|
|
+ return "交易控制失败,请重试";
|
|
|
+ case "3099":
|
|
|
+ return "渠道商户错误";
|
|
|
+ case "3014":
|
|
|
+ return "交易金额小于应收手续费";
|
|
|
+ case "3031":
|
|
|
+ return "校验实名信息失败";
|
|
|
+ case "3088":
|
|
|
+ return "交易未支付";
|
|
|
+ case "3089":
|
|
|
+ return "撤销异常,如已影响资金24小时内会做差错退款处理";
|
|
|
+ case "3045":
|
|
|
+ return "其他错误,请查看详细信息";
|
|
|
+ case "3050":
|
|
|
+ return "交易已被撤销";
|
|
|
+ case "3999":
|
|
|
+ return "其他错误";
|
|
|
+ default:
|
|
|
+ // 其他3开头的错误码代表交易失败
|
|
|
+ if (trxstatus.startsWith("3")) {
|
|
|
+ return "交易失败";
|
|
|
+ }
|
|
|
+ // 其他2开头的状态码作为处理中
|
|
|
+ else if (trxstatus.startsWith("2")) {
|
|
|
+ return "交易处理中";
|
|
|
+ }
|
|
|
+ // 其他状态默认处理中
|
|
|
+ else {
|
|
|
+ return "状态处理中";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
public MyRet list(int pageNumber, int pageSize, Long userId) {
|
|
|
// 接收 Integer 类型的 orderStatus
|