<!--#include file="../../conn/conn.asp"-->
<!--#include file="../../inc/Commoncode.asp"-->
<!--#include file="../../inc/pay_md5.asp"-->
<!--#include file="../../inc/hmac-md5.asp"-->
<!--#include file="../../inc/base64.asp"-->
<%
r0_Cmd		=	Request.QueryString("r0_Cmd")
r1_Code		=	Request.QueryString("r1_Code")
r2_TrxId	=	Request.QueryString("r2_TrxId")
r3_Amt		=	Request.QueryString("r3_Amt")
r4_Cur		=	Request.QueryString("r4_Cur")
r5_Pid		=	Request.QueryString("r5_Pid")
r6_Order	=	Request.QueryString("r6_Order")
r7_Uid		=	Request.QueryString("r7_Uid")
r8_MP		=	Request.QueryString("r8_MP")
r9_BType	=	Request.QueryString("r9_BType") 	
hmac		=	Request.QueryString("hmac")

set rs=server.CreateObject("adodb.recordset")
query="select * from Job_pay_online where chk=1 and payflag=7"
rs.open query,conn,1,1
if not rs.eof then
ipayno=rs("shbh")
ipaykey=rs("pay_key")
else
Response.Write ("<script language=JavaScript>{alert('错误：对不起，系统配置错误！');location.href = 'javascript:history.go(-1)';}</script>")
response.end
end if
rs.close  

if ipayno="" then
Response.Write ("<script language=JavaScript>{alert('错误：对不起，系统配置错误！');location.href = 'javascript:history.go(-1)';}</script>")
response.end
end if

v_mid=replace(strAnsi2Unicode(Base64decode(strUnicode2Ansi(ipayno))),chr(13)&chr(10),"<br>")
key=replace(strAnsi2Unicode(Base64decode(strUnicode2Ansi(ipaykey))),chr(13)&chr(10),"<br>")
p1_MerId = v_mid																											
merchantKey = key
'取得签名数据前的字符串，一定按照文档中标明的签名顺序进行
sbOld = sbOld + CStr(p1_MerId)
sbOld = sbOld + r0_Cmd
sbOld = sbOld + r1_Code
sbOld = sbOld + r2_TrxId
sbOld = sbOld + r3_Amt
sbOld = sbOld + r4_Cur
sbOld = sbOld + r5_Pid
sbOld = sbOld + r6_Order
sbOld = sbOld + r7_Uid
sbOld = sbOld + r8_MP
sbOld = sbOld + r9_BType
bRet = HmacMd5(sbOld,merchantKey)
'校验码正确
returnMsg	= ""
If hmac=bRet Then
  If(r1_Code="1") Then
	query = "select * from JOB_pay_back where pay_oid='"&r6_Order&"'"
	rs.Open query, conn, 1, 1
	If rs.RecordCount <> 1 Then
	Response.Write ("<script language=JavaScript>{alert('对不起，通讯故障，请与本站联系！');location.href = 'javascript:history.go(-1)';}</script>")
	response.end
	ElseIf rs("pay_isucceed") = 1 Then
	Response.Write ("<script language=JavaScript>{alert('对不起，该支付已经结算完毕！');location.href = 'javascript:history.go(-1)';}</script>")
	response.end
	End If
	rs.Close
	If(r9_BType="1") Then
		payok=true					
	ElseIf(r9_BType="2") Then				
		Response.write("success")
		payok=true
	End IF
  else
	 Response.Write ("<script language=JavaScript>{alert('对不起，该支付已经处理完毕！');location.href = 'javascript:history.go(-1)';}</script>")
	response.end
  End IF
Else
	payok=false
End If

''''''''''''''''

If payok Then
''''''''''''''''''''''''''''''会员入款
	conn.execute("Update JOB_pay_back set pay_isucceed =1,pay_pmode='"&v_pmode&"' where pay_oid='"&r6_Order&"'")
	sql="select * from job_member where member_login='"&Request.Cookies(FRHRCMS)("user_login")&"'"
	rs.open sql,conn,1,3
	If rs.RecordCount <> 1 Then
	  payok=false
	  rs.close
	  set rs=nothing
	else
	rs("Member_balance")=rs("Member_balance")+fix(r3_Amt)
	rs.update
	rs.close
	set rs=nothing
	end if
else
    conn.execute("Update JOB_pay_back set pay_pstring='"&r8_MP&"',pay_isucceed=2 where pay_oid='"&r6_Order&"'")
end if
conn.close
set conn=nothing
%>
<HTML><HEAD><TITLE>银行在线支付</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<STYLE>TD {
	FONT-SIZE: 9pt; LINE-HEIGHT: 14pt
}
</STYLE>

<META content="MSHTML 6.00.2800.1226" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">
<br>
<br>
<br>
<TABLE height=400 cellSpacing=0 cellPadding=0 width=500 
background=../pay_img/cmbchinabg.jpg border=0 align="center" style="border:#000000 1px double">
  <TBODY> 
  <TR>
    <TD vAlign=top>
      <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
        <TBODY>
        <TR>
          <TD><IMG height=86 src="../pay_img/blank.gif" width=10></TD>
          <TD>&nbsp;</TD></TR>
        <TR>
          <TD width=236><img height=1 src="../pay_img/blank.gif" 
            width=236></TD>
          <TD vAlign=top> 
            <P><% if payok=true then %><font color="#FF0000"><b>恭喜您！</b></font><br>
              <br>
              您所支付的款项：<br>
              <br>
              人民币：<b><font color="#FF0000"><%=r3_Amt%></font>元</b><br>
              <br>
              已经成功转到您的会员号下！<br>
			  <% else %>
              <font color="#FF0000"><b><font color="#0000FF">对不起！</font></b></font><br>
              <br>
              您所支付的款项：<br>
              <br>
              人民币：<b><font color="#FF0000"><%=r3_Amt%></font>元</b><br>
              <br>
              因操作失败未能转到您的会员号下！ 
			  <% end if %></P>
	 <P>&nbsp;</P>
	 </TD>
	 </TR>
	 </TBODY>
	 </TABLE>
	 </TD>
	 </TR>
	 </TBODY>
	 </TABLE>
	 </BODY>
</HTML>