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