package com.bonus.canteen.core.account.v3.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bonus.canteen.core.account.v3.api.dto.AccCountDTO;
import com.bonus.canteen.core.account.v3.api.dto.AccStatisticsSumDTO;
import com.bonus.canteen.core.account.v3.api.vo.AccCardStatisticsVO;
import com.bonus.canteen.core.account.v3.api.vo.AccCountStatisticsVO;
import com.bonus.canteen.core.account.v3.api.vo.AccCountVO;
import com.bonus.canteen.core.account.v3.api.vo.AccInfoDetailVO;
import com.bonus.canteen.core.account.v3.app.dto.AppWorkAccInfoPageDTO;
import com.bonus.canteen.core.account.v3.app.vo.AppWorkAccInfoVO;
import com.bonus.canteen.core.account.v3.model.AccInfo;
import com.bonus.canteen.core.account.v3.mq.send.model.AccStatusChangeModel;
import com.bonus.canteen.core.account.v3.po.AccInfoOpenPO;
import com.bonus.canteen.core.account.v3.web.dto.AccExistFrozenPageDTO;
import com.bonus.canteen.core.account.v3.web.dto.AccInfoPageDTO;
import com.bonus.canteen.core.account.v3.web.vo.AccExistFrozenListVO;
import com.bonus.canteen.core.account.v3.web.vo.AccInfoPageVO;
import com.bonus.canteen.core.account.v3.web.vo.AccInfoVO;
import com.bonus.canteen.core.autth.config.LeNiuDataPermission;
import com.bonus.canteen.core.autth.enums.DataPermissionTypeEnum;
import com.bonus.canteen.core.autth.po.MgrUserAuthPO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface AccInfoMapper extends BaseMapper<AccInfo> {
   @LeNiuDataPermission(
           alias = "t2",
           permissionType = DataPermissionTypeEnum.PERMISSION_ORG
   )
   List<AccInfoPageVO> queryListAccInfo(@Param("infoParam") AccInfoPageDTO content);

   @LeNiuDataPermission(
           alias = "t2",
           permissionType = DataPermissionTypeEnum.PERMISSION_ORG
   )
   AccInfoPageVO queryPageAccInfoSum(@Param("infoParam") AccInfoPageDTO content);

   @LeNiuDataPermission(
           alias = "t2",
           permissionType = DataPermissionTypeEnum.PERMISSION_ORG
   )
   List<AccInfoPageVO> queryPageAccInfoForBatch(@Param("infoParam") AccInfoPageDTO accPageParam);

   @LeNiuDataPermission(
           alias = "t2",
           permissionType = DataPermissionTypeEnum.PERMISSION_ORG
   )
   List<Long> queryAccIdByParam(@Param("infoParam") AccInfoPageDTO accPageParam);

   Integer updateStateByOverdue(@Param("overdueDate") LocalDate overdueDate, @Param("changeStatus") Integer changeStatus, @Param("oldStatusList") List<Integer> oldStatusList);

   List<Long> listAccStateOverdue(@Param("overdueDate") LocalDate overdueDate, @Param("oldStatusList") List<Integer> oldStatusList);

   AccInfoVO getAccInfoVOByCustId(@Param("custId") Long custId);

   List<AccInfoVO> listAccInfoVOByCustIdList(@Param("custIdList") List<Long> custIdList);

   @LeNiuDataPermission(
           alias = "ci",
           permissionType = DataPermissionTypeEnum.PERMISSION_ORG
   )
   Page<AccExistFrozenListVO> queryFrozenAccPage(Page<?> page, @Param("infoParam") AccExistFrozenPageDTO pageDTO);

   Long getSumScopeByAccIdList(@Param("accIdList") List<Long> accIdList);

   List<AccInfoDetailVO> getAccInfoDetailVOV2();

   AccInfoOpenPO getAccInfoOpenPOByCustId(@Param("custId") Long custId);

   List<AccInfoOpenPO> queryPageAccInfoOpenPO(@Param("custIdList") List<Long> custIdList);

   List<AccInfoVO> queryAccStatusAndCard(@Param("custIdList") List<Long> custIdList);

   List<AccInfoVO> queryAccBaseInfoList(@Param("custIdList") List<Long> custIdList);

   List<AccStatusChangeModel> queryAccStatusByCustIdList(@Param("custIdList") List<Long> custIdList);

   AccCountVO accOpenCountStatistics(@Param("accCountParam") AccCountDTO accCountParam);

   AccCountVO accCloseCountStatistics(@Param("accCountParam") AccCountDTO accCountParam);

   AccCountStatisticsVO accCountStatistics(@Param("param") AccStatisticsSumDTO accStatisticsSumDTO, @Param("authPO") MgrUserAuthPO authPO);

   List<AccCountStatisticsVO> accCountStatisticsV2(@Param("param") AccStatisticsSumDTO accStatisticsSumDTO);

   AccCardStatisticsVO accCardStatistics(@Param("param") AccStatisticsSumDTO accStatisticsSumDTO, @Param("authPO") MgrUserAuthPO authPO);

   List<AccCardStatisticsVO> accCardStatisticsV2(@Param("param") AccStatisticsSumDTO accStatisticsSumDTO);

   @LeNiuDataPermission(
           alias = "t2",
           permissionType = DataPermissionTypeEnum.PERMISSION_ORG
   )
   Page<AppWorkAccInfoVO> queryPageAccInfoForAppWork(Page<AppWorkAccInfoVO> page, @Param("infoParam") AppWorkAccInfoPageDTO pageDTO);

   Integer queryAccInfoExpiredCount(@Param("startDateTime") LocalDateTime startDateTime, @Param("endDateTime") LocalDateTime endDateTime, @Param("accStatus") Integer accStatus);
}
