@pisell/pisellos 0.0.559 → 0.0.561

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 (41) hide show
  1. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +1 -0
  2. package/dist/model/strategy/adapter/dataVariant/adapter.js +15 -0
  3. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +2 -0
  4. package/dist/model/strategy/adapter/dataVariant/evaluator.js +25 -0
  5. package/dist/model/strategy/adapter/dataVariant/type.d.ts +2 -0
  6. package/dist/modules/Discount/index.d.ts +5 -2
  7. package/dist/modules/Discount/index.js +21 -1
  8. package/dist/modules/Discount/types.d.ts +4 -0
  9. package/dist/modules/Order/index.d.ts +1 -0
  10. package/dist/modules/Order/index.js +16 -4
  11. package/dist/modules/Order/types.d.ts +2 -0
  12. package/dist/modules/ProductList/index.js +18 -10
  13. package/dist/modules/Rules/index.js +10 -1
  14. package/dist/modules/Schedule/getDateIsInSchedule.js +5 -0
  15. package/dist/modules/Summary/utils.js +42 -21
  16. package/dist/solution/ShopDiscount/index.js +16 -15
  17. package/dist/solution/VenueBooking/index.d.ts +1 -0
  18. package/dist/solution/VenueBooking/index.js +52 -36
  19. package/dist/solution/VenueBooking/utils/smartPricing.d.ts +1 -0
  20. package/dist/solution/VenueBooking/utils/smartPricing.js +6 -6
  21. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +1 -0
  22. package/lib/model/strategy/adapter/dataVariant/adapter.js +10 -0
  23. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +2 -0
  24. package/lib/model/strategy/adapter/dataVariant/evaluator.js +20 -1
  25. package/lib/model/strategy/adapter/dataVariant/type.d.ts +2 -0
  26. package/lib/modules/Discount/index.d.ts +5 -2
  27. package/lib/modules/Discount/index.js +11 -1
  28. package/lib/modules/Discount/types.d.ts +4 -0
  29. package/lib/modules/Order/index.d.ts +1 -0
  30. package/lib/modules/Order/index.js +11 -1
  31. package/lib/modules/Order/types.d.ts +2 -0
  32. package/lib/modules/ProductList/index.js +9 -2
  33. package/lib/modules/Rules/index.js +6 -1
  34. package/lib/modules/Schedule/getDateIsInSchedule.js +4 -0
  35. package/lib/modules/Summary/utils.js +23 -3
  36. package/lib/solution/ShopDiscount/index.js +3 -2
  37. package/lib/solution/VenueBooking/index.d.ts +1 -0
  38. package/lib/solution/VenueBooking/index.js +15 -3
  39. package/lib/solution/VenueBooking/utils/smartPricing.d.ts +1 -0
  40. package/lib/solution/VenueBooking/utils/smartPricing.js +1 -1
  41. package/package.json +1 -1
@@ -501,32 +501,32 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
501
501
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
502
502
  while (1) switch (_context5.prev = _context5.next) {
503
503
  case 0:
504
+ _context5.next = 2;
505
+ return _this3.store.order.loadDiscountConfig({
506
+ customerId: params.customerId
507
+ });
508
+ case 2:
504
509
  _this3.clearSlotPriceMapCache();
505
510
  _this3.recalculateOrderPricesFromSmartPricing();
506
511
  // 刷新 holder 表单数据
507
512
  if (!_this3.store.holder) {
508
- _context5.next = 5;
513
+ _context5.next = 7;
509
514
  break;
510
515
  }
511
- _context5.next = 5;
516
+ _context5.next = 7;
512
517
  return _this3.store.holder.refreshAllFormRecords({
513
518
  customer_id: params.customerId,
514
519
  useCache: false
515
520
  });
516
- case 5:
521
+ case 7:
517
522
  if (!_this3.store.quotation) {
518
- _context5.next = 8;
523
+ _context5.next = 10;
519
524
  break;
520
525
  }
521
- _context5.next = 8;
526
+ _context5.next = 10;
522
527
  return _this3.store.quotation.loadQuotations({
523
528
  channel: (_this3$otherParams = _this3.otherParams) === null || _this3$otherParams === void 0 ? void 0 : _this3$otherParams.channel
524
529
  });
525
- case 8:
526
- _context5.next = 10;
527
- return _this3.store.order.loadDiscountConfig({
528
- customerId: params.customerId
529
- });
530
530
  case 10:
531
531
  _context5.next = 12;
532
532
  return _this3.store.order.recalculateSummary({
@@ -970,6 +970,21 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
970
970
  return undefined;
971
971
  }
972
972
  }
973
+ }, {
974
+ key: "resolveAvailableWalletIdsForSmartPricing",
975
+ value: function resolveAvailableWalletIdsForSmartPricing() {
976
+ var _this$store$order3, _this$store$order3$ge, _this$otherParams9, _this$otherParams10, _this$otherParams11, _this$otherParams12;
977
+ var orderWalletIds = (_this$store$order3 = this.store.order) === null || _this$store$order3 === void 0 || (_this$store$order3$ge = _this$store$order3.getAvailableWalletIds) === null || _this$store$order3$ge === void 0 ? void 0 : _this$store$order3$ge.call(_this$store$order3);
978
+ var fallbackWalletIds = ((_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.available_wallet_ids) || ((_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.availableWalletIds) || ((_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 || (_this$otherParams11 = _this$otherParams11.strategy_context) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.available_wallet_ids) || ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 || (_this$otherParams12 = _this$otherParams12.strategy_context) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.availableWalletIds);
979
+ var source = Array.isArray(orderWalletIds) && orderWalletIds.length ? orderWalletIds : fallbackWalletIds;
980
+ if (!Array.isArray(source)) return [];
981
+ var ids = source.map(function (item) {
982
+ return Number(item);
983
+ }).filter(function (item) {
984
+ return Number.isFinite(item) && item > 0;
985
+ });
986
+ return Array.from(new Set(ids));
987
+ }
973
988
 
974
989
  /** 读取 schedule 全量列表,供智能定价 schedule_match 使用 */
975
990
  }, {
@@ -985,17 +1000,18 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
985
1000
  }, {
986
1001
  key: "buildSmartPricingContext",
987
1002
  value: function buildSmartPricingContext(customerId) {
988
- var _this$core5, _this$otherParams9, _this$otherParams10, _this$otherParams11, _this$otherParams12, _this$otherParams13, _this$otherParams14, _this$otherParams15;
1003
+ var _this$core5, _this$otherParams13, _this$otherParams14, _this$otherParams15, _this$otherParams16, _this$otherParams17, _this$otherParams18, _this$otherParams19;
989
1004
  var evaluator = (_this$core5 = this.core) === null || _this$core5 === void 0 || (_this$core5 = _this$core5.context) === null || _this$core5 === void 0 ? void 0 : _this$core5.dataVariantEvaluator;
990
1005
  return {
991
1006
  evaluator: evaluator,
992
1007
  scheduleList: this.getScheduleListForSmartPricing(),
993
- menuList: ((_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.menuList) || ((_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 || (_this$otherParams10 = _this$otherParams10.openData) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.menuList) || [],
1008
+ menuList: ((_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.menuList) || ((_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 || (_this$otherParams14 = _this$otherParams14.openData) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.menuList) || [],
994
1009
  customerId: customerId !== null && customerId !== void 0 ? customerId : this.resolveCustomerIdForSmartPricing(),
995
- channel: (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.channel,
996
- businessCode: (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.businessCode,
997
- orderType: ((_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.orderType) || ((_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.type),
998
- strategy_context: (_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.strategy_context
1010
+ availableWalletIds: this.resolveAvailableWalletIdsForSmartPricing(),
1011
+ channel: (_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.channel,
1012
+ businessCode: (_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.businessCode,
1013
+ orderType: ((_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.orderType) || ((_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.type),
1014
+ strategy_context: (_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.strategy_context
999
1015
  };
1000
1016
  }
1001
1017
 
@@ -1014,7 +1030,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1014
1030
  key: "getSlotPriceMapCacheKey",
1015
1031
  value: function getSlotPriceMapCacheKey(date, context) {
1016
1032
  var _context$customerId, _context$channel, _context$businessCode;
1017
- return [date, (_context$customerId = context.customerId) !== null && _context$customerId !== void 0 ? _context$customerId : '', (_context$channel = context.channel) !== null && _context$channel !== void 0 ? _context$channel : '', (_context$businessCode = context.businessCode) !== null && _context$businessCode !== void 0 ? _context$businessCode : ''].join('|');
1033
+ return [date, (_context$customerId = context.customerId) !== null && _context$customerId !== void 0 ? _context$customerId : '', (context.availableWalletIds || []).join(','), (_context$channel = context.channel) !== null && _context$channel !== void 0 ? _context$channel : '', (_context$businessCode = context.businessCode) !== null && _context$businessCode !== void 0 ? _context$businessCode : ''].join('|');
1018
1034
  }
1019
1035
 
1020
1036
  /**
@@ -1074,7 +1090,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1074
1090
  key: "_doLoadAllProducts",
1075
1091
  value: function () {
1076
1092
  var _doLoadAllProducts2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
1077
- var _this$otherParams16, _this$store$venueProd, associatedMenus, menuListIds, allProducts, rawList, list, venueList, addonList, venueStore, _this$store$order3, _this$store$order3$ge, products;
1093
+ var _this$otherParams20, _this$store$venueProd, associatedMenus, menuListIds, allProducts, rawList, list, venueList, addonList, venueStore, _this$store$order4, _this$store$order4$ge, products;
1078
1094
  return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1079
1095
  while (1) switch (_context12.prev = _context12.next) {
1080
1096
  case 0:
@@ -1095,7 +1111,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1095
1111
  _context12.next = 8;
1096
1112
  return this.loadOpenDataConfig();
1097
1113
  case 8:
1098
- associatedMenus = ((_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 || (_this$otherParams16 = _this$otherParams16.openData) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16['menu.associated_menus']) || [];
1114
+ associatedMenus = ((_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 || (_this$otherParams20 = _this$otherParams20.openData) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20['menu.associated_menus']) || [];
1099
1115
  if (associatedMenus.length) {
1100
1116
  _context12.next = 12;
1101
1117
  break;
@@ -1141,7 +1157,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1141
1157
  _context12.next = 31;
1142
1158
  break;
1143
1159
  }
1144
- products = ((_this$store$order3 = this.store.order) === null || _this$store$order3 === void 0 || (_this$store$order3$ge = _this$store$order3.getOrderProducts) === null || _this$store$order3$ge === void 0 ? void 0 : _this$store$order3$ge.call(_this$store$order3)) || [];
1160
+ products = ((_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 || (_this$store$order4$ge = _this$store$order4.getOrderProducts) === null || _this$store$order4$ge === void 0 ? void 0 : _this$store$order4$ge.call(_this$store$order4)) || [];
1145
1161
  _context12.next = 31;
1146
1162
  return this.preloadHolderForms(products);
1147
1163
  case 31:
@@ -1605,8 +1621,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1605
1621
  }, {
1606
1622
  key: "getSelectedSlotsForResource",
1607
1623
  value: function getSelectedSlotsForResource(resourceId, productId) {
1608
- var _this$store$order4;
1609
- var tempOrder = (_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 ? void 0 : _this$store$order4.getTempOrder();
1624
+ var _this$store$order5;
1625
+ var tempOrder = (_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 ? void 0 : _this$store$order5.getTempOrder();
1610
1626
  if (!tempOrder) return [];
1611
1627
  var venueProducts = tempOrder.products.filter(function (p) {
1612
1628
  var _p$metadata, _p$metadata2;
@@ -1767,9 +1783,9 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1767
1783
  }, {
1768
1784
  key: "getAllSelectedSlots",
1769
1785
  value: function getAllSelectedSlots() {
1770
- var _this$store$order5;
1786
+ var _this$store$order6;
1771
1787
  var result = new Map();
1772
- var tempOrder = (_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 ? void 0 : _this$store$order5.getTempOrder();
1788
+ var tempOrder = (_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 ? void 0 : _this$store$order6.getTempOrder();
1773
1789
  if (!tempOrder) return result;
1774
1790
  var venueProducts = tempOrder.products.filter(function (p) {
1775
1791
  var _p$metadata3;
@@ -1829,7 +1845,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1829
1845
  key: "reconcileOrderForResourceProduct",
1830
1846
  value: (function () {
1831
1847
  var _reconcileOrderForResourceProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(resourceId, productId, slots) {
1832
- var _this$store$order6, _this$store$order6$ge;
1848
+ var _this$store$order7, _this$store$order7$ge;
1833
1849
  var mappings, mapping, tempOrder, matchesCurrent, merged, rawResource, childRawResources, venueProduct, i, _rawResource$form_id, _venueProduct$is_char, group, identityKey, bookingUuid, startMoment, endMoment, duration, customDepositData, resourceEntry, booking, products;
1834
1850
  return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1835
1851
  while (1) switch (_context18.prev = _context18.next) {
@@ -1997,7 +2013,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1997
2013
  }
1998
2014
 
1999
2015
  // 获取表单信息
2000
- products = ((_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 || (_this$store$order6$ge = _this$store$order6.getOrderProducts) === null || _this$store$order6$ge === void 0 ? void 0 : _this$store$order6$ge.call(_this$store$order6)) || [];
2016
+ products = ((_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 || (_this$store$order7$ge = _this$store$order7.getOrderProducts) === null || _this$store$order7$ge === void 0 ? void 0 : _this$store$order7$ge.call(_this$store$order7)) || [];
2001
2017
  _context18.next = 25;
2002
2018
  return this.preloadHolderForms(products);
2003
2019
  case 25:
@@ -2112,8 +2128,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2112
2128
  }, {
2113
2129
  key: "getTempOrder",
2114
2130
  value: function getTempOrder() {
2115
- var _this$store$order7;
2116
- var result = ((_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 ? void 0 : _this$store$order7.getTempOrder()) || null;
2131
+ var _this$store$order8;
2132
+ var result = ((_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 ? void 0 : _this$store$order8.getTempOrder()) || null;
2117
2133
  return result;
2118
2134
  }
2119
2135
  }, {
@@ -2589,7 +2605,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2589
2605
  key: "submitOrder",
2590
2606
  value: function () {
2591
2607
  var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
2592
- var _this$otherParams17, _this$otherParams18, _this$otherParams19, _this$otherParams20, _tempOrder$products2, result, tempOrder;
2608
+ var _this$otherParams21, _this$otherParams22, _this$otherParams23, _this$otherParams24, _tempOrder$products2, result, tempOrder;
2593
2609
  return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2594
2610
  while (1) switch (_context25.prev = _context25.next) {
2595
2611
  case 0:
@@ -2607,10 +2623,10 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2607
2623
  _context25.next = 8;
2608
2624
  return this.store.order.submitTempOrder({
2609
2625
  cacheId: this.cacheId,
2610
- platform: (_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.platform,
2611
- businessCode: (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.businessCode,
2612
- channel: (_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.channel,
2613
- type: (_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.type
2626
+ platform: (_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.platform,
2627
+ businessCode: (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.businessCode,
2628
+ channel: (_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.channel,
2629
+ type: (_this$otherParams24 = this.otherParams) === null || _this$otherParams24 === void 0 ? void 0 : _this$otherParams24.type
2614
2630
  });
2615
2631
  case 8:
2616
2632
  result = _context25.sent;
@@ -2750,7 +2766,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2750
2766
  key: "removeProductFromOrder",
2751
2767
  value: function () {
2752
2768
  var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(identity) {
2753
- var _this$store$order$get3, _this$store$order8, _this$store$order$ens, _this$store$order9, _tempOrder$bookings, tempOrder, products, _tempOrder$bookings2, _tempOrder$bookings3, venueProductUids, venueBookingUids, _iterator17, _step17, _product$metadata7, _product$metadata8, product, beforeBookingCount, _this$store$order$per, _this$store$order10;
2769
+ var _this$store$order$get3, _this$store$order9, _this$store$order$ens, _this$store$order10, _tempOrder$bookings, tempOrder, products, _tempOrder$bookings2, _tempOrder$bookings3, venueProductUids, venueBookingUids, _iterator17, _step17, _product$metadata7, _product$metadata8, product, beforeBookingCount, _this$store$order$per, _this$store$order11;
2754
2770
  return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2755
2771
  while (1) switch (_context28.prev = _context28.next) {
2756
2772
  case 0:
@@ -2765,7 +2781,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2765
2781
  }
2766
2782
  throw new Error('order 模块未初始化');
2767
2783
  case 4:
2768
- tempOrder = ((_this$store$order$get3 = (_this$store$order8 = this.store.order).getTempOrder) === null || _this$store$order$get3 === void 0 ? void 0 : _this$store$order$get3.call(_this$store$order8)) || ((_this$store$order$ens = (_this$store$order9 = this.store.order).ensureTempOrder) === null || _this$store$order$ens === void 0 ? void 0 : _this$store$order$ens.call(_this$store$order9));
2784
+ tempOrder = ((_this$store$order$get3 = (_this$store$order9 = this.store.order).getTempOrder) === null || _this$store$order$get3 === void 0 ? void 0 : _this$store$order$get3.call(_this$store$order9)) || ((_this$store$order$ens = (_this$store$order10 = this.store.order).ensureTempOrder) === null || _this$store$order$ens === void 0 ? void 0 : _this$store$order$ens.call(_this$store$order10));
2769
2785
  _context28.next = 7;
2770
2786
  return this.store.order.removeProductFromOrder(identity);
2771
2787
  case 7:
@@ -2822,7 +2838,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2822
2838
  return true;
2823
2839
  });
2824
2840
  if ((((_tempOrder$bookings3 = tempOrder.bookings) === null || _tempOrder$bookings3 === void 0 ? void 0 : _tempOrder$bookings3.length) || 0) !== beforeBookingCount) {
2825
- (_this$store$order$per = (_this$store$order10 = this.store.order).persistTempOrder) === null || _this$store$order$per === void 0 || _this$store$order$per.call(_this$store$order10);
2841
+ (_this$store$order$per = (_this$store$order11 = this.store.order).persistTempOrder) === null || _this$store$order$per === void 0 || _this$store$order$per.call(_this$store$order11);
2826
2842
  }
2827
2843
  case 33:
2828
2844
  _context28.next = 35;
@@ -10,6 +10,7 @@ export interface VenueBookingSmartPricingContext {
10
10
  scheduleList?: ScheduleItem[];
11
11
  menuList?: DataVariantMenu[];
12
12
  customerId?: number | string;
13
+ availableWalletIds?: Array<number | string>;
13
14
  channel?: string;
14
15
  businessCode?: string;
15
16
  orderType?: string;
@@ -16,7 +16,7 @@ export function extractProductPrice(product) {
16
16
 
17
17
  /** 组装 DataVariant 评估入参,对齐 OS Server buildProductFormatterContext 语义 */
18
18
  export function buildDataVariantBusinessData(products, context, scheduleDateTime) {
19
- var _context$channel, _ref, _context$orderType, _ref2, _context$businessCode;
19
+ var _ref, _context$availableWal, _context$channel, _ref2, _context$orderType, _ref3, _context$businessCode;
20
20
  var strategyContext = context.strategy_context || {};
21
21
  return {
22
22
  products: products,
@@ -25,9 +25,10 @@ export function buildDataVariantBusinessData(products, context, scheduleDateTime
25
25
  scheduleList: context.scheduleList || [],
26
26
  menuList: context.menuList || [],
27
27
  customerId: context.customerId,
28
+ availableWalletIds: (_ref = (_context$availableWal = context.availableWalletIds) !== null && _context$availableWal !== void 0 ? _context$availableWal : strategyContext.available_wallet_ids) !== null && _ref !== void 0 ? _ref : strategyContext.availableWalletIds,
28
29
  channel: (_context$channel = context.channel) !== null && _context$channel !== void 0 ? _context$channel : strategyContext.channel,
29
- orderType: (_ref = (_context$orderType = context.orderType) !== null && _context$orderType !== void 0 ? _context$orderType : strategyContext.orderType) !== null && _ref !== void 0 ? _ref : strategyContext.order_type,
30
- businessCode: (_ref2 = (_context$businessCode = context.businessCode) !== null && _context$businessCode !== void 0 ? _context$businessCode : strategyContext.business_code) !== null && _ref2 !== void 0 ? _ref2 : strategyContext.businessCode,
30
+ orderType: (_ref2 = (_context$orderType = context.orderType) !== null && _context$orderType !== void 0 ? _context$orderType : strategyContext.orderType) !== null && _ref2 !== void 0 ? _ref2 : strategyContext.order_type,
31
+ businessCode: (_ref3 = (_context$businessCode = context.businessCode) !== null && _context$businessCode !== void 0 ? _context$businessCode : strategyContext.business_code) !== null && _ref3 !== void 0 ? _ref3 : strategyContext.businessCode,
31
32
  custom: strategyContext
32
33
  };
33
34
  }
@@ -44,7 +45,6 @@ export function formatProductsWithDataVariant(products, context, scheduleDateTim
44
45
  }
45
46
  var resolvedAt = scheduleDateTime || dayjs().format('YYYY-MM-DD HH:mm:ss');
46
47
  var businessData = buildDataVariantBusinessData(products, context, resolvedAt);
47
- console.log(businessData, 'businessData');
48
48
  var result = evaluator.resolveProducts(businessData);
49
49
  return Array.isArray(result === null || result === void 0 ? void 0 : result.products) ? result.products : products;
50
50
  }
@@ -207,7 +207,7 @@ export function buildSlotPriceMapByScheduleSegments(params) {
207
207
  * 指定商品在某一 datetime 的智能定价(addon / 单点重算用)。
208
208
  */
209
209
  export function getPriceForProductAtDatetime(params) {
210
- var _ref3, _extractProductPrice;
210
+ var _ref4, _extractProductPrice;
211
211
  var products = params.products,
212
212
  context = params.context,
213
213
  productId = params.productId,
@@ -217,7 +217,7 @@ export function getPriceForProductAtDatetime(params) {
217
217
  var product = resolved.find(function (item) {
218
218
  return Number(item.id) === Number(productId);
219
219
  });
220
- return (_ref3 = (_extractProductPrice = extractProductPrice(product || {})) !== null && _extractProductPrice !== void 0 ? _extractProductPrice : fallbackPrice) !== null && _ref3 !== void 0 ? _ref3 : '0.00';
220
+ return (_ref4 = (_extractProductPrice = extractProductPrice(product || {})) !== null && _extractProductPrice !== void 0 ? _extractProductPrice : fallbackPrice) !== null && _ref4 !== void 0 ? _ref4 : '0.00';
221
221
  }
222
222
 
223
223
  /** 从 slot 价格 Map 读取单价,找不到则回退 fallback */
@@ -45,5 +45,6 @@ export declare class DataVariantAdapter implements BusinessAdapter {
45
45
  * 归一化客户 id:无效值返回 undefined,有效值统一为 number。
46
46
  */
47
47
  private normalizeCustomerId;
48
+ private normalizeNumberArray;
48
49
  }
49
50
  export default DataVariantAdapter;
@@ -47,9 +47,11 @@ var DataVariantAdapter = class {
47
47
  orderType,
48
48
  businessCode,
49
49
  customerId,
50
+ availableWalletIds,
50
51
  custom
51
52
  } = businessData;
52
53
  const normalizedCustomerId = this.normalizeCustomerId(customerId);
54
+ const normalizedAvailableWalletIds = this.normalizeNumberArray(availableWalletIds ?? (custom == null ? void 0 : custom.available_wallet_ids));
53
55
  const resolvedBusinessCode = businessCode || (custom == null ? void 0 : custom.business_code) || (custom == null ? void 0 : custom.businessCode) || "";
54
56
  return {
55
57
  entities: {
@@ -63,6 +65,8 @@ var DataVariantAdapter = class {
63
65
  // snake_case 与策略配置 field 对齐;customerId 保留兼容旧配置
64
66
  customer_id: normalizedCustomerId,
65
67
  customerId: normalizedCustomerId,
68
+ available_wallet_ids: normalizedAvailableWalletIds,
69
+ availableWalletIds: normalizedAvailableWalletIds,
66
70
  business_code: resolvedBusinessCode
67
71
  },
68
72
  metadata: {
@@ -131,6 +135,12 @@ var DataVariantAdapter = class {
131
135
  const parsed = Number(value);
132
136
  return Number.isFinite(parsed) && parsed > 0 ? parsed : void 0;
133
137
  }
138
+ normalizeNumberArray(value) {
139
+ if (!Array.isArray(value))
140
+ return [];
141
+ const ids = value.map((item) => Number(item)).filter((item) => Number.isFinite(item) && item > 0);
142
+ return Array.from(new Set(ids));
143
+ }
134
144
  };
135
145
  var adapter_default = DataVariantAdapter;
136
146
  // Annotate the CommonJS export names for ESM import in node:
@@ -64,6 +64,7 @@ export declare class DataVariantEvaluator {
64
64
  private createEngine;
65
65
  private evaluateScheduleMatch;
66
66
  private evaluateMenuMatch;
67
+ private evaluateArrayIntersects;
67
68
  private collectScheduleIdsFromStrategies;
68
69
  private extractTimePointsFromSchedules;
69
70
  private addDateTimePoint;
@@ -81,6 +82,7 @@ export declare class DataVariantEvaluator {
81
82
  private flattenConditionRules;
82
83
  private isConditionGroup;
83
84
  private normalizeNumberArray;
85
+ private normalizeComparableArray;
84
86
  private buildProductKey;
85
87
  private toNumber;
86
88
  }
@@ -346,7 +346,8 @@ var DataVariantEvaluator = class {
346
346
  compareValue,
347
347
  businessData.scheduleList || []
348
348
  ),
349
- menu_match: (fieldValue, compareValue) => this.evaluateMenuMatch(fieldValue, compareValue, menuScopeMap)
349
+ menu_match: (fieldValue, compareValue) => this.evaluateMenuMatch(fieldValue, compareValue, menuScopeMap),
350
+ array_intersects: (fieldValue, compareValue) => this.evaluateArrayIntersects(fieldValue, compareValue)
350
351
  };
351
352
  return new import_engine.StrategyEngine({
352
353
  debug: false,
@@ -379,6 +380,14 @@ var DataVariantEvaluator = class {
379
380
  }
380
381
  return false;
381
382
  }
383
+ evaluateArrayIntersects(fieldValue, compareValue) {
384
+ const fieldValues = this.normalizeComparableArray(fieldValue);
385
+ const compareValues = this.normalizeComparableArray(compareValue);
386
+ if (!fieldValues.length || !compareValues.length)
387
+ return false;
388
+ const compareSet = new Set(compareValues);
389
+ return fieldValues.some((item) => compareSet.has(item));
390
+ }
382
391
  collectScheduleIdsFromStrategies(strategyConfigs) {
383
392
  const scheduleIds = /* @__PURE__ */ new Set();
384
393
  for (const config of strategyConfigs) {
@@ -549,6 +558,16 @@ var DataVariantEvaluator = class {
549
558
  return [];
550
559
  return value.map((item) => this.toNumber(item)).filter((item) => item > 0);
551
560
  }
561
+ normalizeComparableArray(value) {
562
+ const list = Array.isArray(value) ? value : value == null || value === "" ? [] : [value];
563
+ const normalized = list.map((item) => {
564
+ if (item == null || item === "")
565
+ return "";
566
+ const parsed = Number(item);
567
+ return Number.isFinite(parsed) ? String(parsed) : String(item).trim();
568
+ }).filter(Boolean);
569
+ return Array.from(new Set(normalized));
570
+ }
552
571
  buildProductKey(productId, variantId) {
553
572
  return `${productId}:${variantId}`;
554
573
  }
@@ -102,6 +102,8 @@ export interface DataVariantBusinessData {
102
102
  /** 当前业务编码,对应策略条件 field: business_code */
103
103
  businessCode?: string;
104
104
  customerId?: number | string;
105
+ /** 当前客户可用 wallet/pass id 合并列表,对应策略条件 field: available_wallet_ids */
106
+ availableWalletIds?: Array<number | string>;
105
107
  custom?: Record<string, any>;
106
108
  }
107
109
  /**
@@ -1,6 +1,6 @@
1
1
  import { Module, PisellCore, ModuleOptions } from '../../types';
2
2
  import { BaseModule } from '../BaseModule';
3
- import { Discount, DiscountModuleAPI, DiscountWithReason } from './types';
3
+ import { Discount, DiscountModuleAPI, DiscountWithReason, DiscountPrepareConfigResult } from './types';
4
4
  export declare class DiscountModule extends BaseModule implements Module, DiscountModuleAPI {
5
5
  protected defaultName: string;
6
6
  protected defaultVersion: string;
@@ -22,9 +22,12 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
22
22
  with_discount_card: 0 | 1;
23
23
  customer_id: number;
24
24
  with_wallet_pass_holder: 0 | 1;
25
+ with_available_wallet_flag?: 0 | 1;
26
+ with_available_wallet_pass_flag?: 0 | 1;
25
27
  request_timezone: string;
26
28
  order_id?: number;
27
- }): Promise<Discount[]>;
29
+ }): Promise<DiscountPrepareConfigResult>;
30
+ private extractAvailableWalletIds;
28
31
  batchSearch(code: string, options?: {
29
32
  customerId?: number;
30
33
  orderId?: number;
@@ -100,7 +100,17 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
100
100
  const goodPassList = this.filterEnabledDiscountList(
101
101
  [...((_a = prepareConfig == null ? void 0 : prepareConfig.data) == null ? void 0 : _a.good_pass_list) || [], ...((_b = prepareConfig == null ? void 0 : prepareConfig.data) == null ? void 0 : _b.discount_card_list) || []]
102
102
  ) || [];
103
- return goodPassList;
103
+ return {
104
+ discountList: goodPassList,
105
+ availableWalletIds: this.extractAvailableWalletIds(prepareConfig == null ? void 0 : prepareConfig.data)
106
+ };
107
+ }
108
+ extractAvailableWalletIds(data) {
109
+ const availableWalletList = Array.isArray(data == null ? void 0 : data.avaiable_wallet_list) ? data.avaiable_wallet_list : Array.isArray(data == null ? void 0 : data.available_wallet_list) ? data.available_wallet_list : [];
110
+ const availableWalletPassList = Array.isArray(data == null ? void 0 : data.available_wallet_pass_list) ? data.available_wallet_pass_list : [];
111
+ const walletIds = availableWalletList.map((item) => Number(item == null ? void 0 : item.id)).filter((id) => Number.isFinite(id) && id > 0);
112
+ const walletPassProductIds = availableWalletPassList.map((item) => Number(item == null ? void 0 : item.product_id)).filter((id) => Number.isFinite(id) && id > 0);
113
+ return Array.from(/* @__PURE__ */ new Set([...walletIds, ...walletPassProductIds]));
104
114
  }
105
115
  async batchSearch(code, options) {
106
116
  const { customerId, orderId } = options || {};
@@ -68,6 +68,10 @@ export interface DiscountWithReason {
68
68
  discountList: Discount[];
69
69
  unavailableReasonKey: DiscountFilterRejectKey | null;
70
70
  }
71
+ export interface DiscountPrepareConfigResult {
72
+ discountList: Discount[];
73
+ availableWalletIds: number[];
74
+ }
71
75
  interface ExtensionData {
72
76
  id: number;
73
77
  shop_id: number;
@@ -42,6 +42,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
42
42
  action?: 'create';
43
43
  }): Promise<void>;
44
44
  getDiscountList(): Discount[];
45
+ getAvailableWalletIds(): number[];
45
46
  scanCode(code: string, customerId?: number): Promise<{
46
47
  isAvailable: boolean;
47
48
  discountList: Discount[];
@@ -76,6 +76,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
76
76
  if (!this.store.tempOrder) {
77
77
  this.store.tempOrder = null;
78
78
  }
79
+ if (!Array.isArray(this.store.availableWalletIds)) {
80
+ this.store.availableWalletIds = [];
81
+ }
79
82
  this.request = this.core.getPlugin("request");
80
83
  this.window = this.core.getPlugin("window");
81
84
  const otherParams = options.otherParams || {};
@@ -164,14 +167,18 @@ var OrderModule = class extends import_BaseModule.BaseModule {
164
167
  // ─── Discount: 公共 API ───
165
168
  async loadDiscountConfig(params) {
166
169
  var _a, _b, _c, _d;
167
- const discountList = await ((_a = this.store.discount) == null ? void 0 : _a.loadPrepareConfig({
170
+ const prepareConfig = await ((_a = this.store.discount) == null ? void 0 : _a.loadPrepareConfig({
168
171
  customer_id: params.customerId,
169
172
  action: params.action || "create",
170
173
  with_good_pass: 1,
171
174
  with_discount_card: 1,
172
175
  with_wallet_pass_holder: 1,
176
+ with_available_wallet_flag: 1,
177
+ with_available_wallet_pass_flag: 1,
173
178
  request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
174
179
  }));
180
+ const discountList = prepareConfig == null ? void 0 : prepareConfig.discountList;
181
+ this.store.availableWalletIds = (prepareConfig == null ? void 0 : prepareConfig.availableWalletIds) || [];
175
182
  if (discountList) {
176
183
  (_b = this.store.discount) == null ? void 0 : _b.setDiscountList(discountList);
177
184
  }
@@ -183,6 +190,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
183
190
  var _a;
184
191
  return ((_a = this.store.discount) == null ? void 0 : _a.getDiscountList()) || [];
185
192
  }
193
+ getAvailableWalletIds() {
194
+ return this.store.availableWalletIds || [];
195
+ }
186
196
  async scanCode(code, customerId) {
187
197
  var _a, _b, _c, _d, _e;
188
198
  const resultDiscountWithReason = await ((_a = this.store.discount) == null ? void 0 : _a.batchSearch(code, { customerId })) || { discountList: [], unavailableReasonKey: null };
@@ -15,6 +15,7 @@ export interface OrderState {
15
15
  discountList: any[];
16
16
  discount: DiscountModule | null;
17
17
  rules: RulesModule | null;
18
+ availableWalletIds?: number[];
18
19
  }
19
20
  /** 更新购物车行:仅传 SKU 时命中同 SKU 第一行;多行同 SKU 须传 identity_key / 选项指纹等 */
20
21
  export interface UpdateProductInOrderParams {
@@ -250,5 +251,6 @@ export interface OrderModuleAPI {
250
251
  action?: 'create';
251
252
  }) => Promise<void>;
252
253
  getDiscountList: () => Discount[];
254
+ getAvailableWalletIds: () => number[];
253
255
  applyDiscount: () => void;
254
256
  }
@@ -62,7 +62,7 @@ var ProductList = class extends import_BaseModule.BaseModule {
62
62
  with_schedule,
63
63
  with_extra = []
64
64
  }, options) {
65
- var _a;
65
+ var _a, _b, _c;
66
66
  let userPlugin = this.core.getPlugin("user");
67
67
  let customer_id = void 0;
68
68
  try {
@@ -70,6 +70,13 @@ var ProductList = class extends import_BaseModule.BaseModule {
70
70
  } catch (error) {
71
71
  console.error(error);
72
72
  }
73
+ const channelMap = {
74
+ "online_store": "online-store",
75
+ "scan_to_order": "online-store",
76
+ "scan_to_order_2": "online-store",
77
+ "scan_to_order_3": "online-store"
78
+ };
79
+ const saleChannel = channelMap[(_b = this.otherParams) == null ? void 0 : _b.channel] || ((_c = this.otherParams) == null ? void 0 : _c.channel);
73
80
  try {
74
81
  const productsData = await this.request.post(
75
82
  `/product/query`,
@@ -99,7 +106,7 @@ var ProductList = class extends import_BaseModule.BaseModule {
99
106
  schedule_date,
100
107
  schedule_datetime,
101
108
  // application_code: this.otherParams?.channel === 'online_store' ? 'online-store' : this.otherParams?.channel,
102
- application_code: "online-store",
109
+ application_code: saleChannel,
103
110
  with_schedule,
104
111
  is_eject: 1,
105
112
  open_deposit: 1
@@ -418,6 +418,11 @@ var RulesModule = class extends import_BaseModule.BaseModule {
418
418
  }
419
419
  });
420
420
  }
421
+ const isProductIncludedByLimitedData = (limitedData, productId) => {
422
+ const excludedIds = (limitedData == null ? void 0 : limitedData.exclude_product_ids) || [];
423
+ const isExcluded = (limitedData == null ? void 0 : limitedData.filter) === 1 && excludedIds.some((id) => String(id) === String(productId));
424
+ return !isExcluded;
425
+ };
421
426
  const usedDiscounts = /* @__PURE__ */ new Map();
422
427
  const usedProductIdCounts = /* @__PURE__ */ new Map();
423
428
  const usedDiscountCardLimitCounts = /* @__PURE__ */ new Map();
@@ -776,7 +781,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
776
781
  return false;
777
782
  }
778
783
  if (limitedData.type === "product_all") {
779
- if (limitedData.filter === 1 && limitedData.exclude_product_ids.includes(product.id)) {
784
+ if (!isProductIncludedByLimitedData(limitedData, product.id)) {
780
785
  return false;
781
786
  }
782
787
  if (!this.checkPackageSubItemUsageRules(discount, flatItem)) {
@@ -34,6 +34,10 @@ __export(getDateIsInSchedule_exports, {
34
34
  });
35
35
  module.exports = __toCommonJS(getDateIsInSchedule_exports);
36
36
  var import_dayjs = __toESM(require("dayjs"));
37
+ var import_isSameOrAfter = __toESM(require("dayjs/plugin/isSameOrAfter"));
38
+ var import_isSameOrBefore = __toESM(require("dayjs/plugin/isSameOrBefore"));
39
+ import_dayjs.default.extend(import_isSameOrAfter.default);
40
+ import_dayjs.default.extend(import_isSameOrBefore.default);
37
41
  var getDateIsInSchedule = (dateTime, scheduleList) => {
38
42
  if (!dateTime || !scheduleList || scheduleList.length === 0) {
39
43
  return false;
@@ -387,6 +387,26 @@ var calculateTaxFee = (shopInfo, items) => {
387
387
  }, new import_decimal.default(0));
388
388
  return totalTaxFee;
389
389
  };
390
+ var getCartItemDepositData = (item) => {
391
+ var _a, _b, _c, _d;
392
+ const target = item;
393
+ return ((_a = target == null ? void 0 : target._productOrigin) == null ? void 0 : _a.custom_deposit_data) || ((_b = target == null ? void 0 : target._origin) == null ? void 0 : _b.custom_deposit_data) || ((_d = (_c = target == null ? void 0 : target._origin) == null ? void 0 : _c.product) == null ? void 0 : _d.custom_deposit_data);
394
+ };
395
+ var getCartItemQuantity = (item) => {
396
+ return new import_decimal.default((item == null ? void 0 : item.num) || 1);
397
+ };
398
+ var calculateCartItemDepositTotal = (item) => {
399
+ var _a;
400
+ const depositData = getCartItemDepositData(item);
401
+ if ((depositData == null ? void 0 : depositData.has_deposit) == 1 && typeof (depositData == null ? void 0 : depositData.deposit_fixed) === "string" && typeof (depositData == null ? void 0 : depositData.deposit_percentage) === "string") {
402
+ const lineTotal = new import_decimal.default(item.summaryTotal ?? item.total ?? 0);
403
+ const quantity = getCartItemQuantity(item);
404
+ const fixedTotal = new import_decimal.default(depositData.deposit_fixed || 0).times(quantity);
405
+ const percentageTotal = new import_decimal.default(depositData.deposit_percentage || 0).times(lineTotal);
406
+ return fixedTotal.plus(percentageTotal);
407
+ }
408
+ return new import_decimal.default(((_a = item == null ? void 0 : item.deposit) == null ? void 0 : _a.total) || 0);
409
+ };
390
410
  var calculateDeposit = (items) => {
391
411
  if (!(items == null ? void 0 : items.length)) {
392
412
  return void 0;
@@ -394,11 +414,11 @@ var calculateDeposit = (items) => {
394
414
  const protocols = [];
395
415
  let hasDeposit = false;
396
416
  const total = items.reduce((sum, item) => {
397
- var _a, _b, _c;
417
+ var _a, _b;
398
418
  if (item == null ? void 0 : item.deposit) {
399
419
  hasDeposit = true;
400
- const cartItemTotalPrice = new import_decimal.default(((_a = item == null ? void 0 : item.deposit) == null ? void 0 : _a.total) || 0);
401
- (_c = (_b = item == null ? void 0 : item.deposit) == null ? void 0 : _b.protocols) == null ? void 0 : _c.forEach((protocol) => {
420
+ const cartItemTotalPrice = calculateCartItemDepositTotal(item);
421
+ (_b = (_a = item == null ? void 0 : item.deposit) == null ? void 0 : _a.protocols) == null ? void 0 : _b.forEach((protocol) => {
402
422
  if (protocols.findIndex((p) => p.id === protocol.id) === -1) {
403
423
  protocols.push(protocol);
404
424
  }