wujianwei
2025-12-18 a2c07518198c857c15afc377988ae20e1d468fa4
新增费用接口
10个文件已修改
223 ■■■■■ 已修改文件
service/src/main/java/com/ruoyi/cwgl/controller/ReceivableFeeManagementController.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/java/com/ruoyi/cwgl/domain/PayableFeeManagement.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/java/com/ruoyi/cwgl/mapper/ReceivableFeeDetailMapper.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/java/com/ruoyi/cwgl/mapper/ReceivableFeeManagementMapper.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/java/com/ruoyi/cwgl/service/IReceivableFeeDetailService.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/java/com/ruoyi/cwgl/service/IReceivableFeeManagementService.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/java/com/ruoyi/cwgl/service/impl/ReceivableFeeDetailServiceImpl.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/java/com/ruoyi/cwgl/service/impl/ReceivableFeeManagementServiceImpl.java 130 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/resources/mapper/cwgl/ReceivableFeeDetailMapper.xml 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/resources/mapper/cwgl/ReceivableFeeManagementMapper.xml 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/src/main/java/com/ruoyi/cwgl/controller/ReceivableFeeManagementController.java
@@ -18,6 +18,7 @@
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.cwgl.domain.ReceivableFeeManagement;
import com.ruoyi.cwgl.service.IReceivableFeeManagementService;
import com.ruoyi.cwgl.domain.vo.ReceivableBillCreateVo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
@@ -105,4 +106,27 @@
    {
        return toAjax(receivableFeeManagementService.deleteReceivableFeeManagementByIds(ids));
    }
    /**
     * 查询应收费用统计信息
     */
    @PreAuthorize("@ss.hasPermi('cwgl:receivableFeeManagement:statistics')")
    @GetMapping("/statistics/{ids}")
    public AjaxResult getStatistics(@PathVariable Integer[] ids)
    {
        return AjaxResult.success(receivableFeeManagementService.getReceivableFeeStatistics(ids));
    }
    /**
     * 创建应收账单
     */
    @PreAuthorize("@ss.hasPermi('cwgl:receivableFeeManagement:createBill')")
    @Log(title = "应收账单管理", businessType = BusinessType.INSERT)
    @PostMapping("/createBill")
    public AjaxResult createBill(@RequestBody ReceivableBillCreateVo billCreateVo)
    {
        Integer billId = receivableFeeManagementService.createReceivableBill(billCreateVo);
        return AjaxResult.success(billId);
    }
}
service/src/main/java/com/ruoyi/cwgl/domain/PayableFeeManagement.java
@@ -1,5 +1,6 @@
package com.ruoyi.cwgl.domain;
import java.math.BigDecimal;
import java.util.List;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
service/src/main/java/com/ruoyi/cwgl/mapper/ReceivableFeeDetailMapper.java
@@ -84,4 +84,12 @@
     * @return 结果
     */
    public int deleteReceivableFeeDetailByIds(Integer[] ids);
    /**
     * 根据应收费用ID数组查询应收费用明细列表
     *
     * @param receivableFeeIds 应收费用ID数组
     * @return 应收费用明细集合
     */
    public List<ReceivableFeeDetail> selectReceivableFeeDetailByReceivableFeeIds(Integer[] receivableFeeIds);
}
service/src/main/java/com/ruoyi/cwgl/mapper/ReceivableFeeManagementMapper.java
@@ -84,4 +84,12 @@
     * @return 结果
     */
    public int deleteReceivableFeeManagementByIds(Integer[] ids);
    /**
     * 根据应收费用ID数组查询应收费用管理列表
     *
     * @param ids 应收费用ID数组
     * @return 应收费用管理集合
     */
    public List<ReceivableFeeManagement> selectReceivableFeeManagementByIds(Integer[] ids);
}
service/src/main/java/com/ruoyi/cwgl/service/IReceivableFeeDetailService.java
@@ -99,4 +99,12 @@
     * @return 结果
     */
    public int deleteReceivableFeeDetailById(Integer id);
    /**
     * 根据应收费用ID数组查询应收费用明细列表
     *
     * @param receivableFeeIds 应收费用ID数组
     * @return 应收费用明细集合
     */
    public List<ReceivableFeeDetail> selectReceivableFeeDetailByReceivableFeeIds(Integer[] receivableFeeIds);
}
service/src/main/java/com/ruoyi/cwgl/service/IReceivableFeeManagementService.java
@@ -2,6 +2,8 @@
import java.util.List;
import com.ruoyi.cwgl.domain.ReceivableFeeManagement;
import com.ruoyi.cwgl.domain.vo.ReceivableFeeStatisticsVo;
import com.ruoyi.cwgl.domain.vo.ReceivableBillCreateVo;
import com.baomidou.mybatisplus.extension.service.IService;
/**
 * 应收费用管理Service接口
@@ -99,4 +101,15 @@
     * @return 结果
     */
    public int deleteReceivableFeeManagementById(Integer id);
    public ReceivableFeeStatisticsVo getReceivableFeeStatistics(Integer[] ids);
    /**
     * 根据统计数据创建应收账单
     *
     * @param billCreateVo 包含统计数据和账单类型的请求对象
     * @return 创建的应收账单ID
     */
    public Integer createReceivableBill(ReceivableBillCreateVo billCreateVo);
}
service/src/main/java/com/ruoyi/cwgl/service/impl/ReceivableFeeDetailServiceImpl.java
@@ -179,4 +179,17 @@
    {
        return receivableFeeDetailMapper.deleteReceivableFeeDetailById(id);
    }
    /**
     * 根据应收费用ID数组查询应收费用明细列表
     *
     * @param receivableFeeIds 应收费用ID数组
     * @return 应收费用明细集合
     */
    @DataSource(DataSourceType.SLAVE)
    @Override
    public List<ReceivableFeeDetail> selectReceivableFeeDetailByReceivableFeeIds(Integer[] receivableFeeIds)
    {
        return receivableFeeDetailMapper.selectReceivableFeeDetailByReceivableFeeIds(receivableFeeIds);
    }
}
service/src/main/java/com/ruoyi/cwgl/service/impl/ReceivableFeeManagementServiceImpl.java
@@ -1,9 +1,17 @@
package com.ruoyi.cwgl.service.impl;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import javax.annotation.Resource;
import com.ruoyi.cwgl.domain.ReceivableFeeDetail;
import com.ruoyi.cwgl.domain.vo.ReceivableFeeStatisticsVo;
import com.ruoyi.system.domain.SysConfig;
import com.ruoyi.system.mapper.SysConfigMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Service;
import org.springframework.scheduling.annotation.Async;
@@ -17,8 +25,13 @@
import com.ruoyi.cwgl.mapper.ReceivableFeeManagementMapper;
import com.ruoyi.cwgl.domain.ReceivableFeeManagement;
import com.ruoyi.cwgl.domain.ReceivableBillManagement;
import com.ruoyi.cwgl.domain.ReceivableBillSettlementDetail;
import com.ruoyi.cwgl.service.IReceivableFeeDetailService;
import com.ruoyi.cwgl.service.IReceivableFeeManagementService;
import com.ruoyi.cwgl.service.IReceivableBillManagementService;
import com.ruoyi.cwgl.service.IReceivableBillSettlementDetailService;
import com.ruoyi.cwgl.domain.vo.ReceivableBillCreateVo;
import com.ruoyi.common.core.text.Convert;
/**
@@ -37,6 +50,15 @@
    
    @Autowired
    private IReceivableFeeDetailService receivableFeeDetailService;
    @Resource
    private SysConfigMapper sysConfigMapper;
    @Autowired
    private IReceivableBillManagementService receivableBillManagementService;
    @Autowired
    private IReceivableBillSettlementDetailService receivableBillSettlementDetailService;
    /**
@@ -202,4 +224,112 @@
    {
        return receivableFeeManagementMapper.deleteReceivableFeeManagementById(id);
    }
    /**
     * 根据应收费用ID数组查询统计信息和明细
     *
     * @param ids 应收费用ID数组
     * @return 包含统计信息和明细的结果
     */
    @DataSource(DataSourceType.SLAVE)
    @Override
    public ReceivableFeeStatisticsVo getReceivableFeeStatistics(Integer[] ids)
    {
        // 查询应收费用主表记录
        List<ReceivableFeeManagement> receivableFeeList = receivableFeeManagementMapper.selectReceivableFeeManagementByIds(ids);
        // 计算单据数量
        int documentCount = receivableFeeList.size();
        SysConfig sysConfig = sysConfigMapper.selectConfig(new SysConfig() {{
            setConfigKey("sys.hk.rmb.rate");
        }});
        // 计算总应收金额
        BigDecimal totalReceivableAmount = receivableFeeList.stream()
                .map(ReceivableFeeManagement::getReceivableAmount)
                .reduce(BigDecimal.ZERO, BigDecimal::add);
        BigDecimal exchangeRate = new BigDecimal(sysConfig.getConfigValue());
        BigDecimal totalAmountHkd = totalReceivableAmount.divide(exchangeRate, 2, RoundingMode.HALF_UP);
        // 查询应收费用明细
        List<ReceivableFeeDetail> detailList = receivableFeeDetailService.selectReceivableFeeDetailByReceivableFeeIds(ids);
        // 组装返回结果
        ReceivableFeeStatisticsVo result = new ReceivableFeeStatisticsVo();
        result.setDocumentCount(documentCount);
        result.setRate(exchangeRate);
        result.setTotalReceivableAmount(totalReceivableAmount);
        result.setTotalAmountRmb(totalReceivableAmount);
        result.setTotalAmountHkd(totalAmountHkd);
        result.setDetailList(detailList);
        return result;
    }
    /**
     * 根据统计数据创建应收账单
     *
     * @param billCreateVo 包含统计数据和账单类型的请求对象
     * @return 创建的应收账单ID
     */
    @Override
    public Integer createReceivableBill(ReceivableBillCreateVo billCreateVo) {
        // 1. 准备数据
        ReceivableFeeStatisticsVo statisticsVo = billCreateVo.getStatisticsData();
        Integer billType = billCreateVo.getBillType();
        // 2. 创建应收账单主记录
        ReceivableBillManagement billManagement = new ReceivableBillManagement();
        billManagement.setDocumentCount(statisticsVo.getDocumentCount());
        billManagement.setExchangeRate(statisticsVo.getRate());
        billManagement.setStatus("DRAFT"); // 默认草稿状态
        billManagement.setCreateTime(DateUtils.getNowDate());
        // 3. 根据账单类型设置币种和总金额
        if (billType == 0) {
            // 人民币账单
            billManagement.setCurrency("CNY");
            billManagement.setTotalAmount(statisticsVo.getTotalAmountRmb());
        } else if (billType == 1) {
            // 港币账单
            billManagement.setCurrency("HKD");
            billManagement.setTotalAmount(statisticsVo.getTotalAmountHkd());
        } else {
            throw new IllegalArgumentException("无效的账单类型:" + billType);
        }
        // 4. 保存主账单记录
        receivableBillManagementService.insertReceivableBillManagement(billManagement);
        Integer billId = billManagement.getId();
        // 5. 创建应收账单结算明细
        List<ReceivableBillSettlementDetail> detailList = new java.util.ArrayList<>();
        for (ReceivableFeeDetail feeDetail : statisticsVo.getDetailList()) {
            ReceivableBillSettlementDetail settlementDetail = new ReceivableBillSettlementDetail();
            settlementDetail.setBillId(billId);
            // 根据账单类型设置明细金额
            if (billType == 0) {
                // 人民币账单使用原金额
                settlementDetail.setReceiptAmount(feeDetail.getBillingAmount());
            } else {
                // 港币账单转换金额
                settlementDetail.setReceiptAmount(feeDetail.getBillingAmount().divide(statisticsVo.getRate(), 2, RoundingMode.HALF_UP));
            }
            // 设置其他明细信息
            settlementDetail.setSettlementMethod("0"); // 默认为空,后续可以更新
            settlementDetail.setCreateTime(DateUtils.getNowDate());
            detailList.add(settlementDetail);
        }
        // 6. 批量保存明细记录
        if (!detailList.isEmpty()) {
            receivableBillSettlementDetailService.insertReceivableBillSettlementDetailBatch(detailList);
        }
        return billId;
    }
}
service/src/main/resources/mapper/cwgl/ReceivableFeeDetailMapper.xml
@@ -179,4 +179,13 @@
        </foreach>
    </delete>
    <!--根据应收费用ID数组查询明细-->
    <select id="selectReceivableFeeDetailByReceivableFeeIds" parameterType="Integer" resultMap="ReceivableFeeDetailResult">
        <include refid="selectReceivableFeeDetailVo"/>
        where thisTab.receivable_fee_id in
        <foreach item="receivableFeeId" collection="array" open="(" separator="," close=")">
            #{receivableFeeId}
        </foreach>
    </select>
</mapper>
service/src/main/resources/mapper/cwgl/ReceivableFeeManagementMapper.xml
@@ -203,4 +203,13 @@
        </foreach>
    </delete>
    <!--根据ID数组查询-->
    <select id="selectReceivableFeeManagementByIds" parameterType="Integer" resultMap="ReceivableFeeManagementResult">
        <include refid="selectReceivableFeeManagementVo"/>
        where thisTab.id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </select>
</mapper>