<?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.game.business.mapper.ShopSubOrderMapper">
    
    <resultMap type="com.game.business.domain.ShopSubOrder" id="ShopSubOrderResult">
        <result property="id"    column="id"    />
        <result property="addTime"    column="add_time"    />
        <result property="businessId"    column="business_id"    />
        <result property="businessOrderId"    column="business_order_id"    />
        <result property="composeId"    column="compose_id"    />
        <result property="goodsId"    column="goods_id"    />
        <result property="goodsName"    column="goods_name"    />
        <result property="goodsNum"    column="goods_num"    />
        <result property="goodsPicture"    column="goods_picture"    />
        <result property="goodsPrice"    column="goods_price"    />
        <result property="logisticsName"    column="logistics_name"    />
        <result property="logisticsNum"    column="logistics_num"    />
        <result property="orderNum"    column="order_num"    />
        <result property="payId"    column="pay_id"    />
        <result property="remake"    column="remake"    />
        <result property="skuName"    column="sku_name"    />
        <result property="status"    column="status"    />
    </resultMap>

    <sql id="selectShopSubOrderVo">
        select id, add_time, business_id, business_order_id, compose_id, goods_id, goods_name, goods_num, goods_picture, goods_price, logistics_name, logistics_num, order_num, pay_id, remake, sku_name, status from shop_sub_order
    </sql>

    <select id="selectShopSubOrderList" parameterType="com.game.business.domain.ShopSubOrder" resultMap="ShopSubOrderResult">
        <include refid="selectShopSubOrderVo"/>
        <where>  
            <if test="addTime != null "> and add_time = #{addTime}</if>
            <if test="businessId != null "> and business_id = #{businessId}</if>
            <if test="businessOrderId != null "> and business_order_id = #{businessOrderId}</if>
            <if test="composeId != null "> and compose_id = #{composeId}</if>
            <if test="goodsId != null "> and goods_id = #{goodsId}</if>
            <if test="goodsName != null  and goodsName != ''"> and goods_name like concat('%', #{goodsName}, '%')</if>
            <if test="goodsNum != null "> and goods_num = #{goodsNum}</if>
            <if test="goodsPicture != null  and goodsPicture != ''"> and goods_picture = #{goodsPicture}</if>
            <if test="goodsPrice != null "> and goods_price = #{goodsPrice}</if>
            <if test="logisticsName != null  and logisticsName != ''"> and logistics_name like concat('%', #{logisticsName}, '%')</if>
            <if test="logisticsNum != null  and logisticsNum != ''"> and logistics_num = #{logisticsNum}</if>
            <if test="orderNum != null  and orderNum != ''"> and order_num = #{orderNum}</if>
            <if test="payId != null "> and pay_id = #{payId}</if>
            <if test="remake != null  and remake != ''"> and remake = #{remake}</if>
            <if test="skuName != null  and skuName != ''"> and sku_name like concat('%', #{skuName}, '%')</if>
            <if test="status != null "> and status = #{status}</if>
        </where>
    </select>
    
    <select id="selectShopSubOrderById" parameterType="Long" resultMap="ShopSubOrderResult">
        <include refid="selectShopSubOrderVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertShopSubOrder" parameterType="com.game.business.domain.ShopSubOrder">
        insert into shop_sub_order
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="addTime != null">add_time,</if>
            <if test="businessId != null">business_id,</if>
            <if test="businessOrderId != null">business_order_id,</if>
            <if test="composeId != null">compose_id,</if>
            <if test="goodsId != null">goods_id,</if>
            <if test="goodsName != null">goods_name,</if>
            <if test="goodsNum != null">goods_num,</if>
            <if test="goodsPicture != null">goods_picture,</if>
            <if test="goodsPrice != null">goods_price,</if>
            <if test="logisticsName != null">logistics_name,</if>
            <if test="logisticsNum != null">logistics_num,</if>
            <if test="orderNum != null">order_num,</if>
            <if test="payId != null">pay_id,</if>
            <if test="remake != null">remake,</if>
            <if test="skuName != null">sku_name,</if>
            <if test="status != null">status,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="addTime != null">#{addTime},</if>
            <if test="businessId != null">#{businessId},</if>
            <if test="businessOrderId != null">#{businessOrderId},</if>
            <if test="composeId != null">#{composeId},</if>
            <if test="goodsId != null">#{goodsId},</if>
            <if test="goodsName != null">#{goodsName},</if>
            <if test="goodsNum != null">#{goodsNum},</if>
            <if test="goodsPicture != null">#{goodsPicture},</if>
            <if test="goodsPrice != null">#{goodsPrice},</if>
            <if test="logisticsName != null">#{logisticsName},</if>
            <if test="logisticsNum != null">#{logisticsNum},</if>
            <if test="orderNum != null">#{orderNum},</if>
            <if test="payId != null">#{payId},</if>
            <if test="remake != null">#{remake},</if>
            <if test="skuName != null">#{skuName},</if>
            <if test="status != null">#{status},</if>
         </trim>
    </insert>

    <update id="updateShopSubOrder" parameterType="com.game.business.domain.ShopSubOrder">
        update shop_sub_order
        <trim prefix="SET" suffixOverrides=",">
            <if test="addTime != null">add_time = #{addTime},</if>
            <if test="businessId != null">business_id = #{businessId},</if>
            <if test="businessOrderId != null">business_order_id = #{businessOrderId},</if>
            <if test="composeId != null">compose_id = #{composeId},</if>
            <if test="goodsId != null">goods_id = #{goodsId},</if>
            <if test="goodsName != null">goods_name = #{goodsName},</if>
            <if test="goodsNum != null">goods_num = #{goodsNum},</if>
            <if test="goodsPicture != null">goods_picture = #{goodsPicture},</if>
            <if test="goodsPrice != null">goods_price = #{goodsPrice},</if>
            <if test="logisticsName != null">logistics_name = #{logisticsName},</if>
            <if test="logisticsNum != null">logistics_num = #{logisticsNum},</if>
            <if test="orderNum != null">order_num = #{orderNum},</if>
            <if test="payId != null">pay_id = #{payId},</if>
            <if test="remake != null">remake = #{remake},</if>
            <if test="skuName != null">sku_name = #{skuName},</if>
            <if test="status != null">status = #{status},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteShopSubOrderById" parameterType="Long">
        delete from shop_sub_order where id = #{id}
    </delete>

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