stat_helper.php 4.0 KB

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