Files
admin-php-module/commands/POSTBonus.php
miroman-afk 723e9a8768 v.2.25
Small fix
2022-12-22 12:52:42 +03:00

35 lines
1.1 KiB
PHP

<?php
namespace App\Commands;
use App\Component\Models\ClientsBonus;
use App\Console\Commands\HRCCommand;
use App\Console\Commands\HRCCommandInterface;
use Illuminate\Support\Facades\Log;
class POSTBonus extends HRCCommand implements HRCCommandInterface
{
protected $signature = 'postbonus';
public function command($input, $output = null)
{
$client_guid = $input['client_id'];
$bonus_amount = abs($input['amount']);
$staff_id = $input['who'];
$bonus_time = $input['date_transaction'];
$type = $input['type'];
ClientsBonus::bonusReg($client_guid, $bonus_amount, $type);
ClientsBonus::bonusLog($client_guid, $bonus_amount, $bonus_time, $staff_id);
if ($type == 'in') {
$message = 'Начислено ' . $bonus_amount . ' бонусов';
} elseif ($type == 'out') {
$message = 'Списано ' . $bonus_amount . ' бонусов';
}
$bonus_result = ClientsBonus::getBonus($client_guid);
return [
'status' => 'success',
'message' => $message,
'result' => $bonus_result
];
}
}