stanley-king 7 anos atrás
pai
commit
c60178b88d

+ 7 - 2
crontab/control/date.php

@@ -106,9 +106,14 @@ class dateControl extends BaseCronControl
         $this->_arrival_notice();
     }
 
-    public function t23_50_clockOp()
+    public function one_clockOp()
     {
-        bonus_helper::onDaiyMember(time());
+        $cur_date = new DateTime();
+        $inter = new DateInterval('P1D');
+        $cur_date->sub($inter);
+        stat_helper::onDaiyMember($cur_date->getTimestamp());
+        stat_helper::onDaiyBonus($cur_date->getTimestamp());
+        stat_helper::onDaiyOrder($cur_date->getTimestamp());
     }
 
     /**

+ 16 - 2
helper/stat_helper.php

@@ -9,6 +9,7 @@
 require_once (BASE_ROOT_PATH . '/helper/statistics/stat_base.php');
 require_once (BASE_ROOT_PATH . '/helper/statistics/stbonus.php');
 require_once (BASE_ROOT_PATH . '/helper/statistics/stmember.php');
+require_once (BASE_ROOT_PATH . '/helper/statistics/statorder.php');
 
 class stat_helper
 {
@@ -44,11 +45,11 @@ class stat_helper
 
         return true;
     }
-    public static function bonus_other()
+    public static function onDaiyBonus($time)
     {
         try
         {
-            $stat = new statistics\stbonus(time());
+            $stat = new statistics\stbonus($time);
             $stat->daily();
         }
         catch(Exception $ex)
@@ -80,4 +81,17 @@ class stat_helper
             Log::record($ex->getMessage(),Log::DEBUG);
         }
     }
+    public static function onDaiyOrder($time)
+    {
+        try
+        {
+            $stat = new statistics\statorder($time);
+            $stat->daily();
+        }
+        catch(Exception $ex)
+        {
+            Log::record($ex->getMessage(),Log::DEBUG);
+        }
+    }
+
 }

+ 1 - 1
helper/statistics/stat_order.php

@@ -10,7 +10,7 @@ namespace statistics;
 
 use Log;
 
-class stat_order extends stat_base
+class statorder extends stat_base
 {
     public function __construct($stime)
     {

+ 5 - 0
helper/statistics/stbonus.php

@@ -93,6 +93,8 @@ class stbonus extends stat_base
     */
     private function all_send_bonus($mbonus_type)
     {
+        $this->calc_time(self::cur_date_type);
+
         $cond['send_start_date'] = array('between',array($this->mStartm,$this->mEndtm));
         $field = 'bonus_rate,
         sum(total_amount) as all_total_amount,
@@ -154,6 +156,7 @@ class stbonus extends stat_base
     */
     private function avaliable_bonus($muser_bonus)
     {
+        $this->calc_time(self::cur_date_type);
         $field = 'bonus_rate,sum(remain_amount) as total_amount,count(*) as bonus_count';
         $cond = ['bonus_status' => 3, 'usable_time' => ['gt', $this->mStartm]];
         $items = $muser_bonus->field($field)->where($cond)->group('bonus_rate')->select();
@@ -193,6 +196,8 @@ class stbonus extends stat_base
     */
     private function admin_send_bonus($mbonus_type)
     {
+        $this->calc_time(self::cur_date_type);
+
         $cond['send_start_date'] = array('between',array($this->mStartm,$this->mEndtm));
         $cond['sender_id'] = self::admin_member_id;
         $field = 'bonus_rate,

+ 4 - 0
test/TestStat.php

@@ -26,6 +26,10 @@ class TestStat extends PHPUnit_Framework_TestCase
     {
         $cur_date = new DateTime();
         $cur_date->setDate(2016,8,20);
+        $inter = new DateInterval('P1D');
+        $cur_date->sub($inter);
         stat_helper::onDaiyMember($cur_date->getTimestamp());
+        stat_helper::onDaiyBonus($cur_date->getTimestamp());
+        stat_helper::onDaiyOrder($cur_date->getTimestamp());
     }
 }