Helius
2021-03-11 a72aa4bb793ec765892406c842039a71b33215b1
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
<?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.matrix.system.hive.dao.SysProjServicesDao">
    
    <resultMap type="SysProjServices" id="SysProjServicesMap">
            <id property="id" column="ID" />
            <result property="bedId" column="BED_ID" />
            <result property="beauticianId" column="BEAUTICIAN_ID" />
            <result property="deviceId" column="DEVICE_ID" />
            <result property="devisionId" column="DEVISION_ID" />
            <result property="skinCond" column="SKIN_COND" />
            <result property="isPeeling" column="IS_PEELING" />
            <result property="useTime" column="USE_TIME" />
            <result property="isDry" column="IS_DRY" />
            <result property="isMakeup" column="IS_MAKEUP" />
            <result property="valuable" column="VALUABLE" />
            <result property="containNo" column="CONTAIN_NO" />
            <result property="remark" column="REMARK" />
            <result property="state" column="STATE" />
            <result property="isWheel" column="IS_WHEEL" />
            <result property="medicalId" column="MEDICAL_ID" />
            <result property="lightId" column="LIGHT_ID" />
            <result property="doctorId" column="DOCTOR_ID" />
            <result property="shopId" column="SHOP_ID" />
            <result property="yyTime" column="YY_TIME" />
            <result property="vipId" column="VIP_ID" />
            <result property="createTime" column="CREATE_TIME" />
            <result property="createStaffId" column="CREATE_STAFF_ID" />
            <result property="startTime" column="START_TIME"/>
            <result property="endTime" column="END_TIME"/>
            <result property="isOverTime" column="IS_OVERTIME"/>
            <result property="serviceNo" column="SERVICE_NO"/>
            <result property="totalTime" column="TOTAL_TIME"/>
            <result property="money" column="MONEY"/>
            <result property="changeId" column="CHANGE_ID"/>
            <result property="oldShopId" column="OLD_SHOP_ID"/>
            <result property="consumeTime" column="consume_time"/>
            <result property="companyId" column="company_id"/>
            <result property="comment" column="comment"/>
            <result property="reply" column="reply"/>
            <result property="overtimeNotice" column="overtime_notice"/>
 
 
            
            <result property="beautiName" column="beautiName"/>
            <result property="plsName" column="plsName"/>
            <result property="shopName" column="shopName"/>
            <result property="createStaffName" column="createStaffName"/>
            <result property="bedName" column="bedName"/>
            <result property="vipName" column="VIP_Name"/>
 
            <association property="vipInfo"  resultMap="com.matrix.system.hive.dao.SysVipInfoDao.SysVipInfoMapSimple" ></association>
 
    </resultMap>
 
    <!--  插入方法   -->
    <insert id="insert" parameterType="SysProjServices"
        useGeneratedKeys="true" keyProperty="id">
        INSERT INTO sys_proj_services (
            ID,
            BED_ID,
            BEAUTICIAN_ID,
            DEVICE_ID,
            DEVISION_ID,
            SKIN_COND,
            IS_PEELING,
            USE_TIME,
            IS_DRY,
            IS_MAKEUP,
    
            VALUABLE,
            CONTAIN_NO,
            REMARK,
            STATE,
            IS_WHEEL,
            MEDICAL_ID,
            LIGHT_ID,
            DOCTOR_ID,
            SHOP_ID,
            YY_TIME,
            VIP_ID,
            CREATE_TIME,
            CREATE_STAFF_ID,
            START_TIME,
            END_TIME,
            IS_OVERTIME,
            SERVICE_NO,
            TOTAL_TIME,
            MONEY,
            CHANGE_ID,
            OLD_SHOP_ID,
            consume_time,
            company_id,
            comment,
            reply,
            overtime_notice
        )
    VALUES (
            #{id},
            #{bedId},
            #{beauticianId},
            #{deviceId},
            #{devisionId},
            #{skinCond},
            #{isPeeling},
            #{useTime},
            #{isDry},
            #{isMakeup},
            #{valuable},
            #{containNo},
            #{remark},
            #{state},
            #{isWheel},
            #{medicalId},
            #{lightId},
            #{doctorId},
            #{shopId},
            #{yyTime},
            #{vipId},
            #{createTime},
            #{createStaffId},
            #{startTime},
            #{endTime},
            #{isOverTime},
            #{serviceNo},
            #{totalTime},
            #{money},
            #{changeId},
            #{oldShopId},
            #{consumeTime},
            #{companyId},
            #{comment},
            #{reply},
            #{overtimeNotice}
    )
        
    </insert>
 
    <!--  根据id更新 部分更新   -->
    <update id="updateOrderTime">
        UPDATE sys_proj_services set consume_time=#{consumeTime} WHERE id=#{id}
    </update>
 
    <!-- 设置服务单为已通知 -->
    <update id="updateNoticeTimes" >
        UPDATE sys_proj_services set overtime_notice=1
        where  ID in
        <foreach collection="list" index="index" item="item" open="("
                 separator="," close=")">
            #{item}
        </foreach>
    </update>
 
 
    
    <update id="update">
        UPDATE sys_proj_services
        <set>
                <if test="bedId != null and bedId !='' ">
                    BED_ID = #{bedId},
                </if>        
                <if test="beauticianId != null and beauticianId !='' ">
                    BEAUTICIAN_ID = #{beauticianId},
                </if>        
                <if test="deviceId != null and deviceId !='' ">
                    DEVICE_ID = #{deviceId},
                </if>        
                <if test="devisionId != null and devisionId !='' ">
                    DEVISION_ID = #{devisionId},
                </if>        
                <if test="skinCond != null and skinCond !='' ">
                    SKIN_COND = #{skinCond},
                </if>        
                <if test="isPeeling != null and isPeeling !='' ">
                    IS_PEELING = #{isPeeling},
                </if>        
                <if test="useTime != null  ">
                    USE_TIME = #{useTime},
                </if>        
                <if test="isDry != null and isDry !='' ">
                    IS_DRY = #{isDry},
                </if>        
                <if test="isMakeup != null and isMakeup !='' ">
                    IS_MAKEUP = #{isMakeup},
                </if>        
                <if test="valuable != null and valuable !='' ">
                    VALUABLE = #{valuable},
                </if>        
                <if test="containNo != null and containNo !='' ">
                    CONTAIN_NO = #{containNo},
                </if>        
                <if test="remark != null and remark !='' ">
                    REMARK = #{remark},
                </if>        
                <if test="state != null and state !='' ">
                    STATE = #{state},
                </if>        
                <if test="isWheel != null and isWheel !='' ">
                    IS_WHEEL = #{isWheel},
                </if>        
                <if test="medicalId != null and medicalId !='' ">
                    MEDICAL_ID = #{medicalId},
                </if>        
                <if test="lightId != null and lightId !='' ">
                    LIGHT_ID = #{lightId},
                </if>        
                <if test="doctorId != null and doctorId !='' ">
                    DOCTOR_ID = #{doctorId},
                </if>        
                <if test="shopId != null and shopId !='' ">
                    SHOP_ID = #{shopId},
                </if>        
                <if test="yyTime != null   ">
                    YY_TIME = #{yyTime},
                </if>        
                <if test="vipId != null and vipId !='' ">
                    VIP_ID = #{vipId},
                </if>        
                <if test="createTime != null  ">
                    CREATE_TIME = #{createTime},
                </if>        
                <if test="createStaffId != null and createStaffId !='' ">
                    CREATE_STAFF_ID = #{createStaffId},
                </if>
                <if test="startTime != null  ">
                    START_TIME = #{startTime},
                </if>
                <if test="endTime != null   ">
                    END_TIME = #{endTime},
                </if>
                <if test="isOverTime != null  ">
                    IS_OVERTIME = #{isOverTime},
                </if>
                <if test="serviceNo != null and serviceNo !='' ">
                    SERVICE_NO = #{serviceNo},
                </if>
                <if test="totalTime != null  ">
                    TOTAL_TIME = #{totalTime},
                </if>
                <if test="money != null and money !='' ">
                    MONEY = #{money},
                </if>
                <if test="changeId != null and changeId !='' ">
                    CHANGE_ID = #{changeId},
                </if>
                <if test="oldShopId != null and oldShopId !='' ">
                    OLD_SHOP_ID = #{oldShopId},
                </if>
                <if test="consumeTime != null  ">
                    consume_time = #{consumeTime},
                </if>
 
                <if test="reply != null  ">
                    reply = #{reply},
                </if>
                <if test="comment != null  ">
                    comment = #{comment},
                </if>
                <if test="overtimeNotice != null  ">
                    overtime_notice = #{overtimeNotice},
                </if>
        </set>
        WHERE id=#{id} 
    </update>
 
 
    <!-- 批量删除 -->
    <delete id="deleteByIds" parameterType="java.util.List">
        delete from sys_proj_services where  ID in
        <foreach collection="list" index="index" item="item" open="("
            separator="," close=")">
            #{item}
        </foreach>
    </delete>
        
    <!-- 根据id删除-->
    <delete id="deleteById" >
        DELETE FROM sys_proj_services
        where  ID=#{id} 
    </delete>
 
    <select id="selectInPage" resultMap="SysProjServicesMap">
        select distinct
        a.*,
        b.PHONE ,
        b.VIP_NAME ,
        b.VIP_NO,
        (select  su_name from  sys_users f where  a.CREATE_STAFF_ID=f.su_id ) as  createStaffName,
        (select  su_name from  sys_users j where  a.BEAUTICIAN_ID=j.su_id ) as  beautiName,
        (select  su_name from  sys_users k where  a.devision_id=k.su_id ) as plsName,
        (select  shop_name from  sys_shop_info h where  a.SHOP_ID=h.ID ) as shopName,
        (select  bed_name from  sys_bed_info i where  a.BED_ID=i.ID ) as bedName
        FROM sys_proj_services a
        LEFT JOIN sys_vip_info b on b.ID=a.VIP_ID
        left join sys_beautician_state c on a.id=c.SERVICES_ID
        WHERE 1 = 1
        <if test="record!=null">
            <if test="record.queryStaffId != null and record.queryStaffId !='' ">
                and (a.CREATE_STAFF_ID  = #{record.queryStaffId}  or c.STAFF_ID=#{record.queryStaffId}  )
            </if>
            <if test="record.vipName != null and record.vipName !='' ">
                and b.VIP_NAME like CONCAT('%',#{record.vipName},'%')
            </if>
            <if test="record.vipPhone !=null and record.vipPhone !=''  ">
                and b.PHONE like CONCAT('%',#{record.vipPhone},'%')
            </if>
            <if test="record.createStaffId != null and record.createStaffId !='' ">
                and a.CREATE_STAFF_ID  = #{record.createStaffId}
            </if>
            <if test="record.id != null and record.id !='' ">
                and a.ID  = #{record.id}
            </if>
            <if test="(record.companyId!=null and record.companyId!='') ">
                and a.company_id = #{record.companyId}
            </if>
 
            <if test="record.bedId != null and record.bedId !='' ">
                and a.BED_ID  = #{record.bedId}
            </if>
            <if test="record.state != null and record.state !='' ">
                and a.STATE  = #{record.state}
            </if>
            <if test="record.shopId != null and record.shopId !='' ">
                AND a.SHOP_ID = #{record.shopId}
            </if>
            <if test="record.vipId != null and record.vipId !='' ">
                and a.VIP_ID   = #{record.vipId}
            </if>
            <if test="record.isOverTime != null  and record.serviceNo !=''   ">
                and a.IS_OVERTIME  > #{record.isOverTime}
            </if>
            <if test="record.serviceNo != null and record.serviceNo !='' ">
                and a.SERVICE_NO  like CONCAT('%',#{record.serviceNo},'%')
            </if>
            <if test="record.beginTime != null  ">
                and a.YY_TIME  <![CDATA[>=]]> #{record.beginTime}
            </if>
            <if test="record.closureTime != null  ">
                and a.YY_TIME <![CDATA[<=]]> #{record.closureTime}
            </if>
        </if>
        <if test="pageVo !=null"><!-- 判断pageVo对象是否为空 -->
            <if test="pageVo.sort !=null  and pageVo.order !=null">
                order by
                ${pageVo.sort} ${pageVo.order}
            </if>
            <if test="pageVo.offset >=0  and pageVo.limit >0">
                limit
                #{pageVo.offset},#{pageVo.limit}
            </if>
        </if>
    </select>
    <!-- 查询总条数 -->
    <select id="selectTotalRecord"    resultType="java.lang.Integer">
        select count(*)
        from (
        select distinct
        a.id
        FROM sys_proj_services a
        LEFT JOIN sys_vip_info b on b.ID=a.VIP_ID
        left join sys_beautician_state c on a.id=c.SERVICES_ID
        WHERE 1 = 1
        <if test="record!=null">
            <if test="record.queryStaffId != null and record.queryStaffId !='' ">
                and (a.CREATE_STAFF_ID  = #{record.queryStaffId}  or c.STAFF_ID=#{record.queryStaffId}  )
            </if>
            <if test="record.vipName != null and record.vipName !='' ">
                and b.VIP_NAME like CONCAT('%',#{record.vipName},'%')
            </if>
            <if test="record.vipPhone !=null and record.vipPhone !=''  ">
                and b.PHONE like CONCAT('%',#{record.vipPhone},'%')
            </if>
            <if test="record.createStaffId != null and record.createStaffId !='' ">
                and a.CREATE_STAFF_ID  = #{record.createStaffId}
            </if>
            <if test="record.id != null and record.id !='' ">
                and a.ID  = #{record.id}
            </if>
            <if test="record.bedId != null and record.bedId !='' ">
                and a.BED_ID  = #{record.bedId}
            </if>
            <if test="record.state != null and record.state !='' ">
                and a.STATE  = #{record.state}
            </if>
 
            <if test="(record.companyId!=null and record.companyId!='') ">
                and a.company_id = #{record.companyId}
            </if>
            <if test="record.shopId != null and record.shopId !='' ">
                AND a.SHOP_ID = #{record.shopId}
            </if>
            <if test="record.vipId != null and record.vipId !='' ">
                and a.VIP_ID   = #{record.vipId}
            </if>
            <if test="record.isOverTime != null  and record.serviceNo !=''   ">
                and a.IS_OVERTIME  > #{record.isOverTime}
            </if>
            <if test="record.serviceNo != null and record.serviceNo !='' ">
                and a.SERVICE_NO  like CONCAT('%',#{record.serviceNo},'%')
            </if>
            <if test="record.beginTime != null  ">
                and a.YY_TIME  <![CDATA[>=]]> #{record.beginTime}
            </if>
            <if test="record.closureTime != null  ">
                and a.YY_TIME <![CDATA[<=]]> #{record.closureTime}
            </if>
        </if>
             ) t
 
    </select>
 
    <!-- 根据id查询-->
    <select id="selectById" resultMap="SysProjServicesMap">
        select    distinct
        a.*,
        b.PHONE ,
        b.VIP_Name ,
        b.VIP_NO,
        (select  su_name from  sys_users f where  a.CREATE_STAFF_ID=f.su_id ) as  createStaffName,
        (select  su_name from  sys_users j where  a.BEAUTICIAN_ID=j.su_id ) as  beautiName,
        (select  su_name from  sys_users k where  a.devision_id=k.su_id ) as plsName,
        (select  shop_name from  sys_shop_info h where  a.SHOP_ID=h.ID ) as shopName,
        (select  bed_name from  sys_bed_info i where  a.BED_ID=i.ID ) as bedName
        FROM sys_proj_services a
        LEFT JOIN sys_vip_info b on b.ID=a.VIP_ID
        left join sys_beautician_state c on a.id=c.SERVICES_ID
        where  a.ID=#{id}
    </select>
 
    <select id="selectNeedNoticeService" resultMap="SysProjServicesMap">
    select
        a.id,
        a.company_id,
        b.VIP_Name
        FROM sys_proj_services a
        LEFT JOIN sys_vip_info b on b.ID=a.VIP_ID
        where   a.YY_TIME > now()
        and DATE_ADD(now(),INTERVAL 1 HOUR) > a.YY_TIME
        and overtime_notice is null
    </select>
 
 
 
    <!-- 根据对象查询-->
    <select id="selectByModel" resultMap="SysProjServicesMap">
        select    distinct
        a.*,
        b.PHONE ,
        b.VIP_Name ,
        b.VIP_NO,
        (select  su_name from  sys_users f where  a.CREATE_STAFF_ID=f.su_id ) as  createStaffName,
        (select  su_name from  sys_users j where  a.BEAUTICIAN_ID=j.su_id ) as  beautiName,
        (select  su_name from  sys_users k where  a.devision_id=k.su_id ) as plsName,
        (select  shop_name from  sys_shop_info h where  a.SHOP_ID=h.ID ) as shopName,
        (select  bed_name from  sys_bed_info i where  a.BED_ID=i.ID ) as bedName
        FROM sys_proj_services a
        LEFT JOIN sys_vip_info b on b.ID=a.VIP_ID
        left join sys_beautician_state c on a.id=c.SERVICES_ID
        WHERE 1 = 1
        <if test="record!=null">
            <if test="record.queryStaffId != null and record.queryStaffId !='' ">
                and (a.CREATE_STAFF_ID  = #{record.queryStaffId}  or c.STAFF_ID=#{record.queryStaffId}  )
            </if>
            <if test="record.vipName != null and record.vipName !='' ">
                and b.VIP_NAME like CONCAT('%',#{record.vipName},'%')
            </if>
            <if test="record.vipPhone !=null and record.vipPhone !=''  ">
                and b.PHONE like CONCAT('%',#{record.vipPhone},'%')
            </if>
            <if test="record.createStaffId != null and record.createStaffId !='' ">
                and a.CREATE_STAFF_ID  = #{record.createStaffId}
            </if>
            <if test="record.id != null and record.id !='' ">
                and a.ID  = #{record.id}
            </if>
            <if test="record.bedId != null and record.bedId !='' ">
                and a.BED_ID  = #{record.bedId}
            </if>
            <if test="record.state != null and record.state !='' ">
                and a.STATE  = #{record.state}
            </if>
            <if test="record.shopId != null and record.shopId !='' ">
                AND a.SHOP_ID = #{record.shopId}
            </if>
            <if test="record.vipId != null and record.vipId !='' ">
                and a.VIP_ID   = #{record.vipId}
            </if>
            <if test="record.isOverTime != null  and record.serviceNo !=''   ">
                and a.IS_OVERTIME  > #{record.isOverTime}
            </if>
            <if test="record.serviceNo != null and record.serviceNo !='' ">
                and a.SERVICE_NO  like CONCAT('%',#{record.serviceNo},'%')
            </if>
 
            <if test="(record.companyId!=null and record.companyId!='') ">
                and a.company_id = #{record.companyId}
            </if>
            <if test="record.beginTime != null  ">
                and a.YY_TIME  <![CDATA[>=]]> #{record.beginTime}
            </if>
            <if test="record.closureTime != null  ">
                and a.YY_TIME <![CDATA[<=]]> #{record.closureTime}
            </if>
        </if>
    </select>
 
    <resultMap id="ServiceOrderListVoMap" type="com.matrix.system.app.vo.ServiceOrderListVo">
        <id column="id" property="id" />
        <result column="serviceNo" property="serviceNo"/>
        <result property="time" column="time"/>
        <result property="bed" column="bed" />
        <result property="vipName" column="vipName" />
        <result property="vipId" column="vipId" />
        <result property="timeLength" column="timeLength" />
        <result property="status" column="status" />
        <result property="createStaffId" column="createStaffId" />
        <result property="shopName" column="shop_short_name" />
        <collection property="projs" ofType="com.matrix.system.app.vo.ServiceOrderListProjVo">
            <result property="projName" column="projName" />
            <result property="beautyName" column="beautyName" />
            <result property="id" column="staffId" />
        </collection>
    </resultMap>
 
 
    <select id="selectApiServiceOrderListInPage" resultMap="ServiceOrderListVoMap">
        select
           a.id id,
           a.SERVICE_NO serviceNo,
           a.YY_TIME time,
           a.TOTAL_TIME timeLength,
           a.state status,
           a.create_staff_id createStaffId,
           d.BED_NAME bed,
           e.VIP_NAME vipName,
           e.id vipId,
           b.staff_id staffId,
           f.su_name beautyName,
           g.proj_name projName,
           h.shop_short_name
        from sys_proj_services a
        left join sys_beautician_state b on a.ID=b.SERVICES_ID
        left join sys_bed_state c on a.ID = c.SERVICE_ID
        left join sys_bed_info d on c.BED_ID=d.ID
        left join sys_vip_info e on a.VIP_ID=e.ID
        left join sys_users f on f.su_id=b.STAFF_ID
        left join sys_proj_use g on b.puse_id=g.ID
        left join sys_shop_info h on a.SHOP_ID=h.ID
        <where>
            and a.company_id=#{record.companyId}
            <if test="record.queryKey != null and record.queryKey != ''">
                and (instr(a.SERVICE_NO, #{record.queryKey}) or instr(e.phone, #{record.queryKey}) or instr(e.vip_name, #{record.queryKey}) )
            </if>
            <if test="record.vipId != null and record.vipId != ''">
                and a.vip_id = #{record.vipId}
            </if>
            <if test="record.status != null and record.status != ''">
                and a.state = #{record.status}
             </if>
            <if test="record.shopId != null">
                and a.shop_id=#{record.shopId}
            </if>
            <if test="record.userId!=null">
                and (a.create_staff_id=#{record.userId} or b.staff_id=#{record.userId})
            </if>
 
        </where>
        <if test="pageVo !=null"><!-- 判断pageVo对象是否为空 -->
            order by a.yy_time desc
            <if test="pageVo.offset >=0  and pageVo.limit >0">
                limit
                #{pageVo.offset},#{pageVo.limit}
            </if>
        </if>
    </select>
 
    <select id="selectApiServiceOrderListTotal" resultType="java.lang.Integer">
        select count(1)
        from sys_proj_services a
        left join sys_beautician_state b on a.ID=b.SERVICES_ID
        left join sys_bed_state c on a.ID = c.SERVICE_ID
        left join sys_bed_info d on c.BED_ID=d.ID
        left join sys_vip_info e on a.VIP_ID=e.ID
        left join sys_users f on f.su_id=b.STAFF_ID
        left join sys_proj_use g on b.puse_id=g.ID
        <where>
            and a.company_id=#{record.companyId}
            <if test="record.queryKey != null and record.queryKey != ''">
                and (instr(a.SERVICE_NO, #{record.queryKey}) or instr(e.phone, #{record.queryKey}) or instr(e.vip_name, #{record.queryKey}) )
            </if>
            <if test="record.status != null and record.status != ''">
                and a.state = #{record.status}
            </if>
            <if test="record.shopId != null">
                and a.shop_id=#{record.shopId}
            </if>
            <if test="record.userId!=null">
                and (a.create_staff_id=#{record.userId} or b.staff_id=#{record.userId})
            </if>
        </where>
    </select>
 
 
 
 
    <resultMap id="ErpServiceOrderListVoMap" type="com.matrix.system.shopXcx.api.vo.ErpServiceOrderListVo">
        <id column="id" property="id" />
        <result column="serviceNo" property="serviceNo"/>
        <result property="time" column="time"/>
        <result property="bed" column="bed" />
        <result property="timeLength" column="timeLength" />
        <result property="status" column="status" />
        <result property="shopName" column="shopName" />
        <result property="shopAddr" column="shopAddr" />
        <result property="comment" column="comment" />
        <result property="reply" column="reply" />
        <collection property="projs" ofType="com.matrix.system.shopXcx.api.vo.ErpServiceOrderListProjVo">
            <result property="projName" column="projName" />
            <result property="beautyName" column="beautyName" />
            <result property="imgMobile" column="imgMobile" />
        </collection>
    </resultMap>
    <select id="findWxServiceOrderList" resultMap="ErpServiceOrderListVoMap">
        select
        a.id id,
        a.SERVICE_NO serviceNo,
        a.YY_TIME time,
        a.TOTAL_TIME timeLength,
        a.state status,
        d.BED_NAME bed,
        f.su_name beautyName,
        g.proj_name projName,
        h.shop_short_name as shopName,
        h.shop_addr as shopAddr,
        m.img as imgMobile
        from sys_proj_services a
        left join sys_beautician_state b on a.ID=b.SERVICES_ID
        left join sys_bed_state c on a.ID = c.SERVICE_ID
        left join sys_bed_info d on c.BED_ID=d.ID
        left join sys_vip_info e on a.VIP_ID=e.ID
        left join sys_users f on f.su_id=b.STAFF_ID
        left join sys_proj_use g on b.puse_id=g.ID
        left join sys_shop_info h on a.SHOP_ID=h.ID
        left join shopping_goods m on g.proj_id=m.id
        <where>
            <if test="queryKey != null and queryKey != ''">
                and instr(a.SERVICE_NO, #{queryKey})
            </if>
            <if test="vipId != null and vipId != ''">
                and a.vip_id = #{vipId}
            </if>
            <if test="vipStatus != null and vipStatus != '' and vipStatus!=0 ">
                <if test="vipStatus == 1">
                    and a.state = '待确认'
                </if>
                <if test="vipStatus == 2">
                    and a.state in ( '预约成功待处理' ,'需配料','配料完成','服务中')
                </if>
                <if test="vipStatus == 3">
                    and ( a.state in ( '服务完成' ,'服务单结束') and a.comment is  null)
                </if>
                <if test="vipStatus == 4">
                    and a.comment is not null
                </if>
                <if test="vipStatus == 5">
                    and a.state = '预约取消'
                </if>
            </if>
        </where>
            order by a.yy_time desc
            limit #{offset}, #{limit}
    </select>
    <select id="findWxServiceOrderById" resultMap="ErpServiceOrderListVoMap">
        select
        a.id id,
        a.SERVICE_NO serviceNo,
        a.YY_TIME time,
        a.TOTAL_TIME timeLength,
        a.state status,
        a.comment,
        a.reply,
        d.BED_NAME bed,
        f.su_name beautyName,
        g.proj_name projName,
        h.shop_short_name as shopName,
        h.shop_addr as shopAddr,
        m.img as imgMobile
        from sys_proj_services a
        left join sys_beautician_state b on a.ID=b.SERVICES_ID
        left join sys_bed_state c on a.ID = c.SERVICE_ID
        left join sys_bed_info d on c.BED_ID=d.ID
        left join sys_vip_info e on a.VIP_ID=e.ID
        left join sys_users f on f.su_id=b.STAFF_ID
        left join sys_proj_use g on b.puse_id=g.ID
        left join sys_shop_info h on a.SHOP_ID=h.ID
        left join shopping_goods m on g.proj_id=m.id
        where a.id=#{id}
    </select>
 
 
    <select id="selectProjServicesByOrderItemId" resultMap="SysProjServicesMap">
        select a.* from sys_proj_services a
          inner join sys_beautician_state b on a.id=b.SERVICES_ID
          inner join sys_proj_use c on c.id=b.puse_id
        where ORDER_ITEM_ID=#{itemId} and a.STATE!='预约取消'
    </select>
</mapper>