v.2.24
1. POSTBonus in/out 2. POSTPresale in/out 3. Переработана форма гостя
This commit is contained in:
@@ -13,4 +13,55 @@ class Client extends Model {
|
||||
public function clientPhone() {
|
||||
return $this->belongsTo('App\Component\Models\ClientsPhone', 'user_code', 'client_guid');
|
||||
}
|
||||
|
||||
public static function getPhone($guid) {
|
||||
$phone = ClientsPhone::where('client_guid', $guid)->first();
|
||||
if (isset($phone)) {
|
||||
$phone = $phone['phone'];
|
||||
} else {
|
||||
$phone = '';
|
||||
}
|
||||
return $phone;
|
||||
}
|
||||
|
||||
public static function getEmail($guid) {
|
||||
$email = ClientsEmail::where('client_guid', $guid)->first();
|
||||
if (isset($email)) {
|
||||
$email = $email['email'];
|
||||
} else {
|
||||
$email = '';
|
||||
}
|
||||
return $email;
|
||||
}
|
||||
|
||||
public static function getAddress($guid) {
|
||||
$address = ClientsAddress::where('client_guid', $guid)->first();
|
||||
if (isset($address)) {
|
||||
$address = $address['address'];
|
||||
} else {
|
||||
$address = '';
|
||||
}
|
||||
return $address;
|
||||
}
|
||||
|
||||
public static function getBarcode($guid) {
|
||||
$barcode = ClientsBarcode::where('client_guid', $guid)->first();
|
||||
if (isset($barcode)) {
|
||||
$barcode = $barcode['value'];
|
||||
} else {
|
||||
$barcode = '';
|
||||
}
|
||||
return $barcode;
|
||||
}
|
||||
|
||||
public static function getID($guid) {
|
||||
$id = Client::where('client_guid', $guid)->first();
|
||||
if (isset($id)) {
|
||||
$id = $id['id'];
|
||||
} else {
|
||||
$id = '';
|
||||
}
|
||||
return $id;
|
||||
}
|
||||
|
||||
}
|
||||
11
models/ClientsActions.php
Normal file
11
models/ClientsActions.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ClientsActions extends Model
|
||||
{
|
||||
protected $table = 'clients_actions';
|
||||
protected $guarded = [];
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
60
models/ClientsPresale.php
Normal file
60
models/ClientsPresale.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ClientsPresale extends Model
|
||||
{
|
||||
protected $table = 'clients_presales';
|
||||
protected $guarded = [];
|
||||
|
||||
/**
|
||||
* Presale info.
|
||||
*/
|
||||
public static function getPresale($guid)
|
||||
{
|
||||
$presale = ClientsPresale::where('client_guid', $guid)->first();
|
||||
if (isset($presale)) {
|
||||
$presale = $presale['value'];
|
||||
} else {
|
||||
$presale = 0;
|
||||
}
|
||||
return $presale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save presale value.
|
||||
*/
|
||||
public static function presaleReg($guid, $value)
|
||||
{
|
||||
$presale_value = ClientsPresale::where('client_guid', $guid)->first();
|
||||
$presale = ClientsPresale::updateOrCreate(
|
||||
['client_guid' => $guid],
|
||||
['value' => $presale_value['value'] + $value]
|
||||
);
|
||||
|
||||
return $presale['value'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Presale log.
|
||||
*/
|
||||
public static function presaleLog($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 = 2;
|
||||
$action->who = $staff_id;
|
||||
$action->save();
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,78 @@ namespace App\Component\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ExchangeOrders extends Model {
|
||||
protected $table = 'exchange_orders';
|
||||
class ExchangeOrders extends Model
|
||||
{
|
||||
protected $table = 'exchange_orders';
|
||||
|
||||
/**
|
||||
* Get order info
|
||||
*/
|
||||
public static function getInfo($order_id, $shift_id)
|
||||
{
|
||||
$order = ExchangeOrders::where('code', $order_id)->where('shift_id', $shift_id)->first();
|
||||
$open_time = $order['opened'];
|
||||
$close_time = $order['closed'];
|
||||
$who_open = Staff::getName($order['who_open']);
|
||||
$who_close = Staff::getName($order['who_close']);
|
||||
$items = ExchangeItems::where('order_code', $order_id)->where('shift_id', $shift_id)->get();
|
||||
$order_status = '';
|
||||
if ($order['is_deleted'] > 0) {
|
||||
$order_status = 'Удален';
|
||||
} elseif ($order['is_returned'] > 0) {
|
||||
$order_status = 'Возвращен';
|
||||
} elseif ($order['is_waited'] > 0 && $order['is_closed'] < 1) {
|
||||
$order_status = 'В ожидании';
|
||||
} else {
|
||||
$order_status = 'Оплачен';
|
||||
}
|
||||
$order_cash = $order['cash'];
|
||||
$order_credit = $order['credit'];
|
||||
$order_clearing = $order['clearing'];
|
||||
$order_presale = $order['presale'];
|
||||
$order_self = $order['self'];
|
||||
$order_info = [];
|
||||
$amount = $full_price = 0;
|
||||
foreach ($items as $key => $item) {
|
||||
$realPrice = $item['real_price'] * $item['count'] * $item['cof'];
|
||||
$salePrice = $item['sale_price'] * $item['count'];
|
||||
if ($realPrice > 0) {
|
||||
$discount = $salePrice / $realPrice;
|
||||
$discount = (1 - $discount) * 100;
|
||||
} else {
|
||||
$discount = 0;
|
||||
}
|
||||
$order_info[] = array(
|
||||
'id' => $key + 1,
|
||||
'name' => Dishes::getName($item['dish_code']),
|
||||
'count' => $item['count'],
|
||||
'price' => $item['real_price'],
|
||||
'sale_price' => $item['sale_price'],
|
||||
'cof' => $item['cof'],
|
||||
'unit' => Units::getName($item['units_id']),
|
||||
'amount' => round($item['sale_price'] * $item['count'], 2),
|
||||
'discount' => round($discount, 2)
|
||||
);
|
||||
$amount += round($item['sale_price'] * $item['count'], 2);
|
||||
$full_price += round($realPrice,2);
|
||||
}
|
||||
$order = [];
|
||||
$order[] = array(
|
||||
'order_id' => $order_id,
|
||||
'opened' => $open_time,
|
||||
'closed' => $close_time,
|
||||
'who_open' => $who_open,
|
||||
'who_close' => $who_close,
|
||||
'order_status' => $order_status,
|
||||
'amount' => $amount,
|
||||
'full_price' => $full_price,
|
||||
'cash' => $order_cash,
|
||||
'credit' => $order_credit,
|
||||
'clearing' => $order_clearing,
|
||||
'self' => $order_self,
|
||||
'presale' => $order_presale,
|
||||
'items' => $order_info
|
||||
);
|
||||
return $order;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,78 @@ namespace App\Component\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ShiftOnlineOrders extends Model {
|
||||
protected $table = 'shift_online_orders';
|
||||
class ShiftOnlineOrders extends Model
|
||||
{
|
||||
protected $table = 'shift_online_orders';
|
||||
|
||||
/**
|
||||
* Get order info
|
||||
*/
|
||||
public static function getInfo($order_id)
|
||||
{
|
||||
$order = ShiftOnlineOrders::where('code', $order_id)->first();
|
||||
$open_time = $order['opened'];
|
||||
$close_time = $order['closed'];
|
||||
$who_open = Staff::getName($order['who_open']);
|
||||
$who_close = Staff::getName($order['who_close']);
|
||||
$items = ShiftOnlineItems::where('order_code', $order_id)->get();
|
||||
$order_status = '';
|
||||
if ($order['is_deleted'] > 0) {
|
||||
$order_status = 'Удален';
|
||||
} elseif ($order['is_returned'] > 0) {
|
||||
$order_status = 'Возвращен';
|
||||
} elseif ($order['is_waited'] > 0 && $order['is_closed'] < 1) {
|
||||
$order_status = 'В ожидании';
|
||||
} else {
|
||||
$order_status = 'Оплачен';
|
||||
}
|
||||
$order_cash = $order['cash'];
|
||||
$order_credit = $order['credit'];
|
||||
$order_clearing = $order['clearing'];
|
||||
$order_presale = $order['presale'];
|
||||
$order_self = $order['self'];
|
||||
$order_info = [];
|
||||
$amount = $full_price = 0;
|
||||
foreach ($items as $key => $item) {
|
||||
$realPrice = $item['real_price'] * $item['count'] * $item['cof'];
|
||||
$salePrice = $item['sale_price'] * $item['count'];
|
||||
if ($realPrice > 0) {
|
||||
$discount = $salePrice / $realPrice;
|
||||
$discount = (1 - $discount) * 100;
|
||||
} else {
|
||||
$discount = 0;
|
||||
}
|
||||
$order_info[] = array(
|
||||
'id' => $key + 1,
|
||||
'name' => Dishes::getName($item['dish_code']),
|
||||
'count' => $item['count'],
|
||||
'price' => $item['real_price'],
|
||||
'sale_price' => $item['sale_price'],
|
||||
'cof' => $item['cof'],
|
||||
'unit' => Units::getName($item['units_id']),
|
||||
'amount' => round($item['sale_price'] * $item['count'], 2),
|
||||
'discount' => round($discount, 2)
|
||||
);
|
||||
$amount += round($item['sale_price'] * $item['count'], 2);
|
||||
$full_price += round($realPrice,2);
|
||||
}
|
||||
$order = [];
|
||||
$order[] = array(
|
||||
'order_id' => $order_id,
|
||||
'opened' => $open_time,
|
||||
'closed' => $close_time,
|
||||
'who_open' => $who_open,
|
||||
'who_close' => $who_close,
|
||||
'order_status' => $order_status,
|
||||
'amount' => $amount,
|
||||
'full_price' => $full_price,
|
||||
'cash' => $order_cash,
|
||||
'credit' => $order_credit,
|
||||
'clearing' => $order_clearing,
|
||||
'self' => $order_self,
|
||||
'presale' => $order_presale,
|
||||
'items' => $order_info
|
||||
);
|
||||
return $order;
|
||||
}
|
||||
}
|
||||
@@ -4,12 +4,25 @@ namespace App\Component\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Units extends Model {
|
||||
protected $table = 'units';
|
||||
/**
|
||||
* The attributes that aren't mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $guarded = [];
|
||||
class Units extends Model
|
||||
{
|
||||
protected $table = 'units';
|
||||
/**
|
||||
* The attributes that aren't mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $guarded = [];
|
||||
|
||||
public static function getName($data)
|
||||
{
|
||||
$unit_in_list = UnitsList::where('id', $data)->first();
|
||||
$unit_name = Units::where('id', $unit_in_list['unit_id'])->first();
|
||||
if ($unit_name) {
|
||||
$unit_name = $unit_name['name'];
|
||||
} else {
|
||||
$unit_name = 'шт';
|
||||
}
|
||||
return $unit_name;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user