Commit 3c5e07ff by fudahua

门店binlog

parent 1e3f78ae
......@@ -70,5 +70,13 @@ public interface StoreRangeService {
*/
public Page<TabStoreRelation> pageStoreRelation(String enterpriseId, String wxEnterpriseId, String search, BasePageInfo pageInfo);
/**
* 保存门店的绑定关联关系
*
* @param list
* @return
*/
public boolean saveStoreRelations(List<TabStoreRelation> list);
}
......@@ -93,4 +93,13 @@ public class StoreRangeServiceImpl implements StoreRangeService {
Page<TabStoreRelation> retPage = PageUtil.changePageHelperToCurrentPage(new PageInfo<>(storeRelations));
return retPage;
}
@Override
public boolean saveStoreRelations(List<TabStoreRelation> list) {
//todo 销售线索 批量操作
list.forEach(tab -> {
tabHaobanStoreRelationMapper.insertSelective(tab);
});
return true;
}
}
......@@ -6,6 +6,7 @@ import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.Page;
import com.gic.commons.util.ToolUtil;
import com.gic.enterprise.api.dto.*;
import com.gic.enterprise.api.service.StoreService;
import com.gic.haoban.base.api.common.BasePageInfo;
......@@ -240,6 +241,12 @@ public class WxEnterpriseRelatedApiServiceImpl implements WxEnterpriseRelatedApi
tab.setUpdateTime(new Date());
tab.setWxEnterpriseRelatedId(UuidUtil.randomUUID());
wxEnterpriseRelatedMapper.insertSelective(tab);
} else {
tab.setMemberOpenCardFlag(detailDTO.getMemberOpenCardFlag());
tab.setWxEnterpriseType(detailDTO.getWxEnterpriseType());
tab.setRangeType(1);
tab.setUpdateTime(new Date());
wxEnterpriseRelatedMapper.updateByPrimaryKeySelective(tab);
}
//保存门店范围
......@@ -278,7 +285,7 @@ public class WxEnterpriseRelatedApiServiceImpl implements WxEnterpriseRelatedApi
// 获取所有门店信息
List<StoreSimpleDTO> storeDtos = storeService.listSimpleStore(enterpriseId, null, null);
Map<String, List<String>> storeMapByGroupId = storeDtos.stream().collect(Collectors.groupingBy(dto -> dto.getStoreGroupId(), Collectors.mapping(dto -> dto.getStoreId(), Collectors.toList())));
Map<String, String> storeIdMap = storeDtos.stream().collect(Collectors.toMap(dto -> dto.getStoreId(), dto -> dto.getStoreGroupId()));
//获取所有门店分组
List<PowerStoreGroupDTO> storeGroupList = storeGroupService.getStoreGroupList(enterpriseId, null);
......@@ -304,14 +311,26 @@ public class WxEnterpriseRelatedApiServiceImpl implements WxEnterpriseRelatedApi
});
//组装门店的id
Map<String, Set<String>> ret = new HashMap<>();
List<TabStoreRelation> ret = new ArrayList<>();
relationMapByWxEid.forEach((wxEid, groupIds) -> {
Set<String> storeIds = groupIds.stream().filter(mid -> storeGroupChainMap.containsKey(mid))
.flatMap(midGid -> storeGroupChainMap.get(midGid).stream()).collect(Collectors.toSet());
ret.put(wxEid, storeIds);
List<TabStoreRelation> midRelations = groupIds.stream().filter(mid -> storeGroupChainMap.containsKey(mid))
.flatMap(midGid -> storeGroupChainMap.get(midGid).stream())
.map(storeId -> {
//todo 销售线索 门店名称 企业id
TabStoreRelation tabStoreRelation = new TabStoreRelation();
tabStoreRelation.setWxEnterpriseId(wxEid);
tabStoreRelation.setStoreGroupId(storeIdMap.get(storeId));
tabStoreRelation.setStatusFlag(1);
tabStoreRelation.setStoreRelationId(ToolUtil.randomUUID());
tabStoreRelation.setCreateTime(new Date());
tabStoreRelation.setUpdateTime(new Date());
return tabStoreRelation;
}).collect(Collectors.toList());
ret.addAll(midRelations);
});
storeRangeService.saveStoreRelations(ret);
return false;
}
......@@ -358,4 +377,6 @@ public class WxEnterpriseRelatedApiServiceImpl implements WxEnterpriseRelatedApi
retPage.setResult(EntityUtil.changeEntityListNew(BindStoreInfoDTO.class, dtoList));
return retPage;
}
}
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