<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.fdkankan.ucenter.mapper.ISceneCooperationMapper">


    <select id="getCooperationSceneProNum" resultType="java.lang.Long">
        SELECT count(0) FROM t_scene_cooperation a
        LEFT JOIN t_scene_pro b ON a.scene_num = b.num
        WHERE a.rec_status = 'A' AND b.rec_status = 'A' AND b.is_upgrade = 0
        AND a.user_id = #{userId} AND  b.scene_source in
        <foreach collection="sceneSource" item="index" open="(" close=")" separator=",">
            #{index}
        </foreach>
    </select>
    <select id="getCooperationScenePlusNum" resultType="java.lang.Long">
        SELECT count(0) FROM t_scene_cooperation a
        LEFT JOIN t_scene_plus b ON a.scene_num = b.num
        WHERE a.rec_status = 'A' AND b.rec_status = 'A'
        AND a.user_id = #{userId}  AND b.scene_source in
        <foreach collection="sceneSource" item="index" open="(" close=")" separator=",">
            #{index}
        </foreach>
    </select>

    <select id="getGroupCooperationSceneProNum" resultType="com.fdkankan.ucenter.vo.response.SceneNumVo">
        SELECT scene_source as type,count(0) as cooperationSceneNum,
               CASE
                   WHEN a.scene_type = "mesh" THEN 1
                   WHEN a.scene_type = "laser" THEN 0
                   END  as isObj
        FROM t_scene_cooperation a
        LEFT JOIN t_scene_pro b ON a.scene_num = b.num
        WHERE a.rec_status = 'A' AND b.rec_status = 'A' AND b.is_upgrade = 0
        AND a.user_id = #{userId}
        group by scene_source,isObj
    </select>
    <select id="getGroupCooperationScenePlusNum" resultType="com.fdkankan.ucenter.vo.response.SceneNumVo">
        SELECT scene_source as type,count(0) as cooperationSceneNum ,
               CASE
                   WHEN a.scene_type = "mesh" THEN 1
                   WHEN a.scene_type = "laser" THEN 0
               END  as isObj
        FROM t_scene_cooperation a
                 LEFT JOIN t_scene_plus b ON a.scene_num = b.num
        WHERE a.rec_status = 'A' AND b.rec_status = 'A'
          AND a.user_id = #{userId}
        group by scene_source,isObj

    </select>
</mapper>
