MerchantParamSetRecordController.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 MerchantParamSetRecordController : BaseController
  19. {
  20. public MerchantParamSetRecordController(IHttpContextAccessor accessor) : base(accessor)
  21. {
  22. }
  23. #region 商户管理-商户管理-直连商户活动变更记录
  24. [Authorize]
  25. public JsonResult DirectMerchantParamSetRecordList(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 = DirectMerchantParamSetRecordListDo(value, out Other);
  31. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList, Other = Other });
  32. }
  33. private List<Dictionary<string, object>> DirectMerchantParamSetRecordListDo(string value, out Dictionary<string, object> Other)
  34. {
  35. JsonData data = JsonMapper.ToObject(value);
  36. string MerchantId = data["MerchantId"].ToString(); //商户Id
  37. int pageSize = int.Parse(function.CheckInt(data["page_size"].ToString()));
  38. int pageNum = int.Parse(function.CheckInt(data["page_num"].ToString()));
  39. string condition = "";
  40. if (!string.IsNullOrEmpty(data["MerchantId"].ToString()))
  41. {
  42. condition += " and MerchantId='" + MerchantId + "'";
  43. }
  44. List<RelationData> relationData = new List<RelationData>();
  45. Other = new Dictionary<string, object>();
  46. int count = 0;
  47. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  48. List<Dictionary<string, object>> source = MerchantParamSetRecordService.List(relationData, condition, out count, pageNum, pageSize);
  49. var merSet = MerchantParamSetService.Query(int.Parse(MerchantId));
  50. foreach (Dictionary<string, object> subdata in source)
  51. {
  52. Dictionary<string, object> curData = new Dictionary<string, object>();
  53. var Id = int.Parse(subdata["Id"].ToString()); //变更记录Id
  54. curData.Add("Id", Id); //变更记录Id
  55. var status = -1;
  56. if (merSet.Version == Id && merSet.IsAll == 0)
  57. {
  58. status = 1;
  59. }
  60. if (subdata["BeforeIsAll"].ToString() == "0" && subdata["AfterIsAll"].ToString() == "1")
  61. {
  62. status = 0;
  63. }
  64. if (merSet.Version != Id && subdata["BeforeIsAll"].ToString() == "0" && subdata["AfterIsAll"].ToString() == "0")
  65. {
  66. status = -1;
  67. }
  68. curData.Add("Status", status); //活动状态(1 使用中 -1 已失效 0 已关闭)
  69. curData.Add("MerchantName", MerchantAddInfoService.Query(int.Parse(subdata["MerchantId"].ToString())).CertMerchantName); //商户名称
  70. curData.Add("CreateDate", subdata["CreateDate"].ToString() == "" ? "" : DateTime.Parse(subdata["CreateDate"].ToString()).ToString("yyyy-MM-dd HH:mm:ss")); //最后操作时间
  71. curData.Add("GetPercent", subdata["AfterGetPercent"].ToString()); //实收比例
  72. curData.Add("DiviPersons", subdata["AfterDiviPersons"].ToString()); //分红人数
  73. curData.Add("ProfitDays", subdata["AfterProfitDays"].ToString()); //分红天数
  74. curData.Add("MinPayMoney", subdata["AfterMinPayMoney"].ToString()); //参与门槛
  75. curData.Add("DiviPercent", subdata["AfterDiviPercent"].ToString()); //最大分红比例
  76. dataList.Add(curData);
  77. }
  78. Other.Add("Count", count); //总数
  79. return dataList;
  80. }
  81. #endregion
  82. }
  83. }