|
|
|
@@ -2,6 +2,7 @@ package com.simple.controller; |
|
|
|
|
|
|
|
import java.text.NumberFormat; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Calendar; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
@@ -28,6 +29,7 @@ import com.simple.domain.po.WxCoupon; |
|
|
|
import com.simple.domain.po.WxCouponOrder; |
|
|
|
import com.simple.domain.po.WxTags; |
|
|
|
import com.simple.domain.vo.UserStructureVo; |
|
|
|
import com.simple.enums.EnumAgeInfo; |
|
|
|
import com.simple.service.WxCUserBasicInfoService; |
|
|
|
import com.simple.service.WxCUserService; |
|
|
|
import com.simple.service.WxCUserTagsService; |
|
|
|
@@ -206,30 +208,61 @@ public class WxCUserBasicInfoController extends BaseController |
|
|
|
WxCuerBasicInfoDto dto = new WxCuerBasicInfoDto(); |
|
|
|
dto.setStartTime(startTime); |
|
|
|
dto.setEndTime(endTime); |
|
|
|
dto.setSex(0); |
|
|
|
//保密 |
|
|
|
long secrecy = wxCUserBasicInfoService.findCountBySex(dto); |
|
|
|
dto.setSex(0); |
|
|
|
long secrecy = getCount(dto); |
|
|
|
dto.setSex(1); |
|
|
|
long boy = wxCUserBasicInfoService.findCountBySex(dto); |
|
|
|
long boy = getCount(dto); |
|
|
|
dto.setSex(2); |
|
|
|
long girl=wxCUserBasicInfoService.findCountBySex(dto); |
|
|
|
long girl=getCount(dto); |
|
|
|
Long all =secrecy+boy+girl; |
|
|
|
List<UserStructureVo> vos = new ArrayList<>(); |
|
|
|
vos.add(getVo(secrecy, all, "保密")); |
|
|
|
vos.add(getVo(boy, all, "男")); |
|
|
|
vos.add(getVo(girl, all, "女")); |
|
|
|
vos.add(getVo(secrecy, all, "保密")); |
|
|
|
return new ResultData(vos); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("查询会员年龄结构") |
|
|
|
@GetMapping("/findUserAgeStructure") |
|
|
|
public ResultData findUserAgeStructure() { |
|
|
|
Calendar c = Calendar.getInstance(); |
|
|
|
|
|
|
|
for(EnumAgeInfo a:EnumAgeInfo.values()) { |
|
|
|
c.clear(); |
|
|
|
c.setTime(new Date()); |
|
|
|
c.set(Calendar.HOUR_OF_DAY, 0); |
|
|
|
c.set(Calendar.MINUTE,0); |
|
|
|
c.set(Calendar.SECOND,0); |
|
|
|
long count = getCountByAge(a, c); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return new ResultData(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private long getCountByAge(EnumAgeInfo a,Calendar c) { |
|
|
|
WxCuerBasicInfoDto dto =new WxCuerBasicInfoDto(); |
|
|
|
c.add(Calendar.YEAR, -a.getEnd()); |
|
|
|
Date startTime = c.getTime(); |
|
|
|
c.clear(); |
|
|
|
c.setTime(startTime); |
|
|
|
c.add(Calendar.YEAR,a.getEnd()-a.getStart()); |
|
|
|
Date endTime = c.getTime(); |
|
|
|
dto.setStartTime(startTime); |
|
|
|
dto.setEndTime(endTime); |
|
|
|
return wxCUserBasicInfoService.findCountByAge(dto); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//通过性别获取数量 |
|
|
|
private long getCount(WxCuerBasicInfoDto dto) { |
|
|
|
//TODO 考虑性能问题,暂不处理少量重复问题,后续可考虑大数据处理 |
|
|
|
return wxCUserBasicInfoService.findCountBySex(dto)+ |
|
|
|
wxCUserService.findCountBySex(dto); |
|
|
|
} |
|
|
|
|
|
|
|
private UserStructureVo getVo(long count,long all,String name) { |
|
|
|
UserStructureVo vo = new UserStructureVo(); |
|
|
|
vo.setName(name); |
|
|
|
|