AnhLedger commited on
Commit
e1abcaf
1 Parent(s): f2ebae3

modify payment

Browse files
backend/src/entities/payment.entity.ts CHANGED
@@ -7,8 +7,6 @@ import {
7
  Relation,
8
  } from 'typeorm';
9
  import { OrderEntity } from './order.entity.js';
10
- import { PaymentMethod } from '../common/enums/PaymentMethod.enum.js';
11
- import { VnpCardType } from '../common/enums/VnpCardType.enum.js';
12
 
13
  @Entity('payments')
14
  export class PaymentEntity extends BaseEntity {
@@ -18,36 +16,33 @@ export class PaymentEntity extends BaseEntity {
18
  @OneToOne(() => OrderEntity, (a) => a.payment)
19
  order: Relation<OrderEntity>;
20
 
21
- @Column({ type: 'enum', enum: PaymentMethod, default: 0 })
22
- payment_method: PaymentMethod;
23
 
24
  @Column()
25
  vnp_amount: number
26
 
27
- @Column()
28
  vnp_bank_code: string
29
 
30
- @Column()
31
  vnp_bank_tran_no:string
32
 
33
- @Column({ type: 'enum', enum: VnpCardType, default: 0})
34
- vnp_card_type: VnpCardType
35
 
36
- @Column()
37
- vnp_order_info: string
38
 
39
- @Column()
40
  vnp_paydate: string
41
 
42
- @Column()
43
  vnp_response_code: number
44
 
45
- @Column()
46
  vnp_transaction_no: string
47
 
48
- @Column()
49
  vnp_transaction_status: number
50
-
51
- @Column()
52
- vnp_securehash: string
53
  }
 
7
  Relation,
8
  } from 'typeorm';
9
  import { OrderEntity } from './order.entity.js';
 
 
10
 
11
  @Entity('payments')
12
  export class PaymentEntity extends BaseEntity {
 
16
  @OneToOne(() => OrderEntity, (a) => a.payment)
17
  order: Relation<OrderEntity>;
18
 
19
+ @Column({ default: 0 })
20
+ payment_method: number;
21
 
22
  @Column()
23
  vnp_amount: number
24
 
25
+ @Column({ nullable: true })
26
  vnp_bank_code: string
27
 
28
+ @Column({ nullable: true })
29
  vnp_bank_tran_no:string
30
 
31
+ @Column({ default: 0})
32
+ vnp_card_type: number
33
 
34
+ @Column({ nullable: true })
35
+ vnp_order_info: string //Nội dung giao dịch
36
 
37
+ @Column({ nullable: true })
38
  vnp_paydate: string
39
 
40
+ @Column({ nullable: true })
41
  vnp_response_code: number
42
 
43
+ @Column({ nullable: true })
44
  vnp_transaction_no: string
45
 
46
+ @Column({ nullable: true })
47
  vnp_transaction_status: number
 
 
 
48
  }
backend/src/migrations/{1730648552709-modify_payment.ts → 1730650476355-modify_payment.ts} RENAMED
@@ -1,36 +1,40 @@
1
  import { MigrationInterface, QueryRunner } from "typeorm";
2
 
3
- export class ModifyPayment1730648552709 implements MigrationInterface {
4
- name = 'ModifyPayment1730648552709'
5
 
6
  public async up(queryRunner: QueryRunner): Promise<void> {
7
- await queryRunner.query(`ALTER TYPE "public"."payments_payment_method_enum" RENAME TO "payments_payment_method_enum_old"`);
8
- await queryRunner.query(`CREATE TYPE "public"."payments_payment_method_enum" AS ENUM('0', '1', '2')`);
9
- await queryRunner.query(`ALTER TABLE "payments" ALTER COLUMN "payment_method" DROP DEFAULT`);
10
- await queryRunner.query(`ALTER TABLE "payments" ALTER COLUMN "payment_method" TYPE "public"."payments_payment_method_enum" USING "payment_method"::"text"::"public"."payments_payment_method_enum"`);
11
- await queryRunner.query(`ALTER TABLE "payments" ALTER COLUMN "payment_method" SET DEFAULT '0'`);
12
- await queryRunner.query(`DROP TYPE "public"."payments_payment_method_enum_old"`);
13
- await queryRunner.query(`ALTER TYPE "public"."payments_vnp_card_type_enum" RENAME TO "payments_vnp_card_type_enum_old"`);
14
- await queryRunner.query(`CREATE TYPE "public"."payments_vnp_card_type_enum" AS ENUM('0', '1', '2')`);
15
- await queryRunner.query(`ALTER TABLE "payments" ALTER COLUMN "vnp_card_type" DROP DEFAULT`);
16
- await queryRunner.query(`ALTER TABLE "payments" ALTER COLUMN "vnp_card_type" TYPE "public"."payments_vnp_card_type_enum" USING "vnp_card_type"::"text"::"public"."payments_vnp_card_type_enum"`);
17
- await queryRunner.query(`ALTER TABLE "payments" ALTER COLUMN "vnp_card_type" SET DEFAULT '0'`);
18
- await queryRunner.query(`DROP TYPE "public"."payments_vnp_card_type_enum_old"`);
 
 
19
  }
20
 
21
  public async down(queryRunner: QueryRunner): Promise<void> {
22
- await queryRunner.query(`CREATE TYPE "public"."payments_vnp_card_type_enum_old" AS ENUM('ATM', 'QRCODE', 'None')`);
23
- await queryRunner.query(`ALTER TABLE "payments" ALTER COLUMN "vnp_card_type" DROP DEFAULT`);
24
- await queryRunner.query(`ALTER TABLE "payments" ALTER COLUMN "vnp_card_type" TYPE "public"."payments_vnp_card_type_enum_old" USING "vnp_card_type"::"text"::"public"."payments_vnp_card_type_enum_old"`);
25
- await queryRunner.query(`ALTER TABLE "payments" ALTER COLUMN "vnp_card_type" SET DEFAULT 'None'`);
26
- await queryRunner.query(`DROP TYPE "public"."payments_vnp_card_type_enum"`);
27
- await queryRunner.query(`ALTER TYPE "public"."payments_vnp_card_type_enum_old" RENAME TO "payments_vnp_card_type_enum"`);
28
- await queryRunner.query(`CREATE TYPE "public"."payments_payment_method_enum_old" AS ENUM('CASH', 'CARD', 'ONLINE_PAYMENT')`);
29
- await queryRunner.query(`ALTER TABLE "payments" ALTER COLUMN "payment_method" DROP DEFAULT`);
30
- await queryRunner.query(`ALTER TABLE "payments" ALTER COLUMN "payment_method" TYPE "public"."payments_payment_method_enum_old" USING "payment_method"::"text"::"public"."payments_payment_method_enum_old"`);
31
- await queryRunner.query(`ALTER TABLE "payments" ALTER COLUMN "payment_method" SET DEFAULT 'CASH'`);
32
- await queryRunner.query(`DROP TYPE "public"."payments_payment_method_enum"`);
33
- await queryRunner.query(`ALTER TYPE "public"."payments_payment_method_enum_old" RENAME TO "payments_payment_method_enum"`);
 
 
34
  }
35
 
36
  }
 
1
  import { MigrationInterface, QueryRunner } from "typeorm";
2
 
3
+ export class ModifyPayment1730650476355 implements MigrationInterface {
4
+ name = 'ModifyPayment1730650476355'
5
 
6
  public async up(queryRunner: QueryRunner): Promise<void> {
7
+ await queryRunner.query(`ALTER TABLE "payments" DROP COLUMN "vnp_securehash"`);
8
+ await queryRunner.query(`ALTER TABLE "payments" DROP COLUMN "payment_method"`);
9
+ await queryRunner.query(`DROP TYPE "public"."payments_payment_method_enum"`);
10
+ await queryRunner.query(`ALTER TABLE "payments" ADD "payment_method" integer NOT NULL DEFAULT '0'`);
11
+ await queryRunner.query(`ALTER TABLE "payments" ALTER COLUMN "vnp_bank_code" DROP NOT NULL`);
12
+ await queryRunner.query(`ALTER TABLE "payments" ALTER COLUMN "vnp_bank_tran_no" DROP NOT NULL`);
13
+ await queryRunner.query(`ALTER TABLE "payments" DROP COLUMN "vnp_card_type"`);
14
+ await queryRunner.query(`DROP TYPE "public"."payments_vnp_card_type_enum"`);
15
+ await queryRunner.query(`ALTER TABLE "payments" ADD "vnp_card_type" integer NOT NULL DEFAULT '0'`);
16
+ await queryRunner.query(`ALTER TABLE "payments" ALTER COLUMN "vnp_order_info" DROP NOT NULL`);
17
+ await queryRunner.query(`ALTER TABLE "payments" ALTER COLUMN "vnp_paydate" DROP NOT NULL`);
18
+ await queryRunner.query(`ALTER TABLE "payments" ALTER COLUMN "vnp_response_code" DROP NOT NULL`);
19
+ await queryRunner.query(`ALTER TABLE "payments" ALTER COLUMN "vnp_transaction_no" DROP NOT NULL`);
20
+ await queryRunner.query(`ALTER TABLE "payments" ALTER COLUMN "vnp_transaction_status" DROP NOT NULL`);
21
  }
22
 
23
  public async down(queryRunner: QueryRunner): Promise<void> {
24
+ await queryRunner.query(`ALTER TABLE "payments" ALTER COLUMN "vnp_transaction_status" SET NOT NULL`);
25
+ await queryRunner.query(`ALTER TABLE "payments" ALTER COLUMN "vnp_transaction_no" SET NOT NULL`);
26
+ await queryRunner.query(`ALTER TABLE "payments" ALTER COLUMN "vnp_response_code" SET NOT NULL`);
27
+ await queryRunner.query(`ALTER TABLE "payments" ALTER COLUMN "vnp_paydate" SET NOT NULL`);
28
+ await queryRunner.query(`ALTER TABLE "payments" ALTER COLUMN "vnp_order_info" SET NOT NULL`);
29
+ await queryRunner.query(`ALTER TABLE "payments" DROP COLUMN "vnp_card_type"`);
30
+ await queryRunner.query(`CREATE TYPE "public"."payments_vnp_card_type_enum" AS ENUM('0', '1', '2')`);
31
+ await queryRunner.query(`ALTER TABLE "payments" ADD "vnp_card_type" "public"."payments_vnp_card_type_enum" NOT NULL DEFAULT '0'`);
32
+ await queryRunner.query(`ALTER TABLE "payments" ALTER COLUMN "vnp_bank_tran_no" SET NOT NULL`);
33
+ await queryRunner.query(`ALTER TABLE "payments" ALTER COLUMN "vnp_bank_code" SET NOT NULL`);
34
+ await queryRunner.query(`ALTER TABLE "payments" DROP COLUMN "payment_method"`);
35
+ await queryRunner.query(`CREATE TYPE "public"."payments_payment_method_enum" AS ENUM('0', '1', '2')`);
36
+ await queryRunner.query(`ALTER TABLE "payments" ADD "payment_method" "public"."payments_payment_method_enum" NOT NULL DEFAULT '0'`);
37
+ await queryRunner.query(`ALTER TABLE "payments" ADD "vnp_securehash" character varying NOT NULL`);
38
  }
39
 
40
  }