<?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.ShopRentInfoMapper">
  <resultMap id="BaseResultMap" type="com.cool.store.entity.ShopRentInfoDO">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="shop_id" jdbcType="BIGINT" property="shopId" />
    <result column="point_id" jdbcType="BIGINT" property="pointId" />
    <result column="rent_type" jdbcType="TINYINT" property="rentType" />
    <result column="sign_time" jdbcType="TIMESTAMP" property="signTime" />
    <result column="contract_start_time" jdbcType="TIMESTAMP" property="contractStartTime" />
    <result column="contract_end_time" jdbcType="TIMESTAMP" property="contractEndTime" />
    <result column="contract_months" jdbcType="INTEGER" property="contractMonths" />
    <result column="shop_rent_type" jdbcType="TINYINT" property="shopRentType" />
    <result column="month_rent" jdbcType="VARCHAR" property="monthRent" />
    <result column="first_year_month_rent" jdbcType="VARCHAR" property="firstYearMonthRent" />
    <result column="second_year_month_rent" jdbcType="VARCHAR" property="secondYearMonthRent" />
    <result column="third_year_month_rent" jdbcType="VARCHAR" property="thirdYearMonthRent" />
    <result column="contract_pic" jdbcType="VARCHAR" property="contractPic" />
    <result column="house_certificate_pic" jdbcType="VARCHAR" property="houseCertificatePic" />
    <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>

  <sql id="allColumn">
    id, shop_id, point_id, rent_type, sign_time, contract_start_time, contract_end_time, contract_months, shop_rent_type,
    month_rent, first_year_month_rent, second_year_month_rent, third_year_month_rent, contract_pic,
    house_certificate_pic, audit_id, deleted, create_time, update_time
  </sql>

  <select id="getRentContractByShopId" resultMap="BaseResultMap">
    select
      <include refid="allColumn"/>
    from
      xfsg_shop_rent_info
    where shop_id = #{shopId} and deleted = 0
  </select>

  <update id="deleteRentContractByShopId">
    update
      xfsg_shop_rent_info
    set
      deleted = 1
    where shop_id = #{shopId}
  </update>

  <select id="getRentContractByShopIds" resultType="com.cool.store.entity.ShopRentInfoDO">
    select
      <include refid="allColumn"/>
    from
      xfsg_shop_rent_info
    where
      deleted = 0 and shop_id in
      <foreach collection="shopIds" item="shopId" separator="," open="(" close=")">
        #{shopId}
      </foreach>
  </select>

</mapper>