main #49

Merged
zhuotianyuan merged 6 commits from zhuotianyuan/API:main into main 2026-01-14 11:45:32 +00:00
6 changed files with 36 additions and 2667 deletions
Showing only changes of commit f7335d9717 - Show all commits

View File

@ -22,7 +22,7 @@ import {
CreateVariationDTO,
UpdateReviewDTO,
} from '../dto/site-api.dto';
import { UnifiedPaginationDTO, UnifiedSearchParamsDTO, } from '../dto/api.dto';
import { UnifiedPaginationDTO, UnifiedSearchParamsDTO, ShopyyGetAllOrdersParams } from '../dto/api.dto';
import {
ShopyyAllProductQuery,
ShopyyCustomer,
@ -37,6 +37,7 @@ import {
OrderStatus,
} from '../enums/base.enum';
import { BatchOperationDTO, BatchOperationResultDTO } from '../dto/batch.dto';
import dayjs = require('dayjs');
export class ShopyyAdapter implements ISiteAdapter {
shopyyFinancialStatusMap= {
'200': '待支付',
@ -559,9 +560,21 @@ export class ShopyyAdapter implements ISiteAdapter {
per_page,
};
}
mapGetAllOrdersParams(params: UnifiedSearchParamsDTO) :ShopyyGetAllOrdersParams{
const pay_at_min = dayjs(params.after || '').valueOf().toString();
const pay_at_max = dayjs(params.before || '').valueOf().toString();
return {
page: params.page || 1,
per_page: params.per_page || 20,
pay_at_min: pay_at_min,
pay_at_max: pay_at_max,
}
}
async getAllOrders(params?: UnifiedSearchParamsDTO): Promise<UnifiedOrderDTO[]> {
const data = await this.shopyyService.getAllOrders(this.site.id, params);
const normalizedParams = this.mapGetAllOrdersParams(params);
const data = await this.shopyyService.getAllOrders(this.site.id, normalizedParams);
return data.map(this.mapPlatformToUnifiedOrder.bind(this));
}

View File

@ -52,6 +52,23 @@ export class UnifiedSearchParamsDTO<Where=Record<string, any>> {
orderBy?: Record<string, 'asc' | 'desc'> | string;
}
/**
* Shopyy获取所有订单参数DTO
*/
export class ShopyyGetAllOrdersParams {
@ApiProperty({ description: '页码', example: 1, required: false })
page?: number;
@ApiProperty({ description: '每页数量', example: 20, required: false })
per_page?: number;
@ApiProperty({ description: '支付时间范围开始', example: '2023-01-01T00:00:00Z', required: false })
pay_at_min?: string;
@ApiProperty({ description: '支付时间范围结束', example: '2023-01-01T23:59:59Z', required: false })
pay_at_max?: string;
}
/**
*
*/

View File

@ -172,7 +172,7 @@ export class FreightwavesService {
private async sendRequest<T>(url: string, data: any): Promise<FreightwavesResponse<T>> {
try {
// 设置请求头 - 使用太平洋时间 (America/Los_Angeles)
const date = dayjs().tz('America/Los_Angeles').format('YYYY-MM-DD HH:mm:ss');
const date = dayjs().tz('America/Los_Angeles').format('YYYY-mm-dd HH:mm:ss');
const headers = {
'Content-Type': 'application/json',
'requestDate': date,
@ -267,7 +267,7 @@ export class FreightwavesService {
partner: this.config.partner,
};
const response = await this.sendRequest<CreateOrderResponseData>('/shipService/order/createOrder', requestData);
const response = await this.sendRequest<CreateOrderResponseData>('/shipService/order/createOrder?apipost_id=0422aa', requestData);
return response.data;
}
@ -423,7 +423,7 @@ export class FreightwavesService {
// 设置必要的配置
this.setConfig({
appSecret: 'gELCHguGmdTLo!zfihfM91hae8G@9Sz23Mh6pHrt',
apiBaseUrl: 'https://tms.freightwaves.ca',
apiBaseUrl: 'https://console-mock.apipost.cn/mock/0',
partner: '25072621035200000060'
});

File diff suppressed because it is too large Load Diff

View File

@ -2644,8 +2644,6 @@ export class OrderService {
throw new Error(`导出CSV文件失败: ${error.message}`);
}
}
}
<<<<<<< HEAD
/**
*
@ -2722,11 +2720,4 @@ export class OrderService {
return result;
}
}
=======
>>>>>>> 68574dbc7a74e0f8130f195eba4a28dd3887c485

View File

@ -313,7 +313,6 @@ export class ShopyyService {
const { items: firstPageItems, totalPages} = firstPage;
// const { page = 1, per_page = 100 } = params;
// 如果只有一页数据,直接返回
if (totalPages <= 1) {
return firstPageItems;
@ -334,7 +333,7 @@ export class ShopyyService {
// 创建当前批次的并发请求
for (let i = 0; i < batchSize; i++) {
const page = currentPage + i;
const pagePromise = this.getOrders(site, page, 100)
const pagePromise = this.getOrders(site, page, 100, params)
.then(pageResult => pageResult.items)
.catch(error => {
console.error(`获取第 ${page} 页数据失败:`, error);