package org.jeecg.modules.system.app.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.app.form.PageOrdersForm;
import org.jeecg.modules.app.vo.PageOrdersVO;
import org.jeecg.modules.app.vo.game.GameOrderVo;
import org.jeecg.modules.quartz.vo.JobClassNoticeVo;
import org.jeecg.modules.quartz.vo.JobReservationSiteVo;
import org.jeecg.modules.system.app.dto.AppGameRuleDTO;
import org.jeecg.modules.system.app.entity.AppOrder;
import org.jeecg.modules.system.app.form.AppOrderPageForm;
import org.jeecg.modules.system.app.form.RefundOrderPageForm;
import org.jeecg.modules.system.app.vo.OrderPageVO;
import org.jeecg.modules.system.app.vo.RefundOrderPageVO;
import org.jeecg.modules.system.app.vo.statistics.FindByShopSumVO;

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

/**
 * @Description: 订单表
 * @Author: jeecg-boot
 * @Date:   2025-07-03
 * @Version: V1.0
 */
@Mapper
public interface AppOrderMapper extends BaseMapper<AppOrder> {

    Page<OrderPageVO> queryPage(Page<OrderPageVO> page, @Param("appOrderPageForm") AppOrderPageForm appOrderPageForm);

    /**
     * 查询已报名数
     * @param productIds
     * @param type
     * @return
     */
    int countTypeAndProductIds(@Param("productIds") List<String> productIds, @Param("type") int type);

    List<GameOrderVo> findByNewOrderInfo(@Param("productIds")  List<String> productIds,@Param("orderType")  Integer orderType);

    Long findByTeachingCount(@Param("productIds") List<String> productIds);

    Long findByOrderNumCount(@Param("productIds") List<String> productIds);

    int queryBookedCount(@Param("placeId") String placeId,
                         @Param("date") String date,
                         @Param("startTime") String startTime,
                         @Param("endTime") String endTime);

    IPage<PageOrdersVO> pageOrders(Page<PageOrdersVO> page, @Param("pageOrdersForm") PageOrdersForm pageOrdersForm);

    List<JobClassNoticeVo> findByJob(@Param("hoursBefore") Integer hoursBefore,@Param("date") Date date,@Param("maxRetry")  int maxRetry);

    List<JobReservationSiteVo> findByReservationSite();

    List<JobReservationSiteVo> findByReservationSiteTicket(@Param("currentDate")LocalDate currentDate,@Param("localTime") LocalTime localTime);

    List<FindByShopSumVO> findByShopSumList(@Param("orgCode")String orgCode,@Param("startTime") LocalDateTime startTime,@Param("endTime") LocalDateTime endTime);

    Long findByProductIds(@Param("productIds") List<AppGameRuleDTO> productIds);

    IPage<RefundOrderPageVO> refundOrderPageList(IPage<RefundOrderPageVO> page,@Param("refundOrderPageForm") RefundOrderPageForm refundOrderPageForm);
}
