From 2b1dc7c85e31321c7e3fffccc7e4e459dfce1f75 Mon Sep 17 00:00:00 2001 From: hupeng Date: Thu, 20 Sep 2018 16:05:04 +0800 Subject: [PATCH] =?UTF-8?q?[A=E7=AB=AF][=E4=BF=AE=E6=94=B9]:=E4=BC=9A?= =?UTF-8?q?=E5=91=98=E9=A6=96=E9=A1=B5=E6=8E=A5=E5=8F=A3=E6=9B=B4=E6=94=B9?= =?UTF-8?q?=E9=80=82=E9=85=8D=E6=9C=80=E6=96=B0=E4=BC=9A=E5=91=98=E6=A6=82?= =?UTF-8?q?=E8=A7=88=E5=89=8D=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/WxCUserDataController.java | 326 +++++++++--------- .../resources/mapper/WxCouponOrderMapper.xml | 3 +- 2 files changed, 163 insertions(+), 166 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/WxCUserDataController.java b/mallinkAdmin/src/main/java/com/iformall/controller/WxCUserDataController.java index a9ca99ed4..77609fd06 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/WxCUserDataController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/WxCUserDataController.java @@ -45,70 +45,75 @@ public class WxCUserDataController extends BaseController { @GetMapping("findUserCountData") @ApiOperation("查询用户数量接口") public ResultData findUserCountData() { - WxCUserBasicInfoDto dto = new WxCUserBasicInfoDto(); - long allCount = wxCUserService.findCount(dto);//总数 + WxCUserBasicInfoDto dto = new WxCUserBasicInfoDto(); + dto.setTenantId(getTenantId()); + long allCount = wxCUserService.findCount(dto);//总数 Calendar c = Calendar.getInstance(); c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE,0); c.set(Calendar.SECOND,0); Date today = c.getTime(); -// dto.setStartTime(today); -// dto.setEndTime(null); -// long todayCount= wxCUserService.findCount( dto);//今天新增 -// System.out.println(todayCount); + long todayCount=0; long yesterdayCount =0; long dayOfWeekCount=0; - List newCountVos = new ArrayList<>();//每日新增会员数 - int j=0; - for(int i=7;i>=0;i--) { + List weekVos = new ArrayList<>();//周会员数 + List monthVos = new ArrayList<>();//周会员数 + + for(int i=29,sortNum=0;i>=0;i--) { c.clear(); c.setTime(today); c.add(Calendar.DAY_OF_YEAR, -i); dto.setStartTime(c.getTime()); c.add(Calendar.DAY_OF_YEAR, 1); dto.setEndTime(c.getTime()); - long count= wxCUserService.findCount(dto); - UserStructureVo vo = new UserStructureVo(); - vo.setSortNum(j); - j++; - vo.setName(new SimpleDateFormat("MM-dd").format(dto.getStartTime())); - vo.setCount(count); - if(i==1) { - yesterdayCount= count; - } - if(i==0) { - todayCount=count; - } - if(i==7) { - dayOfWeekCount=count;//上周同比 - }else { - newCountVos.add(vo); - } + long count= wxCUserService.findCount(dto); + UserStructureVo vo = new UserStructureVo(); + + vo.setName(new SimpleDateFormat("MM/dd").format(dto.getStartTime())); + vo.setSortNum(sortNum++); + vo.setCount(count); + if (i <= 7) { + UserStructureVo vow = new UserStructureVo(); + vow.setSortNum(vo.getSortNum()); + vow.setName(vo.getName()); + vow.setCount(vo.getCount()); + + if (i == 1) { + yesterdayCount = vow.getCount(); + } + if (i == 0) { + todayCount = vow.getCount(); + } + if (i == 7) { + dayOfWeekCount = vow.getCount(); + } else { + weekVos.add(vow); + } + } + monthVos.add(vo); } - NumberFormat nf = NumberFormat.getPercentInstance(); - nf.setMinimumFractionDigits(2); - String dayPercentage =""; - if(yesterdayCount>0) { - Long count =todayCount-yesterdayCount; - dayPercentage=nf.format(count.doubleValue()/new Double(yesterdayCount).doubleValue()); - }else { - dayPercentage= nf.format(new Double(todayCount).doubleValue()); - } - String weekPercentage =""; - if(dayOfWeekCount>0) { - Long count =todayCount-dayOfWeekCount; - weekPercentage=nf.format(count.doubleValue()/new Double(dayOfWeekCount).doubleValue()); - }else { - weekPercentage= nf.format(new Double(todayCount).doubleValue()); - } - Map map = new HashMap<>(); - map.put("allCount", allCount);//会员总数 - map.put("todayCount", todayCount);//今日新增会员数 - map.put("newCountVos", newCountVos);//近一个月新增数列表 - map.put("dayPercentage",dayPercentage);//日环比 - map.put("weekPercentage",weekPercentage); //周同比 - return new ResultData(map); + + NumberFormat nf = NumberFormat.getPercentInstance(); + nf.setMinimumFractionDigits(2); + String dayPercentage ="--"; + if(yesterdayCount>0) { + Long count =todayCount-yesterdayCount; + dayPercentage=nf.format(count.doubleValue()/new Double(yesterdayCount).doubleValue()); + } + String weekPercentage ="--"; + if(dayOfWeekCount>0) { + Long count =todayCount-dayOfWeekCount; + weekPercentage=nf.format(count.doubleValue()/new Double(dayOfWeekCount).doubleValue()); + } + Map map = new HashMap<>(); + map.put("allCount", allCount);//会员总数 + map.put("todayCount", todayCount);//今日新增会员数 + map.put("weekVos", weekVos);//月用户增加数列表 + map.put("monthVos", monthVos);//月用户增加数列表 + map.put("dayPercentage",dayPercentage);//日环比 + map.put("weekPercentage",weekPercentage); //周同比 + return new ResultData(map); } @ApiOperation("查询用户活跃量") @@ -129,24 +134,23 @@ public class WxCUserDataController extends BaseController { List list = wxUserVisitService.touchUsersReportList(params); Map dateMap = new HashMap<>(); for(TouchUsersReportVo vo :list) { - dateMap.put(vo.getxTime(), vo); + dateMap.put(vo.getxTime(), vo); } - List weekVos = new ArrayList<>();//每周uv - List monthVos =new ArrayList<>();//每月uv - int j=1; - long yesterdayCount =0;//昨天活跃数 - long beforeYesterdayCount=0;//前天活跃数 - long thisMonthCount=0;//月总数 - long dayOfWeekCount=0;//上周周x数 - for(int i=6;i>=0;i--) { + List weekVos = new ArrayList<>();//每周uv + List monthVos =new ArrayList<>();//每月uv + + long yesterdayCount =0;//昨天活跃数 + long beforeYesterdayCount=0;//前天活跃数 + long thisMonthCount=0;//月总数 + long dayOfWeekCount=0;//上周周x数 + for(int i=29,sortNum=0;i>=0;i--) { c.clear(); c.setTime(endTime); c.add(Calendar.DAY_OF_YEAR, -i); String dayStr = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime()); UserStructureVo vo = new UserStructureVo(); - vo.setName(new SimpleDateFormat("MM-dd").format(c.getTime())); - vo.setSortNum(j); - j++; + vo.setName(new SimpleDateFormat("MM/dd").format(c.getTime())); + vo.setSortNum(sortNum++); if(dateMap.get(dayStr)!=null) { TouchUsersReportVo rv = dateMap.get(dayStr); Long l = new Long((long) rv.getUv()); @@ -154,82 +158,70 @@ public class WxCUserDataController extends BaseController { }else { vo.setCount(0); } - weekVos.add(vo); + + if (i <= 7) { + UserStructureVo vow = new UserStructureVo(); + vow.setName(vo.getName()); + vow.setSortNum(vo.getSortNum()); + vow.setCount(vo.getCount()); + + if (i == 0) { + yesterdayCount = vow.getCount(); + } + if (i == 1) { + beforeYesterdayCount = vow.getCount(); + } + if (i == 7) { + dayOfWeekCount = vow.getCount(); + } else { + weekVos.add(vow); + } + + } + monthVos.add(vo); + thisMonthCount+=vo.getCount(); } - - j=1; - for(int i=29;i>=0;i--) { - c.clear(); - c.setTime(endTime); - c.add(Calendar.DAY_OF_YEAR, -i); - String dayStr = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime()); - UserStructureVo vo = new UserStructureVo(); - vo.setName(new SimpleDateFormat("MM-dd").format(c.getTime())); - vo.setSortNum(j); - if(dateMap.get(dayStr)!=null) { - TouchUsersReportVo rv = dateMap.get(dayStr); - Long l = new Long((long) rv.getUv()); - vo.setCount(l); - }else { - vo.setCount(0); - } - thisMonthCount+=vo.getCount(); - if(i==0) { - yesterdayCount =vo.getCount(); - } - if(i==1) { - beforeYesterdayCount =vo.getCount(); - } - if(i==7) { - dayOfWeekCount=vo.getCount(); - } - monthVos.add(vo); - j++; - } - NumberFormat nf = NumberFormat.getPercentInstance(); - nf.setMinimumFractionDigits(2); - String dayPercentage =""; - if(beforeYesterdayCount>0) { - Long count =yesterdayCount-beforeYesterdayCount; - dayPercentage=nf.format(count.doubleValue()/new Double(beforeYesterdayCount).doubleValue()); - }else { - dayPercentage= nf.format(new Double(yesterdayCount).doubleValue()); - } - String weekPercentage =""; - if(dayOfWeekCount>0) { - Long count =yesterdayCount-dayOfWeekCount; - weekPercentage=nf.format(count.doubleValue()/new Double(dayOfWeekCount).doubleValue()); - }else { - weekPercentage= nf.format(new Double(yesterdayCount).doubleValue()); - } - Map mapVo =new HashMap<>(); - mapVo.put("yesterdayCount", yesterdayCount);//昨日活跃数 - mapVo.put("thisMonthCount", thisMonthCount);//近一个月活跃数 - mapVo.put("weekVos", weekVos);//上周活跃数列表 - mapVo.put("monthVos", monthVos);//上月活跃数列表 - mapVo.put("dayPercentage",dayPercentage);//日环比 - mapVo.put("weekPercentage",weekPercentage); //周同比 - return new ResultData(mapVo); + + NumberFormat nf = NumberFormat.getPercentInstance(); + nf.setMinimumFractionDigits(2); + String dayPercentage ="--"; + if(beforeYesterdayCount>0) { + Long count =yesterdayCount-beforeYesterdayCount; + dayPercentage=nf.format(count.doubleValue()/new Double(beforeYesterdayCount).doubleValue()); + } + String weekPercentage ="--"; + if(dayOfWeekCount>0) { + Long count =yesterdayCount-dayOfWeekCount; + weekPercentage=nf.format(count.doubleValue()/new Double(dayOfWeekCount).doubleValue()); + } + Map mapVo =new HashMap<>(); + mapVo.put("yesterdayCount", yesterdayCount);//昨日活跃数 + mapVo.put("thisMonthCount", thisMonthCount);//近一个月活跃数 + mapVo.put("weekVos", weekVos);//周活跃数列表 + mapVo.put("monthVos", monthVos);//月活跃数列表 + mapVo.put("dayPercentage",dayPercentage);//日环比 + mapVo.put("weekPercentage",weekPercentage); //周同比 + return new ResultData(mapVo); } @ApiOperation("查询用户消费金额") @GetMapping("findUserAmountData") private ResultData findUserAmountData() { - String tenantId = getTenantId(); - Calendar c =Calendar.getInstance(); - Date today = c.getTime(); - c.add(Calendar.DAY_OF_YEAR, 1); - c.set(Calendar.HOUR_OF_DAY, 0); - c.set(Calendar.MINUTE,0); - c.set(Calendar.SECOND,0); - Date endTime = c.getTime();//明天0点 - c.add(Calendar.DAY_OF_YEAR, -30);//三十天前 - Date startTime = c.getTime(); - int thisMonthCount =wxCouponOrderService.queryPriceTotal(tenantId, startTime, endTime);//月消费金额 + String tenantId = getTenantId(); + Calendar c =Calendar.getInstance(); + Date today = c.getTime(); + c.add(Calendar.DAY_OF_YEAR, 1); + c.set(Calendar.HOUR_OF_DAY, 0); + c.set(Calendar.MINUTE,0); + c.set(Calendar.SECOND,0); + Date endTime = c.getTime();//明天0点 + c.add(Calendar.DAY_OF_YEAR, -30);//三十天前 + Date startTime = c.getTime(); + int thisMonthCount =wxCouponOrderService.queryPriceTotal(tenantId, startTime, endTime);//月消费金额 c.clear(); c.setTime(endTime); Date eTime=c.getTime(); - c.add(Calendar.DAY_OF_YEAR, -8); + c.add(Calendar.DAY_OF_YEAR, -30); Date sTime =c.getTime(); List datas = wxCouponOrderService.queryPriceTotalGroup(tenantId, sTime, eTime); Map dataMap = new HashMap<>(); @@ -238,52 +230,55 @@ public class WxCUserDataController extends BaseController { } Integer todayCount=0;//今日金额数 Integer yesterdayCount =0;//昨日金额数 - Integer dayOfWeekCount=0;//上周x - int j=0; - List weekCountVos = new ArrayList<>();//周消费金额 - for(int i=7;i>=0;i--) { - c.clear(); - c.setTime(today); - c.add(Calendar.DAY_OF_YEAR, -i); - String dateStr = new SimpleDateFormat("MM-dd").format(c.getTime()); - UserStructureVo vo = new UserStructureVo(); - vo.setName(new SimpleDateFormat("MM-dd").format(c.getTime())); - vo.setSortNum(j); - if(dataMap.get(dateStr)!=null) { - int price= dataMap.get(dateStr); - vo.setPrice(price); - }else { - vo.setPrice(0); - } - if(i==0) { - todayCount =vo.getPrice(); - } - if(i==1) { - yesterdayCount =vo.getPrice(); - } - if(i==7) { - dayOfWeekCount=vo.getPrice(); - }else { - weekCountVos.add(vo); - } - j++; - + Integer dayOfWeekCount=0;//上周x + List weekVos = new ArrayList<>();//周消费金额 + List monthVos = new ArrayList<>();//周消费金额 + for(int i=29,sortNum=0;i>=0;i--) { + c.clear(); + c.setTime(today); + c.add(Calendar.DAY_OF_YEAR, -i); + String dateStr = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime()); + UserStructureVo vo = new UserStructureVo(); + vo.setName(new SimpleDateFormat("MM/dd").format(c.getTime())); + vo.setSortNum(sortNum++); + if(dataMap.get(dateStr)!=null) { + int price= dataMap.get(dateStr); + vo.setPrice(price); + }else { + vo.setPrice(0); + } + if (i <= 7) { + UserStructureVo vow = new UserStructureVo(); + vow.setName(vo.getName()); + vow.setSortNum(vo.getSortNum()); + vow.setPrice(vo.getPrice()); + + if (i == 0) { + todayCount = vow.getPrice(); + } + if (i == 1) { + yesterdayCount = vow.getPrice(); + } + if (i == 7) { + dayOfWeekCount = vow.getPrice(); + } else { + weekVos.add(vow); + } + } + monthVos.add(vo); } + NumberFormat nf = NumberFormat.getPercentInstance(); nf.setMinimumFractionDigits(2); - String dayPercentage =""; + String dayPercentage ="--"; if(yesterdayCount>0) { Integer count =todayCount-yesterdayCount; dayPercentage=nf.format(count.doubleValue()/new Double(yesterdayCount).doubleValue()); - }else { - dayPercentage= nf.format(new Double(todayCount).doubleValue()); } - String weekPercentage =""; + String weekPercentage ="--"; if(dayOfWeekCount>0) { Integer count =todayCount-dayOfWeekCount; weekPercentage=nf.format(count.doubleValue()/new Double(dayOfWeekCount).doubleValue()); - }else { - weekPercentage= nf.format(new Double(todayCount).doubleValue()); } Map map =new HashMap<>(); DecimalFormat df=new DecimalFormat("0.00"); @@ -292,7 +287,8 @@ public class WxCUserDataController extends BaseController { map.put("thisMonthCount", thisMonthCountStr);//近一个月消费金额数 map.put("dayPercentage",dayPercentage);//日环比 map.put("weekPercentage",weekPercentage); //周同比 - map.put("weekCountVos", weekCountVos);//一周金额列表 + map.put("weekVos", weekVos);//一周金额列表 + map.put("monthVos", monthVos);//一月金额列表 return new ResultData(map); } diff --git a/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml index 89bd36994..5012b52a6 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml @@ -163,6 +163,7 @@ and co.coupon_id = c.id and cu.id = co.c_user_id and bu.id = co.b_user_id + and bu.status = 0 AND co.update_date > #{startDate,jdbcType=TIMESTAMP} @@ -425,7 +426,7 @@