FBAOrderController.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. using Microsoft.AspNetCore.Mvc;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Threading.Tasks;
  6. using XYY.Authentication.Standard;
  7. using XYY.Common.Standard;
  8. using XYY.Core.Standard.Mvc;
  9. using XYY.Model.Standard.Dto.MpsOrder;
  10. using XYY.Model.Standard.Finance;
  11. using XYY.Model.Standard.MpsOrder;
  12. using XYY.Model.Standard.MpsOrder.dto;
  13. using XYY.Model.Standard.MpsOrder.views;
  14. using XYY.Service.Standard.Order.FBA;
  15. namespace XYY.Api.Order.Controllers.FBA
  16. {
  17. [Route("api/[controller]/[action]")]
  18. [ApiController]
  19. public class FBAOrderController : ApiControllerBase
  20. {
  21. IFBAOrderService orderService;
  22. public FBAOrderController(IFBAOrderService orderService)
  23. {
  24. this.orderService = orderService;
  25. }
  26. #region 空派收件
  27. public async Task<IActionResult> GetReceivingInfo(QueryModel queryModel)
  28. {
  29. if (queryModel?.QueryParamer != null && queryModel.QueryParamer.Any(x => x.Filed == "IsGoodsNames"))
  30. {
  31. var tempParamer = queryModel.QueryParamer.Where(x => x.Filed == "IsGoodsNames").FirstOrDefault();
  32. if (tempParamer.Value == "1") { queryModel.QueryParamer.Add(new QueryParamer() { Filed = "GoodsNames", Method = "IsNotNl", Value = "" }); }
  33. else if (tempParamer.Value == "2") { queryModel.QueryParamer.Add(new QueryParamer() { Filed = "GoodsNames", Method = "IsNl", Value = "" }); }
  34. queryModel.QueryParamer.Remove(tempParamer);
  35. }
  36. var data = await this.orderService.GetReceivingInfo(queryModel);
  37. return Ok(data);
  38. }
  39. public async Task<IActionResult> GetReceivingBoxs(int Id)
  40. {
  41. var data = await this.orderService.GetReceivingBoxs(new List<int>() { Id });
  42. return Ok(data);
  43. }
  44. public async Task<IActionResult> GetReceivingBoxsByIds(IEnumerable<int> Ids)
  45. {
  46. var data = await this.orderService.GetReceivingBoxs(Ids);
  47. return Ok(data);
  48. }
  49. public async Task<IActionResult> UpdateReceivingBoxs(List<Order_MpsOrderBox> boxs)
  50. {
  51. var data = await this.orderService.UpdateReceivingBoxs(boxs);
  52. return Ok(data);
  53. }
  54. public async Task<IActionResult> GoToPrint(IEnumerable<int> Ids)
  55. {
  56. var data = await this.orderService.GoToPrint(Ids);
  57. return Ok(data);
  58. }
  59. public async Task<IActionResult> UpdateFile(string BoxNumber)
  60. {
  61. var boxPicInfo = await orderService.GetBoxPictureOrderInfo(BoxNumber);
  62. var filelist = (await Request.ReadFormAsync()).Files;
  63. foreach (var file in filelist)
  64. {
  65. var result = await orderService.UpdateBoxPicture(boxPicInfo, file.OpenReadStream());
  66. }
  67. return Ok();
  68. }
  69. public async Task<IActionResult> GetBoxPictures(string BoxNumber)
  70. {
  71. var data = await orderService.GetBoxPictures(BoxNumber);
  72. return Ok(data);
  73. }
  74. public async Task<IActionResult> RemoveBoxPicture(int[] PicIds)
  75. {
  76. var data = await orderService.RemoveBoxPicture(PicIds);
  77. return Ok(data);
  78. }
  79. [HttpPost]
  80. public async Task<IActionResult> ImportMpsBoxAddresseeInfo()
  81. {
  82. var filelist = (await Request.ReadFormAsync()).Files;
  83. if (filelist != null && filelist.Count > 0)
  84. {
  85. var u = User.GetUserContent();
  86. string userName = u.NiceName;
  87. var file = filelist[0];
  88. var result = await orderService.ImportMpsBoxAddresseeInfo(file.OpenReadStream(), userName);
  89. return Ok(result);
  90. }
  91. else
  92. {
  93. return Error("请上传一个文件");
  94. }
  95. }
  96. #endregion
  97. //public async Task<IActionResult> GetOrderReceivingInfo(int orderId)
  98. //{
  99. // var data = await this.orderService.GetOrderReceivingInfo(orderId);
  100. // return Ok(data);
  101. //}
  102. //public async Task<IActionResult> SaveOrderRceiveingInfo(View_Order_ReceivingInfo View_Order_ReceivingInfo)
  103. //{
  104. // await this.orderService.SaveOrderRceiveingInfo(View_Order_ReceivingInfo);
  105. // return Ok();
  106. //}
  107. #region 空派打单
  108. public async Task<IActionResult> GetPrintList(QueryModel queryModel)
  109. {
  110. if (queryModel?.QueryParamer != null && queryModel.QueryParamer.Any(x => x.Filed == "IsXYY"))
  111. {
  112. var tempParamer = queryModel.QueryParamer.Where(x => x.Filed == "IsXYY").FirstOrDefault();
  113. if (tempParamer.Value == "1") { queryModel.QueryParamer.Add(new QueryParamer() { Filed = "LEFT(TrackingNumber,3)", Method = "NotEq", Value = "XYY" }); }
  114. else if (tempParamer.Value == "2") { queryModel.QueryParamer.Add(new QueryParamer() { Filed = "LEFT(TrackingNumber,3)", Method = "Eq", Value = "XYY" }); }
  115. queryModel.QueryParamer.Remove(tempParamer);
  116. }
  117. if (queryModel?.QueryParamer != null && queryModel.QueryParamer.Any(x => x.Filed == "IsOrderPrintQty"))
  118. {
  119. var tempParamer = queryModel.QueryParamer.Where(x => x.Filed == "IsOrderPrintQty").FirstOrDefault();
  120. if (tempParamer.Value == "1") { queryModel.QueryParamer.Add(new QueryParamer() { Filed = "isnull(OrderPrintQty,0)", Method = "Eq", Value = "1" }); }
  121. else if (tempParamer.Value == "2") { queryModel.QueryParamer.Add(new QueryParamer() { Filed = "isnull(OrderPrintQty,0)", Method = "Eq", Value = "0" }); }
  122. queryModel.QueryParamer.Remove(tempParamer);
  123. }
  124. var data = await this.orderService.GetPrintList(queryModel);
  125. return Ok(data);
  126. }
  127. public async Task<IActionResult> GetPrint(int orderId)
  128. {
  129. var data = await this.orderService.GetPrint(orderId);
  130. return Ok(data);
  131. }
  132. public async Task<IActionResult> GetReceivingBoxsGoods(int Id)
  133. {
  134. var data = await this.orderService.GetReceivingGoods(Id);
  135. return Ok(data);
  136. }
  137. public async Task<IActionResult> GetReceivingAddress(int Id)
  138. {
  139. var data = await this.orderService.GetReceivingAddress(Id);
  140. return Ok(data);
  141. }
  142. public async Task<IActionResult> UpdatePrintBoxs(MpsPrint boxs)
  143. {
  144. var data = await this.orderService.UpdatePrintBoxs(boxs);
  145. return Ok(data);
  146. }
  147. public async Task<IActionResult> GoToIncome(IEnumerable<int> Ids)
  148. {
  149. var data = await this.orderService.GoToIncome(Ids);
  150. return Ok(data);
  151. }
  152. public async Task<IActionResult> UpdateOrderPrintQty(int orderId, bool OrderPrintQty)
  153. {
  154. var data = await this.orderService.UpdateOrderPrintQty(orderId, OrderPrintQty);
  155. return Ok(data);
  156. }
  157. public async Task<IActionResult> BatchUpdateOrderPrintQty(IEnumerable<int> Ids)
  158. {
  159. var data = await this.orderService.BatchUpdateOrderPrintQty(Ids);
  160. return Ok(data);
  161. }
  162. #endregion
  163. //public async Task<IActionResult> SavePrintInfos(View_Order_Print View_Order_ReceivingInfo)
  164. //{
  165. // await this.orderService.SavePrintInfos(View_Order_ReceivingInfo);
  166. // return Ok();
  167. //}
  168. #region 空派收入
  169. public async Task<IActionResult> GetCustomerConfirmList(QueryModel queryModel)
  170. {
  171. //判断用户角色
  172. var u = User.GetUserContent();
  173. if (u.Roles.Contains("销售"))
  174. {
  175. if (queryModel?.QueryParamer != null)
  176. { queryModel.QueryParamer.Add(new QueryParamer() { Filed = "NickName", Method = "Eq", Value = u.NiceName }); }
  177. else
  178. { queryModel.QueryParamer = new List<QueryParamer>(); queryModel.QueryParamer.Add(new QueryParamer() { Filed = "NickName", Method = "Eq", Value = u.NiceName }); }
  179. }
  180. if (queryModel?.QueryParamer != null && queryModel.QueryParamer.Any(x => x.Filed == "IsConfim"))
  181. {
  182. var tempParamer = queryModel.QueryParamer.Where(x => x.Filed == "IsConfim").FirstOrDefault();
  183. if (tempParamer.Value == "1") { queryModel.QueryParamer.Add(new QueryParamer() { Filed = "isnull(SalesmanConfirmFee,0)", Method = "Gr", Value = "0" }); }
  184. else if (tempParamer.Value == "2") { queryModel.QueryParamer.Add(new QueryParamer() { Filed = "isnull(SalesmanConfirmFee,0)", Method = "LeE", Value = "0" }); }
  185. queryModel.QueryParamer.Remove(tempParamer);
  186. }
  187. var data = await this.orderService.GetCustomerConfirmList(queryModel);
  188. return Ok(data);
  189. }
  190. public async Task<IActionResult> GetCustomerConfirm(int orderId)
  191. {
  192. var data = await this.orderService.GetCustomerConfirm(orderId);
  193. return Ok(data);
  194. }
  195. public async Task<IActionResult> UpdateCustomerConfirm(MpsCustomerConfirm dto)
  196. {
  197. var data = await this.orderService.UpdateCustomerConfirm(dto);
  198. return Ok(data);
  199. }
  200. public async Task<IActionResult> GetBatchConfirmWeight(IEnumerable<int> Ids)
  201. {
  202. var data = await this.orderService.GetBatchConfirmWeight(Ids);
  203. return Ok(data);
  204. }
  205. public async Task<IActionResult> UpdateBatchConfirmWeight(List<ConfirmWeight> confirmWeights)
  206. {
  207. var data = await this.orderService.UpdateBatchConfirmWeight(confirmWeights);
  208. return Ok();
  209. }
  210. public async Task<IActionResult> GetBatchConfirmIncidenta(IEnumerable<int> Ids)
  211. {
  212. var data = await this.orderService.GetBatchIncidenta(Ids, XYY.Model.Standard.Finance.FBAIncidentalCalculateTarget.客户);
  213. data = data.OrderBy(x => x.OrderId).ToList();
  214. return Ok(data);
  215. }
  216. public async Task<IActionResult> UpdateBatchConfirmIncidenta(List<FBA_Incidental> incidentals)
  217. {
  218. var data = await this.orderService.UpdateBatchConfirmIncidenta(incidentals);
  219. return Ok();
  220. }
  221. public async Task<IActionResult> GoToSettlement(IEnumerable<int> Ids)
  222. {
  223. var u = User.GetUserContent();
  224. var data = await this.orderService.GoToSettlement(Ids, u.NiceName);
  225. return Ok(data);
  226. }
  227. public async Task<IActionResult> ExportWaitConfirm(IEnumerable<int> Ids)
  228. {
  229. byte[] data = await orderService.ExportWaitConfirm(Ids);
  230. return File(data, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", DateTime.Now.ToString_yyyyMMddHHmm() + ".xls");
  231. }
  232. public async Task<IActionResult> GetBoxIDCR(Order_MpsOrderBox box)
  233. {
  234. string data = await orderService.GetBoxIDCR(box);
  235. return Ok(data);
  236. }
  237. public async Task<IActionResult> SalesmanConfirmFee(int Id)
  238. {
  239. var data = await orderService.SalesmanConfirmFee(Id);
  240. return Ok(data);
  241. }
  242. /// <summary>
  243. /// 修改创建渠道
  244. /// </summary>
  245. /// <returns></returns>
  246. [HttpPost]
  247. public async Task<IActionResult> ModifyCreateOrderChannelId(MpsModifyCreateOrderChannelId mpsModify)
  248. {
  249. var u = User.GetUserContent();
  250. await orderService.ModifyCreateOrderChannelId(mpsModify, u);
  251. return Ok();
  252. }
  253. //修复一下新增的计算计费 实重/泡重 数据
  254. public async Task<IActionResult> RepairSettlementData(List<int> Ids)
  255. {
  256. var data = await orderService.RepairSettlementData(Ids);
  257. return Ok(data);
  258. }
  259. #endregion
  260. #region 单价获取
  261. public async Task<IActionResult> GetUnitPrice(KPUnitPriceRequest request)
  262. {
  263. var data = await this.orderService.GetUnitPrice(request);
  264. return Ok(data);
  265. }
  266. #endregion
  267. #region 结算
  268. public async Task<IActionResult> GetSettlementConfirmList(QueryModel queryModel)
  269. {
  270. if (queryModel?.QueryParamer != null && queryModel.QueryParamer.Any(x => x.Filed == "IsConfim"))
  271. {
  272. var tempParamer = queryModel.QueryParamer.Where(x => x.Filed == "IsConfim").FirstOrDefault();
  273. if (tempParamer.Value == "1") { queryModel.QueryParamer.Add(new QueryParamer() { Filed = "isnull(IsSettlementConfirm,0)", Method = "Eq", Value = "1" }); }
  274. else if (tempParamer.Value == "2") { queryModel.QueryParamer.Add(new QueryParamer() { Filed = "isnull(IsSettlementConfirm,0)", Method = "Eq", Value = "0" }); }
  275. queryModel.QueryParamer.Remove(tempParamer);
  276. }
  277. var data = await this.orderService.GetSettlementConfirmList(queryModel);
  278. return Ok(data);
  279. }
  280. public async Task<IActionResult> ExportEnd(QueryModel queryModel)
  281. {
  282. if (queryModel?.QueryParamer != null && queryModel.QueryParamer.Any(x => x.Filed == "IsConfim"))
  283. {
  284. var tempParamer = queryModel.QueryParamer.Where(x => x.Filed == "IsConfim").FirstOrDefault();
  285. if (tempParamer.Value == "1") { queryModel.QueryParamer.Add(new QueryParamer() { Filed = "isnull(IsSettlementConfirm,0)", Method = "Eq", Value = "1" }); }
  286. else if (tempParamer.Value == "2") { queryModel.QueryParamer.Add(new QueryParamer() { Filed = "isnull(IsSettlementConfirm,0)", Method = "Eq", Value = "0" }); }
  287. queryModel.QueryParamer.Remove(tempParamer);
  288. }
  289. byte[] data = await orderService.ExportSettlementConfirm(queryModel);
  290. return File(data, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", DateTime.Now.ToString_yyyyMMddHHmm() + ".xls");
  291. }
  292. public async Task<IActionResult> GetSettlementConfirm(int orderId)
  293. {
  294. var data = await this.orderService.GetSettlementConfirm(orderId);
  295. return Ok(data);
  296. }
  297. public async Task<IActionResult> GetBatchSettlementWeight(IEnumerable<int> Ids)
  298. {
  299. var data = await this.orderService.GetBatchSettlementWeight(Ids);
  300. return Ok(data);
  301. }
  302. public async Task<IActionResult> UpdateBatchSettlementWeight(List<ConfirmWeight> confirmWeights)
  303. {
  304. var data = await this.orderService.UpdateBatchSettlementWeight(confirmWeights);
  305. return Ok();
  306. }
  307. public async Task<IActionResult> UpdateSettlementConfirm(MpsSettlementConfirm dto)
  308. {
  309. var data = await this.orderService.UpdateSettlementConfirm(dto);
  310. return Ok(data);
  311. }
  312. public async Task<IActionResult> GetBatchSettlementIncidenta(IEnumerable<int> Ids)
  313. {
  314. var data = await this.orderService.GetBatchIncidenta(Ids, XYY.Model.Standard.Finance.FBAIncidentalCalculateTarget.结算价);
  315. data = data.OrderBy(x => x.OrderId).ToList();
  316. return Ok(data);
  317. }
  318. public async Task<IActionResult> UpdateBatchSettlementIncidenta(List<FBA_Incidental> incidentals)
  319. {
  320. var data = await this.orderService.UpdateBatchSettlementIncidenta(incidentals);
  321. return Ok();
  322. }
  323. public async Task<IActionResult> UpdateSettlementConfirmForTable(MpsSettlementConfirmTableData dto)
  324. {
  325. var data = await this.orderService.UpdateSettlementConfirmForTable(dto);
  326. return Ok(data);
  327. }
  328. public async Task<IActionResult> SettlementConfirmOperation(int orderId)
  329. {
  330. var u = User.GetUserContent();
  331. var data = await this.orderService.SettlementConfirmOperation(orderId, u.NiceName);
  332. return Ok(data);
  333. }
  334. public async Task<IActionResult> GoToEnd(IEnumerable<int> Ids)
  335. {
  336. var u = User.GetUserContent();
  337. var data = await this.orderService.GoToEnd(Ids, u.NiceName);
  338. return Ok(data);
  339. }
  340. //重算订单结算数据
  341. public async Task<IActionResult> recalculationOrderSettlementPrice(List<int> Ids)
  342. {
  343. await orderService.CalculateSettlementPrice(Ids);
  344. return Ok();
  345. }
  346. #endregion
  347. public async Task<IActionResult> SaveCustomerConfirm(View_Order_CustomerConfirm View_Order_CustomerConfirm)
  348. {
  349. await this.orderService.SaveCustomerConfirm(View_Order_CustomerConfirm);
  350. return Ok();
  351. }
  352. public async Task<IActionResult> SaveSettlementConfirm(View_Order_SettlementConfirm View_Order_SettlementConfirm)
  353. {
  354. await this.orderService.SaveSettlementConfirm(View_Order_SettlementConfirm);
  355. return Ok();
  356. }
  357. #region 合计报表
  358. public async Task<IActionResult> GetGrossProfitByCustomer(QueryModel queryModel)
  359. {
  360. var data = await orderService.GetGrossProfitByCustomer(queryModel);
  361. return Ok(data);
  362. }
  363. public async Task<IActionResult> GetGrossProfitByOrder(QueryModel queryModel)
  364. {
  365. //判断用户角色
  366. var u = User.GetUserContent();
  367. if (u.Roles.Contains("销售"))
  368. {
  369. if (queryModel?.QueryParamer != null)
  370. { queryModel.QueryParamer.Add(new QueryParamer() { Filed = "NickName", Method = "Eq", Value = u.NiceName }); }
  371. else
  372. { queryModel.QueryParamer = new List<QueryParamer>(); queryModel.QueryParamer.Add(new QueryParamer() { Filed = "NickName", Method = "Eq", Value = u.NiceName }); }
  373. }
  374. var data = await orderService.GetGrossProfitByOrder(queryModel);
  375. return Ok(data);
  376. }
  377. #endregion
  378. }
  379. }