@pisell/pisellos 2.3.225 → 2.3.226

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 (32) hide show
  1. package/dist/modules/Customer/types.d.ts +4 -0
  2. package/dist/modules/Order/index.js +123 -79
  3. package/dist/modules/Order/types.d.ts +2 -0
  4. package/dist/modules/Order/utils/bookingUuid.d.ts +4 -0
  5. package/dist/modules/Order/utils/bookingUuid.js +24 -0
  6. package/dist/modules/Order/utils.js +2 -0
  7. package/dist/modules/Product/index.d.ts +1 -1
  8. package/dist/modules/Summary/utils.d.ts +1 -1
  9. package/dist/solution/BaseSales/index.js +3 -0
  10. package/dist/solution/BookingByStep/index.d.ts +2 -2
  11. package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +8 -8
  12. package/dist/solution/Checkout/index.js +104 -69
  13. package/dist/solution/Checkout/types.d.ts +1 -0
  14. package/dist/solution/ScanOrder/index.js +10 -2
  15. package/dist/solution/VenueBooking/index.js +522 -490
  16. package/lib/model/strategy/adapter/promotion/index.js +1 -46
  17. package/lib/modules/Customer/types.d.ts +4 -0
  18. package/lib/modules/Order/index.js +44 -6
  19. package/lib/modules/Order/types.d.ts +2 -0
  20. package/lib/modules/Order/utils/bookingUuid.d.ts +4 -0
  21. package/lib/modules/Order/utils/bookingUuid.js +25 -0
  22. package/lib/modules/Order/utils.js +5 -1
  23. package/lib/modules/Product/index.d.ts +1 -1
  24. package/lib/modules/Summary/utils.d.ts +1 -1
  25. package/lib/solution/BaseSales/index.js +3 -0
  26. package/lib/solution/BookingByStep/index.d.ts +2 -2
  27. package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +8 -8
  28. package/lib/solution/Checkout/index.js +21 -0
  29. package/lib/solution/Checkout/types.d.ts +1 -0
  30. package/lib/solution/ScanOrder/index.js +6 -0
  31. package/lib/solution/VenueBooking/index.js +6 -1
  32. package/package.json +1 -1
@@ -44,6 +44,10 @@ export interface ShopGetCustomerListParams {
44
44
  num?: number;
45
45
  /** 搜索关键词 */
46
46
  search?: string;
47
+ /** Full national phone number, without the international calling code. */
48
+ phone?: string;
49
+ /** Exact email lookup, independent from the generic search keyword. */
50
+ email?: string;
47
51
  /** 关联查询参数 */
48
52
  with?: CustomerWith[];
49
53
  /** wallet搜索标识 */
@@ -31,6 +31,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
31
31
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
32
32
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
33
33
  import { loadSalesOrderSnapshot } from "../../shared/sales/loadSalesOrderSnapshot";
34
+ import { assignBookingUuid, ensureBookingUuid } from "./utils/bookingUuid";
34
35
  import { PAYMENT_REFRESH_MESSAGE, requiresLocalPaymentRefresh, stripLocalEftposState } from "./localEftposState";
35
36
  import { BaseModule } from "../BaseModule";
36
37
  import { OrderHooks } from "./types";
@@ -3759,7 +3760,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3759
3760
  }),
3760
3761
  booking_uid: bookingUid
3761
3762
  }),
3762
- booking: _objectSpread(_objectSpread({}, params.booking), {}, {
3763
+ booking: _objectSpread(_objectSpread({}, ensureBookingUuid(params.booking)), {}, {
3763
3764
  is_all: normalizeBookingIsAll(params.booking),
3764
3765
  product_uid: productUid,
3765
3766
  sub_type: normalizeBookingSubType(params.booking),
@@ -4627,7 +4628,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4627
4628
  var tempOrder = this.ensureTempOrder();
4628
4629
  var bookings = tempOrder.bookings || [];
4629
4630
  var firstIndex = bookings.findIndex(isFulfillmentTimingBooking);
4630
- var nextBooking = buildPickupTimingBooking(input, bookings[firstIndex]);
4631
+ var nextBooking = ensureBookingUuid(buildPickupTimingBooking(input, bookings[firstIndex]));
4631
4632
  // Keep the first row's identity and position; repair duplicate marked rows only.
4632
4633
  tempOrder.bookings = firstIndex === -1 ? [].concat(_toConsumableArray(bookings), [nextBooking]) : bookings.flatMap(function (booking, index) {
4633
4634
  return index === firstIndex ? [nextBooking] : isFulfillmentTimingBooking(booking) ? [] : [booking];
@@ -5561,7 +5562,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5561
5562
  }, {
5562
5563
  key: "appendProductLineToTempOrder",
5563
5564
  value: function appendProductLineToTempOrder(tempOrder, product, booking, options) {
5564
- var _normalizedIncoming$p,
5565
+ var _booking,
5566
+ _tempOrder$bookings2,
5567
+ _normalizedIncoming$p,
5565
5568
  _normalizedIncoming$p2,
5566
5569
  _booking_uid,
5567
5570
  _metadata,
@@ -5569,6 +5572,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5569
5572
  _productToAdd$metadat,
5570
5573
  _origin,
5571
5574
  _this37 = this;
5575
+ var incomingBookingUuid = (_booking = booking) === null || _booking === void 0 ? void 0 : _booking.uuid;
5576
+ if (booking && incomingBookingUuid && (_tempOrder$bookings2 = tempOrder.bookings) !== null && _tempOrder$bookings2 !== void 0 && _tempOrder$bookings2.some(function (item) {
5577
+ return item.uuid === incomingBookingUuid;
5578
+ })) {
5579
+ // Appending a copy creates a different booking; editing uses the update path below.
5580
+ booking = _objectSpread(_objectSpread({}, booking), {}, {
5581
+ uuid: createUuidV4(),
5582
+ id: undefined,
5583
+ schedule_event_id: undefined
5584
+ });
5585
+ }
5572
5586
  var linked = booking ? this.createLinkedProductAndBooking({
5573
5587
  product: product,
5574
5588
  booking: booking
@@ -5726,6 +5740,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5726
5740
  singleLine.num = 1;
5727
5741
  delete singleLine.product_quantity;
5728
5742
  var singleBooking = cloneDeep(booking);
5743
+ if (index > 0) {
5744
+ // Both single-add and batch-add quantity splits create separate appointments.
5745
+ delete singleBooking.uuid;
5746
+ delete singleBooking.schedule_event_id;
5747
+ delete singleBooking.id;
5748
+ }
5729
5749
  var bookingHolder = booking !== null && booking !== void 0 && booking.holder && _typeof(booking.holder) === 'object' ? booking.holder : null;
5730
5750
  var metadataHolder = booking !== null && booking !== void 0 && (_booking$metadata6 = booking.metadata) !== null && _booking$metadata6 !== void 0 && _booking$metadata6.holder && _typeof(booking.metadata.holder) === 'object' ? booking.metadata.holder : null;
5731
5751
  var rawHolderIds = (_ref70 = (_ref71 = (_bookingHolder$form_r = bookingHolder === null || bookingHolder === void 0 ? void 0 : bookingHolder.form_record) !== null && _bookingHolder$form_r !== void 0 ? _bookingHolder$form_r : booking === null || booking === void 0 || (_booking$metadata7 = booking.metadata) === null || _booking$metadata7 === void 0 ? void 0 : _booking$metadata7.holder_id) !== null && _ref71 !== void 0 ? _ref71 : metadataHolder === null || metadataHolder === void 0 ? void 0 : metadataHolder.form_record) !== null && _ref70 !== void 0 ? _ref70 : product === null || product === void 0 || (_product$metadata10 = product.metadata) === null || _product$metadata10 === void 0 ? void 0 : _product$metadata10.holder_id;
@@ -6097,13 +6117,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6097
6117
  var _replaceBookingProductWithRelatedRetailDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
6098
6118
  var _target$metadata,
6099
6119
  _target$metadata2,
6120
+ _this41 = this,
6100
6121
  _params$product$num,
6101
6122
  _target$metadata3,
6102
6123
  _params$product$metad,
6103
6124
  _params$product$metad2,
6104
- _params$booking$metad,
6105
- _this41 = this;
6106
- var live, mutation, beforeCommit, uid, getUid, targetIndex, target, scopeKey, targetBookingUid, children, start, serviceDatetime, ownedUids, nextUids, retainedChildUids, nextChildren, _iterator23, _step23, _loop2, publishedFields, guardedFields, readFields, baseline, identity, isCurrentOrder, draft, removed, _iterator24, _step24, line, _iterator25, _step25, _draft$_extend, _line, replacement, _iterator26, _step26, _step26$value, index, child, beforePublish;
6125
+ _params$booking$metad;
6126
+ var live, mutation, beforeCommit, uid, getUid, targetIndex, target, scopeKey, targetBookingUid, targetBookings, children, start, serviceDatetime, ownedUids, nextUids, retainedChildUids, nextChildren, _iterator23, _step23, _loop2, publishedFields, guardedFields, readFields, baseline, identity, isCurrentOrder, draft, removed, _iterator24, _step24, line, _iterator25, _step25, _draft$_extend, _line, replacement, replacementBooking, _iterator26, _step26, _step26$value, index, child, beforePublish;
6107
6127
  return _regeneratorRuntime().wrap(function _callee30$(_context32) {
6108
6128
  while (1) switch (_context32.prev = _context32.next) {
6109
6129
  case 0:
@@ -6122,17 +6142,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6122
6142
  target = live.products[targetIndex];
6123
6143
  scopeKey = String((target === null || target === void 0 || (_target$metadata = target.metadata) === null || _target$metadata === void 0 ? void 0 : _target$metadata.venue_booking_scope_key) || '');
6124
6144
  targetBookingUid = String((target === null || target === void 0 ? void 0 : target.booking_uid) || (target === null || target === void 0 || (_target$metadata2 = target.metadata) === null || _target$metadata2 === void 0 ? void 0 : _target$metadata2.booking_uid) || '');
6125
- if (!(!uid || !target || !scopeKey || live.order_id || target.order_detail_id != null || Number(target.num) !== 1 || Number((_params$product$num = params.product.num) !== null && _params$product$num !== void 0 ? _params$product$num : 1) !== 1 || ((_target$metadata3 = target.metadata) === null || _target$metadata3 === void 0 ? void 0 : _target$metadata3.venue_booking_role) !== 'party_main' || ((_params$product$metad = params.product.metadata) === null || _params$product$metad === void 0 ? void 0 : _params$product$metad.venue_booking_role) !== 'party_main' || ((_params$product$metad2 = params.product.metadata) === null || _params$product$metad2 === void 0 ? void 0 : _params$product$metad2.venue_booking_scope_key) !== scopeKey || !Array.isArray(params.relatedRetailProducts) || (live.payments || []).length > 0 || !targetBookingUid || String(((_params$booking$metad = params.booking.metadata) === null || _params$booking$metad === void 0 ? void 0 : _params$booking$metad.unique_identification_number) || '') !== targetBookingUid || (live.bookings || []).filter(function (booking) {
6126
- return _this41.getBookingUniqueIdentificationNumber(booking) === targetBookingUid;
6127
- }).length !== 1 || live.products.filter(function (line) {
6145
+ targetBookings = (live.bookings || []).filter(function (row) {
6146
+ return _this41.getBookingUniqueIdentificationNumber(row) === targetBookingUid;
6147
+ });
6148
+ if (!(!uid || !target || !scopeKey || live.order_id || target.order_detail_id != null || Number(target.num) !== 1 || Number((_params$product$num = params.product.num) !== null && _params$product$num !== void 0 ? _params$product$num : 1) !== 1 || ((_target$metadata3 = target.metadata) === null || _target$metadata3 === void 0 ? void 0 : _target$metadata3.venue_booking_role) !== 'party_main' || ((_params$product$metad = params.product.metadata) === null || _params$product$metad === void 0 ? void 0 : _params$product$metad.venue_booking_role) !== 'party_main' || ((_params$product$metad2 = params.product.metadata) === null || _params$product$metad2 === void 0 ? void 0 : _params$product$metad2.venue_booking_scope_key) !== scopeKey || !Array.isArray(params.relatedRetailProducts) || (live.payments || []).length > 0 || !targetBookingUid || String(((_params$booking$metad = params.booking.metadata) === null || _params$booking$metad === void 0 ? void 0 : _params$booking$metad.unique_identification_number) || '') !== targetBookingUid || targetBookings.length !== 1 || live.products.filter(function (line) {
6128
6149
  var _line$metadata3, _line$metadata4;
6129
6150
  return ((_line$metadata3 = line.metadata) === null || _line$metadata3 === void 0 ? void 0 : _line$metadata3.venue_booking_role) === 'party_main' && ((_line$metadata4 = line.metadata) === null || _line$metadata4 === void 0 ? void 0 : _line$metadata4.venue_booking_scope_key) === scopeKey;
6130
6151
  }).length !== 1)) {
6131
- _context32.next = 12;
6152
+ _context32.next = 13;
6132
6153
  break;
6133
6154
  }
6134
6155
  throw new Error('[Order] Party replacement requires one unsubmitted, unpaid main booking in the same scope');
6135
- case 12:
6156
+ case 13:
6136
6157
  children = live.products.filter(function (line) {
6137
6158
  var _line$metadata5, _line$metadata6;
6138
6159
  return ((_line$metadata5 = line.metadata) === null || _line$metadata5 === void 0 ? void 0 : _line$metadata5.venue_booking_role) === 'party_extra' && String(((_line$metadata6 = line.metadata) === null || _line$metadata6 === void 0 ? void 0 : _line$metadata6.venue_booking_parent_uid) || '') === uid;
@@ -6141,25 +6162,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6141
6162
  var _line$metadata7;
6142
6163
  return !getUid(line) || ((_line$metadata7 = line.metadata) === null || _line$metadata7 === void 0 ? void 0 : _line$metadata7.venue_booking_scope_key) !== scopeKey || line.order_detail_id != null || _this41.hasLinkedBookingUid(line);
6143
6164
  })) {
6144
- _context32.next = 15;
6165
+ _context32.next = 16;
6145
6166
  break;
6146
6167
  }
6147
6168
  throw new Error('[Order] Related retail line does not belong to this local Party scope');
6148
- case 15:
6169
+ case 16:
6149
6170
  start = params.booking.start_at || "".concat(params.booking.start_date || '', " ").concat(params.booking.start_time || '').trim();
6150
6171
  if (!(!start || !dayjs(start).isValid())) {
6151
- _context32.next = 18;
6172
+ _context32.next = 19;
6152
6173
  break;
6153
6174
  }
6154
6175
  throw new Error('[Order] Party service datetime is required');
6155
- case 18:
6176
+ case 19:
6156
6177
  serviceDatetime = dayjs(start).format('YYYY-MM-DD HH:mm:ss');
6157
6178
  ownedUids = new Set(children.map(getUid));
6158
6179
  nextUids = new Set();
6159
6180
  retainedChildUids = new Set();
6160
6181
  nextChildren = cloneDeep(params.relatedRetailProducts);
6161
6182
  _iterator23 = _createForOfIteratorHelper(nextChildren);
6162
- _context32.prev = 24;
6183
+ _context32.prev = 25;
6163
6184
  _loop2 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop2() {
6164
6185
  var _child$metadata, _child$metadata2, _child$metadata3, _child$metadata4, _child$num;
6165
6186
  var child, childUid, purchaseDatetime, normalizedPurchaseDatetime, previous, _live$_extend, _rawChild$_origin, previousForms, rawChild;
@@ -6200,27 +6221,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6200
6221
  }, _loop2);
6201
6222
  });
6202
6223
  _iterator23.s();
6203
- case 27:
6224
+ case 28:
6204
6225
  if ((_step23 = _iterator23.n()).done) {
6205
- _context32.next = 31;
6226
+ _context32.next = 32;
6206
6227
  break;
6207
6228
  }
6208
- return _context32.delegateYield(_loop2(), "t0", 29);
6209
- case 29:
6210
- _context32.next = 27;
6229
+ return _context32.delegateYield(_loop2(), "t0", 30);
6230
+ case 30:
6231
+ _context32.next = 28;
6211
6232
  break;
6212
- case 31:
6213
- _context32.next = 36;
6233
+ case 32:
6234
+ _context32.next = 37;
6214
6235
  break;
6215
- case 33:
6216
- _context32.prev = 33;
6217
- _context32.t1 = _context32["catch"](24);
6236
+ case 34:
6237
+ _context32.prev = 34;
6238
+ _context32.t1 = _context32["catch"](25);
6218
6239
  _iterator23.e(_context32.t1);
6219
- case 36:
6220
- _context32.prev = 36;
6240
+ case 37:
6241
+ _context32.prev = 37;
6221
6242
  _iterator23.f();
6222
- return _context32.finish(36);
6223
- case 39:
6243
+ return _context32.finish(37);
6244
+ case 40:
6224
6245
  publishedFields = ['products', 'bookings', 'notes', '_extend', 'metadata', 'holder', 'holder_relations', 'currency_code', 'currency_symbol', 'currency_format'];
6225
6246
  guardedFields = [].concat(publishedFields, ['customer_id', 'discount_list', 'shop_discount', 'payments']);
6226
6247
  readFields = function readFields(order, fields) {
@@ -6275,43 +6296,45 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6275
6296
  venue_booking_service_datetime: serviceDatetime
6276
6297
  });
6277
6298
  replacement.unique_identification_number = uid;
6278
- _context32.next = 59;
6279
- return this.appendProductLineToTempOrder(draft, replacement, cloneDeep(params.booking), {
6299
+ replacementBooking = cloneDeep(params.booking);
6300
+ replacementBooking.uuid = targetBookings[0].uuid || replacementBooking.uuid;
6301
+ _context32.next = 62;
6302
+ return this.appendProductLineToTempOrder(draft, replacement, replacementBooking, {
6280
6303
  insertAtIndex: targetIndex,
6281
6304
  disableMerge: true,
6282
6305
  beforeCommit: beforeCommit
6283
6306
  });
6284
- case 59:
6307
+ case 62:
6285
6308
  _iterator26 = _createForOfIteratorHelper(nextChildren.entries());
6286
- _context32.prev = 60;
6309
+ _context32.prev = 63;
6287
6310
  _iterator26.s();
6288
- case 62:
6311
+ case 65:
6289
6312
  if ((_step26 = _iterator26.n()).done) {
6290
- _context32.next = 68;
6313
+ _context32.next = 71;
6291
6314
  break;
6292
6315
  }
6293
6316
  _step26$value = _slicedToArray(_step26.value, 2), index = _step26$value[0], child = _step26$value[1];
6294
- _context32.next = 66;
6317
+ _context32.next = 69;
6295
6318
  return this.appendProductLineToTempOrder(draft, child, undefined, {
6296
6319
  insertAtIndex: targetIndex + index + 1,
6297
6320
  disableMerge: true,
6298
6321
  beforeCommit: beforeCommit
6299
6322
  });
6300
- case 66:
6301
- _context32.next = 62;
6323
+ case 69:
6324
+ _context32.next = 65;
6302
6325
  break;
6303
- case 68:
6304
- _context32.next = 73;
6326
+ case 71:
6327
+ _context32.next = 76;
6305
6328
  break;
6306
- case 70:
6307
- _context32.prev = 70;
6308
- _context32.t2 = _context32["catch"](60);
6309
- _iterator26.e(_context32.t2);
6310
6329
  case 73:
6311
6330
  _context32.prev = 73;
6312
- _iterator26.f();
6313
- return _context32.finish(73);
6331
+ _context32.t2 = _context32["catch"](63);
6332
+ _iterator26.e(_context32.t2);
6314
6333
  case 76:
6334
+ _context32.prev = 76;
6335
+ _iterator26.f();
6336
+ return _context32.finish(76);
6337
+ case 79:
6315
6338
  this.removeSalesNotesForMissingProductLines(draft);
6316
6339
  this.syncTempOrderHolderFromBookings(draft);
6317
6340
  beforePublish = function beforePublish() {
@@ -6325,45 +6348,45 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6325
6348
  };
6326
6349
  beforePublish();
6327
6350
  if (!mutation.commit) {
6328
- _context32.next = 85;
6351
+ _context32.next = 88;
6329
6352
  break;
6330
6353
  }
6331
- _context32.next = 83;
6354
+ _context32.next = 86;
6332
6355
  return mutation.commit({
6333
6356
  beforeCommit: beforePublish
6334
6357
  });
6335
- case 83:
6336
- _context32.next = 86;
6358
+ case 86:
6359
+ _context32.next = 89;
6337
6360
  break;
6338
- case 85:
6361
+ case 88:
6339
6362
  // No await between the final CAS and publication; preserve every unrelated live field.
6340
6363
  Object.assign(live, readFields(draft, publishedFields));
6341
- case 86:
6342
- _context32.prev = 86;
6364
+ case 89:
6365
+ _context32.prev = 89;
6343
6366
  if (isCurrentOrder()) this.persistTempOrder();
6344
- _context32.next = 90;
6367
+ _context32.next = 93;
6345
6368
  return this.finalizeProductOrderMutation(live, {
6346
6369
  isCurrentOrder: isCurrentOrder
6347
6370
  });
6348
- case 90:
6349
- _context32.next = 95;
6371
+ case 93:
6372
+ _context32.next = 98;
6350
6373
  break;
6351
- case 92:
6352
- _context32.prev = 92;
6353
- _context32.t3 = _context32["catch"](86);
6374
+ case 95:
6375
+ _context32.prev = 95;
6376
+ _context32.t3 = _context32["catch"](89);
6354
6377
  // Already committed. Do not invite a second replacement or restore a stale snapshot.
6355
6378
  this.logWarning('Party replacement committed; finalization failed', {
6356
6379
  productLineUid: uid,
6357
6380
  committed: true,
6358
6381
  error: _context32.t3 instanceof Error ? _context32.t3.message : String(_context32.t3)
6359
6382
  });
6360
- case 95:
6383
+ case 98:
6361
6384
  return _context32.abrupt("return", live.products);
6362
- case 96:
6385
+ case 99:
6363
6386
  case "end":
6364
6387
  return _context32.stop();
6365
6388
  }
6366
- }, _callee30, this, [[24, 33, 36, 39], [60, 70, 73, 76], [86, 92]]);
6389
+ }, _callee30, this, [[25, 34, 37, 40], [63, 73, 76, 79], [89, 95]]);
6367
6390
  }));
6368
6391
  function replaceBookingProductWithRelatedRetailDraft(_x35) {
6369
6392
  return _replaceBookingProductWithRelatedRetailDraft.apply(this, arguments);
@@ -6851,16 +6874,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6851
6874
  });
6852
6875
  }
6853
6876
  if (booking) {
6854
- var _normalizedProduct$me, _targetProduct$metada21;
6877
+ var _normalizedProduct$me, _targetProduct$metada21, _targetProduct$metada22, _bookings$find;
6855
6878
  var productUid = String(((_normalizedProduct$me = normalizedProduct.metadata) === null || _normalizedProduct$me === void 0 ? void 0 : _normalizedProduct$me.unique_identification_number) || ((_targetProduct$metada21 = targetProduct.metadata) === null || _targetProduct$metada21 === void 0 ? void 0 : _targetProduct$metada21.unique_identification_number) || unique_identification_number || createUuidV4());
6856
6879
  normalizedProduct.metadata = _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
6857
6880
  unique_identification_number: productUid
6858
6881
  });
6882
+ var originalBookingUid = targetProduct.booking_uid || ((_targetProduct$metada22 = targetProduct.metadata) === null || _targetProduct$metada22 === void 0 ? void 0 : _targetProduct$metada22.booking_uid) || preservedBookingUid;
6883
+ var bookings = tempOrder.bookings || [];
6884
+ var eventId = booking.schedule_event_id;
6885
+ var originalBooking = (_bookings$find = bookings.find(function (row) {
6886
+ return Number(eventId) > 0 && String(row.schedule_event_id) === String(eventId);
6887
+ })) !== null && _bookings$find !== void 0 ? _bookings$find : bookings.find(function (row) {
6888
+ var _row$metadata;
6889
+ return originalBookingUid && ((_row$metadata = row.metadata) === null || _row$metadata === void 0 ? void 0 : _row$metadata.unique_identification_number) === originalBookingUid;
6890
+ });
6891
+ var _booking$uuid = booking.uuid,
6892
+ incomingUuid = _booking$uuid === void 0 ? originalBooking === null || originalBooking === void 0 ? void 0 : originalBooking.uuid : _booking$uuid;
6859
6893
  var linked = this.createLinkedProductAndBooking({
6860
6894
  product: _objectSpread(_objectSpread({}, normalizedProduct), {}, {
6861
6895
  unique_identification_number: productUid
6862
6896
  }),
6863
- booking: booking
6897
+ booking: _objectSpread(_objectSpread({}, booking), {}, {
6898
+ uuid: (originalBooking === null || originalBooking === void 0 ? void 0 : originalBooking.uuid) || incomingUuid
6899
+ })
6864
6900
  });
6865
6901
  this.removeLinkedBookingsForProduct(tempOrder, targetProduct);
6866
6902
  normalizedProduct = _objectSpread(_objectSpread({}, normalizedProduct), {}, {
@@ -7228,7 +7264,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7228
7264
  key: "updateOrderProductQuantityDraft",
7229
7265
  value: function () {
7230
7266
  var _updateOrderProductQuantityDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params, options) {
7231
- var _this$store$tempOrder10, _targetProduct$metada22;
7267
+ var _this$store$tempOrder10, _targetProduct$metada23;
7232
7268
  var isCurrentOrder, product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, mutation, tempOrder, identityLookup, productIndex, targetUid, targetProduct, isPersistedOrderLine, normalizedProduct, settlementSnapshot, currencyProductId, asset, requiredAmount, balance, beforeCommit, isVirtualSettlement, promotionPayload;
7233
7269
  return _regeneratorRuntime().wrap(function _callee39$(_context42) {
7234
7270
  while (1) switch (_context42.prev = _context42.next) {
@@ -7279,7 +7315,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7279
7315
  normalizedProduct = this.normalizeVirtualSettlementProductIfEnabled(normalizeOrderProduct(_objectSpread(_objectSpread({}, targetProduct), {}, {
7280
7316
  num: getSafeProductNum(num),
7281
7317
  metadata: _objectSpread(_objectSpread({}, targetProduct.metadata || {}), {}, {
7282
- unique_identification_number: ((_targetProduct$metada22 = targetProduct.metadata) === null || _targetProduct$metada22 === void 0 ? void 0 : _targetProduct$metada22.unique_identification_number) || unique_identification_number
7318
+ unique_identification_number: ((_targetProduct$metada23 = targetProduct.metadata) === null || _targetProduct$metada23 === void 0 ? void 0 : _targetProduct$metada23.unique_identification_number) || unique_identification_number
7283
7319
  })
7284
7320
  })));
7285
7321
  normalizedProduct.discount_list = normalizeOrderProductDiscountList(isPersistedOrderLine ? syncReducedEntitlementPassUsageCount(normalizedProduct.discount_list, targetProduct.num, normalizedProduct.num) : normalizedProduct.discount_list);
@@ -7400,13 +7436,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7400
7436
  throw new Error('[Order] 目标 booking 不存在,无法更新');
7401
7437
  }
7402
7438
  var targetBooking = tempOrder.bookings[bookingIndex] || {};
7439
+ var _updates$uuid = updates.uuid,
7440
+ incomingUuid = _updates$uuid === void 0 ? targetBooking.uuid : _updates$uuid;
7403
7441
  var nextBooking = _objectSpread(_objectSpread(_objectSpread({}, targetBooking), updates), {}, {
7442
+ uuid: targetBooking.uuid || incomingUuid,
7404
7443
  metadata: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, targetBooking.metadata || {}), updates.metadata || {}), Number((_targetBooking$metada = targetBooking.metadata) === null || _targetBooking$metada === void 0 ? void 0 : _targetBooking$metada.is_change_by_redeem) === 1 ? {
7405
7444
  is_change_by_redeem: 1
7406
7445
  } : {}), {}, {
7407
7446
  unique_identification_number: bookingUid
7408
7447
  })
7409
7448
  });
7449
+ assignBookingUuid(nextBooking);
7410
7450
  this.syncBookingMetadataHolder(nextBooking, nextBooking.metadata);
7411
7451
  nextBooking.is_all = normalizeBookingIsAll(nextBooking);
7412
7452
  nextBooking.sub_type = normalizeBookingSubType(nextBooking);
@@ -8663,11 +8703,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
8663
8703
  key: "createOrderByCheckout",
8664
8704
  value: (function () {
8665
8705
  var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
8666
- var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3;
8706
+ var _params$bookings2, _params$payments, _params$bookings3, _params$relation_prod2, _params$payments2, _params$payments3;
8667
8707
  var onlineStorePaymentCodeList, _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, orderData, response;
8668
8708
  return _regeneratorRuntime().wrap(function _callee57$(_context61) {
8669
8709
  while (1) switch (_context61.prev = _context61.next) {
8670
8710
  case 0:
8711
+ (_params$bookings2 = params.bookings) === null || _params$bookings2 === void 0 || _params$bookings2.forEach(assignBookingUuid);
8671
8712
  // 过滤掉由在线店铺下单的 payment 支付数据
8672
8713
  onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
8673
8714
  params.payments = (_params$payments = params.payments) === null || _params$payments === void 0 ? void 0 : _params$payments.filter(function (p) {
@@ -8678,7 +8719,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
8678
8719
  platform: params.platform,
8679
8720
  is_deposit: params.is_deposit,
8680
8721
  customer_id: params.customer_id,
8681
- bookingsCount: ((_params$bookings2 = params.bookings) === null || _params$bookings2 === void 0 ? void 0 : _params$bookings2.length) || 0,
8722
+ bookingsCount: ((_params$bookings3 = params.bookings) === null || _params$bookings3 === void 0 ? void 0 : _params$bookings3.length) || 0,
8682
8723
  relationProductsCount: ((_params$relation_prod2 = params.relation_products) === null || _params$relation_prod2 === void 0 ? void 0 : _params$relation_prod2.length) || 0,
8683
8724
  paymentsCount: ((_params$payments2 = params.payments) === null || _params$payments2 === void 0 ? void 0 : _params$payments2.length) || 0,
8684
8725
  depositAmount: params.deposit_amount,
@@ -8691,7 +8732,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
8691
8732
  return p.code;
8692
8733
  })) || []
8693
8734
  });
8694
- _context61.prev = 3;
8735
+ _context61.prev = 4;
8695
8736
  // 构建订单数据,设置默认值并允许 params 覆盖
8696
8737
  orderData = _objectSpread({
8697
8738
  sales_channel: 'my_pisel',
@@ -8739,30 +8780,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
8739
8780
  hasOrderId: !!orderData.order_id,
8740
8781
  smallTicketDataFlag: orderData.small_ticket_data_flag
8741
8782
  });
8742
- _context61.next = 10;
8783
+ _context61.next = 11;
8743
8784
  return this.request.post('/order/checkout', orderData, {
8744
8785
  osServer: true,
8745
8786
  customToast: function customToast() {}
8746
8787
  });
8747
- case 10:
8788
+ case 11:
8748
8789
  response = _context61.sent;
8749
8790
  this.logInfo('Order API called successfully', {
8750
8791
  response: response
8751
8792
  });
8752
8793
  return _context61.abrupt("return", response);
8753
- case 15:
8754
- _context61.prev = 15;
8755
- _context61.t0 = _context61["catch"](3);
8794
+ case 16:
8795
+ _context61.prev = 16;
8796
+ _context61.t0 = _context61["catch"](4);
8756
8797
  console.error('[Order] createOrderByCheckout 创建订单失败:', _context61.t0);
8757
8798
  this.logInfo('Order API called failed', {
8758
8799
  error: _context61.t0 instanceof Error ? _context61.t0.message : String(_context61.t0)
8759
8800
  });
8760
8801
  throw _context61.t0;
8761
- case 20:
8802
+ case 21:
8762
8803
  case "end":
8763
8804
  return _context61.stop();
8764
8805
  }
8765
- }, _callee57, this, [[3, 15]]);
8806
+ }, _callee57, this, [[4, 16]]);
8766
8807
  }));
8767
8808
  function createOrderByCheckout(_x71) {
8768
8809
  return _createOrderByCheckout.apply(this, arguments);
@@ -8773,11 +8814,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
8773
8814
  key: "submitSalesOrder",
8774
8815
  value: function () {
8775
8816
  var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(params) {
8817
+ var _query$bookings;
8776
8818
  var url, query, fetchUrl, handledByOsServer, requestQuery;
8777
8819
  return _regeneratorRuntime().wrap(function _callee58$(_context62) {
8778
8820
  while (1) switch (_context62.prev = _context62.next) {
8779
8821
  case 0:
8780
8822
  url = params.url, query = params.query;
8823
+ (_query$bookings = query.bookings) === null || _query$bookings === void 0 || _query$bookings.forEach(assignBookingUuid);
8781
8824
  fetchUrl = url || '/order/sales/checkout';
8782
8825
  handledByOsServer = this.isSalesCheckoutHandledByOsServer(fetchUrl);
8783
8826
  requestQuery = handledByOsServer ? query : stripLocalEftposState(stripOsPrivatePayloadFields(query));
@@ -8788,7 +8831,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
8788
8831
  osServer: true,
8789
8832
  customToast: function customToast() {}
8790
8833
  }));
8791
- case 6:
8834
+ case 7:
8792
8835
  case "end":
8793
8836
  return _context62.stop();
8794
8837
  }
@@ -9283,7 +9326,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
9283
9326
  }) : [];
9284
9327
  nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
9285
9328
  var booking = _this57.normalizeHydratedBookingHolder(b || {});
9286
- return _objectSpread(_objectSpread({}, booking), {}, {
9329
+ var submitted = isFulfillmentTimingBooking(booking) || Number(booking.parent_id) !== 0;
9330
+ return _objectSpread(_objectSpread({}, submitted ? ensureBookingUuid(booking) : booking), {}, {
9287
9331
  is_all: normalizeBookingIsAll(booking),
9288
9332
  sub_type: normalizeBookingSubType(booking)
9289
9333
  });
@@ -617,6 +617,8 @@ export interface CommitOrderParams {
617
617
  };
618
618
  }
619
619
  export interface OrderSubmitBooking {
620
+ /** Stable booking identity, created once and shared with external allocations. */
621
+ uuid?: string | null;
620
622
  relation_id?: string;
621
623
  form_id?: string;
622
624
  collect_pax?: number;
@@ -0,0 +1,4 @@
1
+ /** Cross-system booking identity; independent from the legacy cart-line UID. */
2
+ export declare function ensureBookingUuid<T extends Record<string, any>>(booking: T): T;
3
+ /** Retain a generated UUID on the draft so a checkout retry sends the same value. */
4
+ export declare function assignBookingUuid(booking: Record<string, any> | null | undefined): void;
@@ -0,0 +1,24 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ import { createUuidV4 } from "./orderCollectionIdentity";
8
+
9
+ /** Cross-system booking identity; independent from the legacy cart-line UID. */
10
+ export function ensureBookingUuid(booking) {
11
+ if (booking.uuid) return booking;
12
+ // Only an explicit null confirms that an existing booking needs a UUID when saved.
13
+ if (booking.uuid !== null && Number(booking.schedule_event_id || booking.id) > 0) return booking;
14
+ return _objectSpread(_objectSpread({}, booking), {}, {
15
+ uuid: createUuidV4()
16
+ });
17
+ }
18
+
19
+ /** Retain a generated UUID on the draft so a checkout retry sends the same value. */
20
+ export function assignBookingUuid(booking) {
21
+ if (!booking) return;
22
+ var resolved = ensureBookingUuid(booking);
23
+ if (resolved !== booking) booking.uuid = resolved.uuid;
24
+ }
@@ -31,6 +31,7 @@ import { hasManualProductDiscountFlag } from "./utils/manualProductDiscount";
31
31
  import { getProductHolderConfig } from "../Holder/utils";
32
32
  import { buildProductLineFingerprint, createEmptySummary } from "../../solution/ScanOrder/utils";
33
33
  import { createUuidV4 } from "./utils/orderCollectionIdentity";
34
+ import { assignBookingUuid } from "./utils/bookingUuid";
34
35
  import { encodeSalesNotes } from "./salesNotes";
35
36
  import { isFulfillmentTimingBooking } from "./pickupTiming";
36
37
  import { ensureHolderRelationUuids, getProductHolderRelations, hasProductBooking, removeProductHolderRelations } from "./holderRelations";
@@ -1664,6 +1665,7 @@ export function buildSubmitPayload(params) {
1664
1665
  bookings: (tempOrder.bookings || []).filter(function (booking) {
1665
1666
  return isFulfillmentTimingBooking(booking) || Number(booking.parent_id) !== 0;
1666
1667
  }).map(function (booking) {
1668
+ assignBookingUuid(booking);
1667
1669
  return normalizeSubmitBooking(booking);
1668
1670
  }),
1669
1671
  payments: tempOrder.payments || [],
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "normal" | "duration" | "session";
52
+ getProductType(): "duration" | "normal" | "session";
53
53
  }
@@ -72,7 +72,7 @@ export declare const calculateOriginSubtotal: (items: CartItem[]) => string;
72
72
  * @return {*}
73
73
  * @Author: xiangfeng.xue
74
74
  */
75
- export declare const calculateTaxFee: (shopInfo: any, items: CartItem[]) => "0.00" | Decimal;
75
+ export declare const calculateTaxFee: (shopInfo: any, items: CartItem[]) => Decimal | "0.00";
76
76
  /**
77
77
  * @title: 计算定金
78
78
  * @param items - 购物车商品数组
@@ -256,6 +256,9 @@ function mergeBaseSalesCollectionItem(kind, currentItem, incomingItem, uidRemaps
256
256
  }
257
257
  }
258
258
  var mergedItem = mergedUid ? setOrderCollectionUid(kind, incomingItem, mergedUid) : cloneDeep(incomingItem);
259
+ if (kind === 'booking' && !mergedItem.uuid && currentItem.uuid !== undefined) {
260
+ mergedItem.uuid = currentItem.uuid;
261
+ }
259
262
  var persistentIdField = BASE_SALES_PERSISTENT_ID_FIELD_BY_KIND[kind];
260
263
  if (isBaseSalesBlankValue(mergedItem[persistentIdField]) && !isBaseSalesBlankValue(identityMergedItem[persistentIdField])) {
261
264
  mergedItem[persistentIdField] = identityMergedItem[persistentIdField];
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
342
342
  date: string;
343
343
  status: string;
344
344
  week: string;
345
- weekNum: 0 | 2 | 1 | 6 | 4 | 5 | 3;
345
+ weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
346
346
  }[]>;
347
347
  submitTimeSlot(timeSlots: TimeSliceItem): void;
348
348
  private getScheduleDataByIds;
@@ -389,7 +389,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
389
389
  };
390
390
  setOtherData(key: string, value: any): void;
391
391
  getOtherData(key: string): any;
392
- getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
392
+ getProductTypeById(id: number): Promise<"duration" | "normal" | "session">;
393
393
  /**
394
394
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
395
395
  *