Commit cf25c2f0 by guojx

门店状态筛选接口优化

parent d3255f9a
......@@ -948,6 +948,10 @@ public class StaffApiServiceImpl implements StaffApiService {
storeSearchDTO.setStatusAnyIn(storeStatusList);
}
List<String> resultList = storeService.listStoreIds(storeSearchDTO);
if (CollectionUtils.isEmpty(resultList)) {
return Collections.singletonList("no_store");
}
if (addUnassignedStore && isSuperAdminStore) {
if (!hasStoreStatusFilter || storeStatusList.contains("2")) {
//所有门店权限,且选择了上线门店状态,则添加无归属门店id
......
......@@ -20,6 +20,7 @@ import com.gic.enterprise.api.enums.CustomPageTypeEnum;
import com.gic.enterprise.api.service.*;
import com.gic.haoban.manage.web.qo.StaffAddVO;
import com.gic.haoban.manage.web.utils.CustomSwitcher;
import com.gic.haoban.manage.web.utils.storestatusfilter.StoreStatusFilterUtils;
import com.gic.haoban.manage.web.vo.*;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -1802,60 +1803,81 @@ public class WxStaffController extends WebBaseController {
@RequestMapping("/list-clerk-store")
public RestResponse<Object> listClerkStore(String wxEnterpriseId, String enterpriseId, String clerkId,
@RequestParam(defaultValue = "20") int pageSize, @RequestParam(defaultValue = "1") int currentPage,
String storeSearchParams) {
List<String> storeIdList = this.staffApiService.getHaoBanStoreIdsRolesByClerkId(clerkId, wxEnterpriseId);
if (CollectionUtils.isEmpty(storeIdList)) {
String storeSearchParams, Integer storeStatusFilter) {
if (StringUtils.isBlank(enterpriseId)) {
return RestResponse.failure("-1", "企业参数为空");
}
// List<String> storeIdList = this.staffApiService.getHaoBanStoreIdsRolesByClerkId(clerkId, wxEnterpriseId);
List<String> storeIdList = this.staffApiService.getHaobanStoreIdsRolesByClerkIdAndStoreStatus(clerkId, wxEnterpriseId,
StoreStatusFilterUtils.getStoreStatusList(storeStatusFilter), null);
if (CollectionUtils.isNotEmpty(storeIdList) && storeIdList.contains("no_store")) {
return RestResponse.failure("-1", "无授权门店");
}
List<StoreListVO> voList = new ArrayList<>();
int totalCount = 0;
List<StoreDTO> storeDTOList = new ArrayList<>();
if (storeIdList.get(0).contains("-1")) {
String storeWidgetId = this.powerService.getStoreWidgetId(null, clerkId);
logger.info("权限-所有门店storeWidgetId={}", storeWidgetId);
Page<Object> pageParam = new Page<Object>();
pageParam.setCurrentPage(currentPage);
pageParam.setPageSize(pageSize);
ClerkDTO clerkDTO = clerkService.getClerkByClerkIdNoStatus(clerkId);
if(clerkDTO.getClerkType() == 2) {
Page<StoreDTO> page = storeWidgetService.getStoreWidgetStore(storeWidgetId, null, enterpriseId, pageParam,
null, null);
if (page != null) {
storeDTOList = page.getResult();
totalCount = page.getTotalCount();
}
}else if(clerkDTO.getClerkType()==3) {
StoreSearchDTO searchDTO = new StoreSearchDTO() ;
searchDTO.setEnterpriseId(clerkDTO.getEnterpriseId());
Page<StoreDTO> page = this.storeService.storeListPage(pageParam,searchDTO) ;
if (page != null) {
storeDTOList = page.getResult();
totalCount = page.getTotalCount();
}
}
} else {
totalCount = storeIdList.size();
int start = pageSize * (currentPage - 1);
if (start < totalCount) {
int end = start + pageSize;
if (end > totalCount) {
end = totalCount;
}
List<String> subStoreIdList = storeIdList.subList(start, end);
if (CollectionUtils.isNotEmpty(subStoreIdList)) {
logger.info("分页当前页storeid数={}", subStoreIdList.size());
String[] arr = new String[subStoreIdList.size()];
List<StoreDTO> storeList = this.storeService.getStores(subStoreIdList.toArray(arr));
Map<String, StoreDTO> storeMap = storeList.stream()
.collect(Collectors.toMap(StoreDTO::getStoreId, o -> o, (k1, k2) -> k1));
for (String id : subStoreIdList) {
if (null != storeMap.get(id)) {
storeDTOList.add(storeMap.get(id));
}
}
}
}
}
searchDTO.setEnterpriseId(enterpriseId);
searchDTO.setStatusIn("-3");
if (CollectionUtils.isNotEmpty(storeIdList)) {
searchDTO.setAuthStoreIdList(storeIdList);
}
Page<StoreDTO> resPage = this.storeService.storeListPage(pageParam,searchDTO) ;
if (resPage != null) {
storeDTOList = resPage.getResult();
totalCount = resPage.getTotalCount();
}
// if (storeIdList.get(0).contains("-1")) {
// String storeWidgetId = this.powerService.getStoreWidgetId(null, clerkId);
// logger.info("权限-所有门店storeWidgetId={}", storeWidgetId);
// Page<Object> pageParam = new Page<Object>();
// pageParam.setCurrentPage(currentPage);
// pageParam.setPageSize(pageSize);
// ClerkDTO clerkDTO = clerkService.getClerkByClerkIdNoStatus(clerkId);
// if(clerkDTO.getClerkType() == 2) {
// Page<StoreDTO> page = storeWidgetService.getStoreWidgetStore(storeWidgetId, null, enterpriseId, pageParam,
// null, null);
// if (page != null) {
// storeDTOList = page.getResult();
// totalCount = page.getTotalCount();
// }
// }else if(clerkDTO.getClerkType()==3) {
// StoreSearchDTO searchDTO = new StoreSearchDTO() ;
// searchDTO.setEnterpriseId(clerkDTO.getEnterpriseId());
// Page<StoreDTO> page = this.storeService.storeListPage(pageParam,searchDTO) ;
// if (page != null) {
// storeDTOList = page.getResult();
// totalCount = page.getTotalCount();
// }
// }
// } else {
// totalCount = storeIdList.size();
// int start = pageSize * (currentPage - 1);
// if (start < totalCount) {
// int end = start + pageSize;
// if (end > totalCount) {
// end = totalCount;
// }
// List<String> subStoreIdList = storeIdList.subList(start, end);
// if (CollectionUtils.isNotEmpty(subStoreIdList)) {
// logger.info("分页当前页storeid数={}", subStoreIdList.size());
// String[] arr = new String[subStoreIdList.size()];
// List<StoreDTO> storeList = this.storeService.getStores(subStoreIdList.toArray(arr));
// Map<String, StoreDTO> storeMap = storeList.stream()
// .collect(Collectors.toMap(StoreDTO::getStoreId, o -> o, (k1, k2) -> k1));
// for (String id : subStoreIdList) {
// if (null != storeMap.get(id)) {
// storeDTOList.add(storeMap.get(id));
// }
// }
// }
// }
// }
if (CollectionUtils.isNotEmpty(storeDTOList)) {
for (StoreDTO store : storeDTOList) {
StoreListVO vo = new StoreListVO();
......@@ -1863,6 +1885,7 @@ public class WxStaffController extends WebBaseController {
vo.setStoreName(store.getStoreName());
vo.setStoreCode(store.getStoreCode());
vo.setEnterpriseId(store.getEnterpriseId());
vo.setStoreStatusFilter(StoreStatusFilterUtils.getStoreStatusFilter(store.getStatus()));
voList.add(vo);
}
}
......@@ -1929,6 +1952,7 @@ public class WxStaffController extends WebBaseController {
vo.setStoreName(dto.getStoreName());
vo.setStoreCode(dto.getStoreCode());
vo.setEnterpriseId(dto.getEnterpriseId());
vo.setStoreStatusFilter(StoreStatusFilterUtils.getStoreStatusFilter(dto.getStatus()));
retList.add(vo);
}
return retList;
......@@ -1937,13 +1961,14 @@ public class WxStaffController extends WebBaseController {
// 区经门店查询
@RequestMapping("search-clerk-store")
public RestResponse<Object> listClerkStoreByParams(String wxEnterpriseId, String enterpriseId, String clerkId,
String storeSearchParams) {
String storeSearchParams, Integer storeStatusFilter) {
if (StringUtils.isEmpty(storeSearchParams)) {
return RestResponse.failure("-1", "查询条件为空");
}
// 如果有权限控制,进行管辖门店过0滤
List<String> authStoreIdList = this.staffApiService.getHaoBanStoreIdsRolesByClerkId(clerkId, wxEnterpriseId);
if (CollectionUtils.isEmpty(authStoreIdList)) {
List<String> authStoreIdList = this.staffApiService.getHaobanStoreIdsRolesByClerkIdAndStoreStatus(clerkId, wxEnterpriseId,
StoreStatusFilterUtils.getStoreStatusList(storeStatusFilter), null);
if (CollectionUtils.isNotEmpty(authStoreIdList) && authStoreIdList.contains("no_store")) {
return RestResponse.failure("-1", "无授权门店");
}
Page page = this.page(wxEnterpriseId, enterpriseId, clerkId, 20, 1, storeSearchParams, authStoreIdList);
......
......@@ -23,9 +23,11 @@ import com.gic.enterprise.api.service.EnterpriseChannelApiService;
import com.gic.enterprise.api.service.EnterpriseService;
import com.gic.enterprise.api.service.data.DataIndexApiService;
import com.gic.enterprise.service.CustomSettingApiService;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.web.qo.data.*;
import com.gic.haoban.manage.web.utils.DateFillUtils;
import com.gic.haoban.manage.web.utils.StoreAuthUtils;
import com.gic.haoban.manage.web.utils.storestatusfilter.StoreStatusFilterUtils;
import com.gic.haoban.manage.web.vo.data.DataMemberExtendVO;
import com.gic.haoban.manage.web.vo.data.SalesStructureVO;
import lombok.extern.slf4j.Slf4j;
......@@ -52,6 +54,8 @@ import java.util.stream.Stream;
@Slf4j
public class DataController {
@Autowired
private StaffApiService staffApiService;
@Autowired
private StoreAuthUtils storeAuthUtils;
@Autowired
private DataIndexApiService dataIndexApiService;
......@@ -487,7 +491,10 @@ public class DataController {
String storeIdParam = jsonObject.getString("storeId");
boolean hasStoreId = StringUtils.isNotBlank(storeIdParam);
if (!hasStoreId) {
getAuthStore(qo.getStoreId(), qo.getClerkId(), qo.getWxEnterpriseId(), jsonObject);
List<String> authStoreIdList = staffApiService.getNotEmptyHaobanStoreIdsRolesByClerkIdAndStoreStatus(qo.getClerkId(), qo.getWxEnterpriseId(),
StoreStatusFilterUtils.getStoreStatusList(jsonObject.getInteger("storeStatusFilter")), true);
jsonObject.put("storeId", authStoreIdList.stream().collect(Collectors.joining(",")));
//getAuthStore(qo.getStoreId(), qo.getClerkId(), qo.getWxEnterpriseId(), jsonObject);
}
String apolloKey = qo.getApolloKey();
......
package com.gic.haoban.manage.web.utils.storestatusfilter;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class StoreStatusFilterUtils {
/**
* 获取门店实际状态值
* @param storeStatusFilter 0或者空:全部 1:上线 2:未上线 -3 :回收站
* @return
*/
public static List<String> getStoreStatusList(Integer storeStatusFilter) {
if (storeStatusFilter == null || storeStatusFilter == 0) {
return Collections.emptyList();
}
switch (storeStatusFilter) {
case 2:
return Stream.of("3", "6", "7").collect(Collectors.toList());
case -3:
return Stream.of("-3").collect(Collectors.toList());
default:
return Stream.of("2").collect(Collectors.toList());
}
}
public static Integer getStoreStatusFilter(Integer storeStatus) {
switch (storeStatus) {
case 2:
return 1;
case -3:
return -3;
default :
return 2;
}
}
}
......@@ -10,6 +10,20 @@ public class StoreListVO implements Serializable{
private String enterpriseId;
/**
* 1:上线 2:未上线 -3 :回收站
*/
private Integer storeStatusFilter;
public Integer getStoreStatusFilter() {
return storeStatusFilter;
}
public void setStoreStatusFilter(Integer storeStatusFilter) {
this.storeStatusFilter = storeStatusFilter;
}
public String getStoreId() {
return storeId;
}
......
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