@pisell/pisellos 2.3.226 → 2.3.228

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 (52) hide show
  1. package/dist/modules/Customer/types.d.ts +0 -4
  2. package/dist/modules/Order/index.d.ts +2 -0
  3. package/dist/modules/Order/index.js +82 -125
  4. package/dist/modules/Order/types.d.ts +0 -2
  5. package/dist/modules/Order/utils.js +0 -2
  6. package/dist/modules/Product/index.d.ts +1 -1
  7. package/dist/modules/Rules/index.js +1 -1
  8. package/dist/modules/Rules/types.d.ts +2 -0
  9. package/dist/modules/Summary/utils.d.ts +1 -1
  10. package/dist/solution/BaseSales/index.js +0 -3
  11. package/dist/solution/BookingByStep/index.d.ts +2 -2
  12. package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +14 -14
  13. package/dist/solution/Checkout/index.js +69 -104
  14. package/dist/solution/Checkout/types.d.ts +0 -1
  15. package/dist/solution/ScanOrder/additionalOrderPayload.d.ts +40 -0
  16. package/dist/solution/ScanOrder/additionalOrderPayload.js +52 -0
  17. package/dist/solution/ScanOrder/index.js +13 -19
  18. package/dist/solution/UnifiedBookingSales/draftDiscounts.d.ts +8 -0
  19. package/dist/solution/UnifiedBookingSales/draftDiscounts.js +101 -0
  20. package/dist/solution/UnifiedBookingSales/index.d.ts +7 -0
  21. package/dist/solution/UnifiedBookingSales/index.js +1253 -1072
  22. package/dist/solution/UnifiedBookingSales/types.d.ts +5 -0
  23. package/dist/solution/VenueBooking/index.js +490 -522
  24. package/lib/model/strategy/adapter/promotion/index.js +46 -1
  25. package/lib/modules/Customer/types.d.ts +0 -4
  26. package/lib/modules/Order/index.d.ts +2 -0
  27. package/lib/modules/Order/index.js +9 -46
  28. package/lib/modules/Order/types.d.ts +0 -2
  29. package/lib/modules/Order/utils.js +1 -5
  30. package/lib/modules/Product/index.d.ts +1 -1
  31. package/lib/modules/Rules/index.js +1 -1
  32. package/lib/modules/Rules/types.d.ts +2 -0
  33. package/lib/modules/Summary/utils.d.ts +1 -1
  34. package/lib/solution/BaseSales/index.js +0 -3
  35. package/lib/solution/BookingByStep/index.d.ts +2 -2
  36. package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +14 -14
  37. package/lib/solution/Checkout/index.js +0 -21
  38. package/lib/solution/Checkout/types.d.ts +0 -1
  39. package/lib/solution/ScanOrder/additionalOrderPayload.d.ts +40 -0
  40. package/lib/solution/ScanOrder/additionalOrderPayload.js +50 -0
  41. package/lib/solution/ScanOrder/index.js +5 -9
  42. package/lib/solution/UnifiedBookingSales/draftDiscounts.d.ts +8 -0
  43. package/lib/solution/UnifiedBookingSales/draftDiscounts.js +36 -0
  44. package/lib/solution/UnifiedBookingSales/index.d.ts +7 -0
  45. package/lib/solution/UnifiedBookingSales/index.js +78 -0
  46. package/lib/solution/UnifiedBookingSales/types.d.ts +5 -0
  47. package/lib/solution/VenueBooking/index.js +1 -6
  48. package/package.json +1 -1
  49. package/dist/modules/Order/utils/bookingUuid.d.ts +0 -4
  50. package/dist/modules/Order/utils/bookingUuid.js +0 -24
  51. package/lib/modules/Order/utils/bookingUuid.d.ts +0 -4
  52. package/lib/modules/Order/utils/bookingUuid.js +0 -25
@@ -31,6 +31,7 @@ exports.collectAvailabilityResourceIds = collectAvailabilityResourceIds;
31
31
  exports.normalizeProductForAvailability = normalizeProductForAvailability;
32
32
  var _dayjs = _interopRequireDefault(require("dayjs"));
33
33
  var _lodashEs = require("lodash-es");
34
+ var _draftDiscounts = require("./draftDiscounts");
34
35
  var _modules = require("../../modules");
35
36
  var _pickupTiming = require("../../modules/Order/pickupTiming");
36
37
  var _cacheItemToBookingInput = require("../../modules/BookingContext/utils/cacheItemToBookingInput");
@@ -2097,6 +2098,83 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
2097
2098
  }
2098
2099
  return this.store.order?.getTempOrder() || tempOrder;
2099
2100
  }
2101
+ getDraftDiscountSelection() {
2102
+ const order = this.getTempOrder();
2103
+ return order ? (0, _draftDiscounts.collectDraftDiscountSelection)(order, this.getDiscountList()) : [];
2104
+ }
2105
+
2106
+ /** Restore a local draft's cards as editable runtime entries, never as settled historical cards. */
2107
+ async restoreDraftDiscountSelection(snapshot) {
2108
+ const order = this.getTempOrder();
2109
+ if (!order || order.order_id && !isLocalOrderId(order.order_id)) return;
2110
+ const customerId = resolveTempOrderCustomerId(order);
2111
+ // A login/account change must not replay another customer's saved cards.
2112
+ if (resolveTempOrderCustomerId(snapshot.order) !== customerId) return;
2113
+ if (snapshot.order.external_sale_number !== order.external_sale_number) return;
2114
+ const selections = snapshot.discountSelection ?? (0, _draftDiscounts.collectDraftDiscountSelection)(snapshot.order);
2115
+ if (!selections.length) return;
2116
+ const beforeCommit = this.store.order.createCartIntentCommitGuard('scan_promotion', order);
2117
+ const assertCurrent = () => {
2118
+ if (this.getTempOrder() !== order || resolveTempOrderCustomerId(this.getTempOrder()) !== customerId) {
2119
+ throw Object.assign(new Error('The draft discount session ended.'), {
2120
+ code: 'SALES_GUARD_REJECTED'
2121
+ });
2122
+ }
2123
+ };
2124
+ assertCurrent();
2125
+ const discountModule = this.store.order.store.discount;
2126
+ const current = this.getDiscountList();
2127
+ const currentById = new Map(current.map(discount => [String(discount.id), discount]));
2128
+ const codes = [...new Set(selections.filter(selection => selection.code && (selection.isScan || !currentById.has(String(selection.id)))).map(selection => selection.code))];
2129
+ // Scanned cards are absent from prepare/config. Re-query each unique code once;
2130
+ // copying their old config would keep expired cards and stale eligibility alive.
2131
+ const results = await Promise.all(codes.map(code => discountModule.batchSearch(code, {
2132
+ customerId: customerId || undefined
2133
+ })));
2134
+ assertCurrent();
2135
+ const scanned = new Map();
2136
+ for (const result of results) {
2137
+ for (const discount of result.discountList || []) scanned.set(String(discount.id), discount);
2138
+ }
2139
+ const next = new Map(this.getDiscountList().map(discount => [String(discount.id), discount]));
2140
+ for (const selection of selections) {
2141
+ const id = String(selection.id);
2142
+ const revalidated = selection.code && (selection.isScan || !currentById.has(id));
2143
+ const discount = revalidated ? scanned.get(id) : next.get(id);
2144
+ if (!discount) {
2145
+ next.delete(id);
2146
+ continue;
2147
+ }
2148
+ next.set(id, {
2149
+ ...discount,
2150
+ isScan: Boolean(selection.isScan || revalidated),
2151
+ isSelected: selection.selected,
2152
+ isManualSelect: !selection.selected
2153
+ });
2154
+ }
2155
+ beforeCommit();
2156
+ await discountModule.setOriginalDiscountList([...next.values()]);
2157
+ assertCurrent();
2158
+ await discountModule.setDiscountList([...next.values()]);
2159
+ assertCurrent();
2160
+ // One calculation owns both the displayed cards and the restored line prices.
2161
+ this.store.order.applyDiscount({
2162
+ force: true
2163
+ });
2164
+ await this.store.order.recalculateSummary({
2165
+ createIfMissing: true
2166
+ });
2167
+ assertCurrent();
2168
+ const restored = this.store.order.ensureTempOrder();
2169
+ restored.discount_list = this.getDiscountList().filter(discount => discount.isSelected);
2170
+ this.store.order.persistTempOrder();
2171
+ await this.effectsEmit('onDiscountApplied', {
2172
+ productList: restored.products || [],
2173
+ discountList: this.getDiscountList(),
2174
+ selectedDiscountList: restored.discount_list,
2175
+ tempOrder: restored
2176
+ });
2177
+ }
2100
2178
  async syncAuthenticatedOrderCustomer() {
2101
2179
  if (!this.isAuthenticatedCustomerUserPlatform()) return false;
2102
2180
  const authenticatedCustomer = this.core?.getPlugin?.('user')?.get?.();
@@ -302,6 +302,11 @@ export interface UnifiedBookingSalesDiscountResult {
302
302
  summaryAfter?: unknown;
303
303
  }
304
304
  export interface UnifiedBookingSalesApi {
305
+ getDraftDiscountSelection: () => import('./draftDiscounts').DraftDiscountSelection[];
306
+ restoreDraftDiscountSelection: (snapshot: {
307
+ order: Record<string, any>;
308
+ discountSelection?: import('./draftDiscounts').DraftDiscountSelection[];
309
+ }) => Promise<void>;
305
310
  /** Uses cached business settings and evaluates the current store-local clock. */
306
311
  getBusinessAvailability: () => Promise<import('../../modules/BusinessAvailability').BusinessAvailability>;
307
312
  loadOpenData: (params: UnifiedBookingSalesLoadOpenDataParams) => Promise<OpenDataConfig>;
@@ -38,7 +38,6 @@ var _smartPricing = require("./utils/smartPricing");
38
38
  var _slotMerge = require("./utils/slotMerge");
39
39
  var _utils3 = require("../../modules/Order/utils");
40
40
  var _Order = require("../../modules/Order");
41
- var _bookingUuid = require("../../modules/Order/utils/bookingUuid");
42
41
  var _types4 = require("../RegisterAndLogin/types");
43
42
  var _decimal = _interopRequireDefault(require("decimal.js"));
44
43
  var _Holder = require("../../modules/Holder");
@@ -1198,7 +1197,6 @@ class VenueBookingImpl extends _BaseSales.BaseSalesImpl {
1198
1197
  if (!mapping) return;
1199
1198
  const tempOrder = this.store.order.ensureTempOrder();
1200
1199
  const matchesCurrent = (meta, pid) => !!meta?.venue_booking && String(meta?.resource_id) === String(resourceId) && Number(pid) === Number(productId);
1201
- const previousBookings = (tempOrder.bookings || []).filter(row => row.uuid && matchesCurrent(row.metadata, row.metadata?.product_id ?? row.product?.product_id));
1202
1200
  tempOrder.products = tempOrder.products.filter(p => !matchesCurrent(p.metadata, p.product_id));
1203
1201
  tempOrder.bookings = (tempOrder.bookings || []).filter(b => {
1204
1202
  if (!b.metadata?.venue_booking) return true;
@@ -1334,10 +1332,7 @@ class VenueBookingImpl extends _BaseSales.BaseSalesImpl {
1334
1332
  productUid,
1335
1333
  childResources: childRawResources
1336
1334
  });
1337
- // A resized or split interval can reuse its original UUID once.
1338
- const original = previousBookings.findIndex(row => `${row.start_date} ${String(row.start_time).slice(0, 5)}` < group.endTime && `${row.end_date} ${String(row.end_time).slice(0, 5)}` > group.startTime);
1339
- if (original >= 0) booking.uuid = previousBookings.splice(original, 1)[0].uuid;
1340
- tempOrder.bookings.push((0, _bookingUuid.ensureBookingUuid)(booking));
1335
+ tempOrder.bookings.push(booking);
1341
1336
  }
1342
1337
 
1343
1338
  // 获取表单信息
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.226",
4
+ "version": "2.3.228",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -1,4 +0,0 @@
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;
@@ -1,24 +0,0 @@
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
- }
@@ -1,4 +0,0 @@
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;
@@ -1,25 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.assignBookingUuid = assignBookingUuid;
7
- exports.ensureBookingUuid = ensureBookingUuid;
8
- var _orderCollectionIdentity = require("./orderCollectionIdentity");
9
- /** Cross-system booking identity; independent from the legacy cart-line UID. */
10
- 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 {
15
- ...booking,
16
- uuid: (0, _orderCollectionIdentity.createUuidV4)()
17
- };
18
- }
19
-
20
- /** Retain a generated UUID on the draft so a checkout retry sends the same value. */
21
- function assignBookingUuid(booking) {
22
- if (!booking) return;
23
- const resolved = ensureBookingUuid(booking);
24
- if (resolved !== booking) booking.uuid = resolved.uuid;
25
- }