Commit 007f59b4 by fudahua

绑定接口

parent 83a7a273
...@@ -15,6 +15,10 @@ public class StoreRangeInfoDTO implements Serializable { ...@@ -15,6 +15,10 @@ public class StoreRangeInfoDTO implements Serializable {
* *
*/ */
private String wxEnterpriseId; private String wxEnterpriseId;
/**
* 企业名称
*/
private String wxEnterpriseName;
/** /**
* 关联id 默认0 * 关联id 默认0
...@@ -26,6 +30,13 @@ public class StoreRangeInfoDTO implements Serializable { ...@@ -26,6 +30,13 @@ public class StoreRangeInfoDTO implements Serializable {
*/ */
private Integer relationType; private Integer relationType;
public String getWxEnterpriseName() {
return wxEnterpriseName;
}
public void setWxEnterpriseName(String wxEnterpriseName) {
this.wxEnterpriseName = wxEnterpriseName;
}
/** /**
*/ */
......
package com.gic.haoban.manage.web.controller; package com.gic.haoban.manage.web.controller;
import java.util.HashSet; import com.gic.enterprise.api.dto.PowerStoreGroupDTO;
import java.util.List; import com.gic.enterprise.api.service.StoreGroupService;
import java.util.Set; import com.gic.haoban.common.utils.HaobanResponse;
import java.util.stream.Collectors;
import com.gic.haoban.auth.api.dto.UserRightDetailDTO;
import com.gic.haoban.manage.api.dto.StoreRangeInfoDTO; import com.gic.haoban.manage.api.dto.StoreRangeInfoDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseRelationDetailDTO; import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService; import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.vo.LoginVO; import com.gic.haoban.manage.web.vo.LoginVO;
import com.gic.haoban.manage.web.vo.StoreGroupVo; import com.gic.haoban.manage.web.vo.StoreGroupVo;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
...@@ -18,11 +16,11 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -18,11 +16,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.gic.enterprise.api.dto.PowerStoreGroupDTO; import java.util.HashMap;
import com.gic.enterprise.api.service.StoreGroupService; import java.util.HashSet;
import com.gic.haoban.base.api.common.BasePageInfo; import java.util.List;
import com.gic.haoban.common.utils.HaobanResponse; import java.util.Map;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode; import java.util.stream.Collectors;
@RestController @RestController
public class GicDepartmentController extends WebBaseController{ public class GicDepartmentController extends WebBaseController{
...@@ -49,17 +47,28 @@ public class GicDepartmentController extends WebBaseController{ ...@@ -49,17 +47,28 @@ public class GicDepartmentController extends WebBaseController{
String wxEnterpriseId = loginUser.getWxEnterpriseId(); String wxEnterpriseId = loginUser.getWxEnterpriseId();
List<PowerStoreGroupDTO> departmentList = storeGroupService.getStoreGroupList(enterpriseId, keyWord); List<PowerStoreGroupDTO> departmentList = storeGroupService.getStoreGroupList(enterpriseId, keyWord);
List<StoreRangeInfoDTO> rangeInfoDTOList = wxEnterpriseRelatedApiService.listAllBindStoreOrGroup(enterpriseId); List<StoreRangeInfoDTO> rangeInfoDTOList = wxEnterpriseRelatedApiService.listAllBindStoreOrGroup(enterpriseId);
Set<String> groupIds = new HashSet<>(); Map<String, StoreRangeInfoDTO> storeRangeMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(rangeInfoDTOList)) { if (CollectionUtils.isNotEmpty(rangeInfoDTOList)) {
groupIds = rangeInfoDTOList.stream().filter(dto -> (!dto.getWxEnterpriseId().equals(wxEnterpriseId)) && dto.getRelationType() == 1) List<WxEnterpriseDTO> wxEnterpriseDTOS = wxEnterpriseRelatedApiService.listWxEnterpriseByEid(enterpriseId);
.map(dto -> dto.getRelationId()).collect(Collectors.toSet()); Map<String, WxEnterpriseDTO> wxEnterpriseDTOMap = wxEnterpriseDTOS.stream().collect(Collectors.toMap(dto -> dto.getWxEnterpriseId(), dto -> dto));
storeRangeMap = rangeInfoDTOList.stream().filter(dto -> (!dto.getWxEnterpriseId().equals(wxEnterpriseId)) && dto.getRelationType() == 1)
.map(dto -> {
dto.setWxEnterpriseName(wxEnterpriseDTOMap.get(dto.getWxEnterpriseId()).getCorpName());
return dto;
}).collect(Collectors.toMap(dto -> dto.getRelationId(), dto -> dto));
} }
Set<String> finalGroupIds = groupIds; Map<String, StoreRangeInfoDTO> finalStoreRangeMap = storeRangeMap;
List<StoreGroupVo> ret = departmentList.stream().map(dto -> { List<StoreGroupVo> ret = departmentList.stream().map(dto -> {
StoreRangeInfoDTO mid = finalStoreRangeMap.get(dto.getStoreGroupId());
StoreGroupVo storeGroupVo = new StoreGroupVo(); StoreGroupVo storeGroupVo = new StoreGroupVo();
storeGroupVo.setRelationId(dto.getStoreGroupId()); storeGroupVo.setRelationId(dto.getStoreGroupId());
storeGroupVo.setParentRelationId(dto.getParentGroupId()); storeGroupVo.setParentRelationId(dto.getParentGroupId());
storeGroupVo.setIsBind(finalGroupIds.contains(dto.getStoreGroupId()) ? 1 : 0); if (mid != null) {
storeGroupVo.setIsBind(1);
storeGroupVo.setWxEnterpriseId(mid.getWxEnterpriseId());
storeGroupVo.setWxEnterpriseName(mid.getWxEnterpriseName());
}
storeGroupVo.setRelationType(1); storeGroupVo.setRelationType(1);
storeGroupVo.setRelationName(dto.getStoreGroupName()); storeGroupVo.setRelationName(dto.getStoreGroupName());
return storeGroupVo; return storeGroupVo;
......
...@@ -12,8 +12,26 @@ public class StoreGroupVo implements Serializable { ...@@ -12,8 +12,26 @@ public class StoreGroupVo implements Serializable {
private Integer relationType; private Integer relationType;
private String relationName; private String relationName;
private int isBind = 0; private int isBind = 0;
private String wxEnterpriseId;
private String wxEnterpriseName;
private String parentRelationId; private String parentRelationId;
public String getWxEnterpriseId() {
return wxEnterpriseId;
}
public void setWxEnterpriseId(String wxEnterpriseId) {
this.wxEnterpriseId = wxEnterpriseId;
}
public String getWxEnterpriseName() {
return wxEnterpriseName;
}
public void setWxEnterpriseName(String wxEnterpriseName) {
this.wxEnterpriseName = wxEnterpriseName;
}
public String getRelationId() { public String getRelationId() {
return relationId; return relationId;
} }
......
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