package com.czg.service.order.mapper;

import com.czg.order.vo.OrderDetailPrintVo;
import com.mybatisflex.core.BaseMapper;
import com.czg.order.entity.OrderDetail;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

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

/**
 * 订单详情 映射层。
 *
 * @author ww
 * @since 2025-02-13
 */
public interface OrderDetailMapper extends BaseMapper<OrderDetail> {
    void createOrderDetails(@Param("orderId") Long orderId,@Param("orderDetails") List<OrderDetail> orderDetails);


    List<OrderDetailPrintVo> getOrderDetailPrint(Long orderId);

    @Update("UPDATE tb_order_detail SET status = #{status}, order_time = #{orderTime} " +
            "WHERE order_id = #{orderId} AND status = 'wait-pay'")
    int updateStatusByOrderId(@Param("orderId") Long orderId,
                              @Param("status") String status,
                              @Param("orderTime") LocalDateTime orderTime);
}
