From d505d86cc0e7343891e23b974d2e66bbb430ce1c Mon Sep 17 00:00:00 2001 From: tdx Date: Tue, 25 Feb 2025 08:22:01 +0000 Subject: [PATCH] SVN r289 SVN-Revision: r289 --- 插件库/Lskj.PubInvoiceOut/FrmMain.cs | 60 +++++++++------------------- 1 file changed, 18 insertions(+), 42 deletions(-) diff --git a/插件库/Lskj.PubInvoiceOut/FrmMain.cs b/插件库/Lskj.PubInvoiceOut/FrmMain.cs index ff21be1..c9de3fc 100644 --- a/插件库/Lskj.PubInvoiceOut/FrmMain.cs +++ b/插件库/Lskj.PubInvoiceOut/FrmMain.cs @@ -112,17 +112,17 @@ namespace Lskj.PubInvoiceOut token = SqlHelper.ExecuteScalar("select invoiceToken from p_systemtab") + ""; } ResultModel makeModel = new ResultModel(); - if (MakeInvoice(makeModel, ref token) || makeModel.Message.Contains("开票中") || makeModel.Message.Contains("编号重复")|| makeModel.Message.Contains("编号重复") || makeModel.Message.Contains("手动重推") || makeModel.Message.Contains("开票完成")) + if (MakeInvoice(ref makeModel, ref token) || makeModel.Message.Contains("开票中") || makeModel.Message.Contains("编号重复") || makeModel.Message.Contains("编号重复") || makeModel.Message.Contains("手动重推") || makeModel.Message.Contains("开票完成")) { bool isMake = false; if (makeModel.Message.Contains("开票中") || makeModel.Message.Contains("编号重复") || makeModel.Message.Contains("手动重推")) { ResultModel refreshModel = new ResultModel(); - RefreshInvoiceResponse(refreshModel, ref token, true); + RefreshInvoiceResponse(ref refreshModel, ref token, true); if (refreshModel.State.Equals("22")) { ResultModel retryModel = new ResultModel(); - RetryInvoice(retryModel, ref token, true); + RetryInvoice(ref retryModel, ref token, true); if (retryModel.Code.Equals("9999")) { @@ -166,7 +166,7 @@ namespace Lskj.PubInvoiceOut while (true) { ResultModel refreshModel = new ResultModel(); - RefreshInvoiceResponse(refreshModel, ref token); + RefreshInvoiceResponse(ref refreshModel, ref token); if (refreshModel.Code.Equals("0000") && !refreshModel.State.Equals("2") && refreshModel.Message.Equals("获取成功") && refreshModel.Result.Contains("发票未生成")) { if (isMake) @@ -637,7 +637,7 @@ namespace Lskj.PubInvoiceOut /// 蓝字发票开具 /// /// - private bool MakeInvoice(ResultModel resultModel, ref string token, bool isNext = true) + private bool MakeInvoice(ref ResultModel resultModel, ref string token, bool isNext = true) { bool isLogin = false; try @@ -765,7 +765,7 @@ namespace Lskj.PubInvoiceOut if (isNext) { resultModel = new ResultModel(); - isLogin = MakeInvoice(resultModel, ref token, false); + isLogin = MakeInvoice(ref resultModel, ref token, false); } } } @@ -782,7 +782,7 @@ namespace Lskj.PubInvoiceOut } return isLogin; } - private bool RefreshInvoiceResponse(ResultModel resultModel, ref string token, bool isInvoice = false, bool isNext = true) + private bool RefreshInvoiceResponse(ref ResultModel resultModel, ref string token, bool isInvoice = false, bool isNext = true) { if (resultModel == null) { @@ -837,7 +837,12 @@ namespace Lskj.PubInvoiceOut resultModel.State = invoiceStatus; if (resultModel.Code.Equals("0000")) { - if (!invoiceStatus.Equals("0") && !invoiceStatus.Equals("4")) + if (invoiceStatus.Equals("20"))//正在开票中 + { + resultModel = new ResultModel(); + isLogin = RefreshInvoiceResponse(ref resultModel, ref token, isInvoice); + } + else if (!invoiceStatus.Equals("0") && !invoiceStatus.Equals("4")) { JObject resultObj = (JsonConvert.DeserializeObject(resultModel.JResult["result"] + "") as JArray)[0] as JObject; if (isInvoice) @@ -846,7 +851,7 @@ namespace Lskj.PubInvoiceOut this.InvoiceId = id; SqlHelper.ExecuteNonQuery(string.Format("update Acc_InvoiceMaintab set O_invoiceId = '{0}' where XMid = '{1}'", InvoiceId, PrimaryValue)); } - if (!invoiceStatus.Equals("22") && !invoiceStatus.Equals("24")) + if (invoiceStatus.Equals("2")) { isLogin = true; string invoiceNr = resultObj["invoiceNr"] + ""; @@ -882,7 +887,7 @@ namespace Lskj.PubInvoiceOut if (isNext) { resultModel = new ResultModel(); - isLogin = RefreshInvoiceResponse(resultModel, ref token, isInvoice, false); + isLogin = RefreshInvoiceResponse(ref resultModel, ref token, isInvoice, false); } } } @@ -906,7 +911,7 @@ namespace Lskj.PubInvoiceOut /// /// /// - private bool RetryInvoice(ResultModel resultModel, ref string token, bool isNext = true) + private bool RetryInvoice(ref ResultModel resultModel, ref string token, bool isNext = true) { if (resultModel == null) { @@ -961,7 +966,7 @@ namespace Lskj.PubInvoiceOut if (isNext) { resultModel = new ResultModel(); - isLogin = RetryInvoice(resultModel, ref token, false); + isLogin = RetryInvoice(ref resultModel, ref token, false); } } } @@ -1215,33 +1220,4 @@ namespace Lskj.PubInvoiceOut { isLogin = true; } - else if (resultModel.Code.Equals("500")) - { - resultModel.Message = resultJObject + ""; - isLogin = false; - } - else if (resultModel.Code.Equals("1006") && resultModel.Message.Contains("token已失效")) - { - token = GetToken(); - if (isNext) - { - resultModel = new ResultModel(); - isLogin = MakeRedBill(resultModel, ref token, false); - } - } - } - } - else - { - isLogin = false; - } - } - catch (Exception ex) - { - resultModel.Message = ex.Message; - isLogin = false; - } - return isLogin; - } - } -} + else if (resultMode \ No newline at end of file