IMDoingOrderMapper.xml
42.7 KB
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
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
<?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.sibu.orderHelper.integral.dao.IMDoingOrderDao">
<!-- <cache type="org.mybatis.caches.ehcache.EhcacheCache"/> -->
<sql id="Base_DoingOrder_column">
order_id,member_id,order_code,order_status,order_from,
order_platform,contact,phone,province,city,
area,address,zipcode,total_integral,total_money,freight,buyer_remark,
erp_download,erp_import,create_dt,main_order_code,delete_flag,buyer_username,buyer_phone,express_name,
user_coupon_id,user_coupon_money,deduction_vb,deduction_money,share_member_id,share_order_money,supplier_id,supplier_name,platform_type
</sql>
<sql id="Base_DoingOrder1_column">
order1_id,member_id,order_id,sort_index,product_id,
purchase_quantity,shipped_quantity,integral,line_integral,price,line_price
</sql>
<sql id="Select_DoingOrder_column">
do.order_id,do.member_id,do.order_code,do.order_status,do.order_from,do.main_order_code,
do.order_platform,do.contact,do.phone,do.province,do.city,do.area,do.address,do.zipcode,
do.buyer_remark,do.seller_remark,do.total_integral,do.total_money,do.freight,do.express_name,do.freight,do.if_evaluate,
do.express_code,do.express_code2,do.create_dt,do.user_coupon_id,do.user_coupon_money,do.deduction_vb,do.deduction_money,
do.erp_import,do.prerefund_original_order_status,do.buyer_username,do.buyer_phone,do.share_member_id,do.share_order_money,
do.main_order_code,
do1.order1_id,do1.product_id,
do1.purchase_quantity,do1.integral,do1.line_integral,do1.price,do1.line_price,do1.erp_code,do1.spec_detail,do1.sku_id,
do1.name,do1.thumb_img,do1.market_price,do1.is_evaluate,do1.discount_price,do1.discount_line_price,
do1.deduction_product_vb,do1.deduction_line_vb,do1.refund_status,do1.sort_index,do1.product_share_percentage
</sql>
<!-- 添加主订单 -->
<insert id="addDoingOrder" parameterType="map">
insert into ${tablename} (
<include refid="Base_DoingOrder_column"/>
) value(
#{doingOrder.orderId},
#{doingOrder.memberId},
#{doingOrder.orderCode},
#{doingOrder.orderStatus},
#{doingOrder.orderFrom},
#{doingOrder.orderPlatform},
#{doingOrder.contact},
#{doingOrder.phone},
#{doingOrder.province},
#{doingOrder.city},
#{doingOrder.area},
#{doingOrder.address},
#{doingOrder.zipcode},
#{doingOrder.totalIntegral},
#{doingOrder.totalMoney},
#{doingOrder.freight},
#{doingOrder.buyerRemark},
#{doingOrder.erpDownload},
#{doingOrder.erpImport},
NOW(),
#{doingOrder.mainOrderCode},
#{doingOrder.deleteFlag},
#{doingOrder.buyerUsername},
#{doingOrder.buyerPhone},
#{doingOrder.expressName},
#{doingOrder.userCouponId},
#{doingOrder.userCouponMoney},
#{doingOrder.deductionVb},
#{doingOrder.deductionMoney},
#{doingOrder.shareMemberId},
#{doingOrder.shareOrderMoney},
#{doingOrder.supplierId},
#{doingOrder.supplierName},
#{doingOrder.platformType}
)
</insert>
<!-- 添加子订单 -->
<insert id="addDoingOrder1" parameterType="map">
<![CDATA[
insert into ${doingOrder1table} (
order1_id,member_id,order_id,sort_index,product_id,
purchase_quantity,shipped_quantity,integral,line_integral,price,line_price,sku_id,erp_code,spec_detail,name,thumb_img,market_price,
discount_price,discount_line_price,deduction_product_vb,deduction_line_vb,product_share_percentage,
deduction_product_vb_price,deduction_line_vb_price,deduction_product_coupon_price,deduction_line_coupon_price
) values
]]>
<foreach collection="doingOrders1" item="item" index="index" separator=",">
(
#{item.order1Id},
#{item.memberId},
#{item.orderId},
#{item.sortIndex},
#{item.productId},
#{item.purchaseQuantity},
#{item.shippedQuantity},
#{item.integral},
#{item.lineIntegral},
#{item.price},
#{item.linePrice},
#{item.skuId},
#{item.erpCode},
#{item.specDetail},
#{item.name},
#{item.thumbImg},
#{item.marketPrice},
#{item.discountPrice},
#{item.discountLinePrice},
#{item.deductionProductVb},
#{item.deductionLineVb},
#{item.productSharePercentage},
#{item.deductionProductVbPrice},
#{item.deductionLineVbPrice},
#{item.deductionProductCouponPrice},
#{item.deductionLineCouponPrice}
)
</foreach>
</insert>
<!--添加赠品-->
<insert id="addProductToOrder" parameterType="map">
insert into ${doingOrder1table} (
order1_id,member_id,order_id,sort_index,product_id,
purchase_quantity,shipped_quantity,integral,line_integral,price,line_price,sku_id,erp_code,spec_detail,name,thumb_img,market_price
) value
(
#{doingOrder1.order1Id},
#{doingOrder1.memberId},
#{doingOrder1.orderId},
#{doingOrder1.sortIndex},
#{doingOrder1.productId},
#{doingOrder1.purchaseQuantity},
#{doingOrder1.shippedQuantity},
#{doingOrder1.integral},
#{doingOrder1.lineIntegral},
#{doingOrder1.price},
#{doingOrder1.linePrice},
#{doingOrder1.skuId},
#{doingOrder1.erpCode},
#{doingOrder1.specDetail},
#{doingOrder1.name},
#{doingOrder1.thumbImg},
#{doingOrder1.marketPrice}
)
</insert>
<!-- 删除订单 -->
<delete id="deleteDoingOrder" parameterType="map">
delete from ${tablename} where main_order_code = #{orderId} and member_id = #{memberId}
</delete>
<!-- 检查某个产品用户可以兑换的件数 -->
<select id="getCanExchangeProductNum" parameterType="map" resultType="int">
select IFNULL(sum(purchase_quantity),0) from ${tablename} where product_id = #{productId} and member_id = #{memberId}
and order_id in
(
select order_id from ${orderTableName} where member_id = #{memberId} and order_status in (1,3,4,5,6,7,100)
)
</select>
<!-- 分页查询订单列表 (全部类型与待支付带兑换外)-->
<select id="listIMOrder" parameterType="map" resultMap="listIMOrderColumn">
select doo.order_id,doo.member_id,doo.order_code,doo.order_status,doo.order_from,
doo.order_platform,doo.contact,doo.phone,doo.total_integral,doo.total_money,doo.freight,doo.create_dt,doo.if_evaluate,
do1.order1_id,do1.product_id,do1.purchase_quantity,do1.integral,do1.line_integral,do1.price,do1.line_price,do1.is_evaluate,do1.spec_detail,
do1.name,do1.thumb_img,do1.market_price,do1.product_share_percentage
from ${doingOrder1Table} do1,
(
select do.order_id,do.member_id,do.order_code,do.order_status,do.order_from,
do.order_platform,do.contact,do.phone,do.total_integral,do.total_money,do.freight,do.create_dt,do.if_evaluate,do.share_order_money from ${doingOrderTable} do
where do.member_id = #{memberId} AND do.delete_flag=1
<if test="orderStatus >= 2 and orderStatus <= 3">
AND (do.order_status = 2 OR do.order_status = 3)
</if>
<if test="orderStatus == 1">
AND do.order_status = 1
</if>
<if test="orderStatus == 4">
AND do.order_status = 4
</if>
<if test="orderStatus == 5">
AND do.order_status = 5 AND do.if_evaluate = 0
</if>
<if test="orderStatus == 6">
AND do.order_status >= 6 AND do.order_status <= 8
</if>
<if test="orderStatus == 9">
AND do.order_status = 5 AND do.if_evaluate = 1
</if>
order by do.create_dt desc
limit ${pageNow}, ${pageSize}
) doo
where doo.order_id=do1.order_id
order by doo.create_dt desc
</select>
<!-- 计算总记录数(待支付与带兑换) -->
<select id="countIMOrderByWait" parameterType="map" resultType="int">
SELECT COUNT(1) FROM
(
SELECT do.order_id,do.member_id,do.order_code,do.order_status,do.order_from,do.main_order_code,
do.order_platform,do.contact,do.phone,sum(do.total_integral) total_integral,sum(do.total_money) total_money,sum(do.freight) freight,
do.create_dt,do.if_evaluate,SUM(do.share_order_money) share_order_money
FROM ${doingOrderTable} do
where do.member_id = #{memberId} AND do.delete_flag=1 AND order_from='0'
AND do.order_status = 1 GROUP BY main_order_code
UNION ALL
(
SELECT do.order_id,do.member_id,do.order_code,do.order_status,do.order_from,do.main_order_code,
do.order_platform,do.contact,do.phone,sum(do.total_integral) total_integral,sum(do.total_money) total_money,sum(do.freight) freight,
do.create_dt,do.if_evaluate,SUM(do.share_order_money) share_order_money
FROM ${doingOrderTable} do
where do.member_id = #{memberId} AND do.delete_flag=1 AND order_from='1'
AND do.order_status = 1 GROUP BY main_order_code
)
) o ORDER BY CREATE_dt DESC
</select>
<resultMap type="com.sibu.orderHelper.integral.reponse.DoingOrderListResponse" id="listIMOrderColumn">
<id column="order_id" property="orderId" />
<result column="member_id" property="memberId" />
<result column="order_code" property="orderCode" />
<result column="order_status" property="orderStatus" />
<result column="order_from" property="orderFrom" />
<result column="contact" property="contact" />
<result column="phone" property="phone" />
<result column="total_integral" property="totalIntegral" />
<result column="total_money" property="totalMoney" />
<result column="freight" property="freight" />
<result column="create_dt" property="createDt" />
<result column="if_evaluate" property="ifEvaluate" />
<result column="main_order_code" property="mainOrderCode" />
<result column="share_order_money" property="shareOrderMoney" />
<collection property="order1s" column="order_id" ofType="com.sibu.orderHelper.integral.reponse.DoingOrder1DetailResponse">
<id column="order1_id" property="order1Id" />
<result column="product_id" property="productId" />
<result column="purchase_quantity" property="purchaseQuantity" />
<result column="shipped_quantity" property="shippedQuantity" />
<result column="integral" property="integral" />
<result column="line_integral" property="lineIntegral" />
<result column="price" property="price" />
<result column="line_price" property="linePrice" />
<result column="is_evaluate" property="isEvaluate" />
<result column="spec_detail" property="specDetail"/>
<result column="name" property="name" />
<result column="market_price" property="marketPrice" />
<result column="thumb_img" property="thumbImg" />
<result column="product_share_percentage" property="productSharePercentage" />
</collection>
</resultMap>
<!-- 查询订单详情(包含产品) -->
<select id="getIMOrderDetailById" parameterType="map" resultMap="oneIMOrderDetailColumn">
select <include refid="Select_DoingOrder_column"/> ,do.supplier_id,do.supplier_name,do.platform_type
from ${doingOrderTable} do left join ${doingOrder1Table} do1 on do.order_id=do1.order_id
where do.order_id=#{orderId} AND do.member_id = #{memberId} AND do.delete_flag=1
</select>
<!-- 查询订单详情(包含产品) -->
<select id="getIMOrderDetailByMainOrderCodeAndMemberIdAndOrderFrom" parameterType="map" resultMap="oneIMOrderDetailColumn">
select <include refid="Select_DoingOrder_column"/>
from ${doingOrderTable} do left join ${doingOrder1Table} do1 on do.order_id=do1.order_id
where do.main_order_code=#{mainOrderCode} AND do.member_id = #{memberId} AND do.delete_flag=1 and do.order_from=#{orderFrom}
</select>
<!-- 查询订单详情(包含产品) -->
<select id="getIMOrderDetailByMainOrderCodeAndOrderFrom" parameterType="map" resultMap="oneIMOrderDetailColumn">
select <include refid="Select_DoingOrder_column"/>
from ${doingOrderTable} do left join ${doingOrder1Table} do1 on do.order_id=do1.order_id
where do.main_order_code=#{mainOrderCode} AND do.delete_flag=1 and do.order_from=#{orderFrom}
</select>
<select id="getIMOrderDetailByOrderCode" parameterType="map" resultMap="oneIMOrderDetailColumn">
select <include refid="Select_DoingOrder_column"/>,do.transaction_id,do1.deduction_line_coupon_price,do1.deduction_line_vb_price
from ${doingOrderTable} do left join ${doingOrder1Table} do1
on do.order_id=do1.order_id
where do.order_code = #{orderCode} AND do.delete_flag=1
</select>
<select id="getIMOrderDetailByMap" parameterType="map" resultMap="oneIMOrderDetailColumn">
select <include refid="Select_DoingOrder_column"/>,do.transaction_id,do1.deduction_line_coupon_price,do1.deduction_line_vb_price
from ${doingOrderTable} do left join ${doingOrder1Table} do1
on do.order_id=do1.order_id
where do.order_code = #{orderCode} AND do.delete_flag=1 and order_status IN ('1','3','4','5','8','100')
</select>
<!-- 根据main_order_code查询现金订单详情-->
<select id="getIMOrderDetailByMainOrderCode" parameterType="map" resultMap="oneIMOrderDetailColumn">
SELECT <include refid="Select_DoingOrder_column"/> FROM
(
SELECT do.order_id,do.member_id,do.order_code,do.order_status,do.order_from,do.main_order_code,
do.order_platform,do.contact,do.phone,do.province,do.city,do.area,do.address,do.zipcode,
do.buyer_remark,do.seller_remark,sum(do.total_integral) total_integral,sum(do.total_money) total_money,do.express_name,sum(do.freight) freight,do.if_evaluate,
do.express_code,do.express_code2,do.create_dt,do.user_coupon_id,sum(do.user_coupon_money) user_coupon_money,sum(do.deduction_vb) deduction_vb,sum(do.deduction_money) deduction_money,
do.erp_import,do.prerefund_original_order_status,do.buyer_username,do.buyer_phone,do.share_member_id,sum(do.share_order_money) share_order_money
FROM ${doingOrderTable} do
WHERE do.main_order_code = #{orderCode} AND order_from = 1
AND do.delete_flag=1
GROUP BY main_order_code
) do
,
(
select do1.order1_id,do1.product_id,
do1.purchase_quantity,do1.integral,do1.line_integral,do1.price,do1.line_price,do1.erp_code,do1.spec_detail,do1.sku_id,
do1.name,do1.thumb_img,do1.market_price,do1.is_evaluate,do1.discount_price,do1.discount_line_price,
do1.deduction_product_vb,do1.deduction_line_vb,do1.refund_status,do1.sort_index,do1.product_share_percentage,do.main_order_code
from ${doingOrderTable} do,${doingOrder1Table} do1
WHERE do.order_id=do1.order_id AND do.main_order_code = #{orderCode} AND order_from = 1
AND do.delete_flag=1
) do1
WHERE do.main_order_code=do1.main_order_code
</select>
<select id="listCommentByOrder" parameterType="map" resultMap="listOrder1sProduct">
select do1.order1_id,do1.member_id,do1.order_id,do1.sort_index,do1.product_id,
do1.purchase_quantity,do1.shipped_quantity,do1.integral,do1.line_integral,do1.price,do1.line_price,do1.is_evaluate,do1.spec_detail,
do1.name,do1.market_price,do1.thumb_img
from ${doingOrder1Table} do1
where do1.order_id = #{orderId}
</select>
<select id="getDoingOrder1ToComment" parameterType="map" resultMap="listOrder1sProduct">
select do1.order1_id,do1.member_id,do1.order_id,do1.sort_index,do1.product_id,
do1.purchase_quantity,do1.shipped_quantity,do1.integral,do1.line_integral,do1.price,do1.line_price,do1.is_evaluate,do1.spec_detail,
do1.name,do1.market_price,do1.thumb_img
from ${doingOrder1Table} do1
where do1.order1_id = #{order1Id}
</select>
<resultMap type="com.sibu.orderHelper.integral.reponse.DoingOrder1DetailResponse" id="listOrder1sProduct">
<id column="order1_id" property="order1Id" />
<result column="member_id" property="memberId" />
<result column="order_id" property="orderId" />
<result column="sort_index" property="sortIndex" />
<result column="product_id" property="productId" />
<result column="purchase_quantity" property="purchaseQuantity" />
<result column="shipped_quantity" property="shippedQuantity" />
<result column="integral" property="integral" />
<result column="line_integral" property="lineIntegral" />
<result column="price" property="price" />
<result column="line_price" property="linePrice" />
<result column="is_evaluate" property="isEvaluate" />
<result column="spec_detail" property="specDetail"/>
<result column="name" property="name"/>
<result column="thumb_img" property="thumbImg"/>
<result column="market_price" property="marketPrice"/>
</resultMap>
<resultMap type="com.sibu.orderHelper.integral.reponse.DoingOrderDetailResponse" id="oneIMOrderDetailColumn">
<id column="order_id" property="orderId" />
<result column="member_id" property="memberId" />
<result column="order_code" property="orderCode" />
<result column="order_status" property="orderStatus" />
<result column="order_from" property="orderFrom" />
<result column="contact" property="contact" />
<result column="phone" property="phone" />
<result column="province" property="province" />
<result column="city" property="city" />
<result column="area" property="area" />
<result column="address" property="address" />
<result column="zipcode" property="zipcode" />
<result column="buyer_remark" property="buyerRemark" />
<result column="seller_remark" property="sellerRemark" />
<result column="total_integral" property="totalIntegral" />
<result column="total_money" property="totalMoney" />
<result column="freight" property="freight" />
<result column="express_name" property="expressName" />
<result column="express_code" property="expressCode" />
<result column="express_code2" property="expressCode2" />
<result column="create_dt" property="createDt" />
<result column="user_coupon_id" property="userCouponId" />
<result column="user_coupon_money" property="userCouponMoney" />
<result column="deduction_vb" property="deductionVb" />
<result column="deduction_money" property="deductionMoney" />
<result column="if_evaluate" property="ifEvaluate" />
<result column="erp_import" property="erpImport" />
<result column="prerefund_original_order_status" property="prerefundOriginalOrderStatus" />
<result column="buyer_username" property="buyerUsername" />
<result column="buyer_phone" property="buyerPhone" />
<result column="share_member_id" property="shareMemberId" />
<result column="share_order_money" property="shareOrderMoney" />
<result column="main_order_code" property="mainOrderCode" />
<result column="supplier_id" property="supplierId" />
<result column="supplier_name" property="supplierName" />
<result column="platform_type" property="platformType" />
<result column="transaction_id" property="transactionId"/>
<collection property="order1s" column="order_id" ofType="com.sibu.orderHelper.integral.reponse.DoingOrder1DetailResponse">
<id column="order1_id" property="order1Id" />
<result column="product_id" property="productId" />
<result column="purchase_quantity" property="purchaseQuantity" />
<result column="shipped_quantity" property="shippedQuantity" />
<result column="integral" property="integral" />
<result column="line_integral" property="lineIntegral" />
<result column="price" property="price" />
<result column="line_price" property="linePrice" />
<result column="spec_detail" property="specDetail"/>
<result column="erp_code" property="erpCode"/>
<result column="sku_id" property="skuId"/>
<result column="name" property="name" />
<result column="thumb_img" property="thumbImg" />
<result column="market_price" property="marketPrice" />
<result column="is_evaluate" property="isEvaluate" />
<result column="discount_price" property="discountPrice" />
<result column="discount_line_price" property="discountLinePrice" />
<result column="deduction_product_vb" property="deductionProductVb" />
<result column="deduction_line_vb" property="deductionLineVb" />
<result column="deduction_line_coupon_price" property="deductionLineCouponPrice" />
<result column="deduction_line_vb_price" property="deductionLineVbPrice" />
<result column="refund_status" property="refundStatus" />
<result column="sort_index" property="sortIndex" />
<result column="product_share_percentage" property="productSharePercentage" />
</collection>
</resultMap>
<!-- 获取订单详情(不包含产品) -->
<select id="getOneIMOrderById" parameterType="map" resultMap="oneIMOrderNotProduct">
select order_id,member_id,order_code,order_status,order_from,
order_platform,contact,phone,total_integral,freight,create_dt,pay_dt,total_money,buyer_username,buyer_phone
from ${doingOrderTable}
where order_id=#{orderId} AND member_id = #{memberId} AND delete_flag=1
</select>
<resultMap type="com.sibu.orderHelper.integral.reponse.DoingOrderDetailResponse" id="oneIMOrderNotProduct">
<result column="order_id" property="orderId" />
<result column="member_id" property="memberId" />
<result column="order_code" property="orderCode" />
<result column="order_status" property="orderStatus" />
<result column="order_from" property="orderFrom" />
<result column="contact" property="contact" />
<result column="phone" property="phone" />
<result column="total_integral" property="totalIntegral" />
<result column="total_money" property="totalMoney" />
<result column="freight" property="freight" />
<result column="create_dt" property="createDt" />
<result column="pay_dt" property="payDt" />
<result column="buyer_username" property="buyerUsername" />
<result column="buyer_phone" property="buyerPhone" />
</resultMap>
<!-- 恢复退单之前的订单状态 -->
<update id="restorePreOrderStatus" parameterType="map">
update ${doingOrderTable} set order_status=#{newStatus} where order_id=#{orderId} AND member_id = #{memberId} and order_status = #{oldStatus}
</update>
<!-- 取消订单 -->
<update id="cancleIMorderById" parameterType="map">
update ${doingOrderTable} set order_status=8 where order_id=#{orderId} AND member_id = #{memberId} and order_status = 1
</update>
<!-- 取消订单 -->
<update id="cancelByMainOrderCodeAndMemberIdAndOrderFromAndOrderStatusIsWaitPay" parameterType="map">
update ${doingOrderTable} set order_status=8 where main_order_code=#{mainOrderCode} AND member_id = #{memberId} and order_from = #{orderFrom} and order_status = 1
</update>
<!-- 取消订单 -->
<update id="deleteOrderById" parameterType="map">
update ${doingOrderTable} set delete_flag=0 where order_id=#{orderId} AND member_id = #{memberId} and order_status = 1
</update>
<!-- 更新订单状态 -->
<update id="updateOrderStatus" parameterType="map">
update ${doingOrderTable} set order_status = ${orderStatus}, pay_dt=NOW() where order_id=#{orderId} AND member_id = #{memberId} limit 1
</update>
<!--更新订单赠送的优惠券-->
<update id="updateOrderCoupon" parameterType="map">
update ${doingOrderTable} set gift_coupon_id=#{giftCouponId} where order_id=#{orderId} AND member_id = #{memberId} limit 1
</update>
<update id="updateOrderStatusAndSavePreOrderStatus" parameterType="map" >
update ${doingOrderTable}
set order_status = ${newOrderStatus},prerefund_original_order_status = ${oldOrderStatus}
where order_id=#{orderId} and member_id = #{memberId} and order_status = #{oldOrderStatus} and erp_import=#{oldErpImport}
</update>
<update id="updateIntegralPayOrderStatus" parameterType="map">
update ${doingOrderTable} set order_status = ${orderStatus}, pay_dt=NOW(), pay_type=${payType} where order_id=#{orderId} AND member_id = #{memberId} limit 1
</update>
<!-- 更新微信支付订单状态,根据订单号 -->
<update id="updateWxPayOrder" parameterType="map">
update ${doingOrderTable} set order_status = ${orderStatus}, transaction_id=#{transactionId}, open_id=#{openId}, pay_type=${payType}, pay_dt=NOW()
where order_code = #{orderCode} and order_status in (1,8) limit 1
</update>
<!-- 新 更新微信支付订单状态,根据订单号查询出main_order_code,集合订单类型再更新 -->
<update id="updateNewWxPayOrder" parameterType="map">
update ${doingOrderTable} set order_status = ${orderStatus}, transaction_id=#{transactionId}, open_id=#{openId}, pay_type=${payType}, pay_dt=NOW() where main_order_code = #{mainOrderCode} and order_from = 1 and order_status = 1
</update>
<!-- 更新合并支付的微信支付订单状态,根据主订单号 -->
<update id="updateWxPayOrderForMainOrderCode" parameterType="map">
update ${doingOrderTable} set order_status = ${orderStatus}, transaction_id=#{transactionId}, open_id=#{openId}, pay_type=${payType}, pay_dt=NOW()
where main_order_code = #{mainOrderCode} and order_status in (1,8) and order_from = 1
</update>
<!-- 订单收货 -->
<update id="receivedOrder" parameterType="map">
update ${doingOrderTable} set order_status = ${orderStatus}, receive_dt=NOW() where order_id=#{orderId} AND member_id = #{memberId} limit 1
</update>
<!-- 获取子订单 -->
<select id="getOneIMOrder1ById" parameterType="map" resultMap="oneDoingOrder1Column">
select <include refid="Base_DoingOrder1_column" />
from ${doingOrder1Table}
where order_id = #{orderId} and product_id=#{productId} and member_id=#{memberId}
limit 1
</select>
<!-- 更新子订单的待评价转态 -->
<update id="updateDoingOrder1Evaluate" parameterType="map">
update ${doingOrder1Table} set is_evaluate = ${isEvaluate} where order1_id = #{order1Id} and member_id = #{memberId}
</update>
<!-- 统计子订单有多少未评价子订单数量 -->
<select id="totalDoingOrder1NotEvaluate" parameterType="map" resultType="int">
select count(1) from ${doingOrder1Table} where order_id = #{orderId} and member_id = #{memberId} and is_evaluate = ${isEvaluate}
</select>
<!-- 更新总订单是否已评价完 -->
<update id="updateDoingOrderEvaluate" parameterType="map">
update ${doingOrderTable} set if_evaluate = ${isEvaluate} where order_id = #{orderId} and member_id = #{memberId} limit 1
</update>
<update id="updateOrderItemRefundStatus" parameterType="map">
update ${doingOrder1Table} set refund_status = ${refundStatus} where order_id = #{orderId} and order1_id = #{order1Id}
</update>
<resultMap type="com.sibu.orderHelper.integral.reponse.DoingOrder1DetailResponse" id="oneDoingOrder1Column">
<id column="order1_id" property="order1Id" />
<result column="member_id" property="memberId" />
<result column="order_id" property="orderId" />
<result column="sort_index" property="sortIndex" />
<result column="product_id" property="productId" />
<result column="purchase_quantity" property="purchaseQuantity" />
<result column="shipped_quantity" property="shippedQuantity" />
<result column="integral" property="integral" />
<result column="line_integral" property="lineIntegral" />
<result column="price" property="price" />
<result column="line_price" property="linePrice" />
</resultMap>
<select id="getShareOrderCouponByOrderId" parameterType="java.util.Map" resultType="java.lang.String">
select gift_coupon_id from ${doingOrderTable} where order_id = #{orderId} limit 1
</select>
<!-- 分页查询订单列表待支付与待兑换 -->
<select id="listIMOrderWaitPay" parameterType="map" resultMap="listIMOrderColumnMain">
SELECT o.order_id,o.member_id,o.order_code,o.order_status,o.order_from,o.main_order_code,
o.order_platform,o.contact,o.phone,o.total_integral,o.total_money,o.freight,
o.create_dt,o.if_evaluate,o.share_order_money FROM
(
SELECT do.order_id,do.member_id,do.order_code,do.order_status,do.order_from,do.main_order_code,
do.order_platform,do.contact,do.phone,sum(do.total_integral) total_integral,sum(do.total_money) total_money,sum(do.freight) freight,
do.create_dt,do.if_evaluate,SUM(do.share_order_money) share_order_money
FROM ${doingOrderTable} do
where do.member_id = #{memberId} AND do.delete_flag=1 AND order_from='0'
AND do.order_status = 1 GROUP BY main_order_code
UNION ALL
(
SELECT do.order_id,do.member_id,do.order_code,do.order_status,do.order_from,do.main_order_code,
do.order_platform,do.contact,do.phone,sum(do.total_integral) total_integral,sum(do.total_money) total_money,sum(do.freight) freight,
do.create_dt,do.if_evaluate,SUM(do.share_order_money) share_order_money
FROM ${doingOrderTable} do
where do.member_id = #{memberId} AND do.delete_flag=1 AND order_from='1'
AND do.order_status = 1 GROUP BY main_order_code
)
) o ORDER BY CREATE_dt DESC
LIMIT ${pageNow}, ${pageSize}
</select>
<resultMap type="com.sibu.orderHelper.integral.reponse.DoingOrderListResponse" id="listIMOrderColumnMain">
<id column="order_id" property="orderId" />
<result column="member_id" property="memberId" />
<result column="order_code" property="orderCode" />
<result column="order_status" property="orderStatus" />
<result column="order_from" property="orderFrom" />
<result column="contact" property="contact" />
<result column="phone" property="phone" />
<result column="total_integral" property="totalIntegral" />
<result column="total_money" property="totalMoney" />
<result column="freight" property="freight" />
<result column="create_dt" property="createDt" />
<result column="if_evaluate" property="ifEvaluate" />
<result column="main_order_code" property="mainOrderCode" />
<result column="share_order_money" property="shareOrderMoney" />
<collection property="order1s" column="main_order_code" ofType="com.sibu.orderHelper.integral.reponse.DoingOrder1DetailResponse">
<id column="order1_id" property="order1Id" />
<result column="product_id" property="productId" />
<result column="purchase_quantity" property="purchaseQuantity" />
<result column="shipped_quantity" property="shippedQuantity" />
<result column="integral" property="integral" />
<result column="line_integral" property="lineIntegral" />
<result column="price" property="price" />
<result column="line_price" property="linePrice" />
<result column="is_evaluate" property="isEvaluate" />
<result column="spec_detail" property="specDetail"/>
<result column="name" property="name" />
<result column="market_price" property="marketPrice" />
<result column="thumb_img" property="thumbImg" />
<result column="product_share_percentage" property="productSharePercentage" />
</collection>
</resultMap>
<!-- 分页查询订单(全部类型) -->
<select id="listIMOrderAll" parameterType="map" resultMap="listIMOrderColumn">
SELECT o.order_id,o.member_id,o.order_code,o.order_status,o.order_from,o.main_order_code,
o.order_platform,o.contact,o.phone,o.total_integral,o.total_money,o.freight,
o.create_dt,o.if_evaluate,o.share_order_money FROM
(
SELECT do.order_id,do.member_id,do.order_code,do.order_status,do.order_from,do.main_order_code,
do.order_platform,do.contact,do.phone,sum(do.total_integral) total_integral,sum(do.total_money) total_money,sum(do.freight) freight,
do.create_dt,do.if_evaluate,SUM(do.share_order_money) share_order_money
FROM ${doingOrderTable} do
where do.member_id = #{memberId} AND do.delete_flag=1 AND order_from='0'
AND do.order_status = 1 GROUP BY main_order_code
UNION ALL
(
SELECT do.order_id,do.member_id,do.order_code,do.order_status,do.order_from,do.main_order_code,
do.order_platform,do.contact,do.phone,sum(do.total_integral) total_integral,sum(do.total_money) total_money,sum(do.freight) freight,
do.create_dt,do.if_evaluate,SUM(do.share_order_money) share_order_money
FROM ${doingOrderTable} do
where do.member_id = #{memberId} AND do.delete_flag=1 AND order_from='1'
AND do.order_status = 1 GROUP BY main_order_code
)
UNION ALL
(
SELECT do.order_id,do.member_id,do.order_code,do.order_status,do.order_from,do.main_order_code,
do.order_platform,do.contact,do.phone, total_integral, total_money, freight,
do.create_dt,do.if_evaluate, share_order_money
FROM ${doingOrderTable} do
where do.member_id = #{memberId} AND do.delete_flag=1
AND do.order_status != 1
)
) o ORDER BY CREATE_dt DESC
LIMIT ${pageNow}, ${pageSize}
</select>
<!-- 计算总记录数(待支付与带兑换外) -->
<select id="countIMOrderAll" parameterType="map" resultType="int">
SELECT COUNT(1) FROM
(
SELECT do.order_id,do.member_id,do.order_code,do.order_status,do.order_from,do.main_order_code,
do.order_platform,do.contact,do.phone,sum(do.total_integral) total_integral,sum(do.total_money) total_money,sum(do.freight) freight,
do.create_dt,do.if_evaluate,SUM(do.share_order_money) share_order_money
FROM ${doingOrderTable} do
where do.member_id = #{memberId} AND do.delete_flag=1 AND order_from='0'
AND do.order_status = 1 GROUP BY main_order_code
UNION ALL
(
SELECT do.order_id,do.member_id,do.order_code,do.order_status,do.order_from,do.main_order_code,
do.order_platform,do.contact,do.phone,sum(do.total_integral) total_integral,sum(do.total_money) total_money,sum(do.freight) freight,
do.create_dt,do.if_evaluate,SUM(do.share_order_money) share_order_money
FROM ${doingOrderTable} do
where do.member_id = #{memberId} AND do.delete_flag=1 AND order_from='1'
AND do.order_status = 1 GROUP BY main_order_code
)
UNION ALL
(
SELECT do.order_id,do.member_id,do.order_code,do.order_status,do.order_from,do.main_order_code,
do.order_platform,do.contact,do.phone, total_integral, total_money, freight,
do.create_dt,do.if_evaluate, share_order_money
FROM ${doingOrderTable} do
where do.member_id = #{memberId} AND do.delete_flag=1 AND order_from='0'
AND do.order_status != 1
)
UNION ALL
(
SELECT do.order_id,do.member_id,do.order_code,do.order_status,do.order_from,do.main_order_code,
do.order_platform,do.contact,do.phone, total_integral, total_money, freight,
do.create_dt,do.if_evaluate, share_order_money
FROM ${doingOrderTable} do
where do.member_id = #{memberId} AND do.delete_flag=1 AND order_from='1'
AND do.order_status != 1
)
) o ORDER BY CREATE_dt DESC
</select>
<!-- 查询订单详情(包含产品)待支付与待兑换 -->
<select id="getIMOrderDetailByMainIdAndOrderStatus" parameterType="map" resultMap="manyIMOrderDetailColumn">
SELECT <include refid="Select_DoingOrder_column"/> FROM
(
SELECT do.order_id,do.member_id,do.order_code,do.order_status,do.order_from,do.main_order_code,
do.order_platform,do.contact,do.phone,do.province,do.city,do.area,do.address,do.zipcode,
do.buyer_remark,do.seller_remark,sum(do.total_integral) total_integral,sum(do.total_money) total_money,do.express_name,sum(do.freight) freight,do.if_evaluate,
do.express_code,do.express_code2,do.create_dt,do.user_coupon_id,sum(do.user_coupon_money) user_coupon_money,sum(do.deduction_vb) deduction_vb,sum(do.deduction_money) deduction_money,
do.erp_import,do.prerefund_original_order_status,do.buyer_username,do.buyer_phone,do.share_member_id,sum(do.share_order_money) share_order_money
FROM ${doingOrderTable} do
WHERE do.main_order_code = #{mainOrderCode} AND do.order_status = '1' AND order_from = #{orderFrom}
AND do.delete_flag=1
GROUP BY main_order_code
) do
,
(
select do1.order1_id,do1.product_id,
do1.purchase_quantity,do1.integral,do1.line_integral,do1.price,do1.line_price,do1.erp_code,do1.spec_detail,do1.sku_id,
do1.name,do1.thumb_img,do1.market_price,do1.is_evaluate,do1.discount_price,do1.discount_line_price,
do1.deduction_product_vb,do1.deduction_line_vb,do1.refund_status,do1.sort_index,do1.product_share_percentage,do.main_order_code
from ${doingOrderTable} do,${doingOrder1Table} do1
WHERE do.order_id=do1.order_id AND do.main_order_code = #{mainOrderCode} AND do.order_status = '1' AND order_from = #{orderFrom}
AND do.delete_flag=1
) do1
WHERE do.main_order_code=do1.main_order_code
</select>
<!-- 待支付待兑换 ordercode使用main_order_code -->
<resultMap type="com.sibu.orderHelper.integral.reponse.DoingOrderDetailResponse" id="manyIMOrderDetailColumn">
<id column="order_id" property="orderId" />
<result column="member_id" property="memberId" />
<result column="order_code" property="orderCode" />
<result column="order_status" property="orderStatus" />
<result column="order_from" property="orderFrom" />
<result column="contact" property="contact" />
<result column="phone" property="phone" />
<result column="province" property="province" />
<result column="city" property="city" />
<result column="area" property="area" />
<result column="address" property="address" />
<result column="zipcode" property="zipcode" />
<result column="buyer_remark" property="buyerRemark" />
<result column="seller_remark" property="sellerRemark" />
<result column="total_integral" property="totalIntegral" />
<result column="total_money" property="totalMoney" />
<result column="freight" property="freight" />
<result column="express_name" property="expressName" />
<result column="express_code" property="expressCode" />
<result column="express_code2" property="expressCode2" />
<result column="create_dt" property="createDt" />
<result column="user_coupon_id" property="userCouponId" />
<result column="user_coupon_money" property="userCouponMoney" />
<result column="deduction_vb" property="deductionVb" />
<result column="deduction_money" property="deductionMoney" />
<result column="if_evaluate" property="ifEvaluate" />
<result column="erp_import" property="erpImport" />
<result column="prerefund_original_order_status" property="prerefundOriginalOrderStatus" />
<result column="buyer_username" property="buyerUsername" />
<result column="buyer_phone" property="buyerPhone" />
<result column="share_member_id" property="shareMemberId" />
<result column="share_order_money" property="shareOrderMoney" />
<result column="main_order_code" property="mainOrderCode" />
<collection property="order1s" column="main_order_Code" ofType="com.sibu.orderHelper.integral.reponse.DoingOrder1DetailResponse">
<id column="order1_id" property="order1Id" />
<result column="product_id" property="productId" />
<result column="purchase_quantity" property="purchaseQuantity" />
<result column="shipped_quantity" property="shippedQuantity" />
<result column="integral" property="integral" />
<result column="line_integral" property="lineIntegral" />
<result column="price" property="price" />
<result column="line_price" property="linePrice" />
<result column="spec_detail" property="specDetail"/>
<result column="erp_code" property="erpCode"/>
<result column="sku_id" property="skuId"/>
<result column="name" property="name" />
<result column="thumb_img" property="thumbImg" />
<result column="market_price" property="marketPrice" />
<result column="is_evaluate" property="isEvaluate" />
<result column="discount_price" property="discountPrice" />
<result column="discount_line_price" property="discountLinePrice" />
<result column="deduction_product_vb" property="deductionProductVb" />
<result column="deduction_line_vb" property="deductionLineVb" />
<result column="refund_status" property="refundStatus" />
<result column="sort_index" property="sortIndex" />
<result column="product_share_percentage" property="productSharePercentage" />
</collection>
</resultMap>
<!-- 计算总记录数(待支付与带兑换外) -->
<select id="countIMOrder" parameterType="map" resultType="int">
select COUNT(*)from ${doingOrderTable} where member_id = #{memberId} AND delete_flag=1
<if test="orderStatus >= 2 and orderStatus <= 3">
AND (order_status = 2 OR order_status = 3)
</if>
<if test="orderStatus == 1">
AND order_status = 1
</if>
<if test="orderStatus == 4">
AND order_status = 4
</if>
<if test="orderStatus == 5">
AND order_status = 5 and if_evaluate = 0
</if>
<if test="orderStatus == 6">
AND order_status >= 6 AND order_status <= 8
</if>
<if test="orderStatus == 9">
AND order_status = 5 and if_evaluate = 1
</if>
</select>
<!-- -->
<select id="countPineAppleOrder" parameterType="map" resultType="int">
SELECT SUM(num) AS num FROM
<foreach collection="tableNames" open="(" close=")" separator=" UNION ALL " item="tableName">
SELECT COUNT(*) AS num FROM ${tableName[0]}
where delete_flag =1 and supplier_id = #{supplierId}
<if test="orderStatusList !=null and orderStatusList.size() > 0">
and order_status in (
<foreach collection="orderStatusList" open="" close="" separator="," item="orderStatus">
#{orderStatus}
</foreach>
)
</if>
<if test="timeType != null">
<if test="timeType =='JH_02'">
<if test="startTime!=null">
and create_dt >= #{startTime}
</if>
<if test="endTime!=null">
and create_dt <= #{endTime}
</if>
</if>
<if test="timeType =='JH_01'">
<if test="startTime!=null">
and create_dt >= #{startTime}
</if>
<if test="endTime!=null">
and create_dt <= #{endTime}
</if>
</if>
</if>
</foreach>
as temp
</select>
<select id="pagerPineAppleOrders" parameterType="map" resultMap="oneIMOrderDetailColumn">
select * from
<foreach collection="tableNames" open="(" close=")" separator=" UNION ALL " item="tableName">
select
do.order_id,do.member_id,do.order_code,do.order_status,do.order_from,
do.order_platform,do.contact,do.phone,do.province,do.city,do.area,do.address,do.zipcode,
do.buyer_remark,do.seller_remark,do.total_integral,do.total_money,do.freight,do.express_name,do.if_evaluate,
do.express_code,do.express_code2,do.create_dt,do.user_coupon_id,do.user_coupon_money,do.deduction_vb,do.deduction_money,
do.erp_import,do.prerefund_original_order_status,do.buyer_username,do.buyer_phone,do.share_member_id,do.share_order_money,
do.main_order_code,do.transaction_id
from ${tableName[0]} do
where delete_flag =1 and supplier_id = #{supplierId}
<if test="orderStatusList !=null and orderStatusList.size() > 0">
and order_status in (
<foreach collection="orderStatusList" open="" close="" separator="," item="orderStatus">
#{orderStatus}
</foreach>
)
</if>
<if test="timeType != null">
<if test="timeType =='JH_02'">
<if test="startTime!=null">
and create_dt >= #{startTime}
</if>
<if test="endTime!=null">
and create_dt <= #{endTime}
</if>
</if>
<if test="timeType =='JH_01'">
<if test="startTime!=null">
and create_dt >= #{startTime}
</if>
<if test="endTime!=null">
and create_dt <= #{endTime}
</if>
</if>
</if>
</foreach>
as temp
ORDER BY temp.create_dt desc
limit ${pageNow}, ${pageSize}
</select>
<!-- 根据mainordercode与订单类型获取详细订单信息-->
<select id="getDoingOrder1DetailResponseList" parameterType="map" resultMap="listOrder1sProduct">
SELECT o1.order1_id,o1.product_id,o1.purchase_quantity,o1.integral,o1.line_integral,o1.price,o1.line_price,o1.is_evaluate,o1.spec_detail,
o1.name,o1.thumb_img,o1.market_price,o1.product_share_percentage FROM ${doingOrder1Table} o1
WHERE o1.order_id IN (SELECT do.order_id FROM ${doingOrderTable} do WHERE do.main_order_code = #{mainOrderCode} and do.order_from = #{orderFrom} and do.delete_flag = 1)
</select>
<select id="getDoingOrderDetailResponseList" parameterType="map" resultMap="oneIMOrderDetailColumn">
select <include refid="Select_DoingOrder_column"/>
from ${doingOrderTable} do left join ${doingOrder1Table} do1 on do.order_id=do1.order_id
where do.main_order_code = #{mainOrderCode} and do.order_from = #{orderFrom} AND do.delete_flag=1
</select>
<update id="updateOrderStatusByMap" parameterType="java.util.Map">
update ${doingOrderTable} set order_status = 7,
seller_remark='线下已退款处理,线上人工修改订单状态为退款成功'
WHERE order_code = #{orderCode}
</update>
</mapper>