微信支付宝退款
This commit is contained in:
@@ -102,7 +102,8 @@ public class AliPayUtil {
|
||||
// 退款原因
|
||||
model.setRefundReason(reFundDTO.getRefundReason());
|
||||
}
|
||||
model.setOutRequestNo(UUID.randomUUID().toString().substring(0, 6));
|
||||
//退款请求号。标识一次退款请求,需要保证在交易号下唯一,如需部分退款,则此参数必传。
|
||||
model.setOutRequestNo(reFundDTO.getOutRequestNo());
|
||||
request.setBizModel(model);
|
||||
AlipayTradeRefundResponse response = null;
|
||||
|
||||
|
||||
@@ -50,8 +50,8 @@ public class AliPayController {
|
||||
* 支付宝退款
|
||||
*/
|
||||
@RequestMapping("/refund")
|
||||
public R refund(@RequestBody ReFundDTO reFundDTO) {
|
||||
String refund = aliPayService.refund(reFundDTO);
|
||||
public R refund(@RequestBody Map<String,Object> params) {
|
||||
String refund = aliPayService.refund(params);
|
||||
return R.ok().put("msg",refund);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,4 +35,9 @@ public class ReFundDTO {
|
||||
*/
|
||||
private String customerId;
|
||||
|
||||
/**
|
||||
* 退款请求号 标识一次退款请求,需要保证在交易号下唯一,如需部分退款,则此参数必传。
|
||||
*/
|
||||
private String outRequestNo;
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ package com.peanut.modules.pay.alipay.service;
|
||||
import com.peanut.modules.pay.alipay.dto.AlipayDTO;
|
||||
import com.peanut.modules.pay.alipay.dto.ReFundDTO;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public interface AliPayService {
|
||||
@@ -26,10 +27,8 @@ public interface AliPayService {
|
||||
|
||||
/**
|
||||
* 支付宝退款
|
||||
* @param reFundDTO
|
||||
* @return
|
||||
*/
|
||||
String refund(ReFundDTO reFundDTO);
|
||||
String refund(Map<String,Object> params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.alipay.api.internal.util.AlipaySignature;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.CopyUtils;
|
||||
import com.peanut.common.utils.OrderUtils;
|
||||
import com.peanut.modules.book.dao.BuyOrderProductDao;
|
||||
@@ -18,6 +19,8 @@ import com.peanut.modules.pay.alipay.config.AliPayUtil;
|
||||
import com.peanut.modules.pay.alipay.dto.AlipayDTO;
|
||||
import com.peanut.modules.pay.alipay.dto.ReFundDTO;
|
||||
import com.peanut.modules.pay.alipay.service.AliPayService;
|
||||
import com.peanut.modules.pay.refund.entity.PayRefundOrder;
|
||||
import com.peanut.modules.pay.refund.service.PayRefundOrderService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -54,6 +57,8 @@ public class AliPayServiceImpl implements AliPayService {
|
||||
private ShopProductBookDao shopProductBookDao;
|
||||
@Autowired
|
||||
private UserEbookBuyDao userEbookBuyDao;
|
||||
@Autowired
|
||||
private PayRefundOrderService refundOrderService;
|
||||
|
||||
@Override
|
||||
public String pay(AlipayDTO payDto) {
|
||||
@@ -248,8 +253,20 @@ public class AliPayServiceImpl implements AliPayService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String refund(ReFundDTO reFundDTO) {
|
||||
@Transactional
|
||||
public String refund(Map<String,Object> params) {
|
||||
log.info(">>>>>>>>>>App请求支付宝退款接口");
|
||||
LambdaQueryWrapper<PayZfbOrderEntity> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.eq(PayZfbOrderEntity::getRelevanceoid,params.get("orderSn").toString());
|
||||
PayZfbOrderEntity payZfbOrder = payZfbOrderService.getOne(wrapper);
|
||||
ReFundDTO reFundDTO = new ReFundDTO();
|
||||
reFundDTO.setOutTrandeNo(payZfbOrder.getOutTradeNo());
|
||||
reFundDTO.setTradeNo(payZfbOrder.getTradeNo());
|
||||
reFundDTO.setCustomerId(payZfbOrder.getCustomerid());
|
||||
reFundDTO.setRefundReason(params.get("reason").toString());
|
||||
reFundDTO.setRefundAmount(new BigDecimal(params.get("refundFee").toString()));
|
||||
// reFundDTO.setOutRequestNo(params.get("outRequestNo").toString());
|
||||
reFundDTO.setOutRequestNo(UUID.randomUUID().toString());
|
||||
Map<String, Object> map = aliPayUtil.aliPayRefund(reFundDTO);
|
||||
Object obj = map.get("msg");
|
||||
String resJson = obj.toString();
|
||||
@@ -260,23 +277,26 @@ public class AliPayServiceImpl implements AliPayService {
|
||||
"Y".equals(((Map)res.get("alipay_trade_refund_response")).get("fund_change"))){
|
||||
log.info(">>>>>>>>>>>支付宝退款成功!<<<<<<<<<<<<<");
|
||||
//表操作
|
||||
|
||||
|
||||
MPJLambdaWrapper<BuyOrder> w = new MPJLambdaWrapper();
|
||||
w.leftJoin(PayZfbOrderEntity.class,PayZfbOrderEntity::getRelevanceoid, BuyOrder::getOrderSn);
|
||||
w.eq("trade_no",((Map)res.get("alipay_trade_refund_response")).get("trade_no"));
|
||||
BuyOrder order = buyOrderService.getOne(w);
|
||||
PayRefundOrder refund = new PayRefundOrder();
|
||||
refund.setPayType("2");
|
||||
refund.setOrderId(order.getOrderId());
|
||||
refund.setTradeNo(((Map)res.get("alipay_trade_refund_response")).get("trade_no").toString());
|
||||
refund.setOutTradeNo(((Map)res.get("alipay_trade_refund_response")).get("out_trade_no").toString());
|
||||
refund.setRefundFee(((Map)res.get("alipay_trade_refund_response")).get("refund_fee").toString());
|
||||
refundOrderService.save(refund);
|
||||
refundOrderService.businessOpt(order);
|
||||
}
|
||||
return resJson;
|
||||
}
|
||||
|
||||
//TODO 更新订单状态
|
||||
|
||||
|
||||
|
||||
//TODO 更新用户优惠券状态
|
||||
|
||||
|
||||
//TODO 推送一路健康优惠券
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user