【调度系统】广东民航医疗快线调度系统源代码
wanglizhong
2025-06-24 a51d070d364b0da8e5f8ea9203a6e50c8b4c0af3
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
<% @LANGUAGE="VBSCRIPT" CODEPAGE="65001" %> 
<% Session.CodePage=65001 %> 
<% Response.charset = "utf-8" %>
<!--#include virtual="/v3/inc/odbc.asp"-->
<!--#include virtual="/v3/inc/function.asp"-->
<!--#include virtual="/v3/inc/core.asp"-->
<script language="JScript" runat="Server"> 
function toObject(json) { 
    eval("var o=" + json); 
    return o; 
function toArray(s){
    var dic = Server.CreateObject("Scripting.Dictionary")
    eval("var a=" + json);
    for(var i=0;i<a.length;i++){
        var obj = Server.CreateObject("Scripting.Dictionary")
        for(x in a[i]) obj.Add(x,a[i][x])
        dic.Add(i, obj);
    }
    return dic
}
</script> 
 
<script language="jscript" runat="server">
Array.prototype.get = function(i)
{
 return this[i]; 
};
function getjson(str){
 try{
  eval("var jsonStr = (" + str + ")");
 }catch(ex){
  var jsonStr = null;
 }
 return jsonStr;
}
</script>
<%
Set rs = Server.CreateObject("ADODB.Recordset")
Set rsDt = Server.CreateObject("ADODB.Recordset")
method="OrderPrice"
V                = trim(request("V"))                '公式版本
If V="" Then V="1.0"
 
UserID            = trim(request("UserID"))        '用户ID
ServiceOrdID    = trim(request("ServiceOrdID"))        '服务单号
StartAddress    = trim(request("StartAddress"))        '出发地地址(支持坐标)
Address            = trim(request("Address"))        '出发地地址简写
ViaAddress        = trim(request("ViaAddress"))        '转出地址(不使用)
EndAddress        = trim(request("EndAddress"))        '目的地址
ServiceBranch    = trim(request("ServiceBranch"))    '所属地区/分公司
ServiceOrdApptDate= trim(request("ApptDate"))    '预约时间
 
TraDistance    = trim(request("TraDistance"))        '任务单程公里数
IsLifting        = trim(request("IsLifting"))        '是否抬楼机
LiftingInt        = trim(request("LiftingInt"))        '抬楼层数:默认0
WaitingInt        = trim(request("WaitingInt"))        '等待时长:默认0
 
Isluxury        = trim(request("Isluxury"))            '是否使用豪华车:默认0
If Isluxury="" Then Isluxury="0"
IsRoundtrip        = trim(request("IsRoundtrip"))        '是否往返:默认0
If IsRoundtrip="" Then IsRoundtrip="0"
 
IsCoupon        = trim(request("IsCoupon"))            '是否使用优惠券/次数卡:默认哪个优惠优先使用哪个
If IsCoupon="" Then IsCoupon="-1"
 
'NursingLevel    = trim(request("NursingLevel"))        '医护护理级别
'IsVentilato        = trim(request("IsVentilato"))        '是否使用呼吸机
'IsWarmBox        = trim(request("IsWarmBox"))        '是否使用温箱
 
 
 
'ICUInt            = trim(request("ICUInt"))            '居家ICU服务时长:默认0
 
IRid            = trim(request("IRid"))                '方案ID
StartProvince    = trim(request("StartProvince"))
StartCity        = trim(request("StartCity"))
StartArea        = trim(request("StartArea"))
U_UnitShort        = trim(request("U_UnitShort"))
U_TraDistance    = trim(request("U_TraDistance"))
AgeGroup    = trim(request("AgeGroup"))    '病人年龄段(1成年人 (12岁以上),2儿童(0-3岁(含3岁)),3儿童(3-6岁(含6岁)),4儿童(6-12岁),5新生儿 (出生至28天以内))
If U_TraDistance="" Then U_TraDistance=0
 
IRState="IRState"    '方案状态
 
If V="0.1" Then
    IRState="IRwxState"
ElseIf V="2.0" Then
    IRState="IRwxState"
End If
 
If Not IsNumeric(UserID) Then UserID=""
If ServiceOrdID="undefined" Then ServiceOrdID=""
If TraDistance="" Or Not IsNumeric(TraDistance) Then TraDistance=0
If NursingLevel="" Or Not IsNumeric(NursingLevel) Then NursingLevel=0
If IsVentilato="" Or Not IsNumeric(IsVentilato) Then IsVentilato=0
If IsWarmBox="" Or Not IsNumeric(IsWarmBox) Then IsWarmBox=0
If IsFerry="" Or Not IsNumeric(IsFerry) Then IsFerry=0
If LiftingInt="" Or Not IsNumeric(LiftingInt) Then LiftingInt=0
If WaitingInt="" Or Not IsNumeric(WaitingInt) Then WaitingInt=0
If ICUInt="" Or Not IsNumeric(ICUInt) Then ICUInt=0
If IRid="" Or Not IsNumeric(IRid) Then IRid=0
If IsLifting="" Or Not IsNumeric(IsLifting) Then IsLifting=0
TraDistance=CLng(TraDistance)
'LiftingInt=CLng(LiftingInt)-1
 
If ServiceBranch="" Then ServiceBranch="GZ"
errcode=0
OrderPrice=0
StartAddress_lat=0
StartAddress_lng=0
EndAddress_lat=0
EndAddress_lng=0
 
If ServiceOrdID<>""  Then
    sql="select ServiceOrdUserID,ServiceOrdClass,ServiceOrdTraStreet,ServiceOrdTraVia,ServiceOrdTraEnd,ServiceOrdUnitRemarks,ServiceOrdApptDate,ServiceOrdTraStreetCoo,ServiceOrdTraEndCoo from ServiceOrder where ServiceOrdID="&ServiceOrdID
    rs.open Sql,objConn,1,1
    If not rs.Eof Then
        UserID=rs("ServiceOrdUserID")
        ServiceBranch    = rs("ServiceOrdClass")
        StartAddress    = trim(rs("ServiceOrdTraStreet"))
        StartAddressTXT=trim(rs("ServiceOrdTraStreet"))
        If trim(rs("ServiceOrdTraStreetCoo"))<>"" Then StartAddress=ServiceOrdTraStreetCoo
        EndAddress        = trim(rs("ServiceOrdTraEnd"))
        EndAddressTXT=trim(rs("ServiceOrdTraStreet"))
        If trim(rs("ServiceOrdTraEndCoo"))<>"" Then EndAddress=ServiceOrdTraEndCoo
 
        ServiceOrdUnitRemarks = trim(rs("ServiceOrdUnitRemarks"))
        ServiceOrdApptDate=rs("ServiceOrdApptDate")
    End If
    rs.close()
Else
    StartAddressTXT    = StartAddress
    EndAddressTXT    = EndAddress
End If
 
 
 
If StartAddress="" Then
    errcode=40020
    errmsg="invalid StartAddress"
ElseIf EndAddress="" Then
    errcode=40021
    errmsg="invalid EndAddress"
End If
 
If TraDistance=0 or StartProvince="" Then
    '出发地坐标
    If InStr(StartAddress,",")>1 And errcode=0 Then
        StartAddressSP=SPLIT(StartAddress,",")
        If UBOUND(StartAddressSP)=1 Then
            If IsNumeric(StartAddressSP(0)) And IsNumeric(StartAddressSP(1)) Then
                StartAddress_lat=StartAddressSP(0)
                StartAddress_lng=StartAddressSP(1)
            End If
        End If
    End If
    
    If StartAddress_lat=0 And errcode=0 Then
        appUrl="https://api.map.baidu.com/geocoding/v3/"
        args1="address="&StartAddress&"&output=json&ak=rGQBbHKGjAtVQy23OckafQkC6nNlaGmi"
        HTMLCODE= GetBody(appUrl,args1)
        'Response.Write HTMLCODE
        'Response.End
        json    = HTMLCODE
        str=json
        set obj = getjson(str)
        status        = obj.status
        If status=0 Then
            StartAddress_lat        = obj.result.location.lat
            StartAddress_lng        = obj.result.location.lng
            'OrderPriceTXT="出发:"&StartAddress_lng&","&StartAddress_lat
            OrderPriceTXT=StartAddressTXT
        End if
    End If
 
    '目的地坐标
    If InStr(EndAddress,",")>1 And errcode=0 Then
        EndAddressSP=SPLIT(EndAddress,",")
        If UBOUND(EndAddressSP)=1 Then
            If IsNumeric(EndAddressSP(0)) And IsNumeric(EndAddressSP(1)) Then
                EndAddress_lat=EndAddressSP(0)
                EndAddress_lng=EndAddressSP(1)
            End If
        End If
    End If
    If EndAddress_lat=0 And errcode=0 Then
        appUrl="https://api.map.baidu.com/geocoding/v3/"
        args1="address="&EndAddress&"&output=json&ak=rGQBbHKGjAtVQy23OckafQkC6nNlaGmi"
        HTMLCODE= GetBody(appUrl,args1)
        'Response.Write HTMLCODE
        'Response.End
        json    = HTMLCODE
        str=json
        set obj = getjson(str)
        status        = obj.status
        If status=0 Then
            EndAddress_lat        = obj.result.location.lat
            EndAddress_lng        = obj.result.location.lng
        End If
    End If
    'OrderPriceTXT=OrderPriceTXT&" 目的:"&EndAddress_lng&","&EndAddress_lat
    OrderPriceTXT=OrderPriceTXT&"至"&EndAddressTXT
End If
 
If (StartAddress_lat<>0 And EndAddress_lat<>0) And errcode=0 Then
    '实时距离
    
    '计算所属地区(按出发地计算)
    Region_lat=StartAddress_lat
    Region_lng=StartAddress_lng
 
            
    '地区报价方案
    appUrl="https://api.map.baidu.com/reverse_geocoding/v3/"
    args1="location="&Region_lat&","&Region_lng&"&output=json&latest_admin=1&ak=rGQBbHKGjAtVQy23OckafQkC6nNlaGmi"
    HTMLCODE= GetBody(appUrl,args1)
    json    = HTMLCODE
    'Response.Write HTMLCODE
    str=json
    set obj = getjson(str)
    status        = obj.status
    If status=0 Then
        StartProvince    = obj.result.addressComponent.province
        StartCity    = obj.result.addressComponent.city
        StartArea    = obj.result.addressComponent.district
    End If
 
    If TraDistance=0 Then
        '路线规划距离(公里)
        appUrl="https://api.map.baidu.com/directionlite/v1/driving"
        args1="origin="&StartAddress_lat&","&StartAddress_lng&"&destination="&EndAddress_lat&","&EndAddress_lng&"&coord_type=wgs84&ak=rGQBbHKGjAtVQy23OckafQkC6nNlaGmi"
        HTMLCODE= GetBody(appUrl,args1)
        json    = HTMLCODE
        
        str=json
        set obj = getjson(str)
        status        = obj.status
        If status=0 Then
            str=json
            str=right(str,len(str)-instr(str,"[")+1)
            str=left(str,InstrRev(str,"]"))
            set obj = getjson(str)
            for i=0 to obj.length-1
                TraDistance        = obj.get(i).distance            '行程距离(米)
            Next
        End If
        If TraDistance>1000 And IsNumeric(TraDistance) Then
            TraDistance=CInt(TraDistance/1000)
        ElseIf TraDistance>0 And IsNumeric(TraDistance) Then
            TraDistance=1
        End If
        If IsRoundtrip="1" Then
            TraDistance=TraDistance*2
        End If
        OrderPriceTXT=OrderPriceTXT&" 预计距离:"&TraDistance&"公里 "
    End If
Else
    '缓存距离
    OrderPriceTXT=OrderPriceTXT&" 预计距离:"&TraDistance&"公里 "
    If U_TraDistance<>"" And U_TraDistance<>"0" Then OrderPriceTXT="出发机构:"&U_UnitShort&" "&U_TraDistance&"公里 "&OrderPriceTXT
End If
 
    
If TraDistance>0 Then
    '费用计算
    IRPrice=0
    OrderPrice=0
    IsOrdinary="0"    '是否有普通车可选 0没有,1有
    If errcode=0 Then
        '地址屏蔽黑名单
 
        If StartProvince<>"" And StartCity<>"" And StartArea<>"" And IRid=0 And 1=2 Then
            sql="select IRid,IRNursingLevel from IntroducerRegion where "&IRState&"=1 and (IRProvince='"&StartProvince&"' and IRCity='"&StartCity&"' and IRArea='"&StartArea&"' and IRkeyword='') and IRPrice>0 order by IRUnitID desc,IRNursingLevel desc"
            rs.open sql,objConn,1,1
            do while not rs.Eof
                IRid            = rs("IRid")            '报价方案ID
                IRNursingLevel    = rs("IRNursingLevel")    '医护护理级别
                If CLng(IRNursingLevel)=CLng(NursingLevel) Then exit do
            rs.movenext
            loop
            rs.close()
        End If
        If IRid=0 Then    '默认方案1
            IRid=1
        End If
        If IRid<>0 Then
            '手动报价
            If InStr(Address,"白云机场")>0 Or InStr(Address,"白云国际机场")>0 Then
                IRPrice=489
                IRlimit1=5
                IRDtPrice=6    
            ElseIf InStr(Address,"广州南站")>0 Then
                IRPrice=389
                IRlimit1=5
                IRDtPrice=6
            ElseIf InStr(Address,"广州白云站")>0 Then
                IRPrice=389
                IRlimit1=5
                IRDtPrice=6
            ElseIf InStr(Address,"广州东站")>0 Then
                IRPrice=359
                IRlimit1=5
                IRDtPrice=6
            'ElseIf StartArea="白云区" Then
            '    IRPrice=99
            '    IRlimit1=5
            '    IRDtPrice=6
            elseIf StartArea="越秀区" Or StartArea="荔湾区" Or StartArea="海珠区" Or StartArea="天河区"  Or StartArea="黄埔区"  Or StartArea="白云区" Then
                IRPrice=169
                IRlimit1=5
                IRDtPrice=6
            elseif StartArea="番禺区" Then
                IRPrice=219
                IRlimit1=5
                IRDtPrice=6
            ElseIf StartArea="花都区" Then
                IRPrice=169
                IRlimit1=5
                IRDtPrice=6
            ElseIf StartArea="增城区" And  Isluxury="0" Then
                IRPrice=99
                IRlimit1=5
                IRDtPrice=6
                IsOrdinary="1"
            Elseif StartArea="增城区" And  Isluxury="1" Then
                IRPrice=99
                IRlimit1=5
                IRDtPrice=6
                IsOrdinary="1"
            ElseIf StartArea="从化区" Then
                IRPrice=359
                IRlimit1=5
                IRDtPrice=6
            ElseIf StartArea="南沙区" And Isluxury="0" Then
                IRPrice=99
                IRlimit1=5
                IRDtPrice=6
                IsOrdinary="1"
            ElseIf StartArea="南沙区" And Isluxury="1" Then
                IRPrice=359
                IRlimit1=5
                IRDtPrice=6
                IsOrdinary="1"
            Else
                IRPrice=359
                IRlimit1=5
                IRDtPrice=6
            End If
        End If
        addressComponent=StartProvince
        If StartCity<>"" Then addressComponent=addressComponent&"-"&StartCity
        If StartArea<>"" Then addressComponent=addressComponent&"-"&StartArea
        If IsRoundtrip="1" Then
            IRlimit1=IRlimit1*2
        End If
        
        '计算报价
        OrderPriceFRM=""
        'OrderPriceTXT=""
        If IRPrice>0 And TraDistance>0 Then
            '基础报价
            'If IsCoupon="2" Then IRPrice=0    '使用次数卡减免起步费
            OrderPrice=OrderPrice+IRPrice    '起步价
            OrderPriceFRM = OrderPriceFRM & IRPrice
            OrderPriceTXT = OrderPriceTXT&"起步价("&IRlimit1&"公里内):"&IRPrice&"元\n"
 
            If TraDistance>IRlimit1 then
                IRDtDistance=TraDistance-IRlimit1
                'If IRDtDistance<IRDtlimit2 Then IRDtDistance=IRDtlimit2
                OrderPrice=OrderPrice+IRDtDistance*IRDtPrice
                OrderPriceFRM = OrderPriceFRM & "+"&IRDtDistance&"*"&IRDtPrice
                OrderPriceTXT = OrderPriceTXT&IRlimit1&"公里以上:"&IRDtPrice&"元/公里\n"
            End If
 
            '服务报价
            If CLng(IsLifting)=1 Then    '是否要电动爬楼机
                IRIsLiftingCost=69        '爬楼机基本费用
                IRLiftingIntCost=10    '3楼以上每层费用
                If CLng(LiftingInt)>=3 Then
                    IRIsLiftingCost=IRIsLiftingCost+(CLng(LiftingInt)-2)*IRLiftingIntCost
                End If
                OrderPrice=OrderPrice+IRIsLiftingCost
                OrderPriceFRM = OrderPriceFRM & "+"&IRIsLiftingCost
                OrderPriceTXT = OrderPriceTXT&"电动爬楼机费用:"&IRIsLiftingCost&"元\n"
            End If
            If round(WaitingInt,1)>0 Then    '等待费用(10分钟)
                IRWaitingCost=10
                OrderPrice=OrderPrice+WaitingIn*IRWaitingCost
                OrderPriceFRM = OrderPriceFRM & "+"&WaitingInt&"*"&IRWaitingCost
                OrderPriceTXT = OrderPriceTXT&"等待费用:"&WaitingInt*IRWaitingCost&"元\n"
            End If
            If ServiceOrdApptDate<>"" Then    '非工作时间服务费用20250624,周一~周五晚上22点后至早上7点整前为1.3倍
                sql="select SpecialRatio from SpecialDates where SpecialDates='"&formatdatetime(ServiceOrdApptDate,2)&"'"
                rs.open sql,objConn,1,1
                if not rs.Eof Then
                    SpecialRatio=rs("SpecialRatio")
                    OrderPriceFRM = OrderPriceFRM & OrderPrice*(SpecialRatio-1)
                    OrderPriceTXT = OrderPriceTXT&"节假日时间服务费用:"&OrderPrice*(SpecialRatio-1)&"元\n"
                    OrderPrice=OrderPrice*SpecialRatio
                ElseIf (hour(ServiceOrdApptDate)>=22 Or hour(ServiceOrdApptDate)<7)  Then
                    OrderPriceFRM = OrderPriceFRM & OrderPrice*0.3
                    OrderPriceTXT = OrderPriceTXT&"非工作时间服务费用:"&OrderPrice*0.3&"元\n"
                    OrderPrice=OrderPrice*1.3
                End If
                rs.close()
            End If
 
            '次数卡查询
            UserCard=0
            UserCardNO=""
            UserCardName=""
            If UserID<>"" And TraDistance>0 Then
                sql="select top 1 * from (select ProjectName,ServiceOrdIDDt,sum(CardInt) CardInt,CardPrice,OriginalPrice,CardStartDate,CardEndDate,Instructions from UserCard,CouponCardData where CardId=ToCid and ToUserID="&UserID&" and CardEndDate>=getdate() GROUP BY ProjectName,ServiceOrdIDDt,CardPrice,OriginalPrice,CardStartDate,CardEndDate,Instructions) as a1 where CardInt>0 order by CardEndDate"
                rs.open sql,objConn,1,1
                if not rs.Eof Then 
                    UserCard=rs("CardInt")
                    UserCardNO=Right(rs("ServiceOrdIDDt"),8)    '卡号
                    UserCardName="次数卡"
                End If
                rs.close()
                
                '使用次数卡减免起步费
                If (IsCoupon="2" Or IsCoupon="-1") And UserCard>0 And OrderPrice>=IRPrice Then
                    IsCoupon="2"
                    OrderPrice=OrderPrice-IRPrice
                    OrderPriceFRM = OrderPriceFRM & "-"&IRPrice
                    OrderPriceTXT = OrderPriceTXT&"次数卡:-"&IRPrice&"元 "&UserCardNO&"\n"
                    OrderPriceTips="共计减免:"&IRPrice&"元"
                    ServiceOrdTraPriceReason="次数卡:"&UserCardNO&" "&IRPrice&"元"
                End If
            End If
 
            '优惠券查询
            UserCouponNO=""
            UserCoupon=0
            If UserID<>"" And TraDistance>0 Then
                sql="select CouponNO,CouponMoney from Coupon where CouponDate_Ent>=getdate() and ToUserID="&UserID&" and CouponState=0 order by CouponMoney desc"
                rs.open sql,objConn,1,1
                do while not rs.Eof
                    CouponNO=rs("CouponNO")
                    CouponMoney=rs("CouponMoney")
                    If CouponMoney=150 And TraDistance>=100 Then
                        UserCouponNO    = CouponNO
                        UserCoupon            = CouponMoney
                        Exit Do
                    ElseIf CouponMoney=20 Then
                        UserCouponNO    = CouponNO
                        UserCoupon            = CouponMoney
                        Exit Do
                    End If
                    rs.movenext
                loop
                rs.close()
 
                If (IsCoupon="1" Or IsCoupon="-1") And CouponMoney>0 And OrderPrice>=CouponMoney Then
                    IsCoupon="1"
                    OrderPrice=OrderPrice-CouponMoney
                    OrderPriceFRM = OrderPriceFRM & "-"&CouponMoney
                    OrderPriceTXT = OrderPriceTXT&"活动优惠券:-"&CouponMoney&"元 "&CouponNO&"\n"
                    OrderPriceTips="共计优惠:"&CouponMoney&"元"
                    ServiceOrdTraPriceReason="优惠券:"&CouponNO&" "&CouponMoney&"元"
                End If
            End If
 
            
 
            OrderPriceFRM = OrderPriceFRM&"="&OrderPrice
            OrderPriceTXT = OrderPriceTXT&"总费用:"&OrderPrice&"元\n"
        Else
            OrderPrice=0
            OrderPriceFRM="暂不报价"
            OrderPriceTXT="客服报价"
 
            '次数卡查询
            OrdCard=0
            If UserID<>"" And TraDistance>0 Then
                sql="select top 1 * from (select ProjectName,ServiceOrdIDDt,sum(CardInt) CardInt,CardPrice,OriginalPrice,CardStartDate,CardEndDate,Instructions from UserCard,CouponCardData where CardId=ToCid and ToUserID="&UserID&" and CardEndDate>=getdate() GROUP BY ProjectName,ServiceOrdIDDt,CardPrice,OriginalPrice,CardStartDate,CardEndDate,Instructions) as a1 where CardInt>0 order by CardEndDate"
                rs.open sql,objConn,1,1
                if not rs.Eof Then 
                    UserCard=rs("CardInt")
                    UserCardNO=Right(rs("ServiceOrdIDDt"),8)    '卡号
                    UserCardName="次数卡"
                End If
                rs.close()
                If (IsCoupon="2" Or IsCoupon="-1") And OrdCard>0 Then
                    IsCoupon="2"
                    OrderPriceTXT = OrderPriceTXT&",客户希望使用次数卡:"&UserCardNO&"\n"
                End If
            End If
 
            '优惠券查询
            OrdCoupon=0
            If UserID<>"" And TraDistance>0 Then
                sql="select CouponNO,CouponMoney from Coupon where CouponDate_Ent>=getdate() and ToUserID="&UserID&" and CouponState=0 order by CouponMoney desc"
                rs.open sql,objConn,1,1
                do while not rs.Eof
                    CouponNO=rs("CouponNO")
                    CouponMoney=rs("CouponMoney")
                    If CouponMoney=150 And TraDistance>=100 And StartProvince="广东省" Then
                        UserCouponNO    = CouponNO
                        UserCoupon        = CouponMoney
                        Exit Do
                    ElseIf CouponMoney=20 And StartCity="广州市" Then
                        UserCouponNO    = CouponNO
                        UserCoupon        = CouponMoney
                        Exit Do
                    End If
                    rs.movenext
                loop
                rs.close()
                If (IsCoupon="1" Or IsCoupon="-1") And OrdCoupon>0 Then
                    IsCoupon="1"
                    OrderPriceTXT = OrderPriceTXT&",客户希望使用优惠券:-"&CouponMoney&"元\n"
                End If
            End If
 
        End If
 
    End If
    If ServiceTXT<>"" Then ServiceTXT="您的转运距离约"&TraDistance&"公里。"&ServiceTXT
    If ServiceOrdID<>"" And ServiceOrdID<>"0" Then
        sql="delete from ServiceOrder_Options where ServiceOptionsID in (-1,1000,1001) and ServiceOrdSoID="&ServiceOrdID
        objConn.Execute sql
        ServiceOptionsValue="转运距离约"&TraDistance&"公里"
        sql="Insert into ServiceOrder_Options (ServiceOrdSoID,ServiceOptionsID,ServiceOptionsValue) values ("&ServiceOrdID&",-1,'"&ServiceOptionsValue&"')"
        objConn.Execute sql
        sql="Insert into ServiceOrder_Options (ServiceOrdSoID,ServiceOptionsID,ServiceOptionsValue) values ("&ServiceOrdID&",1000,'报价说明:"&OrderPriceTXT&"')"
        objConn.Execute sql
        sql="Insert into ServiceOrder_Options (ServiceOrdSoID,ServiceOptionsID,ServiceOptionsValue) values ("&ServiceOrdID&",1001,'报价公式:"&OrderPriceFRM&"')"
        objConn.Execute sql
    End If
    'OrderPriceTXT=""
    'OrderPriceTXT=OrderPriceTips
    'OrderPrice=0.01
    If IsCoupon="-1" Then IsCoupon="0"
    webJson="{""APPID"":"""&APPID&""",""method"":"""&method&""",""result"":1,""OrderPrice"":"""&OrderPrice&""",""TraDistance"":"""&TraDistance&""",""addressComponent"":"""&addressComponent&""",""StartAddress"":"""&StartAddress&""",""EndAddress"":"""&EndAddress&""",""origin"":"""&StartAddress_lat&","&StartAddress_lng&""",""destination"":"""&EndAddress_lat&","&EndAddress_lng&""",""OrderPriceFRM"":"""&OrderPriceFRM&""",""OrderPriceTXT"":"""&OrderPriceTXT&""",""IRid"":"""&IRid&""",""ServiceTXT"":"""&ServiceTXT&""",""StartProvince"":"""&StartProvince&""",""StartCity"":"""&StartCity&""",""StartArea"":"""&StartArea&""",""U_UnitShort"":"""&U_UnitShort&""",""U_TraDistance"":"""&U_TraDistance&""",""IsCoupon"":"""&IsCoupon&""",""UserCouponNO"":"""&UserCouponNO&""",""UserCoupon"":"""&UserCoupon&""",""UserCardNO"":"""&UserCardNO&""",""UserCard"":"""&UserCard&""",""OrderPriceTips"":"""&OrderPriceTips&""",""IsOrdinary"":"""&IsOrdinary&"""}"
 
Else
    errcode=40022
    errmsg="invalid Address"
End If
 
 
If Left(errcode,1)="4" Or webJson="" Then
    If errcode="" Then
        errcode=-1
        errmsg="error"
    End If
    webJson="{""APPID"":"""&APPID&""",""method"":"""&method&""",""result"":2,""errcode"":"&errcode&",""errmsg"":"""&errmsg&"""}"
    'Call OA_Running(UnitID,webJson)
Else
    OkJson="{""APPID"":"""&APPID&""",""method"":"""&method&""",""result"":1,""Running"":"""&sParaRunning&"""}"
    'Call OA_Running(UnitID,OkJson)
End If
 
Response.Write webJson
Response.End
%>