SVN r1146
SVN-Revision: r1146
This commit is contained in:
@@ -3,12 +3,14 @@ using Lskj.Control;
|
||||
using Lskj.Control.BrowserSetting;
|
||||
using Lskj.Control.Model;
|
||||
using Lskj.Core;
|
||||
using Lskj.Model;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -122,6 +124,7 @@ namespace Lskj.PubInvoiceOut
|
||||
if (refreshModel.State.Equals("22"))
|
||||
{
|
||||
ResultModel retryModel = new ResultModel();
|
||||
//重开
|
||||
RetryInvoice(ref retryModel, ref token, true);
|
||||
|
||||
if (retryModel.Code.Equals("9999"))
|
||||
@@ -284,27 +287,223 @@ namespace Lskj.PubInvoiceOut
|
||||
/// </summary>
|
||||
private void MainMakeRedInvoice()
|
||||
{
|
||||
WaitForm.ShowForm();
|
||||
string token = string.Empty;
|
||||
if (AlterTable("p_systemtab", "invoiceToken", "varchar(1000)"))
|
||||
{
|
||||
token = SqlHelper.ExecuteScalar("select invoiceToken from p_systemtab") + "";
|
||||
}
|
||||
ResultModel initializeRedModel = new ResultModel();
|
||||
if (InitializeRedConfirm(initializeRedModel, ref token))
|
||||
string hzinvoiceId = SqlHelper.ExecuteScalar($"select O_hzinvoiceId from Acc_InvoiceMaintab where XMid = '{PrimaryValue}'") + "";
|
||||
if (string.IsNullOrEmpty(hzinvoiceId))
|
||||
{
|
||||
ResultModel saveRedModel = new ResultModel();
|
||||
saveRedModel.Result = initializeRedModel.Result;
|
||||
if (SaveRedConfirm(saveRedModel, ref token))
|
||||
using (FrmSelectMsg frmSelectMsg = new FrmSelectMsg())
|
||||
{
|
||||
ResultModel makeRedModel = new ResultModel();
|
||||
makeRedModel.Result = saveRedModel.Result;
|
||||
makeRedModel.JResult = saveRedModel.JResult;
|
||||
if (MakeRedBill(makeRedModel, ref token))
|
||||
if (frmSelectMsg.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
|
||||
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>
|
||||
/// 修改表结构
|
||||
@@ -904,6 +1103,180 @@ namespace Lskj.PubInvoiceOut
|
||||
}
|
||||
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>
|
||||
@@ -984,7 +1357,7 @@ namespace Lskj.PubInvoiceOut
|
||||
return isLogin;
|
||||
}
|
||||
/// <summary>
|
||||
/// 红字确认单初始化
|
||||
/// 红字确认单初始化(已作废)
|
||||
/// </summary>
|
||||
/// <param name="resultModel"></param>
|
||||
/// <param name="token"></param>
|
||||
@@ -1063,7 +1436,7 @@ namespace Lskj.PubInvoiceOut
|
||||
/// <param name="token"></param>
|
||||
/// <param name="isNext"></param>
|
||||
/// <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;
|
||||
try
|
||||
@@ -1076,7 +1449,7 @@ namespace Lskj.PubInvoiceOut
|
||||
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);
|
||||
Dictionary<string, string> headerDic = new Dictionary<string, string>();
|
||||
headerDic.Add("token", token);
|
||||
@@ -1084,9 +1457,8 @@ namespace Lskj.PubInvoiceOut
|
||||
DataRow SourceRow = this.MainDataTab.Rows.Count > 0 ? this.MainDataTab.Rows[0] : 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("responseDec", resultModel.Result);
|
||||
pmsJObject.Add("createorId", SourceRow.Table.Columns.Contains("createorId") ? SourceRow["createorId"] + "" : "");
|
||||
JObject vatoutRedConfirmJObject = new JObject();
|
||||
vatoutRedConfirmJObject.Add("invoiceId", InvoiceId);
|
||||
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("favouredPolicyFlag", item.Table.Columns.Contains("favouredPolicyFlag") ? item["favouredPolicyFlag"] + "" : "");
|
||||
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);
|
||||
}
|
||||
pmsJObject.Add("vatoutRedConfirmItems", vatoutRedConfirmItemsArray);
|
||||
@@ -1136,6 +1510,8 @@ namespace Lskj.PubInvoiceOut
|
||||
{
|
||||
string billUuid = resultJObject["billUuid"] + "";
|
||||
string billNo = resultJObject["billNo"] + "";
|
||||
string billStatus = resultJObject["billStatus"] + "";
|
||||
resultModel.State = billStatus;
|
||||
resultModel.JResult = resultJObject;
|
||||
isLogin = true;
|
||||
}
|
||||
@@ -1150,7 +1526,7 @@ namespace Lskj.PubInvoiceOut
|
||||
if (isNext)
|
||||
{
|
||||
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="isNext"></param>
|
||||
/// <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;
|
||||
try
|
||||
@@ -1220,4 +1596,82 @@ namespace Lskj.PubInvoiceOut
|
||||
{
|
||||
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"))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user