StoreMachineApplyController.cs 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779
  1. // using System;
  2. // using System.Web;
  3. // using System.Collections.Generic;
  4. // using System.Diagnostics;
  5. // using System.Linq;
  6. // using System.Threading.Tasks;
  7. // using Microsoft.AspNetCore.Mvc;
  8. // using Microsoft.AspNetCore.Http;
  9. // using Microsoft.Extensions.Logging;
  10. // using Microsoft.Extensions.Options;
  11. // using MySystem.Models;
  12. // using Library;
  13. // using LitJson;
  14. // using MySystemLib;
  15. // /// <summary>
  16. // /// 机具申请记录
  17. // /// </summary>
  18. // namespace MySystem.Areas.Admin.Controllers
  19. // {
  20. // [Area("Admin")]
  21. // [Route("Admin/[controller]/[action]")]
  22. // public class StoreMachineApplyController : BaseController
  23. // {
  24. // public StoreMachineApplyController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
  25. // {
  26. // OtherMySqlConn.connstr = ConfigurationManager.AppSettings["SqlConnStr"].ToString();
  27. // }
  28. // #region 机具申请记录列表
  29. // /// <summary>
  30. // /// 机具申请记录列表
  31. // /// </summary>
  32. // /// <returns></returns>
  33. // public IActionResult Index(StoreMachineApply data, string right)
  34. // {
  35. // ViewBag.RightInfo = RightInfo;
  36. // ViewBag.right = right;
  37. // return View();
  38. // }
  39. // #endregion
  40. // #region 根据条件查询机具申请记录列表
  41. // /// <summary>
  42. // /// 机具申请记录列表
  43. // /// </summary>
  44. // /// <returns></returns>
  45. // public JsonResult IndexData(StoreMachineApply data, string MakerCode, string RealName, string StoreNo, string StoreName, string StoreMakerCode, string StatusSelect, string SendStatusSelect, string StoreTypeSelect, int page = 1, int limit = 30)
  46. // {
  47. // Dictionary<string, string> Fields = new Dictionary<string, string>();
  48. // Fields.Add("ApplyNo", "1"); //申请单号
  49. // Fields.Add("BrandId", "1"); //品牌
  50. // Fields.Add("ExpressNo", "1"); //快递单号
  51. // string condition = " and Status>-1";
  52. // //创客编号
  53. // if (!string.IsNullOrEmpty(MakerCode))
  54. // {
  55. // condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + MakerCode + "')";
  56. // }
  57. // //创客名称
  58. // if (!string.IsNullOrEmpty(RealName))
  59. // {
  60. // condition += " and UserId in (select UserId from UserForRealName where RealName='" + RealName + "')";
  61. // }
  62. // //仓库编号
  63. // if (!string.IsNullOrEmpty(StoreNo))
  64. // {
  65. // condition += " and StoreId in (select StoreId from StoreForCode where Code='" + StoreNo + "')";
  66. // }
  67. // //仓库名称
  68. // if (!string.IsNullOrEmpty(StoreName))
  69. // {
  70. // condition += " and StoreId in (select StoreId from StoreForName where Name='" + StoreName + "')";
  71. // }
  72. // //仓库归属创客编号
  73. // if (!string.IsNullOrEmpty(StoreMakerCode))
  74. // {
  75. // condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + StoreMakerCode + "')";
  76. // }
  77. // //订单状态
  78. // if (!string.IsNullOrEmpty(StatusSelect))
  79. // {
  80. // condition += " and Status=" + StatusSelect;
  81. // }
  82. // //发货状态
  83. // if (!string.IsNullOrEmpty(SendStatusSelect))
  84. // {
  85. // condition += " and SendStatus=" + SendStatusSelect;
  86. // }
  87. // //仓库类型
  88. // if (!string.IsNullOrEmpty(StoreTypeSelect))
  89. // {
  90. // condition += " and StoreType=" + StoreTypeSelect;
  91. // }
  92. // Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("StoreMachineApply", Fields, "Id desc", "0", page, limit, condition);
  93. // List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  94. // foreach (Dictionary<string, object> dic in diclist)
  95. // {
  96. // dic["BrandId"] = RelationClass.GetKqProductBrandInfo(int.Parse(dic["BrandId"].ToString()));
  97. // //申请仓库信息
  98. // int StoreId = int.Parse(dic["StoreId"].ToString());
  99. // StoreHouse store = db.StoreHouse.FirstOrDefault(m => m.Id == StoreId) ?? new StoreHouse();
  100. // dic["StoreInfo"] = store.StoreNo + "<br />" + store.StoreName;
  101. // //仓库收货地址
  102. // dic["StoreAddressInfo"] = store.Areas + "<br />" + store.Address;
  103. // //仓库联系人信息
  104. // //dic["StoreContact"] = dic["StoreManagerMobile"].ToString() + "<br />" + dic["StoreManager"].ToString();
  105. // //仓库归属信息
  106. // // int StoreUserId = int.Parse(dic["StoreUserId"].ToString());
  107. // // Users storeUser = db.Users.FirstOrDefault(m => m.Id == StoreUserId) ?? new Users();
  108. // // int StoreType = int.Parse(dic["StoreType"].ToString());
  109. // // string StoreTypeName = "";
  110. // // if(StoreType == 0) StoreTypeName = "总仓";
  111. // // if(StoreType == 1) StoreTypeName = "分仓";
  112. // // dic["StoreUser"] = storeUser.MakerCode + "<br />" + StoreTypeName;
  113. // //创客信息
  114. // int UserId = int.Parse(dic["UserId"].ToString());
  115. // Users puser = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
  116. // dic["UserInfo"] = puser.MakerCode + "<br />" + puser.RealName;
  117. // //顶级创客
  118. // // int TopUserId = int.Parse(dic["TopUserId"].ToString());
  119. // // Users tuser = db.Users.FirstOrDefault(m => m.Id == TopUserId) ?? new Users();
  120. // // dic["TopUserInfo"] = tuser.MakerCode + "<br />" + tuser.RealName;
  121. // //申请状态
  122. // int Status = int.Parse(dic["Status"].ToString());
  123. // if (Status == 0) dic["Status"] = "待审核";
  124. // if (Status == 1) dic["Status"] = "申请成功";
  125. // if (Status == 2) dic["Status"] = "申请失败";
  126. // }
  127. // Dictionary<string, object> other = new Dictionary<string, object>();
  128. // other.Add("ApplyNum", 0);
  129. // other.Add("SendNum", 0);
  130. // obj.Add("other", other);
  131. // return Json(obj);
  132. // }
  133. // #endregion
  134. // #region 增加机具申请记录
  135. // /// <summary>
  136. // /// 增加或修改机具申请记录信息
  137. // /// </summary>
  138. // /// <returns></returns>
  139. // public IActionResult Add(string right)
  140. // {
  141. // ViewBag.RightInfo = RightInfo;
  142. // ViewBag.right = right;
  143. // return View();
  144. // }
  145. // #endregion
  146. // #region 增加机具申请记录
  147. // /// <summary>
  148. // /// 增加或修改机具申请记录信息
  149. // /// </summary>
  150. // /// <returns></returns>
  151. // [HttpPost]
  152. // public string Add(StoreMachineApply data)
  153. // {
  154. // Dictionary<string, object> Fields = new Dictionary<string, object>();
  155. // Fields.Add("SeoTitle", data.SeoTitle);
  156. // Fields.Add("SeoKeyword", data.SeoKeyword);
  157. // Fields.Add("SeoDescription", data.SeoDescription);
  158. // int Id = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Add("StoreMachineApply", Fields, 0);
  159. // AddSysLog(data.Id.ToString(), "StoreMachineApply", "add");
  160. // db.SaveChanges();
  161. // return "success";
  162. // }
  163. // #endregion
  164. // #region 修改机具申请记录信息
  165. // /// <summary>
  166. // /// 增加或修改机具申请记录信息
  167. // /// </summary>
  168. // /// <returns></returns>
  169. // public IActionResult Edit(string right, int Id = 0)
  170. // {
  171. // ViewBag.RightInfo = RightInfo;
  172. // ViewBag.right = right;
  173. // StoreMachineApply editData = db.StoreMachineApply.FirstOrDefault(m => m.Id == Id) ?? new StoreMachineApply();
  174. // ViewBag.data = editData;
  175. // KqProducts kqProducts = db.KqProducts.FirstOrDefault(m => m.Id == editData.BrandId);
  176. // ViewBag.BrandName = kqProducts.Name;
  177. // Users user = db.Users.FirstOrDefault(m => m.Id == editData.UserId) ?? new Users();
  178. // ViewBag.MakerCode = user.MakerCode;
  179. // ViewBag.RealName = user.RealName;
  180. // int Status = editData.Status;
  181. // if (Status == 0) ViewBag.Status = "待审核";
  182. // if (Status == 1) ViewBag.Status = "申请成功";
  183. // if (Status == 2) ViewBag.Status = "申请失败";
  184. // return View();
  185. // }
  186. // #endregion
  187. // #region 修改机具申请记录
  188. // /// <summary>
  189. // /// 增加或修改机具申请记录信息
  190. // /// </summary>
  191. // /// <returns></returns>
  192. // [HttpPost]
  193. // public string Edit(StoreMachineApply data)
  194. // {
  195. // Dictionary<string, object> Fields = new Dictionary<string, object>();
  196. // Fields.Add("ApplyNo", data.ApplyNo); //申请单号
  197. // // Fields.Add("BrandId", data.BrandId); //产品Id
  198. // Fields.Add("ApplyNum", data.ApplyNum); //申请箱数
  199. // Fields.Add("SendNum", data.SendNum); //发货箱数
  200. // // Fields.Add("UserId", data.UserId); //创客ID
  201. // Fields.Add("Status", data.Status); //申请状态
  202. // Fields.Add("SwapSnExpand", data.SwapSnExpand);//已发货机具SN
  203. // Fields.Add("SeoDescription", data.SeoDescription); //申请描述
  204. // new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("StoreMachineApply", Fields, data.Id);
  205. // AddSysLog(data.Id.ToString(), "StoreMachineApply", "update");
  206. // db.SaveChanges();
  207. // return "success";
  208. // }
  209. // #endregion
  210. // #region 删除机具申请记录信息
  211. // /// <summary>
  212. // /// 删除机具申请记录信息
  213. // /// </summary>
  214. // /// <returns></returns>
  215. // public string Delete(string Id)
  216. // {
  217. // string[] idlist = Id.Split(new char[] { ',' });
  218. // AddSysLog(Id, "StoreMachineApply", "del");
  219. // foreach (string subid in idlist)
  220. // {
  221. // int id = int.Parse(subid);
  222. // Dictionary<string, object> Fields = new Dictionary<string, object>();
  223. // Fields.Add("Status", -1);
  224. // new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("StoreMachineApply", Fields, id);
  225. // }
  226. // db.SaveChanges();
  227. // return "success";
  228. // }
  229. // #endregion
  230. // #region 取消机具申请记录信息
  231. // /// <summary>
  232. // /// 取消机具申请记录信息
  233. // /// </summary>
  234. // /// <returns></returns>
  235. // public string Cancel(int Id)
  236. // {
  237. // StoreMachineApply storeMachineApply = db.StoreMachineApply.FirstOrDefault(m => m.Id == Id);
  238. // Orders order = db.Orders.FirstOrDefault(m => m.Id == storeMachineApply.OrderId);
  239. // if (storeMachineApply != null && order != null)
  240. // {
  241. // function.WriteLog(Newtonsoft.Json.JsonConvert.SerializeObject(storeMachineApply) + "#cut#" + Newtonsoft.Json.JsonConvert.SerializeObject(order) + "#cut#" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "机具申请订单取消日志");
  242. // db.StoreMachineApply.Remove(storeMachineApply);
  243. // db.Orders.Remove(order);
  244. // db.SaveChanges();
  245. // }
  246. // AddSysLog(Id, "StoreMachineApply", "cancel");
  247. // AddSysLog(Id, "Orders", "cancel");
  248. // return "success";
  249. // }
  250. // #endregion
  251. // #region 开启
  252. // /// <summary>
  253. // /// 开启
  254. // /// </summary>
  255. // /// <returns></returns>
  256. // public string Open(string Id)
  257. // {
  258. // string[] idlist = Id.Split(new char[] { ',' });
  259. // AddSysLog(Id, "StoreMachineApply", "open");
  260. // foreach (string subid in idlist)
  261. // {
  262. // int id = int.Parse(subid);
  263. // Dictionary<string, object> Fields = new Dictionary<string, object>();
  264. // Fields.Add("Status", 1);
  265. // new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("StoreMachineApply", Fields, id);
  266. // }
  267. // db.SaveChanges();
  268. // return "success";
  269. // }
  270. // #endregion
  271. // #region 关闭
  272. // /// <summary>
  273. // /// 关闭
  274. // /// </summary>
  275. // /// <returns></returns>
  276. // public string Close(string Id)
  277. // {
  278. // string[] idlist = Id.Split(new char[] { ',' });
  279. // AddSysLog(Id, "StoreMachineApply", "close");
  280. // foreach (string subid in idlist)
  281. // {
  282. // int id = int.Parse(subid);
  283. // Dictionary<string, object> Fields = new Dictionary<string, object>();
  284. // Fields.Add("Status", 0);
  285. // new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("StoreMachineApply", Fields, id);
  286. // }
  287. // db.SaveChanges();
  288. // return "success";
  289. // }
  290. // #endregion
  291. // #region 排序
  292. // /// <summary>
  293. // /// 排序
  294. // /// </summary>
  295. // /// <param name="Id"></param>
  296. // public string Sort(int Id, int Sort)
  297. // {
  298. // new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Sort("StoreMachineApply", Sort, Id);
  299. // AddSysLog(Id.ToString(), "StoreMachineApply", "sort");
  300. // return "success";
  301. // }
  302. // #endregion
  303. // #region 导入数据
  304. // public IActionResult Import(string right, string ExcelKind)
  305. // {
  306. // ViewBag.RightInfo = RightInfo;
  307. // ViewBag.right = right;
  308. // ViewBag.ExcelKind = ExcelKind;
  309. // return View();
  310. // }
  311. // /// <summary>
  312. // /// 导入数据
  313. // /// </summary>
  314. // /// <param name="ExcelData"></param>
  315. // [HttpPost]
  316. // public string ImportPost(string ExcelData)
  317. // {
  318. // // // RedisDbconn.Instance.AddList("ExcelImport", ExcelPath + "#cut#" + Kind);
  319. // // string key = function.MD5_16(Guid.NewGuid().ToString());
  320. // // RedisDbconn.Instance.AddList("ExcelImportV2", ExcelPath + "#cut#" + Kind + "#cut#" + key);
  321. // // return "success|" + key;
  322. // ExcelData = HttpUtility.UrlDecode(ExcelData);
  323. // JsonData list = JsonMapper.ToObject(ExcelData);
  324. // for (int i = 1; i < list.Count; i++)
  325. // {
  326. // JsonData dr = list[i];
  327. // // string SwapSnExpand = dr[0].ToString();
  328. // var temp = dr[0].ToString();
  329. // temp = temp.Substring(1);
  330. // temp = temp.Substring(0, temp.Length - 1);
  331. // var SwapSnExpand = temp.Split(",,");
  332. // // StoreMachineApply storeMachineApply = db.StoreMachineApply.FirstOrDefault(m => m.MakerCode == MakerCode);
  333. // // if (UserCode != null)
  334. // // {
  335. // // Users User = db.Users.FirstOrDefault(m => m.Id == UserCode.UserId);
  336. // // if (User != null)
  337. // // {
  338. // // User.SettleAmount = decimal.Parse(function.CheckInt(SettleAmount));
  339. // // }
  340. // // }
  341. // }
  342. // db.SaveChanges();
  343. // return "success";
  344. // }
  345. // #endregion
  346. // #region 导出Excel
  347. // /// <summary>
  348. // /// 导出Excel
  349. // /// </summary>
  350. // /// <returns></returns>
  351. // public JsonResult ExportExcel(StoreMachineApply data, string MakerCode, string RealName, string StoreNo, string StoreName, string StoreMakerCode, string StatusSelect, string SendStatusSelect, string StoreTypeSelect)
  352. // {
  353. // Dictionary<string, string> Fields = new Dictionary<string, string>();
  354. // Fields.Add("ApplyNo", "1"); //申请单号
  355. // Fields.Add("BrandId", "1"); //品牌
  356. // Fields.Add("ApplyTime", "3"); //申请时间
  357. // Fields.Add("ExpressNo", "1"); //快递单号
  358. // string condition = " and Status>-1";
  359. // //创客编号
  360. // if (!string.IsNullOrEmpty(MakerCode))
  361. // {
  362. // condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + MakerCode + "')";
  363. // }
  364. // //创客名称
  365. // if (!string.IsNullOrEmpty(RealName))
  366. // {
  367. // condition += " and UserId in (select UserId from UserForRealName where RealName='" + RealName + "')";
  368. // }
  369. // //仓库编号
  370. // if (!string.IsNullOrEmpty(StoreNo))
  371. // {
  372. // condition += " and StoreId in (select StoreId from StoreForCode where Code='" + StoreNo + "')";
  373. // }
  374. // //仓库名称
  375. // if (!string.IsNullOrEmpty(RealName))
  376. // {
  377. // condition += " and StoreId in (select StoreId from StoreForName where Name='" + RealName + "')";
  378. // }
  379. // //仓库归属创客编号
  380. // if (!string.IsNullOrEmpty(StoreMakerCode))
  381. // {
  382. // condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + StoreMakerCode + "')";
  383. // }
  384. // //订单状态
  385. // if (!string.IsNullOrEmpty(StatusSelect))
  386. // {
  387. // condition += " and Status=" + StatusSelect;
  388. // }
  389. // //发货状态
  390. // if (!string.IsNullOrEmpty(SendStatusSelect))
  391. // {
  392. // condition += " and SendStatus=" + SendStatusSelect;
  393. // }
  394. // //仓库类型
  395. // if (!string.IsNullOrEmpty(StoreTypeSelect))
  396. // {
  397. // condition += " and StoreType=" + StoreTypeSelect;
  398. // }
  399. // 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);
  400. // List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  401. // foreach (Dictionary<string, object> dic in diclist)
  402. // {
  403. // dic["BrandId"] = RelationClass.GetKqProductBrandInfo(int.Parse(dic["BrandId"].ToString()));
  404. // //申请仓库信息
  405. // int StoreId = int.Parse(dic["StoreId"].ToString());
  406. // StoreHouse store = db.StoreHouse.FirstOrDefault(m => m.Id == StoreId) ?? new StoreHouse();
  407. // dic["StoreInfo"] = store.StoreNo + "<br />" + store.StoreName;
  408. // //仓库联系人信息
  409. // //dic["StoreContact"] = dic["StoreManagerMobile"].ToString() + "<br />" + dic["StoreManager"].ToString();
  410. // //仓库归属信息
  411. // // int StoreUserId = int.Parse(dic["StoreUserId"].ToString());
  412. // // Users storeUser = db.Users.FirstOrDefault(m => m.Id == StoreUserId) ?? new Users();
  413. // // int StoreType = int.Parse(dic["StoreType"].ToString());
  414. // // string StoreTypeName = "";
  415. // // if(StoreType == 0) StoreTypeName = "总仓";
  416. // // if(StoreType == 1) StoreTypeName = "分仓";
  417. // // dic["StoreUser"] = storeUser.MakerCode + "<br />" + StoreTypeName;
  418. // //创客信息
  419. // int UserId = int.Parse(dic["UserId"].ToString());
  420. // Users puser = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
  421. // dic["UserInfo"] = puser.MakerCode + "<br />" + puser.RealName;
  422. // //顶级创客
  423. // // int TopUserId = int.Parse(dic["TopUserId"].ToString());
  424. // // Users tuser = db.Users.FirstOrDefault(m => m.Id == TopUserId) ?? new Users();
  425. // // dic["TopUserInfo"] = tuser.MakerCode + "<br />" + tuser.RealName;
  426. // //申请状态
  427. // int Status = int.Parse(dic["Status"].ToString());
  428. // if (Status == 0) dic["Status"] = "待审核";
  429. // if (Status == 1) dic["Status"] = "申请成功";
  430. // if (Status == 2) dic["Status"] = "申请失败";
  431. // dic.Remove("BrandId");
  432. // dic.Remove("StoreInfo");
  433. // dic.Remove("UserInfo");
  434. // dic.Remove("Status");
  435. // }
  436. // Dictionary<string, object> result = new Dictionary<string, object>();
  437. // result.Add("Status", "1");
  438. // result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
  439. // result.Add("Obj", diclist);
  440. // Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
  441. // ReturnFields.Add("ApplyNo", "申请单号");
  442. // ReturnFields.Add("BrandId", "产品类型");
  443. // ReturnFields.Add("StoreId", "申请仓库");
  444. // ReturnFields.Add("StoreMakerCode", "仓库归属创客编号");
  445. // ReturnFields.Add("StoreRealName", "仓库归属创客名称");
  446. // ReturnFields.Add("MakerCode", "创客编号");
  447. // ReturnFields.Add("MakerName", "创客名称");
  448. // ReturnFields.Add("Status", "申请状态");
  449. // ReturnFields.Add("ApplyTime", "申请时间");
  450. // ReturnFields.Add("ApplyNum", "申请箱数");
  451. // ReturnFields.Add("SendNum", "发货箱数");
  452. // ReturnFields.Add("SwapSnExpand", "已发货SN号");
  453. // ReturnFields.Add("SeoDescription", "申请描述");
  454. // result.Add("Fields", ReturnFields);
  455. // AddSysLog("0", "StoreMachineApply", "ExportExcel");
  456. // return Json(result);
  457. // }
  458. // #endregion
  459. // #region 审核发货
  460. // public IActionResult AuditSend(string right, int Id = 0)
  461. // {
  462. // ViewBag.RightInfo = RightInfo;
  463. // ViewBag.right = right;
  464. // StoreMachineApply editData = db.StoreMachineApply.FirstOrDefault(m => m.Id == Id) ?? new StoreMachineApply();
  465. // ViewBag.data = editData;
  466. // Users users = db.Users.FirstOrDefault(m => m.Id == editData.UserId) ?? new Users();
  467. // StoreHouse storeHouse = db.StoreHouse.FirstOrDefault(m => m.Id == editData.StoreId) ?? new StoreHouse();
  468. // ViewBag.MakerCode = users.MakerCode;
  469. // ViewBag.RealName = users.RealName;
  470. // return View();
  471. // }
  472. // #endregion
  473. // #region 审核发货
  474. // [HttpPost]
  475. // public string AuditSend(StoreMachineApply data, string ExcelData)
  476. // {
  477. // Dictionary<string, object> Fields = new Dictionary<string, object>();
  478. // Fields.Add("ApplyNum", data.ApplyNum); //申请箱数
  479. // Fields.Add("SendNum", data.SendNum); //发货箱数
  480. // Fields.Add("SeoDescription", data.SeoDescription); //申请描述
  481. // Fields.Add("Status", data.Status);
  482. // new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("StoreMachineApply", Fields, data.Id);
  483. // AddSysLog(data.Id.ToString(), "StoreMachineApply", "AuditSend");
  484. // StoreMachineApply apply = db.StoreMachineApply.FirstOrDefault(m=>m.Id == data.Id) ?? new StoreMachineApply();
  485. // StoreHouse tostore = db.StoreHouse.FirstOrDefault(m=>m.Id == apply.StoreId) ?? new StoreHouse();
  486. // int BrandId = apply.BrandId.Value;
  487. // var FromStoreId = 0;
  488. // if (BrandId==1)
  489. // {
  490. // FromStoreId=7;
  491. // }
  492. // else if (BrandId==2)
  493. // {
  494. // FromStoreId=721;
  495. // }
  496. // else if (BrandId==3)
  497. // {
  498. // FromStoreId=697;
  499. // }
  500. // else if (BrandId==4)
  501. // {
  502. // FromStoreId=774;
  503. // }
  504. // else if (BrandId==5)
  505. // {
  506. // FromStoreId=775;
  507. // }
  508. // else if (BrandId==6)
  509. // {
  510. // FromStoreId=871;
  511. // }
  512. // else if (BrandId==7)
  513. // {
  514. // FromStoreId=0;
  515. // }
  516. // ExcelData = HttpUtility.UrlDecode(ExcelData);
  517. // JsonData list = JsonMapper.ToObject(ExcelData);
  518. // Dictionary<string, int> storeData = new Dictionary<string, int>();
  519. // Dictionary<string, int> toStoreData = new Dictionary<string, int>();
  520. // for (int i = 1; i < list.Count; i++)
  521. // {
  522. // JsonData dr = list[i];
  523. // string itemJson = dr.ToJson();
  524. // string SnNo = itemJson.Contains("\"A\"") ? dr["A"].ToString() : "";
  525. // string BatchNo = itemJson.Contains("\"B\"") ? dr["B"].ToString() : "";
  526. // string OutNote = itemJson.Contains("\"C\"") ? dr["B"].ToString() : "";
  527. // StoreMachineApply storeMachineApply = db.StoreMachineApply.FirstOrDefault(m=>m.Id == data.Id);
  528. // if (storeMachineApply != null)
  529. // {
  530. // storeMachineApply.SwapSnExpand = function.CheckString(SnNo)+',';
  531. // }
  532. // MachineForSnNo machinefor = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == SnNo) ?? new MachineForSnNo();
  533. // PosMachinesTwo machine = db.PosMachinesTwo.FirstOrDefault(m => m.Id == machinefor.SnId && m.StoreId != apply.StoreId && m.BuyUserId == 0 && m.UserId == 0) ?? new PosMachinesTwo();
  534. // if (machine.Id > 0)
  535. // {
  536. // StoreStockChange stockchange = db.StoreStockChange.Add(new StoreStockChange()
  537. // {
  538. // CreateDate = DateTime.Now,
  539. // StoreId = FromStoreId, //出货仓库
  540. // BrandId = BrandId, //产品类型
  541. // ProductName = RelationClass.GetKqProductBrandInfo(BrandId), //产品名称
  542. // BizBatchNo = BatchNo, //业务批次号
  543. // TransType = 1, //交易类型
  544. // SnNo = SnNo, //SN编号
  545. // StockOpDirect = 1, //库存操作方向
  546. // SnStatus = 1, //SN状态
  547. // DeviceVendor = machine.DeviceName, //设备厂商
  548. // DeviceModel = machine.DeviceKind, //设备型号
  549. // DeviceType = machine.DeviceType, //设备类型
  550. // FromUserId = tostore.UserId, //出货人
  551. // FromDate = DateTime.Now, //出库时间
  552. // FromRemark = OutNote, //出库备注
  553. // ToUserId = tostore.UserId, //收货人
  554. // ToStoreId = tostore.Id, //退货收货仓库
  555. // SourceStoreId = machine.SourceStoreId, //源仓库编号
  556. // BrandType = machine.DeviceType, //品牌类型
  557. // }).Entity;
  558. // db.SaveChanges();
  559. // string ChangeNo = "SC";
  560. // int StoreStockChangeId = stockchange.Id;
  561. // string StoreStockChangeIdString = StoreStockChangeId.ToString();
  562. // for (int j = 0; j < 18 - StoreStockChangeId.ToString().Length; j++)
  563. // {
  564. // StoreStockChangeIdString = "0" + StoreStockChangeIdString;
  565. // }
  566. // ChangeNo += StoreStockChangeIdString;
  567. // stockchange.ChangeNo = ChangeNo; //交易流水编号
  568. // machine.StoreId = tostore.Id;
  569. // db.StoreChangeHistory.Add(new StoreChangeHistory()
  570. // {
  571. // CreateDate = DateTime.Now,
  572. // UserId = tostore.UserId, //创客
  573. // BrandId = BrandId, //产品类型
  574. // ChangeRecordNo = ChangeNo, //变更记录单号
  575. // BizBatchNo = BatchNo, //业务批次号
  576. // TransType = 1, //交易类型
  577. // SnNo = SnNo, //SN编号
  578. // SnType = machine.PosSnType, //SN机具类型
  579. // StockOpDirect = 1, //库存操作方向
  580. // DeviceVendor = machine.DeviceName, //设备厂商
  581. // DeviceModel = machine.DeviceKind, //设备型号
  582. // DeviceType = machine.DeviceType, //设备类型
  583. // FromUserId = tostore.UserId, //出货创客
  584. // FromDate = DateTime.Now, //出库时间
  585. // FromRemark = OutNote, //出库备注
  586. // SourceStoreId = machine.SourceStoreId, //源仓库
  587. // StoreId = tostore.Id, //仓库
  588. // });
  589. // db.StoreChangeHistory.Add(new StoreChangeHistory()
  590. // {
  591. // CreateDate = DateTime.Now,
  592. // UserId = tostore.UserId, //创客
  593. // BrandId = BrandId, //产品类型
  594. // ChangeRecordNo = ChangeNo, //变更记录单号
  595. // BizBatchNo = BatchNo, //业务批次号
  596. // TransType = 1, //交易类型
  597. // SnNo = SnNo, //SN编号
  598. // SnType = machine.PosSnType, //SN机具类型
  599. // StockOpDirect = 0, //库存操作方向
  600. // DeviceVendor = machine.DeviceName, //设备厂商
  601. // DeviceModel = machine.DeviceKind, //设备型号
  602. // DeviceType = machine.DeviceType, //设备类型
  603. // ToUserId = tostore.UserId, //收货创客
  604. // ToStoreId = tostore.Id, //创客退货收货仓库
  605. // ToDate = DateTime.Now, //入库时间
  606. // ToRemark = OutNote, //入库备注
  607. // SourceStoreId = machine.SourceStoreId, //源仓库
  608. // StoreId = tostore.Id, //仓库
  609. // });
  610. // db.SaveChanges();
  611. // }
  612. // }
  613. // db.SaveChanges();
  614. // int StoreId = FromStoreId;
  615. // int OpStoreNum = list.Count - 1;
  616. // StoreHouse store = db.StoreHouse.FirstOrDefault(m => m.Id == StoreId) ?? new StoreHouse();
  617. // StoreBalance balance = db.StoreBalance.Add(new StoreBalance()
  618. // {
  619. // CreateDate = DateTime.Now,
  620. // StoreId = StoreId, //仓库
  621. // TransType = 1, //交易类型
  622. // BrandId = BrandId, //产品类型
  623. // OpStoreNum = OpStoreNum, //操作库存数
  624. // OpSymbol = "-", //操作符
  625. // BeforeTotalNum = store.TotalNum, //操作前总库存数
  626. // AfterTotalNum = store.TotalNum, //操作后总库存数
  627. // BeforeLaveNum = store.LaveNum, //操作前剩余库存数
  628. // AfterLaveNum = store.LaveNum - OpStoreNum, //操作后剩余库存数
  629. // BeforeOutNum = store.OutNum, //操作前出库数
  630. // AfterOutNum = store.OutNum + OpStoreNum, //操作后出库数
  631. // }).Entity;
  632. // db.SaveChanges();
  633. // string ChangeNo1 = "SC";
  634. // int StoreStockChangeId1 = balance.Id;
  635. // string StoreStockChangeId1String = StoreStockChangeId1.ToString();
  636. // for (int i = 0; i < 18 - StoreStockChangeId1.ToString().Length; i++)
  637. // {
  638. // StoreStockChangeId1String = "0" + StoreStockChangeId1String;
  639. // }
  640. // ChangeNo1 += StoreStockChangeId1String;
  641. // balance.TransRecordNo = ChangeNo1; //交易流水编号
  642. // store.LaveNum -= OpStoreNum;
  643. // store.OutNum += OpStoreNum;
  644. // db.SaveChanges();
  645. // StoreId = tostore.Id;
  646. // balance = db.StoreBalance.Add(new StoreBalance()
  647. // {
  648. // CreateDate = DateTime.Now,
  649. // StoreId = StoreId, //仓库
  650. // TransType = 0, //交易类型
  651. // BrandId = BrandId, //产品类型
  652. // OpStoreNum = OpStoreNum, //操作库存数
  653. // OpSymbol = "+", //操作符
  654. // BeforeTotalNum = store.TotalNum, //操作前总库存数
  655. // AfterTotalNum = store.TotalNum + OpStoreNum, //操作后总库存数
  656. // BeforeLaveNum = store.LaveNum, //操作前剩余库存数
  657. // AfterLaveNum = store.LaveNum + OpStoreNum, //操作后剩余库存数
  658. // BeforeOutNum = store.OutNum, //操作前出库数
  659. // AfterOutNum = store.OutNum, //操作后出库数
  660. // }).Entity;
  661. // db.SaveChanges();
  662. // string ChangeNo2 = "SC";
  663. // int StoreStockChangeId2 = balance.Id;
  664. // string StoreStockChangeId2String = StoreStockChangeId2.ToString();
  665. // for (int i = 0; i < 18 - StoreStockChangeId2.ToString().Length; i++)
  666. // {
  667. // StoreStockChangeId2String = "0" + StoreStockChangeId2String;
  668. // }
  669. // ChangeNo2 += StoreStockChangeId2String;
  670. // balance.TransRecordNo = ChangeNo2; //交易流水编号
  671. // store.TotalNum += OpStoreNum;
  672. // store.LaveNum += OpStoreNum;
  673. // db.SaveChanges();
  674. // if (data.Status == 1)
  675. // {
  676. // return "success";
  677. // }
  678. // else
  679. // {
  680. // return "false";
  681. // }
  682. // }
  683. // #endregion
  684. // }
  685. // }