| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714 |
- /*
- * 机具申请订单
- */
- using System;
- using System.Web;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- using System.Data;
- using System.Threading.Tasks;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.AspNetCore.Http;
- using Microsoft.Extensions.Logging;
- using Microsoft.Extensions.Options;
- using MySystem.Models;
- using Library;
- using LitJson;
- using MySystemLib;
- namespace MySystem.Areas.Admin.Controllers
- {
- [Area("Admin")]
- [Route("Admin/[controller]/[action]")]
- public class MachineApplyController : BaseController
- {
- public MachineApplyController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
- {
- OtherMySqlConn.connstr = ConfigurationManager.AppSettings["SqlConnStr"].ToString();
- }
- #region 机具申请订单列表
- /// <summary>
- /// 根据条件查询机具申请订单列表
- /// </summary>
- /// <returns></returns>
- public IActionResult Index(MachineApply data, string right)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- return View();
- }
- #endregion
- #region 根据条件查询机具申请订单列表
- /// <summary>
- /// 机具申请订单列表
- /// </summary>
- /// <returns></returns>
- public JsonResult IndexData(MachineApply data, string MakerCode, string RealName, string StoreNo, string StoreName, string StoreMakerCode, string StatusSelect, string SendStatusSelect, string StoreTypeSelect, int page = 1, int limit = 30)
- {
- Dictionary<string, string> Fields = new Dictionary<string, string>();
- Fields.Add("ApplyNo", "1"); //申请单号
- Fields.Add("BrandId", "1"); //品牌
- Fields.Add("ApplyTime", "3"); //申请时间
- Fields.Add("ExpressNo", "1"); //快递单号
- Fields.Add("DeliveryType", "0"); //提货类型
- Fields.Add("StoreManager", "1"); //仓库联系人
- Fields.Add("SendDate", "3"); //发货时间
- Fields.Add("TopUserId", "0"); //顶级创客
- Fields.Add("SwapSnExpand", "1"); //兑换SN
- Fields.Add("SendSn", "1"); //发货SN
- string condition = " and Status>-1";
- //创客编号
- if (!string.IsNullOrEmpty(MakerCode))
- {
- condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + MakerCode + "')";
- }
- //创客名称
- if (!string.IsNullOrEmpty(RealName))
- {
- condition += " and UserId in (select UserId from UserForRealName where RealName='" + RealName + "')";
- }
- //仓库编号
- if (!string.IsNullOrEmpty(StoreNo))
- {
- condition += " and StoreId in (select StoreId from StoreForCode where Code='" + StoreNo + "')";
- }
- //仓库名称
- if (!string.IsNullOrEmpty(StoreName))
- {
- condition += " and StoreId in (select StoreId from StoreForName where Name='" + StoreName + "')";
- }
- //仓库归属创客编号
- if (!string.IsNullOrEmpty(StoreMakerCode))
- {
- condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + StoreMakerCode + "')";
- }
- //订单状态
- if(!string.IsNullOrEmpty(StatusSelect))
- {
- condition += " and Status=" + StatusSelect;
- }
- //发货状态
- if(!string.IsNullOrEmpty(SendStatusSelect))
- {
- condition += " and SendStatus=" + SendStatusSelect;
- }
- //仓库类型
- if(!string.IsNullOrEmpty(StoreTypeSelect))
- {
- condition += " and StoreType=" + StoreTypeSelect;
- }
- Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("MachineApply", Fields, "Id desc", "0", page, limit, condition);
- List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
- foreach (Dictionary<string, object> dic in diclist)
- {
- dic["BrandId"] = RelationClass.GetKqProductBrandInfo(int.Parse(dic["BrandId"].ToString()));
- //发货仓库
- int StoreId = int.Parse(dic["StoreId"].ToString());
- StoreHouse store = db.StoreHouse.FirstOrDefault(m => m.Id == StoreId) ?? new StoreHouse();
- dic["StoreInfo"] = store.StoreNo + "<br />" + store.StoreName;
- //仓库联系人信息
- dic["StoreContact"] = dic["StoreManagerMobile"].ToString() + "<br />" + dic["StoreManager"].ToString();
- //仓库归属信息
- int StoreUserId = int.Parse(dic["StoreUserId"].ToString());
- Users storeUser = db.Users.FirstOrDefault(m => m.Id == StoreUserId) ?? new Users();
- int StoreType = int.Parse(dic["StoreType"].ToString());
- string StoreTypeName = "";
- if(StoreType == 0) StoreTypeName = "总仓";
- if(StoreType == 1) StoreTypeName = "分仓";
- dic["StoreUser"] = storeUser.MakerCode + "<br />" + StoreTypeName;
- //创客信息
- int UserId = int.Parse(dic["UserId"].ToString());
- Users puser = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
- dic["UserInfo"] = puser.MakerCode + "<br />" + puser.RealName;
- //顶级创客
- int TopUserId = int.Parse(dic["TopUserId"].ToString());
- Users tuser = db.Users.FirstOrDefault(m => m.Id == TopUserId) ?? new Users();
- dic["TopUserInfo"] = tuser.MakerCode + "<br />" + tuser.RealName;
-
- //收件人姓名-联系电话
- dic["StoreContact"] = dic["RealName"].ToString() + "<br />" + dic["Mobile"].ToString();
- //订单状态
- int Status = int.Parse(dic["Status"].ToString());
- if(Status == 0) dic["Status"] = "待审核";
- if(Status == 1) dic["Status"] = "申请成功";
- if(Status == 2) dic["Status"] = "申请失败";
- //提货方式
- int DeliveryType = int.Parse(dic["DeliveryType"].ToString());
- if(DeliveryType == 0) dic["DeliveryType"] = "";
- if(DeliveryType == 1) dic["DeliveryType"] = "邮寄到付";
- if(DeliveryType == 2) dic["DeliveryType"] = "上门自提";
- //发货状态
- int SendStatus = int.Parse(dic["SendStatus"].ToString());
- if(SendStatus == 0) dic["SendStatus"] = "未发货";
- if(SendStatus == 1) dic["SendStatus"] = "已发货";
-
- //快递单号-快递名称
- dic["ExpressInfo"] = dic["ExpressName"].ToString() + "<br />" + dic["ExpressNo"].ToString();
- }
- Dictionary<string, object> other = new Dictionary<string, object>();
- int ApplyCount = 0;//申请机具数
- int SendCount = 0;//发货机具数
- DataTable dt = OtherMySqlConn.dtable("select sum(ApplyDeviceNum) from MachineApply where SendStatus=0" + condition);
- if (dt.Rows.Count > 0)
- {
- ApplyCount = int.Parse(function.CheckNum(dt.Rows[0][0].ToString()));
- }
- dt = OtherMySqlConn.dtable("select sum(ApplyDeviceNum) from MachineApply where SendStatus=1" + condition);
- if (dt.Rows.Count > 0)
- {
- SendCount = int.Parse(function.CheckNum(dt.Rows[0][0].ToString()));
- }
- other.Add("ApplyCount", ApplyCount);
- other.Add("SendCount", SendCount);
- obj.Add("other", other);
- return Json(obj);
- }
- #endregion
- #region 增加机具申请订单
- /// <summary>
- /// 增加或修改机具申请订单信息
- /// </summary>
- /// <returns></returns>
- public IActionResult Add(string right)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- return View();
- }
- #endregion
- #region 增加机具申请订单
- /// <summary>
- /// 增加或修改机具申请订单信息
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public string Add(MachineApply data)
- {
- Dictionary<string, object> Fields = new Dictionary<string, object>();
- Fields.Add("SeoTitle", data.SeoTitle);
- Fields.Add("SeoKeyword", data.SeoKeyword);
- Fields.Add("SeoDescription", data.SeoDescription);
- int Id = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Add("MachineApply", Fields, 0);
- AddSysLog(data.Id.ToString(), "MachineApply", "add");
- db.SaveChanges();
- return "success";
- }
- #endregion
- #region 修改机具申请订单
- /// <summary>
- /// 增加或修改机具申请订单信息
- /// </summary>
- /// <returns></returns>
- public IActionResult Edit(string right, int Id = 0)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- MachineApply editData = db.MachineApply.FirstOrDefault(m => m.Id == Id) ?? new MachineApply();
- ViewBag.data = editData;
- Users user = db.Users.FirstOrDefault(m => m.Id == editData.UserId) ?? new Users();
- ViewBag.MakerCode = user.MakerCode;
- ViewBag.RealName = user.RealName;
- int Status = editData.Status;
- if(Status == 0) ViewBag.Status = "待审核";
- if(Status == 1) ViewBag.Status = "申请成功";
- if(Status == 2) ViewBag.Status = "申请失败";
- int AuditResult = editData.AuditResult;
- if(AuditResult == 0) ViewBag.AuditResult = "未通过";
- if(AuditResult == 1) ViewBag.AuditResult = "通过";
- //邮寄方式
- int DeliveryType = editData.DeliveryType;
- if(DeliveryType == 1) ViewBag.DeliveryType = "邮寄到付";
- if(DeliveryType == 2) ViewBag.DeliveryType = "上门自提";
- //发货状态
- int SendStatus = editData.SendStatus;
- if(SendStatus == 0) ViewBag.SendStatus = "未发货";
- if(SendStatus == 1) ViewBag.SendStatus = "已发货";
- return View();
- }
- #endregion
- #region 修改机具申请订单
- /// <summary>
- /// 增加或修改机具申请订单信息
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public string Edit(MachineApply data)
- {
- Dictionary<string, object> Fields = new Dictionary<string, object>();
- Fields.Add("SeoTitle", data.SeoTitle);
- Fields.Add("SeoKeyword", data.SeoKeyword);
- Fields.Add("SeoDescription", data.SeoDescription);
- new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("MachineApply", Fields, data.Id);
- AddSysLog(data.Id.ToString(), "MachineApply", "update");
- db.SaveChanges();
- return "success";
- }
- #endregion
- #region 删除机具申请订单信息
- /// <summary>
- /// 删除机具申请订单信息
- /// </summary>
- /// <returns></returns>
- public string Delete(string Id)
- {
- string[] idlist = Id.Split(new char[] { ',' });
- AddSysLog(Id, "MachineApply", "del");
- foreach (string subid in idlist)
- {
- int id = int.Parse(subid);
- Dictionary<string, object> Fields = new Dictionary<string, object>();
- Fields.Add("Status", -1);
- new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("MachineApply", Fields, id);
- }
- db.SaveChanges();
- return "success";
- }
- #endregion
-
- #region 取消机具申请订单
- /// <summary>
- /// 取消机具申请订单
- /// </summary>
- /// <returns></returns>
- public string Cancel(int Id)
- {
- AddSysLog(Id, "MachineApply", "cancel");
- MachineApply apply = db.MachineApply.FirstOrDefault(m => m.Id == Id);
- if (apply != null)
- {
- Orders order = db.Orders.FirstOrDefault(m => m.Id == apply.QueryCount);
- if (order != null)
- {
- string SwapSnExpand = apply.SwapSnExpand;
- if (!string.IsNullOrEmpty(SwapSnExpand))
- {
- string[] list = SwapSnExpand.TrimEnd('\n').Split('\n');
- if (apply.Sort > 0)
- {
- int Kind = apply.Sort - 1;
- string ChangeRecordNo = "SC" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8);
- int CouponCount = 0;
- foreach (string sub in list)
- {
- PosCoupons coupon = db.PosCoupons.FirstOrDefault(m => m.ExchangeCode == sub && m.UserId == order.UserId && m.IsUse == 1);
- if (coupon != null)
- {
- coupon.IsUse = 0;
- coupon.IsLock = 0;
- coupon.UseDate = DateTime.Parse("1900-01-01");
- PosCouponRecord query = db.PosCouponRecord.Add(new PosCouponRecord()
- {
- QueryCount = Kind,
- CreateDate = DateTime.Now,
- ChangeKind = 1,
- OrderNo = ChangeRecordNo,
- ToUserId = order.UserId,
- FromUserId = order.UserId,
- PosCouponId = coupon.Id,
- }).Entity;
- CouponCount += 1;
- }
- }
- if (CouponCount > 0)
- {
- PosCouponForUser forUser = db.PosCouponForUser.FirstOrDefault(m => m.Id == order.UserId);
- if (forUser == null)
- {
- forUser = db.PosCouponForUser.Add(new PosCouponForUser()
- {
- Id = order.UserId,
- }).Entity;
- db.SaveChanges();
- }
- int BeforeOut = forUser.OutNum;
- int BeforeTotal = forUser.TotalNum;
- int BeforeStock = forUser.StockNum;
- forUser.StockNum += CouponCount;
- int AfterOut = forUser.OutNum;
- int AfterTotal = forUser.TotalNum;
- int AfterStock = forUser.StockNum;
- PosCouponOrders stat = db.PosCouponOrders.Add(new PosCouponOrders()
- {
- QueryCount = Kind,
- CreateDate = DateTime.Now,
- ChangeKind = 1,
- ChangeCount = CouponCount,
- AfterOut = AfterOut,
- AfterTotal = AfterTotal,
- AfterStock = AfterStock,
- BeforeOut = BeforeOut,
- BeforeTotal = BeforeTotal,
- BeforeStock = BeforeStock,
- OrderNo = ChangeRecordNo,
- ToUserId = order.UserId,
- FromUserId = order.UserId,
- }).Entity;
- }
- function.WriteLog(Newtonsoft.Json.JsonConvert.SerializeObject(apply) + "#cut#" + Newtonsoft.Json.JsonConvert.SerializeObject(order) + "#cut#" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "机具申请订单取消日志");
- db.MachineApply.Remove(apply);
- db.Orders.Remove(order);
- db.SaveChanges();
- }
- else
- {
- foreach (string sub in list)
- {
- string SourcePosSn = sub.Split(':')[0];
- MachineForSnNo forSnNo = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == SourcePosSn) ?? new MachineForSnNo();
- PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == forSnNo.SnId);
- if (pos != null)
- {
- function.WriteLog(Newtonsoft.Json.JsonConvert.SerializeObject(apply) + "#cut#" + Newtonsoft.Json.JsonConvert.SerializeObject(order) + "#cut#" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "机具申请订单取消日志");
- pos.IsPurchase = 0;
- RedisDbconn.Instance.Clear("PosMachinesTwo:" + pos.Id);
- }
- }
- db.MachineApply.Remove(apply);
- db.Orders.Remove(order);
- db.SaveChanges();
- }
- }
- }
- }
- return "success";
- }
- #endregion
- #region 开启
- /// <summary>
- /// 开启
- /// </summary>
- /// <returns></returns>
- public string Open(string Id)
- {
- string[] idlist = Id.Split(new char[] { ',' });
- AddSysLog(Id, "MachineApply", "open");
- foreach (string subid in idlist)
- {
- int id = int.Parse(subid);
- Dictionary<string, object> Fields = new Dictionary<string, object>();
- Fields.Add("Status", 1);
- new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("MachineApply", Fields, id);
- }
- db.SaveChanges();
- return "success";
- }
- #endregion
- #region 关闭
- /// <summary>
- /// 关闭
- /// </summary>
- /// <returns></returns>
- public string Close(string Id)
- {
- string[] idlist = Id.Split(new char[] { ',' });
- AddSysLog(Id, "MachineApply", "close");
- foreach (string subid in idlist)
- {
- int id = int.Parse(subid);
- Dictionary<string, object> Fields = new Dictionary<string, object>();
- Fields.Add("Status", 0);
- new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("MachineApply", Fields, id);
- }
- db.SaveChanges();
- return "success";
- }
- #endregion
- #region 排序
- /// <summary>
- /// 排序
- /// </summary>
- /// <param name="Id"></param>
- public string Sort(int Id, int Sort)
- {
- new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Sort("MachineApply", Sort, Id);
- AddSysLog(Id.ToString(), "MachineApply", "sort");
- return "success";
- }
- #endregion
- #region 导入数据
- /// <summary>
- /// 导入数据
- /// </summary>
- /// <param name="ExcelData"></param>
- public string Import(string ExcelData)
- {
- ExcelData = HttpUtility.UrlDecode(ExcelData);
- JsonData list = JsonMapper.ToObject(ExcelData);
- for (int i = 1; i < list.Count; i++)
- {
- JsonData dr = list[i];
- db.MachineApply.Add(new MachineApply()
- {
- CreateDate = DateTime.Now,
- UpdateDate = DateTime.Now,
- });
- db.SaveChanges();
- }
- AddSysLog("0", "MachineApply", "Import");
- return "success";
- }
- #endregion
- #region 导出Excel
- /// <summary>
- /// 导出Excel
- /// </summary>
- /// <returns></returns>
- public JsonResult ExportExcel(MachineApply data, string MakerCode, string RealName, string StoreNo, string StoreName, string StoreMakerCode, string StatusSelect, string SendStatusSelect, string StoreTypeSelect)
- {
- Dictionary<string, string> Fields = new Dictionary<string, string>();
- Fields.Add("ApplyNo", "1"); //申请单号
- Fields.Add("BrandId", "1"); //品牌
- Fields.Add("ApplyTime", "3"); //申请时间
- Fields.Add("ExpressNo", "1"); //快递单号
- Fields.Add("DeliveryType", "0"); //提货类型
- Fields.Add("StoreManager", "1"); //仓库联系人
- Fields.Add("SendDate", "3"); //发货时间
- Fields.Add("TopUserId", "0"); //顶级创客
- Fields.Add("SwapSnExpand", "1"); //兑换SN
- Fields.Add("SendSn", "1"); //发货SN
- string condition = " and Status>-1";
- //创客编号
- if (!string.IsNullOrEmpty(MakerCode))
- {
- condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + MakerCode + "')";
- }
- //创客名称
- if (!string.IsNullOrEmpty(RealName))
- {
- condition += " and UserId in (select UserId from UserForRealName where RealName='" + RealName + "')";
- }
- //仓库编号
- if (!string.IsNullOrEmpty(StoreNo))
- {
- condition += " and StoreId in (select StoreId from StoreForCode where Code='" + StoreNo + "')";
- }
- //仓库名称
- if (!string.IsNullOrEmpty(RealName))
- {
- condition += " and StoreId in (select StoreId from StoreForName where Name='" + RealName + "')";
- }
- //仓库归属创客编号
- if (!string.IsNullOrEmpty(StoreMakerCode))
- {
- condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + StoreMakerCode + "')";
- }
- //订单状态
- if(!string.IsNullOrEmpty(StatusSelect))
- {
- condition += " and Status=" + StatusSelect;
- }
- //发货状态
- if(!string.IsNullOrEmpty(SendStatusSelect))
- {
- condition += " and SendStatus=" + SendStatusSelect;
- }
- //仓库类型
- if(!string.IsNullOrEmpty(StoreTypeSelect))
- {
- condition += " and StoreType=" + StoreTypeSelect;
- }
- Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("MachineApply", Fields, "Id desc", "0", 1, 20000, condition, "ApplyNo,UserId,TopUserId,BrandId,Areas,Address,RealName,Mobile,ApplyDeviceName,ApplyDeviceNum,ApplyTime,SendStatus,ExpressNo,ExpressName,DeliveryType,StoreId,StoreName,StoreManager,StoreManagerMobile,Remark,StoreUserId,SendDate,StoreType,Status", false);
- List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
- foreach (Dictionary<string, object> dic in diclist)
- {
- dic["BrandId"] = RelationClass.GetKqProductBrandInfo(int.Parse(dic["BrandId"].ToString()));
- //发货仓库
- int StoreId = int.Parse(dic["StoreId"].ToString());
- StoreHouse store = db.StoreHouse.FirstOrDefault(m => m.Id == StoreId) ?? new StoreHouse();
- dic["StoreNo"] = store.StoreNo;
- dic["StoreName"] = store.StoreName;
- //仓库归属信息
- int StoreUserId = int.Parse(dic["StoreUserId"].ToString());
- Users storeUser = db.Users.FirstOrDefault(m => m.Id == StoreUserId) ?? new Users();
- dic["StoreMakerCode"] = storeUser.MakerCode;
- int StoreType = int.Parse(dic["StoreType"].ToString());
- if(StoreType == 0) dic["StoreType"] = "总仓";
- if(StoreType == 1) dic["StoreType"] = "分仓";
- //创客信息
- int UserId = int.Parse(dic["UserId"].ToString());
- Users puser = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
- dic["MakerCode"] = puser.MakerCode;
- dic["MakerName"] = puser.RealName;
- //顶级创客
- int TopUserId = int.Parse(dic["TopUserId"].ToString());
- Users tuser = db.Users.FirstOrDefault(m => m.Id == TopUserId) ?? new Users();
- dic["TopMakerCode"] = tuser.MakerCode;
- dic["TopRealName"] = tuser.RealName;
-
- //订单状态
- int Status = int.Parse(dic["Status"].ToString());
- if(Status == 0) dic["Status"] = "待审核";
- if(Status == 1) dic["Status"] = "申请成功";
- if(Status == 2) dic["Status"] = "申请失败";
- //提货方式
- int DeliveryType = int.Parse(dic["DeliveryType"].ToString());
- if(DeliveryType == 0) dic["DeliveryType"] = "";
- if(DeliveryType == 1) dic["DeliveryType"] = "邮寄到付";
- if(DeliveryType == 2) dic["DeliveryType"] = "上门自提";
- //发货状态
- int SendStatus = int.Parse(dic["SendStatus"].ToString());
- if(SendStatus == 0) dic["SendStatus"] = "未发货";
- if(SendStatus == 1) dic["SendStatus"] = "已发货";
- dic.Remove("UserId");
- dic.Remove("TopUserId");
- dic.Remove("StoreId");
- dic.Remove("StoreUserId");
- }
- Dictionary<string, object> result = new Dictionary<string, object>();
- result.Add("Status", "1");
- result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
- result.Add("Obj", diclist);
- Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
- ReturnFields.Add("ApplyNo", "申请单号");
- ReturnFields.Add("StoreNo", "发货仓库编号");
- ReturnFields.Add("StoreName", "发货仓库名称");
- ReturnFields.Add("StoreMakerCode", "仓库归属创客编号");
- ReturnFields.Add("StoreRealName", "仓库归属创客名称");
- ReturnFields.Add("MakerCode", "创客编号");
- ReturnFields.Add("MakerName", "创客名称");
- ReturnFields.Add("StoreType", "仓库类型");
- ReturnFields.Add("StoreManager", "仓库联系人");
- ReturnFields.Add("StoreManagerMobile", "仓库联系人手机号");
- ReturnFields.Add("BrandId", "产品类型");
- ReturnFields.Add("Areas", "收货所在地区");
- ReturnFields.Add("Address", "收货详细地址");
- ReturnFields.Add("RealName", "收件人姓名");
- ReturnFields.Add("Mobile", "收件人手机号");
- ReturnFields.Add("ApplyDeviceName", "申请机具名称");
- ReturnFields.Add("ApplyDeviceNum", "申请机具数量");
- ReturnFields.Add("Status", "订单状态");
- ReturnFields.Add("ApplyTime", "申请时间");
- ReturnFields.Add("SendStatus", "发货状态");
- ReturnFields.Add("SendDate", "发货时间");
- ReturnFields.Add("ExpressNo", "快递单号");
- ReturnFields.Add("ExpressName", "快递名称");
- ReturnFields.Add("DeliveryType", "提货类型");
- ReturnFields.Add("Remark", "订单备注");
- result.Add("Fields", ReturnFields);
- AddSysLog("0", "MachineApply", "ExportExcel");
- return Json(result);
- }
- #endregion
-
- #region 审核发货
- public IActionResult AuditSend(string right, int Id = 0)
- {
- ViewBag.RightInfo = RightInfo;
- ViewBag.right = right;
- MachineApply editData = db.MachineApply.FirstOrDefault(m => m.Id == Id) ?? new MachineApply();
- ViewBag.data = editData;
- return View();
- }
- #endregion
- #region 审核发货
- [HttpPost]
- public string AuditSend(MachineApply data)
- {
- Dictionary<string, object> Fields = new Dictionary<string, object>();
- Fields.Add("ExpressNo", data.ExpressNo);
- Fields.Add("ExpressName", data.ExpressName);
- Fields.Add("StoreId", data.StoreId);
- Fields.Add("AuditResult", data.AuditResult);
- Fields.Add("SendSn", data.SendSn);
- Fields.Add("SendStatus", 1);
- new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("MachineApply", Fields, data.Id);
- AddSysLog(data.Id.ToString(), "MachineApply", "AuditSend");
- db.SaveChanges();
- return "success";
- }
- #endregion
- }
- }
|