diff --git a/mallinkCApi/src/main/java/com/iformall/controller/WxCouponController.java b/mallinkCApi/src/main/java/com/iformall/controller/WxCouponController.java index bac0fafe2..c8830d6da 100644 --- a/mallinkCApi/src/main/java/com/iformall/controller/WxCouponController.java +++ b/mallinkCApi/src/main/java/com/iformall/controller/WxCouponController.java @@ -4,6 +4,7 @@ import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; @@ -380,36 +381,39 @@ public class WxCouponController extends BaseController { Map> labelCityMap = CouponCacheUtils.getCouponMerchantLableMapCache(redisTemplate, couponChannel.getCouponId()); if (null == labelCityMap) { - Map> couponMerchantMap = getCouponMerchant(couponChannel, null); + Map> couponMerchantMap = getCouponMerchant(couponChannel, null,false); if (null != couponMerchantMap) { - List merchantVoList = couponMerchantMap.get(couponChannel.getCouponId()); - if (null != merchantVoList ) { - Map cityLableMap = sysGaoDeService.getAllCityLabelMap(); - //A-list,B-list - labelCityMap = new HashMap>(); - for (int i = 0 ; i< merchantVoList.size(); i++) { - WxMerchantVo mv = merchantVoList.get(i); - if (StringUtils.isNotBlank(mv.getCity())){ - String cityLable = cityLableMap.get(mv.getCity()); - if (StringUtils.isNotBlank(cityLable)) { - List list = labelCityMap.get(cityLable); - if (null == list) { - list = new ArrayList(); - list.add(mv.getCity()); - labelCityMap.put(cityLable, list); - }else { - if (!list.contains(mv.getCity())) { - list.add(mv.getCity()); - } - } - } - - } - } - if (labelCityMap.size() > 0 ) { - CouponCacheUtils.setCouponMerchantLableMapCache(redisTemplate, couponChannel.getCouponId(), labelCityMap); - } + Map cityLableMap = sysGaoDeService.getAllCityLabelMap(); + for (Iterator it = couponMerchantMap.keySet().iterator();it.hasNext();) { + String mallKey = it.next(); + List merchantVoList = couponMerchantMap.get(mallKey); + if (null != merchantVoList ) { + //A-list,B-list + labelCityMap = new HashMap>(); + for (int i = 0 ; i< merchantVoList.size(); i++) { + WxMerchantVo mv = merchantVoList.get(i); + if (StringUtils.isNotBlank(mv.getCity())){ + String cityLable = cityLableMap.get(mv.getCity()); + if (StringUtils.isNotBlank(cityLable)) { + List list = labelCityMap.get(cityLable); + if (null == list) { + list = new ArrayList(); + list.add(mv.getCity()); + labelCityMap.put(cityLable, list); + }else { + if (!list.contains(mv.getCity())) { + list.add(mv.getCity()); + } + } + } + + } + } + } } + if (labelCityMap.size() > 0 ) { + CouponCacheUtils.setCouponMerchantLableMapCache(redisTemplate, couponChannel.getCouponId(), labelCityMap); + } } } return new ResultData(labelCityMap); @@ -452,19 +456,24 @@ public class WxCouponController extends BaseController { CouponCacheUtils.setCouponChannelCache(redisTemplate, couponChannelIdL, couponChannel); } - return new ResultData(getCouponMerchant(couponChannel, city)); + return new ResultData(getCouponMerchant(couponChannel, city,true)); } - private Map> getCouponMerchant(WxCouponChannel couponChannel,String city) { - Map> volist = CouponCacheUtils.getCouponMerchantCache(redisTemplate, couponChannel.getCouponId(),city); - if (null == volist) { - volist = couponService.getCouponMerchantList(getTenantInfo(), couponChannel.getCouponId(),city); - if (null != volist && volist.size() > 0 ) { - CouponCacheUtils.setCouponMerchantCache(redisTemplate, couponChannel.getCouponId(),city, volist); + private Map> getCouponMerchant(WxCouponChannel couponChannel,String city,boolean queryCache) { + if (queryCache) { + Map> volist = CouponCacheUtils.getCouponMerchantCache(redisTemplate, couponChannel.getCouponId(),city); + if (null == volist) { + volist = couponService.getCouponMerchantList(getTenantInfo(), couponChannel.getCouponId(),city); + if (null != volist && volist.size() > 0 ) { + CouponCacheUtils.setCouponMerchantCache(redisTemplate, couponChannel.getCouponId(),city, volist); + } } - } - return volist; + return volist; + }else { + return couponService.getCouponMerchantList(getTenantInfo(), couponChannel.getCouponId(),city); + } + } @TenantIgnore diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java index df4bc992c..d42735f63 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java @@ -1551,8 +1551,10 @@ public class WxMerchantServiceImpl implements WxMerchantService { if (null != poiMerchantIds && poiMerchantIds.size() > 0 ){ //取交集 merchantIds = (List) CollectionUtils.intersection(poiMerchantIds, productMerchantIds); + }else { + merchantIds = productMerchantIds; } - if (null == merchantIds) { + if (null == merchantIds || merchantIds.size() <= 0 ) { return retMap; } @@ -1673,6 +1675,10 @@ public class WxMerchantServiceImpl implements WxMerchantService { poiQ.setCity(city); poiQ.updateTenantInfo(tenantEntity); poiMerchantIds = ttMerchantPoiMapper.findIdList(poiQ); + if (null == poiMerchantIds || poiMerchantIds.size() <= 0 ) { + poiMerchantIds = new ArrayList(); + poiMerchantIds.add(-1L); + } } Map> couponMerchantVoList = findCouponMerchantVoList(couponIds,tenantEntity,poiMerchantIds,hasShop);