YcCardOnlineController.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using Microsoft.Extensions.Logging;
  6. using Microsoft.Extensions.Options;
  7. using Microsoft.AspNetCore.Mvc;
  8. using Microsoft.AspNetCore.Http;
  9. using System.IO;
  10. using Library;
  11. using LitJson;
  12. namespace MySystem.Areas.Api.Controllers
  13. {
  14. public class YcCardOnlineController : Admin.Controllers.BaseController
  15. {
  16. public YcCardOnlineController(IHttpContextAccessor accessor, ILogger<Admin.Controllers.BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
  17. {
  18. }
  19. #region 接收订单通知
  20. [Route("/yc/order/notice")]
  21. public Dictionary<string, object> Bind(int BrandId)
  22. {
  23. StreamReader sr = new StreamReader(Request.Body);
  24. string requestMes = sr.ReadToEnd();
  25. if (string.IsNullOrEmpty(requestMes))
  26. {
  27. return new Dictionary<string, object>();
  28. }
  29. RedisDbconn.Instance.AddList("yc_order_list", requestMes);
  30. Dictionary<string, object> obj = new Dictionary<string, object>();
  31. obj.Add("resultCode", 1);
  32. return obj;
  33. }
  34. #endregion
  35. #region 设备信息初始化回传接口
  36. [Route("/yc/device/init")]
  37. public Dictionary<string, object> Init()
  38. {
  39. StreamReader sr = new StreamReader(Request.Body);
  40. string requestMes = sr.ReadToEnd();
  41. if (string.IsNullOrEmpty(requestMes))
  42. {
  43. return new Dictionary<string, object>();
  44. }
  45. LogHelper.Instance.WriteLog(DateTime.Now.ToString() + "\n" + requestMes, "WIFI设备信息初始化回传接口推送消息");
  46. RedisDbconn.Instance.AddList("yc_device", "init#cut#" + requestMes);
  47. Dictionary<string, object> obj = new Dictionary<string, object>();
  48. obj.Add("resultCode", 1);
  49. obj.Add("errorCode", null);
  50. obj.Add("errorDesc", null);
  51. return obj;
  52. }
  53. #endregion
  54. #region 设备信息变更回传接口
  55. [Route("/yc/device/change")]
  56. public Dictionary<string, object> Change()
  57. {
  58. StreamReader sr = new StreamReader(Request.Body);
  59. string requestMes = sr.ReadToEnd();
  60. if (string.IsNullOrEmpty(requestMes))
  61. {
  62. return new Dictionary<string, object>();
  63. }
  64. LogHelper.Instance.WriteLog(DateTime.Now.ToString() + "\n" + requestMes, "WIFI设备信息变更回传接口推送消息");
  65. RedisDbconn.Instance.AddList("yc_device", "change#cut#" + requestMes);
  66. Dictionary<string, object> obj = new Dictionary<string, object>();
  67. obj.Add("resultCode", 1);
  68. obj.Add("errorCode", null);
  69. obj.Add("errorDesc", null);
  70. return obj;
  71. }
  72. #endregion
  73. #region 订单信息初始化回传接口
  74. [Route("/yc/order/init")]
  75. public Dictionary<string, object> OrderInit()
  76. {
  77. StreamReader sr = new StreamReader(Request.Body);
  78. string requestMes = sr.ReadToEnd();
  79. if (string.IsNullOrEmpty(requestMes))
  80. {
  81. return new Dictionary<string, object>();
  82. }
  83. LogHelper.Instance.WriteLog(DateTime.Now.ToString() + "\n" + requestMes, "WIFI订单信息初始化回传接口推送消息");
  84. RedisDbconn.Instance.AddList("yc_order", "init#cut#" + requestMes);
  85. Dictionary<string, object> obj = new Dictionary<string, object>();
  86. obj.Add("resultCode", 1);
  87. obj.Add("errorCode", null);
  88. obj.Add("errorDesc", null);
  89. return obj;
  90. }
  91. #endregion
  92. #region 订单状态变更回传接口
  93. [Route("/yc/order/change")]
  94. public Dictionary<string, object> OrderChange()
  95. {
  96. StreamReader sr = new StreamReader(Request.Body);
  97. string requestMes = sr.ReadToEnd();
  98. if (string.IsNullOrEmpty(requestMes))
  99. {
  100. return new Dictionary<string, object>();
  101. }
  102. LogHelper.Instance.WriteLog(DateTime.Now.ToString() + "\n" + requestMes, "WIFI订单状态变更回传接口推送消息");
  103. RedisDbconn.Instance.AddList("yc_order", "change#cut#" + requestMes);
  104. Dictionary<string, object> obj = new Dictionary<string, object>();
  105. obj.Add("resultCode", 1);
  106. obj.Add("errorCode", null);
  107. obj.Add("errorDesc", null);
  108. return obj;
  109. }
  110. #endregion
  111. }
  112. }