<?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.platform.yijia.dao.IntegralWaresMapper">
  <!--返回结果-->
  <resultMap id="BaseResultMap" type="com.platform.yijia.pojo.IntegralWares">
    <id     column="id"              jdbcType="INTEGER"    property="id" />
    <result column="wares_name"      jdbcType="VARCHAR"    property="waresName" />
    <result column="sale_integral"   jdbcType="DECIMAL"    property="saleIntegral" />
    <result column="wares_pic"       jdbcType="VARCHAR"    property="waresPic" />
    <result column="wares_detail"    jdbcType="VARCHAR"    property="waresDetail" />
    <result column="wares_count"     jdbcType="INTEGER"    property="waresCount" />
    <result column="wares_out_count" jdbcType="INTEGER"    property="waresOutCount" />
    <result column="wares_status"    jdbcType="VARCHAR"    property="waresStatus" />
    <result column="create_time"     jdbcType="TIMESTAMP"  property="createTime" />
    <result column="create_by"       jdbcType="VARCHAR"    property="createBy" />
    <result column="update_time"     jdbcType="TIMESTAMP"  property="updateTime" />
    <result column="update_by"       jdbcType="VARCHAR"    property="updateBy" />
    <result column="station_id"      jdbcType="INTEGER"    property="stationId" />
  </resultMap>

  <!--查询列-->
  <sql id="Base_Column_List">
    id, wares_name, sale_integral, wares_pic,
    wares_detail, wares_count, wares_out_count, wares_status,
    create_time, create_by, update_time, update_by
  </sql>

  <!--查询油站商品信息-->
  <select id="getIntegralWaresInfoList" resultMap="BaseResultMap" parameterType="com.platform.yijia.pojo.IntegralWares">
    SELECT
        <include refid="Base_Column_List" />
    FROM integral_wares
    <where>
         wares_status = "1"
      <if test="stationId !=null and stationId !=''">
        AND station_id = #{stationId}
      </if>
      <if test="id !=null and id !=''">
        AND id = #{id}
      </if>
    </where>
  </select>

  <!--查询油站商品信息-->
  <select id="getIntegralWaresInfo" resultMap="BaseResultMap" parameterType="com.platform.yijia.pojo.IntegralWares">
    SELECT
        <include refid="Base_Column_List" />
    FROM integral_wares
    <where>
      wares_status = "1"
      <if test="id !=null and id !=''">
        AND id = #{id}
      </if>
    </where>
  </select>

  <!--更新油站商品已售数量-->
  <update id="updateIntegralWaresInfo" parameterType="com.platform.yijia.pojo.IntegralWares">
    UPDATE
        integral_wares
    <set>
      <if test="waresCount !=null">
        wares_count = #{waresCount},
      </if>
      <if test="waresOutCount !=null">
        wares_out_count = #{waresOutCount}
      </if>
    </set>
    <where>
      <if test="id !=null and id != ''">
        id = #{id}
      </if>
    </where>
  </update>


</mapper>
