xuhy
2025-05-19 508f3e225df87e0da974424981e7782fc5ce875c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?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.system.mapper.TOrderSaleGoodsMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ruoyi.system.domain.TOrderSaleGoods">
        <id column="id" property="id" />
        <result column="orderId" property="orderId" />
        <result column="goodsNum" property="goodsNum" />
        <result column="goodsName" property="goodsName" />
        <result column="goodsCostPrice" property="goodsCostPrice" />
        <result column="goodsSalePrice" property="goodsSalePrice" />
        <result column="goodsCount" property="goodsCount" />
        <result column="thisSalePrice" property="thisSalePrice" />
        <result column="goodsPicture" property="goodsPicture" />
        <result column="typeId" property="typeId" />
        <result column="goodsId" property="goodsId" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, orderId, goodsNum, goodsName, goodsCostPrice, goodsSalePrice, goodsCount, thisSalePrice, goodsPicture,typeId,goodsId
    </sql>
    <delete id="deleteByOrderId">
        DELETE FROM t_order_sale_goods WHERE orderId in
         <foreach collection="saleIds" item="orderId" separator="," open="(" close=")">
             #{orderId}
         </foreach>
    </delete>
    <select id="costTotal" resultType="java.math.BigDecimal">
        select sum(goodsCostPrice) from t_order_sale_goods
        <where>
            <if test="ids != null and ids.size()>0">
                AND orderId IN
                <foreach collection="ids" item="id" open="(" separator="," close=")">
                    #{id}
                </foreach>
            </if>
        </where>
    </select>
    <select id="salesRanking" resultType="com.ruoyi.system.vo.SalesRankingVO">
        SELECT tgt.typeName,SUM(tosg.thisSalePrice*tosg.goodsCount) AS salesVolume
        FROM t_order_sale_goods tosg
        LEFT JOIN t_order_sale tos on tosg.orderId=tos.id
        LEFT JOIN t_goods_type tgt ON tosg.typeId = tgt.id
        <where>
            <if test="ids != null and ids.size()>0">
                AND tosg.orderId IN
                <foreach collection="ids" item="id" open="(" separator="," close=")">
                    #{id}
                </foreach>
            </if>
            AND tos.isCover = 1
            AND tos.status = 2
        </where>
        GROUP BY tgt.typeName
    </select>
 
</mapper>