纽威
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

209 lines
7.9 KiB

3 years ago
  1. using NFine.Application.ProductManage;
  2. using NFine.Application.SystemManage;
  3. using NFine.Code;
  4. using NFine.Domain.Entity.ProductManage;
  5. using NFine.Domain.Entity.SystemManage;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Configuration;
  9. using System.Data;
  10. using System.Linq;
  11. using System.Web.Mvc;
  12. namespace NFine.Web.Areas.ProductManage.Controllers
  13. {
  14. public class PreSellController : ControllerBase
  15. {
  16. private MaintainApp maintainApp = new MaintainApp();
  17. private PreSellApp presellApp = new PreSellApp();
  18. private CustomerApp cusapp = new CustomerApp();
  19. [HttpGet]
  20. [HandlerAjaxOnly]
  21. public ActionResult GetGridJson(Pagination pagination, string queryJson)
  22. {
  23. //var data = maintainAppApp.GetList(keyword);
  24. var data = new
  25. {
  26. rows = maintainApp.GetListPS(pagination, queryJson),
  27. total = pagination.total,
  28. page = pagination.page,
  29. records = pagination.records
  30. };
  31. return Content(data.ToJson());
  32. }
  33. public ActionResult GetGridJsonPS(string keyword)
  34. {
  35. var data = presellApp.GetList(keyword);
  36. return Content(data.ToJson());
  37. }
  38. public ActionResult GetOrderNo()
  39. {
  40. string userCode = OperatorProvider.Provider.GetCurrent().UserCode;
  41. string date = DateTime.Now.ToString("yyyyMMdd");
  42. string year = DateTime.Now.ToString("yyyy");
  43. string orderno = userCode + "-" + date + "-";
  44. string no = presellApp.GetOrderNo(orderno);
  45. int newNo = string.IsNullOrEmpty(no) ? 1 : Convert.ToInt32(no.Substring(no.Length - 3, 3)) + 1;
  46. orderno = userCode + "-" + date + "-" + newNo.ToString().PadLeft(3, '0');
  47. return Content(orderno);
  48. }
  49. [HttpGet]
  50. [HandlerAjaxOnly]
  51. public ActionResult GetFormJson(string keyValue)
  52. {
  53. var data = maintainApp.GetForm(keyValue);
  54. return Content(data.ToJson());
  55. }
  56. [HttpGet]
  57. [HandlerAjaxOnly]
  58. public ActionResult GetFormJsonPS(string keyValue)
  59. {
  60. var data = maintainApp.GetForm(keyValue);
  61. return Content(data.ToJson());
  62. }
  63. [HttpPost]
  64. public void Export(string keyValue)
  65. {
  66. string ids = "";
  67. var str = keyValue.Split(',');
  68. for (int i = 0; i < str.Length; i++)
  69. {
  70. if (i == 0)
  71. ids = "'" + str[i].ToString() + "'";
  72. else
  73. ids += ",'" + str[i].ToString() + "'";
  74. }
  75. //var data = maintainApp.GetList2(ids); //preselldetailApp.GetList2(keyValue, keyword);
  76. var data = maintainApp.GetList2All();
  77. DataTable dt = (DataTable)data;
  78. if (dt != null && dt.Rows.Count > 0)
  79. {
  80. //string PreSellNo = presellApp.GetPreSellNo(dt.Rows[0]["F_Id"].ToString());
  81. dt.Columns.Remove("F_Id");
  82. //dt.Columns.Remove("Product_Id");
  83. GridViewExportUtil.Export2(dt);
  84. }
  85. }
  86. [HttpPost]
  87. [HandlerAjaxOnly]
  88. [HandlerAuthorize]
  89. [ValidateAntiForgeryToken]
  90. public ActionResult SubmitForm(string newPreSellNo, string oldPreSell, string IsUse, string keyValue, string cusID, string cusName)
  91. {
  92. string salesmanID = NFine.Code.OperatorProvider.Provider.GetCurrent().UserId;
  93. CustomerEntity cus = cusapp.GetForm(cusID);
  94. //获取选中的产品的ID数组
  95. string[] array = keyValue.Split(',');
  96. ICSProductPreSellEntity ppsEntity = null;
  97. List<ICSProductPreSellDetailEntity> entityList = new List<ICSProductPreSellDetailEntity>();
  98. if (IsUse.ToLower() == "false")
  99. {
  100. //创建新的订单项目
  101. //string GUID = Guid.NewGuid().ToString();
  102. ppsEntity = new ICSProductPreSellEntity();
  103. ppsEntity.F_Id = Common.GuId();
  104. ppsEntity.PreSellNo = newPreSellNo;
  105. ppsEntity.CustomerId = cus.F_Id;
  106. ppsEntity.CustomerName = cus.F_CusName;
  107. ppsEntity.IsConfirm = false;
  108. ppsEntity.F_CreatorUserId = salesmanID;
  109. ppsEntity.F_CreatorTime = DateTime.Now;
  110. ppsEntity.F_Location = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
  111. //根据旧的订单编号插入子表数据
  112. foreach (string productID in array)
  113. {
  114. if (!string.IsNullOrEmpty(productID))
  115. {
  116. ICSProductPreSellDetailEntity entity = new ICSProductPreSellDetailEntity();
  117. //entity.F_Id = Guid.NewGuid().ToString();
  118. entity.PreSell_Id = ppsEntity.F_Id;
  119. entity.Product_Id = productID;
  120. entity.Product_SN = maintainApp.GetForm(productID).ProductSN;
  121. entity.PreSellTime = DateTime.Now;
  122. entity.F_CreatorUserId = salesmanID;
  123. entity.F_CreatorTime = DateTime.Now;
  124. entityList.Add(entity);
  125. }
  126. }
  127. }
  128. else
  129. {
  130. foreach (string productID in array)
  131. {
  132. ICSProductPreSellDetailEntity entity = new ICSProductPreSellDetailEntity();
  133. //entity.F_Id = Guid.NewGuid().ToString();
  134. entity.PreSell_Id = oldPreSell;
  135. entity.Product_Id = productID;
  136. entity.Product_SN = maintainApp.GetForm(productID).ProductSN;
  137. entity.PreSellTime = DateTime.Now;
  138. entity.Status = 2;
  139. entity.F_CreatorUserId = salesmanID;
  140. entity.F_CreatorTime = DateTime.Now;
  141. entityList.Add(entity);
  142. }
  143. }
  144. List<ICSProductEntity> list = new List<ICSProductEntity>();
  145. foreach (string id in array)
  146. {
  147. ICSProductEntity model = new ICSProductEntity();
  148. model = maintainApp.GetForm(id);
  149. model.F_Id = id;
  150. //model.IsLock = true;
  151. list.Add(model);
  152. }
  153. presellApp.SubmitForm(list, ppsEntity, entityList);
  154. string ExpiredDays = presellApp.GetExpiredDays("ExpiredDays");
  155. return Success("Scheduled success.<br/>Your order will expire in " + ExpiredDays + " days. Please confirm the order as soon as possible.");
  156. }
  157. [HttpPost]
  158. [HandlerAjaxOnly]
  159. [HandlerAuthorize]
  160. [ValidateAntiForgeryToken]
  161. public ActionResult DeleteForm(string keyValue)
  162. {
  163. maintainApp.DeleteForm(keyValue);
  164. return Success("Delete success.");
  165. }
  166. [HttpPost]
  167. [HandlerAjaxOnly]
  168. [HandlerAuthorize]
  169. [ValidateAntiForgeryToken]
  170. public ActionResult PreSll(string keyValue)
  171. {
  172. string[] array = keyValue.Split(',');
  173. //for (int i = 0; i < array.Length; i++)
  174. //{
  175. // ids.Add(array[i]);
  176. //}
  177. List<ICSProductEntity> list = new List<ICSProductEntity>();
  178. foreach (string id in array)
  179. {
  180. ICSProductEntity model = new ICSProductEntity();
  181. model.F_Id = id;
  182. model.IsLock = true;
  183. list.Add(model);
  184. }
  185. maintainApp.PrsSell(list);
  186. //model.F_Id =
  187. //UserEntity userEntity = new UserEntity();
  188. //userEntity.F_Id = keyValue
  189. return Success("Scheduled success.");
  190. }
  191. [HttpGet]
  192. public ActionResult Orders()
  193. {
  194. return View();
  195. }
  196. }
  197. }