stat_helper.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: stanley-king
  5. * Date: 2017/5/25
  6. * Time: 上午9:30
  7. */
  8. require_once (BASE_ROOT_PATH . '/helper/statistics/stat_base.php');
  9. require_once (BASE_ROOT_PATH . '/helper/statistics/stbonus.php');
  10. require_once (BASE_ROOT_PATH . '/helper/statistics/stmember.php');
  11. require_once (BASE_ROOT_PATH . '/helper/statistics/statorder.php');
  12. require_once (BASE_ROOT_PATH . '/helper/statistics/statcall.php');
  13. class stat_helper
  14. {
  15. const cur_date_type = 1;
  16. const last_week_type = 2;
  17. const last_hmonth_type = 3;
  18. const last_month_type = 4;
  19. //['time' => time(),'use_type' => $this->mUsedType,'rate' => $rate,'amount' => $used / 100,'member_id' => $this->member_id]
  20. public static function onUseBonus($param)
  21. {
  22. if(empty($param) || is_array($param) == false) {
  23. return false;
  24. }
  25. try
  26. {
  27. $time = intval($param['time']);
  28. $stat = new statistics\stbonus($time);
  29. $use_type = intval($param['use_type']);
  30. $rate = intval($param['rate']);
  31. $amount = $param['amount'];
  32. if($use_type == bonus_helper::pay_order_withold) {
  33. $stat->add_paied($rate,$amount);
  34. }
  35. elseif (($use_type == bonus_helper::send_bonus_withold)) {
  36. $stat->add_send($rate,$amount);
  37. }
  38. }
  39. catch (Exception $ex) {
  40. Log::record($ex->getMessage(),Log::ERR);
  41. }
  42. return true;
  43. }
  44. public static function onDaiyBonus($time)
  45. {
  46. try
  47. {
  48. $stat = new statistics\stbonus($time);
  49. $stat->daily();
  50. }
  51. catch(Exception $ex)
  52. {
  53. Log::record($ex->getMessage(),Log::ERR);
  54. }
  55. }
  56. public static function onInitSelfDiscount()
  57. {
  58. try
  59. {
  60. $stat = new statistics\stbonus(time());
  61. $stat->init_discount_self();
  62. }
  63. catch(Exception $ex)
  64. {
  65. Log::record($ex->getMessage(),Log::ERR);
  66. }
  67. }
  68. public static function onInitInviteesDiscount()
  69. {
  70. try
  71. {
  72. $stat = new statistics\stbonus(time());
  73. $stat->init_discount_invitee();
  74. }
  75. catch(Exception $ex)
  76. {
  77. Log::record($ex->getMessage(),Log::ERR);
  78. }
  79. }
  80. public static function onDailySelfDiscount($time)
  81. {
  82. try
  83. {
  84. $stat = new statistics\stbonus($time);
  85. $stat->discount_self();
  86. }
  87. catch(Exception $ex)
  88. {
  89. Log::record($ex->getMessage(),Log::ERR);
  90. }
  91. }
  92. public static function onDailyInviteeDiscount($time)
  93. {
  94. try
  95. {
  96. $stat = new statistics\stbonus($time);
  97. $stat->discount_invitee();
  98. }
  99. catch(Exception $ex)
  100. {
  101. Log::record($ex->getMessage(),Log::ERR);
  102. }
  103. }
  104. public static function onInvite()
  105. {
  106. try
  107. {
  108. $stat = new statistics\stmember(time());
  109. $stat->onInvite();
  110. }
  111. catch(Exception $ex)
  112. {
  113. Log::record($ex->getMessage(),Log::ERR);
  114. }
  115. }
  116. public static function onDaiyMember($time)
  117. {
  118. try
  119. {
  120. $stat = new statistics\stmember($time);
  121. $stat->daily();
  122. }
  123. catch(Exception $ex)
  124. {
  125. Log::record($ex->getMessage(),Log::ERR);
  126. }
  127. }
  128. public static function onDaiyOrder($time)
  129. {
  130. try
  131. {
  132. $stat = new statistics\statorder($time);
  133. $stat->daily();
  134. }
  135. catch(Exception $ex)
  136. {
  137. Log::record($ex->getMessage(),Log::ERR);
  138. }
  139. }
  140. }