Compare commits
12 Commits
6f35d5d9c9
...
cf65e36d24
| Author | SHA1 | Date |
|---|---|---|
|
|
cf65e36d24 | |
|
|
8d12c0ff79 | |
|
|
3664431931 | |
|
|
f797950b4c | |
|
|
cd0bcedfad | |
|
|
93931f7915 | |
|
|
9e90d5f9cf | |
|
|
6311451d61 | |
|
|
5e55b85107 | |
|
|
89d7d78ccc | |
|
|
e024d8752d | |
|
|
8f6727ae75 |
|
|
@ -403,9 +403,6 @@ export class ShopyyAdapter implements ISiteAdapter {
|
|||
mapCreateOrderParams(data: Partial<UnifiedOrderDTO>): any {
|
||||
return data
|
||||
}
|
||||
mapProductQuery(query: UnifiedSearchParamsDTO): ShopyyProductQuery {
|
||||
return this.mapSearchParams(query)
|
||||
}
|
||||
|
||||
mapUpdateOrderParams(data: Partial<UnifiedOrderDTO>): any {
|
||||
// 构建 ShopYY 订单更新参数(仅包含传入的字段)
|
||||
|
|
@ -980,18 +977,6 @@ export class ShopyyAdapter implements ISiteAdapter {
|
|||
return product
|
||||
}
|
||||
|
||||
// 通过sku获取产品详情的私有方法
|
||||
private async getProductBySku(sku: string): Promise<UnifiedProductDTO> {
|
||||
// 使用Shopyy API的搜索功能通过sku查询产品
|
||||
const response = await this.getAllProducts({ where: {sku} });
|
||||
console.log('getProductBySku', response)
|
||||
const product = response?.[0]
|
||||
if (!product) {
|
||||
throw new Error(`未找到sku为${sku}的产品`);
|
||||
}
|
||||
return product
|
||||
}
|
||||
|
||||
async batchProcessProducts(
|
||||
data: { create?: any[]; update?: any[]; delete?: Array<string | number> }
|
||||
): Promise<any> {
|
||||
|
|
@ -1194,10 +1179,7 @@ export class ShopyyAdapter implements ISiteAdapter {
|
|||
}
|
||||
|
||||
// ========== Webhook映射方法 ==========
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
>>>>>>> 89d7d78 (refactor(api): 统一接口参数为对象形式并支持多条件查询)
|
||||
|
||||
mapUnifiedToPlatformWebhook(data: Partial<UnifiedWebhookDTO>) {
|
||||
return data
|
||||
|
|
|
|||
|
|
@ -55,15 +55,6 @@ export class WooCommerceAdapter implements ISiteAdapter {
|
|||
mapUpdateVariationParams(data: UpdateVariationDTO) {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
batchProcessProducts?(data: BatchOperationDTO): Promise<BatchOperationResultDTO> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
mapCreateVariationParams(data: CreateVariationDTO) {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
mapUpdateVariationParams(data: UpdateVariationDTO) {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
// ========== 客户映射方法 ==========
|
||||
|
||||
|
|
@ -403,30 +394,53 @@ export class WooCommerceAdapter implements ISiteAdapter {
|
|||
// 将 WooCommerce 订单数据映射为统一订单DTO
|
||||
// 包含账单地址与收货地址以及创建与更新时间
|
||||
|
||||
// 产品操作方法
|
||||
async getProduct(id: string | number): Promise<UnifiedProductDTO> {
|
||||
// 获取单个产品详情并映射为统一产品DTO
|
||||
const api = (this.wpService as any).createApi(this.site, 'wc/v3');
|
||||
const res = await api.get(`products/${id}`);
|
||||
const product = res.data;
|
||||
// 映射物流追踪信息,将后端格式转换为前端期望的格式
|
||||
const fulfillments = (item.fulfillments || []).map((track: any) => ({
|
||||
tracking_number: track.tracking_number || '',
|
||||
shipping_provider: track.shipping_provider || '',
|
||||
shipping_method: track.shipping_method || '',
|
||||
status: track.status || '',
|
||||
date_created: track.date_created || '',
|
||||
items: track.items || [],
|
||||
}));
|
||||
|
||||
// 如果产品类型是 variable 且有变体 ID 列表,则加载完整的变体数据
|
||||
if (product.type === 'variable' && product.variations && Array.isArray(product.variations) && product.variations.length > 0) {
|
||||
try {
|
||||
// 批量获取该产品的所有变体数据
|
||||
const variations = await this.wpService.sdkGetAll(
|
||||
api,
|
||||
`products/${product.id}/variations`
|
||||
);
|
||||
// 将完整的变体数据添加到产品对象中
|
||||
product.variations = variations;
|
||||
} catch (error) {
|
||||
// 如果获取变体失败,保持原有的 ID 数组
|
||||
console.error(`获取产品 ${product.id} 的变体数据失败:`, error);
|
||||
}
|
||||
}
|
||||
|
||||
return this.mapProduct(product);
|
||||
return {
|
||||
id: item.id,
|
||||
number: item.number,
|
||||
status: item.status,
|
||||
currency: item.currency,
|
||||
total: item.total,
|
||||
customer_id: item.customer_id,
|
||||
customer_email: item.billing?.email || '', // TODO 与 email 重复 保留一个即可
|
||||
email: item.billing?.email || '',
|
||||
customer_name: `${item.billing?.first_name || ''} ${item.billing?.last_name || ''}`.trim(),
|
||||
refunds: item.refunds?.map?.(refund => ({
|
||||
id: refund.id,
|
||||
reason: refund.reason,
|
||||
total: refund.total,
|
||||
})),
|
||||
line_items: (item.line_items as any[]).map(li => ({
|
||||
...li,
|
||||
productId: li.product_id,
|
||||
})),
|
||||
customer_ip_address: item.customer_ip_address ?? '',
|
||||
date_paid: item.date_paid ?? '',
|
||||
utm_source: item?.meta_data?.find(el => el.key === '_wc_order_attribution_utm_source')?.value || '',
|
||||
device_type: item?.meta_data?.find(el => el.key === '_wc_order_attribution_device_type')?.value || '',
|
||||
source_type: item?.meta_data?.find(el => el.key === '_wc_order_attribution_source_type')?.value || '',
|
||||
billing: item.billing,
|
||||
shipping: item.shipping,
|
||||
billing_full_address: this.buildFullAddress(item.billing),
|
||||
shipping_full_address: this.buildFullAddress(item.shipping),
|
||||
payment_method: item.payment_method_title,
|
||||
date_created: item.date_created,
|
||||
date_modified: item.date_modified,
|
||||
shipping_lines: item.shipping_lines,
|
||||
fee_lines: item.fee_lines,
|
||||
coupon_lines: item.coupon_lines,
|
||||
fulfillments,
|
||||
raw: item,
|
||||
};
|
||||
}
|
||||
|
||||
// 订单操作方法
|
||||
|
|
|
|||
|
|
@ -36,13 +36,11 @@ export interface ISiteAdapter {
|
|||
mapUnifiedToPlatformCustomer(data: Partial<UnifiedCustomerDTO>): any;
|
||||
|
||||
/**
|
||||
* 获取单个客户
|
||||
* 获取单个客户
|
||||
*/
|
||||
getCustomer(where: Partial<Pick<UnifiedCustomerDTO, 'id' | 'email' | 'phone'>>): Promise<UnifiedCustomerDTO>;
|
||||
|
||||
/**
|
||||
* 获取客户列表
|
||||
* 获取客户列表
|
||||
*/
|
||||
getCustomers(params: UnifiedSearchParamsDTO): Promise<UnifiedPaginationDTO<UnifiedCustomerDTO>>;
|
||||
|
|
@ -70,7 +68,6 @@ export interface ISiteAdapter {
|
|||
/**
|
||||
* 批量处理客户
|
||||
*/
|
||||
|
||||
batchProcessCustomers?(data: BatchOperationDTO): Promise<BatchOperationResultDTO>;
|
||||
|
||||
// ========== 媒体映射方法 ==========
|
||||
|
|
|
|||
Loading…
Reference in New Issue