From 0ef7f96095ae8f4e37c99b9ef226cce5554f3450 Mon Sep 17 00:00:00 2001
From: liyong <18434998025@163.com>
Date: 星期一, 20 四月 2026 10:24:43 +0800
Subject: [PATCH] feat(customer): 添加客户档案新增字段并优化删除逻辑

---
 src/main/java/com/ruoyi/basic/pojo/CustomerPrivate.java                |   22 +++++++++++
 src/main/java/com/ruoyi/sales/vo/ExportProcessContractVo.java          |    2 
 src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java |    7 ++-
 src/main/resources/mapper/basic/CustomerPrivatePoolMapper.xml          |   23 +++++++++--
 src/main/java/com/ruoyi/basic/dto/CustomerPrivatePoolDto.java          |   22 +++++++++++
 src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java    |   13 ++++--
 6 files changed, 76 insertions(+), 13 deletions(-)

diff --git a/src/main/java/com/ruoyi/basic/dto/CustomerPrivatePoolDto.java b/src/main/java/com/ruoyi/basic/dto/CustomerPrivatePoolDto.java
index c06f542..8a3570b 100644
--- a/src/main/java/com/ruoyi/basic/dto/CustomerPrivatePoolDto.java
+++ b/src/main/java/com/ruoyi/basic/dto/CustomerPrivatePoolDto.java
@@ -121,4 +121,26 @@
     private List<Long> ids;
 
 
+    @ApiModelProperty(value = "娉曚汉")
+    @Excel(name = "娉曚汉")
+    @TableField(value = "corporation")
+    private String corporation;
+
+    @ApiModelProperty(value = "浼犵湡")
+    @Excel(name = "浼犵湡")
+    @TableField(value = "fax")
+    private String fax;
+
+    @ApiModelProperty(value = "寮�鎴疯")
+    @Excel(name = "寮�鎴疯")
+    @TableField(value = "bank_name")
+    private String bankName;
+
+    @ApiModelProperty(value = "浠g悊")
+    @Excel(name = "浠g悊")
+    @TableField(value = "agent")
+    private String agent;
+
+
+
 }
diff --git a/src/main/java/com/ruoyi/basic/pojo/CustomerPrivate.java b/src/main/java/com/ruoyi/basic/pojo/CustomerPrivate.java
index 85f49a5..4a87f53 100644
--- a/src/main/java/com/ruoyi/basic/pojo/CustomerPrivate.java
+++ b/src/main/java/com/ruoyi/basic/pojo/CustomerPrivate.java
@@ -88,6 +88,28 @@
     @Excel(name = "瀹㈡埛鍒嗙被")
     private String customerType;
 
+
+    @ApiModelProperty(value = "娉曚汉")
+    @Excel(name = "娉曚汉")
+    @TableField(value = "corporation")
+    private String corporation;
+
+    @ApiModelProperty(value = "浼犵湡")
+    @Excel(name = "浼犵湡")
+    @TableField(value = "fax")
+    private String fax;
+
+    @ApiModelProperty(value = "寮�鎴疯")
+    @Excel(name = "寮�鎴疯")
+    @TableField(value = "bank_name")
+    private String bankName;
+
+    @ApiModelProperty(value = "浠g悊")
+    @Excel(name = "浠g悊")
+    @TableField(value = "agent")
+    private String agent;
+
+
     @ApiModelProperty("鍒涘缓浜篒D")
     @TableField(fill = FieldFill.INSERT)
     private Long createUser;
diff --git a/src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java b/src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java
index 12af6c7..d8c7881 100644
--- a/src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java
+++ b/src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java
@@ -185,12 +185,15 @@
         if (!salesLedgers.isEmpty()) {
             throw new RuntimeException("瀹㈡埛妗f涓嬫湁閿�鍞悎鍚岋紝璇峰厛鍒犻櫎閿�鍞悎鍚�");
         }
-        //  鍒犻櫎瀹㈡埛鐨勫悓鏃朵篃闇�瑕佸垹闄ゅ搴旂殑瀹㈡埛璺熼殢銆侀檮浠跺拰鍥炶鎻愰啋
-        for (Long id : ids) {
-            customerFollowUpService.deleteByCustomerId(id);
-            customerReturnVisitService.deleteByCustomerId(id);
+        List<CustomerPrivatePool> customerPrivatePools = customerPrivatePoolMapper.selectList(new QueryWrapper<CustomerPrivatePool>().lambda().in(CustomerPrivatePool::getCustomerId, idList));
+        if (!customerPrivatePools.isEmpty()) {
+            throw new RuntimeException("瀹㈡埛妗f涓嬫湁瀹㈡埛绉佹捣锛岃鍏堟敹鍥炵娴锋暟鎹�");
         }
-
+        //  鍒犻櫎瀹㈡埛鐨勫悓鏃朵篃闇�瑕佸垹闄ゅ搴旂殑瀹㈡埛璺熼殢銆侀檮浠跺拰鍥炶鎻愰啋
+//        for (Long id : ids) {
+//            customerFollowUpService.deleteByCustomerId(id);
+//            customerReturnVisitService.deleteByCustomerId(id);
+//        }
         return customerMapper.deleteBatchIds(idList);
     }
 
diff --git a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
index d6ea7ba..60e7fd5 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
@@ -480,14 +480,15 @@
         exportProcessContract.setId(id);
         SalesLedger salesLedger = salesLedgerMapper.selectById(id);
         // 鏌ヨ瀹㈡埛鍏徃淇℃伅
-        Customer customer = customerMapper.selectById(salesLedger.getCustomerId());
+        CustomerPrivatePoolDto customerPrivatePoolDto = customerPrivatePoolMapper.selectInfo(salesLedger.getCustomerId());
+
         exportProcessContract.setCreateTime(LocalDateTimeUtil.format(Optional.ofNullable(salesLedger.getExecutionDate()).orElse(LocalDate.now()), "yyyy骞碝M鏈坉d鏃�"));
         exportProcessContract.setRemark(Optional.ofNullable(salesLedger.getRemarks()).orElse("鏃�")); // 澶囨敞
         exportProcessContract.setPlaceOfSinging(Optional.ofNullable(salesLedger.getPlaceOfSinging()).orElse(""));
 
         // 濉啓鐢叉柟淇℃伅
-        ExportProcessContractVo.Customer partyA = ExportProcessContractVo.Customer.getCustomer(customer);
-        exportProcessContract.setPartyAClientName(customer.getCustomerName());
+        ExportProcessContractVo.Customer partyA = ExportProcessContractVo.Customer.getCustomer(customerPrivatePoolDto);
+        exportProcessContract.setPartyAClientName(customerPrivatePoolDto.getCustomerName());
         exportProcessContract.setPartyA(partyA);
 
         // 濉啓涔欐柟淇℃伅
diff --git a/src/main/java/com/ruoyi/sales/vo/ExportProcessContractVo.java b/src/main/java/com/ruoyi/sales/vo/ExportProcessContractVo.java
index 5ec848c..08ba6dd 100644
--- a/src/main/java/com/ruoyi/sales/vo/ExportProcessContractVo.java
+++ b/src/main/java/com/ruoyi/sales/vo/ExportProcessContractVo.java
@@ -83,7 +83,7 @@
         // 閭紪
         private String postCode = "";
 
-        public static ExportProcessContractVo.Customer getCustomer(com.ruoyi.basic.pojo.Customer customer) {
+        public static ExportProcessContractVo.Customer getCustomer(com.ruoyi.basic.dto.CustomerPrivatePoolDto customer) {
             ExportProcessContractVo.Customer partyA = new ExportProcessContractVo.Customer();
             partyA.setFax(Optional.ofNullable(customer.getFax()).orElse(""));
             partyA.setAddress(padRight(customer.getCompanyAddress(), 15));
diff --git a/src/main/resources/mapper/basic/CustomerPrivatePoolMapper.xml b/src/main/resources/mapper/basic/CustomerPrivatePoolMapper.xml
index 5fc2c24..2e69ab0 100644
--- a/src/main/resources/mapper/basic/CustomerPrivatePoolMapper.xml
+++ b/src/main/resources/mapper/basic/CustomerPrivatePoolMapper.xml
@@ -29,7 +29,11 @@
         coalesce(c.tenant_id, cp.tenant_id) as tenant_id,
         coalesce(c.basic_bank_account, cp.basic_bank_account) as basic_bank_account,
         coalesce(c.bank_account, cp.bank_account) as bank_account,
-        coalesce(c.bank_code, cp.bank_code) as bank_code
+        coalesce(c.bank_code, cp.bank_code) as bank_code,
+        coalesce(c.corporation, cp.corporation) as corporation,
+        coalesce(c.fax, cp.fax) as fax,
+        coalesce(c.agent, cp.agent) as agent,
+        coalesce(c.bank_name, cp.bank_name) as bank_name
         from customer_private_pool cpp
         left join customer c on c.id = cpp.customer_id and cpp.type = 1
         left join customer_private cp on cp.id = cpp.customer_id and cpp.type = 0
@@ -40,6 +44,9 @@
             </if>
             <if test="c.customerType != null">
                 and c.customer_type = #{c.customerType}
+            </if>
+            <if test="c.boundId != null">
+                and cpp.bound_id = #{c.boundId}
             </if>
         </where>
         order by cpp.id desc
@@ -61,7 +68,11 @@
                coalesce(c.tenant_id, cp.tenant_id) as tenant_id,
                coalesce(c.basic_bank_account, cp.basic_bank_account) as basic_bank_account,
                coalesce(c.bank_account, cp.bank_account) as bank_account,
-               coalesce(c.bank_code, cp.bank_code) as bank_code
+               coalesce(c.bank_code, cp.bank_code) as bank_code,
+               coalesce(c.corporation, cp.corporation) as corporation,
+               coalesce(c.fax, cp.fax) as fax,
+               coalesce(c.agent, cp.agent) as agent,
+               coalesce(c.bank_name, cp.bank_name) as bank_name
         from customer_private_pool cpp
                  left join customer c on c.id = cpp.customer_id and cpp.type = 1
                  left join customer_private cp on cp.id = cpp.customer_id and cpp.type = 0
@@ -89,9 +100,13 @@
                coalesce(c.basic_bank_account, cp.basic_bank_account) as basic_bank_account,
                coalesce(c.bank_account, cp.bank_account) as bank_account,
                coalesce(c.bank_code, cp.bank_code) as bank_code
+            coalesce(c.corporation, cp.corporation) as corporation,
+               coalesce(c.fax, cp.fax) as fax,
+               coalesce(c.agent, cp.agent) as agent,
+               coalesce(c.bank_name, cp.bank_name) as bank_name
         from customer_private_pool cpp
-                 left join customer c on c.id = cpp.customer_id and cpp.type = 1
-                 left join customer_private cp on cp.id = cpp.customer_id and cpp.type = 0
+            left join customer c on c.id = cpp.customer_id and cpp.type = 1
+            left join customer_private cp on cp.id = cpp.customer_id and cpp.type = 0
     </select>
 
 </mapper>

--
Gitblit v1.9.3