From db8c524f14a26517efa2d405abe9cf03bb13f9f4 Mon Sep 17 00:00:00 2001 From: yechenhao Date: Thu, 14 May 2020 18:25:18 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E4=BC=98=E5=8C=96=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CustomerViewController.java | 40 ++++++++++++- .../customer/service/CustomerViewService.java | 58 +++++++++++++------ 2 files changed, 77 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/kiisoo/ic/customer/controller/CustomerViewController.java b/src/main/java/com/kiisoo/ic/customer/controller/CustomerViewController.java index 51159e2..463521c 100644 --- a/src/main/java/com/kiisoo/ic/customer/controller/CustomerViewController.java +++ b/src/main/java/com/kiisoo/ic/customer/controller/CustomerViewController.java @@ -34,7 +34,7 @@ public class CustomerViewController extends BaseController { private CustomerViewService customerViewService; /** - * 客户概览main + * 客户概览main——趋势图 * @param userId 用户id * @param selectStartTime 选中开始时间 * @param selectEndTime 选中结束时间 @@ -56,7 +56,43 @@ public class CustomerViewController extends BaseController { } /** - * 客户概览main + * 客户概览——Top榜 + * @param userId 用户id + * @param selectStartTime 选中开始时间 + * @param selectEndTime 选中结束时间 + * @return 客户概览VO + */ + @ResponseBody + @RequestMapping(value = "/main/date", method = RequestMethod.GET) + public Map getMainDataDate(@RequestParam("userId")Long userId, @RequestParam("selectStartTime")String selectStartTime, @RequestParam("selectEndTime")String selectEndTime){ + try{ + CustomerViewVO result = customerViewService.selectCustomerViewMainDate(userId, selectStartTime, selectEndTime); + return data(result); + }catch (Exception e){ + log.error("查询客户数据概览出错", e); + return fail(); + } + } + + /** + * 客户概览——拉黑数 + * @param userId 用户id + * @return 客户概览VO + */ + @ResponseBody + @RequestMapping(value = "/main/del", method = RequestMethod.GET) + public MapgetMainDataDate(@RequestParam("userId")Long userId){ + try{ + CustomerViewVO result = customerViewService.getDelNum(userId); + return data(result); + }catch (Exception e){ + log.error("查询客户数据概览出错", e); + return fail(); + } + } + + /** + * 客户概览——好友总数,好友去重数 * @return 客户概览VO */ @ResponseBody diff --git a/src/main/java/com/kiisoo/ic/customer/service/CustomerViewService.java b/src/main/java/com/kiisoo/ic/customer/service/CustomerViewService.java index b464986..9a237b4 100644 --- a/src/main/java/com/kiisoo/ic/customer/service/CustomerViewService.java +++ b/src/main/java/com/kiisoo/ic/customer/service/CustomerViewService.java @@ -101,7 +101,7 @@ public class CustomerViewService { private RetailCompanyMapper retailCompanyMapper; /** - * 客户概览main + * 客户概览main——趋势图 * @param userId 用户id * @param selectStartTime 选中开始时间 * @param selectEndTime 选中结束时间 @@ -116,37 +116,60 @@ public class CustomerViewService { if(CollectionUtils.isEmpty(shopIds)){ return customerViewVO; } - //柱状图好友list + //柱状图好友趋势图 List customerList = opCustomerDOMapper.selectCustomerList(shopIds, null, null, startTime, endTime); //会员总数 - //todo 会员数据暂时不能根据店铺查询 Long vipCount = opVipDOMapper.selectVipCountNew(); + customerViewVO.setAllVipCount(vipCount); - List newCustimerList = customerList.stream().filter(customerDO -> filterCustomerByRegisterTime(customerDO, selectStartTime, selectEndTime)).collect(Collectors.toList()); - //零售公司店均新增 - List shopAverageNewCustomerList = getOrgShopAvgNewCustomerList(newCustimerList, userId); - customerViewVO.setCompanyShopAverageNewCustomerList(shopAverageNewCustomerList); //设置趋势柱状图list List validCustomerList = customerList.stream().filter(customerDO -> VALID.equals(customerDO.getValidType())).collect(Collectors.toList()); handleChartData(customerList, validCustomerList, customerViewVO); - //设置新增好友,好友总数,拉黑数,vip人数 - setCustomerViewData(customerViewVO, vipCount, customerList, validCustomerList, selectStartTime, selectEndTime); + + //设置新增好友,新增好友(去重),vip人数 + setCustomerViewData(customerViewVO, customerList, validCustomerList, selectStartTime, selectEndTime); + + return customerViewVO; + } + + /** + * 客户概览——Top榜 + * @param userId 用户id + * @param selectStartTime 选中开始时间 + * @param selectEndTime 选中结束时间 + * @return 客户概览VO + */ + public CustomerViewVO selectCustomerViewMainDate(Long userId, String selectStartTime, String selectEndTime){ + CustomerViewVO customerViewVO = new CustomerViewVO(); + //shopIds + List shopIds = getShopIds(userId); + if(CollectionUtils.isEmpty(shopIds)){ + return customerViewVO; + } + //柱状图好友list + List customerList = opCustomerDOMapper.selectCustomerList(shopIds, null, null, selectStartTime, selectEndTime); + + //零售公司店均新增 + List shopAverageNewCustomerList = getOrgShopAvgNewCustomerList(customerList, userId); + customerViewVO.setCompanyShopAverageNewCustomerList(shopAverageNewCustomerList); + //前十名排行list等 - List orgNewCustomerList = getOrgNewCustomerList(newCustimerList); - List shopNewCustomerList = getShopNewCustomerList(newCustimerList); - List zeroExtendList = getZeroExtendList(newCustimerList, shopIds); + List orgNewCustomerList = getOrgNewCustomerList(customerList); + List shopNewCustomerList = getShopNewCustomerList(customerList); + List zeroExtendList = getZeroExtendList(customerList, shopIds); customerViewVO.setOrgNewCustomerList(orgNewCustomerList); customerViewVO.setShopNewCustomerList(shopNewCustomerList); customerViewVO.setZeroExtendList(zeroExtendList); + return customerViewVO; } /** - * 获取拉黑 - * @param userId - * @return + * 客户概览——拉黑数 + * @param userId 用户id + * @return 客户概览VO */ public CustomerViewVO getDelNum(Long userId){ List shopIds = getShopIds(userId); @@ -173,13 +196,12 @@ public class CustomerViewService { /** * 新增好友,好友总数,拉黑数,vip人数 * @param customerViewVO 客户概览VO - * @param vipCount 会员总数 * @param customerList 新增好友list * @param validCustomerList 新增好友(去重)list * @param selectStartTime 选中开始时间 * @param selectEndTime 选中结束时间 */ - public void setCustomerViewData(CustomerViewVO customerViewVO, Long vipCount,List customerList, + public void setCustomerViewData(CustomerViewVO customerViewVO, List customerList, List validCustomerList, String selectStartTime, String selectEndTime){ //新增好友 Long newCustomerCount = customerList.stream().filter(customerDO -> filterCustomerByRegisterTime(customerDO, selectStartTime, selectEndTime)).count(); @@ -187,8 +209,6 @@ public class CustomerViewService { //新增好友(去重) Long newValidCustomerCount = validCustomerList.stream().filter(customerDO -> filterCustomerByRegisterTime(customerDO, selectStartTime, selectEndTime)).count(); customerViewVO.setNewValidCustomer(newValidCustomerCount); - //会员总数 - customerViewVO.setAllVipCount(vipCount); }