<!--#include file="config.asp"-->
<!--#include file="check.asp"-->
<!--#include file="../inc/cls_payment.asp"-->
<%
Dim m_orderid,addmoney,m_oamount,m_ocomment
Dim wp,strChinaeBank
strChinaeBank = Split(Newasp.ChinaeBank, "|||")
Set wp = New WebPayment_Cls
wp.PayPlatform = CInt(Newasp.StopBankPay)
wp.Paymentid = Trim(strChinaeBank(0))
wp.Paymentkey = Trim(strChinaeBank(1))
wp.Percent = Newasp.CheckNumeric(strChinaeBank(2))
wp.Comment = "会员充值"
wp.ReceivePage
m_orderid = Newasp.CheckInfuse(wp.Orderid,30)
addmoney = wp.Buymoney
m_oamount = wp.Paymoney
m_ocomment = wp.Comment
Select Case CInt(wp.ErrNumber)
Case 0
	SaveUserInfo m_orderid,addmoney,m_oamount,m_ocomment
Case 3
	ErrMsg = wp.Description
	Founderr = True
Case 4
	ErrMsg = wp.Description
	Founderr = True
Case 5
	ErrMsg = wp.Description
	Founderr = True
Case 6
	ErrMsg = wp.Description
	Founderr = True
Case 8
	ErrMsg = wp.Description
	Founderr = True
End Select
Set wp = Nothing
If Founderr = True Then
	Call Returnerr(ErrMsg)
End If
CloseConn
Function SaveUserInfo(OrderForm,addmoney,realmoney,readme)
	Dim Rs,SQL
	addmoney = Newasp.CheckNumeric(addmoney)
	realmoney = Newasp.CheckNumeric(realmoney)
	Set Rs = Newasp.Execute("SELECT id FROM xp90com_AddMoney WHERE OrderForm='"& Newasp.CheckRequest(OrderForm,50) &"'")
	If Not (Rs.BOF And Rs.EOF) Then
		ErrMsg = ErrMsg + "<li>认证信息出错，请不要重复提交数据,此次交易失败！！！</li>"
		Founderr = True
		Set Rs = Nothing
		Exit Function
	End If
	Set Rs = Nothing
	If Founderr = True Then Exit Function
	Set Rs = Server.CreateObject("ADODB.Recordset")
	SQL = "SELECT * FROM xp90com_AddMoney WHERE (id is null)"
	Rs.Open SQL,Conn,1,3
	Rs.AddNew
		Rs("userid").Value = Newasp.memberid
		Rs("username").Value = Newasp.membername
		Rs("title").Value = Newasp.ChkFormStr(readme)
		Rs("OrderForm").Value = Trim(OrderForm)
		Rs("addmoney").Value = Newasp.CheckNumeric(realmoney)
		Rs("addtime").Value = Now()
		Rs("readme").Value = Newasp.ChkFormStr(readme)
		Rs("paytype").Value = "在线支付"
		Rs("finished").Value = 1
		Rs("deletion").Value = 0
	Rs.Update
	Rs.Close:Set Rs = Nothing
	Newasp.Execute ("UPDATE xp90com_User SET usermoney=usermoney+"& CCur(addmoney) &" WHERE username='"& Newasp.CheckRequest(Newasp.membername,50) &"' And userid="& CLng(Newasp.memberid))
	Set Rs = Server.CreateObject("ADODB.Recordset")
	SQL = "SELECT * FROM xp90com_Account WHERE (AccountID is null)"
	Rs.Open SQL,Conn,1,3
	Rs.addnew
		Rs("payer").Value = Newasp.membername
		Rs("payee").Value = Newasp.SiteName
		Rs("product").Value = Newasp.ChkFormStr(readme)
		Rs("Amount").Value = 1
		Rs("unit").Value = "次"
		Rs("price").Value = CCur(addmoney)
		Rs("TotalPrices").Value = Newasp.CheckNumeric(realmoney)
		Rs("DateAndTime").Value = Now()
		Rs("Accountype").Value = 0
		Rs("Explain").Value = Newasp.ChkFormStr(readme)
		Rs("Reclaim").Value = 0
	Rs.update
	Rs.Close:Set Rs = Nothing
	Call Returnsuc("<li>恭喜您！认证成功，会员充值完成。</li><li>实收金额："& FormatCurrency(realmoney,2,-1) &" 元</li><li>充值金额："& FormatCurrency(addmoney,2,-1) &" 元</li><li>此次所用手续费："& FormatCurrency(realmoney-addmoney,2,-1) &" 元</li>")
End Function
%>
