PosMerchantInfoListController.cs 49 KB

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