| @@ -93,7 +93,7 @@ public class CouponInjectController extends BaseController { | |||
| if (couponInject != null) { | |||
| List<Long> tagids = JSON.parseArray(couponInject.getTags(), Long.class); | |||
| if (!tagids.isEmpty()) { | |||
| couponInject.setWxChooseTagVo(wxCUserTagsService.findChooseTag(getTenantId(), tagids)); | |||
| couponInject.setTagsList(wxCUserTagsService.findTagList(getTenantId(), tagids)); | |||
| } | |||
| couponInject.setMsgModel(wxMsgModelService.getById(couponInject.getModelId())); | |||
| @@ -72,27 +72,7 @@ public class WxCUserBasicInfoController extends BaseController { | |||
| WxCUserTags uTag = wxCUserTagsService.getById(info.getTagId()); | |||
| if (StringUtils.isNotBlank(uTag.getTags())) { | |||
| List<Long> ids = JSONObject.parseArray(uTag.getTags(), Long.class); | |||
| if (!ids.isEmpty()) { | |||
| WxTags wxTags = new WxTags(); | |||
| wxTags.setIds(ids); | |||
| PageInfo<WxTags> page = wxTagsService.listAsPage(wxTags, 1, 256); | |||
| String tagNames = ""; | |||
| String tagIds = ""; | |||
| List<Long> tagIdList = new ArrayList<>(); | |||
| for (WxTags wt : page.getList()) { | |||
| tagNames += wt.getName() + "/"; | |||
| tagIds += wt.getId() + ","; | |||
| tagIdList.add(wt.getId()); | |||
| } | |||
| if (StringUtils.isNotBlank(tagNames)) { | |||
| info.setTagNames(tagNames.substring(0, tagNames.length() - 1)); | |||
| } | |||
| if (StringUtils.isNoneBlank(tagIds)) { | |||
| info.setTagIds(tagIds.substring(0, tagIds.length() - 1)); | |||
| } | |||
| long count = wxCUserTagsService.findCountByTag(getTenantId(), tagIdList); | |||
| info.setCount(count); | |||
| } | |||
| info.setTagsList(wxCUserTagsService.findTagList(getTenantId(),ids)); | |||
| } | |||
| } | |||
| } | |||
| @@ -63,6 +63,7 @@ public class WxTagsController extends BaseController { | |||
| WxTagsTypeVo ttvo = new WxTagsTypeVo(); | |||
| ttvo.setId(tt.getId()); | |||
| ttvo.setName(tt.getName()); | |||
| ttvo.setFlag(tt.getFlag()); | |||
| ttvo.setGroupId(tg.getId()); | |||
| ttvo.setGroupName(tg.getName()); | |||
| @@ -76,52 +77,17 @@ public class WxTagsController extends BaseController { | |||
| } | |||
| return new ResultData(groupVos); | |||
| } | |||
| @GetMapping("getPeopleTagList") | |||
| @ApiOperation("用户人群tag接口") | |||
| public ResultData getPeopleTagList() { | |||
| List<WxTagsGroupVo> groupVos = new ArrayList<>(); | |||
| List<WxTagsGroup> groups = wxTagsGroupService.findList(null); | |||
| for(WxTagsGroup tg:groups) { | |||
| WxTagsGroupVo tgvo =new WxTagsGroupVo(); | |||
| tgvo.setId(tg.getId()); | |||
| tgvo.setName(tg.getName()); | |||
| WxTagsType type = new WxTagsType(); | |||
| type.setGroupId(tg.getId()); | |||
| List<WxTagsTypeVo> typeVos =new ArrayList<>(); | |||
| List<WxTagsType> types = wxTagsTypeService.findList(type); | |||
| for(WxTagsType tt:types) { | |||
| WxTagsTypeVo ttvo = new WxTagsTypeVo(); | |||
| ttvo.setId(tt.getId()); | |||
| ttvo.setName(tt.getName()); | |||
| ttvo.setGroupId(tg.getId()); | |||
| ttvo.setGroupName(tg.getName()); | |||
| WxTags t = new WxTags(); | |||
| t.setTypeId(tt.getId()); | |||
| ttvo.setTags(wxTagsService.findList(t)); | |||
| typeVos.add(ttvo); | |||
| } | |||
| tgvo.setTypes(typeVos); | |||
| groupVos.add(tgvo); | |||
| } | |||
| return new ResultData(groupVos); | |||
| } | |||
| @ApiOperation("查询微信用户人群") | |||
| @GetMapping("findCUserCountByTag") | |||
| public Result findCUserCountByTag(Long[] tagIds) { | |||
| long count = wxCUserTagsService.findCUserCountByTag(getTenantId(), Arrays.asList(tagIds)); | |||
| return new ResultData(Result.SUCCESS,"查询成功",count); | |||
| return new ResultData(wxCUserTagsService.findTagListFromCUser(getTenantId(), Arrays.asList(tagIds))); | |||
| } | |||
| @ApiOperation("查询会员用户人群") | |||
| @GetMapping("findCountByTag") | |||
| public Result findCountByTag(Long[] tagIds) { | |||
| long count = wxCUserTagsService.findCountByTag(getTenantId(), Arrays.asList(tagIds)); | |||
| return new ResultData(Result.SUCCESS,"查询成功",count); | |||
| return new ResultData(wxCUserTagsService.findTagList(getTenantId(), Arrays.asList(tagIds))); | |||
| } | |||
| @@ -1,7 +1,5 @@ | |||
| package com.iformall.domain.po; | |||
| import com.iformall.domain.vo.WxChooseTagVo; | |||
| import javax.persistence.Id; | |||
| import javax.persistence.Table; | |||
| import javax.persistence.Transient; | |||
| @@ -20,8 +18,6 @@ public class CouponInject implements Serializable { | |||
| protected List<Long> ids; | |||
| @Transient | |||
| protected String sortColumns; | |||
| @Transient | |||
| protected WxChooseTagVo wxChooseTagVo; | |||
| public WxMsgModel getMsgModel() { | |||
| return msgModel; | |||
| @@ -191,13 +187,7 @@ public class CouponInject implements Serializable { | |||
| public void setUpdateTime(Date _updateTime) { | |||
| updateTime = _updateTime; | |||
| } | |||
| public WxChooseTagVo getWxChooseTagVo() { | |||
| return wxChooseTagVo; | |||
| } | |||
| public void setWxChooseTagVo(WxChooseTagVo wxChooseTagVo) { | |||
| this.wxChooseTagVo = wxChooseTagVo; | |||
| } | |||
| public Date getSendTimeStart() { | |||
| return sendTimeStart; | |||
| } | |||
| @@ -230,6 +220,17 @@ public class CouponInject implements Serializable { | |||
| this.msgId = msgId; | |||
| } | |||
| List<WxTags> tagsList; | |||
| public List<WxTags> getTagsList() { | |||
| return tagsList; | |||
| } | |||
| public void setTagsList(List<WxTags> tagsList) { | |||
| this.tagsList = tagsList; | |||
| } | |||
| public static enum Field | |||
| { | |||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||
| @@ -109,8 +109,10 @@ public class WxCUserBasicInfo implements Serializable { | |||
| @Transient | |||
| @Excel(name="标签",width = 20,orderNum = "10") | |||
| private String tagNames; | |||
| @Transient | |||
| private long count; | |||
| private List<WxTags> tagsList; | |||
| @Transient | |||
| private Date startTime; | |||
| @Transient | |||
| @@ -136,14 +138,6 @@ public class WxCUserBasicInfo implements Serializable { | |||
| this.nickName = nickName; | |||
| } | |||
| public long getCount() { | |||
| return count; | |||
| } | |||
| public void setCount(long count) { | |||
| this.count = count; | |||
| } | |||
| public String getTagNames() { | |||
| return tagNames; | |||
| } | |||
| @@ -152,7 +146,6 @@ public class WxCUserBasicInfo implements Serializable { | |||
| this.tagNames = tagNames; | |||
| } | |||
| public String getTagIds() { | |||
| return tagIds; | |||
| } | |||
| @@ -270,6 +263,14 @@ public class WxCUserBasicInfo implements Serializable { | |||
| addressStr = _addressStr; | |||
| } | |||
| public List<WxTags> getTagsList() { | |||
| return tagsList; | |||
| } | |||
| public void setTagsList(List<WxTags> tagsList) { | |||
| this.tagsList = tagsList; | |||
| } | |||
| public static enum Field | |||
| { | |||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||
| @@ -52,6 +52,16 @@ public class WxTags implements Serializable { | |||
| @io.swagger.annotations.ApiModelProperty(value="二级属性 性别等",name="typeName") | |||
| private String typeName; | |||
| @Transient | |||
| protected long count; | |||
| public long getCount() { | |||
| return count; | |||
| } | |||
| public void setCount(long count) { | |||
| this.count = count; | |||
| } | |||
| public String getName() { | |||
| return name; | |||
| } | |||
| @@ -1,30 +0,0 @@ | |||
| package com.iformall.domain.vo; | |||
| import java.io.Serializable; | |||
| public class WxChooseTagVo implements Serializable{ | |||
| /** | |||
| * | |||
| */ | |||
| private static final long serialVersionUID = -2193506530627907289L; | |||
| //tagname | |||
| private String names; | |||
| //用户数 | |||
| private Long userCount; | |||
| public String getNames() { | |||
| return names; | |||
| } | |||
| public void setNames(String names) { | |||
| this.names = names; | |||
| } | |||
| public Long getUserCount() { | |||
| return userCount; | |||
| } | |||
| public void setUserCount(Long userCount) { | |||
| this.userCount = userCount; | |||
| } | |||
| } | |||
| @@ -7,7 +7,6 @@ import com.iformall.domain.po.WxCUser; | |||
| import com.iformall.domain.po.WxCUserBasicInfo; | |||
| import com.iformall.domain.po.WxCUserTags; | |||
| import com.iformall.domain.po.WxTags; | |||
| import com.iformall.domain.vo.WxChooseTagVo; | |||
| import com.iformall.enums.EnumAssignTagsTrigger; | |||
| public interface WxCUserTagsService { | |||
| @@ -44,12 +43,6 @@ public interface WxCUserTagsService { | |||
| */ | |||
| void deleteById(Long id); | |||
| /** | |||
| * tagIds查询 用户数量(会员列表中的user) | |||
| * @param tagIds | |||
| * @return | |||
| */ | |||
| long findCountByTag(String tenantId, List<Long> tagIds); | |||
| /** | |||
| * | |||
| @@ -59,14 +52,6 @@ public interface WxCUserTagsService { | |||
| */ | |||
| List<WxCUserBasicInfo> findByTag(String tenantId, List<Long> tagIds); | |||
| /** | |||
| * tagIds查询 用户数量(登陆过C端的用户,并且保有手机号) | |||
| * @param tagIds | |||
| * @return | |||
| */ | |||
| long findCUserCountByTag(String tenantId, List<Long> tagIds); | |||
| /** | |||
| * | |||
| * tagIds查询用户user信息集合(登陆过C端的用户,并且保有手机号) | |||
| @@ -74,15 +59,12 @@ public interface WxCUserTagsService { | |||
| * @return | |||
| */ | |||
| List<WxCUser> findCUserByTag(String tenantId, List<Long> tagIds); | |||
| /** | |||
| * 获取用户数量和tags name(登陆过C端的用户,并且保有手机号) | |||
| * @param tagIds | |||
| * @return | |||
| */ | |||
| WxChooseTagVo findChooseTag(String tenantId, List<Long> tagIds); | |||
| List<WxTags> findTagList(String tenantId, List<Long> tagIds); | |||
| List<WxTags> findTagListFromCUser(String tenantId, List<Long> tagIds); | |||
| List<WxTags> assignTags(List<Long> tagIdList, WxCUserBasicInfo user); | |||
| List<WxTags> triggerAssignTags(EnumAssignTagsTrigger trigger, Object obj); | |||
| @@ -22,7 +22,6 @@ import org.springframework.stereotype.Service; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.domain.vo.WxChooseTagVo; | |||
| import com.iformall.service.WxCUserTagsService; | |||
| @Service | |||
| @@ -81,26 +80,29 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService { | |||
| wxCUserTagsMapper.deleteByPrimaryKey(id); | |||
| } | |||
| @Override | |||
| public long findCountByTag(String tenantId, List<Long> tagIds) { | |||
| String str = JSON.toJSONString(tagIds); | |||
| private long findCountByTag(String tenantId, Long tagId) { | |||
| String str = JSON.toJSONString(tagId); | |||
| return wxCUserTagsMapper.findCountByTags(str,tenantId); | |||
| } | |||
| @Override | |||
| public long findCUserCountByTag(String tenantId, List<Long> tagIds) { | |||
| String str = JSON.toJSONString(tagIds); | |||
| private long findCUserCountByTag(String tenantId, Long tagId) { | |||
| String str = JSON.toJSONString(tagId); | |||
| return wxCUserTagsMapper.findCUserCountByTags(str,tenantId); | |||
| } | |||
| @Override | |||
| public List<WxCUser> findCUserByTag(String tenantId, List<Long> tagIds) { | |||
| String str = JSON.toJSONString(tagIds); | |||
| List<Long> userIds = wxCUserTagsMapper.findCUserByTags(str,tenantId); | |||
| if(userIds.size()==0) { | |||
| return new ArrayList<>(); | |||
| } | |||
| if (tagIds == null || tagIds.isEmpty()) | |||
| return new ArrayList<WxCUser>(); | |||
| Set<Long> hs = new HashSet<>(); | |||
| for (Long tagId:tagIds) { | |||
| String str = JSON.toJSONString(tagId); | |||
| hs.addAll(wxCUserTagsMapper.findCUserByTags(str, tenantId)); | |||
| } | |||
| List<Long> userIds = new ArrayList<>(); | |||
| userIds.addAll(hs); | |||
| WxCUser wxCUser = new WxCUser(); | |||
| wxCUser.setIds(userIds); | |||
| return wxCUserMapper.findList(wxCUser); | |||
| @@ -108,12 +110,16 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService { | |||
| @Override | |||
| public List<WxCUserBasicInfo> findByTag(String tenantId, List<Long> tagIds) { | |||
| String str = JSON.toJSONString(tagIds); | |||
| List<Long> userIds = wxCUserTagsMapper.findByTags(str,tenantId); | |||
| if(userIds.size()==0) { | |||
| return new ArrayList<>(); | |||
| } | |||
| if (tagIds == null || tagIds.isEmpty()) | |||
| return new ArrayList<WxCUserBasicInfo>(); | |||
| Set<Long> hs = new HashSet<>(); | |||
| for (Long tagId:tagIds) { | |||
| String str = JSON.toJSONString(tagId); | |||
| hs.addAll(wxCUserTagsMapper.findByTags(str, tenantId)); | |||
| } | |||
| List<Long> userIds = new ArrayList<>(); | |||
| userIds.addAll(hs); | |||
| WxCUserBasicInfo wxCUserBasicInfo = new WxCUserBasicInfo(); | |||
| wxCUserBasicInfo.setIds(userIds); | |||
| return wxCUserBasicInfoMapper.findList(wxCUserBasicInfo); | |||
| @@ -121,22 +127,29 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService { | |||
| @Override | |||
| public WxChooseTagVo findChooseTag(String tenantId, List<Long> tagIds) { | |||
| public List<WxTags> findTagList(String tenantId, List<Long> tagIds) { | |||
| if (tagIds == null || tagIds.isEmpty()) | |||
| return new ArrayList<WxTags>(); | |||
| WxTags wxTags =new WxTags(); | |||
| wxTags.setIds(tagIds); | |||
| List<WxTags> list = wxTagsMapper.findList(wxTags); | |||
| StringBuffer names= new StringBuffer(); | |||
| for(WxTags t:list) { | |||
| names.append(t.getName()+"/"); | |||
| } | |||
| String endName=""; | |||
| if(names.length()>0) { | |||
| endName = names.toString().substring(0,names.length()-1); | |||
| } | |||
| WxChooseTagVo vo =new WxChooseTagVo(); | |||
| vo.setNames(endName); | |||
| vo.setUserCount(findCUserCountByTag(tenantId,tagIds)); | |||
| return vo; | |||
| for (WxTags t : list) { | |||
| t.setCount(findCountByTag(tenantId,t.getId())); | |||
| } | |||
| return list; | |||
| } | |||
| @Override | |||
| public List<WxTags> findTagListFromCUser(String tenantId, List<Long> tagIds) { | |||
| if (tagIds == null || tagIds.isEmpty()) | |||
| return new ArrayList<WxTags>(); | |||
| WxTags wxTags =new WxTags(); | |||
| wxTags.setIds(tagIds); | |||
| List<WxTags> list = wxTagsMapper.findList(wxTags); | |||
| for (WxTags t : list) { | |||
| t.setCount(findCUserCountByTag(tenantId,t.getId())); | |||
| } | |||
| return list; | |||
| } | |||
| //**************************************************自动打标逻辑代码 ************************************************************* | |||
| @@ -70,23 +70,23 @@ | |||
| </select> | |||
| <select id="findCUserCountByTags" resultType="java.lang.Long"> | |||
| select count(user_id) from wx_c_user_tags cut, wx_c_user cu | |||
| where cut.user_id = cu.id | |||
| and JSON_CONTAINS(tags,#{tagIds} ) | |||
| and cut.tenant_id = #{tenantId}; | |||
| select count(user_id) from wx_c_user_tags cut, wx_c_user cu | |||
| where cut.user_id = cu.id | |||
| and JSON_CONTAINS(tags,#{tagIds} ) | |||
| and cut.tenant_id = #{tenantId}; | |||
| </select> | |||
| <select id="findByTags" resultType="java.lang.Long"> | |||
| select user_id from wx_c_user_tags cut | |||
| where JSON_CONTAINS(tags,#{tagIds} ) | |||
| and cut.tenant_id = #{tenantId}; | |||
| select user_id from wx_c_user_tags cut | |||
| where JSON_CONTAINS(tags,#{tagIds} ) | |||
| and cut.tenant_id = #{tenantId}; | |||
| </select> | |||
| <select id="findCUserByTags" resultType="java.lang.Long"> | |||
| select user_id from wx_c_user_tags cut, wx_c_user cu | |||
| where cut.user_id = cu.id | |||
| and JSON_CONTAINS(tags,#{tagIds} ) | |||
| and cut.tenant_id = #{tenantId}; | |||
| select user_id from wx_c_user_tags cut, wx_c_user cu | |||
| where cut.user_id = cu.id | |||
| and JSON_CONTAINS(tags,#{tagIds} ) | |||
| and cut.tenant_id = #{tenantId}; | |||
| </select> | |||
| <update id="updateNewId" parameterType="com.iformall.domain.vo.CUserTagVo"> | |||