v.2.24
1. POSTBonus in/out 2. POSTPresale in/out 3. Переработана форма гостя
This commit is contained in:
60
models/ClientsBonus.php
Normal file
60
models/ClientsBonus.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ClientsBonus extends Model
|
||||
{
|
||||
protected $table = 'clients_bonuses';
|
||||
protected $guarded = [];
|
||||
|
||||
/**
|
||||
* Bonus info.
|
||||
*/
|
||||
public static function getBonus($guid)
|
||||
{
|
||||
$bonus = ClientsBonus::where('client_guid', $guid)->first();
|
||||
if (isset($bonus)) {
|
||||
$bonus = $bonus['value'];
|
||||
} else {
|
||||
$bonus = 0;
|
||||
}
|
||||
return $bonus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save bonus value.
|
||||
*/
|
||||
public static function bonusReg($guid, $value)
|
||||
{
|
||||
$bonus_value = ClientsBonus::where('client_guid', $guid)->first();
|
||||
$bonus = ClientsBonus::updateOrCreate(
|
||||
['client_guid' => $guid],
|
||||
['value' => $bonus_value['value'] + $value]
|
||||
);
|
||||
|
||||
return $bonus['value'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Bonus log.
|
||||
*/
|
||||
public static function bonusLog($guid, $value, $time, $staff_id)
|
||||
{
|
||||
if ($value > 0) {
|
||||
$action_name = 'Зачиление бонусов';
|
||||
} else {
|
||||
$action_name = 'Списание бонусов';
|
||||
}
|
||||
$action = new ClientsActions();
|
||||
$action->action = $action_name;
|
||||
$action->created = Carbon::createFromTimestampUTC($time)->timezone('Europe/Minsk');
|
||||
$action->user_id = $guid;
|
||||
$action->action_value = abs($value);
|
||||
$action->action_type = 1;
|
||||
$action->who = $staff_id;
|
||||
$action->save();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user