优化
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.member.api.activitypay;
|
package cn.iocoder.yudao.module.member.api.activitypay;
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.member.api.activitypay.dto.ActivityPayDTO;
|
import cn.iocoder.yudao.module.member.api.activitypay.dto.ActivityPayDTO;
|
||||||
|
import cn.iocoder.yudao.module.member.api.activitypay.dto.ActivityPayRespDTO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户收件地址 API 接口
|
* 用户收件地址 API 接口
|
||||||
@ -12,4 +13,6 @@ public interface ActivityApi {
|
|||||||
|
|
||||||
void createActivityPay(ActivityPayDTO createReqVO);
|
void createActivityPay(ActivityPayDTO createReqVO);
|
||||||
|
|
||||||
|
ActivityPayRespDTO getActivityPay(Long id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.api.activitypay.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
|
||||||
|
public class ActivityPayRespDTO {
|
||||||
|
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
|
||||||
|
private Long activityId;
|
||||||
|
|
||||||
|
|
||||||
|
private String serialNumbers;
|
||||||
|
|
||||||
|
|
||||||
|
private BigDecimal price;
|
||||||
|
|
||||||
|
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
|
||||||
|
private String mobile;
|
||||||
|
|
||||||
|
private String transactionId;
|
||||||
|
|
||||||
|
private String openid;
|
||||||
|
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
}
|
@ -1,8 +1,11 @@
|
|||||||
package cn.iocoder.yudao.module.member.api.activitypay;
|
package cn.iocoder.yudao.module.member.api.activitypay;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.module.member.api.activitypay.dto.ActivityPayDTO;
|
import cn.iocoder.yudao.module.member.api.activitypay.dto.ActivityPayDTO;
|
||||||
|
import cn.iocoder.yudao.module.member.api.activitypay.dto.ActivityPayRespDTO;
|
||||||
import cn.iocoder.yudao.module.member.controller.admin.activitypay.vo.ActivityPaySaveReqVO;
|
import cn.iocoder.yudao.module.member.controller.admin.activitypay.vo.ActivityPaySaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.activitypay.ActivityPayDO;
|
||||||
import cn.iocoder.yudao.module.member.service.activitypay.ActivityPayService;
|
import cn.iocoder.yudao.module.member.service.activitypay.ActivityPayService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@ -26,4 +29,10 @@ public class ActivityApiImpl implements ActivityApi {
|
|||||||
bean.setMenu(createReqVO.getMenu());
|
bean.setMenu(createReqVO.getMenu());
|
||||||
activityPayService.addActivityPay(bean);
|
activityPayService.addActivityPay(bean);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActivityPayRespDTO getActivityPay(Long id) {
|
||||||
|
ActivityPayDO activityPay = activityPayService.getActivityPay(id);
|
||||||
|
return BeanUtils.toBean(activityPay, ActivityPayRespDTO.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.member.controller.admin.activitypay.vo;
|
package cn.iocoder.yudao.module.member.controller.admin.activitypay.vo;
|
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelIgnore;
|
||||||
import com.alibaba.excel.annotation.ExcelProperty;
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -38,9 +39,14 @@ public class ActivityPayPageRVO {
|
|||||||
@ExcelProperty("预约就餐时间")
|
@ExcelProperty("预约就餐时间")
|
||||||
private String reserveTime;
|
private String reserveTime;
|
||||||
|
|
||||||
@ExcelProperty("电话")
|
@ExcelIgnore
|
||||||
private String voucher;
|
private String voucher;
|
||||||
|
|
||||||
|
@ExcelProperty("代金券使用数量")
|
||||||
|
private int voucherNum;
|
||||||
|
|
||||||
@ExcelProperty("创建时间")
|
@ExcelProperty("创建时间")
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -24,6 +24,7 @@ import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
|||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@ -325,6 +326,15 @@ public class ActivityPayServiceImpl implements ActivityPayService {
|
|||||||
queryDTOPage.setSize(pageVO.getPageSize());
|
queryDTOPage.setSize(pageVO.getPageSize());
|
||||||
|
|
||||||
Page<ActivityPayPageRVO> activityAwardsUserRespVOPage = activityPayMapper.getPage1(queryDTOPage, pageVO);
|
Page<ActivityPayPageRVO> activityAwardsUserRespVOPage = activityPayMapper.getPage1(queryDTOPage, pageVO);
|
||||||
|
|
||||||
|
activityAwardsUserRespVOPage.getRecords().forEach(activityPayPageRVO -> {
|
||||||
|
if(StringUtils.isNotBlank(activityPayPageRVO.getVoucher())){
|
||||||
|
int length = activityPayPageRVO.getVoucher().split(",").length;
|
||||||
|
activityPayPageRVO.setVoucherNum(length);
|
||||||
|
}else{
|
||||||
|
activityPayPageRVO.setVoucherNum(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
return new PageResult<>(activityAwardsUserRespVOPage.getRecords(), activityAwardsUserRespVOPage.getTotal());
|
return new PageResult<>(activityAwardsUserRespVOPage.getRecords(), activityAwardsUserRespVOPage.getTotal());
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -94,6 +94,7 @@ public interface ErrorCodeConstants {
|
|||||||
ErrorCode ORDER_NOT_COMPLETE = new ErrorCode(1_007_902_002, "还有订单尚未结算");
|
ErrorCode ORDER_NOT_COMPLETE = new ErrorCode(1_007_902_002, "还有订单尚未结算");
|
||||||
ErrorCode WX_ACCOUNT_NO = new ErrorCode(1_007_902_002, "微信充值金额不足");
|
ErrorCode WX_ACCOUNT_NO = new ErrorCode(1_007_902_002, "微信充值金额不足");
|
||||||
ErrorCode REFUND_NOT_COMPLETE = new ErrorCode(1_007_902_002, "还有退款正在进行");
|
ErrorCode REFUND_NOT_COMPLETE = new ErrorCode(1_007_902_002, "还有退款正在进行");
|
||||||
|
ErrorCode REFUND_MOBILE_ERROR = new ErrorCode(1_007_902_002, "手机号错误");
|
||||||
|
|
||||||
|
|
||||||
ErrorCode DIVIDE_COMPANY_NOT_EXISTS = new ErrorCode(1_007_903_001, "分账公司不存在");
|
ErrorCode DIVIDE_COMPANY_NOT_EXISTS = new ErrorCode(1_007_903_001, "分账公司不存在");
|
||||||
|
@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.pay.controller.app.divide;
|
|||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.module.pay.controller.app.divide.vo.DrawMoneyVO;
|
import cn.iocoder.yudao.module.pay.controller.app.divide.vo.DrawMoneyVO;
|
||||||
import cn.iocoder.yudao.module.pay.controller.app.divide.vo.RefundMoneyVO;
|
import cn.iocoder.yudao.module.pay.controller.app.divide.vo.ActivityRefundMoney;
|
||||||
import cn.iocoder.yudao.module.pay.service.wxprofitsharing.WxProfitsharingService;
|
import cn.iocoder.yudao.module.pay.service.wxprofitsharing.WxProfitsharingService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
@ -31,10 +31,10 @@ public class AppDivideController {
|
|||||||
return success(profitsharingService.drawMoney(drawMoneyVO));
|
return success(profitsharingService.drawMoney(drawMoneyVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/refundMoney")
|
@PostMapping("/activityRefundMoney")
|
||||||
@Operation(summary = "退款")
|
@Operation(summary = "活动退款")
|
||||||
public CommonResult<Boolean> refundMoney(@RequestBody RefundMoneyVO refundMoney) {
|
public CommonResult<Boolean> activityRefundMoney(@RequestBody ActivityRefundMoney refundMoney) {
|
||||||
return success(profitsharingService.refundMoney(refundMoney));
|
return success(profitsharingService.activityRefundMoney(refundMoney));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -5,11 +5,14 @@ import lombok.Data;
|
|||||||
|
|
||||||
@Schema(description = "管理后台 - 分账单新增/修改 Request VO")
|
@Schema(description = "管理后台 - 分账单新增/修改 Request VO")
|
||||||
@Data
|
@Data
|
||||||
public class RefundMoneyVO {
|
public class ActivityRefundMoney {
|
||||||
|
|
||||||
@Schema(description = "用户编号")
|
@Schema(description = "用户编号")
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
|
@Schema(description = "订单编号")
|
||||||
|
private Long orderId;
|
||||||
|
|
||||||
@Schema(description = "总金额,单位:分")
|
@Schema(description = "总金额,单位:分")
|
||||||
//@NotNull(message = "总金额,单位:分不能为空")
|
//@NotNull(message = "总金额,单位:分不能为空")
|
||||||
private Integer totalPrice;
|
private Integer totalPrice;
|
||||||
@ -18,11 +21,8 @@ public class RefundMoneyVO {
|
|||||||
*/
|
*/
|
||||||
private String channelUserId;
|
private String channelUserId;
|
||||||
|
|
||||||
/**
|
|
||||||
* 1-用户退款 2-商家退款
|
|
||||||
*/
|
|
||||||
private String type;
|
|
||||||
|
|
||||||
private String transactionId;
|
@Schema(description = "电话号码")
|
||||||
|
private String mobile;
|
||||||
|
|
||||||
}
|
}
|
@ -4,7 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|||||||
import cn.iocoder.yudao.module.pay.controller.admin.wxprofitsharing.vo.WxProfitsharingPageReqVO;
|
import cn.iocoder.yudao.module.pay.controller.admin.wxprofitsharing.vo.WxProfitsharingPageReqVO;
|
||||||
import cn.iocoder.yudao.module.pay.controller.admin.wxprofitsharing.vo.WxProfitsharingSaveReqVO;
|
import cn.iocoder.yudao.module.pay.controller.admin.wxprofitsharing.vo.WxProfitsharingSaveReqVO;
|
||||||
import cn.iocoder.yudao.module.pay.controller.app.divide.vo.DrawMoneyVO;
|
import cn.iocoder.yudao.module.pay.controller.app.divide.vo.DrawMoneyVO;
|
||||||
import cn.iocoder.yudao.module.pay.controller.app.divide.vo.RefundMoneyVO;
|
import cn.iocoder.yudao.module.pay.controller.app.divide.vo.ActivityRefundMoney;
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wxprofitsharing.WxProfitsharingDO;
|
import cn.iocoder.yudao.module.pay.dal.dataobject.wxprofitsharing.WxProfitsharingDO;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
@ -77,5 +77,5 @@ public interface WxProfitsharingService {
|
|||||||
/**
|
/**
|
||||||
* 活动退款
|
* 活动退款
|
||||||
*/
|
*/
|
||||||
Boolean refundMoney(RefundMoneyVO refundMoney);
|
void activityRefundMoney(ActivityRefundMoney refundMoney);
|
||||||
}
|
}
|
@ -15,10 +15,12 @@ import cn.iocoder.yudao.framework.pay.core.client.dto.divide.PayDivideUnifiedDto
|
|||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO;
|
import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO;
|
import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundUnifiedReqDTO;
|
||||||
import cn.iocoder.yudao.framework.pay.core.enums.divide.PayDivideRefundStatusRespEnum;
|
import cn.iocoder.yudao.framework.pay.core.enums.divide.PayDivideRefundStatusRespEnum;
|
||||||
|
import cn.iocoder.yudao.module.member.api.activitypay.ActivityApi;
|
||||||
|
import cn.iocoder.yudao.module.member.api.activitypay.dto.ActivityPayRespDTO;
|
||||||
import cn.iocoder.yudao.module.pay.controller.admin.wxprofitsharing.vo.WxProfitsharingPageReqVO;
|
import cn.iocoder.yudao.module.pay.controller.admin.wxprofitsharing.vo.WxProfitsharingPageReqVO;
|
||||||
import cn.iocoder.yudao.module.pay.controller.admin.wxprofitsharing.vo.WxProfitsharingSaveReqVO;
|
import cn.iocoder.yudao.module.pay.controller.admin.wxprofitsharing.vo.WxProfitsharingSaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.pay.controller.app.divide.vo.ActivityRefundMoney;
|
||||||
import cn.iocoder.yudao.module.pay.controller.app.divide.vo.DrawMoneyVO;
|
import cn.iocoder.yudao.module.pay.controller.app.divide.vo.DrawMoneyVO;
|
||||||
import cn.iocoder.yudao.module.pay.controller.app.divide.vo.RefundMoneyVO;
|
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO;
|
import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO;
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.dividecompany.DivideCompanyDO;
|
import cn.iocoder.yudao.module.pay.dal.dataobject.dividecompany.DivideCompanyDO;
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.refundlog.PayRefundLogDO;
|
import cn.iocoder.yudao.module.pay.dal.dataobject.refundlog.PayRefundLogDO;
|
||||||
@ -92,6 +94,8 @@ public class WxProfitsharingServiceImpl implements WxProfitsharingService {
|
|||||||
private WxRefundMapper wxRefundMapper;
|
private WxRefundMapper wxRefundMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private PayRefundLogMapper payRefundLogMapper;
|
private PayRefundLogMapper payRefundLogMapper;
|
||||||
|
@Resource
|
||||||
|
private ActivityApi activityApi;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createWxProfitsharing(WxProfitsharingSaveReqVO createReqVO) {
|
public Long createWxProfitsharing(WxProfitsharingSaveReqVO createReqVO) {
|
||||||
@ -847,7 +851,7 @@ public class WxProfitsharingServiceImpl implements WxProfitsharingService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean refundMoney(RefundMoneyVO refundMoney) {
|
public void activityRefundMoney(ActivityRefundMoney refundMoney) {
|
||||||
|
|
||||||
//判断用户是否正在退款
|
//判断用户是否正在退款
|
||||||
List<WxRefundDO> refundDOList1 = wxRefundMapper.selectList(Wrappers.<WxRefundDO>lambdaQuery()
|
List<WxRefundDO> refundDOList1 = wxRefundMapper.selectList(Wrappers.<WxRefundDO>lambdaQuery()
|
||||||
@ -857,91 +861,80 @@ public class WxProfitsharingServiceImpl implements WxProfitsharingService {
|
|||||||
throw new ServiceException(REFUND_NOT_COMPLETE);
|
throw new ServiceException(REFUND_NOT_COMPLETE);
|
||||||
}
|
}
|
||||||
|
|
||||||
//判断是否有金额可退款
|
//判断退款金额是否正确
|
||||||
int money = refundMoney.getTotalPrice();
|
|
||||||
|
ActivityPayRespDTO activityPay = activityApi.getActivityPay(refundMoney.getOrderId());
|
||||||
|
if (activityPay == null) {
|
||||||
|
throw new ServiceException(new ErrorCode(1_007_902_002, "未查询到付款订单"));
|
||||||
|
}
|
||||||
|
if (!activityPay.getMobile().equals(refundMoney.getMobile())) {
|
||||||
|
throw new ServiceException(REFUND_MOBILE_ERROR);
|
||||||
|
}
|
||||||
|
int money = activityPay.getPrice().multiply(new BigDecimal(100)).intValue();
|
||||||
|
|
||||||
|
|
||||||
//交易时间超过一年的订单无法提交退款(按支付成功时间+365天计算)
|
//交易时间超过一年的订单无法提交退款(按支付成功时间+365天计算)
|
||||||
LocalDateTime now = LocalDateTime.now(); // 获取当前时间
|
LocalDateTime now = LocalDateTime.now(); // 获取当前时间
|
||||||
LocalDateTime threeYearsAgo = now.minusDays(364);
|
LocalDateTime oneYearAgo = now.minusDays(364);
|
||||||
|
if (activityPay.getCreateTime().isBefore(oneYearAgo)) {
|
||||||
//查询最近的充值订单,时间倒序退款
|
throw new ServiceException(new ErrorCode(1_007_902_002, "订单已超退款时限"));
|
||||||
List<WxOrderDO> wxOrderDOList = wxOrderMapper.selectList(Wrappers.<WxOrderDO>lambdaQuery()
|
|
||||||
.eq(WxOrderDO::getOpenId, refundMoney.getChannelUserId())
|
|
||||||
.eq(WxOrderDO::getTransactionId, refundMoney.getTransactionId())
|
|
||||||
.gt(WxOrderDO::getRefundPrice, 0)
|
|
||||||
.ge(WxOrderDO::getCreateTime, threeYearsAgo)
|
|
||||||
.orderByDesc(WxOrderDO::getCreateTime));
|
|
||||||
|
|
||||||
if(wxOrderDOList.isEmpty()){
|
|
||||||
throw new ServiceException(new ErrorCode(1_007_902_002, "未查询到付款订单"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Map<Long, WxOrderDO> orderMap = wxOrderDOList.stream().collect(Collectors.toMap(WxOrderDO::getId, vo -> vo));
|
//查询充值订单
|
||||||
|
WxOrderDO wxOrderDO = wxOrderMapper.selectOne(Wrappers.<WxOrderDO>lambdaQuery()
|
||||||
//筛选出未分账的订单
|
.eq(WxOrderDO::getOpenId, refundMoney.getChannelUserId())
|
||||||
List<WxOrderDO> unDivideList = wxOrderDOList.stream().filter(vo -> vo.getRefundPrice().equals(vo.getProfitsharingPrice())).collect(Collectors.toList());
|
.eq(WxOrderDO::getTransactionId, activityPay.getTransactionId())
|
||||||
|
.last("limit 1"));
|
||||||
//筛选出已分账的订单
|
if (wxOrderDO == null) {
|
||||||
List<WxOrderDO> divideList = wxOrderDOList.stream().filter(vo -> !vo.getRefundPrice().equals(vo.getProfitsharingPrice())).collect(Collectors.toList());
|
throw new ServiceException(new ErrorCode(1_007_902_002, "充值订单不存在"));
|
||||||
|
}
|
||||||
//筛选出分账完的订单
|
|
||||||
List<WxOrderDO> divideCpList = divideList.stream().filter(vo -> vo.getProfitsharingPrice() == 0).collect(Collectors.toList());
|
|
||||||
|
|
||||||
//剩下的是未分账完的订单
|
|
||||||
List<WxOrderDO> divideUnCpList = divideList.stream().filter(vo -> vo.getProfitsharingPrice() != 0).collect(Collectors.toList());
|
|
||||||
|
|
||||||
//生成退款订单
|
//生成退款订单
|
||||||
List<WxRefundDO> refundDOList = createRefund(unDivideList, divideCpList, divideUnCpList, money, refundMoney.getUserId());
|
WxRefundDO refundDO = createActivityRefund(wxOrderDO, money, refundMoney.getUserId());
|
||||||
|
|
||||||
|
|
||||||
int failNum = 0;
|
|
||||||
//调用微信退款接口
|
//调用微信退款接口
|
||||||
if (CollectionUtil.isNotEmpty(refundDOList)) {
|
PayChannelDO channel = channelService.validPayChannel(wxOrderDO.getChannelId());
|
||||||
for (WxRefundDO wxRefundDO : refundDOList) {
|
|
||||||
WxOrderDO wxOrderDO = orderMap.get(wxRefundDO.getPayWxOrderId());
|
|
||||||
|
|
||||||
PayChannelDO channel = channelService.validPayChannel(wxOrderDO.getChannelId());
|
PayClient client = channelService.getPayClient(wxOrderDO.getChannelId());
|
||||||
|
PayRefundUnifiedReqDTO payRefundUnifiedReqDTO = new PayRefundUnifiedReqDTO();
|
||||||
|
payRefundUnifiedReqDTO.setTransactionId(activityPay.getTransactionId())
|
||||||
|
.setReason("预定退款")
|
||||||
|
.setRefundPrice(refundDO.getTotalPrice())
|
||||||
|
.setOutRefundNo(refundDO.getOutRefundNo())
|
||||||
|
.setPayPrice(refundDO.getTotalPrice())
|
||||||
|
.setNotifyUrl(genChannelRefundNotifyUrlActivity(channel,"1"));
|
||||||
|
PayRefundRespDTO payRefundRespDTO = client.unifiedRefund(payRefundUnifiedReqDTO);
|
||||||
|
|
||||||
PayClient client = channelService.getPayClient(wxOrderDO.getChannelId());
|
String channelRefundNo = payRefundRespDTO.getChannelRefundNo();
|
||||||
PayRefundUnifiedReqDTO payRefundUnifiedReqDTO = new PayRefundUnifiedReqDTO();
|
refundDO.setRefundId(channelRefundNo);
|
||||||
payRefundUnifiedReqDTO.setTransactionId(wxOrderDO.getTransactionId())
|
if (cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum.WAITING.getStatus().equals(payRefundRespDTO.getStatus())) {
|
||||||
.setReason("预定退款")
|
refundDO.setStatus(PayDivideRefundStatusRespEnum.PROCESSING.getStatus());
|
||||||
.setRefundPrice(wxRefundDO.getTotalPrice())
|
} else if (cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum.SUCCESS.getStatus().equals(payRefundRespDTO.getStatus())) {
|
||||||
.setOutRefundNo(wxRefundDO.getOutRefundNo())
|
refundDO.setStatus(PayDivideRefundStatusRespEnum.SUCCESS.getStatus());
|
||||||
.setPayPrice(wxOrderDO.getTotalPrice())
|
} else {
|
||||||
.setNotifyUrl(genChannelRefundNotifyUrl(channel));
|
refundDO.setStatus(PayDivideRefundStatusRespEnum.ABNORMAL.getStatus());
|
||||||
PayRefundRespDTO payRefundRespDTO = client.unifiedRefund(payRefundUnifiedReqDTO);
|
|
||||||
|
|
||||||
String channelRefundNo = payRefundRespDTO.getChannelRefundNo();
|
|
||||||
wxRefundDO.setRefundId(channelRefundNo);
|
|
||||||
if (cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum.WAITING.getStatus().equals(payRefundRespDTO.getStatus())) {
|
|
||||||
wxRefundDO.setStatus(PayDivideRefundStatusRespEnum.PROCESSING.getStatus());
|
|
||||||
} else if (cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum.SUCCESS.getStatus().equals(payRefundRespDTO.getStatus())) {
|
|
||||||
wxRefundDO.setStatus(PayDivideRefundStatusRespEnum.SUCCESS.getStatus());
|
|
||||||
} else {
|
|
||||||
failNum++;
|
|
||||||
wxRefundDO.setStatus(PayDivideRefundStatusRespEnum.ABNORMAL.getStatus());
|
|
||||||
}
|
|
||||||
|
|
||||||
wxRefundMapper.insert(wxRefundDO);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
wxRefundMapper.insert(refundDO);
|
||||||
return failNum <= 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public WxRefundDO createRefundOne(WxOrderDO wxOrderDO, int money, Long userId) {
|
public WxRefundDO createActivityRefund(WxOrderDO wxOrderDO, int money, Long userId) {
|
||||||
|
|
||||||
//退款订单
|
//退款订单
|
||||||
List<WxRefundDO> backList = new ArrayList<>();
|
|
||||||
|
|
||||||
WxRefundDO wxRefundDO = new WxRefundDO();
|
WxRefundDO wxRefundDO = new WxRefundDO();
|
||||||
wxRefundDO.setPayWxOrderId(wxOrderDO.getId());
|
wxRefundDO.setPayWxOrderId(wxOrderDO.getId());
|
||||||
wxRefundDO.setUserId(userId);
|
wxRefundDO.setUserId(userId);
|
||||||
wxRefundDO.setOutRefundNo(noRedisDAO.generate(payProperties.getRefundNoPrefix()));
|
wxRefundDO.setOutRefundNo(noRedisDAO.generate(payProperties.getRefundNoPrefix()));
|
||||||
wxRefundDO.setTotalPrice(money);
|
wxRefundDO.setTotalPrice(money);
|
||||||
|
String jsonString = JsonUtils.toJsonString(wxOrderDO);
|
||||||
|
divideRedisTemplate.opsForValue().set("RA" + wxOrderDO.getId(), jsonString);
|
||||||
return wxRefundDO;
|
return wxRefundDO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String genChannelRefundNotifyUrlActivity(PayChannelDO channel,String type) {
|
||||||
|
if("1".equals(type)){
|
||||||
|
return payProperties.getRefundNotifyUrl() + "/" + channel.getId();
|
||||||
|
}
|
||||||
|
return payProperties.getRefundNotifyUrl() + "/" + channel.getId();
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user