退款和分润优化
This commit is contained in:
@ -14,6 +14,9 @@ public enum PayStatusEnum {
|
|||||||
USERPAYING("USERPAYING", "用户支付中"),
|
USERPAYING("USERPAYING", "用户支付中"),
|
||||||
SUCCESS("SUCCESS", "支付成功"),
|
SUCCESS("SUCCESS", "支付成功"),
|
||||||
PAYERROR("PAYERROR", "支付失败"),
|
PAYERROR("PAYERROR", "支付失败"),
|
||||||
|
REFUNDING("REFUNDING", "退款中"),
|
||||||
|
REFUND_SUCCESS("REFUND_SUCCESS", "退款成功"),
|
||||||
|
REFUND_ERROR("REFUND_ERROR", "退款失败"),
|
||||||
;
|
;
|
||||||
private final String code;
|
private final String code;
|
||||||
|
|
||||||
|
|||||||
@ -15,6 +15,7 @@ public enum SubOrderTypeEnum {
|
|||||||
RENTCAR("RENTCAR", "租车订单"),
|
RENTCAR("RENTCAR", "租车订单"),
|
||||||
RENTBATTEY("RENTBATTEY", "租电订单"),
|
RENTBATTEY("RENTBATTEY", "租电订单"),
|
||||||
OVERDUE("OVERDUE", "逾期订单"),
|
OVERDUE("OVERDUE", "逾期订单"),
|
||||||
|
FD_DEPOSIT("FD_DEPOSIT", "退押金订单")
|
||||||
;
|
;
|
||||||
private final String code;
|
private final String code;
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,16 @@
|
|||||||
|
package com.sczx.order.mapper;
|
||||||
|
|
||||||
|
import com.sczx.order.po.BaseUserReferralPO;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 用户引荐信息 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zhangli
|
||||||
|
* @since 2025-08-24 23:25:03
|
||||||
|
*/
|
||||||
|
public interface BaseUserReferralMapper extends BaseMapper<BaseUserReferralPO> {
|
||||||
|
|
||||||
|
}
|
||||||
66
src/main/java/com/sczx/order/po/BaseUserReferralPO.java
Normal file
66
src/main/java/com/sczx/order/po/BaseUserReferralPO.java
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
package com.sczx.order.po;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 用户引荐信息
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zhangli
|
||||||
|
* @since 2025-08-24 23:25:03
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@TableName("zc_base_user_referral")
|
||||||
|
@ApiModel(value = "BaseUserReferralPO对象", description = "用户引荐信息")
|
||||||
|
public class BaseUserReferralPO implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty("id主键")
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@ApiModelProperty("被引荐人id")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@ApiModelProperty("被引荐人手机号")
|
||||||
|
private String userPhoneNumber;
|
||||||
|
|
||||||
|
@ApiModelProperty("引荐人id")
|
||||||
|
private Long referralUserId;
|
||||||
|
|
||||||
|
@ApiModelProperty("引荐人手机号")
|
||||||
|
private String referralUserPhoneNumber;
|
||||||
|
|
||||||
|
@ApiModelProperty("奖励截止日期")
|
||||||
|
private LocalDate awardDeadline;
|
||||||
|
|
||||||
|
@ApiModelProperty("奖励比例")
|
||||||
|
private BigDecimal awardRate;
|
||||||
|
|
||||||
|
@ApiModelProperty("引荐订单")
|
||||||
|
private String referralOrderNo;
|
||||||
|
|
||||||
|
@ApiModelProperty("删除标志(0代表存在 2代表删除)")
|
||||||
|
private String delFlag;
|
||||||
|
|
||||||
|
@ApiModelProperty("创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("更新时间")
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -58,6 +58,9 @@ public class OrderSubPO implements Serializable {
|
|||||||
@ApiModelProperty("支付ID")
|
@ApiModelProperty("支付ID")
|
||||||
private String paymentId;
|
private String paymentId;
|
||||||
|
|
||||||
|
@ApiModelProperty("退款单ID")
|
||||||
|
private String refundId;
|
||||||
|
|
||||||
@ApiModelProperty("支付状态")
|
@ApiModelProperty("支付状态")
|
||||||
private String payStatus;
|
private String payStatus;
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,16 @@
|
|||||||
|
package com.sczx.order.repository;
|
||||||
|
|
||||||
|
import com.sczx.order.po.BaseUserReferralPO;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 用户引荐信息 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zhangli
|
||||||
|
* @since 2025-08-24 23:25:03
|
||||||
|
*/
|
||||||
|
public interface BaseUserReferralRepo extends IService<BaseUserReferralPO> {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
package com.sczx.order.repository.impl;
|
||||||
|
|
||||||
|
import com.sczx.order.po.BaseUserReferralPO;
|
||||||
|
import com.sczx.order.mapper.BaseUserReferralMapper;
|
||||||
|
import com.sczx.order.repository.BaseUserReferralRepo;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 用户引荐信息 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zhangli
|
||||||
|
* @since 2025-08-24 23:25:03
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class BaseUserReferralRepoImpl extends ServiceImpl<BaseUserReferralMapper, BaseUserReferralPO> implements BaseUserReferralRepo {
|
||||||
|
|
||||||
|
}
|
||||||
31
src/main/java/com/sczx/order/service/PayService.java
Normal file
31
src/main/java/com/sczx/order/service/PayService.java
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package com.sczx.order.service;
|
||||||
|
|
||||||
|
import com.sczx.order.dto.SimpleUserInfoDTO;
|
||||||
|
import com.sczx.order.thirdpart.dto.UnifiedPaymentInfoDTO;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
public interface PayService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预支付下单
|
||||||
|
* @param payType
|
||||||
|
* @param body
|
||||||
|
* @param companyId
|
||||||
|
* @param outTradeNo
|
||||||
|
* @param userInfoDTO
|
||||||
|
* @param totalFee
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
UnifiedPaymentInfoDTO prepayOrder(String payType, String body, Long companyId, String outTradeNo, SimpleUserInfoDTO userInfoDTO, BigDecimal totalFee);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 退款
|
||||||
|
* @param payType
|
||||||
|
* @param companyId
|
||||||
|
* @param outTradeNo
|
||||||
|
* @param totalFee
|
||||||
|
* @param refundFee
|
||||||
|
*/
|
||||||
|
String refundOrder(String payType,Long companyId,String outTradeNo, BigDecimal totalFee, BigDecimal refundFee);
|
||||||
|
}
|
||||||
@ -9,16 +9,9 @@ import com.sczx.order.common.enums.WalletChangeTypeEnum;
|
|||||||
import com.sczx.order.dto.OrderDistribDTO;
|
import com.sczx.order.dto.OrderDistribDTO;
|
||||||
import com.sczx.order.dto.OrderDistribQueryReq;
|
import com.sczx.order.dto.OrderDistribQueryReq;
|
||||||
import com.sczx.order.exception.BizException;
|
import com.sczx.order.exception.BizException;
|
||||||
import com.sczx.order.po.BaseWalletChangePO;
|
import com.sczx.order.po.*;
|
||||||
import com.sczx.order.po.BaseWalletPO;
|
import com.sczx.order.repository.*;
|
||||||
import com.sczx.order.po.OrderDistribPO;
|
|
||||||
import com.sczx.order.po.OrderMainPO;
|
|
||||||
import com.sczx.order.repository.BaseWalletChangeRepo;
|
|
||||||
import com.sczx.order.repository.BaseWalletRepo;
|
|
||||||
import com.sczx.order.repository.OrderDistribRepo;
|
|
||||||
import com.sczx.order.repository.OrderMainRepo;
|
|
||||||
import com.sczx.order.service.OrderDistribService;
|
import com.sczx.order.service.OrderDistribService;
|
||||||
import com.sczx.order.thirdpart.dto.BaseUserReferralDTO;
|
|
||||||
import com.sczx.order.thirdpart.dto.CompanyDTO;
|
import com.sczx.order.thirdpart.dto.CompanyDTO;
|
||||||
import com.sczx.order.thirdpart.dto.CompanyStoreDTO;
|
import com.sczx.order.thirdpart.dto.CompanyStoreDTO;
|
||||||
import com.sczx.order.thirdpart.dto.SysConfigDTO;
|
import com.sczx.order.thirdpart.dto.SysConfigDTO;
|
||||||
@ -57,6 +50,9 @@ public class OrderDistribServiceImpl implements OrderDistribService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private UserInteg userInteg;
|
private UserInteg userInteg;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BaseUserReferralRepo baseUserReferralRepo;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPage<OrderDistribDTO> pageQueryOrderDistrib(Integer pageNo, Integer pageSize, OrderDistribQueryReq orderDistribQueryReq) {
|
public IPage<OrderDistribDTO> pageQueryOrderDistrib(Integer pageNo, Integer pageSize, OrderDistribQueryReq orderDistribQueryReq) {
|
||||||
return orderDistribRepo.pageQueryOrderDistrib(pageNo, pageSize, orderDistribQueryReq);
|
return orderDistribRepo.pageQueryOrderDistrib(pageNo, pageSize, orderDistribQueryReq);
|
||||||
@ -87,16 +83,23 @@ public class OrderDistribServiceImpl implements OrderDistribService {
|
|||||||
addOrderDistribPOList.add(storeDistribPO);
|
addOrderDistribPOList.add(storeDistribPO);
|
||||||
|
|
||||||
//推荐人分润
|
//推荐人分润
|
||||||
BaseUserReferralDTO baseUserReferralDTO = userInteg.getUserReferralByUserId(orderMainPO.getCustomerId());
|
OrderDistribPO referralDistribPO = null;
|
||||||
if(Objects.nonNull(baseUserReferralDTO)
|
LambdaQueryWrapper<BaseUserReferralPO> userReferralWrapper = new LambdaQueryWrapper<>();
|
||||||
&& Objects.nonNull(baseUserReferralDTO.getReferralUserId())){
|
userReferralWrapper.eq(BaseUserReferralPO::getUserId, orderMainPO.getCustomerId())
|
||||||
|
.eq(BaseUserReferralPO::getDelFlag, "0")
|
||||||
|
.isNull(BaseUserReferralPO::getReferralOrderNo).last(" limit 1");
|
||||||
|
BaseUserReferralPO baseUserReferralPO = baseUserReferralRepo.getOne(userReferralWrapper);
|
||||||
|
if(Objects.nonNull(baseUserReferralPO)
|
||||||
|
&& Objects.nonNull(baseUserReferralPO.getReferralUserId())){
|
||||||
|
|
||||||
|
|
||||||
List<SysConfigDTO> configList = storeInteg.listConfigByConfigKey(Lists.newArrayList("sczx.invitation.day", "sczx.invitation.rate"));
|
List<SysConfigDTO> configList = storeInteg.listConfigByConfigKey(Lists.newArrayList("sczx.invitation.day", "sczx.invitation.rate"));
|
||||||
String invitationDay = String.valueOf(configList.stream().filter(config -> "sczx.invitation.day".equals(config.getConfigKey())).findFirst().orElse(null));
|
String invitationDay = String.valueOf(configList.stream().filter(config -> "sczx.invitation.day".equals(config.getConfigKey())).findFirst().orElse(null));
|
||||||
LocalDate awardDeadline = baseUserReferralDTO.getCreateTime().toLocalDate().plusDays(Integer.parseInt(invitationDay));
|
LocalDate awardDeadline = baseUserReferralPO.getCreateTime().toLocalDate().plusDays(Integer.parseInt(invitationDay));
|
||||||
//判断奖励是否过期
|
//判断奖励是否过期
|
||||||
if(awardDeadline.isAfter(LocalDate.now())){
|
if(awardDeadline.isAfter(LocalDate.now())){
|
||||||
String invitationRate = String.valueOf(configList.stream().filter(config -> "sczx.invitation.rate".equals(config.getConfigKey())).findFirst().orElse(null));
|
String invitationRate = String.valueOf(configList.stream().filter(config -> "sczx.invitation.rate".equals(config.getConfigKey())).findFirst().orElse(null));
|
||||||
OrderDistribPO referralDistribPO = getOrderDistribPO(orderMainPO.getOrderId(),orderMainPO.getOrderNo(),DistribTypeEnum.REFERRAL.getCode(),invitationRate,orderMainPO.getOrderAmount(),null,null,baseUserReferralDTO.getReferralUserId());
|
referralDistribPO = getOrderDistribPO(orderMainPO.getOrderId(),orderMainPO.getOrderNo(),DistribTypeEnum.REFERRAL.getCode(),invitationRate,orderMainPO.getOrderAmount(),null,null,baseUserReferralPO.getReferralUserId());
|
||||||
addOrderDistribPOList.add(referralDistribPO);
|
addOrderDistribPOList.add(referralDistribPO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -129,6 +132,12 @@ public class OrderDistribServiceImpl implements OrderDistribService {
|
|||||||
baseWalletChangePO.setChangeAmount(storeDistribPO.getDistribAmount());
|
baseWalletChangePO.setChangeAmount(storeDistribPO.getDistribAmount());
|
||||||
baseWalletChangePO.setReferralOrderNo(orderMainPO.getOrderNo());
|
baseWalletChangePO.setReferralOrderNo(orderMainPO.getOrderNo());
|
||||||
baseWalletChangeRepo.save(baseWalletChangePO);
|
baseWalletChangeRepo.save(baseWalletChangePO);
|
||||||
|
|
||||||
|
//更新推荐信息,防止重复分润
|
||||||
|
LambdaUpdateWrapper<BaseUserReferralPO> updateWrapper = new LambdaUpdateWrapper<>();
|
||||||
|
updateWrapper.eq(BaseUserReferralPO::getUserId, orderMainPO.getCustomerId())
|
||||||
|
.set(BaseUserReferralPO::getReferralOrderNo, storeDistribPO.getOrderNo());
|
||||||
|
baseUserReferralRepo.update(updateWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -21,9 +21,9 @@ import com.sczx.order.repository.OrderMainRepo;
|
|||||||
import com.sczx.order.repository.OrderSubRepo;
|
import com.sczx.order.repository.OrderSubRepo;
|
||||||
import com.sczx.order.service.OrderDistribService;
|
import com.sczx.order.service.OrderDistribService;
|
||||||
import com.sczx.order.service.OrderService;
|
import com.sczx.order.service.OrderService;
|
||||||
|
import com.sczx.order.service.PayService;
|
||||||
import com.sczx.order.thirdpart.dto.*;
|
import com.sczx.order.thirdpart.dto.*;
|
||||||
import com.sczx.order.thirdpart.dto.req.CarQueryConditionReq;
|
import com.sczx.order.thirdpart.dto.req.CarQueryConditionReq;
|
||||||
import com.sczx.order.thirdpart.dto.req.PaymentRequest;
|
|
||||||
import com.sczx.order.thirdpart.integration.CarInteg;
|
import com.sczx.order.thirdpart.integration.CarInteg;
|
||||||
import com.sczx.order.thirdpart.integration.PayInteg;
|
import com.sczx.order.thirdpart.integration.PayInteg;
|
||||||
import com.sczx.order.thirdpart.integration.StoreInteg;
|
import com.sczx.order.thirdpart.integration.StoreInteg;
|
||||||
@ -77,6 +77,9 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private OrderDistribService orderDistribService;
|
private OrderDistribService orderDistribService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PayService payService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OrderMainPO queryOrderMainPoByOrderNo(String orderNo, String delFlag) {
|
public OrderMainPO queryOrderMainPoByOrderNo(String orderNo, String delFlag) {
|
||||||
LambdaQueryWrapper<OrderMainPO> currentOrderWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<OrderMainPO> currentOrderWrapper = new LambdaQueryWrapper<>();
|
||||||
@ -183,7 +186,7 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
|
|
||||||
//发起支付返回预支付信息
|
//发起支付返回预支付信息
|
||||||
String paymentId = OrderUtil.generateSubOrderNo(OrderUtil.ZF_PREFIX);
|
String paymentId = OrderUtil.generateSubOrderNo(OrderUtil.ZF_PREFIX);
|
||||||
UnifiedPaymentInfoDTO unifiedPaymentInfoDTO = prepayOrder(paymentType,rentCarRuleDTO.getRuleName(),Long.valueOf(companyStoreDTO.getOperatingCompanyId()),paymentId,userInfoDTO
|
UnifiedPaymentInfoDTO unifiedPaymentInfoDTO = payService.prepayOrder(paymentType,rentCarRuleDTO.getRuleName(),Long.valueOf(companyStoreDTO.getOperatingCompanyId()),paymentId,userInfoDTO
|
||||||
,orderMainPO.getOrderAmount());
|
,orderMainPO.getOrderAmount());
|
||||||
|
|
||||||
// UnifiedPaymentInfoDTO unifiedPaymentInfoDTO = new UnifiedPaymentInfoDTO();
|
// UnifiedPaymentInfoDTO unifiedPaymentInfoDTO = new UnifiedPaymentInfoDTO();
|
||||||
@ -290,7 +293,7 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
|
|
||||||
// 起支付返回预支付信息
|
// 起支付返回预支付信息
|
||||||
RentCarRuleDTO rentCarRuleDTO = carInteg.getRentCarRuleByCarRuleId(orderMainPO.getRentCarRuleId());
|
RentCarRuleDTO rentCarRuleDTO = carInteg.getRentCarRuleByCarRuleId(orderMainPO.getRentCarRuleId());
|
||||||
UnifiedPaymentInfoDTO unifiedPaymentInfoDTO = prepayOrder(paymentType,rentCarRuleDTO.getRuleName(),orderMainPO.getOperatorId(),rentOrder.getPaymentId(),userInfoDTO
|
UnifiedPaymentInfoDTO unifiedPaymentInfoDTO = payService.prepayOrder(paymentType,rentCarRuleDTO.getRuleName(),orderMainPO.getOperatorId(),rentOrder.getPaymentId(),userInfoDTO
|
||||||
,rentCarOrderAmount);
|
,rentCarOrderAmount);
|
||||||
|
|
||||||
// //发起支付
|
// //发起支付
|
||||||
@ -384,7 +387,7 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
// unifiedPaymentInfoDTO = payInteg.unifiedOrder(paymentRequest);
|
// unifiedPaymentInfoDTO = payInteg.unifiedOrder(paymentRequest);
|
||||||
// // TODO 其他支付类型
|
// // TODO 其他支付类型
|
||||||
// }
|
// }
|
||||||
return prepayOrder(orderSubPO.getPaymentMethod(),rentCarRuleDTO.getRuleName(),orderMainPO.getOperatorId(),orderSubPO.getPaymentId(),userInfoDTO
|
return payService.prepayOrder(orderSubPO.getPaymentMethod(),rentCarRuleDTO.getRuleName(),orderMainPO.getOperatorId(),orderSubPO.getPaymentId(),userInfoDTO
|
||||||
,orderAmount);
|
,orderAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -479,7 +482,7 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
rentOrder.setPaymentMethod(paymentType);
|
rentOrder.setPaymentMethod(paymentType);
|
||||||
// 发起支付返回预支付信息
|
// 发起支付返回预支付信息
|
||||||
RentCarRuleDTO rentCarRuleDTO = carInteg.getRentCarRuleByCarRuleId(orderMainPO.getRentCarRuleId());
|
RentCarRuleDTO rentCarRuleDTO = carInteg.getRentCarRuleByCarRuleId(orderMainPO.getRentCarRuleId());
|
||||||
UnifiedPaymentInfoDTO unifiedPaymentInfoDTO = prepayOrder(paymentType,rentCarRuleDTO.getRuleName(),orderMainPO.getOperatorId(),rentOrder.getPaymentId(),userInfoDTO
|
UnifiedPaymentInfoDTO unifiedPaymentInfoDTO = payService.prepayOrder(paymentType,rentCarRuleDTO.getRuleName(),orderMainPO.getOperatorId(),rentOrder.getPaymentId(),userInfoDTO
|
||||||
,overDueAmount);
|
,overDueAmount);
|
||||||
|
|
||||||
// //发起支付
|
// //发起支付
|
||||||
@ -863,6 +866,30 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
ThreadPoolUtils.getThreadPool().execute(() -> {
|
ThreadPoolUtils.getThreadPool().execute(() -> {
|
||||||
orderDistribService.saveOrderDistrib(returnCarReq.getOrderNo());
|
orderDistribService.saveOrderDistrib(returnCarReq.getOrderNo());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ThreadPoolUtils.getThreadPool().execute(() -> {
|
||||||
|
LambdaQueryWrapper<OrderSubPO> orderSubWrapper = new LambdaQueryWrapper<>();
|
||||||
|
orderSubWrapper.eq(OrderSubPO::getOrderId, orderDTO.getOrderId())
|
||||||
|
.eq(OrderSubPO::getDelFlag, "0")
|
||||||
|
.eq(OrderSubPO::getSuborderType, SubOrderTypeEnum.DEPOSIT.getCode())
|
||||||
|
.eq(OrderSubPO::getPayStatus, PayStatusEnum.SUCCESS).last(" limit 1");
|
||||||
|
OrderSubPO orderSubPO = orderSubRepo.getOne(orderSubWrapper);
|
||||||
|
if (Objects.nonNull(orderSubPO)) {
|
||||||
|
//退款回调成功则添加退款子订单
|
||||||
|
String outRefundNo = payService.refundOrder(orderSubPO.getPaymentMethod(), orderDTO.getOperatorId(), orderSubPO.getPaymentId(), orderSubPO.getAmount(), orderSubPO.getAmount());
|
||||||
|
if (StringUtils.isNotBlank(outRefundNo)) {
|
||||||
|
OrderSubPO fdSubOrder = new OrderSubPO();
|
||||||
|
fdSubOrder.setOrderId(orderDTO.getOrderId());
|
||||||
|
fdSubOrder.setSuborderNo(OrderUtil.generateSubOrderNo(OrderUtil.FD_PREFIX));
|
||||||
|
fdSubOrder.setSuborderType(SubOrderTypeEnum.FD_DEPOSIT.getCode());
|
||||||
|
fdSubOrder.setAmount(orderSubPO.getAmount());
|
||||||
|
fdSubOrder.setPaymentMethod(orderSubPO.getPaymentMethod());
|
||||||
|
fdSubOrder.setPayStatus(PayStatusEnum.REFUNDING.getCode());
|
||||||
|
fdSubOrder.setRefundId(outRefundNo);
|
||||||
|
orderSubRepo.save(fdSubOrder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
return orderDTO;
|
return orderDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -898,38 +925,6 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
return orderMainRepo.pageQueryRentBatteyOrder(pageNo, pageSize, orderQueryReq.getCustomerId(), orderQueryReq.getStoreId(), orderStatusList, orderQueryReq.getQueryBrandName());
|
return orderMainRepo.pageQueryRentBatteyOrder(pageNo, pageSize, orderQueryReq.getCustomerId(), orderQueryReq.getStoreId(), orderStatusList, orderQueryReq.getQueryBrandName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 预支付下单
|
|
||||||
* @param payType
|
|
||||||
* @param body
|
|
||||||
* @param companyId
|
|
||||||
* @param outTradeNo
|
|
||||||
* @param userInfoDTO
|
|
||||||
* @param totalFee
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private UnifiedPaymentInfoDTO prepayOrder(String payType,String body,Long companyId,String outTradeNo,SimpleUserInfoDTO userInfoDTO,BigDecimal totalFee){
|
|
||||||
// 发起支付返回预支付信息
|
|
||||||
UnifiedPaymentInfoDTO unifiedPaymentInfoDTO = null;
|
|
||||||
|
|
||||||
//发起支付
|
|
||||||
if(StringUtils.equalsIgnoreCase(payType, PaymentTypeEnum.WX_PAY.getCode())){
|
|
||||||
String openId = userInfoDTO.getWechatOpenid();
|
|
||||||
PaymentRequest paymentRequest = new PaymentRequest();
|
|
||||||
paymentRequest.setCompanyId(companyId);
|
|
||||||
paymentRequest.setOutTradeNo(outTradeNo);
|
|
||||||
paymentRequest.setOpenId(openId);
|
|
||||||
paymentRequest.setAttach(companyId.toString());
|
|
||||||
paymentRequest.setSpbillCreateIp("127.0.0.1");
|
|
||||||
paymentRequest.setBody(body);
|
|
||||||
// paymentRequest.setTotalFee(totalFee.multiply(new BigDecimal(100)).intValue());
|
|
||||||
paymentRequest.setTotalFee(10);
|
|
||||||
unifiedPaymentInfoDTO = payInteg.unifiedOrder(paymentRequest);
|
|
||||||
// TODO 其他支付类型
|
|
||||||
}
|
|
||||||
return unifiedPaymentInfoDTO;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付成功更新订单状态
|
* 支付成功更新订单状态
|
||||||
|
|||||||
@ -0,0 +1,70 @@
|
|||||||
|
package com.sczx.order.service.impl;
|
||||||
|
|
||||||
|
import com.sczx.order.common.enums.PaymentTypeEnum;
|
||||||
|
import com.sczx.order.dto.SimpleUserInfoDTO;
|
||||||
|
import com.sczx.order.service.PayService;
|
||||||
|
import com.sczx.order.thirdpart.dto.UnifiedPaymentInfoDTO;
|
||||||
|
import com.sczx.order.thirdpart.dto.req.PaymentRequest;
|
||||||
|
import com.sczx.order.thirdpart.dto.req.RefundRequest;
|
||||||
|
import com.sczx.order.thirdpart.integration.PayInteg;
|
||||||
|
import com.sczx.order.utils.OrderUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class PayServiceImpl implements PayService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PayInteg payInteg;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UnifiedPaymentInfoDTO prepayOrder(String payType, String body, Long companyId, String outTradeNo, SimpleUserInfoDTO userInfoDTO, BigDecimal totalFee) {
|
||||||
|
// 发起支付返回预支付信息
|
||||||
|
UnifiedPaymentInfoDTO unifiedPaymentInfoDTO = null;
|
||||||
|
|
||||||
|
//发起支付
|
||||||
|
if(StringUtils.equalsIgnoreCase(payType, PaymentTypeEnum.WX_PAY.getCode())){
|
||||||
|
String openId = userInfoDTO.getWechatOpenid();
|
||||||
|
PaymentRequest paymentRequest = new PaymentRequest();
|
||||||
|
paymentRequest.setCompanyId(companyId);
|
||||||
|
paymentRequest.setOutTradeNo(outTradeNo);
|
||||||
|
paymentRequest.setOpenId(openId);
|
||||||
|
paymentRequest.setAttach(companyId.toString());
|
||||||
|
paymentRequest.setSpbillCreateIp("127.0.0.1");
|
||||||
|
paymentRequest.setBody(body);
|
||||||
|
// paymentRequest.setTotalFee(totalFee.multiply(new BigDecimal(100)).intValue());
|
||||||
|
paymentRequest.setTotalFee(10);
|
||||||
|
unifiedPaymentInfoDTO = payInteg.unifiedOrder(paymentRequest);
|
||||||
|
// TODO 其他支付类型
|
||||||
|
}
|
||||||
|
return unifiedPaymentInfoDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String refundOrder(String payType, Long companyId, String outTradeNo, BigDecimal totalFee, BigDecimal refundFee) {
|
||||||
|
try{
|
||||||
|
String outRefundNo = OrderUtil.generateSubOrderNo(OrderUtil.FD_PREFIX);
|
||||||
|
//发起退款
|
||||||
|
if(StringUtils.equalsIgnoreCase(payType, PaymentTypeEnum.WX_PAY.getCode())){
|
||||||
|
RefundRequest refundRequest = new RefundRequest();
|
||||||
|
refundRequest.setCompanyId(companyId);
|
||||||
|
refundRequest.setOutTradeNo(outTradeNo);
|
||||||
|
refundRequest.setOutRefundNo(outRefundNo);
|
||||||
|
// refundRequest.setTotalFee(totalFee.multiply(new BigDecimal(100)).intValue());
|
||||||
|
// refundRequest.setRefundFee(refundFee.multiply(new BigDecimal(100)).intValue());
|
||||||
|
|
||||||
|
refundRequest.setTotalFee(10);
|
||||||
|
refundRequest.setRefundFee(10);
|
||||||
|
payInteg.refund(refundRequest);
|
||||||
|
}
|
||||||
|
} catch (Exception e){
|
||||||
|
log.error("退款失败",e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -23,6 +23,8 @@ public class OrderUtil {
|
|||||||
|
|
||||||
public static final String ZF_PREFIX = "ZF";
|
public static final String ZF_PREFIX = "ZF";
|
||||||
|
|
||||||
|
public static final String FD_PREFIX = "FD";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成订单号的方法
|
* 生成订单号的方法
|
||||||
* @return 唯一订单号字符串
|
* @return 唯一订单号字符串
|
||||||
|
|||||||
5
src/main/resources/mapper/BaseUserReferralMapper.xml
Normal file
5
src/main/resources/mapper/BaseUserReferralMapper.xml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.sczx.order.mapper.BaseUserReferralMapper">
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user