returnGet<RB_BackAccount_Extend>(string.Format("SELECT A.*,B.`Name` as BackName,B.Logo as BackLogo,C.`Name` as TypeName,D.`Name` as CurrencyName,D.Rate,D.CurrentRate as CurrencyRate,D.OutCashRate as PayRate,D.ExchangeRates,D.IsStandardCurrency as IsStandardCurrency FROM {0} as A LEFT JOIN rb_financialinstitutions AS B ON A.BackId = B.ID left JOIN RB_AccountType as c ON A.TypeId = C.ID LEFT JOIN rb_currency as D ON D.ID = A.currencyID {1}",TableName,where)).ToList();
}
/// <summary>
/// 查询银行名称
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
publicstringGetBankName(intid)
{
stringsql=$"select Alias from {TableName} where ID={id}";
where+=string.Format(" AND A."+nameof(RB_BackAccount.RB_Group_Id)+" ={0} ",RB_Group_id);
}
where+=string.Format(" AND A."+nameof(RB_BackAccount.Alias)+" like '%{0}%' ",alias);
returnGet<RB_BackAccount_Extend>(string.Format("SELECT A.ID,A.Alias,A.RB_Branch_Id,B.`Name` as BackName,C.`Name` as TypeName FROM {0} as A LEFT JOIN rb_financialinstitutions AS B ON A.BackId = B.ID left JOIN RB_AccountType as c ON A.TypeId = C.ID LEFT JOIN rb_currency as D ON D.ID = A.currencyID {1}",TableName,where)).ToList();
stringwhere=$@" 1=1 and c.{nameof(RB_ClientBankAccount.Type)}={Type} and c.{nameof(RB_ClientBankAccount.RB_Group_Id)}={RB_Group_id}";
if(empId>0)
{
where+=$@" and c.{nameof(RB_ClientBankAccount.ObjID)}={empId}";
}
if(bankId>0)
{
where+=$@" and c.{nameof(RB_ClientBankAccount.BankId)}={bankId}";
}
if(BranchId>=0)
{
where+=$@" and c.{nameof(RB_ClientBankAccount.RB_Branch_Id)}={BranchId}";
}
if(!string.IsNullOrWhiteSpace(accountHolder))
{
where+=$@" and c.{nameof(RB_ClientBankAccount.AccountHolder)} like '%{accountHolder}%'";
}
if(!string.IsNullOrWhiteSpace(accountAlias))
{
where+=$@" and c.{nameof(RB_ClientBankAccount.AccountAlias)} like '%{accountAlias}%'";
}
stringsql=$@" select c.*,b.Name as BankName,sum(IFNULL(f.PayMoney,0)) as PayMoney from {TableName} c left join RB_FinancialInstitutions b on c.{nameof(RB_ClientBankAccount.BankId)}=b.ID
left join {nameof(RB_Finance)} f on f.{nameof(RB_Finance.ClientType)}=c.{nameof(RB_ClientBankAccount.Type)} and f.{nameof(RB_Finance.ClientID)}=c.{nameof(RB_ClientBankAccount.ObjID)} and f.{nameof(RB_Finance.Status)}=2
where {where} group by c.ID,B.Name order by c.ID desc";
SELECT A.ID,B.ID AS BankID,A.`Name`,B.alias as Alias,B.backNo,IFNULL(B.Initialbalance,0)AS Initialbalance,IFNULL(B.Initialbalance*A.CurrentRate,0) as Balance,1 AS Type,A.`Status` FROM rb_currency AS A LEFT JOIN rb_backaccount AS B ON A.ID=B.currencyId where B.`Status`=0
UNION ALL
SELECT A.ID,B.ID AS BankID,A.`Name`,B.Alias,B.PlatformNo as backNo,IFNULL(B.Initialbalance,0)AS Initialbalance,IFNULL(B.Initialbalance*A.CurrentRate,0) as Balance,2 AS Type,A.`Status` FROM rb_currency AS A LEFT JOIN rb_platformaccount AS B ON A.ID=B.CurrencyId where B.`Status`=0
UNION ALL
SELECT A.ID,B.ID AS BankID,A.`Name`,B.Alias,'' as backNo,IFNULL(B.Initialbalance,0)AS Initialbalance,IFNULL(B.Initialbalance*A.CurrentRate,0) as Balance,3 AS Type,A.`Status` FROM rb_currency AS A LEFT JOIN rb_cashaccount AS B ON A.ID=B.CurrencyId where B.`Status`=0
UNION ALL
SELECT A.ID,B.ID AS BankID,A.`Name`,B.Alias,'' as backNo,IFNULL(B.Initialbalance,0)AS Initialbalance,IFNULL(B.Initialbalance*A.CurrentRate,0) as Balance,4 AS Type,A.`Status` FROM rb_currency AS A LEFT JOIN rb_cashpoolaccount AS B ON A.ID=B.CurrencyId where B.`Status`=0) as Temp ");
sbwhere.AppendFormat(" AND Temp.{0}={1}",nameof(RB_Currency.Status),(int)DateStateEnum.Normal);
if(model.ID>0)
{
sbwhere.AppendFormat(" AND Temp.{0}={1} ",nameof(RB_Currency.ID),model.ID);
}
if(sbwhere.ToString().Length>0)
{
sbwhere.Insert(0," WHERE 1=1 ");
}
returnGetPage<RB_Currency_Extend>(pageIndex,pageSize,outcount,sb.ToString()+sbwhere.ToString()+" order by Temp.ID,Temp.Type ASC ").ToList();
SELECT A.ID,B.ID AS BankID,A.`Name`,B.alias as Alias,B.backNo,B.Initialbalance,IFNULL(B.Initialbalance*A.CurrentRate,0) as Balance,1 AS Type,A.`Status` FROM rb_currency AS A LEFT JOIN rb_backaccount AS B ON A.ID=B.currencyId where B.`Status`=0
UNION ALL
SELECT A.ID,B.ID AS BankID,A.`Name`,B.Alias,B.PlatformNo as backNo,B.Initialbalance,IFNULL(B.Initialbalance*A.CurrentRate,0) as Balance,2 AS Type,A.`Status` FROM rb_currency AS A LEFT JOIN rb_platformaccount AS B ON A.ID=B.CurrencyId where B.`Status`=0
UNION ALL
SELECT A.ID,B.ID AS BankID,A.`Name`,B.Alias,'' as backNo,B.Initialbalance,IFNULL(B.Initialbalance*A.CurrentRate,0) as Balance,3 AS Type,A.`Status` FROM rb_currency AS A LEFT JOIN rb_cashaccount AS B ON A.ID=B.CurrencyId where B.`Status`=0
UNION ALL
SELECT A.ID,B.ID AS BankID,A.`Name`,B.Alias,'' as backNo,B.Initialbalance,IFNULL(B.Initialbalance*A.CurrentRate,0) as Balance,4 AS Type,A.`Status` FROM rb_currency AS A LEFT JOIN rb_cashpoolaccount AS B ON A.ID=B.CurrencyId where B.`Status`=0) as Temp ");
sbwhere.AppendFormat(" AND Temp.{0}={1}",nameof(RB_Currency_Extend.Status),(int)DateStateEnum.Normal);
if(model.ID>0)
{
sbwhere.AppendFormat(" AND Temp.{0}={1} ",nameof(RB_Currency_Extend.ID),model.ID);