package cn.iocoder.yudao.module.member.dal.mysql.business;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.member.controller.admin.business.vo.BusinessPageReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.business.BusinessDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 营业统计 Mapper
 *
 * @author 开发账号
 */
@Mapper
public interface BusinessMapper extends BaseMapperX<BusinessDO> {

    default PageResult<BusinessDO> selectPage(BusinessPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BusinessDO>()
                .eqIfPresent(BusinessDO::getTurnover, reqVO.getTurnover())
                .eqIfPresent(BusinessDO::getOrderSum, reqVO.getOrderSum())
                .eqIfPresent(BusinessDO::getCustomerSum, reqVO.getCustomerSum())
                .eqIfPresent(BusinessDO::getPriceAvg, reqVO.getPriceAvg())
                .eqIfPresent(BusinessDO::getRechargePurse, reqVO.getRechargePurse())
                .eqIfPresent(BusinessDO::getSubsidyPurse, reqVO.getSubsidyPurse())
                .eqIfPresent(BusinessDO::getGratis, reqVO.getGratis())
                .eqIfPresent(BusinessDO::getBreakfast, reqVO.getBreakfast())
                .eqIfPresent(BusinessDO::getLunch, reqVO.getLunch())
                .eqIfPresent(BusinessDO::getDinner, reqVO.getDinner())
                .eqIfPresent(BusinessDO::getWeigh, reqVO.getWeigh())
                .betweenIfPresent(BusinessDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BusinessDO::getId));
    }

}