|
|
|
|
<?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="cc.hiver.mall.checkstock.mapper.CheckStockDetailMapper">
|
|
|
|
|
<resultMap id="BaseResultMap" type="cc.hiver.mall.checkstock.entity.CheckStockDetail">
|
|
|
|
|
<id column="id" jdbcType="VARCHAR" property="id" />
|
|
|
|
|
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
|
|
|
|
|
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
|
|
|
|
<result column="del_flag" jdbcType="INTEGER" property="delFlag" />
|
|
|
|
|
<result column="update_by" jdbcType="VARCHAR" property="updateBy" />
|
|
|
|
|
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
|
|
|
|
<result column="check_stock_id" jdbcType="VARCHAR" property="checkStockId" />
|
|
|
|
|
<result column="product_id" jdbcType="VARCHAR" property="productId" />
|
|
|
|
|
<result column="product_name" jdbcType="VARCHAR" property="productName" />
|
|
|
|
|
<result column="product_picture" jdbcType="VARCHAR" property="productPicture" />
|
|
|
|
|
<result column="product_sn" jdbcType="VARCHAR" property="productSn" />
|
|
|
|
|
<result column="shop_id" jdbcType="VARCHAR" property="shopId" />
|
|
|
|
|
<result column="attribute_list" jdbcType="VARCHAR" property="attributeList" />
|
|
|
|
|
<result column="pd_num" jdbcType="INTEGER" property="pdNum" />
|
|
|
|
|
<result column="change_count" jdbcType="INTEGER" property="changeCount" />
|
|
|
|
|
<result column="stock_count" jdbcType="INTEGER" property="stockCount" />
|
|
|
|
|
</resultMap>
|
|
|
|
|
<sql id="Example_Where_Clause">
|
|
|
|
|
<where>
|
|
|
|
|
<foreach collection="oredCriteria" item="criteria" separator="or">
|
|
|
|
|
<if test="criteria.valid">
|
|
|
|
|
<trim prefix="(" prefixOverrides="and" suffix=")">
|
|
|
|
|
<foreach collection="criteria.criteria" item="criterion">
|
|
|
|
|
<choose>
|
|
|
|
|
<when test="criterion.noValue">
|
|
|
|
|
and ${criterion.condition}
|
|
|
|
|
</when>
|
|
|
|
|
<when test="criterion.singleValue">
|
|
|
|
|
and ${criterion.condition} #{criterion.value}
|
|
|
|
|
</when>
|
|
|
|
|
<when test="criterion.betweenValue">
|
|
|
|
|
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
|
|
|
|
</when>
|
|
|
|
|
<when test="criterion.listValue">
|
|
|
|
|
and ${criterion.condition}
|
|
|
|
|
<foreach close=")" collection="criterion.value" item="listItem" open="("
|
|
|
|
|
separator=",">
|
|
|
|
|
#{listItem}
|
|
|
|
|
</foreach>
|
|
|
|
|
</when>
|
|
|
|
|
</choose>
|
|
|
|
|
</foreach>
|
|
|
|
|
</trim>
|
|
|
|
|
</if>
|
|
|
|
|
</foreach>
|
|
|
|
|
</where>
|
|
|
|
|
</sql>
|
|
|
|
|
<sql id="Update_By_Example_Where_Clause">
|
|
|
|
|
<where>
|
|
|
|
|
<foreach collection="example.oredCriteria" item="criteria" separator="or">
|
|
|
|
|
<if test="criteria.valid">
|
|
|
|
|
<trim prefix="(" prefixOverrides="and" suffix=")">
|
|
|
|
|
<foreach collection="criteria.criteria" item="criterion">
|
|
|
|
|
<choose>
|
|
|
|
|
<when test="criterion.noValue">
|
|
|
|
|
and ${criterion.condition}
|
|
|
|
|
</when>
|
|
|
|
|
<when test="criterion.singleValue">
|
|
|
|
|
and ${criterion.condition} #{criterion.value}
|
|
|
|
|
</when>
|
|
|
|
|
<when test="criterion.betweenValue">
|
|
|
|
|
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
|
|
|
|
</when>
|
|
|
|
|
<when test="criterion.listValue">
|
|
|
|
|
and ${criterion.condition}
|
|
|
|
|
<foreach close=")" collection="criterion.value" item="listItem" open="("
|
|
|
|
|
separator=",">
|
|
|
|
|
#{listItem}
|
|
|
|
|
</foreach>
|
|
|
|
|
</when>
|
|
|
|
|
</choose>
|
|
|
|
|
</foreach>
|
|
|
|
|
</trim>
|
|
|
|
|
</if>
|
|
|
|
|
</foreach>
|
|
|
|
|
</where>
|
|
|
|
|
</sql>
|
|
|
|
|
<sql id="Base_Column_List">
|
|
|
|
|
id, create_by, create_time, del_flag, update_by, update_time, check_stock_id, product_id, product_name,
|
|
|
|
|
product_picture, product_sn, shop_id, attribute_list, pd_num, change_count, stock_count
|
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
|
|
<insert id="batchInsertCheckStock" parameterType="java.util.List">
|
|
|
|
|
insert into t_check_stock_detail (id, create_by, create_time, del_flag, update_by, update_time, check_stock_id, product_id, product_name,
|
|
|
|
|
product_picture, product_sn, shop_id, attribute_list, pd_num, change_count, stock_count)
|
|
|
|
|
values
|
|
|
|
|
<foreach collection="checkStockDetailList" item="checkStockDetail" separator=",">
|
|
|
|
|
(#{checkStockDetail.id},#{checkStockDetail.createBy},#{checkStockDetail.createTime},#{checkStockDetail.delFlag},
|
|
|
|
|
#{checkStockDetail.updateBy},#{checkStockDetail.updateTime},#{checkStockDetail.checkStockId},#{checkStockDetail.productId},#{checkStockDetail.productName},
|
|
|
|
|
#{checkStockDetail.productPicture},#{checkStockDetail.productSn},#{checkStockDetail.shopId},#{checkStockDetail.attributeList},#{checkStockDetail.pdNum},
|
|
|
|
|
#{checkStockDetail.changeCount},#{checkStockDetail.stockCount})
|
|
|
|
|
</foreach>
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<select id="getByCheckStockDetailByCheckId" parameterType="java.lang.String" resultMap="BaseResultMap">
|
|
|
|
|
select
|
|
|
|
|
<include refid="Base_Column_List"/>
|
|
|
|
|
from t_check_stock_detail
|
|
|
|
|
where check_stock_id = #{checkStockId,jdbcType=VARCHAR}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getByCheckStockDetailByCheckIdOfPage" resultMap="BaseResultMap">
|
|
|
|
|
select
|
|
|
|
|
<include refid="Base_Column_List"/>
|
|
|
|
|
from t_check_stock_detail
|
|
|
|
|
where check_stock_id = #{checkStockPageQuery.checkStockId,jdbcType=VARCHAR}
|
|
|
|
|
and product_id in
|
|
|
|
|
<foreach item="productId" collection="checkStockPageQuery.productIdList" open="(" separator="," close=")">
|
|
|
|
|
#{productId}
|
|
|
|
|
</foreach>
|
|
|
|
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getByCheckStockProductByCheckId" resultType="java.lang.String">
|
|
|
|
|
SELECT
|
|
|
|
|
product_id
|
|
|
|
|
FROM
|
|
|
|
|
t_check_stock_detail
|
|
|
|
|
WHERE
|
|
|
|
|
check_stock_id = #{checkStockPageQuery.checkStockId,jdbcType=VARCHAR}
|
|
|
|
|
GROUP BY
|
|
|
|
|
product_id
|
|
|
|
|
order by product_id
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<delete id="deleteByProductId" parameterType="java.lang.String">
|
|
|
|
|
delete
|
|
|
|
|
from t_check_stock_detail
|
|
|
|
|
where shop_id = #{shopId,jdbcType=VARCHAR}
|
|
|
|
|
and check_stock_id = #{checkStockId,jdbcType=VARCHAR}
|
|
|
|
|
and product_id = #{productId,jdbcType=VARCHAR}
|
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
<select id="getCheckStockTjVos" resultType="cc.hiver.mall.checkstock.vo.CheckStockTjVo">
|
|
|
|
|
SELECT
|
|
|
|
|
dd.product_id,
|
|
|
|
|
dd.check_stock_id,
|
|
|
|
|
sum( dd.change_count ) change_count,
|
|
|
|
|
tt.purchase_price,(
|
|
|
|
|
CASE
|
|
|
|
|
WHEN dd.change_count > 0 THEN
|
|
|
|
|
1
|
|
|
|
|
WHEN dd.change_count < 0 THEN
|
|
|
|
|
2
|
|
|
|
|
END
|
|
|
|
|
) AS change_type
|
|
|
|
|
FROM
|
|
|
|
|
t_check_stock_detail dd
|
|
|
|
|
JOIN t_product tt ON dd.product_id = tt.id
|
|
|
|
|
WHERE
|
|
|
|
|
dd.shop_id = #{shopId,jdbcType=VARCHAR}
|
|
|
|
|
GROUP BY
|
|
|
|
|
dd.product_id,
|
|
|
|
|
change_type,
|
|
|
|
|
dd.check_stock_id
|
|
|
|
|
</select>
|
|
|
|
|
</mapper>
|