Small fix
This commit is contained in:
miroman-afk
2022-12-22 12:52:42 +03:00
parent d24bba305f
commit 723e9a8768
15 changed files with 213 additions and 117 deletions

View File

@@ -38,7 +38,7 @@ class GETClientInfo extends HRCCommand implements HRCCommandInterface
'email' => $email,
'address' => $address,
'order_count' => $orders_count,
'order_sum' => $orders_sum,
'order_sum' => round($orders_sum, 2),
'presale' => $presale,
'bonus' => intval($bonus),
)

View File

@@ -17,29 +17,21 @@ class GETClientOrders extends HRCCommand implements HRCCommandInterface
if (isset($input['id'])) {
$client = Client::where('id', $input['id'])->first();
$client_guid = $client['user_code'];
$exchange_orders = ExchangeOrders::where('client_code', $client_guid)->where('is_returned', 0)->where('is_deleted', 0)->orderByDesc('closed')->get();
$online_orders = ShiftOnlineOrders::where('client_code', $client_guid)->where('is_returned', 0)->where('is_deleted', 0)->orderByDesc('closed')->get();
$orders = [];
foreach ($online_orders as $online_order) {
$orders[] = array(
'id' => $online_order['code'],
'opened' => $online_order['opened'],
'closed' => $online_order['closed'],
'sum' => $online_order['order_sum'],
'discount' => $online_order['sale_sum'],
'shift_id' => 0
);
}
foreach ($exchange_orders as $exchange_order) {
$orders[] = array(
'id' => $exchange_order['code'],
'opened' => $exchange_order['opened'],
'closed' => $exchange_order['closed'],
'sum' => $exchange_order['order_sum'],
'discount' => $exchange_order['sale_sum'],
'shift_id' => $exchange_order['shift_id']
);
}
$exchange_orders = ExchangeOrders::select('code', 'opened', 'closed', 'order_sum', 'sale_sum')
->where('client_code', $client_guid)
->where('is_returned', 0)
->where('is_deleted', 0)
->orderByDesc('closed')
->get()
->toArray();
$online_orders = ShiftOnlineOrders::select('code', 'opened', 'closed', 'order_sum', 'sale_sum')
->where('client_code', $client_guid)
->where('is_returned', 0)
->where('is_deleted', 0)
->orderByDesc('closed')
->get()
->toArray();
$orders = array_merge($online_orders, $exchange_orders);
return [
'status' => 'success',
'orders' => $orders,

View File

@@ -5,6 +5,7 @@ namespace App\Commands;
use App\Component\Models\Dishes;
use App\Component\Models\ExchangeActions;
use App\Component\Models\ExchangeDeleted;
use App\Component\Models\ExchangeItems;
use App\Component\Models\ExchangeOrders;
use App\Component\Models\ExchangeShifts;
use App\Component\Models\Reasons;
@@ -739,6 +740,36 @@ class GETDataReport extends HRCCommand implements HRCCommandInterface
'deleted' => $deleted
];
}
if ($input['type'] == 'abc') {
if (isset($input['start_date']) && isset($input['end_date'])) {
$end_date = date('Y-m-d H:i:s', strtotime($input['end_date']));
$start_date = date('Y-m-d H:i:s', strtotime($input['start_date']));
$orders_shifts = ExchangeOrders::where('opened', '>=', $start_date)
->where('closed', '=<', $end_date)
->where('is_deleted', 0)
->where('is_returned', 0)
->where('is_closed', 1)
->groupBy('shift_id')
->get();
$orders = ExchangeOrders::where('opened', '>=', $start_date)
->where('closed', '=<', $end_date)
->where('is_deleted', 0)
->where('is_returned', 0)
->where('is_closed', 1)
->get();
$revenue = 0;
foreach ($orders_shifts as $orders_shift) {
$shift_revenue = ExchangeShifts::where('shift_id', $orders_shift['shift_id'])
->first();
$revenue += $shift_revenue['revenue'];
}
foreach ($orders as $order) {
$order_items = ExchangeItems::where('order_code', $order['code'])
->where('shift_id', $order['shift_id'])
->get();
}
}
}
} else {
return [
'status' => 'success',

View File

@@ -14,15 +14,16 @@ class POSTBonus extends HRCCommand implements HRCCommandInterface
public function command($input, $output = null)
{
$client_guid = $input['client_id'];
$bonus_amount = $input['amount'];
$bonus_amount = abs($input['amount']);
$staff_id = $input['who'];
$bonus_time = $input['date_transaction'];
ClientsBonus::bonusReg($client_guid, $bonus_amount);
$type = $input['type'];
ClientsBonus::bonusReg($client_guid, $bonus_amount, $type);
ClientsBonus::bonusLog($client_guid, $bonus_amount, $bonus_time, $staff_id);
if ($bonus_amount > 0) {
if ($type == 'in') {
$message = 'Начислено ' . $bonus_amount . ' бонусов';
} else {
$message = 'Списано ' . abs($bonus_amount) . ' бонусов';
} elseif ($type == 'out') {
$message = 'Списано ' . $bonus_amount . ' бонусов';
}
$bonus_result = ClientsBonus::getBonus($client_guid);
return [

View File

@@ -13,15 +13,16 @@ class POSTPresale extends HRCCommand implements HRCCommandInterface
public function command($input, $output = null)
{
$client_guid = $input['client_id'];
$presale_amount = $input['amount'];
$presale_amount = abs($input['amount']);
$staff_id = $input['who'];
$presale_time = $input['date_transaction'];
ClientsPresale::presaleReg($client_guid, $presale_amount);
$type = $input['type'];
ClientsPresale::presaleReg($client_guid, $presale_amount, $type);
ClientsPresale::presaleLog($client_guid, $presale_amount, $presale_time, $staff_id);
if ($presale_amount > 0) {
if ($type == 'in') {
$message = 'Внесен аванс на сумму ' . $presale_amount . ' BYN';
} else {
$message = 'Зачтен аванс на сумму ' . abs($presale_amount) . ' BYN';
} elseif ($type == 'out') {
$message = 'Зачтен аванс на сумму ' . $presale_amount . ' BYN';
}
$presale_result = ClientsPresale::getPresale($client_guid);
return [