SetLklFeeService.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Linq;
  5. using System.Threading;
  6. using MySystem.PxcModels;
  7. using Library;
  8. using LitJson;
  9. namespace MySystem
  10. {
  11. /// <summary>
  12. /// 设置机具费率标记并推送消息
  13. /// </summary>
  14. public class SetLklFeeService
  15. {
  16. public readonly static SetLklFeeService Instance = new SetLklFeeService();
  17. private SetLklFeeService()
  18. { }
  19. public void Start()
  20. {
  21. Thread th = new Thread(doSomething);
  22. th.IsBackground = true;
  23. th.Start();
  24. }
  25. public void doSomething()
  26. {
  27. while (true)
  28. {
  29. string content = RedisDbconn.Instance.RPop<string>("SetLklFeeQueue");
  30. if (!string.IsNullOrEmpty(content))
  31. {
  32. try
  33. {
  34. string[] arr = content.Split('|');
  35. string MerNo = arr[0];
  36. string Fee = arr[1];
  37. string addRate = arr[2];
  38. string back = PublicImportDataService.Instance.LkLSetFee(MerNo, decimal.Parse(Fee), int.Parse(addRate));
  39. JsonData obj = JsonMapper.ToObject(back);
  40. if (obj["message"].ToString() == "SUCCESS")
  41. {
  42. }
  43. else
  44. {
  45. string msg = obj["message"].ToString();
  46. }
  47. Thread.Sleep(1000);
  48. }
  49. catch (Exception ex)
  50. {
  51. Utils.WriteLog(DateTime.Now.ToString() + "\r\n" + ex.ToString(), "单独设置拉卡拉费率异常");
  52. Thread.Sleep(60000);
  53. }
  54. }
  55. else
  56. {
  57. Thread.Sleep(60000);
  58. }
  59. }
  60. }
  61. }
  62. }