957 lines
37 KiB
C#
957 lines
37 KiB
C#
|
|
using Antlr.Runtime.Tree;
|
|||
|
|
using Google.Protobuf.WellKnownTypes;
|
|||
|
|
using Microsoft.Ajax.Utilities;
|
|||
|
|
using Models;
|
|||
|
|
using Models.ModelGoods;
|
|||
|
|
using Models.ModelItems;
|
|||
|
|
using MySqlX.XDevAPI.Common;
|
|||
|
|
using Newtonsoft.Json;
|
|||
|
|
using Org.BouncyCastle.Ocsp;
|
|||
|
|
using Services.Api;
|
|||
|
|
using Services.Manager;
|
|||
|
|
using Services.Tool;
|
|||
|
|
using SqlSugar;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.IO;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Net;
|
|||
|
|
using System.Reflection.Emit;
|
|||
|
|
using System.Runtime.CompilerServices;
|
|||
|
|
using System.Security.Cryptography;
|
|||
|
|
using System.Security.Policy;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Web;
|
|||
|
|
using System.Web.Mvc;
|
|||
|
|
using System.Web.Razor.Tokenizer.Symbols;
|
|||
|
|
using System.Web.Services.Description;
|
|||
|
|
using System.Web.UI;
|
|||
|
|
|
|||
|
|
|
|||
|
|
namespace WxApi.Controllers
|
|||
|
|
{
|
|||
|
|
public class uts_zongqing_tbl_importinfoall : uts_zongqing_tbl_importinfo
|
|||
|
|
{
|
|||
|
|
public string ProjectName { get; set; }
|
|||
|
|
}
|
|||
|
|
public class uts_johao_tbl_importinfoall : uts_johao_tbl_importinfo
|
|||
|
|
{
|
|||
|
|
public string ProjectName { get; set; }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public class WxController : Controller
|
|||
|
|
{
|
|||
|
|
// GET: Wx
|
|||
|
|
public ActionResult Index()
|
|||
|
|
{
|
|||
|
|
return View();
|
|||
|
|
}
|
|||
|
|
//使用案例
|
|||
|
|
// curl --request POST \
|
|||
|
|
//--url https://localhost:44379/Wx/Wxlog \
|
|||
|
|
//--header 'content-type: multipart/form-data' \
|
|||
|
|
//--form UserName=hahah \
|
|||
|
|
//--form appid=6571 \
|
|||
|
|
//--form Password=123451116 \
|
|||
|
|
//--form islong=false \
|
|||
|
|
//--form openid=1211111
|
|||
|
|
/// <summary>
|
|||
|
|
/// 用户验证登录
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="UserName">用户名</param>
|
|||
|
|
/// <param name="appid">app编号</param>
|
|||
|
|
/// <param name="Password">密码</param>
|
|||
|
|
/// <param name="islong">登录时间长短</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
[HttpPost]
|
|||
|
|
public ActionResult Wxlog(string UserName = "", int appid = 0, string Password = "", bool islong = false, string openid = "")
|
|||
|
|
{
|
|||
|
|
//写日志
|
|||
|
|
Logs.WriteTimingPlanLog("用户名:" + UserName + "密码:" + Password);
|
|||
|
|
var result = new ReturnResult<dynamic>();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
//获取信息
|
|||
|
|
result = OTApi.Wxlog(UserName, Password, appid, null, openid, islong);
|
|||
|
|
if (result != null)
|
|||
|
|
{
|
|||
|
|
if (result.Status == 200)
|
|||
|
|
{
|
|||
|
|
result.Status = 200;
|
|||
|
|
result.Message = "请求成功。。。。";
|
|||
|
|
}
|
|||
|
|
else if (result.Status == 300)
|
|||
|
|
{
|
|||
|
|
result.Status = 300;
|
|||
|
|
result.Message = "您的帐号没有激活,请联系管理员";
|
|||
|
|
Logs.WriteLog("账号激活:" + result.Message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
Logs.WriteErrorLog("登录出问题了您来看看吧", ex);
|
|||
|
|
result.Status = 500;
|
|||
|
|
result.Message = "服务器错误";
|
|||
|
|
result.Data = null;
|
|||
|
|
}
|
|||
|
|
return Json(result);
|
|||
|
|
}
|
|||
|
|
//使用案例
|
|||
|
|
//curl --request POST \
|
|||
|
|
//--url https://localhost:44379/Wx/LoginToken \
|
|||
|
|
//--header 'content-type: multipart/form-data' \
|
|||
|
|
//--form token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzM4NCJ9.eyJkYXRhIjpudWxsLCJleHAiOjQwNTUwMDIwMjAwLjB9.Oyr_dtY1C - 9atU5hU0isQPmsUoVEco0KInrWbXp-vIhFOTe4rbKbVYrOYHfYCIG4 \
|
|||
|
|
//--form appid = 5
|
|||
|
|
/// </summary>
|
|||
|
|
/// Token登录
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="token">Token值</param>
|
|||
|
|
/// <param name="appid">app编号</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
[HttpPost]
|
|||
|
|
public ActionResult LoginToken(string token, int appid = 5)
|
|||
|
|
{
|
|||
|
|
var info = new ReturnResult<dynamic>();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
info = OTApi.WxlogToken(token, appid);
|
|||
|
|
//info.Data = TokenHelper.CheckToken(token);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
Logs.WriteLog("检查token时的Error:" + ex);
|
|||
|
|
info.Status = 500;
|
|||
|
|
info.Message = "服务器错误";
|
|||
|
|
info.Data = null;
|
|||
|
|
}
|
|||
|
|
return Json(info);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据运货单号查询订单编号信息
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="ShippingCode">订单编号</param>
|
|||
|
|
/// <param name="token"></param>
|
|||
|
|
/// <param name="Status">状态</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
[HttpPost]
|
|||
|
|
|
|||
|
|
public ActionResult GetOutList(string ShippingCode, int sqlid)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
if (sqlid == 7)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
List<uts_zongqing_tbl_importinfoall> coos = SqlSugarGoodsBase.Db.Queryable<uts_zongqing_tbl_importinfo>()
|
|||
|
|
.Where(x => x.ShippingCode == ShippingCode).OrderByDescending(x => x.ShippingDateTime).Select(x => new uts_zongqing_tbl_importinfoall
|
|||
|
|
{
|
|||
|
|
ID = x.ID,
|
|||
|
|
ShippingCode = x.ShippingCode,
|
|||
|
|
ProjectID = x.ProjectID,
|
|||
|
|
Barcode = x.Barcode,
|
|||
|
|
ImportDateTime = x.ImportDateTime,
|
|||
|
|
UpdateTime = x.UpdateTime,
|
|||
|
|
ColorBox_BarCode = x.ColorBox_BarCode,
|
|||
|
|
OutBoxCode = x.OutBoxCode,
|
|||
|
|
ShippingDateTime = x.ShippingDateTime,
|
|||
|
|
ShippingLoader = x.ShippingLoader,
|
|||
|
|
})
|
|||
|
|
.ToList();
|
|||
|
|
List<jsonapi> retList = new List<jsonapi>();
|
|||
|
|
if (coos.Count <= 0)
|
|||
|
|
{
|
|||
|
|
return Json(retList);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
foreach (uts_zongqing_tbl_importinfoall item in coos)
|
|||
|
|
{
|
|||
|
|
List<TBL_Project> g = SqlBase.Db.Queryable<TBL_Project>().Where(x => x.ProjectName != "Shipping").ToList();
|
|||
|
|
|
|||
|
|
List<TBL_Project> listsm = g.Where(x => x.ID == item.ProjectID).ToList();
|
|||
|
|
if (listsm.Count > 0)
|
|||
|
|
{
|
|||
|
|
item.ProjectName = listsm[0].ProjectName;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//if item's outbox already in array, add colorbox to item's CCodeBCodeList
|
|||
|
|
//else, create a outbox item to array, and add colorbox to iems CCodeBCodeList
|
|||
|
|
bool isExistInList = false;
|
|||
|
|
int matchPos = -1;
|
|||
|
|
for (int i = 0; i < retList.Count; i++)
|
|||
|
|
{
|
|||
|
|
if (retList[i].OutBoxCode == item.OutBoxCode)
|
|||
|
|
{
|
|||
|
|
isExistInList = true;
|
|||
|
|
matchPos = i;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (isExistInList)
|
|||
|
|
{
|
|||
|
|
retList[matchPos].CCodeBCodeList.Add(new ColorBarPair { ColorBox = item.ColorBox_BarCode, BarCode = item.Barcode });
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
jsonapi tmpObj = new jsonapi();
|
|||
|
|
tmpObj.OutBoxCode = item.OutBoxCode;
|
|||
|
|
tmpObj.ProjectID = item.ProjectID;
|
|||
|
|
tmpObj.Operator = item.ShippingLoader;
|
|||
|
|
tmpObj.ShippingDateTime = item.ShippingDateTime;
|
|||
|
|
tmpObj.ShippingCode = item.ShippingCode;
|
|||
|
|
tmpObj.Status = true;
|
|||
|
|
tmpObj.ProjectName=item.ProjectName;
|
|||
|
|
tmpObj.CCodeBCodeList = new List<ColorBarPair>();
|
|||
|
|
tmpObj.CCodeBCodeList.Add(new ColorBarPair { ColorBox = item.ColorBox_BarCode, BarCode = item.Barcode });
|
|||
|
|
retList.Add(tmpObj);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
return Json(retList);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
List<uts_johao_tbl_importinfoall> coos = SqlSugarGoodsBase.Db.Queryable<uts_johao_tbl_importinfo>()
|
|||
|
|
.Where(x => x.ShippingCode == ShippingCode).OrderByDescending(x => x.ShippingDateTime).Select(x => new uts_johao_tbl_importinfoall
|
|||
|
|
{
|
|||
|
|
ID = x.ID,
|
|||
|
|
ShippingCode = x.ShippingCode,
|
|||
|
|
ProjectID = x.ProjectID,
|
|||
|
|
Barcode = x.Barcode,
|
|||
|
|
ImportDateTime = x.ImportDateTime,
|
|||
|
|
UpdateTime = x.UpdateTime,
|
|||
|
|
ColorBox_BarCode = x.ColorBox_BarCode,
|
|||
|
|
OutBoxCode = x.OutBoxCode,
|
|||
|
|
ShippingDateTime = x.ShippingDateTime,
|
|||
|
|
ShippingLoader = x.ShippingLoader,
|
|||
|
|
})
|
|||
|
|
.ToList();
|
|||
|
|
// List<uts_johao_tbl_importinfo> coos = SqlSugarGoodsBase.Db.Queryable<uts_johao_tbl_importinfo>()
|
|||
|
|
//.Where(x => x.ShippingCode == ShippingCode)
|
|||
|
|
//.OrderByDescending(x => x.ShippingDateTime).ToList();
|
|||
|
|
List<jsonapi> retList = new List<jsonapi>();
|
|||
|
|
if (coos.Count <= 0)
|
|||
|
|
{
|
|||
|
|
return Json(retList);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
foreach (uts_johao_tbl_importinfoall item in coos)
|
|||
|
|
{
|
|||
|
|
List<TBL_Project> g = SqljohaoBase.Db.Queryable<TBL_Project>().ToList();
|
|||
|
|
|
|||
|
|
List<TBL_Project> listsm = g.Where(x => x.ID == item.ProjectID).ToList();
|
|||
|
|
if (listsm.Count > 0)
|
|||
|
|
{
|
|||
|
|
item.ProjectName = listsm[0].ProjectName;
|
|||
|
|
}
|
|||
|
|
//if item's outbox already in array, add colorbox to item's CCodeBCodeList
|
|||
|
|
//else, create a outbox item to array, and add colorbox to iems CCodeBCodeList
|
|||
|
|
bool isExistInList = false;
|
|||
|
|
int matchPos = -1;
|
|||
|
|
for (int i = 0; i < retList.Count; i++)
|
|||
|
|
{
|
|||
|
|
if (retList[i].OutBoxCode == item.OutBoxCode)
|
|||
|
|
{
|
|||
|
|
isExistInList = true;
|
|||
|
|
matchPos = i;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (isExistInList)
|
|||
|
|
{
|
|||
|
|
retList[matchPos].CCodeBCodeList.Add(new ColorBarPair { ColorBox = item.ColorBox_BarCode, BarCode = item.Barcode });
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
jsonapi tmpObj = new jsonapi();
|
|||
|
|
tmpObj.OutBoxCode = item.OutBoxCode;
|
|||
|
|
tmpObj.ProjectID = item.ProjectID;
|
|||
|
|
tmpObj.Operator = item.ShippingLoader;
|
|||
|
|
tmpObj.ShippingDateTime = item.ShippingDateTime;
|
|||
|
|
tmpObj.ShippingCode = item.ShippingCode;
|
|||
|
|
tmpObj.Status = true;
|
|||
|
|
tmpObj.ProjectName = item.ProjectName;
|
|||
|
|
tmpObj.CCodeBCodeList = new List<ColorBarPair>();
|
|||
|
|
tmpObj.CCodeBCodeList.Add(new ColorBarPair { ColorBox = item.ColorBox_BarCode, BarCode = item.Barcode });
|
|||
|
|
retList.Add(tmpObj);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
return Json(retList);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据运货单号查询订单编号信息
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="ShippingCode"></param>
|
|||
|
|
/// <param name="token"></param>
|
|||
|
|
/// <param name="Status"></param>
|
|||
|
|
/// <param name="ProjectListID"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
[HttpPost]
|
|||
|
|
public ActionResult GetdingdanbyID(string ShippingCode, string token = "", int Status = 0, int ProjectListID = 0, int sqlid = 0)
|
|||
|
|
{
|
|||
|
|
var result = new ReturnResult<dynamic>();
|
|||
|
|
// 检查Token值是否存在
|
|||
|
|
string aa = TokenHelper.CheckToken(token);
|
|||
|
|
|
|||
|
|
if (aa != null)
|
|||
|
|
{
|
|||
|
|
TBL_UTS_Manage_User aas = JsonConvert.DeserializeObject<TBL_UTS_Manage_User>(aa);
|
|||
|
|
TBL_UTS_Manage_User user = SqlSugarBase.Db.Queryable<TBL_UTS_Manage_User>().First(x => x.UserName == aas.UserName);
|
|||
|
|
if (aas.IsValid == user.IsValid && aas.PlaintextPwd == user.PlaintextPwd)
|
|||
|
|
{
|
|||
|
|
Logs.WriteLog("根据运货单号查询订单编号信息,操作人是:" + aas.UserName);
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
if (sqlid == 7)
|
|||
|
|
{
|
|||
|
|
result = OTApi.GetdingdanbyID1(ShippingCode, Status, ProjectListID);
|
|||
|
|
}
|
|||
|
|
else if (sqlid == 2)
|
|||
|
|
{
|
|||
|
|
result = OTApi.GetdingdanbyID2(ShippingCode, Status, ProjectListID);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (result != null)
|
|||
|
|
{
|
|||
|
|
result.IsAdmin = aas.IsAdmin;
|
|||
|
|
result.Status = 200;
|
|||
|
|
result.Message = "请求成功。。。。";
|
|||
|
|
Logs.WriteLog("查询订单信息" + result.Message);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
Logs.WriteLog("请检查根据运货单号和状态查询订单编号信息的Error:" + ex);
|
|||
|
|
result.Status = 500;
|
|||
|
|
result.Message = "服务器错误";
|
|||
|
|
result.Data = null;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
result.Status = 100;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
Logs.WriteLog("token丢失,需要要重新登录!");
|
|||
|
|
result.Status = 401;
|
|||
|
|
result.Message = "服务器错误";
|
|||
|
|
result.Data = null;
|
|||
|
|
}
|
|||
|
|
return Json(result);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取微信的openid
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="appid">小程序id</param>
|
|||
|
|
/// 如果重新生成了小程序密钥这个密钥需要修改成新的密钥
|
|||
|
|
/// <param name="secret">小程序密钥</param>
|
|||
|
|
/// <param name="js_code">codeid</param>
|
|||
|
|
/// <param name="grant_type">授权类型</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
[HttpPost]
|
|||
|
|
public ActionResult Getgetopenid(string appid = "wx5f9bb9191db4a415", string secret = "ff1a49ee953b87a67ad8b4d3a475b93b", string js_code = "", string grant_type = "authorization_code")
|
|||
|
|
{
|
|||
|
|
string strRlt = "";
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
//创建Get请求
|
|||
|
|
string url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + appid + "&secret=" + secret + "&js_code=" + js_code + "&grant_type=" + grant_type;
|
|||
|
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
|||
|
|
request.Method = "GET";
|
|||
|
|
request.ContentType = "text/html;charset=UTF-8";
|
|||
|
|
|
|||
|
|
//接受返回来的数据
|
|||
|
|
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
|||
|
|
Stream stream = response.GetResponseStream();
|
|||
|
|
StreamReader streamReader = new StreamReader(stream, Encoding.GetEncoding("utf-8"));
|
|||
|
|
//后台发请求返回来的数据
|
|||
|
|
strRlt = streamReader.ReadToEnd();
|
|||
|
|
|
|||
|
|
streamReader.Close();
|
|||
|
|
stream.Close();
|
|||
|
|
response.Close();
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
Logs.WriteLog("获取openid的Error:" + ex);
|
|||
|
|
}
|
|||
|
|
return Json(strRlt);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取外箱码信息
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="goodid">外箱码</param>
|
|||
|
|
/// <param name="token">token值</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
[HttpPost]
|
|||
|
|
public ActionResult GetBoxnumber(string goodid = "", string token = "", string dingdan = "")
|
|||
|
|
{
|
|||
|
|
var result = new ReturnResult<dynamic>();
|
|||
|
|
// 检查Token值是否存在
|
|||
|
|
string aa = TokenHelper.CheckToken(token);
|
|||
|
|
if (aa != null)
|
|||
|
|
{
|
|||
|
|
TBL_UTS_Manage_User aas = JsonConvert.DeserializeObject<TBL_UTS_Manage_User>(aa);
|
|||
|
|
TBL_UTS_Manage_User user = SqlSugarBase.Db.Queryable<TBL_UTS_Manage_User>().First(x => x.UserName == aas.UserName);
|
|||
|
|
if (aas.IsValid == user.IsValid && aas.PlaintextPwd == user.PlaintextPwd)
|
|||
|
|
{
|
|||
|
|
Logs.WriteLog("查询外箱码信息,操作人是:" + aas.UserName);
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
result = OTApi.WxBoxnumber(goodid, dingdan);
|
|||
|
|
if (result != null && result.Status == 200)
|
|||
|
|
{
|
|||
|
|
result.Status = 200;
|
|||
|
|
result.Message = "请求成功。。。。";
|
|||
|
|
}
|
|||
|
|
else if (result.Status == 400)
|
|||
|
|
{
|
|||
|
|
result.Status = 400;
|
|||
|
|
result.Message = "数量已经预订单匹配上了,可以休息一下";
|
|||
|
|
}
|
|||
|
|
else if (result.Status == 300)
|
|||
|
|
{
|
|||
|
|
result.Status = 300;
|
|||
|
|
result.Message = "您扫的码没有匹配到相应的数据请重新扫码";
|
|||
|
|
result.nums = 0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
Logs.WriteLog("请检查查询外箱码信息的Error:" + ex);
|
|||
|
|
result.Status = 500;
|
|||
|
|
result.Message = "服务器错误";
|
|||
|
|
result.Data = null;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
result.Status = 100;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
Logs.WriteLog("token丢失,需要要重新登录!");
|
|||
|
|
result.Status = 401;
|
|||
|
|
result.Message = "服务器错误";
|
|||
|
|
result.Data = null;
|
|||
|
|
}
|
|||
|
|
return Json(result);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据彩合信息查询物品经过了多少站
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="CHID">彩盒ID</param>
|
|||
|
|
/// <param name="token"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
[HttpPost]
|
|||
|
|
public ActionResult CHBYT(string CHID = "", string token = "")
|
|||
|
|
{
|
|||
|
|
var result = new ReturnResult<dynamic>();
|
|||
|
|
// 检查Token值是否存在
|
|||
|
|
string aa = TokenHelper.CheckToken(token);
|
|||
|
|
if (aa != null)
|
|||
|
|
{
|
|||
|
|
TBL_UTS_Manage_User aas = JsonConvert.DeserializeObject<TBL_UTS_Manage_User>(aa);
|
|||
|
|
Logs.WriteLog("查询彩盒码信息,操作人是:" + aas.UserName);
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
result = OTApi.CHBYTs(CHID);
|
|||
|
|
if (result != null)
|
|||
|
|
{
|
|||
|
|
result.Status = 200;
|
|||
|
|
result.Message = "请求成功。。。。";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
Logs.WriteLog("请检查查询彩盒码信息的Error:" + ex);
|
|||
|
|
result.Status = 500;
|
|||
|
|
result.Message = "服务器错误";
|
|||
|
|
result.Data = null;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
Logs.WriteLog("token丢失,需要要重新登录!");
|
|||
|
|
result.Status = 401;
|
|||
|
|
result.Message = "服务器错误";
|
|||
|
|
result.Data = null;
|
|||
|
|
}
|
|||
|
|
return Json(result);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据订单号码查询订单信息
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="ShippingCode"></param>
|
|||
|
|
/// <param name="token"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
[HttpPost]
|
|||
|
|
public ActionResult QrderInformation(string ShippingCode = "", string token = "", int sqlid = 0)
|
|||
|
|
{
|
|||
|
|
var result = new ReturnResult<dynamic>();
|
|||
|
|
|
|||
|
|
// 检查Token值是否存在
|
|||
|
|
string aa = TokenHelper.CheckToken(token);
|
|||
|
|
if (aa != null)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
TBL_UTS_Manage_User aas = JsonConvert.DeserializeObject<TBL_UTS_Manage_User>(aa);
|
|||
|
|
Logs.WriteLog("页面数据更新,操作人是:" + aas.UserName);
|
|||
|
|
if (sqlid == 7)
|
|||
|
|
{
|
|||
|
|
result = OTApi.GetQrderInformationByShippingCode(ShippingCode);
|
|||
|
|
}
|
|||
|
|
else if (sqlid == 2)
|
|||
|
|
{
|
|||
|
|
result = OTApi.GetQrderInformationByShippingCode1(ShippingCode);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
result.Status = 401;
|
|||
|
|
result.Message = "页面数据更新失败";
|
|||
|
|
Logs.WriteLog("页面数据更新,操作人是:" + ex);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
Logs.WriteLog("token丢失,需要要重新登录!");
|
|||
|
|
result.Status = 401;
|
|||
|
|
result.Message = "服务器错误";
|
|||
|
|
result.Data = null;
|
|||
|
|
}
|
|||
|
|
return Json(result);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 绑定
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="ShippingCode"></param>
|
|||
|
|
/// <param name="outid"></param>
|
|||
|
|
/// <param name="token"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
[HttpPost]
|
|||
|
|
public ActionResult AddAdds(string ShippingCode = "", string outid = "", string token = "", int sqlid = 0)
|
|||
|
|
{
|
|||
|
|
string aa = TokenHelper.CheckToken(token);
|
|||
|
|
jsonapi result = new jsonapi();
|
|||
|
|
if (aa != null)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
TBL_UTS_Manage_User aas = JsonConvert.DeserializeObject<TBL_UTS_Manage_User>(aa);
|
|||
|
|
Logs.WriteLog("绑定,操作人是:" + aas.UserName);
|
|||
|
|
if (sqlid == 7)
|
|||
|
|
{
|
|||
|
|
result = OTApi.Add2(ShippingCode, outid, aas.UserName);
|
|||
|
|
}
|
|||
|
|
else if (sqlid == 2)
|
|||
|
|
{
|
|||
|
|
result = OTApi.Add3(ShippingCode, outid, aas.UserName);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
result.Message = "绑定失败";
|
|||
|
|
Logs.WriteLog("绑定,操作人是:" + ex);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
Logs.WriteLog("token丢失,需要要重新登录!");
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
return Json(result);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 外箱码和订单解绑
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="ShippingCode">订单编号</param>
|
|||
|
|
/// <param name="OutBoxCodeList">外箱信息</param>
|
|||
|
|
/// <param name="token"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
[HttpPost]
|
|||
|
|
public ActionResult EditEdit(string ShippingCode = "", string OutBoxCodeList = null, string token = "", int sqlid = 0)
|
|||
|
|
{
|
|||
|
|
jsonapi retList = new jsonapi();
|
|||
|
|
// 检查Token值是否存在
|
|||
|
|
string aa = TokenHelper.CheckToken(token);
|
|||
|
|
if (aa != null)
|
|||
|
|
{
|
|||
|
|
TBL_UTS_Manage_User aas = JsonConvert.DeserializeObject<TBL_UTS_Manage_User>(aa);
|
|||
|
|
Logs.WriteLog("外箱码和订单解绑,操作人是:" + aas.UserName);
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
if (sqlid == 7)
|
|||
|
|
{
|
|||
|
|
retList = OTApi.Edit(ShippingCode, OutBoxCodeList, aas.UserName);
|
|||
|
|
}
|
|||
|
|
else if (sqlid == 2)
|
|||
|
|
{
|
|||
|
|
retList = OTApi.Edit1(ShippingCode, OutBoxCodeList, aas.UserName);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
retList.Message = "外箱码和订单解绑失败";
|
|||
|
|
Logs.WriteLog("外箱码和订单解绑:" + ex);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
retList.Message = "token丢失,需要要重新登录!";
|
|||
|
|
Logs.WriteLog("token丢失,需要要重新登录!");
|
|||
|
|
}
|
|||
|
|
return Json(retList);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 查询彩盒信息
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="outCode">外箱码</param>
|
|||
|
|
/// <param name="token"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
[HttpPost]
|
|||
|
|
public ActionResult GetoutIDbyID(string outCode = "", string token = "")
|
|||
|
|
{
|
|||
|
|
var result = new ReturnResult<dynamic>();
|
|||
|
|
// 检查Token值是否存在
|
|||
|
|
string aa = TokenHelper.CheckToken(token);
|
|||
|
|
TBL_UTS_Manage_User aas = JsonConvert.DeserializeObject<TBL_UTS_Manage_User>(TokenHelper.CheckToken(token));
|
|||
|
|
if (aa != null)
|
|||
|
|
{
|
|||
|
|
TBL_UTS_Manage_User user = SqlSugarBase.Db.Queryable<TBL_UTS_Manage_User>().First(x => x.UserName == aas.UserName);
|
|||
|
|
if (aas.IsValid == user.IsValid && aas.PlaintextPwd == user.PlaintextPwd)
|
|||
|
|
{
|
|||
|
|
Logs.WriteLog("查询彩盒信息,操作人是:" + aas.UserName);
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
result = OTApi.GetoutIDbyIDs(outCode);
|
|||
|
|
if (result != null && result.Status == 200)
|
|||
|
|
{
|
|||
|
|
result.Status = 200;
|
|||
|
|
result.Message = "请求成功。。。。";
|
|||
|
|
}
|
|||
|
|
else if (result.Status == 400)
|
|||
|
|
{
|
|||
|
|
result.Status = 400;
|
|||
|
|
result.Message = "数据不完整,请扫码后点击添加";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
Logs.WriteLog("外箱码和订单解绑:" + ex);
|
|||
|
|
result.Status = 500;
|
|||
|
|
result.Message = "服务器错误";
|
|||
|
|
result.Data = null;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
result.Status = 100;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
Logs.WriteLog("token丢失,需要要重新登录!");
|
|||
|
|
result.Status = 401;
|
|||
|
|
result.Message = "服务器错误";
|
|||
|
|
result.Data = null;
|
|||
|
|
}
|
|||
|
|
return Json(result);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 将用户的openid写入数据库
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="Uid">用户名称</param>
|
|||
|
|
/// <param name="openid">用户的openid</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
[HttpPost]
|
|||
|
|
public ActionResult AddTelAndopenId(string Uid = "", string openid = "")
|
|||
|
|
{
|
|||
|
|
var result = new ReturnResult<dynamic>();
|
|||
|
|
Logs.WriteLog("将用户的openid写入数据库");
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
result = OTApi.AddTelAndopenId(Uid, openid);
|
|||
|
|
if (result != null && result.Status == 200)
|
|||
|
|
{
|
|||
|
|
result.Status = 200;
|
|||
|
|
result.Message = "请求成功。。。。";
|
|||
|
|
}
|
|||
|
|
else if (result.Status == 400)
|
|||
|
|
{
|
|||
|
|
result.Status = 400;
|
|||
|
|
result.Message = "你的微信号码已经绑定了,请换一个微信来注册";
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
result.Status = 300;
|
|||
|
|
result.Message = "这个账号被绑定了";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
Logs.WriteLog("数据库写入用户的openID的Error:" + ex);
|
|||
|
|
result.Status = 500;
|
|||
|
|
result.Message = "服务器错误";
|
|||
|
|
result.Data = null;
|
|||
|
|
}
|
|||
|
|
return Json(result);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 结单
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="ShippingCode">订单号</param>
|
|||
|
|
/// <param name="token"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
[HttpPost]
|
|||
|
|
public ActionResult SettleTheBill(string ShippingCode = "", string token = "", int sqlid = 0)
|
|||
|
|
{
|
|||
|
|
var result = new ReturnResult<dynamic>();
|
|||
|
|
// 检查Token值是否存在
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string aa = TokenHelper.CheckToken(token);
|
|||
|
|
if (aa != null)
|
|||
|
|
{
|
|||
|
|
TBL_UTS_Manage_User aas = JsonConvert.DeserializeObject<TBL_UTS_Manage_User>(aa);
|
|||
|
|
TBL_UTS_Manage_User user = SqlSugarBase.Db.Queryable<TBL_UTS_Manage_User>().First(x => x.UserName == aas.UserName);
|
|||
|
|
if (aas.IsValid == user.IsValid && aas.PlaintextPwd == user.PlaintextPwd)
|
|||
|
|
{
|
|||
|
|
Logs.WriteLog("结单,操作人是:" + aas.UserName);
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
if (sqlid == 7)
|
|||
|
|
{
|
|||
|
|
result = OTApi.SettleTheBills(ShippingCode, aas.UserName);
|
|||
|
|
}
|
|||
|
|
else if (sqlid == 2)
|
|||
|
|
{
|
|||
|
|
result = OTApi.SettleTheBills1(ShippingCode, aas.UserName);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (result.Status == 200)
|
|||
|
|
{
|
|||
|
|
result.Status = 200;
|
|||
|
|
result.Message = "请求成功。。。。";
|
|||
|
|
Logs.WriteLog("结单" + result.Message);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
result.Status = 212;
|
|||
|
|
Logs.WriteLog("结单" + result.Message);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
Logs.WriteLog("结单Error:" + ex);
|
|||
|
|
result.Status = 500;
|
|||
|
|
result.Message = "服务器错误";
|
|||
|
|
result.Data = null;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
result.Status = 100;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
Logs.WriteLog("token丢失,需要要重新登录!");
|
|||
|
|
result.Status = 401;
|
|||
|
|
result.Message = "服务器错误";
|
|||
|
|
result.Data = null;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
Logs.WriteLog("结单Error:" + ex);
|
|||
|
|
result.Status = 500;
|
|||
|
|
result.Message = "服务器错误";
|
|||
|
|
result.Data = null;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return Json(result);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 查看日志
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="token"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
[HttpPost]
|
|||
|
|
public ActionResult ShowLog(string starttime, string endtime, string ShippingCode = "", string Outcode = "", int czuo = 3, int jixing = 0, string token = "", int sqlid = 0)
|
|||
|
|
{
|
|||
|
|
var result = new ReturnResult<dynamic>();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string aa = TokenHelper.CheckToken(token);
|
|||
|
|
|
|||
|
|
if (aa != null)
|
|||
|
|
{
|
|||
|
|
TBL_UTS_Manage_User aas = JsonConvert.DeserializeObject<TBL_UTS_Manage_User>(aa);
|
|||
|
|
if (sqlid == 7)
|
|||
|
|
{
|
|||
|
|
result = OTApi.Viewlog(starttime, endtime, ShippingCode, Outcode, czuo, jixing);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
result = OTApi.Viewlog1(starttime, endtime, ShippingCode, Outcode, czuo, jixing);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
Logs.WriteLog("token丢失,需要要重新登录!");
|
|||
|
|
result.Status = 401;
|
|||
|
|
result.Message = "服务器错误";
|
|||
|
|
result.Data = null;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
throw;
|
|||
|
|
}
|
|||
|
|
// 检查Token值是否存在
|
|||
|
|
|
|||
|
|
return Json(result);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 添加方法
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="filePath"></param>
|
|||
|
|
/// <param name="name"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public ActionResult Addimgage(string filePath, string name)
|
|||
|
|
{
|
|||
|
|
var result = new ReturnResult<dynamic>();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
if (!string.IsNullOrEmpty(filePath))
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
LogHelp.WriteExceptionLog(ex);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return Json(result);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 已结单后有权限的人修改状态
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="ShippingCodes"></param>
|
|||
|
|
/// <param name="token"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public ActionResult Eentstatus(string ShippingCodes, string token, int sqlid = 0)
|
|||
|
|
{
|
|||
|
|
var result = new ReturnResult<dynamic>();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string aa = TokenHelper.CheckToken(token);
|
|||
|
|
if (aa != null)
|
|||
|
|
{
|
|||
|
|
TBL_UTS_Manage_User aas = JsonConvert.DeserializeObject<TBL_UTS_Manage_User>(aa);
|
|||
|
|
TBL_UTS_Manage_User user = SqlSugarBase.Db.Queryable<TBL_UTS_Manage_User>().First(x => x.UserName == aas.UserName);
|
|||
|
|
if (aas.IsValid == user.IsValid && aas.PlaintextPwd == user.PlaintextPwd)
|
|||
|
|
{
|
|||
|
|
Logs.WriteLog("已结单后有权限的人修改状态,操作人是:" + aas.UserName);
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
if (sqlid == 7)
|
|||
|
|
{
|
|||
|
|
result = OTApi.Eentstatus(ShippingCodes, aas.UserName);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
result = OTApi.Eentstatus1(ShippingCodes, aas.UserName);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (result.Status == 200)
|
|||
|
|
{
|
|||
|
|
result.Status = 200;
|
|||
|
|
result.Message = "请求成功。。。。";
|
|||
|
|
Logs.WriteLog("已结单后有权限的人修改状态" + result.Message);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
Logs.WriteLog("已结单后有权限的人修改状态:" + ex);
|
|||
|
|
result.Status = 500;
|
|||
|
|
result.Message = "服务器错误";
|
|||
|
|
result.Data = null;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
result.Message = "你的账号没有激活";
|
|||
|
|
result.Status = 100;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
Logs.WriteLog("token丢失,需要要重新登录!");
|
|||
|
|
result.Status = 401;
|
|||
|
|
result.Message = "服务器错误";
|
|||
|
|
result.Data = null;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
Logs.WriteLog("结单Error:" + ex);
|
|||
|
|
result.Status = 500;
|
|||
|
|
result.Message = "服务器错误";
|
|||
|
|
result.Data = null;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return Json(result);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 搜索权限
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="Uid"></param>
|
|||
|
|
/// <param name="token"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
[HttpPost]
|
|||
|
|
public ActionResult Shuruusernamebyquanxian(string Uid)
|
|||
|
|
{
|
|||
|
|
TBL_UTS_Manage_User unameid = SqlSugarBase.Db.Queryable<TBL_UTS_Manage_User>().First(x => x.UserName == Uid);
|
|||
|
|
if (unameid==null)
|
|||
|
|
{
|
|||
|
|
return Json("on");
|
|||
|
|
}
|
|||
|
|
List<TBL_UTS_Manage_UserAuth_Operation> qx = SqlSugarBase.Db.Queryable<TBL_UTS_Manage_UserAuth_Operation>().GroupBy(x=>x.DatabaseID).Where(x => x.UserID == unameid.ID && (x.DatabaseName== "uts_ZongQing" ||x.DatabaseName== "uts_johao")).ToList();
|
|||
|
|
List<ProbjectType> asg = new List<ProbjectType>();
|
|||
|
|
foreach (var item in qx)
|
|||
|
|
{
|
|||
|
|
ProbjectType tBL_Project = new ProbjectType();
|
|||
|
|
tBL_Project.text = item.DatabaseName;
|
|||
|
|
tBL_Project.value = item.DatabaseID;
|
|||
|
|
asg.Add(tBL_Project);
|
|||
|
|
}
|
|||
|
|
return Json(asg);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|