Commit cf25c2f0 by guojx

门店状态筛选接口优化

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