PosMachinesTwoController.cs 4.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Microsoft.AspNetCore.Mvc;
  5. using Microsoft.AspNetCore.Http;
  6. using Microsoft.Extensions.Logging;
  7. using Microsoft.Extensions.Options;
  8. using Microsoft.AspNetCore.Authorization;
  9. using System.Web;
  10. using MySystem.Models.Main1;
  11. using MySystem.Service.Main1;
  12. using LitJson;
  13. using Library;
  14. namespace MySystem.Areas.Api.Controllers.v1.Main1
  15. {
  16. [Area("Api")]
  17. [Route("/v1/QrCodePlateMain/[controller]/[action]")]
  18. public class PosMachinesTwoController : BaseController
  19. {
  20. public PosMachinesTwoController(IHttpContextAccessor accessor) : base(accessor)
  21. {
  22. }
  23. #region 重置交易额-直连重置码牌交易额
  24. [Authorize]
  25. public JsonResult DirectResetQrCodeAmount(string value)
  26. {
  27. value = PublicFunction.DesDecrypt(value);
  28. JsonData data = JsonMapper.ToObject(value);
  29. AppResultJson result = DirectResetQrCodeAmountDo(value);
  30. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  31. }
  32. private AppResultJson DirectResetQrCodeAmountDo(string value)
  33. {
  34. JsonData data = JsonMapper.ToObject(value);
  35. string PosSn = data["PosSn"].ToString(); //码牌Sn
  36. string TradeDate = data["TradeDate"].ToString(); //交易时间
  37. if (string.IsNullOrEmpty(data["PosSn"].ToString()) || string.IsNullOrEmpty(data["TradeDate"].ToString()))
  38. {
  39. return new AppResultJson() { Status = "-1", Info = "码牌Sn和交易时间不能为空" };
  40. }
  41. var pos = PosMachinesTwoService.Query(" and PosSn=" + PosSn + "");
  42. if (pos.Id == 0 || pos.OpId != 1)
  43. {
  44. return new AppResultJson() { Status = "-1", Info = "未找到该码牌Sn或该码牌通道不符" };
  45. }
  46. string[] datelist = TradeDate.Split(new string[] { " - " }, StringSplitOptions.None);
  47. string start = DateTime.Parse(datelist[0]).ToString("yyyyMMdd");
  48. string end = DateTime.Parse(datelist[1]).ToString("yyyyMMdd");
  49. string info = "{\"SnNo\":\"" + PosSn + "\",\"StartDate\":\"" + start + "\",\"EndDate\": \"" + end + "\"}";
  50. RedisDbconn.Instance.AddList("ResetSnStatDataQueue", info);
  51. Dictionary<string, object> Obj = new Dictionary<string, object>();
  52. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  53. }
  54. #endregion
  55. #region 重置交易额-银联重置码牌交易额
  56. [Authorize]
  57. public JsonResult UnionPayResetQrCodeAmount(string value)
  58. {
  59. value = PublicFunction.DesDecrypt(value);
  60. JsonData data = JsonMapper.ToObject(value);
  61. AppResultJson result = UnionPayResetQrCodeAmountDo(value);
  62. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  63. }
  64. private AppResultJson UnionPayResetQrCodeAmountDo(string value)
  65. {
  66. JsonData data = JsonMapper.ToObject(value);
  67. string PosSn = data["PosSn"].ToString(); //码牌Sn
  68. string TradeDate = data["TradeDate"].ToString(); //交易时间
  69. if (string.IsNullOrEmpty(data["PosSn"].ToString()) || string.IsNullOrEmpty(data["TradeDate"].ToString()))
  70. {
  71. return new AppResultJson() { Status = "-1", Info = "码牌Sn和交易时间不能为空" };
  72. }
  73. var pos = PosMachinesTwoService.Query(" and PosSn=" + PosSn + "");
  74. if (pos.Id == 0 || pos.OpId != 2)
  75. {
  76. return new AppResultJson() { Status = "-1", Info = "未找到该码牌Sn或该码牌通道不符" };
  77. }
  78. string[] datelist = TradeDate.Split(new string[] { " - " }, StringSplitOptions.None);
  79. string start = DateTime.Parse(datelist[0]).ToString("yyyyMMdd");
  80. string end = DateTime.Parse(datelist[1]).ToString("yyyyMMdd");
  81. string info = "{\"SnNo\":\"" + PosSn + "\",\"StartDate\":\"" + start + "\",\"EndDate\": \"" + end + "\"}";
  82. RedisDbconn.Instance.AddList("ResetSnStatDataQueue2", info);
  83. Dictionary<string, object> Obj = new Dictionary<string, object>();
  84. return new AppResultJson() { Status = "1", Info = "", Data = Obj };
  85. }
  86. #endregion
  87. }
  88. }