立航 饭 2 weeks ago
parent
commit
26e4ee830c

+ 3 - 1
2.Data/SMP.Model/Finance/Finance_ServiceBillResolveApply.cs

@@ -15,11 +15,13 @@ namespace SMP.Model.Finance
         public int SolutionId { get; set; }
         public string BillFileUrl { get; set; }
         public ResolveStatus Status { get; set; }
-        public BillResolveApplyType Type{get;set;}
+        public BillResolveApplyType Type { get; set; }
         public string Message { get; set; }
         public DateTime? FinishTime { get; set; }
         public int ServiceProviderId { get; set; }
         public string BillTypeCode { get; set; }
         public string BatchFileName { get; set; }
+
+        public int? ItemTypeId { get; set; }
     }
 }

+ 1 - 0
2.Data/SMP.Model/Finance/Finance_ServiceBillResolveSolution.cs

@@ -13,5 +13,6 @@ namespace SMP.Model.Finance
         public bool Deleted { get; set; }
         public bool Enabled { get; set; }
         public string EndRowTags { get; set; }
+        public int? ItemTypeId { get; set; }
     }
 }

+ 4 - 4
3.Service/SMP.Service/ServiceBillResolve/Dto/ServiceBillResolveSolutionDto.cs

@@ -11,12 +11,12 @@ namespace SMP.Service.ServiceBillResolve.Dto
     public class ServiceBillResolveSolutionDto
     {
         public int Id { get; set; }
-       
+
         public string Name { get; set; }
         public string BillTypeCode { get; set; }
         public int ServiceProviderId { get; set; }
         public string? Description { get; set; }
-  
+
         public string? CreateUserName { get; set; }
         public DateTime? CreateTime { get; set; }
 
@@ -26,7 +26,7 @@ namespace SMP.Service.ServiceBillResolve.Dto
         public string? IncomeDataName { get; set; }
         public string? EndRowTags { get; set; }
         public bool Enabled { get; set; }
-
+        public int ItemTypeId { get; set; }
         public List<ServiceBillResolveSolutionRuleDto> Rules { get; set; }
     }
 
@@ -37,7 +37,7 @@ namespace SMP.Service.ServiceBillResolve.Dto
         public int SolutionId { get; set; }
         public string SheetPattern { get; set; }
         public string? DataName { get; set; }
-        public bool DataUseRegx { get;  set; }
+        public bool DataUseRegx { get; set; }
         public string? DataAddressPattern { get; set; }
 
         public string? NumberAddressPattern { get; set; }

+ 19 - 6
3.Service/SMP.Service/ServiceBillResolve/IServiceBillResolveService.cs

@@ -225,7 +225,8 @@ namespace SMP.Service.ServiceBillResolve
                 EndRowTags = dto.EndRowTags,
                 Description = dto.Description,
                 CreateTime = now,
-                Enabled = dto.Enabled
+                Enabled = dto.Enabled,
+                ItemTypeId = dto.ItemTypeId
             };
 
             var rules = dto.Rules.CopyList<Finance_ServiceBillResolveSolutionRule>().ToList();
@@ -496,7 +497,7 @@ namespace SMP.Service.ServiceBillResolve
             string billTypeCode = solution.BillTypeCode;
             ServiceBillResolveApplyResult result = new ServiceBillResolveApplyResult { Success = true };
 
-            Finance_ServiceBillResolveApply apply = CreateResolveSolutionApply(serviceProviderId, billTypeCode, solution.Id, rawFileUrl, billName, batchFileName, description);
+            Finance_ServiceBillResolveApply apply = CreateResolveSolutionApply(solution.ItemTypeId, serviceProviderId, billTypeCode, solution.Id, rawFileUrl, billName, batchFileName, description);
             long applyId = await _solutionApplyRepotitory.InsertAsync(apply);
             int applyId32 = (int)applyId;
             ServiceBillResolveParam resolveParam = CreateResolveParam(solution, billTime, financialTime, billFile, rules, sheetNames, endRowTags);
@@ -504,7 +505,8 @@ namespace SMP.Service.ServiceBillResolve
             List<ServiceBillResolveResult> resultResult = null;
             try
             {
-                resultResult = _serviceBillResolver.Resolve(resolveParam);
+                resultResult = _serviceBillResolver.
+                    Resolve(resolveParam);
             }
             catch (Exception ex)
             {
@@ -573,7 +575,6 @@ namespace SMP.Service.ServiceBillResolve
             var dataDivideRules = rules.Where(r => r.EnableDataDivide.HasValue && r.EnableDataDivide.Value == true);
             if (dataDivideRules?.Any() == true)
             {
-
                 var ruleIds = dataDivideRules.Select(r => r.Id).ToList();
                 var targetResults = resultEntities.Where(r => ruleIds.Contains(r.RuleId));
                 if (targetResults?.Any() == true)
@@ -616,6 +617,7 @@ namespace SMP.Service.ServiceBillResolve
 
         /// <summary>
         /// 补全SytemNo
+        /// 增加检验,未补全时,警告
         /// </summary>
         /// <param name="resultEntities"></param>
         private async Task FixSystemNo(IList<Finance_ServiceBillResolveResult> resultEntities)
@@ -631,6 +633,10 @@ namespace SMP.Service.ServiceBillResolve
                         Dictionary<string, OrderNumberInfo> numberPairs = await GetOrderSystemNoByTransferNumber(trackingNumbers.Distinct(), g.Key);
                         if (numberPairs?.Any() == true)
                         {
+                            if (numberPairs.Count != trackingNumbers.Count())
+                                throw new Exception("匹配到系统单号小于表格单号数量,请检查单号数据!");
+                            if (numberPairs.Any(x => string.IsNullOrEmpty(x.Value.OrderChannelUniqueId)))
+                                throw new Exception("有订单未匹配到下单渠道,请尝试同步最新的下单渠道");
                             foreach (var i in g)
                             {
                                 if (numberPairs.TryGetValue(i.Number, out OrderNumberInfo? info))
@@ -639,6 +645,12 @@ namespace SMP.Service.ServiceBillResolve
                                     i.OrderChannelUniqueId = info.OrderChannelUniqueId;
                                 }
                             }
+
+
+                        }
+                        else
+                        {
+                            throw new Exception("未匹配到系统单号,请检查数据与映射!");
                         }
                     }
                 }
@@ -756,7 +768,7 @@ namespace SMP.Service.ServiceBillResolve
             return resolveParam;
         }
 
-        private Finance_ServiceBillResolveApply CreateResolveSolutionApply(int serviceProviderId, string billTypeCode, int resolveSolutionId, string fileUrl, string billName, string batchFileName, string description)
+        private Finance_ServiceBillResolveApply CreateResolveSolutionApply(int? itemTypeId, int serviceProviderId, string billTypeCode, int resolveSolutionId, string fileUrl, string billName, string batchFileName, string description)
         {
             Finance_ServiceBillResolveApply apply = new Finance_ServiceBillResolveApply
             {
@@ -769,7 +781,8 @@ namespace SMP.Service.ServiceBillResolve
                 ServiceProviderId = serviceProviderId,
                 BillTypeCode = billTypeCode,
                 BatchFileName = batchFileName,
-                Type = BillResolveApplyType.自动解析
+                Type = BillResolveApplyType.自动解析,
+                ItemTypeId = itemTypeId
             };
             return apply;
         }

+ 1 - 0
3.Service/SMP.Service/ServiceBillResolve/ServiceBillResolver.cs

@@ -178,6 +178,7 @@ namespace SMP.Service.ServiceBillResolve
             ValidateResolveParam(param);
             IWorkbook workbook = WorkbookFactory.Create(param.File);
 
+
             List<ServiceBillResolveResult> resolveResults = new List<ServiceBillResolveResult>();
 
             bool bySpecifiedSheets = param.Sheets?.Any() == true;