v.2.4 RestoreShift

This commit is contained in:
miroman-afk
2022-01-10 02:28:28 +03:00
parent 7438ebef78
commit 0209970fe1
13 changed files with 306 additions and 5 deletions

View File

@@ -2,9 +2,9 @@
namespace App\Commands;
use App\Component\Models\ExchangeShifts;
use App\Component\Models\OrderBot;
use App\Component\Models\Report;
use App\Component\Models\Shifts;
use App\Console\Commands\HRCCommand;
use App\Console\Commands\HRCCommandInterface;
@@ -13,7 +13,7 @@ class OutOrders extends HRCCommand implements HRCCommandInterface {
public function command($input, $output = null) {
if ((array_key_exists('shift_id', $input)) === true) {
$shifts = Shifts::select('id', 'opened', 'closed')->where('id', '=', $input['shift_id'])->get();
$shifts = ExchangeShifts::select('id', 'opened', 'closed')->where('id', '=', $input['shift_id'])->get();
if (is_array($shifts) || is_object($shifts)) {
foreach ($shifts as $shift) {
$out = array('id' => $shift['id'], 'opened' => $shift['opened'], 'closed' => $shift['closed']);

View File

@@ -0,0 +1,160 @@
<?php
namespace App\Commands;
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\ShiftOnlineActions;
use App\Component\Models\ShiftOnlineDeleted;
use App\Component\Models\ShiftOnlineItems;
use App\Component\Models\ShiftOnlineOrders;
use App\Component\Models\Shifts;
use App\Component\Models\TerminalUpdate;
use App\Console\Commands\HRCCommand;
use App\Console\Commands\HRCCommandInterface;
class POSTRestoreShift extends HRCCommand implements HRCCommandInterface {
protected $signature = 'postrestoreshift';
public function command($input, $output = null) {
$shift_id = 4;
$cache_dir = __DIR__ . "\\..\\..\\..\\Cache\\";
$terminal_updates_old = TerminalUpdate::where('method', '=', 'online')->get();
foreach ($terminal_updates_old as $key => $terminal_online) {
$old_date = date_create($terminal_online['next_at']);
date_modify($old_date, '+1 hour');
$new_date = date_format($old_date, 'Y-m-d H:i:s');
$new_terminal_online = TerminalUpdate::find($terminal_online['id']);
$new_terminal_online->next_at = $new_date;
$new_terminal_online->save();
}
$terminal_updates_new = TerminalUpdate::where('method', '=', 'online')->get();
$exchange_shifts = ExchangeShifts::where('id', '=', $shift_id)->get();
$exchange_orders = ExchangeOrders::where('shift_id', '=', $shift_id)->get();
$exchange_items = ExchangeItems::where('shift_id', '=', $shift_id)->get();
$exchange_actions = ExchangeActions::where('shift_id', '=', $shift_id)->get();
$exchange_deleted = ExchangeDeleted::where('shift_id', '=', $shift_id)->get();
//clear shifts
Shifts::truncate();
foreach ($exchange_shifts as $key => $exchange_shift) {
$shift = new Shifts;
$shift->opened = $exchange_shift['opened'];
$shift->closed = $exchange_shift['closed'];
$shift->who_open = $exchange_shift['who_open'];
$shift->who_close = $exchange_shift['who_close'];
$shift->z_number = $exchange_shift['id'];
$shift->save();
}
//clear shift_online_orders
ShiftOnlineOrders::truncate();
foreach ($exchange_orders as $key => $exchange_order) {
$shift_online_order = new ShiftOnlineOrders;
$shift_online_order->cash = $exchange_order["cash"];
$shift_online_order->check_number = $exchange_order["check_number"];
$shift_online_order->clearing = $exchange_order["clearing"];
$shift_online_order->client_code = $exchange_order["client_code"];
$shift_online_order->client_count = $exchange_order["clients_count"];
if ($exchange_order["closed"] == '0000-00-00 00:00:00') {
$exchange_order["closed"] = '1970-01-01 00:00:00';
}
$shift_online_order->closed = $exchange_order["closed"];
$shift_online_order->code = $exchange_order["code"];
$shift_online_order->credit = $exchange_order["credit"];
$shift_online_order->full_sum = $exchange_order["full_sum"];
$shift_online_order->guid = $exchange_order["guid"];
$shift_online_order->is_block = $exchange_order["is_block"];
$shift_online_order->is_closed = $exchange_order["is_closed"];
$shift_online_order->is_deleted = $exchange_order["is_deleted"];
$shift_online_order->is_edit = $exchange_order["is_edit"];
$shift_online_order->is_printed = $exchange_order["is_printed"];
$shift_online_order->is_returned = $exchange_order["is_returned"];
$shift_online_order->is_self = $exchange_order["is_self"];
$shift_online_order->is_waited = $exchange_order["is_waited"];
if ($exchange_order["manual_discount"] == '') {
$exchange_order["manual_discount"] = 0;
} else {
$exchange_order["manual_discount"] = $exchange_order["manual_discount"] + 0;
}
$shift_online_order->manual_discount = $exchange_order["manual_discount"];
$shift_online_order->opened = $exchange_order["opened"];
$shift_online_order->order_sum = $exchange_order["order_sum"];
$shift_online_order->params_code = $exchange_order["params_id"];
$shift_online_order->place_name = $exchange_order["place_name"];
$shift_online_order->presale = $exchange_order["presale"];
$shift_online_order->sale_sum = $exchange_order["sale_sum"];
$shift_online_order->self = $exchange_order["self"];
$shift_online_order->table_name = $exchange_order["table_name"];
$shift_online_order->table_place = $exchange_order["table_place"];
$shift_online_order->terminal_id = $exchange_order["terminal_id"];
$shift_online_order->version_type = $exchange_order["version_type"];
$shift_online_order->who_close = $exchange_order["who_close"];
$shift_online_order->who_open = $exchange_order["who_open"];
$shift_online_order->save();
}
ShiftOnlineItems::truncate();
foreach ($exchange_items as $key => $exchange_item) {
$shift_online_item = new ShiftOnlineItems;
$shift_online_item->code = $exchange_item["code"];
$shift_online_item->cof = $exchange_item["cof"];
$shift_online_item->count = $exchange_item["count"];
$shift_online_item->count_real = $exchange_item["count_real"];
$shift_online_item->count_return = $exchange_item["count_return"];
$shift_online_item->dish_code = $exchange_item["dishes_code"];
$shift_online_item->menu_code = $exchange_item["menu_code"];
$shift_online_item->modificator_code = $exchange_item["modificator_code"];
$shift_online_item->order_code = $exchange_item["order_code"];
$shift_online_item->parent_id = $exchange_item["parent_id"];
$shift_online_item->real_price = $exchange_item["real_price"];
$shift_online_item->sale_price = $exchange_item["sale_price"];
$shift_online_item->special_price = $exchange_item["special_price"];
$shift_online_item->terminal_id = $exchange_item["terminal_id"];
$shift_online_item->units_code = $exchange_item["units_id"];
$shift_online_item->save();
}
ShiftOnlineActions::truncate();
foreach ($exchange_actions as $key => $exchange_action) {
$shift_online_action = new ShiftOnlineActions;
$shift_online_action->type_action = $exchange_action["action_type"];
$shift_online_action->more = $exchange_action["more"];
$shift_online_action->order_code = $exchange_action["order_code"];
$shift_online_action->order_position = $exchange_action["order_position"];
$shift_online_action->reason = $exchange_action["reason"];
$shift_online_action->terminal_id = $exchange_action["terminal_id"];
$shift_online_action->time = $exchange_action["time"];
$shift_online_action->value = $exchange_action["value"];
$shift_online_action->who = $exchange_action["who"];
$shift_online_action->workcode = $exchange_action["work_code"];
$shift_online_action->workgroup = $exchange_action["work_group"];
$shift_online_action->save();
}
ShiftOnlineDeleted::truncate();
foreach ($exchange_deleted as $key => $exchange_deleted_item) {
$shift_online_deleted_item = new ShiftOnlineDeleted;
$shift_online_deleted_item->code = $exchange_deleted_item["code"];
$shift_online_deleted_item->count = $exchange_deleted_item["count"];
$shift_online_deleted_item->dishes_code = $exchange_deleted_item["dishes_code"];
$shift_online_deleted_item->item_id = $exchange_deleted_item["item_id"];
$shift_online_deleted_item->menu_code = $exchange_deleted_item["menu_code"];
$shift_online_deleted_item->order_code = $exchange_deleted_item["order_code"];
$shift_online_deleted_item->real_price = $exchange_deleted_item["real_price"];
$shift_online_deleted_item->sale_price = $exchange_deleted_item["sale_price"];
$shift_online_deleted_item->terminal_id = $exchange_deleted_item["terminal_id"];
$shift_online_deleted_item->units_id = $exchange_deleted_item["units_id"];
$shift_online_deleted_item->save();
}
return [
'status' => 'success',
'terminal_old' => $terminal_updates_old,
'terminal_new' => $terminal_updates_new,
];
}
}

View File

@@ -0,0 +1,63 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddColumnsToShiftOnlineOrders extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up() {
Schema::table('shift_online_orders', function (Blueprint $table) {
$table->integer('is_self')->nullable();
$table->integer('is_block')->nullable();
$table->integer('is_edit')->nullable();
$table->string('guid')->nullable();
});
Schema::table('shift_online_items', function (Blueprint $table) {
$table->decimal('count_real', $precision = 16, $scale = 2)->nullable();
$table->decimal('count_return', $precision = 16, $scale = 2)->nullable();
$table->integer('parent_id')->nullable();
});
Schema::table('shift_online_actions', function (Blueprint $table) {
$table->integer('terminal_id')->nullable();
});
Schema::table('exchange_orders', function (Blueprint $table) {
$table->string('table_place')->nullable();
});
Schema::table('exchange_items', function (Blueprint $table) {
$table->integer('modificator_code')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down() {
Schema::table('shift_online_orders', function (Blueprint $table) {
$table->dropColumn('is_self');
$table->dropColumn('guid');
$table->dropColumn('is_block');
$table->dropColumn('is_edit');
});
Schema::table('shift_online_items', function (Blueprint $table) {
$table->dropColumn('count_real');
$table->dropColumn('count_return');
$table->dropColumn('parent_id');
});
Schema::table('shift_online_actions', function (Blueprint $table) {
$table->dropColumn('terminal_id');
});
Schema::table('exchange_orders', function (Blueprint $table) {
$table->dropColumn('table_place');
});
Schema::table('exchange_items', function (Blueprint $table) {
$table->dropColumn('modificator_code');
});
}
}

View File

@@ -0,0 +1,9 @@
<?php
namespace App\Component\Models;
use Illuminate\Database\Eloquent\Model;
class ExchangeActions extends Model {
protected $table = 'exchange_actions';
}

View File

@@ -0,0 +1,9 @@
<?php
namespace App\Component\Models;
use Illuminate\Database\Eloquent\Model;
class ExchangeDeleted extends Model {
protected $table = 'exchange_deleted';
}

View File

@@ -0,0 +1,9 @@
<?php
namespace App\Component\Models;
use Illuminate\Database\Eloquent\Model;
class ShiftOnlineActions extends Model {
protected $table = 'shift_online_actions';
}

View File

@@ -0,0 +1,9 @@
<?php
namespace App\Component\Models;
use Illuminate\Database\Eloquent\Model;
class ShiftOnlineDeleted extends Model {
protected $table = 'shift_online_deleted';
}

View File

@@ -0,0 +1,9 @@
<?php
namespace App\Component\Models;
use Illuminate\Database\Eloquent\Model;
class ShiftOnlineItems extends Model {
protected $table = 'shift_online_items';
}

View File

@@ -0,0 +1,9 @@
<?php
namespace App\Component\Models;
use Illuminate\Database\Eloquent\Model;
class ShiftOnlineOrders extends Model {
protected $table = 'shift_online_orders';
}

View File

@@ -5,5 +5,5 @@ namespace App\Component\Models;
use Illuminate\Database\Eloquent\Model;
class Shifts extends Model {
protected $table = 'exchange_shifts';
protected $table = 'shifts';
}

View File

@@ -0,0 +1,9 @@
<?php
namespace App\Component\Models;
use Illuminate\Database\Eloquent\Model;
class TerminalUpdate extends Model {
protected $table = 'terminals_update';
}

View File

@@ -5,5 +5,12 @@ item: [
url: 'app.dashboard',
icon: 'dashboard',
order: 0
},
{
name: 'Eorders',
acl: 'eorders',
url: 'app.orders',
icon: 'dashboard',
order: 0
}
];

View File

@@ -8,9 +8,17 @@
},
{
code: 'app.v1.reimport',
url: '/v1/reimport',
url: '/v1/reimport',
templateUrl: '../views/reimport.html',
data: { title : 'Повторная выгрузка' },
controller: 'ReImportCtrl',
resolve: ['scripts/controllers/reimport.js']
resolve: ['scripts/controllers/reimport.js']
},
{
code: 'app.orders',
url: '/v1/orders',
templateUrl: '../views/orders/orders.html',
data: { title : 'Eorders' },
controller: 'OrdersCtrl',
resolve: ['scripts/controllers/orders.js']
}