mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-11-04 04:08:43 +08:00 
			
		
		
		
	Merge remote-tracking branch 'origin/feature/mall_product' into feature/mall_product
This commit is contained in:
		@@ -1,34 +0,0 @@
 | 
			
		||||
package cn.iocoder.yudao.module.pay.api.wallet;
 | 
			
		||||
 | 
			
		||||
import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.service.wallet.PayWalletRechargeService;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.service.wallet.PayWalletTransactionService;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
import org.springframework.validation.annotation.Validated;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Resource;
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 钱包 API 接口实现类
 | 
			
		||||
 *
 | 
			
		||||
 * @author owen
 | 
			
		||||
 */
 | 
			
		||||
@Service
 | 
			
		||||
@Validated
 | 
			
		||||
public class PayWalletApiImpl implements PayWalletApi {
 | 
			
		||||
 | 
			
		||||
    @Resource
 | 
			
		||||
    private PayWalletRechargeService payWalletRechargeService;
 | 
			
		||||
    @Resource
 | 
			
		||||
    private PayWalletTransactionService payWalletTransactionService;
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public WalletSummaryRespDTO getWalletSummary(LocalDateTime beginTime, LocalDateTime endTime) {
 | 
			
		||||
        WalletSummaryRespDTO walletSummary = payWalletRechargeService.getWalletSummary(beginTime, endTime);
 | 
			
		||||
        walletSummary.setOrderWalletPayPrice(payWalletTransactionService.getPriceSummary(PayWalletBizTypeEnum.PAYMENT, beginTime, endTime));
 | 
			
		||||
        return walletSummary;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,17 +1,10 @@
 | 
			
		||||
package cn.iocoder.yudao.module.pay.dal.mysql.wallet;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.bean.BeanUtil;
 | 
			
		||||
import cn.hutool.core.collection.CollUtil;
 | 
			
		||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
 | 
			
		||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum;
 | 
			
		||||
import com.github.yulichang.toolkit.MPJWrappers;
 | 
			
		||||
import org.apache.ibatis.annotations.Mapper;
 | 
			
		||||
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
 | 
			
		||||
@Mapper
 | 
			
		||||
public interface PayWalletRechargeMapper extends BaseMapperX<PayWalletRechargeDO> {
 | 
			
		||||
 | 
			
		||||
@@ -25,24 +18,6 @@ public interface PayWalletRechargeMapper extends BaseMapperX<PayWalletRechargeDO
 | 
			
		||||
                .eq(PayWalletRechargeDO::getId, id).eq(PayWalletRechargeDO::getRefundStatus, whereRefundStatus));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    default WalletSummaryRespDTO selectRechargeSummaryByPayTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) {
 | 
			
		||||
        return BeanUtil.copyProperties(CollUtil.get(selectMaps(MPJWrappers.<PayWalletRechargeDO>lambdaJoin()
 | 
			
		||||
                        .selectCount(PayWalletRechargeDO::getId, WalletSummaryRespDTO::getRechargePayCount)
 | 
			
		||||
                        .selectSum(PayWalletRechargeDO::getPayPrice, WalletSummaryRespDTO::getRechargePayPrice)
 | 
			
		||||
                        .eq(PayWalletRechargeDO::getPayStatus, true)
 | 
			
		||||
                        .between(PayWalletRechargeDO::getPayTime, beginTime, endTime)), 0),
 | 
			
		||||
                WalletSummaryRespDTO.class);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    default WalletSummaryRespDTO selectRechargeSummaryByRefundTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) {
 | 
			
		||||
        return BeanUtil.copyProperties(CollUtil.get(selectMaps(MPJWrappers.<PayWalletRechargeDO>lambdaJoin()
 | 
			
		||||
                        .selectCount(PayWalletRechargeDO::getId, WalletSummaryRespDTO::getRechargeRefundCount)
 | 
			
		||||
                        .selectSum(PayWalletRechargeDO::getRefundPayPrice, WalletSummaryRespDTO::getRechargeRefundPrice)
 | 
			
		||||
                        .eq(PayWalletRechargeDO::getRefundStatus, PayRefundStatusEnum.SUCCESS.getStatus())
 | 
			
		||||
                        .between(PayWalletRechargeDO::getRefundTime, beginTime, endTime)), 0),
 | 
			
		||||
                WalletSummaryRespDTO.class);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -6,12 +6,9 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
 | 
			
		||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO;
 | 
			
		||||
import com.github.yulichang.toolkit.MPJWrappers;
 | 
			
		||||
import org.apache.ibatis.annotations.Mapper;
 | 
			
		||||
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
import java.util.Objects;
 | 
			
		||||
import java.util.Optional;
 | 
			
		||||
 | 
			
		||||
@Mapper
 | 
			
		||||
public interface PayWalletTransactionMapper extends BaseMapperX<PayWalletTransactionDO> {
 | 
			
		||||
@@ -38,15 +35,6 @@ public interface PayWalletTransactionMapper extends BaseMapperX<PayWalletTransac
 | 
			
		||||
                PayWalletTransactionDO::getBizType, bizType);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    default Integer selectSummaryByBizTypeAndCreateTimeBetween(Integer type, LocalDateTime beginTime, LocalDateTime endTime) {
 | 
			
		||||
        return Optional.ofNullable(selectOne(MPJWrappers.<PayWalletTransactionDO>lambdaJoin()
 | 
			
		||||
                        .selectSum(PayWalletTransactionDO::getPrice)
 | 
			
		||||
                        .eq(PayWalletTransactionDO::getBizType, type)
 | 
			
		||||
                        .between(PayWalletTransactionDO::getCreateTime, beginTime, endTime)))
 | 
			
		||||
                .map(PayWalletTransactionDO::getPrice)
 | 
			
		||||
                .orElse(0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,11 +1,8 @@
 | 
			
		||||
package cn.iocoder.yudao.module.pay.service.wallet;
 | 
			
		||||
 | 
			
		||||
import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO;
 | 
			
		||||
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 钱包充值 Service 接口
 | 
			
		||||
 *
 | 
			
		||||
@@ -16,8 +13,8 @@ public interface PayWalletRechargeService {
 | 
			
		||||
    /**
 | 
			
		||||
     * 创建钱包充值记录(发起充值)
 | 
			
		||||
     *
 | 
			
		||||
     * @param userId 用户 id
 | 
			
		||||
     * @param userType 用户类型
 | 
			
		||||
     * @param userId      用户 id
 | 
			
		||||
     * @param userType    用户类型
 | 
			
		||||
     * @param createReqVO 钱包充值请求 VO
 | 
			
		||||
     * @return 钱包充值记录
 | 
			
		||||
     */
 | 
			
		||||
@@ -27,32 +24,25 @@ public interface PayWalletRechargeService {
 | 
			
		||||
    /**
 | 
			
		||||
     * 更新钱包充值成功
 | 
			
		||||
     *
 | 
			
		||||
     * @param id 钱包充值记录 id
 | 
			
		||||
     * @param id         钱包充值记录 id
 | 
			
		||||
     * @param payOrderId 支付订单 id
 | 
			
		||||
     */
 | 
			
		||||
    void updateWalletRechargerPaid(Long id, Long payOrderId);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 发起钱包充值退款
 | 
			
		||||
     * @param id 钱包充值编号
 | 
			
		||||
     *
 | 
			
		||||
     * @param id     钱包充值编号
 | 
			
		||||
     * @param userIp 用户 ip 地址
 | 
			
		||||
     */
 | 
			
		||||
    void refundWalletRecharge(Long id, String userIp);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 更新钱包充值记录为已退款
 | 
			
		||||
     * @param id  钱包充值 id
 | 
			
		||||
     *
 | 
			
		||||
     * @param id          钱包充值 id
 | 
			
		||||
     * @param payRefundId 退款单id
 | 
			
		||||
     */
 | 
			
		||||
    void updateWalletRechargeRefunded(Long id, Long payRefundId);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 获取钱包统计
 | 
			
		||||
     *
 | 
			
		||||
     * @param beginTime 起始时间
 | 
			
		||||
     * @param endTime   截止时间
 | 
			
		||||
     * @return 钱包统计
 | 
			
		||||
     */
 | 
			
		||||
    WalletSummaryRespDTO getWalletSummary(LocalDateTime beginTime, LocalDateTime endTime);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,6 @@ import cn.hutool.core.lang.Assert;
 | 
			
		||||
import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO;
 | 
			
		||||
@@ -279,15 +278,4 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService {
 | 
			
		||||
        return payOrder;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public WalletSummaryRespDTO getWalletSummary(LocalDateTime beginTime, LocalDateTime endTime) {
 | 
			
		||||
        WalletSummaryRespDTO paySummary = walletRechargeMapper.selectRechargeSummaryByPayTimeBetween(beginTime, endTime);
 | 
			
		||||
        WalletSummaryRespDTO refundSummary = walletRechargeMapper.selectRechargeSummaryByRefundTimeBetween(beginTime, endTime);
 | 
			
		||||
 | 
			
		||||
        paySummary.setRechargeRefundCount(refundSummary.getRechargeRefundCount());
 | 
			
		||||
        paySummary.setRechargeRefundPrice(refundSummary.getRechargeRefundPrice());
 | 
			
		||||
 | 
			
		||||
        return paySummary;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +1,9 @@
 | 
			
		||||
package cn.iocoder.yudao.module.pay.service.wallet;
 | 
			
		||||
 | 
			
		||||
import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum;
 | 
			
		||||
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 钱包 Service 接口
 | 
			
		||||
 *
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,6 @@
 | 
			
		||||
package cn.iocoder.yudao.module.pay.service.wallet;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.lang.Assert;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.api.wallet.dto.WalletSummaryRespDTO;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO;
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,6 @@ import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum;
 | 
			
		||||
import cn.iocoder.yudao.module.pay.service.wallet.bo.WalletTransactionCreateReqBO;
 | 
			
		||||
 | 
			
		||||
import javax.validation.Valid;
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 钱包余额流水 Service 接口
 | 
			
		||||
@@ -50,14 +49,4 @@ public interface PayWalletTransactionService {
 | 
			
		||||
     */
 | 
			
		||||
    PayWalletTransactionDO getWalletTransaction(String bizId, PayWalletBizTypeEnum type);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 获取支付金额合计
 | 
			
		||||
     *
 | 
			
		||||
     * @param bizType   业务类型
 | 
			
		||||
     * @param beginTime 开始时间
 | 
			
		||||
     * @param endTime   结束时间
 | 
			
		||||
     * @return 支付金额合计
 | 
			
		||||
     */
 | 
			
		||||
    Integer getPriceSummary(PayWalletBizTypeEnum bizType, LocalDateTime beginTime, LocalDateTime endTime);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -13,7 +13,6 @@ import lombok.extern.slf4j.Slf4j;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Resource;
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 钱包流水 Service 实现类
 | 
			
		||||
@@ -61,9 +60,4 @@ public class PayWalletTransactionServiceImpl implements PayWalletTransactionServ
 | 
			
		||||
        return payWalletTransactionMapper.selectByBiz(bizId, type.getType());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Integer getPriceSummary(PayWalletBizTypeEnum bizType, LocalDateTime beginTime, LocalDateTime endTime) {
 | 
			
		||||
        return payWalletTransactionMapper.selectSummaryByBizTypeAndCreateTimeBetween(bizType.getType(), beginTime, endTime);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user