MerchantAddInfoService.cs 25 KB

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