📄 addpayment.aspx.cs
字号:
namespace PowerEasy.WebSite.User.Shop
{
using PowerEasy.Accessories;
using PowerEasy.Common;
using PowerEasy.Components;
using PowerEasy.Controls;
using PowerEasy.Enumerations;
using PowerEasy.Model.Accessories;
using PowerEasy.Model.Shop;
using PowerEasy.Model.UserManage;
using PowerEasy.Shop;
using PowerEasy.UserManage;
using PowerEasy.Web.UI;
using PowerEasy.WebSite.Controls;
using System;
using System.Collections.Generic;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
public class AddPayment : DynamicPage
{
protected Button BtnSave;
protected HtmlForm form1;
protected Label LabMessage;
protected Label lblPartPayAge;
protected TextBox TxtBalance;
protected TextBox TxtClientName;
protected TextBox TxtMoney;
protected TextBox TxtMoneyReceipt;
protected TextBox TxtMoneyTotal;
protected TextBox TxtOrderNum;
protected TextBox TxtOverdraft;
protected TextBox TxtUserName;
protected UserNavigation UserCenterNavigation;
protected MoneyValidator Vmoney;
protected ExtendedSiteMapPath YourPosition;
protected void BtnSave_Click(object sender, EventArgs e)
{
if (base.IsValid)
{
decimal num = DataConverter.CDecimal(this.TxtMoney.Text);
ShopConfig shopConfig = SiteConfig.ShopConfig;
OrderInfo orderInfo = (OrderInfo) this.ViewState["OrderInfo"];
UserInfo userInfo = (UserInfo) this.ViewState["UserInfo"];
if (num <= 0M)
{
DynamicPage.WriteErrMsg("请输入支付金额!");
}
if ((userInfo.Balance + DataConverter.CDecimal(userInfo.UserPurview.Overdraft)) < num)
{
DynamicPage.WriteErrMsg("您输入的支付金额超过了您的资金余额,无效支付!");
}
if (shopConfig.EnablePartPay && (num < (orderInfo.MoneyTotal * (Convert.ToDecimal(shopConfig.PartPayAge.ToString()) / 100M))))
{
DynamicPage.WriteErrMsg("您输入的支付金额未达到系统设置的订金比率:" + shopConfig.PartPayAge + "%");
}
if ((orderInfo.MoneyReceipt + num) >= orderInfo.MoneyTotal)
{
bool flag = false;
bool flag2 = false;
bool flag3 = false;
bool flag4 = false;
bool flag5 = false;
orderInfo.EnableDownload = true;
IList<OrderItemInfo> infoListByOrderId = OrderItem.GetInfoListByOrderId(orderInfo.OrderId);
bool flag6 = true;
int stockId = 0;
foreach (OrderItemInfo info3 in infoListByOrderId)
{
if (Product.CharacterIsExists(info3.ProductCharacter, ProductCharacter.Card))
{
if (Cards.GetCardByOrderItemId(info3.ProductId, info3.TableName, info3.ItemId).IsNull)
{
IList<CardInfo> list2 = Cards.GetUnsoldCard(info3.TableName, info3.ProductId, info3.Amount);
if (list2.Count >= info3.Amount)
{
foreach (CardInfo info5 in list2)
{
info5.OrderItemId = info3.ItemId;
Cards.Update(info5);
}
if (flag6)
{
stockId = StockManage.GetMaxId() + 1;
flag6 = false;
}
Order.AddStockItemBySendCard(stockId, info3);
}
else
{
flag5 = true;
}
}
flag4 = true;
}
flag = Product.CharacterIsExists(info3.ProductCharacter, ProductCharacter.Practicality);
flag2 = Product.CharacterIsExists(info3.ProductCharacter, ProductCharacter.Service);
flag3 = Product.CharacterIsExists(info3.ProductCharacter, ProductCharacter.Download);
}
if (!flag6)
{
StockInfo stockInfo = new StockInfo();
stockInfo.Inputer = PEContext.Current.Admin.AdminName;
stockInfo.InputTime = DateTime.Now;
stockInfo.Remark = "交付点卡";
stockInfo.StockId = StockManage.GetMaxId() + 1;
stockInfo.StockNum = StockItem.GetShipmentNum();
stockInfo.StockType = StockType.Shipment;
StockManage.Add(stockInfo);
}
if (!flag && !flag5)
{
orderInfo.DeliverStatus = DeliverStatus.Consignment;
}
if ((flag3 && !flag) && (!flag2 && !flag4))
{
orderInfo.DeliverStatus = DeliverStatus.SignIn;
}
}
else if (!shopConfig.EnablePartPay)
{
DynamicPage.WriteErrMsg("系统已经关闭付订金功能,您必需全额支付。");
}
orderInfo.MoneyReceipt += num;
if (orderInfo.Status < OrderStatus.Confirmed)
{
orderInfo.Status = OrderStatus.Confirmed;
}
Order.Update(orderInfo);
userInfo.Balance -= num;
Users.Update(userInfo);
BankrollItemInfo bankrollItemInfo = new BankrollItemInfo();
bankrollItemInfo.Inputer = "System";
bankrollItemInfo.UserName = PEContext.Current.User.UserName;
bankrollItemInfo.ClientId = orderInfo.ClientId;
bankrollItemInfo.Money = -1M * Math.Abs(num);
bankrollItemInfo.MoneyType = 4;
bankrollItemInfo.CurrencyType = 1;
bankrollItemInfo.OrderId = orderInfo.OrderId;
bankrollItemInfo.Remark = "支付订单费用,订单号:" + orderInfo.OrderNum;
bankrollItemInfo.DateAndTime = new DateTime?(DateTime.Now);
bankrollItemInfo.LogTime = new DateTime?(DateTime.Now);
BankrollItem.Add(bankrollItemInfo);
BasePage.ResponseRedirect("ShowOrder.aspx?OrderId=" + orderInfo.OrderId.ToString());
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!base.IsPostBack)
{
int orderId = BasePage.RequestInt32("OrderId");
if (orderId <= 0)
{
DynamicPage.WriteErrMsg("请指定要支付的订单!", "OrderList.aspx");
}
else
{
string str = BasePage.RequestString("AddOrder");
string successMessage = "";
if (str == "success")
{
successMessage = "订单已经成功提交!<br>";
}
ShopConfig shopConfig = SiteConfig.ShopConfig;
if (shopConfig.EnablePartPay)
{
this.lblPartPayAge.Visible = true;
this.lblPartPayAge.Text = "系统支付预付订单功能,如果您当前余额不足,您最少可以预付订单金额的:" + shopConfig.PartPayAge.ToString() + "%";
}
UserInfo usersByUserName = Users.GetUsersByUserName(PEContext.Current.User.UserName);
if (!usersByUserName.IsNull)
{
decimal num2 = DataConverter.CDecimal(usersByUserName.UserPurview.Overdraft);
if ((usersByUserName.Balance + num2) <= 0M)
{
DynamicPage.WriteErrMsg(successMessage + "您的资金余额不足,不能使用虚拟货币支付!", "ShowOrder.aspx?OrderID=" + orderId);
}
OrderInfo orderById = Order.GetOrderById(orderId);
if (orderById.IsNull)
{
DynamicPage.WriteErrMsg("找不到指定的订单!", "OrderList.aspx");
}
else if (orderById.MoneyTotal <= orderById.MoneyReceipt)
{
if (str == "success")
{
DynamicPage.WriteSuccessMsg(successMessage, "ShowOrder.aspx?OrderID=" + orderId);
}
else
{
DynamicPage.WriteErrMsg("此订单已经付清,无需再支付!", "ShowOrder.aspx?OrderID=" + orderId);
}
}
this.ViewState["OrderInfo"] = orderById;
this.ViewState["UserInfo"] = usersByUserName;
decimal balance = orderById.MoneyTotal - orderById.MoneyReceipt;
if (usersByUserName.Balance <= balance)
{
balance = usersByUserName.Balance;
}
this.TxtUserName.Text = orderById.UserName;
this.TxtClientName.Text = orderById.ClientName;
this.TxtBalance.Text = usersByUserName.Balance.ToString("0.00");
this.TxtOverdraft.Text = num2.ToString("0.00");
this.TxtOrderNum.Text = orderById.OrderNum;
this.TxtMoneyTotal.Text = orderById.MoneyTotal.ToString("0.00");
this.TxtMoneyReceipt.Text = orderById.MoneyReceipt.ToString("0.00");
this.TxtMoney.Text = (balance > 0M) ? balance.ToString("0.00") : orderById.MoneyTotal.ToString("0.00");
if (!SiteConfig.ShopConfig.EnablePartPay && ((usersByUserName.Balance + num2) < (orderById.MoneyTotal - orderById.MoneyReceipt)))
{
this.BtnSave.Enabled = false;
this.LabMessage.Text = "您的预付款少于订单金额,不允许支付!";
}
}
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -