allocatr/application/common/command/UpdateWorkerManCommand.php
2025-04-17 17:30:29 +08:00

36 lines
831 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)->avg('worker_star');
if($avg){
$worker->star = $avg;
$worker->save();
}
}
}
}