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

Commit 4a5227f6 authored by 胡佳晨's avatar 胡佳晨

`提交支付宝 退款回调`

parent 00a50615
......@@ -18,6 +18,7 @@ import com.liquidnet.service.dragon.dto.DragonOrdersDto;
import com.liquidnet.service.dragon.dto.DragonPayBaseReqDto;
import com.liquidnet.service.dragon.dto.DragonPayBaseRespDto;
import com.liquidnet.service.dragon.dto.DragonPayOrderQueryRespDto;
import com.liquidnet.service.dragon.service.impl.DragonOrderRefundsServiceImpl;
import com.liquidnet.service.dragon.utils.DataUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -52,6 +53,9 @@ public class PayChannelStrategyAlipayImpl implements IPayChannelStrategy {
@Autowired
private AlipayBiz alipayBiz;
@Autowired
private DragonOrderRefundsServiceImpl dragonOrderRefundsService;
@Value("${liquidnet.dragon.wepay.partnerKey}")
private String partnerKey;
......@@ -66,7 +70,9 @@ public class PayChannelStrategyAlipayImpl implements IPayChannelStrategy {
Map<String, String> notifyMap = new HashMap<String, String>();
notifyMap = alipayBiz.parseNotifyMsg(requestParams);
log.info("dragonNotify-->alipay json : {}", JSON.toJSONString(notifyMap));
if(notifyMap.containsKey("refund_fee") || notifyMap.containsKey("gmt_refund") || notifyMap.containsKey("out_biz_no")) {
dragonOrderRefundsService.aliPayRefundCallBack(JSON.toJSONString(notifyMap));
}
log.info("接收到{}支付结果{}", payType, notifyMap);
String returnStr = null;
......
package com.liquidnet.service.dragon.controller;
import com.liquidnet.service.dragon.service.IDragonOrderRefundsService;
import com.liquidnet.service.dragon.service.IDragonOrdersService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
......
package com.liquidnet.service.dragon.service.impl;
import com.alibaba.fastjson.JSON;
import com.alipay.api.request.AlipayTradeFastpayRefundQueryRequest;
import com.alipay.api.request.AlipayTradeRefundRequest;
import com.alipay.api.response.AlipayTradeFastpayRefundQueryResponse;
import com.alipay.api.response.AlipayTradeRefundResponse;
import com.liquidnet.common.cache.redis.util.RedisUtil;
import com.liquidnet.commons.lang.util.DateUtil;
......@@ -28,6 +30,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.DateUtils;
import org.apache.http.entity.StringEntity;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -411,46 +414,50 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
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();
AlipayTradeFastpayRefundQueryRequest request = new AlipayTradeFastpayRefundQueryRequest();//创建API对应的request类
log.debug("AlipayTradeFastpayRefundQueryRequest -> data = " + JSON.toJSONString(request));
request.setBizContent("{" +
"\"out_trade_no\":\"" + callBackDto.getOutTradeNo() + "\"," +
"\"trade_no\":\"" + callBackDto.getTradeNo() + "\"," +
"\"out_request_no\":\"" + callBackDto.getOutBizNo() + "\"}"); //设置业务参数
AlipayTradeFastpayRefundQueryResponse response = PayAlipayUtils.getInstance().getHttpClient().execute(request);
if (response.getRefundChannelStatus().equalsIgnoreCase("SUCCESS")) {
try {
sendMySqlRedis(
SqlMapping.get("dragon_order_refund_log.insert"),
new Object[]{outRefundNo, "退款原因", jsonStr, nowTime, nowTime}
new Object[]{response.getOutRequestNo(), response.getRefundReason(), jsonStr, nowTime, nowTime}
);
sendMySqlRedis(
SqlMapping.get("dragon_order_refund_success.update"),
new Object[]{nowTime, refundAt, DragonConstant.RefundStatusEnum.STATUS_REFUNDED.getCode(), outRefundNo}
new Object[]{nowTime, response.getGmtRefundPay(), DragonConstant.RefundStatusEnum.STATUS_REFUNDED.getCode(), response.getOutRequestNo()}
);
NotifyUrlDto dto = new NotifyUrlDto();
if (callBackDto.getNotifyType().equalsIgnoreCase("SUCCESS")) {
if (response.getRefundChannelStatus().equalsIgnoreCase("SUCCESS")) {
dto.setStatus(1);
} else {
dto.setStatus(0);
}
dto.setOrderRefundCode(outRefundNo);
dto.setRefundCode(outTradeNo);
dto.setRefundPrice(refundFee);
dto.setRefundAt(refundAt);
dto.setRefundError("退款失败");
dto.setOrderRefundCode(response.getOutRequestNo());
dto.setRefundCode(response.getOutTradeNo());
dto.setRefundPrice(response.getRefundAmount());
dto.setRefundAt(DateUtil.format(response.getGmtRefundPay(), DateUtil.Formatter.yyyyMMddHHmmss));
dto.setRefundPrice(response.getRefundAmount());
dto.setRefundError(response.getSubMsg());
sendNotifyUrl(dto);
return "<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>";
return "success";
} catch (Exception e) {
e.printStackTrace();
log.error("");
return "<xml><return_code><![CDATA[FAIL]]></return_code><return_msg><![CDATA[ERROR]]></return_msg></xml>";
return "fail";
}
} else {
return "<xml><return_code><![CDATA[FAIL]]></return_code><return_msg><![CDATA[ERROR]]></return_msg></xml>";
return "fail";
}
} catch (Exception e) {
e.printStackTrace();
log.error("");
return "<xml><return_code><![CDATA[FAIL]]></return_code><return_msg><![CDATA[ERROR]]></return_msg></xml>";
return "fail";
}
}
......@@ -497,7 +504,7 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
params.add("refundCode", notifyUrlDto.getRefundCode());
params.add("refundError", notifyUrlDto.getRefundError());
// params.add("refundId", notifyUrlDto.getRefundId());
params.add("refundPrice", notifyUrlDto.getRefundPrice());
// 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);
log.debug("RETURN RESPONSE=" + response);
......
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