BusinessUtil.cs 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. if(!new MerchantTradeSummaryService().CheckTableExist(TradeMonth))
  25. {
  26. return dataList;
  27. }
  28. List<Dictionary<string, object>> source = new MerchantTradeSummaryService().List2(new List<FieldItem>(), " and MerchantId=" + MerchantId, TradeMonth, pageNum, pageSize, "TradeDate desc");
  29. // var infos = UserTradeDbconn.GetDateTradeList(MerchantId,TradeMonth);
  30. foreach (Dictionary<string, object> subdata in source)
  31. {
  32. Dictionary<string, object> curData = new Dictionary<string, object>();
  33. curData.Add("TradeDate", subdata["TradeDate"].ToString()); //日期
  34. curData.Add("TotalAmount", subdata["TradeAmount"].ToString()); //营业总金额
  35. curData.Add("InFactAmount", subdata["InFactAmount"].ToString()); //实收总金额
  36. curData.Add("ActAmount", subdata["ActAmount"].ToString()); //活动总金额
  37. curData.Add("NonActAmount", subdata["NonActAmount"].ToString()); //非活动总金额
  38. curData.Add("WeChatInFactAmount", subdata["WeChatInfactAmount"].ToString()); //微信实收
  39. curData.Add("AliPayInFactAmount", subdata["AliPayInFactAmount"].ToString()); //支付宝实收
  40. curData.Add("OrderCount", subdata["OderCount"].ToString()); //订单数
  41. curData.Add("Kind", 1); //通道(1 直连 2 银联)
  42. dataList.Add(curData);
  43. }
  44. return dataList;
  45. }
  46. #endregion
  47. #region 经营数据记录(半年)
  48. /// <summary>
  49. /// 经营数据记录(半年)
  50. /// </summary>
  51. /// <param name="MerchantId">商户Id</param>
  52. /// <param name="pageSize">条数</param>
  53. /// <param name="pageNum">页数</param>
  54. /// <returns></returns>
  55. public static List<Dictionary<string, object>> BussinessRecordForHalfYear(int MerchantId, int pageSize, int pageNum)
  56. {
  57. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  58. List<Dictionary<string, object>> source = UserTradeDbconn.Instance.GetMonthTradeList(MerchantId, "TradeAmount,InFactAmount,ActAmount,NonActAmount,WeChatInFactAmount,AliPayInFactAmount,OderCount");
  59. foreach (Dictionary<string, object> subdata in source)
  60. {
  61. Dictionary<string, object> curData = new Dictionary<string, object>();
  62. curData.Add("TradeDate", subdata["TradeDate"].ToString()); //日期
  63. curData.Add("TotalAmount", subdata["TradeAmount"].ToString()); //营业总金额
  64. curData.Add("InFactAmount", subdata["InFactAmount"].ToString()); //实收总金额
  65. curData.Add("ActAmount", subdata["ActAmount"].ToString()); //活动总金额
  66. curData.Add("NonActAmount", subdata["NonActAmount"].ToString()); //非活动总金额
  67. curData.Add("WeChatInFactAmount", subdata["WeChatInFactAmount"].ToString()); //微信实收
  68. curData.Add("AliPayInFactAmount", subdata["AliPayInFactAmount"].ToString()); //支付宝实收
  69. curData.Add("OrderCount", subdata["OderCount"].ToString()); //订单数
  70. dataList.Add(curData);
  71. }
  72. return dataList;
  73. }
  74. #endregion
  75. #region 经营详情列表
  76. /// <summary>
  77. /// 经营详情列表
  78. /// </summary>
  79. /// <param name="condition">查询条件</param>
  80. /// <param name="pageSize">条数</param>
  81. /// <param name="pageNum">页数</param>
  82. /// <returns></returns>
  83. public static List<Dictionary<string, object>> DayDetailList(string condition, int pageSize, int pageNum)
  84. {
  85. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  86. List<Dictionary<string, object>> source = new ConsumerOrdersService().List(new List<FieldItem>(), condition, pageNum, pageSize);
  87. foreach (Dictionary<string, object> subdata in source)
  88. {
  89. Dictionary<string, object> curData = new Dictionary<string, object>();
  90. curData.Add("Id", subdata["Id"].ToString()); //订单Id
  91. curData.Add("TradeDate", DateTime.Parse(subdata["CreateDate"].ToString()).ToString("HH:mm:ss")); //日期
  92. curData.Add("PayMode", subdata["PayMode"].ToString()); //支付方式(1 支付宝 2 微信)
  93. curData.Add("IsAct", subdata["IsAct"].ToString()); //是否活动(1 是 0 否)
  94. curData.Add("PayMoney", subdata["PayMoney"].ToString()); //订单金额
  95. curData.Add("Kind", 1); //通道(1 直连 2 银联)
  96. dataList.Add(curData);
  97. }
  98. return dataList;
  99. }
  100. #endregion
  101. #region 交易详情
  102. /// <summary>
  103. /// 交易详情
  104. /// </summary>
  105. /// <param name="condition">查询条件</param>
  106. /// <returns></returns>
  107. public static Dictionary<string, object> OrderDetail(string condition)
  108. {
  109. Dictionary<string, object> obj = new Dictionary<string, object>();
  110. List<Dictionary<string, object>> source = new ConsumerOrdersService().List(new List<FieldItem>(), condition, 1, 999);
  111. foreach (Dictionary<string, object> subdata in source)
  112. {
  113. var leaveAmount = decimal.Parse(subdata["MaxDivi"].ToString()) - decimal.Parse(subdata["CurDivi"].ToString());
  114. obj.Add("TradeDate", DateTime.Parse(subdata["CreateDate"].ToString()).ToString("yyyy-MM-dd HH:mm:ss")); //日期
  115. obj.Add("PayMode", subdata["PayMode"].ToString()); //支付方式(1 微信 2 支付宝)
  116. obj.Add("PayMoney", subdata["PayMoney"].ToString()); //是否活动(1 是 0 否)
  117. obj.Add("IsAct", subdata["IsAct"].ToString()); //是否活动(1 是 0 否)
  118. obj.Add("OrderNo", subdata["OrderNo"].ToString()); //订单号
  119. obj.Add("ReturnFlag", int.Parse(subdata["ReturnFlag"].ToString())); //返现标记(0 否 1 是)
  120. obj.Add("Kind", 1); //通道(1 直连 2 银联)
  121. obj.Add("LeaveAmount", leaveAmount); //剩余返现金额
  122. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  123. List<Dictionary<string, object>> dics = new ConsumerProfitService().List(new List<FieldItem>(), " and OrderId=" + int.Parse(subdata["Id"].ToString()) + "", 1, 999);
  124. foreach (Dictionary<string, object> dic in dics)
  125. {
  126. Dictionary<string, object> cdata = new Dictionary<string, object>();
  127. var CreateDate = DateTime.Parse(dic["CreateDate"].ToString());
  128. var TradeDate = CreateDate.Month + "月" + CreateDate.Day + "日" + " " + CreateDate.ToString("HH:mm");
  129. cdata.Add("ProfitDate", TradeDate); //分红时间
  130. cdata.Add("ProfitAmount", dic["GetMoney"].ToString()); //分红金额
  131. dataList.Add(cdata);
  132. }
  133. obj.Add("ProfitTotalAmount", new ConsumerProfitService().Sum("GetMoney", " and OrderId=" + int.Parse(subdata["Id"].ToString()) + "")["GetMoney"]); //分红总金额
  134. MerchantInfo merchant = new MerchantInfoService().Query(int.Parse(function.CheckInt(subdata["MerchantId"].ToString())));
  135. obj.Add("MerchantName", merchant.Name); //门店名称
  136. obj.Add("ProfitList", dataList); //订单分红记录列表
  137. }
  138. return obj;
  139. }
  140. #endregion
  141. }
  142. }