zhibing.pu
2024-04-19 2e366b939271b6ea338641f8a72d1bcd2182dbe7
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
package com.stylefeng.guns.modular.api;
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.smallLogistics.model.OrderLogisticsSpread;
import com.stylefeng.guns.modular.smallLogistics.server.IOrderLogisticsService;
import com.stylefeng.guns.modular.smallLogistics.server.impl.OrderLogisticsSpreadService;
import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService;
import com.stylefeng.guns.modular.system.model.OrderPosition;
import com.stylefeng.guns.modular.system.model.Reassign;
import com.stylefeng.guns.modular.system.service.IDriverService;
import com.stylefeng.guns.modular.system.service.IOrderService;
import com.stylefeng.guns.modular.system.service.IReassignService;
import com.stylefeng.guns.modular.system.util.*;
import com.stylefeng.guns.modular.system.util.Tingg.model.CallbackRequest;
import com.stylefeng.guns.modular.system.util.Tingg.model.CallbackResponse;
import com.stylefeng.guns.modular.system.util.Tingg.model.Payments;
import com.stylefeng.guns.modular.system.warpper.BaseWarpper;
import com.stylefeng.guns.modular.system.warpper.MoneyInfoWarpper;
import com.stylefeng.guns.modular.system.warpper.OrderInfoWarpper;
import com.stylefeng.guns.modular.system.warpper.OrderListWarpper;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
 
/**
 * 订单相关控制器
 */
@RestController
@RequestMapping("")
public class OrderController {
 
    @Autowired
    private IOrderService orderService;
 
    @Autowired
    private IDriverService driverService;
 
    @Autowired
    private IReassignService reassignService;
 
    @Autowired
    private PushUtil pushUtil;
 
    @Autowired
    private ChinaMobileUtil chinaMobileUtil;
 
    @Autowired
    private IOrderLogisticsService orderLogisticsService;
 
    @Autowired
    private IOrderPrivateCarService orderPrivateCarService;
 
    @Value("${filePath}")
    private String filePath;
 
 
 
 
 
 
    /**
     * 司机端获取首页订单列表
     * @param state
     * @param pageNum
     * @param size
     * @param request
     * @return
     */
    @ResponseBody
    @PostMapping("/api/order/queryOrderList")
    @ApiOperation(value = "获取首页订单列表", tags = {"司机端-首页"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "数据类型(1=服务中,2=待服务)", name = "state", required = true, dataType = "int"),
            @ApiImplicitParam(value = "页码,首页1", name = "pageNum", required = true, dataType = "int"),
            @ApiImplicitParam(value = "页条数", name = "size", required = true, dataType = "int"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil<List<OrderListWarpper>> queryOrderList(Integer state, Integer pageNum, Integer size, Integer language, HttpServletRequest request){
        try {
            Integer uid = driverService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            List<Map<String, Object>> list = orderService.queryOrderList(state, pageNum, size, uid, language);
            return ResultUtil.success(OrderListWarpper.getOrderListWarpper(list));
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    /**
     * 司机端获取首页订单列表
     * @param state
     * @param pageNum
     * @param size
     * @param request
     * @return
     */
    @ResponseBody
    @PostMapping("/api/order/queryOrderList1")
    @ApiOperation(value = "获取首页订单列表", tags = {"司机端-车载端"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "数据类型(1=服务中,2=待服务)", name = "state", required = true, dataType = "int"),
            @ApiImplicitParam(value = "页码,首页1", name = "pageNum", required = true, dataType = "int"),
            @ApiImplicitParam(value = "页条数", name = "size", required = true, dataType = "int"),
            @ApiImplicitParam(value = "订单类型(1=其他订单,2=小件物流)", name = "type", required = true, dataType = "int"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil<List<OrderListWarpper>> queryOrderList1(Integer state, Integer type, Integer pageNum, Integer size, Integer language, HttpServletRequest request){
        try {
            Integer uid = driverService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            List<Map<String, Object>> list = orderService.queryOrderList1(state, type, pageNum, size, uid, language);
            return ResultUtil.success(OrderListWarpper.getOrderListWarpper(list));
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
 
 
 
    /**
     * 获取我的订单列表
     * @param state
     * @param pageNum
     * @param size
     * @param request
     * @return
     */
    @ResponseBody
    @PostMapping("/api/order/queryMyAllOrder")
    @ApiOperation(value = "获取我的订单列表", tags = {"司机端-首页"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "数据类型(1=全部,2=待支付,3=已取消,4=已完成)", name = "state", required = true, dataType = "int"),
            @ApiImplicitParam(value = "页码,首页1", name = "pageNum", required = true, dataType = "int"),
            @ApiImplicitParam(value = "页条数", name = "size", required = true, dataType = "int"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil<List<OrderListWarpper>> queryMyAllOrder(Integer state, Integer pageNum, Integer size, Integer language, HttpServletRequest request){
        try {
            Integer uid = driverService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            List<OrderListWarpper> listWarppers = orderService.queryMyAllOrder(state, pageNum, size, uid, language);
            return ResultUtil.success(listWarppers);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    /**
     * 获取抢单界面的订单详情
     * @param orderId
     * @param orderType
     * @param lon
     * @param lat
     * @return
     */
    @ResponseBody
    @PostMapping("/api/order/queryPushOrder")
    @ApiOperation(value = "获取抢单界面的订单详情【1.0】", tags = {"司机端-首页"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"),
            @ApiImplicitParam(value = "订单类型(1=专车,4=小件物流-同城)", name = "orderType", required = true, dataType = "int"),
            @ApiImplicitParam(value = "当前定位经度", name = "lon", required = true, dataType = "string"),
            @ApiImplicitParam(value = "当前定位纬度", name = "lat", required = true, dataType = "string"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil<OrderInfoWarpper> queryPushOrder(Integer orderId, Integer orderType, String lon, String lat, Integer language){
        try {
            Map<String, Object> map = orderService.queryPushOrder(orderId, orderType, lon, lat, language);
            OrderInfoWarpper orderInfoWarpper = OrderInfoWarpper.getOrderInfoWarpper(map);
            orderInfoWarpper.setOrderPositionList("");
            return ResultUtil.success(orderInfoWarpper);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    /**
     * 司机抢单操作
     * @param orderId
     * @param orderType
     * @param request
     * @return
     */
    @ResponseBody
    @PostMapping("/api/order/grabOrder")
    @ApiOperation(value = "司机抢单操作", tags = {"司机端-首页"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"),
            @ApiImplicitParam(value = "订单类型(1=专车,4=小件物流-同城)", name = "orderType", required = true, dataType = "int"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil grabOrder(Integer orderId, Integer orderType, Integer language, HttpServletRequest request){
        try {
            Integer uid = driverService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            return orderService.grabOrder(orderId, orderType, uid, language);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    @Autowired
    private OrderLogisticsSpreadService spreadService;
    /**
     * 获取服务中页面订单详情
     * @param orderId
     * @param orderType
     * @return
     */
    @ResponseBody
    @PostMapping("/api/order/queryOrderInfo")
    @ApiOperation(value = "获取服务中页面订单详情", tags = {"司机端-服务中"}, notes = "",response = OrderInfoWarpper.class)
    @ApiImplicitParams({
            @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"),
            @ApiImplicitParam(value = "订单类型(1=专车,4=小件物流-同城)", name = "orderType", required = true, dataType = "int"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil<OrderInfoWarpper> queryOrderInfo(Integer language, Integer orderId, Integer orderType){
        try {
            Map<String, Object> map = orderService.queryOrderInfo(language, orderId, orderType);
            OrderInfoWarpper orderInfoWarpper = OrderInfoWarpper.getOrderInfoWarpper(map);
            File file = new File(filePath + orderId + "_" + orderType + ".txt");
            if(file.exists()){
                //读取文件(字符流)
                BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file),"UTF-8"));
                //循环取出数据
                String str = null;
                StringBuffer sb = new StringBuffer();
                while ((str = in.readLine()) != null) {
                    sb.append(str);
                }
                List<OrderPosition> list = JSONArray.parseArray(sb.toString(), OrderPosition.class);
                orderInfoWarpper.setOrderPositionList(JSONObject.toJSONString(list));
            }else{
                orderInfoWarpper.setOrderPositionList("");
            }
 
            List<OrderLogisticsSpread> orderLogisticsId = spreadService.selectList(new EntityWrapper<OrderLogisticsSpread>().eq("orderLogisticsId", orderId));
            if (!orderLogisticsId.isEmpty()){
                double sum =  0;
                for (OrderLogisticsSpread orderLogisticsSpread : orderLogisticsId) {
 
                    if (orderLogisticsSpread.getPayType()!=null&&orderLogisticsSpread.getPayType() == 4) {
                        Double payMoney = orderLogisticsSpread.getPayMoney();
                        sum = sum + payMoney;
                    }
                }
                sum = sum+orderInfoWarpper.getPayMoney();
                orderInfoWarpper.setPayMoney(sum);
            }
 
 
            return ResultUtil.success(orderInfoWarpper);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    /**
     * 获取订单的改派金额
     * @param orderId
     * @param orderType
     * @return
     */
    @ResponseBody
    @PostMapping("/api/order/queryReassignMoney")
    @ApiOperation(value = "获取改派支付金额", tags = {"司机端-服务中"}, notes = "返回金额为0不需要调用支付")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "订单id(跨城多个订单使用逗号分隔)", name = "orderId", required = true, dataType = "string"),
            @ApiImplicitParam(value = "订单类型(1=专车,4=小件物流-同城)", name = "orderType", required = true, dataType = "int"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil<BaseWarpper> queryReassignMoney(String orderId, Integer orderType){
        try {
            String[] split = orderId.split(",");
            Double aDouble = orderService.queryReassignMoney(Integer.valueOf(split[0]), orderType);
            BaseWarpper baseWarpper = new BaseWarpper();
            if(orderType == 3){
                aDouble = aDouble * split.length;
            }
            baseWarpper.setAmount(aDouble);
            return ResultUtil.success(baseWarpper);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    /**
     * 司机提交改派申请
     * @param reassign
     * @param request
     * @return
     */
    @ResponseBody
    @PostMapping("/api/order/reassign")
    @ApiOperation(value = "提交改派申请", tags = {"司机端-服务中"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"),
            @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,4=小件物流-同城,5=小件物流-跨城)", name = "orderType", required = true, dataType = "int"),
            @ApiImplicitParam(value = "改派支付方式(1=微信,2=支付宝,3=余额)", name = "payType", required = false, dataType = "int"),
            @ApiImplicitParam(value = "改派原因", name = "reason", required = true, dataType = "string"),
            @ApiImplicitParam(value = "备注", name = "remark", required = false, dataType = "string"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil reassign(Reassign reassign, Integer language, HttpServletRequest request){
        try {
            Integer uid = driverService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            return reassignService.saveData(reassign, uid, null, language);
        }catch (SystemException s){
            return ResultUtil.error(s.getMsg());
        } catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    /**
     * 司机走流程操作
     * @param orderId
     * @param orderType
     * @param state
     * @param lon
     * @param lat
     * @param request
     * @return
     */
    @ResponseBody
    @PostMapping("/api/order/process")
    @ApiOperation(value = "司机走流程操作", tags = {"司机端-服务中"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"),
            @ApiImplicitParam(value = "订单类型(1=专车,4=小件物流-同城)", name = "orderType", required = true, dataType = "int"),
            @ApiImplicitParam(value = "流程操作状态(3=开始出发预约点,4=到达预约点,5=开始服务,6=服务结束)", name = "state", required = true, dataType = "int"),
            @ApiImplicitParam(value = "手机号后四位", name = "phone", required = false, dataType = "String"),
            @ApiImplicitParam(value = "当前经度", name = "lon", required = true, dataType = "double"),
            @ApiImplicitParam(value = "当前纬度", name = "lat", required = true, dataType = "double"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil process(Integer orderId, Integer orderType, Integer state, Double lon, Double lat,String phone, String pickUpCode, Integer language, HttpServletRequest request){
        try {
            Integer uid = driverService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            return orderService.process(orderId, orderType, state, uid, lon, lat, phone, pickUpCode, language);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
 
    /**
     * 司机抢单操作(车载端)
     * @param orderId
     * @param orderType
     * @param request
     * @return
     */
    @ResponseBody
    @PostMapping("/api/order/grabOrder_")
    @ApiOperation(value = "司机抢单操作", tags = {"司机端-车载端"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"),
            @ApiImplicitParam(value = "订单类型(2=出租车,4=小件物流-同城,5=小件物流-跨城)", name = "orderType", required = true, dataType = "int"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil grabOrder_(Integer orderId, Integer orderType, HttpServletRequest request){
        try {
            Integer uid = driverService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            return orderService.grabOrder_(orderId, orderType, uid);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
 
    /**
     * 司机确认费用
     * @param orderId
     * @param orderType
     * @param type
     * @param travelFee
     * @param parkingFee
     * @param crossingFee
     * @return
     */
    @ResponseBody
    @PostMapping("/api/order/confirmFees")
    @ApiOperation(value = "司机确认费用", tags = {"司机端-服务中"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"),
            @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=城际,4=同城小件物流)", name = "orderType", required = true, dataType = "int"),
            @ApiImplicitParam(value = "支付方式(1=OK平台收款,2=其他方式收款)", name = "type", required = true, dataType = "int"),
            @ApiImplicitParam(value = "行程费用(出租车必传)", name = "travelFee", required = false, dataType = "double"),
            @ApiImplicitParam(value = "停车费", name = "parkingFee", required = false, dataType = "double"),
            @ApiImplicitParam(value = "过路费", name = "crossingFee", required = false, dataType = "double"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil confirmFees(Integer language, Integer orderId, Integer orderType, Integer type, Double travelFee, Double parkingFee, Double crossingFee){
        try{
            return orderService.confirmFees(language, orderId, orderType, type, travelFee, parkingFee, crossingFee);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
 
    /**
     * 司机确认费用(车载端)
     * @param orderId
     * @param orderType
     * @param type
     * @param travelFee
     * @return
     */
    @ResponseBody
    @PostMapping("/api/order/confirmFees_")
    @ApiOperation(value = "司机确认费用(车载端)", tags = {"司机端-车载端"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"),
            @ApiImplicitParam(value = "订单类型(2=出租车)", name = "orderType", required = true, dataType = "int"),
            @ApiImplicitParam(value = "支付方式(1=OK平台收款)", name = "type", required = true, dataType = "int"),
            @ApiImplicitParam(value = "行程费用", name = "travelFee", required = false, dataType = "double"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil confirmFees_(Integer orderId, Integer orderType, Integer type, Double travelFee, Double lon, Double lat){
        try{
            return orderService.confirmFees_(orderId, orderType, type, travelFee, lon, lat);
        }catch (Exception e){
            e.printStackTrace();
            System.err.println(lon + "," + lat);
            return ResultUtil.runErr();
        }
    }
 
 
 
 
 
    /**
     * 获取待支付页详情
     * @param orderId
     * @param orderType
     * @return
     */
    @ResponseBody
    @PostMapping("/api/order/queryToBePaidPage")
    @ApiOperation(value = "获取待支付页详情", tags = {"司机端-服务中"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"),
            @ApiImplicitParam(value = "订单类型(1=专车,2=出租车)", name = "orderType", required = true, dataType = "int"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil<OrderInfoWarpper> queryToBePaidPage(Integer language, Integer orderId, Integer orderType){
        try {
            Map<String, Object> map = orderService.queryToBePaidPage(language, orderId, orderType);
            return ResultUtil.success(OrderInfoWarpper.getOrderInfoWarpper(map));
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    /**
     * 后台改派成功后的推送接口
     * @param orderId
     * @param orderType
     * @return
     */
    @ResponseBody
    @PostMapping("/base/order/pushOrderState")
    public String pushOrderState(Integer language, Integer orderId, Integer orderType){
        try {
            Map<String, Object> map = orderService.queryOrderInfo(language, orderId, orderType);
            //更新小号绑定关系
            orderService.RebindMidAxbBindSend(orderId, orderType);
 
            pushUtil.pushOrderReassign(Integer.valueOf(String.valueOf(map.get("driverId"))), 2,Integer.valueOf(String.valueOf(map.get("orderId"))), orderType);
 
            pushUtil.pushOrderReassign(Integer.valueOf(String.valueOf(map.get("userId"))), 1,Integer.valueOf(String.valueOf(map.get("orderId"))), orderType);
            pushUtil.pushOrderState(1, Integer.valueOf(String.valueOf(map.get("userId"))), Integer.valueOf(String.valueOf(map.get("orderId"))), orderType,
                    Integer.valueOf(String.valueOf(map.get("orderState"))));
            return JSON.toJSONString(ResultUtil.success());
        }catch (Exception e){
            e.printStackTrace();
            return JSON.toJSONString(ResultUtil.runErr());
        }
    }
 
 
 
 
    @ResponseBody
    @PostMapping("/base/order/reassign_")
    @ApiOperation(value = "提交改派申请", tags = {"司机端-服务中"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"),
            @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=城际,4=小件物流-同城,5=小件物流-跨城,6=包车)", name = "orderType", required = true, dataType = "int"),
            @ApiImplicitParam(value = "改派支付方式(1=微信,2=支付宝,3=余额)", name = "payType", required = false, dataType = "int"),
            @ApiImplicitParam(value = "改派原因", name = "reason", required = true, dataType = "string"),
            @ApiImplicitParam(value = "备注", name = "remark", required = false, dataType = "string"),
    })
    public String reassign_(Reassign reassign, Integer uid, Integer language){
        try {
            ResultUtil resultUtil = reassignService.saveData(reassign, uid, 3, language);
            return JSON.toJSONString(resultUtil);
        }catch (SystemException s){
            return JSON.toJSONString(ResultUtil.error(s.getMsg()));
        } catch (Exception e){
            e.printStackTrace();
            return JSON.toJSONString(ResultUtil.runErr());
        }
    }
 
 
    @ResponseBody
    @PostMapping("/base/order/test")
    public String test(String phoneA, String phoneB){
        try {
            Map<String, String> map = chinaMobileUtil.midAxbBindSend(phoneA, phoneB, 28);
            System.err.println(JSON.toJSONString(map));
        }catch (Exception e){
            e.printStackTrace();
            return "";
        }
        return null;
    }
 
    @ResponseBody
    @PostMapping("/base/order/test_")
    public String test(String bindId){
        try {
            Map<String, String> map = chinaMobileUtil.midAxbUnBindSend(bindId,"");
        }catch (Exception e){
            e.printStackTrace();
            return "";
        }
        return null;
    }
 
 
    /**
     * 司机确认费用(车载端)不管之前数据状态直接修改到待支付(流程断网情况的处理流程)
     * @param orderId
     * @param orderType
     * @param type
     * @param travelFee
     * @param lon
     * @param lat
     * @return
     */
    @ResponseBody
    @PostMapping("/api/order/confirmFees$")
    @ApiOperation(value = "司机确认费用(车载端)不管之前数据状态直接修改到已完成(流程断网情况的处理流程)", tags = {"司机端-车载端"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"),
            @ApiImplicitParam(value = "订单类型(2=出租车)", name = "orderType", required = true, dataType = "int"),
            @ApiImplicitParam(value = "支付方式(1=OK平台收款)", name = "type", required = true, dataType = "int"),
            @ApiImplicitParam(value = "行程费用", name = "travelFee", required = false, dataType = "double"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil confirmFees$(Integer orderId, Integer orderType, Integer type, Double travelFee, Double lon, Double lat){
        try{
            return orderService.confirmFees$(orderId, orderType, type, travelFee, lon, lat);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
    @ResponseBody
    @PostMapping("/api/order/queryVoiceBroadcast")
    @ApiOperation(value = "接单后获取语音播报内容", tags = {"司机端-首页"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"),
            @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=城际,4=小件物流-同城,5=小件物流-跨城)", name = "orderType", required = true, dataType = "int"),
            @ApiImplicitParam(value = "当前位置经度", name = "lon", required = true, dataType = "string"),
            @ApiImplicitParam(value = "当前位置纬度", name = "lat", required = true, dataType = "string"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil queryVoiceBroadcast(Integer orderId, Integer orderType, String lon, String lat){
        try {
            String s = orderService.queryVoiceBroadcast(orderId, orderType, lon, lat);
            return ResultUtil.success(s);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
 
 
    /**
     * 手动确认订单完成
     * @param orderId
     * @param orderType
     * @return
     */
    @ResponseBody
    @PostMapping("/api/order/completeOrder")
    @ApiOperation(value = "手动确认订单完成", tags = {"司机端-服务中"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"),
            @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,4=同城小件物流)", name = "orderType", required = true, dataType = "int"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil completeOrder(Integer orderId, Integer orderType, Integer language){
        try {
            return orderService.completeOrder(orderId, orderType, language);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
 
    @ResponseBody
    @PostMapping("/api/order/queryMoneyInfo")
    @ApiOperation(value = "获取订单费用明细【2.0】", tags = {"司机端-服务中"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"),
            @ApiImplicitParam(value = "订单类型(1=专车,4=同城小件物流)", name = "orderType", required = true, dataType = "int"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil<MoneyInfoWarpper> queryMoneyInfo(Integer orderId, Integer orderType){
        try {
            Map<String, Object> map = orderService.queryMoneyInfo(orderId, orderType);
            return ResultUtil.success(MoneyInfoWarpper.getMoneyInfoWarpper(map));
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
    
    @ResponseBody
    @PostMapping("/api/order/fillInPickUpCode")
    @ApiOperation(value = "验证小件物流取件码", tags = {"司机端-服务中"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"),
            @ApiImplicitParam(value = "取件码", name = "pickUpCode", required = true, dataType = "string"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil fillInPickUpCode(Integer orderId, String pickUpCode, Integer language){
        try {
            return orderLogisticsService.fillInPickUpCode(orderId, pickUpCode, language);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
    @ResponseBody
    @PostMapping("/api/order/makeUpTheDifference")
    @ApiOperation(value = "设置小件物流差价", tags = {"司机端-服务中"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"),
            @ApiImplicitParam(value = "差价金额", name = "difference", required = true, dataType = "double"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil makeUpTheDifference(Integer orderId, Double difference, Integer language){
        try {
            return orderLogisticsService.makeUpTheDifference(orderId, difference, language);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
    @ResponseBody
    @PostMapping("/api/order/sendVerificationCode")
    @ApiOperation(value = "小件物流发送收货码", tags = {"司机端-服务中"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil sendVerificationCode(Integer orderId, Integer language){
        try {
            orderLogisticsService.sendVerificationCode(orderId, language);
            return ResultUtil.success();
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
 
 
    @ResponseBody
    @PostMapping("/api/order/payOrder")
    @ApiOperation(value = "司机订单代付(现金收款)", tags = {"司机端-服务中"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"),
            @ApiImplicitParam(value = "订单类型", name = "orderType", required = true, dataType = "int"),
            @ApiImplicitParam(value = "支付方式(1=手机支付,2=银行卡支付,3=余额)", name = "payType", required = true, dataType = "int"),
            @ApiImplicitParam(value = "银行卡id", name = "bankCardId", required = false, dataType = "int"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil payOrder(Integer orderId, Integer orderType, Integer payType, Integer bankCardId, Integer language, HttpServletRequest request){
        try {
            Integer uid = driverService.getUserIdFormRedis(request);
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            return orderService.payOrder(uid, orderId, orderType, payType, bankCardId, language);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
 
 
 
    /**
     * 完成订单微信支付回调
     * @param
     */
    @ResponseBody
    @PostMapping("/base/wxPayOrderTaxi")
    public CallbackResponse wxPayOrderTaxi(@RequestBody CallbackRequest callbackRequest){
        CallbackResponse callbackResponse = new CallbackResponse();
        try {
            /**
             * 指示服务是否成功或付费的总体请求代码。。
             * 177-部分付费请求
             * 178-表明请求已全额支付
             * 179-表示请求已部分支付但已过期。
             * 129-请求已过期,未付款。
             * 180.商户拒绝请求
             * 183-商户接受请求,我们可以结算资金
             * 188-商户收到请求。
             */
            String request_status_code = callbackRequest.getRequest_status_code();
            String out_trade_no = callbackRequest.getMerchant_transaction_id();
            if("177".equals(request_status_code) || "178".equals(request_status_code)){
                Payments payments = callbackRequest.getPayments().get(0);
                String order_id = payments.getPayer_transaction_id();
                if(ToolUtil.isNotEmpty(out_trade_no)){
                    Integer orderType = Integer.valueOf(out_trade_no.substring(17, 18));
                    Integer language = Integer.valueOf(out_trade_no.substring(18, 19));
                    Integer id = Integer.valueOf(out_trade_no.substring(19));
                    switch (orderType){
                        case 1:
                            orderPrivateCarService.payOrderPrivateCarCallback(id, order_id, language);
                            break;
                        case 4:
                            orderLogisticsService.payOrderLogisticsCallback(id, order_id, language);
                            break;
                    }
                    callbackResponse.setCheckout_request_id(order_id);
                    callbackResponse.setMerchant_transaction_id(out_trade_no);
                    callbackResponse.setStatus_code("183");
                    callbackResponse.setStatus_description("Payment processed successfully");
                    callbackResponse.setReceipt_number(UUIDUtil.getRandomCode(16));
                }
            }else{
                callbackResponse.setCheckout_request_id(UUIDUtil.getRandomCode(16));
                callbackResponse.setMerchant_transaction_id(out_trade_no);
                callbackResponse.setStatus_code("180");
                callbackResponse.setStatus_description("means payment rejected.");
                callbackResponse.setReceipt_number(UUIDUtil.getRandomCode(16));
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return callbackResponse;
    }
    
    
    
    
    @ResponseBody
    @PostMapping("/api/taxi/updateEndAddress")
    @ApiOperation(value = "处理乘客修改目的地【2.0】", tags = {"用户端-专车", "用户端-小件物流"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"),
            @ApiImplicitParam(value = "订单类型", name = "orderType", required = true, dataType = "int"),
            @ApiImplicitParam(value = "状态(2=同意,3=拒绝)", name = "status", required = true, dataType = "int"),
            @ApiImplicitParam(value = "语言", name = "language", required = true, dataType = "int"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil updateEndAddress(Integer orderId, Integer orderType, Integer status){
        switch (orderType){
            case 1:
                orderPrivateCarService.updateEndAddress(orderId, status);
                break;
            case 4:
                orderLogisticsService.updateEndAddress(orderId, status);
                break;
        }
        return ResultUtil.success();
    }
}