📄 mymhadpay.aspx.cs
字号:
using System;
using System.Web.UI.WebControls;
using System.Collections.Generic;
namespace YXShop.Web.Membercenter.Dynamic
{
public partial class myMHadPay : System.Web.UI.Page
{
public static string orderId = "";
public static int userID = 0;
private static decimal orderPrice = 0;
private decimal outPrice = 0;
private static decimal remiPrice = 0;
private static decimal paymPrice = 0;
private static decimal prepPrice = 0;
YXShop.BLL.Orders bll = new YXShop.BLL.Orders();
YXShop.BLL.BankAccount bankBll = new YXShop.BLL.BankAccount();
YXShop.BLL.MemberInfo membBll = new YXShop.BLL.MemberInfo();
YXShop.BLL.UserInAndExp UIAEBll = new YXShop.BLL.UserInAndExp();
YXShop.BLL.RemittanceInfo Remibll = new YXShop.BLL.RemittanceInfo();//银行支付
YXShop.BLL.PaymentMoney paymbll = new YXShop.BLL.PaymentMoney();//现金支付
YXShop.BLL.PrepayMoney prepbll = new YXShop.BLL.PrepayMoney();//预付款支付
protected void Page_Load(object sender, EventArgs e)
{
//是不是管理员
if (Session["MemberID"] == null)
{
Response.Redirect("../index.aspx", true);
}
else
{
if (string.IsNullOrEmpty(Session["MemberID"].ToString()))
{
Response.Redirect("../index.aspx", true);
}
}
saveInfo.Attributes.Add("onclick", "confirm('你确定保存汇款信息吗?')");
if ((!IsPostBack) || ((Request["Event"] != null) && (Request["Event"] != "")))
{
//初始化信息(订单信息,银行信息,支付信息)
if (!string.IsNullOrEmpty(Request.QueryString["OrderID"]))
{
//bindOrderInfo(YXShop.Common.WebUtility.replaceStr(Request.QueryString["OrderID"]));
orderId = YXShop.Common.WebUtility.replaceStr(Request.QueryString["OrderID"]);
bindOrderInfo(orderId);
BindBank(DropDownList1);
}
else
{
Response.Redirect("myOrderList.aspx");
}
}
}
/// <summary>
/// 绑定订单数据及其它
/// </summary>
/// <param name="orderID"></param>
private void bindOrderInfo(string orderID)
{
List<YXShop.Model.Orders> li = bll.GetListByColumn("OrderID", orderID);
YXShop.Model.RemittanceInfo bankModel = Remibll.GetModel(orderId);
YXShop.Model.PaymentMoney paymModel = paymbll.GetModel(orderId);
YXShop.Model.PrepayMoney prepModel = prepbll.GetModel(orderId);
if (li.Count == 1)
{
orderPrice = Convert.ToDecimal(li[0].FactPrice);//实际订单价
remiPrice = Convert.ToDecimal(bankModel != null ? bankModel.RemittanceMoney : 0);
paymPrice = Convert.ToDecimal(paymModel != null ? paymModel.GatheringMoney : 0);
prepPrice = Convert.ToDecimal(prepModel != null ? prepModel.PayoutMoney : 0);
userID = int.Parse(li[0].UserId);
Label1.Text = li[0].ConsigneeName;
//Label2.Text = li[0].ConsigneeRealName;
myuser.Text = li[0].ConsigneeRealName;
myuser.NavigateUrl = "~/Admin/Consumer/MemberInfo.aspx?Pro_ID=" + li[0].UserId;
Label3.Text = li[0].OrderId;
Label4.Text = orderPrice.ToString();
Label5.Text = (remiPrice + paymPrice + prepPrice).ToString();//已经支付
TextBox4.Text = (orderPrice - remiPrice - paymPrice - prepPrice).ToString();
TextBox2.Text = li[0].Remark;
if (orderPrice <= (remiPrice + paymPrice + prepPrice))
{
//如果已经支付清,就转到对应信息页面
YXShop.Common.alert.show("订单已经支付清!");
}
}
}
/// <summary>
/// 绑定银行数据
/// </summary>
/// <param name="ddl"></param>
protected void BindBank(DropDownList ddl)
{
YXShop.BLL.BankAccount bank = new YXShop.BLL.BankAccount();
int i = 0;
int j = 0;
List<YXShop.Model.BankAccount> modelList = bank.GetAll(1, 20, out i, out j);
ListItem li = null;
foreach (YXShop.Model.BankAccount model in modelList)
{
li = new ListItem();
li.Value = model.BC_Id.ToString();
li.Text = model.BC_Name;
ddl.Items.Add(li);
}
}
protected void saveInfo_Click(object sender, EventArgs e)
{
YXShop.Model.UserInAndExp userInAndExp = null;
YXShop.Model.RemittanceInfo Remittance = new YXShop.Model.RemittanceInfo();
#region 已付款计算
decimal inPrice = Convert.ToDecimal(TextBox4.Text.Trim());
decimal totalPrice = inPrice + remiPrice + prepPrice + paymPrice;
if (totalPrice > orderPrice)
{
//多余的款项
outPrice = totalPrice - orderPrice;
}
bool bl = CheckBox1.Checked;
if (bl)
{
//汇款总金额
if (outPrice > 0)
{
Remittance.RemittanceMoney = (inPrice + remiPrice - outPrice);
}
else
{
Remittance.RemittanceMoney = (inPrice + remiPrice);//银行转帐录入金额
}
}
else
{
Remittance.RemittanceMoney = (inPrice + remiPrice);//银行转帐录入金额
}
#endregion
#region 银行汇款信息
Remittance.OrderID = orderId;
Remittance.UserName = myuser.Text;
Remittance.RemittanceDate = getMoneyDate.Date;
//Remittance.RemittanceMoney = "";
Remittance.RemintanceBank = Convert.ToInt32(DropDownList1.SelectedValue);
Remittance.PresentTicket = 0;
Remittance.Remark = YXShop.Common.WebUtility.replaceStr(TextBox2.Text.Trim()) == string.Empty ? "我已汇款。订单号:" + orderId + "" : YXShop.Common.WebUtility.replaceStr(TextBox2.Text.Trim());
Remittance.InformMode = CheckBox1.Checked ? CheckBox1.Text : "";
Remittance.NoteDate = DateTime.Now;
Remittance.NoteName = "";
#endregion
//int userID = membBll.getUserIDByName(myuser.Text);//通过用户名找寻用户编号
if (userID == 0)
{
YXShop.Common.alert.ShowAndRedirect(this, "请重新登陆!", "../index.aspx");
}
//更新用户表//YXShop_UserInAndExp
#region 用户交易明细
userInAndExp = new YXShop.Model.UserInAndExp();
userInAndExp.UserID = userID;
userInAndExp.AdsumMoneyDate = getMoneyDate.Date;
userInAndExp.AdsumMoney = Convert.ToDecimal(TextBox4.Text);
userInAndExp.PresentTicket = 0;
userInAndExp.RemitJoinMode = YXShop.Common.StatuEnum.RemitJoinMode.银行汇款.GetHashCode();
userInAndExp.RemitJoinBank = DropDownList1.SelectedItem.Text;
userInAndExp.Remark = YXShop.Common.WebUtility.replaceStr(TextBox2.Text.Trim()) == string.Empty ? "我已汇款。订单号:" + orderId + "" : YXShop.Common.WebUtility.replaceStr(TextBox2.Text.Trim());//备注
userInAndExp.InformMode = CheckBox1.Checked ? CheckBox1.Text : "";//通知方式
userInAndExp.BosomNote = "";//内部信息
userInAndExp.NoteDate = DateTime.Now;
userInAndExp.NoteName = Session["MemberName"].ToString();
userInAndExp.incomeAndExpStatus = 1;
userInAndExp.Status = 1;
#endregion
#region 数据处理
try
{
//用户明细信息添加
UIAEBll.Add(userInAndExp);
if (Remibll.UpdateMoney(Remittance) != 1)
{
Remibll.Add(Remittance);
}
//付款状态,订单状态
if (totalPrice >= orderPrice)
{
bll.UpdateOrders("PaymentStatus", YXShop.Common.StatuEnum.PaymentStatu.已经付清.GetHashCode(), orderId);
}
else
{
bll.UpdateOrders("PaymentStatus", YXShop.Common.StatuEnum.PaymentStatu.未付清.GetHashCode(), orderId);
bll.UpdateOrders("OrderStatus", YXShop.Common.StatuEnum.OrderStatu.未结清.GetHashCode(), orderId);
}
if (bl)
{
if (outPrice > 0)
{
membBll.addUserMoney(userID, outPrice);
}
}
YXShop.Common.alert.ShowAndRedirect(this, "银行支付成功!", "orderInfo.aspx?OrderID=" + orderId);
}
catch
{
YXShop.Common.alert.ShowAndRedirect(this, "银行支付失败!", "orderInfo.aspx?OrderID=" + orderId);
}
#endregion
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("orderInfo.aspx?OrderID=" + orderId, true);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -