diff --git a/DSWeb/Areas/Account/Controllers/Chfee_invoice_HangXinController.cs b/DSWeb/Areas/Account/Controllers/Chfee_invoice_HangXinController.cs index f0c46b48..ae164993 100644 --- a/DSWeb/Areas/Account/Controllers/Chfee_invoice_HangXinController.cs +++ b/DSWeb/Areas/Account/Controllers/Chfee_invoice_HangXinController.cs @@ -350,9 +350,11 @@ namespace DSWeb.Areas.Account.Controllers var INVITERFACE = MsSysInvInterFaceSetDAL.GetData("INVOICELINE='" + headData.INVOICELINEREF + "'", ""); if (INVITERFACE.INVITERFACE == "") headData.INVITERFACE = INVITERFACE.INVITERFACE; - else + else headData.INVITERFACE = "诺诺发票接口"; - + } + else + { } @@ -999,7 +1001,7 @@ namespace DSWeb.Areas.Account.Controllers // return View(); //} - private JsonResponse checkinfo(string BILLNO, string redirecturl,string redReason="") + private JsonResponse checkinfo(string BILLNO, string redirecturl, string redReason = "", bool setred = false) { var result = new DBResult(); var head = new ChInvoice_HangXin(); @@ -1027,15 +1029,18 @@ namespace DSWeb.Areas.Account.Controllers if (head.INVITERFACE == "诺诺全电发票") { - if (!string.IsNullOrWhiteSpace(redReason)) - { - head.redReason = redReason; - } - else + if (setred) { - jsonRespose.Success = false; - jsonRespose.Message = "必须选择冲红理由!"; - return jsonRespose; + if (!string.IsNullOrWhiteSpace(redReason)) + { + head.redReason = redReason; + } + else + { + jsonRespose.Success = false; + jsonRespose.Message = "必须选择冲红理由!"; + return jsonRespose; + } } } @@ -1045,26 +1050,29 @@ namespace DSWeb.Areas.Account.Controllers var modb = new ModelObjectDB(); result = modb.Save(head); } - else { + else + { if (head.INVITERFACE == "诺诺全电发票") { - if (!string.IsNullOrWhiteSpace(redReason)) + if (setred) { - head.redReason = redReason; - - - - head.DbOperationType = DbOperationType.DbotUpd; - head.ModelUIStatus = "E"; - var modb = new ModelObjectDB(); - result = modb.Save(head); - } - else - { - jsonRespose.Success = false; - jsonRespose.Message = "必须选择冲红理由!"; - return jsonRespose; + if (!string.IsNullOrWhiteSpace(redReason)) + { + head.redReason = redReason; + + head.DbOperationType = DbOperationType.DbotUpd; + head.ModelUIStatus = "E"; + var modb = new ModelObjectDB(); + result = modb.Save(head); + } + else + { + jsonRespose.Success = false; + jsonRespose.Message = "必须选择冲红理由!"; + return jsonRespose; + } } + } } //head = list[0]; @@ -1235,7 +1243,7 @@ namespace DSWeb.Areas.Account.Controllers } } - else if (head.INVITERFACE == "诺诺全电发票" ) + else if (head.INVITERFACE == "诺诺全电发票") { var hx = 诺诺全电发票.getHelper(head.TAXCODE); if (!hx.CanUse) @@ -1260,7 +1268,7 @@ namespace DSWeb.Areas.Account.Controllers if (!string.IsNullOrWhiteSpace(hx.accessToken)) { result = hx.PostInvoice(head, detailList); - } + } } } @@ -1329,11 +1337,11 @@ namespace DSWeb.Areas.Account.Controllers //诺诺全电发票的红票 读取其实是读取 红字确认单查询接口 if (headdata.PTORRED == "1") { - result=Do_NuoNuoQuanDianReadInv(BILLNO); + result = Do_NuoNuoQuanDianReadInv(BILLNO); } if (headdata.PTORRED == "2") { - var _r= NNRedConfirm_Read(BILLNO); + var _r = NNRedConfirm_Read(BILLNO); return BasicDataRefDAL.GetContentResult(_r); } } @@ -1495,7 +1503,8 @@ namespace DSWeb.Areas.Account.Controllers } var result = hx.ReadInvoice(head); - if (!result.Success) { + if (!result.Success) + { return new JsonResponse { Success = result.Success, Message = result.Message, Data = "" }; ; } @@ -1641,16 +1650,16 @@ namespace DSWeb.Areas.Account.Controllers var hx = new HangXinRequestHelper(); - - + + if (head.INVITERFACE == "诺诺发票接口" || head.INVITERFACE == "") { - hx=HangXinRequestHelper.getHelper(head.TAXCODE); + hx = HangXinRequestHelper.getHelper(head.TAXCODE); } else if (head.INVITERFACE == "瑞宏发票接口") { - + } else if (head.INVITERFACE == "诺诺全电发票") @@ -1694,7 +1703,7 @@ namespace DSWeb.Areas.Account.Controllers /// /// /// - public ContentResult NNSetRed(string bill, string redirecturl,string redReason="") + public ContentResult NNSetRed(string bill, string redirecturl, string redReason = "") { //首先判断是否有 modInvLock 发票开出锁定 var result = new DBResult(); @@ -1704,7 +1713,7 @@ namespace DSWeb.Areas.Account.Controllers //首先判断数据完整性与合法性 及检查平台认证 - var checkresult = checkinfo(bill, redirecturl, redReason); + var checkresult = checkinfo(bill, redirecturl, redReason, true); //被冲红的蓝票信息 var BlueInvoice = ChinvoiceDAL.GetData(" cm.billno='" + bill + "'"); @@ -1719,7 +1728,7 @@ namespace DSWeb.Areas.Account.Controllers var head = (ChInvoice_HangXin)checkresult.Data; var BlueHead = head; - if (head.INVITERFACE == "诺诺全电发票") + if (head.INVITERFACE == "诺诺全电发票") { //全电发票没有发票代码 if (string.IsNullOrEmpty(head.INVOICENO)) @@ -1729,9 +1738,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) }; + } } @@ -1814,7 +1829,7 @@ namespace DSWeb.Areas.Account.Controllers //redhead仅用于向诺诺全电红字申请单接口发送用 //redhead = AutoMapperHelper.MapTo(head); - + redhead.GID = System.Guid.NewGuid().ToString(); redhead.BILLNO = PubSysDAL.GetBillNo("0308"); @@ -1841,25 +1856,22 @@ namespace DSWeb.Areas.Account.Controllers //红字申请单申请编号 即为发票业务编号 到时候红票的订单编号也是这个 // - head.billUuid = redhead.BILLNO; + //head.billUuid = redhead.BILLNO; } } var modb = new ModelObjectDB(); - if (head.INVITERFACE != "诺诺全电发票") { + if (head.INVITERFACE != "诺诺全电发票") + { //一般的红票业务此时保存红票信息 result = ChinvoiceDAL.SaveInvDetail(head.GID, detailList); if (result.Success == true) { - - result = modb.Save(head); - //ChinvoiceDAL.UpdateInvNoUse(headData.INVOICENO, Convert.ToString(Session["USERID"]),headData.BILLNO); - //if (headData.EXCHANGERATE != 0) - //{ - // ChinvoiceDAL.updateFeeTax(headData.BILLNO, headData.EXCHANGERATE); + //主要保存了红票的billno在billUuid当中 + result = modb.Save(head); + - //} }; } @@ -1929,7 +1941,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); } @@ -1965,8 +2061,9 @@ namespace DSWeb.Areas.Account.Controllers result = hx.ReadRedConfirm(ref head); if (!result.Success) { return result; } - else { - var _r= Do_NuoNuoQuanDianReadInv(head.BILLNO); + else + { + var _r = Do_NuoNuoQuanDianReadInv(head.BILLNO); result.Success = _r.Success; result.Message = _r.Message; @@ -2029,7 +2126,8 @@ namespace DSWeb.Areas.Account.Controllers private DBResult checkCanPost(ChInvoice_HangXin head) { var result = new DBResult(true, "", ""); - if (head.ISFRINV) { + if (head.ISFRINV) + { return result; } @@ -2087,7 +2185,7 @@ namespace DSWeb.Areas.Account.Controllers /// /// /// - private JsonResponse checkCanRead(string BILLNO, string redirecturl="") + private JsonResponse checkCanRead(string BILLNO, string redirecturl = "") { var result = new DBResult(); @@ -2634,7 +2732,7 @@ namespace DSWeb.Areas.Account.Controllers #endregion - + } } diff --git a/DSWeb/Areas/Account/DAL/Chfee_invoice_HangXin/Chfee_InvoiceDAL.cs b/DSWeb/Areas/Account/DAL/Chfee_invoice_HangXin/Chfee_InvoiceDAL.cs index ce660e83..616a26bc 100644 --- a/DSWeb/Areas/Account/DAL/Chfee_invoice_HangXin/Chfee_InvoiceDAL.cs +++ b/DSWeb/Areas/Account/DAL/Chfee_invoice_HangXin/Chfee_InvoiceDAL.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Data; using System.Data.Common; using System.Collections.Generic; @@ -37,12 +37,12 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin { #region 发票列表 - static public List GetDataList(int start, int limit, string strCondition, string userid="", string usercode="", string orgcode="", string sort = null) + static public List GetDataList(int start, int limit, string strCondition, string userid = "", string usercode = "", string orgcode = "", string sort = null) { var rangstr = GetRangDAListStr("", userid, usercode, orgcode); - if (!string.IsNullOrEmpty(rangstr) &&!string.IsNullOrWhiteSpace(userid+ usercode+ orgcode)) + if (!string.IsNullOrEmpty(rangstr) && !string.IsNullOrWhiteSpace(userid + usercode + orgcode)) { if (!string.IsNullOrEmpty(strCondition)) { @@ -99,7 +99,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin strSql.Append(",buyerManagerName,managerCardType,managerCardNo"); strSql.Append(",redReason,billInfoNo,billUUid"); - + strSql.Append(" FROM ch_fee_invoice cm where 1=1 "); if (!string.IsNullOrEmpty(strCondition)) @@ -216,7 +216,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin static public ChInvoice_HangXin GetData(string condition, string userid = "", string usercode = "", string orgcode = "") { - var list = GetDataList(0,1,condition,userid,usercode,orgcode,""); + var list = GetDataList(0, 1, condition, userid, usercode, orgcode, ""); if (list.Count > 0) return list[0]; @@ -259,9 +259,9 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin data.POD = Convert.ToString(reader["POD"]); if (reader["AMOUNT"] != DBNull.Value) - data.AMOUNT = Convert.ToDecimal(reader["AMOUNT"]); + data.AMOUNT = Convert.ToDecimal(reader["AMOUNT"]); if (reader["INVAMOUNT"] != DBNull.Value) - data.INVAMOUNT = Math.Round(Convert.ToDecimal(reader["INVAMOUNT"]), 2, MidpointRounding.AwayFromZero); + data.INVAMOUNT = Math.Round(Convert.ToDecimal(reader["INVAMOUNT"]), 2, MidpointRounding.AwayFromZero); data.AMOUNTCAPITAL = Convert.ToString(reader["AMOUNTCAPITAL"]); if (reader["OTCURRAMOUNT"] != DBNull.Value) data.OTCURRAMOUNT = Convert.ToDecimal(reader["OTCURRAMOUNT"]); @@ -270,7 +270,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin else data.EXCHANGERATE = 0; data.APPLICANT = Convert.ToString(reader["APPLICANT"]); -// data.APPLICANTNAME = Convert.ToString(reader["APPLICANTNAME"]); + // data.APPLICANTNAME = Convert.ToString(reader["APPLICANTNAME"]); if (reader["APPLYTIME"] != DBNull.Value) data.APPLYTIME = Convert.ToDateTime(reader["APPLYTIME"]); @@ -279,7 +279,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin data.OPERATOR = Convert.ToString(reader["OPERATOR"]); data.OPERATORNAME = Convert.ToString(reader["OPERATORNAME"]); - + data.REMARK = Convert.ToString(reader["REMARK"]); data.COMPANYID = Convert.ToString(reader["COMPANYID"]); @@ -306,7 +306,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin data.SALECORP = Convert.ToString(reader["SALECORP"]);//分公司代码 data.ACCOUNT = Convert.ToString(reader["ACCOUNT"]);//分公司代码 data.BANK = Convert.ToString(reader["BANK"]);//分公司代码 - data.DZSTATUS= Convert.ToString(reader["DZSTATUS"]); + data.DZSTATUS = Convert.ToString(reader["DZSTATUS"]); data.CUSTTEL = Convert.ToString(reader["CUSTTEL"]); data.CUSTADDR = Convert.ToString(reader["CUSTADDR"]); @@ -378,11 +378,12 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin { strSql.Append(" where " + strCondition); } - var result= DetailSetData(strSql); + var result = DetailSetData(strSql); //增加三个税收属性相关的字段 var PIDList = ""; - if (result.Count > 0) { + if (result.Count > 0) + { foreach (var detail in result) { if (PIDList.IndexOf(detail.PID) > 0) continue; @@ -393,7 +394,8 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin if (PIDList != "") { var CodeGoodInvList = MsCodeGoodInvDAL.GetDataList(" gid in (SELECT GOODSNAME FROM ch_fee_invoicedetail where PID in( '" + PIDList + "' )) "); - if (CodeGoodInvList.Count > 0) { + if (CodeGoodInvList.Count > 0) + { foreach (var detail in result) { foreach (var CodeGoodInv in CodeGoodInvList) @@ -425,7 +427,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin { strSql.Append(" where " + strCondition); } - return DetailSetData(strSql,db,tran); + return DetailSetData(strSql, db, tran); } static public ChInvoiceDetail GetDetailData(string condition) { @@ -452,16 +454,16 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin data.SERIALNO = Convert.ToInt16(reader["SerialNo"]); data.GOODSNAME = Convert.ToString(reader["GOODSNAME"]); data.GOODSNAMEREF = Convert.ToString(reader["GOODSNAMEREF"]); - if (data.GOODSNAMEREF == "" || data.GOODSNAMEREF ==null) data.GOODSNAMEREF = data.GOODSNAME; + if (data.GOODSNAMEREF == "" || data.GOODSNAMEREF == null) data.GOODSNAMEREF = data.GOODSNAME; data.SPEC = Convert.ToString(reader["SPEC"]); data.UNIT = Convert.ToString(reader["UNIT"]); data.PKGS = Convert.ToDecimal(reader["PKGS"]); data.TAXPRICE = Convert.ToDecimal(reader["TAXPRICE"]); data.PRICE = Convert.ToDecimal(reader["PRICE"]); - data.AMOUNT = Math.Round(Convert.ToDecimal(reader["AMOUNT"]), 2, MidpointRounding.AwayFromZero); + data.AMOUNT = Math.Round(Convert.ToDecimal(reader["AMOUNT"]), 2, MidpointRounding.AwayFromZero); data.TAXRATE = Convert.ToDecimal(reader["TAXRATE"]); data.TAX = Convert.ToDecimal(reader["TAX"]); - data.REMARK= Convert.ToString(reader["Remark"]); + data.REMARK = Convert.ToString(reader["Remark"]); data.GOODCODE = Convert.ToString(reader["GOODCODE"]); #endregion headList.Add(data); @@ -473,7 +475,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin private static List DetailSetData(StringBuilder strSql, Database db, DbTransaction tran) { var headList = new List(); - using (IDataReader reader = db.ExecuteReader(tran,CommandType.Text, strSql.ToString())) + using (IDataReader reader = db.ExecuteReader(tran, CommandType.Text, strSql.ToString())) { while (reader.Read()) { @@ -506,7 +508,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin } - public static List GetInvoiceNo (string companyid,string userid) + public static List GetInvoiceNo(string companyid, string userid) { var strSql = new StringBuilder(); strSql.Append("select b.INVOICECODE+i.INVOICENUM INVOICENUM from ch_fee_invoiceitems i left join ch_fee_invoicebooks b on (i.BOOKID=b.GID)"); @@ -534,7 +536,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin #region 发票费用明细 - static public List GetBodyList(string strCondition,string sort="") + static public List GetBodyList(string strCondition, string sort = "") { var strSql = new StringBuilder(); strSql.Append(" SELECT c.GID,c.BSNO,c.FEEID,c.FEENAME,c.CURRENCY,c.AMOUNT,c.DOAMOUNT,c.ORIGCURRENCY,c.ORIGAMOUNT,ISNULL(c.ORIGSTLAMOUNT,0) AS ORIGSTLAMOUNT,c.EXCHANGERATE "); @@ -644,7 +646,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin data.DOC = Convert.ToString(reader["DOC"]); data.SALE = Convert.ToString(reader["SALE"]); if (reader["BSSTATUS"] != DBNull.Value) - data.BSSTATUS = Convert.ToBoolean(reader["BSSTATUS"]); + data.BSSTATUS = Convert.ToBoolean(reader["BSSTATUS"]); if (reader["ORIGEXCHANGERATE"] != DBNull.Value) data.ORIGEXCHANGERATE = Convert.ToDecimal(reader["ORIGEXCHANGERATE"]); data.Remark = Convert.ToString(reader["Remark"]); @@ -885,7 +887,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin data.SALE = Convert.ToString(reader["SALE"]); if (reader["BSSTATUS"] != DBNull.Value) - data.BSSTATUS = Convert.ToBoolean(reader["BSSTATUS"]); + data.BSSTATUS = Convert.ToBoolean(reader["BSSTATUS"]); data.CH_ID = Convert.ToString(reader["CH_ID"]); data.FeeType = Convert.ToInt16(reader["FeeType"]); @@ -1440,7 +1442,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin data.CURR = Convert.ToString(reader["CURRENCY"]); data.EXRATE = 0; if (reader["EXCHANGERATE"] != DBNull.Value) - data.DFEXRATE = Convert.ToDecimal(reader["EXCHANGERATE"]); + data.DFEXRATE = Convert.ToDecimal(reader["EXCHANGERATE"]); #endregion headList.Add(data); @@ -1450,7 +1452,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin return headList; } #region 费用列表明细 - static public List GetFeeDetailList(string strCondition, string userid, string usercode, string orgcode,string sort=null) + static public List GetFeeDetailList(string strCondition, string userid, string usercode, string orgcode, string sort = null) { var strSql = new StringBuilder(); @@ -1761,7 +1763,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin decimal amtttl = 0; - decimal acctaxrate =0; + decimal acctaxrate = 0; decimal doamount = 0; decimal StlAmount = 0; @@ -1887,9 +1889,10 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin } } - if (!isList&& amtttl!=0) { + if (!isList && amtttl != 0) + { - var dataList =GetDetailList(" PID='"+GID+"'"); + var dataList = GetDetailList(" PID='" + GID + "'"); if (dataList.Count != 0) { var invlist = dataList[0]; @@ -1897,13 +1900,14 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin db.AddInParameter(cmdUpdateInv, "@GID", DbType.String, invlist.GID); if (acctaxrate == 0) { - db.AddInParameter(cmdUpdateInv, "@AMOUNT", DbType.Decimal, Math.Round(invlist.AMOUNT+amtttl,2)); - db.AddInParameter(cmdUpdateInv, "@TAXPRICE", DbType.Decimal, Math.Round((invlist.AMOUNT + amtttl)/invlist.PKGS,2)); - db.AddInParameter(cmdUpdateInv, "@PRICE", DbType.Decimal, Math.Round((invlist.AMOUNT + amtttl) / invlist.PKGS,2)); + db.AddInParameter(cmdUpdateInv, "@AMOUNT", DbType.Decimal, Math.Round(invlist.AMOUNT + amtttl, 2)); + db.AddInParameter(cmdUpdateInv, "@TAXPRICE", DbType.Decimal, Math.Round((invlist.AMOUNT + amtttl) / invlist.PKGS, 2)); + db.AddInParameter(cmdUpdateInv, "@PRICE", DbType.Decimal, Math.Round((invlist.AMOUNT + amtttl) / invlist.PKGS, 2)); db.AddInParameter(cmdUpdateInv, "@TAXRATE", DbType.Decimal, 0); - db.AddInParameter(cmdUpdateInv, "@TAX", DbType.Decimal,0); + db.AddInParameter(cmdUpdateInv, "@TAX", DbType.Decimal, 0); } - else { + else + { amtttl = amtttl + (invlist.TAXPRICE * invlist.PKGS); @@ -1927,7 +1931,8 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin db.ExecuteNonQuery(cmdUpdateInv, tran); } - else { + else + { cmdInsertInv.Parameters.Clear(); db.AddInParameter(cmdInsertInv, "@GID", DbType.String, Guid.NewGuid().ToString()); db.AddInParameter(cmdInsertInv, "@PID", DbType.String, GID); @@ -1935,7 +1940,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin if (defGOOD.GOODNAME == "") { db.AddInParameter(cmdInsertInv, "@GOODSNAME", DbType.String, "代理运杂费"); - db.AddInParameter(cmdInsertInv, "@UNIT", DbType.String,"票"); + db.AddInParameter(cmdInsertInv, "@UNIT", DbType.String, "票"); } else { @@ -1945,29 +1950,29 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin db.AddInParameter(cmdInsertInv, "@SPEC", DbType.String, defGOOD.SPEC); db.AddInParameter(cmdInsertInv, "@PKGS", DbType.Decimal, 1); - db.AddInParameter(cmdInsertInv, "@TAXPRICE", DbType.Decimal, Math.Round(amtttl,2)); + db.AddInParameter(cmdInsertInv, "@TAXPRICE", DbType.Decimal, Math.Round(amtttl, 2)); db.AddInParameter(cmdInsertInv, "@TAXRATE", DbType.Decimal, acctaxrate); if (acctaxrate == 0) { - db.AddInParameter(cmdInsertInv, "@PRICE", DbType.Decimal, Math.Round(amtttl,2)); - db.AddInParameter(cmdInsertInv, "@AMOUNT", DbType.Decimal, Math.Round(amtttl,2)); + db.AddInParameter(cmdInsertInv, "@PRICE", DbType.Decimal, Math.Round(amtttl, 2)); + db.AddInParameter(cmdInsertInv, "@AMOUNT", DbType.Decimal, Math.Round(amtttl, 2)); db.AddInParameter(cmdInsertInv, "@TAX", DbType.Decimal, 0); } else { var tax = Math.Round(amtttl / (1 + acctaxrate / 100) * (acctaxrate / 100), 2); - var amount = amtttl-tax; + var amount = amtttl - tax; db.AddInParameter(cmdInsertInv, "@PRICE", DbType.Decimal, amount); db.AddInParameter(cmdInsertInv, "@AMOUNT", DbType.Decimal, amount); db.AddInParameter(cmdInsertInv, "@TAX", DbType.Decimal, tax); } db.AddInParameter(cmdInsertInv, "@Remark", DbType.String, ""); db.AddInParameter(cmdInsertInv, "@GOODCODE", DbType.String, defGOOD.GOODCODE); - db.ExecuteNonQuery(cmdInsertInv, tran); - + db.ExecuteNonQuery(cmdInsertInv, tran); + } - - + + } if (ischaoe) { @@ -2004,7 +2009,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin - public static DBResult AddBill(ChInvoice_HangXin headData, string feesql, List exratelist, string companyid, bool isList, string GID,string userid, bool custgroup = false) + public static DBResult AddBill(ChInvoice_HangXin headData, string feesql, List exratelist, string companyid, bool isList, string GID, string userid, bool custgroup = false) { var result = new DBResult(); var defGOOD = MsCodeGoodInvDAL.GetData(" ISDEF='1' and (DEFCURR='' or DEFCURR='" + headData.RECVCURR + "') "); @@ -2036,9 +2041,9 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin try { - if (!custgroup) + if (!custgroup) feesql = feesql + " AND CUSTOMERNAME='" + headData.CUSTOMERNAME + "'"; - var feelist = GetFeeDetailList(feesql,userid,"",companyid); + var feelist = GetFeeDetailList(feesql, userid, "", companyid); var cmdInsert = @@ -2107,7 +2112,8 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin } } - if (!ischaoe) { + if (!ischaoe) + { cmdInsert.Parameters.Clear(); db.AddInParameter(cmdInsert, "@GID", DbType.String, Guid.NewGuid().ToString()); db.AddInParameter(cmdInsert, "@BILLNO", DbType.String, headData.BILLNO); @@ -2133,7 +2139,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin amtttl = amtttl - enumValue.StlAmount; else amtttl = amtttl + enumValue.StlAmount; - enumValue.ExChangerate =1; + enumValue.ExChangerate = 1; } else { @@ -2222,7 +2228,8 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin db.AddInParameter(cmdInsertInv, "@TAX", DbType.Decimal, tax); } } - else { + else + { var UExrate = GetExrate(enumValue.Currency, exratelist); db.AddInParameter(cmdInsertInv, "@TAXPRICE", DbType.Decimal, Math.Round(enumValue.StlAmount * UExrate, 2)); @@ -2264,7 +2271,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin amtttl = amtttl + Math.Round(invfeesum.amount * invfeesum.exchange, 2, MidpointRounding.AwayFromZero); } } - if (!isList&& amtttl!=0) + if (!isList && amtttl != 0) { var dataList = GetDetailList(" PID='" + GID + "'"); @@ -2275,9 +2282,9 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin db.AddInParameter(cmdUpdateInv, "@GID", DbType.String, invlist.GID); if (acctaxrate == 0) { - db.AddInParameter(cmdUpdateInv, "@AMOUNT", DbType.Decimal, Math.Round(invlist.AMOUNT + amtttl,2)); - db.AddInParameter(cmdUpdateInv, "@TAXPRICE", DbType.Decimal, Math.Round((invlist.AMOUNT + amtttl) / invlist.PKGS,2)); - db.AddInParameter(cmdUpdateInv, "@PRICE", DbType.Decimal, Math.Round((invlist.AMOUNT + amtttl) / invlist.PKGS,2)); + db.AddInParameter(cmdUpdateInv, "@AMOUNT", DbType.Decimal, Math.Round(invlist.AMOUNT + amtttl, 2)); + db.AddInParameter(cmdUpdateInv, "@TAXPRICE", DbType.Decimal, Math.Round((invlist.AMOUNT + amtttl) / invlist.PKGS, 2)); + db.AddInParameter(cmdUpdateInv, "@PRICE", DbType.Decimal, Math.Round((invlist.AMOUNT + amtttl) / invlist.PKGS, 2)); db.AddInParameter(cmdUpdateInv, "@TAXRATE", DbType.Decimal, 0); db.AddInParameter(cmdUpdateInv, "@TAX", DbType.Decimal, 0); } @@ -2320,7 +2327,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin db.AddInParameter(cmdInsertInv, "@GOODSNAME", DbType.String, defGOOD.GID); db.AddInParameter(cmdInsertInv, "@UNIT", DbType.String, defGOOD.UNIT); } - db.AddInParameter(cmdInsertInv, "@SPEC", DbType.String,defGOOD.SPEC); + db.AddInParameter(cmdInsertInv, "@SPEC", DbType.String, defGOOD.SPEC); db.AddInParameter(cmdInsertInv, "@PKGS", DbType.Decimal, 1); db.AddInParameter(cmdInsertInv, "@TAXPRICE", DbType.Decimal, amtttl); db.AddInParameter(cmdInsertInv, "@TAXRATE", DbType.Decimal, acctaxrate); @@ -2334,13 +2341,13 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin { var tax = Math.Round(amtttl / (1 + acctaxrate / 100) * (acctaxrate / 100), 2); var amount = amtttl - tax; -// var amount = Math.Round(amtttl / (1 + acctaxrate / 100),2); + // var amount = Math.Round(amtttl / (1 + acctaxrate / 100),2); db.AddInParameter(cmdInsertInv, "@PRICE", DbType.Decimal, amount); db.AddInParameter(cmdInsertInv, "@AMOUNT", DbType.Decimal, amount); db.AddInParameter(cmdInsertInv, "@TAX", DbType.Decimal, tax); } db.AddInParameter(cmdInsertInv, "@Remark", DbType.String, ""); - db.AddInParameter(cmdInsertInv, "@GOODCODE", DbType.String,defGOOD.GOODCODE); + db.AddInParameter(cmdInsertInv, "@GOODCODE", DbType.String, defGOOD.GOODCODE); db.ExecuteNonQuery(cmdInsertInv, tran); } @@ -2380,11 +2387,11 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin } - public static DBResult updateFeeTax(string billno,decimal taxrate) + public static DBResult updateFeeTax(string billno, decimal taxrate) { var result = new DBResult(); - var dataList = ChinvoiceDAL.GetBodyList("BILLNO='"+billno+"'"); + var dataList = ChinvoiceDAL.GetBodyList("BILLNO='" + billno + "'"); Database db = DatabaseFactory.CreateDatabase(); @@ -2544,7 +2551,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin return result; } - public static int p_update_Amount(string billno,string GID) + public static int p_update_Amount(string billno, string GID) { Database db = DatabaseFactory.CreateDatabase(); @@ -2638,15 +2645,15 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin db.AddInParameter(cmdUpdateInv, "@BILLNO", DbType.String, billno); foreach (var enumValue in bodyList) { - currency =enumValue.CURRENCY; - rate =enumValue.RATE; - custrateno =enumValue.CUSTRATENO; + currency = enumValue.CURRENCY; + rate = enumValue.RATE; + custrateno = enumValue.CUSTRATENO; custaddrtel = enumValue.CUSTADDRTEL; custbank = enumValue.CUSTBANK; INVOICECATEGORY = enumValue.INVOICECATEGORY; ACTUALCUSTOMERNAME = enumValue.ACTUALCUSTOMERNAME; INVOICECUSTNAME = enumValue.INVOICECUSTNAME; - REMARK = REMARK+' '+enumValue.REMARK; + REMARK = REMARK + ' ' + enumValue.REMARK; cmdInsert.Parameters.Clear(); db.AddInParameter(cmdInsert, "@BILLNO", DbType.String, billno); @@ -2655,22 +2662,24 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin cmdUpdate.Parameters.Clear(); db.AddInParameter(cmdUpdate, "@AppBILLNO", DbType.String, enumValue.BILLNO); - db.AddInParameter(cmdUpdate, "@INVOICENUM", DbType.String,invoiceno); + db.AddInParameter(cmdUpdate, "@INVOICENUM", DbType.String, invoiceno); db.ExecuteNonQuery(cmdUpdate, tran); - var invdetaillist = GetDetailList("PID='"+enumValue.GID+"'",db,tran); + var invdetaillist = GetDetailList("PID='" + enumValue.GID + "'", db, tran); if (invdetaillist != null) { foreach (var enumInvDetail in invdetaillist) { bool ishave = false; - if (invdetailDataList != null) { + if (invdetailDataList != null) + { foreach (var invdetailData in invdetailDataList) { - if (invdetailData.GOODSNAME == enumInvDetail.GOODSNAME) { + if (invdetailData.GOODSNAME == enumInvDetail.GOODSNAME) + { invdetailData.TAXPRICE = invdetailData.TAXPRICE + enumInvDetail.TAXPRICE; invdetailData.PRICE = invdetailData.PRICE + enumInvDetail.PRICE; invdetailData.AMOUNT = invdetailData.AMOUNT + enumInvDetail.AMOUNT; @@ -2680,12 +2689,13 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin } } - if (!ishave) { + if (!ishave) + { var invdetailtmp = enumInvDetail; invdetailtmp.GID = "*"; invdetailtmp.PID = GID; invdetailDataList.Add(invdetailtmp); - + } //if (invdetailData.AMOUNT == 0) @@ -2724,7 +2734,8 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin } - if (invdetailDataList != null) { + if (invdetailDataList != null) + { foreach (var invdetailData in invdetailDataList) { if (invdetailData.GID == "*") @@ -2746,7 +2757,8 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin db.ExecuteNonQuery(cmdInsertInvDetail, tran); } - else { + else + { var cmdUpdateInvDetail = db.GetSqlStringCommand( @@ -2756,12 +2768,12 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin db.AddInParameter(cmdUpdateInvDetail, "@PRICE", DbType.Decimal, invdetailData.PRICE); db.AddInParameter(cmdUpdateInvDetail, "@AMOUNT", DbType.Decimal, invdetailData.AMOUNT); db.AddInParameter(cmdUpdateInvDetail, "@TAX", DbType.Decimal, invdetailData.TAX); - db.ExecuteNonQuery(cmdUpdateInvDetail, tran); - + db.ExecuteNonQuery(cmdUpdateInvDetail, tran); + } } - + } //if (invdetailid == string.Empty) @@ -2794,11 +2806,11 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin // db.AddInParameter(cmdUpdateInvDetail, "@AMOUNT", DbType.Decimal, invdetailData.AMOUNT); // db.AddInParameter(cmdUpdateInvDetail, "@TAX", DbType.Decimal, invdetailData.TAX); // db.ExecuteNonQuery(cmdUpdateInvDetail, tran); - + //} - db.AddInParameter(cmdUpdateInv, "@REMARK", DbType.String, REMARK); + db.AddInParameter(cmdUpdateInv, "@REMARK", DbType.String, REMARK); db.ExecuteNonQuery(cmdUpdateInv, tran); @@ -2893,7 +2905,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin foreach (var enumValue in bodyList) { var stlamount = enumValue.STLAMOUNT; - var invappdetail = ChinvoiceapplicationDAL.GetBodyList("c.BILLNO='"+enumValue.BILLNO+"'"); + var invappdetail = ChinvoiceapplicationDAL.GetBodyList("c.BILLNO='" + enumValue.BILLNO + "'"); if (invappdetail != null) @@ -2966,10 +2978,10 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin } - } + } } - currency = enumValue.CURRENCY; + currency = enumValue.CURRENCY; rate = enumValue.RATE; custrateno = enumValue.CUSTRATENO; custaddrtel = enumValue.CUSTADDRTEL; @@ -3037,7 +3049,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin if (invdetailData.GOODSNAME == enumInvDetail.GOODSNAME) { invdetailData.TAXPRICE = invdetailData.TAXPRICE + enumInvDetail.TAXPRICE * (stlinvaount / enumInvDetail.AMOUNT); - invdetailData.PRICE = invdetailData.PRICE + enumInvDetail.PRICE*(stlinvaount/ enumInvDetail.AMOUNT); + invdetailData.PRICE = invdetailData.PRICE + enumInvDetail.PRICE * (stlinvaount / enumInvDetail.AMOUNT); invdetailData.AMOUNT = invdetailData.AMOUNT + stlinvaount; invdetailData.TAX = invdetailData.TAX + enumInvDetail.TAX * (stlinvaount / enumInvDetail.AMOUNT); ishave = true; @@ -3050,10 +3062,10 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin var invdetailtmp = enumInvDetail; invdetailtmp.GID = "*"; invdetailtmp.PID = GID; - invdetailtmp.TAXPRICE = enumInvDetail.TAXPRICE * (stlinvaount / enumInvDetail.AMOUNT); - invdetailtmp.PRICE = enumInvDetail.PRICE * (stlinvaount / enumInvDetail.AMOUNT); - invdetailtmp.AMOUNT = stlinvaount; - invdetailtmp.TAX = enumInvDetail.TAX * (stlinvaount / enumInvDetail.AMOUNT); + invdetailtmp.TAXPRICE = enumInvDetail.TAXPRICE * (stlinvaount / enumInvDetail.AMOUNT); + invdetailtmp.PRICE = enumInvDetail.PRICE * (stlinvaount / enumInvDetail.AMOUNT); + invdetailtmp.AMOUNT = stlinvaount; + invdetailtmp.TAX = enumInvDetail.TAX * (stlinvaount / enumInvDetail.AMOUNT); invdetailDataList.Add(invdetailtmp); } @@ -3179,7 +3191,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin } - public static DBResult DelAppList(List boday,string billno) + public static DBResult DelAppList(List boday, string billno) { var result = new DBResult(); @@ -3199,7 +3211,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin var cmddelete = db.GetSqlStringCommand("delete from ch_fee_do where BILLNO=@BILLNO AND FEEID IN (SELECT FEEID FROM CH_FEE_DO WHERE BILLNO=@AppBILLNO)"); - var cmdUpdate =db.GetSqlStringCommand( + var cmdUpdate = db.GetSqlStringCommand( @"declare @FEEID varchar(100) declare @ORDERINVOICE numeric(19,4) @@ -3267,7 +3279,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin #endregion - public static DBResult UpdateInvNoDelete(string billno,string userid,bool isdelete=true) + public static DBResult UpdateInvNoDelete(string billno, string userid, bool isdelete = true) { var result = new DBResult(); @@ -3291,7 +3303,8 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin db.GetSqlStringCommand( @"UPDATE ch_fee_invoiceitems set ISDELETE=0 where INVOICENUM=@BILLNO"); - if (billno.Length > 8) { + if (billno.Length > 8) + { cmdUpdate = db.GetSqlStringCommand( @@ -3315,11 +3328,12 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin db.AddInParameter(cmdUpdate, "@DELETETIME", DbType.String, DateTime.Now); db.ExecuteNonQuery(cmdUpdate, tran); } - else { + else + { cmdUpdate2.Parameters.Clear(); db.AddInParameter(cmdUpdate2, "@BILLNO", DbType.String, billno); - db.ExecuteNonQuery(cmdUpdate2, tran); + db.ExecuteNonQuery(cmdUpdate2, tran); } @@ -3346,7 +3360,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin return result; } - public static DBResult UpdateInvNoUse(string billno, string userid,string invbillno) + public static DBResult UpdateInvNoUse(string billno, string userid, string invbillno) { var result = new DBResult(); @@ -3371,10 +3385,11 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin var cmdUpdate = db.GetSqlStringCommand( @"UPDATE ch_fee_invoiceitems set ISMAKEOUT=1,MAKEOUTUSER=@DELETEUSER,MAKEOUTTIME=@DELETETIME,BILLNO=@INVBILLNO where INVOICENUM=@BILLNO"); - if (billno.Length > 8) { - cmdUpdate = - db.GetSqlStringCommand( - @"UPDATE ch_fee_invoiceitems set ISMAKEOUT=1,MAKEOUTUSER=@DELETEUSER,MAKEOUTTIME=@DELETETIME,BILLNO=@INVBILLNO FROM ch_fee_invoiceitems I + if (billno.Length > 8) + { + cmdUpdate = + db.GetSqlStringCommand( + @"UPDATE ch_fee_invoiceitems set ISMAKEOUT=1,MAKEOUTUSER=@DELETEUSER,MAKEOUTTIME=@DELETETIME,BILLNO=@INVBILLNO FROM ch_fee_invoiceitems I LEFT JOIN ch_fee_invoicebooks B ON (B.GID=I.BOOKID) where B.INVOICECODE+I.INVOICENUM=@BILLNO"); } @@ -3430,7 +3445,8 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin db.GetSqlStringCommand( @"UPDATE ch_fee_invoiceitems set ISMAKEOUT=0,MAKEOUTUSER='',MAKEOUTTIME=null,BILLNO='' where INVOICENUM=@BILLNO"); - if (billno.Length > 8) { + if (billno.Length > 8) + { cmdUpdate = db.GetSqlStringCommand( @@ -3481,13 +3497,13 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin { - var cmdUpdate = - db.GetSqlStringCommand( - @"UPDATE ch_fee_invoice set ISNEEDPRINT=1 where BILLNO=@BILLNO"); + var cmdUpdate = + db.GetSqlStringCommand( + @"UPDATE ch_fee_invoice set ISNEEDPRINT=1 where BILLNO=@BILLNO"); - cmdUpdate.Parameters.Clear(); - db.AddInParameter(cmdUpdate, "@BILLNO", DbType.String, billno); - db.ExecuteNonQuery(cmdUpdate, tran); + cmdUpdate.Parameters.Clear(); + db.AddInParameter(cmdUpdate, "@BILLNO", DbType.String, billno); + db.ExecuteNonQuery(cmdUpdate, tran); @@ -3514,7 +3530,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin return result; } - public static DBResult UpdateDelete(string billno,string userid,bool isdelete=true) + public static DBResult UpdateDelete(string billno, string userid, bool isdelete = true) { var result = new DBResult(); @@ -3544,11 +3560,12 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin db.AddInParameter(cmdUpdate, "@BILLNO", DbType.String, billno); db.ExecuteNonQuery(cmdUpdate, tran); } - else { + else + { cmdUpdate2.Parameters.Clear(); db.AddInParameter(cmdUpdate2, "@BILLNO", DbType.String, billno); - db.ExecuteNonQuery(cmdUpdate2, tran); - + db.ExecuteNonQuery(cmdUpdate2, tran); + } @@ -3711,7 +3728,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin } - public static DBResult UnLock(String bill,string userid) + public static DBResult UnLock(String bill, string userid) { var result = new DBResult(); @@ -3762,7 +3779,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin return result; } - public static DBResult UnLockList(String bills,string userid) + public static DBResult UnLockList(String bills, string userid) { var result = new DBResult(); @@ -3823,7 +3840,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin public static DBResult UpInvListDZStauts(List invlist, string dzstatus) { var result = new DBResult(); - + Database db = DatabaseFactory.CreateDatabase(); using (var conn = db.CreateConnection()) { @@ -3836,7 +3853,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin { - var cmdupdate = db.GetSqlStringCommand("update ch_fee_invoice set DZSTATUS='"+dzstatus+"' where BILLNO=@BILLNO"); + var cmdupdate = db.GetSqlStringCommand("update ch_fee_invoice set DZSTATUS='" + dzstatus + "' where BILLNO=@BILLNO"); cmdupdate.Parameters.Clear(); @@ -3925,7 +3942,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin public static DBResult GetRemarksTemplate(string companyid, string templatename = "") { var result = new DBResult(); - if (templatename == "" || templatename ==null) { templatename = "发票备注"; }; + if (templatename == "" || templatename == null) { templatename = "发票备注"; }; string str = ""; var strSql = new StringBuilder(); strSql.Append("SELECT "); @@ -3950,7 +3967,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin return result; } - public static DBResult SaveRemarksTemplate(string Template,string companyid,string templatename="") + public static DBResult SaveRemarksTemplate(string Template, string companyid, string templatename = "") { var result = new DBResult(); @@ -4108,8 +4125,8 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin //if (strl == "") strl = str + Environment.NewLine; //else strl = strl + str + Environment.NewLine; - if (strl == "") strl = str +" "; - else strl = strl + str +" "; + if (strl == "") strl = str + " "; + else strl = strl + str + " "; } } @@ -4122,7 +4139,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin for (var i = 0; i <= StrList.Length - 1; i++) { str = StrList[i]; - if (str.IndexOf("[外币金额(总计)]") >=0|| str.IndexOf("[人民币金额(总计)]") >= 0 && str.IndexOf("[折算汇率(总计)]") >= 0) + if (str.IndexOf("[外币金额(总计)]") >= 0 || str.IndexOf("[人民币金额(总计)]") >= 0 && str.IndexOf("[折算汇率(总计)]") >= 0) { str = str.Replace("[委托编号]", ""); str = str.Replace("[主提单号]", ""); @@ -4177,7 +4194,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin #region 导出发票 - + public static string CreateInvList(List headList, string path) { @@ -4205,7 +4222,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin r.WriteLine(""); r.WriteLine("2.0"); r.WriteLine(""); - r.WriteLine(""+headList.Count+""); + r.WriteLine("" + headList.Count + ""); r.WriteLine(""); foreach (var bill in headList) { @@ -4221,18 +4238,18 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin r.WriteLine("" + fhr + ""); r.WriteLine("" + skr + ""); r.WriteLine("12.0"); - if (bill.EXCHANGERATE==0) + if (bill.EXCHANGERATE == 0) r.WriteLine("0"); else r.WriteLine("1"); r.WriteLine(""); - var invdetaillist = GetDetailList("PID='"+bill.GID+"'"); + var invdetaillist = GetDetailList("PID='" + bill.GID + "'"); var invno = 1; foreach (var invdetail in invdetaillist) { r.WriteLine(""); - r.WriteLine("" + invno.ToString()+ ""); + r.WriteLine("" + invno.ToString() + ""); r.WriteLine("" + invdetail.GOODSNAMEREF + ""); r.WriteLine("" + invdetail.SPEC + ""); r.WriteLine("" + invdetail.UNIT + ""); @@ -4244,10 +4261,10 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin r.WriteLine("" + defGOOD.DEFREMARK + ""); - r.WriteLine("" + Math.Round(invdetail.PRICE,2).ToString() + ""); - r.WriteLine("" + Math.Round(invdetail.PKGS,0).ToString() + ""); - r.WriteLine("" + Math.Round(invdetail.AMOUNT,2).ToString() + ""); - r.WriteLine("" + Math.Round((invdetail.TAXRATE/100),2).ToString() + ""); + r.WriteLine("" + Math.Round(invdetail.PRICE, 2).ToString() + ""); + r.WriteLine("" + Math.Round(invdetail.PKGS, 0).ToString() + ""); + r.WriteLine("" + Math.Round(invdetail.AMOUNT, 2).ToString() + ""); + r.WriteLine("" + Math.Round((invdetail.TAXRATE / 100), 2).ToString() + ""); r.WriteLine("0"); r.WriteLine(""); @@ -4259,13 +4276,14 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin r.WriteLine(""); r.WriteLine(""); - if (INVEXPLOCK.PARAMVALUE == "1") { + if (INVEXPLOCK.PARAMVALUE == "1") + { - var blUpSQL = "update ch_fee_invoice set BILLSTATUS=1 where BILLNO='" + bill.BILLNO+ "' "; - bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL); + var blUpSQL = "update ch_fee_invoice set BILLSTATUS=1 where BILLNO='" + bill.BILLNO + "' "; + bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL); } - + } r.WriteLine(""); r.WriteLine(""); @@ -4274,7 +4292,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin f.Close(); return filename; } - public static string CreateDZInvList(List headList, string path,string companyid) + public static string CreateDZInvList(List headList, string path, string companyid) { var opBill = headList[0]; string filename = path + "\\" + headList[0].INVOICENO.ToString() + "-" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".xml"; @@ -4306,7 +4324,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin var invdetaillist = GetDetailList("PID='" + bill.GID + "'"); foreach (var invdetail1 in invdetaillist) { - hjse = hjse+invdetail1.TAX; + hjse = hjse + invdetail1.TAX; } hjje = bill.INVAMOUNT - hjse; r.WriteLine(""); @@ -4315,9 +4333,9 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin r.WriteLine("33.0"); var company = MsCompanysDAL.GetNoPicData("GID='" + companyid + "'"); - r.WriteLine("" + company.TAXCODE+ ""); + r.WriteLine("" + company.TAXCODE + ""); r.WriteLine("" + company.BILLRISES + ""); - r.WriteLine("" +company.ADDRESS + ""); + r.WriteLine("" + company.ADDRESS + ""); r.WriteLine(""); r.WriteLine("" + bill.CUSTRATENO + ""); @@ -4349,8 +4367,8 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin r.WriteLine("0"); r.WriteLine("" + defGOOD.GOODCODE + ""); r.WriteLine("" + defGOOD.GOODCODE + ""); - if (defGOOD.ISUSEPREF=="1") - r.WriteLine("1"); + if (defGOOD.ISUSEPREF == "1") + r.WriteLine("1"); else r.WriteLine("0"); r.WriteLine("1"); r.WriteLine(""); @@ -4383,7 +4401,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin - public static string CreateInvRYORDERTList(List headList, string path,string optype,string invaccount,string invpsw) + public static string CreateInvRYORDERTList(List headList, string path, string optype, string invaccount, string invpsw) { var opBill = headList[0]; string filename = path + "\\FPORDER" + headList[0].INVOICENO.ToString() + "-" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".xml"; @@ -4397,7 +4415,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin var ReCode = "OP01"; - if (optype=="M") ReCode = "OP02"; + if (optype == "M") ReCode = "OP02"; if (optype == "D") ReCode = "OP03"; Request order = new Request(); XmlHead Head = new XmlHead(); @@ -4415,10 +4433,11 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin foreach (var bill in headList) { - var bslist = GetBsList("c.BILLNO='"+bill.BILLNO+"'"); + var bslist = GetBsList("c.BILLNO='" + bill.BILLNO + "'"); var bs = new Chfee_do_detail(); if (bslist.Count > 0) bs = bslist[0]; - else { + else + { bs.ETD = DateTime.Now.ToString("yyyy-MM-dd"); bs.PORTLOAD = "QINGDAO"; bs.PORTDISCHARGE = "KOBE,JAPAN"; @@ -4436,18 +4455,19 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin orderdetail.order_type = "整箱"; orderdetail.order_date = bs.ETD; orderdetail.customer_fullname = bill.INVOICECUSTNAME; - orderdetail.start_port =bs.PORTLOAD.Replace(","," "); + orderdetail.start_port = bs.PORTLOAD.Replace(",", " "); orderdetail.end_port = bs.PORTDISCHARGE.Replace(",", " "); - orderdetail.sail_date =bs.ETD; - orderdetail.shipname =bs.VESSEL; - orderdetail.voyage_no =bs.VOYNO; - orderdetail.bill_lading_no =bs.MBLNO; + orderdetail.sail_date = bs.ETD; + orderdetail.shipname = bs.VESSEL; + orderdetail.voyage_no = bs.VOYNO; + orderdetail.bill_lading_no = bs.MBLNO; var ctnList = new List(); - var bsctnlist =MsOpSeaeDAL.GetBodyListSum("BSNO='"+bs.BSNO+"'"); - foreach (var enumCtn in bsctnlist ) { + var bsctnlist = MsOpSeaeDAL.GetBodyListSum("BSNO='" + bs.BSNO + "'"); + foreach (var enumCtn in bsctnlist) + { XmlCtn ctn = new XmlCtn(); ctn.ctn_type = enumCtn.CTNALL; ctn.ctn_quantity = enumCtn.CTNNUM.ToString(); @@ -4458,7 +4478,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin XmlCtns Ctns = new XmlCtns(); Ctns.Ctns = ctnList; - orderBody.Ctns= Ctns; + orderBody.Ctns = Ctns; var feelist = new List(); var invdetaillist = GetDetailList("PID='" + bill.GID + "'"); var invno = 1; @@ -4468,11 +4488,11 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin fee.expense_id = invdetail.GID; fee.expense_name = invdetail.GOODSNAMEREF; fee.currency = "RMB"; - fee.price =Math.Round(invdetail.TAXPRICE,2).ToString(); + fee.price = Math.Round(invdetail.TAXPRICE, 2).ToString(); fee.unit = invdetail.UNIT; if (fee.unit == "") fee.unit = "票"; - fee.quantity = Math.Round(invdetail.PKGS,0).ToString(); - if (fee.quantity == ""|| fee.quantity == "0") fee.quantity = "1"; + fee.quantity = Math.Round(invdetail.PKGS, 0).ToString(); + if (fee.quantity == "" || fee.quantity == "0") fee.quantity = "1"; feelist.Add(fee); } @@ -4482,7 +4502,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin orderBody.expenses = expenses; order.OrderBody = orderBody; -// order.OrderBody=ord + // order.OrderBody=ord } using (StreamWriter sw = new StreamWriter(filename)) @@ -4501,7 +4521,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin } - public static string CreateInvRYTList(List headList, string path, string optype, List expenses,string invaccount,string invpsw,string email) + public static string CreateInvRYTList(List headList, string path, string optype, List expenses, string invaccount, string invpsw, string email) { var opBill = headList[0]; string filename = path + "\\FP" + headList[0].INVOICENO.ToString() + "-" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".xml"; @@ -4550,7 +4570,8 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin invoice.customer_bank_name = banklist[0]; invoice.customer_bank_account = banklist[1]; } - else { + else + { invoice.customer_bank_name = bill.CUSTBANK; invoice.customer_bank_account = bill.CUSTBANK; } @@ -4568,7 +4589,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin -// order.OrderBody.Ctns.Ctns = ctnList; + // order.OrderBody.Ctns.Ctns = ctnList; var XmlInvDetail = new List(); var invno = 1; foreach (var invdetail in expenses) @@ -4589,8 +4610,8 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin invoiceBodys.InvDetail = invoicelist; XmlInvoiceBody invoiceBody = new XmlInvoiceBody(); invoiceBody.InvoiceBodys = invoiceBodys; - order.InvoiceBody= invoiceBody; -// order.OrderBody.expenses.expenses = feelist; + order.InvoiceBody = invoiceBody; + // order.OrderBody.expenses.expenses = feelist; } 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 ce339c1a..53a31f94 100644 --- a/DSWeb/Areas/Account/Models/Chfee_invoice_HangXin/Chfee_Invoice.cs +++ b/DSWeb/Areas/Account/Models/Chfee_invoice_HangXin/Chfee_Invoice.cs @@ -281,7 +281,7 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin [ModelDB] public string billUuid { get; set; } = ""; - + /// /// 购买方经办人姓名(全电发票特有字段) @@ -513,12 +513,14 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin public string invoiceCode { - get { - if (string.IsNullOrWhiteSpace(ChInvoice_HangXin.REDCODE)) { + get + { + if (string.IsNullOrWhiteSpace(ChInvoice_HangXin.REDCODE)) + { return ""; } - return ChInvoice_HangXin.REDCODE.Length==11? "0"+ChInvoice_HangXin.REDCODE: ChInvoice_HangXin.REDCODE; + return ChInvoice_HangXin.REDCODE.Length == 11 ? "0" + ChInvoice_HangXin.REDCODE : ChInvoice_HangXin.REDCODE; } } @@ -704,7 +706,7 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin } [JsonObject] - public class NuoNuoQuanDian_Head : HXInvoice_Head + public class NuoNuoQuanDian_Head : HXInvoice_Head { public NuoNuoQuanDian_Head() @@ -803,7 +805,7 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin } [JsonObject] - public class NuoNuoQuanDian_Detail : HXInvoice_Detail + public class NuoNuoQuanDian_Detail : HXInvoice_Detail { public NuoNuoQuanDian_Detail() { @@ -859,9 +861,9 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin public string callBackUrl { get; set; } = ""; - public string invoiceCode { get { return ChInvoice_HangXin.INVOICECODE; } } + public string invoiceCode { get { return ChInvoice_HangXin.INVOICECODE; } } - public string invoiceNumber { get{ return ChInvoice_HangXin.INVOICENO; } } + public string invoiceNumber { get { return ChInvoice_HangXin.INVOICENO; } } public string taxNum { get { return ChInvoice_HangXin.TAXCODE; } } @@ -984,7 +986,7 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin [JsonObject] public class NuoNuoQuanDian_ReadRedConfirm : HXInvoice_Head { - + public NuoNuoQuanDian_ReadRedConfirm() { @@ -1096,8 +1098,8 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin */ /* 正式地址 大简云*/ - public string appKey { get; set; }= "23646802"; - public string appSecret { get; set; } = "CBFAFF5B0AED4465"; + public string appKey { get; set; } = "23646802"; + public string appSecret { get; set; } = "CBFAFF5B0AED4465"; /// @@ -1509,7 +1511,7 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin } } - protected static HangXinRequestHelper getPortToken_诺诺全电发票自应用模式(string taxnum ) + protected static HangXinRequestHelper getPortToken_诺诺全电发票自应用模式(string taxnum) { try @@ -1522,8 +1524,9 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin { return result; } - else { - result.appKey= INVITERFACE.NUONUOAPPKEY; + else + { + result.appKey = INVITERFACE.NUONUOAPPKEY; result.appSecret = INVITERFACE.NUONUOAPPSECRET; } @@ -1554,12 +1557,12 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin // return hx; // } //} - result.accessToken= pt.message; + result.accessToken = pt.message; return result; } else - return new HangXinRequestHelper(taxnum,""); + return new HangXinRequestHelper(taxnum, ""); } catch (Exception e) { @@ -2044,7 +2047,8 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin } - public class 诺诺全电发票 : HangXinRequestHelper { + public class 诺诺全电发票 : HangXinRequestHelper + { public static 诺诺全电发票 getHelper(string taxnum) { @@ -2070,7 +2074,7 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin } string method = "nuonuo.OpeMplatform.queryInvoiceResult"; - var json = "{" + "\"serialNos\":[\"" + head.INVOICESERIALNUM + "\"]," + "\"orderNo\":[],"+ "\"isOfferInvoiceDetail\":0 }"; + var json = "{" + "\"serialNos\":[\"" + head.INVOICESERIALNUM + "\"]," + "\"orderNo\":[]," + "\"isOfferInvoiceDetail\":0 }"; if (string.IsNullOrWhiteSpace(head.INVOICESERIALNUM)) @@ -2119,7 +2123,7 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin { returndate = ChinvoiceDAL.GetData("cm.BILLNO='" + head.BILLNO + "'"); } - head=returndate ; + head = returndate; //var invoiceSerialNum = _return.result[0].invoiceSerialNum; var info = _return.result[0]; @@ -2131,7 +2135,7 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin head.INVOICEINFOURL = info.ofdUrl; head.INVOICEPDFURL = info.paperPdfUrl; - head.INVOICEMAKETIME = BasicDataRefDAL. Timestamp2Datetime( info.invoiceTime).ToString("yyyy-MM-dd HH:mm:ss"); + head.INVOICEMAKETIME = BasicDataRefDAL.Timestamp2Datetime(info.invoiceTime).ToString("yyyy-MM-dd HH:mm:ss"); //if (!string.IsNullOrWhiteSpace(info.invoiceSerialNum)) //{ // head.INVOICESERIALNUM = info.invoiceSerialNum; @@ -2140,9 +2144,10 @@ 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) + if (!result.Success) return result; result.Message = info.statusMsg; @@ -2155,10 +2160,11 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin var hx = getHelper(head.TAXCODE); hx.重推(head); } - else { + else + { result.Message += ":" + info.failCause; } - result.Data= head; + result.Data = head; return result; } @@ -2169,10 +2175,11 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin try { var info = _return.result[0]; - failCause= "[" + info.failCause + "]"; + failCause = "[" + info.failCause + "]"; } - catch { - + catch + { + } var msg = _return.code + ":" + _return.describe + failCause; @@ -2182,7 +2189,8 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin } } - public DBResult 重推(ChInvoice_HangXin head) { + public DBResult 重推(ChInvoice_HangXin head) + { var result = new DBResult(); if (string.IsNullOrEmpty(head.INVOICESERIALNUM)) @@ -2191,7 +2199,7 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin return result; } - var senid=Guid.NewGuid().ToString(); + var senid = Guid.NewGuid().ToString(); string method = "nuonuo.OpeMplatform.reInvoice"; @@ -2204,7 +2212,7 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin invoiceNumEnd = "" }; - var json = DSWeb.MvcShipping.Helper.JsonConvert.Serialize(content) ; + var json = DSWeb.MvcShipping.Helper.JsonConvert.Serialize(content); //"{" + "\"fpqqlsh\":\"" + head.INVOICESERIALNUM + "\"," + "\"orderNo\":[]," + "\"isOfferInvoiceDetail\":0 }"; @@ -2348,7 +2356,7 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin { //appkey与token问题 需要重新认证 //HangXinRequestHelper.clear(accessToken); - result.SetErrorInfo( "需要重新认证"); + result.SetErrorInfo("需要重新认证"); return result; } else if (_return.code == "E9106") @@ -2371,10 +2379,14 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin /// /// /// - public DBResult PostRedConfirm( ChInvoice_HangXin head,ref ChInvoice_HangXin bluehead,List detailList) + public DBResult PostRedConfirm(ChInvoice_HangXin head, ref ChInvoice_HangXin bluehead, List detailList) { //var billno = head.BILLNO; + //20230529 增加判断 如果INVOICEMAKETIME到当前时间 小于24小时 则提示错误并返回 + // + + var _head = new NuoNuoQuanDian_RedConfirm(head); var json = DSWeb.TruckMng.Helper.JsonConvert.Serialize(_head); @@ -2396,9 +2408,9 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin //红字申请单提交成功 //读取红字确认单 - var _r= ReadRedConfirm(ref head, detailList); + var _r = ReadRedConfirm(ref head, detailList); - if (!_r.Success) + if (!_r.Success) { return _r; } @@ -2466,7 +2478,7 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin - + } //else if (_return.code == "070101" || _return.code == "070301") @@ -2496,7 +2508,7 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin /// /// /// - public DBResult ReadRedConfirm(ref ChInvoice_HangXin head, List detailList=null) + public DBResult ReadRedConfirm(ref ChInvoice_HangXin head, List detailList = null) { //var billno = head.BILLNO; @@ -2510,8 +2522,8 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin string rtn = NNOpenSDK.sendPostSyncRequest(URL, getSendid(), appKey, appSecret, accessToken, taxnum, method, json); BasicDataRefDAL.SaveLog(rtn, "诺诺全电", "读红字单", "返回值"); - - + + var _return = DSWeb.TruckMng.Helper.JsonConvert.Deserialize<红字申请单读取返回值>(rtn.Trim('"')); var result = new DBResult(); @@ -2521,12 +2533,14 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin //根据查询结果读取红票信息 //税务那边实际的红票的订单编号 即为红字申请单orderno,也就是当时传过去的咱们的发票BILLNO - if (_return.申请成功()) { + if (_return.申请成功()) + { //则读取红票 //如不为空 这就是发出红字申请单之后返回结果成功立刻读的 //如为空 就是已产生的红票读取 就不保存了 - if (detailList != null) { + if (detailList != null) + { head.INVOICESERIALNUM = ""; var modb = new ModelObjectDB(); @@ -2542,7 +2556,26 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin //result = ReadInvoice(head); //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(); @@ -2711,13 +2744,25 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin [JsonObject] ///解析开票命令返回值;作废命令返回值 - public class 红字申请单读取返回值: KPResponse + public class 红字申请单读取返回值 : KPResponse { public new 红字申请单result result { get; set; } - public bool 申请成功() { + public bool 申请成功() + { return result.billStatus() == "01"; } + + public string 错误信息() + { + return result.errormsg(); + } + + public bool 申请中() + { + return result.billStatus() == "15"; + } + } public class 红字申请单result @@ -2725,11 +2770,17 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin public int total { get; set; } public new List<红字申请单> list { get; set; } - public string billStatus() { + public string billStatus() + { if (list == null || list.Count == 0) return null; return list[0].billStatus; } + public string errormsg() + { + if (list == null || list.Count == 0) return null; + return list[0].billMessage; + } } @@ -3018,7 +3069,7 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin [JsonObject] ///解析读取发票信息命令返回值 - public class ReadResponse_诺诺全电发票: ReadResponse + public class ReadResponse_诺诺全电发票 : ReadResponse { public List result { get; set; } @@ -3208,12 +3259,12 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin /// public string paperPdfUrl { get; set; } public string ofdUrl { get; set; } - + /// /// /// public List invoiceItems { get; set; } - + } public class InvoiceItems @@ -3281,4 +3332,14 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin { } + + public class InvoiceFeeSum + { + public string CURR { get; set; } + public decimal amount { get; set; } + + public decimal exchange { get; set; } + + } + } diff --git a/DSWeb/Areas/Account/Viewsjs/Chfee_invoice_HangXin/ChInvoiceAppEdit.js b/DSWeb/Areas/Account/Viewsjs/Chfee_invoice_HangXin/ChInvoiceAppEdit.js index e8226650..1f0a9bee 100644 --- a/DSWeb/Areas/Account/Viewsjs/Chfee_invoice_HangXin/ChInvoiceAppEdit.js +++ b/DSWeb/Areas/Account/Viewsjs/Chfee_invoice_HangXin/ChInvoiceAppEdit.js @@ -483,9 +483,29 @@ Ext.extend(Shipping.MsChInvoiceAppEdit, Ext.Panel, { } } } + }); + this.storeRedReason = Ext.create('DsExt.ux.RefEnumStore', {}); + this.storeRedReason.load({ params: { enumTypeId: 80008 } }); + this.comboxRedReason = Ext.create('DsExt.ux.RefTableCombox', { + fieldLabel: "冲红理由", //业务类型 + FLEX: 0.8, + store: this.storeRedReason, + name: 'redReason', + valueField: 'EnumValueId', + displayField: 'EnumValueName', + enableKeyEvents: true, + listeners: { + //scope: this, + //'select': function (combo, records, eOpts) { + // if (records.length > 0) { + // _this.setInvTile(records[0].data.EnumValueName); + // } + //} + } }); + this.StoreOpRange = Ext.create('DsExt.ux.RefTableStore', { model: 'MsOP', proxy: { @@ -1242,6 +1262,7 @@ Ext.extend(Shipping.MsChInvoiceAppEdit, Ext.Panel, { }] }, + this.comboxRedReason, ////// { fieldLabel: '船名航次', hidden: true, @@ -5538,6 +5559,7 @@ Ext.extend(Shipping.MsChInvoiceAppEdit, Ext.Panel, { onNNSetRedClick: function () { var billno = this.formEdit.getForm().findField('BILLNO').getValue(); + var redReason = this.formEdit.getForm().findField('redReason').getValue(); if (billno == '*' || billno == '') {