| @@ -1,46 +0,0 @@ | |||
| package com.iformall.schedule; | |||
| import com.iformall.mapper.WxCUserMapper; | |||
| import com.iformall.service.MailService; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.scheduling.annotation.Scheduled; | |||
| import org.springframework.stereotype.Component; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| @Component | |||
| public class WxCUserCheckSchedule { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private boolean isFmException; | |||
| @Autowired | |||
| private String fmExceptionEmails; | |||
| @Autowired | |||
| private MailService mailService; | |||
| @Autowired | |||
| private WxCUserMapper cUserMapper; | |||
| //@Scheduled(cron = "0 0 8 * * ?") // 每天凌晨08:00对c_user扫描查重 | |||
| // @Scheduled(cron = "0 */1 * * * ?") // 测试1分钟一次 | |||
| // public void cuserCheckDuplicate() { | |||
| // | |||
| // List<Map<String, Object>> mapList = cUserMapper.checkCountByTenantOpenId(); | |||
| // if(mapList.size()> 0) { | |||
| // String message = "wx_c_user异常,有重复数据"; | |||
| // logger.error(message); | |||
| // if(isFmException) { | |||
| // String[] receivers = fmExceptionEmails.split(","); | |||
| // //发送邮件 | |||
| // mailService.sendSimpleMail(receivers, message, message); | |||
| // } | |||
| // } | |||
| // } | |||
| } | |||
| @@ -7,6 +7,7 @@ import lombok.EqualsAndHashCode; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| /** | |||
| * @author Stormeye | |||
| @@ -32,6 +33,9 @@ public class BaseCUserEntity extends TenantEntity { | |||
| @TableField(exist = false) | |||
| protected static EnumAppPlat appPlat; | |||
| @TableField(exist = false) | |||
| private List<Long> userIds; | |||
| /** | |||
| * 是否是会员 | |||
| @@ -88,4 +92,13 @@ public class BaseCUserEntity extends TenantEntity { | |||
| public void setAppPlat(EnumAppPlat appPlat) { | |||
| this.appPlat = appPlat; | |||
| } | |||
| public List<Long> getUserIds() { | |||
| return userIds; | |||
| } | |||
| public void setUserIds(List<Long> userIds) { | |||
| this.userIds = userIds; | |||
| } | |||
| } | |||
| @@ -27,10 +27,10 @@ public class BaseTenantEntity extends BaseEntity { | |||
| protected String finalTenantId; | |||
| public String getFinalTenantId() { | |||
| finalTenantId = tenantId; | |||
| if (StringUtils.isNotBlank(parentTenantId)) { | |||
| finalTenantId = parentTenantId; | |||
| } | |||
| finalTenantId = tenantId; | |||
| return finalTenantId; | |||
| } | |||
| @@ -44,10 +44,10 @@ public class TenantEntity extends BaseEntity { | |||
| } | |||
| public String getFinalTenantId() { | |||
| finalTenantId = tenantId; | |||
| if (StringUtils.isNotBlank(parentTenantId)) { | |||
| finalTenantId = parentTenantId; | |||
| } | |||
| finalTenantId = tenantId; | |||
| return finalTenantId; | |||
| } | |||
| @@ -29,8 +29,6 @@ public interface TtCUserMapper extends CommonMapper<TtCUser, Long> { | |||
| long countByChannel(TtCUser ttCUser); | |||
| //List<Map<String, Object>> checkCountByTenantOpenId(); | |||
| void updateUserId(TtCUser record); | |||
| void delForUserIdOnly(@Param("id")Long id, @Param("userId")Long userId,@Param("tenantId")String tenantId); | |||
| @@ -62,6 +62,6 @@ public interface WxCUserBasicInfoMapper extends CommonMapper<WxCUserBasicInfo, S | |||
| void cuserOldToNew(@Param(value = "oldCuserId")Long oldCuserId, @Param(value = "newCuserId")Long newCuserId, | |||
| @Param("tableIndex")Integer tableIndex,@Param("finalTableIndex")Integer finalTableIndex); | |||
| List<String> findOpenIdByFilter(WxCUserBasicInfoDto wxCUserBasicInfoDto); | |||
| List<Long> findIdByFilter(WxCUserBasicInfoDto wxCUserBasicInfoDto); | |||
| } | |||
| @@ -29,8 +29,6 @@ public interface WxCUserMapper extends CommonMapper<WxCUser, Long> { | |||
| long countByChannel(WxCUser wxCUser); | |||
| //List<Map<String, Object>> checkCountByTenantOpenId(); | |||
| void updateUserId(WxCUser record); | |||
| void delForUserIdOnly(@Param("id")Long id, @Param("userId")Long userId,@Param("tenantId")String tenantId); | |||
| @@ -14,11 +14,12 @@ public interface WxCUserTagsMapper extends CommonMapper<WxCUserTags, String> { | |||
| WxCUserTags selectById(@Param("id")Long id,@Param("tenantId")String tenantId); | |||
| List<WxCUserTags> findList(WxCUserTags wxCUserTags); | |||
| List<Long> findIdList(@Param("tenantId")String tenantId, @Param("tagIdList")List<Long> tagIdList); | |||
| long countUser(@Param("tagIds")String tagIds,@Param("tenantId")String tenantId,@Param("finalTenantId")String finalTenantId, | |||
| @Param("startTime")Date startTime,@Param("endTime")Date endTime); | |||
| List<Long> findUserIdList(@Param("tagIds")String tagIds,@Param("tenantId")String tenantId); | |||
| void updateNewId(CUserTagNewIdVo record); | |||
| int deleteById(@Param("id")Long id,@Param("tenantId")String tenantId); | |||
| } | |||
| @@ -103,4 +103,12 @@ public interface WxCouponOrderMapper extends CommonMapper<WxCouponOrder, Long> { | |||
| List<WxCouponOrder> findUserTradeList(WxCouponOrder wxCouponOrder); | |||
| /** | |||
| * 获取时间范围内核销的用户(参数不能为null) | |||
| * @param tenantId | |||
| * @param verifiedStartTime | |||
| * @param verifiedStartTime1 | |||
| * @return | |||
| */ | |||
| List<Long> findVerifiedUserIds(@Param("tenantId")String tenantId, @Param("verifiedStartTime")Date verifiedStartTime, @Param("verifiedEndTime")Date verifiedEndTime); | |||
| } | |||
| @@ -29,7 +29,7 @@ public interface WxCUserBasicInfoService { | |||
| List<WxCUserBasicInfo> listByFilter(TenantEntity tenantEntity, List<WxCUserBasicInfoFilterDto> filterList); | |||
| List<String> findOpenIdByFilter(TenantEntity tenantEntity, List<WxCUserBasicInfoFilterDto> filterList); | |||
| List<Long> findIdByFilter(TenantEntity tenantEntity, List<WxCUserBasicInfoFilterDto> filterList); | |||
| List<WxCUserBasicInfo> listByFilterList(TenantEntity tenantEntity, List<WxCUserBasicInfoFilterListDto> filterList); | |||
| @@ -43,7 +43,6 @@ public interface WxCUserBasicInfoService { | |||
| * @return | |||
| */ | |||
| PageInfo<WxCUserBasicInfo> listAsPage(WxCUserBasicInfo record, Integer pageIndex, Integer pageSize); | |||
| PageInfo<WxCUserBasicInfo> listAsPage(TenantEntity tenantInfo, WxCUserBasicInfo wxCUserBasicInfo, Integer pageIndex, Integer pageSize); | |||
| List<WxCUserBasicInfo> listPhoneAndNameByIds(WxCUserBasicInfo record); | |||
| /** | |||
| @@ -96,7 +96,6 @@ public interface WxCUserService { | |||
| /** | |||
| * 统计数量 | |||
| * @param dto | |||
| * @param tenantEntitys | |||
| * @return | |||
| */ | |||
| long findCount(WxCUserBasicInfoDto dto); | |||
| @@ -112,7 +111,6 @@ public interface WxCUserService { | |||
| /** | |||
| * 通过渠道获取会员信息 | |||
| * @param user | |||
| * @param tenantEntitys | |||
| * @param pageIndex | |||
| * @param pageSize | |||
| * @return | |||
| @@ -123,7 +121,6 @@ public interface WxCUserService { | |||
| /** | |||
| * 登录后发消息 | |||
| * @param user | |||
| */ | |||
| void actionMsgAfterLogin(WxCUserFrom wxCUserFrom); | |||
| @@ -10,6 +10,7 @@ import com.iformall.service.tags.TagsDeveloper; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| public interface WxCUserTagsService { | |||
| @@ -53,4 +54,11 @@ public interface WxCUserTagsService { | |||
| void updateTagByUserId(Long cUserId,TenantEntity tenantinfo, List<Long> tags); | |||
| /** | |||
| * 获取标签id------标签name map | |||
| * @param tenantInfo | |||
| * @param tagIds | |||
| * @return | |||
| */ | |||
| Map<Long, String> findIdTagNames(TenantEntity tenantInfo, List<Long> tagIds); | |||
| } | |||
| @@ -1,6 +1,5 @@ | |||
| package com.iformall.service.impl; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| @@ -46,6 +45,9 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService,IExc | |||
| @Autowired | |||
| WxCUserTagsMapper wxCUserTagsMapper; | |||
| @Autowired | |||
| WxCouponOrderMapper wxCouponOrderMapper; | |||
| @Autowired | |||
| WxCUserBasicInfoMapper wxCUserBasicInfoMapper; | |||
| @@ -402,6 +404,13 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService,IExc | |||
| Date.from( | |||
| localDate.plusMonths(1).with(TemporalAdjusters.firstDayOfMonth()).atStartOfDay().atZone(zone).toInstant())); | |||
| } | |||
| if(dto.getVerifiedStartTime() != null && dto.getVerifiedEndTime() != null){ | |||
| List<Long> userIds = wxCouponOrderMapper.findVerifiedUserIds(dto.getTenantId(),dto.getVerifiedStartTime(),dto.getVerifiedEndTime()); | |||
| if(!userIds.isEmpty()){ | |||
| dto.setIds(userIds); | |||
| } | |||
| } | |||
| } | |||
| private WxCUserBasicInfoDto filtersToDto(TenantEntity tenantEntity, List<WxCUserBasicInfoFilterDto> filterList){ | |||
| @@ -429,8 +438,12 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService,IExc | |||
| tagIdList.add(f.getId()); | |||
| } | |||
| }); | |||
| if(!tagIdList.isEmpty()) | |||
| dto.setTagIds(tagIdList); | |||
| if(!tagIdList.isEmpty()){ | |||
| List<Long> tagIds = wxCUserTagsMapper.findIdList(tenantEntity.getTenantId(),tagIdList); | |||
| if(!tagIds.isEmpty()){ | |||
| dto.setTagIds(tagIds); | |||
| } | |||
| } | |||
| return dto; | |||
| } | |||
| @@ -534,11 +547,11 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService,IExc | |||
| } | |||
| @Override | |||
| public List<String> findOpenIdByFilter(TenantEntity tenantEntity, List<WxCUserBasicInfoFilterDto> filterList) { | |||
| public List<Long> findIdByFilter(TenantEntity tenantEntity, List<WxCUserBasicInfoFilterDto> filterList) { | |||
| WxCUserBasicInfoDto wxCUserBasicInfoDto = filtersToDto(tenantEntity, filterList); | |||
| wxCUserBasicInfoDto.updateTenantInfo(tenantEntity); | |||
| wxCUserBasicInfoDto.setFinalTenantId(tenantEntity.getFinalTenantId()); | |||
| return wxCUserBasicInfoMapper.findOpenIdByFilter(wxCUserBasicInfoDto); | |||
| return wxCUserBasicInfoMapper.findIdByFilter(wxCUserBasicInfoDto); | |||
| } | |||
| @Override | |||
| @@ -550,9 +563,16 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService,IExc | |||
| @Override | |||
| public List<String> listOpenIdByFilter(TenantEntity tenantEntity, List<WxCUserBasicInfoFilterListDto> filterList) { | |||
| HashSet<String> openSet = new HashSet<>(); | |||
| filterList.stream().forEach(f->openSet.addAll(findOpenIdByFilter(tenantEntity,f.getTagList()))); | |||
| return new ArrayList<>(openSet); | |||
| HashSet<Long> idSet = new HashSet<>(); | |||
| filterList.stream().forEach(f->idSet.addAll(findIdByFilter(tenantEntity,f.getTagList()))); | |||
| if(idSet.isEmpty()){ | |||
| return new ArrayList<String>(); | |||
| } | |||
| WxCUser cuser = new WxCUser(); | |||
| cuser.updateTenantInfo(tenantEntity); | |||
| cuser.setUserIds(new ArrayList<>(idSet)); | |||
| List<String> openList = wxCUserMapper.listOpenId(cuser); | |||
| return openList; | |||
| } | |||
| @@ -564,13 +584,6 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService,IExc | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCUserBasicInfoMapper.findList(record)); | |||
| } | |||
| @Override | |||
| public PageInfo<WxCUserBasicInfo> listAsPage(TenantEntity tenantInfo, WxCUserBasicInfo wxCUserBasicInfo, Integer pageIndex, Integer pageSize) { | |||
| wxCUserBasicInfo.setTenantId(tenantInfo.getTenantId()); | |||
| wxCUserBasicInfo.undateFinalTenantId(tenantInfo); | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCUserBasicInfoMapper.findList(wxCUserBasicInfo)); | |||
| } | |||
| @Override | |||
| public int countUser(WxCUserBasicInfo record) { | |||
| return wxCUserBasicInfoMapper.selectCount(new QueryWrapper(record)); | |||
| @@ -1220,14 +1233,13 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService,IExc | |||
| basicInfo.setBegin((page-1)*20000); | |||
| basicInfo.setLimit(20000); | |||
| basicInfo.undateFinalTenantId(tenantInfo); | |||
| basicInfo.undateFinalTenantId(tenantInfo); | |||
| list = wxCUserBasicInfoMapper.findVoList(basicInfo); | |||
| if (null == list || list.size() <= 0 ) { | |||
| return null; | |||
| } | |||
| // List<Long> userIds = wxCUserBasicInfoMapper.findVoIdsList1(tenantInfo,basicInfo); | |||
| // List<Long> userIds = list.stream().map(cc -> cc.getId()).collect(Collectors.toList()); | |||
| // if (null != userIds && userIds.size() > 0 ) { | |||
| // WxCreditHistory chaddq = new WxCreditHistory(); | |||
| // chaddq.setUserIdList(userIds); | |||
| @@ -1250,41 +1262,14 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService,IExc | |||
| // if(null != chless){ | |||
| // chlesMap = chless.stream().collect(Collectors.toMap(WxCreditHistory::getCUserId, WxCreditHistory::getCreditNum)); | |||
| // } | |||
| // | |||
| //// WxCUserTags tq = new WxCUserTags(); | |||
| //// tq.setUserIdList(userIds); | |||
| //// tq.setTenantId(tenantInfo.getFinalTenantId()); | |||
| //// List<WxCUserTags> userTagList = wxCUserTagsMapper.findList(tq); | |||
| //// Map<Long, String> tagMap = new HashMap<>(); | |||
| //// Map<Long, String> userTagsMap = new HashMap<>(); | |||
| //// if (null != userTagList) { | |||
| //// List<WxTags> tagList = wxTagsMapper.findListAll(); | |||
| //// tagMap = tagList.stream().collect(Collectors.toMap(WxTags::getId, WxTags::getName)); | |||
| //// userTagsMap = userTagList.stream().collect(Collectors.toMap(WxCUserTags::getUserId, WxCUserTags::getTags)); | |||
| //// | |||
| //// } | |||
| // | |||
| List<WxTags> tagList = wxTagsMapper.findListAll(tenantInfo.getTenantId()); | |||
| // | |||
| // Map<Long, Integer> finalChaddMap = chaddMap; | |||
| // Map<Long, Integer> finalChlesMap = chlesMap; | |||
| //// Map<Long, String> finalUserTagsMap = userTagsMap; | |||
| Map<Long, String> finalTagMap = tagList.stream().collect(Collectors.toMap(WxTags::getId, WxTags::getName));; | |||
| //处理会员标签 | |||
| List<Long> tagIds = list.stream().map(cc -> cc.getTagId()).collect(Collectors.toList()); | |||
| Map<Long, String> tagIdName = wxCUserTagsService.findIdTagNames(tenantInfo,tagIds); | |||
| list.stream().forEach(u->{ | |||
| // u.setAddCredit(finalChaddMap.get(u.getId())); | |||
| // u.setLesCredit(finalChlesMap.get(u.getId())); | |||
| if(StringUtils.isNotBlank(u.getTags())){ | |||
| List<Long> ids = JSONObject.parseArray(u.getTags(), Long.class); | |||
| if (null != ids) { | |||
| String tagNames = StringUtils.join(ids.stream().map(id-> finalTagMap.get(id)).collect(Collectors.toList()),"/"); | |||
| u.setTagNames(tagNames); | |||
| } | |||
| } | |||
| // List<Long> ids = JSONObject.parseArray(finalUserTagsMap.get(u.getId()), Long.class); | |||
| // if (null != ids) { | |||
| // String tagNames = StringUtils.join(ids.stream().map(id-> finalTagMap.get(id)).collect(Collectors.toList()),"/"); | |||
| // u.setTagNames(tagNames); | |||
| // } | |||
| u.setTagNames(tagIdName.get(u.getTagId())); | |||
| }); | |||
| // | |||
| // } | |||
| @@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.domain.dto.WxCUserBasicInfoDto; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.vo.WxCUserBasicTagVo; | |||
| @@ -27,6 +28,7 @@ import java.math.RoundingMode; | |||
| import java.text.SimpleDateFormat; | |||
| import java.util.*; | |||
| import java.util.regex.Pattern; | |||
| import java.util.stream.Collectors; | |||
| @Service | |||
| public class WxCUserTagsServiceImpl implements WxCUserTagsService { | |||
| @@ -77,7 +79,16 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService { | |||
| @Override | |||
| public long countUser(TenantEntity tenantEntity, Long tagId, Date startTime, Date endTime ) { | |||
| String str = JSON.toJSONString(tagId); | |||
| return wxCUserTagsMapper.countUser(str, tenantEntity.getFinalTenantId(),tenantEntity.getFinalTenantId(), startTime, endTime); | |||
| List<Long> userIds = wxCUserTagsMapper.findUserIdList(str, tenantEntity.getFinalTenantId()); | |||
| if(startTime == null && endTime == null){ | |||
| return (long)userIds.size(); | |||
| }else{ | |||
| WxCUserBasicInfoDto dto = new WxCUserBasicInfoDto(); | |||
| dto.updateTenantInfo(tenantEntity); | |||
| dto.setStartTime(startTime); | |||
| dto.setEndTime(endTime); | |||
| return wxCUserBasicInfoMapper.findCount(dto); | |||
| } | |||
| } | |||
| @@ -319,7 +330,32 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService { | |||
| } | |||
| } | |||
| public Long getTagId(List<Long> tagList, Long id, WxTags wxTags) { | |||
| @Override | |||
| public Map<Long, String> findIdTagNames(TenantEntity tenantInfo, List<Long> tagIds) { | |||
| Map<Long, String> tagIdName = new HashMap<>(); | |||
| if(tagIds == null || tagIds.isEmpty()){ | |||
| return tagIdName; | |||
| } | |||
| WxCUserTags userTagsQ = new WxCUserTags(); | |||
| userTagsQ.updateTenantInfo(tenantInfo); | |||
| userTagsQ.setIds(tagIds); | |||
| List<WxCUserTags> userTagsList = wxCUserTagsMapper.findList(userTagsQ); | |||
| List<WxTags> tagList = wxTagsMapper.findListAll(tenantInfo.getTenantId()); | |||
| Map<Long, String> finalTagMap = tagList.stream().collect(Collectors.toMap(WxTags::getId, WxTags::getName)); | |||
| for (WxCUserTags wct:userTagsList) { | |||
| if(StringUtils.isNotBlank(wct.getTags())){ | |||
| List<Long> ids = JSONObject.parseArray(wct.getTags(), Long.class); | |||
| if (null != ids) { | |||
| String tagNames = StringUtils.join(ids.stream().map(id-> finalTagMap.get(id)).collect(Collectors.toList()),"/"); | |||
| tagIdName.put(wct.getId(),tagNames); | |||
| } | |||
| } | |||
| } | |||
| return tagIdName; | |||
| } | |||
| public Long getTagId(List<Long> tagList, Long id, WxTags wxTags) { | |||
| List<WxTags> list = wxTagsMapper.findList(wxTags); | |||
| for (WxTags tag : list) { | |||
| boolean flag = false; | |||
| @@ -76,7 +76,7 @@ public class WxChartServiceImpl implements WxChartDataService { | |||
| @Autowired | |||
| WxLevelConfigMapper wxLevelConfigMapper; | |||
| @Autowired | |||
| WxCUserTagsMapper wxCUserTagsMapper; | |||
| WxCUserTagsService wxCUserTagsService; | |||
| @Lazy | |||
| @Autowired | |||
| @@ -2312,7 +2312,7 @@ public class WxChartServiceImpl implements WxChartDataService { | |||
| for (int i = 0; i < tags.length; i++) { | |||
| WxTags tag = new WxTags(); | |||
| tag.setName(tags[i].getMessage()); | |||
| tag.setCount(wxCUserTagsMapper.countUser(JSON.toJSONString(tags[i].getCode()), tenantEntity.getFinalTenantId(),tenantEntity.getFinalTenantId(), startTime, endTime)); | |||
| tag.setCount(wxCUserTagsService.countUser(tenantEntity,tags[i].getCode(), startTime, endTime)); | |||
| tagList.add(tag); | |||
| total -= tag.getCount(); | |||
| } | |||
| @@ -2348,7 +2348,7 @@ public class WxChartServiceImpl implements WxChartDataService { | |||
| for (int i = 0; i < tags.length; i++) { | |||
| WxTags tag = new WxTags(); | |||
| tag.setName(tags[i].getMessage()); | |||
| tag.setCount(wxCUserTagsMapper.countUser(JSON.toJSONString(tags[i].getCode()), tenantEntity.getFinalTenantId(),tenantEntity.getFinalTenantId(), startTime, endTime)); | |||
| tag.setCount(wxCUserTagsService.countUser(tenantEntity,tags[i].getCode(), startTime, endTime)); | |||
| tagList.add(tag); | |||
| total -= tag.getCount(); | |||
| } | |||
| @@ -242,6 +242,12 @@ | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != userIds "> | |||
| and user_id in | |||
| <foreach collection="userIds" index="index" item="userIdItem" open="(" separator="," close=")"> | |||
| #{userIdItem} | |||
| </foreach> | |||
| </if> | |||
| </select> | |||
| <update id="updateMsgCount" parameterType="com.iformall.domain.po.tt.TtCUser"> | |||
| @@ -319,16 +325,16 @@ | |||
| </select> | |||
| <select id="findCountHistory" resultType="com.iformall.domain.vo.UserCountVo"> | |||
| <select id="findCountHistory" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="com.iformall.domain.vo.UserCountVo"> | |||
| select count(id) as incCount, | |||
| <if test="1 == reportType "> | |||
| date_format(create_date, '%Y-%m-%d') as reportTime, | |||
| date_format(create_date, '%Y-%m-%d') as reportTime | |||
| </if> | |||
| <if test="2 == reportType "> | |||
| date_format(create_date, '%Y-%m') as reportTime, | |||
| date_format(create_date, '%Y-%m') as reportTime | |||
| </if> | |||
| <if test="3 == reportType "> | |||
| date_format(create_date, '%Y') as reportTime, | |||
| date_format(create_date, '%Y') as reportTime | |||
| </if> | |||
| from tt_c_user | |||
| @@ -391,11 +397,6 @@ | |||
| </if> | |||
| </select> | |||
| <select id="checkCountByTenantOpenId" resultType="hashmap" > | |||
| select * from (select tenant_id, open_id, count(tenant_id+open_id) as u_count from tt_c_user group by tenant_id, open_id) t where t.u_count >= 2 | |||
| </select> | |||
| <update id="updateUserId" parameterType="com.iformall.domain.po.tt.TtCUser"> | |||
| update tt_c_user | |||
| set user_id=#{userId} | |||
| @@ -100,23 +100,17 @@ | |||
| <if test=" null != name "> | |||
| and wcubi.`name` like concat('%', #{name},'%') | |||
| </if> | |||
| <if test=" null != startTime and null!=endTime"> | |||
| <if test=" null != startTime and null != endTime"> | |||
| and wcubi.`create_date` between #{startTime} and #{endTime} | |||
| </if> | |||
| <if test=" null != activeStartTime and null!=activeEndTime"> | |||
| <if test=" null != activeStartTime and null != activeEndTime"> | |||
| and wcubi.`active_time` between #{activeStartTime} and #{activeEndTime} | |||
| </if> | |||
| <if test=" null != status "> | |||
| and wcubi.`status` = #{status} | |||
| </if> | |||
| <if test=" null != carNumber and '' != carNumber"> | |||
| and wcubi.id in (select c_user_id from wx_c_user_car | |||
| where (`tenant_id` = #{finalTenantId} or `parent_tenant_id` = #{finalTenantId}) | |||
| and car_number like concat('%', #{carNumber},'%')) | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and wcubi.id in | |||
| @@ -131,7 +125,10 @@ | |||
| <select id="selectById" parameterType="java.util.HashMap" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns"/> from wx_c_user_basic_info wcubi where wcubi.id =#{id} and wcubi.final_tenant_id = #{finalTenantId} | |||
| select <include refid="allColumns"/> | |||
| from wx_c_user_basic_info wcubi | |||
| where wcubi.id =#{id} | |||
| and wcubi.final_tenant_id = #{finalTenantId} | |||
| </select> | |||
| <select id="findList" parameterType="com.iformall.domain.po.WxCUserBasicInfo" resultMap="BaseResultMap"> | |||
| @@ -146,11 +143,11 @@ | |||
| from wx_c_user_basic_info wcubi | |||
| where wcubi.`final_tenant_id` = #{finalTenantId} | |||
| <if test=" null != ids "> | |||
| and wcubi.id in | |||
| and wcubi.id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| </foreach> | |||
| </if> | |||
| </if> | |||
| </select> | |||
| <select id="findIdList" parameterType="com.iformall.domain.po.WxCUserBasicInfo" resultType="Long"> | |||
| @@ -160,26 +157,31 @@ | |||
| </select> | |||
| <update id="updateScore" parameterType="com.iformall.domain.po.WxCUserBasicInfo"> | |||
| update wx_c_user_basic_info set poins=#{poins} | |||
| where id=#{id} | |||
| update wx_c_user_basic_info | |||
| set poins = #{poins} | |||
| where id = #{id} | |||
| </update> | |||
| <update id="updateUpScore" parameterType="com.iformall.domain.po.WxCUserBasicInfo"> | |||
| update wx_c_user_basic_info set poins=poins+#{poins} | |||
| where id=#{id} | |||
| update wx_c_user_basic_info | |||
| set poins = poins+#{poins} | |||
| where id = #{id} | |||
| </update> | |||
| <update id="updateDownScore" parameterType="com.iformall.domain.po.WxCUserBasicInfo"> | |||
| update wx_c_user_basic_info set poins=poins-#{poins} | |||
| where id=#{id} | |||
| update wx_c_user_basic_info | |||
| set poins = poins-#{poins} | |||
| where id = #{id} | |||
| </update> | |||
| <update id="updateNewId" parameterType="com.iformall.domain.vo.CUserBaseVo"> | |||
| update wx_c_user_basic_info set id=#{newId} , credit=#{credit} , poins=#{poins} | |||
| where id = #{id} | |||
| update wx_c_user_basic_info | |||
| set id = #{newId} , credit = #{credit} , poins = #{poins} | |||
| where id = #{id} | |||
| </update> | |||
| <select id="findCountBySex" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long"> | |||
| select count(wcubi.id) from wx_c_user_basic_info wcubi | |||
| select count(wcubi.id) | |||
| from wx_c_user_basic_info wcubi | |||
| where wcubi.sex =#{sex} | |||
| and wcubi.`final_tenant_id` = #{finalTenantId} | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| @@ -222,7 +224,8 @@ | |||
| </select> | |||
| <select id="findCountByScore" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long"> | |||
| select count(wcubi.id) from wx_c_user_basic_info wcubi | |||
| select count(wcubi.id) | |||
| from wx_c_user_basic_info wcubi | |||
| where wcubi.`final_tenant_id` = #{finalTenantId} | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and wcubi.`tenant_id` like concat('%,', #{tenantId},',%') | |||
| @@ -288,7 +291,8 @@ | |||
| </select> | |||
| <select id="findCount" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long"> | |||
| select count(wcubi.id) from wx_c_user_basic_info wcubi | |||
| select count(wcubi.id) | |||
| from wx_c_user_basic_info wcubi | |||
| where wcubi.`final_tenant_id` = #{finalTenantId} | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and wcubi.`tenant_id` like concat('%,', #{tenantId},',%') | |||
| @@ -302,18 +306,24 @@ | |||
| <if test="1 == queryImport"> | |||
| and wcubi.create_date like '%00:00:00' | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and wcubi.id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| </foreach> | |||
| </if> | |||
| </select> | |||
| <select id="findCountHistory" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="com.iformall.domain.vo.UserCountVo"> | |||
| select count(wcubi.id) as incCount, | |||
| <if test="1 == reportType "> | |||
| date_format(wcubi.create_date, '%Y-%m-%d') as reportTime, | |||
| date_format(wcubi.create_date, '%Y-%m-%d') as reportTime | |||
| </if> | |||
| <if test="2 == reportType "> | |||
| date_format(wcubi.create_date, '%Y-%m') as reportTime, | |||
| date_format(wcubi.create_date, '%Y-%m') as reportTime | |||
| </if> | |||
| <if test="3 == reportType "> | |||
| date_format(wcubi.create_date, '%Y') as reportTime, | |||
| date_format(wcubi.create_date, '%Y') as reportTime | |||
| </if> | |||
| from wx_c_user_basic_info wcubi | |||
| where wcubi.`final_tenant_id` = #{finalTenantId} | |||
| @@ -436,10 +446,8 @@ | |||
| <select id="findVoList" parameterType="com.iformall.domain.po.WxCUserBasicInfo" resultMap="VoBaseResultMap"> | |||
| select | |||
| wcubi.`id`,wcubi.`name`,wcubi.`sex`,wcubi.`height`,wcubi.`weight`,wcubi.`id_card`,wcubi.`phone`,wcubi.`nick_name`,wcubi.`education`,wcubi.`birthdate`,wcubi.`address`, | |||
| wcubi.`active_time`,wcubi.`create_date`,wcubi.`poins`,wcubi.`credit`, | |||
| wcut.`tags` | |||
| wcubi.`active_time`,wcubi.`create_date`,wcubi.`poins`,wcubi.`credit`,wcubi.`tag_id` | |||
| from wx_c_user_basic_info wcubi | |||
| left join wx_c_user_tags${basicInfo.shardFinalTableSuffix} wcut on wcut.`id` = wcubi.`tag_id` | |||
| <include refid="dynamicVoWhereConditions"/> | |||
| <if test=" null != begin "> | |||
| limit #{begin}, #{limit} | |||
| @@ -484,15 +492,6 @@ | |||
| and wcubi.active_time <= #{loginEndTime} | |||
| </if> | |||
| <if test=" null != verifiedStartTime and null != verifiedEndTime "> | |||
| and 0 < | |||
| (select count(*) from wx_coupon_order wco | |||
| where wcubi.id = wco.c_user_id | |||
| and wco.coupon_order_status = 1 | |||
| and wco.update_date >= #{verifiedStartTime} | |||
| and wco.update_date <= #{verifiedEndTime}) | |||
| </if> | |||
| <if test=" null != phones"> | |||
| and wcubi.phone in (${phones}) | |||
| </if> | |||
| @@ -513,21 +512,26 @@ | |||
| )) | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and wcubi.id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != tagIds "> | |||
| and JSON_CONTAINS(JSON_ARRAY(wcut.tags),JSON_ARRAY | |||
| and wcubi.`tag_id` in | |||
| <foreach collection="tagIds" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| </foreach> | |||
| ) | |||
| </if> | |||
| <!-- <if test=" null != sortColumns">order by ${sortColumns}</if>--> | |||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | |||
| </sql> | |||
| <select id="findCountByFilter" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long"> | |||
| select count(distinct wcubi.id) from wx_c_user_basic_info wcubi | |||
| <if test=" null != tagIds "> | |||
| join wx_c_user_tags wcut on wcut.`id` = wcubi.`tag_id` | |||
| </if> | |||
| select count(distinct wcubi.id) | |||
| from wx_c_user_basic_info wcubi | |||
| <include refid="filterWhereConditions"/> | |||
| </select> | |||
| @@ -535,25 +539,18 @@ | |||
| <select id="findListByFilter" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultMap="BaseResultMap"> | |||
| select wcubi.`id`,wcubi.`phone`,wcubi.`email` | |||
| from wx_c_user_basic_info wcubi | |||
| <if test=" null != tagIds "> | |||
| join wx_c_user_tags wcut on wcut.`id` = wcubi.`tag_id` | |||
| </if> | |||
| <include refid="filterWhereConditions"/> | |||
| </select> | |||
| <select id="findOpenIdByFilter" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="String"> | |||
| select distinct open_id from wx_c_user where user_id in ( | |||
| <select id="findIdByFilter" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long"> | |||
| select id | |||
| from wx_c_user_basic_info wcubi | |||
| <if test=" null != tagIds "> | |||
| join wx_c_user_tags wcut on wcut.`id` = wcubi.`tag_id` | |||
| </if> | |||
| <include refid="filterWhereConditions"/> | |||
| ) | |||
| </select> | |||
| <select id="findGrowUserCount" resultType="java.lang.Long"> | |||
| SELECT count(wcubi.id) FROM wx_c_user_basic_info wcubi | |||
| SELECT count(wcubi.id) | |||
| FROM wx_c_user_basic_info wcubi | |||
| where wcubi.`final_tenant_id` = #{finalTenantId} | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and wcubi.`tenant_id` like concat('%,', #{tenantId},',%') | |||
| @@ -99,7 +99,8 @@ | |||
| </select> | |||
| <select id="countUser" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Integer"> | |||
| select count(DISTINCT ubi.id) from wx_c_user_car uc, wx_c_user_basic_info ubi | |||
| select count(DISTINCT ubi.id) | |||
| from wx_c_user_car uc, wx_c_user_basic_info ubi | |||
| where uc.c_user_id = ubi.id | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and uc.tenant_id = #{tenantId} | |||
| @@ -133,7 +133,8 @@ | |||
| </select> | |||
| <select id="visits" parameterType="com.iformall.domain.vo.WxCUserFromVo" resultType="com.iformall.domain.vo.WxCUserFromVo"> | |||
| select a.from_id fromId,a.from_type fromType,a.from_name fromName,a.from_phone fromPhone,IFNULL(a.visits,0) visits,IFNULL(b.reach_user,0) reachUser,IFNULL(c.new_user,0) newUser from ( | |||
| select a.from_id fromId,a.from_type fromType,a.from_name fromName,a.from_phone fromPhone,IFNULL(a.visits,0) visits,IFNULL(b.reach_user,0) reachUser,IFNULL(c.new_user,0) newUser | |||
| from ( | |||
| select wcuf.from_id,wcuf.from_type, | |||
| <if test=" fromType == 2 ">wcubi.nick_name from_name,wcubi.phone from_phone,</if> | |||
| <if test=" fromType == 5 ">wm.name from_name,wm.link_phone from_phone,</if> | |||
| @@ -242,6 +242,12 @@ | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != userIds "> | |||
| and user_id in | |||
| <foreach collection="userIds" index="index" item="userIdItem" open="(" separator="," close=")"> | |||
| #{userIdItem} | |||
| </foreach> | |||
| </if> | |||
| </select> | |||
| <update id="updateMsgCount" parameterType="com.iformall.domain.po.WxCUser"> | |||
| @@ -321,16 +327,16 @@ | |||
| </select> | |||
| <select id="findCountHistory" resultType="com.iformall.domain.vo.UserCountVo"> | |||
| <select id="findCountHistory" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="com.iformall.domain.vo.UserCountVo"> | |||
| select count(id) as incCount, | |||
| <if test="1 == reportType "> | |||
| date_format(create_date, '%Y-%m-%d') as reportTime, | |||
| date_format(create_date, '%Y-%m-%d') as reportTime | |||
| </if> | |||
| <if test="2 == reportType "> | |||
| date_format(create_date, '%Y-%m') as reportTime, | |||
| date_format(create_date, '%Y-%m') as reportTime | |||
| </if> | |||
| <if test="3 == reportType "> | |||
| date_format(create_date, '%Y') as reportTime, | |||
| date_format(create_date, '%Y') as reportTime | |||
| </if> | |||
| from wx_c_user | |||
| where `tenant_id` = #{tenantId} | |||
| @@ -392,11 +398,6 @@ | |||
| </if> | |||
| </select> | |||
| <select id="checkCountByTenantOpenId" resultType="hashmap" > | |||
| select * from (select tenant_id, open_id, count(tenant_id+open_id) as u_count from wx_c_user group by tenant_id, open_id) t where t.u_count >= 2 | |||
| </select> | |||
| <update id="updateUserId" parameterType="com.iformall.domain.po.WxCUser"> | |||
| update wx_c_user | |||
| set user_id=#{userId} | |||
| @@ -15,36 +15,25 @@ | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where 1 = 1 | |||
| where `tenant_id` = #{tenantId} | |||
| <if test=" null != id "> | |||
| and `id` = #{id} | |||
| </if> | |||
| <if test=" null != tenantId "> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != userId "> | |||
| and `user_id` = #{userId} | |||
| </if> | |||
| <if test=" null != tags "> | |||
| and `tags` like concat('%', #{tags},'%') | |||
| </if> | |||
| <if test=" null != createDate "> | |||
| and `create_date` = #{createDate} | |||
| </if> | |||
| <if test=" null != updateDate "> | |||
| and `update_date` = #{updateDate} | |||
| </if> | |||
| <if test=" null != userIdList "> | |||
| @@ -60,20 +49,36 @@ | |||
| #{idItem} | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != tagIdList "> | |||
| and JSON_CONTAINS(JSON_ARRAY(tags),JSON_ARRAY | |||
| <foreach collection="tagIdList" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| </foreach> | |||
| ) | |||
| </if> | |||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | |||
| </sql> | |||
| <select id="findList" parameterType="com.iformall.domain.po.WxCUserTags" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| from wx_c_user_tags | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| <select id="selectById" parameterType="java.util.HashMap" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns"/> from wx_c_user_tags where id = #{id} and tenant_id = #{tenantId} | |||
| select <include refid="allColumns"/> | |||
| from wx_c_user_tags | |||
| where id = #{id} and tenant_id = #{tenantId} | |||
| </select> | |||
| <delete id="deleteById" parameterType="java.util.HashMap"> | |||
| delete from wx_c_user_tags where id = #{id} and tenant_id = #{tenantId} | |||
| delete from wx_c_user_tags | |||
| where id = #{id} and tenant_id = #{tenantId} | |||
| </delete> | |||
| <select id="findList" parameterType="com.iformall.domain.po.WxCUserTags" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| <select id="findIdList" parameterType="java.util.HashMap" resultType="java.lang.Long"> | |||
| select id | |||
| from wx_c_user_tags | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| @@ -85,25 +90,15 @@ | |||
| and user_id = #{userId} | |||
| </update> | |||
| <select id="countUser" resultType="java.lang.Long"> | |||
| select count(cut.user_id) from wx_c_user_tags cut, wx_c_user_basic_info cubi | |||
| where cut.user_id = cubi.id | |||
| and cubi.final_tenant_id = #{finalTenantId} | |||
| <if test="null != tenantId"> | |||
| and cut.tenant_id = #{tenantId} | |||
| </if> | |||
| <if test=" null != startTime "> | |||
| and cubi.create_date >= #{startTime} | |||
| </if> | |||
| <if test=" null != endTime"> | |||
| and cubi.create_date < #{endTime} | |||
| </if> | |||
| <select id="findUserIdList" resultType="java.lang.Long"> | |||
| select distinct user_id | |||
| from wx_c_user_tags | |||
| where tenant_id = #{tenantId} | |||
| <if test=" null != tagIds"> | |||
| and JSON_CONTAINS(cut.tags,#{tagIds}) | |||
| </if> | |||
| </select> | |||
| </mapper> | |||
| @@ -1124,7 +1124,13 @@ | |||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | |||
| <if test=" null == sortColumns">order by co.create_date desc</if> | |||
| </select> | |||
| <select id="findVerifiedUserIds" parameterType="java.util.HashMap" resultType="java.lang.Long"> | |||
| select distinct c_user_id from wx_coupon_order | |||
| where `tenant_id` = #{tenantId} | |||
| and wco.coupon_order_status = 1 | |||
| and wco.update_date >= #{verifiedStartTime} | |||
| and wco.update_date <= #{verifiedEndTime} | |||
| </select> | |||
| </mapper> | |||