| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Data;
- using CoreFS.CA06;
- using DbHelp = Core.StlMes.Client.Sale.DbHelp;
- namespace Core.StlMes.Client.Sale.SaleFundMgt.FundBLL.FundCustAccount
- {
- public class FundCustAccountMgt : FundBaseBLL.FundBaseBLL
- {
- private OpeBase _ob;
- public FundCustAccountMgt(OpeBase ob)
- : base(ob)
- {
- _ob = ob;
- }
- /// <summary>
- /// 通过结算单位和客户名称,返回客户账户信息
- /// </summary>
- /// <param name="balanceSubject"></param>
- /// <param name="buyercode"></param>
- /// <returns></returns>
- public System.Data.DataSet GetCustAccountByBalanceSubjectAndBuyercode(string balanceSubject, string buyercode)
- {
- return GetFundCustAccountInstance().GetSelFundCustAccountInfo(balanceSubject, buyercode, true);
- }
- /// <summary>
- ///通过结算单位 获取所有客户账户数据集
- /// </summary>
- /// <param name="sqlQueryCondition"></param>
- /// <returns></returns>
- public DataSet GetCustAccountByBalanceSubject(string balanceSubject)
- {
- return base.GetFundCustAccountInstance().GetSelFundCustAccountInfo(balanceSubject);
- }
- /// <summary>
- /// 返回一个结算单位下的所有账户信息
- /// </summary>
- /// <param name="balanceSub"></param>
- /// <returns></returns>
- public List<Model.SEL_FUND_CUST_ACCOUNT> GetSelFundCustAccountByBalanceSubject(string balanceSub)
- {
- return this.GetFundCustAccountInstance().GetSelFundCustAccountModelByBalanceList(balanceSub);
- }
- public Model.SEL_FUND_CUST_ACCOUNT GetSelFundCustAccountByBalanceSubjectAndBuyercode(string balanceSubject, string buyercode)
- {
- return this.GetFundCustAccountInstance().GetSelFundCustAccountModelByBalanceAndBuyercode(balanceSubject,buyercode);
- }
- /// <summary>
- /// 通过结算单位,客户名称返回其资金转移明细数据
- /// </summary>
- /// <param name="balanceSubject"></param>
- /// <param name="buyercode"></param>
- /// <returns></returns>
- public DataSet GetSelFundUsedDetailByBalancesubjectAndBuyercode(string balanceSubject, string buyercode)
- {
- return base.GetFundCustUsedDetailInstance().GetSelFundUsedDetail(balanceSubject,buyercode);
- }
- public System.Collections.ArrayList GetAllSaleAre()
- {
- System.Collections.ArrayList list = new System.Collections.ArrayList();
- DataSet ds = new DataSet();
- string sql = "SELECT distinct A.SALE_AREA_DESC FROM SLM_BASE_SALE_AREA_TYP A where a.validflag='1'";
- ds = base.ExecuteReader(sql);
- try
- {
- foreach (DataRow dr in ds.Tables[0].Rows)
- {
- list.Add(dr[0].ToString());
- }
- }
- catch
- {
- }
- return list;
- }
- public void CreateCustAccount(Model.SEL_FUND_CUST_ACCOUNT acct, string creator,out string err)
- {
- err = "";
- // 检查同结算单位和合同号是否存在
- Model.SEL_FUND_CUST_ACCOUNT fund = null;
- DbHelp.DbTransaction transaction = base.GetTransaction();
- fund = GetFundCustAccountInstance().GetSelFundCustAccountModelByBalanceAndBuyercode(acct.BALANCESUBJECT, acct.BUYERCODE);
- //if (fund != null)
- //{
- // err = "客户信息已经存在";
- // return;
- //}
- bool isCreateSecAccountBySaleArea = true;
- System.Collections.ArrayList list = GetAllSaleAre();
- if (!isCreateSecAccountBySaleArea)
- {
- list.Clear();
- }
- try
- {
-
- Model.SEL_FUND_PACT_ACCOUNT pactact = new Model.SEL_FUND_PACT_ACCOUNT();
- //secact.BALANCESUBJECT = acct.BALANCESUBJECT;
- //secact.BUYERCODE = acct.BUYERCODE;
- //secact.SECONDACCOUNT = FundVariable.FundConstVariable.defaultSecondLevelAccount;
- //secact.IMPORTOR = creator;
- //secact.IMPORTTIME = Util.DateTimeUtil.GetSystemDate();
- pactact.BALANCESUBJECT = acct.BALANCESUBJECT;
- pactact.BUYERCODE = acct.BUYERCODE;
- pactact.SECONDACCOUNT = FundVariable.FundConstVariable.defaultSecondLevelAccount;
- pactact.PACTNO = FundVariable.FundConstVariable.defaultPactLevelAccount;
- pactact.IMPORTOR = creator;
- pactact.IMPORTTIME = Util.DateTimeUtil.GetSystemDate();
- System.Collections.ArrayList listsql = new System.Collections.ArrayList();
- // 写入记录
- // 创建客户账户
- // GetFundCustAccountInstance().Insert_SelFundCustAccount(acct, transaction);
- if (fund == null)
- listsql.Add(GetFundCustAccountInstance().Sql_Insert_SelFundCustAccount(acct));
- // 创建默认二级账户
- // 是否创建默认的二级账户和合同账户
- if (FundVariable.FundConstVariable.isCreateDefaultAccount)
- {
- Model.SEL_FUND_SECONDLEVEL_ACCOUNT secact = null;
- secact = new Core.StlMes.Client.Sale.SaleFundMgt.Model.SEL_FUND_SECONDLEVEL_ACCOUNT();
- secact.BALANCESUBJECT = acct.BALANCESUBJECT;
- secact.BUYERCODE = acct.BUYERCODE;
- secact.SECONDACCOUNT = FundVariable.FundConstVariable.defaultSecondLevelAccount;
- secact.IMPORTOR = creator;
- secact.IMPORTTIME = Util.DateTimeUtil.GetSystemDate();
- Model.SEL_FUND_SECONDLEVEL_ACCOUNT secacct1 =
- base.GetFundSecondAccountInstance().GetSelFundSecondAccountBySecondAccount(secact.BALANCESUBJECT, secact.BUYERCODE, secact.SECONDACCOUNT);
- if (secacct1 == null)
- {
- // listsql.Add(GetFundSecondAccountInstance().SqlCreateSecondLevelAccount(secact));
- // GetFundSecondAccountInstance().CreateSecondLevelAccount(secact, transaction);
- }
- List<Model.SEL_FUND_PACT_ACCOUNT> acctmodel = base.GetFundPactAccountInstance().
- GetSelFundPactAccountByBalanceAndPactno(pactact.BALANCESUBJECT, pactact.BUYERCODE, pactact.PACTNO);
- if (acctmodel == null || acctmodel.Count == 0)
- {
- // 创建默认合同账户
- // GetFundPactAccountInstance().CreateFundPactAccount(pactact, transaction);
- // listsql.Add(GetFundPactAccountInstance().Sql_CreateFundPactAccount(pactact));
- }
- if (list.Count > 0)
- {
- foreach (string s in list)
- {
- secact = new Core.StlMes.Client.Sale.SaleFundMgt.Model.SEL_FUND_SECONDLEVEL_ACCOUNT();
- secact.BALANCESUBJECT = acct.BALANCESUBJECT;
- secact.BUYERCODE = acct.BUYERCODE;
- secact.SECONDACCOUNT = s;
- secact.IMPORTOR = creator;
- secact.IMPORTTIME = Util.DateTimeUtil.GetSystemDate();
- Model.SEL_FUND_SECONDLEVEL_ACCOUNT secacct =
- base.GetFundSecondAccountInstance().GetSelFundSecondAccountBySecondAccount(secact.BALANCESUBJECT, secact.BUYERCODE, secact.SECONDACCOUNT);
- if (secacct == null)
- {
- listsql.Add(GetFundSecondAccountInstance().SqlCreateSecondLevelAccount(secact));
- // GetFundSecondAccountInstance().CreateSecondLevelAccount(secact, transaction);
- }
- pactact.SECONDACCOUNT = s;
- // List<Model.SEL_FUND_PACT_ACCOUNT> acctmodel1 = base.GetFundPactAccountInstance().
- //GetSelFundPactAccountByBalanceAndPactno(pactact.BALANCESUBJECT, pactact.BUYERCODE, pactact.PACTNO);
- // if (acctmodel1 == null || acctmodel1.Count == 0)
- // {
- // // 创建默认合同账户
- // // GetFundPactAccountInstance().CreateFundPactAccount(pactact, transaction);
- // listsql.Add(GetFundPactAccountInstance().Sql_CreateFundPactAccount(pactact));
- // }
-
- }
- }
-
- }
- string errMsg = "";
- base.ExecuteNoReader(listsql, out err);
- // 提交
- }
- catch(Exception ex)
- {
-
-
- }
-
-
-
- }
- /// <summary>
- /// 在集合中搜寻一个客户单位
- /// </summary>
- /// <param name="balanceSubject"></param>
- /// <param name="buyercode"></param>
- /// <param name="list"></param>
- /// <returns></returns>
- public Boolean IsCustAccountExists(string balanceSubject, string buyercode, List<Model.SEL_FUND_CUST_ACCOUNT> list)
- {
- if (list == null)
- return false;
- if (list.Count == 0)
- return false;
- foreach (Model.SEL_FUND_CUST_ACCOUNT acc in list)
- {
- if (acc.BALANCESUBJECT == balanceSubject && acc.BUYERCODE == buyercode)
- {
- return true;
-
- }
- }
- return false;
- }
-
- /// <summary>
- /// 删除一个客户账户信息
- /// </summary>
- /// <param name="balanceSubject"></param>
- /// <param name="buyercode"></param>
- /// <param name="errMsg"></param>
- public void DeleCustAccount(string balanceSubject, string buyercode, string deletor,out string errMsg)
- {
- errMsg = "";
- // 检查账户信息
- Model.SEL_FUND_CUST_ACCOUNT cust = GetSelFundCustAccountByBalanceSubjectAndBuyercode(balanceSubject,buyercode);
- if (cust == null)
- return;
- // 有剩余资金,不允许删除
- if (cust.LEAVEMONEY > 0)
- {
- errMsg = "剩余资金大于0";
- return;
- }
-
- // 有二级账户,不允许删除
- FundDAL.FundSecondLevelAccountDAL.FundSecondlevelAccountDAL secacct = new FundDAL.FundSecondLevelAccountDAL.FundSecondlevelAccountDAL(this._ob);
- List<Model.SEL_FUND_SECONDLEVEL_ACCOUNT> seclist =
- secacct.GetSelFundSecondAccountByBalanceSubjectAndBuyercode(balanceSubject,buyercode);
- if (seclist != null)
- {
- if (seclist.Count > 0)
- {
- errMsg = "该账户存在子账户";
- return;
- }
- }
- // 删除
- GetFundCustAccountInstance().DeleteCustAccount(balanceSubject, buyercode, out errMsg);
- }
-
-
- }
- }
|