@pisell/pisellos 2.3.130 → 2.3.132
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.
- package/dist/modules/BusinessAvailability/index.d.ts +30 -0
- package/dist/modules/BusinessAvailability/index.js +204 -0
- package/dist/modules/OpenData/types.d.ts +2 -0
- package/dist/modules/Order/index.d.ts +5 -2
- package/dist/modules/Order/index.js +315 -241
- package/dist/modules/Order/types.d.ts +8 -0
- package/dist/solution/BaseSales/index.d.ts +4 -15
- package/dist/solution/BaseSales/index.js +151 -89
- package/dist/solution/BaseSales/types.d.ts +11 -0
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +41 -13
- package/dist/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
- package/dist/solution/UnifiedBookingSales/businessAvailability.js +292 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +11 -0
- package/dist/solution/UnifiedBookingSales/index.js +154 -75
- package/dist/solution/UnifiedBookingSales/types.d.ts +2 -0
- package/dist/solution/VenueBooking/index.js +45 -44
- package/lib/modules/BusinessAvailability/index.d.ts +30 -0
- package/lib/modules/BusinessAvailability/index.js +146 -0
- package/lib/modules/OpenData/types.d.ts +2 -0
- package/lib/modules/Order/index.d.ts +5 -2
- package/lib/modules/Order/index.js +62 -6
- package/lib/modules/Order/types.d.ts +8 -0
- package/lib/solution/BaseSales/index.d.ts +4 -15
- package/lib/solution/BaseSales/index.js +64 -24
- package/lib/solution/BaseSales/types.d.ts +11 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +37 -4
- package/lib/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
- package/lib/solution/UnifiedBookingSales/businessAvailability.js +138 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +11 -0
- package/lib/solution/UnifiedBookingSales/index.js +54 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +2 -0
- package/lib/solution/VenueBooking/index.js +9 -8
- package/package.json +1 -1
|
@@ -216,6 +216,8 @@ export interface UnifiedBookingSalesDiscountResult {
|
|
|
216
216
|
summaryAfter?: unknown;
|
|
217
217
|
}
|
|
218
218
|
export interface UnifiedBookingSalesApi {
|
|
219
|
+
/** Uses cached business settings and evaluates the current store-local clock. */
|
|
220
|
+
getBusinessAvailability: () => Promise<import('../../modules/BusinessAvailability').BusinessAvailability>;
|
|
219
221
|
loadOpenData: (params: UnifiedBookingSalesLoadOpenDataParams) => Promise<OpenDataConfig>;
|
|
220
222
|
/** Returns the latest OpenData payload cached by this solution instance. */
|
|
221
223
|
getOpenData: () => Promise<OpenDataConfig | null>;
|
|
@@ -47,7 +47,7 @@ import { extractResourceIds, buildResourceProductMap } from "./utils/resource";
|
|
|
47
47
|
import { buildTimeSlotGrid, isBusinessHoursCrossDay, generateTimeLabels } from "./utils/timeSlot";
|
|
48
48
|
import { buildDateRangeSummary } from "./utils/dateSummary";
|
|
49
49
|
import { mergeConsecutiveSlots, expandMergedSlotToIndividual, buildVenueIdentityKey, buildVenueBookingEntry, buildVenueResourceMetadata, buildPriceBreakdown } from "./utils/slotMerge";
|
|
50
|
-
import { composeLinePrice, createUuidV4, getProductSkuOptions, sumOptionUnitPrice } from "../../modules/Order/utils";
|
|
50
|
+
import { composeLinePrice, createUuidV4, getOrderProductLineUid, getProductSkuOptions, sumOptionUnitPrice } from "../../modules/Order/utils";
|
|
51
51
|
import { OrderModule } from "../../modules/Order";
|
|
52
52
|
import { RegisterAndLoginHooks } from "../RegisterAndLogin/types";
|
|
53
53
|
import Decimal from 'decimal.js';
|
|
@@ -309,8 +309,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
309
309
|
}, {
|
|
310
310
|
key: "readProductOriginFromTempOrder",
|
|
311
311
|
value: function readProductOriginFromTempOrder(tempOrder, product) {
|
|
312
|
-
var
|
|
313
|
-
var uid = (
|
|
312
|
+
var _tempOrder$_extend3;
|
|
313
|
+
var uid = getOrderProductLineUid(product);
|
|
314
314
|
if (uid && (_tempOrder$_extend3 = tempOrder._extend) !== null && _tempOrder$_extend3 !== void 0 && (_tempOrder$_extend3 = _tempOrder$_extend3.productsByUid) !== null && _tempOrder$_extend3 !== void 0 && (_tempOrder$_extend3 = _tempOrder$_extend3[uid]) !== null && _tempOrder$_extend3 !== void 0 && _tempOrder$_extend3.origin) {
|
|
315
315
|
return tempOrder._extend.productsByUid[uid].origin;
|
|
316
316
|
}
|
|
@@ -1795,9 +1795,9 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1795
1795
|
_step10;
|
|
1796
1796
|
try {
|
|
1797
1797
|
var _loop2 = function _loop2() {
|
|
1798
|
-
var _product$
|
|
1798
|
+
var _product$metadata;
|
|
1799
1799
|
var product = _step10.value;
|
|
1800
|
-
var resourceId = (_product$
|
|
1800
|
+
var resourceId = (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.resource_id;
|
|
1801
1801
|
if (resourceId == null) return 1; // continue
|
|
1802
1802
|
var productId = Number(product.product_id);
|
|
1803
1803
|
var existing = result.get(resourceId) || [];
|
|
@@ -1845,7 +1845,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1845
1845
|
value: (function () {
|
|
1846
1846
|
var _reconcileOrderForResourceProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(resourceId, productId, slots) {
|
|
1847
1847
|
var _this$store$order6, _this$store$order6$ge;
|
|
1848
|
-
var mappings, mapping, tempOrder, matchesCurrent, merged, rawResource, childRawResources, venueProduct, i, _rawResource$form_id, _venueProduct$is_char, _this$otherParams15, group,
|
|
1848
|
+
var mappings, mapping, tempOrder, matchesCurrent, merged, rawResource, childRawResources, venueProduct, i, _rawResource$form_id, _venueProduct$is_char, _this$otherParams15, group, productUid, bookingUuid, startMoment, endMoment, duration, customDepositData, productTitle, resourceEntry, venueProductOrigin, normalizedVenueOrderProduct, venueOrderProduct, booking, products;
|
|
1849
1849
|
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1850
1850
|
while (1) switch (_context19.prev = _context19.next) {
|
|
1851
1851
|
case 0:
|
|
@@ -1904,7 +1904,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1904
1904
|
tempOrder.bookings = tempOrder.bookings || [];
|
|
1905
1905
|
for (i = 0; i < merged.length; i++) {
|
|
1906
1906
|
group = merged[i];
|
|
1907
|
-
|
|
1907
|
+
productUid = buildVenueIdentityKey(resourceId, i);
|
|
1908
1908
|
bookingUuid = createUuidV4();
|
|
1909
1909
|
startMoment = dayjs(group.startTime, 'YYYY-MM-DD HH:mm');
|
|
1910
1910
|
endMoment = dayjs(group.endTime, 'YYYY-MM-DD HH:mm');
|
|
@@ -1980,12 +1980,12 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1980
1980
|
normalizedVenueOrderProduct = normalizeOrderProduct({
|
|
1981
1981
|
product_id: mapping.productId,
|
|
1982
1982
|
product_variant_id: 0,
|
|
1983
|
-
identity_key: identityKey,
|
|
1984
1983
|
num: 1,
|
|
1985
1984
|
selling_price: group.totalPrice,
|
|
1986
1985
|
original_price: group.totalPrice,
|
|
1987
1986
|
is_charge_tax: (_venueProduct$is_char = venueProduct === null || venueProduct === void 0 ? void 0 : venueProduct.is_charge_tax) !== null && _venueProduct$is_char !== void 0 ? _venueProduct$is_char : 0,
|
|
1988
1987
|
metadata: _objectSpread(_objectSpread({
|
|
1988
|
+
unique_identification_number: productUid,
|
|
1989
1989
|
venue_booking: true
|
|
1990
1990
|
}, productTitle ? {
|
|
1991
1991
|
product_title: productTitle
|
|
@@ -2009,7 +2009,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2009
2009
|
venueOrderProduct = productTitle ? _objectSpread(_objectSpread({}, normalizedVenueOrderProduct), {}, {
|
|
2010
2010
|
product_title: productTitle
|
|
2011
2011
|
}) : normalizedVenueOrderProduct;
|
|
2012
|
-
this.attachProductOriginToTempOrder(tempOrder,
|
|
2012
|
+
this.attachProductOriginToTempOrder(tempOrder, productUid, venueProductOrigin);
|
|
2013
2013
|
tempOrder.products.push(venueOrderProduct);
|
|
2014
2014
|
booking = buildVenueBookingEntry({
|
|
2015
2015
|
group: group,
|
|
@@ -2017,7 +2017,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2017
2017
|
mapping: mapping,
|
|
2018
2018
|
rawResource: rawResource,
|
|
2019
2019
|
bookingUuid: bookingUuid,
|
|
2020
|
-
productUid:
|
|
2020
|
+
productUid: productUid,
|
|
2021
2021
|
childResources: childRawResources
|
|
2022
2022
|
});
|
|
2023
2023
|
tempOrder.bookings.push(booking);
|
|
@@ -2223,9 +2223,9 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2223
2223
|
_step13;
|
|
2224
2224
|
try {
|
|
2225
2225
|
var _loop4 = function _loop4() {
|
|
2226
|
-
var _product$
|
|
2226
|
+
var _product$metadata2;
|
|
2227
2227
|
var product = _step13.value;
|
|
2228
|
-
if ((_product$
|
|
2228
|
+
if ((_product$metadata2 = product.metadata) !== null && _product$metadata2 !== void 0 && _product$metadata2.venue_booking) {
|
|
2229
2229
|
var mappings = _this11.resourceProductMap.get(product.metadata.resource_id);
|
|
2230
2230
|
if (!mappings || !mappings.length) return 0; // continue
|
|
2231
2231
|
var mapping = mappings.find(function (m) {
|
|
@@ -2346,7 +2346,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2346
2346
|
key: "setDiscountSelected",
|
|
2347
2347
|
value: (function () {
|
|
2348
2348
|
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
|
|
2349
|
-
var _tempOrder$holder, _this$store$order$get, _this$store$order$get2, list, beforeTarget, updated, updatedTarget, tempOrder, orderStore, discountModule, rulesModule, holders, nextDiscountList, _tempOrder$holder2, result, beforeSelectedIds, _iterator14, _step14, d, selectedResourceIds, _iterator15, _step15, _origin, _product$metadata$sou, _product$
|
|
2349
|
+
var _tempOrder$holder, _this$store$order$get, _this$store$order$get2, list, beforeTarget, updated, updatedTarget, tempOrder, orderStore, discountModule, rulesModule, holders, nextDiscountList, _tempOrder$holder2, result, beforeSelectedIds, _iterator14, _step14, d, selectedResourceIds, _iterator15, _step15, _origin, _product$metadata$sou, _product$metadata3, _product$metadata4, _product$original_pri, product, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice, afterApplyTarget, finalSummary, finalProduct, finalTarget;
|
|
2350
2350
|
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
2351
2351
|
while (1) switch (_context23.prev = _context23.next) {
|
|
2352
2352
|
case 0:
|
|
@@ -2465,7 +2465,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2465
2465
|
return sum + (pd.amount || 0);
|
|
2466
2466
|
}, 0);
|
|
2467
2467
|
optionSum = sumOptionUnitPrice(getProductSkuOptions(product));
|
|
2468
|
-
sourcePrice = (_product$metadata$sou = (_product$
|
|
2468
|
+
sourcePrice = (_product$metadata$sou = (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.source_product_price) !== null && _product$metadata$sou !== void 0 ? _product$metadata$sou : ((_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.main_product_original_price) != null ? new Decimal(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : (_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : '0';
|
|
2469
2469
|
newSourceSellingPrice = new Decimal(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
2470
2470
|
newMainSellingPrice = new Decimal(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
2471
2471
|
if (product.metadata) {
|
|
@@ -2671,7 +2671,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2671
2671
|
key: "addProductToOrder",
|
|
2672
2672
|
value: function () {
|
|
2673
2673
|
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(product) {
|
|
2674
|
-
var _product$
|
|
2674
|
+
var _product$metadata5, _product$product_vari2, _this$otherParams20, quotationPrice, products;
|
|
2675
2675
|
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
2676
2676
|
while (1) switch (_context27.prev = _context27.next) {
|
|
2677
2677
|
case 0:
|
|
@@ -2686,7 +2686,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2686
2686
|
}
|
|
2687
2687
|
throw new Error('order 模块未初始化');
|
|
2688
2688
|
case 4:
|
|
2689
|
-
if (!((_product$
|
|
2689
|
+
if (!((_product$metadata5 = product.metadata) !== null && _product$metadata5 !== void 0 && _product$metadata5.venue_booking) && this.store.quotation && product.product_id != null) {
|
|
2690
2690
|
quotationPrice = this.store.quotation.getPriceForProduct({
|
|
2691
2691
|
productId: product.product_id,
|
|
2692
2692
|
variantId: (_product$product_vari2 = product.product_variant_id) !== null && _product$product_vari2 !== void 0 ? _product$product_vari2 : undefined,
|
|
@@ -2783,7 +2783,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2783
2783
|
key: "removeProductFromOrder",
|
|
2784
2784
|
value: function () {
|
|
2785
2785
|
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(identity) {
|
|
2786
|
-
var _this$store$order$get3, _this$store$order8, _this$store$order$ens, _this$store$order9, _tempOrder$bookings, tempOrder, products, _tempOrder$bookings2, _tempOrder$bookings3, venueProductUids, venueBookingUids, _iterator16, _step16, _product$
|
|
2786
|
+
var _this$store$order$get3, _this$store$order8, _this$store$order$ens, _this$store$order9, _tempOrder$bookings, tempOrder, products, _tempOrder$bookings2, _tempOrder$bookings3, venueProductUids, venueBookingUids, _iterator16, _step16, _product$metadata6, _product$metadata7, product, productUid, beforeBookingCount, _this$store$order$per, _this$store$order10;
|
|
2787
2787
|
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
2788
2788
|
while (1) switch (_context29.prev = _context29.next) {
|
|
2789
2789
|
case 0:
|
|
@@ -2804,7 +2804,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2804
2804
|
case 7:
|
|
2805
2805
|
products = _context29.sent;
|
|
2806
2806
|
if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$bookings = tempOrder.bookings) !== null && _tempOrder$bookings !== void 0 && _tempOrder$bookings.length)) {
|
|
2807
|
-
_context29.next =
|
|
2807
|
+
_context29.next = 34;
|
|
2808
2808
|
break;
|
|
2809
2809
|
}
|
|
2810
2810
|
venueProductUids = new Set();
|
|
@@ -2814,35 +2814,36 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2814
2814
|
_iterator16.s();
|
|
2815
2815
|
case 14:
|
|
2816
2816
|
if ((_step16 = _iterator16.n()).done) {
|
|
2817
|
-
_context29.next =
|
|
2817
|
+
_context29.next = 23;
|
|
2818
2818
|
break;
|
|
2819
2819
|
}
|
|
2820
2820
|
product = _step16.value;
|
|
2821
|
-
if (product !== null && product !== void 0 && (_product$
|
|
2821
|
+
if (product !== null && product !== void 0 && (_product$metadata6 = product.metadata) !== null && _product$metadata6 !== void 0 && _product$metadata6.venue_booking) {
|
|
2822
2822
|
_context29.next = 18;
|
|
2823
2823
|
break;
|
|
2824
2824
|
}
|
|
2825
|
-
return _context29.abrupt("continue",
|
|
2825
|
+
return _context29.abrupt("continue", 21);
|
|
2826
2826
|
case 18:
|
|
2827
|
-
|
|
2828
|
-
if (
|
|
2827
|
+
productUid = getOrderProductLineUid(product);
|
|
2828
|
+
if (productUid) venueProductUids.add(productUid);
|
|
2829
|
+
if ((_product$metadata7 = product.metadata) !== null && _product$metadata7 !== void 0 && _product$metadata7.booking_uid) {
|
|
2829
2830
|
venueBookingUids.add(String(product.metadata.booking_uid));
|
|
2830
2831
|
}
|
|
2831
|
-
case
|
|
2832
|
+
case 21:
|
|
2832
2833
|
_context29.next = 14;
|
|
2833
2834
|
break;
|
|
2834
|
-
case
|
|
2835
|
-
_context29.next =
|
|
2835
|
+
case 23:
|
|
2836
|
+
_context29.next = 28;
|
|
2836
2837
|
break;
|
|
2837
|
-
case
|
|
2838
|
-
_context29.prev =
|
|
2838
|
+
case 25:
|
|
2839
|
+
_context29.prev = 25;
|
|
2839
2840
|
_context29.t0 = _context29["catch"](12);
|
|
2840
2841
|
_iterator16.e(_context29.t0);
|
|
2841
|
-
case
|
|
2842
|
-
_context29.prev =
|
|
2842
|
+
case 28:
|
|
2843
|
+
_context29.prev = 28;
|
|
2843
2844
|
_iterator16.f();
|
|
2844
|
-
return _context29.finish(
|
|
2845
|
-
case
|
|
2845
|
+
return _context29.finish(28);
|
|
2846
|
+
case 31:
|
|
2846
2847
|
beforeBookingCount = ((_tempOrder$bookings2 = tempOrder.bookings) === null || _tempOrder$bookings2 === void 0 ? void 0 : _tempOrder$bookings2.length) || 0;
|
|
2847
2848
|
tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
2848
2849
|
var _booking$metadata, _booking$metadata2;
|
|
@@ -2857,27 +2858,27 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2857
2858
|
if ((((_tempOrder$bookings3 = tempOrder.bookings) === null || _tempOrder$bookings3 === void 0 ? void 0 : _tempOrder$bookings3.length) || 0) !== beforeBookingCount) {
|
|
2858
2859
|
(_this$store$order$per = (_this$store$order10 = this.store.order).persistTempOrder) === null || _this$store$order$per === void 0 || _this$store$order$per.call(_this$store$order10);
|
|
2859
2860
|
}
|
|
2860
|
-
case
|
|
2861
|
-
_context29.next =
|
|
2861
|
+
case 34:
|
|
2862
|
+
_context29.next = 36;
|
|
2862
2863
|
return this.refreshItemRuleQuantityLimits();
|
|
2863
|
-
case
|
|
2864
|
-
_context29.next =
|
|
2864
|
+
case 36:
|
|
2865
|
+
_context29.next = 38;
|
|
2865
2866
|
return this.refreshCartValidationPassed();
|
|
2866
|
-
case
|
|
2867
|
+
case 38:
|
|
2867
2868
|
this.logMethodSuccess('removeProductFromOrder', {
|
|
2868
2869
|
productCount: products.length
|
|
2869
2870
|
});
|
|
2870
2871
|
return _context29.abrupt("return", products);
|
|
2871
|
-
case
|
|
2872
|
-
_context29.prev =
|
|
2872
|
+
case 42:
|
|
2873
|
+
_context29.prev = 42;
|
|
2873
2874
|
_context29.t1 = _context29["catch"](1);
|
|
2874
2875
|
this.logMethodError('removeProductFromOrder', _context29.t1);
|
|
2875
2876
|
throw _context29.t1;
|
|
2876
|
-
case
|
|
2877
|
+
case 46:
|
|
2877
2878
|
case "end":
|
|
2878
2879
|
return _context29.stop();
|
|
2879
2880
|
}
|
|
2880
|
-
}, _callee29, this, [[1,
|
|
2881
|
+
}, _callee29, this, [[1, 42], [12, 25, 28, 31]]);
|
|
2881
2882
|
}));
|
|
2882
2883
|
function removeProductFromOrder(_x20) {
|
|
2883
2884
|
return _removeProductFromOrder.apply(this, arguments);
|
|
@@ -3257,7 +3258,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3257
3258
|
key: "applyPrefillByItemRule",
|
|
3258
3259
|
value: function () {
|
|
3259
3260
|
var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
|
|
3260
|
-
var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges, _iterator18, _step18, _prefillItem$product_, prefillItem, productId, productVariantId, targetQuantity, sourceItem, productIndex, _sourceItem$price,
|
|
3261
|
+
var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges, _iterator18, _step18, _prefillItem$product_, prefillItem, productId, productVariantId, targetQuantity, sourceItem, productIndex, _sourceItem$price, sellingPrice, origin, product, productUid, targetProduct, previousOrigin, nextOrigin, existedQuantity, delta, nextProduct, _productUid;
|
|
3261
3262
|
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
3262
3263
|
while (1) switch (_context38.prev = _context38.next) {
|
|
3263
3264
|
case 0:
|
|
@@ -3352,7 +3353,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3352
3353
|
},
|
|
3353
3354
|
_origin: origin
|
|
3354
3355
|
});
|
|
3355
|
-
productUid =
|
|
3356
|
+
productUid = getOrderProductLineUid(product) || '';
|
|
3356
3357
|
this.attachProductOriginToTempOrder(tempOrder, productUid, origin);
|
|
3357
3358
|
tempOrder.products.push(product);
|
|
3358
3359
|
hasChanges = true;
|
|
@@ -3372,7 +3373,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3372
3373
|
})
|
|
3373
3374
|
});
|
|
3374
3375
|
if (delta > 0 || Boolean(sourceItem && (!previousOrigin || (previousOrigin === null || previousOrigin === void 0 ? void 0 : previousOrigin.price) !== (sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.price)))) {
|
|
3375
|
-
_productUid =
|
|
3376
|
+
_productUid = getOrderProductLineUid(nextProduct) || '';
|
|
3376
3377
|
this.attachProductOriginToTempOrder(tempOrder, _productUid, nextOrigin);
|
|
3377
3378
|
tempOrder.products[productIndex] = nextProduct;
|
|
3378
3379
|
hasChanges = true;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { MultiLangObject } from '../OpenData/types';
|
|
2
|
+
import type { ScheduleItem } from '../Schedule/types';
|
|
3
|
+
export type BusinessClosedBehavior = 'show_menu_disabled' | 'hide_all';
|
|
4
|
+
export interface BusinessAvailability {
|
|
5
|
+
status: 'open' | 'paused' | 'closed' | 'error';
|
|
6
|
+
behavior: BusinessClosedBehavior | null;
|
|
7
|
+
message: string | MultiLangObject | null;
|
|
8
|
+
/** Epoch milliseconds. Re-evaluate the cached configuration at this time. */
|
|
9
|
+
nextChangeAt: number;
|
|
10
|
+
requirePaymentOnSubmit: boolean;
|
|
11
|
+
error?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface BusinessAvailabilityConfig {
|
|
14
|
+
paused: boolean;
|
|
15
|
+
pauseBehavior: BusinessClosedBehavior;
|
|
16
|
+
closedBehavior: BusinessClosedBehavior;
|
|
17
|
+
pauseMessage: BusinessAvailability['message'];
|
|
18
|
+
closedMessage: BusinessAvailability['message'];
|
|
19
|
+
scheduleIds: number[];
|
|
20
|
+
invalidScheduleIds: boolean;
|
|
21
|
+
requirePaymentOnSubmit: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare function normalizeBusinessAvailabilityConfig(data: Record<string, unknown>): BusinessAvailabilityConfig;
|
|
24
|
+
/** Business ordering is independent of reservation switches and Pickup slot availability. */
|
|
25
|
+
export declare function computeBusinessAvailability(input: {
|
|
26
|
+
config: BusinessAvailabilityConfig;
|
|
27
|
+
schedules: ScheduleItem[];
|
|
28
|
+
timezone: string;
|
|
29
|
+
now: Date;
|
|
30
|
+
}): BusinessAvailability;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.computeBusinessAvailability = computeBusinessAvailability;
|
|
7
|
+
exports.normalizeBusinessAvailabilityConfig = normalizeBusinessAvailabilityConfig;
|
|
8
|
+
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
9
|
+
var _isSameOrAfter = _interopRequireDefault(require("dayjs/plugin/isSameOrAfter"));
|
|
10
|
+
var _isSameOrBefore = _interopRequireDefault(require("dayjs/plugin/isSameOrBefore"));
|
|
11
|
+
var _getDateIsInSchedule = require("../Schedule/getDateIsInSchedule");
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
_dayjs.default.extend(_isSameOrAfter.default);
|
|
14
|
+
_dayjs.default.extend(_isSameOrBefore.default);
|
|
15
|
+
const DAY = 86_400_000;
|
|
16
|
+
const behavior = value => value === 'show_menu_disabled' ? value : 'hide_all';
|
|
17
|
+
const message = value => typeof value === 'string' || value !== null && typeof value === 'object' && !Array.isArray(value) ? value : null;
|
|
18
|
+
function normalizeBusinessAvailabilityConfig(data) {
|
|
19
|
+
const rawIds = data['availability.operating_hours'];
|
|
20
|
+
const ids = Array.isArray(rawIds) ? rawIds.map(id => typeof id === 'number' || typeof id === 'string' ? Number(id) : NaN) : [];
|
|
21
|
+
const validIds = ids.filter(id => Number.isInteger(id) && id > 0);
|
|
22
|
+
const paused = data['availability.paused'];
|
|
23
|
+
return {
|
|
24
|
+
paused: paused === true || paused === 1 || paused === 'true' || paused === '1',
|
|
25
|
+
pauseBehavior: behavior(data['availability.pause_behavior']),
|
|
26
|
+
closedBehavior: behavior(data['availability.closed_behavior']),
|
|
27
|
+
pauseMessage: message(data['availability.pause_message']),
|
|
28
|
+
closedMessage: message(data['availability.closed_message']),
|
|
29
|
+
scheduleIds: [...new Set(validIds)],
|
|
30
|
+
invalidScheduleIds: rawIds != null && (!Array.isArray(rawIds) || validIds.length !== ids.length),
|
|
31
|
+
// Only an explicitly disabled setting changes the existing payment flow.
|
|
32
|
+
requirePaymentOnSubmit: data['sale.require_payment_on_submit'] !== false
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function createClock(timezone) {
|
|
36
|
+
if (!timezone) throw new Error('Store timezone is unavailable.');
|
|
37
|
+
const formatter = new Intl.DateTimeFormat('en-GB', {
|
|
38
|
+
timeZone: timezone,
|
|
39
|
+
year: 'numeric',
|
|
40
|
+
month: '2-digit',
|
|
41
|
+
day: '2-digit',
|
|
42
|
+
hour: '2-digit',
|
|
43
|
+
minute: '2-digit',
|
|
44
|
+
second: '2-digit',
|
|
45
|
+
hourCycle: 'h23'
|
|
46
|
+
});
|
|
47
|
+
const local = timestamp => {
|
|
48
|
+
const parts = {};
|
|
49
|
+
formatter.formatToParts(timestamp).forEach(part => {
|
|
50
|
+
parts[part.type] = part.value;
|
|
51
|
+
});
|
|
52
|
+
const date = `${parts.year}-${parts.month}-${parts.day}`;
|
|
53
|
+
return {
|
|
54
|
+
date,
|
|
55
|
+
scalar: Date.parse(`${date}T${parts.hour}:${parts.minute}:${parts.second}Z`)
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
const offsets = new Set();
|
|
59
|
+
const instants = scalar => {
|
|
60
|
+
offsets.clear();
|
|
61
|
+
for (let hours = -36; hours <= 36; hours += 6) {
|
|
62
|
+
const sample = scalar + hours * 3_600_000;
|
|
63
|
+
offsets.add(local(sample).scalar - sample);
|
|
64
|
+
}
|
|
65
|
+
return [...offsets].map(offset => scalar - offset).filter(instant => local(instant).scalar === scalar).sort((a, b) => a - b);
|
|
66
|
+
};
|
|
67
|
+
return {
|
|
68
|
+
local,
|
|
69
|
+
instants
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Business ordering is independent of reservation switches and Pickup slot availability. */
|
|
74
|
+
function computeBusinessAvailability(input) {
|
|
75
|
+
const {
|
|
76
|
+
config,
|
|
77
|
+
schedules,
|
|
78
|
+
timezone,
|
|
79
|
+
now
|
|
80
|
+
} = input;
|
|
81
|
+
const nowAt = now.getTime();
|
|
82
|
+
const base = {
|
|
83
|
+
requirePaymentOnSubmit: config.requirePaymentOnSubmit,
|
|
84
|
+
nextChangeAt: nowAt + DAY
|
|
85
|
+
};
|
|
86
|
+
if (config.paused) {
|
|
87
|
+
return {
|
|
88
|
+
...base,
|
|
89
|
+
status: 'paused',
|
|
90
|
+
behavior: config.pauseBehavior,
|
|
91
|
+
message: config.pauseMessage
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
if (config.invalidScheduleIds) throw new Error('Business operating-hours configuration is invalid.');
|
|
95
|
+
if (!config.scheduleIds.length) return {
|
|
96
|
+
...base,
|
|
97
|
+
status: 'open',
|
|
98
|
+
behavior: null,
|
|
99
|
+
message: null
|
|
100
|
+
};
|
|
101
|
+
const selected = schedules.filter(schedule => config.scheduleIds.includes(Number(schedule.id)));
|
|
102
|
+
if (config.scheduleIds.some(id => !selected.some(schedule => Number(schedule.id) === id))) {
|
|
103
|
+
throw new Error('A configured business operating-hours schedule is unavailable.');
|
|
104
|
+
}
|
|
105
|
+
const clock = createClock(timezone);
|
|
106
|
+
const current = clock.local(nowAt);
|
|
107
|
+
const today = Date.parse(`${current.date}T00:00:00Z`);
|
|
108
|
+
const nextMidnight = clock.instants(today + DAY).find(instant => instant > nowAt);
|
|
109
|
+
let nextChangeAt = nextMidnight ?? nowAt + 60_000;
|
|
110
|
+
let open = false;
|
|
111
|
+
// Yesterday contributes the tail of overnight windows; today supplies the next boundary.
|
|
112
|
+
for (const dateAt of [today - DAY, today]) {
|
|
113
|
+
const date = new Date(dateAt).toISOString().slice(0, 10);
|
|
114
|
+
// Schedule's resolver merges by time-of-day, so resolve each schedule independently.
|
|
115
|
+
for (const schedule of selected) {
|
|
116
|
+
for (const window of (0, _getDateIsInSchedule.getScheduleStartEndTimePoints)(date, [schedule])) {
|
|
117
|
+
const toMinutes = value => {
|
|
118
|
+
if (!/^(?:[01]\d|2[0-3]):[0-5]\d$/.test(value) && value !== '24:00') {
|
|
119
|
+
throw new Error('Business operating-hours schedule contains an invalid time.');
|
|
120
|
+
}
|
|
121
|
+
const [hours, minutes] = value.split(':').map(Number);
|
|
122
|
+
return hours * 60 + minutes;
|
|
123
|
+
};
|
|
124
|
+
const start = dateAt + toMinutes(window.start_time) * 60_000;
|
|
125
|
+
let end = dateAt + toMinutes(window.end_time) * 60_000;
|
|
126
|
+
if (end <= start) end += DAY;
|
|
127
|
+
if (current.scalar >= start && current.scalar < end) open = true;
|
|
128
|
+
for (const boundary of [start, end]) {
|
|
129
|
+
for (const instant of clock.instants(boundary)) {
|
|
130
|
+
if (instant > nowAt) nextChangeAt = Math.min(nextChangeAt, instant);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
// A timezone offset change can repeat/skip a wall-clock boundary. A local-only safety
|
|
137
|
+
// check also covers throttled timers; it does not fetch either configuration source.
|
|
138
|
+
nextChangeAt = Math.min(nextChangeAt, nowAt + 60_000);
|
|
139
|
+
return {
|
|
140
|
+
...base,
|
|
141
|
+
nextChangeAt,
|
|
142
|
+
status: open ? 'open' : 'closed',
|
|
143
|
+
behavior: open ? null : config.closedBehavior,
|
|
144
|
+
message: open ? null : config.closedMessage
|
|
145
|
+
};
|
|
146
|
+
}
|
|
@@ -69,6 +69,8 @@ export interface OpenDataConfig {
|
|
|
69
69
|
'reservation.time_slice'?: number | string;
|
|
70
70
|
'sale.allow_item_notes'?: boolean;
|
|
71
71
|
'sale.allow_order_notes'?: boolean;
|
|
72
|
+
/** False submits an order without starting or confirming payment. */
|
|
73
|
+
'sale.require_payment_on_submit'?: boolean | null;
|
|
72
74
|
'sale.enable_item_rules'?: boolean;
|
|
73
75
|
'sale.enable_short_number'?: boolean;
|
|
74
76
|
'sale.short_number_daily_reset'?: boolean;
|
|
@@ -4,7 +4,7 @@ import { OrderModuleAPI, CommitOrderParams, UpdateOrderBookingParams, UpdateOrde
|
|
|
4
4
|
import { CartItem } from '../Cart/types';
|
|
5
5
|
import { type SubmitPayloadEnhancer } from './utils';
|
|
6
6
|
import { type PickupTimingBooking, type PickupTimingBookingInput } from './pickupTiming';
|
|
7
|
-
import type { OrderAmountSnapshot, AddProductBookingInput, AddProductToOrderOptions, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, ReplaceTempOrderOptions, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions, RemoveProductsFromOrderOptions, SalesNote, SalesNotesMutationSnapshot, SetSalesNoteInput, PickupReferenceMode, PointCardSnapshotMergeContext, PointCardSnapshotItem, ShopServiceData, ShopServiceType } from './types';
|
|
7
|
+
import type { OrderAmountSnapshot, AddProductBookingInput, AddProductToOrderOptions, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, OrderCartIntentCommitContext, ReplaceTempOrderOptions, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions, RemoveProductsFromOrderOptions, SalesNote, SalesNotesMutationSnapshot, SetSalesNoteInput, PickupReferenceMode, PointCardSnapshotMergeContext, PointCardSnapshotItem, ShopServiceData, ShopServiceType } from './types';
|
|
8
8
|
import type { ICustomer } from '../AccountList/types';
|
|
9
9
|
import type { Discount } from '../Discount/types';
|
|
10
10
|
import { UnavailableReason } from '../Rules/types';
|
|
@@ -67,6 +67,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
67
67
|
* orderModule.updateOtherParams({ cacheId: 'cache-2', channel: 'pos' });
|
|
68
68
|
*/
|
|
69
69
|
updateOtherParams(params: Record<string, any>): void;
|
|
70
|
+
/** Internal intent boundary shared with asynchronous scanner/detail flows. */
|
|
71
|
+
createCartIntentCommitGuard(action: OrderCartIntentCommitContext['action'], tempOrder?: OrderTempOrder | null): () => void;
|
|
70
72
|
/** PC/H5 属于在线店铺;其它或缺失平台统一沿用 POS 行为。 */
|
|
71
73
|
isOnlineStorePlatform(): boolean;
|
|
72
74
|
/**
|
|
@@ -502,6 +504,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
502
504
|
private hasSameEntitlementMergePriceConfig;
|
|
503
505
|
private getBundleRuntimeIdentity;
|
|
504
506
|
private preservePersistedBundlePriceFields;
|
|
507
|
+
private isRestrictedCartProductUpdate;
|
|
505
508
|
private applyOrderProductUpdateToTempOrder;
|
|
506
509
|
updateOrderProduct(params: UpdateOrderProductParams): Promise<OrderProduct[]>;
|
|
507
510
|
updateOrderProducts(paramsList: UpdateOrderProductParams[]): Promise<OrderProduct[]>;
|
|
@@ -589,7 +592,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
589
592
|
generateIdempotencyToken(): string;
|
|
590
593
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
591
594
|
createOrder(params: CommitOrderParams['query']): {
|
|
592
|
-
type: "
|
|
595
|
+
type: "virtual" | "appointment_booking";
|
|
593
596
|
platform: string;
|
|
594
597
|
sales_channel: string;
|
|
595
598
|
order_sales_channel: string;
|