package cn.iocoder.yudao.module.basic.dal.mysql.dealerinfo;

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.basic.dal.dataobject.dealerinfo.DealerInfoDO;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.basic.controller.admin.dealerinfo.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 经销商 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface DealerInfoMapper extends BaseMapperX<DealerInfoDO> {

    default PageResult<DealerInfoDO> selectPage(DealerInfoPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DealerInfoDO>()
                .likeIfPresent(DealerInfoDO::getDealerName, reqVO.getDealerName())
                .eqIfPresent(DealerInfoDO::getDealerId, reqVO.getDealerId())
                .eqIfPresent(DealerInfoDO::getBelongBusinessId, reqVO.getBelongBusinessId())
                .likeIfPresent(DealerInfoDO::getBelongBusinessName, reqVO.getBelongBusinessName())
                .eqIfPresent(DealerInfoDO::getBusinessCode, reqVO.getBusinessCode())
                .eqIfPresent(DealerInfoDO::getContactPhone, reqVO.getContactPhone())
                .likeIfPresent(DealerInfoDO::getContactName, reqVO.getContactName())
                .eqIfPresent(DealerInfoDO::getCommonSaleArea, reqVO.getCommonSaleArea())
                .eqIfPresent(DealerInfoDO::getCommonSaleAreaId, reqVO.getCommonSaleAreaId())
                .betweenIfPresent(DealerInfoDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(DealerInfoDO::getRemarks, reqVO.getRemarks())
                .orderByDesc(DealerInfoDO::getId));
    }

    IPage<DealerInfoDO> selectPageByInfo(IPage<DealerInfoDO> page, @Param(Constants.WRAPPER) Wrapper<DealerInfoDO> queryWrapper);

    List<DealerInfoDO> getDealerInfoByGoods(@Param("dealerId") String dealerId, @Param("businessInfoId") Long businessInfoId, @Param("goodsId") String goodsId);
}
