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.BLL.OA; using CY.Infrastructure.Common; namespace CY.WebForm.Pages.financial { public partial class MemberOrderMoneyReceive : BasePage { EC_PaymentRecordBLL _EC_PaymentRecordBLL = new EC_PaymentRecordBLL(); Pay_PaymentAccountBLL _Pay_PaymentAccountBLL = new Pay_PaymentAccountBLL(); OA_SubjectSetBLL _OA_SubjectSetBLL = new OA_SubjectSetBLL(); EC_MemberBasicBLL _EC_MemberBasicBLL = new EC_MemberBasicBLL(); Pay_PaymentAccountBLL bll_Pay_PaymentAccountBLL = new Pay_PaymentAccountBLL(); private int KeyId { get { return Request.Params["Keyid"] != null ? int.Parse(Request.Params["Keyid"].ToString()) : 0; } } public decimal AllPayMoney { get; set; } protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindPage(); } } private void BindPage() { EC_PaymentRecord paymentRecord = _EC_PaymentRecordBLL.GetModelByKeyid(KeyId); if (paymentRecord != null) { this.lblMemberName.Text = paymentRecord.MemberName; this.lblPayType.Text = paymentRecord.PayType; this.lblPayAllMoney.Text = paymentRecord.PayAllMoney.Value.ToString("0.00"); this.txtPayMoney.Text = this.lblPayAllMoney.Text; this.txtReceiveDate.Value = DateTime.Now.ToString("yyyy-MM-dd hh:mm"); //科目名称 this.selSubject.DataSource = _OA_SubjectSetBLL.getAllSubject(CurrentUser.MemberId, "借"); this.selSubject.DataBind(); this.selSubject.Items.Insert(0, new ListItem("请选择", "")); AllPayMoney = paymentRecord.PayAllMoney.Value; this.txtPayMoney.Attributes.Add("max", AllPayMoney.ToString("0.00")); Pay_PaymentAccount payMentAccount = _Pay_PaymentAccountBLL.MergeBufferMoneyByMemberId(paymentRecord.MemberId); if (payMentAccount != null) { if (payMentAccount.SurplusMoney.HasValue) this.lblHaveMoney.Text = payMentAccount.SurplusMoney.Value.ToString("0.00"); } } } protected void btnSave_Click(object sender, EventArgs e) { string acoountType = Request["rad"]; switch (acoountType) { case "银行账户": case "现金账户": Payoffline(); break; case "2": //网站余额 PayOnline(); break; } } /// /// 当线下(银行账户或者现金账户)收款时 /// private void Payoffline() { decimal PayMoney = this.txtPayMoney.Text.ToDecimal2().Value; OA_FirmAccountBLL _OA_FirmAccountBLL = new OA_FirmAccountBLL(); OA_FirmAccount firmAccount = new OA_FirmAccount(); firmAccount = _OA_FirmAccountBLL.getSingleSubject(Request["selAccountName"].ToInt32()); firmAccount.AllIncome = firmAccount.AllIncome + PayMoney; firmAccount.Balance = firmAccount.Balance + PayMoney; OA_FirmAccountRecord firmAccountRecord = new OA_FirmAccountRecord(); firmAccountRecord.AccountId = Request["selAccountName"].ToInt32(); firmAccountRecord.LastUpdateTime = DateTime.Parse(this.txtReceiveDate.Value); firmAccountRecord.Money = PayMoney; firmAccountRecord.OperationalMatters = " "; firmAccountRecord.Operator = CurrentUser.ShortName; firmAccountRecord.PaymentUnit = lblMemberName.Text; firmAccountRecord.RecordTypeId = 1;//收入 firmAccountRecord.Remark = this.txtRemark.Value; firmAccountRecord.SubjectId = selSubject.Value.ToInt32(); firmAccountRecord.ResidualAmount = firmAccount.Balance; firmAccountRecord.Department = ""; EC_PaymentRecord paymentRecord = _EC_PaymentRecordBLL.GetModelByKeyid(KeyId); paymentRecord.PayMoney = PayMoney; EC_MemberBasic memberBasic = _EC_MemberBasicBLL.GetMemberByMemberId(paymentRecord.MemberId); memberBasic.UseState = 3; memberBasic.ExpirationTime = paymentRecord.PayEndTime; OA_FirmAccountRecordBLL _OA_FirmAccountRecordBLL = new OA_FirmAccountRecordBLL(); int type = GetSourceTypeId(paymentRecord.PayType); if (_OA_FirmAccountRecordBLL.AddModel(firmAccountRecord, firmAccount, memberBasic, paymentRecord)) { bll_Pay_PaymentAccountBLL.SendPoOrMoToMember(paymentRecord.MemberId, type, PayMoney); JavaScript.RefreshDIVOpener(this); } else JavaScript.MessageBox("操作失败", this); } /// /// 网站余额支付 /// private void PayOnline() { decimal PayMoney = this.txtPayMoney.Text.ToDecimal2().Value; EC_PaymentRecord paymentRecord = _EC_PaymentRecordBLL.GetModelByKeyid(KeyId); paymentRecord.PayMoney = PayMoney; Pay_PaymentAccount payMentAccount = _Pay_PaymentAccountBLL.MergeBufferMoneyByMemberId(paymentRecord.MemberId); decimal surplusMoney = payMentAccount.SurplusMoney.HasValue ? payMentAccount.SurplusMoney.Value : 0; if (surplusMoney < PayMoney) { this.radYH.Checked = true; this.radYE.Checked = false; this.radXJ.Checked = false; JavaScript.MessageBox("会员网站余额小于支付金额,不能支付", this); return; } Pay_PaymentAccount m_Pay_PaymentAccount = _EC_MemberBasicBLL.GetPaymentAccountByMemberId(paymentRecord.MemberId); CY.Model.Pay.Pay_Request m_Pay_Request = null; m_Pay_Request = new Model.Pay.Pay_Request(); m_Pay_Request.Payeeid = AdminAccount.Keyid ?? 0; m_Pay_Request.Payerid = m_Pay_PaymentAccount.Keyid ?? 0; m_Pay_Request.Paymoney = PayMoney; m_Pay_Request.Subject = "其他收入"; m_Pay_Request.BalanceAccount = 15; m_Pay_Request.UsedCredit = -1; EC_MemberBasic memberBasic = _EC_MemberBasicBLL.GetMemberByMemberId(paymentRecord.MemberId); memberBasic.UseState = 3; memberBasic.ExpirationTime = paymentRecord.PayEndTime; if (_EC_PaymentRecordBLL.UpdateModel(paymentRecord, m_Pay_Request, memberBasic)) { int type = GetSourceTypeId(paymentRecord.PayType); bll_Pay_PaymentAccountBLL.SendPoOrMoToMember(paymentRecord.MemberId, type, PayMoney); JavaScript.RefreshDIVOpener(this); } else { this.radYH.Checked = true; this.radYE.Checked = false; this.radXJ.Checked = false; JavaScript.MessageBox("操作失败", this); } } public int GetSourceTypeId(string payType) { int type = 0; switch (payType) { case "印刷厂商注册费": case "印刷厂商续费": type = 89; break; case "个人网店押金": type = 393; break; case "管理软件费": type = 91; break; case "网站广告费": type = 392; break; case "杂志广告费": type = 90; break; } return type; } } }