diff --git a/server/crm/src/main/java/com/pudonghot/ambition/crm/service/support/CustomerYearToDateSaleServiceSupport.java b/server/crm/src/main/java/com/pudonghot/ambition/crm/service/support/CustomerYearToDateSaleServiceSupport.java index 92c5245..94ee811 100644 --- a/server/crm/src/main/java/com/pudonghot/ambition/crm/service/support/CustomerYearToDateSaleServiceSupport.java +++ b/server/crm/src/main/java/com/pudonghot/ambition/crm/service/support/CustomerYearToDateSaleServiceSupport.java @@ -105,15 +105,22 @@ public class CustomerYearToDateSaleServiceSupport return; } - val customer = customerMapper.find( + val customers = customerMapper.list( new Search(Customer.ID2, customerId2) .eq(Customer.NAME, customerName)); - if (customer == null) { + if (customers.isEmpty()) { log.warn("No customer [{}] found, ignore.", customerName); return; } + if (customers.size() > 1) { + log.warn("Duplicate customers [{}] found, error.", customers); + throw new IllegalStateException( + "Duplicate customer found, id [" + customerId2 + "] name [" + customerName + "]"); + } + + val customer = customers.iterator().next(); val customerId = customer.getId(); customerYtdSale.setCustomerId(customerId); customerYtdSale.setYear(StringUtils.trim(record.get(3)));