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.
 
 

536 lines
20 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.SaleDetailMapper">
<resultMap id="BaseResultMap" type="cc.hiver.mall.entity.SaleDetail">
<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="sale_id" jdbcType="VARCHAR" property="saleId" />
<result column="product_id" jdbcType="VARCHAR" property="productId" />
<result column="product_name" jdbcType="VARCHAR" property="productName" />
<result column="unit" jdbcType="VARCHAR" property="unit" />
<result column="shop_id" jdbcType="VARCHAR" property="shopId" />
<result column="category_id" jdbcType="VARCHAR" property="categoryId" />
<result column="attribute_list" jdbcType="VARCHAR" property="attributeList" />
<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="product_count" jdbcType="INTEGER" property="productCount" />
<result column="discount" jdbcType="DECIMAL" property="discount" />
<result column="discount_amount" jdbcType="DECIMAL" property="discountAmount" />
<result column="real_price" jdbcType="DECIMAL" property="realPrice" />
<result column="product_picture" jdbcType="VARCHAR" property="productPicture" />
<result column="product_sn" jdbcType="VARCHAR" property="productSn" />
</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, sale_id, product_id,
product_name, unit, shop_id, category_id, attribute_list, price, purchase_price,
wholesale_price, product_count, discount, discount_amount, real_price,product_picture,product_sn
</sql>
<select id="selectByExample" parameterType="cc.hiver.mall.entity.SaleDetailExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from t_sale_detail
<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_sale_detail
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from t_sale_detail
where id = #{id,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="cc.hiver.mall.entity.SaleDetailExample">
delete from t_sale_detail
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="cc.hiver.mall.entity.SaleDetail">
insert into t_sale_detail (id, create_by, create_time,
del_flag, update_by, update_time,
sale_id, product_id, product_name,
unit, shop_id, category_id,
attribute_list, price, purchase_price,
wholesale_price, product_count, discount,
discount_amount, real_price,product_picture,product_sn)
values (#{id,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{delFlag,jdbcType=INTEGER}, #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP},
#{saleId,jdbcType=VARCHAR}, #{productId,jdbcType=VARCHAR}, #{productName,jdbcType=VARCHAR},
#{unit,jdbcType=VARCHAR}, #{shopId,jdbcType=VARCHAR}, #{categoryId,jdbcType=VARCHAR},
#{attributeList,jdbcType=VARCHAR}, #{price,jdbcType=DECIMAL}, #{purchasePrice,jdbcType=DECIMAL},
#{wholesalePrice,jdbcType=DECIMAL}, #{productCount,jdbcType=INTEGER}, #{discount,jdbcType=DECIMAL},
#{discountAmount,jdbcType=DECIMAL}, #{realPrice,jdbcType=DECIMAL}, #{productPicture,jdbcType=VARCHAR}, #{productSn,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="cc.hiver.mall.entity.SaleDetail">
insert into t_sale_detail
<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="saleId != null">
sale_id,
</if>
<if test="productId != null">
product_id,
</if>
<if test="productName != null">
product_name,
</if>
<if test="unit != null">
unit,
</if>
<if test="shopId != null">
shop_id,
</if>
<if test="categoryId != null">
category_id,
</if>
<if test="attributeList != null">
attribute_list,
</if>
<if test="price != null">
price,
</if>
<if test="purchasePrice != null">
purchase_price,
</if>
<if test="wholesalePrice != null">
wholesale_price,
</if>
<if test="productCount != null">
product_count,
</if>
<if test="discount != null">
discount,
</if>
<if test="discountAmount != null">
discount_amount,
</if>
<if test="realPrice != null">
real_price,
</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="saleId != null">
#{saleId,jdbcType=VARCHAR},
</if>
<if test="productId != null">
#{productId,jdbcType=VARCHAR},
</if>
<if test="productName != null">
#{productName,jdbcType=VARCHAR},
</if>
<if test="unit != null">
#{unit,jdbcType=VARCHAR},
</if>
<if test="shopId != null">
#{shopId,jdbcType=VARCHAR},
</if>
<if test="categoryId != null">
#{categoryId,jdbcType=VARCHAR},
</if>
<if test="attributeList != null">
#{attributeList,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="productCount != null">
#{productCount,jdbcType=INTEGER},
</if>
<if test="discount != null">
#{discount,jdbcType=DECIMAL},
</if>
<if test="discountAmount != null">
#{discountAmount,jdbcType=DECIMAL},
</if>
<if test="realPrice != null">
#{realPrice,jdbcType=DECIMAL},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="cc.hiver.mall.entity.SaleDetailExample" resultType="java.lang.Long">
select count(*) from t_sale_detail
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update t_sale_detail
<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.saleId != null">
sale_id = #{record.saleId,jdbcType=VARCHAR},
</if>
<if test="record.productId != null">
product_id = #{record.productId,jdbcType=VARCHAR},
</if>
<if test="record.productName != null">
product_name = #{record.productName,jdbcType=VARCHAR},
</if>
<if test="record.unit != null">
unit = #{record.unit,jdbcType=VARCHAR},
</if>
<if test="record.shopId != null">
shop_id = #{record.shopId,jdbcType=VARCHAR},
</if>
<if test="record.categoryId != null">
category_id = #{record.categoryId,jdbcType=VARCHAR},
</if>
<if test="record.attributeList != null">
attribute_list = #{record.attributeList,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.productCount != null">
product_count = #{record.productCount,jdbcType=INTEGER},
</if>
<if test="record.discount != null">
discount = #{record.discount,jdbcType=DECIMAL},
</if>
<if test="record.discountAmount != null">
discount_amount = #{record.discountAmount,jdbcType=DECIMAL},
</if>
<if test="record.realPrice != null">
real_price = #{record.realPrice,jdbcType=DECIMAL},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update t_sale_detail
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},
sale_id = #{record.saleId,jdbcType=VARCHAR},
product_id = #{record.productId,jdbcType=VARCHAR},
product_name = #{record.productName,jdbcType=VARCHAR},
unit = #{record.unit,jdbcType=VARCHAR},
shop_id = #{record.shopId,jdbcType=VARCHAR},
category_id = #{record.categoryId,jdbcType=VARCHAR},
attribute_list = #{record.attributeList,jdbcType=VARCHAR},
price = #{record.price,jdbcType=DECIMAL},
purchase_price = #{record.purchasePrice,jdbcType=DECIMAL},
wholesale_price = #{record.wholesalePrice,jdbcType=DECIMAL},
product_count = #{record.productCount,jdbcType=INTEGER},
discount = #{record.discount,jdbcType=DECIMAL},
discount_amount = #{record.discountAmount,jdbcType=DECIMAL},
real_price = #{record.realPrice,jdbcType=DECIMAL}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="cc.hiver.mall.entity.SaleDetail">
update t_sale_detail
<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="saleId != null">
sale_id = #{saleId,jdbcType=VARCHAR},
</if>
<if test="productId != null">
product_id = #{productId,jdbcType=VARCHAR},
</if>
<if test="productName != null">
product_name = #{productName,jdbcType=VARCHAR},
</if>
<if test="unit != null">
unit = #{unit,jdbcType=VARCHAR},
</if>
<if test="shopId != null">
shop_id = #{shopId,jdbcType=VARCHAR},
</if>
<if test="categoryId != null">
category_id = #{categoryId,jdbcType=VARCHAR},
</if>
<if test="attributeList != null">
attribute_list = #{attributeList,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="productCount != null">
product_count = #{productCount,jdbcType=INTEGER},
</if>
<if test="discount != null">
discount = #{discount,jdbcType=DECIMAL},
</if>
<if test="discountAmount != null">
discount_amount = #{discountAmount,jdbcType=DECIMAL},
</if>
<if test="realPrice != null">
real_price = #{realPrice,jdbcType=DECIMAL},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="cc.hiver.mall.entity.SaleDetail">
update t_sale_detail
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},
sale_id = #{saleId,jdbcType=VARCHAR},
product_id = #{productId,jdbcType=VARCHAR},
product_name = #{productName,jdbcType=VARCHAR},
unit = #{unit,jdbcType=VARCHAR},
shop_id = #{shopId,jdbcType=VARCHAR},
category_id = #{categoryId,jdbcType=VARCHAR},
attribute_list = #{attributeList,jdbcType=VARCHAR},
price = #{price,jdbcType=DECIMAL},
purchase_price = #{purchasePrice,jdbcType=DECIMAL},
wholesale_price = #{wholesalePrice,jdbcType=DECIMAL},
product_count = #{productCount,jdbcType=INTEGER},
discount = #{discount,jdbcType=DECIMAL},
discount_amount = #{discountAmount,jdbcType=DECIMAL},
real_price = #{realPrice,jdbcType=DECIMAL}
where id = #{id,jdbcType=VARCHAR}
</update>
<select id="selectByCondition" parameterType="cc.hiver.mall.entity.SaleDetailExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from t_sale_detail
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<!--根据销售单id 删除之前所有商品信息-->
<delete id="deleteBySaleId" parameterType="java.lang.String">
delete from t_sale_detail
where sale_id = #{saleId,jdbcType=VARCHAR}
</delete>
<insert id="batchSaveSaleDetails" parameterType="java.util.List">
insert into t_sale_detail (id, create_by, create_time,
del_flag, update_by, update_time,
sale_id, product_id, product_name,
unit, shop_id, category_id,
attribute_list, price, purchase_price,
wholesale_price, product_count, discount,
discount_amount, real_price,product_picture,product_sn) values
<foreach collection ="saleDetailList" item="entity" index= "index" separator =",">
(#{entity.id,jdbcType=VARCHAR}, #{entity.createBy,jdbcType=VARCHAR}, #{entity.createTime,jdbcType=TIMESTAMP},
#{entity.delFlag,jdbcType=INTEGER}, #{entity.updateBy,jdbcType=VARCHAR}, #{entity.updateTime,jdbcType=TIMESTAMP},
#{entity.saleId,jdbcType=VARCHAR}, #{entity.productId,jdbcType=VARCHAR}, #{entity.productName,jdbcType=VARCHAR},
#{entity.unit,jdbcType=VARCHAR}, #{entity.shopId,jdbcType=VARCHAR}, #{entity.categoryId,jdbcType=VARCHAR},
#{entity.attributeList,jdbcType=VARCHAR}, #{entity.price,jdbcType=DECIMAL}, #{entity.purchasePrice,jdbcType=DECIMAL},
#{entity.wholesalePrice,jdbcType=DECIMAL}, #{entity.productCount,jdbcType=INTEGER}, #{entity.discount,jdbcType=DECIMAL},
#{entity.discountAmount,jdbcType=DECIMAL}, #{entity.realPrice,jdbcType=DECIMAL}, #{entity.productPicture,jdbcType=VARCHAR}, #{entity.productSn,jdbcType=VARCHAR})
</foreach>
</insert>
<select id="listOfShopAll" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM
t_sale_detail
WHERE
sale_id IN (
SELECT id FROM t_sale
WHERE
status != '2'
and status != '6'
and status != '7'
and shop_id = #{shopId}
<!--时间查询-->
<if test='startDate != null'>
and create_time BETWEEN #{startDate} AND #{endDate}
</if>
)
</select>
<update id="putInUpdatePurchasePrice">
<foreach collection="purchaseDetails" item="item" separator=";" open="" close="">
update t_sale_detail set purchase_price = #{item.purchasePrice} WHERE product_id = #{item.productId} and purchase_price is null
</foreach>
</update>
<select id="getSaleDetails" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_sale_detail
where sale_id in
<foreach close=")" collection="saleIdList" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</select>
<select id="getSaleDetailListByProductIds" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_sale_detail
where del_flag = '0'
and product_id in
<foreach close=")" collection="productIdList" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</select>
</mapper>