<?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">
<!--mybatis-3-mapper.dtd:约束文件的名称，限制和检查在当前文件中出现的标签和属性符合mybatis的要求-->
<!--namespace：命名空间，要有唯一的值，要求使用dao接口的权限定名称（一个dao接口对应一个mapper，namespace指明对应哪个dao接口）-->
<mapper namespace="com.cool.store.mapper.OrderSysInfoMapper">
    <resultMap id="BaseResultMap" type="com.cool.store.entity.OrderSysInfoDO">
        <id property="id" column="id" jdbcType="BIGINT"/>
        <result property="shopId" column="shop_id" jdbcType="BIGINT"/>
        <result property="xgjVicePresident" column="xgj_vice_president" jdbcType="VARCHAR"/>
        <result property="xgjRegionId" column="xgj_region_id" jdbcType="VARCHAR"/>
        <result property="xgjRegionName" column="xgj_region_name" jdbcType="VARCHAR"/>
        <result property="addresseeName" column="addressee_name" jdbcType="VARCHAR"/>
        <result property="addresseeMobile" column="addressee_mobile" jdbcType="VARCHAR"/>
        <result property="addresseeProvince" column="addressee_province" jdbcType="VARCHAR"/>
        <result property="addresseeCity" column="addressee_city" jdbcType="VARCHAR"/>
        <result property="addresseeDistrict" column="addressee_district" jdbcType="VARCHAR"/>
        <result property="addresseeAddress" column="addressee_address" jdbcType="VARCHAR"/>
        <result property="declareGoodsLogisticsWarehouse" column="declare_goods_logistics_warehouse"
                jdbcType="VARCHAR"/>
        <result property="declareGoodsType" column="declare_goods_type" jdbcType="VARCHAR"/>
        <result property="declareGoodsDate" column="declare_goods_date" jdbcType="VARCHAR"/>
        <result property="warehouseDeliveryDate" column="warehouse_delivery_date" jdbcType="VARCHAR"/>
        <result property="orderCreateTime" column="order_create_time" jdbcType="TIMESTAMP"/>
        <result property="orderUpdateTime" column="order_update_time" jdbcType="TIMESTAMP"/>
        <result property="orderCreateUser" column="order_create_user" jdbcType="VARCHAR"/>
        <result property="orderUpdateUser" column="order_update_user" jdbcType="VARCHAR"/>
        <result property="receivingFirmName" column="receiving_firm_name" jdbcType="VARCHAR"/>
        <result property="receivingMsBankAccount" column="receiving_ms_bank_account" jdbcType="VARCHAR"/>
        <result property="receivingMsBankBranch" column="receiving_ms_bank_branch" jdbcType="VARCHAR"/>
        <result property="bankUnionPayAccount" column="bank_unionPay_account" jdbcType="VARCHAR"/>
        <result property="receivingCreateTime" column="receiving_create_time" jdbcType="TIMESTAMP"/>
        <result property="receivingUpdateTime" column="receiving_update_time" jdbcType="TIMESTAMP"/>
        <result property="receivingCreateUser" column="receiving_create_user" jdbcType="VARCHAR"/>
        <result property="receivingUpdateUser" column="receiving_update_user" jdbcType="VARCHAR"/>
        <result property="orderRemark" column="order_remark" jdbcType="VARCHAR"/>
    </resultMap>
    <sql id="base_colum_list">
        id, shop_id, xgj_vice_president, xgj_region_id,xgj_region_name,addresseeName, addressee_mobile, addressee_province, addressee_city,
        addressee_district, addressee_address, declare_goods_logistics_warehouse, declare_goods_date,
        warehouse_delivery_date, order_create_time, order_update_time, order_create_user, order_update_user,
        receiving_firm_name, receiving_ms_bank_account, receiving_ms_bank_branch, bank_unionPay_account,
        receiving_create_time, receiving_update_time, receiving_create_user, receiving_update_user,
        declare_goods_type, order_remark
    </sql>
    <insert id="batchInsertSpecific">
        <foreach collection="list" item="item" index="index" separator=";">
            insert into xfsg_order_sys_info (
            shop_id,addressee_province,addressee_city,addressee_district,addressee_address,declare_goods_logistics_warehouse,receiving_ms_bank_account)
            values(
            #{item.shopId},
            #{item.addresseeProvince},
            #{item.addresseeCity},
            #{item.addresseeDistrict},
            #{item.addresseeAddress},
            #{item.declareGoodsLogisticsWarehouse},
            #{item.receivingMsBankAccount}
            )
        </foreach>
    </insert>
    <update id="updateAddresseeAddress">
        update xfsg_order_sys_info
        <set>
        <if test="update.addresseeAddress != null and update.addresseeAddress != ''">
             addressee_address = #{update.addresseeAddress},
        </if>
        <if test="update.addresseeProvince !=null and update.addresseeProvince != ''">
             addressee_province = #{update.addresseeProvince},
        </if>
        <if test="update.addresseeCity !=null and update.addresseeCity != ''">
             addressee_city = #{update.addresseeCity},
        </if>
        <if test="update.addresseeDistrict !=null and update.addresseeDistrict != ''">
             addressee_district = #{update.addresseeDistrict}
        </if>
        </set>
        where shop_id = #{update.shopId}
    </update>
    <update id="batchUpdateSpecific">
        <foreach collection="list" separator=";" index="index" item="item">
            update xfsg_order_sys_info
            <set>
                <if test="item.addresseeAddress != null and item.addresseeAddress != ''">
                    addressee_address = #{item.addresseeAddress},
                </if>
                <if test="item.addresseeProvince !=null and item.addresseeProvince != ''">
                    addressee_province = #{item.addresseeProvince},
                </if>
                <if test="item.addresseeCity !=null and item.addresseeCity != ''">
                    addressee_city = #{item.addresseeCity},
                </if>
                <if test="item.addresseeDistrict !=null and item.addresseeDistrict != ''">
                    addressee_district = #{item.addresseeDistrict},
                </if>
                <if test="item.declareGoodsLogisticsWarehouse !=null and item.declareGoodsLogisticsWarehouse != ''">
                    declare_goods_logistics_warehouse = #{item.declareGoodsLogisticsWarehouse},
                </if>
                <if test="item.receivingMsBankAccount !=null and item.receivingMsBankAccount != ''">
                    receiving_ms_bank_account = #{item.receivingMsBankAccount},
                </if>
                order_update_time = now()
            </set>
            where shop_id = #{item.shopId}
        </foreach>
    </update>
    <select id="getSpecificByShopIdList" resultType="com.cool.store.entity.OrderSysInfoDO">
        select
        shop_id as shopId,
        declare_goods_logistics_warehouse as declareGoodsLogisticsWarehouse,
        declare_goods_type as declareGoodsType,
        declare_goods_date as declareGoodsDate,
        receiving_firm_name as receivingFirmName,
        receiving_ms_bank_account as receivingMsBankAccount
        from xfsg_order_sys_info
        where shop_id in
        <foreach collection="list" item="item" index="index" open="(" separator="," close=")">
            #{item}
        </foreach>
    </select>
</mapper>