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

import java.util.*;

import co.yixiang.yshop.framework.common.pojo.PageResult;
import co.yixiang.yshop.framework.mybatis.core.query.LambdaQueryWrapperX;
import co.yixiang.yshop.framework.mybatis.core.mapper.BaseMapperX;
import co.yixiang.yshop.module.order.dal.dataobject.rechargeorder.RechargeOrderDO;
import org.apache.ibatis.annotations.Mapper;
import co.yixiang.yshop.module.order.controller.admin.rechargeorder.vo.*;

/**
 * 充值订单 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())
                .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));
    }

}
