|
|
@ -37,6 +37,7 @@ public class DeliverRequestFisAppService : |
|
|
|
private readonly ITransactionTypeAppService _transactionTypeAppService; |
|
|
|
private readonly IBalanceAppService _balanceAppService; |
|
|
|
private readonly IItemBasicAppService _itemBasicAppService; |
|
|
|
private readonly ICustomerItemAppService _customerItemAppService; |
|
|
|
|
|
|
|
private readonly ISalePriceSheetAppService _salePriceSheetAppService; |
|
|
|
|
|
|
@ -49,8 +50,8 @@ public class DeliverRequestFisAppService : |
|
|
|
ITransactionTypeAppService transactionTypeAppService, |
|
|
|
IBalanceAppService balanceAppService, |
|
|
|
IItemBasicAppService itemBasicAppService, |
|
|
|
ISalePriceSheetAppService salePriceSheetAppService |
|
|
|
|
|
|
|
ISalePriceSheetAppService salePriceSheetAppService, |
|
|
|
ICustomerItemAppService customerItemAppService |
|
|
|
|
|
|
|
) |
|
|
|
: base(repository, deliverRequestManager) |
|
|
@ -63,6 +64,7 @@ public class DeliverRequestFisAppService : |
|
|
|
_balanceAppService = balanceAppService; |
|
|
|
_itemBasicAppService = itemBasicAppService; |
|
|
|
_salePriceSheetAppService = salePriceSheetAppService; |
|
|
|
_customerItemAppService= customerItemAppService; |
|
|
|
} |
|
|
|
/// <summary>
|
|
|
|
/// 删除
|
|
|
@ -113,11 +115,6 @@ public class DeliverRequestFisAppService : |
|
|
|
await SetRequestAutoPropertiesAsync(itemTransformRequest).ConfigureAwait(false); |
|
|
|
foreach (var detail in itemTransformRequest.Details) |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
//_salePriceSheetAppService.GetByItemCodeAndCustomerCode(detail.ItemCode,itemTransformRequest.CustomerCode)
|
|
|
|
|
|
|
|
|
|
|
|
var itemBasicDto = await _itemBasicAppService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false); |
|
|
|
CheckItemBasic(itemBasicDto, detail.ItemCode); |
|
|
|
|
|
|
@ -146,11 +143,20 @@ public class DeliverRequestFisAppService : |
|
|
|
detail.ItemName = itemBasicDto.Name; |
|
|
|
detail.Uom = itemBasicDto.BasicUom; |
|
|
|
detail.StdPackQty=itemBasicDto.StdPackQty; |
|
|
|
|
|
|
|
// CheckPrice(detail);
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
var itemlist=itemTransformRequest.Details.Select(p => p.ItemCode).Distinct(); |
|
|
|
var customerCode = itemTransformRequest.CustomerCode; |
|
|
|
var errors=await CheckCustomerItem(itemlist.ToList(),customerCode).ConfigureAwait(false); |
|
|
|
if (errors.Count > 0) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"客户零件关系表中没有查到客户为{customerCode},零件号为{string.Join(",", errors.ToArray())}的零件关系"); |
|
|
|
} |
|
|
|
var priceErrors=await IsExistCustomerItemPrice(itemlist.ToList(), customerCode).ConfigureAwait(false); |
|
|
|
if (priceErrors.Count > 0) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"销售价格表中没有查到客户为{customerCode},零件号为{string.Join(",", priceErrors.ToArray())}的零件关系和价格"); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return dictionary; |
|
|
@ -173,12 +179,34 @@ public class DeliverRequestFisAppService : |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//private static void CheckPrice(DeliverRequestDetail detail
|
|
|
|
// )
|
|
|
|
//{
|
|
|
|
|
|
|
|
//}
|
|
|
|
private async Task<List<string>> CheckCustomerItem(List<string> partlist, string customerCode) |
|
|
|
{ |
|
|
|
List<string> errorlist = new List<string>(); |
|
|
|
foreach (var itm in partlist) |
|
|
|
{ |
|
|
|
var result = await _customerItemAppService.GetByCustomerAndItemAsync(itm, customerCode).ConfigureAwait(false); |
|
|
|
if (result == null) |
|
|
|
{ |
|
|
|
errorlist.Add(itm); |
|
|
|
} |
|
|
|
} |
|
|
|
return errorlist; |
|
|
|
} |
|
|
|
private async Task<List<string>> IsExistCustomerItemPrice(List<string> partlist, string customerCode) |
|
|
|
{ |
|
|
|
List<string> errorlist = new List<string>(); |
|
|
|
foreach (var itm in partlist) |
|
|
|
{ |
|
|
|
var result = await _salePriceSheetAppService.GetByItemCodeAndCustomerCode(itm, customerCode).ConfigureAwait(false); |
|
|
|
if (result == null) |
|
|
|
{ |
|
|
|
errorlist.Add(itm); |
|
|
|
} |
|
|
|
} |
|
|
|
return errorlist; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -248,6 +276,20 @@ public class DeliverRequestFisAppService : |
|
|
|
{ |
|
|
|
var entity = ObjectMapper.Map<DeliverRequestEditInput, DeliverRequest>(input); |
|
|
|
|
|
|
|
var itemlist = entity.Details.Select(p => p.ItemCode).Distinct(); |
|
|
|
var customerCode = entity.CustomerCode; |
|
|
|
var errors = await CheckCustomerItem(itemlist.ToList(), customerCode).ConfigureAwait(false); |
|
|
|
if (errors.Count > 0) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"客户零件关系表中没有查到客户为{customerCode},零件号为{string.Join(",", errors.ToArray())}的零件关系"); |
|
|
|
} |
|
|
|
var priceErrors = await IsExistCustomerItemPrice(itemlist.ToList(), customerCode).ConfigureAwait(false); |
|
|
|
if (priceErrors.Count > 0) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"销售价格表中没有查到客户为{customerCode},零件号为{string.Join(",", priceErrors.ToArray())}的零件关系和价格"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
await _deliverRequestManager.CreateAsync(entity).ConfigureAwait(false); |
|
|
|
|
|
|
|
var dto = ObjectMapper.Map<DeliverRequest, DeliverRequestDTO>(entity); |
|
|
|