Commit 495d9c9b by zhiwj

Merge branch 'developer' of…

Merge branch 'developer' of http://115.159.76.241/base_platform_enterprise/gic-data-cloud into developer
parents 46eb1060 7f8c840f
......@@ -5,7 +5,9 @@ import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.cloud.web.auth.DataAuthUtils;
import com.gic.cloud.web.constant.StoreChannelEnum;
import com.gic.cloud.web.qo.BaseSalesParamQo;
import com.gic.cloud.web.qo.DateTypeQo;
import com.gic.cloud.web.utils.LevelUtil;
import com.gic.cloud.web.vo.BaseSalesVo;
import com.gic.cloud.web.vo.LevelVo;
import com.gic.commons.webapi.reponse.RestResponse;
......@@ -40,34 +42,53 @@ public class BaseSalesController {
private WmStoreApiService wmStoreApiService;
@RequestMapping("base-sales")
public RestResponse baseSales(Integer channel, Integer userId, Integer enterpriseId, String searchJSON,
DateTypeQo dateTypeQo, String mbrAreaId, Integer level, Integer parentId,
String sortField, Integer sortType, Integer pageNum, Integer pageSize){
List<Integer> list = this.storeSearchUtils.storeSearch(userId, enterpriseId, searchJSON);
List<String> onLine = this.storeSearchUtils.onLineStoreSearch(userId, enterpriseId, searchJSON);
List<Integer> childrenStoreGroupIdList = this.storeSearchUtils.getChildrenStoreGroupIdList(parentId);
List<Long> mbrAreaIdList = this.dataAuthUtils.getMbrAreaId(userId, enterpriseId);
if(level == null){
level = this.storeSearchUtils.getLevel(userId, enterpriseId, searchJSON).getLevel();
public RestResponse baseSales(BaseSalesParamQo qo){
BaseSalesVo vo = new BaseSalesVo();
List<Integer> list = this.storeSearchUtils.storeSearch(qo.getUserId(), qo.getEnterpriseId(), qo.getSearchJSON());
List<String> onLine = this.storeSearchUtils.onLineStoreSearch(qo.getUserId(), qo.getEnterpriseId(), qo.getSearchJSON());
List<Integer> childrenStoreGroupIdList = this.storeSearchUtils.getChildrenStoreGroupIdList(qo.getParentId());
List<Long> mbrAreaIdList = this.dataAuthUtils.getMbrAreaId(qo.getUserId(), qo.getEnterpriseId());
Integer maxLevel = 0;
/******线下渠道需要点击下钻,该值只会在线下时才会使用********/
LevelVo levelVo = this.storeSearchUtils.getLevel(qo.getUserId(), qo.getEnterpriseId(), qo.getSearchJSON());
if(qo.getLevel() == null){
qo.setLevel(levelVo.getLevel());
maxLevel = levelVo.getMaxLevel();
}
/****首页进入基础页面时,如果渠道为空,根据当前条件判断渠道,channel==null表示多渠道***/
if(qo.getChannel() == null){
/**********设置层级名称,只有在首次进入页面会展示,下钻均显示返回上一级*********/
Integer newChannel = this.storeSearchUtils.getChannel(qo.getUserId(), qo.getEnterpriseId(), qo.getSearchJSON());
qo.setChannel(newChannel);
}
/***********如果是线下的第一层级,需要展示切换层级按钮*************/
if(qo.getChannel() == StoreChannelEnum.OFFLINE.getChannel() && qo.getLevel() == levelVo.getLevel()){
vo.setChangeLevel(1);
}
if(qo.getChannel() == null){
vo.setLevelName("所有渠道");
} else if(qo.getChannel() == StoreChannelEnum.OFFLINE.getChannel()){
vo.setLevelName(LevelUtil.getLevelName(qo.getLevel()));
} else {
vo.setLevelName("店铺层级");
}
BaseSalesParamsDTO dto = new BaseSalesParamsDTO();
dto.setChannel(channel);
dto.setEnterpriseId(enterpriseId);
dto.setChannel(qo.getChannel());
dto.setEnterpriseId(qo.getEnterpriseId());
dto.setStoreInfoIdList(list);
dto.setOnLine(onLine);
dto.setMbrAreaId(StringUtils.isBlank(mbrAreaId) ? null : Long.valueOf(mbrAreaId));
dto.setMbrAreaId(StringUtils.isBlank(qo.getMbrAreaId()) ? null : Long.valueOf(qo.getMbrAreaId()));
dto.setMbrAreaIdList(mbrAreaIdList);
dto.setType(dateTypeQo.getType());
dto.setDate(dateTypeQo.getDate());
dto.setType(qo.getType());
dto.setDate(qo.getDate());
dto.setChildrenStoreGroupIdList(childrenStoreGroupIdList);
dto.setLevel(level);
dto.setSortField(sortField);
dto.setSortType(sortType == null ? 1 : sortType);
dto.setPageNum(pageNum);
dto.setPageSize(pageSize);
dto.setLevel(qo.getLevel());
dto.setSortField(qo.getSortField());
dto.setSortType(qo.getSortType() == null ? 1 : qo.getSortType());
dto.setPageNum(qo.getPageNum());
dto.setPageSize(qo.getPageSize());
ServiceResponse<Page<BaseSalesDTO>> response = this.baseSalesApiService.pageBaseSales(dto);
BaseSalesVo vo = new BaseSalesVo();
vo.setPage(this.parseData(response.getResult(), channel, enterpriseId, level));
vo.setPage(this.parseData(response.getResult(), qo.getChannel(), qo.getEnterpriseId(), qo.getLevel(), maxLevel));
dto.setCountType(2);//合计
ServiceResponse<Page<BaseSalesDTO>> response1 = this.baseSalesApiService.pageBaseSales(dto);
if(response1.isSuccess() && response1.getResult() != null && CollectionUtils.isNotEmpty(response1.getResult().getResult())){
......@@ -78,7 +99,7 @@ public class BaseSalesController {
vo.setTotal(total);
}
}
if(channel != null && channel == 1 && parentId == null){
if(qo.getChannel() != null && qo.getChannel() == 1 && qo.getParentId() == null){
dto.setCountType(3); //无归属
ServiceResponse<Page<BaseSalesDTO>> response2 = this.baseSalesApiService.pageBaseSales(dto);
if(response2.isSuccess() && response2.getResult() != null && CollectionUtils.isNotEmpty(response2.getResult().getResult())){
......@@ -93,21 +114,30 @@ public class BaseSalesController {
return RestResponse.success(vo);
}
public Page<BaseSalesDTO> parseData(Page<BaseSalesDTO> page , Integer channel, Integer enterpriseId, Integer level){
public Page<BaseSalesDTO> parseData(Page<BaseSalesDTO> page , Integer channel, Integer enterpriseId, Integer level, Integer maxLevel){
if(page != null && CollectionUtils.isNotEmpty(page.getResult())){
if(channel == null){ //全渠道
page.getResult().stream().forEach(baseSalesDTO -> {
baseSalesDTO.setLevel(level - 1);
if(StoreChannelEnum.OFFLINE.getChannel() == Integer.valueOf(baseSalesDTO.getId())){
baseSalesDTO.setName(StoreChannelEnum.OFFLINE.getMessage());
baseSalesDTO.setChannel(StoreChannelEnum.OFFLINE.getChannel());
baseSalesDTO.setHasChildren(1);
}
if(StoreChannelEnum.GICMALL.getChannel() == Integer.valueOf(baseSalesDTO.getId())){
baseSalesDTO.setName(StoreChannelEnum.GICMALL.getMessage());
baseSalesDTO.setChannel(StoreChannelEnum.GICMALL.getChannel());
baseSalesDTO.setHasChildren(1);
}
if(StoreChannelEnum.WMMALL.getChannel() == Integer.valueOf(baseSalesDTO.getId())){
baseSalesDTO.setName(StoreChannelEnum.WMMALL.getMessage());
baseSalesDTO.setChannel(StoreChannelEnum.WMMALL.getChannel());
baseSalesDTO.setHasChildren(1);
}
if(StoreChannelEnum.TIANMAO.getChannel() == Integer.valueOf(baseSalesDTO.getId())){
baseSalesDTO.setName(StoreChannelEnum.TIANMAO.getMessage());
baseSalesDTO.setChannel(StoreChannelEnum.TIANMAO.getChannel());
baseSalesDTO.setHasChildren(1);
}
});
}
......@@ -115,9 +145,11 @@ public class BaseSalesController {
List<ShopDTO> result = shopApiService.getAllShopByEnterpriseIdAndName(enterpriseId, null, ShopTypeEnum.MALL_SHOP.getCode()).getResult();
if(CollectionUtils.isNotEmpty(result)){
page.getResult().stream().forEach(baseSalesDTO -> {
baseSalesDTO.setLevel(level - 1);
for(ShopDTO shopDTO : result){
if(baseSalesDTO.getId().equals(shopDTO.getId())){
baseSalesDTO.setName(shopDTO.getName());
baseSalesDTO.setChannel(StoreChannelEnum.OFFLINE.getChannel());
}
}
});
......@@ -127,9 +159,11 @@ public class BaseSalesController {
List<WmStoreDTO> result1 = wmStoreApiService.listWmStore(enterpriseId, null).getResult();
if(CollectionUtils.isNotEmpty(result1)){
page.getResult().stream().forEach(baseSalesDTO -> {
baseSalesDTO.setLevel(level - 1);
for(WmStoreDTO dto : result1){
if(baseSalesDTO.getId().equals(dto.getWmMallStoreId()+"")){
baseSalesDTO.setName(dto.getWmMainAccount());
baseSalesDTO.setChannel(StoreChannelEnum.OFFLINE.getChannel());
}
}
});
......@@ -138,6 +172,8 @@ public class BaseSalesController {
if(channel == StoreChannelEnum.OFFLINE.getChannel()){
page.getResult().stream().forEach(baseSalesDTO -> {
baseSalesDTO.setLevel(level);
baseSalesDTO.setChannel(StoreChannelEnum.OFFLINE.getChannel());
baseSalesDTO.setHasChildren(level < maxLevel ? 1 : 0);
});
}
}
......
......@@ -9,9 +9,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSON;
import com.gic.cloud.web.auth.DataAuthUtils;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.data.api.qo.consumestructure.AgeConsumeAreaQO;
import com.gic.data.api.qo.consumestructure.AgeConsumeShareQO;
import com.gic.data.api.qo.consumestructure.GradeConsumeTrendQO;
import com.gic.data.api.qo.consumestructure.*;
import com.gic.data.api.service.consumestructure.ConsumeStructureApiService;
import com.gic.enterprise.utils.ResultControllerUtils;
......@@ -69,4 +67,90 @@ public class ConsumeStructureController {
params.setStoreInfoIdList(storeSearchUtils.storeSearch(params.getUserId(), params.getEnterpriseId(), params.getSearchJson()));
return ResultControllerUtils.commonResult(consumeStructureApiService.queryGradeConsumeTrend(params));
}
@RequestMapping("get-grade-consume-survey")
public RestResponse getGradeConsumeSurvey(GradeConsumeTrendQO params) {
log.info("消费构成-等级-概况参数:{}", JSON.toJSONString(params));
params.setOnlineStoreIdList(storeSearchUtils.onLineStoreSearch(params.getUserId(), params.getEnterpriseId(), params.getSearchJson()));
params.setStoreInfoIdList(storeSearchUtils.storeSearch(params.getUserId(), params.getEnterpriseId(), params.getSearchJson()));
return ResultControllerUtils.commonResult(consumeStructureApiService.queryGradeConsumeSurvey(params));
}
@RequestMapping("get-grade-consume-area")
public RestResponse queryGradeConsumeArea(GradeConsumeAreaQO params) {
log.info("消费构成-等级-区域参数:{}", JSON.toJSONString(params));
params.setOnlineStoreIdList(storeSearchUtils.onLineStoreSearch(params.getUserId(), params.getEnterpriseId(), params.getSearchJson()));
params.setStoreInfoIdList(storeSearchUtils.storeSearch(params.getUserId(), params.getEnterpriseId(), params.getSearchJson()));
if (params.getLevel() != null) {
params.setLevel(storeSearchUtils.getLevel(params.getUserId(), params.getEnterpriseId(), params.getSearchJson()).getLevel());
}
params.setGroupIdList(storeSearchUtils.getChildrenStoreGroupIdList(params.getParentId()));
return ResultControllerUtils.commonResult(consumeStructureApiService.pageGradeConsumeArea(params));
}
@RequestMapping("get-birth-consume-rate")
public RestResponse getBirthConsumeRate(BirthConsumeRateQO params) {
log.info("消费构成-生日会员-占比参数:{}", JSON.toJSONString(params));
params.setOnlineStoreIdList(storeSearchUtils.onLineStoreSearch(params.getUserId(), params.getEnterpriseId(), params.getSearchJson()));
params.setStoreInfoIdList(storeSearchUtils.storeSearch(params.getUserId(), params.getEnterpriseId(), params.getSearchJson()));
params.setMemberCardIdList(dataAuthUtils.getMbrAreaId(params.getUserId(), params.getEnterpriseId()));
return ResultControllerUtils.commonResult(consumeStructureApiService.getBirthConsumeRate(params));
}
@RequestMapping("get-birth-consume-trend")
public RestResponse getBirthConsumeTrend(BirthConsumeRateQO params) {
log.info("消费构成-生日会员-趋势参数:{}", JSON.toJSONString(params));
params.setOnlineStoreIdList(storeSearchUtils.onLineStoreSearch(params.getUserId(), params.getEnterpriseId(), params.getSearchJson()));
params.setStoreInfoIdList(storeSearchUtils.storeSearch(params.getUserId(), params.getEnterpriseId(), params.getSearchJson()));
params.setMemberCardIdList(dataAuthUtils.getMbrAreaId(params.getUserId(), params.getEnterpriseId()));
return ResultControllerUtils.commonResult(consumeStructureApiService.queryBirthConsumeTrend(params));
}
@RequestMapping("get-birth-consume-survey")
public RestResponse getBirthConsumeSurvey(BirthConsumeRateQO params) {
log.info("消费构成-生日会员-概况参数:{}", JSON.toJSONString(params));
params.setOnlineStoreIdList(storeSearchUtils.onLineStoreSearch(params.getUserId(), params.getEnterpriseId(), params.getSearchJson()));
params.setStoreInfoIdList(storeSearchUtils.storeSearch(params.getUserId(), params.getEnterpriseId(), params.getSearchJson()));
params.setMemberCardIdList(dataAuthUtils.getMbrAreaId(params.getUserId(), params.getEnterpriseId()));
return ResultControllerUtils.commonResult(consumeStructureApiService.queryBirthConsumeSurvey(params));
}
@RequestMapping("get-old-consume-rate")
public RestResponse getOldConsumeRate(NewOldConsumeRateQO params) {
log.info("消费构成-新老会员-占比参数:{}", JSON.toJSONString(params));
params.setOnlineStoreIdList(storeSearchUtils.onLineStoreSearch(params.getUserId(), params.getEnterpriseId(), params.getSearchJson()));
params.setStoreInfoIdList(storeSearchUtils.storeSearch(params.getUserId(), params.getEnterpriseId(), params.getSearchJson()));
params.setMemberCardIdList(dataAuthUtils.getMbrAreaId(params.getUserId(), params.getEnterpriseId()));
return ResultControllerUtils.commonResult(consumeStructureApiService.getOldConsumeRate(params));
}
@RequestMapping("get-old-consume-trend")
public RestResponse queryOldConsumeTrend(NewOldConsumeRateQO params) {
log.info("消费构成-新老会员-趋势参数:{}", JSON.toJSONString(params));
params.setOnlineStoreIdList(storeSearchUtils.onLineStoreSearch(params.getUserId(), params.getEnterpriseId(), params.getSearchJson()));
params.setStoreInfoIdList(storeSearchUtils.storeSearch(params.getUserId(), params.getEnterpriseId(), params.getSearchJson()));
params.setMemberCardIdList(dataAuthUtils.getMbrAreaId(params.getUserId(), params.getEnterpriseId()));
return ResultControllerUtils.commonResult(consumeStructureApiService.queryOldConsumeTrend(params));
}
@RequestMapping("get-old-consume-survey")
public RestResponse getBirthConsumeSurvey(NewOldConsumeRateQO params) {
log.info("消费构成-新老会员-概况参数:{}", JSON.toJSONString(params));
params.setOnlineStoreIdList(storeSearchUtils.onLineStoreSearch(params.getUserId(), params.getEnterpriseId(), params.getSearchJson()));
params.setStoreInfoIdList(storeSearchUtils.storeSearch(params.getUserId(), params.getEnterpriseId(), params.getSearchJson()));
params.setMemberCardIdList(dataAuthUtils.getMbrAreaId(params.getUserId(), params.getEnterpriseId()));
return ResultControllerUtils.commonResult(consumeStructureApiService.queryNewOldConsumeSurvey(params));
}
@RequestMapping("get-old-consume-area")
public RestResponse queryGradeConsumeArea(NewOldConsumeAreaQO params) {
log.info("消费构成-新老会员-区域参数:{}", JSON.toJSONString(params));
params.setOnlineStoreIdList(storeSearchUtils.onLineStoreSearch(params.getUserId(), params.getEnterpriseId(), params.getSearchJson()));
params.setStoreInfoIdList(storeSearchUtils.storeSearch(params.getUserId(), params.getEnterpriseId(), params.getSearchJson()));
if (params.getLevel() != null) {
params.setLevel(storeSearchUtils.getLevel(params.getUserId(), params.getEnterpriseId(), params.getSearchJson()).getLevel());
}
params.setGroupIdList(storeSearchUtils.getChildrenStoreGroupIdList(params.getParentId()));
return ResultControllerUtils.commonResult(consumeStructureApiService.pageNewOldConsumeArea(params));
}
}
......@@ -9,11 +9,13 @@ import com.gic.cloud.service.IndexApiService;
import com.gic.cloud.web.auth.DataAuthUtils;
import com.gic.cloud.web.qo.DateTypeQo;
import com.gic.cloud.web.vo.FunctionModuleVo;
import com.gic.cloud.web.vo.LevelNameVo;
import com.gic.cloud.web.vo.LevelVo;
import com.gic.cloud.web.vo.MbrVo;
import com.gic.cloud.web.vo.index.IndexSalesVo;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.data.api.dto.IndexMemberDTO;
import com.gic.data.api.dto.IndexSalesDTO;
import com.gic.data.api.service.IndexSalesApiService;
import org.apache.commons.collections.CollectionUtils;
......@@ -52,6 +54,26 @@ public class IndexController {
return RestResponse.success(EntityUtil.changeEntityByJSON(IndexSalesVo.class, indexSales.getResult()));
}
@RequestMapping("index-member")
public RestResponse indexMember(Integer userId, Integer enterpriseId, String searchJSON,
DateTypeQo dateTypeQo, String mbrAreaId){
List<Integer> list = this.storeSearchUtils.storeSearch(userId, enterpriseId, searchJSON);
List<String> onLine = this.storeSearchUtils.onLineStoreSearch(userId, enterpriseId, searchJSON);
List<Long> mbrAreaIdList = this.dataAuthUtils.getMbrAreaId(userId, enterpriseId);
ServiceResponse<IndexMemberDTO> indexMember = this.indexSalesApiService.getIndexMember(enterpriseId, list, onLine,
StringUtils.isNoneBlank(mbrAreaId) ? Long.valueOf(mbrAreaId) : null,
mbrAreaIdList, dateTypeQo.getType(), dateTypeQo.getDate());
return RestResponse.success(indexMember.getResult());
}
@RequestMapping("index-consume")
public RestResponse indexConsume(Integer userId, Integer enterpriseId, String searchJSON,
DateTypeQo dateTypeQo, String mbrAreaId){
List<Integer> list = this.storeSearchUtils.storeSearch(userId, enterpriseId, searchJSON);
List<String> onLine = this.storeSearchUtils.onLineStoreSearch(userId, enterpriseId, searchJSON);
List<Long> mbrAreaIdList = this.dataAuthUtils.getMbrAreaId(userId, enterpriseId);
return RestResponse.success();
}
@RequestMapping("function-list")
public RestResponse functionList(Integer userId){
......@@ -70,7 +92,24 @@ public class IndexController {
@RequestMapping("get-level")
public RestResponse getLevel(Integer userId, Integer enterpriseId, String searchJSON){
LevelVo level = this.storeSearchUtils.getLevel(userId, enterpriseId, searchJSON);
return RestResponse.success(level);
List<LevelNameVo> list = new ArrayList<>();
LevelNameVo vo1 = new LevelNameVo(1, "第一层级", 1 >= level.getLevel() && 1 <= level.getMaxLevel() ? 1: 0);
LevelNameVo vo2 = new LevelNameVo(2, "第二层级", 2 >= level.getLevel() && 2 <= level.getMaxLevel() ? 1: 0);
LevelNameVo vo3 = new LevelNameVo(3, "第三层级", 3 >= level.getLevel() && 3 <= level.getMaxLevel() ? 1: 0);
LevelNameVo vo4 = new LevelNameVo(4, "第四层级", 4 >= level.getLevel() && 4 <= level.getMaxLevel() ? 1: 0);
LevelNameVo vo5 = new LevelNameVo(5, "第五层级", 5 >= level.getLevel() && 5 <= level.getMaxLevel() ? 1: 0);
LevelNameVo vo6 = new LevelNameVo(6, "第六层级", 6 >= level.getLevel() && 6 <= level.getMaxLevel() ? 1: 0);
LevelNameVo vo7 = new LevelNameVo(7, "门店", 1);
LevelNameVo vo8 = new LevelNameVo(8, "导购", 1);
list.add(vo1);
list.add(vo2);
list.add(vo3);
list.add(vo4);
list.add(vo5);
list.add(vo6);
list.add(vo7);
list.add(vo8);
return RestResponse.success(list);
}
}
......@@ -15,6 +15,7 @@ import com.gic.cloud.web.auth.StoreAuth;
import com.gic.cloud.web.constant.StoreChannelEnum;
import com.gic.cloud.web.qo.StoreSearchQo;
import com.gic.cloud.web.vo.LevelVo;
import com.gic.redis.data.util.RedisUtil;
import com.gic.store.dto.StoreDTO;
import com.gic.store.dto.StoreGroupDTO;
import com.gic.store.dto.StoreSearchDTO;
......@@ -32,6 +33,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@Component
......@@ -51,17 +53,19 @@ public class StoreSearchUtils {
private StoreGroupApiService storeGroupApiService;
public List<Integer> storeSearch(Integer userId, Integer enterpriseId, String searchJson){
String key = "1:" + enterpriseId + ":" + userId +":" + (StringUtils.isNotBlank(searchJson) ? searchJson.hashCode() : "searchJSON".hashCode());
StoreAuth storeAuth = this.dataAuthUtils.getStoreAuth(userId, enterpriseId);
if(!storeAuth.isHasAuth()){
ArrayList<Integer> list = new ArrayList<>();
list.add(0);
return list;
}
List<Integer> resultList = new ArrayList<>();
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();
resultList = storeAuth.getStoreInfoIdList();
}else {
StoreSearchDTO storeSearchDTO = new StoreSearchDTO();
storeSearchDTO.setEnterpriseId(enterpriseId);
......@@ -91,30 +95,35 @@ public class StoreSearchUtils {
List<StoreDTO> storeDTOList = pageServiceResponse.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()){
resultList = storeInfoIdList.stream().filter(s -> {
for (Integer storeInfoId : storeAuth.getStoreInfoIdList()) {
if (s.intValue() == storeInfoId.intValue()) {
return true;
}
}
return false;
}).collect(Collectors.toList());
}else {
return storeInfoIdList;
}
}
}
}else {
resultList = storeAuth.getStoreInfoIdList();
}
if(CollectionUtils.isNotEmpty(resultList)){
RedisUtil.setCache(key, 1, 10l, TimeUnit.MINUTES);
}else {
resultList.add(0);
}
return storeAuth.getStoreInfoIdList();
return resultList;
}
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());
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.TIANMAO.getChannel(), userId, enterpriseId);
}else {
list.add("noauth");
}
......@@ -147,17 +156,47 @@ public class StoreSearchUtils {
}
});
int start = 0;
while (true){
if(levelMap.get(start) != null && levelMap.get(start).intValue() > 1){
vo.setLevel(start);
break;
if(!levelMap.isEmpty()){
while (true){
if(levelMap.get(start) != null && levelMap.get(start).intValue() > 1){
vo.setLevel(start);
break;
}
start++;
}
start++;
vo.setMaxLevel(levelMap.size() - 1);
}
vo.setMaxLevel(levelMap.size() - 1);
return vo;
}
public Integer getChannel(Integer userId, Integer enterpriseId, String searchJson){
String offlineKey = "1:" + enterpriseId + ":" + userId +":" + (StringUtils.isNotBlank(searchJson) ? searchJson.hashCode() : "searchJSON".hashCode());
String gicMallKey = "2:" + enterpriseId + ":" + userId +":" + (StringUtils.isNotBlank(searchJson) ? searchJson.hashCode() : "searchJSON".hashCode());
String wmKey = "3:" + enterpriseId + ":" + userId +":" + (StringUtils.isNotBlank(searchJson) ? searchJson.hashCode() : "searchJSON".hashCode());
String tmKey = "4:" + enterpriseId + ":" + userId +":" + (StringUtils.isNotBlank(searchJson) ? searchJson.hashCode() : "searchJSON".hashCode());
int offline = RedisUtil.getCache(offlineKey) == null ? 0 : 1;
int gicMall = RedisUtil.getCache(gicMallKey) == null ? 0 : 1;
int wm = RedisUtil.getCache(wmKey) == null ? 0 : 1;
int tm = RedisUtil.getCache(tmKey) == null ? 0 : 1;
if((offline + gicMall + wm + tm) > 1){ //多渠道
return null;
}else if((offline + gicMall + wm + tm) == 1){
if(offline == 1){
return offline;
}
if(gicMall == 1){
return gicMall;
}
if(wm == 1){
return wm;
}
if(tm == 1){
return tm;
}
}
return null;
}
public List<Integer> getChildrenStoreGroupIdList(Integer storeGroupId){
if(storeGroupId != null){
List<StoreGroupDTO> result = this.storeGroupApiService.listStoreGroupAndChildren(storeGroupId).getResult();
......@@ -168,24 +207,30 @@ public class StoreSearchUtils {
return new ArrayList<>();
}
private void getOnlineStoreIds(String searchJson, OnLineAuth onlineStoreAuth, List<String> list, Integer channel){
private void getOnlineStoreIds(String searchJson, OnLineAuth onlineStoreAuth, List<String> list, Integer channel, Integer userId, Integer enterpriseId){
String key = channel + ":" + enterpriseId +":" + userId +":" + (StringUtils.isNotBlank(searchJson) ? searchJson.hashCode() : "searchJSON".hashCode());
if(StringUtils.isNotBlank(searchJson)){
StoreSearchQo searchQo = JSON.parseObject(searchJson).getObject(channel.toString(), StoreSearchQo.class);
log.info("getOnlineStoreIds:{},{}", searchJson, JSON.toJSONString(searchQo));
if(searchQo != null){
if(searchQo.getAll() == 1){
onlineStoreAuth.getList().stream().filter(s -> {
if(s.getChannel() == channel){
list.addAll(s.getStoreIdList());
}
return false;
});
}else {
if(searchQo.getAll() != 1){
if(StringUtils.isNotBlank(searchQo.getStoreGroupIds())){
RedisUtil.setCache(key, 1, 10l, TimeUnit.MINUTES);
list.addAll(Arrays.asList(searchQo.getStoreGroupIds().split(",")));
}
}
}
} else {
onlineStoreAuth.getList().stream().forEach(s -> {
System.out.println(JSON.toJSONString(s));
if(s.getChannel().intValue() == channel.intValue()){
if(CollectionUtils.isNotEmpty(s.getStoreIdList())){
RedisUtil.setCache(key, 1, 10l, TimeUnit.MINUTES);
list.addAll(s.getStoreIdList());
}
}
});
}
}
}
package com.gic.cloud.web.qo;
public class BaseSalesParamQo {
private Integer channel;
private Integer userId;
private Integer enterpriseId;
private String searchJSON;
private Integer type;
private String date;
private String mbrAreaId;
private Integer level;
private Integer parentId;
private String sortField;
private Integer sortType;
private Integer pageNum;
private Integer pageSize;
public Integer getChannel() {
return channel;
}
public void setChannel(Integer channel) {
this.channel = channel;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public Integer getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(Integer enterpriseId) {
this.enterpriseId = enterpriseId;
}
public String getSearchJSON() {
return searchJSON;
}
public void setSearchJSON(String searchJSON) {
this.searchJSON = searchJSON;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getMbrAreaId() {
return mbrAreaId;
}
public void setMbrAreaId(String mbrAreaId) {
this.mbrAreaId = mbrAreaId;
}
public Integer getLevel() {
return level;
}
public void setLevel(Integer level) {
this.level = level;
}
public Integer getParentId() {
return parentId;
}
public void setParentId(Integer parentId) {
this.parentId = parentId;
}
public String getSortField() {
return sortField;
}
public void setSortField(String sortField) {
this.sortField = sortField;
}
public Integer getSortType() {
return sortType;
}
public void setSortType(Integer sortType) {
this.sortType = sortType;
}
public Integer getPageNum() {
return pageNum;
}
public void setPageNum(Integer pageNum) {
this.pageNum = pageNum;
}
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
}
package com.gic.cloud.web.utils;
import java.util.HashMap;
import java.util.Map;
public class LevelUtil {
private static Map<Integer, String> levelMap = new HashMap<>();
static {
levelMap.put(1, "第一层级");
levelMap.put(2, "第二层级");
levelMap.put(3, "第三层级");
levelMap.put(4, "第四层级");
levelMap.put(5, "第五层级");
levelMap.put(6, "第六层级");
levelMap.put(7, "门店");
levelMap.put(8, "导购");
}
public static String getLevelName(Integer level){
return levelMap.get(level);
}
}
......@@ -7,6 +7,8 @@ public class BaseSalesVo {
private Page<BaseSalesDTO> page;
private BaseSalesDTO total;
private BaseSalesDTO wgs;
private String levelName;
private Integer changeLevel = 0;
public Page<BaseSalesDTO> getPage() {
return page;
......@@ -31,4 +33,20 @@ public class BaseSalesVo {
public void setWgs(BaseSalesDTO wgs) {
this.wgs = wgs;
}
public String getLevelName() {
return levelName;
}
public void setLevelName(String levelName) {
this.levelName = levelName;
}
public Integer getChangeLevel() {
return changeLevel;
}
public void setChangeLevel(Integer changeLevel) {
this.changeLevel = changeLevel;
}
}
package com.gic.cloud.web.vo;
public class LevelNameVo {
private Integer level = 0;
private String levelName;
private Integer canSelect = 1;
public LevelNameVo(){
}
public LevelNameVo(Integer level, String levelName, Integer canSelect){
this.level = level;
this.levelName = levelName;
this.canSelect = canSelect;
}
public Integer getLevel() {
return level;
}
public void setLevel(Integer level) {
this.level = level;
}
public String getLevelName() {
return levelName;
}
public void setLevelName(String levelName) {
this.levelName = levelName;
}
public Integer getCanSelect() {
return canSelect;
}
public void setCanSelect(Integer canSelect) {
this.canSelect = canSelect;
}
}
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