|
@@ -0,0 +1,82 @@
|
|
|
+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 ConsumerOrdersController : ConsumersController
|
|
|
+ {
|
|
|
+ public ConsumerOrdersController(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);
|
|
|
+ string OpenId = data["OpenId"].ToString(); //微信或支付宝Id
|
|
|
+ int Kind = int.Parse(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";
|
|
|
+ if (Kind == 1)
|
|
|
+ {
|
|
|
+ OpenId = AlipayMiniOpenIdDo(OpenId);
|
|
|
+ }
|
|
|
+ if (Kind == 2)
|
|
|
+ {
|
|
|
+ OpenId = WeChatMiniOpenIdDo(OpenId);
|
|
|
+ }
|
|
|
+ string limitString = " LIMIT " + pageSize;
|
|
|
+ if (pageNum > 1)
|
|
|
+ {
|
|
|
+ int skipNum = pageSize * (pageNum - 1);
|
|
|
+ limitString = " LIMIT " + skipNum + "," + pageSize;
|
|
|
+ }
|
|
|
+ condition += limitString;
|
|
|
+ List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
|
|
|
+ DataTable dt = CustomerSqlConn.dtable("SELECT * FROM(SELECT a.*,b.CertMerchantName FROM(SELECT Id,1 Kind,MerchantId,UpdateDate,OrderNo,ConsumerId,PayMoney,CurDivi,Status FROM QrCodePlateMainServer.ConsumerOrders WHERE ConsumerId IN(SELECT Id FROM QrCodePlateMainServer.Consumers WHERE WechatOpenId='" + OpenId + "') 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,MerchantId,UpdateDate,OrderNo,ConsumerId,PayMoney,CurDivi,Status FROM QrCodePlateMainServer2.ConsumerOrders WHERE ConsumerId IN(SELECT Id FROM QrCodePlateMainServer.Consumers WHERE WechatOpenId='" + OpenId + "') 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);
|
|
|
+ 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["OrderNo"].ToString()); //订单号
|
|
|
+ curData.Add("PayMoney", decimal.Parse(dr["PayMoney"].ToString())); //支付金额
|
|
|
+ curData.Add("ReturnMoney", decimal.Parse(dr["CurDivi"].ToString())); //已返金额
|
|
|
+ curData.Add("Status", int.Parse(dr["Status"].ToString())); //状态
|
|
|
+ curData.Add("CreateDate", DateTime.Parse(dr["UpdateDate"].ToString()).ToString("yyyy-MM-dd HH:mm:ss")); //创建时间
|
|
|
+ curData.Add("MerchantName", dr["CertMerchantName"].ToString()); //商户名称
|
|
|
+ dataList.Add(curData);
|
|
|
+ }
|
|
|
+ Other = new Dictionary<string, object>();
|
|
|
+ Other.Add("count", dt.Rows.Count);
|
|
|
+ return dataList;
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ }
|
|
|
+}
|