Commit 44a859cc by zhiwj

Merge branch 'developer' of…

Merge branch 'developer' of http://115.159.76.241/base_platform_enterprise/gic-data-cloud into developer
parents 41120ff7 f1b5b14f
......@@ -6,6 +6,9 @@ import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.cloud.dto.DataAuthDTO;
import com.gic.cloud.service.DataAuthApiService;
import com.gic.store.dto.StoreDTO;
import com.gic.store.dto.StoreSearchDTO;
import com.gic.store.service.StoreApiService;
import com.gic.store.service.StoreWidgetApiService;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
......@@ -15,6 +18,7 @@ import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Component
public class DataAuthUtils {
......@@ -24,6 +28,8 @@ public class DataAuthUtils {
private DataAuthApiService dataAuthApiService;
@Autowired
private StoreWidgetApiService storeWidgetApiService;
@Autowired
private StoreApiService storeApiService;
public StoreAuth getStoreAuth(Integer userId, Integer enterpriseId){
ServiceResponse<DataAuthDTO> response = this.dataAuthApiService.ggetDataAuthByUserId(enterpriseId, userId);
......@@ -37,7 +43,10 @@ public class DataAuthUtils {
storeAuth.setStoreInfoIdList(storeInfoIdList);
storeAuth.setStoreWidgetId(storeWidgetId);
}else {
storeAuth.setStoreInfoIdList(new ArrayList<>());
StoreSearchDTO storeSearchDTO = new StoreSearchDTO();
storeSearchDTO.setEnterpriseId(enterpriseId);
List<StoreDTO> result = this.storeApiService.listStore(storeSearchDTO, 1, 20000).getResult().getResult();
storeAuth.setStoreInfoIdList(result.stream().map(storeDTO -> storeDTO.getStoreInfoId()).collect(Collectors.toList()));
}
}
return storeAuth;
......
package com.gic.cloud.web.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.gic.cloud.dto.AttentionStoreDTO;
import com.gic.cloud.dto.TempStoreConditionDTO;
import com.gic.cloud.service.StoreAttentionApiService;
import com.gic.cloud.service.TempStoreConditionApiService;
import com.gic.cloud.web.auth.DataAuthUtils;
import com.gic.cloud.web.auth.OnLineAuth;
import com.gic.cloud.web.auth.OnLineStore;
import com.gic.cloud.web.auth.StoreAuth;
import com.gic.cloud.web.constant.StoreChannelEnum;
import com.gic.cloud.web.qo.StoreSearchQo;
import com.gic.store.dto.StoreDTO;
import com.gic.store.dto.StoreGroupDTO;
import com.gic.store.dto.StoreSearchDTO;
import com.gic.store.service.StoreApiService;
import com.gic.store.service.StoreGroupApiService;
import com.gic.store.service.StoreWidgetApiService;
import com.google.inject.internal.cglib.core.$ClassEmitter;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.reflections.Store;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.*;
import java.util.stream.Collectors;
@Component
public class StoreSearchUtils {
@Autowired
private DataAuthUtils dataAuthUtils;
@Autowired
private StoreAttentionApiService storeAttentionApiService;
@Autowired
private TempStoreConditionApiService tempStoreConditionApiService;
@Autowired
private StoreWidgetApiService storeWidgetApiService;
@Autowired
private StoreApiService storeApiService;
@Autowired
private StoreGroupApiService storeGroupApiService;
public List<Integer> storeSearch(Integer userId, Integer enterpriseId, String searchJson){
StoreAuth storeAuth = this.dataAuthUtils.getStoreAuth(userId, enterpriseId);
if(!storeAuth.isHasAuth()){
ArrayList<Integer> list = new ArrayList<>();
list.add(0);
return list;
}
if(StringUtils.isNotBlank(searchJson)){
JSONObject json = JSON.parseObject(searchJson);
StoreSearchQo storeSearchQo = json.getObject(StoreChannelEnum.OFFLINE.getChannel().toString(), StoreSearchQo.class);
if(storeSearchQo.getAll() == 1){
return storeAuth.getStoreInfoIdList();
}else {
StoreSearchDTO storeSearchDTO = new StoreSearchDTO();
storeSearchDTO.setEnterpriseId(enterpriseId);
storeSearchDTO.setStoreInfoIds(storeSearchQo.getStoreIds());
storeSearchDTO.setStoreGroupIds(storeSearchQo.getStoreGroupIds());
storeSearchDTO.setRegionIds(storeSearchQo.getRegion());
storeSearchDTO.setStoreTypes(storeSearchQo.getStoreType());
storeSearchDTO.setStoreStatuss(storeSearchQo.getStoreStatus());
storeSearchDTO.setErpStatuss(storeSearchQo.getErpStatus());
storeSearchDTO.setStoreTags(storeSearchQo.getStoreTag());
if(storeSearchQo.getAttentionStore() == 1){
List<AttentionStoreDTO> result = this.storeAttentionApiService.pageStoreAttention(userId, enterpriseId, 1, Integer.MAX_VALUE).getResult().getResult();
List<Integer> list = result.stream().map(t -> t.getStoreId()).collect(Collectors.toList());
String storeInfoIds = StringUtils.join(list, ",");
storeSearchDTO.setStoreInfoIds(storeSearchDTO.getStoreInfoIds()+","+ storeInfoIds);
}
if(storeSearchQo.getTmpStore() == 0){
TempStoreConditionDTO result = this.tempStoreConditionApiService.getTempStoreCondition(enterpriseId).getResult();
if(result != null){
Integer tempStoreId = result.getStoreWidgetId();
List<Integer> tempStoreIdList = this.storeWidgetApiService.listStoreInfoIdByStoreWidgetId(enterpriseId, tempStoreId).getResult();
storeSearchDTO.setStoreIdsOfNot(StringUtils.join(tempStoreIdList, ","));
}
}
List<StoreDTO> storeDTOList = this.storeApiService.listStore(storeSearchDTO, 1, 20000).getResult().getResult();
List<Integer> storeInfoIdList = storeDTOList.stream().map(storeDTO -> storeDTO.getStoreInfoId()).collect(Collectors.toList());
if(CollectionUtils.isNotEmpty(storeAuth.getStoreInfoIdList())){
return storeInfoIdList.stream().filter(s -> {
for(Integer storeInfoId : storeAuth.getStoreInfoIdList()){
if(s.intValue() == storeInfoId.intValue()){
return true;
}
}
return false;
}).collect(Collectors.toList());
}else {
return storeInfoIdList;
}
}
}
return storeAuth.getStoreInfoIdList();
}
public List<String> onLineStoreSearch(Integer userId, Integer enterpriseId, String searchJson){
OnLineAuth onlineStoreAuth = this.dataAuthUtils.getOnlineStore(userId, enterpriseId);
List<String> list = new ArrayList<>();
if(onlineStoreAuth.isHasAuth()){
this.getOnlineStoreIds(searchJson, onlineStoreAuth, list, StoreChannelEnum.GICMALL.getChannel());
this.getOnlineStoreIds(searchJson, onlineStoreAuth, list, StoreChannelEnum.WMMALL.getChannel());
this.getOnlineStoreIds(searchJson, onlineStoreAuth, list, StoreChannelEnum.TIANMAO.getChannel());
}else {
list.add("noauth");
}
return list;
}
public Integer getLevel(Integer userId, Integer enterpriseId, String searchJson){
List<Integer> list = this.storeSearch(userId, enterpriseId, searchJson);
StoreSearchDTO storeSearchDTO = new StoreSearchDTO();
storeSearchDTO.setEnterpriseId(enterpriseId);
storeSearchDTO.setStoreInfoIds(StringUtils.join(list, ","));
List<StoreDTO> result = this.storeApiService.listStore(storeSearchDTO, 1, 20000).getResult().getResult();
Map<Integer, Integer> map = new HashMap<>();
result.forEach(storeDTO -> {
List<Integer> storeGroupIdList = storeDTO.getStoreGroupIdList();
storeGroupIdList.forEach(storeGroupId ->{
map.put(storeGroupId, storeGroupId);
});
});
List<StoreGroupDTO> allStoreGroupIdList = this.storeGroupApiService.listStoreGroupByIds(null, enterpriseId).getResult();
Map<Integer, Integer> levelMap = new HashMap<>();
allStoreGroupIdList.forEach(storeGroupDTO -> {
levelMap.put(storeGroupDTO.getGroupLevel(), levelMap.get(storeGroupDTO.getGroupLevel())== null ? 1 : levelMap.get(storeGroupDTO.getGroupLevel())+1);
});
int start = 0;
while (true){
if(levelMap.get(start) != null && levelMap.get(start).intValue() > 1){
return start;
}
start++;
}
}
private void getOnlineStoreIds(String searchJson, OnLineAuth onlineStoreAuth, List<String> list, Integer channel){
StoreSearchQo searchQo = JSON.parseObject(searchJson).getObject(channel.toString(), StoreSearchQo.class);
if(searchQo.getAll() == 1){
onlineStoreAuth.getList().stream().filter(s -> {
if(s.getChannel() == channel){
list.addAll(s.getStoreIdList());
}
return false;
});
}else {
list.addAll(Arrays.asList(searchQo.getStoreGroupIds().split(",")));
}
}
}
......@@ -54,6 +54,8 @@ public class StoreWidgetController {
private WmStoreApiService wmStoreApiService;
@Autowired
private StoreAttentionApiService storeAttentionApiService;
@Autowired
private StoreSearchUtils storeSearchUtils;
@RequestMapping("store-widget-index")
public RestResponse storeWidgetIndex(Integer userId, Integer enterpriseId){
......@@ -352,8 +354,11 @@ public class StoreWidgetController {
}
@RequestMapping("get-store-count")
public RestResponse getStoreCount(String searchJSON){
return RestResponse.success(1);
public RestResponse getStoreCount(String searchJSON, Integer userId, Integer enterpriseId){
List<Integer> list = this.storeSearchUtils.storeSearch(userId, enterpriseId, searchJSON);
List<String> stringList = this.storeSearchUtils.onLineStoreSearch(userId, enterpriseId, searchJSON);
log.info("getStoreCount:{},{},{},{},{}", searchJSON, userId, enterpriseId, list.size(), stringList.size());
return RestResponse.success(list.size() + stringList.size());
}
private Map<Integer, StoreGroupVo> mapStoreGroup(Integer enterpriseId){
......@@ -399,10 +404,10 @@ public class StoreWidgetController {
List<WmStoreDTO> result = wmStoreApiService.listWmStore(enterpriseId).getResult();
if(CollectionUtils.isNotEmpty(result)){
for(WmStoreDTO wmStoreDTO : result){
if(storeIdList.contains(wmStoreDTO.getWmStoreId())){
if(storeIdList.contains(wmStoreDTO.getWmMallStoreId().toString())){
OnLineStoreVo onLineStoreVo = new OnLineStoreVo();
onLineStoreVo.setOnStoreId(wmStoreDTO.getWmStoreId()+"");
onLineStoreVo.setOnStoreName(wmStoreDTO.getWmMainAccount());
onLineStoreVo.setOnStoreName(wmStoreDTO.getWmPidName());
list.add(onLineStoreVo);
}
}
......
package com.gic.cloud.web.qo;
public class StoreSearchQo {
private Integer all = 0;
private String region;
private String storeType;
private String storeStatus;
private String erpStatus;
private String storeTag;
private Integer attentionStore = 0;
private Integer tmpStore = 0;
private String storeGroupIds; //和线上共享使用,当为线上门店时,该值对应店铺
private String storeIds; //和线上共享使用,当为线上门店时,该值对应店铺下门店id
public Integer getAll() {
return all;
}
public void setAll(Integer all) {
this.all = all;
}
public String getStoreGroupIds() {
return storeGroupIds;
}
public void setStoreGroupIds(String storeGroupIds) {
this.storeGroupIds = storeGroupIds;
}
public String getRegion() {
return region;
}
public void setRegion(String region) {
this.region = region;
}
public String getStoreType() {
return storeType;
}
public void setStoreType(String storeType) {
this.storeType = storeType;
}
public String getStoreStatus() {
return storeStatus;
}
public void setStoreStatus(String storeStatus) {
this.storeStatus = storeStatus;
}
public String getErpStatus() {
return erpStatus;
}
public void setErpStatus(String erpStatus) {
this.erpStatus = erpStatus;
}
public String getStoreTag() {
return storeTag;
}
public void setStoreTag(String storeTag) {
this.storeTag = storeTag;
}
public Integer getAttentionStore() {
return attentionStore;
}
public void setAttentionStore(Integer attentionStore) {
this.attentionStore = attentionStore;
}
public Integer getTmpStore() {
return tmpStore;
}
public void setTmpStore(Integer tmpStore) {
this.tmpStore = tmpStore;
}
public String getStoreIds() {
return storeIds;
}
public void setStoreIds(String storeIds) {
this.storeIds = storeIds;
}
}
......@@ -142,4 +142,5 @@
<dubbo:reference interface="com.gic.marketing.process.api.service.sms.SmsSendApiService" id="smsSendApiService" timeout="6000" retries="0"/>
<dubbo:reference interface="com.gic.store.service.StoreTagApiService" id="storeTagApiService" timeout="6000" retries="0"/>
<dubbo:reference interface="com.gic.cloud.service.StoreAttentionApiService" id="storeAttentionApiService" timeout="6000" retries="0"/>
<dubbo:reference interface="com.gic.cloud.service.TempStoreConditionApiService" id="tempStoreConditionApiService" timeout="6000" retries="0"/>
</beans>
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