<!--#include virtual="/inc/conn.asp"-->
<!--#include virtual="/inc/sitecon.asp"-->
<!--#include virtual="/inc/md52.asp"--> 
<!--#include virtual="/inc/buysyspc.asp"-->
<!--#include virtual="/pay/weifutong/classes/class.asp"-->
<%
On error resume next

Response.CharSet="GB2312"
Response.ContentType="text/html"

restr="{"
restr=restr&"""err"":"""","

'初始化参数
isshowerweima="no"
isguolvallcan="no" '清空表单所有参数
isgoodurl=SafeRequestform("isgoodurl")
if trim(isgoodurl)="" then isgoodurl="no"

set rss=server.CreateObject("adodb.recordset")

'POST方法
function getHTTPPagwx(url,cset) 
dim Http 
set Http=server.createobject("MSXML2.XMLHTTP") 
Http.open "GET",url,false 
Http.send() 
if Http.readystate<>4 then exit function 
getHTTPPagwx=bytesToBSTR(Http.responseBody,cset) 
set http=nothing 
if err.number<>0 then response.Write "{""err"":""Err-71-"&Err.Description&"请联系管理员""}":response.end
end function
			
'威富通获取数据
Function BytesToBstrwft(body)
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 = "GB2312"
BytesToBstrwft = objstream.ReadText
objstream.Close()
Set objstream = Nothing
End Function



'邮箱检测
Function RegTest(str,r,i)
Dim Reg
Set Reg=New RegExp
Reg.IgnoreCase=i
Reg.Pattern=r
RegTest=Reg.Test(str)
Set Reg=Nothing
End Function

'日期格式补零
function FillZero(str)
	if len(str)=1 then
	FillZero = "0"&str
	else
	FillZero=str
	end if
end function

'创建订单号
sjstr=split(userinip,".")
if len(sjstr(0))=1 then 
sj1="0"&sjstr(0)
else
sj1=mid(sjstr(0),1,1)&mid(sjstr(0),len(sjstr(0)),len(sjstr(0)))
end if
if len(sjstr(1))=1 then 
sj2="0"&sjstr(1)
else
sj2=mid(sjstr(1),1,1)&mid(sjstr(1),len(sjstr(1)),len(sjstr(1)))
end if
sito=sj1&sj2&mid(sjstr(2),len(sjstr(2)),len(sjstr(2)))&mid(sjstr(3),len(sjstr(3)),len(sjstr(3)))
if err.number<>0 then response.Write "{""err"":""Err-97-"&Err.Description&"请联系管理员""}":response.end

Const stringmodarr = "0123456789"
strlength = Len(stringmodarr)
Randomize timer
For i = 1 To 5 
randarr2 = randarr2&Mid(stringmodarr,Int(Rnd * strlength + 1),1)  
Next 
For i = 1 To 4 
randarr3 = randarr3&Mid(stringmodarr,Int(Rnd * strlength + 1),1)  
Next 

'订单完整组合 randarrlei&randarrhost&randarrddku&randarrlast
randarrlei="D" 	 	'标示 D订单 C财务
randarrhost="A" 	'服务器数据库
randarrlast=Right(("00"&Day(Now())),2)&Right(("00"&second(Now())),2)&sito&randarr2    '订单字符串
randarrlasta=Right(("00"&Day(Now())),2)&Right(("00"&second(Now())),2)&sito&randarr3   '订单字符串 支付宝驻守使用

'获取参数
if SafeRequestform("act")="" or SafeRequestform("act")<>"buy" then 
response.Write "{""err"":""获取参数错误""}"
response.End()
end if

shanghuqq=SafeRequestform("shanghuqq")
if trim(shanghuqq)="" then shanghuqq="-"

tikapass=SafeRequestform("tikapass") 					'提卡密码
feilei=SafeRequestform("feilei")                  		'分类ID
shangid=SafeRequestform("shangid")				 		'商品ID
gooduserid=SafeRequestform("gooduserid")          		'商品所属会员ID
quantity=SafeRequestform("quantity")              		'购买数量
danjia=SafeRequestform("danjia")				  		'商品单价
goodyj=SafeRequestform("goodyj")				  		'商品原价(单价)
goodzongjia=SafeRequestform("goodzongjia")        		'商品总价
contact=vbsUnEscape(trim(SafeRequestform("contact")))	'联系方式
bugpass=vbsUnEscape(trim(SafeRequestform("buypass")))   '购卡密码
istelka=trim(SafeRequestform("istelka"))          	 	'是否使用手机接收短信 yes是
isxinyongka=SafeRequestform("isxinyongka")        		'是否信用卡支付
pid=SafeRequestform("pid")                  			'支付通道代码
youhuiquan=SafeRequestform("youhuiquan")      	 		'优惠券信息
youhuiquanzhi=SafeRequestform("youhuiquanzhi")			'优惠券值
isyouhui=SafeRequestform("isyouhui")          			'是否使用优惠券 选定值=1
aybankpay=SafeRequestform("aybankpay")					'网银值  1支付宝网银 2财付通网银 3易宝网银 ALIPAY  TENPAY  99余额
email=""
'email=vbsUnEscape(SafeRequestform("email"))            '邮箱

if request.Cookies("aynameid")<>"" then 				'and request.Cookies("kfopenid")<>"" and request.Cookies("kfopenname")<>""
ayddbuyid=request.Cookies("aynameid")
else
ayddbuyid=0
end if

if istelka="true" then istelka="yes"
if isxinyongka="true" then isxinyongka="1"
if isyouhui="false" then isyouhui=""

yingfuzongjia=goodzongjia                       '应支付总价
showddzj=danjia*quantity						'订单总价
ddzj=showddzj

if isyouhui="" then 
youhuiquan=""
youhuiquanzhi=""
end if



'除去优惠券值计算真实订单总价
if trim(youhuiquanzhi)<>"" then   
	youhuiquanstr=split(youhuiquanzhi,"|")
	if Ubound(youhuiquanstr)>0 then youhuiquanzhi=mid(youhuiquanzhi,1,instr(1,youhuiquanzhi,"|")-1)&"%"        				
		str=split(youhuiquanzhi,"%")
		if Ubound(str)>0 then
		quanzhi=mid(youhuiquanzhi,1,instr(1,youhuiquanzhi,"%")-1)
		ddzj=showddzj-quanzhi/100*showddzj 
		else
		ddzj=showddzj-youhuiquanzhi
		end if
if err.number<>0 then response.Write "{""err"":""Err-188-"&Err.Description&"请联系管理员""}":response.end
end if
'除去优惠券值计算真实订单总价END

picpid=pid

'参数判断验证
if shangid="" then response.Write "{""err"":""商品信息有误""}":response.End()
if cint(quantity)<1 then response.Write "{""err"":""购买数量有误""}":response.End()
if feilei="0" or shangid="0" then response.Write "{""err"":""请选择需要购买的商品""}":response.End()
if contact="" then response.Write "{""err"":""请填写一个联系方式以便查询""}":response.End()
if len(contact)<6 then response.Write "{""err"":""联系方式不少于6位请重新填写""}":response.End()
if contact="123456" or contact="000000" or contact="0000000" or contact="888888" or contact="112233" or contact="111111" then response.Write "{""err"":""联系方式过于简单请重新填写""}":response.End()
if trim(yingfuzongjia)<>"" and CCur(yingfuzongjia)<0 then response.Write "{""err"":""商品价格出现错误请重新选择""}":response.End()
if yingfuzongjia<>0 and pid="" then response.Write "{""err"":""请选择支付方式""}":response.End()
if yingfuzongjia=0 then response.Write "{""err"":""支付价格有误""}":response.End()

'if trim(email)<>"" then
'	emailobj=RegTest(trim(email),"([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}",True)
'	if emailobj=false then
'	response.Write "{""err"":""请填写一个正确的邮箱""}"
'	response.End()
'	end if
'end if
'参数判断验证END
 
'检查是否在买家黑名单
call chkbuyhei(contact,trim(email))


'是否有其他核心设置
shezhi1="no"
shezhi2="no"
shezhi3="no"
rs.open "select * from ayapiquanju2" ,conn,1,1
if cint(rs("shezhi1"))=1 then shezhi1="yes"	'非重要级别 是否开启 支付宝人工收款接口 1是
if cint(rs("shezhi2"))=1 then shezhi2="yes"	'非重要级别 是否开启 微信人工收款接口 1是
if cint(rs("shezhi3"))=1 then shezhi3="yes"	'非重要级别 是否开启 QQ人工收款接口 1是
rs.close


'全局参数
rs.open "select * from ayquanju",conn,1,1
bankfs=rs("aybankpay")
aychenbank=rs("aychenbank")      '网银接口成本
aychenalipay=rs("aychenalipay")  '支付宝接口成本
saomacheng=rs("saomacheng")      '微信扫码成本
qqsaomacheng=rs("qqsaomacheng")  'qq成本
jdsaomacheng=rs("jdsaomacheng")  '京东成本
alipayguanfei=rs("qzalipayf")    '支付宝官方接口手续费
buyisdl=rs("buyisdl")			 '全局强制登录购买

if pid<>"ALIPAY" and pid<>"WEIXIN" and pid<>"QQPAY" and pid<>"JDPAY" then wangyin=aybankpay

if wangyin="1" or wangyin="2" then
aybankf=rs("aybankf") 			 '网银交易费率
zaybankf=rs("aybankf") 			 '上级代理默认网银手续费
end if

if pid="ALIPAY" then 
ayalif=rs("ayalif")  			  '支付宝交易费率
zayalif=rs("ayalif")  			  '上级代理默认支付宝手续费
ayisraili=rs("ayisraili")         '是否使用支付宝驻守 1是
aliqitajiekou=rs("aliqitajiekou")  '其他接口
alipayguancheng=rs("qzalipayc")   '支付宝官方接口成本
qzalipayf2=rs("qzalipayf2")       '支付宝驻守程序手续费
qzalipayc2=rs("qzalipayc2")       '支付宝驻守程序成本
end if

if pid="WEIXIN" then
saomafei=rs("saomafei")           '微信扫码交易费率
zsaomafei=rs("saomafei")		  '上级代理默认微信扫码手续费
wxqitajiekou=rs("wxqitajiekou")   '其他接口
end if

if pid="QQPAY" then
qqsaomafei=rs("qqsaomafei")      'QQ扫码费率
zqqsaomafei=rs("qqsaomafei")     '上级代理qq扫码默认费率
qqqitajiekou=rs("qqqitajiekou")  '其他接口
end if

if pid="JDPAY" then
jdsaomafei=rs("jdsaomafei")      '京东费率
zjdsaomafei=rs("jdsaomafei")     '上级代理京东扫码默认费率
jdqitajiekou=rs("jdqitajiekou")  '京东其他接口
end if

isalipayfz=rs("isalipayfz")      '是否开启秒结 1是
alipayfzxx=rs("alipayfzxx")      '秒结下限
alipayfzsx=rs("alipayfzsx")      '秒结上限
alipayfzfei=rs("alipayfzfei")    '秒结手续费
alipayfz1=rs("alipayfz1")        '秒结开始时间
alipayfz2=rs("alipayfz2")        '秒结结束时间
rs.close

'商户数据处理
isvip="no"			'是否VIP
isshzishou="no"		'是否使用 商家自收 
rs.open "select * from ayname where aynameid="&gooduserid&"",conn,1,1
if rs.bof and rs.eof then
response.Write "{""err"":""无此商家""}"
response.end
end if

if cint(rs("ddmaxj"))>0 then		'订单单价上限
	if ccur(ddzj)>ccur(rs("ddmaxj")) then 
	response.Write "{""err"":""订单金额超限""}"
	response.end
	end if
end if

if cint(rs("isbuylog"))=1 then		'强制买家登录购买
	if request.Cookies("aynameid")="" or cint(ayddbuyid)=0 then 
	response.Write "{""err"":""必须登录后才可以购买""}"
	response.end
	end if
end if

if cint(rs("isbuylog"))<>2 then		'2=关闭强制登录
	if cint(buyisdl)=1 then			'全站强制买家登录购买
		if request.Cookies("aynameid")="" or cint(ayddbuyid)=0 then 
		response.Write "{""err"":""必须登录后才可以购买""}"
		response.end
		end if
	end if
end if

yongjin=rs("yongjin")
ayjibie=rs("ayjibie")
ayaisalipayfz=rs("ayaisalipayfz")	 '秒结

if cint(rs("isshangzishou"))=1 then  '商家自收 接口
	if DateDiff("d",now(),rs("zishoudate"))>=1 then '权限未到期
		if pid="ALIPAY" and cint(rs("iszsali"))=1 then 
		isshzishou="yes"
		shzishoupic=trim(rs("zsali"))
		end if
		if pid="WEIXIN" and cint(rs("iszswei"))=1 then 
		isshzishou="yes"
		shzishoupic=trim(rs("zswei"))
		end if
		if pid="QQPAY" and cint(rs("iszsqq"))=1 then 
		isshzishou="yes"
		shzishoupic=trim(rs("zsqq"))
		end if
	end if
end if

ddku=trim(rs("ddku"))
select case	trim(rs("ddku")) 		 '订单库
case "aydingdan"
randarrddku="A"
case "aydingdan01"
randarrddku="B"
case "aydingdan02"
randarrddku="C"
case "aydingdan03"
randarrddku="D"
case "aydingdan04"
randarrddku="E"
case "aydingdan05"
randarrddku="F"
end select
'创建订单号
randarr=randarrlei&randarrhost&randarrddku&randarrlast 
rs.close


'商户级别
if cint(ayjibie)<>5 and cint(ayjibie)<>9 then
isvip="yes"

	rs.open "select * from ayujb where ayujbgid="&ayjibie&"" ,conn,1,1
	if wangyin="1" or wangyin="2" then
	if cint(rs("ayisbankpay"))=0 then 
	response.Write "{""err"":""该商家级别未启用该支付方式""}"
	response.end
	end if
	bankfs=rs("aybankpay")
	aybankf=rs("ayujbbankbl")   	   '非普通商户 网银费率   0为免费
	aychenbank=rs("ayujbjiekoubank")   '非普通商户 接口成本 网银
	end if
	
	if pid="ALIPAY" then
	if cint(rs("ayisalipay"))=0 then
	response.Write "{""err"":""该商家级别未启用该支付方式""}"
	response.end
	end if
	ayalif=rs("ayujbalibl")  		   '非普通商户 支付宝费率 0为免费
	aychenalipay=rs("ayujbjiekouali")  '非普通商户 接口成本 支付宝  
	aliqitajiekou=rs("jbaliqitajiekou")  '其他接口
	end if
	
	if pid="WEIXIN" then
	if cint(rs("ayissaopay"))=0 then
	response.Write "{""err"":""该商家级别未启用该支付方式""}"
	response.end
	end if
	saomafei=rs("ayujbsaobl")   	   '非普通商户 微信费率   0为免费
	saomacheng=rs("ayujbjiekouwei")    '非普通商户 接口成本 微信 
	wxqitajiekou=rs("jbwxqitajiekou")  '其他接口
	end if
	
	if pid="QQPAY" then
	if cint(rs("ayisqqpay"))=0 then
	response.Write "{""err"":""该商家级别未启用该支付方式""}"
	response.end
	end if
	qqsaomafei=rs("ayujbqqbl")  	   '非普通商户 QQ扫码费率 0为免费
	qqsaomacheng=rs("ayujbjiekouqq")   '非普通商户 接口成本 QQ扫码 
	qqqitajiekou=rs("jbqqqitajiekou")'其他接口
	end if
	
	if pid="JDPAY" then
	if cint(rs("ayisjdpay"))=0 then
	response.Write "{""err"":""该商家级别未启用该支付方式""}"
	response.end
	end if
	jdsaomafei=rs("jdsaomafei")  	    '非普通商户 京东扫码费率 0为免费
	jdsaomacheng=rs("jdsaomacheng")     '非普通商户 接口成本 京东扫码 
	jdqitajiekou=rs("jdqitajiekou")		'其他接口
	end if

	rs.close
end if


'是否为包年套餐商户
rs.open "select top 1 aytcuid,aytcbuyd,aytcsj,aytczt,aytcisyear,aytcyearf,aytczhiding from aytaocanlog where aytcuid="&gooduserid&" and aytcisyear=1 and aytczt=0",conn,1,1
if not(rs.bof and rs.eof) then
	if DateDiff("d",rs("aytcbuyd"),now())<=clng(rs("aytcsj")) then  '*******套餐未过期
		if chkujb(ayjibie,trim(rs("aytczhiding")))=true then  '检查级别是否可用
		aybankf=rs("aytcyearf")    '包年套餐网银手续费
		ayalif=rs("aytcyearf")     '包年套餐支付宝手续费
		saomafei=rs("aytcyearf")   '包年套餐微信手续费
		qqsaomafei=rs("aytcyearf") '包年套餐手Q手续费
		jdsaomafei=rs("aytcyearf") '包年套餐京东手续费
		end if

	end if
end if
rs.close


'其他核心设置 非重要级别 是否开启人工收款接口 
if shezhi1="yes" then	'支付宝人工
	if cint(ayjibie)=4 or cint(ayjibie)=10 or cint(ayjibie)=7 or cint(ayjibie)=6 or cint(ayjibie)=14 or cint(ayjibie)=1 or cint(ayjibie)=13 then
	aliqitajiekou=90
	aychenalipay=0
	end if
end if
if shezhi2="yes" then	'微信人工
	if cint(ayjibie)=4 or cint(ayjibie)=10 or cint(ayjibie)=7 or cint(ayjibie)=6 or cint(ayjibie)=14 or cint(ayjibie)=1 or cint(ayjibie)=13 then
	wxqitajiekou=90
	saomacheng=0
	end if
end if
if shezhi3="yes" then	'QQ人工
	if cint(ayjibie)=4 or cint(ayjibie)=10 or cint(ayjibie)=7 or cint(ayjibie)=6 or cint(ayjibie)=14 or cint(ayjibie)=1 or cint(ayjibie)=13 then
	qqqitajiekou=90
	qqsaomacheng=0
	end if
end if
 

'生成支付地址
zhifufangshi=99
if wangyin="1" or wangyin="2" then zhifufangshi=0
if pid="ALIPAY" then zhifufangshi=2 
if pid="WEIXIN" then zhifufangshi=4
if pid="QQPAY" then zhifufangshi=5
if pid="JDPAY" then zhifufangshi=6


if wangyin="1" then  
qudao="支付宝"
urlact="action='/pay/alipaybank/' method=post"  '1支付宝网银
end if 
if wangyin="2" then  
qudao="财付通"
urlact="action='/pay/tenpaybank/' method=get"	 '2财付通网银
end if 

isusershoukuan="no"	'个人收款二维码

'支付宝帐号
if pid="ALIPAY" then  
isqtalipay="no" '是否使用其他跳转支付宝接口

	urlact="action='/pay/alipay/' method=post" '支付宝官方
	qudao="官方"
	
	if cint(aliqitajiekou)=1 then 	'IK接口
	qudao="28"
	isqtalipay="yes"
	urlact="action='/pay/ikpay/' method=post" 
	end if
	
	'平台代收   商户 个人 二维码收款
	rss.open "select top 1 * from ayshoukuan where userid="&gooduserid&" and lei=1 and isok=1",conn,1,1
	if not(rss.bof and rss.eof) then
		zishoufs=trim(rss("con"))
		picurl=trim(rss("pic"))
		allname=trim(rss("allname"))
		ayshoukuanid=rss("ayshoukuanid")
		aliqitajiekou=91
		isusershoukuan="yes"
		zhifufs="1"
		qudao="平台代收"
		urlact="action='/pay/erweima/' method=post" 
		isqtalipay="yes"
	end if
	rss.close
	
	'商家自收
	if isshzishou="yes" then
	aliqitajiekou=92
	isusershoukuan="no"
	zhifufs="1"
	qudao="商家自收"
	urlact="action='/pay/erweima_zs/' method=post" 
	isqtalipay="yes"
	picurl=shzishoupic
	end if
	
	'平台开启 二维码人工收款 支持轮询
	if cint(aliqitajiekou)=90  then  
	
		zhifufs="1"
		qudao="自收"
		urlact="action='/pay/erweima/' method=post" 
		isqtalipay="yes"
		grlunxunsum=0
		constr=""
		
		sql="select * from ayshoukuan where userid=0 and lei=1 and isok=1" 
		rss.open sql,conn,1,1
		if not(rss.bof and rss.eof) then
		do while not rss.eof
			grlunxunsum=grlunxunsum+1
			constr=constr&trim(rss("con"))&","
			zishoufs=trim(rss("con"))
			picurl=trim(rss("pic"))
			allname=trim(rss("allname"))
			ayshoukuanid=rss("ayshoukuanid")
		rss.movenext
		loop
		end if
		rss.close
		
		if grlunxunsum=0 then 
		response.Write "{""err"":""没有可用收款方式""}"
		response.end
		end if
		
		'#####个人二维码代收 轮询开始
		if grlunxunsum>1 then
		constr=mid(constr,1,len(constr)-1)
		
			rss.open "select top 1 * from aybuylx where qudao='自收' and zhifufs=1 order by aylxid desc" ,conn,1,1
			if not(rss.bof and rss.eof) then
				if trim(rss("zishoufs"))<>"" and isnull(trim(rss("zishoufs")))=false then 	'最后一单 自收订单 自收接口 如：艺星24492628@qq.com
				lastzishoufs=trim(rss("zishoufs"))
				else
				lastzishoufs=""	
				end if
			end if
			rss.close
			
			fenjiestr=split(constr,",")	'获取已设置好的轮询接口个数	Ubound(fenjiestr)+1	单个具体位置 fenjiestr(0)
			lunxunzongshu=Ubound(fenjiestr)
			
			isyou="no"	'是否还存在已设置的轮询接口中
			nextzishounum=0
			For zishousum=0 To Ubound(fenjiestr)
				if lastzishoufs=fenjiestr(zishousum) then	'获取最后一单渠道 在已设置的轮询接口中的位置
				nextzishounum=zishousum+1								'下一个轮询接口 位置
				isyou="yes"
				if nextzishounum>lunxunzongshu then nextzishounum=0
				exit for
				end if
			next 
		
			if isyou="no" then
			nextzishoujiekou=fenjiestr(0)
			else
			nextzishoujiekou=fenjiestr(nextzishounum)
			end if
			
			sql="select * from ayshoukuan where con='"&nextzishoujiekou&"'" 
			rss.open sql,conn,1,1
			zishoufs=trim(rss("con"))
			picurl=trim(rss("pic"))
			allname=trim(rss("allname"))
			ayshoukuanid=rss("ayshoukuanid")
			rss.close
			
		end if
		'#####个人二维码代收 轮询结束
	
	
	
	end if
		
	
end if



'微信三方接口
if trim(pid)="WEIXIN" then
	
	if cint(wxqitajiekou)=2 then  'IK接口
	qudao="28"
	isqtalipay="yes"
	urlact="action='/pay/ikpay/' method=post" 
	end if
	
	
	'平台代收 商户 个人 二维码收款
	rss.open "select top 1 * from ayshoukuan where userid="&gooduserid&" and lei=2 and isok=1",conn,1,1
	if not(rss.bof and rss.eof) then
		zishoufs=trim(rss("con"))
		picurl=trim(rss("pic"))
		allname=trim(rss("allname"))
		ayshoukuanid=rss("ayshoukuanid")
		wxqitajiekou=91
		isusershoukuan="yes"
		zhifufs="2"
		qudao="平台代收"
		urlact="action='/pay/erweima/' method=post" 
		isqtalipay="yes"
	end if
	rss.close
	
	'商家自收
	if isshzishou="yes" then
	wxqitajiekou=92
	isusershoukuan="no"
	zhifufs="2"
	qudao="商家自收"
	urlact="action='/pay/erweima_zs/' method=post" 
	isqtalipay="yes"
	picurl=shzishoupic
	end if
	
	'平台开启 二维码人工收款 支持轮询
	if cint(wxqitajiekou)=90  then  
	
		zhifufs="2"
		qudao="自收"
		urlact="action='/pay/erweima/' method=post" 
		isqtalipay="yes"
		grlunxunsum=0
		constr=""
		
		sql="select * from ayshoukuan where userid=0 and lei=2 and isok=1" 
		rss.open sql,conn,1,1
		if not(rss.bof and rss.eof) then
		do while not rss.eof
			grlunxunsum=grlunxunsum+1
			constr=constr&trim(rss("con"))&","
			zishoufs=trim(rss("con"))
			picurl=trim(rss("pic"))
			allname=trim(rss("allname"))
			ayshoukuanid=rss("ayshoukuanid")
		rss.movenext
		loop
		end if
		rss.close
		
		if grlunxunsum=0 then 
		response.Write "{""err"":""没有可用收款方式""}"
		response.end
		end if
		
		'#####个人二维码代收 轮询开始
		if grlunxunsum>1 then
		constr=mid(constr,1,len(constr)-1)
		
			rss.open "select top 1 * from aybuylx where qudao='自收' and zhifufs=2 order by aylxid desc" ,conn,1,1
			if not(rss.bof and rss.eof) then
				if trim(rss("zishoufs"))<>"" and isnull(trim(rss("zishoufs")))=false then 	'最后一单 自收订单 自收接口 如：艺星24492628@qq.com
				lastzishoufs=trim(rss("zishoufs"))
				else
				lastzishoufs=""	
				end if
			end if
			rss.close
			
			fenjiestr=split(constr,",")	'获取已设置好的轮询接口个数	Ubound(fenjiestr)+1	单个具体位置 fenjiestr(0)
			lunxunzongshu=Ubound(fenjiestr)
			
			isyou="no"	'是否还存在已设置的轮询接口中
			nextzishounum=0
			For zishousum=0 To Ubound(fenjiestr)
				if lastzishoufs=fenjiestr(zishousum) then	'获取最后一单渠道 在已设置的轮询接口中的位置
				nextzishounum=zishousum+1								'下一个轮询接口 位置
				isyou="yes"
				if nextzishounum>lunxunzongshu then nextzishounum=0
				exit for
				end if
			next 
		
			if isyou="no" then
			nextzishoujiekou=fenjiestr(0)
			else
			nextzishoujiekou=fenjiestr(nextzishounum)
			end if
			
			sql="select * from ayshoukuan where con='"&nextzishoujiekou&"'" 
			rss.open sql,conn,1,1
			zishoufs=trim(rss("con"))
			picurl=trim(rss("pic"))
			allname=trim(rss("allname"))
			ayshoukuanid=rss("ayshoukuanid")
			rss.close
			
		end if
		'#####个人二维码代收 轮询结束
	
	end if
	
end if

if trim(pid)="QQPAY" then
	
	if cint(qqqitajiekou)=1 then  'IK接口
	qudao="28"
	isqtalipay="yes"
	urlact="action='/pay/ikpay/' method=post" 
	end if
	
	'平台代收 商户 个人 二维码收款
	rss.open "select top 1 * from ayshoukuan where userid="&gooduserid&" and lei=3 and isok=1",conn,1,1
	if not(rss.bof and rss.eof) then
		zishoufs=trim(rss("con"))
		picurl=trim(rss("pic"))
		allname=trim(rss("allname"))
		ayshoukuanid=rss("ayshoukuanid")
		qqqitajiekou=91
		isusershoukuan="yes"
		zhifufs="3"
		qudao="平台代收"
		urlact="action='/pay/erweima/' method=post" 
		isqtalipay="yes"
	end if
	rss.close
	
	'商家自收
	if isshzishou="yes" then
	qqqitajiekou=92
	isusershoukuan="no"
	zhifufs="3"
	qudao="商家自收"
	urlact="action='/pay/erweima_zs/' method=post" 
	isqtalipay="yes"
	picurl=shzishoupic
	end if
	
	'平台开启 二维码人工收款 支持轮询
	if cint(qqqitajiekou)=90  then  
	
		zhifufs="3"
		qudao="自收"
		urlact="action='/pay/erweima/' method=post" 
		isqtalipay="yes"
		grlunxunsum=0
		constr=""
		
		sql="select * from ayshoukuan where userid=0 and lei=3 and isok=1" 
		rss.open sql,conn,1,1
		if not(rss.bof and rss.eof) then
		do while not rss.eof
			grlunxunsum=grlunxunsum+1
			constr=constr&trim(rss("con"))&","
			zishoufs=trim(rss("con"))
			picurl=trim(rss("pic"))
			allname=trim(rss("allname"))
			ayshoukuanid=rss("ayshoukuanid")
		rss.movenext
		loop
		end if
		rss.close
		
		if grlunxunsum=0 then 
		response.Write "{""err"":""没有可用收款方式""}"
		response.end
		end if
		
		'#####个人二维码代收 轮询开始
		if grlunxunsum>1 then
		constr=mid(constr,1,len(constr)-1)
		
			rss.open "select top 1 * from aybuylx where qudao='自收' and zhifufs=3 order by aylxid desc" ,conn,1,1
			if not(rss.bof and rss.eof) then
				if trim(rss("zishoufs"))<>"" and isnull(trim(rss("zishoufs")))=false then 	'最后一单 自收订单 自收接口 如：艺星24492628@qq.com
				lastzishoufs=trim(rss("zishoufs"))
				else
				lastzishoufs=""	
				end if
			end if
			rss.close
			
			fenjiestr=split(constr,",")	'获取已设置好的轮询接口个数	Ubound(fenjiestr)+1	单个具体位置 fenjiestr(0)
			lunxunzongshu=Ubound(fenjiestr)
			
			isyou="no"	'是否还存在已设置的轮询接口中
			nextzishounum=0
			For zishousum=0 To Ubound(fenjiestr)
				if lastzishoufs=fenjiestr(zishousum) then	'获取最后一单渠道 在已设置的轮询接口中的位置
				nextzishounum=zishousum+1								'下一个轮询接口 位置
				isyou="yes"
				if nextzishounum>lunxunzongshu then nextzishounum=0
				exit for
				end if
			next 
		
			if isyou="no" then
			nextzishoujiekou=fenjiestr(0)
			else
			nextzishoujiekou=fenjiestr(nextzishounum)
			end if
			
			sql="select * from ayshoukuan where con='"&nextzishoujiekou&"'" 
			rss.open sql,conn,1,1
			zishoufs=trim(rss("con"))
			picurl=trim(rss("pic"))
			allname=trim(rss("allname"))
			ayshoukuanid=rss("ayshoukuanid")
			rss.close
			
		end if
		'#####个人二维码代收 轮询结束
	
	end if
	
end if
 

if trim(pid)="JDPAY" then
	'response.Write "{""err"":""京东支付已停用""}"
	'response.end
end if
'生成支付方式 -结束





'获取商品成本价及常见错误检测
aygoodsuoyouid=gooduserid '初始本商户ID
rs.open "select * from aygood where aygoodid="&clng(shangid)&"",conn,1,1
aydingdancb=rs("aychenben")
aygoodname=rs("aygoodname")
aygooddlid=rs("aygooddlid")  			'上级代理ID 默认0无代理
aysjgid=rs("aysjgid")        			'上级商品ID
aysjjiage=rs("aysjjiage")               '代理价格
aychenben=rs("aychenben")               '成本价格

if clng(aygooddlid)<>0 then

if isusershoukuan="yes" or isshzishou="yes" then
response.Write "{""err"":""当前商家收款方式不支持代理关系""}":response.end
end if

	'是否批发  批发数量 价格 在本代理商调用
	if cint(rs("aypifayes"))=1 then 
	if ccur(quantity)>=ccur(rs("aypifa5")) then aysjjiage=rs("dailicb5")
	if ccur(quantity)<ccur(rs("aypifa5")) and ccur(quantity)>=ccur(rs("aypifa4")) then aysjjiage=rs("dailicb4")
	if ccur(quantity)<ccur(rs("aypifa4")) and ccur(quantity)>=ccur(rs("aypifa3")) then aysjjiage=rs("dailicb3")
	if ccur(quantity)<ccur(rs("aypifa3")) and ccur(quantity)>=ccur(rs("aypifa2")) then aysjjiage=rs("dailicb2")
	if ccur(quantity)<ccur(rs("aypifa2")) and ccur(quantity)>=ccur(rs("aypifa1")) then 
	aysjjiage=rs("dailicb1")
	else
	aysjjiage=rs("aysjjiage")
	end if
	end if

aygooddlfd=ccur(aysjjiage)*ccur(quantity)  '代理商 应如总价 代理价格或批发单价*购买数量
end if

if trim(rs("bugpass"))<>"" and isnull(trim(rs("bugpass")))=false then
	if bugpass="" then response.Write "{""err"":""需要正确输入购卡密码""}":response.end
	if bugpass<>trim(rs("bugpass")) then response.Write "{""err"":""需要正确输入购卡密码""}":response.end
end if
if cint(rs("ayggodispass"))=1 then
	if trim(tikapass)="" then response.Write "{""err"":""商家要求必须设置一个提卡密码""}":response.end
end if
rs.close



'组织 代理关系 -结束
'saygooddlid=aygooddlid '初始 仅显示 上级代理 不显示总代理
dailistr=""
if clng(aygooddlid)<>0 then '是代理商品  
		For sum=1 To 10 '10层代理关系
		
			'aysjgid 上级商品ID 
			'aysjjiage 商品代理价格
			'aygoodsuoyouid 代理商 商户ID  
			'aygooddlid 上级代理 商户ID 
			'aygsumid 商品唯一标示
			
			if isnull(trim(aysjgid))=true or trim(aysjgid)="" then  '上级商品ID
			response.Write "{""err"":""代理商品ID错误""}"
			response.end 
			end if
			if clng(aysjgid)=0 then 
			response.Write "{""err"":""代理商品ID错误""}"
			response.end
			end if
			if ccur(aysjjiage)=0 then  '商品代理价格有误
			response.Write "{""err"":""代理商品价格错误""}"
			response.end
			end if
		
			'验证代理关系                                                                                 '代理商 商户ID                        上级代理 商户ID 
			rs.open "select aydluserid,aydlsjuserid,aydlistongguo from aydailishang where aydluserid='"&clng(aygoodsuoyouid)&"' and aydlsjuserid='"&clng(aygooddlid)&"' and aydlistongguo=1",conn,1,1
			if rs.bof and rs.eof then 
			response.Write "{""err"":""代理关系失效""}"
			response.end
			end if
			rs.close
			
			'获取代理商品ID                            '上级商品ID                          上级代理 商户ID 
			rs.open "select * from aygood where aygoodid="&clng(aysjgid)&" and aygoodsuoyouid="&clng(aygooddlid)&" and aygoodzhuangtai=0",conn,1,1
			if not(rs.bof and rs.eof) then 
				
				'上级代理 相关参数 卡密库 财务库 会员级别 费率
				set rsj=server.CreateObject("adodb.recordset")
				set rsjb=server.CreateObject("adodb.recordset")
				rsj.open "select aynameid,ayjibie,kamiku,ddku,cwku from ayname where aynameid="&aygooddlid&"",conn,1,1
				zkamiku=trim(rsj("kamiku"))
				zddku=trim(rsj("ddku"))
				zcwku=trim(rsj("cwku"))
				if rsj("ayjibie")<>5 and rsj("ayjibie")<>9 then
					rsjb.open "select * from ayujb where ayujbgid="&rsj("ayjibie")&"",conn,1,1
					if not(rsjb.bof and rsjb.eof) then
					zayalif=rsjb("ayujbalibl")   '非普通商户 支付宝交易价值比例 0为免费
					zaybankf=rsjb("ayujbbankbl") '非普通商户 网银交易价值比例 0为免费
					zsaomafei=rsjb("ayujbsaobl") '微信扫码
					zqqsaomafei=rsjb("ayujbqqbl")'QQ扫码
					zjdsaomafei=rsjb("jdsaomafei")
					end if
					rsjb.close 
				end if 
				rsj.close
				
				'查看上级代理是否为包年套餐商户
				rsj.open "select top 1 aytcuid,aytcbuyd,aytcsj,aytczt,aytcisyear,aytcyearf from aytaocanlog where aytcuid="&aygooddlid&" and aytcisyear=1 and aytczt=0" ,conn,1,1
				if not(rsj.bof and rsj.eof) then
					if DateDiff("d",rsj("aytcbuyd"),now())<=clng(rsj("aytcsj")) then  '*******套餐未过期
					zayalif=rsj("aytcyearf")  '包年套餐手续费价值
					zaytenf=rsj("aytcyearf")  
					zaybankf=rsj("aytcyearf")
					zsaomafei=rsj("aytcyearf")
					zqqsaomafei=rsj("aytcyearf")
					zjdsaomafei=rsj("aytcyearf")
					end if
				end if
				rsj.close
				
				
				pifachenben=rs("aychenben")
				'批发
				if cint(rs("aypifayes"))=1 then 
					if clng(rs("aygooddlid"))<>0 then '多层上级代理  成本=dailicb1
						if ccur(quantity)>=ccur(rs("aypifa5")) then pifachenben=rs("dailicb5")
						if ccur(quantity)<ccur(rs("aypifa5")) and ccur(quantity)>=ccur(rs("aypifa4")) then pifachenben=rs("dailicb4")
						if ccur(quantity)<ccur(rs("aypifa4")) and ccur(quantity)>=ccur(rs("aypifa3")) then pifachenben=rs("dailicb3")
						if ccur(quantity)<ccur(rs("aypifa3")) and ccur(quantity)>=ccur(rs("aypifa2")) then pifachenben=rs("dailicb2")
						if ccur(quantity)<ccur(rs("aypifa2")) and ccur(quantity)>=ccur(rs("aypifa1")) then
						pifachenben=rs("dailicb1")
						else
						pifachenben=rs("aychenben")
						end if
						
					else  '已是总代 成本=dailij1
						if ccur(quantity)>=ccur(rs("aypifa5")) then pifachenben=rs("dailij5")
						if ccur(quantity)<ccur(rs("aypifa5")) and ccur(quantity)>=ccur(rs("aypifa4")) then pifachenben=rs("dailij4")
						if ccur(quantity)<ccur(rs("aypifa4")) and ccur(quantity)>=ccur(rs("aypifa3")) then pifachenben=rs("dailij3")
						if ccur(quantity)<ccur(rs("aypifa3")) and ccur(quantity)>=ccur(rs("aypifa2")) then pifachenben=rs("dailij2")
						if ccur(quantity)<ccur(rs("aypifa2")) and ccur(quantity)>=ccur(rs("aypifa1")) then
						pifachenben=rs("dailij1")
						else
						pifachenben=rs("aychenben")
						end if
						
					end if
				end if

					   '代理商品成本    '上级商品成本价
				if ccur(aychenben)<ccur(pifachenben) then
				response.Write "{""err"":""代理商品成本价格低于上级代理成本价格""}"
				response.end
				end if
				
				'上级代理入账 不含手续费
				if clng(rs("aygooddlid"))=0 then '已是总代
				caiwuyf=aysjjiage*ccur(quantity) '应付金额 用于利润统计
				ddzjzd=aysjjiage*ccur(quantity) '上级代理入款 = 商品代理价格
				else '多层上级代理
				caiwuyf=ccur(aysjjiage)-ccur(pifachenben) '应付金额 用于利润统计
				caiwuyf=ccur(caiwuyf)*ccur(quantity)
				ddzjzd=ccur(aysjjiage)-ccur(pifachenben) '上级代理入款 = 商品代理价 - 商品成本价或批发成本价
				ddzjzd=ddzjzd*ccur(quantity)
				end if
				

				
				'获取手续费后的价格  
				if wangyin="1" or wangyin="2" then
				if ccur(ddzjzd)>=1 then	ddzjzd=ccur(ddzjzd)-ccur(zaybankf/100*ddzjzd):else:ddzjzd=ccur(ddzjzd)-0.01:end if
				end if
				if pid="ALIPAY" then
				if ccur(ddzjzd)>=1 then	ddzjzd=ccur(ddzjzd)-ccur(zayalif/100*ddzjzd):else:ddzjzd=ccur(ddzjzd)-0.01:end if
				end if
				if pid="WEIXIN" then 
				if ccur(ddzjzd)>=1 then ddzjzd=ccur(ddzjzd)-ccur(zsaomafei/100*ddzjzd):else:ddzjzd=ccur(ddzjzd)-0.01:end if
				end if
				if pid="QQPAY" then 
				if ccur(ddzjzd)>=1 then	ddzjzd=ccur(ddzjzd)-ccur(zqqsaomafei/100*ddzjzd):else:ddzjzd=ccur(ddzjzd)-0.01:end if
				end if  
				if pid="JDPAY" then 
				if ccur(ddzjzd)>=1 then	ddzjzd=ccur(ddzjzd)-ccur(zjdsaomafei/100*ddzjzd):else:ddzjzd=ccur(ddzjzd)-0.01:end if
				end if 
				
				if ccur(ddzjzd)<=0 then 
				call logadd("0","NP-上级代理入款小于0",0,1)
				response.Write "{""err"":""上级代理入款应大于0，请联系商家""}"
				response.end
				end if
				
				'                 序号|上级商品ID|上级商品代理价格|本商户ID|上级代理ID|上级卡密库|上级订单库|上级财务库|上级代理入款|统计利润金额
				dailistr=dailistr&sum&","&aysjgid&","&aysjjiage&","&aygoodsuoyouid&","&aygooddlid&","&zkamiku&","&zddku&","&zcwku&","&Formatnumber(ddzjzd,2,true,0,0)&","&caiwuyf&"|"
				
				if clng(rs("aygooddlid"))=0 then '已是顶级代理  
				rs.close
				exit for
				else
					aysjgid=rs("aysjgid") 			    '上级商品ID 
					aysjjiage=rs("aysjjiage") 		    '商品代理价格
					aygoodsuoyouid=rs("aygoodsuoyouid") '代理商 商户ID  
					aychenben=rs("aychenben")           '成本价格
					aygooddlid=rs("aygooddlid")		    '上级代理 商户ID 
					'批发
					if cint(rs("aypifayes"))=1 then 
						if ccur(quantity)>=ccur(rs("aypifa5")) then 
						aysjjiage=rs("dailicb5")
						aychenben=rs("dailicb5")
						end if
						if ccur(quantity)<ccur(rs("aypifa5")) and ccur(quantity)>=ccur(rs("aypifa4")) then 
						aysjjiage=rs("dailicb4")
						aychenben=rs("dailicb4")
						end if
						if ccur(quantity)<ccur(rs("aypifa4")) and ccur(quantity)>=ccur(rs("aypifa3")) then 
						aysjjiage=rs("dailicb3")
						aychenben=rs("dailicb3")
						end if
						if ccur(quantity)<ccur(rs("aypifa3")) and ccur(quantity)>=ccur(rs("aypifa2")) then 
						aysjjiage=rs("dailicb2")
						aychenben=rs("dailicb2")
						end if
						if ccur(quantity)<ccur(rs("aypifa2")) and ccur(quantity)>=ccur(rs("aypifa1")) then 
						aysjjiage=rs("dailicb1")
						aychenben=rs("dailicb1")
						else
						aysjjiage=rs("aysjjiage")
						aychenben=rs("aychenben")
						end if
					end if
				end if
				
			else
			response.Write "{""err"":""未找到代理商品""}"
			response.end
			end if
			rs.close
			
		next 
dailistr=mid(dailistr,1,len(dailistr)-1)
end if
'组织 代理关系 -结束


if clng(aygooddlid)<>0 then
ddzj=ccur(yingfuzongjia)-ccur(aygooddlfd) '代理商入账 不含手续费 应付总价-代理价格
end if


'获取手续费后的价格  
	yingkouyongjin=0 '商户个人收款码 默认应扣预存手续费
	
	if wangyin="1" or wangyin="2" then
	jiekoulirun=ccur(aybankf)-ccur(aychenbank) '接口利润
		if aybankf<>0 then 
		if ccur(ddzj)>=1 then ddzj=ccur(ddzj)-ccur(aybankf/100*ddzj):else:ddzj=ccur(ddzj)-0.01:end if
		end if
	end if
	
	if pid="ALIPAY" then
		if isusershoukuan="yes" then
			jiekoulirun=0.6
			if ccur(ddzj)>=5 then yingkouyongjin=0.006*ddzj:else:yingkouyongjin=0.03:end if
			ddzj=0
			if ccur(yongjin)<ccur(yingkouyongjin) then
			response.Write "{""err"":""预存手续费不足""}"
			response.end
			end if
		else
			jiekoulirun=ccur(ayalif)-ccur(aychenalipay) 
			if ayalif<>0 then 
			if ccur(ddzj)>=1 then ddzj=ccur(ddzj)-ccur(ayalif/100*ddzj):else:ddzj=ccur(ddzj)-0.01:end if
			end if
		end if
	end if
	
	if pid="WEIXIN" then
		if isusershoukuan="yes" then
			jiekoulirun=0.6
			if ccur(ddzj)>=5 then yingkouyongjin=0.006*ddzj:else:yingkouyongjin=0.03:end if
			ddzj=0
			if ccur(yongjin)<ccur(yingkouyongjin) then
			response.Write "{""err"":""预存手续费不足""}"
			response.end
			end if
		else
			jiekoulirun=ccur(saomafei)-ccur(saomacheng)
			if saomafei<>0 then 
			if ccur(ddzj)>=1 then ddzj=ccur(ddzj)-ccur(saomafei/100*ddzj):else:ddzj=ccur(ddzj)-0.01:end if
			end if
		end if
	end if
	
	if pid="QQPAY" then
		if isusershoukuan="yes" then
			jiekoulirun=0.6
			if ccur(ddzj)>=5 then yingkouyongjin=0.006*ddzj:else:yingkouyongjin=0.03:end if
			ddzj=0
			if ccur(yongjin)<ccur(yingkouyongjin) then
			response.Write "{""err"":""预存手续费不足""}"
			response.end
			end if
		else
			jiekoulirun=ccur(qqsaomafei)-ccur(qqsaomacheng) 
			if qqsaomafei<>0 then 
			if ccur(ddzj)>=1 then ddzj=ccur(ddzj)-ccur(qqsaomafei/100*ddzj):else:ddzj=ccur(ddzj)-0.01:end if
			end if
		end if
	end if
	
	if pid="JDPAY" then
	jiekoulirun=ccur(jdsaomafei)-ccur(jdsaomacheng) 
		if jdsaomafei<>0 then 
		if ccur(ddzj)>=1 then ddzj=ccur(ddzj)-ccur(jdsaomafei/100*ddzj):else:ddzj=ccur(ddzj)-0.01:end if
		end if
	end if

'代理商品 禁止0元入款
if ccur(ddzj)<=0 and isusershoukuan="no" then 
	call logadd("0","NP-入款小于0-"&ddzj&"-商品ID-"&shangid&"",0,1)
	response.Write "{""err"":""商品入款应大于0，请联系商家""}"
	response.End()
end if


'优惠券价值应小于订单价格一半
'if trim(youhuiquanzhi)<>"" then
'	if ccur(youhuiquanzhi)*2>=ccur(showddzj) then 
'	call logadd("0","NP-优惠券大于订单金额一般-"&youhuiquanzhi&"-"&showddzj&"-商品ID-"&shangid&"",0,1)
'	response.Write "{""err"":""商优惠券禁止在该类商品价格范围使用，请联系商家""}"
'	response.End()
'	end if
'end if


'检查订单是否被篡改  -开始
rs.open "select aygoodzhuangtai,aygoodid,aygoodfl,ayjiage,aypifayes,aypifa1,aypifa2,aypifa3,aypifa4,aypifa5,aypifaj1,aypifaj2,aypifaj3,aypifaj4,aypifaj5,ayyouhuiyes from aygood where aygoodid="&clng(shangid)&" and aygoodsuoyouid="&gooduserid&"",conn,1,1	
		if not(rs.bof and rs.eof) then 
					'商品状态检测
					if cint(rs("aygoodzhuangtai"))=1 then
					response.Write "{""err"":""该商品已下架""}"
					response.End()
					end if
					
					'商品隶属分类检测 
					if clng(feilei)<>clng(rs("aygoodfl")) then
					response.Write "{""err"":""商品分类信息获取失败，请重新尝试购买""}"
					response.End()
					end if
					
					'优惠券 
					if trim(youhuiquan)<>"" then
						'检测是否开启优惠券
						if cint(rs("ayyouhuiyes"))=0 then
						response.Write "{""err"":""商品优惠券信息错误，请重新尝试购买err1""}"
						response.End()
						end if
						'检测优惠券价值是否正确
						if ccur(chkbuyyouhuiquan(trim(youhuiquan),gooduserid))<>ccur(youhuiquanzhi) then
						response.Write "{""err"":""优惠券信息错误，请重新尝试购买err2""}"
						response.End()
						end if
					end if
					
					'不使用批发优惠
					if cint(rs("aypifayes"))=0 then 
								'与订单原价(单价)不符
								if ccur(goodyj)<>ccur(rs("ayjiage")) then 
								response.Write "{""err"":""订单单价有误，请重新尝试购买""}" 
								response.End()
								end if
								'与订单总价不符
								ddyzj=ccur(rs("ayjiage"))*ccur(quantity)
								if ccur(showddzj)<>ccur(ddyzj) then 
								response.Write "{""err"":""订单总价有误，请重新尝试购买""}"
								response.End()
								end if
								'应付总价不符
								if zhifufangshi<>1 then
									if trim(youhuiquan)="" then  'if istelka="yes"
										yfzongjia=yingfuzongjia
										if istelka="yes" then yfzongjia=ccur(yingfuzongjia)-0.1
										if ccur(yfzongjia)<>ccur(ddyzj) then 
										response.Write "{""err"":""应付总价有误，请重新尝试购买err1""}"
										response.End()
										end if
									else
										kouyouhui=ccur(ddyzj)-ccur(youhuiquanzhi) '除去优惠券价值
										yfzongjia=yingfuzongjia
										if istelka="yes" then yfzongjia=ccur(yingfuzongjia)-0.1
										if ccur(kouyouhui)<>ccur(yfzongjia) then
										response.Write "{""err"":""含优惠券应付总价有误，请重新尝试购买""}"
										response.End()
										end if
									end if
								end if
					else '使用批发优惠
								'获取批发单价
								if clng(rs("aypifa5"))<>0 then
									if ccur(quantity)>=ccur(rs("aypifa5")) then pifadj=rs("aypifaj5")
									if ccur(quantity)<ccur(rs("aypifa5")) and ccur(quantity)>=ccur(rs("aypifa4")) then pifadj=rs("aypifaj4")
									if ccur(quantity)<ccur(rs("aypifa4")) and ccur(quantity)>=ccur(rs("aypifa3")) then pifadj=rs("aypifaj3")
									if ccur(quantity)<ccur(rs("aypifa3")) and ccur(quantity)>=ccur(rs("aypifa2")) then pifadj=rs("aypifaj2")
									if ccur(quantity)<ccur(rs("aypifa2")) and ccur(quantity)>=ccur(rs("aypifa1")) then pifadj=rs("aypifaj1")
									if ccur(quantity)<ccur(rs("aypifa1")) then pifadj=rs("ayjiage")	 		
								elseif clng(rs("aypifa4"))<>0 then
									if ccur(quantity)>=ccur(rs("aypifa4")) then pifadj=rs("aypifaj4")
									if ccur(quantity)<ccur(rs("aypifa4")) and ccur(quantity)>=ccur(rs("aypifa3")) then pifadj=rs("aypifaj3")
									if ccur(quantity)<ccur(rs("aypifa3")) and ccur(quantity)>=ccur(rs("aypifa2")) then pifadj=rs("aypifaj2")
									if ccur(quantity)<ccur(rs("aypifa2")) and ccur(quantity)>=ccur(rs("aypifa1")) then pifadj=rs("aypifaj1")
									if ccur(quantity)<ccur(rs("aypifa1")) then pifadj=rs("ayjiage")	 
								elseif clng(rs("aypifa3"))<>0 then
									if ccur(quantity)>=ccur(rs("aypifa3")) then pifadj=rs("aypifaj3")
									if ccur(quantity)<ccur(rs("aypifa3")) and ccur(quantity)>=ccur(rs("aypifa2")) then pifadj=rs("aypifaj2")
									if ccur(quantity)<ccur(rs("aypifa2")) and ccur(quantity)>=ccur(rs("aypifa1")) then pifadj=rs("aypifaj1")
									if ccur(quantity)<ccur(rs("aypifa1")) then pifadj=rs("ayjiage")	 
								elseif clng(rs("aypifa2"))<>0 then
									if ccur(quantity)>=ccur(rs("aypifa2")) then pifadj=rs("aypifaj2")
									if ccur(quantity)<ccur(rs("aypifa2")) and ccur(quantity)>=ccur(rs("aypifa1")) then pifadj=rs("aypifaj1")
									if ccur(quantity)<ccur(rs("aypifa1")) then pifadj=rs("ayjiage")	 
								elseif clng(rs("aypifa1"))<>0 then
									if ccur(quantity)>=ccur(rs("aypifa1")) then pifadj=rs("aypifaj1")
									if ccur(quantity)<ccur(rs("aypifa1")) then pifadj=rs("ayjiage")	 
								end if
									
								'与订单单价不符
								if ccur(danjia)<>ccur(pifadj) then 
								response.Write "{""err"":""订单单价有误，请重新尝试购买""}"
								response.End()
								end if
								'与订单总价不符
								ddyzj=ccur(pifadj)*ccur(quantity)
								if ccur(showddzj)<>ccur(ddyzj) then 
								response.Write "{""err"":""订单总价有误，请重新尝试购买""}"
								response.End()
								end if
								'应付总价不符
								if zhifufangshi<>1 then
									if trim(youhuiquan)="" then
										yfzongjia=yingfuzongjia
										if istelka="yes" then yfzongjia=ccur(yingfuzongjia)-0.1
										if ccur(yfzongjia)<>ccur(ddyzj) then 
										response.Write "{""err"":""应付总价有误，请重新尝试购买""}"
										response.End()
										end if
									else
										yfzongjia=yingfuzongjia
										if istelka="yes" then yfzongjia=ccur(yingfuzongjia)-0.1
										kouyouhui=ccur(ddyzj)-ccur(youhuiquanzhi) '除去优惠券价值
										if ccur(kouyouhui)<>ccur(yfzongjia) then
										response.Write "{""err"":""含优惠券应付总价有误，请重新尝试购买""}"
										response.End()
										end if
									end if
								end if
					end if
		else
		response.Write "{""err"":""未找到该订单商品""}"
		response.End()
		end if
		rs.close
'检查订单是否被篡改  -结束

'创建订单

'支付宝分账处理
isalipayfz_2=0
if cint(ayaisalipayfz)=1 and cint(isalipayfz)=1 and zhifufangshi<>1 and ccur(showddzj)>=10 and isusershoukuan="no" then
	if hour(now())>=cint(alipayfz1) and hour(now())<cint(alipayfz2) then 
	isalipayfz_2=1
	end if
end if

aybuyipxx=trim(userinip)&"@"&request.serverVariables("HTTP_USER_AGENT")

buyuseryu=0
'if buyuseryu=1 then zhifufangshi=99   	'支付方式 0网银 1充值卡 2支付宝 3财付通 4快捷 99余额

'微信接收卡密
openid="-"
if request.Cookies("openid")<>"" then openid=request.Cookies("openid")

'是否使用手机接收短信0.1元
msnurl="-"
'短链接
if istelka="yes" then msnurl="yes" 

if isyiok="no" then
if ccur(yingfuzongjia)<1 then response.Write "{""err"":""订单金额不能低于1元，请联系商家或增加购买数量""}":response.End()
end if

strsign=""
strsign=trim(randarr)
strsign=strsign&trim(pid)
strsign=strsign&shangid
strsign=strsign&gooduserid
strsign=strsign&Formatnumber(yingfuzongjia,4,true,-1,0)
strsign=strsign&Formatnumber(ddzj,2,true,0,0)
strsign=strsign&Formatnumber(goodyj,4,true,-1,0)
strsign=strsign&Formatnumber(danjia,4,true,-1,0)
strsign=strsign&Formatnumber(showddzj,4,true,-1,0)
strsign=strsign&ptjiami
strsign=md5(strsign)


'传递订单号
restr=restr&"""ddh"":"""&randarr&""","	

showrandarr=randarr '显示订单号
show_body="查询退款Q"&fuwuqq&"订单"&randarr  '中文 长商品说明
show_body1="查询退款Q"&fuwuqq					'中文 短商品说明
show_bodyy="QQ"&fuwuqq&"-"&randarr				'非中文 商品说明
z_body="buy"

'支付宝支付
if pid="ALIPAY" then   
		
		if cint(aliqitajiekou)=1 then '使用IK接口 支付宝扫码
			qudao="28"
			isshowerweima="yes"  
			z_partner=toparkey("ayapipartner")
			signstr="z_partner="&z_partner&"&z_key="&toparkey("ayapikey")&"&z_trade_no="&randarr&"&z_total_fee="&Formatnumber(yingfuzongjia,4,true,-1,0) 
			z_sign=UCase(MD5(signstr))
			sfd=getHTTPPagwx(""&apijk&"api161208/alipay_sao.asp?z_partner="&z_partner&"&z_nurl="&toparkey("ayapinotify")&"&z_trade_no="&randarr&"&z_sign="&z_sign&"&z_total_fee="&yingfuzongjia&"&z_body="&z_body&"&z_fs=2&contact="&contact&"","gb2312")
			if trim(sfd)="notourl" then
			isshowerweima="no"
			end if
			if err.number<>0 then conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"','Template/newbuy2/pay/index.asp','"&randarr&"','"&qudao&"','"&pid&"','PC')")
		end if
		
		if cint(aliqitajiekou)=2 then '吉易支付宝
			qudao="吉易"
			isshowerweima="yes"
			mch_id=toparkey("jiyiid")
			jiyikey=toparkey("jiyikey")
			notify_url=toparkey("jiyino")
			return_url=toparkey("jiyire")
			attach="buy"
			body=show_bodyy
			charset="utf-8"
			out_trade_no=randarr
			payment_code="8004"		'支付渠道编码	8001微信扫码支付	8004支付宝扫码支付
			sign_type="MD5"
			timestamp=now()
			total_fee=yingfuzongjia
			version="1.0"
			surl="http://pay.jipays.com/gateway"
			str="attach="&attach&"&"
			str=str&"body="&body&"&"
			str=str&"charset="&charset&"&"
			str=str&"mch_id="&mch_id&"&"
			str=str&"notify_url="&notify_url&"&"
			str=str&"out_trade_no="&out_trade_no&"&"
			str=str&"payment_code="&payment_code&"&"
			str=str&"return_url="&return_url&"&"
			'str=str&"sign_type="&sign_type&"&"
			str=str&"timestamp="&timestamp&"&"
			str=str&"total_fee="&total_fee&"&"
			str=str&"version="&version&"&"
			str=str&"key="&jiyikey
			sign=md5(str)
			Set d =Server.CreateObject("Scripting.Dictionary")
			Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
			d.Add "attach",attach
			d.Add "body",body
			d.Add "charset",charset
			d.Add "mch_id", mch_id
			d.Add "notify_url",notify_url
			d.Add "out_trade_no", out_trade_no
			d.Add "payment_code", payment_code
			d.Add "return_url", return_url
			d.Add "sign_type", sign_type
			d.Add "timestamp", timestamp
			d.Add "total_fee", total_fee
			d.Add "version", version
			d.Add "sign", sign
			result=parseURL(d)
			xmlhttp.Open "POST", surl , false
			xmlhttp.SetRequestHeader "content-type", "application/x-www-form-urlencoded;charset=utf-8"
			xmlhttp.SetRequestHeader "X-Requested-With", "XMLHttpRequest"
			xmlhttp.Send result	
			Set json = toObject(xmlhttp.responseTEXT)
			'response.Write json.data.qrcode_url
			sfd=trim(json.data.qrcode_url)
			if err.number<>0 then conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"','Template/newbuy2/pay/index.asp','"&randarr&"','"&qudao&"','"&pid&"','PC')")
		end if
		
		if cint(aliqitajiekou)=3 then '吉易2支付宝
			qudao="吉易2"
			isshowerweima="yes"
			mch_id=jiyiid2
			jiyikey=jiyikey2
			notify_url=jiyino2
			return_url=jiyire2
			attach="buy"
			body=show_bodyy
			charset="utf-8"
			out_trade_no=randarr
			payment_code="8004"		'支付渠道编码	8001微信扫码支付	8004支付宝扫码支付
			sign_type="MD5"
			timestamp=now()
			total_fee=yingfuzongjia
			version="1.0"
			surl="http://pay.jipays.com/gateway"
			str="attach="&attach&"&"
			str=str&"body="&body&"&"
			str=str&"charset="&charset&"&"
			str=str&"mch_id="&mch_id&"&"
			str=str&"notify_url="&notify_url&"&"
			str=str&"out_trade_no="&out_trade_no&"&"
			str=str&"payment_code="&payment_code&"&"
			str=str&"return_url="&return_url&"&"
			'str=str&"sign_type="&sign_type&"&"
			str=str&"timestamp="&timestamp&"&"
			str=str&"total_fee="&total_fee&"&"
			str=str&"version="&version&"&"
			str=str&"key="&jiyikey
			sign=md5(str)
			Set d =Server.CreateObject("Scripting.Dictionary")
			Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
			d.Add "attach",attach
			d.Add "body",body
			d.Add "charset",charset
			d.Add "mch_id", mch_id
			d.Add "notify_url",notify_url
			d.Add "out_trade_no", out_trade_no
			d.Add "payment_code", payment_code
			d.Add "return_url", return_url
			d.Add "sign_type", sign_type
			d.Add "timestamp", timestamp
			d.Add "total_fee", total_fee
			d.Add "version", version
			d.Add "sign", sign
			result=parseURL(d)
			xmlhttp.Open "POST", surl , false
			xmlhttp.SetRequestHeader "content-type", "application/x-www-form-urlencoded;charset=utf-8"
			xmlhttp.SetRequestHeader "X-Requested-With", "XMLHttpRequest"
			xmlhttp.Send result	
			Set json = toObject(xmlhttp.responseTEXT)
			'response.Write json.data.qrcode_url
			sfd=trim(json.data.qrcode_url)
			if err.number<>0 then conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"','Template/newbuy2/pay/index.asp','"&randarr&"','"&qudao&"','"&pid&"','PC')")
		end if
		
		
		
		if cint(aliqitajiekou)=10 then '优畅支付宝
			qudao="优畅"
			isshowerweima="yes"
			mch_id=toparkey("youchangid")
			key=toparkey("youchangkey")
			notify_url=toparkey("youchangno")
			tourl = "http://mapi.bosc.uline.cc/alipay/orders/precreate" '支付宝	ALI_OFFLINE_NATIVE
			payment_code="ALI_OFFLINE_NATIVE"	
			total_fee=yingfuzongjia*100
			out_trade_no=randarr
			nonce_str=randarr
			body=show_bodyy										
			attach="buy"										
			spbill_create_ip=Request.ServerVariables("REMOTE_ADDR")
			trade_type="NATIVE"		
			Set packageParams = CreateObject("Scripting.Dictionary")
			packageParams.Add "mch_id", mch_id
			packageParams.Add "nonce_str", nonce_str
			packageParams.Add "body", body
			packageParams.Add "attach", attach 
			packageParams.Add "out_trade_no", out_trade_no
			packageParams.Add "total_fee", total_fee
			packageParams.Add "spbill_create_ip", spbill_create_ip
			packageParams.Add "notify_url", notify_url
			packageParams.Add "trade_type", trade_type 
			packageParams.Add "payment_code", payment_code
			strsign2 = createSHA1Sign(packageParams) & "&key="&key
			sign = UCase(md5(strsign2))
			packageParams.Add "sign", sign
			para = parseXML(packageParams)
			Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
			http.Option(4) = 13056
			http.Option(6) = False
			http.SetTimeouts 5000, 10000, 10000, 10000
			http.Open "POST", tourl, False
			http.SetRequestHeader "Connection", "Keep-Alive"
			http.SetRequestHeader "User-Agent", "Mozilla/4.0"
			http.SetRequestHeader "Content-Length", Len(data)
			http.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
			http.Send para
			body = BytesToBstr(http.ResponseBody, "utf-8")
			return_code = mysubstr(body, "<return_code>", "</return_code>")
			result_code = mysubstr(body, "<result_code>", "</result_code>")
			if return_code="SUCCESS" and result_code="SUCCESS" then 
			sfd = mysubstr(body, "<qr_code>", "</qr_code>")
			else
			conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"-"&body&"','Template/newbuy2/pay/index.asp','"&randarr&"','"&qudao&"','"&pid&"','PC')")
			response.Write "{""err"":""Err-1600，请尝试重新提交或使用其他支付方式，还可以联系平台客服""}"
			response.end
			end if
		end if
		
		
		if cint(aliqitajiekou)=11 then '优畅2支付宝
			qudao="优畅2"
			isshowerweima="yes"
			mch_id=youchangid2
			key=youchangkey2
			notify_url=youchangno2
			tourl = "http://mapi.bosc.uline.cc/alipay/orders/precreate" '支付宝	ALI_OFFLINE_NATIVE
			payment_code="ALI_OFFLINE_NATIVE"	
			total_fee=yingfuzongjia*100
			out_trade_no=randarr
			nonce_str=randarr
			body=show_bodyy										
			attach="buy"										
			spbill_create_ip=Request.ServerVariables("REMOTE_ADDR")
			trade_type="NATIVE"		
			Set packageParams = CreateObject("Scripting.Dictionary")
			packageParams.Add "mch_id", mch_id
			packageParams.Add "nonce_str", nonce_str
			packageParams.Add "body", body
			packageParams.Add "attach", attach 
			packageParams.Add "out_trade_no", out_trade_no
			packageParams.Add "total_fee", total_fee
			packageParams.Add "spbill_create_ip", spbill_create_ip
			packageParams.Add "notify_url", notify_url
			packageParams.Add "trade_type", trade_type 
			packageParams.Add "payment_code", payment_code
			strsign2 = createSHA1Sign(packageParams) & "&key="&key
			sign = UCase(md5(strsign2))
			packageParams.Add "sign", sign
			para = parseXML(packageParams)
			Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
			http.Option(4) = 13056
			http.Option(6) = False
			http.SetTimeouts 5000, 10000, 10000, 10000
			http.Open "POST", tourl, False
			http.SetRequestHeader "Connection", "Keep-Alive"
			http.SetRequestHeader "User-Agent", "Mozilla/4.0"
			http.SetRequestHeader "Content-Length", Len(data)
			http.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
			http.Send para
			body = BytesToBstr(http.ResponseBody, "utf-8")
			return_code = mysubstr(body, "<return_code>", "</return_code>")
			result_code = mysubstr(body, "<result_code>", "</result_code>")
			if return_code="SUCCESS" and result_code="SUCCESS" then 
			sfd = mysubstr(body, "<qr_code>", "</qr_code>")
			else
			conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"-"&body&"','Template/newbuy2/pay/index.asp','"&randarr&"','"&qudao&"','"&pid&"','PC')")
			response.Write "{""err"":""Err-1600，请尝试重新提交或使用其他支付方式，还可以联系平台客服""}"
			response.end
			end if
		end if
						
		
		if cint(aliqitajiekou)=30 then '上海汇付-威富通1 支付宝
			qudao="汇付"
			isshowerweima="yes"
			time_start=year(now)&FillZero(month(now))&FillZero(day(now))&FillZero(hour(now))&FillZero(minute(now))&FillZero(second(now))
			Set packageParams = CreateObject("Scripting.Dictionary")  'Server.CreateObject("Scripting.Dictionary")
			packageParams.Add "attach", z_body       '随机字符串，商户可自定义
			packageParams.Add "body", show_bodyy                     '商品描述
			packageParams.Add "charset", "UTF-8" 
			packageParams.Add "mch_create_ip", Request.ServerVariables("REMOTE_ADDR")                     '终端 IP
			packageParams.Add "mch_id", huifu_id              '商户号
			packageParams.Add "nonce_str", z_body 
			packageParams.Add "notify_url", huifu_no         '通知回调地址，目前默认是空格，商户在测试支付和上线时必须改为自己的，且保证外网能访问到
			packageParams.Add "out_trade_no", randarr          '商户订单号
			packageParams.Add "service", "pay.alipay.nativev2"                     '接口类型  微信 pay.weixin.scancode  手q：pay.qq.jspay
			packageParams.Add "sign_type", "MD5" 
			packageParams.Add "time_start", time_start 
			packageParams.Add "total_fee", yingfuzongjia*100                   '总金额 ，以分为单位
			packageParams.Add "version", "2.0" 
			strsign2 = createSHA1Sign(packageParams) & "&key="&huifu_key
			sign = UCase(md5(strsign2))
			packageParams.Add "sign", sign
			para = parseXML(packageParams)
			Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
			http.Option(4) = 13056
			http.Option(6) = False
			surl = "https://pay.swiftpass.cn/pay/gateway"
			http.SetTimeouts 5000, 10000, 10000, 10000
			http.Open "POST", surl, False
			http.SetRequestHeader "Connection", "Keep-Alive"
			http.SetRequestHeader "User-Agent", "Mozilla/4.0"
			http.SetRequestHeader "Content-Length", Len(data)
			http.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
			http.Send para
			body = BytesToBstrwft(http.ResponseBody)
			Status = mysubstr(body, "<status><![CDATA[", "]]></status>")
			If Status = 0 Then result_code = mysubstr(body, "<result_code><![CDATA[", "]]></result_code>")
			If result_code = 0 Then	code_img_url = mysubstr(body, "<code_img_url><![CDATA[", "]]></code_img_url>")
			sfd=replace(code_img_url,"https://pay.swiftpass.cn/pay/qrcode?uuid="," ")
			sfd=replace(sfd,"https://pay2.swiftpass.cn/pay/qrcode?uuid="," ")
			sfd=replace(sfd,"%3A%2F%2F","://")
			sfd=replace(sfd,"%2F","/")
			sfd=replace(sfd,"%3F","?")
			sfd=replace(sfd,"%3D","=")
			sfd=replace(sfd,"%26","&")
if err.number<>0 or result_code=1 then conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"-"&body&"','Template/newbuy2/pay/index.asp','"&randarr&"','"&qudao&"','"&pid&"','PC')")
		end if
		
		if cint(aliqitajiekou)=31 then '上海汇付-威富通2 支付宝
			qudao="汇付2"
			isshowerweima="yes"
			time_start=year(now)&FillZero(month(now))&FillZero(day(now))&FillZero(hour(now))&FillZero(minute(now))&FillZero(second(now))
			Set packageParams = CreateObject("Scripting.Dictionary")  'Server.CreateObject("Scripting.Dictionary")
			packageParams.Add "attach", z_body       '随机字符串，商户可自定义
			packageParams.Add "body", show_bodyy                     '商品描述
			packageParams.Add "charset", "UTF-8" 
			packageParams.Add "mch_create_ip", Request.ServerVariables("REMOTE_ADDR")                     '终端 IP
			packageParams.Add "mch_id", huifu_id2              '商户号
			packageParams.Add "nonce_str", z_body 
			packageParams.Add "notify_url", huifu_no2         '通知回调地址，目前默认是空格，商户在测试支付和上线时必须改为自己的，且保证外网能访问到
			packageParams.Add "out_trade_no", randarr          '商户订单号
			packageParams.Add "service", "pay.alipay.nativev2"                     '接口类型  微信 pay.weixin.scancode  手q：pay.qq.jspay
			packageParams.Add "sign_type", "MD5" 
			packageParams.Add "time_start", time_start 
			packageParams.Add "total_fee", yingfuzongjia*100                   '总金额 ，以分为单位
			packageParams.Add "version", "2.0" 
			strsign2 = createSHA1Sign(packageParams) & "&key="&huifu_key2
			sign = UCase(md5(strsign2))
			packageParams.Add "sign", sign
			para = parseXML(packageParams)
			Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
			http.Option(4) = 13056
			http.Option(6) = False
			surl = "https://pay.swiftpass.cn/pay/gateway"
			http.SetTimeouts 5000, 10000, 10000, 10000
			http.Open "POST", surl, False
			http.SetRequestHeader "Connection", "Keep-Alive"
			http.SetRequestHeader "User-Agent", "Mozilla/4.0"
			http.SetRequestHeader "Content-Length", Len(data)
			http.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
			http.Send para
			body = BytesToBstrwft(http.ResponseBody)
			Status = mysubstr(body, "<status><![CDATA[", "]]></status>")
			If Status = 0 Then result_code = mysubstr(body, "<result_code><![CDATA[", "]]></result_code>")
			If result_code = 0 Then	code_img_url = mysubstr(body, "<code_img_url><![CDATA[", "]]></code_img_url>")
			sfd=replace(code_img_url,"https://pay.swiftpass.cn/pay/qrcode?uuid="," ")
			sfd=replace(sfd,"https://pay2.swiftpass.cn/pay/qrcode?uuid="," ")
			sfd=replace(sfd,"%3A%2F%2F","://")
			sfd=replace(sfd,"%2F","/")
			sfd=replace(sfd,"%3F","?")
			sfd=replace(sfd,"%3D","=")
			sfd=replace(sfd,"%26","&")
if err.number<>0 or result_code=1 then conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"-"&body&"','Template/newbuy2/pay/index.asp','"&randarr&"','"&qudao&"','"&pid&"','PC')")
		end if
		
end if




'QQ支付
if trim(pid)="QQPAY" then
feeq=yingfuzongjia*100
		
			if cint(qqqitajiekou)=1 then  '*****使用 IK接口 QQ扫码支付 ******
				qudao="28"
				isshowerweima="yes"
				z_partner=toparkey("ayapipartner")
				signstr="z_partner="&z_partner&"&z_key="&toparkey("ayapikey")&"&z_trade_no="&randarr&"&z_total_fee="&Formatnumber(yingfuzongjia,4,true,-1,0) 
				z_sign=UCase(MD5(signstr))
				sfd=getHTTPPagwx(""&apijk&"api161208/qq.asp?z_partner="&z_partner&"&z_nurl="&toparkey("ayapinotify")&"&z_trade_no="&randarr&"&z_sign="&z_sign&"&z_total_fee="&yingfuzongjia&"&z_body="&z_body&"&z_fs=6&contact="&contact&"","gb2312")
				if err.number<>0 then conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"','Template/newbuy2/pay/index.asp','"&randarr&"','"&qudao&"','"&pid&"','PC')")
			end if
				
			if cint(qqqitajiekou)=15 then '掌灵qq	
				qudao="掌灵"
				isshowerweima="yes"
				Set d =Server.CreateObject("Scripting.Dictionary")
				Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
				d.Add "amount",yingfuzongjia*100
				d.Add "body",z_body
				d.Add "mchntOrderNo",randarr
				d.Add "notifyUrl", toparkey("zlno")
				d.Add "payChannelId","2000000003" '支付宝0000000002 微信2100000001  QQ 2000000003 微信H5 2000000001 
				d.Add "returnUrl", toparkey("zlno") 
				d.Add "subject", show_body
				result=parseURL(d)
				xmlhttp.Open "POST", weburl&"pay/mingtian/index.php", false
				xmlhttp.SetRequestHeader "content-type", "application/x-www-form-urlencoded"
				xmlhttp.Send result		
				codeurl=xmlhttp.responseTEXT
				'response.Write codeurl
				'response.End()
				Set json = toObject(codeurl)
				codeurl=split(json.extra,"&")
				sfd=replace(codeurl(0),"code_url="," ")
				sfd=trim(sfd)
				if err.number<>0 then conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"','Template/newbuy2/pay/index.asp','"&randarr&"','"&qudao&"','"&pid&"','PC')")
			end if
			
			if cint(qqqitajiekou)=16 then '掌灵qq2	
				qudao="掌灵2"
				isshowerweima="yes"
				Set d =Server.CreateObject("Scripting.Dictionary")
				Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
				d.Add "amount",yingfuzongjia*100
				d.Add "body",z_body
				d.Add "mchntOrderNo",randarr
				d.Add "notifyUrl", zlno2
				d.Add "payChannelId","2000000003" '支付宝0000000002 微信2100000001  QQ 2000000003 微信H5 2000000001 
				d.Add "returnUrl", zlno2 
				d.Add "subject", show_body
				result=parseURL(d)
				xmlhttp.Open "POST", weburl&"pay/mingtian2/index.php", false
				xmlhttp.SetRequestHeader "content-type", "application/x-www-form-urlencoded"
				xmlhttp.Send result		
				codeurl=xmlhttp.responseTEXT
				Set json = toObject(codeurl)
				codeurl=split(json.extra,"&")
				sfd=replace(codeurl(0),"code_url="," ")
				sfd=trim(sfd)
				if err.number<>0 then conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"','Template/newbuy2/pay/index.asp','"&randarr&"','"&qudao&"','"&pid&"','PC')")
			end if
			
			if cint(qqqitajiekou)=19 then '优畅qq
				qudao="优畅"
				isshowerweima="yes"
				mch_id=toparkey("youchangid")
				key=toparkey("youchangkey")
				notify_url=toparkey("youchangno")
				tourl = "http://mapi.bosc.uline.cc/qqpay/orders" 
				payment_code="QQ_OFFLINE_NATIVE"	
				total_fee=yingfuzongjia*100
				out_trade_no=randarr
				nonce_str=randarr
				body=show_bodyy										
				attach="buy"										
				spbill_create_ip=Request.ServerVariables("REMOTE_ADDR")
				trade_type="NATIVE"		
				Set packageParams = CreateObject("Scripting.Dictionary")
				packageParams.Add "mch_id", mch_id
				packageParams.Add "nonce_str", nonce_str
				packageParams.Add "body", body
				packageParams.Add "attach", attach 
				packageParams.Add "out_trade_no", out_trade_no
				packageParams.Add "total_fee", total_fee
				packageParams.Add "spbill_create_ip", spbill_create_ip
				packageParams.Add "notify_url", notify_url
				packageParams.Add "trade_type", trade_type 
				packageParams.Add "payment_code", payment_code
				strsign2 = createSHA1Sign(packageParams) & "&key="&key
				sign = UCase(md5(strsign2))
				packageParams.Add "sign", sign
				para = parseXML(packageParams)
				Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
				http.Option(4) = 13056
				http.Option(6) = False
				http.SetTimeouts 5000, 10000, 10000, 10000
				http.Open "POST", tourl, False
				http.SetRequestHeader "Connection", "Keep-Alive"
				http.SetRequestHeader "User-Agent", "Mozilla/4.0"
				http.SetRequestHeader "Content-Length", Len(data)
				http.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
				http.Send para
				body = BytesToBstr(http.ResponseBody, "utf-8")
				return_code = mysubstr(body, "<return_code>", "</return_code>")
				result_code = mysubstr(body, "<result_code>", "</result_code>")
				if return_code="SUCCESS" and result_code="SUCCESS" then 
				sfd = mysubstr(body, "<code_url>", "</code_url>")
				else
				conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"-"&body&"','Template/newbuy2/pay/index.asp','"&randarr&"','"&qudao&"','"&pid&"','PC')")
				response.Write "{""err"":""Err-1600，请尝试重新提交或使用其他支付方式，还可以联系平台客服""}"
				response.end
				end if
			end if
			
						
			if cint(qqqitajiekou)=0 then '官方
				qudao="官方"
				isshowerweima="yes"
				ver="2.0"
				charset="2"
				bank_type="0"
				pay_channel="1"
				fee_type="1"
				bargainor_id=toparkey("qqpar")
				key=toparkey("qqkey")
				notify_url=toparkey("qqnotify")
				sp_billno=randarr
				desc = show_bodyy  
				attach=z_body
				toUrl = "http://myun.tenpay.com/cgi-bin/wappayv2.0/wappay_init.cgi" 
				signstr="attach="&attach
				signstr=signstr&"&bank_type="&bank_type
				signstr=signstr&"&bargainor_id="&bargainor_id
				signstr=signstr&"&charset="&charset
				signstr=signstr&"&desc="&desc
				signstr=signstr&"&fee_type="&fee_type
				signstr=signstr&"&notify_url="&notify_url
				signstr=signstr&"&pay_channel="&pay_channel
				signstr=signstr&"&sp_billno="&sp_billno
				signstr=signstr&"&total_fee="&feeq
				signstr=signstr&"&ver="&ver
				signstr=signstr&"&key="&key
				sign=MD5(signstr)
				sign=UCase(sign)
				str=getHTTPPagwx(""&toUrl&"?attach="&attach&"&bank_type="&bank_type&"&bargainor_id="&bargainor_id&"&charset="&charset&"&desc="&desc&"&fee_type="&fee_type&"&notify_url="&notify_url&"&pay_channel="&pay_channel&"&purchaser_id="&purchaser_id&"&sign="&sign&"&sp_billno="&sp_billno&"&time_expire="&time_expire&"&time_start="&time_start&"&total_fee="&feeq&"&ver="&ver&"","gb2312")
				str=mid(str,instr(1,str,"<token_id>")+10)
				str=replace(str,"</token_id></root>"," ")
				sfd="http://myun.tenpay.com/mqq/pay/qrcode.html?t="&trim(str)
				if err.number<>0 then conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"','Template/newbuy2/pay/index.asp','"&randarr&"','"&qudao&"','"&pid&"','PC')")
			end if

end if




'微信支付
if trim(pid)="WEIXIN" then
feeq=yingfuzongjia*100
	
	if cint(wxqitajiekou)=0 then '官方微信
		qudao="官方"
		isshowerweima="yes"
		notifyUrl = toparkey("saomanotify")
		notifyUrl=replace(notifyUrl,"{siteweb}",Request.ServerVariables("SERVER_NAME"))
		Function getSign(signParams)
		Dim keys,k,v,i,j,md5str,sign
		keys	= signParams.Keys()
		for i=0 to UBound(keys)-1
			for j=i+1 to UBound(keys)
			if StrComp(keys(i), keys(j)) > 0 then 
			tmp=keys(i)
			keys(i)=keys(j)
			keys(j)=tmp
			end if
			next
		next
		For Each k in keys
		v = signParams(k)
		if v <> "" and k <> "sign" and k <> "key" then
		md5str	= md5str & k & "=" & v & "&"
		end if
		Next
		md5str	= md5str & "key=" & skey
		sign	= UCase(md5(md5str))
		getSign	= sign
		End Function
		function checkSign(signParams,sing)
		hqsign = getSign(signParams)
		if hqsign=sing then
		checkSign=true
		else
		checkSign=false
		end if
		end function
		Set d =Server.CreateObject("Scripting.Dictionary")
		Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
		d.Add "body_title",show_body
		d.Add "out_trade_no",randarr
		d.Add "total_fee",feeq
		d.Add "trade_type","NATIVE"
		d.Add "attach", z_body
		d.Add "notify_url",notifyUrl
		d.Add "appid", toparkey("appid")
		d.Add "mch_id", toparkey("mchid")
		d.Add "paykey", toparkey("skey")
		result=parseURL(d)
		xmlhttp.Open "POST", toparkey("saomatourl"), false
		xmlhttp.SetRequestHeader "content-type", "application/x-www-form-urlencoded"
		xmlhttp.Send result		
		sfd=xmlhttp.responseTEXT
		if err.number<>0 then conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"','Template/newbuy2/pay/index.asp','"&randarr&"','"&qudao&"','"&pid&"','PC')")
	end if
	
	
	if cint(wxqitajiekou)=2 then  '*****使用 IK接口******
		qudao="28"
		isshowerweima="yes"
		z_partner=toparkey("ayapipartner")
		signstr="z_partner="&z_partner&"&z_key="&toparkey("ayapikey")&"&z_trade_no="&randarr&"&z_total_fee="&Formatnumber(yingfuzongjia,4,true,-1,0) 
		z_sign=UCase(MD5(signstr))
		sfd=getHTTPPagwx(""&apijk&"api161208/weixin_sao.asp?z_partner="&z_partner&"&z_nurl="&toparkey("ayapinotify")&"&z_trade_no="&randarr&"&z_sign="&z_sign&"&z_total_fee="&yingfuzongjia&"&z_body="&z_body&"&z_fs=5&contact="&contact&"","gb2312")
		if trim(sfd)="notourl" then
		isshowerweima="no"
		end if
		if err.number<>0 then conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"','Template/newbuy2/pay/index.asp','"&randarr&"','"&qudao&"','"&pid&"','PC')")
	end if
	
		if cint(wxqitajiekou)=3 then '吉易微信
			qudao="吉易"
			isshowerweima="yes"
			mch_id=toparkey("jiyiid")
			jiyikey=toparkey("jiyikey")
			notify_url=toparkey("jiyino")
			return_url=toparkey("jiyire")
			attach="buy"
			body=show_bodyy
			charset="utf-8"
			out_trade_no=randarr
			payment_code="8001"		'支付渠道编码	8001微信扫码支付	8004支付宝扫码支付
			sign_type="MD5"
			timestamp=now()
			total_fee=yingfuzongjia
			version="1.0"
			surl="http://pay.jipays.com/gateway"
			str="attach="&attach&"&"
			str=str&"body="&body&"&"
			str=str&"charset="&charset&"&"
			str=str&"mch_id="&mch_id&"&"
			str=str&"notify_url="&notify_url&"&"
			str=str&"out_trade_no="&out_trade_no&"&"
			str=str&"payment_code="&payment_code&"&"
			str=str&"return_url="&return_url&"&"
			'str=str&"sign_type="&sign_type&"&"
			str=str&"timestamp="&timestamp&"&"
			str=str&"total_fee="&total_fee&"&"
			str=str&"version="&version&"&"
			str=str&"key="&jiyikey
			sign=md5(str)
			Set d =Server.CreateObject("Scripting.Dictionary")
			Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
			d.Add "attach",attach
			d.Add "body",body
			d.Add "charset",charset
			d.Add "mch_id", mch_id
			d.Add "notify_url",notify_url
			d.Add "out_trade_no", out_trade_no
			d.Add "payment_code", payment_code
			d.Add "return_url", return_url
			d.Add "sign_type", sign_type
			d.Add "timestamp", timestamp
			d.Add "total_fee", total_fee
			d.Add "version", version
			d.Add "sign", sign
			result=parseURL(d)
			xmlhttp.Open "POST", surl , false
			xmlhttp.SetRequestHeader "content-type", "application/x-www-form-urlencoded;charset=utf-8"
			xmlhttp.SetRequestHeader "X-Requested-With", "XMLHttpRequest"
			xmlhttp.Send result	
			Set json = toObject(xmlhttp.responseTEXT)
			'response.Write json.data.qrcode_url
			sfd=trim(json.data.qrcode_url)
			if err.number<>0 then conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"','Template/newbuy2/pay/index.asp','"&randarr&"','"&qudao&"','"&pid&"','PC')")
		end if
	
		if cint(wxqitajiekou)=4 then '吉易2微信
			qudao="吉易2"
			isshowerweima="yes"
			mch_id=jiyiid2
			jiyikey=jiyikey2
			notify_url=jiyino2
			return_url=jiyire2
			attach="buy"
			body=show_bodyy
			charset="utf-8"
			out_trade_no=randarr
			payment_code="8001"		'支付渠道编码	8001微信扫码支付	8004支付宝扫码支付
			sign_type="MD5"
			timestamp=now()
			total_fee=yingfuzongjia
			version="1.0"
			surl="http://pay.jipays.com/gateway"
			str="attach="&attach&"&"
			str=str&"body="&body&"&"
			str=str&"charset="&charset&"&"
			str=str&"mch_id="&mch_id&"&"
			str=str&"notify_url="&notify_url&"&"
			str=str&"out_trade_no="&out_trade_no&"&"
			str=str&"payment_code="&payment_code&"&"
			str=str&"return_url="&return_url&"&"
			'str=str&"sign_type="&sign_type&"&"
			str=str&"timestamp="&timestamp&"&"
			str=str&"total_fee="&total_fee&"&"
			str=str&"version="&version&"&"
			str=str&"key="&jiyikey
			sign=md5(str)
			Set d =Server.CreateObject("Scripting.Dictionary")
			Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
			d.Add "attach",attach
			d.Add "body",body
			d.Add "charset",charset
			d.Add "mch_id", mch_id
			d.Add "notify_url",notify_url
			d.Add "out_trade_no", out_trade_no
			d.Add "payment_code", payment_code
			d.Add "return_url", return_url
			d.Add "sign_type", sign_type
			d.Add "timestamp", timestamp
			d.Add "total_fee", total_fee
			d.Add "version", version
			d.Add "sign", sign
			result=parseURL(d)
			xmlhttp.Open "POST", surl , false
			xmlhttp.SetRequestHeader "content-type", "application/x-www-form-urlencoded;charset=utf-8"
			xmlhttp.SetRequestHeader "X-Requested-With", "XMLHttpRequest"
			xmlhttp.Send result	
			Set json = toObject(xmlhttp.responseTEXT)
			'response.Write json.data.qrcode_url
			sfd=trim(json.data.qrcode_url)
			if err.number<>0 then conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"','Template/newbuy2/pay/index.asp','"&randarr&"','"&qudao&"','"&pid&"','PC')")
		end if
	
	
	if cint(wxqitajiekou)=5 then '掌灵微信
		qudao="掌灵"
		isshowerweima="yes"
		Set d =Server.CreateObject("Scripting.Dictionary")
		Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
		d.Add "amount",yingfuzongjia*100
		d.Add "body",z_body
		d.Add "mchntOrderNo",randarr
		d.Add "notifyUrl", toparkey("zlno")
		d.Add "payChannelId","2100000001" '支付宝0000000002 微信2100000001  
		d.Add "returnUrl", toparkey("zlno")
		d.Add "subject", show_body
		result=parseURL(d)
		xmlhttp.Open "POST", weburl&"pay/mingtian/index.php", false
		xmlhttp.SetRequestHeader "content-type", "application/x-www-form-urlencoded"
		xmlhttp.Send result		
		codeurl=xmlhttp.responseTEXT
		Set json = toObject(codeurl)
		codeurl=split(json.extra,"&")
		sfd=replace(codeurl(0),"code_url="," ")
		sfd=trim(sfd)
		if err.number<>0 then conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"','Template/newbuy2/pay/index.asp','"&randarr&"','"&qudao&"','"&pid&"','PC')")
	end if
	
	if cint(wxqitajiekou)=6 then '掌灵微信2
		qudao="掌灵2"
		isshowerweima="yes"
		Set d =Server.CreateObject("Scripting.Dictionary")
		Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
		d.Add "amount",yingfuzongjia*100
		d.Add "body",z_body
		d.Add "mchntOrderNo",randarr
		d.Add "notifyUrl", zlno2
		d.Add "payChannelId","2100000001" '支付宝0000000002 微信2100000001  
		d.Add "returnUrl", zlno2 
		d.Add "subject", show_body
		result=parseURL(d)
		xmlhttp.Open "POST", weburl&"pay/mingtian2/index.php", false
		xmlhttp.SetRequestHeader "content-type", "application/x-www-form-urlencoded"
		xmlhttp.Send result		
		codeurl=xmlhttp.responseTEXT
		'response.Write codeurl
		'response.End()
		Set json = toObject(codeurl)
		codeurl=split(json.extra,"&")
		sfd=replace(codeurl(0),"code_url="," ")
		sfd=trim(sfd)
		if err.number<>0 then conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"','Template/newbuy2/pay/index.asp','"&randarr&"','"&qudao&"','"&pid&"','PC')")
	end if
	

 	

	
	if cint(wxqitajiekou)=10 then '系统默认 优畅微信
		qudao="优畅"
		isshowerweima="yes"
			mch_id=toparkey("youchangid")
			key=toparkey("youchangkey")
			notify_url=toparkey("youchangno")
			tourl = "http://mapi.bosc.uline.cc/wechat/orders"
			payment_code="WX_OFFLINE_NATIVE"	
			total_fee=yingfuzongjia*100
			out_trade_no=randarr
			nonce_str=randarr
			body=show_bodyy										
			attach="buy"										
			spbill_create_ip=Request.ServerVariables("REMOTE_ADDR")
			trade_type="NATIVE"		
			Set packageParams = CreateObject("Scripting.Dictionary")
			packageParams.Add "mch_id", mch_id
			packageParams.Add "nonce_str", nonce_str
			packageParams.Add "body", body
			packageParams.Add "attach", attach 
			packageParams.Add "out_trade_no", out_trade_no
			packageParams.Add "total_fee", total_fee
			packageParams.Add "spbill_create_ip", spbill_create_ip
			packageParams.Add "notify_url", notify_url
			packageParams.Add "trade_type", trade_type 
			packageParams.Add "payment_code", payment_code
			strsign2 = createSHA1Sign(packageParams) & "&key="&key
			sign = UCase(md5(strsign2))
			packageParams.Add "sign", sign
			para = parseXML(packageParams)
			Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
			http.Option(4) = 13056
			http.Option(6) = False
			http.SetTimeouts 5000, 10000, 10000, 10000
			http.Open "POST", tourl, False
			http.SetRequestHeader "Connection", "Keep-Alive"
			http.SetRequestHeader "User-Agent", "Mozilla/4.0"
			http.SetRequestHeader "Content-Length", Len(data)
			http.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
			http.Send para
			body = BytesToBstr(http.ResponseBody, "utf-8")
			return_code = mysubstr(body, "<return_code>", "</return_code>")
			result_code = mysubstr(body, "<result_code>", "</result_code>")
			if return_code="SUCCESS" and result_code="SUCCESS" then 
			sfd = mysubstr(body, "<code_url>", "</code_url>")
			else
			conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"-"&body&"','Template/newbuy2/pay/index.asp','"&randarr&"','"&qudao&"','"&pid&"','PC')")
			response.Write "{""err"":""Err-1600，请尝试重新提交或使用其他支付方式，还可以联系平台客服""}"
			response.end
			end if
	end if
		
	
	if cint(wxqitajiekou)=12 then '优畅2微信
		qudao="优畅2"
		isshowerweima="yes"
			mch_id=youchangid2
			key=youchangkey2
			notify_url=youchangno2
			tourl = "http://mapi.bosc.uline.cc/wechat/orders"
			payment_code="WX_OFFLINE_NATIVE"	
			total_fee=yingfuzongjia*100
			out_trade_no=randarr
			nonce_str=randarr
			body=show_bodyy										
			attach="buy"										
			spbill_create_ip=Request.ServerVariables("REMOTE_ADDR")
			trade_type="NATIVE"		
			Set packageParams = CreateObject("Scripting.Dictionary")
			packageParams.Add "mch_id", mch_id
			packageParams.Add "nonce_str", nonce_str
			packageParams.Add "body", body
			packageParams.Add "attach", attach 
			packageParams.Add "out_trade_no", out_trade_no
			packageParams.Add "total_fee", total_fee
			packageParams.Add "spbill_create_ip", spbill_create_ip
			packageParams.Add "notify_url", notify_url
			packageParams.Add "trade_type", trade_type 
			packageParams.Add "payment_code", payment_code
			strsign2 = createSHA1Sign(packageParams) & "&key="&key
			sign = UCase(md5(strsign2))
			packageParams.Add "sign", sign
			para = parseXML(packageParams)
			Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
			http.Option(4) = 13056
			http.Option(6) = False
			http.SetTimeouts 5000, 10000, 10000, 10000
			http.Open "POST", tourl, False
			http.SetRequestHeader "Connection", "Keep-Alive"
			http.SetRequestHeader "User-Agent", "Mozilla/4.0"
			http.SetRequestHeader "Content-Length", Len(data)
			http.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
			http.Send para
			body = BytesToBstr(http.ResponseBody, "utf-8")
			return_code = mysubstr(body, "<return_code>", "</return_code>")
			result_code = mysubstr(body, "<result_code>", "</result_code>")
			if return_code="SUCCESS" and result_code="SUCCESS" then 
			sfd = mysubstr(body, "<code_url>", "</code_url>")
			else
			conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"-"&body&"','Template/newbuy2/pay/index.asp','"&randarr&"','"&qudao&"','"&pid&"','PC')")
			response.Write "{""err"":""Err-1600，请尝试重新提交或使用其他支付方式，还可以联系平台客服""}"
			response.end
			end if
	end if
	

	if cint(wxqitajiekou)=30 then '上海汇付-威富通微信
		qudao="汇付"
	    isshowerweima="yes"
		Set packageParams = CreateObject("Scripting.Dictionary")  'Server.CreateObject("Scripting.Dictionary")
		packageParams.Add "attach", z_body
		packageParams.Add "service", "pay.weixin.native"                     '接口类型  微信 pay.weixin.scancode  手q：pay.qq.jspay
		packageParams.Add "mch_id", huifu_id              '商户号
		packageParams.Add "out_trade_no", randarr          '商户订单号
		packageParams.Add "body", show_bodyy                     '商品描述
		packageParams.Add "total_fee", yingfuzongjia*100                   '总金额 ，以分为单位
		packageParams.Add "mch_create_ip", Request.ServerVariables("REMOTE_ADDR")                     '终端 IP
		packageParams.Add "notify_url", huifu_no         '通知回调地址，目前默认是空格，商户在测试支付和上线时必须改为自己的，且保证外网能访问到
		packageParams.Add "nonce_str", randarr       '随机字符串，商户可自定义
		strsign2 = createSHA1Sign(packageParams) & "&key="&huifu_key
		sign = UCase(md5(strsign2))
		packageParams.Add "sign", sign
		para = parseXML(packageParams)
		Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
		http.Option(4) = 13056
		http.Option(6) = False
		surl = "https://pay.swiftpass.cn/pay/gateway"
		http.SetTimeouts 5000, 10000, 10000, 10000
		http.Open "POST", surl, False
		http.SetRequestHeader "Connection", "Keep-Alive"
		http.SetRequestHeader "User-Agent", "Mozilla/4.0"
		http.SetRequestHeader "Content-Length", Len(data)
		http.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
		http.Send para
		body = BytesToBstrwft(http.ResponseBody)
		'response.Write server.HTMLEncode(body)
		Status = mysubstr(body, "<status><![CDATA[", "]]></status>")
		If Status = 0 Then result_code = mysubstr(body, "<result_code><![CDATA[", "]]></result_code>")
		If result_code = 0 Then	code_img_url = mysubstr(body, "<code_img_url><![CDATA[", "]]></code_img_url>")
		sfd=replace(code_img_url,"https://pay.swiftpass.cn/pay/qrcode?uuid="," ")
		sfd=replace(sfd,"https://pay2.swiftpass.cn/pay/qrcode?uuid="," ")
		sfd=replace(sfd,"%3A%2F%2F","://")
		sfd=replace(sfd,"%2F","/")
		sfd=replace(sfd,"%3F","?")
		sfd=replace(sfd,"%3D","=")
		sfd=replace(sfd,"%26","&")
if err.number<>0 or result_code=1 then conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"-"&body&"','Template/newbuy2/pay/index.asp','"&randarr&"','"&qudao&"','"&pid&"','PC')")
	end if

	if cint(wxqitajiekou)=31 then '上海汇付-威富通微信2
		qudao="汇付2"
	    isshowerweima="yes"
		Set packageParams = CreateObject("Scripting.Dictionary")  'Server.CreateObject("Scripting.Dictionary")
		packageParams.Add "attach", z_body
		packageParams.Add "service", "pay.weixin.native"                     '接口类型  微信 pay.weixin.scancode  手q：pay.qq.jspay
		packageParams.Add "mch_id", huifu_id2              '商户号
		packageParams.Add "out_trade_no", randarr          '商户订单号
		packageParams.Add "body", show_bodyy                     '商品描述
		packageParams.Add "total_fee", yingfuzongjia*100                   '总金额 ，以分为单位
		packageParams.Add "mch_create_ip", Request.ServerVariables("REMOTE_ADDR")                     '终端 IP
		packageParams.Add "notify_url", huifu_no2         '通知回调地址，目前默认是空格，商户在测试支付和上线时必须改为自己的，且保证外网能访问到
		packageParams.Add "nonce_str", randarr       '随机字符串，商户可自定义
		strsign2 = createSHA1Sign(packageParams) & "&key="&huifu_key2
		sign = UCase(md5(strsign2))
		packageParams.Add "sign", sign
		para = parseXML(packageParams)
		Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
		http.Option(4) = 13056
		http.Option(6) = False
		surl = "https://pay.swiftpass.cn/pay/gateway"
		http.SetTimeouts 5000, 10000, 10000, 10000
		http.Open "POST", surl, False
		http.SetRequestHeader "Connection", "Keep-Alive"
		http.SetRequestHeader "User-Agent", "Mozilla/4.0"
		http.SetRequestHeader "Content-Length", Len(data)
		http.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
		http.Send para
		body = BytesToBstrwft(http.ResponseBody)
		Status = mysubstr(body, "<status><![CDATA[", "]]></status>")
		If Status = 0 Then result_code = mysubstr(body, "<result_code><![CDATA[", "]]></result_code>")
		If result_code = 0 Then	code_img_url = mysubstr(body, "<code_img_url><![CDATA[", "]]></code_img_url>")
		sfd=replace(code_img_url,"https://pay.swiftpass.cn/pay/qrcode?uuid="," ")
		sfd=replace(sfd,"https://pay2.swiftpass.cn/pay/qrcode?uuid="," ")
		sfd=replace(sfd,"%3A%2F%2F","://")
		sfd=replace(sfd,"%2F","/")
		sfd=replace(sfd,"%3F","?")
		sfd=replace(sfd,"%3D","=")
		sfd=replace(sfd,"%26","&")
if err.number<>0 or result_code=1 then conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"-"&body&"','Template/newbuy2/pay/index.asp','"&randarr&"','"&qudao&"','"&pid&"','PC')")
	end if
	
	
	
	if cint(wxqitajiekou)=50 then '优畅50  【公众号URL直接访问  扫码URL生成二维码】
		qudao="优畅50"
	    isshowerweima="yes"
		mch_id=ycnewid50
		appid=ycnewappid50
		key=ycnewkey50
		notify_url=youchangno50
		Set packageParams = CreateObject("Scripting.Dictionary")
		packageParams.Add "appid", appid
		packageParams.Add "attach", z_body
		packageParams.Add "body", show_bodyy
		packageParams.Add "mch_id", mch_id
		packageParams.Add "method", "mbupay.unifpay.native"
		packageParams.Add "nonce_str", randarr
		packageParams.Add "notify_url", notify_url
		packageParams.Add "out_trade_no", randarr
		packageParams.Add "total_fee", yingfuzongjia*100
		strsign2 = createSHA1Sign(packageParams) & "&key="&key
		sign = UCase(md5(strsign2))
		packageParams.Add "sign", sign
		para = parseXML(packageParams)
		Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
		http.Option(4) = 13056
		http.Option(6) = False
		http.SetTimeouts 5000, 10000, 10000, 10000
		tourl = "https://api.tnbpay.com/pay/gateway"
		http.Open "POST", tourl, False
		http.SetRequestHeader "Connection", "Keep-Alive"
		http.SetRequestHeader "User-Agent", "Mozilla/4.0"
		http.SetRequestHeader "Content-Length", Len(data)
		http.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
		http.Send para
		body = BytesToBstr(http.ResponseBody, "utf-8")
		'response.Write server.HTMLEncode(body)
		'response.End()
		return_code = mysubstr(body, "<return_code><![CDATA[", "]]></return_code>")
		if return_code="FAIL" then
		return_msg = mysubstr(body, "<return_msg><![CDATA[", "]]></return_msg>")
		'response.Write return_msg
		conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"-"&return_msg&"','Template/newbuy2/pay/index.asp','"&randarr&"','"&qudao&"','"&pid&"','PC')")
		response.Write "{""err"":""Err-1600，请尝试重新提交或使用其他支付方式，还可以联系平台客服""}"
		response.End()
		end if
		result_code = mysubstr(body, "<result_code><![CDATA[", "]]></result_code>")
		if return_code="SUCCESS" and result_code="SUCCESS" then
		code_url = mysubstr(body, "<code_url><![CDATA[", "]]></code_url>")
		'response.Write code_url&"<br>"
		sfd=code_url
		end if
	end if
	
	if cint(wxqitajiekou)=51 then '优畅51 【公众号URL直接访问  扫码URL生成二维码】
		qudao="优畅51"
	    isshowerweima="yes"
		mch_id=ycnewid51
		appid=ycnewappid51
		key=ycnewkey51
		notify_url=youchangno51
		Set packageParams = CreateObject("Scripting.Dictionary")
		packageParams.Add "appid", appid
		packageParams.Add "attach", z_body
		packageParams.Add "body", show_bodyy
		packageParams.Add "mch_id", mch_id
		packageParams.Add "method", "mbupay.unifpay.native"
		packageParams.Add "nonce_str", randarr
		packageParams.Add "notify_url", notify_url
		packageParams.Add "out_trade_no", randarr
		packageParams.Add "total_fee", yingfuzongjia*100
		strsign2 = createSHA1Sign(packageParams) & "&key="&key
		sign = UCase(md5(strsign2))
		packageParams.Add "sign", sign
		para = parseXML(packageParams)
		Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
		http.Option(4) = 13056
		http.Option(6) = False
		http.SetTimeouts 5000, 10000, 10000, 10000
		tourl = "https://api.tnbpay.com/pay/gateway"
		http.Open "POST", tourl, False
		http.SetRequestHeader "Connection", "Keep-Alive"
		http.SetRequestHeader "User-Agent", "Mozilla/4.0"
		http.SetRequestHeader "Content-Length", Len(data)
		http.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
		http.Send para
		body = BytesToBstr(http.ResponseBody, "utf-8")
		'response.Write server.HTMLEncode(body)
		'response.End()
		return_code = mysubstr(body, "<return_code><![CDATA[", "]]></return_code>")
		if return_code="FAIL" then
		return_msg = mysubstr(body, "<return_msg><![CDATA[", "]]></return_msg>")
		'response.Write return_msg
		conn.Execute("Insert Into ayerr(errcon,errlu,errdd,errqudao,errfs,errpcwap) values('"&Err.Description&"-"&return_msg&"','Template/newbuy2/pay/index.asp','"&randarr&"','"&qudao&"','"&pid&"','PC')")
		response.Write "{""err"":""Err-1600，请尝试重新提交或使用其他支付方式，还可以联系平台客服""}"
		response.End()
		end if
		result_code = mysubstr(body, "<result_code><![CDATA[", "]]></result_code>")
		if return_code="SUCCESS" and result_code="SUCCESS" then
		code_url = mysubstr(body, "<code_url><![CDATA[", "]]></code_url>")
		'response.Write code_url&"<br>"
		sfd=code_url
		end if
	end if
	
	
end if


'京东支付
if trim(pid)="JDPAY" then
end if

if err.number<>0 then response.Write "{""err"":""Err-1599-["&Err.Description&"]，请尝试重新提交或使用其他支付方式，还可以联系平台客服""}":response.end 


'浏览器缓存订单号
hostbiaoshi="A"		'服务器标示
if request.Cookies("ikpayddh")<>"" then

	ikpayddhstr=request.Cookies("ikpayddh")
	sumikpayddh=split(ikpayddhstr,"|")					'数量  6     Ubound(sumikpayddh)     总数-1
	
	if Ubound(sumikpayddh)>=30 then						'上限个数
	laststr=sumikpayddh(Ubound(sumikpayddh)-1)&"|"		'A&DAB164215112269824|
	laststrCookies=replace(ikpayddhstr,laststr," ")
	laststrCookies=trim(laststrCookies)
	response.Cookies("ikpayddh")=laststrCookies
	end if

	'if instr(1,request.Cookies("ikpayddh"),randarr&"|")=0 then
	response.Cookies("ikpayddh")=hostbiaoshi&"&"&randarr&"|"&request.Cookies("ikpayddh")
	response.Cookies("ikpayddh").expires=DateAdd("n",60,now())
	'end if
	
else
response.Cookies("ikpayddh")=hostbiaoshi&"&"&randarr&"|"
response.Cookies("ikpayddh").expires=DateAdd("n",60,now())
end if




'rs.open "select top 1 aydingdansum from "&ddku&" where aydingdansum='"&randarr&"' order by aydingdanid desc",conn,1,1
'if not(rs.bof and rs.eof) then
'response.Write "{""err"":""订单号重复""}"
'response.End()
'end if
'rs.close


'二维码 提交方式 
if isshowerweima="yes" then
	conn.Execute("Insert Into "&ddku&"(isalipayfz,apicheng,aydingdansum,aydingdanuser,aydigndanyf,aydingdanyj,aydingdanjin,aydingdanzj,shangqq,aydingdanin,aydingdancb,ayddquantity,ayddfeileiid,ayddshangid,aybuyipxx,ayddcontact,ayddpid,aydingdansj,aydingdanpass,ayddyouhuiquanzhi,ayddyouhuiquan,ayddemail,ayddzffangshi,ayddsign,dailikuo,openid,msnurl,qudao,ayddbuyid,lailuyu) values('"&isalipayfz_2&"','"&jiekoulirun&"','"&randarr&"','"&gooduserid&"','"&yingfuzongjia&"','"&goodyj&"','"&danjia&"','"&showddzj&"','"&shanghuqq&"','"&Formatnumber(ddzj,2,true,0,0)&"','"&aydingdancb&"','"&quantity&"','"&clng(feilei)&"','"&clng(shangid)&"','"&aybuyipxx&"','"&contact&"','"&trim(pid)&"','"&now()&"','"&trim(tikapass)&"','"&youhuiquanzhi&"','"&youhuiquan&"','"&email&"','"&zhifufangshi&"','"&strsign&"','"&dailistr&"','"&openid&"','"&msnurl&"','"&qudao&"','"&ayddbuyid&"','"&request.Cookies("lailuyu")&"')")
	conn.Execute("Insert Into aybuylx(aylxcon,aylxku,aydddsum,aylxbuyid,qudao,suid) values('"&contact&"','"&ddku&"','"&randarr&"','"&ayddbuyid&"','"&qudao&"','"&gooduserid&"')")
	if err.number<>0 then response.Write "{""err"":""Err-1833-"&Err.Description&"入库错误，请重新尝试或联系管理员""}":response.end 	
	restr=restr&"""fs"":""erweima"","		
	restr=restr&"""code"":"""&trim(ReplaceTrim(sfd))&"""}"
	response.Cookies("timed")=now()
	response.Write restr
	response.end
end if




'自收订单
iserweimashou="no"
if pid="ALIPAY" and (cint(aliqitajiekou)=90 or cint(aliqitajiekou)=91) then iserweimashou="yes"
if pid="WEIXIN" and (cint(wxqitajiekou)=90 or cint(wxqitajiekou)=91) then iserweimashou="yes"
if pid="QQPAY" and (cint(qqqitajiekou)=90 or cint(qqqitajiekou)=91) then iserweimashou="yes"


if iserweimashou="yes" then   
nextjsum=zishoujj(yingfuzongjia,zishoufs,contact)	'应加分
jjjin=ccur(yingfuzongjia)+ccur(nextjsum)/100	'加价后应付价格
conn.Execute("Insert Into ddlasttime(ddhao) values('"&randarr&"')")
conn.Execute("Insert Into aybuylx(aylxcon,aylxku,aydddsum,aylxbuyid,aylxjin,zishoufs,jjjzj,qudao,suid,zhifufs) values('"&contact&"','"&ddku&"','"&randarr&"','"&ayddbuyid&"','"&yingfuzongjia&"','"&zishoufs&"','"&nextjsum&"','"&qudao&"','"&gooduserid&"','"&zhifufs&"')")
else
conn.Execute("Insert Into aybuylx(aylxcon,aylxku,aydddsum,aylxbuyid) values('"&contact&"','"&ddku&"','"&randarr&"','"&ayddbuyid&"')")
end if

conn.Execute("Insert Into "&ddku&"(isalipayfz,apicheng,aydingdansum,aydingdanuser,aydigndanyf,aydingdanyj,aydingdanjin,aydingdanzj,shangqq,aydingdanin,aydingdancb,ayddquantity,ayddfeileiid,ayddshangid,aybuyipxx,ayddcontact,ayddpid,aydingdansj,aydingdanpass,ayddyouhuiquanzhi,ayddyouhuiquan,ayddemail,ayddzffangshi,ayddsign,dailikuo,openid,msnurl,qudao,ayddbuyid,lailuyu,zishoufs,jjjzj,yongjin) values('"&isalipayfz_2&"','"&jiekoulirun&"','"&randarr&"','"&gooduserid&"','"&yingfuzongjia&"','"&goodyj&"','"&danjia&"','"&showddzj&"','"&shanghuqq&"','"&Formatnumber(ddzj,2,true,0,0)&"','"&aydingdancb&"','"&quantity&"','"&clng(feilei)&"','"&clng(shangid)&"','"&aybuyipxx&"','"&contact&"','"&trim(pid)&"','"&now()&"','"&trim(tikapass)&"','"&youhuiquanzhi&"','"&youhuiquan&"','"&email&"','"&zhifufangshi&"','"&strsign&"','"&dailistr&"','"&openid&"','"&msnurl&"','"&qudao&"','"&ayddbuyid&"','"&request.Cookies("lailuyu")&"','"&zishoufs&"','"&nextjsum&"','"&yingkouyongjin&"')")


if err.number<>0 then response.Write "{""err"":""Err-1844-"&Err.Description&"入库错误，请重新尝试或联系管理员""}":response.end 	

if isxinyongka="1" then pid=" "
response.Cookies("openid")=""




'表单 提交方式
restr=restr&"""fs"":""biaodan"","	
formstr="<form "&urlact&" name=formtj id=formtj target=_blank>"



'初始化 爱普接口 清空其他无用参数 开始
'初始化 爱普接口 清空其他无用参数 结束


if isguolvallcan="no" then
	if zhifufangshi<>99 and ccur(yingfuzongjia)<>0 then
	formstr=formstr&"<input type=hidden name=z_total_fee value="&yingfuzongjia&" />"
	formstr=formstr&"<input type=hidden name=z_trade_no value="&randarr&" />"
	formstr=formstr&"<input type=hidden name=z_body value="&z_body&" />"
	formstr=formstr&"<input type=hidden name=z_weburl value="&apiurl&" />"
	formstr=formstr&"<input type=hidden name=contact value="&contact&" />"
	
		if zhifufangshi=0 and wangyin="1" then    '支付宝 网银直连
		formstr=formstr&"<input type=hidden name=z_bankid value="&pid&" />"
		formstr=formstr&"<input type=hidden name=WIDseller_email value="&paymail&" />"
		formstr=formstr&"<input type=hidden name=WIDout_trade_no value="&randarr&" />"
		formstr=formstr&"<input type=hidden name=WIDsubject value="&show_body1&" />"
		formstr=formstr&"<input type=hidden name=WIDtotal_fee value="&yingfuzongjia&" />"
		formstr=formstr&"<input type=hidden name=WIDdefaultbank value="&pid&" />"
		formstr=formstr&"<input type=hidden name=WIDbody value="&z_body&" />"
		formstr=formstr&"<input type=hidden name=WIDshow_url value="&zweburl&" />"
		end if
	
	
		if zhifufangshi=0 and wangyin="2" then    '财付通 网银直连
		formstr=formstr&"<input type=hidden name=order_no value="&randarr&" />"
		formstr=formstr&"<input type=hidden name=product_name value="&show_body1&" />"
		formstr=formstr&"<input type=hidden name=order_price value="&yingfuzongjia&" />"
		formstr=formstr&"<input type=hidden name=trade_mode value=1 />"
		formstr=formstr&"<input type=hidden name=remarkexplain value="&show_body1&" />"
		formstr=formstr&"<input type=hidden name=attach value="&z_body&" />"
		
		'formstr=formstr&"<input type=hidden name=bank_type_value value="&pid&" />"
		'formstr=formstr&"<input type=hidden name=z_bankid value="&pid&" />"
		end if
		
		if zhifufangshi=2 and pid="ALIPAY" then       '支付宝帐号
		formstr=formstr&"<input type=hidden name=z_bankid value=ALIPAY />"
		
			if isqtalipay="yes" then
						'if cint(aliqitajiekou)=40 then '艺星官方
						'formstr=formstr&"<input type=hidden name=WIDout_trade_no value="&randarr&" />"
						'formstr=formstr&"<input type=hidden name=WIDtotal_fee value="&yingfuzongjia&" />"
						'formstr=formstr&"<input type=hidden name=WIDbody value="&z_body&" />"
						'end if
						if cint(aliqitajiekou)=40 or cint(aliqitajiekou)=41 or cint(aliqitajiekou)=42 then  '一扫付1   一扫付2  一扫付3
							formstr=formstr&"<input type=hidden name=orderId value="&randarr&" />"
							formstr=formstr&"<input type=hidden name=orderAmount value="&yingfuzongjia&" />"
							formstr=formstr&"<input type=hidden name=payMethod value=2 />"
							formstr=formstr&"<input type=hidden name=payType value=21 />"
						end if
						if cint(aliqitajiekou)=90 or cint(aliqitajiekou)=91 then '人工收款
						formstr=formstr&"<input type=hidden name=total_fee value="&yingfuzongjia&" />"
						formstr=formstr&"<input type=hidden name=out_trade_no value="&randarr&" />"
						formstr=formstr&"<input type=hidden name=jjjin value="&jjjin&" />"
						formstr=formstr&"<input type=hidden name=act value=ali />"
						formstr=formstr&"<input type=hidden name=shouid value="&ayshoukuanid&" />"
						formstr=formstr&"<input type=hidden name=allname value="&allname&" />"
						end if
						if cint(aliqitajiekou)=92  then '商家自收
						formstr=formstr&"<input type=hidden name=total_fee value="&yingfuzongjia&" />"
						formstr=formstr&"<input type=hidden name=out_trade_no value="&randarr&" />"
						formstr=formstr&"<input type=hidden name=act value=ali />"
						formstr=formstr&"<input type=hidden name=shouid value="&picurl&" />"
						end if
						
			else
				formstr=formstr&"<input type=hidden name=WIDseller_email value="&toparkey("ayalipaymail")&" />"
				formstr=formstr&"<input type=hidden name=WIDout_trade_no value="&randarr&" />"
				formstr=formstr&"<input type=hidden name=WIDsubject value="&show_body&" />"
				formstr=formstr&"<input type=hidden name=WIDtotal_fee value="&yingfuzongjia&" />"
				formstr=formstr&"<input type=hidden name=WIDbody value="&z_body&" />"
				formstr=formstr&"<input type=hidden name=WIDshow_url value="&zweburl&" />"
			end if
		end if
		
		if zhifufangshi=4 and pid="WEIXIN" then   
		formstr=formstr&"<input type=hidden name=z_bankid value=WEIXIN />"
				if isqtalipay="yes" then
						if cint(wxqitajiekou)=40 or cint(wxqitajiekou)=41 or cint(wxqitajiekou)=42 then	 '一扫付1   一扫付2  一扫付3
							formstr=formstr&"<input type=hidden name=orderId value="&randarr&" />"
							formstr=formstr&"<input type=hidden name=orderAmount value="&yingfuzongjia&" />"
							formstr=formstr&"<input type=hidden name=payMethod value=1 />"
							formstr=formstr&"<input type=hidden name=payType value=11 />"
						end if
						if cint(wxqitajiekou)=90 or cint(wxqitajiekou)=91 then '人工收款
						formstr=formstr&"<input type=hidden name=total_fee value="&yingfuzongjia&" />"
						formstr=formstr&"<input type=hidden name=out_trade_no value="&randarr&" />"
						formstr=formstr&"<input type=hidden name=jjjin value="&jjjin&" />"
						formstr=formstr&"<input type=hidden name=act value=wei />"
						formstr=formstr&"<input type=hidden name=shouid value="&ayshoukuanid&" />"
						formstr=formstr&"<input type=hidden name=allname value="&allname&" />"
						end if
						if cint(wxqitajiekou)=92  then '商家自收
						formstr=formstr&"<input type=hidden name=total_fee value="&yingfuzongjia&" />"
						formstr=formstr&"<input type=hidden name=out_trade_no value="&randarr&" />"
						formstr=formstr&"<input type=hidden name=act value=wei />"
						formstr=formstr&"<input type=hidden name=shouid value="&picurl&" />"
						end if
				end if
		end if
		
		if zhifufangshi=5 and pid="QQPAY" then   '微信 扫码收款-人工
		formstr=formstr&"<input type=hidden name=z_bankid value=QQPAY />"
			if cint(qqqitajiekou)=90 or cint(qqqitajiekou)=91 then '人工收款
			formstr=formstr&"<input type=hidden name=total_fee value="&yingfuzongjia&" />"
			formstr=formstr&"<input type=hidden name=out_trade_no value="&randarr&" />"
			formstr=formstr&"<input type=hidden name=jjjin value="&jjjin&" />"
			formstr=formstr&"<input type=hidden name=act value=qq />"
			formstr=formstr&"<input type=hidden name=shouid value="&ayshoukuanid&" />"
			formstr=formstr&"<input type=hidden name=allname value="&allname&" />"
			end if
			if cint(qqqitajiekou)=92  then '商家自收
			formstr=formstr&"<input type=hidden name=total_fee value="&yingfuzongjia&" />"
			formstr=formstr&"<input type=hidden name=out_trade_no value="&randarr&" />"
			formstr=formstr&"<input type=hidden name=act value=qq />"
			formstr=formstr&"<input type=hidden name=shouid value="&picurl&" />"
			end if
			
		end if

			
		

		
	end if  
end if
        
formstr=formstr&"</form>"
restr=restr&"""bdlist"":"""&formstr&"""}"

if err.number<>0 then response.Write "{""err"":""Err-1769-"&Err.Description&"请联系管理员""}":response.end
response.Cookies("timed")=now()
response.Write restr


conn.close
set conn=nothing


%>