诺诺开票逻辑回滚至原逻辑

DS7_JinGang
ddlucky 2 years ago
parent a9d938f7a7
commit 4feeab87fa

@ -34,8 +34,6 @@ using iTextSharp.text.pdf;
using DSWeb.MvcShipping.DAL.MsSysInvInterFaceSet;
using DSWeb.Common.Helper;
using DSWeb.MvcShipping.DAL.MsBaseInfoDAL;
using NuonuoSDK;
using java.applet;
namespace DSWeb.Areas.Account.Controllers
{
@ -109,7 +107,7 @@ namespace DSWeb.Areas.Account.Controllers
sort = sort.Replace("INVOICETYPEREF", "INVOICETYPE");
sort = sort.Replace("APPLICANT", "(select top 1 (select ShowName from [user] where GID=ap.applicant) APPLICANT from ch_fee_invoiceapplication ap where invbillno=cm.BILLNO)");
}
var dataList = ChinvoiceDAL.GetDataList(start, limit,condition, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]), sort);
var dataList = ChinvoiceDAL.GetDataList(start, limit, condition, Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]), sort);
int count = ChinvoiceDAL.getTotalCount(condition, CookieConfig.GetCookie_UserId(Request), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = count, data = dataList.ToList() });
@ -123,7 +121,7 @@ namespace DSWeb.Areas.Account.Controllers
return new ContentResult() { Content = json };
}
public ContentResult GetData(string handle, string condition,bool isapp)
public ContentResult GetData(string handle, string condition, bool isapp)
{
ChInvoice_HangXin head = null;
@ -163,7 +161,8 @@ namespace DSWeb.Areas.Account.Controllers
head.INVOICETYPE = 2;
head.INVOICETYPEREF = "申请发票";
}
else {
else
{
head.INVOICETYPE = 1;
head.INVOICETYPEREF = "自由发票";
}
@ -189,7 +188,7 @@ namespace DSWeb.Areas.Account.Controllers
public ContentResult GetBillList(string condition, string sort)
{
var dataList = ChinvoiceDAL.GetBodyList(condition,sort);
var dataList = ChinvoiceDAL.GetBodyList(condition, sort);
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
@ -225,7 +224,7 @@ namespace DSWeb.Areas.Account.Controllers
public ContentResult GetBillDataList(int start, int limit, string sort, string condition)
{
var dataList = ChinvoiceDAL.GetAddBillList(start, limit,condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort);
var dataList = ChinvoiceDAL.GetAddBillList(start, limit, condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort);
int count = ChinvoiceDAL.getAddBillTotalCount(condition, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]));
var json = JsonConvert.Serialize(
new { Success = true, Message = "查询成功", totalCount = count, data = dataList.ToList() });
@ -308,7 +307,8 @@ namespace DSWeb.Areas.Account.Controllers
headData.CUSTADDRTEL = dsHSCODE.Tables[0].Rows[0]["INVADDRTEL"].ToString();
else headData.CUSTADDRTEL = dsHSCODE.Tables[0].Rows[0]["Addr"].ToString() + " " + dsHSCODE.Tables[0].Rows[0]["Tel"].ToString();
}
if (string.IsNullOrEmpty(headData.CUSTTEL)) {
if (string.IsNullOrEmpty(headData.CUSTTEL))
{
if (dsHSCODE.Tables[0].Rows[0]["Tel"].ToString() != "")
headData.CUSTTEL = dsHSCODE.Tables[0].Rows[0]["Tel"].ToString();
}
@ -348,7 +348,8 @@ namespace DSWeb.Areas.Account.Controllers
else headData.INVITERFACE = "诺诺发票接口";
}
if (!string.IsNullOrEmpty(headData.CUSTTEL)&&(headData.CUSTTEL.Trim().Length>20)) {
if (!string.IsNullOrEmpty(headData.CUSTTEL) && (headData.CUSTTEL.Trim().Length > 20))
{
isPost = false;
errorstr = "客户电话长度不允许超过20";
@ -359,10 +360,12 @@ namespace DSWeb.Areas.Account.Controllers
isPost = false;
errorstr = "客户电话长度不允许超过80";
}
if (!string.IsNullOrEmpty(headData.SALECORPID)&& !string.IsNullOrEmpty(headData.ACCOUNT)) {
if (!string.IsNullOrEmpty(headData.SALECORPID) && !string.IsNullOrEmpty(headData.ACCOUNT))
{
var banklist = MsBaseInfoDAL.GetAllBANKList("LINKID='"+ headData.SALECORPID + "'");
if (banklist.Find(x => (x.CURRENCY == headData.RECVCURR || x.CURRENCY=="")&& x.BANKACCOUNT == headData.ACCOUNT) == null) {
var banklist = MsBaseInfoDAL.GetAllBANKList("LINKID='" + headData.SALECORPID + "'");
if (banklist.Find(x => (x.CURRENCY == headData.RECVCURR || x.CURRENCY == "") && x.BANKACCOUNT == headData.ACCOUNT) == null)
{
isPost = false;
errorstr = "银行及账号于收款单位和币别不一致,请检查";
@ -405,7 +408,8 @@ 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) };
@ -413,7 +417,7 @@ namespace DSWeb.Areas.Account.Controllers
}
public ContentResult AddDetail(string bill, string data, string curr,bool islist,string GID,string invoiceno)
public ContentResult AddDetail(string bill, string data, string curr, bool islist, string GID, string invoiceno)
{
//首先判断是否有 modInvoiceImport发票引入费用 权限
@ -424,7 +428,7 @@ namespace DSWeb.Areas.Account.Controllers
var bodyList = JsonConvert.Deserialize<List<BillChfeeDetail>>(data);
var headdata = ChinvoiceDAL.GetData(" BILLNO='" + bill + "'", Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]));
var modb = new ModelObjectDB();
DBResult result = ChinvoiceDAL.AddDetail(bill, bodyList, curr, Convert.ToString(Session["COMPANYID"]), islist, GID,headdata);
DBResult result = ChinvoiceDAL.AddDetail(bill, bodyList, curr, Convert.ToString(Session["COMPANYID"]), islist, GID, headdata);
if (result.Success) { ChinvoiceDAL.p_update_Amount(bill, GID); }
@ -477,13 +481,13 @@ namespace DSWeb.Areas.Account.Controllers
}
public ContentResult DelBill(string data, string billno,string GID)
public ContentResult DelBill(string data, string billno, string GID)
{
//首先判断是否有 modInvoiceImport发票引入费用 权限
var bodyList = JsonConvert.Deserialize<List<Chfee_do_detail>>(data);
DBResult result = ChinvoiceDAL.DelFeeDo(bodyList,GID);
DBResult result = ChinvoiceDAL.DelFeeDo(bodyList, GID);
if (result.Success) { ChinvoiceDAL.p_update_Amount(billno, GID); }
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
@ -496,13 +500,14 @@ namespace DSWeb.Areas.Account.Controllers
public ContentResult Delete(string data)
{
var headData = JsonConvert.Deserialize<ChInvoice_HangXin>(data);
headData = ChinvoiceDAL.GetData(" cm.BILLNO='"+ headData.BILLNO+ "'");
headData = ChinvoiceDAL.GetData(" cm.BILLNO='" + headData.BILLNO + "'");
DBResult result;
//首先判断是否有 modInvLock 发票开出锁定
//20191205 防止已经获得【流水号】的发票业务被删除
if (!string.IsNullOrWhiteSpace(headData.INVOICESERIALNUM) && headData.INVAMOUNT>0) {
if (!string.IsNullOrWhiteSpace(headData.INVOICESERIALNUM) && headData.INVAMOUNT > 0)
{
var jsonRespose1 = new JsonResponse { Success = false, Message = "已经获得流水号且仍包含费用的发票业务不能删除" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose1) };
}
@ -512,7 +517,8 @@ namespace DSWeb.Areas.Account.Controllers
var jsonRespose1 = new JsonResponse { Success = false, Message = "已经实际开出的发票业务不能删除" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose1) };
}
if (headData.EINVOICESTATEREF == "开票中") {
if (headData.EINVOICESTATEREF == "开票中")
{
var jsonRespose1 = new JsonResponse { Success = false, Message = "当前发票状态不允许删除" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose1) };
@ -548,7 +554,7 @@ namespace DSWeb.Areas.Account.Controllers
var rangestr = BasicDataRefDAL.CanOperateStr_INVOICE(ModName, Session["USERID"].ToString());
var _L = ChinvoiceDAL.GetData("GID='"+head.GID+"' and "+ rangestr);
var _L = ChinvoiceDAL.GetData("GID='" + head.GID + "' and " + rangestr);
if (_L.GID == head.GID)
{
@ -613,10 +619,10 @@ namespace DSWeb.Areas.Account.Controllers
// return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose1) };
//}
DBResult result;
result = ChinvoiceDAL.UpdateDelete(headData.BILLNO, Convert.ToString(Session["USERID"]),false);
result = ChinvoiceDAL.UpdateDelete(headData.BILLNO, Convert.ToString(Session["USERID"]), false);
if (result.Success == true)
{
ChinvoiceDAL.UpdateInvNoDelete(headData.INVOICENO, Convert.ToString(Session["USERID"]),false);
ChinvoiceDAL.UpdateInvNoDelete(headData.INVOICENO, Convert.ToString(Session["USERID"]), false);
}
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
@ -638,15 +644,15 @@ namespace DSWeb.Areas.Account.Controllers
public ContentResult AddAppDetail(string bill, string data, string invoiceno, string GID)
{
var bodyList = JsonConvert.Deserialize<List<ChInvoiceapplication>>(data);
var StrGid="";
var StrGid = "";
if (bodyList != null)
{
foreach (var enumValue in bodyList)
{
if (StrGid=="")
StrGid="'"+enumValue.GID+"'";
if (StrGid == "")
StrGid = "'" + enumValue.GID + "'";
else
StrGid=StrGid+",'"+enumValue.GID+"'";
StrGid = StrGid + ",'" + enumValue.GID + "'";
}
}
@ -662,13 +668,15 @@ namespace DSWeb.Areas.Account.Controllers
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
else {
else
{
var jsonRespose = new JsonResponse { Success = false, Message = "发票申请已生成发票,请刷新!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
}
else {
var jsonRespose = new JsonResponse { Success =false, Message ="无需要添加的发票申请!" };
else
{
var jsonRespose = new JsonResponse { Success = false, Message = "无需要添加的发票申请!" };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
@ -680,13 +688,13 @@ namespace DSWeb.Areas.Account.Controllers
var bodyList = JsonConvert.Deserialize<List<ChInvoiceapplication>>(data);
DBResult result = ChinvoiceDAL.DelAppList(bodyList,billno);
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)
public ContentResult DelInvDetail(string billno, string body, string GID)
{
var bodyList = JsonConvert.Deserialize<List<ChInvoiceDetail>>(body);
@ -745,7 +753,8 @@ namespace DSWeb.Areas.Account.Controllers
#region 保存指定发票业务list的PDF文件 将其拼合成一个dpf后返回url
public ContentResult GetONEPDF(string BILLNOS) {
public ContentResult GetONEPDF(string BILLNOS)
{
JsonResponse result = new JsonResponse();
try
@ -777,7 +786,8 @@ namespace DSWeb.Areas.Account.Controllers
result.Message = "没有可以打印的发票文件";
return result.getContentReult();
}
else {
else
{
//pdflist.OrderBy(o => o);
pdflist.Sort(delegate (string p1, string p2)
@ -796,7 +806,8 @@ namespace DSWeb.Areas.Account.Controllers
result.Data = "../../INVOICEPDF/" + Session["USERID"].ToString() + ".pdf";
}
catch (Exception e) {
catch (Exception e)
{
result.Success = false;
result.Message = e.Message;
}
@ -806,7 +817,8 @@ namespace DSWeb.Areas.Account.Controllers
}
private void SavePDF(string[] pdfarray) {
private void SavePDF(string[] pdfarray)
{
string outputFileName = BasicDataRefDAL.getPath("INVOICEPDF") + Session["USERID"].ToString() + ".pdf";
//PdfDocumentBase doc = PdfDocument.MergeFiles(pdfarray);
@ -865,7 +877,7 @@ namespace DSWeb.Areas.Account.Controllers
if (filename != "")
{
//result.Data = "../../EDIFiles/ExportInv/" + filename;
result.Data =filename;
result.Data = filename;
filename = Path.GetFileName(filename);
result.Success = true;
result.Message = filename;
@ -918,7 +930,8 @@ namespace DSWeb.Areas.Account.Controllers
#region 航信接口调用
public ContentResult test(string str) {
public ContentResult test(string str)
{
var result = new KPResponse();
@ -964,14 +977,15 @@ namespace DSWeb.Areas.Account.Controllers
// return View();
//}
private JsonResponse checkinfo(string BILLNO,string redirecturl) {
private JsonResponse checkinfo(string BILLNO, string redirecturl)
{
var result = new DBResult();
var head = new ChInvoice_HangXin();
//var detail = new List<chinvoice_de>
var jsonRespose = new JsonResponse { Success = true, Message = result.Message, Data = result.Data };
//首先判断数据完整性与合法性
head = ChinvoiceDAL.GetData( "cm.BILLNO='" + BILLNO + "'");
head = ChinvoiceDAL.GetData("cm.BILLNO='" + BILLNO + "'");
if (string.IsNullOrEmpty(head.INVOICELINE))
@ -981,7 +995,7 @@ namespace DSWeb.Areas.Account.Controllers
}
if (head.BILLNO!="")
if (head.BILLNO != "")
{
if (string.IsNullOrEmpty(head.INVITERFACE))
{
@ -1014,7 +1028,7 @@ namespace DSWeb.Areas.Account.Controllers
else
{
if (head.INVITERFACE == "诺诺发票接口"|| head.INVITERFACE =="")
if (head.INVITERFACE == "诺诺发票接口" || head.INVITERFACE == "")
{
//如果该税号的token需要 返回认证窗口
var hx = HangXinRequestHelper.getHelper(head.TAXCODE);
@ -1025,21 +1039,17 @@ namespace DSWeb.Areas.Account.Controllers
jsonRespose.Message = hx.ERRORMSG;
return jsonRespose;
}
//20230109如无token则采用新的token获取方式
//HangXinRequestHelper.redirectUri = getRedirecturl(redirecturl);
//if (hx.needStart)
//{
// //BasicDataRefDAL.SaveLog("checkinfoBILLNO=" + BILLNO, "", "诺诺平台", "返回认证窗口");
// jsonRespose = TokenPage();
//
// var token= NNOpenSDK.getMerchantToken(HangXinRequestHelper.appKey, HangXinRequestHelper.appSecret);
// //public static string getMerchantToken(string appKey, string appSecret)
//}
HangXinRequestHelper.redirectUri = getRedirecturl(redirecturl);
if (hx.needStart)
{
BasicDataRefDAL.SaveLog("checkinfoBILLNO=" + BILLNO, "", "诺诺平台", "返回认证窗口");
jsonRespose = TokenPage();
}
else {
jsonRespose.Success =true;
jsonRespose.Message ="";
}
else
{
jsonRespose.Success = true;
jsonRespose.Message = "";
return jsonRespose;
}
}
@ -1047,7 +1057,8 @@ namespace DSWeb.Areas.Account.Controllers
}
private JsonResponse TokenPage() {
private JsonResponse TokenPage()
{
var jsonRespose = new JsonResponse { Success = true, Message = "", Data = "" };
@ -1063,7 +1074,7 @@ namespace DSWeb.Areas.Account.Controllers
/// </summary>
/// <param name="bill"></param>
/// <returns></returns>
public ContentResult NNMakeInv(string bill,string redirecturl)
public ContentResult NNMakeInv(string bill, string redirecturl)
{
//首先判断是否有 modInvLock 发票开出锁定
var result = new DBResult();
@ -1075,13 +1086,15 @@ namespace DSWeb.Areas.Account.Controllers
//首先判断数据完整性与合法性
var checkresult = checkinfo(bill,redirecturl);
var checkresult = checkinfo(bill, redirecturl);
if (!checkresult.Success) {
if (!checkresult.Success)
{
return new ContentResult() { Content = JsonConvert.Serialize(checkresult) };
}
else {
var head = (ChInvoice_HangXin) checkresult.Data;
else
{
var head = (ChInvoice_HangXin)checkresult.Data;
decimal invamount = 0;
var invitems = ChinvoiceapplicationDAL.GetDetailList("PID='" + head.GID + "'", "");
foreach (var invitem in invitems)
@ -1096,7 +1109,7 @@ namespace DSWeb.Areas.Account.Controllers
ChInvoice_HangXin returndate = null;
if (head.INVITERFACE == "诺诺发票接口"|| head.INVITERFACE =="")
if (head.INVITERFACE == "诺诺发票接口" || head.INVITERFACE == "")
{
var hx = HangXinRequestHelper.getHelper(head.TAXCODE);
if (!hx.CanUse)
@ -1119,19 +1132,19 @@ namespace DSWeb.Areas.Account.Controllers
else
{
//HangXinRequestHelper.redirectUri = getRedirecturl(redirecturl);
HangXinRequestHelper.redirectUri = getRedirecturl(redirecturl);
var detailList = ChinvoiceDAL.GetDetailList("PID='" + head.GID + "'");
//var CodeGoodInvList = MsCodeGoodInvDAL.GetDataList(" gid in (SELECT GOODSNAME FROM ch_fee_invoicedetail where PID = '"+ head.GID + "')");
if (!string.IsNullOrWhiteSpace(hx.accessToken))
{
result = hx.PostInvoice(head, detailList);
}
//if (result.Message == "需要重新认证" || string.IsNullOrWhiteSpace(hx.accessToken))
//{
// BasicDataRefDAL.SaveLog("PostInvoice 反回‘需要重新认证’", "", "诺诺平台", "返回认证窗口");
// var _r = TokenPage();
// return new ContentResult() { Content = JsonConvert.Serialize(_r) };
//}
if (result.Message == "需要重新认证" || string.IsNullOrWhiteSpace(hx.accessToken))
{
BasicDataRefDAL.SaveLog("PostInvoice 反回‘需要重新认证’", "", "诺诺平台", "返回认证窗口");
var _r = TokenPage();
return new ContentResult() { Content = JsonConvert.Serialize(_r) };
}
//returndate = ChinvoiceDAL.GetData(" BILLNO='" + head.BILLNO + "'");
}
@ -1142,7 +1155,7 @@ namespace DSWeb.Areas.Account.Controllers
string msg = null;
if (!string.IsNullOrEmpty(head.INVOICESERIALNUM))
{//如果该发票流水号不为空
result.Success = ruihongHelper.QueryInvoiceRecord(head.GID,head.INVOICESERIALNUM, out msg);
result.Success = ruihongHelper.QueryInvoiceRecord(head.GID, head.INVOICESERIALNUM, out msg);
result.Message = msg;
}
@ -1194,7 +1207,7 @@ namespace DSWeb.Areas.Account.Controllers
{
//如果已有pdf地址 则直接返回
var headdata = ChinvoiceDAL.GetData(" cm.BILLNO='"+BILLNO+"'");
var headdata = ChinvoiceDAL.GetData(" cm.BILLNO='" + BILLNO + "'");
@ -1207,7 +1220,7 @@ namespace DSWeb.Areas.Account.Controllers
}
else
{
if (headdata.INVITERFACE == "诺诺发票接口"|| headdata.INVITERFACE =="")
if (headdata.INVITERFACE == "诺诺发票接口" || headdata.INVITERFACE == "")
{
result = Do_NNReadInv(BILLNO, redirecturl);
}
@ -1216,10 +1229,10 @@ namespace DSWeb.Areas.Account.Controllers
RuihongHelper ruihongHelper = new RuihongHelper();
string msg = null;
var succ = ruihongHelper.QueryInvoiceRecord(headdata.GID,headdata.INVOICESERIALNUM, out msg);
var succ = ruihongHelper.QueryInvoiceRecord(headdata.GID, headdata.INVOICESERIALNUM, out msg);
result.Success = succ;
result.Message = msg;
result.Data= ChinvoiceDAL.GetData(" BILLNO='" + headdata.BILLNO + "'");
result.Data = ChinvoiceDAL.GetData(" BILLNO='" + headdata.BILLNO + "'");
}
}
@ -1259,7 +1272,7 @@ namespace DSWeb.Areas.Account.Controllers
string msg = null;
var succ = ruihongHelper.QueryInvoiceRecord(headdata.GID, headdata.INVOICESERIALNUM, out msg);
var invoice= ChinvoiceDAL.GetData(" BILLNO='" + headdata.BILLNO + "'");
var invoice = ChinvoiceDAL.GetData(" BILLNO='" + headdata.BILLNO + "'");
result.Success = succ;
result.Message = msg;
result.Data = invoice;
@ -1276,7 +1289,8 @@ namespace DSWeb.Areas.Account.Controllers
return result.getContentReult();
}
private JsonResponse Do_NNReadInv(string BILLNO, string redirecturl) {
private JsonResponse Do_NNReadInv(string BILLNO, string redirecturl)
{
//var hx = HangXinRequestHelper.getHelper(taxnum);
//var result = new DBResult();
@ -1348,7 +1362,8 @@ namespace DSWeb.Areas.Account.Controllers
return jsonRespose;
}
public static string getRedirecturl(string redirecturl) {
public static string getRedirecturl(string redirecturl)
{
return redirecturl;
}
@ -1407,7 +1422,8 @@ namespace DSWeb.Areas.Account.Controllers
return result.getContentReult();
}
public JsonResponse Do_NNVoidInv(string BILLNO, string redirecturl) {
public JsonResponse Do_NNVoidInv(string BILLNO, string redirecturl)
{
var jsonRespose = new JsonResponse { Success = false, Message = "", Data = "" };
@ -1501,7 +1517,8 @@ namespace DSWeb.Areas.Account.Controllers
var head = (ChInvoice_HangXin)checkresult.Data;
if (string.IsNullOrEmpty(head.INVOICENO) || string.IsNullOrEmpty(head.INVOICECODE)) {
if (string.IsNullOrEmpty(head.INVOICENO) || string.IsNullOrEmpty(head.INVOICECODE))
{
jsonRespose.Success = false;
jsonRespose.Message = "该发票没有发票号和发票代码,无法进行冲红。";
@ -1518,7 +1535,7 @@ namespace DSWeb.Areas.Account.Controllers
var detailList = ChinvoiceDAL.GetDetailList("PID='" + head.GID + "'");
//如果已经存在一张相应的红票则将现在这个head变成那个红票
var _existRed = ChinvoiceDAL.GetData(" REDNUM='"+head.INVOICENO+"' and REDCODE='"+head.INVOICECODE+"' ");
var _existRed = ChinvoiceDAL.GetData(" REDNUM='" + head.INVOICENO + "' and REDCODE='" + head.INVOICECODE + "' ");
if (_existRed.BILLNO != "*")
{
head = _existRed;
@ -1584,7 +1601,7 @@ namespace DSWeb.Areas.Account.Controllers
var returndate = ChinvoiceDAL.GetData(" BILLNO='" + head.BILLNO + "'");
if (head.INVITERFACE == "诺诺发票接口"|| head.INVITERFACE =="")
if (head.INVITERFACE == "诺诺发票接口" || head.INVITERFACE == "")
{
var hx = HangXinRequestHelper.getHelper(head.TAXCODE);
if (!hx.CanUse)
@ -1627,7 +1644,8 @@ namespace DSWeb.Areas.Account.Controllers
string msg = null;
result.Success = ruihongHelper.RedInvoiceRecord(returndate.GID, out msg);
result.Message = msg;
if (result.Success) {
if (result.Success)
{
var needautolock = MsSysParamSetDAL.GetSysParam("INVOICEAUTOLOCK").isnullortrue();
if (needautolock)
@ -1661,18 +1679,21 @@ namespace DSWeb.Areas.Account.Controllers
/// </summary>
/// <param name="REMARK"></param>
/// <returns></returns>
private string REDREMARK(string REMARK) {
private string REDREMARK(string REMARK)
{
if (REMARK.Length <= 88) return REMARK;
else {
else
{
while((REMARK.Length > 88)&&(REMARK.IndexOf(" ")>=0))
while ((REMARK.Length > 88) && (REMARK.IndexOf(" ") >= 0))
{
REMARK=REMARK.Replace(" ", " ");
REMARK = REMARK.Replace(" ", " ");
}
if (REMARK.Length > 88) {
REMARK=REMARK.Replace("\n", "");
if (REMARK.Length > 88)
{
REMARK = REMARK.Replace("\n", "");
}
if (REMARK.Length > 88)
{
@ -1689,13 +1710,14 @@ namespace DSWeb.Areas.Account.Controllers
/// </summary>
/// <param name="head"></param>
/// <returns></returns>
private DBResult checkCanPost(ChInvoice_HangXin head) {
var result = new DBResult(true,"","");
private DBResult checkCanPost(ChInvoice_HangXin head)
{
var result = new DBResult(true, "", "");
if (string.IsNullOrEmpty(head.INVOICECUSTNAME)) setErrorMessage(ref result, "购方名称 不能为空");
if (string.IsNullOrEmpty(head.PUSHMOBILE)) setErrorMessage(ref result, "推送的手机号码 不能为空");
var ErrorInfo= "销售方公司(我方公司)没有维护:";
var ErrorInfo = "销售方公司(我方公司)没有维护:";
var LocalErrorInfo = "销售方公司(我方公司)没有维护:";
if (string.IsNullOrWhiteSpace(head.TAXCODE))
{
@ -1787,7 +1809,8 @@ namespace DSWeb.Areas.Account.Controllers
private void setErrorMessage(ref DBResult r,string message) {
private void setErrorMessage(ref DBResult r, string message)
{
r.setMessage(false, message);
}
@ -1807,11 +1830,11 @@ namespace DSWeb.Areas.Account.Controllers
{
DBResult result = ChinvoiceDAL.GetRemarksTemplate(Convert.ToString(Session["COMPANYID"]), TemplateName);
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message,Data=result.Data };
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message, Data = result.Data };
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
}
public ContentResult SaveRemarksTemplate(string Template,string TemplateName)
public ContentResult SaveRemarksTemplate(string Template, string TemplateName)
{
DBResult result = ChinvoiceDAL.SaveRemarksTemplate(Template, Convert.ToString(Session["COMPANYID"]), TemplateName);
@ -1896,7 +1919,7 @@ namespace DSWeb.Areas.Account.Controllers
{
headData.DbOperationType = DbOperationType.DbotDel;
}
if (headData.TYPE == "") headData.TYPE ="0";
if (headData.TYPE == "") headData.TYPE = "0";
var BILLNO = headData.GID;
var modb = new ModelObjectDB();
@ -2010,7 +2033,7 @@ namespace DSWeb.Areas.Account.Controllers
var _count = 0;
//(string TABLENAME,string _PKEY,string _sql,string DBNAME)
BaseTableMC fromdbbase = new BaseTableMC("M_INVOICE","INVOICE_ID","","P2DB");
BaseTableMC fromdbbase = new BaseTableMC("M_INVOICE", "INVOICE_ID", "", "P2DB");
var dataList = DBTableConnDAL.getToList(fromdbbase, "联力P2发票", condition);
@ -2048,8 +2071,10 @@ namespace DSWeb.Areas.Account.Controllers
var splitword = "\r\n";
if (dataList.Count > 0) {
foreach (var data in dataList) {
if (dataList.Count > 0)
{
foreach (var data in dataList)
{
var feenamearray = data.GetSplitField("FEENAME", splitword);
var amoutarray = data.GetSplitField("AMOUNT", splitword);
var PRICEarray = data.GetSplitField("PRICE", splitword);
@ -2058,7 +2083,8 @@ namespace DSWeb.Areas.Account.Controllers
if (feenamearray.Length > 1)
{
for (var _i = 0; _i < feenamearray.Length; _i++) {
for (var _i = 0; _i < feenamearray.Length; _i++)
{
var resultdata = new BaseTableMC();
resultdata.SetValue("CURRENCY", data.GetValue("CURRENCY"));
@ -2071,7 +2097,8 @@ namespace DSWeb.Areas.Account.Controllers
resultlist.Add(resultdata);
}
}
else {
else
{
resultlist.Add(data);
}
}
@ -2090,7 +2117,7 @@ namespace DSWeb.Areas.Account.Controllers
return new ContentResult() { Content = json };
}
public ContentResult GetP2_CUST(string condition= " isnull(invoice_no,'')='' ")
public ContentResult GetP2_CUST(string condition = " isnull(invoice_no,'')='' ")
{
var canlogin = BasicDataRefDAL.CheckLogin(Session);
@ -2178,7 +2205,7 @@ namespace DSWeb.Areas.Account.Controllers
}
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<ChInvoice_HangXin>(data);
@ -2186,7 +2213,7 @@ namespace DSWeb.Areas.Account.Controllers
BaseTableMC fromdbbase = new BaseTableMC("M_INVOICE", "INVOICE_ID", "", "P2DB");
var P2DataList = DBTableConnDAL.getToList(fromdbbase, "联力P2发票", " INVOICE_ID='"+headData.BSNO+"'");
var P2DataList = DBTableConnDAL.getToList(fromdbbase, "联力P2发票", " INVOICE_ID='" + headData.BSNO + "'");
var bodyList = new List<ChInvoiceDetail>();
@ -2194,7 +2221,8 @@ namespace DSWeb.Areas.Account.Controllers
var P2Data = new BaseTableMC();
if (P2DataList.Count() > 0) {
if (P2DataList.Count() > 0)
{
P2Data = P2DataList[0];
}
@ -2202,7 +2230,8 @@ namespace DSWeb.Areas.Account.Controllers
{
//查看是否已被使用 如是则返回错误并结束
var isexists = CheckExists(" BSNO='" + headData.BSNO + "' ");
if (!isexists.Success) {
if (!isexists.Success)
{
return isexists.getContentReult();
}
@ -2226,7 +2255,7 @@ namespace DSWeb.Areas.Account.Controllers
localData.DbOperationType = DbOperationType.DbotUpd;
bodyList = ChinvoiceDAL.GetDetailList(" PID='"+localData.GID+"' ");
bodyList = ChinvoiceDAL.GetDetailList(" PID='" + localData.GID + "' ");
}
localData.SetP2Value(P2Data);
@ -2237,7 +2266,7 @@ namespace DSWeb.Areas.Account.Controllers
ChinvoiceDAL.DelInvDetail(bodyList);
}
SaveBodyList = ChInvoiceDetail.GetP2DetailList(P2Data, (localData.PTORRED=="2"));
SaveBodyList = ChInvoiceDetail.GetP2DetailList(P2Data, (localData.PTORRED == "2"));
var BILLNO = localData.BILLNO;
var modb = new ModelObjectDB();
@ -2262,10 +2291,11 @@ namespace DSWeb.Areas.Account.Controllers
Data = ChinvoiceDAL.GetData(" BILLNO='" + BILLNO + "'", Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_UserCode(Request), Convert.ToString(Session["COMPANYID"]))
};
return jsonRespose.getContentReult() ;
return jsonRespose.getContentReult();
}
private JsonResponse CheckExists(string condition) {
private JsonResponse CheckExists(string condition)
{
var existsdata = ChinvoiceDAL.GetData(condition);
JsonResponse result = new JsonResponse();
if (!string.IsNullOrWhiteSpace(existsdata.GID))
@ -2273,7 +2303,8 @@ namespace DSWeb.Areas.Account.Controllers
result.Success = false;
result.Message = "该发票已经被使用!";
}
else {
else
{
result.Success = true;
}
return result;

@ -20,10 +20,6 @@ using DSWeb.Areas.MvcShipping.Comm;
using Newtonsoft.Json.Linq;
using DSWeb.Areas.SysMng.Models.DBTableConn;
using DSWeb.Areas.SysMng.DAL.DBTableConn;
using System.Configuration;
using DSWeb.MvcShipping.DAL.MsSysParamSet;
using com.sun.xml.@internal.ws.developer;
using System.Linq;
namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin
{
@ -131,8 +127,10 @@ 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;
else return false;
@ -240,10 +238,12 @@ 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]);
@ -254,28 +254,31 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin
return result;
}
public void SetP2Value(BaseTableMC P2data) {
public void SetP2Value(BaseTableMC P2data)
{
var connList = DBTableConnDAL.getConn("联力P2发票");
BSNO = P2data.GetValue("BSNO");
CUSTOMERNAME = P2data.GetValue("CUSTOMERNAME");
INVOICECUSTNAME = P2data.GetValue("INVOICECUSTNAME");
VESSELVOYAGE = P2data.GetValue("VESSEL")+";"+ P2data.GetValue("VOYAGE");
VESSELVOYAGE = P2data.GetValue("VESSEL") + ";" + P2data.GetValue("VOYAGE");
ETD = P2data.GetValue("ETD");
POL = P2data.GetValue("POL");
POD = P2data.GetValue("POD");
RECVCURR = P2data.GetValue("CURRENCY");
CURRENCY = "RMB";
CUSTRATENO = P2data.GetValue("CUSTRATENO");
if (RECVCURR == "RMB") {
AMOUNT = getarraysum( P2data.GetSplitField("AMOUNT", "\r\n"));
if (RECVCURR == "RMB")
{
AMOUNT = getarraysum(P2data.GetSplitField("AMOUNT", "\r\n"));
};
if (RECVCURR != "RMB")
{
AMOUNT = 0M;
var pricearray= P2data.GetSplitField("INVAMOUNT", "\r\n");
var pricearray = P2data.GetSplitField("INVAMOUNT", "\r\n");
var numarray = P2data.GetSplitField("NUM", "\r\n");
for (var _i = 0; _i < pricearray.Length; _i++) {
for (var _i = 0; _i < pricearray.Length; _i++)
{
try
{
AMOUNT += Convert.ToDecimal(pricearray[_i]) * Convert.ToDecimal(numarray[_i]);
@ -288,7 +291,8 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin
{
OTCURRAMOUNT = getarraysum(P2data.GetSplitField("AMOUNT", "\r\n"));
}
else {
else
{
OTCURRAMOUNT = 0M;
}
AMOUNTCAPITAL = P2data.GetValue("AMOUNTCAPITAL");
@ -307,11 +311,13 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin
PTORRED = "1";//默认正票
INVOICELINE = "p";//默认普通电票
if (P2data.GetValue("REDINVOICE") == "1") {
if (P2data.GetValue("REDINVOICE") == "1")
{
PTORRED = "2";
BaseTableMC fromdbbase = new BaseTableMC("M_INVOICE", "INVOICE_ID", "", "P2DB");
var BeREDDataList = DBTableConnDAL.getToList(fromdbbase, "联力P2发票", " INVOICE_ID='" + P2data.GetValue("REDBSNO") + "'");
if (BeREDDataList.Count > 0) {
if (BeREDDataList.Count > 0)
{
var BeRedinvoice = BeREDDataList[0];
REDNUM = BeRedinvoice.GetValue("INVOICENO");
REDCODE = BeRedinvoice.GetValue("INVOICECODE");
@ -324,14 +330,17 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin
}
[JsonObject]
public class HXInvoice {
public class HXInvoice
{
public HXInvoice_Head order;
public HXInvoice(ChInvoice_HangXin head, List<ChInvoiceDetail> body) {
public HXInvoice(ChInvoice_HangXin head, List<ChInvoiceDetail> body)
{
this.order = new HXInvoice_Head(head);
List<HXInvoice_Detail> invoiceDetail = new List<HXInvoice_Detail>();
foreach (var detail in body) {
foreach (var detail in body)
{
var item = new HXInvoice_Detail(detail);
@ -345,10 +354,12 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin
public class HXInvoice_Head
{
private ChInvoice_HangXin ChInvoice_HangXin;
public HXInvoice_Head() {
public HXInvoice_Head()
{
}
public HXInvoice_Head(ChInvoice_HangXin ChInvoice_HangXin) {
public HXInvoice_Head(ChInvoice_HangXin ChInvoice_HangXin)
{
this.ChInvoice_HangXin = ChInvoice_HangXin;
}
@ -388,7 +399,7 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin
public string invoiceDate
{
get { return ChInvoice_HangXin.INVOICEMAKETIME+" 12:00:00"; }
get { return ChInvoice_HangXin.INVOICEMAKETIME + " 12:00:00"; }
}
public string clerk
@ -438,12 +449,12 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin
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
@ -453,7 +464,9 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin
public string invoiceLine
{
get { return ChInvoice_HangXin.INVOICELINE;
get
{
return ChInvoice_HangXin.INVOICELINE;
}
}
@ -537,7 +550,9 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin
public string taxRate
{
get { return Math.Round((ChInvoiceDetail.TAXRATE / 100), 2, MidpointRounding.AwayFromZero).ToString();
get
{
return Math.Round((ChInvoiceDetail.TAXRATE / 100), 2, MidpointRounding.AwayFromZero).ToString();
}
}
@ -637,23 +652,24 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin
public static string appSecret { get { return "SDFAFF5B0AED4465"; } }
*/
/*
/* 使
//339901999999516
public static string appKey { get { return "G6bvh0ke"; } }
public static string appSecret { get { return "6850C5AED14E4177"; } }
*/
/* 正式地址 大简云*/
//public static string appKey { get { return ConfigurationManager.AppSettings["NuoNuo_appKey"]; } }
//public static string appSecret { get { return ConfigurationManager.AppSettings["NuoNuo_appSecret"]; } }
public static string appKey { get; set; }
public static string appSecret { get; set; }
public static string appKey { get { return "23646802"; } }
public static string appSecret { get { return "CBFAFF5B0AED4465"; } }
/// <summary>
/// 使用沙盒地址还是实际工作地址
/// </summary>
public static string URL {
get {
public static string URL
{
get
{
//return sandboxUrl; //沙盒测试地址
return normalUrl;
}
@ -908,8 +924,6 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin
public HangXinRequestHelper()
{
appKey = MsSysParamSetDAL.GetSysParamValue("NuoNuo_appKey");
appSecret = MsSysParamSetDAL.GetSysParamValue("NuoNuo_appSecret");
tokenstarttime = Convert.ToDateTime("1900-01-01");
}
public HangXinRequestHelper(string taxnum)
@ -918,14 +932,14 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin
if (HXTokenHelperList == null) HXTokenHelperList = new List<HangXinRequestHelper>();
HXTokenHelperList.Add(this);
}
public HangXinRequestHelper(string taxnum,string accessToken)
public HangXinRequestHelper(string taxnum, string accessToken)
{
this.taxnum = taxnum;
this.accessToken = accessToken;
if (HXTokenHelperList == null) HXTokenHelperList = new List<HangXinRequestHelper>();
var curr = HXTokenHelperList.Find(o => o.taxnum == taxnum);
if (!(curr==null))
if (!(curr == null))
{
curr.accessToken = accessToken;
}
@ -1007,90 +1021,58 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin
//var result = new HangXinRequestHelper(taxnum);
//return result;
appKey = MsSysParamSetDAL.GetSysParamValue("NuoNuo_appKey") ;
appSecret = MsSysParamSetDAL.GetSysParamValue("NuoNuo_appSecret");
var _token = getPortToken(taxnum);
return _token;
}
private static HangXinRequestHelper getPortToken(string taxnum) {
private static HangXinRequestHelper getPortToken(string taxnum)
{
try
{
///读取接口token
//JObject reqObj = new JObject();
//reqObj.Add("taxnum", taxnum);
var dic = new Dictionary<string, string>();
dic.Add("taxnum", taxnum);
//var dic = new Dictionary<string, string>();
//dic.Add("taxnum", taxnum);
//var rtn = WebRequestHelper.DoPost(_IURL, dic, 10000);
//PortTokenmb pt = Newtonsoft.Json.JsonConvert.DeserializeObject<PortTokenmb>(rtn);
var rtn = WebRequestHelper.DoPost(_IURL, dic, 10000);
//var rtn = WebRequestHelper.DoPost(_SandBoxURL, dic, 20000);
//20230109 改为将token值记录在OP_LOGICINFO表中 BSNO=公司税号 propname='诺诺Token' 字段名NuoNuo_Token
//RepCZModel CZM = Newtonsoft.Json.JsonConvert.DeserializeObject<RepCZModel>(rtn);
PortTokenmb pt = Newtonsoft.Json.JsonConvert.DeserializeObject<PortTokenmb>(rtn);
if (HXTokenHelperList.Exists(x => x.taxnum == taxnum))
if (pt.status == "1")
{
var _token= HXTokenHelperList.First(x=>x.taxnum == taxnum);
var result = new HangXinRequestHelper(taxnum, _token.accessToken);
return result;
}
else {
var _dic = BasicDataRefDAL.GetLogicInfo(taxnum, "诺诺Token");
if (_dic != null && _dic.ContainsKey("NuoNuo_Token"))
{
var tokenstr = _dic["NuoNuo_Token"];
foreach (var hx in HXTokenHelperList)
{
if (hx.taxnum == taxnum)
{
hx.accessToken = tokenstr;
hx.accessToken = pt.message;
hx.CanUse = true;
hx.ERRORMSG = "";
return hx;
}
}
var result = new HangXinRequestHelper(taxnum, tokenstr);
var result = new HangXinRequestHelper(taxnum, pt.message);
return result;
}
else {
var tokenjson = NNOpenSDK.getMerchantToken(HangXinRequestHelper.appKey, HangXinRequestHelper.appSecret);
var token = DSWeb.MvcShipping.Helper.JsonConvert.Deserialize<nuonuotoken>(tokenjson);
var dic =new Dictionary<string, string> {
{"NuoNuo_Token",token.access_token }
};
BasicDataRefDAL.SaveLogicInfo(taxnum, "诺诺Token", dic);
return new HangXinRequestHelper(taxnum, token.access_token);
}
}
else
return new HangXinRequestHelper(taxnum, "");
}
catch (Exception e) {
catch (Exception e)
{
var result = new HangXinRequestHelper(taxnum, "");
result.CanUse = false;
result.ERRORMSG = "没有取得开票密钥:"+e.Message;
result.ERRORMSG = "没有取得开票密钥:" + e.Message;
return result;
}
}
public class nuonuotoken {
public string access_token { get; set; }
public int expires_in { get; set; }
}
//{\"access_token\":\"4ad7dfbf111624e13b146e0ozbnazu8s\",\"expires_in\":-1}
/// <summary>
@ -1156,14 +1138,11 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin
var result = new DBResult(false, "需要重新认证", null);
return result;
}
else if (_return.code == "E9106" )
else if (_return.code == "E9106")
{
//E9106 订单编号不能重复
//同billno重复发送 执行一次用订单号读取
//return ReadInvoice_BILLNO(head);
var result = ReadInvoice(head);
return result;
return ReadInvoice_BILLNO(head);
}
else
{
@ -1175,7 +1154,7 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin
public string PostInvoice(string json)
{
string method = "nuonuo.electronInvoice.requestBillingnew";
string method = "nuonuo.electronInvoice.requestBilling";
BasicDataRefDAL.SaveLog("URL=" + URL + ";appKey=" + appKey + ";appSecret=" + appSecret + ";accessToken=" + accessToken + ";taxnum=" + taxnum + ";method=" + method + ";content=" + json, "诺诺平台", "发票开出", "发送值");
string result = NNOpenSDK.sendPostSyncRequest(URL, getSendid(), appKey, appSecret, accessToken, taxnum, method, json);
@ -1186,9 +1165,10 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin
}
public DBResult ReadInvoice(string INVOICESERIALNUM,string USERID) {
public DBResult ReadInvoice(string INVOICESERIALNUM, string USERID)
{
var head = ChinvoiceDAL.GetData( "cm.INVOICESERIALNUM='" + INVOICESERIALNUM + "'");
var head = ChinvoiceDAL.GetData("cm.INVOICESERIALNUM='" + INVOICESERIALNUM + "'");
var _r = ReadInvoice(head);
@ -1198,22 +1178,21 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin
public DBResult ReadInvoice(ChInvoice_HangXin head)
{
if (string.IsNullOrEmpty(head.INVOICESERIALNUM)) {
if (string.IsNullOrEmpty(head.INVOICESERIALNUM))
{
var result = new DBResult { Success = false, Message = "还未成功进行平台开票,无可读数据", Data = "" };
return result;
}
//string method = "nuonuo.electronInvoice.CheckEInvoice";
//var json = "{" + "\"invoiceSerialNum\":[\"" + head.INVOICESERIALNUM + "\"]" + "}";
string method = "nuonuo.electronInvoice.queryInvoiceResult";
var json = "{" + "\"orderNos\":[]," + "\"serialNos\":[\"" + head.INVOICESERIALNUM + "\"]" + "}";
string method = "nuonuo.electronInvoice.CheckEInvoice";
var json = "{" + "\"invoiceSerialNum\":[\"" + head.INVOICESERIALNUM + "\"]" + "}";
if (string.IsNullOrWhiteSpace(head.INVOICESERIALNUM))
{
//如果流水号为空 则改为按业务编号读取
//method = "nuonuo.electronInvoice.querySerialNum";
json = "{" + "\"orderNos\":[\"" + head.BILLNO + "\"]," + "\"serialNos\":[]"+ "}";
method = "nuonuo.electronInvoice.querySerialNum";
json = "{" + "\"orderNo\":[\"" + head.BILLNO + "\"]" + "}";
}
//读取业务
@ -1226,7 +1205,8 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin
BasicDataRefDAL.SaveLog(_r, "诺诺平台", "读取发票信息", "返回值");
var _return = dealresponse_Read(_r);
if (_return.code == "070101"|| _return.code == "070301") {
if (_return.code == "070101" || _return.code == "070301")
{
//appkey与token问题 需要重新认证
//HangXinRequestHelper.clear(accessToken);
var result = new DBResult(false, "需要重新认证", null);
@ -1244,29 +1224,20 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin
if (_return.code == "E0000")
{
//开票信息读取成功
var returndate = ChinvoiceDAL.GetData( "cm.INVOICESERIALNUM='" + head.INVOICESERIALNUM + "'");
var returndate = ChinvoiceDAL.GetData("cm.INVOICESERIALNUM='" + head.INVOICESERIALNUM + "'");
head = returndate;
//var invoiceSerialNum = _return.result[0].invoiceSerialNum;
var info = _return.result[0];
var result = new DBResult();
//如果,"statusMsg":"开票失败"返回错误
if (info.statusMsg == "开票失败") {
return result.SetErrorInfo(info.statusMsg + ":" + info.failCause);
}
//立即调用读取发票信息的方法 将返回值设置进head 并保存
//head.INVOICESERIALNUM = invoiceSerialNum;
head.INVOICECODE = info.invoiceCode;
head.INVOICENO = info.invoiceNo;
head.INVOICENO = info.invoiceNum;
head.EINVOICESTATE = info.status;
head.INVOICEINFOURL = info.pictureUrl;
head.INVOICEPDFURL = info.pdfUrl;
var invdate = BasicDataRefDAL.Timestamp2Datetime(info.updateTime);
head.INVOICEINFOURL = info.invoiceImageUrl;
head.INVOICEPDFURL = info.invoiceFileUrl;
head.INVOICEMAKETIME = invdate.ToString("yyyy-MM-dd HH:mm:ss");
head.INVOICEMAKETIME = info.invoiceDate;
//if (!string.IsNullOrWhiteSpace(info.invoiceSerialNum))
//{
// head.INVOICESERIALNUM = info.invoiceSerialNum;
@ -1276,13 +1247,14 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin
head.DbOperationType = DbOperationType.DbotUpd;
head.ModelUIStatus = "E";
var modb = new ModelObjectDB();
result = modb.Save(head);
//result.Message = info.resultMsg;
var result = modb.Save(head);
result.Message = info.resultMsg;
//if (info.resultMsg.Contains("开具结果:0,开具失败原因:开票异常")) {
// result.Message = "开票异常,请尝试重新连接税控盘、重新启动税控软件和诺诺客户端,然后再次读取发票信息;如仍显示此提示,请联系诺诺平台客服人员,并提供销方税号和此发票的流水号";
//}
if (info.resultMsg.Contains("开具结果:0,开具失败原因:开票异常"))
{
result.Message = "开票异常,请尝试重新连接税控盘、重新启动税控软件和诺诺客户端,然后再次读取发票信息;如仍显示此提示,请联系诺诺平台客服人员,并提供销方税号和此发票的流水号";
}
return result;
@ -1290,87 +1262,87 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin
else
{
var msg = _return.code+":"+_return.describe;
var msg = _return.code + ":" + _return.describe;
var result = new DBResult { Success = false, Message = DSWeb.TruckMng.Helper.JsonConvert.Serialize(msg), Data = "" };
return result;
}
}
//public DBResult ReadInvoice_BILLNO(ChInvoice_HangXin head)
//{
public DBResult ReadInvoice_BILLNO(ChInvoice_HangXin head)
{
// //读取业务
// string method = "nuonuo.electronInvoice.querySerialNum";
// var json = "{" + "\"orderNo\":[\"" + head.BILLNO + "\"]" + "}";
//读取业务
string method = "nuonuo.electronInvoice.querySerialNum";
var json = "{" + "\"orderNo\":[\"" + head.BILLNO + "\"]" + "}";
// BasicDataRefDAL.SaveLog("URL=" + URL + ";appKey=" + appKey + ";appSecret=" + appSecret + ";accessToken=" + accessToken + ";taxnum=" + taxnum + ";method=" + method + ";content=" + json, "诺诺平台", "读取发票信息", "发送值");
// string _r = NNOpenSDK.sendPostSyncRequest(URL, getSendid(), appKey, appSecret, accessToken, taxnum, method, json);
// BasicDataRefDAL.SaveLog(_r, "诺诺平台", "读取发票信息", "返回值");
// var _return = dealresponse_Read(_r);
BasicDataRefDAL.SaveLog("URL=" + URL + ";appKey=" + appKey + ";appSecret=" + appSecret + ";accessToken=" + accessToken + ";taxnum=" + taxnum + ";method=" + method + ";content=" + json, "诺诺平台", "读取发票信息", "发送值");
string _r = NNOpenSDK.sendPostSyncRequest(URL, getSendid(), appKey, appSecret, accessToken, taxnum, method, json);
BasicDataRefDAL.SaveLog(_r, "诺诺平台", "读取发票信息", "返回值");
var _return = dealresponse_Read(_r);
// if (_return.code == "070101" || _return.code == "070301")
// {
// //appkey与token问题 需要重新认证
// //HangXinRequestHelper.clear(accessToken);
// var result = new DBResult(false, "需要重新认证", null);
// return result;
// }
// if (_return.code == "070302")
// {
// //appkey与token问题 需要重新认证
// //HangXinRequestHelper.clear(accessToken);
// var result = new DBResult(false, "需要联系诺诺平台开通相关权限", null);
// return result;
// }
if (_return.code == "070101" || _return.code == "070301")
{
//appkey与token问题 需要重新认证
//HangXinRequestHelper.clear(accessToken);
var result = new DBResult(false, "需要重新认证", null);
return result;
}
if (_return.code == "070302")
{
//appkey与token问题 需要重新认证
//HangXinRequestHelper.clear(accessToken);
var result = new DBResult(false, "需要联系诺诺平台开通相关权限", null);
return result;
}
// if (_return.code == "E0000")
// {
// //开票信息读取成功
// var returndate = ChinvoiceDAL.GetData( "cm.INVOICESERIALNUM='" + head.INVOICESERIALNUM + "'");
// head = returndate;
// //var invoiceSerialNum = _return.result[0].invoiceSerialNum;
// var info = _return.result[0];
// //立即调用读取发票信息的方法 将返回值设置进head 并保存
// //head.INVOICESERIALNUM = invoiceSerialNum;
// head.INVOICECODE = info.invoiceCode;
// head.INVOICENO = info.invoiceNum;
// head.EINVOICESTATE = info.status;
// head.INVOICEINFOURL = info.invoiceImageUrl;
// head.INVOICEPDFURL = info.invoiceFileUrl;
// head.INVOICEMAKETIME = info.invoiceDate;
// if (!string.IsNullOrWhiteSpace(info.invoiceSerialNum))
// {
// head.INVOICESERIALNUM = info.invoiceSerialNum;
// }
// //head.REMARK = head.REMARK.Replace(info.remark,"")+ info.remark;
if (_return.code == "E0000")
{
//开票信息读取成功
var returndate = ChinvoiceDAL.GetData("cm.INVOICESERIALNUM='" + head.INVOICESERIALNUM + "'");
head = returndate;
//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.DbOperationType = DbOperationType.DbotUpd;
// head.ModelUIStatus = "E";
// var modb = new ModelObjectDB();
// var result = modb.Save(head);
// result.Message = info.resultMsg;
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;
if (info.resultMsg.Contains("开具结果:0,开具失败原因:开票异常"))
{
result.Message = "开票异常,请尝试重新连接税控盘、重新启动税控软件和诺诺客户端,然后再次读取发票信息;如仍显示此提示,请联系诺诺平台客服人员,并提供销方税号和此发票的流水号";
}
// }
// else
// {
return result;
// var msg = _return.code + ":" + _return.describe;
// var result = new DBResult { Success = false, Message = DSWeb.TruckMng.Helper.JsonConvert.Serialize(msg), Data = "" };
// return result;
}
else
{
// }
//}
var msg = _return.code + ":" + _return.describe;
var result = new DBResult { Success = false, Message = DSWeb.TruckMng.Helper.JsonConvert.Serialize(msg), Data = "" };
return result;
}
}
public DBResult VoidInvoice(ChInvoice_HangXin head)
{
if (string.IsNullOrEmpty(head.INVOICESERIALNUM))
@ -1382,16 +1354,16 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin
//作废接口
string method = "nuonuo.electronInvoice.invoiceCancellation";
// String content = "{" +
//"\"invoiceId\":\"19051413444101000011\"," +
//"\"invoiceCode\":\"033001800211\"," +
//"\"invoiceNo\":\"07912653\"" +
//"}";
// String content = "{" +
//"\"invoiceId\":\"19051413444101000011\"," +
//"\"invoiceCode\":\"033001800211\"," +
//"\"invoiceNo\":\"07912653\"" +
//"}";
var json = "{" +
"\"invoiceId\":\""+ head.INVOICESERIALNUM + "\"," +
"\"invoiceCode\":\""+ head.INVOICECODE + "\"," +
"\"invoiceNo\":\""+ head.INVOICENO + "\"" +
"\"invoiceId\":\"" + head.INVOICESERIALNUM + "\"," +
"\"invoiceCode\":\"" + head.INVOICECODE + "\"," +
"\"invoiceNo\":\"" + head.INVOICENO + "\"" +
"}";
BasicDataRefDAL.SaveLog("URL=" + URL + ";appKey=" + appKey + ";appSecret=" + appSecret + ";accessToken=" + accessToken + ";taxnum=" + taxnum + ";method=" + method + ";content=" + json, "诺诺平台", "发票作废", "发送值");
@ -1403,9 +1375,9 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin
{
//作废请求成功
var invoiceSerialNum = _return.result;
var invoiceSerialNum = _return.result.invoiceId;
//head.INVOICESERIALNUM = invoiceSerialNum;
head.INVOICESERIALNUM = invoiceSerialNum;
head.ISDELETE = "true";
@ -1419,7 +1391,7 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin
else
{
var msg = _return.code+_return.status + ":" + _return.describe+ _return.msg;
var msg = _return.code + _return.status + ":" + _return.describe + _return.msg;
var result = new DBResult { Success = false, Message = DSWeb.TruckMng.Helper.JsonConvert.Serialize(msg), Data = "" };
return result;
@ -1431,7 +1403,8 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin
/// </summary>
/// <param name="json"></param>
/// <returns></returns>
private KPResponse dealresponse_KP(string json) {
private KPResponse dealresponse_KP(string json)
{
var result = new KPResponse();
result = DSWeb.TruckMng.Helper.JsonConvert.Deserialize<KPResponse>(json.Trim('"'));
@ -1556,8 +1529,9 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin
/// TAXNUM,CODE,USERID,ACCESSTOKEN,REFRESHTOKEN,STARTTIME,SAVETIME,ERROR,ERROR_DESCRIPTION
/// </summary>
/// <returns></returns>
private string getInsertStr() {
var result = string.Format(" insert into Invoice_HangXinToken values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}')", taxnum,code,userId,accessToken,refreshToken, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),error,error_description);
private string getInsertStr()
{
var result = string.Format(" insert into Invoice_HangXinToken values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}')", taxnum, code, userId, accessToken, refreshToken, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), error, error_description);
return result;
}
@ -1572,7 +1546,8 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin
}
public class PortTokenmb {
public class PortTokenmb
{
public string message { get; set; }
public string status { get; set; }
}
@ -1642,205 +1617,12 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin
public KPResult result { get; set; }
}
public class Result
{
/// <summary>
/// 深圳市宝安区兴围工业一路17-F105 电话:13692121010
/// </summary>
public string address { get; set; }
/// <summary>
/// 中国银行深圳机场支行 749763304324
/// </summary>
public string bankAccount { get; set; }
/// <summary>
/// 吴彩婷
/// </summary>
public string checker { get; set; }
/// <summary>
/// 吴彩婷
/// </summary>
public string clerk { get; set; }
/// <summary>
///
/// </summary>
public string clerkId { get; set; }
/// <summary>
///
/// </summary>
public long createTime { get; set; }
/// <summary>
///
/// </summary>
public string deptId { get; set; }
/// <summary>
///
/// </summary>
public string extensionNumber { get; set; }
/// <summary>
///
/// </summary>
public string imgUrls { get; set; }
/// <summary>
///
/// </summary>
public long invoiceDate { get; set; }
/// <summary>
///
/// </summary>
public string invoiceType { get; set; }
/// <summary>
///
/// </summary>
public string listFlag { get; set; }
/// <summary>
///
/// </summary>
public string listName { get; set; }
/// <summary>
///
/// </summary>
public string notifyEmail { get; set; }
/// <summary>
///
/// </summary>
public string ofdUrl { get; set; }
/// <summary>
///
/// </summary>
public string oldInvoiceCode { get; set; }
/// <summary>
///
/// </summary>
public string oldInvoiceNo { get; set; }
/// <summary>
///
/// </summary>
public string orderAmount { get; set; }
/// <summary>
/// 吴彩婷
/// </summary>
public string payee { get; set; }
/// <summary>
///
/// </summary>
public string phone { get; set; }
/// <summary>
///
/// </summary>
public int productOilFlag { get; set; }
/// <summary>
///
/// </summary>
public string proxyInvoiceFlag { get; set; }
/// <summary>
///
/// </summary>
public string remark { get; set; }
/// <summary>
///
/// </summary>
public string requestSrc { get; set; }
/// <summary>
/// 上海敬运国际物流有限公司
/// </summary>
public string saleName { get; set; }
/// <summary>
/// 中国银行北外滩支行-435168156076
/// </summary>
public string salerAccount { get; set; }
/// <summary>
/// 上海市虹口区吴淞路218号宝矿大厦1207室
/// </summary>
public string salerAddress { get; set; }
/// <summary>
///
/// </summary>
public string salerTaxNum { get; set; }
/// <summary>
///
/// </summary>
public string salerTel { get; set; }
/// <summary>
///
/// </summary>
public int specificFactor { get; set; }
/// <summary>
///
/// </summary>
public string telephone { get; set; }
/// <summary>
///
/// </summary>
public string terminalNumber { get; set; }
/// <summary>
///
/// </summary>
public long updateTime { get; set; }
/// <summary>
///
/// </summary>
public string serialNo { get; set; }
/// <summary>
///
/// </summary>
public string orderNo { get; set; }
/// <summary>
///
/// </summary>
public string status { get; set; }
/// <summary>
/// 开票失败
/// </summary>
public string statusMsg { get; set; }
/// <summary>
/// 请将客户端开票模式切换为【网页开票模式】
/// </summary>
public string failCause { get; set; }
/// <summary>
///
/// </summary>
public string pdfUrl { get; set; }
/// <summary>
///
/// </summary>
public string pictureUrl { get; set; }
/// <summary>
///
/// </summary>
public string invoiceCode { get; set; }
/// <summary>
///
/// </summary>
public string invoiceNo { get; set; }
/// <summary>
///
/// </summary>
public string exTaxAmount { get; set; }
/// <summary>
///
/// </summary>
public string taxAmount { get; set; }
/// <summary>
/// 深圳卓越顺达货运代理有限公司
/// </summary>
public string payerName { get; set; }
/// <summary>
///
/// </summary>
public string payerTaxNo { get; set; }
/// <summary>
/// 增值税电子普通发票
/// </summary>
public string invoiceKind { get; set; }
}
[JsonObject]
///解析开票命令返回值内的result
public class KPResult
{
public string invoiceSerialNum { get; set; }
//public string invoiceId { get; set; }
public string invoiceId { get; set; }
}
@ -1870,7 +1652,7 @@ namespace DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin
public List<string> result { get; set; }
*/
public List<Result> result { get; set; }
public List<ReadResult> result { get; set; }
}
[JsonObject]
///用于解析“读取发票信息”方法返回的发票信息

Loading…
Cancel
Save