package com.platform.service.custom;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.platform.entity.TmDealLog;
import com.platform.service.impl.TmDealLogServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.time.LocalDate;

/**
 * @author abnerhou
 * @date 2020/9/24 19:07
 * @desciption
 */

@Service
@Slf4j
public class OrderDealLogService extends TmDealLogServiceImpl {

    public long getDealNumByBrandId(LocalDate dealDate , int brandId){
        QueryWrapper<TmDealLog> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("brand_id" , brandId);
        queryWrapper.eq("enable" , 1);
        queryWrapper.eq("deal_date" , dealDate);
        IPage<TmDealLog> page = new Page<>(1 , 10);
        IPage<TmDealLog> result = new Page<>();
        result = getBaseMapper().selectPage(page , queryWrapper);
        if(null != result){
            return result.getTotal();
        }
        return 0;
    }
}
