12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Data;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.AspNetCore.Http;
- using Microsoft.Extensions.Logging;
- using Microsoft.Extensions.Options;
- using Microsoft.AspNetCore.Authorization;
- using MySystem.MainModels;
- using LitJson;
- using Library;
- using System.Security.Cryptography;
- using System.Text;
- namespace MySystem.Areas.Api.Controllers.v1
- {
- [Area("Api")]
- [Route("/v1/QrCodePlateMain/[controller]/[action]")]
- public class ConsumerProfitController : ConsumersController
- {
- public ConsumerProfitController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
- {
- }
- #region 我的-分红记录-列表
- [Authorize]
- public JsonResult List(string value)
- {
- value = DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- Dictionary<string, object> Other = new Dictionary<string, object>();
- List<Dictionary<string, object>> dataList = ListDo(value, out Other);
- return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList, Other = Other });
- }
- private List<Dictionary<string, object>> ListDo(string value, out Dictionary<string, object> Other)
- {
- JsonData data = JsonMapper.ToObject(value);
- int ConsumerId = int.Parse(function.CheckInt(data["ConsumerId"].ToString())); //用户Id
- string OpenId = data["OpenId"].ToString(); //用户OpenId
- int Kind = int.Parse(function.CheckInt(data["Kind"].ToString())); //类型(1 支付宝 2 微信)
- int pageSize = int.Parse(function.CheckInt(data["page_size"].ToString()));
- int pageNum = int.Parse(function.CheckInt(data["page_num"].ToString()));
- string condition = " WHERE 1=1";
- string limitString = " LIMIT " + pageSize;
- if (pageNum > 1)
- {
- int skipNum = pageSize * (pageNum - 1);
- limitString = " LIMIT " + skipNum + "," + pageSize;
- }
- condition += limitString;
- List<RelationData> relationData = new List<RelationData>();
- List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
- Other = new Dictionary<string, object>();
- var WechatOpenId = OpenId;
- // var consumer = Services.Main.ConsumersService.Query(ConsumerId);
- // var consumer2 = Services.Main2.ConsumersService.Query(ConsumerId);
- // if (consumer.Id > 0 && ConsumerId > 0)
- // {
- // WechatOpenId = consumer.WechatOpenId;
- // }
- // else
- // {
- // if (consumer2.Id > 0 && ConsumerId > 0)
- // {
- // WechatOpenId = consumer2.WechatOpenId;
- // }
- // }
- if (ConsumerId > 0 && !string.IsNullOrEmpty(WechatOpenId))
- {
- 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);
- foreach (DataRow dr in dt.Rows)
- {
- Dictionary<string, object> curData = new Dictionary<string, object>();
- curData.Add("Id", int.Parse(dr["Id"].ToString())); //Id
- curData.Add("Kind", int.Parse(dr["Kind"].ToString())); //商户类型(1 直连 2 银联)
- curData.Add("OrderNo", dr["SeoTitle"].ToString()); //订单号
- curData.Add("CreateDate", dr["CreateDate"].ToString()); //创建时间
- curData.Add("MerchantName", dr["CertMerchantName"].ToString()); //商户名称
- curData.Add("GetMoney", decimal.Parse(dr["GetMoney"].ToString())); //分红金额
- dataList.Add(curData);
- }
- Other.Add("count", dt.Rows.Count);
- }
- else
- {
- Other.Add("count", 0);
- }
- return dataList;
- }
- #endregion
- }
- }
|