<?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="cn.com.ctop.kuaishou.modules.dimension.mapper.KuaiShouDimensionUnitMapper">
	<update id="editBatch">
		update ctop_kuaishou_dimension_unit
		set submit_status = #{submitStatus}
		where id in
		<foreach collection="ids" item="item" separator=","
				 open="(" close=")">
			#{item}
		</foreach>

	</update>

	<select id="getCampaignCount" resultType="com.alibaba.fastjson.JSONObject">
       SELECT
        t1.campaign_id as 'campaignId',
        t2.campaign_type as 'campaignType',
        t2.campaign_name as 'campaignName',
        t2.day_budget as 'dayBudget'
        from
   	(
		SELECT
			campaign_id
		FROM
			ctop_kuaishou_dimension_unit
		WHERE strategy_id = #{strategyId}
		and account_id = #{accountId}
		AND submit_status = 0
		GROUP BY
			campaign_id
	) t1
        LEFT JOIN (
	    SELECT
		*
	    FROM
		ctop_kuaishou_dimension_campaign
	    WHERE  account_id = #{accountId}
    )  t2
        ON t1.campaign_id = t2.campaign_id

    </select>
	<select id="getUnitCount" resultType="java.lang.Integer">
		SELECT
			count(1) as 'count'
		FROM
			ctop_kuaishou_dimension_unit
		WHERE strategy_id = #{strategyId}
			and account_id = #{accountId}
		AND submit_status = 0
	</select>
	<select id="getUnitCountByStrategyId" resultType="java.lang.Integer">
		select  count(1) as 'count'  from
		ctop_kuaishou_dimension_unit where strategy_id = #{strategyId}
		and  submit_status = 0

	</select>
</mapper>