RuoYi-Vue/xkt/src/main/resources/mapper/StoreSaleDetailMapper.xml

175 lines
8.1 KiB
XML

<?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.ruoyi.xkt.mapper.StoreSaleDetailMapper">
<resultMap type="StoreSaleDetail" id="StoreSaleDetailResult">
<result property="id" column="id" />
<result property="storeSaleId" column="store_sale_id" />
<result property="storeProdId" column="store_prod_id" />
<result property="storeProdColorSizeId" column="store_prod_color_size_id" />
<result property="saleType" column="sale_type" />
<result property="price" column="price" />
<result property="discountedPrice" column="discounted_price" />
<result property="quantity" column="quantity" />
<result property="amount" column="amount" />
<result property="otherDiscount" column="other_discount" />
<result property="version" column="version" />
<result property="delFlag" column="del_flag" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectStoreSaleDetailVo">
select id, store_sale_id, store_prod_id, store_prod_color_size_id, sale_type, price, discounted_price, quantity, amount, other_discount, version, del_flag, create_by, create_time, update_by, update_time from store_sale_detail
</sql>
<select id="selectStoreSaleDetailList" parameterType="StoreSaleDetail" resultMap="StoreSaleDetailResult">
<include refid="selectStoreSaleDetailVo"/>
<where>
<if test="storeSaleId != null "> and store_sale_id = #{storeSaleId}</if>
<if test="storeProdId != null "> and store_prod_id = #{storeProdId}</if>
<if test="storeProdColorSizeId != null "> and store_prod_color_size_id = #{storeProdColorSizeId}</if>
<if test="saleType != null "> and sale_type = #{saleType}</if>
<if test="price != null "> and price = #{price}</if>
<if test="discountedPrice != null "> and discounted_price = #{discountedPrice}</if>
<if test="quantity != null "> and quantity = #{quantity}</if>
<if test="amount != null "> and amount = #{amount}</if>
<if test="otherDiscount != null "> and other_discount = #{otherDiscount}</if>
<if test="version != null "> and version = #{version}</if>
</where>
</select>
<select id="selectStoreSaleDetailByStoreSaleDetailId" parameterType="Long" resultMap="StoreSaleDetailResult">
<include refid="selectStoreSaleDetailVo"/>
where id = #{id}
</select>
<insert id="insertStoreSaleDetail" parameterType="StoreSaleDetail" useGeneratedKeys="true" keyProperty="storeSaleDetailId">
insert into store_sale_detail
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="storeSaleId != null">store_sale_id,</if>
<if test="storeProdId != null">store_prod_id,</if>
<if test="storeProdColorSizeId != null">store_prod_color_size_id,</if>
<if test="saleType != null">sale_type,</if>
<if test="price != null">price,</if>
<if test="discountedPrice != null">discounted_price,</if>
<if test="quantity != null">quantity,</if>
<if test="amount != null">amount,</if>
<if test="otherDiscount != null">other_discount,</if>
<if test="version != null">version,</if>
<if test="delFlag != null">del_flag,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="storeSaleId != null">#{storeSaleId},</if>
<if test="storeProdId != null">#{storeProdId},</if>
<if test="storeProdColorSizeId != null">#{storeProdColorSizeId},</if>
<if test="saleType != null">#{saleType},</if>
<if test="price != null">#{price},</if>
<if test="discountedPrice != null">#{discountedPrice},</if>
<if test="quantity != null">#{quantity},</if>
<if test="amount != null">#{amount},</if>
<if test="otherDiscount != null">#{otherDiscount},</if>
<if test="version != null">#{version},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateStoreSaleDetail" parameterType="StoreSaleDetail">
update store_sale_detail
<trim prefix="SET" suffixOverrides=",">
<if test="storeSaleId != null">store_sale_id = #{storeSaleId},</if>
<if test="storeProdId != null">store_prod_id = #{storeProdId},</if>
<if test="storeProdColorSizeId != null">store_prod_color_size_id = #{storeProdColorSizeId},</if>
<if test="saleType != null">sale_type = #{saleType},</if>
<if test="price != null">price = #{price},</if>
<if test="discountedPrice != null">discounted_price = #{discountedPrice},</if>
<if test="quantity != null">quantity = #{quantity},</if>
<if test="amount != null">amount = #{amount},</if>
<if test="otherDiscount != null">other_discount = #{otherDiscount},</if>
<if test="version != null">version = #{version},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteStoreSaleDetailByStoreSaleDetailId" parameterType="Long">
delete from store_sale_detail where id = #{id}
</delete>
<delete id="deleteStoreSaleDetailByStoreSaleDetailIds" parameterType="String">
delete from store_sale_detail where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="selectTop10List" resultType="com.ruoyi.xkt.dto.dailyStoreTag.DailyStoreTagDTO">
SELECT
ssd.store_id,
SUM(IFNULL( ssd.quantity, 0 )) AS count
FROM
store_sale_detail ssd
WHERE
ssd.del_flag = 0
AND ssd.sale_type = 1
AND ssd.voucher_date between #{oneMonthAgo} AND #{yesterday}
GROUP BY
ssd.store_id
ORDER BY
SUM(IFNULL( ssd.quantity, 0 )) DESC
LIMIT 10
</select>
<select id="selectTop50List" resultType="com.ruoyi.xkt.dto.dailyStoreTag.DailyStoreTagDTO">
SELECT
ssd.store_prod_id,
ssd.store_id,
SUM(IFNULL( ssd.quantity, 0 )) AS count
FROM
store_sale_detail ssd
WHERE
ssd.del_flag = 0
AND ssd.sale_type = 1
AND ssd.voucher_date between #{oneMonthAgo} AND #{yesterday}
GROUP BY
ssd.store_id,
ssd.store_prod_id
ORDER BY
count DESC
LIMIT 50
</select>
<select id="selectTop20List" resultType="com.ruoyi.xkt.dto.dailyStoreTag.DailyStoreTagDTO">
SELECT
sp.store_id,
SUM( id ) AS count
FROM
store_product sp
WHERE
sp.del_flag = 0
AND sp.create_time between #{oneWeekAgo} AND #{yesterday}
GROUP BY
sp.store_id
ORDER BY
count DESC
LIMIT 20
</select>
</mapper>