fix
parent
1edbd3ac9d
commit
18fffad0d9
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use A7kz\Platform\Models\UniModel;
|
||||
use A7kz\Platform\Modules\Platform\Segment\Facades\Segment;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Mpdf\Tag\Mark;
|
||||
|
||||
class MobileApiController extends Controller
|
||||
{
|
||||
public function getMarks() {
|
||||
$data = [];
|
||||
$marks = UniModel::model('pipi_brand_models')->get();
|
||||
if (!isset($marks)) {
|
||||
return response()->json();
|
||||
}
|
||||
foreach ($marks as $mark) {
|
||||
$brand = UniModel::model('pipi_auto_brands')->find($mark->brand_id);
|
||||
$tariffs = UniModel::model('pipi_auto_tariffs')->where('model_id', $mark->id)->first();
|
||||
if ($mark->name != 'Ввод остатков') {
|
||||
$data[$mark->name] = [
|
||||
'brand' => $brand->name,
|
||||
'mark' => $mark->name,
|
||||
'tariffs' => $tariffs?->toArray()
|
||||
];
|
||||
}
|
||||
}
|
||||
return response()->json($data);
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ use A7kz\Platform\Models\UniModel;
|
|||
use A7kz\Platform\Modules\Platform\Segment\Facades\Segment;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
|
@ -13,13 +14,12 @@ use Illuminate\Support\Facades\Storage;
|
|||
class Sync1cApiController extends Controller
|
||||
{
|
||||
|
||||
private function formatDate($date): ?string
|
||||
private function formatDate($date): ?Carbon
|
||||
{
|
||||
$date = trim($date);
|
||||
|
||||
try {
|
||||
$dateObject = \Carbon\Carbon::createFromFormat('d.m.Y', $date);
|
||||
return $dateObject->format('Y-m-d');
|
||||
return Carbon::parse($date);
|
||||
} catch (\Exception $e) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -62,14 +62,15 @@ class Sync1cApiController extends Controller
|
|||
'name' => $value['Модель'],
|
||||
'brand_id' => UniModel::model('pipi_auto_brands', $segment->connector)
|
||||
->firstOrCreate(['name' => $value['Марка']])->id,
|
||||
'year' => $this->formatDate($value['ГодПроизводства'])?->format('Y'),
|
||||
])->id,
|
||||
'color_id' => UniModel::model('pipi_auto_colors', $segment->connector)
|
||||
->firstOrCreate(['name' => $value['Цвет']])->id,
|
||||
'serial_number' => $value['СерийныйНомер'],
|
||||
'state_number' => $value['ГосНомер'],
|
||||
'manufacture_year' => $this->formatDate($value['ГодПроизводства']),
|
||||
'manufacture_year' => $this->formatDate($value['ГодПроизводства'])?->format('Y-m-d'),
|
||||
'passport_number' => $value['НомерТехПаспорта'],
|
||||
'passport_date' => $this->formatDate($value['ДатаТехпаспорта']),
|
||||
'passport_date' => $this->formatDate($value['ДатаТехпаспорта'])?->format('Y-m-d'),
|
||||
'estimated_cost' => $value['ОценочнаяСтоимость'],
|
||||
'owner_id' => UniModel::model('pipi_owners', $segment->connector)
|
||||
->firstOrCreate(['name' => $value['ВладелецИмущества']])->id,
|
||||
|
|
@ -79,7 +80,7 @@ class Sync1cApiController extends Controller
|
|||
'is_predefined' => (bool)$value['Предопределенный'],
|
||||
'predefined_data_name' => $value['ИмяПредопределенныхДанных'],
|
||||
'inspection_kit' => $inspectionKit,
|
||||
'deleted_at' => (bool) $value['ПометкаУдаления'] ? now() : null,
|
||||
'deleted_at' => $value['ПометкаУдаления'] == 'Да' ? now() : null,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
@ -126,12 +127,12 @@ class Sync1cApiController extends Controller
|
|||
'phone' => $value['Телефон'],
|
||||
'mail' => $value['Почта'],
|
||||
'id_number' => $value['УдНомер'],
|
||||
'id_date' => $this->formatDate($value['УдДата']),
|
||||
'id_date' => $this->formatDate($value['УдДата'])?->format('Y-m-d'),
|
||||
'issued' => $value['УдВыдан'],
|
||||
'contract_id' => $value['ОсновнойДоговор'] ? UniModel::model('pipi_owner_contracts', $segment->connector)->firstOrCreate([
|
||||
'name' => $value['ОсновнойДоговор']
|
||||
])->id : null,
|
||||
'deleted_at' => $value['ПометкаУдаления'] ? now() : null,
|
||||
'deleted_at' => $value['ПометкаУдаления'] == 'Да' ? now() : null,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
@ -179,11 +180,11 @@ class Sync1cApiController extends Controller
|
|||
'comments' => $value['Комментарий'],
|
||||
'organization' => $value['Организация'],
|
||||
'contract_number' => $value['НомерДоговора'],
|
||||
'contract_date' => $this->formatDate($value['ДатаДоговора']),
|
||||
'started_at' => $this->formatDate($value['ДатаНачалаДействияДоговора']),
|
||||
'ended_at' => $this->formatDate($value['ДатаОкончанияДействияДоговора']),
|
||||
'contract_date' => $this->formatDate($value['ДатаДоговора'])?->format('Y-m-d'),
|
||||
'started_at' => $this->formatDate($value['ДатаНачалаДействияДоговора'])?->format('Y-m-d'),
|
||||
'ended_at' => $this->formatDate($value['ДатаОкончанияДействияДоговора'])?->format('Y-m-d'),
|
||||
'payment_type' => $value['УсловияОплаты'],
|
||||
'deleted_at' => $value['ПометкаУдаления'] ? now() : null,
|
||||
'deleted_at' => $value['ПометкаУдаления'] == 'Да' ? now() : null,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Notifications;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use NotificationChannels\Telegram\TelegramMessage;
|
||||
|
||||
class TelegramNotification extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
return ['telegram'];
|
||||
}
|
||||
|
||||
public function toTelegram($notifiable)
|
||||
{
|
||||
print_r($notifiable);
|
||||
return TelegramMessage::create()
|
||||
->to(env('TELEGRAM_CHAT_ID'))
|
||||
->content($notifiable['car'])
|
||||
->line('')
|
||||
->line($notifiable['base_price'])
|
||||
->line($notifiable['period'])
|
||||
->line($notifiable['pickup_location'])
|
||||
->line($notifiable['return_location'])
|
||||
->line($notifiable['customer_type'])
|
||||
->line($notifiable['customer_full_name'])
|
||||
->line($notifiable['customer_email'])
|
||||
->line($notifiable['customer_phone']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*/
|
||||
public function toMail(object $notifiable): MailMessage
|
||||
{
|
||||
return (new MailMessage)
|
||||
->line('The introduction to the notification.')
|
||||
->action('Notification Action', url('/'))
|
||||
->line('Thank you for using our application!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array representation of the notification.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(object $notifiable): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -60,6 +60,7 @@ return new class extends \A7kz\Platform\Commands\InstallScript {
|
|||
->firstOrCreate([
|
||||
'name' => $value['Модель'],
|
||||
'brand_id' => $autoBrand->id,
|
||||
'year' => $this->formatDate($value['ГодПроизводства'])?->format('Y'),
|
||||
])->id;
|
||||
$car->color_id = UniModel::model('pipi_auto_colors', $segment->connector)
|
||||
->firstOrCreate([
|
||||
|
|
@ -67,9 +68,9 @@ return new class extends \A7kz\Platform\Commands\InstallScript {
|
|||
])->id;
|
||||
$car->serial_number = $value['СерийныйНомер'];
|
||||
$car->state_number = $value['ГосНомер'];
|
||||
$car->manufacture_year = $this->formatDate($value['ГодПроизводства']);
|
||||
$car->manufacture_year = $this->formatDate($value['ГодПроизводства'])?->format('Y-m-d');
|
||||
$car->passport_number = $value['НомерТехПаспорта'];
|
||||
$car->passport_date = $this->formatDate($value['ДатаТехпаспорта']);
|
||||
$car->passport_date = $this->formatDate($value['ДатаТехпаспорта'])?->format('Y-m-d');
|
||||
$car->estimated_cost = $value['ОценочнаяСтоимость'];
|
||||
$owner = UniModel::model('pipi_owners', $segment->connector)
|
||||
->firstOrCreate([
|
||||
|
|
@ -83,7 +84,7 @@ return new class extends \A7kz\Platform\Commands\InstallScript {
|
|||
$car->is_predefined = (bool) $value['Предопределенный'];
|
||||
$car->predefined_data_name = $value['ИмяПредопределенныхДанных'];
|
||||
$car->inspection_kit = json_validate($value['КомпректацияДляОсмотра']) ? $value['КомпректацияДляОсмотра'] : null;
|
||||
if ((bool) $value['ПометкаУдаления']) {
|
||||
if ($value['ПометкаУдаления'] == 'Да') {
|
||||
$car->deleted_at = now();
|
||||
}
|
||||
$car->save();
|
||||
|
|
@ -135,13 +136,12 @@ return new class extends \A7kz\Platform\Commands\InstallScript {
|
|||
}
|
||||
}
|
||||
|
||||
private function formatDate($date): ?string
|
||||
private function formatDate($date): ?Carbon
|
||||
{
|
||||
$date = trim($date);
|
||||
|
||||
try {
|
||||
$dateObject = \Carbon\Carbon::createFromFormat('d.m.Y', $date);
|
||||
return $dateObject->format('Y-m-d');
|
||||
return Carbon::parse($date);
|
||||
} catch (\Exception $e) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,9 +14,17 @@ return new class extends Migration
|
|||
foreach ($segments as $segment) {
|
||||
Schema::connection($segment->connector)->create('pipi_auto_tariffs', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name')->nullable()->comment('Наименование');
|
||||
$table->string('name');
|
||||
$table->string('type');
|
||||
$table->integer('day_range_start');
|
||||
$table->integer('day_range_end');
|
||||
$table->integer('base_rate');
|
||||
$table->integer('deposit');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unsignedBigInteger('model_id')->nullable()->comment('Тариф');
|
||||
$table->foreign('model_id')->references('id')->on('pipi_brand_models');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@
|
|||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"year": {
|
||||
"type": "string"
|
||||
},
|
||||
"brand_id": {
|
||||
"type": "foreign",
|
||||
"table": "pipi_auto_brands",
|
||||
|
|
@ -219,9 +222,17 @@
|
|||
"title": "Модели автомобилей",
|
||||
"template": "app.base.crud.grid",
|
||||
"cols": [
|
||||
{
|
||||
"name": "brand_id",
|
||||
"caption": "Название марки"
|
||||
},
|
||||
{
|
||||
"name": "name",
|
||||
"caption": "Название цвета"
|
||||
"caption": "Название модели"
|
||||
},
|
||||
{
|
||||
"name": "year",
|
||||
"caption": "Год выпуска"
|
||||
}
|
||||
],
|
||||
"action": {
|
||||
|
|
@ -260,18 +271,25 @@
|
|||
{
|
||||
"cols": [
|
||||
{
|
||||
"size": 6,
|
||||
"size": 5,
|
||||
"input": {
|
||||
"name": "name",
|
||||
"label": "Название"
|
||||
}
|
||||
},
|
||||
{
|
||||
"size": 6,
|
||||
"size": 5,
|
||||
"input": {
|
||||
"name": "brand_id",
|
||||
"label": "Марка"
|
||||
}
|
||||
},
|
||||
{
|
||||
"size": 2,
|
||||
"input": {
|
||||
"name": "year",
|
||||
"label": "Год"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -286,18 +304,25 @@
|
|||
{
|
||||
"cols": [
|
||||
{
|
||||
"size": 6,
|
||||
"size": 5,
|
||||
"input": {
|
||||
"name": "name",
|
||||
"label": "Название"
|
||||
}
|
||||
},
|
||||
{
|
||||
"size": 6,
|
||||
"size": 5,
|
||||
"input": {
|
||||
"name": "brand_id",
|
||||
"label": "Марка"
|
||||
}
|
||||
},
|
||||
{
|
||||
"size": 2,
|
||||
"input": {
|
||||
"name": "year",
|
||||
"label": "Год"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ return new class extends \A7kz\Platform\Commands\InstallScript {
|
|||
Schema::connection($segment->connector)->create('pipi_brand_models', static function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name')->nullable()->comment('Наименование');
|
||||
$table->integer('year')->nullable()->comment('Год выпуска');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
|
|
|
|||
|
|
@ -75,11 +75,11 @@ return new class extends \A7kz\Platform\Commands\InstallScript {
|
|||
$model->comments = $value['Комментарий'];
|
||||
$model->organization = $value['Организация'];
|
||||
$model->contract_number = $value['НомерДоговора'];
|
||||
$model->contract_date = $this->formatDate($value['ДатаДоговора']);
|
||||
$model->started_at = $this->formatDate($value['ДатаНачалаДействияДоговора']);
|
||||
$model->ended_at = $this->formatDate($value['ДатаОкончанияДействияДоговора']);
|
||||
$model->contract_date = $this->formatDate($value['ДатаДоговора'])?->format('Y-m-d');
|
||||
$model->started_at = $this->formatDate($value['ДатаНачалаДействияДоговора'])?->format('Y-m-d');
|
||||
$model->ended_at = $this->formatDate($value['ДатаОкончанияДействияДоговора'])?->format('Y-m-d');
|
||||
$model->payment_type = $value['УсловияОплаты'];
|
||||
if ((bool) $value['ПометкаУдаления']) {
|
||||
if ($value['ПометкаУдаления'] = 'Да') {
|
||||
$model->deleted_at = now();
|
||||
}
|
||||
$model->save();
|
||||
|
|
@ -101,13 +101,12 @@ return new class extends \A7kz\Platform\Commands\InstallScript {
|
|||
}
|
||||
}
|
||||
|
||||
private function formatDate($date): ?string
|
||||
private function formatDate($date): ?Carbon
|
||||
{
|
||||
$date = trim($date);
|
||||
|
||||
try {
|
||||
$dateObject = \Carbon\Carbon::createFromFormat('d.m.Y', $date);
|
||||
return $dateObject->format('Y-m-d');
|
||||
return Carbon::parse($date);
|
||||
} catch (\Exception $e) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ return new class extends \A7kz\Platform\Commands\InstallScript {
|
|||
$model->mail = $value['Почта'];
|
||||
$model->id_number = $value['УдНомер'];
|
||||
if ($value['УдДата']) {
|
||||
$model->id_date = $this->formatDate($value['УдДата']);
|
||||
$model->id_date = $this->formatDate($value['УдДата'])->format('Y-m-d');
|
||||
}
|
||||
$model->issued = $value['УдВыдан'];
|
||||
if ($value['ОсновнойДоговор']) {
|
||||
|
|
@ -97,7 +97,7 @@ return new class extends \A7kz\Platform\Commands\InstallScript {
|
|||
'name' => $value['ОсновнойДоговор']
|
||||
])->id;
|
||||
}
|
||||
if ((bool) $value['ПометкаУдаления']) {
|
||||
if ($value['ПометкаУдаления'] == 'Да') {
|
||||
$model->deleted_at = now();
|
||||
}
|
||||
$model->save();
|
||||
|
|
@ -118,13 +118,12 @@ return new class extends \A7kz\Platform\Commands\InstallScript {
|
|||
}
|
||||
}
|
||||
|
||||
private function formatDate($date): ?string
|
||||
private function formatDate($date): ?Carbon
|
||||
{
|
||||
$date = trim($date);
|
||||
|
||||
try {
|
||||
$dateObject = \Carbon\Carbon::createFromFormat('d.m.Y', $date);
|
||||
return $dateObject->format('Y-m-d');
|
||||
return Carbon::parse($date);
|
||||
} catch (\Exception $e) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
use App\Http\Controllers\MobileApiController;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
|
|
@ -20,3 +21,7 @@ Route::prefix('1c')->group(function () {
|
|||
Route::post('syncOwners', [Sync1cApiController::class, 'syncOwners']);
|
||||
Route::post('syncOwnerContracts', [Sync1cApiController::class, 'syncOwnerContracts']);
|
||||
});
|
||||
|
||||
Route::prefix('mobile')->group(function () {
|
||||
Route::get('getMarks', [MobileApiController::class, 'getMarks']);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue