From f2e783ca6e47761e7daadbac193cf80474d35edd Mon Sep 17 00:00:00 2001
From: liyong <18434998025@163.com>
Date: 星期一, 25 五月 2026 13:19:12 +0800
Subject: [PATCH] feat(approve): 重构审批流程配置功能
---
src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 55 insertions(+), 5 deletions(-)
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 b7cb426..154605a 100644
--- a/src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java
+++ b/src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java
@@ -9,6 +9,7 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.basic.dto.CustomerDto;
import com.ruoyi.basic.dto.CustomerFollowUpDto;
+import com.ruoyi.basic.excel.CustomerExcelDTO;
import com.ruoyi.basic.mapper.CustomerMapper;
import com.ruoyi.basic.pojo.Customer;
import com.ruoyi.basic.pojo.CustomerFollowUp;
@@ -23,6 +24,7 @@
import com.ruoyi.framework.security.LoginUser;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.system.domain.SysUser;
+import com.ruoyi.project.system.mapper.SysUserMapper;
import com.ruoyi.sales.mapper.SalesLedgerMapper;
import com.ruoyi.sales.pojo.SalesLedger;
import lombok.AllArgsConstructor;
@@ -33,10 +35,8 @@
import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.time.ZoneId;
+import java.util.*;
import java.util.stream.Collectors;
@@ -58,6 +58,8 @@
private CustomerFollowUpFileService customerFollowUpFileService;
private CustomerReturnVisitService customerReturnVisitService;
+
+ private SysUserMapper sysUserMapper;
/**
* 鏌ヨ瀹㈡埛妗f
@@ -141,6 +143,7 @@
queryWrapper.like(Customer::getCustomerType, customerType);
}
+
// 3. 鎵ц鍒嗛〉鏌ヨ锛堜繚鐣欏垎椤靛厓鏁版嵁锛�
IPage<Customer> customerPage = customerMapper.selectPage(page, queryWrapper);
@@ -163,7 +166,11 @@
if (followUp != null) {
c.setFollowUpLevel(followUp.getFollowUpLevel());
- c.setFollowUpTime(followUp.getFollowUpTime());
+ c.setFollowUpTime(
+ Date.from(
+ followUp.getFollowUpTime().atZone(ZoneId.systemDefault()).toInstant()
+ )
+ );
}
})
.collect(Collectors.toList());
@@ -183,9 +190,17 @@
*/
@Override
public int insertCustomer(Customer customer) {
+ // 1. 鏍¢獙瀹㈡埛鍚嶇О鏄惁宸插瓨鍦�
+ LambdaQueryWrapper<Customer> queryWrapper = new LambdaQueryWrapper<>();
+ queryWrapper.eq(Customer::getCustomerName, customer.getCustomerName());
+ List<Customer> customerList = customerMapper.selectList(queryWrapper);
+ if (!customerList.isEmpty()) {
+ throw new RuntimeException("瀹㈡埛鍚嶇О宸插瓨鍦�");
+ }
LoginUser loginUser = SecurityUtils.getLoginUser();
Long tenantId = loginUser.getTenantId();
customer.setTenantId(tenantId);
+ customer.setCreateUser(loginUser.getUserId().intValue());
return customerMapper.insert(customer);
}
@@ -197,6 +212,14 @@
*/
@Override
public int updateCustomer(Customer customer) {
+ // 1. 鏍¢獙瀹㈡埛鍚嶇О鏄惁宸插瓨鍦�
+ LambdaQueryWrapper<Customer> queryWrapper = new LambdaQueryWrapper<>();
+ queryWrapper.eq(Customer::getCustomerName, customer.getCustomerName());
+ queryWrapper.ne(Customer::getId, customer.getId());
+ List<Customer> customerList = customerMapper.selectList(queryWrapper);
+ if (!customerList.isEmpty()) {
+ throw new RuntimeException("瀹㈡埛鍚嶇О宸插瓨鍦�");
+ }
LoginUser loginUser = SecurityUtils.getLoginUser();
Long tenantId = loginUser.getTenantId();
customer.setTenantId(tenantId);
@@ -234,8 +257,18 @@
}
@Override
+ public List<CustomerExcelDTO> selectCustomerDtoByIds(Long[] ids) {
+ return customerMapper.selectCustomerDtoListByIds(Arrays.asList(ids));
+ }
+
+ @Override
public List<Customer> selectCustomerLists(Customer customer) {
return customerMapper.selectList(null);
+ }
+
+ @Override
+ public List<CustomerExcelDTO> selectCustomerDtoLists() {
+ return customerMapper.selectCustomerDtoLists();
}
@Override
@@ -292,4 +325,21 @@
}
return sb.toString();
}
+
+ @Override
+ public int transferCustomer(CustomerDto customerDto) {
+ // 鏍¢獙缁存姢浜烘槸鍚﹀瓨鍦�
+ SysUser sysUser = sysUserMapper.selectUserById(customerDto.getCreateUser().longValue());
+ if (sysUser == null) {
+ throw new RuntimeException("缁存姢浜轰笉瀛樺湪");
+ }
+ // 鏍¢獙瀹㈡埛鏄惁瀛樺湪
+ Customer customer = customerMapper.selectById(customerDto.getId());
+ if (customer == null) {
+ throw new RuntimeException("瀹㈡埛涓嶅瓨鍦�");
+ }
+ customer.setMaintainer(sysUser.getNickName());
+ customer.setCreateUser(customerDto.getCreateUser());
+ return customerMapper.updateById(customer);
+ }
}
--
Gitblit v1.9.3