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

[会员结构查询][新增]查询百分比

release_toaliyun_real
jinguo24@163.com 7 лет назад
Родитель
Сommit
6a886b3e14
7 измененных файлов: 150 добавлений и 14 удалений
  1. +50
    -0
      mallinkAdmin/src/main/java/com/simple/controller/WxCUserBasicInfoController.java
  2. +11
    -3
      mallinkService/src/main/java/com/simple/domain/dto/WxCuerBasicInfoDto.java
  3. +42
    -0
      mallinkService/src/main/java/com/simple/domain/vo/UserStructureVo.java
  4. +2
    -0
      mallinkService/src/main/java/com/simple/mapper/WxCUserBasicInfoMapper.java
  5. +12
    -3
      mallinkService/src/main/java/com/simple/service/WxCUserBasicInfoService.java
  6. +17
    -6
      mallinkService/src/main/java/com/simple/service/impl/WxCUserBasicInfoServiceImpl.java
  7. +16
    -2
      mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml

+ 50
- 0
mallinkAdmin/src/main/java/com/simple/controller/WxCUserBasicInfoController.java Просмотреть файл

@@ -1,6 +1,8 @@
package com.simple.controller;

import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
@@ -25,6 +27,7 @@ import com.simple.domain.po.WxCUserTags;
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.service.WxCUserBasicInfoService;
import com.simple.service.WxCUserService;
import com.simple.service.WxCUserTagsService;
@@ -194,4 +197,51 @@ public class WxCUserBasicInfoController extends BaseController
}
return new ResultData(Result.SUCCESS,"查询成功",page);
}
@ApiOperation("查询会员性别结构")
@GetMapping("/findUserSexStructure")
public ResultData findUserSexStructure(
Date startTime,Date endTime
) {
WxCuerBasicInfoDto dto = new WxCuerBasicInfoDto();
dto.setStartTime(startTime);
dto.setEndTime(endTime);
dto.setSex(0);
//保密
long secrecy = wxCUserBasicInfoService.findCountBySex(dto);
dto.setSex(1);
long boy = wxCUserBasicInfoService.findCountBySex(dto);
dto.setSex(2);
long girl=wxCUserBasicInfoService.findCountBySex(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, "女"));
return new ResultData(vos);
}
@ApiOperation("查询会员年龄结构")
@GetMapping("/findUserSexStructure")
public ResultData findUserAgeStructure() {
return new ResultData();
}
private UserStructureVo getVo(long count,long all,String name) {
UserStructureVo vo = new UserStructureVo();
vo.setName(name);
vo.setCount(count+"");
NumberFormat nf = NumberFormat.getPercentInstance();
nf.setMinimumFractionDigits(2);//控制保留小数点后几位,2:表示保留2位小数点
if(all>0) {
vo.setPercentage(nf.format(new Long(count).doubleValue()/new Long(all).doubleValue()));
}else {
vo.setPercentage("0.00%");
}
return vo;
}
}

+ 11
- 3
mallinkService/src/main/java/com/simple/domain/dto/WxCuerBasicInfoDto.java Просмотреть файл

@@ -32,10 +32,18 @@ public class WxCuerBasicInfoDto implements Serializable{
// @io.swagger.annotations.ApiModelProperty(value="租户id",name="tenantId")
@Transient
private String tenantId;
@Transient
private Integer sex;
public Integer getSex() {
return sex;
}
public void setSex(Integer sex) {
this.sex = sex;
}
public String getName() {
return name;
}


+ 42
- 0
mallinkService/src/main/java/com/simple/domain/vo/UserStructureVo.java Просмотреть файл

@@ -0,0 +1,42 @@
package com.simple.domain.vo;
import java.io.Serializable;
/**
* 会员结构vo
* @author jinguo
*
*/
public class UserStructureVo implements Serializable{
/**
*
*/
private static final long serialVersionUID = 6780570955120276660L;
//名称
private String name;
//数量
private String count;
//百分比
private String percentage;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCount() {
return count;
}
public void setCount(String count) {
this.count = count;
}
public String getPercentage() {
return percentage;
}
public void setPercentage(String percentage) {
this.percentage = percentage;
}
}

+ 2
- 0
mallinkService/src/main/java/com/simple/mapper/WxCUserBasicInfoMapper.java Просмотреть файл

@@ -17,5 +17,7 @@ public interface WxCUserBasicInfoMapper extends CommonMapper<WxCUserBasicInfo, S

void updateScore(WxCUserBasicInfo record);
long findCountBySex(WxCuerBasicInfoDto dto);
long findCountByAge(WxCuerBasicInfoDto dto);
}

+ 12
- 3
mallinkService/src/main/java/com/simple/service/WxCUserBasicInfoService.java Просмотреть файл

@@ -48,10 +48,19 @@ public interface WxCUserBasicInfoService {
*/
void updateScore(WxCUserBasicInfo record);

/**
* 根据性别查询数量
* @param sex
* @return
*/
long findCountBySex(WxCuerBasicInfoDto dto);



/**
* 根据年龄查询数量
* @param dto
* @return
*/
long findCountByAge(WxCuerBasicInfoDto dto);


+ 17
- 6
mallinkService/src/main/java/com/simple/service/impl/WxCUserBasicInfoServiceImpl.java Просмотреть файл

@@ -35,6 +35,7 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService {
wxCUserBasicInfoMapper.updateScore(record);

}


@Override
@@ -58,12 +59,22 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService {
public void deleteById(Long id) {
wxCUserBasicInfoMapper.deleteByPrimaryKey(id);
}



@Override
public long findCountBySex(WxCuerBasicInfoDto dto) {
return wxCUserBasicInfoMapper.findCountBySex(dto);
}



@Override
public long findCountByAge(WxCuerBasicInfoDto dto) {
// TODO Auto-generated method stub
return 0;
}
}

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

@@ -113,7 +113,7 @@
</select>
<select id="list" parameterType="com.simple.domain.po.WxCUserBasicInfo" resultMap="BaseResultMap">
<select id="list" parameterType="com.simple.domain.dto.WxCuerBasicInfoDto" resultMap="BaseResultMap">
select <include refid="allColumns" /> from wx_c_user_basic_info where 1=1
<if test=" null != tenantId ">
and `tenant_id` = #{tenantId}
@@ -141,7 +141,21 @@

</update>

<select id="findCountBySex" parameterType="com.simple.domain.dto.WxCuerBasicInfoDto">
select count(id) from wx_c_user_basic_info where sex =#{sex}
<if test=" null != startTime ">
and create_date &gt;= #{startTime}
</if>
<if test=" null != endTime">
and create_date &lt;= #{endTime}
</if>
</select>
<select id="findCountBySex" parameterType="com.simple.domain.dto.WxCuerBasicInfoDto">
select count(id) from wx_c_user_basic_info where
create_date &gt;= #{startTime}
and create_date &lt;= #{endTime}
</select>
</mapper>

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