| | |
| | | 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; |