PosMerchantInfoListController.cs 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131
  1. /*
  2. * 商户
  3. */
  4. using System;
  5. using System.Web;
  6. using System.Collections.Generic;
  7. using System.Diagnostics;
  8. using System.Linq;
  9. using System.Data;
  10. using System.Threading.Tasks;
  11. using Microsoft.AspNetCore.Mvc;
  12. using Microsoft.AspNetCore.Http;
  13. using Microsoft.Extensions.Logging;
  14. using Microsoft.Extensions.Options;
  15. using MySystem.Models;
  16. using Library;
  17. using LitJson;
  18. using MySystemLib;
  19. namespace MySystem.Areas.Admin.Controllers
  20. {
  21. [Area("Admin")]
  22. [Route("Admin/[controller]/[action]")]
  23. public class PosMerchantInfoListController : BaseController
  24. {
  25. public PosMerchantInfoListController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
  26. {
  27. OtherMySqlConn.connstr = ConfigurationManager.AppSettings["SqlConnStr"].ToString();
  28. }
  29. #region 商户列表
  30. /// <summary>
  31. /// 根据条件查询商户列表
  32. /// </summary>
  33. /// <returns></returns>
  34. public IActionResult Index(PosMerchantInfo data, string right, string BrandId)
  35. {
  36. ViewBag.RightInfo = RightInfo;
  37. ViewBag.right = right;
  38. ViewBag.BrandId = BrandId;
  39. return View();
  40. }
  41. #endregion
  42. #region 根据条件查询商户列表
  43. /// <summary>
  44. /// 商户列表
  45. /// </summary>
  46. /// <returns></returns>
  47. public JsonResult IndexData(PosMerchantInfo data, string MerIdcardNo, string MerchantName, string PhoneNo, string PosSn, int ShowFlag = 0, int page = 1, int limit = 30)
  48. {
  49. Dictionary<string, string> Fields = new Dictionary<string, string>();
  50. if (ShowFlag == 0)
  51. {
  52. Dictionary<string, object> objs = new Dictionary<string, object>();
  53. return Json(objs);
  54. }
  55. string condition = " and Status>-1";
  56. //身份证号
  57. if (!string.IsNullOrEmpty(MerIdcardNo))
  58. {
  59. var IdCardf = MerIdcardNo.Substring(0, 6);
  60. var IdCardb = MerIdcardNo.Substring(MerIdcardNo.Length - 4);
  61. condition += " and LEFT(MerIdcardNo,6)=" + IdCardf + " AND RIGHT(MerIdcardNo,4)=" + IdCardb + "";
  62. }
  63. //商户姓名
  64. if (!string.IsNullOrEmpty(MerchantName))
  65. {
  66. condition += " and MerchantName like '%" + MerchantName + "%'";
  67. }
  68. //手机号
  69. if (!string.IsNullOrEmpty(PhoneNo))
  70. {
  71. var PhoneNof = PhoneNo.Substring(0, 3);
  72. var PhoneNob = PhoneNo.Substring(PhoneNo.Length - 4);
  73. condition += " and LEFT(MerchantMobile,3)=" + PhoneNof + " AND RIGHT(MerchantMobile,4)=" + PhoneNob + "";
  74. }
  75. //机具号
  76. if (!string.IsNullOrEmpty(PosSn))
  77. {
  78. condition += " and KqSnNo='" + PosSn + "'";
  79. }
  80. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("PosMerchantInfo", Fields, "Id desc", "0", page, limit, condition);
  81. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  82. foreach (Dictionary<string, object> dic in diclist)
  83. {
  84. //直属创客
  85. int UserId = int.Parse(dic["UserId"].ToString());
  86. Users puser = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
  87. dic["MakerCode"] = puser.MakerCode;
  88. dic["RealName"] = puser.RealName;
  89. //顶级创客
  90. int TopUserId = int.Parse(dic["TopUserId"].ToString());
  91. Users tuser = db.Users.FirstOrDefault(m => m.Id == TopUserId) ?? new Users();
  92. dic["TopMakerCode"] = tuser.MakerCode;
  93. dic["TopRealName"] = tuser.RealName;
  94. //商户创客
  95. int MerUserId = int.Parse(dic["MerUserId"].ToString());
  96. Users muser = db.Users.FirstOrDefault(m => m.Id == MerUserId) ?? new Users();
  97. dic["MerMakerCode"] = muser.MakerCode;
  98. dic["MerRealName"] = muser.RealName;
  99. //申请创客
  100. int SnApplyUserId = int.Parse(dic["SnApplyUserId"].ToString());
  101. Users snuser = db.Users.FirstOrDefault(m => m.Id == SnApplyUserId) ?? new Users();
  102. dic["SnApplyMakerCode"] = snuser.MakerCode;
  103. dic["SnApplyRealName"] = snuser.RealName;
  104. //SN仓库
  105. int SnStoreId = int.Parse(dic["SnStoreId"].ToString());
  106. StoreHouse store = db.StoreHouse.FirstOrDefault(m => m.Id == SnStoreId) ?? new StoreHouse();
  107. dic["StoreNo"] = store.StoreNo;
  108. dic["StoreName"] = store.StoreName;
  109. //机具类型
  110. int SnType = int.Parse(dic["SnType"].ToString());
  111. if (SnType == 0) dic["SnType"] = "兑换机具";
  112. if (SnType == 1) dic["SnType"] = "循环机具";
  113. //返利资格
  114. dic["RebateQual"] = dic["RebateQual"].ToString() == "1" ? "是" : "否";
  115. //激活类型
  116. int ActType = int.Parse(dic["ActType"].ToString());
  117. if (ActType == 0) dic["ActType"] = "正常激活";
  118. if (ActType == 1) dic["ActType"] = "首次已激活MPOS";
  119. if (ActType == 2) dic["ActType"] = "首次已激活KPOS";
  120. if (ActType == 3) dic["ActType"] = "循环机划拨激活";
  121. //商户状态
  122. int MerStatus = int.Parse(dic["MerStatus"].ToString());
  123. if (MerStatus == 0) dic["MerStatus"] = "正常";
  124. if (MerStatus == 1) dic["MerStatus"] = "冻结";
  125. if (MerStatus == 2) dic["MerStatus"] = "关闭";
  126. //商户激活状态
  127. int ActiveStatus = int.Parse(dic["ActiveStatus"].ToString());
  128. if (ActiveStatus == 0) dic["ActiveStatus"] = "未激活";
  129. if (ActiveStatus == 1) dic["ActiveStatus"] = "已激活";
  130. if (ActiveStatus == 2) dic["ActiveStatus"] = "SN已返现";
  131. //商户创客类型
  132. int MerUserType = int.Parse(dic["MerUserType"].ToString());
  133. if (MerUserType == 0) dic["MerUserType"] = "非商户型创客";
  134. if (MerUserType == 1) dic["MerUserType"] = "商户型创客";
  135. }
  136. return Json(obj);
  137. }
  138. #endregion
  139. #region 人工已退商户列表
  140. /// <summary>
  141. /// 根据条件人工已退商户列表
  142. /// </summary>
  143. /// <returns></returns>
  144. public IActionResult Indexrg(PosMerchantInfo data, string right, string BrandId)
  145. {
  146. ViewBag.RightInfo = RightInfo;
  147. ViewBag.right = right;
  148. ViewBag.BrandId = BrandId;
  149. return View();
  150. }
  151. #endregion
  152. #region 根据条件查询人工已退商户列表
  153. /// <summary>
  154. /// 人工已退商户列表
  155. /// </summary>
  156. /// <returns></returns>
  157. public JsonResult IndexrgData(PosMerchantInfo data, string KqMerNo, string MerIdcardNo, string MerchantName, string PhoneNo, string PosSn, int page = 1, int limit = 30)
  158. {
  159. Dictionary<string, string> Fields = new Dictionary<string, string>();
  160. // Fields.Add("KqMerNo", "1"); //商户编号
  161. string condition = " and Status>-1 and StandardStatus=-2";
  162. //身份证号
  163. if (!string.IsNullOrEmpty(MerIdcardNo))
  164. {
  165. var IdCardf = MerIdcardNo.Substring(0, 6);
  166. var IdCardb = MerIdcardNo.Substring(MerIdcardNo.Length - 4);
  167. condition += " and LEFT(MerIdcardNo,6)=" + IdCardf + " AND RIGHT(MerIdcardNo,4)=" + IdCardb + "";
  168. }
  169. //商户姓名
  170. if (!string.IsNullOrEmpty(MerchantName))
  171. {
  172. condition += " and MerchantName like '%" + MerchantName + "%'";
  173. }
  174. //商户编号
  175. if (!string.IsNullOrEmpty(KqMerNo))
  176. {
  177. condition += " and KqMerNo='" + KqMerNo + "'";
  178. }
  179. //机具号
  180. if (!string.IsNullOrEmpty(PosSn))
  181. {
  182. condition += " and KqSnNo='" + PosSn + "'";
  183. }
  184. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("PosMerchantInfo", Fields, "KqRegTime DESC", "0", page, limit, condition);
  185. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  186. foreach (Dictionary<string, object> dic in diclist)
  187. {
  188. //直属创客
  189. int UserId = int.Parse(dic["UserId"].ToString());
  190. Users puser = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
  191. dic["MakerCode"] = puser.MakerCode;
  192. dic["RealName"] = puser.RealName;
  193. //顶级创客
  194. int TopUserId = int.Parse(dic["TopUserId"].ToString());
  195. Users tuser = db.Users.FirstOrDefault(m => m.Id == TopUserId) ?? new Users();
  196. dic["TopMakerCode"] = tuser.MakerCode;
  197. dic["TopRealName"] = tuser.RealName;
  198. //商户创客
  199. int MerUserId = int.Parse(dic["MerUserId"].ToString());
  200. Users muser = db.Users.FirstOrDefault(m => m.Id == MerUserId) ?? new Users();
  201. dic["MerMakerCode"] = muser.MakerCode;
  202. dic["MerRealName"] = muser.RealName;
  203. //申请创客
  204. int SnApplyUserId = int.Parse(dic["SnApplyUserId"].ToString());
  205. Users snuser = db.Users.FirstOrDefault(m => m.Id == SnApplyUserId) ?? new Users();
  206. dic["SnApplyMakerCode"] = snuser.MakerCode;
  207. dic["SnApplyRealName"] = snuser.RealName;
  208. //SN仓库
  209. int SnStoreId = int.Parse(dic["SnStoreId"].ToString());
  210. StoreHouse store = db.StoreHouse.FirstOrDefault(m => m.Id == SnStoreId) ?? new StoreHouse();
  211. dic["StoreNo"] = store.StoreNo;
  212. dic["StoreName"] = store.StoreName;
  213. //机具类型
  214. int SnType = int.Parse(dic["SnType"].ToString());
  215. if (SnType == 0) dic["SnType"] = "兑换机具";
  216. if (SnType == 1) dic["SnType"] = "循环机具";
  217. //返利资格
  218. dic["RebateQual"] = dic["RebateQual"].ToString() == "1" ? "是" : "否";
  219. //激活类型
  220. int ActType = int.Parse(dic["ActType"].ToString());
  221. if (ActType == 0) dic["ActType"] = "正常激活";
  222. if (ActType == 1) dic["ActType"] = "首次已激活MPOS";
  223. if (ActType == 2) dic["ActType"] = "首次已激活KPOS";
  224. if (ActType == 3) dic["ActType"] = "循环机划拨激活";
  225. //商户状态
  226. int MerStatus = int.Parse(dic["MerStatus"].ToString());
  227. if (MerStatus == 0) dic["MerStatus"] = "正常";
  228. if (MerStatus == 1) dic["MerStatus"] = "冻结";
  229. if (MerStatus == 2) dic["MerStatus"] = "关闭";
  230. //商户激活状态
  231. int ActiveStatus = int.Parse(dic["ActiveStatus"].ToString());
  232. if (ActiveStatus == 0) dic["ActiveStatus"] = "未激活";
  233. if (ActiveStatus == 1) dic["ActiveStatus"] = "已激活";
  234. if (ActiveStatus == 2) dic["ActiveStatus"] = "SN已返现";
  235. //商户创客类型
  236. int MerUserType = int.Parse(dic["MerUserType"].ToString());
  237. if (MerUserType == 0) dic["MerUserType"] = "非商户型创客";
  238. if (MerUserType == 1) dic["MerUserType"] = "商户型创客";
  239. var KqSnNo = dic["KqSnNo"].ToString();
  240. var pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == KqSnNo) ?? new PosMachinesTwo();
  241. //实际押金
  242. string SeoKeyword = "0";
  243. if (!string.IsNullOrEmpty(pos.SeoKeyword))
  244. {
  245. if (pos.BrandId != 2 && pos.BrandId != 7 && pos.BrandId != 10 && pos.BrandId != 11)
  246. {
  247. SeoKeyword = (decimal.Parse(pos.SeoKeyword) / 100).ToString();
  248. }
  249. else
  250. {
  251. SeoKeyword = pos.SeoKeyword;
  252. }
  253. }
  254. dic["SeoKeyword"] = SeoKeyword;
  255. //设置押金
  256. string PrizeParams = "0";
  257. if (!string.IsNullOrEmpty(pos.PrizeParams))
  258. {
  259. PrizeParams = pos.PrizeParams.ToString();
  260. }
  261. dic["PrizeParams"] = PrizeParams;
  262. }
  263. Dictionary<string, object> other = new Dictionary<string, object>();
  264. decimal ReturnAmount = 0.00M;//服务费总金额
  265. decimal ReturnAmounts = 0.00M;//退还总金额
  266. DataTable dt = OtherMySqlConn.dtable("SELECT SUM(Remark) FROM PosMerchantInfo WHERE 1=1" + condition);
  267. if (dt.Rows.Count > 0)
  268. {
  269. ReturnAmounts = decimal.Parse(function.CheckNum(dt.Rows[0][0].ToString()));
  270. }
  271. DataTable dts = OtherMySqlConn.dtable("SELECT KqSnNo FROM PosMerchantInfo WHERE 1=1" + condition);
  272. if (dt.Rows.Count > 0)
  273. {
  274. foreach (DataRow item in dts.Rows)
  275. {
  276. string KqSnNo = item["KqSnNo"].ToString();
  277. var pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == KqSnNo) ?? new PosMachinesTwo();
  278. if (!string.IsNullOrEmpty(pos.SeoKeyword))
  279. {
  280. if (pos.BrandId != 2 && pos.BrandId != 7 && pos.BrandId != 10 && pos.BrandId != 11)
  281. {
  282. ReturnAmount += decimal.Parse(pos.SeoKeyword) / 100;
  283. }
  284. else
  285. {
  286. ReturnAmount += decimal.Parse(pos.SeoKeyword);
  287. }
  288. }
  289. }
  290. }
  291. other.Add("ReturnAmount", ReturnAmount.ToString("f2"));
  292. other.Add("ReturnAmounts", ReturnAmounts.ToString("f2"));
  293. obj.Add("other", other);
  294. return Json(obj);
  295. }
  296. #endregion
  297. #region 导出人工已退商户Excel
  298. /// <summary>
  299. /// 导出人工已退商户Excel
  300. /// </summary>
  301. /// <returns></returns>
  302. public JsonResult ExportrgExcel(PosMerchantInfo data, string MerIdcardNo, string MerchantName, string PhoneNo, string PosSn)
  303. {
  304. Dictionary<string, string> Fields = new Dictionary<string, string>();
  305. Fields.Add("KqMerNo", "1"); //商户编号
  306. string condition = " and Status>-1 and StandardStatus=-2";
  307. //身份证号
  308. if (!string.IsNullOrEmpty(MerIdcardNo))
  309. {
  310. var IdCardf = MerIdcardNo.Substring(0, 6);
  311. var IdCardb = MerIdcardNo.Substring(MerIdcardNo.Length - 4);
  312. condition += " and LEFT(MerIdcardNo,6)=" + IdCardf + " AND RIGHT(MerIdcardNo,4)=" + IdCardb + "";
  313. }
  314. //商户姓名
  315. if (!string.IsNullOrEmpty(MerchantName))
  316. {
  317. condition += " and MerchantName like '%" + MerchantName + "%'";
  318. }
  319. //手机号
  320. if (!string.IsNullOrEmpty(PhoneNo))
  321. {
  322. var PhoneNof = PhoneNo.Substring(0, 3);
  323. var PhoneNob = PhoneNo.Substring(PhoneNo.Length - 4);
  324. condition += " and LEFT(MerchantMobile,3)=" + PhoneNof + " AND RIGHT(MerchantMobile,4)=" + PhoneNob + "";
  325. }
  326. //机具号
  327. if (!string.IsNullOrEmpty(PosSn))
  328. {
  329. condition += " and KqSnNo='" + PosSn + "'";
  330. }
  331. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("PosMerchantInfo", Fields, "Id desc", "0", 1, 20000, condition, "MerchantName,Remark,KqMerNo,KqSnNo,UserId,KqRegTime", false);
  332. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  333. foreach (Dictionary<string, object> dic in diclist)
  334. {
  335. var KqSnNo = dic["KqSnNo"].ToString();
  336. var pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == KqSnNo) ?? new PosMachinesTwo();
  337. var brand = db.KqProducts.FirstOrDefault(m => m.Id == pos.BrandId) ?? new KqProducts();
  338. dic["BrandName"] = brand.Name;
  339. int UserId = int.Parse(dic["UserId"].ToString());
  340. Users puser = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
  341. dic["MakerCode"] = puser.MakerCode;
  342. dic["RealName"] = puser.RealName;
  343. dic.Remove("UserId");
  344. //实际押金
  345. string SeoKeyword = "0";
  346. if (!string.IsNullOrEmpty(pos.SeoKeyword))
  347. {
  348. if (pos.BrandId != 2 && pos.BrandId != 7 && pos.BrandId != 10 && pos.BrandId != 11)
  349. {
  350. SeoKeyword = (decimal.Parse(pos.SeoKeyword) / 100).ToString();
  351. }
  352. else
  353. {
  354. SeoKeyword = pos.SeoKeyword;
  355. }
  356. }
  357. dic["SeoKeyword"] = SeoKeyword;
  358. }
  359. Dictionary<string, object> result = new Dictionary<string, object>();
  360. result.Add("Status", "1");
  361. result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
  362. result.Add("Obj", diclist);
  363. Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
  364. ReturnFields.Add("KqMerNo", "商户编号");
  365. ReturnFields.Add("MerchantName", "商户名称");
  366. ReturnFields.Add("BrandName", "机具品牌");
  367. ReturnFields.Add("KqSnNo", "机具SN");
  368. ReturnFields.Add("KqRegTime", "退还时间");
  369. ReturnFields.Add("SeoKeyword", "服务费金额");
  370. ReturnFields.Add("Remark", "已退还金额");
  371. ReturnFields.Add("MakerCode", "创客编号");
  372. ReturnFields.Add("RealName", "创客姓名");
  373. result.Add("Fields", ReturnFields);
  374. AddSysLog("0", "PosMerchantInfo", "ExportrgExcel");
  375. return Json(result);
  376. }
  377. #endregion
  378. #region 达标商户列表
  379. /// <summary>
  380. /// 达标商户列表
  381. /// </summary>
  382. /// <returns></returns>
  383. public IActionResult Indexs(PosMerchantInfo data, string right, string BrandId)
  384. {
  385. ViewBag.RightInfo = RightInfo;
  386. ViewBag.right = right;
  387. ViewBag.BrandId = BrandId;
  388. return View();
  389. }
  390. #endregion
  391. #region 根据条件查询达标商户列表
  392. /// <summary>
  393. /// 根据条件查询达标商户列表
  394. /// </summary>
  395. /// <returns></returns>
  396. public JsonResult IndexsData(PosMerchantInfo data, int page = 1, int limit = 30)
  397. {
  398. Dictionary<string, string> Fields = new Dictionary<string, string>();
  399. Fields.Add("MerchantMobile", "1"); //商户手机号
  400. Fields.Add("KqSnNo", "1"); //快钱SN号
  401. Fields.Add("MerIdcardNo", "1"); //身份证号
  402. string condition = " and Status>-1 and StandardStatus=4 and StandardMonths=10";
  403. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("PosMerchantInfo", Fields, "Id desc", "0", page, limit, condition);
  404. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  405. foreach (Dictionary<string, object> dic in diclist)
  406. {
  407. //直属创客
  408. int UserId = int.Parse(dic["UserId"].ToString());
  409. Users puser = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
  410. dic["MakerCode"] = puser.MakerCode;
  411. dic["RealName"] = puser.RealName;
  412. //顶级创客
  413. int TopUserId = int.Parse(dic["TopUserId"].ToString());
  414. Users tuser = db.Users.FirstOrDefault(m => m.Id == TopUserId) ?? new Users();
  415. dic["TopMakerCode"] = tuser.MakerCode;
  416. dic["TopRealName"] = tuser.RealName;
  417. //商户创客
  418. int MerUserId = int.Parse(dic["MerUserId"].ToString());
  419. Users muser = db.Users.FirstOrDefault(m => m.Id == MerUserId) ?? new Users();
  420. dic["MerMakerCode"] = muser.MakerCode;
  421. dic["MerRealName"] = muser.RealName;
  422. //申请创客
  423. int SnApplyUserId = int.Parse(dic["SnApplyUserId"].ToString());
  424. Users snuser = db.Users.FirstOrDefault(m => m.Id == SnApplyUserId) ?? new Users();
  425. dic["SnApplyMakerCode"] = snuser.MakerCode;
  426. dic["SnApplyRealName"] = snuser.RealName;
  427. //SN仓库
  428. int SnStoreId = int.Parse(dic["SnStoreId"].ToString());
  429. StoreHouse store = db.StoreHouse.FirstOrDefault(m => m.Id == SnStoreId) ?? new StoreHouse();
  430. dic["StoreNo"] = store.StoreNo;
  431. dic["StoreName"] = store.StoreName;
  432. //机具类型
  433. int SnType = int.Parse(dic["SnType"].ToString());
  434. if (SnType == 0) dic["SnType"] = "兑换机具";
  435. if (SnType == 1) dic["SnType"] = "循环机具";
  436. //返利资格
  437. dic["RebateQual"] = dic["RebateQual"].ToString() == "1" ? "是" : "否";
  438. //激活类型
  439. int ActType = int.Parse(dic["ActType"].ToString());
  440. if (ActType == 0) dic["ActType"] = "正常激活";
  441. if (ActType == 1) dic["ActType"] = "首次已激活MPOS";
  442. if (ActType == 2) dic["ActType"] = "首次已激活KPOS";
  443. if (ActType == 3) dic["ActType"] = "循环机划拨激活";
  444. //商户状态
  445. int MerStatus = int.Parse(dic["MerStatus"].ToString());
  446. if (MerStatus == 0) dic["MerStatus"] = "正常";
  447. if (MerStatus == 1) dic["MerStatus"] = "冻结";
  448. if (MerStatus == 2) dic["MerStatus"] = "关闭";
  449. //商户激活状态
  450. int ActiveStatus = int.Parse(dic["ActiveStatus"].ToString());
  451. if (ActiveStatus == 0) dic["ActiveStatus"] = "未激活";
  452. if (ActiveStatus == 1) dic["ActiveStatus"] = "已激活";
  453. if (ActiveStatus == 2) dic["ActiveStatus"] = "SN已返现";
  454. //商户创客类型
  455. int MerUserType = int.Parse(dic["MerUserType"].ToString());
  456. if (MerUserType == 0) dic["MerUserType"] = "非商户型创客";
  457. if (MerUserType == 1) dic["MerUserType"] = "商户型创客";
  458. }
  459. return Json(obj);
  460. }
  461. #endregion
  462. #region 首台达标商户列表
  463. /// <summary>
  464. /// 首台达标商户列表
  465. /// </summary>
  466. /// <returns></returns>
  467. public IActionResult Indexfs(string right)
  468. {
  469. ViewBag.RightInfo = RightInfo;
  470. ViewBag.right = right;
  471. return View();
  472. }
  473. #endregion
  474. #region 根据条件查询首台达标商户列表
  475. /// <summary>
  476. /// 根据条件查询首台达标商户列表
  477. /// </summary>
  478. /// <returns></returns>
  479. public IActionResult IndexfsData(string MerchantMobile, string KqSnNo, string MerIdcardNo, int page = 1, int limit = 30)
  480. {
  481. string condition = "";
  482. if (!string.IsNullOrEmpty(MerchantMobile))
  483. {
  484. condition += " and b.MerchantMobile like '%" + MerchantMobile + "%'";
  485. }
  486. if (!string.IsNullOrEmpty(KqSnNo))
  487. {
  488. condition += " and b.KqSnNo like '%" + KqSnNo + "%'";
  489. }
  490. if (!string.IsNullOrEmpty(MerIdcardNo))
  491. {
  492. condition += " and b.MerIdcardNo like '%" + MerIdcardNo + "%'";
  493. }
  494. var amount = 0.00M;
  495. List<Dictionary<string, object>> diclist = new List<Dictionary<string, object>>();
  496. DataTable dt = OtherMySqlConn.dtable("SELECT a.BrandId,a.PosSn,a.BindMerchantId,a.SeoKeyword,b.KqMerNo,b.MerIdcardNo,b.MerchantName,b.MerchantMobile FROM PosMachinesTwo a,PosMerchantInfo b WHERE a.`Status`>-1 AND a.SeoKeyword!='' AND a.SeoKeyword!='0' AND a.SeoKeyword IS NOT NULL AND a.IsFirst=1 AND b.StandardMonths=10 AND b.StandardStatus=4 AND a.BindMerchantId=b.Id " + condition);
  497. if (dt.Rows.Count > 0)
  498. {
  499. foreach (DataRow item in dt.Rows)
  500. {
  501. var BindMerchantId = item["BindMerchantId"].ToString();
  502. var BrandId = item["BrandId"].ToString();
  503. var PosSn = item["PosSn"].ToString();
  504. var SeoKeyword = item["SeoKeyword"].ToString();
  505. if (BrandId != "2" && BrandId != "7")
  506. {
  507. SeoKeyword = (decimal.Parse(SeoKeyword) / 100).ToString();
  508. }
  509. amount += decimal.Parse(SeoKeyword);
  510. var KqMerNo = item["KqMerNo"].ToString();
  511. var IdcardNo = item["MerIdcardNo"].ToString();
  512. var MerchantName = item["MerchantName"].ToString();
  513. var Mobile = item["MerchantMobile"].ToString();
  514. Dictionary<string, object> datas = new Dictionary<string, object>();
  515. datas.Add("Id", BindMerchantId);
  516. datas.Add("PosSn", PosSn);
  517. datas.Add("SeoKeyword", SeoKeyword);
  518. datas.Add("KqMerNo", KqMerNo);
  519. datas.Add("IdcardNo", IdcardNo);
  520. datas.Add("MerchantName", MerchantName);
  521. datas.Add("MerchantMobile", Mobile);
  522. diclist.Add(datas);
  523. }
  524. }
  525. Dictionary<string, object> obj = new Dictionary<string, object>();
  526. Dictionary<string, object> other = new Dictionary<string, object>();
  527. var ReturnAmount = amount;
  528. var fReturnAmount = amount * 0.92M;
  529. other.Add("ReturnAmount", ReturnAmount.ToString("f2"));
  530. other.Add("fReturnAmount", fReturnAmount.ToString("f2"));
  531. obj.Add("other", other);
  532. obj.Add("code", 0);
  533. obj.Add("msg", "");
  534. obj.Add("count", diclist.Count);
  535. obj.Add("data", diclist);
  536. return Json(obj);
  537. }
  538. #endregion
  539. #region 非首台达标商户列表
  540. /// <summary>
  541. /// 非首台达标商户列表
  542. /// </summary>
  543. /// <returns></returns>
  544. public IActionResult Indexnfs(string right)
  545. {
  546. ViewBag.RightInfo = RightInfo;
  547. ViewBag.right = right;
  548. return View();
  549. }
  550. #endregion
  551. #region 根据条件查询非首台达标商户列表
  552. /// <summary>
  553. /// 根据条件查询非首台达标商户列表
  554. /// </summary>
  555. /// <returns></returns>
  556. public IActionResult IndexnfsData(string MerchantMobile, string KqSnNo, string MerIdcardNo, int page = 1, int limit = 30)
  557. {
  558. string condition = "";
  559. if (!string.IsNullOrEmpty(MerchantMobile))
  560. {
  561. condition += " and b.MerchantMobile like '%" + MerchantMobile + "%'";
  562. }
  563. if (!string.IsNullOrEmpty(KqSnNo))
  564. {
  565. condition += " and b.KqSnNo like '%" + KqSnNo + "%'";
  566. }
  567. if (!string.IsNullOrEmpty(MerIdcardNo))
  568. {
  569. condition += " and b.MerIdcardNo like '%" + MerIdcardNo + "%'";
  570. }
  571. var amount = 0.00M;
  572. List<Dictionary<string, object>> diclist = new List<Dictionary<string, object>>();
  573. DataTable dt = OtherMySqlConn.dtable("SELECT a.BrandId,a.PosSn,a.BindMerchantId,a.SeoKeyword,b.KqMerNo,b.MerIdcardNo,b.MerchantName,b.MerchantMobile FROM PosMachinesTwo a,PosMerchantInfo b WHERE a.`Status`>-1 AND a.SeoKeyword!='' AND a.SeoKeyword!='0' AND a.SeoKeyword IS NOT NULL AND a.IsFirst=0 AND b.StandardMonths=10 AND b.StandardStatus=4 AND a.BindMerchantId=b.Id " + condition);
  574. if (dt.Rows.Count > 0)
  575. {
  576. foreach (DataRow item in dt.Rows)
  577. {
  578. var BindMerchantId = item["BindMerchantId"].ToString();
  579. var BrandId = item["BrandId"].ToString();
  580. var PosSn = item["PosSn"].ToString();
  581. var SeoKeyword = item["SeoKeyword"].ToString();
  582. if (BrandId != "2" && BrandId != "7")
  583. {
  584. SeoKeyword = (decimal.Parse(SeoKeyword) / 100).ToString();
  585. }
  586. amount += decimal.Parse(SeoKeyword);
  587. var KqMerNo = item["KqMerNo"].ToString();
  588. var IdcardNo = item["MerIdcardNo"].ToString();
  589. var MerchantName = item["MerchantName"].ToString();
  590. var Mobile = item["MerchantMobile"].ToString();
  591. Dictionary<string, object> datas = new Dictionary<string, object>();
  592. datas.Add("Id", BindMerchantId);
  593. datas.Add("PosSn", PosSn);
  594. datas.Add("SeoKeyword", SeoKeyword);
  595. datas.Add("KqMerNo", KqMerNo);
  596. datas.Add("IdcardNo", IdcardNo);
  597. datas.Add("MerchantName", MerchantName);
  598. datas.Add("MerchantMobile", Mobile);
  599. diclist.Add(datas);
  600. }
  601. }
  602. Dictionary<string, object> obj = new Dictionary<string, object>();
  603. Dictionary<string, object> other = new Dictionary<string, object>();
  604. var ReturnAmount = amount;
  605. var fReturnAmount = amount * 0.92M;
  606. other.Add("ReturnAmount", ReturnAmount.ToString("f2"));
  607. other.Add("fReturnAmount", fReturnAmount.ToString("f2"));
  608. obj.Add("other", other);
  609. obj.Add("code", 0);
  610. obj.Add("msg", "");
  611. obj.Add("count", diclist.Count);
  612. obj.Add("data", diclist);
  613. return Json(obj);
  614. }
  615. #endregion
  616. #region 批量通过
  617. /// <summary>
  618. /// 批量通过
  619. /// </summary>
  620. /// <returns></returns>
  621. public string BatchSetting(string Id)
  622. {
  623. string[] idlist = Id.Split(new char[] { ',' });
  624. AddSysLog(Id, "PosMerchantInfo", "BatchSetting");
  625. var Ids = "";//商户Id
  626. foreach (string subid in idlist)
  627. {
  628. int id = int.Parse(subid);
  629. Ids += id + ",";
  630. Dictionary<string, object> Fields = new Dictionary<string, object>();
  631. Fields.Add("StandardStatus", 101);//设置为可退押状态
  632. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("PosMerchantInfo", Fields, id);
  633. }
  634. string text = string.Format("商户押金退还批量通过,商户Id: '" + Ids.TrimEnd(',') + "',操作人: '" + SysUserName + "_" + SysRealName + "',Time'" + DateTime.Now + "'");
  635. function.WriteLog(text, "商户押金退还批量通过");
  636. db.SaveChanges();
  637. return "success";
  638. }
  639. #endregion
  640. #region 增加商户
  641. /// <summary>
  642. /// 增加或修改商户信息
  643. /// </summary>
  644. /// <returns></returns>
  645. public IActionResult Add(string right)
  646. {
  647. ViewBag.RightInfo = RightInfo;
  648. ViewBag.right = right;
  649. return View();
  650. }
  651. #endregion
  652. #region 增加商户
  653. /// <summary>
  654. /// 增加或修改商户信息
  655. /// </summary>
  656. /// <returns></returns>
  657. [HttpPost]
  658. public string Add(PosMerchantInfo data)
  659. {
  660. Dictionary<string, object> Fields = new Dictionary<string, object>();
  661. Fields.Add("SeoTitle", data.SeoTitle);
  662. Fields.Add("SeoKeyword", data.SeoKeyword);
  663. Fields.Add("SeoDescription", data.SeoDescription);
  664. int Id = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Add("PosMerchantInfo", Fields, 0);
  665. AddSysLog(data.Id.ToString(), "PosMerchantInfo", "add");
  666. db.SaveChanges();
  667. return "success";
  668. }
  669. #endregion
  670. #region 修改商户
  671. /// <summary>
  672. /// 增加或修改商户信息
  673. /// </summary>
  674. /// <returns></returns>
  675. public IActionResult Edit(string right, int Id = 0)
  676. {
  677. ViewBag.RightInfo = RightInfo;
  678. ViewBag.right = right;
  679. PosMerchantInfo editData = db.PosMerchantInfo.FirstOrDefault(m => m.Id == Id) ?? new PosMerchantInfo();
  680. ViewBag.data = editData;
  681. return View();
  682. }
  683. #endregion
  684. #region 修改商户
  685. /// <summary>
  686. /// 增加或修改商户信息
  687. /// </summary>
  688. /// <returns></returns>
  689. [HttpPost]
  690. public string Edit(PosMerchantInfo data)
  691. {
  692. Dictionary<string, object> Fields = new Dictionary<string, object>();
  693. Fields.Add("SeoTitle", data.SeoTitle);
  694. Fields.Add("SeoKeyword", data.SeoKeyword);
  695. Fields.Add("SeoDescription", data.SeoDescription);
  696. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("PosMerchantInfo", Fields, data.Id);
  697. AddSysLog(data.Id.ToString(), "PosMerchantInfo", "update");
  698. db.SaveChanges();
  699. return "success";
  700. }
  701. #endregion
  702. #region 删除商户信息
  703. /// <summary>
  704. /// 删除商户信息
  705. /// </summary>
  706. /// <returns></returns>
  707. public string Delete(string Id)
  708. {
  709. string[] idlist = Id.Split(new char[] { ',' });
  710. AddSysLog(Id, "PosMerchantInfo", "del");
  711. foreach (string subid in idlist)
  712. {
  713. int id = int.Parse(subid);
  714. Dictionary<string, object> Fields = new Dictionary<string, object>();
  715. Fields.Add("Status", -1);
  716. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("PosMerchantInfo", Fields, id);
  717. }
  718. db.SaveChanges();
  719. return "success";
  720. }
  721. #endregion
  722. #region 开启
  723. /// <summary>
  724. /// 开启
  725. /// </summary>
  726. /// <returns></returns>
  727. public string Open(string Id)
  728. {
  729. string[] idlist = Id.Split(new char[] { ',' });
  730. AddSysLog(Id, "PosMerchantInfo", "open");
  731. foreach (string subid in idlist)
  732. {
  733. int id = int.Parse(subid);
  734. Dictionary<string, object> Fields = new Dictionary<string, object>();
  735. Fields.Add("Status", 1);
  736. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("PosMerchantInfo", Fields, id);
  737. }
  738. db.SaveChanges();
  739. return "success";
  740. }
  741. #endregion
  742. #region 关闭
  743. /// <summary>
  744. /// 关闭
  745. /// </summary>
  746. /// <returns></returns>
  747. public string Close(string Id)
  748. {
  749. string[] idlist = Id.Split(new char[] { ',' });
  750. AddSysLog(Id, "PosMerchantInfo", "close");
  751. foreach (string subid in idlist)
  752. {
  753. int id = int.Parse(subid);
  754. Dictionary<string, object> Fields = new Dictionary<string, object>();
  755. Fields.Add("Status", 0);
  756. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Edit("PosMerchantInfo", Fields, id);
  757. }
  758. db.SaveChanges();
  759. return "success";
  760. }
  761. #endregion
  762. #region 排序
  763. /// <summary>
  764. /// 排序
  765. /// </summary>
  766. /// <param name="Id"></param>
  767. public string Sort(int Id, int Sort)
  768. {
  769. new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).Sort("PosMerchantInfo", Sort, Id);
  770. AddSysLog(Id.ToString(), "PosMerchantInfo", "sort");
  771. return "success";
  772. }
  773. #endregion
  774. #region 导入数据
  775. /// <summary>
  776. /// 导入数据
  777. /// </summary>
  778. /// <param name="ExcelData"></param>
  779. public string Import(string ExcelData)
  780. {
  781. ExcelData = HttpUtility.UrlDecode(ExcelData);
  782. JsonData list = JsonMapper.ToObject(ExcelData);
  783. var Ids = "";
  784. for (int i = 1; i < list.Count; i++)
  785. {
  786. JsonData dr = list[i];
  787. string KqMerNo = dr[0].ToString(); // 商户编号
  788. string Amount = dr[1].ToString(); // 已退金额
  789. string KqRegTime = dr[2].ToString(); // 退还时间
  790. var posMerchantInfo = db.PosMerchantInfo.FirstOrDefault(m => m.KqMerNo == KqMerNo) ?? new PosMerchantInfo();
  791. posMerchantInfo.StandardStatus = -2;
  792. posMerchantInfo.Remark = Amount;
  793. posMerchantInfo.KqRegTime = DateTime.Parse(KqRegTime);
  794. Ids += posMerchantInfo.Id + "_" + Amount + ",";
  795. db.SaveChanges();
  796. }
  797. AddSysLog("0", "PosMerchantInfo", "Import");
  798. string text = string.Format("导入人工已退,商户Id: '" + Ids.TrimEnd(',') + "',操作人: '" + SysUserName + "_" + SysRealName + "',Time'" + DateTime.Now + "'");
  799. function.WriteLog(text, "导入人工已退");
  800. return "success";
  801. }
  802. #endregion
  803. #region 导出Excel
  804. /// <summary>
  805. /// 导出Excel
  806. /// </summary>
  807. /// <returns></returns>
  808. public JsonResult ExportExcel(PosMerchantInfo data, string MakerCode, string RealName, string MerMakerCode, string StoreNo, string StoreName, string MerStatusSelect, string ActiveStatusSelect, string ActTypeSelect, string MerUserTypeSelect)
  809. {
  810. Dictionary<string, string> Fields = new Dictionary<string, string>();
  811. Fields.Add("BrandId", "1");
  812. Fields.Add("MerchantNo", "1"); //商户编号
  813. Fields.Add("MerchantName", "1"); //商户姓名
  814. Fields.Add("MerchantMobile", "1"); //商户手机号
  815. Fields.Add("KqMerNo", "1"); //快钱商户编码
  816. Fields.Add("KqSnNo", "1"); //快钱SN号
  817. Fields.Add("KqRegTime", "3"); //渠道注册时间
  818. Fields.Add("TopUserId", "0"); //顶级创客
  819. string condition = " and Status>-1";
  820. //创客编号
  821. if (!string.IsNullOrEmpty(MakerCode))
  822. {
  823. condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + MakerCode + "')";
  824. }
  825. //创客名称
  826. if (!string.IsNullOrEmpty(RealName))
  827. {
  828. condition += " and UserId in (select UserId from UserForRealName where RealName='" + RealName + "')";
  829. }
  830. //商户创客编号
  831. if (!string.IsNullOrEmpty(MerMakerCode))
  832. {
  833. condition += " and MerUserId in (select UserId from UserForMakerCode where MakerCode='" + MerMakerCode + "')";
  834. }
  835. //仓库编号
  836. if (!string.IsNullOrEmpty(StoreNo))
  837. {
  838. condition += " and StoreId in (select StoreId from StoreForCode where Code='" + StoreNo + "')";
  839. }
  840. //仓库名称
  841. if (!string.IsNullOrEmpty(RealName))
  842. {
  843. condition += " and StoreId in (select StoreId from StoreForName where Name='" + StoreName + "')";
  844. }
  845. //商户状态
  846. if (!string.IsNullOrEmpty(MerStatusSelect))
  847. {
  848. condition += " and MerStatus=" + MerStatusSelect;
  849. }
  850. //商户激活状态
  851. if (!string.IsNullOrEmpty(ActiveStatusSelect))
  852. {
  853. condition += " and ActiveStatus=" + ActiveStatusSelect;
  854. }
  855. //激活类型
  856. if (!string.IsNullOrEmpty(ActTypeSelect))
  857. {
  858. condition += " and ActType=" + ActTypeSelect;
  859. }
  860. //商户创客类型
  861. if (!string.IsNullOrEmpty(MerUserTypeSelect))
  862. {
  863. condition += " and MerUserType=" + MerUserTypeSelect;
  864. }
  865. Dictionary<string, object> obj = new AdminContentOther(_accessor.HttpContext, PublicFunction.MainTables).IndexData("PosMerchantInfo", Fields, "Id desc", "0", 1, 20000, condition, "MerchantNo,MerchantName,MerchantMobile,KqMerNo,KqSnNo,MerStatus,ActiveStatus,UserId,MerUserId,SnType,SnApplyUserId,KqRegTime,ActType,SnStoreId,TopUserId,MerUserType,RebateQual", false);
  866. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  867. foreach (Dictionary<string, object> dic in diclist)
  868. {
  869. //直属创客
  870. int UserId = int.Parse(dic["UserId"].ToString());
  871. Users puser = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
  872. dic["MakerCode"] = puser.MakerCode;
  873. dic["RealName"] = puser.RealName;
  874. //顶级创客
  875. int TopUserId = int.Parse(dic["TopUserId"].ToString());
  876. Users tuser = db.Users.FirstOrDefault(m => m.Id == TopUserId) ?? new Users();
  877. dic["TopMakerCode"] = tuser.MakerCode;
  878. dic["TopRealName"] = tuser.RealName;
  879. //商户创客
  880. int MerUserId = int.Parse(dic["MerUserId"].ToString());
  881. Users muser = db.Users.FirstOrDefault(m => m.Id == MerUserId) ?? new Users();
  882. dic["MerMakerCode"] = muser.MakerCode;
  883. dic["MerRealName"] = muser.RealName;
  884. //申请创客
  885. int SnApplyUserId = int.Parse(dic["SnApplyUserId"].ToString());
  886. Users snuser = db.Users.FirstOrDefault(m => m.Id == SnApplyUserId) ?? new Users();
  887. dic["SnApplyMakerCode"] = snuser.MakerCode;
  888. dic["SnApplyRealName"] = snuser.RealName;
  889. //SN仓库
  890. int SnStoreId = int.Parse(dic["SnStoreId"].ToString());
  891. StoreHouse store = db.StoreHouse.FirstOrDefault(m => m.Id == SnStoreId) ?? new StoreHouse();
  892. dic["StoreNo"] = store.StoreNo;
  893. dic["StoreName"] = store.StoreName;
  894. //机具类型
  895. int SnType = int.Parse(dic["SnType"].ToString());
  896. if (SnType == 0) dic["SnType"] = "兑换机具";
  897. if (SnType == 1) dic["SnType"] = "循环机具";
  898. //返利资格
  899. dic["RebateQual"] = dic["RebateQual"].ToString() == "1" ? "是" : "否";
  900. //激活类型
  901. int ActType = int.Parse(dic["ActType"].ToString());
  902. if (ActType == 0) dic["ActType"] = "正常激活";
  903. if (ActType == 1) dic["ActType"] = "首次已激活MPOS";
  904. if (ActType == 2) dic["ActType"] = "首次已激活KPOS";
  905. if (ActType == 3) dic["ActType"] = "循环机划拨激活";
  906. //商户状态
  907. int MerStatus = int.Parse(dic["MerStatus"].ToString());
  908. if (MerStatus == 0) dic["MerStatus"] = "正常";
  909. if (MerStatus == 1) dic["MerStatus"] = "冻结";
  910. if (MerStatus == 2) dic["MerStatus"] = "关闭";
  911. //商户激活状态
  912. int ActiveStatus = int.Parse(dic["ActiveStatus"].ToString());
  913. if (ActiveStatus == 0) dic["ActiveStatus"] = "未激活";
  914. if (ActiveStatus == 1) dic["ActiveStatus"] = "已激活";
  915. if (ActiveStatus == 2) dic["ActiveStatus"] = "SN已返现";
  916. //商户创客类型
  917. int MerUserType = int.Parse(dic["MerUserType"].ToString());
  918. if (MerUserType == 0) dic["MerUserType"] = "非商户型创客";
  919. if (MerUserType == 1) dic["MerUserType"] = "商户型创客";
  920. dic.Remove("UserId");
  921. dic.Remove("TopUserId");
  922. dic.Remove("MerUserId");
  923. dic.Remove("SnApplyUserId");
  924. dic.Remove("SnStoreId");
  925. }
  926. Dictionary<string, object> result = new Dictionary<string, object>();
  927. result.Add("Status", "1");
  928. result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
  929. result.Add("Obj", diclist);
  930. Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
  931. ReturnFields.Add("MerchantNo", "商户编号");
  932. ReturnFields.Add("MerchantName", "商户名称");
  933. ReturnFields.Add("MerchantMobile", "商户手机号");
  934. ReturnFields.Add("KqMerNo", "快钱商户编码");
  935. ReturnFields.Add("KqSnNo", "快钱SN号");
  936. ReturnFields.Add("SnType", "机具类型");
  937. ReturnFields.Add("RebateQual", "返利资格");
  938. ReturnFields.Add("ActType", "激活类型");
  939. ReturnFields.Add("MerStatus", "商户状态");
  940. ReturnFields.Add("ActiveStatus", "商户激活状态");
  941. ReturnFields.Add("MerMakerCode", "商户创客编码");
  942. ReturnFields.Add("MerRealName", "商户创客名称");
  943. ReturnFields.Add("MerUserType", "商户创客类型");
  944. ReturnFields.Add("MakerCode", "直属创客编号");
  945. ReturnFields.Add("RealName", "直属创客姓名");
  946. ReturnFields.Add("TopMakerCode", "顶级创客编码");
  947. ReturnFields.Add("TopRealName", "顶级创客名称");
  948. ReturnFields.Add("StoreNo", "SN仓库编号");
  949. ReturnFields.Add("StoreName", "SN仓库名称");
  950. ReturnFields.Add("SnApplyMakerCode", "申请创客编号");
  951. ReturnFields.Add("SnApplyRealName", "申请创客姓名");
  952. ReturnFields.Add("KqRegTime", "注册时间");
  953. result.Add("Fields", ReturnFields);
  954. AddSysLog("0", "PosMerchantInfo", "ExportExcel");
  955. return Json(result);
  956. }
  957. #endregion
  958. #region 同步交易额
  959. public IActionResult SycnTradeAmount(string right, int Id = 0)
  960. {
  961. ViewBag.RightInfo = RightInfo;
  962. ViewBag.right = right;
  963. PosMerchantInfo editData = db.PosMerchantInfo.FirstOrDefault(m => m.Id == Id) ?? new PosMerchantInfo();
  964. ViewBag.data = editData;
  965. return View();
  966. }
  967. #endregion
  968. #region 同步交易额
  969. [HttpPost]
  970. public string SycnTradeAmountDo(DateTime sdate, DateTime edate, int MerchantId)
  971. {
  972. if (sdate.AddMonths(1) < edate)
  973. {
  974. return "时间间隔不能超过1个月";
  975. }
  976. if (edate >= DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00"))
  977. {
  978. return "结束时间只能是今天之前";
  979. }
  980. string check = RedisDbconn.Instance.Get<string>("ResetMerchantTradeQueue:" + MerchantId);
  981. if (!string.IsNullOrEmpty(check))
  982. {
  983. return "请稍后再试";
  984. }
  985. try
  986. {
  987. RedisDbconn.Instance.AddList("ResetMerchantTradeQueue", MerchantId + "#cut#" + sdate.ToString("yyyy-MM-dd HH:mm:ss") + "#cut#" + edate.ToString("yyyy-MM-dd HH:mm:ss"));
  988. RedisDbconn.Instance.Set("ResetMerchantTradeQueue:" + MerchantId, "wait");
  989. RedisDbconn.Instance.SetExpire("ResetMerchantTradeQueue:" + MerchantId, 3600);
  990. }
  991. catch (Exception ex)
  992. {
  993. function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "统计商户的交易额异常");
  994. return "同步异常";
  995. }
  996. return "success";
  997. }
  998. #endregion
  999. }
  1000. }