add card to card payment method

This commit is contained in:
2026-06-07 16:17:49 +03:30
parent c6c9812fd6
commit caaeb0d34a
7 changed files with 121 additions and 124 deletions
+92 -123
View File
@@ -976,6 +976,16 @@
"primary": false,
"unique": false
},
{
"keyName": "restaurants_slug_index",
"columnNames": [
"slug"
],
"composite": false,
"constraint": false,
"primary": false,
"unique": false
},
{
"keyName": "restaurants_slug_is_active_index",
"columnNames": [
@@ -987,16 +997,6 @@
"primary": false,
"unique": false
},
{
"keyName": "restaurants_is_active_index",
"columnNames": [
"is_active"
],
"composite": false,
"constraint": false,
"primary": false,
"unique": false
},
{
"keyName": "restaurants_pkey",
"columnNames": [
@@ -1076,7 +1076,8 @@
"enumItems": [
"Online",
"Cash",
"Wallet"
"Wallet",
"Cart"
],
"mappedType": "enum"
},
@@ -1102,6 +1103,16 @@
"length": 255,
"mappedType": "string"
},
"card_number": {
"name": "card_number",
"type": "varchar(255)",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": true,
"length": 255,
"mappedType": "string"
},
"enabled": {
"name": "enabled",
"type": "boolean",
@@ -1156,6 +1167,16 @@
"primary": false,
"unique": false
},
{
"keyName": "payment_methods_restaurant_id_index",
"columnNames": [
"restaurant_id"
],
"composite": false,
"constraint": false,
"primary": false,
"unique": false
},
{
"keyName": "payment_methods_restaurant_id_enabled_index",
"columnNames": [
@@ -2146,6 +2167,17 @@
"primary": false,
"unique": false
},
{
"keyName": "categories_restaurant_id_id_index",
"columnNames": [
"restaurant_id",
"id"
],
"composite": true,
"constraint": false,
"primary": false,
"unique": false
},
{
"keyName": "categories_restaurant_id_is_active_index",
"columnNames": [
@@ -2419,27 +2451,6 @@
"primary": false,
"unique": false
},
{
"keyName": "foods_is_active_index",
"columnNames": [
"is_active"
],
"composite": false,
"constraint": false,
"primary": false,
"unique": false
},
{
"keyName": "foods_category_id_is_active_index",
"columnNames": [
"category_id",
"is_active"
],
"composite": true,
"constraint": false,
"primary": false,
"unique": false
},
{
"keyName": "foods_restaurant_id_is_active_index",
"columnNames": [
@@ -2892,17 +2903,6 @@
"primary": false,
"unique": false
},
{
"keyName": "admin_roles_admin_id_restaurant_id_unique",
"columnNames": [
"admin_id",
"restaurant_id"
],
"composite": true,
"constraint": true,
"primary": false,
"unique": true
},
{
"keyName": "admin_roles_pkey",
"columnNames": [
@@ -3140,6 +3140,16 @@
"primary": false,
"unique": false
},
{
"keyName": "schedules_rest_id_index",
"columnNames": [
"rest_id"
],
"composite": false,
"constraint": false,
"primary": false,
"unique": false
},
{
"keyName": "schedules_pkey",
"columnNames": [
@@ -3399,9 +3409,9 @@
"unique": false
},
{
"keyName": "users_is_active_index",
"keyName": "users_phone_index",
"columnNames": [
"is_active"
"phone"
],
"composite": false,
"constraint": false,
@@ -3556,26 +3566,6 @@
"primary": false,
"unique": false
},
{
"keyName": "point_transactions_restaurant_id_index",
"columnNames": [
"restaurant_id"
],
"composite": false,
"constraint": false,
"primary": false,
"unique": false
},
{
"keyName": "point_transactions_user_id_index",
"columnNames": [
"user_id"
],
"composite": false,
"constraint": false,
"primary": false,
"unique": false
},
{
"keyName": "point_transactions_user_id_restaurant_id_index",
"columnNames": [
@@ -3771,6 +3761,16 @@
"primary": false,
"unique": false
},
{
"keyName": "pagers_restaurant_id_index",
"columnNames": [
"restaurant_id"
],
"composite": false,
"constraint": false,
"primary": false,
"unique": false
},
{
"keyName": "pagers_pkey",
"columnNames": [
@@ -4108,16 +4108,6 @@
"primary": false,
"unique": false
},
{
"keyName": "orders_status_index",
"columnNames": [
"status"
],
"composite": false,
"constraint": false,
"primary": false,
"unique": false
},
{
"keyName": "orders_restaurant_id_order_number_index",
"columnNames": [
@@ -4129,17 +4119,6 @@
"primary": false,
"unique": false
},
{
"keyName": "orders_user_id_status_index",
"columnNames": [
"user_id",
"status"
],
"composite": true,
"constraint": false,
"primary": false,
"unique": false
},
{
"keyName": "orders_restaurant_id_status_index",
"columnNames": [
@@ -4152,15 +4131,14 @@
"unique": false
},
{
"keyName": "orders_restaurant_id_order_number_unique",
"keyName": "orders_restaurant_id_index",
"columnNames": [
"restaurant_id",
"order_number"
"restaurant_id"
],
"composite": true,
"constraint": true,
"composite": false,
"constraint": false,
"primary": false,
"unique": true
"unique": false
},
{
"keyName": "orders_pkey",
@@ -4556,7 +4534,8 @@
"enumItems": [
"Online",
"Cash",
"Wallet"
"Wallet",
"Cart"
],
"mappedType": "enum"
},
@@ -4690,6 +4669,16 @@
"primary": false,
"unique": false
},
{
"keyName": "payments_order_id_index",
"columnNames": [
"order_id"
],
"composite": false,
"constraint": false,
"primary": false,
"unique": false
},
{
"keyName": "payments_pkey",
"columnNames": [
@@ -4849,16 +4838,6 @@
"primary": false,
"unique": false
},
{
"keyName": "order_items_food_id_index",
"columnNames": [
"food_id"
],
"composite": false,
"constraint": false,
"primary": false,
"unique": false
},
{
"keyName": "order_items_order_id_index",
"columnNames": [
@@ -5402,6 +5381,16 @@
"primary": false,
"unique": false
},
{
"keyName": "user_addresses_user_id_index",
"columnNames": [
"user_id"
],
"composite": false,
"constraint": false,
"primary": false,
"unique": false
},
{
"keyName": "user_addresses_pkey",
"columnNames": [
@@ -5569,26 +5558,6 @@
"primary": false,
"unique": false
},
{
"keyName": "wallet_transactions_restaurant_id_index",
"columnNames": [
"restaurant_id"
],
"composite": false,
"constraint": false,
"primary": false,
"unique": false
},
{
"keyName": "wallet_transactions_user_id_index",
"columnNames": [
"user_id"
],
"composite": false,
"constraint": false,
"primary": false,
"unique": false
},
{
"keyName": "wallet_transactions_user_id_restaurant_id_index",
"columnNames": [
@@ -0,0 +1,13 @@
import { Migration } from '@mikro-orm/migrations';
export class Migration20260607124425_add_card_number_to_payment_methods extends Migration {
override async up(): Promise<void> {
this.addSql(`alter table "payment_methods" add column "card_number" varchar(255) null;`);
}
override async down(): Promise<void> {
this.addSql(`alter table "payment_methods" drop column "card_number";`);
}
}
@@ -18,6 +18,11 @@ export class CreatePaymentMethodDto {
@IsString()
description?: string;
@ApiProperty({ description: 'Card number for card-to-card payments', required: false })
@IsOptional()
@IsString()
cardNumber?: string;
@ApiProperty({ description: 'Is payment method enabled', required: false, default: true })
@IsOptional()
@IsBoolean()
@@ -20,6 +20,9 @@ export class PaymentMethod extends BaseEntity {
@Property({ nullable: true })
description?: string;
@Property({ nullable: true })
cardNumber?: string;
@Property({ default: true })
enabled: boolean = true;
@@ -4,6 +4,7 @@ export enum PaymentMethodEnum {
Online = 'Online',
Cash = 'Cash',
Wallet = 'Wallet',
Cart = 'Cart',
}
export enum PaymentStatusEnum {
Pending = 'pending',
+1
View File
@@ -6,6 +6,7 @@ export interface PaymentMethodData {
enabled: boolean;
order: number;
gateway: PaymentGatewayEnum | null;
cardNumber?: string;
merchantId?: string;
}
+6 -1
View File
@@ -22,6 +22,7 @@ export class PaymentMethodsSeeder {
enabled: methodData.enabled,
order: methodData.order,
gateway: methodData.gateway,
cardNumber: methodData.cardNumber,
merchantId: methodData.merchantId,
});
em.persist(paymentMethod);
@@ -30,7 +31,8 @@ export class PaymentMethodsSeeder {
if (
existing.description !== methodData.description ||
existing.enabled !== methodData.enabled ||
existing.order !== methodData.order
existing.order !== methodData.order ||
existing.cardNumber !== methodData.cardNumber
) {
existing.description = methodData.description;
existing.enabled = methodData.enabled;
@@ -38,6 +40,9 @@ export class PaymentMethodsSeeder {
if (methodData.gateway !== undefined) {
existing.gateway = methodData.gateway;
}
if (methodData.cardNumber !== undefined) {
existing.cardNumber = methodData.cardNumber;
}
if (methodData.merchantId !== undefined) {
existing.merchantId = methodData.merchantId;
}