SellerOrderGoodsViewMapper.xml 8.07 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.SellerOrderGoodsViewMapper">
  <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="storage_num" jdbcType="INTEGER" property="storageNum" />
    <result column="size_num" jdbcType="INTEGER" property="sizeNum" />
    <result column="attributes" jdbcType="INTEGER" property="attributes" />
  </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,attributes
  </sql>

  <select id="selectEntryCntByUidStatusGBSkc" resultType="java.lang.Integer">
    SELECT COUNT(*) from (select sog.id FROM seller_order_goods sog,seller_order so
    WHERE sog.id = so.skup and sog.uid = #{uid,jdbcType=INTEGER}
    and sog.is_del = 1 AND so.payment = 11
    <include refid="sql_where_skupTyps_scope" />
    <if test="statusList != null">
      and sog.status in
      <foreach item="status" index="index" collection="statusList" open="(" separator="," close=")">
        #{status, jdbcType=TINYINT}
      </foreach>
    </if>
    GROUP BY sog.uid,product_id) t
  </select>

  <sql id="Base_Column_List_with_table_name">
    sog.id as id, sog.uid as uid, product_id, product_name,storage_id,depot_no,size_id,size_name,
    color_id, color_name, goods_price, sog.status as status, image_url, sog.is_del as is_del, batch_no,
    sog.attributes as attributes
  </sql>

  <select id="selectEntryListByUidStatusGBSkc" resultMap="BaseResultMap">
    SELECT <include refid="Base_Column_List_with_table_name" /> FROM seller_order_goods sog,seller_order so
    WHERE sog.id = so.skup and sog.uid = #{uid,jdbcType=INTEGER}
    and sog.is_del = 1 AND so.payment = 11
    <include refid="sql_where_skupTyps_scope" />
    <if test="statusList != null">
      and sog.status in
      <foreach item="status" index="index" collection="statusList" open="(" separator="," close=")">
        #{status, jdbcType=TINYINT}
      </foreach>
    </if>
    GROUP BY sog.uid,product_id ORDER BY id DESC
    limit #{offset, jdbcType=INTEGER}, #{limit, jdbcType=INTEGER}
  </select>

  <select id="selectByUidStatusGBSkc" resultMap="BaseResultMap">
    SELECT `uid`,`product_id`,`product_name`,`color_id`,`color_name`,COUNT(size_id) size_num,SUM(size_storage) storage_num FROM
    (
    SELECT sog.`uid`,`product_id`,`product_name`,`color_id`,`color_name`,size_id,COUNT(`size_id`) size_storage
    FROM seller_order_goods sog,seller_order so
    WHERE sog.id = so.skup and sog.uid = #{uid,jdbcType=INTEGER}
    and sog.is_del = 1 AND so.payment = 11
    <include refid="sql_where_skupTyps_scope" />
    <if test="statusList != null">
      and sog.status in
      <foreach item="status" index="index" collection="statusList" open="(" separator="," close=")">
        #{status, jdbcType=TINYINT}
      </foreach>
    </if>
     AND product_id = #{productId,jdbcType=INTEGER}
    GROUP BY sog.uid,size_id
    ) t
  </select>

  <select id="selectNotEntryCntByUidStatus" resultType="java.lang.Integer">
    SELECT COUNT(*) from (select sog.id FROM seller_order_goods sog,seller_order so
    WHERE sog.id = so.skup and sog.uid = #{uid,jdbcType=INTEGER} and sog.is_del = 1
    AND (so.payment != 11 or so.payment is null)
    <include refid="sql_where_skupTyps_scope" />
    <if test="statusList != null">
      and sog.status in
      <foreach item="status" index="index" collection="statusList" open="(" separator="," close=")">
        #{status, jdbcType=TINYINT}
      </foreach>
    </if>
    ) t
  </select>

  <select id="selectNotEntryListByUidStatus" resultMap="BaseResultMap">
    SELECT <include refid="Base_Column_List_with_table_name" /> FROM seller_order_goods sog,seller_order so
    WHERE sog.id = so.skup and sog.uid = #{uid,jdbcType=INTEGER} and sog.is_del = 1
    AND (so.payment != 11 or so.payment is null)
    <include refid="sql_where_skupTyps_scope" />
    <if test="statusList != null">
      and sog.status in
      <foreach item="status" index="index" collection="statusList" open="(" separator="," close=")">
        #{status, jdbcType=TINYINT}
      </foreach>
    </if>
     ORDER BY id DESC
    limit #{offset, jdbcType=INTEGER}, #{limit, jdbcType=INTEGER}
  </select>

  <select id="selectEntryListByUidStatusGBSku" resultMap="BaseResultMap">
    SELECT <include refid="Base_Column_List_with_table_name" />,COUNT(`size_id`) storage_num
    FROM seller_order_goods sog,seller_order so WHERE sog.id = so.skup
    AND sog.uid = #{condition.uid,jdbcType=INTEGER} AND so.payment = 11
    <include refid="sql_where_skupTyps_scope" />
    AND sog.status = #{condition.status, jdbcType=TINYINT}
    AND product_id = #{condition.productId,jdbcType=INTEGER}
    GROUP BY sog.attributes,size_id,`goods_price`
    order by size_id,goods_price
    limit #{offset, jdbcType=INTEGER}, #{limit, jdbcType=INTEGER}
  </select>

  <select id="selectEntryCntByUidStatusGBSku" resultType="java.lang.Integer">
    select count(*) FROM
    (
    SELECT size_id ,goods_price
    FROM seller_order_goods sog,seller_order so WHERE sog.id = so.skup
    AND sog.uid = #{condition.uid,jdbcType=INTEGER} AND so.payment = 11
    <include refid="sql_where_skupTyps_scope" />
    AND sog.status = #{condition.status, jdbcType=TINYINT}
    AND product_id = #{condition.productId,jdbcType=INTEGER}

    GROUP BY sog.attributes,size_id,`goods_price`
    ) t
  </select>

  <sql id="sql_where_skupTyps_scope" >
    and attributes in
    <foreach collection="skupTypes" item="skupType" open="(" close=")" separator=",">
      #{skupType,jdbcType=INTEGER}
    </foreach>
  </sql>

  <select id="selectCanSellByStorageId" resultMap="BaseResultMap">
    SELECT <include refid="Base_Column_List" />
    FROM seller_order_goods
    WHERE storage_id = #{storageId,jdbcType=INTEGER} and status = 1
  </select>


  <select id="selectCntByUidTypeStatus" resultType="java.lang.Integer">
    SELECT COUNT(*) from (select sog.id FROM seller_order_goods sog,seller_order so
    WHERE sog.id = so.skup and sog.uid = #{uid,jdbcType=INTEGER} and sog.is_del = 1
    <include refid="sql_where_skupTyps_scope" />
    <if test="statusList != null">
      and sog.status in
      <foreach item="status" index="index" collection="statusList" open="(" separator="," close=")">
        #{status, jdbcType=TINYINT}
      </foreach>
    </if>
    ) t
  </select>

  <select id="selectAllByUidTypeStatus" resultMap="BaseResultMap">
    SELECT <include refid="Base_Column_List_with_table_name" /> FROM seller_order_goods sog,seller_order so
    WHERE sog.id = so.skup and sog.uid = #{uid,jdbcType=INTEGER} and sog.is_del = 1
    <include refid="sql_where_skupTyps_scope" />
    <if test="statusList != null">
      and sog.status in
      <foreach item="status" index="index" collection="statusList" open="(" separator="," close=")">
        #{status, jdbcType=TINYINT}
      </foreach>
    </if>
    ORDER BY id DESC
    limit #{offset, jdbcType=INTEGER}, #{limit, jdbcType=INTEGER}
  </select>

</mapper>