PosMerchantInfoListController.cs 48 KB

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