从山证v2.3.0拷贝
This commit is contained in:
@@ -0,0 +1,177 @@
|
||||
using BaseOUDAL;
|
||||
|
||||
namespace YLErp.Modules.BasicDataModule
|
||||
{
|
||||
public class ExchangeAccountService : YLBaseService
|
||||
{
|
||||
public ExchangeAccountService(OptUserInfo userInfo) : base(userInfo)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询exchange_account
|
||||
/// </summary>
|
||||
public SearchListResult<ExchangeAccountDto> SearchList(ExchangeAccountReq req)
|
||||
{
|
||||
var query = from a in DbContext.exchange_account
|
||||
join b in DbContext.assetunit on a.DefaultBookId equals b.id into bs
|
||||
from b in bs.DefaultIfEmpty()
|
||||
orderby a.id descending
|
||||
select new ExchangeAccountDto
|
||||
{
|
||||
id = a.id,
|
||||
AccountCode = a.AccountCode,
|
||||
AccountName = a.AccountName,
|
||||
AccountType = a.AccountType,
|
||||
DefaultBookId = a.DefaultBookId,
|
||||
Description = a.Description,
|
||||
InitialCost = a.InitialCost,
|
||||
Status = a.Status,
|
||||
Total = a.Total,
|
||||
Available = a.Available,
|
||||
CurrFund = a.CurrFund,
|
||||
CurrMargin = a.CurrMargin,
|
||||
TraderIds = a.TraderIds,
|
||||
TraderNames = a.TraderNames,
|
||||
VarietyIds = a.VarietyIds,
|
||||
AssetBookName = b.Name
|
||||
};
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(req.AccountName))
|
||||
{
|
||||
query = query.Where(s => s.AccountName.Contains(req.AccountName));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(req.AccountCode))
|
||||
{
|
||||
query = query.Where(d => d.AccountCode.Contains(req.AccountCode));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(req.AccountType))
|
||||
{
|
||||
query = query.Where(d => d.AccountType.Contains(req.AccountType));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(req.TraderIds))
|
||||
{
|
||||
query = query.Where(d => d.TraderIds.Contains(req.TraderIds));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(req.TraderNames))
|
||||
{
|
||||
query = query.Where(s => ("," + s.TraderIds + ",").Contains("," + req.TraderNames + ","));
|
||||
}
|
||||
|
||||
if (req.Status != null)
|
||||
{
|
||||
query = query.Where(d => d.Status == req.Status);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(req.Description))
|
||||
{
|
||||
query = query.Where(d => d.Description.Contains(req.Description));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(req.sidx))
|
||||
{
|
||||
req.sidx = "id";
|
||||
req.sord = "desc";
|
||||
}
|
||||
|
||||
return query.ToSearchList(req, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过对冲账户编码获取对冲账户
|
||||
/// </summary>
|
||||
/// <param name="codes"></param>
|
||||
/// <returns></returns>
|
||||
public List<ExchangeAccount> GetListByCodes(List<string> codes)
|
||||
{
|
||||
if (codes == null || codes.Count == 0)
|
||||
{
|
||||
return new List<ExchangeAccount>();
|
||||
}
|
||||
return DbContext.exchange_account.AsNoTracking().Where(p => codes.Contains(p.AccountCode) && p.Status == 1).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取对冲账户编号
|
||||
/// </summary>
|
||||
/// <param name="bookIds"></param>
|
||||
/// <returns></returns>
|
||||
public List<ExchangeAccount> GetExchangeAccountByBookIds(List<int> bookIds)
|
||||
{
|
||||
return DbContext.exchange_account.AsNoTracking().Where(p => p.DefaultBookId > 0 && bookIds.Contains((int)p.DefaultBookId) && p.Status == 1).ToList();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class ExchangeAccountReq : BaseSearchReq
|
||||
{
|
||||
public string AccountName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 账户
|
||||
/// </summary>
|
||||
public string AccountCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 账户类型
|
||||
/// </summary>
|
||||
public string AccountType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 交易员id
|
||||
/// </summary>
|
||||
public string TraderIds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 交易员名称
|
||||
/// </summary>
|
||||
public string TraderNames { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 状态
|
||||
/// </summary>
|
||||
public int? Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 初始成本
|
||||
/// </summary>
|
||||
public double? InitialCost { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 总资金
|
||||
/// </summary>
|
||||
public double? Total { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 可用资金
|
||||
/// </summary>
|
||||
public double? Available { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 描述
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 默认簿记账户Id
|
||||
/// </summary>
|
||||
public int? DefaultBookId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 品种
|
||||
/// </summary>
|
||||
public string VarietyIds { get; set; }
|
||||
}
|
||||
|
||||
public class ExchangeAccountResult
|
||||
{
|
||||
public ExchangeAccount ExchangeAccount { get; set; }
|
||||
|
||||
public AssetUnit TradingBook { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user