Commit c3451283 by 陶光胜

门店控件查询

parent 35069117
...@@ -82,8 +82,38 @@ public class StoreSearchUtils { ...@@ -82,8 +82,38 @@ public class StoreSearchUtils {
return 0; return 0;
} }
public int dealSearchJson(String searchJson){
/***线上和线下选项值都为空的时候--所有门店权限范围
* 线上或者线下有一个的选项值不为空时,则为单渠道权限范围*
* 线上和线下的json值为空的时候 -- 所有门店权限范围*/
if(StringUtils.isBlank(searchJson)){
return 0;
} else {
JSONObject json = JSON.parseObject(searchJson);
StoreSearchQo offLineSearch = json.getObject(StoreChannelEnum.OFFLINE.getChannel().toString(), StoreSearchQo.class);
StoreSearchQo onLineSearch = JSON.parseObject(searchJson).getObject(StoreChannelEnum.WMMALL.getChannel().toString(), StoreSearchQo.class);
boolean off = offLineSearch.isEmpty();
boolean online = onLineSearch.isEmpty();
if(off && online){
return 0;
} else if(!off && online){
return 1;
} else if(off && !online){
return 2;
} else {
return 0;
}
}
}
public List<Integer> storeSearch(Integer userId, Integer enterpriseId, String searchJson){ public List<Integer> storeSearch(Integer userId, Integer enterpriseId, String searchJson){
log.info("storeSearchParams:{},{},{}", userId, enterpriseId, searchJson); log.info("storeSearchParams:{},{},{}", userId, enterpriseId, searchJson);
List<Integer> resultList = new ArrayList<>();
int flag = dealSearchJson(searchJson);
if(flag == 2){
resultList.add(0);
return resultList;
}
String key = "1:" + enterpriseId + ":" + userId +":" + (StringUtils.isNotBlank(searchJson) ? searchJson.hashCode() : "searchJSON".hashCode()); String key = "1:" + enterpriseId + ":" + userId +":" + (StringUtils.isNotBlank(searchJson) ? searchJson.hashCode() : "searchJSON".hashCode());
StoreAuth storeAuth = this.dataAuthUtils.getStoreAuth(userId, enterpriseId); StoreAuth storeAuth = this.dataAuthUtils.getStoreAuth(userId, enterpriseId);
log.info("storeAuth:{}", JSON.toJSONString(storeAuth)); log.info("storeAuth:{}", JSON.toJSONString(storeAuth));
...@@ -92,7 +122,6 @@ public class StoreSearchUtils { ...@@ -92,7 +122,6 @@ public class StoreSearchUtils {
list.add(0); list.add(0);
return list; return list;
} }
List<Integer> resultList = new ArrayList<>();
if(StringUtils.isNotBlank(searchJson)){ if(StringUtils.isNotBlank(searchJson)){
JSONObject json = JSON.parseObject(searchJson); JSONObject json = JSON.parseObject(searchJson);
StoreSearchQo storeSearchQo = json.getObject(StoreChannelEnum.OFFLINE.getChannel().toString(), StoreSearchQo.class); StoreSearchQo storeSearchQo = json.getObject(StoreChannelEnum.OFFLINE.getChannel().toString(), StoreSearchQo.class);
...@@ -175,9 +204,14 @@ public class StoreSearchUtils { ...@@ -175,9 +204,14 @@ public class StoreSearchUtils {
} }
public List<String> onLineStoreSearch(Integer userId, Integer enterpriseId, String searchJson){ public List<String> onLineStoreSearch(Integer userId, Integer enterpriseId, String searchJson){
List<String> list = new ArrayList<>();
int flag = dealSearchJson(searchJson);
if(flag == 1){
list.add("0");
return list;
}
OnLineAuth onlineStoreAuth = this.dataAuthUtils.getOnlineStore(userId, enterpriseId); OnLineAuth onlineStoreAuth = this.dataAuthUtils.getOnlineStore(userId, enterpriseId);
log.info("onlineStoreAuth:{}", JSON.toJSONString(onlineStoreAuth)); log.info("onlineStoreAuth:{}", JSON.toJSONString(onlineStoreAuth));
List<String> list = new ArrayList<>();
if(onlineStoreAuth.isHasAuth()){ if(onlineStoreAuth.isHasAuth()){
this.getOnlineStoreIds(searchJson, onlineStoreAuth, list, StoreChannelEnum.GICMALL.getChannel(), userId, enterpriseId); this.getOnlineStoreIds(searchJson, onlineStoreAuth, list, StoreChannelEnum.GICMALL.getChannel(), userId, enterpriseId);
this.getOnlineStoreIds(searchJson, onlineStoreAuth, list, StoreChannelEnum.WMMALL.getChannel(), userId, enterpriseId); this.getOnlineStoreIds(searchJson, onlineStoreAuth, list, StoreChannelEnum.WMMALL.getChannel(), userId, enterpriseId);
...@@ -327,37 +361,38 @@ public class StoreSearchUtils { ...@@ -327,37 +361,38 @@ public class StoreSearchUtils {
} }
} }
private List<String> filter(Integer channel, StoreSearchQo searchQo, Integer enterpriseId, String key, List<String> onLineStoreIdList){ private List<String> filter(Integer channel, StoreSearchQo searchQo, Integer enterpriseId, String key, List<String> onLineStoreIdList) {
if(StoreChannelEnum.WMMALL.getChannel().equals(channel)){ if (StoreChannelEnum.WMMALL.getChannel().equals(channel)) {
List<WmStoreDTO> wmStoreDTOList = this.wmStoreApiService.listWmStore(onLineStoreIdList, null).getResult(); List<WmStoreDTO> wmStoreDTOList = this.wmStoreApiService.listWmStore(onLineStoreIdList, null).getResult();
List<String> onLineStoreList = wmStoreDTOList.stream().filter(wmStoreDTO -> { List<String> onLineStoreList = wmStoreDTOList.stream().filter(wmStoreDTO -> {
boolean resourceFlag = true; boolean resourceFlag = true;
if(StringUtils.isNotBlank(searchQo.getResourceType())){ if (StringUtils.isNotBlank(searchQo.getResourceType())) {
if("1".equals(searchQo.getResourceType())){ //自有资源 if ("1".equals(searchQo.getResourceType())) { //自有资源
if(enterpriseId.equals(wmStoreDTO.getEnterpriseId())){ if (enterpriseId.equals(wmStoreDTO.getEnterpriseId())) {
resourceFlag = true; resourceFlag = true;
} }
} }
if("2".equals(searchQo.getStoreBrand())){ //共享资源 if ("2".equals(searchQo.getStoreBrand())) { //共享资源
if(!enterpriseId.equals(wmStoreDTO.getEnterpriseId())){ if (!enterpriseId.equals(wmStoreDTO.getEnterpriseId())) {
resourceFlag = true; resourceFlag = true;
} }
} }
} }
boolean brandFlag = true; boolean brandFlag = true;
if(StringUtils.isNotBlank(searchQo.getStoreBrand())){ if (StringUtils.isNotBlank(searchQo.getStoreBrand())) {
List<String> strings = Arrays.asList(searchQo.getStoreBrand().split(",")); List<String> strings = Arrays.asList(searchQo.getStoreBrand().split(","));
if(strings.contains(wmStoreDTO.getStoreBrandId().toString())){ if (strings.contains(wmStoreDTO.getStoreBrandId().toString())) {
brandFlag = true; brandFlag = true;
} }
} }
return resourceFlag || brandFlag; return resourceFlag || brandFlag;
}).map(wmStoreDTO -> wmStoreDTO.getWmMallStoreId().toString()).collect(Collectors.toList()); }).map(wmStoreDTO -> wmStoreDTO.getWmMallStoreId().toString()).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(onLineStoreList)){ if (CollectionUtils.isNotEmpty(onLineStoreList)) {
RedisUtil.setCache(key, 1, 10L, TimeUnit.MINUTES); RedisUtil.setCache(key, 1, 10L, TimeUnit.MINUTES);
} }
return onLineStoreList; return onLineStoreList;
} }
return null;
} }
} }
package com.gic.cloud.web.qo; package com.gic.cloud.web.qo;
import org.apache.commons.lang3.StringUtils;
/** /**
* 门店查询 * 门店查询
* @ClassName: StoreSearchQo
 * @ClassName: StoreSearchQo

...@@ -32,6 +35,11 @@ public class StoreSearchQo { ...@@ -32,6 +35,11 @@ public class StoreSearchQo {
private String resourceType; private String resourceType;
public boolean isEmpty(){
return all == 0 && StringUtils.isBlank(region) && StringUtils.isBlank(storeType) && StringUtils.isBlank(storeStatus) && StringUtils.isBlank(storeTag)
&& attentionStore == 0 && StringUtils.isBlank(storeGroupIds) && StringUtils.isBlank(storeIds) && StringUtils.isBlank(storeBrand) && StringUtils.isBlank(resourceType);
}
public Integer getAll() { public Integer getAll() {
return all; return all;
} }
...@@ -135,4 +143,5 @@ public class StoreSearchQo { ...@@ -135,4 +143,5 @@ public class StoreSearchQo {
public void setResourceType(String resourceType) { public void setResourceType(String resourceType) {
this.resourceType = resourceType; this.resourceType = resourceType;
} }
} }
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