Commit e58f110a authored by 33's avatar 33

退款失败原因

parent fd241994
...@@ -39,6 +39,9 @@ public class Refund { ...@@ -39,6 +39,9 @@ public class Refund {
@ApiModelProperty("退款发起渠道 1-用户发起 2-后台运营发起") @ApiModelProperty("退款发起渠道 1-用户发起 2-后台运营发起")
private Integer channel; private Integer channel;
@ApiModelProperty("退款失败信息")
private String failMessage;
private Date createDate; private Date createDate;
private Date updateDate; private Date updateDate;
......
...@@ -29,4 +29,7 @@ public class PaymentVo extends Order { ...@@ -29,4 +29,7 @@ public class PaymentVo extends Order {
@ApiModelProperty("退款状态 1- 退款中 2-退款成功 3-退款失败") @ApiModelProperty("退款状态 1- 退款中 2-退款成功 3-退款失败")
private Integer refundStatus; private Integer refundStatus;
@ApiModelProperty("退款失败信息")
private String failMessage;
} }
...@@ -289,10 +289,10 @@ public class WxPayServiceImpl implements WxPayService { ...@@ -289,10 +289,10 @@ public class WxPayServiceImpl implements WxPayService {
CloseableHttpResponse response = httpClient.execute(httpPost); CloseableHttpResponse response = httpClient.execute(httpPost);
String bodyAsString = EntityUtils.toString(response.getEntity()); String bodyAsString = EntityUtils.toString(response.getEntity());
log.info("退款接口返回参数: {}", bodyAsString); log.info("退款接口返回参数: {}", bodyAsString);
JSONObject jsonObject = JSONUtil.parseObj(bodyAsString);
int statusCode = response.getStatusLine().getStatusCode(); int statusCode = response.getStatusLine().getStatusCode();
// 发起退款成功 // 发起退款成功
if (statusCode == 200 || statusCode == 204) { if (statusCode == 200 || statusCode == 204) {
JSONObject jsonObject = JSONUtil.parseObj(bodyAsString);
refund.setRefundId(jsonObject.getStr("refund_id")); refund.setRefundId(jsonObject.getStr("refund_id"));
refund.setTransactionId(jsonObject.getStr("transaction_id")); refund.setTransactionId(jsonObject.getStr("transaction_id"));
refund.setUserReceivedAccount(jsonObject.getStr("user_received_account")); refund.setUserReceivedAccount(jsonObject.getStr("user_received_account"));
...@@ -303,6 +303,7 @@ public class WxPayServiceImpl implements WxPayService { ...@@ -303,6 +303,7 @@ public class WxPayServiceImpl implements WxPayService {
} else { } else {
// 发起退款失败 // 发起退款失败
refund.setRefundStatus(RefundStatus.FAINED.getStatus()); refund.setRefundStatus(RefundStatus.FAINED.getStatus());
refund.setFailMessage(jsonObject.getStr("message"));
result = false; result = false;
} }
// 插入退款信息 // 插入退款信息
...@@ -312,7 +313,7 @@ public class WxPayServiceImpl implements WxPayService { ...@@ -312,7 +313,7 @@ public class WxPayServiceImpl implements WxPayService {
refund.setChannel(channel); refund.setChannel(channel);
refundService.saveOrUpdate(refund); refundService.saveOrUpdate(refund);
// 如果是用户端发起的退款, 失败时则需抛出异常,告知系统管理员退款失败 // 如果是用户端发起的退款, 失败时则需抛出异常,告知系统管理员退款失败
if (RefundLaunchChannel.USER.getCode().equals(channel)) { if (RefundLaunchChannel.USER.getCode().equals(channel) && result) {
// 异步发送退款短信通知 // 异步发送退款短信通知
smsService.sendRefundSms(orderId); smsService.sendRefundSms(orderId);
} }
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
SELECT SELECT
t.order_id, t.order_id,
t.refund_status, t.refund_status,
t.fail_message,
t.update_date as trade_time, t.update_date as trade_time,
o.*, o.*,
u.telephone, u.telephone,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment