HelpProfitRebateDetailService.cs 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. /*
  2. * 助利宝返利明细表
  3. */
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Data;
  8. using MySystem.Models.Main;
  9. using Library;
  10. using LitJson;
  11. namespace MySystem.Service.Main
  12. {
  13. public class HelpProfitRebateDetailService
  14. {
  15. string _conn = "";
  16. public HelpProfitRebateDetailService()
  17. {
  18. _conn = ConfigurationManager.AppSettings["SqlConnStr"].ToString();
  19. }
  20. /// <summary>
  21. /// 查询列表
  22. /// </summary>
  23. /// <param name="relationData">关联表</param>
  24. /// <param name="condition">查询条件(sql语句)</param>
  25. /// <param name="count">总数(输出)</param>
  26. /// <param name="page">页码</param>
  27. /// <param name="limit">每页条数</param>
  28. /// <returns></returns>
  29. public List<Dictionary<string, object>> List(List<RelationData> relationData, string condition, out int count, int page = 1, int limit = 30, string orderBy = "Sort desc,Id desc")
  30. {
  31. List<string> fields = new List<string>(); //要显示的列
  32. fields.Add("Id");
  33. fields.Add("CreateDate"); //添加时间
  34. fields.Add("Status"); //状态
  35. fields.Add("TradeMonth"); //交易月
  36. fields.Add("TradeDate"); //交易日
  37. fields.Add("UserId"); //创客
  38. fields.Add("ProductType"); //产品类型
  39. fields.Add("MerchantId"); //商户
  40. fields.Add("CreditRewardAmount"); //贷记卡交易奖励金额
  41. fields.Add("DebitRewardAmount"); //借记卡交易奖励金额
  42. fields.Add("Remark"); //备注
  43. Dictionary<string, object> obj = new DbService(AppConfig.Base.dbTables, _conn).IndexData("HelpProfitRebateDetail", relationData, orderBy, page, limit, condition, fields);
  44. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  45. count = int.Parse(obj["count"].ToString());
  46. return diclist;
  47. }
  48. public List<Dictionary<string, object>> List(List<RelationData> relationData, string condition, int page = 1, int limit = 30, string orderBy = "Sort desc,Id desc")
  49. {
  50. List<string> fields = new List<string>(); //要显示的列
  51. fields.Add("Id");
  52. fields.Add("CreateDate"); //添加时间
  53. fields.Add("Status"); //状态
  54. fields.Add("TradeMonth"); //交易月
  55. fields.Add("TradeDate"); //交易日
  56. fields.Add("UserId"); //创客
  57. fields.Add("ProductType"); //产品类型
  58. fields.Add("MerchantId"); //商户
  59. fields.Add("CreditRewardAmount"); //贷记卡交易奖励金额
  60. fields.Add("DebitRewardAmount"); //借记卡交易奖励金额
  61. fields.Add("Remark"); //备注
  62. Dictionary<string, object> obj = new DbService(AppConfig.Base.dbTables, _conn).IndexData("HelpProfitRebateDetail", relationData, orderBy, page, limit, condition, fields);
  63. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  64. return diclist;
  65. }
  66. /// <summary>
  67. /// 查询一条记录
  68. /// </summary>
  69. /// <param name="Id">主键Id</param>
  70. /// <returns></returns>
  71. public HelpProfitRebateDetail Query(int Id)
  72. {
  73. WebCMSEntities db = new WebCMSEntities();
  74. HelpProfitRebateDetail editData = db.HelpProfitRebateDetail.FirstOrDefault(m => m.Id == Id) ?? new HelpProfitRebateDetail();
  75. db.Dispose();
  76. return editData;
  77. }
  78. /// <summary>
  79. /// 查询记录数
  80. /// </summary>
  81. /// <param name="Id">主键Id</param>
  82. /// <returns></returns>
  83. public int Count(string condition = "")
  84. {
  85. int result = 0;
  86. DataTable dt = CustomerSqlConn.dtable("select count(Id) from HelpProfitRebateDetail where 1=1" + condition, _conn);
  87. if(dt.Rows.Count > 0)
  88. {
  89. result = int.Parse(function.CheckInt(dt.Rows[0][0].ToString()));
  90. }
  91. return result;
  92. }
  93. /// <summary>
  94. /// 查询是否存在
  95. /// </summary>
  96. /// <param name="Id">主键Id</param>
  97. /// <returns></returns>
  98. public bool Exist(int Id)
  99. {
  100. WebCMSEntities db = new WebCMSEntities();
  101. bool check = db.HelpProfitRebateDetail.Any(m => m.Id == Id);
  102. db.Dispose();
  103. return check;
  104. }
  105. /// <summary>
  106. /// 添加数据
  107. /// </summary>
  108. /// <param name="Fields">要设置的字段</param>
  109. /// <returns></returns>
  110. public AppResultJson Add(Dictionary<string, object> fields, bool check = true)
  111. {
  112. if(check)
  113. {
  114. }
  115. int Id = new DbService(AppConfig.Base.dbTables, _conn).Add("HelpProfitRebateDetail", fields, 0);
  116. return new AppResultJson(){ Status = "1", Data = Id };
  117. }
  118. /// <summary>
  119. /// 修改数据
  120. /// </summary>
  121. /// <param name="Fields">要设置的字段</param>
  122. /// <param name="Id">主键Id</param>
  123. public AppResultJson Edit(Dictionary<string, object> fields, int Id, bool check = true)
  124. {
  125. if(check)
  126. {
  127. }
  128. new DbService(AppConfig.Base.dbTables, _conn).Edit("HelpProfitRebateDetail", fields, Id);
  129. return new AppResultJson(){ Status = "1", Data = Id };
  130. }
  131. /// <summary>
  132. /// 逻辑删除
  133. /// </summary>
  134. /// <param name="Id">主键Id</param>
  135. public void Remove(int Id)
  136. {
  137. Dictionary<string, object> fields = new Dictionary<string, object>();
  138. fields.Add("Status", -1);
  139. new DbService(AppConfig.Base.dbTables, _conn).Edit("HelpProfitRebateDetail", fields, Id);
  140. }
  141. /// <summary>
  142. /// 删除数据
  143. /// </summary>
  144. /// <param name="Id">主键Id</param>
  145. public void Delete(int Id)
  146. {
  147. new DbService(AppConfig.Base.dbTables, _conn).Delete("HelpProfitRebateDetail", Id);
  148. }
  149. /// <summary>
  150. /// 排序
  151. /// </summary>
  152. /// <param name="Id">主键Id</param>
  153. /// <param name="Sort">排序序号</param>
  154. public void Sort(int Id, int Sort)
  155. {
  156. new DbService(AppConfig.Base.dbTables, _conn).Sort("HelpProfitRebateDetail", Sort, Id);
  157. }
  158. /// <summary>
  159. /// 导入数据
  160. /// </summary>
  161. /// <param name="ExcelData">json数据</param>
  162. public void Import(string ExcelData)
  163. {
  164. WebCMSEntities db = new WebCMSEntities();
  165. JsonData list = JsonMapper.ToObject(ExcelData);
  166. for (int i = 1; i < list.Count;i++ )
  167. {
  168. JsonData dr = list[i];
  169. db.HelpProfitRebateDetail.Add(new HelpProfitRebateDetail()
  170. {
  171. CreateDate = DateTime.Now,
  172. UpdateDate = DateTime.Now,
  173. });
  174. db.SaveChanges();
  175. }
  176. db.Dispose();
  177. }
  178. /// <summary>
  179. /// 导出excel表格
  180. /// </summary>
  181. /// <param name="fields">查询条件(单个字段)</param>
  182. /// <param name="condition">查询条件(sql语句)</param>
  183. /// <returns></returns>
  184. // public void ExportExcel(List<RelationData> relationData, string condition)
  185. // {
  186. // }
  187. }
  188. }