合代码

This commit is contained in:
shuo.wang
2025-05-14 10:02:43 +08:00
parent 176e403813
commit 11de076ba2
2 changed files with 55 additions and 43 deletions

View File

@@ -21,7 +21,7 @@ public class FranchiseReportResponse {
private String regionName;
@ApiModelProperty(value = "门店数")
private Integer storeNum;
private Integer storeNum = 0;
@ApiModelProperty(value = "鸡排普通店")
private Integer normalStoreNum = 0;

View File

@@ -22,6 +22,7 @@ import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
@@ -43,48 +44,59 @@ public class FranchiseReportServiceImpl implements FranchiseReportService {
@Override
public List<FranchiseReportResponse> getFranchiseReport(FranchiseReportRequest request) {
if (StringUtils.isBlank(request.getBuildStartTime()) || StringUtils.isBlank(request.getBuildEndTime())) {
throw new ServiceException(ErrorCodeEnum.TIME_NULL_FALSE);
}
//集团查大区
List<Long> regionIdByGroupName = bigRegionDAO.getRegionIdByGroupName(request.getJoinGroupName());
if (CollectionUtils.isNotEmpty(regionIdByGroupName)) {
request.getRegionIds().addAll(regionIdByGroupName);
}
List<FranchiseReportDTO> shopFranchiseReportList = shopInfoDAO.getShopFranchiseReportList(request);
if (CollectionUtils.isEmpty(shopFranchiseReportList)) {
log.info("查询门店数据为空");
return null;
}
List<FranchiseReportResponse> responseList = new ArrayList<>();
List<Long> shopIds = shopFranchiseReportList.stream().map(FranchiseReportDTO::getShopId).collect(Collectors.toList());
Set<Long> regionSet = shopFranchiseReportList.stream().map(FranchiseReportDTO::getRegionId).collect(Collectors.toSet());
Map<Long, List<FranchiseReportDTO>> shopByRegionMap = shopFranchiseReportList.stream().collect(Collectors.groupingBy(FranchiseReportDTO::getRegionId));
//加盟费账单
List<FranchiseFeeDO> franchiseFeeList = franchiseFeeMapper.getFranchiseFeeByShopIds(shopIds);
Map<Long, FranchiseFeeDO> franchiseFeeMap = franchiseFeeList.stream().collect(Collectors.toMap(FranchiseFeeDO::getShopId, franchiseFeeDO -> franchiseFeeDO));
List<BigRegionDO> bigRegionDOList = bigRegionDAO.getByRegionIdList(new ArrayList<>(regionSet));
Map<Long, BigRegionDO> bigRegionDOMap = bigRegionDOList.stream().collect(Collectors.toMap(BigRegionDO::getRegionId, bigRegionDO -> bigRegionDO));
Map<Long, FranchiseReportResponse> responseByRegionIdMap = new HashMap<>();
for (FranchiseReportDTO shopFranchiseReportDTO : shopFranchiseReportList) {
FranchiseReportResponse response = responseByRegionIdMap.get(shopFranchiseReportDTO.getRegionId());
if (response == null){
response = new FranchiseReportResponse();
}
if (StoreTypeEnum.NO_SHOW_STORE.getCode().equals(shopFranchiseReportDTO.getStoreType())){
response.setNoShowStoreNum(response.getNoShowStoreNum() + 1);
}else if (StoreTypeEnum.ORDINARY_STORE.getCode().equals(shopFranchiseReportDTO.getStoreType())){
response.setNormalStoreNum(response.getNormalStoreNum() + 1);
}else if (StoreTypeEnum.RESTAURANT_STORE.getCode().equals(shopFranchiseReportDTO.getStoreType())){
response.setRestaurantStoreNum(response.getRestaurantStoreNum() + 1);
}
FranchiseFeeDO franchiseFeeDO = franchiseFeeMap.get(shopFranchiseReportDTO.getShopId());
if (franchiseFeeDO != null){
// response.setFranchiseFeeTotal(response.getFranchiseFeeTotal().add(franchiseFeeDO.getYearFranchiseFee()));
}
}
// if (StringUtils.isBlank(request.getBuildStartTime()) || StringUtils.isBlank(request.getBuildEndTime())) {
// throw new ServiceException(ErrorCodeEnum.TIME_NULL_FALSE);
// }
// //集团查大区
// List<Long> regionIdByGroupName = bigRegionDAO.getRegionIdByGroupName(request.getJoinGroupName());
// if (CollectionUtils.isNotEmpty(regionIdByGroupName)) {
// request.getRegionIds().addAll(regionIdByGroupName);
// }
// List<FranchiseReportDTO> shopFranchiseReportList = shopInfoDAO.getShopFranchiseReportList(request);
// if (CollectionUtils.isEmpty(shopFranchiseReportList)) {
// log.info("查询门店数据为空");
// return null;
// }
// List<FranchiseReportResponse> responseList = new ArrayList<>();
// List<Long> shopIds = shopFranchiseReportList.stream().map(FranchiseReportDTO::getShopId).collect(Collectors.toList());
// Set<Long> regionSet = shopFranchiseReportList.stream().map(FranchiseReportDTO::getRegionId).collect(Collectors.toSet());
// Map<Long, List<FranchiseReportDTO>> shopByRegionMap = shopFranchiseReportList.stream().collect(Collectors.groupingBy(FranchiseReportDTO::getRegionId));
// //加盟费账单
// List<FranchiseFeeDO> franchiseFeeList = franchiseFeeMapper.getFranchiseFeeByShopIds(shopIds);
// Map<Long, FranchiseFeeDO> franchiseFeeMap = franchiseFeeList.stream().collect(Collectors.toMap(FranchiseFeeDO::getShopId, franchiseFeeDO -> franchiseFeeDO));
// List<BigRegionDO> bigRegionDOList = bigRegionDAO.getByRegionIdList(new ArrayList<>(regionSet));
// Map<Long, BigRegionDO> bigRegionDOMap = bigRegionDOList.stream().collect(Collectors.toMap(BigRegionDO::getRegionId, bigRegionDO -> bigRegionDO));
// Map<Long, FranchiseReportResponse> responseByRegionIdMap = new HashMap<>();
//
// for (FranchiseReportDTO shopFranchiseReportDTO : shopFranchiseReportList) {
// FranchiseReportResponse response = responseByRegionIdMap.get(shopFranchiseReportDTO.getRegionId());
// if (response == null){
// response = new FranchiseReportResponse();
// }
// if (StoreTypeEnum.NO_SHOW_STORE.getCode().equals(shopFranchiseReportDTO.getStoreType())){
// response.setNoShowStoreNum(response.getNoShowStoreNum() + 1);
// }else if (StoreTypeEnum.ORDINARY_STORE.getCode().equals(shopFranchiseReportDTO.getStoreType())){
// response.setNormalStoreNum(response.getNormalStoreNum() + 1);
// }else if (StoreTypeEnum.RESTAURANT_STORE.getCode().equals(shopFranchiseReportDTO.getStoreType())){
// response.setRestaurantStoreNum(response.getRestaurantStoreNum() + 1);
// }
// response.setStoreNum(response.getStoreNum() + 1);
// FranchiseFeeDO franchiseFeeDO = franchiseFeeMap.get(shopFranchiseReportDTO.getShopId());
// if (franchiseFeeDO != null){
// response.setFranchiseFeeTotal(response.getFranchiseFeeTotal().add(new BigDecimal(franchiseFeeDO.getYearFranchiseFee())));
// response.setLoanMarginTotal(response.getLoanMarginTotal().add(new BigDecimal(franchiseFeeDO.getLoanMargin())));
// response.setFirstYearManagementFeeTotal(response.getFirstYearManagementFeeTotal().add(new BigDecimal(franchiseFeeDO.getFirstYearManageFee())));
// response.setFirstYearBrandingFeeTotal(response.getFirstYearBrandingFeeTotal().add(new BigDecimal(franchiseFeeDO.getFirstYearFee())));
// response.setPerformanceBondTotal(response.getPerformanceBondTotal().add(new BigDecimal(franchiseFeeDO.getPerformanceBond())));
// response.setManagementBrandingDesignFeeTotal(response.getManagementBrandingDesignFeeTotal()
// .add(new BigDecimal(franchiseFeeDO.getYearFranchiseFee()))
// .add(new BigDecimal(franchiseFeeDO.getFirstYearManageFee()))
// .add(new BigDecimal(franchiseFeeDO.getFirstYearFee()))
// .add(new BigDecimal(franchiseFeeDO.getPerformanceBond())));
// }
// responseByRegionIdMap.put(shopFranchiseReportDTO.getRegionId(), response);
// }
//
return null;
}
}