MerchantInfoController.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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.Main1;
  11. using MySystem.Service.Main1;
  12. using LitJson;
  13. using Library;
  14. namespace MySystem.Areas.Api.Controllers.v1.Main1
  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 DirectQualifiedMerchants(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 = DirectQualifiedMerchantsDo(value, out Other);
  31. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList, Other = Other });
  32. }
  33. private List<Dictionary<string, object>> DirectQualifiedMerchantsDo(string value, out Dictionary<string, object> Other)
  34. {
  35. JsonData data = JsonMapper.ToObject(value);
  36. string MerchantName = data["MerchantName"].ToString(); //商户名称
  37. string AliPID = data["AliPID"].ToString(); //支付宝PID
  38. string WeChatNo = data["WeChatNo"].ToString(); //微信商户号
  39. int pageSize = int.Parse(function.CheckInt(data["page_size"].ToString()));
  40. int pageNum = int.Parse(function.CheckInt(data["page_num"].ToString()));
  41. string condition = " and IsAct=1 and ExamineStatus=1 and Months=10";
  42. if (!string.IsNullOrEmpty(MerchantName))
  43. {
  44. condition += " and Name like '%" + MerchantName + "%'";
  45. }
  46. if (!string.IsNullOrEmpty(AliPID))
  47. {
  48. var merAddInfo = MerchantAddInfoService.Query(" and AlipayPid=" + AliPID + "");
  49. condition += " and Id=" + merAddInfo.Id + "";
  50. }
  51. if (!string.IsNullOrEmpty(WeChatNo))
  52. {
  53. var merAddInfo = MerchantAddInfoService.Query(" and SubMchid=" + WeChatNo + "");
  54. condition += " and Id=" + merAddInfo.Id + "";
  55. }
  56. List<RelationData> relationData = new List<RelationData>();
  57. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  58. Other = new Dictionary<string, object>();
  59. int count = 0;
  60. List<Dictionary<string, object>> source = MerchantInfoService.List(relationData, condition, out count, pageNum, pageSize);
  61. foreach (Dictionary<string, object> subdata in source)
  62. {
  63. Dictionary<string, object> curData = new Dictionary<string, object>();
  64. var MerchantId = int.Parse(subdata["Id"].ToString());
  65. var merAddInfo = MerchantAddInfoService.Query(MerchantId);
  66. var Status = -1;
  67. var order = MerchantDepositOrderService.Query(" and Status>0 and MerchantId=" + MerchantId + "");
  68. if (order.Id > 0) Status = int.Parse(subdata["Status"].ToString());
  69. curData.Add("Id", MerchantId); //Id
  70. curData.Add("MerchantName", merAddInfo.CertMerchantName); //商户名称
  71. curData.Add("AliPID", merAddInfo.AlipayPid); //支付宝PID
  72. curData.Add("WeChatNo", merAddInfo.SubMchid); //微信商户号
  73. curData.Add("UpdateDate", order.UpdateDate.ToString() == "" ? "" : DateTime.Parse(order.UpdateDate.ToString()).ToString("yyyy-MM-dd HH:mm:ss")); //激活时间
  74. curData.Add("PayMode", order.Sort); //支付方式(1 支付宝 2 微信)
  75. curData.Add("Status", Status); //达标状态(-1 未参与 0 考核中 1 已通过 2 未通过 101 待领取 100 已领取 99 发放中)
  76. curData.Add("Months", subdata["Months"].ToString()); //达标月数
  77. dataList.Add(curData);
  78. }
  79. Other.Add("Count", count); //总数
  80. return dataList;
  81. }
  82. #endregion
  83. #region 商户管理-商户管理-直连重置登录密码
  84. [Authorize]
  85. public JsonResult DirectResetLoginPwd(string value)
  86. {
  87. value = PublicFunction.DesDecrypt(value);
  88. JsonData data = JsonMapper.ToObject(value);
  89. AppResultJson result = DirectResetLoginPwdDo(value);
  90. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  91. }
  92. private AppResultJson DirectResetLoginPwdDo(string value)
  93. {
  94. JsonData data = JsonMapper.ToObject(value);
  95. string MerchantId = data["MerchantId"].ToString(); //商户Id
  96. Dictionary<string, object> Obj = new Dictionary<string, object>();
  97. var Id = int.Parse(MerchantId);
  98. var query = main1db.MerchantInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantInfo();
  99. var loginMobile = main1db.MerchantLoginInfo.FirstOrDefault(m => m.LoginMobile == query.Mobile) ?? new MerchantLoginInfo();
  100. Dictionary<string, object> fields = new Dictionary<string, object>();
  101. if (query.Id > 0)
  102. {
  103. query.LoginPwd = function.MD532(query.Mobile.Substring(query.Mobile.Length - 6, 6)); //登录密码
  104. if (loginMobile.Id > 0)
  105. {
  106. loginMobile.LoginPwd = query.LoginPwd; //登录密码
  107. }
  108. }
  109. main1db.SaveChanges();
  110. return new AppResultJson() { Status = "1", Info = "该商户的登录密码已重置为手机号后6位", Data = Obj };
  111. }
  112. #endregion
  113. #region 商户管理-商户管理-直连修改手机号
  114. [Authorize]
  115. public JsonResult DirectEditMobile(string value)
  116. {
  117. value = PublicFunction.DesDecrypt(value);
  118. JsonData data = JsonMapper.ToObject(value);
  119. AppResultJson result = DirectEditMobileDo(value);
  120. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  121. }
  122. private AppResultJson DirectEditMobileDo(string value)
  123. {
  124. JsonData data = JsonMapper.ToObject(value);
  125. string MerchantId = data["MerchantId"].ToString(); //商户Id
  126. string Mobile = data["Mobile"].ToString(); //新手机号
  127. string MobileCode = data["MobileCode"].ToString(); //短信验证码
  128. Dictionary<string, object> Obj = new Dictionary<string, object>();
  129. if (Mobile.Length != 11 || !function.IsInt(Mobile) || Mobile.Substring(0, 1) != "1")
  130. {
  131. return new AppResultJson() { Status = "-1", Info = "手机号不正确" };
  132. }
  133. var mobilecheck = RedisDbconn.Instance.Get<string>("MobileCodeCheck:" + Mobile);
  134. if (mobilecheck == "")
  135. {
  136. return new AppResultJson() { Status = "-1", Info = "短信验证码不正确" };
  137. }
  138. if (mobilecheck != MobileCode)
  139. {
  140. return new AppResultJson() { Status = "-1", Info = "短信验证码不正确" };
  141. }
  142. RedisDbconn.Instance.Clear("MobileCodeCheck:" + Mobile);
  143. var Id = int.Parse(MerchantId);
  144. var check = MerchantLoginInfoService.Query(" and LoginMobile=" + Mobile + "");
  145. if (check.Id > 0)
  146. {
  147. return new AppResultJson() { Status = "-1", Info = "已存在相关登录手机号" };
  148. }
  149. var query = main1db.MerchantInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantInfo();
  150. var loginMobile = main1db.MerchantLoginInfo.FirstOrDefault(m => m.LoginMobile == query.Mobile) ?? new MerchantLoginInfo();
  151. Dictionary<string, object> fields = new Dictionary<string, object>();
  152. if (query.Id > 0)
  153. {
  154. query.Mobile = Mobile;
  155. query.LoginPwd = function.MD532(Mobile.Substring(Mobile.Length - 6, 6)); //登录密码
  156. if (loginMobile.Id > 0)
  157. {
  158. loginMobile.LoginMobile = Mobile;
  159. loginMobile.LoginPwd = query.LoginPwd; //登录密码
  160. }
  161. }
  162. main1db.SaveChanges();
  163. return new AppResultJson() { Status = "1", Info = "修改成功,新密码默认为该手机号后6位", Data = Obj };
  164. }
  165. #endregion
  166. }
  167. }