MerchantParamSetRecordController.cs 4.0 KB

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