PosMerchantInfoListController.cs 48 KB

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