<% @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"-->
|
<%
|
Set rs = Server.CreateObject("ADODB.Recordset")
|
Set rsDt = Server.CreateObject("ADODB.Recordset")
|
|
method=trim(Request("method"))
|
errcode=""
|
if method="" Then
|
errcode=40001
|
errmsg="invalid method"
|
end If
|
|
'时间戳验证----------
|
UnixTime=trim(Request("UnixTime"))
|
Call MD5_UnixTime(UnixTime)
|
'时间戳验证---end
|
|
'签名验证----------
|
ApiSign=trim(Request("Sign"))
|
if ApiSign="" Then
|
errcode=40005
|
errmsg="invalid Sign"
|
else
|
'待签名字符串
|
ReDim arr(Request.QueryString.Count+Request.Form.Count,2)
|
Dim v '所有表单值
|
Dim t '所有表单数量
|
v=Request.QueryString
|
If v<>"" And Request.Form<>"" Then
|
v=v&"&"&Request.Form
|
ElseIf Request.Form<>"" Then
|
v=Request.Form
|
End If
|
t=Request.QueryString.Count+Request.Form.Count
|
For i=0 To t-1
|
arr(i,1)=Split(Split(v,"&")(i),"=")(0)
|
arr(i,2)=Split(Split(v,"&")(i),"=")(1)
|
Next
|
For i = 0 To t-1
|
For j = i + 1 To t-1
|
If arr(i,1) > arr(j,1) Then
|
tmp1 = arr(i,1)
|
arr(i,1) = arr(j,1)
|
arr(j,1) = tmp1
|
tmp2 = arr(i,2)
|
arr(i,2) = arr(j,2)
|
arr(j,2) = tmp2
|
End If
|
Next
|
Next
|
For i = 0 To t-1
|
'response.write arr(i,1) & "=" & arr(i,2) & "<br>"
|
If arr(i,1)="Sign" Then
|
reserve=arr(i,2)
|
else
|
If arr(i,2)="timestamp" Then arr(i,2)=Date() &" "& Time()
|
sParaSort=sParaSort & arr(i,1) & arr(i,2)
|
sParaRunning=sParaRunning &"&"& arr(i,1) &"="& arr(i,2)
|
End if
|
Next
|
sign_type = "MD5"
|
input_charset="utf-8"
|
stringA=sParaSort&key
|
'response.write sParaSort & "<br>"
|
Private Function BuildRequestMysign(sParaSort)
|
'获得签名结果
|
Select Case sign_type
|
Case "MD5" BuildRequestMysign = Md5Sign(sParaSort,key,input_charset)
|
Case Else BuildRequestMysign = ""
|
End Select
|
End Function
|
sParaSort=BuildRequestMysign(sParaSort)
|
If CStr(ApiSign)<>CStr(sParaSort) Then
|
errcode=40006
|
errmsg="invalid Sign"
|
'签名调试
|
If is_test="1" Or ApiSign="vicgame" Then errmsg="invalid stringA:"&stringA&",Sign:"&sParaSort
|
errmsg="invalid stringA:"&stringA&",Sign:"&sParaSort
|
End If
|
End If
|
'签名验证---end
|
|
objConn.BeginTrans
|
|
If errcode="" then
|
select case method
|
case "APITest" '接口测试
|
TestData=trim(Request("Test")) '服务单状态
|
webJson="{""method"":""APITest"",""result"":1,""Test"":"""&TestData&"""}"
|
'接口测试 end
|
|
case "User_Login" '用户登陆/信息查询/用户注册
|
'必须
|
LoginType = trim(Request("LoginType")) '登陆方式(0用户ID,1电话号,2手机号+短信验证码,4微信openid)
|
'可选
|
UserSource = trim(Request("UserSource")) '用户来源信息
|
UserName = trim(Request("UserName")) '用户姓名
|
More = trim(Request("More")) '更多会员信息
|
|
errcode=1
|
NewUser=0
|
RecommendUserID=0
|
beginning_title=""
|
beginning_address=""
|
ending_title=""
|
ending_address=""
|
If UserSource="undefined" Then UserSource=""
|
If LoginType="" Then LoginType="0"
|
If UserSource<>"" Then '分拆推荐人
|
UserSource = Replace(UserSource,"lid","Iid")
|
UserSource = Replace(UserSource,"/","|")
|
UserSourceSP = SPLIT(UserSource,"|")
|
UserSource = ""
|
for i=0 to ubound(UserSourceSP)
|
If InStr(UserSourceSP(i),"Rid")>=1 Then
|
'推荐人信息
|
Rid=Replace(UserSourceSP(i),"Rid","")
|
If IsNumeric(Rid) Then RecommendUserID=Rid
|
ElseIf UserSourceSP(i)="UP" Then
|
'更新来源信息
|
UpdateSource="YES"
|
ElseIf UserSourceSP(i)="QR" Then
|
'转运快线小程序扫码下单
|
UpdateSource="QR"
|
ElseIf UserSourceSP(i)="Valet" Then
|
'转运快线小程序代客下单
|
UpdateSource="Valet"
|
ElseIf InStr(UserSourceSP(i),"iuid")>=1 Then
|
'转运快线小程序介绍人id
|
iuid=Replace(UserSourceSP(i),"iuid","")
|
ElseIf InStr(UserSourceSP(i),"uuid")>=1 Then
|
'转运快线小程序推广单uuid
|
uuid=Replace(UserSourceSP(i),"uuid","")
|
Else
|
UserSource = UserSource &"|"&UserSourceSP(i)
|
If InStr(UserSourceSP(i),"Iid")>=1 Then
|
Iid=Replace(UserSourceSP(i),"Iid","")
|
sql="select UnitName,UnitAddress from IntroducerData,IntroducerUnitData where UnitID=IntroducerUnitID and IntroducerID="&Iid
|
rs.open sql,objConn,1,1
|
if not rs.eof Then
|
ending_title = rs("UnitName")
|
ending_address = rs("UnitAddress")
|
End If
|
rs.close()
|
End If
|
End If
|
Next
|
If UserSource<>"" Then UserSource=Mid(UserSource,2)
|
End If
|
If LoginType="0" Then '用户ID登陆
|
'必须
|
UserID = trim(Request("UserID")) '用户唯一ID
|
|
ElseIf LoginType="1" Then '电话号登陆
|
'必须
|
UserPhone = trim(Request("UserPhone")) '用户手机号
|
'可选
|
UserID = trim(Request("UserID")) '用户唯一ID
|
|
If UserPhone="" Or Not IsNumeric(UserPhone) Then
|
errcode=40602
|
errmsg="empty UserPhone"
|
else
|
sql="select top 1 id,ToUserID from UserPhone where strPhone='"&UserPhone&"' order by LoginTime desc"
|
rs.open sql,objConn,1,1
|
if not rs.eof Then
|
PhoneID = rs("id")
|
ToUserID = rs("ToUserID")
|
Else
|
PhoneID=0
|
ToUserID=0
|
End If
|
rs.close()
|
'response.write ToUserID
|
If UserID<>"" And UserID<>"0" And IsNumeric(UserID) And PhoneID<>0 Then
|
'更新已有手机信息
|
sql="update UserPhone set ToUserID="&UserID&",LoginTime=getdate() where id="&PhoneID
|
objConn.Execute sql
|
If UserSource<>"" Then
|
sql="update UserData set UserPhone='"&UserPhone&"',UserSource='"&UserSource&"' where UserID="&UserID
|
Else
|
sql="update UserData set UserPhone='"&UserPhone&"' where UserID="&UserID
|
End If
|
objConn.Execute sql
|
ElseIf UserID<>"" And UserID<>"0" And IsNumeric(UserID) And PhoneID=0 Then
|
'新增用户手机信息
|
sql="Insert into UserPhone (ToUserID,strPhone,strPhone_is) values ("&UserID&",'"&UserPhone&"',1)"
|
objConn.Execute sql
|
sql="update UserData set UserPhone='"&UserPhone&"' where UserID="&UserID
|
objConn.Execute sql
|
ElseIf PhoneID=0 And ToUserID=0 Then
|
'新用户&手机注册
|
sql="Insert into UserData (UserUnitID,UserPhone,UserSource) values ("&UnitID&",'"&UserPhone&"','"&UserSource&"')"
|
objConn.Execute sql
|
sql="select top 1 UserID from UserData where UserPhone='"&UserPhone&"' order by UserID desc"
|
rs.open sql,objConn,1,1
|
if not rs.eof Then
|
UserID=rs("UserID")
|
sql="Insert into UserPhone (ToUserID,strPhone) values ("&UserID&",'"&UserPhone&"')"
|
objConn.Execute sql
|
End If
|
rs.close()
|
NewUser=1
|
Else
|
'正常手机登陆
|
UserID=ToUserID
|
sql="update UserPhone set LoginTime=getdate() where id="&PhoneID
|
objConn.Execute sql
|
End If
|
sql="update ServiceOrder set ServiceOrdUserID="&UserID&" where ServiceOrdUserID<>"&UserID&" and ServiceOrdCoPhone='"&UserPhone&"'"
|
objConn.Execute sql
|
End If
|
|
sql="select top 1 ToUserID from UserPhone where strPhone='"&UserPhone&"' order by LoginTime desc"
|
rs.open sql,objConn,1,1
|
if not rs.eof Then
|
UserID = rs("ToUserID")
|
Else
|
errcode=40603
|
errmsg="invalid UserPhone"
|
End if
|
rs.close()
|
|
ElseIf LoginType="2" Then '手机号+短信验证码登陆
|
'必须
|
UserPhone = trim(Request("UserPhone")) '用户手机号
|
UserPhoneVerify = trim(Request("UserPhoneVerify")) '短信验证码
|
'可选
|
UserID = trim(Request("UserID")) '用户唯一ID
|
|
If UserPhone="" Or UserPhoneVerify="" Or Not IsNumeric(UserPhone) Then
|
errcode=40603
|
errmsg="empty UserPhone/UserPhoneVerify"
|
else
|
sql="select top 1 ID from UserPhoneVerify where Phone='"&UserPhone&"' and PhoneVerify='"&UserPhoneVerify&"' and datediff(Mi,SendTime,getdate())<=30 order by SendTime desc"
|
rs.open sql,objConn,1,1
|
if not rs.eof Then
|
rs.close()
|
PhoneID=0
|
ToUserID=0
|
sql="select top 1 id,ToUserID from UserPhone where strPhone='"&UserPhone&"' order by LoginTime desc"
|
rs.open sql,objConn,1,1
|
if not rs.eof Then
|
PhoneID = rs("id")
|
ToUserID = rs("ToUserID")
|
End If
|
If UserID<>"" And UserID<>"0" And IsNumeric(UserID) And PhoneID<>0 Then
|
'更新已有手机信息
|
sql="update UserPhone set strPhone_is=1,ToUserID="&UserID&",LoginTime=getdate() where id="&PhoneID
|
objConn.Execute sql
|
sql="update UserData set UserPhone='"&UserPhone&"' where UserID="&UserID
|
objConn.Execute sql
|
ElseIf UserID<>"" And UserID<>"0" And IsNumeric(UserID) And PhoneID=0 Then
|
'新增用户手机信息
|
sql="Insert into UserPhone (ToUserID,strPhone,strPhone_is) values ("&UserID&",'"&UserPhone&"',1)"
|
objConn.Execute sql
|
sql="update UserData set UserPhone='"&UserPhone&"' where UserID="&UserID
|
objConn.Execute sql
|
ElseIf PhoneID=0 And ToUserID=0 Then
|
'新用户&手机注册
|
rs.close()
|
sql="Insert into UserData (UserUnitID,UserPhone,UserSource) values ("&UnitID&",'"&UserPhone&"','"&UserSource&"')"
|
objConn.Execute sql
|
sql="select top 1 UserID from UserData where UserPhone='"&UserPhone&"' order by UserID desc"
|
rs.open sql,objConn,1,1
|
if not rs.eof Then
|
UserID=rs("UserID")
|
sql="Insert into UserPhone (ToUserID,strPhone,strPhone_is) values ("&UserID&",'"&UserPhone&"',1)"
|
objConn.Execute sql
|
End If
|
NewUser=1
|
Else
|
'正常手机登陆
|
UserID=ToUserID
|
sql="update UserPhone set strPhone_is=1,LoginTime=getdate() where id="&PhoneID
|
objConn.Execute sql
|
End If
|
sql="update ServiceOrder set ServiceOrdUserID="&UserID&" where ServiceOrdUserID<>"&UserID&" and ServiceOrdCoPhone='"&UserPhone&"'"
|
objConn.Execute sql
|
Else
|
errcode=40603
|
errmsg="invalid UserPhoneVerify"
|
End if
|
rs.close()
|
End If
|
|
ElseIf LoginType="3" Then '微信openid登陆
|
'必须
|
wxOpenid = trim(Request("wxOpenid")) '微信OpenID
|
|
'可选
|
UserID = trim(Request("UserID")) '用户唯一ID
|
wxOriginalID = trim(Request("wxOriginalID")) '微信原始ID
|
wxUnionID = trim(Request("wxUnionID")) '微信UnionID
|
wxNickName = trim(Request("wxNickName")) '微信昵称
|
wxAvatarUrl = trim(Request("wxAvatarUrl")) '微信头像链接
|
UserPhone = trim(Request("UserPhone")) '用户手机号
|
|
If wxOpenid="" Or wxOpenid="undefined" Then
|
errcode=40604
|
errmsg="empty wxOpenid"
|
else
|
If wxUnionID="undefined" Then wxUnionID=""
|
If wxOriginalID<>"" Then OriginalSql=" and OriginalID='"&wxOriginalID&"' "
|
If wxUnionID<>"" Then UnionIDSql=",UnionID='"&wxUnionID&"'"
|
sql="select top 1 id,ToUserID,UserPhone from weixinOpenID,UserData where UserID=ToUserID and OpenID='"&wxOpenid&"'"&OriginalSql&" order by LoginTime desc"
|
rs.open sql,objConn,1,1
|
if not rs.eof Then
|
weixinID = rs("id")
|
ToUserID = rs("ToUserID")
|
UserPhone = rs("UserPhone")
|
ElseIf wxUnionID<>"" Then
|
rs.close()
|
sql="select top 1 id,ToUserID from weixinOpenID where UnionID='"&wxUnionID&"' and ToUserID<>0 order by LoginTime desc"
|
rs.open sql,objConn,1,1
|
if not rs.eof Then
|
weixinID = 0
|
ToUserID = rs("ToUserID")
|
UserID = ToUserID
|
Else
|
weixinID = 0
|
ToUserID = 0
|
End If
|
Else
|
weixinID = 0
|
ToUserID = 0
|
End If
|
rs.close()
|
|
If UserID<>"" And UserID<>"0" And IsNumeric(UserID) And weixinID<>0 Then
|
'更新已有微信信息
|
sql="update weixinOpenID set ToUserID="&UserID&",LoginTime=getdate()"&UnionIDSql&" where id="&weixinID
|
objConn.Execute sql
|
ElseIf UserID<>"" And UserID<>"0" And IsNumeric(UserID) And weixinID=0 Then
|
'新增用户微信信息
|
sql="Insert into weixinOpenID (ToUserID,OriginalID,OpenID,UnionID) values ("&UserID&",'"&wxOriginalID&"','"&wxOpenid&"','"&wxUnionID&"')"
|
objConn.Execute sql
|
ElseIf weixinID=0 And ToUserID=0 Then
|
'新用户&微信注册
|
sql="Insert into UserData (UserUnitID,UserSource) values ("&UnitID&",'"&UserSource&"')"
|
objConn.Execute sql
|
sql="select top 1 UserID from UserData order by UserID desc"
|
rs.open sql,objConn,1,1
|
if not rs.eof Then
|
UserID=rs("UserID")
|
sql="Insert into weixinOpenID (ToUserID,OriginalID,OpenID,UnionID) values ("&UserID&",'"&wxOriginalID&"','"&wxOpenid&"','"&wxUnionID&"')"
|
objConn.Execute sql
|
End If
|
rs.close()
|
NewUser=1
|
Else
|
'正常微信登陆
|
UserID=ToUserID
|
sql="update weixinOpenID set LoginTime=getdate()"&UnionIDSql&" where id="&weixinID
|
objConn.Execute sql
|
End If
|
If wxNickName<>"" And wxAvatarUrl<>"" Then
|
'更新微信昵称和头像
|
sql="update UserData set UserNickName='"&wxNickName&"',UserAvatarUrl='"&wxAvatarUrl&"' where UserID="&UserID
|
objConn.Execute sql
|
End If
|
If UserID<>"" And UserID<>"0" And UserPhone<>"" And not isnull(UserPhone) Then
|
sql="update UserPhone set ToUserID="&UserID&" where ToUserID<>"&UserID&" and strPhone='"&UserPhone&"'"
|
objConn.Execute sql
|
sql="update ServiceOrder set ServiceOrdUserID="&UserID&" where ServiceOrdUserID<>"&UserID&" and ServiceOrdCoPhone='"&UserPhone&"'"
|
objConn.Execute sql
|
End If
|
End If
|
|
'NewUser=1 新用户
|
|
Else
|
errcode=40601
|
errmsg="empty LoginType"
|
End If
|
'If UserID="4" Then UserID=31982
|
'数据不完整
|
If errcode<>1 Then
|
|
ElseIf UserID="" Then
|
errcode=40610
|
errmsg="empty Data"
|
Else
|
'If UnitState<>2 Then UnitSql=" and UserUnitID="&UnitID '只显示指定商户
|
sql="select * from UserData where UserID="&UserID & UnitSql
|
rs.open sql,objConn,1,1
|
if not rs.eof Then
|
UserID = rs("UserID")
|
If UserName<>"" Then
|
UserNameSql=",UserName='"&UserName&"'"
|
Else
|
UserName = rs("UserName")
|
End If
|
|
|
UserPhone = rs("UserPhone")
|
UserNickName= rs("UserNickName")
|
UserAvatarUrl=rs("UserAvatarUrl")
|
UserLevel = rs("UserLevel")
|
UserRegisterTime= rs("UserRegisterTime")
|
UserLoginTime= rs("UserLoginTime")
|
UserUnitID = rs("UserUnitID")
|
Old_RecommendUserID = rs("RecommendUserID")
|
Old_UserSource = rs("UserSource")
|
Old_UserSourceTime=rs("UserSourceTime")
|
Old_UserSourceTimeTerm=rs("UserSourceTimeTerm")
|
If UserBranch="" Then UserBranch = "GZ"
|
|
'更新用户来源信息
|
If UserSource<>"" Then
|
UserSourceSql=",UserSource='"&UserSource&"',UserSourceTime=getdate(),UserSourceTimeTerm=12" '用户来源信息12小时内有效
|
'Else
|
' If Old_UserSource<>"" And Old_UserSourceTime<>"" Then
|
' If datediff("s",Now(),DateAdd("h",Old_UserSourceTimeTerm,Old_UserSourceTime))>=0 Then
|
' UserSource=Old_UserSource
|
' End If
|
' End If
|
Else
|
UserSource=Old_UserSource
|
End If
|
If RecommendUserID<>"" Then
|
UserSourceSql=UserSourceSql&",RecommendUserID="&RecommendUserID
|
End If
|
sql="update UserData set UserLoginTime=getdate()"&UserNameSql&UserSourceSql&RecommendSql&" where UserID="&UserID
|
objConn.Execute sql
|
|
'用户昵称处理
|
If UserNickName<>"" Then
|
UserNickName = Replace(UserNickName,"?","")
|
If UserNickName="" Then UserNickName="微信用户"
|
End If
|
'更多用户信息
|
If More="1" Then
|
'订单金额/订单数量
|
rs.close()
|
sql="select count(ServiceOrdID),isnull(sum(ServiceOrdTraTxnPrice),0) from ServiceOrder where ServiceOrdState<>4 and ServiceOrdUserID="&UserID
|
rs.open sql,objConn,1,1
|
OrderInt = rs(0)
|
|
'用户积分
|
rs.close()
|
sql="select isnull(sum(PaidMoney),0) sumPaidMoney from Welcab.dbo.UserData a LEFT JOIN Welcab.dbo.UserRecommendNote on ToUserID=UserID and ToRUserID=RecommendUserID LEFT JOIN Welcab.dbo.ServiceOrder on ServiceOrdUserID=a.UserID and ServiceOrdState<>4 LEFT JOIN Welcab.dbo.PaidMoney on PaidMoney.ServiceOrdIDDt=ServiceOrder.ServiceOrdID and PaidMoney<>0 where a.RecommendUserID="&UserID
|
rs.open sql,objConn,1,1
|
PointsInt = CInt(rs(0)*0.1)
|
|
'现金券金额
|
rs.close()
|
sql="select isnull(SUM(CouponMoney),0) from Coupon where getdate() BETWEEN CouponDate and CouponDate_Ent and CouponState=0 and ToUserID="&UserID
|
rs.open sql,objConn,1,1
|
CouponMoney = rs(0)
|
|
MoreJson=",""Points"":"""&PointsInt&""",""Coupon"":"""&CouponMoney&""",""OrderInt"":"""&OrderInt&""""
|
End If
|
'预绑定出行卡处理
|
If UserPhone<>"" Then
|
sql="update UserCard set ToUserID="&UserID&" where ToUserID=0 and CardInt<>0 and CardPhone='"&UserPhone&"'"
|
objConn.Execute sql
|
End If
|
webJson="{""method"":""User_Login"",""result"":1,""UserID"":"&UserID&",""UserName"":"""&UserName&""",""UserPhone"":"""&UserPhone&""",""UserNickName"":"""&UserNickName&""",""UserAvatarUrl"":"""&UserAvatarUrl&""",""UserLevel"":"&UserLevel&",""RegisterTime"":"""&UserRegisterTime&""",""LoginTime"":"""&UserLoginTime&""",""UserUnitID"":"""&UserUnitID&""",""UserBranch"":"""&UserBranch&""",""UserSource"":"""&UserSource&""",""RecommendUserID"":"""&RecommendUserID&""",""beginning"": {""title"":"""&beginning_title&""",""address"":"""&beginning_address&"""},""ending"": {""title"":"""&ending_title&""",""address"":"""&ending_address&"""}"&MoreJson&"}"
|
Else
|
errcode=40611
|
errmsg="invalid UserID"
|
End if
|
rs.close()
|
End if
|
'用户登陆/信息查询/用户注册 end
|
|
case "Send_SMS" '短信发送
|
'必须
|
SendPhone = trim(Request("SendPhone")) '发送手机
|
SendType = trim(Request("SendType")) '发送信息类型(1 自定义信息,2 手机验证)
|
|
'可选
|
UserID = trim(Request("UserID")) '用户唯一ID
|
SendText = trim(request("SendText")) '发送内容
|
SendRemarks = trim(request("SendRemarks")) '发送备注
|
|
errcode=1
|
|
if SendPhone="" Or Len(SendPhone)<>11 Or Not IsNumeric(SendPhone) Then
|
errcode=40621
|
errmsg="invalid SendPhone"
|
|
ElseIf SendType="1" Then
|
'1 自定义信息
|
If SendText<>"" Then
|
SendText = SendText&"【医疗快线】"
|
call Get_SMS(SendPhone,SendText,SendRemarks)
|
webJson="{""APPID"":"""&APPID&""",""method"":"""&method&""",""result"":1}"
|
Else
|
errcode=40623
|
errmsg="invalid SendText"
|
End If
|
|
ElseIf SendType="2" Then
|
'2 手机验证
|
randomize
|
for i=1 to 4
|
PhoneVerify = PhoneVerify&int(10*Rnd())
|
Next
|
PhoneVerify=Left(PhoneVerify,4)
|
sql="Insert into UserPhoneVerify (Phone,PhoneVerify) values ('"&SendPhone&"','"&PhoneVerify&"')"
|
objConn.Execute sql
|
SendText = "您的验证码是:"&PhoneVerify&",请您在15分钟内输入验证码,切勿泄露于他人"
|
SendText = SendText&"【医疗快线】"
|
lateCode="SMS_171940354"
|
appUrl="https://api.966120.com.cn/v1/SendSms.php?Phone="&SendPhone&"&code="&PhoneVerify&"&lateCode="&lateCode
|
call PostBody(appUrl,args1)
|
'call Get_SMS(SendPhone,SendText,SendRemarks)
|
webJson="{""APPID"":"""&APPID&""",""method"":"""&method&""",""result"":1}"
|
Else
|
errcode=40622
|
errmsg="invalid SendType"
|
End If
|
|
'短信发送 end
|
|
case "User_getCoupon" '用户领取优惠券
|
'必须
|
UserID = trim(Request("UserID")) '用户唯一ID
|
CouponCode= trim(Request("CouponCode")) '活动优惠券编号
|
|
errcode=1
|
If CouponCode="" Then CouponCode="1244"
|
|
if UserID="" Or Not IsNumeric(UserID) Then
|
errcode=40624
|
errmsg="invalid UserID"
|
|
'Elseif CouponCode="" Then
|
' errcode=40625
|
' errmsg="invalid CouponCode"
|
|
Else
|
'1 羊城通六榕街社区服务中心活动 发优惠券: 市内20*10 100公里以上150*5
|
'羊城通,慈爱嘉,福寿康,美好家园,珠江健康,谷丰,安颐通,中山二院,省二医,闪互 (CouponCode="1244" Or InStr(CouponCode,"Iid")>0) And
|
If DateDiff("d",now(),"2024-6-30")<=0 And DateDiff("d",now(),"2024-12-31")>=0 Then
|
sql="select * from Coupon where CouponDate_Ent>=getdate() and (CouponCode='"&CouponCode&"' or CouponCode like 'Iid%') and ToUserID="&UserID
|
rs.open Sql,objConn,1,1
|
If rs.Eof then
|
CouponMoney=20
|
CouponRemarks="广州市中心七区行政区域内可使用"
|
CouponName="市内福祉车出行(就医出行、日常出行)20元代金券"
|
If UserID="" Then UserID=0
|
for i=1 to 10
|
CouponNO=DTimeID()&getIDnumbers(6)
|
sql="Insert into Coupon (CouponNO,CouponName,CouponMoney,CouponDate_Ent,CouponRemarks,ServiceOrdIDPK,ToUserID,CouponCode) values ('"&CouponNO&"','"&CouponName&"',"&CouponMoney&",getdate()+90,'"&CouponRemarks&"',0,"&UserID&",'"&CouponCode&"')"
|
objConn.Execute sql
|
Next
|
|
CouponMoney=150
|
CouponRemarks="广东内单程转运距离100公里以上可使用"
|
CouponName="福祉车旅游陪护150元代金券"
|
for i=1 to 5
|
CouponNO=DTimeID()&getIDnumbers(6)
|
If UserID="" Then UserID=0
|
sql="Insert into Coupon (CouponNO,CouponName,CouponMoney,CouponDate_Ent,CouponRemarks,ServiceOrdIDPK,ToUserID,CouponCode) values ('"&CouponNO&"','"&CouponName&"',"&CouponMoney&",getdate()+90,'"&CouponRemarks&"',0,"&UserID&",'"&CouponCode&"')"
|
objConn.Execute sql
|
Next
|
|
webJson="""UserInformation"":{""Title"":""优惠券领取成功"",""Content"":"""",""PicUrl"":""https://api.966120.com.cn/OA_img/20240401200013.png"",""Url"":"""",""OpenType"":""""}"
|
Else
|
errcode=40627
|
errmsg="重复领取"
|
End If
|
rs.close()
|
Else
|
errcode=40626
|
errmsg="invalid CouponCode"
|
End If
|
End If
|
|
If webJson<>"" Then
|
webJson="{""method"":""User_getCoupon"",""result"":1,"&webJson&"}"
|
End If
|
|
'用户清空优惠券 end
|
case "User_dalCoupon" '用户清空优惠券
|
'必须
|
UserID = trim(Request("UserID")) '用户唯一ID
|
|
errcode=1
|
|
if UserID="" Or Not IsNumeric(UserID) Then
|
errcode=40624
|
errmsg="invalid UserID"
|
|
Else
|
sql="delete from Coupon where ToUserID="&UserID
|
objConn.Execute sql
|
|
webJson="""resultOK"":1"
|
End If
|
|
If webJson<>"" Then
|
webJson="{""method"":""User_dalCoupon"",""result"":1,"&webJson&"}"
|
End If
|
|
'用户领取优惠券 end
|
|
case "User_CouponsList" '会员优惠券列表
|
'必须
|
UserID=trim(Request("UserID")) '购物系统会员ID
|
|
'可选
|
CouponsListType=trim(Request("CouponsListType")) '列表类型(1未使用,2已使用,3已过期)
|
|
'写入默认值
|
If UserID="undefined" Then UserID=""
|
If CouponsListType="" Then CouponsListType=1
|
|
'查找数据库
|
If UserID="" Then
|
errcode=40071
|
errmsg="invalid UserID"
|
ElseIf CouponsListType=2 Then
|
'2已使用
|
webJson = """UserID"":"""&UserID&""",""CouponsList"":["
|
i=0
|
sql="select * from Coupon where CouponState=1 and ToUserID="&UserID&" order by CouponDate desc"
|
'Response.Write sql &"<br>"
|
rs.open sql,objConn,1,1
|
do while not rs.Eof
|
Did = rs("id")
|
D_No = rs("CouponNO")
|
D_Name = rs("CouponName") '优惠券名称
|
D_NameSP = SPLIT(D_Name,"-")
|
If UBOUND(D_NameSP)>=1 Then
|
D_Name=D_NameSP(0)
|
LimitTXT=D_NameSP(1)
|
Else
|
D_Name=D_Name
|
LimitTXT=Mid(D_No,1,4)&" "&Mid(D_No,4,4)&" "&Mid(D_No,8,4)&" "&Mid(D_No,12,4)
|
End If
|
UserMoney = Abs(rs("CouponMoney")) '优惠券金额
|
time1 = rs("CouponDate") '使用时间
|
time2 = FormatDateTime(rs("CouponDate_Ent"),2) '有效时间
|
UseURL = "pages/index/index" '转跳连接
|
CouponRemarks = rs("CouponRemarks") '使用说明
|
|
If i>0 Then webJson=webJson&","
|
webJson=webJson&"{""CouponId"":"""&Did&""",""CouponNo"":"""&LimitTXT&""",""CouponName"":"""&D_Name&""",""CouponMoney"":"""&UserMoney&""",""CouponTime"":"""&time2&""",""CouponLimit"":"""&CouponRemarks&"""}"
|
i=i+1
|
rs.movenext
|
loop
|
rs.close()
|
webJson = webJson&"]"
|
ElseIf CouponsListType=3 Then
|
'3已过期
|
webJson = """UserID"":"""&UserID&""",""CouponsList"":["
|
i=0
|
sql="select * from Coupon where CouponState=0 and datediff(ss,getdate(),CouponDate_Ent)<0 and ToUserID="&UserID&" order by CouponDate desc"
|
'Response.Write sql &"<br>"
|
rs.open sql,objConn,1,1
|
do while not rs.Eof
|
Did = rs("id")
|
D_No = rs("CouponNO")
|
D_Name = rs("CouponName") '优惠券名称
|
D_NameSP = SPLIT(D_Name,"-")
|
If UBOUND(D_NameSP)>=1 Then
|
D_Name=D_NameSP(0)
|
LimitTXT=D_NameSP(1)
|
Else
|
D_Name=D_Name
|
LimitTXT=Mid(D_No,1,4)&" "&Mid(D_No,4,4)&" "&Mid(D_No,8,4)&" "&Mid(D_No,12,4)
|
End If
|
UserMoney = Abs(rs("CouponMoney")) '优惠券金额
|
time1 = rs("CouponDate") '使用时间
|
time2 = FormatDateTime(rs("CouponDate_Ent"),2) '有效时间
|
UseURL = "pages/index/index" '转跳连接
|
CouponRemarks = rs("CouponRemarks") '使用说明
|
|
If i>0 Then webJson=webJson&","
|
webJson=webJson&"{""CouponId"":"""&Did&""",""CouponNo"":"""&LimitTXT&""",""CouponName"":"""&D_Name&""",""CouponMoney"":"""&UserMoney&""",""CouponTime"":"""&time2&""",""CouponLimit"":"""&CouponRemarks&"""}"
|
i=i+1
|
rs.movenext
|
loop
|
rs.close()
|
webJson = webJson&"]"
|
Else
|
'1未使用
|
webJson = """UserID"":"""&UserID&""",""CouponsList"":["
|
i=0
|
sql="select * from Coupon where CouponState=0 and datediff(ss,getdate(),CouponDate_Ent)>=0 and ToUserID="&UserID&" order by CouponDate desc"
|
'Response.Write sql &"<br>"
|
rs.open sql,objConn,1,1
|
do while not rs.Eof
|
Did = rs("id")
|
D_No = rs("CouponNO")
|
D_Name = rs("CouponName") '优惠券名称
|
D_NameSP = SPLIT(D_Name,"-")
|
If UBOUND(D_NameSP)>=1 Then
|
D_Name=D_NameSP(0)
|
LimitTXT=D_NameSP(1)
|
Else
|
D_Name=D_Name
|
LimitTXT=Mid(D_No,1,4)&" "&Mid(D_No,4,4)&" "&Mid(D_No,8,4)&" "&Mid(D_No,12,4)
|
End If
|
UserMoney = Abs(rs("CouponMoney")) '优惠券金额
|
time1 = rs("CouponDate") '使用时间
|
time2 = FormatDateTime(rs("CouponDate_Ent"),2) '有效时间
|
UseURL = "pages/h5/h5?src=https://api.966120.com.cn/user/UserCoupons.php@D_No#"&D_No&"$CouponName#"&rs("CouponName") '转跳连接
|
CouponRemarks = rs("CouponRemarks") '使用说明
|
|
If i>0 Then webJson=webJson&","
|
webJson=webJson&"{""CouponId"":"""&Did&""",""CouponNo"":"""&LimitTXT&""",""CouponName"":"""&D_Name&""",""CouponMoney"":"""&UserMoney&""",""CouponTime"":"""&time2&""",""CouponLimit"":"""&CouponRemarks&"""}"
|
i=i+1
|
rs.movenext
|
loop
|
rs.close()
|
webJson = webJson&"]"
|
End If
|
|
If webJson<>"" Then
|
webJson="{""method"":""User_CouponsList"",""result"":1,"&webJson&",""total"":"""&i&"""}"
|
End If
|
'会员优惠券列表 end
|
|
case "User_Information" '用户公告
|
'必须
|
UserID = trim(Request("UserID")) '用户ID
|
wxOpenid = trim(Request("wxOpenid")) '微信OpenID
|
pages = trim(Request("pages")) '当前页面链接
|
|
'可选
|
|
'写入默认值
|
If pages="" Then pages="index"
|
If not IsNumeric(UserID) Then UserID=0
|
If wxOpenid="undefined" Then wxOpenid=""
|
If UserID="" Then UserID=0
|
|
FormIDInt=0 '总用户已收到公告数量
|
FormIDInt1=0 '最近一天用户已收到公告数量
|
FormIDInt7=0 '最近一周用户已收到公告数量
|
|
'页面转跳类型说明
|
'OpenType switchTab 转跳底部主页面,navigateTo 转跳内容页面,reLaunch 关闭所有页面并转跳页面,redirectTo 关闭当前页面并转跳内页
|
|
'查找数据库
|
If wxOpenid<>"" Then
|
'检查wxOpenid同期公告次数
|
sql="select count(id) from UserInformation where datediff(Hour,InformationTime,GETDATE())<24 and ToWxOpenID='"&wxOpenid&"'"
|
rs.open sql,objConn,1,1
|
FormIDInt1=rs(0)
|
rs.close()
|
sql="select count(id) from UserInformation where datediff(Hour,InformationTime,GETDATE())<168 and ToWxOpenID='"&wxOpenid&"'"
|
rs.open sql,objConn,1,1
|
FormIDInt7=rs(0)
|
rs.close()
|
sql="select count(id) from UserInformation where ToWxOpenID='"&wxOpenid&"'"
|
rs.open sql,objConn,1,1
|
FormIDInt=rs(0)
|
rs.close()
|
ElseIf UserID<>0 Then
|
'检查UserID同期公告次数
|
sql="select count(id) from UserInformation where datediff(Hour,InformationTime,GETDATE())<24 and ToUserID="&UserID
|
rs.open sql,objConn,1,1
|
FormIDInt1=rs(0)
|
rs.close()
|
sql="select count(id) from UserInformation where datediff(Hour,InformationTime,GETDATE())<168 and ToUserID="&UserID
|
rs.open sql,objConn,1,1
|
FormIDInt7=rs(0)
|
rs.close()
|
sql="select count(id) from UserInformation where ToUserID="&UserID
|
rs.open sql,objConn,1,1
|
FormIDInt=rs(0)
|
rs.close()
|
End If
|
|
'wxOpenid="okHIJ0Y3jT30pJJhVwCmdHgPu8Kk" Or UserID="6129" Or userid="6237" Or userid="10"
|
'20.01.14活动
|
If UserID<>"0" Then
|
'webJson="""UserInformation"":{""Title"":""用户优惠券"",""Content"":"""",""PicUrl"":""https://api.966120.com.cn/OA_img/ad_20230419.png"",""Url"":""/pages/my/coupon/coupon"",""OpenType"":""navigateTo""}"
|
webJson="""UserInformation"":{""Title"":""用户优惠券"",""Content"":"""",""PicUrl"":""https://api.966120.com.cn/OA_img/ad_20230727.png"",""Url"":"""",""OpenType"":""""}"
|
Else
|
webJson="""UserInformation"":0"
|
End If
|
|
If webJson<>"""UserInformation"":0" Then
|
'记录公告次数
|
sql="insert into UserInformation (ToUserID,ToWxOpenID,UserPages) values ("&UserID&",'"&wxOpenid&"','"&pages&"')"
|
objConn.Execute sql
|
End If
|
|
'webJson="""UserInformation"":{""Title"":""首页公告"",""Content"":""公告内容测试"",""PicUrl"":""http://m.v.com.cn/images/2018091601.jpg"",""Url"":""""}"
|
'webJson="""UserInformation"":{""Title"":""首页公告"",""Content"":""公告内容测试公告内容测试公告内容测试公告内容测试公告内容测试公告内容测试公告内容测试"",""PicUrl"":"""",""Url"":""""}"
|
|
If webJson<>"" Then
|
webJson="{""method"":""User_Information"",""result"":1,"&webJson&"}"
|
End If
|
'用户公告 end
|
|
case "Points_UserList" '用户推荐人员记录
|
'必须
|
UserID = trim(Request("UserID")) '用户ID
|
|
'可选
|
page_no = trim(Request("page_no")) '页码(默认1)
|
page_size = trim(Request("page_size")) '每页显示数量(默认20,最大100)
|
|
'写入默认值
|
If UserID="undefined" Then UserID=""
|
If CouponsListType="" Then CouponsListType=1
|
If page_no="" Then page_no=1
|
If page_size="" Then page_size=20
|
If CInt(page_size)>100 Then page_size=100
|
total=0
|
totalMoney=0
|
totalPoints=0
|
errcode=1
|
|
'查找数据库
|
If UserID="" Then
|
errcode=40071
|
errmsg="invalid UserID"
|
Else
|
'测试
|
'UserID=53
|
webJson=""
|
sql="select UserID,UserName,UserLevel from UserData where UserID="&UserID
|
rs.open sql,objConn,1,1
|
if not rs.eof Then
|
UserID = rs("UserID")
|
UserName = rs("UserName")
|
UserLevel = rs("UserLevel")
|
Else
|
errcode=40071
|
errmsg="invalid UserID"
|
End If
|
rs.close()
|
If errcode=1 Then
|
webJson = """UserID"":"""&UserID&""",""Points_UserList"":["
|
i=0
|
'sql="select UserID,UserName,UserLevel,NoteName,UserPhone,UserNickName,UserAvatarUrl,RecommendTime=CONVERT(varchar(20),RecommendTime,111),sumUser=(select COUNT(UserID) from UserData as b where b.RecommendUserID=a.UserID),RecommendUserID,sumOrdInt=(select COUNT(DispatchOrdID) from ServiceOrder,DispatchOrd where DispatchOrd.ServiceOrdIDDt=ServiceOrdID and ServiceOrdUserID=a.UserID and DispatchOrdState=8),sumPaidMoney=(select isnull(sum(PaidMoney),0) from ServiceOrder,DispatchOrd,PaidMoney where DispatchOrd.ServiceOrdIDDt=ServiceOrdID and PaidMoney.ServiceOrdIDDt=ServiceOrdID and PaidMoney<>0 and ServiceOrdUserID=a.UserID and DispatchOrdState=8) from UserData as a LEFT JOIN UserRecommendNote on ToUserID=UserID and ToRUserID=RecommendUserID where RecommendUserID="&UserID&" order by RecommendTime desc"
|
|
sql="select UserID,UserName,NoteName,UserPhone,UserNickName,UserAvatarUrl,RecommendTime,sumUser=(select COUNT(UserID) from UserData as b where b.RecommendUserID=a1.UserID),COUNT(ServiceOrdID) sumOrdInt,sum(isnull(sumPaidMoney,0)) sumPaidMoney from (select a.UserID,a.UserName,NoteName,a.UserPhone,a.UserNickName,a.UserAvatarUrl,a.RecommendTime,isnull(ServiceOrdID,0) ServiceOrdID,sum(isnull(PaidMoney,0)) sumPaidMoney from Welcab.dbo.UserData a LEFT JOIN Welcab.dbo.UserRecommendNote on ToUserID=UserID and ToRUserID=RecommendUserID LEFT JOIN Welcab.dbo.ServiceOrder on ServiceOrdUserID=a.UserID and ServiceOrdState<>4 LEFT JOIN Welcab.dbo.PaidMoney on PaidMoney.ServiceOrdIDDt=ServiceOrder.ServiceOrdID and PaidMoney<>0 where a.RecommendUserID="&UserID&" GROUP BY a.UserID,a.UserName,NoteName,a.UserPhone,a.UserNickName,a.UserAvatarUrl,a.RecommendTime,ServiceOrdID ) a1 GROUP BY UserID,UserName,NoteName,UserPhone,UserNickName,UserAvatarUrl,RecommendTime order by RecommendTime"
|
'Response.Write sql
|
rs.open sql,objConn,1,1
|
if not rs.eof then
|
rs.pagesize=page_size
|
rs.absolutepage=page_no
|
total=rs.recordcount
|
end If
|
do while not rs.Eof and i<CInt(page_size)
|
P_UserID = rs("UserID")
|
P_UserName = rs("UserName")
|
P_NoteName = rs("NoteName")
|
P_UserPhone = rs("UserPhone")
|
P_UserNickName = rs("UserNickName")
|
P_UserAvatarUrl = rs("UserAvatarUrl")
|
P_RecommendTime = rs("RecommendTime")
|
P_sumUser = rs("sumUser")
|
P_sumOrdInt = rs("sumOrdInt")
|
P_sumPaidMoney = rs("sumPaidMoney")
|
totalMoney=totalMoney+P_sumPaidMoney
|
|
P_sumPoints = CInt(P_sumPaidMoney*0.1)
|
totalPoints=totalPoints+P_sumPoints
|
|
If P_sumPaidMoney<=0 Then P_sumOrdInt=0
|
If P_NoteName="" Or Isnull(P_NoteName) Then P_NoteName=P_UserName
|
If P_NoteName="" Or Isnull(P_NoteName) Then P_NoteName=P_UserNickName
|
If P_NoteName="" Or Isnull(P_NoteName) Then P_NoteName="微信用户"
|
|
If i>0 Then webJson=webJson&","
|
webJson=webJson&"{""P_UserID"":"""&P_UserID&""",""P_NoteName"":"""&P_NoteName&""",""P_UserPhone"":"""&P_UserPhone&""",""P_UserAvatarUrl"":"""&P_UserAvatarUrl&""",""P_RecommendTime"":"""&P_RecommendTime&""",""P_sumOrdInt"":"""&P_sumOrdInt&""",""P_sumPaidMoney"":"""&P_sumPaidMoney&""",""P_sumPoints"":"""&P_sumPoints&"""}"
|
i=i+1
|
rs.movenext
|
loop
|
rs.close()
|
webJson = webJson&"],""total"":"""&total&""",""totalMoney"":"""&totalMoney&""",""totalPoints"":"""&totalPoints&""""
|
End If
|
End If
|
|
If webJson<>"" Then
|
webJson="{""method"":""Points_UserList"",""result"":1,"&webJson&"}"
|
End If
|
|
'用户推荐人员记录 end
|
|
case "Points_NoteNameUpdate" '用户推荐人员姓名修改
|
'必须
|
UserID = trim(Request("UserID")) '用户ID
|
ToUserID = trim(Request("ToUserID")) '推荐用户ID
|
ToNoteName = trim(Request("ToNoteName")) '推荐用户名称
|
|
errcode=1
|
|
'查找数据库
|
If UserID="" Then
|
errcode=40071
|
errmsg="invalid UserID"
|
ElseIf ToUserID="" Then
|
errcode=40071
|
errmsg="invalid ToUserID"
|
ElseIf ToNoteName="" Then
|
errcode=40071
|
errmsg="invalid ToNoteName"
|
Else
|
'测试
|
'UserID=53
|
webJson=""
|
sql="select id from UserRecommendNote where ToRUserID="&UserID&" and ToUserID="&ToUserID
|
rs.open sql,objConn,1,1
|
if not rs.eof Then
|
id = rs("id")
|
End If
|
|
If errcode=1 Then
|
If id<>"" Then
|
sql="update UserRecommendNote set NoteName='"&ToNoteName&"',UpdateTime=getdate() where id="&id
|
objConn.Execute sql
|
Else
|
sql="insert into UserRecommendNote (ToUserID,ToRUserID,NoteName) values ("&ToUserID&","&UserID&",'"&ToNoteName&"')"
|
objConn.Execute sql
|
End If
|
webJson="{""method"":""Points_NoteNameUpdate"",""result"":1}"
|
End If
|
End If
|
'用户推荐人员姓名修改 end
|
|
case "Points_List" '用户积分记录
|
'必须
|
UserID = trim(Request("UserID")) '用户ID
|
Points_Type = trim(Request("Points_Type")) '查询类型
|
|
'可选
|
page_no = trim(Request("page_no")) '页码(默认1)
|
page_size = trim(Request("page_size")) '每页显示数量(默认20,最大100)
|
|
'写入默认值
|
If UserID="undefined" Then UserID=""
|
If Points_Type="undefined" Then Points_Type=""
|
If page_no="" Then page_no=1
|
If page_size="" Then page_size=20
|
If CInt(page_size)>100 Then page_size=100
|
total=0
|
errcode=1
|
'查找数据库
|
If UserID="" Then
|
errcode=40071
|
errmsg="invalid UserID"
|
Else
|
'测试
|
'UserID=53
|
webJson=""
|
sql="select UserID,UserName,UserLevel from UserData where UserID="&UserID
|
rs.open sql,objConn,1,1
|
if not rs.eof Then
|
UserID = rs("UserID")
|
UserName = rs("UserName")
|
UserLevel = rs("UserLevel")
|
Else
|
errcode=40071
|
errmsg="invalid UserID"
|
End If
|
rs.close()
|
If errcode=1 Then
|
webJson = """UserID"":"""&UserID&""",""Points_List"":["
|
i=0
|
sql="select * from dbo.UserPoints where ToUserID="&UserID&" and Points_State<>4 order by Points_Time desc"
|
'Response.Write sql&"<br>"
|
rs.open sql,objConn,1,1
|
if not rs.eof then
|
rs.pagesize=page_size
|
rs.absolutepage=page_no
|
total=rs.recordcount
|
end If
|
do while not rs.Eof and i<=CInt(page_size)
|
Pid = rs("Pid")
|
P_Score = rs("Points_Score") '积分
|
P_Type = rs("Points_Type")
|
P_Time = FormatDateTime(rs("Points_Time"),2)&" "&FormatDateTime(rs("Points_Time"),4)
|
P_State = rs("Points_State")
|
P_Value1 = rs("Points_Value1")
|
P_Value2 = rs("Points_Value2")
|
P_Value3 = rs("Points_Value3")
|
P_ServiceOrdIDDt= rs("ServiceOrdIDDt")
|
If P_Type="1" Then '1.消费积分:自己消费产生的积分(任务单号、任务时间、积分)
|
P_TypeName="消费积分"
|
ElseIf P_Type="2" Then '2.转入积分:别人转赠给你的积分(转让人、转入时间、积分)
|
P_TypeName="转入积分"
|
ElseIf P_Type="3" Then '3.推荐积分:推荐其他用户消费产生的积分(微信头像、微信昵称、下单时间、积分)
|
P_TypeName="推荐积分"
|
ElseIf P_Type="4" Then '4.积分提现:(提现方式、提现单号、处理状态、提现时间、积分)
|
P_TypeName="积分提现"
|
ElseIf P_Type="5" Then '5.转出积分:转赠给别人的积分(转让人、转入时间、积分)
|
P_TypeName="转出积分"
|
End If
|
If i>0 Then webJson = webJson&","
|
webJson = webJson&"{""P_Type"":"""&P_Type&""",""P_TypeName"":"""&P_TypeName&""",""P_Value1"":"""&P_Value1&""",""P_Value2"":"""&P_Value2&""",""P_Value3"":"""&P_Value3&""",""P_Time"":"""&P_Time&""",""P_Score"":"""&P_Score&"""}"
|
i=i+1
|
rs.movenext
|
loop
|
rs.close()
|
sql="select isnull(SUM(Points_Score),0) Points_Score from UserPoints where ToUserID="&UserID
|
rs.open sql,objConn,1,1
|
totalMoney = rs("Points_Score")
|
rs.close()
|
webJson = webJson&"],""total"":"""&total&""",""totalMoney"":"""&totalMoney&""""
|
End If
|
End If
|
|
If webJson<>"" Then
|
webJson="{""method"":""Points_List"",""result"":1,"&webJson&"}"
|
End If
|
'用户积分记录 end
|
|
|
case "Points_Transfer" '用户积分转赠
|
'必须
|
UserID = trim(Request("UserID")) '用户ID
|
wxOpenid = trim(Request("wxOpenid")) '微信OpenID
|
ToPhone = trim(Request("ToPhone")) '目标用户手机号
|
ToScore = trim(Request("ToScore")) '申请转赠积分
|
|
errcode=1
|
|
'查找数据库
|
If UserID="" Or UserID="undefined" Then
|
errcode=40071
|
errmsg="invalid UserID"
|
ElseIf wxOpenid="" Or wxOpenid="undefined" Then
|
errcode=40072
|
errmsg="invalid wxOpenid"
|
ElseIf ToPhone="" Or ToPhone="undefined" Then
|
errcode=40073
|
errmsg="invalid ToPhone"
|
ElseIf ToScore="" Or ToScore="undefined" Or ToScore="0" Then
|
errcode=40074
|
errmsg="invalid ToScore"
|
End If
|
|
If errcode=1 Then '用户检查
|
sql="select top 1 id,ToUserID,UserPhone from weixinOpenID,UserData where UserID=ToUserID and UserID="&UserID&" and OpenID='"&wxOpenid&"' order by LoginTime desc"
|
rs.open sql,objConn,1,1
|
if Not rs.eof Then
|
UserPhone = rs("UserPhone")
|
Else
|
errcode=40075
|
errmsg="invalid UserID"
|
End If
|
rs.close()
|
End If
|
If errcode=1 Then '查询转赠用户UserID
|
sql="select UserID from UserData,UserPhone where UserID=ToUserID and strPhone='"&ToPhone&"' and strPhone<>'"&UserPhone&"'"
|
rs.open sql,objConn,1,1
|
if Not rs.eof Then
|
ToUserID=rs("UserID")
|
Else
|
errcode=40077
|
errmsg="invalid ToPhone"
|
errcode=1
|
webJson="{""method"":""Points_Transfer"",""result"":1,""TransferScore"":"&ToScore&"}"
|
End If
|
rs.close()
|
End If
|
If errcode=1 Then '可用积分检查
|
sql="select isnull(SUM(Points_Score),0) Points_Score from UserPoints where ToUserID="&UserID
|
rs.open sql,objConn,1,1
|
U_Score = rs("Points_Score")
|
if CInt(U_Score)<CInt(ToScore) Then
|
errcode=40076
|
errmsg="invalid ToScore"
|
End If
|
rs.close()
|
'测试
|
'errcode=1
|
'webJson="{""method"":""Points_Transfer"",""result"":1,""TransferScore"":"&ToScore&"}"
|
End If
|
If errcode=1 Then '积分转赠
|
sql="Insert into UserPoints (ToUserID,Points_Score,Points_Type,Points_State,Points_Value1) values ("&UserID&","&-ToScore&",5,1,'"&ToPhone&"')"
|
objConn.Execute sql
|
sql="Insert into UserPoints (ToUserID,Points_Score,Points_Type,Points_State,Points_Value1) values ("&ToUserID&","&ToScore&",2,1,'"&UserPhone&"')"
|
objConn.Execute sql
|
webJson="{""method"":""Points_Transfer"",""result"":1,""TransferScore"":"&ToScore&"}"
|
End If
|
'用户积分转赠 end
|
|
case "Points_QueryCash" '用户可提现金额查询
|
'必须
|
UserID = trim(Request("UserID")) '用户ID
|
wxOpenid = trim(Request("wxOpenid")) '微信OpenID
|
|
errcode=1
|
|
'查找数据库
|
If UserID="" Or UserID="undefined" Then
|
errcode=40071
|
errmsg="invalid UserID"
|
ElseIf wxOpenid="" Or wxOpenid="undefined" Then
|
errcode=40072
|
errmsg="invalid wxOpenid"
|
End If
|
|
If errcode=1 Then '用户检查
|
sql="select top 1 id,ToUserID,UserPhone from weixinOpenID,UserData where UserID=ToUserID and UserID="&UserID&" and OpenID='"&wxOpenid&"' order by LoginTime desc"
|
rs.open sql,objConn,1,1
|
if Not rs.eof Then
|
UserPhone = rs("UserPhone")
|
Else
|
errcode=40073
|
errmsg="invalid wxOpenid"
|
End If
|
rs.close()
|
End If
|
If errcode=1 Then '可用积分检查
|
sql="select isnull(SUM(Points_Score),0) Points_Score from UserPoints where ToUserID="&UserID
|
rs.open sql,objConn,1,1
|
QueryCash = rs("Points_Score")
|
rs.close()
|
'测试
|
'QueryCash=200
|
webJson="{""method"":""Points_QueryCash"",""result"":1,""QueryCash"":"&QueryCash&"}"
|
End If
|
'用户可提现金额查询 end
|
|
case "Points_WithdrawalCash" '用户提现申请(未完成)
|
'必须
|
UserID = trim(Request("UserID")) '用户ID
|
wxOpenid = trim(Request("wxOpenid")) '微信OpenID
|
|
errcode=1
|
WithdrawalCash=0
|
|
'查找数据库
|
If UserID="" Or UserID="undefined" Then
|
errcode=40071
|
errmsg="invalid UserID"
|
ElseIf wxOpenid="" Or wxOpenid="undefined" Then
|
errcode=40072
|
errmsg="invalid wxOpenid"
|
End If
|
|
If errcode=1 Then '用户检查
|
sql="select top 1 id,ToUserID,UserPhone from weixinOpenID,UserData where UserID=ToUserID and UserID="&UserID&" and OpenID='"&wxOpenid&"' order by LoginTime desc"
|
rs.open sql,objConn,1,1
|
if Not rs.eof Then
|
UserPhone = rs("UserPhone")
|
Else
|
errcode=40073
|
errmsg="invalid wxOpenid"
|
End If
|
rs.close()
|
End If
|
If errcode=1 Then '可用积分检查
|
sql="select isnull(SUM(Points_Score),0) Points_Score from UserPoints where ToUserID="&UserID
|
rs.open sql,objConn,1,1
|
QueryCash = rs("Points_Score")
|
rs.close()
|
End If
|
|
If errcode=1 And WithdrawalCash>200 Then '积分提现(未完成)
|
sql="Insert into UserPoints (ToUserID,Points_Score,Points_Type,Points_State,Points_Value1,Points_Value2,Points_Value3) values ("&UserID&","&-WithdrawalCash&",4,1,'微信零钱','2023070522001460581413748642','提现完成')"
|
objConn.Execute sql
|
webJson="{""method"":""Points_WithdrawalCash"",""result"":1,""WithdrawalCash"":"&WithdrawalCash&"}"
|
Else
|
errcode=40073
|
errmsg="invalid QueryCash"
|
End If
|
'用户提现申请 end
|
|
case "UserCodeScene" '生成用户个人二维码参数
|
'必须
|
UserID = trim(Request("UserID")) '用户ID
|
|
errcode=1
|
|
'查找数据库
|
If UserID="" Or UserID="undefined" Then
|
errcode=40071
|
errmsg="invalid UserID"
|
End If
|
|
If errcode=1 Then '用户检查
|
sql="select UserID,UserLevel,UserSource from UserData where UserID="&UserID
|
rs.open sql,objConn,1,1
|
if Not rs.eof Then
|
UserID = rs("UserID")
|
UserLevel = rs("UserLevel")
|
UserSource = rs("UserSource")
|
Else
|
errcode=40073
|
errmsg="invalid UserID"
|
End If
|
rs.close()
|
End If
|
|
If errcode=1 Then
|
scene="S=Rid"&UserID
|
If UserLevel=2 And UserSource<>"" Then
|
scene = scene&"/"&UserSource
|
End If
|
webJson="{""method"":""UserCodeScene"",""result"":1,""UserID"":"&UserID&",""scene"":"""&scene&"""}"
|
End If
|
'生成用户个人二维码参数 end
|
|
case else
|
errcode=40004
|
errmsg="invalid method"
|
end Select
|
End If
|
|
rsRollbackTrans(objConn.Errors.count)
|
|
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
|
|
'Post方法
|
Function PostBody(appUrl,args1)
|
Set PBrs = Server.CreateObject("ADODB.Recordset")
|
sql="select id from API_Json where DATEDIFF (ss,Json_time,GETDATE())<=30 and Json='"&args1&"'"
|
PBrs.open sql,objConn,1,1
|
If PBrs.Eof Then
|
Set https = Server.CreateObject("Msxml2.ServerXMLHTTP")
|
|
'Set https = Server.CreateObject("MSXML2.XMLHTTP")
|
With https
|
.Open "Post", appUrl, False
|
.setRequestHeader "Content-Type","application/x-www-form-urlencoded"
|
.Send args1
|
PostBody = .ResponseBody
|
End With
|
PostBody = BytesToBstr(PostBody,"utf-8")
|
Set https = Nothing
|
End If
|
PBrs.close()
|
End Function
|
Function BytesToBstr(body,Cset) '飘易:转换GB2312
|
dim objstream
|
set objstream = Server.CreateObject("adodb.stream")
|
objstream.Type = 1
|
objstream.Mode =3
|
objstream.Open
|
objstream.Write body
|
objstream.Position = 0
|
objstream.Type = 2
|
objstream.Charset = Cset
|
BytesToBstr = objstream.ReadText
|
objstream.Close
|
set objstream = nothing
|
End Function
|
%>
|
|
<%If method="Article_detail" And trim(Request("aa"))="1" then%>
|
<textarea><%=webJson%></textarea>
|
<%End if%>
|