package com.ycwl.basic.mapper;

import com.ycwl.basic.model.mobile.order.OrderAppPageReq;
import com.ycwl.basic.model.pc.order.entity.OrderEntity;
import com.ycwl.basic.model.pc.order.entity.OrderItemEntity;
import com.ycwl.basic.model.pc.order.req.OrderUpdateReq;
import com.ycwl.basic.model.pc.order.req.OrderAddReq;
import com.ycwl.basic.model.pc.order.req.OrderReqQuery;
import com.ycwl.basic.model.pc.order.resp.OrderAppRespVO;
import com.ycwl.basic.model.pc.order.resp.OrderRespVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @Author：longbinbin
 * @Date：2024/11/29 16:32
 * 订单
 */
@Mapper
public interface OrderMapper {
    List<OrderRespVO> list(OrderReqQuery orderReqQuery);
    List<OrderRespVO> listDetail(OrderReqQuery orderReqQuery);
    OrderRespVO getById(Long id);
    int add(OrderEntity order);
//    int deleteById(Long id);
    int update(OrderUpdateReq order);

    /**
     * 添加订单明细
     * @param orderItems
     * @return
     */
    int addOrderItems(List<OrderItemEntity> orderItems);

    int countByUserId(Long userId);

    List<OrderAppRespVO> appList(OrderAppPageReq orderReqQuery);

    OrderAppRespVO appDetail(Long id);

    List<OrderRespVO> refundList(OrderReqQuery query);

    List<OrderItemEntity> listOrderItemByOrderId(Long orderId);

    OrderEntity getUserBuyItem(Long userId, int goodsType, Long goodsId);

    OrderEntity get(Long orderId);

    OrderItemEntity getOrderItem(Long orderItemId);

    int updateOrderPrice(OrderEntity updateEntity);
    int updateOrder(OrderEntity updateEntity);

    OrderEntity queryTypeOrder(Long userId, Long faceId, Long scenicId, int orderType, Integer priceConfigId);

    OrderEntity getUserOrderItem(Long userId, Long scenicId, int orderType, Long configId, Integer goodsType, Long goodsId);
    
    int updateMemberIdByFaceId(OrderEntity orderEntity);

    List<OrderItemEntity> getOrderItems(Long orderId);

    OrderEntity getUserBuyFaceItem(Long memberId, Long faceId, int goodsType, Long goodsId);

    /**
     * 查询购买了指定视频的所有订单ID（直接购买）
     * @param videoId 视频ID
     * @return 订单ID列表
     */
    List<Long> getOrderIdsByVideoId(Long videoId);

    /**
     * 查询购买了指定模板和faceId的所有订单ID
     * @param faceId 人脸ID
     * @param templateId 模板ID
     * @return 订单ID列表
     */
    List<Long> getOrderIdsByFaceIdAndTemplateId(@Param("faceId") Long faceId, @Param("templateId") Long templateId);
}
