优化
This commit is contained in:
@ -45,4 +45,6 @@ public class ActivityPayDTO {
|
|||||||
private String voucherId;
|
private String voucherId;
|
||||||
|
|
||||||
private String transactionId;
|
private String transactionId;
|
||||||
|
|
||||||
|
private String openid;
|
||||||
}
|
}
|
@ -38,4 +38,6 @@ public class ActivityPaySaveReqVO {
|
|||||||
private String voucherId;
|
private String voucherId;
|
||||||
|
|
||||||
private String transactionId;
|
private String transactionId;
|
||||||
|
|
||||||
|
private String openid;
|
||||||
}
|
}
|
@ -6,6 +6,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 活动用餐桌子 Response VO")
|
@Schema(description = "管理后台 - 活动用餐桌子 Response VO")
|
||||||
@ -47,4 +48,7 @@ public class ActivityTableRespVO {
|
|||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
private LocalDate reserveTime;
|
||||||
|
|
||||||
|
private String type;
|
||||||
}
|
}
|
@ -30,4 +30,6 @@ public class ActivityTableSaveReqVO {
|
|||||||
@Schema(description = "电话")
|
@Schema(description = "电话")
|
||||||
private String mobile;
|
private String mobile;
|
||||||
|
|
||||||
|
private String type;
|
||||||
|
|
||||||
}
|
}
|
@ -62,4 +62,6 @@ public class ActivityPayDO extends BaseDO {
|
|||||||
private String voucher;
|
private String voucher;
|
||||||
|
|
||||||
private String transactionId;
|
private String transactionId;
|
||||||
|
|
||||||
|
private String openid;
|
||||||
}
|
}
|
@ -56,4 +56,6 @@ public class ActivityTableDO extends BaseDO {
|
|||||||
|
|
||||||
private LocalDate reserveTime;
|
private LocalDate reserveTime;
|
||||||
|
|
||||||
|
private String type;
|
||||||
|
|
||||||
}
|
}
|
@ -123,6 +123,7 @@ public class ActivityTableServiceImpl implements ActivityTableService {
|
|||||||
LocalDate localDate = LocalDate.parse(time, formatter);
|
LocalDate localDate = LocalDate.parse(time, formatter);
|
||||||
return activityTableMapper.selectList(Wrappers.lambdaQuery(ActivityTableDO.class)
|
return activityTableMapper.selectList(Wrappers.lambdaQuery(ActivityTableDO.class)
|
||||||
.eq(ActivityTableDO::getReserveTime, localDate)
|
.eq(ActivityTableDO::getReserveTime, localDate)
|
||||||
|
.eq(ActivityTableDO::getType, "0")
|
||||||
.eq(ActivityTableDO::getActivityId, activityId));
|
.eq(ActivityTableDO::getActivityId, activityId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,6 +139,7 @@ public class ActivityTableServiceImpl implements ActivityTableService {
|
|||||||
List<ActivityTableDO> activityTableDOS = activityTableMapper.selectList(Wrappers.lambdaQuery(ActivityTableDO.class)
|
List<ActivityTableDO> activityTableDOS = activityTableMapper.selectList(Wrappers.lambdaQuery(ActivityTableDO.class)
|
||||||
.eq(ActivityTableDO::getReserveTime, localDate)
|
.eq(ActivityTableDO::getReserveTime, localDate)
|
||||||
.eq(ActivityTableDO::getActivityId, vo.getActivityId())
|
.eq(ActivityTableDO::getActivityId, vo.getActivityId())
|
||||||
|
.eq(ActivityTableDO::getType, "0")
|
||||||
.in(ActivityTableDO::getSerialNumber, vo.getSerialNumbers()));
|
.in(ActivityTableDO::getSerialNumber, vo.getSerialNumbers()));
|
||||||
|
|
||||||
if (!activityTableDOS.isEmpty()) {
|
if (!activityTableDOS.isEmpty()) {
|
||||||
|
@ -152,6 +152,7 @@ public class PayNotifyController {
|
|||||||
activityPayDTO.setDiningPeriod( deserializedMap.get("diningPeriod"));
|
activityPayDTO.setDiningPeriod( deserializedMap.get("diningPeriod"));
|
||||||
activityPayDTO.setVoucherId( deserializedMap.get("voucherId"));
|
activityPayDTO.setVoucherId( deserializedMap.get("voucherId"));
|
||||||
activityPayDTO.setTransactionId( notify.getChannelOrderNo());
|
activityPayDTO.setTransactionId( notify.getChannelOrderNo());
|
||||||
|
activityPayDTO.setOpenid(deserializedMap.get("openid"));
|
||||||
|
|
||||||
activityApi.createActivityPay(activityPayDTO);
|
activityApi.createActivityPay(activityPayDTO);
|
||||||
notifyRedisTemplate.delete("RESERVED" + notify.getOutTradeNo());
|
notifyRedisTemplate.delete("RESERVED" + notify.getOutTradeNo());
|
||||||
|
@ -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.service.divide.DivideService;
|
import cn.iocoder.yudao.module.pay.controller.app.divide.vo.RefundMoneyVO;
|
||||||
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,4 +31,10 @@ public class AppDivideController {
|
|||||||
return success(profitsharingService.drawMoney(drawMoneyVO));
|
return success(profitsharingService.drawMoney(drawMoneyVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/refundMoney")
|
||||||
|
@Operation(summary = "退款")
|
||||||
|
public CommonResult<Boolean> refundMoney(@RequestBody RefundMoneyVO refundMoney) {
|
||||||
|
return success(profitsharingService.refundMoney(refundMoney));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package cn.iocoder.yudao.module.pay.controller.app.divide.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 分账单新增/修改 Request VO")
|
||||||
|
@Data
|
||||||
|
public class RefundMoneyVO {
|
||||||
|
|
||||||
|
@Schema(description = "用户编号")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@Schema(description = "总金额,单位:分")
|
||||||
|
//@NotNull(message = "总金额,单位:分不能为空")
|
||||||
|
private Integer totalPrice;
|
||||||
|
/**
|
||||||
|
* 渠道用户编号
|
||||||
|
*/
|
||||||
|
private String channelUserId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1-用户退款 2-商家退款
|
||||||
|
*/
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
private String transactionId;
|
||||||
|
|
||||||
|
}
|
@ -184,6 +184,7 @@ public class PayOrderServiceImpl implements PayOrderService {
|
|||||||
stringStringHashMap.put("reserveTime",reqVO.getReserveTime());
|
stringStringHashMap.put("reserveTime",reqVO.getReserveTime());
|
||||||
stringStringHashMap.put("dish",reqVO.getDish());
|
stringStringHashMap.put("dish",reqVO.getDish());
|
||||||
stringStringHashMap.put("diningPeriod",reqVO.getDiningPeriod());
|
stringStringHashMap.put("diningPeriod",reqVO.getDiningPeriod());
|
||||||
|
stringStringHashMap.put("openid",reqVO.getChannelExtras().get("openid"));
|
||||||
if(reqVO.getVoucherId()!=null){
|
if(reqVO.getVoucherId()!=null){
|
||||||
stringStringHashMap.put("voucherId",reqVO.getVoucherId().toString());
|
stringStringHashMap.put("voucherId",reqVO.getVoucherId().toString());
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
package cn.iocoder.yudao.module.pay.service.wxprofitsharing;
|
package cn.iocoder.yudao.module.pay.service.wxprofitsharing;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import javax.validation.*;
|
|
||||||
import cn.iocoder.yudao.module.pay.controller.admin.wxprofitsharing.vo.*;
|
|
||||||
import cn.iocoder.yudao.module.pay.controller.app.divide.vo.DrawMoneyVO;
|
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.divide.DivideDO;
|
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wxprofitsharing.WxProfitsharingDO;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
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.app.divide.vo.DrawMoneyVO;
|
||||||
|
import cn.iocoder.yudao.module.pay.controller.app.divide.vo.RefundMoneyVO;
|
||||||
|
import cn.iocoder.yudao.module.pay.dal.dataobject.wxprofitsharing.WxProfitsharingDO;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信分账记录 Service 接口
|
* 微信分账记录 Service 接口
|
||||||
@ -73,4 +73,9 @@ public interface WxProfitsharingService {
|
|||||||
* 分账回退
|
* 分账回退
|
||||||
*/
|
*/
|
||||||
void returnMoney(Long payWxOrderId,int returnMoney);
|
void returnMoney(Long payWxOrderId,int returnMoney);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 活动退款
|
||||||
|
*/
|
||||||
|
Boolean refundMoney(RefundMoneyVO refundMoney);
|
||||||
}
|
}
|
@ -1,10 +1,12 @@
|
|||||||
package cn.iocoder.yudao.module.pay.service.wxprofitsharing;
|
package cn.iocoder.yudao.module.pay.service.wxprofitsharing;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.iocoder.yudao.framework.common.exception.ErrorCode;
|
||||||
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.PayClient;
|
import cn.iocoder.yudao.framework.pay.core.client.PayClient;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.divide.PayDivideBackRespDto;
|
import cn.iocoder.yudao.framework.pay.core.client.dto.divide.PayDivideBackRespDto;
|
||||||
import cn.iocoder.yudao.framework.pay.core.client.dto.divide.PayDivideBackUnifiedDto;
|
import cn.iocoder.yudao.framework.pay.core.client.dto.divide.PayDivideBackUnifiedDto;
|
||||||
@ -13,21 +15,21 @@ 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.framework.pay.core.enums.divide.PayDivideStatusRespEnum;
|
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.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.divide.DivideDO;
|
|
||||||
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.divideinfo.DivideInfoDO;
|
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.dividerecord.DivideRecordDO;
|
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.refundlog.PayRefundLogDO;
|
import cn.iocoder.yudao.module.pay.dal.dataobject.refundlog.PayRefundLogDO;
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.refundrecord.RefundRecordDO;
|
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wxorder.WxOrderDO;
|
import cn.iocoder.yudao.module.pay.dal.dataobject.wxorder.WxOrderDO;
|
||||||
|
import cn.iocoder.yudao.module.pay.dal.dataobject.wxprofitsharing.WxProfitsharingDO;
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wxprofitsharinginfo.WxProfitsharingInfoDO;
|
import cn.iocoder.yudao.module.pay.dal.dataobject.wxprofitsharinginfo.WxProfitsharingInfoDO;
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wxprofitsharingreturn.WxProfitsharingReturnDO;
|
import cn.iocoder.yudao.module.pay.dal.dataobject.wxprofitsharingreturn.WxProfitsharingReturnDO;
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wxrefund.WxRefundDO;
|
import cn.iocoder.yudao.module.pay.dal.dataobject.wxrefund.WxRefundDO;
|
||||||
import cn.iocoder.yudao.module.pay.dal.mysql.refundlog.PayRefundLogMapper;
|
import cn.iocoder.yudao.module.pay.dal.mysql.refundlog.PayRefundLogMapper;
|
||||||
import cn.iocoder.yudao.module.pay.dal.mysql.wxorder.WxOrderMapper;
|
import cn.iocoder.yudao.module.pay.dal.mysql.wxorder.WxOrderMapper;
|
||||||
|
import cn.iocoder.yudao.module.pay.dal.mysql.wxprofitsharing.WxProfitsharingMapper;
|
||||||
import cn.iocoder.yudao.module.pay.dal.mysql.wxprofitsharinginfo.WxProfitsharingInfoMapper;
|
import cn.iocoder.yudao.module.pay.dal.mysql.wxprofitsharinginfo.WxProfitsharingInfoMapper;
|
||||||
import cn.iocoder.yudao.module.pay.dal.mysql.wxprofitsharingreturn.WxProfitsharingReturnMapper;
|
import cn.iocoder.yudao.module.pay.dal.mysql.wxprofitsharingreturn.WxProfitsharingReturnMapper;
|
||||||
import cn.iocoder.yudao.module.pay.dal.mysql.wxrefund.WxRefundMapper;
|
import cn.iocoder.yudao.module.pay.dal.mysql.wxrefund.WxRefundMapper;
|
||||||
@ -42,27 +44,18 @@ import com.github.binarywang.wxpay.bean.profitsharing.result.ProfitSharingV3Resu
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.pay.controller.admin.wxprofitsharing.vo.*;
|
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wxprofitsharing.WxProfitsharingDO;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.pay.dal.mysql.wxprofitsharing.WxProfitsharingMapper;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*;
|
import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*;
|
||||||
@ -852,4 +845,103 @@ public class WxProfitsharingServiceImpl implements WxProfitsharingService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean refundMoney(RefundMoneyVO refundMoney) {
|
||||||
|
|
||||||
|
//判断用户是否正在退款
|
||||||
|
List<WxRefundDO> refundDOList1 = wxRefundMapper.selectList(Wrappers.<WxRefundDO>lambdaQuery()
|
||||||
|
.eq(WxRefundDO::getStatus, PayDivideRefundStatusRespEnum.PROCESSING.getStatus())
|
||||||
|
.eq(WxRefundDO::getUserId, refundMoney.getUserId()));
|
||||||
|
if (CollectionUtil.isNotEmpty(refundDOList1)) {
|
||||||
|
throw new ServiceException(REFUND_NOT_COMPLETE);
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断是否有金额可退款
|
||||||
|
int money = refundMoney.getTotalPrice();
|
||||||
|
|
||||||
|
//交易时间超过一年的订单无法提交退款(按支付成功时间+365天计算)
|
||||||
|
LocalDateTime now = LocalDateTime.now(); // 获取当前时间
|
||||||
|
LocalDateTime threeYearsAgo = now.minusDays(364);
|
||||||
|
|
||||||
|
//查询最近的充值订单,时间倒序退款
|
||||||
|
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));
|
||||||
|
|
||||||
|
//筛选出未分账的订单
|
||||||
|
List<WxOrderDO> unDivideList = wxOrderDOList.stream().filter(vo -> vo.getRefundPrice().equals(vo.getProfitsharingPrice())).collect(Collectors.toList());
|
||||||
|
|
||||||
|
//筛选出已分账的订单
|
||||||
|
List<WxOrderDO> divideList = wxOrderDOList.stream().filter(vo -> !vo.getRefundPrice().equals(vo.getProfitsharingPrice())).collect(Collectors.toList());
|
||||||
|
|
||||||
|
//筛选出分账完的订单
|
||||||
|
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());
|
||||||
|
|
||||||
|
|
||||||
|
int failNum = 0;
|
||||||
|
//调用微信退款接口
|
||||||
|
if (CollectionUtil.isNotEmpty(refundDOList)) {
|
||||||
|
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(wxOrderDO.getTransactionId())
|
||||||
|
.setReason("预定退款")
|
||||||
|
.setRefundPrice(wxRefundDO.getTotalPrice())
|
||||||
|
.setOutRefundNo(wxRefundDO.getOutRefundNo())
|
||||||
|
.setPayPrice(wxOrderDO.getTotalPrice())
|
||||||
|
.setNotifyUrl(genChannelRefundNotifyUrl(channel));
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return failNum <= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WxRefundDO createRefundOne(WxOrderDO wxOrderDO, int money, Long userId) {
|
||||||
|
|
||||||
|
//退款订单
|
||||||
|
List<WxRefundDO> backList = new ArrayList<>();
|
||||||
|
|
||||||
|
WxRefundDO wxRefundDO = new WxRefundDO();
|
||||||
|
wxRefundDO.setPayWxOrderId(wxOrderDO.getId());
|
||||||
|
wxRefundDO.setUserId(userId);
|
||||||
|
wxRefundDO.setOutRefundNo(noRedisDAO.generate(payProperties.getRefundNoPrefix()));
|
||||||
|
wxRefundDO.setTotalPrice(money);
|
||||||
|
|
||||||
|
return wxRefundDO;
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user