Skip to content

Commit dee8fd2

Browse files
committed
feat(alipay): add alipay
1 parent 4d44690 commit dee8fd2

24 files changed

+463
-452
lines changed

example.env

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@ OBB_GOOGLE_REDIRECT_URI=
3636
OBB_ALIPAY_APPID=
3737
OBB_ALIPAY_CERT_PATH=
3838
OBB_ALIPAY_KEY_PATH=
39+
OBB_ALIPAY_RETURN_URL=
3940

4041
OBB_WECHAT_APP_KEY=
4142
OBB_WECHAT_PAY_APPID=
4243
OBB_WECHAT_PAY_MCHID=
4344
OBB_WECHAT_PAY_SERIAL=
4445
OBB_WECHAT_PAY_CERT_PATH=
45-
OBB_WECHAT_PAY_KEY_PATH=
46+
OBB_WECHAT_PAY_KEY_PATH=

src/i18n/en/order.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"errors": {
3+
"orderNotFound": "Order not found",
4+
"orderStatusIncorrect": "Order status is incorrect, cannot mark as paid",
5+
"paidOrderCannotClose": "Paid order cannot be closed",
6+
"onlyPaidOrderCanRefund": "Only paid orders can be refunded"
7+
}
8+
}

src/i18n/en/pay.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"errors": {
3+
"invalidParameter": "Invalid parameter",
4+
"signatureVerificationFailed": "Signature verification failed",
5+
"missingRequiredParameters": "Missing required parameters",
6+
"orderAmountMismatch": "Order amount mismatch",
7+
"cannotGetUserIP": "Cannot get user's valid IP, unable to create order"
8+
}
9+
}

src/i18n/en/product.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"errors": {
3+
"productNotFound": "Product not found"
4+
}
5+
}

src/i18n/zh/order.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"errors": {
3+
"orderNotFound": "订单不存在",
4+
"orderStatusIncorrect": "订单状态不正确,无法标记为已支付",
5+
"paidOrderCannotClose": "已支付的订单无法关闭",
6+
"onlyPaidOrderCanRefund": "只有已支付的订单才能退款"
7+
}
8+
}

src/i18n/zh/pay.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"errors": {
3+
"invalidParameter": "参数错误",
4+
"signatureVerificationFailed": "签名验证失败",
5+
"missingRequiredParameters": "缺少必要参数",
6+
"orderAmountMismatch": "订单金额不匹配",
7+
"cannotGetUserIP": "无法获取用户有效IP,无法创建订单"
8+
}
9+
}

src/i18n/zh/product.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"errors": {
3+
"productNotFound": "产品不存在"
4+
}
5+
}

src/orders/dto/create-order.dto.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IsString, IsNumber, IsEnum, IsOptional, Min } from 'class-validator';
1+
import { IsString, IsEnum } from 'class-validator';
22
import {
33
PaymentMethod,
44
PaymentType,
@@ -8,19 +8,9 @@ export class CreateOrderDto {
88
@IsString()
99
productId: string;
1010

11-
@IsNumber()
12-
@Min(1)
13-
amount: number;
14-
15-
@IsString()
16-
description: string;
17-
1811
@IsEnum(PaymentMethod)
1912
paymentMethod: PaymentMethod;
2013

2114
@IsEnum(PaymentType)
2215
paymentType: PaymentType;
23-
24-
@IsOptional()
25-
metadata?: Record<string, any>;
2616
}

src/orders/dto/update-order.dto.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,4 @@ export class UpdateOrderDto {
99
@IsOptional()
1010
@IsString()
1111
thirdPartyOrderNo?: string;
12-
13-
@IsOptional()
14-
metadata?: Record<string, any>;
1512
}

src/orders/entities/order.entity.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Base } from 'omniboxd/common/base.entity';
2-
import { Entity, Column, PrimaryGeneratedColumn, Index } from 'typeorm';
2+
import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm';
33

44
export enum OrderStatus {
55
PENDING = 'pending',
@@ -25,11 +25,9 @@ export class Order extends Base {
2525
id: string;
2626

2727
@Column('varchar', { unique: true })
28-
@Index()
2928
orderNo: string;
3029

3130
@Column('varchar')
32-
@Index()
3331
userId: string;
3432

3533
@Column('varchar', { nullable: true })
@@ -46,7 +44,6 @@ export class Order extends Base {
4644
enum: OrderStatus,
4745
default: OrderStatus.PENDING,
4846
})
49-
@Index()
5047
status: OrderStatus;
5148

5249
@Column({
@@ -64,15 +61,11 @@ export class Order extends Base {
6461
paymentType: PaymentType | null;
6562

6663
@Column('varchar', { nullable: true })
67-
@Index()
68-
thirdPartyOrderNo: string | null; // 第三方支付平台订单号(微信/支付宝)
64+
thirdPartyOrderNo: string | null;
6965

7066
@Column('varchar')
7167
description: string;
7268

73-
@Column('jsonb', { nullable: true })
74-
metadata: Record<string, any> | null; // 其他元数据
75-
7669
@Column('timestamptz', { nullable: true })
7770
paidAt: Date | null;
7871

0 commit comments

Comments
 (0)