lmw
2023-05-12 f67802a41f9e01444d1115f34ecc6e1beb05fc3b
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
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
package com.fuban.user.network
 
import cn.sinata.xldutils.data.ResultData
import cn.sinata.xldutils.utils.SPUtils
import com.google.gson.Gson
import com.google.gson.JsonObject
import com.fuban.user.network.entity.*
import com.fuban.user.network.entity.Function
import com.fuban.user.utils.Const
import io.reactivex.Flowable
 
object HttpManager {
    private const val PAGE_SIZE = 20
    /**
     * 发起请求方法
     */
    private fun request() =
        RRetrofit.instance().create(ApiService::class.java)
 
    private fun getAppId() = SPUtils.instance().getString(Const.User.APP_ID)
    /**
     * 获取h5
     * @param type 1:隐私协议,2:用户协议,3:用户指南,4:法律条款,5:关于我们
     */
    fun getH5(type:Int): Flowable<ResultData<JsonObject>> {
        return request().getH5(type)
    }
 
    /**
     * 获取首页电话
     * @param code 行政区域编号
     */
    fun getPhone(code: String): Flowable<ResultData<ArrayList<Phone>>> {
        return request().getPhone(code)
    }
 
    /**
     * 包车获取首页电话
     * @param code 行政区域编号
     */
    fun queryPhones(code: String): Flowable<ResultData<ArrayList<Phone>>> {
        return request().queryPhones(code)
    }
 
    /**
     * 获取首页轮播消息
     * @param type 1:轮播消息
     */
    fun queryNotices(type: Int): Flowable<ResultData<ArrayList<Message>>> {
        return request().queryNotices(type)
    }
 
    /**
     * 获取首页广告
     * @param type 1:弹窗广告,2:底部广告
     */
    fun getAds(type: Int,code: String): Flowable<ResultData<ArrayList<Message>>> {
        return request().getAds(type,code)
    }
 
    /**
     * 发送验证码
     * @param type 1=身份验证,2=登录确认,3=用户注册,4=修改密码
     */
    fun sendSms(phone: String,type: Int): Flowable<ResultData<JsonObject>> {
        return request().getCode(phone,type)
    }
    /**
     * 验证码登录
     */
    fun codeLogin(phone: String,code: String,area: String? = null,ip: String? = null): Flowable<ResultData<JsonObject>> {
        return request().codeLogin(phone,code,area,ip)
    }
 
    /**
     * 密码登录
     */
    fun pwdLogin(phone: String,code: String): Flowable<ResultData<JsonObject>> {
        return request().pwdLogin(phone,code)
    }
 
    /**
     * 微信登录
     */
    fun wxLogin(openid: String?, registAreaCode: String, unionid: String?, avatar: String?,nickName: String?,sex: Int?): Flowable<ResultData<JsonObject>> {
        return request().wxLogin(openid, registAreaCode, unionid,avatar,nickName, sex)
    }
 
    /**
     * 一键登录
     */
    fun oneClickLogin(token: String): Flowable<ResultData<JsonObject>> {
        return request().oneClickLogin(token)
    }
 
    /**
     * 微信登录绑定手机
     */
    fun bindingPhone(code:String,phone: String): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["code"] = code
        map["phone"] = phone
        map["loginType"] = "0"
        map["appid"] = getAppId()
        map["sign"] = SignUtil.getSign(map)
        return request().getBaseResponse(Apis.bindingPhone,map)
    }
 
    /**
     * 注销
     */
    fun unregister(): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["appid"] = getAppId()
        map["sign"] = SignUtil.getSign(map)
        return request().getBaseResponse(Apis.cancellation,map)
    }
 
    /**
     * 忘记密码
     */
    fun forgetPassword(code: String,password: String,phone: String): Flowable<ResultData<JsonObject>> {
        return request().forgetPassword(code, password, phone)
    }
 
    /**
     * 城市是否开通
     */
    fun isOpenCity(code:String): Flowable<ResultData<JsonObject>> {
        return request().isOpenCity(code)
    }
 
    /**
     * 定位城市功能
     */
    fun queryBusiness(city:String,province:String,district:String): Flowable<ResultData<ArrayList<Function>>> {
        return request().queryBusiness(city,district, province)
    }
 
    /**
     * 选择城市功能
     */
    fun queryBusinessById(id: Int): Flowable<ResultData<ArrayList<Function>>> {
        return request().queryBusinessById(id)
    }
 
    /**
     * 开通城市列表
     */
    fun queryOpenCity(): Flowable<ResultData<ArrayList<OpenCity>>> {
        return request().queryOpenCity()
    }
 
    /**
     * 附近司机数量
     * @param type:1=专车,2=出租车,3=城际,4=小件物流-同城,5=小件物流-跨城,6=包车
     */
    fun getDriverNum(lat:Double,lon:Double,type: Int): Flowable<ResultData<JsonObject>> {
        return request().getDriverNum(lat, lon, type)
    }
 
    /**
     * 查询价格和车型
     * @param type:1=专车,2=出租车,3=城际,4=小件物流-同城,5=小件物流-跨城,6=包车
     */
    fun queryServerCarModel(start:String,end:String,type: Int): Flowable<ResultData<ArrayList<CarPrice>>> {
        return request().queryServerCarModel(start, end, type)
    }
 
    /**
     * 出租车和专车下单
     * @param orderSource:1:APP下单,2:扫码下单
     * @param orderType:1=普通,2=预约
     * @param substitute:是否是代下单(0:否,1:是)
     * @param type:订单类型(1=普通订单,2=摆渡订单)
     * @param businessType:业务类型
     */
    fun addTaxiOrder(endAddress: String,endLat: Double,endLon:Double, orderSource:Int,orderType :Int,placementLat :Double,
                     placementLon:Double,startAddress :String,startLat:Double, startLon :Double,substitute :Int,tipMoney:Int,
                     travelTime:String,driverId:Int?, passengers:String?,passengersPhone:String?,serverCarModelId: Int? = 0,type: Int = 1,
                     businessType: Int = Const.OrderType.TYPE_TAXI): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["endAddress"] = endAddress
        map["endLat"] = endLat
        map["endLon"] = endLon
        map["orderSource"] = orderSource
        map["orderType"] = orderType
        map["placementLat"] = placementLat
        map["placementLon"] = placementLon
        map["startAddress"] = startAddress
        map["startLat"] = startLat
        map["startLon"] = startLon
        map["substitute"] = substitute
        map["tipMoney"] = tipMoney
        map["type"] = type
        map["travelTime"] = travelTime
        if (businessType == Const.OrderType.TYPE_SPECIAL&&serverCarModelId!=null) //专车要选车型
            map["serverCarModelId"] = serverCarModelId
        if (driverId!=null)
            map["driverId"] = driverId
        if (passengers!=null)
            map["passengers"] = passengers
        if (passengersPhone!=null)
            map["passengersPhone"] = passengersPhone
        map["appid"] = getAppId()
        map["sign"] = SignUtil.getSign(map)
        return request().getBaseResponse(if (businessType == Const.OrderType.TYPE_TAXI) Apis.addTaxiOrder else Apis.createOrder,map)
    }
 
    /**
     * 摆渡车下单
     * @param orderSource:1:APP下单,2:扫码下单
     */
    fun saveOrderFerry(endAddress: String,endLat: Double,endLon:Double, orderSource:Int,placementLat :Double,
                     placementLon:Double,startAddress :String,startLat:Double, startLon :Double,
                     travelTime:String, serverCarModelIds:String, crossCityOrderId:Int, place:Int): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["endAddress"] = endAddress
        map["endLat"] = endLat
        map["endLon"] = endLon
        map["orderSource"] = orderSource
        map["placementLat"] = placementLat
        map["placementLon"] = placementLon
        map["startAddress"] = startAddress
        map["startLat"] = startLat
        map["startLon"] = startLon
        map["travelTime"] = travelTime
        map["serverCarModelIds"] = serverCarModelIds
        map["crossCityOrderId"] = crossCityOrderId
        map["place"] = place
        map["appid"] = getAppId()
        map["sign"] = SignUtil.getSign(map)
        return request().getBaseResponse(Apis.saveOrderFerry,map)
    }
 
    /**
     * 获取行政区域三级联动数据
     */
    fun queryRegions(id:Int = 0): Flowable<ResultData<ArrayList<City>>> {
        return request().queryRegions(id)
    }
 
    /**
     * 获取物流单价
     */
    fun queryLogisticsUnitPrice(endAddress: String,startLonLat: String,type: Int): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["endAddress"] = endAddress
        map["startLonLat"] = startLonLat
        map["type"] = type
        map["appid"] = getAppId()
        return request().queryLogisticsUnitPrice(endAddress, startLonLat, type,SignUtil.getSign(map), getAppId())
    }
 
    /**
     * 获取物流单价
     */
    fun queryPayMoney(endAddress: String,startLonLat: String,num:Int,type: Int): Flowable<ResultData<JsonObject>> {
        return request().queryPayMoney(endAddress, startLonLat, num,type)
    }
 
    /**
     * 我的订单
     * @param type 订单类型(1=专车,2=出租车,3=直通车)
     */
    fun myOrderList(page:Int,type: Int,size:Int = PAGE_SIZE): Flowable<ResultData<ArrayList<Order>>> {
        val map = HashMap<String, Any>()
        map["pageNum"] = page
        map["size"] = size
        map["type"] = type
        map["appid"] = getAppId()
        return request().myOrderList(page,size, type,SignUtil.getSign(map), getAppId())
    }
 
    /**
     * 订单详情
     * @param type 订单类型(1=专车,2=出租车,3=城际,4=小件物流-同城,5=小件物流-跨城,6=包车)
     */
    fun queryOrderInfo(id:Int,type: Int): Flowable<ResultData<Order>> {
        val map = HashMap<String, Any>()
        map["orderId"] = id
        map["orderType"] = type
        map["appid"] = getAppId()
        return request().queryOrderInfo(id, type,SignUtil.getSign(map), getAppId())
    }
 
    /**
     * 取消费用
     */
    fun cancelMoney(id:Int,type: Int): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["id"] = id
        map["orderType"] = type
        map["appid"] = getAppId()
        map["sign"] = SignUtil.getSign(map)
        return request().getBaseResponse(Apis.cancelMoney,map)
    }
 
    /**
     * 继续等待
     * @param orderType 订单类型(1=专车,2=出租车,3=城际,4=小件物流-同城,5=小件物流-跨城,6=包车)
     */
    fun pushOrderTaxi(id:Int,orderType:Int): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["id"] = id
        map["orderType"] = orderType
        map["appid"] = getAppId()
        map["sign"] = SignUtil.getSign(map)
        return request().getBaseResponse(Apis.pushOrderTaxi,map)
    }
 
    /**
     * 取消订单
     * @param orderType 订单类型(1=专车,2=出租车,3=城际,4=小件物流-同城,5=小件物流-跨城,6=包车)
     */
    fun cancelOrder(id:Int, orderType:Int, reason:String?=null, remark:String?=null): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["id"] = id
        map["orderType"] = orderType
        if (reason!=null)
            map["reason"] = reason
        if (!remark.isNullOrEmpty())
            map["remark"] = remark
        map["appid"] = getAppId()
        map["sign"] = SignUtil.getSign(map)
        return request().getBaseResponse(Apis.cancelTaxi,map)
    }
 
    /**
     * 投诉司机
     */
    fun complaintService(driverId:Int,description:String,reason:String): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["driverId"] = driverId
        if (description.isNotEmpty())
            map["description"] = description
        map["reason"] = reason
        map["appid"] = getAppId()
        map["sign"] = SignUtil.getSign(map)
        return request().getBaseResponse(Apis.complaintService,map)
    }
 
    /**
     * 余额和优惠券数量
     */
    fun queryBalance(orderId:Int,orderType:Int): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["orderId"] = orderId
        map["orderType"] = orderType
        map["appid"] = getAppId()
        map["sign"] = SignUtil.getSign(map)
        return request().getBaseResponse(Apis.queryBalance,map)
    }
 
    /**
     * 行程中信息
     * @param orderType 订单类型(1=专车,2=出租车,3=城际,4=小件物流-同城,5=小件物流-跨城,6=包车)
     */
    fun trippingInfo(id:Int,orderType:Int): Flowable<ResultData<TrippingInfo>> {
        val map = HashMap<String, Any>()
        map["orderId"] = id
        map["orderType"] = orderType
        map["appid"] = getAppId()
        return request().trippingInfo(id,orderType,SignUtil.getSign(map),getAppId())
    }
 
    /**
     * 是否有司机接单
     * @param orderType 订单类型(1=专车,2=出租车,3=城际,4=小件物流-同城,5=小件物流-跨城,6=包车)
     */
    fun queryEndPush(id:Int,orderType:Int): Flowable<ResultData<Order>> {
        val map = HashMap<String, Any>()
        map["orderId"] = id
        map["orderType"] = orderType
        map["appid"] = getAppId()
        return request().queryEndPush(id,orderType,SignUtil.getSign(map),getAppId())
    }
 
    /**
     * 司机详情
     */
    fun queryDriverInfo(id:Int): Flowable<ResultData<DriverInfo>> {
        val map = HashMap<String, Any>()
        map["id"] = id
        map["appid"] = getAppId()
        return request().queryDriverInfo(id,SignUtil.getSign(map),getAppId())
    }
 
    /**
     * 司机详情
     */
    fun queryDriverEvaluate(id:Int,page: Int,size: Int = Const.PAGE_SIZE): Flowable<ResultData<ArrayList<Evaluation>>> {
        val map = HashMap<String, Any>()
        map["id"] = id
        map["pageNum"] = page
        map["size"] = size
        map["appid"] = getAppId()
        return request().queryDriverEvaluate(id,page,size,SignUtil.getSign(map),getAppId())
    }
 
    /**
     * 用户详情
     */
    fun queryUserInfo(): Flowable<ResultData<UserInfo>> {
        val map = HashMap<String, Any>()
        map["appid"] = getAppId()
        return request().queryUserInfo(SignUtil.getSign(map),getAppId())
    }
 
 
    /**
     * 修改用户详情
     */
    fun updateInfo(avatar:String?,birthday:String?,nickname:String?,sex:String?): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        if (avatar!=null)
            map["avatar"] = avatar
        if (birthday!=null)
            map["birthday"] = birthday
        if (nickname!=null)
            map["nickname"] = nickname
        if (sex!=null)
            map["sex"] = sex
        map["appid"] = getAppId()
        map["sign"] = SignUtil.getSign(map)
        return request().getBaseResponse(Apis.updateInfo,map)
    }
 
    /**
     * 行程支付
     * @param payType 1=微信,2=支付宝,3=余额
     */
    fun payTaxiOrder(id:Int,payType:Int,orderType:Int,couponId:Int?=null): Flowable<ResultData<OrderPayBean>> {
        val map = HashMap<String, Any>()
        map["orderId"] = id
        map["payType"] = payType
        map["type"] = 1
        map["orderType"] = orderType
        if (couponId!=null)
            map["couponId"] = couponId
        map["appid"] = getAppId()
        return request().payTaxiOrder(id,payType,1,orderType,couponId,SignUtil.getSign(map),getAppId())
    }
 
    /**
     * 小件物流补差价支付
     * @param payType 1=微信,2=支付宝,3=余额
     */
    fun payOrderLogisticsSpread(id:Int,payType:Int): Flowable<ResultData<OrderPayBean>> {
        val map = HashMap<String, Any>()
        map["orderId"] = id
        map["payType"] = payType
        map["type"] = 1
        map["appid"] = getAppId()
        return request().payOrderLogisticsSpread(id,payType,1,SignUtil.getSign(map),getAppId())
    }
 
    /**
     * 取消支付
     * @param payType 1=微信,2=支付宝,3=余额
     */
    fun cancleOrderTaxi(id:Int,payType:Int,cancleId:Int,orderType:Int): Flowable<ResultData<OrderPayBean>> {
        val map = HashMap<String, Any>()
        map["id"] = id
        map["payType"] = payType
        map["type"] = 1
        map["cancleId"] = cancleId
        map["orderType"] = orderType
        map["appid"] = getAppId()
        return request().cancleOrderTaxi(id,payType,1,orderType,cancleId,SignUtil.getSign(map),getAppId())
    }
 
    /**
     * 评价
     */
    fun orderEvaluate(orderId:Int,fraction:Int,orderType:Int,content:String): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["orderId"] = orderId
        map["fraction"] = fraction
        map["orderType"] = orderType
        map["content"] = content
        map["appid"] = getAppId()
        map["sign"] = SignUtil.getSign(map)
        return request().getBaseResponse(Apis.orderEvaluate,map)
    }
 
    /**
     * 评价后获取红包金额
     */
    fun queryRedMoney(orderId:Int,orderType:Int): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["orderId"] = orderId
        map["orderType"] = orderType
        map["appid"] = getAppId()
        map["sign"] = SignUtil.getSign(map)
        return request().getBaseResponse(Apis.queryRedMoney,map)
    }
 
    /**
     * 车载端线下支付
     */
    fun completeOrder(orderId:Int,orderType:Int): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["orderId"] = orderId
        map["orderType"] = orderType
        map["appid"] = getAppId()
        map["sign"] = SignUtil.getSign(map)
        return request().getBaseResponse(Apis.completeOrder,map)
    }
 
    /**
     * 查询进行中的订单
     */
    fun queryServingOrder(): Flowable<ResultData<ArrayList<Order>>> {
        val map = HashMap<String, Any>()
        map["appid"] = getAppId()
        return request().queryTripping(SignUtil.getSign(map),getAppId())
    }
 
    /**
     * 查询可用优惠券
     */
    fun queryCoupon(orderId: Int,orderType: Int,page: Int): Flowable<ResultData<ArrayList<Coupon>>> {
        val map = HashMap<String, Any>()
        map["orderId"] = orderId
        map["orderType"] = orderType
        map["pageNum"] = page
        map["size"] = PAGE_SIZE
        map["appid"] = getAppId()
        return request().queryCoupon(orderId,orderType,page, PAGE_SIZE,SignUtil.getSign(map),getAppId())
    }
 
    /**
     * 查询行程路径
     */
    fun queryTrack(orderId: Int,orderType: Int): Flowable<ResultData<ArrayList<Point>>> {
        val map = HashMap<String, Any>()
        map["orderId"] = orderId
        map["orderType"] = orderType
        map["appid"] = getAppId()
        return request().queryTrack(orderId,orderType,SignUtil.getSign(map),getAppId())
    }
 
    /**
     * 查询行程路径
     */
    fun querySite(orderId: Int,orderType: Int): Flowable<ResultData<ArrayList<Point>>> {
        val map = HashMap<String, Any>()
        map["orderId"] = orderId
        map["orderType"] = orderType
        map["appid"] = getAppId()
        return request().queryTrack(orderId,orderType,SignUtil.getSign(map),getAppId())
    }
 
    /**
     * 查询优惠券
     */
    fun queryMyCoupons(page: Int,state: Int): Flowable<ResultData<ArrayList<Coupon>>> {
        val map = HashMap<String, Any>()
        map["pageNum"] = page
        map["size"] = PAGE_SIZE
        map["state"] = state
        map["appid"] = getAppId()
        return request().queryMyCoupons(page,PAGE_SIZE,state,SignUtil.getSign(map),getAppId())
    }
 
    /**
     * 实名认证提交
     */
    fun realName(idcode:String,img1:String,img2:String,name:String): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["idcode"] = idcode
        map["img1"] = img1
        map["img2"] = img2
        map["name"] = name
        map["appid"] = getAppId()
        map["sign"] = SignUtil.getSign(map)
        return request().getBaseResponse(Apis.realName,map)
    }
 
    /**
     * 实名认证信息
     */
    fun queryRealName(): Flowable<ResultData<RealName>> {
        val map = HashMap<String, Any>()
        map["appid"] = getAppId()
        return request().queryRealName(SignUtil.getSign(map),getAppId())
    }
 
    /**
     * 删除优惠券
     */
    fun delMyCoupon(id:Int): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["id"] = id
        map["appid"] = getAppId()
        map["sign"] = SignUtil.getSign(map)
        return request().getBaseResponse(Apis.delMyCoupon,map)
    }
 
    /**
     * 赠送优惠券
     */
    fun giveCoupon(id:Int,userId:Int): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["id"] = id
        map["userId"] = userId
        map["appid"] = getAppId()
        map["sign"] = SignUtil.getSign(map)
        return request().getBaseResponse(Apis.giveCoupon,map)
    }
 
    /**
     * 设置紧急联系人
     */
    fun setEmergency(name:String,phone:String): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["name"] = name
        map["phone"] = phone
        map["appid"] = getAppId()
        map["sign"] = SignUtil.getSign(map)
        return request().getBaseResponse(Apis.setEmergency,map)
    }
 
    /**
     * 根据手机号查询用户信息(赠送优惠券)
     */
    fun queryUser(phone:String): Flowable<ResultData<UserInfo>> {
        val map = HashMap<String, Any>()
        map["phone"] = phone
        map["appid"] = getAppId()
        return request().queryUser(phone,SignUtil.getSign(map), getAppId())
    }
 
    /**
     * 消费记录、提现记录、红包使用记录、积分兑换记录
     */
    fun walletRecord(url:String,page: Int,size: Int = PAGE_SIZE): Flowable<ResultData<ArrayList<WalletRecord>>> {
        val map = HashMap<String, Any>()
        map["pageNum"] = page
        map["size"] = size
        map["appid"] = getAppId()
        return request().walletRecord(url,page,size,SignUtil.getSign(map), getAppId())
    }
 
    /**
     * 红包列表
     */
    fun queryMyRedEnvelope(page: Int,size: Int = PAGE_SIZE): Flowable<ResultData<ArrayList<WalletRecord>>> {
        val map = HashMap<String, Any>()
        map["pageNum"] = page
        map["size"] = size
        map["appid"] = getAppId()
        return request().queryRedEnvelope(page,size,SignUtil.getSign(map), getAppId())
    }
 
    /**
     * 提现申请
     */
    fun withdrawal(name:String,code:String,money:Double): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["name"] = name
        map["code"] = code
        map["money"] = money
        map["appid"] = getAppId()
        map["sign"] = SignUtil.getSign(map)
        return request().getBaseResponse(Apis.withdrawal,map)
    }
 
    /**
     * 反馈
     */
    fun feedback(content:String): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["content"] = content
        map["appid"] = getAppId()
        map["sign"] = SignUtil.getSign(map)
        return request().getBaseResponse(Apis.feedback,map)
    }
 
    /**
     * 留言
     */
    fun leaveMessage(content:String): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["content"] = content
        map["appid"] = getAppId()
        map["sign"] = SignUtil.getSign(map)
        return request().getBaseResponse(Apis.leaveMessage,map)
    }
 
    /**
     * 留言记录
     */
    fun queryProblems(page: Int,size: Int = PAGE_SIZE): Flowable<ResultData<ArrayList<ServiceRecord>>> {
        val map = HashMap<String, Any>()
        map["pageNum"] = page
        map["size"] = size
        map["appid"] = getAppId()
        return request().queryProblems(page,size,SignUtil.getSign(map), getAppId())
    }
 
 
    /**
     * 消息中心列表
     * @param type 1=公告,2=系统消息
     */
    fun msgNotice(type: Int,page: Int,size: Int = PAGE_SIZE): Flowable<ResultData<ArrayList<Message>>> {
        val map = HashMap<String, Any>()
        map["pageNum"] = page
        map["size"] = size
        map["type"] = type
        map["appid"] = getAppId()
        return request().msgNotice(page,size,type,SignUtil.getSign(map), getAppId())
    }
 
    /**
     * 客服电话
     */
    fun queryCustomerPhone(code:String): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["code"] = code
        map["appid"] = getAppId()
        map["sign"] = SignUtil.getSign(map)
        return request().getBaseResponse(Apis.queryCustomerPhone,map)
    }
 
    /**
     * 未读数量
     */
    fun queryUnReadNum(): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["appid"] = getAppId()
        map["sign"] = SignUtil.getSign(map)
        return request().getBaseResponse(Apis.queryUnReadNum,map)
    }
 
    /**
     * 验证短信
     */
    fun checkCode(code:String,phone: String): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["code"] = code
        map["phone"] = phone
        map["appid"] = getAppId()
        map["sign"] = SignUtil.getSign(map)
        return request().getBaseResponse(Apis.checkCaptcha,map)
    }
 
    /**
     * 修改密码
     */
    fun updatePassword(password:String): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["password"] = password
        map["appid"] = getAppId()
        map["sign"] = SignUtil.getSign(map)
        return request().getBaseResponse(Apis.updatePassword,map)
    }
 
    /**
     * 修改手机号
     */
    fun updatePhone(code:String,phone: String): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["code"] = code
        map["phone"] = phone
        map["appid"] = getAppId()
        map["sign"] = SignUtil.getSign(map)
        return request().getBaseResponse(Apis.updatePhone,map)
    }
 
    /**
     * 清空消息
     */
    fun clearSystemNotice(): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["appid"] = getAppId()
        map["sign"] = SignUtil.getSign(map)
        return request().getBaseResponse(Apis.clearSystemNotice,map)
    }
 
    /**
     * 删除消息
     */
    fun delSystemNotice(id:Int): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["id"] = id
        map["appid"] = getAppId()
        map["sign"] = SignUtil.getSign(map)
        return request().getBaseResponse(Apis.delSystemNotice,map)
    }
 
    /**
     * 阅读消息
     */
    fun readSystemNotice(id:Int): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["id"] = id
        map["appid"] = getAppId()
        map["sign"] = SignUtil.getSign(map)
        return request().getBaseResponse(Apis.readSystemNotice,map)
    }
 
    /**
     * 分享得红包
     */
    fun shareRedEnvelope(id:Int,type: Int): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["orderId"] = id
        map["orderType"] = type
        map["appid"] = getAppId()
        map["sign"] = SignUtil.getSign(map)
        return request().getBaseResponse(Apis.shareRedEnvelope,map)
    }
 
    /**
     * 余额充值
     * @param payType 1=微信,2=支付宝
     * @param type 1=用户APP端
     */
    fun depositBalance(payType:Int,money:Double,type:Int = 1): Flowable<ResultData<OrderPayBean>> {
        val map = HashMap<String, Any>()
        map["payType"] = payType
        map["money"] = money
        map["type"] = type
        map["appid"] = getAppId()
        return request().depositBalance(money,payType,type,SignUtil.getSign(map), getAppId())
    }
 
    /**
     * 检查版本
     */
    fun queryNewData(): Flowable<ResultData<VersionData>> {
        return request().queryNewData()
    }
 
    /**
     * 起终点站点
     */
    fun querySite(startId:Int? = null): Flowable<ResultData<ArrayList<City>>> {
        return request().querySite(startId)
    }
 
    /**
     * 线路搜索
     */
    fun queryLines(startId:Int,endId:Int): Flowable<ResultData<ArrayList<Line>>> {
        return request().queryLines(startId,endId)
    }
 
    /**
     * 班次搜索
     */
    fun queryDriver(day:String,lineId:Int,driverId:Int? = null): Flowable<ResultData<ArrayList<Shift>>> {
        return request().queryDriver(day,lineId,driverId)
    }
 
    /**
     * 搜索座位
     */
    fun querySeat(id: Int): Flowable<ResultData<SeatInfo>> {
        return request().querySeat(id)
    }
 
    /**
     * 站点范围
     */
    fun queryLocation(id: Int): Flowable<ResultData<ArrayList<Anchor>>> {
        return request().queryLocation(id)
    }
 
    /**
     * 站点是否在范围内
     * */
    fun areaMonitoring(id: Int,code: String,lonLat:String): Flowable<ResultData<Int>> {
        return request().areaMonitoring(id,code, lonLat)
    }
 
    /**
     * 查询预估价格
     */
    fun queryOrderMoney(lineId:Int,startLonLat:String,endLonLat:String,peopleNumber:Int, seatNumber:String, travelMode:Int,
                        serverCarModelId:Int, totalSeat:Int): Flowable<ResultData<JsonObject>> {
        return request().queryOrderMoney(lineId, startLonLat, endLonLat, peopleNumber, seatNumber, travelMode, serverCarModelId, totalSeat)
    }
 
    /**
     * 跨城下单
     * @param orderSource 订单来源(1:APP下单,2:扫码下单,3:小程序下单,4:司机下单,5:调度下单)
     * @param travelMode 出行方式(1=拼车,2=包车)
     */
    fun orderCrossCity(carId:Int,lineId:Int,lineShiftDriverId:Int,driverId:Int,distance:Double, orderSource:Int,
                       startLat:Double, startLon:Double,endLat:Double,endLon:Double,travelTime:String,placementLat:Double,
                       placementLon:Double,startAddress:String,endAddress:String,placementAddress:String,
                       remark:String?,peopleNumber:Int,seatNumber:String,frequentPassengersId :String,travelMode:Int,serverCarModelId:Int,totalSeat:Int): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["carId"] = carId
        map["lineId"] = lineId
        map["lineShiftDriverId"] = lineShiftDriverId
        map["driverId"] = driverId
        map["distance"] = distance
        map["orderSource"] = orderSource
        map["startLat"] = startLat
        map["startLon"] = startLon
        map["endLat"] = endLat
        map["endLon"] = endLon
        map["travelTime"] = travelTime
        map["placementLat"] = placementLat
        map["placementLon"] = placementLon
        map["startAddress"] = startAddress
        map["endAddress"] = endAddress
        map["placementAddress"] = placementAddress
        if (!remark.isNullOrEmpty())
            map["remark"] = remark
        map["peopleNumber"] = peopleNumber
        map["seatNumber"] = seatNumber
        val intList = arrayListOf<Int>()
        intList.addAll(frequentPassengersId.split(",").map { it.toInt() })
        val toJson = Gson().toJson(intList)
        map["frequentPassengersId"] = toJson
        map["travelMode"] = travelMode
        map["serverCarModelId"] = serverCarModelId
        map["totalSeat"] = totalSeat
        map["appid"] = getAppId()
        return request().orderCrossCity(carId,lineId,lineShiftDriverId,driverId,distance, orderSource,
            startLat, startLon,endLat,endLon,travelTime,placementLat,
            placementLon,startAddress,endAddress,placementAddress,
            remark,peopleNumber,seatNumber,toJson,travelMode,serverCarModelId,totalSeat,SignUtil.getSign(map), getAppId())
    }
 
    /**
     * 查询包车车型
     */
    fun queryServerCarModels(): Flowable<ResultData<ArrayList<CarPrice>>> {
        return request().queryServerCarModels()
    }
 
    /**
     * 包车下单
     */
    fun orderCharteredCar(carTime:Int, travelTime:String,  placeLonLat:String,contactPerson:String, contactPhone:String,
                         modelUse:String, peopleNumber:Int, serverCarModelId:Int): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["carTime"] = carTime
        map["travelTime"] = travelTime
        map["placeLonLat"] = placeLonLat
        map["contactPerson"] = contactPerson
        map["contactPhone"] = contactPhone
        map["peopleNumber"] = peopleNumber
        map["modelUse"] = modelUse
        map["serverCarModelId"] = serverCarModelId
        map["appid"] = getAppId()
        return request().orderCharteredCar(carTime,travelTime,placeLonLat,contactPerson,contactPhone,modelUse,peopleNumber,
            serverCarModelId,SignUtil.getSign(map), getAppId())
    }
 
    /**
     * 物流订单数量
     */
    fun queryLogisticsNumber(): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["appid"] = getAppId()
        map["sign"] = SignUtil.getSign(map)
        return request().getBaseResponse(Apis.queryLogisticsNumber,map)
    }
 
    /**
     * 物流下单
     */
    fun smallLogistics(cargoNumber:Int,cargoType:Int,endAddress:String,placementLat:Double,placementLon:Double,recipient:String,
                       recipientPhone:String,remark:String,startAddress:String,startLat:Double,startLon:Double,tipMoney:Int,
                       travelTime:String,type:Int,urgent:Int, orderSource:Int=1): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["cargoNumber"] = cargoNumber
        map["cargoType"] = cargoType
        map["endAddress"] = endAddress
        map["placementLat"] = placementLat
        map["placementLon"] = placementLon
        map["recipient"] = recipient
        map["recipientPhone"] = recipientPhone
        if (remark.isNotEmpty())
            map["remark"] = remark
        map["startAddress"] = startAddress
        map["startLat"] = startLat
        map["startLon"] = startLon
        map["tipMoney"] = tipMoney
        map["travelTime"] = travelTime
        map["type"] = type
        map["urgent"] = urgent
        map["orderSource"] = orderSource
        map["appid"] = getAppId()
        map["sign"] = SignUtil.getSign(map)
        return request().getBaseResponse(Apis.smallLogistics,map)
    }
 
    /**
     * 根据起点和终点坐标判断是不是同一个市内
     */
    fun judgingTheCity(endAddress:String,startLonLat:String): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["endAddress"] = endAddress
        map["startLonLat"] = startLonLat
        return request().getBaseResponse(Apis.judgingTheCity,map)
    }
 
    /**
     * 积分礼物列表
     */
    fun queryGoods(page:Int,size: Int = Const.PAGE_SIZE): Flowable<ResultData<ArrayList<Goods>>> {
        val map = HashMap<String, Any>()
        map["pageNum"] = page
        map["size"] = size
        map["appid"] = getAppId()
        return request().queryGoods(page,size,SignUtil.getSign(map), getAppId())
    }
 
    /**
     * 礼物详情
     */
    fun queryGoodsInfo(id:Int): Flowable<ResultData<Goods>> {
        val map = HashMap<String, Any>()
        map["id"] = id
        map["appid"] = getAppId()
        return request().queryGoodsInfo(id,SignUtil.getSign(map), getAppId())
    }
 
    /**
     * 积分兑换
     */
    fun addIntegralOrder(consigneeAddress:String,  consigneeName:String,consigneePhone:String, goodsId:Int,
                         remark:String): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["consigneeAddress"] = consigneeAddress
        map["consigneeName"] = consigneeName
        map["consigneePhone"] = consigneePhone
        map["goodsId"] = goodsId
        if (remark.isNotEmpty())
            map["remark"] = remark
        map["appid"] = getAppId()
        map["sign"] = SignUtil.getSign(map)
        return request().getBaseResponse(Apis.addIntegralOrder,map)
    }
 
    /**
     * 常用乘车人
     */
    fun queryFrequentPassengersList(): Flowable<ResultData<List<Passenger>>> {
        return request().queryFrequentPassengersList()
    }
 
    /**
     * 添加/编辑 常用乘车人
     */
    fun saveFrequentPassengers(idcode:String,name:String,phone:String,sex:Int,id:Int?=null): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["idcode"] = idcode
        map["name"] = name
        map["phone"] = phone
        map["sex"] = sex
        if (id!=null)
            map["id"] = id
        map["appid"] = getAppId()
        map["sign"] = SignUtil.getSign(map)
        return request().getBaseResponse(Apis.saveFrequentPassengers,map)
    }
 
    /**
     * 删除
     */
    fun delFrequentPassengers(id:Int): Flowable<ResultData<JsonObject>> {
        val map = HashMap<String, Any>()
        map["id"] = id
        map["appid"] = getAppId()
        map["sign"] = SignUtil.getSign(map)
        return request().getBaseResponse(Apis.delFrequentPassengers,map)
    }
}