<?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.ms.dal.mapper.PlatformPurchaseOrderMapper">

    <resultMap id="BaseResultMap" type="com.ms.dal.entity.PlatformPurchaseOrder">
            <id property="purOrderId" column="pur_order_id" jdbcType="VARCHAR"/>
            <result property="orderId" column="order_id" jdbcType="VARCHAR"/>
            <result property="shopId" column="shop_id" jdbcType="BIGINT"/>
            <result property="outPreOrderId" column="out_pre_order_id" jdbcType="VARCHAR"/>
            <result property="supplierOrderId" column="supplier_order_id" jdbcType="VARCHAR"/>
            <result property="supplierOrderH5Url" column="supplier_order_h5_url" jdbcType="VARCHAR"/>
            <result property="supplierOrderPcUrl" column="supplier_order_pc_url" jdbcType="VARCHAR"/>
            <result property="purchaseStatus" column="purchase_status" jdbcType="VARCHAR"/>
            <result property="status" column="status" jdbcType="VARCHAR"/>
            <result property="payH5Url" column="pay_h5_url" jdbcType="VARCHAR"/>
            <result property="payPcUrl" column="pay_pc_url" jdbcType="VARCHAR"/>
            <result property="gmtCreate" column="gmt_create" jdbcType="TIMESTAMP"/>
            <result property="gmtModified" column="gmt_modified" jdbcType="TIMESTAMP"/>
    </resultMap>

    <sql id="Base_Column_List">
        pur_order_id,order_id,shop_id,
        out_pre_order_id,supplier_order_id,supplier_order_h5_url,
        supplier_order_pc_url,purchase_status,status,
        pay_h5_url,pay_pc_url,gmt_create,
        gmt_modified
    </sql>

    <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from platform_purchase_order
        where  pur_order_id = #{purOrderId,jdbcType=VARCHAR} 
    </select>
    <select id="getListByPurOrderIds" resultType="com.ms.dal.entity.PlatformPurchaseOrder">
        select
        <include refid="Base_Column_List" />
        from platform_purchase_order
        where 1=1
        <choose>
            <when test="purOrderIds!=null and purOrderIds.size>0">
                and pur_order_id in
                <foreach collection="purOrderIds" item="purOrderId" index="index" open="(" close=")" separator=",">
                    #{purOrderId}
                </foreach>
            </when>
            <otherwise>
                AND 1=0
            </otherwise>
        </choose>
    </select>

    <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
        delete from platform_purchase_order
        where  pur_order_id = #{purOrderId,jdbcType=VARCHAR} 
    </delete>
    <insert id="insert" keyColumn="pur_order_id" keyProperty="purOrderId" parameterType="com.ms.dal.entity.PlatformPurchaseOrder" useGeneratedKeys="true">
        insert into platform_purchase_order
        ( pur_order_id,order_id,shop_id
        ,out_pre_order_id,supplier_order_id,supplier_order_h5_url
        ,supplier_order_pc_url,purchase_status,status
        ,pay_h5_url,pay_pc_url,gmt_create
        ,gmt_modified)
        values (#{purOrderId,jdbcType=VARCHAR},#{orderId,jdbcType=VARCHAR},#{shopId,jdbcType=BIGINT}
        ,#{outPreOrderId,jdbcType=VARCHAR},#{supplierOrderId,jdbcType=VARCHAR},#{supplierOrderH5Url,jdbcType=VARCHAR}
        ,#{supplierOrderPcUrl,jdbcType=VARCHAR},#{purchaseStatus,jdbcType=VARCHAR},#{status,jdbcType=VARCHAR}
        ,#{payH5Url,jdbcType=VARCHAR},#{payPcUrl,jdbcType=VARCHAR},#{gmtCreate,jdbcType=TIMESTAMP}
        ,#{gmtModified,jdbcType=TIMESTAMP})
    </insert>
    <update id="insertOrUpdate"  keyColumn="pur_order_id" keyProperty="purOrderId" parameterType="com.ms.dal.entity.PlatformPurchaseOrder"
        useGeneratedKeys="true">
        insert into platform_purchase_order
        <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="purOrderId != null">pur_order_id,</if>
                <if test="orderId != null">order_id,</if>
                <if test="shopId != null">shop_id,</if>
                <if test="outPreOrderId != null">out_pre_order_id,</if>
                <if test="supplierOrderId != null">supplier_order_id,</if>
                <if test="supplierOrderH5Url != null">supplier_order_h5_url,</if>
                <if test="supplierOrderPcUrl != null">supplier_order_pc_url,</if>
                <if test="purchaseStatus != null">purchase_status,</if>
                <if test="status != null">status,</if>
                <if test="payH5Url != null">pay_h5_url,</if>
                <if test="payPcUrl != null">pay_pc_url,</if>
                <if test="gmtCreate != null">gmt_create,</if>
                <if test="gmtModified != null">gmt_modified,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test="purOrderId != null">#{purOrderId,jdbcType=VARCHAR},</if>
                <if test="orderId != null">#{orderId,jdbcType=VARCHAR},</if>
                <if test="shopId != null">#{shopId,jdbcType=BIGINT},</if>
                <if test="outPreOrderId != null">#{outPreOrderId,jdbcType=VARCHAR},</if>
                <if test="supplierOrderId != null">#{supplierOrderId,jdbcType=VARCHAR},</if>
                <if test="supplierOrderH5Url != null">#{supplierOrderH5Url,jdbcType=VARCHAR},</if>
                <if test="supplierOrderPcUrl != null">#{supplierOrderPcUrl,jdbcType=VARCHAR},</if>
                <if test="purchaseStatus != null">#{purchaseStatus,jdbcType=VARCHAR},</if>
                <if test="status != null">#{status,jdbcType=VARCHAR},</if>
                <if test="payH5Url != null">#{payH5Url,jdbcType=VARCHAR},</if>
                <if test="payPcUrl != null">#{payPcUrl,jdbcType=VARCHAR},</if>
                <if test="gmtCreate != null">#{gmtCreate,jdbcType=TIMESTAMP},</if>
                <if test="gmtModified != null">#{gmtModified,jdbcType=TIMESTAMP},</if>
        </trim>
        ON DUPLICATE KEY UPDATE
        <trim  suffixOverrides=",">
                <if test="orderId != null">
                    order_id = #{orderId,jdbcType=VARCHAR},
                </if>
                <if test="shopId != null">
                    shop_id = #{shopId,jdbcType=BIGINT},
                </if>
                <if test="outPreOrderId != null">
                    out_pre_order_id = #{outPreOrderId,jdbcType=VARCHAR},
                </if>
                <if test="supplierOrderId != null">
                    supplier_order_id = #{supplierOrderId,jdbcType=VARCHAR},
                </if>
                <if test="supplierOrderH5Url != null">
                    supplier_order_h5_url = #{supplierOrderH5Url,jdbcType=VARCHAR},
                </if>
                <if test="supplierOrderPcUrl != null">
                    supplier_order_pc_url = #{supplierOrderPcUrl,jdbcType=VARCHAR},
                </if>
                <if test="purchaseStatus != null">
                    purchase_status = #{purchaseStatus,jdbcType=VARCHAR},
                </if>
                <if test="status != null">
                    status = #{status,jdbcType=VARCHAR},
                </if>
                <if test="payH5Url != null">
                    pay_h5_url = #{payH5Url,jdbcType=VARCHAR},
                </if>
                <if test="payPcUrl != null">
                    pay_pc_url = #{payPcUrl,jdbcType=VARCHAR},
                </if>
                <if test="gmtCreate != null">
                    gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
                </if>
                <if test="gmtModified != null">
                    gmt_modified = #{gmtModified,jdbcType=TIMESTAMP},
                </if>
        </trim>
    </update>
    <insert id="insertSelective" keyColumn="pur_order_id" keyProperty="purOrderId" parameterType="com.ms.dal.entity.PlatformPurchaseOrder" useGeneratedKeys="true">
        insert into platform_purchase_order
        <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="purOrderId != null">pur_order_id,</if>
                <if test="orderId != null">order_id,</if>
                <if test="shopId != null">shop_id,</if>
                <if test="outPreOrderId != null">out_pre_order_id,</if>
                <if test="supplierOrderId != null">supplier_order_id,</if>
                <if test="supplierOrderH5Url != null">supplier_order_h5_url,</if>
                <if test="supplierOrderPcUrl != null">supplier_order_pc_url,</if>
                <if test="purchaseStatus != null">purchase_status,</if>
                <if test="status != null">status,</if>
                <if test="payH5Url != null">pay_h5_url,</if>
                <if test="payPcUrl != null">pay_pc_url,</if>
                <if test="gmtCreate != null">gmt_create,</if>
                <if test="gmtModified != null">gmt_modified,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test="purOrderId != null">#{purOrderId,jdbcType=VARCHAR},</if>
                <if test="orderId != null">#{orderId,jdbcType=VARCHAR},</if>
                <if test="shopId != null">#{shopId,jdbcType=BIGINT},</if>
                <if test="outPreOrderId != null">#{outPreOrderId,jdbcType=VARCHAR},</if>
                <if test="supplierOrderId != null">#{supplierOrderId,jdbcType=VARCHAR},</if>
                <if test="supplierOrderH5Url != null">#{supplierOrderH5Url,jdbcType=VARCHAR},</if>
                <if test="supplierOrderPcUrl != null">#{supplierOrderPcUrl,jdbcType=VARCHAR},</if>
                <if test="purchaseStatus != null">#{purchaseStatus,jdbcType=VARCHAR},</if>
                <if test="status != null">#{status,jdbcType=VARCHAR},</if>
                <if test="payH5Url != null">#{payH5Url,jdbcType=VARCHAR},</if>
                <if test="payPcUrl != null">#{payPcUrl,jdbcType=VARCHAR},</if>
                <if test="gmtCreate != null">#{gmtCreate,jdbcType=TIMESTAMP},</if>
                <if test="gmtModified != null">#{gmtModified,jdbcType=TIMESTAMP},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.ms.dal.entity.PlatformPurchaseOrder">
        update platform_purchase_order
        <set>
                <if test="orderId != null">
                    order_id = #{orderId,jdbcType=VARCHAR},
                </if>
                <if test="shopId != null">
                    shop_id = #{shopId,jdbcType=BIGINT},
                </if>
                <if test="outPreOrderId != null">
                    out_pre_order_id = #{outPreOrderId,jdbcType=VARCHAR},
                </if>
                <if test="supplierOrderId != null">
                    supplier_order_id = #{supplierOrderId,jdbcType=VARCHAR},
                </if>
                <if test="supplierOrderH5Url != null">
                    supplier_order_h5_url = #{supplierOrderH5Url,jdbcType=VARCHAR},
                </if>
                <if test="supplierOrderPcUrl != null">
                    supplier_order_pc_url = #{supplierOrderPcUrl,jdbcType=VARCHAR},
                </if>
                <if test="purchaseStatus != null">
                    purchase_status = #{purchaseStatus,jdbcType=VARCHAR},
                </if>
                <if test="status != null">
                    status = #{status,jdbcType=VARCHAR},
                </if>
                <if test="payH5Url != null">
                    pay_h5_url = #{payH5Url,jdbcType=VARCHAR},
                </if>
                <if test="payPcUrl != null">
                    pay_pc_url = #{payPcUrl,jdbcType=VARCHAR},
                </if>
                <if test="gmtCreate != null">
                    gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
                </if>
                <if test="gmtModified != null">
                    gmt_modified = #{gmtModified,jdbcType=TIMESTAMP},
                </if>
        </set>
        where   pur_order_id = #{purOrderId,jdbcType=VARCHAR} 
    </update>
    <update id="updateByPrimaryKey" parameterType="com.ms.dal.entity.PlatformPurchaseOrder">
        update platform_purchase_order
        set 
            order_id =  #{orderId,jdbcType=VARCHAR},
            shop_id =  #{shopId,jdbcType=BIGINT},
            out_pre_order_id =  #{outPreOrderId,jdbcType=VARCHAR},
            supplier_order_id =  #{supplierOrderId,jdbcType=VARCHAR},
            supplier_order_h5_url =  #{supplierOrderH5Url,jdbcType=VARCHAR},
            supplier_order_pc_url =  #{supplierOrderPcUrl,jdbcType=VARCHAR},
            purchase_status =  #{purchaseStatus,jdbcType=VARCHAR},
            status =  #{status,jdbcType=VARCHAR},
            pay_h5_url =  #{payH5Url,jdbcType=VARCHAR},
            pay_pc_url =  #{payPcUrl,jdbcType=VARCHAR},
            gmt_create =  #{gmtCreate,jdbcType=TIMESTAMP},
            gmt_modified =  #{gmtModified,jdbcType=TIMESTAMP}
        where   pur_order_id = #{purOrderId,jdbcType=VARCHAR} 
    </update>
</mapper>
