Skip to content

Commit

Permalink
fix: rename dictionary models
Browse files Browse the repository at this point in the history
  • Loading branch information
avlyalin committed Jul 27, 2020
1 parent 283ffc2 commit 46c4c01
Show file tree
Hide file tree
Showing 25 changed files with 204 additions and 207 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ php artisan migrate
* **acquiring_apple_pay_payments** - платежи через Apple Pay
* **acquiring_samsung_pay_payments** - платежи через Samsung Pay
* **acquiring_google_pay_payments** - платежи через Google Pay
* **dict_acquiring_payment_statuses** - справочник статусов платежей
* **dict_acquiring_payment_operation_types** - справочник типов операций
* **dict_acquiring_payment_systems** - справочник платежных систем
* **acquiring_payment_statuses** - справочник статусов платежей
* **acquiring_payment_operation_types** - справочник типов операций
* **acquiring_payment_systems** - справочник платежных систем

Диаграмма:
![screenshot of conversion](./diagram.png)
Expand Down Expand Up @@ -461,14 +461,14 @@ php artisan sberbank-acquiring:update-statuses --id=1 --id=7
Рекомендуется добавить команду в шедулер (**app/Console/Kernel.php**):
```php
use Avlyalin\SberbankAcquiring\Commands\UpdateStatusCommand;
use Avlyalin\SberbankAcquiring\Models\DictAcquiringPaymentStatus;
use Avlyalin\SberbankAcquiring\Models\AcquiringPaymentStatus;

protected function schedule(Schedule $schedule)
{
$schedule->command(UpdateStatusCommand::class, [
'--id' => [
DictAcquiringPaymentStatus::NEW,
DictAcquiringPaymentStatus::ACS_AUTH,
AcquiringPaymentStatus::NEW,
AcquiringPaymentStatus::ACS_AUTH,
],
])->everyMinute();
}
Expand Down
6 changes: 3 additions & 3 deletions config/sberbank-acquiring.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,16 @@
/**
* Статусы платежей
*/
'dict_payment_statuses' => 'dict_acquiring_payment_statuses',
'payment_statuses' => 'acquiring_payment_statuses',

/**
* Типы операций
*/
'dict_payment_operation_types' => 'dict_acquiring_payment_operation_types',
'payment_operation_types' => 'acquiring_payment_operation_types',

/**
* Типы платежных систем
*/
'dict_payment_systems' => 'dict_acquiring_payment_systems',
'payment_systems' => 'acquiring_payment_systems',
],
];
16 changes: 8 additions & 8 deletions database/factories/AcquiringPaymentFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use Avlyalin\SberbankAcquiring\Models\AcquiringPayment;
use Avlyalin\SberbankAcquiring\Models\ApplePayPayment;
use Avlyalin\SberbankAcquiring\Models\DictAcquiringPaymentStatus;
use Avlyalin\SberbankAcquiring\Models\DictAcquiringPaymentSystem;
use Avlyalin\SberbankAcquiring\Models\AcquiringPaymentStatus;
use Avlyalin\SberbankAcquiring\Models\AcquiringPaymentSystem;
use Avlyalin\SberbankAcquiring\Models\GooglePayPayment;
use Avlyalin\SberbankAcquiring\Models\SamsungPayPayment;
use Avlyalin\SberbankAcquiring\Models\SberbankPayment;
Expand All @@ -14,40 +14,40 @@
$factory->define(AcquiringPayment::class, function () {
return [
'bank_order_id' => Str::random(36),
'system_id' => DictAcquiringPaymentSystem::SBERBANK,
'status_id' => DictAcquiringPaymentStatus::all()->random()->id,
'system_id' => AcquiringPaymentSystem::SBERBANK,
'status_id' => AcquiringPaymentStatus::all()->random()->id,
'payment_type' => SberbankPayment::class,
'payment_id' => factory(SberbankPayment::class)->create()->id,
];
});

$factory->state(AcquiringPayment::class, 'sberbank', function () {
return [
'system_id' => DictAcquiringPaymentSystem::SBERBANK,
'system_id' => AcquiringPaymentSystem::SBERBANK,
'payment_type' => SberbankPayment::class,
'payment_id' => factory(SberbankPayment::class)->create()->id,
];
});

$factory->state(AcquiringPayment::class, 'applePay', function () {
return [
'system_id' => DictAcquiringPaymentSystem::APPLE_PAY,
'system_id' => AcquiringPaymentSystem::APPLE_PAY,
'payment_type' => ApplePayPayment::class,
'payment_id' => factory(ApplePayPayment::class)->create()->id,
];
});

$factory->state(AcquiringPayment::class, 'samsungPay', function () {
return [
'system_id' => DictAcquiringPaymentSystem::SAMSUNG_PAY,
'system_id' => AcquiringPaymentSystem::SAMSUNG_PAY,
'payment_type' => SamsungPayPayment::class,
'payment_id' => factory(SamsungPayPayment::class)->create()->id,
];
});

$factory->state(AcquiringPayment::class, 'googlePay', function () {
return [
'system_id' => DictAcquiringPaymentSystem::GOOGLE_PAY,
'system_id' => AcquiringPaymentSystem::GOOGLE_PAY,
'payment_type' => GooglePayPayment::class,
'payment_id' => factory(GooglePayPayment::class)->create()->id,
];
Expand Down
4 changes: 2 additions & 2 deletions database/factories/AcquiringPaymentOperationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

use Avlyalin\SberbankAcquiring\Models\AcquiringPayment;
use Avlyalin\SberbankAcquiring\Models\AcquiringPaymentOperation;
use Avlyalin\SberbankAcquiring\Models\DictAcquiringPaymentOperationType;
use Avlyalin\SberbankAcquiring\Models\AcquiringPaymentOperationType;
use Faker\Generator as Faker;

$factory->define(AcquiringPaymentOperation::class, function (Faker $faker) {
return [
'user_id' => factory(config('sberbank-acquiring.user.model'))->create()->getKey(),
'payment_id' => factory(AcquiringPayment::class)->create()->id,
'type_id' => DictAcquiringPaymentOperationType::all()->random()->id,
'type_id' => AcquiringPaymentOperationType::all()->random()->id,
'request_json' => json_encode([$faker->word => $faker->word, $faker->word => $faker->word]),
'response_json' => json_encode([$faker->word => $faker->word, $faker->word => $faker->word]),
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

class CreateDictAcquiringPaymentOperationTypesTable extends Migration
class CreateAcquiringPaymentOperationTypesTable extends Migration
{
use HasConfig;

Expand All @@ -18,14 +18,13 @@ class CreateDictAcquiringPaymentOperationTypesTable extends Migration
*/
public function up()
{
$tableName = $this->getTableName('dict_payment_operation_types');
$tableName = $this->getTableName('payment_operation_types');

Schema::create($tableName, function (Blueprint $table) {
$table->increments('id');
$table->date('begin_date')->default('1800-01-01')->comment('Дата начала действия справочного значения');
$table->date('end_date')->default('9999-12-31')->comment('Дата окончания действия справочного значения');
$table->string('name')->comment('Название операции');
$table->string('full_name')->comment('Полное название операции');
$table->boolean('is_active')->default(1)->comment('Флаг действия справочного значения');
$table->timestamp('created_at')->useCurrent();
$table->timestamp('updated_at')->useCurrent();
});
Expand Down Expand Up @@ -60,7 +59,7 @@ public function up()
*/
public function down()
{
$tableName = $this->getTableName('dict_payment_operation_types');
$tableName = $this->getTableName('payment_operation_types');
Schema::dropIfExists($tableName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

class CreateDictAcquiringPaymentStatusesTable extends Migration
class CreateAcquiringPaymentStatusesTable extends Migration
{
use HasConfig;

Expand All @@ -18,15 +18,14 @@ class CreateDictAcquiringPaymentStatusesTable extends Migration
*/
public function up()
{
$tableName = $this->getTableName('dict_payment_statuses');
$tableName = $this->getTableName('payment_statuses');

Schema::create($tableName, function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('bank_id')->nullable()->unique()->comment('id статуса в системе банка');
$table->date('begin_date')->default('1800-01-01')->comment('Дата начала действия справочного значения');
$table->date('end_date')->default('9999-12-31')->comment('Дата окончания действия справочного значения');
$table->string('name')->comment('Имя статуса');
$table->string('full_name')->comment('Полное имя статуса');
$table->boolean('is_active')->default(1)->comment('Флаг действия справочного значения');
$table->timestamp('created_at')->useCurrent();
$table->timestamp('updated_at')->useCurrent();
});
Expand Down Expand Up @@ -54,7 +53,7 @@ public function up()
*/
public function down()
{
$tableName = $this->getTableName('dict_payment_statuses');
$tableName = $this->getTableName('payment_statuses');
Schema::dropIfExists($tableName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

class CreateDictAcquiringPaymentSystemsTable extends Migration
class CreateAcquiringPaymentSystemsTable extends Migration
{
use HasConfig;

Expand All @@ -18,14 +18,13 @@ class CreateDictAcquiringPaymentSystemsTable extends Migration
*/
public function up()
{
$tableName = $this->getTableName('dict_payment_systems');
$tableName = $this->getTableName('payment_systems');

Schema::create($tableName, function (Blueprint $table) {
$table->increments('id');
$table->date('begin_date')->default('1800-01-01')->comment('Дата начала действия справочного значения');
$table->date('end_date')->default('9999-12-31')->comment('Дата окончания действия справочного значения');
$table->string('name')->comment('Имя системы');
$table->string('full_name')->comment('Полное имя системы');
$table->boolean('is_active')->default(1)->comment('Флаг действия справочного значения');
$table->timestamp('created_at')->useCurrent();
$table->timestamp('updated_at')->useCurrent();
});
Expand All @@ -48,7 +47,7 @@ public function up()
*/
public function down()
{
$tableName = $this->getTableName('dict_payment_systems');
$tableName = $this->getTableName('payment_systems');
Schema::dropIfExists($tableName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class CreateAcquiringPaymentsTable extends Migration
public function up()
{
$tableName = $this->getTableName('payments');
$statusesTableName = $this->getTableName('dict_payment_statuses');
$systemsTableName = $this->getTableName('dict_payment_systems');
$statusesTableName = $this->getTableName('payment_statuses');
$systemsTableName = $this->getTableName('payment_systems');

Schema::create($tableName, function (Blueprint $table) use ($tableName, $statusesTableName, $systemsTableName) {
$table->bigIncrements('id');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function up()
{
$tableName = $this->getTableName('payment_operations');
$paymentsTableName = $this->getTableName('payments');
$operationTypesTableName = $this->getTableName('dict_payment_operation_types');
$operationTypesTableName = $this->getTableName('payment_operation_types');

Schema::create(
$tableName,
Expand Down Expand Up @@ -58,7 +58,7 @@ public function down()
{
$tableName = $this->getTableName('payment_operations');
$paymentsTableName = $this->getTableName('payments');
$operationTypesTableName = $this->getTableName('dict_payment_operation_types');
$operationTypesTableName = $this->getTableName('payment_operation_types');

if (DB::getDriverName() !== 'sqlite') {
Schema::table(
Expand Down
Loading

0 comments on commit 46c4c01

Please sign in to comment.