@@ -22,7 +22,6 @@ import com.alipay.api.domain.AlipayTradeOrderSettleModel;
|
||||
import com.alipay.api.domain.AlipayTradePayModel;
|
||||
import com.alipay.api.domain.AlipayTradePrecreateModel;
|
||||
import com.alipay.api.domain.AlipayTradeQueryModel;
|
||||
import com.alipay.api.domain.AlipayTradeRefundModel;
|
||||
import com.alipay.api.domain.Participant;
|
||||
import com.alipay.api.internal.util.AlipaySignature;
|
||||
import com.alipay.api.response.AlipayFundAuthOrderFreezeResponse;
|
||||
@@ -386,23 +385,9 @@ public class AliPayController extends AbstractAliPayApiController {
|
||||
* 退款
|
||||
*/
|
||||
@PostMapping(value = "/tradeRefund")
|
||||
public String tradeRefund(@RequestParam(required = false, name = "outTradeNo") String outTradeNo, @RequestParam(required = false, name = "tradeNo") String tradeNo) {
|
||||
public String tradeRefund(@RequestParam Long orderId) {
|
||||
|
||||
try {
|
||||
AlipayTradeRefundModel model = new AlipayTradeRefundModel();
|
||||
if (StringUtils.isNotEmpty(outTradeNo)) {
|
||||
model.setOutTradeNo(outTradeNo);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(tradeNo)) {
|
||||
model.setTradeNo(tradeNo);
|
||||
}
|
||||
model.setRefundAmount("0.01");
|
||||
model.setRefundReason("正常退款");
|
||||
return AliPayApi.tradeRefundToResponse(model).getBody();
|
||||
} catch (AlipayApiException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
return aliPayService.tradeRefund(orderId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,4 +15,6 @@ public interface IAliPayService {
|
||||
void wapPay(HttpServletResponse response, Long orderId, String returnUrl, String notifyUrl);
|
||||
|
||||
String notifyUrl(HttpServletRequest request, String publicKey);
|
||||
|
||||
String tradeRefund(Long orderId);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package org.wfc.payment.pay.alipay.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.alipay.api.domain.AlipayTradePagePayModel;
|
||||
import com.alipay.api.domain.AlipayTradeRefundModel;
|
||||
import com.alipay.api.domain.AlipayTradeWapPayModel;
|
||||
import com.alipay.api.internal.util.AlipaySignature;
|
||||
import com.ijpay.alipay.AliPayApi;
|
||||
@@ -33,12 +36,10 @@ public class AliPayServiceImpl implements IAliPayService {
|
||||
@Override
|
||||
public void pcPay(HttpServletResponse response, Long orderId, String returnUrl, String notifyUrl) {
|
||||
try {
|
||||
R<UOrderVo> orderRes = remoteUUserService.getOrderById(orderId);
|
||||
UOrderVo orderVo = orderRes.getData();
|
||||
if (orderVo == null) {
|
||||
String totalAmount = getAmountByOrder(orderId);
|
||||
if (StrUtil.isBlank(totalAmount)) {
|
||||
return;
|
||||
}
|
||||
String totalAmount = orderVo.getOrderAmount().setScale(2, RoundingMode.HALF_UP).toString();
|
||||
log.info("pc outTradeNo>" + orderId);
|
||||
|
||||
AlipayTradePagePayModel model = new AlipayTradePagePayModel();
|
||||
@@ -56,14 +57,21 @@ public class AliPayServiceImpl implements IAliPayService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wapPay(HttpServletResponse response, Long orderId, String returnUrl, String notifyUrl) {
|
||||
private String getAmountByOrder(Long orderId) {
|
||||
R<UOrderVo> orderRes = remoteUUserService.getOrderById(orderId);
|
||||
UOrderVo orderVo = orderRes.getData();
|
||||
if (orderVo == null) {
|
||||
return null;
|
||||
}
|
||||
return orderVo.getOrderAmount().setScale(2, RoundingMode.HALF_UP).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wapPay(HttpServletResponse response, Long orderId, String returnUrl, String notifyUrl) {
|
||||
String totalAmount = getAmountByOrder(orderId);
|
||||
if (StrUtil.isBlank(totalAmount)) {
|
||||
return;
|
||||
}
|
||||
String totalAmount = orderVo.getOrderAmount().setScale(2, RoundingMode.HALF_UP).toString();
|
||||
|
||||
String body = "WANFI WAP PAY";
|
||||
String subject = "WANFI PAY";
|
||||
@@ -108,4 +116,25 @@ public class AliPayServiceImpl implements IAliPayService {
|
||||
return "failure";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String tradeRefund(Long orderId) {
|
||||
try {
|
||||
String totalAmount = getAmountByOrder(orderId);
|
||||
if (StrUtil.isBlank(totalAmount)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
AlipayTradeRefundModel model = new AlipayTradeRefundModel();
|
||||
if (ObjectUtil.isNotNull(orderId)) {
|
||||
model.setOutTradeNo(orderId.toString());
|
||||
}
|
||||
model.setRefundAmount(totalAmount);
|
||||
model.setRefundReason("normal refund");
|
||||
return AliPayApi.tradeRefundToResponse(model).getBody();
|
||||
} catch (AlipayApiException e) {
|
||||
log.error("alipay refund error", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user