MerchantAmountSummayUtil.cs 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using MySystem.Models.Main;
  2. using Library;
  3. using MySystem.Service.Main;
  4. using System.Collections.Generic;
  5. using System;
  6. namespace MySystem
  7. {
  8. /// <summary>
  9. /// 商户业绩统计工具类
  10. /// </summary>
  11. public class MerchantAmountSummayUtil
  12. {
  13. #region 已激活商户-达标信息列表
  14. /// <summary>
  15. /// 已激活商户-达标信息列表
  16. /// </summary>
  17. /// <param name="MerchantId">商户Id</param>
  18. /// <param name="PageSize">条数</param>
  19. /// <param name="PageNum">页数</param>
  20. /// <returns></returns>
  21. public static List<Dictionary<string, object>> ListDo(int MerchantId, int PageSize, int PageNum)
  22. {
  23. List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
  24. var query = MerchantDepositOrderService.Query(" and Status=1 and MerchantId=" + MerchantId + "");
  25. var Status = 0;//活动交易状态
  26. var IsJoin = 0;//是否参加活动(0 否 1 是)
  27. if (query.Id == 0) IsJoin = 1;
  28. var month = DateTime.Parse(query.CreateDate.ToString());
  29. var TradeMonth = "";
  30. decimal TradeAmount = 0.00M;
  31. Dictionary<string, string> dic = new Dictionary<string, string>();
  32. for (int i = 0; i < 10; i++)
  33. {
  34. month = month.AddMonths(i + 1);
  35. TradeMonth = month.ToString("yyyy-MM");
  36. var check = MerchantAmountSummayService.Query(" and IsAct=1 and TradeMonth='" + TradeMonth + "' and MerchantId=" + MerchantId + "");
  37. if (check.Id > 0)
  38. {
  39. dic = MerchantAmountSummayService.Sum("TradeAmount", " and IsAct=1 and TradeMonth='" + TradeMonth + "'");
  40. TradeAmount = decimal.Parse(dic["TradeAmount"].ToString());
  41. }
  42. if (IsJoin == 0)
  43. {
  44. //未参与
  45. Status = 3;
  46. }
  47. else
  48. {
  49. //考核中
  50. if (DateTime.Now.ToString("yyyy-MM") == TradeMonth) Status = 1;
  51. //待考核
  52. if (int.Parse(DateTime.Now.ToString("yyyyMM")) < int.Parse(month.ToString("yyyyMM"))) Status = 0;
  53. //已通过
  54. if (TradeAmount >= 10000 && IsJoin != 3 && check.Id > 0) Status = 2;
  55. //未通过
  56. if (TradeAmount < 10000 && IsJoin != 3 && check.Id > 0) Status = -1;
  57. Dictionary<string, object> curData = new Dictionary<string, object>();
  58. curData.Add("TradeMonth", TradeMonth); //月份
  59. curData.Add("TradeAmount", TradeAmount); //订单金额
  60. curData.Add("Status", Status); //状态(-1 未通过 0 待考核 1 考核中 2 已通过 3 未参与)
  61. dataList.Add(curData);
  62. }
  63. }
  64. return dataList;
  65. }
  66. #endregion
  67. }
  68. }