username@email.com
2025-05-15 6fe02a16e55f17e45a3997171e1b2284d45af25b
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
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.OA;
using CY.Infrastructure.Common;
using CY.BLL.Sys;
using CY.BLL;
namespace CY.WebForm.Pages.financial
{
    //吴辉
    //汇款确认
    public partial class PayConfirm : BasePage
    {
        OA_RemittanceAdviceBLL _OA_RemittanceAdviceBLL = null;
        OA_FirmAccountBLL _OA_FirmAccountBLL = null;
        OA_SubjectSetBLL _OA_SubjectSetBLL = null;
        Sys_DictionaryBLL _Sys_DictionaryBLL = null;
        OA_CorporateClientsBLL bll_OA_CorporateClientsBLL = null;
        OA_AdvanceMoneyRecordBLL bll_OA_AdvanceMoneyRecordBLL = null;
 
        public string IsAdmin;
 
        public PayConfirm()
        {
            _OA_SubjectSetBLL = new OA_SubjectSetBLL();
            _OA_FirmAccountBLL = new OA_FirmAccountBLL();
            _OA_RemittanceAdviceBLL = new OA_RemittanceAdviceBLL();
            _Sys_DictionaryBLL = new Sys_DictionaryBLL();
            bll_OA_CorporateClientsBLL = new OA_CorporateClientsBLL();
            bll_OA_AdvanceMoneyRecordBLL = new OA_AdvanceMoneyRecordBLL();
        }
 
        protected void Page_Load(object sender, EventArgs e)
        {
            IsAdmin = (CurrentUser.MemberType == "管理员" ? "1" : "0");
            try
            {
                switch (Request["DataType"])
                {
                    case "change":
                        Response.Write(reLoadAccountName(Request["TypeName"].ToString2()));
                        break;
                    default://一般情况不处理
                        if (IsPostBack || IsCallback)
                            return;
                        else
                        {
                            InitialData();
                            BindList();
                        }
                        return;
                }
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                Response.Clear();
                Response.Write("-1");
            }
            Response.End();
        }
 
        protected string reLoadAccountName(string selAcoountType)
        {
            return JsonHelper.GetJsonStringByObject(_OA_FirmAccountBLL.getAllSubject(CurrentUser.MemberId, selAcoountType));
        }
 
        protected void BindList()
        {
            OA_RemittanceAdvice remittanceAdvice = _OA_RemittanceAdviceBLL.SelectSingleModel(Request["Keyid"].ToString2());
 
            if (Request["type"] == "ReceiveFirmName")
            {
                this.tdFirm.InnerText = "收款厂商:";
                this.spanFirm.InnerText = remittanceAdvice.ReceiveFirmName;
            }
            else
            {
                this.tdFirm.InnerText = "汇款厂商:";
                this.spanFirm.InnerText = remittanceAdvice.RemittanceFirmName;
            }
 
            this.spanRemittanceBankId.InnerText = remittanceAdvice.RemittanceBankName;
            this.spanRemittanceMoney.InnerText = remittanceAdvice.RemittanceMoney.ToString2();
            this.spanSureMoney.Value = remittanceAdvice.RemittanceMoney.ToString2();
            this.txtRemark.InnerHtml = remittanceAdvice.Remark;
            this.txtInAccountMoney.Value = remittanceAdvice.RemittanceMoney.ToString2();
        }
 
        protected void InitialData()
        {
            //科目名称
            this.selSubject.DataSource = _OA_SubjectSetBLL.getAllSubject(CurrentUser.MemberId, "借");
            this.selSubject.DataBind();
            this.selSubject.Items.Insert(0, new ListItem("请选择", ""));
 
            //账户类型
            this.selAcoountType.DataSource = _Sys_DictionaryBLL.GetDataByType("账户类型");
            this.selAcoountType.DataBind();
        }
 
        protected void btn_Submit_Click(object sender, EventArgs e)
        {
            try
            {
                OA_RemittanceAdvice remittanceAdvice = _OA_RemittanceAdviceBLL.SelectSingleModel(Request["Keyid"].ToString2());
                decimal PayMoney = this.spanSureMoney.Value.ToDecimal2() ?? 0;
                decimal IncomeMoney = this.txtInAccountMoney.Value.ToDecimal2() ?? 0;
 
                if (PayMoney < 0)
                {
                    JavaScript.MessageBox("请填写大于 0 的确认金额",this,false,false);
                    return;
                }
                if (PayMoney > remittanceAdvice.RemittanceMoney)
                {
                    JavaScript.MessageBox("确认金额 不能大于 汇款金额", this, false, false);
                    return;
                }
                if (IncomeMoney > PayMoney)
                {
                    JavaScript.MessageBox("预付款存入金额 不能大于 确认金额", this, false, false);
                    return;
                }
 
                remittanceAdvice.SuerMoney = PayMoney;
                remittanceAdvice.SuerPerson = CurrentUser.ShortName;
                remittanceAdvice.SuerTime = DateTime.Now;
                remittanceAdvice.TrandingStatus = 1;
                _OA_RemittanceAdviceBLL.UpdateModel(remittanceAdvice);
 
                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.Now;
                firmAccountRecord.Money = PayMoney;
                firmAccountRecord.OperationalMatters = " ";
                firmAccountRecord.Operator = CurrentUser.ShortName;
                firmAccountRecord.PaymentUnit = this.spanFirm.InnerText;
                firmAccountRecord.RecordTypeId = 1;//收入
                firmAccountRecord.Remark = " ";
                firmAccountRecord.SubjectId = selSubject.Value.ToInt32();
                firmAccountRecord.ResidualAmount = firmAccount.Balance;
                firmAccountRecord.Department = "";
 
                if (IncomeMoney >0)
                {
                    if (CurrentUser.MemberType == "管理员")
                    {
                        Guid nowGuid = remittanceAdvice.RemittanceFirmId;
                        EC_MemberBasicBLL bll_EC_MemberBasicBLL = new EC_MemberBasicBLL();
                        Pay_PaymentAccountBLL bll_Pay_PaymentAccountBLL = new Pay_PaymentAccountBLL();
                        Pay_PaymentAccount m_Pay_PaymentAccount = bll_EC_MemberBasicBLL.GetPaymentAccountByMemberId(nowGuid);
                        CY.Model.Pay.Pay_Request m_Pay_Request = null;
 
                        m_Pay_Request = new Model.Pay.Pay_Request();
                        m_Pay_Request.Payeeid = m_Pay_PaymentAccount.Keyid ?? 0;
                        m_Pay_Request.Payerid = AdminAccount.Keyid ?? 0;
                        m_Pay_Request.Paymoney = IncomeMoney;
                        m_Pay_Request.Subject = "线下转账充值";
                        m_Pay_Request.BalanceAccount = 0;
                        m_Pay_Request.UsedCredit = -1;
 
                        bool IsSuccess = bll_Pay_PaymentAccountBLL.RechargeSuccesUnLine(m_Pay_PaymentAccount,m_Pay_Request);
                        //if (IsSuccess)
                        //{
                        //    m_Pay_PaymentAccount = bll_EC_MemberBasicBLL.GetPaymentAccountByMemberId(nowGuid);
                        //    bll_Pay_PaymentAccountBLL.SendPoOrMoToMember(nowGuid, 86, IncomeMoney);
                        //}
                    }
                    else
                    {
                        OA_CorporateClients m_OA_CorporateClients = bll_OA_CorporateClientsBLL.SelectModelByFirmIdandMemberId(CurrentUser.MemberId, remittanceAdvice.RemittanceFirmId);
                        m_OA_CorporateClients.Prepayments = m_OA_CorporateClients.Prepayments + IncomeMoney;
                        bll_OA_CorporateClientsBLL.UpdateModel(m_OA_CorporateClients);
 
                        OA_AdvanceMoneyRecord m_OA_AdvanceMoneyRecord = new OA_AdvanceMoneyRecord();
                        m_OA_AdvanceMoneyRecord.CustomerId = m_OA_CorporateClients.Keyid;
                        m_OA_AdvanceMoneyRecord.OperatTypeId = _Sys_DictionaryBLL.GetNameByMeanValue(1, "客户预付款明细类型");
                        m_OA_AdvanceMoneyRecord.OperatMoney = PayMoney;
                        m_OA_AdvanceMoneyRecord.SubjectName = PayMoney > 0 ? "预付款收入" : "预付款收入(负)";
                        m_OA_AdvanceMoneyRecord.AccountType = firmAccount.AccountType;
                        m_OA_AdvanceMoneyRecord.AccountName = firmAccount.AccountName + "-" + firmAccount.UserName;
                        m_OA_AdvanceMoneyRecord.LastUpdateTime = DateTime.Now;
                        m_OA_AdvanceMoneyRecord.Operator = CurrentUser.ShortName.ToString2();
                        m_OA_AdvanceMoneyRecord.Remark = "来自 客户汇款";
                        bll_OA_AdvanceMoneyRecordBLL.InsertModel(m_OA_AdvanceMoneyRecord);
                    }
                }
 
                OA_FirmAccountRecordBLL _OA_FirmAccountRecordBLL = new OA_FirmAccountRecordBLL();
                if (_OA_FirmAccountRecordBLL.AddModel(firmAccountRecord, firmAccount))
                    JavaScript.RefreshDIVOpener(this);
                else
                    JavaScript.MessageBox("操作失败", this);
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                JavaScript.MessageBox("操作失败", this);
            }
        }
    }
}