从山证v2.3.0拷贝
This commit is contained in:
@@ -0,0 +1,187 @@
|
||||
using BaseOUDAL;
|
||||
|
||||
namespace YLErp.Modules.ClientCashModule
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class ClientCashOtherService : YLBaseService
|
||||
{
|
||||
public ClientCashOtherService(OptUserInfo userInfo) : base(userInfo)
|
||||
{
|
||||
}
|
||||
|
||||
public client_cash_other SaveClientCashOther(client_cash_other req)
|
||||
{
|
||||
client_cash_other clientCashOther;
|
||||
bool isAddNew = req.id == 0;
|
||||
|
||||
if (isAddNew)
|
||||
{
|
||||
DbContext.client_cash_other.Add(clientCashOther = new client_cash_other());
|
||||
}
|
||||
else
|
||||
{
|
||||
clientCashOther = DbContext.client_cash_other.Find(req.id);
|
||||
}
|
||||
|
||||
DbContext.Entry(clientCashOther).CurrentValues.SetValues(req);
|
||||
if (req.Action.Contains("支出") && clientCashOther.Money > 0)
|
||||
{
|
||||
clientCashOther.Money = -clientCashOther.Money;
|
||||
}
|
||||
clientCashOther.OptId = UserId;
|
||||
clientCashOther.OptName = UserName;
|
||||
clientCashOther.OptDate = DateTime.Now;
|
||||
|
||||
//设置关联数据
|
||||
var client = DataCacheProvider.GetClientDataSource().GetData(req.ClientId ?? 0);
|
||||
if (client != null)
|
||||
{
|
||||
clientCashOther.ClientName = client.Name;
|
||||
clientCashOther.ClientNumber = client.Number;
|
||||
}
|
||||
|
||||
DbContext.SaveChanges();
|
||||
|
||||
return clientCashOther;
|
||||
}
|
||||
|
||||
public SearchListResult<client_cash_other> SearchClientCashOtherList(ClientCashOtherReq req)
|
||||
{
|
||||
var query = from source in DbContext.client_cash_other select source;
|
||||
|
||||
if (!string.IsNullOrEmpty(req.ClientName))
|
||||
{
|
||||
query = query.Where(x => x.ClientName.Contains(req.ClientName));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(req.ClientIds) && req.ClientIdsInt.Count()>0)
|
||||
{
|
||||
query = query.Where(d => d.ClientId != null && req.ClientIdsInt.Contains(d.ClientId.Value));
|
||||
}
|
||||
|
||||
if (req.HappenDateStart != DateTime.MinValue)
|
||||
{
|
||||
query = query.Where(d => d.HappenDate >= req.HappenDateStart);
|
||||
}
|
||||
|
||||
if (req.HappenDateEnd != DateTime.MinValue)
|
||||
{
|
||||
DateTime HappenDateTemp = req.HappenDateEnd.AddDays(1);
|
||||
query = query.Where(d => d.HappenDate < HappenDateTemp);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(req.ActionTypes))
|
||||
{
|
||||
query = query.Where(x => req.ActionTypes.Contains(x.Action));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(req.sidx))
|
||||
{
|
||||
req.sidx = "HappenDate";
|
||||
req.sord = "desc";
|
||||
}
|
||||
|
||||
SearchListResult<client_cash_other> retListResult = query.ToSearchList(req);
|
||||
|
||||
var gsum = new client_cash_otherGridSum();
|
||||
if (query.Any())
|
||||
{
|
||||
gsum.MoneySum = query.Sum(q => q.Money);
|
||||
}
|
||||
retListResult.Sum = gsum;
|
||||
|
||||
return retListResult;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class ClientCashOtherReq : BaseSearchReq
|
||||
{
|
||||
public int? id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 客户ID
|
||||
/// </summary>
|
||||
public int? ClientId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 客户编号
|
||||
/// </summary>
|
||||
public string ClientNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 客户名称
|
||||
/// </summary>
|
||||
public string ClientName { get; set; }
|
||||
|
||||
public string ClientIds { get; set; }
|
||||
|
||||
public List<int> ClientIdsInt
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(ClientIds))
|
||||
{
|
||||
return new List<int>();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ClientIds.Substring(0, 1) == ",")
|
||||
{
|
||||
return new List<int>();
|
||||
}
|
||||
return ClientIds.Split(',').Select(c => Convert.ToInt32(c)).ToList();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 操作类型
|
||||
/// </summary>
|
||||
public string Action { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作类型复选框筛选条件
|
||||
/// </summary>
|
||||
public string ActionTypes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 金额
|
||||
/// </summary>
|
||||
public double? Money { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 发生时间
|
||||
/// </summary>
|
||||
public DateTime? HappenDate { get; set; }
|
||||
|
||||
public DateTime HappenDateStart { get; set; }
|
||||
|
||||
public DateTime HappenDateEnd { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string Comments { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作人
|
||||
/// </summary>
|
||||
public int? OptId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作人
|
||||
/// </summary>
|
||||
public string OptName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作时间
|
||||
/// </summary>
|
||||
public DateTime? OptDate { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user