| @@ -4,11 +4,14 @@ import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.dto.WxCUserBasicInfoDto; | |||
| import com.iformall.domain.po.WxCUser; | |||
| import com.iformall.domain.po.WxLevelConfig; | |||
| import com.iformall.domain.po.WxUserChannel; | |||
| import com.iformall.domain.vo.UserStructureVo; | |||
| import com.iformall.enums.EnumAgeInfo; | |||
| import com.iformall.enums.EnumCUserBaseInfoSex; | |||
| import com.iformall.service.WxCUserBasicInfoService; | |||
| import com.iformall.service.WxCUserService; | |||
| import com.iformall.service.WxLevelConfigService; | |||
| import com.iformall.service.WxUserChannelService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| @@ -38,27 +41,28 @@ public class WxUserStructureController extends BaseController { | |||
| @Autowired | |||
| private WxCUserService wxCUserService; | |||
| @Autowired | |||
| private WxLevelConfigService wxLevelConfigService; | |||
| @Autowired | |||
| private WxUserChannelService wxUserChannelService; | |||
| /***************************会员结构*****************************/ | |||
| @ApiOperation("查询会员性别结构") | |||
| @GetMapping("/findUserSexStructure") | |||
| public ResultData findUserSexStructure(Date startTime, Date endTime) { | |||
| WxCUserBasicInfoDto dto = new WxCUserBasicInfoDto(); | |||
| dto.setTenantId(getTenantId()); | |||
| dto.setStartTime(startTime); | |||
| // if (endTime != null) { | |||
| // Calendar c = Calendar.getInstance(); | |||
| // c.setTime(endTime); | |||
| // c.add(Calendar.DAY_OF_YEAR, 1); | |||
| // endTime = c.getTime(); | |||
| // } | |||
| dto.setEndTime(endTime); | |||
| //保密 | |||
| dto.setSex(0); | |||
| dto.setSex(EnumCUserBaseInfoSex.UNKNOWN.getCode()); | |||
| long secrecy = wxCUserBasicInfoService.findCountBySex(dto); | |||
| dto.setSex(1); | |||
| dto.setSex(EnumCUserBaseInfoSex.MALE.getCode()); | |||
| long boy = wxCUserBasicInfoService.findCountBySex(dto); | |||
| dto.setSex(2); | |||
| dto.setSex(EnumCUserBaseInfoSex.FEMALE.getCode()); | |||
| long girl = wxCUserBasicInfoService.findCountBySex(dto); | |||
| Long all = secrecy + boy + girl; | |||
| List<UserStructureVo> vos = new ArrayList<>(); | |||
| @@ -74,12 +78,6 @@ public class WxUserStructureController extends BaseController { | |||
| WxCUserBasicInfoDto dto = new WxCUserBasicInfoDto(); | |||
| dto.setTenantId(getTenantId()); | |||
| dto.setStartTime(startTime); | |||
| // if (endTime != null) { | |||
| // Calendar c = Calendar.getInstance(); | |||
| // c.setTime(endTime); | |||
| // c.add(Calendar.DAY_OF_YEAR, 1); | |||
| // endTime = c.getTime(); | |||
| // } | |||
| dto.setEndTime(endTime); | |||
| long all = wxCUserBasicInfoService.findCount(dto); | |||
| List<UserStructureVo> vos = new ArrayList<>(); | |||
| @@ -96,6 +94,47 @@ public class WxUserStructureController extends BaseController { | |||
| return new ResultData(vos); | |||
| } | |||
| @ApiOperation("查询会员积分结构") | |||
| @GetMapping("/findUserLevelStructure") | |||
| public ResultData findUserLevelStructure(Date startTime, Date endTime) { | |||
| WxLevelConfig wxLevelConfig = new WxLevelConfig(); | |||
| wxLevelConfig.setTenantId(getTenantId()); | |||
| wxLevelConfig.setSortColumns(WxLevelConfig.Field.Points_ASC); | |||
| List<WxLevelConfig> levelList = wxLevelConfigService.findList(wxLevelConfig); | |||
| for( int i = 0; i < levelList.size(); i++) { | |||
| WxCUserBasicInfoDto dto = new WxCUserBasicInfoDto(); | |||
| dto.setTenantId(getTenantId()); | |||
| dto.setStartTime(startTime); | |||
| dto.setEndTime(endTime); | |||
| if (i == 0) { | |||
| dto.setLevelEndScore(levelList.get(i).getPoints()); | |||
| } else if (i == levelList.size()-1) { | |||
| dto.setLevelStartScore(levelList.get(i).getPoints()); | |||
| } else{ | |||
| dto.setLevelStartScore(levelList.get(i).getPoints()); | |||
| dto.setLevelEndScore(levelList.get(i+1).getPoints()); | |||
| } | |||
| long all = wxCUserBasicInfoService.findCountByScore(dto); | |||
| //null积分算最低级会员 | |||
| if (i == 0){ | |||
| dto.setLevelStartScore(null); | |||
| dto.setLevelEndScore(null); | |||
| all += wxCUserBasicInfoService.findCountByScore(dto); | |||
| } | |||
| levelList.get(i).setCount(all); | |||
| } | |||
| return new ResultData(levelList); | |||
| } | |||
| /********************************会员数据**************************************/ | |||
| @ApiOperation("查询会员数量") | |||
| @GetMapping("/findUserDataCount") | |||
| public ResultData findUserCount(Date startTime, Date endTime) { | |||
| @@ -39,9 +39,15 @@ public class WxCUserBasicInfoDto implements Serializable{ | |||
| @Transient | |||
| private Date birthStartTime; | |||
| @Transient | |||
| private Date birthEndTime; | |||
| @Transient | |||
| private Integer levelStartScore; | |||
| @Transient | |||
| private Integer levelEndScore; | |||
| @Transient | |||
| private Integer sex; | |||
| @@ -117,5 +123,22 @@ public class WxCUserBasicInfoDto implements Serializable{ | |||
| this.phone = phone; | |||
| } | |||
| public Integer getLevelEndScore() { | |||
| return levelEndScore; | |||
| } | |||
| public void setLevelEndScore(Integer levelEndScore) { | |||
| this.levelEndScore = levelEndScore; | |||
| } | |||
| public Integer getLevelStartScore() { | |||
| return levelStartScore; | |||
| } | |||
| public void setLevelStartScore(Integer levelStartScore) { | |||
| this.levelStartScore = levelStartScore; | |||
| } | |||
| } | |||
| @@ -56,6 +56,12 @@ public class WxLevelConfig implements Serializable { | |||
| /*租户id**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="租户id",name="tenantId") | |||
| private String tenantId; | |||
| @Transient | |||
| protected Long count; | |||
| public Integer getPoints() { | |||
| return points; | |||
| } | |||
| @@ -87,7 +93,13 @@ public class WxLevelConfig implements Serializable { | |||
| tenantId = _tenantId; | |||
| } | |||
| public Long getCount() { | |||
| return count; | |||
| } | |||
| public void setCount(Long count) { | |||
| this.count = count; | |||
| } | |||
| public static enum Field | |||
| { | |||
| @@ -19,6 +19,8 @@ public interface WxCUserBasicInfoMapper extends CommonMapper<WxCUserBasicInfo, S | |||
| long findCountByAge(WxCUserBasicInfoDto dto); | |||
| long findCountByScore(WxCUserBasicInfoDto dto); | |||
| long findCount(WxCUserBasicInfoDto dto); | |||
| } | |||
| @@ -88,7 +88,16 @@ public interface WxCUserBasicInfoService { | |||
| * @param dto | |||
| * @return | |||
| */ | |||
| long findCountByAge(WxCUserBasicInfoDto dto); | |||
| /** | |||
| * 根据年龄积分查寻数量 | |||
| * | |||
| * @param dto | |||
| * @return | |||
| */ | |||
| long findCountByScore(WxCUserBasicInfoDto dto); | |||
| void exportData(HttpServletRequest request, HttpServletResponse response, String tenantId); | |||
| @@ -56,8 +56,14 @@ public interface WxLevelConfigService { | |||
| */ | |||
| String getLevel(String tenantId,int score); | |||
| /** | |||
| * 根据实体查询分页列表 | |||
| * | |||
| * @param record | |||
| * @return | |||
| */ | |||
| List<WxLevelConfig> findList(WxLevelConfig record); | |||
| } | |||
| @@ -140,6 +140,11 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { | |||
| return wxCUserBasicInfoMapper.findCountByAge(dto); | |||
| } | |||
| @Override | |||
| public long findCountByScore(WxCUserBasicInfoDto dto) { | |||
| return wxCUserBasicInfoMapper.findCountByScore(dto); | |||
| } | |||
| @Override | |||
| public void exportData(HttpServletRequest request, HttpServletResponse response, String tenantId) { | |||
| WxCUserBasicInfo basicInfoQ = new WxCUserBasicInfo(); | |||
| @@ -25,6 +25,11 @@ public class WxLevelConfigServiceImpl implements WxLevelConfigService { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxLevelConfigMapper.findList(record)); | |||
| } | |||
| @Override | |||
| public List<WxLevelConfig> findList(WxLevelConfig record){ | |||
| return wxLevelConfigMapper.findList(record); | |||
| } | |||
| @Override | |||
| public List<WxLevelConfig> getByTenantId(String tenantId) { | |||
| WxLevelConfig wxLevelConfig = new WxLevelConfig(); | |||
| @@ -21,7 +21,7 @@ | |||
| <sql id="allColumns"> | |||
| `id`,`phone`,`birthdate`,`education`,`sex`,`email`,`address`,`poins`,`tag_id`, | |||
| `create_date`,`update_date`,`tenant_id`,`name`, level, nick_name | |||
| `create_date`,`update_date`,`tenant_id`,`name`,`level`,`nick_name` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -153,7 +153,34 @@ | |||
| </if> | |||
| </select> | |||
| <select id="findCountByScore" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long"> | |||
| select count(id) from wx_c_user_basic_info where 1=1 | |||
| <if test=" null != startTime "> | |||
| and create_date >= #{startTime} | |||
| </if> | |||
| <if test=" null != endTime"> | |||
| and create_date <= #{endTime} | |||
| </if> | |||
| <if test=" null != levelStartScore "> | |||
| and poins >= #{levelStartScore} | |||
| </if> | |||
| <if test=" null != levelEndScore"> | |||
| and poins <= #{levelEndScore} | |||
| </if> | |||
| <if test=" null == levelStartScore and null == levelEndScore"> | |||
| and poins is null | |||
| </if> | |||
| <if test="null != tenantId"> | |||
| and tenant_id =#{tenantId} | |||
| </if> | |||
| </select> | |||
| <select id="findCount" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long"> | |||
| select count(id) from wx_c_user_basic_info where 1=1 | |||
| <if test=" null != startTime "> | |||