package com.ylx.companion.mapper;

import com.ylx.companion.domain.vo.HotCompanionProjectVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 类描述：
 *
 * @author Administrator
 * @version 1.0
 * @date 2026/6/10 11:07
 */
@Mapper
public interface CompanionRecommendMapper {

    /**
     * 查询销量前5的陪玩项目（假设有订单表 t_order 且包含 project_id, status=5 已完成）
     * 若没有订单表，可暂时返回空或使用降级逻辑
     */
    @Select("SELECT p.id as project_id, p.title as project_name, p.standard_duration as project_duration, " +
            "COUNT(o.id) as sales, AVG(o.final_amount) as avg_current_price, p.highlight " +
            "FROM project p " +
            "LEFT JOIN t_order o ON o.project_id = p.id AND o.status = 5 AND o.is_delete = 0 " +
            "WHERE p.type = 2 AND p.status = 0 AND p.is_delete = 0 " +
            "GROUP BY p.id " +
            "ORDER BY sales DESC " +
            "LIMIT 5")
    List<HotCompanionProjectVO> selectHotProjects();
}