|
|
|
@ -10,6 +10,7 @@ using Myshipping.Application.Entity;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using Furion.FriendlyException;
|
|
|
|
|
using Myshipping.Core.Entity;
|
|
|
|
|
|
|
|
|
|
namespace Myshipping.Application
|
|
|
|
|
{
|
|
|
|
@ -20,11 +21,18 @@ namespace Myshipping.Application
|
|
|
|
|
public class BookingOrderContactService : IBookingOrderContactService, IDynamicApiController, ITransient
|
|
|
|
|
{
|
|
|
|
|
private readonly SqlSugarRepository<BookingOrderContact> _rep;
|
|
|
|
|
private readonly SqlSugarRepository<BookingOrder> _repOrder;
|
|
|
|
|
private readonly SqlSugarRepository<DjyCustomerContact> _repContact;
|
|
|
|
|
private readonly ILogger<BookingOrderContact> _logger;
|
|
|
|
|
|
|
|
|
|
public BookingOrderContactService(SqlSugarRepository<BookingOrderContact> rep, ILogger<BookingOrderContact> logger)
|
|
|
|
|
public BookingOrderContactService(SqlSugarRepository<BookingOrderContact> rep,
|
|
|
|
|
SqlSugarRepository<BookingOrder> repOrder,
|
|
|
|
|
SqlSugarRepository<DjyCustomerContact> repContact,
|
|
|
|
|
ILogger<BookingOrderContact> logger)
|
|
|
|
|
{
|
|
|
|
|
_rep = rep;
|
|
|
|
|
_repOrder = repOrder;
|
|
|
|
|
_repContact = repContact;
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -114,13 +122,29 @@ namespace Myshipping.Application
|
|
|
|
|
public async Task SaveBatch(List<UpdateBookingOrderContactInput> input, long bookingId)
|
|
|
|
|
{
|
|
|
|
|
_rep.Delete(x => x.BookingId == bookingId);
|
|
|
|
|
if (input!=null&&input.Count>0) {
|
|
|
|
|
if (input != null && input.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in input)
|
|
|
|
|
{
|
|
|
|
|
await _rep.InsertAsync(item.Adapt<BookingOrderContact>());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//自动增加到该客户的联系人
|
|
|
|
|
var bookObj = _repOrder.FirstOrDefault(x => x.Id == bookingId);
|
|
|
|
|
if (bookObj.CUSTOMERID.HasValue && bookObj.CUSTOMERID.Value > 0)
|
|
|
|
|
{
|
|
|
|
|
var dbContacts = _repContact.Where(x => x.CustomerId == bookObj.CUSTOMERID.Value).ToList();
|
|
|
|
|
|
|
|
|
|
//不存在的,增加
|
|
|
|
|
foreach (var item in input.Where(x => dbContacts.Count(cc => cc.Name == x.Name) == 0))
|
|
|
|
|
{
|
|
|
|
|
var ct = item.Adapt<DjyCustomerContact>();
|
|
|
|
|
ct.CustomerId = bookObj.CUSTOMERID.Value;
|
|
|
|
|
await _repContact.InsertAsync(ct);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///// <summary>
|
|
|
|
|