ConsumerProfitController.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. string OpenId = data["OpenId"].ToString(); //微信或支付宝Id
  38. int Kind = int.Parse(data["Kind"].ToString()); //类型(1 支付宝 2 微信)
  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 = " WHERE 1=1";
  42. if (Kind == 1)
  43. {
  44. OpenId = AlipayMiniOpenIdDo(OpenId);
  45. }
  46. if (Kind == 2)
  47. {
  48. OpenId = WeChatMiniOpenIdDo(OpenId);
  49. }
  50. string limitString = " LIMIT " + pageSize;
  51. if (pageNum > 1)
  52. {
  53. int skipNum = pageSize * (pageNum - 1);
  54. limitString = " LIMIT " + skipNum + "," + pageSize;
  55. }
  56. condition += limitString;
  57. List<RelationData> relationData = new List<RelationData>();
  58. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  59. 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='') AND Status>0 AND PayModel=" + 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 QrCodePlateMainServer.Consumers WHERE WechatOpenId='') AND Status>0 AND PayModel=" + 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);
  60. foreach (DataRow dr in dt.Rows)
  61. {
  62. Dictionary<string, object> curData = new Dictionary<string, object>();
  63. curData.Add("Id", int.Parse(dr["Id"].ToString())); //Id
  64. curData.Add("Kind", int.Parse(dr["Kind"].ToString())); //商户类型(1 直连 2 银联)
  65. curData.Add("OrderNo", dr["SeoTitle"].ToString()); //订单号
  66. curData.Add("CreateDate", dr["CreateDate"].ToString()); //创建时间
  67. curData.Add("MerchantName", dr["CertMerchantName"].ToString()); //商户名称
  68. curData.Add("GetMoney", decimal.Parse(dr["GetMoney"].ToString())); //分红金额
  69. dataList.Add(curData);
  70. }
  71. Other = new Dictionary<string, object>();
  72. Other.Add("count", dt.Rows.Count);
  73. return dataList;
  74. }
  75. #endregion
  76. }
  77. }