门店明细表

This commit is contained in:
shuo.wang
2025-06-05 15:07:05 +08:00
parent 81083972ca
commit 0d389a9e89
8 changed files with 226 additions and 7 deletions

View File

@@ -11,7 +11,7 @@ public enum JoinModeEnum {
FRANCHISE_COMPANIES(2,"加盟公司加盟店"),
OWN_STORE(3,"加盟公司自有店"),
STRONG_FRANCHISE(4,"强加盟"),
DIRECT_SALES_TO_JOINING(5,"直营转加盟")
DIRECT_SALES_TO_JOINING(5,"老店转加盟")
;
private int code;
private String desc;

View File

@@ -486,9 +486,16 @@
</select>
<select id="getShopFranchiseReportList" resultType="com.cool.store.dto.FranchiseReportDTO">
select
a.id as shopId,
a.region_id as regionId,
a.store_type as storeType
a.store_type as storeType,
a.shop_code as shopCode,
a.investment_manager as investmentManager,
a.shop_name as shopName,
a.join_mode as joinMode,
a.franchise_brand as franchiseBrand,
b.actual_complete_time as actualCompleteTime
from xfsg_shop_info a
left join xfsg_shop_stage_info b on a.id = b.shop_id
where

View File

@@ -16,4 +16,11 @@ public class FranchiseReportDTO {
private Long regionId;
private Integer storeType;
private String actualCompleteTime;
private String franchiseBrand;
private String investmentManager;
private Integer joinMode;
private String shopCode;
private String shopName;
}

View File

@@ -30,4 +30,7 @@ public class FranchiseReportRequest {
@ApiModelProperty(value = "建店完成结束时间 时间格式 2025-05-01 23:59:59")
private String buildEndTime;
private Integer pageNum=1;
private Integer pageSize=10;
}

View File

@@ -0,0 +1,107 @@
package com.cool.store.response;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
/**
* @Author: WangShuo
* @Date: 2025/06/05/11:03
* @Version 1.0
* @注释:
*/
@Data
public class ShopReportResponse {
@ApiModelProperty(value = "建店完成日期")
@ExcelProperty(value = "日期",order = 1)
@ColumnWidth(25)
private String buildTime;
@ApiModelProperty(value = "加盟品牌")
@ExcelProperty(value = "加盟品牌",order = 2)
@ColumnWidth(25)
private String franchiseBrand;
@ApiModelProperty(value = "所属加盟集团")
@ExcelProperty(value = "所属加盟集团",order = 3)
@ColumnWidth(25)
private String joinGroupName;
@ApiModelProperty(value = "所属大区")
@ExcelProperty(value = "所属大区",order = 4)
@ColumnWidth(20)
private String regionName;
@ApiModelProperty(value = "督导")
@ExcelProperty(value = "督导",order = 5)
@ColumnWidth(15)
private String investmentManagerName ;
@ApiModelProperty(value = "加盟模式")
@ExcelProperty(value = "加盟模式",order = 6)
@ColumnWidth(15)
private String joinMode ;
@ApiModelProperty(value = "门店编码")
@ExcelProperty(value = "门店编码",order = 7)
@ColumnWidth(15)
private String shopCode ;
@ApiModelProperty(value = "门店名称")
@ExcelProperty(value = "门店名称",order = 8)
@ColumnWidth(15)
private String shopName ;
@ApiModelProperty(value = "门店类型")
@ExcelProperty(value = "门店类型",order = 9)
@ColumnWidth(15)
private String storeType ;
@ApiModelProperty(value = "加盟费")
@ExcelProperty(value = "加盟费",order = 10)
@ColumnWidth(20)
private BigDecimal franchiseFee = BigDecimal.ZERO;
@ApiModelProperty(value = "品牌费")
@ExcelProperty(value = "品牌费",order = 11)
@ColumnWidth(20)
private BigDecimal firstYearBrandingFee = BigDecimal.ZERO;
@ApiModelProperty(value = "管理费")
@ExcelProperty(value = "管理费",order = 12)
@ColumnWidth(20)
private BigDecimal firstYearManagementFee = BigDecimal.ZERO;
@ApiModelProperty(value = "设计费")
@ExcelProperty(value = "设计费",order = 13)
@ColumnWidth(20)
private BigDecimal performanceBond = BigDecimal.ZERO;
@ApiModelProperty(value = "管理/品牌/设计费")
@ExcelProperty(value = "管理/品牌/设计费",order = 14)
@ColumnWidth(25)
private BigDecimal managementBrandingDesignFeeTotal = BigDecimal.ZERO;
@ApiModelProperty(value = "保证金")
@ExcelProperty(value = "保证金",order = 15)
@ColumnWidth(20)
private BigDecimal loanMargin = BigDecimal.ZERO;
@ApiModelProperty(value = "收款金额总计")
@ExcelProperty(value = "收款金额总计=加盟费+管理/品牌/设计费+保证金",order = 16)
@ColumnWidth(25)
private BigDecimal total = BigDecimal.ZERO;
//集团维度使用
@ExcelIgnore
private Long regionId;
}

View File

@@ -2,6 +2,7 @@ package com.cool.store.service;
import com.cool.store.request.FranchiseReportRequest;
import com.cool.store.response.FranchiseReportResponse;
import com.cool.store.response.ShopReportResponse;
import com.github.pagehelper.PageInfo;
import java.util.List;
@@ -15,4 +16,6 @@ import java.util.List;
public interface FranchiseReportService {
List<FranchiseReportResponse> zxjpOpenShopReport(FranchiseReportRequest request);
//门店维度
PageInfo<ShopReportResponse> zxjpOpenShopReportPage(FranchiseReportRequest request);
}

View File

@@ -1,19 +1,21 @@
package com.cool.store.service.impl;
import com.cool.store.dao.BigRegionDAO;
import com.cool.store.dao.FranchiseFeeDAO;
import com.cool.store.dao.ShopInfoDAO;
import com.cool.store.dao.*;
import com.cool.store.dto.FranchiseReportDTO;
import com.cool.store.entity.BigRegionDO;
import com.cool.store.entity.FranchiseFeeDO;
import com.cool.store.enums.ErrorCodeEnum;
import com.cool.store.enums.FranchiseBrandEnum;
import com.cool.store.enums.JoinModeEnum;
import com.cool.store.enums.StoreTypeEnum;
import com.cool.store.exception.ServiceException;
import com.cool.store.mapper.FranchiseFeeMapper;
import com.cool.store.request.FranchiseReportRequest;
import com.cool.store.response.FranchiseReportResponse;
import com.cool.store.response.ShopReportResponse;
import com.cool.store.service.FranchiseReportService;
import com.cool.store.utils.poi.StringUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import groovy.util.logging.Log4j;
import io.swagger.annotations.ApiModelProperty;
@@ -39,12 +41,16 @@ import java.util.stream.Collectors;
@Slf4j
@Service
public class FranchiseReportServiceImpl implements FranchiseReportService {
@Resource
private EnterpriseUserDAO enterpriseUserDAO;
@Resource
private BigRegionDAO bigRegionDAO;
@Resource
private ShopInfoDAO shopInfoDAO;
@Resource
private FranchiseFeeMapper franchiseFeeMapper;
@Resource
private RegionDao regionDao;
@Override
public List<FranchiseReportResponse> zxjpOpenShopReport(FranchiseReportRequest request) {
@@ -190,6 +196,84 @@ public class FranchiseReportServiceImpl implements FranchiseReportService {
return list;
}
@Override
public PageInfo<ShopReportResponse> zxjpOpenShopReportPage(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)) {
if (CollectionUtils.isEmpty(request.getRegionIds())) {
request.setRegionIds(regionIdByGroupName);
} else {
request.getRegionIds().retainAll(regionIdByGroupName);
if (CollectionUtils.isEmpty(request.getRegionIds())) {
throw new ServiceException(ErrorCodeEnum.REGION_INTERSECTION_IS_NULL);
}
}
}
PageHelper.startPage(request.getPageNum(), request.getPageSize());
List<FranchiseReportDTO> shopFranchiseReportList = shopInfoDAO.getShopFranchiseReportList(request);
if (CollectionUtils.isEmpty(shopFranchiseReportList)) {
log.info("查询门店数据为空");
return null;
}
List<Long> shopIds = shopFranchiseReportList.stream().map(FranchiseReportDTO::getShopId).collect(Collectors.toList());
Set<Long> regionSet = shopFranchiseReportList.stream().map(FranchiseReportDTO::getRegionId).collect(Collectors.toSet());
Set<String> investmentManagerUsers = shopFranchiseReportList.stream().map(FranchiseReportDTO::getInvestmentManager).collect(Collectors.toSet());
Map<String, String> userNameMap = enterpriseUserDAO.getUserNameMap(new ArrayList<>(investmentManagerUsers));
//加盟费账单
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, String> regionNameMap = regionDao.getRegionNameMap(new ArrayList<>(regionSet));
List<ShopReportResponse> list = new ArrayList<>();
for (FranchiseReportDTO shopFranchiseReportDTO : shopFranchiseReportList) {
BigRegionDO bigRegionDO = bigRegionDOMap.getOrDefault(shopFranchiseReportDTO.getRegionId(), new BigRegionDO());
String regionName = regionNameMap.getOrDefault(shopFranchiseReportDTO.getRegionId(), "");
ShopReportResponse response = new ShopReportResponse();
response.setRegionId(shopFranchiseReportDTO.getRegionId());
response.setRegionName(regionName);
String groupName = bigRegionDO.getGroupName();
if (StringUtils.isBlank(groupName)) {
response.setJoinGroupName("-");
} else {
response.setJoinGroupName(groupName);
}
response.setBuildTime(shopFranchiseReportDTO.getActualCompleteTime());
response.setShopCode(shopFranchiseReportDTO.getShopCode());
response.setShopName(shopFranchiseReportDTO.getShopName());
response.setStoreType(StoreTypeEnum.getMessage(shopFranchiseReportDTO.getStoreType()));
response.setJoinMode(JoinModeEnum.getByCode(shopFranchiseReportDTO.getJoinMode()));
response.setFranchiseBrand(FranchiseBrandEnum.getDescByCode(shopFranchiseReportDTO.getFranchiseBrand()));
response.setInvestmentManagerName(userNameMap.getOrDefault(shopFranchiseReportDTO.getInvestmentManager(), ""));
FranchiseFeeDO franchiseFeeDO = franchiseFeeMap.get(shopFranchiseReportDTO.getShopId());
if (franchiseFeeDO != null) {
response.setFranchiseFee(response.getFranchiseFee().add(new BigDecimal(franchiseFeeDO.getYearFranchiseFee())));
response.setLoanMargin(response.getLoanMargin().add(new BigDecimal(franchiseFeeDO.getLoanMargin())));
response.setFirstYearManagementFee(response.getFirstYearManagementFee().add(new BigDecimal(franchiseFeeDO.getFirstYearManageFee())));
response.setFirstYearBrandingFee(response.getFirstYearBrandingFee().add(new BigDecimal(franchiseFeeDO.getFirstYearFee())));
response.setPerformanceBond(response.getPerformanceBond().add(new BigDecimal(franchiseFeeDO.getPerformanceBond())));
response.setManagementBrandingDesignFeeTotal(response.getManagementBrandingDesignFeeTotal()
.add(new BigDecimal(franchiseFeeDO.getFirstYearManageFee()))
.add(new BigDecimal(franchiseFeeDO.getFirstYearFee()))
.add(new BigDecimal(franchiseFeeDO.getPerformanceBond())));
response.setTotal(response.getTotal()
.add(response.getManagementBrandingDesignFeeTotal())
.add(response.getLoanMargin())
.add(response.getFranchiseFee()));
}
list.add(response);
}
if (CollectionUtils.isEmpty(list)) {
log.info("数据为空");
return null;
}
return new PageInfo<>(list.stream().sorted(Comparator.comparing(ShopReportResponse::getBuildTime).reversed()).collect(Collectors.toList()));
}
public static void sortByName(List<FranchiseReportResponse> list) {
list.sort(Comparator.comparingInt(f -> extractNumberFromName(f.getJoinGroupName())));
}

View File

@@ -4,7 +4,9 @@ import com.alibaba.fastjson.JSONObject;
import com.cool.store.request.FranchiseReportRequest;
import com.cool.store.response.FranchiseReportResponse;
import com.cool.store.response.ResponseResult;
import com.cool.store.response.ShopReportResponse;
import com.cool.store.service.FranchiseReportService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestBody;
@@ -32,4 +34,10 @@ public class PCFranchiseReportController {
public ResponseResult< List<FranchiseReportResponse>> getList(@RequestBody FranchiseReportRequest request) {
return ResponseResult.success( franchiseReportService.zxjpOpenShopReport(request));
}
@RequestMapping("/getZxjpOpenShopReportPage")
@ApiOperation("正新鸡排开店明细")
public ResponseResult<PageInfo<ShopReportResponse>> ZxjpOpenShopReportPage(@RequestBody FranchiseReportRequest request) {
return ResponseResult.success( franchiseReportService.zxjpOpenShopReportPage(request));
}
}