记得上下班打卡 | git大法好,push需谨慎

Commit 3dbc5b28 authored by 胡佳晨's avatar 胡佳晨

提交支付宝 退款回调

parent 1f74c37a
......@@ -19,7 +19,7 @@ public class NotifyUrlDto implements Serializable {
private String refundPrice;
// private String refundReason;
// private String refundType;
private String refundId;
// private String refundId;
private String refundAt;
private String refundError;
}
package com.liquidnet.service.dragon.channel.wepay.resp;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@Data
public class AliPayRefundReturnCallBackDto {
@JsonProperty("gmt_create")
private String gmtCreate;
@JsonProperty("charset")
private String charset;
@JsonProperty("seller_email")
private String sellerEmail;
@JsonProperty("gmt_payment")
private String gmtPayment;
@JsonProperty("notify_time")
private String notifyTime;
@JsonProperty("subject")
private String subject;
@JsonProperty("gmt_refund")
private String gmtRefund;
@JsonProperty("sign")
private String sign;
@JsonProperty("out_biz_no")
private String outBizNo;
@JsonProperty("body")
private String body;
@JsonProperty("buyer_id")
private String buyerId;
@JsonProperty("version")
private String version;
@JsonProperty("notify_id")
private String notifyId;
@JsonProperty("notify_type")
private String notifyType;
@JsonProperty("out_trade_no")
private String outTradeNo;
@JsonProperty("total_amount")
private String totalAmount;
@JsonProperty("trade_status")
private String tradeStatus;
@JsonProperty("refund_fee")
private String refundFee;
@JsonProperty("trade_no")
private String tradeNo;
@JsonProperty("auth_app_id")
private String authAppId;
@JsonProperty("buyer_logon_id")
private String buyerLogonId;
@JsonProperty("app_id")
private String appId;
@JsonProperty("sign_type")
private String signType;
@JsonProperty("seller_id")
private String sellerId;
}
......@@ -7,8 +7,10 @@ import com.liquidnet.common.cache.redis.util.RedisUtil;
import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.commons.lang.util.HttpUtil;
import com.liquidnet.commons.lang.util.IDGenerator;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.base.SqlMapping;
import com.liquidnet.service.dragon.channel.wepay.resp.AliPayRefundReturnCallBackDto;
import com.liquidnet.service.dragon.channel.wepay.resp.WePayRefundReturnCallBackDto;
import com.liquidnet.service.dragon.channel.wepay.resp.WePayRefundReturnCallBackInfoDto;
import com.liquidnet.service.dragon.constant.DragonConstant;
......@@ -21,6 +23,7 @@ import com.liquidnet.service.dragon.service.IDragonOrderRefundsService;
import com.liquidnet.service.dragon.utils.PayAlipayUtils;
import com.liquidnet.service.dragon.utils.PayWepayUtils;
import com.liquidnet.service.dragon.utils.XmlUtil;
import io.github.classgraph.json.JSONUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
......@@ -321,7 +324,6 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
contentDto.setResponse(response.getBody());
channelDto.setContent(contentDto);
return channelDto;
} catch (Exception e) {
e.printStackTrace();
log.error("");
......@@ -383,7 +385,7 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
dto.setRefundCode(info.getOutTradeNo());
dto.setRefundPrice(info.getRefundFee());
// dto.setRefundReason();
dto.setRefundId(info.getRefundId());
// dto.setRefundId(info.getRefundId());
// dto.setRefundType(info.getrefund);
dto.setRefundAt(refundAt);
dto.setRefundError(callBackDto.getReturnMsg());
......@@ -404,6 +406,62 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
}
}
public String aliPayRefundCallBack(String jsonStr) {
LocalDateTime nowTime = LocalDateTime.now();
try {
AliPayRefundReturnCallBackDto callBackDto = JsonUtils.fromJson(jsonStr, AliPayRefundReturnCallBackDto.class);
log.debug("DATA = " + callBackDto);
if (callBackDto.getNotifyType().equalsIgnoreCase("SUCCESS")) {
String outRefundNo = callBackDto.getOutBizNo();
String refundAt = callBackDto.getGmtRefund();
String outTradeNo = callBackDto.getOutTradeNo();
String refundFee = callBackDto.getRefundFee();
try {
sendMySqlRedis(
SqlMapping.get("dragon_order_refund_log.insert"),
new Object[]{outRefundNo, "退款原因", jsonStr, nowTime, nowTime}
);
sendMySqlRedis(
SqlMapping.get("dragon_order_refund_success.update"),
new Object[]{nowTime, refundAt, DragonConstant.RefundStatusEnum.STATUS_REFUNDED.getCode(), outRefundNo}
);
NotifyUrlDto dto = new NotifyUrlDto();
if (callBackDto.getNotifyType().equalsIgnoreCase("SUCCESS")) {
dto.setStatus(1);
} else {
dto.setStatus(0);
}
dto.setOrderRefundCode(outRefundNo);
dto.setRefundCode(outTradeNo);
dto.setRefundPrice(refundFee);
dto.setRefundAt(refundAt);
dto.setRefundError("退款失败");
sendNotifyUrl(dto);
return "<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>";
} catch (Exception e) {
e.printStackTrace();
log.error("");
return "<xml><return_code><![CDATA[FAIL]]></return_code><return_msg><![CDATA[ERROR]]></return_msg></xml>";
}
} else {
return "<xml><return_code><![CDATA[FAIL]]></return_code><return_msg><![CDATA[ERROR]]></return_msg></xml>";
}
} catch (Exception e) {
e.printStackTrace();
log.error("");
return "<xml><return_code><![CDATA[FAIL]]></return_code><return_msg><![CDATA[ERROR]]></return_msg></xml>";
}
}
/**
* out_biz_no -> orderRefundCode
* trade_no -> paymentId
* orderCode -> 不存在
* code -> out_trade_no
*
*/
/**
* 给 REDIS 队列发送消息 数据库相关
*
......@@ -438,7 +496,7 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
params.add("refundAt", notifyUrlDto.getRefundAt());
params.add("refundCode", notifyUrlDto.getRefundCode());
params.add("refundError", notifyUrlDto.getRefundError());
params.add("refundId", notifyUrlDto.getRefundId());
// params.add("refundId", notifyUrlDto.getRefundId());
params.add("refundPrice", notifyUrlDto.getRefundPrice());
params.add("status", notifyUrlDto.getStatus().toString());
String response = HttpUtil.post((String) redisUtil.get(DragonConstant.REFUND_REDIS_KET + notifyUrlDto.getOrderRefundCode()), params);
......
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