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 entity = model.Adapt<DjyCustomer>();
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();
@ -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();
}
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)
{
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,16 +266,12 @@ 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 (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();
@ -298,6 +290,9 @@ namespace Myshipping.Application
}
entity.PropString = entity.PropString.Replace("forwarder", "booking_agent");
if (m == null)
{
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,
@ -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)

@ -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