<% @LANGUAGE="VBSCRIPT" CODEPAGE="65001" %>
|
<% Session.CodePage=65001 %>
|
<% Response.charset = "utf-8" %>
|
<!--#include virtual="/inc/odbc.asp"-->
|
<!--#include virtual="/inc/function.asp"-->
|
<!--#include virtual="/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>
|
<%
|
'百度地图
|
'ak="lA7jbMtGXprDlUfbvAGNRuXm4phHhk7b" 'vicgame
|
ak="rGQBbHKGjAtVQy23OckafQkC6nNlaGmi" 'vicgame_NS1
|
'ak="U4ff8syGj0qRZyVc9G0eFH0NxuDY3oKd" '良
|
|
Set rs = Server.CreateObject("ADODB.Recordset")
|
Set rsDt = Server.CreateObject("ADODB.Recordset")
|
method="OrderPrice_v2"
|
V = trim(request("V")) '公式版本
|
If V="" Then V="1.0"
|
|
adminID = trim(request("adminID"))
|
ServiceOrdID = trim(request("ServiceOrdID")) '服务单号
|
StartAddress = trim(request("StartAddress")) '派车地址
|
ViaAddress = trim(request("ViaAddress")) '转出地址
|
EndAddress = trim(request("EndAddress")) '转入地址
|
ServiceBranch = trim(request("ServiceBranch")) '所属地区/分公司
|
|
TraDistance = trim(request("TraDistance")) '任务单程公里数
|
NursingLevel = trim(request("NursingLevel")) '医护护理级别
|
IsVentilato = trim(request("IsVentilato")) '是否使用呼吸机
|
IsWarmBox = trim(request("IsWarmBox")) '是否使用温箱
|
IsFerry = trim(request("IsFerry")) '是否轮渡
|
LiftingInt = trim(request("LiftingInt")) '抬楼层数:默认0
|
WaitingInt = trim(request("WaitingInt")) '等待时长:默认0
|
ICUInt = trim(request("ICUInt")) '居家ICU服务时长:默认0
|
|
IsCoupon = trim(request("IsCoupon")) '是否使用优惠券:默认1
|
If IsCoupon="" Then IsCoupon="1"
|
IsIntegral = trim(request("IsIntegral")) '是否使用积分:默认0
|
If IsIntegral="" Then IsIntegral="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
|
OrdIsCoupon="0"
|
|
IRState="IRState" '方案状态
|
|
If V="0.1" Then
|
IRState="IRwxState"
|
ElseIf V="2.0" Then
|
newborn = trim(request("newborn")) '新生儿
|
direction = trim(request("direction"))'转运方向
|
symptom = trim(request("symptom")) '病人症状
|
Ventilato = trim(request("Ventilato"))'呼吸机
|
IsMedical = trim(request("IsMedical"))'是否需要医护人员
|
If LiftingInt="" Or Not IsNumeric(LiftingInt) Then LiftingInt=0
|
If newborn="" Then newborn=2
|
If direction="" Then direction=1
|
If symptom="" Then symptom=1
|
If IsMedical="" Then IsMedical=0
|
If Ventilato="" Then Ventilato=0
|
'新生儿
|
If newborn="1" Then
|
IsWarmBox=1
|
ServiceTXT="新生儿温箱、"
|
End If
|
|
'病情
|
If symptom="1" And IsWarmBox<>"1" Then '轻症
|
NursingLevel=1
|
ServiceTXT="我们将为您配备专业救护车和司机。"
|
If IsMedical="2" Then
|
NursingLevel=2
|
ElseIf IsMedical="3" Or Ventilato="2" Or Ventilato="3" Then
|
NursingLevel=3
|
End If
|
ElseIf symptom="2" And IsWarmBox<>"1" Then '病情稳定
|
NursingLevel=2
|
ServiceTXT="我们将为您配备专业救护车和护士、司机。并提供"&ServiceTXT&"氧气、吸痰机、微泵、监护仪。"
|
If IsMedical="1" Then
|
NursingLevel=1
|
ElseIf IsMedical="3" Or Ventilato="2" Or Ventilato="3" Then
|
NursingLevel=3
|
End If
|
ElseIf (IsWarmBox="1") And (symptom="1" Or symptom="2") Then '温箱
|
NursingLevel=3
|
ServiceTXT="我们将为您配备专业救护车和医生、护士、司机。并提供"&ServiceTXT&"氧气、吸痰机、微泵、心电监护仪、急救药品。"
|
ElseIf symptom="4" Or symptom="3" Then '危重/濒危
|
NursingLevel=3
|
IsVentilato=1
|
ServiceTXT="我们将为您配备专业救护车和医生、护士、司机。并提供"&ServiceTXT&"专业呼吸机、氧气、吸痰机、4组微泵、除颤监护仪、急救药品。"
|
End If
|
'呼吸机
|
If Ventilato="2" Or Ventilato="3" Then
|
IsVentilato=1
|
NursingLevel=3
|
ServiceTXT="呼吸机、"
|
ElseIf Ventilato="1" Then
|
IsVentilato=0
|
End If
|
ServiceTXT=""
|
IRState="IRwxState"
|
End If
|
|
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
|
TraDistance=CLng(TraDistance)
|
LiftingInt=CLng(LiftingInt)-1
|
|
If ServiceBranch="" Then ServiceBranch="BF"
|
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 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"))
|
If rs("ServiceOrdTraVia")<>"" Then StartAddress=rs("ServiceOrdTraVia") '出发地址按转出地址计算
|
EndAddress = trim(rs("ServiceOrdTraEnd"))
|
ServiceOrdUnitRemarks = trim(rs("ServiceOrdUnitRemarks"))
|
ServiceOrdApptDate=rs("ServiceOrdApptDate")
|
If (ServiceOrdUnitRemarks="高铁转运" Or ServiceOrdUnitRemarks="民航转运" Or ServiceOrdUnitRemarks="医疗包机" Or ServiceOrdUnitRemarks="直升机") And IRState="IRwxState" Then
|
IsCoupon = trim(request("IsCoupon")) '是否使用优惠券:默认0
|
If IsCoupon="" Then IsCoupon="0"
|
'优惠券查询
|
OrdCoupon=0
|
If UserID<>"" And ServiceOrdID<>"" Then
|
rs.close()
|
If ServiceOrdUnitRemarks="高铁转运" Then
|
CouponName="高铁"
|
Else
|
CouponName="航空"
|
End If
|
sql="select CouponNO,CouponMoney from Coupon where CouponDate_Ent>=getdate() and ToUserID="&UserID&" and CouponState=0 and CouponName like '%"&CouponName&"%' order by CouponMoney desc"
|
rs.open sql,objConn,1,1
|
If Not rs.Eof Then
|
CouponNO=rs("CouponNO")
|
CouponMoney=rs("CouponMoney")
|
OrdCoupon = CouponMoney
|
OrdIsCoupon="1"
|
End If
|
rs.close()
|
If IsCoupon="1" And OrdCoupon>0 Then
|
OrderPriceTXT = OrderPriceTXT&",客户希望使用优惠券:-"&OrdCoupon&"元\n"
|
ElseIf IsIntegral="1" Then
|
OrderPriceTXT = OrderPriceTXT&",客户希望使用积分\n"
|
End If
|
sql="delete from ServiceOrder_Options where ServiceOptionsID in (-1,1000,1001) and ServiceOrdSoID="&ServiceOrdID
|
objConn.Execute sql
|
sql="Insert into ServiceOrder_Options (ServiceOrdSoID,ServiceOptionsID,ServiceOptionsValue) values ("&ServiceOrdID&",1000,'报价说明:"&OrderPriceTXT&"')"
|
objConn.Execute sql
|
End If
|
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&""",""NursingLevel"":"""&NursingLevel&""",""ServiceTXT"":"""&ServiceTXT&""",""StartProvince"":"""&StartProvince&""",""StartCity"":"""&StartCity&""",""StartArea"":"""&StartArea&""",""U_UnitShort"":"""&U_UnitShort&""",""U_TraDistance"":"""&U_TraDistance&""",""OrdIsCoupon"":"""&OrdIsCoupon&""",""OrdCoupon"":"""&OrdCoupon&"""}"
|
Response.Write webJson
|
Response.End
|
End If
|
End If
|
rs.close()
|
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
|
sql="select HopsProvince+HopsCity+HopsArea+HospAddress from HospData where HospName='"&StartAddress&"'"
|
rs.open Sql,objConn,1,1
|
If not rs.Eof Then
|
StartAddress=rs(0)
|
End If
|
rs.close()
|
appUrl="https://api.map.baidu.com/geocoding/v3/"
|
args1="address="&StartAddress&"&output=json&ak="&ak
|
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="转出"
|
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
|
sql="select HopsProvince+HopsCity+HopsArea+HospAddress from HospData where HospName='"&EndAddress&"'"
|
rs.open Sql,objConn,1,1
|
If not rs.Eof Then
|
EndAddress=rs(0)
|
End If
|
rs.close()
|
appUrl="https://api.map.baidu.com/geocoding/v3/"
|
args1="address="&EndAddress&"&output=json&ak="&ak
|
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&"至转入"
|
End If
|
|
If (StartAddress_lat<>0 And EndAddress_lat<>0) And errcode=0 Then
|
'实时距离
|
'机构参数
|
sql="select * from IntroducerUnitData where ServiceBranch='"&ServiceBranch&"' and UnitState<>0 order by UnitID desc"
|
rs.open sql,objConn,1,1
|
If Not rs.eof Then
|
UnitID = rs("UnitID")
|
ServiceBranch = rs("ServiceBranch")
|
ServiceMinPrice = rs("ServiceMinPrice")
|
ServiceUnitPrice= rs("ServiceUnitPrice")
|
ServiceLong = rs("ServiceLong")
|
ServiceAddress_lat=rs("ServiceAddress_lat")
|
ServiceAddress_lng=rs("ServiceAddress_lng")
|
Else
|
errcode=40024
|
errmsg="invalid ServiceBranch"
|
End If
|
rs.close()
|
|
If 1=2 Then
|
'计算所属地区(按离机构近的计算)
|
sql="select (cast((6378137.0*ACOS(SIN("&ServiceAddress_lat&"/180*PI())*SIN(cast("&StartAddress_lat&" as decimal(15,10))/180*PI())+COS("&ServiceAddress_lat&"/180*PI())*COS(cast("&StartAddress_lat&" as decimal(15,10))/180*PI())*COS(("&ServiceAddress_lng&"-cast("&StartAddress_lng&" as decimal(15,10)))/180*PI()))) as decimal(15,0))),(cast((6378137.0*ACOS(SIN("&ServiceAddress_lat&"/180*PI())*SIN(cast("&EndAddress_lat&" as decimal(15,10))/180*PI())+COS("&ServiceAddress_lat&"/180*PI())*COS(cast("&EndAddress_lat&" as decimal(15,10))/180*PI())*COS(("&ServiceAddress_lng&"-cast("&EndAddress_lng&" as decimal(15,10)))/180*PI()))) as decimal(15,0)))"
|
'Response.Write sql
|
rs.open Sql,objConn,1,1
|
StartDistance=clng(rs(0))
|
EndDistance=clng(rs(1))
|
rs.close()
|
If StartDistance<EndDistance Then
|
Region_lat=StartAddress_lat
|
Region_lng=StartAddress_lng
|
Else
|
Region_lat=EndAddress_lat
|
Region_lng=EndAddress_lng
|
End If
|
Else
|
'计算所属地区(按出发地计算)
|
Region_lat=StartAddress_lat
|
Region_lng=StartAddress_lng
|
End If
|
|
|
'地区报价方案
|
appUrl="https://api.map.baidu.com/reverse_geocoding/v3/"
|
args1="location="&Region_lat&","&Region_lng&"&output=json&latest_admin=1&ak="&ak
|
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
|
'StartAddress_lat=FormatNumber(StartAddress_lat, 6)
|
'StartAddress_lng=FormatNumber(StartAddress_lng, 6)
|
'EndAddress_lat=FormatNumber(EndAddress_lat, 6)
|
'EndAddress_lng=FormatNumber(EndAddress_lng, 6)
|
'路线规划距离(公里)
|
appUrl="https://api.map.baidu.com/directionlite/v1/driving"
|
args1="origin="&StartAddress_lat&","&StartAddress_lng&"&destination="&EndAddress_lat&","&EndAddress_lng&"&coord_type=bd09ll&ak="&ak
|
'Response.Write args1
|
HTMLCODE= GetBody(appUrl,args1)
|
json = HTMLCODE
|
'Response.Write 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
|
OrderPriceTXT=OrderPriceTXT&" 规划距离:"&TraDistance&"公里 "
|
|
'各机构距离计算
|
sql="select COUNT(*) from IntroducerRegion where IRCity='"&StartCity&"'"
|
rs.open sql,objConn,1,1
|
StartCityIRInt=rs(0)
|
rs.close()
|
If StartCityIRInt>0 And V<>"0.1" Then
|
U_TraDistance=10000
|
U_UnitShort=""
|
sql="select UnitID,UnitShort,ServiceAddress,ServiceAddress_lat,ServiceAddress_lng from IntroducerUnitData where UnitState<>0 and ServiceAddress_lat<>0 and ServiceAddress_lng<>0 and ServiceAddress like '%"&StartCity&"%'" 'UnitID=14
|
rs.open sql,objConn,1,1
|
do while not rs.Eof
|
U_UnitID = rs("UnitID") '机构ID
|
U_ServiceAddress = rs("ServiceAddress") '机构出发地址
|
U_ServiceAddress_lat = rs("ServiceAddress_lat") '机构出发坐标
|
U_ServiceAddress_lng = rs("ServiceAddress_lng") '机构出发坐标
|
'机构到出发地 路线规划距离(公里)
|
appUrl="https://api.map.baidu.com/directionlite/v1/driving"
|
args1="origin="&U_ServiceAddress_lat&","&U_ServiceAddress_lng&"&destination="&StartAddress_lat&","&StartAddress_lng&"&coord_type=wgs84&ak="&ak
|
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
|
new_U_TraDistance = obj.get(i).distance '行程距离(米)
|
Next
|
End If
|
If new_U_TraDistance>1000 And IsNumeric(new_U_TraDistance) Then
|
new_U_TraDistance=CInt(new_U_TraDistance/1000)
|
ElseIf new_U_TraDistance>0 And IsNumeric(new_U_TraDistance) Then
|
new_U_TraDistance=1
|
End If
|
If new_U_TraDistance<U_TraDistance Then
|
U_TraDistance=new_U_TraDistance
|
U_UnitShort = Replace(rs("UnitShort"),"微信小程序","广州总部") '机构名称
|
End If
|
rs.movenext
|
loop
|
rs.close()
|
OrderPriceTXT="出发机构:"&U_UnitShort&" "&U_TraDistance&"公里 "&OrderPriceTXT
|
End If
|
End If
|
Else
|
'缓存距离
|
OrderPriceTXT=OrderPriceTXT&" 规划距离:"&TraDistance&"公里 "
|
If U_TraDistance<>"" And U_TraDistance<>"0" Then OrderPriceTXT="出发机构:"&U_UnitShort&" "&U_TraDistance&"公里 "&OrderPriceTXT
|
End If
|
|
'Response.Write OrderPriceTXT
|
|
If TraDistance>0 Then
|
'费用计算
|
IRPrice=0
|
OrderPrice=0
|
If errcode=0 Then
|
'地址屏蔽黑名单
|
'If StartArea="增城区" or StartArea="花都区" or StartArea="从化区" or StartArea="南沙区" or StartArea="番禺区" Then
|
If StartArea="1" Then
|
IRid=0
|
Else
|
If StartProvince<>"" And StartCity<>"" And StartArea<>"" And StartAddress<>"" And IRid=0 Then
|
sql="select IRid,IRNursingLevel from IntroducerRegion where "&IRState&"=1 and (IRProvince='"&StartProvince&"' and IRCity='"&StartCity&"' and IRArea='"&StartArea&"' and '"&StartAddress&"' like '%'+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 StartProvince<>"" And StartCity<>"" And StartArea<>"" And IRid=0 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 StartProvince<>"" And StartCity<>"" And IRid=0 Then
|
sql="select IRid,IRNursingLevel from IntroducerRegion where "&IRState&"=1 and (IRProvince='"&StartProvince&"' and IRCity='"&StartCity&"' and IRArea='' 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 StartProvince<>"" And IRid=0 Then
|
sql="select IRid,IRNursingLevel from IntroducerRegion where "&IRState&"=1 and (IRProvince='"&StartProvince&"' and IRCity='' and IRArea='' 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
|
sql="select IRid,IRNursingLevel from IntroducerRegion where "&IRState&"=1 and (IRProvince='其它') and IRPrice>0 order by IRUnitID,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
|
End If
|
If IRid<>0 Then
|
sql="select IRid,Unitlimit,UnitPrice,IRPrice,IRNursingLevel,IRVentilatorCost,IRWarmBoxCost,IRLiftingCost,IRWaitingCost,IRFerryCost from IntroducerRegion where IRid="&IRid
|
rs.open sql,objConn,1,1
|
If Not rs.eof Then
|
IRid = rs("IRid") '报价方案ID
|
Unitlimit = rs("Unitlimit") '派车点免费距离
|
UnitPrice = rs("UnitPrice") '派车点收费金额
|
IRPrice = rs("IRPrice") '起步价
|
IRNursingLevel = rs("IRNursingLevel") '医护护理级别
|
IRVentilatorCost= rs("IRVentilatorCost")'呼吸机费用
|
IRWarmBoxCost = rs("IRWarmBoxCost") '温箱费用
|
IRLiftingCost = rs("IRLiftingCost") '每层抬楼费用
|
IRWaitingCost = rs("IRWaitingCost") '每半小时等待费用
|
IRFerryCost = rs("IRFerryCost") '轮渡费用
|
IRICUCost = 1000 '每小时居家ICU费用
|
IRDtPriceTimes = 1
|
If AgeGroup="2" Or AgeGroup="5" Then '儿童固定起步价(2儿童(0-3岁(含3岁)),3儿童(3-6岁(含6岁)),4儿童(6-12岁),5新生儿 (出生至28天以内))
|
IRPrice=IRPrice*1.2 '基础费1.2倍
|
IRDtPriceTimes=1.2
|
ElseIf AgeGroup="3" Then
|
IRPrice=IRPrice*1.1 '基础费1.1倍
|
IRDtPriceTimes=1.1
|
ElseIf AgeGroup="4" Then
|
IRPrice=IRPrice*1.05 '基础费1.05倍
|
IRDtPriceTimes=1.05
|
End If
|
End If
|
rs.close()
|
End If
|
addressComponent=StartProvince
|
If StartCity<>"" Then addressComponent=addressComponent&"-"&StartCity
|
If StartArea<>"" Then addressComponent=addressComponent&"-"&StartArea
|
|
'计算报价
|
OrderPriceFRM=""
|
'OrderPriceTXT=""
|
If IRPrice>0 And TraDistance>0 Then
|
'基础报价
|
'Response.Write IRid
|
If CLng(U_TraDistance)>CLng(Unitlimit) And UnitPrice>0 Then '派车价
|
OrderUnitlimit=U_TraDistance-Unitlimit
|
OrderUnitPrice=OrderUnitlimit * UnitPrice
|
OrderPrice=OrderUnitPrice
|
OrderPriceFRM = "("&U_TraDistance&"-"&Unitlimit &")*"& UnitPrice &"+"
|
OrderPriceTXT = OrderPriceTXT&"派车价(超"&OrderUnitlimit&"公里):"&OrderUnitlimit*UnitPrice&"元\n"
|
End If
|
OrderPrice=OrderPrice+IRPrice '起步价
|
If IRDtPriceTimes>1 Then OrderPriceFRM=OrderPriceFRM&"("
|
OrderPriceFRM = OrderPriceFRM & (IRPrice/IRDtPriceTimes)
|
OrderPriceTXT = OrderPriceTXT&"起步价(20公里内):"&IRPrice&"元\n"
|
sql="select IRDtlimit,IRDtPrice from came.dbo.IntroducerRegionDt where IRDt_id="&IRid&" and IRDtlimit<="&TraDistance&" order by IRDtlimit"
|
rs.open sql,objConn,1,1
|
RegionDt=""
|
r=1
|
IRDtlimit1=0
|
IRDtlimit2=0
|
do while not rs.Eof
|
IRDtlimit1=rs("IRDtlimit")
|
'OrderPriceTXT=replace(OrderPriceTXT,"#起步公里#",IRDtlimit1)
|
IRDtPrice=rs("IRDtPrice")*IRDtPriceTimes
|
rs.movenext
|
If not rs.Eof Then
|
IRDtlimit2=rs("IRDtlimit")
|
Else
|
IRDtlimit2=TraDistance
|
End If
|
IRDtDistance=IRDtlimit2-IRDtlimit1
|
'If IRDtDistance<IRDtlimit2 Then IRDtDistance=IRDtlimit2
|
OrderPrice=OrderPrice+IRDtDistance*IRDtPrice
|
If IRDtDistance>0 Then
|
OrderPriceFRM = OrderPriceFRM & "+"&IRDtDistance&"*"&IRDtPrice/IRDtPriceTimes
|
If IRDtlimit2=TraDistance Or IRDtlimit2="" Then
|
OrderPriceTXT = OrderPriceTXT&IRDtlimit1&"公里以上:"&IRDtPrice&"元/公里\n"
|
Else
|
OrderPriceTXT = OrderPriceTXT&IRDtlimit1&"公里至"&IRDtlimit2&"公里:"&IRDtPrice&"元/公里\n"
|
End If
|
End If
|
loop
|
rs.close()
|
If IRDtPriceTimes>1 Then OrderPriceFRM=OrderPriceFRM&")*"&IRDtPriceTimes
|
|
'服务报价
|
If CLng(IsVentilato)=1 Then '是否使用呼吸机
|
OrderPrice=OrderPrice+IRVentilatorCost
|
OrderPriceFRM = OrderPriceFRM & "+"&IRVentilatorCost
|
OrderPriceTXT = OrderPriceTXT&"呼吸机费用:"&IRVentilatorCost&"元\n"
|
End If
|
If CLng(IsWarmBox)=1 Then '是否使用温箱
|
OrderPrice=OrderPrice+IRWarmBoxCost
|
OrderPriceFRM = OrderPriceFRM & "+"&IRWarmBoxCost
|
OrderPriceTXT = OrderPriceTXT&"温箱费用:"&IRWarmBoxCost&"元\n"
|
End If
|
If CLng(IsFerry)=1 Then '是否要轮渡
|
OrderPrice=OrderPrice+IRFerryCost
|
OrderPriceFRM = OrderPriceFRM & "+"&IRFerryCost
|
OrderPriceTXT = OrderPriceTXT&"轮渡费用:"&IRFerryCost&"元\n"
|
End If
|
If CLng(LiftingInt)>0 Then '抬楼层数
|
OrderPrice=OrderPrice+IRLiftingCost*LiftingInt
|
OrderPriceFRM = OrderPriceFRM & "+"&IRLiftingCost&"*"&LiftingInt
|
OrderPriceTXT = OrderPriceTXT&"抬楼费用:"&IRLiftingCost*CLng(LiftingInt)&"元\n"
|
End If
|
If round(WaitingInt,1)>0 Then '等待费用(每半小时)
|
OrderPrice=OrderPrice+WaitingInt*2*IRWaitingCost
|
OrderPriceFRM = OrderPriceFRM & "+"&WaitingInt&"*2*"&IRWaitingCost
|
OrderPriceTXT = OrderPriceTXT&"等待费用:"&WaitingInt*2*IRWaitingCost&"元\n"
|
End If
|
If CLng(ICUInt)>0 Then '居家ICU 前6小时1000元,超6小时500元/小时
|
If CLng(ICUInt)<=6 Then
|
OrderPrice=OrderPrice+IRICUCost*ICUInt
|
OrderPriceFRM = OrderPriceFRM & "+"&IRICUCost&"*"&ICUInt
|
OrderPriceTXT = OrderPriceTXT&"居家ICU费用:"&IRICUCost*ICUInt&"元\n"
|
Else
|
OrderPrice=OrderPrice+IRICUCost*6+500*(ICUInt-6)
|
OrderPriceFRM = OrderPriceFRM & "+"&IRICUCost&"*6+500*"&(ICUInt-6)
|
OrderPriceTXT = OrderPriceTXT&"居家ICU费用:"&IRICUCost*6+500*(ICUInt-6)&"元\n"
|
End If
|
End If
|
If ServiceOrdApptDate<>"" And ServiceOrdApptDate<>"1900/1/1" And ServiceOrdApptDate<>"1900-1-1" Then '夜间服务费用,20:00-00:00加收300 00:01-06:30加收500
|
If hour(ServiceOrdApptDate)>=20 Then
|
OrderPrice=OrderPrice+300
|
OrderPriceFRM = OrderPriceFRM & "+300"
|
OrderPriceTXT = OrderPriceTXT&"夜间服务费用:300元\n"
|
ElseIf hour(ServiceOrdApptDate)<6 or (hour(ServiceOrdApptDate)=6 And Minute(ServiceOrdApptDate)<=30) Then
|
OrderPrice=OrderPrice+500
|
OrderPriceFRM = OrderPriceFRM & "+500"
|
OrderPriceTXT = OrderPriceTXT&"夜间服务费用:500元\n"
|
End If
|
End If
|
|
OrderPriceTXT1=OrderPriceTXT
|
'自动使用优惠券
|
ServiceOrdTraPriceReason=""
|
OrdCoupon=0
|
If UserID<>"" And ServiceOrdID<>"" 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=500 And TraDistance>=500 Then
|
If IsCoupon="1" Then
|
OrderPrice=OrderPrice-CouponMoney
|
OrderPriceFRM = OrderPriceFRM & "-"&CouponMoney
|
OrderPriceTXT = OrderPriceTXT&"活动优惠券:-"&CouponMoney&"元 "&CouponNO&"\n"
|
OrderPriceTips="已使用代金券,共计优惠:"&CouponMoney&"元"
|
ServiceOrdTraPriceReason="优惠券:"&CouponNO&" "&CouponMoney&"元"
|
End If
|
OrdCoupon = CouponMoney
|
OrdIsCoupon="1"
|
Exit Do
|
ElseIf CouponMoney=200 And TraDistance>=100 Then
|
If IsCoupon="1" Then
|
OrderPrice=OrderPrice-CouponMoney
|
OrderPriceFRM = OrderPriceFRM & "-"&CouponMoney
|
OrderPriceTXT = OrderPriceTXT&"活动优惠券:-"&CouponMoney&"元 "&CouponNO&"\n"
|
OrderPriceTips="已使用代金券,共计优惠:"&CouponMoney&"元"
|
ServiceOrdTraPriceReason="优惠券:"&CouponNO&" "&CouponMoney&"元"
|
End If
|
OrdCoupon = CouponMoney
|
OrdIsCoupon="1"
|
Exit Do
|
ElseIf CouponMoney=50 Then
|
If IsCoupon="1" Then
|
OrderPrice=OrderPrice-CouponMoney
|
OrderPriceFRM = OrderPriceFRM & "-"&CouponMoney
|
OrderPriceTXT = OrderPriceTXT&"活动优惠券:-"&CouponMoney&"元 "&CouponNO&"\n"
|
OrderPriceTips="已使用代金券,共计优惠:"&CouponMoney&"元"
|
ServiceOrdTraPriceReason="优惠券:"&CouponNO&" "&CouponMoney&"元"
|
End If
|
OrdCoupon = CouponMoney
|
OrdIsCoupon="1"
|
Exit Do
|
End If
|
rs.movenext
|
loop
|
rs.close()
|
sql="update ServiceOrder set ServiceOrdTraPriceReason='"&ServiceOrdTraPriceReason&"' where ServiceOrdID="&ServiceOrdID
|
objConn.Execute sql
|
End If
|
OrderPriceFRM = OrderPriceFRM&"="&OrderPrice
|
OrderPriceTXT = OrderPriceTXT&"总费用:"&OrderPrice&"元\n"
|
Else
|
OrderPrice=0
|
OrderPriceFRM="暂不报价"
|
OrderPriceTXT="客服报价"
|
IsCoupon = trim(request("IsCoupon")) '是否使用优惠券:默认0
|
If IsCoupon="" Then IsCoupon="0"
|
'优惠券查询
|
OrdCoupon=0
|
If UserID<>"" And ServiceOrdID<>"" 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=500 And TraDistance>=500 Then
|
OrdCoupon = CouponMoney
|
OrdIsCoupon="1"
|
Exit Do
|
ElseIf CouponMoney=200 And TraDistance>=100 Then
|
OrdCoupon = CouponMoney
|
OrdIsCoupon="1"
|
Exit Do
|
ElseIf CouponMoney=50 Then
|
OrdCoupon = CouponMoney
|
OrdIsCoupon="1"
|
Exit Do
|
End If
|
rs.movenext
|
loop
|
rs.close()
|
If IsCoupon="1" And OrdCoupon>0 Then
|
OrderPriceTXT = OrderPriceTXT&",客户希望使用优惠券:-"&OrdCoupon&"元\n"
|
ElseIf IsIntegral="1" Then
|
OrderPriceTXT = OrderPriceTXT&",客户希望使用积分\n"
|
End If
|
End If
|
End If
|
|
End If
|
|
If ServiceTXT<>"" Then ServiceTXT="您的转运距离约"&TraDistance&"公里。"&ServiceTXT
|
If ServiceOrdID<>"" And ServiceOrdID<>"0" And V="2.0" Then
|
sql="delete from ServiceOrder_Options where ServiceOptionsID in (-1,1000,1001) and ServiceOrdSoID="&ServiceOrdID
|
objConn.Execute sql
|
ServiceOptionsValue="转运距离约"&TraDistance&"公里"
|
If U_UnitShort<>"" Then
|
ServiceOptionsValue=ServiceOptionsValue&",建议执行单位:"&U_UnitShort
|
End If
|
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
|
ElseIf adminID<>"" Then
|
U_UnitShort = Replace(U_UnitShort,"微信小程序","广州总部") '机构名称
|
OrderPricelog=U_UnitShort&" 预估距离:"&TraDistance&"公里"
|
If U_TraDistance<>"" Then OrderPricelog=OrderPricelog&" 派车距离:"&U_TraDistance&"公里"
|
OrderPricelog=OrderPricelog&" 自动报价:"&OrderPrice&"元 报价说明:"&OrderPriceTXT1&"报价公式:"&OrderPriceFRM&""
|
sql="Insert into API_Json (method,Json,Json_time,reserve) values ('报价工具','"&OrderPricelog&"',getdate(),'"&adminID&"')"
|
objConn.Execute sql
|
End If
|
If ServiceOrdID<>"" And ServiceOrdID<>"0" And OrderPrice<>"" And OrderPrice<>"0" And IsNumeric(OrderPrice) Then
|
sql="update ServiceOrder set OrderPrice_Auto="&OrderPrice&" where ServiceOrdID="&ServiceOrdID
|
objConn.Execute sql
|
End If
|
OrderPriceTXT=""
|
OrderPriceTXT=OrderPriceTips
|
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&""",""OrderPriceTXT1"":"""&OrderPriceTXT1&""",""IRid"":"""&IRid&""",""NursingLevel"":"""&NursingLevel&""",""ServiceTXT"":"""&ServiceTXT&""",""StartProvince"":"""&StartProvince&""",""StartCity"":"""&StartCity&""",""StartArea"":"""&StartArea&""",""U_UnitShort"":"""&U_UnitShort&""",""U_TraDistance"":"""&U_TraDistance&""",""OrdIsCoupon"":"""&OrdIsCoupon&""",""OrdCoupon"":"""&OrdCoupon&"""}"
|
|
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
|
%>
|