|
|
using System;
|
|
|
using System.Linq;
|
|
|
using System.Web.Mvc;
|
|
|
using DSWeb.MvcShipping.Models.SysInvInterFaceSet;
|
|
|
using DSWeb.MvcShipping.DAL.MsSysInvInterFaceSet;
|
|
|
using DSWeb.MvcShipping.Helper;
|
|
|
using DSWeb.MvcShipping.Comm.Cookie;
|
|
|
using System.Collections.Generic;
|
|
|
using HcUtility.Comm;
|
|
|
using HcUtility.Core;
|
|
|
using DSWeb.Areas.CommMng.DAL;
|
|
|
using DSWeb.Areas.Account.Models.Chfee_Invoice_HangXin;
|
|
|
using DSWeb.Common.DB;
|
|
|
using DSWeb.SoftMng.Filter;
|
|
|
|
|
|
namespace DSWeb.MvcShipping.Controllers
|
|
|
{
|
|
|
[JsonRequestBehavior]
|
|
|
public class MsSysInvInterFaceSetController : Controller
|
|
|
{
|
|
|
//
|
|
|
// GET:
|
|
|
public ActionResult Index()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
//
|
|
|
// GET: /
|
|
|
public ActionResult InvIndex()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
//
|
|
|
// GET:
|
|
|
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
|
|
|
public ContentResult GetDataList(string condition, string sort)
|
|
|
{
|
|
|
var dataList = MsSysInvInterFaceSetDAL.GetDataList(condition, Convert.ToString(Session["COMPANYID"]), sort);
|
|
|
|
|
|
var json = JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = dataList.ToList() });
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
|
|
|
//
|
|
|
// GET:/TruckMng/MsWlTyreAcc/GetData/
|
|
|
[SqlKeyWordsFilter(Type = "Action")]//sql 防注入过滤器
|
|
|
public ContentResult GetData(string handle, string condition)
|
|
|
{
|
|
|
SysInvInterFaceSet head = null;
|
|
|
|
|
|
if (handle == "edit")
|
|
|
{
|
|
|
var list = MsSysInvInterFaceSetDAL.GetDataList(condition, Convert.ToString(Session["COMPANYID"]));
|
|
|
if (list.Count > 0)
|
|
|
head = list[0];
|
|
|
}
|
|
|
|
|
|
if (head == null)
|
|
|
{
|
|
|
head = new SysInvInterFaceSet();
|
|
|
}
|
|
|
|
|
|
var json = JsonConvert.Serialize(
|
|
|
new { Success = true, Message = "查询成功", data = head });
|
|
|
return new ContentResult() { Content = json };
|
|
|
}
|
|
|
|
|
|
public ContentResult Delete(string data)
|
|
|
{
|
|
|
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
|
|
|
{
|
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
}
|
|
|
//
|
|
|
var headData = JsonConvert.Deserialize<SysInvInterFaceSet>(data);
|
|
|
var modb = new ModelObjectDB();
|
|
|
DBResult result = modb.Delete(headData);
|
|
|
|
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
|
|
|
public ContentResult SaveDetail(string body)
|
|
|
{
|
|
|
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
|
|
|
{
|
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
|
}
|
|
|
//
|
|
|
var bodyList = JsonConvert.Deserialize<List<SysInvInterFaceSet>>(body);
|
|
|
|
|
|
DBResult result = MsSysInvInterFaceSetDAL.SaveDetail(bodyList, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"]), CookieConfig.GetCookie_LocalCurr(Request));
|
|
|
|
|
|
var jsonRespose = new JsonResponse { Success = result.Success, Message = result.Message };
|
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose) };
|
|
|
}
|
|
|
|
|
|
|
|
|
public ContentResult RegainToken(string GID)
|
|
|
{
|
|
|
|
|
|
var canlogin = BasicDataRefDAL.CheckLogin(Session);
|
|
|
if (!canlogin.Success)
|
|
|
{
|
|
|
return (ContentResult)canlogin.Data;
|
|
|
}
|
|
|
|
|
|
var result = new DBResult();
|
|
|
|
|
|
var condition = $" GID='{GID}' ";
|
|
|
SysInvInterFaceSet head = null;
|
|
|
|
|
|
var list = MsSysInvInterFaceSetDAL.GetDataList(condition, Convert.ToString(Session["COMPANYID"]));
|
|
|
if (list.Count > 0)
|
|
|
{
|
|
|
head = list[0];
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
result.SetErrorInfo("没有找到业务");
|
|
|
return BasicDataRefDAL.GetContentResult(result);
|
|
|
}
|
|
|
var cdc = new CommonDataContext();
|
|
|
var companyinfo = cdc.company.Where(x => x.GID == head.COMPANYID).ToList();
|
|
|
|
|
|
if (companyinfo == null || companyinfo.Count == 0)
|
|
|
{
|
|
|
result.SetErrorInfo("没有找到该分公司");
|
|
|
return BasicDataRefDAL.GetContentResult(result);
|
|
|
}
|
|
|
|
|
|
var company = companyinfo[0];
|
|
|
if (string.IsNullOrWhiteSpace(company.TAXCODE))
|
|
|
{
|
|
|
result.SetErrorInfo($"没有找到分公司[{head.COMPANYNAME}]的税号");
|
|
|
return BasicDataRefDAL.GetContentResult(result);
|
|
|
}
|
|
|
|
|
|
var hx = 诺诺全电发票.RegainToken(company.TAXCODE, company.GID);
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(hx.accessToken))
|
|
|
{
|
|
|
result.OK("已重新获取到新的开票认证,请尝试重新开票");
|
|
|
return BasicDataRefDAL.GetContentResult(result);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return BasicDataRefDAL.GetContentResult(result.SetErrorInfo($"没有获取到新的开票认证,请稍后再次尝试,或联系客服人员。"));
|
|
|
//return BasicDataRefDAL.GetContentResult(result);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|