Browse Source

[会员结构][修改]修改返回数据

release_toaliyun_real
jinguo24@163.com 7 years ago
parent
commit
5a791fe90e
5 changed files with 59 additions and 23 deletions
  1. +16
    -16
      mallinkAdmin/src/main/java/com/simple/controller/WxCUserBasicInfoController.java
  2. +21
    -0
      mallinkService/src/main/java/com/simple/domain/dto/WxCuerBasicInfoDto.java
  3. +8
    -0
      mallinkService/src/main/java/com/simple/domain/vo/UserStructureVo.java
  4. +4
    -4
      mallinkService/src/main/java/com/simple/enums/EnumAgeInfo.java
  5. +10
    -3
      mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml

+ 16
- 16
mallinkAdmin/src/main/java/com/simple/controller/WxCUserBasicInfoController.java View File

@@ -217,17 +217,19 @@ public class WxCUserBasicInfoController extends BaseController
long girl=getCount(dto);
Long all =secrecy+boy+girl;
List<UserStructureVo> vos = new ArrayList<>();
vos.add(getVo(boy, all, "男"));
vos.add(getVo(girl, all, "女"));
vos.add(getVo(secrecy, all, "保密"));
vos.add(getVo(boy, all, "男",1));
vos.add(getVo(girl, all, "女",2));
vos.add(getVo(secrecy, all, "保密",3));
return new ResultData(vos);
}
@ApiOperation("查询会员年龄结构")
@GetMapping("/findUserAgeStructure")
public ResultData findUserAgeStructure() {
long all =wxCUserBasicInfoService.findCountByAge(new WxCuerBasicInfoDto());
public ResultData findUserAgeStructure( Date startTime,Date endTime) {
WxCuerBasicInfoDto dto = new WxCuerBasicInfoDto();
dto.setStartTime(startTime);
dto.setEndTime(endTime);
long all =wxCUserBasicInfoService.findCountByAge(dto);
List<UserStructureVo> vos = new ArrayList<>();
Calendar c = Calendar.getInstance();
for(EnumAgeInfo a:EnumAgeInfo.values()) {
@@ -236,25 +238,22 @@ public class WxCUserBasicInfoController extends BaseController
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE,0);
c.set(Calendar.SECOND,0);
long count = getCountByAge(a, c);
vos.add(getVo(count, all, a.getDesc()));
long count = getCountByAge(a, c,dto);
vos.add(getVo(count, all, a.getDesc(),a.getSortNum()));
}
return new ResultData();
return new ResultData(vos);
}
private long getCountByAge(EnumAgeInfo a,Calendar c) {
WxCuerBasicInfoDto dto =new WxCuerBasicInfoDto();
private long getCountByAge(EnumAgeInfo a,Calendar c, WxCuerBasicInfoDto dto ) {
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);
dto.setBirthStartTime(startTime);
dto.setBirthEndTime(endTime);
return wxCUserBasicInfoService.findCountByAge(dto);
}
@@ -266,8 +265,9 @@ public class WxCUserBasicInfoController extends BaseController
wxCUserService.findCountBySex(dto);
}
private UserStructureVo getVo(long count,long all,String name) {
private UserStructureVo getVo(long count,long all,String name,Integer num) {
UserStructureVo vo = new UserStructureVo();
vo.setSortNum(num);
vo.setName(name);
vo.setCount(count+"");
NumberFormat nf = NumberFormat.getPercentInstance();


+ 21
- 0
mallinkService/src/main/java/com/simple/domain/dto/WxCuerBasicInfoDto.java View File

@@ -32,10 +32,31 @@ public class WxCuerBasicInfoDto implements Serializable{
// @io.swagger.annotations.ApiModelProperty(value="租户id",name="tenantId")
@Transient
private String tenantId;
@Transient
private Date birthStartTime;
@Transient
private Date birthEndTime;
@Transient
private Integer sex;
public Date getBirthStartTime() {
return birthStartTime;
}
public void setBirthStartTime(Date birthStartTime) {
this.birthStartTime = birthStartTime;
}
public Date getBirthEndTime() {
return birthEndTime;
}
public void setBirthEndTime(Date birthEndTime) {
this.birthEndTime = birthEndTime;
}
public Integer getSex() {
return sex;
}


+ 8
- 0
mallinkService/src/main/java/com/simple/domain/vo/UserStructureVo.java View File

@@ -18,6 +18,14 @@ public class UserStructureVo implements Serializable{
private String count;
//百分比
private String percentage;
//序号
private Integer sortNum;
public Integer getSortNum() {
return sortNum;
}
public void setSortNum(Integer sortNum) {
this.sortNum = sortNum;
}
public String getName() {
return name;
}


+ 4
- 4
mallinkService/src/main/java/com/simple/enums/EnumAgeInfo.java View File

@@ -3,10 +3,10 @@ package com.simple.enums;
public enum EnumAgeInfo {
FIRST_SLOT(1,0,18,"18岁以下"),
SECOND_SLOT(2,18,24,"18岁-24岁"),
THIRD_SLOT(3,18,24,"25岁-34岁"),
FOURTH_SLOT(4,18,24,"35岁-44岁"),
FIFTH_SLOT(5,18,24,"45岁-54岁"),
SIXTH_SLOT(6,18,24,"55岁-60岁"),
THIRD_SLOT(3,25,34,"25岁-34岁"),
FOURTH_SLOT(4,35,44,"35岁-44岁"),
FIFTH_SLOT(5,45,54,"45岁-54岁"),
SIXTH_SLOT(6,54,60,"55岁-60岁"),
SEVENTH_SLOT(7,18,24,"60岁以上")
;


+ 10
- 3
mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml View File

@@ -153,12 +153,19 @@
<select id="findCountByAge" parameterType="com.simple.domain.dto.WxCuerBasicInfoDto" resultType="java.lang.Long">
select count(id) from wx_c_user_basic_info where 1=1
select count(id) from wx_c_user_basic_info where birthdate != null
<if test=" null != startTime ">
and birthdate &gt;= #{startTime}
and create_date &gt;= #{startTime}
</if>
<if test=" null != endTime">
and birthdate &lt;= #{endTime}
and create_date &lt;= #{endTime}
</if>
<if test=" null != birthStartTime ">
and birthdate &gt;= #{birthStartTime}
</if>
<if test=" null != birthEndTime">
and birthdate &lt;= #{birthEndTime}
</if>
</select>


Loading…
Cancel
Save