@pisell/pisellos 2.3.229 → 2.3.231

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 (37) hide show
  1. package/dist/model/strategy/adapter/promotion/adapter.js +14 -2
  2. package/dist/model/strategy/adapter/promotion/evaluator.js +23 -8
  3. package/dist/model/strategy/adapter/promotion/type.d.ts +10 -2
  4. package/dist/modules/Order/index.d.ts +1 -1
  5. package/dist/modules/Order/index.js +1371 -1234
  6. package/dist/modules/Order/types.d.ts +13 -34
  7. package/dist/modules/Order/types.js +2 -0
  8. package/dist/modules/Summary/utils.d.ts +1 -1
  9. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +5 -18
  10. package/dist/solution/BaseSales/utils/cartPromotion.js +252 -168
  11. package/dist/solution/BookingTicket/index.d.ts +2 -2
  12. package/dist/solution/BookingTicket/index.js +45 -21
  13. package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +10 -10
  14. package/dist/solution/ScanOrder/index.d.ts +1 -0
  15. package/dist/solution/ScanOrder/index.js +52 -38
  16. package/dist/solution/ScanOrder/menuAvailability.js +3 -25
  17. package/dist/solution/ScanOrder/shopTime.d.ts +6 -0
  18. package/dist/solution/ScanOrder/shopTime.js +36 -0
  19. package/lib/model/strategy/adapter/promotion/adapter.js +10 -1
  20. package/lib/model/strategy/adapter/promotion/evaluator.js +18 -6
  21. package/lib/model/strategy/adapter/promotion/type.d.ts +10 -2
  22. package/lib/modules/Order/index.d.ts +1 -1
  23. package/lib/modules/Order/index.js +103 -32
  24. package/lib/modules/Order/types.d.ts +13 -34
  25. package/lib/modules/Order/types.js +1 -0
  26. package/lib/modules/Summary/utils.d.ts +1 -1
  27. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +5 -18
  28. package/lib/solution/BaseSales/utils/cartPromotion.js +87 -40
  29. package/lib/solution/BookingTicket/index.d.ts +2 -2
  30. package/lib/solution/BookingTicket/index.js +28 -11
  31. package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +10 -10
  32. package/lib/solution/ScanOrder/index.d.ts +1 -0
  33. package/lib/solution/ScanOrder/index.js +26 -13
  34. package/lib/solution/ScanOrder/menuAvailability.js +3 -20
  35. package/lib/solution/ScanOrder/shopTime.d.ts +6 -0
  36. package/lib/solution/ScanOrder/shopTime.js +37 -0
  37. package/package.json +1 -1
@@ -196,14 +196,26 @@ export var PromotionAdapter = /*#__PURE__*/function () {
196
196
  var _config$cumulative2;
197
197
  var value = action.value || {};
198
198
  var config = action.config || {};
199
- return {
199
+ var fixedGiftProducts = config.fixedGiftProducts;
200
+ if (fixedGiftProducts !== undefined) {
201
+ if (!Number.isSafeInteger(value.buyQuantity) || value.buyQuantity <= 0 || !Array.isArray(fixedGiftProducts) || fixedGiftProducts.length === 0 || fixedGiftProducts.some(function (gift) {
202
+ return !gift || !Number.isSafeInteger(gift.product_id) || gift.product_id <= 0 || !Number.isSafeInteger(gift.product_variant_id) || gift.product_variant_id < 0 || !Number.isSafeInteger(gift.quantity) || gift.quantity <= 0;
203
+ }) || new Set(fixedGiftProducts.map(function (gift) {
204
+ return gift.product_id;
205
+ })).size !== fixedGiftProducts.length) {
206
+ return undefined;
207
+ }
208
+ }
209
+ return _objectSpread({
200
210
  type: PROMOTION_ACTION_TYPES.BUY_X_GET_Y_FREE,
201
211
  buyQuantity: value.buyQuantity || 1,
202
212
  freeQuantity: value.freeQuantity || 1,
203
213
  giftSelectionMode: config.giftSelectionMode || 'user_select',
204
214
  cumulative: (_config$cumulative2 = config.cumulative) !== null && _config$cumulative2 !== void 0 ? _config$cumulative2 : true,
205
215
  giftProducts: config.giftProducts || []
206
- };
216
+ }, fixedGiftProducts && {
217
+ fixedGiftProducts: fixedGiftProducts
218
+ });
207
219
  }
208
220
 
209
221
  /**
@@ -1007,7 +1007,8 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
1007
1007
  var buyQuantity = detail.buyQuantity,
1008
1008
  freeQuantity = detail.freeQuantity,
1009
1009
  cumulative = detail.cumulative,
1010
- giftProducts = detail.giftProducts;
1010
+ giftProducts = detail.giftProducts,
1011
+ fixedGiftProducts = detail.fixedGiftProducts;
1011
1012
  var result = [];
1012
1013
  var originalAmount = new Decimal(0);
1013
1014
  var finalAmount = new Decimal(0);
@@ -1089,18 +1090,32 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
1089
1090
  } finally {
1090
1091
  _iterator16.f();
1091
1092
  }
1092
- var giftCount = 0;
1093
- if (isFulfilled) {
1094
- giftCount = cumulative ? Math.floor(totalPromoQty / buyQuantity) * freeQuantity : freeQuantity;
1095
- }
1093
+ var groupCount = isFulfilled ? cumulative ? Math.floor(totalPromoQty / buyQuantity) : 1 : 0;
1094
+ var giftQuotas = fixedGiftProducts === null || fixedGiftProducts === void 0 ? void 0 : fixedGiftProducts.map(function (gift) {
1095
+ return _objectSpread(_objectSpread({}, gift), {}, {
1096
+ quantity: gift.quantity * groupCount
1097
+ });
1098
+ });
1099
+ var giftCount = giftQuotas ? giftQuotas.reduce(function (total, gift) {
1100
+ return total + gift.quantity;
1101
+ }, 0) : groupCount * freeQuantity;
1096
1102
 
1097
1103
  // 5. 构建赠品信息
1098
- var giftInfo = giftCount > 0 ? {
1104
+ var giftInfo = giftCount > 0 ? _objectSpread({
1099
1105
  strategyId: strategyId,
1100
1106
  strategyName: strategyName,
1101
1107
  giftCount: giftCount,
1102
- giftOptions: giftProducts || []
1103
- } : null;
1108
+ giftOptions: fixedGiftProducts ? fixedGiftProducts.map(function (_ref) {
1109
+ var product_id = _ref.product_id,
1110
+ product_variant_id = _ref.product_variant_id;
1111
+ return {
1112
+ product_id: product_id,
1113
+ product_variant_id: product_variant_id
1114
+ };
1115
+ }) : giftProducts || []
1116
+ }, giftQuotas && {
1117
+ giftQuotas: giftQuotas
1118
+ }) : null;
1104
1119
  return {
1105
1120
  products: result,
1106
1121
  originalAmount: originalAmount.toNumber(),
@@ -50,8 +50,8 @@ export interface XItemsForYPriceConfig {
50
50
  export interface BuyXGetYFreeValue {
51
51
  /** 买X件 */
52
52
  buyQuantity: number;
53
- /** 送Y件 */
54
- freeQuantity: number;
53
+ /** 任选赠品的总件数 */
54
+ freeQuantity?: number;
55
55
  }
56
56
  /**
57
57
  * 赠品选择模式
@@ -67,6 +67,8 @@ export interface BuyXGetYFreeConfig {
67
67
  cumulative?: boolean;
68
68
  /** 可选的赠品列表 */
69
69
  giftProducts?: ProductIdentifier[];
70
+ /** 每满足一组购买门槛,各款应赠的份数 */
71
+ fixedGiftProducts?: FixedGiftProduct[];
70
72
  }
71
73
  /**
72
74
  * 商品奖励优惠方式
@@ -138,6 +140,9 @@ export interface ProductIdentifier {
138
140
  */
139
141
  product_variant_id: number;
140
142
  }
143
+ export interface FixedGiftProduct extends ProductIdentifier {
144
+ quantity: number;
145
+ }
141
146
  import { ActionEffect } from '../../type';
142
147
  /**
143
148
  * X件Y元 Action
@@ -291,6 +296,7 @@ export interface BuyXGetYFreeActionDetail {
291
296
  cumulative: boolean;
292
297
  /** 可选的赠品列表 */
293
298
  giftProducts: ProductIdentifier[];
299
+ fixedGiftProducts?: FixedGiftProduct[];
294
300
  }
295
301
  /**
296
302
  * 商品奖励 Action 详情
@@ -507,6 +513,8 @@ export interface GiftInfo {
507
513
  giftCount: number;
508
514
  /** 可选赠品列表 */
509
515
  giftOptions: ProductIdentifier[];
516
+ /** 购物车当前可领取的逐款额度 */
517
+ giftQuotas?: FixedGiftProduct[];
510
518
  }
511
519
  /**
512
520
  * 带定价的购物车评估结果
@@ -644,7 +644,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
644
644
  generateIdempotencyToken(): string;
645
645
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
646
646
  createOrder(params: CommitOrderParams['query']): {
647
- type: "appointment_booking" | "virtual";
647
+ type: "virtual" | "appointment_booking";
648
648
  platform: string;
649
649
  sales_channel: string;
650
650
  order_sales_channel: string;