@pisell/pisellos 2.3.54 → 2.3.55

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.
@@ -0,0 +1,9 @@
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, ITEM_REWARD_STRATEGY } from "./examples";
@@ -487,7 +487,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
487
487
  generateIdempotencyToken(): string;
488
488
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
489
489
  createOrder(params: CommitOrderParams['query']): {
490
- type: "appointment_booking" | "virtual";
490
+ type: "virtual" | "appointment_booking";
491
491
  platform: string;
492
492
  sales_channel: string;
493
493
  order_sales_channel: string;
@@ -3888,8 +3888,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3888
3888
  _normalizedIncoming$p2,
3889
3889
  _booking_uid,
3890
3890
  _metadata,
3891
+ _productToAdd$metadat,
3892
+ _origin,
3891
3893
  _this26 = this;
3892
- var linked, productToAdd, incomingFingerprint, normalizedIncoming, isWeighingProduct, netWeight, incomingBookingUid, hasIncomingGoodPass, hasIncomingProductNote, hasIncomingBookingUid, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, insertAtIndex, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList, mergedProduct;
3894
+ var linked, productToAdd, incomingFingerprint, normalizedIncoming, isWeighingProduct, netWeight, incomingBookingUid, hasIncomingGoodPass, hasIncomingProductNote, hasIncomingBookingUid, isIncomingCustomItem, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, insertAtIndex, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList, mergedProduct;
3893
3895
  return _regeneratorRuntime().wrap(function _callee20$(_context22) {
3894
3896
  while (1) switch (_context22.prev = _context22.next) {
3895
3897
  case 0:
@@ -3919,7 +3921,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3919
3921
  hasIncomingGoodPass = this.hasGoodPassDiscount(normalizedIncoming);
3920
3922
  hasIncomingProductNote = this.hasOrderProductLineNote(normalizedIncoming);
3921
3923
  hasIncomingBookingUid = this.hasLinkedBookingUid(productToAdd) || this.hasLinkedBookingUid(normalizedIncoming);
3922
- shouldForceNewLine = !!booking || hasIncomingProductNote || hasIncomingBookingUid || isWeighingProduct;
3924
+ isIncomingCustomItem = ((_productToAdd$metadat = productToAdd.metadata) === null || _productToAdd$metadat === void 0 || (_productToAdd$metadat = _productToAdd$metadat.origin) === null || _productToAdd$metadat === void 0 ? void 0 : _productToAdd$metadat.isCustomItem) === true || ((_origin = productToAdd._origin) === null || _origin === void 0 ? void 0 : _origin.isCustomItem) === true;
3925
+ shouldForceNewLine = !!booking || hasIncomingProductNote || hasIncomingBookingUid || isIncomingCustomItem || isWeighingProduct;
3923
3926
  matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
3924
3927
  var _item$metadata3;
3925
3928
  if (_this26.hasGoodPassDiscount(item)) return false;
@@ -3934,10 +3937,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3934
3937
  matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
3935
3938
  existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
3936
3939
  if (!matchedProduct) {
3937
- _context22.next = 24;
3940
+ _context22.next = 25;
3938
3941
  break;
3939
3942
  }
3940
- _context22.next = 21;
3943
+ _context22.next = 22;
3941
3944
  return this.shouldMergeProductToOrder({
3942
3945
  incomingProduct: productToAdd,
3943
3946
  normalizedIncoming: normalizedIncoming,
@@ -3948,13 +3951,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3948
3951
  tempOrder: tempOrder,
3949
3952
  booking: booking
3950
3953
  });
3951
- case 21:
3954
+ case 22:
3952
3955
  _context22.t0 = _context22.sent;
3953
- _context22.next = 25;
3956
+ _context22.next = 26;
3954
3957
  break;
3955
- case 24:
3956
- _context22.t0 = false;
3957
3958
  case 25:
3959
+ _context22.t0 = false;
3960
+ case 26:
3958
3961
  shouldMerge = _context22.t0;
3959
3962
  if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
3960
3963
  this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
@@ -4015,7 +4018,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4015
4018
  if (linked) {
4016
4019
  tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
4017
4020
  }
4018
- case 28:
4021
+ case 29:
4019
4022
  case "end":
4020
4023
  return _context22.stop();
4021
4024
  }
@@ -468,10 +468,13 @@ function getProductLineNoteSignature(product) {
468
468
  }
469
469
 
470
470
  /**
471
- * 称重行以及编辑订单历史行都有各自的促销合并边界。
471
+ * 自定义商品、称重行以及编辑订单历史行都有各自的促销合并边界。
472
472
  */
473
473
  function getPromotionLineMergeBoundary(product) {
474
474
  var _product$product_sku, _product$metadata3;
475
+ if ((product === null || product === void 0 ? void 0 : product.product_id) === undefined || (product === null || product === void 0 ? void 0 : product.product_id) === null) {
476
+ return "custom:".concat(getOrderProductUid(product));
477
+ }
475
478
  if (Number((product === null || product === void 0 || (_product$product_sku = product.product_sku) === null || _product$product_sku === void 0 ? void 0 : _product$product_sku.open_sold_weight) || 0) === 1) {
476
479
  return "weighing:".concat(getOrderProductUid(product));
477
480
  }
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 5 | 2 | 1 | 6 | 4 | 3;
329
+ weekNum: 0 | 2 | 1 | 6 | 4 | 5 | 3;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -0,0 +1,51 @@
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
+ ITEM_REWARD_STRATEGY: () => import_examples.ITEM_REWARD_STRATEGY,
34
+ PromotionAdapter: () => import_adapter.PromotionAdapter,
35
+ PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
36
+ X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
37
+ default: () => import_adapter2.default
38
+ });
39
+ module.exports = __toCommonJS(promotion_exports);
40
+ var import_evaluator = require("./evaluator");
41
+ var import_adapter = require("./adapter");
42
+ var import_adapter2 = __toESM(require("./adapter"));
43
+ var import_examples = require("./examples");
44
+ // Annotate the CommonJS export names for ESM import in node:
45
+ 0 && (module.exports = {
46
+ BUY_X_GET_Y_FREE_STRATEGY,
47
+ ITEM_REWARD_STRATEGY,
48
+ PromotionAdapter,
49
+ PromotionEvaluator,
50
+ X_ITEMS_FOR_Y_PRICE_STRATEGY
51
+ });
@@ -487,7 +487,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
487
487
  generateIdempotencyToken(): string;
488
488
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
489
489
  createOrder(params: CommitOrderParams['query']): {
490
- type: "appointment_booking" | "virtual";
490
+ type: "virtual" | "appointment_booking";
491
491
  platform: string;
492
492
  sales_channel: string;
493
493
  order_sales_channel: string;
@@ -2898,7 +2898,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2898
2898
  * await this.appendProductLineToTempOrder(tempOrder, { product_id: 1, num: 1 }, booking);
2899
2899
  */
2900
2900
  async appendProductLineToTempOrder(tempOrder, product, booking, options) {
2901
- var _a, _b, _c, _d;
2901
+ var _a, _b, _c, _d, _e, _f, _g;
2902
2902
  const linked = booking ? this.createLinkedProductAndBooking({ product, booking }) : null;
2903
2903
  const productToAdd = (linked == null ? void 0 : linked.product) || product;
2904
2904
  const incomingFingerprint = (0, import_utils3.buildProductLineFingerprint)(
@@ -2930,7 +2930,8 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2930
2930
  );
2931
2931
  const hasIncomingProductNote = this.hasOrderProductLineNote(normalizedIncoming);
2932
2932
  const hasIncomingBookingUid = this.hasLinkedBookingUid(productToAdd) || this.hasLinkedBookingUid(normalizedIncoming);
2933
- const shouldForceNewLine = !!booking || hasIncomingProductNote || hasIncomingBookingUid || isWeighingProduct;
2933
+ const isIncomingCustomItem = ((_e = (_d = productToAdd.metadata) == null ? void 0 : _d.origin) == null ? void 0 : _e.isCustomItem) === true || ((_f = productToAdd._origin) == null ? void 0 : _f.isCustomItem) === true;
2934
+ const shouldForceNewLine = !!booking || hasIncomingProductNote || hasIncomingBookingUid || isIncomingCustomItem || isWeighingProduct;
2934
2935
  const matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex((item) => {
2935
2936
  var _a2;
2936
2937
  if (this.hasGoodPassDiscount(item))
@@ -2991,7 +2992,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2991
2992
  }
2992
2993
  } else {
2993
2994
  const targetProduct = matchedProduct;
2994
- const targetUid = (_d = targetProduct.metadata) == null ? void 0 : _d.unique_identification_number;
2995
+ const targetUid = (_g = targetProduct.metadata) == null ? void 0 : _g.unique_identification_number;
2995
2996
  const normalizedProduct = (0, import_utils.mergeOrderProductDisplayFields)(
2996
2997
  targetProduct,
2997
2998
  (0, import_utils3.normalizeOrderProduct)({
@@ -368,6 +368,9 @@ function getProductLineNoteSignature(product) {
368
368
  }
369
369
  function getPromotionLineMergeBoundary(product) {
370
370
  var _a, _b;
371
+ if ((product == null ? void 0 : product.product_id) === void 0 || (product == null ? void 0 : product.product_id) === null) {
372
+ return `custom:${getOrderProductUid(product)}`;
373
+ }
371
374
  if (Number(((_a = product == null ? void 0 : product.product_sku) == null ? void 0 : _a.open_sold_weight) || 0) === 1) {
372
375
  return `weighing:${getOrderProductUid(product)}`;
373
376
  }
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 5 | 2 | 1 | 6 | 4 | 3;
329
+ weekNum: 0 | 2 | 1 | 6 | 4 | 5 | 3;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.54",
4
+ "version": "2.3.55",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",