Commit 91f0f42c by guojuxing

店招品牌添加共享标志

parent 3d720276
...@@ -57,6 +57,17 @@ public class StoreBrandDTO implements Serializable { ...@@ -57,6 +57,17 @@ public class StoreBrandDTO implements Serializable {
/**1自有 2共享*/ /**1自有 2共享*/
private Integer type; private Integer type;
/***********前端使用字段*********/
/**
* 共享标记 1:自有 0:共享
*/
private Integer ownerFlag;
/**
* 自有商户名称
*/
private String ownerEntName;
public Integer getStoreBrandId() { public Integer getStoreBrandId() {
return storeBrandId; return storeBrandId;
} }
...@@ -153,6 +164,27 @@ public class StoreBrandDTO implements Serializable { ...@@ -153,6 +164,27 @@ public class StoreBrandDTO implements Serializable {
this.type = type; this.type = type;
} }
public Integer getOwnerFlag() {
if (type != null && type == 2) {
return 0;
}
return 1;
}
public StoreBrandDTO setOwnerFlag(Integer ownerFlag) {
this.ownerFlag = ownerFlag;
return this;
}
public String getOwnerEntName() {
return ownerEntName;
}
public StoreBrandDTO setOwnerEntName(String ownerEntName) {
this.ownerEntName = ownerEntName;
return this;
}
@Override @Override
public String toString() { public String toString() {
return "StoreBrandDTO{" + return "StoreBrandDTO{" +
...@@ -168,6 +200,8 @@ public class StoreBrandDTO implements Serializable { ...@@ -168,6 +200,8 @@ public class StoreBrandDTO implements Serializable {
", seq=" + seq + ", seq=" + seq +
", hasRel=" + hasRel + ", hasRel=" + hasRel +
", type=" + type + ", type=" + type +
", ownerFlag=" + ownerFlag +
", ownerEntName='" + ownerEntName + '\'' +
'}'; '}';
} }
} }
...@@ -55,6 +55,17 @@ public class StoreRegionDTO implements Serializable { ...@@ -55,6 +55,17 @@ public class StoreRegionDTO implements Serializable {
private Integer ownType; private Integer ownType;
private String shareEnterpriseName; private String shareEnterpriseName;
/***********前端使用字段*********/
/**
* 共享标记 1:自有 0:共享
*/
private Integer ownerFlag;
/**
* 自有商户名称
*/
private String ownerEntName;
public Integer getRegionId() { public Integer getRegionId() {
return regionId; return regionId;
} }
...@@ -143,19 +154,43 @@ public class StoreRegionDTO implements Serializable { ...@@ -143,19 +154,43 @@ public class StoreRegionDTO implements Serializable {
this.erpFlag = erpFlag; this.erpFlag = erpFlag;
} }
public Integer getOwnerFlag() {
if (ownType != null && ownType == 1) {
return 0;
}
return 1;
}
public StoreRegionDTO setOwnerFlag(Integer ownerFlag) {
this.ownerFlag = ownerFlag;
return this;
}
public String getOwnerEntName() {
return shareEnterpriseName;
}
public StoreRegionDTO setOwnerEntName(String ownerEntName) {
this.ownerEntName = ownerEntName;
return this;
}
@Override @Override
public String toString() { public String toString() {
return "StoreRegionDTO{" + return "StoreRegionDTO{" +
"regionId=" + regionId + "regionId=" + regionId +
", regionCode='" + regionCode + '\'' + ", regionCode='" + regionCode + '\'' +
", regionName='" + regionName + '\'' + ", regionName='" + regionName + '\'' +
", status=" + deleteFlag + ", erpFlag=" + erpFlag +
", deleteFlag=" + deleteFlag +
", createTime=" + createTime + ", createTime=" + createTime +
", updateTime=" + updateTime + ", updateTime=" + updateTime +
", enterpriseId=" + enterpriseId + ", enterpriseId=" + enterpriseId +
", fromEnterpriseId=" + fromEnterpriseId + ", fromEnterpriseId=" + fromEnterpriseId +
", ownType=" + ownType + ", ownType=" + ownType +
", shareEnterpriseName='" + shareEnterpriseName + '\'' + ", shareEnterpriseName='" + shareEnterpriseName + '\'' +
", ownerFlag=" + ownerFlag +
", ownerEntName='" + ownerEntName + '\'' +
'}'; '}';
} }
} }
package com.gic.store.dto.union;
import java.io.Serializable;
/**
* 店招品牌
* @ClassName:
* @Description: 

* @author guojuxing

* @date 2021/6/24 3:47 PM

*/
public class StoreBrandShareDTO implements Serializable{
private static final long serialVersionUID = 7242053220313579132L;
/***********前端使用字段*********/
/**
* 共享标记 1:自有 0:共享
*/
private Integer ownerFlag;
/**
* 自有商户名称
*/
private String ownerEntName;
private Integer storeBrandId;
public Integer getOwnerFlag() {
return ownerFlag;
}
public StoreBrandShareDTO setOwnerFlag(Integer ownerFlag) {
this.ownerFlag = ownerFlag;
return this;
}
public String getOwnerEntName() {
return ownerEntName;
}
public StoreBrandShareDTO setOwnerEntName(String ownerEntName) {
this.ownerEntName = ownerEntName;
return this;
}
public Integer getStoreBrandId() {
return storeBrandId;
}
public StoreBrandShareDTO setStoreBrandId(Integer storeBrandId) {
this.storeBrandId = storeBrandId;
return this;
}
@Override
public String toString() {
return "StoreBrandShareDTO{" +
"ownerFlag=" + ownerFlag +
", ownerEntName='" + ownerEntName + '\'' +
", storeBrandId=" + storeBrandId +
'}';
}
}
...@@ -3,8 +3,10 @@ package com.gic.store.service; ...@@ -3,8 +3,10 @@ package com.gic.store.service;
import com.gic.api.base.commons.Page; import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse; import com.gic.api.base.commons.ServiceResponse;
import com.gic.store.dto.StoreBrandDTO; import com.gic.store.dto.StoreBrandDTO;
import com.gic.store.dto.union.StoreBrandShareDTO;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @ClassName: StoreBrandApiService * @ClassName: StoreBrandApiService
...@@ -50,6 +52,13 @@ public interface StoreBrandApiService { ...@@ -50,6 +52,13 @@ public interface StoreBrandApiService {
* @throws * @throws
*/ */
ServiceResponse<List<StoreBrandDTO>> listAllStoreBrand(Integer enterpriseId, String search); ServiceResponse<List<StoreBrandDTO>> listAllStoreBrand(Integer enterpriseId, String search);
/**
* 获取品牌自有商户信息
* @param storeBrandList
* @return
*/
ServiceResponse<Map<Integer, StoreBrandShareDTO>> getStoreBrandShareEnterprise(List<StoreBrandDTO> storeBrandList);
/** /**
* 删除全部 * 删除全部
......
...@@ -7,11 +7,14 @@ import com.gic.commons.util.EntityUtil; ...@@ -7,11 +7,14 @@ import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.GlobalInfo; import com.gic.commons.util.GlobalInfo;
import com.gic.commons.util.PageHelperUtils; import com.gic.commons.util.PageHelperUtils;
import com.gic.enterprise.constants.Constants; import com.gic.enterprise.constants.Constants;
import com.gic.enterprise.dto.EnterpriseDTO;
import com.gic.enterprise.error.ErrorCode; import com.gic.enterprise.error.ErrorCode;
import com.gic.enterprise.response.EnterpriseServiceResponse; import com.gic.enterprise.response.EnterpriseServiceResponse;
import com.gic.enterprise.service.EnterpriseApiService;
import com.gic.enterprise.service.EnterpriseInitApiService; import com.gic.enterprise.service.EnterpriseInitApiService;
import com.gic.enterprise.service.PlatformBrandApiService; import com.gic.enterprise.service.PlatformBrandApiService;
import com.gic.store.dto.StoreBrandDTO; import com.gic.store.dto.StoreBrandDTO;
import com.gic.store.dto.union.StoreBrandShareDTO;
import com.gic.store.entity.TabStoreBrand; import com.gic.store.entity.TabStoreBrand;
import com.gic.store.service.StoreBrandApiService; import com.gic.store.service.StoreBrandApiService;
import com.gic.store.service.StoreBrandService; import com.gic.store.service.StoreBrandService;
...@@ -24,8 +27,7 @@ import org.apache.logging.log4j.Logger; ...@@ -24,8 +27,7 @@ import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
...@@ -47,6 +49,8 @@ public class StoreBrandApiServiceImpl implements StoreBrandApiService { ...@@ -47,6 +49,8 @@ public class StoreBrandApiServiceImpl implements StoreBrandApiService {
private PlatformBrandApiService platformBrandApiService; private PlatformBrandApiService platformBrandApiService;
@Autowired @Autowired
private EnterpriseInitApiService enterpriseInitApiService; private EnterpriseInitApiService enterpriseInitApiService;
@Autowired
private EnterpriseApiService enterpriseApiService;
@Override @Override
...@@ -81,8 +85,16 @@ public class StoreBrandApiServiceImpl implements StoreBrandApiService { ...@@ -81,8 +85,16 @@ public class StoreBrandApiServiceImpl implements StoreBrandApiService {
Page<StoreBrandDTO> page = PageHelperUtils.changePageHelperToCurrentPage(storeBrandList, StoreBrandDTO.class); Page<StoreBrandDTO> page = PageHelperUtils.changePageHelperToCurrentPage(storeBrandList, StoreBrandDTO.class);
List<StoreBrandDTO> resultList = page.getResult(); List<StoreBrandDTO> resultList = page.getResult();
int index = (pageNum - 1) * pageSize + 1; int index = (pageNum - 1) * pageSize + 1;
Map<Integer, StoreBrandShareDTO> storeBrandShareDTOMap = getStoreBrandShareEnterprise(resultList).getResult();
for (int i = 0; i < resultList.size(); i++) { for (int i = 0; i < resultList.size(); i++) {
resultList.get(i).setSeq(index + i); StoreBrandDTO storeBrandDTO = resultList.get(i);
StoreBrandShareDTO temp = storeBrandShareDTOMap.get(storeBrandDTO.getStoreBrandId());
if (temp != null) {
storeBrandDTO.setOwnerFlag(temp.getOwnerFlag());
storeBrandDTO.setOwnerEntName(temp.getOwnerEntName());
}
storeBrandDTO.setSeq(index + i);
} }
return ServiceResponse.success(page); return ServiceResponse.success(page);
} }
...@@ -95,6 +107,60 @@ public class StoreBrandApiServiceImpl implements StoreBrandApiService { ...@@ -95,6 +107,60 @@ public class StoreBrandApiServiceImpl implements StoreBrandApiService {
} }
@Override @Override
public ServiceResponse<Map<Integer, StoreBrandShareDTO>> getStoreBrandShareEnterprise(List<StoreBrandDTO> storeBrandList) {
List<StoreBrandShareDTO> voList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(storeBrandList)) {
//共享类型
List<Integer> brandIdList = storeBrandList.stream().filter(e -> Objects.equals(e.getType(), 2))
.mapToInt(e -> e.getStoreBrandId())
.boxed()
.collect(Collectors.toList());
Map<Integer, String> enterpriseMap = new HashMap<>();
Map<Integer, Integer> brandIdMap = new HashMap<>();
ServiceResponse<List<StoreBrandDTO>> brandResponse = listAllStoreBrandInfoByIds(brandIdList);
if (brandResponse.isSuccess() && CollectionUtils.isNotEmpty(brandResponse.getResult())) {
List<StoreBrandDTO> brandList = brandResponse.getResult();
//自有品牌的商户ID
List<Integer> enterpriseIdList = brandList.stream()
.filter(e -> Objects.equals(e.getType(), 1))
.mapToInt(e -> e.getEnterpriseId()).boxed()
.collect(Collectors.toList());
//自有品牌
brandIdMap = brandList.stream().filter(e -> Objects.equals(e.getType(), 1))
.collect(Collectors.toMap(e -> e.getStoreBrandId(), e -> e.getEnterpriseId()));
ServiceResponse<List<EnterpriseDTO>> enterpriseResponse = enterpriseApiService.listEnterpriseByIds(enterpriseIdList);
if (enterpriseResponse.isSuccess()) {
enterpriseMap = enterpriseResponse.getResult().stream().collect(Collectors.toMap(e -> e.getEnterpriseId(), e -> e.getEnterpriseName()));
}
}
Map<Integer, String> finalEnterpriseMap = enterpriseMap;
Map<Integer, Integer> finalBrandIdMap = brandIdMap;
voList = storeBrandList.stream()
.map(e -> {
StoreBrandShareDTO vo = new StoreBrandShareDTO();
vo.setStoreBrandId(e.getStoreBrandId());
//共享类型
if (Objects.equals(e.getType(), 2)) {
Integer tempEnterpriseId = finalBrandIdMap.get(e.getStoreBrandId());
vo.setOwnerEntName(finalEnterpriseMap.get(tempEnterpriseId));
vo.setOwnerFlag(0);
} else {
//自有
vo.setOwnerFlag(1);
}
return vo;
})
.collect(Collectors.toList());
return ServiceResponse.success(voList.stream().collect(Collectors.toMap(StoreBrandShareDTO::getStoreBrandId, e -> e)));
}
return ServiceResponse.success(new HashMap<>(2));
}
@Override
public ServiceResponse deleteAll(Integer enterpriseId) { public ServiceResponse deleteAll(Integer enterpriseId) {
List<TabStoreBrand> storeBrandList = storeBrandService.listAllStoreBrand(enterpriseId, null); List<TabStoreBrand> storeBrandList = storeBrandService.listAllStoreBrand(enterpriseId, null);
if (CollectionUtils.isEmpty(storeBrandList)) { if (CollectionUtils.isEmpty(storeBrandList)) {
......
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