@pisell/pisellos 0.0.516 → 0.0.518

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 (47) hide show
  1. package/dist/modules/Cart/utils/cartProduct.js +1 -1
  2. package/dist/modules/Order/index.d.ts +1 -1
  3. package/dist/modules/Order/utils.js +16 -13
  4. package/dist/modules/ProductList/index.js +2 -1
  5. package/dist/modules/Quotation/index.d.ts +1 -1
  6. package/dist/modules/Quotation/index.js +2 -2
  7. package/dist/modules/Rules/index.js +1 -0
  8. package/dist/modules/ScanOrderLogger/index.d.ts +2 -0
  9. package/dist/modules/ScanOrderLogger/index.js +15 -2
  10. package/dist/modules/ScanOrderLogger/providers/feishu.js +45 -27
  11. package/dist/modules/ScanOrderLogger/types.d.ts +1 -0
  12. package/dist/solution/BookingByStep/index.d.ts +2 -2
  13. package/dist/solution/BookingByStep/index.js +2 -1
  14. package/dist/solution/BookingTicket/index.d.ts +1 -1
  15. package/dist/solution/ScanOrder/index.d.ts +7 -1
  16. package/dist/solution/ScanOrder/index.js +207 -97
  17. package/dist/solution/ScanOrder/utils.js +5 -5
  18. package/dist/solution/VenueBooking/index.d.ts +2 -0
  19. package/dist/solution/VenueBooking/index.js +94 -42
  20. package/dist/solution/VenueBooking/types.d.ts +1 -0
  21. package/dist/solution/VenueBooking/utils/resource.js +1 -0
  22. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
  23. package/dist/solution/VenueBooking/utils/slotMerge.js +16 -1
  24. package/lib/modules/Cart/utils/cartProduct.js +1 -1
  25. package/lib/modules/Order/index.d.ts +1 -1
  26. package/lib/modules/Order/utils.js +2 -13
  27. package/lib/modules/ProductList/index.js +2 -1
  28. package/lib/modules/Quotation/index.d.ts +1 -1
  29. package/lib/modules/Quotation/index.js +2 -2
  30. package/lib/modules/Rules/index.js +1 -0
  31. package/lib/modules/ScanOrderLogger/index.d.ts +2 -0
  32. package/lib/modules/ScanOrderLogger/index.js +13 -1
  33. package/lib/modules/ScanOrderLogger/providers/feishu.js +15 -6
  34. package/lib/modules/ScanOrderLogger/types.d.ts +1 -0
  35. package/lib/solution/BookingByStep/index.d.ts +2 -2
  36. package/lib/solution/BookingByStep/index.js +2 -2
  37. package/lib/solution/BookingTicket/index.d.ts +1 -1
  38. package/lib/solution/ScanOrder/index.d.ts +7 -1
  39. package/lib/solution/ScanOrder/index.js +114 -28
  40. package/lib/solution/ScanOrder/utils.js +2 -2
  41. package/lib/solution/VenueBooking/index.d.ts +2 -0
  42. package/lib/solution/VenueBooking/index.js +45 -7
  43. package/lib/solution/VenueBooking/types.d.ts +1 -0
  44. package/lib/solution/VenueBooking/utils/resource.js +1 -0
  45. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
  46. package/lib/solution/VenueBooking/utils/slotMerge.js +13 -1
  47. package/package.json +1 -1
@@ -483,10 +483,10 @@ export function normalizeOrderProduct(product) {
483
483
  metadata.unique_identification_number = resolvedIdentityKey;
484
484
  }
485
485
  var normalizedBundle = (product.product_bundle || []).map(function (item) {
486
- var _ref2, _item$bundle_selling_, _ref3, _ref4, _item$custom_price;
486
+ var _ref2, _item$bundle_selling_;
487
487
  return _objectSpread(_objectSpread({}, item), {}, {
488
- bundle_selling_price: (_ref2 = (_item$bundle_selling_ = item.bundle_selling_price) !== null && _item$bundle_selling_ !== void 0 ? _item$bundle_selling_ : item.price) !== null && _ref2 !== void 0 ? _ref2 : '0.00',
489
- custom_price: (_ref3 = (_ref4 = (_item$custom_price = item.custom_price) !== null && _item$custom_price !== void 0 ? _item$custom_price : item.bundle_selling_price) !== null && _ref4 !== void 0 ? _ref4 : item.price) !== null && _ref3 !== void 0 ? _ref3 : '0.00'
488
+ bundle_selling_price: (_ref2 = (_item$bundle_selling_ = item.bundle_selling_price) !== null && _item$bundle_selling_ !== void 0 ? _item$bundle_selling_ : item.price) !== null && _ref2 !== void 0 ? _ref2 : '0.00'
489
+ // custom_price: item.custom_price ?? item.bundle_selling_price ?? item.price ?? '0.00',
490
490
  });
491
491
  });
492
492
  var normalizedOptions = product.product_option_item || [];
@@ -506,7 +506,7 @@ export function normalizeOrderProduct(product) {
506
506
  var variantPrice = Array.isArray(variantList) ? (_variantList$find = variantList.find(function (v) {
507
507
  return Number(v === null || v === void 0 ? void 0 : v.id) === variantId;
508
508
  })) === null || _variantList$find === void 0 ? void 0 : _variantList$find.price : undefined;
509
- var resolvedSource = function (_product$_origin, _product$_origin2, _ref5, _product$original_pri) {
509
+ var resolvedSource = function (_product$_origin, _product$_origin2, _ref3, _product$original_pri) {
510
510
  if (metadata.source_product_price !== undefined) {
511
511
  return String(metadata.source_product_price);
512
512
  }
@@ -524,7 +524,7 @@ export function normalizeOrderProduct(product) {
524
524
  if (!isV2 && metadata.main_product_original_price !== undefined) {
525
525
  return String(metadata.main_product_original_price);
526
526
  }
527
- return (_ref5 = (_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : product.selling_price) !== null && _ref5 !== void 0 ? _ref5 : '0.00';
527
+ return (_ref3 = (_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : product.selling_price) !== null && _ref3 !== void 0 ? _ref3 : '0.00';
528
528
  }();
529
529
 
530
530
  // 2) 派生 main_product_original_price(含 option、不含折扣)
@@ -41,6 +41,8 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
41
41
  private loadOpenDataConfigInFlight;
42
42
  private static readonly OPEN_DATA_CACHE_TTL;
43
43
  private getLoggerContext;
44
+ private safeStringify;
45
+ private pickErrorMessage;
44
46
  private serializeError;
45
47
  private addVenueBookingLog;
46
48
  private logMethodStart;
@@ -44,7 +44,7 @@ import { ItemRuleEvaluator } from "../../model/strategy/adapter/itemRule";
44
44
  import { extractResourceIds, buildResourceProductMap } from "./utils/resource";
45
45
  import { buildTimeSlotGrid, isBusinessHoursCrossDay, generateTimeLabels } from "./utils/timeSlot";
46
46
  import { buildDateRangeSummary } from "./utils/dateSummary";
47
- import { mergeConsecutiveSlots, expandMergedSlotToIndividual, buildVenueIdentityKey, buildVenueBookingEntry, buildPriceBreakdown } from "./utils/slotMerge";
47
+ import { mergeConsecutiveSlots, expandMergedSlotToIndividual, buildVenueIdentityKey, buildVenueBookingEntry, buildVenueResourceMetadata, buildPriceBreakdown } from "./utils/slotMerge";
48
48
  import { composeLinePrice, createUuidV4, sumOptionUnitPrice } from "../../modules/Order/utils";
49
49
  import { OrderModule } from "../../modules/Order";
50
50
  import { RegisterAndLoginHooks } from "../RegisterAndLogin/types";
@@ -112,6 +112,26 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
112
112
  moduleName: 'venueBooking'
113
113
  };
114
114
  }
115
+ }, {
116
+ key: "safeStringify",
117
+ value: function safeStringify(value) {
118
+ try {
119
+ return JSON.stringify(value);
120
+ } catch (_unused) {
121
+ return undefined;
122
+ }
123
+ }
124
+ }, {
125
+ key: "pickErrorMessage",
126
+ value: function pickErrorMessage(error) {
127
+ var _error$data, _error$response, _error$error;
128
+ var candidates = [error.message, (_error$data = error.data) === null || _error$data === void 0 ? void 0 : _error$data.message, (_error$response = error.response) === null || _error$response === void 0 || (_error$response = _error$response.data) === null || _error$response === void 0 ? void 0 : _error$response.message, (_error$error = error.error) === null || _error$error === void 0 ? void 0 : _error$error.message];
129
+ for (var _i = 0, _candidates = candidates; _i < _candidates.length; _i++) {
130
+ var candidate = _candidates[_i];
131
+ if (typeof candidate === 'string' && candidate.trim()) return candidate;
132
+ }
133
+ return undefined;
134
+ }
115
135
  }, {
116
136
  key: "serializeError",
117
137
  value: function serializeError(error) {
@@ -122,6 +142,21 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
122
142
  stack: error.stack
123
143
  };
124
144
  }
145
+ if (error && _typeof(error) === 'object') {
146
+ var raw = error;
147
+ var message = this.pickErrorMessage(raw) || this.safeStringify(raw) || String(error);
148
+ return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, typeof raw.name === 'string' ? {
149
+ name: raw.name
150
+ } : {}), {}, {
151
+ message: message
152
+ }, 'code' in raw ? {
153
+ code: raw.code
154
+ } : {}), 'status' in raw ? {
155
+ status: raw.status
156
+ } : {}), this.safeStringify(raw) ? {
157
+ raw: this.safeStringify(raw)
158
+ } : {});
159
+ }
125
160
  return {
126
161
  message: String(error)
127
162
  };
@@ -246,8 +281,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
246
281
  value: function resolveCustomerIdFromLoginPayload(payload) {
247
282
  var _payload$user, _payload$user2, _payload$user3, _payload$user4, _payload$account, _payload$account2, _payload$account3, _payload$_origin;
248
283
  var candidates = [payload === null || payload === void 0 ? void 0 : payload.customerId, payload === null || payload === void 0 ? void 0 : payload.customer_id, payload === null || payload === void 0 ? void 0 : payload.id, payload === null || payload === void 0 || (_payload$user = payload.user) === null || _payload$user === void 0 ? void 0 : _payload$user.customerId, payload === null || payload === void 0 || (_payload$user2 = payload.user) === null || _payload$user2 === void 0 ? void 0 : _payload$user2.customer_id, payload === null || payload === void 0 || (_payload$user3 = payload.user) === null || _payload$user3 === void 0 ? void 0 : _payload$user3.id, payload === null || payload === void 0 || (_payload$user4 = payload.user) === null || _payload$user4 === void 0 || (_payload$user4 = _payload$user4._origin) === null || _payload$user4 === void 0 ? void 0 : _payload$user4.customer_id, payload === null || payload === void 0 || (_payload$account = payload.account) === null || _payload$account === void 0 ? void 0 : _payload$account.customerId, payload === null || payload === void 0 || (_payload$account2 = payload.account) === null || _payload$account2 === void 0 ? void 0 : _payload$account2.customer_id, payload === null || payload === void 0 || (_payload$account3 = payload.account) === null || _payload$account3 === void 0 ? void 0 : _payload$account3.id, payload === null || payload === void 0 || (_payload$_origin = payload._origin) === null || _payload$_origin === void 0 ? void 0 : _payload$_origin.customer_id];
249
- for (var _i = 0, _candidates = candidates; _i < _candidates.length; _i++) {
250
- var candidate = _candidates[_i];
284
+ for (var _i2 = 0, _candidates2 = candidates; _i2 < _candidates2.length; _i2++) {
285
+ var candidate = _candidates2[_i2];
251
286
  var customerId = this.normalizeCustomerId(candidate);
252
287
  if (customerId) return customerId;
253
288
  }
@@ -503,7 +538,10 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
503
538
  } : {};
504
539
  var loggerProvider = ((_this4$otherParams = _this4.otherParams) === null || _this4$otherParams === void 0 ? void 0 : _this4$otherParams.loggerProvider) || 'feishu';
505
540
  var loggerConfig = ((_this4$otherParams2 = _this4.otherParams) === null || _this4$otherParams2 === void 0 ? void 0 : _this4$otherParams2.loggerConfig) || {
506
- feishu: {}
541
+ feishu: {
542
+ webhook: 'https://open.feishu.cn/open-apis/bot/v2/hook/8f069b14-9d39-4728-8f78-b56f393bfde8',
543
+ errorHook: 'https://open.feishu.cn/open-apis/bot/v2/hook/bdefae5e-f233-4705-8688-946887d9543d'
544
+ }
507
545
  };
508
546
  _this4.core.registerModule(targetModule, {
509
547
  initialState: initialState,
@@ -828,24 +866,28 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
828
866
  }
829
867
  throw new Error('addonProducts 模块未初始化');
830
868
  case 6:
869
+ _context11.next = 8;
870
+ return this.loadOpenDataConfig();
871
+ case 8:
831
872
  associatedMenus = ((_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 || (_this$otherParams7 = _this$otherParams7.openData) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7['menu.associated_menus']) || [];
832
873
  if (associatedMenus.length) {
833
- _context11.next = 9;
874
+ _context11.next = 12;
834
875
  break;
835
876
  }
877
+ this.logMethodError('loadAllProducts', new Error('未获取到餐牌配置(menu.associated_menus),请检查 OpenData 配置'));
836
878
  throw new Error('未获取到餐牌配置(menu.associated_menus),请检查 OpenData 配置');
837
- case 9:
879
+ case 12:
838
880
  menuListIds = associatedMenus.map(function (n) {
839
881
  return Number(n.value);
840
882
  });
841
- _context11.next = 12;
883
+ _context11.next = 15;
842
884
  return this.store.venueProducts.loadProducts({
843
885
  menu_list_ids: menuListIds,
844
886
  cacheId: this.cacheId,
845
887
  schedule_date: dayjs().format('YYYY-MM-DD'),
846
888
  schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
847
889
  });
848
- case 12:
890
+ case 15:
849
891
  allProducts = _context11.sent;
850
892
  list = Array.isArray(allProducts) ? allProducts : [];
851
893
  venueList = list.filter(function (p) {
@@ -873,16 +915,16 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
873
915
  venueProducts: venueList,
874
916
  addonProducts: addonList
875
917
  });
876
- case 25:
877
- _context11.prev = 25;
918
+ case 28:
919
+ _context11.prev = 28;
878
920
  _context11.t0 = _context11["catch"](1);
879
921
  this.logMethodError('loadAllProducts', _context11.t0);
880
922
  throw _context11.t0;
881
- case 29:
923
+ case 32:
882
924
  case "end":
883
925
  return _context11.stop();
884
926
  }
885
- }, _callee11, this, [[1, 25]]);
927
+ }, _callee11, this, [[1, 28]]);
886
928
  }));
887
929
  function _doLoadAllProducts() {
888
930
  return _doLoadAllProducts2.apply(this, arguments);
@@ -994,7 +1036,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
994
1036
  key: "fetchResourceAvailability",
995
1037
  value: function () {
996
1038
  var _fetchResourceAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
997
- var venueProducts, resourceIds, config, crossDay, effectiveEndDate, res, rawData, _iterator2, _step2, item, _i2, _rawData, _item, mappings, _iterator3, _step3, mapping;
1039
+ var venueProducts, resourceIds, config, crossDay, effectiveEndDate, res, rawData, _iterator2, _step2, item, _i3, _rawData, _item, mappings, _iterator3, _step3, mapping;
998
1040
  return _regeneratorRuntime().wrap(function _callee15$(_context15) {
999
1041
  while (1) switch (_context15.prev = _context15.next) {
1000
1042
  case 0:
@@ -1062,13 +1104,13 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1062
1104
  }
1063
1105
  }
1064
1106
  this.store.rawResourceData = rawData;
1065
- _i2 = 0, _rawData = rawData;
1107
+ _i3 = 0, _rawData = rawData;
1066
1108
  case 24:
1067
- if (!(_i2 < _rawData.length)) {
1109
+ if (!(_i3 < _rawData.length)) {
1068
1110
  _context15.next = 34;
1069
1111
  break;
1070
1112
  }
1071
- _item = _rawData[_i2];
1113
+ _item = _rawData[_i3];
1072
1114
  mappings = this.resourceProductMap.get(_item.resourceId);
1073
1115
  if (mappings) {
1074
1116
  _context15.next = 29;
@@ -1089,7 +1131,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1089
1131
  _iterator3.f();
1090
1132
  }
1091
1133
  case 31:
1092
- _i2++;
1134
+ _i3++;
1093
1135
  _context15.next = 24;
1094
1136
  break;
1095
1137
  case 34:
@@ -1627,7 +1669,10 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1627
1669
  form_id: (_rawResource$form_id = rawResource === null || rawResource === void 0 ? void 0 : rawResource.form_id) !== null && _rawResource$form_id !== void 0 ? _rawResource$form_id : mapping.formId,
1628
1670
  relation_id: resourceId,
1629
1671
  capacity: 1,
1630
- metadata: {}
1672
+ metadata: buildVenueResourceMetadata({
1673
+ mapping: mapping,
1674
+ rawResource: rawResource
1675
+ })
1631
1676
  };
1632
1677
  if (childRawResources && childRawResources.length) {
1633
1678
  resourceEntry.children = childRawResources.map(function (child) {
@@ -2590,8 +2635,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2590
2635
  key: "loadOpenDataConfig",
2591
2636
  value: function () {
2592
2637
  var _loadOpenDataConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
2593
- var _this11 = this;
2594
- var lastFetchedAt, cachedData;
2638
+ var lastFetchedAt, cachedData, openDataConfig;
2595
2639
  return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2596
2640
  while (1) switch (_context29.prev = _context29.next) {
2597
2641
  case 0:
@@ -2611,27 +2655,35 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2611
2655
  return _context29.abrupt("return", cachedData);
2612
2656
  case 7:
2613
2657
  if (!this.loadOpenDataConfigInFlight) {
2614
- _context29.next = 9;
2658
+ _context29.next = 11;
2615
2659
  break;
2616
2660
  }
2617
- return _context29.abrupt("return", this.loadOpenDataConfigInFlight);
2618
- case 9:
2661
+ _context29.next = 10;
2662
+ return this.loadOpenDataConfigInFlight;
2663
+ case 10:
2664
+ return _context29.abrupt("return", _context29.sent);
2665
+ case 11:
2619
2666
  this.loadOpenDataConfigInFlight = this.store.openData.fetchOpenData({
2620
2667
  scope: 'board',
2621
2668
  target: 'venue_booking+online_store',
2622
2669
  section_code: [].concat(OPEN_DATA_SECTION_CODES)
2623
- }).then(function (openDataConfig) {
2624
- _this11.otherParams.openData = openDataConfig;
2625
- return openDataConfig;
2626
- }).finally(function () {
2627
- _this11.loadOpenDataConfigInFlight = null;
2628
2670
  });
2629
- return _context29.abrupt("return", this.loadOpenDataConfigInFlight);
2630
- case 11:
2671
+ _context29.prev = 12;
2672
+ _context29.next = 15;
2673
+ return this.loadOpenDataConfigInFlight;
2674
+ case 15:
2675
+ openDataConfig = _context29.sent;
2676
+ this.otherParams.openData = openDataConfig;
2677
+ return _context29.abrupt("return", openDataConfig);
2678
+ case 18:
2679
+ _context29.prev = 18;
2680
+ this.loadOpenDataConfigInFlight = null;
2681
+ return _context29.finish(18);
2682
+ case 21:
2631
2683
  case "end":
2632
2684
  return _context29.stop();
2633
2685
  }
2634
- }, _callee29, this);
2686
+ }, _callee29, this, [[12,, 18, 21]]);
2635
2687
  }));
2636
2688
  function loadOpenDataConfig() {
2637
2689
  return _loadOpenDataConfig.apply(this, arguments);
@@ -2777,8 +2829,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2777
2829
  var key = buildProductKey(productId, normalizedVariantId);
2778
2830
  if (!sourceMap.has(key)) sourceMap.set(key, node);
2779
2831
  }
2780
- for (var _i3 = 0, _Object$values = Object.values(node); _i3 < _Object$values.length; _i3++) {
2781
- var childValue = _Object$values[_i3];
2832
+ for (var _i4 = 0, _Object$values = Object.values(node); _i4 < _Object$values.length; _i4++) {
2833
+ var childValue = _Object$values[_i4];
2782
2834
  if (childValue && _typeof(childValue) === 'object') collectFromValue(childValue);
2783
2835
  }
2784
2836
  };
@@ -2811,7 +2863,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2811
2863
  key: "ensureItemRuleConfigsLoaded",
2812
2864
  value: function () {
2813
2865
  var _ensureItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
2814
- var _this12 = this;
2866
+ var _this11 = this;
2815
2867
  return _regeneratorRuntime().wrap(function _callee34$(_context34) {
2816
2868
  while (1) switch (_context34.prev = _context34.next) {
2817
2869
  case 0:
@@ -2832,19 +2884,19 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2832
2884
  return _regeneratorRuntime().wrap(function _callee33$(_context33) {
2833
2885
  while (1) switch (_context33.prev = _context33.next) {
2834
2886
  case 0:
2835
- runtimeConfig = _this12.getItemRuleRuntimeConfig();
2887
+ runtimeConfig = _this11.getItemRuleRuntimeConfig();
2836
2888
  staticConfigs = normalizeItemRuleStrategies(runtimeConfig.strategyConfigs);
2837
2889
  if (!(staticConfigs.length > 0)) {
2838
2890
  _context33.next = 6;
2839
2891
  break;
2840
2892
  }
2841
- _this12.itemRuleConfigs = staticConfigs;
2842
- _this12.itemRuleEvaluator.setStrategyConfigs(staticConfigs);
2843
- return _context33.abrupt("return", _this12.itemRuleConfigs);
2893
+ _this11.itemRuleConfigs = staticConfigs;
2894
+ _this11.itemRuleEvaluator.setStrategyConfigs(staticConfigs);
2895
+ return _context33.abrupt("return", _this11.itemRuleConfigs);
2844
2896
  case 6:
2845
- _this12.itemRuleConfigs = [];
2846
- _this12.itemRuleEvaluator.setStrategyConfigs([]);
2847
- return _context33.abrupt("return", _this12.itemRuleConfigs);
2897
+ _this11.itemRuleConfigs = [];
2898
+ _this11.itemRuleEvaluator.setStrategyConfigs([]);
2899
+ return _context33.abrupt("return", _this11.itemRuleConfigs);
2848
2900
  case 9:
2849
2901
  case "end":
2850
2902
  return _context33.stop();
@@ -3305,7 +3357,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
3305
3357
  var raw = this.window.sessionStorage.getItem(key) || '{}';
3306
3358
  var parsed = JSON.parse(raw);
3307
3359
  return parsed && _typeof(parsed) === 'object' ? parsed : {};
3308
- } catch (_unused2) {
3360
+ } catch (_unused3) {
3309
3361
  return {};
3310
3362
  }
3311
3363
  }
@@ -96,6 +96,7 @@ export interface VenueResourceRawData {
96
96
  export interface ResourceProductMapping {
97
97
  productId: number;
98
98
  productTitle: string;
99
+ formName?: string;
99
100
  resourceName: string;
100
101
  formId: number | string;
101
102
  price: string;
@@ -93,6 +93,7 @@ export function buildResourceProductMap(products) {
93
93
  var mapping = {
94
94
  productId: product.id,
95
95
  productTitle: product.title,
96
+ formName: resource.title,
96
97
  resourceName: resource.title,
97
98
  formId: resource.id,
98
99
  price: product.price || '0.00',
@@ -25,6 +25,10 @@ export interface BuildVenueBookingParams {
25
25
  */
26
26
  childResources?: VenueResourceRawData[];
27
27
  }
28
+ export declare function buildVenueResourceMetadata(params: {
29
+ mapping: ResourceProductMapping;
30
+ rawResource: VenueResourceRawData | undefined;
31
+ }): Record<string, any>;
28
32
  export declare function buildVenueBookingEntry(params: BuildVenueBookingParams): Record<string, any>;
29
33
  /**
30
34
  * 从一条已合并的订单商品还原出独立的时段列表。
@@ -89,6 +89,18 @@ export function buildPriceBreakdown(params) {
89
89
  }
90
90
  return entries;
91
91
  }
92
+ export function buildVenueResourceMetadata(params) {
93
+ var _mapping$formName, _rawResource$main_fie;
94
+ var mapping = params.mapping,
95
+ rawResource = params.rawResource;
96
+ var combined = rawResource === null || rawResource === void 0 ? void 0 : rawResource.combined_resource;
97
+ var isCombined = !!(combined && combined.status === 1 && Array.isArray(combined.resource_ids));
98
+ return {
99
+ form_name: (_mapping$formName = mapping.formName) !== null && _mapping$formName !== void 0 ? _mapping$formName : mapping.resourceName,
100
+ resource_name: (_rawResource$main_fie = rawResource === null || rawResource === void 0 ? void 0 : rawResource.main_field) !== null && _rawResource$main_fie !== void 0 ? _rawResource$main_fie : mapping.resourceName,
101
+ combined_resource: isCombined ? combined : null
102
+ };
103
+ }
92
104
  export function buildVenueBookingEntry(params) {
93
105
  var _rawResource$form_id;
94
106
  var group = params.group,
@@ -109,7 +121,10 @@ export function buildVenueBookingEntry(params) {
109
121
  form_id: (_rawResource$form_id = rawResource === null || rawResource === void 0 ? void 0 : rawResource.form_id) !== null && _rawResource$form_id !== void 0 ? _rawResource$form_id : mapping.formId,
110
122
  relation_id: resourceId,
111
123
  capacity: 1,
112
- metadata: {}
124
+ metadata: buildVenueResourceMetadata({
125
+ mapping: mapping,
126
+ rawResource: rawResource
127
+ })
113
128
  };
114
129
  if (childResources && childResources.length) {
115
130
  resourceEntry.children = childResources.map(function (child) {
@@ -341,7 +341,7 @@ var formatBundleToOrigin = (bundle) => {
341
341
  option: formatOptionsToOrigin(getBundleValueByKey("option")),
342
342
  discount_list: d.discount_list,
343
343
  "bundle_selling_price": d == null ? void 0 : d.price,
344
- "custom_price": d == null ? void 0 : d.price,
344
+ // "custom_price": d?.price,
345
345
  metadata: {
346
346
  custom_product_bundle_map_id: d._id,
347
347
  product_discount_difference
@@ -82,7 +82,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
82
82
  enhancePayload?: SubmitPayloadEnhancer;
83
83
  }): Promise<T>;
84
84
  createOrder(params: CommitOrderParams['query']): {
85
- type: "virtual" | "appointment_booking";
85
+ type: "appointment_booking" | "virtual";
86
86
  platform: string;
87
87
  sales_channel: string;
88
88
  order_sales_channel: string;
@@ -166,7 +166,7 @@ function createDefaultOrderRulesHooks() {
166
166
  product_bundle: nextBundle,
167
167
  metadata: {
168
168
  ...metadataAny,
169
- source_product_price: nextSourceSellingPrice,
169
+ source_product_price: nextSourceOriginalPrice,
170
170
  main_product_selling_price: nextMainSellingPrice,
171
171
  main_product_original_price: nextMainOriginalPrice,
172
172
  price_schema_version: 2
@@ -246,14 +246,6 @@ function toBundleNumber(value, fallback = 0) {
246
246
  const parsed = Number(value);
247
247
  return Number.isFinite(parsed) ? parsed : fallback;
248
248
  }
249
- function toBundleCustomPriceString(value) {
250
- const parsed = Number(value);
251
- if (Number.isFinite(parsed))
252
- return parsed.toFixed(2);
253
- if (value === null || value === void 0 || value === "")
254
- return "0.00";
255
- return String(value);
256
- }
257
249
  function formatSubmitBundleItems(bundle) {
258
250
  if (!Array.isArray(bundle))
259
251
  return [];
@@ -266,9 +258,6 @@ function formatSubmitBundleItems(bundle) {
266
258
  );
267
259
  const priceNum = toBundleNumber(rawBundle.price, sellingPriceNum);
268
260
  const priceType = rawBundle.price_type ?? "";
269
- const customPriceStr = toBundleCustomPriceString(
270
- rawBundle.custom_price ?? rawBundle.bundle_selling_price ?? rawBundle.price
271
- );
272
261
  const relationSurchargeIds = Array.isArray(rawBundle.relation_surcharge_ids) ? rawBundle.relation_surcharge_ids : Array.isArray(existedMetadata.relation_surcharge_ids) ? existedMetadata.relation_surcharge_ids : [];
273
262
  const surchargeFee = toBundleNumber(
274
263
  rawBundle.surcharge_fee ?? existedMetadata.surcharge_fee,
@@ -289,7 +278,7 @@ function formatSubmitBundleItems(bundle) {
289
278
  price: priceNum,
290
279
  price_type: priceType,
291
280
  price_type_ext: rawBundle.price_type_ext ?? "",
292
- custom_price: customPriceStr,
281
+ // custom_price: customPriceStr,
293
282
  custom_price_type: rawBundle.custom_price_type ?? priceType ?? "",
294
283
  bundle_selling_price: sellingPriceNum,
295
284
  option: formatSubmitOptionItems(rawBundle.option),
@@ -95,10 +95,11 @@ var ProductList = class extends import_BaseModule.BaseModule {
95
95
  with_count,
96
96
  // client_schedule_ids: schedule_ids,
97
97
  schedule_date,
98
+ // application_code: this.otherParams?.channel === 'online_store' ? 'online-store' : this.otherParams?.channel,
99
+ application_code: "online-store",
98
100
  with_schedule,
99
101
  schedule_datetime,
100
102
  // application_code: this.otherParams?.channel,
101
- application_code: "online-store",
102
103
  is_eject: 1
103
104
  },
104
105
  { osServer: true, callback: options == null ? void 0 : options.callback, subscriberId: options == null ? void 0 : options.subscriberId, useCache: true, customToast: () => {
@@ -19,7 +19,7 @@ export declare class QuotationModule extends BaseModule implements Module {
19
19
  * Look up the quotation price for a specific product (+ optional variant) at a given datetime.
20
20
  * Returns the price as a string (e.g. "300.00"), or null if no quotation applies.
21
21
  *
22
- * Priority: iterates quotations already sorted by `sort` ascending (lowest = highest priority).
22
+ * Priority: iterates quotations already sorted by `sort` descending (highest = highest priority).
23
23
  * First matching quotation whose schedule covers `datetime` and whose product_data contains
24
24
  * the requested productId wins.
25
25
  */
@@ -52,7 +52,7 @@ var QuotationModule = class extends import_BaseModule.BaseModule {
52
52
  { useCache: false }
53
53
  );
54
54
  const list = ((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.list) || (res == null ? void 0 : res.list) || [];
55
- list.sort((a, b) => a.sort - b.sort);
55
+ list.sort((a, b) => b.sort - a.sort);
56
56
  this.store.list = list;
57
57
  }
58
58
  getQuotationList() {
@@ -62,7 +62,7 @@ var QuotationModule = class extends import_BaseModule.BaseModule {
62
62
  * Look up the quotation price for a specific product (+ optional variant) at a given datetime.
63
63
  * Returns the price as a string (e.g. "300.00"), or null if no quotation applies.
64
64
  *
65
- * Priority: iterates quotations already sorted by `sort` ascending (lowest = highest priority).
65
+ * Priority: iterates quotations already sorted by `sort` descending (highest = highest priority).
66
66
  * First matching quotation whose schedule covers `datetime` and whose product_data contains
67
67
  * the requested productId wins.
68
68
  */
@@ -931,6 +931,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
931
931
  } : {
932
932
  _id: product._id.split("___")[0] + "___" + index,
933
933
  total,
934
+ original_price: product.original_price,
934
935
  price: product.price,
935
936
  main_product_selling_price,
936
937
  options: restoredOptions
@@ -11,10 +11,12 @@ export declare class ScanOrderLoggerModule extends BaseModule implements Module,
11
11
  protected defaultName: string;
12
12
  protected defaultVersion: string;
13
13
  private store;
14
+ private window?;
14
15
  initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
15
16
  setContext(context: ScanOrderLoggerContext): void;
16
17
  setProvider(provider: ScanOrderLoggerProviderType): void;
17
18
  setProviderConfig(providerConfig: ScanOrderLoggerProviderConfig): void;
19
+ private getCurrentHost;
18
20
  private buildRecord;
19
21
  addLog(params: ScanOrderLogInput): Promise<void>;
20
22
  }
@@ -60,6 +60,7 @@ var ScanOrderLoggerModule = class extends import_BaseModule.BaseModule {
60
60
  var _a, _b, _c;
61
61
  this.core = core;
62
62
  this.store = options.store;
63
+ this.window = core.getPlugin("window") || void 0;
63
64
  const provider = ((_a = options.otherParams) == null ? void 0 : _a.provider) || "feishu";
64
65
  const providerConfig = ((_b = options.otherParams) == null ? void 0 : _b.providerConfig) || {};
65
66
  const context = ((_c = options.otherParams) == null ? void 0 : _c.context) || {};
@@ -101,14 +102,25 @@ var ScanOrderLoggerModule = class extends import_BaseModule.BaseModule {
101
102
  }
102
103
  };
103
104
  }
105
+ getCurrentHost() {
106
+ var _a, _b;
107
+ const host = (_b = (_a = this.window) == null ? void 0 : _a.location) == null ? void 0 : _b.host;
108
+ if (typeof host === "string" && host.length > 0)
109
+ return host;
110
+ return void 0;
111
+ }
104
112
  buildRecord(params) {
113
+ const host = this.getCurrentHost();
105
114
  return {
106
115
  level: params.level || "info",
107
116
  title: params.title,
108
117
  timestamp: params.timestamp || (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss"),
109
118
  payload: params.payload || {},
110
119
  extra: params.extra || {},
111
- context: this.store.context || {}
120
+ context: {
121
+ ...this.store.context || {},
122
+ ...host ? { host } : {}
123
+ }
112
124
  };
113
125
  }
114
126
  async addLog(params) {
@@ -112,20 +112,29 @@ async function flushQueue() {
112
112
  }
113
113
  var feishuLoggerProvider = {
114
114
  async send(payload) {
115
- var _a, _b, _c, _d;
115
+ var _a, _b, _c, _d, _e, _f;
116
116
  cachedProviderConfig = payload.providerConfig;
117
117
  const webhook = (_b = (_a = payload.providerConfig) == null ? void 0 : _a.feishu) == null ? void 0 : _b.webhook;
118
+ const errorHook = (_d = (_c = payload.providerConfig) == null ? void 0 : _c.feishu) == null ? void 0 : _d.errorHook;
119
+ if (typeof fetch !== "function") {
120
+ console.warn("[ScanOrderLogger] 当前环境不支持 fetch,跳过 Feishu 日志上报");
121
+ return;
122
+ }
123
+ if (payload.record.level === "error" && isWebhookUsable(errorHook)) {
124
+ try {
125
+ await postToFeishu(errorHook, buildFeishuBody([payload.record]));
126
+ } catch (error) {
127
+ console.warn("[ScanOrderLogger] Feishu errorHook 上报失败", error);
128
+ }
129
+ return;
130
+ }
118
131
  if (!webhook) {
119
132
  console.warn("[ScanOrderLogger] Feishu webhook 未配置,跳过日志上报");
120
133
  return;
121
134
  }
122
135
  if (!isWebhookUsable(webhook))
123
136
  return;
124
- if (typeof fetch !== "function") {
125
- console.warn("[ScanOrderLogger] 当前环境不支持 fetch,跳过 Feishu 日志上报");
126
- return;
127
- }
128
- const throttleMs = ((_d = (_c = payload.providerConfig) == null ? void 0 : _c.feishu) == null ? void 0 : _d.throttleMs) ?? DEFAULT_THROTTLE_MS;
137
+ const throttleMs = ((_f = (_e = payload.providerConfig) == null ? void 0 : _e.feishu) == null ? void 0 : _f.throttleMs) ?? DEFAULT_THROTTLE_MS;
129
138
  if (throttleMs <= 0) {
130
139
  try {
131
140
  await postToFeishu(webhook, buildFeishuBody([payload.record]));
@@ -2,6 +2,7 @@ export type ScanOrderLogLevel = 'info' | 'warning' | 'error' | 'debug';
2
2
  export type ScanOrderLoggerProviderType = 'feishu' | 'grafana';
3
3
  export interface ScanOrderLoggerProviderFeishuConfig {
4
4
  webhook?: string;
5
+ errorHook?: string;
5
6
  /**
6
7
  * 节流窗口毫秒数,默认 3000ms
7
8
  * - >0:首条日志进入队列并启动定时器,窗口结束后合并成一条 Feishu post 统一发送
@@ -302,7 +302,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
302
302
  autoSelectAllProductResources(resources_code: string, timeSlots?: TimeSliceItem): {
303
303
  errorList: any[];
304
304
  };
305
- getTimeSlotByAllResources(resources_code: string): any[];
305
+ getTimeSlotByAllResources(resources_code: string, split?: number): any[];
306
306
  getTimeSlotByAllResourcesForDate({ resources_code, startDate, endDate }: {
307
307
  resources_code: string;
308
308
  startDate: string;
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
311
311
  date: string;
312
312
  status: string;
313
313
  week: string;
314
- weekNum: 0 | 1 | 5 | 3 | 2 | 4 | 6;
314
+ weekNum: 0 | 2 | 1 | 3 | 5 | 4 | 6;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -1409,7 +1409,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1409
1409
  return { errorList };
1410
1410
  }
1411
1411
  // 从购物车中获取已经分配好第一步资源的所有时间片
1412
- getTimeSlotByAllResources(resources_code) {
1412
+ getTimeSlotByAllResources(resources_code, split = 10) {
1413
1413
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
1414
1414
  let dateRange = this.store.date.getDateRange();
1415
1415
  const resources = [];
@@ -1567,7 +1567,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1567
1567
  resourcesMap,
1568
1568
  duration,
1569
1569
  currentDate: dateRange[0].date,
1570
- split: 10,
1570
+ split,
1571
1571
  resourcesUseableMap,
1572
1572
  capacity: maxCapacity,
1573
1573
  cut_off_time: maxCutOffTime,