MerchantInfoController.cs 4.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 = "";
  42. if (!string.IsNullOrEmpty(MerchantName))
  43. {
  44. condition += " and Name='" + 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", subdata["Id"].ToString()); //商户名称
  71. curData.Add("AliPID", merAddInfo.AlipayPid); //支付宝PID
  72. curData.Add("WeChatNo", merAddInfo.SubMchid); //微信商户号
  73. curData.Add("UpdateDate", order.UpdateDate.ToString() == null ? "" : 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. }
  84. }