From 7b4cbfd53a3825e2c9ba149daa6d6ff180e77288 Mon Sep 17 00:00:00 2001 From: zhuotianyuan Date: Fri, 10 Oct 2025 16:03:25 +0800 Subject: [PATCH] =?UTF-8?q?20251010-zhuotianyuan-=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=A1=A8=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/entity/order_items_original.entity.ts | 113 ++++++++++++++++++++++ src/service/order.service.ts | 2 +- 2 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 src/entity/order_items_original.entity.ts diff --git a/src/entity/order_items_original.entity.ts b/src/entity/order_items_original.entity.ts new file mode 100644 index 0000000..d5f2232 --- /dev/null +++ b/src/entity/order_items_original.entity.ts @@ -0,0 +1,113 @@ +import { ApiProperty } from '@midwayjs/swagger'; +import { Exclude, Expose } from 'class-transformer'; +import { + Column, + CreateDateColumn, + Entity, + JoinColumn, + ManyToOne, + PrimaryGeneratedColumn, + UpdateDateColumn, +} from 'typeorm'; +import { Order } from './order.entity'; + + +@Entity('order_item_original') +@Exclude() +export class OrderItemOriginal { + @ApiProperty() + @PrimaryGeneratedColumn() + @Expose() + id: number; + + @ApiProperty() + @ManyToOne(() => Order) + @JoinColumn({ name: 'order_id' }) + @Column({ name: 'order_id' }) + @Expose() + orderId: number; // 订单 ID + + + @ApiProperty() + @Column() + @Expose() + name: string; + + @ApiProperty() + @Column() + @Expose() + siteId: string; // 来源站点唯一标识 + + @ApiProperty() + @Column() + @Expose() + externalOrderId: string; // WooCommerce 订单 ID + + @ApiProperty() + @Column({ nullable: true }) + @Expose() + externalOrderItemId: string; // WooCommerce 订单item ID + + @ApiProperty() + @Column() + @Expose() + externalProductId: string; // WooCommerce 产品 ID + + @ApiProperty() + @Column() + @Expose() + externalVariationId: string; // WooCommerce 变体 ID + + @ApiProperty() + @Column() + @Expose() + quantity: number; + + @ApiProperty() + @Column('decimal', { precision: 10, scale: 2, nullable: true }) + @Expose() + subtotal: number; + + @ApiProperty() + @Column('decimal', { precision: 10, scale: 2, nullable: true }) + @Expose() + subtotal_tax: number; + + @ApiProperty() + @Column('decimal', { precision: 10, scale: 2, nullable: true }) + @Expose() + total: number; + + @ApiProperty() + @Column('decimal', { precision: 10, scale: 2, nullable: true }) + @Expose() + total_tax: number; + + @ApiProperty() + @Column({ nullable: true }) + @Expose() + sku?: string; + + @ApiProperty() + @Column('decimal', { precision: 10, scale: 2 }) + @Expose() + price: number; + + @ApiProperty({ + example: '2022-12-12 11:11:11', + description: '创建时间', + required: true, + }) + @CreateDateColumn() + @Expose() + createdAt: Date; + + @ApiProperty({ + example: '2022-12-12 11:11:11', + description: '更新时间', + required: true, + }) + @UpdateDateColumn() + @Expose() + updatedAt: Date; +} \ No newline at end of file diff --git a/src/service/order.service.ts b/src/service/order.service.ts index 6662104..a37045c 100644 --- a/src/service/order.service.ts +++ b/src/service/order.service.ts @@ -213,7 +213,7 @@ export class OrderService { el => el.key === '_wc_order_attribution_utm_source' )?.value || ''; order.customer_email = order?.billing?.email || order?.shipping?.email; - order.billing_phone = order?.billing?.phone || order?.shipping?.phone; + // order.billing_phone = order?.billing?.phone || order?.shipping?.phone; const entity = plainToClass(Order, order); const existingOrder = await this.orderModel.findOne({ where: { externalOrderId: order.externalOrderId, siteId: siteId },