feat: 添加产品图片URL字段并优化订单处理逻辑

添加产品实体中的图片URL字段
更新订单服务以支持更多查询参数和分页
修改数据库连接配置为生产环境
调整运费服务API基础URL
优化订单适配器中的字段映射逻辑
This commit is contained in:
zhuotianyuan 2026-01-14 20:07:10 +08:00
parent 408ec8f424
commit f5e4605cce
6 changed files with 22 additions and 20 deletions

View File

@ -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 ?? ''),
@ -573,14 +574,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<UnifiedOrderDTO[]> {

View File

@ -15,11 +15,12 @@ export default {
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
},
},
},

View File

@ -56,10 +56,7 @@ export class UnifiedSearchParamsDTO<Where=Record<string, any>> {
* 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=支付时间
}
/**

View File

@ -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;
// 商品来源

View File

@ -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'
});

View File

@ -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<any> {
async getOrders(site: any | number, page: number = 1, pageSize: number = 3000, params: ShopyyGetAllOrdersParams = {}): Promise<any> {
// 如果传入的是站点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<string, any> = {}, maxPages: number = 10, concurrencyLimit: number = 100): Promise<any> {
const firstPage = await this.getOrders(site, 1, 100);
async getAllOrders(site: any | number, params: ShopyyGetAllOrdersParams = {}, maxPages: number = 10, concurrencyLimit: number = 100): Promise<any> {
const firstPage = await this.getOrders(site, 1, 100, params);
const { items: firstPageItems, totalPages} = firstPage;