diff --git a/src/main/java/com/kiisoo/ic/generalize/service/RetailCompanyService.java b/src/main/java/com/kiisoo/ic/generalize/service/RetailCompanyService.java index e0b6740..57135dc 100644 --- a/src/main/java/com/kiisoo/ic/generalize/service/RetailCompanyService.java +++ b/src/main/java/com/kiisoo/ic/generalize/service/RetailCompanyService.java @@ -377,12 +377,12 @@ public class RetailCompanyService { //计算两个时间间隔用于计算平均值 LocalDate start = LocalDate.parse(startTime); LocalDate end = LocalDate.parse(endTime); - long days = end.until(start, ChronoUnit.DAYS); + long days = end.until(start, ChronoUnit.DAYS) + 1; organizationalVO.setNewCustomer((int) (countEnd - count)); organizationalVO.setNewEffectiveCustomer((int) (countEnd2 - count2)); - organizationalVO.setAvgNewCustomer(check(countEnd - count, days)); - organizationalVO.setAvgNewEffectiveCustomer(check(countEnd2 - count2, days)); + organizationalVO.setAvgNewCustomer(check1(countEnd - count, days)); + organizationalVO.setAvgNewEffectiveCustomer(check1(countEnd2 - count2, days)); } private void newCustomerStore(String startTime, String endTime, DataVO organizationalVO, List storeIds) { @@ -436,6 +436,20 @@ public class RetailCompanyService { return Math.round((l1 / l2) * 100); } } + /** + * 除法计算 + * + * @param l1 被除数 + * @param l2 除数 + * @return 值 + */ + public Integer check1(Long l1, Long l2) { + if (l2 == null || l1 == null || l2 == 0) { + return 0; + } else { + return Math.round((l1 / l2)); + } + } /** * 查询门店推广数据