无关风月
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?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.TOrderMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.jilongda.common.model.TOrder">
        <id column="id" property="id" />
        <result column="customerId" property="customerId" />
        <result column="orderAmount" property="orderAmount" />
        <result column="orderingPersonId" property="orderingPersonId" />
        <result column="orderStatus" property="orderStatus" />
        <result column="paymentTerms" property="paymentTerms" />
        <result column="invoiceType" property="invoiceType" />
        <result column="logistics" property="logistics" />
        <result column="expectedDeliveryDate" property="expectedDeliveryDate" />
        <result column="orderCode" property="orderCode" />
        <result column="remark" property="remark" />
        <result column="createTime" property="createTime" />
        <result column="updateTime" property="updateTime" />
        <result column="createBy" property="createBy" />
        <result column="updateBy" property="updateBy" />
        <result column="isDelete" property="isDelete" />
        <result column="recipientName" property="recipientName" />
        <result column="recipientPhone" property="recipientPhone" />
        <result column="recipientAddress" property="recipientAddress" />
        <result column="passUserId" property="passUserId" />
        <result column="passRemark" property="passRemark" />
        <result column="reportPics" property="reportPics" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, customerId, orderAmount, orderingPersonId, orderStatus, paymentTerms, invoiceType, logistics, expectedDeliveryDate,
            orderCode, remark, createTime, updateTime, createBy, updateBy, isDelete, recipientName, recipientPhone,
            recipientAddress, passUserId, passRemark,reportPics
    </sql>
    <select id="pageList" resultType="com.jilongda.manage.vo.TOrderVO">
        SELECT o.id, o.customerId, o.orderAmount, o.orderingPersonId, o.orderStatus, o.paymentTerms, o.invoiceType, o.logistics,
               o.expectedDeliveryDate, o.orderCode, o.remark, o.createTime, o.updateTime, o.createBy, o.updateBy, o.isDelete,
        o.recipientName, o.recipientPhone, o.recipientAddress, o.passUserId, o.passRemark,o.reportPics,tc.companyName,tc.subsidiaryName,
        tog.goodsName,tog.goodsNature,tog.goodsType,tog.goodsBrand,tog.goodsNo,tog.goodsSpecifications,tog.buyNum,tog.goodsPrice
        FROM t_order o
        LEFT JOIN t_customers tc ON o.customerId = tc.id
        LEFT JOIN t_order_good tog ON o.id = tog.orderId
        <where>
            <if test="query.companyName != null and query.companyName != ''">
                AND tc.companyName LIKE CONCAT('%',#{query.companyName},'%')
            </if>
            <if test="query.orderCode != null and query.orderCode != ''">
                AND o.orderCode LIKE CONCAT('%',#{query.orderCode},'%')
            </if>
            <if test="query.recipientName != null and query.recipientName != ''">
                AND o.recipientName LIKE CONCAT('%',#{query.recipientName},'%')
            </if>
            <if test="query.orderStatus != null">
                AND o.orderStatus = #{query.orderStatus}
            </if>
            AND o.isDelete = ${@com.jilongda.common.enums.DisabledEnum@NO.getCode()}
        </where>
        ORDER BY o.createTime DESC
    </select>
    <select id="achievement" resultType="com.jilongda.manage.vo.AchievementVO">
        SELECT orderingPersonId AS userId,SUM(orderAmount) AS sumMoney
        FROM t_order
        <where>
            <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
                AND createTime between #{startTime} and #{endTime}
            </if>
            AND (orderStatus = 2 or orderStatus = 4 or orderStatus = 5)
            AND isDelete = ${@com.jilongda.common.enums.DisabledEnum@NO.getCode()}
        </where>
        AND customerId IS NOT NULL
        GROUP BY userId
        ORDER BY SUM(orderAmount) DESC
        limit 10
    </select>
    <select id="pageListExport" resultType="com.jilongda.manage.excel.TOrderExportExcels">
        SELECT o.id, o.customerId, o.orderAmount, o.orderingPersonId, o.orderStatus, o.paymentTerms, o.invoiceType, o.logistics,
        o.expectedDeliveryDate, o.orderCode, o.remark, o.createTime, o.updateTime, o.createBy, o.updateBy, o.isDelete,
        o.recipientName, o.recipientPhone, o.recipientAddress, o.passUserId, o.passRemark,o.reportPics,tc.companyName,tc.subsidiaryName,
        tog.goodsName,tog.goodsNature,tog.goodsType,tog.goodsBrand,tog.goodsNo,tog.goodsSpecifications,tog.buyNum,tog.goodsPrice
        FROM t_order o
        LEFT JOIN t_customers tc ON o.customerId = tc.id
        LEFT JOIN t_order_good tog ON o.id = tog.orderId
        <where>
            <if test="query.companyName != null and query.companyName != ''">
                AND tc.companyName LIKE CONCAT('%',#{query.companyName},'%')
            </if>
            <if test="query.orderCode != null and query.orderCode != ''">
                AND o.orderCode LIKE CONCAT('%',#{query.orderCode},'%')
            </if>
            <if test="query.recipientName != null and query.recipientName != ''">
                AND o.recipientName LIKE CONCAT('%',#{query.recipientName},'%')
            </if>
            <if test="query.orderStatus != null">
                AND o.orderStatus = #{query.orderStatus}
            </if>
            AND o.isDelete = ${@com.jilongda.common.enums.DisabledEnum@NO.getCode()}
        </where>
        ORDER BY o.createTime DESC
    </select>
 
</mapper>