SellerOrderGoodsMapper.xml 14.3 KB
<?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.yohoufo.dal.order.SellerOrderGoodsMapper">
  <resultMap id="BaseResultMap" type="com.yohoufo.dal.order.model.SellerOrderGoods">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="product_id" jdbcType="INTEGER" property="productId" />
    <result column="uid" jdbcType="INTEGER" property="uid" />
    <result column="product_name" jdbcType="VARCHAR" property="productName" />
    <result column="storage_id" jdbcType="INTEGER" property="storageId" />
    <result column="depot_no" jdbcType="INTEGER" property="depotNo" />
    <result column="size_id" jdbcType="INTEGER" property="sizeId" />
    <result column="size_name" jdbcType="VARCHAR" property="sizeName" />
    <result column="color_id" jdbcType="SMALLINT" property="colorId" />
    <result column="color_name" jdbcType="VARCHAR" property="colorName" />
    <result column="goods_price" jdbcType="DECIMAL" property="goodsPrice" />
    <result column="status" jdbcType="TINYINT" property="status" />
    <result column="image_url" jdbcType="VARCHAR" property="imageUrl" />
    <result column="is_del" jdbcType="TINYINT" property="isDel" />
    <result column="batch_no" jdbcType="BIGINT" property="batchNo" />
    <result column="num" jdbcType="INTEGER" property="num" />
    <result column="skup_list" jdbcType="VARCHAR" property="skupList" />
  </resultMap>
  <sql id="Base_Column_List">
    id, uid, product_id, product_name, storage_id, depot_no, size_id, size_name,
    color_id, color_name, goods_price, status, image_url, is_del, batch_no
  </sql>
  <select id="selectByPrimaryKey"  resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from seller_order_goods
    where id = #{id,jdbcType=INTEGER}
  </select>


  <select id="selectBySkups" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from seller_order_goods
    where 1=1
    <if test="list != null">
      and id in
      <foreach item="item" index="index" collection="list" open="(" separator="," close=")">
        #{item}
      </foreach>
    </if>
  </select>

  <select id="selectByBatchNo"  resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from seller_order_goods
    where batch_no = #{condition.batchNo,jdbcType=BIGINT} and status in
    <foreach collection="statusList" item="status" open="(" close=")" separator=",">
      #{status,jdbcType=TINYINT}
    </foreach>
  </select>


  <select id="selectBySkup" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from seller_order_goods
    where 1=1
    <if test="list != null">
      and id in
      <foreach item="item" index="index" collection="list" open="(" separator="," close=")">
        #{item}
      </foreach>
    </if>
  </select>

  <select id="selectBySkupsNStatus" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from seller_order_goods
    where 1=1
    <if test="list != null">
      and id in
      <foreach item="item" index="index" collection="list" open="(" separator="," close=")">
        #{item}
      </foreach>
    </if>
    and status in
    <foreach collection="statusList" item="status" open="(" close=")" separator=",">
      #{status, jdbcType=TINYINT}
    </foreach>

  </select>

  <sql id="sql_where_4_select_UidStatusList">
    uid = #{uid,jdbcType=INTEGER} and is_del = 1
    <if test="statusList != null">
      and status in
      <foreach item="status" index="index" collection="statusList" open="(" separator="," close=")">
        #{status, jdbcType=TINYINT}
      </foreach>
    </if>
  </sql>

  <select id="selectCntByUidStatusList" resultType="java.lang.Integer">
    select count(*) from seller_order_goods where <include refid="sql_where_4_select_UidStatusList"/>
  </select>

  <select id="selectCntByUid" resultType="java.lang.Integer">
    select count(*) from seller_order_goods where uid = #{uid,jdbcType=INTEGER}
  </select>

  <select id="selectByUidStatusList" resultMap="BaseResultMap">
    select <include refid="Base_Column_List" /> from seller_order_goods
    where <include refid="sql_where_4_select_UidStatusList"/>
    order by id desc
    limit #{offset, jdbcType=INTEGER}, #{limit, jdbcType=INTEGER}
  </select>

  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from seller_order_goods
    where id = #{id,jdbcType=INTEGER}
  </delete>

  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.dal.order.model.SellerOrderGoods" useGeneratedKeys="true">
    insert into seller_order_goods (product_id, product_name, storage_id,
      depot_no, size_id, size_name, 
       color_id, color_name,
      goods_price, status)
    values (#{productId,jdbcType=INTEGER}, #{productName,jdbcType=VARCHAR}, #{storageId,jdbcType=INTEGER}, 
      #{depotNo,jdbcType=INTEGER}, #{sizeId,jdbcType=INTEGER}, #{sizeName,jdbcType=VARCHAR}, 
       #{colorId,jdbcType=SMALLINT}, #{colorName,jdbcType=VARCHAR},
      #{goodsPrice,jdbcType=DECIMAL}, #{status,jdbcType=TINYINT})
  </insert>


  <insert id="insertBatch" keyColumn="id" keyProperty="id"  useGeneratedKeys="true">
    insert into seller_order_goods (product_id, product_name, storage_id,
    depot_no, size_id, size_name,
    color_id, color_name,
    goods_price, status, batch_no)
    values
    <foreach collection="records" item="sog" separator=",">
      (#{sog.productId,jdbcType=INTEGER}, #{sog.productName,jdbcType=VARCHAR}, #{sog.storageId,jdbcType=INTEGER},
      #{sog.depotNo,jdbcType=INTEGER}, #{sog.sizeId,jdbcType=INTEGER}, #{sog.sizeName,jdbcType=VARCHAR},
      #{sog.colorId,jdbcType=SMALLINT}, #{sog.colorName,jdbcType=VARCHAR},
      #{sog.goodsPrice,jdbcType=DECIMAL}, #{sog.status,jdbcType=TINYINT}, #{sog.batchNo,jdbcType=BIGINT})
    </foreach>

  </insert>


  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.dal.order.model.SellerOrderGoods" useGeneratedKeys="true">
    insert into seller_order_goods
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="productId != null">
        product_id,
      </if>
      <if test="uid != null">
        uid,
      </if>
      <if test="productName != null">
        product_name,
      </if>
      <if test="storageId != null">
        storage_id,
      </if>
      <if test="depotNo != null">
        depot_no,
      </if>
      <if test="sizeId != null">
        size_id,
      </if>
      <if test="sizeName != null">
        size_name,
      </if>
      <if test="imageUrl != null">
        image_url,
      </if>
      <if test="colorId != null">
        color_id,
      </if>
      <if test="colorName != null">
        color_name,
      </if>
      <if test="goodsPrice != null">
        goods_price,
      </if>
      <if test="status != null">
        status,
      </if>
      <if test="batchNo != null">
        batch_no,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="productId != null">
        #{productId,jdbcType=INTEGER},
      </if>
      <if test="uid != null">
        #{uid,jdbcType=INTEGER},
      </if>
      <if test="productName != null">
        #{productName,jdbcType=VARCHAR},
      </if>
      <if test="storageId != null">
        #{storageId,jdbcType=INTEGER},
      </if>
      <if test="depotNo != null">
        #{depotNo,jdbcType=INTEGER},
      </if>
      <if test="sizeId != null">
        #{sizeId,jdbcType=INTEGER},
      </if>
      <if test="sizeName != null">
        #{sizeName,jdbcType=VARCHAR},
      </if>
      <if test="imageUrl != null">
        #{imageUrl,jdbcType=VARCHAR},
      </if>
      <if test="colorId != null">
        #{colorId,jdbcType=SMALLINT},
      </if>
      <if test="colorName != null">
        #{colorName,jdbcType=VARCHAR},
      </if>
      <if test="goodsPrice != null">
        #{goodsPrice,jdbcType=DECIMAL},
      </if>
      <if test="status != null">
        #{status,jdbcType=TINYINT},
      </if>
      <if test="batchNo != null">
        #{batchNo,jdbcType=BIGINT},
      </if>
    </trim>
  </insert>



  <update id="updateStatusBySkpu" parameterType="com.yohoufo.dal.order.model.SellerOrderGoods">
    update seller_order_goods
    <set>
      <if test="status != null">
        status = #{status,jdbcType=TINYINT},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
    and status = #{exceptStatus,jdbcType=TINYINT}
  </update>


  <update id="updateByPrimaryKeySelective" parameterType="com.yohoufo.dal.order.model.SellerOrderGoods">
    update seller_order_goods
    <set>
      <if test="productId != null">
        product_id = #{productId,jdbcType=INTEGER},
      </if>
      <if test="productName != null">
        product_name = #{productName,jdbcType=VARCHAR},
      </if>
      <if test="storageId != null">
        storage_id = #{storageId,jdbcType=INTEGER},
      </if>
      <if test="depotNo != null">
        depot_no = #{depotNo,jdbcType=INTEGER},
      </if>
      <if test="sizeId != null">
        size_id = #{sizeId,jdbcType=INTEGER},
      </if>
      <if test="sizeName != null">
        size_name = #{sizeName,jdbcType=VARCHAR},
      </if>

      <if test="colorId != null">
        color_id = #{colorId,jdbcType=SMALLINT},
      </if>
      <if test="colorName != null">
        color_name = #{colorName,jdbcType=VARCHAR},
      </if>
      <if test="goodsPrice != null">
        goods_price = #{goodsPrice,jdbcType=DECIMAL},
      </if>
      <if test="status != null">
        status = #{status,jdbcType=TINYINT},
      </if>
      <if test="isDel != null">
        is_del = #{isDel,jdbcType=TINYINT}
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>


  <update id="updateByPrimaryKeys">
    update seller_order_goods
    <set>
    <if test="condition.goodsPrice != null">
      goods_price = #{condition.goodsPrice,jdbcType=DECIMAL},
    </if>
    <if test="condition.status != null">
      status = #{condition.status,jdbcType=TINYINT},
    </if>
    </set>
    where id in
    <foreach collection="ids" item="id" open="(" close=")" separator=",">
      #{id,jdbcType=INTEGER}
    </foreach>
  </update>

  <update id="updateByPrimaryKey" parameterType="com.yohoufo.dal.order.model.SellerOrderGoods">
    update seller_order_goods
    set product_id = #{productId,jdbcType=INTEGER},
      product_name = #{productName,jdbcType=VARCHAR},
      storage_id = #{storageId,jdbcType=INTEGER},
      depot_no = #{depotNo,jdbcType=INTEGER},
      size_id = #{sizeId,jdbcType=INTEGER},
      size_name = #{sizeName,jdbcType=VARCHAR},
      color_id = #{colorId,jdbcType=SMALLINT},
      color_name = #{colorName,jdbcType=VARCHAR},
      goods_price = #{goodsPrice,jdbcType=DECIMAL},
      status = #{status,jdbcType=TINYINT}
    where id = #{id,jdbcType=INTEGER}
  </update>

  <sql id="sql_where_4_select_UidStatusGBBNList">
    uid = #{uid,jdbcType=INTEGER} and is_del = 1
    <if test="statusList != null">
      and status in
      <foreach item="status" index="index" collection="statusList" open="(" separator="," close=")">
        #{status, jdbcType=TINYINT}
      </foreach>
    </if>
    group by batch_no , goods_price ,`status`
  </sql>
  <select id="selectCntByUidStatusGBBNList" resultType="java.lang.Integer">
    SELECT COUNT(*) FROM (SELECT batch_no FROM `seller_order_goods`
    WHERE <include refid="sql_where_4_select_UidStatusGBBNList"/> ) t
  </select>

  <select id="selectByUidStatusGBBNList" resultMap="BaseResultMap">
    select <include refid="Base_Column_List" />,count(*) num,GROUP_CONCAT(id) skup_list from seller_order_goods
    where <include refid="sql_where_4_select_UidStatusGBBNList"/>
    order by id desc
    limit #{offset, jdbcType=INTEGER}, #{limit, jdbcType=INTEGER}
  </select>

  <select id="selectByUidStatusGBBN" parameterType="com.yohoufo.dal.order.model.SellerOrderGoods" resultMap="BaseResultMap">
    select <include refid="Base_Column_List" />,count(*) num,GROUP_CONCAT(id) skup_list from seller_order_goods
    where uid = #{uid,jdbcType=INTEGER} and is_del = 1
    and batch_no =  #{batchNo,jdbcType=BIGINT}
    and goods_price = #{goodsPrice,jdbcType=DECIMAL}
    and status = #{status,jdbcType=TINYINT}
    group by batch_no , goods_price ,`status`
    limit 1
  </select>


  <select id="selectGPByBNStatusPrice" parameterType="com.yohoufo.dal.order.model.SellerOrderGoods" resultMap="BaseResultMap">
    select <include refid="Base_Column_List" /> from seller_order_goods
    where uid = #{uid,jdbcType=INTEGER} and is_del = 1
    and batch_no =  #{batchNo,jdbcType=BIGINT}
    and goods_price = #{goodsPrice,jdbcType=DECIMAL}
    and status = #{status,jdbcType=TINYINT}
    order by id desc
  </select>

  <update id="batchDelete">
    update seller_order_goods set is_del = 0
    where id in
    <foreach collection="skups" item="id" open="(" close=")" separator=",">
      #{id,jdbcType=INTEGER}
    </foreach>
  </update>

  <select id="selectByUidBNStatusGBBPSList" resultMap="BaseResultMap">
    select <include refid="Base_Column_List" />,count(*) num,GROUP_CONCAT(id) skup_list from seller_order_goods
    where batch_no = #{batchNo,jdbcType=BIGINT}
    and <include refid="sql_where_4_select_UidStatusGBBNList"/>
    order by id desc
  </select>



  <select id="selectByGroup" resultMap="BaseResultMap">
    select <include refid="Base_Column_List" />,count(*) num,GROUP_CONCAT(id) skup_list from seller_order_goods
    where 1=1
    <if test="id != null">
      and id &lt; #{id,jdbcType=INTEGER}
    </if>
    and <include refid="sql_where_4_select_UidStatusGBBNList"/>
    order by id desc
    limit #{limit, jdbcType=INTEGER}
  </select>

  <select id="selectByUidStorageStatusGBBPSList" resultMap="BaseResultMap">
    select <include refid="Base_Column_List" /> from seller_order_goods
    where storage_id = #{storageId,jdbcType=INTEGER}
    and <include refid="sql_where_4_select_UidStatusGBBNList"/>
  </select>
</mapper>