Merge branch 'cc_20250513_franchise_report' into cc_2250513_api

This commit is contained in:
shuo.wang
2025-05-14 10:03:04 +08:00
13 changed files with 339 additions and 12 deletions

View File

@@ -195,7 +195,7 @@ public enum ErrorCodeEnum {
AUDIT_RESULT_FALSE(109012, "意向加盟合同API本次调用结果与上一次不一致", null),
TIME_NULL_FALSE(109013, "有时间为空", null),
TIME_NULL_FALSE(109013, "完成时间不能为空", null),
UNISSUED_STATEMENT_2(109014, "该门店已发布账单", null),

View File

@@ -5,10 +5,13 @@ import com.cool.store.entity.BigRegionDO;
import com.cool.store.enums.ErrorCodeEnum;
import com.cool.store.exception.ServiceException;
import com.cool.store.mapper.BigRegionMapper;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.entity.Example;
import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Author suzhuhong
@@ -32,4 +35,25 @@ public class BigRegionDAO {
return bigRegionMapper.queryOrgInfoByBigRegionAndJoinMode(regionId,joinMode);
}
public List<Long> getRegionIdByGroupName(List<String> groupNameList){
if (CollectionUtils.isEmpty(groupNameList)){
return null;
}
Example example = new Example(BigRegionDO.class);
example.createCriteria().andIn("groupName", groupNameList);
List<BigRegionDO> bigRegionDOS = bigRegionMapper.selectByExample(example);
if (CollectionUtils.isEmpty(bigRegionDOS)){
return null;
}
return bigRegionDOS.stream().map(BigRegionDO::getRegionId).collect(Collectors.toList());
}
public List<BigRegionDO> getByRegionIdList(List<Long> regionIdList){
if (CollectionUtils.isEmpty(regionIdList)){
return null;
}
Example example = new Example(BigRegionDO.class);
example.createCriteria().andIn("regionId", regionIdList);
return bigRegionMapper.selectByExample(example);
}
}

View File

@@ -1,6 +1,7 @@
package com.cool.store.dao;
import com.cool.store.constants.CommonConstants;
import com.cool.store.dto.FranchiseReportDTO;
import com.cool.store.dto.LicenseSyncDTO;
import com.cool.store.dto.Preparation.PreparationDTO;
import com.cool.store.dto.openPreparation.OpenPlanShopInfoDTO;
@@ -12,11 +13,7 @@ import com.cool.store.enums.ErrorCodeEnum;
import com.cool.store.enums.point.ShopStatusEnum;
import com.cool.store.exception.ServiceException;
import com.cool.store.mapper.ShopInfoMapper;
import com.cool.store.request.BranchShopRequest;
import com.cool.store.request.PlanListRequest;
import com.cool.store.request.PointLinePageRequest;
import com.cool.store.request.PreparationRequest;
import com.cool.store.request.platformBuildListRequest;
import com.cool.store.request.*;
import com.cool.store.response.MiniShopsResponse;
import com.cool.store.response.PlatformBuildListResponse;
import com.cool.store.vo.shop.StageShopCountVO;
@@ -290,4 +287,8 @@ public class ShopInfoDAO {
example.createCriteria().andIn("shopCode", shopCodeList).andEqualTo("deleted", false);
return shopInfoMapper.selectByExample(example);
}
public List<FranchiseReportDTO> getShopFranchiseReportList(FranchiseReportRequest request){
return shopInfoMapper.getShopFranchiseReportList(request);
}
}

View File

@@ -1,5 +1,6 @@
package com.cool.store.mapper;
import com.cool.store.dto.FranchiseReportDTO;
import com.cool.store.dto.LicenseSyncDTO;
import com.cool.store.dto.Preparation.PreparationDTO;
import com.cool.store.dto.openPreparation.OpenPlanShopInfoDTO;
@@ -7,11 +8,7 @@ import com.cool.store.dto.point.LineCountDTO;
import com.cool.store.dto.point.ShopPointDTO;
import com.cool.store.entity.PointInfoDO;
import com.cool.store.entity.ShopInfoDO;
import com.cool.store.request.BranchShopRequest;
import com.cool.store.request.PlanListRequest;
import com.cool.store.request.PointLinePageRequest;
import com.cool.store.request.PreparationRequest;
import com.cool.store.request.platformBuildListRequest;
import com.cool.store.request.*;
import com.cool.store.response.MiniShopsResponse;
import com.cool.store.response.PlatformBuildListResponse;
import com.cool.store.vo.shop.StageShopCountVO;
@@ -114,7 +111,7 @@ public interface ShopInfoMapper extends Mapper<ShopInfoDO> {
/**
* selectAllDataOrByShopId
* @param shopId
* @param
* @return
*/
List<ShopInfoDO> selectAllDataOrByLineId(@Param("lineId") Long lineId);
@@ -141,4 +138,5 @@ public interface ShopInfoMapper extends Mapper<ShopInfoDO> {
Integer updateShopCity(@Param("list") List<ShopInfoDO> list);
List<FranchiseReportDTO> getShopFranchiseReportList(@Param("request") FranchiseReportRequest request);
}

View File

@@ -14,6 +14,7 @@
<result column="join_mode" jdbcType="TINYINT" property="joinMode" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="group_name" jdbcType="VARCHAR" property="groupName" />
</resultMap>

View File

@@ -482,6 +482,30 @@
a.create_time >= '2025-04-19 00:00:00'
and b.downstream_system_salting is null;
</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
from xfsg_shop_info a
left join xfsg_shop_stage_info b on a.id = b.shop_id
where
a.deleted = 0 and a.shop_status != 2 and a.franchise_brand = 1
and b.shop_sub_stage = 150 and b.is_terminated = 1
<if test = "request.regionIds !=null and request.regionIds.size >0">
and a.region_id in
<foreach collection="request.regionIds" item="regionId" index="index" open="(" separator="," close=")">
#{regionId}
</foreach>
</if>
<if test = "request.storeTypes !=null and request.storeTypes.size >0">
and a.store_type in
<foreach collection="request.storeTypes" item="storeType" index="index" open="(" separator="," close=")">
#{storeType}
</foreach>
</if>
and b.actual_completion_time >= #{request.buildStartTime} and b.actual_completion_time &lt;= #{request.buildEndTime}
</select>
<update id="batchUpdate" parameterType="list">
<foreach collection="list" item="item" index="index" open="" close="" separator=";">

View File

@@ -0,0 +1,19 @@
package com.cool.store.dto;
import lombok.Data;
/**
* @Author: WangShuo
* @Date: 2025/05/13/15:59
* @Version 1.0
* @注释:
*/
@Data
public class FranchiseReportDTO {
private Long shopId;
private Long regionId;
private Integer storeType;
}

View File

@@ -57,6 +57,17 @@ public class BigRegionDO {
@Column(name = "update_time")
private Date updateTime;
//集团名称
@Column(name = "group_name")
private String groupName;
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
/**
* @return id
*/

View File

@@ -0,0 +1,33 @@
package com.cool.store.request;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* @Author: WangShuo
* @Date: 2025/05/13/15:27
* @Version 1.0
* @注释:
*/
@Data
public class FranchiseReportRequest {
@ApiModelProperty(value = "加盟集团")
private List<String> joinGroupName;
@ApiModelProperty(value = "加盟分部/片区")
private List<Long> regionIds;
@ApiModelProperty(value = "门店类型")
private List<Integer> storeTypes;
@ApiModelProperty(value = "建店完成开始 时间格式 2025-05-01 00:00:00")
private String buildStartTime;
@ApiModelProperty(value = "建店完成结束时间 时间格式 2025-05-01 23:59:59")
private String buildEndTime;
}

View File

@@ -0,0 +1,62 @@
package com.cool.store.response;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
* @Author: WangShuo
* @Date: 2025/05/13/15:30
* @Version 1.0
* @注释:
*/
@Data
public class FranchiseReportResponse {
@ApiModelProperty(value = "加盟集团")
private String joinGroupName;
@ApiModelProperty(value = "加盟分部/片区")
private String regionName;
@ApiModelProperty(value = "门店数")
private Integer storeNum = 0;
@ApiModelProperty(value = "鸡排普通店")
private Integer normalStoreNum = 0;
@ApiModelProperty(value = "鸡排餐厅店")
private Integer restaurantStoreNum = 0;
@ApiModelProperty(value = "鸡排无展示门店")
private Integer noShowStoreNum = 0;
@ApiModelProperty(value = "加盟费")
private BigDecimal franchiseFeeTotal = BigDecimal.ZERO;
@ApiModelProperty(value = "品牌费")
private BigDecimal firstYearBrandingFeeTotal = BigDecimal.ZERO;
@ApiModelProperty(value = "管理费")
private BigDecimal firstYearManagementFeeTotal = BigDecimal.ZERO;
@ApiModelProperty(value = "设计费")
private BigDecimal performanceBondTotal = BigDecimal.ZERO;
@ApiModelProperty(value = "管理/品牌/设计费")
private BigDecimal managementBrandingDesignFeeTotal = BigDecimal.ZERO;
@ApiModelProperty(value = "保证金")
private BigDecimal loanMarginTotal = BigDecimal.ZERO;
@ApiModelProperty(value = "昨日日期")
private String yesterdayDate;
@ApiModelProperty(value = "昨天门店数")
private Integer yesterdayStoreNum = 0;
private Long regionId;
}

View File

@@ -0,0 +1,18 @@
package com.cool.store.service;
import com.cool.store.request.FranchiseReportRequest;
import com.cool.store.response.FranchiseReportResponse;
import com.github.pagehelper.PageInfo;
import java.util.List;
/**
* @Author: WangShuo
* @Date: 2025/05/13/15:22
* @Version 1.0
* @注释:
*/
public interface FranchiseReportService {
List<FranchiseReportResponse> getFranchiseReport(FranchiseReportRequest request);
}

View File

@@ -0,0 +1,102 @@
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.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.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.service.FranchiseReportService;
import com.cool.store.utils.poi.StringUtils;
import com.github.pagehelper.PageInfo;
import groovy.util.logging.Log4j;
import io.swagger.annotations.ApiModelProperty;
import lombok.extern.slf4j.Slf4j;
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;
/**
* @Author: WangShuo
* @Date: 2025/05/13/15:22
* @Version 1.0
* @注释:
*/
@Slf4j
@Service
public class FranchiseReportServiceImpl implements FranchiseReportService {
@Resource
private BigRegionDAO bigRegionDAO;
@Resource
private ShopInfoDAO shopInfoDAO;
@Resource
private FranchiseFeeMapper franchiseFeeMapper;
@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);
// }
// 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;
}
}

View File

@@ -0,0 +1,34 @@
package com.cool.store.controller.webb;
import com.cool.store.request.FranchiseReportRequest;
import com.cool.store.response.FranchiseReportResponse;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.FranchiseReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
/**
* @Author: WangShuo
* @Date: 2025/05/13/15:46
* @Version 1.0
* @注释:
*/
@RestController
@RequestMapping("/pc/franchiseReport")
@Api(tags = "PC端加盟报表")
public class PCFranchiseReportController {
@Resource
private FranchiseReportService franchiseReportService;
@RequestMapping("/getList")
@ApiOperation("正新鸡排开店")
public ResponseResult<List<FranchiseReportResponse>> getList(@RequestBody FranchiseReportRequest request) {
return ResponseResult.success( franchiseReportService.getFranchiseReport(request));
}
}