SVN r1146

SVN-Revision: r1146
This commit is contained in:
tdx
2026-03-22 13:50:57 +00:00
parent 84bfbbb067
commit e28188af85
6 changed files with 719 additions and 55 deletions
+472 -18
View File
@@ -3,12 +3,14 @@ using Lskj.Control;
using Lskj.Control.BrowserSetting; using Lskj.Control.BrowserSetting;
using Lskj.Control.Model; using Lskj.Control.Model;
using Lskj.Core; using Lskj.Core;
using Lskj.Model;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Data; using System.Data;
using System.Data.SqlClient;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@@ -122,6 +124,7 @@ namespace Lskj.PubInvoiceOut
if (refreshModel.State.Equals("22")) if (refreshModel.State.Equals("22"))
{ {
ResultModel retryModel = new ResultModel(); ResultModel retryModel = new ResultModel();
//重开
RetryInvoice(ref retryModel, ref token, true); RetryInvoice(ref retryModel, ref token, true);
if (retryModel.Code.Equals("9999")) if (retryModel.Code.Equals("9999"))
@@ -284,28 +287,224 @@ namespace Lskj.PubInvoiceOut
/// </summary> /// </summary>
private void MainMakeRedInvoice() private void MainMakeRedInvoice()
{ {
WaitForm.ShowForm();
string token = string.Empty; string token = string.Empty;
if (AlterTable("p_systemtab", "invoiceToken", "varchar(1000)")) if (AlterTable("p_systemtab", "invoiceToken", "varchar(1000)"))
{ {
token = SqlHelper.ExecuteScalar("select invoiceToken from p_systemtab") + ""; token = SqlHelper.ExecuteScalar("select invoiceToken from p_systemtab") + "";
} }
ResultModel initializeRedModel = new ResultModel(); string hzinvoiceId = SqlHelper.ExecuteScalar($"select O_hzinvoiceId from Acc_InvoiceMaintab where XMid = '{PrimaryValue}'") + "";
if (InitializeRedConfirm(initializeRedModel, ref token)) if (string.IsNullOrEmpty(hzinvoiceId))
{ {
ResultModel saveRedModel = new ResultModel(); using (FrmSelectMsg frmSelectMsg = new FrmSelectMsg())
saveRedModel.Result = initializeRedModel.Result;
if (SaveRedConfirm(saveRedModel, ref token))
{ {
ResultModel makeRedModel = new ResultModel(); if (frmSelectMsg.ShowDialog() == DialogResult.OK)
makeRedModel.Result = saveRedModel.Result;
makeRedModel.JResult = saveRedModel.JResult;
if (MakeRedBill(makeRedModel, ref token))
{ {
if (frmSelectMsg.SelectModel == null)
{
MessageUtil.Show("未选择红冲原因");
return;
}
ResultModel saveModel = new ResultModel();
if (FlushRedInvoice(frmSelectMsg.SelectModel.ValueMember, ref saveModel, ref token))
{
hzinvoiceId = SqlHelper.ExecuteScalar($"select O_hzinvoiceId from Acc_InvoiceMaintab where XMid = '{PrimaryValue}'") + "";
if (!string.IsNullOrEmpty(hzinvoiceId))
{
MainMakeRedInvoice();
return;
}
}
else if (saveModel.Code.Equals("9999"))
{
if (saveModel.Code.Equals("9999") && (saveModel.Result.Contains("重新登录") || saveModel.Result.Contains("重新登入")))//如果需要验证码登录
{
WaitForm.HideForm();
FrmSendCode frmSendCode = new FrmSendCode();
frmSendCode.SendCodeCallback += (sender, e) =>
{
ResultModel sendModel = new ResultModel();
SendCode(sendModel, ref token);
e.Code = sendModel.Code;
e.Message = sendModel.Message;
};
frmSendCode.LoginCallback += (sender, e) =>
{
ResultModel sendModel = new ResultModel();
Login(sendModel, frmSendCode.SendCode, ref token);
if (sendModel.Code.Equals("0000"))
{
AgainSendCode = true;
}
e.Code = sendModel.Code;
e.Message = sendModel.Message;
};
DialogResult dialogResult = frmSendCode.ShowDialog();
if (dialogResult == DialogResult.OK)
{
WaitForm.ShowForm();
MainMakeRedInvoice();
return;
}
else
{
MessageUtil.Show("验证失败");
return;
}
}
else if (saveModel.Code.Equals("9999") && (saveModel.Result.Contains("重新认证") || saveModel.Result.Contains("认证")))//如果需要扫码
{
WaitForm.HideForm();
FrmQrCode frmQrCode = new FrmQrCode();
frmQrCode.OnAttestationCallback += (sender, e) =>
{
ResultModel sendModel = new ResultModel();
Attestation(sendModel, ref token);
e.Code = sendModel.Code;
e.Message = sendModel.Message;
e.Result = sendModel.Result;
};
frmQrCode.OnVerifyQrCodeCallback += (sender, e) =>
{
ResultModel sendModel = new ResultModel();
VerifyQrCode(sendModel, ref token);
if (sendModel.Code.Equals("0000") && sendModel.Result.Equals("2"))
{
AgainQrCode = true;
}
e.Code = sendModel.Code;
e.Message = sendModel.Message;
e.Result = sendModel.Result;
};
DialogResult dialogResult = frmQrCode.ShowDialog();
if (dialogResult == DialogResult.OK)
{
WaitForm.ShowForm();
MainMakeRedInvoice();
return;
}
else
{
MessageUtil.Show("验证失败");
return;
}
}
else
{
MessageUtil.Show(saveModel.Message);
return;
} }
} }
} }
} }
}
else
{
while (true)
{
ResultModel refreshModel = new ResultModel();
RefreshHZInvoiceResponse(hzinvoiceId, ref refreshModel, ref token);
if (refreshModel.Code.Equals("0000") && !refreshModel.State.Equals("2") && refreshModel.Message.Equals("获取成功") && refreshModel.Result.Contains("发票未生成"))
{
MessageUtil.Show("发票未生成");
return;
}
else if (refreshModel.Code.Equals("0000") && !refreshModel.State.Equals("2") && refreshModel.Message.Equals("获取成功") && (refreshModel.Result.Contains("重新登录") || refreshModel.Result.Contains("重新登入")))//如果需要验证码登录
{
WaitForm.HideForm();
FrmSendCode frmSendCode = new FrmSendCode();
frmSendCode.SendCodeCallback += (sender, e) =>
{
ResultModel sendModel = new ResultModel();
SendCode(sendModel, ref token);
e.Code = sendModel.Code;
e.Message = sendModel.Message;
};
frmSendCode.LoginCallback += (sender, e) =>
{
ResultModel sendModel = new ResultModel();
Login(sendModel, frmSendCode.SendCode, ref token);
if (sendModel.Code.Equals("0000"))
{
AgainSendCode = true;
}
e.Code = sendModel.Code;
e.Message = sendModel.Message;
};
DialogResult dialogResult = frmSendCode.ShowDialog();
if (dialogResult == DialogResult.OK)
{
MainMakeInvoice();
return;
}
else
{
MessageUtil.Show("验证失败");
return;
}
}
else if (refreshModel.Code.Equals("0000") && !refreshModel.State.Equals("2") && refreshModel.Message.Equals("获取成功") && (refreshModel.Result.Contains("重新认证") || refreshModel.Result.Contains("认证")))//如果需要扫码
{
WaitForm.HideForm();
FrmQrCode frmQrCode = new FrmQrCode();
frmQrCode.OnAttestationCallback += (sender, e) =>
{
ResultModel sendModel = new ResultModel();
Attestation(sendModel, ref token);
e.Code = sendModel.Code;
e.Message = sendModel.Message;
e.Result = sendModel.Result;
};
frmQrCode.OnVerifyQrCodeCallback += (sender, e) =>
{
ResultModel sendModel = new ResultModel();
VerifyQrCode(sendModel, ref token);
if (sendModel.Code.Equals("0000") && sendModel.Result.Equals("2"))
{
AgainQrCode = true;
}
e.Code = sendModel.Code;
e.Message = sendModel.Message;
e.Result = sendModel.Result;
};
DialogResult dialogResult = frmQrCode.ShowDialog();
if (dialogResult == DialogResult.OK)
{
WaitForm.ShowForm();
MainMakeInvoice();
return;
}
else
{
MessageUtil.Show("验证失败");
return;
}
}
else if (refreshModel.Code.Equals("0000") && !refreshModel.State.Equals("2") && refreshModel.Message.Equals("获取成功") && refreshModel.Result.Contains("errReason"))
{
string errReason = "";
try
{
JArray returnResult = (JArray)JsonConvert.DeserializeObject(refreshModel.Result);
errReason = returnResult[0]["errReason"] + "";
}
catch (Exception)
{
errReason = refreshModel.Result;
}
MessageUtil.Show(errReason);
return;
}
else
{
MessageUtil.Show(refreshModel.Message);
return;
}
System.Threading.Thread.Sleep(500);
}
}
WaitForm.HideForm();
}
/// <summary> /// <summary>
/// 修改表结构 /// 修改表结构
/// </summary> /// </summary>
@@ -904,6 +1103,180 @@ namespace Lskj.PubInvoiceOut
} }
return isLogin; return isLogin;
} }
private bool RefreshHZInvoiceResponse(string hzinvoiceId, ref ResultModel resultModel, ref string token, bool isNext = true)
{
WaitForm.ShowForm();
if (resultModel == null)
{
resultModel = new ResultModel();
}
bool isLogin = false;
try
{
if (string.IsNullOrEmpty(token) && AlterTable("p_systemtab", "invoiceToken", "varchar(1000)"))
{
token = SqlHelper.ExecuteScalar("select invoiceToken from p_systemtab") + "";
if (string.IsNullOrEmpty(token))
{
token = GetToken();
}
}
string url = "https://lqzs.kflmgzs.com/prod-api/aisinoOpenApi/aisino/outSide/refreshInvoiceResponse";
HttpTools.setting("application/json", null, null, HttpTools.Encode.UTF8);
Dictionary<string, string> headerDic = new Dictionary<string, string>();
headerDic.Add("token", token);
JObject pmsJObject = new JObject();
DataRow SourceRow = this.MainDataTab.Rows.Count > 0 ? this.MainDataTab.Rows[0] : null;
if (SourceRow != null)
{
pmsJObject.Add("taxNo", SourceRow.Table.Columns.Contains("taxNo") ? SourceRow["taxNo"] + "" : "");
pmsJObject.Add("username", SourceRow.Table.Columns.Contains("username") ? SourceRow["username"] + "" : "");
JObject reInvoiceVOObject = new JObject();
JArray invoiceIdsArray = new JArray();
invoiceIdsArray.Add(hzinvoiceId);
reInvoiceVOObject.Add("invoiceIds", invoiceIdsArray);
pmsJObject.Add("reInvoiceVO", reInvoiceVOObject);
HttpWebResponse webResponse = HttpTools.Post(url, JsonConvert.SerializeObject(pmsJObject), null, headerDic, HttpTools.Method.POST);
string result = new StreamReader(webResponse.GetResponseStream(), Encoding.UTF8).ReadToEnd();
if (webResponse != null && !string.IsNullOrEmpty(result))
{
JObject resultJObject = (JObject)JsonConvert.DeserializeObject(result);
resultModel.JResult = resultJObject;
resultModel.Code = resultJObject["code"] + "";
resultModel.Message = resultJObject["message"] + "";
resultModel.Result = resultJObject["result"] + "";
JArray returnResult = (JArray)JsonConvert.DeserializeObject(resultModel.Result);
string invoiceStatus = returnResult[0]["invoiceStatus"] + "";
resultModel.State = invoiceStatus;
if (resultModel.Code.Equals("0000"))
{
if (invoiceStatus.Equals("20"))//正在开票中
{
resultModel = new ResultModel();
isLogin = RefreshInvoiceResponse(ref resultModel, ref token);
}
else if (!invoiceStatus.Equals("0") && !invoiceStatus.Equals("4"))
{
JObject resultObj = (JsonConvert.DeserializeObject(resultModel.JResult["result"] + "") as JArray)[0] as JObject;
if (invoiceStatus.Equals("2"))
{
isLogin = true;
string lz_invoiceID = Safe(SourceRow.Table.Columns.Contains("invoiceId") ? SourceRow["invoiceId"] + "" : "");
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine($@"if exists(select lz_invoiceID from Acc_hzInvoicemaintab where lz_invoiceID = '{lz_invoiceID}')");
stringBuilder.AppendLine($@"begin delete from Acc_hzInvoicemaintab where lz_invoiceID = '{lz_invoiceID}' delete from Acc_hzInvoicelisttab where lz_invoiceID = '{lz_invoiceID}' end;");
string Safe(string s) => (s ?? "").Replace("'", "''");
// ===== 主表字段 =====
string createTime = Safe(resultObj["createTime"] + "");
string documentNo = Safe(resultObj["documentNo"] + "");
string errReason = Safe(resultObj["errReason"] + "");
string fplx = resultObj["fplx"] + "";
string ghfAddr = Safe(resultObj["ghfAddr"] + "");
string ghfNsrmc = Safe(resultObj["ghfNsrmc"] + "");
string ghfNsrsbh = Safe(resultObj["ghfNsrsbh"] + "");
string ghfType = resultObj["ghfType"] + "";
string hjje = resultObj["hjje"] + "";
string hjse = resultObj["hjse"] + "";
string invoiceDate = Safe(resultObj["invoiceDate"] + "");
string invoiceNr = Safe(resultObj["invoiceNr"] + "");
string issuer = Safe(resultObj["issuer"] + "");
string jshj = resultObj["jshj"] + "";
string kce = resultObj["kce"] + "";
string memo = Safe(resultObj["memo"] + "");
string refInvoiceNr = Safe(resultObj["refInvoiceNr"] + "");
string sellerAddrName = Safe(resultObj["sellerAddrName"] + "");
string sellerBankAccount = Safe(resultObj["sellerBankAccount"] + "");
string sellerNsrmc = Safe(resultObj["sellerNsrmc"] + "");
string sellerNsrsbh = Safe(resultObj["sellerNsrsbh"] + "");
string sellerTel = Safe(resultObj["sellerTel"] + "");
string sendStatus = resultObj["sendStatus"] + "";
string tsfs = resultObj["tsfs"] + "";
string id = Safe(resultObj["id"] + "");
stringBuilder.AppendLine($@"
INSERT INTO Acc_hzInvoicemaintab (createTime,documentNo,errReason,fplx,ghfAddr,ghfNsrmc,ghfNsrsbh,ghfType,hjje,hjse,invoiceDate,invoiceNr,invoiceStatus,issuer,jshj,kce,memo,refInvoiceNr,sellerAddrName,sellerBankAccount,sellerNsrmc,sellerNsrsbh,sellerTel,sendStatus,tsfs,id,lz_invoiceID)
VALUES
('{createTime}','{documentNo}','{errReason}',{fplx},'{ghfAddr}','{ghfNsrmc}','{ghfNsrsbh}',{ghfType},{hjje},{hjse},'{invoiceDate}','{invoiceNr}',{invoiceStatus},'{issuer}',{jshj},{kce},'{memo}','{refInvoiceNr}','{sellerAddrName}','{sellerBankAccount}','{sellerNsrmc}','{sellerNsrsbh}','{sellerTel}',{sendStatus},{tsfs},'{id}','{lz_invoiceID}');");
var items = (JArray)resultObj["vatOutInvoiceItems"];
foreach (var item in items)
{
string invoiceId = Safe(item["invoiceId"] + "");
string itemOrder = item["itemOrder"] + "";
string productName = Safe(item["productName"] + "");
string spec = Safe(item["spec"] + ""); // 如果 JSON 没有可以自定义字段
string unit = Safe(item["unit"] + "");
string quantity = item["quantity"] + "";
string price = item["price"] + "";
string incTaxPrice = item["incTaxPrice"] + "";
string amount = item["amount"] + "";
string incTaxAmount = item["incTaxAmount"] + "";
string taxAmount = item["taxAmount"] + "";
string taxRate = item["taxRate"] + "";
string taxPre = item["taxPre"] + "";
string sphxz = item["sphxz"] + "";
string ssflbm = Safe(item["ssflbm"] + "");
stringBuilder.AppendLine($@"
INSERT INTO Acc_hzInvoicelisttab (invoiceId,itemOrder,productName,spec,unit,quantity,price,incTaxPrice,amount,incTaxAmount,taxAmount,taxRate,taxPre,sphxz,ssflbm,lz_invoiceID)
VALUES
('{invoiceId}',{itemOrder},'{productName}','{spec}','{unit}',{quantity},{price},{incTaxPrice},{amount},{incTaxAmount},{taxAmount},{taxRate},{taxPre},{sphxz},'{ssflbm}','{lz_invoiceID}');");
}
SqlHelper.ExecuteNonQuery(stringBuilder.ToString());
// 定义参数列表
List<SqlParameter> list = new List<SqlParameter>
{
new SqlParameter("@invoiceId", SqlDbType.VarChar, 255),
new SqlParameter("@operid", SqlDbType.Int),
new SqlParameter("@msg", SqlDbType.VarChar, 1000) // 输出参数
};
list[0].Value = lz_invoiceID;
list[1].Value = ERPInfo.Instance.UserId;
list[2].Direction = ParameterDirection.Output;
SqlParameter[] cmdParams = list.ToArray();
SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, "p_hzfpbillcreate_pr", cmdParams);
string rtnmsg = cmdParams[2].Value + "";
if (!string.IsNullOrEmpty(rtnmsg))
{
MessageUtil.Show(rtnmsg);
}
}
}
else
{
isLogin = false;
}
}
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 = RefreshInvoiceResponse(ref resultModel, ref token, false);
}
}
}
}
else
{
isLogin = false;
}
}
catch (Exception ex)
{
resultModel.Message = ex.Message;
isLogin = false;
}
WaitForm.HideForm();
return isLogin;
}
/// <summary> /// <summary>
/// 重开发票 /// 重开发票
/// </summary> /// </summary>
@@ -984,7 +1357,7 @@ namespace Lskj.PubInvoiceOut
return isLogin; return isLogin;
} }
/// <summary> /// <summary>
/// 红字确认单初始化 /// 红字确认单初始化(已作废)
/// </summary> /// </summary>
/// <param name="resultModel"></param> /// <param name="resultModel"></param>
/// <param name="token"></param> /// <param name="token"></param>
@@ -1063,7 +1436,7 @@ namespace Lskj.PubInvoiceOut
/// <param name="token"></param> /// <param name="token"></param>
/// <param name="isNext"></param> /// <param name="isNext"></param>
/// <returns></returns> /// <returns></returns>
private bool SaveRedConfirm(ResultModel resultModel, ref string token, bool isNext = true) private bool SaveRedConfirm(ref ResultModel resultModel, ref string token, bool isNext = true)
{ {
bool isLogin = false; bool isLogin = false;
try try
@@ -1076,7 +1449,7 @@ namespace Lskj.PubInvoiceOut
token = GetToken(); token = GetToken();
} }
} }
string url = "https://lqzs.kflmgzs.com/prod-api/aisinoOpenApi/aisino/outSide/saveRedConfirm"; string url = "https://lqzs.kflmgzs.com/prod-api/aisinoOpenApi/aisino/outSide/saveRedConfirmV2";
HttpTools.setting("application/json", null, null, HttpTools.Encode.UTF8); HttpTools.setting("application/json", null, null, HttpTools.Encode.UTF8);
Dictionary<string, string> headerDic = new Dictionary<string, string>(); Dictionary<string, string> headerDic = new Dictionary<string, string>();
headerDic.Add("token", token); headerDic.Add("token", token);
@@ -1084,9 +1457,8 @@ namespace Lskj.PubInvoiceOut
DataRow SourceRow = this.MainDataTab.Rows.Count > 0 ? this.MainDataTab.Rows[0] : null; DataRow SourceRow = this.MainDataTab.Rows.Count > 0 ? this.MainDataTab.Rows[0] : null;
if (SourceRow != null) if (SourceRow != null)
{ {
pmsJObject.Add("url", SourceRow.Table.Columns.Contains("url") ? SourceRow["url"] + "" : "");
pmsJObject.Add("taxNo", SourceRow.Table.Columns.Contains("taxNo") ? SourceRow["taxNo"] + "" : ""); pmsJObject.Add("taxNo", SourceRow.Table.Columns.Contains("taxNo") ? SourceRow["taxNo"] + "" : "");
pmsJObject.Add("responseDec", resultModel.Result); pmsJObject.Add("createorId", SourceRow.Table.Columns.Contains("createorId") ? SourceRow["createorId"] + "" : "");
JObject vatoutRedConfirmJObject = new JObject(); JObject vatoutRedConfirmJObject = new JObject();
vatoutRedConfirmJObject.Add("invoiceId", InvoiceId); vatoutRedConfirmJObject.Add("invoiceId", InvoiceId);
vatoutRedConfirmJObject.Add("applySource", SourceRow.Table.Columns.Contains("applySource") ? SourceRow["applySource"] + "" : ""); vatoutRedConfirmJObject.Add("applySource", SourceRow.Table.Columns.Contains("applySource") ? SourceRow["applySource"] + "" : "");
@@ -1122,6 +1494,8 @@ namespace Lskj.PubInvoiceOut
itemJObject.Add("goodsCode", item.Table.Columns.Contains("goodsCode") ? item["goodsCode"] + "" : ""); itemJObject.Add("goodsCode", item.Table.Columns.Contains("goodsCode") ? item["goodsCode"] + "" : "");
itemJObject.Add("favouredPolicyFlag", item.Table.Columns.Contains("favouredPolicyFlag") ? item["favouredPolicyFlag"] + "" : ""); itemJObject.Add("favouredPolicyFlag", item.Table.Columns.Contains("favouredPolicyFlag") ? item["favouredPolicyFlag"] + "" : "");
itemJObject.Add("issuer", item.Table.Columns.Contains("issuer") ? item["issuer"] + "" : ""); itemJObject.Add("issuer", item.Table.Columns.Contains("issuer") ? item["issuer"] + "" : "");
itemJObject.Add("username", item.Table.Columns.Contains("username") ? item["username"] + "" : "");
itemJObject.Add("url", item.Table.Columns.Contains("url") ? item["url"] + "" : "");
vatoutRedConfirmItemsArray.Add(itemJObject); vatoutRedConfirmItemsArray.Add(itemJObject);
} }
pmsJObject.Add("vatoutRedConfirmItems", vatoutRedConfirmItemsArray); pmsJObject.Add("vatoutRedConfirmItems", vatoutRedConfirmItemsArray);
@@ -1136,6 +1510,8 @@ namespace Lskj.PubInvoiceOut
{ {
string billUuid = resultJObject["billUuid"] + ""; string billUuid = resultJObject["billUuid"] + "";
string billNo = resultJObject["billNo"] + ""; string billNo = resultJObject["billNo"] + "";
string billStatus = resultJObject["billStatus"] + "";
resultModel.State = billStatus;
resultModel.JResult = resultJObject; resultModel.JResult = resultJObject;
isLogin = true; isLogin = true;
} }
@@ -1150,7 +1526,7 @@ namespace Lskj.PubInvoiceOut
if (isNext) if (isNext)
{ {
resultModel = new ResultModel(); resultModel = new ResultModel();
isLogin = SaveRedConfirm(resultModel, ref token, false); isLogin = SaveRedConfirm(ref resultModel, ref token, false);
} }
} }
} }
@@ -1174,7 +1550,7 @@ namespace Lskj.PubInvoiceOut
/// <param name="token"></param> /// <param name="token"></param>
/// <param name="isNext"></param> /// <param name="isNext"></param>
/// <returns></returns> /// <returns></returns>
private bool MakeRedBill(ResultModel resultModel, ref string token, bool isNext = true) private bool MakeRedBill(ref ResultModel resultModel, ref string token, bool isNext = true)
{ {
bool isLogin = false; bool isLogin = false;
try try
@@ -1220,4 +1596,82 @@ namespace Lskj.PubInvoiceOut
{ {
isLogin = true; isLogin = true;
} }
else if (resultMode 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(ref resultModel, ref token, false);
}
}
}
}
else
{
isLogin = false;
}
}
catch (Exception ex)
{
resultModel.Message = ex.Message;
isLogin = false;
}
return isLogin;
}
/// <summary>
/// 快捷红冲
/// </summary>
/// <param name="resultModel"></param>
/// <param name="token"></param>
/// <param name="isNext"></param>
/// <returns></returns>
private bool FlushRedInvoice(string redReason, ref ResultModel resultModel, ref string token, bool isNext = true)
{
WaitForm.ShowForm();
bool isLogin = false;
try
{
if (string.IsNullOrEmpty(token) && AlterTable("p_systemtab", "invoiceToken", "varchar(1000)"))
{
token = SqlHelper.ExecuteScalar("select invoiceToken from p_systemtab") + "";
if (string.IsNullOrEmpty(token))
{
token = GetToken();
}
}
string url = "https://lqzs.kflmgzs.com/prod-api/aisinoOpenApi/aisino/outSide/flushRedInvoice";
HttpTools.setting("application/json", null, null, HttpTools.Encode.UTF8);
Dictionary<string, string> headerDic = new Dictionary<string, string>();
headerDic.Add("token", token);
JObject pmsJObject = new JObject();
DataRow SourceRow = this.MainDataTab.Rows.Count > 0 ? this.MainDataTab.Rows[0] : null;
if (SourceRow != null)
{
pmsJObject.Add("taxNo", SourceRow.Table.Columns.Contains("taxNo") ? SourceRow["taxNo"] + "" : "");
pmsJObject.Add("username", SourceRow.Table.Columns.Contains("username") ? SourceRow["username"] + "" : "");
pmsJObject.Add("invoiceId", SourceRow.Table.Columns.Contains("invoiceId") ? SourceRow["invoiceId"] + "" : "");
pmsJObject.Add("redReason", redReason);
//pmsJObject.Add("createorId", SourceRow.Table.Columns.Contains("createorId") ? SourceRow["createorId"] + "" : "");
HttpWebResponse webResponse = HttpTools.Post(url, JsonConvert.SerializeObject(pmsJObject), null, headerDic, HttpTools.Method.POST);
string result = new StreamReader(webResponse.GetResponseStream(), Encoding.UTF8).ReadToEnd();
if (webResponse != null && !string.IsNullOrEmpty(result))
{
JObject resultJObject = (JObject)JsonConvert.DeserializeObject(result);
resultModel.Code = resultJObject["code"] + "";
resultModel.Message = resultJObject["message"] + "";
resultModel.Result = resultJObject["message"] + "";
if (resultModel.Code.Equals("0000"))
{
InvoiceId = resultJObject["invoiceId"] + "";
SqlHelper.ExecuteNonQuery(string.Format("update Acc_InvoiceMaintab set O_hzinvoiceId = '{0}' where XMid = '{1}'", InvoiceId, PrimaryValue));
isLogin = true;
}
else if (resultModel.Code.Equals("500"))
{
+1 -35
View File
@@ -134,38 +134,4 @@ namespace Lskj.PubInvoiceOut
this.Close(); this.Close();
this.Dispose(); this.Dispose();
} }
return;
}
}
}
}
else
{
ShowTips(resultEventArgs.Message);
}
}
catch (Exception)
{
}
System.Threading.Thread.Sleep(5000);
}
});
thread.Start();
}
}
public void ShowTips(string msg)
{
if (this.InvokeRequired && this.IsHandleCreated)
{
this.Invoke(new Action(() =>
{
this.tipsLabel.Text = msg;
}));
}
else
{
this.tipsLabel.Text = msg;
}
}
}
}
+74
View File
@@ -0,0 +1,74 @@
namespace Lskj.PubInvoiceOut
{
partial class FrmSelectMsg
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.codeLabel = new System.Windows.Forms.Label();
this.txtEdit = new DevExpress.XtraEditors.ComboBoxEdit();
this.btnBillSave = new DevExpress.XtraEditors.SimpleButton();
((System.ComponentModel.ISupportInitialize)(this.txtEdit.Properties)).BeginInit();
this.SuspendLayout();
//
// codeLabel
//
this.codeLabel.AutoSize = true;
this.codeLabel.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.codeLabel.Location = new System.Drawing.Point(12, 21);
this.codeLabel.Name = "codeLabel";
this.codeLabel.Size = new System.Drawing.Size(68, 17);
this.codeLabel.TabIndex = 8;
this.codeLabel.Text = "红冲原因:";
//
// txtEdit
//
this.txtEdit.Location = new System.Drawing.Point(86, 19);
this.txtEdit.Name = "txtEdit";
this.txtEdit.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
this.txtEdit.Properties.DropDownRows = 8;
this.txtEdit.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
this.txtEdit.Size = new System.Drawing.Size(141, 20);
this.txtEdit.TabIndex = 11;
//
// btnBillSave
//
this.btnBillSave.AllowFocus = false;
this.btnBillSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnBillSave.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnBillSave.Appearance.Options.UseFont = true;
this.btnBillSave.Location = new System.Drawing.Point(242, 17);
this.btnBillSave.Name = "btnBillSave";
this.btnBillSave.Size = new System.Drawing.Size(67, 26);
this.btnBillSave.TabIndex = 22;
this.btnBillSave.Text = "确定";
this.btnBillSave.Click += new System.EventHandler(this.btnBillSave_Click);
//
// FrmSelectMsg
//
@@ -0,0 +1,31 @@
using Lskj.Control;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Lskj.PubInvoiceOut
{
public partial class FrmSelectMsg : BaseForm
{
public ComboBoxModel SelectModel
{
get
{
return (ComboBoxModel)txtEdit.SelectedItem;
}
}
public FrmSelectMsg()
{
InitializeComponent();
this.Load += FrmSelectMsg_Load;
}
private void FrmSelectMsg_Load(object sender, EventArgs e)
{
txtEdit.Properties.Items.Add(new ComboBoxModel() { ValueMember = "1", DisplayMember = "销货退回" });
tx
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -37,6 +37,7 @@
<StartupObject /> <StartupObject />
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="DevExpress.Data.v15.2, Version=15.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
<Reference Include="DevExpress.Utils.v15.2, Version=15.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" /> <Reference Include="DevExpress.Utils.v15.2, Version=15.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
<Reference Include="DevExpress.XtraEditors.v15.2, Version=15.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" /> <Reference Include="DevExpress.XtraEditors.v15.2, Version=15.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
@@ -54,8 +55,12 @@
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="zxing"> <Reference Include="zxing, Version=0.14.0.0, Culture=neutral, PublicKeyToken=4e88037ac681fe60, processorArchitecture=MSIL">
<HintPath>..\..\Debug\zxing.dll</HintPath> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\引用DLL\zxing.dll</HintPath>
</Reference>
<Reference Include="zxing.presentation">
<HintPath>..\..\引用DLL\zxing.presentation.dll</HintPath>
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@@ -72,6 +77,12 @@
<Compile Include="FrmQrCode.Designer.cs"> <Compile Include="FrmQrCode.Designer.cs">
<DependentUpon>FrmQrCode.cs</DependentUpon> <DependentUpon>FrmQrCode.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="FrmSelectMsg.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmSelectMsg.Designer.cs">
<DependentUpon>FrmSelectMsg.cs</DependentUpon>
</Compile>
<Compile Include="FrmSendCode.cs"> <Compile Include="FrmSendCode.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
@@ -87,9 +98,13 @@
<EmbeddedResource Include="FrmQrCode.resx"> <EmbeddedResource Include="FrmQrCode.resx">
<DependentUpon>FrmQrCode.cs</DependentUpon> <DependentUpon>FrmQrCode.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="FrmSelectMsg.resx">
<DependentUpon>FrmSelectMsg.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FrmSendCode.resx"> <EmbeddedResource Include="FrmSendCode.resx">
<DependentUpon>FrmSendCode.cs</DependentUpon> <DependentUpon>FrmSendCode.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Properties\licenses.licx" />
<EmbeddedResource Include="Properties\Resources.resx"> <EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
@@ -123,6 +138,10 @@
<Project>{2A1BE6AC-1077-491B-A754-C5822FE8121E}</Project> <Project>{2A1BE6AC-1077-491B-A754-C5822FE8121E}</Project>
<Name>Lskj.Core</Name> <Name>Lskj.Core</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\Lskj.Model\Lskj.Model.csproj">
<Project>{52BC40E0-C0C6-4F78-996B-CAE028D209CA}</Project>
<Name>Lskj.Model</Name>
</ProjectReference>
<ProjectReference Include="..\Lskj.Util\Lskj.Util.csproj"> <ProjectReference Include="..\Lskj.Util\Lskj.Util.csproj">
<Project>{A51BF642-6543-4DE3-8948-83F558B72BD4}</Project> <Project>{A51BF642-6543-4DE3-8948-83F558B72BD4}</Project>
<Name>Lskj.Util</Name> <Name>Lskj.Util</Name>