ActivityPrizeDetailService.cs 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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 ActivityPrizeDetailService
  14. {
  15. string _conn = "";
  16. public ActivityPrizeDetailService()
  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("TradeAmt"); //合伙人团队交易总金额
  36. fields.Add("CheckStatus"); //同步状态
  37. fields.Add("TradeMonth"); //交易月份
  38. fields.Add("OtherProdCreditTradeAmt"); //其他组合计算产品贷记卡交易总金额
  39. fields.Add("CreditTradeAmt"); //合伙人团队贷记卡交易总金额
  40. fields.Add("ActRewardAmt"); //合伙人团队交易活动奖励金额
  41. fields.Add("ProfitRate"); //活动奖励对应分成比例
  42. Dictionary<string, object> obj = new DbService(AppConfig.Base.mainTables, _conn).IndexData("ActivityPrizeDetail", relationData, orderBy, page, limit, condition, fields);
  43. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  44. count = int.Parse(obj["count"].ToString());
  45. return diclist;
  46. }
  47. public List<Dictionary<string, object>> List(List<RelationData> relationData, string condition, int page = 1, int limit = 30, string orderBy = "Sort desc,Id desc")
  48. {
  49. List<string> fields = new List<string>(); //要显示的列
  50. fields.Add("Id");
  51. fields.Add("CreateDate"); //添加时间
  52. fields.Add("Status"); //状态
  53. fields.Add("TradeAmt"); //合伙人团队交易总金额
  54. fields.Add("CheckStatus"); //同步状态
  55. fields.Add("TradeMonth"); //交易月份
  56. fields.Add("OtherProdCreditTradeAmt"); //其他组合计算产品贷记卡交易总金额
  57. fields.Add("CreditTradeAmt"); //合伙人团队贷记卡交易总金额
  58. fields.Add("ActRewardAmt"); //合伙人团队交易活动奖励金额
  59. fields.Add("ProfitRate"); //活动奖励对应分成比例
  60. Dictionary<string, object> obj = new DbService(AppConfig.Base.mainTables, _conn).IndexData("ActivityPrizeDetail", relationData, orderBy, page, limit, condition, fields);
  61. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  62. return diclist;
  63. }
  64. /// <summary>
  65. /// 查询一条记录
  66. /// </summary>
  67. /// <param name="Id">主键Id</param>
  68. /// <returns></returns>
  69. public ActivityPrizeDetail Query(int Id)
  70. {
  71. WebCMSEntities db = new WebCMSEntities();
  72. ActivityPrizeDetail editData = db.ActivityPrizeDetail.FirstOrDefault(m => m.Id == Id) ?? new ActivityPrizeDetail();
  73. db.Dispose();
  74. return editData;
  75. }
  76. /// <summary>
  77. /// 查询记录数
  78. /// </summary>
  79. /// <param name="Id">主键Id</param>
  80. /// <returns></returns>
  81. public int Count(string condition = "")
  82. {
  83. int result = 0;
  84. DataTable dt = CustomerSqlConn.dtable("select count(Id) from ActivityPrizeDetail where 1=1" + condition, _conn);
  85. if (dt.Rows.Count > 0)
  86. {
  87. result = int.Parse(function.CheckInt(dt.Rows[0][0].ToString()));
  88. }
  89. return result;
  90. }
  91. /// <summary>
  92. /// 查询是否存在
  93. /// </summary>
  94. /// <param name="Id">主键Id</param>
  95. /// <returns></returns>
  96. public bool Exist(int Id)
  97. {
  98. WebCMSEntities db = new WebCMSEntities();
  99. bool check = db.ActivityPrizeDetail.Any(m => m.Id == Id);
  100. db.Dispose();
  101. return check;
  102. }
  103. /// <summary>
  104. /// 添加数据
  105. /// </summary>
  106. /// <param name="Fields">要设置的字段</param>
  107. /// <returns></returns>
  108. public AppResultJson Add(Dictionary<string, object> fields, bool check = true)
  109. {
  110. if (check)
  111. {
  112. }
  113. int Id = new DbService(AppConfig.Base.mainTables, _conn).Add("ActivityPrizeDetail", fields, 0);
  114. return new AppResultJson() { Status = "1", Data = Id };
  115. }
  116. /// <summary>
  117. /// 修改数据
  118. /// </summary>
  119. /// <param name="Fields">要设置的字段</param>
  120. /// <param name="Id">主键Id</param>
  121. public AppResultJson Edit(Dictionary<string, object> fields, int Id, bool check = true)
  122. {
  123. if (check)
  124. {
  125. }
  126. new DbService(AppConfig.Base.mainTables, _conn).Edit("ActivityPrizeDetail", fields, Id);
  127. return new AppResultJson() { Status = "1", Data = Id };
  128. }
  129. /// <summary>
  130. /// 逻辑删除
  131. /// </summary>
  132. /// <param name="Id">主键Id</param>
  133. public void Remove(int Id)
  134. {
  135. Dictionary<string, object> fields = new Dictionary<string, object>();
  136. fields.Add("Status", -1);
  137. new DbService(AppConfig.Base.mainTables, _conn).Edit("ActivityPrizeDetail", fields, Id);
  138. }
  139. /// <summary>
  140. /// 删除数据
  141. /// </summary>
  142. /// <param name="Id">主键Id</param>
  143. public void Delete(int Id)
  144. {
  145. new DbService(AppConfig.Base.mainTables, _conn).Delete("ActivityPrizeDetail", Id);
  146. }
  147. /// <summary>
  148. /// 排序
  149. /// </summary>
  150. /// <param name="Id">主键Id</param>
  151. /// <param name="Sort">排序序号</param>
  152. public void Sort(int Id, int Sort)
  153. {
  154. new DbService(AppConfig.Base.mainTables, _conn).Sort("ActivityPrizeDetail", Sort, Id);
  155. }
  156. /// <summary>
  157. /// 导入数据
  158. /// </summary>
  159. /// <param name="ExcelData">json数据</param>
  160. public void Import(string ExcelData)
  161. {
  162. WebCMSEntities db = new WebCMSEntities();
  163. JsonData list = JsonMapper.ToObject(ExcelData);
  164. for (int i = 1; i < list.Count; i++)
  165. {
  166. JsonData dr = list[i];
  167. db.ActivityPrizeDetail.Add(new ActivityPrizeDetail()
  168. {
  169. CreateDate = DateTime.Now,
  170. UpdateDate = DateTime.Now,
  171. });
  172. db.SaveChanges();
  173. }
  174. db.Dispose();
  175. }
  176. /// <summary>
  177. /// 导出excel表格
  178. /// </summary>
  179. /// <param name="fields">查询条件(单个字段)</param>
  180. /// <param name="condition">查询条件(sql语句)</param>
  181. /// <returns></returns>
  182. // public void ExportExcel(List<RelationData> relationData, string condition)
  183. // {
  184. // }
  185. }
  186. }