Compare commits
No commits in common. "89d7d78cccae2a7ef0e810047bcad950dc70ff97" and "8f6727ae757903b3445d276834decbb53ba3b853" have entirely different histories.
89d7d78ccc
...
8f6727ae75
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -7,6 +7,7 @@ import {
|
||||||
CancelFulfillmentDTO,
|
CancelFulfillmentDTO,
|
||||||
CreateReviewDTO,
|
CreateReviewDTO,
|
||||||
CreateWebhookDTO,
|
CreateWebhookDTO,
|
||||||
|
FulfillmentDTO,
|
||||||
UnifiedCustomerDTO,
|
UnifiedCustomerDTO,
|
||||||
UnifiedCustomerPaginationDTO,
|
UnifiedCustomerPaginationDTO,
|
||||||
UnifiedMediaPaginationDTO,
|
UnifiedMediaPaginationDTO,
|
||||||
|
|
@ -105,7 +106,7 @@ export class SiteApiController {
|
||||||
this.logger.debug(`[Site API] 更新评论开始, siteId: ${siteId}, id: ${id}, body: ${JSON.stringify(body)}`);
|
this.logger.debug(`[Site API] 更新评论开始, siteId: ${siteId}, id: ${id}, body: ${JSON.stringify(body)}`);
|
||||||
try {
|
try {
|
||||||
const adapter = await this.siteApiService.getAdapter(siteId);
|
const adapter = await this.siteApiService.getAdapter(siteId);
|
||||||
const data = await adapter.updateReview({ id }, body);
|
const data = await adapter.updateReview(id, body);
|
||||||
this.logger.debug(`[Site API] 更新评论成功, siteId: ${siteId}, id: ${id}`);
|
this.logger.debug(`[Site API] 更新评论成功, siteId: ${siteId}, id: ${id}`);
|
||||||
return successResponse(data);
|
return successResponse(data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
@ -123,7 +124,7 @@ export class SiteApiController {
|
||||||
this.logger.debug(`[Site API] 删除评论开始, siteId: ${siteId}, id: ${id}`);
|
this.logger.debug(`[Site API] 删除评论开始, siteId: ${siteId}, id: ${id}`);
|
||||||
try {
|
try {
|
||||||
const adapter = await this.siteApiService.getAdapter(siteId);
|
const adapter = await this.siteApiService.getAdapter(siteId);
|
||||||
const data = await adapter.deleteReview({ id });
|
const data = await adapter.deleteReview(id);
|
||||||
this.logger.debug(`[Site API] 删除评论成功, siteId: ${siteId}, id: ${id}`);
|
this.logger.debug(`[Site API] 删除评论成功, siteId: ${siteId}, id: ${id}`);
|
||||||
return successResponse(data);
|
return successResponse(data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
@ -159,7 +160,7 @@ export class SiteApiController {
|
||||||
this.logger.debug(`[Site API] 获取单个webhook开始, siteId: ${siteId}, id: ${id}`);
|
this.logger.debug(`[Site API] 获取单个webhook开始, siteId: ${siteId}, id: ${id}`);
|
||||||
try {
|
try {
|
||||||
const adapter = await this.siteApiService.getAdapter(siteId);
|
const adapter = await this.siteApiService.getAdapter(siteId);
|
||||||
const data = await adapter.getWebhook({ id });
|
const data = await adapter.getWebhook(id);
|
||||||
this.logger.debug(`[Site API] 获取单个webhook成功, siteId: ${siteId}, id: ${id}`);
|
this.logger.debug(`[Site API] 获取单个webhook成功, siteId: ${siteId}, id: ${id}`);
|
||||||
return successResponse(data);
|
return successResponse(data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
@ -198,7 +199,7 @@ export class SiteApiController {
|
||||||
this.logger.debug(`[Site API] 更新webhook开始, siteId: ${siteId}, id: ${id}, body: ${JSON.stringify(body)}`);
|
this.logger.debug(`[Site API] 更新webhook开始, siteId: ${siteId}, id: ${id}, body: ${JSON.stringify(body)}`);
|
||||||
try {
|
try {
|
||||||
const adapter = await this.siteApiService.getAdapter(siteId);
|
const adapter = await this.siteApiService.getAdapter(siteId);
|
||||||
const data = await adapter.updateWebhook({ id }, body);
|
const data = await adapter.updateWebhook(id, body);
|
||||||
this.logger.debug(`[Site API] 更新webhook成功, siteId: ${siteId}, id: ${id}`);
|
this.logger.debug(`[Site API] 更新webhook成功, siteId: ${siteId}, id: ${id}`);
|
||||||
return successResponse(data);
|
return successResponse(data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
@ -216,7 +217,7 @@ export class SiteApiController {
|
||||||
this.logger.debug(`[Site API] 删除webhook开始, siteId: ${siteId}, id: ${id}`);
|
this.logger.debug(`[Site API] 删除webhook开始, siteId: ${siteId}, id: ${id}`);
|
||||||
try {
|
try {
|
||||||
const adapter = await this.siteApiService.getAdapter(siteId);
|
const adapter = await this.siteApiService.getAdapter(siteId);
|
||||||
const data = await adapter.deleteWebhook({ id });
|
const data = await adapter.deleteWebhook(id);
|
||||||
this.logger.debug(`[Site API] 删除webhook成功, siteId: ${siteId}, id: ${id}`);
|
this.logger.debug(`[Site API] 删除webhook成功, siteId: ${siteId}, id: ${id}`);
|
||||||
return successResponse(data);
|
return successResponse(data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
@ -326,7 +327,7 @@ export class SiteApiController {
|
||||||
if (site.type === 'woocommerce') {
|
if (site.type === 'woocommerce') {
|
||||||
const page = query.page || 1;
|
const page = query.page || 1;
|
||||||
const perPage = (query.per_page) || 100;
|
const perPage = (query.per_page) || 100;
|
||||||
const res = await this.siteApiService.wpService.getProducts(site, { page, per_page: perPage });
|
const res = await this.siteApiService.wpService.getProducts(site, page, perPage);
|
||||||
const header = ['id', 'name', 'type', 'status', 'sku', 'regular_price', 'sale_price', 'stock_status', 'stock_quantity'];
|
const header = ['id', 'name', 'type', 'status', 'sku', 'regular_price', 'sale_price', 'stock_status', 'stock_quantity'];
|
||||||
const rows = (res.items || []).map((p: any) => [p.id, p.name, p.type, p.status, p.sku, p.regular_price, p.sale_price, p.stock_status, p.stock_quantity]);
|
const rows = (res.items || []).map((p: any) => [p.id, p.name, p.type, p.status, p.sku, p.regular_price, p.sale_price, p.stock_status, p.stock_quantity]);
|
||||||
const toCsvValue = (val: any) => {
|
const toCsvValue = (val: any) => {
|
||||||
|
|
@ -359,7 +360,7 @@ export class SiteApiController {
|
||||||
this.logger.info(`[Site API] 获取单个产品开始, siteId: ${siteId}, productId: ${id}`);
|
this.logger.info(`[Site API] 获取单个产品开始, siteId: ${siteId}, productId: ${id}`);
|
||||||
try {
|
try {
|
||||||
const adapter = await this.siteApiService.getAdapter(siteId);
|
const adapter = await this.siteApiService.getAdapter(siteId);
|
||||||
const data = await adapter.getProduct({ id });
|
const data = await adapter.getProduct(id);
|
||||||
|
|
||||||
// 如果获取到商品数据,则增强ERP产品信息
|
// 如果获取到商品数据,则增强ERP产品信息
|
||||||
if (data) {
|
if (data) {
|
||||||
|
|
@ -484,7 +485,7 @@ export class SiteApiController {
|
||||||
this.logger.info(`[Site API] 更新产品开始, siteId: ${siteId}, productId: ${id}`);
|
this.logger.info(`[Site API] 更新产品开始, siteId: ${siteId}, productId: ${id}`);
|
||||||
try {
|
try {
|
||||||
const adapter = await this.siteApiService.getAdapter(siteId);
|
const adapter = await this.siteApiService.getAdapter(siteId);
|
||||||
const data = await adapter.updateProduct({ id }, body);
|
const data = await adapter.updateProduct(id, body);
|
||||||
this.logger.info(`[Site API] 更新产品成功, siteId: ${siteId}, productId: ${id}`);
|
this.logger.info(`[Site API] 更新产品成功, siteId: ${siteId}, productId: ${id}`);
|
||||||
return successResponse(data);
|
return successResponse(data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
@ -539,7 +540,7 @@ export class SiteApiController {
|
||||||
this.logger.info(`[Site API] 删除产品开始, siteId: ${siteId}, productId: ${id}`);
|
this.logger.info(`[Site API] 删除产品开始, siteId: ${siteId}, productId: ${id}`);
|
||||||
try {
|
try {
|
||||||
const adapter = await this.siteApiService.getAdapter(siteId);
|
const adapter = await this.siteApiService.getAdapter(siteId);
|
||||||
const success = await adapter.deleteProduct({ id });
|
const success = await adapter.deleteProduct(id);
|
||||||
this.logger.info(`[Site API] 删除产品成功, siteId: ${siteId}, productId: ${id}`);
|
this.logger.info(`[Site API] 删除产品成功, siteId: ${siteId}, productId: ${id}`);
|
||||||
return successResponse(success);
|
return successResponse(success);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
@ -584,7 +585,7 @@ export class SiteApiController {
|
||||||
for (const item of body.update) {
|
for (const item of body.update) {
|
||||||
try {
|
try {
|
||||||
const id = item.id;
|
const id = item.id;
|
||||||
const data = await adapter.updateProduct({ id }, item);
|
const data = await adapter.updateProduct(id, item);
|
||||||
updated.push(data);
|
updated.push(data);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
errors.push({
|
errors.push({
|
||||||
|
|
@ -597,7 +598,7 @@ export class SiteApiController {
|
||||||
if (body.delete?.length) {
|
if (body.delete?.length) {
|
||||||
for (const id of body.delete) {
|
for (const id of body.delete) {
|
||||||
try {
|
try {
|
||||||
const ok = await adapter.deleteProduct({ id });
|
const ok = await adapter.deleteProduct(id);
|
||||||
if (ok) deleted.push(id);
|
if (ok) deleted.push(id);
|
||||||
else errors.push({
|
else errors.push({
|
||||||
identifier: String(id),
|
identifier: String(id),
|
||||||
|
|
@ -771,7 +772,7 @@ export class SiteApiController {
|
||||||
this.logger.info(`[Site API] 获取单个订单开始, siteId: ${siteId}, orderId: ${id}`);
|
this.logger.info(`[Site API] 获取单个订单开始, siteId: ${siteId}, orderId: ${id}`);
|
||||||
try {
|
try {
|
||||||
const adapter = await this.siteApiService.getAdapter(siteId);
|
const adapter = await this.siteApiService.getAdapter(siteId);
|
||||||
const data = await adapter.getOrder({ id });
|
const data = await adapter.getOrder(id);
|
||||||
this.logger.info(`[Site API] 获取单个订单成功, siteId: ${siteId}, orderId: ${id}`);
|
this.logger.info(`[Site API] 获取单个订单成功, siteId: ${siteId}, orderId: ${id}`);
|
||||||
return successResponse(data);
|
return successResponse(data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
@ -843,7 +844,7 @@ export class SiteApiController {
|
||||||
this.logger.info(`[Site API] 更新订单开始, siteId: ${siteId}, orderId: ${id}`);
|
this.logger.info(`[Site API] 更新订单开始, siteId: ${siteId}, orderId: ${id}`);
|
||||||
try {
|
try {
|
||||||
const adapter = await this.siteApiService.getAdapter(siteId);
|
const adapter = await this.siteApiService.getAdapter(siteId);
|
||||||
const ok = await adapter.updateOrder({ id }, body);
|
const ok = await adapter.updateOrder(id, body);
|
||||||
this.logger.info(`[Site API] 更新订单成功, siteId: ${siteId}, orderId: ${id}`);
|
this.logger.info(`[Site API] 更新订单成功, siteId: ${siteId}, orderId: ${id}`);
|
||||||
return successResponse(ok);
|
return successResponse(ok);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
@ -861,7 +862,7 @@ export class SiteApiController {
|
||||||
this.logger.info(`[Site API] 删除订单开始, siteId: ${siteId}, orderId: ${id}`);
|
this.logger.info(`[Site API] 删除订单开始, siteId: ${siteId}, orderId: ${id}`);
|
||||||
try {
|
try {
|
||||||
const adapter = await this.siteApiService.getAdapter(siteId);
|
const adapter = await this.siteApiService.getAdapter(siteId);
|
||||||
const ok = await adapter.deleteOrder({ id });
|
const ok = await adapter.deleteOrder(id);
|
||||||
this.logger.info(`[Site API] 删除订单成功, siteId: ${siteId}, orderId: ${id}`);
|
this.logger.info(`[Site API] 删除订单成功, siteId: ${siteId}, orderId: ${id}`);
|
||||||
return successResponse(ok);
|
return successResponse(ok);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
@ -901,7 +902,7 @@ export class SiteApiController {
|
||||||
for (const item of body.update) {
|
for (const item of body.update) {
|
||||||
try {
|
try {
|
||||||
const id = item.id;
|
const id = item.id;
|
||||||
const ok = await adapter.updateOrder({ id }, item);
|
const ok = await adapter.updateOrder(id, item);
|
||||||
if (ok) updated.push(item);
|
if (ok) updated.push(item);
|
||||||
else errors.push({
|
else errors.push({
|
||||||
identifier: String(item.id || 'unknown'),
|
identifier: String(item.id || 'unknown'),
|
||||||
|
|
@ -918,7 +919,7 @@ export class SiteApiController {
|
||||||
if (body.delete?.length) {
|
if (body.delete?.length) {
|
||||||
for (const id of body.delete) {
|
for (const id of body.delete) {
|
||||||
try {
|
try {
|
||||||
const ok = await adapter.deleteOrder({ id });
|
const ok = await adapter.deleteOrder(id);
|
||||||
if (ok) deleted.push(id);
|
if (ok) deleted.push(id);
|
||||||
else errors.push({
|
else errors.push({
|
||||||
identifier: String(id),
|
identifier: String(id),
|
||||||
|
|
@ -985,6 +986,25 @@ export class SiteApiController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Post('/:siteId/orders/:id/fulfill')
|
||||||
|
@ApiOkResponse({ type: Object })
|
||||||
|
async fulfillOrder(
|
||||||
|
@Param('siteId') siteId: number,
|
||||||
|
@Param('id') id: string,
|
||||||
|
@Body() body: FulfillmentDTO
|
||||||
|
) {
|
||||||
|
this.logger.info(`[Site API] 订单履约开始, siteId: ${siteId}, orderId: ${id}`);
|
||||||
|
try {
|
||||||
|
const adapter = await this.siteApiService.getAdapter(siteId);
|
||||||
|
const data = await adapter.fulfillOrder(id, body);
|
||||||
|
this.logger.info(`[Site API] 订单履约成功, siteId: ${siteId}, orderId: ${id}`);
|
||||||
|
return successResponse(data);
|
||||||
|
} catch (error) {
|
||||||
|
this.logger.error(`[Site API] 订单履约失败, siteId: ${siteId}, orderId: ${id}, 错误信息: ${error.message}`);
|
||||||
|
return errorResponse(error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Post('/:siteId/orders/:id/cancel-fulfill')
|
@Post('/:siteId/orders/:id/cancel-fulfill')
|
||||||
@ApiOkResponse({ type: Object })
|
@ApiOkResponse({ type: Object })
|
||||||
async cancelFulfillment(
|
async cancelFulfillment(
|
||||||
|
|
@ -1435,7 +1455,7 @@ export class SiteApiController {
|
||||||
this.logger.info(`[Site API] 获取单个客户开始, siteId: ${siteId}, customerId: ${id}`);
|
this.logger.info(`[Site API] 获取单个客户开始, siteId: ${siteId}, customerId: ${id}`);
|
||||||
try {
|
try {
|
||||||
const adapter = await this.siteApiService.getAdapter(siteId);
|
const adapter = await this.siteApiService.getAdapter(siteId);
|
||||||
const data = await adapter.getCustomer({ id });
|
const data = await adapter.getCustomer(id);
|
||||||
this.logger.info(`[Site API] 获取单个客户成功, siteId: ${siteId}, customerId: ${id}`);
|
this.logger.info(`[Site API] 获取单个客户成功, siteId: ${siteId}, customerId: ${id}`);
|
||||||
return successResponse(data);
|
return successResponse(data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
@ -1507,7 +1527,7 @@ export class SiteApiController {
|
||||||
this.logger.info(`[Site API] 更新客户开始, siteId: ${siteId}, customerId: ${id}`);
|
this.logger.info(`[Site API] 更新客户开始, siteId: ${siteId}, customerId: ${id}`);
|
||||||
try {
|
try {
|
||||||
const adapter = await this.siteApiService.getAdapter(siteId);
|
const adapter = await this.siteApiService.getAdapter(siteId);
|
||||||
const data = await adapter.updateCustomer({ id }, body);
|
const data = await adapter.updateCustomer(id, body);
|
||||||
this.logger.info(`[Site API] 更新客户成功, siteId: ${siteId}, customerId: ${id}`);
|
this.logger.info(`[Site API] 更新客户成功, siteId: ${siteId}, customerId: ${id}`);
|
||||||
return successResponse(data);
|
return successResponse(data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
@ -1525,7 +1545,7 @@ export class SiteApiController {
|
||||||
this.logger.info(`[Site API] 删除客户开始, siteId: ${siteId}, customerId: ${id}`);
|
this.logger.info(`[Site API] 删除客户开始, siteId: ${siteId}, customerId: ${id}`);
|
||||||
try {
|
try {
|
||||||
const adapter = await this.siteApiService.getAdapter(siteId);
|
const adapter = await this.siteApiService.getAdapter(siteId);
|
||||||
const success = await adapter.deleteCustomer({ id });
|
const success = await adapter.deleteCustomer(id);
|
||||||
this.logger.info(`[Site API] 删除客户成功, siteId: ${siteId}, customerId: ${id}`);
|
this.logger.info(`[Site API] 删除客户成功, siteId: ${siteId}, customerId: ${id}`);
|
||||||
return successResponse(success);
|
return successResponse(success);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
@ -1561,7 +1581,7 @@ export class SiteApiController {
|
||||||
for (const item of body.update) {
|
for (const item of body.update) {
|
||||||
try {
|
try {
|
||||||
const id = item.id;
|
const id = item.id;
|
||||||
const data = await adapter.updateCustomer({ id }, item);
|
const data = await adapter.updateCustomer(id, item);
|
||||||
updated.push(data);
|
updated.push(data);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
failed.push({ action: 'update', item, error: (e as any).message });
|
failed.push({ action: 'update', item, error: (e as any).message });
|
||||||
|
|
@ -1571,7 +1591,7 @@ export class SiteApiController {
|
||||||
if (body.delete?.length) {
|
if (body.delete?.length) {
|
||||||
for (const id of body.delete) {
|
for (const id of body.delete) {
|
||||||
try {
|
try {
|
||||||
const ok = await adapter.deleteCustomer({ id });
|
const ok = await adapter.deleteCustomer(id);
|
||||||
if (ok) deleted.push(id);
|
if (ok) deleted.push(id);
|
||||||
else failed.push({ action: 'delete', id, error: 'delete failed' });
|
else failed.push({ action: 'delete', id, error: 'delete failed' });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
||||||
|
|
@ -20,70 +20,50 @@ import { UnifiedPaginationDTO, UnifiedSearchParamsDTO } from '../dto/api.dto';
|
||||||
import { BatchOperationDTO, BatchOperationResultDTO } from '../dto/batch.dto';
|
import { BatchOperationDTO, BatchOperationResultDTO } from '../dto/batch.dto';
|
||||||
|
|
||||||
export interface ISiteAdapter {
|
export interface ISiteAdapter {
|
||||||
// ========== 客户映射方法 ==========
|
|
||||||
/**
|
/**
|
||||||
* 将平台客户数据转换为统一客户数据格式
|
* 获取产品列表
|
||||||
* @param data 平台特定客户数据
|
|
||||||
* @returns 统一客户数据格式
|
|
||||||
*/
|
*/
|
||||||
mapPlatformToUnifiedCustomer(data: any): UnifiedCustomerDTO;
|
getProducts(params: UnifiedSearchParamsDTO): Promise<UnifiedPaginationDTO<UnifiedProductDTO>>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将统一客户数据格式转换为平台客户数据
|
* 获取所有产品
|
||||||
* @param data 统一客户数据格式
|
|
||||||
* @returns 平台特定客户数据
|
|
||||||
*/
|
*/
|
||||||
mapUnifiedToPlatformCustomer(data: Partial<UnifiedCustomerDTO>): any;
|
getAllProducts(params?: UnifiedSearchParamsDTO): Promise<UnifiedProductDTO[]>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取单个客户
|
* 获取单个产品
|
||||||
*/
|
*/
|
||||||
getCustomer(where: Partial<Pick<UnifiedCustomerDTO, 'id' | 'email' | 'phone'>>): Promise<UnifiedCustomerDTO>;
|
getProduct(id: string | number): Promise<UnifiedProductDTO>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取客户列表
|
* 获取订单列表
|
||||||
*/
|
*/
|
||||||
getCustomers(params: UnifiedSearchParamsDTO): Promise<UnifiedPaginationDTO<UnifiedCustomerDTO>>;
|
getOrders(params: UnifiedSearchParamsDTO): Promise<UnifiedPaginationDTO<UnifiedOrderDTO>>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取所有客户
|
* 获取订单总数
|
||||||
*/
|
*/
|
||||||
getAllCustomers(params?: UnifiedSearchParamsDTO): Promise<UnifiedCustomerDTO[]>;
|
countOrders(params: Record<string,any>): Promise<number>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建客户
|
* 获取所有订单
|
||||||
*/
|
*/
|
||||||
createCustomer(data: Partial<UnifiedCustomerDTO>): Promise<UnifiedCustomerDTO>;
|
getAllOrders(params?: UnifiedSearchParamsDTO): Promise<UnifiedOrderDTO[]>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新客户
|
* 获取单个订单
|
||||||
*/
|
*/
|
||||||
updateCustomer(where: Partial<Pick<UnifiedCustomerDTO, 'id' | 'email' | 'phone'>>, data: Partial<UnifiedCustomerDTO>): Promise<UnifiedCustomerDTO>;
|
getOrder(id: string | number): Promise<UnifiedOrderDTO>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除客户
|
* 获取订阅列表
|
||||||
*/
|
*/
|
||||||
deleteCustomer(where: Partial<Pick<UnifiedCustomerDTO, 'id' | 'email' | 'phone'>>): Promise<boolean>;
|
getSubscriptions(params: UnifiedSearchParamsDTO): Promise<UnifiedPaginationDTO<UnifiedSubscriptionDTO>>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量处理客户
|
* 获取所有订阅
|
||||||
*/
|
*/
|
||||||
batchProcessCustomers?(data: BatchOperationDTO): Promise<BatchOperationResultDTO>;
|
getAllSubscriptions(params?: UnifiedSearchParamsDTO): Promise<UnifiedSubscriptionDTO[]>;
|
||||||
|
|
||||||
// ========== 媒体映射方法 ==========
|
|
||||||
/**
|
|
||||||
* 将平台媒体数据转换为统一媒体数据格式
|
|
||||||
* @param data 平台特定媒体数据
|
|
||||||
* @returns 统一媒体数据格式
|
|
||||||
*/
|
|
||||||
mapPlatformToUnifiedMedia(data: any): UnifiedMediaDTO;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将统一媒体数据格式转换为平台媒体数据
|
|
||||||
* @param data 统一媒体数据格式
|
|
||||||
* @returns 平台特定媒体数据
|
|
||||||
*/
|
|
||||||
mapUnifiedToPlatformMedia(data: Partial<UnifiedMediaDTO>): any;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取媒体列表
|
* 获取媒体列表
|
||||||
|
|
@ -100,69 +80,75 @@ export interface ISiteAdapter {
|
||||||
*/
|
*/
|
||||||
createMedia(file: any): Promise<UnifiedMediaDTO>;
|
createMedia(file: any): Promise<UnifiedMediaDTO>;
|
||||||
|
|
||||||
// ========== 订单映射方法 ==========
|
|
||||||
/**
|
/**
|
||||||
* 将平台订单数据转换为统一订单数据格式
|
* 获取评论列表
|
||||||
* @param data 平台特定订单数据
|
|
||||||
* @returns 统一订单数据格式
|
|
||||||
*/
|
*/
|
||||||
mapPlatformToUnifiedOrder(data: any): UnifiedOrderDTO;
|
getReviews(params: UnifiedSearchParamsDTO): Promise<UnifiedPaginationDTO<UnifiedReviewDTO>>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将统一订单数据格式转换为平台订单数据
|
* 获取所有评论
|
||||||
* @param data 统一订单数据格式
|
|
||||||
* @returns 平台特定订单数据
|
|
||||||
*/
|
*/
|
||||||
mapUnifiedToPlatformOrder(data: Partial<UnifiedOrderDTO>): any;
|
getAllReviews(params?: UnifiedSearchParamsDTO): Promise<UnifiedReviewDTO[]>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将统一订单创建参数转换为平台订单创建参数
|
* 创建评论
|
||||||
* @param data 统一订单创建参数
|
|
||||||
* @returns 平台订单创建参数
|
|
||||||
*/
|
*/
|
||||||
mapCreateOrderParams(data: Partial<UnifiedOrderDTO>): any;
|
createReview(data: CreateReviewDTO): Promise<UnifiedReviewDTO>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将统一订单更新参数转换为平台订单更新参数
|
* 更新评论
|
||||||
* @param data 统一订单更新参数
|
|
||||||
* @returns 平台订单更新参数
|
|
||||||
*/
|
*/
|
||||||
mapUpdateOrderParams(data: Partial<UnifiedOrderDTO>): any;
|
updateReview(id: number, data: UpdateReviewDTO): Promise<UnifiedReviewDTO>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取单个订单
|
* 删除评论
|
||||||
*/
|
*/
|
||||||
getOrder(where: Partial<Pick<UnifiedOrderDTO, 'id'>>): Promise<UnifiedOrderDTO>;
|
deleteReview(id: number): Promise<boolean>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取订单列表
|
* 创建产品
|
||||||
*/
|
*/
|
||||||
getOrders(params: UnifiedSearchParamsDTO): Promise<UnifiedPaginationDTO<UnifiedOrderDTO>>;
|
createProduct(data: Partial<UnifiedProductDTO>): Promise<UnifiedProductDTO>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取所有订单
|
* 更新产品
|
||||||
*/
|
*/
|
||||||
getAllOrders(params?: UnifiedSearchParamsDTO): Promise<UnifiedOrderDTO[]>;
|
updateProduct(id: string | number, data: Partial<UnifiedProductDTO>): Promise<boolean>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取订单总数
|
* 删除产品
|
||||||
*/
|
*/
|
||||||
countOrders(params: Record<string, any>): Promise<number>;
|
deleteProduct(id: string | number): Promise<boolean>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建订单
|
* 获取产品变体列表
|
||||||
*/
|
*/
|
||||||
createOrder(data: Partial<UnifiedOrderDTO>): Promise<UnifiedOrderDTO>;
|
getVariations(productId: string | number, params: UnifiedSearchParamsDTO): Promise<UnifiedVariationPaginationDTO>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新订单
|
* 获取所有产品变体
|
||||||
*/
|
*/
|
||||||
updateOrder(where: Partial<Pick<UnifiedOrderDTO, 'id'>>, data: Partial<UnifiedOrderDTO>): Promise<boolean>;
|
getAllVariations(productId: string | number, params?: UnifiedSearchParamsDTO): Promise<UnifiedProductVariationDTO[]>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除订单
|
* 获取单个产品变体
|
||||||
*/
|
*/
|
||||||
deleteOrder(where: Partial<Pick<UnifiedOrderDTO, 'id'>>): Promise<boolean>;
|
getVariation(productId: string | number, variationId: string | number): Promise<UnifiedProductVariationDTO>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建产品变体
|
||||||
|
*/
|
||||||
|
createVariation(productId: string | number, data: CreateVariationDTO): Promise<UnifiedProductVariationDTO>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新产品变体
|
||||||
|
*/
|
||||||
|
updateVariation(productId: string | number, variationId: string | number, data: UpdateVariationDTO): Promise<UnifiedProductVariationDTO>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除产品变体
|
||||||
|
*/
|
||||||
|
deleteVariation(productId: string | number, variationId: string | number): Promise<boolean>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取订单备注
|
* 获取订单备注
|
||||||
|
|
@ -174,6 +160,71 @@ export interface ISiteAdapter {
|
||||||
*/
|
*/
|
||||||
createOrderNote(orderId: string | number, data: any): Promise<any>;
|
createOrderNote(orderId: string | number, data: any): Promise<any>;
|
||||||
|
|
||||||
|
batchProcessProducts?(data: BatchOperationDTO): Promise<BatchOperationResultDTO>;
|
||||||
|
|
||||||
|
createOrder(data: Partial<UnifiedOrderDTO>): Promise<UnifiedOrderDTO>;
|
||||||
|
updateOrder(id: string | number, data: Partial<UnifiedOrderDTO>): Promise<boolean>;
|
||||||
|
deleteOrder(id: string | number): Promise<boolean>;
|
||||||
|
|
||||||
|
batchProcessOrders?(data: BatchOperationDTO): Promise<BatchOperationResultDTO>;
|
||||||
|
|
||||||
|
getCustomers(params: UnifiedSearchParamsDTO): Promise<UnifiedPaginationDTO<UnifiedCustomerDTO>>;
|
||||||
|
getAllCustomers(params?: UnifiedSearchParamsDTO): Promise<UnifiedCustomerDTO[]>;
|
||||||
|
getCustomer(id: string | number): Promise<UnifiedCustomerDTO>;
|
||||||
|
createCustomer(data: Partial<UnifiedCustomerDTO>): Promise<UnifiedCustomerDTO>;
|
||||||
|
updateCustomer(id: string | number, data: Partial<UnifiedCustomerDTO>): Promise<UnifiedCustomerDTO>;
|
||||||
|
deleteCustomer(id: string | number): Promise<boolean>;
|
||||||
|
|
||||||
|
batchProcessCustomers?(data: BatchOperationDTO): Promise<BatchOperationResultDTO>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取webhooks列表
|
||||||
|
*/
|
||||||
|
getWebhooks(params: UnifiedSearchParamsDTO): Promise<UnifiedWebhookPaginationDTO>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有webhooks
|
||||||
|
*/
|
||||||
|
getAllWebhooks(params?: UnifiedSearchParamsDTO): Promise<UnifiedWebhookDTO[]>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取单个webhook
|
||||||
|
*/
|
||||||
|
getWebhook(id: string | number): Promise<UnifiedWebhookDTO>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建webhook
|
||||||
|
*/
|
||||||
|
createWebhook(data: CreateWebhookDTO): Promise<UnifiedWebhookDTO>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新webhook
|
||||||
|
*/
|
||||||
|
updateWebhook(id: string | number, data: UpdateWebhookDTO): Promise<UnifiedWebhookDTO>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除webhook
|
||||||
|
*/
|
||||||
|
deleteWebhook(id: string | number): Promise<boolean>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取站点链接列表
|
||||||
|
*/
|
||||||
|
getLinks(): Promise<Array<{title: string, url: string}>>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单履行(发货)
|
||||||
|
*/
|
||||||
|
fulfillOrder(orderId: string | number, data: {
|
||||||
|
tracking_number?: string;
|
||||||
|
shipping_provider?: string;
|
||||||
|
shipping_method?: string;
|
||||||
|
items?: Array<{
|
||||||
|
order_item_id: number;
|
||||||
|
quantity: number;
|
||||||
|
}>;
|
||||||
|
}): Promise<any>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 取消订单履行
|
* 取消订单履行
|
||||||
*/
|
*/
|
||||||
|
|
@ -221,276 +272,4 @@ export interface ISiteAdapter {
|
||||||
* 删除订单履行信息
|
* 删除订单履行信息
|
||||||
*/
|
*/
|
||||||
deleteOrderFulfillment(orderId: string | number, fulfillmentId: string): Promise<boolean>;
|
deleteOrderFulfillment(orderId: string | number, fulfillmentId: string): Promise<boolean>;
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量处理订单
|
|
||||||
*/
|
|
||||||
batchProcessOrders?(data: BatchOperationDTO): Promise<BatchOperationResultDTO>;
|
|
||||||
|
|
||||||
// ========== 产品映射方法 ==========
|
|
||||||
/**
|
|
||||||
* 将平台产品数据转换为统一产品数据格式
|
|
||||||
* @param data 平台特定产品数据
|
|
||||||
* @returns 统一产品数据格式
|
|
||||||
*/
|
|
||||||
mapPlatformToUnifiedProduct(data: any): UnifiedProductDTO;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将统一产品数据格式转换为平台产品数据
|
|
||||||
* @param data 统一产品数据格式
|
|
||||||
* @returns 平台特定产品数据
|
|
||||||
*/
|
|
||||||
mapUnifiedToPlatformProduct(data: Partial<UnifiedProductDTO>): any;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将统一产品创建参数转换为平台产品创建参数
|
|
||||||
* @param data 统一产品创建参数
|
|
||||||
* @returns 平台产品创建参数
|
|
||||||
*/
|
|
||||||
mapCreateProductParams(data: Partial<UnifiedProductDTO>): any;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将统一产品更新参数转换为平台产品更新参数
|
|
||||||
* @param data 统一产品更新参数
|
|
||||||
* @returns 平台产品更新参数
|
|
||||||
*/
|
|
||||||
mapUpdateProductParams(data: Partial<UnifiedProductDTO>): any;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取单个产品
|
|
||||||
*/
|
|
||||||
getProduct(where: Partial<Pick<UnifiedProductDTO, 'id' | 'sku'>>): Promise<UnifiedProductDTO>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取产品列表
|
|
||||||
*/
|
|
||||||
getProducts(params: UnifiedSearchParamsDTO): Promise<UnifiedPaginationDTO<UnifiedProductDTO>>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取所有产品
|
|
||||||
*/
|
|
||||||
getAllProducts(params?: UnifiedSearchParamsDTO): Promise<UnifiedProductDTO[]>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建产品
|
|
||||||
*/
|
|
||||||
createProduct(data: Partial<UnifiedProductDTO>): Promise<UnifiedProductDTO>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新产品
|
|
||||||
*/
|
|
||||||
updateProduct(where: Partial<Pick<UnifiedProductDTO, 'id' | 'sku'>>, data: Partial<UnifiedProductDTO>): Promise<boolean>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除产品
|
|
||||||
*/
|
|
||||||
deleteProduct(where: Partial<Pick<UnifiedProductDTO, 'id' | 'sku'>>): Promise<boolean>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量处理产品
|
|
||||||
*/
|
|
||||||
batchProcessProducts?(data: BatchOperationDTO): Promise<BatchOperationResultDTO>;
|
|
||||||
|
|
||||||
// ========== 评论映射方法 ==========
|
|
||||||
/**
|
|
||||||
* 将平台评论数据转换为统一评论数据格式
|
|
||||||
* @param data 平台特定评论数据
|
|
||||||
* @returns 统一评论数据格式
|
|
||||||
*/
|
|
||||||
mapPlatformToUnifiedReview(data: any): UnifiedReviewDTO;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将统一评论数据格式转换为平台评论数据
|
|
||||||
* @param data 统一评论数据格式
|
|
||||||
* @returns 平台特定评论数据
|
|
||||||
*/
|
|
||||||
mapUnifiedToPlatformReview(data: Partial<UnifiedReviewDTO>): any;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将统一评论创建参数转换为平台评论创建参数
|
|
||||||
* @param data 统一评论创建参数
|
|
||||||
* @returns 平台评论创建参数
|
|
||||||
*/
|
|
||||||
mapCreateReviewParams(data: CreateReviewDTO): any;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将统一评论更新参数转换为平台评论更新参数
|
|
||||||
* @param data 统一评论更新参数
|
|
||||||
* @returns 平台评论更新参数
|
|
||||||
*/
|
|
||||||
mapUpdateReviewParams(data: UpdateReviewDTO): any;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取评论列表
|
|
||||||
*/
|
|
||||||
getReviews(params: UnifiedSearchParamsDTO): Promise<UnifiedPaginationDTO<UnifiedReviewDTO>>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取所有评论
|
|
||||||
*/
|
|
||||||
getAllReviews(params?: UnifiedSearchParamsDTO): Promise<UnifiedReviewDTO[]>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建评论
|
|
||||||
*/
|
|
||||||
createReview(data: CreateReviewDTO): Promise<UnifiedReviewDTO>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新评论
|
|
||||||
*/
|
|
||||||
updateReview(where: Partial<Pick<UnifiedReviewDTO, 'id'>>, data: UpdateReviewDTO): Promise<UnifiedReviewDTO>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除评论
|
|
||||||
*/
|
|
||||||
deleteReview(where: Partial<Pick<UnifiedReviewDTO, 'id'>>): Promise<boolean>;
|
|
||||||
|
|
||||||
// ========== 订阅映射方法 ==========
|
|
||||||
/**
|
|
||||||
* 将平台订阅数据转换为统一订阅数据格式
|
|
||||||
* @param data 平台特定订阅数据
|
|
||||||
* @returns 统一订阅数据格式
|
|
||||||
*/
|
|
||||||
mapPlatformToUnifiedSubscription(data: any): UnifiedSubscriptionDTO;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将统一订阅数据格式转换为平台订阅数据
|
|
||||||
* @param data 统一订阅数据格式
|
|
||||||
* @returns 平台特定订阅数据
|
|
||||||
*/
|
|
||||||
mapUnifiedToPlatformSubscription(data: Partial<UnifiedSubscriptionDTO>): any;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取订阅列表
|
|
||||||
*/
|
|
||||||
getSubscriptions(params: UnifiedSearchParamsDTO): Promise<UnifiedPaginationDTO<UnifiedSubscriptionDTO>>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取所有订阅
|
|
||||||
*/
|
|
||||||
getAllSubscriptions(params?: UnifiedSearchParamsDTO): Promise<UnifiedSubscriptionDTO[]>;
|
|
||||||
|
|
||||||
// ========== 产品变体映射方法 ==========
|
|
||||||
/**
|
|
||||||
* 将平台产品变体数据转换为统一产品变体数据格式
|
|
||||||
* @param data 平台特定产品变体数据
|
|
||||||
* @returns 统一产品变体数据格式
|
|
||||||
*/
|
|
||||||
mapPlatformToUnifiedVariation(data: any): UnifiedProductVariationDTO;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将统一产品变体数据格式转换为平台产品变体数据
|
|
||||||
* @param data 统一产品变体数据格式
|
|
||||||
* @returns 平台特定产品变体数据
|
|
||||||
*/
|
|
||||||
mapUnifiedToPlatformVariation(data: Partial<UnifiedProductVariationDTO>): any;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将统一产品变体创建参数转换为平台产品变体创建参数
|
|
||||||
* @param data 统一产品变体创建参数
|
|
||||||
* @returns 平台产品变体创建参数
|
|
||||||
*/
|
|
||||||
mapCreateVariationParams(data: CreateVariationDTO): any;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将统一产品变体更新参数转换为平台产品变体更新参数
|
|
||||||
* @param data 统一产品变体更新参数
|
|
||||||
* @returns 平台产品变体更新参数
|
|
||||||
*/
|
|
||||||
mapUpdateVariationParams(data: UpdateVariationDTO): any;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取单个产品变体
|
|
||||||
*/
|
|
||||||
getVariation(productId: string | number, variationId: string | number): Promise<UnifiedProductVariationDTO>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取产品变体列表
|
|
||||||
*/
|
|
||||||
getVariations(productId: string | number, params: UnifiedSearchParamsDTO): Promise<UnifiedVariationPaginationDTO>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取所有产品变体
|
|
||||||
*/
|
|
||||||
getAllVariations(productId: string | number, params?: UnifiedSearchParamsDTO): Promise<UnifiedProductVariationDTO[]>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建产品变体
|
|
||||||
*/
|
|
||||||
createVariation(productId: string | number, data: CreateVariationDTO): Promise<UnifiedProductVariationDTO>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新产品变体
|
|
||||||
*/
|
|
||||||
updateVariation(productId: string | number, variationId: string | number, data: UpdateVariationDTO): Promise<UnifiedProductVariationDTO>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除产品变体
|
|
||||||
*/
|
|
||||||
deleteVariation(productId: string | number, variationId: string | number): Promise<boolean>;
|
|
||||||
|
|
||||||
// ========== Webhook映射方法 ==========
|
|
||||||
/**
|
|
||||||
* 将平台Webhook数据转换为统一Webhook数据格式
|
|
||||||
* @param data 平台特定Webhook数据
|
|
||||||
* @returns 统一Webhook数据格式
|
|
||||||
*/
|
|
||||||
mapPlatformToUnifiedWebhook(data: any): UnifiedWebhookDTO;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将统一Webhook数据格式转换为平台Webhook数据
|
|
||||||
* @param data 统一Webhook数据格式
|
|
||||||
* @returns 平台特定Webhook数据
|
|
||||||
*/
|
|
||||||
mapUnifiedToPlatformWebhook(data: Partial<UnifiedWebhookDTO>): any;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将统一Webhook创建参数转换为平台Webhook创建参数
|
|
||||||
* @param data 统一Webhook创建参数
|
|
||||||
* @returns 平台Webhook创建参数
|
|
||||||
*/
|
|
||||||
mapCreateWebhookParams(data: CreateWebhookDTO): any;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将统一Webhook更新参数转换为平台Webhook更新参数
|
|
||||||
* @param data 统一Webhook更新参数
|
|
||||||
* @returns 平台Webhook更新参数
|
|
||||||
*/
|
|
||||||
mapUpdateWebhookParams(data: UpdateWebhookDTO): any;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取单个webhook
|
|
||||||
*/
|
|
||||||
getWebhook(where: Partial<Pick<UnifiedWebhookDTO, 'id'>>): Promise<UnifiedWebhookDTO>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取webhooks列表
|
|
||||||
*/
|
|
||||||
getWebhooks(params: UnifiedSearchParamsDTO): Promise<UnifiedWebhookPaginationDTO>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取所有webhooks
|
|
||||||
*/
|
|
||||||
getAllWebhooks(params?: UnifiedSearchParamsDTO): Promise<UnifiedWebhookDTO[]>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建webhook
|
|
||||||
*/
|
|
||||||
createWebhook(data: CreateWebhookDTO): Promise<UnifiedWebhookDTO>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新webhook
|
|
||||||
*/
|
|
||||||
updateWebhook(where: Partial<Pick<UnifiedWebhookDTO, 'id'>>, data: UpdateWebhookDTO): Promise<UnifiedWebhookDTO>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除webhook
|
|
||||||
*/
|
|
||||||
deleteWebhook(where: Partial<Pick<UnifiedWebhookDTO, 'id'>>): Promise<boolean>;
|
|
||||||
|
|
||||||
// ========== 站点/其他方法 ==========
|
|
||||||
/**
|
|
||||||
* 获取站点链接列表
|
|
||||||
*/
|
|
||||||
getLinks(): Promise<Array<{ title: string, url: string }>>;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -202,7 +202,7 @@ export class OrderService {
|
||||||
try {
|
try {
|
||||||
// 调用 WooCommerce API 获取订单
|
// 调用 WooCommerce API 获取订单
|
||||||
const adapter = await this.siteApiService.getAdapter(siteId);
|
const adapter = await this.siteApiService.getAdapter(siteId);
|
||||||
const order = await adapter.getOrder({ id: orderId });
|
const order = await adapter.getOrder(orderId);
|
||||||
|
|
||||||
// 检查订单是否已存在,以区分创建和更新
|
// 检查订单是否已存在,以区分创建和更新
|
||||||
const existingOrder = await this.orderModel.findOne({
|
const existingOrder = await this.orderModel.findOne({
|
||||||
|
|
|
||||||
|
|
@ -110,22 +110,36 @@ export class SiteApiService {
|
||||||
const adapter = await this.getAdapter(siteId);
|
const adapter = await this.getAdapter(siteId);
|
||||||
|
|
||||||
// 首先尝试查找产品
|
// 首先尝试查找产品
|
||||||
if (product.sku) {
|
if (product.id) {
|
||||||
|
try {
|
||||||
|
// 尝试获取产品以确认它是否存在
|
||||||
|
const existingProduct = await adapter.getProduct(product.id);
|
||||||
|
if (existingProduct) {
|
||||||
|
// 产品存在,执行更新
|
||||||
|
return await adapter.updateProduct(product.id, product);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
// 如果获取产品失败,可能是因为产品不存在,继续执行创建逻辑
|
||||||
|
console.log(`产品 ${product.id} 不存在,将创建新产品:`, error.message);
|
||||||
|
}
|
||||||
|
} else if (product.sku) {
|
||||||
// 如果没有提供ID但提供了SKU,尝试通过SKU查找产品
|
// 如果没有提供ID但提供了SKU,尝试通过SKU查找产品
|
||||||
try {
|
try {
|
||||||
// 尝试搜索具有相同SKU的产品
|
// 尝试搜索具有相同SKU的产品
|
||||||
const existingProduct = await adapter.getProduct( { sku: product.sku });
|
const searchResult = await adapter.getProducts({ where: { sku: product.sku } });
|
||||||
if (existingProduct) {
|
if (searchResult.items && searchResult.items.length > 0) {
|
||||||
|
const existingProduct = searchResult.items[0];
|
||||||
// 找到现有产品,更新它
|
// 找到现有产品,更新它
|
||||||
return await adapter.updateProduct({ id: existingProduct.id }, product);
|
return await adapter.updateProduct(existingProduct.id, product);
|
||||||
}
|
}
|
||||||
// 产品不存在,执行创建
|
|
||||||
return await adapter.createProduct(product);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// 搜索失败,继续执行创建逻辑
|
// 搜索失败,继续执行创建逻辑
|
||||||
console.log(`通过SKU搜索产品失败:`, error.message);
|
console.log(`通过SKU搜索产品失败:`, error.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 产品不存在,执行创建
|
||||||
|
return await adapter.createProduct(product);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -183,7 +197,7 @@ export class SiteApiService {
|
||||||
*/
|
*/
|
||||||
async getProductFromSite(siteId: number, productId: string | number): Promise<any> {
|
async getProductFromSite(siteId: number, productId: string | number): Promise<any> {
|
||||||
const adapter = await this.getAdapter(siteId);
|
const adapter = await this.getAdapter(siteId);
|
||||||
return await adapter.getProduct({ id: productId });
|
return await adapter.getProduct(productId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -240,11 +240,9 @@ export class WPService implements IPlatformService {
|
||||||
return allData;
|
return allData;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getProducts(site: any, params: Record<string, any> = {}): Promise<any> {
|
async getProducts(site: any, page: number = 1, pageSize: number = 100): Promise<any> {
|
||||||
const api = this.createApi(site, 'wc/v3');
|
const api = this.createApi(site, 'wc/v3');
|
||||||
const page = params.page ?? 1;
|
return await this.sdkGetPage<WooProduct>(api, 'products', { page, per_page: pageSize });
|
||||||
const per_page = params.per_page ?? params.pageSize ?? 100;
|
|
||||||
return await this.sdkGetPage<WooProduct>(api, 'products', { ...params, page, per_page });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getProduct(site: any, id: number): Promise<any> {
|
async getProduct(site: any, id: number): Promise<any> {
|
||||||
|
|
@ -256,7 +254,7 @@ export class WPService implements IPlatformService {
|
||||||
|
|
||||||
// 导出 WooCommerce 产品为特殊CSV(平台特性)
|
// 导出 WooCommerce 产品为特殊CSV(平台特性)
|
||||||
async exportProductsCsvSpecial(site: any, page: number = 1, pageSize: number = 100): Promise<string> {
|
async exportProductsCsvSpecial(site: any, page: number = 1, pageSize: number = 100): Promise<string> {
|
||||||
const list = await this.getProducts(site, { page, per_page: pageSize });
|
const list = await this.getProducts(site, page, pageSize);
|
||||||
const header = ['id','name','type','status','sku','regular_price','sale_price','stock_status','stock_quantity'];
|
const header = ['id','name','type','status','sku','regular_price','sale_price','stock_status','stock_quantity'];
|
||||||
const rows = (list.items || []).map((p: any) => [p.id,p.name,p.type,p.status,p.sku,p.regular_price,p.sale_price,p.stock_status,p.stock_quantity]);
|
const rows = (list.items || []).map((p: any) => [p.id,p.name,p.type,p.status,p.sku,p.regular_price,p.sale_price,p.stock_status,p.stock_quantity]);
|
||||||
const csv = [header.join(','), ...rows.map(r => r.map(v => String(v ?? '')).join(','))].join('\n');
|
const csv = [header.join(','), ...rows.map(r => r.map(v => String(v ?? '')).join(','))].join('\n');
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
// 从 unified 到 数据库需要有个转换流程
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
// 文件转换
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
import { UnifiedOrderDTO } from "../dto/site-api.dto";
|
|
||||||
|
|
||||||
export class ShipmentAdapter {
|
|
||||||
// 用于导出物流需要的数据
|
|
||||||
mapFromOrder(order: UnifiedOrderDTO): any {
|
|
||||||
return order;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue