| @@ -8,6 +8,7 @@ import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.dto.WxCUserBasicInfoFilterDto; | |||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.enums.EnumAssignTagsTrigger; | import com.iformall.enums.EnumAssignTagsTrigger; | ||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| @@ -474,4 +475,21 @@ public class WxCUserBasicInfoController extends BaseController { | |||||
| logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::listFilter"); | logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::listFilter"); | ||||
| return new ResultData(wxCUserBasicInfoService.listFilters(getTenantId())); | return new ResultData(wxCUserBasicInfoService.listFilters(getTenantId())); | ||||
| } | } | ||||
| @ApiOperation("获取会员过滤器") | |||||
| @PostMapping("/countByFilter") | |||||
| public ResultData countByFilter(@RequestBody List<WxCUserBasicInfoFilterDto> filterList) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::listFilter"); | |||||
| return new ResultData(wxCUserBasicInfoService.countByFilter(getTenantId(),filterList)); | |||||
| } | |||||
| @ApiOperation("获取会员过滤器") | |||||
| @PostMapping("/listByFilter") | |||||
| public ResultData listByFilter(@RequestBody List<WxCUserBasicInfoFilterDto> filterList) { | |||||
| logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::listFilter"); | |||||
| return new ResultData(wxCUserBasicInfoService.listByFilter(getTenantId(),filterList)); | |||||
| } | |||||
| } | } | ||||
| @@ -56,6 +56,9 @@ public class WxCUserBasicInfoDto implements Serializable{ | |||||
| @Transient | @Transient | ||||
| List<Long> tagIds; | List<Long> tagIds; | ||||
| @Transient | |||||
| protected String sortColumns; | |||||
| public Long getId() { | public Long getId() { | ||||
| return id; | return id; | ||||
| } | } | ||||
| @@ -153,4 +156,12 @@ public class WxCUserBasicInfoDto implements Serializable{ | |||||
| public void setTagIds(List<Long> tagIds) { | public void setTagIds(List<Long> tagIds) { | ||||
| this.tagIds = tagIds; | this.tagIds = tagIds; | ||||
| } | } | ||||
| public String getSortColumns() { | |||||
| return sortColumns; | |||||
| } | |||||
| public void setSortColumns(String sortColumns) { | |||||
| this.sortColumns = sortColumns; | |||||
| } | |||||
| } | } | ||||
| @@ -186,6 +186,11 @@ public enum EnumTag { | |||||
| ID_1004(1004L, EnumTagType.ID_50,"一年以内"), | ID_1004(1004L, EnumTagType.ID_50,"一年以内"), | ||||
| ID_1005(1005L, EnumTagType.ID_50,"五年以内"), | ID_1005(1005L, EnumTagType.ID_50,"五年以内"), | ||||
| ID_1006(1006L, EnumTagType.ID_50,"五年以上"), | ID_1006(1006L, EnumTagType.ID_50,"五年以上"), | ||||
| ID_1007(1007L, EnumTagType.ID_50,"一年以上"), | |||||
| ID_1008(1008L, EnumTagType.ID_50,"一季度以上"), | |||||
| ID_1009(1009L, EnumTagType.ID_50,"一月以上"), | |||||
| ID_1010(1010L, EnumTagType.ID_50,"一周以上"), | |||||
| ID_1011(1011L, EnumTagType.ID_50,"一天以上"), | |||||
| ; | ; | ||||
| @@ -2,6 +2,7 @@ package com.iformall.service; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.domain.dto.WxCUserBasicInfoDto; | import com.iformall.domain.dto.WxCUserBasicInfoDto; | ||||
| import com.iformall.domain.dto.WxCUserBasicInfoFilterDto; | |||||
| import com.iformall.domain.po.MallUserInfo; | import com.iformall.domain.po.MallUserInfo; | ||||
| import com.iformall.domain.po.WxCUserBasicInfo; | import com.iformall.domain.po.WxCUserBasicInfo; | ||||
| import com.iformall.domain.po.WxCarPayRecord; | import com.iformall.domain.po.WxCarPayRecord; | ||||
| @@ -20,8 +21,9 @@ public interface WxCUserBasicInfoService { | |||||
| * @return | * @return | ||||
| */ | */ | ||||
| List<WxTagsGroupVo> listFilters(String tenentId); | |||||
| List<WxTagsGroupVo> listFilters(String tenantId); | |||||
| long countByFilter(String tenantId, List<WxCUserBasicInfoFilterDto> filterList); | |||||
| List<WxCUserBasicInfo> listByFilter(String tenantId, List<WxCUserBasicInfoFilterDto> filterList); | |||||
| /** | /** | ||||
| * 根据实体查询分页列表 | * 根据实体查询分页列表 | ||||
| * | * | ||||
| @@ -103,6 +103,26 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { | |||||
| new WxTags(){{ | new WxTags(){{ | ||||
| setName(EnumTag.ID_1006.getMessage()); | setName(EnumTag.ID_1006.getMessage()); | ||||
| setId(EnumTag.ID_1006.getCode()); | setId(EnumTag.ID_1006.getCode()); | ||||
| }}, | |||||
| new WxTags(){{ | |||||
| setName(EnumTag.ID_1007.getMessage()); | |||||
| setId(EnumTag.ID_1007.getCode()); | |||||
| }}, | |||||
| new WxTags(){{ | |||||
| setName(EnumTag.ID_1008.getMessage()); | |||||
| setId(EnumTag.ID_1008.getCode()); | |||||
| }}, | |||||
| new WxTags(){{ | |||||
| setName(EnumTag.ID_1009.getMessage()); | |||||
| setId(EnumTag.ID_1009.getCode()); | |||||
| }}, | |||||
| new WxTags(){{ | |||||
| setName(EnumTag.ID_1010.getMessage()); | |||||
| setId(EnumTag.ID_1010.getCode()); | |||||
| }}, | |||||
| new WxTags(){{ | |||||
| setName(EnumTag.ID_1011.getMessage()); | |||||
| setId(EnumTag.ID_1011.getCode()); | |||||
| }} | }} | ||||
| ) | ) | ||||
| ); | ); | ||||
| @@ -120,80 +140,110 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { | |||||
| }}); | }}); | ||||
| put(EnumTag.ID_1001.getCode(), | put(EnumTag.ID_1001.getCode(), | ||||
| new HashMap<String,Long>(){{ | new HashMap<String,Long>(){{ | ||||
| put(RANGE_START,1L); | |||||
| put(RANGE_START,0L); | |||||
| put(RANGE_END,7L); | put(RANGE_END,7L); | ||||
| }}); | }}); | ||||
| put(EnumTag.ID_1002.getCode(), | put(EnumTag.ID_1002.getCode(), | ||||
| new HashMap<String,Long>(){{ | new HashMap<String,Long>(){{ | ||||
| put(RANGE_START,7L); | |||||
| put(RANGE_START,0L); | |||||
| put(RANGE_END,30L); | put(RANGE_END,30L); | ||||
| }}); | }}); | ||||
| put(EnumTag.ID_1003.getCode(), | put(EnumTag.ID_1003.getCode(), | ||||
| new HashMap<String,Long>(){{ | new HashMap<String,Long>(){{ | ||||
| put(RANGE_START,30L); | |||||
| put(RANGE_START,0L); | |||||
| put(RANGE_END,90L); | put(RANGE_END,90L); | ||||
| }}); | }}); | ||||
| put(EnumTag.ID_1004.getCode(), | put(EnumTag.ID_1004.getCode(), | ||||
| new HashMap<String,Long>(){{ | new HashMap<String,Long>(){{ | ||||
| put(RANGE_START,90L); | |||||
| put(RANGE_START,0L); | |||||
| put(RANGE_END,365L); | put(RANGE_END,365L); | ||||
| }}); | }}); | ||||
| put(EnumTag.ID_1005.getCode(), | put(EnumTag.ID_1005.getCode(), | ||||
| new HashMap<String,Long>(){{ | new HashMap<String,Long>(){{ | ||||
| put(RANGE_START,365L); | |||||
| put(RANGE_START,0L); | |||||
| put(RANGE_END,365*5L); | put(RANGE_END,365*5L); | ||||
| }}); | }}); | ||||
| put(EnumTag.ID_1006.getCode(), | put(EnumTag.ID_1006.getCode(), | ||||
| new HashMap<String,Long>(){{ | new HashMap<String,Long>(){{ | ||||
| put(RANGE_START,365*5L); | put(RANGE_START,365*5L); | ||||
| }}); | }}); | ||||
| put(EnumTag.ID_1007.getCode(), | |||||
| new HashMap<String,Long>(){{ | |||||
| put(RANGE_START,365L); | |||||
| }}); | |||||
| put(EnumTag.ID_1008.getCode(), | |||||
| new HashMap<String,Long>(){{ | |||||
| put(RANGE_START,90L); | |||||
| }}); | |||||
| put(EnumTag.ID_1009.getCode(), | |||||
| new HashMap<String,Long>(){{ | |||||
| put(RANGE_START,30L); | |||||
| }}); | |||||
| put(EnumTag.ID_1010.getCode(), | |||||
| new HashMap<String,Long>(){{ | |||||
| put(RANGE_START,7L); | |||||
| }}); | |||||
| put(EnumTag.ID_1011.getCode(), | |||||
| new HashMap<String,Long>(){{ | |||||
| put(RANGE_START,1L); | |||||
| }}); | |||||
| } | } | ||||
| }; | }; | ||||
| private WxCUserBasicInfoDto filtersToDto(String tenentId, List<WxCUserBasicInfoFilterDto> filterList){ | |||||
| private WxCUserBasicInfoDto filtersToDto(String tenantId, List<WxCUserBasicInfoFilterDto> filterList){ | |||||
| WxCUserBasicInfoDto dto = new WxCUserBasicInfoDto(); | WxCUserBasicInfoDto dto = new WxCUserBasicInfoDto(); | ||||
| dto.setTagIds(new ArrayList<>()); | |||||
| List<WxLevelConfig> levels = wxLevelConfigService.getByTenantId(tenentId); | |||||
| filterList.stream().forEach(f->{ | |||||
| List<Long> tagIdList = new ArrayList<>(); | |||||
| switch(EnumTagType.getEnum(f.getTypeId())) { | |||||
| case ID_50: | |||||
| ZoneId zone = ZoneId.systemDefault(); | |||||
| Long rangeStart = memberTimeMap.get(f.getId()).get(RANGE_START); | |||||
| Long rangeEnd = memberTimeMap.get(f.getId()).get(RANGE_END); | |||||
| List<WxLevelConfig> levels = wxLevelConfigService.getByTenantId(tenantId); | |||||
| filterList.stream().forEach(f->{ | |||||
| if (f.getTypeId()==null) { | |||||
| tagIdList.add(f.getId()); | |||||
| return; | |||||
| } | |||||
| if(f.getTypeId().equals(EnumTagType.ID_50.getCode())) { | |||||
| ZoneId zone = ZoneId.systemDefault(); | |||||
| if (rangeEnd != null){ | |||||
| Map<String,Long> rangeMap = memberTimeMap.get(f.getId()); | |||||
| if (rangeMap != null) { | |||||
| Long rangeEnd = rangeMap.get(RANGE_END); | |||||
| if (rangeEnd != null) { | |||||
| LocalDateTime localDateTimeStart = LocalDateTime.now().minusDays(rangeEnd); | LocalDateTime localDateTimeStart = LocalDateTime.now().minusDays(rangeEnd); | ||||
| dto.setStartTime(Date.from(localDateTimeStart.atZone(zone).toInstant())); | dto.setStartTime(Date.from(localDateTimeStart.atZone(zone).toInstant())); | ||||
| } | } | ||||
| Long rangeStart = rangeMap.get(RANGE_START); | |||||
| if (rangeStart != null) { | if (rangeStart != null) { | ||||
| LocalDateTime localDateTimeEnd = LocalDateTime.now().minusDays(rangeStart); | LocalDateTime localDateTimeEnd = LocalDateTime.now().minusDays(rangeStart); | ||||
| dto.setEndTime(Date.from(localDateTimeEnd.atZone(zone).toInstant())); | dto.setEndTime(Date.from(localDateTimeEnd.atZone(zone).toInstant())); | ||||
| } | } | ||||
| break; | |||||
| case ID_51: | |||||
| for (int i=0;i<levels.size();i++) | |||||
| { | |||||
| } | |||||
| } else if (f.getTypeId().equals(EnumTagType.ID_51.getCode())) { | |||||
| if (f.getId().equals(0L)) { | |||||
| dto.setLevelStartScore(0); | |||||
| if (levels.isEmpty()) | |||||
| dto.setLevelEndScore(null); | |||||
| else | |||||
| dto.setLevelEndScore(levels.get(0).getPoints()); | |||||
| } else { | |||||
| for (int i = 0; i < levels.size(); i++) { | |||||
| WxLevelConfig l = levels.get(i); | WxLevelConfig l = levels.get(i); | ||||
| if (f.getId().equals(0L)) | |||||
| dto.setLevelStartScore(0); | |||||
| else | |||||
| if (l.getId().equals(f.getId())) { | |||||
| dto.setLevelStartScore(l.getPoints()); | dto.setLevelStartScore(l.getPoints()); | ||||
| if (i + 1<levels.size()) | |||||
| dto.setLevelEndScore(levels.get(i+1).getPoints()); | |||||
| else | |||||
| dto.setLevelEndScore(null); | |||||
| if (i + 1 < levels.size()) | |||||
| dto.setLevelEndScore(levels.get(i + 1).getPoints()); | |||||
| else | |||||
| dto.setLevelEndScore(null); | |||||
| break; | |||||
| } | |||||
| } | } | ||||
| break; | |||||
| default: | |||||
| dto.getTagIds().add(f.getId()); | |||||
| } | |||||
| } else { | |||||
| tagIdList.add(f.getId()); | |||||
| } | } | ||||
| }); | }); | ||||
| if(!tagIdList.isEmpty()) | |||||
| dto.setTagIds(tagIdList); | |||||
| dto.setTenantId(tenantId); | |||||
| return dto; | return dto; | ||||
| } | } | ||||
| @@ -338,53 +338,59 @@ | |||||
| </select> | </select> | ||||
| <sql id="msgColumns"> | |||||
| cu.`id`,cu.`phone`,cu.`email` | |||||
| </sql> | |||||
| <sql id="filterWhereConditions"> | <sql id="filterWhereConditions"> | ||||
| where 1=1 | where 1=1 | ||||
| <if test="null != tenantId"> | <if test="null != tenantId"> | ||||
| and tenant_id =#{tenantId} | |||||
| and cu.tenant_id =#{tenantId} | |||||
| </if> | </if> | ||||
| <if test=" null != startTime "> | <if test=" null != startTime "> | ||||
| and create_date >= #{startTime} | |||||
| and cu.create_date >= #{startTime} | |||||
| </if> | </if> | ||||
| <if test=" null != endTime"> | <if test=" null != endTime"> | ||||
| and create_date <= #{endTime} | |||||
| and cu.create_date <= #{endTime} | |||||
| </if> | </if> | ||||
| <if test=" null != levelStartScore and (0 != levelStartScore and '' != levelStartScore"> | |||||
| and poins >= #{levelStartScore} | |||||
| <if test=" null != levelStartScore and (0 != levelStartScore and '' != levelStartScore)"> | |||||
| and cu.poins >= #{levelStartScore} | |||||
| <if test=" null != levelEndScore"> | <if test=" null != levelEndScore"> | ||||
| and poins < #{levelEndScore} | |||||
| and cu.poins < #{levelEndScore} | |||||
| </if> | </if> | ||||
| </if> | </if> | ||||
| <if test=" null != levelStartScore and (0 == levelStartScore or '' == levelStartScore"> | |||||
| and (poins is null or | |||||
| (poins >= #{levelStartScore} | |||||
| <if test=" null != levelStartScore and (0 == levelStartScore or '' == levelStartScore)"> | |||||
| and (cu.poins is null or | |||||
| (cu.poins >= #{levelStartScore} | |||||
| <if test=" null != levelEndScore"> | <if test=" null != levelEndScore"> | ||||
| and poins < #{levelEndScore} | |||||
| and cu.poins < #{levelEndScore} | |||||
| </if> | </if> | ||||
| )) | )) | ||||
| </if> | </if> | ||||
| <if test=" null != ids "> | |||||
| <if test=" null != tagIds "> | |||||
| and JSON_CONTAINS(JSON_ARRAY(cut.tags),JSON_ARRAY | |||||
| <foreach collection="tagIds" index="index" item="idItem" open="(" separator="," close=")"> | <foreach collection="tagIds" index="index" item="idItem" open="(" separator="," close=")"> | ||||
| and #{idItem} in cut.tags | |||||
| #{idItem} | |||||
| </foreach> | </foreach> | ||||
| ) | |||||
| </if> | </if> | ||||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | <if test=" null != sortColumns">order by ${sortColumns}</if> | ||||
| </sql> | </sql> | ||||
| <select id="findCountByFilter" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long"> | <select id="findCountByFilter" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long"> | ||||
| select count(id) from wx_c_user_basic_info | |||||
| select count(*) from wx_c_user_basic_info cu | |||||
| join wx_c_user_tags cut on cut.`id` = cu.`tag_id` | join wx_c_user_tags cut on cut.`id` = cu.`tag_id` | ||||
| <include refid="filterWhereConditions"/> | <include refid="filterWhereConditions"/> | ||||
| </select> | </select> | ||||
| <select id="findListByFilter" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultMap="BaseResultMap"> | <select id="findListByFilter" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultMap="BaseResultMap"> | ||||
| select <include refid="allColumns"/> | |||||
| from wx_c_user_basic_info | |||||
| select <include refid="msgColumns"/> | |||||
| from wx_c_user_basic_info cu | |||||
| join wx_c_user_tags cut on cut.`id` = cu.`tag_id` | join wx_c_user_tags cut on cut.`id` = cu.`tag_id` | ||||
| <include refid="filterWhereConditions"/> | <include refid="filterWhereConditions"/> | ||||
| </select> | </select> | ||||
| @@ -61,13 +61,6 @@ | |||||
| <include refid="dynamicWhereConditions"/> | <include refid="dynamicWhereConditions"/> | ||||
| </select> | </select> | ||||
| <select id="getByName" parameterType="String" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns"/> | |||||
| from wx_tags where 1=1 | |||||
| <if test="_parameter!= null and _parameter!= ''"> | |||||
| and `name` = #{name} | |||||
| </if> | |||||
| </select> | |||||
| <select id="findListAll" resultMap="BaseResultMap"> | <select id="findListAll" resultMap="BaseResultMap"> | ||||
| select | select | ||||
| <include refid="allColumnsVo"/> | <include refid="allColumnsVo"/> | ||||