|
|
|
@ -1940,106 +1940,131 @@ namespace DSWeb.Areas.Account.Controllers
|
|
|
|
|
}
|
|
|
|
|
else if (head.INVITERFACE == "诺诺全电发票")
|
|
|
|
|
{
|
|
|
|
|
var hx = 诺诺全电发票.getHelper(head.TAXCODE, head.COMPANYID);
|
|
|
|
|
|
|
|
|
|
//20230529
|
|
|
|
|
//1 如果ch_fee_invoice.billuuid有值的话
|
|
|
|
|
//这个值是最近一次提交的红字确认单订单编码
|
|
|
|
|
//用这个值读取红字确认单状态 如成功则做红票相应的处理
|
|
|
|
|
//如状态15申请中 则不做操作返回申请中
|
|
|
|
|
//如非成功和15 则返回错误 并清空billuuid;
|
|
|
|
|
//2 如果ch_fee_invoice.billuuid无值 则重新产生值并发出红字确认单
|
|
|
|
|
|
|
|
|
|
//此时head.billUuid如果不为空 代表已有红字申请单
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(head.billUuid))//&&
|
|
|
|
|
var hx = 诺诺全电发票.getHelper(head.TAXCODE);
|
|
|
|
|
//20230608 如果ptorred=2
|
|
|
|
|
//代表这个head就是红票
|
|
|
|
|
if (head.PTORRED == "2")
|
|
|
|
|
{
|
|
|
|
|
redhead.BILLNO = redhead.billUuid;
|
|
|
|
|
redhead = AutoMapperHelper.MapTo<ChInvoice_HangXin, ChInvoice_HangXin>(head);
|
|
|
|
|
//redhead.REDNUM = head.INVOICENO;
|
|
|
|
|
|
|
|
|
|
result = hx.ReadInvoice(redhead);
|
|
|
|
|
|
|
|
|
|
var _r = hx.ReadRedConfirm(ref redhead, detailList);
|
|
|
|
|
|
|
|
|
|
if (!_r.Success)
|
|
|
|
|
if (!result.Success)
|
|
|
|
|
{
|
|
|
|
|
return BasicDataRefDAL.GetContentResult(_r);
|
|
|
|
|
return BasicDataRefDAL.GetContentResult(result);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ChinvoiceDAL.SetRed(redhead);
|
|
|
|
|
BlueInvoice = ChinvoiceDAL.GetData(" cm.INVOICECODE='" + head.REDCODE + "' and cm.INVOICENO='" + head.REDNUM + "'");
|
|
|
|
|
result = SetInvoiceFee(BlueInvoice);
|
|
|
|
|
|
|
|
|
|
return BasicDataRefDAL.GetContentResult(result);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
//var hx = 诺诺全电发票.getHelper(head.TAXCODE);
|
|
|
|
|
if (!hx.CanUse)
|
|
|
|
|
{
|
|
|
|
|
result.SetErrorInfo(hx.ERRORMSG);
|
|
|
|
|
//20230529
|
|
|
|
|
//1 如果ch_fee_invoice.billuuid有值的话
|
|
|
|
|
//这个值是最近一次提交的红字确认单订单编码
|
|
|
|
|
//用这个值读取红字确认单状态 如成功则做红票相应的处理
|
|
|
|
|
//如状态15申请中 则不做操作返回申请中
|
|
|
|
|
//如非成功和15 则返回错误 并清空billuuid;
|
|
|
|
|
//2 如果ch_fee_invoice.billuuid无值 则重新产生值并发出红字确认单
|
|
|
|
|
|
|
|
|
|
return BasicDataRefDAL.GetContentResult(result);
|
|
|
|
|
}
|
|
|
|
|
//if (hx.accessToken == "")
|
|
|
|
|
//{
|
|
|
|
|
// BasicDataRefDAL.SaveLog("NNReadInv;税号" + head.TAXCODE + "的 accessToken为空", "", "诺诺平台", "返回认证窗口");
|
|
|
|
|
// var _r = TokenPage();
|
|
|
|
|
// return _r;
|
|
|
|
|
//}
|
|
|
|
|
result = hx.ReadInvoice(redhead);
|
|
|
|
|
|
|
|
|
|
if (!result.Success)
|
|
|
|
|
{
|
|
|
|
|
return BasicDataRefDAL.GetContentResult(result);
|
|
|
|
|
}
|
|
|
|
|
//此时head.billUuid如果不为空 代表已有红字申请单
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(head.billUuid))//&&
|
|
|
|
|
{
|
|
|
|
|
redhead.BILLNO = redhead.billUuid;
|
|
|
|
|
|
|
|
|
|
//if (result.Message == "需要重新认证")
|
|
|
|
|
//{
|
|
|
|
|
// //HangXinRequestHelper.clear(hx.accessToken);
|
|
|
|
|
// BasicDataRefDAL.SaveLog("ReadInvoice 反回‘需要重新认证’", "", "诺诺平台", "返回认证窗口");
|
|
|
|
|
// var _r = TokenPage();
|
|
|
|
|
// return _r;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
returndate = ChinvoiceDAL.GetData(" BILLNO='" + head.BILLNO + "'");
|
|
|
|
|
var _r = hx.ReadRedConfirm(ref redhead, detailList);
|
|
|
|
|
|
|
|
|
|
if (redhead.PTORRED == "2")
|
|
|
|
|
if (!_r.Success)
|
|
|
|
|
{
|
|
|
|
|
ChinvoiceDAL.SetRed(redhead);
|
|
|
|
|
|
|
|
|
|
//将原票内的申请和费用恢复原状
|
|
|
|
|
//var BlueInvoice = ChinvoiceDAL.GetData(" cm.INVOICECODE='" + head.REDCODE + "' and cm.INVOICENO='" + head.REDNUM + "'");
|
|
|
|
|
//result = SetInvoiceFee(BlueInvoice);
|
|
|
|
|
return BasicDataRefDAL.GetContentResult(_r);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//如果状态为开出成功 则执行锁定
|
|
|
|
|
if (returndate.EINVOICESTATE == "2" && returndate.BILLSTATUS == 0)
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//ChinvoiceDAL.Lock(returndate.BILLNO);
|
|
|
|
|
|
|
|
|
|
//20200106 添加 如sys_param_set.PARAMNAME=INVOICEAUTOLOCK 没有值或值为false 则不执行锁定
|
|
|
|
|
var needautolock = MsSysParamSetDAL.GetSysParam("INVOICEAUTOLOCK").isnullortrue();
|
|
|
|
|
|
|
|
|
|
if (needautolock)
|
|
|
|
|
//var hx = 诺诺全电发票.getHelper(head.TAXCODE);
|
|
|
|
|
if (!hx.CanUse)
|
|
|
|
|
{
|
|
|
|
|
ChinvoiceDAL.Lock(returndate.BILLNO);
|
|
|
|
|
result.SetErrorInfo(hx.ERRORMSG);
|
|
|
|
|
|
|
|
|
|
return BasicDataRefDAL.GetContentResult(result);
|
|
|
|
|
}
|
|
|
|
|
//if (hx.accessToken == "")
|
|
|
|
|
//{
|
|
|
|
|
// BasicDataRefDAL.SaveLog("NNReadInv;税号" + head.TAXCODE + "的 accessToken为空", "", "诺诺平台", "返回认证窗口");
|
|
|
|
|
// var _r = TokenPage();
|
|
|
|
|
// return _r;
|
|
|
|
|
//}
|
|
|
|
|
result = hx.ReadInvoice(redhead);
|
|
|
|
|
|
|
|
|
|
if (!result.Success)
|
|
|
|
|
{
|
|
|
|
|
return BasicDataRefDAL.GetContentResult(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//if (result.Message == "需要重新认证")
|
|
|
|
|
//{
|
|
|
|
|
// //HangXinRequestHelper.clear(hx.accessToken);
|
|
|
|
|
// BasicDataRefDAL.SaveLog("ReadInvoice 反回‘需要重新认证’", "", "诺诺平台", "返回认证窗口");
|
|
|
|
|
// var _r = TokenPage();
|
|
|
|
|
// return _r;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
returndate = ChinvoiceDAL.GetData(" BILLNO='" + head.BILLNO + "'");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (redhead.PTORRED == "2")
|
|
|
|
|
{
|
|
|
|
|
ChinvoiceDAL.SetRed(redhead);
|
|
|
|
|
|
|
|
|
|
result.Data = returndate;
|
|
|
|
|
//将原票内的申请和费用恢复原状
|
|
|
|
|
BlueInvoice = ChinvoiceDAL.GetData(" cm.INVOICECODE='" + head.REDCODE + "' and cm.INVOICENO='" + head.REDNUM + "'");
|
|
|
|
|
result = SetInvoiceFee(BlueInvoice);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return BasicDataRefDAL.GetContentResult(result);
|
|
|
|
|
}
|
|
|
|
|
//如果状态为开出成功 则执行锁定
|
|
|
|
|
if (returndate.EINVOICESTATE == "2" && returndate.BILLSTATUS == 0)
|
|
|
|
|
{
|
|
|
|
|
//ChinvoiceDAL.Lock(returndate.BILLNO);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//head.billUuid如果不为空 代表还没发红字申请单
|
|
|
|
|
//获取红票信息并发出
|
|
|
|
|
redhead.BILLNO = PubSysDAL.GetBillNo("0308");
|
|
|
|
|
//20200106 添加 如sys_param_set.PARAMNAME=INVOICEAUTOLOCK 没有值或值为false 则不执行锁定
|
|
|
|
|
var needautolock = MsSysParamSetDAL.GetSysParam("INVOICEAUTOLOCK").isnullortrue();
|
|
|
|
|
|
|
|
|
|
if (needautolock)
|
|
|
|
|
{
|
|
|
|
|
ChinvoiceDAL.Lock(returndate.BILLNO);
|
|
|
|
|
}
|
|
|
|
|
returndate = ChinvoiceDAL.GetData(" BILLNO='" + head.BILLNO + "'");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
head.billUuid = redhead.BILLNO;
|
|
|
|
|
|
|
|
|
|
result.Data = returndate;
|
|
|
|
|
|
|
|
|
|
result = hx.PostRedConfirm(redhead, ref head, detailList);
|
|
|
|
|
if (result.Success == false)
|
|
|
|
|
return BasicDataRefDAL.GetContentResult(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//head.billUuid如果不为空 代表还没发红字申请单
|
|
|
|
|
//获取红票信息并发出
|
|
|
|
|
redhead.BILLNO = PubSysDAL.GetBillNo("0308");
|
|
|
|
|
|
|
|
|
|
head.billUuid = redhead.BILLNO;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result = hx.PostRedConfirm(redhead, ref head, detailList);
|
|
|
|
|
if (result.Success == false)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//诺诺全电票根据红字申请单的结果读取确认单
|
|
|
|
@ -2056,6 +2081,7 @@ namespace DSWeb.Areas.Account.Controllers
|
|
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 诺诺全电发票 读取红字申请单
|
|
|
|
|
/// </summary>
|
|
|
|
|