using MySystem.MainModels;
using Library;
using System.Collections.Generic;
using System;
namespace MySystem
{
///
/// 经营数据工具类
///
public class BusinessUtil
{
#region 经营数据记录(月)
///
/// 经营数据记录(月)
///
/// 商户Id
/// 月份
/// 条数
/// 页数
///
public static List> BussinessRecordForMonth(int MerchantId, string TradeMonth, int pageSize, int pageNum)
{
List> dataList = new List>();
if(!new MerchantTradeSummaryService().CheckTableExist(TradeMonth))
{
return dataList;
}
List> source = new MerchantTradeSummaryService().List2(new List(), " and MerchantId=" + MerchantId, TradeMonth, pageNum, pageSize, "TradeDate desc");
// var infos = UserTradeDbconn.GetDateTradeList(MerchantId,TradeMonth);
foreach (Dictionary subdata in source)
{
Dictionary curData = new Dictionary();
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;
}
#endregion
#region 经营数据记录(半年)
///
/// 经营数据记录(半年)
///
/// 商户Id
/// 条数
/// 页数
///
public static List> BussinessRecordForHalfYear(int MerchantId, int pageSize, int pageNum)
{
List> dataList = new List>();
List> source = UserTradeDbconn.Instance.GetMonthTradeList(MerchantId, "TradeAmount,InFactAmount,ActAmount,NonActAmount,WeChatInFactAmount,AliPayInFactAmount,OderCount");
foreach (Dictionary subdata in source)
{
Dictionary curData = new Dictionary();
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;
}
#endregion
#region 经营详情列表
///
/// 经营详情列表
///
/// 查询条件
/// 条数
/// 页数
///
public static List> DayDetailList(string condition, int pageSize, int pageNum)
{
List> dataList = new List>();
List> source = new ConsumerOrdersService().List(new List(), condition, pageNum, pageSize);
foreach (Dictionary subdata in source)
{
Dictionary curData = new Dictionary();
curData.Add("Id", subdata["Id"].ToString()); //订单Id
curData.Add("TradeDate", DateTime.Parse(subdata["CreateDate"].ToString()).ToString("HH:mm:ss")); //日期
curData.Add("PayMode", subdata["PayMode"].ToString()); //支付方式(1 支付宝 2 微信)
curData.Add("IsAct", subdata["IsAct"].ToString()); //是否活动(1 是 0 否)
curData.Add("PayMoney", subdata["PayMoney"].ToString()); //订单金额
curData.Add("Kind", 1); //通道(1 直连 2 银联)
dataList.Add(curData);
}
return dataList;
}
#endregion
#region 交易详情
///
/// 交易详情
///
/// 查询条件
///
public static Dictionary OrderDetail(string condition)
{
Dictionary obj = new Dictionary();
List> source = new ConsumerOrdersService().List(new List(), condition, 1, 999);
foreach (Dictionary subdata in source)
{
var leaveAmount = decimal.Parse(subdata["MaxDivi"].ToString()) - decimal.Parse(subdata["CurDivi"].ToString());
obj.Add("TradeDate", DateTime.Parse(subdata["CreateDate"].ToString()).ToString("yyyy-MM-dd HH:mm:ss")); //日期
obj.Add("PayMode", subdata["PayMode"].ToString()); //支付方式(1 微信 2 支付宝)
obj.Add("PayMoney", subdata["PayMoney"].ToString()); //是否活动(1 是 0 否)
obj.Add("IsAct", subdata["IsAct"].ToString()); //是否活动(1 是 0 否)
obj.Add("OrderNo", subdata["OrderNo"].ToString()); //订单号
obj.Add("ReturnFlag", int.Parse(subdata["ReturnFlag"].ToString())); //返现标记(0 否 1 是)
obj.Add("Kind", 1); //通道(1 直连 2 银联)
obj.Add("LeaveAmount", leaveAmount); //剩余返现金额
List> dataList = new List>();
List> dics = new ConsumerProfitService().List(new List(), " and OrderId=" + int.Parse(subdata["Id"].ToString()) + "", 1, 999);
foreach (Dictionary dic in dics)
{
Dictionary cdata = new Dictionary();
var CreateDate = DateTime.Parse(dic["CreateDate"].ToString());
var TradeDate = CreateDate.Month + "月" + CreateDate.Day + "日" + " " + CreateDate.ToString("HH:mm");
cdata.Add("ProfitDate", TradeDate); //分红时间
cdata.Add("ProfitAmount", dic["GetMoney"].ToString()); //分红金额
dataList.Add(cdata);
}
obj.Add("ProfitTotalAmount", new ConsumerProfitService().Sum("GetMoney", " and OrderId=" + int.Parse(subdata["Id"].ToString()) + "")["GetMoney"]); //分红总金额
MerchantInfo merchant = new MerchantInfoService().Query(int.Parse(function.CheckInt(subdata["MerchantId"].ToString())));
obj.Add("MerchantName", merchant.Name); //门店名称
obj.Add("ProfitList", dataList); //订单分红记录列表
}
return obj;
}
#endregion
}
}