stat_helper.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. class stat_helper
  13. {
  14. const cur_date_type = 1;
  15. const last_week_type = 2;
  16. const last_hmonth_type = 3;
  17. const last_month_type = 4;
  18. //['time' => time(),'use_type' => $this->mUsedType,'rate' => $rate,'amount' => $used / 100,'member_id' => $this->member_id]
  19. public static function onUseBonus($param)
  20. {
  21. if(empty($param) || is_array($param) == false) {
  22. return false;
  23. }
  24. try
  25. {
  26. $time = intval($param['time']);
  27. $stat = new statistics\stbonus($time);
  28. $use_type = intval($param['use_type']);
  29. $rate = intval($param['rate']);
  30. $amount = $param['amount'];
  31. if($use_type == bonus_helper::pay_order_withold) {
  32. $stat->add_paied($rate,$amount);
  33. }
  34. elseif (($use_type == bonus_helper::send_bonus_withold)) {
  35. $stat->add_send($rate,$amount);
  36. }
  37. }
  38. catch (Exception $ex) {
  39. Log::record($ex->getMessage(),Log::ERR);
  40. }
  41. return true;
  42. }
  43. public static function onDaiyBonus($time)
  44. {
  45. try
  46. {
  47. $stat = new statistics\stbonus($time);
  48. $stat->daily();
  49. }
  50. catch(Exception $ex)
  51. {
  52. Log::record($ex->getMessage(),Log::ERR);
  53. }
  54. }
  55. public static function onInvite()
  56. {
  57. try
  58. {
  59. $stat = new statistics\stmember(time());
  60. $stat->onInvite();
  61. }
  62. catch(Exception $ex)
  63. {
  64. Log::record($ex->getMessage(),Log::ERR);
  65. }
  66. }
  67. public static function onDaiyMember($time)
  68. {
  69. try
  70. {
  71. $stat = new statistics\stmember($time);
  72. $stat->daily();
  73. }
  74. catch(Exception $ex)
  75. {
  76. Log::record($ex->getMessage(),Log::ERR);
  77. }
  78. }
  79. public static function onDaiyOrder($time)
  80. {
  81. try
  82. {
  83. $stat = new statistics\statorder($time);
  84. $stat->daily();
  85. }
  86. catch(Exception $ex)
  87. {
  88. Log::record($ex->getMessage(),Log::ERR);
  89. }
  90. }
  91. }