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 bed58390..1ee8d699 100644 --- a/ds-wms-service/DS.WMS.Core/Invoice/Method/InvoiceIssuanceService.cs +++ b/ds-wms-service/DS.WMS.Core/Invoice/Method/InvoiceIssuanceService.cs @@ -5,12 +5,17 @@ using DS.WMS.Core.Application.Method; using DS.WMS.Core.Code.Entity; using DS.WMS.Core.Invoice.Dtos; using DS.WMS.Core.Invoice.Interface; +using DS.WMS.Core.QuarztJobs.Dtos; +using DS.WMS.Core.QuarztJobs.Other; using DS.WMS.Core.Sys.Entity; using Masuit.Tools; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using Org.BouncyCastle.Ocsp; using SqlSugar; +using static AnyDiff.DifferenceLines; namespace DS.WMS.Core.Invoice.Method { @@ -19,7 +24,13 @@ namespace DS.WMS.Core.Invoice.Method /// public sealed class InvoiceIssuanceService : ApplicationServiceBase, IInvoiceIssuanceService { - readonly InvoiceApiFox api; + //readonly InvoiceApiFox api; + static readonly ApiFox api; + + static InvoiceIssuanceService() + { + api = new ApiFox(); + } /// /// 初始化并加载配置 @@ -28,7 +39,7 @@ namespace DS.WMS.Core.Invoice.Method public InvoiceIssuanceService(IServiceProvider provider) : base(provider) { var config = provider.GetRequiredService(); - api = new InvoiceApiFox(config); + } /// @@ -101,7 +112,22 @@ namespace DS.WMS.Core.Invoice.Method if (request.order.Count == 0 || request.order.Any(x => x.invoiceDetail.Count == 0)) return DataResult.FailedWithDesc(MultiLanguageConst.InvoiceIncomplete); - var result = await api.PostAsync>("/api/Invoice/services", request); + //var result = await api.PostAsync>("/api/Invoice/services", request); + + var order = await TenantDb.Queryable().Where(x => ids.Contains(x.Id)).FirstAsync(); + + var orgauthinfo = Db.Queryable().LeftJoin((t, a) => t.Id == a.OrgId) + .Where((t, a) => t.Id == order.SaleDeptId) + .Select((t, a) => new + { + a.Key, + a.Secret + }).First(); + api.DefaultHeaders.Add("USER_KEY", orgauthinfo.Key); + api.DefaultHeaders.Add("USER_SECRET", orgauthinfo.Secret); + + var result = await api.PostAsync>(AppSetting.app(new string[] { "InvoiceApi", "BaseUrl" }) + "/api/Invoice/services", request); + if (!result.Succeeded) return DataResult.Failed(result.Message, result.MultiCode); @@ -132,8 +158,20 @@ namespace DS.WMS.Core.Invoice.Method /// public async Task UpdateInvoiceNumberAsync(string sn) { + //var result = await api.PostAsync>("/api/Invoice/GetInvoiceState", new { guid = sn }); //调用查询API获取发票号 - var result = await api.PostAsync>("/api/Invoice/GetInvoiceState", new { guid = sn }); + var order = await TenantDb.Queryable().Where(x => x.SN == sn).FirstAsync(); + var orgauthinfo = Db.Queryable().LeftJoin((t, a) => t.Id == a.OrgId) + .Where((t, a) => t.Id == order.SaleDeptId) + .Select((t, a) => new + { + a.Key, + a.Secret + }).First(); + api.DefaultHeaders.Add("USER_KEY", orgauthinfo.Key); + api.DefaultHeaders.Add("USER_SECRET", orgauthinfo.Secret); + var result = await api.PostAsync>(AppSetting.app(new string[] { "InvoiceApi", "BaseUrl" }) + "/api/Invoice/GetInvoiceState", new { guid = sn }); + if (!result.Succeeded) return DataResult.Failed(result.Message, result.MultiCode); @@ -202,7 +240,13 @@ namespace DS.WMS.Core.Invoice.Method return DataResult.FailedWithDesc(MultiLanguageConst.EmptyData); var req = new InvoiceReversalRequest { orderNo = invoice.BillNO }; - var result = await api.PostAsync>("/api/Invoice/RedInvoicing", req); + // var result = await api.PostAsync>("/api/Invoice/RedInvoicing", req); + + var orgauthinfo = Db.Queryable().Where(t => t.Id == invoice.SaleDeptId).First(); + api.DefaultHeaders.Add("USER_KEY", orgauthinfo.Key); + api.DefaultHeaders.Add("USER_SECRET", orgauthinfo.Secret); + var result = await api.PostAsync>(AppSetting.app(new string[] { "InvoiceApi", "BaseUrl" }) + "/api/Invoice/RedInvoicing", req); + if (!result.Succeeded) return DataResult.Failed(result.Message, result.MultiCode); diff --git a/ds-wms-service/DS.WMS.Core/Invoice/Method/InvoiceService`1.cs b/ds-wms-service/DS.WMS.Core/Invoice/Method/InvoiceService`1.cs index bcd7fcde..250f4f56 100644 --- a/ds-wms-service/DS.WMS.Core/Invoice/Method/InvoiceService`1.cs +++ b/ds-wms-service/DS.WMS.Core/Invoice/Method/InvoiceService`1.cs @@ -450,7 +450,8 @@ namespace DS.WMS.Core.Invoice.Method } //补充销方信息 - var org = await Db.Queryable().Where(x => x.Id == User.OrgId).Select(x => new { x.OrgFullName, x.LicenseCode }).FirstAsync(); + //var org = await Db.Queryable().Where(x => x.Id == User.OrgId).Select(x => new { x.OrgFullName, x.LicenseCode }).FirstAsync(); + var org = await Db.Queryable().LeftJoin((t, a) => t.Id == a.OrgId).Where((t, a) => t.Id == invoice.SaleDeptId).Select((t, a) => new { t.OrgFullName, t.LicenseCode }).FirstAsync(); if (org != null) { invoice.OrgName = org.OrgFullName; diff --git a/ds-wms-service/DS.WMS.Core/Sys/Method/SysOrgAuthService.cs b/ds-wms-service/DS.WMS.Core/Sys/Method/SysOrgAuthService.cs index f54db76f..2912c44b 100644 --- a/ds-wms-service/DS.WMS.Core/Sys/Method/SysOrgAuthService.cs +++ b/ds-wms-service/DS.WMS.Core/Sys/Method/SysOrgAuthService.cs @@ -44,7 +44,7 @@ public class SysOrgAuthService: IOrgAuthService { //序列化查询条件 var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition); - var data = db.Queryable() + var data = db.Queryable() .Where(whereList) .Select().ToQueryPage(request.PageCondition); return data;