Browse Source

更新版本

FoShanPG
Administrator 3 years ago
parent
commit
951f295654
  1. 4
      src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Materials/MaterialAppService.cs
  2. 6
      src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceList.cs
  3. 39
      src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceListManager.cs

4
src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Materials/MaterialAppService.cs

@ -174,7 +174,7 @@ namespace Win.Sfs.SettleAccount.Entities.Materials
var _first = result.FirstOrDefault(p => p.MaterialCode == itm);
if (_first != null)
{
var _price = new PriceList(GuidGenerator.Create(), DateTime.MinValue, DateTime.MaxValue, _first.MaterialPrice, _first.MaterialCode, 0, GuidGenerator.Create(), version);
var _price = new PriceList(GuidGenerator.Create(), DateTime.MinValue, DateTime.MaxValue, _first.MaterialPrice, _first.MaterialCode, 0, GuidGenerator.Create(), version,string.Empty);
_priceList.Add(_price);
}
}
@ -183,7 +183,7 @@ namespace Win.Sfs.SettleAccount.Entities.Materials
var _first = result.FirstOrDefault(p => p.ChildMaterialCode == itm);
if (_first != null)
{
var _price = new PriceList(GuidGenerator.Create(), DateTime.MinValue, DateTime.MaxValue, _first.ChildMaterialPrice, _first.ChildMaterialCode, 0, GuidGenerator.Create(), version);
var _price = new PriceList(GuidGenerator.Create(), DateTime.MinValue, DateTime.MaxValue, _first.ChildMaterialPrice, _first.ChildMaterialCode, 0, GuidGenerator.Create(), version,string.Empty);
_priceList.Add(_price);
}
}

6
src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceList.cs

@ -20,7 +20,7 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
{
public PriceList()
{ }
public PriceList(Guid Id,DateTime beginDate, DateTime endDate, decimal price, string materialCode, int type,Guid parentId,string version):base(Id)
public PriceList(Guid Id,DateTime beginDate, DateTime endDate, decimal price, string materialCode, int type,Guid parentId,string version, string customerCode) :base(Id)
{
BeginDate = beginDate;
EndDate = endDate;
@ -29,15 +29,17 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
Type = type;
ParentId = parentId;
Version = version;
CustomerCode = customerCode;
}
public void Set(DateTime beginDate, DateTime endDate, decimal price, string materialCode, int type)
public void Set(DateTime beginDate, DateTime endDate, decimal price, string materialCode, int type,string customerCode)
{
BeginDate = beginDate;
EndDate = endDate;
Price = price;
MaterialCode = materialCode;
Type = type;
CustomerCode = customerCode;
}
public void Update(Guid id,string version)
{

39
src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceListManager.cs

@ -78,25 +78,40 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
var pricelist = GetPriceList(version);
//var LeftJoin = from emp in ListOfEmployees
// join dept in ListOfDepartment
// on emp.DeptID equals dept.ID into JoinedEmpDept
// from dept in JoinedEmpDept.DefaultIfEmpty()
var add= from itm1 in entities join itm2 in pricelist
on new { itm1.Type, itm1.CustomerCode, itm1.MaterialCode } equals new { itm2.Type, itm2.CustomerCode, itm2.MaterialCode }
into temp from itm3 in temp.DefaultIfEmpty() where itm3 == null select itm1;
var update = from itm1 in entities
join itm2 in pricelist
on new { itm1.Type, itm1.CustomerCode, itm1.MaterialCode } equals new { itm2.Type, itm2.CustomerCode, itm2.MaterialCode }
on new { itm1.Type, itm1.MaterialCode } equals new { itm2.Type, itm2.MaterialCode }
where itm1.Price != itm2.Price
select new PriceList(itm2.Id, itm2.BeginDate, itm2.EndDate, itm1.Price, itm2.MaterialCode,itm2.Type, itm2.ParentId, itm2.Version);
select new PriceList(itm2.Id, itm2.BeginDate, itm2.EndDate, itm1.Price, itm2.MaterialCode, itm2.Type, itm2.ParentId, itm2.Version, itm1.CustomerCode);
if (update.Count() > 0)
{
await _repository.GetDbContext().BulkUpdateAsync(update.ToList());
}
else
{
var add = from itm1 in entities
join itm2 in pricelist
on new { itm1.Type, itm1.MaterialCode }
equals new { itm2.Type, itm2.MaterialCode }
into temp
from itm3 in temp.DefaultIfEmpty()
where itm3 == null
select itm1;
await _repository.GetDbContext().BulkInsertAsync<PriceList>(add.ToList());
}
await _repository.GetDbContext().BulkUpdateAsync(update.ToList());
await _repository.GetDbContext().BulkInsertAsync<PriceList>(add.ToList());
var _first = _versionRepository.FirstOrDefault(p => p.Version == version);
@ -113,7 +128,7 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
public virtual async Task<PriceList> CreateAsync(PriceList input)
{
var entity = new PriceList(
GuidGenerator.Create(), input.BeginDate, input.EndDate, input.Price, input.MaterialCode, input.Type,input.ParentId,input.Version
GuidGenerator.Create(), input.BeginDate, input.EndDate, input.Price, input.MaterialCode, input.Type,input.ParentId,input.Version,input.CustomerCode
);
return await _repository.InsertAsync(entity);
@ -125,7 +140,7 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
{
var entity = await _repository.GetAsync(id);
entity.Set(
input.BeginDate, input.EndDate, input.Price, input.MaterialCode, input.Type
input.BeginDate, input.EndDate, input.Price, input.MaterialCode, input.Type,input.CustomerCode
);
return await _repository.UpdateAsync(entity);

Loading…
Cancel
Save