📄 payonline.cs
字号:
namespace PowerEasy.Shop
{
using PowerEasy.Accessories;
using PowerEasy.Common;
using PowerEasy.Components;
using PowerEasy.Enumerations;
using PowerEasy.Model.Accessories;
using PowerEasy.Model.Shop;
using PowerEasy.Model.UserManage;
using PowerEasy.UserManage;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Web;
public class PayOnline
{
private int m_ClientID;
private string m_Message;
private decimal m_MoneyPayout;
private decimal m_MoneyReceipt;
private OrderInfo m_OrderInfo;
private int m_PaymentLogId;
private int m_PlatformId;
private int m_UserId;
private string m_UserName;
public static PayOnlineState AddPayment(int orderId, int payPlatformId, decimal money, string userName, string paymentNum)
{
if (orderId > 0)
{
OrderInfo orderById = Order.GetOrderById(orderId);
if (!orderById.IsNull)
{
return PayOnlineState.OrderNotFound;
}
if (orderById.MoneyTotal <= orderById.MoneyReceipt)
{
return PayOnlineState.AccountPaid;
}
}
PayPlatformInfo payPlatformById = PayPlatform.GetPayPlatformById(payPlatformId);
if (payPlatformById.IsNull)
{
return PayOnlineState.PayPlatFormNotFound;
}
if (payPlatformById.IsDisabled)
{
return PayOnlineState.PayPlatFormDisabled;
}
money = Math.Abs(money);
if (money <= 0.01M)
{
return PayOnlineState.TooLittleMoney;
}
if (string.IsNullOrEmpty(paymentNum))
{
return PayOnlineState.NoPaymentNumber;
}
decimal num = money + ((money * DataConverter.CDecimal(payPlatformById.Rate)) / 100M);
PaymentLogInfo paymentLogInfo = new PaymentLogInfo();
paymentLogInfo.UserName = userName;
paymentLogInfo.OrderId = orderId;
paymentLogInfo.PaymentNum = paymentNum;
paymentLogInfo.PlatformId = payPlatformById.PayPlatformId;
paymentLogInfo.MoneyPay = money;
paymentLogInfo.MoneyTrue = num;
paymentLogInfo.PayTime = new DateTime?(DateTime.Now);
paymentLogInfo.Status = 1;
paymentLogInfo.PlatformInfo = "";
paymentLogInfo.Remark = "";
paymentLogInfo.SuccessTime = null;
if (PaymentLog.Add(paymentLogInfo))
{
return PayOnlineState.Ok;
}
return PayOnlineState.Fail;
}
public static string AppendParam(string returnStr, string paramId, string paramValue)
{
if (!string.IsNullOrEmpty(returnStr))
{
if (!string.IsNullOrEmpty(paramValue))
{
string str = returnStr;
returnStr = str + "&" + paramId + "=" + paramValue;
}
return returnStr;
}
if (!string.IsNullOrEmpty(paramValue))
{
returnStr = paramId + "=" + paramValue;
}
return returnStr;
}
public static string GetApplicationName()
{
return GetApplicationName(HttpContext.Current);
}
public static string GetApplicationName(HttpContext context)
{
if (context == null)
{
return string.Empty;
}
string host = context.Request.Url.Host;
string applicationPath = context.Request.ApplicationPath;
return (host + applicationPath);
}
public static string GetStateDescription(PayOnlineState state)
{
string str = string.Empty;
switch (state)
{
case PayOnlineState.None:
return "";
case PayOnlineState.Ok:
return "在线支付成功!";
case PayOnlineState.OrderNotFound:
return "找不到指定的订单!";
case PayOnlineState.AccountPaid:
return "指定的订单已经付清,不用再付款!";
case PayOnlineState.NoMoney:
return "请输入划款金额!";
case PayOnlineState.TooLittleMoney:
return "每次划款金额不能低于0.01元!";
case PayOnlineState.PayPlatFormNotFound:
return "找不到指定的支付平台!";
case PayOnlineState.PayPlatFormDisabled:
return "指定的支付平台未启动!";
case PayOnlineState.NoPaymentNumber:
return "没有支付编号!";
case PayOnlineState.PaymentLogNotFound:
return "找不到指定的支付单!";
case PayOnlineState.RemittanceWrong:
return "支付金额不对!";
case PayOnlineState.Fail:
return "在线支付失败!";
}
return str;
}
public static bool IsFabrication(int orderId)
{
bool flag = false;
if (orderId == 0)
{
return true;
}
foreach (OrderItemInfo info in OrderItem.GetInfoListByOrderId(orderId))
{
ProductInfo productById = Product.GetProductById(info.ProductId, info.TableName);
if (!productById.IsNull)
{
if (Product.CharacterIsExists(productById.ProductCharacter, ProductCharacter.Card))
{
flag = true;
continue;
}
return false;
}
}
return flag;
}
private static void Log(string logTitle, string logMessage, TextWriter w)
{
w.Write("\r\nLog Entry : ");
w.WriteLine("{0} {1} {2}", DateTime.Now.ToLongTimeString(), DateTime.Now.ToLongDateString(), logTitle);
w.WriteLine("{0}", logMessage);
w.WriteLine("-------------------------------");
w.Flush();
}
private static bool ProcessCards(StringBuilder payOnlineMessage, bool doUpdate, OrderItemInfo itemInfo, ref bool isFirstStockItem, ref int stockId)
{
bool flag = false;
IList<CardInfo> list = Cards.GetCardList(itemInfo.TableName, itemInfo.ProductId, itemInfo.ItemId);
if (list.Count == 0)
{
if (doUpdate)
{
IList<CardInfo> list2 = Cards.GetUnsoldCard(itemInfo.TableName, itemInfo.ProductId, itemInfo.Amount);
string str = string.Empty;
if (list2.Count >= itemInfo.Amount)
{
foreach (CardInfo info in list2)
{
string str2 = str;
str = str2 + "<br>卡号:" + info.CardNum + " 密码:" + StringHelper.Base64StringDecode(info.Password);
info.OrderItemId = itemInfo.ItemId;
Cards.Update(info);
}
if (isFirstStockItem)
{
stockId = StockManage.GetMaxId() + 1;
isFirstStockItem = false;
}
Order.AddStockItemBySendCard(stockId, itemInfo);
}
else
{
flag = true;
}
payOnlineMessage.Append("<br /><br />您购买的充值卡的信息如下,请您尽快使用,以防充值卡被他人使用!<br />");
payOnlineMessage.Append(str);
payOnlineMessage.Append("<br><br><a href='../User/Info/Recharge.aspx'>使用充值卡充值</a> ");
}
return flag;
}
payOnlineMessage.Append("<br /><br />您购买的充值卡的信息如下,请您尽快使用,以防充值卡被他人使用!<br />");
foreach (CardInfo info2 in list)
{
payOnlineMessage.Append("<br />卡号:" + info2.CardNum + " 密码:" + StringHelper.Base64StringDecode(info2.Password));
payOnlineMessage.Append("<br /><br /><a href='../User/Info/Recharge.aspx'>使用充值卡充值</a> ");
}
return flag;
}
private bool ShowCardInfo(StringBuilder payOnlineMessage, bool doUpdate, bool isok)
{
bool flag = false;
bool flag2 = false;
bool flag3 = false;
bool flag4 = false;
bool flag5 = false;
IList<OrderItemInfo> infoListByOrderId = OrderItem.GetInfoListByOrderId(this.m_OrderInfo.OrderId);
int stockId = 0;
bool isFirstStockItem = true;
foreach (OrderItemInfo info in infoListByOrderId)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -