using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Web;
|
using System.Web.UI;
|
using System.Web.UI.WebControls;
|
using CY.BLL;
|
using CY.Model;
|
using CY.Infrastructure.Query;
|
using CY.Infrastructure.Common;
|
using CY.BLL.Sys;
|
using DealMvc.Pay.Tenpay;
|
using JumbotCms.API.Tenpay;
|
using CY.Config;
|
|
namespace CY.WebForm.Pages.pay
|
{
|
public partial class RechargeReturn : BasePage
|
{
|
Pay_AccountedRecordBLL bll_Pay_AccountedRecordBLL = null;
|
Pay_PaymentAccountBLL bll_Pay_PaymentAccountBLL = null;
|
Sys_DictionaryBLL bll_Sys_DictionaryBLL = null;
|
DateTime nowTime = new DateTime();
|
public bool RechargeState = true;
|
//初始化
|
public RechargeReturn()
|
{
|
bll_Pay_AccountedRecordBLL = new Pay_AccountedRecordBLL();
|
bll_Pay_PaymentAccountBLL = new Pay_PaymentAccountBLL();
|
bll_Sys_DictionaryBLL = new Sys_DictionaryBLL();
|
nowTime = DateTime.Now;
|
}
|
|
protected void Page_Load(object sender, EventArgs e)
|
{
|
if (!IsPostBack)
|
{
|
if (Session["RechargeSubmit"].ToString2() == "get")
|
{
|
RechargeState = Tenpay_Return();
|
Session["RechargeState"] = RechargeState.ToString2();
|
}
|
else
|
{
|
if (string.IsNullOrEmpty(Session["RechargeState"].ToString2()))
|
Session["RechargeState"] = false;
|
}
|
}
|
}
|
|
//充值返回结果
|
public bool Tenpay_Return()
|
{
|
try
|
{
|
/* attach=&bargainor_id=1208389301&cmdno=1&date=20120111&fee_type=1&pay_info=OK
|
* &pay_result=0&pay_time=1326291710&sign=0925C26EA436BAC80010E7F3F6C9FAE3
|
* &sp_billno=2220091839&total_fee=1&transaction_id=1208389301201201112220091839&ver=1
|
*/
|
Session["RechargeSubmit"] = "";
|
PayResponseHandler resHandler = new PayResponseHandler(System.Web.HttpContext.Current);
|
|
resHandler.setKey(WebInfo.Instance.Tenpay_key.ToString2());
|
|
//判断签名
|
if (resHandler.isTenpaySign())
|
{
|
//交易单号---时间:2012-03-29 21:11 已更新
|
//string transaction_id = resHandler.getParameter("transaction_id");
|
// reqHandler.setParameter("attach", orderid); //订单ID
|
string orderid = resHandler.getParameter("attach");
|
|
//金额金额,以分为单位
|
string total_fee = resHandler.getParameter("total_fee");
|
|
//支付结果
|
string pay_result = resHandler.getParameter("pay_result");
|
|
Pay_AccountedRecord m_Pay_AccountedRecord = bll_Pay_AccountedRecordBLL.GetModel(orderid);
|
decimal Money = (m_Pay_AccountedRecord.AccountingMoney).ToDouble2().Value.ToString("0.0000").ToDecimal2().Value;
|
string o = orderid;
|
|
if (m_Pay_AccountedRecord == null && m_Pay_AccountedRecord.Keyid == null)
|
return false;
|
if (!"0".Equals(pay_result))
|
return false;
|
|
lock (this)
|
{
|
string trueMoney = Convert.ToInt32(Money * 100).ToString() ;
|
int? PayStatus =bll_Sys_DictionaryBLL.GetKeyIdByKeyid(1, "Pay_交易状态");
|
if (total_fee == trueMoney && m_Pay_AccountedRecord.StatusId == PayStatus)
|
{
|
Pay_PaymentAccount m_Pay_PaymentAccount = CurrentPayAccount;
|
if (m_Pay_PaymentAccount == null)
|
{
|
return false;
|
}
|
m_Pay_AccountedRecord.StatusId = bll_Sys_DictionaryBLL.GetKeyIdByKeyid(-1, "Pay_交易状态");
|
|
CY.Model.Pay.Pay_Request m_Pay_Request = new Model.Pay.Pay_Request();
|
m_Pay_Request.Payeeid = CurrentPayAccount.Keyid ?? 0;
|
m_Pay_Request.Payerid = AdminAccount.Keyid ?? 0;
|
m_Pay_Request.Paymoney = Money;
|
m_Pay_Request.Subject = "充值方式:" + (Session["RechargeBank"]?? "财付通");
|
m_Pay_Request.BalanceAccount = 0;
|
m_Pay_Request.UsedCredit = -1;
|
Session["RechargeMoney"] = Money.ToString2();
|
Session["RechargeBank"] = bll_Sys_DictionaryBLL.GetNameByMeanValue(m_Pay_AccountedRecord.AccountingTarget.ToInt32(), "Pay_银行名称");
|
|
if (bll_Pay_PaymentAccountBLL.RechargeSucces(m_Pay_PaymentAccount, m_Pay_Request, m_Pay_AccountedRecord))
|
{
|
return true;
|
}
|
else
|
{
|
return false;
|
}
|
}
|
}
|
return false;
|
}
|
|
}
|
catch (Exception ex)
|
{
|
PAGEHandleException(ex);
|
return false;
|
}
|
return false;
|
}
|
}
|
}
|