v.2.27
Fixed reports
This commit is contained in:
@@ -3,17 +3,9 @@
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\Client;
|
||||
use App\Component\Models\ClientsAddress;
|
||||
use App\Component\Models\ClientsBarcode;
|
||||
use App\Component\Models\ClientsBonus;
|
||||
use App\Component\Models\ClientsEmail;
|
||||
use App\Component\Models\ClientsGroup;
|
||||
use App\Component\Models\ClientsPhone;
|
||||
use App\Component\Models\ClientsPresale;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class GETClients extends HRCCommand implements HRCCommandInterface
|
||||
{
|
||||
@@ -21,99 +13,6 @@ class GETClients extends HRCCommand implements HRCCommandInterface
|
||||
|
||||
public function command($input, $output = null)
|
||||
{
|
||||
if (isset($input['type']) && $input['type'] == 'loyalty') {
|
||||
$last_update = Carbon::createFromTimestampUTC($input['last_update'])->timezone('Europe/Minsk');
|
||||
$phones = ClientsPhone::where('updated_at', '>=', $last_update)->get();
|
||||
$addresses = ClientsAddress::where('updated_at', '>=', $last_update)->get();
|
||||
$barcodes = ClientsBarcode::where('updated_at', '>=', $last_update)->get();
|
||||
$emails = ClientsEmail::where('updated_at', '>=', $last_update)->get();
|
||||
$presales = ClientsPresale::where('updated_at', '>=', $last_update)->get();
|
||||
$bonuses = ClientsBonus::where('updated_at', '>=', $last_update)->get();
|
||||
$clients = Client::where('updated_at', '>=', $last_update)->get();
|
||||
$info = [];
|
||||
foreach ($phones as $phone) {
|
||||
$info[] = $phone['client_guid'];
|
||||
}
|
||||
foreach ($addresses as $address) {
|
||||
$info[] = $address['client_guid'];
|
||||
}
|
||||
foreach ($barcodes as $barcode) {
|
||||
$info[] = $barcode['client_guid'];
|
||||
}
|
||||
foreach ($emails as $email) {
|
||||
$info[] = $email['client_guid'];
|
||||
}
|
||||
foreach ($presales as $presale) {
|
||||
$info[] = $presale['client_guid'];
|
||||
}
|
||||
foreach ($bonuses as $bonus) {
|
||||
$info[] = $bonus['client_guid'];
|
||||
}
|
||||
foreach ($clients as $client) {
|
||||
$info[] = $client['user_code'];
|
||||
}
|
||||
$guides = array_values(array_unique($info));
|
||||
$email = $phone = $client = [];
|
||||
foreach ($guides as $guid) {
|
||||
$email_address = Client::getEmail($guid);
|
||||
$phone_number = Client::getPhone($guid);
|
||||
$client_info = Client::where('user_code', $guid)->first();
|
||||
$email[] = array(
|
||||
'email' => $email_address
|
||||
);
|
||||
$phone[] = array(
|
||||
'phone' => $phone_number
|
||||
);
|
||||
$badge[] = array(
|
||||
'name' => 'Test',
|
||||
'code' => 1
|
||||
);
|
||||
$bonus_dishes[] = array(
|
||||
'code' => ''
|
||||
);
|
||||
if (ClientsBonus::getBonus($guid) > 0) {
|
||||
$bonus_info[] = array(
|
||||
'amount' => ClientsBonus::getBonus($guid),
|
||||
'dishes' => $bonus_dishes
|
||||
);
|
||||
} else {
|
||||
$bonus_info[] = array(
|
||||
'amount' => ClientsBonus::getBonus($guid)
|
||||
);
|
||||
}
|
||||
|
||||
$group_info = ClientsGroup::where('code', $client_info['group_id'])->first();
|
||||
$client[] = array(
|
||||
'id' => $client_info['id'],
|
||||
'name' => $client_info['name'],
|
||||
'guid' => $guid,
|
||||
'presale' => ClientsPresale::getPresale($guid),
|
||||
'bonuses' => $bonus_info,
|
||||
'barcode' => Client::getBarcode($guid),
|
||||
'group_id' => $client_info['group_id'],
|
||||
'emails' => $email,
|
||||
'phones' => $phone,
|
||||
'badges' => $badge
|
||||
);
|
||||
$groups[] = $group_info['code'];
|
||||
$email = $phone = $badge = $bonus_dishes = $bonus_info = [];
|
||||
}
|
||||
$groups_guides = array_values(array_unique($groups));
|
||||
foreach ($groups_guides as $group) {
|
||||
$group_info = ClientsGroup::where('code', $group)->first();
|
||||
$groups_info[] = array(
|
||||
'id' => $group_info['id'],
|
||||
'name' => $group_info['name'],
|
||||
'guid' => $group_info['code'],
|
||||
);
|
||||
}
|
||||
|
||||
return [
|
||||
'status' => 'success',
|
||||
'clients' => $client,
|
||||
'groups' => $groups_info,
|
||||
];
|
||||
}
|
||||
if (ClientsGroup::where('code', '0')->count() == 0) {
|
||||
$group = new ClientsGroup([
|
||||
'code' => '0',
|
||||
@@ -145,12 +44,33 @@ class GETClients extends HRCCommand implements HRCCommandInterface
|
||||
$phone = Client::getPhone($client['user_code']);
|
||||
$email = Client::getEmail($client['user_code']);
|
||||
$address = Client::getAddress($client['user_code']);
|
||||
$barcode = Client::getBarcode($client['user_code']);
|
||||
if ($client['is_special_price'] == 0) {
|
||||
$special_price = false;
|
||||
} else {
|
||||
$special_price = true;
|
||||
}
|
||||
if ($client['is_employee'] == 0) {
|
||||
$employee = false;
|
||||
} else {
|
||||
$employee = true;
|
||||
}
|
||||
if ($client['is_block'] == 0) {
|
||||
$is_block = false;
|
||||
} else {
|
||||
$is_block = true;
|
||||
}
|
||||
$out[] = array(
|
||||
'id' => $client['id'],
|
||||
'name' => $client['name'],
|
||||
'phone' => $phone,
|
||||
'email' => $email,
|
||||
'address' => $address,
|
||||
'barcode' => $barcode,
|
||||
'special_price' => $special_price,
|
||||
'employee' => $employee,
|
||||
'is_block' => $is_block,
|
||||
|
||||
);
|
||||
}
|
||||
return [
|
||||
|
||||
Reference in New Issue
Block a user