| @@ -93,7 +93,7 @@ public class CouponInjectController extends BaseController { | |||||
| if (couponInject != null) { | if (couponInject != null) { | ||||
| List<Long> tagids = JSON.parseArray(couponInject.getTags(), Long.class); | List<Long> tagids = JSON.parseArray(couponInject.getTags(), Long.class); | ||||
| if (!tagids.isEmpty()) { | if (!tagids.isEmpty()) { | ||||
| couponInject.setWxChooseTagVo(wxCUserTagsService.findChooseTag(getTenantId(), tagids)); | |||||
| couponInject.setTagsList(wxCUserTagsService.findTagList(getTenantId(), tagids)); | |||||
| } | } | ||||
| couponInject.setMsgModel(wxMsgModelService.getById(couponInject.getModelId())); | couponInject.setMsgModel(wxMsgModelService.getById(couponInject.getModelId())); | ||||
| @@ -72,27 +72,7 @@ public class WxCUserBasicInfoController extends BaseController { | |||||
| WxCUserTags uTag = wxCUserTagsService.getById(info.getTagId()); | WxCUserTags uTag = wxCUserTagsService.getById(info.getTagId()); | ||||
| if (StringUtils.isNotBlank(uTag.getTags())) { | if (StringUtils.isNotBlank(uTag.getTags())) { | ||||
| List<Long> ids = JSONObject.parseArray(uTag.getTags(), Long.class); | 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(); | WxTagsTypeVo ttvo = new WxTagsTypeVo(); | ||||
| ttvo.setId(tt.getId()); | ttvo.setId(tt.getId()); | ||||
| ttvo.setName(tt.getName()); | ttvo.setName(tt.getName()); | ||||
| ttvo.setFlag(tt.getFlag()); | |||||
| ttvo.setGroupId(tg.getId()); | ttvo.setGroupId(tg.getId()); | ||||
| ttvo.setGroupName(tg.getName()); | ttvo.setGroupName(tg.getName()); | ||||
| @@ -76,52 +77,17 @@ public class WxTagsController extends BaseController { | |||||
| } | } | ||||
| return new ResultData(groupVos); | 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("查询微信用户人群") | @ApiOperation("查询微信用户人群") | ||||
| @GetMapping("findCUserCountByTag") | @GetMapping("findCUserCountByTag") | ||||
| public Result findCUserCountByTag(Long[] tagIds) { | 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("查询会员用户人群") | @ApiOperation("查询会员用户人群") | ||||
| @GetMapping("findCountByTag") | @GetMapping("findCountByTag") | ||||
| public Result findCountByTag(Long[] tagIds) { | 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; | package com.iformall.domain.po; | ||||
| import com.iformall.domain.vo.WxChooseTagVo; | |||||
| import javax.persistence.Id; | import javax.persistence.Id; | ||||
| import javax.persistence.Table; | import javax.persistence.Table; | ||||
| import javax.persistence.Transient; | import javax.persistence.Transient; | ||||
| @@ -20,8 +18,6 @@ public class CouponInject implements Serializable { | |||||
| protected List<Long> ids; | protected List<Long> ids; | ||||
| @Transient | @Transient | ||||
| protected String sortColumns; | protected String sortColumns; | ||||
| @Transient | |||||
| protected WxChooseTagVo wxChooseTagVo; | |||||
| public WxMsgModel getMsgModel() { | public WxMsgModel getMsgModel() { | ||||
| return msgModel; | return msgModel; | ||||
| @@ -191,13 +187,7 @@ public class CouponInject implements Serializable { | |||||
| public void setUpdateTime(Date _updateTime) { | public void setUpdateTime(Date _updateTime) { | ||||
| updateTime = _updateTime; | updateTime = _updateTime; | ||||
| } | } | ||||
| public WxChooseTagVo getWxChooseTagVo() { | |||||
| return wxChooseTagVo; | |||||
| } | |||||
| public void setWxChooseTagVo(WxChooseTagVo wxChooseTagVo) { | |||||
| this.wxChooseTagVo = wxChooseTagVo; | |||||
| } | |||||
| public Date getSendTimeStart() { | public Date getSendTimeStart() { | ||||
| return sendTimeStart; | return sendTimeStart; | ||||
| } | } | ||||
| @@ -230,6 +220,17 @@ public class CouponInject implements Serializable { | |||||
| this.msgId = msgId; | 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 | public static enum Field | ||||
| { | { | ||||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | ||||
| @@ -109,8 +109,10 @@ public class WxCUserBasicInfo implements Serializable { | |||||
| @Transient | @Transient | ||||
| @Excel(name="标签",width = 20,orderNum = "10") | @Excel(name="标签",width = 20,orderNum = "10") | ||||
| private String tagNames; | private String tagNames; | ||||
| @Transient | @Transient | ||||
| private long count; | |||||
| private List<WxTags> tagsList; | |||||
| @Transient | @Transient | ||||
| private Date startTime; | private Date startTime; | ||||
| @Transient | @Transient | ||||
| @@ -136,14 +138,6 @@ public class WxCUserBasicInfo implements Serializable { | |||||
| this.nickName = nickName; | this.nickName = nickName; | ||||
| } | } | ||||
| public long getCount() { | |||||
| return count; | |||||
| } | |||||
| public void setCount(long count) { | |||||
| this.count = count; | |||||
| } | |||||
| public String getTagNames() { | public String getTagNames() { | ||||
| return tagNames; | return tagNames; | ||||
| } | } | ||||
| @@ -152,7 +146,6 @@ public class WxCUserBasicInfo implements Serializable { | |||||
| this.tagNames = tagNames; | this.tagNames = tagNames; | ||||
| } | } | ||||
| public String getTagIds() { | public String getTagIds() { | ||||
| return tagIds; | return tagIds; | ||||
| } | } | ||||
| @@ -270,6 +263,14 @@ public class WxCUserBasicInfo implements Serializable { | |||||
| addressStr = _addressStr; | addressStr = _addressStr; | ||||
| } | } | ||||
| public List<WxTags> getTagsList() { | |||||
| return tagsList; | |||||
| } | |||||
| public void setTagsList(List<WxTags> tagsList) { | |||||
| this.tagsList = tagsList; | |||||
| } | |||||
| public static enum Field | public static enum Field | ||||
| { | { | ||||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | ||||
| @@ -52,6 +52,16 @@ public class WxTags implements Serializable { | |||||
| @io.swagger.annotations.ApiModelProperty(value="二级属性 性别等",name="typeName") | @io.swagger.annotations.ApiModelProperty(value="二级属性 性别等",name="typeName") | ||||
| private String typeName; | private String typeName; | ||||
| @Transient | |||||
| protected long count; | |||||
| public long getCount() { | |||||
| return count; | |||||
| } | |||||
| public void setCount(long count) { | |||||
| this.count = count; | |||||
| } | |||||
| public String getName() { | public String getName() { | ||||
| return name; | 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.WxCUserBasicInfo; | ||||
| import com.iformall.domain.po.WxCUserTags; | import com.iformall.domain.po.WxCUserTags; | ||||
| import com.iformall.domain.po.WxTags; | import com.iformall.domain.po.WxTags; | ||||
| import com.iformall.domain.vo.WxChooseTagVo; | |||||
| import com.iformall.enums.EnumAssignTagsTrigger; | import com.iformall.enums.EnumAssignTagsTrigger; | ||||
| public interface WxCUserTagsService { | public interface WxCUserTagsService { | ||||
| @@ -44,12 +43,6 @@ public interface WxCUserTagsService { | |||||
| */ | */ | ||||
| void deleteById(Long id); | 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); | List<WxCUserBasicInfo> findByTag(String tenantId, List<Long> tagIds); | ||||
| /** | |||||
| * tagIds查询 用户数量(登陆过C端的用户,并且保有手机号) | |||||
| * @param tagIds | |||||
| * @return | |||||
| */ | |||||
| long findCUserCountByTag(String tenantId, List<Long> tagIds); | |||||
| /** | /** | ||||
| * | * | ||||
| * tagIds查询用户user信息集合(登陆过C端的用户,并且保有手机号) | * tagIds查询用户user信息集合(登陆过C端的用户,并且保有手机号) | ||||
| @@ -74,15 +59,12 @@ public interface WxCUserTagsService { | |||||
| * @return | * @return | ||||
| */ | */ | ||||
| List<WxCUser> findCUserByTag(String tenantId, List<Long> tagIds); | 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> assignTags(List<Long> tagIdList, WxCUserBasicInfo user); | ||||
| List<WxTags> triggerAssignTags(EnumAssignTagsTrigger trigger, Object obj); | 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.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.common.IdWorker; | import com.iformall.common.IdWorker; | ||||
| import com.iformall.domain.vo.WxChooseTagVo; | |||||
| import com.iformall.service.WxCUserTagsService; | import com.iformall.service.WxCUserTagsService; | ||||
| @Service | @Service | ||||
| @@ -81,26 +80,29 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService { | |||||
| wxCUserTagsMapper.deleteByPrimaryKey(id); | 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); | 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); | return wxCUserTagsMapper.findCUserCountByTags(str,tenantId); | ||||
| } | } | ||||
| @Override | @Override | ||||
| public List<WxCUser> findCUserByTag(String tenantId, List<Long> tagIds) { | 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 wxCUser = new WxCUser(); | ||||
| wxCUser.setIds(userIds); | wxCUser.setIds(userIds); | ||||
| return wxCUserMapper.findList(wxCUser); | return wxCUserMapper.findList(wxCUser); | ||||
| @@ -108,12 +110,16 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService { | |||||
| @Override | @Override | ||||
| public List<WxCUserBasicInfo> findByTag(String tenantId, List<Long> tagIds) { | 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 wxCUserBasicInfo = new WxCUserBasicInfo(); | ||||
| wxCUserBasicInfo.setIds(userIds); | wxCUserBasicInfo.setIds(userIds); | ||||
| return wxCUserBasicInfoMapper.findList(wxCUserBasicInfo); | return wxCUserBasicInfoMapper.findList(wxCUserBasicInfo); | ||||
| @@ -121,22 +127,29 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService { | |||||
| @Override | @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 wxTags =new WxTags(); | ||||
| wxTags.setIds(tagIds); | wxTags.setIds(tagIds); | ||||
| List<WxTags> list = wxTagsMapper.findList(wxTags); | 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> | ||||
| <select id="findCUserCountByTags" resultType="java.lang.Long"> | <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> | ||||
| <select id="findByTags" resultType="java.lang.Long"> | <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> | ||||
| <select id="findCUserByTags" resultType="java.lang.Long"> | <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> | </select> | ||||
| <update id="updateNewId" parameterType="com.iformall.domain.vo.CUserTagVo"> | <update id="updateNewId" parameterType="com.iformall.domain.vo.CUserTagVo"> | ||||