wlzboy
2026-03-06 55cb4e492f782126e941b80c53c496159d8eb3c0
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<?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.ServiceOrderMapper">
    
    <resultMap type="ServiceOrder" id="ServiceOrderResult">
        <result property="serviceOrdId"    column="ServiceOrdID"    />
        <result property="serviceOrdUserID"    column="ServiceOrdUserID"    />
        <result property="serviceOrdClass"    column="ServiceOrdClass"    />
        <result property="serviceOrdType"    column="ServiceOrdType"    />
        <result property="serviceOrdState"    column="ServiceOrdState"    />
        <result property="serviceOrdStartDate"    column="ServiceOrdStartDate"    />
        <result property="serviceOrdApptDate"    column="ServiceOrdApptDate"    />
        <result property="serviceOrdCoName"    column="ServiceOrdCoName"    />
        <result property="serviceOrdCoPhone"    column="ServiceOrdCoPhone"    />
        <result property="serviceOrdPtName"    column="ServiceOrdPtName"    />
        <result property="serviceOrdPtAge"    column="ServiceOrdPtAge"    />
        <result property="serviceOrdPtSex"    column="ServiceOrdPtSex"    />
        <result property="serviceOrdPtKG"    column="ServiceOrdPtKG"    />
        <result property="serviceOrdPtNat"    column="ServiceOrdPtNat"    />
        <result property="serviceOrdPtIDCard"    column="ServiceOrdPtIDCard"    />
        <result property="serviceOrdTraProvince"    column="ServiceOrdTraProvince"    />
        <result property="serviceOrdTraCity"    column="ServiceOrdTraCity"    />
        <result property="serviceOrdTraStreet"    column="ServiceOrdTraStreet"    />
        <result property="serviceOrdTraEnd"    column="ServiceOrdTraEnd"    />
        <result property="serviceOrdTraDistance"    column="ServiceOrdTraDistance"    />
        <result property="serviceOrdTraUnitPrice"    column="ServiceOrdTraUnitPrice"    />
        <result property="serviceOrdTraTxnPrice"    column="ServiceOrdTraTxnPrice"    />
        <result property="serviceOrdTraPaidType"    column="ServiceOrdTraPaidType"    />
        <result property="serviceOrdTraPaidPrice"    column="ServiceOrdTraPaidPrice"    />
        <result property="serviceOrdUnitRemarks"    column="ServiceOrdUnitRemarks"    />
        <result property="serviceOrdCCTime"    column="ServiceOrd_CC_Time"    />
        <result property="serviceOrdVisit"    column="ServiceOrdVisit"    />
    </resultMap>
    <resultMap type="java.util.HashMap" id="ServiceCancelResult">
        <result property="ServiceOrdState" column="ServiceOrdState" />
        <result property="ServiceOrdCancelReason" column="ServiceOrdCancelReason" />
        <result property="ServiceOrdCancelReasonTXT" column="ServiceOrdCancelReasonTXT" />
    </resultMap>
    <sql id="selectServiceOrderVo">
        select ServiceOrdID, ServiceOrdUserID, ServiceOrdClass, ServiceOrdType, ServiceOrdState, ServiceOrdStartDate, ServiceOrdApptDate, ServiceOrdCoName, ServiceOrdCoPhone, ServiceOrdPtName, ServiceOrdPtAge, ServiceOrdPtSex, ServiceOrdPtKG, ServiceOrdPtNat, ServiceOrdPtIDCard, ServiceOrdTraProvince, ServiceOrdTraCity, ServiceOrdTraStreet, ServiceOrdTraEnd, ServiceOrdTraDistance, ServiceOrdTraUnitPrice, ServiceOrdTraTxnPrice, ServiceOrdTraPaidType, ServiceOrdTraPaidPrice, ServiceOrdUnitRemarks, ServiceOrd_CC_Time, ServiceOrdVisit from ServiceOrder
    </sql>
 
    <sql id="selectServiceOrderWhere">
        <where>  
            <if test="serviceOrder.serviceOrdUserID != null "> and ServiceOrdUserID = #{serviceOrder.serviceOrdUserID}</if>
            <if test="serviceOrder.serviceOrdClass != null  and serviceOrder.serviceOrdClass != ''"> and ServiceOrdClass = #{serviceOrder.serviceOrdClass}</if>
            <if test="serviceOrder.serviceOrdType != null "> and ServiceOrdType = #{serviceOrder.serviceOrdType}</if>
            <if test="serviceOrder.serviceOrdState != null "> and ServiceOrdState = #{serviceOrder.serviceOrdState}</if>
            <if test="serviceOrder.serviceOrdStartDate != null "> and ServiceOrdStartDate = #{serviceOrder.serviceOrdStartDate}</if>
            <if test="serviceOrder.serviceOrdApptDate != null "> and ServiceOrdApptDate = #{serviceOrder.serviceOrdApptDate}</if>
            <if test="serviceOrder.serviceOrdCoName != null  and serviceOrder.serviceOrdCoName != ''"> and ServiceOrdCoName like '%' + #{serviceOrder.serviceOrdCoName} + '%'</if>
            <if test="serviceOrder.serviceOrdCoPhone != null  and serviceOrder.serviceOrdCoPhone != ''"> and ServiceOrdCoPhone = #{serviceOrder.serviceOrdCoPhone}</if>
            <if test="serviceOrder.serviceOrdPtName != null  and serviceOrder.serviceOrdPtName != ''"> and ServiceOrdPtName like '%' + #{serviceOrder.serviceOrdPtName} + '%'</if>
            <if test="serviceOrder.serviceOrdPtAge != null  and serviceOrder.serviceOrdPtAge != ''"> and ServiceOrdPtAge = #{serviceOrder.serviceOrdPtAge}</if>
            <if test="serviceOrder.serviceOrdPtSex != null  and serviceOrder.serviceOrdPtSex != ''"> and ServiceOrdPtSex = #{serviceOrder.serviceOrdPtSex}</if>
            <if test="serviceOrder.serviceOrdPtIDCard != null  and serviceOrder.serviceOrdPtIDCard != ''"> and ServiceOrdPtIDCard = #{serviceOrder.serviceOrdPtIDCard}</if>
            <if test="serviceOrder.serviceOrdTraTxnPrice != null  and serviceOrder.serviceOrdTraTxnPrice != ''"> and ServiceOrdTraTxnPrice = #{serviceOrder.serviceOrdTraTxnPrice}</if>
        </where>
    </sql>
 
    <select id="selectServiceOrderList" resultMap="ServiceOrderResult">
        SELECT *
        FROM (
            SELECT ROW_NUMBER() OVER (ORDER BY ServiceOrdID) AS RowNum, *
            FROM ServiceOrder
            <include refid="selectServiceOrderWhere"/>
        ) AS TempTable
        WHERE RowNum BETWEEN #{offset} + 1 AND #{offset} + #{pageSize}
    </select>
 
    <select id="selectServiceOrderCount" resultType="Integer">
        SELECT COUNT(1)
        FROM ServiceOrder
        <include refid="selectServiceOrderWhere"/>
    </select>
    
    <select id="selectServiceOrderById" parameterType="Long" resultMap="ServiceOrderResult">
        <include refid="selectServiceOrderVo"/>
        where ServiceOrdID = #{serviceOrdId}
    </select>
        
    <insert id="insertServiceOrder" parameterType="ServiceOrder" useGeneratedKeys="true" keyProperty="serviceOrdId">
        insert into ServiceOrder
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="serviceOrdUserID != null">ServiceOrdUserID,</if>
            <if test="serviceOrdClass != null">ServiceOrdClass,</if>
            <if test="serviceOrdType != null">ServiceOrdType,</if>
            <if test="serviceOrdState != null">ServiceOrdState,</if>
            <if test="serviceOrdStartDate != null">ServiceOrdStartDate,</if>
            <if test="serviceOrdApptDate != null">ServiceOrdApptDate,</if>
            <if test="serviceOrdCoName != null">ServiceOrdCoName,</if>
            <if test="serviceOrdCoPhone != null">ServiceOrdCoPhone,</if>
            <if test="serviceOrdPtName != null">ServiceOrdPtName,</if>
            <if test="serviceOrdPtAge != null">ServiceOrdPtAge,</if>
            <if test="serviceOrdPtSex != null">ServiceOrdPtSex,</if>
            <if test="serviceOrdPtKG != null">ServiceOrdPtKG,</if>
            <if test="serviceOrdPtNat != null">ServiceOrdPtNat,</if>
            <if test="serviceOrdPtIDCard != null">ServiceOrdPtIDCard,</if>
            <if test="serviceOrdTraProvince != null">ServiceOrdTraProvince,</if>
            <if test="serviceOrdTraCity != null">ServiceOrdTraCity,</if>
            <if test="serviceOrdTraStreet != null">ServiceOrdTraStreet,</if>
            <if test="serviceOrdTraEnd != null">ServiceOrdTraEnd,</if>
            <if test="serviceOrdTraDistance != null">ServiceOrdTraDistance,</if>
            <if test="serviceOrdTraUnitPrice != null">ServiceOrdTraUnitPrice,</if>
            <if test="serviceOrdTraTxnPrice != null">ServiceOrdTraTxnPrice,</if>
            <if test="serviceOrdTraPaidType != null">ServiceOrdTraPaidType,</if>
            <if test="serviceOrdTraPaidPrice != null">ServiceOrdTraPaidPrice,</if>
            <if test="serviceOrdUnitRemarks != null">ServiceOrdUnitRemarks,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="serviceOrdUserID != null">#{serviceOrdUserID},</if>
            <if test="serviceOrdClass != null">#{serviceOrdClass},</if>
            <if test="serviceOrdType != null">#{serviceOrdType},</if>
            <if test="serviceOrdState != null">#{serviceOrdState},</if>
            <if test="serviceOrdStartDate != null">#{serviceOrdStartDate},</if>
            <if test="serviceOrdApptDate != null">#{serviceOrdApptDate},</if>
            <if test="serviceOrdCoName != null">#{serviceOrdCoName},</if>
            <if test="serviceOrdCoPhone != null">#{serviceOrdCoPhone},</if>
            <if test="serviceOrdPtName != null">#{serviceOrdPtName},</if>
            <if test="serviceOrdPtAge != null">#{serviceOrdPtAge},</if>
            <if test="serviceOrdPtSex != null">#{serviceOrdPtSex},</if>
            <if test="serviceOrdPtKG != null">#{serviceOrdPtKG},</if>
            <if test="serviceOrdPtNat != null">#{serviceOrdPtNat},</if>
            <if test="serviceOrdPtIDCard != null">#{serviceOrdPtIDCard},</if>
            <if test="serviceOrdTraProvince != null">#{serviceOrdTraProvince},</if>
            <if test="serviceOrdTraCity != null">#{serviceOrdTraCity},</if>
            <if test="serviceOrdTraStreet != null">#{serviceOrdTraStreet},</if>
            <if test="serviceOrdTraEnd != null">#{serviceOrdTraEnd},</if>
            <if test="serviceOrdTraDistance != null">#{serviceOrdTraDistance},</if>
            <if test="serviceOrdTraUnitPrice != null">#{serviceOrdTraUnitPrice},</if>
            <if test="serviceOrdTraTxnPrice != null">#{serviceOrdTraTxnPrice},</if>
            <if test="serviceOrdTraPaidType != null">#{serviceOrdTraPaidType},</if>
            <if test="serviceOrdTraPaidPrice != null">#{serviceOrdTraPaidPrice},</if>
            <if test="serviceOrdUnitRemarks != null">#{serviceOrdUnitRemarks},</if>
         </trim>
    </insert>
 
    <update id="updateServiceOrder" parameterType="ServiceOrder">
        update ServiceOrder
        <trim prefix="SET" suffixOverrides=",">
            <if test="serviceOrdUserID != null">ServiceOrdUserID = #{serviceOrdUserID},</if>
            <if test="serviceOrdClass != null">ServiceOrdClass = #{serviceOrdClass},</if>
            <if test="serviceOrdType != null">ServiceOrdType = #{serviceOrdType},</if>
            <if test="serviceOrdState != null">ServiceOrdState = #{serviceOrdState},</if>
            <if test="serviceOrdStartDate != null">ServiceOrdStartDate = #{serviceOrdStartDate},</if>
            <if test="serviceOrdApptDate != null">ServiceOrdApptDate = #{serviceOrdApptDate},</if>
            <if test="serviceOrdCoName != null">ServiceOrdCoName = #{serviceOrdCoName},</if>
            <if test="serviceOrdCoPhone != null">ServiceOrdCoPhone = #{serviceOrdCoPhone},</if>
            <if test="serviceOrdPtName != null">ServiceOrdPtName = #{serviceOrdPtName},</if>
            <if test="serviceOrdPtAge != null">ServiceOrdPtAge = #{serviceOrdPtAge},</if>
            <if test="serviceOrdPtSex != null">ServiceOrdPtSex = #{serviceOrdPtSex},</if>
            <if test="serviceOrdPtKG != null">ServiceOrdPtKG = #{serviceOrdPtKG},</if>
            <if test="serviceOrdPtNat != null">ServiceOrdPtNat = #{serviceOrdPtNat},</if>
            <if test="serviceOrdPtIDCard != null">ServiceOrdPtIDCard = #{serviceOrdPtIDCard},</if>
            <if test="serviceOrdTraProvince != null">ServiceOrdTraProvince = #{serviceOrdTraProvince},</if>
            <if test="serviceOrdTraCity != null">ServiceOrdTraCity = #{serviceOrdTraCity},</if>
            <if test="serviceOrdTraStreet != null">ServiceOrdTraStreet = #{serviceOrdTraStreet},</if>
            <if test="serviceOrdTraEnd != null">ServiceOrdTraEnd = #{serviceOrdTraEnd},</if>
            <if test="serviceOrdTraDistance != null">ServiceOrdTraDistance = #{serviceOrdTraDistance},</if>
            <if test="serviceOrdTraUnitPrice != null">ServiceOrdTraUnitPrice = #{serviceOrdTraUnitPrice},</if>
            <if test="serviceOrdTraTxnPrice != null">ServiceOrdTraTxnPrice = #{serviceOrdTraTxnPrice},</if>
            <if test="serviceOrdTraPaidType != null">ServiceOrdTraPaidType = #{serviceOrdTraPaidType},</if>
            <if test="serviceOrdTraPaidPrice != null">ServiceOrdTraPaidPrice = #{serviceOrdTraPaidPrice},</if>
            <if test="serviceOrdUnitRemarks != null">ServiceOrdUnitRemarks = #{serviceOrdUnitRemarks},</if>
        </trim>
        where ServiceOrdID = #{serviceOrdId}
    </update>
 
    <delete id="deleteServiceOrderById" parameterType="Long">
        delete from ServiceOrder where ServiceOrdID = #{serviceOrdId}
    </delete>
 
    <delete id="deleteServiceOrderByIds" parameterType="String">
        delete from ServiceOrder where ServiceOrdID in 
        <foreach item="serviceOrdId" collection="array" open="(" separator="," close=")">
            #{serviceOrdId}
        </foreach>
    </delete>
    
    <!-- 更新服务订单取消信息 -->
    <update id="updateServiceOrderCancelInfo">
        update ServiceOrder 
        set ServiceOrdState = 4,
            ServiceOrdCancelReason = #{cancelReason},
            ServiceOrdCancelReasonTXT = #{cancelReasonText}
        where ServiceOrdID = #{serviceOrdId}
    </update>
    
    <!-- 根据服务订单ID查询订单状态 -->
    <select id="selectServiceOrderStateById" parameterType="Long" resultType="Integer">
        select ServiceOrdState 
        from ServiceOrder 
        where ServiceOrdID = #{serviceOrdId}
    </select>
    <select id="selectServiceCancelInfoById" parameterType="Long" resultMap="ServiceCancelResult">
        select ServiceOrdState, ServiceOrdCancelReason, ServiceOrdCancelReasonTXT
        from ServiceOrder 
        where ServiceOrdID = #{serviceOrdId}
    </select>
</mapper>