user = $user; //用户模型 $this->profit = $profit; //分红记录模型 $this->eachCash = $eachCash; //每一份金额 $this->identity = $identity; //参与分红身份ID } public function handle() { if ($this->eachCash <= 0) { return false; } $selfPoint = $this->user->pointlogs() ->where('identity_id', $this->identity) ->where('created_at', '<', $this->profit->end_at) ->sum('point'); $cash = round($this->eachCash * $selfPoint, 2); if ($cash > 0) { $this->user->rule('profit' . $this->identity, $cash, false, [date('Y-m-d', strtotime($this->profit->end_at))]); } } }