<?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.qmth.sop.business.mapper.TFCustomFlowEntityMapper">

    <select id="getFlowTaskRemindMsgInfo" resultType="com.qmth.sop.business.bean.result.FlowTaskMsgResult">
        select
            tbs.id as serviceId,
            tbs.name as serviceName,
            sc.name as customName,
            su.real_name as realName,
            su.mobile_number as mobileNumber,
            tbda.apply_time as applyTime,
            tbpe.type as exchangeType
        from
            t_f_custom_flow_entity tfcfe
            left join t_b_crm tbc on tbc.crm_no = tfcfe.crm_no
            left join t_b_service tbs on tbs.id = tbc.service_id
            left join sys_custom sc on sc.id = tbc.custom_id
            left join t_b_ding_apply tbda on tbda.ding_exception_no = tfcfe.code
            left join t_b_project_exchange tbpe on tbpe.exchange_no = tfcfe.code
            left join sys_user su on su.id = #{userId}
        where
            tfcfe.id = #{id}
    </select>

    <select id="getFlowTaskRemindSmsInfo" resultType="com.qmth.sop.business.bean.result.FlowTaskSmsResult">
        select
            tbs.id as serviceId,
            tbs.name as serviceName,
            sc.name as customName,
            su.real_name as realName,
            su.mobile_number as mobileNumber
        from
            t_f_custom_flow_entity tfcfe
            left join t_b_crm tbc on tbc.crm_no = tfcfe.crm_no
            left join t_b_service tbs on tbs.id = tbc.service_id
            left join sys_custom sc on sc.id = tbc.custom_id
            left join sys_user su on su.id = #{userId}
        where
            tfcfe.id = #{id}
    </select>

    <select id="getFlowTaskRemindSmsInfoByCrmNo" resultType="com.qmth.sop.business.bean.result.FlowTaskSmsResult">
        select
            tbs.id as serviceId,
            tbs.name as serviceName,
            sc.name as customName,
            su.real_name as realName,
            su.mobile_number as mobileNumber
        from
            t_b_crm tbc
            left join t_b_service tbs on tbs.id = tbc.service_id
            left join sys_custom sc on sc.id = tbc.custom_id
            left join sys_user su on su.id = #{userId}
        where
            tbc.crm_no = #{crmNo} limit 1
    </select>
</mapper>
