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

37 lines
1.3 KiB
PHP

<?php
namespace App\Commands;
use App\Component\Models\Client;
use App\Component\Models\ClientsPresale;
use App\Console\Commands\HRCCommand;
use App\Console\Commands\HRCCommandInterface;
use Carbon\Carbon;
class POSTPresale extends HRCCommand implements HRCCommandInterface
{
protected $signature = 'postpresale';
public function command($input, $output = null)
{
$client_guid = $input['client_guid'];
$presale_amount = abs($input['amount']);
$staff_id = $input['who_id'];
$presale_time = $input['date_transaction'];
$type = $input['type'];
$action_type = intval($input['action_type']);
$code_order = intval($input['code_order']);
ClientsPresale::presaleReg($client_guid, $presale_amount, $type);
$message = ClientsPresale::presaleLog($client_guid, $presale_amount, $presale_time, $staff_id, $action_type, $code_order);
$client = Client::where('user_code', $client_guid)->first();
$client = Client::find($client['id']);
$client->updated_at = Carbon::createFromTimestampUTC($presale_time)->timezone('Europe/Minsk');
$client->save();
$presale_result = ClientsPresale::getPresale($client_guid);
return [
'status' => 'success',
'message' => $message,
'result' => $presale_result
];
}
}