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

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.screen.vo.DishVO;
import cn.iocoder.yudao.module.member.controller.app.orderdetail.vo.AppOrderDetailPageReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.orderdetail.OrderDetailDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 订单明细 Mapper
 *
 * @author 开发账号
 */
@Mapper
public interface OrderDetailMapper extends BaseMapperX<OrderDetailDO> {

    default PageResult<OrderDetailDO> selectPage(AppOrderDetailPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<OrderDetailDO>()
                .eqIfPresent(OrderDetailDO::getOrderId, reqVO.getOrderId())
                .eqIfPresent(OrderDetailDO::getDishesId, reqVO.getDishesId())
                .likeIfPresent(OrderDetailDO::getDishesName, reqVO.getDishesName())
                .eqIfPresent(OrderDetailDO::getWeight, reqVO.getWeight())
                .eqIfPresent(OrderDetailDO::getHeat, reqVO.getHeat())
                .betweenIfPresent(OrderDetailDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(OrderDetailDO::getId));
    }

    List<DishVO> selectDishSale(@Param("storeId") Long storeId, @Param("startTime") LocalDateTime startTime
            ,@Param("endTime") LocalDateTime endTime,@Param("type")Integer type);

}