@pisell/pisellos 2.3.15 → 2.3.17

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.
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
311
311
  date: string;
312
312
  status: string;
313
313
  week: string;
314
- weekNum: 0 | 5 | 1 | 2 | 3 | 6 | 4;
314
+ weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -322,7 +322,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
322
322
  * 获取当前的客户搜索条件
323
323
  * @returns 当前搜索条件
324
324
  */
325
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
325
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
326
326
  /**
327
327
  * 获取客户列表状态(包含滚动加载相关状态)
328
328
  * @returns 客户状态
@@ -555,7 +555,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
555
555
  handlePrintWristband(params: {
556
556
  voucher_ids: number[];
557
557
  }): Promise<void>;
558
- handleCheckIn(params: {
558
+ handleRedeem(params: {
559
559
  voucher_ids: number[];
560
560
  is_checkin: boolean;
561
561
  }): Promise<any>;
@@ -2657,45 +2657,35 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2657
2657
  return _handlePrintWristband.apply(this, arguments);
2658
2658
  }
2659
2659
  return handlePrintWristband;
2660
- }() // 触发 checkIn
2660
+ }() // 触发核销
2661
2661
  }, {
2662
- key: "handleCheckIn",
2662
+ key: "handleRedeem",
2663
2663
  value: function () {
2664
- var _handleCheckIn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
2664
+ var _handleRedeem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
2665
2665
  var _this$store$order5, _this$store$order5$ge, _this$store$order6, _ref20, _tempOrder$order_id2;
2666
- var voucherIds, voucherIdSet, tempOrder, vouchers, batchMetadata, hasUpdatedVoucher, nextVouchers, identity, externalSaleNumber, orderId, orderLookup;
2666
+ var voucherIds, status, voucherIdSet, tempOrder, vouchers, hasUpdatedVoucher, nextVouchers, identity, externalSaleNumber, orderId, orderLookup;
2667
2667
  return _regeneratorRuntime().wrap(function _callee33$(_context33) {
2668
2668
  while (1) switch (_context33.prev = _context33.next) {
2669
2669
  case 0:
2670
+ voucherIds = Array.isArray(params.voucher_ids) ? params.voucher_ids : [];
2671
+ status = params.is_checkin ? 'used' : 'unused';
2670
2672
  this.logger.addLog({
2671
2673
  type: 'info',
2672
- title: '[BookingTicket] handleCheckIn',
2674
+ title: '[BookingTicket] handleRedeem',
2673
2675
  metadata: {
2674
- voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids],
2675
- is_checkin: params.is_checkin
2676
+ voucher_ids: voucherIds,
2677
+ status: status
2676
2678
  }
2677
2679
  });
2678
- voucherIds = Array.isArray(params.voucher_ids) ? params.voucher_ids : [];
2679
2680
  voucherIdSet = new Set(voucherIds);
2680
2681
  tempOrder = (_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 || (_this$store$order5$ge = _this$store$order5.getTempOrder) === null || _this$store$order5$ge === void 0 ? void 0 : _this$store$order5$ge.call(_this$store$order5);
2681
2682
  vouchers = (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.vouchers) || ((_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 ? void 0 : _this$store$order6.getVouchers()) || [];
2682
- batchMetadata = [];
2683
2683
  hasUpdatedVoucher = false;
2684
2684
  nextVouchers = vouchers.map(function (voucher) {
2685
- var _voucher$metadata;
2686
2685
  if (!voucherIdSet.has(voucher.voucher_id)) return voucher;
2687
2686
  hasUpdatedVoucher = true;
2688
- var metadata = _objectSpread(_objectSpread({}, voucher.metadata || {}), {}, {
2689
- ticket: _objectSpread(_objectSpread({}, ((_voucher$metadata = voucher.metadata) === null || _voucher$metadata === void 0 ? void 0 : _voucher$metadata.ticket) || {}), {}, {
2690
- is_checkin: params.is_checkin
2691
- })
2692
- });
2693
- batchMetadata.push({
2694
- voucher_id: voucher.voucher_id,
2695
- metadata: metadata
2696
- });
2697
2687
  return _objectSpread(_objectSpread({}, voucher), {}, {
2698
- metadata: metadata
2688
+ status: status
2699
2689
  });
2700
2690
  });
2701
2691
  if (!(tempOrder && hasUpdatedVoucher)) {
@@ -2708,7 +2698,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2708
2698
  }));
2709
2699
  case 11:
2710
2700
  this.core.effects.emit("".concat(this.name, ":onVouchersChange"), {});
2711
- if (!(batchMetadata.length === 0)) {
2701
+ if (!(voucherIds.length === 0)) {
2712
2702
  _context33.next = 14;
2713
2703
  break;
2714
2704
  }
@@ -2723,8 +2713,9 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2723
2713
  externalSaleNumber = (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.external_sale_number) || (identity === null || identity === void 0 ? void 0 : identity.externalSaleNumber) || undefined;
2724
2714
  orderId = (_ref20 = (_tempOrder$order_id2 = tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.order_id) !== null && _tempOrder$order_id2 !== void 0 ? _tempOrder$order_id2 : identity === null || identity === void 0 ? void 0 : identity.orderId) !== null && _ref20 !== void 0 ? _ref20 : undefined;
2725
2715
  orderLookup = externalSaleNumber || orderId || (identity === null || identity === void 0 ? void 0 : identity.orderNumber) || (identity === null || identity === void 0 ? void 0 : identity.shopOrderNumber) || (identity === null || identity === void 0 ? void 0 : identity.shopFullOrderNumber) || undefined;
2726
- return _context33.abrupt("return", this.request.post('/machinecode/batch-metadata', {
2727
- data: batchMetadata,
2716
+ return _context33.abrupt("return", this.request.post('/machinecode/batch', {
2717
+ ids: voucherIds,
2718
+ status: status,
2728
2719
  order_lookup: orderLookup,
2729
2720
  order_id: orderId,
2730
2721
  external_sale_number: externalSaleNumber
@@ -2737,10 +2728,10 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2737
2728
  }
2738
2729
  }, _callee33, this);
2739
2730
  }));
2740
- function handleCheckIn(_x24) {
2741
- return _handleCheckIn.apply(this, arguments);
2731
+ function handleRedeem(_x24) {
2732
+ return _handleRedeem.apply(this, arguments);
2742
2733
  }
2743
- return handleCheckIn;
2734
+ return handleRedeem;
2744
2735
  }()
2745
2736
  /**
2746
2737
  * 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
@@ -0,0 +1,49 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/model/strategy/adapter/promotion/index.ts
30
+ var promotion_exports = {};
31
+ __export(promotion_exports, {
32
+ BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
33
+ PromotionAdapter: () => import_adapter.PromotionAdapter,
34
+ PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
35
+ X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
36
+ default: () => import_adapter2.default
37
+ });
38
+ module.exports = __toCommonJS(promotion_exports);
39
+ var import_evaluator = require("./evaluator");
40
+ var import_adapter = require("./adapter");
41
+ var import_adapter2 = __toESM(require("./adapter"));
42
+ var import_examples = require("./examples");
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ BUY_X_GET_Y_FREE_STRATEGY,
46
+ PromotionAdapter,
47
+ PromotionEvaluator,
48
+ X_ITEMS_FOR_Y_PRICE_STRATEGY
49
+ });
@@ -230,6 +230,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
230
230
  * const ids = this.collectBookingHolderRecords(booking);
231
231
  */
232
232
  private collectBookingHolderRecords;
233
+ private setProductHolderFromBooking;
234
+ private syncLinkedBookingHoldersToProducts;
233
235
  /**
234
236
  * 按 form_record 顺序读取 booking holder 的主字段名称。
235
237
  *
@@ -458,7 +460,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
458
460
  generateIdempotencyToken(): string;
459
461
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
460
462
  createOrder(params: CommitOrderParams['query']): {
461
- type: "appointment_booking" | "virtual";
463
+ type: "virtual" | "appointment_booking";
462
464
  platform: string;
463
465
  sales_channel: string;
464
466
  order_sales_channel: string;
@@ -544,6 +544,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
544
544
  const tempOrder = this.store.tempOrder;
545
545
  if (!tempOrder)
546
546
  return;
547
+ this.syncLinkedBookingHoldersToProducts(tempOrder);
547
548
  delete tempOrder.discount_list;
548
549
  const discountList = ((_a = this.store.discount) == null ? void 0 : _a.getDiscountList()) || [];
549
550
  const shouldSkipDiscountCalculation = this.shouldSkipDiscountCalculation(tempOrder);
@@ -1787,6 +1788,47 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1787
1788
  const records = Array.isArray(source) ? source : [source];
1788
1789
  return records.filter((record) => record !== void 0 && record !== null && record !== "");
1789
1790
  }
1791
+ setProductHolderFromBooking(product, booking) {
1792
+ if (!product || !booking)
1793
+ return;
1794
+ const holderRecords = this.collectBookingHolderRecords(booking);
1795
+ if (!product.metadata || typeof product.metadata !== "object") {
1796
+ product.metadata = {};
1797
+ }
1798
+ product.metadata.holder_id = holderRecords.length > 0 ? holderRecords : null;
1799
+ }
1800
+ syncLinkedBookingHoldersToProducts(tempOrder) {
1801
+ const bookings = tempOrder.bookings || [];
1802
+ const products = tempOrder.products || [];
1803
+ if (!bookings.length || !products.length)
1804
+ return;
1805
+ const bookingByProductUid = /* @__PURE__ */ new Map();
1806
+ const bookingByBookingUid = /* @__PURE__ */ new Map();
1807
+ bookings.forEach((booking) => {
1808
+ var _a, _b;
1809
+ if (!booking || typeof booking !== "object")
1810
+ return;
1811
+ const productUid = booking.product_uid || ((_a = booking.metadata) == null ? void 0 : _a.product_uid);
1812
+ if (productUid !== void 0 && productUid !== null && String(productUid) !== "") {
1813
+ bookingByProductUid.set(String(productUid), booking);
1814
+ }
1815
+ const bookingUid = ((_b = booking.metadata) == null ? void 0 : _b.unique_identification_number) || booking.booking_uid;
1816
+ if (bookingUid !== void 0 && bookingUid !== null && String(bookingUid) !== "") {
1817
+ bookingByBookingUid.set(String(bookingUid), booking);
1818
+ }
1819
+ });
1820
+ products.forEach((product) => {
1821
+ var _a, _b;
1822
+ if (!product || typeof product !== "object")
1823
+ return;
1824
+ const productUid = ((_a = product.metadata) == null ? void 0 : _a.unique_identification_number) || product.unique_identification_number;
1825
+ const bookingUid = product.booking_uid || ((_b = product.metadata) == null ? void 0 : _b.booking_uid);
1826
+ const linkedBooking = (productUid !== void 0 && productUid !== null && String(productUid) !== "" ? bookingByProductUid.get(String(productUid)) : void 0) || (bookingUid !== void 0 && bookingUid !== null && String(bookingUid) !== "" ? bookingByBookingUid.get(String(bookingUid)) : void 0);
1827
+ if (linkedBooking) {
1828
+ this.setProductHolderFromBooking(product, linkedBooking);
1829
+ }
1830
+ });
1831
+ }
1790
1832
  /**
1791
1833
  * 按 form_record 顺序读取 booking holder 的主字段名称。
1792
1834
  *
@@ -1866,6 +1908,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1866
1908
  if (nextHolder || hasHolderSource || bookings.length === 0) {
1867
1909
  tempOrder.holder = nextHolder;
1868
1910
  }
1911
+ this.syncLinkedBookingHoldersToProducts(tempOrder);
1869
1912
  }
1870
1913
  getBookingUniqueIdentificationNumber(booking) {
1871
1914
  var _a;
@@ -4069,6 +4112,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
4069
4112
  product.booking_uid = linkedBookingUid;
4070
4113
  product.metadata.booking_uid = linkedBookingUid;
4071
4114
  });
4115
+ this.syncLinkedBookingHoldersToProducts(tempOrder);
4072
4116
  }
4073
4117
  pickHydratedDisplayText(value) {
4074
4118
  if (value === void 0 || value === null)
@@ -308,6 +308,8 @@ function getFallbackAllProductSurchargeIds(surchargeList) {
308
308
  return ids;
309
309
  if (Number(config.is_all ?? 0) !== 1)
310
310
  return ids;
311
+ if (Number(config.open_schedule ?? 0) === 1 && config.schedule_type !== "all")
312
+ return ids;
311
313
  ids.push(id);
312
314
  return ids;
313
315
  }, []);
@@ -431,9 +431,9 @@ declare class Server {
431
431
  private shouldLookupLocalPrintOrder;
432
432
  private getLocalPrintOrderLookup;
433
433
  private handleLocalPrintOrder;
434
- private handleMachinecodeBatchMetadata;
434
+ private handleMachinecodeBatchMeta;
435
435
  private resolveMachinecodeBatchMetadataLookup;
436
- private syncMachinecodeBatchMetadataToLocalOrder;
436
+ private syncMachinecodeRedeemStatusToLocalOrder;
437
437
  private handleOrderCheckoutSubmit;
438
438
  private handleSyncCheckoutSubmit;
439
439
  private handlePendingSyncCheckoutOrder;
@@ -662,17 +662,19 @@ var Server = class {
662
662
  };
663
663
  }
664
664
  };
665
- this.handleMachinecodeBatchMetadata = async ({ data }) => {
665
+ this.handleMachinecodeBatchMeta = async ({ data }) => {
666
666
  var _a, _b;
667
- const title = "handleMachinecodeBatchMetadata";
668
- const backendPath = "/shop/machinecode/batch-metadata";
669
- const batchMetadata = Array.isArray(data == null ? void 0 : data.data) ? data.data : [];
667
+ const title = "handleMachinecodeBatchMeta";
668
+ const backendPath = "/shop/machinecode/batch";
669
+ const ids = Array.isArray(data == null ? void 0 : data.ids) ? data.ids : [];
670
+ const status = data == null ? void 0 : data.status;
670
671
  this.logInfo(`${title}: 开始处理`, {
671
672
  backendPath,
672
- batchSize: batchMetadata.length,
673
+ batchSize: ids.length,
674
+ status,
673
675
  order_lookup: this.resolveMachinecodeBatchMetadataLookup(data) ?? null
674
676
  });
675
- if (batchMetadata.length === 0) {
677
+ if (ids.length === 0) {
676
678
  return {
677
679
  code: 200,
678
680
  status: true,
@@ -680,11 +682,19 @@ var Server = class {
680
682
  data: []
681
683
  };
682
684
  }
685
+ if (status !== "used" && status !== "unused") {
686
+ return {
687
+ code: 400,
688
+ status: false,
689
+ message: "无效的核销状态",
690
+ data: null
691
+ };
692
+ }
683
693
  try {
684
- await this.syncMachinecodeBatchMetadataToLocalOrder(data, batchMetadata);
694
+ await this.syncMachinecodeRedeemStatusToLocalOrder(data, ids, status);
685
695
  } catch (error) {
686
696
  const message = this.getUnknownErrorMessage(error);
687
- this.logError(`${title}: 本地订单 metadata 更新失败`, {
697
+ this.logError(`${title}: 本地订单核销状态更新失败`, {
688
698
  error: message,
689
699
  error_detail: this.normalizeUnknownError(error)
690
700
  });
@@ -706,7 +716,8 @@ var Server = class {
706
716
  }
707
717
  try {
708
718
  const response = await this.app.request.post(backendPath, {
709
- data: batchMetadata
719
+ ids,
720
+ status
710
721
  }, {
711
722
  isShopApi: true,
712
723
  customToast: () => {
@@ -1827,13 +1838,13 @@ var Server = class {
1827
1838
  },
1828
1839
  {
1829
1840
  method: "post",
1830
- path: "/shop/machinecode/batch-metadata",
1831
- handler: this.handleMachinecodeBatchMetadata.bind(this)
1841
+ path: "/shop/machinecode/batch",
1842
+ handler: this.handleMachinecodeBatchMeta.bind(this)
1832
1843
  },
1833
1844
  {
1834
1845
  method: "post",
1835
- path: "/machinecode/batch-metadata",
1836
- handler: this.handleMachinecodeBatchMetadata.bind(this)
1846
+ path: "/machinecode/batch",
1847
+ handler: this.handleMachinecodeBatchMeta.bind(this)
1837
1848
  }
1838
1849
  ]);
1839
1850
  this.registerPrefixRoutes([
@@ -2839,39 +2850,39 @@ var Server = class {
2839
2850
  ];
2840
2851
  return candidates.find((candidate) => candidate !== void 0 && candidate !== null && candidate !== "");
2841
2852
  }
2842
- async syncMachinecodeBatchMetadataToLocalOrder(data, batchMetadata) {
2853
+ async syncMachinecodeRedeemStatusToLocalOrder(data, ids, status) {
2843
2854
  var _a;
2844
2855
  const title = "handleMachinecodeBatchMetadata";
2845
2856
  const lookup = this.resolveMachinecodeBatchMetadataLookup(data);
2846
2857
  if (lookup === void 0) {
2847
- this.logWarning(`${title}: order lookup 缺失,跳过本地订单 metadata 更新`, {
2848
- batchSize: batchMetadata.length
2858
+ this.logWarning(`${title}: order lookup 缺失,跳过本地订单核销状态更新`, {
2859
+ batchSize: ids.length,
2860
+ status
2849
2861
  });
2850
2862
  return;
2851
2863
  }
2852
2864
  if (!((_a = this.order) == null ? void 0 : _a.getLocalOrderByLookup)) {
2853
- this.logWarning(`${title}: Order 模块未注册,跳过本地订单 metadata 更新`, {
2854
- lookup
2865
+ this.logWarning(`${title}: Order 模块未注册,跳过本地订单核销状态更新`, {
2866
+ lookup,
2867
+ status
2855
2868
  });
2856
2869
  return;
2857
2870
  }
2858
2871
  const localOrder = await this.order.getLocalOrderByLookup(lookup);
2859
2872
  if (!localOrder) {
2860
- this.logWarning(`${title}: 本地订单不存在,跳过 metadata 更新`, {
2861
- lookup
2873
+ this.logWarning(`${title}: 本地订单不存在,跳过核销状态更新`, {
2874
+ lookup,
2875
+ status
2862
2876
  });
2863
2877
  return;
2864
2878
  }
2865
- const metadataByVoucherId = /* @__PURE__ */ new Map();
2866
- for (const item of batchMetadata) {
2867
- const voucherId = (item == null ? void 0 : item.voucher_id) ?? (item == null ? void 0 : item.voucherId);
2868
- if (voucherId === void 0 || voucherId === null || voucherId === "")
2869
- continue;
2870
- metadataByVoucherId.set(String(voucherId), (item == null ? void 0 : item.metadata) || {});
2871
- }
2872
- if (metadataByVoucherId.size === 0) {
2873
- this.logWarning(`${title}: voucher metadata 缺失,跳过本地订单 metadata 更新`, {
2874
- lookup
2879
+ const voucherIdSet = new Set(
2880
+ ids.filter((id) => id !== void 0 && id !== null && id !== "").map((id) => String(id))
2881
+ );
2882
+ if (voucherIdSet.size === 0) {
2883
+ this.logWarning(`${title}: voucher ids 缺失,跳过本地订单核销状态更新`, {
2884
+ lookup,
2885
+ status
2875
2886
  });
2876
2887
  return;
2877
2888
  }
@@ -2881,19 +2892,19 @@ var Server = class {
2881
2892
  const voucherId = voucher == null ? void 0 : voucher.voucher_id;
2882
2893
  if (voucherId === void 0 || voucherId === null)
2883
2894
  return voucher;
2884
- const metadata = metadataByVoucherId.get(String(voucherId));
2885
- if (!metadata)
2895
+ if (!voucherIdSet.has(String(voucherId)))
2886
2896
  return voucher;
2887
2897
  hasUpdatedVoucher = true;
2888
2898
  return {
2889
2899
  ...voucher,
2890
- metadata
2900
+ status
2891
2901
  };
2892
2902
  });
2893
2903
  if (!hasUpdatedVoucher) {
2894
- this.logWarning(`${title}: 本地订单未命中任何 voucher,跳过 metadata 更新`, {
2904
+ this.logWarning(`${title}: 本地订单未命中任何 voucher,跳过核销状态更新`, {
2895
2905
  lookup,
2896
- voucher_ids: Array.from(metadataByVoucherId.keys())
2906
+ voucher_ids: Array.from(voucherIdSet),
2907
+ status
2897
2908
  });
2898
2909
  return;
2899
2910
  }
@@ -2902,9 +2913,10 @@ var Server = class {
2902
2913
  ...localOrder,
2903
2914
  vouchers: nextVouchers
2904
2915
  });
2905
- this.logInfo(`${title}: 本地订单 vouchers metadata 已更新`, {
2916
+ this.logInfo(`${title}: 本地订单 vouchers 核销状态已更新`, {
2906
2917
  lookup,
2907
- updatedCount: metadataByVoucherId.size
2918
+ updatedCount: voucherIdSet.size,
2919
+ status
2908
2920
  });
2909
2921
  return;
2910
2922
  }
@@ -2913,14 +2925,16 @@ var Server = class {
2913
2925
  externalSaleNumber: data.external_sale_number,
2914
2926
  patch: { vouchers: nextVouchers }
2915
2927
  });
2916
- this.logInfo(`${title}: 本地订单 vouchers metadata 已更新`, {
2928
+ this.logInfo(`${title}: 本地订单 vouchers 核销状态已更新`, {
2917
2929
  lookup,
2918
- updatedCount: metadataByVoucherId.size
2930
+ updatedCount: voucherIdSet.size,
2931
+ status
2919
2932
  });
2920
2933
  return;
2921
2934
  }
2922
- this.logWarning(`${title}: Order 模块不支持本地订单覆盖,跳过 metadata 更新`, {
2923
- lookup
2935
+ this.logWarning(`${title}: Order 模块不支持本地订单覆盖,跳过核销状态更新`, {
2936
+ lookup,
2937
+ status
2924
2938
  });
2925
2939
  }
2926
2940
  async handleOrderCheckoutSubmit(params) {
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
311
311
  date: string;
312
312
  status: string;
313
313
  week: string;
314
- weekNum: 0 | 5 | 1 | 2 | 3 | 6 | 4;
314
+ weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -322,7 +322,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
322
322
  * 获取当前的客户搜索条件
323
323
  * @returns 当前搜索条件
324
324
  */
325
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
325
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
326
326
  /**
327
327
  * 获取客户列表状态(包含滚动加载相关状态)
328
328
  * @returns 客户状态
@@ -555,7 +555,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
555
555
  handlePrintWristband(params: {
556
556
  voucher_ids: number[];
557
557
  }): Promise<void>;
558
- handleCheckIn(params: {
558
+ handleRedeem(params: {
559
559
  voucher_ids: number[];
560
560
  is_checkin: boolean;
561
561
  }): Promise<any>;
@@ -1551,42 +1551,30 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
1551
1551
  source_id: idempotencyKey
1552
1552
  });
1553
1553
  }
1554
- // 触发 checkIn
1555
- async handleCheckIn(params) {
1554
+ // 触发核销
1555
+ async handleRedeem(params) {
1556
1556
  var _a, _b, _c;
1557
+ const voucherIds = Array.isArray(params.voucher_ids) ? params.voucher_ids : [];
1558
+ const status = params.is_checkin ? "used" : "unused";
1557
1559
  this.logger.addLog({
1558
1560
  type: "info",
1559
- title: "[BookingTicket] handleCheckIn",
1561
+ title: "[BookingTicket] handleRedeem",
1560
1562
  metadata: {
1561
- voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids],
1562
- is_checkin: params.is_checkin
1563
+ voucher_ids: voucherIds,
1564
+ status
1563
1565
  }
1564
1566
  });
1565
- const voucherIds = Array.isArray(params.voucher_ids) ? params.voucher_ids : [];
1566
1567
  const voucherIdSet = new Set(voucherIds);
1567
1568
  const tempOrder = (_b = (_a = this.store.order) == null ? void 0 : _a.getTempOrder) == null ? void 0 : _b.call(_a);
1568
1569
  const vouchers = (tempOrder == null ? void 0 : tempOrder.vouchers) || ((_c = this.store.order) == null ? void 0 : _c.getVouchers()) || [];
1569
- const batchMetadata = [];
1570
1570
  let hasUpdatedVoucher = false;
1571
1571
  const nextVouchers = vouchers.map((voucher) => {
1572
- var _a2;
1573
1572
  if (!voucherIdSet.has(voucher.voucher_id))
1574
1573
  return voucher;
1575
1574
  hasUpdatedVoucher = true;
1576
- const metadata = {
1577
- ...voucher.metadata || {},
1578
- ticket: {
1579
- ...((_a2 = voucher.metadata) == null ? void 0 : _a2.ticket) || {},
1580
- is_checkin: params.is_checkin
1581
- }
1582
- };
1583
- batchMetadata.push({
1584
- voucher_id: voucher.voucher_id,
1585
- metadata
1586
- });
1587
1575
  return {
1588
1576
  ...voucher,
1589
- metadata
1577
+ status
1590
1578
  };
1591
1579
  });
1592
1580
  if (tempOrder && hasUpdatedVoucher) {
@@ -1596,7 +1584,7 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
1596
1584
  });
1597
1585
  }
1598
1586
  this.core.effects.emit(`${this.name}:onVouchersChange`, {});
1599
- if (batchMetadata.length === 0) {
1587
+ if (voucherIds.length === 0) {
1600
1588
  return {
1601
1589
  code: 200,
1602
1590
  status: true,
@@ -1608,8 +1596,9 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
1608
1596
  const externalSaleNumber = (tempOrder == null ? void 0 : tempOrder.external_sale_number) || (identity == null ? void 0 : identity.externalSaleNumber) || void 0;
1609
1597
  const orderId = (tempOrder == null ? void 0 : tempOrder.order_id) ?? (identity == null ? void 0 : identity.orderId) ?? void 0;
1610
1598
  const orderLookup = externalSaleNumber || orderId || (identity == null ? void 0 : identity.orderNumber) || (identity == null ? void 0 : identity.shopOrderNumber) || (identity == null ? void 0 : identity.shopFullOrderNumber) || void 0;
1611
- return this.request.post("/machinecode/batch-metadata", {
1612
- data: batchMetadata,
1599
+ return this.request.post("/machinecode/batch", {
1600
+ ids: voucherIds,
1601
+ status,
1613
1602
  order_lookup: orderLookup,
1614
1603
  order_id: orderId,
1615
1604
  external_sale_number: externalSaleNumber
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.15",
4
+ "version": "2.3.17",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",