|
|
|
@ -46,9 +46,11 @@ namespace Myshipping.Application
|
|
|
|
|
private readonly SqlSugarRepository<BookingCtn> _repCtn;
|
|
|
|
|
private readonly SqlSugarRepository<SysUser> _repUser;
|
|
|
|
|
private readonly SqlSugarRepository<SysTenant> _repTenant;
|
|
|
|
|
private readonly SqlSugarRepository<DjyCustomer> _djycustomer;
|
|
|
|
|
private readonly SqlSugarRepository<DjyCustomerContact> _djycustomercontact;
|
|
|
|
|
|
|
|
|
|
public DataSyncService(ILogger<BookingOrderService> logger, ISysCacheService cache, SqlSugarRepository<BookingOrder> rep, SqlSugarRepository<BookingCtn> repCtn,
|
|
|
|
|
SqlSugarRepository<SysUser> repUser, SqlSugarRepository<SysTenant> repTenant)
|
|
|
|
|
SqlSugarRepository<SysUser> repUser, SqlSugarRepository<SysTenant> repTenant, SqlSugarRepository<DjyCustomer> djycustomer, SqlSugarRepository<DjyCustomerContact> djycustomercontact)
|
|
|
|
|
{
|
|
|
|
|
this._logger = logger;
|
|
|
|
|
this._rep = rep;
|
|
|
|
@ -56,6 +58,8 @@ namespace Myshipping.Application
|
|
|
|
|
this._cache = cache;
|
|
|
|
|
this._repUser = repUser;
|
|
|
|
|
this._repTenant = repTenant;
|
|
|
|
|
this._djycustomer = djycustomer;
|
|
|
|
|
this._djycustomercontact = djycustomercontact;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -69,15 +73,34 @@ namespace Myshipping.Application
|
|
|
|
|
public async Task<long> SyncCustomer(DjyCustomerSyncDto model)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
if (string.IsNullOrWhiteSpace(model.CodeName)) {
|
|
|
|
|
throw Oops.Bah("请上传正确数据,Code未录入");
|
|
|
|
|
}
|
|
|
|
|
var m = await _djycustomer.Where(x => x.CodeName == model.CodeName).FirstAsync();
|
|
|
|
|
var entity = model.Adapt<DjyCustomer>();
|
|
|
|
|
if (m == null)
|
|
|
|
|
{
|
|
|
|
|
await _djycustomer.InsertAsync(entity);
|
|
|
|
|
foreach (var item in model.ContactList)
|
|
|
|
|
{
|
|
|
|
|
var contact = item.Adapt<DjyCustomerContact>();
|
|
|
|
|
contact.CustomerId = entity.Id;
|
|
|
|
|
await _djycustomercontact.InsertAsync(contact);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
entity.Id=m.Id;
|
|
|
|
|
await _djycustomer.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
|
|
|
|
await _djycustomercontact.DeleteAsync(x => x.CustomerId == entity.Id);
|
|
|
|
|
foreach (var item in model.ContactList)
|
|
|
|
|
{
|
|
|
|
|
var contact = item.Adapt<DjyCustomerContact>();
|
|
|
|
|
contact.CustomerId = entity.Id;
|
|
|
|
|
await _djycustomercontact.InsertAsync(contact);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return entity.Id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|