stanley-king 7 vuotta sitten
vanhempi
commit
225d77a844

+ 2 - 3
crontab/control/command.php

@@ -107,9 +107,8 @@ class commandControl extends BaseCronControl
         }
     }
 
-    public function order_allOp()
+    public function order_pushOp()
     {
-        $pay_sn = '310564081999751324';
-        account_helper::onAsyncTask($pay_sn);
+        QueueClient::push('onAsyncBroadcastOrder',['pay_sn' => '860564087314530577','amount' => 1,'days' => 30]);
     }
 }

+ 11 - 0
data/logic/queue.logic.php

@@ -691,6 +691,17 @@ class queueLogic
         return callback(true);
     }
 
+    public function onAsyncBroadcastOrder($param)
+    {
+        $pay_sn = $param['pay_sn'];
+        $amount = $param['amount'];
+        $days   = $param['days'];
+        if(!empty($pay_sn) && !empty($amount)) {
+            account_helper::onAsyncBroadcastOrder($pay_sn,$amount,$days);
+        }
+        return callback(true);
+    }
+
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     public function onAsyncUgcPublish($param)
     {

+ 4 - 4
helper/account_helper.php

@@ -25,7 +25,7 @@ require_once(BASE_ROOT_PATH . '/helper/async/status.php');
 require_once(BASE_ROOT_PATH . '/helper/async/register.php');
 require_once(BASE_ROOT_PATH . '/helper/async/order.php');
 require_once(BASE_ROOT_PATH . '/helper/async/qugc.php');
-require_once(BASE_ROOT_PATH . '/helper/async/task.php');
+require_once(BASE_ROOT_PATH . '/helper/async/broadcast.php');
 
 require_once(BASE_ROOT_PATH . '/helper/order_helper.php');
 require_once(BASE_ROOT_PATH . '/helper/fcode/present_manager.php');
@@ -401,12 +401,12 @@ class account_helper
         }
     }
 
-    public static function onAsyncTask($pay_sn)
+    public static function onAsyncBroadcastOrder($pay_sn,$amount,$days)
     {
         try
         {
-            $iPusher = new async\task($pay_sn);
-            $iPusher->run();
+            $iPusher = new async\broadcast($pay_sn);
+            $iPusher->order_bonus($amount,$days);
         } catch (Exception $ex) {
             Log::record($ex->getMessage(),Log::ERR);
         }

+ 10 - 4
helper/async/task.php

@@ -15,8 +15,9 @@ use Exception;
 use bonus;
 use bonus_helper;
 use Log;
+use util;
 
-class task extends IAsync
+class broadcast extends IAsync
 {
     private $simple_order;
     private $user_info;
@@ -32,15 +33,20 @@ class task extends IAsync
         $user = $this->simple_order->user();
         $this->user_info = new member_info($user);
     }
-
     public function run()
     {
+    }
+
+    public function order_bonus($amount,$days = 30)
+    {
         $mod_member = Model('member');
+        $days = intval($days);
+        $cond['member_time'] = ['gt',util::first_day_secs(time() - $days * 86400)];
         $i = 0;
         while (true)
         {
             $start = $i * 1000;
-            $items = $mod_member->field('member_id')->order('member_id asc')->limit("{$start},1000")->select();
+            $items = $mod_member->field('member_id')->where($cond)->order('member_id asc')->limit("{$start},1000")->select();
             if(empty($items)) {
                 return;
             }
@@ -55,7 +61,7 @@ class task extends IAsync
             }
 
             $num = count($uids);
-            $amount = 1;
+
             $params = bonus\parameters::order_complete_all($this->user_info->nickname(),$num,$amount);
             foreach ($params as $param)
             {

+ 4 - 0
helper/util_helper.php

@@ -172,6 +172,10 @@ class util
         $base64 = base64_decode($base64url);
         return $base64;
     }
+    public static function first_day_secs($input)
+    {
+        return strtotime(date('Y-m-d',$input));
+    }
     public static function last_day_secs($input)
     {
         return strtotime(date('Y-m-d',$input)) + 86399;

+ 1 - 1
test/TestAccount_helper.php

@@ -84,7 +84,7 @@ class testAccounthelper extends PHPUnit_Framework_TestCase
 
     public function testTask()
     {
-        account_helper::onAsyncTask('290563492188164623');
+        account_helper::onAsyncBroadcastOrder('290563492188164623',0.1,30);
     }
 
     public static function tearDownAfterClass()