PreSendStockDetailController.cs 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765
  1. /*
  2. * 预发货库存明细
  3. */
  4. using System;
  5. using System.Web;
  6. using System.Collections.Generic;
  7. using System.Diagnostics;
  8. using System.Linq;
  9. using System.Threading.Tasks;
  10. using Microsoft.AspNetCore.Mvc;
  11. using Microsoft.AspNetCore.Http;
  12. using Microsoft.Extensions.Logging;
  13. using Microsoft.Extensions.Options;
  14. using MySystem.Models;
  15. using Library;
  16. using LitJson;
  17. using MySystemLib;
  18. namespace MySystem.Areas.Admin.Controllers
  19. {
  20. [Area("Admin")]
  21. [Route("Admin/[controller]/[action]")]
  22. public class PreSendStockDetailController : BaseController
  23. {
  24. public PreSendStockDetailController(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(PreSendStockDetail data, string right, string StoreId)
  34. {
  35. ViewBag.RightInfo = RightInfo;
  36. ViewBag.right = right;
  37. ViewBag.StoreId = StoreId;
  38. return View();
  39. }
  40. #endregion
  41. #region 根据条件查询预发货库存明细列表
  42. /// <summary>
  43. /// 预发货库存明细列表
  44. /// </summary>
  45. /// <returns></returns>
  46. public JsonResult IndexData(PreSendStockDetail data, string StoreIdStoreName, string StoreIdStoreNo, string CreateDateData, string ApplyDateData, string BrandIdSelect, string ToUserIdMakerCode, string ToUserIdRealName, string ToStoreIdStoreNo, string ToStoreIdStoreName, string SourceStoreIdStoreNo, string SourceStoreIdStoreName, string FromUserIdMakerCode, string FromUserIdRealName, string FromStoreIdStoreNo, string FromStoreIdStoreName, int page = 1, int limit = 30)
  47. {
  48. Dictionary<string, string> Fields = new Dictionary<string, string>();
  49. Fields.Add("StoreId", "1");
  50. // Fields.Add("CreateDate", "3"); //时间
  51. Fields.Add("SnNo", "1"); //SN编号
  52. // Fields.Add("ApplyDate", "3"); //申请时间
  53. string condition = " and Status>-1";
  54. //仓库名称
  55. if (!string.IsNullOrEmpty(StoreIdStoreName))
  56. {
  57. condition += " and StoreId in (select StoreId from StoreForName where Name='" + StoreIdStoreName + "')";
  58. }
  59. //仓库编号
  60. if (!string.IsNullOrEmpty(StoreIdStoreNo))
  61. {
  62. condition += " and StoreId in (select StoreId from StoreForCode where Code='" + StoreIdStoreNo + "')";
  63. }
  64. if (!string.IsNullOrEmpty(CreateDateData))
  65. {
  66. string[] datelist = CreateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
  67. string start = datelist[0];
  68. string end = datelist[1];
  69. condition += " and CreateDate>='" + start + " 00:00:00' and CreateDate<='" + end + " 23:59:59'";
  70. }
  71. if (!string.IsNullOrEmpty(ApplyDateData))
  72. {
  73. string[] datelist = ApplyDateData.Split(new string[] { " - " }, StringSplitOptions.None);
  74. string start = datelist[0];
  75. string end = datelist[1];
  76. condition += " and ApplyDate>='" + start + " 00:00:00' and ApplyDate<='" + end + " 23:59:59'";
  77. }
  78. //产品类型
  79. if (!string.IsNullOrEmpty(BrandIdSelect))
  80. {
  81. condition += " and BrandId=" + BrandIdSelect;
  82. }
  83. //收货人创客编号
  84. if (!string.IsNullOrEmpty(ToUserIdMakerCode))
  85. {
  86. condition += " and ToUserId in (select UserId from UserForMakerCode where MakerCode='" + ToUserIdMakerCode + "')";
  87. }
  88. //收货人真实姓名
  89. if (!string.IsNullOrEmpty(ToUserIdRealName))
  90. {
  91. condition += " and ToUserId in (select UserId from UserForRealName where RealName='" + ToUserIdRealName + "')";
  92. }
  93. //收货仓库编号
  94. if (!string.IsNullOrEmpty(ToStoreIdStoreNo))
  95. {
  96. condition += " and ToStoreId in (select StoreId from StoreForCode where Code='" + ToStoreIdStoreNo + "')";
  97. }
  98. //收货仓库名称
  99. if (!string.IsNullOrEmpty(ToStoreIdStoreName))
  100. {
  101. condition += " and ToStoreId in (select StoreId from StoreForName where Name='" + ToStoreIdStoreName + "')";
  102. }
  103. //源仓库编号仓库编号
  104. if (!string.IsNullOrEmpty(SourceStoreIdStoreNo))
  105. {
  106. condition += " and SourceStoreId in (select StoreId from StoreForCode where Code='" + SourceStoreIdStoreNo + "')";
  107. }
  108. //源仓库编号仓库名称
  109. if (!string.IsNullOrEmpty(SourceStoreIdStoreName))
  110. {
  111. condition += " and SourceStoreId in (select StoreId from StoreForName where Name=='" + SourceStoreIdStoreName + "')";
  112. }
  113. //出货创客编号
  114. if (!string.IsNullOrEmpty(FromUserIdMakerCode))
  115. {
  116. condition += " and FromUserId in (select UserId from UserForMakerCode where MakerCode='" + FromUserIdMakerCode + "')";
  117. }
  118. //出货创客真实姓名
  119. if (!string.IsNullOrEmpty(FromUserIdRealName))
  120. {
  121. condition += " and FromUserId in (select UserId from UserForRealName where RealName='" + FromUserIdRealName + "')";
  122. }
  123. //出货仓库编号
  124. if (!string.IsNullOrEmpty(FromStoreIdStoreNo))
  125. {
  126. condition += " and FromStoreId in (select StoreId from StoreForCode where Code='" + FromStoreIdStoreNo + "')";
  127. }
  128. //出货仓库名称
  129. if (!string.IsNullOrEmpty(FromStoreIdStoreName))
  130. {
  131. condition += " and FromStoreId in (select StoreId from StoreForName where Name='" + FromStoreIdStoreName + "')";
  132. }
  133. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("PreSendStockDetail", Fields, "Id desc", "0", page, limit, condition);
  134. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  135. foreach (Dictionary<string, object> dic in diclist)
  136. {
  137. //仓库
  138. int StoreId = int.Parse(function.CheckInt(dic["StoreId"].ToString()));
  139. SmallStoreHouse storeid_SmallStoreHouse = db.SmallStoreHouse.FirstOrDefault(m => m.Id == StoreId) ?? new SmallStoreHouse();
  140. dic["StoreIdStoreName"] = storeid_SmallStoreHouse.StoreName;
  141. dic["StoreIdStoreNo"] = storeid_SmallStoreHouse.StoreNo;
  142. dic.Remove("StoreId");
  143. //产品类型
  144. dic["BrandId"] = RelationClass.GetKqProductBrandInfo(int.Parse(dic["BrandId"].ToString()));
  145. //SNID
  146. dic["SnId"] = RelationClass.GetPosMachinesTwoInfo(int.Parse(dic["SnId"].ToString()));
  147. //收货人
  148. int ToUserId = int.Parse(function.CheckInt(dic["ToUserId"].ToString()));
  149. Users touserid_Users = db.Users.FirstOrDefault(m => m.Id == ToUserId) ?? new Users();
  150. dic["ToUserIdMakerCode"] = touserid_Users.MakerCode;
  151. dic["ToUserIdRealName"] = touserid_Users.RealName;
  152. dic.Remove("ToUserId");
  153. //收货仓库
  154. int ToStoreId = int.Parse(function.CheckInt(dic["ToStoreId"].ToString()));
  155. StoreHouse tostoreid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == ToStoreId) ?? new StoreHouse();
  156. dic["ToStoreIdStoreNo"] = tostoreid_StoreHouse.StoreNo;
  157. dic["ToStoreIdStoreName"] = tostoreid_StoreHouse.StoreName;
  158. dic.Remove("ToStoreId");
  159. //源仓库编号
  160. int SourceStoreId = int.Parse(function.CheckInt(dic["SourceStoreId"].ToString()));
  161. StoreHouse sourcestoreid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == SourceStoreId) ?? new StoreHouse();
  162. dic["SourceStoreIdStoreNo"] = sourcestoreid_StoreHouse.StoreNo;
  163. dic["SourceStoreIdStoreName"] = sourcestoreid_StoreHouse.StoreName;
  164. dic.Remove("SourceStoreId");
  165. dic["ApplyFlagName"] = dic["ApplyFlag"].ToString() == "1" ? "是" : "否";
  166. //出货创客
  167. int FromUserId = int.Parse(function.CheckInt(dic["FromUserId"].ToString()));
  168. Users fromuserid_Users = db.Users.FirstOrDefault(m => m.Id == FromUserId) ?? new Users();
  169. dic["FromUserIdMakerCode"] = fromuserid_Users.MakerCode;
  170. dic["FromUserIdRealName"] = fromuserid_Users.RealName;
  171. dic.Remove("FromUserId");
  172. //出货仓库
  173. int FromStoreId = int.Parse(function.CheckInt(dic["FromStoreId"].ToString()));
  174. StoreHouse fromstoreid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == FromStoreId) ?? new StoreHouse();
  175. dic["FromStoreIdStoreNo"] = fromstoreid_StoreHouse.StoreNo;
  176. dic["FromStoreIdStoreName"] = fromstoreid_StoreHouse.StoreName;
  177. dic.Remove("FromStoreId");
  178. dic["CancelFlagName"] = dic["CancelFlag"].ToString() == "1" ? "是" : "否";
  179. //是否占用额度
  180. int AuthFlag = int.Parse(function.CheckInt(dic["AuthFlag"].ToString()));
  181. if (AuthFlag == 0) dic["PayMode"] = "否";
  182. if (AuthFlag == 1) dic["PayMode"] = "是";
  183. }
  184. return Json(obj);
  185. }
  186. #endregion
  187. #region 增加预发货库存明细
  188. /// <summary>
  189. /// 增加或修改预发货库存明细信息
  190. /// </summary>
  191. /// <returns></returns>
  192. public IActionResult Add(string right, string StoreId)
  193. {
  194. ViewBag.RightInfo = RightInfo;
  195. ViewBag.right = right;
  196. ViewBag.StoreId = StoreId;
  197. return View();
  198. }
  199. #endregion
  200. #region 增加预发货库存明细
  201. /// <summary>
  202. /// 增加或修改预发货库存明细信息
  203. /// </summary>
  204. /// <returns></returns>
  205. [HttpPost]
  206. public string Add(PreSendStockDetail data)
  207. {
  208. Dictionary<string, object> Fields = new Dictionary<string, object>();
  209. Fields.Add("StoreId", data.StoreId);
  210. Fields.Add("StoreId", data.StoreId); //仓库
  211. Fields.Add("BrandId", data.BrandId); //产品类型
  212. Fields.Add("SnId", data.SnId); //SNID
  213. Fields.Add("ToUserId", data.ToUserId); //收货人
  214. Fields.Add("ToStoreId", data.ToStoreId); //收货仓库
  215. Fields.Add("SourceStoreId", data.SourceStoreId); //源仓库编号
  216. Fields.Add("ApplyFlag", data.ApplyFlag); //申请标记
  217. Fields.Add("ApplyDate", data.ApplyDate); //申请时间
  218. Fields.Add("FromUserId", data.FromUserId); //出货创客
  219. Fields.Add("FromStoreId", data.FromStoreId); //出货仓库
  220. Fields.Add("CancelFlag", data.CancelFlag); //撤回标记
  221. Fields.Add("CancelDate", data.CancelDate); //撤回时间
  222. Fields.Add("SeoTitle", data.SeoTitle);
  223. Fields.Add("SeoKeyword", data.SeoKeyword);
  224. Fields.Add("SeoDescription", data.SeoDescription);
  225. int Id = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Add("PreSendStockDetail", Fields, 0);
  226. AddSysLog(data.Id.ToString(), "PreSendStockDetail", "add");
  227. db.SaveChanges();
  228. return "success";
  229. }
  230. #endregion
  231. #region 修改预发货库存明细
  232. /// <summary>
  233. /// 增加或修改预发货库存明细信息
  234. /// </summary>
  235. /// <returns></returns>
  236. public IActionResult Edit(string right, string StoreId, int Id = 0)
  237. {
  238. ViewBag.RightInfo = RightInfo;
  239. ViewBag.right = right;
  240. ViewBag.StoreId = StoreId;
  241. PreSendStockDetail editData = db.PreSendStockDetail.FirstOrDefault(m => m.Id == Id) ?? new PreSendStockDetail();
  242. ViewBag.data = editData;
  243. return View();
  244. }
  245. #endregion
  246. #region 修改预发货库存明细
  247. /// <summary>
  248. /// 增加或修改预发货库存明细信息
  249. /// </summary>
  250. /// <returns></returns>
  251. [HttpPost]
  252. public string Edit(PreSendStockDetail data)
  253. {
  254. Dictionary<string, object> Fields = new Dictionary<string, object>();
  255. Fields.Add("StoreId", data.StoreId);
  256. Fields.Add("StoreId", data.StoreId); //仓库
  257. Fields.Add("BrandId", data.BrandId); //产品类型
  258. Fields.Add("SnId", data.SnId); //SNID
  259. Fields.Add("ToUserId", data.ToUserId); //收货人
  260. Fields.Add("ToStoreId", data.ToStoreId); //收货仓库
  261. Fields.Add("SourceStoreId", data.SourceStoreId); //源仓库编号
  262. Fields.Add("ApplyFlag", data.ApplyFlag); //申请标记
  263. Fields.Add("ApplyDate", data.ApplyDate); //申请时间
  264. Fields.Add("FromUserId", data.FromUserId); //出货创客
  265. Fields.Add("FromStoreId", data.FromStoreId); //出货仓库
  266. Fields.Add("CancelFlag", data.CancelFlag); //撤回标记
  267. Fields.Add("CancelDate", data.CancelDate); //撤回时间
  268. Fields.Add("SeoTitle", data.SeoTitle);
  269. Fields.Add("SeoKeyword", data.SeoKeyword);
  270. Fields.Add("SeoDescription", data.SeoDescription);
  271. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("PreSendStockDetail", Fields, data.Id);
  272. AddSysLog(data.Id.ToString(), "PreSendStockDetail", "update");
  273. db.SaveChanges();
  274. return "success";
  275. }
  276. #endregion
  277. #region 删除预发货库存明细信息
  278. /// <summary>
  279. /// 删除预发货库存明细信息
  280. /// </summary>
  281. /// <returns></returns>
  282. public string Delete(string Id)
  283. {
  284. string[] idlist = Id.Split(new char[] { ',' });
  285. AddSysLog(Id, "PreSendStockDetail", "del");
  286. foreach (string subid in idlist)
  287. {
  288. int id = int.Parse(subid);
  289. Dictionary<string, object> Fields = new Dictionary<string, object>();
  290. Fields.Add("Status", -1);
  291. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("PreSendStockDetail", Fields, id);
  292. }
  293. db.SaveChanges();
  294. return "success";
  295. }
  296. #endregion
  297. #region 开启
  298. /// <summary>
  299. /// 开启
  300. /// </summary>
  301. /// <returns></returns>
  302. public string Open(string Id)
  303. {
  304. string[] idlist = Id.Split(new char[] { ',' });
  305. AddSysLog(Id, "PreSendStockDetail", "open");
  306. foreach (string subid in idlist)
  307. {
  308. int id = int.Parse(subid);
  309. Dictionary<string, object> Fields = new Dictionary<string, object>();
  310. Fields.Add("Status", 1);
  311. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("PreSendStockDetail", Fields, id);
  312. }
  313. db.SaveChanges();
  314. return "success";
  315. }
  316. #endregion
  317. #region 关闭
  318. /// <summary>
  319. /// 关闭
  320. /// </summary>
  321. /// <returns></returns>
  322. public string Close(string Id)
  323. {
  324. string[] idlist = Id.Split(new char[] { ',' });
  325. AddSysLog(Id, "PreSendStockDetail", "close");
  326. foreach (string subid in idlist)
  327. {
  328. int id = int.Parse(subid);
  329. Dictionary<string, object> Fields = new Dictionary<string, object>();
  330. Fields.Add("Status", 0);
  331. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("PreSendStockDetail", Fields, id);
  332. }
  333. db.SaveChanges();
  334. return "success";
  335. }
  336. #endregion
  337. #region 排序
  338. /// <summary>
  339. /// 排序
  340. /// </summary>
  341. /// <param name="Id"></param>
  342. public string Sort(int Id, int Sort)
  343. {
  344. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Sort("PreSendStockDetail", Sort, Id);
  345. AddSysLog(Id.ToString(), "PreSendStockDetail", "sort");
  346. return "success";
  347. }
  348. #endregion
  349. #region 导入数据
  350. /// <summary>
  351. /// 导入数据
  352. /// </summary>
  353. /// <param name="ExcelData"></param>
  354. public string Import(string ExcelData)
  355. {
  356. ExcelData = HttpUtility.UrlDecode(ExcelData);
  357. JsonData list = JsonMapper.ToObject(ExcelData);
  358. for (int i = 1; i < list.Count; i++)
  359. {
  360. JsonData dr = list[i];
  361. db.PreSendStockDetail.Add(new PreSendStockDetail()
  362. {
  363. CreateDate = DateTime.Now,
  364. UpdateDate = DateTime.Now,
  365. });
  366. db.SaveChanges();
  367. }
  368. AddSysLog("0", "PreSendStockDetail", "Import");
  369. return "success";
  370. }
  371. #endregion
  372. #region 导出Excel
  373. /// <summary>
  374. /// 导出Excel
  375. /// </summary>
  376. /// <returns></returns>
  377. public JsonResult ExportExcel(PreSendStockDetail data, string StoreIdStoreName, string StoreIdStoreNo, string BrandIdSelect, string ToUserIdMakerCode, string ToUserIdRealName, string ToStoreIdStoreNo, string ToStoreIdStoreName, string SourceStoreIdStoreNo, string SourceStoreIdStoreName, string FromUserIdMakerCode, string FromUserIdRealName, string FromStoreIdStoreNo, string FromStoreIdStoreName)
  378. {
  379. Dictionary<string, string> Fields = new Dictionary<string, string>();
  380. Fields.Add("CreateDate", "3"); //时间
  381. Fields.Add("SnNo", "1"); //SN编号
  382. Fields.Add("ApplyDate", "3"); //申请时间
  383. string condition = " and Status>-1";
  384. //仓库名称
  385. if (!string.IsNullOrEmpty(StoreIdStoreName))
  386. {
  387. condition += " and StoreId in (select StoreId from SmallStoreHouseForStoreName where StoreName='" + StoreIdStoreName + "')";
  388. }
  389. //仓库编号
  390. if (!string.IsNullOrEmpty(StoreIdStoreNo))
  391. {
  392. condition += " and StoreId in (select StoreId from SmallStoreHouseForStoreNo where StoreNo='" + StoreIdStoreNo + "')";
  393. }
  394. //产品类型
  395. if (!string.IsNullOrEmpty(BrandIdSelect))
  396. {
  397. condition += " and BrandId=" + BrandIdSelect;
  398. }
  399. //收货人创客编号
  400. if (!string.IsNullOrEmpty(ToUserIdMakerCode))
  401. {
  402. condition += " and ToUserId in (select ToUserId from UserForMakerCode where MakerCode='" + ToUserIdMakerCode + "')";
  403. }
  404. //收货人真实姓名
  405. if (!string.IsNullOrEmpty(ToUserIdRealName))
  406. {
  407. condition += " and ToUserId in (select ToUserId from UserForRealName where RealName='" + ToUserIdRealName + "')";
  408. }
  409. //收货仓库编号
  410. if (!string.IsNullOrEmpty(ToStoreIdStoreNo))
  411. {
  412. condition += " and ToStoreId in (select ToStoreId from StoreHouseForStoreNo where StoreNo='" + ToStoreIdStoreNo + "')";
  413. }
  414. //收货仓库名称
  415. if (!string.IsNullOrEmpty(ToStoreIdStoreName))
  416. {
  417. condition += " and ToStoreId in (select ToStoreId from StoreHouseForStoreName where StoreName='" + ToStoreIdStoreName + "')";
  418. }
  419. //源仓库编号仓库编号
  420. if (!string.IsNullOrEmpty(SourceStoreIdStoreNo))
  421. {
  422. condition += " and SourceStoreId in (select SourceStoreId from StoreHouseForStoreNo where StoreNo='" + SourceStoreIdStoreNo + "')";
  423. }
  424. //源仓库编号仓库名称
  425. if (!string.IsNullOrEmpty(SourceStoreIdStoreName))
  426. {
  427. condition += " and SourceStoreId in (select SourceStoreId from StoreHouseForStoreName where StoreName='" + SourceStoreIdStoreName + "')";
  428. }
  429. //出货创客编号
  430. if (!string.IsNullOrEmpty(FromUserIdMakerCode))
  431. {
  432. condition += " and FromUserId in (select FromUserId from UserForMakerCode where MakerCode='" + FromUserIdMakerCode + "')";
  433. }
  434. //出货创客真实姓名
  435. if (!string.IsNullOrEmpty(FromUserIdRealName))
  436. {
  437. condition += " and FromUserId in (select FromUserId from UserForRealName where RealName='" + FromUserIdRealName + "')";
  438. }
  439. //出货仓库编号
  440. if (!string.IsNullOrEmpty(FromStoreIdStoreNo))
  441. {
  442. condition += " and FromStoreId in (select FromStoreId from StoreHouseForStoreNo where StoreNo='" + FromStoreIdStoreNo + "')";
  443. }
  444. //出货仓库名称
  445. if (!string.IsNullOrEmpty(FromStoreIdStoreName))
  446. {
  447. condition += " and FromStoreId in (select FromStoreId from StoreHouseForStoreName where StoreName='" + FromStoreIdStoreName + "')";
  448. }
  449. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("PreSendStockDetail", Fields, "Id desc", "0", 1, 20000, condition, "StoreId,BrandId,SnNo,SnId,ToUserId,ToStoreId,SourceStoreId,ApplyFlag,ApplyDate,FromUserId,FromStoreId,CancelFlag,CancelDate", false);
  450. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  451. foreach (Dictionary<string, object> dic in diclist)
  452. {
  453. //仓库
  454. int StoreId = int.Parse(function.CheckInt(dic["StoreId"].ToString()));
  455. SmallStoreHouse storeid_SmallStoreHouse = db.SmallStoreHouse.FirstOrDefault(m => m.Id == StoreId) ?? new SmallStoreHouse();
  456. dic["StoreIdStoreName"] = storeid_SmallStoreHouse.StoreName;
  457. dic["StoreIdStoreNo"] = storeid_SmallStoreHouse.StoreNo;
  458. dic.Remove("StoreId");
  459. //产品类型
  460. dic["BrandId"] = RelationClass.GetKqProductBrandInfo(int.Parse(dic["BrandId"].ToString()));
  461. //SNID
  462. dic["SnId"] = RelationClass.GetPosMachinesTwoInfo(int.Parse(dic["SnId"].ToString()));
  463. //收货人
  464. int ToUserId = int.Parse(function.CheckInt(dic["ToUserId"].ToString()));
  465. Users touserid_Users = db.Users.FirstOrDefault(m => m.Id == ToUserId) ?? new Users();
  466. dic["ToUserIdMakerCode"] = touserid_Users.MakerCode;
  467. dic["ToUserIdRealName"] = touserid_Users.RealName;
  468. dic.Remove("ToUserId");
  469. //收货仓库
  470. int ToStoreId = int.Parse(function.CheckInt(dic["ToStoreId"].ToString()));
  471. StoreHouse tostoreid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == ToStoreId) ?? new StoreHouse();
  472. dic["ToStoreIdStoreNo"] = tostoreid_StoreHouse.StoreNo;
  473. dic["ToStoreIdStoreName"] = tostoreid_StoreHouse.StoreName;
  474. dic.Remove("ToStoreId");
  475. //源仓库编号
  476. int SourceStoreId = int.Parse(function.CheckInt(dic["SourceStoreId"].ToString()));
  477. StoreHouse sourcestoreid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == SourceStoreId) ?? new StoreHouse();
  478. dic["SourceStoreIdStoreNo"] = sourcestoreid_StoreHouse.StoreNo;
  479. dic["SourceStoreIdStoreName"] = sourcestoreid_StoreHouse.StoreName;
  480. dic.Remove("SourceStoreId");
  481. dic["ApplyFlagName"] = dic["ApplyFlag"].ToString() == "1" ? "是" : "否";
  482. //出货创客
  483. int FromUserId = int.Parse(function.CheckInt(dic["FromUserId"].ToString()));
  484. Users fromuserid_Users = db.Users.FirstOrDefault(m => m.Id == FromUserId) ?? new Users();
  485. dic["FromUserIdMakerCode"] = fromuserid_Users.MakerCode;
  486. dic["FromUserIdRealName"] = fromuserid_Users.RealName;
  487. dic.Remove("FromUserId");
  488. //出货仓库
  489. int FromStoreId = int.Parse(function.CheckInt(dic["FromStoreId"].ToString()));
  490. StoreHouse fromstoreid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == FromStoreId) ?? new StoreHouse();
  491. dic["FromStoreIdStoreNo"] = fromstoreid_StoreHouse.StoreNo;
  492. dic["FromStoreIdStoreName"] = fromstoreid_StoreHouse.StoreName;
  493. dic.Remove("FromStoreId");
  494. dic["CancelFlagName"] = dic["CancelFlag"].ToString() == "1" ? "是" : "否";
  495. }
  496. Dictionary<string, object> result = new Dictionary<string, object>();
  497. result.Add("Status", "1");
  498. result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
  499. result.Add("Obj", diclist);
  500. Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
  501. ReturnFields.Add("StoreIdStoreName", "仓库名称");
  502. ReturnFields.Add("StoreIdStoreNo", "仓库编号");
  503. ReturnFields.Add("BrandId", "产品类型");
  504. ReturnFields.Add("SnNo", "SN编号");
  505. ReturnFields.Add("SnId", "SNID");
  506. ReturnFields.Add("ToUserIdMakerCode", "收货人创客编号");
  507. ReturnFields.Add("ToUserIdRealName", "收货人真实姓名");
  508. ReturnFields.Add("ToStoreIdStoreNo", "收货仓库编号");
  509. ReturnFields.Add("ToStoreIdStoreName", "收货仓库名称");
  510. ReturnFields.Add("SourceStoreIdStoreNo", "源仓库编号仓库编号");
  511. ReturnFields.Add("SourceStoreIdStoreName", "源仓库编号仓库名称");
  512. ReturnFields.Add("ApplyFlag", "申请标记");
  513. ReturnFields.Add("ApplyDate", "申请时间");
  514. ReturnFields.Add("FromUserIdMakerCode", "出货创客编号");
  515. ReturnFields.Add("FromUserIdRealName", "出货创客真实姓名");
  516. ReturnFields.Add("FromStoreIdStoreNo", "出货仓库编号");
  517. ReturnFields.Add("FromStoreIdStoreName", "出货仓库名称");
  518. ReturnFields.Add("CancelFlag", "撤回标记");
  519. ReturnFields.Add("CancelDate", "撤回时间");
  520. result.Add("Fields", ReturnFields);
  521. AddSysLog("0", "PreSendStockDetail", "ExportExcel");
  522. return Json(result);
  523. }
  524. #endregion
  525. #region 预发货库存明细列表(占额度超过30天未兑换)
  526. /// <summary>
  527. /// 根据条件查询预发货库存明细列表(占额度超过30天未兑换)
  528. /// </summary>
  529. /// <returns></returns>
  530. public IActionResult Indexs(PreSendStockDetail data, string right, string StoreId)
  531. {
  532. ViewBag.RightInfo = RightInfo;
  533. ViewBag.right = right;
  534. ViewBag.StoreId = StoreId;
  535. return View();
  536. }
  537. #endregion
  538. #region 根据条件查询预发货库存明细列表(占额度超过30天未兑换)
  539. /// <summary>
  540. /// 根据条件查询预发货库存明细列表(占额度超过30天未兑换)
  541. /// </summary>
  542. /// <returns></returns>
  543. public JsonResult IndexsData(PreSendStockDetail data, string StoreIdStoreName, string StoreIdStoreNo, string CreateDateData, string ApplyDateData, string BrandIdSelect, string ToUserIdMakerCode, string ToUserIdRealName, string ToStoreIdStoreNo, string ToStoreIdStoreName, string SourceStoreIdStoreNo, string SourceStoreIdStoreName, string FromUserIdMakerCode, string FromUserIdRealName, string FromStoreIdStoreNo, string FromStoreIdStoreName, int page = 1, int limit = 30)
  544. {
  545. Dictionary<string, string> Fields = new Dictionary<string, string>();
  546. Fields.Add("StoreId", "1");
  547. // Fields.Add("CreateDate", "3"); //时间
  548. Fields.Add("SnNo", "1"); //SN编号
  549. // Fields.Add("ApplyDate", "3"); //申请时间
  550. // string condition = " and Status>-1 and DATE_SUB(CURDATE(), INTERVAL 30 DAY) >= date(CreateDate) and ApplyFlag =0 and AuthFlag =1";
  551. string condition = " and Status=1 and DATE_SUB(CURDATE(), INTERVAL 30 DAY) >= date(CreateDate) and ApplyFlag =0";
  552. //仓库名称
  553. if (!string.IsNullOrEmpty(StoreIdStoreName))
  554. {
  555. condition += " and StoreId in (select StoreId from StoreForName where Name='" + StoreIdStoreName + "')";
  556. }
  557. //仓库编号
  558. if (!string.IsNullOrEmpty(StoreIdStoreNo))
  559. {
  560. condition += " and StoreId in (select StoreId from StoreForCode where Code='" + StoreIdStoreNo + "')";
  561. }
  562. if (!string.IsNullOrEmpty(CreateDateData))
  563. {
  564. string[] datelist = CreateDateData.Split(new string[] { " - " }, StringSplitOptions.None);
  565. string start = datelist[0];
  566. string end = datelist[1];
  567. condition += " and CreateDate>='" + start + " 00:00:00' and CreateDate<='" + end + " 23:59:59'";
  568. }
  569. if (!string.IsNullOrEmpty(ApplyDateData))
  570. {
  571. string[] datelist = ApplyDateData.Split(new string[] { " - " }, StringSplitOptions.None);
  572. string start = datelist[0];
  573. string end = datelist[1];
  574. condition += " and ApplyDate>='" + start + " 00:00:00' and ApplyDate<='" + end + " 23:59:59'";
  575. }
  576. //产品类型
  577. if (!string.IsNullOrEmpty(BrandIdSelect))
  578. {
  579. condition += " and BrandId=" + BrandIdSelect;
  580. }
  581. //收货人创客编号
  582. if (!string.IsNullOrEmpty(ToUserIdMakerCode))
  583. {
  584. condition += " and ToUserId in (select UserId from UserForMakerCode where MakerCode='" + ToUserIdMakerCode + "')";
  585. }
  586. //收货人真实姓名
  587. if (!string.IsNullOrEmpty(ToUserIdRealName))
  588. {
  589. condition += " and ToUserId in (select UserId from UserForRealName where RealName='" + ToUserIdRealName + "')";
  590. }
  591. //收货仓库编号
  592. if (!string.IsNullOrEmpty(ToStoreIdStoreNo))
  593. {
  594. condition += " and ToStoreId in (select StoreId from StoreForCode where Code='" + ToStoreIdStoreNo + "')";
  595. }
  596. //收货仓库名称
  597. if (!string.IsNullOrEmpty(ToStoreIdStoreName))
  598. {
  599. condition += " and ToStoreId in (select StoreId from StoreForName where Name='" + ToStoreIdStoreName + "')";
  600. }
  601. //源仓库编号仓库编号
  602. if (!string.IsNullOrEmpty(SourceStoreIdStoreNo))
  603. {
  604. condition += " and SourceStoreId in (select StoreId from StoreForCode where Code='" + SourceStoreIdStoreNo + "')";
  605. }
  606. //源仓库编号仓库名称
  607. if (!string.IsNullOrEmpty(SourceStoreIdStoreName))
  608. {
  609. condition += " and SourceStoreId in (select StoreId from StoreForName where Name=='" + SourceStoreIdStoreName + "')";
  610. }
  611. //出货创客编号
  612. if (!string.IsNullOrEmpty(FromUserIdMakerCode))
  613. {
  614. condition += " and FromUserId in (select UserId from UserForMakerCode where MakerCode='" + FromUserIdMakerCode + "')";
  615. }
  616. //出货创客真实姓名
  617. if (!string.IsNullOrEmpty(FromUserIdRealName))
  618. {
  619. condition += " and FromUserId in (select UserId from UserForRealName where RealName='" + FromUserIdRealName + "')";
  620. }
  621. //出货仓库编号
  622. if (!string.IsNullOrEmpty(FromStoreIdStoreNo))
  623. {
  624. condition += " and FromStoreId in (select StoreId from StoreForCode where Code='" + FromStoreIdStoreNo + "')";
  625. }
  626. //出货仓库名称
  627. if (!string.IsNullOrEmpty(FromStoreIdStoreName))
  628. {
  629. condition += " and FromStoreId in (select StoreId from StoreForName where Name='" + FromStoreIdStoreName + "')";
  630. }
  631. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("PreSendStockDetail", Fields, "Id desc", "0", page, limit, condition);
  632. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  633. foreach (Dictionary<string, object> dic in diclist)
  634. {
  635. //仓库
  636. int StoreId = int.Parse(function.CheckInt(dic["StoreId"].ToString()));
  637. SmallStoreHouse storeid_SmallStoreHouse = db.SmallStoreHouse.FirstOrDefault(m => m.Id == StoreId) ?? new SmallStoreHouse();
  638. dic["StoreIdStoreName"] = storeid_SmallStoreHouse.StoreName;
  639. dic["StoreIdStoreNo"] = storeid_SmallStoreHouse.StoreNo;
  640. dic.Remove("StoreId");
  641. //产品类型
  642. dic["BrandId"] = RelationClass.GetKqProductBrandInfo(int.Parse(dic["BrandId"].ToString()));
  643. //收货人
  644. int ToUserId = int.Parse(function.CheckInt(dic["ToUserId"].ToString()));
  645. Users touserid_Users = db.Users.FirstOrDefault(m => m.Id == ToUserId) ?? new Users();
  646. dic["ToUserIdMakerCode"] = touserid_Users.MakerCode;
  647. dic["ToUserIdRealName"] = touserid_Users.RealName;
  648. dic.Remove("ToUserId");
  649. //收货仓库
  650. int ToStoreId = int.Parse(function.CheckInt(dic["ToStoreId"].ToString()));
  651. StoreHouse tostoreid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == ToStoreId) ?? new StoreHouse();
  652. dic["ToStoreIdStoreNo"] = tostoreid_StoreHouse.StoreNo;
  653. dic["ToStoreIdStoreName"] = tostoreid_StoreHouse.StoreName;
  654. dic.Remove("ToStoreId");
  655. //源仓库编号
  656. int SourceStoreId = int.Parse(function.CheckInt(dic["SourceStoreId"].ToString()));
  657. StoreHouse sourcestoreid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == SourceStoreId) ?? new StoreHouse();
  658. dic["SourceStoreIdStoreNo"] = sourcestoreid_StoreHouse.StoreNo;
  659. dic["SourceStoreIdStoreName"] = sourcestoreid_StoreHouse.StoreName;
  660. dic.Remove("SourceStoreId");
  661. dic["ApplyFlagName"] = dic["ApplyFlag"].ToString() == "1" ? "是" : "否";
  662. //出货创客
  663. int FromUserId = int.Parse(function.CheckInt(dic["FromUserId"].ToString()));
  664. Users fromuserid_Users = db.Users.FirstOrDefault(m => m.Id == FromUserId) ?? new Users();
  665. dic["FromUserIdMakerCode"] = fromuserid_Users.MakerCode;
  666. dic["FromUserIdRealName"] = fromuserid_Users.RealName;
  667. dic.Remove("FromUserId");
  668. //出货仓库
  669. int FromStoreId = int.Parse(function.CheckInt(dic["FromStoreId"].ToString()));
  670. StoreHouse fromstoreid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == FromStoreId) ?? new StoreHouse();
  671. dic["FromStoreIdStoreNo"] = fromstoreid_StoreHouse.StoreNo;
  672. dic["FromStoreIdStoreName"] = fromstoreid_StoreHouse.StoreName;
  673. dic.Remove("FromStoreId");
  674. dic["CancelFlagName"] = dic["CancelFlag"].ToString() == "1" ? "是" : "否";
  675. //是否占用额度
  676. int AuthFlag = int.Parse(function.CheckInt(dic["AuthFlag"].ToString()));
  677. if (AuthFlag == 0) dic["PayMode"] = "否";
  678. if (AuthFlag == 1) dic["PayMode"] = "是";
  679. }
  680. return Json(obj);
  681. }
  682. #endregion
  683. }
  684. }