PrizePushHelper.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using System;
  2. using System.Linq;
  3. using System.Data;
  4. using System.Threading;
  5. using Library;
  6. using LitJson;
  7. using System.Collections.Generic;
  8. namespace MySystem
  9. {
  10. public class PrizePushHelper
  11. {
  12. public readonly static PrizePushHelper Instance = new PrizePushHelper();
  13. private PrizePushHelper()
  14. {
  15. }
  16. string NoticeUrl = "https://apigateway.kexiaoshuang.com/v1/kxs/userServer/userAccount/sendPrize";
  17. //要执行的方法
  18. public void Do(string batchNo, string prizeName, string prizeCode, decimal prizeAmt, int prizeObjectId, string requestParamField = "")
  19. {
  20. try
  21. {
  22. Dictionary<string, object> prizeItem = new Dictionary<string, object>();
  23. prizeItem.Add("prize_date", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  24. prizeItem.Add("prize_name", prizeName);
  25. prizeItem.Add("prize_code", prizeCode);
  26. prizeItem.Add("batch_no", batchNo);
  27. prizeItem.Add("request_param_field", requestParamField);
  28. List<Dictionary<string, object>> prizeItemList = new List<Dictionary<string, object>>();
  29. Dictionary<string, object> prizeItemSub = new Dictionary<string, object>();
  30. prizeItemSub.Add("prize_amount", prizeAmt);
  31. prizeItemSub.Add("prize_obj", prizeObjectId);
  32. prizeItemList.Add(prizeItemSub);
  33. prizeItem.Add("prize_list", prizeItemList);
  34. string prizeOutContent = Newtonsoft.Json.JsonConvert.SerializeObject(prizeItem);
  35. function.WriteLog("请求参数:" + prizeOutContent, "奖励通知返回报文");
  36. string noticeJson = function.PostWebRequest(NoticeUrl, prizeOutContent, "application/json");
  37. function.WriteLog("返回报文:" + noticeJson + "\n\n\n", "奖励通知返回报文");
  38. }
  39. catch(Exception ex)
  40. {
  41. LogHelper.Instance.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString() + "\n\n", "奖励通知返回异常");
  42. }
  43. }
  44. }
  45. }