From 3e5e22f5358156ff7430ee117546123ffe042611 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期日, 20 九月 2026 20:23:52 +0800
Subject: [PATCH] feat(stock): 实现出品出库绑定销售台账功能
---
src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java | 62 ++++++++++++++++++++++++++-----
1 files changed, 52 insertions(+), 10 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 0b0c6cd..78cb8ba 100644
--- a/src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java
+++ b/src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java
@@ -23,6 +23,7 @@
import com.ruoyi.framework.web.domain.R;
import com.ruoyi.procurementrecord.mapper.ReturnManagementMapper;
import com.ruoyi.procurementrecord.pojo.ReturnManagement;
+import com.ruoyi.sales.dto.CustomerDepositAmountDto;
import com.ruoyi.sales.mapper.SalesLedgerMapper;
import com.ruoyi.sales.mapper.SalesQuotationMapper;
import com.ruoyi.sales.pojo.SalesLedger;
@@ -38,6 +39,7 @@
import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;
+import java.math.BigDecimal;
import java.time.ZoneId;
import java.util.*;
import java.util.stream.Collectors;
@@ -117,7 +119,37 @@
customerVo.setFollowUpList(followUpDtoList);
}
+ fillDepositAmount(Collections.singletonList(customerVo));
+
return customerVo;
+ }
+
+ /**
+ * 濉唬鍌ㄩ噾棰濓紙璇ュ鎴峰叏閮ㄣ�岀被鍨�=浠e偍銆嶇殑閿�鍞彴璐﹀悎鍚岄噾棰濈疮璁★級骞跺垽鏂槸鍚﹀凡瓒呬俊鎵樺熀閲�
+ */
+ private void fillDepositAmount(List<CustomerVo> records) {
+ if (CollectionUtils.isEmpty(records)) {
+ return;
+ }
+ List<Long> customerIds = records.stream()
+ .map(CustomerVo::getId)
+ .filter(Objects::nonNull)
+ .collect(Collectors.toList());
+ Map<Long, BigDecimal> depositAmountMap = customerIds.isEmpty()
+ ? Collections.emptyMap()
+ : salesLedgerMapper.selectDepositAmountByCustomerIds(customerIds).stream()
+ .filter(item -> item.getCustomerId() != null)
+ .collect(Collectors.toMap(
+ CustomerDepositAmountDto::getCustomerId,
+ item -> item.getDepositTotalAmount() == null ? BigDecimal.ZERO : item.getDepositTotalAmount(),
+ (existing, replacement) -> existing));
+
+ records.forEach(customer -> {
+ BigDecimal depositTotalAmount = depositAmountMap.getOrDefault(customer.getId(), BigDecimal.ZERO);
+ customer.setDepositTotalAmount(depositTotalAmount);
+ customer.setExceedsTrustFund(customer.getTrustFund() != null
+ && depositTotalAmount.compareTo(customer.getTrustFund()) > 0);
+ });
}
/**
@@ -168,6 +200,8 @@
c.setUserIds(userIds);
}
});
+
+ fillDepositAmount(records);
}
return customerPage;
@@ -310,18 +344,26 @@
@Override
public List<Map<String, Object>> customerList(Customer customer) {
- LambdaQueryWrapper<Customer> queryWrapper = Wrappers.lambdaQuery();
- queryWrapper.select(Customer::getId, Customer::getCustomerName, Customer::getTaxpayerIdentificationNumber);
+ LoginUser loginUser = SecurityUtils.getLoginUser();
+ Long loginUserId = loginUser.getUserId();
+ CustomerDto query = new CustomerDto();
+ if (customer != null) {
+ BeanUtils.copyProperties(customer, query);
+ }
- // 鑾峰彇鍘熷鏌ヨ缁撴灉
- List<Map<String, Object>> result = customerMapper.selectMaps(queryWrapper);
+ // 澶嶇敤瀹㈡埛鍒楄〃鐨勫彲瑙佹�ц鍒欙紝閬垮厤鎶婂埆浜虹殑绉佹捣瀹㈡埛鏆撮湶缁欏綋鍓嶈处鍙�
+ List<CustomerVo> visibleCustomers = customerMapper.list(query, loginUserId);
+ if (CollectionUtils.isEmpty(visibleCustomers)) {
+ return Collections.emptyList();
+ }
- // 灏嗕笅鍒掔嚎鍛藉悕杞崲涓洪┘宄板懡鍚�
- return result.stream().map(map -> map.entrySet().stream()
- .collect(Collectors.toMap(
- entry -> underlineToCamel(entry.getKey()),
- Map.Entry::getValue))
- ).collect(Collectors.toList());
+ return visibleCustomers.stream().map(item -> {
+ Map<String, Object> map = new LinkedHashMap<>();
+ map.put("id", item.getId());
+ map.put("customerName", item.getCustomerName());
+ map.put("taxpayerIdentificationNumber", item.getTaxpayerIdentificationNumber());
+ return map;
+ }).collect(Collectors.toList());
}
// 鍒嗛厤鍏捣瀹㈡埛缁欑娴�
--
Gitblit v1.9.3