|
@@ -2,6 +2,7 @@ using MySystem.MainModels;
|
|
|
using Library;
|
|
|
using System.Collections.Generic;
|
|
|
using System;
|
|
|
+using System.Data;
|
|
|
|
|
|
namespace MySystem
|
|
|
{
|
|
@@ -10,7 +11,7 @@ namespace MySystem
|
|
|
/// </summary>
|
|
|
public class BusinessUtil
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
#region 经营数据记录(月)
|
|
|
/// <summary>
|
|
|
/// 经营数据记录(月)
|
|
@@ -23,24 +24,51 @@ namespace MySystem
|
|
|
public static List<Dictionary<string, object>> BussinessRecordForMonth(int MerchantId, string TradeMonth, int pageSize, int pageNum)
|
|
|
{
|
|
|
List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
|
|
|
- if(!new MerchantTradeSummaryService().CheckTableExist(TradeMonth))
|
|
|
+ if (!new MerchantTradeSummaryService().CheckTableExist(TradeMonth))
|
|
|
{
|
|
|
return dataList;
|
|
|
}
|
|
|
- List<Dictionary<string, object>> source = new MerchantTradeSummaryService().List2(new List<FieldItem>(), " and MerchantId=" + MerchantId, TradeMonth, pageNum, pageSize, "TradeDate desc");
|
|
|
- // var infos = UserTradeDbconn.GetDateTradeList(MerchantId,TradeMonth);
|
|
|
- foreach (Dictionary<string, object> subdata in source)
|
|
|
+ // List<Dictionary<string, object>> source = new MerchantTradeSummaryService().List2(new List<FieldItem>(), " and MerchantId=" + MerchantId, TradeMonth, pageNum, pageSize, "TradeDate desc");
|
|
|
+ // // var infos = UserTradeDbconn.GetDateTradeList(MerchantId,TradeMonth);
|
|
|
+ // foreach (Dictionary<string, object> subdata in source)
|
|
|
+ // {
|
|
|
+ // Dictionary<string, object> curData = new Dictionary<string, object>();
|
|
|
+ // curData.Add("TradeDate", subdata["TradeDate"].ToString()); //日期
|
|
|
+ // curData.Add("TotalAmount", subdata["TradeAmount"].ToString()); //营业总金额
|
|
|
+ // curData.Add("InFactAmount", subdata["InFactAmount"].ToString()); //实收总金额
|
|
|
+ // curData.Add("ActAmount", subdata["ActAmount"].ToString()); //活动总金额
|
|
|
+ // curData.Add("NonActAmount", subdata["NonActAmount"].ToString()); //非活动总金额
|
|
|
+ // curData.Add("WeChatInFactAmount", subdata["WeChatInfactAmount"].ToString()); //微信实收
|
|
|
+ // curData.Add("AliPayInFactAmount", subdata["AliPayInFactAmount"].ToString()); //支付宝实收
|
|
|
+ // curData.Add("OrderCount", subdata["OderCount"].ToString()); //订单数
|
|
|
+ // curData.Add("Kind", 1); //通道(1 直连 2 银联)
|
|
|
+ // dataList.Add(curData);
|
|
|
+ // }
|
|
|
+ // return dataList;
|
|
|
+
|
|
|
+ string limit = " limit " + pageSize;
|
|
|
+ if (pageNum > 1)
|
|
|
+ {
|
|
|
+ int skip = (pageNum - 1) * pageSize;
|
|
|
+ limit = " limit " + skip + "," + pageSize;
|
|
|
+ }
|
|
|
+ DataTable dt = CustomerSqlConn.dtable("select TradeDate,sum(TradeAmount) TotalAmount,sum(TotalActual) InFactAmount,sum(if(IsAct=1,TradeAmount,0)) ActAmount,sum(if(IsAct=0,TradeAmount,0)) NonActAmount,sum(if(PayMode=2,TotalActual,0)) WeChatInFactAmount,sum(if(PayMode=1,TotalActual,0)) AliPayInFactAmount,sum(TradeCount) OrderCount from MerchantAmountSummay where MerchantId=" + MerchantId + " and TradeMonth='" + TradeMonth + "' group by TradeDate order by TradeDate desc" + limit, AppConfig.Base.SqlConnStr);
|
|
|
+ if (dt.Rows.Count < 1)
|
|
|
+ {
|
|
|
+ return dataList;
|
|
|
+ }
|
|
|
+ foreach (DataRow subdata in dt.Rows)
|
|
|
{
|
|
|
Dictionary<string, object> curData = new Dictionary<string, object>();
|
|
|
curData.Add("TradeDate", subdata["TradeDate"].ToString()); //日期
|
|
|
- curData.Add("TotalAmount", subdata["TradeAmount"].ToString()); //营业总金额
|
|
|
- curData.Add("InFactAmount", subdata["InFactAmount"].ToString()); //实收总金额
|
|
|
- curData.Add("ActAmount", subdata["ActAmount"].ToString()); //活动总金额
|
|
|
- curData.Add("NonActAmount", subdata["NonActAmount"].ToString()); //非活动总金额
|
|
|
- curData.Add("WeChatInFactAmount", subdata["WeChatInfactAmount"].ToString()); //微信实收
|
|
|
- curData.Add("AliPayInFactAmount", subdata["AliPayInFactAmount"].ToString()); //支付宝实收
|
|
|
- curData.Add("OrderCount", subdata["OderCount"].ToString()); //订单数
|
|
|
- curData.Add("Kind", 1); //通道(1 直连 2 银联)
|
|
|
+ curData.Add("TotalAmount", decimal.Parse(subdata["TotalAmount"].ToString()).ToString("f2")); //营业总金额
|
|
|
+ curData.Add("InFactAmount", decimal.Parse(subdata["InFactAmount"].ToString()).ToString("f2")); //实收总金额
|
|
|
+ curData.Add("ActAmount", decimal.Parse(subdata["ActAmount"].ToString()).ToString("f2")); //活动总金额
|
|
|
+ curData.Add("NonActAmount", decimal.Parse(subdata["NonActAmount"].ToString()).ToString("f2")); //非活动总金额
|
|
|
+ curData.Add("WeChatInFactAmount", decimal.Parse(subdata["WeChatInfactAmount"].ToString()).ToString("f2")); //微信实收
|
|
|
+ curData.Add("AliPayInFactAmount", decimal.Parse(subdata["AliPayInFactAmount"].ToString()).ToString("f2")); //支付宝实收
|
|
|
+ curData.Add("OrderCount", subdata["OrderCount"].ToString()); //订单数
|
|
|
+ curData.Add("Kind", 2); //通道(1 直连 2 银联)
|
|
|
dataList.Add(curData);
|
|
|
}
|
|
|
return dataList;
|
|
@@ -59,19 +87,45 @@ namespace MySystem
|
|
|
public static List<Dictionary<string, object>> BussinessRecordForHalfYear(int MerchantId, int pageSize, int pageNum)
|
|
|
{
|
|
|
List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
|
|
|
- List<Dictionary<string, object>> source = UserTradeDbconn.Instance.GetMonthTradeList(MerchantId, "TradeAmount,InFactAmount,ActAmount,NonActAmount,WeChatInFactAmount,AliPayInFactAmount,OderCount");
|
|
|
- foreach (Dictionary<string, object> subdata in source)
|
|
|
+ // List<Dictionary<string, object>> source = UserTradeDbconn.Instance.GetMonthTradeList(MerchantId, "TradeAmount,InFactAmount,ActAmount,NonActAmount,WeChatInFactAmount,AliPayInFactAmount,OderCount");
|
|
|
+ // foreach (Dictionary<string, object> subdata in source)
|
|
|
+ // {
|
|
|
+ // Dictionary<string, object> curData = new Dictionary<string, object>();
|
|
|
+ // curData.Add("TradeDate", subdata["TradeDate"].ToString()); //日期
|
|
|
+ // curData.Add("TotalAmount", subdata["TradeAmount"].ToString()); //营业总金额
|
|
|
+ // curData.Add("InFactAmount", subdata["InFactAmount"].ToString()); //实收总金额
|
|
|
+ // curData.Add("ActAmount", subdata["ActAmount"].ToString()); //活动总金额
|
|
|
+ // curData.Add("NonActAmount", subdata["NonActAmount"].ToString()); //非活动总金额
|
|
|
+ // curData.Add("WeChatInFactAmount", subdata["WeChatInFactAmount"].ToString()); //微信实收
|
|
|
+ // curData.Add("AliPayInFactAmount", subdata["AliPayInFactAmount"].ToString()); //支付宝实收
|
|
|
+ // curData.Add("OrderCount", subdata["OderCount"].ToString()); //订单数
|
|
|
+ // dataList.Add(curData);
|
|
|
+ // }
|
|
|
+
|
|
|
+
|
|
|
+ var end = DateTime.Now.ToString("yyyyMM");
|
|
|
+ var start = DateTime.Now.AddMonths(-5).ToString("yyyyMM");
|
|
|
+ DataTable dt = CustomerSqlConn.dtable("SELECT TradeMonth 日期,SUM(TradeAmount) 营业总金额,SUM(TotalActual) 实收总金额,SUM(IF(IsAct=1,TotalActual,0)) 活动总金额,SUM(IF(IsAct=0,TotalActual,0)) 非活动总金额,SUM(IF(PayMode=1,TotalActual,0)) 微信实收,SUM(IF(PayMode=2,TotalActual,0)) 支付宝实收,SUM(TradeCount) 订单数 FROM MerchantAmountSummay WHERE MerchantId=" + MerchantId + " AND TradeMonth>='" + start + "' AND TradeMonth<='" + end + "' GROUP BY TradeMonth ORDER BY TradeMonth DESC", AppConfig.Base.SqlConnStr);
|
|
|
+ if (dt.Rows.Count < 1)
|
|
|
{
|
|
|
- Dictionary<string, object> curData = new Dictionary<string, object>();
|
|
|
- curData.Add("TradeDate", subdata["TradeDate"].ToString()); //日期
|
|
|
- curData.Add("TotalAmount", subdata["TradeAmount"].ToString()); //营业总金额
|
|
|
- curData.Add("InFactAmount", subdata["InFactAmount"].ToString()); //实收总金额
|
|
|
- curData.Add("ActAmount", subdata["ActAmount"].ToString()); //活动总金额
|
|
|
- curData.Add("NonActAmount", subdata["NonActAmount"].ToString()); //非活动总金额
|
|
|
- curData.Add("WeChatInFactAmount", subdata["WeChatInFactAmount"].ToString()); //微信实收
|
|
|
- curData.Add("AliPayInFactAmount", subdata["AliPayInFactAmount"].ToString()); //支付宝实收
|
|
|
- curData.Add("OrderCount", subdata["OderCount"].ToString()); //订单数
|
|
|
- dataList.Add(curData);
|
|
|
+ return dataList;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ foreach (DataRow item in dt.Rows)
|
|
|
+ {
|
|
|
+ Dictionary<string, object> curData = new Dictionary<string, object>();
|
|
|
+ var TradeDate = item["日期"].ToString();
|
|
|
+ curData.Add("TradeDate", TradeDate.Substring(0, 4) + "-" + TradeDate.Substring(TradeDate.Length - 2, 2)); //日期
|
|
|
+ curData.Add("TotalAmount", decimal.Parse(item["营业总金额"].ToString()).ToString("f2")); //营业总金额
|
|
|
+ curData.Add("InFactAmount", decimal.Parse(item["实收总金额"].ToString()).ToString("f2")); //实收总金额
|
|
|
+ curData.Add("ActAmount", decimal.Parse(item["活动总金额"].ToString()).ToString("f2")); //活动总金额
|
|
|
+ curData.Add("NonActAmount", decimal.Parse(item["非活动总金额"].ToString()).ToString("f2")); //非活动总金额
|
|
|
+ curData.Add("WeChatInFactAmount", decimal.Parse(item["微信实收"].ToString()).ToString("f2")); //微信实收
|
|
|
+ curData.Add("AliPayInFactAmount", decimal.Parse(item["支付宝实收"].ToString()).ToString("f2")); //支付宝实收
|
|
|
+ curData.Add("OrderCount", item["订单数"].ToString()); //订单数
|
|
|
+ dataList.Add(curData);
|
|
|
+ }
|
|
|
}
|
|
|
return dataList;
|
|
|
}
|