@pisell/pisellos 2.3.230 → 2.3.231
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/model/strategy/adapter/promotion/adapter.js +14 -2
- package/dist/model/strategy/adapter/promotion/evaluator.js +23 -8
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/model/strategy/adapter/promotion/type.d.ts +10 -2
- package/dist/modules/Customer/types.d.ts +0 -4
- package/dist/modules/Order/index.js +1411 -1318
- package/dist/modules/Order/types.d.ts +13 -36
- package/dist/modules/Order/types.js +2 -0
- package/dist/modules/Order/utils.js +0 -2
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/solution/BaseSales/index.js +0 -3
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +5 -18
- package/dist/solution/BaseSales/utils/cartPromotion.js +252 -168
- package/dist/solution/BookingByStep/index.d.ts +3 -3
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +45 -21
- package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +9 -9
- package/dist/solution/Checkout/index.js +69 -104
- package/dist/solution/Checkout/types.d.ts +0 -1
- package/dist/solution/ScanOrder/index.d.ts +1 -0
- package/dist/solution/ScanOrder/index.js +54 -48
- package/dist/solution/ScanOrder/menuAvailability.js +3 -25
- package/dist/solution/ScanOrder/shopTime.d.ts +6 -0
- package/dist/solution/ScanOrder/shopTime.js +36 -0
- package/dist/solution/VenueBooking/index.js +490 -522
- package/lib/model/strategy/adapter/promotion/adapter.js +10 -1
- package/lib/model/strategy/adapter/promotion/evaluator.js +18 -6
- package/lib/model/strategy/adapter/promotion/type.d.ts +10 -2
- package/lib/modules/Customer/types.d.ts +0 -4
- package/lib/modules/Order/index.js +109 -76
- package/lib/modules/Order/types.d.ts +13 -36
- package/lib/modules/Order/types.js +1 -0
- package/lib/modules/Order/utils.js +1 -5
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/solution/BaseSales/index.js +0 -3
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +5 -18
- package/lib/solution/BaseSales/utils/cartPromotion.js +87 -40
- package/lib/solution/BookingByStep/index.d.ts +3 -3
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +28 -11
- package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +9 -9
- package/lib/solution/Checkout/index.js +0 -21
- package/lib/solution/Checkout/types.d.ts +0 -1
- package/lib/solution/ScanOrder/index.d.ts +1 -0
- package/lib/solution/ScanOrder/index.js +26 -19
- package/lib/solution/ScanOrder/menuAvailability.js +3 -20
- package/lib/solution/ScanOrder/shopTime.d.ts +6 -0
- package/lib/solution/ScanOrder/shopTime.js +37 -0
- package/lib/solution/VenueBooking/index.js +1 -6
- package/package.json +1 -1
- package/dist/modules/Order/utils/bookingUuid.d.ts +0 -4
- package/dist/modules/Order/utils/bookingUuid.js +0 -24
- package/lib/modules/Order/utils/bookingUuid.d.ts +0 -4
- package/lib/modules/Order/utils/bookingUuid.js +0 -25
|
@@ -37,7 +37,7 @@ import { createModule } from "../BookingByStep/types";
|
|
|
37
37
|
import { ProductList } from "../../modules/ProductList";
|
|
38
38
|
import { getDateIsInSchedule } from "../../modules/Schedule/getDateIsInSchedule";
|
|
39
39
|
import { composeLinePrice, buildSubmitPayload, createUuidV4, getProductSkuOptions, normalizeSubmitBooking, normalizeSubmitCollectPaxValue, resolveTableOccupancyDuration, sumOptionUnitPrice } from "../../modules/Order/utils";
|
|
40
|
-
import
|
|
40
|
+
import { createScanOrderShopClock } from "./shopTime";
|
|
41
41
|
import { ItemRuleEvaluator } from "../../model/strategy/adapter/itemRule";
|
|
42
42
|
import { prepareScanOrderMenuAvailability, ScanOrderMenuAvailabilityError } from "./menuAvailability";
|
|
43
43
|
import { formatScanOrderMoreProducts } from "./additionalOrderPayload";
|
|
@@ -1333,7 +1333,16 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1333
1333
|
return _prepareRetailAvailability.apply(this, arguments);
|
|
1334
1334
|
}
|
|
1335
1335
|
return prepareRetailAvailability;
|
|
1336
|
-
}()
|
|
1336
|
+
}()
|
|
1337
|
+
}, {
|
|
1338
|
+
key: "getShopTime",
|
|
1339
|
+
value: function getShopTime() {
|
|
1340
|
+
var _this$getPickupTiming;
|
|
1341
|
+
var instant = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date();
|
|
1342
|
+
return createScanOrderShopClock(String((_this$getPickupTiming = this.getPickupTimingContextData('timezone')) !== null && _this$getPickupTiming !== void 0 ? _this$getPickupTiming : ''))(instant);
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
// ScanOrder 提交 payload enhancer:
|
|
1337
1346
|
// - 新单有桌台上下文但无 booking 时,补建基础预约(通用 Order 已不再自动生成)
|
|
1338
1347
|
// - 给所有 booking 注入 appointment_status: 'started'(扫码点餐语义)
|
|
1339
1348
|
// - 给所有 booking 的 metadata 注入 resource_select_type(来自预约规则商品的 resource.type)
|
|
@@ -1430,30 +1439,25 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1430
1439
|
var ruleProductUid = ruleProduct ? createUuidV4() : undefined;
|
|
1431
1440
|
var bookingCapacityDimensionId = (_pickFirstCustomCapac = pickFirstCustomCapacityDimensionId(_this5.enabledReservationRuleProducts)) !== null && _pickFirstCustomCapac !== void 0 ? _pickFirstCustomCapac : 0;
|
|
1432
1441
|
var bookings = payload.bookings || [];
|
|
1442
|
+
var scheduleDate = payload.schedule_date;
|
|
1433
1443
|
if (!tempOrder.order_id && bookings.length === 0) {
|
|
1434
|
-
var
|
|
1435
|
-
var extend = (_tempOrder$_extend = tempOrder._extend) !== null && _tempOrder$_extend !== void 0 ? _tempOrder$_extend : tempOrder._extend = {};
|
|
1436
|
-
if (!extend.scanOrderBookingUuid) {
|
|
1437
|
-
var _this5$store$order, _this5$store$order$pe;
|
|
1438
|
-
extend.scanOrderBookingUuid = createUuidV4();
|
|
1439
|
-
(_this5$store$order = _this5.store.order) === null || _this5$store$order === void 0 || (_this5$store$order$pe = _this5$store$order.persistTempOrder) === null || _this5$store$order$pe === void 0 || _this5$store$order$pe.call(_this5$store$order);
|
|
1440
|
-
}
|
|
1441
|
-
var bookingStart = dayjs(now);
|
|
1444
|
+
var bookingStart = _this5.getShopTime(now);
|
|
1442
1445
|
var bookingDuration = resolveTableOccupancyDuration(tempOrder);
|
|
1443
|
-
|
|
1446
|
+
// Add elapsed minutes before formatting both ends so DST changes are respected.
|
|
1447
|
+
var bookingEnd = _this5.getShopTime(new Date(now.getTime() + bookingDuration * 60000));
|
|
1448
|
+
scheduleDate = bookingStart.dateTime;
|
|
1444
1449
|
bookings = [normalizeSubmitBooking({
|
|
1445
|
-
uuid: extend.scanOrderBookingUuid,
|
|
1446
1450
|
relation_id: 0,
|
|
1447
1451
|
form_id: 0,
|
|
1448
|
-
start_time: bookingStart.
|
|
1449
|
-
start_date: bookingStart.
|
|
1450
|
-
end_time: bookingEnd.
|
|
1451
|
-
end_date: bookingEnd.
|
|
1452
|
+
start_time: bookingStart.time,
|
|
1453
|
+
start_date: bookingStart.date,
|
|
1454
|
+
end_time: bookingEnd.time,
|
|
1455
|
+
end_date: bookingEnd.date,
|
|
1452
1456
|
duration: bookingDuration,
|
|
1453
1457
|
metadata: {
|
|
1454
1458
|
unique_identification_number: bookingUuid
|
|
1455
1459
|
},
|
|
1456
|
-
select_date: bookingStart.
|
|
1460
|
+
select_date: bookingStart.date,
|
|
1457
1461
|
is_all: false,
|
|
1458
1462
|
like_status: 'common',
|
|
1459
1463
|
schedule_id: 0,
|
|
@@ -1514,6 +1518,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1514
1518
|
});
|
|
1515
1519
|
}
|
|
1516
1520
|
return _objectSpread(_objectSpread({}, payload), {}, {
|
|
1521
|
+
schedule_date: scheduleDate,
|
|
1517
1522
|
bookings: nextBookings,
|
|
1518
1523
|
products: nextProducts
|
|
1519
1524
|
});
|
|
@@ -1608,10 +1613,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1608
1613
|
_step5;
|
|
1609
1614
|
try {
|
|
1610
1615
|
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
1611
|
-
var _product$metadata3, _product$metadata4, _tempOrder$
|
|
1616
|
+
var _product$metadata3, _product$metadata4, _tempOrder$_extend;
|
|
1612
1617
|
var product = _step5.value;
|
|
1613
1618
|
var uid = (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.unique_identification_number;
|
|
1614
|
-
var origins = [product._origin, (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.origin, uid ? (_tempOrder$
|
|
1619
|
+
var origins = [product._origin, (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.origin, uid ? (_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 || (_tempOrder$_extend = _tempOrder$_extend.productsByUid) === null || _tempOrder$_extend === void 0 || (_tempOrder$_extend = _tempOrder$_extend[String(uid)]) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend.origin : undefined];
|
|
1615
1620
|
for (var _i5 = 0, _origins = origins; _i5 < _origins.length; _i5++) {
|
|
1616
1621
|
var origin = _origins[_i5];
|
|
1617
1622
|
if (origin && _typeof(origin) === 'object' && !Array.isArray(origin)) {
|
|
@@ -1637,7 +1642,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1637
1642
|
value: function () {
|
|
1638
1643
|
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
1639
1644
|
var _this6 = this;
|
|
1640
|
-
var _this$store$resource2, _resource$relationId, _this$otherParams13, _this$
|
|
1645
|
+
var _this$store$resource2, _resource$relationId, _this$otherParams13, _this$getPickupTiming2, _tempOrder$products, pax, tempOrderForSubmit, resourceTableName, isAdditionalOrder, enhanceBookingPayload, ruleProduct, resource, willAppendRuleProduct, productsToPrepare, associatedMenus, validateMenuAvailability, enhancePayload, result, tempOrder;
|
|
1641
1646
|
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1642
1647
|
while (1) switch (_context18.prev = _context18.next) {
|
|
1643
1648
|
case 0:
|
|
@@ -1693,7 +1698,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1693
1698
|
menuIds: associatedMenus.map(function (menu) {
|
|
1694
1699
|
return menu === null || menu === void 0 ? void 0 : menu.value;
|
|
1695
1700
|
}),
|
|
1696
|
-
timezone: String((_this$
|
|
1701
|
+
timezone: String((_this$getPickupTiming2 = this.getPickupTimingContextData('timezone')) !== null && _this$getPickupTiming2 !== void 0 ? _this$getPickupTiming2 : ''),
|
|
1697
1702
|
products: productsToPrepare,
|
|
1698
1703
|
productSources: this.getMenuAvailabilityProductSources(tempOrderForSubmit)
|
|
1699
1704
|
});
|
|
@@ -2914,6 +2919,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2914
2919
|
pendingRequestPaxMin,
|
|
2915
2920
|
pendingRequestPaxMax,
|
|
2916
2921
|
reservationProductList,
|
|
2922
|
+
_this$getShopTime,
|
|
2917
2923
|
scheduleDate,
|
|
2918
2924
|
scheduleDatetime,
|
|
2919
2925
|
loaded,
|
|
@@ -3012,7 +3018,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3012
3018
|
if (operatingHourIds.length && this.store.schedule) {
|
|
3013
3019
|
scheduleList = this.store.schedule.getScheduleListByIds(operatingHourIds);
|
|
3014
3020
|
if (scheduleList.length) {
|
|
3015
|
-
now =
|
|
3021
|
+
now = this.getShopTime().dateTime;
|
|
3016
3022
|
outsideOperatingHours = !getDateIsInSchedule(now, scheduleList);
|
|
3017
3023
|
}
|
|
3018
3024
|
}
|
|
@@ -3056,16 +3062,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3056
3062
|
})
|
|
3057
3063
|
});
|
|
3058
3064
|
case 42:
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
_context37.next = 46;
|
|
3065
|
+
_this$getShopTime = this.getShopTime(), scheduleDate = _this$getShopTime.date, scheduleDatetime = _this$getShopTime.dateTime;
|
|
3066
|
+
_context37.next = 45;
|
|
3062
3067
|
return reservationProductList.loadProducts({
|
|
3063
3068
|
product_ids: reservationLinkIds,
|
|
3064
3069
|
schedule_date: scheduleDate,
|
|
3065
3070
|
schedule_datetime: scheduleDatetime,
|
|
3066
3071
|
cacheId: this.cacheId
|
|
3067
3072
|
});
|
|
3068
|
-
case
|
|
3073
|
+
case 45:
|
|
3069
3074
|
loaded = _context37.sent;
|
|
3070
3075
|
if (Array.isArray(loaded)) {
|
|
3071
3076
|
matchedRuleProduct = findReservationRuleProductByResourceId(loaded, normalizedResourceId);
|
|
@@ -3117,9 +3122,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3117
3122
|
}
|
|
3118
3123
|
|
|
3119
3124
|
// Step2: 请求新的资源占用详情接口。occupy_details 第一维是资源,不是订单。
|
|
3120
|
-
_context37.next =
|
|
3125
|
+
_context37.next = 49;
|
|
3121
3126
|
return this.fetchResourceOccupyDetailsByResourceId(normalizedResourceId);
|
|
3122
|
-
case
|
|
3127
|
+
case 49:
|
|
3123
3128
|
occupyDetails = _context37.sent;
|
|
3124
3129
|
occupyDetail = (_occupyDetails$ = occupyDetails[0]) !== null && _occupyDetails$ !== void 0 ? _occupyDetails$ : null; // Step3: 结合预约规则商品的 product_resource.resources 与占用接口返回的 form_id,
|
|
3125
3130
|
// 计算当前桌台的 resourceSelectType(single/multiple/capacity)
|
|
@@ -3127,7 +3132,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3127
3132
|
allowAddItems = toBoolean(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['sale.allow_add_items']);
|
|
3128
3133
|
additionalOrderResult = this.resolveAdditionalOrderFromOccupyDetail(occupyDetail, resourceSelectType, allowAddItems);
|
|
3129
3134
|
if (!(additionalOrderResult.reason === 'multiple_orders')) {
|
|
3130
|
-
_context37.next =
|
|
3135
|
+
_context37.next = 60;
|
|
3131
3136
|
break;
|
|
3132
3137
|
}
|
|
3133
3138
|
multipleOrdersState = _objectSpread(_objectSpread({}, this.normalizeResourceState(occupyDetail, resourceSelectType, hasOrderId)), {}, {
|
|
@@ -3148,7 +3153,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3148
3153
|
resourceSelectType: resourceSelectType
|
|
3149
3154
|
});
|
|
3150
3155
|
return _context37.abrupt("return", _availabilityInfo);
|
|
3151
|
-
case
|
|
3156
|
+
case 60:
|
|
3152
3157
|
// Step4: 用 occupyDetail + resourceSelectType 规整为 resourceState
|
|
3153
3158
|
resourceState = this.normalizeResourceState(occupyDetail, resourceSelectType, hasOrderId);
|
|
3154
3159
|
additionalOrderId = additionalOrderResult.order_id;
|
|
@@ -3194,12 +3199,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3194
3199
|
|
|
3195
3200
|
// 空闲状态下自动准备本地临时订单,供后续“购物车式”商品操作使用
|
|
3196
3201
|
if (!(availabilityInfo.mode === 'idle')) {
|
|
3197
|
-
_context37.next =
|
|
3202
|
+
_context37.next = 72;
|
|
3198
3203
|
break;
|
|
3199
3204
|
}
|
|
3200
|
-
_context37.next =
|
|
3205
|
+
_context37.next = 72;
|
|
3201
3206
|
return this.addNewOrder();
|
|
3202
|
-
case
|
|
3207
|
+
case 72:
|
|
3203
3208
|
isAdditionalOrderMode = availabilityInfo.mode === 'additional_order' || availabilityInfo.mode === 'additional_order_with_code'; // 如果是加单模式,tempOrder 里需要记录目标订单 id,提交的时候走加单接口
|
|
3204
3209
|
if (isAdditionalOrderMode) {
|
|
3205
3210
|
tempOrder.order_id = additionalOrderId;
|
|
@@ -3215,13 +3220,13 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3215
3220
|
} : {}));
|
|
3216
3221
|
return acc;
|
|
3217
3222
|
}, []) : []; // pax 由 setEntryPaxNumber 负责写入 itemRuleRuntimeConfig.pax
|
|
3218
|
-
_context37.next =
|
|
3223
|
+
_context37.next = 78;
|
|
3219
3224
|
return this.setItemRuleRuntimeConfig({
|
|
3220
3225
|
serviceType: (_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.businessCode,
|
|
3221
3226
|
submissionIndex: isAdditionalOrderMode ? 1 : 0,
|
|
3222
3227
|
historicalItems: historicalItems
|
|
3223
3228
|
});
|
|
3224
|
-
case
|
|
3229
|
+
case 78:
|
|
3225
3230
|
// operating_hours 超出营业时段 + closed_behavior=show_menu_disabled:
|
|
3226
3231
|
// 允许浏览商品但 UI 层需拦截“下一步”,这里覆盖最终 mode 并回传错误提示
|
|
3227
3232
|
if (outsideOperatingHours && closedBehaviorValue === 'show_menu_disabled') {
|
|
@@ -3243,18 +3248,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3243
3248
|
isFull: resourceState.isFull
|
|
3244
3249
|
});
|
|
3245
3250
|
return _context37.abrupt("return", availabilityInfo);
|
|
3246
|
-
case
|
|
3247
|
-
_context37.prev =
|
|
3251
|
+
case 83:
|
|
3252
|
+
_context37.prev = 83;
|
|
3248
3253
|
_context37.t0 = _context37["catch"](3);
|
|
3249
3254
|
this.logMethodError('checkResourceAvailable', _context37.t0.message, {
|
|
3250
3255
|
resourceId: normalizedResourceId
|
|
3251
3256
|
});
|
|
3252
3257
|
throw _context37.t0;
|
|
3253
|
-
case
|
|
3258
|
+
case 87:
|
|
3254
3259
|
case "end":
|
|
3255
3260
|
return _context37.stop();
|
|
3256
3261
|
}
|
|
3257
|
-
}, _callee37, this, [[3,
|
|
3262
|
+
}, _callee37, this, [[3, 83]]);
|
|
3258
3263
|
}));
|
|
3259
3264
|
function checkResourceAvailable(_x20) {
|
|
3260
3265
|
return _checkResourceAvailable.apply(this, arguments);
|
|
@@ -3344,7 +3349,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3344
3349
|
value: function () {
|
|
3345
3350
|
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40() {
|
|
3346
3351
|
var _this$otherParams21;
|
|
3347
|
-
var associatedMenus, menu_list_ids, res, productList, formattedRes;
|
|
3352
|
+
var associatedMenus, menu_list_ids, _this$getShopTime2, date, dateTime, res, productList, formattedRes;
|
|
3348
3353
|
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
3349
3354
|
while (1) switch (_context40.prev = _context40.next) {
|
|
3350
3355
|
case 0:
|
|
@@ -3361,14 +3366,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3361
3366
|
}
|
|
3362
3367
|
throw new Error('products 模块未初始化');
|
|
3363
3368
|
case 6:
|
|
3364
|
-
|
|
3369
|
+
_this$getShopTime2 = this.getShopTime(), date = _this$getShopTime2.date, dateTime = _this$getShopTime2.dateTime;
|
|
3370
|
+
_context40.next = 9;
|
|
3365
3371
|
return this.store.products.loadProducts({
|
|
3366
3372
|
menu_list_ids: menu_list_ids,
|
|
3367
3373
|
cacheId: this.cacheId,
|
|
3368
|
-
schedule_date:
|
|
3369
|
-
schedule_datetime:
|
|
3374
|
+
schedule_date: date,
|
|
3375
|
+
schedule_datetime: dateTime
|
|
3370
3376
|
});
|
|
3371
|
-
case
|
|
3377
|
+
case 9:
|
|
3372
3378
|
res = _context40.sent;
|
|
3373
3379
|
productList = this.assertProductListLoaded('getProductList', res, {
|
|
3374
3380
|
menu_list_ids: menu_list_ids,
|
|
@@ -3379,8 +3385,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3379
3385
|
menuCount: menu_list_ids.length
|
|
3380
3386
|
});
|
|
3381
3387
|
return _context40.abrupt("return", formattedRes);
|
|
3382
|
-
case
|
|
3383
|
-
_context40.prev =
|
|
3388
|
+
case 16:
|
|
3389
|
+
_context40.prev = 16;
|
|
3384
3390
|
_context40.t0 = _context40["catch"](3);
|
|
3385
3391
|
if (!(_context40.t0 !== null && _context40.t0 !== void 0 && _context40.t0.__scanOrderLogged)) {
|
|
3386
3392
|
this.logMethodError('getProductList', _context40.t0, {
|
|
@@ -3389,11 +3395,11 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3389
3395
|
});
|
|
3390
3396
|
}
|
|
3391
3397
|
throw _context40.t0;
|
|
3392
|
-
case
|
|
3398
|
+
case 20:
|
|
3393
3399
|
case "end":
|
|
3394
3400
|
return _context40.stop();
|
|
3395
3401
|
}
|
|
3396
|
-
}, _callee40, this, [[3,
|
|
3402
|
+
}, _callee40, this, [[3, 16]]);
|
|
3397
3403
|
}));
|
|
3398
3404
|
function getProductList() {
|
|
3399
3405
|
return _getProductList.apply(this, arguments);
|
|
@@ -31,6 +31,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
31
31
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
32
32
|
import { getDateIsInSchedule } from "../ShopDiscount/utils";
|
|
33
33
|
import dayjs from 'dayjs';
|
|
34
|
+
import { createScanOrderShopClock } from "./shopTime";
|
|
34
35
|
export var ScanOrderMenuAvailabilityError = /*#__PURE__*/function (_Error) {
|
|
35
36
|
_inherits(ScanOrderMenuAvailabilityError, _Error);
|
|
36
37
|
var _super = _createSuper(ScanOrderMenuAvailabilityError);
|
|
@@ -139,29 +140,6 @@ function validateSchedule(schedule) {
|
|
|
139
140
|
return typeof day !== 'number' || !Number.isInteger(day) || day < 0 || day > 6;
|
|
140
141
|
}))) return fail();
|
|
141
142
|
}
|
|
142
|
-
function createShopClock(timezone) {
|
|
143
|
-
if (typeof timezone !== 'string' || !timezone.trim()) return fail();
|
|
144
|
-
var formatter = new Intl.DateTimeFormat('en-GB', {
|
|
145
|
-
timeZone: timezone.trim(),
|
|
146
|
-
year: 'numeric',
|
|
147
|
-
month: '2-digit',
|
|
148
|
-
day: '2-digit',
|
|
149
|
-
hour: '2-digit',
|
|
150
|
-
minute: '2-digit',
|
|
151
|
-
second: '2-digit',
|
|
152
|
-
hourCycle: 'h23'
|
|
153
|
-
});
|
|
154
|
-
return function () {
|
|
155
|
-
var parts = formatter.formatToParts(new Date());
|
|
156
|
-
var value = function value(type) {
|
|
157
|
-
var _parts$find;
|
|
158
|
-
return (_parts$find = parts.find(function (part) {
|
|
159
|
-
return part.type === type;
|
|
160
|
-
})) === null || _parts$find === void 0 ? void 0 : _parts$find.value;
|
|
161
|
-
};
|
|
162
|
-
return "".concat(value('year'), "-").concat(value('month'), "-").concat(value('day'), " ").concat(value('hour'), ":").concat(value('minute'), ":").concat(value('second'));
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
143
|
function collectSources(target, sources) {
|
|
166
144
|
var _iterator = _createForOfIteratorHelper(sources),
|
|
167
145
|
_step;
|
|
@@ -206,7 +184,7 @@ function _prepareScanOrderMenuAvailability() {
|
|
|
206
184
|
return id !== undefined;
|
|
207
185
|
});
|
|
208
186
|
_context.prev = 2;
|
|
209
|
-
now =
|
|
187
|
+
now = createScanOrderShopClock(timezone);
|
|
210
188
|
configuredIds = readIds(menuIds);
|
|
211
189
|
_context.next = 7;
|
|
212
190
|
return Promise.all([request.get('/form/data/v1', {
|
|
@@ -290,7 +268,7 @@ function _prepareScanOrderMenuAvailability() {
|
|
|
290
268
|
return _context.abrupt("return", function (currentProducts) {
|
|
291
269
|
var currentSources = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
292
270
|
try {
|
|
293
|
-
var currentTime = now();
|
|
271
|
+
var currentTime = now().dateTime;
|
|
294
272
|
var collections = new Map(collectionsByProduct);
|
|
295
273
|
collectSources(collections, [].concat(_toConsumableArray(currentProducts), _toConsumableArray(currentSources)));
|
|
296
274
|
var unavailable = [];
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** Format absolute instants as the shop's calendar fields, independent of the device timezone. */
|
|
2
|
+
export function createScanOrderShopClock(timezone) {
|
|
3
|
+
var message = 'Unable to determine store time. Please refresh and try again.';
|
|
4
|
+
var formatter;
|
|
5
|
+
try {
|
|
6
|
+
if (typeof timezone !== 'string' || !timezone.trim()) throw new Error(message);
|
|
7
|
+
formatter = new Intl.DateTimeFormat('en-GB', {
|
|
8
|
+
timeZone: timezone.trim(),
|
|
9
|
+
year: 'numeric',
|
|
10
|
+
month: '2-digit',
|
|
11
|
+
day: '2-digit',
|
|
12
|
+
hour: '2-digit',
|
|
13
|
+
minute: '2-digit',
|
|
14
|
+
second: '2-digit',
|
|
15
|
+
hourCycle: 'h23'
|
|
16
|
+
});
|
|
17
|
+
} catch (_unused) {
|
|
18
|
+
throw new Error(message);
|
|
19
|
+
}
|
|
20
|
+
return function () {
|
|
21
|
+
var instant = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date();
|
|
22
|
+
var parts = formatter.formatToParts(instant);
|
|
23
|
+
var value = function value(type) {
|
|
24
|
+
return parts.find(function (part) {
|
|
25
|
+
return part.type === type;
|
|
26
|
+
}).value;
|
|
27
|
+
};
|
|
28
|
+
var date = "".concat(value('year'), "-").concat(value('month'), "-").concat(value('day'));
|
|
29
|
+
var time = "".concat(value('hour'), ":").concat(value('minute'));
|
|
30
|
+
return {
|
|
31
|
+
date: date,
|
|
32
|
+
time: time,
|
|
33
|
+
dateTime: "".concat(date, " ").concat(time, ":").concat(value('second'))
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
}
|