diff --git a/src/adapter/shopyy.adapter.ts b/src/adapter/shopyy.adapter.ts index 7365fcd..9a3894d 100644 --- a/src/adapter/shopyy.adapter.ts +++ b/src/adapter/shopyy.adapter.ts @@ -275,6 +275,7 @@ export class ShopyyAdapter implements ISiteAdapter { state: shipping.province || item.shipping_zone || '', postcode: shipping.zip || item.shipping_postcode || '', method_title: item.payment_method || '', + phone: shipping.phone || (item as any).telephone || '', country: shipping.country_name || shipping.country_code || @@ -315,7 +316,7 @@ export class ShopyyAdapter implements ISiteAdapter { const lineItems: UnifiedOrderLineItemDTO[] = (item.products || []).map( (product) => ({ id: product.id, - name: product.product_title || product.name, + name:product.sku_value?.[0]?.value || product.product_title || product.name, product_id: product.product_id, quantity: product.quantity, total: String(product.price ?? ''), @@ -572,14 +573,14 @@ export class ShopyyAdapter implements ISiteAdapter { } mapGetAllOrdersParams(params: UnifiedSearchParamsDTO) :ShopyyGetAllOrdersParams{ - const pay_at_min = dayjs(params.after || '').valueOf().toString(); - const pay_at_max = dayjs(params.before || '').valueOf().toString(); + const pay_at_min = dayjs(params.after || '').unix().toString(); + const pay_at_max = dayjs(params.before || '').unix().toString(); return { - page: params.page || 1, - per_page: params.per_page || 20, + per_page: params.per_page || 100, pay_at_min: pay_at_min, pay_at_max: pay_at_max, + order_field: 'pay_at', } } async getAllOrders(params?: UnifiedSearchParamsDTO): Promise { diff --git a/src/config/config.local.ts b/src/config/config.local.ts index b02f922..3894427 100644 --- a/src/config/config.local.ts +++ b/src/config/config.local.ts @@ -12,14 +12,15 @@ export default { // }, // }, // }, - typeorm: { + typeorm: { dataSource: { default: { - host: 'localhost', - port: "23306", + host: '13.212.62.127', + port: "3306", username: 'root', - password: '12345678', + password: 'Yoone!@.2025', database: 'inventory_v2', + synchronize: true }, }, }, diff --git a/src/dto/api.dto.ts b/src/dto/api.dto.ts index bdd7d50..2dd0017 100644 --- a/src/dto/api.dto.ts +++ b/src/dto/api.dto.ts @@ -56,10 +56,7 @@ export class UnifiedSearchParamsDTO> { * Shopyy获取所有订单参数DTO */ export class ShopyyGetAllOrdersParams { - @ApiProperty({ description: '页码', example: 1, required: false }) - page?: number; - - @ApiProperty({ description: '每页数量', example: 20, required: false }) + @ApiProperty({ description: '每页数量', example: 100, required: false }) per_page?: number; @ApiProperty({ description: '支付时间范围开始', example: '2023-01-01T00:00:00Z', required: false }) @@ -67,6 +64,9 @@ export class ShopyyGetAllOrdersParams { @ApiProperty({ description: '支付时间范围结束', example: '2023-01-01T23:59:59Z', required: false }) pay_at_max?: string; + + @ApiProperty({ description: '排序字段', example: 'id', required: false }) + order_field?: string;//排序字段(默认id) id=订单ID updated_at=最后更新时间 pay_at=支付时间 } /** diff --git a/src/dto/shopyy.dto.ts b/src/dto/shopyy.dto.ts index a6c4906..bd708ab 100644 --- a/src/dto/shopyy.dto.ts +++ b/src/dto/shopyy.dto.ts @@ -873,10 +873,10 @@ export interface ShopyyOrder { tax_price?: number; // SKU编码 sku?: string; - // SKU值 - sku_value?: string; + // SKU代码 sku_code?: string; + sku_value?: string | any[]; // 条形码 barcode?: string; // 商品来源 diff --git a/src/service/freightwaves.service.ts b/src/service/freightwaves.service.ts index bcd6ca5..10900ef 100644 --- a/src/service/freightwaves.service.ts +++ b/src/service/freightwaves.service.ts @@ -423,7 +423,7 @@ export class FreightwavesService { // 设置必要的配置 this.setConfig({ appSecret: 'gELCHguGmdTLo!zfihfM91hae8G@9Sz23Mh6pHrt', - apiBaseUrl: 'https://console-mock.apipost.cn/mock/0', + apiBaseUrl: 'https://tms.freightwaves.ca', partner: '25072621035200000060' }); diff --git a/src/service/shopyy.service.ts b/src/service/shopyy.service.ts index 1e623f2..28029bb 100644 --- a/src/service/shopyy.service.ts +++ b/src/service/shopyy.service.ts @@ -10,7 +10,7 @@ import { Site } from '../entity/site.entity'; import { UnifiedReviewDTO } from '../dto/site-api.dto'; import { ShopyyGetOneOrderResult, ShopyyReview } from '../dto/shopyy.dto'; import { BatchOperationDTO, BatchOperationResultDTO } from '../dto/batch.dto'; -import { UnifiedSearchParamsDTO } from '../dto/api.dto'; +import { UnifiedSearchParamsDTO,ShopyyGetAllOrdersParams } from '../dto/api.dto'; /** * ShopYY平台服务实现 */ @@ -288,7 +288,7 @@ export class ShopyyService { * @param pageSize 每页数量 * @returns 分页订单列表 */ - async getOrders(site: any | number, page: number = 1, pageSize: number = 100, params: UnifiedSearchParamsDTO = {}): Promise { + async getOrders(site: any | number, page: number = 1, pageSize: number = 3000, params: ShopyyGetAllOrdersParams = {}): Promise { // 如果传入的是站点ID,则获取站点配置 const siteConfig = typeof site === 'number' ? await this.siteService.get(site) : site; @@ -308,8 +308,8 @@ export class ShopyyService { }; } - async getAllOrders(site: any | number, params: Record = {}, maxPages: number = 10, concurrencyLimit: number = 100): Promise { - const firstPage = await this.getOrders(site, 1, 100); + async getAllOrders(site: any | number, params: ShopyyGetAllOrdersParams = {}, maxPages: number = 10, concurrencyLimit: number = 100): Promise { + const firstPage = await this.getOrders(site, 1, 100, params); const { items: firstPageItems, totalPages} = firstPage; diff --git a/test-freightwaves.js b/test-freightwaves.js index e2a537a..c41c661 100644 --- a/test-freightwaves.js +++ b/test-freightwaves.js @@ -1,6 +1,6 @@ // Test script for FreightwavesService createOrder method -const { FreightwavesService } = require('./dist/service/test-freightwaves.service'); +const { FreightwavesService } = require('./dist/service/freightwaves.service'); async function testFreightwavesService() { try {