package cn.newfeifan.mall.module.product.dal.mysql.skuapply;

import java.util.*;

import cn.newfeifan.mall.framework.common.pojo.PageResult;
import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.newfeifan.mall.framework.mybatis.core.mapper.BaseMapperX;
import cn.newfeifan.mall.module.product.dal.dataobject.skuapply.SkuApplyDO;
import org.apache.ibatis.annotations.Mapper;
import cn.newfeifan.mall.module.product.controller.admin.skuapply.vo.*;

/**
 * 商品sku申请 Mapper
 *
 * @author 非繁人
 */
@Mapper
public interface SkuApplyMapper extends BaseMapperX<SkuApplyDO> {

    default PageResult<SkuApplyDO> selectPage(SkuApplyPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<SkuApplyDO>()
                .eqIfPresent(SkuApplyDO::getSpuApplyId, reqVO.getSpuApplyId())
                .eqIfPresent(SkuApplyDO::getProperties, reqVO.getProperties())
                .eqIfPresent(SkuApplyDO::getPrice, reqVO.getPrice())
                .eqIfPresent(SkuApplyDO::getPromotionFee, reqVO.getPromotionFee())
                .eqIfPresent(SkuApplyDO::getMark, reqVO.getMark())
                .eqIfPresent(SkuApplyDO::getMarketPrice, reqVO.getMarketPrice())
                .eqIfPresent(SkuApplyDO::getCostPrice, reqVO.getCostPrice())
                .eqIfPresent(SkuApplyDO::getBarCode, reqVO.getBarCode())
                .eqIfPresent(SkuApplyDO::getPicUrl, reqVO.getPicUrl())
                .eqIfPresent(SkuApplyDO::getStock, reqVO.getStock())
                .eqIfPresent(SkuApplyDO::getWeight, reqVO.getWeight())
                .eqIfPresent(SkuApplyDO::getVolume, reqVO.getVolume())
                .eqIfPresent(SkuApplyDO::getFirstBrokeragePrice, reqVO.getFirstBrokeragePrice())
                .eqIfPresent(SkuApplyDO::getSecondBrokeragePrice, reqVO.getSecondBrokeragePrice())
                .eqIfPresent(SkuApplyDO::getSalesCount, reqVO.getSalesCount())
                .betweenIfPresent(SkuApplyDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(SkuApplyDO::getShopId, reqVO.getShopId())
                .eqIfPresent(SkuApplyDO::getMerchantId, reqVO.getMerchantId())
                .eqIfPresent(SkuApplyDO::getHighPrecisionPrice, reqVO.getHighPrecisionPrice())
                .eqIfPresent(SkuApplyDO::getSettlementPrice, reqVO.getSettlementPrice())
                .eqIfPresent(SkuApplyDO::getHighPrecisionSettlementPrice, reqVO.getHighPrecisionSettlementPrice())
                .orderByDesc(SkuApplyDO::getId));
    }

    default List<SkuApplyDO> selectListBySpuId(Long spuApplyId){
        return selectList(SkuApplyDO::getSpuApplyId, spuApplyId);
    }
}