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