package com.yc.ship.module.trade.dal.mysql.order;

import com.yc.ship.framework.mybatis.core.mapper.BaseMapperX;
import com.yc.ship.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yc.ship.framework.tenant.core.aop.TenantIgnore;
import com.yc.ship.module.trade.controller.admin.order.vo.order.OrderShareVO;
import com.yc.ship.module.trade.controller.admin.order.vo.order.OrderTotalRoomModelVO;
import com.yc.ship.module.trade.controller.app.otc.vo.AppRoomDescVO;
import com.yc.ship.module.trade.dal.dataobject.order.TradeOrderCountryDO;
import com.yc.ship.module.trade.dal.dataobject.order.TradeOrderRoomModelDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 订单关联房型数据 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface TradeOrderRoomModelMapper extends BaseMapperX<TradeOrderRoomModelDO> {


    List<TradeOrderRoomModelDO> selectListByOrderId(@Param("orderId") Long id);


    List<TradeOrderRoomModelDO> selectListByOrderIds(@Param("orderIds") List<Long> orderIds);

    default void deleteByOrderId(Long orderId) {
        delete(new LambdaQueryWrapperX<TradeOrderRoomModelDO>()
                .eq(TradeOrderRoomModelDO::getOrderId, orderId));
    }

    @Update("UPDATE trade_order_room_model SET deleted = #{deleted},update_time = now(), sync_status = '0' WHERE order_id = #{orderId}")
    @TenantIgnore
    void updateDeleted(@Param("orderId") Long orderId, @Param("deleted")  int deleted);

    /**
     * 统计订单拼房数据
     * @param orderIds
     * @return
     */
    List<OrderShareVO> selectOrderShareStatsByOrderIds(@Param("orderIds") List<Long> orderIds);
    List<OrderShareVO> selectOrderShareStatsByOrderIds1(@Param("orderIds") List<Long> orderIds);

    List<AppRoomDescVO> selectRoomDesc(@Param("orderIds") List<Long> orderIds, @Param("keyword") String keyword);
    /**
     * 统计订单房型数据
     * @param orderIds
     * @return
     */
    List<OrderTotalRoomModelVO> selectOrderRoomModelStatsByOrderIds(@Param("orderIds") List<Long> orderIds);
}