You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Dispatch/Controllers/MainController.cs

140 lines
5.2 KiB
C#

using System.Configuration;
using System.Linq;
using System.Web.Mvc;
using DSWeb.Areas.Dispatch.DB;
using DSWeb.Areas.Dispatch.Helper;
using DSWeb.Areas.Dispatch.Models;
using DSWeb.Dispatch.DAL;
namespace DSWeb.Areas.Dispatch.Controllers
{
public class MainController : Controller
{
private static string encryptKey = ConfigurationManager.AppSettings["dispatchApiEncryptKey"];
private DataContext dataContext = new DataContext();
[HttpGet]
public JsonResult GetSaleOpSeaeList(int start, int limit, string condition, string sort, string order, bool hasNoFee = true)
{
RespGetOpSeae resp = new RespGetOpSeae();
string strUserData = Request.Headers["UserData"];
if (string.IsNullOrWhiteSpace(strUserData))
{
resp.Success = false;
resp.Message = "用户无效,请重新登录";
}
else
{
strUserData = EncryptHandler.Decrypt(encryptKey, strUserData);
var userObj = Newtonsoft.Json.JsonConvert.DeserializeObject<InfoClientLoginViewModel>(strUserData);
var dataList = MsOpSeaeDAL.GetSaleDataList(userObj.SHORTNAME, condition, sort, order, hasNoFee);
var list = dataList.Skip(start).Take(limit);
resp.Success = true;
resp.Message = "查询成功";
resp.Data = list.ToList();
resp.Total = dataList.Count;
}
return Json(resp, JsonRequestBehavior.AllowGet);
}
[HttpGet]
public JsonResult GetFeeList(string BSNO)
{
RespGetFee resp = new RespGetFee();
string strUserData = Request.Headers["UserData"];
if (string.IsNullOrWhiteSpace(strUserData))
{
resp.Success = false;
resp.Message = "用户无效,请重新登录";
}
else
{
strUserData = EncryptHandler.Decrypt(encryptKey, strUserData);
var userObj = Newtonsoft.Json.JsonConvert.DeserializeObject<InfoClientLoginViewModel>(strUserData);
var dataList = MsChFeeDAL.GetShouldGetDataList(userObj.SHORTNAME, BSNO);
resp.Success = true;
resp.Message = "查询成功";
resp.Data = dataList;
}
return Json(resp, JsonRequestBehavior.AllowGet);
}
[HttpGet]
public JsonResult GetStatusList(string BSNO)
{
RespGetOpStatus resp = new RespGetOpStatus();
string strUserData = Request.Headers["UserData"];
if (string.IsNullOrWhiteSpace(strUserData))
{
resp.Success = false;
resp.Message = "用户无效,请重新登录";
}
else
{
strUserData = EncryptHandler.Decrypt(encryptKey, strUserData);
var userObj = Newtonsoft.Json.JsonConvert.DeserializeObject<InfoClientLoginViewModel>(strUserData);
var dataList = dataContext.OpStatus.Where(s => s.BSNO == BSNO);
resp.Success = true;
resp.Message = "查询成功";
resp.Data = dataList.AsOpStatusViewModelList();
}
return Json(resp, JsonRequestBehavior.AllowGet);
}
[HttpGet]
public JsonResult GetFileList(string BSNO)
{
RespGetFiles resp = new RespGetFiles();
string strUserData = Request.Headers["UserData"];
if (string.IsNullOrWhiteSpace(strUserData))
{
resp.Success = false;
resp.Message = "用户无效,请重新登录";
}
else
{
strUserData = EncryptHandler.Decrypt(encryptKey, strUserData);
var userObj = Newtonsoft.Json.JsonConvert.DeserializeObject<InfoClientLoginViewModel>(strUserData);
var dataList = dataContext.ReceiptDocs.Where(s => s.BSNO == BSNO && s.ISPUBLIC.HasValue && s.ISPUBLIC.Value);
resp.Success = true;
resp.Message = "查询成功";
resp.Data = dataList.AsReceiptDocListViewModelList();
}
return Json(resp, JsonRequestBehavior.AllowGet);
}
[HttpGet]
public JsonResult GetReportList(string condition, string sort, string order)
{
RespReportOpSeae resp = new RespReportOpSeae();
string strUserData = Request.Headers["UserData"];
if (string.IsNullOrWhiteSpace(strUserData))
{
resp.Success = false;
resp.Message = "用户无效,请重新登录";
}
else
{
strUserData = EncryptHandler.Decrypt(encryptKey, strUserData);
var userObj = Newtonsoft.Json.JsonConvert.DeserializeObject<InfoClientLoginViewModel>(strUserData);
var dataList = MsOpSeaeDAL.GetReportDataList(userObj.SHORTNAME, condition, sort, order);
resp.Success = true;
resp.Message = "查询成功";
resp.Data = dataList;
}
return Json(resp, JsonRequestBehavior.AllowGet);
}
}
}