Test.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace app\api\command;
  3. use app\common\logic\ScanLogic;
  4. use think\console\Command;
  5. use think\console\Input;
  6. use think\console\Output;
  7. use app\common\model\ProductOrder;
  8. use app\common\model\UserModel;
  9. use think\Model;
  10. class Test extends Command
  11. {
  12. protected function configure()
  13. {
  14. $this->setName('test')->setDescription('Here is the remark ');
  15. }
  16. protected function execute(Input $input, Output $output)
  17. {
  18. /* 永不超时 */
  19. // ini_set('max_execution_time', 0);
  20. // 记录开始运行的时间
  21. $GLOBALS['_beginTime'] = microtime(TRUE);
  22. $output->writeln('定时任务开始执行:' . date('Y-m-d H:i:s', time()));
  23. /*** 发放分红收益 ***/
  24. $begin_usdt = microtime(TRUE);
  25. $output->writeln("开始发放加权分红:");
  26. $count = $this->reset_user_pledge();
  27. $output->writeln('定时任务执行结束,总执行:' . $count . '个');
  28. }
  29. public static function reset_user_pledge(){
  30. $productOrder = new ProductOrder(); //Loader::model('ProductOrder');
  31. $count = 0;
  32. $num = 6;
  33. $ids = 14;
  34. UserModel::chunk(500, function($items) use ($count,$num , $ids, $productOrder) {
  35. foreach ($items as $item) {
  36. // 处理每个数据项
  37. $productOrder::setPopularNoAreaOrder($num, 0, 0, $ids, $item->id, 5);
  38. $count ++;
  39. }
  40. });
  41. return $count;
  42. }
  43. }