where('status','normal')->select(); foreach ($list as $key => $value) { $amount = Db::name('transaction_record')->where('type',2)->where('user_id', $value['id'])->sum('amount'); $ret = Db::name('user')->where('id', $value['id'])->update(['profit_amount' => $amount]); var_dump($ret); } $this->success('请求成功'); } }