forked from yoone/API
1
0
Fork 0

refactor(service): 统一将wPService重命名为wpService以符合命名规范

This commit is contained in:
tikkhun 2025-11-17 11:03:25 +08:00
parent dc070fadde
commit e94ea5ed58
2 changed files with 13 additions and 13 deletions

View File

@ -38,7 +38,7 @@ export class OrderService {
sites: WpSite[];
@Inject()
wPService: WPService;
wpService: WPService;
@Inject()
stockService: StockService;
@ -101,14 +101,14 @@ export class OrderService {
customerModel: Repository<Customer>;
async syncOrders(siteId: string) {
const orders = await this.wPService.getOrders(siteId); // 调用 WooCommerce API 获取订单
const orders = await this.wpService.getOrders(siteId); // 调用 WooCommerce API 获取订单
for (const order of orders) {
await this.syncSingleOrder(siteId, order);
}
}
async syncOrderById(siteId: string, orderId: string) {
const order = await this.wPService.getOrder(siteId, orderId);
const order = await this.wpService.getOrder(siteId, orderId);
await this.syncSingleOrder(siteId, order, true);
}
// 订单状态切换表
@ -131,7 +131,7 @@ export class OrderService {
throw new Error(`更新订单信息,但失败,原因为 ${siteId} 的站点信息不存在`)
}
// 同步更新回 wordpress 的 order 状态
await this.wPService.updateOrder(site, order.id, { status: order.status });
await this.wpService.updateOrder(site, order.id, { status: order.status });
order.status = this.orderAutoNextStatusMap[originStatus];
} catch (error) {
console.error('更新订单状态失败,原因为:', error)
@ -442,7 +442,7 @@ export class OrderService {
refunds: Record<string, any>[];
}) {
for (const item of refunds) {
const refund = await this.wPService.getOrderRefund(
const refund = await this.wpService.getOrderRefund(
siteId,
externalOrderId,
item.id
@ -1261,9 +1261,9 @@ export class OrderService {
async cancelOrder(id: number) {
const order = await this.orderModel.findOne({ where: { id } });
if (!order) throw new Error(`订单 ${id}不存在`);
const site = this.wPService.geSite(order.siteId);
const site = this.wpService.geSite(order.siteId);
if (order.status !== OrderStatus.CANCEL) {
await this.wPService.updateOrder(site, order.externalOrderId, {
await this.wpService.updateOrder(site, order.externalOrderId, {
status: OrderStatus.CANCEL,
});
order.status = OrderStatus.CANCEL;
@ -1275,9 +1275,9 @@ export class OrderService {
async refundOrder(id: number) {
const order = await this.orderModel.findOne({ where: { id } });
if (!order) throw new Error(`订单 ${id}不存在`);
const site = this.wPService.geSite(order.siteId);
const site = this.wpService.geSite(order.siteId);
if (order.status !== OrderStatus.REFUNDED) {
await this.wPService.updateOrder(site, order.externalOrderId, {
await this.wpService.updateOrder(site, order.externalOrderId, {
status: OrderStatus.REFUNDED,
});
order.status = OrderStatus.REFUNDED;
@ -1289,9 +1289,9 @@ export class OrderService {
async completedOrder(id: number) {
const order = await this.orderModel.findOne({ where: { id } });
if (!order) throw new Error(`订单 ${id}不存在`);
const site = this.wPService.geSite(order.siteId);
const site = this.wpService.geSite(order.siteId);
if (order.status !== OrderStatus.COMPLETED) {
await this.wPService.updateOrder(site, order.externalOrderId, {
await this.wpService.updateOrder(site, order.externalOrderId, {
status: OrderStatus.COMPLETED,
});
order.status = OrderStatus.COMPLETED;

View File

@ -10,7 +10,7 @@ import { QuerySubscriptionDTO } from '../dto/subscription.dto';
@Provide()
export class SubscriptionService {
@Inject()
wPService: WPService;
wpService: WPService;
@InjectEntityModel(Subscription)
subscriptionModel: Repository<Subscription>;
@ -20,7 +20,7 @@ export class SubscriptionService {
* - WooCommerce /
*/
async syncSubscriptions(siteId: string) {
const subs = await this.wPService.getSubscriptions(siteId);
const subs = await this.wpService.getSubscriptions(siteId);
for (const sub of subs) {
await this.syncSingleSubscription(siteId, sub);
}