stat_helper.php 4.4 KB

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