You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

486 lines
18 KiB

<?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.dao.mapper.StockLogMapper">
<resultMap id="BaseResultMap" type="cc.hiver.mall.entity.StockLog">
<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="order_id" jdbcType="VARCHAR" property="orderId" />
<result column="detail_id" jdbcType="VARCHAR" property="detailId" />
<result column="product_id" jdbcType="VARCHAR" property="productId" />
<result column="attribute_list" jdbcType="VARCHAR" property="attributeList" />
<result column="stock" jdbcType="INTEGER" property="stock" />
<result column="product_count" jdbcType="INTEGER" property="productCount" />
<result column="change_type" jdbcType="VARCHAR" property="changeType" />
<result column="price" jdbcType="DECIMAL" property="price" />
<result column="purchase_price" jdbcType="DECIMAL" property="purchasePrice" />
<result column="wholesale_price" jdbcType="DECIMAL" property="wholesalePrice" />
<result column="shop_id" jdbcType="VARCHAR" property="shopId" />
<result column="ocr_picture_path" jdbcType="VARCHAR" property="ocrPicturePath" />
</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, order_id,detail_id,product_id, attribute_list,
stock, product_count, change_type, price, purchase_price, wholesale_price, shop_id, ocr_picture_path
</sql>
<select id="selectByExample" parameterType="cc.hiver.mall.entity.StockLogExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from t_stock_log
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from t_stock_log
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from t_stock_log
where id = #{id,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="cc.hiver.mall.entity.StockLogExample">
delete from t_stock_log
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="cc.hiver.mall.entity.StockLog">
insert into t_stock_log (id, create_by, create_time,
del_flag, update_by, update_time,
order_id,detail_id,product_id, attribute_list, stock,
product_count, change_type, price,
purchase_price, wholesale_price, shop_id,ocr_picture_path
)
values (#{id,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{delFlag,jdbcType=INTEGER}, #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP},
#{orderId,jdbcType=VARCHAR},#{detailId,jdbcType=VARCHAR},#{productId,jdbcType=VARCHAR}, #{attributeList,jdbcType=VARCHAR}, #{stock,jdbcType=INTEGER},
#{productCount,jdbcType=INTEGER}, #{changeType,jdbcType=VARCHAR}, #{price,jdbcType=DECIMAL},
#{purchasePrice,jdbcType=DECIMAL}, #{wholesalePrice,jdbcType=DECIMAL}, #{shopId,jdbcType=VARCHAR},
#{ocrPicturePath,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="cc.hiver.mall.entity.StockLog">
insert into t_stock_log
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="createBy != null">
create_by,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="delFlag != null">
del_flag,
</if>
<if test="updateBy != null">
update_by,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="orderId != null">
order_id,
</if>
<if test="detailId != null">
detail_id,
</if>
<if test="productId != null">
product_id,
</if>
<if test="attributeList != null">
attribute_list,
</if>
<if test="stock != null">
stock,
</if>
<if test="productCount != null">
product_count,
</if>
<if test="changeType != null">
change_type,
</if>
<if test="price != null">
price,
</if>
<if test="purchasePrice != null">
purchase_price,
</if>
<if test="wholesalePrice != null">
wholesale_price,
</if>
<if test="shopId != null">
shop_id,
</if>
<if test="ocrPicturePath != null">
#{ocrPicturePath,jdbcType=VARCHAR}
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
#{createBy,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="delFlag != null">
#{delFlag,jdbcType=INTEGER},
</if>
<if test="updateBy != null">
#{updateBy,jdbcType=VARCHAR},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="orderId != null">
#{orderId,jdbcType=VARCHAR},
</if>
<if test="detailId != null">
#{detailId,jdbcType=VARCHAR},
</if>
<if test="de != null">
#{productId,jdbcType=VARCHAR},
</if>
<if test="attributeList != null">
#{attributeList,jdbcType=VARCHAR},
</if>
<if test="stock != null">
#{stock,jdbcType=INTEGER},
</if>
<if test="productCount != null">
#{productCount,jdbcType=INTEGER},
</if>
<if test="changeType != null">
#{changeType,jdbcType=VARCHAR},
</if>
<if test="price != null">
#{price,jdbcType=DECIMAL},
</if>
<if test="purchasePrice != null">
#{purchasePrice,jdbcType=DECIMAL},
</if>
<if test="wholesalePrice != null">
#{wholesalePrice,jdbcType=DECIMAL},
</if>
<if test="shopId != null">
#{shopId,jdbcType=VARCHAR},
</if>
<if test="ocrPicturePath != null">
#{ocrPicturePath,jdbcType=VARCHAR}
</if>
</trim>
</insert>
<select id="countByExample" parameterType="cc.hiver.mall.entity.StockLogExample" resultType="java.lang.Long">
select count(*) from t_stock_log
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update t_stock_log
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=VARCHAR},
</if>
<if test="record.createBy != null">
create_by = #{record.createBy,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if test="record.delFlag != null">
del_flag = #{record.delFlag,jdbcType=INTEGER},
</if>
<if test="record.updateBy != null">
update_by = #{record.updateBy,jdbcType=VARCHAR},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
</if>
<if test="record.orderId != null">
order_id = #{record.orderId,jdbcType=VARCHAR},
</if>
<if test="record.detailId != null">
detail_id = #{record.detailId,jdbcType=VARCHAR},
</if>
<if test="record.productId != null">
product_id = #{record.productId,jdbcType=VARCHAR},
</if>
<if test="record.attributeList != null">
attribute_list = #{record.attributeList,jdbcType=VARCHAR},
</if>
<if test="record.stock != null">
stock = #{record.stock,jdbcType=INTEGER},
</if>
<if test="record.productCount != null">
product_count = #{record.productCount,jdbcType=INTEGER},
</if>
<if test="record.changeType != null">
change_type = #{record.changeType,jdbcType=VARCHAR},
</if>
<if test="record.price != null">
price = #{record.price,jdbcType=DECIMAL},
</if>
<if test="record.purchasePrice != null">
purchase_price = #{record.purchasePrice,jdbcType=DECIMAL},
</if>
<if test="record.wholesalePrice != null">
wholesale_price = #{record.wholesalePrice,jdbcType=DECIMAL},
</if>
<if test="record.shopId != null">
shop_id = #{record.shopId,jdbcType=VARCHAR},
</if>
<if test="record.ocrPicturePath != null">
ocr_picture_path = #{record.ocrPicturePath,jdbcType=VARCHAR}
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update t_stock_log
set id = #{record.id,jdbcType=VARCHAR},
create_by = #{record.createBy,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
del_flag = #{record.delFlag,jdbcType=INTEGER},
update_by = #{record.updateBy,jdbcType=VARCHAR},
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
order_id = #{record.orderId,jdbcType=VARCHAR},
detail_id = #{record.detailId,jdbcType=VARCHAR},
product_id = #{record.productId,jdbcType=VARCHAR},
attribute_list = #{record.attributeList,jdbcType=VARCHAR},
stock = #{record.stock,jdbcType=INTEGER},
product_count = #{record.productCount,jdbcType=INTEGER},
change_type = #{record.changeType,jdbcType=VARCHAR},
price = #{record.price,jdbcType=DECIMAL},
purchase_price = #{record.purchasePrice,jdbcType=DECIMAL},
wholesale_price = #{record.wholesalePrice,jdbcType=DECIMAL},
shop_id = #{record.shopId,jdbcType=VARCHAR},
ocr_picture_path = #{record.ocrPicturePath,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="cc.hiver.mall.entity.StockLog">
update t_stock_log
<set>
<if test="createBy != null">
create_by = #{createBy,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="delFlag != null">
del_flag = #{delFlag,jdbcType=INTEGER},
</if>
<if test="updateBy != null">
update_by = #{updateBy,jdbcType=VARCHAR},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="orderId != null">
order_id = #{orderId,jdbcType=VARCHAR},
</if>
<if test="detailId != null">
detail_id = #{detailId,jdbcType=VARCHAR},
</if>
<if test="productId != null">
product_id = #{productId,jdbcType=VARCHAR},
</if>
<if test="attributeList != null">
attribute_list = #{attributeList,jdbcType=VARCHAR},
</if>
<if test="stock != null">
stock = #{stock,jdbcType=INTEGER},
</if>
<if test="productCount != null">
product_count = #{productCount,jdbcType=INTEGER},
</if>
<if test="changeType != null">
change_type = #{changeType,jdbcType=VARCHAR},
</if>
<if test="price != null">
price = #{price,jdbcType=DECIMAL},
</if>
<if test="purchasePrice != null">
purchase_price = #{purchasePrice,jdbcType=DECIMAL},
</if>
<if test="wholesalePrice != null">
wholesale_price = #{wholesalePrice,jdbcType=DECIMAL},
</if>
<if test="shopId != null">
shop_id = #{shopId,jdbcType=VARCHAR},
</if>
<if test="ocrPicturePath != null">
ocr_picture_path = #{ocrPicturePath,jdbcType=VARCHAR}
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="cc.hiver.mall.entity.StockLog">
update t_stock_log
set create_by = #{createBy,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
del_flag = #{delFlag,jdbcType=INTEGER},
update_by = #{updateBy,jdbcType=VARCHAR},
update_time = #{updateTime,jdbcType=TIMESTAMP},
order_id = #{orderId,jdbcType=VARCHAR},
detail_id = #{detailId,jdbcType=VARCHAR},
product_id = #{productId,jdbcType=VARCHAR},
attribute_list = #{attributeList,jdbcType=VARCHAR},
stock = #{stock,jdbcType=INTEGER},
product_count = #{productCount,jdbcType=INTEGER},
change_type = #{changeType,jdbcType=VARCHAR},
price = #{price,jdbcType=DECIMAL},
purchase_price = #{purchasePrice,jdbcType=DECIMAL},
wholesale_price = #{wholesalePrice,jdbcType=DECIMAL},
shop_id = #{shopId,jdbcType=VARCHAR},
ocr_picture_path = #{ocrPicturePath,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
<select id="getByPurchaseId" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from t_stock_log
where order_id = #{id,jdbcType=VARCHAR}
</select>
<select id="getByPurchaseIds" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from t_stock_log
where del_flag ='0'
<if test='productId != null and productId.trim() neq "" '>
and product_id = #{productId,jdbcType=VARCHAR}
</if>
and order_id in
<foreach close=")" collection="purchaseIds" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</select>
<insert id="batchSaveStockLogList" parameterType="java.util.List">
insert into t_stock_log (id, create_by, create_time, del_flag, update_by, update_time, order_id,detail_id,product_id, attribute_list,
stock, product_count, change_type, price, purchase_price, wholesale_price, shop_id, ocr_picture_path) values
<foreach item="stockLog" collection="stockLogList" index="index" separator=",">
(#{stockLog.id}, #{stockLog.createBy}, #{stockLog.createTime}, #{stockLog.delFlag}, #{stockLog.updateBy},
#{stockLog.updateTime}, #{stockLog.orderId},#{stockLog.detailId}, #{stockLog.productId}, #{stockLog.attributeList},
#{stockLog.stock}, #{stockLog.productCount}, #{stockLog.changeType}, #{stockLog.price}, #{stockLog.purchasePrice},
#{stockLog.wholesalePrice}, #{stockLog.shopId},#{stockLog.ocrPicturePath})
</foreach>
</insert>
<update id="deleteByPurchaseId" parameterType="java.lang.String">
update t_stock_log set del_flag = '1' where order_id = #{purchaseId,jdbcType=VARCHAR}
</update>
<!--根据入库单id真删除-->
<delete id="realDeleteByPurchaseId" parameterType="java.lang.String">
delete from t_stock_log
where order_id = #{purchaseId,jdbcType=VARCHAR}
</delete>
<update id="putInUpdatePurchasePrice">
<foreach collection="purchaseDetails" item="item" separator=";" open="" close="">
update t_stock_log set purchase_price = #{item.purchasePrice} WHERE product_id = #{item.productId} and purchase_price is null
</foreach>
</update>
<select id="getPurchaseDetails" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_stock_log
where order_id in
<foreach close=")" collection="purchaseIdList" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</select>
<select id="getByProductIds" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_stock_log
where order_id = #{purchaseId,jdbcType=VARCHAR}
and product_id in
<foreach close=")" collection="productIdList" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</select>
</mapper>