stat_helper.php 4.1 KB

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