ProfitShareService.cs 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // using System;
  2. // using System.Collections.Generic;
  3. // using System.Linq;
  4. // using MySystem.Models.Main;
  5. // using Library;
  6. // using LitJson;
  7. // using System.Text.RegularExpressions;
  8. // using System.Threading;
  9. // namespace MySystem
  10. // {
  11. // public class ProfitShareService
  12. // {
  13. // public readonly static ProfitShareService Instance = new ProfitShareService();
  14. // private ProfitShareService()
  15. // { }
  16. // public void Start()
  17. // {
  18. // Thread th = new Thread(StartListen);
  19. // th.IsBackground = true;
  20. // th.Start();
  21. // }
  22. // public void StartListen()
  23. // {
  24. // while (true)
  25. // {
  26. // string content = RedisDbconn.Instance.RPop<string>("ProfitShareQueue");
  27. // if (!string.IsNullOrEmpty(content))
  28. // {
  29. // StartDo(content);
  30. // }
  31. // else
  32. // {
  33. // Thread.Sleep(2000);
  34. // }
  35. // }
  36. // }
  37. // public void StartDo(string content)
  38. // {
  39. // try
  40. // {
  41. // JsonData jsonObj = JsonMapper.ToObject(content);
  42. // string SubMchid = jsonObj["SubMchid"].ToString(); //子商户号
  43. // string TradeNo = jsonObj["TradeNo"].ToString(); //微信订单号
  44. // string OrderNo = jsonObj["OrderNo"].ToString(); //商户订单号
  45. // string result = WeChatFunction.Instance.QueryProfitShare(SubMchid, TradeNo, OrderNo);
  46. // JsonData resultObj = JsonMapper.ToObject(result);
  47. // if(result.Contains("\"state\":"))
  48. // {
  49. // string state = resultObj["state"].ToString();
  50. // if(state == "FINISHED")
  51. // {
  52. // WebCMSEntities db = new WebCMSEntities();
  53. // ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.OrderNo == OrderNo && m.Status == 2);
  54. // if (order != null)
  55. // {
  56. // RedisDbconn.Instance.AddList("ConsumerOrders:Divi:" + order.PayMode + ":List", order.Id.ToString());
  57. // // RedisDbconn.Instance.AddRightList("ConsumerOrders:Divi:" + order.PayMode + ":" + order.MerchantId, order);
  58. // }
  59. // db.Dispose();
  60. // }
  61. // else
  62. // {
  63. // RedisDbconn.Instance.AddList("ProfitShareQueue", content);
  64. // }
  65. // }
  66. // }
  67. // catch (Exception ex)
  68. // {
  69. // function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "分账队列异常");
  70. // }
  71. // }
  72. // }
  73. // }