From e10a267bf2bfcc1b837ce90df3b40813c762f85e Mon Sep 17 00:00:00 2001 From: cjy Date: Wed, 10 Jul 2024 18:05:12 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=AF=B9=E8=B4=A6=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=8F=8A=E6=94=B6=E5=8F=91=E9=80=9A=E6=9C=AB=E7=8F=AD?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Check/Method/CheckBillAutoService.cs | 132 ++++++++++++++++-- .../Op/Dtos/ShippingBillTemplateReq.cs | 5 + .../Op/Dtos/ShippingBillTemplateRes.cs | 4 + .../Op/Dtos/ShippingBillTemplateSelectRes.cs | 4 + .../Entity/SeaExportShippingBillTemplate.cs | 6 +- 5 files changed, 140 insertions(+), 11 deletions(-) diff --git a/ds-wms-service/DS.WMS.Core/Check/Method/CheckBillAutoService.cs b/ds-wms-service/DS.WMS.Core/Check/Method/CheckBillAutoService.cs index 731d2165..a0e2073b 100644 --- a/ds-wms-service/DS.WMS.Core/Check/Method/CheckBillAutoService.cs +++ b/ds-wms-service/DS.WMS.Core/Check/Method/CheckBillAutoService.cs @@ -21,6 +21,8 @@ using NPOI.SS.Formula.Functions; using NPOI.Util; using Quartz.Logging; using DS.Module.Core.Data; +using System.Collections; +using LanguageExt.ClassInstances.Pred; namespace DS.WMS.Core.Check.Method { @@ -133,7 +135,7 @@ namespace DS.WMS.Core.Check.Method foreach (var item in req) { var mblno = item.提单号; - var bizList = tenantDb.Queryable().Where(x => x.CustomerId == info.CustomerId && x.MBLNO.Contains(mblno)).ToList(); + var bizList = tenantDb.Queryable().Where(x => x.MBLNO.Contains(mblno)).ToList(); if (bizList.Count > 1) { var mblnos = bizList.Select(x => x.MBLNO).Distinct(); @@ -336,28 +338,138 @@ namespace DS.WMS.Core.Check.Method /// /// 自动对账重新匹配 /// - /// 主表Ids + /// 主表Id /// public DataResult RecountCheckBillAuto(IdModel req) { var tenantDb = saasService.GetBizDbScopeById(user.TenantId); - if (req.Ids.Length == 0) - return DataResult.Failed("业务Ids不能为空"); - var billLists = tenantDb.Queryable().Where(x => req.Ids.Contains(x.Id)).ToList(); - if (billLists.Count > 0) + if (req.Id.IsNull()) + return DataResult.Failed("业务Id不能为空"); + var info = tenantDb.Queryable().Where(x => x.Id ==long.Parse(req.Id)).First(); + + if (info.IsNotNull()) { - foreach (var bill in billLists) + if (info.BillNo.IsNotNull()) { - - + return DataResult.Failed("存在已生成的对账信息!"); } + var list = tenantDb.Queryable().Where(x => x.CheckId == long.Parse(req.Id)).ToList(); + foreach (var bill in list) + { + var mblno = bill.MBLNO; + var usdAmount = 0M; + var rmbAmount = 0M; + var bizList = tenantDb.Queryable().Where(x => x.MBLNO.Contains(mblno)).ToList(); + var mblnos = bizList.Select(x => x.MBLNO).Distinct(); + foreach (var temp in mblnos) + { + var mblno1 = temp; + var bizlist1 = bizList.Where(x => x.MBLNO == mblno1).ToList(); + //var mainBiz = bizlist1[0]; + foreach (var biz in bizlist1) + { + var feeList = tenantDb.Queryable().Where(x => x.BusinessId == biz.BusinessId && x.CustomerId == info.CustomerId && x.FeeType == FeeType.Payable).ToList(); + foreach (var record in feeList) + { + if (record.Currency == "RMB") + { + rmbAmount += record.Amount; + } + if (record.Currency == "USD") + { + usdAmount += record.Amount; + } + } + } + } + bill.RMBLocalAmount = rmbAmount; + bill.USDLocalAmount = usdAmount; + bill.RMBDifferenceAmount = rmbAmount - bill.RMBCheckAmount; + bill.USDDifferenceAmount = usdAmount - bill.USDCheckAmount; + bill.IsEqual = (rmbAmount - bill.RMBCheckAmount == 0 && usdAmount - bill.USDCheckAmount == 0) ? true : false; + } + tenantDb.Updateable(list).ExecuteCommand(); + //更新主表 + if (list.Where(x => x.IsEqual == false).Any()) + { + info.CheckStatus = 2; + info.CheckStatusName = "对账不一致"; + } + else + { + info.CheckStatus = 1; + info.CheckStatusName = "对账一致"; + } + tenantDb.Updateable(info).ExecuteCommand(); } else { - return DataResult.Failed("无匹配的自动对账信息"); + return DataResult.Failed("自动对账主表信息不存在"); } + return DataResult.Successed("重新匹配成功!", MultiLanguageConst.DataUpdateSuccess); + } + + + /// + /// 生成对账单 + /// + /// 主表Id + /// + public DataResult CreateCheckBill(IdModel req) + { + var tenantDb = saasService.GetBizDbScopeById(user.TenantId); + + if (req.Id.IsNull()) + return DataResult.Failed("业务Id不能为空"); + var info = tenantDb.Queryable().Where(x => x.Id == long.Parse(req.Id)).First(); + if (info.IsNull()) + return DataResult.Failed("自动对账主表信息不存在"); + if (info.BillNo.IsNotNull()) + return DataResult.Failed("对账信息已生成!"); + + + + var list = tenantDb.Queryable().Where(x => x.CheckId == long.Parse(req.Id)).ToList(); + foreach (var bill in list) + { + var mblno = bill.MBLNO; + var usdAmount = 0M; + var rmbAmount = 0M; + var bizList = tenantDb.Queryable().Where(x => x.MBLNO.Contains(mblno)).ToList(); + var mblnos = bizList.Select(x => x.MBLNO).Distinct(); + foreach (var temp in mblnos) + { + var mblno1 = temp; + var bizlist1 = bizList.Where(x => x.MBLNO == mblno1).ToList(); + //var mainBiz = bizlist1[0]; + foreach (var biz in bizlist1) + { + var feeList = tenantDb.Queryable().Where(x => x.BusinessId == biz.BusinessId && x.CustomerId == info.CustomerId && x.FeeType == FeeType.Payable).ToList(); + foreach (var record in feeList) + { + if (record.Currency == "RMB") + { + rmbAmount += record.Amount; + } + if (record.Currency == "USD") + { + usdAmount += record.Amount; + } + } + } + } + bill.RMBLocalAmount = rmbAmount; + bill.USDLocalAmount = usdAmount; + bill.RMBDifferenceAmount = rmbAmount - bill.RMBCheckAmount; + bill.USDDifferenceAmount = usdAmount - bill.USDCheckAmount; + bill.IsEqual = (rmbAmount - bill.RMBCheckAmount == 0 && usdAmount - bill.USDCheckAmount == 0) ? true : false; + } + tenantDb.Updateable(list).ExecuteCommand(); ; + + + return DataResult.Successed("重新匹配成功!", MultiLanguageConst.DataUpdateSuccess); } } diff --git a/ds-wms-service/DS.WMS.Core/Op/Dtos/ShippingBillTemplateReq.cs b/ds-wms-service/DS.WMS.Core/Op/Dtos/ShippingBillTemplateReq.cs index 531d6b88..98b19834 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Dtos/ShippingBillTemplateReq.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Dtos/ShippingBillTemplateReq.cs @@ -1,4 +1,5 @@ using DS.Module.Core; +using SqlSugar; using System; using System.Collections.Generic; using System.Linq; @@ -42,6 +43,10 @@ namespace DS.WMS.Core.Op.Dtos /// public string Tel { get; set; } /// + /// 邮箱 + /// + public string Email { get; set; } + /// /// 类型 1 收 2 发 3 通 /// public string Type { get; set; } diff --git a/ds-wms-service/DS.WMS.Core/Op/Dtos/ShippingBillTemplateRes.cs b/ds-wms-service/DS.WMS.Core/Op/Dtos/ShippingBillTemplateRes.cs index d3b8af8d..144e45db 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Dtos/ShippingBillTemplateRes.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Dtos/ShippingBillTemplateRes.cs @@ -43,6 +43,10 @@ namespace DS.WMS.Core.Op.Dtos /// public string Tel { get; set; } /// + /// 邮箱 + /// + public string Email { get; set; } + /// /// 类型 1 收 2 发 3 通 /// public string Type { get; set; } diff --git a/ds-wms-service/DS.WMS.Core/Op/Dtos/ShippingBillTemplateSelectRes.cs b/ds-wms-service/DS.WMS.Core/Op/Dtos/ShippingBillTemplateSelectRes.cs index cdca8b68..5d5cb0c2 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Dtos/ShippingBillTemplateSelectRes.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Dtos/ShippingBillTemplateSelectRes.cs @@ -43,6 +43,10 @@ namespace DS.WMS.Core.Op.Dtos /// public string Tel { get; set; } /// + /// 邮箱 + /// + public string Email { get; set; } + /// /// 类型 1 收 2 发 3 通 /// public string Type { get; set; } diff --git a/ds-wms-service/DS.WMS.Core/Op/Entity/SeaExportShippingBillTemplate.cs b/ds-wms-service/DS.WMS.Core/Op/Entity/SeaExportShippingBillTemplate.cs index 3fc05e11..8112d210 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Entity/SeaExportShippingBillTemplate.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Entity/SeaExportShippingBillTemplate.cs @@ -45,7 +45,11 @@ namespace DS.WMS.Core.Op.Entity /// [SugarColumn(ColumnDescription = "电话", IsNullable = true, Length = 50)] public string Tel { get; set; } - + /// + /// 邮箱 + /// + [SugarColumn(ColumnDescription = "邮箱", IsNullable = true, Length = 100)] + public string Email { get; set; } /// /// 模板内容 ///