UserStoreChangeController.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  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 UserStoreChangeController : BaseController
  23. {
  24. public UserStoreChangeController(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(UserStoreChange 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(UserStoreChange data, string UserIdMakerCode, string UserIdRealName, string BindMerchantIdMerchantNo, string BindMerchantIdMerchantName, string BrandIdSelect, string TransTypeSelect, string StockOpDirectSelect, string SnStatusSelect, string BindStatusSelect, string ActiveStatusSelect, string BrandTypeSelect, int page = 1, int limit = 30)
  46. {
  47. Dictionary<string, string> Fields = new Dictionary<string, string>();
  48. Fields.Add("CreateDate", "3"); //时间
  49. Fields.Add("SnNo", "1"); //SN编号
  50. string condition = " and Status>-1";
  51. //创客编号
  52. if (!string.IsNullOrEmpty(UserIdMakerCode))
  53. {
  54. condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + UserIdMakerCode + "')";
  55. }
  56. //创客真实姓名
  57. if (!string.IsNullOrEmpty(UserIdRealName))
  58. {
  59. condition += " and UserId in (select UserId from UserForRealName where RealName='" + UserIdRealName + "')";
  60. }
  61. //产品类型
  62. if (!string.IsNullOrEmpty(BrandIdSelect))
  63. {
  64. condition += " and BrandId=" + BrandIdSelect;
  65. }
  66. //交易类型
  67. if (!string.IsNullOrEmpty(TransTypeSelect))
  68. {
  69. condition += " and TransType=" + TransTypeSelect;
  70. }
  71. //库存操作方向
  72. if (!string.IsNullOrEmpty(StockOpDirectSelect))
  73. {
  74. condition += " and StockOpDirect=" + StockOpDirectSelect;
  75. }
  76. //SN状态
  77. if (!string.IsNullOrEmpty(SnStatusSelect))
  78. {
  79. condition += " and SnStatus=" + SnStatusSelect;
  80. }
  81. //绑定状态
  82. if (!string.IsNullOrEmpty(BindStatusSelect))
  83. {
  84. condition += " and BindStatus=" + BindStatusSelect;
  85. }
  86. //激活状态
  87. if (!string.IsNullOrEmpty(ActiveStatusSelect))
  88. {
  89. condition += " and ActiveStatus=" + ActiveStatusSelect;
  90. }
  91. //绑定商户商户编号
  92. if (!string.IsNullOrEmpty(BindMerchantIdMerchantNo))
  93. {
  94. condition += " and BindMerchantId in (select MerchantId from MerchantForCode where Code='" + BindMerchantIdMerchantNo + "')";
  95. }
  96. //绑定商户商户姓名
  97. if (!string.IsNullOrEmpty(BindMerchantIdMerchantName))
  98. {
  99. condition += " and BindMerchantId in (select MerchantId from MerchantForName where Name='" + BindMerchantIdMerchantName + "')";
  100. }
  101. //品牌类型
  102. if (!string.IsNullOrEmpty(BrandTypeSelect))
  103. {
  104. condition += " and BrandType=" + BrandTypeSelect;
  105. }
  106. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("UserStoreChange", Fields, "Id desc", "0", page, limit, condition);
  107. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  108. foreach (Dictionary<string, object> dic in diclist)
  109. {
  110. //创客
  111. int UserId = int.Parse(function.CheckInt(dic["UserId"].ToString()));
  112. Users userid_Users = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
  113. dic["UserIdMakerCode"] = userid_Users.MakerCode;
  114. dic["UserIdRealName"] = userid_Users.RealName;
  115. dic.Remove("UserId");
  116. //产品类型
  117. dic["BrandId"] = RelationClass.GetKqProductBrandInfo(int.Parse(dic["BrandId"].ToString()));
  118. //交易类型
  119. int TransType = int.Parse(dic["TransType"].ToString());
  120. if (TransType == 10) dic["TransType"] = "领取";
  121. if (TransType == 11) dic["TransType"] = "划拨";
  122. if (TransType == 13) dic["TransType"] = "退货";
  123. if (TransType == 0) dic["TransType"] = "";
  124. //SN机具类型
  125. int SnType = int.Parse(dic["SnType"].ToString());
  126. if (SnType == 0) dic["SnType"] = "购买机具";
  127. if (SnType == 1) dic["SnType"] = "赠送机具";
  128. //库存操作方向
  129. int StockOpDirect = int.Parse(dic["StockOpDirect"].ToString());
  130. if (StockOpDirect == 0) dic["StockOpDirect"] = "入库";
  131. if (StockOpDirect == 1) dic["StockOpDirect"] = "出库";
  132. //收货创客
  133. int ToUserId = int.Parse(function.CheckInt(dic["ToUserId"].ToString()));
  134. Users touserid_Users = db.Users.FirstOrDefault(m => m.Id == ToUserId) ?? new Users();
  135. dic["ToUserIdMakerCode"] = touserid_Users.MakerCode;
  136. dic["ToUserIdRealName"] = touserid_Users.RealName;
  137. dic.Remove("ToUserId");
  138. //创客退货收货仓库
  139. int ToStoreId = int.Parse(function.CheckInt(dic["ToStoreId"].ToString()));
  140. StoreHouse tostoreid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == ToStoreId) ?? new StoreHouse();
  141. dic["ToStoreIdStoreNo"] = tostoreid_StoreHouse.StoreNo;
  142. dic["ToStoreIdStoreName"] = tostoreid_StoreHouse.StoreName;
  143. dic.Remove("ToStoreId");
  144. //源仓库
  145. int SourceStoreId = int.Parse(function.CheckInt(dic["SourceStoreId"].ToString()));
  146. StoreHouse sourcestoreid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == SourceStoreId) ?? new StoreHouse();
  147. dic["SourceStoreIdStoreNo"] = sourcestoreid_StoreHouse.StoreNo;
  148. dic["SourceStoreIdStoreName"] = sourcestoreid_StoreHouse.StoreName;
  149. dic.Remove("SourceStoreId");
  150. //SN状态
  151. int SnStatus = int.Parse(dic["SnStatus"].ToString());
  152. if (SnStatus == 0) dic["SnStatus"] = "未拨出";
  153. if (SnStatus == 1) dic["SnStatus"] = "已拨出";
  154. //绑定状态
  155. int BindStatus = int.Parse(dic["BindStatus"].ToString());
  156. if (BindStatus == 0) dic["BindStatus"] = "未绑定";
  157. if (BindStatus == 1) dic["BindStatus"] = "已绑定";
  158. //绑定商户
  159. int BindMerchantId = int.Parse(function.CheckInt(dic["BindMerchantId"].ToString()));
  160. MerchantInfo bindmerchantid_MerchantInfo = db.MerchantInfo.FirstOrDefault(m => m.Id == BindMerchantId) ?? new MerchantInfo();
  161. dic["BindMerchantIdMerchantNo"] = "";
  162. dic["BindMerchantIdMerchantName"] = bindmerchantid_MerchantInfo.Name;
  163. dic.Remove("BindMerchantId");
  164. //激活状态
  165. int ActiveStatus = int.Parse(dic["ActiveStatus"].ToString());
  166. if (ActiveStatus == 0) dic["ActiveStatus"] = "未激活";
  167. if (ActiveStatus == 1) dic["ActiveStatus"] = "已激活";
  168. //激活奖励创客
  169. int ActRewardUserId = int.Parse(function.CheckInt(dic["ActRewardUserId"].ToString()));
  170. Users actrewarduserid_Users = db.Users.FirstOrDefault(m => m.Id == ActRewardUserId) ?? new Users();
  171. dic["ActRewardUserIdMakerCode"] = actrewarduserid_Users.MakerCode;
  172. dic["ActRewardUserIdRealName"] = actrewarduserid_Users.RealName;
  173. dic.Remove("ActRewardUserId");
  174. //出货创客
  175. int FromUserId = int.Parse(function.CheckInt(dic["FromUserId"].ToString()));
  176. Users fromuserid_Users = db.Users.FirstOrDefault(m => m.Id == FromUserId) ?? new Users();
  177. dic["FromUserIdMakerCode"] = fromuserid_Users.MakerCode;
  178. dic["FromUserIdRealName"] = fromuserid_Users.RealName;
  179. dic.Remove("FromUserId");
  180. }
  181. Dictionary<string, object> other = new Dictionary<string, object>();
  182. other.Add("NotPutNotBindCount", 0);
  183. other.Add("NotPutBindCount", 0);
  184. other.Add("PutNotBindCount", 0);
  185. other.Add("PutBindCount", 0);
  186. other.Add("NotPutNotBindCount2", 0);
  187. other.Add("NotPutBindCount2", 0);
  188. other.Add("PutNotBindCount2", 0);
  189. other.Add("PutBindCount2", 0);
  190. other.Add("NotPutNotBindCount3", 0);
  191. other.Add("NotPutBindCount3", 0);
  192. other.Add("PutNotBindCount3", 0);
  193. other.Add("PutBindCount3", 0);
  194. other.Add("NotPutNotBindCount4", 0);
  195. other.Add("NotPutBindCount4", 0);
  196. other.Add("PutNotBindCount4", 0);
  197. other.Add("PutBindCount4", 0);
  198. obj.Add("other", other);
  199. return Json(obj);
  200. }
  201. #endregion
  202. #region 增加创客库存变动记录
  203. /// <summary>
  204. /// 增加或修改创客库存变动记录信息
  205. /// </summary>
  206. /// <returns></returns>
  207. public IActionResult Add(string right)
  208. {
  209. ViewBag.RightInfo = RightInfo;
  210. ViewBag.right = right;
  211. return View();
  212. }
  213. #endregion
  214. #region 增加创客库存变动记录
  215. /// <summary>
  216. /// 增加或修改创客库存变动记录信息
  217. /// </summary>
  218. /// <returns></returns>
  219. [HttpPost]
  220. public string Add(UserStoreChange data)
  221. {
  222. Dictionary<string, object> Fields = new Dictionary<string, object>();
  223. Fields.Add("SeoTitle", data.SeoTitle);
  224. Fields.Add("SeoKeyword", data.SeoKeyword);
  225. Fields.Add("SeoDescription", data.SeoDescription);
  226. int Id = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Add("UserStoreChange", Fields, 0);
  227. AddSysLog(data.Id.ToString(), "UserStoreChange", "add");
  228. db.SaveChanges();
  229. return "success";
  230. }
  231. #endregion
  232. #region 修改创客库存变动记录
  233. /// <summary>
  234. /// 增加或修改创客库存变动记录信息
  235. /// </summary>
  236. /// <returns></returns>
  237. public IActionResult Edit(string right, int Id = 0)
  238. {
  239. ViewBag.RightInfo = RightInfo;
  240. ViewBag.right = right;
  241. UserStoreChange editData = db.UserStoreChange.FirstOrDefault(m => m.Id == Id) ?? new UserStoreChange();
  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(UserStoreChange data)
  253. {
  254. Dictionary<string, object> Fields = new Dictionary<string, object>();
  255. Fields.Add("SeoTitle", data.SeoTitle);
  256. Fields.Add("SeoKeyword", data.SeoKeyword);
  257. Fields.Add("SeoDescription", data.SeoDescription);
  258. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("UserStoreChange", Fields, data.Id);
  259. AddSysLog(data.Id.ToString(), "UserStoreChange", "update");
  260. db.SaveChanges();
  261. return "success";
  262. }
  263. #endregion
  264. #region 删除创客库存变动记录信息
  265. /// <summary>
  266. /// 删除创客库存变动记录信息
  267. /// </summary>
  268. /// <returns></returns>
  269. public string Delete(string Id)
  270. {
  271. string[] idlist = Id.Split(new char[] { ',' });
  272. AddSysLog(Id, "UserStoreChange", "del");
  273. foreach (string subid in idlist)
  274. {
  275. int id = int.Parse(subid);
  276. Dictionary<string, object> Fields = new Dictionary<string, object>();
  277. Fields.Add("Status", -1);
  278. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("UserStoreChange", Fields, id);
  279. }
  280. db.SaveChanges();
  281. return "success";
  282. }
  283. #endregion
  284. #region 开启
  285. /// <summary>
  286. /// 开启
  287. /// </summary>
  288. /// <returns></returns>
  289. public string Open(string Id)
  290. {
  291. string[] idlist = Id.Split(new char[] { ',' });
  292. AddSysLog(Id, "UserStoreChange", "open");
  293. foreach (string subid in idlist)
  294. {
  295. int id = int.Parse(subid);
  296. Dictionary<string, object> Fields = new Dictionary<string, object>();
  297. Fields.Add("Status", 1);
  298. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("UserStoreChange", Fields, id);
  299. }
  300. db.SaveChanges();
  301. return "success";
  302. }
  303. #endregion
  304. #region 关闭
  305. /// <summary>
  306. /// 关闭
  307. /// </summary>
  308. /// <returns></returns>
  309. public string Close(string Id)
  310. {
  311. string[] idlist = Id.Split(new char[] { ',' });
  312. AddSysLog(Id, "UserStoreChange", "close");
  313. foreach (string subid in idlist)
  314. {
  315. int id = int.Parse(subid);
  316. Dictionary<string, object> Fields = new Dictionary<string, object>();
  317. Fields.Add("Status", 0);
  318. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("UserStoreChange", Fields, id);
  319. }
  320. db.SaveChanges();
  321. return "success";
  322. }
  323. #endregion
  324. #region 排序
  325. /// <summary>
  326. /// 排序
  327. /// </summary>
  328. /// <param name="Id"></param>
  329. public string Sort(int Id, int Sort)
  330. {
  331. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Sort("UserStoreChange", Sort, Id);
  332. AddSysLog(Id.ToString(), "UserStoreChange", "sort");
  333. return "success";
  334. }
  335. #endregion
  336. #region 导入数据
  337. /// <summary>
  338. /// 导入数据
  339. /// </summary>
  340. /// <param name="ExcelData"></param>
  341. public string Import(string ExcelData)
  342. {
  343. ExcelData = HttpUtility.UrlDecode(ExcelData);
  344. JsonData list = JsonMapper.ToObject(ExcelData);
  345. for (int i = 1; i < list.Count; i++)
  346. {
  347. JsonData dr = list[i];
  348. db.UserStoreChange.Add(new UserStoreChange()
  349. {
  350. CreateDate = DateTime.Now,
  351. UpdateDate = DateTime.Now,
  352. });
  353. db.SaveChanges();
  354. }
  355. AddSysLog("0", "UserStoreChange", "Import");
  356. return "success";
  357. }
  358. #endregion
  359. #region 导出Excel
  360. /// <summary>
  361. /// 导出Excel
  362. /// </summary>
  363. /// <returns></returns>
  364. public JsonResult ExportExcel(UserStoreChange data, string UserIdMakerCode, string UserIdRealName, string BindMerchantIdMerchantNo, string BindMerchantIdMerchantName, string BrandIdSelect, string TransTypeSelect, string StockOpDirectSelect, string SnStatusSelect, string BindStatusSelect, string ActiveStatusSelect, string BrandTypeSelect)
  365. {
  366. Dictionary<string, string> Fields = new Dictionary<string, string>();
  367. Fields.Add("CreateDate", "3"); //时间
  368. Fields.Add("SnNo", "1"); //SN编号
  369. string condition = " and Status>-1";
  370. //创客编号
  371. if (!string.IsNullOrEmpty(UserIdMakerCode))
  372. {
  373. condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + UserIdMakerCode + "')";
  374. }
  375. //创客真实姓名
  376. if (!string.IsNullOrEmpty(UserIdRealName))
  377. {
  378. condition += " and UserId in (select UserId from UserForRealName where RealName='" + UserIdRealName + "')";
  379. }
  380. //产品类型
  381. if (!string.IsNullOrEmpty(BrandIdSelect))
  382. {
  383. condition += " and BrandId=" + BrandIdSelect;
  384. }
  385. //交易类型
  386. if (!string.IsNullOrEmpty(TransTypeSelect))
  387. {
  388. condition += " and TransType=" + TransTypeSelect;
  389. }
  390. //库存操作方向
  391. if (!string.IsNullOrEmpty(StockOpDirectSelect))
  392. {
  393. condition += " and StockOpDirect=" + StockOpDirectSelect;
  394. }
  395. //SN状态
  396. if (!string.IsNullOrEmpty(SnStatusSelect))
  397. {
  398. condition += " and SnStatus=" + SnStatusSelect;
  399. }
  400. //绑定状态
  401. if (!string.IsNullOrEmpty(BindStatusSelect))
  402. {
  403. condition += " and BindStatus=" + BindStatusSelect;
  404. }
  405. //激活状态
  406. if (!string.IsNullOrEmpty(ActiveStatusSelect))
  407. {
  408. condition += " and ActiveStatus=" + ActiveStatusSelect;
  409. }
  410. //绑定商户商户编号
  411. if (!string.IsNullOrEmpty(BindMerchantIdMerchantNo))
  412. {
  413. condition += " and BindMerchantId in (select MerchantId from MerchantForCode where Code='" + BindMerchantIdMerchantNo + "')";
  414. }
  415. //绑定商户商户姓名
  416. if (!string.IsNullOrEmpty(BindMerchantIdMerchantName))
  417. {
  418. condition += " and BindMerchantId in (select MerchantId from MerchantForName where Name='" + BindMerchantIdMerchantName + "')";
  419. }
  420. //品牌类型
  421. if (!string.IsNullOrEmpty(BrandTypeSelect))
  422. {
  423. condition += " and BrandType=" + BrandTypeSelect;
  424. }
  425. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("UserStoreChange", Fields, "Id desc", "0", 1, 20000, condition, "UserId,BrandId,TransType,SnNo,SnType,StockOpDirect,ToUserId,ToStoreId,SourceStoreId,SnStatus,BindStatus,BindMerchantId,ActiveStatus,ActRewardUserId,FromUserId,CreateDate", false);
  426. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  427. foreach (Dictionary<string, object> dic in diclist)
  428. {
  429. //创客
  430. int UserId = int.Parse(function.CheckInt(dic["UserId"].ToString()));
  431. Users userid_Users = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
  432. dic["UserIdMakerCode"] = userid_Users.MakerCode;
  433. dic["UserIdRealName"] = userid_Users.RealName;
  434. dic.Remove("UserId");
  435. //产品类型
  436. dic["BrandId"] = RelationClass.GetKqProductBrandInfo(int.Parse(dic["BrandId"].ToString()));
  437. //交易类型
  438. int TransType = int.Parse(dic["TransType"].ToString());
  439. if (TransType == 10) dic["TransType"] = "领取";
  440. if (TransType == 11) dic["TransType"] = "划拨";
  441. if (TransType == 13) dic["TransType"] = "退货";
  442. if (TransType == 0) dic["TransType"] = "";
  443. //SN机具类型
  444. int SnType = int.Parse(dic["SnType"].ToString());
  445. if (SnType == 0) dic["SnType"] = "购买机具";
  446. if (SnType == 1) dic["SnType"] = "赠送机具";
  447. //库存操作方向
  448. int StockOpDirect = int.Parse(dic["StockOpDirect"].ToString());
  449. if (StockOpDirect == 0) dic["StockOpDirect"] = "入库";
  450. if (StockOpDirect == 1) dic["StockOpDirect"] = "出库";
  451. //收货创客
  452. int ToUserId = int.Parse(function.CheckInt(dic["ToUserId"].ToString()));
  453. Users touserid_Users = db.Users.FirstOrDefault(m => m.Id == ToUserId) ?? new Users();
  454. dic["ToUserIdMakerCode"] = touserid_Users.MakerCode;
  455. dic["ToUserIdRealName"] = touserid_Users.RealName;
  456. dic.Remove("ToUserId");
  457. //创客退货收货仓库
  458. int ToStoreId = int.Parse(function.CheckInt(dic["ToStoreId"].ToString()));
  459. StoreHouse tostoreid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == ToStoreId) ?? new StoreHouse();
  460. dic["ToStoreIdStoreNo"] = tostoreid_StoreHouse.StoreNo;
  461. dic["ToStoreIdStoreName"] = tostoreid_StoreHouse.StoreName;
  462. dic.Remove("ToStoreId");
  463. //源仓库
  464. int SourceStoreId = int.Parse(function.CheckInt(dic["SourceStoreId"].ToString()));
  465. StoreHouse sourcestoreid_StoreHouse = db.StoreHouse.FirstOrDefault(m => m.Id == SourceStoreId) ?? new StoreHouse();
  466. dic["SourceStoreIdStoreNo"] = sourcestoreid_StoreHouse.StoreNo;
  467. dic["SourceStoreIdStoreName"] = sourcestoreid_StoreHouse.StoreName;
  468. dic.Remove("SourceStoreId");
  469. //SN状态
  470. int SnStatus = int.Parse(dic["SnStatus"].ToString());
  471. if (SnStatus == 0) dic["SnStatus"] = "未拨出";
  472. if (SnStatus == 1) dic["SnStatus"] = "已拨出";
  473. //绑定状态
  474. int BindStatus = int.Parse(dic["BindStatus"].ToString());
  475. if (BindStatus == 0) dic["BindStatus"] = "未绑定";
  476. if (BindStatus == 1) dic["BindStatus"] = "已绑定";
  477. //绑定商户
  478. int BindMerchantId = int.Parse(function.CheckInt(dic["BindMerchantId"].ToString()));
  479. MerchantInfo bindmerchantid_MerchantInfo = db.MerchantInfo.FirstOrDefault(m => m.Id == BindMerchantId) ?? new MerchantInfo();
  480. dic["BindMerchantIdMerchantNo"] = "";
  481. dic["BindMerchantIdMerchantName"] = bindmerchantid_MerchantInfo.Name;
  482. dic.Remove("BindMerchantId");
  483. //激活状态
  484. int ActiveStatus = int.Parse(dic["ActiveStatus"].ToString());
  485. if (ActiveStatus == 0) dic["ActiveStatus"] = "未激活";
  486. if (ActiveStatus == 1) dic["ActiveStatus"] = "已激活";
  487. //激活奖励创客
  488. int ActRewardUserId = int.Parse(function.CheckInt(dic["ActRewardUserId"].ToString()));
  489. Users actrewarduserid_Users = db.Users.FirstOrDefault(m => m.Id == ActRewardUserId) ?? new Users();
  490. dic["ActRewardUserIdMakerCode"] = actrewarduserid_Users.MakerCode;
  491. dic["ActRewardUserIdRealName"] = actrewarduserid_Users.RealName;
  492. dic.Remove("ActRewardUserId");
  493. //出货创客
  494. int FromUserId = int.Parse(function.CheckInt(dic["FromUserId"].ToString()));
  495. Users fromuserid_Users = db.Users.FirstOrDefault(m => m.Id == FromUserId) ?? new Users();
  496. dic["FromUserIdMakerCode"] = fromuserid_Users.MakerCode;
  497. dic["FromUserIdRealName"] = fromuserid_Users.RealName;
  498. dic.Remove("FromUserId");
  499. }
  500. Dictionary<string, object> result = new Dictionary<string, object>();
  501. result.Add("Status", "1");
  502. result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
  503. result.Add("Obj", diclist);
  504. Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
  505. ReturnFields.Add("UserIdMakerCode", "创客编号");
  506. ReturnFields.Add("UserIdRealName", "创客真实姓名");
  507. ReturnFields.Add("BrandId", "产品类型");
  508. ReturnFields.Add("TransType", "交易类型");
  509. ReturnFields.Add("SnNo", "SN编号");
  510. ReturnFields.Add("SnType", "SN机具类型");
  511. ReturnFields.Add("StockOpDirect", "库存操作方向");
  512. ReturnFields.Add("ToUserIdMakerCode", "收货创客编号");
  513. ReturnFields.Add("ToUserIdRealName", "收货创客真实姓名");
  514. ReturnFields.Add("ToStoreIdStoreNo", "创客退货收货仓库编号");
  515. ReturnFields.Add("ToStoreIdStoreName", "创客退货收货仓库名称");
  516. ReturnFields.Add("SourceStoreIdStoreNo", "源仓库编号");
  517. ReturnFields.Add("SourceStoreIdStoreName", "源仓库名称");
  518. ReturnFields.Add("SnStatus", "SN状态");
  519. ReturnFields.Add("BindStatus", "绑定状态");
  520. ReturnFields.Add("BindMerchantIdMerchantNo", "绑定商户编号");
  521. ReturnFields.Add("BindMerchantIdMerchantName", "绑定商户姓名");
  522. ReturnFields.Add("ActiveStatus", "激活状态");
  523. ReturnFields.Add("ActRewardUserIdMakerCode", "激活奖励创客编号");
  524. ReturnFields.Add("ActRewardUserIdRealName", "激活奖励创客真实姓名");
  525. ReturnFields.Add("FromUserIdMakerCode", "出货创客编号");
  526. ReturnFields.Add("FromUserIdRealName", "出货创客真实姓名");
  527. ReturnFields.Add("CreateDate", "变动时间");
  528. result.Add("Fields", ReturnFields);
  529. AddSysLog("0", "UserStoreChange", "ExportExcel");
  530. return Json(result);
  531. }
  532. #endregion
  533. }
  534. }