📄 cashpay.aspx.cs
字号:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Collections.Generic;
using Shop.Web.UI;
//////////////////////////////////////////////////////////////////////////////////////////////
////订单金额,現金金额 ////
////订单表状态,現金支付记录,用户信息记录 ////
////現金金额不足时:始终更新現金支付表,增加用户信息记录,订单状态(付款):未付清 ////
////現金金额大于订单金额时:多余的現金转入用户资金余额中 ////
//////////////////////////////////////////////////////////////////////////////////////////////
namespace YXShop.Web.Admin.Orders
{
public partial class cashPay : 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.RemittanceInfo Remibll = new YXShop.BLL.RemittanceInfo();//银行支付
YXShop.BLL.PaymentMoney paymbll = new YXShop.BLL.PaymentMoney();//现金支付
YXShop.BLL.PrepayMoney prepbll = new YXShop.BLL.PrepayMoney();//预付款支付
YXShop.BLL.Orders bll = new YXShop.BLL.Orders();
YXShop.BLL.MemberInfo membBll = new YXShop.BLL.MemberInfo();
YXShop.BLL.UserInAndExp uiaeBll = new YXShop.BLL.UserInAndExp();
BasePage bp = null;
protected void Page_Load(object sender, EventArgs e)
{
//是不是管理员
if (!PowerTree.PowerPass.isPass("006002008", PowerTree.PowerPanel.PowerType.other))
{
bp = new BasePage();
bp.PageError("对不起,你没有现金支付的权限!", "../index.aspx");
}
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);
}
else
{
Response.Redirect("orderList.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].TotalPrice);
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 = UserReal(userID);
myuser.Text = UserName(userID);
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;
TextBox1.Text = Convert.ToInt32(li[0].TotalPrice).ToString();
if (orderPrice <= (remiPrice + paymPrice + prepPrice))
{
//如果已经支付清,就转到对应信息页面
YXShop.Common.alert.ShowAndRedirectgo(this, "订单已经支付清!", "orderInfo.aspx?OrderID=" + orderId);
}
}
}
#region 客户信息查询
protected string UserName(int UserID)
{
string str = "";
//YXShop.BLL.MemberInfo data = new YXShop.BLL.MemberInfo();
YXShop.BLL.UserCommon datau = new YXShop.BLL.UserCommon();
YXShop.Model.UserCommon data = datau.GetId(UserID);
str = data.UserName;
return str;
}
protected string UserReal(int UserID)
{
string str = "";
YXShop.BLL.MemberInfo data = new YXShop.BLL.MemberInfo();
List<YXShop.Model.MemberInfo> dataStr = data.GetListByColumn("UID", UserID);
if (dataStr.Count > 0)
{
str = dataStr[0].cTrueName;
}
return str;
}
#endregion
/// <summary>
/// 保存現金支付信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void saveInfo_Click(object sender, EventArgs e)
{
YXShop.Model.UserInAndExp uiaeModel = null;
YXShop.Model.PaymentMoney moneyModel = new YXShop.Model.PaymentMoney();
#region 已付款计算
decimal inPrice = Convert.ToDecimal(TextBox4.Text.Trim());
decimal totalPrice = inPrice + remiPrice + prepPrice + paymPrice;
if (totalPrice > orderPrice)
{
//多余的款项
outPrice = totalPrice - orderPrice;
}
//现金总金额
if (outPrice > 0)
{
moneyModel.GatheringMoney = (inPrice + paymPrice - outPrice);
}
else
{
moneyModel.GatheringMoney = (inPrice + paymPrice);//現金錄入金額
}
#endregion
#region 現金記錄信息
moneyModel.OrderID = orderId;
moneyModel.UserName = myuser.Text;
//moneyModel.GatheringMoney = Convert.ToDecimal(TextBox4.Text);
moneyModel.GatheringDate = getMoneyDate.Date;
moneyModel.Remark = TextBox2.Text;
if (CheckBox2.Checked)
{
moneyModel.PresentTicket = this.TextBox1.Text != string.Empty ? Convert.ToInt32(YXShop.Common.WebUtility.replaceStr(TextBox1.Text)) : 0;
}
else
{
moneyModel.PresentTicket = 0;
}
moneyModel.NoteDate = DateTime.Now;
moneyModel.NoteName = Session["AdminName"].ToString();
#endregion
//int userID = membBll.getUserIDByName(myuser.Text);
if (userID == 0)
{
YXShop.Common.alert.ShowAndRedirectgo(this, "该用户不存在!", "orderInfo.aspx?OrderID=" + orderId);
}
#region 用户交易明细
uiaeModel = new YXShop.Model.UserInAndExp();
uiaeModel.UserID = userID;
uiaeModel.AdsumMoneyDate = getMoneyDate.Date;
uiaeModel.AdsumMoney = Convert.ToDecimal(TextBox4.Text);
uiaeModel.PresentTicket = this.TextBox1.Text != string.Empty ? Convert.ToDecimal(TextBox1.Text) : 0;
uiaeModel.RemitJoinMode = 3;//支付方式:现金支付
uiaeModel.RemitJoinBank = "";
uiaeModel.Remark = YXShop.Common.WebUtility.replaceStr(TextBox2.Text.Trim()) == string.Empty ? "支付订单费用。订单号:" + orderId + "" : YXShop.Common.WebUtility.replaceStr(TextBox2.Text.Trim());//备注
uiaeModel.InformMode = "";//通知方式
uiaeModel.BosomNote = YXShop.Common.WebUtility.replaceStr(TextBox5.Text);//内部信息
uiaeModel.NoteDate = DateTime.Now;
uiaeModel.NoteName = Session["AdminName"].ToString();
uiaeModel.incomeAndExpStatus = 1;
uiaeModel.Status = 0;
#endregion
#region 数据处理
try
{
//用户明细信息添加
uiaeBll.Add(uiaeModel);
if (paymbll.UpdateMoney(moneyModel) != 1)
{
paymbll.Add(moneyModel);
}
//付款状态,订单状态
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 (outPrice > 0)
{
membBll.addUserMoney(userID, outPrice);
}
}
catch (Exception ex)
{
Response.Redirect("../Succeed/ErrorOrder.aspx?Key=" + ex.Message + "&OrderId=" + orderId + "'");
}
finally
{
Response.Redirect("../Succeed/SueeccdOrder.aspx?Key=現金支付&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 + -