| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?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 Test extends Command
- {
- protected function configure()
- {
- $this->setName('test')->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("开始发放加权分红:");
- $this->reset_user_pledge();
- $time_total = round(microtime(true) - $GLOBALS['_beginTime'], 4);//计算耗时
- $output->writeln('定时任务执行结束,总耗时' . date('Y-m-d H:i:s', time()) . '; 耗时:' . $time_total . '秒');
- }
- public static function reset_user_pledge(){
- $productOrder = new ProductOrder(); //Loader::model('ProductOrder');
- $count = 0;
- UserModel::chunk(500, function($items) use ($count, $productOrder) {
- foreach ($items as $item) {
- // 处理每个数据项
- $productOrder::setPopularNoAreaOrder(6, 0, 0, 14, $item->id, 5);
- $count ++;
- }
- });
- dump("总计:".$count);
- }
- }
|