Просмотр исходного кода

[A端][修改]:会员首页接口更改适配最新会员概览前端

release_toaliyun_real
hupeng 7 лет назад
Родитель
Сommit
2b1dc7c85e
2 измененных файлов: 163 добавлений и 166 удалений
  1. +161
    -165
      mallinkAdmin/src/main/java/com/iformall/controller/WxCUserDataController.java
  2. +2
    -1
      mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml

+ 161
- 165
mallinkAdmin/src/main/java/com/iformall/controller/WxCUserDataController.java Просмотреть файл

@@ -45,70 +45,75 @@ public class WxCUserDataController extends BaseController {
@GetMapping("findUserCountData") @GetMapping("findUserCountData")
@ApiOperation("查询用户数量接口") @ApiOperation("查询用户数量接口")
public ResultData findUserCountData() { 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(); Calendar c = Calendar.getInstance();
c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE,0); c.set(Calendar.MINUTE,0);
c.set(Calendar.SECOND,0); c.set(Calendar.SECOND,0);
Date today = c.getTime(); Date today = c.getTime();
// dto.setStartTime(today);
// dto.setEndTime(null);
// long todayCount= wxCUserService.findCount( dto);//今天新增
// System.out.println(todayCount);

long todayCount=0; long todayCount=0;
long yesterdayCount =0; long yesterdayCount =0;
long dayOfWeekCount=0; long dayOfWeekCount=0;
List<UserStructureVo> newCountVos = new ArrayList<>();//每日新增会员数
int j=0;
for(int i=7;i>=0;i--) {
List<UserStructureVo> weekVos = new ArrayList<>();//周会员数
List<UserStructureVo> monthVos = new ArrayList<>();//周会员数

for(int i=29,sortNum=0;i>=0;i--) {
c.clear(); c.clear();
c.setTime(today); c.setTime(today);
c.add(Calendar.DAY_OF_YEAR, -i); c.add(Calendar.DAY_OF_YEAR, -i);
dto.setStartTime(c.getTime()); dto.setStartTime(c.getTime());
c.add(Calendar.DAY_OF_YEAR, 1); c.add(Calendar.DAY_OF_YEAR, 1);
dto.setEndTime(c.getTime()); 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<String,Object> 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<String,Object> 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("查询用户活跃量") @ApiOperation("查询用户活跃量")
@@ -129,24 +134,23 @@ public class WxCUserDataController extends BaseController {
List<TouchUsersReportVo> list = wxUserVisitService.touchUsersReportList(params); List<TouchUsersReportVo> list = wxUserVisitService.touchUsersReportList(params);
Map<String,TouchUsersReportVo> dateMap = new HashMap<>(); Map<String,TouchUsersReportVo> dateMap = new HashMap<>();
for(TouchUsersReportVo vo :list) { for(TouchUsersReportVo vo :list) {
dateMap.put(vo.getxTime(), vo);
dateMap.put(vo.getxTime(), vo);
} }
List<UserStructureVo> weekVos = new ArrayList<>();//每周uv
List<UserStructureVo> 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<UserStructureVo> weekVos = new ArrayList<>();//每周uv
List<UserStructureVo> 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.clear();
c.setTime(endTime); c.setTime(endTime);
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(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) { if(dateMap.get(dayStr)!=null) {
TouchUsersReportVo rv = dateMap.get(dayStr); TouchUsersReportVo rv = dateMap.get(dayStr);
Long l = new Long((long) rv.getUv()); Long l = new Long((long) rv.getUv());
@@ -154,82 +158,70 @@ public class WxCUserDataController extends BaseController {
}else { }else {
vo.setCount(0); 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<String,Object> 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<String,Object> 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("查询用户消费金额") @ApiOperation("查询用户消费金额")
@GetMapping("findUserAmountData") @GetMapping("findUserAmountData")
private ResultData 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.clear();
c.setTime(endTime); c.setTime(endTime);
Date eTime=c.getTime(); Date eTime=c.getTime();
c.add(Calendar.DAY_OF_YEAR, -8);
c.add(Calendar.DAY_OF_YEAR, -30);
Date sTime =c.getTime(); Date sTime =c.getTime();
List<CUserDateAmountVo> datas = wxCouponOrderService.queryPriceTotalGroup(tenantId, sTime, eTime); List<CUserDateAmountVo> datas = wxCouponOrderService.queryPriceTotalGroup(tenantId, sTime, eTime);
Map<String,Integer> dataMap = new HashMap<>(); Map<String,Integer> dataMap = new HashMap<>();
@@ -238,52 +230,55 @@ public class WxCUserDataController extends BaseController {
} }
Integer todayCount=0;//今日金额数 Integer todayCount=0;//今日金额数
Integer yesterdayCount =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++;
Integer dayOfWeekCount=0;//上周x
List<UserStructureVo> weekVos = new ArrayList<>();//周消费金额
List<UserStructureVo> 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(); NumberFormat nf = NumberFormat.getPercentInstance();
nf.setMinimumFractionDigits(2); nf.setMinimumFractionDigits(2);
String dayPercentage ="";
String dayPercentage ="--";
if(yesterdayCount>0) { if(yesterdayCount>0) {
Integer count =todayCount-yesterdayCount; Integer count =todayCount-yesterdayCount;
dayPercentage=nf.format(count.doubleValue()/new Double(yesterdayCount).doubleValue()); dayPercentage=nf.format(count.doubleValue()/new Double(yesterdayCount).doubleValue());
}else {
dayPercentage= nf.format(new Double(todayCount).doubleValue());
} }
String weekPercentage ="";
String weekPercentage ="--";
if(dayOfWeekCount>0) { if(dayOfWeekCount>0) {
Integer count =todayCount-dayOfWeekCount; Integer count =todayCount-dayOfWeekCount;
weekPercentage=nf.format(count.doubleValue()/new Double(dayOfWeekCount).doubleValue()); weekPercentage=nf.format(count.doubleValue()/new Double(dayOfWeekCount).doubleValue());
}else {
weekPercentage= nf.format(new Double(todayCount).doubleValue());
} }
Map<String,Object> map =new HashMap<>(); Map<String,Object> map =new HashMap<>();
DecimalFormat df=new DecimalFormat("0.00"); DecimalFormat df=new DecimalFormat("0.00");
@@ -292,7 +287,8 @@ public class WxCUserDataController extends BaseController {
map.put("thisMonthCount", thisMonthCountStr);//近一个月消费金额数 map.put("thisMonthCount", thisMonthCountStr);//近一个月消费金额数
map.put("dayPercentage",dayPercentage);//日环比 map.put("dayPercentage",dayPercentage);//日环比
map.put("weekPercentage",weekPercentage); //周同比 map.put("weekPercentage",weekPercentage); //周同比
map.put("weekCountVos", weekCountVos);//一周金额列表
map.put("weekVos", weekVos);//一周金额列表
map.put("monthVos", monthVos);//一月金额列表
return new ResultData(map); return new ResultData(map);
} }


+ 2
- 1
mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml Просмотреть файл

@@ -163,6 +163,7 @@
and co.coupon_id = c.id and co.coupon_id = c.id
and cu.id = co.c_user_id and cu.id = co.c_user_id
and bu.id = co.b_user_id and bu.id = co.b_user_id
and bu.status = 0
<if test="startDate != null"> <if test="startDate != null">
AND co.update_date &gt; #{startDate,jdbcType=TIMESTAMP} AND co.update_date &gt; #{startDate,jdbcType=TIMESTAMP}
</if> </if>
@@ -425,7 +426,7 @@
</select> </select>


<select id="queryPriceTotalGroup" resultType="com.iformall.domain.vo.CUserDateAmountVo" > <select id="queryPriceTotalGroup" resultType="com.iformall.domain.vo.CUserDateAmountVo" >
SELECT DATE_FORMAT(create_date,'%m-%d') as xTime,SUM(coupon_price) as price from wx_coupon_order
SELECT DATE_FORMAT(create_date,'%Y-%m-%d') as xTime,SUM(coupon_price) as price from wx_coupon_order
where tenant_id=#{tenantId} AND create_date &gt;= #{startTime} and create_date &lt; #{endTime} GROUP BY xTime where tenant_id=#{tenantId} AND create_date &gt;= #{startTime} and create_date &lt; #{endTime} GROUP BY xTime
</select> </select>




Загрузка…
Отмена
Сохранить