@pisell/pisellos 2.3.195 → 2.3.197
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/BookingContext/utils/calendarBooking.d.ts +15 -0
- package/dist/modules/BookingContext/utils/calendarBooking.js +207 -0
- package/dist/modules/BookingContext/utils/index.d.ts +1 -0
- package/dist/modules/BookingContext/utils/index.js +1 -0
- package/dist/modules/BookingContext/utils/productExtend.d.ts +6 -0
- package/dist/modules/BookingContext/utils/productExtend.js +21 -0
- package/dist/modules/Order/index.d.ts +3 -0
- package/dist/modules/Order/index.js +127 -46
- package/dist/modules/Order/unpaidAmountGap.d.ts +6 -0
- package/dist/modules/Order/unpaidAmountGap.js +72 -0
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/ResourcePlanner/planner.js +24 -0
- package/dist/modules/ResourcePlanner/types.d.ts +7 -0
- package/dist/server/index.js +207 -193
- package/dist/server/modules/order/index.js +2 -1
- package/dist/shared/receipt/small-ticket.d.ts +3 -0
- package/dist/shared/receipt/small-ticket.js +26 -3
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingTicket/index.d.ts +2 -14
- package/dist/solution/BookingTicket/index.js +8 -4
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +2 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.js +35 -8
- package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
- package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.js +188 -0
- package/dist/solution/OrderInvoicePreview/index.js +13 -8
- package/dist/solution/UnifiedBookingSales/index.d.ts +16 -2
- package/dist/solution/UnifiedBookingSales/index.js +1670 -1377
- package/dist/solution/UnifiedBookingSales/types.d.ts +1 -0
- package/dist/solution/UnifiedBookingSales/venueCatalogSession.js +11 -5
- package/lib/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
- package/lib/modules/BookingContext/utils/calendarBooking.js +156 -0
- package/lib/modules/BookingContext/utils/index.d.ts +1 -0
- package/lib/modules/BookingContext/utils/index.js +11 -0
- package/lib/modules/BookingContext/utils/productExtend.d.ts +6 -0
- package/lib/modules/BookingContext/utils/productExtend.js +23 -0
- package/lib/modules/Order/index.d.ts +3 -0
- package/lib/modules/Order/index.js +85 -16
- package/lib/modules/Order/unpaidAmountGap.d.ts +6 -0
- package/lib/modules/Order/unpaidAmountGap.js +60 -0
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/ResourcePlanner/planner.js +23 -0
- package/lib/modules/ResourcePlanner/types.d.ts +7 -0
- package/lib/server/index.js +21 -5
- package/lib/server/modules/order/index.js +2 -1
- package/lib/shared/receipt/small-ticket.d.ts +3 -0
- package/lib/shared/receipt/small-ticket.js +24 -1
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingTicket/index.d.ts +2 -14
- package/lib/solution/BookingTicket/index.js +4 -2
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +2 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.js +33 -3
- package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
- package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.js +136 -0
- package/lib/solution/OrderInvoicePreview/index.js +6 -1
- package/lib/solution/UnifiedBookingSales/index.d.ts +16 -2
- package/lib/solution/UnifiedBookingSales/index.js +176 -36
- package/lib/solution/UnifiedBookingSales/types.d.ts +1 -0
- package/lib/solution/UnifiedBookingSales/venueCatalogSession.js +9 -5
- package/package.json +1 -1
|
@@ -34,6 +34,7 @@ import { cloneDeep, isEqual } from 'lodash-es';
|
|
|
34
34
|
import { isLocalFinalizedPayment, LOCAL_EFTPOS_FINALIZED, LOCAL_EFTPOS_REFRESH_REQUIRED, requiresLocalPaymentRefresh } from "../../../modules/Order/localEftposState";
|
|
35
35
|
import dayjs from 'dayjs';
|
|
36
36
|
import { BaseModule } from "../../../modules/BaseModule";
|
|
37
|
+
import { normalizeUnpaidOrderAmountGap } from "../../../modules/Order/unpaidAmountGap";
|
|
37
38
|
import { applyOrderCollectionUidRemaps, getOrderCollectionPersistentId, getOrderCollectionReferenceUid, getOrderCollectionUid, isSameOrderCollectionItem, mergeOrderCollectionItems, normalizeOrderCollections } from "../../../modules/Order/utils/orderCollectionIdentity";
|
|
38
39
|
import { OrderHooks } from "./types";
|
|
39
40
|
import { getOrderPaymentIdentityKeys, isIdentifiedPendingOrderPayment, isPendingOrderPayment, mergeOrderPaymentListsByIdentity, mergeOrderPaymentRecord, resolveOrderPaymentIdentity } from "../../../modules/Order/payment-utils";
|
|
@@ -375,7 +376,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
375
376
|
this.logInfo('订单子项身份已规范化', context);
|
|
376
377
|
}
|
|
377
378
|
}
|
|
378
|
-
return result.order;
|
|
379
|
+
return normalizeUnpaidOrderAmountGap(result.order);
|
|
379
380
|
}
|
|
380
381
|
|
|
381
382
|
/**
|
|
@@ -15,6 +15,9 @@ export interface SmallTicketShopInfo {
|
|
|
15
15
|
currency_code?: string;
|
|
16
16
|
primary_locale?: string;
|
|
17
17
|
timezone?: string;
|
|
18
|
+
/** Customer-facing shop domain, supplied by the host shop context. */
|
|
19
|
+
default_domain?: string;
|
|
20
|
+
private_domain_protocol?: string;
|
|
18
21
|
[key: string]: any;
|
|
19
22
|
}
|
|
20
23
|
export interface BuildSmallTicketDataParams {
|
|
@@ -20,6 +20,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
20
20
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
21
21
|
import dayjs from 'dayjs';
|
|
22
22
|
import Decimal from 'decimal.js';
|
|
23
|
+
import { normalizeUnpaidOrderAmountGap } from "../../modules/Order/unpaidAmountGap";
|
|
23
24
|
import { getProductHolderRelations, hasProductBooking } from "../../modules/Order/holderRelations";
|
|
24
25
|
import { isFulfillmentTimingBooking } from "../../modules/Order/pickupTiming";
|
|
25
26
|
import { resolveInvoiceDataVisibility } from "./templateVisibility";
|
|
@@ -318,7 +319,8 @@ var LABELS = {
|
|
|
318
319
|
}
|
|
319
320
|
};
|
|
320
321
|
export function buildSmallTicketData(params) {
|
|
321
|
-
var
|
|
322
|
+
var normalizedOrder = normalizeUnpaidOrderAmountGap(params.order || {});
|
|
323
|
+
var order = params.includeReceiptKeys ? copyReceiptSource(normalizedOrder) : normalizedOrder;
|
|
322
324
|
var shopInfo = params.shopInfo || {};
|
|
323
325
|
var locales = resolveLocales(shopInfo, params.locales);
|
|
324
326
|
var productMap = params.productMap || {};
|
|
@@ -409,10 +411,14 @@ function buildBaseData(params) {
|
|
|
409
411
|
currencySymbol = params.currencySymbol,
|
|
410
412
|
financials = params.financials;
|
|
411
413
|
var orderNumber = stringify(order.buzzer || order.shop_full_order_number);
|
|
412
|
-
|
|
414
|
+
var rewardClaim = buildRewardClaimUrl(shopInfo, order.shop_order_number);
|
|
415
|
+
return _objectSpread(_objectSpread({
|
|
413
416
|
shop_name: stringify(shopInfo.name || order.shop_name),
|
|
414
417
|
note: stringify(order.note),
|
|
415
|
-
shop_order_number: stringify(order.shop_order_number)
|
|
418
|
+
shop_order_number: stringify(order.shop_order_number)
|
|
419
|
+
}, rewardClaim ? {
|
|
420
|
+
reward_claim: rewardClaim
|
|
421
|
+
} : {}), {}, {
|
|
416
422
|
order_number: orderNumber,
|
|
417
423
|
shop_tax_number: stringify(shopInfo.tax_number || order.shop_tax_number),
|
|
418
424
|
shop_phone: stringify(shopInfo.phone || order.shop_phone),
|
|
@@ -430,6 +436,23 @@ function buildBaseData(params) {
|
|
|
430
436
|
updated_at: formatDateTime(order.updated_at, locale)
|
|
431
437
|
} : {});
|
|
432
438
|
}
|
|
439
|
+
function buildRewardClaimUrl(shopInfo, shopOrderNumber) {
|
|
440
|
+
var domain = typeof shopInfo.default_domain === 'string' ? shopInfo.default_domain.trim() : '';
|
|
441
|
+
var orderNumber = typeof shopOrderNumber === 'string' ? shopOrderNumber.trim() : typeof shopOrderNumber === 'number' && Number.isFinite(shopOrderNumber) ? String(shopOrderNumber) : '';
|
|
442
|
+
if (!domain || !orderNumber) return undefined;
|
|
443
|
+
try {
|
|
444
|
+
var protocol = shopInfo.private_domain_protocol === 'http' ? 'http' : 'https';
|
|
445
|
+
var base = new URL(/^[a-z][a-z\d+.-]*:\/\//i.test(domain) ? domain : "".concat(protocol, "://").concat(domain));
|
|
446
|
+
if (!['http:', 'https:'].includes(base.protocol) || base.username || base.password) {
|
|
447
|
+
return undefined;
|
|
448
|
+
}
|
|
449
|
+
var url = new URL('/claim-purchase-rewards', base);
|
|
450
|
+
url.searchParams.set('shop_order_number', orderNumber);
|
|
451
|
+
return url.toString();
|
|
452
|
+
} catch (_unused) {
|
|
453
|
+
return undefined;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
433
456
|
function buildProducts(order, locale, productMap) {
|
|
434
457
|
var products = Array.isArray(order.products) ? order.products : [];
|
|
435
458
|
var allergyByProductUid = buildProductAllergyMap(order, locale);
|
|
@@ -328,7 +328,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
328
328
|
date: string;
|
|
329
329
|
status: string;
|
|
330
330
|
week: string;
|
|
331
|
-
weekNum: 0 |
|
|
331
|
+
weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
|
|
332
332
|
}[]>;
|
|
333
333
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
334
334
|
private getScheduleDataByIds;
|
|
@@ -375,7 +375,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
375
375
|
};
|
|
376
376
|
setOtherData(key: string, value: any): void;
|
|
377
377
|
getOtherData(key: string): any;
|
|
378
|
-
getProductTypeById(id: number): Promise<"
|
|
378
|
+
getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
|
|
379
379
|
/**
|
|
380
380
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
381
381
|
*
|
|
@@ -366,7 +366,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
366
366
|
* 获取当前的客户搜索条件
|
|
367
367
|
* @returns 当前搜索条件
|
|
368
368
|
*/
|
|
369
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
369
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
370
370
|
/**
|
|
371
371
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
372
372
|
* @returns 客户状态
|
|
@@ -485,19 +485,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
485
485
|
* 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
|
|
486
486
|
* 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
|
|
487
487
|
*/
|
|
488
|
-
decideAddProduct(item: any, options?: Partial<AddProductDecideContext>):
|
|
489
|
-
action: "reloadCatalog";
|
|
490
|
-
} | {
|
|
491
|
-
action: "add";
|
|
492
|
-
cacheItem: any;
|
|
493
|
-
} | {
|
|
494
|
-
action: "requiresDetail";
|
|
495
|
-
payload: AddProductRequiresDetailPayload;
|
|
496
|
-
} | {
|
|
497
|
-
action: "requiresBookingEdit";
|
|
498
|
-
cacheItem: any;
|
|
499
|
-
payload: import("./utils/addProductDecision").AddProductRequiresBookingEditPayload;
|
|
500
|
-
};
|
|
488
|
+
decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
|
|
501
489
|
/** 规格弹窗 callback 后的第二段决策。 */
|
|
502
490
|
decideAfterDetail(cacheItem: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
|
|
503
491
|
/**
|
|
@@ -2740,7 +2740,8 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2740
2740
|
var _extra$date,
|
|
2741
2741
|
_extra$presetStartTim,
|
|
2742
2742
|
_this$getOrderSession,
|
|
2743
|
-
_this8 = this
|
|
2743
|
+
_this8 = this,
|
|
2744
|
+
_this$otherParams9;
|
|
2744
2745
|
var state = this.store.bookingContext.getState();
|
|
2745
2746
|
var date = (_extra$date = extra === null || extra === void 0 ? void 0 : extra.date) !== null && _extra$date !== void 0 ? _extra$date : state.date;
|
|
2746
2747
|
return _objectSpread(_objectSpread({
|
|
@@ -2753,7 +2754,8 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2753
2754
|
orderSessionId: (_this$getOrderSession = this.getOrderSessionId()) !== null && _this$getOrderSession !== void 0 ? _this$getOrderSession : undefined,
|
|
2754
2755
|
isOrderSessionCurrent: function isOrderSessionCurrent(sessionId) {
|
|
2755
2756
|
return _this8.isOrderSessionCurrent(sessionId);
|
|
2756
|
-
}
|
|
2757
|
+
},
|
|
2758
|
+
platform: String(((_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.platform) || '').trim().toLowerCase()
|
|
2757
2759
|
});
|
|
2758
2760
|
}
|
|
2759
2761
|
|
|
@@ -2855,7 +2857,8 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2855
2857
|
_this$store$order$get5,
|
|
2856
2858
|
_extra$presetStartTim2,
|
|
2857
2859
|
_this$getOrderSession2,
|
|
2858
|
-
_this9 = this
|
|
2860
|
+
_this9 = this,
|
|
2861
|
+
_this$otherParams10;
|
|
2859
2862
|
var bookingContextState = this.store.bookingContext.getState();
|
|
2860
2863
|
var date = (_extra$date2 = extra === null || extra === void 0 ? void 0 : extra.date) !== null && _extra$date2 !== void 0 ? _extra$date2 : bookingContextState.date;
|
|
2861
2864
|
var orderCustomerId = (_ref14 = (_this$getOrderCustome4 = (_this$getOrderCustome5 = this.getOrderCustomerSnapshot()) === null || _this$getOrderCustome5 === void 0 ? void 0 : _this$getOrderCustome5.id) !== null && _this$getOrderCustome4 !== void 0 ? _this$getOrderCustome4 : (_this$store$order$get5 = this.store.order.getTempOrder()) === null || _this$store$order$get5 === void 0 ? void 0 : _this$store$order$get5.customer_id) !== null && _ref14 !== void 0 ? _ref14 : undefined;
|
|
@@ -2871,7 +2874,8 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2871
2874
|
orderSessionId: (_this$getOrderSession2 = this.getOrderSessionId()) !== null && _this$getOrderSession2 !== void 0 ? _this$getOrderSession2 : undefined,
|
|
2872
2875
|
isOrderSessionCurrent: function isOrderSessionCurrent(sessionId) {
|
|
2873
2876
|
return _this9.isOrderSessionCurrent(sessionId);
|
|
2874
|
-
}
|
|
2877
|
+
},
|
|
2878
|
+
platform: String(((_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.platform) || '').trim().toLowerCase()
|
|
2875
2879
|
});
|
|
2876
2880
|
}
|
|
2877
2881
|
|
|
@@ -41,6 +41,8 @@ export declare function decideAfterDetail(cacheItem: any, ctx?: AddProductDecide
|
|
|
41
41
|
* @deprecated 请用 `decideAddProduct`;保留兼容:autoClose=true 仅表示可直接加车(action=add)。
|
|
42
42
|
*/
|
|
43
43
|
export interface AddProductRequiresDetailPayload {
|
|
44
|
+
/** Same prepared decision cache supplied to the Host; never a separate Flow preflight. */
|
|
45
|
+
preparedCacheItem?: any;
|
|
44
46
|
item: ProductData | Record<string, any>;
|
|
45
47
|
/** UI 需展示的子弹窗开关。 */
|
|
46
48
|
showConfig: {
|
|
@@ -5,7 +5,8 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
5
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
6
|
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); }
|
|
7
7
|
import dayjs from 'dayjs';
|
|
8
|
-
import { cacheItemToBookingInput, derivePresetStartTimeFromDate, getProductExtend, getIsAutoClose, isSessionProduct, isBookingProduct, applySessionTimesToExtend, hasActualResourceSelection, productNeedsResourceExtend } from "../../../modules/BookingContext";
|
|
8
|
+
import { cacheItemToBookingInput, derivePresetStartTimeFromDate, getProductExtend, getIsAutoClose, isSessionProduct, isBookingProduct, applySessionTimesToExtend, hasActualResourceSelection, productNeedsResourceExtend, getCalendarBookingRange, calendarBookingNeedsInput, calendarBookingPreparationKey } from "../../../modules/BookingContext";
|
|
9
|
+
import { resolveUniqueCartDetailValue } from "./resolveUniqueCartDetail";
|
|
9
10
|
import { transformBaseProductToOrderProduct } from "../../BaseSales/utils/transformBaseProductToOrderProduct";
|
|
10
11
|
import { buildProductSkuFromCacheItem } from "./weighingProductSku";
|
|
11
12
|
import { isSelfServicePlatform } from "../../../utils/platform";
|
|
@@ -34,6 +35,7 @@ function needsSpecDetailModal(item) {
|
|
|
34
35
|
* 第二段:预约商品是否仍需打开资源 / 时间编辑(自助终端强制打开,其他渠道与 info2 `cacheItem.autoClose` 等价)。
|
|
35
36
|
*/
|
|
36
37
|
function needsBookingEdit(cacheItem, ctx) {
|
|
38
|
+
if (getCalendarBookingRange(cacheItem, ctx)) return calendarBookingNeedsInput(cacheItem);
|
|
37
39
|
if (isNormalBookingProduct(cacheItem)) return false;
|
|
38
40
|
if (isSelfServicePlatform(ctx === null || ctx === void 0 ? void 0 : ctx.channel)) return true;
|
|
39
41
|
var isAutoAllocationOn = (ctx === null || ctx === void 0 ? void 0 : ctx.isAutoAllocationOn) || function () {
|
|
@@ -54,13 +56,22 @@ function buildRequiresBookingEditPayload(cacheItem, ctx) {
|
|
|
54
56
|
*/
|
|
55
57
|
export function decideAddProduct(item, ctx) {
|
|
56
58
|
var derivedCtx = withDerivedBookingCtx(ctx);
|
|
57
|
-
|
|
59
|
+
var calendarRange = getCalendarBookingRange(item, derivedCtx);
|
|
60
|
+
var uniqueValue = calendarRange ? resolveUniqueCartDetailValue(item) : null;
|
|
61
|
+
var selectedItem = uniqueValue ? _objectSpread(_objectSpread({}, item), {}, {
|
|
62
|
+
cartDetailValue: uniqueValue,
|
|
63
|
+
isOpenDetailModal: false
|
|
64
|
+
}) : item;
|
|
65
|
+
if (needsSpecDetailModal(selectedItem)) {
|
|
66
|
+
var preparedCacheItem = calendarRange ? prepareBookingCacheItem(buildCacheItemFromCartDetail(item, derivedCtx), derivedCtx) : undefined;
|
|
58
67
|
return {
|
|
59
68
|
action: 'requiresDetail',
|
|
60
|
-
payload: buildRequiresDetailPayload(item, derivedCtx)
|
|
69
|
+
payload: _objectSpread(_objectSpread({}, buildRequiresDetailPayload(item, derivedCtx)), preparedCacheItem ? {
|
|
70
|
+
preparedCacheItem: preparedCacheItem
|
|
71
|
+
} : {})
|
|
61
72
|
};
|
|
62
73
|
}
|
|
63
|
-
var cacheItem = prepareBookingCacheItem(buildCacheItemFromCartDetail(
|
|
74
|
+
var cacheItem = prepareBookingCacheItem(buildCacheItemFromCartDetail(selectedItem, derivedCtx), derivedCtx);
|
|
64
75
|
if (needsBookingEdit(cacheItem, derivedCtx)) {
|
|
65
76
|
return {
|
|
66
77
|
action: 'requiresBookingEdit',
|
|
@@ -142,7 +153,23 @@ function isMultiDayLike(cacheItem) {
|
|
|
142
153
|
* `_extend.resource / capacity / startDate / endDate` 等后续 booking mapper 需要的字段。
|
|
143
154
|
*/
|
|
144
155
|
export function prepareBookingCacheItem(cacheItem, ctx) {
|
|
145
|
-
|
|
156
|
+
var _ctx, _cacheItem$duration2, _cacheItem$_extend, _ctx2;
|
|
157
|
+
if (getCalendarBookingRange(cacheItem, ctx)) {
|
|
158
|
+
var _cacheItem$_data;
|
|
159
|
+
if (((_cacheItem$_data = cacheItem._data) === null || _cacheItem$_data === void 0 ? void 0 : _cacheItem$_data.calendarBookingPreparationKey) === calendarBookingPreparationKey(cacheItem, ctx)) return cacheItem;
|
|
160
|
+
return getProductExtend({
|
|
161
|
+
cacheItem: cacheItem,
|
|
162
|
+
ctx: ctx,
|
|
163
|
+
isDisabledTime: true
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
if ((_ctx = ctx) !== null && _ctx !== void 0 && _ctx.bookingTimeRangeFromCalendar && (((_cacheItem$duration2 = cacheItem.duration) === null || _cacheItem$duration2 === void 0 ? void 0 : _cacheItem$duration2.type) === 'days' || cacheItem.duration_type === 'days' || ((_cacheItem$_extend = cacheItem._extend) === null || _cacheItem$_extend === void 0 ? void 0 : _cacheItem$_extend.sub_type) === 'days')) {
|
|
167
|
+
ctx = _objectSpread(_objectSpread({}, ctx), {}, {
|
|
168
|
+
bookingTimeRangeFromCalendar: undefined,
|
|
169
|
+
resourceIdFromCalendar: undefined
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
if (((_ctx2 = ctx) === null || _ctx2 === void 0 ? void 0 : _ctx2.rememberedTime) === undefined && (isNormalBookingProduct(cacheItem) || hasPreparedBookingExtend(cacheItem))) {
|
|
146
173
|
return cacheItem;
|
|
147
174
|
}
|
|
148
175
|
return getProductExtend({
|
|
@@ -320,9 +347,9 @@ export function transformDetailToProductAndBooking(cacheItem, ctx) {
|
|
|
320
347
|
* 把 cacheItem._extend.other 中的字段 + 顶层运行态拼成 `BaseProductDetailPayload`。
|
|
321
348
|
*/
|
|
322
349
|
function buildBasePayloadFromCacheItem(cacheItem, ctx) {
|
|
323
|
-
var _cacheItem$
|
|
324
|
-
var other = (cacheItem === null || cacheItem === void 0 || (_cacheItem$
|
|
325
|
-
var quantity = (ctx === null || ctx === void 0 ? void 0 : ctx.quantity) != null && ctx.quantity > 0 ? ctx.quantity : (_cacheItem$_extend$qu = cacheItem === null || cacheItem === void 0 || (_cacheItem$
|
|
350
|
+
var _cacheItem$_extend2, _cacheItem$_extend$qu, _cacheItem$_extend3, _cacheItem$product_id, _cacheItem$id, _ref5, _other$product_varian, _other$production_cod, _extend$skuValue, _extend$_skuValue, _extend$price, _extend$price2, _cacheItem$metadata$s, _cacheItem$metadata, _extend$metadata;
|
|
351
|
+
var other = (cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend2 = cacheItem._extend) === null || _cacheItem$_extend2 === void 0 ? void 0 : _cacheItem$_extend2.other) || {};
|
|
352
|
+
var quantity = (ctx === null || ctx === void 0 ? void 0 : ctx.quantity) != null && ctx.quantity > 0 ? ctx.quantity : (_cacheItem$_extend$qu = cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend3 = cacheItem._extend) === null || _cacheItem$_extend3 === void 0 ? void 0 : _cacheItem$_extend3.quantity) !== null && _cacheItem$_extend$qu !== void 0 ? _cacheItem$_extend$qu : 1;
|
|
326
353
|
var resolvedPid = (_cacheItem$product_id = cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.product_id) !== null && _cacheItem$product_id !== void 0 ? _cacheItem$product_id : cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.id;
|
|
327
354
|
var extend = (cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem._extend) || {};
|
|
328
355
|
var productSku = buildProductSkuFromCacheItem(cacheItem);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type RecordValue = Record<string, any>;
|
|
2
|
+
/**
|
|
3
|
+
* Resolve a whole SKU only when the original configuration proves one legal
|
|
4
|
+
* result. A default, a stock-filtered remainder, or missing detail is not proof
|
|
5
|
+
* of uniqueness. The input product and its existing selections stay untouched.
|
|
6
|
+
*/
|
|
7
|
+
export declare function resolveUniqueCartDetailValue(product: RecordValue): RecordValue | null;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
3
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
4
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
8
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
9
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
10
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
11
|
+
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); }
|
|
12
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
13
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
14
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
15
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
16
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
17
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
18
|
+
var flag = function flag(value) {
|
|
19
|
+
return value === true || value === 1 || value === '1';
|
|
20
|
+
};
|
|
21
|
+
var cleared = function cleared(value) {
|
|
22
|
+
return value === false || value === 0 || value === '0';
|
|
23
|
+
};
|
|
24
|
+
var enabled = function enabled(item) {
|
|
25
|
+
return item && !flag(item.disabled) && !cleared(item.is_enabled) && item.deleted_at == null;
|
|
26
|
+
};
|
|
27
|
+
var sellable = function sellable(item) {
|
|
28
|
+
return enabled(item) && (!flag(item.is_track) || flag(item.over_sold) || Number(item.stock_quantity) > 0);
|
|
29
|
+
};
|
|
30
|
+
var bound = function bound(value) {
|
|
31
|
+
var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
32
|
+
if (value == null || value === '') return fallback;
|
|
33
|
+
if (typeof value !== 'number' && typeof value !== 'string') return null;
|
|
34
|
+
var number = Number(value);
|
|
35
|
+
return Number.isInteger(number) && number >= 0 ? number : null;
|
|
36
|
+
};
|
|
37
|
+
var validId = function validId(value) {
|
|
38
|
+
return (typeof value === 'number' || typeof value === 'string') && Number.isSafeInteger(Number(value)) && Number(value) > 0;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/** A choice is unique only if its complete allowed quantity interval is one value. */
|
|
42
|
+
function fixedQuantity(minimums, maximums) {
|
|
43
|
+
var min = Math.max.apply(Math, [1].concat(_toConsumableArray(minimums)));
|
|
44
|
+
var max = Math.min.apply(Math, _toConsumableArray(maximums.filter(function (value) {
|
|
45
|
+
return value > 0;
|
|
46
|
+
})).concat([Infinity]));
|
|
47
|
+
return min === max ? min : null;
|
|
48
|
+
}
|
|
49
|
+
function configuredGroups(product, key, countKey) {
|
|
50
|
+
var groups = product[key];
|
|
51
|
+
if (groups == null && product[countKey] == null) return null;
|
|
52
|
+
var count = bound(product[countKey]);
|
|
53
|
+
if (count == null || groups != null && !Array.isArray(groups)) return null;
|
|
54
|
+
if (count > 0 && (!Array.isArray(groups) || groups.length !== count)) return null;
|
|
55
|
+
return groups || [];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Resolve a whole SKU only when the original configuration proves one legal
|
|
60
|
+
* result. A default, a stock-filtered remainder, or missing detail is not proof
|
|
61
|
+
* of uniqueness. The input product and its existing selections stay untouched.
|
|
62
|
+
*/
|
|
63
|
+
export function resolveUniqueCartDetailValue(product) {
|
|
64
|
+
var _product$id, _product$id2, _product$option_group, _product$bundle_group, _product$bundle_group2, _product$variant_grou, _existing$option, _existing$bundle, _ref2, _value$session$key;
|
|
65
|
+
if (!product || !validId((_product$id = product.id) !== null && _product$id !== void 0 ? _product$id : product.product_id) || flag(product.open_sold_weight)) return null;
|
|
66
|
+
var productId = (_product$id2 = product.id) !== null && _product$id2 !== void 0 ? _product$id2 : product.product_id;
|
|
67
|
+
var existing = product.cartDetailValue;
|
|
68
|
+
var hasConfiguredSku = flag(product.is_variant) || Number(product.variant_count) > 0 || Number(product.option_group_count) > 0 || Number(product.bundle_group_count) > 0 || ((_product$option_group = product.option_group) === null || _product$option_group === void 0 ? void 0 : _product$option_group.length) > 0 || ((_product$bundle_group = product.bundle_group) === null || _product$bundle_group === void 0 ? void 0 : _product$bundle_group.length) > 0 || ((_product$bundle_group2 = product.bundle_groups) === null || _product$bundle_group2 === void 0 ? void 0 : _product$bundle_group2.length) > 0 || ((_product$variant_grou = product.variant_group) === null || _product$variant_grou === void 0 ? void 0 : _product$variant_grou.length) > 0;
|
|
69
|
+
if (existing && !hasConfiguredSku && !((_existing$option = existing.option) !== null && _existing$option !== void 0 && _existing$option.length || (_existing$bundle = existing.bundle) !== null && _existing$bundle !== void 0 && _existing$bundle.length)) {
|
|
70
|
+
return _objectSpread(_objectSpread({}, existing), {}, {
|
|
71
|
+
product_id: productId,
|
|
72
|
+
quantity: 1
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
var knowsVariantShape = cleared(product.is_variant) || product.variant_count === 0 || product.variant_count === '0' || Array.isArray(product.variant) || Array.isArray(product.variant_group);
|
|
76
|
+
if (!knowsVariantShape) return null;
|
|
77
|
+
var optionGroups = configuredGroups(product, 'option_group', 'option_group_count');
|
|
78
|
+
var bundleKey = product.bundle_group != null ? 'bundle_group' : 'bundle_groups';
|
|
79
|
+
var bundleGroups = configuredGroups(product, bundleKey, 'bundle_group_count');
|
|
80
|
+
if (!optionGroups || !bundleGroups) return null;
|
|
81
|
+
var value = _objectSpread(_objectSpread({}, product.cartDetailValue || {}), {}, {
|
|
82
|
+
product_id: productId,
|
|
83
|
+
product_variant_id: 0,
|
|
84
|
+
option: [],
|
|
85
|
+
bundle: [],
|
|
86
|
+
quantity: 1
|
|
87
|
+
});
|
|
88
|
+
var hasVariant = flag(product.is_variant) || Number(product.variant_count) > 0 || Array.isArray(product.variant_group) && product.variant_group.length > 0 || Array.isArray(product.variant) && product.variant.length > 0;
|
|
89
|
+
if (hasVariant) {
|
|
90
|
+
var _ref, _variant$production_c;
|
|
91
|
+
if (!Array.isArray(product.variant) || product.variant.length !== 1 || Number(product.variant_count) > 0 && Number(product.variant_count) !== 1) return null;
|
|
92
|
+
var _product$variant = _slicedToArray(product.variant, 1),
|
|
93
|
+
variant = _product$variant[0];
|
|
94
|
+
if (!validId(variant === null || variant === void 0 ? void 0 : variant.id) || !sellable(variant)) return null;
|
|
95
|
+
value.product_variant_id = variant.id;
|
|
96
|
+
if (variant.price == null || variant.price === '' || !Number.isFinite(Number(variant.price)) || Number(variant.price) < 0) return null;
|
|
97
|
+
value.price = variant.price;
|
|
98
|
+
value.production_code = (_ref = (_variant$production_c = variant.production_code) !== null && _variant$production_c !== void 0 ? _variant$production_c : variant.code) !== null && _ref !== void 0 ? _ref : '';
|
|
99
|
+
}
|
|
100
|
+
var _iterator = _createForOfIteratorHelper(optionGroups),
|
|
101
|
+
_step;
|
|
102
|
+
try {
|
|
103
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
104
|
+
var _group$metadata, _group$metadata2, _group$metadata3, _ref3, _item$price;
|
|
105
|
+
var group = _step.value;
|
|
106
|
+
// Do not silently remove configured alternatives that are disabled or out of stock.
|
|
107
|
+
if (!validId(group === null || group === void 0 ? void 0 : group.id) || !enabled(group) || !Array.isArray(group.option_item) || group.option_item.length !== 1) return null;
|
|
108
|
+
var _group$option_item = _slicedToArray(group.option_item, 1),
|
|
109
|
+
item = _group$option_item[0];
|
|
110
|
+
if (!validId(item === null || item === void 0 ? void 0 : item.id) || !sellable(item)) return null;
|
|
111
|
+
var multiple = flag(group.is_multiple);
|
|
112
|
+
var groupMin = bound(group.min_quantity);
|
|
113
|
+
var groupMax = bound(group.max_quantity);
|
|
114
|
+
var itemMin = bound(item.min_quantity);
|
|
115
|
+
var itemMax = bound(item.max_quantity, 1);
|
|
116
|
+
if ([groupMin, groupMax, itemMin, itemMax].some(function (value) {
|
|
117
|
+
return value == null;
|
|
118
|
+
})) return null;
|
|
119
|
+
var advanced = multiple && flag((_group$metadata = group.metadata) === null || _group$metadata === void 0 ? void 0 : _group$metadata.advanced_settings_enabled);
|
|
120
|
+
var minTypes = advanced ? bound((_group$metadata2 = group.metadata) === null || _group$metadata2 === void 0 || (_group$metadata2 = _group$metadata2.option_types_config) === null || _group$metadata2 === void 0 ? void 0 : _group$metadata2.min) : 0;
|
|
121
|
+
var maxTypes = advanced ? bound((_group$metadata3 = group.metadata) === null || _group$metadata3 === void 0 || (_group$metadata3 = _group$metadata3.option_types_config) === null || _group$metadata3 === void 0 ? void 0 : _group$metadata3.max) : 0;
|
|
122
|
+
if (minTypes == null || maxTypes == null || minTypes > 1 || maxTypes > 0 && maxTypes < minTypes) return null;
|
|
123
|
+
var required = multiple ? groupMin > 0 || minTypes > 0 : flag(group.required);
|
|
124
|
+
if (!required) return null;
|
|
125
|
+
var quantity = fixedQuantity([itemMin].concat(_toConsumableArray(multiple ? [groupMin] : [])), [itemMax].concat(_toConsumableArray(multiple ? [groupMax] : [])));
|
|
126
|
+
if (!quantity) return null;
|
|
127
|
+
var price = (_ref3 = (_item$price = item.price) !== null && _item$price !== void 0 ? _item$price : item.add_price) !== null && _ref3 !== void 0 ? _ref3 : 0;
|
|
128
|
+
value.option.push(_objectSpread(_objectSpread({}, item), {}, {
|
|
129
|
+
id: item.id,
|
|
130
|
+
product_option_item_id: item.id,
|
|
131
|
+
option_group_item_id: item.id,
|
|
132
|
+
option_group_id: group.id,
|
|
133
|
+
product_id: productId,
|
|
134
|
+
quantity: quantity,
|
|
135
|
+
num: quantity,
|
|
136
|
+
price: price,
|
|
137
|
+
original_price: price
|
|
138
|
+
}));
|
|
139
|
+
}
|
|
140
|
+
} catch (err) {
|
|
141
|
+
_iterator.e(err);
|
|
142
|
+
} finally {
|
|
143
|
+
_iterator.f();
|
|
144
|
+
}
|
|
145
|
+
var _iterator2 = _createForOfIteratorHelper(bundleGroups),
|
|
146
|
+
_step2;
|
|
147
|
+
try {
|
|
148
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
149
|
+
var _item$option_group, _item$variant_group, _item$variant, _item$bundle_group, _item$bundle_groups;
|
|
150
|
+
var _group = _step2.value;
|
|
151
|
+
if (!validId(_group === null || _group === void 0 ? void 0 : _group.id) || !enabled(_group) || !Array.isArray(_group.bundle_item) || _group.bundle_item.length !== 1) return null;
|
|
152
|
+
var _group$bundle_item = _slicedToArray(_group.bundle_item, 1),
|
|
153
|
+
_item = _group$bundle_item[0];
|
|
154
|
+
if (!validId(_item === null || _item === void 0 ? void 0 : _item.id) || !validId(_item === null || _item === void 0 ? void 0 : _item.bundle_product_id) || !sellable(_item) || (_item$option_group = _item.option_group) !== null && _item$option_group !== void 0 && _item$option_group.length || (_item$variant_group = _item.variant_group) !== null && _item$variant_group !== void 0 && _item$variant_group.length || (_item$variant = _item.variant) !== null && _item$variant !== void 0 && _item$variant.length || (_item$bundle_group = _item.bundle_group) !== null && _item$bundle_group !== void 0 && _item$bundle_group.length || (_item$bundle_groups = _item.bundle_groups) !== null && _item$bundle_groups !== void 0 && _item$bundle_groups.length || flag(_item.is_variant) || flag(_item.open_sold_weight) || Number(_item.variant_count) > 0 || Number(_item.option_group_count) > 0 || Number(_item.bundle_group_count) > 0) return null;
|
|
155
|
+
var _groupMin = bound(_group.min_quantity);
|
|
156
|
+
var _groupMax = bound(_group.max_quantity);
|
|
157
|
+
var _itemMin = bound(_item.min_quantity);
|
|
158
|
+
var _itemMax = bound(_item.max_quantity);
|
|
159
|
+
if ([_groupMin, _groupMax, _itemMin, _itemMax].some(function (value) {
|
|
160
|
+
return value == null;
|
|
161
|
+
}) || _groupMin <= 0) return null;
|
|
162
|
+
var _quantity = fixedQuantity([_groupMin, _itemMin], [_groupMax, _itemMax]);
|
|
163
|
+
if (!_quantity) return null;
|
|
164
|
+
value.bundle.push(_objectSpread(_objectSpread({}, _item), {}, {
|
|
165
|
+
id: _item.id,
|
|
166
|
+
group_id: _group.id,
|
|
167
|
+
bundle_group_id: _group.id,
|
|
168
|
+
_bundle_product_id: _item.bundle_product_id,
|
|
169
|
+
quantity: _quantity,
|
|
170
|
+
num: _quantity,
|
|
171
|
+
option: []
|
|
172
|
+
}));
|
|
173
|
+
}
|
|
174
|
+
} catch (err) {
|
|
175
|
+
_iterator2.e(err);
|
|
176
|
+
} finally {
|
|
177
|
+
_iterator2.f();
|
|
178
|
+
}
|
|
179
|
+
var key = [productId, value.product_variant_id].concat(_toConsumableArray(value.option.map(function (item) {
|
|
180
|
+
return "o".concat(item.option_group_id, ":").concat(item.id, ":").concat(item.quantity);
|
|
181
|
+
})), _toConsumableArray(value.bundle.map(function (item) {
|
|
182
|
+
return "b".concat(item.group_id, ":").concat(item.id, ":").concat(item.quantity);
|
|
183
|
+
})), _toConsumableArray(value.session ? ["s".concat((_ref2 = (_value$session$key = value.session.key) !== null && _value$session$key !== void 0 ? _value$session$key : value.session.id) !== null && _ref2 !== void 0 ? _ref2 : '')] : [])).join('_');
|
|
184
|
+
return _objectSpread(_objectSpread({}, value), {}, {
|
|
185
|
+
key: key,
|
|
186
|
+
rowKey: key
|
|
187
|
+
});
|
|
188
|
+
}
|
|
@@ -187,8 +187,8 @@ export var OrderInvoicePreviewImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
187
187
|
error: null
|
|
188
188
|
});
|
|
189
189
|
var task = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
190
|
-
var
|
|
191
|
-
var _yield$Promise$all, _yield$Promise$all2, snapshot, context, template, source, getData, coreData, shop, languageOptions, remembered, selected, locale, result;
|
|
190
|
+
var _appPlugin$getData, _appPlugin$getApp, _hostApp$models, _hostApp$models$getSt, _hostApp$models$getSt2, _hostApp$models$getSt3, _hostApp$data, _hostApp$data$getStor, _hostApp$data$getStor2, _hostApp$data$getStor3, _coreData$core, _this3$languageSelect;
|
|
191
|
+
var _yield$Promise$all, _yield$Promise$all2, snapshot, context, template, source, appPlugin, getData, coreData, hostApp, shopCore, shop, languageOptions, remembered, selected, locale, result;
|
|
192
192
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
193
193
|
while (1) switch (_context.prev = _context.next) {
|
|
194
194
|
case 0:
|
|
@@ -201,23 +201,28 @@ export var OrderInvoicePreviewImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
201
201
|
context = _yield$Promise$all2[1];
|
|
202
202
|
template = _yield$Promise$all2[2];
|
|
203
203
|
source = withPaymentMethodNames(snapshot, context.methods);
|
|
204
|
-
|
|
204
|
+
appPlugin = _this3.core.getPlugin('app');
|
|
205
|
+
getData = appPlugin === null || appPlugin === void 0 || (_appPlugin$getData = appPlugin.getData) === null || _appPlugin$getData === void 0 ? void 0 : _appPlugin$getData.call(appPlugin);
|
|
205
206
|
if (!((getData === null || getData === void 0 ? void 0 : getData('shop_id')) != null && String(getData('shop_id')) !== String(input.shopId))) {
|
|
206
|
-
_context.next =
|
|
207
|
+
_context.next = 12;
|
|
207
208
|
break;
|
|
208
209
|
}
|
|
209
210
|
throw new Error('Invoice shop changed');
|
|
210
|
-
case
|
|
211
|
+
case 12:
|
|
211
212
|
coreData = getData === null || getData === void 0 ? void 0 : getData('core');
|
|
213
|
+
hostApp = appPlugin === null || appPlugin === void 0 || (_appPlugin$getApp = appPlugin.getApp) === null || _appPlugin$getApp === void 0 ? void 0 : _appPlugin$getApp.call(appPlugin);
|
|
214
|
+
shopCore = (hostApp === null || hostApp === void 0 || (_hostApp$models = hostApp.models) === null || _hostApp$models === void 0 || (_hostApp$models$getSt = _hostApp$models.getStore) === null || _hostApp$models$getSt === void 0 || (_hostApp$models$getSt2 = (_hostApp$models$getSt3 = _hostApp$models$getSt.call(_hostApp$models)).getDataByModel) === null || _hostApp$models$getSt2 === void 0 ? void 0 : _hostApp$models$getSt2.call(_hostApp$models$getSt3, 'core', 'core')) || (hostApp === null || hostApp === void 0 || (_hostApp$data = hostApp.data) === null || _hostApp$data === void 0 || (_hostApp$data = _hostApp$data.store) === null || _hostApp$data === void 0 || (_hostApp$data$getStor = _hostApp$data.getStore) === null || _hostApp$data$getStor === void 0 || (_hostApp$data$getStor2 = (_hostApp$data$getStor3 = _hostApp$data$getStor.call(_hostApp$data)).getDataByModel) === null || _hostApp$data$getStor2 === void 0 ? void 0 : _hostApp$data$getStor2.call(_hostApp$data$getStor3, 'core', 'core')) || (coreData === null || coreData === void 0 ? void 0 : coreData.core) || coreData || {};
|
|
212
215
|
shop = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, (coreData === null || coreData === void 0 || (_coreData$core = coreData.core) === null || _coreData$core === void 0 ? void 0 : _coreData$core.shop) || (coreData === null || coreData === void 0 ? void 0 : coreData.shop) || {}), (getData === null || getData === void 0 ? void 0 : getData('shop_info')) || {}), input.shop), context.shop), getData !== null && getData !== void 0 && getData('tax_country_code') ? {
|
|
213
216
|
tax_country_code: getData('tax_country_code')
|
|
214
217
|
} : {});
|
|
218
|
+
shop.default_domain || (shop.default_domain = shopCore.default_domain);
|
|
219
|
+
shop.private_domain_protocol || (shop.private_domain_protocol = shopCore.private_domain_protocol);
|
|
215
220
|
if (!(generation !== _this3.generation || _this3.disposed)) {
|
|
216
|
-
_context.next =
|
|
221
|
+
_context.next = 20;
|
|
217
222
|
break;
|
|
218
223
|
}
|
|
219
224
|
throw new Error('Invoice request superseded');
|
|
220
|
-
case
|
|
225
|
+
case 20:
|
|
221
226
|
languageOptions = resolveCustomerInvoiceLanguages(template.language, input.locale);
|
|
222
227
|
remembered = (_this3$languageSelect = _this3.languageSelection) === null || _this3$languageSelect === void 0 ? void 0 : _this3$languageSelect.code;
|
|
223
228
|
selected = languageOptions.find(function (option) {
|
|
@@ -254,7 +259,7 @@ export var OrderInvoicePreviewImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
254
259
|
error: null
|
|
255
260
|
});
|
|
256
261
|
return _context.abrupt("return", result);
|
|
257
|
-
case
|
|
262
|
+
case 27:
|
|
258
263
|
case "end":
|
|
259
264
|
return _context.stop();
|
|
260
265
|
}
|
|
@@ -5,8 +5,8 @@ import type { AddProductDecideContext } from '../BookingTicket/utils/addProductD
|
|
|
5
5
|
import { type InvoiceLayoutConfig, type InvoiceTemplateSettings, type OpenDataConfig, type ResolvedSalesSettings } from '../../modules/OpenData';
|
|
6
6
|
import type { LoadScheduleAvailableDateParams, ScheduleItem } from '../../modules/Schedule/types';
|
|
7
7
|
import type { ProductListLoadProductsParams, ProductListStoreQueryParams } from '../../modules/ProductList';
|
|
8
|
-
import type { AvailabilityDateRange, AvailabilityOccupancy, AvailabilityProduct, AvailabilityResource, GetProductTimeRangesRequest } from '../../modules/ResourcePlanner';
|
|
9
|
-
import type { AvailabilityContextRef, ContextualAvailabilityQuery, ContextualAvailabilityQueryResult, ContextualCommitAvailabilitySelectionParams, ContextualProductTimeRangeGroup, UnifiedBookingSalesAddRetailProductParams, UnifiedBookingSalesCatalogQueryBatch, UnifiedBookingSalesVenueCatalogSession, UnifiedBookingSalesVenueCatalogSessionParams, UnifiedBookingSalesApplyPlannerDiscountsParams, UnifiedBookingSalesCommitAvailabilitySelectionResult, UnifiedBookingSalesDiscountResult, UnifiedBookingSalesLoadProductsByScheduleDateParams, UnifiedBookingSalesLoadOpenDataParams, UnifiedBookingSalesPrepareAvailabilityProjectionParams, UnifiedBookingSalesPolicyResponse, UnifiedBookingSalesQueryBookingResourceDetailsParams, UnifiedBookingSalesResourceDetail, UnifiedBookingSalesResolveProductAllergyRequirementParams, UnifiedBookingSalesStageRetailProductsParams, UnifiedBookingSalesState } from './types';
|
|
8
|
+
import type { AvailabilityDateRange, AvailabilityOccupancy, AvailabilityProduct, AvailabilityRequirementSelection, AvailabilityResource, GetProductTimeRangesRequest } from '../../modules/ResourcePlanner';
|
|
9
|
+
import type { AvailabilityContextRef, ContextualAvailabilityQuery, ContextualAvailabilityQueryResult, ContextualCommitAvailabilitySelectionParams, ContextualProductTimeRange, ContextualProductTimeRangeGroup, UnifiedBookingSalesAddRetailProductParams, UnifiedBookingSalesCatalogQueryBatch, UnifiedBookingSalesVenueCatalogSession, UnifiedBookingSalesVenueCatalogSessionParams, UnifiedBookingSalesApplyPlannerDiscountsParams, UnifiedBookingSalesCommitAvailabilitySelectionResult, UnifiedBookingSalesDiscountResult, UnifiedBookingSalesLoadProductsByScheduleDateParams, UnifiedBookingSalesLoadOpenDataParams, UnifiedBookingSalesPrepareAvailabilityProjectionParams, UnifiedBookingSalesPolicyResponse, UnifiedBookingSalesQueryBookingResourceDetailsParams, UnifiedBookingSalesResourceDetail, UnifiedBookingSalesResolveProductAllergyRequirementParams, UnifiedBookingSalesStageRetailProductsParams, UnifiedBookingSalesState } from './types';
|
|
10
10
|
import type { BusinessAvailability } from '../../modules/BusinessAvailability';
|
|
11
11
|
import { BookingTicket } from '../BookingTicket';
|
|
12
12
|
import type { BaseSalesSubmitSalesOrderParams } from '../BaseSales/types';
|
|
@@ -122,6 +122,18 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
122
122
|
* 仅供直加调用;手动时间选择和 availability candidate 不经过此方法。
|
|
123
123
|
*/
|
|
124
124
|
prepareDirectAddFlexibleBooking(cacheItem: any): Promise<any>;
|
|
125
|
+
/** Reuse an approved calendar cache; only the final commit may mutate the order. */
|
|
126
|
+
prepareDirectAddCalendarBooking(cacheItem: any, options?: {
|
|
127
|
+
bookingCount?: number;
|
|
128
|
+
availabilityCommitGuard?: () => void;
|
|
129
|
+
}): Promise<{
|
|
130
|
+
cacheItem: any;
|
|
131
|
+
contextId: string;
|
|
132
|
+
candidate: ContextualProductTimeRange;
|
|
133
|
+
requirementSelections: AvailabilityRequirementSelection[];
|
|
134
|
+
partySize: number;
|
|
135
|
+
bookingCount: number;
|
|
136
|
+
} | null>;
|
|
125
137
|
private resolveAvailabilityPrepareDefaults;
|
|
126
138
|
private buildAvailabilityPrepareKey;
|
|
127
139
|
private clearAvailabilityRemoteResourceState;
|
|
@@ -309,6 +321,8 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
309
321
|
stageRetailProducts(params: UnifiedBookingSalesStageRetailProductsParams): Promise<Record<string, any> | null>;
|
|
310
322
|
/** Explicit capability: order-scoped Tickets extras use guarded writes without implicit SKU merging. */
|
|
311
323
|
supportsVenueTicketExtras(): boolean;
|
|
324
|
+
/** The venue retail write path accepts per-line Holder relations for both templates. */
|
|
325
|
+
supportsVenueExtraHolders(): boolean;
|
|
312
326
|
/**
|
|
313
327
|
* Adds one retail line without replacing the cart's existing retail selection.
|
|
314
328
|
* This is intentionally separate from stageRetailProducts(), whose contract is
|