<?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.SysCustomReceiverMapper">

    <select id="listCustom" resultType="com.qmth.sop.business.entity.SysCustomReceiver" parameterType="com.qmth.sop.common.enums.ProductTypeEnum">
        select distinct name from sys_custom_receiver
        <where>
            <if test="type !=null">
                AND type=#{type}
            </if>
        </where>
    </select>

    <select id="page" resultType="com.qmth.sop.business.bean.result.SysCustomReceiverResult">
        SELECT
        r.id,
        r.type,
        r.NAME,
        r.unit,
        r.consignee,
        r.consignee_phone consigneePhone,
        r.consignee_address consigneeAddress
        FROM
        sys_custom_receiver r
        <where>
            <if test="type != null">
                AND r.type=#{type}
            </if>
            <if test="name != null and name != ''">
                AND r.name=#{name}
            </if>
            <if test="dpr != null and !dpr.hasAdmin and !dpr.hasPmo and !dpr.hasBusiness">
                <if test="dpr.hasAccountManager">
                    AND r.create_id = #{dpr.requestUserId}
                </if>
            </if>
        </where>
        order by r.update_time desc
    </select>

    <select id="listCustomReceiver" resultType="com.qmth.sop.business.bean.result.SysCustomReceiverResult">
        SELECT
        r.type,
        r.NAME,
        r.unit,
        r.consignee,
        r.consignee_phone consigneePhone,
        r.consignee_address consigneeAddress
        FROM
        sys_custom_receiver r
        <where>
            <if test="type != null">
                AND r.type=#{type}
            </if>
            <if test="name != null and name != ''">
                AND r.name=#{name}
            </if>
            <if test="dpr != null and !dpr.hasAdmin and !dpr.hasPmo and !dpr.hasBusiness">
                <if test="dpr.hasAccountManager">
                    AND r.create_id = #{dpr.requestUserId}
                </if>
            </if>
        </where>
        order by r.update_time desc
    </select>

</mapper>