| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- namespace app\api\command;
- use app\common\logic\ScanLogic;
- use think\console\Command;
- use think\console\Input;
- use think\console\Output;
- use app\common\model\ProductOrder;
- use app\common\model\UserModel;
- use think\Model;
- class Task extends Command
- {
- protected function configure()
- {
- $this->setName('task')->setDescription('Here is the remark ');
- }
- protected function execute(Input $input, Output $output)
- {
- /* 永不超时 */
- // ini_set('max_execution_time', 0);
- // 记录开始运行的时间
- $GLOBALS['_beginTime'] = microtime(TRUE);
- $output->writeln('定时任务开始执行:' . date('Y-m-d H:i:s', time()));
- /*** 发放分红收益 ***/
- $begin_usdt = microtime(TRUE);
- $output->writeln("开始发放加权分红:");
- $count = $this->reset_user_pledge();
- $output->writeln('定时任务执行结束,总执行:' . $count . '个');
- }
- public static function reset_user_pledge(){
- $productOrder = new ProductOrder(); //Loader::model('ProductOrder');
- $count = 0;
- $num = 6;
- $ids = 14;
- UserModel::chunk(500, function($items) use ($count,$num , $ids, $productOrder) {
- foreach ($items as $item) {
- // 处理每个数据项
- $productOrder::setPopularNoAreaOrder($num, 0, 0, $ids, $item->id, 5);
- $count ++;
- }
- });
-
- return $count;
- }
- }
|