mobile_activity.php 739 B

123456789101112131415161718192021222324
  1. <?php
  2. use app\common\model\Mobile;
  3. use Workerman\Lib\Timer;
  4. use Workerman\Worker as WO;
  5. class MobileActivity extends Com{
  6. public static function run(){
  7. $work=self::newWorker();
  8. $work->onWorkerStart=function (WO $worker){
  9. Timer::add(3,function (){
  10. $ids=Mobile::where('activity_time_end','<=',time())
  11. ->where('is_activity',1)
  12. ->where('type',1)
  13. ->column('id');
  14. self::log("找到".count($ids).'条记录');
  15. foreach ($ids as $id){
  16. $mobile=Mobile::find($id);
  17. $mobile->makeNotActivity();
  18. }
  19. });
  20. };
  21. }
  22. }
  23. //MobileActivity::run();