optimize
wet 1 year ago
parent b771e93793
commit caa5468030

@ -128,26 +128,38 @@ namespace Myshipping.Application
}
var m = await _djycustomer.AsQueryable().Filter(null, true).Where(x => x.ShortName == model.ShortName && x.IsDeleted == false && x.TenantId == UserManager.TENANT_ID).FirstAsync();
var entity = model.Adapt<DjyCustomer>();
if (!string.IsNullOrEmpty(entity.SALE))
{
entity.SALEID = userlist.Where(x => x.Name == entity.SALE).Count() == 0 ? "" : userlist.Where(x => x.Name == entity.SALE).Select(x => x.Id).FirstOrDefault().ToString();
}
if (!string.IsNullOrEmpty(entity.OP))
{
entity.OPID = userlist.Where(x => x.Name == entity.OP).Count() == 0 ? "" : userlist.Where(x => x.Name == entity.OP).Select(x => x.Id).FirstOrDefault().ToString();
}
if (!string.IsNullOrEmpty(entity.DOC))
{
entity.DOCID = userlist.Where(x => x.Name == entity.DOC).Count() == 0 ? "" : userlist.Where(x => x.Name == entity.DOC).Select(x => x.Id).FirstOrDefault().ToString();
}
if (!string.IsNullOrEmpty(entity.CUSTSERVICE))
{
entity.CUSTSERVICEID = userlist.Where(x => x.Name == entity.CUSTSERVICE).Count() == 0 ? "" : userlist.Where(x => x.Name == entity.CUSTSERVICE).Select(x => x.Id).FirstOrDefault().ToString();
}
if (entity.Level=="R3"&& !string.IsNullOrEmpty(entity.CUSTSERVICE)) {
throw Oops.Bah("等级为R3客服为空");
}
if ((entity.Level == "R1"|| entity.Level == "R2") && string.IsNullOrEmpty(entity.CUSTSERVICE))
{
throw Oops.Bah("等级为R1/R2客服必填");
}
entity.PropString = entity.PropString.Replace("forwarder", "booking_agent");
if (m == null)
{
if (!string.IsNullOrEmpty(entity.SALE))
{
entity.SALEID = userlist.Where(x => x.Name == entity.SALE).Count() == 0 ? "" : userlist.Where(x => x.Name == entity.SALE).Select(x => x.Id).FirstOrDefault().ToString();
}
if (!string.IsNullOrEmpty(entity.OP))
{
entity.OPID = userlist.Where(x => x.Name == entity.OP).Count() == 0 ? "" : userlist.Where(x => x.Name == entity.OP).Select(x => x.Id).FirstOrDefault().ToString();
}
if (!string.IsNullOrEmpty(entity.DOC))
{
entity.DOCID = userlist.Where(x => x.Name == entity.DOC).Count() == 0 ? "" : userlist.Where(x => x.Name == entity.DOC).Select(x => x.Id).FirstOrDefault().ToString();
}
if (!string.IsNullOrEmpty(entity.CUSTSERVICE))
{
entity.CUSTSERVICEID = userlist.Where(x => x.Name == entity.CUSTSERVICE).Count() == 0 ? "" : userlist.Where(x => x.Name == entity.CUSTSERVICE).Select(x => x.Id).FirstOrDefault().ToString();
}
entity.PropString = entity.PropString.Replace("forwarder", "booking_agent");
entity.TenantId = UserManager.TENANT_ID;
await _djycustomer.InsertAsync(entity);
foreach (var item in model.ContactList)
@ -188,23 +200,7 @@ namespace Myshipping.Application
else
{
entity.Id = m.Id;
if (!string.IsNullOrEmpty(entity.SALE))
{
entity.SALEID = userlist.Where(x => x.Name == entity.SALE).Count() == 0 ? "" : userlist.Where(x => x.Name == entity.SALE).Select(x => x.Id).FirstOrDefault().ToString();
}
if (!string.IsNullOrEmpty(entity.OP))
{
entity.OPID = userlist.Where(x => x.Name == entity.OP).Count() == 0 ? "" : userlist.Where(x => x.Name == entity.OP).Select(x => x.Id).FirstOrDefault().ToString();
}
if (!string.IsNullOrEmpty(entity.DOC))
{
entity.DOCID = userlist.Where(x => x.Name == entity.DOC).Count() == 0 ? "" : userlist.Where(x => x.Name == entity.DOC).Select(x => x.Id).FirstOrDefault().ToString();
}
if (!string.IsNullOrEmpty(entity.CUSTSERVICE))
{
entity.CUSTSERVICEID = userlist.Where(x => x.Name == entity.CUSTSERVICE).Count() == 0 ? "" : userlist.Where(x => x.Name == entity.CUSTSERVICE).Select(x => x.Id).FirstOrDefault().ToString();
}
entity.PropString = entity.PropString.Replace("forwarder", "booking_agent");
await _djycustomer.AsUpdateable(entity).IgnoreColumns(it => new
@ -270,34 +266,33 @@ namespace Myshipping.Application
var shiplist = await _codeForwarder.AsQueryable().ToListAsync();
foreach (var item in model)
{
if (string.IsNullOrWhiteSpace(item.ShortName))
{
throw Oops.Bah("简称未录入");
}
var m = mlist.Where(x => x.ShortName == item.ShortName).FirstOrDefault();
var entity = item.Adapt<DjyCustomer>();
if (!string.IsNullOrEmpty(entity.SALE))
{
entity.SALEID = userlist.Where(x => x.Name == entity.SALE).Count() == 0 ? "" : userlist.Where(x => x.Name == entity.SALE).Select(x => x.Id).FirstOrDefault().ToString();
}
if (!string.IsNullOrEmpty(entity.OP))
{
entity.OPID = userlist.Where(x => x.Name == entity.OP).Count() == 0 ? "" : userlist.Where(x => x.Name == entity.OP).Select(x => x.Id).FirstOrDefault().ToString();
}
if (!string.IsNullOrEmpty(entity.DOC))
{
entity.DOCID = userlist.Where(x => x.Name == entity.DOC).Count() == 0 ? "" : userlist.Where(x => x.Name == entity.DOC).Select(x => x.Id).FirstOrDefault().ToString();
}
if (!string.IsNullOrEmpty(entity.CUSTSERVICE))
{
entity.CUSTSERVICEID = userlist.Where(x => x.Name == entity.CUSTSERVICE).Count() == 0 ? "" : userlist.Where(x => x.Name == entity.CUSTSERVICE).Select(x => x.Id).FirstOrDefault().ToString();
}
entity.PropString = entity.PropString.Replace("forwarder", "booking_agent");
if (m == null)
{
if (!string.IsNullOrEmpty(entity.SALE))
{
entity.SALEID = userlist.Where(x => x.Name == entity.SALE).Count() == 0 ? "" : userlist.Where(x => x.Name == entity.SALE).Select(x => x.Id).FirstOrDefault().ToString();
}
if (!string.IsNullOrEmpty(entity.OP))
{
entity.OPID = userlist.Where(x => x.Name == entity.OP).Count() == 0 ? "" : userlist.Where(x => x.Name == entity.OP).Select(x => x.Id).FirstOrDefault().ToString();
}
if (!string.IsNullOrEmpty(entity.DOC))
{
entity.DOCID = userlist.Where(x => x.Name == entity.DOC).Count() == 0 ? "" : userlist.Where(x => x.Name == entity.DOC).Select(x => x.Id).FirstOrDefault().ToString();
}
if (!string.IsNullOrEmpty(entity.CUSTSERVICE))
{
entity.CUSTSERVICEID = userlist.Where(x => x.Name == entity.CUSTSERVICE).Count() == 0 ? "" : userlist.Where(x => x.Name == entity.CUSTSERVICE).Select(x => x.Id).FirstOrDefault().ToString();
}
entity.PropString = entity.PropString.Replace("forwarder", "booking_agent");
entity.TenantId = UserManager.TENANT_ID;
await _djycustomer.InsertAsync(entity);
foreach (var it in item.ContactList)
@ -342,23 +337,6 @@ namespace Myshipping.Application
else
{
entity.Id = m.Id;
if (!string.IsNullOrEmpty(entity.SALE))
{
entity.SALEID = userlist.Where(x => x.Name == entity.SALE).Count() == 0 ? "" : userlist.Where(x => x.Name == entity.SALE).Select(x => x.Id).FirstOrDefault().ToString();
}
if (!string.IsNullOrEmpty(entity.OP))
{
entity.OPID = userlist.Where(x => x.Name == entity.OP).Count() == 0 ? "" : userlist.Where(x => x.Name == entity.OP).Select(x => x.Id).FirstOrDefault().ToString();
}
if (!string.IsNullOrEmpty(entity.DOC))
{
entity.DOCID = userlist.Where(x => x.Name == entity.DOC).Count() == 0 ? "" : userlist.Where(x => x.Name == entity.DOC).Select(x => x.Id).FirstOrDefault().ToString();
}
if (!string.IsNullOrEmpty(entity.CUSTSERVICE))
{
entity.CUSTSERVICEID = userlist.Where(x => x.Name == entity.CUSTSERVICE).Count() == 0 ? "" : userlist.Where(x => x.Name == entity.CUSTSERVICE).Select(x => x.Id).FirstOrDefault().ToString();
}
entity.PropString = entity.PropString.Replace("forwarder", "booking_agent");
await _djycustomer.AsUpdateable(entity).IgnoreColumns(it => new
{
it.TenantId,
@ -429,8 +407,8 @@ namespace Myshipping.Application
{
var CreatedUserId= userlist.Where(x => x.Name == item.CreatedUserName).Select(x => x.Id).FirstOrDefault();
var CreatedUserId = userlist.Where(x => x.Name == item.CreatedUserName).Select(x => x.Id).FirstOrDefault();
if (string.IsNullOrWhiteSpace(item.BSNO))
{
throw Oops.Bah("BSNO未录入");
@ -473,7 +451,8 @@ namespace Myshipping.Application
else
{
entity.Id = m.Id;
if (m.ETD!=null) {
if (m.ETD != null)
{
entity.ETD = m.ETD;
}
if (m.ETD != null)
@ -502,15 +481,15 @@ namespace Myshipping.Application
foreach (var it in order)
{
//更新订舱船期
if (it.ETD != item.ETD && item.ETD!=null)
if (it.ETD != item.ETD && item.ETD != null)
{
it.ETD = item.ETD;
}
if (it.ATD != item.ATD&&item.ATD != null)
if (it.ATD != item.ATD && item.ATD != null)
{
it.ATD = item.ATD;
}
if (it.YgtETD != item.YgtETD&&item.YgtETD != null)
if (it.YgtETD != item.YgtETD && item.YgtETD != null)
{
it.YgtETD = item.YgtETD;
}
@ -546,7 +525,7 @@ namespace Myshipping.Application
CreatedTime = DateTime.Now,
CreatedUserId = CreatedUserId,
CreatedUserName = item.CreatedUserName
});
});
if (it.ETD != item.ETD)
{
await _bookinglogdetail.InsertReturnSnowflakeIdAsync(new BookingLogDetail
@ -2287,7 +2266,7 @@ namespace Myshipping.Application
public async Task<dynamic> GetSyncVesselDate()
{
var list = await _vesselinfo.AsQueryable().Filter(null, true).Where(x =>x.Sign==false&&x.ATD == null && x.TenantId == UserManager.TENANT_ID && (x.Voyno != null && x.Voyno != "")).Select(x => new
var list = await _vesselinfo.AsQueryable().Filter(null, true).Where(x => x.Sign == false && x.ATD == null && x.TenantId == UserManager.TENANT_ID && (x.Voyno != null && x.Voyno != "")).Select(x => new
{
Vessel = x.Vessel,
Voyno = x.Voyno,

@ -170,7 +170,10 @@ namespace Myshipping.Application
/// </summary>
public string TIDANINFO { get; set; }
/// <summary>
/// 等级
/// </summary>
public string Level { get; set; }
/// <summary>
/// 联系人
/// </summary>

@ -147,5 +147,10 @@ namespace Myshipping.Core.Entity
/// 服务项目
/// </summary>
public string ServiceItem { get; set; }
/// <summary>
/// 等级
/// </summary>
public string Level { get; set; }
}
}

@ -1919,6 +1919,11 @@
服务项目
</summary>
</member>
<member name="P:Myshipping.Core.Entity.DjyCustomer.Level">
<summary>
等级
</summary>
</member>
<member name="T:Myshipping.Core.Entity.DjyCustomerContact">
<summary>

@ -90,6 +90,18 @@ namespace Myshipping.Core.Service
}
var entity = input.Adapt<DjyCustomer>();
if (entity.Level == "R3" && !string.IsNullOrEmpty(entity.CUSTSERVICE))
{
throw Oops.Bah("等级为R3客服为空");
}
if ((entity.Level == "R1" || entity.Level == "R2") && string.IsNullOrEmpty(entity.CUSTSERVICE))
{
throw Oops.Bah("等级为R1/R2客服必填");
}
await _rep.InsertAsync(entity);
var contactList = input.Contacts.Adapt<List<DjyCustomerContact>>();
contactList.ForEach(x => x.CustomerId = entity.Id);
@ -119,6 +131,18 @@ namespace Myshipping.Core.Service
var entity = input.Adapt<DjyCustomer>();
if (entity.Level == "R3" && !string.IsNullOrEmpty(entity.CUSTSERVICE))
{
throw Oops.Bah("等级为R3客服为空");
}
if ((entity.Level == "R1" || entity.Level == "R2") && string.IsNullOrEmpty(entity.CUSTSERVICE))
{
throw Oops.Bah("等级为R1/R2客服必填");
}
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
await _repContact.DeleteAsync(x => x.CustomerId == input.Id);
var contactList = input.Contacts.Adapt<List<DjyCustomerContact>>();

Loading…
Cancel
Save