支付优化,分润增加门店钱包变更
This commit is contained in:
@ -0,0 +1,23 @@
|
|||||||
|
package com.sczx.order.common.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小程序类型枚举
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum WalletChangeTypeEnum {
|
||||||
|
REFERRAL("REFERRAL", "引荐"),
|
||||||
|
WITHDRAWAL("WITHDRAWAL", "提现");
|
||||||
|
|
||||||
|
private final String code;
|
||||||
|
|
||||||
|
private final String desc;
|
||||||
|
|
||||||
|
|
||||||
|
WalletChangeTypeEnum(String code, String desc) {
|
||||||
|
this.code = code;
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
package com.sczx.order.mapper;
|
||||||
|
|
||||||
|
import com.sczx.order.po.BaseWalletChangePO;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 钱包变更记录 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zhangli
|
||||||
|
* @since 2025-08-24 13:08:39
|
||||||
|
*/
|
||||||
|
public interface BaseWalletChangeMapper extends BaseMapper<BaseWalletChangePO> {
|
||||||
|
|
||||||
|
}
|
||||||
16
src/main/java/com/sczx/order/mapper/BaseWalletMapper.java
Normal file
16
src/main/java/com/sczx/order/mapper/BaseWalletMapper.java
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package com.sczx.order.mapper;
|
||||||
|
|
||||||
|
import com.sczx.order.po.BaseWalletPO;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 钱包信息 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zhangli
|
||||||
|
* @since 2025-08-24 13:08:07
|
||||||
|
*/
|
||||||
|
public interface BaseWalletMapper extends BaseMapper<BaseWalletPO> {
|
||||||
|
|
||||||
|
}
|
||||||
65
src/main/java/com/sczx/order/po/BaseWalletChangePO.java
Normal file
65
src/main/java/com/sczx/order/po/BaseWalletChangePO.java
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
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.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 13:08:39
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@TableName("zc_base_wallet_change")
|
||||||
|
@ApiModel(value = "BaseWalletChangePO对象", description = "钱包变更记录")
|
||||||
|
public class BaseWalletChangePO 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 changeType;
|
||||||
|
|
||||||
|
@ApiModelProperty("支付类型")
|
||||||
|
private String payType;
|
||||||
|
|
||||||
|
@ApiModelProperty("变更时间")
|
||||||
|
private LocalDateTime changeTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("变更金额(元)")
|
||||||
|
private BigDecimal changeAmount;
|
||||||
|
|
||||||
|
@ApiModelProperty("引荐订单")
|
||||||
|
private String referralOrderNo;
|
||||||
|
|
||||||
|
@ApiModelProperty("提现状态")
|
||||||
|
private String changeStatus;
|
||||||
|
|
||||||
|
@ApiModelProperty("删除标志(0代表存在 2代表删除)")
|
||||||
|
private String delFlag;
|
||||||
|
|
||||||
|
@ApiModelProperty("创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("更新时间")
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
62
src/main/java/com/sczx/order/po/BaseWalletPO.java
Normal file
62
src/main/java/com/sczx/order/po/BaseWalletPO.java
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
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.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 13:08:07
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@TableName("zc_base_wallet")
|
||||||
|
@ApiModel(value = "BaseWalletPO对象", description = "钱包信息")
|
||||||
|
public class BaseWalletPO implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty("用户id主键")
|
||||||
|
@TableId(value = "user_id", type = IdType.AUTO)
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@ApiModelProperty("用户名")
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
@ApiModelProperty("手机号")
|
||||||
|
private String phoneNumber;
|
||||||
|
|
||||||
|
@ApiModelProperty("余额(元)")
|
||||||
|
private BigDecimal balance;
|
||||||
|
|
||||||
|
@ApiModelProperty("可用金额(元)")
|
||||||
|
private BigDecimal availableAmount;
|
||||||
|
|
||||||
|
@ApiModelProperty("冻结金额(元)")
|
||||||
|
private BigDecimal freezeAmount;
|
||||||
|
|
||||||
|
@ApiModelProperty("钱包类型0门店1用户")
|
||||||
|
private Integer walletType;
|
||||||
|
|
||||||
|
@ApiModelProperty("删除标志(0代表存在 2代表删除)")
|
||||||
|
private String delFlag;
|
||||||
|
|
||||||
|
@ApiModelProperty("创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("更新时间")
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
package com.sczx.order.repository;
|
||||||
|
|
||||||
|
import com.sczx.order.po.BaseWalletChangePO;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 钱包变更记录 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zhangli
|
||||||
|
* @since 2025-08-24 13:08:39
|
||||||
|
*/
|
||||||
|
public interface BaseWalletChangeRepo extends IService<BaseWalletChangePO> {
|
||||||
|
|
||||||
|
}
|
||||||
16
src/main/java/com/sczx/order/repository/BaseWalletRepo.java
Normal file
16
src/main/java/com/sczx/order/repository/BaseWalletRepo.java
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package com.sczx.order.repository;
|
||||||
|
|
||||||
|
import com.sczx.order.po.BaseWalletPO;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 钱包信息 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zhangli
|
||||||
|
* @since 2025-08-24 13:08:07
|
||||||
|
*/
|
||||||
|
public interface BaseWalletRepo extends IService<BaseWalletPO> {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
package com.sczx.order.repository.impl;
|
||||||
|
|
||||||
|
import com.sczx.order.po.BaseWalletChangePO;
|
||||||
|
import com.sczx.order.mapper.BaseWalletChangeMapper;
|
||||||
|
import com.sczx.order.repository.BaseWalletChangeRepo;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 钱包变更记录 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zhangli
|
||||||
|
* @since 2025-08-24 13:08:39
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class BaseWalletChangeRepoImpl extends ServiceImpl<BaseWalletChangeMapper, BaseWalletChangePO> implements BaseWalletChangeRepo {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
package com.sczx.order.repository.impl;
|
||||||
|
|
||||||
|
import com.sczx.order.po.BaseWalletPO;
|
||||||
|
import com.sczx.order.mapper.BaseWalletMapper;
|
||||||
|
import com.sczx.order.repository.BaseWalletRepo;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 钱包信息 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zhangli
|
||||||
|
* @since 2025-08-24 13:08:07
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class BaseWalletRepoImpl extends ServiceImpl<BaseWalletMapper, BaseWalletPO> implements BaseWalletRepo {
|
||||||
|
|
||||||
|
}
|
||||||
@ -94,6 +94,7 @@ public interface OrderService {
|
|||||||
*/
|
*/
|
||||||
OrderDTO confirmReturnCar(ReturnCarReq returnCarReq);
|
OrderDTO confirmReturnCar(ReturnCarReq returnCarReq);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 门店订单统计
|
* 门店订单统计
|
||||||
* @param storeId
|
* @param storeId
|
||||||
|
|||||||
@ -5,11 +5,16 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.sczx.order.common.enums.DistribTypeEnum;
|
import com.sczx.order.common.enums.DistribTypeEnum;
|
||||||
|
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.BaseWalletPO;
|
||||||
import com.sczx.order.po.OrderDistribPO;
|
import com.sczx.order.po.OrderDistribPO;
|
||||||
import com.sczx.order.po.OrderMainPO;
|
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.OrderDistribRepo;
|
||||||
import com.sczx.order.repository.OrderMainRepo;
|
import com.sczx.order.repository.OrderMainRepo;
|
||||||
import com.sczx.order.service.OrderDistribService;
|
import com.sczx.order.service.OrderDistribService;
|
||||||
@ -26,6 +31,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@ -39,6 +45,12 @@ public class OrderDistribServiceImpl implements OrderDistribService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private OrderMainRepo orderMainRepo;
|
private OrderMainRepo orderMainRepo;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BaseWalletRepo baseWalletRepo;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BaseWalletChangeRepo baseWalletChangeRepo;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private StoreInteg storeInteg;
|
private StoreInteg storeInteg;
|
||||||
|
|
||||||
@ -66,12 +78,12 @@ public class OrderDistribServiceImpl implements OrderDistribService {
|
|||||||
CompanyDTO companyDTO = storeInteg.getCompanyById(Integer.valueOf(orderMainPO.getOperatorId().toString()));
|
CompanyDTO companyDTO = storeInteg.getCompanyById(Integer.valueOf(orderMainPO.getOperatorId().toString()));
|
||||||
Integer sharingRatio = companyDTO.getSharingRatio();
|
Integer sharingRatio = companyDTO.getSharingRatio();
|
||||||
|
|
||||||
OrderDistribPO platFormDistribPO = getOrderDistribPO(orderMainPO.getOrderId(),orderMainPO.getOrderNo(),DistribTypeEnum.PLATFORM.getCode(),sharingRatio.toString(),orderMainPO.getOrderAmount(),null,null,null);
|
OrderDistribPO platFormDistribPO = getOrderDistribPO(orderMainPO.getOrderId(),orderMainPO.getOrderNo(),DistribTypeEnum.PLATFORM.getCode(),sharingRatio.toString(),orderMainPO.getOrderAmount(),Integer.valueOf(orderMainPO.getOperatorId().toString()),Integer.valueOf(orderMainPO.getStoreId().toString()),null);
|
||||||
addOrderDistribPOList.add(platFormDistribPO);
|
addOrderDistribPOList.add(platFormDistribPO);
|
||||||
|
|
||||||
//门店分润
|
//门店分润
|
||||||
CompanyStoreDTO companyStoreDTO = storeInteg.getStoreById(Integer.valueOf(orderMainPO.getStoreId().toString()));
|
CompanyStoreDTO companyStoreDTO = storeInteg.getStoreById(Integer.valueOf(orderMainPO.getStoreId().toString()));
|
||||||
OrderDistribPO storeDistribPO = getOrderDistribPO(orderMainPO.getOrderId(),orderMainPO.getOrderNo(),DistribTypeEnum.STORE.getCode(),companyStoreDTO.getZucheRatio().toString(),orderMainPO.getOrderAmount(),null,Integer.valueOf(orderMainPO.getStoreId().toString()),null);
|
OrderDistribPO storeDistribPO = getOrderDistribPO(orderMainPO.getOrderId(),orderMainPO.getOrderNo(),DistribTypeEnum.STORE.getCode(),companyStoreDTO.getZucheRatio().toString(),orderMainPO.getOrderAmount(),Integer.valueOf(orderMainPO.getOperatorId().toString()),Integer.valueOf(orderMainPO.getStoreId().toString()),null);
|
||||||
addOrderDistribPOList.add(storeDistribPO);
|
addOrderDistribPOList.add(storeDistribPO);
|
||||||
|
|
||||||
//推荐人分润
|
//推荐人分润
|
||||||
@ -91,7 +103,7 @@ public class OrderDistribServiceImpl implements OrderDistribService {
|
|||||||
BigDecimal alreadyShareRate = addOrderDistribPOList.stream().map(OrderDistribPO::getDistribRate).reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
|
BigDecimal alreadyShareRate = addOrderDistribPOList.stream().map(OrderDistribPO::getDistribRate).reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
|
||||||
//运营商分润
|
//运营商分润
|
||||||
String companyRate = String.valueOf(BigDecimal.ONE.subtract(alreadyShareRate).multiply(BigDecimal.valueOf(100)));
|
String companyRate = String.valueOf(BigDecimal.ONE.subtract(alreadyShareRate).multiply(BigDecimal.valueOf(100)));
|
||||||
OrderDistribPO companyDistribPO = getOrderDistribPO(orderMainPO.getOrderId(),orderMainPO.getOrderNo(),DistribTypeEnum.COMPANY.getCode(),companyRate,orderMainPO.getOrderAmount(),Integer.valueOf(orderMainPO.getOperatorId().toString()),null,null);
|
OrderDistribPO companyDistribPO = getOrderDistribPO(orderMainPO.getOrderId(),orderMainPO.getOrderNo(),DistribTypeEnum.COMPANY.getCode(),companyRate,orderMainPO.getOrderAmount(),Integer.valueOf(orderMainPO.getOperatorId().toString()),Integer.valueOf(orderMainPO.getStoreId().toString()),null);
|
||||||
addOrderDistribPOList.add(companyDistribPO);
|
addOrderDistribPOList.add(companyDistribPO);
|
||||||
orderDistribRepo.saveOrUpdateBatch(addOrderDistribPOList);
|
orderDistribRepo.saveOrUpdateBatch(addOrderDistribPOList);
|
||||||
|
|
||||||
@ -99,6 +111,29 @@ public class OrderDistribServiceImpl implements OrderDistribService {
|
|||||||
updateMainWrapper.eq(OrderMainPO::getOrderId, orderMainPO.getOrderId())
|
updateMainWrapper.eq(OrderMainPO::getOrderId, orderMainPO.getOrderId())
|
||||||
.set(OrderMainPO::getDistribed, 1);
|
.set(OrderMainPO::getDistribed, 1);
|
||||||
orderMainRepo.update(updateMainWrapper);
|
orderMainRepo.update(updateMainWrapper);
|
||||||
|
|
||||||
|
//门店钱包入账
|
||||||
|
LambdaQueryWrapper<BaseWalletPO> queryWalletWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWalletWrapper.eq(BaseWalletPO::getUserId, orderMainPO.getOperatorId()).last(" limit 1");
|
||||||
|
BaseWalletPO baseWalletPO = baseWalletRepo.getOne(queryWalletWrapper);
|
||||||
|
if(baseWalletPO != null){
|
||||||
|
LambdaUpdateWrapper<BaseWalletPO> updateWalletWrapper = new LambdaUpdateWrapper<>();
|
||||||
|
updateWalletWrapper.eq(BaseWalletPO::getUserId, orderMainPO.getOperatorId())
|
||||||
|
.set(BaseWalletPO::getBalance, baseWalletPO.getBalance().add(storeDistribPO.getDistribAmount()));
|
||||||
|
baseWalletRepo.update(updateWalletWrapper);
|
||||||
|
|
||||||
|
BaseWalletChangePO baseWalletChangePO = new BaseWalletChangePO();
|
||||||
|
baseWalletChangePO.setUserId(orderMainPO.getOperatorId());
|
||||||
|
baseWalletChangePO.setChangeType(WalletChangeTypeEnum.REFERRAL.getCode());
|
||||||
|
baseWalletChangePO.setChangeTime(LocalDateTime.now());
|
||||||
|
baseWalletChangePO.setChangeAmount(storeDistribPO.getDistribAmount());
|
||||||
|
baseWalletChangePO.setReferralOrderNo(orderMainPO.getOrderNo());
|
||||||
|
baseWalletChangeRepo.save(baseWalletChangePO);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -176,23 +176,27 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
BigDecimal orderAmount = orderSubPOList.stream().map(OrderSubPO::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
BigDecimal orderAmount = orderSubPOList.stream().map(OrderSubPO::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
orderMainPO.setOrderAmount(orderAmount);
|
orderMainPO.setOrderAmount(orderAmount);
|
||||||
|
|
||||||
// TODO 发起支付返回预支付信息
|
//发起支付返回预支付信息
|
||||||
UnifiedPaymentInfoDTO unifiedPaymentInfoDTO = new UnifiedPaymentInfoDTO();
|
|
||||||
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
|
||||||
if(StringUtils.equalsIgnoreCase(userInfoDTO.getMiniProgramType(), MiniProgramTypeEnum.WECHAT.getType())){
|
,orderMainPO.getOrderAmount());
|
||||||
PaymentRequest paymentRequest = new PaymentRequest();
|
|
||||||
paymentRequest.setCompanyId(Long.valueOf(companyStoreDTO.getOperatingCompanyId()));
|
// UnifiedPaymentInfoDTO unifiedPaymentInfoDTO = new UnifiedPaymentInfoDTO();
|
||||||
paymentRequest.setOutTradeNo(paymentId);
|
//
|
||||||
paymentRequest.setOpenId(userInfoDTO.getWechatOpenid());
|
// //发起支付
|
||||||
paymentRequest.setAttach(companyStoreDTO.getOperatingCompanyId().toString());
|
// if(StringUtils.equalsIgnoreCase(userInfoDTO.getMiniProgramType(), MiniProgramTypeEnum.WECHAT.getType())){
|
||||||
paymentRequest.setSpbillCreateIp("127.0.0.1");
|
// PaymentRequest paymentRequest = new PaymentRequest();
|
||||||
paymentRequest.setBody(rentCarRuleDTO.getRuleName());
|
// paymentRequest.setCompanyId(Long.valueOf(companyStoreDTO.getOperatingCompanyId()));
|
||||||
// paymentRequest.setTotalFee(orderMainPO.getOrderAmount().multiply(new BigDecimal(100)).intValue());
|
// paymentRequest.setOutTradeNo(paymentId);
|
||||||
paymentRequest.setTotalFee(10);
|
// paymentRequest.setOpenId(userInfoDTO.getWechatOpenid());
|
||||||
unifiedPaymentInfoDTO = payInteg.unifiedOrder(paymentRequest);
|
// paymentRequest.setAttach(companyStoreDTO.getOperatingCompanyId().toString());
|
||||||
// TODO 其他支付类型
|
// paymentRequest.setSpbillCreateIp("127.0.0.1");
|
||||||
}
|
// paymentRequest.setBody(rentCarRuleDTO.getRuleName());
|
||||||
|
//// paymentRequest.setTotalFee(orderMainPO.getOrderAmount().multiply(new BigDecimal(100)).intValue());
|
||||||
|
// paymentRequest.setTotalFee(10);
|
||||||
|
// unifiedPaymentInfoDTO = payInteg.unifiedOrder(paymentRequest);
|
||||||
|
// // TODO 其他支付类型
|
||||||
|
// }
|
||||||
|
|
||||||
for(OrderSubPO orderSubPO : orderSubPOList){
|
for(OrderSubPO orderSubPO : orderSubPOList){
|
||||||
orderSubPO.setPaymentId(paymentId);
|
orderSubPO.setPaymentId(paymentId);
|
||||||
@ -265,24 +269,6 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
paymentType = PaymentTypeEnum.ZFB_PAY.getCode();
|
paymentType = PaymentTypeEnum.ZFB_PAY.getCode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//生成租车订单
|
|
||||||
// BigDecimal rentCarOrderAmount = getRentCarAmount(orderMainPO.getRentalType(), orderMainPO.getRentalPrice(), orderMainPO.getRentalDays());
|
|
||||||
|
|
||||||
//计算续租金额
|
|
||||||
// BigDecimal rentCarOrderAmount = new BigDecimal(0);
|
|
||||||
// if(RentCarTypeEnum.HOUR_RENTAL.getCode().equalsIgnoreCase(orderMainPO.getRentalType())){
|
|
||||||
// Integer overdueHours = OrderUtil.getOrderOverdueHours(orderMainPO.getEndRentTime());
|
|
||||||
// rentCarOrderAmount = rentCarOrderAmount.add(orderMainPO.getRentalPrice().multiply(new BigDecimal(overdueHours+1)));
|
|
||||||
// } else if(RentCarTypeEnum.DAILY_RENTAL.getCode().equalsIgnoreCase(orderMainPO.getRentalType())){
|
|
||||||
// Integer rentalDays = OrderUtil.getOrderExpectedDays(orderMainPO.getEndRentTime());
|
|
||||||
// rentCarOrderAmount = rentCarOrderAmount.add(orderMainPO.getRentalPrice().multiply(new BigDecimal(rentalDays+1)));
|
|
||||||
// } else if(RentCarTypeEnum.DAYS_RENTAL.getCode().equalsIgnoreCase(orderMainPO.getRentalType())){
|
|
||||||
// Integer rentalDays = OrderUtil.getOrderExpectedDays(orderMainPO.getEndRentTime());
|
|
||||||
// rentCarOrderAmount = rentCarOrderAmount.add(orderMainPO.getRentalPrice().multiply(new BigDecimal(rentalDays+orderMainPO.getRentalDays())));
|
|
||||||
// } else {
|
|
||||||
// Integer rentalDays = OrderUtil.getOrderExpectedDays(orderMainPO.getEndRentTime());
|
|
||||||
// rentCarOrderAmount = rentCarOrderAmount.add(orderMainPO.getRentalPrice().multiply(new BigDecimal(rentalDays+30)));
|
|
||||||
// }
|
|
||||||
|
|
||||||
BigDecimal rentCarOrderAmount = getReRentCarAmount(orderMainPO.getEndRentTime(), orderMainPO.getRentalType(), orderMainPO.getRentalPrice(), orderMainPO.getRentalDays());
|
BigDecimal rentCarOrderAmount = getReRentCarAmount(orderMainPO.getEndRentTime(), orderMainPO.getRentalType(), orderMainPO.getRentalPrice(), orderMainPO.getRentalDays());
|
||||||
|
|
||||||
@ -298,23 +284,25 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
rentOrder.setPayStatus(PayStatusEnum.USERPAYING.getCode());
|
rentOrder.setPayStatus(PayStatusEnum.USERPAYING.getCode());
|
||||||
|
|
||||||
// 起支付返回预支付信息
|
// 起支付返回预支付信息
|
||||||
UnifiedPaymentInfoDTO unifiedPaymentInfoDTO = null;
|
RentCarRuleDTO rentCarRuleDTO = carInteg.getRentCarRuleByCarRuleId(orderMainPO.getRentCarRuleId());
|
||||||
|
UnifiedPaymentInfoDTO unifiedPaymentInfoDTO = prepayOrder(paymentType,rentCarRuleDTO.getRuleName(),orderMainPO.getOperatorId(),rentOrder.getPaymentId(),userInfoDTO
|
||||||
|
,rentCarOrderAmount);
|
||||||
|
|
||||||
//发起支付
|
// //发起支付
|
||||||
if(StringUtils.equalsIgnoreCase(userInfoDTO.getMiniProgramType(), MiniProgramTypeEnum.WECHAT.getType())){
|
// if(StringUtils.equalsIgnoreCase(userInfoDTO.getMiniProgramType(), MiniProgramTypeEnum.WECHAT.getType())){
|
||||||
RentCarRuleDTO rentCarRuleDTO = carInteg.getRentCarRuleByCarRuleId(orderMainPO.getRentCarRuleId());
|
//
|
||||||
PaymentRequest paymentRequest = new PaymentRequest();
|
// PaymentRequest paymentRequest = new PaymentRequest();
|
||||||
paymentRequest.setCompanyId(orderMainPO.getOperatorId());
|
// paymentRequest.setCompanyId(orderMainPO.getOperatorId());
|
||||||
paymentRequest.setOutTradeNo(rentOrder.getPaymentId());
|
// paymentRequest.setOutTradeNo(rentOrder.getPaymentId());
|
||||||
paymentRequest.setOpenId(userInfoDTO.getWechatOpenid());
|
// paymentRequest.setOpenId(userInfoDTO.getWechatOpenid());
|
||||||
paymentRequest.setAttach(orderMainPO.getOperatorId().toString());
|
// paymentRequest.setAttach(orderMainPO.getOperatorId().toString());
|
||||||
paymentRequest.setSpbillCreateIp("127.0.0.1");
|
// paymentRequest.setSpbillCreateIp("127.0.0.1");
|
||||||
paymentRequest.setBody(rentCarRuleDTO.getRuleName());
|
// paymentRequest.setBody(rentCarRuleDTO.getRuleName());
|
||||||
// paymentRequest.setTotalFee(rentCarOrderAmount.multiply(new BigDecimal(100)).intValue());
|
//// paymentRequest.setTotalFee(rentCarOrderAmount.multiply(new BigDecimal(100)).intValue());
|
||||||
paymentRequest.setTotalFee(10);
|
// paymentRequest.setTotalFee(10);
|
||||||
unifiedPaymentInfoDTO = payInteg.unifiedOrder(paymentRequest);
|
// unifiedPaymentInfoDTO = payInteg.unifiedOrder(paymentRequest);
|
||||||
// TODO 其他支付类型
|
// // TODO 其他支付类型
|
||||||
}
|
// }
|
||||||
|
|
||||||
orderSubRepo.save(rentOrder);
|
orderSubRepo.save(rentOrder);
|
||||||
|
|
||||||
@ -369,29 +357,30 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
if(orderSubPOList.isEmpty()){
|
if(orderSubPOList.isEmpty()){
|
||||||
throw new InnerException("待支付子订单不存在");
|
throw new InnerException("待支付子订单不存在");
|
||||||
}
|
}
|
||||||
//获取门店信息
|
|
||||||
CompanyStoreDTO companyStoreDTO = storeInteg.getStoreById(Integer.valueOf(orderMainPO.getStoreId().toString()));
|
|
||||||
|
|
||||||
RentCarRuleDTO rentCarRuleDTO = carInteg.getRentCarRuleByCarRuleId(orderMainPO.getRentCarRuleId());
|
|
||||||
SimpleUserInfoDTO userInfoDTO = jwtUtil.getUserInfoFromToken();
|
SimpleUserInfoDTO userInfoDTO = jwtUtil.getUserInfoFromToken();
|
||||||
OrderSubPO orderSubPO = orderSubPOList.get(0);
|
OrderSubPO orderSubPO = orderSubPOList.get(0);
|
||||||
UnifiedPaymentInfoDTO unifiedPaymentInfoDTO = null;
|
|
||||||
//发起支付
|
RentCarRuleDTO rentCarRuleDTO = carInteg.getRentCarRuleByCarRuleId(orderMainPO.getRentCarRuleId());
|
||||||
if(StringUtils.equalsIgnoreCase(orderSubPO.getPaymentMethod(), PaymentTypeEnum.WX_PAY.getCode())){
|
BigDecimal orderAmount = orderSubPOList.stream().map(OrderSubPO::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
PaymentRequest paymentRequest = new PaymentRequest();
|
// 起支付返回预支付信息
|
||||||
paymentRequest.setCompanyId(Long.valueOf(companyStoreDTO.getOperatingCompanyId()));
|
// //发起支付
|
||||||
paymentRequest.setOutTradeNo(orderSubPO.getPaymentId());
|
// if(StringUtils.equalsIgnoreCase(orderSubPO.getPaymentMethod(), PaymentTypeEnum.WX_PAY.getCode())){
|
||||||
paymentRequest.setOpenId(userInfoDTO.getWechatOpenid());
|
// PaymentRequest paymentRequest = new PaymentRequest();
|
||||||
paymentRequest.setAttach(companyStoreDTO.getOperatingCompanyId().toString());
|
// paymentRequest.setCompanyId(Long.valueOf(companyStoreDTO.getOperatingCompanyId()));
|
||||||
paymentRequest.setSpbillCreateIp("127.0.0.1");
|
// paymentRequest.setOutTradeNo(orderSubPO.getPaymentId());
|
||||||
paymentRequest.setBody(rentCarRuleDTO.getRuleName());
|
// paymentRequest.setOpenId(userInfoDTO.getWechatOpenid());
|
||||||
// BigDecimal orderAmount = orderSubPOList.stream().map(OrderSubPO::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
// paymentRequest.setAttach(companyStoreDTO.getOperatingCompanyId().toString());
|
||||||
// paymentRequest.setTotalFee(orderAmount.multiply(new BigDecimal(100)).intValue());
|
// paymentRequest.setSpbillCreateIp("127.0.0.1");
|
||||||
paymentRequest.setTotalFee(10);
|
// paymentRequest.setBody(rentCarRuleDTO.getRuleName());
|
||||||
unifiedPaymentInfoDTO = payInteg.unifiedOrder(paymentRequest);
|
//// BigDecimal orderAmount = orderSubPOList.stream().map(OrderSubPO::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
// TODO 其他支付类型
|
//// paymentRequest.setTotalFee(orderAmount.multiply(new BigDecimal(100)).intValue());
|
||||||
}
|
// paymentRequest.setTotalFee(10);
|
||||||
return unifiedPaymentInfoDTO;
|
// unifiedPaymentInfoDTO = payInteg.unifiedOrder(paymentRequest);
|
||||||
|
// // TODO 其他支付类型
|
||||||
|
// }
|
||||||
|
return prepayOrder(orderSubPO.getPaymentMethod(),rentCarRuleDTO.getRuleName(),orderMainPO.getOperatorId(),orderSubPO.getPaymentId(),userInfoDTO
|
||||||
|
,orderAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -484,23 +473,25 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
rentOrder.setPayStatus(PayStatusEnum.USERPAYING.getCode());
|
rentOrder.setPayStatus(PayStatusEnum.USERPAYING.getCode());
|
||||||
rentOrder.setPaymentMethod(paymentType);
|
rentOrder.setPaymentMethod(paymentType);
|
||||||
// 发起支付返回预支付信息
|
// 发起支付返回预支付信息
|
||||||
UnifiedPaymentInfoDTO unifiedPaymentInfoDTO = null;
|
RentCarRuleDTO rentCarRuleDTO = carInteg.getRentCarRuleByCarRuleId(orderMainPO.getRentCarRuleId());
|
||||||
|
UnifiedPaymentInfoDTO unifiedPaymentInfoDTO = prepayOrder(paymentType,rentCarRuleDTO.getRuleName(),orderMainPO.getOperatorId(),rentOrder.getPaymentId(),userInfoDTO
|
||||||
|
,overDueAmount);
|
||||||
|
|
||||||
//发起支付
|
// //发起支付
|
||||||
if(StringUtils.equalsIgnoreCase(userInfoDTO.getMiniProgramType(), MiniProgramTypeEnum.WECHAT.getType())){
|
// if(StringUtils.equalsIgnoreCase(userInfoDTO.getMiniProgramType(), MiniProgramTypeEnum.WECHAT.getType())){
|
||||||
RentCarRuleDTO rentCarRuleDTO = carInteg.getRentCarRuleByCarRuleId(orderMainPO.getRentCarRuleId());
|
// RentCarRuleDTO rentCarRuleDTO = carInteg.getRentCarRuleByCarRuleId(orderMainPO.getRentCarRuleId());
|
||||||
PaymentRequest paymentRequest = new PaymentRequest();
|
// PaymentRequest paymentRequest = new PaymentRequest();
|
||||||
paymentRequest.setCompanyId(orderMainPO.getOperatorId());
|
// paymentRequest.setCompanyId(orderMainPO.getOperatorId());
|
||||||
paymentRequest.setOutTradeNo(rentOrder.getPaymentId());
|
// paymentRequest.setOutTradeNo(rentOrder.getPaymentId());
|
||||||
paymentRequest.setOpenId(userInfoDTO.getWechatOpenid());
|
// paymentRequest.setOpenId(userInfoDTO.getWechatOpenid());
|
||||||
paymentRequest.setAttach(orderMainPO.getOperatorId().toString());
|
// paymentRequest.setAttach(orderMainPO.getOperatorId().toString());
|
||||||
paymentRequest.setSpbillCreateIp("127.0.0.1");
|
// paymentRequest.setSpbillCreateIp("127.0.0.1");
|
||||||
paymentRequest.setBody(rentCarRuleDTO.getRuleName());
|
// paymentRequest.setBody(rentCarRuleDTO.getRuleName());
|
||||||
// paymentRequest.setTotalFee(overDueAmount.multiply(new BigDecimal(100)).intValue());
|
//// paymentRequest.setTotalFee(overDueAmount.multiply(new BigDecimal(100)).intValue());
|
||||||
paymentRequest.setTotalFee(10);
|
// paymentRequest.setTotalFee(10);
|
||||||
unifiedPaymentInfoDTO = payInteg.unifiedOrder(paymentRequest);
|
// unifiedPaymentInfoDTO = payInteg.unifiedOrder(paymentRequest);
|
||||||
// TODO 其他支付类型
|
// // TODO 其他支付类型
|
||||||
}
|
// }
|
||||||
|
|
||||||
orderSubRepo.save(rentOrder);
|
orderSubRepo.save(rentOrder);
|
||||||
|
|
||||||
@ -874,6 +865,39 @@ 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付成功更新订单状态
|
* 支付成功更新订单状态
|
||||||
* @param orderMainPO
|
* @param orderMainPO
|
||||||
|
|||||||
5
src/main/resources/mapper/BaseWalletChangeMapper.xml
Normal file
5
src/main/resources/mapper/BaseWalletChangeMapper.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.BaseWalletChangeMapper">
|
||||||
|
|
||||||
|
</mapper>
|
||||||
5
src/main/resources/mapper/BaseWalletMapper.xml
Normal file
5
src/main/resources/mapper/BaseWalletMapper.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.BaseWalletMapper">
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user