private String agentMsg;
private String agentRefno;
+ private DtlStatus dtlStatus;
public AgentCode getCode() {
return code;
public void setAgentRefno(String agentRefno) {
this.agentRefno = agentRefno;
}
+
+ public DtlStatus getDtlStatus() {
+ return dtlStatus;
+ }
+
+ public void setDtlStatus(DtlStatus dtlStatus) {
+ this.dtlStatus = dtlStatus;
+ }
}
--- /dev/null
+package com.supwisdom.dlpay.agent;
+
+public enum DtlStatus {
+ SUCCESS, //成功
+ FAIL, //失败
+ REFUND, //已退款
+ PARTIAL_REFUND //部分退款
+}
errcode.add(Pair.of(AgentCode.SHORT_OF_BALANCE, new YnrccRespCode("0302", "余额不足")));
errcode.add(Pair.of(AgentCode.SERVER_INTERNAL_ERROR, new YnrccRespCode("0303", "MD5校验失败")));
errcode.add(Pair.of(AgentCode.ILLEGAL_DATA, new YnrccRespCode("0304", "该卡号已经解约,不允许重复解约")));
- errcode.add(Pair.of(AgentCode.FAIL, new YnrccRespCode("0401", "原始流水不存在")));
+ errcode.add(Pair.of(AgentCode.REFNO_NOT_EXISTS, new YnrccRespCode("0401", "原始流水不存在")));
errcode.add(Pair.of(AgentCode.FAIL, new YnrccRespCode("0402", "原始流水未成功")));
errcode.add(Pair.of(AgentCode.FAIL, new YnrccRespCode("0403", "原始流水已退款")));
errcode.add(Pair.of(AgentCode.SHORT_OF_BALANCE, new YnrccRespCode("0404", "商户账户余额不足")));
import com.supwisdom.dlpay.agent.AgentCode
import com.supwisdom.dlpay.agent.AgentPayService
import com.supwisdom.dlpay.agent.AgentResponse
+import com.supwisdom.dlpay.agent.DtlStatus
import com.supwisdom.dlpay.agent.citizencard.DlpayResp
import com.supwisdom.dlpay.agent.citizencard.YnrccRespCode
import com.supwisdom.dlpay.agent.citizencard.YnrccUtil
it.agentCode = code.second.code
it.agentMsg = code.first.message() + "-" + code.second.msg
it.agentRefno = resp.bankjourno
+ it.dtlStatus = when (resp.status) {
+ YnrccUtil.DTL_STATUS_SUCCESS -> DtlStatus.SUCCESS
+ YnrccUtil.DTL_STATUS_REFUND -> DtlStatus.REFUND
+ YnrccUtil.DTL_STATUS_PART_REFUND -> DtlStatus.PARTIAL_REFUND
+ else -> DtlStatus.FAIL
+ }
}
}
}
\ No newline at end of file
package com.supwisdom.dlpay.api
import com.supwisdom.dlpay.agent.AgentCode
+import com.supwisdom.dlpay.agent.DtlStatus
+
import com.supwisdom.dlpay.agent.citizencard.YnrccUtil
import com.supwisdom.dlpay.api.domain.TTransactionMain
import com.supwisdom.dlpay.api.repositories.ShopaccService
}
val service = ApplicationUtil.findAgentPayService(applicationContext,
- transaction.sourceType)
+ transaction.sourceType+ "Agent")
+
logger.info("refno=[${transaction.refno}]开始第" + (qcnt + 1) + "次查询支付结果:")
val resp = service.query(transaction)
when (resp.code) {
AgentCode.SUCCESS -> {
//查询成功
-// when {
-// YnrccUtil.DTL_STATUS_SUCCESS == resp.status ->
-// transactionService.success(refno, resp.bankjourno, false) //流水成功
-// YnrccUtil.DTL_STATUS_REFUND == resp.status -> {
-// //流水已退款 TODO:流水成功后才退款,无查询原成功流水逻辑
-// return
-// }
-// YnrccUtil.DTL_STATUS_PART_REFUND == resp.status -> {
-// //流水已部分退款 TODO:暂无逻辑
-// return
-// }
-// else -> {
-// //流水失败
-// transactionService.fail(refno, "查询流水状态为交易失败")
-// }
-// }
- transactionService.success(transaction.refno, resp.agentRefno, false)
+ when (resp.dtlStatus) {
+ DtlStatus.SUCCESS ->
+ transactionService.success(transaction.refno, resp.agentRefno, false) //流水成功
+ DtlStatus.REFUND -> {
+ //流水已退款 TODO:流水成功后才退款,无查询原成功流水逻辑
+ logger.error("refno=[${transaction.refno}]查询结果为:已退款!!!")
+ return
+ }
+ DtlStatus.PARTIAL_REFUND -> {
+ //流水已部分退款 TODO:暂无逻辑
+ logger.error("refno=[${transaction.refno}]查询结果为:已部分退款!!!")
+ return
+ }
+ else -> {
+ //流水失败
+ transactionService.fail(transaction.refno, "查询流水状态为交易失败")
+ }
+ }
}
- AgentCode.REFNO_NOT_EXISTS -> transactionService.fail(transaction.refno, "银行流水不存在")
- AgentCode.COMMON_ERROR -> queryResult(transaction, qcnt + 1)
+ AgentCode.REFNO_NOT_EXISTS ->
+ transactionService.fail(transaction.refno, "银行流水不存在") //银行返回流水不存在
+ AgentCode.REQUIRE_QUERY ->
+ queryResult(transaction, qcnt + 1) //查询次数加1
else -> {
- transactionService.fail(transaction.refno, resp.agentMsg)
+ //其他明确错误,查询失败
+ logger.error("查询refno=[${transaction.refno}]流水结果返回失败:code=[${resp.agentCode}],message=[${resp.agentMsg}]")
}
}
} catch (ex: Exception) {
} else {
consumePayService.checkCanReverse(mainDtl.sourceType)
}
+ } else {
+ throw TransactionCheckException(TradeErrorCode.TRANSDTL_STATUS_ERROR,
+ "该笔交易未定义sourcetype, 不支持撤销")
}
val builder = TransactionBuilder().apply {
val cancelTrans = builder.cancelInit(mainDtl.refno, transactionService)
transactionService.wip(cancelTrans.refno)
val service = createAgentService(mainDtl.sourceType)
- val resp = service.pay(cancelTrans)
+ val resp = service.cancel(cancelTrans)
when (resp.code) {
AgentCode.SUCCESS -> {
transactionService.success(cancelTrans.refno, resp.agentRefno, false)
"${resp.agentCode}-${resp.agentMsg}").let {
return ResponseEntity.ok(ResponseBodyBuilder.create()
.fail(PayReverseResponse(cancelTrans.refno),
- TradeErrorCode.WAIT_QUERY_RESULT, "请查询撤销结果"))
+ TradeErrorCode.BUSINESS_DEAL_ERROR, "交易撤销失败!${resp.agentMsg}"))
}
}
} ?: return ResponseEntity.ok(ResponseBodyBuilder.create().fail(PayReverseResponse(),
- TradeErrorCode.BUSINESS_DEAL_ERROR, "流水不存在"))
+ TradeErrorCode.TRANSACTION_NOT_EXISTS, "流水不存在"))
}
/**
transactionService.success(refundTrans.refno, resp.agentRefno, false)
return ResponseEntity.ok(ResponseBodyBuilder.create()
- .success(PayReverseResponse(refundTrans.refno), "交易撤销成功"))
+ .success(PayReverseResponse(refundTrans.refno), "交易退款成功"))
}
AgentCode.REQUIRE_QUERY -> {
//待查询
agentQueryResultTask.queryResult(refundTrans, 0)
return ResponseEntity.ok(ResponseBodyBuilder.create()
.fail(PayReverseResponse(refundTrans.refno),
- TradeErrorCode.WAIT_QUERY_RESULT, "请查询撤销结果"))
+ TradeErrorCode.WAIT_QUERY_RESULT, "请查询退款结果"))
}
else -> transactionService.fail(refundTrans.refno,
"${resp.agentCode}-${resp.agentMsg}").let {
return ResponseEntity.ok(ResponseBodyBuilder.create()
.fail(PayReverseResponse(refundTrans.refno),
- TradeErrorCode.WAIT_QUERY_RESULT, "请查询撤销结果"))
+ TradeErrorCode.BUSINESS_DEAL_ERROR, "退款失败!${resp.agentMsg}"))
}
}