diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportService.cs index b2630910..b6e8f2a6 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportService.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportService.cs @@ -798,6 +798,62 @@ public partial class SeaExportService : ISeaExportService } } } + if (seaExport.CustomserId != 0) + { + var delCustomsers = contactLists.Where(x => x.BusinessType == BusinessType.OceanShippingExport && x.CustomerType == "custom" && x.CustomerId != seaExport.CustomserId).ToList(); + if (delCustomsers.Count > 0) + { + delList.AddRange(delCustomsers); + } + var defaultContact = sqlSugarScope.Queryable().Where(x => x.ClientId == seaExport.CustomserId && x.IsDefault == true).First(); + if (defaultContact.IsNotNull()) + { + if (!contactLists.Where(x => x.BusinessType == BusinessType.OceanShippingExport && x.CustomerType == "custom" && x.Name == defaultContact.Name).Any()) + { + addList.Add(new BusinessOrderContact() + { + BusinessId = seaExport.Id, + CustomerId = (long)seaExport.CustomserId, + CustomerName = seaExport.CustomerName, + CustomerType = "custom", + CustomerTypeName = "报关行", + Name = defaultContact.Name, + Mobile = defaultContact.Mobile, + Tel = defaultContact.Tel, + Email = defaultContact.Email, + CustomerContactId = defaultContact.Id + }); + } + } + } + if (seaExport.AgentId != 0) + { + var delAgents = contactLists.Where(x => x.BusinessType == BusinessType.OceanShippingExport && x.CustomerType == "agent" && x.CustomerId != seaExport.CustomserId).ToList(); + if (delAgents.Count > 0) + { + delList.AddRange(delAgents); + } + var defaultContact = sqlSugarScope.Queryable().Where(x => x.ClientId == seaExport.AgentId && x.IsDefault == true).First(); + if (defaultContact.IsNotNull()) + { + if (!contactLists.Where(x => x.BusinessType == BusinessType.OceanShippingExport && x.CustomerType == "agent" && x.Name == defaultContact.Name).Any()) + { + addList.Add(new BusinessOrderContact() + { + BusinessId = seaExport.Id, + CustomerId = (long)seaExport.AgentId, + CustomerName = seaExport.Agent, + CustomerType = "agent", + CustomerTypeName = "国外代理", + Name = defaultContact.Name, + Mobile = defaultContact.Mobile, + Tel = defaultContact.Tel, + Email = defaultContact.Email, + CustomerContactId = defaultContact.Id + }); + } + } + } if (addList.Count > 0) sqlSugarScope.Insertable(addList).ExecuteCommand(); if (delList.Count > 0)