MerchantDepositBackService.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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 MerchantDepositBackService
  14. {
  15. static string _conn = ConfigurationManager.AppSettings["SqlConnStr"].ToString();
  16. /// <summary>
  17. /// 查询列表(适合多表关联查询)
  18. /// </summary>
  19. /// <param name="relationData">关联表</param>
  20. /// <param name="condition">查询条件(sql语句)</param>
  21. /// <param name="count">总数(输出)</param>
  22. /// <param name="page">页码</param>
  23. /// <param name="limit">每页条数</param>
  24. /// <returns></returns>
  25. public static 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")
  26. {
  27. List<string> fields = new List<string>(); //要显示的列
  28. fields.Add("Id");
  29. fields.Add("CreateDate"); //添加时间
  30. fields.Add("Status"); //状态
  31. fields.Add("MerchantId"); //商户Id
  32. fields.Add("AlipayAccountNo"); //支付宝账号
  33. fields.Add("BankCardNo"); //银行卡号
  34. fields.Add("ReturnAmount"); //退还金额
  35. fields.Add("ReturnWay"); //退还方式
  36. fields.Add("ApplyNo"); //申请单号
  37. fields.Add("UserId"); //创客Id
  38. fields.Add("Remark"); //备注
  39. Dictionary<string, object> obj = new DbService(AppConfig.Base.mainTables, _conn).IndexData("MerchantDepositBack", relationData, orderBy, page, limit, condition, fields);
  40. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  41. count = int.Parse(obj["count"].ToString());
  42. return diclist;
  43. }
  44. public static List<Dictionary<string, object>> List(List<RelationData> relationData, string condition, int page = 1, int limit = 30, string orderBy = "Sort desc,Id desc")
  45. {
  46. List<string> fields = new List<string>(); //要显示的列
  47. fields.Add("Id");
  48. fields.Add("CreateDate"); //添加时间
  49. fields.Add("Status"); //状态
  50. fields.Add("MerchantId"); //商户Id
  51. fields.Add("AlipayAccountNo"); //支付宝账号
  52. fields.Add("BankCardNo"); //银行卡号
  53. fields.Add("ReturnAmount"); //退还金额
  54. fields.Add("ReturnWay"); //退还方式
  55. fields.Add("ApplyNo"); //申请单号
  56. fields.Add("UserId"); //创客Id
  57. fields.Add("Remark"); //备注
  58. Dictionary<string, object> obj = new DbService(AppConfig.Base.mainTables, _conn).IndexData("MerchantDepositBack", relationData, orderBy, page, limit, condition, fields);
  59. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  60. return diclist;
  61. }
  62. /// <summary>
  63. /// 查询列表(单表)
  64. /// </summary>
  65. /// <param name="fieldList">返回的字段</param>
  66. /// <param name="condition">查询条件</param>
  67. /// <param name="page">页码</param>
  68. /// <param name="limit">每页条数</param>
  69. /// <param name="orderBy">排序</param>
  70. /// <returns></returns>
  71. public static List<Dictionary<string, object>> List(string fieldList, string condition, int page = 1, int limit = 30, string orderBy = "Sort desc,Id desc")
  72. {
  73. List<string> fields = fieldList.Split(',').ToList(); //要显示的列
  74. Dictionary<string, object> obj = new DbService(AppConfig.Base.mainTables, _conn).IndexData("MerchantDepositBack", new List<RelationData>(), orderBy, page, limit, condition, fields);
  75. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  76. return diclist;
  77. }
  78. /// <summary>
  79. /// 查询一条记录
  80. /// </summary>
  81. /// <param name="Id">主键Id</param>
  82. /// <returns></returns>
  83. public static MerchantDepositBack Query(int Id)
  84. {
  85. Dictionary<string, object> obj = new DbService(AppConfig.Base.mainTables, _conn).Query("*", "MerchantDepositBack", Id);
  86. if (obj.Keys.Count > 0)
  87. {
  88. return Newtonsoft.Json.JsonConvert.DeserializeObject<MerchantDepositBack>(Newtonsoft.Json.JsonConvert.SerializeObject(obj));
  89. }
  90. return new MerchantDepositBack();
  91. }
  92. /// <summary>
  93. /// 查询一条记录
  94. /// </summary>
  95. /// <param name="condition">查询条件(sql语句)</param>
  96. /// <returns></returns>
  97. public static MerchantDepositBack Query(string condition)
  98. {
  99. Dictionary<string, object> obj = new DbService(AppConfig.Base.mainTables, _conn).Query("*", "MerchantDepositBack", condition);
  100. if (obj.Keys.Count > 0)
  101. {
  102. return Newtonsoft.Json.JsonConvert.DeserializeObject<MerchantDepositBack>(Newtonsoft.Json.JsonConvert.SerializeObject(obj));
  103. }
  104. return new MerchantDepositBack();
  105. }
  106. /// <summary>
  107. /// 查询一条记录
  108. /// </summary>
  109. /// <param name="condition">查询条件(sql语句)</param>
  110. /// <param name="fields">返回的字段</param>
  111. /// <returns></returns>
  112. public static Dictionary<string, object> Query(string condition, string fields)
  113. {
  114. Dictionary<string, object> obj = new DbService(AppConfig.Base.mainTables, _conn).Query(fields, "MerchantDepositBack", condition);
  115. return obj;
  116. }
  117. public static decimal Sum(string condition, string field)
  118. {
  119. decimal amount = 0;
  120. Dictionary<string, object> obj = new DbService(AppConfig.Base.mainTables, _conn).Query("Sum(" + field + ") " + field + "", "MerchantDepositBack", condition);
  121. if (obj.Keys.Count > 0)
  122. {
  123. amount = decimal.Parse(obj[field].ToString());
  124. }
  125. return amount;
  126. }
  127. /// <summary>
  128. /// 查询记录数
  129. /// </summary>
  130. /// <param name="Id">主键Id</param>
  131. /// <returns></returns>
  132. public static int Count(string condition = "", string field = "Id")
  133. {
  134. int result = 0;
  135. Dictionary<string, object> obj = new DbService(AppConfig.Base.mainTables, _conn).Query("count(" + field + ") " + field + "", "MerchantDepositBack", condition);
  136. if (obj.Keys.Count > 0)
  137. {
  138. result = int.Parse(function.CheckInt(obj[field].ToString()));
  139. }
  140. return result;
  141. }
  142. /// <summary>
  143. /// 查询是否存在
  144. /// </summary>
  145. /// <param name="Id">主键Id</param>
  146. /// <returns></returns>
  147. public static bool Exist(string condition)
  148. {
  149. Dictionary<string, object> obj = new DbService(AppConfig.Base.mainTables, _conn).Query("1", "MerchantDepositBack", condition);
  150. if (obj.Keys.Count > 0)
  151. {
  152. return true;
  153. }
  154. return false;
  155. }
  156. /// <summary>
  157. /// 添加数据
  158. /// </summary>
  159. /// <param name="Fields">要设置的字段</param>
  160. /// <returns></returns>
  161. public static AppResultJson Add(Dictionary<string, object> fields, bool check = true)
  162. {
  163. if (check)
  164. {
  165. }
  166. int Id = new DbService(AppConfig.Base.mainTables, _conn).Add("MerchantDepositBack", fields, 0);
  167. return new AppResultJson() { Status = "1", Data = Id };
  168. }
  169. /// <summary>
  170. /// 修改数据
  171. /// </summary>
  172. /// <param name="Fields">要设置的字段</param>
  173. /// <param name="Id">主键Id</param>
  174. public static AppResultJson Edit(Dictionary<string, object> fields, int Id, bool check = true)
  175. {
  176. if (check)
  177. {
  178. }
  179. new DbService(AppConfig.Base.mainTables, _conn).Edit("MerchantDepositBack", fields, Id);
  180. return new AppResultJson() { Status = "1", Data = Id };
  181. }
  182. /// <summary>
  183. /// 逻辑删除
  184. /// </summary>
  185. /// <param name="Id">主键Id</param>
  186. public static void Remove(int Id)
  187. {
  188. Dictionary<string, object> fields = new Dictionary<string, object>();
  189. fields.Add("Status", -1);
  190. new DbService(AppConfig.Base.mainTables, _conn).Edit("MerchantDepositBack", fields, Id);
  191. }
  192. /// <summary>
  193. /// 删除数据
  194. /// </summary>
  195. /// <param name="Id">主键Id</param>
  196. public static void Delete(int Id)
  197. {
  198. new DbService(AppConfig.Base.mainTables, _conn).Delete("MerchantDepositBack", Id);
  199. }
  200. /// <summary>
  201. /// 排序
  202. /// </summary>
  203. /// <param name="Id">主键Id</param>
  204. /// <param name="Sort">排序序号</param>
  205. public static void Sort(int Id, int Sort)
  206. {
  207. new DbService(AppConfig.Base.mainTables, _conn).Sort("MerchantDepositBack", Sort, Id);
  208. }
  209. /// <summary>
  210. /// 导入数据
  211. /// </summary>
  212. /// <param name="ExcelData">json数据</param>
  213. public static void Import(string ExcelData)
  214. {
  215. // WebCMSEntities db = new WebCMSEntities();
  216. // JsonData list = JsonMapper.ToObject(ExcelData);
  217. // for (int i = 1; i < list.Count;i++ )
  218. // {
  219. // JsonData dr = list[i];
  220. // db.MerchantDepositBack.Add(new MerchantDepositBack()
  221. // {
  222. // CreateDate = DateTime.Now,
  223. // UpdateDate = DateTime.Now,
  224. // });
  225. // db.SaveChanges();
  226. // }
  227. // db.Dispose();
  228. }
  229. /// <summary>
  230. /// 导出excel表格
  231. /// </summary>
  232. /// <param name="fields">查询条件(单个字段)</param>
  233. /// <param name="condition">查询条件(sql语句)</param>
  234. /// <returns></returns>
  235. // public static void ExportExcel(List<RelationData> relationData, string condition)
  236. // {
  237. // }
  238. }
  239. }