37 lines
882 B
PHP
37 lines
882 B
PHP
<?php
|
|
|
|
namespace app\common\command;
|
|
|
|
use app\admin\model\order\Review;
|
|
use app\admin\model\OrderDispatch;
|
|
use app\admin\model\OrderDispatchRecord;
|
|
|
|
use app\admin\model\Worker;
|
|
use think\console\Command;
|
|
use think\console\Input;
|
|
use think\console\Output;
|
|
|
|
class UpdateWorkerManCommand extends Command
|
|
{
|
|
protected function configure()
|
|
{
|
|
$this->setName('update-worker-man-info')
|
|
->setDescription('更新师傅信息(评分),每天一次');
|
|
}
|
|
|
|
protected function execute(Input $input, Output $output)
|
|
{
|
|
$workers = Worker::all();
|
|
foreach ($workers as $worker)
|
|
{
|
|
$avg = Review::where('worker_id',$worker->id)->where('is_star',1)->avg('worker_star');
|
|
if($avg){
|
|
$worker->star = $avg;
|
|
$worker->save();
|
|
}
|
|
}
|
|
$output->info('OVER');
|
|
}
|
|
|
|
|
|
} |