username@email.com
2025-05-12 ae6e40362a745caef9ead36f81f38313fb8c2c66
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
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;
            }
        }
 
        /// <summary>
        /// 当线下(银行账户或者现金账户)收款时
        /// </summary>
        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);
        }
 
        /// <summary>
        /// 网站余额支付
        /// </summary>
        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;
        }
    }
}