ScrmSubscribeMerchantMapper.xml 8.32 KB
<?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.glsx.entmicro.mapper.ScrmSubscribeMerchantMapper">
    <resultMap id="BaseResultMap" type="cn.com.glsx.entmicro.entity.subscribe.ScrmSubscribeMerchantDO">
        <!--
          WARNING - @mbg.generated
        -->
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="created_by" jdbcType="INTEGER" property="createdBy"/>
        <result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
        <result column="updated_by" jdbcType="INTEGER" property="updatedBy"/>
        <result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime"/>
        <result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
        <result column="merchant_id" jdbcType="INTEGER" property="merchantId"/>
        <result column="merchant_name" jdbcType="VARCHAR" property="merchantName"/>
        <result column="service_type" jdbcType="INTEGER" property="serviceType"/>
        <result column="open_state" jdbcType="VARCHAR" property="openState"/>
        <result column="open_time" jdbcType="TIMESTAMP" property="openTime"/>
        <result column="activity_id" jdbcType="INTEGER" property="activityId"/>
        <result column="welfare_man_id" jdbcType="INTEGER" property="welfareManId"/>
        <result column="entmicro_name" jdbcType="VARCHAR" property="entmicroName"/>
        <result column="begin_time" jdbcType="TIMESTAMP" property="beginTime"/>
        <result column="end_time" jdbcType="TIMESTAMP" property="endTime"/>
        <result column="open_status" jdbcType="TINYINT" property="openStatus"/>
    </resultMap>
    <resultMap id="SubscriptionViewResponseMap"
               type="cn.com.glsx.entmicro.model.response.subscribe.SubscriptionViewRpcResponse">
        <id column="id" jdbcType="INTEGER" property="subId"/>
        <result column="merchant_id" jdbcType="INTEGER" property="merchantId"/>
        <result column="merchant_name" jdbcType="VARCHAR" property="merchantName"/>
        <result column="service_type" jdbcType="INTEGER" property="serviceType"/>
        <result column="open_state" jdbcType="VARCHAR" property="openState"/>
        <result column="open_time" jdbcType="TIMESTAMP" property="openTime"/>
        <result column="activity_id" jdbcType="INTEGER" property="activityId"/>
        <result column="welfare_man_id" jdbcType="INTEGER" property="welfareManId"/>
        <result column="entmicro_name" jdbcType="VARCHAR" property="entmicroName"/>
        <result column="begin_time" jdbcType="TIMESTAMP" property="beginTime"/>
        <result column="end_time" jdbcType="TIMESTAMP" property="endTime"/>
        <result column="open_status" jdbcType="INTEGER" property="openStatus"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--
          WARNING - @mbg.generated
        -->
        id, created_by, created_time, updated_by, updated_time, del_flag, merchant_id, merchant_name, service_type,
        open_time, activity_id,welfare_man_id,entmicro_name, open_state,begin_time,end_time,open_status
    </sql>
    <update id="updateListOutOfDate">
        <foreach collection="list" index="index" item="item" separator=";">
            update scrm_subscribe_merchant set open_state = #{item.openState},open_status = #{item.openStatus}
            where id = #{item.id}
        </foreach>
    </update>

    <select id="selectSubscribeMerchantPage" resultMap="SubscriptionViewResponseMap">
        select
        <include refid="Base_Column_List"/>
        from scrm_subscribe_merchant
        where del_flag = 0
        <if test="merchantId != null ">
            and merchant_id = #{merchantId}
        </if>
        <if test="serviceType != null ">
            and service_type = #{serviceType}
        </if>
        <if test="merchantName != null and merchantName != ''">
            and merchant_name like concat("%",#{merchantName},"%")
        </if>
        <if test="openStatus != null ">
            and open_status = #{openStatus}
        </if>
        group by id
        order by open_time desc
    </select>

    <select id="selectMoveCarCodeCount"
            resultType="cn.com.glsx.entmicro.model.response.subscribe.MoveCarCodeCountResponse">
        select smccb.merchant_id merchantId,count(smccb.id) totalCount,count(smccb.owner_phone) bindCount
        from scrm_move_car_code_bind smccb
        where smccb.del_flag = 0
        <if test="merchantIdList != null and  merchantIdList.size>0">
            and smccb.merchant_id IN
            <foreach collection="merchantIdList" index="index" open="(" close=")" separator="," item="merchantId">
                #{merchantId}
            </foreach>
        </if>
        group by smccb.merchant_id
    </select>

    <select id="selectIsOpenMerchant" resultType="java.lang.Integer">
        select ssm.merchant_id from scrm_subscribe_merchant ssm
        where ssm.del_flag = 0 and service_type = #{serviceType}
        <if test="merchantIdList != null and  merchantIdList.size>0">
            and ssm.merchant_id IN
            <foreach collection="merchantIdList" index="index" open="(" close=")" separator="," item="merchantId">
                #{merchantId}
            </foreach>
        </if>
        group by ssm.merchant_id
    </select>
    <select id="findOutOfDateMerchant"
            resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from scrm_subscribe_merchant
        where del_flag = 0 and end_time &lt; NOW()
    </select>
    <select id="findActivityIdList"
            resultType="cn.com.glsx.entmicro.model.response.subscribe.SubscribeActRpcResponse">
        SELECT t.service_type  AS serviceType,
               t.activity_id   AS activityId,
               t1.service_name AS serviceTypeName
        FROM scrm_subscribe_merchant t
                 LEFT JOIN scrm_subscribe_service t1 ON t1.service_type = t.service_type
        WHERE t.del_flag = 0
          AND t.open_status = 1
          AND t.merchant_id = #{condition.merchantId}
    </select>
    <select id="getOpenedInfo"
            resultType="cn.com.glsx.entmicro.model.response.subscribe.MerchantSubServeRpcResponse">
        SELECT merchant_id as merchantId , welfare_man_id as welfareManId,service_type as serviceType FROM
        scrm_subscribe_merchant
        WHERE del_flag = 0 AND open_status = 1
        <if test="condition.serviceType != null">
            AND service_type = #{condition.serviceType}
        </if>
        <if test="condition.merchantIds != null and condition.merchantIds.size > 0">
            AND merchant_id in
            <foreach collection="condition.merchantIds" item="item" index="index" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
    </select>


    <select id="findMerchantWelfareIdInfo"
            resultType="cn.com.glsx.entmicro.model.response.subscribe.MerchantWelfareIdResponse">
        select merchant_id as merchantId , welfare_man_id as welfareManId,merchant_name as merchantName
        from scrm_subscribe_merchant where del_flag = 0 and service_type = 3 and merchant_id in
        <foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
            #{item}
        </foreach>
    </select>
    <select id="selectMerchantSubscribe"
            resultMap="BaseResultMap">
        select *
        from scrm_subscribe_merchant
        where del_flag = 0
          and merchant_id = #{merchantId}
          and service_type = #{serviceType}
    </select>
    <select id="getOpenMerchantPage"
            resultType="cn.com.glsx.entmicro.model.response.subscribe.SubscribeServiceRpcResponse">
        select merchant_id as merchantId,merchant_name as merchantName,service_type as serviceType
        from scrm_subscribe_merchant where del_flag = 0 and open_status = 1
        <if test="param.serviceType != null">
            <if test="param.serviceType == 3">
                and welfare_man_id is not null
            </if>
            and service_type = #{param.serviceType}
        </if>
        <if test="param.merchantId != null">
            and merchant_id = #{param.merchantId}
        </if>
        <if test="param.merchantName != null and param.merchantName != ''">
            and merchant_name LIKE CONCAT('%',#{param.merchantName},'%')
        </if>
        order by created_time desc
    </select>
</mapper>