username@email.com
2025-05-14 99ddfbcecf0fa2881eb3a91028257eef87dab6de
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
221
222
223
224
225
226
227
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CY.Model;
using CY.BLL;
using CY.Infrastructure.Common;
using CY.BLL.Sys;
 
namespace CY.WebForm.Pages.webmanage
{
    //吴辉
    //提现审核
    public partial class CashHandle : BasePage
    {
        Pay_CashApplyBLL bll_Pay_CashApplyBLL = null;
        Sys_DictionaryBLL bll_Sys_DictionaryBLL = null;
        Pay_PaymentAccountBLL bll_Pay_PaymentAccountBLL = null;
 
        //初始化
        public CashHandle()
        {
            bll_Pay_CashApplyBLL = new Pay_CashApplyBLL();
            bll_Sys_DictionaryBLL = new Sys_DictionaryBLL();
            bll_Pay_PaymentAccountBLL = new Pay_PaymentAccountBLL();
        }
 
        //页面加载
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
            }
        }
 
        //绑定数据
        public void BindData()
        {
            Pay_CashApply m_Pay_CashApply = bll_Pay_CashApplyBLL.GetModel(Request["Keyid"].ToInt32());
            if (m_Pay_CashApply != null)
            {
                this.spanMemberName.InnerText = m_Pay_CashApply.MemberName;
                this.spanCashType.InnerText = m_Pay_CashApply.CashTypeId.ToString() == "0" ? "账户提现" : (m_Pay_CashApply.CashTypeId.ToString() == "1" ? "推广提现" : (m_Pay_CashApply.CashTypeId.ToString() == "2" ? "申领代理佣金" : "报销推广费用"));
                this.spanCashMoney.InnerText = m_Pay_CashApply.Money.Value.ToString("0");
                this.spanCashCard.InnerText = m_Pay_CashApply.TargetBankId;
                this.spanCashBank.InnerText = m_Pay_CashApply.TargetBankName;
                this.spanCardholder.InnerText = m_Pay_CashApply.Cardholder;
                this.divRemark.InnerHtml = m_Pay_CashApply.Remark;
 
                if (m_Pay_CashApply.State == 0)
                {
                    this.HandleNo.Visible = true;
                    this.HandleYes.Visible = false;
                    this.HandleOver.Visible = false;
                }
                else if (m_Pay_CashApply.State == 1)
                {
                    this.HandleOver.Visible = true;
                    this.HandleNo.Visible = false;
                    this.HandleYes.Visible = false;
                }
                else
                {
                    this.HandleNo.Visible = false;
                    this.HandleYes.Visible = true;
                    this.HandleOver.Visible = false;
                    this.spanState.InnerText = m_Pay_CashApply.CashStateName;
                }
            }
        }
 
        //提交事件
        protected void btn_Submit_Click(object sender, EventArgs e)
        {
            Pay_CashApply m_Pay_CashApply = bll_Pay_CashApplyBLL.GetModel(Request["Keyid"].ToInt32());
            Pay_PaymentAccount m_Pay_PaymentAccount = bll_Pay_PaymentAccountBLL.MergeBufferMoneyByMemberId(m_Pay_CashApply.MemberId);
            CY.Model.Pay.Pay_Request m_Pay_Request = null;
            Pay_PromotionRecord m_Pay_PromotionRecord = null;
 
            if (m_Pay_CashApply != null && m_Pay_PaymentAccount !=null)
            {
                switch (m_Pay_CashApply.State)
                {
                    case 0:
                        m_Pay_CashApply.State = this.selHandleState.Value.ToInt32();
                        break;
                    case 1:
                        m_Pay_CashApply.State = this.selOverState.Value.ToInt32();
                        break;
                    default:
                        JavaScript.MessageBox("操作失败", this);
                        return;
                }
 
 
                if (m_Pay_CashApply.State == 2)
                {
                    m_Pay_CashApply.Remark = m_Pay_CashApply.Remark + "<br/>完成时间:" + DateTime.Now.ToString() + ",完成人:" + CurrentUser.ShortName + "," + this.txtOver.Value;
                    m_Pay_CashApply.CompleteTime = DateTime.Now;
                    m_Pay_CashApply.UPTime = DateTime.Now;
                    if (m_Pay_CashApply.CashTypeId == 0)
                    {
                        if (m_Pay_PaymentAccount.SurplusMoney < (m_Pay_CashApply.Money ?? 0))
                        {
                            JavaScript.MessageBox("账户余额不足", this);
                            return;
                        }
 
                        m_Pay_Request = new Model.Pay.Pay_Request();
                        m_Pay_Request.Payeeid = AdminAccount.Keyid.Value;
                        m_Pay_Request.Payerid = m_Pay_PaymentAccount.Keyid.Value;
                        m_Pay_Request.Paymoney = m_Pay_CashApply.Money ?? 0;
                        m_Pay_Request.Subject = "账户提现";
                        m_Pay_Request.BalanceAccount = 12;
                        m_Pay_Request.UsedCredit = -1;
                    }
                    else if (m_Pay_CashApply.CashTypeId == 1)
                    {
                        if (m_Pay_PaymentAccount.PromotionMoney < (m_Pay_CashApply.Money ?? 0))
                        {
                            JavaScript.MessageBox("推广金余额不足", this);
                            return;
                        }
                        m_Pay_PaymentAccount.PromotionMoney = m_Pay_PaymentAccount.PromotionMoney - m_Pay_CashApply.Money ?? 0;
 
                        m_Pay_PromotionRecord = new Pay_PromotionRecord();
                        m_Pay_PromotionRecord.TradingMoney = m_Pay_CashApply.Money ?? 0;
                        m_Pay_PromotionRecord.TradingName = "推广金提现";
                        m_Pay_PromotionRecord.CreateTime = DateTime.Now;
                        m_Pay_PromotionRecord.TradingType = -1;
                        m_Pay_PromotionRecord.PayId = m_Pay_PaymentAccount.Keyid;
                        m_Pay_PromotionRecord.ResidualMoney = m_Pay_PaymentAccount.PromotionMoney;
                        m_Pay_PromotionRecord.TradingState = -1;
                        m_Pay_PromotionRecord.Remark = m_Pay_CashApply.MemberId.ToString2();
                        m_Pay_PromotionRecord.TardingRemark = "推广金提现";
                        m_Pay_PromotionRecord.IsProxy = false;
                        m_Pay_PromotionRecord.SendMemberId = m_Pay_PaymentAccount.MemberId;
                        m_Pay_PromotionRecord.GetMemberId = m_Pay_PaymentAccount.MemberId;
                        m_Pay_PromotionRecord.DataType = "推广";
                        m_Pay_PromotionRecord.RewardType = "推广金";
                    }
                    else if (m_Pay_CashApply.CashTypeId == 2)
                    {
                        if (m_Pay_PaymentAccount.ProxyMoneyCash < (m_Pay_CashApply.Money ?? 0))
                        {
                            JavaScript.MessageBox("申领的代理佣金余额不足", this);
                            return;
                        }
                        m_Pay_PaymentAccount.ProxyMoney = m_Pay_PaymentAccount.ProxyMoney - m_Pay_CashApply.Money ?? 0;
                        m_Pay_PaymentAccount.ProxyMoneyCash = m_Pay_PaymentAccount.ProxyMoneyCash - m_Pay_CashApply.Money ?? 0;
 
                        m_Pay_PromotionRecord = new Pay_PromotionRecord();
                        m_Pay_PromotionRecord.TradingMoney = m_Pay_CashApply.Money ?? 0;
                        m_Pay_PromotionRecord.TradingName = "申领代理佣金";
                        m_Pay_PromotionRecord.CreateTime = DateTime.Now;
                        m_Pay_PromotionRecord.TradingType = -1;
                        m_Pay_PromotionRecord.PayId = m_Pay_PaymentAccount.Keyid;
                        m_Pay_PromotionRecord.ResidualMoney = m_Pay_PaymentAccount.ProxyMoneyCash;
                        m_Pay_PromotionRecord.TradingState = -1;
                        m_Pay_PromotionRecord.Remark = m_Pay_CashApply.MemberId.ToString2();
                        m_Pay_PromotionRecord.TardingRemark = "申领代理佣金";
                        m_Pay_PromotionRecord.IsProxy = false;
                        m_Pay_PromotionRecord.SendMemberId = m_Pay_PaymentAccount.MemberId;
                        m_Pay_PromotionRecord.GetMemberId = m_Pay_PaymentAccount.MemberId;
                        m_Pay_PromotionRecord.DataType = "代理";
                        m_Pay_PromotionRecord.RewardType = "代理金";
                    }
                    else if (m_Pay_CashApply.CashTypeId == 3)
                    {
                        if (m_Pay_PaymentAccount.ProxyMoneyAudit < (m_Pay_CashApply.Money ?? 0))
                        {
                            JavaScript.MessageBox("申请报销的推广费用余额不足", this);
                            return;
                        }
                        m_Pay_PaymentAccount.ProxyMoney = m_Pay_PaymentAccount.ProxyMoney - m_Pay_CashApply.Money ?? 0;
                        m_Pay_PaymentAccount.ProxyMoneyAudit = m_Pay_PaymentAccount.ProxyMoneyAudit - m_Pay_CashApply.Money ?? 0;
 
                        m_Pay_PromotionRecord = new Pay_PromotionRecord();
                        m_Pay_PromotionRecord.TradingMoney = m_Pay_CashApply.Money ?? 0;
                        m_Pay_PromotionRecord.TradingName = "报销推广费用";
                        m_Pay_PromotionRecord.CreateTime = DateTime.Now;
                        m_Pay_PromotionRecord.TradingType = -1;
                        m_Pay_PromotionRecord.PayId = m_Pay_PaymentAccount.Keyid;
                        m_Pay_PromotionRecord.ResidualMoney = m_Pay_PaymentAccount.ProxyMoneyAudit;
                        m_Pay_PromotionRecord.TradingState = -1;
                        m_Pay_PromotionRecord.Remark = m_Pay_CashApply.MemberId.ToString2();
                        m_Pay_PromotionRecord.TardingRemark = "报销推广费用";
                        m_Pay_PromotionRecord.IsProxy = false;
                        m_Pay_PromotionRecord.SendMemberId = m_Pay_PaymentAccount.MemberId;
                        m_Pay_PromotionRecord.GetMemberId = m_Pay_PaymentAccount.MemberId;
                        m_Pay_PromotionRecord.DataType = "代理";
                        m_Pay_PromotionRecord.RewardType = "代理金";
                    }
                }
                else
                {
                    m_Pay_CashApply.Remark = m_Pay_CashApply.Remark + "<br/>审核时间:" + DateTime.Now.ToString() + ",审核人:" + CurrentUser.ShortName + "," + this.txtRemark.Value;
                    m_Pay_CashApply.AuditTime = DateTime.Now;
                    m_Pay_CashApply.UPTime = DateTime.Now;
                }
                if (bll_Pay_CashApplyBLL.HandleCash(m_Pay_CashApply, m_Pay_Request, m_Pay_PromotionRecord, m_Pay_PaymentAccount))
                {
                    if (m_Pay_CashApply.State == 2)
                    {
                        JavaScript.MessageBox("操作成功", this, "top.frmright.ReLoad();top.Dialog.close();");
                    }
                    else
                    {
                        JavaScript.MessageBox("审核成功", this, "window.location='/Pages/webmanage/CashHandle.aspx?Keyid=" + m_Pay_CashApply .Keyid+ "'");
                    }
                }
                else
                {
                    JavaScript.MessageBox("操作失败", this);
                }
 
            }
            else
            {
                JavaScript.MessageBox("操作失败", this);
            }
        }
    }
}