ConsumerProfitController.cs 5.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Data;
  5. using Microsoft.AspNetCore.Mvc;
  6. using Microsoft.AspNetCore.Http;
  7. using Microsoft.Extensions.Logging;
  8. using Microsoft.Extensions.Options;
  9. using Microsoft.AspNetCore.Authorization;
  10. using MySystem.MainModels;
  11. using LitJson;
  12. using Library;
  13. using System.Security.Cryptography;
  14. using System.Text;
  15. namespace MySystem.Areas.Api.Controllers.v1
  16. {
  17. [Area("Api")]
  18. [Route("/v1/QrCodePlateMain/[controller]/[action]")]
  19. public class ConsumerProfitController : ConsumersController
  20. {
  21. public ConsumerProfitController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
  22. {
  23. }
  24. #region 我的-分红记录-列表
  25. [Authorize]
  26. public JsonResult List(string value)
  27. {
  28. value = DesDecrypt(value);
  29. JsonData data = JsonMapper.ToObject(value);
  30. Dictionary<string, object> Other = new Dictionary<string, object>();
  31. List<Dictionary<string, object>> dataList = ListDo(value, out Other);
  32. return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList, Other = Other });
  33. }
  34. private List<Dictionary<string, object>> ListDo(string value, out Dictionary<string, object> Other)
  35. {
  36. JsonData data = JsonMapper.ToObject(value);
  37. int ConsumerId = int.Parse(function.CheckInt(data["ConsumerId"].ToString())); //用户Id
  38. string OpenId = data["OpenId"].ToString(); //用户OpenId
  39. int Kind = int.Parse(function.CheckInt(data["Kind"].ToString())); //类型(1 支付宝 2 微信)
  40. int pageSize = int.Parse(function.CheckInt(data["page_size"].ToString()));
  41. int pageNum = int.Parse(function.CheckInt(data["page_num"].ToString()));
  42. string condition = " WHERE 1=1";
  43. string limitString = " LIMIT " + pageSize;
  44. if (pageNum > 1)
  45. {
  46. int skipNum = pageSize * (pageNum - 1);
  47. limitString = " LIMIT " + skipNum + "," + pageSize;
  48. }
  49. condition += limitString;
  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. var WechatOpenId = OpenId;
  54. // var consumer = Services.Main.ConsumersService.Query(ConsumerId);
  55. // var consumer2 = Services.Main2.ConsumersService.Query(ConsumerId);
  56. // if (consumer.Id > 0 && ConsumerId > 0)
  57. // {
  58. // WechatOpenId = consumer.WechatOpenId;
  59. // }
  60. // else
  61. // {
  62. // if (consumer2.Id > 0 && ConsumerId > 0)
  63. // {
  64. // WechatOpenId = consumer2.WechatOpenId;
  65. // }
  66. // }
  67. if (ConsumerId > 0 && !string.IsNullOrEmpty(WechatOpenId))
  68. {
  69. DataTable dt = CustomerSqlConn.dtable("SELECT * FROM(SELECT a.*,b.CertMerchantName FROM (SELECT Id,1 Kind,CreateDate,SeoTitle,GetMoney,MerchantId FROM QrCodePlateMainServer.ConsumerProfit WHERE OrderId IN(SELECT Id FROM QrCodePlateMainServer.ConsumerOrders WHERE ConsumerId IN(SELECT Id FROM QrCodePlateMainServer.Consumers WHERE WechatOpenId='" + WechatOpenId + "') AND Status>0 AND PayMode=" + Kind + "))a LEFT JOIN (SELECT Id,CertMerchantName FROM QrCodePlateMainServer.MerchantAddInfo WHERE Status=2 OR QueryCount=2)b ON a.MerchantId=b.Id UNION ALL SELECT a.*,b.CertMerchantName FROM (SELECT Id,2 Kind,CreateDate,SeoTitle,GetMoney,MerchantId FROM QrCodePlateMainServer2.ConsumerProfit WHERE OrderId IN(SELECT Id FROM QrCodePlateMainServer2.ConsumerOrders WHERE ConsumerId IN(SELECT Id FROM QrCodePlateMainServer2.Consumers WHERE WechatOpenId='" + WechatOpenId + "') AND Status>0 AND PayMode=" + Kind + "))a LEFT JOIN (SELECT Id,CertMerchantName FROM QrCodePlateMainServer2.MerchantAddInfo WHERE Status=2 OR QueryCount=2)b ON a.MerchantId=b.Id)aa" + condition, AppConfig.Base.SqlConnStr);
  70. foreach (DataRow dr in dt.Rows)
  71. {
  72. Dictionary<string, object> curData = new Dictionary<string, object>();
  73. curData.Add("Id", int.Parse(dr["Id"].ToString())); //Id
  74. curData.Add("Kind", int.Parse(dr["Kind"].ToString())); //商户类型(1 直连 2 银联)
  75. curData.Add("OrderNo", dr["SeoTitle"].ToString()); //订单号
  76. curData.Add("CreateDate", dr["CreateDate"].ToString()); //创建时间
  77. curData.Add("MerchantName", dr["CertMerchantName"].ToString()); //商户名称
  78. curData.Add("GetMoney", decimal.Parse(dr["GetMoney"].ToString())); //分红金额
  79. dataList.Add(curData);
  80. }
  81. Other.Add("count", dt.Rows.Count);
  82. }
  83. else
  84. {
  85. Other.Add("count", 0);
  86. }
  87. return dataList;
  88. }
  89. #endregion
  90. }
  91. }