feat: 商城退款
parent
dea7cb0b77
commit
630e1d454e
|
@ -3,9 +3,11 @@ package cn.iocoder.yudao.module.shop.service.order.impl;
|
|||
import cn.iocoder.yudao.framework.common.enums.Constants;
|
||||
import cn.iocoder.yudao.module.infra.api.config.ApiConfigApi;
|
||||
import cn.iocoder.yudao.module.shop.dal.dataobject.order.StoreOrder;
|
||||
import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.RechargeOrderDO;
|
||||
import cn.iocoder.yudao.module.shop.dal.mysql.order.StoreOrderMapper;
|
||||
import cn.iocoder.yudao.module.shop.request.order.StoreOrderRefundRequest;
|
||||
import cn.iocoder.yudao.module.shop.service.order.StoreOrderRefundService;
|
||||
import cn.iocoder.yudao.module.shop.support.pay.WxPayStrategy;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -27,6 +29,8 @@ public class StoreOrderRefundServiceImpl extends ServiceImpl<StoreOrderMapper, S
|
|||
|
||||
@Autowired
|
||||
private ApiConfigApi apiConfigApi;
|
||||
@Autowired
|
||||
private WxPayStrategy wxPayStrategy;
|
||||
|
||||
@Override
|
||||
public void refund(StoreOrderRefundRequest request, StoreOrder storeOrder) {
|
||||
|
@ -70,7 +74,10 @@ public class StoreOrderRefundServiceImpl extends ServiceImpl<StoreOrderMapper, S
|
|||
String apiDomain = apiConfigApi.getConfigKey(Constants.CONFIG_KEY_API_URL).toString();
|
||||
|
||||
// TODO 微信退款
|
||||
|
||||
RechargeOrderDO orderDO = new RechargeOrderDO();
|
||||
orderDO.setOrderId(request.getOrderNo());
|
||||
orderDO.setPayPrice(request.getAmount());
|
||||
wxPayStrategy.refund(orderDO);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1142,7 +1142,7 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
|
|||
orderCheck(request);
|
||||
// 初始化订单
|
||||
MemberUserRespDTO user = userService.getUser(loginUser.getId());
|
||||
String code = generateBillNo("MEMBER");
|
||||
String code = OrderUtil.generateBillNo("MEMBER");
|
||||
RechargeOrderDO orderDO = initializeOrder(request, code, user);
|
||||
// 获取支付策略
|
||||
IPayStrategy payStrategy = strategySupport.getPayStrategy(request.getPayType());
|
||||
|
@ -1227,7 +1227,7 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
|
|||
// 获取支付策略
|
||||
IPayStrategy payStrategy = strategySupport.getPayStrategy(orderDO.getPayType());
|
||||
payStrategy.refund(orderDO);
|
||||
return null;
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1335,18 +1335,6 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
|
|||
return orderDO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单号
|
||||
*
|
||||
* @param prefix
|
||||
* @return
|
||||
*/
|
||||
public static String generateBillNo(String prefix) {
|
||||
String idStr = IdWorker.getIdStr();
|
||||
idStr = prefix + "_" + idStr;
|
||||
return idStr;
|
||||
}
|
||||
|
||||
private void orderCheck(OrderContentRequest request) {
|
||||
Assert.isTrue(!CollectionUtils.isEmpty(request.getOrderInfos()), "订单信息不能为空!");
|
||||
if (StringUtils.isNotBlank(request.getUserPhone()) && StringUtils.isNotBlank(request.getConfirmPhone())) {
|
||||
|
|
|
@ -7,6 +7,7 @@ import cn.iocoder.yudao.framework.pay.config.WxPayOneAutoConfiguration;
|
|||
import cn.iocoder.yudao.framework.pay.properties.WxPayProperties;
|
||||
import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.RechargeOrderDO;
|
||||
import cn.iocoder.yudao.module.shop.response.member.InitOrderResponse;
|
||||
import cn.iocoder.yudao.module.shop.utils.OrderUtil;
|
||||
import com.github.binarywang.wxpay.bean.request.WxPayRefundV3Request;
|
||||
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request;
|
||||
import com.github.binarywang.wxpay.bean.result.WxPayRefundV3Result;
|
||||
|
@ -60,12 +61,19 @@ public class WxPayStrategy implements IPayStrategy{
|
|||
return response;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String article="MEMBER_11111";
|
||||
|
||||
article=article.replace("MEMBER","TUIKUAN");
|
||||
System.out.println(article);
|
||||
}
|
||||
@Override
|
||||
public void refund(RechargeOrderDO orderDO) {
|
||||
WxPayRefundV3Request wxPayRefundV3Request = new WxPayRefundV3Request();
|
||||
wxPayRefundV3Request.setOutTradeNo(orderDO.getOrderId());
|
||||
wxPayRefundV3Request.setOutRefundNo(orderDO.getPaySerialNumber());
|
||||
wxPayRefundV3Request.setTransactionId(orderDO.getOrderId());
|
||||
String code = OrderUtil.generateBillNo("TUIKUAN");
|
||||
wxPayRefundV3Request.setOutRefundNo(code);
|
||||
wxPayRefundV3Request.setTransactionId(orderDO.getPaySerialNumber());
|
||||
wxPayRefundV3Request.setReason("商品已售完");
|
||||
wxPayRefundV3Request.setNotifyUrl(payProperties.getRefundNotifyUrl());
|
||||
int sum = orderDO.getPayPrice().multiply(new BigDecimal("100")).intValue();
|
||||
|
|
|
@ -10,6 +10,7 @@ import cn.iocoder.yudao.module.shop.constants.SysConfigConstants;
|
|||
import cn.iocoder.yudao.module.shop.dal.dataobject.order.StoreOrder;
|
||||
import cn.iocoder.yudao.module.shop.service.order.StoreOrderService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -117,4 +118,16 @@ public class OrderUtil {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单号
|
||||
*
|
||||
* @param prefix
|
||||
* @return
|
||||
*/
|
||||
public static String generateBillNo(String prefix) {
|
||||
String idStr = IdWorker.getIdStr();
|
||||
idStr = prefix + "_" + idStr;
|
||||
return idStr;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue