@pisell/pisellos 2.2.184 → 2.2.185

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.
@@ -1,9 +0,0 @@
1
- // 导出评估器
2
- export { PromotionEvaluator } from "./evaluator";
3
-
4
- // 导出适配器
5
- export { PromotionAdapter } from "./adapter";
6
- export { default } from "./adapter";
7
-
8
- // 导出策略配置示例常量
9
- export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY } from "./examples";
@@ -264,7 +264,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
264
264
  private logSubmitBackendRejected;
265
265
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
266
266
  createOrder(params: CommitOrderParams['query']): {
267
- type: "virtual" | "appointment_booking";
267
+ type: "appointment_booking" | "virtual";
268
268
  platform: string;
269
269
  sales_channel: string;
270
270
  order_sales_channel: string;
@@ -1,7 +1,3 @@
1
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
4
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
5
1
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
6
2
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
3
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
@@ -2224,8 +2220,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2224
2220
  key: "updateOrderProduct",
2225
2221
  value: function () {
2226
2222
  var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params) {
2227
- var _targetProduct$metada2, _metadata, _metadata2, _metadata3, _tempOrder$products$p;
2228
- var product_id, product_variant_id, updates, unique_identification_number, identity_key, product_option_item, product_bundle, booking, tempOrder, identityLookup, productIndex, targetUid, targetProduct, nextProduct, callerUpdatesTopPrice, callerUpdatesMainMeta, existedMeta, normalizedProduct, _normalizedProduct$me, _targetProduct$metada3, productUid, linked;
2223
+ var _targetProduct$metada2, _metadata, _metadata2, _metadata3, _nextProduct$metadata, _targetProduct$metada3, _tempOrder$products$p;
2224
+ var product_id, product_variant_id, updates, unique_identification_number, identity_key, product_option_item, product_bundle, booking, tempOrder, identityLookup, productIndex, targetUid, targetProduct, nextProduct, callerUpdatesTopPrice, callerUpdatesMainMeta, existedMeta, normalizedProduct, preservedBookingUid, _normalizedProduct$me, _targetProduct$metada4, productUid, linked;
2229
2225
  return _regeneratorRuntime().wrap(function _callee17$(_context19) {
2230
2226
  while (1) switch (_context19.prev = _context19.next) {
2231
2227
  case 0:
@@ -2292,8 +2288,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2292
2288
  // 否则 → 把顶层 selling_price 视作 source,派生 main_product_* 并写 price_schema_version: 2。
2293
2289
  normalizedProduct = mergeOrderProductDisplayFields(nextProduct, normalizeOrderProduct(nextProduct));
2294
2290
  normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
2291
+ preservedBookingUid = nextProduct.booking_uid || ((_nextProduct$metadata = nextProduct.metadata) === null || _nextProduct$metadata === void 0 ? void 0 : _nextProduct$metadata.booking_uid) || targetProduct.booking_uid || ((_targetProduct$metada3 = targetProduct.metadata) === null || _targetProduct$metada3 === void 0 ? void 0 : _targetProduct$metada3.booking_uid);
2292
+ if (!booking && preservedBookingUid) {
2293
+ normalizedProduct.booking_uid = preservedBookingUid;
2294
+ normalizedProduct.metadata = _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
2295
+ booking_uid: preservedBookingUid
2296
+ });
2297
+ }
2295
2298
  if (booking) {
2296
- productUid = String(((_normalizedProduct$me = normalizedProduct.metadata) === null || _normalizedProduct$me === void 0 ? void 0 : _normalizedProduct$me.unique_identification_number) || ((_targetProduct$metada3 = targetProduct.metadata) === null || _targetProduct$metada3 === void 0 ? void 0 : _targetProduct$metada3.unique_identification_number) || unique_identification_number || createUuidV4());
2299
+ productUid = String(((_normalizedProduct$me = normalizedProduct.metadata) === null || _normalizedProduct$me === void 0 ? void 0 : _normalizedProduct$me.unique_identification_number) || ((_targetProduct$metada4 = targetProduct.metadata) === null || _targetProduct$metada4 === void 0 ? void 0 : _targetProduct$metada4.unique_identification_number) || unique_identification_number || createUuidV4());
2297
2300
  normalizedProduct.metadata = _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
2298
2301
  unique_identification_number: productUid
2299
2302
  });
@@ -2315,18 +2318,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2315
2318
  }
2316
2319
  tempOrder.products[productIndex] = normalizedProduct;
2317
2320
  this.captureProductRuntime(tempOrder, updates, tempOrder.products[productIndex], (_tempOrder$products$p = tempOrder.products[productIndex].metadata) === null || _tempOrder$products$p === void 0 ? void 0 : _tempOrder$products$p.unique_identification_number);
2318
- _context19.next = 25;
2321
+ _context19.next = 27;
2319
2322
  return this.applyPromotion();
2320
- case 25:
2323
+ case 27:
2321
2324
  this.applyDiscount();
2322
- _context19.next = 28;
2325
+ _context19.next = 30;
2323
2326
  return this.recalculateSummary({
2324
2327
  createIfMissing: true
2325
2328
  });
2326
- case 28:
2329
+ case 30:
2327
2330
  this.persistTempOrder();
2328
2331
  return _context19.abrupt("return", tempOrder.products);
2329
- case 30:
2332
+ case 32:
2330
2333
  case "end":
2331
2334
  return _context19.stop();
2332
2335
  }
@@ -2341,7 +2344,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2341
2344
  key: "updateOrderProductQuantity",
2342
2345
  value: function () {
2343
2346
  var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(params) {
2344
- var _targetProduct$metada4;
2347
+ var _targetProduct$metada5;
2345
2348
  var product_id, product_variant_id, num, unique_identification_number, identity_key, product_option_item, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct;
2346
2349
  return _regeneratorRuntime().wrap(function _callee18$(_context20) {
2347
2350
  while (1) switch (_context20.prev = _context20.next) {
@@ -2382,7 +2385,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2382
2385
  normalizedProduct = normalizeOrderProduct(_objectSpread(_objectSpread({}, targetProduct), {}, {
2383
2386
  num: getSafeProductNum(num),
2384
2387
  metadata: _objectSpread(_objectSpread({}, targetProduct.metadata || {}), {}, {
2385
- unique_identification_number: ((_targetProduct$metada4 = targetProduct.metadata) === null || _targetProduct$metada4 === void 0 ? void 0 : _targetProduct$metada4.unique_identification_number) || unique_identification_number
2388
+ unique_identification_number: ((_targetProduct$metada5 = targetProduct.metadata) === null || _targetProduct$metada5 === void 0 ? void 0 : _targetProduct$metada5.unique_identification_number) || unique_identification_number
2386
2389
  })
2387
2390
  }));
2388
2391
  normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
@@ -3272,8 +3275,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3272
3275
  delete nextTempOrder.holder_id;
3273
3276
  nextTempOrder.metadata = raw.metadata && _typeof(raw.metadata) === 'object' ? _objectSpread({}, raw.metadata) : {};
3274
3277
  nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
3275
- var rawProducts = Array.isArray(raw.products) ? raw.products : [];
3276
- nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
3278
+ nextTempOrder.products = Array.isArray(raw.products) ? raw.products.map(function (p) {
3277
3279
  return _this10.normalizeHydratedOrderProduct(p);
3278
3280
  }) : [];
3279
3281
  nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
@@ -3300,31 +3302,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3300
3302
  }) : {
3301
3303
  productsByUid: {}
3302
3304
  };
3303
- var tempOrderExtend = nextTempOrder._extend;
3304
- var productsByUid = tempOrderExtend.productsByUid || {};
3305
- var _iterator8 = _createForOfIteratorHelper(nextTempOrder.products.entries()),
3306
- _step8;
3307
- try {
3308
- for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
3309
- var _product$metadata6, _ref23, _ref24, _existed$origin, _rawProduct$metadata;
3310
- var _step8$value = _slicedToArray(_step8.value, 2),
3311
- index = _step8$value[0],
3312
- product = _step8$value[1];
3313
- var uid = (_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.unique_identification_number;
3314
- if (!uid) continue;
3315
- var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
3316
- var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
3317
- var origin = (_ref23 = (_ref24 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref24 !== void 0 ? _ref24 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref23 !== void 0 ? _ref23 : rawProduct;
3318
- productsByUid[uid] = _objectSpread(_objectSpread({}, existed), {}, {
3319
- origin: cloneDeep(origin)
3320
- });
3321
- }
3322
- } catch (err) {
3323
- _iterator8.e(err);
3324
- } finally {
3325
- _iterator8.f();
3326
- }
3327
- tempOrderExtend.productsByUid = productsByUid;
3328
3305
  if ((options === null || options === void 0 ? void 0 : options.ensureIdentity) !== false) {
3329
3306
  this.ensureExternalSaleNumber(nextTempOrder);
3330
3307
  }
@@ -3334,10 +3311,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3334
3311
  }, {
3335
3312
  key: "normalizeHydratedProductOptionItem",
3336
3313
  value: function normalizeHydratedProductOptionItem(optionItem) {
3337
- var _ref25, _optionItem$num, _ref26, _optionItem$price;
3338
- var rawNum = (_ref25 = (_optionItem$num = optionItem === null || optionItem === void 0 ? void 0 : optionItem.num) !== null && _optionItem$num !== void 0 ? _optionItem$num : optionItem === null || optionItem === void 0 ? void 0 : optionItem.quantity) !== null && _ref25 !== void 0 ? _ref25 : 1;
3314
+ var _ref23, _optionItem$num, _ref24, _optionItem$price;
3315
+ var rawNum = (_ref23 = (_optionItem$num = optionItem === null || optionItem === void 0 ? void 0 : optionItem.num) !== null && _optionItem$num !== void 0 ? _optionItem$num : optionItem === null || optionItem === void 0 ? void 0 : optionItem.quantity) !== null && _ref23 !== void 0 ? _ref23 : 1;
3339
3316
  var parsedNum = Number(rawNum);
3340
- var rawPrice = (_ref26 = (_optionItem$price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _optionItem$price !== void 0 ? _optionItem$price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _ref26 !== void 0 ? _ref26 : 0;
3317
+ var rawPrice = (_ref24 = (_optionItem$price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _optionItem$price !== void 0 ? _optionItem$price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _ref24 !== void 0 ? _ref24 : 0;
3341
3318
  var parsedPrice = Number(rawPrice);
3342
3319
  return {
3343
3320
  option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
@@ -3370,6 +3347,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3370
3347
  row.product_option_item = this.resolveHydratedProductOptions(row);
3371
3348
  if (!Array.isArray(row.product_bundle)) row.product_bundle = [];
3372
3349
  if (!row.metadata || _typeof(row.metadata) !== 'object') row.metadata = {};
3350
+ if (row.booking_uid && !row.metadata.booking_uid) {
3351
+ row.metadata.booking_uid = row.booking_uid;
3352
+ }
3373
3353
  var existingIdentity = row.metadata.unique_identification_number || row.unique_identification_number;
3374
3354
  if (!existingIdentity) {
3375
3355
  row.metadata.unique_identification_number = createUuidV4();
@@ -3432,67 +3412,67 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3432
3412
  var amount = new Decimal(discount.amount || 0).times(qty).plus(((_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.product_discount_difference) || 0);
3433
3413
  savedMap.set(discountKey, (savedMap.get(discountKey) || new Decimal(0)).plus(amount));
3434
3414
  };
3435
- var _iterator9 = _createForOfIteratorHelper(productList),
3436
- _step9;
3415
+ var _iterator8 = _createForOfIteratorHelper(productList),
3416
+ _step8;
3437
3417
  try {
3438
- for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
3439
- var product = _step9.value;
3418
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
3419
+ var product = _step8.value;
3440
3420
  var qty = product.num || 1;
3441
- var _iterator11 = _createForOfIteratorHelper(product.discount_list || []),
3442
- _step11;
3421
+ var _iterator10 = _createForOfIteratorHelper(product.discount_list || []),
3422
+ _step10;
3443
3423
  try {
3444
- for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
3445
- var pd = _step11.value;
3424
+ for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
3425
+ var pd = _step10.value;
3446
3426
  addDiscountAmount(pd, qty);
3447
3427
  }
3448
3428
  } catch (err) {
3449
- _iterator11.e(err);
3429
+ _iterator10.e(err);
3450
3430
  } finally {
3451
- _iterator11.f();
3431
+ _iterator10.f();
3452
3432
  }
3453
- var _iterator12 = _createForOfIteratorHelper(product.product_bundle || []),
3454
- _step12;
3433
+ var _iterator11 = _createForOfIteratorHelper(product.product_bundle || []),
3434
+ _step11;
3455
3435
  try {
3456
- for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
3457
- var _ref27, _bundle$num;
3458
- var bundle = _step12.value;
3459
- var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref27 = (_bundle$num = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num !== void 0 ? _bundle$num : bundle === null || bundle === void 0 ? void 0 : bundle.quantity) !== null && _ref27 !== void 0 ? _ref27 : 1) || 1).toNumber();
3460
- var _iterator13 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
3461
- _step13;
3436
+ for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
3437
+ var _ref25, _bundle$num;
3438
+ var bundle = _step11.value;
3439
+ var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref25 = (_bundle$num = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num !== void 0 ? _bundle$num : bundle === null || bundle === void 0 ? void 0 : bundle.quantity) !== null && _ref25 !== void 0 ? _ref25 : 1) || 1).toNumber();
3440
+ var _iterator12 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
3441
+ _step12;
3462
3442
  try {
3463
- for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
3464
- var _pd = _step13.value;
3443
+ for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
3444
+ var _pd = _step12.value;
3465
3445
  addDiscountAmount(_pd, bundleQty);
3466
3446
  }
3467
3447
  } catch (err) {
3468
- _iterator13.e(err);
3448
+ _iterator12.e(err);
3469
3449
  } finally {
3470
- _iterator13.f();
3450
+ _iterator12.f();
3471
3451
  }
3472
3452
  }
3473
3453
  } catch (err) {
3474
- _iterator12.e(err);
3454
+ _iterator11.e(err);
3475
3455
  } finally {
3476
- _iterator12.f();
3456
+ _iterator11.f();
3477
3457
  }
3478
3458
  }
3479
3459
  } catch (err) {
3480
- _iterator9.e(err);
3460
+ _iterator8.e(err);
3481
3461
  } finally {
3482
- _iterator9.f();
3462
+ _iterator8.f();
3483
3463
  }
3484
- var _iterator10 = _createForOfIteratorHelper(discountList),
3485
- _step10;
3464
+ var _iterator9 = _createForOfIteratorHelper(discountList),
3465
+ _step9;
3486
3466
  try {
3487
- for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
3488
- var d = _step10.value;
3467
+ for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
3468
+ var d = _step9.value;
3489
3469
  var key = d.id;
3490
3470
  d.savedAmount = d.isSelected && key != null && savedMap.has(key) ? savedMap.get(key).toNumber() : 0;
3491
3471
  }
3492
3472
  } catch (err) {
3493
- _iterator10.e(err);
3473
+ _iterator9.e(err);
3494
3474
  } finally {
3495
- _iterator10.f();
3475
+ _iterator9.f();
3496
3476
  }
3497
3477
  }
3498
3478
  }]);
@@ -33,7 +33,7 @@ function normalizeOptionItems(optionItems) {
33
33
  if (!Array.isArray(optionItems)) return [];
34
34
  return optionItems.map(function (optionItem) {
35
35
  var _ref, _optionItem$price, _optionItem$num;
36
- var optionGroupItemId = toNumber(optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id);
36
+ var optionGroupItemId = toNumber(optionItem === null || optionItem === void 0 ? void 0 : optionItem.id);
37
37
  var price = (_ref = (_optionItem$price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _optionItem$price !== void 0 ? _optionItem$price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _ref !== void 0 ? _ref : 0;
38
38
  return {
39
39
  option_group_item_id: optionGroupItemId,
@@ -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 | 4 | 2 | 3 | 6;
314
+ weekNum: 0 | 2 | 1 | 5 | 3 | 4 | 6;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -1,49 +0,0 @@
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
- });
@@ -264,7 +264,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
264
264
  private logSubmitBackendRejected;
265
265
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
266
266
  createOrder(params: CommitOrderParams['query']): {
267
- type: "virtual" | "appointment_booking";
267
+ type: "appointment_booking" | "virtual";
268
268
  platform: string;
269
269
  sales_channel: string;
270
270
  order_sales_channel: string;
@@ -1559,7 +1559,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1559
1559
  );
1560
1560
  }
1561
1561
  async updateOrderProduct(params) {
1562
- var _a, _b, _c, _d, _e, _f, _g;
1562
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
1563
1563
  const {
1564
1564
  product_id,
1565
1565
  product_variant_id,
@@ -1634,9 +1634,17 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1634
1634
  normalizedProduct.discount_list = (0, import_utils.normalizeOrderProductDiscountList)(
1635
1635
  normalizedProduct.discount_list
1636
1636
  );
1637
+ const preservedBookingUid = nextProduct.booking_uid || ((_e = nextProduct.metadata) == null ? void 0 : _e.booking_uid) || targetProduct.booking_uid || ((_f = targetProduct.metadata) == null ? void 0 : _f.booking_uid);
1638
+ if (!booking && preservedBookingUid) {
1639
+ normalizedProduct.booking_uid = preservedBookingUid;
1640
+ normalizedProduct.metadata = {
1641
+ ...normalizedProduct.metadata || {},
1642
+ booking_uid: preservedBookingUid
1643
+ };
1644
+ }
1637
1645
  if (booking) {
1638
1646
  const productUid = String(
1639
- ((_e = normalizedProduct.metadata) == null ? void 0 : _e.unique_identification_number) || ((_f = targetProduct.metadata) == null ? void 0 : _f.unique_identification_number) || unique_identification_number || (0, import_utils.createUuidV4)()
1647
+ ((_g = normalizedProduct.metadata) == null ? void 0 : _g.unique_identification_number) || ((_h = targetProduct.metadata) == null ? void 0 : _h.unique_identification_number) || unique_identification_number || (0, import_utils.createUuidV4)()
1640
1648
  );
1641
1649
  normalizedProduct.metadata = {
1642
1650
  ...normalizedProduct.metadata || {},
@@ -1666,7 +1674,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1666
1674
  tempOrder,
1667
1675
  updates,
1668
1676
  tempOrder.products[productIndex],
1669
- (_g = tempOrder.products[productIndex].metadata) == null ? void 0 : _g.unique_identification_number
1677
+ (_i = tempOrder.products[productIndex].metadata) == null ? void 0 : _i.unique_identification_number
1670
1678
  );
1671
1679
  await this.applyPromotion();
1672
1680
  this.applyDiscount();
@@ -2274,7 +2282,6 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2274
2282
  return nextTempOrder;
2275
2283
  }
2276
2284
  normalizeTempOrderForRuntime(raw, options) {
2277
- var _a, _b;
2278
2285
  const nextTempOrder = {
2279
2286
  ...this.createDefaultTempOrderInstance(),
2280
2287
  ...raw || {}
@@ -2294,8 +2301,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2294
2301
  delete nextTempOrder.holder_id;
2295
2302
  nextTempOrder.metadata = raw.metadata && typeof raw.metadata === "object" ? { ...raw.metadata } : {};
2296
2303
  nextTempOrder.holder = raw.holder && typeof raw.holder === "object" ? { ...raw.holder } : null;
2297
- const rawProducts = Array.isArray(raw.products) ? raw.products : [];
2298
- nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map((p) => this.normalizeHydratedOrderProduct(p)) : [];
2304
+ nextTempOrder.products = Array.isArray(raw.products) ? raw.products.map((p) => this.normalizeHydratedOrderProduct(p)) : [];
2299
2305
  nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map((b) => ({
2300
2306
  ...b || {},
2301
2307
  is_all: (0, import_utils.normalizeBookingIsAll)(b || {}),
@@ -2310,21 +2316,6 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2310
2316
  ...raw._extend,
2311
2317
  productsByUid: raw._extend.productsByUid || {}
2312
2318
  } : { productsByUid: {} };
2313
- const tempOrderExtend = nextTempOrder._extend;
2314
- const productsByUid = tempOrderExtend.productsByUid || {};
2315
- for (const [index, product] of nextTempOrder.products.entries()) {
2316
- const uid = (_a = product.metadata) == null ? void 0 : _a.unique_identification_number;
2317
- if (!uid)
2318
- continue;
2319
- const existed = productsByUid[uid] && typeof productsByUid[uid] === "object" ? productsByUid[uid] : {};
2320
- const rawProduct = rawProducts[index] && typeof rawProducts[index] === "object" ? rawProducts[index] : product;
2321
- const origin = existed.origin ?? rawProduct._origin ?? ((_b = rawProduct.metadata) == null ? void 0 : _b.origin) ?? rawProduct;
2322
- productsByUid[uid] = {
2323
- ...existed,
2324
- origin: (0, import_lodash_es.cloneDeep)(origin)
2325
- };
2326
- }
2327
- tempOrderExtend.productsByUid = productsByUid;
2328
2319
  if ((options == null ? void 0 : options.ensureIdentity) !== false) {
2329
2320
  this.ensureExternalSaleNumber(nextTempOrder);
2330
2321
  }
@@ -2365,6 +2356,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2365
2356
  row.product_bundle = [];
2366
2357
  if (!row.metadata || typeof row.metadata !== "object")
2367
2358
  row.metadata = {};
2359
+ if (row.booking_uid && !row.metadata.booking_uid) {
2360
+ row.metadata.booking_uid = row.booking_uid;
2361
+ }
2368
2362
  const existingIdentity = row.metadata.unique_identification_number || row.unique_identification_number;
2369
2363
  if (!existingIdentity) {
2370
2364
  row.metadata.unique_identification_number = (0, import_utils.createUuidV4)();
@@ -53,7 +53,7 @@ function normalizeOptionItems(optionItems) {
53
53
  if (!Array.isArray(optionItems))
54
54
  return [];
55
55
  return optionItems.map((optionItem) => {
56
- const optionGroupItemId = toNumber(optionItem == null ? void 0 : optionItem.option_group_item_id);
56
+ const optionGroupItemId = toNumber(optionItem == null ? void 0 : optionItem.id);
57
57
  const price = (optionItem == null ? void 0 : optionItem.price) ?? (optionItem == null ? void 0 : optionItem.add_price) ?? 0;
58
58
  return {
59
59
  option_group_item_id: optionGroupItemId,
@@ -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 | 4 | 2 | 3 | 6;
314
+ weekNum: 0 | 2 | 1 | 5 | 3 | 4 | 6;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.184",
4
+ "version": "2.2.185",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",