From b94831f6bc2ecafb7159b09d4622226410a1c31a Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期一, 19 一月 2026 18:03:14 +0800
Subject: [PATCH] yys 1.客户模块修改 2.销售报价修改 3.回款登记修改
---
src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java | 53 +++++++++++++++++++++++++++++++++++++----------------
1 files changed, 37 insertions(+), 16 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 afc1c30..53eabdd 100644
--- a/src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java
+++ b/src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java
@@ -2,6 +2,7 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -11,10 +12,17 @@
import com.ruoyi.basic.service.ICustomerService;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.security.LoginUser;
+import com.ruoyi.framework.web.domain.AjaxResult;
+import com.ruoyi.project.system.domain.SysUser;
+import com.ruoyi.sales.mapper.SalesLedgerMapper;
+import com.ruoyi.sales.pojo.SalesLedger;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+import org.springframework.web.multipart.MultipartFile;
import java.util.Arrays;
import java.util.List;
@@ -33,6 +41,7 @@
@AllArgsConstructor
@Slf4j
public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> implements ICustomerService {
+ private final SalesLedgerMapper salesLedgerMapper;
private CustomerMapper customerMapper;
/**
@@ -98,8 +107,8 @@
@Override
public int insertCustomer(Customer customer) {
LoginUser loginUser = SecurityUtils.getLoginUser();
- Integer tenantId = loginUser.getTenantId();
- customer.setTenantId(Long.valueOf(tenantId));
+ Long tenantId = loginUser.getTenantId();
+ customer.setTenantId(tenantId);
return customerMapper.insert(customer);
}
@@ -112,8 +121,8 @@
@Override
public int updateCustomer(Customer customer) {
LoginUser loginUser = SecurityUtils.getLoginUser();
- Integer tenantId = loginUser.getTenantId();
- customer.setTenantId(Long.valueOf(tenantId));
+ Long tenantId = loginUser.getTenantId();
+ customer.setTenantId(tenantId);
return customerMapper.updateById(customer);
}
@@ -126,6 +135,10 @@
@Override
public int deleteCustomerByIds(Long[] ids) {
List<Long> idList = Arrays.asList(ids);
+ List<SalesLedger> salesLedgers = salesLedgerMapper.selectList(new QueryWrapper<SalesLedger>().lambda().in(SalesLedger::getCustomerId, idList));
+ if (!salesLedgers.isEmpty()) {
+ throw new RuntimeException("瀹㈡埛妗f涓嬫湁閿�鍞悎鍚岋紝璇峰厛鍒犻櫎閿�鍞悎鍚�");
+ }
return customerMapper.deleteBatchIds(idList);
}
@@ -142,19 +155,27 @@
}
@Override
- public List<Map<String, Object>> customerList(Customer customer) {
+ public AjaxResult importData(MultipartFile file) {
+ try {
+ ExcelUtil<Customer> util = new ExcelUtil<Customer>(Customer.class);
+ List<Customer> userList = util.importExcel(file.getInputStream());
+ if(CollectionUtils.isEmpty(userList)){
+ return AjaxResult.warn("妯℃澘閿欒鎴栧鍏ユ暟鎹负绌�");
+ }
+ this.saveOrUpdateBatch(userList);
+ return AjaxResult.success(true);
+ }catch (Exception e){
+ e.printStackTrace();
+ return AjaxResult.error("瀵煎叆澶辫触");
+ }
+
+ }
+
+ @Override
+ public List<Customer> customerList(Customer customer) {
LambdaQueryWrapper<Customer> queryWrapper = Wrappers.lambdaQuery();
- queryWrapper.select(Customer::getId, Customer::getCustomerName, Customer::getTaxpayerIdentificationNumber);
-
- // 鑾峰彇鍘熷鏌ヨ缁撴灉
- List<Map<String, Object>> result = customerMapper.selectMaps(queryWrapper);
-
- // 灏嗕笅鍒掔嚎鍛藉悕杞崲涓洪┘宄板懡鍚�
- return result.stream().map(map -> map.entrySet().stream()
- .collect(Collectors.toMap(
- entry -> underlineToCamel(entry.getKey()),
- Map.Entry::getValue))
- ).collect(Collectors.toList());
+ queryWrapper.select(Customer::getId, Customer::getCustomerName, Customer::getTaxpayerIdentificationNumber,Customer::getType);
+ return customerMapper.selectList(queryWrapper);
}
/**
--
Gitblit v1.9.3