<?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.cyksj.mapper.corp.CorpCustomerAcquisitionLinkMapper">

    <select id="selectActiveCodeByFollowIndx" resultType="com.cyksj.model.entity.CorpCustomerAcquisitionLink">
        select *
        from corp_customer_acquisition_link
        where user_list != '[]' and
        <foreach collection="list" item="item" open="(" separator="OR" close=")">
            JSON_CONTAINS(user_list, '${item}')
        </foreach>
    </select>

    <select id="selectAcLinkCorpTemplateCouponIdsByTagIds" resultType="java.lang.String">
        select distinct ct.coupon_ids from (select msg_id from corp_customer_acquisition_link
        where msg_id != 0 and tags != '[]' and
        <foreach collection="tagIds" item="item" open="(" separator="OR" close=")">
            JSON_CONTAINS(tags, '"${item}"')
        </foreach>)s inner join corp_welcome_template ct on ct.id = s.msg_id
        where ct.coupon_ids is not null
    </select>
</mapper>