@pisell/pisellos 0.10.90 → 0.10.91
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/itemRule/adapter.d.ts +3 -1
- package/dist/model/strategy/adapter/itemRule/adapter.js +74 -7
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
- package/dist/model/strategy/adapter/itemRule/evaluator.js +13 -0
- package/dist/model/strategy/adapter/itemRule/type.d.ts +40 -1
- package/dist/model/strategy/adapter/itemRule/type.js +10 -0
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +2 -1
- package/dist/model/strategy/adapter/promotion/evaluator.js +103 -112
- 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 +21 -0
- package/dist/modules/BookingContext/utils/productExtend.js +132 -33
- package/dist/modules/BookingContext/utils/resources.js +1 -1
- package/dist/modules/Cart/index.js +4 -3
- package/dist/modules/Cart/types.d.ts +2 -0
- package/dist/modules/Cart/utils/cartProduct.d.ts +3 -1
- package/dist/modules/Cart/utils/cartProduct.js +59 -32
- package/dist/modules/Date/index.d.ts +1 -1
- package/dist/modules/Date/index.js +60 -14
- package/dist/modules/Date/types.d.ts +5 -0
- package/dist/modules/OpenData/salesSettings.js +1 -1
- package/dist/modules/OpenData/types.d.ts +9 -0
- package/dist/modules/OpenData/utils.d.ts +1 -1
- package/dist/modules/OpenData/utils.js +3 -2
- package/dist/modules/Order/index.d.ts +22 -7
- package/dist/modules/Order/index.js +1565 -1161
- package/dist/modules/Order/localEftposState.d.ts +13 -0
- package/dist/modules/Order/localEftposState.js +39 -0
- package/dist/modules/Order/types.d.ts +33 -11
- package/dist/modules/Order/types.js +2 -2
- package/dist/modules/Order/unpaidAmountGap.d.ts +6 -0
- package/dist/modules/Order/unpaidAmountGap.js +72 -0
- package/dist/modules/Order/utils.d.ts +4 -1
- package/dist/modules/Order/utils.js +75 -52
- package/dist/modules/Payment/walletpass.js +32 -6
- package/dist/modules/Product/types.d.ts +16 -0
- package/dist/modules/ProductList/index.js +1 -1
- package/dist/modules/ResourcePlanner/planner.d.ts +2 -0
- package/dist/modules/ResourcePlanner/planner.js +383 -24
- package/dist/modules/ResourcePlanner/types.d.ts +42 -0
- package/dist/modules/Rules/index.js +86 -54
- package/dist/modules/Schedule/index.d.ts +7 -1
- package/dist/modules/Schedule/index.js +155 -39
- package/dist/modules/Schedule/types.d.ts +2 -0
- package/dist/modules/bookingReadValidation.d.ts +6 -0
- package/dist/modules/bookingReadValidation.js +72 -0
- package/dist/plugins/request.d.ts +2 -0
- package/dist/server/index.d.ts +9 -0
- package/dist/server/index.js +1928 -1462
- package/dist/server/modules/form/index.d.ts +19 -0
- package/dist/server/modules/form/index.js +205 -0
- package/dist/server/modules/form/types.d.ts +13 -0
- package/dist/server/modules/form/types.js +3 -0
- package/dist/server/modules/index.d.ts +3 -0
- package/dist/server/modules/index.js +4 -0
- package/dist/server/modules/order/index.d.ts +21 -0
- package/dist/server/modules/order/index.js +1399 -831
- package/dist/server/modules/order/types.d.ts +3 -0
- package/dist/server/modules/order/utils/filterOrders.js +20 -0
- package/dist/server/modules/products/index.d.ts +28 -7
- package/dist/server/modules/products/index.js +1295 -769
- package/dist/server/modules/products/replication.d.ts +8 -0
- package/dist/server/modules/products/replication.js +69 -0
- package/dist/server/modules/products/types.d.ts +12 -1
- package/dist/server/modules/products/types.js +4 -0
- package/dist/shared/receipt/customerInvoiceLanguages.d.ts +1 -1
- package/dist/shared/receipt/customerInvoiceLanguages.js +5 -3
- package/dist/shared/receipt/small-ticket.d.ts +1 -0
- package/dist/shared/receipt/small-ticket.js +58 -26
- package/dist/shared/receipt/templateVisibility.d.ts +3 -0
- package/dist/shared/receipt/templateVisibility.js +6 -2
- package/dist/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
- package/dist/solution/BaseSales/fulfillmentItemRules.js +750 -0
- package/dist/solution/BaseSales/index.d.ts +22 -6
- package/dist/solution/BaseSales/index.js +1881 -1347
- package/dist/solution/BaseSales/pickupTiming.d.ts +4 -0
- package/dist/solution/BaseSales/pickupTiming.js +35 -8
- package/dist/solution/BaseSales/types.d.ts +4 -0
- package/dist/solution/BaseSales/types.js +1 -0
- package/dist/solution/BaseSales/utils/posDurationPricing.d.ts +21 -0
- package/dist/solution/BaseSales/utils/posDurationPricing.js +174 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +2 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +8 -8
- package/dist/solution/BookingByStep/index.d.ts +18 -2
- package/dist/solution/BookingByStep/index.js +681 -361
- package/dist/solution/BookingByStep/utils/resources.d.ts +10 -0
- package/dist/solution/BookingByStep/utils/resources.js +117 -76
- package/dist/solution/BookingTicket/index.d.ts +6 -0
- package/dist/solution/BookingTicket/index.js +666 -593
- package/dist/solution/BookingTicket/types.d.ts +1 -1
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
- package/dist/solution/BookingTicket/utils/addProductDecision.js +35 -8
- package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +3 -3
- package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
- package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.js +188 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +58 -94
- package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +1 -3
- package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +33 -62
- package/dist/solution/OrderInvoicePreview/index.js +4 -3
- package/dist/solution/Sales/index.js +1 -1
- package/dist/solution/ScanOrder/index.d.ts +2 -0
- package/dist/solution/ScanOrder/index.js +230 -97
- package/dist/solution/ScanOrder/menuAvailability.d.ts +24 -0
- package/dist/solution/ScanOrder/menuAvailability.js +363 -0
- package/dist/solution/ScanOrder/types.d.ts +3 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +42 -10
- package/dist/solution/UnifiedBookingSales/index.js +2493 -1496
- package/dist/solution/UnifiedBookingSales/salesSettings.js +1 -1
- package/dist/solution/UnifiedBookingSales/types.d.ts +20 -5
- package/dist/utils/pos-receipt-auto-print.d.ts +4 -0
- package/dist/utils/pos-receipt-auto-print.js +14 -0
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
- package/lib/model/strategy/adapter/itemRule/adapter.js +54 -4
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
- package/lib/model/strategy/adapter/itemRule/evaluator.js +9 -0
- package/lib/model/strategy/adapter/itemRule/type.d.ts +40 -1
- package/lib/model/strategy/adapter/itemRule/type.js +10 -0
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +2 -1
- package/lib/model/strategy/adapter/promotion/evaluator.js +22 -21
- 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 +21 -0
- package/lib/modules/BookingContext/utils/productExtend.js +104 -5
- package/lib/modules/BookingContext/utils/resources.js +1 -1
- package/lib/modules/Cart/index.js +4 -2
- package/lib/modules/Cart/types.d.ts +2 -0
- package/lib/modules/Cart/utils/cartProduct.d.ts +3 -1
- package/lib/modules/Cart/utils/cartProduct.js +39 -20
- package/lib/modules/Date/index.d.ts +1 -1
- package/lib/modules/Date/index.js +28 -5
- package/lib/modules/Date/types.d.ts +5 -0
- package/lib/modules/OpenData/salesSettings.js +1 -1
- package/lib/modules/OpenData/types.d.ts +9 -0
- package/lib/modules/OpenData/utils.d.ts +1 -1
- package/lib/modules/OpenData/utils.js +3 -2
- package/lib/modules/Order/index.d.ts +22 -7
- package/lib/modules/Order/index.js +457 -174
- package/lib/modules/Order/localEftposState.d.ts +13 -0
- package/lib/modules/Order/localEftposState.js +44 -0
- package/lib/modules/Order/types.d.ts +33 -11
- package/lib/modules/Order/types.js +2 -2
- package/lib/modules/Order/unpaidAmountGap.d.ts +6 -0
- package/lib/modules/Order/unpaidAmountGap.js +60 -0
- package/lib/modules/Order/utils.d.ts +4 -1
- package/lib/modules/Order/utils.js +29 -3
- package/lib/modules/Payment/walletpass.js +23 -1
- package/lib/modules/Product/types.d.ts +16 -0
- package/lib/modules/ProductList/index.js +1 -1
- package/lib/modules/ResourcePlanner/planner.d.ts +2 -0
- package/lib/modules/ResourcePlanner/planner.js +299 -9
- package/lib/modules/ResourcePlanner/types.d.ts +42 -0
- package/lib/modules/Rules/index.js +32 -3
- package/lib/modules/Schedule/index.d.ts +7 -1
- package/lib/modules/Schedule/index.js +68 -4
- package/lib/modules/Schedule/types.d.ts +2 -0
- package/lib/modules/bookingReadValidation.d.ts +6 -0
- package/lib/modules/bookingReadValidation.js +56 -0
- package/lib/plugins/request.d.ts +2 -0
- package/lib/server/index.d.ts +9 -0
- package/lib/server/index.js +279 -30
- package/lib/server/modules/form/index.d.ts +19 -0
- package/lib/server/modules/form/index.js +73 -0
- package/lib/server/modules/form/types.d.ts +13 -0
- package/lib/server/modules/form/types.js +9 -0
- package/lib/server/modules/index.d.ts +3 -0
- package/lib/server/modules/index.js +15 -1
- package/lib/server/modules/order/index.d.ts +21 -0
- package/lib/server/modules/order/index.js +344 -35
- package/lib/server/modules/order/types.d.ts +3 -0
- package/lib/server/modules/order/utils/filterOrders.js +18 -0
- package/lib/server/modules/products/index.d.ts +28 -7
- package/lib/server/modules/products/index.js +224 -62
- package/lib/server/modules/products/replication.d.ts +8 -0
- package/lib/server/modules/products/replication.js +30 -0
- package/lib/server/modules/products/types.d.ts +12 -1
- package/lib/server/modules/products/types.js +3 -0
- package/lib/shared/receipt/customerInvoiceLanguages.d.ts +1 -1
- package/lib/shared/receipt/customerInvoiceLanguages.js +5 -3
- package/lib/shared/receipt/small-ticket.d.ts +1 -0
- package/lib/shared/receipt/small-ticket.js +53 -25
- package/lib/shared/receipt/templateVisibility.d.ts +3 -0
- package/lib/shared/receipt/templateVisibility.js +6 -2
- package/lib/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
- package/lib/solution/BaseSales/fulfillmentItemRules.js +259 -0
- package/lib/solution/BaseSales/index.d.ts +22 -6
- package/lib/solution/BaseSales/index.js +347 -59
- package/lib/solution/BaseSales/pickupTiming.d.ts +4 -0
- package/lib/solution/BaseSales/pickupTiming.js +24 -3
- package/lib/solution/BaseSales/types.d.ts +4 -0
- package/lib/solution/BaseSales/types.js +1 -0
- package/lib/solution/BaseSales/utils/posDurationPricing.d.ts +21 -0
- package/lib/solution/BaseSales/utils/posDurationPricing.js +133 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +2 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -1
- package/lib/solution/BookingByStep/index.d.ts +18 -2
- package/lib/solution/BookingByStep/index.js +229 -17
- package/lib/solution/BookingByStep/utils/resources.d.ts +10 -0
- package/lib/solution/BookingByStep/utils/resources.js +25 -15
- package/lib/solution/BookingTicket/index.d.ts +6 -0
- package/lib/solution/BookingTicket/index.js +40 -5
- package/lib/solution/BookingTicket/types.d.ts +1 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.js +34 -4
- package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +3 -3
- package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
- package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.js +136 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +2 -14
- package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +1 -3
- package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +17 -34
- package/lib/solution/OrderInvoicePreview/index.js +1 -0
- package/lib/solution/Sales/index.js +1 -1
- package/lib/solution/ScanOrder/index.d.ts +2 -0
- package/lib/solution/ScanOrder/index.js +131 -22
- package/lib/solution/ScanOrder/menuAvailability.d.ts +24 -0
- package/lib/solution/ScanOrder/menuAvailability.js +203 -0
- package/lib/solution/ScanOrder/types.d.ts +3 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +42 -10
- package/lib/solution/UnifiedBookingSales/index.js +717 -144
- package/lib/solution/UnifiedBookingSales/salesSettings.js +1 -1
- package/lib/solution/UnifiedBookingSales/types.d.ts +20 -5
- package/lib/utils/pos-receipt-auto-print.d.ts +4 -0
- package/lib/utils/pos-receipt-auto-print.js +13 -0
- package/package.json +1 -1
|
@@ -208,7 +208,7 @@ export interface AddAddTimeProductsToBookingInput {
|
|
|
208
208
|
}
|
|
209
209
|
/** 扫码宿主桥接:SalesSdk 在 pubsub 订阅回调里注入,OS 需要 UI 时直接调用 */
|
|
210
210
|
export interface GlobalScanHostBridge {
|
|
211
|
-
/** product-voucher handles voucher codes
|
|
211
|
+
/** product-voucher handles voucher codes; product-voucher-collection loads all vouchers for the scanned customer. */
|
|
212
212
|
scanScope?: 'all' | 'product-voucher' | 'product-voucher-collection';
|
|
213
213
|
/** A one-shot entry may outlive its page while requests are in flight. */
|
|
214
214
|
isCurrent?: () => boolean;
|
|
@@ -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: {
|
|
@@ -65,7 +67,6 @@ export interface AddProductDecideContext extends BookingCalcContext {
|
|
|
65
67
|
type?: 'select' | 'detail';
|
|
66
68
|
quantity?: number;
|
|
67
69
|
customerId?: number | string;
|
|
68
|
-
channel?: string;
|
|
69
70
|
}
|
|
70
71
|
/**
|
|
71
72
|
* 统一补齐预约商品的运行态字段。
|
|
@@ -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);
|
|
@@ -30,6 +30,9 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
|
|
|
30
30
|
holder: Record<string, any> | null;
|
|
31
31
|
relation_forms: any[];
|
|
32
32
|
holder_relations?: import("../../../modules/Order/types").OrderHolderRelation[] | undefined;
|
|
33
|
+
phone: string;
|
|
34
|
+
email: string;
|
|
35
|
+
contacts_info: Record<string, any> | null;
|
|
33
36
|
order_id: number | null;
|
|
34
37
|
external_sale_number: string;
|
|
35
38
|
order_number: string | null;
|
|
@@ -43,8 +46,6 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
|
|
|
43
46
|
customer_id: number | null;
|
|
44
47
|
customer_name: string;
|
|
45
48
|
country_calling_code: string;
|
|
46
|
-
phone: string;
|
|
47
|
-
email: string;
|
|
48
49
|
is_price_include_tax: number;
|
|
49
50
|
tax_title: string;
|
|
50
51
|
tax_country_code: string;
|
|
@@ -61,7 +62,6 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
|
|
|
61
62
|
schedule_date: string;
|
|
62
63
|
bookings: any[];
|
|
63
64
|
payments: any[];
|
|
64
|
-
contacts_info: Record<string, any> | null;
|
|
65
65
|
order_meta_list?: import("../../../modules/Order/types").OrderMetaList | undefined;
|
|
66
66
|
refunds?: any[] | undefined;
|
|
67
67
|
surcharges: any[];
|
|
@@ -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
|
+
}
|
|
@@ -210,7 +210,7 @@ export function applyGlobalScan(_x14, _x15, _x16) {
|
|
|
210
210
|
}
|
|
211
211
|
function _applyGlobalScan() {
|
|
212
212
|
_applyGlobalScan = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(host, formatted, bridge) {
|
|
213
|
-
var searchType, data, scanCode, formattedCustomerId, isCrossShopWallet, isWalletPassUnavailableAtStore, _getRealCustomerId, _bridge$onNotify5, currentCustomer, currentCustomerId, _customer, sourceCustomerId, _bridge$onNotify, _bridge$onNotify2, _customerId, _bridge$onNotify3, orderCustomer, switched, _bridge$onNotify4,
|
|
213
|
+
var searchType, data, scanCode, formattedCustomerId, isCrossShopWallet, isWalletPassUnavailableAtStore, _getRealCustomerId, _bridge$onNotify5, currentCustomer, currentCustomerId, _customer, sourceCustomerId, _bridge$onNotify, _bridge$onNotify2, _customerId, _bridge$onNotify3, orderCustomer, switched, _bridge$onNotify4, _promotionResult$isAc, _bridge$onNotify6, snapshot, activeCustomer, bindWalletPassCustomer, trySelectWalletAsset, bindResult, walletSelection, promotionCustomerId, promotionResult, list, _bridge$onNotify12, addedCount, _iterator, _step, _item, outcome, _bridge$onNotify13, _data$order_id, _data$business_code, orderId, _bridge$onNotify14;
|
|
214
214
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
215
215
|
while (1) switch (_context6.prev = _context6.next) {
|
|
216
216
|
case 0:
|
|
@@ -321,7 +321,7 @@ function _applyGlobalScan() {
|
|
|
321
321
|
});
|
|
322
322
|
case 44:
|
|
323
323
|
if (!(searchType === 'walletPass')) {
|
|
324
|
-
_context6.next =
|
|
324
|
+
_context6.next = 78;
|
|
325
325
|
break;
|
|
326
326
|
}
|
|
327
327
|
if (!isWalletPassUnavailableAtStore) {
|
|
@@ -495,111 +495,75 @@ function _applyGlobalScan() {
|
|
|
495
495
|
return bindWalletPassCustomer();
|
|
496
496
|
case 54:
|
|
497
497
|
bindResult = _context6.sent;
|
|
498
|
-
|
|
499
|
-
_context6.next = 61;
|
|
500
|
-
break;
|
|
501
|
-
}
|
|
502
|
-
_context6.next = 58;
|
|
503
|
-
return bridge.applyPromotionCode(scanCode, getRealCustomerId(activeCustomer), {
|
|
504
|
-
suppressFailureNotification: true,
|
|
505
|
-
productVouchersOnly: true
|
|
506
|
-
});
|
|
507
|
-
case 58:
|
|
508
|
-
_context6.t2 = _context6.sent;
|
|
509
|
-
_context6.next = 62;
|
|
510
|
-
break;
|
|
511
|
-
case 61:
|
|
512
|
-
_context6.t2 = undefined;
|
|
513
|
-
case 62:
|
|
514
|
-
collectionPromotion = _context6.t2;
|
|
515
|
-
if (!((_collectionPromotion$ = collectionPromotion === null || collectionPromotion === void 0 ? void 0 : collectionPromotion.isAccepted) !== null && _collectionPromotion$ !== void 0 ? _collectionPromotion$ : collectionPromotion === null || collectionPromotion === void 0 ? void 0 : collectionPromotion.isAvailable)) {
|
|
516
|
-
_context6.next = 65;
|
|
517
|
-
break;
|
|
518
|
-
}
|
|
519
|
-
return _context6.abrupt("return", {
|
|
520
|
-
status: 'success',
|
|
521
|
-
kind: 'promotion'
|
|
522
|
-
});
|
|
523
|
-
case 65:
|
|
524
|
-
_context6.next = 67;
|
|
498
|
+
_context6.next = 57;
|
|
525
499
|
return trySelectWalletAsset();
|
|
526
|
-
case
|
|
500
|
+
case 57:
|
|
527
501
|
walletSelection = _context6.sent;
|
|
528
502
|
if (!walletSelection) {
|
|
529
|
-
_context6.next =
|
|
503
|
+
_context6.next = 60;
|
|
530
504
|
break;
|
|
531
505
|
}
|
|
532
506
|
return _context6.abrupt("return", walletSelection);
|
|
533
|
-
case
|
|
507
|
+
case 60:
|
|
534
508
|
if (bridge !== null && bridge !== void 0 && bridge.applyPromotionCode) {
|
|
535
|
-
_context6.next =
|
|
509
|
+
_context6.next = 62;
|
|
536
510
|
break;
|
|
537
511
|
}
|
|
538
512
|
return _context6.abrupt("return", {
|
|
539
513
|
status: 'failed',
|
|
540
514
|
reason: 'no_bridge'
|
|
541
515
|
});
|
|
542
|
-
case
|
|
516
|
+
case 62:
|
|
543
517
|
promotionCustomerId = getRealCustomerId(activeCustomer);
|
|
544
|
-
if (!(collectionPromotion !== null && collectionPromotion !== void 0)) {
|
|
545
|
-
_context6.next = 77;
|
|
546
|
-
break;
|
|
547
|
-
}
|
|
548
|
-
_context6.t3 = collectionPromotion;
|
|
549
|
-
_context6.next = 87;
|
|
550
|
-
break;
|
|
551
|
-
case 77:
|
|
552
518
|
if (!bindResult.customerBound) {
|
|
553
|
-
_context6.next =
|
|
519
|
+
_context6.next = 69;
|
|
554
520
|
break;
|
|
555
521
|
}
|
|
556
|
-
_context6.next =
|
|
522
|
+
_context6.next = 66;
|
|
557
523
|
return bridge.applyPromotionCode(scanCode, promotionCustomerId, {
|
|
558
524
|
suppressFailureNotification: true
|
|
559
525
|
});
|
|
560
|
-
case
|
|
561
|
-
_context6.
|
|
562
|
-
_context6.next =
|
|
526
|
+
case 66:
|
|
527
|
+
_context6.t2 = _context6.sent;
|
|
528
|
+
_context6.next = 72;
|
|
563
529
|
break;
|
|
564
|
-
case
|
|
565
|
-
_context6.next =
|
|
530
|
+
case 69:
|
|
531
|
+
_context6.next = 71;
|
|
566
532
|
return bridge.applyPromotionCode(scanCode, promotionCustomerId);
|
|
567
|
-
case
|
|
568
|
-
_context6.
|
|
569
|
-
case
|
|
570
|
-
|
|
571
|
-
case 87:
|
|
572
|
-
promotionResult = _context6.t3;
|
|
533
|
+
case 71:
|
|
534
|
+
_context6.t2 = _context6.sent;
|
|
535
|
+
case 72:
|
|
536
|
+
promotionResult = _context6.t2;
|
|
573
537
|
if (!((_promotionResult$isAc = promotionResult === null || promotionResult === void 0 ? void 0 : promotionResult.isAccepted) !== null && _promotionResult$isAc !== void 0 ? _promotionResult$isAc : promotionResult === null || promotionResult === void 0 ? void 0 : promotionResult.isAvailable)) {
|
|
574
|
-
_context6.next =
|
|
538
|
+
_context6.next = 75;
|
|
575
539
|
break;
|
|
576
540
|
}
|
|
577
541
|
return _context6.abrupt("return", {
|
|
578
542
|
status: 'success',
|
|
579
543
|
kind: 'promotion'
|
|
580
544
|
});
|
|
581
|
-
case
|
|
545
|
+
case 75:
|
|
582
546
|
if (!bindResult.customerBound) {
|
|
583
|
-
_context6.next =
|
|
547
|
+
_context6.next = 77;
|
|
584
548
|
break;
|
|
585
549
|
}
|
|
586
550
|
return _context6.abrupt("return", {
|
|
587
551
|
status: 'success',
|
|
588
552
|
kind: 'customer'
|
|
589
553
|
});
|
|
590
|
-
case
|
|
554
|
+
case 77:
|
|
591
555
|
return _context6.abrupt("return", {
|
|
592
556
|
status: 'failed',
|
|
593
557
|
reason: 'invalid_data'
|
|
594
558
|
});
|
|
595
|
-
case
|
|
559
|
+
case 78:
|
|
596
560
|
if (!(searchType === 'product' || searchType === 'local_product')) {
|
|
597
|
-
_context6.next =
|
|
561
|
+
_context6.next = 111;
|
|
598
562
|
break;
|
|
599
563
|
}
|
|
600
564
|
list = data === null || data === void 0 ? void 0 : data.list;
|
|
601
565
|
if (!(!Array.isArray(list) || list.length === 0)) {
|
|
602
|
-
_context6.next =
|
|
566
|
+
_context6.next = 83;
|
|
603
567
|
break;
|
|
604
568
|
}
|
|
605
569
|
bridge === null || bridge === void 0 || (_bridge$onNotify12 = bridge.onNotify) === null || _bridge$onNotify12 === void 0 || _bridge$onNotify12.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
|
|
@@ -607,57 +571,57 @@ function _applyGlobalScan() {
|
|
|
607
571
|
status: 'failed',
|
|
608
572
|
reason: 'invalid_data'
|
|
609
573
|
});
|
|
610
|
-
case
|
|
574
|
+
case 83:
|
|
611
575
|
addedCount = 0;
|
|
612
576
|
_iterator = _createForOfIteratorHelper(list);
|
|
613
|
-
_context6.prev =
|
|
577
|
+
_context6.prev = 85;
|
|
614
578
|
_iterator.s();
|
|
615
|
-
case
|
|
579
|
+
case 87:
|
|
616
580
|
if ((_step = _iterator.n()).done) {
|
|
617
|
-
_context6.next =
|
|
581
|
+
_context6.next = 99;
|
|
618
582
|
break;
|
|
619
583
|
}
|
|
620
584
|
_item = _step.value;
|
|
621
|
-
_context6.next =
|
|
585
|
+
_context6.next = 91;
|
|
622
586
|
return processScannedProductItem(host, _item, scanCode, bridge);
|
|
623
|
-
case
|
|
587
|
+
case 91:
|
|
624
588
|
outcome = _context6.sent;
|
|
625
589
|
if (outcome === 'added') {
|
|
626
590
|
addedCount += 1;
|
|
627
591
|
}
|
|
628
592
|
if (!(outcome === 'cancelled')) {
|
|
629
|
-
_context6.next =
|
|
593
|
+
_context6.next = 95;
|
|
630
594
|
break;
|
|
631
595
|
}
|
|
632
596
|
return _context6.abrupt("return", {
|
|
633
597
|
status: 'cancelled'
|
|
634
598
|
});
|
|
635
|
-
case
|
|
599
|
+
case 95:
|
|
636
600
|
if (!(outcome === 'pending')) {
|
|
637
|
-
_context6.next =
|
|
601
|
+
_context6.next = 97;
|
|
638
602
|
break;
|
|
639
603
|
}
|
|
640
604
|
return _context6.abrupt("return", {
|
|
641
605
|
status: 'pending',
|
|
642
606
|
kind: 'requiresDetail'
|
|
643
607
|
});
|
|
644
|
-
case
|
|
645
|
-
_context6.next =
|
|
608
|
+
case 97:
|
|
609
|
+
_context6.next = 87;
|
|
646
610
|
break;
|
|
647
|
-
case
|
|
648
|
-
_context6.next =
|
|
611
|
+
case 99:
|
|
612
|
+
_context6.next = 104;
|
|
649
613
|
break;
|
|
650
|
-
case
|
|
651
|
-
_context6.prev =
|
|
652
|
-
_context6.
|
|
653
|
-
_iterator.e(_context6.
|
|
654
|
-
case
|
|
655
|
-
_context6.prev =
|
|
614
|
+
case 101:
|
|
615
|
+
_context6.prev = 101;
|
|
616
|
+
_context6.t3 = _context6["catch"](85);
|
|
617
|
+
_iterator.e(_context6.t3);
|
|
618
|
+
case 104:
|
|
619
|
+
_context6.prev = 104;
|
|
656
620
|
_iterator.f();
|
|
657
|
-
return _context6.finish(
|
|
658
|
-
case
|
|
621
|
+
return _context6.finish(104);
|
|
622
|
+
case 107:
|
|
659
623
|
if (!(addedCount > 0)) {
|
|
660
|
-
_context6.next =
|
|
624
|
+
_context6.next = 110;
|
|
661
625
|
break;
|
|
662
626
|
}
|
|
663
627
|
bridge === null || bridge === void 0 || (_bridge$onNotify13 = bridge.onNotify) === null || _bridge$onNotify13 === void 0 || _bridge$onNotify13.call(bridge, 'success');
|
|
@@ -668,19 +632,19 @@ function _applyGlobalScan() {
|
|
|
668
632
|
count: addedCount
|
|
669
633
|
}
|
|
670
634
|
});
|
|
671
|
-
case
|
|
635
|
+
case 110:
|
|
672
636
|
return _context6.abrupt("return", {
|
|
673
637
|
status: 'failed',
|
|
674
638
|
reason: 'no_bridge'
|
|
675
639
|
});
|
|
676
|
-
case
|
|
640
|
+
case 111:
|
|
677
641
|
if (!(searchType === 'order')) {
|
|
678
|
-
_context6.next =
|
|
642
|
+
_context6.next = 120;
|
|
679
643
|
break;
|
|
680
644
|
}
|
|
681
645
|
orderId = (_data$order_id = data === null || data === void 0 ? void 0 : data.order_id) !== null && _data$order_id !== void 0 ? _data$order_id : data === null || data === void 0 ? void 0 : data.id;
|
|
682
646
|
if (orderId) {
|
|
683
|
-
_context6.next =
|
|
647
|
+
_context6.next = 116;
|
|
684
648
|
break;
|
|
685
649
|
}
|
|
686
650
|
bridge === null || bridge === void 0 || (_bridge$onNotify14 = bridge.onNotify) === null || _bridge$onNotify14 === void 0 || _bridge$onNotify14.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
|
|
@@ -688,16 +652,16 @@ function _applyGlobalScan() {
|
|
|
688
652
|
status: 'failed',
|
|
689
653
|
reason: 'invalid_data'
|
|
690
654
|
});
|
|
691
|
-
case
|
|
655
|
+
case 116:
|
|
692
656
|
if (bridge !== null && bridge !== void 0 && bridge.openOrder) {
|
|
693
|
-
_context6.next =
|
|
657
|
+
_context6.next = 118;
|
|
694
658
|
break;
|
|
695
659
|
}
|
|
696
660
|
return _context6.abrupt("return", {
|
|
697
661
|
status: 'pending',
|
|
698
662
|
kind: 'openOrder'
|
|
699
663
|
});
|
|
700
|
-
case
|
|
664
|
+
case 118:
|
|
701
665
|
bridge.openOrder({
|
|
702
666
|
order_id: Number(orderId),
|
|
703
667
|
business_code: (_data$business_code = data === null || data === void 0 ? void 0 : data.business_code) !== null && _data$business_code !== void 0 ? _data$business_code : host.getBusinessCode()
|
|
@@ -706,16 +670,16 @@ function _applyGlobalScan() {
|
|
|
706
670
|
status: 'pending',
|
|
707
671
|
kind: 'openOrder'
|
|
708
672
|
});
|
|
709
|
-
case
|
|
673
|
+
case 120:
|
|
710
674
|
return _context6.abrupt("return", {
|
|
711
675
|
status: 'failed',
|
|
712
676
|
reason: 'invalid_data'
|
|
713
677
|
});
|
|
714
|
-
case
|
|
678
|
+
case 121:
|
|
715
679
|
case "end":
|
|
716
680
|
return _context6.stop();
|
|
717
681
|
}
|
|
718
|
-
}, _callee6, null, [[10, 16], [30, 37], [
|
|
682
|
+
}, _callee6, null, [[10, 16], [30, 37], [85, 101, 104, 107]]);
|
|
719
683
|
}));
|
|
720
684
|
return _applyGlobalScan.apply(this, arguments);
|
|
721
685
|
}
|