<?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.slodon.b2b2c.dao.write.integral.IntegralProductWriteMapper">
  <resultMap id="resultMap" type="com.slodon.b2b2c.integral.pojo.IntegralProduct">
    <id column="integral_product_id" property="integralProductId" />
    <result column="goods_id" property="goodsId" />
    <result column="goods_name" property="goodsName" />
    <result column="spec_values" property="specValues" />
    <result column="spec_value_ids" property="specValueIds" />
    <result column="market_price" property="marketPrice" />
    <result column="integral_price" property="integralPrice" />
    <result column="cash_price" property="cashPrice" />
    <result column="store_id" property="storeId" />
    <result column="store_name" property="storeName" />
    <result column="product_stock" property="productStock" />
    <result column="product_stock_warning" property="productStockWarning" />
    <result column="product_stock_warning_state" property="productStockWarningState" />
    <result column="actual_sales" property="actualSales" />
    <result column="product_code" property="productCode" />
    <result column="bar_code" property="barCode" />
    <result column="weight" property="weight" />
    <result column="length" property="length" />
    <result column="width" property="width" />
    <result column="height" property="height" />
    <result column="main_image" property="mainImage" />
    <result column="state" property="state" />
    <result column="is_default" property="isDefault" />
  </resultMap>
  <!--除主键外的所有字段，用于插入操作-->
  <sql id="columns">
    <trim suffixOverrides=",">
      <if test="integralProductId != null">
        `integral_product_id`,
      </if>
      <if test="goodsId != null">
        `goods_id`,
      </if>
      <if test="goodsName != null">
        `goods_name`,
      </if>
      <if test="specValues != null">
        `spec_values`,
      </if>
      <if test="specValueIds != null">
        `spec_value_ids`,
      </if>
      <if test="marketPrice != null">
        `market_price`,
      </if>
      <if test="integralPrice != null">
        `integral_price`,
      </if>
      <if test="cashPrice != null">
        `cash_price`,
      </if>
      <if test="storeId != null">
        `store_id`,
      </if>
      <if test="storeName != null">
        `store_name`,
      </if>
      <if test="productStock != null">
        `product_stock`,
      </if>
      <if test="productStockWarning != null">
        `product_stock_warning`,
      </if>
      <if test="productStockWarningState != null">
        `product_stock_warning_state`,
      </if>
      <if test="actualSales != null">
        `actual_sales`,
      </if>
      <if test="productCode != null">
        `product_code`,
      </if>
      <if test="barCode != null">
        `bar_code`,
      </if>
      <if test="weight != null">
        `weight`,
      </if>
      <if test="length != null">
        `length`,
      </if>
      <if test="width != null">
        `width`,
      </if>
      <if test="height != null">
        `height`,
      </if>
      <if test="mainImage != null">
        `main_image`,
      </if>
      <if test="state != null">
        `state`,
      </if>
      <if test="isDefault != null">
        `is_default`,
      </if>
    </trim>
  </sql>
  <!--按照主键值进行操作-->
  <sql id="pkWhere">
    WHERE `integral_product_id` = #{primaryKey}
  </sql>
  <!--操作条件-->
  <sql id="whereCondition">
    <if test="example != null">
      <trim prefix="WHERE" prefixOverrides="AND|OR">
        <if test="example.integralProductIdNotEquals != null">
          AND `integral_product_id` != #{example.integralProductIdNotEquals}
        </if>
        <if test="example.integralProductIdIn != null">
          AND `integral_product_id` in (${example.integralProductIdIn})
        </if>
        <if test="example.goodsId != null">
          AND `goods_id` = #{example.goodsId}
        </if>
        <if test="example.goodsName != null">
          AND `goods_name` = #{example.goodsName}
        </if>
        <if test="example.goodsNameLike != null">
          AND `goods_name` like concat('%',#{example.goodsNameLike},'%')
        </if>
        <if test="example.specValues != null">
          AND `spec_values` = #{example.specValues}
        </if>
        <if test="example.specValueIds != null">
          AND `spec_value_ids` = #{example.specValueIds}
        </if>
        <if test="example.marketPrice != null">
          AND `market_price` = #{example.marketPrice}
        </if>
        <if test="example.integralPrice != null">
          AND `integral_price` = #{example.integralPrice}
        </if>
        <if test="example.cashPrice != null">
          AND `cash_price` = #{example.cashPrice}
        </if>
        <if test="example.storeId != null">
          AND `store_id` = #{example.storeId}
        </if>
        <if test="example.storeName != null">
          AND `store_name` = #{example.storeName}
        </if>
        <if test="example.storeNameLike != null">
          AND `store_name` like concat('%',#{example.storeNameLike},'%')
        </if>
        <if test="example.productStock != null">
          AND `product_stock` = #{example.productStock}
        </if>
        <if test="example.productStockWarning != null">
          AND `product_stock_warning` = #{example.productStockWarning}
        </if>
        <if test="example.productStockWarningState != null">
          AND `product_stock_warning_state` = #{example.productStockWarningState}
        </if>
        <if test="example.productStockWarningStateIn != null">
          AND `product_stock_warning_state` in (${example.productStockWarningStateIn})
        </if>
        <if test="example.productStockWarningStateNotIn != null">
          AND `product_stock_warning_state` not in (${example.productStockWarningStateNotIn})
        </if>
        <if test="example.productStockWarningStateNotEquals != null">
          AND `product_stock_warning_state` != #{example.productStockWarningStateNotEquals}
        </if>
        <if test="example.actualSales != null">
          AND `actual_sales` = #{example.actualSales}
        </if>
        <if test="example.productCode != null">
          AND `product_code` = #{example.productCode}
        </if>
        <if test="example.barCode != null">
          AND `bar_code` = #{example.barCode}
        </if>
        <if test="example.weight != null">
          AND `weight` = #{example.weight}
        </if>
        <if test="example.length != null">
          AND `length` = #{example.length}
        </if>
        <if test="example.width != null">
          AND `width` = #{example.width}
        </if>
        <if test="example.height != null">
          AND `height` = #{example.height}
        </if>
        <if test="example.mainImage != null">
          AND `main_image` = #{example.mainImage}
        </if>
        <if test="example.state != null">
          AND `state` = #{example.state}
        </if>
        <if test="example.stateIn != null">
          AND `state` in (${example.stateIn})
        </if>
        <if test="example.stateNotIn != null">
          AND `state` not in (${example.stateNotIn})
        </if>
        <if test="example.stateNotEquals != null">
          AND `state` != #{example.stateNotEquals}
        </if>
        <if test="example.isDefault != null">
          AND `is_default` = #{example.isDefault}
        </if>
      </trim>
    </if>
  </sql>
  <!--排序条件-->
  <sql id="orderBy">
    ORDER BY `integral_product_id` DESC
  </sql>
  <sql id="orderByOther">
    order by ${example.orderBy}
  </sql>
  <!--分组条件-->
  <sql id="groupBy">
    group by ${example.groupBy}
  </sql>
  <!--分页条件-->
  <sql id="limit">
    <if test="size != null and size &gt; 0">
      limit #{startRow},#{size}
    </if>
  </sql>
  <!--查询符合条件的记录数-->
  <select id="countByExample" parameterType="com.slodon.b2b2c.integral.example.IntegralProductExample" resultType="java.lang.Integer">
    SELECT
      COUNT(*)
    FROM `integral_product`
    <include refid="whereCondition" />
  </select>
  <!--根据主键查询记录-->
  <select id="getByPrimaryKey" resultMap="resultMap">
    SELECT
      *
    FROM `integral_product`
    <include refid="pkWhere" />
  </select>
  <!--查询符合条件的记录(所有字段)-->
  <select id="listByExample" resultMap="resultMap">
    SELECT
      *
    FROM `integral_product`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
  </select>
  <!--分页查询符合条件的记录(所有字段)-->
  <select id="listPageByExample" resultMap="resultMap">
    SELECT
      *
    FROM `integral_product`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
    <include refid="limit" />
  </select>
  <!--查询符合条件的记录(指定字段)-->
  <select id="listFieldsByExample" resultMap="resultMap">
    SELECT
      ${fields}
    FROM `integral_product`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
  </select>
  <!--分页查询符合条件的记录(指定字段)-->
  <select id="listFieldsPageByExample" resultMap="resultMap">
    SELECT
      ${fields}
    FROM `integral_product`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
    <include refid="limit" />
  </select>
  <!--根据条件删除记录，可多条删除-->
  <delete id="deleteByExample">
    DELETE FROM `integral_product`
    <include refid="whereCondition" />
  </delete>
  <!--根据主键删除记录-->
  <delete id="deleteByPrimaryKey">
    DELETE FROM `integral_product`
    <include refid="pkWhere" />
  </delete>
  <!--插入一条记录-->
  <insert id="insert" keyColumn="integral_product_id" keyProperty="integralProductId" parameterType="com.slodon.b2b2c.integral.pojo.IntegralProduct" useGeneratedKeys="true">
    INSERT INTO `integral_product`(
    <include refid="columns" />
    )
    VALUES(
    <trim suffixOverrides=",">
      <if test="integralProductId != null">
        #{integralProductId},
      </if>
      <if test="goodsId != null">
        #{goodsId},
      </if>
      <if test="goodsName != null">
        #{goodsName},
      </if>
      <if test="specValues != null">
        #{specValues},
      </if>
      <if test="specValueIds != null">
        #{specValueIds},
      </if>
      <if test="marketPrice != null">
        #{marketPrice},
      </if>
      <if test="integralPrice != null">
        #{integralPrice},
      </if>
      <if test="cashPrice != null">
        #{cashPrice},
      </if>
      <if test="storeId != null">
        #{storeId},
      </if>
      <if test="storeName != null">
        #{storeName},
      </if>
      <if test="productStock != null">
        #{productStock},
      </if>
      <if test="productStockWarning != null">
        #{productStockWarning},
      </if>
      <if test="productStockWarningState != null">
        #{productStockWarningState},
      </if>
      <if test="actualSales != null">
        #{actualSales},
      </if>
      <if test="productCode != null">
        #{productCode},
      </if>
      <if test="barCode != null">
        #{barCode},
      </if>
      <if test="weight != null">
        #{weight},
      </if>
      <if test="length != null">
        #{length},
      </if>
      <if test="width != null">
        #{width},
      </if>
      <if test="height != null">
        #{height},
      </if>
      <if test="mainImage != null">
        #{mainImage},
      </if>
      <if test="state != null">
        #{state},
      </if>
      <if test="isDefault != null">
        #{isDefault},
      </if>
    </trim>
    )
  </insert>
  <!--按条件更新记录中不为空的字段-->
  <update id="updateByExampleSelective">
    UPDATE `integral_product`
    <trim prefix="SET" suffixOverrides=",">
      <if test="record.goodsId != null">
        `goods_id` = #{record.goodsId},
      </if>
      <if test="record.goodsName != null">
        `goods_name` = #{record.goodsName},
      </if>
      <if test="record.specValues != null">
        `spec_values` = #{record.specValues},
      </if>
      <if test="record.specValueIds != null">
        `spec_value_ids` = #{record.specValueIds},
      </if>
      <if test="record.marketPrice != null">
        `market_price` = #{record.marketPrice},
      </if>
      <if test="record.integralPrice != null">
        `integral_price` = #{record.integralPrice},
      </if>
      <if test="record.cashPrice != null">
        `cash_price` = #{record.cashPrice},
      </if>
      <if test="record.storeId != null">
        `store_id` = #{record.storeId},
      </if>
      <if test="record.storeName != null">
        `store_name` = #{record.storeName},
      </if>
      <if test="record.productStock != null">
        `product_stock` = #{record.productStock},
      </if>
      <if test="record.productStockWarning != null">
        `product_stock_warning` = #{record.productStockWarning},
      </if>
      <if test="record.productStockWarningState != null">
        `product_stock_warning_state` = #{record.productStockWarningState},
      </if>
      <if test="record.actualSales != null">
        `actual_sales` = #{record.actualSales},
      </if>
      <if test="record.productCode != null">
        `product_code` = #{record.productCode},
      </if>
      <if test="record.barCode != null">
        `bar_code` = #{record.barCode},
      </if>
      <if test="record.weight != null">
        `weight` = #{record.weight},
      </if>
      <if test="record.length != null">
        `length` = #{record.length},
      </if>
      <if test="record.width != null">
        `width` = #{record.width},
      </if>
      <if test="record.height != null">
        `height` = #{record.height},
      </if>
      <if test="record.mainImage != null">
        `main_image` = #{record.mainImage},
      </if>
      <if test="record.state != null">
        `state` = #{record.state},
      </if>
      <if test="record.isDefault != null">
        `is_default` = #{record.isDefault},
      </if>
    </trim>
    <include refid="whereCondition" />
  </update>
  <!--按照主键更新记录中不为空的字段-->
  <update id="updateByPrimaryKeySelective">
    UPDATE `integral_product`
    <trim prefix="SET" suffixOverrides=",">
      <if test="goodsId != null">
        `goods_id` = #{goodsId},
      </if>
      <if test="goodsName != null">
        `goods_name` = #{goodsName},
      </if>
      <if test="specValues != null">
        `spec_values` = #{specValues},
      </if>
      <if test="specValueIds != null">
        `spec_value_ids` = #{specValueIds},
      </if>
      <if test="marketPrice != null">
        `market_price` = #{marketPrice},
      </if>
      <if test="integralPrice != null">
        `integral_price` = #{integralPrice},
      </if>
      <if test="cashPrice != null">
        `cash_price` = #{cashPrice},
      </if>
      <if test="storeId != null">
        `store_id` = #{storeId},
      </if>
      <if test="storeName != null">
        `store_name` = #{storeName},
      </if>
      <if test="productStock != null">
        `product_stock` = #{productStock},
      </if>
      <if test="productStockWarning != null">
        `product_stock_warning` = #{productStockWarning},
      </if>
      <if test="productStockWarningState != null">
        `product_stock_warning_state` = #{productStockWarningState},
      </if>
      <if test="actualSales != null">
        `actual_sales` = #{actualSales},
      </if>
      <if test="productCode != null">
        `product_code` = #{productCode},
      </if>
      <if test="barCode != null">
        `bar_code` = #{barCode},
      </if>
      <if test="weight != null">
        `weight` = #{weight},
      </if>
      <if test="length != null">
        `length` = #{length},
      </if>
      <if test="width != null">
        `width` = #{width},
      </if>
      <if test="height != null">
        `height` = #{height},
      </if>
      <if test="mainImage != null">
        `main_image` = #{mainImage},
      </if>
      <if test="state != null">
        `state` = #{state},
      </if>
      <if test="isDefault != null">
        `is_default` = #{isDefault},
      </if>
    </trim>
    WHERE `integral_product_id` = #{integralProductId}
  </update>
</mapper>