find(); if (!$pidUser) { return false; } $inData = [ 'user_id' => $pidUser['id'], 'child_id' => $user['id'], 'item_id' => $item_id, 'amount' => $amount, 'type' => $type, ]; $ret = Record::create($inData); if ($ret === false) { return false; } $userData = [ "available_commission_amount" => $pidUser['available_commission_amount'] + $amount, "updatetime" => time(), ]; if (in_array($type, [0,1])) { $userData['total_commission_amount'] = $pidUser['total_commission_amount'] + $amount; } $ret = User::where('id', $pidUser['id'])->update($userData); return $ret; } }