stat_helper.php 4.3 KB

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