Commit b7bfea54 by weijiguang

优化店铺距离限制

parent 19552d0b
...@@ -33,7 +33,7 @@ public class SysBanner extends BaseEntity { ...@@ -33,7 +33,7 @@ public class SysBanner extends BaseEntity {
/** /**
* 目标:1-小程序首页,2-小程序我的,0-其它 * 目标:1-小程序首页,2-小程序我的,0-其它
*/ */
private Integer target; private String target;
/** /**
* 省份列表 * 省份列表
*/ */
......
...@@ -14,7 +14,7 @@ public class BannerListPo { ...@@ -14,7 +14,7 @@ public class BannerListPo {
/** /**
* 目标:1-小程序首页,2-小程序我的,0-其它 * 目标:1-小程序首页,2-小程序我的,0-其它
*/ */
private Integer target; private String target;
/** /**
* 状态 * 状态
*/ */
......
...@@ -24,7 +24,7 @@ public class BannerPo { ...@@ -24,7 +24,7 @@ public class BannerPo {
/** /**
* 目标:1-小程序首页,2-小程序我的,0-其它 * 目标:1-小程序首页,2-小程序我的,0-其它
*/ */
private Integer target; private String[] target;
/** /**
* 排序 * 排序
*/ */
......
...@@ -27,7 +27,8 @@ public class BannerVo { ...@@ -27,7 +27,8 @@ public class BannerVo {
/** /**
* 目标:1-小程序首页,2-小程序我的,0-其它 * 目标:1-小程序首页,2-小程序我的,0-其它
*/ */
private Integer target; private String[] target;
private String targetStr;
/** /**
* 排序 * 排序
*/ */
......
...@@ -56,7 +56,7 @@ public class SysBannerServiceImpl implements ISysBannerService { ...@@ -56,7 +56,7 @@ public class SysBannerServiceImpl implements ISysBannerService {
if (banner.getType() == null || banner.getType() < 1 || banner.getType() > 3) { if (banner.getType() == null || banner.getType() < 1 || banner.getType() > 3) {
throw new ServiceException("类型不正确,1-小程序,2-KDS,3-点单屏"); throw new ServiceException("类型不正确,1-小程序,2-KDS,3-点单屏");
} }
if (banner.getTarget() == null || banner.getTarget() < 0 || banner.getTarget() > 2) { if (StringUtils.isEmpty(banner.getTarget())) {
throw new ServiceException("轮播位置不正确,1-小程序首页,2-小程序我的,0-其它"); throw new ServiceException("轮播位置不正确,1-小程序首页,2-小程序我的,0-其它");
} }
if (banner.getSort() == null) { if (banner.getSort() == null) {
...@@ -88,7 +88,7 @@ public class SysBannerServiceImpl implements ISysBannerService { ...@@ -88,7 +88,7 @@ public class SysBannerServiceImpl implements ISysBannerService {
if (banner.getType() == null || banner.getType() < 1 || banner.getType() > 3) { if (banner.getType() == null || banner.getType() < 1 || banner.getType() > 3) {
throw new ServiceException("类型不正确,1-小程序,2-KDS,3-点单屏"); throw new ServiceException("类型不正确,1-小程序,2-KDS,3-点单屏");
} }
if (banner.getTarget() == null || banner.getTarget() < 0 || banner.getTarget() > 2) { if (StringUtils.isEmpty(banner.getTarget())) {
throw new ServiceException("轮播位置不正确,1-小程序首页,2-小程序我的,0-其它"); throw new ServiceException("轮播位置不正确,1-小程序首页,2-小程序我的,0-其它");
} }
if (banner.getSort() == null) { if (banner.getSort() == null) {
...@@ -110,9 +110,12 @@ public class SysBannerServiceImpl implements ISysBannerService { ...@@ -110,9 +110,12 @@ public class SysBannerServiceImpl implements ISysBannerService {
banner.setImage(bannerPo.getImage()); banner.setImage(bannerPo.getImage());
banner.setPage(bannerPo.getPage()); banner.setPage(bannerPo.getPage());
banner.setType(bannerPo.getType()); banner.setType(bannerPo.getType());
banner.setTarget(bannerPo.getTarget());
banner.setSort(bannerPo.getSort()); banner.setSort(bannerPo.getSort());
banner.setState(bannerPo.getState()); banner.setState(bannerPo.getState());
// banner.setTarget(bannerPo.getTarget());
if (bannerPo.getTarget() != null && bannerPo.getTarget().length > 0) {
banner.setTarget("," + Arrays.asList(bannerPo.getTarget()).stream().collect(Collectors.joining(",")) + ",");
}
if (bannerPo.getProvince() != null && bannerPo.getProvince().length > 0) { if (bannerPo.getProvince() != null && bannerPo.getProvince().length > 0) {
banner.setProvince("," + Arrays.asList(bannerPo.getProvince()).stream().collect(Collectors.joining(",")) + ","); banner.setProvince("," + Arrays.asList(bannerPo.getProvince()).stream().collect(Collectors.joining(",")) + ",");
} }
...@@ -134,10 +137,28 @@ public class SysBannerServiceImpl implements ISysBannerService { ...@@ -134,10 +137,28 @@ public class SysBannerServiceImpl implements ISysBannerService {
bannerVo.setImage(banner.getImage()); bannerVo.setImage(banner.getImage());
bannerVo.setPage(banner.getPage()); bannerVo.setPage(banner.getPage());
bannerVo.setType(banner.getType()); bannerVo.setType(banner.getType());
bannerVo.setTarget(banner.getTarget());
bannerVo.setSort(banner.getSort()); bannerVo.setSort(banner.getSort());
bannerVo.setState(banner.getState()); bannerVo.setState(banner.getState());
// bannerVo.setTarget(banner.getTarget());
if (!StringUtils.isEmpty(banner.getTarget())) {
String str = trim(banner.getTarget());
bannerVo.setTarget(str.split(","));
String targetStr = "";
for (String s : bannerVo.getTarget()) {
if (!StringUtils.isEmpty(targetStr)) {
targetStr += ",";
}
if (s.equals("1")) {
targetStr += "菜单页顶部";
} else if (s.equals("2")) {
targetStr += "我的页banner";
} else if (s.equals("0")) {
targetStr += "菜单轮播";
}
}
bannerVo.setTargetStr(targetStr);
}
if (!StringUtils.isEmpty(banner.getProvince())) { if (!StringUtils.isEmpty(banner.getProvince())) {
String str = trim(banner.getProvince()); String str = trim(banner.getProvince());
bannerVo.setProvinceStr(str); bannerVo.setProvinceStr(str);
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
select * from sys_banner select * from sys_banner
<where> <where>
<if test="type != null ">type = #{type}</if> <if test="type != null ">type = #{type}</if>
<if test="target != null ">and target = #{target}</if> <if test="target != null and target != ''">and target like concat('%,', #{target}, ',%')</if>
<if test="province != null and province != ''">and province like concat('%,', #{province}, ',%')</if> <if test="province != null and province != ''">and province like concat('%,', #{province}, ',%')</if>
<if test="city != null and city != ''">and city like concat('%,', #{city}, ',%')</if> <if test="city != null and city != ''">and city like concat('%,', #{city}, ',%')</if>
<if test="area != null and area != ''">and area like concat('%,', #{area}, ',%')</if> <if test="area != null and area != ''">and area like concat('%,', #{area}, ',%')</if>
...@@ -62,6 +62,9 @@ ...@@ -62,6 +62,9 @@
</insert> </insert>
<select id="selectBanners" resultMap="BannerResult"> <select id="selectBanners" resultMap="BannerResult">
select * from sys_banner where `type` = #{type} and `target` = #{target} and `state` = 0 order by sort, created_at select * from sys_banner
where `type` = #{type}
<if test="target != null and target != ''">and target like concat('%,', #{target}, ',%')</if>
and `state` = 0 order by sort, created_at
</select> </select>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment