PosMerchantInfoListController.cs 52 KB

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