| @@ -2,6 +2,7 @@ package com.iformall.config; | |||
| import com.iformall.domain.po.PushLimit; | |||
| import com.iformall.domain.po.WxCUser; | |||
| import com.iformall.domain.po.WxMall; | |||
| import com.iformall.domain.po.WxScoreRules; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| @@ -142,4 +143,21 @@ public class RedisConfig extends CachingConfigurerSupport { | |||
| return template; | |||
| } | |||
| @Bean("mallRedisTemplate") | |||
| public RedisTemplate<String, WxMall> getMallRedisTemplate(RedisConnectionFactory connectionFactory) { | |||
| RedisTemplate<String, WxMall> template = new RedisTemplate<String, WxMall>(); | |||
| Jackson2JsonRedisSerializer<WxMall> j = new Jackson2JsonRedisSerializer<WxMall>(WxMall.class); | |||
| // value值的序列化 | |||
| template.setValueSerializer(j); | |||
| template.setHashKeySerializer(j); | |||
| // key的序列化 | |||
| template.setKeySerializer(new StringRedisSerializer()); | |||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||
| template.setConnectionFactory(connectionFactory); | |||
| return template; | |||
| } | |||
| } | |||
| @@ -72,6 +72,9 @@ public class HomeController extends BaseController { | |||
| @Autowired | |||
| private MallUserActionService mallUserActionService; | |||
| @Autowired | |||
| private WxMallService mallService; | |||
| @ApiOperation("验证码") | |||
| @GetMapping("/captcha.jpg") | |||
| public void captcha(HttpServletResponse response)throws ServletException, IOException { | |||
| @@ -138,9 +141,21 @@ public class HomeController extends BaseController { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.USER_PASSWD_ERR); | |||
| } | |||
| if(isLogin) { | |||
| MallUserInfo info = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userInfo); | |||
| info.protectInfos(); | |||
| mallUserActionService.saveActionInfo(info.getTenantId(), EnumMallUserAction.CONTROLLER.getCode(), ipaddress, info.getId(), "用户登录"); | |||
| WxMall mall = mallService.getByTenantId(info.getTenantId()); | |||
| if(mall == null) { | |||
| logger.error("未配置相应的mall"); | |||
| return new ResultData(Result.ERROR, "未配置相应的mall"); | |||
| } | |||
| if(!mall.isValid()) { | |||
| logger.error("mall未启用"); | |||
| return new ResultData(Result.ERROR, "mall未启用"); | |||
| } | |||
| try { | |||
| String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); | |||
| @@ -157,8 +172,6 @@ public class HomeController extends BaseController { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(Result.ERROR, e.getMessage()); | |||
| } | |||
| mallUserActionService.saveActionInfo(info.getTenantId(), EnumMallUserAction.CONTROLLER.getCode(), ipaddress, info.getId(), "用户登录"); | |||
| } | |||
| return data; | |||
| } | |||
| @@ -177,25 +190,25 @@ public class HomeController extends BaseController { | |||
| logger.debug("[" + ipaddress + "] HomeController::bHidLogin"); | |||
| ResultData data = new ResultData(); | |||
| // tenantId is appId | |||
| if(StringUtils.isBlank(user.getTenantId())) { | |||
| if (StringUtils.isBlank(user.getTenantId())) { | |||
| logger.error("appid信息未提供"); | |||
| return new ResultData(ErrorCode.MALL_INFO_NOT_FOUND); | |||
| } | |||
| WxAppinfo appinfo = appinfoService.getByAppId(user.getTenantId()); | |||
| if(appinfo == null) { | |||
| if (appinfo == null) { | |||
| logger.error("appid未找到"); | |||
| return new ResultData(ErrorCode.MALL_INFO_NOT_FOUND); | |||
| } | |||
| if(StringUtils.isNotBlank(user.getPhone())) { | |||
| if (StringUtils.isNotBlank(user.getPhone())) { | |||
| // 领导登录 | |||
| user = mallUserInfoService.getByPhone(user.getPhone(), appinfo.getTenantId()); | |||
| if(user == null || !isInMobileAdmin(user)) { | |||
| if (user == null || !isInMobileAdmin(user)) { | |||
| return new ResultData(ErrorCode.USER_NO_PERMISSION); | |||
| } | |||
| } else if(StringUtils.isNotBlank(user.getBopenId())) { | |||
| } else if (StringUtils.isNotBlank(user.getBopenId())) { | |||
| // 领导登录 | |||
| user = mallUserInfoService.getByBOpenId(user.getBopenId(), appinfo.getTenantId()); | |||
| if(user == null || !isInMobileAdmin(user)) { | |||
| if (user == null || !isInMobileAdmin(user)) { | |||
| return new ResultData(ErrorCode.USER_NO_PERMISSION); | |||
| } | |||
| } else { | |||
| @@ -205,32 +218,54 @@ public class HomeController extends BaseController { | |||
| } | |||
| } | |||
| boolean isLogin = false; | |||
| try { | |||
| Subject subject = SecurityUtils.getSubject(); | |||
| UseriFormallToken token = new UseriFormallToken(user.getUsername()); | |||
| subject.login(token); | |||
| isLogin = true; | |||
| } catch (UnknownAccountException e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.USER_IS_EMPTY); | |||
| } catch (DisabledAccountException e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.USER_IS_LOCKED); | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.USER_PASSWD_ERR); | |||
| } | |||
| if (isLogin) { | |||
| MallUserInfo info = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userInfo); | |||
| info.protectInfos(); | |||
| String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); | |||
| Cookie unameCookie = new Cookie("uname", cookieName); | |||
| unameCookie.setPath("/"); | |||
| unameCookie.setMaxAge(3600); | |||
| response.addCookie(unameCookie); | |||
| mallUserActionService.saveActionInfo(info.getTenantId(), EnumMallUserAction.CONTROLLER.getCode(), ipaddress, info.getId(), "用户登录"); | |||
| WxMall mall = mallService.getByTenantId(info.getTenantId()); | |||
| if (mall == null) { | |||
| logger.error("未配置相应的mall"); | |||
| return new ResultData(Result.ERROR, "未配置相应的mall"); | |||
| } | |||
| if (!mall.isValid()) { | |||
| logger.error("mall未启用"); | |||
| return new ResultData(Result.ERROR, "mall未启用"); | |||
| } | |||
| try { | |||
| String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); | |||
| Cookie unameCookie = new Cookie("uname", cookieName); | |||
| unameCookie.setPath("/"); | |||
| unameCookie.setMaxAge(3600); | |||
| response.addCookie(unameCookie); | |||
| Map map = new HashMap(); | |||
| map.put("username", info.getUsername()); | |||
| map.put("withWechat", info.getWithWechat()); | |||
| data.data = map; | |||
| Map map = new HashMap(); | |||
| map.put("username", info.getUsername()); | |||
| map.put("withWechat", info.getWithWechat()); | |||
| data.data = map; | |||
| mallUserActionService.saveActionInfo(info.getTenantId(), EnumMallUserAction.CONTROLLER.getCode(), ipaddress, info.getId(), "用户B端数据塔台登录"); | |||
| } catch (MallinkException e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.USER_PASSWD_ERR); | |||
| } catch(Exception e){ | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.USER_PASSWD_ERR); | |||
| } | |||
| } | |||
| return data; | |||
| } | |||
| @@ -304,6 +339,17 @@ public class HomeController extends BaseController { | |||
| MallUserInfo info = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userInfo); | |||
| info.protectInfos(); | |||
| mallUserActionService.saveActionInfo(info.getTenantId(), EnumMallUserAction.CONTROLLER.getCode(), ipaddress, info.getId(), "用户手机号登录"); | |||
| WxMall mall = mallService.getByTenantId(info.getTenantId()); | |||
| if (mall == null) { | |||
| logger.error("未配置相应的mall"); | |||
| return new ResultData(Result.ERROR, "未配置相应的mall"); | |||
| } | |||
| if (!mall.isValid()) { | |||
| logger.error("mall未启用"); | |||
| return new ResultData(Result.ERROR, "mall未启用"); | |||
| } | |||
| String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); | |||
| Cookie unameCookie = new Cookie("uname", cookieName); | |||
| @@ -315,8 +361,6 @@ public class HomeController extends BaseController { | |||
| map.put("username", info.getUsername()); | |||
| map.put("withWechat", info.getWithWechat()); | |||
| mallUserActionService.saveActionInfo(info.getTenantId(), EnumMallUserAction.CONTROLLER.getCode(), ipaddress, info.getId(), "用户手机号登录"); | |||
| return new ResultData(map); | |||
| } catch (MallinkException e) { | |||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||
| @@ -0,0 +1,4 @@ | |||
| ALTER TABLE wx_mall | |||
| ADD COLUMN sale_type tinyint(2) DEFAULT '1' COMMENT '销售类型', | |||
| ADD COLUMN valid_start DATE default null COMMENT '启用起始时间', | |||
| ADD COLUMN valid_end DATE default null COMMENT '启用结束时间'; | |||
| @@ -2,6 +2,7 @@ package com.iformall.config; | |||
| import com.iformall.domain.po.PushLimit; | |||
| import com.iformall.domain.po.WxCUser; | |||
| import com.iformall.domain.po.WxMall; | |||
| import com.iformall.domain.po.WxScoreRules; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| @@ -104,4 +105,21 @@ public class RedisConfig extends CachingConfigurerSupport { | |||
| return template; | |||
| } | |||
| @Bean("mallRedisTemplate") | |||
| public RedisTemplate<String, WxMall> getMallRedisTemplate(RedisConnectionFactory connectionFactory) { | |||
| RedisTemplate<String, WxMall> template = new RedisTemplate<String, WxMall>(); | |||
| Jackson2JsonRedisSerializer<WxMall> j = new Jackson2JsonRedisSerializer<WxMall>(WxMall.class); | |||
| // value值的序列化 | |||
| template.setValueSerializer(j); | |||
| template.setHashKeySerializer(j); | |||
| // key的序列化 | |||
| template.setKeySerializer(new StringRedisSerializer()); | |||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||
| template.setConnectionFactory(connectionFactory); | |||
| return template; | |||
| } | |||
| } | |||
| @@ -2,6 +2,7 @@ package com.iformall.config; | |||
| import com.iformall.domain.po.PushLimit; | |||
| import com.iformall.domain.po.WxCUser; | |||
| import com.iformall.domain.po.WxMall; | |||
| import com.iformall.domain.po.WxScoreRules; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| @@ -104,4 +105,21 @@ public class RedisConfig extends CachingConfigurerSupport { | |||
| return template; | |||
| } | |||
| @Bean("mallRedisTemplate") | |||
| public RedisTemplate<String, WxMall> getMallRedisTemplate(RedisConnectionFactory connectionFactory) { | |||
| RedisTemplate<String, WxMall> template = new RedisTemplate<String, WxMall>(); | |||
| Jackson2JsonRedisSerializer<WxMall> j = new Jackson2JsonRedisSerializer<WxMall>(WxMall.class); | |||
| // value值的序列化 | |||
| template.setValueSerializer(j); | |||
| template.setHashKeySerializer(j); | |||
| // key的序列化 | |||
| template.setKeySerializer(new StringRedisSerializer()); | |||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||
| template.setConnectionFactory(connectionFactory); | |||
| return template; | |||
| } | |||
| } | |||
| @@ -2,6 +2,7 @@ package com.iformall.config; | |||
| import com.iformall.domain.po.PushLimit; | |||
| import com.iformall.domain.po.WxCUser; | |||
| import com.iformall.domain.po.WxMall; | |||
| import com.iformall.domain.po.WxScoreRules; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| @@ -142,4 +143,21 @@ public class RedisConfig extends CachingConfigurerSupport { | |||
| return template; | |||
| } | |||
| @Bean("mallRedisTemplate") | |||
| public RedisTemplate<String, WxMall> getMallRedisTemplate(RedisConnectionFactory connectionFactory) { | |||
| RedisTemplate<String, WxMall> template = new RedisTemplate<String, WxMall>(); | |||
| Jackson2JsonRedisSerializer<WxMall> j = new Jackson2JsonRedisSerializer<WxMall>(WxMall.class); | |||
| // value值的序列化 | |||
| template.setValueSerializer(j); | |||
| template.setHashKeySerializer(j); | |||
| // key的序列化 | |||
| template.setKeySerializer(new StringRedisSerializer()); | |||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||
| template.setConnectionFactory(connectionFactory); | |||
| return template; | |||
| } | |||
| } | |||
| @@ -2,6 +2,7 @@ package com.iformall.config; | |||
| import com.iformall.domain.po.PushLimit; | |||
| import com.iformall.domain.po.WxCUser; | |||
| import com.iformall.domain.po.WxMall; | |||
| import com.iformall.domain.po.WxScoreRules; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| @@ -126,4 +127,21 @@ public class RedisConfig extends CachingConfigurerSupport { | |||
| return template; | |||
| } | |||
| @Bean("mallRedisTemplate") | |||
| public RedisTemplate<String, WxMall> getMallRedisTemplate(RedisConnectionFactory connectionFactory) { | |||
| RedisTemplate<String, WxMall> template = new RedisTemplate<String, WxMall>(); | |||
| Jackson2JsonRedisSerializer<WxMall> j = new Jackson2JsonRedisSerializer<WxMall>(WxMall.class); | |||
| // value值的序列化 | |||
| template.setValueSerializer(j); | |||
| template.setHashKeySerializer(j); | |||
| // key的序列化 | |||
| template.setKeySerializer(new StringRedisSerializer()); | |||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||
| template.setConnectionFactory(connectionFactory); | |||
| return template; | |||
| } | |||
| } | |||
| @@ -2,6 +2,7 @@ package com.iformall.config; | |||
| import com.iformall.domain.po.PushLimit; | |||
| import com.iformall.domain.po.WxCUser; | |||
| import com.iformall.domain.po.WxMall; | |||
| import com.iformall.domain.po.WxScoreRules; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| @@ -127,4 +128,21 @@ public class RedisConfig extends CachingConfigurerSupport { | |||
| return template; | |||
| } | |||
| @Bean("mallRedisTemplate") | |||
| public RedisTemplate<String, WxMall> getMallRedisTemplate(RedisConnectionFactory connectionFactory) { | |||
| RedisTemplate<String, WxMall> template = new RedisTemplate<String, WxMall>(); | |||
| Jackson2JsonRedisSerializer<WxMall> j = new Jackson2JsonRedisSerializer<WxMall>(WxMall.class); | |||
| // value值的序列化 | |||
| template.setValueSerializer(j); | |||
| template.setHashKeySerializer(j); | |||
| // key的序列化 | |||
| template.setKeySerializer(new StringRedisSerializer()); | |||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||
| template.setConnectionFactory(connectionFactory); | |||
| return template; | |||
| } | |||
| } | |||
| @@ -1,5 +1,8 @@ | |||
| package com.iformall.domain.po; | |||
| import com.iformall.utils.DateUtils; | |||
| import lombok.Data; | |||
| import javax.persistence.Id; | |||
| import javax.persistence.Table; | |||
| import javax.persistence.Transient; | |||
| @@ -9,6 +12,7 @@ import java.util.Date; | |||
| import java.util.List; | |||
| @Table(name = "wx_mall") | |||
| @Data | |||
| public class WxMall implements Serializable { | |||
| private static final long serialVersionUID = 1L; | |||
| @@ -41,47 +45,38 @@ public class WxMall implements Serializable { | |||
| } | |||
| /*租户ID**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | |||
| private String tenantId; | |||
| /*商场名**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="商场名",name="name") | |||
| private String name; | |||
| /*集团**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="集团",name="group") | |||
| private String group; | |||
| /*国家**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="国家",name="country") | |||
| private String country; | |||
| /*省**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="省",name="province") | |||
| private String province; | |||
| /*城市**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="城市",name="city") | |||
| private String city; | |||
| /*地址**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="地址",name="addr") | |||
| private String addr; | |||
| /*总面积**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="总面积",name="totalArea") | |||
| private BigDecimal totalArea; | |||
| /*营业面积**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="营业面积",name="operatingArea") | |||
| private BigDecimal operatingArea; | |||
| /*停车场面积**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="停车场面积",name="parkArea") | |||
| private BigDecimal parkArea; | |||
| /*车位数**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="车位数",name="parkPlaceNumber") | |||
| private Integer parkPlaceNumber; | |||
| @io.swagger.annotations.ApiModelProperty(value="电话",name="servicePhone") | |||
| private String servicePhone; | |||
| @io.swagger.annotations.ApiModelProperty(value="商场图标",name="imgUrl") | |||
| private String imgUrl; | |||
| @io.swagger.annotations.ApiModelProperty(value="商场图标",name="imgUrlH") | |||
| @io.swagger.annotations.ApiModelProperty(value="商场图标-H",name="imgUrlH") | |||
| private String imgUrlH; | |||
| @io.swagger.annotations.ApiModelProperty(value="小程序提示",name="weapNote") | |||
| private String weapNote; | |||
| @io.swagger.annotations.ApiModelProperty(value="小程序二维码",name="imgQrcodeWeapp") | |||
| private String imgQrcodeWeapp; | |||
| @io.swagger.annotations.ApiModelProperty(value="公众平台二维码",name="imgQrcodeWemp") | |||
| @@ -93,159 +88,29 @@ public class WxMall implements Serializable { | |||
| @io.swagger.annotations.ApiModelProperty(value="分享封面图片",name="weappShareCoverImg") | |||
| private String weappShareCoverImg; | |||
| @io.swagger.annotations.ApiModelProperty(value="小程序提示",name="weapNote") | |||
| private String weapNote; | |||
| @io.swagger.annotations.ApiModelProperty(value="销售类型",name="saleType") | |||
| private Integer saleType; | |||
| @io.swagger.annotations.ApiModelProperty(value="启用开始时间",name="validStart") | |||
| private Date validStart; | |||
| @io.swagger.annotations.ApiModelProperty(value="启用结束时间",name="validEnd") | |||
| private Date validEnd; | |||
| @Transient | |||
| protected List<WxMallBuilding> buildings; | |||
| private String imgWeappQrcode; | |||
| public String getImgWeappQrcode() { | |||
| return imgWeappQrcode; | |||
| } | |||
| public void setImgWeappQrcode(String imgWeappQrcode) { | |||
| this.imgWeappQrcode = imgWeappQrcode; | |||
| } | |||
| public String getTenantId() { | |||
| return tenantId; | |||
| } | |||
| public void setTenantId(String _tenantId) { | |||
| tenantId = _tenantId; | |||
| } | |||
| public String getName() { | |||
| return name; | |||
| } | |||
| public void setName(String _name) { | |||
| name = _name; | |||
| } | |||
| public String getGroup() { | |||
| return group; | |||
| } | |||
| public void setGroup(String _group) { | |||
| group = _group; | |||
| } | |||
| public String getCountry() { | |||
| return country; | |||
| } | |||
| public void setCountry(String _country) { | |||
| country = _country; | |||
| } | |||
| public String getProvince() { | |||
| return province; | |||
| } | |||
| public void setProvince(String _province) { | |||
| province = _province; | |||
| } | |||
| public String getCity() { | |||
| return city; | |||
| } | |||
| public void setCity(String _city) { | |||
| city = _city; | |||
| } | |||
| public String getAddr() { | |||
| return addr; | |||
| } | |||
| public void setAddr(String _addr) { | |||
| addr = _addr; | |||
| } | |||
| public BigDecimal getTotalArea() { | |||
| return totalArea; | |||
| } | |||
| public void setTotalArea(BigDecimal _totalArea) { | |||
| totalArea = _totalArea; | |||
| } | |||
| public BigDecimal getOperatingArea() { | |||
| return operatingArea; | |||
| } | |||
| public void setOperatingArea(BigDecimal _operatingArea) { | |||
| operatingArea = _operatingArea; | |||
| } | |||
| public BigDecimal getParkArea() { | |||
| return parkArea; | |||
| } | |||
| public void setParkArea(BigDecimal _parkArea) { | |||
| parkArea = _parkArea; | |||
| } | |||
| public Integer getParkPlaceNumber() { | |||
| return parkPlaceNumber; | |||
| } | |||
| public void setParkPlaceNumber(Integer _parkPlaceNumber) { | |||
| parkPlaceNumber = _parkPlaceNumber; | |||
| } | |||
| public String getServicePhone() { | |||
| return servicePhone; | |||
| } | |||
| public void setServicePhone(String _servicePhone) { | |||
| this.servicePhone = _servicePhone; | |||
| } | |||
| public String getImgUrl() { | |||
| return imgUrl; | |||
| } | |||
| public void setImgUrl(String _imgUrl) { | |||
| this.imgUrl = _imgUrl; | |||
| } | |||
| public String getImgUrlH() { | |||
| return imgUrlH; | |||
| } | |||
| public void setImgUrlH(String imgUrlH) { | |||
| this.imgUrlH = imgUrlH; | |||
| } | |||
| public String getWeapNote() { | |||
| return weapNote; | |||
| } | |||
| public void setWeapNote(String weapNote) { | |||
| this.weapNote = weapNote; | |||
| } | |||
| public List<WxMallBuilding> getBuildings() { | |||
| return buildings; | |||
| } | |||
| public void setBuildings(List<WxMallBuilding> buildings) { | |||
| this.buildings = buildings; | |||
| } | |||
| public String getImgQrcodeWeapp() { | |||
| return imgQrcodeWeapp; | |||
| } | |||
| public void setImgQrcodeWeapp(String imgQrcodeWeapp) { | |||
| this.imgQrcodeWeapp = imgQrcodeWeapp; | |||
| } | |||
| public String getImgQrcodeWemp() { | |||
| return imgQrcodeWemp; | |||
| } | |||
| public void setImgQrcodeWemp(String imgQrcodeWemp) { | |||
| this.imgQrcodeWemp = imgQrcodeWemp; | |||
| } | |||
| public String getWeappShareTitle() { | |||
| return weappShareTitle; | |||
| } | |||
| public void setWeappShareTitle(String weappShareTitle) { | |||
| this.weappShareTitle = weappShareTitle; | |||
| } | |||
| public String getWeappShareCoverImg() { | |||
| return weappShareCoverImg; | |||
| } | |||
| public void setWeappShareCoverImg(String weappShareCoverImg) { | |||
| this.weappShareCoverImg = weappShareCoverImg; | |||
| public boolean isValid() { | |||
| if(saleType != null) { | |||
| if(validStart != null && validEnd != null) { | |||
| Date curDate = new Date(); | |||
| if(curDate.before(validStart) || curDate.after(validEnd)) { | |||
| return false; | |||
| } else { | |||
| return true; | |||
| } | |||
| } | |||
| } | |||
| return true; | |||
| } | |||
| public static enum Field | |||
| @@ -266,6 +131,9 @@ public class WxMall implements Serializable { | |||
| ,ImgUrl_ASC("`img_url` ASC"),ImgUrl_DESC("`img_url` DESC") | |||
| ,ImgUrlH_ASC("`img_url_h` ASC"),ImgUrlH_DESC("`img_url_h` DESC") | |||
| ,WeapNote_ASC("`weap_note` ASC"),WeapNote_DESC("`weap_note` DESC") | |||
| ,SaleType_ASC("`sale_type` ASC"),SaleType_DESC("`sale_type` DESC") | |||
| ,ValidStart_ASC("`valid_start` ASC"),ValidStart_DESC("`valid_start` DESC") | |||
| ,ValidEnd_ASC("`valid_end` ASC"),ValidEnd_DESC("`valid_end` DESC") | |||
| ; | |||
| private String value; | |||
| Field(String value){ | |||
| @@ -9,7 +9,6 @@ public interface WxMallMapper extends CommonMapper<WxMall, Long> { | |||
| List<WxMall> findList(WxMall wxMall); | |||
| void updateToken(WxMall wxMall); | |||
| WxMall getByTenantId(String tenantId); | |||
| } | |||
| @@ -8,15 +8,19 @@ import com.iformall.domain.po.WxMallFloor; | |||
| import com.iformall.mapper.WxMallBuildingMapper; | |||
| import com.iformall.mapper.WxMallFloorMapper; | |||
| import com.iformall.mapper.WxMallMapper; | |||
| import com.iformall.service.WxMallBuildingService; | |||
| import com.iformall.service.WxMallService; | |||
| 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 com.iformall.common.IdWorker; | |||
| import java.util.List; | |||
| import java.util.concurrent.TimeUnit; | |||
| import java.util.stream.Collectors; | |||
| @Service | |||
| @@ -32,6 +36,10 @@ public class WxMallServiceImpl implements WxMallService { | |||
| @Autowired | |||
| WxMallFloorMapper wxMallFloorMapper; | |||
| @Autowired | |||
| @Qualifier("mallRedisTemplate") | |||
| RedisTemplate<String, WxMall> mallRedisTemplate; | |||
| @Override | |||
| public PageInfo<WxMall> listAsPage(WxMall record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxMallMapper.findList(record)); | |||
| @@ -39,7 +47,20 @@ public class WxMallServiceImpl implements WxMallService { | |||
| @Override | |||
| public WxMall getById(Long id) { | |||
| return wxMallMapper.selectByPrimaryKey(id); | |||
| String key = Constant.MALL_KEY_PREV + String.valueOf(id); | |||
| ValueOperations<String, WxMall> operations = mallRedisTemplate.opsForValue(); | |||
| // 缓存 | |||
| boolean hasKey = mallRedisTemplate.hasKey(key); | |||
| if(hasKey) { | |||
| // 从缓存获取用户信息 | |||
| WxMall mall = operations.get(key); | |||
| return mall; | |||
| } | |||
| WxMall mall = wxMallMapper.selectByPrimaryKey(id); | |||
| // 插入缓存 | |||
| operations.set(key, mall, 3600, TimeUnit.SECONDS); | |||
| return mall; | |||
| } | |||
| @Override | |||
| @@ -54,25 +75,53 @@ public class WxMallServiceImpl implements WxMallService { | |||
| } else { | |||
| wxMallMapper.updateByPrimaryKeySelective(record); | |||
| } | |||
| String key = Constant.MALL_KEY_PREV + String.valueOf(record.getId()); | |||
| // 缓存已存在,删除 | |||
| boolean hasKey = mallRedisTemplate.hasKey(key); | |||
| if(hasKey) { | |||
| mallRedisTemplate.delete(key); | |||
| logger.info("更新mall,从缓存中删除mall token >> " + record.getId()); | |||
| } | |||
| } | |||
| @Override | |||
| public void deleteById(Long id) { | |||
| wxMallMapper.deleteByPrimaryKey(id); | |||
| String key = Constant.MALL_KEY_PREV + String.valueOf(id); | |||
| // 缓存已存在,删除 | |||
| boolean hasKey = mallRedisTemplate.hasKey(key); | |||
| if(hasKey) { | |||
| mallRedisTemplate.delete(key); | |||
| logger.info("更新mall,从缓存中删除mall token >> " + id); | |||
| } | |||
| } | |||
| @Override | |||
| public WxMall getByTenantId(String id) { | |||
| WxMall wxMall = new WxMall(); | |||
| wxMall.setTenantId(id); | |||
| return wxMallMapper.findList(wxMall).get(0); | |||
| String key = Constant.MALL_KEY_PREV + String.valueOf(id); | |||
| ValueOperations<String, WxMall> operations = mallRedisTemplate.opsForValue(); | |||
| // 缓存 | |||
| boolean hasKey = mallRedisTemplate.hasKey(key); | |||
| if(hasKey) { | |||
| // 从缓存获取用户信息 | |||
| WxMall mall = operations.get(key); | |||
| return mall; | |||
| } | |||
| WxMall mall = wxMallMapper.getByTenantId(id); | |||
| // 插入缓存 | |||
| operations.set(key, mall, 3600, TimeUnit.SECONDS); | |||
| return mall; | |||
| } | |||
| @Override | |||
| public WxMall getByTenantIdExt(String id) { | |||
| WxMall wxMallParam = new WxMall(); | |||
| wxMallParam.setTenantId(id); | |||
| WxMall wxMall = wxMallMapper.findList(wxMallParam).get(0); | |||
| WxMall wxMall = wxMallMapper.getByTenantId(id); | |||
| if(wxMall == null) { | |||
| return null; | |||
| } | |||
| WxMallBuilding wxMallBuilding = new WxMallBuilding(); | |||
| wxMallBuilding.setTenantId(id); | |||
| @@ -24,6 +24,9 @@ public class Constant { | |||
| // 积分规则 key prev | |||
| public static final String CREDIT_RULES_KEY_PREV = "setting:creditrules1:"; | |||
| // 获取mall信息 | |||
| public static final String MALL_KEY_PREV = "mall:"; | |||
| public static final String fileDirectory = "./uploads/"; | |||
| public static final String importMemPrev = "importmem/"; | |||
| public static final String adminPage = "https://admin.malls.iformall.com"; | |||
| @@ -22,13 +22,17 @@ | |||
| <result column="img_qrcode_wemp" jdbcType="VARCHAR" property="imgQrcodeWemp"/> | |||
| <result column="weapp_share_title" jdbcType="VARCHAR" property="weappShareTitle"/> | |||
| <result column="weapp_share_cover_img" jdbcType="VARCHAR" property="weappShareCoverImg"/> | |||
| <result column="sale_type" jdbcType="TINYINT" property="saleType"/> | |||
| <result column="valid_start" jdbcType="TIMESTAMP" property="validStart"/> | |||
| <result column="valid_end" jdbcType="TIMESTAMP" property="validEnd"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`name`,`group`,`country`,`province`,`city`,`addr`, | |||
| `total_area`,`operating_area`,`park_area`,`park_place_number`,`service_phone`, | |||
| `img_url`,`img_url_h`, `weap_note`, `img_qrcode_weapp`, `img_qrcode_wemp`, | |||
| `weapp_share_title`,`weapp_share_cover_img` | |||
| `weapp_share_title`,`weapp_share_cover_img`, | |||
| `sale_type`, `valid_start`, `valid_end` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -98,6 +102,18 @@ | |||
| and `img_qrcode_wemp` = #{imgQrcodeWemp} | |||
| </if> | |||
| <if test=" null != saleType "> | |||
| and `sale_type` = #{saleType} | |||
| </if> | |||
| <if test=" null != validStart "> | |||
| and `valid_start` = #{validStart} | |||
| </if> | |||
| <if test=" null != validEnd "> | |||
| and `valid_end` = #{validEnd} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| @@ -114,9 +130,12 @@ | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| <update id="updateToken" parameterType="com.iformall.domain.po.WxMall"> | |||
| update wx_mall set token=#{token},expired_time=#{expiredTime} where id=#{id} | |||
| </update> | |||
| <select id="getByTenantId" parameterType="string" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| from wx_mall | |||
| where 1=1 and `tenant_id` = #{value} | |||
| </select> | |||
| </mapper> | |||
| @@ -2,6 +2,7 @@ package com.iformall.config; | |||
| import com.iformall.domain.po.PushLimit; | |||
| import com.iformall.domain.po.WxCUser; | |||
| import com.iformall.domain.po.WxMall; | |||
| import com.iformall.domain.po.WxScoreRules; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| @@ -126,4 +127,21 @@ public class RedisConfig extends CachingConfigurerSupport { | |||
| return template; | |||
| } | |||
| @Bean("mallRedisTemplate") | |||
| public RedisTemplate<String, WxMall> getMallRedisTemplate(RedisConnectionFactory connectionFactory) { | |||
| RedisTemplate<String, WxMall> template = new RedisTemplate<String, WxMall>(); | |||
| Jackson2JsonRedisSerializer<WxMall> j = new Jackson2JsonRedisSerializer<WxMall>(WxMall.class); | |||
| // value值的序列化 | |||
| template.setValueSerializer(j); | |||
| template.setHashKeySerializer(j); | |||
| // key的序列化 | |||
| template.setKeySerializer(new StringRedisSerializer()); | |||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||
| template.setConnectionFactory(connectionFactory); | |||
| return template; | |||
| } | |||
| } | |||