PublicFunction.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. #region 设置押金添加记录公共方法
  39. public static void MerchantDepositSet(int BrandId, int UserId, int SnId, string SnNo, int BeforeDeposit, decimal DepositAmount, string ReturnNote)
  40. {
  41. try
  42. {
  43. WebCMSEntities maindb = new WebCMSEntities();
  44. MerchantDepositSet query = maindb.MerchantDepositSet.Add(new MerchantDepositSet()
  45. {
  46. CreateDate = DateTime.Now, //创建时间
  47. Sort = BrandId,//品牌
  48. SeoTitle = BeforeDeposit.ToString(),//变更前押金
  49. DepositAmount = DepositAmount,//押金
  50. ReturnNote = ReturnNote,//返回信息
  51. SnNo = SnNo,//机具Sn
  52. UserId = UserId,//创客Id
  53. }).Entity;
  54. maindb.SaveChanges();
  55. }
  56. catch (Exception ex)
  57. {
  58. function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ":" + ex.ToString(), "设置押金队列异常");
  59. }
  60. }
  61. #endregion
  62. #region 发送分表数据
  63. public static void SplitTradeRecord(TradeRecord obj, string TradeMonth)
  64. {
  65. RedisDbconn.Instance.AddList("AddTradeRecordQueue", Newtonsoft.Json.JsonConvert.SerializeObject(obj) + "#cut#" + TradeMonth);
  66. }
  67. public static void SplitUserAccountRecord(UserAccountRecord obj, string TradeMonth)
  68. {
  69. RedisDbconn.Instance.AddList("AddUserAccountRecordQueue", Newtonsoft.Json.JsonConvert.SerializeObject(obj) + "#cut#" + TradeMonth);
  70. }
  71. #endregion
  72. }
  73. }