From a613784c5e26b9f4b249630dcc4576c5684f9bff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B5=87=E6=96=87=E9=BE=99?= Date: Thu, 5 Sep 2024 13:56:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E7=A5=A8=E6=A8=A1=E6=9D=BF=E6=B8=B2?= =?UTF-8?q?=E6=9F=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Method/InvoiceTemplateService.cs | 14 +++--- .../Invoice/Dtos/InvoiceAPIRequest.cs | 34 ++++++++++++++ .../Invoice/Dtos/InvoiceIssuance.cs | 9 +--- ...oiceIssuanceResult.cs => InvoiceResult.cs} | 4 +- .../Invoice/Method/InvoiceIssuanceService.cs | 47 +++++++++++++++---- .../FolderProfile1.pubxml.user | 2 +- ds-wms-service/DS.WMS.FeeApi/appsettings.json | 2 +- 7 files changed, 87 insertions(+), 25 deletions(-) create mode 100644 ds-wms-service/DS.WMS.Core/Invoice/Dtos/InvoiceAPIRequest.cs rename ds-wms-service/DS.WMS.Core/Invoice/Dtos/{InvoiceIssuanceResult.cs => InvoiceResult.cs} (82%) diff --git a/ds-wms-service/DS.WMS.Core/Application/Method/InvoiceTemplateService.cs b/ds-wms-service/DS.WMS.Core/Application/Method/InvoiceTemplateService.cs index a81f8018..0b09ab01 100644 --- a/ds-wms-service/DS.WMS.Core/Application/Method/InvoiceTemplateService.cs +++ b/ds-wms-service/DS.WMS.Core/Application/Method/InvoiceTemplateService.cs @@ -104,7 +104,7 @@ namespace DS.WMS.Core.Application.Method foreach (var field in fields) { //循环输出 - if (templateText.Contains($"<{field.FieldName}>")) + if (templateText.Contains($"<{field.DisplayName}>")) { foreach (var item in jArray) { @@ -115,12 +115,12 @@ namespace DS.WMS.Core.Application.Method if (sb2.Length > 0) { sb2.Remove(sb2.Length - 1, 1); //移除最后一个空格 - sb = sb.Replace($"<{field.FieldName}>", sb2.ToString()); + sb = sb.Replace($"<{field.DisplayName}>", sb2.ToString()); sb2.Clear(); } } //单次输出 - else if (templateText.Contains($"[{field.FieldName}]")) + else if (templateText.Contains($"[{field.DisplayName}]")) { string val = string.Empty; if (field.IsSumValue) @@ -134,7 +134,7 @@ namespace DS.WMS.Core.Application.Method } if (!val.IsNullOrEmpty()) - sb = sb.Replace($"[{field.FieldName}]", val); + sb = sb.Replace($"[{field.DisplayName}]", val); } } @@ -170,13 +170,15 @@ namespace DS.WMS.Core.Application.Method OriginalAmount = d.OriginalAmount, OriginalCurrency = d.OriginalCurrency, OriginalRate = f.ExchangeRate, - ExchangeRate = d.ExchangeRate + ExchangeRate = d.ExchangeRate, + BusinessId = f.BusinessId, + BusinessType = f.BusinessType, }).ToListAsync(); var gList = dto.Details.GroupBy(x => x.BusinessType).ToList(); foreach (var g in gList) { - var ids = g.Select(x => x.BusinessId).ToList(); + var ids = g.Select(x => x.BusinessId).Distinct(); switch (g.Key) { case BusinessType.OceanShippingExport: diff --git a/ds-wms-service/DS.WMS.Core/Invoice/Dtos/InvoiceAPIRequest.cs b/ds-wms-service/DS.WMS.Core/Invoice/Dtos/InvoiceAPIRequest.cs new file mode 100644 index 00000000..866200b1 --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Invoice/Dtos/InvoiceAPIRequest.cs @@ -0,0 +1,34 @@ +namespace DS.WMS.Core.Invoice.Dtos +{ + /// + /// 发票API请求实体 + /// + public class InvoiceAPIRequest + { + /// + /// 唯一标识,由企业自己生成32位随机码【消息体】 + /// + public string senid { get; set; } = Guid.NewGuid().ToString("N"); + } + + /// + /// 发票冲红请求 + /// + public class InvoiceReversalRequest : InvoiceAPIRequest + { + /// + /// 用户订单号 + /// + public string orderNo { get; set; } = string.Empty; + + /// + /// 冲红原因;01:开票有误,02:销货退回,03:服务中止,04:销售折让 + /// + public string chyyDm { get; set; } = "00"; + + /// + /// 录入方身份;0:销方,1:购方 + /// + public string lrfsf { get; set; } = "1"; + } +} diff --git a/ds-wms-service/DS.WMS.Core/Invoice/Dtos/InvoiceIssuance.cs b/ds-wms-service/DS.WMS.Core/Invoice/Dtos/InvoiceIssuance.cs index 83d2903c..e7d49efd 100644 --- a/ds-wms-service/DS.WMS.Core/Invoice/Dtos/InvoiceIssuance.cs +++ b/ds-wms-service/DS.WMS.Core/Invoice/Dtos/InvoiceIssuance.cs @@ -3,13 +3,8 @@ /// /// 开票请求 /// - public class InvoiceIssuanceRequest + public class InvoiceIssuanceRequest : InvoiceAPIRequest { - /// - /// 唯一标识,由企业自己生成32位随机码【消息体】 - /// - public string senid { get; set; } = Guid.NewGuid().ToString("N"); - /// /// 忽略商品和服务税收分类合并编码提醒 /// @@ -18,7 +13,7 @@ /// /// 请求体 /// - public List order { get; set; } + public List order { get; set; } = []; } diff --git a/ds-wms-service/DS.WMS.Core/Invoice/Dtos/InvoiceIssuanceResult.cs b/ds-wms-service/DS.WMS.Core/Invoice/Dtos/InvoiceResult.cs similarity index 82% rename from ds-wms-service/DS.WMS.Core/Invoice/Dtos/InvoiceIssuanceResult.cs rename to ds-wms-service/DS.WMS.Core/Invoice/Dtos/InvoiceResult.cs index d560bae5..4d920b0d 100644 --- a/ds-wms-service/DS.WMS.Core/Invoice/Dtos/InvoiceIssuanceResult.cs +++ b/ds-wms-service/DS.WMS.Core/Invoice/Dtos/InvoiceResult.cs @@ -2,7 +2,7 @@ namespace DS.WMS.Core.Invoice.Dtos { - public class InvoiceIssuanceResult + public class InvoiceResult { [DataMember(Name = "code")] public int Code { get; set; } @@ -17,7 +17,7 @@ namespace DS.WMS.Core.Invoice.Dtos public object Data { get; set; } } - public class InvoiceIssuanceResult : InvoiceIssuanceResult + public class InvoiceResult : InvoiceResult { [DataMember(Name = "data")] public new T Data { get; set; } diff --git a/ds-wms-service/DS.WMS.Core/Invoice/Method/InvoiceIssuanceService.cs b/ds-wms-service/DS.WMS.Core/Invoice/Method/InvoiceIssuanceService.cs index d9bb0c09..d1d42216 100644 --- a/ds-wms-service/DS.WMS.Core/Invoice/Method/InvoiceIssuanceService.cs +++ b/ds-wms-service/DS.WMS.Core/Invoice/Method/InvoiceIssuanceService.cs @@ -6,6 +6,8 @@ using DS.WMS.Core.Invoice.Dtos; using DS.WMS.Core.Sys.Entity; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Newtonsoft.Json.Linq; +using Org.BouncyCastle.Crypto; using SqlSugar; namespace DS.WMS.Core.Invoice.Method @@ -30,9 +32,9 @@ namespace DS.WMS.Core.Invoice.Method /// /// 发起开票请求 /// - /// 开票的发票ID + /// 发票ID /// - public async Task> InitiateAsync(params long[] ids) + public async Task> InitiateAsync(params long[] ids) { ArgumentNullException.ThrowIfNull(ids, nameof(ids)); @@ -44,7 +46,7 @@ namespace DS.WMS.Core.Invoice.Method }).FirstAsync(); if (string.IsNullOrEmpty(userInfo.IdCardNo)) - return DataResult.FailedWithDesc(MultiLanguageConst.DrawerIDNumberIsNull); + return DataResult.FailedWithDesc(MultiLanguageConst.DrawerIDNumberIsNull); //请求参数设置 InvoiceIssuanceRequest request = new() @@ -94,23 +96,52 @@ namespace DS.WMS.Core.Invoice.Method }; if (request.order.Count == 0 || request.order.Any(x => x.invoiceDetail.Count == 0)) - return DataResult.FailedWithDesc(MultiLanguageConst.InvoiceIncomplete); + return DataResult.FailedWithDesc(MultiLanguageConst.InvoiceIncomplete); - var result = await api.PostAsync>("/api/Invoice/services", request); + var result = await api.PostAsync>("/api/Invoice/services", request); if (!result.Succeeded) - return DataResult.Failed(result.Message, result.MultiCode); + return DataResult.Failed(result.Message, result.MultiCode); var invResult = result.Data; + JObject? jObj = JObject.Parse(invResult.Data); if (invResult.Success) { - return DataResult.Success(invResult.Data); + return DataResult.Success(jObj); } else { if (invResult.Code == 1) return await InitiateAsync(ids); - return DataResult.Failed(invResult.Message); + return DataResult.FailedData(jObj, invResult.Message); + } + } + + /// + /// 发票冲红 + /// + /// 发票ID + /// + public async Task> ReverseAsync(long id) + { + var invoice = await TenantDb.Queryable().FirstAsync(x => x.Id == id); + if (invoice == null) + return DataResult.FailedWithDesc(MultiLanguageConst.EmptyData); + + var req = new InvoiceReversalRequest { orderNo = invoice.BillNO }; + var result = await api.PostAsync>("/api/Invoice/RedInvoicing", req); + if (!result.Succeeded) + return DataResult.Failed(result.Message, result.MultiCode); + + var invResult = result.Data; + JObject? jObj = JObject.Parse(invResult.Data); + if (invResult.Success) + { + return DataResult.Success(jObj); + } + else + { + return DataResult.FailedData(jObj, invResult.Message); } } diff --git a/ds-wms-service/DS.WMS.FeeApi/Properties/PublishProfiles/FolderProfile1.pubxml.user b/ds-wms-service/DS.WMS.FeeApi/Properties/PublishProfiles/FolderProfile1.pubxml.user index d4b9acf1..1618aaa3 100644 --- a/ds-wms-service/DS.WMS.FeeApi/Properties/PublishProfiles/FolderProfile1.pubxml.user +++ b/ds-wms-service/DS.WMS.FeeApi/Properties/PublishProfiles/FolderProfile1.pubxml.user @@ -5,7 +5,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. <_PublishTargetUrl>D:\Publish\DS8\FeeApi - True|2024-09-05T01:12:44.5610882Z||;True|2024-09-04T10:07:38.3707398+08:00||;True|2024-09-04T09:52:47.0574599+08:00||;True|2024-09-03T16:41:23.7516960+08:00||;True|2024-09-03T15:22:31.8718097+08:00||;True|2024-09-03T10:01:09.7656702+08:00||;False|2024-09-03T09:46:46.8956531+08:00||;True|2024-09-02T17:07:41.0268500+08:00||;True|2024-09-02T13:50:22.0203254+08:00||;True|2024-09-02T13:34:23.3441546+08:00||;True|2024-08-30T11:25:14.7431645+08:00||;True|2024-08-29T16:38:26.3491372+08:00||;True|2024-08-29T16:32:31.8580864+08:00||;False|2024-08-29T16:30:41.4763198+08:00||;True|2024-08-09T09:18:05.8484398+08:00||;True|2024-08-09T08:45:38.7858906+08:00||;True|2024-08-05T11:37:07.3133020+08:00||;True|2024-07-24T16:45:58.2272340+08:00||;True|2024-07-24T15:48:52.0128987+08:00||;True|2024-07-23T17:41:01.7494842+08:00||;True|2024-07-23T17:25:11.8773492+08:00||;True|2024-07-23T17:07:16.5460273+08:00||;True|2024-07-22T08:59:23.3235603+08:00||;True|2024-07-12T17:35:11.1225017+08:00||;True|2024-07-11T11:40:17.3581147+08:00||;True|2024-07-04T17:20:50.0175739+08:00||;True|2024-07-02T11:26:14.2092751+08:00||;True|2024-07-02T09:21:51.3513605+08:00||;True|2024-07-01T17:47:56.0407256+08:00||;True|2024-07-01T16:42:55.7374984+08:00||;True|2024-07-01T15:49:58.9266967+08:00||;True|2024-07-01T14:35:48.1117178+08:00||;True|2024-07-01T11:41:52.2969338+08:00||;True|2024-07-01T11:13:02.6561160+08:00||;True|2024-06-28T15:28:43.1470725+08:00||;True|2024-06-28T15:16:20.1999596+08:00||;True|2024-06-28T15:14:56.2534743+08:00||;True|2024-06-28T15:02:41.3033806+08:00||;True|2024-06-28T13:37:28.2462742+08:00||;True|2024-06-28T11:06:30.7400535+08:00||;True|2024-06-26T15:24:17.1939896+08:00||;True|2024-06-26T14:33:06.3530466+08:00||;True|2024-06-26T09:45:24.4055568+08:00||;True|2024-06-25T15:45:57.6052473+08:00||;True|2024-06-25T10:17:17.7408916+08:00||;False|2024-06-25T10:16:23.5639654+08:00||;False|2024-06-25T10:15:28.3857721+08:00||;False|2024-06-25T10:10:59.5536995+08:00||;False|2024-06-25T10:07:10.4050937+08:00||;True|2024-06-24T15:22:18.2672769+08:00||;True|2024-06-24T15:01:04.8153621+08:00||;False|2024-06-24T15:00:29.9618848+08:00||;True|2024-06-24T14:07:19.9401637+08:00||;False|2024-06-24T14:06:36.1250570+08:00||;True|2024-06-21T15:13:57.4273503+08:00||;True|2024-06-21T15:04:37.8218608+08:00||;True|2024-06-21T14:12:48.0266638+08:00||;True|2024-06-21T13:52:30.0950155+08:00||;True|2024-06-20T11:02:42.9508506+08:00||;True|2024-06-19T11:43:01.1899282+08:00||;True|2024-06-19T11:23:01.2938141+08:00||;True|2024-06-18T08:51:21.6222152+08:00||;True|2024-06-17T09:20:35.0804494+08:00||;True|2024-06-17T08:41:58.1319484+08:00||;True|2024-06-17T08:38:09.0137102+08:00||;True|2024-06-14T15:19:45.7395180+08:00||;True|2024-06-14T14:38:49.7094421+08:00||;True|2024-06-14T14:27:39.2815370+08:00||;True|2024-06-14T09:42:21.5397525+08:00||;True|2024-06-13T16:03:39.8475642+08:00||;True|2024-06-13T14:12:10.1725629+08:00||;True|2024-06-13T10:46:52.6971321+08:00||;True|2024-06-11T17:03:44.8328978+08:00||;True|2024-06-06T17:41:51.1810315+08:00||;True|2024-06-06T10:57:27.8273617+08:00||;True|2024-06-04T14:23:21.3742450+08:00||;True|2024-05-31T17:01:42.4717460+08:00||;True|2024-05-31T13:56:03.0734064+08:00||;True|2024-05-31T08:45:52.3549394+08:00||;True|2024-05-30T17:16:32.8907958+08:00||;True|2024-05-30T16:18:06.9957657+08:00||;True|2024-05-29T15:44:18.4051203+08:00||;True|2024-05-29T15:11:03.1518632+08:00||;True|2024-05-29T14:52:26.0823495+08:00||;True|2024-05-29T11:17:20.2245101+08:00||;True|2024-05-29T08:36:28.9569161+08:00||;True|2024-05-28T08:44:31.4427261+08:00||;False|2024-05-28T08:44:02.5254826+08:00||;True|2024-05-27T15:16:32.9413631+08:00||;True|2024-05-27T15:03:42.9803879+08:00||;True|2024-05-27T08:49:54.3933663+08:00||;True|2024-05-27T08:46:13.5862236+08:00||;True|2024-05-23T17:19:32.8154451+08:00||;True|2024-05-23T17:19:01.4587615+08:00||;True|2024-05-22T16:52:42.2166228+08:00||;True|2024-05-22T15:19:49.1773202+08:00||;True|2024-05-22T15:13:31.9485525+08:00||;True|2024-05-22T13:29:02.1355808+08:00||;True|2024-05-22T09:48:40.8753914+08:00||;True|2024-05-22T09:25:06.2068137+08:00||; + True|2024-09-05T02:21:34.6675149Z||;True|2024-09-05T09:12:44.5610882+08:00||;True|2024-09-04T10:07:38.3707398+08:00||;True|2024-09-04T09:52:47.0574599+08:00||;True|2024-09-03T16:41:23.7516960+08:00||;True|2024-09-03T15:22:31.8718097+08:00||;True|2024-09-03T10:01:09.7656702+08:00||;False|2024-09-03T09:46:46.8956531+08:00||;True|2024-09-02T17:07:41.0268500+08:00||;True|2024-09-02T13:50:22.0203254+08:00||;True|2024-09-02T13:34:23.3441546+08:00||;True|2024-08-30T11:25:14.7431645+08:00||;True|2024-08-29T16:38:26.3491372+08:00||;True|2024-08-29T16:32:31.8580864+08:00||;False|2024-08-29T16:30:41.4763198+08:00||;True|2024-08-09T09:18:05.8484398+08:00||;True|2024-08-09T08:45:38.7858906+08:00||;True|2024-08-05T11:37:07.3133020+08:00||;True|2024-07-24T16:45:58.2272340+08:00||;True|2024-07-24T15:48:52.0128987+08:00||;True|2024-07-23T17:41:01.7494842+08:00||;True|2024-07-23T17:25:11.8773492+08:00||;True|2024-07-23T17:07:16.5460273+08:00||;True|2024-07-22T08:59:23.3235603+08:00||;True|2024-07-12T17:35:11.1225017+08:00||;True|2024-07-11T11:40:17.3581147+08:00||;True|2024-07-04T17:20:50.0175739+08:00||;True|2024-07-02T11:26:14.2092751+08:00||;True|2024-07-02T09:21:51.3513605+08:00||;True|2024-07-01T17:47:56.0407256+08:00||;True|2024-07-01T16:42:55.7374984+08:00||;True|2024-07-01T15:49:58.9266967+08:00||;True|2024-07-01T14:35:48.1117178+08:00||;True|2024-07-01T11:41:52.2969338+08:00||;True|2024-07-01T11:13:02.6561160+08:00||;True|2024-06-28T15:28:43.1470725+08:00||;True|2024-06-28T15:16:20.1999596+08:00||;True|2024-06-28T15:14:56.2534743+08:00||;True|2024-06-28T15:02:41.3033806+08:00||;True|2024-06-28T13:37:28.2462742+08:00||;True|2024-06-28T11:06:30.7400535+08:00||;True|2024-06-26T15:24:17.1939896+08:00||;True|2024-06-26T14:33:06.3530466+08:00||;True|2024-06-26T09:45:24.4055568+08:00||;True|2024-06-25T15:45:57.6052473+08:00||;True|2024-06-25T10:17:17.7408916+08:00||;False|2024-06-25T10:16:23.5639654+08:00||;False|2024-06-25T10:15:28.3857721+08:00||;False|2024-06-25T10:10:59.5536995+08:00||;False|2024-06-25T10:07:10.4050937+08:00||;True|2024-06-24T15:22:18.2672769+08:00||;True|2024-06-24T15:01:04.8153621+08:00||;False|2024-06-24T15:00:29.9618848+08:00||;True|2024-06-24T14:07:19.9401637+08:00||;False|2024-06-24T14:06:36.1250570+08:00||;True|2024-06-21T15:13:57.4273503+08:00||;True|2024-06-21T15:04:37.8218608+08:00||;True|2024-06-21T14:12:48.0266638+08:00||;True|2024-06-21T13:52:30.0950155+08:00||;True|2024-06-20T11:02:42.9508506+08:00||;True|2024-06-19T11:43:01.1899282+08:00||;True|2024-06-19T11:23:01.2938141+08:00||;True|2024-06-18T08:51:21.6222152+08:00||;True|2024-06-17T09:20:35.0804494+08:00||;True|2024-06-17T08:41:58.1319484+08:00||;True|2024-06-17T08:38:09.0137102+08:00||;True|2024-06-14T15:19:45.7395180+08:00||;True|2024-06-14T14:38:49.7094421+08:00||;True|2024-06-14T14:27:39.2815370+08:00||;True|2024-06-14T09:42:21.5397525+08:00||;True|2024-06-13T16:03:39.8475642+08:00||;True|2024-06-13T14:12:10.1725629+08:00||;True|2024-06-13T10:46:52.6971321+08:00||;True|2024-06-11T17:03:44.8328978+08:00||;True|2024-06-06T17:41:51.1810315+08:00||;True|2024-06-06T10:57:27.8273617+08:00||;True|2024-06-04T14:23:21.3742450+08:00||;True|2024-05-31T17:01:42.4717460+08:00||;True|2024-05-31T13:56:03.0734064+08:00||;True|2024-05-31T08:45:52.3549394+08:00||;True|2024-05-30T17:16:32.8907958+08:00||;True|2024-05-30T16:18:06.9957657+08:00||;True|2024-05-29T15:44:18.4051203+08:00||;True|2024-05-29T15:11:03.1518632+08:00||;True|2024-05-29T14:52:26.0823495+08:00||;True|2024-05-29T11:17:20.2245101+08:00||;True|2024-05-29T08:36:28.9569161+08:00||;True|2024-05-28T08:44:31.4427261+08:00||;False|2024-05-28T08:44:02.5254826+08:00||;True|2024-05-27T15:16:32.9413631+08:00||;True|2024-05-27T15:03:42.9803879+08:00||;True|2024-05-27T08:49:54.3933663+08:00||;True|2024-05-27T08:46:13.5862236+08:00||;True|2024-05-23T17:19:32.8154451+08:00||;True|2024-05-23T17:19:01.4587615+08:00||;True|2024-05-22T16:52:42.2166228+08:00||;True|2024-05-22T15:19:49.1773202+08:00||;True|2024-05-22T15:13:31.9485525+08:00||;True|2024-05-22T13:29:02.1355808+08:00||;True|2024-05-22T09:48:40.8753914+08:00||; \ No newline at end of file diff --git a/ds-wms-service/DS.WMS.FeeApi/appsettings.json b/ds-wms-service/DS.WMS.FeeApi/appsettings.json index c7157ba1..31e85f5c 100644 --- a/ds-wms-service/DS.WMS.FeeApi/appsettings.json +++ b/ds-wms-service/DS.WMS.FeeApi/appsettings.json @@ -61,6 +61,6 @@ "InvoiceApi": { "UserKey": "", "UserSecret": "", - "BaseUrl": "http://rm-m5e06xxqpa68a68ry5o.mysql.rds.aliyuncs.com:26650" + "BaseUrl": "http://47.105.115.105:26650" } }