ProfitRewardExportService.cs 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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 ProfitRewardExportService
  14. {
  15. string _conn = "";
  16. public ProfitRewardExportService()
  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("MakerCode"); //创客编号
  36. fields.Add("RealName"); //创客姓名
  37. fields.Add("UserLevel"); //创客当前等级
  38. fields.Add("Rank"); //创客预设等级
  39. fields.Add("DirectFlag"); //分润类型
  40. fields.Add("BrandName"); //品牌名称
  41. fields.Add("CreditTradeAmt"); //贷记卡交易额
  42. fields.Add("CreditTradeProfit"); //贷记卡分润
  43. fields.Add("QrCreditTradeAmt"); //云闪付贷记卡交易额
  44. fields.Add("QrCreditTradeProfit"); //云闪付贷记卡分润
  45. fields.Add("NonQrCreditTradeAmt"); //非云闪付贷记卡交易额
  46. fields.Add("NonQrCreditTradeProfit"); //非云闪付贷记卡分润
  47. fields.Add("HelpCreditTradeAmt"); //非云闪付扶持期贷记卡交易额
  48. fields.Add("HelpCreditTradeProfit"); //非云闪付扶持期贷记卡分润
  49. fields.Add("NotHelpCreditTradeAmt"); //非云闪付稳定期贷记卡交易额
  50. fields.Add("NotHelpCreditTradeProfit"); //非云闪付稳定期贷记卡分润
  51. fields.Add("DebitTradeAmt"); //借记卡交易额
  52. fields.Add("DebitTradeProfit"); //借记卡分润
  53. fields.Add("ProfitCreditTradeAmt"); //非云闪付盈利期贷记卡交易额
  54. fields.Add("ProfitCreditTradeProfit"); //非云闪付盈利期贷记卡分润
  55. Dictionary<string, object> obj = new DbService(AppConfig.Base.dbTables, _conn).IndexData("ProfitRewardExport", relationData, orderBy, page, limit, condition, fields);
  56. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  57. count = int.Parse(obj["count"].ToString());
  58. return diclist;
  59. }
  60. public List<Dictionary<string, object>> List(List<RelationData> relationData, string condition, int page = 1, int limit = 30, string orderBy = "Sort desc,Id desc")
  61. {
  62. List<string> fields = new List<string>(); //要显示的列
  63. fields.Add("Id");
  64. fields.Add("CreateDate"); //添加时间
  65. fields.Add("Status"); //状态
  66. fields.Add("MakerCode"); //创客编号
  67. fields.Add("RealName"); //创客姓名
  68. fields.Add("UserLevel"); //创客当前等级
  69. fields.Add("Rank"); //创客预设等级
  70. fields.Add("DirectFlag"); //分润类型
  71. fields.Add("BrandName"); //品牌名称
  72. fields.Add("CreditTradeAmt"); //贷记卡交易额
  73. fields.Add("CreditTradeProfit"); //贷记卡分润
  74. fields.Add("QrCreditTradeAmt"); //云闪付贷记卡交易额
  75. fields.Add("QrCreditTradeProfit"); //云闪付贷记卡分润
  76. fields.Add("NonQrCreditTradeAmt"); //非云闪付贷记卡交易额
  77. fields.Add("NonQrCreditTradeProfit"); //非云闪付贷记卡分润
  78. fields.Add("HelpCreditTradeAmt"); //非云闪付扶持期贷记卡交易额
  79. fields.Add("HelpCreditTradeProfit"); //非云闪付扶持期贷记卡分润
  80. fields.Add("NotHelpCreditTradeAmt"); //非云闪付稳定期贷记卡交易额
  81. fields.Add("NotHelpCreditTradeProfit"); //非云闪付稳定期贷记卡分润
  82. fields.Add("DebitTradeAmt"); //借记卡交易额
  83. fields.Add("DebitTradeProfit"); //借记卡分润
  84. fields.Add("ProfitCreditTradeAmt"); //非云闪付盈利期贷记卡交易额
  85. fields.Add("ProfitCreditTradeProfit"); //非云闪付盈利期贷记卡分润
  86. Dictionary<string, object> obj = new DbService(AppConfig.Base.dbTables, _conn).IndexData("ProfitRewardExport", relationData, orderBy, page, limit, condition, fields);
  87. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  88. return diclist;
  89. }
  90. /// <summary>
  91. /// 查询一条记录
  92. /// </summary>
  93. /// <param name="Id">主键Id</param>
  94. /// <returns></returns>
  95. public ProfitRewardExport Query(int Id)
  96. {
  97. WebCMSEntities db = new WebCMSEntities();
  98. ProfitRewardExport editData = db.ProfitRewardExport.FirstOrDefault(m => m.Id == Id) ?? new ProfitRewardExport();
  99. db.Dispose();
  100. return editData;
  101. }
  102. /// <summary>
  103. /// 查询记录数
  104. /// </summary>
  105. /// <param name="Id">主键Id</param>
  106. /// <returns></returns>
  107. public int Count(string condition = "")
  108. {
  109. int result = 0;
  110. DataTable dt = CustomerSqlConn.dtable("select count(Id) from ProfitRewardExport where 1=1" + condition, _conn);
  111. if(dt.Rows.Count > 0)
  112. {
  113. result = int.Parse(function.CheckInt(dt.Rows[0][0].ToString()));
  114. }
  115. return result;
  116. }
  117. /// <summary>
  118. /// 查询是否存在
  119. /// </summary>
  120. /// <param name="Id">主键Id</param>
  121. /// <returns></returns>
  122. public bool Exist(int Id)
  123. {
  124. WebCMSEntities db = new WebCMSEntities();
  125. bool check = db.ProfitRewardExport.Any(m => m.Id == Id);
  126. db.Dispose();
  127. return check;
  128. }
  129. /// <summary>
  130. /// 添加数据
  131. /// </summary>
  132. /// <param name="Fields">要设置的字段</param>
  133. /// <returns></returns>
  134. public AppResultJson Add(Dictionary<string, object> fields, bool check = true)
  135. {
  136. if(check)
  137. {
  138. }
  139. int Id = new DbService(AppConfig.Base.dbTables, _conn).Add("ProfitRewardExport", fields, 0);
  140. return new AppResultJson(){ Status = "1", Data = Id };
  141. }
  142. /// <summary>
  143. /// 修改数据
  144. /// </summary>
  145. /// <param name="Fields">要设置的字段</param>
  146. /// <param name="Id">主键Id</param>
  147. public AppResultJson Edit(Dictionary<string, object> fields, int Id, bool check = true)
  148. {
  149. if(check)
  150. {
  151. }
  152. new DbService(AppConfig.Base.dbTables, _conn).Edit("ProfitRewardExport", fields, Id);
  153. return new AppResultJson(){ Status = "1", Data = Id };
  154. }
  155. /// <summary>
  156. /// 逻辑删除
  157. /// </summary>
  158. /// <param name="Id">主键Id</param>
  159. public void Remove(int Id)
  160. {
  161. Dictionary<string, object> fields = new Dictionary<string, object>();
  162. fields.Add("Status", -1);
  163. new DbService(AppConfig.Base.dbTables, _conn).Edit("ProfitRewardExport", fields, Id);
  164. }
  165. /// <summary>
  166. /// 删除数据
  167. /// </summary>
  168. /// <param name="Id">主键Id</param>
  169. public void Delete(int Id)
  170. {
  171. new DbService(AppConfig.Base.dbTables, _conn).Delete("ProfitRewardExport", Id);
  172. }
  173. /// <summary>
  174. /// 排序
  175. /// </summary>
  176. /// <param name="Id">主键Id</param>
  177. /// <param name="Sort">排序序号</param>
  178. public void Sort(int Id, int Sort)
  179. {
  180. new DbService(AppConfig.Base.dbTables, _conn).Sort("ProfitRewardExport", Sort, Id);
  181. }
  182. /// <summary>
  183. /// 导入数据
  184. /// </summary>
  185. /// <param name="ExcelData">json数据</param>
  186. public void Import(string ExcelData)
  187. {
  188. WebCMSEntities db = new WebCMSEntities();
  189. JsonData list = JsonMapper.ToObject(ExcelData);
  190. for (int i = 1; i < list.Count;i++ )
  191. {
  192. JsonData dr = list[i];
  193. db.ProfitRewardExport.Add(new ProfitRewardExport()
  194. {
  195. CreateDate = DateTime.Now,
  196. UpdateDate = DateTime.Now,
  197. });
  198. db.SaveChanges();
  199. }
  200. db.Dispose();
  201. }
  202. /// <summary>
  203. /// 导出excel表格
  204. /// </summary>
  205. /// <param name="fields">查询条件(单个字段)</param>
  206. /// <param name="condition">查询条件(sql语句)</param>
  207. /// <returns></returns>
  208. // public void ExportExcel(List<RelationData> relationData, string condition)
  209. // {
  210. // }
  211. }
  212. }