<?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.CloseStoreStageInfoMapper">
  <resultMap id="BaseResultMap" type="com.cool.store.entity.CloseStoreStageInfoDO">
    <!--
      WARNING - @mbg.generated
    -->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="close_store_id" jdbcType="BIGINT" property="closeStoreId" />
    <result column="shop_stage" jdbcType="TINYINT" property="shopStage" />
    <result column="shop_sub_stage" jdbcType="INTEGER" property="shopSubStage" />
    <result column="shop_sub_stage_status" jdbcType="INTEGER" property="shopSubStageStatus" />
    <result column="is_terminated" jdbcType="BIT" property="isTerminated" />
    <result column="plan_complete_time" jdbcType="VARCHAR" property="planCompleteTime" />
    <result column="actual_complete_time" jdbcType="VARCHAR" property="actualCompleteTime" />
    <result column="remark" jdbcType="VARCHAR" property="remark" />
    <result column="audit_id" jdbcType="BIGINT" property="auditId" />
    <result column="deleted" jdbcType="BIT" property="deleted" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
  </resultMap>

  <insert id="insertBatch" parameterType="java.util.List">
    INSERT INTO zxjp_close_store_stage_info (close_store_id, shop_stage, shop_sub_stage, shop_sub_stage_status, is_terminated, plan_complete_time, actual_complete_time, remark, audit_id)
    VALUES
    <foreach collection="list" item="item" separator=",">
      (#{item.closeStoreId}, #{item.shopStage}, #{item.shopSubStage}, #{item.shopSubStageStatus}, #{item.isTerminated}, #{item.planCompleteTime}, #{item.actualCompleteTime}, #{item.remark}, #{item.auditId})
    </foreach>
  </insert>

  <update id="updateBatchSelective" parameterType="java.util.List">
    <foreach collection="list" item="item" separator=";">
      UPDATE zxjp_close_store_stage_info
      <set>
        <if test="item.shopStage != null">
          shop_stage = #{item.shopStage},
        </if>
        <if test="item.shopSubStage != null">
          shop_sub_stage = #{item.shopSubStage},
        </if>
        <if test="item.shopSubStageStatus != null">
          shop_sub_stage_status = #{item.shopSubStageStatus},
        </if>
        <if test="item.isTerminated != null">
          is_terminated = #{item.isTerminated},
        </if>
        <if test="item.planCompleteTime != null and item.planCompleteTime != ''">
          plan_complete_time = #{item.planCompleteTime},
        </if>
        <if test="item.actualCompleteTime != null and item.actualCompleteTime != ''">
          actual_complete_time = #{item.actualCompleteTime},
        </if>
        <if test="item.remark != null and item.remark != ''">
          remark = #{item.remark},
        </if>
        <if test="item.auditId != null">
          audit_id = #{item.auditId},
        </if>
        update_time = NOW()
      </set>
      WHERE id = #{item.id}
    </foreach>
  </update>
</mapper>