PosMerchantInfoListController.cs 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135
  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, "KqRegTime 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 ReturnAmount = 0.00M;//服务费总金额
  270. decimal ReturnAmounts = 0.00M;//退还总金额
  271. DataTable dt = OtherMySqlConn.dtable("SELECT SUM(Remark) FROM PosMerchantInfo WHERE 1=1" + condition);
  272. if (dt.Rows.Count > 0)
  273. {
  274. ReturnAmounts = 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. ReturnAmount += decimal.Parse(pos.SeoKeyword) / 100;
  288. }
  289. else
  290. {
  291. ReturnAmount += 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,KqRegTime", 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("KqRegTime", "退还时间");
  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. string KqRegTime = dr[2].ToString(); // 退还时间
  795. var posMerchantInfo = db.PosMerchantInfo.FirstOrDefault(m => m.KqMerNo == KqMerNo) ?? new PosMerchantInfo();
  796. posMerchantInfo.StandardStatus = -2;
  797. posMerchantInfo.Remark = Amount;
  798. posMerchantInfo.KqRegTime = DateTime.Parse(KqRegTime);
  799. Ids += posMerchantInfo.Id + "_" + Amount + ",";
  800. db.SaveChanges();
  801. }
  802. AddSysLog("0", "PosMerchantInfo", "Import");
  803. string text = string.Format("导入人工已退,商户Id: '" + Ids.TrimEnd(',') + "',操作人: '" + SysUserName + "_" + SysRealName + "',Time'" + DateTime.Now + "'");
  804. function.WriteLog(text, "导入人工已退");
  805. return "success";
  806. }
  807. #endregion
  808. #region 导出Excel
  809. /// <summary>
  810. /// 导出Excel
  811. /// </summary>
  812. /// <returns></returns>
  813. public JsonResult ExportExcel(PosMerchantInfo data, string MakerCode, string RealName, string MerMakerCode, string StoreNo, string StoreName, string MerStatusSelect, string ActiveStatusSelect, string ActTypeSelect, string MerUserTypeSelect)
  814. {
  815. Dictionary<string, string> Fields = new Dictionary<string, string>();
  816. Fields.Add("BrandId", "1");
  817. Fields.Add("MerchantNo", "1"); //商户编号
  818. Fields.Add("MerchantName", "1"); //商户姓名
  819. Fields.Add("MerchantMobile", "1"); //商户手机号
  820. Fields.Add("KqMerNo", "1"); //快钱商户编码
  821. Fields.Add("KqSnNo", "1"); //快钱SN号
  822. Fields.Add("KqRegTime", "3"); //渠道注册时间
  823. Fields.Add("TopUserId", "0"); //顶级创客
  824. string condition = " and Status>-1";
  825. //创客编号
  826. if (!string.IsNullOrEmpty(MakerCode))
  827. {
  828. condition += " and UserId in (select UserId from UserForMakerCode where MakerCode='" + MakerCode + "')";
  829. }
  830. //创客名称
  831. if (!string.IsNullOrEmpty(RealName))
  832. {
  833. condition += " and UserId in (select UserId from UserForRealName where RealName='" + RealName + "')";
  834. }
  835. //商户创客编号
  836. if (!string.IsNullOrEmpty(MerMakerCode))
  837. {
  838. condition += " and MerUserId in (select UserId from UserForMakerCode where MakerCode='" + MerMakerCode + "')";
  839. }
  840. //仓库编号
  841. if (!string.IsNullOrEmpty(StoreNo))
  842. {
  843. condition += " and StoreId in (select StoreId from StoreForCode where Code='" + StoreNo + "')";
  844. }
  845. //仓库名称
  846. if (!string.IsNullOrEmpty(RealName))
  847. {
  848. condition += " and StoreId in (select StoreId from StoreForName where Name='" + StoreName + "')";
  849. }
  850. //商户状态
  851. if (!string.IsNullOrEmpty(MerStatusSelect))
  852. {
  853. condition += " and MerStatus=" + MerStatusSelect;
  854. }
  855. //商户激活状态
  856. if (!string.IsNullOrEmpty(ActiveStatusSelect))
  857. {
  858. condition += " and ActiveStatus=" + ActiveStatusSelect;
  859. }
  860. //激活类型
  861. if (!string.IsNullOrEmpty(ActTypeSelect))
  862. {
  863. condition += " and ActType=" + ActTypeSelect;
  864. }
  865. //商户创客类型
  866. if (!string.IsNullOrEmpty(MerUserTypeSelect))
  867. {
  868. condition += " and MerUserType=" + MerUserTypeSelect;
  869. }
  870. 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);
  871. List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
  872. foreach (Dictionary<string, object> dic in diclist)
  873. {
  874. //直属创客
  875. int UserId = int.Parse(dic["UserId"].ToString());
  876. Users puser = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
  877. dic["MakerCode"] = puser.MakerCode;
  878. dic["RealName"] = puser.RealName;
  879. //顶级创客
  880. int TopUserId = int.Parse(dic["TopUserId"].ToString());
  881. Users tuser = db.Users.FirstOrDefault(m => m.Id == TopUserId) ?? new Users();
  882. dic["TopMakerCode"] = tuser.MakerCode;
  883. dic["TopRealName"] = tuser.RealName;
  884. //商户创客
  885. int MerUserId = int.Parse(dic["MerUserId"].ToString());
  886. Users muser = db.Users.FirstOrDefault(m => m.Id == MerUserId) ?? new Users();
  887. dic["MerMakerCode"] = muser.MakerCode;
  888. dic["MerRealName"] = muser.RealName;
  889. //申请创客
  890. int SnApplyUserId = int.Parse(dic["SnApplyUserId"].ToString());
  891. Users snuser = db.Users.FirstOrDefault(m => m.Id == SnApplyUserId) ?? new Users();
  892. dic["SnApplyMakerCode"] = snuser.MakerCode;
  893. dic["SnApplyRealName"] = snuser.RealName;
  894. //SN仓库
  895. int SnStoreId = int.Parse(dic["SnStoreId"].ToString());
  896. StoreHouse store = db.StoreHouse.FirstOrDefault(m => m.Id == SnStoreId) ?? new StoreHouse();
  897. dic["StoreNo"] = store.StoreNo;
  898. dic["StoreName"] = store.StoreName;
  899. //机具类型
  900. int SnType = int.Parse(dic["SnType"].ToString());
  901. if (SnType == 0) dic["SnType"] = "兑换机具";
  902. if (SnType == 1) dic["SnType"] = "循环机具";
  903. //返利资格
  904. dic["RebateQual"] = dic["RebateQual"].ToString() == "1" ? "是" : "否";
  905. //激活类型
  906. int ActType = int.Parse(dic["ActType"].ToString());
  907. if (ActType == 0) dic["ActType"] = "正常激活";
  908. if (ActType == 1) dic["ActType"] = "首次已激活MPOS";
  909. if (ActType == 2) dic["ActType"] = "首次已激活KPOS";
  910. if (ActType == 3) dic["ActType"] = "循环机划拨激活";
  911. //商户状态
  912. int MerStatus = int.Parse(dic["MerStatus"].ToString());
  913. if (MerStatus == 0) dic["MerStatus"] = "正常";
  914. if (MerStatus == 1) dic["MerStatus"] = "冻结";
  915. if (MerStatus == 2) dic["MerStatus"] = "关闭";
  916. //商户激活状态
  917. int ActiveStatus = int.Parse(dic["ActiveStatus"].ToString());
  918. if (ActiveStatus == 0) dic["ActiveStatus"] = "未激活";
  919. if (ActiveStatus == 1) dic["ActiveStatus"] = "已激活";
  920. if (ActiveStatus == 2) dic["ActiveStatus"] = "SN已返现";
  921. //商户创客类型
  922. int MerUserType = int.Parse(dic["MerUserType"].ToString());
  923. if (MerUserType == 0) dic["MerUserType"] = "非商户型创客";
  924. if (MerUserType == 1) dic["MerUserType"] = "商户型创客";
  925. dic.Remove("UserId");
  926. dic.Remove("TopUserId");
  927. dic.Remove("MerUserId");
  928. dic.Remove("SnApplyUserId");
  929. dic.Remove("SnStoreId");
  930. }
  931. Dictionary<string, object> result = new Dictionary<string, object>();
  932. result.Add("Status", "1");
  933. result.Add("Info", "Excel报表-" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + ".xlsx");
  934. result.Add("Obj", diclist);
  935. Dictionary<string, object> ReturnFields = new Dictionary<string, object>();
  936. ReturnFields.Add("MerchantNo", "商户编号");
  937. ReturnFields.Add("MerchantName", "商户名称");
  938. ReturnFields.Add("MerchantMobile", "商户手机号");
  939. ReturnFields.Add("KqMerNo", "快钱商户编码");
  940. ReturnFields.Add("KqSnNo", "快钱SN号");
  941. ReturnFields.Add("SnType", "机具类型");
  942. ReturnFields.Add("RebateQual", "返利资格");
  943. ReturnFields.Add("ActType", "激活类型");
  944. ReturnFields.Add("MerStatus", "商户状态");
  945. ReturnFields.Add("ActiveStatus", "商户激活状态");
  946. ReturnFields.Add("MerMakerCode", "商户创客编码");
  947. ReturnFields.Add("MerRealName", "商户创客名称");
  948. ReturnFields.Add("MerUserType", "商户创客类型");
  949. ReturnFields.Add("MakerCode", "直属创客编号");
  950. ReturnFields.Add("RealName", "直属创客姓名");
  951. ReturnFields.Add("TopMakerCode", "顶级创客编码");
  952. ReturnFields.Add("TopRealName", "顶级创客名称");
  953. ReturnFields.Add("StoreNo", "SN仓库编号");
  954. ReturnFields.Add("StoreName", "SN仓库名称");
  955. ReturnFields.Add("SnApplyMakerCode", "申请创客编号");
  956. ReturnFields.Add("SnApplyRealName", "申请创客姓名");
  957. ReturnFields.Add("KqRegTime", "注册时间");
  958. result.Add("Fields", ReturnFields);
  959. AddSysLog("0", "PosMerchantInfo", "ExportExcel");
  960. return Json(result);
  961. }
  962. #endregion
  963. #region 同步交易额
  964. public IActionResult SycnTradeAmount(string right, int Id = 0)
  965. {
  966. ViewBag.RightInfo = RightInfo;
  967. ViewBag.right = right;
  968. PosMerchantInfo editData = db.PosMerchantInfo.FirstOrDefault(m => m.Id == Id) ?? new PosMerchantInfo();
  969. ViewBag.data = editData;
  970. return View();
  971. }
  972. #endregion
  973. #region 同步交易额
  974. [HttpPost]
  975. public string SycnTradeAmountDo(DateTime sdate, DateTime edate, int MerchantId)
  976. {
  977. if (sdate.AddMonths(1) < edate)
  978. {
  979. return "时间间隔不能超过1个月";
  980. }
  981. if (edate >= DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00"))
  982. {
  983. return "结束时间只能是今天之前";
  984. }
  985. string check = RedisDbconn.Instance.Get<string>("ResetMerchantTradeQueue:" + MerchantId);
  986. if (!string.IsNullOrEmpty(check))
  987. {
  988. return "请稍后再试";
  989. }
  990. try
  991. {
  992. RedisDbconn.Instance.AddList("ResetMerchantTradeQueue", MerchantId + "#cut#" + sdate.ToString("yyyy-MM-dd HH:mm:ss") + "#cut#" + edate.ToString("yyyy-MM-dd HH:mm:ss"));
  993. RedisDbconn.Instance.Set("ResetMerchantTradeQueue:" + MerchantId, "wait");
  994. RedisDbconn.Instance.SetExpire("ResetMerchantTradeQueue:" + MerchantId, 3600);
  995. }
  996. catch (Exception ex)
  997. {
  998. function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "统计商户的交易额异常");
  999. return "同步异常";
  1000. }
  1001. return "success";
  1002. }
  1003. #endregion
  1004. }
  1005. }