PosMerchantInfoBakService.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /*
  2. * POS商户(解绑备份)
  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 PosMerchantInfoBakService
  14. {
  15. string _conn = "";
  16. public PosMerchantInfoBakService()
  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("MerchantNo"); //商户编号
  36. fields.Add("MerchantName"); //商户姓名
  37. fields.Add("MerchantMobile"); //商户手机号
  38. fields.Add("KqMerNo"); //渠道商户编码
  39. fields.Add("KqSnNo"); //渠道SN号
  40. fields.Add("MerStatus"); //商户状态
  41. fields.Add("ActiveStatus"); //商户激活状态
  42. fields.Add("DirectUserId"); //直属创客编号
  43. fields.Add("UserId"); //创客
  44. fields.Add("MerUserId"); //商户创客
  45. fields.Add("SnType"); //机具类型
  46. fields.Add("SnApplyUserId"); //机具SN申请创客
  47. fields.Add("KqRegTime"); //渠道注册时间
  48. fields.Add("ActType"); //激活类型
  49. fields.Add("SnStoreId"); //SN仓库
  50. fields.Add("BrandId"); //品牌
  51. fields.Add("MerUserType"); //商户创客类型
  52. Dictionary<string, object> obj = new DbService(AppConfig.Base.dbTables, _conn).IndexData("PosMerchantInfoBak", relationData, orderBy, page, limit, condition, fields);
  53. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  54. count = int.Parse(obj["count"].ToString());
  55. return diclist;
  56. }
  57. public List<Dictionary<string, object>> List(List<RelationData> relationData, string condition, int page = 1, int limit = 30, string orderBy = "Sort desc,Id desc")
  58. {
  59. List<string> fields = new List<string>(); //要显示的列
  60. fields.Add("Id");
  61. fields.Add("CreateDate"); //添加时间
  62. fields.Add("Status"); //状态
  63. fields.Add("MerchantNo"); //商户编号
  64. fields.Add("MerchantName"); //商户姓名
  65. fields.Add("MerchantMobile"); //商户手机号
  66. fields.Add("KqMerNo"); //渠道商户编码
  67. fields.Add("KqSnNo"); //渠道SN号
  68. fields.Add("MerStatus"); //商户状态
  69. fields.Add("ActiveStatus"); //商户激活状态
  70. fields.Add("DirectUserId"); //直属创客编号
  71. fields.Add("UserId"); //创客
  72. fields.Add("MerUserId"); //商户创客
  73. fields.Add("SnType"); //机具类型
  74. fields.Add("SnApplyUserId"); //机具SN申请创客
  75. fields.Add("KqRegTime"); //渠道注册时间
  76. fields.Add("ActType"); //激活类型
  77. fields.Add("SnStoreId"); //SN仓库
  78. fields.Add("BrandId"); //品牌
  79. fields.Add("MerUserType"); //商户创客类型
  80. Dictionary<string, object> obj = new DbService(AppConfig.Base.dbTables, _conn).IndexData("PosMerchantInfoBak", relationData, orderBy, page, limit, condition, fields);
  81. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  82. return diclist;
  83. }
  84. /// <summary>
  85. /// 查询一条记录
  86. /// </summary>
  87. /// <param name="Id">主键Id</param>
  88. /// <returns></returns>
  89. public PosMerchantInfoBak Query(int Id)
  90. {
  91. WebCMSEntities db = new WebCMSEntities();
  92. PosMerchantInfoBak editData = db.PosMerchantInfoBak.FirstOrDefault(m => m.Id == Id) ?? new PosMerchantInfoBak();
  93. db.Dispose();
  94. return editData;
  95. }
  96. /// <summary>
  97. /// 查询记录数
  98. /// </summary>
  99. /// <param name="Id">主键Id</param>
  100. /// <returns></returns>
  101. public int Count(string condition = "")
  102. {
  103. int result = 0;
  104. DataTable dt = CustomerSqlConn.dtable("select count(Id) from PosMerchantInfoBak where 1=1" + condition, _conn);
  105. if(dt.Rows.Count > 0)
  106. {
  107. result = int.Parse(function.CheckInt(dt.Rows[0][0].ToString()));
  108. }
  109. return result;
  110. }
  111. /// <summary>
  112. /// 查询是否存在
  113. /// </summary>
  114. /// <param name="Id">主键Id</param>
  115. /// <returns></returns>
  116. public bool Exist(int Id)
  117. {
  118. WebCMSEntities db = new WebCMSEntities();
  119. bool check = db.PosMerchantInfoBak.Any(m => m.Id == Id);
  120. db.Dispose();
  121. return check;
  122. }
  123. /// <summary>
  124. /// 添加数据
  125. /// </summary>
  126. /// <param name="Fields">要设置的字段</param>
  127. /// <returns></returns>
  128. public AppResultJson Add(Dictionary<string, object> fields, bool check = true)
  129. {
  130. if(check)
  131. {
  132. }
  133. int Id = new DbService(AppConfig.Base.dbTables, _conn).Add("PosMerchantInfoBak", fields, 0);
  134. return new AppResultJson(){ Status = "1", Data = Id };
  135. }
  136. /// <summary>
  137. /// 修改数据
  138. /// </summary>
  139. /// <param name="Fields">要设置的字段</param>
  140. /// <param name="Id">主键Id</param>
  141. public AppResultJson Edit(Dictionary<string, object> fields, int Id, bool check = true)
  142. {
  143. if(check)
  144. {
  145. }
  146. new DbService(AppConfig.Base.dbTables, _conn).Edit("PosMerchantInfoBak", fields, Id);
  147. return new AppResultJson(){ Status = "1", Data = Id };
  148. }
  149. /// <summary>
  150. /// 逻辑删除
  151. /// </summary>
  152. /// <param name="Id">主键Id</param>
  153. public void Remove(int Id)
  154. {
  155. Dictionary<string, object> fields = new Dictionary<string, object>();
  156. fields.Add("Status", -1);
  157. new DbService(AppConfig.Base.dbTables, _conn).Edit("PosMerchantInfoBak", fields, Id);
  158. }
  159. /// <summary>
  160. /// 删除数据
  161. /// </summary>
  162. /// <param name="Id">主键Id</param>
  163. public void Delete(int Id)
  164. {
  165. new DbService(AppConfig.Base.dbTables, _conn).Delete("PosMerchantInfoBak", Id);
  166. }
  167. /// <summary>
  168. /// 排序
  169. /// </summary>
  170. /// <param name="Id">主键Id</param>
  171. /// <param name="Sort">排序序号</param>
  172. public void Sort(int Id, int Sort)
  173. {
  174. new DbService(AppConfig.Base.dbTables, _conn).Sort("PosMerchantInfoBak", Sort, Id);
  175. }
  176. /// <summary>
  177. /// 导入数据
  178. /// </summary>
  179. /// <param name="ExcelData">json数据</param>
  180. public void Import(string ExcelData)
  181. {
  182. WebCMSEntities db = new WebCMSEntities();
  183. JsonData list = JsonMapper.ToObject(ExcelData);
  184. for (int i = 1; i < list.Count;i++ )
  185. {
  186. JsonData dr = list[i];
  187. db.PosMerchantInfoBak.Add(new PosMerchantInfoBak()
  188. {
  189. CreateDate = DateTime.Now,
  190. UpdateDate = DateTime.Now,
  191. });
  192. db.SaveChanges();
  193. }
  194. db.Dispose();
  195. }
  196. /// <summary>
  197. /// 导出excel表格
  198. /// </summary>
  199. /// <param name="fields">查询条件(单个字段)</param>
  200. /// <param name="condition">查询条件(sql语句)</param>
  201. /// <returns></returns>
  202. // public void ExportExcel(List<RelationData> relationData, string condition)
  203. // {
  204. // }
  205. }
  206. }