MachineForSnNoService.cs 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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 MachineForSnNoService
  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("MakerCode"); //创客编号
  32. fields.Add("RealName"); //真实姓名
  33. fields.Add("Mobile"); //手机号
  34. fields.Add("CertId"); //身份证号
  35. fields.Add("UserLevel"); //创客等级
  36. fields.Add("AgentAreas"); //代理区域
  37. fields.Add("MerchantType"); //商户创客类型
  38. fields.Add("MerchantDate"); //成为商户型创客时间
  39. fields.Add("AuthFlag"); //实名标识
  40. fields.Add("AuthDate"); //实名时间
  41. fields.Add("RiskFlag"); //风控标识
  42. fields.Add("ParentUserId"); //直属创客Id
  43. fields.Add("ParentNav"); //父级集合
  44. // fields.Add("SettleAmount"); //最低结算金额
  45. // fields.Add("CashFreezeAmt"); //提现冻结金额
  46. // fields.Add("CertValidStartDate"); //身份证有效期开始时间
  47. // fields.Add("CertValidEndDate"); //身份证有效期结束时间
  48. // fields.Add("SettleBankCardName"); //结算银行卡户名
  49. // fields.Add("AgentLevel"); //代理等级
  50. // fields.Add("CashStatus"); //代付账户状态
  51. // fields.Add("LeaderLevel"); //盟主等级
  52. // fields.Add("BusinessFlag"); //企业标记
  53. // fields.Add("DeviceType"); //设备类型
  54. // fields.Add("HelpProfitAgree"); //助利宝协议标记
  55. // fields.Add("HelpProfitAgreeDate"); //助利宝协议标记时间
  56. Dictionary<string, object> obj = new DbService(AppConfig.Base.mainTables, _conn).IndexData("MachineForSnNo", relationData, orderBy, page, limit, condition, fields);
  57. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  58. count = int.Parse(obj["count"].ToString());
  59. return diclist;
  60. }
  61. public static List<Dictionary<string, object>> List(List<RelationData> relationData, string condition, int page = 1, int limit = 30, string orderBy = "Sort desc,Id desc")
  62. {
  63. List<string> fields = new List<string>(); //要显示的列
  64. fields.Add("Id");
  65. fields.Add("CreateDate"); //添加时间
  66. fields.Add("Status"); //状态
  67. fields.Add("RealName"); //真实姓名
  68. fields.Add("CertId"); //身份证号
  69. fields.Add("UserLevel"); //创客等级
  70. fields.Add("MerchantType"); //商户创客类型
  71. fields.Add("MerchantDate"); //成为商户型创客时间
  72. fields.Add("AuthFlag"); //实名标识
  73. fields.Add("RiskFlag"); //风控标识
  74. fields.Add("MakerCode"); //创客编号
  75. fields.Add("SettleAmount"); //最低结算金额
  76. fields.Add("CashFreezeAmt"); //提现冻结金额
  77. fields.Add("CertValidStartDate"); //身份证有效期开始时间
  78. fields.Add("CertValidEndDate"); //身份证有效期结束时间
  79. fields.Add("SettleBankCardName"); //结算银行卡户名
  80. fields.Add("AgentLevel"); //代理等级
  81. fields.Add("AgentAreas"); //代理区域
  82. fields.Add("CashStatus"); //代付账户状态
  83. fields.Add("LeaderLevel"); //盟主等级
  84. fields.Add("BusinessFlag"); //企业标记
  85. fields.Add("DeviceType"); //设备类型
  86. fields.Add("HelpProfitAgree"); //助利宝协议标记
  87. fields.Add("HelpProfitAgreeDate"); //助利宝协议标记时间
  88. Dictionary<string, object> obj = new DbService(AppConfig.Base.mainTables, _conn).IndexData("MachineForSnNo", relationData, orderBy, page, limit, condition, fields);
  89. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  90. return diclist;
  91. }
  92. /// <summary>
  93. /// 查询一条记录
  94. /// </summary>
  95. /// <param name="SnNo">商户号</param>
  96. /// <returns></returns>
  97. public static MachineForSnNo Query(string SnNo)
  98. {
  99. WebCMSEntities db = new WebCMSEntities();
  100. MachineForSnNo editData = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == SnNo) ?? new MachineForSnNo();
  101. db.Dispose();
  102. return editData;
  103. }
  104. public static MachineForSnNo Query(string condition, string fields = "*")
  105. {
  106. // DataTable dt = new DbService(AppConfig.Base.mainTables, _conn).QueryDetail(fields, "MachineForSnNo", condition);
  107. // if(dt.Rows.Count > 0)
  108. // {
  109. // Dictionary<string, object> row = new Dictionary<string, object>();
  110. // foreach(DataColumn dc in dt.Columns)
  111. // {
  112. // row.Add(dc.ColumnName, dt.Rows[0][dc.ColumnName].ToString());
  113. // }
  114. // return Newtonsoft.Json.JsonConvert.DeserializeObject<MachineForSnNo>(Newtonsoft.Json.JsonConvert.SerializeObject(row));
  115. // }
  116. var machineForSnNo = new DbService(AppConfig.Base.mainTables, _conn).Query(fields, "MachineForSnNo", condition);
  117. if (machineForSnNo.Count > 0)
  118. {
  119. return Newtonsoft.Json.JsonConvert.DeserializeObject<MachineForSnNo>(Newtonsoft.Json.JsonConvert.SerializeObject(machineForSnNo));
  120. }
  121. return new MachineForSnNo();
  122. }
  123. /// <summary>
  124. /// 查询记录数
  125. /// </summary>
  126. /// <param name="Id">主键Id</param>
  127. /// <returns></returns>
  128. public static int Count(string condition = "")
  129. {
  130. int result = 0;
  131. DataTable dt = CustomerSqlConn.dtable("select count(Id) from MachineForSnNo where 1=1" + condition, _conn);
  132. if (dt.Rows.Count > 0)
  133. {
  134. result = int.Parse(function.CheckInt(dt.Rows[0][0].ToString()));
  135. }
  136. return result;
  137. }
  138. /// <summary>
  139. /// 查询是否存在
  140. /// </summary>
  141. /// <param name="SnNo">商户编号</param>
  142. /// <returns></returns>
  143. public static bool Exist(string SnNo)
  144. {
  145. WebCMSEntities db = new WebCMSEntities();
  146. bool check = db.MachineForSnNo.Any(m => m.SnNo == SnNo);
  147. db.Dispose();
  148. return check;
  149. }
  150. /// <summary>
  151. /// 添加数据
  152. /// </summary>
  153. /// <param name="Fields">要设置的字段</param>
  154. /// <returns></returns>
  155. public static AppResultJson Add(Dictionary<string, object> fields, bool check = true)
  156. {
  157. int Id = new DbService(AppConfig.Base.mainTables, _conn).Add("MachineForSnNo", fields, 0);
  158. return new AppResultJson() { Status = "1", Data = Id };
  159. }
  160. /// <summary>
  161. /// 修改数据
  162. /// </summary>
  163. /// <param name="Fields">要设置的字段</param>
  164. /// <param name="Id">主键Id</param>
  165. public static AppResultJson Edit(Dictionary<string, object> fields, int Id, bool check = true)
  166. {
  167. new DbService(AppConfig.Base.mainTables, _conn).Edit("MachineForSnNo", fields, Id);
  168. return new AppResultJson() { Status = "1", Data = Id };
  169. }
  170. /// <summary>
  171. /// 逻辑删除
  172. /// </summary>
  173. /// <param name="SnId">机具Id</param>
  174. public static void Remove(int SnId)
  175. {
  176. Dictionary<string, object> fields = new Dictionary<string, object>();
  177. fields.Add("Status", -1);
  178. new DbService(AppConfig.Base.mainTables, _conn).Edit("MachineForSnNo", fields, SnId);
  179. }
  180. /// <summary>
  181. /// 删除数据
  182. /// </summary>
  183. /// <param name="SnId">机具Id</param>
  184. public static void Delete(int SnId)
  185. {
  186. new DbService(AppConfig.Base.mainTables, _conn).Delete("MachineForSnNo", SnId);
  187. }
  188. public static void DeleteByLinq(string condition, string fields = "*")
  189. {
  190. DataTable dt = new DbService(AppConfig.Base.mainTables, _conn).QueryDetail(fields, "MachineForSnNo", condition);
  191. }
  192. /// <summary>
  193. /// 排序
  194. /// </summary>
  195. /// <param name="Id">主键Id</param>
  196. /// <param name="Sort">排序序号</param>
  197. public static void Sort(int Id, int Sort)
  198. {
  199. new DbService(AppConfig.Base.mainTables, _conn).Sort("MachineForSnNo", Sort, Id);
  200. }
  201. /// <summary>
  202. /// 导出excel表格
  203. /// </summary>
  204. /// <param name="fields">查询条件(单个字段)</param>
  205. /// <param name="condition">查询条件(sql语句)</param>
  206. /// <returns></returns>
  207. // public static void ExportExcel(List<RelationData> relationData, string condition)
  208. // {
  209. // }
  210. }
  211. }