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

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.member.controller.app.storeorder.vo.AppStoreOrderDetailVo;
import cn.iocoder.yudao.module.member.dal.dataobject.storeorderdetail.StoreOrderDetailDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.member.controller.admin.storeorderdetail.vo.*;
import org.apache.ibatis.annotations.Select;

/**
 * 商品订单详情 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface StoreOrderDetailMapper extends BaseMapperX<StoreOrderDetailDO> {

    default PageResult<StoreOrderDetailDO> selectPage(StoreOrderDetailPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<StoreOrderDetailDO>()
                .eqIfPresent(StoreOrderDetailDO::getOrderId, reqVO.getOrderId())
                .eqIfPresent(StoreOrderDetailDO::getGoodsId, reqVO.getGoodsId())
                .eqIfPresent(StoreOrderDetailDO::getCustomPrice, reqVO.getCustomPrice())
                .eqIfPresent(StoreOrderDetailDO::getNumber, reqVO.getNumber())
                .betweenIfPresent(StoreOrderDetailDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(StoreOrderDetailDO::getId));
    }


    @Select("select od.custom_price,od.number,od.weight,od.goods_name,sg.img from member_store_order_detail od left join member_store_goods sg on od.goods_id = sg.goods_id  where od.order_id = #{orderId}")
    List<AppStoreOrderDetailVo> selectByOrderId(Integer orderId);

}