MerchantDepositBackService.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*
  2. * 商户服务费退还记录
  3. */
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Data;
  8. using MySystem.MainModels;
  9. using Library;
  10. using LitJson;
  11. namespace MySystem.Service.Main
  12. {
  13. public class MerchantDepositBackService
  14. {
  15. string _conn = ConfigurationManager.AppSettings["SqlConnStr"].ToString();
  16. /// <summary>
  17. /// 查询列表
  18. /// </summary>
  19. /// <param name="fields">查询条件(单个字段)</param>
  20. /// <param name="condition">查询条件(sql语句)</param>
  21. /// <param name="page">页码</param>
  22. /// <param name="limit">每页条数</param>
  23. /// <returns></returns>
  24. public List<Dictionary<string, object>> List(List<FieldItem> fields, string condition, int page = 1, int limit = 30, string orderby = "Id desc")
  25. {
  26. Dictionary<string, object> obj = new DbService(AppConfig.Base.mainTables, _conn).IndexData("MerchantDepositBack", fields, orderby, "0", page, limit, condition);
  27. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  28. return diclist;
  29. }
  30. /// <summary>
  31. /// 查询一条记录
  32. /// </summary>
  33. /// <param name="Id">主键Id</param>
  34. /// <returns></returns>
  35. public MerchantDepositBack Query(int MerchantId)
  36. {
  37. WebCMSEntities db = new WebCMSEntities();
  38. MerchantDepositBack editData = db.MerchantDepositBack.FirstOrDefault(m => m.Status == 1 && m.MerchantId == MerchantId) ?? new MerchantDepositBack();
  39. db.Dispose();
  40. return editData;
  41. }
  42. public Dictionary<string, string> Sum(string field, string condition)
  43. {
  44. Dictionary<string, string> result = new Dictionary<string, string>();
  45. string sumString = "";
  46. string[] fieldlist = field.Split(',');
  47. foreach(string f in fieldlist)
  48. {
  49. sumString += "sum(" + f + ") " + f + ",";
  50. }
  51. sumString = sumString.TrimEnd(',');
  52. DataTable dt = CustomerSqlConn.dtable("select " + sumString + " from MerchantDepositBack where 1=1" + condition, _conn);
  53. if(dt.Rows.Count > 0)
  54. {
  55. foreach(string f in fieldlist)
  56. {
  57. result.Add(f, function.CheckNum(dt.Rows[0][f].ToString()));
  58. }
  59. }
  60. return result;
  61. }
  62. /// <summary>
  63. /// 添加数据
  64. /// </summary>
  65. /// <param name="Fields">要设置的字段</param>
  66. /// <returns></returns>
  67. public AppResultJson Add(Dictionary<string, object> fields, bool check = true)
  68. {
  69. if (check)
  70. {
  71. }
  72. int Id = new DbService(AppConfig.Base.mainTables, _conn).Add("MerchantDepositBack", fields, 0);
  73. return new AppResultJson() { Status = "1", Data = Id };
  74. }
  75. /// <summary>
  76. /// 修改数据
  77. /// </summary>
  78. /// <param name="Fields">要设置的字段</param>
  79. /// <param name="Id">主键Id</param>
  80. public AppResultJson Edit(Dictionary<string, object> fields, int Id, bool check = true)
  81. {
  82. if (check)
  83. {
  84. }
  85. new DbService(AppConfig.Base.mainTables, _conn).Edit("MerchantDepositBack", fields, Id);
  86. return new AppResultJson() { Status = "1", Data = Id };
  87. }
  88. /// <summary>
  89. /// 逻辑删除
  90. /// </summary>
  91. /// <param name="Id">主键Id</param>
  92. public void Remove(int Id)
  93. {
  94. Dictionary<string, object> fields = new Dictionary<string, object>();
  95. fields.Add("Status", -1);
  96. new DbService(AppConfig.Base.mainTables, _conn).Edit("MerchantDepositBack", fields, Id);
  97. }
  98. /// <summary>
  99. /// 删除数据
  100. /// </summary>
  101. /// <param name="Id">主键Id</param>
  102. public void Delete(int Id)
  103. {
  104. new DbService(AppConfig.Base.mainTables, _conn).Delete("MerchantDepositBack", Id);
  105. }
  106. /// <summary>
  107. /// 排序
  108. /// </summary>
  109. /// <param name="Id">主键Id</param>
  110. /// <param name="Sort">排序序号</param>
  111. public void Sort(int Id, int Sort)
  112. {
  113. new DbService(AppConfig.Base.mainTables, _conn).Sort("MerchantDepositBack", Sort, Id);
  114. }
  115. /// <summary>
  116. /// 导入数据
  117. /// </summary>
  118. /// <param name="ExcelData">json数据</param>
  119. public void Import(string ExcelData)
  120. {
  121. // WebCMSEntities db = new WebCMSEntities();
  122. // JsonData list = JsonMapper.ToObject(ExcelData);
  123. // for (int i = 1; i < list.Count;i++ )
  124. // {
  125. // JsonData dr = list[i];
  126. // db.MerchantDepositBack.Add(new MerchantDepositBack()
  127. // {
  128. // CreateDate = DateTime.Now,
  129. // UpdateDate = DateTime.Now,
  130. // });
  131. // db.SaveChanges();
  132. // }
  133. // db.Dispose();
  134. }
  135. /// <summary>
  136. /// 导出excel表格
  137. /// </summary>
  138. /// <param name="fields">查询条件(单个字段)</param>
  139. /// <param name="condition">查询条件(sql语句)</param>
  140. /// <returns></returns>
  141. // public void ExportExcel(List<RelationData> relationData, string condition)
  142. // {
  143. // }
  144. }
  145. }