diff --git a/DSWeb/Areas/Account/Controllers/Chfee_invoice_HangXinController.cs b/DSWeb/Areas/Account/Controllers/Chfee_invoice_HangXinController.cs index affd57b6..cc17a727 100644 --- a/DSWeb/Areas/Account/Controllers/Chfee_invoice_HangXinController.cs +++ b/DSWeb/Areas/Account/Controllers/Chfee_invoice_HangXinController.cs @@ -34,8 +34,6 @@ using iTextSharp.text.pdf; using DSWeb.MvcShipping.DAL.MsSysInvInterFaceSet; using DSWeb.Common.Helper; using DSWeb.MvcShipping.DAL.MsBaseInfoDAL; -using NuonuoSDK; -using java.applet; namespace DSWeb.Areas.Account.Controllers { @@ -109,7 +107,7 @@ namespace DSWeb.Areas.Account.Controllers sort = sort.Replace("INVOICETYPEREF", "INVOICETYPE"); sort = sort.Replace("APPLICANT", "(select top 1 (select ShowName from [user] where GID=ap.applicant) APPLICANT from ch_fee_invoiceapplication ap where invbillno=cm.BILLNO)"); } - var dataList = ChinvoiceDAL.GetDataList(start, limit,condition, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]), sort); + var dataList = ChinvoiceDAL.GetDataList(start, limit, condition, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]), sort); int count = ChinvoiceDAL.getTotalCount(condition, CookieConfig.GetCookie_UserId(Request), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"])); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = dataList.ToList() }); @@ -123,7 +121,7 @@ namespace DSWeb.Areas.Account.Controllers return new ContentResult() { Content = json }; } - public ContentResult GetData(string handle, string condition,bool isapp) + public ContentResult GetData(string handle, string condition, bool isapp) { ChInvoice_HangXin head = null; @@ -144,7 +142,7 @@ namespace DSWeb.Areas.Account.Controllers head.CREATEUSER = Convert.ToString(Session["USERID"]); head.PTORRED = "1";//默认为正票 head.SALECORPID = Session["COMPANYID"].ToString(); - + head.PAYEE = Convert.ToString(Session["SHOWNAME"]); head.CHECKER = Convert.ToString(Session["SHOWNAME"]); @@ -163,9 +161,10 @@ namespace DSWeb.Areas.Account.Controllers head.INVOICETYPE = 2; head.INVOICETYPEREF = "申请发票"; } - else { + else + { head.INVOICETYPE = 1; - head.INVOICETYPEREF = "自由发票"; + head.INVOICETYPEREF = "自由发票"; } } @@ -189,7 +188,7 @@ namespace DSWeb.Areas.Account.Controllers public ContentResult GetBillList(string condition, string sort) { - var dataList = ChinvoiceDAL.GetBodyList(condition,sort); + var dataList = ChinvoiceDAL.GetBodyList(condition, sort); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); @@ -225,7 +224,7 @@ namespace DSWeb.Areas.Account.Controllers public ContentResult GetBillDataList(int start, int limit, string sort, string condition) { - var dataList = ChinvoiceDAL.GetAddBillList(start, limit,condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort); + var dataList = ChinvoiceDAL.GetAddBillList(start, limit, condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort); int count = ChinvoiceDAL.getAddBillTotalCount(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"])); var json = JsonConvert.Serialize( new { Success = true, Message = "查询成功", totalCount = count, data = dataList.ToList() }); @@ -251,7 +250,7 @@ namespace DSWeb.Areas.Account.Controllers public ContentResult GetAddSum(string condition) { - var dataList = ChinvoiceDAL.GetAddSum(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"])); + var dataList = ChinvoiceDAL.GetAddSum(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"])); var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() }); @@ -308,7 +307,8 @@ namespace DSWeb.Areas.Account.Controllers headData.CUSTADDRTEL = dsHSCODE.Tables[0].Rows[0]["INVADDRTEL"].ToString(); else headData.CUSTADDRTEL = dsHSCODE.Tables[0].Rows[0]["Addr"].ToString() + " " + dsHSCODE.Tables[0].Rows[0]["Tel"].ToString(); } - if (string.IsNullOrEmpty(headData.CUSTTEL)) { + if (string.IsNullOrEmpty(headData.CUSTTEL)) + { if (dsHSCODE.Tables[0].Rows[0]["Tel"].ToString() != "") headData.CUSTTEL = dsHSCODE.Tables[0].Rows[0]["Tel"].ToString(); } @@ -323,7 +323,7 @@ namespace DSWeb.Areas.Account.Controllers headData.CUSTBANK = dsHSCODE.Tables[0].Rows[0]["Rmbbank"].ToString(); } - + } } @@ -348,7 +348,8 @@ namespace DSWeb.Areas.Account.Controllers else headData.INVITERFACE = "诺诺发票接口"; } - if (!string.IsNullOrEmpty(headData.CUSTTEL)&&(headData.CUSTTEL.Trim().Length>20)) { + if (!string.IsNullOrEmpty(headData.CUSTTEL) && (headData.CUSTTEL.Trim().Length > 20)) + { isPost = false; errorstr = "客户电话长度不允许超过20"; @@ -359,10 +360,12 @@ namespace DSWeb.Areas.Account.Controllers isPost = false; errorstr = "客户电话长度不允许超过80"; } - if (!string.IsNullOrEmpty(headData.SALECORPID)&& !string.IsNullOrEmpty(headData.ACCOUNT)) { + if (!string.IsNullOrEmpty(headData.SALECORPID) && !string.IsNullOrEmpty(headData.ACCOUNT)) + { - var banklist = MsBaseInfoDAL.GetAllBANKList("LINKID='"+ headData.SALECORPID + "'"); - if (banklist.Find(x => (x.CURRENCY == headData.RECVCURR || x.CURRENCY=="")&& x.BANKACCOUNT == headData.ACCOUNT) == null) { + var banklist = MsBaseInfoDAL.GetAllBANKList("LINKID='" + headData.SALECORPID + "'"); + if (banklist.Find(x => (x.CURRENCY == headData.RECVCURR || x.CURRENCY == "") && x.BANKACCOUNT == headData.ACCOUNT) == null) + { isPost = false; errorstr = "银行及账号于收款单位和币别不一致,请检查"; @@ -405,15 +408,16 @@ namespace DSWeb.Areas.Account.Controllers return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } - else { + else + { var jsonRespose = new JsonResponse { Success = false, Message = errorstr + "不允许保存!" }; - return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; - + return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; + } } - public ContentResult AddDetail(string bill, string data, string curr,bool islist,string GID,string invoiceno) + public ContentResult AddDetail(string bill, string data, string curr, bool islist, string GID, string invoiceno) { //首先判断是否有 modInvoiceImport发票引入费用 权限 @@ -424,7 +428,7 @@ namespace DSWeb.Areas.Account.Controllers var bodyList = JsonConvert.Deserialize>(data); var headdata = ChinvoiceDAL.GetData(" BILLNO='" + bill + "'", Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"])); var modb = new ModelObjectDB(); - DBResult result = ChinvoiceDAL.AddDetail(bill, bodyList, curr, Convert.ToString(Session["COMPANYID"]), islist, GID,headdata); + DBResult result = ChinvoiceDAL.AddDetail(bill, bodyList, curr, Convert.ToString(Session["COMPANYID"]), islist, GID, headdata); if (result.Success) { ChinvoiceDAL.p_update_Amount(bill, GID); } @@ -477,13 +481,13 @@ namespace DSWeb.Areas.Account.Controllers } - public ContentResult DelBill(string data, string billno,string GID) + public ContentResult DelBill(string data, string billno, string GID) { //首先判断是否有 modInvoiceImport发票引入费用 权限 var bodyList = JsonConvert.Deserialize>(data); - DBResult result = ChinvoiceDAL.DelFeeDo(bodyList,GID); + DBResult result = ChinvoiceDAL.DelFeeDo(bodyList, GID); if (result.Success) { ChinvoiceDAL.p_update_Amount(billno, GID); } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; @@ -496,13 +500,14 @@ namespace DSWeb.Areas.Account.Controllers public ContentResult Delete(string data) { var headData = JsonConvert.Deserialize(data); - headData = ChinvoiceDAL.GetData(" cm.BILLNO='"+ headData.BILLNO+ "'"); + headData = ChinvoiceDAL.GetData(" cm.BILLNO='" + headData.BILLNO + "'"); DBResult result; //首先判断是否有 modInvLock 发票开出锁定 //20191205 防止已经获得【流水号】的发票业务被删除 - if (!string.IsNullOrWhiteSpace(headData.INVOICESERIALNUM) && headData.INVAMOUNT>0) { + if (!string.IsNullOrWhiteSpace(headData.INVOICESERIALNUM) && headData.INVAMOUNT > 0) + { var jsonRespose1 = new JsonResponse { Success = false, Message = "已经获得流水号且仍包含费用的发票业务不能删除" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose1) }; } @@ -512,7 +517,8 @@ namespace DSWeb.Areas.Account.Controllers var jsonRespose1 = new JsonResponse { Success = false, Message = "已经实际开出的发票业务不能删除" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose1) }; } - if (headData.EINVOICESTATEREF == "开票中") { + if (headData.EINVOICESTATEREF == "开票中") + { var jsonRespose1 = new JsonResponse { Success = false, Message = "当前发票状态不允许删除" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose1) }; @@ -522,12 +528,12 @@ namespace DSWeb.Areas.Account.Controllers if (result.Success == true) { - var modb = new ModelObjectDB(); - modb.Delete(headData); - ChinvoiceDAL.UpdateInvNoCancelUse(headData.INVOICENO); - T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); - var blUpSQL = " insert into sys_log(GID,NAME,LOGTYPE,LOGTIME,LOGCONTENT,CREATEUSER) values(NEWID(),'" + headData.BILLNO + "','删除发票','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + headData.INVOICENO + '(' + headData.CUSTOMERNAME + ')' + "','" + Convert.ToString(Session["USERID"]) + "')"; - bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL); + var modb = new ModelObjectDB(); + modb.Delete(headData); + ChinvoiceDAL.UpdateInvNoCancelUse(headData.INVOICENO); + T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); + var blUpSQL = " insert into sys_log(GID,NAME,LOGTYPE,LOGTIME,LOGCONTENT,CREATEUSER) values(NEWID(),'" + headData.BILLNO + "','删除发票','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + headData.INVOICENO + '(' + headData.CUSTOMERNAME + ')' + "','" + Convert.ToString(Session["USERID"]) + "')"; + bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL); } @@ -548,7 +554,7 @@ namespace DSWeb.Areas.Account.Controllers var rangestr = BasicDataRefDAL.CanOperateStr_INVOICE(ModName, Session["USERID"].ToString()); - var _L = ChinvoiceDAL.GetData("GID='"+head.GID+"' and "+ rangestr); + var _L = ChinvoiceDAL.GetData("GID='" + head.GID + "' and " + rangestr); if (_L.GID == head.GID) { @@ -613,10 +619,10 @@ namespace DSWeb.Areas.Account.Controllers // return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose1) }; //} DBResult result; - result = ChinvoiceDAL.UpdateDelete(headData.BILLNO, Convert.ToString(Session["USERID"]),false); + result = ChinvoiceDAL.UpdateDelete(headData.BILLNO, Convert.ToString(Session["USERID"]), false); if (result.Success == true) { - ChinvoiceDAL.UpdateInvNoDelete(headData.INVOICENO, Convert.ToString(Session["USERID"]),false); + ChinvoiceDAL.UpdateInvNoDelete(headData.INVOICENO, Convert.ToString(Session["USERID"]), false); } var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; @@ -635,68 +641,70 @@ namespace DSWeb.Areas.Account.Controllers } #region 发票申请添加 - public ContentResult AddAppDetail(string bill, string data, string invoiceno, string GID) - { - var bodyList = JsonConvert.Deserialize>(data); - var StrGid=""; - if (bodyList != null) - { - foreach (var enumValue in bodyList) - { - if (StrGid=="") - StrGid="'"+enumValue.GID+"'"; - else - StrGid=StrGid+",'"+enumValue.GID+"'"; - - } - } - if (StrGid != "") - { - StrGid = "(" + StrGid + ")"; - var dataList = ChinvoiceapplicationDAL.GetDataInvList(" BILLSTATUS=0 and GID IN " + StrGid, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"])); - if (dataList != null && dataList.Count != 0) - { - var modb = new ModelObjectDB(); - DBResult result = ChinvoiceDAL.AddAppDetail(bill, dataList, invoiceno, Convert.ToString(Session["COMPANYID"]), GID); - if (result.Success) { ChinvoiceDAL.p_update_Amount(bill, GID); } - var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; - return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; - } - else { - var jsonRespose = new JsonResponse { Success = false, Message = "发票申请已生成发票,请刷新!" }; - return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; - } - } - else { - var jsonRespose = new JsonResponse { Success =false, Message ="无需要添加的发票申请!" }; - return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; - - - } - } - - public ContentResult DelAppBill(string data, string billno, string GID) - { - - var bodyList = JsonConvert.Deserialize>(data); - - DBResult result = ChinvoiceDAL.DelAppList(bodyList,billno); - if (result.Success) { ChinvoiceDAL.p_update_Amount(billno, GID); } - var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; - return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; - } - - public ContentResult DelInvDetail(string billno, string body,string GID) - { - - var bodyList = JsonConvert.Deserialize>(body); - - DBResult result = ChinvoiceDAL.DelInvDetail(bodyList); - if (result.Success) { ChinvoiceDAL.p_update_Amount(billno, GID); } - var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; - return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; - } - + public ContentResult AddAppDetail(string bill, string data, string invoiceno, string GID) + { + var bodyList = JsonConvert.Deserialize>(data); + var StrGid = ""; + if (bodyList != null) + { + foreach (var enumValue in bodyList) + { + if (StrGid == "") + StrGid = "'" + enumValue.GID + "'"; + else + StrGid = StrGid + ",'" + enumValue.GID + "'"; + + } + } + if (StrGid != "") + { + StrGid = "(" + StrGid + ")"; + var dataList = ChinvoiceapplicationDAL.GetDataInvList(" BILLSTATUS=0 and GID IN " + StrGid, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"])); + if (dataList != null && dataList.Count != 0) + { + var modb = new ModelObjectDB(); + DBResult result = ChinvoiceDAL.AddAppDetail(bill, dataList, invoiceno, Convert.ToString(Session["COMPANYID"]), GID); + if (result.Success) { ChinvoiceDAL.p_update_Amount(bill, GID); } + var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; + return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; + } + else + { + var jsonRespose = new JsonResponse { Success = false, Message = "发票申请已生成发票,请刷新!" }; + return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; + } + } + else + { + var jsonRespose = new JsonResponse { Success = false, Message = "无需要添加的发票申请!" }; + return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; + + + } + } + + public ContentResult DelAppBill(string data, string billno, string GID) + { + + var bodyList = JsonConvert.Deserialize>(data); + + DBResult result = ChinvoiceDAL.DelAppList(bodyList, billno); + if (result.Success) { ChinvoiceDAL.p_update_Amount(billno, GID); } + var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; + return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; + } + + public ContentResult DelInvDetail(string billno, string body, string GID) + { + + var bodyList = JsonConvert.Deserialize>(body); + + DBResult result = ChinvoiceDAL.DelInvDetail(bodyList); + if (result.Success) { ChinvoiceDAL.p_update_Amount(billno, GID); } + var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message }; + return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; + } + #endregion #region 锁定和撤销锁定 @@ -745,7 +753,8 @@ namespace DSWeb.Areas.Account.Controllers #region 保存指定发票业务list的PDF文件 将其拼合成一个dpf后返回url - public ContentResult GetONEPDF(string BILLNOS) { + public ContentResult GetONEPDF(string BILLNOS) + { JsonResponse result = new JsonResponse(); try @@ -777,7 +786,8 @@ namespace DSWeb.Areas.Account.Controllers result.Message = "没有可以打印的发票文件"; return result.getContentReult(); } - else { + else + { //pdflist.OrderBy(o => o); pdflist.Sort(delegate (string p1, string p2) @@ -796,17 +806,19 @@ namespace DSWeb.Areas.Account.Controllers result.Data = "../../INVOICEPDF/" + Session["USERID"].ToString() + ".pdf"; } - catch (Exception e) { - result.Success = false; + catch (Exception e) + { + result.Success = false; result.Message = e.Message; } - + return result.getContentReult(); } - private void SavePDF(string[] pdfarray) { + private void SavePDF(string[] pdfarray) + { string outputFileName = BasicDataRefDAL.getPath("INVOICEPDF") + Session["USERID"].ToString() + ".pdf"; //PdfDocumentBase doc = PdfDocument.MergeFiles(pdfarray); @@ -860,22 +872,22 @@ namespace DSWeb.Areas.Account.Controllers // var result = new DBResult(); - var filename = ""; - filename = ChinvoiceDAL.CreateInvList(bodyList, path); - if (filename != "") - { - //result.Data = "../../EDIFiles/ExportInv/" + filename; - result.Data =filename; - filename = Path.GetFileName(filename); - result.Success = true; - result.Message = filename; + var filename = ""; + filename = ChinvoiceDAL.CreateInvList(bodyList, path); + if (filename != "") + { + //result.Data = "../../EDIFiles/ExportInv/" + filename; + result.Data = filename; + filename = Path.GetFileName(filename); + result.Success = true; + result.Message = filename; - } - else - { - result.Success = false; - result.Message = "无当前匹配的导出文件!"; - } + } + else + { + result.Success = false; + result.Message = "无当前匹配的导出文件!"; + } // var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = result.Data }; @@ -918,7 +930,8 @@ namespace DSWeb.Areas.Account.Controllers #region 航信接口调用 - public ContentResult test(string str) { + public ContentResult test(string str) + { var result = new KPResponse(); @@ -935,7 +948,7 @@ namespace DSWeb.Areas.Account.Controllers }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; - + } public ActionResult test2(string str) @@ -964,14 +977,15 @@ namespace DSWeb.Areas.Account.Controllers // return View(); //} - private JsonResponse checkinfo(string BILLNO,string redirecturl) { + private JsonResponse checkinfo(string BILLNO, string redirecturl) + { var result = new DBResult(); var head = new ChInvoice_HangXin(); //var detail = new List var jsonRespose = new JsonResponse { Success = true, Message = result.Message, Data = result.Data }; //首先判断数据完整性与合法性 - head = ChinvoiceDAL.GetData( "cm.BILLNO='" + BILLNO + "'"); + head = ChinvoiceDAL.GetData("cm.BILLNO='" + BILLNO + "'"); if (string.IsNullOrEmpty(head.INVOICELINE)) @@ -981,7 +995,7 @@ namespace DSWeb.Areas.Account.Controllers } - if (head.BILLNO!="") + if (head.BILLNO != "") { if (string.IsNullOrEmpty(head.INVITERFACE)) { @@ -1014,7 +1028,7 @@ namespace DSWeb.Areas.Account.Controllers else { - if (head.INVITERFACE == "诺诺发票接口"|| head.INVITERFACE =="") + if (head.INVITERFACE == "诺诺发票接口" || head.INVITERFACE == "") { //如果该税号的token需要 返回认证窗口 var hx = HangXinRequestHelper.getHelper(head.TAXCODE); @@ -1025,21 +1039,17 @@ namespace DSWeb.Areas.Account.Controllers jsonRespose.Message = hx.ERRORMSG; return jsonRespose; } - //20230109如无token则采用新的token获取方式 - //HangXinRequestHelper.redirectUri = getRedirecturl(redirecturl); - //if (hx.needStart) - //{ - // //BasicDataRefDAL.SaveLog("checkinfo;BILLNO=" + BILLNO, "", "诺诺平台", "返回认证窗口"); - // jsonRespose = TokenPage(); - - // - // var token= NNOpenSDK.getMerchantToken(HangXinRequestHelper.appKey, HangXinRequestHelper.appSecret); - // //public static string getMerchantToken(string appKey, string appSecret) - //} + HangXinRequestHelper.redirectUri = getRedirecturl(redirecturl); + if (hx.needStart) + { + BasicDataRefDAL.SaveLog("checkinfo;BILLNO=" + BILLNO, "", "诺诺平台", "返回认证窗口"); + jsonRespose = TokenPage(); + } } - else { - jsonRespose.Success =true; - jsonRespose.Message =""; + else + { + jsonRespose.Success = true; + jsonRespose.Message = ""; return jsonRespose; } } @@ -1047,7 +1057,8 @@ namespace DSWeb.Areas.Account.Controllers } - private JsonResponse TokenPage() { + private JsonResponse TokenPage() + { var jsonRespose = new JsonResponse { Success = true, Message = "", Data = "" }; @@ -1063,7 +1074,7 @@ namespace DSWeb.Areas.Account.Controllers /// /// /// - public ContentResult NNMakeInv(string bill,string redirecturl) + public ContentResult NNMakeInv(string bill, string redirecturl) { //首先判断是否有 modInvLock 发票开出锁定 var result = new DBResult(); @@ -1075,13 +1086,15 @@ namespace DSWeb.Areas.Account.Controllers //首先判断数据完整性与合法性 - var checkresult = checkinfo(bill,redirecturl); + var checkresult = checkinfo(bill, redirecturl); - if (!checkresult.Success) { + if (!checkresult.Success) + { return new ContentResult() { Content = JsonConvert.Serialize(checkresult) }; } - else { - var head = (ChInvoice_HangXin) checkresult.Data; + else + { + var head = (ChInvoice_HangXin)checkresult.Data; decimal invamount = 0; var invitems = ChinvoiceapplicationDAL.GetDetailList("PID='" + head.GID + "'", ""); foreach (var invitem in invitems) @@ -1096,7 +1109,7 @@ namespace DSWeb.Areas.Account.Controllers ChInvoice_HangXin returndate = null; - if (head.INVITERFACE == "诺诺发票接口"|| head.INVITERFACE =="") + if (head.INVITERFACE == "诺诺发票接口" || head.INVITERFACE == "") { var hx = HangXinRequestHelper.getHelper(head.TAXCODE); if (!hx.CanUse) @@ -1106,7 +1119,7 @@ namespace DSWeb.Areas.Account.Controllers return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } - + //20191107 如果该发票存在流水号 则首先去诺诺平台进行一次读取 //如开票信息形如 /*"{\"code\":\"E0000\",\"describe\":\"查询发票信息成功\",\"result\":[{\"orderNo\":\"IN2019110700005\",\"taxExcludedAmount\":500.00,\"c_invoiceid\":\"19110716260203390480\",\"invoiceImageUrl\":\"\",\"buyerName\":\"青岛世悠联国际物流有限公司\",\"invoiceCode\":\"\",\"invoiceNum\":\"\",\"resultMsg\":\"[][2019-11-07 16:30:02] 单据号:19110716260203390480,开具结果:0,开具失败原因:开票异常:\",\"checkCode\":\"\",\"invoiceSerialNum\":\"19110716260203390480\",\"statusMsg\":\"开票失败\",\"buyerTaxNum\":\"91370202MA3CGDCU83\",\"invoiceFileUrl\":\"\",\"invoiceLine\":\"电子增值税普通发票\",\"taxIncludedAmount\":500.00,\"status\":3}]}"*/ @@ -1119,19 +1132,19 @@ namespace DSWeb.Areas.Account.Controllers else { - //HangXinRequestHelper.redirectUri = getRedirecturl(redirecturl); + HangXinRequestHelper.redirectUri = getRedirecturl(redirecturl); var detailList = ChinvoiceDAL.GetDetailList("PID='" + head.GID + "'"); //var CodeGoodInvList = MsCodeGoodInvDAL.GetDataList(" gid in (SELECT GOODSNAME FROM ch_fee_invoicedetail where PID = '"+ head.GID + "')"); if (!string.IsNullOrWhiteSpace(hx.accessToken)) { result = hx.PostInvoice(head, detailList); } - //if (result.Message == "需要重新认证" || string.IsNullOrWhiteSpace(hx.accessToken)) - //{ - // BasicDataRefDAL.SaveLog("PostInvoice 反回‘需要重新认证’", "", "诺诺平台", "返回认证窗口"); - // var _r = TokenPage(); - // return new ContentResult() { Content = JsonConvert.Serialize(_r) }; - //} + if (result.Message == "需要重新认证" || string.IsNullOrWhiteSpace(hx.accessToken)) + { + BasicDataRefDAL.SaveLog("PostInvoice 反回‘需要重新认证’", "", "诺诺平台", "返回认证窗口"); + var _r = TokenPage(); + return new ContentResult() { Content = JsonConvert.Serialize(_r) }; + } //returndate = ChinvoiceDAL.GetData(" BILLNO='" + head.BILLNO + "'"); } @@ -1142,7 +1155,7 @@ namespace DSWeb.Areas.Account.Controllers string msg = null; if (!string.IsNullOrEmpty(head.INVOICESERIALNUM)) {//如果该发票流水号不为空 - result.Success = ruihongHelper.QueryInvoiceRecord(head.GID,head.INVOICESERIALNUM, out msg); + result.Success = ruihongHelper.QueryInvoiceRecord(head.GID, head.INVOICESERIALNUM, out msg); result.Message = msg; } @@ -1161,7 +1174,7 @@ namespace DSWeb.Areas.Account.Controllers } } - } + } returndate = ChinvoiceDAL.GetData(" BILLNO='" + head.BILLNO + "'"); if (returndate.EINVOICESTATE == "2" && returndate.BILLSTATUS == 0) @@ -1180,7 +1193,7 @@ namespace DSWeb.Areas.Account.Controllers jsonRespose.Message = result.Message; jsonRespose.Data = returndate; } - + return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } @@ -1194,7 +1207,7 @@ namespace DSWeb.Areas.Account.Controllers { //如果已有pdf地址 则直接返回 - var headdata = ChinvoiceDAL.GetData(" cm.BILLNO='"+BILLNO+"'"); + var headdata = ChinvoiceDAL.GetData(" cm.BILLNO='" + BILLNO + "'"); @@ -1207,7 +1220,7 @@ namespace DSWeb.Areas.Account.Controllers } else { - if (headdata.INVITERFACE == "诺诺发票接口"|| headdata.INVITERFACE =="") + if (headdata.INVITERFACE == "诺诺发票接口" || headdata.INVITERFACE == "") { result = Do_NNReadInv(BILLNO, redirecturl); } @@ -1216,10 +1229,10 @@ namespace DSWeb.Areas.Account.Controllers RuihongHelper ruihongHelper = new RuihongHelper(); string msg = null; - var succ = ruihongHelper.QueryInvoiceRecord(headdata.GID,headdata.INVOICESERIALNUM, out msg); + var succ = ruihongHelper.QueryInvoiceRecord(headdata.GID, headdata.INVOICESERIALNUM, out msg); result.Success = succ; result.Message = msg; - result.Data= ChinvoiceDAL.GetData(" BILLNO='" + headdata.BILLNO + "'"); + result.Data = ChinvoiceDAL.GetData(" BILLNO='" + headdata.BILLNO + "'"); } } @@ -1259,7 +1272,7 @@ namespace DSWeb.Areas.Account.Controllers string msg = null; var succ = ruihongHelper.QueryInvoiceRecord(headdata.GID, headdata.INVOICESERIALNUM, out msg); - var invoice= ChinvoiceDAL.GetData(" BILLNO='" + headdata.BILLNO + "'"); + var invoice = ChinvoiceDAL.GetData(" BILLNO='" + headdata.BILLNO + "'"); result.Success = succ; result.Message = msg; result.Data = invoice; @@ -1276,7 +1289,8 @@ namespace DSWeb.Areas.Account.Controllers return result.getContentReult(); } - private JsonResponse Do_NNReadInv(string BILLNO, string redirecturl) { + private JsonResponse Do_NNReadInv(string BILLNO, string redirecturl) + { //var hx = HangXinRequestHelper.getHelper(taxnum); //var result = new DBResult(); @@ -1348,7 +1362,8 @@ namespace DSWeb.Areas.Account.Controllers return jsonRespose; } - public static string getRedirecturl(string redirecturl) { + public static string getRedirecturl(string redirecturl) + { return redirecturl; } @@ -1407,7 +1422,8 @@ namespace DSWeb.Areas.Account.Controllers return result.getContentReult(); } - public JsonResponse Do_NNVoidInv(string BILLNO, string redirecturl) { + public JsonResponse Do_NNVoidInv(string BILLNO, string redirecturl) + { var jsonRespose = new JsonResponse { Success = false, Message = "", Data = "" }; @@ -1501,7 +1517,8 @@ namespace DSWeb.Areas.Account.Controllers var head = (ChInvoice_HangXin)checkresult.Data; - if (string.IsNullOrEmpty(head.INVOICENO) || string.IsNullOrEmpty(head.INVOICECODE)) { + if (string.IsNullOrEmpty(head.INVOICENO) || string.IsNullOrEmpty(head.INVOICECODE)) + { jsonRespose.Success = false; jsonRespose.Message = "该发票没有发票号和发票代码,无法进行冲红。"; @@ -1518,7 +1535,7 @@ namespace DSWeb.Areas.Account.Controllers var detailList = ChinvoiceDAL.GetDetailList("PID='" + head.GID + "'"); //如果已经存在一张相应的红票,则将现在这个head变成那个红票 - var _existRed = ChinvoiceDAL.GetData(" REDNUM='"+head.INVOICENO+"' and REDCODE='"+head.INVOICECODE+"' "); + var _existRed = ChinvoiceDAL.GetData(" REDNUM='" + head.INVOICENO + "' and REDCODE='" + head.INVOICECODE + "' "); if (_existRed.BILLNO != "*") { head = _existRed; @@ -1584,7 +1601,7 @@ namespace DSWeb.Areas.Account.Controllers var returndate = ChinvoiceDAL.GetData(" BILLNO='" + head.BILLNO + "'"); - if (head.INVITERFACE == "诺诺发票接口"|| head.INVITERFACE =="") + if (head.INVITERFACE == "诺诺发票接口" || head.INVITERFACE == "") { var hx = HangXinRequestHelper.getHelper(head.TAXCODE); if (!hx.CanUse) @@ -1627,7 +1644,8 @@ namespace DSWeb.Areas.Account.Controllers string msg = null; result.Success = ruihongHelper.RedInvoiceRecord(returndate.GID, out msg); result.Message = msg; - if (result.Success) { + if (result.Success) + { var needautolock = MsSysParamSetDAL.GetSysParam("INVOICEAUTOLOCK").isnullortrue(); if (needautolock) @@ -1661,18 +1679,21 @@ namespace DSWeb.Areas.Account.Controllers /// /// /// - private string REDREMARK(string REMARK) { + private string REDREMARK(string REMARK) + { if (REMARK.Length <= 88) return REMARK; - else { + else + { - while((REMARK.Length > 88)&&(REMARK.IndexOf(" ")>=0)) + while ((REMARK.Length > 88) && (REMARK.IndexOf(" ") >= 0)) { - REMARK=REMARK.Replace(" ", " "); + REMARK = REMARK.Replace(" ", " "); } - if (REMARK.Length > 88) { - REMARK=REMARK.Replace("\n", ""); + if (REMARK.Length > 88) + { + REMARK = REMARK.Replace("\n", ""); } if (REMARK.Length > 88) { @@ -1689,13 +1710,14 @@ namespace DSWeb.Areas.Account.Controllers /// /// /// - private DBResult checkCanPost(ChInvoice_HangXin head) { - var result = new DBResult(true,"",""); + private DBResult checkCanPost(ChInvoice_HangXin head) + { + var result = new DBResult(true, "", ""); if (string.IsNullOrEmpty(head.INVOICECUSTNAME)) setErrorMessage(ref result, "购方名称 不能为空"); if (string.IsNullOrEmpty(head.PUSHMOBILE)) setErrorMessage(ref result, "推送的手机号码 不能为空"); - var ErrorInfo= "销售方公司(我方公司)没有维护:"; + var ErrorInfo = "销售方公司(我方公司)没有维护:"; var LocalErrorInfo = "销售方公司(我方公司)没有维护:"; if (string.IsNullOrWhiteSpace(head.TAXCODE)) { @@ -1787,7 +1809,8 @@ namespace DSWeb.Areas.Account.Controllers - private void setErrorMessage(ref DBResult r,string message) { + private void setErrorMessage(ref DBResult r, string message) + { r.setMessage(false, message); } @@ -1807,11 +1830,11 @@ namespace DSWeb.Areas.Account.Controllers { DBResult result = ChinvoiceDAL.GetRemarksTemplate(Convert.ToString(Session["COMPANYID"]), TemplateName); - var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message,Data=result.Data }; + var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = result.Data }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } - public ContentResult SaveRemarksTemplate(string Template,string TemplateName) + public ContentResult SaveRemarksTemplate(string Template, string TemplateName) { DBResult result = ChinvoiceDAL.SaveRemarksTemplate(Template, Convert.ToString(Session["COMPANYID"]), TemplateName); @@ -1828,7 +1851,7 @@ namespace DSWeb.Areas.Account.Controllers return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } - #endregion + #endregion #region 发票票册 @@ -1843,7 +1866,7 @@ namespace DSWeb.Areas.Account.Controllers public ContentResult GetBookData(string handle, string condition) { - ChInvoiceBook_HangXin head = null; + ChInvoiceBook_HangXin head = null; if (handle == "edit") { @@ -1896,7 +1919,7 @@ namespace DSWeb.Areas.Account.Controllers { headData.DbOperationType = DbOperationType.DbotDel; } - if (headData.TYPE == "") headData.TYPE ="0"; + if (headData.TYPE == "") headData.TYPE = "0"; var BILLNO = headData.GID; var modb = new ModelObjectDB(); @@ -2010,7 +2033,7 @@ namespace DSWeb.Areas.Account.Controllers var _count = 0; //(string TABLENAME,string _PKEY,string _sql,string DBNAME) - BaseTableMC fromdbbase = new BaseTableMC("M_INVOICE","INVOICE_ID","","P2DB"); + BaseTableMC fromdbbase = new BaseTableMC("M_INVOICE", "INVOICE_ID", "", "P2DB"); var dataList = DBTableConnDAL.getToList(fromdbbase, "联力P2发票", condition); @@ -2048,8 +2071,10 @@ namespace DSWeb.Areas.Account.Controllers var splitword = "\r\n"; - if (dataList.Count > 0) { - foreach (var data in dataList) { + if (dataList.Count > 0) + { + foreach (var data in dataList) + { var feenamearray = data.GetSplitField("FEENAME", splitword); var amoutarray = data.GetSplitField("AMOUNT", splitword); var PRICEarray = data.GetSplitField("PRICE", splitword); @@ -2058,7 +2083,8 @@ namespace DSWeb.Areas.Account.Controllers if (feenamearray.Length > 1) { - for (var _i = 0; _i < feenamearray.Length; _i++) { + for (var _i = 0; _i < feenamearray.Length; _i++) + { var resultdata = new BaseTableMC(); resultdata.SetValue("CURRENCY", data.GetValue("CURRENCY")); @@ -2071,7 +2097,8 @@ namespace DSWeb.Areas.Account.Controllers resultlist.Add(resultdata); } } - else { + else + { resultlist.Add(data); } } @@ -2090,7 +2117,7 @@ namespace DSWeb.Areas.Account.Controllers return new ContentResult() { Content = json }; } - public ContentResult GetP2_CUST(string condition= " isnull(invoice_no,'')='' ") + public ContentResult GetP2_CUST(string condition = " isnull(invoice_no,'')='' ") { var canlogin = BasicDataRefDAL.CheckLogin(Session); @@ -2177,8 +2204,8 @@ namespace DSWeb.Areas.Account.Controllers return new ContentResult() { Content = json }; } - - public ContentResult SaveNewP2(string opstatus, string data,string GID,string localdata) + + public ContentResult SaveNewP2(string opstatus, string data, string GID, string localdata) { var headData = JsonConvert.Deserialize(data); @@ -2186,7 +2213,7 @@ namespace DSWeb.Areas.Account.Controllers BaseTableMC fromdbbase = new BaseTableMC("M_INVOICE", "INVOICE_ID", "", "P2DB"); - var P2DataList = DBTableConnDAL.getToList(fromdbbase, "联力P2发票", " INVOICE_ID='"+headData.BSNO+"'"); + var P2DataList = DBTableConnDAL.getToList(fromdbbase, "联力P2发票", " INVOICE_ID='" + headData.BSNO + "'"); var bodyList = new List(); @@ -2194,7 +2221,8 @@ namespace DSWeb.Areas.Account.Controllers var P2Data = new BaseTableMC(); - if (P2DataList.Count() > 0) { + if (P2DataList.Count() > 0) + { P2Data = P2DataList[0]; } @@ -2202,7 +2230,8 @@ namespace DSWeb.Areas.Account.Controllers { //查看是否已被使用 如是则返回错误并结束 var isexists = CheckExists(" BSNO='" + headData.BSNO + "' "); - if (!isexists.Success) { + if (!isexists.Success) + { return isexists.getContentReult(); } @@ -2212,7 +2241,7 @@ namespace DSWeb.Areas.Account.Controllers localData.OPERATOR = Convert.ToString(Session["USERID"]); localData.OPERATETIME = DateTime.Now; localData.DbOperationType = DbOperationType.DbotIns; - + } else if (opstatus == "edit") { @@ -2226,7 +2255,7 @@ namespace DSWeb.Areas.Account.Controllers localData.DbOperationType = DbOperationType.DbotUpd; - bodyList = ChinvoiceDAL.GetDetailList(" PID='"+localData.GID+"' "); + bodyList = ChinvoiceDAL.GetDetailList(" PID='" + localData.GID + "' "); } localData.SetP2Value(P2Data); @@ -2236,8 +2265,8 @@ namespace DSWeb.Areas.Account.Controllers { ChinvoiceDAL.DelInvDetail(bodyList); } - - SaveBodyList = ChInvoiceDetail.GetP2DetailList(P2Data, (localData.PTORRED=="2")); + + SaveBodyList = ChInvoiceDetail.GetP2DetailList(P2Data, (localData.PTORRED == "2")); var BILLNO = localData.BILLNO; var modb = new ModelObjectDB(); @@ -2262,10 +2291,11 @@ namespace DSWeb.Areas.Account.Controllers Data = ChinvoiceDAL.GetData(" BILLNO='" + BILLNO + "'", Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"])) }; - return jsonRespose.getContentReult() ; + return jsonRespose.getContentReult(); } - private JsonResponse CheckExists(string condition) { + private JsonResponse CheckExists(string condition) + { var existsdata = ChinvoiceDAL.GetData(condition); JsonResponse result = new JsonResponse(); if (!string.IsNullOrWhiteSpace(existsdata.GID)) @@ -2273,7 +2303,8 @@ namespace DSWeb.Areas.Account.Controllers result.Success = false; result.Message = "该发票已经被使用!"; } - else { + else + { result.Success = true; } return result; 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 72aac467..5751c616 100644 --- a/DSWeb/Areas/Account/Models/Chfee_invoice_HangXin/Chfee_Invoice.cs +++ b/DSWeb/Areas/Account/Models/Chfee_invoice_HangXin/Chfee_Invoice.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Data; using System.Collections; using System.Collections.Generic; @@ -20,10 +20,6 @@ using DSWeb.Areas.MvcShipping.Comm; using Newtonsoft.Json.Linq; using DSWeb.Areas.SysMng.Models.DBTableConn; using DSWeb.Areas.SysMng.DAL.DBTableConn; -using System.Configuration; -using DSWeb.MvcShipping.DAL.MsSysParamSet; -using com.sun.xml.@internal.ws.developer; -using System.Linq; namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin { @@ -50,9 +46,9 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin private string _INVOICEPDFURL = string.Empty; //发票PDF地址 开票成功后读取发票详情并记录 private string _PTORREDREF = string.Empty; // - private string _PUSHMODEREF = string.Empty; - private string _EINVOICESTATEREF = string.Empty; - private string _INVOICELINEREF = string.Empty; + private string _PUSHMODEREF = string.Empty; + private string _EINVOICESTATEREF = string.Empty; + private string _INVOICELINEREF = string.Empty; private string _TAXCODE = string.Empty; @@ -131,10 +127,12 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin set { _INVOICELINE = value; } } - public bool ISEInvoice { - get { + public bool ISEInvoice + { + get + { if (INVOICELINE == "p" || INVOICELINE == "e") - return true; + return true; else return false; } } @@ -218,7 +216,7 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin [ModelDB] public string CHECKER { - get { return _CHECKER; } + get { return _CHECKER; } set { _CHECKER = value; } } [ModelDB] @@ -240,42 +238,47 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin TableName = "ch_fee_invoice"; } - public static decimal getarraysum(string[] feearray) { + public static decimal getarraysum(string[] feearray) + { var result = 0M; - - for (var _i = 0; _i < feearray.Length; _i++) { + + for (var _i = 0; _i < feearray.Length; _i++) + { try { result += Convert.ToDecimal(feearray[_i]); } catch { } } - + return result; } - public void SetP2Value(BaseTableMC P2data) { + public void SetP2Value(BaseTableMC P2data) + { var connList = DBTableConnDAL.getConn("联力P2发票"); BSNO = P2data.GetValue("BSNO"); CUSTOMERNAME = P2data.GetValue("CUSTOMERNAME"); INVOICECUSTNAME = P2data.GetValue("INVOICECUSTNAME"); - VESSELVOYAGE = P2data.GetValue("VESSEL")+";"+ P2data.GetValue("VOYAGE"); + VESSELVOYAGE = P2data.GetValue("VESSEL") + ";" + P2data.GetValue("VOYAGE"); ETD = P2data.GetValue("ETD"); POL = P2data.GetValue("POL"); POD = P2data.GetValue("POD"); RECVCURR = P2data.GetValue("CURRENCY"); CURRENCY = "RMB"; CUSTRATENO = P2data.GetValue("CUSTRATENO"); - if (RECVCURR == "RMB") { - AMOUNT = getarraysum( P2data.GetSplitField("AMOUNT", "\r\n")); + if (RECVCURR == "RMB") + { + AMOUNT = getarraysum(P2data.GetSplitField("AMOUNT", "\r\n")); }; if (RECVCURR != "RMB") { AMOUNT = 0M; - var pricearray= P2data.GetSplitField("INVAMOUNT", "\r\n"); + var pricearray = P2data.GetSplitField("INVAMOUNT", "\r\n"); var numarray = P2data.GetSplitField("NUM", "\r\n"); - for (var _i = 0; _i < pricearray.Length; _i++) { + for (var _i = 0; _i < pricearray.Length; _i++) + { try { AMOUNT += Convert.ToDecimal(pricearray[_i]) * Convert.ToDecimal(numarray[_i]); @@ -288,7 +291,8 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin { OTCURRAMOUNT = getarraysum(P2data.GetSplitField("AMOUNT", "\r\n")); } - else { + else + { OTCURRAMOUNT = 0M; } AMOUNTCAPITAL = P2data.GetValue("AMOUNTCAPITAL"); @@ -307,11 +311,13 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin PTORRED = "1";//默认正票 INVOICELINE = "p";//默认普通电票 - if (P2data.GetValue("REDINVOICE") == "1") { + if (P2data.GetValue("REDINVOICE") == "1") + { PTORRED = "2"; BaseTableMC fromdbbase = new BaseTableMC("M_INVOICE", "INVOICE_ID", "", "P2DB"); var BeREDDataList = DBTableConnDAL.getToList(fromdbbase, "联力P2发票", " INVOICE_ID='" + P2data.GetValue("REDBSNO") + "'"); - if (BeREDDataList.Count > 0) { + if (BeREDDataList.Count > 0) + { var BeRedinvoice = BeREDDataList[0]; REDNUM = BeRedinvoice.GetValue("INVOICENO"); REDCODE = BeRedinvoice.GetValue("INVOICECODE"); @@ -324,14 +330,17 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin } [JsonObject] - public class HXInvoice { + public class HXInvoice + { public HXInvoice_Head order; - public HXInvoice(ChInvoice_HangXin head, List body) { + public HXInvoice(ChInvoice_HangXin head, List body) + { this.order = new HXInvoice_Head(head); List invoiceDetail = new List(); - foreach (var detail in body) { + foreach (var detail in body) + { var item = new HXInvoice_Detail(detail); @@ -345,10 +354,12 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin public class HXInvoice_Head { private ChInvoice_HangXin ChInvoice_HangXin; - public HXInvoice_Head() { + public HXInvoice_Head() + { } - public HXInvoice_Head(ChInvoice_HangXin ChInvoice_HangXin) { + public HXInvoice_Head(ChInvoice_HangXin ChInvoice_HangXin) + { this.ChInvoice_HangXin = ChInvoice_HangXin; } @@ -358,94 +369,94 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin public string buyerName { get { return ChInvoice_HangXin.INVOICECUSTNAME; } - + } - + public string buyerTaxNum { get { return ChInvoice_HangXin.CUSTRATENO; } } - + public string buyerTel { get { return ChInvoice_HangXin.CUSTTEL; } } - + public string buyerAddress { get { return ChInvoice_HangXin.CUSTADDR; } } - + public string buyerAccount { get { return ChInvoice_HangXin.CUSTBANK; } } - + public string orderNo { get { return ChInvoice_HangXin.BILLNO; } } - + public string invoiceDate { - get { return ChInvoice_HangXin.INVOICEMAKETIME+" 12:00:00"; } + get { return ChInvoice_HangXin.INVOICEMAKETIME + " 12:00:00"; } } - + public string clerk { get { return ChInvoice_HangXin.OPERATORNAME; } } - + public string salerTaxNum { get { return ChInvoice_HangXin.TAXCODE; } } - + public string salerTel { get { return ChInvoice_HangXin.OFFICEPHONE; } } - + public string salerAddress { get { return ChInvoice_HangXin.ADDRESS; } } - + public string salerAccount { get { return ChInvoice_HangXin.ACCOUNT; } } - + public string invoiceType { get { return ChInvoice_HangXin.PTORRED; } } - + public string remark { get { return ChInvoice_HangXin.REMARK; } } - + public string invoiceCode { get { return ChInvoice_HangXin.REDCODE; } } - + public string invoiceNum { get { return ChInvoice_HangXin.REDNUM; } } - + public string pushMode { - get { return ChInvoice_HangXin.PUSHMODE;} + get { return ChInvoice_HangXin.PUSHMODE; } } - + public string buyerPhone { - get { return ChInvoice_HangXin.PUSHMOBILE;} + get { return ChInvoice_HangXin.PUSHMOBILE; } } - + public string email { get { return ChInvoice_HangXin.PUSHEMAIL; } @@ -453,7 +464,9 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin public string invoiceLine { - get { return ChInvoice_HangXin.INVOICELINE; + get + { + return ChInvoice_HangXin.INVOICELINE; } } @@ -526,7 +539,7 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin get { return (Math.Round(ChInvoiceDetail.AMOUNT, 2, MidpointRounding.AwayFromZero) + Math.Round(ChInvoiceDetail.TAX, 2, MidpointRounding.AwayFromZero)).ToString(); - } + } } public string taxExcludedAmount @@ -537,7 +550,9 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin public string taxRate { - get { return Math.Round((ChInvoiceDetail.TAXRATE / 100), 2, MidpointRounding.AwayFromZero).ToString(); + get + { + return Math.Round((ChInvoiceDetail.TAXRATE / 100), 2, MidpointRounding.AwayFromZero).ToString(); } } @@ -594,7 +609,7 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin public class HangXinRequestHelper { public Boolean CanUse = true; - public string ERRORMSG = ""; + public string ERRORMSG = ""; public static List HXTokenHelperList = new List(); @@ -613,7 +628,7 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin // foreach (var hx in HXTokenHelperList) { // hx.ResetToken(); // } - + // //throw new NotImplementedException(); //} @@ -637,23 +652,24 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin public static string appSecret { get { return "SDFAFF5B0AED4465"; } } */ - /* 正式地址测试账户 纸票测试用 + /* 正式地址测试账户 纸票测试用 需使用深圳鑫鹏威 //339901999999516 public static string appKey { get { return "G6bvh0ke"; } } public static string appSecret { get { return "6850C5AED14E4177"; } } */ /* 正式地址 大简云*/ - //public static string appKey { get { return ConfigurationManager.AppSettings["NuoNuo_appKey"]; } } - //public static string appSecret { get { return ConfigurationManager.AppSettings["NuoNuo_appSecret"]; } } - public static string appKey { get; set; } - public static string appSecret { get; set; } + public static string appKey { get { return "23646802"; } } + public static string appSecret { get { return "CBFAFF5B0AED4465"; } } + /// /// 使用沙盒地址还是实际工作地址 /// - public static string URL { - get { + public static string URL + { + get + { //return sandboxUrl; //沙盒测试地址 return normalUrl; } @@ -763,7 +779,7 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin //} if (accessToken == "") return true; else - return false; + return false; } } @@ -881,7 +897,7 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin // returnStr = NNOpenSDK.refreshISVToken(refreshToken, userId, appSecret); // BasicDataRefDAL.SaveLog(returnStr, "诺诺平台", "ISV获取刷新令牌", "返回值"); // dealRefresh_token(returnStr); - + // return returnStr; // } // catch { @@ -908,24 +924,22 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin public HangXinRequestHelper() { - appKey = MsSysParamSetDAL.GetSysParamValue("NuoNuo_appKey"); - appSecret = MsSysParamSetDAL.GetSysParamValue("NuoNuo_appSecret"); tokenstarttime = Convert.ToDateTime("1900-01-01"); } public HangXinRequestHelper(string taxnum) - { + { this.taxnum = taxnum; if (HXTokenHelperList == null) HXTokenHelperList = new List(); HXTokenHelperList.Add(this); } - public HangXinRequestHelper(string taxnum,string accessToken) + public HangXinRequestHelper(string taxnum, string accessToken) { this.taxnum = taxnum; this.accessToken = accessToken; if (HXTokenHelperList == null) HXTokenHelperList = new List(); var curr = HXTokenHelperList.Find(o => o.taxnum == taxnum); - if (!(curr==null)) + if (!(curr == null)) { curr.accessToken = accessToken; } @@ -1007,90 +1021,58 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin //var result = new HangXinRequestHelper(taxnum); //return result; - appKey = MsSysParamSetDAL.GetSysParamValue("NuoNuo_appKey") ; - appSecret = MsSysParamSetDAL.GetSysParamValue("NuoNuo_appSecret"); - var _token = getPortToken(taxnum); return _token; } - private static HangXinRequestHelper getPortToken(string taxnum) { + private static HangXinRequestHelper getPortToken(string taxnum) + { try { ///读取接口token + //JObject reqObj = new JObject(); + //reqObj.Add("taxnum", taxnum); + var dic = new Dictionary(); + dic.Add("taxnum", taxnum); - //var dic = new Dictionary(); - //dic.Add("taxnum", taxnum); - - //var rtn = WebRequestHelper.DoPost(_IURL, dic, 10000); - - //PortTokenmb pt = Newtonsoft.Json.JsonConvert.DeserializeObject(rtn); + var rtn = WebRequestHelper.DoPost(_IURL, dic, 10000); + //var rtn = WebRequestHelper.DoPost(_SandBoxURL, dic, 20000); - //20230109 改为将token值记录在OP_LOGICINFO表中 BSNO=公司税号 propname='诺诺Token' 字段名NuoNuo_Token + //RepCZModel CZM = Newtonsoft.Json.JsonConvert.DeserializeObject(rtn); + PortTokenmb pt = Newtonsoft.Json.JsonConvert.DeserializeObject(rtn); - - if (HXTokenHelperList.Exists(x => x.taxnum == taxnum)) + if (pt.status == "1") { - var _token= HXTokenHelperList.First(x=>x.taxnum == taxnum); - var result = new HangXinRequestHelper(taxnum, _token.accessToken); - - return result; - } - else { - - var _dic = BasicDataRefDAL.GetLogicInfo(taxnum, "诺诺Token"); - - if (_dic != null && _dic.ContainsKey("NuoNuo_Token")) + foreach (var hx in HXTokenHelperList) { - var tokenstr = _dic["NuoNuo_Token"]; - foreach (var hx in HXTokenHelperList) + if (hx.taxnum == taxnum) { - if (hx.taxnum == taxnum) - { - hx.accessToken = tokenstr; - hx.CanUse = true; - hx.ERRORMSG = ""; - return hx; - } + hx.accessToken = pt.message; + hx.CanUse = true; + hx.ERRORMSG = ""; + return hx; } - var result = new HangXinRequestHelper(taxnum, tokenstr); - - return result; } - else { - - var tokenjson = NNOpenSDK.getMerchantToken(HangXinRequestHelper.appKey, HangXinRequestHelper.appSecret); - var token = DSWeb.MvcShipping.Helper.JsonConvert.Deserialize(tokenjson); - - var dic =new Dictionary { - {"NuoNuo_Token",token.access_token } - }; - BasicDataRefDAL.SaveLogicInfo(taxnum, "诺诺Token", dic); + var result = new HangXinRequestHelper(taxnum, pt.message); - return new HangXinRequestHelper(taxnum, token.access_token); - - } + return result; } + else + return new HangXinRequestHelper(taxnum, ""); } - catch (Exception e) { + catch (Exception e) + { var result = new HangXinRequestHelper(taxnum, ""); result.CanUse = false; - result.ERRORMSG = "没有取得开票密钥:"+e.Message; + result.ERRORMSG = "没有取得开票密钥:" + e.Message; return result; } } - public class nuonuotoken { - public string access_token { get; set; } - public int expires_in { get; set; } - } - //{\"access_token\":\"4ad7dfbf111624e13b146e0ozbnazu8s\",\"expires_in\":-1} - - /// @@ -1156,26 +1138,23 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin var result = new DBResult(false, "需要重新认证", null); return result; } - else if (_return.code == "E9106" ) + else if (_return.code == "E9106") { //E9106 订单编号不能重复 //同billno重复发送 执行一次用订单号读取 - //return ReadInvoice_BILLNO(head); - - var result = ReadInvoice(head); - return result; + return ReadInvoice_BILLNO(head); } else { var reault = new DBResult(false, _return.message, head); return reault; } - + } public string PostInvoice(string json) { - string method = "nuonuo.electronInvoice.requestBillingnew"; + string method = "nuonuo.electronInvoice.requestBilling"; BasicDataRefDAL.SaveLog("URL=" + URL + ";appKey=" + appKey + ";appSecret=" + appSecret + ";accessToken=" + accessToken + ";taxnum=" + taxnum + ";method=" + method + ";content=" + json, "诺诺平台", "发票开出", "发送值"); string result = NNOpenSDK.sendPostSyncRequest(URL, getSendid(), appKey, appSecret, accessToken, taxnum, method, json); @@ -1186,9 +1165,10 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin } - public DBResult ReadInvoice(string INVOICESERIALNUM,string USERID) { + public DBResult ReadInvoice(string INVOICESERIALNUM, string USERID) + { - var head = ChinvoiceDAL.GetData( "cm.INVOICESERIALNUM='" + INVOICESERIALNUM + "'"); + var head = ChinvoiceDAL.GetData("cm.INVOICESERIALNUM='" + INVOICESERIALNUM + "'"); var _r = ReadInvoice(head); @@ -1198,22 +1178,21 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin public DBResult ReadInvoice(ChInvoice_HangXin head) { - if (string.IsNullOrEmpty(head.INVOICESERIALNUM)) { + if (string.IsNullOrEmpty(head.INVOICESERIALNUM)) + { var result = new DBResult { Success = false, Message = "还未成功进行平台开票,无可读数据", Data = "" }; return result; } - //string method = "nuonuo.electronInvoice.CheckEInvoice"; - //var json = "{" + "\"invoiceSerialNum\":[\"" + head.INVOICESERIALNUM + "\"]" + "}"; - string method = "nuonuo.electronInvoice.queryInvoiceResult"; - var json = "{" + "\"orderNos\":[]," + "\"serialNos\":[\"" + head.INVOICESERIALNUM + "\"]" + "}"; + string method = "nuonuo.electronInvoice.CheckEInvoice"; + var json = "{" + "\"invoiceSerialNum\":[\"" + head.INVOICESERIALNUM + "\"]" + "}"; if (string.IsNullOrWhiteSpace(head.INVOICESERIALNUM)) { //如果流水号为空 则改为按业务编号读取 - //method = "nuonuo.electronInvoice.querySerialNum"; - json = "{" + "\"orderNos\":[\"" + head.BILLNO + "\"]," + "\"serialNos\":[]"+ "}"; + method = "nuonuo.electronInvoice.querySerialNum"; + json = "{" + "\"orderNo\":[\"" + head.BILLNO + "\"]" + "}"; } //读取业务 @@ -1226,7 +1205,8 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin BasicDataRefDAL.SaveLog(_r, "诺诺平台", "读取发票信息", "返回值"); var _return = dealresponse_Read(_r); - if (_return.code == "070101"|| _return.code == "070301") { + if (_return.code == "070101" || _return.code == "070301") + { //appkey与token问题 需要重新认证 //HangXinRequestHelper.clear(accessToken); var result = new DBResult(false, "需要重新认证", null); @@ -1239,34 +1219,25 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin var result = new DBResult(false, "需要联系诺诺平台开通相关权限", null); return result; } - + if (_return.code == "E0000") { //开票信息读取成功 - var returndate = ChinvoiceDAL.GetData( "cm.INVOICESERIALNUM='" + head.INVOICESERIALNUM + "'"); + var returndate = ChinvoiceDAL.GetData("cm.INVOICESERIALNUM='" + head.INVOICESERIALNUM + "'"); head = returndate; + //var invoiceSerialNum = _return.result[0].invoiceSerialNum; var info = _return.result[0]; - var result = new DBResult(); - - //如果,"statusMsg":"开票失败"返回错误 - if (info.statusMsg == "开票失败") { - return result.SetErrorInfo(info.statusMsg + ":" + info.failCause); - } - - //立即调用读取发票信息的方法 将返回值设置进head 并保存 //head.INVOICESERIALNUM = invoiceSerialNum; head.INVOICECODE = info.invoiceCode; - head.INVOICENO = info.invoiceNo; + head.INVOICENO = info.invoiceNum; head.EINVOICESTATE = info.status; - head.INVOICEINFOURL = info.pictureUrl; - head.INVOICEPDFURL = info.pdfUrl; - - var invdate = BasicDataRefDAL.Timestamp2Datetime(info.updateTime); + head.INVOICEINFOURL = info.invoiceImageUrl; + head.INVOICEPDFURL = info.invoiceFileUrl; - head.INVOICEMAKETIME = invdate.ToString("yyyy-MM-dd HH:mm:ss"); + head.INVOICEMAKETIME = info.invoiceDate; //if (!string.IsNullOrWhiteSpace(info.invoiceSerialNum)) //{ // head.INVOICESERIALNUM = info.invoiceSerialNum; @@ -1276,13 +1247,14 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin head.DbOperationType = DbOperationType.DbotUpd; head.ModelUIStatus = "E"; var modb = new ModelObjectDB(); - result = modb.Save(head); - //result.Message = info.resultMsg; + var result = modb.Save(head); + result.Message = info.resultMsg; - //if (info.resultMsg.Contains("开具结果:0,开具失败原因:开票异常")) { - // result.Message = "开票异常,请尝试重新连接税控盘、重新启动税控软件和诺诺客户端,然后再次读取发票信息;如仍显示此提示,请联系诺诺平台客服人员,并提供销方税号和此发票的流水号"; - //} + if (info.resultMsg.Contains("开具结果:0,开具失败原因:开票异常")) + { + result.Message = "开票异常,请尝试重新连接税控盘、重新启动税控软件和诺诺客户端,然后再次读取发票信息;如仍显示此提示,请联系诺诺平台客服人员,并提供销方税号和此发票的流水号"; + } return result; @@ -1290,87 +1262,87 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin else { - var msg = _return.code+":"+_return.describe; + var msg = _return.code + ":" + _return.describe; var result = new DBResult { Success = false, Message = DSWeb.TruckMng.Helper.JsonConvert.Serialize(msg), Data = "" }; return result; } } - //public DBResult ReadInvoice_BILLNO(ChInvoice_HangXin head) - //{ + public DBResult ReadInvoice_BILLNO(ChInvoice_HangXin head) + { - // //读取业务 - // string method = "nuonuo.electronInvoice.querySerialNum"; - // var json = "{" + "\"orderNo\":[\"" + head.BILLNO + "\"]" + "}"; + //读取业务 + string method = "nuonuo.electronInvoice.querySerialNum"; + var json = "{" + "\"orderNo\":[\"" + head.BILLNO + "\"]" + "}"; - // BasicDataRefDAL.SaveLog("URL=" + URL + ";appKey=" + appKey + ";appSecret=" + appSecret + ";accessToken=" + accessToken + ";taxnum=" + taxnum + ";method=" + method + ";content=" + json, "诺诺平台", "读取发票信息", "发送值"); - // string _r = NNOpenSDK.sendPostSyncRequest(URL, getSendid(), appKey, appSecret, accessToken, taxnum, method, json); - // BasicDataRefDAL.SaveLog(_r, "诺诺平台", "读取发票信息", "返回值"); - // var _return = dealresponse_Read(_r); + BasicDataRefDAL.SaveLog("URL=" + URL + ";appKey=" + appKey + ";appSecret=" + appSecret + ";accessToken=" + accessToken + ";taxnum=" + taxnum + ";method=" + method + ";content=" + json, "诺诺平台", "读取发票信息", "发送值"); + string _r = NNOpenSDK.sendPostSyncRequest(URL, getSendid(), appKey, appSecret, accessToken, taxnum, method, json); + BasicDataRefDAL.SaveLog(_r, "诺诺平台", "读取发票信息", "返回值"); + var _return = dealresponse_Read(_r); - // if (_return.code == "070101" || _return.code == "070301") - // { - // //appkey与token问题 需要重新认证 - // //HangXinRequestHelper.clear(accessToken); - // var result = new DBResult(false, "需要重新认证", null); - // return result; - // } - // if (_return.code == "070302") - // { - // //appkey与token问题 需要重新认证 - // //HangXinRequestHelper.clear(accessToken); - // var result = new DBResult(false, "需要联系诺诺平台开通相关权限", null); - // return result; - // } + if (_return.code == "070101" || _return.code == "070301") + { + //appkey与token问题 需要重新认证 + //HangXinRequestHelper.clear(accessToken); + var result = new DBResult(false, "需要重新认证", null); + return result; + } + if (_return.code == "070302") + { + //appkey与token问题 需要重新认证 + //HangXinRequestHelper.clear(accessToken); + var result = new DBResult(false, "需要联系诺诺平台开通相关权限", null); + return result; + } - // if (_return.code == "E0000") - // { - // //开票信息读取成功 - // var returndate = ChinvoiceDAL.GetData( "cm.INVOICESERIALNUM='" + head.INVOICESERIALNUM + "'"); - // head = returndate; - - // //var invoiceSerialNum = _return.result[0].invoiceSerialNum; - // var info = _return.result[0]; - // //立即调用读取发票信息的方法 将返回值设置进head 并保存 - // //head.INVOICESERIALNUM = invoiceSerialNum; - // head.INVOICECODE = info.invoiceCode; - // head.INVOICENO = info.invoiceNum; - // head.EINVOICESTATE = info.status; - // head.INVOICEINFOURL = info.invoiceImageUrl; - // head.INVOICEPDFURL = info.invoiceFileUrl; - - // head.INVOICEMAKETIME = info.invoiceDate; - // if (!string.IsNullOrWhiteSpace(info.invoiceSerialNum)) - // { - // head.INVOICESERIALNUM = info.invoiceSerialNum; - // } - // //head.REMARK = head.REMARK.Replace(info.remark,"")+ info.remark; + if (_return.code == "E0000") + { + //开票信息读取成功 + var returndate = ChinvoiceDAL.GetData("cm.INVOICESERIALNUM='" + head.INVOICESERIALNUM + "'"); + head = returndate; - // head.DbOperationType = DbOperationType.DbotUpd; - // head.ModelUIStatus = "E"; - // var modb = new ModelObjectDB(); - // var result = modb.Save(head); - // result.Message = info.resultMsg; + //var invoiceSerialNum = _return.result[0].invoiceSerialNum; + var info = _return.result[0]; + //立即调用读取发票信息的方法 将返回值设置进head 并保存 + //head.INVOICESERIALNUM = invoiceSerialNum; + head.INVOICECODE = info.invoiceCode; + head.INVOICENO = info.invoiceNum; + head.EINVOICESTATE = info.status; + head.INVOICEINFOURL = info.invoiceImageUrl; + head.INVOICEPDFURL = info.invoiceFileUrl; + head.INVOICEMAKETIME = info.invoiceDate; + if (!string.IsNullOrWhiteSpace(info.invoiceSerialNum)) + { + head.INVOICESERIALNUM = info.invoiceSerialNum; + } + //head.REMARK = head.REMARK.Replace(info.remark,"")+ info.remark; - // if (info.resultMsg.Contains("开具结果:0,开具失败原因:开票异常")) - // { - // result.Message = "开票异常,请尝试重新连接税控盘、重新启动税控软件和诺诺客户端,然后再次读取发票信息;如仍显示此提示,请联系诺诺平台客服人员,并提供销方税号和此发票的流水号"; - // } + head.DbOperationType = DbOperationType.DbotUpd; + head.ModelUIStatus = "E"; + var modb = new ModelObjectDB(); + var result = modb.Save(head); + result.Message = info.resultMsg; - // return result; - // } - // else - // { + if (info.resultMsg.Contains("开具结果:0,开具失败原因:开票异常")) + { + result.Message = "开票异常,请尝试重新连接税控盘、重新启动税控软件和诺诺客户端,然后再次读取发票信息;如仍显示此提示,请联系诺诺平台客服人员,并提供销方税号和此发票的流水号"; + } - // var msg = _return.code + ":" + _return.describe; - // var result = new DBResult { Success = false, Message = DSWeb.TruckMng.Helper.JsonConvert.Serialize(msg), Data = "" }; - // return result; + return result; - // } - //} + } + else + { + + var msg = _return.code + ":" + _return.describe; + var result = new DBResult { Success = false, Message = DSWeb.TruckMng.Helper.JsonConvert.Serialize(msg), Data = "" }; + return result; + + } + } public DBResult VoidInvoice(ChInvoice_HangXin head) { if (string.IsNullOrEmpty(head.INVOICESERIALNUM)) @@ -1382,16 +1354,16 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin //作废接口 string method = "nuonuo.electronInvoice.invoiceCancellation"; -// String content = "{" + -//"\"invoiceId\":\"19051413444101000011\"," + -//"\"invoiceCode\":\"033001800211\"," + -//"\"invoiceNo\":\"07912653\"" + -//"}"; + // String content = "{" + + //"\"invoiceId\":\"19051413444101000011\"," + + //"\"invoiceCode\":\"033001800211\"," + + //"\"invoiceNo\":\"07912653\"" + + //"}"; var json = "{" + - "\"invoiceId\":\""+ head.INVOICESERIALNUM + "\"," + - "\"invoiceCode\":\""+ head.INVOICECODE + "\"," + - "\"invoiceNo\":\""+ head.INVOICENO + "\"" + + "\"invoiceId\":\"" + head.INVOICESERIALNUM + "\"," + + "\"invoiceCode\":\"" + head.INVOICECODE + "\"," + + "\"invoiceNo\":\"" + head.INVOICENO + "\"" + "}"; BasicDataRefDAL.SaveLog("URL=" + URL + ";appKey=" + appKey + ";appSecret=" + appSecret + ";accessToken=" + accessToken + ";taxnum=" + taxnum + ";method=" + method + ";content=" + json, "诺诺平台", "发票作废", "发送值"); @@ -1403,9 +1375,9 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin { //作废请求成功 - var invoiceSerialNum = _return.result; + var invoiceSerialNum = _return.result.invoiceId; - //head.INVOICESERIALNUM = invoiceSerialNum; + head.INVOICESERIALNUM = invoiceSerialNum; head.ISDELETE = "true"; @@ -1419,7 +1391,7 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin else { - var msg = _return.code+_return.status + ":" + _return.describe+ _return.msg; + var msg = _return.code + _return.status + ":" + _return.describe + _return.msg; var result = new DBResult { Success = false, Message = DSWeb.TruckMng.Helper.JsonConvert.Serialize(msg), Data = "" }; return result; @@ -1431,7 +1403,8 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin /// /// /// - private KPResponse dealresponse_KP(string json) { + private KPResponse dealresponse_KP(string json) + { var result = new KPResponse(); result = DSWeb.TruckMng.Helper.JsonConvert.Deserialize(json.Trim('"')); @@ -1458,7 +1431,7 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin //private void DoSaveToken() //{ // if (HXTokenHelperList==null ||HXTokenHelperList.Count == 0) return; - + // SaveToken(); //} @@ -1545,7 +1518,7 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin // else { // BasicDataRefDAL.SaveLog(getUpdStr(), "诺诺平台", "保存Token", "SaveToken"); // } - + // if (i > 0) result = true; // return result; //} @@ -1556,8 +1529,9 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin /// TAXNUM,CODE,USERID,ACCESSTOKEN,REFRESHTOKEN,STARTTIME,SAVETIME,ERROR,ERROR_DESCRIPTION /// /// - private string getInsertStr() { - var result = string.Format(" insert into Invoice_HangXinToken values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}')", taxnum,code,userId,accessToken,refreshToken, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),error,error_description); + private string getInsertStr() + { + var result = string.Format(" insert into Invoice_HangXinToken values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}')", taxnum, code, userId, accessToken, refreshToken, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), error, error_description); return result; } @@ -1572,7 +1546,8 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin } - public class PortTokenmb { + public class PortTokenmb + { public string message { get; set; } public string status { get; set; } } @@ -1619,7 +1594,7 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin public string error_description { get; set; } public string error { get; set; } } - + [JsonObject] public class oauthUser : ModelObjectBillBody { @@ -1642,205 +1617,12 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin public KPResult result { get; set; } } - public class Result - { - /// - /// 深圳市宝安区兴围工业一路17-F105 电话:13692121010 - /// - public string address { get; set; } - /// - /// 中国银行深圳机场支行 749763304324 - /// - public string bankAccount { get; set; } - /// - /// 吴彩婷 - /// - public string checker { get; set; } - /// - /// 吴彩婷 - /// - public string clerk { get; set; } - /// - /// - /// - public string clerkId { get; set; } - /// - /// - /// - public long createTime { get; set; } - /// - /// - /// - public string deptId { get; set; } - /// - /// - /// - public string extensionNumber { get; set; } - /// - /// - /// - public string imgUrls { get; set; } - /// - /// - /// - public long invoiceDate { get; set; } - /// - /// - /// - public string invoiceType { get; set; } - /// - /// - /// - public string listFlag { get; set; } - /// - /// - /// - public string listName { get; set; } - /// - /// - /// - public string notifyEmail { get; set; } - /// - /// - /// - public string ofdUrl { get; set; } - /// - /// - /// - public string oldInvoiceCode { get; set; } - /// - /// - /// - public string oldInvoiceNo { get; set; } - /// - /// - /// - public string orderAmount { get; set; } - /// - /// 吴彩婷 - /// - public string payee { get; set; } - /// - /// - /// - public string phone { get; set; } - /// - /// - /// - public int productOilFlag { get; set; } - /// - /// - /// - public string proxyInvoiceFlag { get; set; } - /// - /// - /// - public string remark { get; set; } - /// - /// - /// - public string requestSrc { get; set; } - /// - /// 上海敬运国际物流有限公司 - /// - public string saleName { get; set; } - /// - /// 中国银行北外滩支行-435168156076 - /// - public string salerAccount { get; set; } - /// - /// 上海市虹口区吴淞路218号宝矿大厦1207室 - /// - public string salerAddress { get; set; } - /// - /// - /// - public string salerTaxNum { get; set; } - /// - /// - /// - public string salerTel { get; set; } - /// - /// - /// - public int specificFactor { get; set; } - /// - /// - /// - public string telephone { get; set; } - /// - /// - /// - public string terminalNumber { get; set; } - /// - /// - /// - public long updateTime { get; set; } - /// - /// - /// - public string serialNo { get; set; } - /// - /// - /// - public string orderNo { get; set; } - /// - /// - /// - public string status { get; set; } - /// - /// 开票失败 - /// - public string statusMsg { get; set; } - /// - /// 请将客户端开票模式切换为【网页开票模式】 - /// - public string failCause { get; set; } - /// - /// - /// - public string pdfUrl { get; set; } - /// - /// - /// - public string pictureUrl { get; set; } - /// - /// - /// - public string invoiceCode { get; set; } - /// - /// - /// - public string invoiceNo { get; set; } - /// - /// - /// - public string exTaxAmount { get; set; } - /// - /// - /// - public string taxAmount { get; set; } - /// - /// 深圳卓越顺达货运代理有限公司 - /// - public string payerName { get; set; } - /// - /// - /// - public string payerTaxNo { get; set; } - /// - /// 增值税电子普通发票 - /// - public string invoiceKind { get; set; } - } - - [JsonObject] ///解析开票命令返回值内的result public class KPResult { public string invoiceSerialNum { get; set; } - //public string invoiceId { get; set; } + public string invoiceId { get; set; } } @@ -1870,7 +1652,7 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin public List result { get; set; } */ - public List result { get; set; } + public List result { get; set; } } [JsonObject] ///用于解析“读取发票信息”方法返回的发票信息 @@ -1895,7 +1677,7 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin #endregion #region public Fields - + public string orderNo { get { return _orderNo; }