PublicFunction.cs 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Data;
  5. using System.Text.RegularExpressions;
  6. using MySystem.PxcModels;
  7. using Library;
  8. namespace MySystem
  9. {
  10. public class PublicFunction
  11. {
  12. public static decimal NumberFormat(decimal number, int floatCount = 2)
  13. {
  14. string str = number.ToString();
  15. if (str.Contains("."))
  16. {
  17. string[] list = str.Split('.');
  18. if (list[1].Length > floatCount)
  19. {
  20. str = list[0] + "." + list[1].Substring(0, floatCount);
  21. }
  22. }
  23. else
  24. {
  25. str += ".00";
  26. }
  27. return decimal.Parse(str);
  28. }
  29. public static string GetPublicParam(WebCMSEntities db, string Key)
  30. {
  31. CustomTagSet set = db.CustomTagSet.FirstOrDefault(m => m.Tags == Key);
  32. if(set != null)
  33. {
  34. return set.Contents;
  35. }
  36. return "";
  37. }
  38. public static int FeeSetRecord(WebCMSEntities db, PosMachinesTwo pos, PosMerchantInfo mer, decimal ChangeFee)
  39. {
  40. PosMachinesFeeChangeRecord query = db.PosMachinesFeeChangeRecord.FirstOrDefault(m => m.PosId == pos.Id && m.Status == 0);
  41. if(query == null)
  42. {
  43. query = db.PosMachinesFeeChangeRecord.Add(new PosMachinesFeeChangeRecord()
  44. {
  45. CreateDate = DateTime.Now, //创建时间
  46. Sort = pos.BrandId, //品牌Id
  47. UserId = pos.BuyUserId, //创客
  48. PosId = pos.Id, //机具Id
  49. PosSn = pos.PosSn,
  50. MerNo = mer.MerchantNo,
  51. MerchantId = mer.Id,
  52. PosUserId = pos.BuyUserId, //机具所属人
  53. ChangeFee = ChangeFee, //调整费率
  54. }).Entity;
  55. db.SaveChanges();
  56. }
  57. query.UpdateDate = DateTime.Now; //创建时间
  58. query.Sort = pos.BrandId; //品牌Id
  59. query.UserId = pos.BuyUserId; //创客
  60. query.PosId = pos.Id; //机具Id
  61. query.PosSn = pos.PosSn;
  62. query.MerNo = mer.MerchantNo;
  63. query.MerchantId = mer.Id;
  64. query.PosUserId = pos.BuyUserId; //机具所属人
  65. query.ChangeFee = ChangeFee; //调整费率
  66. db.SaveChanges();
  67. return query.Id;
  68. }
  69. #region 发送分表数据
  70. public static void SplitTradeRecord(TradeRecord obj, string TradeMonth)
  71. {
  72. RedisDbconn.Instance.AddList("AddTradeRecordQueue", Newtonsoft.Json.JsonConvert.SerializeObject(obj) + "#cut#" + TradeMonth);
  73. }
  74. public static void SplitUserAccountRecord(UserAccountRecord obj, string TradeMonth)
  75. {
  76. RedisDbconn.Instance.AddList("AddUserAccountRecordQueue", Newtonsoft.Json.JsonConvert.SerializeObject(obj) + "#cut#" + TradeMonth);
  77. }
  78. #endregion
  79. }
  80. }