package co.yixiang.yshop.module.order.dal.mysql.rechargeorder;

import co.yixiang.yshop.framework.common.pojo.PageResult;
import co.yixiang.yshop.framework.mybatis.core.mapper.BaseMapperX;
import co.yixiang.yshop.framework.mybatis.core.query.LambdaQueryWrapperX;
import co.yixiang.yshop.module.order.controller.admin.rechargeorder.vo.RechargeOrderExportReqVO;
import co.yixiang.yshop.module.order.controller.admin.rechargeorder.vo.RechargeOrderPageReqVO;
import co.yixiang.yshop.module.order.controller.admin.rechargeorder.vo.RechargeOrderRespVO;
import co.yixiang.yshop.module.order.dal.dataobject.rechargeorder.RechargeOrderDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 充值订单 Mapper
 *
 * @author admin
 */
@Mapper
public interface RechargeOrderMapper extends BaseMapperX<RechargeOrderDO> {

    default PageResult<RechargeOrderDO> selectPage(RechargeOrderPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<RechargeOrderDO>()
                .eqIfPresent(RechargeOrderDO::getUserId, reqVO.getUserId())
                .likeIfPresent(RechargeOrderDO::getId, reqVO.getId())
                .eqIfPresent(RechargeOrderDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(RechargeOrderDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(RechargeOrderDO::getRechargeAmount, reqVO.getRechargeAmount())
                .eqIfPresent(RechargeOrderDO::getGiftAmount, reqVO.getGiftAmount())
                .eqIfPresent(RechargeOrderDO::getPackageId, reqVO.getPackageId())
                .orderByDesc(RechargeOrderDO::getId));
    }

    default List<RechargeOrderDO> selectList(RechargeOrderExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<RechargeOrderDO>()
                .eqIfPresent(RechargeOrderDO::getUserId, reqVO.getUserId())
                .eqIfPresent(RechargeOrderDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(RechargeOrderDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(RechargeOrderDO::getRechargeAmount, reqVO.getRechargeAmount())
                .eqIfPresent(RechargeOrderDO::getGiftAmount, reqVO.getGiftAmount())
                .eqIfPresent(RechargeOrderDO::getPackageId, reqVO.getPackageId())
                .orderByDesc(RechargeOrderDO::getId));
    }

    IPage<RechargeOrderRespVO> selectPageVO(IPage<RechargeOrderRespVO> mpPage, @Param("param") RechargeOrderPageReqVO pageReqVO);
}
