| @@ -1,11 +1,14 @@ | |||||
| package com.iformall.controller.basic; | package com.iformall.controller.basic; | ||||
| import com.iformall.annotation.SystemControllerLog; | import com.iformall.annotation.SystemControllerLog; | ||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
| import com.iformall.domain.po.WxMall; | import com.iformall.domain.po.WxMall; | ||||
| import com.iformall.enums.EnumGroupSupport; | |||||
| import com.iformall.service.WxMallService; | import com.iformall.service.WxMallService; | ||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| 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; | ||||
| @@ -41,7 +44,17 @@ public class WxMallController extends BaseController { | |||||
| @SystemControllerLog(description = "商城-当前查询") | @SystemControllerLog(description = "商城-当前查询") | ||||
| public ResultData mallinfo() { | public ResultData mallinfo() { | ||||
| logger.debug("[" + getIpAddr() + "] WxMallController::mallinfo"); | logger.debug("[" + getIpAddr() + "] WxMallController::mallinfo"); | ||||
| return new ResultData(wxMallService.getByTenantInfo(ifParentUpdateTenantInfo())); | |||||
| WxMall mall = wxMallService.getByTenantInfo(ifParentUpdateTenantInfo()); | |||||
| if(mall == null) { | |||||
| logger.error("未配置相应的mall"); | |||||
| return new ResultData(Result.ERROR, "未配置相应的mall"); | |||||
| } | |||||
| if (mall.getGroupSupport().equals(EnumGroupSupport.SUPPORT.getCode()) && | |||||
| StringUtils.isBlank(mall.getParentTenantId())) { | |||||
| mall.setSubMalls(wxMallService.getSubByParentTenantId(mall.getTenantId())); | |||||
| } | |||||
| mall.setValidPrompt(wxMallService.mallValid(getUserId(),mall)); | |||||
| return new ResultData(mall); | |||||
| } | } | ||||
| @@ -72,10 +72,6 @@ public class WxChartDataController extends BaseController { | |||||
| String chart = params.get("chart"); | String chart = params.get("chart"); | ||||
| logger.info("[" + getIpAddr() + "] WxChartDataController::queryData chart: " + chart); | logger.info("[" + getIpAddr() + "] WxChartDataController::queryData chart: " + chart); | ||||
| TenantEntity tenantEntity = getTenantInfo(); | TenantEntity tenantEntity = getTenantInfo(); | ||||
| if(StringUtils.isBlank(tenantEntity.getTenantId())){ | |||||
| //todo 集团版查询数据待重构 | |||||
| return new ResultData("集团版查询数据待重构"); | |||||
| } | |||||
| params.put("tenantId",tenantEntity.getTenantId()); | params.put("tenantId",tenantEntity.getTenantId()); | ||||
| params.put("parentTenantId", tenantEntity.getParentTenantId()); | params.put("parentTenantId", tenantEntity.getParentTenantId()); | ||||
| ResultData data = wxChartDataService.queryData(params); | ResultData data = wxChartDataService.queryData(params); | ||||
| @@ -1,6 +1,5 @@ | |||||
| package com.iformall.controller.sys; | package com.iformall.controller.sys; | ||||
| import com.alibaba.fastjson.JSON; | |||||
| import com.google.code.kaptcha.Constants; | import com.google.code.kaptcha.Constants; | ||||
| import com.google.code.kaptcha.Producer; | import com.google.code.kaptcha.Producer; | ||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| @@ -158,7 +157,7 @@ public class HomeController extends BaseController { | |||||
| logger.error("mall已过期"); | logger.error("mall已过期"); | ||||
| return new ResultData(Result.ERROR, "mall已过期"); | return new ResultData(Result.ERROR, "mall已过期"); | ||||
| } | } | ||||
| Map map = new HashMap(); | |||||
| // Map map = new HashMap(); | |||||
| if (mall.getGroupSupport().equals(EnumGroupSupport.SUPPORT.getCode()) && | if (mall.getGroupSupport().equals(EnumGroupSupport.SUPPORT.getCode()) && | ||||
| StringUtils.isBlank(info.getParentTenantId())) { | StringUtils.isBlank(info.getParentTenantId())) { | ||||
| @@ -166,10 +165,10 @@ public class HomeController extends BaseController { | |||||
| session.setAttribute(UserSession.tenantId, null); | session.setAttribute(UserSession.tenantId, null); | ||||
| session.setAttribute(UserSession.parentTenantId, info.getTenantId()); | session.setAttribute(UserSession.parentTenantId, info.getTenantId()); | ||||
| // 集团用户获取子商场 | |||||
| List<WxMall> mallList = mallService.getSubByParentTenantId(info.getTenantId()); | |||||
| map.put("subMalls", JSON.toJSONString(mallList)); | |||||
| map.put("group", EnumGroupSupport.SUPPORT.getCode()); | |||||
| // // 集团用户获取子商场 | |||||
| // List<WxMall> mallList = mallService.getSubByParentTenantId(info.getTenantId()); | |||||
| // map.put("subMalls", JSON.toJSONString(mallList)); | |||||
| // map.put("group", EnumGroupSupport.SUPPORT.getCode()); | |||||
| } | } | ||||
| try { | try { | ||||
| @@ -178,11 +177,11 @@ public class HomeController extends BaseController { | |||||
| unameCookie.setPath("/"); | unameCookie.setPath("/"); | ||||
| 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()); | |||||
| data.data = map; | |||||
| // map.put("mall", JSON.toJSONString(mall)); | |||||
| // map.put("mallValid",mallService.mallValid(info.getId(),mall)); | |||||
| // map.put("saleType",mall.getSaleType()); | |||||
| // map.put("withWechat", info.getWithWechat()); | |||||
| // data.data = map; | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error(e.getMessage()); | logger.error(e.getMessage()); | ||||
| return new ResultData(Result.ERROR, e.getMessage()); | return new ResultData(Result.ERROR, e.getMessage()); | ||||
| @@ -191,6 +190,7 @@ public class HomeController extends BaseController { | |||||
| return data; | return data; | ||||
| } | } | ||||
| private boolean isInMobileAdmin(MallUserInfo user) { | private boolean isInMobileAdmin(MallUserInfo user) { | ||||
| // 检查用户是否有 移动端数据塔台 权限 | // 检查用户是否有 移动端数据塔台 权限 | ||||
| boolean isInMobile = false; | boolean isInMobile = false; | ||||
| @@ -303,11 +303,18 @@ public class HomeController extends BaseController { | |||||
| logger.error("mall已过期"); | logger.error("mall已过期"); | ||||
| return new ResultData(Result.ERROR, "mall已过期"); | return new ResultData(Result.ERROR, "mall已过期"); | ||||
| } | } | ||||
| 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()) && | |||||
| StringUtils.isBlank(info.getParentTenantId())) { | |||||
| Session session = SecurityUtils.getSubject().getSession(); | |||||
| session.setAttribute(UserSession.tenantId, null); | |||||
| session.setAttribute(UserSession.parentTenantId, info.getTenantId()); | |||||
| // // 集团用户获取子商场 | |||||
| // List<WxMall> mallList = mallService.getSubByParentTenantId(info.getTenantId()); | |||||
| // map.put("subMalls", JSON.toJSONString(mallList)); | |||||
| // map.put("group", EnumGroupSupport.SUPPORT.getCode()); | |||||
| } | } | ||||
| try { | try { | ||||
| String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); | String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); | ||||
| @@ -316,9 +323,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("withWechat", info.getWithWechat()); | |||||
| data.data = map; | |||||
| // map.put("username", info.getUsername()); | |||||
| // map.put("withWechat", info.getWithWechat()); | |||||
| // data.data = map; | |||||
| } catch(Exception e){ | } catch(Exception e){ | ||||
| logger.error(e.getMessage()); | logger.error(e.getMessage()); | ||||
| @@ -417,11 +424,18 @@ public class HomeController extends BaseController { | |||||
| logger.error("mall已过期"); | logger.error("mall已过期"); | ||||
| return new ResultData(Result.ERROR, "mall已过期"); | return new ResultData(Result.ERROR, "mall已过期"); | ||||
| } | } | ||||
| 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()) && | |||||
| StringUtils.isBlank(info.getParentTenantId())) { | |||||
| Session session = SecurityUtils.getSubject().getSession(); | |||||
| session.setAttribute(UserSession.tenantId, null); | |||||
| session.setAttribute(UserSession.parentTenantId, info.getTenantId()); | |||||
| // // 集团用户获取子商场 | |||||
| // List<WxMall> mallList = mallService.getSubByParentTenantId(info.getTenantId()); | |||||
| // map.put("subMalls", JSON.toJSONString(mallList)); | |||||
| // map.put("group", EnumGroupSupport.SUPPORT.getCode()); | |||||
| } | } | ||||
| String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); | String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); | ||||
| @@ -430,12 +444,12 @@ 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("mallValid",mallService.mallValid(info.getId(),mall)); | |||||
| map.put("saleType",mall.getSaleType()); | |||||
| map.put("withWechat", info.getWithWechat()); | |||||
| // map.put("mall", JSON.toJSONString(mall)); | |||||
| // map.put("mallValid",mallService.mallValid(info.getId(),mall)); | |||||
| // map.put("saleType",mall.getSaleType()); | |||||
| // map.put("withWechat", info.getWithWechat()); | |||||
| return new ResultData(map); | |||||
| return new ResultData(); | |||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| return new ResultData(e.getErrorCode(), e.getMessage()); | return new ResultData(e.getErrorCode(), e.getMessage()); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| @@ -34,6 +34,7 @@ import org.apache.commons.lang3.StringUtils; | |||||
| import org.apache.shiro.SecurityUtils; | import org.apache.shiro.SecurityUtils; | ||||
| import org.apache.shiro.authc.DisabledAccountException; | import org.apache.shiro.authc.DisabledAccountException; | ||||
| import org.apache.shiro.authc.UnknownAccountException; | import org.apache.shiro.authc.UnknownAccountException; | ||||
| import org.apache.shiro.session.Session; | |||||
| import org.apache.shiro.subject.Subject; | import org.apache.shiro.subject.Subject; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.beans.factory.annotation.Qualifier; | import org.springframework.beans.factory.annotation.Qualifier; | ||||
| @@ -187,11 +188,11 @@ 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()); | |||||
| if (mall.getGroupSupport().equals(EnumGroupSupport.SUPPORT.getCode()) && | |||||
| StringUtils.isBlank(info.getParentTenantId())) { | |||||
| Session session = SecurityUtils.getSubject().getSession(); | |||||
| session.setAttribute(UserSession.tenantId, null); | |||||
| session.setAttribute(UserSession.parentTenantId, info.getTenantId()); | |||||
| } | } | ||||
| try { | try { | ||||
| String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); | String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); | ||||
| @@ -200,11 +201,6 @@ 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()); | ||||
| @@ -363,11 +359,11 @@ 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()); | |||||
| if (mall.getGroupSupport().equals(EnumGroupSupport.SUPPORT.getCode()) && | |||||
| StringUtils.isBlank(info.getParentTenantId())) { | |||||
| Session session = SecurityUtils.getSubject().getSession(); | |||||
| session.setAttribute(UserSession.tenantId, null); | |||||
| session.setAttribute(UserSession.parentTenantId, info.getTenantId()); | |||||
| } | } | ||||
| // 登录cookie | // 登录cookie | ||||
| String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); | String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); | ||||
| @@ -376,11 +372,6 @@ 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()); | ||||
| @@ -106,24 +106,35 @@ public class WxMall extends TenantEntity { | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private boolean valid; | private boolean valid; | ||||
| @TableField(exist = false) | |||||
| private Integer surplusDay;//距离过期还剩天数 | |||||
| private boolean validPrompt;//到期提醒 | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| protected List<WxMall> subMalls; | protected List<WxMall> subMalls; | ||||
| public boolean isValid() { | public boolean isValid() { | ||||
| if(saleType != null) { | |||||
| if(validStart != null && validEnd != null) { | |||||
| Date today = DateUtils.getDateZero(new Date()); | |||||
| if(today.before(validStart) || today.after(validEnd)) { | |||||
| return false; | |||||
| } else { | |||||
| return true; | |||||
| } | |||||
| } | |||||
| if(saleType != null && validEnd != null) { | |||||
| Date today = DateUtils.getDateZero(new Date()); | |||||
| if(today.after(validEnd)) { | |||||
| return false; | |||||
| } else { | |||||
| return true; | |||||
| } | |||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| public Integer getSurplusDay() { | |||||
| if(saleType != null && validEnd != null) { | |||||
| Date today = DateUtils.getDateZero(new Date()); | |||||
| int days = DateUtils.daysBetween(today, validEnd); | |||||
| return days; | |||||
| } | |||||
| return null; | |||||
| } | |||||
| @io.swagger.annotations.ApiModelProperty(value = "营业时间", name = "businessHours") | @io.swagger.annotations.ApiModelProperty(value = "营业时间", name = "businessHours") | ||||
| private String businessHours; | private String businessHours; | ||||
| @@ -90,5 +90,5 @@ public interface WxMallService { | |||||
| ResultData addAadmin(WxMall wxMall); | ResultData addAadmin(WxMall wxMall); | ||||
| String mallValid(Long loginUserId,WxMall mall); | |||||
| boolean mallValid(Long loginUserId,WxMall mall); | |||||
| } | } | ||||
| @@ -369,27 +369,14 @@ public class WxMallServiceImpl implements WxMallService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public String mallValid(Long loginUserId,WxMall mall) { | |||||
| if(mall.getSaleType() == null || mall.getValidEnd() == null){ | |||||
| return null; | |||||
| } | |||||
| 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(days <= 30 && !redisTemplate.hasKey(key)){ | |||||
| RedisCacheUtils.cache(redisTemplate,key,true,3600*6); | |||||
| map.put("isShow",true); | |||||
| }else{ | |||||
| map.put("isShow",false); | |||||
| public boolean mallValid(Long loginUserId,WxMall mall) { | |||||
| if(mall.getSurplusDay() != null && mall.getSurplusDay() <= 30){ | |||||
| String key = Constant.LOGIN_A_USER_VALID + mall.getTenantId() + ":" + loginUserId; | |||||
| if(!redisTemplate.hasKey(key)){ | |||||
| return true; | |||||
| } | |||||
| } | } | ||||
| return JSON.toJSONString(map); | |||||
| return false; | |||||
| } | } | ||||
| } | } | ||||