@pisell/pisellos 2.3.49 → 2.3.50

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 (162) hide show
  1. package/dist/modules/Discount/index.d.ts +1 -0
  2. package/dist/modules/Discount/index.js +40 -11
  3. package/dist/modules/Discount/types.d.ts +1 -0
  4. package/dist/modules/Holder/index.d.ts +48 -0
  5. package/dist/modules/Holder/index.js +640 -0
  6. package/dist/modules/Holder/types.d.ts +123 -0
  7. package/dist/modules/Holder/types.js +1 -0
  8. package/dist/modules/Holder/utils.d.ts +13 -0
  9. package/dist/modules/Holder/utils.js +34 -0
  10. package/dist/modules/OpenData/index.js +2 -2
  11. package/dist/modules/Order/index.d.ts +3 -1
  12. package/dist/modules/Order/index.js +54 -25
  13. package/dist/modules/Order/types.d.ts +9 -0
  14. package/dist/modules/Order/utils.d.ts +10 -0
  15. package/dist/modules/Order/utils.js +35 -3
  16. package/dist/modules/Payment/types.d.ts +0 -8
  17. package/dist/modules/Payment/walletpass.d.ts +1 -7
  18. package/dist/modules/Payment/walletpass.js +45 -155
  19. package/dist/modules/Product/types.d.ts +1 -0
  20. package/dist/modules/ProductList/index.js +33 -14
  21. package/dist/modules/Quotation/index.d.ts +1 -1
  22. package/dist/modules/Quotation/index.js +2 -2
  23. package/dist/modules/ResourcePlanner/index.d.ts +24 -0
  24. package/dist/modules/ResourcePlanner/index.js +181 -0
  25. package/dist/modules/ResourcePlanner/planner.d.ts +14 -0
  26. package/dist/modules/ResourcePlanner/planner.js +1069 -0
  27. package/dist/modules/ResourcePlanner/types.d.ts +227 -0
  28. package/dist/modules/ResourcePlanner/types.js +1 -0
  29. package/dist/modules/Rules/index.js +47 -13
  30. package/dist/modules/SalesSummary/index.js +12 -13
  31. package/dist/modules/ScanOrderLogger/index.d.ts +2 -0
  32. package/dist/modules/ScanOrderLogger/index.js +15 -2
  33. package/dist/modules/ScanOrderLogger/providers/feishu.js +45 -27
  34. package/dist/modules/ScanOrderLogger/types.d.ts +1 -0
  35. package/dist/modules/Schedule/index.d.ts +3 -1
  36. package/dist/modules/Schedule/index.js +21 -16
  37. package/dist/modules/Summary/utils.js +38 -13
  38. package/dist/modules/index.d.ts +2 -0
  39. package/dist/modules/index.js +3 -1
  40. package/dist/plugins/window.d.ts +1 -0
  41. package/dist/server/index.d.ts +14 -0
  42. package/dist/server/index.js +907 -793
  43. package/dist/server/modules/index.d.ts +1 -1
  44. package/dist/server/modules/order/index.d.ts +0 -16
  45. package/dist/server/modules/order/index.js +776 -964
  46. package/dist/server/modules/order/types.d.ts +0 -14
  47. package/dist/server/modules/order/types.js +0 -6
  48. package/dist/solution/BaseSales/index.d.ts +8 -3
  49. package/dist/solution/BaseSales/index.js +64 -50
  50. package/dist/solution/BookingByStep/index.d.ts +17 -2
  51. package/dist/solution/BookingByStep/index.js +294 -215
  52. package/dist/solution/BookingByStep/types.d.ts +2 -1
  53. package/dist/solution/BookingByStep/types.js +3 -1
  54. package/dist/solution/BookingByStep/utils/capacity.js +17 -1
  55. package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  56. package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
  57. package/dist/solution/BookingTicket/index.d.ts +1 -1
  58. package/dist/solution/BookingTicket/index.js +2 -2
  59. package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
  60. package/dist/solution/BookingTicket/utils/scan/handleScan.js +10 -2
  61. package/dist/solution/ScanOrder/index.d.ts +26 -14
  62. package/dist/solution/ScanOrder/index.js +1142 -739
  63. package/dist/solution/ScanOrder/types.d.ts +21 -1
  64. package/dist/solution/ScanOrder/utils.d.ts +8 -0
  65. package/dist/solution/ScanOrder/utils.js +66 -25
  66. package/dist/solution/ShopDiscount/index.d.ts +1 -0
  67. package/dist/solution/ShopDiscount/index.js +125 -87
  68. package/dist/solution/UnifiedBookingSales/index.d.ts +183 -0
  69. package/dist/solution/UnifiedBookingSales/index.js +1891 -0
  70. package/dist/solution/UnifiedBookingSales/types.d.ts +143 -0
  71. package/dist/solution/UnifiedBookingSales/types.js +11 -0
  72. package/dist/solution/VenueBooking/index.d.ts +39 -11
  73. package/dist/solution/VenueBooking/index.js +1167 -841
  74. package/dist/solution/VenueBooking/types.d.ts +3 -0
  75. package/dist/solution/VenueBooking/utils/resource.js +1 -0
  76. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  77. package/dist/solution/VenueBooking/utils/slotMerge.js +10 -5
  78. package/dist/solution/index.d.ts +1 -0
  79. package/dist/solution/index.js +2 -1
  80. package/dist/types/index.d.ts +1 -0
  81. package/lib/model/strategy/adapter/promotion/index.js +51 -0
  82. package/lib/modules/Discount/index.d.ts +1 -0
  83. package/lib/modules/Discount/index.js +9 -0
  84. package/lib/modules/Discount/types.d.ts +1 -0
  85. package/lib/modules/Holder/index.d.ts +48 -0
  86. package/lib/modules/Holder/index.js +402 -0
  87. package/lib/modules/Holder/types.d.ts +123 -0
  88. package/lib/modules/Holder/types.js +17 -0
  89. package/lib/modules/Holder/utils.d.ts +13 -0
  90. package/lib/modules/Holder/utils.js +71 -0
  91. package/lib/modules/OpenData/index.js +1 -1
  92. package/lib/modules/Order/index.d.ts +3 -1
  93. package/lib/modules/Order/index.js +26 -10
  94. package/lib/modules/Order/types.d.ts +9 -0
  95. package/lib/modules/Order/utils.d.ts +10 -0
  96. package/lib/modules/Order/utils.js +36 -5
  97. package/lib/modules/Payment/types.d.ts +0 -8
  98. package/lib/modules/Payment/walletpass.d.ts +1 -7
  99. package/lib/modules/Payment/walletpass.js +9 -107
  100. package/lib/modules/Product/types.d.ts +1 -0
  101. package/lib/modules/ProductList/index.js +40 -31
  102. package/lib/modules/Quotation/index.d.ts +1 -1
  103. package/lib/modules/Quotation/index.js +2 -2
  104. package/lib/modules/ResourcePlanner/index.d.ts +24 -0
  105. package/lib/modules/ResourcePlanner/index.js +148 -0
  106. package/lib/modules/ResourcePlanner/planner.d.ts +14 -0
  107. package/lib/modules/ResourcePlanner/planner.js +933 -0
  108. package/lib/modules/ResourcePlanner/types.d.ts +227 -0
  109. package/lib/modules/ResourcePlanner/types.js +17 -0
  110. package/lib/modules/Rules/index.js +33 -16
  111. package/lib/modules/SalesSummary/index.js +6 -7
  112. package/lib/modules/ScanOrderLogger/index.d.ts +2 -0
  113. package/lib/modules/ScanOrderLogger/index.js +13 -1
  114. package/lib/modules/ScanOrderLogger/providers/feishu.js +15 -6
  115. package/lib/modules/ScanOrderLogger/types.d.ts +1 -0
  116. package/lib/modules/Schedule/index.d.ts +3 -1
  117. package/lib/modules/Schedule/index.js +10 -8
  118. package/lib/modules/Summary/utils.js +21 -1
  119. package/lib/modules/index.d.ts +2 -0
  120. package/lib/modules/index.js +5 -1
  121. package/lib/plugins/window.d.ts +1 -0
  122. package/lib/server/index.d.ts +14 -0
  123. package/lib/server/index.js +72 -15
  124. package/lib/server/modules/index.d.ts +1 -1
  125. package/lib/server/modules/order/index.d.ts +0 -16
  126. package/lib/server/modules/order/index.js +4 -140
  127. package/lib/server/modules/order/types.d.ts +0 -14
  128. package/lib/server/modules/order/types.js +0 -1
  129. package/lib/solution/BaseSales/index.d.ts +8 -3
  130. package/lib/solution/BaseSales/index.js +24 -14
  131. package/lib/solution/BookingByStep/index.d.ts +17 -2
  132. package/lib/solution/BookingByStep/index.js +60 -18
  133. package/lib/solution/BookingByStep/types.d.ts +2 -1
  134. package/lib/solution/BookingByStep/types.js +5 -0
  135. package/lib/solution/BookingByStep/utils/capacity.js +20 -1
  136. package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  137. package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
  138. package/lib/solution/BookingTicket/index.d.ts +1 -1
  139. package/lib/solution/BookingTicket/index.js +10 -2
  140. package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
  141. package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -2
  142. package/lib/solution/ScanOrder/index.d.ts +26 -14
  143. package/lib/solution/ScanOrder/index.js +449 -182
  144. package/lib/solution/ScanOrder/types.d.ts +21 -1
  145. package/lib/solution/ScanOrder/utils.d.ts +8 -0
  146. package/lib/solution/ScanOrder/utils.js +31 -0
  147. package/lib/solution/ShopDiscount/index.d.ts +1 -0
  148. package/lib/solution/ShopDiscount/index.js +14 -0
  149. package/lib/solution/UnifiedBookingSales/index.d.ts +183 -0
  150. package/lib/solution/UnifiedBookingSales/index.js +1084 -0
  151. package/lib/solution/UnifiedBookingSales/types.d.ts +143 -0
  152. package/lib/solution/UnifiedBookingSales/types.js +33 -0
  153. package/lib/solution/VenueBooking/index.d.ts +39 -11
  154. package/lib/solution/VenueBooking/index.js +322 -110
  155. package/lib/solution/VenueBooking/types.d.ts +3 -0
  156. package/lib/solution/VenueBooking/utils/resource.js +1 -0
  157. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  158. package/lib/solution/VenueBooking/utils/slotMerge.js +6 -4
  159. package/lib/solution/index.d.ts +1 -0
  160. package/lib/solution/index.js +3 -1
  161. package/lib/types/index.d.ts +1 -0
  162. package/package.json +1 -1
@@ -39,12 +39,6 @@ function matchesWalletAssetCode(asset, normalizedCode) {
39
39
  return String(identifier !== null && identifier !== void 0 ? identifier : '').trim() === normalizedCode;
40
40
  });
41
41
  }
42
- function normalizeWalletAssetCode(code) {
43
- return String(code !== null && code !== void 0 ? code : '').trim().toUpperCase();
44
- }
45
- function getWalletAssetCodeKeys(asset) {
46
- return [asset === null || asset === void 0 ? void 0 : asset.code, asset === null || asset === void 0 ? void 0 : asset.encoded].map(normalizeWalletAssetCode).filter(Boolean);
47
- }
48
42
  function isWalletAssetAvailable(asset) {
49
43
  if (!asset) return false;
50
44
  if (asset.unified_available_status !== undefined && Number(asset.unified_available_status) !== 1) {
@@ -108,31 +102,18 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
108
102
  _defineProperty(this, "walletInitData", null);
109
103
  _defineProperty(this, "walletAssetsState", createInitialWalletAssetsState());
110
104
  _defineProperty(this, "walletAssetsRequestSequence", 0);
111
- _defineProperty(this, "walletAssetsBehavior", {
112
- autoSelectAfterSearch: true
113
- });
114
- _defineProperty(this, "pendingAutoSelectSearchCodes", new Set());
115
105
  _defineProperty(this, "walletAssetsCalculationContext", {
116
106
  orderTotalAmount: 0,
117
107
  products: []
118
108
  });
119
109
  this.paymentModule = paymentModule;
120
110
  }
121
- _createClass(WalletPassPaymentImpl, [{
122
- key: "configureWalletAssetsBehavior",
123
- value: function configureWalletAssetsBehavior(options) {
124
- if (options.autoSelectAfterSearch === undefined) return;
125
- this.walletAssetsBehavior.autoSelectAfterSearch = options.autoSelectAfterSearch;
126
- if (!options.autoSelectAfterSearch) {
127
- this.pendingAutoSelectSearchCodes.clear();
128
- }
129
- }
130
111
 
131
- /**
132
- * 发送事件的辅助方法
133
- * 支持使用WalletPassHooks或PaymentHooks
134
- */
135
- }, {
112
+ /**
113
+ * 发送事件的辅助方法
114
+ * 支持使用WalletPassHooks或PaymentHooks
115
+ */
116
+ _createClass(WalletPassPaymentImpl, [{
136
117
  key: "emitEvent",
137
118
  value: function emitEvent(hook, data) {
138
119
  try {
@@ -269,33 +250,6 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
269
250
  }
270
251
  return mergeWalletAssets(cachedAssets, refreshedAssets);
271
252
  }
272
- }, {
273
- key: "isPendingAutoSelectAsset",
274
- value: function isPendingAutoSelectAsset(asset) {
275
- var _this = this;
276
- return getWalletAssetCodeKeys(asset).some(function (code) {
277
- return _this.pendingAutoSelectSearchCodes.has(code);
278
- });
279
- }
280
- }, {
281
- key: "clearPendingAutoSelectForAsset",
282
- value: function clearPendingAutoSelectForAsset(asset) {
283
- var _this2 = this;
284
- getWalletAssetCodeKeys(asset).forEach(function (code) {
285
- _this2.pendingAutoSelectSearchCodes.delete(code);
286
- });
287
- }
288
- }, {
289
- key: "queuePendingAutoSelectForAssets",
290
- value: function queuePendingAutoSelectForAssets(assets) {
291
- var _this3 = this;
292
- if (!this.walletAssetsBehavior.autoSelectAfterSearch) return;
293
- assets.forEach(function (asset) {
294
- getWalletAssetCodeKeys(asset).forEach(function (code) {
295
- _this3.pendingAutoSelectSearchCodes.add(code);
296
- });
297
- });
298
- }
299
253
 
300
254
  /**
301
255
  * 生成钱包API默认参数
@@ -1006,8 +960,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
1006
960
  key: "refreshWalletAssetsFromBusinessAsync",
1007
961
  value: (function () {
1008
962
  var _refreshWalletAssetsFromBusinessAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(businessData) {
1009
- var _businessData$product2,
1010
- _this4 = this;
963
+ var _businessData$product2;
1011
964
  var options,
1012
965
  requestSequence,
1013
966
  nextCustomerId,
@@ -1018,7 +971,6 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
1018
971
  committedItems,
1019
972
  selectedIds,
1020
973
  selectionSources,
1021
- scanSelectedAssets,
1022
974
  restoredSearchedAssets,
1023
975
  searchedWalletAssetCodes,
1024
976
  useAggregateRecalculate,
@@ -1032,11 +984,6 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
1032
984
  items,
1033
985
  latestSelectedIds,
1034
986
  latestSelectionSources,
1035
- pendingAutoSelectAssets,
1036
- requestedKeySet,
1037
- nextState,
1038
- selectedKeySet,
1039
- droppedScanSelectedAssets,
1040
987
  _args8 = arguments;
1041
988
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1042
989
  while (1) switch (_context8.prev = _context8.next) {
@@ -1057,18 +1004,12 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
1057
1004
  return committedKeys.has(getWalletAssetKey(item));
1058
1005
  });
1059
1006
  selectedIds = preserveSelection ? _toConsumableArray(this.walletAssetsState.selectedIds) : [];
1060
- selectionSources = preserveSelection ? _objectSpread({}, this.walletAssetsState.selectionSources) : {};
1061
- scanSelectedAssets = preserveSelection ? this.walletAssetsState.selectedItems.filter(function (asset) {
1062
- var assetId = getWalletAssetId(asset);
1063
- return assetId !== undefined && assetId !== null && selectionSources[String(assetId)] === 'scan';
1064
- }) : []; // aggregate-recalculate 不接受空商品列表。
1065
- // 清空购物车时保留扫码资产供后续加购恢复;只有手动 Remove/Clear
1066
- // 会取消自动应用资格,商品变化导致的自动失效需要重新进入待选队列。
1007
+ selectionSources = preserveSelection ? _objectSpread({}, this.walletAssetsState.selectionSources) : {}; // aggregate-recalculate 不接受空商品列表。
1008
+ // 清空购物车时保留扫码资产供后续加购恢复,但必须取消当前选择。
1067
1009
  if ((_businessData$product2 = businessData.products) !== null && _businessData$product2 !== void 0 && _businessData$product2.length) {
1068
- _context8.next = 22;
1010
+ _context8.next = 20;
1069
1011
  break;
1070
1012
  }
1071
- this.queuePendingAutoSelectForAssets(scanSelectedAssets);
1072
1013
  this.generateWalletParams(businessData);
1073
1014
  restoredSearchedAssets = this.searchResults.filter(isWalletPaymentAsset).map(function (item) {
1074
1015
  return _objectSpread(_objectSpread({}, item), {}, {
@@ -1103,7 +1044,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
1103
1044
  totalSelectedAmount: 0,
1104
1045
  error: null
1105
1046
  }));
1106
- case 22:
1047
+ case 20:
1107
1048
  this.publishWalletAssetsState({
1108
1049
  status: 'loading',
1109
1050
  customerId: nextCustomerId,
@@ -1114,40 +1055,40 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
1114
1055
  totalSelectedAmount: preserveSelection ? this.walletAssetsState.totalSelectedAmount : 0,
1115
1056
  error: null
1116
1057
  });
1117
- _context8.prev = 23;
1058
+ _context8.prev = 21;
1118
1059
  searchedWalletAssetCodes = preserveSelection ? this.getSearchedWalletAssetCodes() : [];
1119
1060
  useAggregateRecalculate = preserveSelection && (selectedIds.length > 0 || searchedWalletAssetCodes.length > 0);
1120
1061
  if (!useAggregateRecalculate) {
1121
- _context8.next = 32;
1062
+ _context8.next = 30;
1122
1063
  break;
1123
1064
  }
1124
- _context8.next = 29;
1065
+ _context8.next = 27;
1125
1066
  return this.aggregateRecalculateWalletAssetsAsync(businessData, selectedIds);
1126
- case 29:
1067
+ case 27:
1127
1068
  _context8.t0 = _context8.sent;
1128
- _context8.next = 33;
1069
+ _context8.next = 31;
1129
1070
  break;
1130
- case 32:
1071
+ case 30:
1131
1072
  _context8.t0 = null;
1132
- case 33:
1073
+ case 31:
1133
1074
  aggregateResult = _context8.t0;
1134
1075
  _context8.t1 = aggregateResult;
1135
1076
  if (_context8.t1) {
1136
- _context8.next = 39;
1077
+ _context8.next = 37;
1137
1078
  break;
1138
1079
  }
1139
- _context8.next = 38;
1080
+ _context8.next = 36;
1140
1081
  return this.initializeWalletDataFromBusinessAsync(businessData);
1141
- case 38:
1082
+ case 36:
1142
1083
  _context8.t1 = _context8.sent;
1143
- case 39:
1084
+ case 37:
1144
1085
  result = _context8.t1;
1145
1086
  if (!(requestSequence !== this.walletAssetsRequestSequence)) {
1146
- _context8.next = 42;
1087
+ _context8.next = 40;
1147
1088
  break;
1148
1089
  }
1149
1090
  return _context8.abrupt("return", this.getWalletAssetsState());
1150
- case 42:
1091
+ case 40:
1151
1092
  this.walletAssetsCalculationContext = {
1152
1093
  orderTotalAmount: Number(businessData.order_wait_pay_amount || 0),
1153
1094
  products: result.products || businessData.products || []
@@ -1170,11 +1111,11 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
1170
1111
  }
1171
1112
  searchedWalletAssets = preserveSelection ? this.syncSearchedWalletAssets([].concat(_toConsumableArray(result.transformList || []), _toConsumableArray(result.noApplicableVoucher || []))) : [];
1172
1113
  if (!(requestSequence !== this.walletAssetsRequestSequence)) {
1173
- _context8.next = 48;
1114
+ _context8.next = 46;
1174
1115
  break;
1175
1116
  }
1176
1117
  return _context8.abrupt("return", this.getWalletAssetsState());
1177
- case 48:
1118
+ case 46:
1178
1119
  recommendedKeys = new Set((result.walletRecommendList || []).map(function (asset) {
1179
1120
  return getWalletAssetKey(asset);
1180
1121
  }));
@@ -1185,47 +1126,16 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
1185
1126
  });
1186
1127
  latestSelectedIds = preserveSelection ? authoritativeSelectedIds : [];
1187
1128
  latestSelectionSources = preserveSelection ? _objectSpread({}, this.walletAssetsState.selectionSources) : {};
1188
- pendingAutoSelectAssets = this.walletAssetsBehavior.autoSelectAfterSearch ? items.filter(function (asset) {
1189
- return _this4.isPendingAutoSelectAsset(asset) && isWalletAssetAvailable(asset);
1190
- }) : [];
1191
- requestedKeySet = new Set(latestSelectedIds.map(function (id) {
1192
- return String(id);
1193
- }));
1194
- pendingAutoSelectAssets.forEach(function (asset) {
1195
- var assetId = getWalletAssetId(asset);
1196
- if (assetId === undefined || assetId === null) return;
1197
- var assetKey = String(assetId);
1198
- if (!requestedKeySet.has(assetKey)) {
1199
- requestedKeySet.add(assetKey);
1200
- latestSelectedIds.push(assetId);
1201
- }
1202
- latestSelectionSources[assetKey] = 'scan';
1203
- });
1204
- nextState = this.recalculateWalletAssets(items, latestSelectedIds, latestSelectionSources);
1205
- selectedKeySet = new Set(nextState.selectedIds.map(function (id) {
1206
- return String(id);
1207
- }));
1208
- pendingAutoSelectAssets.forEach(function (asset) {
1209
- var assetId = getWalletAssetId(asset);
1210
- if (assetId !== undefined && assetId !== null && selectedKeySet.has(String(assetId))) {
1211
- _this4.clearPendingAutoSelectForAsset(asset);
1212
- }
1213
- });
1214
- droppedScanSelectedAssets = scanSelectedAssets.filter(function (asset) {
1215
- var assetId = getWalletAssetId(asset);
1216
- return assetId !== undefined && assetId !== null && !selectedKeySet.has(String(assetId));
1217
- });
1218
- this.queuePendingAutoSelectForAssets(droppedScanSelectedAssets);
1219
- return _context8.abrupt("return", nextState);
1220
- case 63:
1221
- _context8.prev = 63;
1222
- _context8.t2 = _context8["catch"](23);
1129
+ return _context8.abrupt("return", this.recalculateWalletAssets(items, latestSelectedIds, latestSelectionSources));
1130
+ case 53:
1131
+ _context8.prev = 53;
1132
+ _context8.t2 = _context8["catch"](21);
1223
1133
  if (!(requestSequence !== this.walletAssetsRequestSequence)) {
1224
- _context8.next = 67;
1134
+ _context8.next = 57;
1225
1135
  break;
1226
1136
  }
1227
1137
  return _context8.abrupt("return", this.getWalletAssetsState());
1228
- case 67:
1138
+ case 57:
1229
1139
  this.paymentModule.logError('[WalletPass] 刷新共享钱包资产失败,保留刷新前状态', _context8.t2, {
1230
1140
  customer_id: businessData.customer_id,
1231
1141
  selected_ids: selectedIds,
@@ -1241,11 +1151,11 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
1241
1151
  customerId: nextCustomerId,
1242
1152
  error: _context8.t2 instanceof Error ? _context8.t2.message : String(_context8.t2)
1243
1153
  }));
1244
- case 69:
1154
+ case 59:
1245
1155
  case "end":
1246
1156
  return _context8.stop();
1247
1157
  }
1248
- }, _callee8, this, [[23, 63]]);
1158
+ }, _callee8, this, [[21, 53]]);
1249
1159
  }));
1250
1160
  function refreshWalletAssetsFromBusinessAsync(_x9) {
1251
1161
  return _refreshWalletAssetsFromBusinessAsync.apply(this, arguments);
@@ -1269,7 +1179,6 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
1269
1179
  return {
1270
1180
  state: this.getWalletAssetsState(),
1271
1181
  searchResults: _toConsumableArray(this.searchResults),
1272
- pendingAutoSelectSearchCodes: _toConsumableArray(this.pendingAutoSelectSearchCodes),
1273
1182
  walletParams: this.walletParams ? _objectSpread({}, this.walletParams) : null,
1274
1183
  calculationContext: {
1275
1184
  orderTotalAmount: this.walletAssetsCalculationContext.orderTotalAmount,
@@ -1284,7 +1193,6 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
1284
1193
  if (!(snapshot !== null && snapshot !== void 0 && snapshot.state)) return this.getWalletAssetsState();
1285
1194
  this.walletAssetsRequestSequence += 1;
1286
1195
  this.searchResults = Array.isArray(snapshot.searchResults) ? _toConsumableArray(snapshot.searchResults) : [];
1287
- this.pendingAutoSelectSearchCodes = this.walletAssetsBehavior.autoSelectAfterSearch && Array.isArray(snapshot.pendingAutoSelectSearchCodes) ? new Set(snapshot.pendingAutoSelectSearchCodes.map(normalizeWalletAssetCode).filter(Boolean)) : new Set();
1288
1196
  this.walletParams = snapshot.walletParams ? _objectSpread({}, snapshot.walletParams) : null;
1289
1197
  this.walletAssetsCalculationContext = {
1290
1198
  orderTotalAmount: Number(((_snapshot$calculation = snapshot.calculationContext) === null || _snapshot$calculation === void 0 ? void 0 : _snapshot$calculation.orderTotalAmount) || 0),
@@ -1302,9 +1210,6 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
1302
1210
  key: "selectWalletAsset",
1303
1211
  value: function selectWalletAsset(assetId, options) {
1304
1212
  var assetKey = String(assetId);
1305
- var asset = this.walletAssetsState.items.find(function (item) {
1306
- return getWalletAssetKey(item) === assetKey;
1307
- });
1308
1213
  var committedKeys = new Set(this.walletAssetsState.committedIds.map(function (id) {
1309
1214
  return String(id);
1310
1215
  }));
@@ -1315,27 +1220,22 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
1315
1220
  var selectionSources = _objectSpread({}, this.walletAssetsState.selectionSources);
1316
1221
  delete selectionSources[assetKey];
1317
1222
  if (options.selected) {
1223
+ var asset = this.walletAssetsState.items.find(function (item) {
1224
+ return getWalletAssetKey(item) === assetKey;
1225
+ });
1318
1226
  if (!asset || !isWalletAssetAvailable(asset)) {
1319
1227
  return this.getWalletAssetsState();
1320
1228
  }
1321
1229
  selectedIds.push(assetId);
1322
1230
  selectionSources[assetKey] = options.source || 'manual';
1323
- } else if (asset) {
1324
- this.clearPendingAutoSelectForAsset(asset);
1325
1231
  }
1326
- var nextState = this.recalculateWalletAssets(this.walletAssetsState.items, selectedIds, selectionSources);
1327
- if (options.selected && asset && nextState.selectedIds.some(function (id) {
1328
- return String(id) === assetKey;
1329
- })) {
1330
- this.clearPendingAutoSelectForAsset(asset);
1331
- }
1332
- return nextState;
1232
+ return this.recalculateWalletAssets(this.walletAssetsState.items, selectedIds, selectionSources);
1333
1233
  }
1334
1234
  }, {
1335
1235
  key: "scanWalletAssetAsync",
1336
1236
  value: function () {
1337
1237
  var _scanWalletAssetAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(code) {
1338
- var normalizedCode, selectedAsset, result, paymentAssets, asset, items, recalculatedState, assetId, selected, isSelected;
1238
+ var normalizedCode, selectedAsset, result, paymentAssets, asset, items, assetId, selected;
1339
1239
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1340
1240
  while (1) switch (_context9.prev = _context9.next) {
1341
1241
  case 0:
@@ -1388,28 +1288,21 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
1388
1288
  });
1389
1289
  case 14:
1390
1290
  items = mergeWalletAssets(this.walletAssetsState.items, [asset]);
1391
- recalculatedState = this.recalculateWalletAssets(items, this.walletAssetsState.selectedIds, this.walletAssetsState.selectionSources);
1291
+ this.recalculateWalletAssets(items, this.walletAssetsState.selectedIds, this.walletAssetsState.selectionSources);
1392
1292
  assetId = getWalletAssetId(asset);
1393
- selected = this.walletAssetsBehavior.autoSelectAfterSearch && assetId !== undefined && isWalletAssetAvailable(asset) ? this.selectWalletAsset(assetId, {
1293
+ selected = assetId !== undefined && isWalletAssetAvailable(asset) ? this.selectWalletAsset(assetId, {
1394
1294
  selected: true,
1395
1295
  source: 'scan'
1396
- }) : recalculatedState;
1397
- isSelected = assetId !== undefined && selected.selectedIds.some(function (id) {
1398
- return String(id) === String(assetId);
1399
- });
1400
- if (isSelected) {
1401
- this.clearPendingAutoSelectForAsset(asset);
1402
- } else if (this.walletAssetsBehavior.autoSelectAfterSearch) {
1403
- this.pendingAutoSelectSearchCodes.add(normalizeWalletAssetCode(normalizedCode));
1404
- this.queuePendingAutoSelectForAssets([asset]);
1405
- }
1296
+ }) : this.getWalletAssetsState();
1406
1297
  return _context9.abrupt("return", {
1407
1298
  type: result.type,
1408
1299
  asset: asset,
1409
- selected: isSelected,
1300
+ selected: assetId !== undefined && selected.selectedIds.some(function (id) {
1301
+ return String(id) === String(assetId);
1302
+ }),
1410
1303
  state: selected
1411
1304
  });
1412
- case 21:
1305
+ case 19:
1413
1306
  case "end":
1414
1307
  return _context9.stop();
1415
1308
  }
@@ -1423,7 +1316,6 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
1423
1316
  }, {
1424
1317
  key: "clearWalletAssetSelection",
1425
1318
  value: function clearWalletAssetSelection() {
1426
- this.pendingAutoSelectSearchCodes.clear();
1427
1319
  return this.recalculateWalletAssets(this.walletAssetsState.items, [], {});
1428
1320
  }
1429
1321
  }, {
@@ -1599,7 +1491,6 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
1599
1491
  key: "clearSearchResults",
1600
1492
  value: function clearSearchResults() {
1601
1493
  this.searchResults = [];
1602
- this.pendingAutoSelectSearchCodes.clear();
1603
1494
  this.paymentModule.logInfo('[WalletPass] 搜索结果缓存已清除');
1604
1495
  }
1605
1496
 
@@ -1631,7 +1522,6 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
1631
1522
  this.walletRecommendList = [];
1632
1523
  this.userIdentificationCodes = [];
1633
1524
  this.searchResults = [];
1634
- this.pendingAutoSelectSearchCodes.clear();
1635
1525
  this.walletParams = null;
1636
1526
  this.walletInitData = null;
1637
1527
  this.walletAssetsRequestSequence += 1;
@@ -193,6 +193,7 @@ export interface ProductData {
193
193
  status?: string;
194
194
  required?: number | string | boolean;
195
195
  resource_id?: number | string | null;
196
+ [key: string]: any;
196
197
  };
197
198
  /** 组合商品id,动态附加 */
198
199
  product_variant_id?: number;
@@ -157,6 +157,10 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
157
157
  userPlugin,
158
158
  customer_id,
159
159
  _userPlugin$get,
160
+ channelMap,
161
+ rawApplicationCode,
162
+ mappedApplicationCode,
163
+ queryPayload,
160
164
  productsData,
161
165
  sortedList,
162
166
  _args4 = arguments;
@@ -185,8 +189,16 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
185
189
  console.error(error);
186
190
  }
187
191
  // 如果没传schedule_date,则从
188
- _context4.next = 7;
189
- return this.request.post("/product/query", {
192
+ channelMap = {
193
+ online_store: 'online-store',
194
+ scan_to_order: 'online-store',
195
+ 'scan-to-order': 'online-store',
196
+ scan_to_order_2: 'mobile_order',
197
+ scan_to_order_3: 'scantoorder3'
198
+ };
199
+ rawApplicationCode = (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.channel;
200
+ mappedApplicationCode = typeof rawApplicationCode === 'string' ? channelMap[rawApplicationCode] || rawApplicationCode : rawApplicationCode;
201
+ queryPayload = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
190
202
  open_quotation: 1,
191
203
  open_bundle: 0,
192
204
  exclude_extension_type: ['product_party', 'product_event', 'product_series_event', 'product_package_ticket', 'ticket', 'event_item'],
@@ -194,28 +206,35 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
194
206
  status: status,
195
207
  num: 500,
196
208
  skip: 1,
197
- customer_id: customer_id,
198
- category_ids: category_ids,
199
- ids: product_ids,
200
- collection: collection,
201
- front_end_cache_id: cacheId,
202
- menu_list_ids: menu_list_ids,
209
+ customer_id: customer_id
210
+ }, Array.isArray(category_ids) && category_ids.length ? {
211
+ category_ids: category_ids
212
+ } : {}), Array.isArray(product_ids) && product_ids.length ? {
213
+ ids: product_ids
214
+ } : {}), Array.isArray(collection) && collection.length ? {
215
+ collection: collection
216
+ } : {}), {}, {
217
+ front_end_cache_id: cacheId
218
+ }, Array.isArray(menu_list_ids) && menu_list_ids.length ? {
219
+ menu_list_ids: menu_list_ids
220
+ } : {}), {}, {
203
221
  with_count: with_count,
204
222
  // client_schedule_ids: schedule_ids,
205
223
  schedule_date: schedule_date,
206
- application_code: (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.channel,
224
+ application_code: mappedApplicationCode,
207
225
  is_eject: 1,
208
226
  with_schedule: with_schedule,
209
227
  schedule_datetime: schedule_datetime,
210
- extension_type: extension_type,
211
- strategy_context: strategy_context
212
- }, {
228
+ extension_type: extension_type
229
+ });
230
+ _context4.next = 11;
231
+ return this.request.post("/product/query", queryPayload, {
213
232
  osServer: true,
214
233
  callback: options === null || options === void 0 ? void 0 : options.callback,
215
234
  subscriberId: options === null || options === void 0 ? void 0 : options.subscriberId,
216
235
  customToast: function customToast() {}
217
236
  });
218
- case 7:
237
+ case 11:
219
238
  productsData = _context4.sent;
220
239
  sortedList = (productsData.data.list || []).slice().sort(function (a, b) {
221
240
  return Number(b.sort) - Number(a.sort);
@@ -228,7 +247,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
228
247
  // }
229
248
  this.addProduct(sortedList);
230
249
  return _context4.abrupt("return", sortedList);
231
- case 11:
250
+ case 15:
232
251
  case "end":
233
252
  return _context4.stop();
234
253
  }
@@ -21,7 +21,7 @@ export declare class QuotationModule extends BaseModule implements Module {
21
21
  * Look up the quotation price for a specific product (+ optional variant) at a given datetime.
22
22
  * Returns the price as a string (e.g. "300.00"), or null if no quotation applies.
23
23
  *
24
- * Priority: iterates quotations already sorted by `sort` ascending (lowest = highest priority).
24
+ * Priority: iterates quotations already sorted by `sort` descending (highest = highest priority).
25
25
  * First matching quotation whose schedule covers `datetime` and whose product_data contains
26
26
  * the requested productId wins.
27
27
  */
@@ -90,7 +90,7 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
90
90
  res = _context2.sent;
91
91
  list = (res === null || res === void 0 || (_data = res.data) === null || _data === void 0 ? void 0 : _data.list) || (res === null || res === void 0 ? void 0 : res.list) || [];
92
92
  list.sort(function (a, b) {
93
- return a.sort - b.sort;
93
+ return b.sort - a.sort;
94
94
  });
95
95
  this.store.list = list;
96
96
  case 9:
@@ -151,7 +151,7 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
151
151
  * Look up the quotation price for a specific product (+ optional variant) at a given datetime.
152
152
  * Returns the price as a string (e.g. "300.00"), or null if no quotation applies.
153
153
  *
154
- * Priority: iterates quotations already sorted by `sort` ascending (lowest = highest priority).
154
+ * Priority: iterates quotations already sorted by `sort` descending (highest = highest priority).
155
155
  * First matching quotation whose schedule covers `datetime` and whose product_data contains
156
156
  * the requested productId wins.
157
157
  */
@@ -0,0 +1,24 @@
1
+ import { BaseModule } from '../BaseModule';
2
+ import type { Module, ModuleOptions, PisellCore } from '../../types';
3
+ import type { ResourcePlannerAssignmentResult, ResourcePlannerAssignableSlotResult, ResourcePlannerContextInput, ResourcePlannerProjection, ResourcePlannerQuery, ResourcePlannerSelectionPatch, ResourcePlannerSnapshot, ResourcePlannerValidationResult } from './types';
4
+ export * from './types';
5
+ export * from './planner';
6
+ export declare enum ResourcePlannerHooks {
7
+ onContextChanged = "resourcePlanner:onContextChanged",
8
+ onSelectionChanged = "resourcePlanner:onSelectionChanged",
9
+ onProjectionChanged = "resourcePlanner:onProjectionChanged"
10
+ }
11
+ export declare class ResourcePlannerModule extends BaseModule implements Module {
12
+ protected defaultName: string;
13
+ protected defaultVersion: string;
14
+ private store;
15
+ initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
16
+ setContext(input: ResourcePlannerContextInput): ResourcePlannerSnapshot;
17
+ mergeContext(input: ResourcePlannerContextInput): ResourcePlannerSnapshot;
18
+ setSelectionPatch(patch: ResourcePlannerSelectionPatch): ResourcePlannerSnapshot;
19
+ queryAvailability(query?: ResourcePlannerQuery): ResourcePlannerProjection;
20
+ autoAssign(query?: ResourcePlannerQuery): ResourcePlannerAssignmentResult;
21
+ resolveAssignableSlots(query?: ResourcePlannerQuery): ResourcePlannerAssignableSlotResult;
22
+ validateSelection(): ResourcePlannerValidationResult;
23
+ getSnapshot(): ResourcePlannerSnapshot;
24
+ }