MerchantInfoController.cs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Microsoft.AspNetCore.Mvc;
  5. using Microsoft.AspNetCore.Http;
  6. using Microsoft.Extensions.Logging;
  7. using Microsoft.Extensions.Options;
  8. using Microsoft.AspNetCore.Authorization;
  9. using System.Web;
  10. using MySystem.Models.Main2;
  11. using MySystem.Service.Main2;
  12. using LitJson;
  13. using Library;
  14. namespace MySystem.Areas.Api.Controllers.v1.Main2
  15. {
  16. [Area("Api")]
  17. [Route("/v1/QrCodePlateMain/[controller]/[action]")]
  18. public class MerchantInfoController : BaseController
  19. {
  20. public MerchantInfoController(IHttpContextAccessor accessor) : base(accessor)
  21. {
  22. }
  23. #region 商户激活-银联达标商户列表
  24. [Authorize]
  25. public JsonResult UnionPayQualifiedMerchants(string value)
  26. {
  27. value = PublicFunction.DesDecrypt(value);
  28. JsonData data = JsonMapper.ToObject(value);
  29. Dictionary<string, object> Other = new Dictionary<string, object>();
  30. List<Dictionary<string, object>> dataList = UnionPayQualifiedMerchantsDo(value, out Other);
  31. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList, Other = Other });
  32. }
  33. private List<Dictionary<string, object>> UnionPayQualifiedMerchantsDo(string value, out Dictionary<string, object> Other)
  34. {
  35. JsonData data = JsonMapper.ToObject(value);
  36. string MerchantName = data["MerchantName"].ToString(); //商户名称
  37. string MctNo = data["MctNo"].ToString(); //商户号
  38. int pageSize = int.Parse(function.CheckInt(data["page_size"].ToString()));
  39. int pageNum = int.Parse(function.CheckInt(data["page_num"].ToString()));
  40. string condition = " and IsAct=1 and ExamineStatus=1 and Months=10";
  41. if (!string.IsNullOrEmpty(MerchantName))
  42. {
  43. condition += " and Name like '%" + MerchantName + "%'";
  44. }
  45. if (!string.IsNullOrEmpty(MctNo))
  46. {
  47. var merAddInfo = MerchantAddInfoService.Query(" and MchtNo=" + MctNo + "");
  48. condition += " and Id=" + merAddInfo.Id + "";
  49. }
  50. List<RelationData> relationData = new List<RelationData>();
  51. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  52. Other = new Dictionary<string, object>();
  53. int count = 0;
  54. List<Dictionary<string, object>> source = MerchantInfoService.List(relationData, condition, out count, pageNum, pageSize);
  55. foreach (Dictionary<string, object> subdata in source)
  56. {
  57. Dictionary<string, object> curData = new Dictionary<string, object>();
  58. var MerchantId = int.Parse(subdata["Id"].ToString());
  59. var merAddInfo = MerchantAddInfoService.Query(MerchantId);
  60. var Status = -1;
  61. var order = MerchantDepositOrderService.Query(" and Status>0 and MerchantId=" + MerchantId + "");
  62. if (order.Id > 0) Status = int.Parse(subdata["Status"].ToString());
  63. curData.Add("Id", MerchantId); //Id
  64. curData.Add("MerchantName", merAddInfo.CertMerchantName); //商户名称
  65. curData.Add("MctNo", merAddInfo.MchtNo); //商户号
  66. curData.Add("UpdateDate", order.UpdateDate.ToString() == "" ? "" : DateTime.Parse(order.UpdateDate.ToString()).ToString("yyyy-MM-dd HH:mm:ss")); //激活时间
  67. curData.Add("PayMode", order.Sort); //支付方式(1 支付宝 2 微信)
  68. curData.Add("Status", Status); //达标状态(-1 未参与 0 考核中 1 已通过 2 未通过 101 待领取 100 已领取 99 发放中)
  69. curData.Add("Months", subdata["Months"].ToString()); //达标月数
  70. dataList.Add(curData);
  71. }
  72. Other.Add("Count", count); //总数
  73. return dataList;
  74. }
  75. #endregion
  76. #region 商户管理-商户管理-银联重置登录密码
  77. [Authorize]
  78. public JsonResult UnionPayResetLoginPwd(string value)
  79. {
  80. value = PublicFunction.DesDecrypt(value);
  81. JsonData data = JsonMapper.ToObject(value);
  82. AppResultJson result = UnionPayResetLoginPwdDo(value);
  83. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  84. }
  85. private AppResultJson UnionPayResetLoginPwdDo(string value)
  86. {
  87. JsonData data = JsonMapper.ToObject(value);
  88. string MerchantId = data["MerchantId"].ToString(); //商户Id
  89. Dictionary<string, object> Obj = new Dictionary<string, object>();
  90. var Id = int.Parse(MerchantId);
  91. var query = main2db.MerchantInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantInfo();
  92. var loginMobile = main1db.MerchantLoginInfo.FirstOrDefault(m => m.LoginMobile == query.Mobile) ?? new Models.Main1.MerchantLoginInfo();
  93. Dictionary<string, object> fields = new Dictionary<string, object>();
  94. if (query.Id > 0)
  95. {
  96. query.LoginPwd = function.MD532(query.Mobile.Substring(query.Mobile.Length - 6, 6)); //登录密码
  97. if (loginMobile.Id > 0)
  98. {
  99. loginMobile.LoginPwd = query.LoginPwd; //登录密码
  100. }
  101. }
  102. main2db.SaveChanges();
  103. main1db.SaveChanges();
  104. return new AppResultJson() { Status = "1", Info = "该商户的登录密码已重置为手机号后6位", Data = Obj };
  105. }
  106. #endregion
  107. #region 商户管理-商户管理-银联修改手机号
  108. [Authorize]
  109. public JsonResult UnionPayEditMobile(string value)
  110. {
  111. value = PublicFunction.DesDecrypt(value);
  112. JsonData data = JsonMapper.ToObject(value);
  113. AppResultJson result = UnionPayEditMobileDo(value);
  114. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  115. }
  116. private AppResultJson UnionPayEditMobileDo(string value)
  117. {
  118. JsonData data = JsonMapper.ToObject(value);
  119. string MerchantId = data["MerchantId"].ToString(); //商户Id
  120. string Mobile = data["Mobile"].ToString(); //新手机号
  121. Dictionary<string, object> Obj = new Dictionary<string, object>();
  122. if (Mobile.Length != 11 || !function.IsInt(Mobile) || Mobile.Substring(0, 1) != "1")
  123. {
  124. return new AppResultJson() { Status = "-1", Info = "手机号不正确" };
  125. }
  126. MobileCodeCheck mobilecheck = RedisDbconn.Instance.Get<MobileCodeCheck>("MobileCodeCheck:" + Mobile);
  127. if (mobilecheck == null)
  128. {
  129. return new AppResultJson() { Status = "-1", Info = "短信验证码不正确" };
  130. }
  131. if (mobilecheck.CheckCode != Mobile)
  132. {
  133. return new AppResultJson() { Status = "-1", Info = "短信验证码不正确" };
  134. }
  135. RedisDbconn.Instance.Clear("MobileCodeCheck:" + Mobile);
  136. var Id = int.Parse(MerchantId);
  137. var query = main2db.MerchantInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantInfo();
  138. var loginMobile = main1db.MerchantLoginInfo.FirstOrDefault(m => m.LoginMobile == Mobile) ?? new Models.Main1.MerchantLoginInfo();
  139. Dictionary<string, object> fields = new Dictionary<string, object>();
  140. if (query.Id > 0)
  141. {
  142. query.Mobile = Mobile;
  143. query.LoginPwd = function.MD532(Mobile.Substring(Mobile.Length - 6, 6)); //登录密码
  144. if (loginMobile.Id > 0)
  145. {
  146. loginMobile.LoginMobile = Mobile;
  147. loginMobile.LoginPwd = query.LoginPwd; //登录密码
  148. }
  149. }
  150. main2db.SaveChanges();
  151. main1db.SaveChanges();
  152. return new AppResultJson() { Status = "1", Info = "修改成功,新密码默认为该手机号后6位", Data = Obj };
  153. }
  154. #endregion
  155. }
  156. }