diff --git a/DSWeb/Areas/Account/Controllers/Chfee_invoice_HangXinController.cs b/DSWeb/Areas/Account/Controllers/Chfee_invoice_HangXinController.cs index 55d359c2..261fdbbb 100644 --- a/DSWeb/Areas/Account/Controllers/Chfee_invoice_HangXinController.cs +++ b/DSWeb/Areas/Account/Controllers/Chfee_invoice_HangXinController.cs @@ -1737,9 +1737,15 @@ namespace DSWeb.Areas.Account.Controllers return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } - //else { - // return NNSetRed_QuanDian(bill); - //} + + //增加判断 如果原票createtime晚于当前时间24小时之前,则报错不允许开出 + if ( BlueInvoice.INVOICEMAKETIME==null|| BlueInvoice.INVOICEMAKETIME == "" || Convert.ToDateTime(BlueInvoice.INVOICEMAKETIME) >DateTime.Now.AddDays(-1)) + { + jsonRespose.Success = false; + jsonRespose.Message = $"该蓝票为{BlueInvoice.INVOICEMAKETIME}开出,当前无法冲红"; + + return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; + } } @@ -1849,7 +1855,7 @@ namespace DSWeb.Areas.Account.Controllers //红字申请单申请编号 即为发票业务编号 到时候红票的订单编号也是这个 // - head.billUuid = redhead.BILLNO; + //head.billUuid = redhead.BILLNO; } } var modb = new ModelObjectDB(); @@ -1861,14 +1867,10 @@ namespace DSWeb.Areas.Account.Controllers result = ChinvoiceDAL.SaveInvDetail(head.GID, detailList); if (result.Success == true) { - + //主要保存了红票的billno在billUuid当中 result = modb.Save(head); - //ChinvoiceDAL.UpdateInvNoUse(headData.INVOICENO, Convert.ToString(Session["USERID"]),headData.BILLNO); - //if (headData.EXCHANGERATE != 0) - //{ - // ChinvoiceDAL.updateFeeTax(headData.BILLNO, headData.EXCHANGERATE); + - //} }; } @@ -1938,7 +1940,91 @@ namespace DSWeb.Areas.Account.Controllers { var hx = 诺诺全电发票.getHelper(head.TAXCODE); - result = hx.PostRedConfirm(redhead, ref head, detailList); + //20230529 + //1 如果ch_fee_invoice.billuuid有值的话 + //这个值是最近一次提交的红字确认单订单编码 + //用这个值读取红字确认单状态 如成功则做红票相应的处理 + //如状态15申请中 则不做操作返回申请中 + //如非成功和15 则返回错误 并清空billuuid; + //2 如果ch_fee_invoice.billuuid无值 则重新产生值并发出红字确认单 + + //此时head.billUuid如果不为空 代表是第一次冲红 + if (!string.IsNullOrWhiteSpace(head.billUuid))//&& + { + var _r = hx.ReadRedConfirm(ref redhead, detailList); + + if (!_r.Success) + { + return BasicDataRefDAL.GetContentResult( _r); + } + else + { + //var hx = 诺诺全电发票.getHelper(head.TAXCODE); + if (!hx.CanUse) + { + 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(head); + + 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 (head.PTORRED == "2") + { + ChinvoiceDAL.SetRed(head); + + //将原票内的申请和费用恢复原状 + //var BlueInvoice = ChinvoiceDAL.GetData(" cm.INVOICECODE='" + head.REDCODE + "' and cm.INVOICENO='" + head.REDNUM + "'"); + //result = SetInvoiceFee(BlueInvoice); + } + + //如果状态为开出成功 则执行锁定 + if (returndate.EINVOICESTATE == "2" && returndate.BILLSTATUS == 0) + { + //ChinvoiceDAL.Lock(returndate.BILLNO); + + //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 + "'"); + } + + + result.Data = returndate; + + return BasicDataRefDAL.GetContentResult(result); + } + + } + else + { + head.billUuid = redhead.BILLNO; + result = hx.PostRedConfirm(redhead, ref head, detailList); + } //诺诺全电票根据红字申请单的结果读取确认单 modb.Save(head); } diff --git a/DSWeb/Areas/Account/Models/Chfee_invoice_HangXin/Chfee_Invoice.cs b/DSWeb/Areas/Account/Models/Chfee_invoice_HangXin/Chfee_Invoice.cs index 0ca0699d..24eb0f14 100644 --- a/DSWeb/Areas/Account/Models/Chfee_invoice_HangXin/Chfee_Invoice.cs +++ b/DSWeb/Areas/Account/Models/Chfee_invoice_HangXin/Chfee_Invoice.cs @@ -2144,6 +2144,7 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin head.DbOperationType = DbOperationType.DbotUpd; head.ModelUIStatus = "E"; + head.INVOICEMAKETIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); var modb = new ModelObjectDB(); var result = modb.Save(head); if (!result.Success) @@ -2382,6 +2383,10 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin { //var billno = head.BILLNO; + //20230529 增加判断 如果INVOICEMAKETIME到当前时间 小于24小时 则提示错误并返回 + // + + var _head = new NuoNuoQuanDian_RedConfirm(head); var json = DSWeb.TruckMng.Helper.JsonConvert.Serialize(_head); @@ -2553,6 +2558,23 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin //return result; ; } + else { + + /*红字确认单状态(不传则查全部状态): 01 无需确认 02 +销方录入待购方确认 03 购方录入待销方确认 04 购销双方 +已确认 05 作废(销方录入购方否认) 06 作废(购方录入 +销方否认) 07 作废(超 72 小时未确认) 08 作废(发起方 +已撤销) 09 作废(确认后撤销) 15 申请中 16 申请失败*/ + if (_return.申请中()) + { + return result.SetErrorInfo("红字确认单申请中"); + } + else + { + return result.SetErrorInfo(_return.错误信息()); + } + + } return result.OK(); @@ -2729,6 +2751,17 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin { return result.billStatus() == "01"; } + + public string 错误信息() + { + return result.errormsg(); + } + + public bool 申请中() + { + return result.billStatus() == "15"; + } + } public class 红字申请单result @@ -2742,6 +2775,11 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin return list[0].billStatus; } + public string errormsg() + { + if (list == null || list.Count == 0) return null; + return list[0].billMessage; + } } diff --git a/DSWeb/Areas/Account/Viewsjs/Chfee_invoice_HangXin/ChInvoiceAppEdit.js b/DSWeb/Areas/Account/Viewsjs/Chfee_invoice_HangXin/ChInvoiceAppEdit.js index 554bf999..af190063 100644 --- a/DSWeb/Areas/Account/Viewsjs/Chfee_invoice_HangXin/ChInvoiceAppEdit.js +++ b/DSWeb/Areas/Account/Viewsjs/Chfee_invoice_HangXin/ChInvoiceAppEdit.js @@ -5432,6 +5432,8 @@ Ext.extend(Shipping.MsChInvoiceAppEdit, Ext.Panel, { var billno = this.formEdit.getForm().findField('BILLNO').getValue(); + var redReason = this.formEdit.getForm().findField('redReason').getValue(); + if (billno == '*' || billno == '') { Ext.Msg.show({ title: '提示', @@ -5449,7 +5451,8 @@ Ext.extend(Shipping.MsChInvoiceAppEdit, Ext.Panel, { url: '/Account/Chfee_invoice_HangXin/NNSetRed', params: { bill: billno, - redirecturl: GetHangXinRedirectUrl() + redirecturl: GetHangXinRedirectUrl(), + redReason: redReason }, callback: function (options, success, response) { if (success) {