<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="../Include/conn.asp"-->
<!--#include file="../Include/ConnDatabase.asp"-->
<%
'=====================================
'天天企业网站管理系统  TianTianCMS
'天天网络科技工作室版权所有
'官方客服中心 http://www.ip126.com
'QQ:530051328 mail:bbfhq@163.com
'=====================================
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>钱包在线支付</title>
</head>
<%
'接收网站参数开始==========
dim dingdan,product_name,order_price,mainname,Paypassword
dingdan=request("ddhm")'订单号码
product_name="产品订购"'支付项目
order_price=request("alimoney")'支付金额
mainname=request("username")'会员名称
Paypassword=md5(request("Paypassword"))'支付密码
'接收网站参数结束==========

If request("pay")="yes" Then
set rs = Server.CreateObject("ADODB.RecordSet")
sql="select * from TianTianCMS_Members where MemName='"&mainname&"' and wallet>"&order_price&" and Paypassword='"&Paypassword&"'"
rs.open sql,conn,1,3
If rs.eof and rs.bof  then'如果不存在会员或会员帐户金额不足时
response.Write "不存在此会员或会员帐户金额不足或支付密码不对！"
response.end
Else
rs("wallet")=rs("wallet")-Formatnumber(order_price,2,-1,-1,0)'扣款
rs.update

'回写数据库支付状态==========================================
Dim username,aliname
set rs = Server.CreateObject("ADODB.RecordSet")
sql="select * from TianTianCMS_Order where ddhm='"&dingdan&"' and cash="&order_price&""
rs.open sql,conn,1,3
If rs("admincl")=0 then'如果接收其它方式支付的通知并处理业务成功，不再重复操作
rs("zfqr")=1'同时更新用户订单付款状态
rs("zffs")=1'同时更新用户订单付款方式
rs("admincl")=1'同时更新用户订单审核状态
rs("ddshsj")=now()
rs("Payment")="钱包支付"
rs.update

Dim Products_id,Products_num,amount
Products_id=split(rs("Products_id"),"|")
Products_num=split(rs("Products_num"),"|")
amount=split(rs("amount"),"|")
Call CloseRs(rs)
'将订单按商品详细记录开始，之前要读出数组参数＝＝＝＝＝＝＝＝
for i=1 to Ubound(Products_id)
set rs = server.createobject("adodb.recordset")
sql="select * from TianTianCMS_Products where ID="&CInt(Products_id(i))
rs.open sql,conn,1,3
rs("sales_amount")=rs("sales_amount")+CInt(Products_num(i))'销售数量
rs("Stock")=rs("Stock")-CInt(Products_num(i))'减去库存
rs("amount")=rs("amount")+Formatnumber(amount(i),2,-1,-1,0)'货款总额
rs.update
Next
Call CloseRs(rs)
for i=1 to Ubound(Products_id)
set rs = server.createobject("adodb.recordset")
sql="select * from TianTianCMS_Sales"
rs.open sql,conn,1,3
rs.addnew
rs("goodsid")=Products_id(i)'商品ID号
rs("sales_num")=CInt(Products_num(i))'销量
rs("sales_amount")=Formatnumber(amount(i),2,-1,-1,0)'货款总额
rs("ddshsj")=now()
rs.update
Next
'将订单按商品详细记录结束＝＝＝＝＝＝＝＝
End if'如果接其它方式支付的通知并处理业务成功，不再重复操作
Call CloseRs(rs)
set rs = server.createobject("adodb.recordset")
sql="select * from TianTianCMS_financiallog"
rs.open sql,conn,1,3
rs.addnew
rs("members")=mainname
rs("ddhm")=dingdan
rs("OrderName")=product_name
rs("spending")=Formatnumber(order_price,2,-1,-1,0)
rs("operator")=mainname
rs("Operatingtime")=now()
rs("audit")=true'同时更新审核状态
rs("audittime")=now()
rs.update
End if
Call CloseRs(rs)
Call CloseDB(conn)
'回写数据库支付状态end=======================================
response.Write "<script language=javascript>alert('操作成功!');window.close();</script>"
response.end
End if%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>会员钱包付款通道</TITLE>
<META content="MSHTML 6.00.3790.2577" name=GENERATOR>

<style type="text/css">
<!--
a:link {
	color: #003399;
}
.px12 {
	font-size: 12px;
}
a:visited {
	color: #003399;
}
a:hover {
	color: #FF6600;
}
.px14 {
	font-size: 14px;
}
.px12hui {
	font-size: 12px;
	color: #999999;
}
.STYLE2 {font-size: 14px; font-weight: bold; }
-->
</style>
</HEAD>
<BODY topMargin=0>

<div align="center">

  <table width="760" height="25" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td></td>
    </tr>
  </table>
  <table width="760" height="406" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td align="center" valign="top"><table width="760" border="0" cellspacing="0" cellpadding="3" align="center">
        <tr>
          <td height="30" width="5" bgcolor="#666666"></td>
          <td width="743" height="30" bgcolor="#FF6600"><font style="color:#FFFFFF;font-size:14px;"><B> 从<%=mainname%>的钱包中支付购物款</B></font></td>
        </tr>
      </table>
          <table width="760" height="42" border="0" align="center" cellpadding="0" cellspacing="0">
               <tr> <td height="30" ><span class="STYLE2">订单信息</span></td>
            </tr>
        </table>
        <table width="760" border="0" cellspacing="0" cellpadding="0" align="center" height="1">
            <tr>
              <td width="740" bgcolor="#CCCCCC"></td>
              <td width="20"></td>
            </tr>
        </table>
        <table width="760" border="0" align="center" cellpadding="0" cellspacing="0">

           <form action="?pay=yes" method="get" name="directFrm" >
            <tr>
              <td align="left"><table width="760" height="30" border="0" align="left" cellpadding="0" cellspacing="1" bgcolor="#FFCC00">
                  <tr>
                    <td align="center" valign="top" bgcolor="#FFFFEE"><table width="760" height="351" border="0" cellpadding="6" cellspacing="0" class="px14" style="display:">
                      <tr>
                        <td height="26" align="right" valign="top">&nbsp;</td>
                        <td valign="top"> 　 </td>
                        <td width="262" rowspan="15" valign="top"><table width="100%" border="0" align="left" cellpadding="0" cellspacing="5">

                            <tr>
                              <td height="24"><font style="color:#000000;font-size:12px;"><b>说明1：</b></font></td>
                            </tr>
                            <tr>
                              <td height="24" align="left"><font style="color:#000000;font-size:12px;">本通道为采用会员钱包付款。请在支付前与本网站达成一致。</font></td>
                            </tr>
                            <tr>
                              <td height="24"><font style="color:#000000;font-size:12px;"><b>说明2：</b></font></td>
                            </tr>
                            <tr>
                              <td height="24" align="left"><font style="color:#000000;font-size:12px;">请务必确认好订单和货款后，再付款。<!--可以在快速付款通道里的“付款概要”和“订单金额”中填入相应的订单信息。--></font></td>
                            </tr>
                        </table></td>
                      </tr>
                      <tr>
                        <td width="96" height="26" align="right" valign="top">收&nbsp;款&nbsp;&nbsp;方： </td>
                        <td width="353" valign="top" align="left"><%=site_name_ch %></td>
                      </tr>
                      <tr>
                        <td align="right" valign="top">订单编号： </td>
                        <td valign="top" align="left"><%=dingdan%><input type="hidden" name="ddhm" maxlength="50" size="18"  value="<%=dingdan%>" /></td>
                      </tr>
                      <tr>
                        <td align="right" valign="top">付款项目： </td>
                        <td valign="top" align="left"><span style="color:#000000;font-size:12px;"><%=product_name%>
                          <input name="product_name" value="<%=product_name%>" type="hidden" size="18" maxlength="50"  />
                        </span></td>
                      </tr>
                      <tr>
                        <td align="right" valign="top">付款金额： </td>
                        <td valign="top" align="left"><%=order_price%> 元<input type="hidden" name="alimoney" maxlength="50" size="18"  value="<%=order_price%>" /></td>
                      </tr>
                      <tr>
                        <td align="right" valign="top">支付方式：</td>
                        <td valign="top" align="left">即时到账</td>
                      </tr>
              <tr>
                <td align="right">钱包支付密码：</td>
                <td><input name="walletPassword" type="text" id="walletPassword" size="20" maxlength="15" /> （必须钱包支付密码对才能存取钱包）
				</td>
              </tr>
                      <tr>
                        <td align="right" valign="top">&nbsp;</td>
                        <td valign="top"><b>
                       <input type="hidden" name="username" value="<%=mainname%>" />
                       <input type="hidden" name="pay" value="yes" />
                          <input name="submit" type="image" src="../tenpay/b2c/image/next.gif" alt="使用钱包安全支付" width="103" height="27" />
                        </b></td>
                        <td width="1" valign="top">&nbsp;</td>
                      </tr>
                    </table></td>
                </tr></form>
      </table></td>
            </tr> 
        </table>
        <table width="760" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td>&nbsp;</td>
            </tr>
        </table></td>
    </tr>
  </table>
</html>
<%Call CloseDB(conn)%>