optimize
wet 1 year ago
parent b771e93793
commit caa5468030

@ -128,9 +128,6 @@ 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 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>(); var entity = model.Adapt<DjyCustomer>();
if (m == null)
{
if (!string.IsNullOrEmpty(entity.SALE)) 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(); entity.SALEID = userlist.Where(x => x.Name == entity.SALE).Count() == 0 ? "" : userlist.Where(x => x.Name == entity.SALE).Select(x => x.Id).FirstOrDefault().ToString();
@ -147,7 +144,22 @@ namespace Myshipping.Application
{ {
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.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"); entity.PropString = entity.PropString.Replace("forwarder", "booking_agent");
if (m == null)
{
entity.TenantId = UserManager.TENANT_ID; entity.TenantId = UserManager.TENANT_ID;
await _djycustomer.InsertAsync(entity); await _djycustomer.InsertAsync(entity);
foreach (var item in model.ContactList) foreach (var item in model.ContactList)
@ -188,23 +200,7 @@ namespace Myshipping.Application
else else
{ {
entity.Id = m.Id; 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 await _djycustomer.AsUpdateable(entity).IgnoreColumns(it => new
@ -270,16 +266,12 @@ namespace Myshipping.Application
var shiplist = await _codeForwarder.AsQueryable().ToListAsync(); var shiplist = await _codeForwarder.AsQueryable().ToListAsync();
foreach (var item in model) foreach (var item in model)
{ {
if (string.IsNullOrWhiteSpace(item.ShortName)) if (string.IsNullOrWhiteSpace(item.ShortName))
{ {
throw Oops.Bah("简称未录入"); throw Oops.Bah("简称未录入");
} }
var m = mlist.Where(x => x.ShortName == item.ShortName).FirstOrDefault(); var m = mlist.Where(x => x.ShortName == item.ShortName).FirstOrDefault();
var entity = item.Adapt<DjyCustomer>(); var entity = item.Adapt<DjyCustomer>();
if (m == null)
{
if (!string.IsNullOrEmpty(entity.SALE)) 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(); entity.SALEID = userlist.Where(x => x.Name == entity.SALE).Count() == 0 ? "" : userlist.Where(x => x.Name == entity.SALE).Select(x => x.Id).FirstOrDefault().ToString();
@ -298,6 +290,9 @@ namespace Myshipping.Application
} }
entity.PropString = entity.PropString.Replace("forwarder", "booking_agent"); entity.PropString = entity.PropString.Replace("forwarder", "booking_agent");
if (m == null)
{
entity.TenantId = UserManager.TENANT_ID; entity.TenantId = UserManager.TENANT_ID;
await _djycustomer.InsertAsync(entity); await _djycustomer.InsertAsync(entity);
foreach (var it in item.ContactList) foreach (var it in item.ContactList)
@ -342,23 +337,6 @@ namespace Myshipping.Application
else else
{ {
entity.Id = m.Id; 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 await _djycustomer.AsUpdateable(entity).IgnoreColumns(it => new
{ {
it.TenantId, it.TenantId,
@ -429,7 +407,7 @@ 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)) if (string.IsNullOrWhiteSpace(item.BSNO))
{ {
@ -473,7 +451,8 @@ namespace Myshipping.Application
else else
{ {
entity.Id = m.Id; entity.Id = m.Id;
if (m.ETD!=null) { if (m.ETD != null)
{
entity.ETD = m.ETD; entity.ETD = m.ETD;
} }
if (m.ETD != null) if (m.ETD != null)
@ -502,15 +481,15 @@ namespace Myshipping.Application
foreach (var it in order) 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; it.ETD = item.ETD;
} }
if (it.ATD != item.ATD&&item.ATD != null) if (it.ATD != item.ATD && item.ATD != null)
{ {
it.ATD = item.ATD; it.ATD = item.ATD;
} }
if (it.YgtETD != item.YgtETD&&item.YgtETD != null) if (it.YgtETD != item.YgtETD && item.YgtETD != null)
{ {
it.YgtETD = item.YgtETD; it.YgtETD = item.YgtETD;
} }
@ -2287,7 +2266,7 @@ namespace Myshipping.Application
public async Task<dynamic> GetSyncVesselDate() 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, Vessel = x.Vessel,
Voyno = x.Voyno, Voyno = x.Voyno,

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

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

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

@ -90,6 +90,18 @@ namespace Myshipping.Core.Service
} }
var entity = input.Adapt<DjyCustomer>(); 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); await _rep.InsertAsync(entity);
var contactList = input.Contacts.Adapt<List<DjyCustomerContact>>(); var contactList = input.Contacts.Adapt<List<DjyCustomerContact>>();
contactList.ForEach(x => x.CustomerId = entity.Id); contactList.ForEach(x => x.CustomerId = entity.Id);
@ -119,6 +131,18 @@ namespace Myshipping.Core.Service
var entity = input.Adapt<DjyCustomer>(); 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 _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
await _repContact.DeleteAsync(x => x.CustomerId == input.Id); await _repContact.DeleteAsync(x => x.CustomerId == input.Id);
var contactList = input.Contacts.Adapt<List<DjyCustomerContact>>(); var contactList = input.Contacts.Adapt<List<DjyCustomerContact>>();

Loading…
Cancel
Save