option('sn'); if (!$sn) { $time = $now->copy()->subQuarter(); $sn = $time->year . '-' . $time->quarter; } $list = []; UserRankModel::where('sn', $sn)->delete(); $userList = PartyUser::get(); foreach ($userList as $item) { $list[] = [ 'sn' => $sn, 'cate_id' => $item->cate_id, 'user_id' => $item->id, 'score' => $item->current_score, 'created_at' => $now, 'updated_at' => $now, ]; } UserRankModel::insert($list); // 清空党员当前得分 PartyUser::where('current_score', '>', 0)->update([ 'current_score' => 0 ]); } }