<?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.liquidnet.service.sweet.mapper.SweetIntegralActivityMapper">

    <select id="searchActivityList" resultType="com.liquidnet.service.sweet.dto.SweetIntegralActivityDto">
        select a.*,
               sum(b.prize_num)  as prize_num,
               count(c.prize_id) as draw_num
        from sweet_integral_activity as a
                 left join sweet_integral_activity_prize as b on a.integral_activity_id = b.integral_activity_id
                 left join sweet_integral_activity_draw as c on b.prize_id = c.prize_id
        <where>
            <if test="activityTitle != null  and activityTitle != ''">
                and kot.activity_title like concat('%', #{activityTitle}, '%')
            </if>
        </where>
        group by a.integral_activity_id
        ORDER BY a.mid DESC
    </select>
</mapper>
