<?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.tmerclub.cloud.multishop.mapper.ShopSubstituteSalesMapper">
  <resultMap id="shopSubstituteSalesMap" type="com.tmerclub.cloud.common.vo.ShopSubstituteSalesVO">
    <id column="shop_substitute_sales_id" property="shopSubstituteSalesId" />
    <result column="shop_id" property="shopId"/>
    <result column="sales_type" property="salesType"/>
    <result column="sales_price_type" property="salesPriceType"/>
    <result column="sales_price" property="salesPrice"/>
    <result column="order_shape" property="orderShape"/>
    <result column="modifier" property="modifier"/>
    <result column="automatic_off" property="automaticOff"/>
  </resultMap>
  <sql id="Vo_Column_List">
    `shop_substitute_sales_id`,`shop_id`,`sales_type`,`sales_price_type`,`sales_price`,`modifier`,`order_shape`,`automatic_off`
  </sql>
  <select id="list" resultMap="shopSubstituteSalesMap">
    select <include refid="Vo_Column_List"/> from shop_substitute_sales order by shop_substitute_sales_id desc
  </select>
  <select id="listByShopIds" resultType="com.tmerclub.cloud.common.vo.ShopSubstituteSalesVO">
    select <include refid="Vo_Column_List"/> from shop_substitute_sales
    where shop_id in
    <foreach collection="shopIds" item="shopId" open="(" separator="," close=")">
      #{shopId}
    </foreach>
  </select>
  <select id="getByShopSubstituteSalesId" resultMap="shopSubstituteSalesMap">
    select <include refid="Vo_Column_List"/> from shop_substitute_sales where shop_id = #{shopId}
  </select>
  <insert id="save">
    insert into shop_substitute_sales (`shop_id`,`sales_type`,`sales_price_type`,`sales_price`,`order_shape`,`modifier`,`automatic_off`)
    values (#{shopSubstituteSales.shopId},#{shopSubstituteSales.salesType},#{shopSubstituteSales.salesPriceType},#{shopSubstituteSales.salesPrice},#{shopSubstituteSales.orderShape},#{shopSubstituteSales.modifier},#{shopSubstituteSales.automaticOff});
  </insert>
  <update id="update">
    update shop_substitute_sales
    <set>
      <if test="shopSubstituteSales.shopId != null">
        `shop_id` = #{shopSubstituteSales.shopId},
      </if>
      <if test="shopSubstituteSales.salesType != null">
        `sales_type` = #{shopSubstituteSales.salesType},
      </if>
      <if test="shopSubstituteSales.salesPriceType != null">
        `sales_price_type` = #{shopSubstituteSales.salesPriceType},
      </if>
      <if test="shopSubstituteSales.salesPrice != null">
        `sales_price` = #{shopSubstituteSales.salesPrice},
      </if>
      <if test="shopSubstituteSales.orderShape != null">
        `order_shape` = #{shopSubstituteSales.orderShape},
      </if>
      <if test="shopSubstituteSales.modifier != null">
        `modifier` = #{shopSubstituteSales.modifier},
      </if>
      <if test="shopSubstituteSales.automaticOff != null">
        `automatic_off` = #{shopSubstituteSales.automaticOff},
      </if>
    </set>
    where shop_substitute_sales_id = #{shopSubstituteSales.shopSubstituteSalesId}
  </update>
  <delete id="deleteById">
    delete from shop_substitute_sales where shop_substitute_sales_id = #{shopSubstituteSalesId}
  </delete>

</mapper>
