Commit 0e138be9 by weijiguang

下单时校验订单中sku数量

parent 8a8223ea
...@@ -139,22 +139,22 @@ public class SysBannerServiceImpl implements ISysBannerService { ...@@ -139,22 +139,22 @@ public class SysBannerServiceImpl implements ISysBannerService {
bannerVo.setState(banner.getState()); bannerVo.setState(banner.getState());
if (!StringUtils.isEmpty(banner.getProvince())) { if (!StringUtils.isEmpty(banner.getProvince())) {
String str = banner.getProvince().substring(1, banner.getProvince().length() - 1); String str = trim(banner.getProvince());
bannerVo.setProvinceStr(str); bannerVo.setProvinceStr(str);
bannerVo.setProvince(str.split(",")); bannerVo.setProvince(str.split(","));
} }
if (!StringUtils.isEmpty(banner.getCity())) { if (!StringUtils.isEmpty(banner.getCity())) {
String str = banner.getCity().substring(1, banner.getCity().length() - 1); String str = trim(banner.getCity());
bannerVo.setCityStr(str); bannerVo.setCityStr(str);
bannerVo.setCity(str.split(",")); bannerVo.setCity(str.split(","));
} }
if (!StringUtils.isEmpty(banner.getArea())) { if (!StringUtils.isEmpty(banner.getArea())) {
String str = banner.getArea().substring(1, banner.getArea().length() - 1); String str = trim(banner.getArea());
bannerVo.setAreaStr(str); bannerVo.setAreaStr(str);
bannerVo.setArea(str.split(",")); bannerVo.setArea(str.split(","));
} }
if (!StringUtils.isEmpty(banner.getShopIds())) { if (!StringUtils.isEmpty(banner.getShopIds())) {
String str = banner.getShopIds().substring(1, banner.getShopIds().length() - 1); String str = trim(banner.getShopIds());
bannerVo.setShopIdsStr(str); bannerVo.setShopIdsStr(str);
String[] shopIds = str.split(","); String[] shopIds = str.split(",");
Long[] ids = new Long[shopIds.length]; Long[] ids = new Long[shopIds.length];
...@@ -166,6 +166,13 @@ public class SysBannerServiceImpl implements ISysBannerService { ...@@ -166,6 +166,13 @@ public class SysBannerServiceImpl implements ISysBannerService {
return bannerVo; return bannerVo;
} }
private String trim(String str) {
if (StringUtils.isEmpty(str)) {
return str;
}
return str.substring(1, str.length() - 1);
}
public List<BannerVo> copyBanner(List<SysBanner> banners) { public List<BannerVo> copyBanner(List<SysBanner> banners) {
List<BannerVo> bannerVos = new ArrayList<>(); List<BannerVo> bannerVos = new ArrayList<>();
if (CollectionUtils.isEmpty(banners)) { if (CollectionUtils.isEmpty(banners)) {
...@@ -214,7 +221,12 @@ public class SysBannerServiceImpl implements ISysBannerService { ...@@ -214,7 +221,12 @@ public class SysBannerServiceImpl implements ISysBannerService {
List<SysBanner> list = new ArrayList<>(); List<SysBanner> list = new ArrayList<>();
banners.forEach(banner -> { banners.forEach(banner -> {
if (!StringUtils.isEmpty(banner.getProvince())) { if (!StringUtils.isEmpty(banner.getProvince())) {
Arrays.stream(banner.getProvince().split(",")).forEach(p -> { String province = trim(banner.getProvince());
if (province.equals("0")) {
list.add(banner);
return;
}
Arrays.stream(province.split(",")).forEach(p -> {
if (p.equals(shop.getProvince())) { if (p.equals(shop.getProvince())) {
list.add(banner); list.add(banner);
return; return;
...@@ -222,7 +234,8 @@ public class SysBannerServiceImpl implements ISysBannerService { ...@@ -222,7 +234,8 @@ public class SysBannerServiceImpl implements ISysBannerService {
}); });
} }
if (!StringUtils.isEmpty(banner.getCity())) { if (!StringUtils.isEmpty(banner.getCity())) {
Arrays.stream(banner.getCity().split(",")).forEach(p -> { String city = trim(banner.getCity());
Arrays.stream(city.split(",")).forEach(p -> {
if (p.equals(shop.getCity())) { if (p.equals(shop.getCity())) {
list.add(banner); list.add(banner);
return; return;
...@@ -230,7 +243,8 @@ public class SysBannerServiceImpl implements ISysBannerService { ...@@ -230,7 +243,8 @@ public class SysBannerServiceImpl implements ISysBannerService {
}); });
} }
if (!StringUtils.isEmpty(banner.getArea())) { if (!StringUtils.isEmpty(banner.getArea())) {
Arrays.stream(banner.getArea().split(",")).forEach(p -> { String area = trim(banner.getArea());
Arrays.stream(area.split(",")).forEach(p -> {
if (p.equals(shop.getZone())) { if (p.equals(shop.getZone())) {
list.add(banner); list.add(banner);
return; return;
...@@ -238,7 +252,8 @@ public class SysBannerServiceImpl implements ISysBannerService { ...@@ -238,7 +252,8 @@ public class SysBannerServiceImpl implements ISysBannerService {
}); });
} }
if (!StringUtils.isEmpty(banner.getShopIds())) { if (!StringUtils.isEmpty(banner.getShopIds())) {
Arrays.stream(banner.getShopIds().split(",")).forEach(p -> { String shopIds = trim(banner.getShopIds());
Arrays.stream(shopIds.split(",")).forEach(p -> {
if (p.equals(String.valueOf(shop.getId()))) { if (p.equals(String.valueOf(shop.getId()))) {
list.add(banner); list.add(banner);
return; return;
...@@ -264,6 +279,11 @@ public class SysBannerServiceImpl implements ISysBannerService { ...@@ -264,6 +279,11 @@ public class SysBannerServiceImpl implements ISysBannerService {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
banners.forEach(banner -> { banners.forEach(banner -> {
if (!StringUtils.isEmpty(banner.getProvince())) { if (!StringUtils.isEmpty(banner.getProvince())) {
String province = trim(banner.getProvince());
if (province.equals("0")) {
list.add(banner.getImage());
return;
}
Arrays.stream(banner.getProvince().split(",")).forEach(p -> { Arrays.stream(banner.getProvince().split(",")).forEach(p -> {
if (p.equals(shop.getProvince())) { if (p.equals(shop.getProvince())) {
list.add(banner.getImage()); list.add(banner.getImage());
...@@ -272,7 +292,8 @@ public class SysBannerServiceImpl implements ISysBannerService { ...@@ -272,7 +292,8 @@ public class SysBannerServiceImpl implements ISysBannerService {
}); });
} }
if (!StringUtils.isEmpty(banner.getCity())) { if (!StringUtils.isEmpty(banner.getCity())) {
Arrays.stream(banner.getCity().split(",")).forEach(p -> { String city = trim(banner.getCity());
Arrays.stream(city.split(",")).forEach(p -> {
if (p.equals(shop.getCity())) { if (p.equals(shop.getCity())) {
list.add(banner.getImage()); list.add(banner.getImage());
return; return;
...@@ -280,7 +301,8 @@ public class SysBannerServiceImpl implements ISysBannerService { ...@@ -280,7 +301,8 @@ public class SysBannerServiceImpl implements ISysBannerService {
}); });
} }
if (!StringUtils.isEmpty(banner.getArea())) { if (!StringUtils.isEmpty(banner.getArea())) {
Arrays.stream(banner.getArea().split(",")).forEach(p -> { String area = trim(banner.getArea());
Arrays.stream(area.split(",")).forEach(p -> {
if (p.equals(shop.getZone())) { if (p.equals(shop.getZone())) {
list.add(banner.getImage()); list.add(banner.getImage());
return; return;
...@@ -288,7 +310,8 @@ public class SysBannerServiceImpl implements ISysBannerService { ...@@ -288,7 +310,8 @@ public class SysBannerServiceImpl implements ISysBannerService {
}); });
} }
if (!StringUtils.isEmpty(banner.getShopIds())) { if (!StringUtils.isEmpty(banner.getShopIds())) {
Arrays.stream(banner.getShopIds().split(",")).forEach(p -> { String shopIds = trim(banner.getShopIds());
Arrays.stream(shopIds.split(",")).forEach(p -> {
if (p.equals(String.valueOf(shop.getId()))) { if (p.equals(String.valueOf(shop.getId()))) {
list.add(banner.getImage()); list.add(banner.getImage());
return; return;
......
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