|
|
@@ -1,5 +1,6 @@ |
|
|
package com.simple.controller;
|
|
|
package com.simple.controller;
|
|
|
|
|
|
|
|
|
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.text.NumberFormat;
|
|
|
import java.text.NumberFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.ArrayList;
|
|
|
@@ -9,7 +10,6 @@ import java.util.HashMap; |
|
|
import java.util.List;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
@@ -17,9 +17,11 @@ import org.springframework.web.bind.annotation.RestController; |
|
|
|
|
|
|
|
|
import com.simple.common.ResultData;
|
|
|
import com.simple.common.ResultData;
|
|
|
import com.simple.domain.dto.WxCuerBasicInfoDto;
|
|
|
import com.simple.domain.dto.WxCuerBasicInfoDto;
|
|
|
|
|
|
import com.simple.domain.vo.CUserDateAmountVo;
|
|
|
import com.simple.domain.vo.TouchUsersReportVo;
|
|
|
import com.simple.domain.vo.TouchUsersReportVo;
|
|
|
import com.simple.domain.vo.UserStructureVo;
|
|
|
import com.simple.domain.vo.UserStructureVo;
|
|
|
import com.simple.service.WxCUserService;
|
|
|
import com.simple.service.WxCUserService;
|
|
|
|
|
|
import com.simple.service.WxCouponOrderService;
|
|
|
import com.simple.service.WxUserVisitService;
|
|
|
import com.simple.service.WxUserVisitService;
|
|
|
|
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.Api;
|
|
|
@@ -34,6 +36,8 @@ public class WxCUserDataController extends BaseController{ |
|
|
private WxCUserService wxCUserService;
|
|
|
private WxCUserService wxCUserService;
|
|
|
@Autowired
|
|
|
@Autowired
|
|
|
private WxUserVisitService wxUserVisitService;
|
|
|
private WxUserVisitService wxUserVisitService;
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private WxCouponOrderService wxCouponOrderService;
|
|
|
|
|
|
|
|
|
@GetMapping("findUserCountData")
|
|
|
@GetMapping("findUserCountData")
|
|
|
@ApiOperation("查询用户数量接口")
|
|
|
@ApiOperation("查询用户数量接口")
|
|
|
@@ -96,14 +100,15 @@ public class WxCUserDataController extends BaseController{ |
|
|
weekPercentage= nf.format(new Double(todayCount).doubleValue());
|
|
|
weekPercentage= nf.format(new Double(todayCount).doubleValue());
|
|
|
}
|
|
|
}
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
map.put("allCount", allCount);
|
|
|
|
|
|
map.put("todayCount", todayCount);
|
|
|
|
|
|
map.put("newCountVos", newCountVos);
|
|
|
|
|
|
|
|
|
map.put("allCount", allCount);//会员总数
|
|
|
|
|
|
map.put("todayCount", todayCount);//今日新增会员数
|
|
|
|
|
|
map.put("newCountVos", newCountVos);//近一个月新增数列表
|
|
|
map.put("dayPercentage",dayPercentage);//日环比
|
|
|
map.put("dayPercentage",dayPercentage);//日环比
|
|
|
map.put("weekPercentage",weekPercentage); //周同比
|
|
|
map.put("weekPercentage",weekPercentage); //周同比
|
|
|
return new ResultData(map);
|
|
|
return new ResultData(map);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation("查询用户活跃量")
|
|
|
@GetMapping("findUserVisitData")
|
|
|
@GetMapping("findUserVisitData")
|
|
|
public ResultData findUserVisitData() {
|
|
|
public ResultData findUserVisitData() {
|
|
|
HashMap<String, Object> params =new HashMap<>();
|
|
|
HashMap<String, Object> params =new HashMap<>();
|
|
|
@@ -136,7 +141,7 @@ public class WxCUserDataController extends BaseController{ |
|
|
c.add(Calendar.DAY_OF_YEAR, -i);
|
|
|
c.add(Calendar.DAY_OF_YEAR, -i);
|
|
|
String dayStr = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
|
|
|
String dayStr = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
|
|
|
UserStructureVo vo = new UserStructureVo();
|
|
|
UserStructureVo vo = new UserStructureVo();
|
|
|
vo.setName(dayStr);
|
|
|
|
|
|
|
|
|
vo.setName(new SimpleDateFormat("MM-dd").format(c.getTime()));
|
|
|
vo.setSortNum(j);
|
|
|
vo.setSortNum(j);
|
|
|
j++;
|
|
|
j++;
|
|
|
if(dateMap.get(dayStr)!=null) {
|
|
|
if(dateMap.get(dayStr)!=null) {
|
|
|
@@ -156,7 +161,7 @@ public class WxCUserDataController extends BaseController{ |
|
|
c.add(Calendar.DAY_OF_YEAR, -i);
|
|
|
c.add(Calendar.DAY_OF_YEAR, -i);
|
|
|
String dayStr = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
|
|
|
String dayStr = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
|
|
|
UserStructureVo vo = new UserStructureVo();
|
|
|
UserStructureVo vo = new UserStructureVo();
|
|
|
vo.setName(dayStr);
|
|
|
|
|
|
|
|
|
vo.setName(new SimpleDateFormat("MM-dd").format(c.getTime()));
|
|
|
vo.setSortNum(j);
|
|
|
vo.setSortNum(j);
|
|
|
if(dateMap.get(dayStr)!=null) {
|
|
|
if(dateMap.get(dayStr)!=null) {
|
|
|
TouchUsersReportVo rv = dateMap.get(dayStr);
|
|
|
TouchUsersReportVo rv = dateMap.get(dayStr);
|
|
|
@@ -175,7 +180,6 @@ public class WxCUserDataController extends BaseController{ |
|
|
if(i==7) {
|
|
|
if(i==7) {
|
|
|
dayOfWeekCount=vo.getCount();
|
|
|
dayOfWeekCount=vo.getCount();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
monthVos.add(vo);
|
|
|
monthVos.add(vo);
|
|
|
j++;
|
|
|
j++;
|
|
|
}
|
|
|
}
|
|
|
@@ -198,12 +202,98 @@ public class WxCUserDataController extends BaseController{ |
|
|
Map<String,Object> mapVo =new HashMap<>();
|
|
|
Map<String,Object> mapVo =new HashMap<>();
|
|
|
mapVo.put("yesterdayCount", yesterdayCount);//昨日活跃数
|
|
|
mapVo.put("yesterdayCount", yesterdayCount);//昨日活跃数
|
|
|
mapVo.put("thisMonthCount", thisMonthCount);//近一个月活跃数
|
|
|
mapVo.put("thisMonthCount", thisMonthCount);//近一个月活跃数
|
|
|
mapVo.put("weekVos", weekVos);//上周活跃数
|
|
|
|
|
|
mapVo.put("monthVos", monthVos);//上月活跃数
|
|
|
|
|
|
|
|
|
mapVo.put("weekVos", weekVos);//上周活跃数列表
|
|
|
|
|
|
mapVo.put("monthVos", monthVos);//上月活跃数列表
|
|
|
mapVo.put("dayPercentage",dayPercentage);//日环比
|
|
|
mapVo.put("dayPercentage",dayPercentage);//日环比
|
|
|
mapVo.put("weekPercentage",weekPercentage); //周同比
|
|
|
mapVo.put("weekPercentage",weekPercentage); //周同比
|
|
|
return new ResultData(mapVo);
|
|
|
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);//月消费金额
|
|
|
|
|
|
c.clear();
|
|
|
|
|
|
c.setTime(endTime);
|
|
|
|
|
|
Date eTime=c.getTime();
|
|
|
|
|
|
c.add(Calendar.DAY_OF_YEAR, -8);
|
|
|
|
|
|
Date sTime =c.getTime();
|
|
|
|
|
|
List<CUserDateAmountVo> datas = wxCouponOrderService.queryPriceTotalGroup(tenantId, sTime, eTime);
|
|
|
|
|
|
Map<String,Integer> dataMap = new HashMap<>();
|
|
|
|
|
|
for(CUserDateAmountVo v:datas) {
|
|
|
|
|
|
dataMap.put(v.getxTime(), v.getPrice());
|
|
|
|
|
|
}
|
|
|
|
|
|
Integer todayCount=0;//今日金额数
|
|
|
|
|
|
Integer yesterdayCount =0;//昨日金额数
|
|
|
|
|
|
Integer dayOfWeekCount=0;//上周x
|
|
|
|
|
|
int j=0;
|
|
|
|
|
|
List<UserStructureVo> 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++;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
NumberFormat nf = NumberFormat.getPercentInstance();
|
|
|
|
|
|
nf.setMinimumFractionDigits(2);
|
|
|
|
|
|
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 ="";
|
|
|
|
|
|
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<String,Object> map =new HashMap<>();
|
|
|
|
|
|
DecimalFormat df=new DecimalFormat("0.00");
|
|
|
|
|
|
map.put("todayCount", df.format((float)todayCount/100));//今日消费金额
|
|
|
|
|
|
String thisMonthCountStr = df.format((float)thisMonthCount/100);
|
|
|
|
|
|
map.put("thisMonthCount", thisMonthCountStr);//近一个月消费金额数
|
|
|
|
|
|
map.put("dayPercentage",dayPercentage);//日环比
|
|
|
|
|
|
map.put("weekPercentage",weekPercentage); //周同比
|
|
|
|
|
|
map.put("weekCountVos", weekCountVos);//一周金额列表
|
|
|
|
|
|
return new ResultData(map);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|