@pisell/private-materials 6.12.169 → 6.12.170
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +10 -10
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +10 -10
- package/es/components/HDLKiosk/components/common/HDLKioskSkuOptionsSelection/index.less +1 -1
- package/es/components/HDLKiosk/components/overlays/HDLKioskModal/index.less +1 -1
- package/es/components/HDLKiosk/components/shell/HDLKioskBottomBarHost/index.js +4 -1
- package/es/components/HDLKiosk/docs/02-Host/351/200/202/351/205/215/344/270/216/344/270/232/345/212/241/346/225/260/346/215/256.md +20 -19
- package/es/components/HDLKiosk/index.js +10 -2
- package/es/components/HDLKiosk/index.less +7 -2
- package/es/components/HDLKiosk/slices/identity/Screen/index.less +1 -1
- package/es/components/HDLKiosk/slices/payment/Screen/index.less +1 -1
- package/es/components/HDLKiosk/ui/HDLKioskWorkflowView.js +26 -1
- package/es/components/HDLKiosk/ui/collaborationStatus.js +11 -0
- package/es/components/bigSale/components/BookingFloatingPanel/useBookingPanelController.js +0 -1
- package/es/components/bigSale/components/TimeBar/index.js +0 -1
- package/es/components/bigSale/dialog.js +0 -1
- package/es/components/bigSale/hooks/useBigSaleContext.js +0 -1
- package/es/components/bigSale/hooks/useSelectFloorMapResourceForBigSale.js +0 -1
- package/es/components/bigSale/index.js +0 -1
- package/es/components/bigSale/templates/HDLKiosk/README.md +43 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/createHost.js +7 -7
- package/es/components/bigSale/templates/HDLKiosk/adapter/{devices.js → devices/devicePort.js} +10 -38
- package/es/components/bigSale/templates/HDLKiosk/adapter/{capabilities.js → host/capabilities.js} +1 -1
- package/es/components/bigSale/templates/HDLKiosk/adapter/{fulfillment.js → host/fulfillmentWriter.js} +3 -3
- package/es/components/bigSale/templates/HDLKiosk/adapter/{projection.js → host/projection.js} +3 -3
- package/es/components/bigSale/templates/HDLKiosk/adapter/{telemetry.js → host/telemetry.js} +1 -1
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales/cart.js +187 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales/catalog.js +160 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/{customizationProduct.js → sales/customizationProduct.js} +3 -3
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales/fulfillment.js +31 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales/identity.js +57 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales/index.js +18 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales/payment.js +123 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales/session.js +71 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales/weightedOperations.js +124 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/{weightedProduct.js → sales/weightedProduct.js} +2 -2
- package/es/components/bigSale/templates/HDLKiosk/adapter/useBigSaleHDLKioskAdapter.js +41 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/useBigSaleHDLKioskHost.js +7 -7
- package/es/components/bigSale/templates/HDLKiosk/cart/useBigSaleHDLKioskCart.js +122 -0
- package/es/components/bigSale/templates/HDLKiosk/{adapter → hooks}/useHDLKioskEntryPreparationToast.js +2 -1
- package/es/components/bigSale/templates/HDLKiosk/index.js +40 -146
- package/es/components/bigSale/templates/HDLKiosk/{adapter/scaleTrigger.js → runtime/BigSaleScaleRuntimeOwner.js} +15 -59
- package/es/components/bigSale/templates/HDLKiosk/{adapter → runtime}/HDLKioskPaymentRuntime.js +2 -2
- package/es/components/bigSale/templates/HDLKiosk/runtime/scaleBridge.js +44 -0
- package/es/components/bigSale/templates/Kiosk/index.js +0 -1
- package/es/components/sharedSecondaryBigSale/SharedSecondaryBigSaleReceiver.js +0 -1
- package/es/index.js +0 -2
- package/es/plus/pisellReservation/data/bookingToReservationTables.js +1 -1
- package/es/plus/pisellReservation/floorMap/floorPlanApi.js +1 -1
- package/es/plus/pisellReservation/floorMap/reservationMock.js +1 -1
- package/es/plus/saleDetail/Base.js +0 -1
- package/es/plus/saleDetail/components/Client/hooks/useClientSelectorProps.js +0 -1
- package/es/plus/saleDetail/components/DetailActions/index.js +0 -1
- package/es/plus/saleDetail/components/SummaryFinancialSections/index.js +0 -1
- package/es/plus/saleDetail/index.js +0 -1
- package/es/plus/saleDetail/tmpl/B/components/Dish/index.js +0 -1
- package/es/plus/saleDetail/tmpl/B/index.js +0 -1
- package/es/plus/salesSdk/utils/addProductWithFlowDebounced.js +1 -1
- package/es/plus/salesSdk/utils/bookingDate.js +1 -1
- package/es/plus/salesSdk/utils/customerAuthGate.js +1 -1
- package/es/plus/salesSdk/utils/enrichCartLineHolderDisplay.js +1 -1
- package/es/private-materials/lowcode/authmodal/meta.d.ts +1 -0
- package/es/pro/Login2.0/AuthModal.d.ts +1 -1
- package/es/pro/Login2.0/index.d.ts +1 -2
- package/es/pro/Login2.0/shared/types.d.ts +1 -1
- package/lib/components/HDLKiosk/components/common/HDLKioskSkuOptionsSelection/index.less +1 -1
- package/lib/components/HDLKiosk/components/overlays/HDLKioskModal/index.less +1 -1
- package/lib/components/HDLKiosk/components/shell/HDLKioskBottomBarHost/index.js +4 -1
- package/lib/components/HDLKiosk/docs/02-Host/351/200/202/351/205/215/344/270/216/344/270/232/345/212/241/346/225/260/346/215/256.md +20 -19
- package/lib/components/HDLKiosk/index.js +10 -2
- package/lib/components/HDLKiosk/index.less +7 -2
- package/lib/components/HDLKiosk/slices/identity/Screen/index.less +1 -1
- package/lib/components/HDLKiosk/slices/payment/Screen/index.less +1 -1
- package/lib/components/HDLKiosk/ui/HDLKioskWorkflowView.js +26 -1
- package/lib/components/HDLKiosk/ui/collaborationStatus.js +11 -0
- package/lib/components/bigSale/templates/HDLKiosk/README.md +43 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/createHost.js +9 -9
- package/lib/components/bigSale/templates/HDLKiosk/adapter/{devices.js → devices/devicePort.js} +10 -38
- package/lib/components/bigSale/templates/HDLKiosk/adapter/{capabilities.js → host/capabilities.js} +1 -1
- package/lib/components/bigSale/templates/HDLKiosk/adapter/{fulfillment.js → host/fulfillmentWriter.js} +3 -3
- package/lib/components/bigSale/templates/HDLKiosk/adapter/{projection.js → host/projection.js} +4 -4
- package/lib/components/bigSale/templates/HDLKiosk/adapter/{telemetry.js → host/telemetry.js} +1 -1
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales/cart.js +189 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales/catalog.js +162 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/{customizationProduct.js → sales/customizationProduct.js} +4 -4
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales/fulfillment.js +31 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales/identity.js +57 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales/index.js +18 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales/payment.js +123 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales/session.js +71 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales/weightedOperations.js +126 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/{weightedProduct.js → sales/weightedProduct.js} +3 -3
- package/lib/components/bigSale/templates/HDLKiosk/adapter/useBigSaleHDLKioskAdapter.js +42 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/useBigSaleHDLKioskHost.js +7 -7
- package/lib/components/bigSale/templates/HDLKiosk/cart/useBigSaleHDLKioskCart.js +124 -0
- package/lib/components/bigSale/templates/HDLKiosk/{adapter → hooks}/useHDLKioskEntryPreparationToast.js +2 -1
- package/lib/components/bigSale/templates/HDLKiosk/index.js +41 -147
- package/lib/components/bigSale/templates/HDLKiosk/{adapter/scaleTrigger.js → runtime/BigSaleScaleRuntimeOwner.js} +14 -59
- package/lib/components/bigSale/templates/HDLKiosk/{adapter → runtime}/HDLKioskPaymentRuntime.js +2 -2
- package/lib/components/bigSale/templates/HDLKiosk/runtime/scaleBridge.js +44 -0
- package/package.json +3 -3
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales.js +0 -710
- package/es/plus/pisellReservation/index.js +0 -17
- package/es/plus/salesSdk/index.js +0 -52
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales.js +0 -712
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { _objectSpread2 } from "../../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
|
|
2
|
+
import { _asyncToGenerator } from "../../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
|
|
3
|
+
import { failed, partialFailure, unknown } from "../normalize.js";
|
|
4
|
+
import { projectBigSaleCartLine, resolveBigSaleLineId } from "../host/projection.js";
|
|
5
|
+
import { findCatalogProduct } from "./catalog.js";
|
|
6
|
+
//#region src/components/bigSale/templates/HDLKiosk/adapter/sales/cart.ts
|
|
7
|
+
function cancelled(reason) {
|
|
8
|
+
return {
|
|
9
|
+
status: "cancelled",
|
|
10
|
+
reason
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function findCartLine(context, lineId) {
|
|
14
|
+
var _context$cart$display;
|
|
15
|
+
return ((_context$cart$display = context.cart.displayLines) !== null && _context$cart$display !== void 0 ? _context$cart$display : context.cart.items).find((line) => resolveBigSaleLineId(line) === lineId);
|
|
16
|
+
}
|
|
17
|
+
function projectConfirmedMutationLine(product) {
|
|
18
|
+
var _projectBigSaleCartLi;
|
|
19
|
+
return product ? (_projectBigSaleCartLi = projectBigSaleCartLine(product)) !== null && _projectBigSaleCartLi !== void 0 ? _projectBigSaleCartLi : void 0 : void 0;
|
|
20
|
+
}
|
|
21
|
+
function projectConfirmedCartLineById(products, lineId) {
|
|
22
|
+
return projectConfirmedMutationLine(products.find((candidate) => resolveBigSaleLineId(candidate) === lineId));
|
|
23
|
+
}
|
|
24
|
+
function createBigSaleCartOperations({ getContext, getSnapshot, executeScan }) {
|
|
25
|
+
return {
|
|
26
|
+
consumeBarcode: function() {
|
|
27
|
+
var _ref = _asyncToGenerator(function* (code, signal) {
|
|
28
|
+
if (signal.aborted) return { status: "cancelled" };
|
|
29
|
+
if (!code.trim()) return failed("barcodeEmpty", "back");
|
|
30
|
+
try {
|
|
31
|
+
var _scanResult$meta$coun, _scanResult$meta;
|
|
32
|
+
const execution = yield executeScan(code);
|
|
33
|
+
if (signal.aborted) return unknown("barcodeAbortedAfterDispatch");
|
|
34
|
+
const scanResult = execution.scanResult;
|
|
35
|
+
if (!scanResult) return failed("barcodeUnavailable", "staff");
|
|
36
|
+
if (scanResult.status === "cancelled") return {
|
|
37
|
+
status: "cancelled",
|
|
38
|
+
reason: scanResult.reason
|
|
39
|
+
};
|
|
40
|
+
if (scanResult.status === "failed") return failed("barcodeNotResolved", "retry");
|
|
41
|
+
return {
|
|
42
|
+
status: "succeeded",
|
|
43
|
+
data: {
|
|
44
|
+
code: scanResult.status === "pending" ? "requiresSelection" : "added",
|
|
45
|
+
cartChangeConfirmed: scanResult.status === "success" && Number((_scanResult$meta$coun = (_scanResult$meta = scanResult.meta) === null || _scanResult$meta === void 0 ? void 0 : _scanResult$meta.count) !== null && _scanResult$meta$coun !== void 0 ? _scanResult$meta$coun : 0) > 0
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
} catch (error) {
|
|
49
|
+
return partialFailure("barcodeDispatchFailed", error);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
return function consumeBarcode(_x, _x2) {
|
|
53
|
+
return _ref.apply(this, arguments);
|
|
54
|
+
};
|
|
55
|
+
}(),
|
|
56
|
+
addProduct: function() {
|
|
57
|
+
var _ref2 = _asyncToGenerator(function* (input, signal) {
|
|
58
|
+
if (signal.aborted) return { status: "cancelled" };
|
|
59
|
+
const productId = Number(input.productId);
|
|
60
|
+
const quantity = Number(input.quantity);
|
|
61
|
+
if (!Number.isFinite(productId) || !Number.isFinite(quantity) || quantity <= 0) return failed("productInputInvalid", "back");
|
|
62
|
+
try {
|
|
63
|
+
const context = getContext();
|
|
64
|
+
const product = findCatalogProduct(context, String(productId));
|
|
65
|
+
if (!product) return failed("productNotFound", "back");
|
|
66
|
+
const result = yield context.cart.addProductWithFlow(product, {
|
|
67
|
+
quantity,
|
|
68
|
+
notShowToast: true
|
|
69
|
+
});
|
|
70
|
+
if (signal.aborted) return unknown("addProductAbortedAfterDispatch");
|
|
71
|
+
if (result.status === "cancelled") return cancelled("userCancelled");
|
|
72
|
+
if (result.status !== "added") return failed("productRequiresUnsupportedSelection", "back");
|
|
73
|
+
const confirmedLine = projectConfirmedMutationLine([...Array.isArray(result.products) ? result.products : []].reverse().find((candidate) => {
|
|
74
|
+
var _candidate$product_id;
|
|
75
|
+
return String((_candidate$product_id = candidate.product_id) !== null && _candidate$product_id !== void 0 ? _candidate$product_id : "") === input.productId;
|
|
76
|
+
}));
|
|
77
|
+
return {
|
|
78
|
+
status: "succeeded",
|
|
79
|
+
data: confirmedLine ? {
|
|
80
|
+
affectedLineId: confirmedLine.lineId,
|
|
81
|
+
confirmedLine
|
|
82
|
+
} : {}
|
|
83
|
+
};
|
|
84
|
+
} catch (error) {
|
|
85
|
+
return partialFailure("addProductFailed", error);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
return function addProduct(_x3, _x4) {
|
|
89
|
+
return _ref2.apply(this, arguments);
|
|
90
|
+
};
|
|
91
|
+
}(),
|
|
92
|
+
updateQuantity: function() {
|
|
93
|
+
var _ref3 = _asyncToGenerator(function* (input, signal) {
|
|
94
|
+
if (signal.aborted) return { status: "cancelled" };
|
|
95
|
+
const quantity = Number(input.quantity);
|
|
96
|
+
if (!Number.isFinite(quantity) || quantity <= 0) return failed("quantityInvalid", "back");
|
|
97
|
+
const context = getContext();
|
|
98
|
+
const line = findCartLine(context, input.lineId);
|
|
99
|
+
if (!line) return failed("cartLineNotFound", "back");
|
|
100
|
+
try {
|
|
101
|
+
const updatedProducts = yield context.cart.updateItemQuantity(line, quantity);
|
|
102
|
+
if (signal.aborted) return unknown("updateQuantityAbortedAfterDispatch");
|
|
103
|
+
const confirmedLine = projectConfirmedCartLineById(Array.isArray(updatedProducts) ? updatedProducts : [], input.lineId);
|
|
104
|
+
return {
|
|
105
|
+
status: "succeeded",
|
|
106
|
+
data: _objectSpread2({ affectedLineId: input.lineId }, confirmedLine ? { confirmedLine } : {})
|
|
107
|
+
};
|
|
108
|
+
} catch (error) {
|
|
109
|
+
return partialFailure("updateQuantityFailed", error);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
return function updateQuantity(_x5, _x6) {
|
|
113
|
+
return _ref3.apply(this, arguments);
|
|
114
|
+
};
|
|
115
|
+
}(),
|
|
116
|
+
removeLine: function() {
|
|
117
|
+
var _ref4 = _asyncToGenerator(function* (input, signal) {
|
|
118
|
+
if (signal.aborted) return { status: "cancelled" };
|
|
119
|
+
const context = getContext();
|
|
120
|
+
const line = findCartLine(context, input.lineId);
|
|
121
|
+
if (!line) return failed("cartLineNotFound", "back");
|
|
122
|
+
try {
|
|
123
|
+
const remainingProducts = yield context.cart.removeItem(line);
|
|
124
|
+
if (signal.aborted) return unknown("removeLineAbortedAfterDispatch");
|
|
125
|
+
return {
|
|
126
|
+
status: "succeeded",
|
|
127
|
+
data: _objectSpread2({ affectedLineId: input.lineId }, Array.isArray(remainingProducts) && !remainingProducts.some((candidate) => resolveBigSaleLineId(candidate) === input.lineId) ? { removedLineId: input.lineId } : {})
|
|
128
|
+
};
|
|
129
|
+
} catch (error) {
|
|
130
|
+
return partialFailure("removeLineFailed", error);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
return function removeLine(_x7, _x8) {
|
|
134
|
+
return _ref4.apply(this, arguments);
|
|
135
|
+
};
|
|
136
|
+
}(),
|
|
137
|
+
waitForCartConsistency: function() {
|
|
138
|
+
var _ref5 = _asyncToGenerator(function* (signal) {
|
|
139
|
+
if (signal.aborted) return { status: "cancelled" };
|
|
140
|
+
try {
|
|
141
|
+
yield getContext().cart.waitForCartConsistency();
|
|
142
|
+
if (signal.aborted) return unknown("consistencyAbortedAfterWait");
|
|
143
|
+
return {
|
|
144
|
+
status: "succeeded",
|
|
145
|
+
data: { observationId: getSnapshot().observationId }
|
|
146
|
+
};
|
|
147
|
+
} catch (error) {
|
|
148
|
+
return failed("cartConsistencyFailed", "retry", error);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
return function waitForCartConsistency(_x9) {
|
|
152
|
+
return _ref5.apply(this, arguments);
|
|
153
|
+
};
|
|
154
|
+
}(),
|
|
155
|
+
recalculateSummary: function() {
|
|
156
|
+
var _ref6 = _asyncToGenerator(function* (signal) {
|
|
157
|
+
if (signal.aborted) return { status: "cancelled" };
|
|
158
|
+
try {
|
|
159
|
+
var _getContext$sales$tem, _getContext$sales$tem2, _getContext$sales$tem3, _getContext$sales$tem4;
|
|
160
|
+
const summary = yield getContext().cart.recalcSummary();
|
|
161
|
+
if (signal.aborted) return unknown("summaryAbortedAfterDispatch");
|
|
162
|
+
if (!summary) return failed("summaryMissing", "retry");
|
|
163
|
+
return {
|
|
164
|
+
status: "succeeded",
|
|
165
|
+
data: {
|
|
166
|
+
observationId: getSnapshot().observationId,
|
|
167
|
+
confirmedSummary: {
|
|
168
|
+
status: "ready",
|
|
169
|
+
currency: String((_getContext$sales$tem = (_getContext$sales$tem2 = getContext().sales.tempOrder) === null || _getContext$sales$tem2 === void 0 ? void 0 : _getContext$sales$tem2.currency_code) !== null && _getContext$sales$tem !== void 0 ? _getContext$sales$tem : ""),
|
|
170
|
+
currencySymbol: String((_getContext$sales$tem3 = (_getContext$sales$tem4 = getContext().sales.tempOrder) === null || _getContext$sales$tem4 === void 0 ? void 0 : _getContext$sales$tem4.currency_symbol) !== null && _getContext$sales$tem3 !== void 0 ? _getContext$sales$tem3 : ""),
|
|
171
|
+
total: String(summary.total_amount),
|
|
172
|
+
due: String(summary.expect_amount)
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
} catch (error) {
|
|
177
|
+
return failed("summaryRecalculationFailed", "retry", error);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
return function recalculateSummary(_x10) {
|
|
181
|
+
return _ref6.apply(this, arguments);
|
|
182
|
+
};
|
|
183
|
+
}()
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
//#endregion
|
|
187
|
+
export { createBigSaleCartOperations, findCartLine, projectConfirmedMutationLine };
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { _objectSpread2 } from "../../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
|
|
2
|
+
import { _asyncToGenerator } from "../../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
|
|
3
|
+
import { resolveProductPricePresentation } from "../../../../../../plus/productSelect/pricing/pricePresentation.js";
|
|
4
|
+
import { failed, partialFailure } from "../normalize.js";
|
|
5
|
+
//#region src/components/bigSale/templates/HDLKiosk/adapter/sales/catalog.ts
|
|
6
|
+
function findCatalogProduct(context, productId) {
|
|
7
|
+
return context.products.products.find((product) => String(product.id) === productId);
|
|
8
|
+
}
|
|
9
|
+
function resolveProductQuery(context) {
|
|
10
|
+
var _bookingTicket$store;
|
|
11
|
+
if (typeof context.products.queryProducts === "function") return function() {
|
|
12
|
+
var _ref = _asyncToGenerator(function* (params) {
|
|
13
|
+
return (yield context.products.queryProducts.call(context.products, params)) || [];
|
|
14
|
+
});
|
|
15
|
+
return function(_x) {
|
|
16
|
+
return _ref.apply(this, arguments);
|
|
17
|
+
};
|
|
18
|
+
}();
|
|
19
|
+
const bookingTicket = context.sales.bookingTicket;
|
|
20
|
+
if (typeof (bookingTicket === null || bookingTicket === void 0 ? void 0 : bookingTicket.queryProducts) === "function") return function() {
|
|
21
|
+
var _ref2 = _asyncToGenerator(function* (params) {
|
|
22
|
+
return (yield bookingTicket.queryProducts(params)) || [];
|
|
23
|
+
});
|
|
24
|
+
return function(_x2) {
|
|
25
|
+
return _ref2.apply(this, arguments);
|
|
26
|
+
};
|
|
27
|
+
}();
|
|
28
|
+
const productListStore = bookingTicket === null || bookingTicket === void 0 || (_bookingTicket$store = bookingTicket.store) === null || _bookingTicket$store === void 0 ? void 0 : _bookingTicket$store.products;
|
|
29
|
+
if (typeof (productListStore === null || productListStore === void 0 ? void 0 : productListStore.queryProducts) === "function") return function() {
|
|
30
|
+
var _ref3 = _asyncToGenerator(function* (params) {
|
|
31
|
+
return (yield productListStore.queryProducts.call(productListStore, params)) || [];
|
|
32
|
+
});
|
|
33
|
+
return function(_x3) {
|
|
34
|
+
return _ref3.apply(this, arguments);
|
|
35
|
+
};
|
|
36
|
+
}();
|
|
37
|
+
}
|
|
38
|
+
function queryPrimaryProduct(_x4, _x5, _x6) {
|
|
39
|
+
return _queryPrimaryProduct.apply(this, arguments);
|
|
40
|
+
}
|
|
41
|
+
function _queryPrimaryProduct() {
|
|
42
|
+
_queryPrimaryProduct = _asyncToGenerator(function* (context, productId, signal) {
|
|
43
|
+
if (signal.aborted) return { status: "cancelled" };
|
|
44
|
+
const queryProducts = resolveProductQuery(context);
|
|
45
|
+
if (!queryProducts) return failed("primaryProductQueryUnavailable", "staff");
|
|
46
|
+
try {
|
|
47
|
+
let products = yield queryProducts({ includeIds: [productId] });
|
|
48
|
+
if (signal.aborted) return { status: "cancelled" };
|
|
49
|
+
let product = products.find((candidate) => String(candidate.id) === productId);
|
|
50
|
+
const numericProductId = Number(productId);
|
|
51
|
+
if (!product && Number.isSafeInteger(numericProductId) && numericProductId > 0 && typeof context.products.findByIds === "function") {
|
|
52
|
+
yield context.products.findByIds([numericProductId], {
|
|
53
|
+
loadMissing: true,
|
|
54
|
+
refreshCatalog: false
|
|
55
|
+
});
|
|
56
|
+
if (signal.aborted) return { status: "cancelled" };
|
|
57
|
+
products = yield queryProducts({ includeIds: [productId] });
|
|
58
|
+
if (signal.aborted) return { status: "cancelled" };
|
|
59
|
+
product = products.find((candidate) => String(candidate.id) === productId);
|
|
60
|
+
}
|
|
61
|
+
return product ? {
|
|
62
|
+
status: "succeeded",
|
|
63
|
+
data: product
|
|
64
|
+
} : failed("primaryProductNotFound", "staff");
|
|
65
|
+
} catch (error) {
|
|
66
|
+
return partialFailure("primaryProductQueryFailed", error);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
return _queryPrimaryProduct.apply(this, arguments);
|
|
70
|
+
}
|
|
71
|
+
function readProductName(product) {
|
|
72
|
+
const rawName = product.title;
|
|
73
|
+
if (typeof rawName === "string") return rawName || void 0;
|
|
74
|
+
if (!rawName || typeof rawName !== "object") return void 0;
|
|
75
|
+
return Object.values(rawName).find((value) => typeof value === "string" && value.length > 0);
|
|
76
|
+
}
|
|
77
|
+
function readLocalizedText(value) {
|
|
78
|
+
if (typeof value === "string") return value || void 0;
|
|
79
|
+
if (!value || typeof value !== "object") return void 0;
|
|
80
|
+
return Object.values(value).find((item) => typeof item === "string" && item.length > 0);
|
|
81
|
+
}
|
|
82
|
+
function projectProductCategories(product) {
|
|
83
|
+
const directCategories = Array.isArray(product.category) ? product.category : [];
|
|
84
|
+
const categories = /* @__PURE__ */ new Map();
|
|
85
|
+
const visit = (category, direct) => {
|
|
86
|
+
var _category$name, _ref4, _category$parent_id;
|
|
87
|
+
if (!category || category.id === void 0 || category.id === null) return;
|
|
88
|
+
const parent = category.parent_category;
|
|
89
|
+
visit(parent, false);
|
|
90
|
+
const categoryId = String(category.id);
|
|
91
|
+
const name = readLocalizedText((_category$name = category.name) !== null && _category$name !== void 0 ? _category$name : category.title);
|
|
92
|
+
if (!name) return;
|
|
93
|
+
const parentId = (_ref4 = (_category$parent_id = category.parent_id) !== null && _category$parent_id !== void 0 ? _category$parent_id : parent === null || parent === void 0 ? void 0 : parent.id) !== null && _ref4 !== void 0 ? _ref4 : void 0;
|
|
94
|
+
const previous = categories.get(categoryId);
|
|
95
|
+
categories.set(categoryId, Object.freeze({
|
|
96
|
+
categoryId,
|
|
97
|
+
name,
|
|
98
|
+
parentId: parentId === void 0 || parentId === null || parentId === 0 ? void 0 : String(parentId),
|
|
99
|
+
sort: Number.isFinite(Number(category.sort)) ? Number(category.sort) : void 0,
|
|
100
|
+
direct: direct || (previous === null || previous === void 0 ? void 0 : previous.direct) === true
|
|
101
|
+
}));
|
|
102
|
+
};
|
|
103
|
+
directCategories.forEach((category) => visit(category, true));
|
|
104
|
+
return Object.freeze(Array.from(categories.values()));
|
|
105
|
+
}
|
|
106
|
+
function projectCatalogProduct(product, currency, currencySymbol) {
|
|
107
|
+
var _ref5, _ref6, _product$price, _product$variants, _product$variants2;
|
|
108
|
+
const name = readProductName(product);
|
|
109
|
+
if (!name) return void 0;
|
|
110
|
+
const rawPrice = (_ref5 = (_ref6 = (_product$price = product.price) !== null && _product$price !== void 0 ? _product$price : product.selling_price) !== null && _ref6 !== void 0 ? _ref6 : (_product$variants = product.variants) === null || _product$variants === void 0 || (_product$variants = _product$variants[0]) === null || _product$variants === void 0 ? void 0 : _product$variants.selling_price) !== null && _ref5 !== void 0 ? _ref5 : (_product$variants2 = product.variants) === null || _product$variants2 === void 0 || (_product$variants2 = _product$variants2[0]) === null || _product$variants2 === void 0 ? void 0 : _product$variants2.price;
|
|
111
|
+
const pricePresentation = resolveProductPricePresentation(product, rawPrice === void 0 || rawPrice === null ? void 0 : { price: rawPrice });
|
|
112
|
+
const categories = projectProductCategories(product);
|
|
113
|
+
return Object.freeze(_objectSpread2({
|
|
114
|
+
productId: String(product.id),
|
|
115
|
+
name,
|
|
116
|
+
imageUrl: product.cover || void 0,
|
|
117
|
+
currency: currency || void 0,
|
|
118
|
+
currencySymbol: currencySymbol || void 0,
|
|
119
|
+
pricePresentation: pricePresentation ? Object.freeze({
|
|
120
|
+
amount: String(pricePresentation.amount),
|
|
121
|
+
originalAmount: pricePresentation.originalAmount === void 0 ? void 0 : String(pricePresentation.originalAmount),
|
|
122
|
+
qualifier: pricePresentation.qualifier,
|
|
123
|
+
unit: pricePresentation.unit,
|
|
124
|
+
precision: pricePresentation.precision
|
|
125
|
+
}) : void 0,
|
|
126
|
+
available: product.status !== "disabled" && product.status !== "sold_out" && product.is_sold_out !== true
|
|
127
|
+
}, categories.length ? { categories } : {}));
|
|
128
|
+
}
|
|
129
|
+
function createBigSaleCatalogOperations({ getContext }) {
|
|
130
|
+
return {
|
|
131
|
+
getCatalogSnapshot: () => {
|
|
132
|
+
var _context$sales$tempOr, _context$sales$tempOr2, _context$sales$tempOr3, _context$sales$tempOr4;
|
|
133
|
+
const context = getContext();
|
|
134
|
+
const currency = String((_context$sales$tempOr = (_context$sales$tempOr2 = context.sales.tempOrder) === null || _context$sales$tempOr2 === void 0 ? void 0 : _context$sales$tempOr2.currency_code) !== null && _context$sales$tempOr !== void 0 ? _context$sales$tempOr : "");
|
|
135
|
+
const currencySymbol = String((_context$sales$tempOr3 = (_context$sales$tempOr4 = context.sales.tempOrder) === null || _context$sales$tempOr4 === void 0 ? void 0 : _context$sales$tempOr4.currency_symbol) !== null && _context$sales$tempOr3 !== void 0 ? _context$sales$tempOr3 : "");
|
|
136
|
+
const products = context.products.products.map((product) => projectCatalogProduct(product, currency, currencySymbol)).filter((product) => product !== void 0);
|
|
137
|
+
return Object.freeze({
|
|
138
|
+
status: context.products.error ? "error" : context.products.loading || context.sales.catalogState === "pending" ? "loading" : "ready",
|
|
139
|
+
products: Object.freeze(products)
|
|
140
|
+
});
|
|
141
|
+
},
|
|
142
|
+
loadPrimaryProduct: function() {
|
|
143
|
+
var _ref7 = _asyncToGenerator(function* (rawProductId, signal) {
|
|
144
|
+
if (signal.aborted) return { status: "cancelled" };
|
|
145
|
+
const productId = Number(rawProductId);
|
|
146
|
+
if (!Number.isFinite(productId)) return failed("primaryProductIdInvalid", "staff");
|
|
147
|
+
try {
|
|
148
|
+
return yield queryPrimaryProduct(getContext(), String(productId), signal);
|
|
149
|
+
} catch (error) {
|
|
150
|
+
return partialFailure("primaryProductLoadFailed", error);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
return function loadPrimaryProduct(_x7, _x8) {
|
|
154
|
+
return _ref7.apply(this, arguments);
|
|
155
|
+
};
|
|
156
|
+
}()
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
//#endregion
|
|
160
|
+
export { createBigSaleCatalogOperations, findCatalogProduct, queryPrimaryProduct };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { _objectSpread2 } from "
|
|
2
|
-
import { validateAndNormalizeSkuValue } from "
|
|
1
|
+
import { _objectSpread2 } from "../../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
|
|
2
|
+
import { validateAndNormalizeSkuValue } from "../../../../../../plus/skuOptionsSelection/utils/validateSkuValue.js";
|
|
3
3
|
import { createHDLWeightedPreparedProduct } from "./weightedProduct.js";
|
|
4
4
|
import Decimal from "decimal.js";
|
|
5
|
-
//#region src/components/bigSale/templates/HDLKiosk/adapter/customizationProduct.ts
|
|
5
|
+
//#region src/components/bigSale/templates/HDLKiosk/adapter/sales/customizationProduct.ts
|
|
6
6
|
/**
|
|
7
7
|
* 文件角色:将 HDLKiosk 选中结果写入 OS 标准称重商品。
|
|
8
8
|
* 运行机制:提交时按 SKUOptionsSelection 的标准 ProductData 约束校验 SkuValue,并将
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { _asyncToGenerator } from "../../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
|
|
2
|
+
import { failed, partialFailure } from "../normalize.js";
|
|
3
|
+
//#region src/components/bigSale/templates/HDLKiosk/adapter/sales/fulfillment.ts
|
|
4
|
+
function createBigSaleFulfillmentOperations({ writeFulfillment, getWriteFulfillment, allowSimulatedFulfillment = false, onSimulatedFulfillment }) {
|
|
5
|
+
return { setFulfillment: function() {
|
|
6
|
+
var _ref = _asyncToGenerator(function* (input, signal) {
|
|
7
|
+
if (signal.aborted) return { status: "cancelled" };
|
|
8
|
+
const currentWriteFulfillment = getWriteFulfillment ? getWriteFulfillment() : writeFulfillment;
|
|
9
|
+
if (!currentWriteFulfillment) {
|
|
10
|
+
if (allowSimulatedFulfillment) {
|
|
11
|
+
onSimulatedFulfillment === null || onSimulatedFulfillment === void 0 || onSimulatedFulfillment(input);
|
|
12
|
+
return {
|
|
13
|
+
status: "succeeded",
|
|
14
|
+
data: void 0
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
return failed("fulfillmentHostWriterUnavailable", "staff");
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
return yield currentWriteFulfillment(input, signal);
|
|
21
|
+
} catch (error) {
|
|
22
|
+
return partialFailure("fulfillmentWriteFailed", error);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return function setFulfillment(_x, _x2) {
|
|
26
|
+
return _ref.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
}() };
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { createBigSaleFulfillmentOperations };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { _objectSpread2 } from "../../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
|
|
2
|
+
import { _asyncToGenerator } from "../../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
|
|
3
|
+
import { failed, partialFailure, unknown } from "../normalize.js";
|
|
4
|
+
//#region src/components/bigSale/templates/HDLKiosk/adapter/sales/identity.ts
|
|
5
|
+
function projectConfirmedCustomer(customer) {
|
|
6
|
+
var _customer$id;
|
|
7
|
+
if (!customer || [
|
|
8
|
+
"0",
|
|
9
|
+
"1",
|
|
10
|
+
""
|
|
11
|
+
].includes(String((_customer$id = customer.id) !== null && _customer$id !== void 0 ? _customer$id : ""))) return;
|
|
12
|
+
return Object.freeze(_objectSpread2(_objectSpread2({
|
|
13
|
+
customerId: String(customer.id),
|
|
14
|
+
displayName: typeof customer.name === "string" ? customer.name : void 0
|
|
15
|
+
}, typeof customer.avatar === "string" && customer.avatar.trim() ? { avatarUrl: customer.avatar.trim() } : {}), {}, { member: true }));
|
|
16
|
+
}
|
|
17
|
+
function createBigSaleIdentityOperations({ getContext, getAuthenticatedCustomer }) {
|
|
18
|
+
return { selectIdentity: function() {
|
|
19
|
+
var _ref = _asyncToGenerator(function* (input, signal) {
|
|
20
|
+
if (signal.aborted) return { status: "cancelled" };
|
|
21
|
+
try {
|
|
22
|
+
var _input$customerId, _currentCustomer$id, _selected$id;
|
|
23
|
+
const context = getContext();
|
|
24
|
+
const customerId = (_input$customerId = input.customerId) === null || _input$customerId === void 0 ? void 0 : _input$customerId.trim();
|
|
25
|
+
if (!customerId) {
|
|
26
|
+
context.customer.select(null);
|
|
27
|
+
if (signal.aborted) return unknown("identityAbortedAfterDispatch");
|
|
28
|
+
return {
|
|
29
|
+
status: "succeeded",
|
|
30
|
+
data: {}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const authenticatedCustomer = getAuthenticatedCustomer === null || getAuthenticatedCustomer === void 0 ? void 0 : getAuthenticatedCustomer(customerId);
|
|
34
|
+
const currentCustomer = context.customer.selected;
|
|
35
|
+
const selected = authenticatedCustomer !== null && authenticatedCustomer !== void 0 ? authenticatedCustomer : String((_currentCustomer$id = currentCustomer === null || currentCustomer === void 0 ? void 0 : currentCustomer.id) !== null && _currentCustomer$id !== void 0 ? _currentCustomer$id : "") === customerId ? currentCustomer : void 0;
|
|
36
|
+
if (!selected || String(selected.id) !== customerId || [
|
|
37
|
+
"0",
|
|
38
|
+
"1",
|
|
39
|
+
""
|
|
40
|
+
].includes(String((_selected$id = selected.id) !== null && _selected$id !== void 0 ? _selected$id : ""))) return failed("authenticatedCustomerUnavailable", "back");
|
|
41
|
+
context.customer.select(selected);
|
|
42
|
+
if (signal.aborted) return unknown("identityAbortedAfterDispatch");
|
|
43
|
+
return {
|
|
44
|
+
status: "succeeded",
|
|
45
|
+
data: { customer: projectConfirmedCustomer(selected) }
|
|
46
|
+
};
|
|
47
|
+
} catch (error) {
|
|
48
|
+
return partialFailure("identitySelectionFailed", error);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
return function selectIdentity(_x, _x2) {
|
|
52
|
+
return _ref.apply(this, arguments);
|
|
53
|
+
};
|
|
54
|
+
}() };
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
export { createBigSaleIdentityOperations };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { _objectSpread2 } from "../../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
|
|
2
|
+
import { createBigSaleCatalogOperations } from "./catalog.js";
|
|
3
|
+
import { createBigSaleCartOperations } from "./cart.js";
|
|
4
|
+
import { createBigSaleFulfillmentOperations } from "./fulfillment.js";
|
|
5
|
+
import { createBigSaleIdentityOperations } from "./identity.js";
|
|
6
|
+
import { createBigSalePaymentOperations } from "./payment.js";
|
|
7
|
+
import { createBigSaleSessionOperations } from "./session.js";
|
|
8
|
+
import { createBigSaleWeightedProductOperations } from "./weightedOperations.js";
|
|
9
|
+
//#region src/components/bigSale/templates/HDLKiosk/adapter/sales/index.ts
|
|
10
|
+
function createBigSaleSalesPort(dependencies) {
|
|
11
|
+
const { getContext, getSnapshot, subscribeProjection } = dependencies;
|
|
12
|
+
return _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({ getObservedSnapshot: getSnapshot }, createBigSaleCatalogOperations({ getContext })), {}, { subscribe: (listener) => {
|
|
13
|
+
var _subscribeProjection;
|
|
14
|
+
return (_subscribeProjection = subscribeProjection === null || subscribeProjection === void 0 ? void 0 : subscribeProjection(listener)) !== null && _subscribeProjection !== void 0 ? _subscribeProjection : (() => void 0);
|
|
15
|
+
} }, createBigSaleSessionOperations({ getContext })), createBigSaleIdentityOperations(dependencies)), createBigSaleFulfillmentOperations(dependencies)), createBigSaleWeightedProductOperations({ getContext })), createBigSaleCartOperations(dependencies)), createBigSalePaymentOperations(dependencies));
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { createBigSaleSalesPort };
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { _asyncToGenerator } from "../../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
|
|
2
|
+
import { failed, isRecord, readPath, unknown } from "../normalize.js";
|
|
3
|
+
//#region src/components/bigSale/templates/HDLKiosk/adapter/sales/payment.ts
|
|
4
|
+
function cancelled(reason) {
|
|
5
|
+
return {
|
|
6
|
+
status: "cancelled",
|
|
7
|
+
reason
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
function normalizeCheckoutResult(result, snapshot) {
|
|
11
|
+
var _readPath, _result$orderId, _snapshot$orderId, _snapshot$customer;
|
|
12
|
+
const status = isRecord(result) ? result.status : void 0;
|
|
13
|
+
const reason = isRecord(result) ? result.reason : void 0;
|
|
14
|
+
const type = isRecord(result) ? result.type : void 0;
|
|
15
|
+
if (status === "cancelled" || reason === "back" || reason === "cancel") return {
|
|
16
|
+
status: "cancelled",
|
|
17
|
+
reason: String(reason !== null && reason !== void 0 ? reason : "cancelled")
|
|
18
|
+
};
|
|
19
|
+
const paymentStatus = (_readPath = readPath(result, [
|
|
20
|
+
"payload",
|
|
21
|
+
"paymentResult",
|
|
22
|
+
"paymentResultViewModel",
|
|
23
|
+
"status"
|
|
24
|
+
])) !== null && _readPath !== void 0 ? _readPath : readPath(result, [
|
|
25
|
+
"data",
|
|
26
|
+
"paymentResult",
|
|
27
|
+
"paymentResultViewModel",
|
|
28
|
+
"status"
|
|
29
|
+
]);
|
|
30
|
+
if (paymentStatus === "failed" || paymentStatus === "wallet-pass-failed") return failed("checkoutFailed", "retry");
|
|
31
|
+
if (type === "error" || status === "failed") return failed("checkoutFailed", "retry");
|
|
32
|
+
if (!(paymentStatus === "success" || paymentStatus === "paid" || paymentStatus === "deposit-paid" || status === "success" || status === "paid")) return unknown("checkoutResultAmbiguous");
|
|
33
|
+
const resultOrderId = isRecord(result) && ((_result$orderId = result.orderId) !== null && _result$orderId !== void 0 ? _result$orderId : result.order_id) || readPath(result, ["payload", "order_id"]) || readPath(result, ["payload", "orderId"]);
|
|
34
|
+
const orderId = (_snapshot$orderId = snapshot.orderId) !== null && _snapshot$orderId !== void 0 ? _snapshot$orderId : resultOrderId;
|
|
35
|
+
if (!orderId || snapshot.summary.status !== "ready") return unknown("checkoutSuccessMissingOrderFacts");
|
|
36
|
+
return {
|
|
37
|
+
status: "succeeded",
|
|
38
|
+
data: {
|
|
39
|
+
orderId: String(orderId),
|
|
40
|
+
amount: snapshot.summary.due,
|
|
41
|
+
member: ((_snapshot$customer = snapshot.customer) === null || _snapshot$customer === void 0 ? void 0 : _snapshot$customer.member) === true
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function refreshCheckoutOrderProjection(_x, _x2, _x3) {
|
|
46
|
+
return _refreshCheckoutOrderProjection.apply(this, arguments);
|
|
47
|
+
}
|
|
48
|
+
function _refreshCheckoutOrderProjection() {
|
|
49
|
+
_refreshCheckoutOrderProjection = _asyncToGenerator(function* (getContext, getSnapshot, result) {
|
|
50
|
+
if (result.status !== "succeeded" || getSnapshot().pickupNumber) return;
|
|
51
|
+
const loadDetail = getContext().sales.loadDetail;
|
|
52
|
+
if (typeof loadDetail !== "function") return;
|
|
53
|
+
try {
|
|
54
|
+
yield loadDetail({
|
|
55
|
+
orderId: result.data.orderId,
|
|
56
|
+
forceRemote: true
|
|
57
|
+
});
|
|
58
|
+
} catch (_unused) {}
|
|
59
|
+
});
|
|
60
|
+
return _refreshCheckoutOrderProjection.apply(this, arguments);
|
|
61
|
+
}
|
|
62
|
+
function createBigSalePaymentOperations({ getContext, getSnapshot, getPaymentController }) {
|
|
63
|
+
return {
|
|
64
|
+
loadPaymentMethods: function() {
|
|
65
|
+
var _ref = _asyncToGenerator(function* (signal) {
|
|
66
|
+
if (signal.aborted) return cancelled("paymentMethodsAborted");
|
|
67
|
+
const controller = getPaymentController === null || getPaymentController === void 0 ? void 0 : getPaymentController();
|
|
68
|
+
return controller ? controller.loadPaymentMethods() : failed("paymentRuntimeUnavailable", "staff");
|
|
69
|
+
});
|
|
70
|
+
return function loadPaymentMethods(_x4) {
|
|
71
|
+
return _ref.apply(this, arguments);
|
|
72
|
+
};
|
|
73
|
+
}(),
|
|
74
|
+
payEftpos: function() {
|
|
75
|
+
var _ref2 = _asyncToGenerator(function* (input, signal) {
|
|
76
|
+
if (signal.aborted) return cancelled("eftposAborted");
|
|
77
|
+
const controller = getPaymentController === null || getPaymentController === void 0 ? void 0 : getPaymentController();
|
|
78
|
+
return controller ? controller.payEftpos(input) : failed("paymentRuntimeUnavailable", "staff");
|
|
79
|
+
});
|
|
80
|
+
return function payEftpos(_x5, _x6) {
|
|
81
|
+
return _ref2.apply(this, arguments);
|
|
82
|
+
};
|
|
83
|
+
}(),
|
|
84
|
+
requestStaffPaymentApproval: function() {
|
|
85
|
+
var _ref3 = _asyncToGenerator(function* (input, signal) {
|
|
86
|
+
if (signal.aborted) return cancelled("staffPaymentApprovalAborted");
|
|
87
|
+
const controller = getPaymentController === null || getPaymentController === void 0 ? void 0 : getPaymentController();
|
|
88
|
+
return controller ? controller.requestStaffPaymentApproval(input) : failed("paymentRuntimeUnavailable", "staff");
|
|
89
|
+
});
|
|
90
|
+
return function requestStaffPaymentApproval(_x7, _x8) {
|
|
91
|
+
return _ref3.apply(this, arguments);
|
|
92
|
+
};
|
|
93
|
+
}(),
|
|
94
|
+
subscribeStaffPaymentAuthorizationResult: (listener) => {
|
|
95
|
+
var _controller$subscribe;
|
|
96
|
+
const controller = getPaymentController === null || getPaymentController === void 0 ? void 0 : getPaymentController();
|
|
97
|
+
return (_controller$subscribe = controller === null || controller === void 0 ? void 0 : controller.subscribeStaffPaymentAuthorizationResult(listener)) !== null && _controller$subscribe !== void 0 ? _controller$subscribe : (() => void 0);
|
|
98
|
+
},
|
|
99
|
+
openCheckout: function() {
|
|
100
|
+
var _ref4 = _asyncToGenerator(function* (signal) {
|
|
101
|
+
if (signal.aborted) return { status: "cancelled" };
|
|
102
|
+
try {
|
|
103
|
+
const snapshotBeforeCheckout = getSnapshot();
|
|
104
|
+
const result = yield getContext().sales.openCheckout({
|
|
105
|
+
paymentResultDisplayMode: "page",
|
|
106
|
+
walletPassMode: "shared"
|
|
107
|
+
});
|
|
108
|
+
if (signal.aborted) return unknown("checkoutAbortedAfterDispatch");
|
|
109
|
+
const checkoutResult = normalizeCheckoutResult(result, snapshotBeforeCheckout);
|
|
110
|
+
yield refreshCheckoutOrderProjection(getContext, getSnapshot, checkoutResult);
|
|
111
|
+
return checkoutResult;
|
|
112
|
+
} catch (error) {
|
|
113
|
+
return unknown("checkoutInvocationFailed", error);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
return function openCheckout(_x9) {
|
|
117
|
+
return _ref4.apply(this, arguments);
|
|
118
|
+
};
|
|
119
|
+
}()
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
//#endregion
|
|
123
|
+
export { createBigSalePaymentOperations };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { _asyncToGenerator } from "../../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
|
|
2
|
+
import { partialFailure, unknown } from "../normalize.js";
|
|
3
|
+
import { resolveBigSaleLiveTempOrder } from "../host/projection.js";
|
|
4
|
+
//#region src/components/bigSale/templates/HDLKiosk/adapter/sales/session.ts
|
|
5
|
+
const PAYMENT_WRITE_FROZEN_STATUSES = new Set(["payment_pending", "processing"]);
|
|
6
|
+
function readPaymentStatus(order) {
|
|
7
|
+
var _order$payment_status;
|
|
8
|
+
return String((_order$payment_status = order === null || order === void 0 ? void 0 : order.payment_status) !== null && _order$payment_status !== void 0 ? _order$payment_status : "").trim().toLowerCase();
|
|
9
|
+
}
|
|
10
|
+
function hasCommittedOrderIdentity(order) {
|
|
11
|
+
const orderId = order === null || order === void 0 ? void 0 : order.order_id;
|
|
12
|
+
return orderId !== null && orderId !== void 0 && String(orderId).trim() !== "";
|
|
13
|
+
}
|
|
14
|
+
function isCommittedPaidOrder(order) {
|
|
15
|
+
return readPaymentStatus(order) === "paid" && hasCommittedOrderIdentity(order);
|
|
16
|
+
}
|
|
17
|
+
function createBigSaleSessionOperations({ getContext }) {
|
|
18
|
+
return {
|
|
19
|
+
ensureSession: function() {
|
|
20
|
+
var _ref = _asyncToGenerator(function* (signal) {
|
|
21
|
+
if (signal.aborted) return { status: "cancelled" };
|
|
22
|
+
const context = getContext();
|
|
23
|
+
const currentOrder = resolveBigSaleLiveTempOrder(context);
|
|
24
|
+
const currentPaymentStatus = readPaymentStatus(currentOrder);
|
|
25
|
+
if (PAYMENT_WRITE_FROZEN_STATUSES.has(currentPaymentStatus)) return unknown("ensureSessionPaymentInProgress");
|
|
26
|
+
if (currentOrder && !isCommittedPaidOrder(currentOrder)) return {
|
|
27
|
+
status: "succeeded",
|
|
28
|
+
data: void 0
|
|
29
|
+
};
|
|
30
|
+
try {
|
|
31
|
+
const createdOrder = isCommittedPaidOrder(currentOrder) ? yield context.sales.clearCartAndReset() : yield context.sales.createNew();
|
|
32
|
+
if (signal.aborted) return unknown("ensureSessionAbortedAfterDispatch");
|
|
33
|
+
const liveCreatedOrder = resolveBigSaleLiveTempOrder(getContext());
|
|
34
|
+
const createdPaymentStatus = readPaymentStatus(liveCreatedOrder !== null && liveCreatedOrder !== void 0 ? liveCreatedOrder : createdOrder);
|
|
35
|
+
if (isCommittedPaidOrder(liveCreatedOrder !== null && liveCreatedOrder !== void 0 ? liveCreatedOrder : createdOrder) || PAYMENT_WRITE_FROZEN_STATUSES.has(createdPaymentStatus)) return unknown("ensureSessionNotWritable");
|
|
36
|
+
return {
|
|
37
|
+
status: "succeeded",
|
|
38
|
+
data: void 0
|
|
39
|
+
};
|
|
40
|
+
} catch (error) {
|
|
41
|
+
return partialFailure("ensureSessionFailed", error);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return function ensureSession(_x) {
|
|
45
|
+
return _ref.apply(this, arguments);
|
|
46
|
+
};
|
|
47
|
+
}(),
|
|
48
|
+
clearAndReset: function() {
|
|
49
|
+
var _ref2 = _asyncToGenerator(function* (signal) {
|
|
50
|
+
if (signal.aborted) return { status: "cancelled" };
|
|
51
|
+
try {
|
|
52
|
+
var _resetOrder$products$, _resetOrder$products, _resetOrder$bookings$, _resetOrder$bookings;
|
|
53
|
+
const resetOrder = yield getContext().sales.clearCartAndReset();
|
|
54
|
+
if (signal.aborted) return unknown("resetAbortedAfterDispatch");
|
|
55
|
+
if (!(((_resetOrder$products$ = (_resetOrder$products = resetOrder.products) === null || _resetOrder$products === void 0 ? void 0 : _resetOrder$products.length) !== null && _resetOrder$products$ !== void 0 ? _resetOrder$products$ : 0) === 0 && ((_resetOrder$bookings$ = (_resetOrder$bookings = resetOrder.bookings) === null || _resetOrder$bookings === void 0 ? void 0 : _resetOrder$bookings.length) !== null && _resetOrder$bookings$ !== void 0 ? _resetOrder$bookings$ : 0) === 0)) return unknown("resetHostResultNotEmpty");
|
|
56
|
+
return {
|
|
57
|
+
status: "succeeded",
|
|
58
|
+
data: { cartEmpty: true }
|
|
59
|
+
};
|
|
60
|
+
} catch (error) {
|
|
61
|
+
return partialFailure("resetFailed", error);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
return function clearAndReset(_x2) {
|
|
65
|
+
return _ref2.apply(this, arguments);
|
|
66
|
+
};
|
|
67
|
+
}()
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { createBigSaleSessionOperations };
|