package cn.iocoder.yudao.module.identity.dal.mysql.diversionstats;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.identity.dal.dataobject.diversionstats.DiversionStatsDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.identity.controller.admin.diversionstats.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 窜货统计 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface DiversionStatsMapper extends BaseMapperX<DiversionStatsDO> {

    default PageResult<DiversionStatsDO> selectPage(DiversionStatsPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DiversionStatsDO>()
                .eqIfPresent(DiversionStatsDO::getDealerId, reqVO.getDealerId())
                .likeIfPresent(DiversionStatsDO::getDealerName, reqVO.getDealerName())
                .eqIfPresent(DiversionStatsDO::getBatchId, reqVO.getBatchId())
                .eqIfPresent(DiversionStatsDO::getGoodsId, reqVO.getGoodsId())
                .likeIfPresent(DiversionStatsDO::getGoodsName, reqVO.getGoodsName())
                .eqIfPresent(DiversionStatsDO::getNum, reqVO.getNum())
                .eqIfPresent(DiversionStatsDO::getBelongBusinessId, reqVO.getBelongBusinessId())
                .likeIfPresent(DiversionStatsDO::getBelongBusinessName, reqVO.getBelongBusinessName())
                .betweenIfPresent(DiversionStatsDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DiversionStatsDO::getId));
    }

    default List<DiversionStatsDO> selectList(DiversionStatsExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<DiversionStatsDO>()
                .eqIfPresent(DiversionStatsDO::getDealerId, reqVO.getDealerId())
                .likeIfPresent(DiversionStatsDO::getDealerName, reqVO.getDealerName())
                .eqIfPresent(DiversionStatsDO::getBatchId, reqVO.getBatchId())
                .eqIfPresent(DiversionStatsDO::getGoodsId, reqVO.getGoodsId())
                .likeIfPresent(DiversionStatsDO::getGoodsName, reqVO.getGoodsName())
                .eqIfPresent(DiversionStatsDO::getNum, reqVO.getNum())
                .eqIfPresent(DiversionStatsDO::getBelongBusinessId, reqVO.getBelongBusinessId())
                .likeIfPresent(DiversionStatsDO::getBelongBusinessName, reqVO.getBelongBusinessName())
                .betweenIfPresent(DiversionStatsDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DiversionStatsDO::getId));
    }

    IPage<DiversionStatsDO> selectStatisticalIdenticalData(IPage<DiversionStatsDO>page,
                                                           @Param("belongBusinessName") String belongBusinessName,
                                                           @Param("goodsId") String goodsId,
                                                           @Param("goodsName") String goodsName,
                                                           @Param("dealerName") String dealerName,
                                                           @Param("dealerId") String dealerId);
}
