@pisell/pisellos 2.2.222 → 2.2.224

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 (61) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  2. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -0
  3. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +3 -0
  4. package/dist/modules/Customer/index.d.ts +7 -0
  5. package/dist/modules/Customer/index.js +16 -0
  6. package/dist/modules/OpenData/index.d.ts +7 -0
  7. package/dist/modules/OpenData/index.js +16 -1
  8. package/dist/modules/Order/index.d.ts +43 -0
  9. package/dist/modules/Order/index.js +296 -112
  10. package/dist/modules/Order/types.d.ts +16 -0
  11. package/dist/modules/Order/utils.js +7 -4
  12. package/dist/modules/Payment/index.d.ts +7 -0
  13. package/dist/modules/Payment/index.js +12 -0
  14. package/dist/modules/ProductList/index.d.ts +7 -0
  15. package/dist/modules/ProductList/index.js +11 -0
  16. package/dist/modules/SalesSummary/index.d.ts +7 -0
  17. package/dist/modules/SalesSummary/index.js +61 -26
  18. package/dist/modules/Schedule/index.d.ts +7 -0
  19. package/dist/modules/Schedule/index.js +16 -0
  20. package/dist/modules/Summary/index.js +2 -1
  21. package/dist/server/modules/order/types.d.ts +2 -0
  22. package/dist/server/modules/order/utils/filterBookings.js +25 -2
  23. package/dist/server/utils/small-ticket.js +160 -30
  24. package/dist/solution/BaseSales/index.d.ts +17 -0
  25. package/dist/solution/BaseSales/index.js +524 -439
  26. package/dist/solution/BaseSales/utils/cartPromotion.js +24 -7
  27. package/dist/solution/BookingByStep/index.d.ts +1 -1
  28. package/dist/solution/BookingTicket/index.d.ts +0 -8
  29. package/dist/solution/BookingTicket/index.js +41 -75
  30. package/dist/types/index.d.ts +10 -0
  31. package/lib/model/strategy/adapter/promotion/index.js +49 -0
  32. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -0
  33. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +3 -0
  34. package/lib/modules/Customer/index.d.ts +7 -0
  35. package/lib/modules/Customer/index.js +12 -0
  36. package/lib/modules/OpenData/index.d.ts +7 -0
  37. package/lib/modules/OpenData/index.js +13 -1
  38. package/lib/modules/Order/index.d.ts +43 -0
  39. package/lib/modules/Order/index.js +145 -3
  40. package/lib/modules/Order/types.d.ts +16 -0
  41. package/lib/modules/Order/utils.js +6 -2
  42. package/lib/modules/Payment/index.d.ts +7 -0
  43. package/lib/modules/Payment/index.js +9 -0
  44. package/lib/modules/ProductList/index.d.ts +7 -0
  45. package/lib/modules/ProductList/index.js +9 -0
  46. package/lib/modules/SalesSummary/index.d.ts +7 -0
  47. package/lib/modules/SalesSummary/index.js +15 -1
  48. package/lib/modules/Schedule/index.d.ts +7 -0
  49. package/lib/modules/Schedule/index.js +12 -0
  50. package/lib/modules/Summary/index.js +2 -1
  51. package/lib/server/modules/order/types.d.ts +2 -0
  52. package/lib/server/modules/order/utils/filterBookings.js +17 -2
  53. package/lib/server/utils/small-ticket.js +141 -32
  54. package/lib/solution/BaseSales/index.d.ts +17 -0
  55. package/lib/solution/BaseSales/index.js +48 -10
  56. package/lib/solution/BaseSales/utils/cartPromotion.js +28 -2
  57. package/lib/solution/BookingByStep/index.d.ts +1 -1
  58. package/lib/solution/BookingTicket/index.d.ts +0 -8
  59. package/lib/solution/BookingTicket/index.js +0 -12
  60. package/lib/types/index.d.ts +10 -0
  61. package/package.json +1 -1
@@ -243,11 +243,27 @@ var OrderModule = class extends import_BaseModule.BaseModule {
243
243
  this.cacheId = otherParams.cacheId;
244
244
  this.salesSummaryModuleName = otherParams.salesSummaryModuleName;
245
245
  this.rulesHooksOverride = (_a = otherParams.rules) == null ? void 0 : _a.hooks;
246
- this.orderHooks = options.hooks || ((_b = otherParams.order) == null ? void 0 : _b.hooks) || ((_c = otherParams.hooks) == null ? void 0 : _c.order);
246
+ this.moduleHooksOverride = options.hooks;
247
+ this.orderHooks = this.moduleHooksOverride || ((_b = otherParams.order) == null ? void 0 : _b.hooks) || ((_c = otherParams.hooks) == null ? void 0 : _c.order);
247
248
  this.otherParams = otherParams;
248
249
  this.registerDiscountModules(options);
249
250
  this.logInfo("OrderModule initialized successfully");
250
251
  }
252
+ /**
253
+ * 更新父级解决方案透传的运行态参数,并同步 Order 内部依赖的派生字段。
254
+ *
255
+ * @example
256
+ * orderModule.updateOtherParams({ cacheId: 'cache-2', channel: 'pos' });
257
+ */
258
+ updateOtherParams(params) {
259
+ var _a, _b, _c;
260
+ const otherParams = params || {};
261
+ this.cacheId = otherParams.cacheId;
262
+ this.salesSummaryModuleName = otherParams.salesSummaryModuleName;
263
+ this.rulesHooksOverride = (_a = otherParams.rules) == null ? void 0 : _a.hooks;
264
+ this.orderHooks = this.moduleHooksOverride || ((_b = otherParams.order) == null ? void 0 : _b.hooks) || ((_c = otherParams.hooks) == null ? void 0 : _c.order);
265
+ this.otherParams = otherParams;
266
+ }
251
267
  /**
252
268
  * 记录信息日志
253
269
  */
@@ -1438,6 +1454,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1438
1454
  );
1439
1455
  productMetadata.unique_identification_number = productUid;
1440
1456
  bookingMetadata.unique_identification_number = bookingUid;
1457
+ this.syncBookingMetadataHolder(params.booking, bookingMetadata);
1441
1458
  return {
1442
1459
  productUid,
1443
1460
  bookingUid,
@@ -1459,6 +1476,110 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1459
1476
  }
1460
1477
  };
1461
1478
  }
1479
+ /**
1480
+ * booking.holder 是提交真源;metadata.holder 作为详情/回显冗余字段同步保存。
1481
+ *
1482
+ * @example
1483
+ * this.syncBookingMetadataHolder(booking, metadata);
1484
+ */
1485
+ syncBookingMetadataHolder(booking, metadata) {
1486
+ if ((booking == null ? void 0 : booking.holder) !== void 0) {
1487
+ metadata.holder = booking.holder;
1488
+ }
1489
+ }
1490
+ /**
1491
+ * 从单条 booking 的 holder / metadata 中收集 holder form_record。
1492
+ *
1493
+ * @example
1494
+ * const ids = this.collectBookingHolderRecords(booking);
1495
+ */
1496
+ collectBookingHolderRecords(booking) {
1497
+ var _a;
1498
+ const holder = (booking == null ? void 0 : booking.holder) && typeof booking.holder === "object" ? booking.holder : null;
1499
+ const source = (holder == null ? void 0 : holder.form_record) ?? ((_a = booking == null ? void 0 : booking.metadata) == null ? void 0 : _a.holder_id);
1500
+ const records = Array.isArray(source) ? source : [source];
1501
+ return records.filter((record) => record !== void 0 && record !== null && record !== "");
1502
+ }
1503
+ /**
1504
+ * 按 form_record 顺序读取 booking holder 的主字段名称。
1505
+ *
1506
+ * @example
1507
+ * const names = this.collectBookingHolderNames(booking);
1508
+ */
1509
+ collectBookingHolderNames(booking) {
1510
+ const holder = (booking == null ? void 0 : booking.holder) && typeof booking.holder === "object" ? booking.holder : null;
1511
+ const rawName = holder == null ? void 0 : holder.name;
1512
+ if (Array.isArray(rawName)) {
1513
+ return rawName.map((name) => String(name || "").trim());
1514
+ }
1515
+ if (typeof rawName === "string") {
1516
+ return rawName.split(",").map((name) => name.trim());
1517
+ }
1518
+ return [];
1519
+ }
1520
+ /**
1521
+ * 按老 ticketBooking `formatHolder` 语义汇总订单顶层 holder。
1522
+ *
1523
+ * @example
1524
+ * const holder = this.buildTempOrderHolderFromBookings(tempOrder);
1525
+ */
1526
+ buildTempOrderHolderFromBookings(tempOrder) {
1527
+ var _a, _b;
1528
+ const holderRecords = [];
1529
+ const holderNames = [];
1530
+ let baseHolder = null;
1531
+ const seen = /* @__PURE__ */ new Set();
1532
+ for (const booking of tempOrder.bookings || []) {
1533
+ const holder = (booking == null ? void 0 : booking.holder) && typeof booking.holder === "object" ? booking.holder : null;
1534
+ if (!baseHolder && holder) {
1535
+ baseHolder = holder;
1536
+ }
1537
+ const records = this.collectBookingHolderRecords(booking);
1538
+ const names = this.collectBookingHolderNames(booking);
1539
+ for (const [index, record] of records.entries()) {
1540
+ const key = String(record);
1541
+ if (seen.has(key))
1542
+ continue;
1543
+ seen.add(key);
1544
+ holderRecords.push(record);
1545
+ if (names[index]) {
1546
+ holderNames.push(names[index]);
1547
+ }
1548
+ }
1549
+ }
1550
+ if (!holderRecords.length) {
1551
+ return null;
1552
+ }
1553
+ const nextHolder = {
1554
+ customer_id: (baseHolder == null ? void 0 : baseHolder.customer_id) ?? tempOrder.customer_id,
1555
+ form_id: (baseHolder == null ? void 0 : baseHolder.form_id) ?? ((_a = tempOrder.holder) == null ? void 0 : _a.form_id) ?? 0,
1556
+ form_record: holderRecords
1557
+ };
1558
+ if (holderNames.length) {
1559
+ nextHolder.name = holderNames.join(",");
1560
+ }
1561
+ if ((baseHolder == null ? void 0 : baseHolder.is_source_shop) || ((_b = this.otherParams) == null ? void 0 : _b.isFranchisee)) {
1562
+ nextHolder.is_source_shop = 1;
1563
+ }
1564
+ return nextHolder;
1565
+ }
1566
+ /**
1567
+ * 将 booking 级 holder 汇总到 tempOrder 顶层 holder。
1568
+ *
1569
+ * @example
1570
+ * this.syncTempOrderHolderFromBookings(tempOrder);
1571
+ */
1572
+ syncTempOrderHolderFromBookings(tempOrder) {
1573
+ const bookings = tempOrder.bookings || [];
1574
+ const hasHolderSource = bookings.some((booking) => {
1575
+ var _a;
1576
+ return (booking == null ? void 0 : booking.holder) !== void 0 || ((_a = booking == null ? void 0 : booking.metadata) == null ? void 0 : _a.holder_id) !== void 0;
1577
+ });
1578
+ const nextHolder = this.buildTempOrderHolderFromBookings(tempOrder);
1579
+ if (nextHolder || hasHolderSource || bookings.length === 0) {
1580
+ tempOrder.holder = nextHolder;
1581
+ }
1582
+ }
1462
1583
  getBookingUniqueIdentificationNumber(booking) {
1463
1584
  var _a;
1464
1585
  const uid = (_a = booking == null ? void 0 : booking.metadata) == null ? void 0 : _a.unique_identification_number;
@@ -1996,6 +2117,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1996
2117
  * await this.finalizeProductOrderMutation(tempOrder);
1997
2118
  */
1998
2119
  async finalizeProductOrderMutation(tempOrder) {
2120
+ this.syncTempOrderHolderFromBookings(tempOrder);
1999
2121
  await this.ensureEditDiscountConfigForProductChange(tempOrder);
2000
2122
  await this.applyPromotion();
2001
2123
  this.applyDiscount();
@@ -2028,7 +2150,8 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2028
2150
  const hasIncomingGoodPass = this.hasGoodPassDiscount(
2029
2151
  normalizedIncoming
2030
2152
  );
2031
- const shouldForceNewLine = !!booking;
2153
+ const hasIncomingProductNote = typeof normalizedIncoming.note === "string" && normalizedIncoming.note.trim().length > 0;
2154
+ const shouldForceNewLine = !!booking || hasIncomingProductNote;
2032
2155
  const matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex((item) => {
2033
2156
  if (this.hasGoodPassDiscount(item))
2034
2157
  return false;
@@ -2294,7 +2417,21 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2294
2417
  const isPersistedOrderLine = targetProduct.order_detail_id !== void 0 && targetProduct.order_detail_id !== null;
2295
2418
  const callerChangesDiscountList = Array.isArray(updates == null ? void 0 : updates.discount_list) && updates.discount_list.length > 0 && !isSameDiscountList(updates.discount_list, targetProduct.discount_list);
2296
2419
  const callerUpdatesManualPrice = ((_f = updates == null ? void 0 : updates.metadata) == null ? void 0 : _f.price_override) !== void 0 || ((_g = updates == null ? void 0 : updates.metadata) == null ? void 0 : _g.is_manual_discount) !== void 0 || ((_h = updates == null ? void 0 : updates.metadata) == null ? void 0 : _h.product_discount_reason) !== void 0 || callerChangesDiscountList;
2297
- if (isPersistedOrderLine && !callerUpdatesManualPrice) {
2420
+ const callerAllowsBookingReprice = (() => {
2421
+ if (params.allow_booking_reprice !== true || !booking || !callerUpdatesTopPrice || !callerUpdatesMainMeta) {
2422
+ return false;
2423
+ }
2424
+ const hasChangedPrice = (nextValue, currentValue) => {
2425
+ if (nextValue === void 0 || nextValue === null || nextValue === "") {
2426
+ return false;
2427
+ }
2428
+ return !new import_decimal.default(Number(nextValue) || 0).equals(
2429
+ new import_decimal.default(Number(currentValue) || 0)
2430
+ );
2431
+ };
2432
+ return hasChangedPrice(updates.selling_price, targetProduct.selling_price) || hasChangedPrice(updates.original_price, targetProduct.original_price);
2433
+ })();
2434
+ if (isPersistedOrderLine && !callerUpdatesManualPrice && !callerAllowsBookingReprice) {
2298
2435
  nextProduct.selling_price = targetProduct.selling_price;
2299
2436
  nextProduct.original_price = targetProduct.original_price;
2300
2437
  nextProduct.payment_price = targetProduct.payment_price;
@@ -2360,6 +2497,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2360
2497
  tempOrder.bookings = [...tempOrder.bookings || [], linked.booking];
2361
2498
  }
2362
2499
  tempOrder.products[productIndex] = normalizedProduct;
2500
+ this.syncTempOrderHolderFromBookings(tempOrder);
2363
2501
  this.captureProductRuntime(
2364
2502
  tempOrder,
2365
2503
  updates,
@@ -2458,9 +2596,11 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2458
2596
  unique_identification_number: bookingUid
2459
2597
  }
2460
2598
  };
2599
+ this.syncBookingMetadataHolder(nextBooking, nextBooking.metadata);
2461
2600
  nextBooking.is_all = (0, import_utils.normalizeBookingIsAll)(nextBooking);
2462
2601
  nextBooking.sub_type = (0, import_utils.normalizeBookingSubType)(nextBooking);
2463
2602
  tempOrder.bookings[bookingIndex] = nextBooking;
2603
+ this.syncTempOrderHolderFromBookings(tempOrder);
2464
2604
  this.persistTempOrder();
2465
2605
  return tempOrder.bookings;
2466
2606
  }
@@ -2472,6 +2612,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2472
2612
  * await this.finalizeAfterProductsMutation(tempOrder);
2473
2613
  */
2474
2614
  async finalizeAfterProductsMutation(tempOrder) {
2615
+ this.syncTempOrderHolderFromBookings(tempOrder);
2475
2616
  await this.applyPromotion();
2476
2617
  this.applyDiscount();
2477
2618
  this.sanitizeTempOrderProducts(tempOrder);
@@ -2513,6 +2654,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2513
2654
  const tempOrder = this.ensureTempOrder();
2514
2655
  tempOrder.products = [];
2515
2656
  tempOrder.bookings = [];
2657
+ this.syncTempOrderHolderFromBookings(tempOrder);
2516
2658
  if (tempOrder._extend && typeof tempOrder._extend === "object") {
2517
2659
  tempOrder._extend = {
2518
2660
  ...tempOrder._extend,
@@ -309,6 +309,19 @@ export interface UpdateOrderProductParams {
309
309
  product_sku?: OrderProductSku;
310
310
  product_bundle?: any[];
311
311
  booking?: AddProductBookingInput;
312
+ /**
313
+ * 预约时间 / 时长变更后允许使用本次报价覆盖已落库订单行历史价。
314
+ *
315
+ * @example
316
+ * await order.updateOrderProduct({
317
+ * product_id: 1,
318
+ * product_variant_id: 0,
319
+ * updates: { selling_price: '6.00', metadata: { source_product_price: '6.00' } },
320
+ * booking: { duration: 2 },
321
+ * allow_booking_reprice: true,
322
+ * });
323
+ */
324
+ allow_booking_reprice?: boolean;
312
325
  }
313
326
  /** 仅更新购物车行数量;行定位语义与 updateOrderProduct / removeProductFromOrder 保持一致 */
314
327
  export interface UpdateOrderProductQuantityParams extends OrderProductIdentity {
@@ -436,6 +449,8 @@ export interface PaymentItemData {
436
449
  type: string;
437
450
  /** 支付时间 (格式: YYYY-MM-DD HH:mm:ss) */
438
451
  payment_time?: string;
452
+ /** 支付项创建时间 (格式: YYYY-MM-DD HH:mm:ss) */
453
+ created_at?: string;
439
454
  /** @deprecated BaseSales/Sales 协议不提交该字段;旧 Checkout/Payment 内部仍可能使用 */
440
455
  isSynced?: boolean;
441
456
  }
@@ -470,6 +485,7 @@ export interface OrderPaymentData {
470
485
  amount?: string;
471
486
  };
472
487
  order_payment_type?: 'normal' | 'deposit';
488
+ /** 支付项创建时间 (格式: YYYY-MM-DD HH:mm:ss) */
473
489
  created_at?: string;
474
490
  updated_at?: string;
475
491
  }
@@ -608,7 +608,8 @@ var SUBMIT_BOOKING_METADATA_WHITELIST = [
608
608
  "collect_pax",
609
609
  "capacity",
610
610
  "holder_id",
611
- "resource_select_type"
611
+ "resource_select_type",
612
+ "holder"
612
613
  ];
613
614
  function normalizeBookingIsAll(booking) {
614
615
  return booking.is_all === true || booking.is_all === 1 || booking.is_all === "1" || booking.is_all === "true" ? 1 : 0;
@@ -818,7 +819,9 @@ function mapPaymentItemToOrderPayment(paymentItem) {
818
819
  metadata[key] = item[key];
819
820
  }
820
821
  }
821
- const paymentTime = item.payment_time ?? (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
822
+ const timestamp = (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
823
+ const paymentTime = item.payment_time ?? timestamp;
824
+ const createdAt = item.created_at ?? timestamp;
822
825
  return {
823
826
  ...item.order_payment_id !== void 0 ? { order_payment_id: item.order_payment_id } : {},
824
827
  amount: String(item.amount ?? "0.00"),
@@ -831,6 +834,7 @@ function mapPaymentItemToOrderPayment(paymentItem) {
831
834
  ...item.service_fee !== void 0 ? { service_fee: String(item.service_fee) } : {},
832
835
  ...item.status !== void 0 ? { status: item.status } : {},
833
836
  payment_time: paymentTime,
837
+ created_at: createdAt,
834
838
  ...item.wallet_pass_usage_unit !== void 0 ? { wallet_pass_usage_unit: item.wallet_pass_usage_unit } : {},
835
839
  ...item.wallet_pass_use_value !== void 0 ? { wallet_pass_use_value: item.wallet_pass_use_value } : {},
836
840
  ...item.fund_record && typeof item.fund_record === "object" && !Array.isArray(item.fund_record) ? { fund_record: { ...item.fund_record } } : {},
@@ -33,6 +33,13 @@ export declare class PaymentModule extends BaseModule implements Module, Payment
33
33
  private runVoucherUpdateLocked;
34
34
  private normalizeVoucherPaymentItems;
35
35
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
36
+ /**
37
+ * 更新父级解决方案透传的运行态参数,主要用于日志父模块等上下文。
38
+ *
39
+ * @example
40
+ * paymentModule.updateOtherParams({ fatherModule: 'bookingTicket' });
41
+ */
42
+ updateOtherParams(params: Record<string, any>): void;
36
43
  /**
37
44
  * 记录信息日志
38
45
  */
@@ -127,6 +127,15 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
127
127
  console.log("[PaymentModule] 初始化完成");
128
128
  this.logInfo("PaymentModule initialized successfully");
129
129
  }
130
+ /**
131
+ * 更新父级解决方案透传的运行态参数,主要用于日志父模块等上下文。
132
+ *
133
+ * @example
134
+ * paymentModule.updateOtherParams({ fatherModule: 'bookingTicket' });
135
+ */
136
+ updateOtherParams(params) {
137
+ this.otherParams = params || {};
138
+ }
130
139
  /**
131
140
  * 记录信息日志
132
141
  */
@@ -10,6 +10,13 @@ export declare class ProductList extends BaseModule implements Module {
10
10
  private otherParams;
11
11
  constructor(name?: string, version?: string);
12
12
  initialize(core: PisellCore, options: any): Promise<void>;
13
+ /**
14
+ * 更新运行态参数,供父级解决方案 setOtherParams 后同步查询上下文。
15
+ *
16
+ * @example
17
+ * productList.updateOtherParams({ channel: 'pos' });
18
+ */
19
+ updateOtherParams(params: Record<string, any>): void;
13
20
  storeChange(path?: string, value?: any): Promise<void>;
14
21
  loadProducts({ category_ids, product_ids, collection, menu_list_ids, customer_id: paramsCustomerId, with_count, schedule_datetime, schedule_date, cacheId, with_schedule, }: {
15
22
  category_ids?: number[];
@@ -47,6 +47,15 @@ var ProductList = class extends import_BaseModule.BaseModule {
47
47
  }
48
48
  this.request = core.getPlugin("request");
49
49
  }
50
+ /**
51
+ * 更新运行态参数,供父级解决方案 setOtherParams 后同步查询上下文。
52
+ *
53
+ * @example
54
+ * productList.updateOtherParams({ channel: 'pos' });
55
+ */
56
+ updateOtherParams(params) {
57
+ this.otherParams = params || {};
58
+ }
50
59
  async storeChange(path, value) {
51
60
  }
52
61
  async loadProducts({
@@ -11,6 +11,13 @@ export declare class SalesSummaryModule extends BaseModule implements Module, Sa
11
11
  private surchargeListModuleName;
12
12
  constructor(name?: string, version?: string);
13
13
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
14
+ /**
15
+ * 更新父级解决方案透传的运行态参数,并在 surcharge 模块名变化时刷新附加费列表。
16
+ *
17
+ * @example
18
+ * await salesSummaryModule.updateOtherParams({ surchargeListModuleName: 'custom_surchargeList' });
19
+ */
20
+ updateOtherParams(params: Record<string, any>): Promise<void>;
14
21
  getSurchargeList(): Promise<void>;
15
22
  private getAppData;
16
23
  private getTaxConfig;
@@ -57,6 +57,19 @@ var SalesSummaryModule = class extends import_BaseModule.BaseModule {
57
57
  }
58
58
  await this.getSurchargeList();
59
59
  }
60
+ /**
61
+ * 更新父级解决方案透传的运行态参数,并在 surcharge 模块名变化时刷新附加费列表。
62
+ *
63
+ * @example
64
+ * await salesSummaryModule.updateOtherParams({ surchargeListModuleName: 'custom_surchargeList' });
65
+ */
66
+ async updateOtherParams(params) {
67
+ const nextSurchargeListModuleName = (params == null ? void 0 : params.surchargeListModuleName) || "surchargeList";
68
+ if (nextSurchargeListModuleName === this.surchargeListModuleName)
69
+ return;
70
+ this.surchargeListModuleName = nextSurchargeListModuleName;
71
+ await this.getSurchargeList();
72
+ }
60
73
  async getSurchargeList() {
61
74
  try {
62
75
  const surchargeListModule = this.core.getModule(
@@ -100,12 +113,13 @@ var SalesSummaryModule = class extends import_BaseModule.BaseModule {
100
113
  };
101
114
  }
102
115
  async getSummary(params) {
116
+ var _a, _b;
103
117
  const { products = [], isPriceIncludeTax, taxRate, shopDiscount } = params;
104
118
  const taxConfig = this.getTaxConfig();
105
119
  const summarySchedule = this.core.getModule(
106
120
  `${this.name.split("_")[0]}_schedule`
107
121
  );
108
- const needScheduleIds = this.store.surchargeList.map((item) => item.available_schedule_ids).flat();
122
+ const needScheduleIds = (_b = (_a = this.store.surchargeList) == null ? void 0 : _a.map((item) => item.available_schedule_ids)) == null ? void 0 : _b.flat();
109
123
  const scheduleList = summarySchedule == null ? void 0 : summarySchedule.getScheduleListByIds(needScheduleIds);
110
124
  const scheduleById = {};
111
125
  if (Array.isArray(scheduleList)) {
@@ -11,6 +11,13 @@ export declare class ScheduleModule extends BaseModule implements Module, Schedu
11
11
  private fatherModule;
12
12
  constructor(name?: string, version?: string);
13
13
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
14
+ /**
15
+ * 更新父级解决方案透传的运行态参数,并刷新 schedule 缓存写入配置。
16
+ *
17
+ * @example
18
+ * scheduleModule.updateOtherParams({ openCache: true, cacheId: 'cache-2' });
19
+ */
20
+ updateOtherParams(params: Record<string, any>): void;
14
21
  /**
15
22
  * 加载当前店铺下所有 schedule
16
23
  *
@@ -73,6 +73,18 @@ var ScheduleModule = class extends import_BaseModule.BaseModule {
73
73
  this.fatherModule = options.otherParams.fatherModule;
74
74
  }
75
75
  }
76
+ /**
77
+ * 更新父级解决方案透传的运行态参数,并刷新 schedule 缓存写入配置。
78
+ *
79
+ * @example
80
+ * scheduleModule.updateOtherParams({ openCache: true, cacheId: 'cache-2' });
81
+ */
82
+ updateOtherParams(params) {
83
+ const otherParams = params || {};
84
+ this.openCache = otherParams.openCache ?? false;
85
+ this.cacheId = otherParams.cacheId;
86
+ this.fatherModule = otherParams.fatherModule;
87
+ }
76
88
  /**
77
89
  * 加载当前店铺下所有 schedule
78
90
  *
@@ -119,8 +119,9 @@ var SummaryModule = class extends import_BaseModule.BaseModule {
119
119
  });
120
120
  }
121
121
  getSurchargeforUtils(items) {
122
+ var _a;
122
123
  const scheduleModule = this.core.getModule("appointmentBooking_schedule");
123
- const needScheduleIds = this.store.surchargeList.map((item) => item.available_schedule_ids).flat();
124
+ const needScheduleIds = (_a = this.store.surchargeList) == null ? void 0 : _a.map((item) => item.available_schedule_ids).flat();
124
125
  const scheduleList = scheduleModule == null ? void 0 : scheduleModule.getScheduleListByIds(needScheduleIds);
125
126
  const scheduleById = {};
126
127
  if (Array.isArray(scheduleList)) {
@@ -241,6 +241,8 @@ export interface OrderPaymentItem {
241
241
  status?: OrderPaymentRecordStatus;
242
242
  /** 支付时间(输入/输出均保留)。来源:OrderPayment.payment_time */
243
243
  payment_time?: string | null;
244
+ /** 支付创建时间(输入/输出均保留)。来源:OrderPayment.created_at */
245
+ created_at?: string | null;
244
246
  /** 手续费配置。来源:OrderPayment.service_charge */
245
247
  service_charge?: Record<string, unknown> | null;
246
248
  /** Wallet Pass 使用单位 */
@@ -71,6 +71,21 @@ function bookingDateTimeString(datePart, timePart) {
71
71
  }
72
72
  return `${d} ${t}`.trim();
73
73
  }
74
+ function resolveBookingTimeRange(booking) {
75
+ const start = toTimestamp(bookingDateTimeString(booking.start_date, booking.start_time));
76
+ if (!start)
77
+ return null;
78
+ const end = toTimestamp(
79
+ bookingDateTimeString(
80
+ booking.end_date || booking.start_date,
81
+ booking.end_time || booking.start_time
82
+ )
83
+ ) || start;
84
+ return end >= start ? [start, end] : [end, start];
85
+ }
86
+ function isRangeOverlapping(left, right) {
87
+ return left[0] <= right[1] && left[1] >= right[0];
88
+ }
74
89
  function parseDateRange(range) {
75
90
  if (!Array.isArray(range) || range.length < 2)
76
91
  return null;
@@ -182,8 +197,8 @@ function matchBooking(booking, orderInfo, ctx) {
182
197
  if (ctx.appointmentStatusSet && !ctx.appointmentStatusSet.has(getBookingAppointmentStatus(booking)))
183
198
  return false;
184
199
  if (ctx.bookingTimeRange) {
185
- const ts = toTimestamp(bookingDateTimeString(booking.start_date, booking.start_time));
186
- if (ts < ctx.bookingTimeRange[0] || ts > ctx.bookingTimeRange[1])
200
+ const bookingRange = resolveBookingTimeRange(booking);
201
+ if (!bookingRange || !isRangeOverlapping(bookingRange, ctx.bookingTimeRange))
187
202
  return false;
188
203
  }
189
204
  if (ctx.afterExecutionTimeMs != null) {