| @@ -2,6 +2,7 @@ package com.iformall.config; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.po.base.BaseCUserEntity; | |||||
| import com.iformall.domain.vo.WxCouponCVo; | import com.iformall.domain.vo.WxCouponCVo; | ||||
| import com.iformall.domain.vo.WxCouponChannelVo; | import com.iformall.domain.vo.WxCouponChannelVo; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| @@ -142,6 +143,23 @@ public class RedisConfig extends CachingConfigurerSupport { | |||||
| return template; | return template; | ||||
| } | } | ||||
| @Bean("baseCUserTokenRedisTemplate") | |||||
| public RedisTemplate<String, BaseCUserEntity> getBaseCUserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
| RedisTemplate<String, BaseCUserEntity> template = new RedisTemplate<String, BaseCUserEntity>(); | |||||
| Jackson2JsonRedisSerializer<BaseCUserEntity> j = new Jackson2JsonRedisSerializer<BaseCUserEntity>(BaseCUserEntity.class); | |||||
| // value值的序列化 | |||||
| template.setValueSerializer(j); | |||||
| template.setHashKeySerializer(j); | |||||
| // key的序列化 | |||||
| template.setKeySerializer(new StringRedisSerializer()); | |||||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||||
| template.setConnectionFactory(connectionFactory); | |||||
| return template; | |||||
| } | |||||
| @Bean("mallRedisTemplate") | @Bean("mallRedisTemplate") | ||||
| public RedisTemplate<String, WxMall> getMallRedisTemplate(RedisConnectionFactory connectionFactory) { | public RedisTemplate<String, WxMall> getMallRedisTemplate(RedisConnectionFactory connectionFactory) { | ||||
| RedisTemplate<String, WxMall> template = new RedisTemplate<String, WxMall>(); | RedisTemplate<String, WxMall> template = new RedisTemplate<String, WxMall>(); | ||||
| @@ -122,7 +122,7 @@ public class WxUserStructureController extends BaseController { | |||||
| for( int i = 0; i < levelList.size(); i++) { | for( int i = 0; i < levelList.size(); i++) { | ||||
| WxCUserBasicInfoDto dto = new WxCUserBasicInfoDto(); | WxCUserBasicInfoDto dto = new WxCUserBasicInfoDto(); | ||||
| dto.updateFinalTenantInfo(getTenantInfo()); | |||||
| dto.updateTenantInfo(getTenantInfo()); | |||||
| dto.setStartTime(startTime); | dto.setStartTime(startTime); | ||||
| dto.setEndTime(endTime); | dto.setEndTime(endTime); | ||||
| if (i + 1 < levelList.size()) { | if (i + 1 < levelList.size()) { | ||||
| @@ -7,7 +7,6 @@ import cn.afterturn.easypoi.handler.impl.ExcelDataHandlerDefaultImpl; | |||||
| import cn.afterturn.easypoi.handler.inter.IExcelDataHandler; | import cn.afterturn.easypoi.handler.inter.IExcelDataHandler; | ||||
| import com.iformall.domain.po.MallUserInfo; | import com.iformall.domain.po.MallUserInfo; | ||||
| import com.iformall.domain.po.WxTags; | import com.iformall.domain.po.WxTags; | ||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.domain.vo.CUserBaseInfoT; | import com.iformall.domain.vo.CUserBaseInfoT; | ||||
| import com.iformall.service.WxCUserBasicInfoService; | import com.iformall.service.WxCUserBasicInfoService; | ||||
| import com.iformall.service.WxTagsService; | import com.iformall.service.WxTagsService; | ||||
| @@ -148,7 +148,7 @@ public class WxCUserBasicInfoController extends BaseController { | |||||
| } | } | ||||
| } | } | ||||
| wxCUserBasicInfo.updateTenantInfo(getTenantInfo()); | wxCUserBasicInfo.updateTenantInfo(getTenantInfo()); | ||||
| wxCUserBasicInfo.setSortColumns(BaseEntity.SortField.ActiveTime_DESC); | |||||
| // wxCUserBasicInfo.setSortColumns(BaseEntity.SortField.ActiveTime_DESC); | |||||
| PageInfo<WxCUserBasicInfo> page = wxCUserBasicInfoService.listAsPage(wxCUserBasicInfo, pageNum, pageSize); | PageInfo<WxCUserBasicInfo> page = wxCUserBasicInfoService.listAsPage(wxCUserBasicInfo, pageNum, pageSize); | ||||
| if (page.getSize() > 0) { | if (page.getSize() > 0) { | ||||
| @@ -47,10 +47,11 @@ public class WxLevelConfigController extends BaseController { | |||||
| public ResultData list(@ModelAttribute WxLevelConfig wxLevelConfig, Integer pageNum, Integer pageSize) { | public ResultData list(@ModelAttribute WxLevelConfig wxLevelConfig, Integer pageNum, Integer pageSize) { | ||||
| logger.debug("[" + getIpAddr() + "] WxLevelConfigController::list"); | logger.debug("[" + getIpAddr() + "] WxLevelConfigController::list"); | ||||
| if (null == wxLevelConfig) wxLevelConfig = new WxLevelConfig(); | if (null == wxLevelConfig) wxLevelConfig = new WxLevelConfig(); | ||||
| if(StringUtils.isNotBlank(getTenantInfo().getParentTenantId())){ | |||||
| wxLevelConfig.setTenantId(getTenantInfo().getParentTenantId()); | |||||
| TenantEntity tenantEntity = ifParentUpdateTenantInfo(); | |||||
| if(StringUtils.isNotBlank(tenantEntity.getParentTenantId())){ | |||||
| wxLevelConfig.setTenantId(tenantEntity.getParentTenantId()); | |||||
| }else{ | }else{ | ||||
| wxLevelConfig.setTenantId(getTenantInfo().getTenantId()); | |||||
| wxLevelConfig.setTenantId(tenantEntity.getTenantId()); | |||||
| } | } | ||||
| wxLevelConfig.setSortColumns(BaseEntity.SortField.Points_ASC); | wxLevelConfig.setSortColumns(BaseEntity.SortField.Points_ASC); | ||||
| final PageInfo<WxLevelConfig> page = wxLevelConfigService.listAsPage(wxLevelConfig, pageNum, pageSize); | final PageInfo<WxLevelConfig> page = wxLevelConfigService.listAsPage(wxLevelConfig, pageNum, pageSize); | ||||
| @@ -63,10 +64,11 @@ public class WxLevelConfigController extends BaseController { | |||||
| public ResultData add(@RequestBody List<WxLevelConfig> levelConfigs) { | public ResultData add(@RequestBody List<WxLevelConfig> levelConfigs) { | ||||
| logger.debug("[" + getIpAddr() + "] WxLevelConfigController::add"); | logger.debug("[" + getIpAddr() + "] WxLevelConfigController::add"); | ||||
| try { | try { | ||||
| if (StringUtils.isNotBlank(getTenantInfo().getParentTenantId())) { | |||||
| if (StringUtils.isNotBlank(ifParentUpdateTenantInfo().getParentTenantId())) { | |||||
| return new ResultData(ErrorCode.USER_NO_PERMISSION.getCode(), "广场用户无此权限"); | return new ResultData(ErrorCode.USER_NO_PERMISSION.getCode(), "广场用户无此权限"); | ||||
| } | } | ||||
| wxLevelConfigService.batchSave(getTenantInfo(), levelConfigs); | |||||
| wxLevelConfigService.batchSave(ifParentUpdateTenantInfo(), levelConfigs); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error(e.getMessage()); | logger.error(e.getMessage()); | ||||
| return new ResultData(ErrorCode.DB_FAIL); | return new ResultData(ErrorCode.DB_FAIL); | ||||
| @@ -80,10 +82,10 @@ public class WxLevelConfigController extends BaseController { | |||||
| public ResultData updateCapabilities(@RequestBody List<WxLevelConfig> levelConfigs) { | public ResultData updateCapabilities(@RequestBody List<WxLevelConfig> levelConfigs) { | ||||
| logger.debug("[" + getIpAddr() + "] WxLevelConfigController::add"); | logger.debug("[" + getIpAddr() + "] WxLevelConfigController::add"); | ||||
| try { | try { | ||||
| if (StringUtils.isNotBlank(getTenantInfo().getParentTenantId())) { | |||||
| if (StringUtils.isNotBlank(ifParentUpdateTenantInfo().getParentTenantId())) { | |||||
| return new ResultData(ErrorCode.USER_NO_PERMISSION.getCode(), "广场用户无此权限"); | return new ResultData(ErrorCode.USER_NO_PERMISSION.getCode(), "广场用户无此权限"); | ||||
| } | } | ||||
| wxLevelConfigService.batchUpdateCapabilities(getTenantInfo(), levelConfigs); | |||||
| wxLevelConfigService.batchUpdateCapabilities(ifParentUpdateTenantInfo(), levelConfigs); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error(e.getMessage()); | logger.error(e.getMessage()); | ||||
| return new ResultData(ErrorCode.DB_FAIL); | return new ResultData(ErrorCode.DB_FAIL); | ||||
| @@ -30,7 +30,7 @@ public class WxScoreRulesController extends BaseController { | |||||
| @SystemControllerLog(description = "成长值-配置") | @SystemControllerLog(description = "成长值-配置") | ||||
| public ResultData list() { | public ResultData list() { | ||||
| logger.debug("[" + getIpAddr() + "] WxScoreRulesController::list"); | logger.debug("[" + getIpAddr() + "] WxScoreRulesController::list"); | ||||
| WxScoreRules scoreRules = wxScoreRulesService.getScoreRules(getTenantInfo()); | |||||
| WxScoreRules scoreRules = wxScoreRulesService.getScoreRules(ifParentUpdateTenantInfo()); | |||||
| if (scoreRules.getCreditLocked() == null) { | if (scoreRules.getCreditLocked() == null) { | ||||
| scoreRules.setCreditLocked(EnumCreditLockedStatus.OPEN.getCode()); | scoreRules.setCreditLocked(EnumCreditLockedStatus.OPEN.getCode()); | ||||
| } | } | ||||
| @@ -42,7 +42,7 @@ public class WxScoreRulesController extends BaseController { | |||||
| @SystemControllerLog(description = "成长值-积分-配置-新增") | @SystemControllerLog(description = "成长值-积分-配置-新增") | ||||
| public ResultData add(@RequestBody WxScoreRules wxScoreRules) { | public ResultData add(@RequestBody WxScoreRules wxScoreRules) { | ||||
| logger.debug("[" + getIpAddr() + "] WxScoreRulesController::add"); | logger.debug("[" + getIpAddr() + "] WxScoreRulesController::add"); | ||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| TenantEntity tenantEntity = ifParentUpdateTenantInfo(); | |||||
| if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) { | if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) { | ||||
| return new ResultData(ErrorCode.USER_NO_PERMISSION.getCode(), "广场用户无此权限"); | return new ResultData(ErrorCode.USER_NO_PERMISSION.getCode(), "广场用户无此权限"); | ||||
| } | } | ||||
| @@ -56,7 +56,7 @@ public class WxScoreRulesController extends BaseController { | |||||
| @SystemControllerLog(description = "积分-配置") | @SystemControllerLog(description = "积分-配置") | ||||
| public ResultData creditRulesList() { | public ResultData creditRulesList() { | ||||
| logger.debug("[" + getIpAddr() + "] WxScoreRulesController::list"); | logger.debug("[" + getIpAddr() + "] WxScoreRulesController::list"); | ||||
| WxScoreRules scoreRules = wxScoreRulesService.getCreditRules(getTenantInfo()); | |||||
| WxScoreRules scoreRules = wxScoreRulesService.getCreditRules(ifParentUpdateTenantInfo()); | |||||
| return new ResultData(scoreRules); | return new ResultData(scoreRules); | ||||
| } | } | ||||
| @@ -71,7 +71,7 @@ public class WxScoreRulesController extends BaseController { | |||||
| if (null == wxScoreRules.getCreditLocked()) { | if (null == wxScoreRules.getCreditLocked()) { | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "creditLocked不能为空"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "creditLocked不能为空"); | ||||
| } | } | ||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| TenantEntity tenantEntity = ifParentUpdateTenantInfo(); | |||||
| if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) { | if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) { | ||||
| return new ResultData(ErrorCode.USER_NO_PERMISSION.getCode(), "广场用户无此权限"); | return new ResultData(ErrorCode.USER_NO_PERMISSION.getCode(), "广场用户无此权限"); | ||||
| } | } | ||||
| @@ -41,5 +41,7 @@ ADD COLUMN `plat` SMALLINT(3) NOT NULL DEFAULT 1 COMMENT 'app平台 1:微信 2: | |||||
| ALTER TABLE `wx_profit_sharing_receiver` | ALTER TABLE `wx_profit_sharing_receiver` | ||||
| ADD COLUMN `plat` SMALLINT(3) NOT NULL DEFAULT 1 COMMENT '平台 1:微信 2:阿里 3:头条'; | ADD COLUMN `plat` SMALLINT(3) NOT NULL DEFAULT 1 COMMENT '平台 1:微信 2:阿里 3:头条'; | ||||
| update mall_sale_type set menus = '[1, 2, 5, 6, 8, 10, 50, 101, 102, 104, 105, 106, 108, 203, 204, 206, 207, 501, 502, 503, 504, 505, 506, 507, 511, 512, 522, 523, 509, 591, 595, 601, 621, 622, 623, 624, 625, 626, 627, 901, 902]' where id=100 | |||||
| @@ -2,6 +2,7 @@ package com.iformall.config; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.po.base.BaseCUserEntity; | |||||
| import com.iformall.domain.vo.WxCouponCVo; | import com.iformall.domain.vo.WxCouponCVo; | ||||
| import com.iformall.domain.vo.WxCouponChannelVo; | import com.iformall.domain.vo.WxCouponChannelVo; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| @@ -107,6 +108,23 @@ public class RedisConfig extends CachingConfigurerSupport { | |||||
| return template; | return template; | ||||
| } | } | ||||
| @Bean("baseCUserTokenRedisTemplate") | |||||
| public RedisTemplate<String, BaseCUserEntity> getBaseCUserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
| RedisTemplate<String, BaseCUserEntity> template = new RedisTemplate<String, BaseCUserEntity>(); | |||||
| Jackson2JsonRedisSerializer<BaseCUserEntity> j = new Jackson2JsonRedisSerializer<BaseCUserEntity>(BaseCUserEntity.class); | |||||
| // value值的序列化 | |||||
| template.setValueSerializer(j); | |||||
| template.setHashKeySerializer(j); | |||||
| // key的序列化 | |||||
| template.setKeySerializer(new StringRedisSerializer()); | |||||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||||
| template.setConnectionFactory(connectionFactory); | |||||
| return template; | |||||
| } | |||||
| @Bean("mallRedisTemplate") | @Bean("mallRedisTemplate") | ||||
| public RedisTemplate<String, WxMall> getMallRedisTemplate(RedisConnectionFactory connectionFactory) { | public RedisTemplate<String, WxMall> getMallRedisTemplate(RedisConnectionFactory connectionFactory) { | ||||
| RedisTemplate<String, WxMall> template = new RedisTemplate<String, WxMall>(); | RedisTemplate<String, WxMall> template = new RedisTemplate<String, WxMall>(); | ||||
| @@ -4,7 +4,8 @@ package com.iformall.aop; | |||||
| import com.alibaba.fastjson.JSONObject; | import com.alibaba.fastjson.JSONObject; | ||||
| import com.iformall.annotation.RedisCache; | import com.iformall.annotation.RedisCache; | ||||
| import com.iformall.domain.po.WxCUser; | import com.iformall.domain.po.WxCUser; | ||||
| import com.iformall.service.WxCUserTokenService; | |||||
| import com.iformall.domain.po.base.BaseCUserEntity; | |||||
| import com.iformall.service.CUserTokenService; | |||||
| import com.iformall.utils.HashUtil; | import com.iformall.utils.HashUtil; | ||||
| import com.iformall.utils.RedisLock; | import com.iformall.utils.RedisLock; | ||||
| import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
| @@ -48,7 +49,7 @@ public class RedisCacheAspect { | |||||
| RedisLock redisLock; | RedisLock redisLock; | ||||
| @Autowired | @Autowired | ||||
| private WxCUserTokenService userTokenService; | |||||
| private CUserTokenService cUserTokenService; | |||||
| @Pointcut("@annotation(com.iformall.annotation.RedisCache)") | @Pointcut("@annotation(com.iformall.annotation.RedisCache)") | ||||
| public void cacheAspect() { | public void cacheAspect() { | ||||
| @@ -66,14 +67,14 @@ public class RedisCacheAspect { | |||||
| } | } | ||||
| log.info("token>>>>>>>>>>>>>>>"+token); | log.info("token>>>>>>>>>>>>>>>"+token); | ||||
| String tenantId; | String tenantId; | ||||
| WxCUser wxCUser = null ; | |||||
| BaseCUserEntity cUser = null ; | |||||
| if(StringUtils.isNotBlank(token)) { | if(StringUtils.isNotBlank(token)) { | ||||
| wxCUser = userTokenService.getByToken(token); | |||||
| cUser = cUserTokenService.getByToken(token); | |||||
| } | } | ||||
| if (Objects.isNull(wxCUser) || wxCUser.getExpireTime().getTime() < System.currentTimeMillis()) { | |||||
| if (Objects.isNull(cUser) || cUser.getExpireTime().getTime() < System.currentTimeMillis()) { | |||||
| tenantId = "0"; | tenantId = "0"; | ||||
| } else { | } else { | ||||
| tenantId = wxCUser.getTenantId(); | |||||
| tenantId = cUser.getTenantId(); | |||||
| } | } | ||||
| // 请求参数 | // 请求参数 | ||||
| @@ -2,6 +2,7 @@ package com.iformall.config; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.po.base.BaseCUserEntity; | |||||
| import com.iformall.domain.vo.WxCouponCVo; | import com.iformall.domain.vo.WxCouponCVo; | ||||
| import com.iformall.domain.vo.WxCouponChannelVo; | import com.iformall.domain.vo.WxCouponChannelVo; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| @@ -106,6 +107,23 @@ public class RedisConfig extends CachingConfigurerSupport { | |||||
| template.setConnectionFactory(connectionFactory); | template.setConnectionFactory(connectionFactory); | ||||
| return template; | return template; | ||||
| } | } | ||||
| @Bean("baseCUserTokenRedisTemplate") | |||||
| public RedisTemplate<String, BaseCUserEntity> getBaseCUserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
| RedisTemplate<String, BaseCUserEntity> template = new RedisTemplate<String, BaseCUserEntity>(); | |||||
| Jackson2JsonRedisSerializer<BaseCUserEntity> j = new Jackson2JsonRedisSerializer<BaseCUserEntity>(BaseCUserEntity.class); | |||||
| // value值的序列化 | |||||
| template.setValueSerializer(j); | |||||
| template.setHashKeySerializer(j); | |||||
| // key的序列化 | |||||
| template.setKeySerializer(new StringRedisSerializer()); | |||||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||||
| template.setConnectionFactory(connectionFactory); | |||||
| return template; | |||||
| } | |||||
| @Bean("cUserBasicInfoRedisTemplate") | @Bean("cUserBasicInfoRedisTemplate") | ||||
| public RedisTemplate<String, WxCUserBasicInfo> getCUserBasicInfoRedisTemplate(RedisConnectionFactory connectionFactory) { | public RedisTemplate<String, WxCUserBasicInfo> getCUserBasicInfoRedisTemplate(RedisConnectionFactory connectionFactory) { | ||||
| @@ -3,6 +3,7 @@ package com.iformall.controller; | |||||
| import cn.binarywang.wx.miniapp.api.WxMaService; | import cn.binarywang.wx.miniapp.api.WxMaService; | ||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.IdWorker; | import com.iformall.common.IdWorker; | ||||
| import com.iformall.domain.po.base.BaseCUserEntity; | |||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.domain.po.WxAppinfo; | import com.iformall.domain.po.WxAppinfo; | ||||
| import com.iformall.domain.po.WxCUser; | import com.iformall.domain.po.WxCUser; | ||||
| @@ -30,8 +31,6 @@ import java.beans.PropertyEditorSupport; | |||||
| import java.text.ParseException; | import java.text.ParseException; | ||||
| import java.text.SimpleDateFormat; | import java.text.SimpleDateFormat; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.List; | |||||
| import java.util.Objects; | |||||
| @RestController | @RestController | ||||
| public class BaseController { | public class BaseController { | ||||
| @@ -51,8 +50,8 @@ public class BaseController { | |||||
| private WxCUserBasicInfoService wxCUserBasicInfoService; | private WxCUserBasicInfoService wxCUserBasicInfoService; | ||||
| @Autowired | @Autowired | ||||
| @Qualifier("cuserTokenRedisTemplate") | |||||
| RedisTemplate<String, WxCUser> cUserTokenRedisTemplate; | |||||
| @Qualifier("baseCUserTokenRedisTemplate") | |||||
| RedisTemplate<String, BaseCUserEntity> baseCUserTokenRedisTemplate; | |||||
| @InitBinder | @InitBinder | ||||
| public void InitBinder(WebDataBinder dataBinder) { | public void InitBinder(WebDataBinder dataBinder) { | ||||
| @@ -30,12 +30,6 @@ public class WxMsgValidationcodeController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| private WxMsgValidationcodeService wxMsgValidationcodeService; | private WxMsgValidationcodeService wxMsgValidationcodeService; | ||||
| @Autowired | |||||
| private WxMerchantBUserService wxMerchantBUserService; | |||||
| @Autowired | |||||
| private WxMerchantService wxMerchantService; | |||||
| @Autowired | @Autowired | ||||
| private WxCUserService wxCUserService; | private WxCUserService wxCUserService; | ||||
| @@ -95,8 +89,8 @@ public class WxMsgValidationcodeController extends BaseController { | |||||
| wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_PHONE,user); | wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_PHONE,user); | ||||
| String key = Constant.tokenPrev + user.getOpenId(); | String key = Constant.tokenPrev + user.getOpenId(); | ||||
| if(cUserTokenRedisTemplate.hasKey(key)){ | |||||
| cUserTokenRedisTemplate.delete(key); | |||||
| if(baseCUserTokenRedisTemplate.hasKey(key)){ | |||||
| baseCUserTokenRedisTemplate.delete(key); | |||||
| } | } | ||||
| } | } | ||||
| return rd; | return rd; | ||||
| @@ -29,8 +29,6 @@ import org.apache.commons.lang3.StringUtils; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.beans.factory.annotation.Qualifier; | |||||
| import org.springframework.data.redis.core.RedisTemplate; | |||||
| import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||
| import org.springframework.web.context.request.RequestContextHolder; | import org.springframework.web.context.request.RequestContextHolder; | ||||
| import org.springframework.web.context.request.ServletRequestAttributes; | import org.springframework.web.context.request.ServletRequestAttributes; | ||||
| @@ -55,9 +53,6 @@ public class WxUserGrantController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| private boolean isFmOpen; | private boolean isFmOpen; | ||||
| @Autowired | |||||
| private WxCUserTokenService userTokenService; | |||||
| @Autowired | @Autowired | ||||
| private WxCUserService wxCUserService; | private WxCUserService wxCUserService; | ||||
| @@ -334,7 +329,7 @@ public class WxUserGrantController extends BaseController { | |||||
| } | } | ||||
| oldUser.setLoginCount(oldUser.getLoginCount() + 1); | oldUser.setLoginCount(oldUser.getLoginCount() + 1); | ||||
| userTokenService.saveOrUpdate(oldUser); | |||||
| wxCUserService.saveOrUpdate(oldUser); | |||||
| // 登录后处理 | // 登录后处理 | ||||
| int score = wxCUserService.actionAfterLogin(oldUser, boolFindByUnionId); | int score = wxCUserService.actionAfterLogin(oldUser, boolFindByUnionId); | ||||
| @@ -371,7 +366,7 @@ public class WxUserGrantController extends BaseController { | |||||
| } | } | ||||
| newUser.setLoginCount(1); | newUser.setLoginCount(1); | ||||
| userTokenService.saveOrUpdate(newUser); | |||||
| wxCUserService.saveOrUpdate(newUser); | |||||
| resultMap.put("token", token); | resultMap.put("token", token); | ||||
| request.setAttribute(Constant.LOGIN_USER_KEY, newUser.getId()); | request.setAttribute(Constant.LOGIN_USER_KEY, newUser.getId()); | ||||
| @@ -418,7 +413,7 @@ public class WxUserGrantController extends BaseController { | |||||
| request.setAttribute(Constant.TENANT_ID, tenantId); | request.setAttribute(Constant.TENANT_ID, tenantId); | ||||
| request.setAttribute(Constant.PARENT_TENANT_ID, parentTenantId); | request.setAttribute(Constant.PARENT_TENANT_ID, parentTenantId); | ||||
| user.setTenantId(tenantId); | user.setTenantId(tenantId); | ||||
| userTokenService.saveOrUpdate(user); | |||||
| wxCUserService.saveOrUpdate(user); | |||||
| } | } | ||||
| return new ResultData(); | return new ResultData(); | ||||
| @@ -561,8 +556,8 @@ public class WxUserGrantController extends BaseController { | |||||
| wxCUserService.saveOrUpdate(updateUser); | wxCUserService.saveOrUpdate(updateUser); | ||||
| String key = Constant.tokenPrev + user.getOpenId(); | String key = Constant.tokenPrev + user.getOpenId(); | ||||
| if(cUserTokenRedisTemplate.hasKey(key)){ | |||||
| cUserTokenRedisTemplate.delete(key); | |||||
| if(baseCUserTokenRedisTemplate.hasKey(key)){ | |||||
| baseCUserTokenRedisTemplate.delete(key); | |||||
| } | } | ||||
| if(bFirstNickName) { | if(bFirstNickName) { | ||||
| @@ -666,8 +661,8 @@ public class WxUserGrantController extends BaseController { | |||||
| wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_PHONE, user); | wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_PHONE, user); | ||||
| } | } | ||||
| String key = Constant.tokenPrev + user.getOpenId(); | String key = Constant.tokenPrev + user.getOpenId(); | ||||
| if(cUserTokenRedisTemplate.hasKey(key)){ | |||||
| cUserTokenRedisTemplate.delete(key); | |||||
| if(baseCUserTokenRedisTemplate.hasKey(key)){ | |||||
| baseCUserTokenRedisTemplate.delete(key); | |||||
| } | } | ||||
| if(isFirstPhone) { | if(isFirstPhone) { | ||||
| @@ -5,9 +5,9 @@ import com.iformall.annotation.AuthIgnore; | |||||
| import com.iformall.annotation.TenantIgnore; | import com.iformall.annotation.TenantIgnore; | ||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.TenantThreadLocal; | import com.iformall.common.TenantThreadLocal; | ||||
| import com.iformall.domain.po.WxCUser; | |||||
| import com.iformall.domain.po.base.BaseCUserEntity; | |||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.service.WxCUserTokenService; | |||||
| import com.iformall.service.CUserTokenService; | |||||
| import com.iformall.utils.Constant; | import com.iformall.utils.Constant; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| @@ -27,7 +27,7 @@ import javax.servlet.http.HttpServletResponse; | |||||
| @Component | @Component | ||||
| public class AuthorizationInterceptor extends HandlerInterceptorAdapter { | public class AuthorizationInterceptor extends HandlerInterceptorAdapter { | ||||
| @Autowired | @Autowired | ||||
| private WxCUserTokenService userTokenService; | |||||
| private CUserTokenService cUserTokenService; | |||||
| @Override | @Override | ||||
| public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { | ||||
| @@ -59,22 +59,21 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { | |||||
| } | } | ||||
| // 查询token信息 | // 查询token信息 | ||||
| WxCUser wxCUser = userTokenService.getByToken(token); | |||||
| if(wxCUser == null || wxCUser.getExpireTime().getTime() < System.currentTimeMillis()){ | |||||
| BaseCUserEntity cUser = cUserTokenService.getByToken(token); | |||||
| if(cUser == null || cUser.getExpireTime().getTime() < System.currentTimeMillis()){ | |||||
| throw new MallinkException(ErrorCode.NET_TOKEN_INVALID.getCode(), "URL:" + request.getRequestURL() + " token失效,请重新登录"); | throw new MallinkException(ErrorCode.NET_TOKEN_INVALID.getCode(), "URL:" + request.getRequestURL() + " token失效,请重新登录"); | ||||
| } | } | ||||
| //设置userId到request里,后续根据userId,获取用户信息 | //设置userId到request里,后续根据userId,获取用户信息 | ||||
| request.setAttribute(Constant.LOGIN_USER_KEY, wxCUser.getId()); | |||||
| request.setAttribute(Constant.TENANT_ID, wxCUser.getTenantId()); | |||||
| if (StringUtils.isNotBlank(wxCUser.getParentTenantId())) { | |||||
| request.setAttribute(Constant.PARENT_TENANT_ID, wxCUser.getParentTenantId()); | |||||
| request.setAttribute(Constant.LOGIN_USER_KEY, cUser.getId()); | |||||
| request.setAttribute(Constant.TENANT_ID, cUser.getTenantId()); | |||||
| if (StringUtils.isNotBlank(cUser.getParentTenantId())) { | |||||
| request.setAttribute(Constant.PARENT_TENANT_ID, cUser.getParentTenantId()); | |||||
| } | } | ||||
| if(wxCUser.isBasicInfo()){ | |||||
| request.setAttribute(Constant.LOGIN_MEMBER_KEY, wxCUser.getUserId()); | |||||
| if(cUser.isBasicInfo()){ | |||||
| request.setAttribute(Constant.LOGIN_MEMBER_KEY, cUser.getUserId()); | |||||
| } | } | ||||
| //如果是要不需要自动设置tenantI信息 | //如果是要不需要自动设置tenantI信息 | ||||
| TenantIgnore tenantIgnoreAnnotation = null; | TenantIgnore tenantIgnoreAnnotation = null; | ||||
| if(handler instanceof HandlerMethod) { | if(handler instanceof HandlerMethod) { | ||||
| @@ -85,9 +84,8 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { | |||||
| if(tenantIgnoreAnnotation != null){ | if(tenantIgnoreAnnotation != null){ | ||||
| TenantThreadLocal.remove(); | TenantThreadLocal.remove(); | ||||
| }else { | }else { | ||||
| TenantThreadLocal.setCurrentThreadTenant(wxCUser.getTenantId(), wxCUser.getParentTenantId()); | |||||
| TenantThreadLocal.setCurrentThreadTenant(cUser.getTenantId(), cUser.getParentTenantId()); | |||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| @@ -1,8 +1,8 @@ | |||||
| package com.iformall.resolver; | package com.iformall.resolver; | ||||
| import com.iformall.annotation.LoginUser; | import com.iformall.annotation.LoginUser; | ||||
| import com.iformall.domain.po.WxCUser; | |||||
| import com.iformall.service.WxCUserTokenService; | |||||
| import com.iformall.domain.po.base.BaseCUserEntity; | |||||
| import com.iformall.service.CUserTokenService; | |||||
| import com.iformall.utils.Constant; | import com.iformall.utils.Constant; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.core.MethodParameter; | import org.springframework.core.MethodParameter; | ||||
| @@ -22,11 +22,11 @@ import org.springframework.web.method.support.ModelAndViewContainer; | |||||
| @Component | @Component | ||||
| public class LoginUserHandlerMethodArgumentResolver implements HandlerMethodArgumentResolver { | public class LoginUserHandlerMethodArgumentResolver implements HandlerMethodArgumentResolver { | ||||
| @Autowired | @Autowired | ||||
| private WxCUserTokenService userTokenService; | |||||
| private CUserTokenService cUserTokenService; | |||||
| @Override | @Override | ||||
| public boolean supportsParameter(MethodParameter parameter) { | public boolean supportsParameter(MethodParameter parameter) { | ||||
| return parameter.getParameterType().isAssignableFrom(WxCUser.class) && parameter.hasParameterAnnotation(LoginUser.class); | |||||
| return parameter.getParameterType().isAssignableFrom(BaseCUserEntity.class) && parameter.hasParameterAnnotation(LoginUser.class); | |||||
| } | } | ||||
| @Override | @Override | ||||
| @@ -39,7 +39,7 @@ public class LoginUserHandlerMethodArgumentResolver implements HandlerMethodArgu | |||||
| } | } | ||||
| //获取用户信息 | //获取用户信息 | ||||
| WxCUser user = userTokenService.getByToken((String)object); | |||||
| BaseCUserEntity user = cUserTokenService.getByToken((String)object); | |||||
| return user; | return user; | ||||
| } | } | ||||
| @@ -2,6 +2,7 @@ package com.iformall.config; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.po.base.BaseCUserEntity; | |||||
| import com.iformall.domain.vo.WxCouponCVo; | import com.iformall.domain.vo.WxCouponCVo; | ||||
| import com.iformall.domain.vo.WxCouponChannelVo; | import com.iformall.domain.vo.WxCouponChannelVo; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| @@ -142,6 +143,23 @@ public class RedisConfig extends CachingConfigurerSupport { | |||||
| return template; | return template; | ||||
| } | } | ||||
| @Bean("baseCUserTokenRedisTemplate") | |||||
| public RedisTemplate<String, BaseCUserEntity> getBaseCUserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
| RedisTemplate<String, BaseCUserEntity> template = new RedisTemplate<String, BaseCUserEntity>(); | |||||
| Jackson2JsonRedisSerializer<BaseCUserEntity> j = new Jackson2JsonRedisSerializer<BaseCUserEntity>(BaseCUserEntity.class); | |||||
| // value值的序列化 | |||||
| template.setValueSerializer(j); | |||||
| template.setHashKeySerializer(j); | |||||
| // key的序列化 | |||||
| template.setKeySerializer(new StringRedisSerializer()); | |||||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||||
| template.setConnectionFactory(connectionFactory); | |||||
| return template; | |||||
| } | |||||
| @Bean("cUserBasicInfoRedisTemplate") | @Bean("cUserBasicInfoRedisTemplate") | ||||
| public RedisTemplate<String, WxCUserBasicInfo> getCUserBasicInfoRedisTemplate(RedisConnectionFactory connectionFactory) { | public RedisTemplate<String, WxCUserBasicInfo> getCUserBasicInfoRedisTemplate(RedisConnectionFactory connectionFactory) { | ||||
| RedisTemplate<String, WxCUserBasicInfo> template = new RedisTemplate<String, WxCUserBasicInfo>(); | RedisTemplate<String, WxCUserBasicInfo> template = new RedisTemplate<String, WxCUserBasicInfo>(); | ||||
| @@ -2,6 +2,7 @@ package com.iformall.config; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.po.base.BaseCUserEntity; | |||||
| import com.iformall.domain.vo.WxCouponCVo; | import com.iformall.domain.vo.WxCouponCVo; | ||||
| import com.iformall.domain.vo.WxCouponChannelVo; | import com.iformall.domain.vo.WxCouponChannelVo; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| @@ -127,6 +128,23 @@ public class RedisConfig extends CachingConfigurerSupport { | |||||
| return template; | return template; | ||||
| } | } | ||||
| @Bean("baseCUserTokenRedisTemplate") | |||||
| public RedisTemplate<String, BaseCUserEntity> getBaseCUserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
| RedisTemplate<String, BaseCUserEntity> template = new RedisTemplate<String, BaseCUserEntity>(); | |||||
| Jackson2JsonRedisSerializer<BaseCUserEntity> j = new Jackson2JsonRedisSerializer<BaseCUserEntity>(BaseCUserEntity.class); | |||||
| // value值的序列化 | |||||
| template.setValueSerializer(j); | |||||
| template.setHashKeySerializer(j); | |||||
| // key的序列化 | |||||
| template.setKeySerializer(new StringRedisSerializer()); | |||||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||||
| template.setConnectionFactory(connectionFactory); | |||||
| return template; | |||||
| } | |||||
| @Bean("cUserBasicInfoRedisTemplate") | @Bean("cUserBasicInfoRedisTemplate") | ||||
| public RedisTemplate<String, WxCUserBasicInfo> getCUserBasicInfoRedisTemplate(RedisConnectionFactory connectionFactory) { | public RedisTemplate<String, WxCUserBasicInfo> getCUserBasicInfoRedisTemplate(RedisConnectionFactory connectionFactory) { | ||||
| RedisTemplate<String, WxCUserBasicInfo> template = new RedisTemplate<String, WxCUserBasicInfo>(); | RedisTemplate<String, WxCUserBasicInfo> template = new RedisTemplate<String, WxCUserBasicInfo>(); | ||||
| @@ -2,6 +2,7 @@ package com.iformall.config; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.po.base.BaseCUserEntity; | |||||
| import com.iformall.domain.vo.WxCouponCVo; | import com.iformall.domain.vo.WxCouponCVo; | ||||
| import com.iformall.domain.vo.WxCouponChannelVo; | import com.iformall.domain.vo.WxCouponChannelVo; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| @@ -105,6 +106,23 @@ public class RedisConfig extends CachingConfigurerSupport { | |||||
| return template; | return template; | ||||
| } | } | ||||
| @Bean("baseCUserTokenRedisTemplate") | |||||
| public RedisTemplate<String, BaseCUserEntity> getBaseCUserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
| RedisTemplate<String, BaseCUserEntity> template = new RedisTemplate<String, BaseCUserEntity>(); | |||||
| Jackson2JsonRedisSerializer<BaseCUserEntity> j = new Jackson2JsonRedisSerializer<BaseCUserEntity>(BaseCUserEntity.class); | |||||
| // value值的序列化 | |||||
| template.setValueSerializer(j); | |||||
| template.setHashKeySerializer(j); | |||||
| // key的序列化 | |||||
| template.setKeySerializer(new StringRedisSerializer()); | |||||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||||
| template.setConnectionFactory(connectionFactory); | |||||
| return template; | |||||
| } | |||||
| @Bean("cUserBasicInfoRedisTemplate") | @Bean("cUserBasicInfoRedisTemplate") | ||||
| public RedisTemplate<String, WxCUserBasicInfo> getCUserBasicInfoRedisTemplate(RedisConnectionFactory connectionFactory) { | public RedisTemplate<String, WxCUserBasicInfo> getCUserBasicInfoRedisTemplate(RedisConnectionFactory connectionFactory) { | ||||
| RedisTemplate<String, WxCUserBasicInfo> template = new RedisTemplate<String, WxCUserBasicInfo>(); | RedisTemplate<String, WxCUserBasicInfo> template = new RedisTemplate<String, WxCUserBasicInfo>(); | ||||
| @@ -2,6 +2,7 @@ package com.iformall.config; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.po.base.BaseCUserEntity; | |||||
| import com.iformall.domain.vo.WxCouponCVo; | import com.iformall.domain.vo.WxCouponCVo; | ||||
| import com.iformall.domain.vo.WxCouponChannelVo; | import com.iformall.domain.vo.WxCouponChannelVo; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| @@ -127,6 +128,23 @@ public class RedisConfig extends CachingConfigurerSupport { | |||||
| return template; | return template; | ||||
| } | } | ||||
| @Bean("baseCUserTokenRedisTemplate") | |||||
| public RedisTemplate<String, BaseCUserEntity> getBaseCUserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
| RedisTemplate<String, BaseCUserEntity> template = new RedisTemplate<String, BaseCUserEntity>(); | |||||
| Jackson2JsonRedisSerializer<BaseCUserEntity> j = new Jackson2JsonRedisSerializer<BaseCUserEntity>(BaseCUserEntity.class); | |||||
| // value值的序列化 | |||||
| template.setValueSerializer(j); | |||||
| template.setHashKeySerializer(j); | |||||
| // key的序列化 | |||||
| template.setKeySerializer(new StringRedisSerializer()); | |||||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||||
| template.setConnectionFactory(connectionFactory); | |||||
| return template; | |||||
| } | |||||
| @Bean("cUserBasicInfoRedisTemplate") | @Bean("cUserBasicInfoRedisTemplate") | ||||
| public RedisTemplate<String, WxCUserBasicInfo> getCUserBasicInfoRedisTemplate(RedisConnectionFactory connectionFactory) { | public RedisTemplate<String, WxCUserBasicInfo> getCUserBasicInfoRedisTemplate(RedisConnectionFactory connectionFactory) { | ||||
| RedisTemplate<String, WxCUserBasicInfo> template = new RedisTemplate<String, WxCUserBasicInfo>(); | RedisTemplate<String, WxCUserBasicInfo> template = new RedisTemplate<String, WxCUserBasicInfo>(); | ||||
| @@ -3,12 +3,9 @@ package com.iformall.domain.po; | |||||
| import com.baomidou.mybatisplus.annotation.TableField; | import com.baomidou.mybatisplus.annotation.TableField; | ||||
| import com.baomidou.mybatisplus.annotation.TableName; | import com.baomidou.mybatisplus.annotation.TableName; | ||||
| import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||||
| import com.iformall.domain.po.base.BaseEntity; | |||||
| import com.iformall.domain.po.base.BaseTenantEntity; | |||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.utils.Constant; | |||||
| import com.iformall.utils.UserUtil; | |||||
| import com.iformall.domain.po.base.BaseCUserEntity; | |||||
| import com.iformall.utils.Constant; | |||||
| import lombok.Data; | import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | import lombok.EqualsAndHashCode; | ||||
| import lombok.ToString; | import lombok.ToString; | ||||
| @@ -24,12 +21,8 @@ import java.util.UUID; | |||||
| @Data | @Data | ||||
| @ToString(callSuper = true) | @ToString(callSuper = true) | ||||
| @EqualsAndHashCode(callSuper = true) | @EqualsAndHashCode(callSuper = true) | ||||
| public class WxCUser extends TenantEntity { | |||||
| public class WxCUser extends BaseCUserEntity { | |||||
| protected Long id; | |||||
| @io.swagger.annotations.ApiModelProperty(value="userId",name="userId") | |||||
| private Long userId; | |||||
| @io.swagger.annotations.ApiModelProperty(value="微信openId",name="openId") | @io.swagger.annotations.ApiModelProperty(value="微信openId",name="openId") | ||||
| private String openId; | private String openId; | ||||
| @io.swagger.annotations.ApiModelProperty(value="微信unionId",name="unionId") | @io.swagger.annotations.ApiModelProperty(value="微信unionId",name="unionId") | ||||
| @@ -74,12 +67,6 @@ public class WxCUser extends TenantEntity { | |||||
| private Date createDate; | private Date createDate; | ||||
| @io.swagger.annotations.ApiModelProperty(value="小程序的appId",name="appId") | @io.swagger.annotations.ApiModelProperty(value="小程序的appId",name="appId") | ||||
| private String appId; | private String appId; | ||||
| /*用户登录用token**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="用户登录用token",name="token") | |||||
| private String token; | |||||
| /*用户过期时间**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="用户过期时间",name="expireTime") | |||||
| private Date expireTime; | |||||
| /*经度**/ | /*经度**/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="经度",name="longitude") | @io.swagger.annotations.ApiModelProperty(value="经度",name="longitude") | ||||
| private BigDecimal longitude; | private BigDecimal longitude; | ||||
| @@ -148,21 +135,13 @@ public class WxCUser extends TenantEntity { | |||||
| private Long operatorId; | private Long operatorId; | ||||
| public String createToken(Date currentDate) { | public String createToken(Date currentDate) { | ||||
| if (expireTime == null || expireTime.getTime() - Constant.H_EXPIRE < currentDate.getTime()) | |||||
| if (this.getExpireTime() == null || this.getExpireTime().getTime() - Constant.H_EXPIRE < currentDate.getTime()) | |||||
| { | { | ||||
| //生成一个token | //生成一个token | ||||
| this.token = UUID.randomUUID().toString(); | |||||
| this.setToken(UUID.randomUUID().toString()+Constant.TOKEN_WXC_END); | |||||
| //过期时间 | //过期时间 | ||||
| this.expireTime = new Date(currentDate.getTime() + Constant.EXPIRE); | |||||
| this.setExpireTime(new Date(currentDate.getTime() + Constant.EXPIRE)); | |||||
| } | } | ||||
| return this.token; | |||||
| } | |||||
| /** | |||||
| * 是否是会员 | |||||
| * @return | |||||
| */ | |||||
| public boolean isBasicInfo() { | |||||
| return UserUtil.CuserIsBasicInfo(this.getUserId()); | |||||
| return this.getToken(); | |||||
| } | } | ||||
| } | } | ||||
| @@ -0,0 +1,38 @@ | |||||
| package com.iformall.domain.po.base; | |||||
| import com.iformall.utils.Constant; | |||||
| import com.iformall.utils.UserUtil; | |||||
| import lombok.Data; | |||||
| import lombok.EqualsAndHashCode; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import java.util.Date; | |||||
| import java.util.UUID; | |||||
| /** | |||||
| * @author Stormeye | |||||
| * @date 2019/4/24 14:32 | |||||
| */ | |||||
| @Data | |||||
| @EqualsAndHashCode(callSuper = true) | |||||
| public class BaseCUserEntity extends TenantEntity { | |||||
| protected Long id; | |||||
| @io.swagger.annotations.ApiModelProperty(value="userId",name="userId") | |||||
| private Long userId; | |||||
| /*用户登录用token**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="用户登录用token",name="token") | |||||
| private String token; | |||||
| /*用户过期时间**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="用户过期时间",name="expireTime") | |||||
| private Date expireTime; | |||||
| /** | |||||
| * 是否是会员 | |||||
| * @return | |||||
| */ | |||||
| public boolean isBasicInfo() { | |||||
| return UserUtil.CuserIsBasicInfo(this.getUserId()); | |||||
| } | |||||
| } | |||||
| @@ -43,6 +43,9 @@ public class TenantVEntity extends BaseEntity { | |||||
| public TenantEntity getTenantInfo() { | public TenantEntity getTenantInfo() { | ||||
| return new TenantEntity() {{ | return new TenantEntity() {{ | ||||
| setTenantId(tenantId); | setTenantId(tenantId); | ||||
| if (StringUtils.isNotBlank(parentTenantId)) { | |||||
| setParentTenantId(parentTenantId); | |||||
| } | |||||
| }}; | }}; | ||||
| } | } | ||||
| } | } | ||||
| @@ -1,14 +1,9 @@ | |||||
| package com.iformall.mapper; | package com.iformall.mapper; | ||||
| import com.iformall.common.CommonMapper; | import com.iformall.common.CommonMapper; | ||||
| import com.iformall.domain.dto.WxCUserBasicInfoDto; | |||||
| import com.iformall.domain.po.WxBuser; | import com.iformall.domain.po.WxBuser; | ||||
| import com.iformall.domain.po.WxCUser; | |||||
| import com.iformall.domain.vo.UserCountVo; | |||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | |||||
| /** | /** | ||||
| * @author gongbiao | * @author gongbiao | ||||
| */ | */ | ||||
| @@ -0,0 +1,15 @@ | |||||
| package com.iformall.service; | |||||
| import com.iformall.domain.po.base.BaseCUserEntity; | |||||
| public interface CUserTokenService { | |||||
| /** | |||||
| * 根据token获得实体 | |||||
| * | |||||
| * @param token | |||||
| * @return | |||||
| */ | |||||
| BaseCUserEntity getByToken(String token); | |||||
| } | |||||
| @@ -6,7 +6,6 @@ import com.iformall.domain.dto.WxCUserBasicInfoDto; | |||||
| import com.iformall.domain.dto.WxCUserBasicInfoFilterDto; | import com.iformall.domain.dto.WxCUserBasicInfoFilterDto; | ||||
| import com.iformall.domain.dto.WxCUserBasicInfoFilterListDto; | import com.iformall.domain.dto.WxCUserBasicInfoFilterListDto; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.po.base.BaseTenantEntity; | |||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.domain.vo.CUserBaseInfoT; | import com.iformall.domain.vo.CUserBaseInfoT; | ||||
| import com.iformall.domain.vo.UserCountVo; | import com.iformall.domain.vo.UserCountVo; | ||||
| @@ -106,6 +105,7 @@ public interface WxCUserBasicInfoService { | |||||
| */ | */ | ||||
| long findCountByAge(WxCUserBasicInfoDto dto); | long findCountByAge(WxCUserBasicInfoDto dto); | ||||
| /** | /** | ||||
| * 根据年龄积分查寻数量 | * 根据年龄积分查寻数量 | ||||
| * | * | ||||
| @@ -1,21 +0,0 @@ | |||||
| package com.iformall.service; | |||||
| import com.iformall.domain.po.WxCUser; | |||||
| public interface WxCUserTokenService { | |||||
| /** | |||||
| * 根据token获得实体 | |||||
| * | |||||
| * @param token | |||||
| * @return | |||||
| */ | |||||
| WxCUser getByToken(String token); | |||||
| /** | |||||
| * 保存或更新实体 | |||||
| * | |||||
| * @param record | |||||
| */ | |||||
| int saveOrUpdate(WxCUser record); | |||||
| } | |||||
| @@ -0,0 +1,55 @@ | |||||
| package com.iformall.service.impl; | |||||
| import com.iformall.domain.po.base.BaseCUserEntity; | |||||
| import com.iformall.mapper.WxCUserMapper; | |||||
| import com.iformall.service.CUserTokenService; | |||||
| import com.iformall.utils.Constant; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.beans.factory.annotation.Qualifier; | |||||
| import org.springframework.data.redis.core.RedisTemplate; | |||||
| import org.springframework.data.redis.core.ValueOperations; | |||||
| import org.springframework.stereotype.Service; | |||||
| import java.util.concurrent.TimeUnit; | |||||
| @Service | |||||
| public class CUserTokenServiceImpl implements CUserTokenService { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| WxCUserMapper wxCUserMapper; | |||||
| @Autowired | |||||
| @Qualifier("baseCUserTokenRedisTemplate") | |||||
| RedisTemplate<String, BaseCUserEntity> baseCUserTokenRedisTemplate; | |||||
| @Override | |||||
| public BaseCUserEntity getByToken(String token) { | |||||
| BaseCUserEntity user = null; | |||||
| logger.info("获取用户信息start ..." + token); | |||||
| String key = Constant.tokenPrev + token; | |||||
| ValueOperations<String, BaseCUserEntity> operations = baseCUserTokenRedisTemplate.opsForValue(); | |||||
| // 缓存 | |||||
| boolean hasKey = baseCUserTokenRedisTemplate.hasKey(key); | |||||
| if(hasKey) { | |||||
| // 从缓存获取用户信息 | |||||
| user = operations.get(key); | |||||
| logger.info("缓存中获取用户信息End-" + token); | |||||
| return user; | |||||
| } | |||||
| if(token.endsWith(Constant.TOKEN_WXC_END)){ | |||||
| user = wxCUserMapper.findByToken(token); | |||||
| } | |||||
| // 插入缓存 | |||||
| operations.set(key, user, 3600, TimeUnit.SECONDS); | |||||
| logger.info("DB中获取用户信息End-" + token); | |||||
| return user; | |||||
| } | |||||
| } | |||||
| @@ -82,6 +82,8 @@ public class WxBusinessServiceImpl implements WxBusinessService { | |||||
| BigDecimal businessSumMoney = new BigDecimal(0); | BigDecimal businessSumMoney = new BigDecimal(0); | ||||
| WxRentContract query = new WxRentContract(); | WxRentContract query = new WxRentContract(); | ||||
| query.setBusinessId((Integer) e.get("id")); | query.setBusinessId((Integer) e.get("id")); | ||||
| query.setIsDel(0); | |||||
| query.updateTenantInfo(wxBusiness.getTenantInfo()); | |||||
| List<WxRentContract> rentContractList = wxRentContractMapper.selectList(new QueryWrapper<>(query)); | List<WxRentContract> rentContractList = wxRentContractMapper.selectList(new QueryWrapper<>(query)); | ||||
| for (WxRentContract dbRent : rentContractList) { | for (WxRentContract dbRent : rentContractList) { | ||||
| if (dbRent.getStatus().equals(EnumRentContractStatus.INTENTION.getCode()) || | if (dbRent.getStatus().equals(EnumRentContractStatus.INTENTION.getCode()) || | ||||
| @@ -103,6 +105,8 @@ public class WxBusinessServiceImpl implements WxBusinessService { | |||||
| WxPropertyContract pquery = new WxPropertyContract(); | WxPropertyContract pquery = new WxPropertyContract(); | ||||
| pquery.setBusinessId((Integer) e.get("id")); | pquery.setBusinessId((Integer) e.get("id")); | ||||
| query.setIsDel(0); | |||||
| pquery.updateTenantInfo(wxBusiness.getTenantInfo()); | |||||
| List<WxPropertyContract> propertyContractList = wxPropertyContractMapper.selectList(new QueryWrapper<>(pquery)); | List<WxPropertyContract> propertyContractList = wxPropertyContractMapper.selectList(new QueryWrapper<>(pquery)); | ||||
| for (WxPropertyContract dbRent : propertyContractList) { | for (WxPropertyContract dbRent : propertyContractList) { | ||||
| if (dbRent.getStatus().equals(EnumRentContractStatus.INTENTION.getCode()) || | if (dbRent.getStatus().equals(EnumRentContractStatus.INTENTION.getCode()) || | ||||
| @@ -9,6 +9,7 @@ import com.iformall.domain.po.WxAuthorizerInfo; | |||||
| import com.iformall.domain.po.WxCUser; | import com.iformall.domain.po.WxCUser; | ||||
| import com.iformall.domain.po.WxCUserBasicInfo; | import com.iformall.domain.po.WxCUserBasicInfo; | ||||
| import com.iformall.domain.po.WxCreditHistory; | import com.iformall.domain.po.WxCreditHistory; | ||||
| import com.iformall.domain.po.base.BaseCUserEntity; | |||||
| import com.iformall.domain.po.msg.FmInsideCLoginMsg; | import com.iformall.domain.po.msg.FmInsideCLoginMsg; | ||||
| import com.iformall.domain.vo.UserCountVo; | import com.iformall.domain.vo.UserCountVo; | ||||
| import com.iformall.enums.*; | import com.iformall.enums.*; | ||||
| @@ -52,8 +53,8 @@ public class WxCUserServiceImpl implements WxCUserService { | |||||
| private MqBaseProducer mqBaseProducer; | private MqBaseProducer mqBaseProducer; | ||||
| @Autowired | @Autowired | ||||
| @Qualifier("cuserTokenRedisTemplate") | |||||
| RedisTemplate<String, WxCUser> cUserTokenRedisTemplate; | |||||
| @Qualifier("baseCUserTokenRedisTemplate") | |||||
| RedisTemplate<String, BaseCUserEntity> baseCUserTokenRedisTemplate; | |||||
| @Override | @Override | ||||
| public PageInfo<WxCUser> listAsPage(WxCUser record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxCUser> listAsPage(WxCUser record, Integer pageIndex, Integer pageSize) { | ||||
| @@ -91,6 +92,8 @@ public class WxCUserServiceImpl implements WxCUserService { | |||||
| if(oldUser != null) { | if(oldUser != null) { | ||||
| // 已有,更新 | // 已有,更新 | ||||
| user.setId(oldUser.getId()); | user.setId(oldUser.getId()); | ||||
| user.setLoginCount(oldUser.getLoginCount()==null?0:oldUser.getLoginCount() + 1); | |||||
| user.setUpdateDate(curr); | |||||
| // TODO 是否其他信息需要更新 | // TODO 是否其他信息需要更新 | ||||
| ret = wxCUserMapper.updateById(user); | ret = wxCUserMapper.updateById(user); | ||||
| return ret; | return ret; | ||||
| @@ -179,8 +182,8 @@ public class WxCUserServiceImpl implements WxCUserService { | |||||
| userL.setUpdateDate(curr); | userL.setUpdateDate(curr); | ||||
| int ret = wxCUserMapper.updateById(userL); | int ret = wxCUserMapper.updateById(userL); | ||||
| String key = Constant.tokenPrev + record.getOpenId(); | String key = Constant.tokenPrev + record.getOpenId(); | ||||
| if(cUserTokenRedisTemplate.hasKey(key)){ | |||||
| cUserTokenRedisTemplate.delete(key); | |||||
| if(baseCUserTokenRedisTemplate.hasKey(key)){ | |||||
| baseCUserTokenRedisTemplate.delete(key); | |||||
| } | } | ||||
| return ret; | return ret; | ||||
| } | } | ||||
| @@ -195,8 +198,8 @@ public class WxCUserServiceImpl implements WxCUserService { | |||||
| userL.setUpdateDate(curr); | userL.setUpdateDate(curr); | ||||
| int ret = wxCUserMapper.updateById(userL); | int ret = wxCUserMapper.updateById(userL); | ||||
| String key = Constant.tokenPrev + record.getOpenId(); | String key = Constant.tokenPrev + record.getOpenId(); | ||||
| if(cUserTokenRedisTemplate.hasKey(key)){ | |||||
| cUserTokenRedisTemplate.delete(key); | |||||
| if(baseCUserTokenRedisTemplate.hasKey(key)){ | |||||
| baseCUserTokenRedisTemplate.delete(key); | |||||
| } | } | ||||
| return ret; | return ret; | ||||
| } | } | ||||
| @@ -210,8 +213,8 @@ public class WxCUserServiceImpl implements WxCUserService { | |||||
| userL.setUpdateDate(curr); | userL.setUpdateDate(curr); | ||||
| int ret = wxCUserMapper.updateById(userL); | int ret = wxCUserMapper.updateById(userL); | ||||
| String key = Constant.tokenPrev + record.getOpenId(); | String key = Constant.tokenPrev + record.getOpenId(); | ||||
| if(cUserTokenRedisTemplate.hasKey(key)){ | |||||
| cUserTokenRedisTemplate.delete(key); | |||||
| if(baseCUserTokenRedisTemplate.hasKey(key)){ | |||||
| baseCUserTokenRedisTemplate.delete(key); | |||||
| } | } | ||||
| return ret; | return ret; | ||||
| } | } | ||||
| @@ -311,8 +314,8 @@ public class WxCUserServiceImpl implements WxCUserService { | |||||
| } | } | ||||
| } | } | ||||
| String key = Constant.tokenPrev + user.getOpenId(); | String key = Constant.tokenPrev + user.getOpenId(); | ||||
| if(cUserTokenRedisTemplate.hasKey(key)){ | |||||
| cUserTokenRedisTemplate.delete(key); | |||||
| if(baseCUserTokenRedisTemplate.hasKey(key)){ | |||||
| baseCUserTokenRedisTemplate.delete(key); | |||||
| } | } | ||||
| return score; | return score; | ||||
| } | } | ||||
| @@ -1,82 +0,0 @@ | |||||
| package com.iformall.service.impl; | |||||
| import com.iformall.common.IdWorker; | |||||
| import com.iformall.domain.po.WxCUser; | |||||
| import com.iformall.mapper.WxCUserMapper; | |||||
| import com.iformall.mapper.WxCouponOrderMapper; | |||||
| import com.iformall.mapper.WxScoreHistoryMapper; | |||||
| import com.iformall.mapper.WxScoreRulesMapper; | |||||
| import com.iformall.service.WxCUserTokenService; | |||||
| import com.iformall.service.WxScoreRulesService; | |||||
| import com.iformall.utils.Constant; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.beans.factory.annotation.Qualifier; | |||||
| import org.springframework.data.redis.core.RedisTemplate; | |||||
| import org.springframework.data.redis.core.ValueOperations; | |||||
| import org.springframework.stereotype.Service; | |||||
| import java.util.Date; | |||||
| import java.util.concurrent.TimeUnit; | |||||
| @Service | |||||
| public class WxCUserTokenServiceImpl implements WxCUserTokenService { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| WxCUserMapper wxCUserMapper; | |||||
| @Autowired | |||||
| @Qualifier("cuserTokenRedisTemplate") | |||||
| RedisTemplate<String, WxCUser> cUserTokenRedisTemplate; | |||||
| @Override | |||||
| public WxCUser getByToken(String token) { | |||||
| logger.info("获取用户信息start ..." + token); | |||||
| String key = Constant.tokenPrev + token; | |||||
| ValueOperations<String, WxCUser> operations = cUserTokenRedisTemplate.opsForValue(); | |||||
| // 缓存 | |||||
| boolean hasKey = cUserTokenRedisTemplate.hasKey(key); | |||||
| if(hasKey) { | |||||
| // 从缓存获取用户信息 | |||||
| WxCUser user = operations.get(key); | |||||
| logger.info("缓存中获取用户信息End-" + token); | |||||
| return user; | |||||
| } | |||||
| WxCUser user = wxCUserMapper.findByToken(token); | |||||
| // 插入缓存 | |||||
| operations.set(key, user, 3600, TimeUnit.SECONDS); | |||||
| logger.info("DB中获取用户信息End-" + token); | |||||
| return user; | |||||
| } | |||||
| @Override | |||||
| public int saveOrUpdate(WxCUser user) { | |||||
| int ret = 0; | |||||
| Date curr = new Date(); | |||||
| if (user.getId() == null) { | |||||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| user.setId(idWorker.nextId()); | |||||
| user.setLoginCount(1); | |||||
| user.setCreateDate(curr); | |||||
| user.setUpdateDate(curr); | |||||
| ret = wxCUserMapper.insert(user); | |||||
| } else { | |||||
| user.setUpdateDate(curr); | |||||
| ret = wxCUserMapper.updateById(user); | |||||
| } | |||||
| String key = Constant.tokenPrev + user.getToken(); | |||||
| // 缓存已存在,删除 | |||||
| boolean hasKey = cUserTokenRedisTemplate.hasKey(key); | |||||
| if(hasKey) { | |||||
| cUserTokenRedisTemplate.delete(key); | |||||
| logger.info("更新用户,从缓存中删除用户 token >> " + user.getToken()); | |||||
| } | |||||
| return ret; | |||||
| } | |||||
| } | |||||
| @@ -2168,7 +2168,7 @@ public class WxChartServiceImpl implements WxChartDataService { | |||||
| for (int i = 0; i < levelList.size(); i++) { | for (int i = 0; i < levelList.size(); i++) { | ||||
| WxCUserBasicInfoDto dto = new WxCUserBasicInfoDto(); | WxCUserBasicInfoDto dto = new WxCUserBasicInfoDto(); | ||||
| dto.updateFinalTenantInfo(tenantEntity); | |||||
| dto.updateTenantInfo(tenantEntity); | |||||
| dto.setStartTime(DateUtils.stringToDate(startdate)); | dto.setStartTime(DateUtils.stringToDate(startdate)); | ||||
| dto.setEndTime(DateUtils.stringToDate(enddate)); | dto.setEndTime(DateUtils.stringToDate(enddate)); | ||||
| if (i + 1 < levelList.size()) { | if (i + 1 < levelList.size()) { | ||||
| @@ -59,7 +59,7 @@ public class WxLevelConfigServiceImpl implements WxLevelConfigService { | |||||
| l.setScale(WxLevelConfig.DEFAULT_SCALE); | l.setScale(WxLevelConfig.DEFAULT_SCALE); | ||||
| } | } | ||||
| WxCUserBasicInfoDto dto = new WxCUserBasicInfoDto(); | WxCUserBasicInfoDto dto = new WxCUserBasicInfoDto(); | ||||
| dto.updateFinalTenantInfo(record); | |||||
| dto.updateTenantInfo(record); | |||||
| dto.setLevelStartScore(l.getPoints()); | dto.setLevelStartScore(l.getPoints()); | ||||
| if (i + 1<page.getList().size()) | if (i + 1<page.getList().size()) | ||||
| dto.setLevelEndScore(page.getList().get(i+1).getPoints()); | dto.setLevelEndScore(page.getList().get(i+1).getPoints()); | ||||
| @@ -309,7 +309,6 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { | |||||
| private int checkTodayLoginScoreCount(WxCUserBasicInfo cUser) { | private int checkTodayLoginScoreCount(WxCUserBasicInfo cUser) { | ||||
| WxScoreHistory scoreHistory = new WxScoreHistory(); | WxScoreHistory scoreHistory = new WxScoreHistory(); | ||||
| scoreHistory.updateFinalTenantInfo(cUser); | |||||
| scoreHistory.setCUserId(cUser.getId()); | scoreHistory.setCUserId(cUser.getId()); | ||||
| scoreHistory.setScoreType(EnumScoreType.LOGIN.getCode()); | scoreHistory.setScoreType(EnumScoreType.LOGIN.getCode()); | ||||
| return wxScoreHistoryMapper.countTodayList(scoreHistory); | return wxScoreHistoryMapper.countTodayList(scoreHistory); | ||||
| @@ -443,7 +442,6 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { | |||||
| private int checkCompleteInfoScoreCount(WxCUserBasicInfo user) { | private int checkCompleteInfoScoreCount(WxCUserBasicInfo user) { | ||||
| WxScoreHistory scoreHistory = new WxScoreHistory(); | WxScoreHistory scoreHistory = new WxScoreHistory(); | ||||
| scoreHistory.updateFinalTenantInfo(user); | |||||
| scoreHistory.setCUserId(user.getId()); | scoreHistory.setCUserId(user.getId()); | ||||
| scoreHistory.setScoreType(EnumScoreType.COMPLETE_INFO.getCode()); | scoreHistory.setScoreType(EnumScoreType.COMPLETE_INFO.getCode()); | ||||
| return wxScoreHistoryMapper.countList(scoreHistory); | return wxScoreHistoryMapper.countList(scoreHistory); | ||||
| @@ -24,6 +24,8 @@ public class Constant { | |||||
| // C端token | // C端token | ||||
| public static final String tokenPrev = "weapp:token:"; | public static final String tokenPrev = "weapp:token:"; | ||||
| public static final String TOKEN_WXC_END = ":wx-cuser"; | |||||
| public static final String LOGIN_USER_KEY = "LOGIN_USER_KEY"; | public static final String LOGIN_USER_KEY = "LOGIN_USER_KEY"; | ||||
| public static final String LOGIN_MEMBER_KEY = "LOGIN_MEMBER_KEY"; | public static final String LOGIN_MEMBER_KEY = "LOGIN_MEMBER_KEY"; | ||||
| public static final String TENANT_ID = "TENANT_ID"; | public static final String TENANT_ID = "TENANT_ID"; | ||||
| @@ -30,97 +30,100 @@ | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`,`phone`,`birthdate`,`education`,`sex`,`email`,`address`,`poins`,`tag_id`, | |||||
| `create_date`,`update_date`,`tenant_id`,`parent_tenant_id`,`final_tenant_id`,`name`,`nick_name`,`avatar_url`, | |||||
| `credit`,`active_time`,`login_count`,`act_record` | |||||
| distinct wcubi.`id`,wcubi.`phone`,wcubi.`birthdate`,wcubi.`education`,wcubi.`sex`,wcubi.`email`, | |||||
| wcubi.`address`,wcubi.`poins`,wcubi.`tag_id`,wcubi.`create_date`,wcubi.`update_date`, | |||||
| wcubi.`tenant_id`,wcubi.`parent_tenant_id`,wcubi.`final_tenant_id`,wcubi.`name`,wcubi.`nick_name`, | |||||
| wcubi.`avatar_url`,wcubi.`credit`,wcubi.`active_time`,wcubi.`login_count`,wcubi.`act_record` | |||||
| ,(select level from wx_level_config | ,(select level from wx_level_config | ||||
| where poins >= points and tenant_id=wcubi.tenant_id | where poins >= points and tenant_id=wcubi.tenant_id | ||||
| order by points desc limit 1 ) level,status | |||||
| order by points desc limit 1 ) level,wcubi.status | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| where 1 = 1 | where 1 = 1 | ||||
| <if test=" null != id "> | <if test=" null != id "> | ||||
| and `id` = #{id} | |||||
| and wcubi.`id` = #{id} | |||||
| </if> | </if> | ||||
| <if test=" null != tenantId and '' != tenantId"> | <if test=" null != tenantId and '' != tenantId"> | ||||
| and `tenant_id` = #{tenantId} | |||||
| and wcu.`tenant_id` = #{tenantId} | |||||
| </if> | </if> | ||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | <if test=" null != parentTenantId and '' != parentTenantId"> | ||||
| and `parent_tenant_id` = #{parentTenantId} | |||||
| and wcu.`parent_tenant_id` = #{parentTenantId} | |||||
| </if> | </if> | ||||
| <if test=" null != finalTenantId and '' != finalTenantId"> | <if test=" null != finalTenantId and '' != finalTenantId"> | ||||
| and `final_tenant_id` = #{finalTenantId} | |||||
| and wcubi.`final_tenant_id` = #{finalTenantId} | |||||
| </if> | </if> | ||||
| <if test=" null != phone "> | <if test=" null != phone "> | ||||
| and `phone` like concat('%', #{phone},'%') | |||||
| and wcubi.`phone` like concat('%', #{phone},'%') | |||||
| </if> | </if> | ||||
| <if test=" null != birthdate "> | <if test=" null != birthdate "> | ||||
| and `birthdate` = #{birthdate} | |||||
| and wcubi.`birthdate` = #{birthdate} | |||||
| </if> | </if> | ||||
| <if test=" null != education "> | <if test=" null != education "> | ||||
| and `education` like concat('%', #{education},'%') | |||||
| and wcubi.`education` like concat('%', #{education},'%') | |||||
| </if> | </if> | ||||
| <if test=" null != sex "> | <if test=" null != sex "> | ||||
| and `sex` = #{sex} | |||||
| and wcubi.`sex` = #{sex} | |||||
| </if> | </if> | ||||
| <if test=" null != email "> | <if test=" null != email "> | ||||
| and `email` like concat('%', #{email},'%') | |||||
| and wcubi.`email` like concat('%', #{email},'%') | |||||
| </if> | </if> | ||||
| <if test=" null != address "> | <if test=" null != address "> | ||||
| and `address` like concat('%', #{address},'%') | |||||
| and wcubi.`address` like concat('%', #{address},'%') | |||||
| </if> | </if> | ||||
| <if test=" null != poins "> | <if test=" null != poins "> | ||||
| and `poins` = #{poins} | |||||
| and wcubi.`poins` = #{poins} | |||||
| </if> | </if> | ||||
| <if test=" null != credit "> | <if test=" null != credit "> | ||||
| and `credit` = #{credit} | |||||
| and wcubi.`credit` = #{credit} | |||||
| </if> | </if> | ||||
| <if test=" null != tagId "> | <if test=" null != tagId "> | ||||
| and `tag_id` = #{tagId} | |||||
| and wcubi.`tag_id` = #{tagId} | |||||
| </if> | </if> | ||||
| <if test=" null != createDate "> | <if test=" null != createDate "> | ||||
| and `create_date` = #{createDate} | |||||
| and wcubi.`create_date` = #{createDate} | |||||
| </if> | </if> | ||||
| <if test=" null != updateDate "> | <if test=" null != updateDate "> | ||||
| and `update_date` = #{updateDate} | |||||
| and wcubi.`update_date` = #{updateDate} | |||||
| </if> | </if> | ||||
| <if test=" null != actRecord "> | <if test=" null != actRecord "> | ||||
| and `act_record` = #{actRecord} | |||||
| and wcubi.`act_record` = #{actRecord} | |||||
| </if> | </if> | ||||
| <if test=" null != name "> | <if test=" null != name "> | ||||
| and `name` like concat('%', #{name},'%') | |||||
| and wcubi.`name` like concat('%', #{name},'%') | |||||
| </if> | </if> | ||||
| <if test=" null != startTime and null!=endTime"> | <if test=" null != startTime and null!=endTime"> | ||||
| and `create_date` between #{startTime} and #{endTime} | |||||
| and wcubi.`create_date` between #{startTime} and #{endTime} | |||||
| </if> | </if> | ||||
| <if test=" null != status "> | <if test=" null != status "> | ||||
| and `status` = #{status} | |||||
| and wcubi.`status` = #{status} | |||||
| </if> | </if> | ||||
| <if test=" null != ids "> | <if test=" null != ids "> | ||||
| and id in | |||||
| and wcubi.id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | ||||
| #{idItem} | #{idItem} | ||||
| </foreach> | </foreach> | ||||
| </if> | </if> | ||||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | |||||
| order by wcubi.`active_time` DESC | |||||
| <!-- <if test=" null != sortColumns">order by ${sortColumns}</if>--> | |||||
| </sql> | </sql> | ||||
| <select id="findList" parameterType="com.iformall.domain.po.WxCUserBasicInfo" resultMap="BaseResultMap"> | <select id="findList" parameterType="com.iformall.domain.po.WxCUserBasicInfo" resultMap="BaseResultMap"> | ||||
| @@ -128,6 +131,7 @@ | |||||
| select | select | ||||
| <include refid="allColumns"/> | <include refid="allColumns"/> | ||||
| from wx_c_user_basic_info wcubi | from wx_c_user_basic_info wcubi | ||||
| left join wx_c_user wcu on wcu.user_id = wcubi.id | |||||
| <include refid="dynamicWhereConditions"/> | <include refid="dynamicWhereConditions"/> | ||||
| ) r where 1=1 | ) r where 1=1 | ||||
| @@ -136,11 +140,6 @@ | |||||
| </if> | </if> | ||||
| </select> | </select> | ||||
| <sql id="allUserColumns"> | |||||
| c.`id`,c.`phone`,cb.`birthdate`,cb.`education`,cb.`sex`,cb.`email`,cb.`address`,cb.`poins`,cb.`tag_id`, | |||||
| cb.`create_date`,cb.`update_date`,c.`tenant_id`,cb.`name`,cb.`level`,cb.`nick_name`,cb.`act_record`,cb.`parent_tenant_id` | |||||
| </sql> | |||||
| <update id="updateScore" parameterType="com.iformall.domain.po.WxCUserBasicInfo"> | <update id="updateScore" parameterType="com.iformall.domain.po.WxCUserBasicInfo"> | ||||
| update wx_c_user_basic_info set poins=#{poins} | update wx_c_user_basic_info set poins=#{poins} | ||||
| where id=#{id} | where id=#{id} | ||||
| @@ -160,85 +159,90 @@ | |||||
| </update> | </update> | ||||
| <select id="findCountBySex" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long"> | <select id="findCountBySex" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long"> | ||||
| select count(id) from wx_c_user_basic_info | |||||
| where sex =#{sex} | |||||
| select count(distinct wcubi.id) from wx_c_user_basic_info wcubi | |||||
| left join wx_c_user wcu on wcu.user_id = wcubi.id | |||||
| where wcubi.sex =#{sex} | |||||
| <if test=" null != startTime "> | <if test=" null != startTime "> | ||||
| and create_date >= #{startTime} | |||||
| and wcubi.create_date >= #{startTime} | |||||
| </if> | </if> | ||||
| <if test=" null != endTime"> | <if test=" null != endTime"> | ||||
| and create_date <= #{endTime} | |||||
| and wcubi.create_date <= #{endTime} | |||||
| </if> | </if> | ||||
| <if test=" null != tenantId and '' != tenantId"> | <if test=" null != tenantId and '' != tenantId"> | ||||
| and `tenant_id` = #{tenantId} | |||||
| and wcu.`tenant_id` = #{tenantId} | |||||
| </if> | </if> | ||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | <if test=" null != parentTenantId and '' != parentTenantId"> | ||||
| and `parent_tenant_id` = #{parentTenantId} | |||||
| and wcu.`parent_tenant_id` = #{parentTenantId} | |||||
| </if> | </if> | ||||
| </select> | </select> | ||||
| <select id="findCountByAge" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long"> | <select id="findCountByAge" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long"> | ||||
| select count(id) from wx_c_user_basic_info where 1=1 | |||||
| select count(distinct wcubi.id) from wx_c_user_basic_info wcubi | |||||
| left join wx_c_user wcu on wcu.user_id = wcubi.id | |||||
| where 1=1 | |||||
| <if test=" null != startTime "> | <if test=" null != startTime "> | ||||
| and create_date >= #{startTime} | |||||
| and wcubi.create_date >= #{startTime} | |||||
| </if> | </if> | ||||
| <if test=" null != endTime"> | <if test=" null != endTime"> | ||||
| and create_date <= #{endTime} | |||||
| and wcubi.create_date <= #{endTime} | |||||
| </if> | </if> | ||||
| <if test=" null != birthStartTime "> | <if test=" null != birthStartTime "> | ||||
| and birthdate >= #{birthStartTime} | |||||
| and wcubi.birthdate >= #{birthStartTime} | |||||
| </if> | </if> | ||||
| <if test=" null != birthEndTime"> | <if test=" null != birthEndTime"> | ||||
| and birthdate <= #{birthEndTime} | |||||
| and wcubi.birthdate <= #{birthEndTime} | |||||
| </if> | </if> | ||||
| <if test=" null == birthStartTime and null == birthEndTime"> | <if test=" null == birthStartTime and null == birthEndTime"> | ||||
| and birthdate is null | |||||
| and wcubi.birthdate is null | |||||
| </if> | </if> | ||||
| <if test=" null != tenantId and '' != tenantId"> | <if test=" null != tenantId and '' != tenantId"> | ||||
| and `tenant_id` = #{tenantId} | |||||
| and wcu.`tenant_id` = #{tenantId} | |||||
| </if> | </if> | ||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | <if test=" null != parentTenantId and '' != parentTenantId"> | ||||
| and `parent_tenant_id` = #{parentTenantId} | |||||
| and wcu.`parent_tenant_id` = #{parentTenantId} | |||||
| </if> | </if> | ||||
| </select> | </select> | ||||
| <select id="findCountByScore" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long"> | <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 | |||||
| select count(distinct wcubi.id) from wx_c_user_basic_info wcubi | |||||
| left join wx_c_user wcu on wcu.user_id = wcubi.id | |||||
| where 1=1 | |||||
| <if test=" null != startTime "> | <if test=" null != startTime "> | ||||
| and create_date >= #{startTime} | |||||
| and wcubi.create_date >= #{startTime} | |||||
| </if> | </if> | ||||
| <if test=" null != endTime"> | <if test=" null != endTime"> | ||||
| and create_date <= #{endTime} | |||||
| and wcubi.create_date <= #{endTime} | |||||
| </if> | </if> | ||||
| <if test=" null != levelStartScore "> | <if test=" null != levelStartScore "> | ||||
| and poins >= #{levelStartScore} | |||||
| and wcubi.poins >= #{levelStartScore} | |||||
| </if> | </if> | ||||
| <if test=" null != levelEndScore"> | <if test=" null != levelEndScore"> | ||||
| and poins < #{levelEndScore} | |||||
| and wcubi.poins < #{levelEndScore} | |||||
| </if> | </if> | ||||
| <if test=" null == levelStartScore and null == levelEndScore"> | <if test=" null == levelStartScore and null == levelEndScore"> | ||||
| and poins is null | |||||
| and wcubi.poins is null | |||||
| </if> | </if> | ||||
| <if test=" null != tenantId and '' != tenantId"> | <if test=" null != tenantId and '' != tenantId"> | ||||
| and `tenant_id` = #{tenantId} | |||||
| and wcu.`tenant_id` = #{tenantId} | |||||
| </if> | </if> | ||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | <if test=" null != parentTenantId and '' != parentTenantId"> | ||||
| and `parent_tenant_id` = #{parentTenantId} | |||||
| and wcu.`parent_tenant_id` = #{parentTenantId} | |||||
| </if> | </if> | ||||
| </select> | </select> | ||||
| <sql id="allColumnsOfScoreList"> | <sql id="allColumnsOfScoreList"> | ||||
| cub.id,cub.phone,cub.birthdate,cub.education,cub.sex,cub.email,cub.address,cub.poins,cub.tag_id, | |||||
| distinct cub.id,cub.phone,cub.birthdate,cub.education,cub.sex,cub.email,cub.address,cub.poins,cub.tag_id, | |||||
| cub.create_date,cub.update_date,cub.tenant_id,cub.name,cub.level,cub.nick_name,cub.score_date,cub.parent_tenant_id | cub.create_date,cub.update_date,cub.tenant_id,cub.name,cub.level,cub.nick_name,cub.score_date,cub.parent_tenant_id | ||||
| </sql> | </sql> | ||||
| @@ -247,7 +251,7 @@ | |||||
| from wx_c_user_basic_info cub | from wx_c_user_basic_info cub | ||||
| inner join wx_c_user cu on cu.user_id = cub.id | inner join wx_c_user cu on cu.user_id = cub.id | ||||
| where 1=1 and cub.status=0 | |||||
| where cub.status=0 | |||||
| <if test=" null != levelStartScore "> | <if test=" null != levelStartScore "> | ||||
| and cub.poins >= #{levelStartScore} | and cub.poins >= #{levelStartScore} | ||||
| @@ -262,10 +266,10 @@ | |||||
| </if> | </if> | ||||
| <if test=" null != tenantId and '' != tenantId"> | <if test=" null != tenantId and '' != tenantId"> | ||||
| and cub.`tenant_id` = #{tenantId} | |||||
| and cu.`tenant_id` = #{tenantId} | |||||
| </if> | </if> | ||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | <if test=" null != parentTenantId and '' != parentTenantId"> | ||||
| and cub.`parent_tenant_id` = #{parentTenantId} | |||||
| and cu.`parent_tenant_id` = #{parentTenantId} | |||||
| </if> | </if> | ||||
| </select> | </select> | ||||
| @@ -274,84 +278,88 @@ | |||||
| select <include refid="allColumnsOfScoreList"/> | select <include refid="allColumnsOfScoreList"/> | ||||
| from wx_c_user_basic_info cub | from wx_c_user_basic_info cub | ||||
| inner join wx_c_user cu on cu.user_id = cub.id | inner join wx_c_user cu on cu.user_id = cub.id | ||||
| where cub.status = 0 and cu.phone is not null | |||||
| where cub.status = 0 | |||||
| AND DATE_FORMAT(cub.birthdate,'%m-%d') >= #{begin} | AND DATE_FORMAT(cub.birthdate,'%m-%d') >= #{begin} | ||||
| AND DATE_FORMAT(cub.birthdate,'%m-%d') <= #{end} | AND DATE_FORMAT(cub.birthdate,'%m-%d') <= #{end} | ||||
| <if test=" null != tenantId and '' != tenantId"> | <if test=" null != tenantId and '' != tenantId"> | ||||
| and cub.`tenant_id` = #{tenantId} | |||||
| and cu.`tenant_id` = #{tenantId} | |||||
| </if> | </if> | ||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | <if test=" null != parentTenantId and '' != parentTenantId"> | ||||
| and cub.`parent_tenant_id` = #{parentTenantId} | |||||
| and cu.`parent_tenant_id` = #{parentTenantId} | |||||
| </if> | </if> | ||||
| </select> | </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(distinct wcubi.id) from wx_c_user_basic_info wcubi | |||||
| left join wx_c_user wcu on wcu.user_id = wcubi.id | |||||
| where 1=1 | |||||
| <if test=" null != startTime "> | <if test=" null != startTime "> | ||||
| and create_date >= #{startTime} | |||||
| and wcubi.create_date >= #{startTime} | |||||
| </if> | </if> | ||||
| <if test=" null != endTime"> | <if test=" null != endTime"> | ||||
| and create_date < #{endTime} | |||||
| and wcubi.create_date < #{endTime} | |||||
| </if> | </if> | ||||
| <if test=" null != tenantId and '' != tenantId"> | <if test=" null != tenantId and '' != tenantId"> | ||||
| and `tenant_id` = #{tenantId} | |||||
| and wcu.`tenant_id` = #{tenantId} | |||||
| </if> | </if> | ||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | <if test=" null != parentTenantId and '' != parentTenantId"> | ||||
| and `parent_tenant_id` = #{parentTenantId} | |||||
| and wcu.`parent_tenant_id` = #{parentTenantId} | |||||
| </if> | </if> | ||||
| <if test="1 == queryImport"> | <if test="1 == queryImport"> | ||||
| and create_date like '%00:00:00' | |||||
| and wcubi.create_date like '%00:00:00' | |||||
| </if> | </if> | ||||
| </select> | </select> | ||||
| <select id="findCountHistory" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" 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, | |||||
| select count(distinct wcubi.id) as incCount, | |||||
| <if test="1 == reportType "> | <if test="1 == reportType "> | ||||
| date_format(create_date, '%Y-%m-%d') as reportTime, | |||||
| date_format(wcubi.create_date, '%Y-%m-%d') as reportTime, | |||||
| </if> | </if> | ||||
| <if test="2 == reportType "> | <if test="2 == reportType "> | ||||
| date_format(create_date, '%Y-%m') as reportTime, | |||||
| date_format(wcubi.create_date, '%Y-%m') as reportTime, | |||||
| </if> | </if> | ||||
| <if test="3 == reportType "> | <if test="3 == reportType "> | ||||
| date_format(create_date, '%Y') as reportTime, | |||||
| date_format(wcubi.create_date, '%Y') as reportTime, | |||||
| </if> | </if> | ||||
| <if test="1 == reportType or 2 == reportType or 3 == reportType"> | <if test="1 == reportType or 2 == reportType or 3 == reportType"> | ||||
| (select count(id) from wx_c_user_basic_info | |||||
| where | |||||
| (select count(distinct wcubi.id) from wx_c_user_basic_info wcubi | |||||
| left join wx_c_user wcu on wcu.user_id = wcubi.id | |||||
| where 1=1 | |||||
| <if test="1 == reportType "> | <if test="1 == reportType "> | ||||
| date_format(create_date, '%Y-%m-%d') <= reportTime | |||||
| date_format(wcubi.create_date, '%Y-%m-%d') <= reportTime | |||||
| </if> | </if> | ||||
| <if test="2 == reportType "> | <if test="2 == reportType "> | ||||
| date_format(create_date, '%Y-%m') <= reportTime | |||||
| date_format(wcubi.create_date, '%Y-%m') <= reportTime | |||||
| </if> | </if> | ||||
| <if test="3 == reportType "> | <if test="3 == reportType "> | ||||
| date_format(create_date, '%Y') <= reportTime | |||||
| date_format(wcubi.create_date, '%Y') <= reportTime | |||||
| </if> | </if> | ||||
| <if test=" null != tenantId and '' != tenantId"> | <if test=" null != tenantId and '' != tenantId"> | ||||
| and `tenant_id` = #{tenantId} | |||||
| and wcu.`tenant_id` = #{tenantId} | |||||
| </if> | </if> | ||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | <if test=" null != parentTenantId and '' != parentTenantId"> | ||||
| and `parent_tenant_id` = #{parentTenantId} | |||||
| and wcu.`parent_tenant_id` = #{parentTenantId} | |||||
| </if> | </if> | ||||
| ) as totalCount | ) as totalCount | ||||
| </if> | </if> | ||||
| from wx_c_user_basic_info where 1=1 | |||||
| from wx_c_user_basic_info wcubi | |||||
| left join wx_c_user wcu on wcu.user_id = wcubi.id | |||||
| where 1=1 | |||||
| <if test=" null != tenantId and '' != tenantId"> | <if test=" null != tenantId and '' != tenantId"> | ||||
| and `tenant_id` = #{tenantId} | |||||
| and wcu.`tenant_id` = #{tenantId} | |||||
| </if> | </if> | ||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | <if test=" null != parentTenantId and '' != parentTenantId"> | ||||
| and `parent_tenant_id` = #{parentTenantId} | |||||
| and wcu.`parent_tenant_id` = #{parentTenantId} | |||||
| </if> | </if> | ||||
| <if test=" null != startTime "> | <if test=" null != startTime "> | ||||
| and create_date >= #{startTime} | |||||
| and wcubi.create_date >= #{startTime} | |||||
| </if> | </if> | ||||
| <if test=" null != endTime"> | <if test=" null != endTime"> | ||||
| and create_date < #{endTime} | |||||
| and wcubi.create_date < #{endTime} | |||||
| </if> | </if> | ||||
| <if test="1 == reportType or 2 == reportType or 3 == reportType"> | <if test="1 == reportType or 2 == reportType or 3 == reportType"> | ||||
| group by reportTime | |||||
| group by wcubi.reportTime | |||||
| </if> | </if> | ||||
| </select> | </select> | ||||
| @@ -369,6 +377,7 @@ | |||||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> | <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> | ||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | ||||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/> | <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/> | ||||
| <result column="final_tenant_id" jdbcType="VARCHAR" property="finalTenantId"/> | |||||
| <result column="name" jdbcType="VARCHAR" property="name"/> | <result column="name" jdbcType="VARCHAR" property="name"/> | ||||
| <result column="level" jdbcType="VARCHAR" property="level"/> | <result column="level" jdbcType="VARCHAR" property="level"/> | ||||
| <result column="nick_name" jdbcType="VARCHAR" property="nickName"/> | <result column="nick_name" jdbcType="VARCHAR" property="nickName"/> | ||||
| @@ -378,9 +387,9 @@ | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allVoColumns"> | <sql id="allVoColumns"> | ||||
| cu.`id`,cu.`phone`,cu.`birthdate`,cu.`education`,cu.`sex`,cu.`email`,cu.`address`,cu.`poins`,cu.`tag_id`, | |||||
| distinct cu.`id`,cu.`phone`,cu.`birthdate`,cu.`education`,cu.`sex`,cu.`email`,cu.`address`,cu.`poins`,cu.`tag_id`, | |||||
| cu.`create_date`,cu.`update_date`,cu.`tenant_id`,cu.`name`,cu.`level`,cu.`nick_name`, | cu.`create_date`,cu.`update_date`,cu.`tenant_id`,cu.`name`,cu.`level`,cu.`nick_name`, | ||||
| cut.`tags`,cu.`credit`,cu.`active_time`,cu.`act_record`,cu.`parent_tenant_id` | |||||
| cut.`tags`,cu.`credit`,cu.`active_time`,cu.`act_record`,cu.`parent_tenant_id`,cu.`final_tenant_id` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicVoWhereConditions"> | <sql id="dynamicVoWhereConditions"> | ||||
| @@ -391,10 +400,13 @@ | |||||
| </if> | </if> | ||||
| <if test=" null != tenantId and '' != tenantId"> | <if test=" null != tenantId and '' != tenantId"> | ||||
| and cu.`tenant_id` = #{tenantId} | |||||
| and c.`tenant_id` = #{tenantId} | |||||
| </if> | </if> | ||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | <if test=" null != parentTenantId and '' != parentTenantId"> | ||||
| and cu.`parent_tenant_id` = #{parentTenantId} | |||||
| and c.`parent_tenant_id` = #{parentTenantId} | |||||
| </if> | |||||
| <if test=" null != finalTenantId and '' != finalTenantId"> | |||||
| and cu.`final_tenant_id` = #{finalTenantId} | |||||
| </if> | </if> | ||||
| <if test=" null != phone "> | <if test=" null != phone "> | ||||
| @@ -460,30 +472,32 @@ | |||||
| select | select | ||||
| <include refid="allVoColumns"/> | <include refid="allVoColumns"/> | ||||
| from wx_c_user_basic_info cu | from wx_c_user_basic_info cu | ||||
| left join wx_c_user c on c.user_id = cu.id | |||||
| left join wx_c_user_tags cut on cut.`id` = cu.`tag_id` | left join wx_c_user_tags cut on cut.`id` = cu.`tag_id` | ||||
| <include refid="dynamicVoWhereConditions"/> | <include refid="dynamicVoWhereConditions"/> | ||||
| </select> | </select> | ||||
| <select id="countVoList" parameterType="com.iformall.domain.po.WxCUserBasicInfo" resultType="java.lang.Integer"> | <select id="countVoList" parameterType="com.iformall.domain.po.WxCUserBasicInfo" resultType="java.lang.Integer"> | ||||
| select | select | ||||
| count(*) | |||||
| count(distinct cu.id) | |||||
| from wx_c_user_basic_info cu | from wx_c_user_basic_info cu | ||||
| left join wx_c_user c on c.user_id = cu.id | |||||
| left join wx_c_user_tags cut on cut.`id` = cu.`tag_id` | left join wx_c_user_tags cut on cut.`id` = cu.`tag_id` | ||||
| <include refid="dynamicVoWhereConditions"/> | <include refid="dynamicVoWhereConditions"/> | ||||
| </select> | </select> | ||||
| <sql id="msgColumns"> | <sql id="msgColumns"> | ||||
| cu.`id`,cu.`phone`,cu.`email` | |||||
| distinct cu.`id`,cu.`phone`,cu.`email` | |||||
| </sql> | </sql> | ||||
| <sql id="filterWhereConditions"> | <sql id="filterWhereConditions"> | ||||
| where 1=1 | where 1=1 | ||||
| <if test=" null != tenantId and '' != tenantId"> | <if test=" null != tenantId and '' != tenantId"> | ||||
| and cu.`tenant_id` = #{tenantId} | |||||
| and c.`tenant_id` = #{tenantId} | |||||
| </if> | </if> | ||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | <if test=" null != parentTenantId and '' != parentTenantId"> | ||||
| and cu.`parent_tenant_id` = #{parentTenantId} | |||||
| and c.`parent_tenant_id` = #{parentTenantId} | |||||
| </if> | </if> | ||||
| <if test=" null != startTime "> | <if test=" null != startTime "> | ||||
| @@ -550,7 +564,8 @@ | |||||
| </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(*) from wx_c_user_basic_info cu | |||||
| select count(distinct cu.id) from wx_c_user_basic_info cu | |||||
| left join wx_c_user c on c.user_id = cu.id | |||||
| <if test=" null != tagIds "> | <if test=" null != tagIds "> | ||||
| join wx_c_user_tags cut on cut.`id` = cu.`tag_id` | join wx_c_user_tags cut on cut.`id` = cu.`tag_id` | ||||
| </if> | </if> | ||||
| @@ -560,6 +575,7 @@ | |||||
| <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="msgColumns"/> | select <include refid="msgColumns"/> | ||||
| from wx_c_user_basic_info cu | from wx_c_user_basic_info cu | ||||
| left join wx_c_user c on c.user_id = cu.id | |||||
| <if test=" null != tagIds "> | <if test=" null != tagIds "> | ||||
| join wx_c_user_tags cut on cut.`id` = cu.`tag_id` | join wx_c_user_tags cut on cut.`id` = cu.`tag_id` | ||||
| </if> | </if> | ||||
| @@ -568,22 +584,26 @@ | |||||
| <select id="findImportUserCount" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long"> | <select id="findImportUserCount" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long"> | ||||
| SELECT count(*) FROM wx_c_user_basic_info cubi left join wx_c_user cu on cubi.id=cu.user_id where cu.id is null | |||||
| SELECT count(distinct cubi.id) FROM wx_c_user_basic_info cubi | |||||
| left join wx_c_user cu on cubi.id=cu.user_id | |||||
| where 1=1 | |||||
| <if test=" null != tenantId and '' != tenantId"> | <if test=" null != tenantId and '' != tenantId"> | ||||
| and cubi.`tenant_id` = #{tenantId} | |||||
| and cu.`tenant_id` = #{tenantId} | |||||
| </if> | </if> | ||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | <if test=" null != parentTenantId and '' != parentTenantId"> | ||||
| and cubi.`parent_tenant_id` = #{parentTenantId} | |||||
| and cu.`parent_tenant_id` = #{parentTenantId} | |||||
| </if> | </if> | ||||
| </select> | </select> | ||||
| <select id="findGrowUserCount" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long"> | <select id="findGrowUserCount" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long"> | ||||
| SELECT count(*) FROM wx_c_user_basic_info cubi left join wx_c_user cu on cubi.id=cu.user_id where cu.id is not null | |||||
| SELECT count(distinct cubi.id) FROM wx_c_user_basic_info cubi | |||||
| left join wx_c_user cu on cubi.id=cu.user_id | |||||
| where 1=1 | |||||
| <if test=" null != tenantId and '' != tenantId"> | <if test=" null != tenantId and '' != tenantId"> | ||||
| and cubi.`tenant_id` = #{tenantId} | |||||
| and cu.`tenant_id` = #{tenantId} | |||||
| </if> | </if> | ||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | <if test=" null != parentTenantId and '' != parentTenantId"> | ||||
| and cubi.`parent_tenant_id` = #{parentTenantId} | |||||
| and cu.`parent_tenant_id` = #{parentTenantId} | |||||
| </if> | </if> | ||||
| </select> | </select> | ||||
| @@ -87,11 +87,9 @@ | |||||
| where uc.c_user_id = ubi.id | where uc.c_user_id = ubi.id | ||||
| <if test=" null != tenantId and '' != tenantId"> | <if test=" null != tenantId and '' != tenantId"> | ||||
| and uc.tenant_id = #{tenantId} | and uc.tenant_id = #{tenantId} | ||||
| and ubi.tenant_id = #{tenantId} | |||||
| </if> | </if> | ||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | <if test=" null != parentTenantId and '' != parentTenantId"> | ||||
| and uc.parent_tenant_id = #{parentTenantId} | and uc.parent_tenant_id = #{parentTenantId} | ||||
| and ubi.parent_tenant_id = #{parentTenantId} | |||||
| </if> | </if> | ||||
| <if test=" null != startTime "> | <if test=" null != startTime "> | ||||
| and ubi.create_date >= #{startTime} | and ubi.create_date >= #{startTime} | ||||
| @@ -119,11 +117,9 @@ | |||||
| WHERE uc.c_user_id = ubi.id | WHERE uc.c_user_id = ubi.id | ||||
| <if test=" null != tenantId and '' != tenantId"> | <if test=" null != tenantId and '' != tenantId"> | ||||
| and uc.tenant_id = #{tenantId} | and uc.tenant_id = #{tenantId} | ||||
| and ubi.tenant_id = #{tenantId} | |||||
| </if> | </if> | ||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | <if test=" null != parentTenantId and '' != parentTenantId"> | ||||
| and uc.parent_tenant_id = #{parentTenantId} | and uc.parent_tenant_id = #{parentTenantId} | ||||
| and ubi.parent_tenant_id = #{parentTenantId} | |||||
| </if> | </if> | ||||
| AND ubi.create_date BETWEEN #{startdate} AND #{enddate}) c | AND ubi.create_date BETWEEN #{startdate} AND #{enddate}) c | ||||
| GROUP BY c.create_time ORDER BY c.create_time | GROUP BY c.create_time ORDER BY c.create_time | ||||
| @@ -2,6 +2,7 @@ package com.iformall.config; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.po.base.BaseCUserEntity; | |||||
| import com.iformall.domain.vo.WxCouponCVo; | import com.iformall.domain.vo.WxCouponCVo; | ||||
| import com.iformall.domain.vo.WxCouponChannelVo; | import com.iformall.domain.vo.WxCouponChannelVo; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| @@ -142,6 +143,23 @@ public class RedisConfig extends CachingConfigurerSupport { | |||||
| return template; | return template; | ||||
| } | } | ||||
| @Bean("baseCUserTokenRedisTemplate") | |||||
| public RedisTemplate<String, BaseCUserEntity> getBaseCUserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
| RedisTemplate<String, BaseCUserEntity> template = new RedisTemplate<String, BaseCUserEntity>(); | |||||
| Jackson2JsonRedisSerializer<BaseCUserEntity> j = new Jackson2JsonRedisSerializer<BaseCUserEntity>(BaseCUserEntity.class); | |||||
| // value值的序列化 | |||||
| template.setValueSerializer(j); | |||||
| template.setHashKeySerializer(j); | |||||
| // key的序列化 | |||||
| template.setKeySerializer(new StringRedisSerializer()); | |||||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||||
| template.setConnectionFactory(connectionFactory); | |||||
| return template; | |||||
| } | |||||
| @Bean("cUserBasicInfoRedisTemplate") | @Bean("cUserBasicInfoRedisTemplate") | ||||
| public RedisTemplate<String, WxCUserBasicInfo> getCUserBasicInfoRedisTemplate(RedisConnectionFactory connectionFactory) { | public RedisTemplate<String, WxCUserBasicInfo> getCUserBasicInfoRedisTemplate(RedisConnectionFactory connectionFactory) { | ||||
| RedisTemplate<String, WxCUserBasicInfo> template = new RedisTemplate<String, WxCUserBasicInfo>(); | RedisTemplate<String, WxCUserBasicInfo> template = new RedisTemplate<String, WxCUserBasicInfo>(); | ||||
| @@ -2,6 +2,7 @@ package com.iformall.config; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.po.base.BaseCUserEntity; | |||||
| import com.iformall.domain.vo.WxCouponCVo; | import com.iformall.domain.vo.WxCouponCVo; | ||||
| import com.iformall.domain.vo.WxCouponChannelVo; | import com.iformall.domain.vo.WxCouponChannelVo; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| @@ -127,6 +128,23 @@ public class RedisConfig extends CachingConfigurerSupport { | |||||
| return template; | return template; | ||||
| } | } | ||||
| @Bean("baseCUserTokenRedisTemplate") | |||||
| public RedisTemplate<String, BaseCUserEntity> getBaseCUserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | |||||
| RedisTemplate<String, BaseCUserEntity> template = new RedisTemplate<String, BaseCUserEntity>(); | |||||
| Jackson2JsonRedisSerializer<BaseCUserEntity> j = new Jackson2JsonRedisSerializer<BaseCUserEntity>(BaseCUserEntity.class); | |||||
| // value值的序列化 | |||||
| template.setValueSerializer(j); | |||||
| template.setHashKeySerializer(j); | |||||
| // key的序列化 | |||||
| template.setKeySerializer(new StringRedisSerializer()); | |||||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||||
| template.setConnectionFactory(connectionFactory); | |||||
| return template; | |||||
| } | |||||
| @Bean("cUserBasicInfoRedisTemplate") | @Bean("cUserBasicInfoRedisTemplate") | ||||
| public RedisTemplate<String, WxCUserBasicInfo> getCUserBasicInfoRedisTemplate(RedisConnectionFactory connectionFactory) { | public RedisTemplate<String, WxCUserBasicInfo> getCUserBasicInfoRedisTemplate(RedisConnectionFactory connectionFactory) { | ||||
| RedisTemplate<String, WxCUserBasicInfo> template = new RedisTemplate<String, WxCUserBasicInfo>(); | RedisTemplate<String, WxCUserBasicInfo> template = new RedisTemplate<String, WxCUserBasicInfo>(); | ||||
| @@ -1,9 +1,9 @@ | |||||
| package com.iformall.interceptor; | package com.iformall.interceptor; | ||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.domain.po.WxCUser; | |||||
| import com.iformall.domain.po.base.BaseCUserEntity; | |||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.service.WxCUserTokenService; | |||||
| import com.iformall.service.CUserTokenService; | |||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| @@ -29,7 +29,7 @@ public class AuthHandshakeInterceptor implements HandshakeInterceptor { | |||||
| private Logger logger = LoggerFactory.getLogger(this.getClass()); | private Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| @Autowired | @Autowired | ||||
| WxCUserTokenService userTokenService; | |||||
| CUserTokenService cUserTokenService; | |||||
| public static final String LOGIN_USER_KEY = "LOGIN_USER_KEY"; | public static final String LOGIN_USER_KEY = "LOGIN_USER_KEY"; | ||||
| public static final String TENANT_ID = "TENANT_ID"; | public static final String TENANT_ID = "TENANT_ID"; | ||||
| @@ -52,15 +52,15 @@ public class AuthHandshakeInterceptor implements HandshakeInterceptor { | |||||
| } | } | ||||
| // 查询token信息 | // 查询token信息 | ||||
| WxCUser wxCUser = userTokenService.getByToken(token); | |||||
| if(wxCUser == null || wxCUser.getExpireTime().getTime() < System.currentTimeMillis()){ | |||||
| BaseCUserEntity cUser = cUserTokenService.getByToken(token); | |||||
| if(cUser == null || cUser.getExpireTime().getTime() < System.currentTimeMillis()){ | |||||
| throw new MallinkException(ErrorCode.NET_TOKEN_INVALID.getCode(), "URL:" + serverHttpRequest.getServletRequest().getRequestURI() + " token失效,请重新登录"); | throw new MallinkException(ErrorCode.NET_TOKEN_INVALID.getCode(), "URL:" + serverHttpRequest.getServletRequest().getRequestURI() + " token失效,请重新登录"); | ||||
| } | } | ||||
| HttpSession session = serverHttpRequest.getServletRequest().getSession(); | HttpSession session = serverHttpRequest.getServletRequest().getSession(); | ||||
| if (session != null) { | if (session != null) { | ||||
| //attributes.put("userId", session.getAttribute("userId")); | //attributes.put("userId", session.getAttribute("userId")); | ||||
| attributes.put(LOGIN_USER_KEY, wxCUser.getId()); | |||||
| attributes.put(TENANT_ID, wxCUser.getTenantId()); | |||||
| attributes.put(LOGIN_USER_KEY, cUser.getId()); | |||||
| attributes.put(TENANT_ID, cUser.getTenantId()); | |||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||