@pisell/pisellos 0.10.90 → 0.10.93
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/index.d.ts +1 -1
- 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 +20 -4
- 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 +10 -0
- package/dist/solution/BookingTicket/index.js +686 -598
- 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 +8 -8
- 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/index.d.ts +1 -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 +20 -4
- 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 +10 -0
- package/lib/solution/BookingTicket/index.js +57 -6
- 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 +8 -8
- 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
|
@@ -31,6 +31,7 @@ var _getDateIsInSchedule = require("../../modules/Schedule/getDateIsInSchedule")
|
|
|
31
31
|
var _utils2 = require("../../modules/Order/utils");
|
|
32
32
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
33
33
|
var _itemRule = require("../../model/strategy/adapter/itemRule");
|
|
34
|
+
var _menuAvailability = require("./menuAvailability");
|
|
34
35
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
35
36
|
function isItemRewardProductDiscount(discount) {
|
|
36
37
|
return discount?.type === 'product' && discount?.metadata?.source === 'promotion' && discount?.metadata?.actionType === 'ITEM_REWARD';
|
|
@@ -789,6 +790,7 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
|
|
|
789
790
|
}
|
|
790
791
|
|
|
791
792
|
// ScanOrder 提交 payload enhancer:
|
|
793
|
+
// - 新单有桌台上下文但无 booking 时,补建基础预约(通用 Order 已不再自动生成)
|
|
792
794
|
// - 给所有 booking 注入 appointment_status: 'started'(扫码点餐语义)
|
|
793
795
|
// - 给所有 booking 的 metadata 注入 resource_select_type(来自预约规则商品的 resource.type)
|
|
794
796
|
// - 给第一条 booking 补 resources 与 product_uid(仅当存在 resource / rule product)
|
|
@@ -810,7 +812,8 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
|
|
|
810
812
|
};
|
|
811
813
|
return (payload, {
|
|
812
814
|
bookingUuid,
|
|
813
|
-
tempOrder
|
|
815
|
+
tempOrder,
|
|
816
|
+
now
|
|
814
817
|
}) => {
|
|
815
818
|
const resourceId = String(resourceState?.relationId ?? '').trim();
|
|
816
819
|
const hasReservationBookingContext = Boolean(ruleProduct && resourceState && resourceId && resourceState.relationId && resourceState.tableFormId);
|
|
@@ -847,7 +850,31 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
|
|
|
847
850
|
} : undefined;
|
|
848
851
|
const ruleProductUid = ruleProduct ? (0, _utils2.createUuidV4)() : undefined;
|
|
849
852
|
const bookingCapacityDimensionId = (0, _utils.pickFirstCustomCapacityDimensionId)(this.enabledReservationRuleProducts) ?? 0;
|
|
850
|
-
|
|
853
|
+
let bookings = payload.bookings || [];
|
|
854
|
+
if (!tempOrder.order_id && bookings.length === 0) {
|
|
855
|
+
const bookingStart = (0, _dayjs.default)(now);
|
|
856
|
+
const bookingDuration = (0, _utils2.resolveTableOccupancyDuration)(tempOrder);
|
|
857
|
+
const bookingEnd = bookingStart.add(bookingDuration, 'minute');
|
|
858
|
+
bookings = [(0, _utils2.normalizeSubmitBooking)({
|
|
859
|
+
relation_id: 0,
|
|
860
|
+
form_id: 0,
|
|
861
|
+
start_time: bookingStart.format('HH:mm'),
|
|
862
|
+
start_date: bookingStart.format('YYYY-MM-DD'),
|
|
863
|
+
end_time: bookingEnd.format('HH:mm'),
|
|
864
|
+
end_date: bookingEnd.format('YYYY-MM-DD'),
|
|
865
|
+
duration: bookingDuration,
|
|
866
|
+
metadata: {
|
|
867
|
+
unique_identification_number: bookingUuid
|
|
868
|
+
},
|
|
869
|
+
select_date: bookingStart.format('YYYY-MM-DD'),
|
|
870
|
+
is_all: false,
|
|
871
|
+
like_status: 'common',
|
|
872
|
+
schedule_id: 0,
|
|
873
|
+
relation_type: '',
|
|
874
|
+
number: 1
|
|
875
|
+
})];
|
|
876
|
+
}
|
|
877
|
+
const nextBookings = bookings.map((booking, idx) => {
|
|
851
878
|
const metadata = {
|
|
852
879
|
...(booking.metadata || {})
|
|
853
880
|
};
|
|
@@ -960,6 +987,27 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
|
|
|
960
987
|
}
|
|
961
988
|
return result;
|
|
962
989
|
}
|
|
990
|
+
|
|
991
|
+
/** Read both current and legacy cart snapshots without changing the product catalog. */
|
|
992
|
+
getMenuAvailabilityProductSources(tempOrder) {
|
|
993
|
+
const products = tempOrder.products || [];
|
|
994
|
+
const sources = [...this.enabledReservationRuleProducts];
|
|
995
|
+
for (const product of products) {
|
|
996
|
+
const uid = product.metadata?.unique_identification_number;
|
|
997
|
+
const origins = [product._origin, product.metadata?.origin, uid ? tempOrder._extend?.productsByUid?.[String(uid)]?.origin : undefined];
|
|
998
|
+
for (const origin of origins) {
|
|
999
|
+
if (origin && typeof origin === 'object' && !Array.isArray(origin)) {
|
|
1000
|
+
sources.push({
|
|
1001
|
+
...origin,
|
|
1002
|
+
product_id: product.product_id
|
|
1003
|
+
});
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
const cachedSources = this.store.products?.getRawProductPriceSources?.(products.map(product => Number(product.product_id)));
|
|
1008
|
+
if (cachedSources) sources.push(...cachedSources.values());
|
|
1009
|
+
return sources;
|
|
1010
|
+
}
|
|
963
1011
|
async submitScanOrder() {
|
|
964
1012
|
this.logMethodStart('submitScanOrder');
|
|
965
1013
|
try {
|
|
@@ -982,8 +1030,51 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
|
|
|
982
1030
|
delete tempOrderForSubmit.table_number;
|
|
983
1031
|
}
|
|
984
1032
|
this.store.order.persistTempOrder();
|
|
985
|
-
const
|
|
986
|
-
const
|
|
1033
|
+
const isAdditionalOrder = this.isScanOrderMoreMode(tempOrderForSubmit);
|
|
1034
|
+
const enhanceBookingPayload = this.buildSubmitPayloadEnhancer();
|
|
1035
|
+
const ruleProduct = this.enabledReservationRuleProducts[0];
|
|
1036
|
+
const resource = this.store.resource;
|
|
1037
|
+
const willAppendRuleProduct = !tempOrderForSubmit.order_id && ruleProduct && String(resource?.relationId ?? '').trim() && resource?.tableFormId;
|
|
1038
|
+
const productsToPrepare = isAdditionalOrder ? tempOrderForSubmit.products.filter(product => product.metadata?.is_rule !== true) : [...tempOrderForSubmit.products, ...(willAppendRuleProduct ? [{
|
|
1039
|
+
product_id: ruleProduct.id,
|
|
1040
|
+
metadata: {
|
|
1041
|
+
is_rule: true
|
|
1042
|
+
}
|
|
1043
|
+
}] : [])];
|
|
1044
|
+
const associatedMenus = this.otherParams?.dineInConfig?.['menu.associated_menus'];
|
|
1045
|
+
if (!Array.isArray(associatedMenus)) {
|
|
1046
|
+
throw new _menuAvailability.ScanOrderMenuAvailabilityError('SCAN_ORDER_MENU_VALIDATION_FAILED');
|
|
1047
|
+
}
|
|
1048
|
+
const validateMenuAvailability = await (0, _menuAvailability.prepareScanOrderMenuAvailability)({
|
|
1049
|
+
request: this.request,
|
|
1050
|
+
menuIds: associatedMenus.map(menu => menu?.value),
|
|
1051
|
+
timezone: String(this.getPickupTimingContextData('timezone') ?? ''),
|
|
1052
|
+
products: productsToPrepare,
|
|
1053
|
+
productSources: this.getMenuAvailabilityProductSources(tempOrderForSubmit)
|
|
1054
|
+
});
|
|
1055
|
+
const enhancePayload = (payload, context) => {
|
|
1056
|
+
const enhancedPayload = enhanceBookingPayload(payload, context);
|
|
1057
|
+
const originalByUid = new Map(context.tempOrder.products.filter(product => product.metadata?.unique_identification_number).map(product => [String(product.metadata.unique_identification_number), product]));
|
|
1058
|
+
const outgoingProducts = isAdditionalOrder ? (0, _utils.filterProductsForScanOrderMore)(enhancedPayload.products) : enhancedPayload.products;
|
|
1059
|
+
// Serialization strips the prefill marker. Restore it only on validation
|
|
1060
|
+
// copies, by line UID, so a manually added row of the same product stays checked.
|
|
1061
|
+
const validationProducts = outgoingProducts.map(product => {
|
|
1062
|
+
const uid = product.metadata?.unique_identification_number;
|
|
1063
|
+
const original = uid ? originalByUid.get(String(uid)) : undefined;
|
|
1064
|
+
return original?.metadata?.item_rule_prefill === true ? {
|
|
1065
|
+
...product,
|
|
1066
|
+
metadata: {
|
|
1067
|
+
...product.metadata,
|
|
1068
|
+
item_rule_prefill: true
|
|
1069
|
+
}
|
|
1070
|
+
} : product;
|
|
1071
|
+
});
|
|
1072
|
+
// Both checkout and add-on build their payload after async quotation. Check
|
|
1073
|
+
// the actual outgoing lines using a fresh clock, never the draft schedule_date.
|
|
1074
|
+
validateMenuAvailability(validationProducts, this.getMenuAvailabilityProductSources(context.tempOrder));
|
|
1075
|
+
return enhancedPayload;
|
|
1076
|
+
};
|
|
1077
|
+
const result = isAdditionalOrder ? await this.submitScanOrderMore({
|
|
987
1078
|
tempOrder: tempOrderForSubmit,
|
|
988
1079
|
enhancePayload
|
|
989
1080
|
}) : await this.submitSalesOrder({
|
|
@@ -1265,29 +1356,40 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1265
1356
|
if (!Number.isFinite(productId) || targetQuantity <= 0) continue;
|
|
1266
1357
|
if (Number.isNaN(productVariantId)) continue;
|
|
1267
1358
|
const sourceItem = productSourceMap.get((0, _utils.buildProductKey)(productId, productVariantId)) || productSourceMap.get((0, _utils.buildProductKey)(productId, 0)) || null;
|
|
1359
|
+
const sourceTitle = sourceItem?.product_title || sourceItem?.title || sourceItem?.name;
|
|
1360
|
+
const productTitle = typeof sourceTitle === 'string' ? {
|
|
1361
|
+
auto: sourceTitle
|
|
1362
|
+
} : sourceTitle;
|
|
1363
|
+
// 标准标题在归一化后补入,供购物车展示,并由 Order 在折扣重算时保留。
|
|
1364
|
+
const displayFields = productTitle ? {
|
|
1365
|
+
product_title: productTitle
|
|
1366
|
+
} : {};
|
|
1268
1367
|
const productIndex = (0, _utils.getProductIdentityIndex)(tempOrder.products, {
|
|
1269
1368
|
product_id: productId,
|
|
1270
1369
|
product_variant_id: productVariantId
|
|
1271
1370
|
});
|
|
1272
1371
|
if (productIndex === -1) {
|
|
1273
1372
|
const sellingPrice = (0, _utils.toPriceString)(sourceItem?.price ?? sourceItem?.selling_price, '0.00');
|
|
1274
|
-
tempOrder.products.push(
|
|
1275
|
-
...
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1373
|
+
tempOrder.products.push({
|
|
1374
|
+
...(0, _utils.normalizeOrderProduct)({
|
|
1375
|
+
...sourceItem,
|
|
1376
|
+
product_id: productId,
|
|
1377
|
+
product_variant_id: productVariantId,
|
|
1378
|
+
num: targetQuantity,
|
|
1379
|
+
selling_price: sellingPrice,
|
|
1380
|
+
original_price: sellingPrice,
|
|
1381
|
+
metadata: {
|
|
1382
|
+
item_rule_prefill: true,
|
|
1383
|
+
item_rule_id: prefillItem.ruleId
|
|
1384
|
+
},
|
|
1385
|
+
_origin: {
|
|
1386
|
+
...(sourceItem || {}),
|
|
1387
|
+
item_rule_prefill: true,
|
|
1388
|
+
item_rule_id: prefillItem.ruleId
|
|
1389
|
+
}
|
|
1390
|
+
}),
|
|
1391
|
+
...displayFields
|
|
1392
|
+
});
|
|
1291
1393
|
hasChanges = true;
|
|
1292
1394
|
continue;
|
|
1293
1395
|
}
|
|
@@ -1296,6 +1398,7 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1296
1398
|
const delta = targetQuantity - existedQuantity;
|
|
1297
1399
|
const nextProduct = {
|
|
1298
1400
|
...targetProduct,
|
|
1401
|
+
...displayFields,
|
|
1299
1402
|
...(delta > 0 ? {
|
|
1300
1403
|
num: (0, _utils.getSafeProductNum)(existedQuantity + delta)
|
|
1301
1404
|
} : {}),
|
|
@@ -1310,8 +1413,9 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1310
1413
|
} : targetProduct._origin
|
|
1311
1414
|
};
|
|
1312
1415
|
const hasQuantityChanged = delta > 0;
|
|
1416
|
+
const hasTitleChanged = Boolean(productTitle && JSON.stringify(targetProduct.product_title) !== JSON.stringify(productTitle));
|
|
1313
1417
|
const hasOriginChanged = Boolean(sourceItem && (!targetProduct._origin || targetProduct._origin?.name !== sourceItem?.name || targetProduct._origin?.title !== sourceItem?.title || targetProduct._origin?.price !== sourceItem?.price));
|
|
1314
|
-
if (hasQuantityChanged || hasOriginChanged) {
|
|
1418
|
+
if (hasQuantityChanged || hasTitleChanged || hasOriginChanged) {
|
|
1315
1419
|
tempOrder.products[productIndex] = nextProduct;
|
|
1316
1420
|
hasChanges = true;
|
|
1317
1421
|
}
|
|
@@ -2045,6 +2149,11 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
|
|
|
2045
2149
|
tempOrder.resource_id = normalizedResourceId;
|
|
2046
2150
|
tempOrder.relation_id = (0, _utils.toPositiveString)(occupyDetail?.form_record_id) || normalizedResourceId || tempOrder.relation_id;
|
|
2047
2151
|
tempOrder.table_form_id = (0, _utils.toPositiveString)(occupyDetail?.form_id) || tempOrder.table_form_id;
|
|
2152
|
+
// 冲突后转加餐需同步模式,否则重试仍会携带整单数据走 checkout。
|
|
2153
|
+
const resourceState = this.store.resource ?? this.normalizeResourceState(occupyDetail, resourceSelectType, true);
|
|
2154
|
+
resourceState.mode = 'additional_order';
|
|
2155
|
+
resourceState.order_id = result.order_id;
|
|
2156
|
+
this.store.resource = resourceState;
|
|
2048
2157
|
this.store.order?.persistTempOrder();
|
|
2049
2158
|
this.logMethodSuccess('syncAdditionalOrderFromResource', {
|
|
2050
2159
|
...result,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
type Product = Record<string, any>;
|
|
2
|
+
type Request = {
|
|
3
|
+
get: (url: string, data?: any, options?: any) => Promise<any>;
|
|
4
|
+
post: (url: string, data?: any, options?: any) => Promise<any>;
|
|
5
|
+
};
|
|
6
|
+
export type ScanOrderMenuAvailabilityErrorCode = 'SCAN_ORDER_MENU_UNAVAILABLE' | 'SCAN_ORDER_MENU_VALIDATION_FAILED';
|
|
7
|
+
export declare class ScanOrderMenuAvailabilityError extends Error {
|
|
8
|
+
readonly code: ScanOrderMenuAvailabilityErrorCode;
|
|
9
|
+
readonly productIds: number[];
|
|
10
|
+
constructor(code: ScanOrderMenuAvailabilityErrorCode, productIds?: number[]);
|
|
11
|
+
}
|
|
12
|
+
export type ScanOrderMenuAvailabilityValidator = (products: Product[], productSources?: Product[]) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Prepare fresh menu definitions without changing ProductList or the cart. The
|
|
15
|
+
* returned validator reads the shop's current time again at the submission boundary.
|
|
16
|
+
*/
|
|
17
|
+
export declare function prepareScanOrderMenuAvailability({ request, menuIds, timezone, products, productSources, }: {
|
|
18
|
+
request: Request;
|
|
19
|
+
menuIds: Array<number | string>;
|
|
20
|
+
timezone: string;
|
|
21
|
+
products: Product[];
|
|
22
|
+
productSources?: Product[];
|
|
23
|
+
}): Promise<ScanOrderMenuAvailabilityValidator>;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ScanOrderMenuAvailabilityError = void 0;
|
|
7
|
+
exports.prepareScanOrderMenuAvailability = prepareScanOrderMenuAvailability;
|
|
8
|
+
var _utils = require("../ShopDiscount/utils");
|
|
9
|
+
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
class ScanOrderMenuAvailabilityError extends Error {
|
|
12
|
+
code;
|
|
13
|
+
productIds;
|
|
14
|
+
constructor(code, productIds = []) {
|
|
15
|
+
super(code);
|
|
16
|
+
this.name = 'ScanOrderMenuAvailabilityError';
|
|
17
|
+
this.code = code;
|
|
18
|
+
this.productIds = [...new Set(productIds)];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.ScanOrderMenuAvailabilityError = ScanOrderMenuAvailabilityError;
|
|
22
|
+
const positiveId = value => {
|
|
23
|
+
const id = Number(value);
|
|
24
|
+
return Number.isInteger(id) && id > 0 ? id : undefined;
|
|
25
|
+
};
|
|
26
|
+
const productId = product => positiveId(product?.product_id ?? product?.id);
|
|
27
|
+
const fail = (ids = []) => {
|
|
28
|
+
throw new ScanOrderMenuAvailabilityError('SCAN_ORDER_MENU_VALIDATION_FAILED', ids);
|
|
29
|
+
};
|
|
30
|
+
function readList(response) {
|
|
31
|
+
if (!response || response.code !== undefined && Number(response.code) !== 200 || response.status === false || typeof response.status === 'number' && response.status >= 400 || response.success === false || !Array.isArray(response.data?.list)) fail();
|
|
32
|
+
return response.data.list;
|
|
33
|
+
}
|
|
34
|
+
function readIds(values) {
|
|
35
|
+
if (!Array.isArray(values)) return fail();
|
|
36
|
+
const ids = values.map(positiveId);
|
|
37
|
+
if (ids.some(id => id === undefined)) return fail();
|
|
38
|
+
return [...new Set(ids)];
|
|
39
|
+
}
|
|
40
|
+
function readMenu(record) {
|
|
41
|
+
const scope = record.partyroom_package?.type;
|
|
42
|
+
if (!['product_all', 'products', 'product_collection'].includes(scope)) return fail();
|
|
43
|
+
const items = record.partyroom_package?.products;
|
|
44
|
+
if (scope !== 'product_all' && !Array.isArray(items)) return fail();
|
|
45
|
+
return {
|
|
46
|
+
id: positiveId(record.form_record_id),
|
|
47
|
+
scheduleIds: readIds(record.schedule),
|
|
48
|
+
scope,
|
|
49
|
+
productIds: scope === 'products' ? readIds(items.map(item => item.product_id)) : [],
|
|
50
|
+
collectionIds: scope === 'product_collection' ? readIds(items.map(item => item.product_collection_id)) : []
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function validateSchedule(schedule) {
|
|
54
|
+
const validDate = value => typeof value === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(value) && (0, _dayjs.default)(value).isValid() && (0, _dayjs.default)(value).format('YYYY-MM-DD') === value;
|
|
55
|
+
const validDateTime = value => typeof value === 'string' && /^\d{4}-\d{2}-\d{2}(?:[ T](?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d)?)?$/.test(value) && validDate(value.slice(0, 10)) && (0, _dayjs.default)(value).isValid();
|
|
56
|
+
const validTime = value => typeof value === 'string' && /^(?:(?:[01]\d|2[0-3]):[0-5]\d|24:00)$/.test(value);
|
|
57
|
+
if (!schedule || !['standard', 'time-slots', 'designation'].includes(schedule.type)) return fail();
|
|
58
|
+
if (schedule.type === 'designation') {
|
|
59
|
+
if (!Array.isArray(schedule.designation) || schedule.designation.some(item => !validDate(item?.start_date) || !validDate(item?.end_date) || !validTime(item?.start_time) || !validTime(item?.end_time))) return fail();
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (!validDateTime(schedule.start_time)) return fail();
|
|
63
|
+
if (schedule.type === 'standard' && !validDateTime(schedule.end_time)) return fail();
|
|
64
|
+
if (schedule.type === 'time-slots' && (!Array.isArray(schedule.time_slot) || schedule.time_slot.some(slot => !validTime(slot?.start_time) || !validTime(slot?.end_time)))) return fail();
|
|
65
|
+
if (schedule.repeat_type === 'none') return;
|
|
66
|
+
if (!['daily', 'weekly'].includes(schedule.repeat_type)) return fail();
|
|
67
|
+
const rule = schedule.repeat_rule;
|
|
68
|
+
if (!rule || !positiveId(rule.frequency) || !['never', 'date', 'occurrence'].includes(rule.end?.type) || rule.end.type === 'date' && !validDateTime(rule.end.end_date)) return fail();
|
|
69
|
+
for (const ranges of [rule.excluded_date, rule.included_date ?? []]) {
|
|
70
|
+
if (!Array.isArray(ranges) || ranges.some(range => !validDateTime(range?.start) || !validDateTime(range?.end))) return fail();
|
|
71
|
+
}
|
|
72
|
+
if (schedule.repeat_type === 'weekly' && (!Array.isArray(rule.frequency_date) || rule.frequency_date.some(day => typeof day !== 'number' || !Number.isInteger(day) || day < 0 || day > 6))) return fail();
|
|
73
|
+
}
|
|
74
|
+
function createShopClock(timezone) {
|
|
75
|
+
if (typeof timezone !== 'string' || !timezone.trim()) return fail();
|
|
76
|
+
const formatter = new Intl.DateTimeFormat('en-GB', {
|
|
77
|
+
timeZone: timezone.trim(),
|
|
78
|
+
year: 'numeric',
|
|
79
|
+
month: '2-digit',
|
|
80
|
+
day: '2-digit',
|
|
81
|
+
hour: '2-digit',
|
|
82
|
+
minute: '2-digit',
|
|
83
|
+
second: '2-digit',
|
|
84
|
+
hourCycle: 'h23'
|
|
85
|
+
});
|
|
86
|
+
return () => {
|
|
87
|
+
const parts = formatter.formatToParts(new Date());
|
|
88
|
+
const value = type => parts.find(part => part.type === type)?.value;
|
|
89
|
+
return `${value('year')}-${value('month')}-${value('day')} ${value('hour')}:${value('minute')}:${value('second')}`;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function collectSources(target, sources) {
|
|
93
|
+
for (const source of sources) {
|
|
94
|
+
const id = productId(source);
|
|
95
|
+
if (!id || !Array.isArray(source?.collection)) continue;
|
|
96
|
+
const ids = source.collection.map(item => positiveId(item?.id));
|
|
97
|
+
if (ids.every(value => value !== undefined)) {
|
|
98
|
+
target.set(id, [...new Set(ids)]);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Prepare fresh menu definitions without changing ProductList or the cart. The
|
|
105
|
+
* returned validator reads the shop's current time again at the submission boundary.
|
|
106
|
+
*/
|
|
107
|
+
async function prepareScanOrderMenuAvailability({
|
|
108
|
+
request,
|
|
109
|
+
menuIds,
|
|
110
|
+
timezone,
|
|
111
|
+
products,
|
|
112
|
+
productSources = []
|
|
113
|
+
}) {
|
|
114
|
+
const initialIds = products.map(productId).filter(id => id !== undefined);
|
|
115
|
+
try {
|
|
116
|
+
const now = createShopClock(timezone);
|
|
117
|
+
const configuredIds = readIds(menuIds);
|
|
118
|
+
const [menuResponse, scheduleResponse] = await Promise.all([request.get('/form/data/v1', {
|
|
119
|
+
skip: 1,
|
|
120
|
+
num: 999,
|
|
121
|
+
code: 'menu_list'
|
|
122
|
+
}, {
|
|
123
|
+
useCache: false
|
|
124
|
+
}), request.get('/schedule', {
|
|
125
|
+
num: 999
|
|
126
|
+
}, {
|
|
127
|
+
useCache: false
|
|
128
|
+
})]);
|
|
129
|
+
const menuRecords = readList(menuResponse);
|
|
130
|
+
const scheduleRecords = readList(scheduleResponse);
|
|
131
|
+
const menuById = new Map(menuRecords.map(menu => [positiveId(menu.form_record_id), menu]));
|
|
132
|
+
const menus = configuredIds.map(id => {
|
|
133
|
+
const record = menuById.get(id);
|
|
134
|
+
return record ? readMenu(record) : fail();
|
|
135
|
+
});
|
|
136
|
+
const scheduleById = new Map(scheduleRecords.map(schedule => [positiveId(schedule.id), schedule]));
|
|
137
|
+
// Only configured menus and their schedules are required. Other pages in a
|
|
138
|
+
// larger catalog cannot affect this business's menu availability.
|
|
139
|
+
const referencedScheduleIds = menus.reduce((ids, menu) => ids.concat(menu.scheduleIds), []);
|
|
140
|
+
for (const id of new Set(referencedScheduleIds)) {
|
|
141
|
+
validateSchedule(scheduleById.get(id));
|
|
142
|
+
}
|
|
143
|
+
const hasCollectionMenu = menus.some(menu => menu.scope === 'product_collection');
|
|
144
|
+
const collectionsByProduct = new Map();
|
|
145
|
+
collectSources(collectionsByProduct, [...products, ...productSources]);
|
|
146
|
+
if (hasCollectionMenu) {
|
|
147
|
+
const missingIds = [...new Set(initialIds.filter(id => !collectionsByProduct.has(id)))];
|
|
148
|
+
if (missingIds.length) {
|
|
149
|
+
const response = await request.post('/product/query', {
|
|
150
|
+
ids: missingIds,
|
|
151
|
+
with: ['collection'],
|
|
152
|
+
open_quotation: 0,
|
|
153
|
+
open_bundle: 0,
|
|
154
|
+
skip: 1,
|
|
155
|
+
num: missingIds.length
|
|
156
|
+
}, {
|
|
157
|
+
useCache: false
|
|
158
|
+
});
|
|
159
|
+
collectSources(collectionsByProduct, readList(response));
|
|
160
|
+
const unresolved = missingIds.filter(id => !collectionsByProduct.has(id));
|
|
161
|
+
if (unresolved.length) fail(unresolved);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return (currentProducts, currentSources = []) => {
|
|
165
|
+
try {
|
|
166
|
+
const currentTime = now();
|
|
167
|
+
const collections = new Map(collectionsByProduct);
|
|
168
|
+
collectSources(collections, [...currentProducts, ...currentSources]);
|
|
169
|
+
const unavailable = [];
|
|
170
|
+
const insufficient = [];
|
|
171
|
+
for (const product of currentProducts) {
|
|
172
|
+
const id = productId(product);
|
|
173
|
+
if (!id) return fail();
|
|
174
|
+
const matchesDirectly = menu => menu.scope === 'product_all' || menu.scope === 'products' && menu.productIds.includes(id);
|
|
175
|
+
const isAvailable = menu => (0, _utils.getDateIsInSchedule)(currentTime, menu.scheduleIds.map(scheduleId => scheduleById.get(scheduleId)));
|
|
176
|
+
// A known valid direct relation is sufficient regardless of missing
|
|
177
|
+
// collection data on a rule product appended after preparation.
|
|
178
|
+
if (menus.some(menu => matchesDirectly(menu) && isAvailable(menu))) continue;
|
|
179
|
+
if (hasCollectionMenu && !collections.has(id)) {
|
|
180
|
+
insufficient.push(id);
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
const productCollections = collections.get(id) || [];
|
|
184
|
+
const associated = menus.filter(menu => matchesDirectly(menu) || menu.scope === 'product_collection' && menu.collectionIds.some(collectionId => productCollections.includes(collectionId)));
|
|
185
|
+
if (associated.some(isAvailable)) continue;
|
|
186
|
+
const systemItem = product.metadata?.item_rule_prefill === true || product.metadata?.is_rule === true;
|
|
187
|
+
if (associated.length === 0 && systemItem) continue;
|
|
188
|
+
unavailable.push(id);
|
|
189
|
+
}
|
|
190
|
+
if (insufficient.length) fail(insufficient);
|
|
191
|
+
if (unavailable.length) {
|
|
192
|
+
throw new ScanOrderMenuAvailabilityError('SCAN_ORDER_MENU_UNAVAILABLE', unavailable);
|
|
193
|
+
}
|
|
194
|
+
} catch (error) {
|
|
195
|
+
if (error instanceof ScanOrderMenuAvailabilityError) throw error;
|
|
196
|
+
return fail(currentProducts.map(productId).filter(id => id !== undefined));
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
} catch (error) {
|
|
200
|
+
if (error instanceof ScanOrderMenuAvailabilityError) throw error;
|
|
201
|
+
return fail(initialIds);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { OrderModule, ProductList, SalesSummaryModule, ScanOrderLogInput, ScanOrderLoggerModule, ScanOrderLoggerProviderConfig, ScanOrderLoggerProviderType, ScheduleModule } from '../../modules';
|
|
2
2
|
import type { QuantityCheckResult, QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
|
|
3
|
+
import type { OrderLocalizedText } from '../../modules/Order/types';
|
|
3
4
|
/**
|
|
4
5
|
* 扫码下单流程 hook
|
|
5
6
|
*/
|
|
@@ -43,6 +44,8 @@ export interface ScanOrderProductSku {
|
|
|
43
44
|
}
|
|
44
45
|
export interface ScanOrderOrderProduct extends ScanOrderOrderProductIdentity {
|
|
45
46
|
order_detail_id: number | null;
|
|
47
|
+
/** 与 Order 一致的商品展示名称。 */
|
|
48
|
+
product_title?: OrderLocalizedText;
|
|
46
49
|
num: number;
|
|
47
50
|
/** Product 或当前 Variant 的生产编码 */
|
|
48
51
|
production_code?: string;
|
|
@@ -5,10 +5,12 @@ import type { AddProductDecideContext } from '../BookingTicket/utils/addProductD
|
|
|
5
5
|
import { type InvoiceLayoutConfig, type InvoiceTemplateSettings, type OpenDataConfig, type ResolvedSalesSettings } from '../../modules/OpenData';
|
|
6
6
|
import type { LoadScheduleAvailableDateParams, ScheduleItem } from '../../modules/Schedule/types';
|
|
7
7
|
import type { ProductListLoadProductsParams, ProductListStoreQueryParams } from '../../modules/ProductList';
|
|
8
|
-
import type { AvailabilityDateRange, AvailabilityOccupancy, AvailabilityProduct, AvailabilityResource, GetProductTimeRangesRequest } from '../../modules/ResourcePlanner';
|
|
9
|
-
import type { AvailabilityContextRef, ContextualAvailabilityQuery, ContextualAvailabilityQueryResult, ContextualCommitAvailabilitySelectionParams, ContextualProductTimeRangeGroup, UnifiedBookingSalesAddRetailProductParams, UnifiedBookingSalesCatalogQueryBatch, UnifiedBookingSalesVenueCatalogSession, UnifiedBookingSalesVenueCatalogSessionParams, UnifiedBookingSalesApplyPlannerDiscountsParams, UnifiedBookingSalesCommitAvailabilitySelectionResult, UnifiedBookingSalesDiscountResult, UnifiedBookingSalesLoadProductsByScheduleDateParams, UnifiedBookingSalesLoadOpenDataParams, UnifiedBookingSalesPrepareAvailabilityProjectionParams, UnifiedBookingSalesPolicyResponse, UnifiedBookingSalesQueryBookingResourceDetailsParams, UnifiedBookingSalesResourceDetail, UnifiedBookingSalesResolveProductAllergyRequirementParams, UnifiedBookingSalesStageRetailProductsParams, UnifiedBookingSalesState } from './types';
|
|
8
|
+
import type { AvailabilityDateRange, AvailabilityOccupancy, AvailabilityProduct, AvailabilityRequirementSelection, AvailabilityResource, GetProductTimeRangesRequest } from '../../modules/ResourcePlanner';
|
|
9
|
+
import type { AvailabilityContextRef, ContextualAvailabilityQuery, ContextualAvailabilityQueryResult, ContextualCommitAvailabilitySelectionParams, ContextualProductTimeRange, ContextualProductTimeRangeGroup, UnifiedBookingSalesAddRetailProductParams, UnifiedBookingSalesCatalogQueryBatch, UnifiedBookingSalesVenueCatalogSession, UnifiedBookingSalesVenueCatalogSessionParams, UnifiedBookingSalesApplyPlannerDiscountsParams, UnifiedBookingSalesCommitAvailabilitySelectionResult, UnifiedBookingSalesDiscountResult, UnifiedBookingSalesLoadProductsByScheduleDateParams, UnifiedBookingSalesLoadOpenDataParams, UnifiedBookingSalesPrepareAvailabilityProjectionParams, UnifiedBookingSalesPolicyResponse, UnifiedBookingSalesQueryBookingResourceDetailsParams, UnifiedBookingSalesResourceDetail, UnifiedBookingSalesResolveProductAllergyRequirementParams, UnifiedBookingSalesStageRetailProductsParams, UnifiedBookingSalesState } from './types';
|
|
10
10
|
import type { BusinessAvailability } from '../../modules/BusinessAvailability';
|
|
11
11
|
import { BookingTicket } from '../BookingTicket';
|
|
12
|
+
import type { BaseSalesSubmitSalesOrderParams } from '../BaseSales/types';
|
|
13
|
+
import { type PosReceiptAutoPrintPaymentStatus } from '../../utils/pos-receipt-auto-print';
|
|
12
14
|
import type { AllergyRequirement } from '../../model/strategy/adapter/itemRule';
|
|
13
15
|
export * from './types';
|
|
14
16
|
export * from './salesSettings';
|
|
@@ -97,7 +99,6 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
97
99
|
private allergyItemRuleConfigs;
|
|
98
100
|
private allergyItemRuleConfigsPromise;
|
|
99
101
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
100
|
-
private initializeUnifiedSalesRuntime;
|
|
101
102
|
protected getSubmitOrderSalesChannel(): string;
|
|
102
103
|
/** Only the explicit Kiosk Sales consumer entry enables this policy; POS stays unchanged. */
|
|
103
104
|
protected isBusinessAvailabilityEnabled(): boolean;
|
|
@@ -109,12 +110,30 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
109
110
|
protected getSubModuleHooks(moduleName: string): any;
|
|
110
111
|
private createAvailabilityFacadeError;
|
|
111
112
|
private getAvailabilityScopeDescriptor;
|
|
112
|
-
|
|
113
|
-
private
|
|
114
|
-
private
|
|
113
|
+
private usesDurationTimeGrid;
|
|
114
|
+
private getCurrentAvailabilityBusinessDate;
|
|
115
|
+
private getAvailabilityBusinessDateRange;
|
|
115
116
|
private normalizeAvailabilityIdList;
|
|
116
117
|
private normalizeAvailabilityStringList;
|
|
117
118
|
private normalizeAvailabilityPrepareDescriptor;
|
|
119
|
+
/**
|
|
120
|
+
* 列表直加没有经过 SKU availability flow,legacy cacheItem 的灵活时长可能落到
|
|
121
|
+
* 23:59。提交前用同一套营业排期补齐结束时间,保留已选开始时间、资源和 Holder。
|
|
122
|
+
* 仅供直加调用;手动时间选择和 availability candidate 不经过此方法。
|
|
123
|
+
*/
|
|
124
|
+
prepareDirectAddFlexibleBooking(cacheItem: any): Promise<any>;
|
|
125
|
+
/** Reuse an approved calendar cache; only the final commit may mutate the order. */
|
|
126
|
+
prepareDirectAddCalendarBooking(cacheItem: any, options?: {
|
|
127
|
+
bookingCount?: number;
|
|
128
|
+
availabilityCommitGuard?: () => void;
|
|
129
|
+
}): Promise<{
|
|
130
|
+
cacheItem: any;
|
|
131
|
+
contextId: string;
|
|
132
|
+
candidate: ContextualProductTimeRange;
|
|
133
|
+
requirementSelections: AvailabilityRequirementSelection[];
|
|
134
|
+
partySize: number;
|
|
135
|
+
bookingCount: number;
|
|
136
|
+
} | null>;
|
|
118
137
|
private resolveAvailabilityPrepareDefaults;
|
|
119
138
|
private buildAvailabilityPrepareKey;
|
|
120
139
|
private clearAvailabilityRemoteResourceState;
|
|
@@ -131,9 +150,9 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
131
150
|
private cloneAvailabilityPrepareParams;
|
|
132
151
|
private getAvailabilityDurationCandidateAnchorAt;
|
|
133
152
|
private createAvailabilityContextRef;
|
|
134
|
-
|
|
135
|
-
private
|
|
136
|
-
private
|
|
153
|
+
/** Accept the v2 interval only within the POS order that recorded it. */
|
|
154
|
+
private resolveOrderRememberedTimes;
|
|
155
|
+
private assertRememberedOrderSession;
|
|
137
156
|
private emitAvailabilityDiagnostic;
|
|
138
157
|
private touchAvailabilityContext;
|
|
139
158
|
private touchAvailabilityProjection;
|
|
@@ -160,6 +179,8 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
160
179
|
* 用于支付跳转等终态场景,避免浏览器返回时恢复已提交订单。
|
|
161
180
|
*/
|
|
162
181
|
clearSessionStorageOrderSnapshot(): void;
|
|
182
|
+
/** 在 Kiosk 拉起支付设备前补齐订单号,同一订单重试复用已分配的号码。 */
|
|
183
|
+
ensureLocalOrderNumbersForCheckout(): Promise<void>;
|
|
163
184
|
/**
|
|
164
185
|
* PC/H5 及自助终端结账默认直接等待云端 checkout;POS/WebPOS 仍保持本地待同步。
|
|
165
186
|
* 显式传 checkoutSyncTaskEnabled: true 时仍可回退到本地同步模式。
|
|
@@ -204,6 +225,9 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
204
225
|
protected loadPickupTimingOpenData(_force: boolean): Promise<Record<string, unknown>>;
|
|
205
226
|
private resetAllergyItemRuleState;
|
|
206
227
|
private fetchAllergyItemRuleConfigs;
|
|
228
|
+
/** Required products currently apply only to the online venue-ticket entry. */
|
|
229
|
+
validateRequiredProducts(): Promise<void>;
|
|
230
|
+
submitSalesOrder<T = any>(params?: BaseSalesSubmitSalesOrderParams): Promise<T>;
|
|
207
231
|
private ensureAllergyItemRuleConfigsLoaded;
|
|
208
232
|
/**
|
|
209
233
|
* 评估当前渠道与商品是否命中 ALLERGY_CHECK。
|
|
@@ -213,6 +237,7 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
213
237
|
clearOpenDataCache(): void;
|
|
214
238
|
getInvoiceLayoutConfig(): Promise<InvoiceLayoutConfig>;
|
|
215
239
|
getInvoiceTemplateSettings(): Promise<InvoiceTemplateSettings>;
|
|
240
|
+
protected getPosReceiptAutoPrintPaymentStatuses(): PosReceiptAutoPrintPaymentStatus[] | undefined;
|
|
216
241
|
protected isInvoiceOpenDataCacheCurrent(): boolean;
|
|
217
242
|
/**
|
|
218
243
|
* Load a resource policy without depending on the legacy appointmentBooking solution.
|
|
@@ -354,8 +379,15 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
354
379
|
private assertAvailabilityCommitWriteCAS;
|
|
355
380
|
private findProductLineByUid;
|
|
356
381
|
private findLinkedBooking;
|
|
357
|
-
|
|
382
|
+
removeBookingProductsOutsideStartDate(startDate: unknown): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
383
|
+
/** Revalidates against the latest landed occupancy cache, then mutates exactly one product line. */
|
|
358
384
|
commitAvailabilitySelection(contextId: string, params: ContextualCommitAvailabilitySelectionParams): Promise<UnifiedBookingSalesCommitAvailabilitySelectionResult>;
|
|
359
385
|
private commitAvailabilitySelectionWithLock;
|
|
386
|
+
private initializeUnifiedSalesRuntime;
|
|
387
|
+
private isVenueKioskPlatform;
|
|
388
|
+
private supportsVenueSelectionSnapshot;
|
|
389
|
+
private getSolutionLogContext;
|
|
390
|
+
private writeSolutionLog;
|
|
391
|
+
private logSolutionFailure;
|
|
360
392
|
}
|
|
361
393
|
export declare const UnifiedBookingSales: typeof UnifiedBookingSalesImpl;
|