@pisell/pisellos 2.2.309 → 2.2.311

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 (122) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  2. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
  3. package/dist/model/strategy/adapter/walletPass/evaluator.js +4 -2
  4. package/dist/modules/BookingContext/index.js +4 -4
  5. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +58 -19
  6. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +24 -12
  7. package/dist/modules/Customer/index.js +6 -3
  8. package/dist/modules/Customer/types.d.ts +2 -0
  9. package/dist/modules/Discount/availability.d.ts +7 -0
  10. package/dist/modules/Discount/availability.js +49 -0
  11. package/dist/modules/Discount/entitlementPass.d.ts +34 -0
  12. package/dist/modules/Discount/entitlementPass.js +147 -0
  13. package/dist/modules/Discount/index.d.ts +2 -2
  14. package/dist/modules/Discount/index.js +37 -151
  15. package/dist/modules/Discount/types.d.ts +36 -5
  16. package/dist/modules/OpenData/index.d.ts +1 -1
  17. package/dist/modules/OpenData/index.js +21 -12
  18. package/dist/modules/Order/index.d.ts +32 -4
  19. package/dist/modules/Order/index.js +733 -373
  20. package/dist/modules/Order/types.d.ts +17 -0
  21. package/dist/modules/Order/utils/orderCollectionIdentity.js +16 -12
  22. package/dist/modules/Order/utils.d.ts +19 -5
  23. package/dist/modules/Order/utils.js +306 -86
  24. package/dist/modules/Payment/index.d.ts +0 -5
  25. package/dist/modules/Payment/index.js +35 -85
  26. package/dist/modules/Payment/types.d.ts +21 -1
  27. package/dist/modules/Payment/types.js +2 -0
  28. package/dist/modules/Payment/walletpass.d.ts +1 -1
  29. package/dist/modules/Payment/walletpass.js +80 -47
  30. package/dist/modules/ProductList/index.js +18 -5
  31. package/dist/modules/Rules/index.d.ts +2 -2
  32. package/dist/modules/Rules/index.js +480 -186
  33. package/dist/modules/Rules/types.d.ts +4 -0
  34. package/dist/server/index.js +8 -5
  35. package/dist/server/modules/floor-plan/index.js +34 -3
  36. package/dist/server/modules/order/index.js +6 -0
  37. package/dist/server/modules/order/types.d.ts +12 -0
  38. package/dist/server/modules/payment/index.d.ts +25 -6
  39. package/dist/server/modules/payment/index.js +660 -133
  40. package/dist/server/utils/small-ticket.d.ts +8 -5
  41. package/dist/server/utils/small-ticket.js +1269 -199
  42. package/dist/solution/BaseSales/index.d.ts +11 -2
  43. package/dist/solution/BaseSales/index.js +1463 -1173
  44. package/dist/solution/BaseSales/types.d.ts +7 -3
  45. package/dist/solution/BaseSales/utils/cartPromotion.js +141 -126
  46. package/dist/solution/BookingTicket/index.d.ts +11 -2
  47. package/dist/solution/BookingTicket/index.js +663 -542
  48. package/dist/solution/BookingTicket/types.d.ts +5 -1
  49. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +2 -0
  50. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +338 -147
  51. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +8 -4
  52. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +6 -0
  53. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +19 -6
  54. package/dist/solution/ShopDiscount/index.d.ts +2 -0
  55. package/dist/solution/ShopDiscount/index.js +99 -42
  56. package/dist/solution/ShopDiscount/utils.d.ts +4 -2
  57. package/dist/solution/ShopDiscount/utils.js +43 -23
  58. package/dist/solution/UnifiedBookingSales/index.d.ts +2 -2
  59. package/dist/solution/UnifiedBookingSales/index.js +5 -5
  60. package/dist/utils/os-private-payload.d.ts +5 -0
  61. package/dist/utils/os-private-payload.js +17 -0
  62. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
  63. package/lib/model/strategy/adapter/walletPass/evaluator.js +2 -0
  64. package/lib/modules/BookingContext/index.js +3 -3
  65. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +35 -6
  66. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +13 -6
  67. package/lib/modules/Customer/index.js +5 -1
  68. package/lib/modules/Customer/types.d.ts +2 -0
  69. package/lib/modules/Discount/availability.d.ts +7 -0
  70. package/lib/modules/Discount/availability.js +43 -0
  71. package/lib/modules/Discount/entitlementPass.d.ts +34 -0
  72. package/lib/modules/Discount/entitlementPass.js +141 -0
  73. package/lib/modules/Discount/index.d.ts +2 -2
  74. package/lib/modules/Discount/index.js +23 -129
  75. package/lib/modules/Discount/types.d.ts +36 -5
  76. package/lib/modules/OpenData/index.d.ts +1 -1
  77. package/lib/modules/OpenData/index.js +11 -2
  78. package/lib/modules/Order/index.d.ts +32 -4
  79. package/lib/modules/Order/index.js +341 -71
  80. package/lib/modules/Order/types.d.ts +17 -0
  81. package/lib/modules/Order/utils/orderCollectionIdentity.js +14 -11
  82. package/lib/modules/Order/utils.d.ts +19 -5
  83. package/lib/modules/Order/utils.js +215 -13
  84. package/lib/modules/Payment/index.d.ts +0 -5
  85. package/lib/modules/Payment/index.js +3 -28
  86. package/lib/modules/Payment/types.d.ts +21 -1
  87. package/lib/modules/Payment/types.js +1 -0
  88. package/lib/modules/Payment/walletpass.d.ts +1 -1
  89. package/lib/modules/Payment/walletpass.js +29 -9
  90. package/lib/modules/ProductList/index.js +14 -1
  91. package/lib/modules/Rules/index.d.ts +2 -2
  92. package/lib/modules/Rules/index.js +357 -110
  93. package/lib/modules/Rules/types.d.ts +4 -0
  94. package/lib/server/index.js +8 -5
  95. package/lib/server/modules/floor-plan/index.js +29 -1
  96. package/lib/server/modules/order/index.js +6 -0
  97. package/lib/server/modules/order/types.d.ts +12 -0
  98. package/lib/server/modules/payment/index.d.ts +25 -6
  99. package/lib/server/modules/payment/index.js +350 -78
  100. package/lib/server/utils/small-ticket.d.ts +8 -5
  101. package/lib/server/utils/small-ticket.js +1009 -121
  102. package/lib/solution/BaseSales/index.d.ts +11 -2
  103. package/lib/solution/BaseSales/index.js +164 -30
  104. package/lib/solution/BaseSales/types.d.ts +7 -3
  105. package/lib/solution/BaseSales/utils/cartPromotion.js +12 -4
  106. package/lib/solution/BookingTicket/index.d.ts +11 -2
  107. package/lib/solution/BookingTicket/index.js +103 -41
  108. package/lib/solution/BookingTicket/types.d.ts +5 -1
  109. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +2 -0
  110. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +174 -42
  111. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +8 -4
  112. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +6 -0
  113. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +11 -3
  114. package/lib/solution/ShopDiscount/index.d.ts +2 -0
  115. package/lib/solution/ShopDiscount/index.js +55 -9
  116. package/lib/solution/ShopDiscount/utils.d.ts +4 -2
  117. package/lib/solution/ShopDiscount/utils.js +42 -25
  118. package/lib/solution/UnifiedBookingSales/index.d.ts +2 -2
  119. package/lib/solution/UnifiedBookingSales/index.js +5 -5
  120. package/lib/utils/os-private-payload.d.ts +5 -0
  121. package/lib/utils/os-private-payload.js +22 -0
  122. package/package.json +1 -1
@@ -29,6 +29,7 @@ import { uniqueById } from "../../solution/ShopDiscount/utils";
29
29
  import { BaseModule } from "../BaseModule";
30
30
  import { DiscountHooks } from "./types";
31
31
  import Decimal from 'decimal.js';
32
+ import { getDiscountLifecycleReason, getDiscountUsageBlockReason, getDiscountUsageLimitFailKey, hasAvailableDiscountBalance } from "./availability";
32
33
  export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
33
34
  _inherits(DiscountModule, _BaseModule);
34
35
  var _super = _createSuper(DiscountModule);
@@ -165,8 +166,8 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
165
166
  key: "loadPrepareConfig",
166
167
  value: function () {
167
168
  var _loadPrepareConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
168
- var _params$with_availabl, _params$with_availabl2, _params$with_virtual_, _prepareConfig$data, _prepareConfig$data2, _prepareConfig$data3, _prepareConfig$data4, _prepareConfig$data5, _prepareConfig$data6;
169
- var prepareConfig, rawDiscountList, availableWalletList, availableWalletPassList, availableWalletIds, virtualCurrencyList, goodPassList;
169
+ var _params$with_availabl, _params$with_availabl2, _params$with_virtual_, _prepareConfig$data, _prepareConfig$data2, _prepareConfig$data3, _prepareConfig$data4, _prepareConfig$data5, _prepareConfig$data6, _prepareConfig$data7;
170
+ var prepareConfig, entitlementPassList, entitlementPassIds, excludeEntitlementDuplicates, rawDiscountList, availableWalletList, availableWalletPassList, availableWalletIds, virtualCurrencyList, goodPassList;
170
171
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
171
172
  while (1) switch (_context4.prev = _context4.next) {
172
173
  case 0:
@@ -181,15 +182,27 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
181
182
  }));
182
183
  case 3:
183
184
  prepareConfig = _context4.sent;
184
- rawDiscountList = [].concat(_toConsumableArray((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data = prepareConfig.data) === null || _prepareConfig$data === void 0 ? void 0 : _prepareConfig$data.good_pass_list) || []), _toConsumableArray((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data2 = prepareConfig.data) === null || _prepareConfig$data2 === void 0 ? void 0 : _prepareConfig$data2.discount_card_list) || []));
185
- availableWalletList = [].concat(_toConsumableArray((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data3 = prepareConfig.data) === null || _prepareConfig$data3 === void 0 ? void 0 : _prepareConfig$data3.avaiable_wallet_list) || []), _toConsumableArray((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data4 = prepareConfig.data) === null || _prepareConfig$data4 === void 0 ? void 0 : _prepareConfig$data4.available_wallet_list) || []));
186
- availableWalletPassList = (prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data5 = prepareConfig.data) === null || _prepareConfig$data5 === void 0 ? void 0 : _prepareConfig$data5.available_wallet_pass_list) || [];
185
+ entitlementPassList = (prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data = prepareConfig.data) === null || _prepareConfig$data === void 0 ? void 0 : _prepareConfig$data.entitlement_pass_list) || [];
186
+ entitlementPassIds = new Set(entitlementPassList.map(function (discount) {
187
+ return discount === null || discount === void 0 ? void 0 : discount.id;
188
+ }).filter(function (id) {
189
+ return id !== undefined && id !== null;
190
+ }).map(function (id) {
191
+ return String(id);
192
+ }));
193
+ excludeEntitlementDuplicates = function excludeEntitlementDuplicates(discount) {
194
+ var id = discount === null || discount === void 0 ? void 0 : discount.id;
195
+ return id === undefined || id === null || !entitlementPassIds.has(String(id));
196
+ };
197
+ rawDiscountList = [].concat(_toConsumableArray(entitlementPassList), _toConsumableArray(((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data2 = prepareConfig.data) === null || _prepareConfig$data2 === void 0 ? void 0 : _prepareConfig$data2.good_pass_list) || []).filter(excludeEntitlementDuplicates)), _toConsumableArray(((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data3 = prepareConfig.data) === null || _prepareConfig$data3 === void 0 ? void 0 : _prepareConfig$data3.discount_card_list) || []).filter(excludeEntitlementDuplicates)));
198
+ availableWalletList = [].concat(_toConsumableArray((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data4 = prepareConfig.data) === null || _prepareConfig$data4 === void 0 ? void 0 : _prepareConfig$data4.avaiable_wallet_list) || []), _toConsumableArray((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data5 = prepareConfig.data) === null || _prepareConfig$data5 === void 0 ? void 0 : _prepareConfig$data5.available_wallet_list) || []));
199
+ availableWalletPassList = (prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data6 = prepareConfig.data) === null || _prepareConfig$data6 === void 0 ? void 0 : _prepareConfig$data6.available_wallet_pass_list) || [];
187
200
  availableWalletIds = this.normalizePositiveNumberIds([].concat(_toConsumableArray(availableWalletList.map(function (item) {
188
201
  return item === null || item === void 0 ? void 0 : item.wallet_id;
189
202
  })), _toConsumableArray(availableWalletPassList.map(function (item) {
190
203
  return item === null || item === void 0 ? void 0 : item.product_id;
191
204
  }))));
192
- virtualCurrencyList = this.normalizeVirtualCurrencyList(prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data6 = prepareConfig.data) === null || _prepareConfig$data6 === void 0 ? void 0 : _prepareConfig$data6.virtual_currency_list);
205
+ virtualCurrencyList = this.normalizeVirtualCurrencyList(prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data7 = prepareConfig.data) === null || _prepareConfig$data7 === void 0 ? void 0 : _prepareConfig$data7.virtual_currency_list);
193
206
  goodPassList = this.filterEnabledDiscountList(rawDiscountList) || []; // this.setDiscountList(goodPassList);
194
207
  return _context4.abrupt("return", {
195
208
  discountList: goodPassList,
@@ -199,7 +212,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
199
212
  return _objectSpread({}, item || {});
200
213
  })
201
214
  });
202
- case 11:
215
+ case 14:
203
216
  case "end":
204
217
  return _context4.stop();
205
218
  }
@@ -253,7 +266,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
253
266
  return this.request.get("/machinecode/batch-search", _objectSpread(_objectSpread({
254
267
  code: code,
255
268
  translate_flag: 1,
256
- tags: ['good_pass', 'product_discount_card'],
269
+ tags: ['entitlement_pass', 'good_pass', 'product_discount_card'],
257
270
  // available: 1,
258
271
  relation_product: 1,
259
272
  with: ['extensionData', 'customScheduleSnapshot', 'holder.detail'],
@@ -292,8 +305,11 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
292
305
  return this.request.get("/machinecode/batch-search", {
293
306
  ids: productIds,
294
307
  translate_flag: 1,
295
- tags: ['good_pass', 'product_discount_card'],
296
- relation_product: 1
308
+ tags: ['entitlement_pass', 'good_pass', 'product_discount_card'],
309
+ relation_product: 1,
310
+ with: ['extensionData', 'customScheduleSnapshot', 'holder.detail'],
311
+ unified_status_info_flag: 1,
312
+ request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
297
313
  });
298
314
  case 2:
299
315
  result = _context6.sent;
@@ -308,160 +324,30 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
308
324
  return _batchSearchByProductIds.apply(this, arguments);
309
325
  }
310
326
  return batchSearchByProductIds;
311
- }()
327
+ }() // 展示列表只剔除已失效项,当前不可用项保留并携带原因。
312
328
  }, {
313
329
  key: "filterEnabledDiscountList",
314
330
  value: function filterEnabledDiscountList(discountList) {
315
- var _this2 = this;
316
331
  return discountList.filter(function (discount) {
317
- return discount.limit_status === 'enable' && new Decimal((discount === null || discount === void 0 ? void 0 : discount.par_value) || 0).minus(new Decimal((discount === null || discount === void 0 ? void 0 : discount.used_par_value) || 0)).greaterThan(0) && _this2.checkUsageCreditsLimit(discount);
332
+ return discount.limit_status === 'enable' && hasAvailableDiscountBalance(discount) && !getDiscountLifecycleReason(discount);
333
+ }).map(function (discount) {
334
+ return _objectSpread(_objectSpread({}, discount), {}, {
335
+ usageLimitFailKey: getDiscountUsageLimitFailKey(discount),
336
+ reasonCode: getDiscountUsageBlockReason(discount)
337
+ });
318
338
  });
319
339
  }
320
-
321
- // 检查使用次数限制
322
- }, {
323
- key: "checkUsageCreditsLimit",
324
- value: function checkUsageCreditsLimit(discount) {
325
- // 如果没有 extension_data,则不需要限制
326
- if (!discount.extension_data || discount.extension_data.length === 0) {
327
- return true;
328
- }
329
-
330
- // 查找 field_key 为 usage_credits 的数据
331
- var usageCreditsData = discount.extension_data.find(function (data) {
332
- return data.field_key === 'usage_credits';
333
- });
334
-
335
- // 如果没有找到 usage_credits 数据,则不需要限制
336
- if (!usageCreditsData) {
337
- return true;
338
- }
339
- var value = usageCreditsData.value;
340
-
341
- // 检查总次数限制
342
- if (value.total_credits && value.total_credits > 0) {
343
- if ((discount.total_order_behavior_count || 0) >= value.total_credits) {
344
- return false;
345
- }
346
- }
347
-
348
- // 检查单用户限制
349
- if (value.per_user_limit && value.per_user_limit > 0) {
350
- if ((discount.customer_order_behavior_count || 0) >= value.per_user_limit) {
351
- return false;
352
- }
353
- }
354
-
355
- // 检查单日限制
356
- if (value.max_per_day && value.max_per_day > 0) {
357
- if ((discount.today_order_behavior_count || 0) >= value.max_per_day) {
358
- return false;
359
- }
360
- }
361
-
362
- // 检查单周限制
363
- if (value.max_per_week && value.max_per_week > 0) {
364
- if ((discount.week_order_behavior_count || 0) >= value.max_per_week) {
365
- return false;
366
- }
367
- }
368
-
369
- // 检查单月限制
370
- if (value.max_per_month && value.max_per_month > 0) {
371
- if ((discount.month_order_behavior_count || 0) >= value.max_per_month) {
372
- return false;
373
- }
374
- }
375
-
376
- // 所有检查都通过
377
- return true;
378
- }
379
-
380
- // 过滤启用且可用的优惠券,并返回校验失败原因
381
340
  }, {
382
341
  key: "filterEnabledDiscountListWithReason",
383
342
  value: function filterEnabledDiscountListWithReason(discountList) {
384
- var _this3 = this;
385
- var lists = discountList.filter(function (discount) {
386
- return discount.limit_status === 'enable';
387
- }).filter(function (discount) {
388
- var remaining = new Decimal((discount === null || discount === void 0 ? void 0 : discount.par_value) || 0).minus(new Decimal((discount === null || discount === void 0 ? void 0 : discount.used_par_value) || 0)).greaterThan(0);
389
- return remaining;
390
- }).map(function (discount) {
391
- var limitFailKey = _this3.checkUsageCreditsLimitWithFailKey(discount);
392
- return _objectSpread(_objectSpread({}, discount), {}, {
393
- usageLimitFailKey: limitFailKey
394
- });
395
- });
396
-
397
- // 可用的列表
398
- var availableLists = lists.filter(function (item) {
399
- return !item.usageLimitFailKey && item.unified_available_status !== 0;
400
- });
401
- // 不可用数据
402
- var currentFailDiscount = lists.find(function (item) {
403
- return item.usageLimitFailKey;
404
- });
405
343
  return {
406
- discountList: availableLists,
407
- unavailableReasonKey: currentFailDiscount === null || currentFailDiscount === void 0 ? void 0 : currentFailDiscount.usageLimitFailKey
344
+ discountList: this.filterEnabledDiscountList(discountList),
345
+ unavailableReasonKey: discountList.map(getDiscountUsageLimitFailKey).find(function (key) {
346
+ return key !== null;
347
+ }) || null
408
348
  };
409
349
  }
410
350
 
411
- // 检查使用次数限制,并返回校验失败原因
412
- }, {
413
- key: "checkUsageCreditsLimitWithFailKey",
414
- value: function checkUsageCreditsLimitWithFailKey(discount) {
415
- if (!discount.extension_data || discount.extension_data.length === 0) {
416
- return null;
417
- }
418
- var usageCreditsData = discount.extension_data.find(function (data) {
419
- return data.field_key === 'usage_credits';
420
- });
421
- if (!usageCreditsData) {
422
- return null;
423
- }
424
- var value = usageCreditsData.value;
425
-
426
- // 总次数限制
427
- if (value.total_credits && value.total_credits > 0) {
428
- if ((discount.total_order_behavior_count || 0) >= value.total_credits) {
429
- return 'total_credits';
430
- }
431
- }
432
-
433
- // 单用户限制
434
- if (value.per_user_limit && value.per_user_limit > 0) {
435
- if ((discount.customer_order_behavior_count || 0) >= value.per_user_limit) {
436
- return 'per_user_limit';
437
- }
438
- }
439
-
440
- // 单日限制
441
- if (value.max_per_day && value.max_per_day > 0) {
442
- if ((discount.today_order_behavior_count || 0) >= value.max_per_day) {
443
- return 'max_per_day';
444
- }
445
- }
446
-
447
- // 单周限制
448
- if (value.max_per_week && value.max_per_week > 0) {
449
- if ((discount.week_order_behavior_count || 0) >= value.max_per_week) {
450
- return 'max_per_week';
451
- }
452
- }
453
-
454
- // 单月限制
455
- if (value.max_per_month && value.max_per_month > 0) {
456
- if ((discount.month_order_behavior_count || 0) >= value.max_per_month) {
457
- return 'max_per_month';
458
- }
459
- }
460
-
461
- // 全部通过
462
- return null;
463
- }
464
-
465
351
  // 根据productIds去重
466
352
  }, {
467
353
  key: "uniqueByProductId",
@@ -44,7 +44,10 @@ interface ApplicableProductDetails {
44
44
  original_amount: string;
45
45
  num: number;
46
46
  metadata?: {
47
+ encoded?: string;
47
48
  product_discount_difference?: number;
49
+ /** 月卡扣除本单新增使用后的剩余次数;不限次数时为 null。 */
50
+ balance?: number | null;
48
51
  };
49
52
  discount?: {
50
53
  fixed_amount?: number;
@@ -63,6 +66,13 @@ interface UsageCreditsValue {
63
66
  max_per_week: number;
64
67
  max_per_month: number;
65
68
  }
69
+ export type IncludedUses = {
70
+ type: 'limited';
71
+ value: number;
72
+ } | {
73
+ type: 'unlimited';
74
+ value: null;
75
+ };
66
76
  export type DiscountFilterRejectKey = 'total_credits' | 'per_user_limit' | 'max_per_day' | 'max_per_week' | 'max_per_month';
67
77
  export interface DiscountWithReason {
68
78
  discountList: Discount[];
@@ -107,30 +117,37 @@ interface ExtensionData {
107
117
  }
108
118
  export interface Discount {
109
119
  id: number;
120
+ shop_id?: number;
110
121
  product_name: string;
111
122
  encoded: string;
112
123
  code: string;
113
124
  tag: string;
114
- expire_time?: string;
125
+ expire_time?: string | null;
126
+ expire_date?: string | null;
127
+ end_time?: string | null;
115
128
  product_id: number;
116
129
  relation_type: string;
117
130
  par_value: string;
118
131
  used_par_value: string;
119
132
  limit_status: string;
120
133
  limited_relation_product_data: Limitedrelationproductdata;
121
- balance: string;
134
+ balance?: string | number | null;
135
+ available_num?: number;
136
+ available_products_info?: any[];
122
137
  format_title: Formattitle;
123
138
  metadata?: {
139
+ encoded?: string;
124
140
  discount_card_type?: 'fixed_amount' | 'percent';
125
141
  custom_product_bundle_map_id?: string;
126
142
  validity_type?: "custom_schedule_validity" | "fixed_validity";
127
- discount_calculation_mode: 'item_level' | 'order_level';
128
- holder: {
143
+ included_uses?: IncludedUses;
144
+ discount_calculation_mode?: 'item_level' | 'order_level';
145
+ holder?: {
129
146
  type: "customer" | "custom";
130
147
  };
131
148
  };
132
149
  product: Product;
133
- type: "product" | 'good_pass';
150
+ type?: "product" | 'good_pass' | 'entitlement_pass' | 'discount_card' | 'product_discount_card';
134
151
  resource_id?: number;
135
152
  savedAmount?: number;
136
153
  isEditMode?: boolean;
@@ -163,9 +180,17 @@ export interface Discount {
163
180
  applicableProductIds?: number[];
164
181
  applicableProductDetails: ApplicableProductDetails[];
165
182
  appliedProductDetails: ApplicableProductDetails[];
183
+ /** Entitlement Pass 编辑订单时已经提交的使用明细。 */
184
+ committedAppliedProductDetails?: ApplicableProductDetails[];
166
185
  isDisabledForProductUsed?: boolean;
167
186
  amount?: number;
168
187
  customer_id?: number | string | null;
188
+ holder?: {
189
+ holder_type?: 'customer' | 'form' | string;
190
+ holder_id?: number | string | Array<number | string>;
191
+ created_at?: string | null;
192
+ [key: string]: any;
193
+ };
169
194
  extension_data?: ExtensionData[];
170
195
  total_order_behavior_count?: number;
171
196
  today_order_behavior_count?: number;
@@ -180,6 +205,12 @@ export interface Discount {
180
205
  start_time?: string;
181
206
  discount_rule_uncheck_flag?: boolean;
182
207
  usageLimitFailKey?: string | null;
208
+ /** 本次规则计算的不可用原因;可用性恢复后清除。 */
209
+ reason?: string;
210
+ reasonCode?: string;
211
+ unified_messages?: {
212
+ title?: string | Record<string, string>;
213
+ };
183
214
  unified_available_status?: number | undefined | null;
184
215
  }
185
216
  export interface DiscountState {
@@ -33,7 +33,7 @@ export declare class OpenDataModule extends BaseModule implements Module {
33
33
  getOpenData(): OpenDataConfig | null;
34
34
  getInvoiceLayoutConfig(): InvoiceLayoutConfig;
35
35
  getInvoiceTemplateSettings(): InvoiceTemplateSettings;
36
- ensureInvoiceTemplateSettings(target: string): Promise<InvoiceTemplateSettings>;
36
+ ensureInvoiceTemplateSettings(target: string, openDataConfig?: OpenDataConfig): Promise<InvoiceTemplateSettings>;
37
37
  private commitInvoiceTemplateSettings;
38
38
  private resolveInvoiceTemplateSettings;
39
39
  private buildInvoiceTemplateCacheKey;
@@ -132,7 +132,8 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
132
132
  key: "shouldSkipInvoiceTemplateDocument",
133
133
  value: function shouldSkipInvoiceTemplateDocument() {
134
134
  var _this$otherParams;
135
- return String(((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.platform) || '').trim().toLowerCase() === 'h5';
135
+ var platform = String(((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.platform) || '').trim().toLowerCase();
136
+ return platform === 'pc' || platform === 'h5';
136
137
  }
137
138
  }, {
138
139
  key: "fetchOpenData",
@@ -233,39 +234,47 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
233
234
  }, {
234
235
  key: "ensureInvoiceTemplateSettings",
235
236
  value: function () {
236
- var _ensureInvoiceTemplateSettings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(target) {
237
+ var _ensureInvoiceTemplateSettings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(target, openDataConfig) {
237
238
  var normalizedTarget, config, fetchRevision, resolved;
238
239
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
239
240
  while (1) switch (_context3.prev = _context3.next) {
240
241
  case 0:
241
242
  normalizedTarget = String(target || '').trim();
243
+ if (openDataConfig && openDataConfig !== this.store.data) {
244
+ // 部分解决方案会在初始化参数中直接收到已经拉取完成的 OpenData。
245
+ // 将它纳入模块状态后再解析 Document,避免为了 Invoice 重复请求 setting,
246
+ // 同时让后续同步 getter 能校验同一份 document id 与 target。
247
+ this.fetchRevision += 1;
248
+ this.store.data = openDataConfig;
249
+ this.store.lastFetchedAt = Date.now();
250
+ }
242
251
  config = this.store.data;
243
252
  if (!(!normalizedTarget || !config)) {
244
- _context3.next = 4;
253
+ _context3.next = 5;
245
254
  break;
246
255
  }
247
256
  return _context3.abrupt("return", getDefaultInvoiceTemplateSettings());
248
- case 4:
257
+ case 5:
249
258
  fetchRevision = this.fetchRevision;
250
- _context3.next = 7;
259
+ _context3.next = 8;
251
260
  return this.resolveInvoiceTemplateSettings(config, normalizedTarget);
252
- case 7:
261
+ case 8:
253
262
  resolved = _context3.sent;
254
263
  if (!(fetchRevision !== this.fetchRevision || this.store.data !== config)) {
255
- _context3.next = 10;
264
+ _context3.next = 11;
256
265
  break;
257
266
  }
258
267
  return _context3.abrupt("return", getDefaultInvoiceTemplateSettings());
259
- case 10:
268
+ case 11:
260
269
  this.commitInvoiceTemplateSettings(normalizedTarget, resolved);
261
270
  return _context3.abrupt("return", normalizeRawInvoiceTemplateSettings(resolved.settings));
262
- case 12:
271
+ case 13:
263
272
  case "end":
264
273
  return _context3.stop();
265
274
  }
266
275
  }, _callee3, this);
267
276
  }));
268
- function ensureInvoiceTemplateSettings(_x4) {
277
+ function ensureInvoiceTemplateSettings(_x4, _x5) {
269
278
  return _ensureInvoiceTemplateSettings.apply(this, arguments);
270
279
  }
271
280
  return ensureInvoiceTemplateSettings;
@@ -367,7 +376,7 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
367
376
  }
368
377
  }, _callee4, this);
369
378
  }));
370
- function resolveInvoiceTemplateSettings(_x5, _x6) {
379
+ function resolveInvoiceTemplateSettings(_x6, _x7) {
371
380
  return _resolveInvoiceTemplateSettings.apply(this, arguments);
372
381
  }
373
382
  return resolveInvoiceTemplateSettings;
@@ -424,7 +433,7 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
424
433
  }
425
434
  }, _callee5, this);
426
435
  }));
427
- function fetchInvoiceTemplateDocument(_x7) {
436
+ function fetchInvoiceTemplateDocument(_x8) {
428
437
  return _fetchInvoiceTemplateDocument.apply(this, arguments);
429
438
  }
430
439
  return fetchInvoiceTemplateDocument;
@@ -3,7 +3,7 @@ import { BaseModule } from '../BaseModule';
3
3
  import { OrderModuleAPI, CommitOrderParams, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, CancelOrderParams, ChangeBookingStatusParams, CheckoutOrderParams } from './types';
4
4
  import { CartItem } from '../Cart/types';
5
5
  import { type SubmitPayloadEnhancer } from './utils';
6
- import type { OrderAmountSnapshot, AddProductBookingInput, AddProductToOrderOptions, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, ReplaceTempOrderOptions, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions, RemoveProductsFromOrderOptions, SalesNote, SalesNotesMutationSnapshot, SetSalesNoteInput, PickupReferenceMode, ShopServiceData, ShopServiceType } from './types';
6
+ import type { OrderAmountSnapshot, AddProductBookingInput, AddProductToOrderOptions, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, ReplaceTempOrderOptions, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions, RemoveProductsFromOrderOptions, SalesNote, SalesNotesMutationSnapshot, SetSalesNoteInput, PickupReferenceMode, PointCardSnapshotMergeContext, PointCardSnapshotItem, ShopServiceData, ShopServiceType } from './types';
7
7
  import type { ICustomer } from '../AccountList/types';
8
8
  import type { Discount } from '../Discount/types';
9
9
  import { UnavailableReason } from '../Rules/types';
@@ -20,6 +20,10 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
20
20
  private openCache;
21
21
  private sessionStoragePersistEnabled;
22
22
  private sessionStorageRestoreRecord;
23
+ /** 只允许当前订单最新的 prepare/config 请求回写客户资产态。 */
24
+ private customerWalletPrepareConfigEpoch;
25
+ /** Payment 可能早于 prepare/config 返回;先按实例 ID 暂存卡号等待 Snapshot。 */
26
+ private pointCardSnapshotCodeCandidates;
23
27
  private salesSummaryModuleName;
24
28
  private rulesHooksOverride?;
25
29
  private moduleHooksOverride?;
@@ -78,6 +82,11 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
78
82
  private logError;
79
83
  private registerDiscountModules;
80
84
  private createDefaultRulesHooks;
85
+ /**
86
+ * Stable across notifyTempOrderChanged's immutable copy, but changes when a
87
+ * different local/server order becomes current.
88
+ */
89
+ private getDiscountConfigOrderIdentityKey;
81
90
  loadDiscountConfig(params: {
82
91
  customerId: number;
83
92
  action?: 'create' | 'edit';
@@ -87,6 +96,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
87
96
  getDiscountList(): Discount[];
88
97
  getAvailableWalletIds(): number[];
89
98
  getVirtualCurrencyList(): import("../Discount/types").VirtualCurrencyAsset[];
99
+ getCustomerWalletPrepareConfigEpoch(): number;
90
100
  private syncScannedDiscountsToOriginalDiscountList;
91
101
  private ensureEditDiscountConfigForProductChange;
92
102
  scanCode(code: string, customerId?: number): Promise<{
@@ -101,6 +111,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
101
111
  applyDiscount(options?: {
102
112
  reapplyBookingDiscountProductUids?: string[];
103
113
  reapplyWeighedDiscountProductUids?: string[];
114
+ preferredEntitlementPassIds?: number[];
104
115
  }): void;
105
116
  /**
106
117
  * 注入促销评估器。
@@ -177,8 +188,19 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
177
188
  consumeSessionStorageRestore(): Record<string, any> | null;
178
189
  notifyTempOrderChanged(): void;
179
190
  private createDefaultTempOrderInstance;
180
- private clearTempOrderPointCardSnapshot;
181
- private writePointCardSnapshotFromPrepareConfig;
191
+ private clearTempOrderCustomerWalletSnapshots;
192
+ private clearCustomerWalletState;
193
+ private clearCustomerWalletRuntimeState;
194
+ private rememberPointCardSnapshotCodeCandidates;
195
+ private getRememberedPointCardSnapshotCodeCandidates;
196
+ private getPointCardSnapshotOrderIdentityKey;
197
+ private isPointCardSnapshotMergeContextCurrent;
198
+ private writeCustomerWalletSnapshotsFromPrepareConfig;
199
+ /**
200
+ * 将 Payment WalletPass 返回的实例 code 回填到当前订单 Snapshot。
201
+ * 这里只按资产 ID 补空值,不新增卡、不覆盖 prepare/config 冻结的余额。
202
+ */
203
+ mergePointCardSnapshotCodes(walletPassList: unknown, context?: PointCardSnapshotMergeContext): PointCardSnapshotItem[];
182
204
  private createExternalSaleNumber;
183
205
  private ensureExternalSaleNumber;
184
206
  private ensureRequestUniqueIdempotencyToken;
@@ -468,7 +490,12 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
468
490
  }>, options?: {
469
491
  skipEditDiscountConfigRefresh?: boolean;
470
492
  }): Promise<OrderProduct[]>;
493
+ private getFullCoveragePassDiscounts;
494
+ private hasEntitlementPassDiscount;
471
495
  private hasGoodPassDiscount;
496
+ private isPersistedProductLine;
497
+ private isRuntimeEntitlementAppend;
498
+ private hasSameEntitlementMergePriceConfig;
472
499
  private getBundleRuntimeIdentity;
473
500
  private preservePersistedBundlePriceFields;
474
501
  private applyOrderProductUpdateToTempOrder;
@@ -589,6 +616,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
589
616
  */
590
617
  createOrderByCheckout(params: CheckoutOrderParams): Promise<any>;
591
618
  submitSalesOrder<T = any>(params: SubmitSalesOrderParams): Promise<T>;
619
+ private isSalesCheckoutHandledByOsServer;
592
620
  /**
593
621
  * 发送支付链接邮件。
594
622
  *
@@ -635,4 +663,4 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
635
663
  getOrderInfo(order_id: number): Promise<any>;
636
664
  getVouchers(): any[];
637
665
  }
638
- export type { AddProductToOrderOptions, OrderMetaList, PointCardSnapshotItem, RemoveProductsFromOrderOptions, SalesNote, SalesNoteDraftInput, SalesNoteLocalizedSelection, SalesNoteLocalizedText, SalesNoteRelation, SalesNoteTextInput, SetSalesNoteInput, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, } from './types';
666
+ export type { AddProductToOrderOptions, OrderMetaList, PointCardSnapshotItem, VirtualCurrencySnapshotItem, RemoveProductsFromOrderOptions, SalesNote, SalesNoteDraftInput, SalesNoteLocalizedSelection, SalesNoteLocalizedText, SalesNoteRelation, SalesNoteTextInput, SetSalesNoteInput, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, } from './types';