package cn.iocoder.yudao.module.order.dal.mysql.orderFeeApplication;

import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQuery;
import cn.iocoder.yudao.framework.mybatis.core.mapper.AbstractMapper;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.order.dal.dataobject.orderFeeApplication.OrderFeeApplicationDO;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.order.vo.orderFeeApplication.*;

/**
 * 订单费用申请 Mapper
 * @author 系统管理员
 */
@Mapper
public interface OrderFeeApplicationMapper extends AbstractMapper<OrderFeeApplicationDO> {
    @Override
    default PageResult<OrderFeeApplicationDO> selectPage(PageVO page, Object object) {
        if (object instanceof OrderFeeApplicationQueryVO) {
            OrderFeeApplicationQueryVO vo = (OrderFeeApplicationQueryVO)object;
            return selectPage(page, new LambdaQuery<OrderFeeApplicationDO>()
                .eqIfPresent(OrderFeeApplicationDO::getOrderId, vo.getOrderId())
                .eqIfPresent(OrderFeeApplicationDO::getFeeType, vo.getFeeType())
                .eqIfPresent(OrderFeeApplicationDO::getApplicationFee, vo.getApplicationFee())
                .eqIfPresent(OrderFeeApplicationDO::getApplicationFeeCurrency, vo.getApplicationFeeCurrency())
                .eqIfPresent(OrderFeeApplicationDO::getPayType, vo.getPayType())
                .eqIfPresent(OrderFeeApplicationDO::getRemarks, vo.getRemarks())
                .eqIfPresent(OrderFeeApplicationDO::getReceiveFlag, vo.getReceiveFlag())
                .eqIfPresent(OrderFeeApplicationDO::getCreator, vo.getCreator())
                .betweenIfPresent(OrderFeeApplicationDO::getCreateTime, vo.getBeginCreateTime(), vo.getEndCreateTime())
                .eqIfPresent(OrderFeeApplicationDO::getApplicationId, vo.getApplicationId())
                .eqIfPresent(OrderFeeApplicationDO::getApplicationAuthor, vo.getApplicationAuthor())
                .eqIfPresent(OrderFeeApplicationDO::getSid, vo.getSid())
                .eqIfPresent(OrderFeeApplicationDO::getShenhe, vo.getShenhe())
                .betweenIfPresent(OrderFeeApplicationDO::getShenhetime, vo.getBeginShenhetime(), vo.getEndShenhetime())
                .eqIfPresent(OrderFeeApplicationDO::getStatus, vo.getStatus())
                .eqIfPresent(OrderFeeApplicationDO::getHuifu, vo.getHuifu())
                    .orderByDesc(OrderFeeApplicationDO::getId));
        }

        return null;
    }

    @Override
    default List<OrderFeeApplicationDO> selectList(Object object) {
        if (object instanceof OrderFeeApplicationQueryVO) {
            OrderFeeApplicationQueryVO vo = (OrderFeeApplicationQueryVO)object;
            return selectList(new LambdaQuery<OrderFeeApplicationDO>()
                .eqIfPresent(OrderFeeApplicationDO::getOrderId, vo.getOrderId())
                .eqIfPresent(OrderFeeApplicationDO::getFeeType, vo.getFeeType())
                .eqIfPresent(OrderFeeApplicationDO::getApplicationFee, vo.getApplicationFee())
                .eqIfPresent(OrderFeeApplicationDO::getApplicationFeeCurrency, vo.getApplicationFeeCurrency())
                .eqIfPresent(OrderFeeApplicationDO::getPayType, vo.getPayType())
                .eqIfPresent(OrderFeeApplicationDO::getRemarks, vo.getRemarks())
                .eqIfPresent(OrderFeeApplicationDO::getReceiveFlag, vo.getReceiveFlag())
                .eqIfPresent(OrderFeeApplicationDO::getCreator, vo.getCreator())
                .betweenIfPresent(OrderFeeApplicationDO::getCreateTime, vo.getBeginCreateTime(), vo.getEndCreateTime())
                .eqIfPresent(OrderFeeApplicationDO::getApplicationId, vo.getApplicationId())
                .eqIfPresent(OrderFeeApplicationDO::getApplicationAuthor, vo.getApplicationAuthor())
                .eqIfPresent(OrderFeeApplicationDO::getSid, vo.getSid())
                .eqIfPresent(OrderFeeApplicationDO::getShenhe, vo.getShenhe())
                .betweenIfPresent(OrderFeeApplicationDO::getShenhetime, vo.getBeginShenhetime(), vo.getEndShenhetime())
                .eqIfPresent(OrderFeeApplicationDO::getStatus, vo.getStatus())
                .eqIfPresent(OrderFeeApplicationDO::getHuifu, vo.getHuifu())
                    .orderByDesc(OrderFeeApplicationDO::getId));
        }

        return null;
    }

    default List<OrderFeeApplicationDO> getFeeApplicationListByOrderId(Long orderId) {
        return selectList(new LambdaQueryWrapperX<OrderFeeApplicationDO>().eq(OrderFeeApplicationDO::getOrderId,orderId));
    };
}
