| @@ -179,8 +179,8 @@ public class HomeController extends BaseController { | |||||
| unameCookie.setMaxAge(3600); | unameCookie.setMaxAge(3600); | ||||
| response.addCookie(unameCookie); | response.addCookie(unameCookie); | ||||
| map.put("mall", JSON.toJSONString(mall)); | map.put("mall", JSON.toJSONString(mall)); | ||||
| map.put("mallValid",mallService.mallValid(info.getId(),mall)); | |||||
| map.put("saleType",mall.getSaleType()); | map.put("saleType",mall.getSaleType()); | ||||
| map.put("username", info.getUsername()); | |||||
| map.put("withWechat", info.getWithWechat()); | map.put("withWechat", info.getWithWechat()); | ||||
| data.data = map; | data.data = map; | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| @@ -430,7 +430,9 @@ public class HomeController extends BaseController { | |||||
| unameCookie.setMaxAge(3600); | unameCookie.setMaxAge(3600); | ||||
| response.addCookie(unameCookie); | response.addCookie(unameCookie); | ||||
| map.put("username", info.getUsername()); | |||||
| map.put("mall", JSON.toJSONString(mall)); | |||||
| map.put("mallValid",mallService.mallValid(info.getId(),mall)); | |||||
| map.put("saleType",mall.getSaleType()); | |||||
| map.put("withWechat", info.getWithWechat()); | map.put("withWechat", info.getWithWechat()); | ||||
| return new ResultData(map); | return new ResultData(map); | ||||
| @@ -200,6 +200,11 @@ public class WechatLoginController extends BaseController { | |||||
| unameCookie.setMaxAge(3600); | unameCookie.setMaxAge(3600); | ||||
| response.addCookie(unameCookie); | response.addCookie(unameCookie); | ||||
| map.put("mall", JSON.toJSONString(mall)); | |||||
| map.put("mallValid",mallService.mallValid(info.getId(),mall)); | |||||
| map.put("saleType",mall.getSaleType()); | |||||
| map.put("withWechat", info.getWithWechat()); | |||||
| MallUserAction action = new MallUserAction(); | MallUserAction action = new MallUserAction(); | ||||
| action.updateTenantInfo(info); | action.updateTenantInfo(info); | ||||
| action.setType(EnumMallUserAction.CONTROLLER.getCode()); | action.setType(EnumMallUserAction.CONTROLLER.getCode()); | ||||
| @@ -358,12 +363,12 @@ public class WechatLoginController extends BaseController { | |||||
| log.error(e.getMessage()); | log.error(e.getMessage()); | ||||
| } | } | ||||
| } | } | ||||
| // Map map = new HashMap(); | |||||
| // if (mall.getGroupSupport().equals(EnumGroupSupport.SUPPORT.getCode())) { | |||||
| // List<WxMall> mallList = mallService.getSubByParentTenantId(mall.getTenantId()); | |||||
| // map.put("subMalls", JSON.toJSONString(mallList)); | |||||
| // map.put("group", EnumGroupSupport.SUPPORT.getCode()); | |||||
| // } | |||||
| Map map = new HashMap(); | |||||
| if (mall.getGroupSupport().equals(EnumGroupSupport.SUPPORT.getCode())) { | |||||
| List<WxMall> mallList = mallService.getSubByParentTenantId(mall.getTenantId()); | |||||
| map.put("subMalls", JSON.toJSONString(mallList)); | |||||
| map.put("group", EnumGroupSupport.SUPPORT.getCode()); | |||||
| } | |||||
| // 登录cookie | // 登录cookie | ||||
| String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); | String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); | ||||
| Cookie unameCookie = new Cookie("uname", cookieName); | Cookie unameCookie = new Cookie("uname", cookieName); | ||||
| @@ -371,6 +376,11 @@ public class WechatLoginController extends BaseController { | |||||
| unameCookie.setMaxAge(3600); | unameCookie.setMaxAge(3600); | ||||
| response.addCookie(unameCookie); | response.addCookie(unameCookie); | ||||
| map.put("mall", JSON.toJSONString(mall)); | |||||
| map.put("mallValid",mallService.mallValid(info.getId(),mall)); | |||||
| map.put("saleType",mall.getSaleType()); | |||||
| map.put("withWechat", info.getWithWechat()); | |||||
| MallUserAction action = new MallUserAction(); | MallUserAction action = new MallUserAction(); | ||||
| action.updateTenantInfo(info); | action.updateTenantInfo(info); | ||||
| action.setType(EnumMallUserAction.CONTROLLER.getCode()); | action.setType(EnumMallUserAction.CONTROLLER.getCode()); | ||||
| @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | |||||
| import com.fasterxml.jackson.annotation.JsonProperty; | import com.fasterxml.jackson.annotation.JsonProperty; | ||||
| import com.iformall.domain.po.base.BaseEntity; | import com.iformall.domain.po.base.BaseEntity; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.utils.DateUtils; | |||||
| import lombok.Data; | import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | import lombok.EqualsAndHashCode; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| @@ -111,8 +112,8 @@ public class WxMall extends TenantEntity { | |||||
| public boolean isValid() { | public boolean isValid() { | ||||
| if(saleType != null) { | if(saleType != null) { | ||||
| if(validStart != null && validEnd != null) { | if(validStart != null && validEnd != null) { | ||||
| Date curDate = new Date(); | |||||
| if(curDate.before(validStart) || curDate.after(validEnd)) { | |||||
| Date today = DateUtils.getDateZero(new Date()); | |||||
| if(today.before(validStart) || today.after(validEnd)) { | |||||
| return false; | return false; | ||||
| } else { | } else { | ||||
| return true; | return true; | ||||
| @@ -89,4 +89,6 @@ public interface WxMallService { | |||||
| PageInfo<WxMall> listAadminAsPage(WxMall wxMall, Integer pageNum, Integer pageSize); | PageInfo<WxMall> listAadminAsPage(WxMall wxMall, Integer pageNum, Integer pageSize); | ||||
| ResultData addAadmin(WxMall wxMall); | ResultData addAadmin(WxMall wxMall); | ||||
| String mallValid(Long loginUserId,WxMall mall); | |||||
| } | } | ||||
| @@ -1,5 +1,6 @@ | |||||
| package com.iformall.service.impl; | package com.iformall.service.impl; | ||||
| import com.alibaba.fastjson.JSON; | |||||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| @@ -16,6 +17,7 @@ import com.iformall.mapper.WxMallMapper; | |||||
| import com.iformall.service.MallUserInfoService; | import com.iformall.service.MallUserInfoService; | ||||
| import com.iformall.service.WxMallService; | import com.iformall.service.WxMallService; | ||||
| import com.iformall.utils.Constant; | import com.iformall.utils.Constant; | ||||
| import com.iformall.utils.DateUtils; | |||||
| import com.iformall.utils.PasswordHelper; | import com.iformall.utils.PasswordHelper; | ||||
| import com.iformall.utils.RedisCacheUtils; | import com.iformall.utils.RedisCacheUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| @@ -30,7 +32,9 @@ import org.springframework.transaction.annotation.Transactional; | |||||
| import org.springframework.util.Assert; | import org.springframework.util.Assert; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.HashMap; | |||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | |||||
| import java.util.concurrent.TimeUnit; | import java.util.concurrent.TimeUnit; | ||||
| import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
| @@ -56,7 +60,7 @@ public class WxMallServiceImpl implements WxMallService { | |||||
| @Autowired | @Autowired | ||||
| @Qualifier("objectCommonRedisTemplate") | @Qualifier("objectCommonRedisTemplate") | ||||
| RedisTemplate<String, Object> subMallListRedisTemplate; | |||||
| RedisTemplate<String, Object> redisTemplate; | |||||
| @@ -224,12 +228,12 @@ public class WxMallServiceImpl implements WxMallService { | |||||
| @Override | @Override | ||||
| public List<WxMall> getSubByParentTenantId(String parentTenantId) { | public List<WxMall> getSubByParentTenantId(String parentTenantId) { | ||||
| String key = Constant.subMallinfoPrev + parentTenantId; | String key = Constant.subMallinfoPrev + parentTenantId; | ||||
| List<WxMall> mallList = RedisCacheUtils.getCacheListObject(subMallListRedisTemplate, key, WxMall.class); | |||||
| List<WxMall> mallList = RedisCacheUtils.getCacheListObject(redisTemplate, key, WxMall.class); | |||||
| if(null == mallList || mallList.size() == 0){ | if(null == mallList || mallList.size() == 0){ | ||||
| WxMall q = new WxMall(); | WxMall q = new WxMall(); | ||||
| q.setParentTenantId(parentTenantId); | q.setParentTenantId(parentTenantId); | ||||
| mallList = wxMallMapper.selectList(new QueryWrapper<>(q)); | mallList = wxMallMapper.selectList(new QueryWrapper<>(q)); | ||||
| RedisCacheUtils.cache(subMallListRedisTemplate, key, mallList, 3600*24*7); | |||||
| RedisCacheUtils.cache(redisTemplate, key, mallList, 3600*24*7); | |||||
| } | } | ||||
| return mallList; | return mallList; | ||||
| } | } | ||||
| @@ -263,10 +267,10 @@ public class WxMallServiceImpl implements WxMallService { | |||||
| mallRedisTemplate.delete(key1); | mallRedisTemplate.delete(key1); | ||||
| } | } | ||||
| String key2 = Constant.subMallinfoPrev + tenantEntity.getTenantId(); | String key2 = Constant.subMallinfoPrev + tenantEntity.getTenantId(); | ||||
| RedisCacheUtils.removeCache(subMallListRedisTemplate, key2); | |||||
| RedisCacheUtils.removeCache(redisTemplate, key2); | |||||
| if(StringUtils.isNotBlank(tenantEntity.getParentTenantId())){ | if(StringUtils.isNotBlank(tenantEntity.getParentTenantId())){ | ||||
| String key3 = Constant.subMallinfoPrev + tenantEntity.getParentTenantId(); | String key3 = Constant.subMallinfoPrev + tenantEntity.getParentTenantId(); | ||||
| RedisCacheUtils.removeCache(subMallListRedisTemplate, key3); | |||||
| RedisCacheUtils.removeCache(redisTemplate, key3); | |||||
| } | } | ||||
| } | } | ||||
| @@ -364,4 +368,25 @@ public class WxMallServiceImpl implements WxMallService { | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @Override | |||||
| public String mallValid(Long loginUserId,WxMall mall) { | |||||
| Map<String,Object> map = new HashMap<>(); | |||||
| Date today = DateUtils.getDateZero(new Date()); | |||||
| map.put("mallName",mall.getName()); | |||||
| //到期时间 | |||||
| map.put("validEnd",mall.getValidEnd()); | |||||
| //距离过期还剩天数 | |||||
| int days = DateUtils.daysBetween(today, mall.getValidEnd()); | |||||
| map.put("surplusDay",days); | |||||
| //是否展示(6小时登陆展示) | |||||
| String key = Constant.LOGIN_A_USER_VALID + mall.getTenantId() + ":" + loginUserId; | |||||
| if(redisTemplate.hasKey(key)){ | |||||
| map.put("isShow",false); | |||||
| }else{ | |||||
| RedisCacheUtils.cache(redisTemplate,key,true,3600*6); | |||||
| map.put("isShow",true); | |||||
| } | |||||
| return JSON.toJSONString(map); | |||||
| } | |||||
| } | } | ||||
| @@ -37,6 +37,8 @@ public class Constant { | |||||
| // TOKEN过期时间, 7天后过期 | // TOKEN过期时间, 7天后过期 | ||||
| public final static int S_D_EXPIRE = EXPIRE * 7; | public final static int S_D_EXPIRE = EXPIRE * 7; | ||||
| public static final String LOGIN_A_USER_VALID = "LOGIN_A_USER_VALID:"; | |||||
| // C端token | // C端token | ||||
| public static final String tokenPrev = "weapp:token:"; | public static final String tokenPrev = "weapp:token:"; | ||||