Files
admin-php-module/commands/POSTBonus.php
miroman-afk fb46c8e739 v.2.27
Fixed reports
2023-05-02 15:21:54 +03:00

41 lines
1.4 KiB
PHP

<?php
namespace App\Commands;
use App\Component\Models\Client;
use App\Component\Models\ClientsBonus;
use App\Console\Commands\HRCCommand;
use App\Console\Commands\HRCCommandInterface;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
class POSTBonus extends HRCCommand implements HRCCommandInterface
{
protected $signature = 'postbonus';
public function command($input, $output = null)
{
$client_guid = $input['client_guid'];
$bonus_amount = abs($input['amount']);
$staff_id = $input['who_id'];
$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);
$client = Client::where('user_code', $client_guid)->first();
$client = Client::find($client['id']);
$client->updated_at = Carbon::createFromTimestampUTC($bonus_time)->timezone('Europe/Minsk');
$client->save();
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
];
}
}