package com.yida.data.mall.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.mall.EduBillOrder;
import com.yida.data.mall.dto.h5.H5BillOrderPageDTO;
import com.yida.data.mall.vo.BillRefundOrderVO;
import com.yida.data.mall.vo.h5.H5BillOrderInfoVO;
import com.yida.data.mall.vo.h5.H5BillOrderPageVO;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;

/**
 * 账单订单表 Mapper
 *
 * @author ZYJ
 * @date 2022-03-31 14:49:59
 */
public interface EduBillOrderMapper extends BaseMapper<EduBillOrder> {

    /**
     * 查询已支付金额
     *
     * @param billId    账单id
     * @param studentId 学生id
     * @return java.math.BigDecimal
     * @author ZYJ
     * @date 2022/3/31 15:36
     */
    BigDecimal sumPayOrderPrice(@Param("billId") Long billId,
                                @Param("studentId") Long studentId);

    /**
     * 前端查询账单订单列表数据
     * 未支付、成功、退款中
     *
     * @param page 分页数据
     * @param dto  账单订单列表请求类
     * @return com.baomidou.mybatisplus.core.metadata.IPage<com.yida.data.mall.vo.h5.H5BillOrderPageVO>
     * @author ZYJ
     * @date 2022/4/1 16:56
     */
    IPage<H5BillOrderPageVO> listH5BillOrderPage(Page<EduBillOrder> page,
                                                 @Param("dto") H5BillOrderPageDTO dto);

    /**
     * 前端查询账单订单详情
     *
     * @param billOrderId 账单订单id
     * @param orderCode   订单号
     * @return com.yida.data.mall.vo.h5.H5BillOrderInfoVO
     * @author ZYJ
     * @date 2022/4/1 17:38
     */
    H5BillOrderInfoVO getH5BillOrderInfo(@Param("billOrderId") Long billOrderId,
                                         @Param("orderCode") String orderCode);

    /**
     * 查询账单缴费人数
     * 缴费金额大于0
     *
     * @param billId 账单id
     * @return java.lang.Long
     * @author ZYJ
     * @date 2022/4/18 16:30
     */
    Long sumPayStudentNumber(@Param("billId") Long billId);

    /**
     * 查询所有已经超时订单
     * 未支付状态
     *
     * @return java.util.List<com.yida.data.common.core.entity.mall.EduBillOrder>
     * @author ZYJ
     * @date 2022/4/14 10:48
     */
    List<EduBillOrder> selectTimeOutBillOrder();

    /**
     * 查询退款中状态的账单订单
     *
     * @return java.util.List<com.yida.data.mall.vo.BillRefundOrderVO>
     * @author ZYJ
     * @date 2022/4/18 13:38
     */
    List<BillRefundOrderVO> selectRefundOrder();

    /**
     * 部门缴费总金额
     *
     * @param billId 账单id
     * @param deptId 家校部门id
     * @param type   家校部门类型
     * @return java.math.BigDecimal
     * @author ZYJ
     * @date 2022/7/11 15:57
     */
    BigDecimal sumDeptPayOrderPrice(@Param("billId") Long billId,
                                    @Param("deptId") Long deptId,
                                    @Param("type") Integer type);
}
