From 6b8f073df16ed45ec9e710abe18d1f4ffde30540 Mon Sep 17 00:00:00 2001
From: sen <sen@qq.com>
Date: 星期五, 19 十二月 2025 08:49:52 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/cwxt_master' into cwxt_master

---
 service/src/main/java/com/ruoyi/cwgl/service/impl/ReceivableFeeManagementServiceImpl.java |  155 +++++++++++++++++++++++++
 service/src/main/java/com/ruoyi/cwgl/mapper/ReceivableFeeManagementMapper.java            |    8 +
 service/src/main/java/com/ruoyi/cwgl/domain/vo/ReceivableFeeStatisticsVo.java             |   44 +++++++
 service/src/main/java/com/ruoyi/cwgl/domain/PayableFeeManagement.java                     |    5 
 service/src/main/java/com/ruoyi/cwgl/service/IReceivableFeeDetailService.java             |    8 +
 service/src/main/java/com/ruoyi/cwgl/service/IReceivableFeeManagementService.java         |   13 ++
 service/src/main/java/com/ruoyi/cwgl/controller/ReceivableFeeManagementController.java    |   24 ++++
 service/src/main/java/com/ruoyi/cwgl/service/impl/ReceivableFeeDetailServiceImpl.java     |   13 ++
 service/src/main/java/com/ruoyi/cwgl/mapper/ReceivableFeeDetailMapper.java                |    8 +
 service/src/main/java/com/ruoyi/cwgl/domain/ReceivableFeeManagement.java                  |    7 +
 service/src/main/java/com/ruoyi/cwgl/service/impl/PayableFeeManagementServiceImpl.java    |   20 +++
 service/src/main/java/com/ruoyi/cwgl/domain/vo/ReceivableBillCreateVo.java                |   21 +++
 service/src/main/resources/mapper/cwgl/ReceivableFeeManagementMapper.xml                  |    9 +
 service/src/main/resources/mapper/cwgl/ReceivableFeeDetailMapper.xml                      |    9 +
 14 files changed, 340 insertions(+), 4 deletions(-)

diff --git a/service/src/main/java/com/ruoyi/cwgl/controller/ReceivableFeeManagementController.java b/service/src/main/java/com/ruoyi/cwgl/controller/ReceivableFeeManagementController.java
index 70cf7ba..5e37019 100644
--- a/service/src/main/java/com/ruoyi/cwgl/controller/ReceivableFeeManagementController.java
+++ b/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);
+    }
 }
diff --git a/service/src/main/java/com/ruoyi/cwgl/domain/PayableFeeManagement.java b/service/src/main/java/com/ruoyi/cwgl/domain/PayableFeeManagement.java
index 7e00c10..5118501 100644
--- a/service/src/main/java/com/ruoyi/cwgl/domain/PayableFeeManagement.java
+++ b/service/src/main/java/com/ruoyi/cwgl/domain/PayableFeeManagement.java
@@ -1,11 +1,11 @@
 package com.ruoyi.cwgl.domain;
 
 import java.math.BigDecimal;
+import java.util.List;
 import java.util.Date;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.ruoyi.common.annotation.Excel;
 import com.baomidou.mybatisplus.annotation.TableField;
-import java.util.Date;
 import lombok.Data;
 /**
  * 搴斾粯璐圭敤绠$悊瀵硅薄 payable_fee_management
@@ -156,5 +156,8 @@
         @TableField("deleted")
     private Integer deleted;
 
+    /** 搴斾粯璐圭敤鏄庣粏鍒楄〃 */
+    @TableField(exist = false)
+    private List<PayableFeeDetail> payableFeeDetailList;
 
 }
diff --git a/service/src/main/java/com/ruoyi/cwgl/domain/ReceivableFeeManagement.java b/service/src/main/java/com/ruoyi/cwgl/domain/ReceivableFeeManagement.java
index 9f15bad..89ef8a6 100644
--- a/service/src/main/java/com/ruoyi/cwgl/domain/ReceivableFeeManagement.java
+++ b/service/src/main/java/com/ruoyi/cwgl/domain/ReceivableFeeManagement.java
@@ -2,10 +2,11 @@
 
 import java.math.BigDecimal;
 import java.util.Date;
+import java.util.List;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.ruoyi.common.annotation.Excel;
 import com.baomidou.mybatisplus.annotation.TableField;
-import java.util.Date;
+import com.ruoyi.cwgl.domain.ReceivableFeeDetail;
 import lombok.Data;
 /**
  * 搴旀敹璐圭敤绠$悊瀵硅薄 receivable_fee_management
@@ -156,5 +157,9 @@
         @TableField("deleted")
     private Integer deleted;
 
+    /** 搴旀敹璐圭敤鏄庣粏鍒楄〃 */
+    @TableField(exist = false)
+    private List<ReceivableFeeDetail> receivableFeeDetailList;
+
 
 }
diff --git a/service/src/main/java/com/ruoyi/cwgl/domain/vo/ReceivableBillCreateVo.java b/service/src/main/java/com/ruoyi/cwgl/domain/vo/ReceivableBillCreateVo.java
new file mode 100644
index 0000000..4e1f75c
--- /dev/null
+++ b/service/src/main/java/com/ruoyi/cwgl/domain/vo/ReceivableBillCreateVo.java
@@ -0,0 +1,21 @@
+package com.ruoyi.cwgl.domain.vo;
+
+import lombok.Data;
+import com.ruoyi.cwgl.domain.vo.ReceivableFeeStatisticsVo;
+
+/**
+ * 鍒涘缓搴旀敹璐﹀崟璇锋眰VO
+ */
+@Data
+public class ReceivableBillCreateVo {
+    
+    /**
+     * 璐﹀崟绫诲瀷锛�0=浜烘皯甯佽处鍗曪紝1=娓竵璐﹀崟
+     */
+    private Integer billType;
+    
+    /**
+     * 搴旀敹璐圭敤缁熻鏁版嵁
+     */
+    private ReceivableFeeStatisticsVo statisticsData;
+}
\ No newline at end of file
diff --git a/service/src/main/java/com/ruoyi/cwgl/domain/vo/ReceivableFeeStatisticsVo.java b/service/src/main/java/com/ruoyi/cwgl/domain/vo/ReceivableFeeStatisticsVo.java
new file mode 100644
index 0000000..f7c68b6
--- /dev/null
+++ b/service/src/main/java/com/ruoyi/cwgl/domain/vo/ReceivableFeeStatisticsVo.java
@@ -0,0 +1,44 @@
+package com.ruoyi.cwgl.domain.vo;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.List;
+import com.ruoyi.cwgl.domain.ReceivableFeeDetail;
+
+/**
+ * 搴旀敹璐圭敤缁熻缁撴灉VO
+ */
+@Data
+public class ReceivableFeeStatisticsVo {
+
+    /**
+     * 鍗曟嵁鏁伴噺
+     */
+    private int documentCount;
+
+    /**
+     * 姹囩巼
+     */
+    private BigDecimal rate;
+
+    /**
+     * 鎬诲簲鏀堕噾棰�
+     */
+    private BigDecimal totalReceivableAmount;
+
+    /**
+     * 浜烘皯甯佹�婚噾棰�
+     */
+    private BigDecimal totalAmountRmb;
+
+    /**
+     * 娓竵鎬婚噾棰�
+     */
+    private BigDecimal totalAmountHkd;
+
+    /**
+     * 鏄庣粏鍒楄〃
+     */
+    private List<ReceivableFeeDetail> detailList;
+}
\ No newline at end of file
diff --git a/service/src/main/java/com/ruoyi/cwgl/mapper/ReceivableFeeDetailMapper.java b/service/src/main/java/com/ruoyi/cwgl/mapper/ReceivableFeeDetailMapper.java
index a6c67d3..741fac3 100644
--- a/service/src/main/java/com/ruoyi/cwgl/mapper/ReceivableFeeDetailMapper.java
+++ b/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);
 }
diff --git a/service/src/main/java/com/ruoyi/cwgl/mapper/ReceivableFeeManagementMapper.java b/service/src/main/java/com/ruoyi/cwgl/mapper/ReceivableFeeManagementMapper.java
index 809b4ce..9d06207 100644
--- a/service/src/main/java/com/ruoyi/cwgl/mapper/ReceivableFeeManagementMapper.java
+++ b/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);
 }
diff --git a/service/src/main/java/com/ruoyi/cwgl/service/IReceivableFeeDetailService.java b/service/src/main/java/com/ruoyi/cwgl/service/IReceivableFeeDetailService.java
index 35081cb..4fdeb99 100644
--- a/service/src/main/java/com/ruoyi/cwgl/service/IReceivableFeeDetailService.java
+++ b/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);
 }
diff --git a/service/src/main/java/com/ruoyi/cwgl/service/IReceivableFeeManagementService.java b/service/src/main/java/com/ruoyi/cwgl/service/IReceivableFeeManagementService.java
index 29edf26..8d71f9c 100644
--- a/service/src/main/java/com/ruoyi/cwgl/service/IReceivableFeeManagementService.java
+++ b/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 鍒涘缓鐨勫簲鏀惰处鍗旾D
+     */
+    public Integer createReceivableBill(ReceivableBillCreateVo billCreateVo);
+
 }
diff --git a/service/src/main/java/com/ruoyi/cwgl/service/impl/PayableFeeManagementServiceImpl.java b/service/src/main/java/com/ruoyi/cwgl/service/impl/PayableFeeManagementServiceImpl.java
index 713e5a8..b45b7d3 100644
--- a/service/src/main/java/com/ruoyi/cwgl/service/impl/PayableFeeManagementServiceImpl.java
+++ b/service/src/main/java/com/ruoyi/cwgl/service/impl/PayableFeeManagementServiceImpl.java
@@ -18,6 +18,7 @@
 import com.ruoyi.cwgl.mapper.PayableFeeManagementMapper;
 import com.ruoyi.cwgl.domain.PayableFeeManagement;
 import com.ruoyi.cwgl.service.IPayableFeeManagementService;
+import com.ruoyi.cwgl.service.IPayableFeeDetailService;
 import com.ruoyi.common.core.text.Convert;
 
 /**
@@ -33,6 +34,9 @@
     protected final Logger logger = LoggerFactory.getLogger(getClass());
     @Resource
     private PayableFeeManagementMapper payableFeeManagementMapper;
+
+    @Resource
+    private IPayableFeeDetailService payableFeeDetailService;
 
 
     /**
@@ -103,7 +107,21 @@
     public int insertPayableFeeManagement(PayableFeeManagement payableFeeManagement)
     {
         payableFeeManagement.setCreateTime(DateUtils.getNowDate());
-        return payableFeeManagementMapper.insertPayableFeeManagement(payableFeeManagement);
+        
+        // 淇濆瓨涓诲疄浣�
+        int result = payableFeeManagementMapper.insertPayableFeeManagement(payableFeeManagement);
+        Integer payableFeeId = payableFeeManagement.getId();
+        
+        // 鎵归噺淇濆瓨鏄庣粏
+        if (payableFeeManagement.getPayableFeeDetailList() != null && !payableFeeManagement.getPayableFeeDetailList().isEmpty()) {
+            payableFeeManagement.getPayableFeeDetailList().forEach(detail -> {
+                detail.setPayableFeeId(payableFeeId);
+                detail.setCreateTime(DateUtils.getNowDate());
+            });
+            payableFeeDetailService.insertPayableFeeDetailBatch(payableFeeManagement.getPayableFeeDetailList());
+        }
+        
+        return result;
     }
 
     /**
diff --git a/service/src/main/java/com/ruoyi/cwgl/service/impl/ReceivableFeeDetailServiceImpl.java b/service/src/main/java/com/ruoyi/cwgl/service/impl/ReceivableFeeDetailServiceImpl.java
index 808dfb8..c9886ff 100644
--- a/service/src/main/java/com/ruoyi/cwgl/service/impl/ReceivableFeeDetailServiceImpl.java
+++ b/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);
+    }
 }
diff --git a/service/src/main/java/com/ruoyi/cwgl/service/impl/ReceivableFeeManagementServiceImpl.java b/service/src/main/java/com/ruoyi/cwgl/service/impl/ReceivableFeeManagementServiceImpl.java
index 73ced5b..866fc93 100644
--- a/service/src/main/java/com/ruoyi/cwgl/service/impl/ReceivableFeeManagementServiceImpl.java
+++ b/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,7 +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;
 
 /**
@@ -33,6 +47,18 @@
     protected final Logger logger = LoggerFactory.getLogger(getClass());
     @Resource
     private ReceivableFeeManagementMapper receivableFeeManagementMapper;
+    
+    @Autowired
+    private IReceivableFeeDetailService receivableFeeDetailService;
+
+    @Resource
+    private SysConfigMapper sysConfigMapper;
+
+    @Autowired
+    private IReceivableBillManagementService receivableBillManagementService;
+
+    @Autowired
+    private IReceivableBillSettlementDetailService receivableBillSettlementDetailService;
 
 
     /**
@@ -103,7 +129,26 @@
     public int insertReceivableFeeManagement(ReceivableFeeManagement receivableFeeManagement)
     {
         receivableFeeManagement.setCreateTime(DateUtils.getNowDate());
-        return receivableFeeManagementMapper.insertReceivableFeeManagement(receivableFeeManagement);
+        
+        // 淇濆瓨涓昏〃淇℃伅
+        int result = receivableFeeManagementMapper.insertReceivableFeeManagement(receivableFeeManagement);
+        
+        // 鑾峰彇涓昏〃ID
+        Integer receivableFeeId = receivableFeeManagement.getId();
+        
+        // 鎵归噺淇濆瓨鏄庣粏鍒楄〃
+        if (receivableFeeManagement.getReceivableFeeDetailList() != null && !receivableFeeManagement.getReceivableFeeDetailList().isEmpty()) {
+            // 璁剧疆姣忎釜鏄庣粏鐨勫簲鏀惰垂鐢ㄧ鐞咺D
+            receivableFeeManagement.getReceivableFeeDetailList().forEach(detail -> {
+                detail.setReceivableFeeId(receivableFeeId);
+                detail.setCreateTime(DateUtils.getNowDate()); // 璁剧疆鍒涘缓鏃堕棿
+            });
+            
+            // 璋冪敤鎵归噺鎻掑叆鏂规硶
+            receivableFeeDetailService.insertReceivableFeeDetailBatch(receivableFeeManagement.getReceivableFeeDetailList());
+        }
+        
+        return result;
     }
 
     /**
@@ -179,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 鍒涘缓鐨勫簲鏀惰处鍗旾D
+     */
+    @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;
+    }
 }
diff --git a/service/src/main/resources/mapper/cwgl/ReceivableFeeDetailMapper.xml b/service/src/main/resources/mapper/cwgl/ReceivableFeeDetailMapper.xml
index 1a0da45..92fb11c 100644
--- a/service/src/main/resources/mapper/cwgl/ReceivableFeeDetailMapper.xml
+++ b/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>
\ No newline at end of file
diff --git a/service/src/main/resources/mapper/cwgl/ReceivableFeeManagementMapper.xml b/service/src/main/resources/mapper/cwgl/ReceivableFeeManagementMapper.xml
index fe51739..3c3512c 100644
--- a/service/src/main/resources/mapper/cwgl/ReceivableFeeManagementMapper.xml
+++ b/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>
\ No newline at end of file

--
Gitblit v1.8.0