From 8b68e5a8d8d43bcb45c9032c3eb893a2b8995acf Mon Sep 17 00:00:00 2001
From: liyong <18434998025@163.com>
Date: 星期五, 17 四月 2026 16:18:51 +0800
Subject: [PATCH] fix(customer): 修复客户私海相关查询和导入功能
---
src/main/resources/mapper/basic/CustomerMapper.xml | 2 +-
src/main/resources/mapper/basic/CustomerPrivatePoolMapper.xml | 6 +++---
src/main/java/com/ruoyi/basic/service/impl/CustomerPrivateServiceImpl.java | 24 ++++++++++++++++++++++--
3 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/src/main/java/com/ruoyi/basic/service/impl/CustomerPrivateServiceImpl.java b/src/main/java/com/ruoyi/basic/service/impl/CustomerPrivateServiceImpl.java
index 3edeaa0..95f6193 100644
--- a/src/main/java/com/ruoyi/basic/service/impl/CustomerPrivateServiceImpl.java
+++ b/src/main/java/com/ruoyi/basic/service/impl/CustomerPrivateServiceImpl.java
@@ -56,6 +56,11 @@
@Autowired
private SalesLedgerMapper salesLedgerMapper;
+ @Autowired
+ private CustomerPrivateMapper customerPrivateMapper;
+ @Autowired
+ private CustomerPrivateService customerPrivateService;
+
@Override
public Boolean add(CustomerPrivateDto customerPrivateDto) {
@@ -64,6 +69,7 @@
//鏂板绉佹捣璁板綍
CustomerPrivatePool customerPrivatePool = new CustomerPrivatePool();
customerPrivatePool.setCustomerId(customerPrivateDto.getId());
+ customerPrivatePool.setType(0L);
customerPrivatePool.setBoundId(SecurityUtils.getLoginUser().getUserId());
customerPrivatePoolMapper.insert(customerPrivatePool);
return true;
@@ -93,20 +99,34 @@
@Override
public R importData(MultipartFile file) {
try {
+ List<CustomerPrivate> existingList = customerPrivateService.list();
+ java.util.Set<String> existingCustomerNames = existingList.stream()
+ .map(CustomerPrivate::getCustomerName)
+ .collect(Collectors.toSet());
+
ExcelUtil<CustomerPrivate> util = new ExcelUtil<CustomerPrivate>(CustomerPrivate.class);
List<CustomerPrivate> userList = util.importExcel(file.getInputStream());
if (CollectionUtils.isEmpty(userList)) {
return R.fail("妯℃澘閿欒鎴栧鍏ユ暟鎹负绌�");
}
+
+ int successCount = 0;
+ int skipCount = 0;
for (CustomerPrivate user : userList) {
+ if (existingCustomerNames.contains(user.getCustomerName())) {
+ skipCount++;
+ continue;
+ }
CustomerPrivateDto customerPrivateDto = new CustomerPrivateDto();
BeanUtils.copyProperties(user, customerPrivateDto);
this.add(customerPrivateDto);
+ existingCustomerNames.add(user.getCustomerName());
+ successCount++;
}
- return R.ok(true);
+ return R.ok("瀵煎叆瀹屾垚锛屾垚鍔�" + successCount + "鏉★紝璺宠繃閲嶅" + skipCount + "鏉�");
} catch (Exception e) {
e.printStackTrace();
- return R.fail("瀵煎叆澶辫触");
+ return R.fail("瀵煎叆澶辫触锛�" + e.getMessage());
}
}
}
diff --git a/src/main/resources/mapper/basic/CustomerMapper.xml b/src/main/resources/mapper/basic/CustomerMapper.xml
index c0bc2fa..3b42238 100644
--- a/src/main/resources/mapper/basic/CustomerMapper.xml
+++ b/src/main/resources/mapper/basic/CustomerMapper.xml
@@ -14,7 +14,7 @@
select group_concat(u2.user_name separator ', ')
from customer_private_pool cpp2
left join sys_user u2 on cpp2.bound_id = u2.user_id
- where cpp2.customer_id = c.id
+ where cpp2.customer_id = c.id and cpp2.delete_flag = 0
and cpp2.bound_id != c.usage_user
) as together_user_names
from customer c
diff --git a/src/main/resources/mapper/basic/CustomerPrivatePoolMapper.xml b/src/main/resources/mapper/basic/CustomerPrivatePoolMapper.xml
index 08e16e4..5fc2c24 100644
--- a/src/main/resources/mapper/basic/CustomerPrivatePoolMapper.xml
+++ b/src/main/resources/mapper/basic/CustomerPrivatePoolMapper.xml
@@ -36,10 +36,10 @@
<where>
cpp.delete_flag = 0
<if test="c.customerName != null and c.customerName != ''">
- and c.customer_name like concat('%', #{c.customerName}, '%')
+ and (c.customer_name like concat('%', #{c.customerName}, '%') or cp.customer_name like concat('%', #{c.customerName}, '%'))
</if>
- <if test="c.boundId != null">
- and cpp.bound_id = #{c.boundId}
+ <if test="c.customerType != null">
+ and c.customer_type = #{c.customerType}
</if>
</where>
order by cpp.id desc
--
Gitblit v1.9.3