无关风月
2024-12-30 4ef2de7aa7fc24ee19020330e781bae0b51b956c
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
<?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.jilongda.manage.mapper.TOrderGoodMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.jilongda.common.model.TOrderGood">
        <id column="id" property="id" />
        <result column="orderId" property="orderId" />
        <result column="goodsName" property="goodsName" />
        <result column="goodsPicture" property="goodsPicture" />
        <result column="goodsNo" property="goodsNo" />
        <result column="goodsBrand" property="goodsBrand" />
        <result column="goodsNature" property="goodsNature" />
        <result column="goodsType" property="goodsType" />
        <result column="goodsRemark" property="goodsRemark" />
        <result column="goodsDosage" property="goodsDosage" />
        <result column="goodsContent" property="goodsContent" />
        <result column="goodsSpecifications" property="goodsSpecifications" />
        <result column="warehouse" property="warehouse" />
        <result column="goodsPrice" property="goodsPrice" />
        <result column="updateGoodsPrice" property="updateGoodsPrice" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, orderId, goodsName, goodsPicture, goodsNo, goodsBrand, goodsNature, goodsType, goodsRemark, goodsDosage, goodsContent, goodsSpecifications, warehouse, goodsPrice, updateGoodsPrice
    </sql>
    <select id="salesData" resultType="com.jilongda.manage.vo.SalesDataVO">
        SELECT og.goodsId AS goodsId,sum(og.buyNum) AS buyNum
        from t_order o
        LEFT JOIN t_order_good og on o.id = og.orderId
        where (o.orderStatus = 2 or o.orderStatus = 4 or o.orderStatus = 5)
        <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
            and o.createTime between #{startTime} and #{endTime}
        </if>
        and og.goodsId IS NOT NULL
        GROUP BY og.goodsId
        ORDER BY sum(og.buyNum) DESC
        limit 10
    </select>
 
</mapper>