package com.yida.data.school.transaction.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yida.data.common.core.entity.apply.EduApplyProductOrder;
import com.yida.data.common.core.entity.apply.EduApplyProductOrderStudent;
import com.yida.data.school.dto.transaction.EduApplyProductOrderDTO;
import com.yida.data.school.vo.transcation.RefundOrderVO;
import java.time.LocalDateTime;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

@Mapper
public interface EduApplyProductOrderMapper extends BaseMapper<EduApplyProductOrder> {

    /**
     * 后台订单
     *
     * @param eduApplyProductOrderDTO
     * @return
     */
    IPage<EduApplyProductOrder> listPageEduProductOrder(Page page,
        @Param("dto") EduApplyProductOrderDTO eduApplyProductOrderDTO,
        @Param("schoolIds") List<Long> schoolIds);

    /**
     * 查询超时订单
     *
     * @param now
     * @return
     */
    List<EduApplyProductOrder> selectExpireOrder(LocalDateTime now);

    /**
     * 查询该学生与该商品有多少未完成订单
     *
     * @param productId
     * @param studentId
     * @return
     */
    Integer countStudentOrder(@Param("productId") Long productId,
        @Param("studentId") Long studentId);

    /**
     * 查询学生未支付订单的支付学生信息
     *
     * @param studentId
     * @return
     */
    EduApplyProductOrderStudent selectNotPayOrderStudent(@Param("studentId") Long studentId, @Param("productId") Long productId);

    /**
     * 查询退款订单
     */
    List<RefundOrderVO> selectRefundOrder();

    /**
     * 手机端查询订单列表
     *
     * @param
     * @return
     */
    List<EduApplyProductOrder> listEduProductOrder(@Param("schoolId") Long schoolId,
        @Param("phone") String phone,
        @Param("studentId") Long studentId);

    /**
     * 根据订单编号查询订单
     */
    EduApplyProductOrder getOrderByCode(@Param("orderCode") String code);
}
