| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | customerVo.setFollowUpList(followUpDtoList); |
| | | } |
| | | |
| | | fillDepositAmount(Collections.singletonList(customerVo)); |
| | | |
| | | return customerVo; |
| | | } |
| | | |
| | | /** |
| | | * 填代储金额(该客户全部「类型=代储」的销售台账合同金额累计)并判断是否已超信托基金 |
| | | */ |
| | | 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); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | |
| | | c.setUserIds(userIds); |
| | | } |
| | | }); |
| | | |
| | | fillDepositAmount(records); |
| | | } |
| | | |
| | | return customerPage; |
| | |
| | | |
| | | @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()); |
| | | } |
| | | |
| | | // 分配公海客户给私海 |