MerchantInfoController.cs 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. Dictionary<string, object> fields = new Dictionary<string, object>();
  93. if (query.Id > 0)
  94. {
  95. query.LoginPwd = function.MD532(query.Mobile.Substring(query.Mobile.Length - 6, 6)); //登录密码
  96. }
  97. main2db.SaveChanges();
  98. return new AppResultJson() { Status = "1", Info = "该商户的登录密码已重置为手机号后6位", Data = Obj };
  99. }
  100. #endregion
  101. #region 商户管理-商户管理-银联修改手机号
  102. [Authorize]
  103. public JsonResult UnionPayEditMobile(string value)
  104. {
  105. value = PublicFunction.DesDecrypt(value);
  106. JsonData data = JsonMapper.ToObject(value);
  107. AppResultJson result = UnionPayEditMobileDo(value);
  108. return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
  109. }
  110. private AppResultJson UnionPayEditMobileDo(string value)
  111. {
  112. JsonData data = JsonMapper.ToObject(value);
  113. string MerchantId = data["MerchantId"].ToString(); //商户Id
  114. string Mobile = data["Mobile"].ToString(); //新手机号
  115. Dictionary<string, object> Obj = new Dictionary<string, object>();
  116. if (Mobile.Length != 11 || !function.IsInt(Mobile) || Mobile.Substring(0, 1) != "1")
  117. {
  118. return new AppResultJson() { Status = "-1", Info = "手机号不正确" };
  119. }
  120. var Id = int.Parse(MerchantId);
  121. var query = main2db.MerchantInfo.FirstOrDefault(m => m.Id == Id) ?? new MerchantInfo();
  122. Dictionary<string, object> fields = new Dictionary<string, object>();
  123. if (query.Id > 0)
  124. {
  125. query.Mobile = Mobile;
  126. query.LoginPwd = function.MD532(Mobile.Substring(Mobile.Length - 6, 6)); //登录密码
  127. }
  128. main2db.SaveChanges();
  129. return new AppResultJson() { Status = "1", Info = "修改成功,新密码默认为该手机号后6位", Data = Obj };
  130. }
  131. #endregion
  132. }
  133. }