BusinessUtil.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. using MySystem.MainModels;
  2. using Library;
  3. using System.Collections.Generic;
  4. using System;
  5. namespace MySystem
  6. {
  7. /// <summary>
  8. /// 经营数据工具类
  9. /// </summary>
  10. public class BusinessUtil
  11. {
  12. #region 经营数据记录(月)
  13. /// <summary>
  14. /// 经营数据记录(月)
  15. /// </summary>
  16. /// <param name="MerchantId">商户Id</param>
  17. /// <param name="TradeMonth">月份</param>
  18. /// <param name="pageSize">条数</param>
  19. /// <param name="pageNum">页数</param>
  20. /// <returns></returns>
  21. public static List<Dictionary<string, object>> BussinessRecordForMonth(int MerchantId, string TradeMonth, int pageSize, int pageNum)
  22. {
  23. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  24. List<Dictionary<string, object>> source = new MerchantTradeSummaryService().List2(new List<FieldItem>(), " and MerchantId=" + MerchantId, TradeMonth, pageNum, pageSize);
  25. // var infos = UserTradeDbconn.GetDateTradeList(MerchantId,TradeMonth);
  26. foreach (Dictionary<string, object> subdata in source)
  27. {
  28. Dictionary<string, object> curData = new Dictionary<string, object>();
  29. curData.Add("TradeDate", subdata["TradeDate"].ToString()); //日期
  30. curData.Add("TotalAmount", subdata["TotalAmount"].ToString()); //营业总金额
  31. curData.Add("InFactAmount", subdata["InFactAmount"].ToString()); //实收总金额
  32. curData.Add("ActAmount", subdata["ActAmount"].ToString()); //活动总金额
  33. curData.Add("NonActAmount", subdata["NonActAmount"].ToString()); //非活动总金额
  34. curData.Add("WeChatInFactAmount", subdata["WeChatInFactAmount"].ToString()); //微信实收
  35. curData.Add("AliPayInFactAmount", subdata["AliPayInFactAmount"].ToString()); //支付宝实收
  36. curData.Add("OrderCount", subdata["OrderCount"].ToString()); //订单数
  37. dataList.Add(curData);
  38. }
  39. return dataList;
  40. }
  41. #endregion
  42. #region 经营数据记录(半年)
  43. /// <summary>
  44. /// 经营数据记录(半年)
  45. /// </summary>
  46. /// <param name="MerchantId">商户Id</param>
  47. /// <param name="pageSize">条数</param>
  48. /// <param name="pageNum">页数</param>
  49. /// <returns></returns>
  50. public static List<Dictionary<string, object>> BussinessRecordForHalfYear(int MerchantId, int pageSize, int pageNum)
  51. {
  52. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  53. List<Dictionary<string, object>> source = UserTradeDbconn.Instance.GetMonthTradeList(MerchantId, "TradeAmount,InFactAmount,ActAmount,NonActAmount,WeChatInFactAmount,AliPayInFactAmount,OderCount");
  54. foreach (Dictionary<string, object> subdata in source)
  55. {
  56. Dictionary<string, object> curData = new Dictionary<string, object>();
  57. curData.Add("TradeDate", subdata["TradeDate"].ToString()); //日期
  58. curData.Add("TotalAmount", subdata["TradeAmount"].ToString()); //营业总金额
  59. curData.Add("InFactAmount", subdata["InFactAmount"].ToString()); //实收总金额
  60. curData.Add("ActAmount", subdata["ActAmount"].ToString()); //活动总金额
  61. curData.Add("NonActAmount", subdata["NonActAmount"].ToString()); //非活动总金额
  62. curData.Add("WeChatInFactAmount", subdata["WeChatInFactAmount"].ToString()); //微信实收
  63. curData.Add("AliPayInFactAmount", subdata["AliPayInFactAmount"].ToString()); //支付宝实收
  64. curData.Add("OrderCount", subdata["OderCount"].ToString()); //订单数
  65. dataList.Add(curData);
  66. }
  67. return dataList;
  68. }
  69. #endregion
  70. #region 经营详情列表
  71. /// <summary>
  72. /// 经营详情列表
  73. /// </summary>
  74. /// <param name="condition">查询条件</param>
  75. /// <param name="pageSize">条数</param>
  76. /// <param name="pageNum">页数</param>
  77. /// <returns></returns>
  78. public static List<Dictionary<string, object>> DayDetailList(string condition, int pageSize, int pageNum)
  79. {
  80. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  81. List<Dictionary<string, object>> source = new ConsumerOrdersService().List(new List<FieldItem>(), condition, pageNum, pageSize);
  82. foreach (Dictionary<string, object> subdata in source)
  83. {
  84. Dictionary<string, object> curData = new Dictionary<string, object>();
  85. curData.Add("Id", subdata["Id"].ToString()); //订单Id
  86. curData.Add("TradeDate", "支付时间" + " " + DateTime.Parse(subdata["CreateDate"].ToString()).ToString("HH:mm:ss")); //日期
  87. curData.Add("PayMode", subdata["PayMode"].ToString()); //支付方式(1 支付宝 2 微信)
  88. curData.Add("IsAct", subdata["IsAct"].ToString()); //是否活动(1 是 0 否)
  89. curData.Add("PayMoney", "+" + subdata["PayMoney"].ToString()); //订单金额
  90. dataList.Add(curData);
  91. }
  92. return dataList;
  93. }
  94. #endregion
  95. #region 交易详情
  96. /// <summary>
  97. /// 交易详情
  98. /// </summary>
  99. /// <param name="condition">查询条件</param>
  100. /// <returns></returns>
  101. public static Dictionary<string, object> OrderDetail(string condition)
  102. {
  103. Dictionary<string, object> obj = new Dictionary<string, object>();
  104. List<Dictionary<string, object>> source = new ConsumerOrdersService().List(new List<FieldItem>(), condition, 1, 999);
  105. foreach (Dictionary<string, object> subdata in source)
  106. {
  107. obj.Add("TradeDate", DateTime.Parse(subdata["CreateDate"].ToString()).ToString("yyyy-MM-dd HH:mm:ss")); //日期
  108. obj.Add("PayMode", subdata["PayMode"].ToString()); //支付方式(1 微信 2 支付宝)
  109. obj.Add("PayMoney", subdata["PayMoney"].ToString()); //是否活动(1 是 0 否)
  110. obj.Add("IsAct", subdata["IsAct"].ToString()); //是否活动(1 是 0 否)
  111. obj.Add("OrderNo", subdata["OrderNo"].ToString()); //订单号
  112. Dictionary<string, object> cdata = new Dictionary<string, object>();
  113. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  114. List<Dictionary<string, object>> dics = new ConsumerProfitService().List(new List<FieldItem>(), " and OrderId=" + int.Parse(subdata["Id"].ToString()) + "", 1, 999);
  115. foreach (Dictionary<string, object> dic in dics)
  116. {
  117. var CreateDate = DateTime.Parse(subdata["CreateDate"].ToString());
  118. var TradeDate = CreateDate.Month + "月" + CreateDate.Day + "日" + " " + CreateDate.ToString("HH:mm");
  119. cdata.Add("ProfitDate", TradeDate); //分红时间
  120. cdata.Add("ProfitAmount", "+" + dic["GetMoney"].ToString()); //分红金额
  121. dataList.Add(cdata);
  122. }
  123. obj.Add("ProfitTotalAmount", new ConsumerProfitService().Sum(" and OrderId=" + int.Parse(subdata["Id"].ToString()) + "", "GetMoney") + "(元)"); //分红总金额
  124. obj.Add("ProfitList", dataList); //订单分红记录列表
  125. }
  126. return obj;
  127. }
  128. #endregion
  129. }
  130. }