package com.cool.store.mapper;

import com.cool.store.dto.PlatformBuildStageDTO;
import com.cool.store.dto.Preparation.ScheduleDTO;
import com.cool.store.entity.ShopStageInfoDO;
import com.cool.store.enums.point.ShopSubStageEnum;
import com.cool.store.enums.point.ShopSubStageStatusEnum;
import com.cool.store.vo.Preparation.PreparationProcessVO;
import com.cool.store.vo.shop.RentInfoToDoVO;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface ShopStageInfoMapper extends Mapper<ShopStageInfoDO> {

    /**
     * 批量插入店铺阶段信息
     * @param addShopStageList
     * @return
     */
    Integer batchInsert(@Param("addShopStageList") List<ShopStageInfoDO> addShopStageList);

    /**
     * 批量修改
     * @param addShopStageList
     * @return
     */
    Integer batchUpdate(@Param("addShopStageList") List<ShopStageInfoDO> addShopStageList);

    /**
     * 获取店铺阶段信息
     * @param shopId
     * @param shopStage
     * @return
     */
    List<ShopStageInfoDO> getShopStageInfo(@Param("shopId") Long shopId, @Param("shopStage") Integer shopStage);

    PreparationProcessVO getPreparationProcess(@Param("shopId") Long shopId);

    /**
     * 查询结束阶段的数量
     * @param shopId
     * @return
     */
    Integer getAllCompletionCount(@Param("shopId") Long shopId);

                                           /**
                                            * 跟新店铺阶段信息
                                            * @param shopId
                                            * @param shopSubStage
                                            * @param shopSubStageStatus
                                            * @param isTerminated
                                            * @param remark
                                            * @return
                                            */
    Integer updateShopStageInfo(@Param("shopId") Long shopId, @Param("shopSubStage") Integer shopSubStage, @Param("shopSubStageStatus") Integer shopSubStageStatus,
                                @Param("isTerminated")boolean isTerminated, @Param("remark") String remark);

    /**
     * 批量更新阶段及审核信息
     * @param shopId
     * @param updateList
     * @return
     */
    Integer batchUpdateShopStageStatus(@Param("shopId") Long shopId, @Param("updateList") List<ShopStageInfoDO> updateList);

    /**
     * 更新阶段及审核信息
     * @param shopId
     * @param shopSubStage
     * @param shopSubStageStatus
     * @param isTerminated
     * @param remark
     * @param auditId
     * @return
     */
    Integer updateShopStageAndAuditInfo(@Param("shopId") Long shopId, @Param("shopSubStage") Integer shopSubStage, @Param("shopSubStageStatus") Integer shopSubStageStatus,
                                @Param("isTerminated")boolean isTerminated, @Param("remark") String remark, @Param("auditId")Long auditId);

    /**
     * 获取子阶段信息
     * @param shopId
     * @param shopSubStage
     * @return
     */
    ShopStageInfoDO getShopSubStageInfo(@Param("shopId") Long shopId, @Param("shopSubStage") Integer shopSubStage);
    /**
     * @Auther: wangshuo
     * @Date: 2024/5/3
     * @description:更新完成时间byshopId
     */
    Integer updateByShopId(@Param("shopStageInfoDO") ShopStageInfoDO shopStageInfoDO);
    /**
     * 更新阶段到未开始状态
     * @param shopId
     * @param shopSubStage
     * @return
     */
    Integer updateShopStageToNotStarted(@Param("shopId") Long shopId, @Param("shopSubStage") Integer shopSubStage);

    /**
     * 获取租赁合同待办列表
     * @param userId
     * @return
     */
    Page<RentInfoToDoVO> getRentContractToDoPage(@Param("userId") String userId, @Param("shopSubStage")Integer shopSubStage, @Param("shopSubStageStatus") Integer shopSubStageStatus);

    List<ShopStageInfoDO> getShopIdListByStageStatus(@Param("shopSubStageStatus") Integer shopSubStageStatus);

    List<ScheduleDTO> getScheduleList(@Param("shopIds") List<Long> shopIds);
    List<ScheduleDTO> getPlatformBuildList(@Param("shopIds") List<Long> shopIds);

    List<ShopStageInfoDO> getShopContractActualCompletionTime(@Param("shopIds") List<Long> shopIds);

    /**
     * 获取可以上传租赁合同的店铺id
     * @param shopIds
     * @return
     */
    List<Long> getCanSubmitRentContractShopIds(@Param("shopIds") List<Long> shopIds);
    /**
     * @Auther: wangshuo
     * @Date: 2024/5/5
     * @description:获取施工阶段未完成的店铺
     */
    List<Long> getShopContractIncompletion();

    Integer batchUpdateStatus(@Param("shopIdList") List<Long> shopIdList,@Param("shopSubStageEnum") Integer shopSubStageEnum,@Param("shopSubStageStatusEnum") Integer shopSubStageStatusEnum) ;

    List<ShopStageInfoDO> getSpecialShopStageInfo(@Param("shopIds") List<Long> shopIds,
                                                  @Param("shopSubStage") Integer shopSubStage,
                                                  @Param("shopSubStageStatusList") List<Integer> shopSubStageStatusList,
                                                  @Param("investmentUserId") String investmentUserId, @Param("authRegionIds") List<String> authRegionIds);
    List<ShopStageInfoDO> getSubStageList(@Param("shopIds") List<Long> shopIds,@Param("shopSubStage") Integer shopSubStage);
    List<ShopStageInfoDO> getSubStages(@Param("shopIds") List<Long> shopIds,@Param("shopSubStage") Integer shopSubStage);

    /**
     * 获取线索处在某个阶段的某个状态的店铺数量
     * @param lineId
     * @return
     */
    Integer getShopCountByLineIdAndStageStatus(@Param("lineId")Long lineId, @Param("shopStage") Integer shopStage, @Param("shopSubStage") Integer shopSubStage, @Param("shopSubStageStatus") Integer shopSubStageStatus);
    /**
     * @Auther: wangshuo
     * @Date: 2024/5/11
     * @description:获取处于a阶段或b阶段，和c阶段的
     */
    List<ShopStageInfoDO> getSubStageListBySubStageStatus(@Param("subStageStatusA")Integer subStageStatusA,@Param("subStageStatusB")Integer subStageStatusB,@Param("subStageStatusC")Integer subStageStatusC );

    /**
     * 根据shopId和阶段查数据
     * @param shopId
     * @param shopSubStage
     * @return
     */
    ShopStageInfoDO getByShopIdAndSubStage(@Param("shopId") Long shopId,
                                           @Param("shopSubStage") Integer shopSubStage);

    List<PlatformBuildStageDTO> getPlatformBuildStage( @Param("shopIds") List<Long> shopIds);
}
