<?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.cool.store.mapper.CloseStoreRefundInfoMapper">
    <resultMap id="BaseResultMap" type="com.cool.store.entity.CloseStoreRefundInfoDO">
    <!--
      WARNING - @mbg.generated
    -->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="close_store_id" jdbcType="BIGINT" property="closeStoreId" />
    <result column="refund_no" jdbcType="VARCHAR" property="refundNo" />
    <result column="type" jdbcType="INTEGER" property="type" />
    <result column="refund_status" jdbcType="BIT" property="refundStatus" />
    <result column="refund_order_no" jdbcType="VARCHAR" property="refundOrderNo" />
    <result column="refund_time" jdbcType="TIMESTAMP" property="refundTime" />
    <result column="invoice_title" jdbcType="VARCHAR" property="invoiceTitle" />
    <result column="submitter_id" jdbcType="VARCHAR" property="submitterId" />
    <result column="submitter_name" jdbcType="VARCHAR" property="submitterName" />
    <result column="refund_reason" jdbcType="VARCHAR" property="refundReason" />
    <result column="refund_type" jdbcType="VARCHAR" property="refundType" />
    <result column="refund_project" jdbcType="VARCHAR" property="refundProject" />
    <result column="remark" jdbcType="VARCHAR" property="remark" />
    <result column="business_code" jdbcType="VARCHAR" property="businessCode" />
    <result column="business_name" jdbcType="VARCHAR" property="businessName" />
    <result column="business_account" jdbcType="VARCHAR" property="businessAccount" />
    <result column="expense_type_code" jdbcType="VARCHAR" property="expenseTypeCode" />
    <result column="expense_apply_time" jdbcType="DATE" property="expenseApplyTime" />
    <result column="expected_amount" jdbcType="DECIMAL" property="expectedAmount" />
    <result column="actual_amount" jdbcType="DECIMAL" property="actualAmount" />
    <result column="deduct_amount" jdbcType="DECIMAL" property="deductAmount" />
    <result column="deduct_reason" jdbcType="VARCHAR" property="deductReason" />
    <result column="close_reason" jdbcType="TINYINT" property="closeReason" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
    <result column="account_number" jdbcType="VARCHAR" property="accountNumber" />
    <result column="bank_name" jdbcType="VARCHAR" property="bankName" />
    <result column="bank_branch_no" jdbcType="VARCHAR" property="bankBranchNo" />
    </resultMap>

    <insert id="insertBatch" parameterType="java.util.List">
        INSERT INTO zxjp_close_store_refund_info (
            close_store_id,
            refund_no,
            type,
            refund_status,
            refund_order_no,
            refund_time,
            invoice_title,
            submitter_id,
            submitter_name,
            refund_reason,
            refund_type,
            refund_project,
            remark,
            business_code,
            business_name,
            business_account,
            expense_type_code,
            expense_apply_time,
            expected_amount,
            actual_amount,
            deduct_amount,
            deduct_reason,
            close_reason,
        ) VALUES
        <foreach collection="list" item="item" separator=",">
            (
            #{item.closeStoreId,jdbcType=BIGINT},
            #{item.refundNo,jdbcType=VARCHAR},
            #{item.type,jdbcType=INTEGER},
            #{item.refundStatus,jdbcType=BIT},
            #{item.refundOrderNo,jdbcType=VARCHAR},
            #{item.refundTime,jdbcType=TIMESTAMP},
            #{item.invoiceTitle,jdbcType=VARCHAR},
            #{item.submitterId,jdbcType=VARCHAR},
            #{item.submitterName,jdbcType=VARCHAR},
            #{item.refundReason,jdbcType=VARCHAR},
            #{item.refundType,jdbcType=VARCHAR},
            #{item.refundProject,jdbcType=VARCHAR},
            #{item.remark,jdbcType=VARCHAR},
            #{item.businessCode,jdbcType=VARCHAR},
            #{item.businessName,jdbcType=VARCHAR},
            #{item.businessAccount,jdbcType=VARCHAR},
            #{item.expenseTypeCode,jdbcType=VARCHAR},
            #{item.expenseApplyTime,jdbcType=DATE},
            #{item.expectedAmount,jdbcType=DECIMAL},
            #{item.actualAmount,jdbcType=DECIMAL},
            #{item.deductAmount,jdbcType=DECIMAL},
            #{item.deductReason,jdbcType=VARCHAR},
            #{item.closeReason,jdbcType=TINYINT},
            )
        </foreach>
    </insert>

    <update id="updateRefundStatusBatchById" parameterType="java.util.List">
        UPDATE zxjp_close_store_refund_info
        <trim prefix="SET" suffixOverrides=",">
            <trim prefix="refund_status = CASE" suffix="END,">
                <foreach collection="list" item="item">
                    WHEN id = #{item.id} THEN #{item.refundStatus}
                </foreach>
            </trim>
        </trim>
        WHERE id IN
        <foreach collection="list" item="item" open="(" separator="," close=")">
            #{item.id}
        </foreach>
    </update>
</mapper>