PosPushDataNewHelper.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Library;
  5. using MySystem.MainModels;
  6. namespace MySystem
  7. {
  8. public class PosPushDataNewHelper
  9. {
  10. public readonly static PosPushDataNewHelper Instance = new PosPushDataNewHelper();
  11. private PosPushDataNewHelper()
  12. { }
  13. //绑定数据
  14. public static void Bind(MerchantAddInfo mer, PosMachinesTwo pos)
  15. {
  16. try
  17. {
  18. Dictionary<string, object> dataContent = new Dictionary<string, object>();
  19. dataContent.Add("pos_sn", pos.PosSn); //机具sn
  20. dataContent.Add("mer_no", mer.SubMchid + "_" + mer.AlipayPid); //商户号
  21. dataContent.Add("id_card", mer.IdCardNumber); //商户身份证
  22. dataContent.Add("mer_name", mer.CertMerchantName); //商户姓名
  23. dataContent.Add("mer_mobile", mer.MobilePhone); //商户手机号
  24. dataContent.Add("request_id", getRequestId(mer.Id, "bind")); //流水号
  25. dataContent.Add("bind_time", mer.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss")); //绑定时间
  26. dataContent.Add("brand", 100); //品牌
  27. Push("bind", dataContent);
  28. }
  29. catch (Exception ex)
  30. {
  31. function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString() + "\n\n", "推送绑定数据异常");
  32. }
  33. }
  34. public static void Push(string dataType, Dictionary<string, object> dataContent)
  35. {
  36. Dictionary<string, object> data = new Dictionary<string, object>();
  37. data.Add("data_type", dataType);
  38. data.Add("data_content", dataContent);
  39. KxsRedisDbconn.Instance.AddList("KxsPosDataQueue", Newtonsoft.Json.JsonConvert.SerializeObject(data));
  40. }
  41. public static string getRequestId(int id, string type)
  42. {
  43. if(id > 0)
  44. {
  45. return function.MD5_32(id.ToString() + type);
  46. }
  47. return DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8);
  48. }
  49. }
  50. }