<!--#include virtual="/inc/conn.asp"-->
<!--#include virtual="/inc/sitecon.asp"-->
<!--#include virtual="/inc/md52.asp"-->
<!--#include virtual="/show/mokuai/sms.asp"-->
<%
On error resume next 
Server.ScriptTimeOut = 999999
	
Function randarr()
Const stringmodarr = "0123456789"
strlength = Len(stringmodarr)
Randomize timer
For i = 1 To 5 
randarr2 = randarr2&Mid(stringmodarr,Int(Rnd * strlength + 1),1)  
Next 
randarr=randarr2
End Function

function FillZero(str)
if len(str)=1 then
FillZero = "0"&str
else
FillZero=str
end if
end function

'创建财务流水号
function getcaiwuliushui(str)
if str="aycaiwu" then randarrcwku="A"
if str="aycaiwu01" then randarrcwku="B"
if str="aycaiwu02" then randarrcwku="C"
if str="aycaiwu03" then randarrcwku="D"
if str="aycaiwu04" then randarrcwku="E"
if str="aycaiwu05" then randarrcwku="F"
crandarrlei="C" 	'标示 D订单 C财务
crandarrhost="A" 	'服务器数据库
crandarrlast=Right(("00"&Month(Now())),2)&Right(("00"&Day(Now())),2)&Right(("00"&hour(Now())),2)&Right(("00"&minute(Now())),2)&Right(("00"&second(Now())),2)&randarr()
getcaiwuliushui=crandarrlei&crandarrhost&randarrcwku&crandarrlast
end function

'## 正文开始 ############################################################################################################################################################################

ischuli="no"	'是否有需要处理订单
isnext="ok"		'是否继续下一项操作
iserr="ok"		'发生错误状态  2成功 3无订单号 4重复订单 5sign错误
chulistr=""		

'## 获取订单 ############################################################################################################################################################################
rs.open "select top 4 aydddzt,aydddsum,aydddj from aybuylx where aydddzt=1",conn,1,3
if not(rs.bof and rs.eof) then 
	do while not rs.eof
	ischuli="yes"
	aydddsum=trim(rs("aydddsum"))
	aydddj=trim(rs("aydddj"))
	aylxku=getddku(aydddsum)
	chulistr=chulistr&aydddsum&","&aydddj&","&aylxku&"|"
	rs("aydddzt")=9		'处理中
	rs.update
	rs.movenext 
	loop
end if
rs.close 


'### 订单处理开始 ########################################################################################################################################################################
'#########################################################################################################################################################################################				
'#########################################################################################################################################################################################

'调试使用#############
'chulistr=""	
'ischuli="yes"
'aydddsum="DAB225514207913748"
'aydddj="DAB225514207913748"
'aylxku=getddku(aydddsum)
'chulistr=chulistr&trim(aydddsum)&","&trim(aydddj)&","&aylxku&"|"
'aydddsum2="DAB220814207906659"
'aydddj2="DAB220814207906659"
'aylxku2=getddku(aydddsum2)
'chulistr=chulistr&aydddsum2&","&aydddj2&","&aylxku2&"|"
'调试结束#############


if ischuli="yes" then
chulistr=mid(trim(chulistr),1,len(trim(chulistr))-1)
chulistr=split(chulistr,"|")

For shu=0 To Ubound(chulistr) 
ddchulistr=split(chulistr(shu),",")	
out_trade_no=ddchulistr(0)	'订单号
trade_no=ddchulistr(1)		'交易号
ddku=ddchulistr(2)			'订单库
		
		'监测支付回调记录
		set huitiaonum=conn.execute("select count(*) as num from aypayhuitiao where aypaydd='"&out_trade_no&"'")
		huitiaonumshu=huitiaonum("num")
		if cint(huitiaonumshu)=0 then
		'conn.execute "update "&ddku&" set aydingdanzt=0,ayddbody='"&now()&"-ddhuitiaonull' where aydingdansum='"&out_trade_no&"'"
		call logadd("0","payaoto-ddhuitiaonull-"&trim(out_trade_no)&"",0,1)
		'response.End()
		end if
			
		rs.open "select top 2 * from "&ddku&" where aydingdansum='"&out_trade_no&"' and aydingdanzt=0" ,conn,1,3	
		if rs.bof and rs.eof then
		rs.close
		isnext="no"
		iserr="ddnull"
		conn.execute "update "&ddku&" set aydingdanzt=0,ayddbody='"&now()&"-ddnull' where aydingdansum='"&out_trade_no&"'"
		call logadd("0","payok-ddnull-"&trim(out_trade_no)&"",0,1)
		end if
		
		if isnext="ok" then
			if rs.RecordCount>1 then 
			rs.close
			isnext="no"
			iserr="ddchongfu"
			conn.execute "update "&ddku&" set aydingdanzt=0,ayddbody='"&now()&"-ddchongfu' where aydingdansum='"&out_trade_no&"'"
			call logadd("0","payaoto-ddchongfu-"&trim(out_trade_no)&"",0,1)
			end if
		end if
		
		if isnext="ok" then
			if trim(rs("ddrebiaoshi"))<>rejiami then 
			rs.close
			isnext="no"
			iserr="rejiamierr"
			conn.execute "update "&ddku&" set aydingdanzt=0,ayddbody='"&now()&"-rejiamierr' where aydingdansum='"&out_trade_no&"'"
			call logadd("0","payaoto-rejiamierr-"&trim(out_trade_no)&"",0,1)
			end if
		end if
		
		if isnext="ok" then
			rs("aydingdanzt")=1
			rs("aydingdanjjhao")=trade_no         	 '付款交易号
			aydingdanuser=rs("aydingdanuser")        '商品所属会员ID
			ayddquantity=rs("ayddquantity")          '数量
			ayddshangid=rs("ayddshangid")            '商品ID
			aydingdanyj=rs("aydingdanyj")            '订单原价
			aydingdanjin=rs("aydingdanjin")          '订单单价
			aydingdanzj=rs("aydingdanzj")            '订单总价以及除去支付价值的总价
			ayddzffangshi=rs("ayddzffangshi")        '支付方式 0网银 1充值卡 2支付宝 3财付通 4快捷 99账户余额支付  10wap支付宝 12wap财付通 13wap微信 14wap qq
			ayddpid=trim(rs("ayddpid"))    		     '支付通道代码
			'ayddemail=rs("ayddemail")			     '买家通知邮箱
			ayddyouhuiquan=trim(rs("ayddyouhuiquan"))'优惠券信息
			aydingdanin=rs("aydingdanin")            '商户入账总价
			ayddcontact=trim(rs("ayddcontact"))      '联系方式
			aydigndanyf=rs("aydigndanyf")            '应付总价
			isalipayfz=rs("isalipayfz")              '支付宝分账
			yalipayfzfei=rs("alipayfzfei")		     '支付宝分账手续费
			apicheng=rs("apicheng")		             '接口纯利润
			shangqq=trim(rs("shangqq"))		         '商户QQ 
			aydingdansj=rs("aydingdansj")            '订单时间
			dailikuo=trim(rs("dailikuo"))            '代理关系
			openid=trim(rs("openid"))          		 '公众号直接购买 openid
			msnurl=trim(rs("msnurl"))          		 '手机短信接收卡密 短网址 空 -
			ayddsign=trim(rs("ayddsign"))
			qtgzh=rs("aydingdanuser")				 '其他公众号通知买家
			yongjin=rs("yongjin")				 	 '商户 个人 收款 应扣佣金
			rs.update
			rs.close 
		end if

		if isnext="ok" then
			strsign=""
			strsign=trim(out_trade_no) 
			strsign=strsign&trim(ayddpid) 
			strsign=strsign&ayddshangid
			strsign=strsign&aydingdanuser
			strsign=strsign&Formatnumber(aydigndanyf,4,true,-1,0)
			strsign=strsign&Formatnumber(aydingdanin,2,true,0,0)
			strsign=strsign&Formatnumber(aydingdanyj,4,true,-1,0)
			strsign=strsign&Formatnumber(aydingdanjin,4,true,-1,0)
			strsign=strsign&Formatnumber(aydingdanzj,4,true,-1,0)
			strsign=strsign&ptjiami
			if trim(MD5(strsign))<>trim(ayddsign) then
			conn.execute "update "&ddku&" set aydingdanzt=0,ayddbody='"&now()&"sign-signerr' where aydingdansum='"&out_trade_no&"'"
			isnext="no"
			iserr="signerr"
			end if
			
			'代理关系
			if dailikuo<>"" then 
			dailistr=split(dailikuo,"|")
			dailiuserstr=split(dailistr(Ubound(dailistr)),",") 	'获取最后一个代理关系 总代 |' dailiuserstr(5) '获取最后一个代理关系 dailiuserstr(5)卡密库 dailiuserstr(1)上级代理商品ID  dailiuserstr(4)上级代理ID
			dailijia=split(dailistr(0),",") 					'获取第一个代理关系 商品代理价  dailijia(9)
			liuliang=ccur(aydingdanzj)-ccur(dailijia(9)) 		'代理商品 代理商应入款
				
			'获取所有代理商ID 写入卡密 由代理卖出
			aykadstr=""
			For dailibuysum=0 To Ubound(dailistr) 
				didstr=split(dailistr(dailibuysum),",")
				aykadstr=aykadstr&tocunid(didstr(3))&","
			next
			end if
		end if

		if isnext="ok" then
			'获取商家信息
			rs.open "select * from ayname where aynameid="&clng(aydingdanuser)&"",conn,1,3		
			aymail=trim(rs("aymail"))
			kamiku=trim(rs("kamiku"))
			aytel=rs("aytel")
			isvipid=rs("isvipid")
			wxopenid=trim(rs("wxopenid"))
			aywebname=trim(rs("aywebname"))
			istelrz=rs("istelrz")
			tsmaichu=rs("tsmaichu")
			tskucun=rs("tskucun")
			ayweixinid=trim(rs("ayweixinid"))
			suijimd5=trim(rs("suijimd5"))
			cwku=trim(rs("cwku"))
			liuliang=aydingdanzj
			fashengyue=ccur(rs("ayyue"))+ccur(aydingdanin)
			fashengyuelog=aydingdanin
		
			if cint(isalipayfz)=1 then 	'******即时到帐功能*******
			fashengyue=ccur(rs("ayyue"))
			rs("ayalipayyu")=ccur(rs("ayalipayyu"))+ccur(aydingdanin)
			else
				if ccur(yongjin)>0 then	'个人收款 扣除佣金
				rs("yongjin")=ccur(rs("yongjin"))-ccur(yongjin)
				else
				rs("ayyue")=Formatnumber(fashengyue,3,true,-1,0)
				end if
			end if	
			rs("aychengjiao")=clng(rs("aychengjiao"))+1 			
			rs.update
			rs.close
			
			if dailikuo<>"" then '代理商品 获取第一个代理关系 上级ID
			oneuserstr=split(dailistr(0),",") 
			sjuserid=oneuserstr(4)
			else
			sjuserid=0
			end if
			'财务入款
			conn.Execute("Insert Into "&cwku&"(aycailiushui,aycaiwuleibie,aycaiwuuser,aycaiwudingdan,aycaiwudate,aycaiwuptjy,aycaiwujine,aycaiwuyue,aycaiwuzhifu,aycaiwupid,aycwfsjin,aycaiwuzt,isalipayfz,alipayfzfei,apicheng,shanguid) values('"&getcaiwuliushui(cwku)&"','0','"&clng(aydingdanuser)&"','"&out_trade_no&"','"&now()&"','"&trade_no&"','"&fashengyuelog&"','"&fashengyue&"','"&cint(ayddzffangshi)&"','"&ayddpid&"','"&liuliang&"','1','"&isalipayfz&"','"&yalipayfzfei&"','"&apicheng&"','"&sjuserid&"')")
		end if

		if isnext="ok" then
			'点卡入库
			if dailikuo<>"" then
			kaku=dailiuserstr(5)
			goodid=dailiuserstr(1)
			else
			kaku=kamiku
			goodid=ayddshangid
			end if
			conn.execute "update top ("&clng(ayddquantity)&") "&trim(kaku)&" set aykayesno=1,aykakai='"&now()&"',aykasuoyoudd='"&out_trade_no&"',aykatel='"&ayddcontact&"',aykadstr='"&aykadstr&"' where aykagoodid="&clng(goodid)&" and aykayesno=0"
			if err.number<>0 then 
			conn.Execute("Insert Into ayerr(errcon,errlu,errbei) values('"&Err.Description&"','inc/payaoto.asp位置-1','"&out_trade_no&"')")
			err.number=0
			end if
		end if


		'***********************************总代处理***************************************************************************************************************************
		'***********************************总代处理***************************************************************************************************************************
		if isnext="ok" then
			if dailikuo<>"" then	'1,21863,40,5896,5729,ayka07,aydingdan,aycaiwu,39.2,40|2,21868,40,5896,5729,ayka07,aydingdan,aycaiwu,39.2,40
			nextsum=0 '初始 隔一级 上级代理ID
			
			For dsum=0 To Ubound(dailistr) 
			
				'获取隔级 上级代理 用于查询下级代理销售订单
				nextsum=nextsum+1
				if nextsum>Ubound(dailistr) then  
				nextshagnji=0   '已无隔级 上级代理 
				else
				nextdailiuserstr=split(dailistr(nextsum),",")
				nextshagnji=nextdailiuserstr(4) '隔级上级代理ID
				end if
			
				'1,21863,40,5896,5729,ayka07,aydingdan,aycaiwu,39.2,40
				'dailiuserstr(0)序号    dailiuserstr(1)上级商品ID     dailiuserstr(2)上级商品代理价格     dailiuserstr(3)本商户ID     dailiuserstr(4)上级代理ID 
				'dailiuserstr(5)上级卡密库     dailiuserstr(6)上级订单库     dailiuserstr(7)上级财务库     dailiuserstr(8)上级代理入款  dailiuserstr(9)统计利润金额
				dailiuserstr=split(dailistr(dsum),",")  
				
				'查询套餐
				sql="select top 1 * from aytaocanlog where aytcuid="&clng(dailiuserstr(4))&" and aytczt=0 order by aytcid desc" 
				rs.open sql,conn,1,3
				if not(rs.bof and rs.eof) then
					if cint(rs("aytcisyear"))=1 then 		'包年套餐
						if DateDiff("d",rs("aytcbuyd"),now())<=clng(rs("aytcsj")) then  '套餐未过期
							z_aytcyearf=rs("aytcyearf")     '包年套餐手续费 
							z_apicheng=ccur(z_aytcyearf)-1
						end if	
					end if
				end if
				rs.close
						
				sql="select aynameid,ayyue,aychengjiao,ayalipayyu from ayname where aynameid="&clng(dailiuserstr(4))&"" 
				rs.open sql,conn,1,3
				fashengyue=ccur(rs("ayyue"))+ccur(dailiuserstr(8))	 '非套餐 上级代理应入账金额
				fashengyuelog=dailiuserstr(8)
				rs("ayyue")=Formatnumber(fashengyue,3,true,-1,0)
				rs("aychengjiao")=clng(rs("aychengjiao"))+1 
				rs.update
				rs.close
				
				'总代财务入款
				conn.Execute("Insert Into "&dailiuserstr(7)&"(aycailiushui,aycaiwuleibie,aycaiwuuser,aycaiwudingdan,aycaiwudate,aycaiwuptjy,aycaiwujine,aycaiwuyue,aycaiwuzhifu,aycaiwupid,aycwfsjin,aycaiwuzt,apicheng,shanguid) values('"&getcaiwuliushui(trim(dailiuserstr(7)))&"','18','"&clng(dailiuserstr(4))&"','"&out_trade_no&"','"&now()&"','"&trade_no&"','"&fashengyuelog&"','"&fashengyue&"','"&cint(ayddzffangshi)&"','"&ayddpid&"','"&dailiuserstr(9)&"','1','"&z_apicheng&"','"&nextshagnji&"')")
			next
			end if 
		end if

		if isnext="ok" then
			'优惠券信息
			if trim(ayddyouhuiquan)<>"" then
				sql="select ayyouhuiquan,ayyouhuiyesno,ayyouhuishiyong,ayyouhuishiyonid,ayyouhuiisty from ayyouhuiquan where ayyouhuiquan='"&trim(ayddyouhuiquan)&"'"
				rs.open sql,conn,1,3
				if not(rs.bof and rs.eof) then
					if rs("ayyouhuiyesno")=0 and rs("ayyouhuiisty")=0 then
					rs("ayyouhuiyesno")=1
					rs("ayyouhuishiyong")=now()
					rs.update
					end if
				end if
				rs.close 
			end if
		end if

		if isnext="ok" then
			'获取商品信息
			rs.open "select * from aygood where aygoodid="&ayddshangid&"" ,conn,1,1	
			aygoodname=trim(rs("aygoodname"))	'商品名称
			ayshoukatz=rs("ayshoukatz")			'是否售卡通知
			shoukatel=rs("shoukatel")			'售卡 手机通知
			shoukamail=rs("shoukamail")			'售卡 邮件通知
			shouikawx=rs("shouikawx")			'售卡 微信通知
			ayyujing=rs("ayyujing")				'预警数量
			ayyujingmss=rs("ayyujingmss")		'预警 站内信通知
			ayyujingmail=rs("ayyujingmail")		'预警 邮箱通知
			ayyujingtel=rs("ayyujingtel")		'预警 手机通知
			ayjujingwx=rs("ayjujingwx")			'预警 微信通知
			rs.close
		end if
		
		if isnext="ok" then
			'【商家】售卡通知*******************************************************************************************************************************
			if cint(ayshoukatz)=1 and cint(tsmaichu)=1 then
				title=webname&"-商品卖出通知" 
				body="<a href="&weburl&" target=_blank><img src="&weblogo&" border=0/></a><br><br><span style=color:#F60>商品：【"&aygoodname&"】 成功卖出:"&ayddquantity&"张<br>订单号："&out_trade_no&"<br>买家联系方式："&ayddcontact&"</span><br><br><a style=color:#F39 href="&weburl&"chaxun?ka="&out_trade_no&" target=_blank>【查看详细订单】</a> <a href="&weburl&"index/tuisong?a=tx&u="&aydingdanuser&"&k="&suijimd5&"&l=1 target=_blank>【退订该类通知】</a>"
				msbody="您的商品："&aygoodname&"，成功卖出："&ayddquantity&"张，订单号："&out_trade_no&""
			
				'售卡邮件通知
				if cint(shoukamail)=1 then
				conn.Execute("Insert Into mailto(mto,mti,mcon,mdd) values('"&aymail&"','"&trim(title)&"','"&trim(body)&"','"&trim(out_trade_no)&"')")
				end if
			
				'售卡手机通知	
				if cint(shoukatel)=1 and cint(istelrz)=1 and cint(isvipid)=1 then
				call mokuai_sms("IK08","1",aytel,msbody,aygoodname,ayddquantity,trim(out_trade_no),trim(out_trade_no))
				end if
			
				'售卡微信通知		
				if cint(shouikawx)=1 and wxopenid<>"" then
				wx1=trim(ayddcontact) 		'成交方
				wx2=aygoodname        		'商品名称
				wx3=ayddquantity			'成交数量
				wx4=Formatnumber(aydingdanzj,2,true,-1,0)'成交金额   
				wx5=aydingdansj			'成交时间
				conn.Execute("Insert Into mailto(mfs,wxlei,mto,wx1,wx2,wx3,wx4,wx5,mdd) values('2','0','"&wxopenid&"','"&wx1&"','"&wx2&"','"&wx3&"','"&wx4&"','"&wx5&"','"&trim(out_trade_no)&"')")
				end if
			end if
			
			'【商家】库存不足通知
			if clng(ayyujing)<>0 and cint(tskucun)=1 and dailikuo="" then
			'获取库存
			set rskanum=conn.execute("select count(*) as num from "&kamiku&" where aykagoodid="&ayddshangid&" and aykayesno=0")
			kakucun=rskanum("num")
					
				if ccur(ayyujing)>ccur(kakucun) then
					title=webname&"-商品库存不足" 
					body="<a href="&weburl&" target=_blank><img src="&weblogo&" border=0/></a><br><br><span style=color:#F60>商品：【"&aygoodname&"】 卡库存仅剩"&ccur(kakucun)-ccur(ayddquantity)&"张 请及时添加卡密</span><br><br><a href="&weburl&"index/tuisong?a=tx&u="&aydingdanuser&"&k="&suijimd5&"&l=2 target=_blank>【退订该类通知】</a>"
					msbody="您的商品："&aygoodname&",卡密库存仅剩"&ccur(kakucun)-ccur(ayddquantity)&"张,请及时添加卡密"
				
					'【商家】站内预警通知 
					if cint(ayyujingmss)=1 then
					time_start=year(now)&FillZero(month(now))&FillZero(day(now))&FillZero(hour(now))&FillZero(minute(now))&FillZero(second(now))
					conn.Execute("Insert Into aytongzhi(aytongzhilei,t4,aytongzhiuser,aytongzhidate,aytongzhibiao,aytongzhicon,suijiid) values('3','1','"&clng(aydingdanuser)&"','"&now()&"','"&title&"','"&body&"','"&trim(aydingdanuser)&time_start&"')")
					end if
									
					'【商家】邮箱预警通知	
					if cint(ayyujingmail)=1 then
					conn.Execute("Insert Into mailto(mto,mti,mcon,mdd) values('"&aymail&"','"&trim(title)&"','"&trim(body)&"','"&trim(out_trade_no)&"')")
					end if
					
					'【商家】手机预警通知
					if cint(ayyujingtel)=1 and cint(istelrz)=1 and cint(isvipid)=1 then
					call mokuai_sms("IK07","1",aytel,msbody,aygoodname,ccur(kakucun)-ccur(ayddquantity),"",trim(out_trade_no))
					end if
					
					'【商家】微信预警通知
					if cint(ayjujingwx)=1 and wxopenid<>"" then 
					wx1=aywebname 	'店铺名称
					wx2=aygoodname 	'商品名称
					wx3=ccur(kakucun)-ccur(ayddquantity) 	'库存数量
					conn.Execute("Insert Into mailto(mfs,wxlei,mto,wx1,wx2,wx3,mdd) values('2','1','"&wxopenid&"','"&wx1&"','"&wx2&"','"&wx3&"','"&trim(out_trade_no)&"')")
					end if
				end if	
			end if
			
			'【买家】邮箱通知***************************************************************************************************
			'if trim(ayddemail)<>"" then 
			'	title=webname&"-支付成功" 
			'	if showtel="yes" then
			'	body="<a href="&weburl&" target=_blank><img src="&weblogo&" border=0/></a><br><br><span style=color:#F60>您所购买商品：【"&aygoodname&"】 已经支付成功。<br>订单号："&out_trade_no&"<br>商家QQ："&shangqq&"<br>商家微信："&ayweixinid&"</span><br><br><a style=color:#F39 href="&weburl&"tika?ka="&out_trade_no&" target=_blank>【点击提取卡密】</a>&nbsp;&nbsp;<a style=color:#F39 href="&weburl&"jubao?cact=tscx&ddh="&out_trade_no&" target=_blank>【订单投诉退款】</a><br><br><span style=color:#F60>提示：商品的使用与售后请联系商家咨询！<br>如果在支付后遇到卡密无效等问题，请在支付后24小时内使用上面""订单投诉退款""链接进行投诉。<br>若商家在24小时内未处理好投诉问题，平台将直接退款。<br><br>平台受理投诉QQ："&fuwuqq&"<br>平台联系电话："&fuwutel&"</span>"
			'	else
			'	body="<a href="&weburl&" target=_blank><img src="&weblogo&" border=0/></a><br><br><span style=color:#F60>您所购买商品：【"&aygoodname&"】 已经支付成功。<br>订单号："&out_trade_no&"<br>商家QQ："&shangqq&"<br>商家微信："&ayweixinid&"</span><br><br><a style=color:#F39 href="&weburl&"tika?ka="&out_trade_no&" target=_blank>【点击提取卡密】</a>&nbsp;&nbsp;<a style=color:#F39 href="&weburl&"jubao?cact=tscx&ddh="&out_trade_no&" target=_blank>【订单投诉退款】</a><br><br><span style=color:#F60>提示：商品的使用与售后请联系商家咨询！<br>如果在支付后遇到卡密无效等问题，请在支付后24小时内使用上面""订单投诉退款""链接进行投诉。<br>若商家在24小时内未处理好投诉问题，平台将直接退款。<br></span>"
			'	end if
			'	conn.Execute("Insert Into mailto(mlei,mto,mti,mcon,mdd) values('2','"&trim(ayddemail)&"','"&title&"','"&body&"','"&trim(out_trade_no)&"')")
			'end if
							
			'【买家】微信通知	
			if openid<>"-" then
				'buykami=replace(buykami,"<br>","\n")
				wx1=aygoodname 		'商品名称
				wxtext="订单编号："&out_trade_no&"\n提取卡密：\n"&wapurl&"tika?ka="&out_trade_no    	'扩展信息
				conn.Execute("Insert Into mailto(mlei,mfs,wxlei,mto,wx1,wxtext,mdd,qtgzh) values('2','2','2','"&openid&"','"&wx1&"','"&wxtext&"','"&trim(out_trade_no)&"','"&qtgzh&"')")
			end if
					
			'【买家】手机通知
			if msnurl<>"-" then
				msbody="您已支付成功,请点击链接提卡 "&wapurl&"tika?ka="&out_trade_no
				newurl=UCase(weburl)
				if instr(1,newurl,"HTTPS://")>0 then 
				httpbs="S"
				else
				httpbs="P"
				end if
				newurl=replace(newurl,"HTTPS://","")
				newurl=replace(newurl,"HTTP://","")
				newurl=replace(newurl,"/","")
				newurl=httpbs&newurl
				newurl=replace(newurl,".","0A")
				newurl=replace(newurl,"C","0B")
				newurl=replace(newurl,"E","0C")
				newurl=replace(newurl,"R","0D")
				newmsbody=trim(newurl)&"0Z"&trim(out_trade_no) 'SMS_68970054  trim(out_trade_no)  | SMS_68630029  newmsbody
				call mokuai_sms("IK02","2",ayddcontact,msbody,trim(newmsbody),"","",trim(out_trade_no))
			end if
		end if
		
		
if iserr="ok" then ddzt="2"
if iserr="ddnull" then ddzt="3"
if iserr="ddchongfu" then ddzt="4"
if iserr="signerr" then ddzt="5"
conn.execute "update aybuylx set aydddzt="&ddzt&" where aydddsum='"&out_trade_no&"'"

next
end if

response.Write "OK<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>"
%>

