Commit baccac7b by fudahua

企业绑定门店

parent 6fe92404
......@@ -288,6 +288,9 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
@Override
public List<StaffClerkRelationDTO> listBindStoreIdByEnterpriseId(String enterpriseId) {
List<TabHaobanStaffClerkRelation> clerkRelations = mapper.listBindStoreIdByEnterpriseId(enterpriseId);
if (CollectionUtils.isEmpty(clerkRelations)) {
return new ArrayList<>();
}
return EntityUtil.changeEntityListNew(StaffClerkRelationDTO.class, clerkRelations);
}
}
......@@ -4,6 +4,7 @@ import com.gic.api.base.commons.Page;
import com.gic.commons.util.ToolUtil;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.common.utils.PageUtil;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.api.dto.StoreOrGroupInfoDTO;
import com.gic.haoban.manage.api.enums.ChannelCodeEnum;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanStoreRangeMapper;
......@@ -113,9 +114,8 @@ public class StoreRangeServiceImpl implements StoreRangeService {
String enterpriseId = list.get(0).getEnterpriseId();
//根据wxEnterpriseId 分组
Map<String, Set<String>> newStoreIdBywxEnterpriseMap = list.stream().collect(Collectors.groupingBy(TabStoreRelation::getWxEnterpriseId, Collectors.mapping(dto -> dto.getStoreId(), Collectors.toSet())));
List<TabStoreRelation> storeRelations = tabHaobanStoreRelationMapper.listStoreRange(enterpriseId);
Map<String, Set<String>> oldStoreIdBywxEnterpriseMap = storeRelations.stream().collect(Collectors.groupingBy(TabStoreRelation::getWxEnterpriseId, Collectors.mapping(dto -> dto.getStoreId(), Collectors.toSet())));
//所有就的门店old绑定列表
Map<String, Set<String>> oldStoreIdBywxEnterpriseMap = getOldStoreIdsByWxEnterpriseId(enterpriseId);
Set<String> needUnBindStoreIds = new HashSet<>();
oldStoreIdBywxEnterpriseMap.forEach((wxEid, oldStoreIds) -> {
......@@ -135,6 +135,51 @@ public class StoreRangeServiceImpl implements StoreRangeService {
return true;
}
/**
* 获取企业下的老的绑定门店
*
* @param enterpriseId
* @return
*/
private Map<String, Set<String>> getOldStoreIdsByWxEnterpriseId(String enterpriseId) {
Map<String, Set<String>> ret = new HashMap<>();
Set<String> wxEnterpriseIds = new HashSet<>();
//更新前绑定门店列表
List<TabStoreRelation> storeRelations = tabHaobanStoreRelationMapper.listStoreRange(enterpriseId);
Map<String, Set<String>> oldStoreIdBywxEnterpriseMap = storeRelations.stream().collect(Collectors.groupingBy(TabStoreRelation::getWxEnterpriseId, Collectors.mapping(dto -> dto.getStoreId(), Collectors.toSet())));
if (CollectionUtils.isNotEmpty(storeRelations)) {
wxEnterpriseIds.addAll(oldStoreIdBywxEnterpriseMap.keySet());
}
//导购绑定列表
List<StaffClerkRelationDTO> staffClerkRelationDTOS = staffClerkRelationService.listBindStoreIdByEnterpriseId(enterpriseId);
Map<String, Set<String>> oldStaffStoreIdByWxEidMap = staffClerkRelationDTOS.stream().collect(Collectors.groupingBy(StaffClerkRelationDTO::getWxEnterpriseId, Collectors.mapping(dto -> dto.getStoreId(), Collectors.toSet())));
if (CollectionUtils.isNotEmpty(staffClerkRelationDTOS)) {
wxEnterpriseIds.addAll(oldStaffStoreIdByWxEidMap.keySet());
}
if (CollectionUtils.isEmpty(wxEnterpriseIds)) {
return ret;
}
//聚合两者就是总门店了
wxEnterpriseIds.forEach(wxid -> {
if (!ret.containsKey(wxid)) {
ret.put(wxid, new HashSet<>());
}
Set<String> storeIds = oldStaffStoreIdByWxEidMap.get(wxid);
if (CollectionUtils.isNotEmpty(storeIds)) {
ret.get(wxid).addAll(storeIds);
}
Set<String> staffStoreIds = oldStoreIdBywxEnterpriseMap.get(wxid);
if (CollectionUtils.isNotEmpty(staffStoreIds)) {
ret.get(wxid).addAll(staffStoreIds);
}
});
return ret;
}
@Override
public List<TabStoreRange> queryStoreRangeByRelationId(String enterpriseId, List<String> relationIds) {
return tabHaobanStoreRangeMapper.listStoreRangeByRelationId(relationIds, enterpriseId);
......
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