<?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.fs.oms.mapper.OmsSupplierMapper">

    <resultMap type="OmsSupplier" id="OmsSupplierResult">
        <result property="id"    column="id"    />
        <result property="code"    column="code"    />
        <result property="name"    column="name"    />
        <result property="type"    column="type"    />
        <result property="level"    column="level"    />
        <result property="cycleDay"    column="cycle_day"    />
        <result property="invoiceType"    column="invoice_type"    />
        <result property="overfillRate"    column="overfill_rate"    />
        <result property="taxRate"    column="tax_rate"    />
        <result property="paymentType"    column="payment_type"    />
        <result property="fullName"    column="full_name"    />
        <result property="mnemonic"    column="mnemonic"    />
        <result property="cooperationTime"    column="cooperation_time"    />
        <result property="contactName"    column="contact_name"    />
        <result property="contractTel"    column="contract_tel"    />
        <result property="contactPhone"    column="contact_phone"    />
        <result property="cityIds"    column="city_ids"    />
        <result property="address"    column="address"    />
        <result property="bankName"    column="bank_name"    />
        <result property="bankDeposit"    column="bank_deposit"    />
        <result property="bankAccount"    column="bank_account"    />
        <result property="remark"    column="remark"    />
        <result property="status"    column="status"    />
        <result property="createUserId"    column="create_user_id"    />
        <result property="updateUserId"    column="update_user_id"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectOmsSupplierVo">
        select id, code, name, type, level, cycle_day, invoice_type, overfill_rate, tax_rate, payment_type, full_name, mnemonic, cooperation_time, contact_name, contract_tel, contact_phone, city_ids, address, bank_name, bank_deposit, bank_account, remark, status, create_user_id, update_user_id, create_time, update_time from oms_supplier
    </sql>

    <select id="selectOmsSupplierList" parameterType="OmsSupplier" resultMap="OmsSupplierResult">
        <include refid="selectOmsSupplierVo"/>
        <where>
            <if test="code != null  and code != ''"> and code = #{code}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="level != null  and level != ''"> and level = #{level}</if>
            <if test="cycleDay != null "> and cycle_day = #{cycleDay}</if>
            <if test="invoiceType != null "> and invoice_type = #{invoiceType}</if>
            <if test="overfillRate != null "> and overfill_rate = #{overfillRate}</if>
            <if test="taxRate != null "> and tax_rate = #{taxRate}</if>
            <if test="paymentType != null  and paymentType != ''"> and payment_type = #{paymentType}</if>
            <if test="fullName != null  and fullName != ''"> and full_name like concat('%', #{fullName}, '%')</if>
            <if test="mnemonic != null  and mnemonic != ''"> and mnemonic = #{mnemonic}</if>
            <if test="cooperationTime != null  and cooperationTime != ''"> and cooperation_time = #{cooperationTime}</if>
            <if test="contactName != null  and contactName != ''"> and contact_name like concat('%', #{contactName}, '%')</if>
            <if test="contractTel != null  and contractTel != ''"> and contract_tel = #{contractTel}</if>
            <if test="contactPhone != null  and contactPhone != ''"> and contact_phone = #{contactPhone}</if>
            <if test="cityIds != null  and cityIds != ''"> and city_ids = #{cityIds}</if>
            <if test="address != null  and address != ''"> and address = #{address}</if>
            <if test="bankName != null  and bankName != ''"> and bank_name like concat('%', #{bankName}, '%')</if>
            <if test="bankDeposit != null  and bankDeposit != ''"> and bank_deposit = #{bankDeposit}</if>
            <if test="bankAccount != null  and bankAccount != ''"> and bank_account = #{bankAccount}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="createUserId != null "> and create_user_id = #{createUserId}</if>
            <if test="updateUserId != null "> and update_user_id = #{updateUserId}</if>
        </where>
    </select>

    <select id="selectSupplierExportVO" parameterType="OmsSupplier" resultMap="OmsSupplierResult">
        <include refid="selectOmsSupplierVo"/>
        <where>
            <if test="code != null  and code != ''"> and code = #{code}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="level != null  and level != ''"> and level = #{level}</if>
            <if test="cycleDay != null "> and cycle_day = #{cycleDay}</if>
            <if test="invoiceType != null "> and invoice_type = #{invoiceType}</if>
            <if test="overfillRate != null "> and overfill_rate = #{overfillRate}</if>
            <if test="taxRate != null "> and tax_rate = #{taxRate}</if>
            <if test="paymentType != null  and paymentType != ''"> and payment_type = #{paymentType}</if>
            <if test="fullName != null  and fullName != ''"> and full_name like concat('%', #{fullName}, '%')</if>
            <if test="mnemonic != null  and mnemonic != ''"> and mnemonic = #{mnemonic}</if>
            <if test="cooperationTime != null  and cooperationTime != ''"> and cooperation_time = #{cooperationTime}</if>
            <if test="contactName != null  and contactName != ''"> and contact_name like concat('%', #{contactName}, '%')</if>
            <if test="contractTel != null  and contractTel != ''"> and contract_tel = #{contractTel}</if>
            <if test="contactPhone != null  and contactPhone != ''"> and contact_phone = #{contactPhone}</if>
            <if test="cityIds != null  and cityIds != ''"> and city_ids = #{cityIds}</if>
            <if test="address != null  and address != ''"> and address = #{address}</if>
            <if test="bankName != null  and bankName != ''"> and bank_name like concat('%', #{bankName}, '%')</if>
            <if test="bankDeposit != null  and bankDeposit != ''"> and bank_deposit = #{bankDeposit}</if>
            <if test="bankAccount != null  and bankAccount != ''"> and bank_account = #{bankAccount}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="createUserId != null "> and create_user_id = #{createUserId}</if>
            <if test="updateUserId != null "> and update_user_id = #{updateUserId}</if>
        </where>
    </select>

    <select id="selectOmsSupplierByStatus" parameterType="OmsSupplier" resultMap="OmsSupplierResult">
        <include refid="selectOmsSupplierVo"/>
        where status = 1
    </select>

    <select id="selectOmsSupplierById" parameterType="Long" resultMap="OmsSupplierResult">
        <include refid="selectOmsSupplierVo"/>
        where id = #{id}
    </select>

    <insert id="insertOmsSupplier" parameterType="OmsSupplier" useGeneratedKeys="true" keyProperty="id">
        insert into oms_supplier
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="code != null">code,</if>
            <if test="name != null">name,</if>
            <if test="type != null">type,</if>
            <if test="level != null">level,</if>
            <if test="cycleDay != null">cycle_day,</if>
            <if test="invoiceType != null">invoice_type,</if>
            <if test="overfillRate != null">overfill_rate,</if>
            <if test="taxRate != null">tax_rate,</if>
            <if test="paymentType != null">payment_type,</if>
            <if test="fullName != null">full_name,</if>
            <if test="mnemonic != null">mnemonic,</if>
            <if test="cooperationTime != null">cooperation_time,</if>
            <if test="contactName != null">contact_name,</if>
            <if test="contractTel != null">contract_tel,</if>
            <if test="contactPhone != null">contact_phone,</if>
            <if test="cityIds != null">city_ids,</if>
            <if test="address != null">address,</if>
            <if test="bankName != null">bank_name,</if>
            <if test="bankDeposit != null">bank_deposit,</if>
            <if test="bankAccount != null">bank_account,</if>
            <if test="remark != null">remark,</if>
            <if test="status != null">status,</if>
            <if test="createUserId != null">create_user_id,</if>
            <if test="updateUserId != null">update_user_id,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="code != null">#{code},</if>
            <if test="name != null">#{name},</if>
            <if test="type != null">#{type},</if>
            <if test="level != null">#{level},</if>
            <if test="cycleDay != null">#{cycleDay},</if>
            <if test="invoiceType != null">#{invoiceType},</if>
            <if test="overfillRate != null">#{overfillRate},</if>
            <if test="taxRate != null">#{taxRate},</if>
            <if test="paymentType != null">#{paymentType},</if>
            <if test="fullName != null">#{fullName},</if>
            <if test="mnemonic != null">#{mnemonic},</if>
            <if test="cooperationTime != null">#{cooperationTime},</if>
            <if test="contactName != null">#{contactName},</if>
            <if test="contractTel != null">#{contractTel},</if>
            <if test="contactPhone != null">#{contactPhone},</if>
            <if test="cityIds != null">#{cityIds},</if>
            <if test="address != null">#{address},</if>
            <if test="bankName != null">#{bankName},</if>
            <if test="bankDeposit != null">#{bankDeposit},</if>
            <if test="bankAccount != null">#{bankAccount},</if>
            <if test="remark != null">#{remark},</if>
            <if test="status != null">#{status},</if>
            <if test="createUserId != null">#{createUserId},</if>
            <if test="updateUserId != null">#{updateUserId},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateOmsSupplier" parameterType="OmsSupplier">
        update oms_supplier
        <trim prefix="SET" suffixOverrides=",">
            <if test="code != null">code = #{code},</if>
            <if test="name != null">name = #{name},</if>
            <if test="type != null">type = #{type},</if>
            <if test="level != null">level = #{level},</if>
            <if test="cycleDay != null">cycle_day = #{cycleDay},</if>
            <if test="invoiceType != null">invoice_type = #{invoiceType},</if>
            <if test="overfillRate != null">overfill_rate = #{overfillRate},</if>
            <if test="taxRate != null">tax_rate = #{taxRate},</if>
            <if test="paymentType != null">payment_type = #{paymentType},</if>
            <if test="fullName != null">full_name = #{fullName},</if>
            <if test="mnemonic != null">mnemonic = #{mnemonic},</if>
            <if test="cooperationTime != null">cooperation_time = #{cooperationTime},</if>
            <if test="contactName != null">contact_name = #{contactName},</if>
            <if test="contractTel != null">contract_tel = #{contractTel},</if>
            <if test="contactPhone != null">contact_phone = #{contactPhone},</if>
            <if test="cityIds != null">city_ids = #{cityIds},</if>
            <if test="address != null">address = #{address},</if>
            <if test="bankName != null">bank_name = #{bankName},</if>
            <if test="bankDeposit != null">bank_deposit = #{bankDeposit},</if>
            <if test="bankAccount != null">bank_account = #{bankAccount},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="status != null">status = #{status},</if>
            <if test="createUserId != null">create_user_id = #{createUserId},</if>
            <if test="updateUserId != null">update_user_id = #{updateUserId},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteOmsSupplierById" parameterType="Long">
        delete from oms_supplier where id = #{id}
    </delete>

    <delete id="deleteOmsSupplierByIds" parameterType="String">
        delete from oms_supplier where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

</mapper>
