MerchantAddInfoService.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  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 MerchantAddInfoService
  14. {
  15. string _conn = "";
  16. public MerchantAddInfoService()
  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("ApplymentState"); //申请单状态
  36. Dictionary<string, object> obj = new DbService(AppConfig.Base.mainTables, _conn).IndexData("MerchantAddInfo", relationData, orderBy, page, limit, condition, fields);
  37. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  38. count = int.Parse(obj["count"].ToString());
  39. return diclist;
  40. }
  41. public List<Dictionary<string, object>> List(List<RelationData> relationData, string condition, int page = 1, int limit = 30, string orderBy = "Sort desc,Id desc")
  42. {
  43. List<string> fields = new List<string>(); //要显示的列
  44. fields.Add("Id");
  45. fields.Add("CreateDate"); //添加时间
  46. fields.Add("Status"); //状态
  47. fields.Add("ApplymentState"); //申请单状态
  48. Dictionary<string, object> obj = new DbService(AppConfig.Base.mainTables, _conn).IndexData("MerchantAddInfo", relationData, orderBy, page, limit, condition, fields);
  49. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  50. return diclist;
  51. }
  52. /// <summary>
  53. /// 查询一条记录
  54. /// </summary>
  55. /// <param name="Id">主键Id</param>
  56. /// <returns></returns>
  57. public MerchantAddInfo Query(int Id)
  58. {
  59. WebCMSEntities db = new WebCMSEntities();
  60. MerchantAddInfo editData = db.MerchantAddInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantAddInfo();
  61. db.Dispose();
  62. return editData;
  63. }
  64. /// <summary>
  65. /// 查询记录数
  66. /// </summary>
  67. /// <param name="Id">主键Id</param>
  68. /// <returns></returns>
  69. public int Count(string condition = "")
  70. {
  71. int result = 0;
  72. DataTable dt = CustomerSqlConn.dtable("select count(Id) from MerchantAddInfo where 1=1" + condition, _conn);
  73. if(dt.Rows.Count > 0)
  74. {
  75. result = int.Parse(function.CheckInt(dt.Rows[0][0].ToString()));
  76. }
  77. return result;
  78. }
  79. /// <summary>
  80. /// 查询是否存在
  81. /// </summary>
  82. /// <param name="Id">主键Id</param>
  83. /// <returns></returns>
  84. public bool Exist(int Id)
  85. {
  86. WebCMSEntities db = new WebCMSEntities();
  87. bool check = db.MerchantAddInfo.Any(m => m.Id == Id);
  88. db.Dispose();
  89. return check;
  90. }
  91. /// <summary>
  92. /// 添加数据
  93. /// </summary>
  94. /// <param name="Fields">要设置的字段</param>
  95. /// <returns></returns>
  96. public AppResultJson Add(Dictionary<string, object> fields, bool check = true)
  97. {
  98. if(check)
  99. {
  100. if (string.IsNullOrEmpty(fields["ContactName"].ToString()))
  101. {
  102. return new AppResultJson() { Status = "-1", Info = "请填写管理员姓名" };
  103. }
  104. if (string.IsNullOrEmpty(fields["ContactIdNumber"].ToString()))
  105. {
  106. return new AppResultJson() { Status = "-1", Info = "请填写管理员身份证件号码" };
  107. }
  108. if (function.CheckIdCard(fields["ContactIdNumber"].ToString()) == "")
  109. {
  110. return new AppResultJson() { Status = "-1", Info = "请填写正确的管理员身份证件号码" };
  111. }
  112. if (string.IsNullOrEmpty(fields["OpenId"].ToString()))
  113. {
  114. return new AppResultJson() { Status = "-1", Info = "请填写管理员微信openid" };
  115. }
  116. if (string.IsNullOrEmpty(fields["MobilePhone"].ToString()))
  117. {
  118. return new AppResultJson() { Status = "-1", Info = "请填写联系手机" };
  119. }
  120. if (function.CheckMobile(fields["MobilePhone"].ToString()) == "")
  121. {
  122. return new AppResultJson() { Status = "-1", Info = "请填写正确的联系手机" };
  123. }
  124. if (string.IsNullOrEmpty(fields["ContactEmail"].ToString()))
  125. {
  126. return new AppResultJson() { Status = "-1", Info = "请填写联系邮箱" };
  127. }
  128. if (string.IsNullOrEmpty(fields["SubjectType"].ToString()))
  129. {
  130. return new AppResultJson() { Status = "-1", Info = "请填写主体类型" };
  131. }
  132. if (string.IsNullOrEmpty(fields["LicenseNumber"].ToString()))
  133. {
  134. return new AppResultJson() { Status = "-1", Info = "请填写统一社会信用代码" };
  135. }
  136. if (string.IsNullOrEmpty(fields["LegalPerson"].ToString()))
  137. {
  138. return new AppResultJson() { Status = "-1", Info = "请填写个体户经营者/法人姓名" };
  139. }
  140. if (string.IsNullOrEmpty(fields["MerchantShortname"].ToString()))
  141. {
  142. return new AppResultJson() { Status = "-1", Info = "请填写商户简称" };
  143. }
  144. if (string.IsNullOrEmpty(fields["SalesScenesType"].ToString()))
  145. {
  146. return new AppResultJson() { Status = "-1", Info = "请填写经营场景类型" };
  147. }
  148. if (string.IsNullOrEmpty(fields["BizStoreName"].ToString()))
  149. {
  150. return new AppResultJson() { Status = "-1", Info = "请填写门店名称" };
  151. }
  152. if (string.IsNullOrEmpty(fields["BizAddressCode"].ToString()))
  153. {
  154. return new AppResultJson() { Status = "-1", Info = "请填写门店省市编码" };
  155. }
  156. if (string.IsNullOrEmpty(fields["BizStoreAddress"].ToString()))
  157. {
  158. return new AppResultJson() { Status = "-1", Info = "请填写门店地址" };
  159. }
  160. if (string.IsNullOrEmpty(fields["MpAppid"].ToString()))
  161. {
  162. return new AppResultJson() { Status = "-1", Info = "请填写服务商公众号APPID" };
  163. }
  164. if (string.IsNullOrEmpty(fields["MpSubAppid"].ToString()))
  165. {
  166. return new AppResultJson() { Status = "-1", Info = "请填写商家公众号APPID" };
  167. }
  168. if (string.IsNullOrEmpty(fields["MiniProgramAppid"].ToString()))
  169. {
  170. return new AppResultJson() { Status = "-1", Info = "请填写服务商小程序APPID" };
  171. }
  172. if (string.IsNullOrEmpty(fields["MiniProgramSubAppid"].ToString()))
  173. {
  174. return new AppResultJson() { Status = "-1", Info = "请填写商家小程序APPID" };
  175. }
  176. if (string.IsNullOrEmpty(fields["AppAppid"].ToString()))
  177. {
  178. return new AppResultJson() { Status = "-1", Info = "请填写服务商应用APPID" };
  179. }
  180. if (string.IsNullOrEmpty(fields["AppSubAppid"].ToString()))
  181. {
  182. return new AppResultJson() { Status = "-1", Info = "请填写商家应用APPID" };
  183. }
  184. if (string.IsNullOrEmpty(fields["WebDomain"].ToString()))
  185. {
  186. return new AppResultJson() { Status = "-1", Info = "请填写互联网网站域名" };
  187. }
  188. if (string.IsNullOrEmpty(fields["WebAppId"].ToString()))
  189. {
  190. return new AppResultJson() { Status = "-1", Info = "请填写互联网网站对应的商家APPID" };
  191. }
  192. if (string.IsNullOrEmpty(fields["SubCorpId"].ToString()))
  193. {
  194. return new AppResultJson() { Status = "-1", Info = "请填写商家企业微信CorpID" };
  195. }
  196. if (string.IsNullOrEmpty(fields["SettlementId"].ToString()))
  197. {
  198. return new AppResultJson() { Status = "-1", Info = "请填写入驻结算规则ID" };
  199. }
  200. if (string.IsNullOrEmpty(fields["QualificationType"].ToString()))
  201. {
  202. return new AppResultJson() { Status = "-1", Info = "请填写所属行业" };
  203. }
  204. if (string.IsNullOrEmpty(fields["ActivitiesId"].ToString()))
  205. {
  206. return new AppResultJson() { Status = "-1", Info = "请填写优惠费率活动ID" };
  207. }
  208. if (string.IsNullOrEmpty(fields["BankAccountType"].ToString()))
  209. {
  210. return new AppResultJson() { Status = "-1", Info = "请填写账户类型" };
  211. }
  212. if (string.IsNullOrEmpty(fields["AccountName"].ToString()))
  213. {
  214. return new AppResultJson() { Status = "-1", Info = "请填写开户名称" };
  215. }
  216. if (string.IsNullOrEmpty(fields["AccountBank"].ToString()))
  217. {
  218. return new AppResultJson() { Status = "-1", Info = "请填写开户银行" };
  219. }
  220. if (string.IsNullOrEmpty(fields["BankAddressCode"].ToString()))
  221. {
  222. return new AppResultJson() { Status = "-1", Info = "请填写开户银行省市编码" };
  223. }
  224. if (string.IsNullOrEmpty(fields["BankBranchId"].ToString()))
  225. {
  226. return new AppResultJson() { Status = "-1", Info = "请填写开户银行联行号" };
  227. }
  228. if (string.IsNullOrEmpty(fields["BankName"].ToString()))
  229. {
  230. return new AppResultJson() { Status = "-1", Info = "请填写开户银行全称" };
  231. }
  232. if (string.IsNullOrEmpty(fields["AccountNumber"].ToString()))
  233. {
  234. return new AppResultJson() { Status = "-1", Info = "请填写银行账号" };
  235. }
  236. }
  237. int Id = new DbService(AppConfig.Base.mainTables, _conn).Add("MerchantAddInfo", fields, 0);
  238. return new AppResultJson(){ Status = "1", Data = Id };
  239. }
  240. /// <summary>
  241. /// 修改数据
  242. /// </summary>
  243. /// <param name="Fields">要设置的字段</param>
  244. /// <param name="Id">主键Id</param>
  245. public AppResultJson Edit(Dictionary<string, object> fields, int Id, bool check = true)
  246. {
  247. if(check)
  248. {
  249. if (string.IsNullOrEmpty(fields["ContactName"].ToString()))
  250. {
  251. return new AppResultJson() { Status = "-1", Info = "请填写管理员姓名" };
  252. }
  253. if (string.IsNullOrEmpty(fields["ContactIdNumber"].ToString()))
  254. {
  255. return new AppResultJson() { Status = "-1", Info = "请填写管理员身份证件号码" };
  256. }
  257. if (function.CheckIdCard(fields["ContactIdNumber"].ToString()) == "")
  258. {
  259. return new AppResultJson() { Status = "-1", Info = "请填写正确的管理员身份证件号码" };
  260. }
  261. if (string.IsNullOrEmpty(fields["OpenId"].ToString()))
  262. {
  263. return new AppResultJson() { Status = "-1", Info = "请填写管理员微信openid" };
  264. }
  265. if (string.IsNullOrEmpty(fields["MobilePhone"].ToString()))
  266. {
  267. return new AppResultJson() { Status = "-1", Info = "请填写联系手机" };
  268. }
  269. if (function.CheckMobile(fields["MobilePhone"].ToString()) == "")
  270. {
  271. return new AppResultJson() { Status = "-1", Info = "请填写正确的联系手机" };
  272. }
  273. if (string.IsNullOrEmpty(fields["ContactEmail"].ToString()))
  274. {
  275. return new AppResultJson() { Status = "-1", Info = "请填写联系邮箱" };
  276. }
  277. if (string.IsNullOrEmpty(fields["SubjectType"].ToString()))
  278. {
  279. return new AppResultJson() { Status = "-1", Info = "请填写主体类型" };
  280. }
  281. if (string.IsNullOrEmpty(fields["LicenseNumber"].ToString()))
  282. {
  283. return new AppResultJson() { Status = "-1", Info = "请填写统一社会信用代码" };
  284. }
  285. if (string.IsNullOrEmpty(fields["LegalPerson"].ToString()))
  286. {
  287. return new AppResultJson() { Status = "-1", Info = "请填写个体户经营者/法人姓名" };
  288. }
  289. if (string.IsNullOrEmpty(fields["MerchantShortname"].ToString()))
  290. {
  291. return new AppResultJson() { Status = "-1", Info = "请填写商户简称" };
  292. }
  293. if (string.IsNullOrEmpty(fields["SalesScenesType"].ToString()))
  294. {
  295. return new AppResultJson() { Status = "-1", Info = "请填写经营场景类型" };
  296. }
  297. if (string.IsNullOrEmpty(fields["BizStoreName"].ToString()))
  298. {
  299. return new AppResultJson() { Status = "-1", Info = "请填写门店名称" };
  300. }
  301. if (string.IsNullOrEmpty(fields["BizAddressCode"].ToString()))
  302. {
  303. return new AppResultJson() { Status = "-1", Info = "请填写门店省市编码" };
  304. }
  305. if (string.IsNullOrEmpty(fields["BizStoreAddress"].ToString()))
  306. {
  307. return new AppResultJson() { Status = "-1", Info = "请填写门店地址" };
  308. }
  309. if (string.IsNullOrEmpty(fields["MpAppid"].ToString()))
  310. {
  311. return new AppResultJson() { Status = "-1", Info = "请填写服务商公众号APPID" };
  312. }
  313. if (string.IsNullOrEmpty(fields["MpSubAppid"].ToString()))
  314. {
  315. return new AppResultJson() { Status = "-1", Info = "请填写商家公众号APPID" };
  316. }
  317. if (string.IsNullOrEmpty(fields["MiniProgramAppid"].ToString()))
  318. {
  319. return new AppResultJson() { Status = "-1", Info = "请填写服务商小程序APPID" };
  320. }
  321. if (string.IsNullOrEmpty(fields["MiniProgramSubAppid"].ToString()))
  322. {
  323. return new AppResultJson() { Status = "-1", Info = "请填写商家小程序APPID" };
  324. }
  325. if (string.IsNullOrEmpty(fields["AppAppid"].ToString()))
  326. {
  327. return new AppResultJson() { Status = "-1", Info = "请填写服务商应用APPID" };
  328. }
  329. if (string.IsNullOrEmpty(fields["AppSubAppid"].ToString()))
  330. {
  331. return new AppResultJson() { Status = "-1", Info = "请填写商家应用APPID" };
  332. }
  333. if (string.IsNullOrEmpty(fields["WebDomain"].ToString()))
  334. {
  335. return new AppResultJson() { Status = "-1", Info = "请填写互联网网站域名" };
  336. }
  337. if (string.IsNullOrEmpty(fields["WebAppId"].ToString()))
  338. {
  339. return new AppResultJson() { Status = "-1", Info = "请填写互联网网站对应的商家APPID" };
  340. }
  341. if (string.IsNullOrEmpty(fields["SubCorpId"].ToString()))
  342. {
  343. return new AppResultJson() { Status = "-1", Info = "请填写商家企业微信CorpID" };
  344. }
  345. if (string.IsNullOrEmpty(fields["SettlementId"].ToString()))
  346. {
  347. return new AppResultJson() { Status = "-1", Info = "请填写入驻结算规则ID" };
  348. }
  349. if (string.IsNullOrEmpty(fields["QualificationType"].ToString()))
  350. {
  351. return new AppResultJson() { Status = "-1", Info = "请填写所属行业" };
  352. }
  353. if (string.IsNullOrEmpty(fields["ActivitiesId"].ToString()))
  354. {
  355. return new AppResultJson() { Status = "-1", Info = "请填写优惠费率活动ID" };
  356. }
  357. if (string.IsNullOrEmpty(fields["BankAccountType"].ToString()))
  358. {
  359. return new AppResultJson() { Status = "-1", Info = "请填写账户类型" };
  360. }
  361. if (string.IsNullOrEmpty(fields["AccountName"].ToString()))
  362. {
  363. return new AppResultJson() { Status = "-1", Info = "请填写开户名称" };
  364. }
  365. if (string.IsNullOrEmpty(fields["AccountBank"].ToString()))
  366. {
  367. return new AppResultJson() { Status = "-1", Info = "请填写开户银行" };
  368. }
  369. if (string.IsNullOrEmpty(fields["BankAddressCode"].ToString()))
  370. {
  371. return new AppResultJson() { Status = "-1", Info = "请填写开户银行省市编码" };
  372. }
  373. if (string.IsNullOrEmpty(fields["BankBranchId"].ToString()))
  374. {
  375. return new AppResultJson() { Status = "-1", Info = "请填写开户银行联行号" };
  376. }
  377. if (string.IsNullOrEmpty(fields["BankName"].ToString()))
  378. {
  379. return new AppResultJson() { Status = "-1", Info = "请填写开户银行全称" };
  380. }
  381. if (string.IsNullOrEmpty(fields["AccountNumber"].ToString()))
  382. {
  383. return new AppResultJson() { Status = "-1", Info = "请填写银行账号" };
  384. }
  385. }
  386. new DbService(AppConfig.Base.mainTables, _conn).Edit("MerchantAddInfo", fields, Id);
  387. return new AppResultJson(){ Status = "1", Data = Id };
  388. }
  389. /// <summary>
  390. /// 逻辑删除
  391. /// </summary>
  392. /// <param name="Id">主键Id</param>
  393. public void Remove(int Id)
  394. {
  395. Dictionary<string, object> fields = new Dictionary<string, object>();
  396. fields.Add("Status", -1);
  397. new DbService(AppConfig.Base.mainTables, _conn).Edit("MerchantAddInfo", fields, Id);
  398. }
  399. /// <summary>
  400. /// 删除数据
  401. /// </summary>
  402. /// <param name="Id">主键Id</param>
  403. public void Delete(int Id)
  404. {
  405. new DbService(AppConfig.Base.mainTables, _conn).Delete("MerchantAddInfo", Id);
  406. }
  407. /// <summary>
  408. /// 排序
  409. /// </summary>
  410. /// <param name="Id">主键Id</param>
  411. /// <param name="Sort">排序序号</param>
  412. public void Sort(int Id, int Sort)
  413. {
  414. new DbService(AppConfig.Base.mainTables, _conn).Sort("MerchantAddInfo", Sort, Id);
  415. }
  416. /// <summary>
  417. /// 导入数据
  418. /// </summary>
  419. /// <param name="ExcelData">json数据</param>
  420. public void Import(string ExcelData)
  421. {
  422. WebCMSEntities db = new WebCMSEntities();
  423. JsonData list = JsonMapper.ToObject(ExcelData);
  424. for (int i = 1; i < list.Count;i++ )
  425. {
  426. JsonData dr = list[i];
  427. db.MerchantAddInfo.Add(new MerchantAddInfo()
  428. {
  429. CreateDate = DateTime.Now,
  430. UpdateDate = DateTime.Now,
  431. });
  432. db.SaveChanges();
  433. }
  434. db.Dispose();
  435. }
  436. /// <summary>
  437. /// 导出excel表格
  438. /// </summary>
  439. /// <param name="fields">查询条件(单个字段)</param>
  440. /// <param name="condition">查询条件(sql语句)</param>
  441. /// <returns></returns>
  442. // public void ExportExcel(List<RelationData> relationData, string condition)
  443. // {
  444. // }
  445. }
  446. }