diff --git a/DSWeb/Areas/Account/Controllers/Chfee_invoice_HangXinController.cs b/DSWeb/Areas/Account/Controllers/Chfee_invoice_HangXinController.cs index e1b6f34a..2579a56b 100644 --- a/DSWeb/Areas/Account/Controllers/Chfee_invoice_HangXinController.cs +++ b/DSWeb/Areas/Account/Controllers/Chfee_invoice_HangXinController.cs @@ -33,6 +33,10 @@ using iTextSharp.text; using iTextSharp.text.pdf; using DSWeb.MvcShipping.DAL.MsSysInvInterFaceSet; using DSWeb.Common.Helper; +using DSWeb.MvcShipping.DAL.MsBaseInfoDAL; +using System.ServiceModel.Configuration; +using DSWeb.Areas.MvcShipping.Helper; +using DSWeb.SoftMng.Model; namespace DSWeb.Areas.Account.Controllers { @@ -106,7 +110,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() }); @@ -120,7 +124,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; @@ -141,7 +145,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"]); @@ -160,9 +164,10 @@ namespace DSWeb.Areas.Account.Controllers head.INVOICETYPE = 2; head.INVOICETYPEREF = "申请发票"; } - else { + else + { head.INVOICETYPE = 1; - head.INVOICETYPEREF = "自由发票"; + head.INVOICETYPEREF = "自由发票"; } } @@ -186,7 +191,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() }); @@ -222,7 +227,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() }); @@ -248,7 +253,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() }); @@ -305,7 +310,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(); } @@ -320,12 +326,14 @@ namespace DSWeb.Areas.Account.Controllers headData.CUSTBANK = dsHSCODE.Tables[0].Rows[0]["Rmbbank"].ToString(); } - + } } } + if (headData.CUSTBANK == null) headData.CUSTBANK = ""; + var isPost = true; var errorstr = ""; if (headData.INVOICENO != "") @@ -342,10 +350,14 @@ namespace DSWeb.Areas.Account.Controllers var INVITERFACE = MsSysInvInterFaceSetDAL.GetData("INVOICELINE='" + headData.INVOICELINEREF + "'", ""); if (INVITERFACE.INVITERFACE == "") headData.INVITERFACE = INVITERFACE.INVITERFACE; - else headData.INVITERFACE = "诺诺发票接口"; + 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"; @@ -356,6 +368,19 @@ namespace DSWeb.Areas.Account.Controllers isPost = false; errorstr = "客户电话长度不允许超过80"; } + 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) + { + isPost = false; + errorstr = "银行及账号于收款单位和币别不一致,请检查"; + + } + + } + if (isPost) @@ -366,8 +391,6 @@ namespace DSWeb.Areas.Account.Controllers headData.CUSTBANK = headData.CUSTBANK.Trim(); headData.REMARK = headData.REMARK.Trim(); - - var BILLNO = headData.BILLNO; var modb = new ModelObjectDB(); DBResult result = ChinvoiceDAL.SaveInvDetail(headData.GID, bodyList); @@ -393,15 +416,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发票引入费用 权限 @@ -412,7 +436,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); } @@ -465,13 +489,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) }; @@ -484,13 +508,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) }; } @@ -500,17 +525,23 @@ namespace DSWeb.Areas.Account.Controllers var jsonRespose1 = new JsonResponse { Success = false, Message = "已经实际开出的发票业务不能删除" }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose1) }; } + if (headData.EINVOICESTATEREF == "开票中") + { + var jsonRespose1 = new JsonResponse { Success = false, Message = "当前发票状态不允许删除" }; + return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose1) }; + + } result = SetInvoiceFee(headData); 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); } @@ -531,7 +562,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) { @@ -554,6 +585,13 @@ namespace DSWeb.Areas.Account.Controllers // var jsonRespose = new JsonResponse { Success =false, Message = "您还不具备针对这条业务的‘发票开出锁定’权限" }; // return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; //} + T_ALL_DA T_ALL_DA = new T_ALL_DA(); + var strCT = T_ALL_DA.GetStrSQL("CT", "select COUNT(*) CT from ch_fee_do_payapplication where PAYBILLNO='" + headData.BILLNO + "'"); + if (strCT != "0" && strCT != "") + { + var jsonRespose2 = new JsonResponse { Success = false, Message = "已发票结算,不允许作废" }; + return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) }; + } return DeleteUp(headData); } @@ -565,6 +603,13 @@ namespace DSWeb.Areas.Account.Controllers // var jsonRespose1 = new JsonResponse { Success = false, Message = "您还不具备针对这条业务的‘发票开出锁定’权限" }; // return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose1) }; //} + T_ALL_DA T_ALL_DA = new T_ALL_DA(); + var strCT = T_ALL_DA.GetStrSQL("CT", "select COUNT(*) CT from ch_fee_do_payapplication where PAYBILLNO='" + headData.BILLNO + "'"); + if (strCT != "0" && strCT != "") + { + var jsonRespose2 = new JsonResponse { Success = false, Message = "已发票结算,不允许作废" }; + return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) }; + } DBResult result; result = SetInvoiceFee(headData); @@ -596,10 +641,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 }; @@ -618,69 +663,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 锁定和撤销锁定 @@ -729,7 +775,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 @@ -759,8 +806,10 @@ namespace DSWeb.Areas.Account.Controllers { result.Success = false; result.Message = "没有可以打印的发票文件"; + return result.getContentReult(); } - else { + else + { //pdflist.OrderBy(o => o); pdflist.Sort(delegate (string p1, string p2) @@ -779,17 +828,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); @@ -843,22 +894,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 }; @@ -901,7 +952,8 @@ namespace DSWeb.Areas.Account.Controllers #region 航信接口调用 - public ContentResult test(string str) { + public ContentResult test(string str) + { var result = new KPResponse(); @@ -918,7 +970,7 @@ namespace DSWeb.Areas.Account.Controllers }; return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; - + } public ActionResult test2(string str) @@ -947,24 +999,24 @@ namespace DSWeb.Areas.Account.Controllers // return View(); //} - private JsonResponse checkinfo(string BILLNO,string redirecturl) { + private JsonResponse checkinfo(string BILLNO, string redirecturl, string redReason = "") + { 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)) { jsonRespose.Success = false; jsonRespose.Message = "发票种类不能为空!"; - } - if (head.BILLNO!="") + if (head.BILLNO != "") { if (string.IsNullOrEmpty(head.INVITERFACE)) { @@ -972,11 +1024,50 @@ namespace DSWeb.Areas.Account.Controllers if (INVITERFACE.INVITERFACE != "") head.INVITERFACE = INVITERFACE.INVITERFACE; else head.INVITERFACE = "诺诺发票接口"; + + if (head.INVITERFACE == "诺诺全电发票") + { + if (!string.IsNullOrWhiteSpace(redReason)) + { + head.redReason = redReason; + } + else + { + jsonRespose.Success = false; + jsonRespose.Message = "必须选择冲红理由!"; + return jsonRespose; + } + } + + head.DbOperationType = DbOperationType.DbotUpd; head.ModelUIStatus = "E"; var modb = new ModelObjectDB(); result = modb.Save(head); } + else + { + if (head.INVITERFACE == "诺诺全电发票") + { + 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]; jsonRespose.Data = head; } @@ -997,7 +1088,7 @@ namespace DSWeb.Areas.Account.Controllers else { - if (head.INVITERFACE == "诺诺发票接口"|| head.INVITERFACE =="") + if (head.INVITERFACE == "诺诺发票接口" || head.INVITERFACE == "") { //如果该税号的token需要 返回认证窗口 var hx = HangXinRequestHelper.getHelper(head.TAXCODE); @@ -1008,16 +1099,17 @@ namespace DSWeb.Areas.Account.Controllers jsonRespose.Message = hx.ERRORMSG; return jsonRespose; } - HangXinRequestHelper.redirectUri = getRedirecturl(redirecturl); + HangXinRequestHelper.redirectUri = redirecturl; //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; } } @@ -1025,13 +1117,15 @@ namespace DSWeb.Areas.Account.Controllers } - private JsonResponse TokenPage() { + private JsonResponse TokenPage() + { var jsonRespose = new JsonResponse { Success = true, Message = "", Data = "" }; jsonRespose.Success = false; jsonRespose.Message = "需要认证诺诺用户名和密码"; - var newwindowurl = "https://open.jss.com.cn/authorization.html?client_id=" + HangXinRequestHelper.appSecret + "&response_type=code&redirect_uri=" + HangXinRequestHelper.redirectUri + "&appKey=" + HangXinRequestHelper.appKey + ""; + var 原诺诺第三方方式开票 = HangXinRequestHelper.getHelper(""); + var newwindowurl = "https://open.jss.com.cn/authorization.html?client_id=" + 原诺诺第三方方式开票.appSecret + "&response_type=code&redirect_uri=" + HangXinRequestHelper.redirectUri + "&appKey=" + 原诺诺第三方方式开票.appKey + ""; jsonRespose.Data = newwindowurl; return jsonRespose; } @@ -1041,7 +1135,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(); @@ -1053,13 +1147,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) @@ -1074,7 +1170,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) @@ -1084,7 +1180,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}]}"*/ @@ -1120,7 +1216,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; } @@ -1139,7 +1235,36 @@ namespace DSWeb.Areas.Account.Controllers } } - } + } + else if (head.INVITERFACE == "诺诺全电发票") + { + var hx = 诺诺全电发票.getHelper(head.TAXCODE); + if (!hx.CanUse) + { + jsonRespose.Success = false; + jsonRespose.Message = hx.ERRORMSG; + return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; + } + + + if (!string.IsNullOrEmpty(head.INVOICESERIALNUM)) + {//如果该发票流水号不为空 + result = hx.ReadInvoice(head); + + } + else + { + + //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); + } + + } + } returndate = ChinvoiceDAL.GetData(" BILLNO='" + head.BILLNO + "'"); if (returndate.EINVOICESTATE == "2" && returndate.BILLSTATUS == 0) @@ -1158,7 +1283,7 @@ namespace DSWeb.Areas.Account.Controllers jsonRespose.Message = result.Message; jsonRespose.Data = returndate; } - + return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } @@ -1172,7 +1297,7 @@ namespace DSWeb.Areas.Account.Controllers { //如果已有pdf地址 则直接返回 - var headdata = ChinvoiceDAL.GetData(" cm.BILLNO='"+BILLNO+"'"); + var headdata = ChinvoiceDAL.GetData(" cm.BILLNO='" + BILLNO + "'"); @@ -1185,7 +1310,7 @@ namespace DSWeb.Areas.Account.Controllers } else { - if (headdata.INVITERFACE == "诺诺发票接口"|| headdata.INVITERFACE =="") + if (headdata.INVITERFACE == "诺诺发票接口" || headdata.INVITERFACE == "") { result = Do_NNReadInv(BILLNO, redirecturl); } @@ -1194,12 +1319,25 @@ 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 + "'"); } + else if (headdata.INVITERFACE == "诺诺全电发票") + { + //诺诺全电发票的红票 读取其实是读取 红字确认单查询接口 + if (headdata.PTORRED == "1") + { + result = Do_NuoNuoQuanDianReadInv(BILLNO); + } + if (headdata.PTORRED == "2") + { + var _r = NNRedConfirm_Read(BILLNO); + return BasicDataRefDAL.GetContentResult(_r); + } + } } return result.getContentReult(); } @@ -1237,7 +1375,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; @@ -1254,7 +1392,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(); @@ -1326,7 +1465,86 @@ namespace DSWeb.Areas.Account.Controllers return jsonRespose; } - public static string getRedirecturl(string redirecturl) { + public JsonResponse Do_NuoNuoQuanDianReadInv(string BILLNO) + { + //var hx = HangXinRequestHelper.getHelper(taxnum); + + //var result = new DBResult(); + + //var detail = new List + var jsonRespose = new JsonResponse { Success = false, Message = "", Data = "" }; + + + //首先判断数据完整性与合法性 + var checkresult = checkCanRead(BILLNO); + + if (!checkresult.Success) return checkresult; + + var head = (ChInvoice_HangXin)checkresult.Data; + var hx = 诺诺全电发票.getHelper(head.TAXCODE); + if (!hx.CanUse) + { + jsonRespose.Success = false; + jsonRespose.Message = hx.ERRORMSG; + return jsonRespose; + } + if (hx.accessToken == "") + { + BasicDataRefDAL.SaveLog("NNReadInv;税号" + head.TAXCODE + "的 accessToken为空", "", "诺诺平台", "返回认证窗口"); + var _r = TokenPage(); + return _r; + } + var result = hx.ReadInvoice(head); + + if (!result.Success) + { + return new JsonResponse { Success = result.Success, Message = result.Message, Data = "" }; ; + } + + //if (result.Message == "需要重新认证") + //{ + // //HangXinRequestHelper.clear(hx.accessToken); + // BasicDataRefDAL.SaveLog("ReadInvoice 反回‘需要重新认证’", "", "诺诺平台", "返回认证窗口"); + // var _r = TokenPage(); + // return _r; + //} + + var 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; + + jsonRespose = new JsonResponse(result); + + return jsonRespose; + } + + public static string getRedirecturl(string redirecturl) + { return redirecturl; } @@ -1385,7 +1603,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 = "" }; @@ -1423,7 +1642,29 @@ namespace DSWeb.Areas.Account.Controllers - var hx = HangXinRequestHelper.getHelper(head.TAXCODE); + var hx = new HangXinRequestHelper(); + + + + if (head.INVITERFACE == "诺诺发票接口" || head.INVITERFACE == "") + { + hx = HangXinRequestHelper.getHelper(head.TAXCODE); + } + else if (head.INVITERFACE == "瑞宏发票接口") + { + + + } + else if (head.INVITERFACE == "诺诺全电发票") + { + //hx = 诺诺全电发票.getHelper(head.TAXCODE); + //jsonRespose.Success = false; + //jsonRespose.Message = "全电发票没有作废操作,请执行冲红操作。"; + //return jsonRespose; + + + } + if (!hx.CanUse) { jsonRespose.Success = false; @@ -1455,7 +1696,7 @@ namespace DSWeb.Areas.Account.Controllers /// /// /// - public ContentResult NNSetRed(string bill, string redirecturl) + public ContentResult NNSetRed(string bill, string redirecturl, string redReason = "") { //首先判断是否有 modInvLock 发票开出锁定 var result = new DBResult(); @@ -1465,7 +1706,7 @@ namespace DSWeb.Areas.Account.Controllers //首先判断数据完整性与合法性 及检查平台认证 - var checkresult = checkinfo(bill, redirecturl); + var checkresult = checkinfo(bill, redirecturl, redReason); //被冲红的蓝票信息 var BlueInvoice = ChinvoiceDAL.GetData(" cm.billno='" + bill + "'"); @@ -1478,12 +1719,33 @@ namespace DSWeb.Areas.Account.Controllers { var head = (ChInvoice_HangXin)checkresult.Data; + var BlueHead = head; - if (string.IsNullOrEmpty(head.INVOICENO) || string.IsNullOrEmpty(head.INVOICECODE)) { - jsonRespose.Success = false; - jsonRespose.Message = "该发票没有发票号和发票代码,无法进行冲红。"; + if (head.INVITERFACE == "诺诺全电发票") + { + //全电发票没有发票代码 + if (string.IsNullOrEmpty(head.INVOICENO)) + { + jsonRespose.Success = false; + jsonRespose.Message = "该电子发票没有发票号,无法进行冲红。"; - return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; + return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; + } + //else { + // return NNSetRed_QuanDian(bill); + //} + + } + + if (head.INVITERFACE != "诺诺全电发票") + { + if (string.IsNullOrEmpty(head.INVOICENO) || string.IsNullOrEmpty(head.INVOICECODE)) + { + jsonRespose.Success = false; + jsonRespose.Message = "该发票没有发票号和发票代码,无法进行冲红。"; + + return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; + } } var beRedBillNo = head.BILLNO; @@ -1495,8 +1757,10 @@ namespace DSWeb.Areas.Account.Controllers var detailList = ChinvoiceDAL.GetDetailList("PID='" + head.GID + "'"); + var redhead = AutoMapperHelper.MapTo(head); + //如果已经存在一张相应的红票,则将现在这个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; @@ -1509,60 +1773,103 @@ namespace DSWeb.Areas.Account.Controllers } else { - - //将该head改成一个新的发票信息 - //将发票明细也同样处理 - - head.GID = System.Guid.NewGuid().ToString(); - head.BILLNO = PubSysDAL.GetBillNo("0308"); - head.PTORRED = "2"; // 开票类型 红票 - - head.INVOICECODE = ""; - head.INVOICENO = ""; - head.EINVOICESTATE = "0"; - head.INVOICESERIALNUM = ""; - //head.BILLSTATUS = 0; - head.REDCODE = RedCode; - head.REDNUM = RedNo; - head.INVAMOUNT = head.INVAMOUNT * -1; - head.INVOICEPDFURL = ""; - head.INVOICEINFOURL = ""; - - head.DbOperationType = DbOperationType.DbotIns; - head.ModelUIStatus = "I"; - head.BILLSTATUS = 1; - foreach (var detail in detailList) + if (head.INVITERFACE != "诺诺全电发票") { - //数量 税额 含税金额 不含税金额 取负数 - detail.SetRed(); - detail.PID = "*"; + //将该head改成一个新的发票信息 + //将发票明细也同样处理 + + head.GID = System.Guid.NewGuid().ToString(); + head.BILLNO = PubSysDAL.GetBillNo("0308"); + head.PTORRED = "2"; // 开票类型 红票 + + head.INVOICECODE = ""; + head.INVOICENO = ""; + head.EINVOICESTATE = "0"; + head.INVOICESERIALNUM = ""; + //head.BILLSTATUS = 0; + head.REDCODE = RedCode; + head.REDNUM = RedNo; + head.INVAMOUNT = head.INVAMOUNT * -1; + head.INVOICEPDFURL = ""; + head.INVOICEINFOURL = ""; + + head.DbOperationType = DbOperationType.DbotIns; + head.ModelUIStatus = "I"; + head.BILLSTATUS = 1; + foreach (var detail in detailList) + { + //数量 税额 含税金额 不含税金额 取负数 + detail.SetRed(); + detail.PID = "*"; + } + + #region SR2020060200007 红票清空推送模式和推送邮箱 + head.PUSHMODE = "-1"; + head.PUSHEMAIL = ""; + head.PUSHMOBILE = "0"; + #endregion + head.REMARK = REDREMARK(head.REMARK); } - #region SR2020060200007 红票清空推送模式和推送邮箱 - head.PUSHMODE = "-1"; - head.PUSHEMAIL = ""; - head.PUSHMOBILE = "0"; - #endregion - head.REMARK = REDREMARK(head.REMARK); + if (head.INVITERFACE == "诺诺全电发票") + { + //redhead仅用于向诺诺全电红字申请单接口发送用 + //redhead = AutoMapperHelper.MapTo(head); + + + + redhead.GID = System.Guid.NewGuid().ToString(); + redhead.BILLNO = PubSysDAL.GetBillNo("0308"); + redhead.PTORRED = "2"; // 开票类型 红票 + redhead.redReason = redReason; + + redhead.REDCODE = RedCode; + redhead.REDNUM = RedNo; + redhead.INVAMOUNT = redhead.INVAMOUNT * -1; + redhead.INVOICEPDFURL = ""; + redhead.INVOICEINFOURL = ""; + + redhead.DbOperationType = DbOperationType.DbotIns; + redhead.ModelUIStatus = "I"; + redhead.BILLSTATUS = 1; + foreach (var detail in detailList) + { + //数量 税额 含税金额 不含税金额 取负数 + detail.SetRed(); + detail.PID = "*"; + } + + redhead.REMARK = REDREMARK_Quandian(redhead); + + //红字申请单申请编号 即为发票业务编号 到时候红票的订单编号也是这个 + // + head.billUuid = redhead.BILLNO; + } } var modb = new ModelObjectDB(); - result = ChinvoiceDAL.SaveInvDetail(head.GID, detailList); - if (result.Success == true) + + if (head.INVITERFACE != "诺诺全电发票") { + //一般的红票业务此时保存红票信息 - result = modb.Save(head); - //ChinvoiceDAL.UpdateInvNoUse(headData.INVOICENO, Convert.ToString(Session["USERID"]),headData.BILLNO); - //if (headData.EXCHANGERATE != 0) - //{ - // ChinvoiceDAL.updateFeeTax(headData.BILLNO, headData.EXCHANGERATE); + 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); - }; + //} + + }; + } 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) @@ -1605,7 +1912,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) @@ -1620,6 +1928,14 @@ namespace DSWeb.Areas.Account.Controllers result = SetInvoiceFee(BlueInvoice); } } + else if (head.INVITERFACE == "诺诺全电发票") + { + var hx = 诺诺全电发票.getHelper(head.TAXCODE); + + result = hx.PostRedConfirm(redhead, ref head, detailList); + //诺诺全电票根据红字申请单的结果读取确认单 + modb.Save(head); + } @@ -1631,6 +1947,39 @@ namespace DSWeb.Areas.Account.Controllers return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } + /// + /// 诺诺全电发票 读取红字申请单 + /// + /// + /// + public DBResult NNRedConfirm_Read(string BILLNO) + { + ChInvoice_HangXin head = ChinvoiceDAL.GetData("cm.BILLNO='" + BILLNO + "'"); + + var result = new DBResult(); + + var hx = 诺诺全电发票.getHelper(head.TAXCODE); + if (!hx.CanUse) + { + result.SetErrorInfo(hx.ERRORMSG); + return result; + } + + result = hx.ReadRedConfirm(ref head); + + if (!result.Success) { return result; } + else + { + var _r = Do_NuoNuoQuanDianReadInv(head.BILLNO); + + result.Success = _r.Success; + result.Message = _r.Message; + result.Data = _r.Data; + } + + return result; + } + /// /// 红票票面备注 固定追加 /// 对应正数发票代码:037021900111号码:84769822 @@ -1639,18 +1988,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) { @@ -1660,6 +2012,17 @@ namespace DSWeb.Areas.Account.Controllers } } + private string REDREMARK_Quandian(ChInvoice_HangXin head) + { + // + + var 购方信息 = " 购方账号:" + head.CUSTBANK; + var 销方信息 = " 销方账号:" + head.ACCOUNT; + head.REMARK += 购方信息 + 销方信息; + + return head.REMARK; + } + /// @@ -1667,13 +2030,18 @@ 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 (head.ISFRINV) + { + return result; + } 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)) { @@ -1724,7 +2092,7 @@ namespace DSWeb.Areas.Account.Controllers /// /// /// - private JsonResponse checkCanRead(string BILLNO, string redirecturl) + private JsonResponse checkCanRead(string BILLNO, string redirecturl = "") { var result = new DBResult(); @@ -1745,27 +2113,31 @@ namespace DSWeb.Areas.Account.Controllers jsonRespose.Message = "没有找到可以开票的发票信息,可能是权限不足或登录信息丢失。"; } - //如果该税号的token需要 返回认证窗口 - var hx = HangXinRequestHelper.getHelper(head.TAXCODE); - if (!hx.CanUse) - { - jsonRespose.Success = false; - jsonRespose.Message = hx.ERRORMSG; - return jsonRespose; - } - HangXinRequestHelper.redirectUri = getRedirecturl(redirecturl); - if (hx.needStart) + if (redirecturl != "") { - BasicDataRefDAL.SaveLog("checkinfo;BILLNO=" + BILLNO, "", "诺诺平台", "返回认证窗口"); - jsonRespose = TokenPage(); - } + //如果该税号的token需要 返回认证窗口 + var hx = HangXinRequestHelper.getHelper(head.TAXCODE); + if (!hx.CanUse) + { + jsonRespose.Success = false; + jsonRespose.Message = hx.ERRORMSG; + return jsonRespose; + } + HangXinRequestHelper.redirectUri = getRedirecturl(redirecturl); + if (hx.needStart) + { + BasicDataRefDAL.SaveLog("checkinfo;BILLNO=" + BILLNO, "", "诺诺平台", "返回认证窗口"); + jsonRespose = TokenPage(); + } + } return jsonRespose; } - private void setErrorMessage(ref DBResult r,string message) { + private void setErrorMessage(ref DBResult r, string message) + { r.setMessage(false, message); } @@ -1785,11 +2157,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); @@ -1806,7 +2178,7 @@ namespace DSWeb.Areas.Account.Controllers return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; } - #endregion + #endregion #region 发票票册 @@ -1821,7 +2193,7 @@ namespace DSWeb.Areas.Account.Controllers public ContentResult GetBookData(string handle, string condition) { - ChInvoiceBook_HangXin head = null; + ChInvoiceBook_HangXin head = null; if (handle == "edit") { @@ -1874,7 +2246,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(); @@ -1988,7 +2360,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); @@ -2026,8 +2398,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); @@ -2036,7 +2410,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")); @@ -2049,7 +2424,8 @@ namespace DSWeb.Areas.Account.Controllers resultlist.Add(resultdata); } } - else { + else + { resultlist.Add(data); } } @@ -2068,7 +2444,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); @@ -2155,8 +2531,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); @@ -2164,7 +2540,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(); @@ -2172,7 +2548,8 @@ namespace DSWeb.Areas.Account.Controllers var P2Data = new BaseTableMC(); - if (P2DataList.Count() > 0) { + if (P2DataList.Count() > 0) + { P2Data = P2DataList[0]; } @@ -2180,7 +2557,8 @@ namespace DSWeb.Areas.Account.Controllers { //查看是否已被使用 如是则返回错误并结束 var isexists = CheckExists(" BSNO='" + headData.BSNO + "' "); - if (!isexists.Success) { + if (!isexists.Success) + { return isexists.getContentReult(); } @@ -2190,7 +2568,7 @@ namespace DSWeb.Areas.Account.Controllers localData.OPERATOR = Convert.ToString(Session["USERID"]); localData.OPERATETIME = DateTime.Now; localData.DbOperationType = DbOperationType.DbotIns; - + } else if (opstatus == "edit") { @@ -2204,7 +2582,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); @@ -2214,8 +2592,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(); @@ -2240,10 +2618,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)) @@ -2251,13 +2630,16 @@ namespace DSWeb.Areas.Account.Controllers result.Success = false; result.Message = "该发票已经被使用!"; } - else { + else + { result.Success = true; } return result; } #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 2e86770c..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)) { @@ -84,7 +84,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin strSql.Append(",(select top 1 (select ShowName from [user] where GID=ap.applicant) APPLICANT from ch_fee_invoiceapplication ap where invbillno=cm.BILLNO) APPLICANT"); strSql.Append(",SALECORPID,(select [NAME] from [company] where GID=cm.SALECORPID) as SALECORP"); - strSql.Append(",CUSTTEL,CUSTADDR,PTORRED,REDCODE,REDNUM,PUSHMODE,PUSHMOBILE,PUSHEMAIL,INVOICELINE,EINVOICESTATE,INVOICEINFOURL,INVOICEPDFURL,INVOICESERIALNUM,INVOICECODE"); + strSql.Append(",CUSTTEL,CUSTADDR,PTORRED,REDCODE,REDNUM,PUSHMODE,PUSHMOBILE,PUSHEMAIL,INVOICELINE,EINVOICESTATE,INVOICEINFOURL,INVOICEPDFURL,INVOICESERIALNUM,INVOICECODE,ISFRINV"); strSql.Append(",dbo.F_getEnumValue(0,80001,cm.PTORRED) as PTORREDREF"); strSql.Append(",dbo.F_getEnumValue(0,80002,cm.PUSHMODE) as PUSHMODEREF"); strSql.Append(",dbo.F_getEnumValue(0,80003,cm.INVOICELINE) as INVOICELINEREF"); @@ -95,6 +95,11 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin strSql.Append(",(select ADDRESS from [company] where gid=cm.SALECORPID) ADDRESS"); strSql.Append(",(select BILLRISES from [company] where gid=cm.SALECORPID) BILLRISES"); strSql.Append(",PAYEE,CHECKER,SETRED,INVITERFACE"); + + strSql.Append(",buyerManagerName,managerCardType,managerCardNo"); + + strSql.Append(",redReason,billInfoNo,billUUid"); + strSql.Append(" FROM ch_fee_invoice cm where 1=1 "); if (!string.IsNullOrEmpty(strCondition)) @@ -173,7 +178,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin strSql.Append(",(select top 1 (select ShowName from [user] where GID=ap.applicant) APPLICANT from ch_fee_invoiceapplication ap where invbillno=cm.BILLNO) APPLICANT"); strSql.Append(",SALECORPID,(select [NAME] from [company] where GID=cm.SALECORPID) as SALECORP"); - strSql.Append(",CUSTTEL,CUSTADDR,PTORRED,REDCODE,REDNUM,PUSHMODE,PUSHMOBILE,PUSHEMAIL,INVOICELINE,EINVOICESTATE,INVOICEINFOURL,INVOICEPDFURL,INVOICESERIALNUM,INVOICECODE"); + strSql.Append(",CUSTTEL,CUSTADDR,PTORRED,REDCODE,REDNUM,PUSHMODE,PUSHMOBILE,PUSHEMAIL,INVOICELINE,EINVOICESTATE,INVOICEINFOURL,INVOICEPDFURL,INVOICESERIALNUM,INVOICECODE,ISFRINV"); strSql.Append(",dbo.F_getEnumValue(0,80001,cm.PTORRED) as PTORREDREF"); strSql.Append(",dbo.F_getEnumValue(0,80002,cm.PUSHMODE) as PUSHMODEREF"); strSql.Append(",dbo.F_getEnumValue(0,80003,cm.INVOICELINE) as INVOICELINEREF"); @@ -185,6 +190,8 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin strSql.Append(",(select BILLRISES from [company] where gid=cm.SALECORPID) BILLRISES"); strSql.Append(",PAYEE,CHECKER,SETRED,INVITERFACE"); + strSql.Append(",buyerManagerName,managerCardType,managerCardNo"); + strSql.Append(" FROM ch_fee_invoice cm where 1=1 "); if (!string.IsNullOrEmpty(strCondition)) @@ -209,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]; @@ -252,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"]); @@ -263,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"]); @@ -272,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"]); @@ -299,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"]); @@ -335,6 +342,16 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin data.CREATEUSERREF = Convert.ToString(reader["CREATEUSERREF"]); if (reader["CREATETIME"] != DBNull.Value) data.CREATETIME = Convert.ToDateTime(reader["CREATETIME"]).ToString("yyyy-MM-dd HH:mm:ss"); + if (reader["ISFRINV"] != DBNull.Value) + data.ISFRINV = Convert.ToBoolean(reader["ISFRINV"]); + + data.redReason = Convert.ToString(reader["redReason"]); + data.billInfoNo = Convert.ToString(reader["billInfoNo"]); + data.billUuid = Convert.ToString(reader["billUuid"]); + + data.buyerManagerName = Convert.ToString(reader["buyerManagerName"]); + data.managerCardType = Convert.ToString(reader["managerCardType"]); + data.managerCardNo = Convert.ToString(reader["managerCardNo"]); #endregion headList.Add(data); } @@ -361,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; @@ -376,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) @@ -408,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) { @@ -435,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); @@ -456,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()) { @@ -489,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)"); @@ -517,12 +536,12 @@ 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 "); strSql.Append(",c.FEETYPE,c.CUSTOMERNAME as FEEOBJNAME,(CASE C.FEETYPE WHEN 1 THEN '收' ELSE '付' END) AS FEETYPEREF,(SELECT EXCHANGERATE from ch_fee where GID=c.FEEID) ORIGEXCHANGERATE"); - strSql.Append(" ,b.OPLBNAME,b.BSSTATUS,b.ACCDATE,b.MBLNO,b.HBLNO,b.CUSTNO"); + strSql.Append(" ,b.OPLBNAME,b.BSSTATUS,b.ACCDATE,b.MBLNO,b.HBLNO,b.CUSTNO,b.ORDERNO"); strSql.Append(",b.CUSTOMERNAME"); strSql.Append(",b.VESSEL,b.VOYNO,b.ETD,b.PORTLOAD"); strSql.Append(",b.PORTDISCHARGE,b.DESTINATION,b.INPUTBY,b.OP,b.CUSTSERVICE"); @@ -556,7 +575,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin strSql.Append(" SELECT '' GID,'' BSNO,'' FEEID,'' FEENAME,'' CURRENCY,sum(ISNULL((case when c.ORIGCURRENCY='RMB' THEN case when c.FEETYPE=1 THEN ORIGAMOUNT ELSE -ORIGAMOUNT END ELSE 0 END),0)) AMOUNT,0 DOAMOUNT"); strSql.Append(",'' ORIGCURRENCY,sum(ISNULL((case when c.ORIGCURRENCY!='RMB' THEN case when c.FEETYPE=1 THEN ORIGAMOUNT ELSE -ORIGAMOUNT END ELSE 0 END),0)) ORIGAMOUNT,0 ORIGSTLAMOUNT,0 EXCHANGERATE,0 ORIGEXCHANGERATE "); strSql.Append(",1 FEETYPE,'' FEEOBJNAME,'收' AS FEETYPEREF"); - strSql.Append(" ,b.OPLBNAME,b.BSSTATUS,b.ACCDATE,b.MBLNO,b.HBLNO,b.CUSTNO"); + strSql.Append(" ,b.OPLBNAME,b.BSSTATUS,b.ACCDATE,b.MBLNO,b.HBLNO,b.CUSTNO,b.ORDERNO"); strSql.Append(",b.CUSTOMERNAME"); strSql.Append(",b.VESSEL,b.VOYNO,b.ETD,b.PORTLOAD"); strSql.Append(",b.PORTDISCHARGE,b.DESTINATION,b.INPUTBY,b.OP,b.CUSTSERVICE"); @@ -569,7 +588,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin { strSql.Append(" where (c.ISDELETED=0 or c.ISDELETED IS NULL) and " + strCondition); } - strSql.Append(" GROUP BY b.OPLBNAME,b.BSSTATUS,b.ACCDATE,b.MBLNO,b.HBLNO,b.CUSTNO"); + strSql.Append(" GROUP BY b.OPLBNAME,b.BSSTATUS,b.ACCDATE,b.MBLNO,b.HBLNO,b.CUSTNO,b.ORDERNO"); strSql.Append(",b.CUSTOMERNAME"); strSql.Append(",b.VESSEL,b.VOYNO,b.ETD,b.PORTLOAD"); strSql.Append(",b.PORTDISCHARGE,b.DESTINATION,b.INPUTBY,b.OP,b.CUSTSERVICE"); @@ -597,12 +616,17 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin data.FEETYPE = Convert.ToInt16(reader["FEETYPE"]); data.FEETYPEREF = Convert.ToString(reader["FEETYPEREF"]); data.CURRENCY = Convert.ToString(reader["CURRENCY"]); - data.AMOUNT = Convert.ToDecimal(reader["AMOUNT"]); - data.DOAMOUNT = Convert.ToDecimal(reader["DOAMOUNT"]); + if (reader["AMOUNT"] != DBNull.Value) + data.AMOUNT = Convert.ToDecimal(reader["AMOUNT"]); + if (reader["DOAMOUNT"] != DBNull.Value) + data.DOAMOUNT = Convert.ToDecimal(reader["DOAMOUNT"]); data.ORIGCURRENCY = Convert.ToString(reader["ORIGCURRENCY"]); - data.ORIGAMOUNT = Convert.ToDecimal(reader["ORIGAMOUNT"]); - data.ORIGSTLAMOUNT = Convert.ToDecimal(reader["ORIGSTLAMOUNT"]); - data.EXCHANGERATE = Convert.ToDecimal(reader["EXCHANGERATE"]); + if (reader["ORIGAMOUNT"] != DBNull.Value) + data.ORIGAMOUNT = Convert.ToDecimal(reader["ORIGAMOUNT"]); + if (reader["ORIGSTLAMOUNT"] != DBNull.Value) + data.ORIGSTLAMOUNT = Convert.ToDecimal(reader["ORIGSTLAMOUNT"]); + if (reader["EXCHANGERATE"] != DBNull.Value) + data.EXCHANGERATE = Convert.ToDecimal(reader["EXCHANGERATE"]); if (reader["ETD"] != DBNull.Value) data.ETD = Convert.ToString(reader["ETD"]); data.ACCDATE = Convert.ToString(reader["ACCDATE"]); @@ -622,11 +646,12 @@ 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"]); data.INPUTMODE = Convert.ToString(reader["INPUTMODE"]); + data.ORDERNO = Convert.ToString(reader["ORDERNO"]); #endregion headList.Add(data); } @@ -763,7 +788,8 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin data.FEETYPE = Convert.ToInt16(reader["FEETYPE"]); data.FEETYPEREF = Convert.ToString(reader["FEETYPEREF"]); data.CURRENCY = Convert.ToString(reader["CURRENCY"]); - data.AMOUNT = Convert.ToDecimal(reader["AMOUNT"]); + if (reader["AMOUNT"] != DBNull.Value) + data.AMOUNT = Convert.ToDecimal(reader["AMOUNT"]); #endregion headList.Add(data); } @@ -861,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"]); @@ -982,7 +1008,11 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin { strSql.Append(" and ISNULL(f.AMOUNT,0)<>ISNULL(f.SETTLEMENT,0) "); } - + var INVISNOTRECPAY = MsSysParamSetDAL.GetData("PARAMNAME='INVISNOTRECPAY'"); + if (INVISNOTRECPAY.PARAMVALUE == "1") + { + strSql.Append(" and ISNULL(f.AMOUNT,0)<>ISNULL(f.ORDERAMOUNT,0) "); + } strSql.Append("GROUP BY b.BSNO,b.OPLB,b.OPLBNAME,b.BSSTATUS,b.ACCDATE,b.MBLNO,b.HBLNO,b.CUSTNO"); strSql.Append(",b.CUSTOMERNAME"); @@ -990,7 +1020,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin strSql.Append(",b.PORTDISCHARGE,b.INPUTBY,b.OP,b.CUSTSERVICE"); strSql.Append(",b.DOC,b.SALE,b.ENTERP,b.CUSTOMNO,b.REMARK,b.SALECORPID,f.CUSTOMERNAME"); strSql.Append(@")as t "); - strSql.Append(string.Format("where t.num>={0} and t.num<={1} ", start, start + limit)); // + strSql.Append(string.Format("where t.num>{0} and t.num<={1} ", start, start + limit)); // return SetAddBillData(strSql); } @@ -1084,8 +1114,8 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin data.REMARK = Convert.ToString(reader["REMARK"]); data.SALECORPID = Convert.ToString(reader["SALECORPID"]); data.SALECORP = Convert.ToString(reader["SALECORP"]); - - data.BSSTATUS = Convert.ToBoolean(reader["BSSTATUS"]); + if (reader["BSSTATUS"] != DBNull.Value) + data.BSSTATUS = Convert.ToBoolean(reader["BSSTATUS"]); data.FEEOBJNAME = Convert.ToString(reader["CUSTNAME"]); if (reader["RMBDR"] != DBNull.Value) @@ -1202,13 +1232,18 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin { strSql.Append(" and ISNULL(f.AMOUNT,0)<>ISNULL(f.SETTLEMENT,0) "); } + var INVISNOTRECPAY = MsSysParamSetDAL.GetData("PARAMNAME='INVISNOTRECPAY'"); + if (INVISNOTRECPAY.PARAMVALUE == "1") + { + strSql.Append(" and ISNULL(f.AMOUNT,0)<>ISNULL(f.ORDERAMOUNT,0) "); + } strSql.Append("GROUP BY b.BSNO,b.TRANSTYPE,b.TRANSSTATUS,b.CUSTOMERNAME,b.CUSTNO,b.CONTRACTNO,b.ORDERNO,b.BSDATE,"); strSql.Append("b.ETD,b.ETA,b.OP,b.SALE,b.CUSTSERVICE,b.CUSTATTN,b.CUSTTEL,b.CONSIGNEENAME,b.CONSIGNEEATTN,b.CONSIGNEETEL,b.CONSIGNEEADDR,"); strSql.Append("b.PORTLOAD,b.PORTDISCHARGE,b.GOODSNAME,b.KGS,b.NETWEIGHT,b.CBM,b.PKGS,b.KINDPKGS,b.TRUCKER,b.TRUCKNO,b.MBLNO,f.CUSTOMERNAME"); strSql.Append(@")as t "); - strSql.Append(string.Format("where t.num>={0} and t.num<={1} ", start, start + limit)); // + strSql.Append(string.Format("where t.num>{0} and t.num<={1} ", start, start + limit)); // return SetAddTruckBillData(strSql); } @@ -1407,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); @@ -1417,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(); @@ -1457,6 +1492,11 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin { strSql.Append(" and ISNULL(f.AMOUNT,0)<>ISNULL(f.SETTLEMENT,0) "); } + var INVISNOTRECPAY = MsSysParamSetDAL.GetData("PARAMNAME='INVISNOTRECPAY'"); + if (INVISNOTRECPAY.PARAMVALUE == "1") + { + strSql.Append(" and ISNULL(f.AMOUNT,0)<>ISNULL(f.ORDERAMOUNT,0) "); + } strSql.Append(" ) AS VF "); @@ -1678,7 +1718,8 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin { INVAPPMAX = true; } - + var INVAMOUNTASSUM = MsSysParamSetDAL.GetData("PARAMNAME='INVAMOUNTASSUM'").PARAMVALUE; + var invfeesumlist = new List(); if (ttlamount >= 99999 && INVAPPMAX) { result.Success = false; @@ -1722,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; @@ -1813,16 +1854,45 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin amtttl = amtttl - enumValue.DoAmount; else amtttl = amtttl + enumValue.DoAmount; + var invfeesum = invfeesumlist.Find(x => x.CURR == enumValue.Currency && x.exchange == enumValue.ExChangerate); + if (invfeesum == null) + { + var newinvfeesum = new InvoiceFeeSum(); + newinvfeesum.CURR = enumValue.Currency; + newinvfeesum.exchange = enumValue.ExChangerate; + if (enumValue.FeeType == 1) + newinvfeesum.amount = enumValue.StlAmount; + else + newinvfeesum.amount = -enumValue.StlAmount; + invfeesumlist.Add(newinvfeesum); + } + else + { + if (enumValue.FeeType == 1) + invfeesum.amount = invfeesum.amount + enumValue.StlAmount; + else invfeesum.amount = invfeesum.amount - enumValue.StlAmount; + + } + } } } acctaxrate = headData.EXCHANGERATE; + if (INVAMOUNTASSUM == "1") + { + amtttl = 0; + foreach (var invfeesum in invfeesumlist) + { + amtttl = amtttl + Math.Round(invfeesum.amount * invfeesum.exchange, 2, MidpointRounding.AwayFromZero); + } + } - 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]; @@ -1830,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); @@ -1860,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); @@ -1868,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 { @@ -1878,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) { @@ -1937,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 + "') "); @@ -1951,7 +2023,8 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin { INVAPPMAX = true; } - + var INVAMOUNTASSUM = MsSysParamSetDAL.GetData("PARAMNAME='INVAMOUNTASSUM'").PARAMVALUE; + var invfeesumlist = new List(); if (ttlamount >= 99999 && INVAPPMAX) { result.Success = false; @@ -1968,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 = @@ -2039,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); @@ -2065,6 +2139,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin amtttl = amtttl - enumValue.StlAmount; else amtttl = amtttl + enumValue.StlAmount; + enumValue.ExChangerate = 1; } else { @@ -2078,6 +2153,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin amtttl = amtttl - Math.Round(enumValue.StlAmount * UExrate, 2); else amtttl = amtttl + Math.Round(enumValue.StlAmount * UExrate, 2); + enumValue.ExChangerate = UExrate; } @@ -2096,6 +2172,26 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin db.ExecuteNonQuery(cmdInsert, tran); + var invfeesum = invfeesumlist.Find(x => x.CURR == enumValue.Currency && x.exchange == enumValue.ExChangerate); + if (invfeesum == null) + { + var newinvfeesum = new InvoiceFeeSum(); + newinvfeesum.CURR = enumValue.Currency; + newinvfeesum.exchange = enumValue.ExChangerate; + if (enumValue.FeeType == 1) + newinvfeesum.amount = enumValue.StlAmount; + else + newinvfeesum.amount = -enumValue.StlAmount; + invfeesumlist.Add(newinvfeesum); + } + else + { + if (enumValue.FeeType == 1) + invfeesum.amount = invfeesum.amount + enumValue.StlAmount; + else invfeesum.amount = invfeesum.amount - enumValue.StlAmount; + + } + cmdUpdate.Parameters.Clear(); db.AddInParameter(cmdUpdate, "@GID", DbType.String, enumValue.CH_ID); db.AddInParameter(cmdUpdate, "@INVOICE", DbType.Decimal, enumValue.StlAmount); @@ -2132,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)); @@ -2165,7 +2262,16 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin } } acctaxrate = headData.EXCHANGERATE; - if (!isList&& amtttl!=0) + if (INVAMOUNTASSUM == "1") + { + + amtttl = 0; + foreach (var invfeesum in invfeesumlist) + { + amtttl = amtttl + Math.Round(invfeesum.amount * invfeesum.exchange, 2, MidpointRounding.AwayFromZero); + } + } + if (!isList && amtttl != 0) { var dataList = GetDetailList(" PID='" + GID + "'"); @@ -2176,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); } @@ -2221,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); @@ -2235,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); } @@ -2281,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(); @@ -2445,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(); @@ -2474,26 +2580,10 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin try { - //如果是新增 则在PUSHEMAIL中写入申请人的邮箱 - //如果申请人邮箱不为空 推送改为邮箱 - //var 申请人info = BasicDataRefDAL.GetVwUser(headData.APPLICANT); - //if (!string.IsNullOrWhiteSpace(申请人info.EMAIL1)) - //{ - // headData.PUSHEMAIL = 申请人info.EMAIL1; - // headData.PUSHMODE = "0"; - //} - //var PUSHEMAIL = ""; - //var PUSHMODE = "-1"; - //var 申请人info = BasicDataRefDAL.GetVwUser(bodyList[0].APPLICANT); - //if (!string.IsNullOrWhiteSpace(申请人info.EMAIL1)) - //{ - // PUSHEMAIL = 申请人info.EMAIL1; - // PUSHMODE = "0"; - //} - var cmdUpdateInv = db.GetSqlStringCommand( - @"update ch_fee_invoice set REMARK=REMARK+' '+@REMARK WHERE BILLNO=@BILLNO"); + @"update ch_fee_invoice set REMARK=REMARK+' '+@REMARK + WHERE BILLNO=@BILLNO"); var cmdInsert = @@ -2553,20 +2643,17 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin cmdUpdateInv.Parameters.Clear(); db.AddInParameter(cmdUpdateInv, "@BILLNO", DbType.String, billno); - //db.AddInParameter(cmdUpdateInv, "@PUSHEMAIL", DbType.String, PUSHEMAIL); - //db.AddInParameter(cmdUpdateInv, "@PUSHMODE", DbType.String, PUSHMODE); - 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); @@ -2575,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; @@ -2600,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) @@ -2644,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 == "*") @@ -2666,7 +2757,8 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin db.ExecuteNonQuery(cmdInsertInvDetail, tran); } - else { + else + { var cmdUpdateInvDetail = db.GetSqlStringCommand( @@ -2676,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) @@ -2714,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); @@ -2813,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) @@ -2886,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; @@ -2957,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; @@ -2970,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); } @@ -3099,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(); @@ -3119,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) @@ -3187,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(); @@ -3211,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( @@ -3235,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); } @@ -3266,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(); @@ -3291,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"); } @@ -3350,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( @@ -3401,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); @@ -3434,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(); @@ -3464,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); + } @@ -3522,7 +3619,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin public static DBResult Lock(String bill) { var result = new DBResult(); - + var INVLOCKFEEAUTOAUDIT = MsSysParamSetDAL.GetData("PARAMNAME='INVLOCKFEEAUTOAUDIT'").PARAMVALUE; Database db = DatabaseFactory.CreateDatabase(); using (var conn = db.CreateConnection()) { @@ -3539,9 +3636,15 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin cmdupdate.Parameters.Clear(); db.AddInParameter(cmdupdate, "@BILLNO", DbType.String, bill); db.ExecuteNonQuery(cmdupdate, tran); + if (INVLOCKFEEAUTOAUDIT == "1") + { + var cmdupdatefee = db.GetSqlStringCommand("update ch_fee set FEESTATUS=0 where FEESTATUS in (1,2) and GID IN (SELECT FEEID FROM CH_FEE_DO WHERE BILLNO=@BILLNO)"); - + cmdupdatefee.Parameters.Clear(); + db.AddInParameter(cmdupdatefee, "@BILLNO", DbType.String, bill); + db.ExecuteNonQuery(cmdupdatefee, tran); + } result = new DBResult(); result.Success = true; result.Message = "锁定成功"; @@ -3569,7 +3672,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin { var result = new DBResult(); var billList = bills.Split(','); - + var INVLOCKFEEAUTOAUDIT = MsSysParamSetDAL.GetData("PARAMNAME='INVLOCKFEEAUTOAUDIT'").PARAMVALUE; Database db = DatabaseFactory.CreateDatabase(); using (var conn = db.CreateConnection()) { @@ -3591,8 +3694,16 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin db.AddInParameter(cmdupdate, "@BILLNO", DbType.String, bill); db.ExecuteNonQuery(cmdupdate, tran); + if (INVLOCKFEEAUTOAUDIT == "1") + { + var cmdupdatefee = db.GetSqlStringCommand("update ch_fee set FEESTATUS=0 where FEESTATUS in (1,2) and GID IN (SELECT FEEID FROM CH_FEE_DO WHERE BILLNO=@BILLNO)"); + cmdupdatefee.Parameters.Clear(); + db.AddInParameter(cmdupdatefee, "@BILLNO", DbType.String, bill); + db.ExecuteNonQuery(cmdupdatefee, tran); + } + result = new DBResult(); result.Success = true; result.Message = "锁定成功"; @@ -3617,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(); @@ -3668,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(); @@ -3729,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()) { @@ -3742,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(); @@ -3831,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 "); @@ -3856,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(); @@ -4014,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 + " "; } } @@ -4028,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("[主提单号]", ""); @@ -4083,7 +4194,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin #region 导出发票 - + public static string CreateInvList(List headList, string path) { @@ -4111,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) { @@ -4127,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 + ""); @@ -4150,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(""); @@ -4165,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(""); @@ -4180,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"; @@ -4212,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(""); @@ -4221,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 + ""); @@ -4255,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(""); @@ -4289,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"; @@ -4303,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(); @@ -4321,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"; @@ -4342,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(); @@ -4364,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; @@ -4374,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); } @@ -4388,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)) @@ -4407,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"; @@ -4456,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; } @@ -4474,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) @@ -4495,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; } @@ -4541,14 +4656,14 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin string str = ""; var strSql = new StringBuilder(); strSql.Append("SELECT "); - strSql.Append(" VISIBLERANGE,OPERATERANGE,AUTHORITYID "); + strSql.Append(" VISIBLERANGE,OPERATERANGE,AUTHORITYID ");//,VSSQL strSql.Append(" from VW_User_Authority "); strSql.Append(" where [NAME]='modInvoiceManagement' and USERID='" + userid + "' and ISDELETE=0"); string visiblerange = "4"; string operaterange = "4"; string AUTHORITYID = ""; - + string VSSQL = ""; Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { @@ -4557,7 +4672,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin visiblerange = Convert.ToString(reader["VISIBLERANGE"]); operaterange = Convert.ToString(reader["OPERATERANGE"]); AUTHORITYID = Convert.ToString(reader["AUTHORITYID"]); - + //VSSQL = Convert.ToString(reader["VSSQL"]); break; } reader.Close(); @@ -4575,10 +4690,11 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin var rangeDa = new RangeDA(); var deptid = rangeDa.GetDEPTGID(userid); str = " CREATEUSER in (select USERID from vw_user where deptid='" + deptid + "') "; + } else if (visiblerange == "1") { - str = " COMPANYID='" + companyid + "' "; + str = " COMPANYID='" + companyid + "' "; } else if (visiblerange == "5") { @@ -4593,11 +4709,11 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin { if (str == "") { - str = " (CREATEUSER in (select USERID from user_company where COMPANYID='" + companyid + "') "; + str = " COMPANYID='" + companyid + "' "; } else { - str = str + " or CREATEUSER in (select USERID from user_company where COMPANYID='" + companyid + "')"; + str = str + " or COMPANYID='" + companyid + "' "; }; } str = str + ")"; @@ -4636,7 +4752,20 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin { str = " 1=1 "; } + VSSQL = VSSQL.Trim(); + if (!string.IsNullOrEmpty(VSSQL)) + { + if (!string.IsNullOrEmpty(str)) + { + str = str + " and (" + VSSQL + ") "; + } + else + { + str = " (" + VSSQL + ") "; + } + + } return str; } @@ -4678,19 +4807,23 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin else if (visiblerange == "2") { var rangeDa = new RangeDA(); - var deptname = rangeDa.GetDEPTNAME(userid); - str = " (OP in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "'))" - + " OR INPUTBY in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "'))" - + " OR SALE in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "'))" - + " OR CUSTSERVICE in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "')))"; + //var deptname = rangeDa.GetDEPTNAME(userid); + //str = " (OP in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "'))" + // + " OR INPUTBY in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "'))" + //+ " OR SALE in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "'))" + //+ " OR CUSTSERVICE in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "')))"; + var deptid = rangeDa.GetDEPTGID(userid); + + str = $" exists(select 1 from vw_user where deptgid='{deptid}' and SHOWNAME in(OP,SALE,CUSTSERVICE,INPUTBY)) "; } else if (visiblerange == "1") { - str = " (OP in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "'))" - + " OR INPUTBY in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "'))" - + " OR SALE in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "'))" - + " OR CUSTSERVICE in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "')))"; + //str = " (OP in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "'))" + //+ " OR INPUTBY in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "'))" + //+ " OR SALE in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "'))" + //+ " OR CUSTSERVICE in (select showname from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "')))"; + str = $" exists(select 1 from vw_user where COMPANYID='{companyid}' and SHOWNAME in(OP,SALE,CUSTSERVICE,INPUTBY)) "; } else if (visiblerange == "0") { 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 135bcdec..0ca0699d 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,6 +20,11 @@ using DSWeb.Areas.MvcShipping.Comm; using Newtonsoft.Json.Linq; using DSWeb.Areas.SysMng.Models.DBTableConn; using DSWeb.Areas.SysMng.DAL.DBTableConn; +using DSWeb.MvcShipping.DAL.MsSysInvInterFaceSet; +using static System.Net.WebRequestMethods; +using sun.security.krb5.@internal.crypto; +using DSWeb.Areas.CommMng.Controllers; +using DSWeb.MvcShipping.DAL.MsSysParamSet; namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin { @@ -41,14 +46,16 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin private string _INVOICELINE = "p"; //发票种类:p,普通发票(电票)(默认);c,普通发票(纸票);s,专用发票;e,收购发票(电票);f,收购发票(纸质) 80003 + public bool 全电发票() { return (_INVOICELINE == "bs" || _INVOICELINE == "pc" || _INVOICELINE == "es" || _INVOICELINE == "ec"); } + private string _EINVOICESTATE = string.Empty; //接口开票是否成功。开票成功时记录为true 80004 private string _INVOICEINFOURL = string.Empty; //发票详情地址 一个url 直接显示诺诺开票的发票详情页 开票成功后读取发票详情并记录 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; @@ -87,12 +94,19 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin get { return _PTORRED; } set { _PTORRED = value; } } + + /// + /// 被冲红(蓝票)发票代码 + /// [ModelDB] public string REDCODE { get { return _REDCODE; } set { _REDCODE = value; } } + /// + /// 被冲红(蓝票)发票号码 + /// [ModelDB] public string REDNUM { @@ -127,10 +141,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; } } @@ -189,6 +205,9 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin set { _EINVOICESTATEREF = value; } } + /// + /// 销方税号 + /// new public string TAXCODE { get { return _TAXCODE; } @@ -205,16 +224,22 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin set { _ADDRESS = value; } } public string BILLRISES { get; set; } + /// + /// 收款人 + /// [ModelDB] public string PAYEE { get { return _PAYEE; } set { _PAYEE = value; } } + /// + /// 复核人 + /// [ModelDB] public string CHECKER { - get { return _CHECKER; } + get { return _CHECKER; } set { _CHECKER = value; } } [ModelDB] @@ -229,6 +254,53 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin get { return _INVITERFACE; } set { _INVITERFACE = value; } } + [ModelDB] + public bool ISFRINV { get; set; } + + + #endregion + + #region 诺诺全电发票增加的字段 + + /// + /// 冲红原因:1:销货退回;2:开票有误;3:服务中止;4:发生销售折让(开具红票时且票种为 p, c, e, f, r 需要传--成品油发票除外;不传时默认为 1) + /// + [ModelDB] + public string redReason { get; set; } = ""; + + /// + /// 红字信息表编号.专票冲红时此项必填,且必须在备注中注明“开具红字增值税专用发票信息表编号 ZZZZZZZZZZZZZZZZ” 字样 + /// ,其 中“Z” 为开具红字增值税专用发票所需要的长度为 16位信息表编号(建议 16 位,最长可支持 24 位)。 + /// + [ModelDB] + public string billInfoNo { get; set; } = ""; + + /// + /// 红字确认单 uuid + /// + [ModelDB] + public string billUuid { get; set; } = ""; + + + + /// + /// 购买方经办人姓名(全电发票特有字段) + /// + [ModelDB] + public string buyerManagerName { get; set; } = ""; + + /// + /// 经办人证件类型:101-组织机构代码证, 102-营业执照, 103-税务登记证, 199-其他单位证件 + /// , 201-居民身份证, 202-军官证, 203-武警警官证, 204-士兵证, 205-军队离退休干部证 + /// , 206-残疾人证, 207-残疾军人证(1-8 级),208-外国护照, 210-港澳居民来往内地通行证 + /// , 212-中华人民共和国往来港澳通行证, 213-台湾居民来往大陆通行证 + /// , 214-大陆居民往来台湾通行证, 215-外国人居留证, 216-外交官证 299-其他个人证件(全电发票特有) + /// + [ModelDB] + public string managerCardType { get; set; } = ""; + [ModelDB] + public string managerCardNo { get; set; } = ""; + #endregion public ChInvoice_HangXin() @@ -236,42 +308,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]); @@ -284,7 +361,8 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin { OTCURRAMOUNT = getarraysum(P2data.GetSplitField("AMOUNT", "\r\n")); } - else { + else + { OTCURRAMOUNT = 0M; } AMOUNTCAPITAL = P2data.GetValue("AMOUNTCAPITAL"); @@ -303,11 +381,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"); @@ -319,15 +399,19 @@ 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); @@ -340,11 +424,13 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin [JsonObject] public class HXInvoice_Head { - private ChInvoice_HangXin ChInvoice_HangXin; - public HXInvoice_Head() { + protected ChInvoice_HangXin ChInvoice_HangXin; + public HXInvoice_Head() + { } - public HXInvoice_Head(ChInvoice_HangXin ChInvoice_HangXin) { + public HXInvoice_Head(ChInvoice_HangXin ChInvoice_HangXin) + { this.ChInvoice_HangXin = ChInvoice_HangXin; } @@ -354,94 +440,105 @@ 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; } + get + { + if (string.IsNullOrWhiteSpace(ChInvoice_HangXin.REDCODE)) + { + return ""; + } + + return ChInvoice_HangXin.REDCODE.Length == 11 ? "0" + ChInvoice_HangXin.REDCODE : 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; } @@ -449,10 +546,14 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin public string invoiceLine { - get { return ChInvoice_HangXin.INVOICELINE; + get + { + return ChInvoice_HangXin.INVOICELINE; } } - + /// + /// 收款人 + /// public string payee { get @@ -474,7 +575,7 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin [JsonObject] public class HXInvoice_Detail { - private ChInvoiceDetail ChInvoiceDetail; + protected ChInvoiceDetail ChInvoiceDetail; public HXInvoice_Detail() { @@ -522,7 +623,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 @@ -533,7 +634,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(); } } @@ -557,6 +660,12 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin ///增值税特殊管理 ///零税率标识:空,非零税;1,免税;2,不征税;3,普通零税率 ///如无则分别填入 1:0不使用 2:空 3:空 非零税率 + /// + /// 全电票内容来自枚举类型80007 + /// 全电发票时: 01:简易征收 02:稀土产品 03:免税 04:不征税 05:先征后退 06:100%先征后退 07:50%先征后退 + /// 08:按 3%简易征收 09:按 5%简易征收 10:按 5%简易征收减按 1.5%计征 11:即征即退 30% 12:即征即退 50% + /// 13:即征即退 70% 14:即征即退 100% 15:超税负 3%即征即退 16:超税负 8%即征即退 + /// 17:超税负 12%即征即退 18:超税负6%即征即退 /// /// public string favouredPolicyFlag @@ -575,1025 +684,2319 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin } - //public class RefreshHangXinTokenJob : IJob - //{ - // public void Execute(IJobExecutionContext context) - // { - // //BasicDataRefDAL.SaveLog("方法被调用1", "诺诺平台", "刷新token", "方法被调用1"); - // HangXinRequestHelper.RefreshTokens(); - // } - //} + [JsonObject] + public class NuoNuoQuanDianInvoice + { + public NuoNuoQuanDian_Head order; - /// - /// 航信接口token管理 - /// - public class HangXinRequestHelper + public NuoNuoQuanDianInvoice(ChInvoice_HangXin head, List body) + { + this.order = new NuoNuoQuanDian_Head(head); + List invoiceDetail = new List(); + + foreach (var detail in body) + { + var item = new NuoNuoQuanDian_Detail(detail); + + + invoiceDetail.Add(item); + } + this.order.invoiceDetail = invoiceDetail; + } + } + + [JsonObject] + public class NuoNuoQuanDian_Head : HXInvoice_Head { - public Boolean CanUse = true; - public string ERRORMSG = ""; - public static List HXTokenHelperList = new List(); + public NuoNuoQuanDian_Head() + { - /// - /// 刷新所有需要刷新的token - /// 20191122 准备放弃该算法 改为从接口获取 - /// - //internal static void RefreshTokens() - //{ - // //BasicDataRefDAL.SaveLog("RefreshTokens; HXTokenHelperList.count="+ HXTokenHelperList.Count.ToString(), "诺诺平台", "刷新token", "方法被调用2"); + } + public NuoNuoQuanDian_Head(ChInvoice_HangXin _ChInvoice) + { + ChInvoice_HangXin = _ChInvoice; + //需增加 + //获取callback地址 + } - // //if (HXTokenHelperList.Count == 0) { - // ReadToken(); - // //} - // if (HXTokenHelperList == null) return; - // foreach (var hx in HXTokenHelperList) { - // hx.ResetToken(); - // } - - // //throw new NotImplementedException(); - //} + //public string redReason { get { return ChInvoice_HangXin.redReason; } } + public string billInfoNo { get { return ChInvoice_HangXin.billInfoNo; } } - //public static void clear(string accessToken) { - // if (HXTokenHelperList == null) return; - // foreach (var hx in HXTokenHelperList) - // { - // if (hx.accessToken == accessToken) - // hx.accessToken = ""; - // } - //} + public string departmentId { get; set; } = ""; + public string clerkId { get; set; } = ""; - #region 基础属性 - /// - /// 我公司的appKey和密码 不写入数据库 只存在程序内 - /// - /// - /* 沙盒测试账户 需使用青岛鑫鹏威 - * 339901999999142 Abcd1234 - public static string appKey { get { return "SD23646802"; } } - public static string appSecret { get { return "SDFAFF5B0AED4465"; } } - - */ - /* 正式地址测试账户 纸票测试用 需使用深圳鑫鹏威 - //339901999999516 - public static string appKey { get { return "G6bvh0ke"; } } - public static string appSecret { get { return "6850C5AED14E4177"; } } - */ + public string listFlag { get; set; } = "0"; - /* 正式地址 大简云*/ - public static string appKey { get { return "23646802"; } } - public static string appSecret { get { return "CBFAFF5B0AED4465"; } } - + public string listName { get; set; } = ""; /// - /// 使用沙盒地址还是实际工作地址 + /// 全电纸票类型(全电纸票时才需要传):(票种为 ec 时,默认 04;票种为 es 时,默认为 1130); 04 2016 版增值税普通发票(二联折叠票) + /// , 05 2016 版增值税普通发票(五联折叠票), 1130增值税专用发票(中文三联无金额限制版) + /// , 1140 增值税专用发票(中文四联无金额限制版),1160 增值税专用发票(中文六联无金额限制版) + /// , 1170 增值税专用发票(中文七联无金额限制版) /// - public static string URL { - get { - //return sandboxUrl; //沙盒测试地址 - return normalUrl; + public string paperInvoiceType + { + get + { + if (ChInvoice_HangXin.INVOICELINE == "ec") return "04"; + if (ChInvoice_HangXin.INVOICELINE == "es") return "1130"; + return ""; } } /// - /// 商户模式的Token + /// 特定要素:0 普通发票(默认)、 1 成品油 、 3 建筑服务、 4货物运输服务、 31 建安发票、 32 房地产销售发票 + /// 目前默认普通发票 /// - public string MerchantToken { get; set; } + public string specificFactor { get; set; } = "0"; /// - /// 在服务商模式当中,客户输入选定账户的认证信息后返回的一个随机码 - /// 每次认证时会被更新。但执行getISVToken或refreshISVToken不会改变code + /// 回传发票信息地址(开票完成、开票失败) + /// 增加系统配置项目 诺诺电票回调地址 /// - public string code { get; set; } + public string callBackUrl { get; set; } = "0"; /// - /// 税号 客户输入的选定账户 + /// 分机号(开票终端号,只能 为空或数字) /// - public string taxnum { get; set; } + public string extensionNumber { get; set; } = "150"; /// - /// 接收诺诺平台返回值的url,需要在其中标好账户id,以对应正确的实例化helper对象 + /// 终端号(开票终端号,只能 为空或数字) /// - public static string redirectUri { get; set; } - //private static string ISVToken { get; set; } + public string terminalNumber { get; set; } = ""; /// - /// getISVToken时返回 refreshToken 时不变 + /// 机器编号(12 位盘号) + /// 增加系统配置项目 税盘盘号 /// - public string accessToken { get; set; } - /// - /// getISVToken时返回 refreshToken时改变 - /// - public string refreshToken { get; set; } + public string machineCode { get; set; } = ""; /// - /// 同一客户税号这个userid似乎不变 + /// 是否机动车类专票 0-否 1-是 /// - public string userId { get; set; } - + public string vehicleFlag { get; set; } = "0"; /// - /// 如果此次返回内容有错误编号 则返回错误 + /// 是否隐藏编码表版本号 0-否 1-是(默认 0,在企业资质中也配置为是隐藏的时候, + /// 并且此字段传 1 的时候代开发票 税率显示***) /// - public bool refstateTrue - { - get - { - if (!string.IsNullOrEmpty(error)) { return false; } - else return true; - } - } + public string hiddenBmbbbh { get; set; } = "0"; - public string error_description { get; set; } - public string error { get; set; } + public string nextInvoiceCode { get; set; } = ""; + public string nextInvoiceNum { get; set; } = ""; + public string invoiceNumEnd { get; set; } = ""; + public string surveyAnswerType { get; set; } = ""; - private static string sandboxUrl = "https://sandbox.nuonuocs.cn/open/v1/services"; - - private static string normalUrl = "https://sdk.nuonuo.com/open/v1/services"; - //爬虫服务器接口 - private static string _IURL = "http://47.104.90.170:5200/fp/token/"; - //private static string _IURL = "http://118.190.106.151:5200/fp/token/"; - //沙盒爬虫 - private static string _SandBoxURL = "http://47.104.90.170:5200/cs/token/"; - //private static string _SandBoxURL = "http://118.190.106.151:5200/cs/token/"; + public string buyerManagerName { get { return ChInvoice_HangXin.buyerManagerName; } } + public string managerCardType { get { return ChInvoice_HangXin.managerCardType; } } - private static string _url { get; set; } + public string managerCardNo { get { return ChInvoice_HangXin.managerCardNo; } } - const string ContentType = "application/x-www-form-urlencoded;charset=UTF-8"; + public List invoiceDetail; + } - public static string returnStr { get; set; } + [JsonObject] + public class NuoNuoQuanDian_Detail : HXInvoice_Detail + { + public NuoNuoQuanDian_Detail() + { - private static string getSendid() + } + public NuoNuoQuanDian_Detail(ChInvoiceDetail ChInvoiceDetail) { - return Guid.NewGuid().ToString().Replace("-", "").Substring(0, 32); // 唯一标识,由企业自己生成32位随机码 + + this.ChInvoiceDetail = ChInvoiceDetail; } - private DateTime _tokenstarttime { get; set; } - //public DateTime gettokenstarttime { get { return _tokenstarttime; } } - public DateTime tokenstarttime { get { return _tokenstarttime; } set { _tokenstarttime = value; } } - public DateTime tokenneedresettime { get { return _tokenstarttime.AddHours(23); } } + public string goodsCode { get; set; } = ""; + public string selfCode { get; set; } = ""; /// - /// 需要初始化。如果有用户认证的code,则返回true,否则需要前台弹出StartUrl窗口,录入认证信息; - /// 20191122 改为接口维护token后 固定返回false + /// 发票行性质:0,正常行;1,折扣行;2,被折扣行,红票只有正常行 /// - public bool needStart - { - get - { + public string invoiceLineProperty { get; set; } = "0"; - //if (string.IsNullOrEmpty(code)) - //{ - // return true; - //} - //else if (System.DateTime.Now > _tokenstarttime.AddHours(24)) - //{ - // return true; - //} - if (accessToken == "") return true; - else - return false; - } - } + } - /// - /// 需要刷新 即当前时间晚于上次刷新23小时 - /// /// 20191122 改为接口维护token后 固定返回false - /// - public bool needresettoken + [JsonObject] + public class NuoNuoQuanDian_SetRed : HXInvoice_Head + { + + public NuoNuoQuanDian_SetRed() { - get - { - //if (System.DateTime.Now >= tokenneedresettime) - //{ - // return true; - //} - return false; - } + } + public NuoNuoQuanDian_SetRed(ChInvoice_HangXin _ChInvoice) + { + ChInvoice_HangXin = _ChInvoice; - /// - /// 具备刷新条件 即token不为空 - /// - //public bool canresettoken - //{ - // get - // { - // if (!string.IsNullOrEmpty(refreshToken)) - // return true; - // else return false; - // } - //} + } - #endregion + public string billInfoNo { get { return ChInvoice_HangXin.billInfoNo; } } - //public bool ResetToken() - //{ - // //BasicDataRefDAL.SaveLog("tokenstarttime="+ tokenstarttime.ToString("yyyy-MM-dd HH:mm:ss")+ ";refreshToken=" + refreshToken + ";accessToken=" + accessToken + ";needresettoken=" + needresettoken.ToString() + ";canresettoken=" + canresettoken.ToString(), "诺诺平台", "刷新令牌", "判断"); + public string deptId { get; set; } = ""; + public string departmentId { get; set; } = ""; + public string clerkId { get; set; } = ""; - // if (needresettoken && canresettoken) - // { - // refreshISVToken(); - // return !needresettoken; - // } - // else return false; - //} + public string listFlag { get; set; } = "0"; - /// - /// 商户获取访问令牌 - /// - /// - //public string getMerchantToken() - //{ - // //BasicDataRefDAL.SaveLog("appKey="+appKey+ ";appSecret=" + appSecret, "诺诺平台", "商户获取访问令牌", "发送值"); - // var result = NNOpenSDK.getMerchantToken(appKey, appSecret); - // dealResponse_token(returnStr); - // //DoSaveToken(); - // BasicDataRefDAL.SaveLog(result, "诺诺平台", "商户获取访问令牌", "返回值"); - // return result; - //} - //public string setMerchantToken() - //{ - // this.MerchantToken = getMerchantToken(); - // return this.MerchantToken; - //} + public string orderTime { get; set; } = ""; + + public string invoiceId { get { return ChInvoice_HangXin.INVOICESERIALNUM; } } + + public string billNo { get; set; } = ""; + public string billUuid { get; set; } = ""; + + public string invoiceLine { get { return ChInvoice_HangXin.INVOICELINE; } } + + public string callBackUrl { get; set; } = ""; + + public string invoiceCode { get { return ChInvoice_HangXin.INVOICECODE; } } + + public string invoiceNumber { get { return ChInvoice_HangXin.INVOICENO; } } + + public string taxNum { get { return ChInvoice_HangXin.TAXCODE; } } + + public string extensionNumber { get; set; } = "150"; + + } + + [JsonObject] + public class NuoNuoQuanDian_RedConfirm : HXInvoice_Head + { + + public NuoNuoQuanDian_RedConfirm() + { + + } + public NuoNuoQuanDian_RedConfirm(ChInvoice_HangXin _ChInvoice) + { + ChInvoice_HangXin = _ChInvoice; + } /// - /// ISV获取访问令牌 + /// 红字确认单申请号,需要保持唯一,不传的话系统自动生成一个; + /// 此处使用蓝票的billno /// - /// - //private ISVTokenmb getISVToken() - //{ - // ISVTokenmb _ISVToken = new ISVTokenmb(); - // //BasicDataRefDAL.SaveLog("appKey=" + appKey + ";appSecret=" + appSecret + ";code=" + code + ";taxnum=" + taxnum + ";redirectUri=" + redirectUri, "诺诺平台", "ISV获取访问令牌", "发送值"); - // returnStr = NNOpenSDK.getISVToken(appKey, appSecret, code, taxnum, redirectUri); - // BasicDataRefDAL.SaveLog(returnStr, "诺诺平台", "ISV获取访问令牌", "返回值"); - // dealResponse_token(returnStr); - - // return _ISVToken; - //} + public string billId { get { return ChInvoice_HangXin.BILLNO; } } + /// + /// 对应蓝票发票种类: bs:电子发票(增值税专用发票), pc:电子发票(普通发票),es:全电纸质发票(增值税专用发票), ec:全电纸质发票(普通发票 + /// + public string blueInvoiceLine { get { return ChInvoice_HangXin.INVOICELINE; } } /// - /// 用认证窗口返回的数据读取token + /// 申请方(录入方)身份: 0 销方 1 购方 /// - /// - //public string setISVToken() - //{ - // //此处应判断 - // //1 token 是否已存在 如不存在则获取needStart - // //如存在则判断更新时间needresettoken - // //if (needStart || needresettoken) - // //{ - // var _ISVToken = getISVToken(); - // return returnStr; - // //} - // //else return "no need to start Token"; + public string applySource { get; set; } = "0"; - // /*"{\"access_token\":\"98600c833f178852e2f4d51cexk9yegi\",\"refresh_token\":\"faf038898dec26eac62640aaed0506cb\",\"oauthUser\":\"{\\\"userName\\\":\\\"339901999999142\\\",\\\"registerType\\\":\\\"1\\\"}\",\"expires_in\":86356,\"userId\":\"d1aa0da6bc9840ae83c1120cecd057ac\"}"*/ + /// + /// 对应蓝票全电号码(全电普票、全电专票都需要) + /// + public string blueInvoiceNumber { get { return ChInvoice_HangXin.REDNUM; } } - // /*{"error_description":"The code is used a second time, please authorization again","error":"070317"}*/ + public string billTime { get; set; } - // /*{"error_description":"Incorrect parameter or Authorization out of date","error":"070313"}*/ - //} + /// + /// 销方税号 + /// + public string sellerTaxNo { get { return ChInvoice_HangXin.TAXCODE; } } /// - /// ISV获取刷新令牌 强制执行 + /// 销方名称,申请说明为销方申请时可为空 /// - /// - //public string refreshISVToken() - //{ - // try - // { - // BasicDataRefDAL.SaveLog("refreshToken=" + refreshToken + ";userId=" + userId + ";appSecret=" + appSecret , "诺诺平台", "ISV获取刷新令牌", "发送值"); - // returnStr = NNOpenSDK.refreshISVToken(refreshToken, userId, appSecret); - // BasicDataRefDAL.SaveLog(returnStr, "诺诺平台", "ISV获取刷新令牌", "返回值"); - // dealRefresh_token(returnStr); - - // return returnStr; - // } - // catch { - // return ""; - // } - //} + public string sellerName { get; set; } = ""; /// - /// ISV获取刷新令牌 如非必要则不执行 + /// 部门门店 id(诺诺网系统中的 id) /// - /// - //public string setrefreshISVToken() - //{ - // if (needStart) - // { - // return "need to start,can not refresh"; - // } - // if (needresettoken) - // { - // return (refreshISVToken()); - // } - // else return "no need to refresh"; - //} + public string departmentId { get; set; } = ""; + /// + /// 开票员 id(诺诺网系统中的 id) + /// + public string clerkId { get; set; } = ""; - public HangXinRequestHelper() - { - 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 string buyerTaxNo { - this.taxnum = taxnum; - this.accessToken = accessToken; - if (HXTokenHelperList == null) HXTokenHelperList = new List(); - var curr = HXTokenHelperList.Find(o => o.taxnum == taxnum); - - if (!(curr==null)) - { - curr.accessToken = accessToken; - } - else - { - HXTokenHelperList.Add(this); - } + get { return ChInvoice_HangXin.CUSTRATENO; } } + ///// + ///// 购方名称 父类已有 + ///// + //public string buyerName + //{ + // get { return ChInvoice_HangXin.INVOICECUSTNAME; } + //} + /// + /// 蓝字发票增值税用途(预留字段可为空): 1 勾选抵扣 2 出口退税 3 代办出口退税 4 不抵扣 + /// + public string vatUsage { get; set; } /// - /// 处理 获取令牌/刷新令牌 命令的返回值 + /// 蓝字发票消费税用途(预留字段可为空) /// - /// - //private void dealResponse_token(string response) { - // var _ISVToken = DSWeb.TruckMng.Helper.JsonConvert.Deserialize(response); - // error = _ISVToken.error; - // if (string.IsNullOrEmpty(error)) - // { - // accessToken = _ISVToken.access_token; - // refreshToken = _ISVToken.refresh_token; - // userId = _ISVToken.userId; - // var userinfo = _ISVToken._oauthUser; - // taxnum = userinfo.userName; - // tokenstarttime = System.DateTime.Now; + public string saleTaxUsage { get; set; } + /// + /// 发票入账状态(预留字段可为空): 0 未入账 1已入账 + /// + public string accountStatus { get; set; } + /// + /// 冲红原因: 1 销货退回 2 开票有误 3 服务中止 4 销售折让 + /// + public string redReason { get { return ChInvoice_HangXin.redReason; } } - // var i = BasicDataRefDAL.ExecSql(getUpdStr()); - // if (i == 0) - // { - // try - // { - // i = BasicDataRefDAL.ExecSql(getInsertStr()); - // BasicDataRefDAL.SaveLog(getInsertStr(), "诺诺平台", "保存Token", "Insert"); - // } - // catch { } - // } - // else - // { - // BasicDataRefDAL.SaveLog(getUpdStr(), "诺诺平台", "保存Token", "Update"); - // } + /// + /// 分机号 150 + /// + public string extensionNumber { get; set; } = "150"; - // } - // else - // { - // error_description = _ISVToken.error_description; - // } - //} + /// + /// 是否自动开票,0 否(不传默认 0)1 是;传 1时, + /// 所申请的确认单变为购销双方已确认或无需确认状态时, + /// 而自动开具红票。目前该字段不生效,电票都自动开,纸票都不自动 + /// + public string autoInvoice { get; set; } = "1"; + //若有值,则在无需确认或购销双方已确认后去自动开红票,发票的开票单号用该值 + //public string orderNo { get { return ChInvoice_HangXin.BILLNO; } } - //private void dealRefresh_token(string response) { - // var _ISVToken = DSWeb.TruckMng.Helper.JsonConvert.Deserialize(response); - // error = _ISVToken.error; - // if (string.IsNullOrEmpty(error)) - // { - // accessToken = _ISVToken.access_token; - // refreshToken = _ISVToken.refresh_token; + public string phone { get { return ChInvoice_HangXin.PUSHMOBILE; } } + public string email { get { return ChInvoice_HangXin.PUSHEMAIL; } } + } - // var i = BasicDataRefDAL.ExecSql(getUpdStr()); - // BasicDataRefDAL.SaveLog(getUpdStr(), "诺诺平台", "保存Token", "refresh Update"); + /// + /// 依托ds7系统中保存的红票,来读取当时发出的红字发票确认单 + /// 由于当时发出的申请单编号,是红字发票的BILLNO,故可以依据这个进行读取 + /// + [JsonObject] + public class NuoNuoQuanDian_ReadRedConfirm : HXInvoice_Head + { - // } - // else - // { - // error_description = _ISVToken.error_description; - // } - //} + public NuoNuoQuanDian_ReadRedConfirm() + { - public static HangXinRequestHelper getHelper(string taxnum) + } + public NuoNuoQuanDian_ReadRedConfirm(ChInvoice_HangXin _ChInvoice) { + ChInvoice_HangXin = _ChInvoice; + } - //ReadToken(); - //foreach (var h in HXTokenHelperList) - //{ - // if (h.taxnum == taxnum) - // { - // return h; - // } - //} - //var result = new HangXinRequestHelper(taxnum); - //return result; - var _token = getPortToken(taxnum); - return _token; - } + /// + /// 操作方身份: 0 销方 1 购方 + /// + public string identity { get; set; } = "0"; + /// + /// 红字确认单状态(不传则查全部状态): + /// 01 无需确认 + /// 02销方录入待购方确认 03 购方录入待销方确认 + /// 04 购销双方已确认 + /// 05 作废(销方录入购方否认) + /// 06 作废(购方录入销方否认) 07 作废(超 72 小时未确认) + /// 08 作废(发起方已撤销) 09 作废(确认后撤销) 15 申请中 16 申请失败 + /// + public string billStatus { get; set; } + /// + /// 红字确认单申请号 ds7当中红票的billno + /// + public string billId { get { return ChInvoice_HangXin.BILLNO; } } + /// + /// 红字确认单编号 + /// + public string billNo { get; set; } + /// + /// 红字确认单 uuid + /// + public string billUuid { get; set; } + /// + /// 填开起始时间,确认单申请号/编号/uuid 有值时,可为空, 允许最大查询范围为 90 天 + /// + public string billTimeStart { get; set; } + /// + /// 填开结束时间,确认单申请号/编号/uuid 有值时,可为空, 允许最大查询范围为 90 天 + /// + public string billTimeEnd { get; set; } + /// + /// 每页数量(默认 10,最大 50) + /// + public string pageSize { get; set; } + /// + /// 当前页码(默认 1) + /// + public string pageNo { get; set; } + } - private static HangXinRequestHelper getPortToken(string taxnum) { - - try - { - ///读取接口token - //JObject reqObj = new JObject(); - //reqObj.Add("taxnum", taxnum); - var dic = new Dictionary(); - dic.Add("taxnum", taxnum); + /// + /// 航信接口token管理 + /// + public class HangXinRequestHelper + { + public Boolean CanUse = true; + public string ERRORMSG = ""; - var rtn = WebRequestHelper.DoPost(_IURL, dic, 10000); - //var rtn = WebRequestHelper.DoPost(_SandBoxURL, dic, 20000); + public static List HXTokenHelperList = new List(); - //RepCZModel CZM = Newtonsoft.Json.JsonConvert.DeserializeObject(rtn); - PortTokenmb pt = Newtonsoft.Json.JsonConvert.DeserializeObject(rtn); + /// + /// 刷新所有需要刷新的token + /// 20191122 准备放弃该算法 改为从接口获取 + /// + //internal static void RefreshTokens() + //{ + // //BasicDataRefDAL.SaveLog("RefreshTokens; HXTokenHelperList.count="+ HXTokenHelperList.Count.ToString(), "诺诺平台", "刷新token", "方法被调用2"); - if (pt.status == "1") - { - foreach (var hx in HXTokenHelperList) - { - if (hx.taxnum == taxnum) - { - hx.accessToken = pt.message; - hx.CanUse = true; - hx.ERRORMSG = ""; - return hx; - } - } - var result = new HangXinRequestHelper(taxnum, pt.message); + // //if (HXTokenHelperList.Count == 0) { + // ReadToken(); + // //} + // if (HXTokenHelperList == null) return; + // foreach (var hx in HXTokenHelperList) { + // hx.ResetToken(); + // } - return result; - } - else - return new HangXinRequestHelper(taxnum, ""); - } - catch (Exception e) { + // //throw new NotImplementedException(); + //} - var result = new HangXinRequestHelper(taxnum, ""); - result.CanUse = false; - result.ERRORMSG = "没有取得开票密钥:"+e.Message; - return result; - } - } + //public static void clear(string accessToken) { + // if (HXTokenHelperList == null) return; + // foreach (var hx in HXTokenHelperList) + // { + // if (hx.accessToken == accessToken) + // hx.accessToken = ""; + // } + //} + #region 基础属性 + /// + /// 我公司的appKey和密码 不写入数据库 只存在程序内 + /// + /// + /* 沙盒测试账户 需使用青岛鑫鹏威 + * 339901999999142 Abcd1234 + public static string appKey { get { return "SD23646802"; } } + public static string appSecret { get { return "SDFAFF5B0AED4465"; } } + + */ + /* 正式地址测试账户 纸票测试用 需使用深圳鑫鹏威 + //339901999999516 + public static string appKey { get { return "G6bvh0ke"; } } + public static string appSecret { get { return "6850C5AED14E4177"; } } + */ + /* 正式地址 大简云*/ + public string appKey { get; set; } = "23646802"; + public string appSecret { get; set; } = "CBFAFF5B0AED4465"; /// - /// 开出发票 + /// 使用沙盒地址还是实际工作地址 /// - /// - /// - /// - public DBResult PostInvoice(ChInvoice_HangXin head, List detailList) + public static string URL { - var billno = head.BILLNO; - - + get + { + //return sandboxUrl; //沙盒测试地址 + return normalUrl; + } + } - //20191028 如果该发票的状态为开票失败 则将其billno临时变更为billno+时分秒,以避开诺诺平台的orderNo不能重复的逻辑 - //然后处理返回值时将新的流水号写回。 - //20191108 - //if (head.EINVOICESTATE == "3"|| head.EINVOICESTATE == "0") - //{ - // head.BILLNO= billno+ DateTime.Now.ToString("HHmmss"); - //} + /// + /// 商户模式的Token + /// + public string MerchantToken { get; set; } - var _head = new HXInvoice(head, detailList); + /// + /// 在服务商模式当中,客户输入选定账户的认证信息后返回的一个随机码 + /// 每次认证时会被更新。但执行getISVToken或refreshISVToken不会改变code + /// + public string code { get; set; } - var json = DSWeb.TruckMng.Helper.JsonConvert.Serialize(_head); + /// + /// 税号 客户输入的选定账户 + /// + public string taxnum { get; set; } - var _r = ""; + /// + /// 接收诺诺平台返回值的url,需要在其中标好账户id,以对应正确的实例化helper对象 + /// + public static string redirectUri { get; set; } + //private static string ISVToken { get; set; } + /// + /// getISVToken时返回 refreshToken 时不变 + /// + public string accessToken { get; set; } - _r = PostInvoice(json); + /// + /// getISVToken时返回 refreshToken时改变 + /// + public string refreshToken { get; set; } + /// + /// 同一客户税号这个userid似乎不变 + /// + public string userId { get; set; } - var _return = dealresponse_KP(_r); - if (_return.code == "E0000") + /// + /// 如果此次返回内容有错误编号 则返回错误 + /// + public bool refstateTrue + { + get { - //开票提交成功 + if (!string.IsNullOrEmpty(error)) { return false; } + else return true; + } + } - var invoiceSerialNum = _return.result.invoiceSerialNum; + public string error_description { get; set; } + public string error { get; set; } - //立即调用读取发票信息的方法 将返回值设置进head 并保存 - head.INVOICESERIALNUM = invoiceSerialNum; - head.BILLNO = billno; - head.DbOperationType = DbOperationType.DbotUpd; - head.ModelUIStatus = "E"; - var modb = new ModelObjectDB(); - var result = modb.Save(head); - result = ReadInvoice(head); + private static string sandboxUrl = "https://sandbox.nuonuocs.cn/open/v1/services"; - //var returndate = ChinvoiceDAL.GetDataList(0, 1, "cm.INVOICESERIALNUM='" + head.INVOICESERIALNUM + "'", head.OPERATOR); + private static string normalUrl = "https://sdk.nuonuo.com/open/v1/services"; - //result.Data = returndate; + //爬虫服务器接口 + private static string _IURL = "http://47.104.90.170:5200/fp/token/"; + //private static string _IURL = "http://118.190.106.151:5200/fp/token/"; - return result; + //沙盒爬虫 + private static string _SandBoxURL = "http://47.104.90.170:5200/cs/token/"; + //private static string _SandBoxURL = "http://118.190.106.151:5200/cs/token/"; - } - else if (_return.code == "070101" || _return.code == "070301") - { - //appkey与token问题 需要重新认证 - //HangXinRequestHelper.clear(accessToken); - var result = new DBResult(false, "需要重新认证", null); - return result; - } - else if (_return.code == "E9106" ) - { - //E9106 订单编号不能重复 - //同billno重复发送 执行一次用订单号读取 - return ReadInvoice_BILLNO(head); - } - else - { - var reault = new DBResult(false, _return.message, head); - return reault; - } - - } - public string PostInvoice(string json) - { - string method = "nuonuo.electronInvoice.requestBilling"; + private static string _url { get; set; } - 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); + const string ContentType = "application/x-www-form-urlencoded;charset=UTF-8"; - BasicDataRefDAL.SaveLog(result, "诺诺平台", "发票开出", "返回值"); + public static string returnStr { get; set; } - return result; + protected static string getSendid() + { + return Guid.NewGuid().ToString().Replace("-", "").Substring(0, 32); // 唯一标识,由企业自己生成32位随机码 } + private DateTime _tokenstarttime { get; set; } + //public DateTime gettokenstarttime { get { return _tokenstarttime; } } + public DateTime tokenstarttime { get { return _tokenstarttime; } set { _tokenstarttime = value; } } + public DateTime tokenneedresettime { get { return _tokenstarttime.AddHours(23); } } - public DBResult ReadInvoice(string INVOICESERIALNUM,string USERID) { - - var head = ChinvoiceDAL.GetData( "cm.INVOICESERIALNUM='" + INVOICESERIALNUM + "'"); - - var _r = ReadInvoice(head); + /// + /// 需要初始化。如果有用户认证的code,则返回true,否则需要前台弹出StartUrl窗口,录入认证信息; + /// 20191122 改为接口维护token后 固定返回false + /// + public bool needStart + { + get + { - return _r; + //if (string.IsNullOrEmpty(code)) + //{ + // return true; + //} + //else if (System.DateTime.Now > _tokenstarttime.AddHours(24)) + //{ + // return true; + //} + if (accessToken == "") return true; + else + return false; + } } - public DBResult ReadInvoice(ChInvoice_HangXin head) - { - if (string.IsNullOrEmpty(head.INVOICESERIALNUM)) { - var result = new DBResult { Success = false, Message = "还未成功进行平台开票,无可读数据", Data = "" }; - return result; + /// + /// 需要刷新 即当前时间晚于上次刷新23小时 + /// /// 20191122 改为接口维护token后 固定返回false + /// + public bool needresettoken + { + get + { + //if (System.DateTime.Now >= tokenneedresettime) + //{ + // return true; + //} + return false; } + } - string method = "nuonuo.electronInvoice.CheckEInvoice"; - var json = "{" + "\"invoiceSerialNum\":[\"" + head.INVOICESERIALNUM + "\"]" + "}"; + /// + /// 具备刷新条件 即token不为空 + /// + //public bool canresettoken + //{ + // get + // { + // if (!string.IsNullOrEmpty(refreshToken)) + // return true; + // else return false; + // } + //} + #endregion - if (string.IsNullOrWhiteSpace(head.INVOICESERIALNUM)) - { - //如果流水号为空 则改为按业务编号读取 - method = "nuonuo.electronInvoice.querySerialNum"; - json = "{" + "\"orderNo\":[\"" + head.BILLNO + "\"]" + "}"; - } + //public bool ResetToken() + //{ + // //BasicDataRefDAL.SaveLog("tokenstarttime="+ tokenstarttime.ToString("yyyy-MM-dd HH:mm:ss")+ ";refreshToken=" + refreshToken + ";accessToken=" + accessToken + ";needresettoken=" + needresettoken.ToString() + ";canresettoken=" + canresettoken.ToString(), "诺诺平台", "刷新令牌", "判断"); - //读取业务 - //string method = "nuonuo.electronInvoice.querySerialNum"; - //var json = "{" + "\"orderNo\":[\"" + head.BILLNO + "\"]" + "}"; + // if (needresettoken && canresettoken) + // { + // refreshISVToken(); + // return !needresettoken; + // } + // else return false; + //} + /// + /// 商户获取访问令牌 + /// + /// + //public string getMerchantToken() + //{ + // //BasicDataRefDAL.SaveLog("appKey="+appKey+ ";appSecret=" + appSecret, "诺诺平台", "商户获取访问令牌", "发送值"); + // var result = NNOpenSDK.getMerchantToken(appKey, appSecret); + // dealResponse_token(returnStr); + // //DoSaveToken(); + // BasicDataRefDAL.SaveLog(result, "诺诺平台", "商户获取访问令牌", "返回值"); + // return result; + //} + //public string setMerchantToken() + //{ + // this.MerchantToken = getMerchantToken(); + // return this.MerchantToken; + //} - 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; - } - + /// + /// ISV获取访问令牌 + /// + /// + //private ISVTokenmb getISVToken() + //{ + // ISVTokenmb _ISVToken = new ISVTokenmb(); + // //BasicDataRefDAL.SaveLog("appKey=" + appKey + ";appSecret=" + appSecret + ";code=" + code + ";taxnum=" + taxnum + ";redirectUri=" + redirectUri, "诺诺平台", "ISV获取访问令牌", "发送值"); + // returnStr = NNOpenSDK.getISVToken(appKey, appSecret, code, taxnum, redirectUri); + // BasicDataRefDAL.SaveLog(returnStr, "诺诺平台", "ISV获取访问令牌", "返回值"); + // dealResponse_token(returnStr); - if (_return.code == "E0000") - { - //开票信息读取成功 - var returndate = ChinvoiceDAL.GetData( "cm.INVOICESERIALNUM='" + head.INVOICESERIALNUM + "'"); - head = returndate; + // return _ISVToken; + //} - //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; + /// + /// 用认证窗口返回的数据读取token + /// + /// + //public string setISVToken() + //{ + // //此处应判断 + // //1 token 是否已存在 如不存在则获取needStart + // //如存在则判断更新时间needresettoken + // //if (needStart || needresettoken) + // //{ + // var _ISVToken = getISVToken(); + // return returnStr; + // //} + // //else return "no need to start Token"; - head.DbOperationType = DbOperationType.DbotUpd; - head.ModelUIStatus = "E"; - var modb = new ModelObjectDB(); - var result = modb.Save(head); - result.Message = info.resultMsg; + // /*"{\"access_token\":\"98600c833f178852e2f4d51cexk9yegi\",\"refresh_token\":\"faf038898dec26eac62640aaed0506cb\",\"oauthUser\":\"{\\\"userName\\\":\\\"339901999999142\\\",\\\"registerType\\\":\\\"1\\\"}\",\"expires_in\":86356,\"userId\":\"d1aa0da6bc9840ae83c1120cecd057ac\"}"*/ + // /*{"error_description":"The code is used a second time, please authorization again","error":"070317"}*/ - if (info.resultMsg.Contains("开具结果:0,开具失败原因:开票异常")) { - result.Message = "开票异常,请尝试重新连接税控盘、重新启动税控软件和诺诺客户端,然后再次读取发票信息;如仍显示此提示,请联系诺诺平台客服人员,并提供销方税号和此发票的流水号"; - } + // /*{"error_description":"Incorrect parameter or Authorization out of date","error":"070313"}*/ + //} - return result; + /// + /// ISV获取刷新令牌 强制执行 + /// + /// + //public string refreshISVToken() + //{ + // try + // { + // BasicDataRefDAL.SaveLog("refreshToken=" + refreshToken + ";userId=" + userId + ";appSecret=" + appSecret , "诺诺平台", "ISV获取刷新令牌", "发送值"); + // returnStr = NNOpenSDK.refreshISVToken(refreshToken, userId, appSecret); + // BasicDataRefDAL.SaveLog(returnStr, "诺诺平台", "ISV获取刷新令牌", "返回值"); + // dealRefresh_token(returnStr); - } - else - { + // return returnStr; + // } + // catch { + // return ""; + // } + //} - var msg = _return.code+":"+_return.describe; - var result = new DBResult { Success = false, Message = DSWeb.TruckMng.Helper.JsonConvert.Serialize(msg), Data = "" }; - return result; + /// + /// ISV获取刷新令牌 如非必要则不执行 + /// + /// + //public string setrefreshISVToken() + //{ + // if (needStart) + // { + // return "need to start,can not refresh"; + // } + // if (needresettoken) + // { + // return (refreshISVToken()); + // } + // else return "no need to refresh"; + //} - } + public HangXinRequestHelper() + { + tokenstarttime = Convert.ToDateTime("1900-01-01"); } - public DBResult ReadInvoice_BILLNO(ChInvoice_HangXin head) + public HangXinRequestHelper(string taxnum) { + this.taxnum = taxnum; + if (HXTokenHelperList == null) HXTokenHelperList = new List(); + HXTokenHelperList.Add(this); + } + 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); - //读取业务 - 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); - - if (_return.code == "070101" || _return.code == "070301") + if (!(curr == null)) { - //appkey与token问题 需要重新认证 - //HangXinRequestHelper.clear(accessToken); - var result = new DBResult(false, "需要重新认证", null); - return result; + curr.accessToken = accessToken; } - if (_return.code == "070302") + else { - //appkey与token问题 需要重新认证 - //HangXinRequestHelper.clear(accessToken); - var result = new DBResult(false, "需要联系诺诺平台开通相关权限", null); - return result; + HXTokenHelperList.Add(this); } + } - 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; + /// + /// 处理 获取令牌/刷新令牌 命令的返回值 + /// + /// + //private void dealResponse_token(string response) { + // var _ISVToken = DSWeb.TruckMng.Helper.JsonConvert.Deserialize(response); + // error = _ISVToken.error; + // if (string.IsNullOrEmpty(error)) + // { + // accessToken = _ISVToken.access_token; + // refreshToken = _ISVToken.refresh_token; + // userId = _ISVToken.userId; + // var userinfo = _ISVToken._oauthUser; + // taxnum = userinfo.userName; + // tokenstarttime = System.DateTime.Now; - head.DbOperationType = DbOperationType.DbotUpd; - head.ModelUIStatus = "E"; - var modb = new ModelObjectDB(); - var result = modb.Save(head); - result.Message = info.resultMsg; + // var i = BasicDataRefDAL.ExecSql(getUpdStr()); + // if (i == 0) + // { + // try + // { + // i = BasicDataRefDAL.ExecSql(getInsertStr()); + // BasicDataRefDAL.SaveLog(getInsertStr(), "诺诺平台", "保存Token", "Insert"); + // } + // catch { } + // } + // else + // { + // BasicDataRefDAL.SaveLog(getUpdStr(), "诺诺平台", "保存Token", "Update"); + // } + // } + // else + // { + // error_description = _ISVToken.error_description; + // } + //} - if (info.resultMsg.Contains("开具结果:0,开具失败原因:开票异常")) - { - result.Message = "开票异常,请尝试重新连接税控盘、重新启动税控软件和诺诺客户端,然后再次读取发票信息;如仍显示此提示,请联系诺诺平台客服人员,并提供销方税号和此发票的流水号"; - } - return result; + //private void dealRefresh_token(string response) { + // var _ISVToken = DSWeb.TruckMng.Helper.JsonConvert.Deserialize(response); + // error = _ISVToken.error; + // if (string.IsNullOrEmpty(error)) + // { + // accessToken = _ISVToken.access_token; + // refreshToken = _ISVToken.refresh_token; + + // var i = BasicDataRefDAL.ExecSql(getUpdStr()); + // BasicDataRefDAL.SaveLog(getUpdStr(), "诺诺平台", "保存Token", "refresh Update"); + + // } + // else + // { + // error_description = _ISVToken.error_description; + // } + //} + + public static HangXinRequestHelper getHelper(string taxnum) + { + + //ReadToken(); + //foreach (var h in HXTokenHelperList) + //{ + // if (h.taxnum == taxnum) + // { + // return h; + // } + //} + //var result = new HangXinRequestHelper(taxnum); + //return result; + + var _token = getPortToken(taxnum); + return _token; + } + + protected static HangXinRequestHelper getPortToken(string taxnum) + { + + try + { + ///读取接口token + //JObject reqObj = new JObject(); + //reqObj.Add("taxnum", taxnum); + var dic = new Dictionary(); + dic.Add("taxnum", taxnum); + + var rtn = WebRequestHelper.DoPost(_IURL, dic, 10000); + //var rtn = WebRequestHelper.DoPost(_SandBoxURL, dic, 20000); + + //RepCZModel CZM = Newtonsoft.Json.JsonConvert.DeserializeObject(rtn); + PortTokenmb pt = Newtonsoft.Json.JsonConvert.DeserializeObject(rtn); + + if (pt.status == "1") + { + foreach (var hx in HXTokenHelperList) + { + if (hx.taxnum == taxnum) + { + hx.accessToken = pt.message; + hx.CanUse = true; + hx.ERRORMSG = ""; + return hx; + } + } + var result = new HangXinRequestHelper(taxnum, pt.message); + + return result; + } + else + return new HangXinRequestHelper(taxnum, ""); } - else + catch (Exception e) { - var msg = _return.code + ":" + _return.describe; - var result = new DBResult { Success = false, Message = DSWeb.TruckMng.Helper.JsonConvert.Serialize(msg), Data = "" }; + var result = new HangXinRequestHelper(taxnum, ""); + result.CanUse = false; + result.ERRORMSG = "没有取得开票密钥:" + e.Message; return result; - } } - public DBResult VoidInvoice(ChInvoice_HangXin head) + + protected static HangXinRequestHelper getPortToken_诺诺全电发票自应用模式(string taxnum) { - if (string.IsNullOrEmpty(head.INVOICESERIALNUM)) + + try { - var result = new DBResult { Success = false, Message = "还未成功进行平台开票,不需要执行作废", Data = "" }; + var result = new HangXinRequestHelper(); + + var INVITERFACE = MsSysInvInterFaceSetDAL.GetData("INVITERFACE='诺诺全电发票'", ""); + + if (string.IsNullOrWhiteSpace(INVITERFACE.NUONUOAPPKEY)) + { + return result; + } + else + { + result.appKey = INVITERFACE.NUONUOAPPKEY; + result.appSecret = INVITERFACE.NUONUOAPPSECRET; + } + + var dic = new Dictionary + { + { "taxnum", taxnum }, + { "client_id", result.appKey }, + { "client_secret", result.appSecret } + }; + + var porturl = "http://47.104.90.170:5200/fp/free_type/"; + + var rtn = WebRequestHelper.DoPost(porturl, dic, 10000); + //var rtn = WebRequestHelper.DoPost(_SandBoxURL, dic, 20000); + + //RepCZModel CZM = Newtonsoft.Json.JsonConvert.DeserializeObject(rtn); + PortTokenmb pt = Newtonsoft.Json.JsonConvert.DeserializeObject(rtn); + + if (pt.status == "1") + { + //foreach (var hx in HXTokenHelperList) + //{ + // if (hx.taxnum == taxnum) + // { + // hx.accessToken = pt.message; + // hx.CanUse = true; + // hx.ERRORMSG = ""; + // return hx; + // } + //} + result.accessToken = pt.message; + + return result; + } + else + return new HangXinRequestHelper(taxnum, ""); + } + catch (Exception e) + { + + var result = new HangXinRequestHelper(taxnum); + result.CanUse = false; + result.ERRORMSG = "没有取得开票密钥:" + e.Message; return result; } + } - //作废接口 - string method = "nuonuo.electronInvoice.invoiceCancellation"; -// String content = "{" + -//"\"invoiceId\":\"19051413444101000011\"," + -//"\"invoiceCode\":\"033001800211\"," + -//"\"invoiceNo\":\"07912653\"" + -//"}"; - var json = "{" + - "\"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, "诺诺平台", "发票作废", "发送值"); - string _r = NNOpenSDK.sendPostSyncRequest(URL, getSendid(), appKey, appSecret, accessToken, taxnum, method, json); - BasicDataRefDAL.SaveLog(_r, "诺诺平台", "发票作废", "返回值"); + /// + /// 开出发票 + /// + /// + /// + /// + public DBResult PostInvoice(ChInvoice_HangXin head, List detailList) + { + var billno = head.BILLNO; + + + + //20191028 如果该发票的状态为开票失败 则将其billno临时变更为billno+时分秒,以避开诺诺平台的orderNo不能重复的逻辑 + //然后处理返回值时将新的流水号写回。 + //20191108 + //if (head.EINVOICESTATE == "3"|| head.EINVOICESTATE == "0") + //{ + // head.BILLNO= billno+ DateTime.Now.ToString("HHmmss"); + //} + + var _head = new HXInvoice(head, detailList); + + var json = DSWeb.TruckMng.Helper.JsonConvert.Serialize(_head); + + var _r = ""; + + + _r = PostInvoice(json); + + var _return = dealresponse_KP(_r); if (_return.code == "E0000") { - //作废请求成功 + //开票提交成功 - var invoiceSerialNum = _return.result.invoiceId; + var invoiceSerialNum = _return.result.invoiceSerialNum; + //立即调用读取发票信息的方法 将返回值设置进head 并保存 head.INVOICESERIALNUM = invoiceSerialNum; + head.BILLNO = billno; - head.ISDELETE = "true"; + head.DbOperationType = DbOperationType.DbotUpd; + head.ModelUIStatus = "E"; + var modb = new ModelObjectDB(); + var result = modb.Save(head); - var result = ReadInvoice(head); + result = ReadInvoice(head); - //var result = new DBResult { Success = true, Message = _return.code + ":" + _return.describe, Data = head }; + //var returndate = ChinvoiceDAL.GetDataList(0, 1, "cm.INVOICESERIALNUM='" + head.INVOICESERIALNUM + "'", head.OPERATOR); + + //result.Data = returndate; return result; } - else + else if (_return.code == "070101" || _return.code == "070301") { - - var msg = _return.code+_return.status + ":" + _return.describe+ _return.msg; - var result = new DBResult { Success = false, Message = DSWeb.TruckMng.Helper.JsonConvert.Serialize(msg), Data = "" }; + //appkey与token问题 需要重新认证 + //HangXinRequestHelper.clear(accessToken); + var result = new DBResult(false, "需要重新认证", null); return result; - } - } - - /// - /// 处理开票命令返回值 - /// - /// - /// - private KPResponse dealresponse_KP(string json) { - var result = new KPResponse(); - - result = DSWeb.TruckMng.Helper.JsonConvert.Deserialize(json.Trim('"')); + else if (_return.code == "E9106") + { + //E9106 订单编号不能重复 + //同billno重复发送 执行一次用订单号读取 + return ReadInvoice_BILLNO(head); + } + else + { + var reault = new DBResult(false, _return.message, head); + return reault; + } - return result; } - /// - /// 处理 读取发票信息命令 - /// - /// - /// - private ReadResponse dealresponse_Read(string json) + public string PostInvoice(string json) { - var result = new ReadResponse(); - result = DSWeb.TruckMng.Helper.JsonConvert.Deserialize(json.Trim('"')); + 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); + + BasicDataRefDAL.SaveLog(result, "诺诺平台", "发票开出", "返回值"); return result; } - /// - /// 执行save操作 - /// - //private void DoSaveToken() - //{ - // if (HXTokenHelperList==null ||HXTokenHelperList.Count == 0) return; - - // SaveToken(); - //} - /// - /// 将数据库内记录的token信息读入static列表 - /// - private static void ReadToken() + public DBResult ReadInvoice(string INVOICESERIALNUM, string USERID) { - //BasicDataRefDAL.SaveLog(" SELECT * from Invoice_HangXinToken ", "诺诺平台", "读取数据库token", "读取数据库token"); - /* 20191210 废弃 - var strSql = " SELECT * from Invoice_HangXinToken "; - Database db = DatabaseFactory.CreateDatabase(); - bool neednew = false; + var head = ChinvoiceDAL.GetData("cm.INVOICESERIALNUM='" + INVOICESERIALNUM + "'"); - using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) + var _r = ReadInvoice(head); + + return _r; + + } + + public DBResult ReadInvoice(ChInvoice_HangXin head) + { + if (string.IsNullOrEmpty(head.INVOICESERIALNUM)) { - while (reader.Read()) + var result = new DBResult { Success = false, Message = "还未成功进行平台开票,无可读数据", Data = "" }; + return result; + } + + string method = "nuonuo.electronInvoice.CheckEInvoice"; + var json = "{" + "\"invoiceSerialNum\":[\"" + head.INVOICESERIALNUM + "\"]" + "}"; + + + if (string.IsNullOrWhiteSpace(head.INVOICESERIALNUM)) + { + //如果流水号为空 则改为按业务编号读取 + method = "nuonuo.electronInvoice.querySerialNum"; + 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); + + 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; + + head.DbOperationType = DbOperationType.DbotUpd; + head.ModelUIStatus = "E"; + var modb = new ModelObjectDB(); + var result = modb.Save(head); + result.Message = info.resultMsg; + + + if (info.resultMsg.Contains("开具结果:0,开具失败原因:开票异常")) { - neednew = true; - if (HXTokenHelperList == null) HXTokenHelperList = new List(); - foreach (var hx in HXTokenHelperList) - { - //BasicDataRefDAL.SaveLog(" 循环税号token:" + hx.taxnum+";reader税号:"+ Convert.ToString(reader["TAXNUM"]), "诺诺平台", "读取数据库token", "读取数据库token"); - if (hx.taxnum == Convert.ToString(reader["TAXNUM"])) - { - //BasicDataRefDAL.SaveLog(" 刷新税号token:"+ hx.taxnum, "诺诺平台", "读取数据库token", "读取数据库token"); - hx.code = Convert.ToString(reader["CODE"]); - hx.userId = Convert.ToString(reader["USERID"]); - hx.accessToken = Convert.ToString(reader["ACCESSTOKEN"]); - hx.refreshToken = Convert.ToString(reader["REFRESHTOKEN"]); - if (reader["STARTTIME"] != DBNull.Value) - hx.tokenstarttime = Convert.ToDateTime(reader["STARTTIME"]); - //if (reader["SAVETIME"] != DBNull.Value) - // hx = Convert.ToString(reader["SAVETIME"]); - hx.error = Convert.ToString(reader["ERROR"]); - hx.error_description = Convert.ToString(reader["ERROR_DESCRIPTION"]); + result.Message = "开票异常,请尝试重新连接税控盘、重新启动税控软件和诺诺客户端,然后再次读取发票信息;如仍显示此提示,请联系诺诺平台客服人员,并提供销方税号和此发票的流水号"; + } - neednew = false; - break; - } - } - if (neednew) - { + return result; - var hx = new HangXinRequestHelper(Convert.ToString(reader["TAXNUM"])); + } + else + { - //BasicDataRefDAL.SaveLog(" 增加税号token:" + hx.taxnum, "诺诺平台", "读取数据库token", "读取数据库token"); - hx.code = Convert.ToString(reader["CODE"]); - hx.userId = Convert.ToString(reader["USERID"]); - hx.accessToken = Convert.ToString(reader["ACCESSTOKEN"]); - hx.refreshToken = Convert.ToString(reader["REFRESHTOKEN"]); - if (reader["STARTTIME"] != DBNull.Value) - hx.tokenstarttime = Convert.ToDateTime(reader["STARTTIME"]); - //if (reader["SAVETIME"] != DBNull.Value) - // hx = Convert.ToString(reader["SAVETIME"]); - hx.error = Convert.ToString(reader["ERROR"]); - hx.error_description = Convert.ToString(reader["ERROR_DESCRIPTION"]); - } - //BasicDataRefDAL.SaveLog(HangXinRequestHelper.HXTokenHelperList.Count.ToString(), "诺诺平台", "Token实体类总数", "读取数据库token"); + 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) + { + + //读取业务 + 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); + + 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; + + head.DbOperationType = DbOperationType.DbotUpd; + head.ModelUIStatus = "E"; + var modb = new ModelObjectDB(); + var result = modb.Save(head); + result.Message = info.resultMsg; + + + if (info.resultMsg.Contains("开具结果:0,开具失败原因:开票异常")) + { + result.Message = "开票异常,请尝试重新连接税控盘、重新启动税控软件和诺诺客户端,然后再次读取发票信息;如仍显示此提示,请联系诺诺平台客服人员,并提供销方税号和此发票的流水号"; } + + 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)) + { + var result = new DBResult { Success = false, Message = "还未成功进行平台开票,不需要执行作废", Data = "" }; + return result; + } + + //作废接口 + string method = "nuonuo.electronInvoice.invoiceCancellation"; + + // String content = "{" + + //"\"invoiceId\":\"19051413444101000011\"," + + //"\"invoiceCode\":\"033001800211\"," + + //"\"invoiceNo\":\"07912653\"" + + //"}"; + + var json = "{" + + "\"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, "诺诺平台", "发票作废", "发送值"); + string _r = NNOpenSDK.sendPostSyncRequest(URL, getSendid(), appKey, appSecret, accessToken, taxnum, method, json); + BasicDataRefDAL.SaveLog(_r, "诺诺平台", "发票作废", "返回值"); + var _return = dealresponse_KP(_r); + + if (_return.code == "E0000") + { + //作废请求成功 + + var invoiceSerialNum = _return.result.invoiceId; + + head.INVOICESERIALNUM = invoiceSerialNum; + + head.ISDELETE = "true"; + + var result = ReadInvoice(head); + + //var result = new DBResult { Success = true, Message = _return.code + ":" + _return.describe, Data = head }; + + return result; + + } + else + { + + 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; + } - */ } /// - /// 保存token信息,当获取和刷新时执行一次 + /// 处理开票命令返回值 + /// + /// + /// + private KPResponse dealresponse_KP(string json) + { + var result = new KPResponse(); + + result = DSWeb.TruckMng.Helper.JsonConvert.Deserialize(json.Trim('"')); + + return result; + } + /// + /// 处理 读取发票信息命令 + /// + /// + /// + private ReadResponse dealresponse_Read(string json) + { + var result = new ReadResponse(); + + result = DSWeb.TruckMng.Helper.JsonConvert.Deserialize(json.Trim('"')); + + return result; + } + + /// + /// 执行save操作 + /// + //private void DoSaveToken() + //{ + // if (HXTokenHelperList==null ||HXTokenHelperList.Count == 0) return; + + // SaveToken(); + //} + + /// + /// 将数据库内记录的token信息读入static列表 + /// + private static void ReadToken() + { + //BasicDataRefDAL.SaveLog(" SELECT * from Invoice_HangXinToken ", "诺诺平台", "读取数据库token", "读取数据库token"); + /* 20191210 废弃 + var strSql = " SELECT * from Invoice_HangXinToken "; + + Database db = DatabaseFactory.CreateDatabase(); + bool neednew = false; + + using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) + { + while (reader.Read()) + { + neednew = true; + if (HXTokenHelperList == null) HXTokenHelperList = new List(); + foreach (var hx in HXTokenHelperList) + { + //BasicDataRefDAL.SaveLog(" 循环税号token:" + hx.taxnum+";reader税号:"+ Convert.ToString(reader["TAXNUM"]), "诺诺平台", "读取数据库token", "读取数据库token"); + if (hx.taxnum == Convert.ToString(reader["TAXNUM"])) + { + //BasicDataRefDAL.SaveLog(" 刷新税号token:"+ hx.taxnum, "诺诺平台", "读取数据库token", "读取数据库token"); + hx.code = Convert.ToString(reader["CODE"]); + hx.userId = Convert.ToString(reader["USERID"]); + hx.accessToken = Convert.ToString(reader["ACCESSTOKEN"]); + hx.refreshToken = Convert.ToString(reader["REFRESHTOKEN"]); + if (reader["STARTTIME"] != DBNull.Value) + hx.tokenstarttime = Convert.ToDateTime(reader["STARTTIME"]); + //if (reader["SAVETIME"] != DBNull.Value) + // hx = Convert.ToString(reader["SAVETIME"]); + hx.error = Convert.ToString(reader["ERROR"]); + hx.error_description = Convert.ToString(reader["ERROR_DESCRIPTION"]); + + neednew = false; + break; + } + } + if (neednew) + { + + var hx = new HangXinRequestHelper(Convert.ToString(reader["TAXNUM"])); + + //BasicDataRefDAL.SaveLog(" 增加税号token:" + hx.taxnum, "诺诺平台", "读取数据库token", "读取数据库token"); + hx.code = Convert.ToString(reader["CODE"]); + hx.userId = Convert.ToString(reader["USERID"]); + hx.accessToken = Convert.ToString(reader["ACCESSTOKEN"]); + hx.refreshToken = Convert.ToString(reader["REFRESHTOKEN"]); + if (reader["STARTTIME"] != DBNull.Value) + hx.tokenstarttime = Convert.ToDateTime(reader["STARTTIME"]); + //if (reader["SAVETIME"] != DBNull.Value) + // hx = Convert.ToString(reader["SAVETIME"]); + hx.error = Convert.ToString(reader["ERROR"]); + hx.error_description = Convert.ToString(reader["ERROR_DESCRIPTION"]); + } + //BasicDataRefDAL.SaveLog(HangXinRequestHelper.HXTokenHelperList.Count.ToString(), "诺诺平台", "Token实体类总数", "读取数据库token"); + } + } + */ + } + + /// + /// 保存token信息,当获取和刷新时执行一次 + /// + /// + /// + //private bool SaveToken() { + // bool result = false; + + + // var i = BasicDataRefDAL.ExecSql(getUpdStr()); + // if (i == 0) { + // try + // { + // i = BasicDataRefDAL.ExecSql(getInsertStr()); + // BasicDataRefDAL.SaveLog(getInsertStr(), "诺诺平台", "保存Token", "SaveToken"); + // } + // catch { } + // } + // else { + // BasicDataRefDAL.SaveLog(getUpdStr(), "诺诺平台", "保存Token", "SaveToken"); + // } + + // if (i > 0) result = true; + // return result; + //} + + /// + /// 获取插入数据库所需的语句 + /// Invoice_HangXinToken + /// 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); + + return result; + } + private string getUpdStr() + { + var result = string.Format(" update Invoice_HangXinToken set CODE='{1}',USERID='{2}',ACCESSTOKEN='{3}',REFRESHTOKEN='{4}',STARTTIME='{5}',SAVETIME='{6}',ERROR='{7}',ERROR_DESCRIPTION='{8}' where TAXNUM='{0}'", 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; + } + + + } + + public class 诺诺全电发票 : HangXinRequestHelper + { + + public static 诺诺全电发票 getHelper(string taxnum) + { + + var _token = getPortToken_诺诺全电发票自应用模式(taxnum); + + 诺诺全电发票 result = new 诺诺全电发票(); + result.appKey = _token.appKey; + result.appSecret = _token.appSecret; + result.accessToken = _token.accessToken; + result.taxnum = taxnum; + + return result; + } + + //接口函数的地址不同 + public DBResult ReadInvoice(ChInvoice_HangXin head) + { + if (string.IsNullOrEmpty(head.INVOICESERIALNUM) && !head.全电发票()) + { + var result = new DBResult { Success = false, Message = "还未成功进行平台开票,无可读数据", Data = "" }; + return result; + } + + string method = "nuonuo.OpeMplatform.queryInvoiceResult"; + var json = "{" + "\"serialNos\":[\"" + head.INVOICESERIALNUM + "\"]," + "\"orderNo\":[]," + "\"isOfferInvoiceDetail\":0 }"; + + + if (string.IsNullOrWhiteSpace(head.INVOICESERIALNUM)) + { + //如果流水号为空 则改为按业务编号读取 + method = "nuonuo.OpeMplatform.queryInvoiceResult"; + json = "{" + "\"orderNos\":[\"" + head.BILLNO + "\"]," + "\"serialNos\":[]," + "\"isOfferInvoiceDetail\":0 }"; + } + + //读取业务 + //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); + + 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 = new ChInvoice_HangXin(); + + if (!head.全电发票()) + { + returndate = ChinvoiceDAL.GetData("cm.INVOICESERIALNUM='" + head.INVOICESERIALNUM + "'"); + } + if (head.全电发票()) + { + returndate = ChinvoiceDAL.GetData("cm.BILLNO='" + head.BILLNO + "'"); + } + head = returndate; + + //var invoiceSerialNum = _return.result[0].invoiceSerialNum; + var info = _return.result[0]; + //立即调用读取发票信息的方法 将返回值设置进head 并保存 + //head.INVOICESERIALNUM = invoiceSerialNum; + head.INVOICECODE = info.invoiceCode; + head.INVOICENO = info.invoiceNo; + head.EINVOICESTATE = info.status; + head.INVOICEINFOURL = info.ofdUrl; + head.INVOICEPDFURL = info.paperPdfUrl; + + head.INVOICEMAKETIME = BasicDataRefDAL.Timestamp2Datetime(info.invoiceTime).ToString("yyyy-MM-dd HH:mm:ss"); + //if (!string.IsNullOrWhiteSpace(info.invoiceSerialNum)) + //{ + // head.INVOICESERIALNUM = info.invoiceSerialNum; + //} + //head.REMARK = head.REMARK.Replace(info.remark,"")+ info.remark; + + head.DbOperationType = DbOperationType.DbotUpd; + head.ModelUIStatus = "E"; + var modb = new ModelObjectDB(); + var result = modb.Save(head); + if (!result.Success) + return result; + + result.Message = info.statusMsg; + if (result.Message.IndexOf("失败") >= 0) + { + result.Success = false; + result.Message += ":" + info.failCause; + + //此处调用一次重推 + var hx = getHelper(head.TAXCODE); + hx.重推(head); + } + else + { + result.Message += ":" + info.failCause; + } + result.Data = head; + return result; + + } + else + { + var failCause = ""; + + try + { + var info = _return.result[0]; + failCause = "[" + info.failCause + "]"; + } + catch + { + + } + + var msg = _return.code + ":" + _return.describe + failCause; + var result = new DBResult { Success = false, Message = DSWeb.TruckMng.Helper.JsonConvert.Serialize(msg), Data = "" }; + return result; + + } + } + + public DBResult 重推(ChInvoice_HangXin head) + { + + var result = new DBResult(); + if (string.IsNullOrEmpty(head.INVOICESERIALNUM)) + { + result = new DBResult { Success = false, Message = "还未成功进行平台开票,无重试数据", Data = "" }; + return result; + } + + var senid = Guid.NewGuid().ToString(); + + string method = "nuonuo.OpeMplatform.reInvoice"; + + var content = new + { + fpqqlsh = head.INVOICESERIALNUM, + orderno = head.BILLNO, + nextInvoiceCode = "", + invoiceNumStart = "", + invoiceNumEnd = "" + }; + + var json = DSWeb.MvcShipping.Helper.JsonConvert.Serialize(content); + //"{" + "\"fpqqlsh\":\"" + head.INVOICESERIALNUM + "\"," + "\"orderNo\":[]," + "\"isOfferInvoiceDetail\":0 }"; + + + + + //读取业务 + //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); + + return result; + } + + private ReadResponse_诺诺全电发票 dealresponse_Read(string json) + { + var result = new ReadResponse_诺诺全电发票(); + + result = DSWeb.TruckMng.Helper.JsonConvert.Deserialize(json.Trim('"')); + + return result; + } + + + public DBResult PostInvoice(ChInvoice_HangXin head, List detailList) + { + var billno = head.BILLNO; + + var _head = new NuoNuoQuanDianInvoice(head, detailList); + + var json = DSWeb.TruckMng.Helper.JsonConvert.Serialize(_head); + + var _r = ""; + + + _r = PostInvoice(json); + + + var _return = dealresponse_KP(_r); + + if (_return.code == "E0000") + { + //开票提交成功 + + var invoiceSerialNum = _return.result.invoiceSerialNum; + + //立即调用读取发票信息的方法 将返回值设置进head 并保存 + head.INVOICESERIALNUM = invoiceSerialNum; + head.BILLNO = billno; + + head.DbOperationType = DbOperationType.DbotUpd; + head.ModelUIStatus = "E"; + var modb = new ModelObjectDB(); + var result = modb.Save(head); + + result = ReadInvoice(head); + + //var returndate = ChinvoiceDAL.GetDataList(0, 1, "cm.INVOICESERIALNUM='" + head.INVOICESERIALNUM + "'", head.OPERATOR); + + //result.Data = returndate; + + return result; + + } + else if (_return.code == "070101" || _return.code == "070301") + { + //appkey与token问题 需要重新认证 + //HangXinRequestHelper.clear(accessToken); + var result = new DBResult(false, "需要重新认证", null); + return result; + } + else if (_return.code == "E9106") + { + //E9106 订单编号不能重复 + //同billno重复发送 执行一次用订单号读取 + return ReadInvoice_BILLNO(head); + } + else + { + var reault = new DBResult(false, _return.message, head); + return reault; + } + + } + private string PostInvoice(string json) + { + + string method = "nuonuo.OpeMplatform.requestBillingNew"; + + 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); + + BasicDataRefDAL.SaveLog(result, "诺诺平台", "发票开出", "返回值"); + + return result; + } + + /// + /// 诺诺全电 快速冲红 + /// + /// + /// + /// + public DBResult PostRedInvoice(ref ChInvoice_HangXin head) + { + //var billno = head.BILLNO; + + var _head = new NuoNuoQuanDian_SetRed(head); + + var json = DSWeb.TruckMng.Helper.JsonConvert.Serialize(_head); + + string method = "nuonuo.OpeMplatform.fastInvoiceRed"; + + BasicDataRefDAL.SaveLog("URL=" + URL + ";appKey=" + appKey + ";appSecret=" + appSecret + ";accessToken=" + accessToken + ";taxnum=" + taxnum + ";method=" + method + ";content=" + json, "诺诺平台", "快捷冲红", "发送值"); + string rtn = NNOpenSDK.sendPostSyncRequest(URL, getSendid(), appKey, appSecret, accessToken, taxnum, method, json); + + BasicDataRefDAL.SaveLog(rtn, "诺诺平台", "快捷冲红", "返回值"); + + + var _return = dealresponse_KP(rtn); + + var result = new DBResult(); + + if (_return.code == "E0000") + { + //冲红提交成功 + + var invoiceSerialNum = _return.result.invoiceSerialNum; + + //立即调用读取发票信息的方法 将返回值设置进head 并保存 + head.INVOICESERIALNUM = invoiceSerialNum; + + return result.OK(); + + } + else if (_return.code == "070101" || _return.code == "070301") + { + //appkey与token问题 需要重新认证 + //HangXinRequestHelper.clear(accessToken); + result.SetErrorInfo("需要重新认证"); + return result; + } + else if (_return.code == "E9106") + { + //E9106 订单编号不能重复 + //同billno重复发送 执行一次用订单号读取 + return ReadInvoice_BILLNO(head); + } + else + { + var reault = new DBResult(false, _return.message, head); + return reault; + } + + } + + /// + /// 诺诺全电 红字确认单申请 + /// + /// + /// + /// + public DBResult PostRedConfirm(ChInvoice_HangXin head, ref ChInvoice_HangXin bluehead, List detailList) + { + //var billno = head.BILLNO; + + var _head = new NuoNuoQuanDian_RedConfirm(head); + + var json = DSWeb.TruckMng.Helper.JsonConvert.Serialize(_head); + + string method = "nuonuo.OpeMplatform.saveInvoiceRedConfirm"; + + BasicDataRefDAL.SaveLog("URL=" + URL + ";appKey=" + appKey + ";appSecret=" + appSecret + ";accessToken=" + accessToken + ";taxnum=" + taxnum + ";method=" + method + ";content=" + json, "诺诺全电", "红字确认单", "发送值"); + 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(); + + if (_return.code == "E0000") + { + //红字申请单提交成功 + + //读取红字确认单 + var _r = ReadRedConfirm(ref head, detailList); + + if (!_r.Success) + { + return _r; + } + else + { + var hx = 诺诺全电发票.getHelper(head.TAXCODE); + if (!hx.CanUse) + { + result.SetErrorInfo(hx.ERRORMSG); + + return result; + } + //if (hx.accessToken == "") + //{ + // BasicDataRefDAL.SaveLog("NNReadInv;税号" + head.TAXCODE + "的 accessToken为空", "", "诺诺平台", "返回认证窗口"); + // var _r = TokenPage(); + // return _r; + //} + result = hx.ReadInvoice(head); + + if (!result.Success) + { + return result; + } + + //if (result.Message == "需要重新认证") + //{ + // //HangXinRequestHelper.clear(hx.accessToken); + // BasicDataRefDAL.SaveLog("ReadInvoice 反回‘需要重新认证’", "", "诺诺平台", "返回认证窗口"); + // var _r = TokenPage(); + // return _r; + //} + + var 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 result; + } + + + + + + } + //else if (_return.code == "070101" || _return.code == "070301") + //{ + // //appkey与token问题 需要重新认证 + // //HangXinRequestHelper.clear(accessToken); + // result.SetErrorInfo("需要重新认证"); + // return result; + //} + //else if (_return.code == "E9106") + //{ + // //E9106 订单编号不能重复 + // //同billno重复发送 执行一次用订单号读取 + // return ReadInvoice_BILLNO(head); + //} + else + { + bluehead.billUuid = ""; + var reault = new DBResult(false, _return.message, head); + return reault; + } + + } + + /// + /// 用户查询全电发票红字确认单 + /// + /// + /// + public DBResult ReadRedConfirm(ref ChInvoice_HangXin head, List detailList = null) + { + //var billno = head.BILLNO; + + var _head = new NuoNuoQuanDian_ReadRedConfirm(head); + + var json = DSWeb.TruckMng.Helper.JsonConvert.Serialize(_head); + + string method = "nuonuo.OpeMplatform.queryInvoiceRedConfirm"; + + BasicDataRefDAL.SaveLog("URL=" + URL + ";appKey=" + appKey + ";appSecret=" + appSecret + ";accessToken=" + accessToken + ";taxnum=" + taxnum + ";method=" + method + ";content=" + json, "诺诺全电", "读红字单", "发送值"); + 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(); + + if (_return.code == "E0000") + { + //根据查询结果读取红票信息 + //税务那边实际的红票的订单编号 即为红字申请单orderno,也就是当时传过去的咱们的发票BILLNO + + if (_return.申请成功()) + { + //则读取红票 + + //如不为空 这就是发出红字申请单之后返回结果成功立刻读的 + //如为空 就是已产生的红票读取 就不保存了 + if (detailList != null) + { + head.INVOICESERIALNUM = ""; + var modb = new ModelObjectDB(); + + result = ChinvoiceDAL.SaveInvDetail(head.GID, detailList); + if (result.Success == true) + { + + result = modb.Save(head); + + }; + } + + + //result = ReadInvoice(head); + //return result; +; + } + + + return result.OK(); + + } + else + { + var reault = new DBResult(false, _return.message, head); + return reault; + } + + } + + private KPResponse dealresponse_KP(string json) + { + var result = new KPResponse(); + + result = DSWeb.TruckMng.Helper.JsonConvert.Deserialize(json.Trim('"')); + + return result; + } + + + public DBResult VoidInvoice(ChInvoice_HangXin head) + { + if (string.IsNullOrEmpty(head.INVOICESERIALNUM)) + { + var result = new DBResult { Success = false, Message = "还未成功进行平台开票,不需要执行作废", Data = "" }; + return result; + } + + //作废接口 + string method = "nuonuo.electronInvoice.invoiceCancellation"; + + // String content = "{" + + //"\"invoiceId\":\"19051413444101000011\"," + + //"\"invoiceCode\":\"033001800211\"," + + //"\"invoiceNo\":\"07912653\"" + + //"}"; + + var json = "{" + + "\"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, "诺诺平台", "发票作废", "发送值"); + string _r = NNOpenSDK.sendPostSyncRequest(URL, getSendid(), appKey, appSecret, accessToken, taxnum, method, json); + BasicDataRefDAL.SaveLog(_r, "诺诺平台", "发票作废", "返回值"); + var _return = dealresponse_KP(_r); + + if (_return.code == "E0000") + { + //作废请求成功 + + var invoiceSerialNum = _return.result.invoiceId; + + head.INVOICESERIALNUM = invoiceSerialNum; + + head.ISDELETE = "true"; + + var result = ReadInvoice(head); + + //var result = new DBResult { Success = true, Message = _return.code + ":" + _return.describe, Data = head }; + + return result; + + } + else + { + + 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; + + } + } + + } + public class PortTokenmb + { + public string message { get; set; } + public string status { get; set; } + } + + [JsonObject] + public class ISVTokenmb : ModelObjectBillHead + { + public string access_token { get; set; } + public string refresh_token { get; set; } + + public string expires_in { get; set; } + public string userId { get; set; } + + public string oauthUser { get; set; } + public oauthUser _oauthUser + { + get + { + oauthUser r_oauthUser = DSWeb.TruckMng.Helper.JsonConvert.Deserialize(oauthUser);//DSWeb.TruckMng.Helper. + return r_oauthUser; + } + } + + public string error_description { get; set; } + public string error { get; set; } + + /*"{\"access_token\":\"98600c833f178852e2f4d51cexk9yegi\", + * \"refresh_token\":\"faf038898dec26eac62640aaed0506cb\", + * \"oauthUser\":\" + * {\\\"userName\\\":\\\"339901999999142\\\", + * \\\"registerType\\\":\\\"1\\\"}\", + * \"expires_in\":86356, + * \"userId\":\"d1aa0da6bc9840ae83c1120cecd057ac\"}"*/ + + } + + [JsonObject] + public class Refreshtokenmb + { + //{"access_token":"1213ef77eab8280536a1a41jehndvz3i","refresh_token":"1a743ee6fd1d965db2b39943e703da4a","expires_in":86400} + //{"error_description":"Incorrect refreshToken[8ffb4a7e21691a5d295ee4f64920fc0d]","error":"070314"} + public string access_token { get; set; } + public string refresh_token { get; set; } + public string error_description { get; set; } + public string error { get; set; } + } + + [JsonObject] + public class oauthUser : ModelObjectBillBody + { + public string userName { get; set; } + public string registerType { get; set; } + } + + [JsonObject] + ///解析开票命令返回值;作废命令返回值 + public class KPResponse + { + public string code { get; set; } + public string describe { get; set; } + public string msg { get; set; } + public string status { get; set; } + public string message { get { return code + ":" + describe; } } + + //public KPResult _result { get {return DSWeb.TruckMng.Helper.JsonConvert.Deserialize(result);} } + + public KPResult result { get; set; } + } + + [JsonObject] + ///解析开票命令返回值内的result + public class KPResult + { + public string invoiceSerialNum { get; set; } + public string invoiceId { get; set; } + } + + [JsonObject] + public class 红字申请单发送返回值 : KPResponse + { + //{"code":"E0000","describe":"调用成功","result":"IN2023051900001"} + public new string result { get; set; } + + } + + [JsonObject] + ///解析开票命令返回值;作废命令返回值 + public class 红字申请单读取返回值 : KPResponse + { + public new 红字申请单result result { get; set; } + + public bool 申请成功() + { + return result.billStatus() == "01"; + } + } + + public class 红字申请单result + { + public int total { get; set; } + public new List<红字申请单> list { get; set; } + + public string billStatus() + { + if (list == null || list.Count == 0) return null; + return list[0].billStatus; + } + + } + + + public class 红字申请单明细 + { + /// + /// + /// + public int id { get; set; } + /// + /// + /// + public string billId { get; set; } + /// + /// + /// + public int detailIndex { get; set; } + /// + /// + /// + public int blueDetailIndex { get; set; } + /// + /// 代理运杂费 + /// + public string goodsName { get; set; } + /// + /// + /// + public string unit { get; set; } + /// + /// + /// + public string specType { get; set; } + /// + /// + /// + public string taxExcludedPrice { get; set; } + /// + /// + /// + public string taxExcludedAmount { get; set; } + /// + /// + /// + public string num { get; set; } + /// + /// + /// + public string taxRate { get; set; } + /// + /// + /// + public string taxAmount { get; set; } + /// + /// + /// + public string goodsCode { get; set; } + /// + /// + /// + public string favouredPolicyFlag { get; set; } + /// + /// + /// + public string favouredPolicyName { get; set; } + /// + /// + /// + public string zeroRateFlag { get; set; } + /// + /// 经纪代理服务 + /// + public string goodsCodeAbb { get; set; } + /// + /// + /// + public string price { get; set; } + /// + /// + /// + public int withTaxFlag { get; set; } + /// + /// + /// + public string deduction { get; set; } + /// + /// + /// + public string taxIncludedAmount { get; set; } + } + + public class 红字申请单 + { + /// + /// + /// + public int id { get; set; } + /// + /// + /// + public string billId { get; set; } + /// + /// + /// + public string billNo { get; set; } + /// + /// + /// + public string billUuid { get; set; } + /// + /// + /// + public string billStatus { get; set; } + /// + /// + /// + public string requestStatus { get; set; } + /// + /// + /// + public string billMessage { get; set; } + /// + /// + /// + public int openStatus { get; set; } + /// + /// + /// + public int applySource { get; set; } + /// + /// + /// + public DateTime billTime { get; set; } + /// + /// + /// + public string taxExcludedAmount { get; set; } + /// + /// + /// + public string taxAmount { get; set; } + /// + /// + /// + public string taxIncludeAmount { get; set; } + /// + /// + /// + public string blueElecInvoiceNumber { get; set; } + /// + /// + /// + public string blueInvoiceNumber { get; set; } + /// + /// + /// + public string blueInvoiceCode { get; set; } + /// + /// + /// + public DateTime blueInvoiceTime { get; set; } + /// + /// + /// + public string blueInvoiceLine { get; set; } + /// + /// + /// + public string sellerTaxNo { get; set; } + /// + /// 青岛锦海运通供应链有限公司 + /// + public string sellerName { get; set; } + /// + /// + /// + public string buyerTaxNo { get; set; } + /// + /// 青岛东宝电子有限公司 + /// + public string buyerName { get; set; } + /// + /// + /// + public DateTime createTime { get; set; } + /// + /// + /// + public DateTime updateTime { get; set; } + /// + /// + /// + public string sellerAccount { get; set; } + /// + /// 中国建设银行平度支行 37101997906051000773 + /// + public string buyerAccount { get; set; } + /// + /// + /// + public string vatUsage { get; set; } + /// + /// + /// + public string saleTaxUsage { get; set; } + /// + /// + /// + public string accountStatus { get; set; } + /// + /// + /// + public string departmentId { get; set; } + /// + /// /// - /// - /// - //private bool SaveToken() { - // bool result = false; - - - // var i = BasicDataRefDAL.ExecSql(getUpdStr()); - // if (i == 0) { - // try - // { - // i = BasicDataRefDAL.ExecSql(getInsertStr()); - // BasicDataRefDAL.SaveLog(getInsertStr(), "诺诺平台", "保存Token", "SaveToken"); - // } - // catch { } - // } - // else { - // BasicDataRefDAL.SaveLog(getUpdStr(), "诺诺平台", "保存Token", "SaveToken"); - // } - - // if (i > 0) result = true; - // return result; - //} - + public string clerkId { get; set; } /// - /// 获取插入数据库所需的语句 - /// Invoice_HangXinToken - /// 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); - - return result; - } - private string getUpdStr() - { - var result = string.Format(" update Invoice_HangXinToken set CODE='{1}',USERID='{2}',ACCESSTOKEN='{3}',REFRESHTOKEN='{4}',STARTTIME='{5}',SAVETIME='{6}',ERROR='{7}',ERROR_DESCRIPTION='{8}' where TAXNUM='{0}'", 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; - } - - - } - - - public class PortTokenmb { - public string message { get; set; } - public string status { get; set; } - } - - [JsonObject] - public class ISVTokenmb : ModelObjectBillHead - { - public string access_token { get; set; } - public string refresh_token { get; set; } - - public string expires_in { get; set; } - public string userId { get; set; } - - public string oauthUser { get; set; } - public oauthUser _oauthUser - { - get - { - oauthUser r_oauthUser = DSWeb.TruckMng.Helper.JsonConvert.Deserialize(oauthUser);//DSWeb.TruckMng.Helper. - return r_oauthUser; - } - } - - public string error_description { get; set; } - public string error { get; set; } - - /*"{\"access_token\":\"98600c833f178852e2f4d51cexk9yegi\", - * \"refresh_token\":\"faf038898dec26eac62640aaed0506cb\", - * \"oauthUser\":\" - * {\\\"userName\\\":\\\"339901999999142\\\", - * \\\"registerType\\\":\\\"1\\\"}\", - * \"expires_in\":86356, - * \"userId\":\"d1aa0da6bc9840ae83c1120cecd057ac\"}"*/ - - } - - [JsonObject] - public class Refreshtokenmb - { - //{"access_token":"1213ef77eab8280536a1a41jehndvz3i","refresh_token":"1a743ee6fd1d965db2b39943e703da4a","expires_in":86400} - //{"error_description":"Incorrect refreshToken[8ffb4a7e21691a5d295ee4f64920fc0d]","error":"070314"} - public string access_token { get; set; } - public string refresh_token { get; set; } - public string error_description { get; set; } - public string error { get; set; } - } - - [JsonObject] - public class oauthUser : ModelObjectBillBody - { - public string userName { get; set; } - public string registerType { get; set; } - } - - [JsonObject] - ///解析开票命令返回值;作废命令返回值 - public class KPResponse - { - public string code { get; set; } - public string describe { get; set; } - public string msg { get; set; } - public string status { get; set; } - public string message { get { return code + ":" + describe; } } - - //public KPResult _result { get {return DSWeb.TruckMng.Helper.JsonConvert.Deserialize(result);} } - - public KPResult result { get; set; } + public string extensionNumber { get; set; } + /// + /// + /// + public string taxNum { get; set; } + /// + /// + /// + public string account { get; set; } + /// + /// + /// + public string redReason { get; set; } + /// + /// + /// + public string confirmAgreement { get; set; } + /// + /// + /// + public string confirmReason { get; set; } + /// + /// + /// + public string confirmTime { get; set; } + /// + /// + /// + public int requestSrc { get; set; } + /// + /// + /// + public List<红字申请单明细> detail { get; set; } } - [JsonObject] - ///解析开票命令返回值内的result - public class KPResult - { - public string invoiceSerialNum { get; set; } - public string invoiceId { get; set; } - } [JsonObject] @@ -1624,6 +3027,17 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin */ public List result { get; set; } } + + [JsonObject] + ///解析读取发票信息命令返回值 + public class ReadResponse_诺诺全电发票 : ReadResponse + { + + public List result { get; set; } + } + + + [JsonObject] ///用于解析“读取发票信息”方法返回的发票信息 public class ReadResult @@ -1647,7 +3061,7 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin #endregion #region public Fields - + public string orderNo { get { return _orderNo; } @@ -1734,9 +3148,159 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin } + ///用于解析“读取发票信息”方法返回的发票信息 + public class ReadResult_诺诺全电发票 + { + /// + /// 流水号 + /// + 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 long invoiceTime { get; set; } + /// + /// + /// + public string invoiceCode { get; set; } + /// + /// + /// + public string invoiceNo { get; set; } + /// + /// + /// + public string exTaxAmount { get; set; } + /// + /// + /// + public string taxAmount { get; set; } + /// + /// 个人2 + /// + public string payerName { get; set; } + /// + /// + /// + public string payerTaxNo { get; set; } + /// + /// 电子增值税普通发票 + /// + public string invoiceKind { get; set; } + /// + /// + /// + public string checkCode { get; set; } + /// + /// 含底图纸票pdf地址 + /// + public string paperPdfUrl { get; set; } + public string ofdUrl { get; set; } + + /// + /// + /// + public List invoiceItems { get; set; } + + } + + public class InvoiceItems + { + /// + /// 门票 + /// + public string itemName { get; set; } + /// + /// 张 + /// + public string itemUnit { get; set; } + /// + /// + /// + public string itemPrice { get; set; } + /// + /// + /// + public string itemTaxRate { get; set; } + /// + /// + /// + public string itemNum { get; set; } + /// + /// + /// + public string itemAmount { get; set; } + /// + /// + /// + public string itemTaxAmount { get; set; } + /// + /// + /// + public string itemSpec { get; set; } + /// + /// + /// + public string itemCode { get; set; } + /// + /// + /// + public string isIncludeTax { get; set; } + /// + /// + /// + public string invoiceLineProperty { get; set; } + /// + /// + /// + public string zeroRateFlag { get; set; } + /// + /// + /// + public string favouredPolicyName { get; set; } + /// + /// + /// + public string favouredPolicyFlag { get; set; } + } + [JsonObject] public class P2INVOICE : BaseTableMC { } + + 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/ChInvoiceBLEdit.js b/DSWeb/Areas/Account/Viewsjs/Chfee_invoice_HangXin/ChInvoiceBLEdit.js index 03ce8712..e1296082 100644 --- a/DSWeb/Areas/Account/Viewsjs/Chfee_invoice_HangXin/ChInvoiceBLEdit.js +++ b/DSWeb/Areas/Account/Viewsjs/Chfee_invoice_HangXin/ChInvoiceBLEdit.js @@ -15,6 +15,7 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { addstore: false, PageSize: 30, sqlcontext: '', + INVITERFACE: '', initUIComponents: function () { this.serialNo = 0; @@ -228,12 +229,19 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { FLEX: 1, enumTypeId: 80002 }); - this.comboxINVOICELINE = getEnumcombox({ - LABEL: '发票种类', - NAME: 'INVOICELINE', + + this.storeINVOICELINE = Ext.create('DsExt.ux.RefEnumStore', {}); + this.storeINVOICELINE.load({ params: { enumTypeId: 80003 } }); + + this.comboxINVOICELINE = Ext.create('DsExt.ux.RefTableCombox', { + fieldLabel: "发票种类", //业务类型 FLEX: 0.65, - enumTypeId: 80003, + store: this.storeINVOICELINE, + name: 'INVOICELINE', + valueField: 'EnumValueId', + displayField: 'EnumValueName', + enableKeyEvents: true, listeners: { scope: this, 'select': function (combo, records, eOpts) { @@ -244,6 +252,7 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { } }); + this.storeInfoClientMailTel = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.InfoClientContactModel', proxy: { url: '/CommMng/BasicDataRef/GetInfoClientMailTel' } @@ -336,7 +345,7 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { CUSTTEL.setValue(getEndTel(data.INVADDRTEL)); - CUSTADDR.setValue(data.INVADDRTEL.replace( getEndTel(data.INVADDRTEL),"")); + CUSTADDR.setValue(data.INVADDRTEL.replace(getEndTel(data.INVADDRTEL), "")); if (CURR == 'RMB') { this.storecustbank.load({ @@ -382,7 +391,7 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { var CUSTNAME = this.formSearch.getForm().findField('CUSTNAME'); var tmpcust = CUSTNAME.getValue(); if (tmpcust == '' || tmpcust == null || tmpcust == undefined) { - CUSTNAME.setValue(CUSTOMERNAME); + CUSTNAME.setValue(CUSTOMERNAME); } } @@ -440,7 +449,7 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { CUSTTEL.setValue(getEndTel(data.INVADDRTEL)); CUSTADDR.setValue(data.INVADDRTEL.replace(getEndTel(data.INVADDRTEL), "")); - + if (CURR == 'RMB') { this.storecustbank.load({ @@ -485,6 +494,27 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, 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: { @@ -674,7 +704,24 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { 'select': function (combo, records, eOpts) { if (records.length > 0) { var companyid = records[0].data.GID; - this.StoreBANK.load({ params: { condition: " LINKID='" + companyid + "'" } }); + var CURR = this.formEdit.getForm().findField('RECVCURR').getValue(); + this.formEdit.getForm().findField('ACCOUNT').setValue(''); + this.StoreBANK.load({ + params: { condition: " LINKID='" + companyid + "'" }, + callback: function (r, options, success) { + if (success) { + if (this.StoreBANK.getCount() > 0) { + for (var i = 0; i < this.StoreBANK.getCount(); i += 1) { + var member = this.StoreBANK.getAt(i); + if (member.data.CURRENCY == CURR && member.data.ISDEF == 'True') { + this.formEdit.getForm().findField('ACCOUNT').setValue(member.data.BANKACCOUNT); + } + } + } + } + }, + scope: this + }); } @@ -704,6 +751,20 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { valueField: 'BANKACCOUNT', displayField: 'BANKACCOUNT' }); + + this.storeQuanDianYouHui = Ext.create('DsExt.ux.RefTableStore', { + model: 'DsExtEnumModel', + proxy: { + url: '/CommMng/PubSys/GetEnumValueList' + } + }); + this.storeInvCategory.load({ + params: { + enumTypeId: 80007 + } + }); + + //#endregion //编辑form this.formEdit = Ext.widget('form', { @@ -731,38 +792,44 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { }, items: [ { - //第一大格第一行 - xtype: 'container', - layout: 'hbox', - defaultType: 'textfield', - margins: '4 0 0 4', - items: [{ - fieldLabel: 'GID', - name: 'GID', - flex: 0, - hidden: true, - margins: '0' - }, - { - fieldLabel: 'BILLSTATUS', - name: 'BILLSTATUS', - flex: 0, - hidden: true, - margins: '0' - }, - { - fieldLabel: 'DZSTATUS', - name: 'DZSTATUS', - flex: 0, - hidden: true, - margins: '0' - }, - { - fieldLabel: 'VOUCHERNO', - name: 'VOUCHERNO', - flex: 0, - hidden: true, - margins: '0' + //第一大格第一行 + xtype: 'container', + layout: 'hbox', + defaultType: 'textfield', + margins: '4 0 0 4', + items: [{ + fieldLabel: 'GID', + name: 'GID', + flex: 0, + hidden: true, + margins: '0' + }, { + fieldLabel: 'billUuid',//用于放置全电发票冲红时的红票申请单编号 + name: 'billUuid', + flex: 0, + hidden: true, + margins: '0' + }, + { + fieldLabel: 'BILLSTATUS', + name: 'BILLSTATUS', + flex: 0, + hidden: true, + margins: '0' + }, + { + fieldLabel: 'DZSTATUS', + name: 'DZSTATUS', + flex: 0, + hidden: true, + margins: '0' + }, + { + fieldLabel: 'VOUCHERNO', + name: 'VOUCHERNO', + flex: 0, + hidden: true, + margins: '0' }, { fieldLabel: 'INVITERFACE', @@ -771,19 +838,19 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { hidden: true, margins: '0' }, - { - fieldLabel: 'VOUNO', - name: 'VOUNO', - flex: 0, - hidden: true, - margins: '0' - }, - { - fieldLabel: 'APPLICANT', - name: 'APPLICANT', - flex: 0, - hidden: true, - margins: '0' + { + fieldLabel: 'VOUNO', + name: 'VOUNO', + flex: 0, + hidden: true, + margins: '0' + }, + { + fieldLabel: 'APPLICANT', + name: 'APPLICANT', + flex: 0, + hidden: true, + margins: '0' }, { fieldLabel: 'OPERATORNAME', @@ -806,165 +873,171 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { hidden: true, margins: '0' }, - { - fieldLabel: 'COMPANYID', - name: 'COMPANYID', - flex: 0, - hidden: true, - margins: '0' - }, - { - fieldLabel: 'INVOICETYPE', - value: '1', - name: 'INVOICETYPE', - flex: 0, - hidden: true, - margins: '0' - }, - //{ - // fieldLabel: 'REMARK', - // name: 'REMARK', - // flex: 0, - // hidden: true, - // margins: '0' - //}, - { - fieldLabel: '编号', - readOnly: true, - hidden: true, - flex: 1, - name: 'BILLNO' - }, - { - fieldLabel: '发票类别', - readOnly: true, - flex: 0.5, - name: 'INVOICETYPEREF' - }, - { - fieldLabel: '开票日期', - labelWidth: labelwidth_top1, - tooltip: '记录“开出发票”的时间', - flex: 0.5, - format: 'Y-m-d', - xtype: 'datefield', - name: 'INVOICEMAKETIME' - }, + { + fieldLabel: 'COMPANYID', + name: 'COMPANYID', + flex: 0, + hidden: true, + margins: '0' + }, + { + fieldLabel: 'INVOICETYPE', + value: '1', + name: 'INVOICETYPE', + flex: 0, + hidden: true, + margins: '0' + }, + //{ + // fieldLabel: 'REMARK', + // name: 'REMARK', + // flex: 0, + // hidden: true, + // margins: '0' + //}, + { + fieldLabel: '编号', + readOnly: true, + hidden: true, + flex: 1, + name: 'BILLNO' + }, + { + fieldLabel: '发票类别', + readOnly: true, + flex: 0.5, + name: 'INVOICETYPEREF' + }, + { + fieldLabel: '开票日期', + labelWidth: labelwidth_top1, + tooltip: '记录“开出发票”的时间', + flex: 0.5, + format: 'Y-m-d', + xtype: 'datefield', + name: 'INVOICEMAKETIME' + }, this.comboxOPERATOR, - this.comboxPAYEE, - this.comboxCHECKER, - { - fieldLabel: '是否锁定', - labelWidth: labelwidth_top1, - flex: 0.5, - readOnly: true, - name: 'BILLSTATUSREF' - }, - { - fieldLabel: '是否打印', - labelWidth: labelwidth_top1, - flex: 0.5, - readOnly: true, - name: 'ISNEEDPRINT' - }, - { - fieldLabel: '是否结算', - labelWidth: labelwidth_top1, - flex: 0.5, - readOnly: true, - name: 'ISNEEDFEE' - }, - { - fieldLabel: '是否作废', - labelWidth: labelwidth_top1, - flex: 0.5, - readOnly: true, - name: 'ISDELETE' - }, - { - fieldLabel: '被冲红', - labelWidth: labelwidth_top1, - flex: 0.5, - readOnly: true, - name: 'SETRED' + this.comboxPAYEE, + this.comboxCHECKER, + { + fieldLabel: '是否锁定', + labelWidth: labelwidth_top1, + flex: 0.5, + readOnly: true, + name: 'BILLSTATUSREF' + }, + { + fieldLabel: '是否打印', + labelWidth: labelwidth_top1, + flex: 0.5, + readOnly: true, + name: 'ISNEEDPRINT' + }, + { + fieldLabel: '是否结算', + labelWidth: labelwidth_top1, + flex: 0.5, + readOnly: true, + name: 'ISNEEDFEE' + }, + { + fieldLabel: '是否作废', + labelWidth: labelwidth_top1, + flex: 0.5, + readOnly: true, + name: 'ISDELETE' + }, + { + fieldLabel: '被冲红', + labelWidth: labelwidth_top1, + flex: 0.5, + readOnly: true, + name: 'SETRED' + }, + { + xtype: 'hiddenfield', + flex: 0 + }] }, - { - xtype: 'hiddenfield', - flex: 0 - }] - }, - - { - //第一大格第二行 - xtype: 'container', - layout: 'hbox', - defaultType: 'textfield', - margins: '4 0 0 4', - items: [this.comboxPTORRED, this.comboxINVOICELINE, { - fieldLabel: 'EINVOICESTATE', - hidden: true, - flex: 1, - name: 'EINVOICESTATE' - }, - { - fieldLabel: '发票号', - readOnly: true, - labelWidth: labelwidth_top1, - flex: 0.85, - name: 'INVOICENO', - listeners: { - // 鼠标移动到文本框显示悬浮框 - render: function (p) { - p.getEl().on('mouseover', - function (p1) { - updateTip(p, '目前纸票和电票的票号都不可以指定\r\n\n纸票需要开出后自动生成发票号,\n然后根据这个发票号放置相应票号的空白发票进行打印'); - }); + //第一大格第二行 + xtype: 'container', + layout: 'hbox', + defaultType: 'textfield', + margins: '4 0 0 4', + items: [this.comboxPTORRED, this.comboxINVOICELINE, + + { + fieldLabel: 'EINVOICESTATE', + hidden: true, + flex: 1, + name: 'EINVOICESTATE' + }, + { + fieldLabel: '发票号', + readOnly: true, + labelWidth: labelwidth_top1, + flex: 0.85, + name: 'INVOICENO', + listeners: { + // 鼠标移动到文本框显示悬浮框 + render: function (p) { + p.getEl().on('mouseover', + function (p1) { + updateTip(p, '目前纸票和电票的票号都不可以指定\r\n\n纸票需要开出后自动生成发票号,\n然后根据这个发票号放置相应票号的空白发票进行打印'); + }); + } } + }, + { + fieldLabel: '发票代码', + labelWidth: labelwidth_top1, + readOnly: true, + flex: 1, + name: 'INVOICECODE' + }, + { + fieldLabel: '发票流水号', + labelWidth: labelwidth_top1, + readOnly: true, + flex: 1, + name: 'INVOICESERIALNUM' + }, + { + fieldLabel: '开票状态', + labelWidth: labelwidth_top1, + flex: 0.5, + readOnly: true, + name: 'EINVOICESTATEREF' + }, { + fieldLabel: '境外发票', //'是否改签', + flex: 0.5, + inputValue: true, + xtype: 'checkboxfield', + name: 'ISFRINV' + }, + { + fieldLabel: '发票详情页', + hidden: true, + flex: 1, + readOnly: true, + name: 'INVOICEINFOURL' + }, + { + fieldLabel: '发票PDF地址', + hidden: true, + flex: 1, + readOnly: true, + name: 'INVOICEPDFURL' } - }, - { - fieldLabel: '发票代码', - labelWidth: labelwidth_top1, - readOnly: true, - flex: 1, - name: 'INVOICECODE' - }, - { - fieldLabel: '发票流水号', - labelWidth: labelwidth_top1, - readOnly: true, - flex: 1, - name: 'INVOICESERIALNUM' - }, - { - fieldLabel: '开票状态', - labelWidth: labelwidth_top1, - flex: 1, - readOnly: true, - name: 'EINVOICESTATEREF' - }, - { - fieldLabel: '发票详情页', - hidden: true, - flex: 1, - readOnly: true, - name: 'INVOICEINFOURL' - }, - { - fieldLabel: '发票PDF地址', - hidden: true, - flex: 1, - readOnly: true, - name: 'INVOICEPDFURL' + //, + //{ + // xtype:'hiddenfield',flex:0.01 + //} + ] } - //, - //{ - // xtype:'hiddenfield',flex:0.01 - //} - ] - } ] //end items(fieldset 1) }, @@ -992,17 +1065,17 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { xtype: 'label', flex: 0.5, text: '', - },{ + }, { xtype: 'label', id: 'INVTITLE', - flex:1, + flex: 1, text: '增值税普通发票', style: { width: '95%', align: 'center', - marginBottom: '10px', + marginBottom: '6px', color: '#9c5223', - fontSize: '30px' + fontSize: '26px' } }] @@ -1014,7 +1087,7 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { items: [{ fieldLabel: '发票抬头', name: 'INVOICECUSTNAME' - },{ + }, { fieldLabel: '纳税人识别号', name: 'CUSTRATENO' }] @@ -1065,7 +1138,7 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { // flex: 1.4, // name: 'PUSHEMAIL' // } - this.comboxInfoClientMailTel + this.comboxInfoClientMailTel ] }] @@ -1196,6 +1269,7 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { { xtype: 'textareafield', grow: true, + flex: 4, labelWidth: labelwidth_sale, name: 'REMARK', height: 61, @@ -1207,7 +1281,7 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { defaultType: 'textfield', layout: 'anchor', region: 'east', - width: 160, + width: 80, defaults: { anchor: '100%' }, @@ -1244,6 +1318,7 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { }] }, + this.comboxRedReason, ////// { fieldLabel: '船名航次', hidden: true, @@ -1311,8 +1386,7 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { name: 'POD' }, { - fieldLabel: 'ATD',//'ETD' - hidden: true, + fieldLabel: 'ETD', hidden: true, labelWidth: 60, name: 'ETD' } @@ -1494,12 +1568,12 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { scope: this }, '-', { - text: '开票', - id:"btn_KP", - tooltip: '通过诺诺(瑞宏)开放平台开出发票', - handler: function (button, event) { - this.onNNMakeInvClick(); - }, + text: '开票', + id: "btn_KP", + tooltip: '通过诺诺(瑞宏)开放平台开出发票', + handler: function (button, event) { + this.onNNMakeInvClick(); + }, scope: this }, { @@ -1522,8 +1596,8 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { scope: this }, '-', { - text: '作废', - id: "btn_Void", + text: '作废', + id: "btn_Void", tooltip: '实际操作成功后才修改发票状态。注意:电票不可作废,纸票月内作废,月外冲红', handler: function (button, event) { this.onNNVoidInvClick(); @@ -1531,15 +1605,22 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { scope: this }, '-', { - text: '冲红', - id: "btn_Setred", - hidden: true, + text: '冲红', + id: "btn_Setred", + hidden: true, tooltip: '注意,未冲红、未作废的发票才能进行此操作', handler: function (button, event) { this.onNNSetRedClick(); }, scope: this + }, '-', + { + text: '打印', //打印 + handler: function (button, event) { + this.Print(); + }, + scope: this }] }); //end 按钮Toolbar //#endregion @@ -1963,7 +2044,7 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { }, { sortable: true, - dataIndex: 'ETD',//'ETD' + dataIndex: 'ETD', header: '开船日期', renderer: Ext.util.Format.dateRenderer('Y-m-d'), width: 100 @@ -2345,7 +2426,7 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { }, { sortable: true, - dataIndex: 'ETD',//'ETD' + dataIndex: 'ETD', header: '开船日期', renderer: Ext.util.Format.dateRenderer('Y-m-d'), width: 100 @@ -3026,7 +3107,7 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { } } } - }, this.comboxFSTATUS, + }, this.comboxFSTATUS, { xtype: 'button', width: 45, @@ -3115,7 +3196,7 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { }); //#region 发票备注 - + //#endregion @@ -3186,6 +3267,124 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { //#endregion 明细表 + //#region 附件上传 + + + + this.storeChfeeFile = Ext.create('Ext.data.Store', { + model: 'FeeFileModel', + remoteSort: false, + proxy: { + type: 'ajax', + url: '/Account/Chfee_payapplication/GetFileList', + reader: { + id: 'GID', + root: 'data', + totalProperty: 'totalCount' + } + } + }); + //表格 + this.FeeFileColumns = [ + { + sortable: true, hidden: true, + dataIndex: 'GID', readOnly: true, + header: 'GID', + width: 80 + }, { + sortable: true, hidden: false, + dataIndex: 'File_OriginalName', readOnly: true, + header: '文件名称', //文件名称 + renderer: function (value, p, record) { + return '' + value + ''; + }, + width: 180 + }, { + sortable: true, hidden: false, + dataIndex: 'UpdateTime', readOnly: true, + header: '上传日期', //上传日期 + width: 80 + }, { + sortable: true, hidden: false, + dataIndex: 'Operator', readOnly: true, + header: '上传者', //上传者 + width: 80 + }, { + sortable: true, hidden: true, + dataIndex: 'File_Name', readOnly: true, + header: '文件物理名称', //文件物理名称 + width: 80 + }, + { + sortable: true, hidden: true, + dataIndex: 'File_Path', + header: 'File_Path', + width: 80 + }, { + xtype: 'actioncolumn', + width: 50, + text: '操作', //操作 + items: [{ + icon: '/images/icons/btnSearch.gif', // Use a URL in the icon config + tooltip: '预览', + handler: function (grid, rowIndex, colIndex) { + var rec = grid.getStore().getAt(rowIndex); + var filePath = "/Areas/Account/Files/" + rec.get('BillNo') + '/' + rec.get('File_Name') + '?a=' + Math.random(); + var imgView = new Shipping.FileView({ filePath: filePath }); + imgView.show(); + } + }] + } + ]; + var selCertModel = Ext.create('Ext.selection.CheckboxModel'); + this.fileGrid = new Ext.grid.GridPanel({ + store: this.storeChfeeFile, + enableHdMenu: false, + layout: 'border', + region: 'center', + loadMask: { msg: '数据加载中,请稍等...' }, //数据加载中,请稍等... + trackMouseOver: true, + disableSelection: false, + selModel: selCertModel, + singleSelect: true, + selType: 'rowmodel', + tbar: [{ + text: '上传图片', //上传图片 + tooltip: '上传文件', + iconCls: "btnadddetail", + handler: function (button, event) { + this.onAddFileClick(button, event); + }, + scope: this + }, '-', { + text: '删除图片', //删除 + tooltip: '删除文件', //删除图片 + iconCls: "btndeletedetail", + handler: function (button, event) { + this.onDelFileClick(button, event); + }, + scope: this + }], + columns: this.FeeFileColumns + }); + //#endregion附件上传 + + //#region 增加附件上传tab + + this.page_2 = new Ext.Panel({ + id: "page_2", + title: '附件上传', //附件上传 + autoScroll: true, + layout: "border", + region: 'center', + //closable:true, + items: [this.fileGrid] + }); + + //#endregion + + + //#region 布局 //控件布局 this.panelTop = new Ext.Panel({ @@ -3220,7 +3419,7 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { id: "TabPanelID", enableTabScroll: true, split: true, - items: [this.panelInv, this.panelBody] + items: [this.panelInv, this.panelBody, this.page_2] }); Ext.apply(this, { @@ -3490,6 +3689,11 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { this.opStatus = ret[0]; this.StoreList = ret[1]; this.editRecord = ret[2]; + this.INVITERFACE = ret[4]; + + if (this.INVITERFACE == '诺诺全电发票') { + this.storeINVOICELINE.load({ params: { enumTypeId: 80006 } }); + } } if (this.opStatus == 'edit' || this.opStatus == 'copyadd') condition = " BILLNO='" + this.editRecord.get('BILLNO') + "'"; @@ -3529,7 +3733,7 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { var data = result.data; - + // _this.formEdit.getForm().findField('BILLSTATUS').setDisabled(false); _this.formEdit.getForm().reset(); _this.formAMT.getForm().reset(); @@ -3569,8 +3773,8 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { this.StoreBANK.load({ params: { condition: " LINKID='" + companyid + "'" } , callback: function (r, options, success) { - if (this.opStatus == 'add') - _this.setBank('RMB'); + if (_this.opStatus == 'add') + _this.setBank('RMB'); } }); @@ -3579,7 +3783,7 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { Data_pushmail = { EMAIL: data.PUSHEMAIL, NAMEANDEMAIL: data.PUSHEMAIL }; this.storeInfoClientMailTel.removeAll(); this.storeInfoClientMailTel.add(Data_pushmail); - + this.storeChfeeFile.load({ params: { start: 0, limit: 9999, BillNo: data.BILLNO } }); this.GetEditStatus(); } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); @@ -4583,14 +4787,14 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { this.storeAddFeeList.reload(); var sql = this.BillSql; if (!isNullorEmpty(sql)) - this.storeBodyAddList.load({ - params: { - start: 0, - limit: _this.PageSize, - sort: '', - condition: sql - } - }); + this.storeBodyAddList.load({ + params: { + start: 0, + limit: _this.PageSize, + sort: '', + condition: sql + } + }); _this.storeBodyList.load({ params: { @@ -4990,7 +5194,7 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { for (var i = 0; i < this.storeCurrExrate.getCount(); i += 1) { var member = this.storeCurrExrate.getAt(i); if (member.data.EXRATE == 0) { - _this.ExrateConversion(member.CURR, billcurr, 'bill', 0); + _this.ExrateConversion(member.data.CURR, billcurr, 'bill', 0); return; } bodydatas.push(member); @@ -5248,14 +5452,14 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { var sql = this.BillSql; if (!isNullorEmpty(sql)) - this.storeBodyAddList.load({ - params: { - start: 0, - limit: _this.PageSize, - sort: '', - condition: sql - } - }); + this.storeBodyAddList.load({ + params: { + start: 0, + limit: _this.PageSize, + sort: '', + condition: sql + } + }); _this.storeBodyList.load({ params: { condition: " BILLNO='" + billno + "'" @@ -5404,14 +5608,14 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { var sql = this.BillSql; if (!isNullorEmpty(sql)) - this.storeBodyAddList.load({ - params: { - start: 0, - limit: _this.PageSize, - sort: '', - condition: sql - } - }); + this.storeBodyAddList.load({ + params: { + start: 0, + limit: _this.PageSize, + sort: '', + condition: sql + } + }); this.storeBodyList.load({ params: { condition: " BILLNO='" + billno + "'" @@ -5707,14 +5911,14 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { var sql = this.BillSql; if (!isNullorEmpty(sql)) - this.storeBodyAddList.load({ - params: { - start: 0, - limit: _this.PageSize, - sort: '', - condition: sql - } - }); + this.storeBodyAddList.load({ + params: { + start: 0, + limit: _this.PageSize, + sort: '', + condition: sql + } + }); this.storeBodyList.load({ params: { condition: " BILLNO='" + billno + "'" @@ -6174,7 +6378,7 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { function (btn) { if (btn == 'yes') { - this.doPostInv(); + _this.doPostInv(); } }); @@ -6361,7 +6565,7 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { } else { _this.dealReturnData(result.Data); var pageurl = result.Data.INVOICEINFOURL; - if (isNullorEmpty(pageurl)) + if (isNullorEmpty(pageurl)) pageurl = result.Data.INVOICEPDFURL; @@ -6408,6 +6612,8 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { var billno = this.formEdit.getForm().findField('BILLNO').getValue(); + var redReason = this.formEdit.getForm().findField('redReason').getValue(); + if (billno == '*' || billno == '') { Ext.Msg.show({ title: '提示', @@ -6425,7 +6631,8 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { url: '/Account/Chfee_invoice_HangXin/NNSetRed', params: { bill: billno, - redirecturl: GetHangXinRedirectUrl() + redirecturl: GetHangXinRedirectUrl(), + redReason: redReason }, callback: function (options, success, response) { if (success) { @@ -6475,8 +6682,7 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { }, - ShowTokenPage: function (result) - { + ShowTokenPage: function (result) { if (result.Message == "需要认证诺诺用户名和密码") { DsOpenEditWin_NoUrl(result.Data, "平台开票信息认证", 600, 400, 300, 300); @@ -6602,18 +6808,18 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { //'更新', name: 'TemplateName', inputValue: '发票备注2' - }, { - boxLabel: '模板3', //'更新', - name: 'TemplateName', - inputValue: '发票备注3' - }] + }, { + boxLabel: '模板3', //'更新', + name: 'TemplateName', + inputValue: '发票备注3' + }] }, { - fieldLabel: '是否追加', //'是否改签', - inputValue: true, - xtype: 'checkboxfield', - name: 'ISZHUIJIA', - checked: true - } + fieldLabel: '是否追加', //'是否改签', + inputValue: true, + xtype: 'checkboxfield', + name: 'ISZHUIJIA', + checked: true + } ] //end root items }); @@ -6662,7 +6868,7 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { var REMARK = _this.formEdit.getForm().findField('REMARK').getValue(); if (ISZHUIJIA) _this.formEdit.getForm().findField('REMARK').setValue(REMARK + ' ' + data); - else + else _this.formEdit.getForm().findField('REMARK').setValue(data); _this.winCustomDataShowGet.close(); @@ -6827,11 +7033,11 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { //'更新', name: 'TemplateName', inputValue: '发票备注2' - }, { - boxLabel: '模板3', //'更新', - name: 'TemplateName', - inputValue: '发票备注3' - }], + }, { + boxLabel: '模板3', //'更新', + name: 'TemplateName', + inputValue: '发票备注3' + }], listeners: { change: function (rd, newValue, oldValue, eOpts) { Ext.Ajax.request({ @@ -6954,9 +7160,9 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { setInvTile: function (invline) { var INVTITLE = Ext.getCmp('INVTITLE'); - if (invline.indexOf('专用') != -1){ + if (invline.indexOf('专用') != -1) { INVTITLE.setText('增值税专用发票', false); - } else if (invline.indexOf('电') != -1){ + } else if (invline.indexOf('电') != -1) { INVTITLE.setText('增值税电子普通发票', false); } else { INVTITLE.setText('增值税普通发票', false); @@ -7023,7 +7229,7 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { }, setBank(CURR) { var BANK = this.formEdit.getForm().findField('ACCOUNT'); - var recs = DsStoreQueryBy2(this.StoreBANK, 'CURRENCY', CURR, 'ISDEF','True'); + var recs = DsStoreQueryBy2(this.StoreBANK, 'CURRENCY', CURR, 'ISDEF', 'True'); if (recs.getCount() > 0) { var data = recs.getAt(0).data; BANK.setValue(data.BANKACCOUNT); @@ -7580,6 +7786,73 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { }, + //#region 文件上传 + + onAddFileClick: function () { + //var billstatus = this.formEdit.getForm().findField('BILLSTATUS').getValue(); + //if ((billstatus != 1) && (billstatus != 4)) { + // Ext.Msg.show({ title: '提示', msg: '当前状态无法添加附件!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); + // return; + //} + var BillNo = this.formEdit.getForm().findField('BILLNO').getValue(); + if (BillNo == '' || BillNo == '*') { + Ext.MessageBox.alert('提示', '请先生成申请编号!'); //提示', '请先生成申请编号! + return; + } + var winAccess = new Shipping.FileUpload({}); + winAccess.BillNo = BillNo; + winAccess.show(); + }, onDelFileClick: function () { + //var billstatus = this.formEdit.getForm().findField('BILLSTATUS').getValue(); + //if ((billstatus != 1) && (billstatus != 4)) { + // Ext.Msg.show({ title: '提示', msg: '当前状态无法删除附件!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); + // return; + //} + var selections = this.fileGrid.getSelectionModel().getSelection(); + if (selections.length == 0) {//提示', msg: '请先选择要删除的数据! + Ext.Msg.show({ title: '提示', msg: '请先选择要删除的数据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); + return; + } + var BillNo = this.formEdit.getForm().findField('BILLNO').getValue(); + + var record = new Array(); + for (var i = 0; i < selections.length; i++) { + record.push(selections[i].data); + } //提示', '确定删除该记录吗?' + Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) { + if (btn == 'yes') { + Ext.Msg.wait('正在删除数据...'); //正在删除数据 + Ext.Ajax.request({ + waitMsg: '正在删除数据...', + url: '/Account/Chfee_payapplication/CertDel', + params: { + data: Ext.JSON.encode(record) + }, + callback: function (options, success, response) { + if (success) { + var jsonresult = Ext.JSON.decode(response.responseText); + if (jsonresult.Success) { + panelEdit.LoadData('edit', "BILLNO='" + BillNo + "'"); + Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); + } //提示 + else { + Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); + } + } + }, + failure: function (response, options) {//'警告', msg: '服务器响应出错,请重试' + Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); + }, + success: function (response, options) { + }, + scope: this + }); //end Ext.Ajax.request + } + }, this); + }, + + //#endregion + GetEditStatus: function () { var canedit = false; var op = this.formEdit.getForm().findField('OPERATORNAME').getValue(); @@ -7699,24 +7972,40 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { var SETRED = this.formEdit.getForm().findField('SETRED').getValue();//true false var PTORRED = this.formEdit.getForm().findField('PTORRED').getValue();//true false + var INVOICELINE = this.formEdit.getForm().findField('INVOICELINE').getValue();//true false + + var btn_KP = Ext.getCmp("btn_KP"); var btn_Invinfo = Ext.getCmp("btn_Invinfo"); var btn_Pdf = Ext.getCmp("btn_Pdf"); var btn_Void = Ext.getCmp("btn_Void"); var btn_Setred = Ext.getCmp("btn_Setred"); + var 全电发票 = (INVOICELINE == "bs" || INVOICELINE == "pc" || INVOICELINE == "es" || INVOICELINE == "ec"); + ///1.如果流水号没有 同时未锁定 而且没有作废 才能点开票 if (isNullorEmpty(INVOICESERIALNUM) && billstatus == 0 && ISDELETE != "True") { - btn_KP.enable(); + //全电红票不能开票 + if (全电发票 && PTORRED == "2") { + btn_KP.disable(); + } else + + btn_KP.enable(); } else { btn_KP.disable(); } ///2.如果流水号没有 不能点读取 + ///20230519 但是全电除外 bs:电子发票(增值税专用发票), pc:电子发票(普通发票),es:全电纸质发票(增值税专用发票), ec:全电纸质发票(普通发票 if (isNullorEmpty(INVOICESERIALNUM)) { - btn_Invinfo.disable(); - btn_Pdf.disable(); + if (全电发票) { + btn_Invinfo.enable(); + btn_Pdf.enable(); + } else { + btn_Invinfo.disable(); + btn_Pdf.disable(); + } } else { btn_Invinfo.enable(); @@ -7806,5 +8095,32 @@ Ext.extend(Shipping.MsChInvoiceBLEdit, Ext.Panel, { this.editRecord = this.StoreList.getAt(j); if (this.opStatus == 'edit') condition = " BILLNO='" + this.editRecord.get('BILLNO') + "'"; this.LoadData(this.opStatus, condition); + }, + Print: function () { + var basicForm = this.formEdit.getForm(); + var billNo = basicForm.findField('BILLNO').value; + var Gid = basicForm.findField('GID').value; + if (billNo == '*' || billNo == '') { + Ext.Msg.show({ title: '错误', msg: '单据还没有保存,请保存后再打印', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); + return; + } + + var printType = 'MSCHFEEINVOICE'; + var sql1 = "SELECT *,(select DESCRIPTION from info_client where SHORTNAME=ch_fee_invoice.CUSTOMERNAME) CUSTFULLNAME FROM ch_fee_invoice WHERE GID='" + Gid + "'"; + var sql2 = "SELECT c.GID,c.BSNO,c.FEEID,c.FEENAME,c.CURRENCY,c.AMOUNT,c.DOAMOUNT,c.ORIGCURRENCY,c.ORIGAMOUNT,c.EXCHANGERATE "; + sql2 = sql2 + ",b.CUSTOMERNAME,b.VESSEL,b.VOYNO,b.ETD,b.PORTLOAD"; + sql2 = sql2 + " ,b.PORTDISCHARGE,b.INPUTBY,b.OP,b.CUSTSERVICE,b.DOC,b.SALE,b.mblno,b.CUSTNO "; + sql2 = sql2 + " FROM ch_fee_do c left join v_op_bill b on (b.bsno=c.bsno)"; + sql2 = sql2 + " WHERE C.BILLNO='" + billNo + "' order by c.FEENAME,c.CREATETIME,b.ETD,b.MBLNO "; + + var sql3 = "SELECT * FROM CH_FEE_INVOICEDETAIL WHERE PID='" + Gid + "'"; + var sql4 = ""; + var sql5 = ""; + var sql6 = ""; + + PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6); + + + } }); \ No newline at end of file diff --git a/DSWeb/Areas/Account/Viewsjs/Chfee_invoice_HangXin/ChInvoiceModel.js b/DSWeb/Areas/Account/Viewsjs/Chfee_invoice_HangXin/ChInvoiceModel.js index 54f9de87..25a41254 100644 --- a/DSWeb/Areas/Account/Viewsjs/Chfee_invoice_HangXin/ChInvoiceModel.js +++ b/DSWeb/Areas/Account/Viewsjs/Chfee_invoice_HangXin/ChInvoiceModel.js @@ -2,68 +2,68 @@ extend: 'Ext.data.Model', idProperty: 'GID', fields: [ - { name: 'GID', type: 'string' }, - { name: 'BILLNO', type: 'string' }, - { name: 'CUSTOMERNAME', type: 'string' }, - { name: 'ACTUALCUSTOMERNAME', type: 'string' }, - { name: 'CURRENCY', type: 'string' }, - { name: 'RECVCURR', type: 'string' }, - { name: 'INVOICENO', type: 'string' }, - { name: 'INVOICECUSTNAME', type: 'string' }, - { name: 'INVOICETYPE', type: 'number' }, - { name: 'INVOICETYPEREF', type: 'string' }, - { name: 'BILLSTATUS', type: 'number' }, - { name: 'BILLSTATUSREF', type: 'string' }, - { name: 'INVOICECATEGORY', type: 'string' }, - { name: 'INVOICECATEGORYREF', type: 'string' }, - { name: 'AMOUNT', type: 'number' }, - { name: 'DOAMOUNT', type: 'number' }, - { name: 'STLAMOUNT', type: 'number' }, - { name: 'INVAMOUNT', type: 'number' }, - { name: 'OTCURRAMOUNT', type: 'number' }, - { name: 'EXCHANGERATE', type: 'number' }, - { name: 'AMOUNTCAPITAL', type: 'string' }, - { name: 'APPLICANT', type: 'string' }, - { name: 'APPLICANTNAME', type: 'string' }, - { name: 'APPLYTIME', type: 'string' }, - { name: 'OPERATOR', type: 'string' }, - { name: 'OPERATORNAME', type: 'string' }, + { name: 'GID', type: 'string' }, + { name: 'BILLNO', type: 'string' }, + { name: 'CUSTOMERNAME', type: 'string' }, + { name: 'ACTUALCUSTOMERNAME', type: 'string' }, + { name: 'CURRENCY', type: 'string' }, + { name: 'RECVCURR', type: 'string' }, + { name: 'INVOICENO', type: 'string' }, + { name: 'INVOICECUSTNAME', type: 'string' }, + { name: 'INVOICETYPE', type: 'number' }, + { name: 'INVOICETYPEREF', type: 'string' }, + { name: 'BILLSTATUS', type: 'number' }, + { name: 'BILLSTATUSREF', type: 'string' }, + { name: 'INVOICECATEGORY', type: 'string' }, + { name: 'INVOICECATEGORYREF', type: 'string' }, + { name: 'AMOUNT', type: 'number' }, + { name: 'DOAMOUNT', type: 'number' }, + { name: 'STLAMOUNT', type: 'number' }, + { name: 'INVAMOUNT', type: 'number' }, + { name: 'OTCURRAMOUNT', type: 'number' }, + { name: 'EXCHANGERATE', type: 'number' }, + { name: 'AMOUNTCAPITAL', type: 'string' }, + { name: 'APPLICANT', type: 'string' }, + { name: 'APPLICANTNAME', type: 'string' }, + { name: 'APPLYTIME', type: 'string' }, + { name: 'OPERATOR', type: 'string' }, + { name: 'OPERATORNAME', type: 'string' }, { name: 'OPERATETIME', type: 'string' }, { name: 'CREATEUSER', type: 'string' }, { name: 'CREATEUSERREF', type: 'string' }, { name: 'CREATETIME', type: 'string' }, - { name: 'INVOICEMAKETIME', type: 'string' }, - { name: 'COMPANYID', type: 'string' }, - { name: 'BSNO', type: 'string' }, - { name: 'MBLNO', type: 'string' }, + { name: 'INVOICEMAKETIME', type: 'string' }, + { name: 'COMPANYID', type: 'string' }, + { name: 'BSNO', type: 'string' }, + { name: 'MBLNO', type: 'string' }, { name: 'VESSELVOYAGE', type: 'string' }, - { name: 'ETD', type: 'string' }, - { name: 'POL', type: 'string' }, - { name: 'POD', type: 'string' }, - { name: 'CUSTRATENO', type: 'string' }, - { name: 'CUSTADDRTEL', type: 'string' }, - { name: 'CUSTBANK', type: 'string' }, - { name: 'BANK', type: 'string' }, - { name: 'ACCOUNT', type: 'string' }, - { name: 'LICENSECODE', type: 'string' }, - { name: 'TAXCODE', type: 'string' }, - { name: 'VOUCHERNO', type: 'string' }, - { name: 'ISNEEDPRINT', type: 'string' }, - { name: 'ISNEEDFEE', type: 'string' }, - { name: 'ISDELETE', type: 'string' }, - { name: 'DELETEOPERATOR', type: 'string' }, - { name: 'DELOPERATORNAME', type: 'string' }, - { name: 'DELETETIME', type: 'string' }, - { name: 'NOSTL', type: 'string' }, - { name: 'FEEAMOUNT', type: 'string' }, - { name: 'REMARK', type: 'string' }, - { name: 'SALECORPID', type: 'string' }, - { name: 'SALECORP', type: 'string' }, - { name: 'DZSTATUS', type: 'string' }, + { name: 'ETD', type: 'string' }, + { name: 'POL', type: 'string' }, + { name: 'POD', type: 'string' }, + { name: 'CUSTRATENO', type: 'string' }, + { name: 'CUSTADDRTEL', type: 'string' }, + { name: 'CUSTBANK', type: 'string' }, + { name: 'BANK', type: 'string' }, + { name: 'ACCOUNT', type: 'string' }, + { name: 'LICENSECODE', type: 'string' }, + { name: 'TAXCODE', type: 'string' }, + { name: 'VOUCHERNO', type: 'string' }, + { name: 'ISNEEDPRINT', type: 'string' }, + { name: 'ISNEEDFEE', type: 'string' }, + { name: 'ISDELETE', type: 'string' }, + { name: 'DELETEOPERATOR', type: 'string' }, + { name: 'DELOPERATORNAME', type: 'string' }, + { name: 'DELETETIME', type: 'string' }, + { name: 'NOSTL', type: 'string' }, + { name: 'FEEAMOUNT', type: 'string' }, + { name: 'REMARK', type: 'string' }, + { name: 'SALECORPID', type: 'string' }, + { name: 'SALECORP', type: 'string' }, + { name: 'DZSTATUS', type: 'string' }, { name: 'VOUNO', type: 'string' } //20191023添加 适应航信接口的需要 - ,{ name: 'CUSTTEL', type: 'string' }, + , { name: 'CUSTTEL', type: 'string' }, { name: 'CUSTADDR', type: 'string' }, { name: 'PTORRED', type: 'string' }, { name: 'REDCODE', type: 'string' }, @@ -81,26 +81,28 @@ { name: 'PUSHMODEREF', type: 'string' }, { name: 'INVOICELINEREF', type: 'string' }, { name: 'EINVOICESTATEREF', type: 'string' }, - { name: 'SETRED', type: 'string' } + { name: 'ISFRINV', type: 'bool' }, + { name: 'SETRED', type: 'string' }, + { name: 'redReason', type: 'string' } - ] + ] }); Ext.define('MsChInvoiceNo', { extend: 'Ext.data.Model', idProperty: 'INVNO', fields: [ - { name: 'INVNO', type: 'string' } - ] + { name: 'INVNO', type: 'string' } + ] }); Ext.define('companymb', { extend: 'Ext.data.Model', fields: [ - { name: 'gid', type: 'string' }, - { name: 'name', type: 'string' } - ] + { name: 'gid', type: 'string' }, + { name: 'name', type: 'string' } + ] }); @@ -109,20 +111,20 @@ Ext.define('MsInfoClientBankModel', { extend: 'Ext.data.Model', idProperty: 'GID', fields: [ - { name: 'GID', type: 'string' }, - { name: 'LINKID', type: 'string' }, - { name: 'ACCOUNTNAME', type: 'string' }, - { name: 'CODENAME', type: 'string' }, - { name: 'CURRENCY', type: 'string' }, - { name: 'ACCOUNTNAMEREF', type: 'string' }, - { name: 'BANKNAME', type: 'string' }, - { name: 'ACCOUNT', type: 'string' }, - { name: 'REMARK', type: 'string' }, - { name: 'FINANCESOFTCODE', type: 'string' }, - { name: 'CREATEUSER', type: 'string' }, - { name: 'CREATETIME', type: 'string' }, - { name: 'CWGLACCID', type: 'string' }, - { name: 'BANKNAME_ACCOUNT', type: 'string' } + { name: 'GID', type: 'string' }, + { name: 'LINKID', type: 'string' }, + { name: 'ACCOUNTNAME', type: 'string' }, + { name: 'CODENAME', type: 'string' }, + { name: 'CURRENCY', type: 'string' }, + { name: 'ACCOUNTNAMEREF', type: 'string' }, + { name: 'BANKNAME', type: 'string' }, + { name: 'ACCOUNT', type: 'string' }, + { name: 'REMARK', type: 'string' }, + { name: 'FINANCESOFTCODE', type: 'string' }, + { name: 'CREATEUSER', type: 'string' }, + { name: 'CREATETIME', type: 'string' }, + { name: 'CWGLACCID', type: 'string' }, + { name: 'BANKNAME_ACCOUNT', type: 'string' } ] }); @@ -225,7 +227,7 @@ Ext.define('MsChInvoice_FEE_P2', { { name: 'FEENAME', type: 'string' }, { name: 'AMOUNT', type: 'string' }, { name: 'AMOUNT_EX', type: 'string' }, - + { name: 'RATE', type: 'string' }, { name: 'PRICE', type: 'string' }, { name: 'NUM', type: 'string' } diff --git a/DSWeb/Areas/CommMng/DAL/BasicDataRefDAL.cs b/DSWeb/Areas/CommMng/DAL/BasicDataRefDAL.cs index 918a615f..089bb932 100644 --- a/DSWeb/Areas/CommMng/DAL/BasicDataRefDAL.cs +++ b/DSWeb/Areas/CommMng/DAL/BasicDataRefDAL.cs @@ -31,6 +31,7 @@ using System.Text.RegularExpressions; using System.Web; using System.Web.Mvc; using static DSWeb.Areas.CommMng.DAL.BasicDataRefDAL; +using System.Security.Cryptography; namespace DSWeb.Areas.CommMng.DAL { @@ -6131,6 +6132,87 @@ namespace DSWeb.Areas.CommMng.DAL #endregion + #region MD5值 + + public static string GetMd5Hash(string str) + { + if (string.IsNullOrWhiteSpace(str)) + { + return null; + } + + MD5 md5hash = MD5.Create(); + + byte[] data = md5hash.ComputeHash(Encoding.UTF8.GetBytes(str)); + + StringBuilder sBuilder = new StringBuilder(); + + for (int i = 0; i < data.Length; i++) + { + sBuilder.Append(data[i].ToString("x2")); + } + return sBuilder.ToString(); + } + + #endregion + + public static ContentResult GetContentResult(DBResult dbresult) + { + var jsonRespose = new JsonResponse + { + Success = dbresult.Success, + Message = dbresult.Message, + Data = null + }; + if (dbresult.Data != null) jsonRespose.Data = dbresult.Data; + return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) }; + } + + + + + public static DateTime ConvertLongToDateTime(long? d) + { + DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); + long lTime = long.Parse(d + "0000"); + TimeSpan toNow = new TimeSpan(lTime); + DateTime dtResult = dtStart.Add(toNow); + return dtResult; + } + + + public static string ConvertToChineseMoney(double money) + { + if (money < 0) + { + throw new ArgumentOutOfRangeException($"参数 money 不能为负值!"); + } + string s = money.ToString("#L#E#D#C#K#E#D#C#J#E#D#C#I#E#D#C#H#E#D#C#G#E#D#C#F#E#D#C#.0B0A"); + s = Regex.Replace(s, @"((?<=-|^)[^1-9]*)|((?'z'0)[0A-E]*((?=[1-9]) + |(?'-z'(?=[F-L\.]|$))))|((?'b'[F-L])(?'z'0)[0A-L]*((?=[1-9])|(?'-z'(?=[\.]|$))))", "${b}${z}"); + return Regex.Replace(s, ".", delegate (System.Text.RegularExpressions.Match m) + { + return "负元空零壹贰叁肆伍陆柒捌玖空空空空空空空分角拾佰仟萬億兆京垓秭穰"[m.Value[0] - '-'].ToString(); + }); + } + + public static string ConvertToChineseMoney2(double money) + { + var result = ConvertToChineseMoney(money); + + var lastchar = result.Substring(result.Length - 1, 1); + if (lastchar == "角" || lastchar == "分") + { + + } + else + { + result += "整"; + } + + return result; + } + public static string getDatetimeString(object obj) { if (string.IsNullOrWhiteSpace(obj.ToString())) return ""; else @@ -6146,6 +6228,19 @@ namespace DSWeb.Areas.CommMng.DAL } } + /// + /// 毫秒型时间戳转datetime + /// + /// + /// + public static DateTime Timestamp2Datetime(long timestamp) + { + + System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));//当地时区 + var time = startTime.AddMilliseconds(timestamp); + return time; + } + #region 解析BC的pdf文档 public static DataTable ExcelToDatatable_2(Stream stream, string fileType, out string strMsg, string sheetName = null) diff --git a/DSWeb/Areas/MvcShipping/DAL/MsSysInvInterFaceSet/MsSysInvInterFaceSetDAL.cs b/DSWeb/Areas/MvcShipping/DAL/MsSysInvInterFaceSet/MsSysInvInterFaceSetDAL.cs index 7650efa7..c4523874 100644 --- a/DSWeb/Areas/MvcShipping/DAL/MsSysInvInterFaceSet/MsSysInvInterFaceSetDAL.cs +++ b/DSWeb/Areas/MvcShipping/DAL/MsSysInvInterFaceSet/MsSysInvInterFaceSetDAL.cs @@ -19,7 +19,7 @@ namespace DSWeb.MvcShipping.DAL.MsSysInvInterFaceSet var strSql = new StringBuilder(); strSql.Append("SELECT GID,INVOICELINE,INVITERFACE,[CREATEUSER]"); - strSql.Append(",[CREATETIME],[MODIFIEDUSER],[MODIFIEDTIME],[COMPANYID]"); + strSql.Append(",[CREATETIME],[MODIFIEDUSER],[MODIFIEDTIME],[COMPANYID],NUONUOAPPKEY,NUONUOAPPSECRET"); strSql.Append(",(select ShowName from [user] where GID=sys_inv_interfaceset.CREATEUSER) as CREATEUSERREF"); strSql.Append(" from sys_inv_interfaceset where 1=1 "); @@ -32,9 +32,10 @@ namespace DSWeb.MvcShipping.DAL.MsSysInvInterFaceSet { strSql.Append(" order by " + sortstring); } - else { + else + { strSql.Append(" order by INVOICELINE"); - + } return SetData(strSql); } @@ -42,7 +43,7 @@ namespace DSWeb.MvcShipping.DAL.MsSysInvInterFaceSet static public SysInvInterFaceSet GetData(string condition, string companyid) { SysInvInterFaceSet data = null; - var list = GetDataList(condition,companyid); + var list = GetDataList(condition, companyid); if (list.Count > 0) data = list[0]; @@ -73,6 +74,8 @@ namespace DSWeb.MvcShipping.DAL.MsSysInvInterFaceSet if (reader["CREATETIME"] != DBNull.Value) data.CREATETIME = Convert.ToDateTime(reader["CREATETIME"]).ToString("yyyy-MM-dd HH:mm:ss"); data.COMPANYID = Convert.ToString(reader["COMPANYID"]); + data.NUONUOAPPKEY = Convert.ToString(reader["NUONUOAPPKEY"]); + data.NUONUOAPPSECRET = Convert.ToString(reader["NUONUOAPPSECRET"]); #endregion headList.Add(data); } @@ -82,7 +85,7 @@ namespace DSWeb.MvcShipping.DAL.MsSysInvInterFaceSet } #endregion - public static DBResult SaveDetail(List bodyList, string companyid,string userid,string LOCALCURR) + public static DBResult SaveDetail(List bodyList, string companyid, string userid, string LOCALCURR) { var result = new DBResult(); @@ -99,11 +102,11 @@ namespace DSWeb.MvcShipping.DAL.MsSysInvInterFaceSet var cmdInsert = db.GetSqlStringCommand( @"insert into sys_inv_interfaceset (GID,INVOICELINE,INVITERFACE,COMPANYID,CREATEUSER,CREATETIME) - values (@GID,@INVOICELINE,@INVITERFACE,@COMPANYID,@CREATEUSER,@CREATETIME) "); + values (@GID,@INVOICELINE,@INVITERFACE,@COMPANYID,@CREATEUSER,@CREATETIME,@NUONUOAPPKEY,@NUONUOAPPSECRET) "); var cmdUpdate = db.GetSqlStringCommand( - @"update sys_inv_interfaceset set INVOICELINE=@INVOICELINE,INVITERFACE=@INVITERFACE,MODIFIEDUSER=@MODIFIEDUSER,MODIFIEDTIME=@MODIFIEDTIME where GID=@GID "); + @"update sys_inv_interfaceset set INVOICELINE=@INVOICELINE,INVITERFACE=@INVITERFACE,MODIFIEDUSER=@MODIFIEDUSER,MODIFIEDTIME=@MODIFIEDTIME,NUONUOAPPKEY=@NUONUOAPPKEY,NUONUOAPPSECRET=@NUONUOAPPSECRET where GID=@GID "); if (bodyList != null) { @@ -121,6 +124,8 @@ namespace DSWeb.MvcShipping.DAL.MsSysInvInterFaceSet db.AddInParameter(cmdInsert, "@CREATETIME", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); db.AddInParameter(cmdInsert, "@CREATEUSER", DbType.String, userid); db.AddInParameter(cmdInsert, "@COMPANYID", DbType.String, companyid); + db.AddInParameter(cmdInsert, "@NUONUOAPPKEY", DbType.String, enumValue.NUONUOAPPKEY); + db.AddInParameter(cmdInsert, "@NUONUOAPPSECRET", DbType.String, enumValue.NUONUOAPPSECRET); db.ExecuteNonQuery(cmdInsert, tran); } else @@ -132,6 +137,8 @@ namespace DSWeb.MvcShipping.DAL.MsSysInvInterFaceSet db.AddInParameter(cmdUpdate, "@INVITERFACE", DbType.String, enumValue.INVITERFACE); db.AddInParameter(cmdUpdate, "@MODIFIEDTIME", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); db.AddInParameter(cmdUpdate, "@MODIFIEDUSER", DbType.String, userid); + db.AddInParameter(cmdUpdate, "@NUONUOAPPKEY", DbType.String, enumValue.NUONUOAPPKEY); + db.AddInParameter(cmdUpdate, "@NUONUOAPPSECRET", DbType.String, enumValue.NUONUOAPPSECRET); db.AddInParameter(cmdUpdate, "@GID", DbType.String, enumValue.GID); db.ExecuteNonQuery(cmdUpdate, tran); } @@ -147,7 +154,7 @@ namespace DSWeb.MvcShipping.DAL.MsSysInvInterFaceSet tran.Rollback(); result.Success = false; - result.Message = "保存出现错误<"+e.Message+">,请重试或联系系统管理员"; + result.Message = "保存出现错误<" + e.Message + ">,请重试或联系系统管理员"; return result; } @@ -159,7 +166,7 @@ namespace DSWeb.MvcShipping.DAL.MsSysInvInterFaceSet return result; } - + diff --git a/DSWeb/Areas/MvcShipping/Models/MsSysInvInterFaceSet/SysInvInterFaceSet.cs b/DSWeb/Areas/MvcShipping/Models/MsSysInvInterFaceSet/SysInvInterFaceSet.cs index 8ca82cd1..d8147722 100644 --- a/DSWeb/Areas/MvcShipping/Models/MsSysInvInterFaceSet/SysInvInterFaceSet.cs +++ b/DSWeb/Areas/MvcShipping/Models/MsSysInvInterFaceSet/SysInvInterFaceSet.cs @@ -30,7 +30,7 @@ namespace DSWeb.MvcShipping.Models.SysInvInterFaceSet } #region Public Properties - + //region public [ModelDB(MDBType = ModelDBOprationType.All, IsPrimary = true)] public string GID @@ -52,7 +52,7 @@ namespace DSWeb.MvcShipping.Models.SysInvInterFaceSet set { _INVOICELINE = value; } } - + [ModelDB(MDBType = ModelDBOprationType.Insert)] public string COMPANYID { @@ -77,12 +77,12 @@ namespace DSWeb.MvcShipping.Models.SysInvInterFaceSet set { _CREATETIME = value; } } - //#endregion - + [ModelDB] + public string NUONUOAPPKEY { get; set; } + [ModelDB] + public string NUONUOAPPSECRET { get; set; } #endregion - - } diff --git a/DSWeb/Areas/MvcShipping/Viewsjs/MsSysInvInterFaceSet/MsSysInvInterFaceSetIndex.js b/DSWeb/Areas/MvcShipping/Viewsjs/MsSysInvInterFaceSet/MsSysInvInterFaceSetIndex.js index 3cedd39f..6dc9692c 100644 --- a/DSWeb/Areas/MvcShipping/Viewsjs/MsSysInvInterFaceSet/MsSysInvInterFaceSetIndex.js +++ b/DSWeb/Areas/MvcShipping/Viewsjs/MsSysInvInterFaceSet/MsSysInvInterFaceSetIndex.js @@ -78,18 +78,34 @@ Ext.extend(Shipping.MsSysInvInterFaceSetIndex, Ext.Panel, { hidden: true, width: 120 }, { - sortable: true, - dataIndex: 'INVOICELINE', - header: '发票种类', - width: 160, - editor: this.comboxINVOICELINE - }, { - sortable: true, - dataIndex: 'INVITERFACE', - header: '接口类型', - width: 160, - editor: this.comboxINVITERFACE - }, { + sortable: true, + dataIndex: 'INVOICELINE', + header: '发票种类', + width: 160, + editor: this.comboxINVOICELINE + }, { + sortable: true, + dataIndex: 'INVITERFACE', + header: '接口类型', + width: 160, + editor: this.comboxINVITERFACE + }, { + sortable: true, + dataIndex: 'NUONUOAPPKEY', + header: 'AppKey', + width: 90, + editor: { + xtype: 'textfield' + } + }, { + sortable: true, + dataIndex: 'NUONUOAPPSECRET', + header: 'AppSecret', + width: 160, + editor: { + xtype: 'textfield' + } + }, { sortable: true, dataIndex: 'CREATEUSERREF', header: '录入人', @@ -248,7 +264,8 @@ Ext.extend(Shipping.MsSysInvInterFaceSetIndex, Ext.Panel, { Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } else { - Ext.Msg.show({ title: '请重试', + Ext.Msg.show({ + title: '请重试', msg: '服务器响应出错', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); diff --git a/DSWeb/Areas/MvcShipping/Viewsjs/MsSysInvInterFaceSet/MsSysInvInterFaceSetModel.js b/DSWeb/Areas/MvcShipping/Viewsjs/MsSysInvInterFaceSet/MsSysInvInterFaceSetModel.js index 710f3329..35526499 100644 --- a/DSWeb/Areas/MvcShipping/Viewsjs/MsSysInvInterFaceSet/MsSysInvInterFaceSetModel.js +++ b/DSWeb/Areas/MvcShipping/Viewsjs/MsSysInvInterFaceSet/MsSysInvInterFaceSetModel.js @@ -8,6 +8,8 @@ { name: 'CREATEUSER', type: 'string' }, { name: 'CREATEUSERREF', type: 'string' }, { name: 'CREATETIME', type: 'string' }, - { name: 'COMPANYID', type: 'string' } - ] + { name: 'COMPANYID', type: 'string' }, + { name: 'NUONUOAPPKEY', type: 'string' }, + { name: 'NUONUOAPPSECRET', type: 'string' } + ] }); diff --git a/HcDBUtility/Comm/DBResult.cs b/HcDBUtility/Comm/DBResult.cs index 7247be5f..02dac010 100644 --- a/HcDBUtility/Comm/DBResult.cs +++ b/HcDBUtility/Comm/DBResult.cs @@ -29,7 +29,8 @@ namespace HcUtility.Comm } public object Data { get; set; } - public DBResult() { + public DBResult() + { success = false; message = ""; Data = null; @@ -47,22 +48,36 @@ namespace HcUtility.Comm message = _message; } - public void setMessage(bool _success, string _message) { + public DBResult setMessage(bool _success, string _message, object data = null) + { success = _success; - message += _message+ ";"; + message += _message + ";"; + + if (data != null) this.Data = data; + return this; } - public void OK() + public DBResult OK() { OK(""); + return this; } - public void OK( string _message) + public void OK(string _message) { success = true; - message += _message + ";"; + if (!string.IsNullOrWhiteSpace(message) && !string.IsNullOrWhiteSpace(_message)) + { + message += ";"; + } + message += _message; + } + public void OK(string _message, object data = null) + { + OK(_message); + Data = data; } - public void SetErrorInfo(string message, bool success = false, object data = null) + public DBResult SetErrorInfo(string message, bool success = false, object data = null) { if (Success != success) Message = ""; Success = success; @@ -77,12 +92,13 @@ namespace HcUtility.Comm Message += message; Data = data; } + return this; } } public class DBDataSetResult : DBResult { - public DataSet DataSet {get;set;} + public DataSet DataSet { get; set; } } public class DBModelObjectResult : DBResult