@pisell/pisellos 2.2.321 → 2.2.323

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 (35) hide show
  1. package/dist/modules/Order/index.d.ts +1 -1
  2. package/dist/modules/Order/utils.js +12 -1
  3. package/dist/modules/Product/index.d.ts +1 -1
  4. package/dist/modules/Product/types.d.ts +5 -0
  5. package/dist/server/index.js +3 -1
  6. package/dist/server/modules/order/types.d.ts +2 -0
  7. package/dist/server/modules/order/utils/filterOrders.js +20 -0
  8. package/dist/solution/BaseSales/index.d.ts +1 -0
  9. package/dist/solution/BaseSales/index.js +298 -209
  10. package/dist/solution/BaseSales/types.d.ts +3 -0
  11. package/dist/solution/BaseSales/utils/posDurationPricing.d.ts +21 -0
  12. package/dist/solution/BaseSales/utils/posDurationPricing.js +174 -0
  13. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +2 -0
  14. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +8 -8
  15. package/dist/solution/BookingByStep/index.d.ts +3 -3
  16. package/dist/solution/BookingTicket/index.d.ts +1 -13
  17. package/dist/solution/UnifiedBookingSales/index.js +34 -16
  18. package/lib/modules/Order/index.d.ts +1 -1
  19. package/lib/modules/Order/utils.js +13 -0
  20. package/lib/modules/Product/index.d.ts +1 -1
  21. package/lib/modules/Product/types.d.ts +5 -0
  22. package/lib/server/index.js +4 -1
  23. package/lib/server/modules/order/types.d.ts +2 -0
  24. package/lib/server/modules/order/utils/filterOrders.js +18 -0
  25. package/lib/solution/BaseSales/index.d.ts +1 -0
  26. package/lib/solution/BaseSales/index.js +95 -36
  27. package/lib/solution/BaseSales/types.d.ts +3 -0
  28. package/lib/solution/BaseSales/utils/posDurationPricing.d.ts +21 -0
  29. package/lib/solution/BaseSales/utils/posDurationPricing.js +133 -0
  30. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +2 -0
  31. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -1
  32. package/lib/solution/BookingByStep/index.d.ts +3 -3
  33. package/lib/solution/BookingTicket/index.d.ts +1 -13
  34. package/lib/solution/UnifiedBookingSales/index.js +23 -1
  35. package/package.json +1 -1
@@ -58,6 +58,7 @@ import { isCustomerUserPlatform, normalizeRuntimePlatform } from "../../utils/pl
58
58
  import { QuotationModule } from "../../modules/Quotation";
59
59
  import { transformBaseProductToOrderProduct as _transformBaseProductToOrderProduct } from "./utils/transformBaseProductToOrderProduct";
60
60
  import { calculateBaseSalesProductBookingPrice } from "./utils/quotationPrice";
61
+ import { buildPosDurationPricingPlan, combinePosDurationPrices, durationPricingUnavailable, forEachPriceQueryGroup, hasAppliedPosDurationPricing, resolveDurationPricingProduct, usesPosDurationPricing } from "./utils/posDurationPricing";
61
62
  var SERVER_ORDER_CHANGED_EVENT = 'order:onOrdersChanged';
62
63
  var PAYMENT_METHODS_CHANGED_EVENT = 'payment:onPaymentMethodsChanged';
63
64
  var OS_FULFILLMENT_REF_MODE_FIELD = '_os_fulfillment_ref_mode';
@@ -1524,8 +1525,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1524
1525
  productsById = _context10.sent;
1525
1526
  shouldAlignSelectedVariantPrice = handledByOsServer && this.preferAuthoritativeProductQueryPrice();
1526
1527
  return _context10.abrupt("return", productIds.map(function (productId, index) {
1527
- var _authoritativeProduct;
1528
+ var _this7$otherParams, _authoritativeProduct;
1528
1529
  var authoritativeProduct = productId === null ? null : productsById.get(productId) || null;
1530
+ if (authoritativeProduct && normalizeRuntimePlatform((_this7$otherParams = _this7.otherParams) === null || _this7$otherParams === void 0 ? void 0 : _this7$otherParams.platform) === 'pos' && (params.strictDurationPricing || usesPosDurationPricing(authoritativeProduct) || hasAppliedPosDurationPricing(selectedProducts[index]))) {
1531
+ return resolveDurationPricingProduct(authoritativeProduct, selectedProducts[index]);
1532
+ }
1529
1533
  if (!shouldAlignSelectedVariantPrice || !authoritativeProduct) return authoritativeProduct;
1530
1534
  var selectedProduct = selectedProducts[index];
1531
1535
  var selectedVariantId = _this7.getSelectedProductVariantId(selectedProduct);
@@ -1698,6 +1702,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1698
1702
  });
1699
1703
  });
1700
1704
  return _objectSpread(_objectSpread(_objectSpread({}, product), authoritativeProduct), {}, {
1705
+ // An omitted current configuration clears a previous catalog/order snapshot.
1706
+ pricing_method: authoritativeProduct.pricing_method,
1701
1707
  id: (_product$id = product.id) !== null && _product$id !== void 0 ? _product$id : authoritativeProduct.id,
1702
1708
  product_id: (_ref24 = (_product$product_id3 = product.product_id) !== null && _product$product_id3 !== void 0 ? _product$product_id3 : authoritativeProduct.product_id) !== null && _ref24 !== void 0 ? _ref24 : authoritativeProduct.id,
1703
1709
  product_variant_id: (_ref25 = (_product$product_vari2 = product.product_variant_id) !== null && _product$product_vari2 !== void 0 ? _product$product_vari2 : authoritativeProduct.product_variant_id) !== null && _ref25 !== void 0 ? _ref25 : 0,
@@ -6899,49 +6905,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6899
6905
  key: "calculateProductBookingPrice",
6900
6906
  value: function () {
6901
6907
  var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(params) {
6902
- var _params$customer_id;
6903
- var useCustomerUserPricing, quotation, customerId, channel, _yield$this$resolvePr, _yield$this$resolvePr2, authoritativeProduct, product;
6908
+ var _yield$this$calculate, _yield$this$calculate2, result;
6904
6909
  return _regeneratorRuntime().wrap(function _callee67$(_context67) {
6905
6910
  while (1) switch (_context67.prev = _context67.next) {
6906
6911
  case 0:
6907
- useCustomerUserPricing = this.isCustomerUserPriceQuery();
6908
- quotation = useCustomerUserPricing ? undefined : this.store.quotation;
6909
- customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : this.getCurrentOrderCustomerId();
6910
- _context67.next = 5;
6911
- return this.prepareProductPriceQueryContext(customerId);
6912
- case 5:
6913
- channel = this.getPriceQueryChannel(params.channel);
6914
- _context67.next = 8;
6915
- return this.resolveProductsForPriceQuery({
6916
- priceQueries: [params],
6917
- schedule: this.getPriceQuerySchedule(params),
6918
- customerId: customerId,
6919
- channel: channel
6920
- });
6921
- case 8:
6922
- _yield$this$resolvePr = _context67.sent;
6923
- _yield$this$resolvePr2 = _slicedToArray(_yield$this$resolvePr, 1);
6924
- authoritativeProduct = _yield$this$resolvePr2[0];
6925
- product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
6926
- if (useCustomerUserPricing) {
6927
- _context67.next = 15;
6928
- break;
6929
- }
6930
- _context67.next = 15;
6931
- return this.loadQuotationForPriceQuery({
6932
- quotation: quotation,
6933
- customer_id: customerId,
6934
- channel: channel
6935
- });
6936
- case 15:
6937
- return _context67.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
6938
- channel: channel,
6939
- product: product,
6940
- fallback_price: authoritativeProduct ? undefined : params.fallback_price,
6941
- customer_id: customerId,
6942
- quotation: authoritativeProduct && this.preferAuthoritativeProductQueryPrice() ? undefined : quotation
6943
- })));
6944
- case 16:
6912
+ _context67.next = 2;
6913
+ return this.calculateProductBookingPrices([params]);
6914
+ case 2:
6915
+ _yield$this$calculate = _context67.sent;
6916
+ _yield$this$calculate2 = _slicedToArray(_yield$this$calculate, 1);
6917
+ result = _yield$this$calculate2[0];
6918
+ return _context67.abrupt("return", result);
6919
+ case 6:
6945
6920
  case "end":
6946
6921
  return _context67.stop();
6947
6922
  }
@@ -7029,23 +7004,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7029
7004
  return shouldRecalculate;
7030
7005
  }
7031
7006
  }, {
7032
- key: "calculateProductBookingPrices",
7007
+ key: "resolveProductBookingPriceGroups",
7033
7008
  value: function () {
7034
- var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(paramsList) {
7035
- var _this22 = this;
7036
- var useCustomerUserPricing, quotation, currentOrderCustomerId, resolvedChannels, authoritativeProducts, groups, quotationContexts;
7009
+ var _resolveProductBookingPriceGroups = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(paramsList, currentOrderCustomerId) {
7010
+ var _this22 = this,
7011
+ _this$otherParams43;
7012
+ var strictDurationPricing,
7013
+ resolvedChannels,
7014
+ authoritativeProducts,
7015
+ groups,
7016
+ _args69 = arguments;
7037
7017
  return _regeneratorRuntime().wrap(function _callee69$(_context69) {
7038
7018
  while (1) switch (_context69.prev = _context69.next) {
7039
7019
  case 0:
7040
- if (paramsList.length) {
7041
- _context69.next = 2;
7042
- break;
7043
- }
7044
- return _context69.abrupt("return", []);
7045
- case 2:
7046
- useCustomerUserPricing = this.isCustomerUserPriceQuery();
7047
- quotation = useCustomerUserPricing ? undefined : this.store.quotation;
7048
- currentOrderCustomerId = this.getCurrentOrderCustomerId();
7020
+ strictDurationPricing = _args69.length > 2 && _args69[2] !== undefined ? _args69[2] : false;
7049
7021
  resolvedChannels = paramsList.map(function (params) {
7050
7022
  return _this22.getPriceQueryChannel(params.channel);
7051
7023
  });
@@ -7054,10 +7026,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7054
7026
  });
7055
7027
  groups = new Map();
7056
7028
  paramsList.forEach(function (params, index) {
7057
- var _params$customer_id2;
7029
+ var _params$customer_id;
7058
7030
  var schedule = _this22.getPriceQuerySchedule(params);
7059
7031
  var channel = resolvedChannels[index];
7060
- var customerId = (_params$customer_id2 = params.customer_id) !== null && _params$customer_id2 !== void 0 ? _params$customer_id2 : currentOrderCustomerId;
7032
+ var customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : currentOrderCustomerId;
7061
7033
  var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || '', _this22.normalizePriceContextCustomerId(customerId) || ''].join('|');
7062
7034
  var group = groups.get(groupKey) || {
7063
7035
  indices: [],
@@ -7068,8 +7040,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7068
7040
  group.indices.push(index);
7069
7041
  groups.set(groupKey, group);
7070
7042
  });
7071
- _context69.next = 11;
7072
- return Promise.all(Array.from(groups.values()).map( /*#__PURE__*/function () {
7043
+ _context69.next = 7;
7044
+ return forEachPriceQueryGroup(Array.from(groups.values()), /*#__PURE__*/function () {
7073
7045
  var _ref55 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(group) {
7074
7046
  var priceQueries, resolvedProducts;
7075
7047
  return _regeneratorRuntime().wrap(function _callee68$(_context68) {
@@ -7086,7 +7058,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7086
7058
  priceQueries: priceQueries,
7087
7059
  schedule: group.schedule,
7088
7060
  customerId: group.customerId,
7089
- channel: group.channel
7061
+ channel: group.channel,
7062
+ strictDurationPricing: strictDurationPricing
7090
7063
  });
7091
7064
  case 5:
7092
7065
  resolvedProducts = _context68.sent;
@@ -7099,55 +7072,171 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7099
7072
  }
7100
7073
  }, _callee68);
7101
7074
  }));
7102
- return function (_x53) {
7075
+ return function (_x54) {
7103
7076
  return _ref55.apply(this, arguments);
7104
7077
  };
7105
- }()));
7106
- case 11:
7078
+ }(), normalizeRuntimePlatform((_this$otherParams43 = this.otherParams) === null || _this$otherParams43 === void 0 ? void 0 : _this$otherParams43.platform) === 'pos' ? 4 : groups.size);
7079
+ case 7:
7080
+ return _context69.abrupt("return", authoritativeProducts);
7081
+ case 8:
7082
+ case "end":
7083
+ return _context69.stop();
7084
+ }
7085
+ }, _callee69, this);
7086
+ }));
7087
+ function resolveProductBookingPriceGroups(_x52, _x53) {
7088
+ return _resolveProductBookingPriceGroups.apply(this, arguments);
7089
+ }
7090
+ return resolveProductBookingPriceGroups;
7091
+ }()
7092
+ }, {
7093
+ key: "calculateProductBookingPrices",
7094
+ value: function () {
7095
+ var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(paramsList) {
7096
+ var _this$otherParams44,
7097
+ _this23 = this;
7098
+ var useCustomerUserPricing, isPos, quotation, currentOrderCustomerId, resolvedChannels, authoritativeProducts, plans, segmentQueries, segmentQueryIndices, segmentProducts, quotationContexts;
7099
+ return _regeneratorRuntime().wrap(function _callee70$(_context70) {
7100
+ while (1) switch (_context70.prev = _context70.next) {
7101
+ case 0:
7102
+ if (paramsList.length) {
7103
+ _context70.next = 2;
7104
+ break;
7105
+ }
7106
+ return _context70.abrupt("return", []);
7107
+ case 2:
7108
+ useCustomerUserPricing = this.isCustomerUserPriceQuery();
7109
+ isPos = normalizeRuntimePlatform((_this$otherParams44 = this.otherParams) === null || _this$otherParams44 === void 0 ? void 0 : _this$otherParams44.platform) === 'pos';
7110
+ quotation = useCustomerUserPricing ? undefined : this.store.quotation;
7111
+ currentOrderCustomerId = this.getCurrentOrderCustomerId();
7112
+ resolvedChannels = paramsList.map(function (params) {
7113
+ return _this23.getPriceQueryChannel(params.channel);
7114
+ });
7115
+ _context70.next = 9;
7116
+ return this.resolveProductBookingPriceGroups(paramsList, currentOrderCustomerId);
7117
+ case 9:
7118
+ authoritativeProducts = _context70.sent;
7119
+ plans = paramsList.map(function (params, index) {
7120
+ if (!isPos) return null;
7121
+ var product = authoritativeProducts[index];
7122
+ if (!product && (usesPosDurationPricing(params.product) || hasAppliedPosDurationPricing(params.product))) {
7123
+ throw durationPricingUnavailable('The authoritative product is unavailable for duration pricing.');
7124
+ }
7125
+ // Read configuration from the response itself: an omitted field must not inherit an old snapshot.
7126
+ return product && usesPosDurationPricing(product) ? buildPosDurationPricingPlan(params, product) : null;
7127
+ });
7128
+ segmentQueries = [];
7129
+ segmentQueryIndices = plans.map(function (plan, index) {
7130
+ return (plan === null || plan === void 0 ? void 0 : plan.segments.slice(1).map(function (segment) {
7131
+ var queryIndex = segmentQueries.length;
7132
+ segmentQueries.push(_objectSpread(_objectSpread({}, paramsList[index]), {}, {
7133
+ product: _objectSpread(_objectSpread({}, paramsList[index].product), {}, {
7134
+ product_bundle: undefined
7135
+ }),
7136
+ booking: _objectSpread(_objectSpread({}, paramsList[index].booking), {}, {
7137
+ start_date: segment.start.slice(0, 10),
7138
+ start_time: segment.start.slice(11),
7139
+ end_date: segment.end.slice(0, 10),
7140
+ end_time: segment.end.slice(11)
7141
+ }),
7142
+ duration: undefined,
7143
+ fallback_price: undefined
7144
+ }));
7145
+ return queryIndex;
7146
+ })) || [];
7147
+ });
7148
+ _context70.next = 15;
7149
+ return this.resolveProductBookingPriceGroups(segmentQueries, currentOrderCustomerId, true);
7150
+ case 15:
7151
+ segmentProducts = _context70.sent;
7152
+ if (!segmentProducts.some(function (product) {
7153
+ return !product;
7154
+ })) {
7155
+ _context70.next = 18;
7156
+ break;
7157
+ }
7158
+ throw durationPricingUnavailable('An authoritative product is missing for a billing unit.');
7159
+ case 18:
7107
7160
  if (useCustomerUserPricing) {
7108
- _context69.next = 16;
7161
+ _context70.next = 23;
7109
7162
  break;
7110
7163
  }
7111
7164
  quotationContexts = new Map();
7112
7165
  paramsList.forEach(function (params, index) {
7113
- var _params$customer_id3;
7166
+ var _params$customer_id2;
7167
+ if (plans[index]) return;
7114
7168
  var channel = resolvedChannels[index];
7115
7169
  var key = channel || '';
7116
7170
  if (quotationContexts.has(key)) return;
7117
7171
  quotationContexts.set(key, {
7118
7172
  channel: channel,
7119
- customer_id: (_params$customer_id3 = params.customer_id) !== null && _params$customer_id3 !== void 0 ? _params$customer_id3 : currentOrderCustomerId
7173
+ customer_id: (_params$customer_id2 = params.customer_id) !== null && _params$customer_id2 !== void 0 ? _params$customer_id2 : currentOrderCustomerId
7120
7174
  });
7121
7175
  });
7122
- _context69.next = 16;
7176
+ _context70.next = 23;
7123
7177
  return Promise.all(Array.from(quotationContexts.values()).map(function (context) {
7124
- return _this22.loadQuotationForPriceQuery(_objectSpread({
7178
+ return _this23.loadQuotationForPriceQuery(_objectSpread({
7125
7179
  quotation: quotation
7126
7180
  }, context));
7127
7181
  }));
7128
- case 16:
7129
- return _context69.abrupt("return", paramsList.map(function (params, index) {
7130
- var _params$customer_id4;
7182
+ case 23:
7183
+ return _context70.abrupt("return", paramsList.map(function (params, index) {
7184
+ var _params$customer_id3, _authoritativeProduct2, _params$duration;
7131
7185
  var productInput = params.product || {};
7132
7186
  var authoritativeProduct = authoritativeProducts[index];
7133
- var product = _this22.mergeProductForPriceQuery(productInput, authoritativeProduct);
7134
- var customerId = (_params$customer_id4 = params.customer_id) !== null && _params$customer_id4 !== void 0 ? _params$customer_id4 : currentOrderCustomerId;
7187
+ var product = _this23.mergeProductForPriceQuery(productInput, authoritativeProduct);
7188
+ var customerId = (_params$customer_id3 = params.customer_id) !== null && _params$customer_id3 !== void 0 ? _params$customer_id3 : currentOrderCustomerId;
7135
7189
  var channel = resolvedChannels[index];
7136
- return calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
7190
+ var plan = plans[index];
7191
+ if (plan) {
7192
+ var unitProducts = [authoritativeProduct].concat(_toConsumableArray(segmentQueryIndices[index].map(function (queryIndex) {
7193
+ return segmentProducts[queryIndex];
7194
+ })));
7195
+ var prices = unitProducts.map(function (unitProduct, unitIndex) {
7196
+ return calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
7197
+ channel: channel,
7198
+ product: _this23.mergeProductForPriceQuery(unitIndex === 0 ? productInput : _objectSpread(_objectSpread({}, productInput), {}, {
7199
+ product_bundle: undefined
7200
+ }), unitProduct),
7201
+ booking: _objectSpread(_objectSpread({}, params.booking), {}, {
7202
+ start_date: plan.segments[unitIndex].start.slice(0, 10),
7203
+ start_time: plan.segments[unitIndex].start.slice(11)
7204
+ }),
7205
+ duration: undefined,
7206
+ fallback_price: undefined,
7207
+ customer_id: customerId,
7208
+ quotation: undefined
7209
+ }));
7210
+ });
7211
+ return combinePosDurationPrices(plan, prices);
7212
+ }
7213
+ var changedToFixed = isPos && (usesPosDurationPricing(productInput) || hasAppliedPosDurationPricing(productInput)) && authoritativeProduct && !usesPosDurationPricing(authoritativeProduct);
7214
+ // A switch to Days can explicitly request the existing per-day quotation path.
7215
+ // Discard the old minute basis, but do not erase that independent legacy input.
7216
+ var keepLegacyDayDuration = changedToFixed && ['day', 'days'].includes(String((authoritativeProduct === null || authoritativeProduct === void 0 || (_authoritativeProduct2 = authoritativeProduct.duration) === null || _authoritativeProduct2 === void 0 ? void 0 : _authoritativeProduct2.type) || '').trim().toLowerCase()) && ['day', 'days'].includes(String(((_params$duration = params.duration) === null || _params$duration === void 0 ? void 0 : _params$duration.type) || '').trim().toLowerCase());
7217
+ var result = calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread(_objectSpread({}, params), changedToFixed && !keepLegacyDayDuration ? {
7218
+ duration: undefined
7219
+ } : {}), {}, {
7137
7220
  channel: channel,
7138
7221
  product: product,
7139
7222
  fallback_price: authoritativeProduct ? undefined : params.fallback_price,
7140
7223
  customer_id: customerId,
7141
- quotation: authoritativeProduct && _this22.preferAuthoritativeProductQueryPrice() ? undefined : quotation
7224
+ quotation: authoritativeProduct && _this23.preferAuthoritativeProductQueryPrice() ? undefined : quotation
7142
7225
  }));
7226
+ return changedToFixed ? _objectSpread(_objectSpread({}, result), {}, {
7227
+ pricing_method: {
7228
+ type: 'fixed_price'
7229
+ },
7230
+ duration: undefined
7231
+ }) : result;
7143
7232
  }));
7144
- case 17:
7233
+ case 24:
7145
7234
  case "end":
7146
- return _context69.stop();
7235
+ return _context70.stop();
7147
7236
  }
7148
- }, _callee69, this);
7237
+ }, _callee70, this);
7149
7238
  }));
7150
- function calculateProductBookingPrices(_x52) {
7239
+ function calculateProductBookingPrices(_x55) {
7151
7240
  return _calculateProductBookingPrices.apply(this, arguments);
7152
7241
  }
7153
7242
  return calculateProductBookingPrices;
@@ -7155,47 +7244,47 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7155
7244
  }, {
7156
7245
  key: "addProductToOrder",
7157
7246
  value: function () {
7158
- var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(product, booking, options) {
7247
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(product, booking, options) {
7159
7248
  var products;
7160
- return _regeneratorRuntime().wrap(function _callee70$(_context70) {
7161
- while (1) switch (_context70.prev = _context70.next) {
7249
+ return _regeneratorRuntime().wrap(function _callee71$(_context71) {
7250
+ while (1) switch (_context71.prev = _context71.next) {
7162
7251
  case 0:
7163
- _context70.prev = 0;
7252
+ _context71.prev = 0;
7164
7253
  if (this.store.order) {
7165
- _context70.next = 3;
7254
+ _context71.next = 3;
7166
7255
  break;
7167
7256
  }
7168
7257
  throw new Error('order 模块未初始化');
7169
7258
  case 3:
7170
7259
  if (!(options === undefined)) {
7171
- _context70.next = 9;
7260
+ _context71.next = 9;
7172
7261
  break;
7173
7262
  }
7174
- _context70.next = 6;
7263
+ _context71.next = 6;
7175
7264
  return this.store.order.addProductToOrder(product, booking);
7176
7265
  case 6:
7177
- _context70.t0 = _context70.sent;
7178
- _context70.next = 12;
7266
+ _context71.t0 = _context71.sent;
7267
+ _context71.next = 12;
7179
7268
  break;
7180
7269
  case 9:
7181
- _context70.next = 11;
7270
+ _context71.next = 11;
7182
7271
  return this.store.order.addProductToOrder(product, booking, options);
7183
7272
  case 11:
7184
- _context70.t0 = _context70.sent;
7273
+ _context71.t0 = _context71.sent;
7185
7274
  case 12:
7186
- products = _context70.t0;
7187
- return _context70.abrupt("return", products);
7275
+ products = _context71.t0;
7276
+ return _context71.abrupt("return", products);
7188
7277
  case 16:
7189
- _context70.prev = 16;
7190
- _context70.t1 = _context70["catch"](0);
7191
- throw _context70.t1;
7278
+ _context71.prev = 16;
7279
+ _context71.t1 = _context71["catch"](0);
7280
+ throw _context71.t1;
7192
7281
  case 19:
7193
7282
  case "end":
7194
- return _context70.stop();
7283
+ return _context71.stop();
7195
7284
  }
7196
- }, _callee70, this, [[0, 16]]);
7285
+ }, _callee71, this, [[0, 16]]);
7197
7286
  }));
7198
- function addProductToOrder(_x54, _x55, _x56) {
7287
+ function addProductToOrder(_x56, _x57, _x58) {
7199
7288
  return _addProductToOrder.apply(this, arguments);
7200
7289
  }
7201
7290
  return addProductToOrder;
@@ -7203,34 +7292,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7203
7292
  }, {
7204
7293
  key: "updateOrderProduct",
7205
7294
  value: function () {
7206
- var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(params) {
7295
+ var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72(params) {
7207
7296
  var products;
7208
- return _regeneratorRuntime().wrap(function _callee71$(_context71) {
7209
- while (1) switch (_context71.prev = _context71.next) {
7297
+ return _regeneratorRuntime().wrap(function _callee72$(_context72) {
7298
+ while (1) switch (_context72.prev = _context72.next) {
7210
7299
  case 0:
7211
- _context71.prev = 0;
7300
+ _context72.prev = 0;
7212
7301
  if (this.store.order) {
7213
- _context71.next = 3;
7302
+ _context72.next = 3;
7214
7303
  break;
7215
7304
  }
7216
7305
  throw new Error('order 模块未初始化');
7217
7306
  case 3:
7218
- _context71.next = 5;
7307
+ _context72.next = 5;
7219
7308
  return this.store.order.updateOrderProduct(params);
7220
7309
  case 5:
7221
- products = _context71.sent;
7222
- return _context71.abrupt("return", products);
7310
+ products = _context72.sent;
7311
+ return _context72.abrupt("return", products);
7223
7312
  case 9:
7224
- _context71.prev = 9;
7225
- _context71.t0 = _context71["catch"](0);
7226
- throw _context71.t0;
7313
+ _context72.prev = 9;
7314
+ _context72.t0 = _context72["catch"](0);
7315
+ throw _context72.t0;
7227
7316
  case 12:
7228
7317
  case "end":
7229
- return _context71.stop();
7318
+ return _context72.stop();
7230
7319
  }
7231
- }, _callee71, this, [[0, 9]]);
7320
+ }, _callee72, this, [[0, 9]]);
7232
7321
  }));
7233
- function updateOrderProduct(_x57) {
7322
+ function updateOrderProduct(_x59) {
7234
7323
  return _updateOrderProduct.apply(this, arguments);
7235
7324
  }
7236
7325
  return updateOrderProduct;
@@ -7238,34 +7327,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7238
7327
  }, {
7239
7328
  key: "updateOrderProducts",
7240
7329
  value: function () {
7241
- var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72(paramsList) {
7330
+ var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73(paramsList) {
7242
7331
  var products;
7243
- return _regeneratorRuntime().wrap(function _callee72$(_context72) {
7244
- while (1) switch (_context72.prev = _context72.next) {
7332
+ return _regeneratorRuntime().wrap(function _callee73$(_context73) {
7333
+ while (1) switch (_context73.prev = _context73.next) {
7245
7334
  case 0:
7246
- _context72.prev = 0;
7335
+ _context73.prev = 0;
7247
7336
  if (this.store.order) {
7248
- _context72.next = 3;
7337
+ _context73.next = 3;
7249
7338
  break;
7250
7339
  }
7251
7340
  throw new Error('order 模块未初始化');
7252
7341
  case 3:
7253
- _context72.next = 5;
7342
+ _context73.next = 5;
7254
7343
  return this.store.order.updateOrderProducts(paramsList);
7255
7344
  case 5:
7256
- products = _context72.sent;
7257
- return _context72.abrupt("return", products);
7345
+ products = _context73.sent;
7346
+ return _context73.abrupt("return", products);
7258
7347
  case 9:
7259
- _context72.prev = 9;
7260
- _context72.t0 = _context72["catch"](0);
7261
- throw _context72.t0;
7348
+ _context73.prev = 9;
7349
+ _context73.t0 = _context73["catch"](0);
7350
+ throw _context73.t0;
7262
7351
  case 12:
7263
7352
  case "end":
7264
- return _context72.stop();
7353
+ return _context73.stop();
7265
7354
  }
7266
- }, _callee72, this, [[0, 9]]);
7355
+ }, _callee73, this, [[0, 9]]);
7267
7356
  }));
7268
- function updateOrderProducts(_x58) {
7357
+ function updateOrderProducts(_x60) {
7269
7358
  return _updateOrderProducts.apply(this, arguments);
7270
7359
  }
7271
7360
  return updateOrderProducts;
@@ -7273,34 +7362,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7273
7362
  }, {
7274
7363
  key: "updateOrderProductQuantity",
7275
7364
  value: function () {
7276
- var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73(params) {
7365
+ var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(params) {
7277
7366
  var products;
7278
- return _regeneratorRuntime().wrap(function _callee73$(_context73) {
7279
- while (1) switch (_context73.prev = _context73.next) {
7367
+ return _regeneratorRuntime().wrap(function _callee74$(_context74) {
7368
+ while (1) switch (_context74.prev = _context74.next) {
7280
7369
  case 0:
7281
- _context73.prev = 0;
7370
+ _context74.prev = 0;
7282
7371
  if (this.store.order) {
7283
- _context73.next = 3;
7372
+ _context74.next = 3;
7284
7373
  break;
7285
7374
  }
7286
7375
  throw new Error('order 模块未初始化');
7287
7376
  case 3:
7288
- _context73.next = 5;
7377
+ _context74.next = 5;
7289
7378
  return this.store.order.updateOrderProductQuantity(params);
7290
7379
  case 5:
7291
- products = _context73.sent;
7292
- return _context73.abrupt("return", products);
7380
+ products = _context74.sent;
7381
+ return _context74.abrupt("return", products);
7293
7382
  case 9:
7294
- _context73.prev = 9;
7295
- _context73.t0 = _context73["catch"](0);
7296
- throw _context73.t0;
7383
+ _context74.prev = 9;
7384
+ _context74.t0 = _context74["catch"](0);
7385
+ throw _context74.t0;
7297
7386
  case 12:
7298
7387
  case "end":
7299
- return _context73.stop();
7388
+ return _context74.stop();
7300
7389
  }
7301
- }, _callee73, this, [[0, 9]]);
7390
+ }, _callee74, this, [[0, 9]]);
7302
7391
  }));
7303
- function updateOrderProductQuantity(_x59) {
7392
+ function updateOrderProductQuantity(_x61) {
7304
7393
  return _updateOrderProductQuantity.apply(this, arguments);
7305
7394
  }
7306
7395
  return updateOrderProductQuantity;
@@ -7323,12 +7412,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7323
7412
  }, {
7324
7413
  key: "setOrderProductLineNote",
7325
7414
  value: (function () {
7326
- var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(identity, note) {
7415
+ var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75(identity, note) {
7327
7416
  var params, products;
7328
- return _regeneratorRuntime().wrap(function _callee74$(_context74) {
7329
- while (1) switch (_context74.prev = _context74.next) {
7417
+ return _regeneratorRuntime().wrap(function _callee75$(_context75) {
7418
+ while (1) switch (_context75.prev = _context75.next) {
7330
7419
  case 0:
7331
- _context74.prev = 0;
7420
+ _context75.prev = 0;
7332
7421
  params = {
7333
7422
  product_id: identity.product_id,
7334
7423
  product_variant_id: identity.product_variant_id,
@@ -7343,22 +7432,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7343
7432
  params.product_sku = identity.product_sku;
7344
7433
  }
7345
7434
  if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
7346
- _context74.next = 7;
7435
+ _context75.next = 7;
7347
7436
  return this.updateOrderProduct(params);
7348
7437
  case 7:
7349
- products = _context74.sent;
7350
- return _context74.abrupt("return", products);
7438
+ products = _context75.sent;
7439
+ return _context75.abrupt("return", products);
7351
7440
  case 11:
7352
- _context74.prev = 11;
7353
- _context74.t0 = _context74["catch"](0);
7354
- throw _context74.t0;
7441
+ _context75.prev = 11;
7442
+ _context75.t0 = _context75["catch"](0);
7443
+ throw _context75.t0;
7355
7444
  case 14:
7356
7445
  case "end":
7357
- return _context74.stop();
7446
+ return _context75.stop();
7358
7447
  }
7359
- }, _callee74, this, [[0, 11]]);
7448
+ }, _callee75, this, [[0, 11]]);
7360
7449
  }));
7361
- function setOrderProductLineNote(_x60, _x61) {
7450
+ function setOrderProductLineNote(_x62, _x63) {
7362
7451
  return _setOrderProductLineNote.apply(this, arguments);
7363
7452
  }
7364
7453
  return setOrderProductLineNote;
@@ -7373,45 +7462,45 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7373
7462
  }, {
7374
7463
  key: "removeProductsFromOrder",
7375
7464
  value: (function () {
7376
- var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75(identities, options) {
7377
- return _regeneratorRuntime().wrap(function _callee75$(_context75) {
7378
- while (1) switch (_context75.prev = _context75.next) {
7465
+ var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee76(identities, options) {
7466
+ return _regeneratorRuntime().wrap(function _callee76$(_context76) {
7467
+ while (1) switch (_context76.prev = _context76.next) {
7379
7468
  case 0:
7380
- _context75.prev = 0;
7469
+ _context76.prev = 0;
7381
7470
  if (this.store.order) {
7382
- _context75.next = 3;
7471
+ _context76.next = 3;
7383
7472
  break;
7384
7473
  }
7385
7474
  throw new Error('order 模块未初始化');
7386
7475
  case 3:
7387
7476
  if (!(options === undefined)) {
7388
- _context75.next = 9;
7477
+ _context76.next = 9;
7389
7478
  break;
7390
7479
  }
7391
- _context75.next = 6;
7480
+ _context76.next = 6;
7392
7481
  return this.store.order.removeProductsFromOrder(identities);
7393
7482
  case 6:
7394
- _context75.t0 = _context75.sent;
7395
- _context75.next = 12;
7483
+ _context76.t0 = _context76.sent;
7484
+ _context76.next = 12;
7396
7485
  break;
7397
7486
  case 9:
7398
- _context75.next = 11;
7487
+ _context76.next = 11;
7399
7488
  return this.store.order.removeProductsFromOrder(identities, options);
7400
7489
  case 11:
7401
- _context75.t0 = _context75.sent;
7490
+ _context76.t0 = _context76.sent;
7402
7491
  case 12:
7403
- return _context75.abrupt("return", _context75.t0);
7492
+ return _context76.abrupt("return", _context76.t0);
7404
7493
  case 15:
7405
- _context75.prev = 15;
7406
- _context75.t1 = _context75["catch"](0);
7407
- throw _context75.t1;
7494
+ _context76.prev = 15;
7495
+ _context76.t1 = _context76["catch"](0);
7496
+ throw _context76.t1;
7408
7497
  case 18:
7409
7498
  case "end":
7410
- return _context75.stop();
7499
+ return _context76.stop();
7411
7500
  }
7412
- }, _callee75, this, [[0, 15]]);
7501
+ }, _callee76, this, [[0, 15]]);
7413
7502
  }));
7414
- function removeProductsFromOrder(_x62, _x63) {
7503
+ function removeProductsFromOrder(_x64, _x65) {
7415
7504
  return _removeProductsFromOrder.apply(this, arguments);
7416
7505
  }
7417
7506
  return removeProductsFromOrder;
@@ -7419,18 +7508,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7419
7508
  }, {
7420
7509
  key: "removeProductFromOrder",
7421
7510
  value: function () {
7422
- var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee76(identity, options) {
7423
- return _regeneratorRuntime().wrap(function _callee76$(_context76) {
7424
- while (1) switch (_context76.prev = _context76.next) {
7511
+ var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee77(identity, options) {
7512
+ return _regeneratorRuntime().wrap(function _callee77$(_context77) {
7513
+ while (1) switch (_context77.prev = _context77.next) {
7425
7514
  case 0:
7426
- return _context76.abrupt("return", this.removeProductsFromOrder([identity], options));
7515
+ return _context77.abrupt("return", this.removeProductsFromOrder([identity], options));
7427
7516
  case 1:
7428
7517
  case "end":
7429
- return _context76.stop();
7518
+ return _context77.stop();
7430
7519
  }
7431
- }, _callee76, this);
7520
+ }, _callee77, this);
7432
7521
  }));
7433
- function removeProductFromOrder(_x64, _x65) {
7522
+ function removeProductFromOrder(_x66, _x67) {
7434
7523
  return _removeProductFromOrder.apply(this, arguments);
7435
7524
  }
7436
7525
  return removeProductFromOrder;
@@ -7480,23 +7569,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7480
7569
  }, {
7481
7570
  key: "applyPromotion",
7482
7571
  value: (function () {
7483
- var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee77() {
7484
- return _regeneratorRuntime().wrap(function _callee77$(_context77) {
7485
- while (1) switch (_context77.prev = _context77.next) {
7572
+ var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee78() {
7573
+ return _regeneratorRuntime().wrap(function _callee78$(_context78) {
7574
+ while (1) switch (_context78.prev = _context78.next) {
7486
7575
  case 0:
7487
7576
  if (this.store.order) {
7488
- _context77.next = 2;
7577
+ _context78.next = 2;
7489
7578
  break;
7490
7579
  }
7491
7580
  throw new Error('order 模块未初始化');
7492
7581
  case 2:
7493
- _context77.next = 4;
7582
+ _context78.next = 4;
7494
7583
  return this.store.order.applyPromotion();
7495
7584
  case 4:
7496
7585
  case "end":
7497
- return _context77.stop();
7586
+ return _context78.stop();
7498
7587
  }
7499
- }, _callee77, this);
7588
+ }, _callee78, this);
7500
7589
  }));
7501
7590
  function applyPromotion() {
7502
7591
  return _applyPromotion.apply(this, arguments);
@@ -7523,18 +7612,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7523
7612
  }, {
7524
7613
  key: "getProductList",
7525
7614
  value: function () {
7526
- var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee78() {
7527
- var _this$otherParams43;
7615
+ var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee79() {
7616
+ var _this$otherParams45;
7528
7617
  var menu_list_ids, _this$store$products, res;
7529
- return _regeneratorRuntime().wrap(function _callee78$(_context78) {
7530
- while (1) switch (_context78.prev = _context78.next) {
7618
+ return _regeneratorRuntime().wrap(function _callee79$(_context79) {
7619
+ while (1) switch (_context79.prev = _context79.next) {
7531
7620
  case 0:
7532
7621
  // 可以直接通过配置里的 menu 读取
7533
- menu_list_ids = ((_this$otherParams43 = this.otherParams) === null || _this$otherParams43 === void 0 || (_this$otherParams43 = _this$otherParams43.dineInConfig) === null || _this$otherParams43 === void 0 ? void 0 : _this$otherParams43['menu.associated_menus'].map(function (n) {
7622
+ menu_list_ids = ((_this$otherParams45 = this.otherParams) === null || _this$otherParams45 === void 0 || (_this$otherParams45 = _this$otherParams45.dineInConfig) === null || _this$otherParams45 === void 0 ? void 0 : _this$otherParams45['menu.associated_menus'].map(function (n) {
7534
7623
  return Number(n.value);
7535
7624
  })) || [];
7536
- _context78.prev = 1;
7537
- _context78.next = 4;
7625
+ _context79.prev = 1;
7626
+ _context79.next = 4;
7538
7627
  return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
7539
7628
  menu_list_ids: menu_list_ids,
7540
7629
  cacheId: this.cacheId,
@@ -7542,17 +7631,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7542
7631
  schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
7543
7632
  });
7544
7633
  case 4:
7545
- res = _context78.sent;
7546
- return _context78.abrupt("return", res);
7634
+ res = _context79.sent;
7635
+ return _context79.abrupt("return", res);
7547
7636
  case 8:
7548
- _context78.prev = 8;
7549
- _context78.t0 = _context78["catch"](1);
7550
- throw _context78.t0;
7637
+ _context79.prev = 8;
7638
+ _context79.t0 = _context79["catch"](1);
7639
+ throw _context79.t0;
7551
7640
  case 11:
7552
7641
  case "end":
7553
- return _context78.stop();
7642
+ return _context79.stop();
7554
7643
  }
7555
- }, _callee78, this, [[1, 8]]);
7644
+ }, _callee79, this, [[1, 8]]);
7556
7645
  }));
7557
7646
  function getProductList() {
7558
7647
  return _getProductList.apply(this, arguments);
@@ -7567,36 +7656,36 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7567
7656
  }, {
7568
7657
  key: "setOtherParams",
7569
7658
  value: function () {
7570
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee79(params) {
7571
- var _this$otherParams44;
7659
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee80(params) {
7660
+ var _this$otherParams46;
7572
7661
  var _ref56,
7573
7662
  _ref56$cover,
7574
7663
  cover,
7575
7664
  previousPickupTimingScope,
7576
- _args79 = arguments;
7577
- return _regeneratorRuntime().wrap(function _callee79$(_context79) {
7578
- while (1) switch (_context79.prev = _context79.next) {
7665
+ _args80 = arguments;
7666
+ return _regeneratorRuntime().wrap(function _callee80$(_context80) {
7667
+ while (1) switch (_context80.prev = _context80.next) {
7579
7668
  case 0:
7580
- _ref56 = _args79.length > 1 && _args79[1] !== undefined ? _args79[1] : {}, _ref56$cover = _ref56.cover, cover = _ref56$cover === void 0 ? false : _ref56$cover;
7669
+ _ref56 = _args80.length > 1 && _args80[1] !== undefined ? _args80[1] : {}, _ref56$cover = _ref56.cover, cover = _ref56$cover === void 0 ? false : _ref56$cover;
7581
7670
  previousPickupTimingScope = this.getPickupTimingScope();
7582
7671
  if (cover) {
7583
7672
  this.otherParams = _objectSpread({}, params);
7584
7673
  } else {
7585
7674
  this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
7586
7675
  }
7587
- this.cacheId = (_this$otherParams44 = this.otherParams) === null || _this$otherParams44 === void 0 ? void 0 : _this$otherParams44.cacheId;
7676
+ this.cacheId = (_this$otherParams46 = this.otherParams) === null || _this$otherParams46 === void 0 ? void 0 : _this$otherParams46.cacheId;
7588
7677
  if (previousPickupTimingScope !== this.getPickupTimingScope()) this.resetPickupTimingCache();
7589
- _context79.next = 7;
7678
+ _context80.next = 7;
7590
7679
  return this.syncOtherParamsToSubModules(params, {
7591
7680
  cover: cover
7592
7681
  });
7593
7682
  case 7:
7594
7683
  case "end":
7595
- return _context79.stop();
7684
+ return _context80.stop();
7596
7685
  }
7597
- }, _callee79, this);
7686
+ }, _callee80, this);
7598
7687
  }));
7599
- function setOtherParams(_x66) {
7688
+ function setOtherParams(_x68) {
7600
7689
  return _setOtherParams.apply(this, arguments);
7601
7690
  }
7602
7691
  return setOtherParams;