<?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.OmsLogisticsMapper">
    
    <resultMap type="OmsLogistics" id="OmsLogisticsResult">
        <result property="id"    column="id"    />
        <result property="logisticsNo"    column="logistics_no"    />
        <result property="logisticsBusinessid"    column="logistics_businessId"    />
        <result property="logisticsBusinessName"    column="logistics_business_name"    />
        <result property="logisticsAmount"    column="logistics_amount"    />
        <result property="logisticsStatus"    column="logistics_status"    />
        <result property="logisticsPayStatus"    column="logistics_pay_status"    />
        <result property="logisticsType"    column="logistics_type"    />
        <result property="businessType"    column="business_type"    />
        <result property="logisticsTime"    column="logistics_time"    />
        <result property="logisticsPayTime"    column="logistics_pay_time"    />
        <result property="userName"    column="user_name"    />
        <result property="userPhone"    column="user_phone"    />
        <result property="userAddress"    column="user_address"    />
        <result property="userRemark"    column="user_remark"    />
        <result property="serviceRemark"    column="service_remark"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectOmsLogisticsVo">
        select id, logistics_no, logistics_businessId, logistics_business_name, logistics_amount, logistics_status, logistics_pay_status, logistics_type, business_type, logistics_time, logistics_pay_time, user_name, user_phone, user_address, user_remark, service_remark, create_time, update_time from oms_logistics
    </sql>

    <select id="selectOmsLogisticsList" parameterType="OmsLogistics" resultMap="OmsLogisticsResult">
        <include refid="selectOmsLogisticsVo"/>
        <where>  
            <if test="logisticsNo != null  and logisticsNo != ''"> and logistics_no = #{logisticsNo}</if>
            <if test="logisticsBusinessid != null  and logisticsBusinessid != ''"> and logistics_businessId = #{logisticsBusinessid}</if>
            <if test="logisticsBusinessName != null  and logisticsBusinessName != ''"> and logistics_business_name like concat('%', #{logisticsBusinessName}, '%')</if>
            <if test="logisticsAmount != null "> and logistics_amount = #{logisticsAmount}</if>
            <if test="logisticsStatus != null "> and logistics_status = #{logisticsStatus}</if>
            <if test="logisticsPayStatus != null "> and logistics_pay_status = #{logisticsPayStatus}</if>
            <if test="logisticsType != null  and logisticsType != ''"> and logistics_type = #{logisticsType}</if>
            <if test="businessType != null "> and business_type = #{businessType}</if>
            <if test="logisticsTime != null  and logisticsTime != ''"> and logistics_time = #{logisticsTime}</if>
            <if test="logisticsPayTime != null  and logisticsPayTime != ''"> and logistics_pay_time = #{logisticsPayTime}</if>
            <if test="userName != null  and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
            <if test="userPhone != null  and userPhone != ''"> and user_phone = #{userPhone}</if>
            <if test="userAddress != null  and userAddress != ''"> and user_address = #{userAddress}</if>
            <if test="userRemark != null  and userRemark != ''"> and user_remark = #{userRemark}</if>
            <if test="serviceRemark != null  and serviceRemark != ''"> and service_remark = #{serviceRemark}</if>
            <if test="createTime != null "> and create_time = #{createTime}</if>
        </where>
    </select>
    
    <select id="selectOmsLogisticsById" parameterType="Long" resultMap="OmsLogisticsResult">
        <include refid="selectOmsLogisticsVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertOmsLogistics" parameterType="OmsLogistics" useGeneratedKeys="true" keyProperty="id">
        insert into oms_logistics
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="logisticsNo != null">logistics_no,</if>
            <if test="logisticsBusinessid != null and logisticsBusinessid != ''">logistics_businessId,</if>
            <if test="logisticsBusinessName != null">logistics_business_name,</if>
            <if test="logisticsAmount != null">logistics_amount,</if>
            <if test="logisticsStatus != null">logistics_status,</if>
            <if test="logisticsPayStatus != null">logistics_pay_status,</if>
            <if test="logisticsType != null">logistics_type,</if>
            <if test="businessType != null">business_type,</if>
            <if test="logisticsTime != null">logistics_time,</if>
            <if test="logisticsPayTime != null">logistics_pay_time,</if>
            <if test="userName != null and userName != ''">user_name,</if>
            <if test="userPhone != null and userPhone != ''">user_phone,</if>
            <if test="userAddress != null and userAddress != ''">user_address,</if>
            <if test="userRemark != null">user_remark,</if>
            <if test="serviceRemark != null">service_remark,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="logisticsNo != null">#{logisticsNo},</if>
            <if test="logisticsBusinessid != null and logisticsBusinessid != ''">#{logisticsBusinessid},</if>
            <if test="logisticsBusinessName != null">#{logisticsBusinessName},</if>
            <if test="logisticsAmount != null">#{logisticsAmount},</if>
            <if test="logisticsStatus != null">#{logisticsStatus},</if>
            <if test="logisticsPayStatus != null">#{logisticsPayStatus},</if>
            <if test="logisticsType != null">#{logisticsType},</if>
            <if test="businessType != null">#{businessType},</if>
            <if test="logisticsTime != null">#{logisticsTime},</if>
            <if test="logisticsPayTime != null">#{logisticsPayTime},</if>
            <if test="userName != null and userName != ''">#{userName},</if>
            <if test="userPhone != null and userPhone != ''">#{userPhone},</if>
            <if test="userAddress != null and userAddress != ''">#{userAddress},</if>
            <if test="userRemark != null">#{userRemark},</if>
            <if test="serviceRemark != null">#{serviceRemark},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateOmsLogistics" parameterType="OmsLogistics">
        update oms_logistics
        <trim prefix="SET" suffixOverrides=",">
            <if test="logisticsNo != null">logistics_no = #{logisticsNo},</if>
            <if test="logisticsBusinessid != null and logisticsBusinessid != ''">logistics_businessId = #{logisticsBusinessid},</if>
            <if test="logisticsBusinessName != null">logistics_business_name = #{logisticsBusinessName},</if>
            <if test="logisticsAmount != null">logistics_amount = #{logisticsAmount},</if>
            <if test="logisticsStatus != null">logistics_status = #{logisticsStatus},</if>
            <if test="logisticsPayStatus != null">logistics_pay_status = #{logisticsPayStatus},</if>
            <if test="logisticsType != null">logistics_type = #{logisticsType},</if>
            <if test="businessType != null">business_type = #{businessType},</if>
            <if test="logisticsTime != null">logistics_time = #{logisticsTime},</if>
            <if test="logisticsPayTime != null">logistics_pay_time = #{logisticsPayTime},</if>
            <if test="userName != null and userName != ''">user_name = #{userName},</if>
            <if test="userPhone != null and userPhone != ''">user_phone = #{userPhone},</if>
            <if test="userAddress != null and userAddress != ''">user_address = #{userAddress},</if>
            <if test="userRemark != null">user_remark = #{userRemark},</if>
            <if test="serviceRemark != null">service_remark = #{serviceRemark},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteOmsLogisticsById" parameterType="Long">
        delete from oms_logistics where id = #{id}
    </delete>

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