@pisell/pisellos 2.2.198 → 2.2.200

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +7 -3
  2. package/dist/modules/Cart/utils/cartProduct.js +11 -1
  3. package/dist/modules/Cart/utils/changePrice.js +11 -11
  4. package/dist/modules/Order/index.js +155 -104
  5. package/dist/modules/Order/types.d.ts +1 -0
  6. package/dist/modules/Order/utils.d.ts +33 -2
  7. package/dist/modules/Order/utils.js +112 -55
  8. package/dist/modules/SalesSummary/utils.js +97 -63
  9. package/dist/server/index.d.ts +3 -0
  10. package/dist/server/index.js +294 -190
  11. package/dist/server/modules/order/index.d.ts +8 -0
  12. package/dist/server/modules/order/index.js +536 -317
  13. package/dist/server/modules/order/types.d.ts +2 -0
  14. package/dist/solution/BaseSales/index.js +2 -1
  15. package/dist/solution/BaseSales/types.d.ts +1 -0
  16. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +19 -4
  17. package/dist/solution/BookingTicket/index.d.ts +23 -0
  18. package/dist/solution/BookingTicket/index.js +291 -196
  19. package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +40 -0
  20. package/dist/solution/BookingTicket/utils/bookingStatus.js +70 -0
  21. package/dist/solution/ScanOrder/types.d.ts +1 -0
  22. package/dist/solution/ScanOrder/utils.js +26 -9
  23. package/dist/solution/VenueBooking/index.js +2 -1
  24. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +4 -1
  25. package/lib/modules/Cart/utils/cartProduct.js +11 -1
  26. package/lib/modules/Cart/utils/changePrice.js +12 -20
  27. package/lib/modules/Order/index.js +58 -6
  28. package/lib/modules/Order/types.d.ts +1 -0
  29. package/lib/modules/Order/utils.d.ts +33 -2
  30. package/lib/modules/Order/utils.js +44 -9
  31. package/lib/modules/SalesSummary/utils.js +41 -44
  32. package/lib/server/index.d.ts +3 -0
  33. package/lib/server/index.js +82 -3
  34. package/lib/server/modules/order/index.d.ts +8 -0
  35. package/lib/server/modules/order/index.js +106 -4
  36. package/lib/server/modules/order/types.d.ts +2 -0
  37. package/lib/solution/BaseSales/index.js +2 -1
  38. package/lib/solution/BaseSales/types.d.ts +1 -0
  39. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +15 -1
  40. package/lib/solution/BookingTicket/index.d.ts +23 -0
  41. package/lib/solution/BookingTicket/index.js +60 -0
  42. package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +40 -0
  43. package/lib/solution/BookingTicket/utils/bookingStatus.js +44 -2
  44. package/lib/solution/ScanOrder/types.d.ts +1 -0
  45. package/lib/solution/ScanOrder/utils.js +28 -10
  46. package/lib/solution/VenueBooking/index.js +2 -1
  47. package/package.json +1 -1
@@ -9,6 +9,21 @@
9
9
  * 字段含义严格对齐既有协议(OrderTempOrder / parseSalesResponse),
10
10
  * 不发明等价关系。
11
11
  */
12
+ /**
13
+ * 子预约状态机转移动作(POST /schedule/booking-transition/{schedule_event_id})。
14
+ *
15
+ * @example
16
+ * await bookingTicket.transitionChildBooking({
17
+ * schedule_event_id: 301,
18
+ * action: 'confirm',
19
+ * });
20
+ */
21
+ export type BookingTransitionAction = 'confirm' | 'reject' | 'arrive' | 'start' | 'complete' | 'cancel' | 'no_show' | 'reschedule';
22
+ /** 子预约状态转移入参 */
23
+ export interface TransitionChildBookingParams {
24
+ schedule_event_id: number | string;
25
+ action: BookingTransitionAction;
26
+ }
12
27
  /**
13
28
  * 从 tempOrder 解析用于调用 appointment-status 接口的 schedule id。
14
29
  *
@@ -35,3 +50,28 @@ export declare function applyBookingsStatus(bookings: any[] | null | undefined,
35
50
  * 长度不一致时按较短一方对齐(防御式编程,正常路径不会发生)。
36
51
  */
37
52
  export declare function restoreBookingsStatus(bookings: any[] | null | undefined, previous: Array<string | undefined>): void;
53
+ /**
54
+ * 将状态机 action 解析为转移后的 `appointment_status`。
55
+ *
56
+ * `reschedule` 暂未在状态矩阵启用,返回 null 表示跳过乐观更新。
57
+ *
58
+ * @example
59
+ * resolveStatusAfterTransition('confirm'); // 'confirmed'
60
+ */
61
+ export declare function resolveStatusAfterTransition(action: BookingTransitionAction): string | null;
62
+ /**
63
+ * 在 bookings 中按 `schedule_event_id` 定位子预约并乐观写入 `appointment_status`。
64
+ *
65
+ * @returns 写入前的 status;未命中时返回 undefined(调用方跳过回滚)
66
+ *
67
+ * @example
68
+ * const prev = applyChildBookingStatus(tempOrder.bookings, 301, 'confirmed');
69
+ */
70
+ export declare function applyChildBookingStatus(bookings: any[] | null | undefined, scheduleEventId: number | string, status: string): string | undefined;
71
+ /**
72
+ * 撤销 applyChildBookingStatus 对单条子预约的乐观写入。
73
+ *
74
+ * @example
75
+ * restoreChildBookingStatus(tempOrder.bookings, 301, prev);
76
+ */
77
+ export declare function restoreChildBookingStatus(bookings: any[] | null | undefined, scheduleEventId: number | string, previous: string | undefined): void;
@@ -20,8 +20,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  var bookingStatus_exports = {};
21
21
  __export(bookingStatus_exports, {
22
22
  applyBookingsStatus: () => applyBookingsStatus,
23
+ applyChildBookingStatus: () => applyChildBookingStatus,
23
24
  resolveScheduleId: () => resolveScheduleId,
24
- restoreBookingsStatus: () => restoreBookingsStatus
25
+ resolveStatusAfterTransition: () => resolveStatusAfterTransition,
26
+ restoreBookingsStatus: () => restoreBookingsStatus,
27
+ restoreChildBookingStatus: () => restoreChildBookingStatus
25
28
  });
26
29
  module.exports = __toCommonJS(bookingStatus_exports);
27
30
  function resolveScheduleId(tempOrder) {
@@ -57,9 +60,48 @@ function restoreBookingsStatus(bookings, previous) {
57
60
  b.appointment_status = previous[i];
58
61
  }
59
62
  }
63
+ function resolveStatusAfterTransition(action) {
64
+ const map = {
65
+ confirm: "confirmed",
66
+ reject: "rejected",
67
+ arrive: "arrived",
68
+ start: "started",
69
+ complete: "completed",
70
+ cancel: "cancelled",
71
+ no_show: "no_show",
72
+ reschedule: null
73
+ };
74
+ return map[action] ?? null;
75
+ }
76
+ function applyChildBookingStatus(bookings, scheduleEventId, status) {
77
+ var _a;
78
+ if (!Array.isArray(bookings))
79
+ return void 0;
80
+ const idx = bookings.findIndex(
81
+ (b) => b && String(b.schedule_event_id) === String(scheduleEventId)
82
+ );
83
+ if (idx === -1)
84
+ return void 0;
85
+ const previous = (_a = bookings[idx]) == null ? void 0 : _a.appointment_status;
86
+ bookings[idx].appointment_status = status;
87
+ return previous;
88
+ }
89
+ function restoreChildBookingStatus(bookings, scheduleEventId, previous) {
90
+ if (!Array.isArray(bookings) || previous === void 0)
91
+ return;
92
+ const idx = bookings.findIndex(
93
+ (b) => b && String(b.schedule_event_id) === String(scheduleEventId)
94
+ );
95
+ if (idx === -1)
96
+ return;
97
+ bookings[idx].appointment_status = previous;
98
+ }
60
99
  // Annotate the CommonJS export names for ESM import in node:
61
100
  0 && (module.exports = {
62
101
  applyBookingsStatus,
102
+ applyChildBookingStatus,
63
103
  resolveScheduleId,
64
- restoreBookingsStatus
104
+ resolveStatusAfterTransition,
105
+ restoreBookingsStatus,
106
+ restoreChildBookingStatus
65
107
  });
@@ -115,6 +115,7 @@ export interface ScanOrderSummary {
115
115
  shipping_tax_fee: string;
116
116
  tax_fee: string;
117
117
  surcharge_fee: string;
118
+ surcharges: any[];
118
119
  discount_amount: string;
119
120
  deposit_amount: string;
120
121
  deposit?: {
@@ -75,6 +75,7 @@ function createEmptySummary() {
75
75
  shipping_tax_fee: "0.00",
76
76
  tax_fee: "0.00",
77
77
  surcharge_fee: "0.00",
78
+ surcharges: [],
78
79
  discount_amount: "0.00",
79
80
  deposit_amount: "0.00",
80
81
  expect_amount: "0.00",
@@ -436,16 +437,33 @@ function normalizeOrderProduct(product) {
436
437
  };
437
438
  });
438
439
  }
439
- const normalizedBundle = bundleInput.map((item) => ({
440
- ...item,
441
- bundle_id: item.bundle_id ?? item.id,
442
- bundle_product_id: item.bundle_product_id ?? item._bundle_product_id,
443
- bundle_group_id: item.bundle_group_id ?? item.group_id,
444
- bundle_selling_price: item.bundle_selling_price ?? item.price ?? "0.00",
445
- price: item.price ?? item.custom_price ?? item.bundle_selling_price ?? "0.00",
446
- price_type: item.price_type ?? item.custom_price_type ?? "",
447
- price_type_ext: item.price_type_ext ?? item.custom_price_type_ext ?? ""
448
- }));
440
+ const normalizedBundle = bundleInput.map((item) => {
441
+ const magnitudeSource = {
442
+ ...item,
443
+ // 计算 markdown 净额时,只把真实毛价交给 helper;若只有 bundle_selling_price,
444
+ // helper 会按历史净额兜底,避免 option 二次扣减。
445
+ price: item.price ?? item.custom_price
446
+ };
447
+ const normalizedItem = {
448
+ ...item,
449
+ bundle_id: item.bundle_id ?? item.id,
450
+ bundle_product_id: item.bundle_product_id ?? item._bundle_product_id,
451
+ bundle_group_id: item.bundle_group_id ?? item.group_id,
452
+ // price 保留毛价(markdown 仍为 5),由 price_type 决定符号。
453
+ price: item.price ?? item.custom_price ?? item.bundle_selling_price ?? "0.00",
454
+ price_type: item.price_type ?? item.custom_price_type ?? "",
455
+ price_type_ext: item.price_type_ext ?? item.custom_price_type_ext ?? ""
456
+ };
457
+ normalizedItem.bundle_selling_price = (0, import_utils.getBundleSellingMagnitude)(magnitudeSource).toFixed(2);
458
+ if (normalizedItem.price_type === "markdown" && (normalizedItem.price_type_ext === "" || normalizedItem.price_type_ext === void 0 || normalizedItem.price_type_ext === null)) {
459
+ normalizedItem.custom_price = normalizedItem.custom_price ?? normalizedItem.price;
460
+ normalizedItem.price = normalizedItem.bundle_selling_price;
461
+ }
462
+ if ((normalizedItem.price_type === "markdown" || normalizedItem.price_type === "markup") && (normalizedItem.price_type_ext === "" || normalizedItem.price_type_ext === void 0 || normalizedItem.price_type_ext === null)) {
463
+ delete normalizedItem.original_total;
464
+ }
465
+ return normalizedItem;
466
+ });
449
467
  const normalizedOptions = (0, import_utils.normalizeProductSkuOptions)((_e = product.product_sku) == null ? void 0 : _e.option);
450
468
  const optionSum = (0, import_utils.sumOptionUnitPrice)(normalizedOptions);
451
469
  const productSku = {
@@ -1395,7 +1395,8 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
1395
1395
  getOrderProducts() {
1396
1396
  if (!this.store.order)
1397
1397
  throw new Error("order 模块未初始化");
1398
- return this.store.order.getOrderProducts();
1398
+ const products = this.store.order.getOrderProducts();
1399
+ return products;
1399
1400
  }
1400
1401
  async getSummary() {
1401
1402
  this.logMethodStart("getSummary");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.198",
4
+ "version": "2.2.200",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",