@pisell/pisellos 0.10.90 → 0.10.91
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
- package/dist/model/strategy/adapter/itemRule/adapter.js +74 -7
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
- package/dist/model/strategy/adapter/itemRule/evaluator.js +13 -0
- package/dist/model/strategy/adapter/itemRule/type.d.ts +40 -1
- package/dist/model/strategy/adapter/itemRule/type.js +10 -0
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +2 -1
- package/dist/model/strategy/adapter/promotion/evaluator.js +103 -112
- package/dist/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
- package/dist/modules/BookingContext/utils/calendarBooking.js +207 -0
- package/dist/modules/BookingContext/utils/index.d.ts +1 -0
- package/dist/modules/BookingContext/utils/index.js +1 -0
- package/dist/modules/BookingContext/utils/productExtend.d.ts +21 -0
- package/dist/modules/BookingContext/utils/productExtend.js +132 -33
- package/dist/modules/BookingContext/utils/resources.js +1 -1
- package/dist/modules/Cart/index.js +4 -3
- package/dist/modules/Cart/types.d.ts +2 -0
- package/dist/modules/Cart/utils/cartProduct.d.ts +3 -1
- package/dist/modules/Cart/utils/cartProduct.js +59 -32
- package/dist/modules/Date/index.d.ts +1 -1
- package/dist/modules/Date/index.js +60 -14
- package/dist/modules/Date/types.d.ts +5 -0
- package/dist/modules/OpenData/salesSettings.js +1 -1
- package/dist/modules/OpenData/types.d.ts +9 -0
- package/dist/modules/OpenData/utils.d.ts +1 -1
- package/dist/modules/OpenData/utils.js +3 -2
- package/dist/modules/Order/index.d.ts +22 -7
- package/dist/modules/Order/index.js +1565 -1161
- package/dist/modules/Order/localEftposState.d.ts +13 -0
- package/dist/modules/Order/localEftposState.js +39 -0
- package/dist/modules/Order/types.d.ts +33 -11
- package/dist/modules/Order/types.js +2 -2
- package/dist/modules/Order/unpaidAmountGap.d.ts +6 -0
- package/dist/modules/Order/unpaidAmountGap.js +72 -0
- package/dist/modules/Order/utils.d.ts +4 -1
- package/dist/modules/Order/utils.js +75 -52
- package/dist/modules/Payment/walletpass.js +32 -6
- package/dist/modules/Product/types.d.ts +16 -0
- package/dist/modules/ProductList/index.js +1 -1
- package/dist/modules/ResourcePlanner/planner.d.ts +2 -0
- package/dist/modules/ResourcePlanner/planner.js +383 -24
- package/dist/modules/ResourcePlanner/types.d.ts +42 -0
- package/dist/modules/Rules/index.js +86 -54
- package/dist/modules/Schedule/index.d.ts +7 -1
- package/dist/modules/Schedule/index.js +155 -39
- package/dist/modules/Schedule/types.d.ts +2 -0
- package/dist/modules/bookingReadValidation.d.ts +6 -0
- package/dist/modules/bookingReadValidation.js +72 -0
- package/dist/plugins/request.d.ts +2 -0
- package/dist/server/index.d.ts +9 -0
- package/dist/server/index.js +1928 -1462
- package/dist/server/modules/form/index.d.ts +19 -0
- package/dist/server/modules/form/index.js +205 -0
- package/dist/server/modules/form/types.d.ts +13 -0
- package/dist/server/modules/form/types.js +3 -0
- package/dist/server/modules/index.d.ts +3 -0
- package/dist/server/modules/index.js +4 -0
- package/dist/server/modules/order/index.d.ts +21 -0
- package/dist/server/modules/order/index.js +1399 -831
- package/dist/server/modules/order/types.d.ts +3 -0
- package/dist/server/modules/order/utils/filterOrders.js +20 -0
- package/dist/server/modules/products/index.d.ts +28 -7
- package/dist/server/modules/products/index.js +1295 -769
- package/dist/server/modules/products/replication.d.ts +8 -0
- package/dist/server/modules/products/replication.js +69 -0
- package/dist/server/modules/products/types.d.ts +12 -1
- package/dist/server/modules/products/types.js +4 -0
- package/dist/shared/receipt/customerInvoiceLanguages.d.ts +1 -1
- package/dist/shared/receipt/customerInvoiceLanguages.js +5 -3
- package/dist/shared/receipt/small-ticket.d.ts +1 -0
- package/dist/shared/receipt/small-ticket.js +58 -26
- package/dist/shared/receipt/templateVisibility.d.ts +3 -0
- package/dist/shared/receipt/templateVisibility.js +6 -2
- package/dist/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
- package/dist/solution/BaseSales/fulfillmentItemRules.js +750 -0
- package/dist/solution/BaseSales/index.d.ts +22 -6
- package/dist/solution/BaseSales/index.js +1881 -1347
- package/dist/solution/BaseSales/pickupTiming.d.ts +4 -0
- package/dist/solution/BaseSales/pickupTiming.js +35 -8
- package/dist/solution/BaseSales/types.d.ts +4 -0
- package/dist/solution/BaseSales/types.js +1 -0
- package/dist/solution/BaseSales/utils/posDurationPricing.d.ts +21 -0
- package/dist/solution/BaseSales/utils/posDurationPricing.js +174 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +2 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +8 -8
- package/dist/solution/BookingByStep/index.d.ts +18 -2
- package/dist/solution/BookingByStep/index.js +681 -361
- package/dist/solution/BookingByStep/utils/resources.d.ts +10 -0
- package/dist/solution/BookingByStep/utils/resources.js +117 -76
- package/dist/solution/BookingTicket/index.d.ts +6 -0
- package/dist/solution/BookingTicket/index.js +666 -593
- package/dist/solution/BookingTicket/types.d.ts +1 -1
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
- package/dist/solution/BookingTicket/utils/addProductDecision.js +35 -8
- package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +3 -3
- package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
- package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.js +188 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +58 -94
- package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +1 -3
- package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +33 -62
- package/dist/solution/OrderInvoicePreview/index.js +4 -3
- package/dist/solution/Sales/index.js +1 -1
- package/dist/solution/ScanOrder/index.d.ts +2 -0
- package/dist/solution/ScanOrder/index.js +230 -97
- package/dist/solution/ScanOrder/menuAvailability.d.ts +24 -0
- package/dist/solution/ScanOrder/menuAvailability.js +363 -0
- package/dist/solution/ScanOrder/types.d.ts +3 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +42 -10
- package/dist/solution/UnifiedBookingSales/index.js +2493 -1496
- package/dist/solution/UnifiedBookingSales/salesSettings.js +1 -1
- package/dist/solution/UnifiedBookingSales/types.d.ts +20 -5
- package/dist/utils/pos-receipt-auto-print.d.ts +4 -0
- package/dist/utils/pos-receipt-auto-print.js +14 -0
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
- package/lib/model/strategy/adapter/itemRule/adapter.js +54 -4
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
- package/lib/model/strategy/adapter/itemRule/evaluator.js +9 -0
- package/lib/model/strategy/adapter/itemRule/type.d.ts +40 -1
- package/lib/model/strategy/adapter/itemRule/type.js +10 -0
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +2 -1
- package/lib/model/strategy/adapter/promotion/evaluator.js +22 -21
- package/lib/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
- package/lib/modules/BookingContext/utils/calendarBooking.js +156 -0
- package/lib/modules/BookingContext/utils/index.d.ts +1 -0
- package/lib/modules/BookingContext/utils/index.js +11 -0
- package/lib/modules/BookingContext/utils/productExtend.d.ts +21 -0
- package/lib/modules/BookingContext/utils/productExtend.js +104 -5
- package/lib/modules/BookingContext/utils/resources.js +1 -1
- package/lib/modules/Cart/index.js +4 -2
- package/lib/modules/Cart/types.d.ts +2 -0
- package/lib/modules/Cart/utils/cartProduct.d.ts +3 -1
- package/lib/modules/Cart/utils/cartProduct.js +39 -20
- package/lib/modules/Date/index.d.ts +1 -1
- package/lib/modules/Date/index.js +28 -5
- package/lib/modules/Date/types.d.ts +5 -0
- package/lib/modules/OpenData/salesSettings.js +1 -1
- package/lib/modules/OpenData/types.d.ts +9 -0
- package/lib/modules/OpenData/utils.d.ts +1 -1
- package/lib/modules/OpenData/utils.js +3 -2
- package/lib/modules/Order/index.d.ts +22 -7
- package/lib/modules/Order/index.js +457 -174
- package/lib/modules/Order/localEftposState.d.ts +13 -0
- package/lib/modules/Order/localEftposState.js +44 -0
- package/lib/modules/Order/types.d.ts +33 -11
- package/lib/modules/Order/types.js +2 -2
- package/lib/modules/Order/unpaidAmountGap.d.ts +6 -0
- package/lib/modules/Order/unpaidAmountGap.js +60 -0
- package/lib/modules/Order/utils.d.ts +4 -1
- package/lib/modules/Order/utils.js +29 -3
- package/lib/modules/Payment/walletpass.js +23 -1
- package/lib/modules/Product/types.d.ts +16 -0
- package/lib/modules/ProductList/index.js +1 -1
- package/lib/modules/ResourcePlanner/planner.d.ts +2 -0
- package/lib/modules/ResourcePlanner/planner.js +299 -9
- package/lib/modules/ResourcePlanner/types.d.ts +42 -0
- package/lib/modules/Rules/index.js +32 -3
- package/lib/modules/Schedule/index.d.ts +7 -1
- package/lib/modules/Schedule/index.js +68 -4
- package/lib/modules/Schedule/types.d.ts +2 -0
- package/lib/modules/bookingReadValidation.d.ts +6 -0
- package/lib/modules/bookingReadValidation.js +56 -0
- package/lib/plugins/request.d.ts +2 -0
- package/lib/server/index.d.ts +9 -0
- package/lib/server/index.js +279 -30
- package/lib/server/modules/form/index.d.ts +19 -0
- package/lib/server/modules/form/index.js +73 -0
- package/lib/server/modules/form/types.d.ts +13 -0
- package/lib/server/modules/form/types.js +9 -0
- package/lib/server/modules/index.d.ts +3 -0
- package/lib/server/modules/index.js +15 -1
- package/lib/server/modules/order/index.d.ts +21 -0
- package/lib/server/modules/order/index.js +344 -35
- package/lib/server/modules/order/types.d.ts +3 -0
- package/lib/server/modules/order/utils/filterOrders.js +18 -0
- package/lib/server/modules/products/index.d.ts +28 -7
- package/lib/server/modules/products/index.js +224 -62
- package/lib/server/modules/products/replication.d.ts +8 -0
- package/lib/server/modules/products/replication.js +30 -0
- package/lib/server/modules/products/types.d.ts +12 -1
- package/lib/server/modules/products/types.js +3 -0
- package/lib/shared/receipt/customerInvoiceLanguages.d.ts +1 -1
- package/lib/shared/receipt/customerInvoiceLanguages.js +5 -3
- package/lib/shared/receipt/small-ticket.d.ts +1 -0
- package/lib/shared/receipt/small-ticket.js +53 -25
- package/lib/shared/receipt/templateVisibility.d.ts +3 -0
- package/lib/shared/receipt/templateVisibility.js +6 -2
- package/lib/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
- package/lib/solution/BaseSales/fulfillmentItemRules.js +259 -0
- package/lib/solution/BaseSales/index.d.ts +22 -6
- package/lib/solution/BaseSales/index.js +347 -59
- package/lib/solution/BaseSales/pickupTiming.d.ts +4 -0
- package/lib/solution/BaseSales/pickupTiming.js +24 -3
- package/lib/solution/BaseSales/types.d.ts +4 -0
- package/lib/solution/BaseSales/types.js +1 -0
- package/lib/solution/BaseSales/utils/posDurationPricing.d.ts +21 -0
- package/lib/solution/BaseSales/utils/posDurationPricing.js +133 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +2 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -1
- package/lib/solution/BookingByStep/index.d.ts +18 -2
- package/lib/solution/BookingByStep/index.js +229 -17
- package/lib/solution/BookingByStep/utils/resources.d.ts +10 -0
- package/lib/solution/BookingByStep/utils/resources.js +25 -15
- package/lib/solution/BookingTicket/index.d.ts +6 -0
- package/lib/solution/BookingTicket/index.js +40 -5
- package/lib/solution/BookingTicket/types.d.ts +1 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.js +34 -4
- package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +3 -3
- package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
- package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.js +136 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +2 -14
- package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +1 -3
- package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +17 -34
- package/lib/solution/OrderInvoicePreview/index.js +1 -0
- package/lib/solution/Sales/index.js +1 -1
- package/lib/solution/ScanOrder/index.d.ts +2 -0
- package/lib/solution/ScanOrder/index.js +131 -22
- package/lib/solution/ScanOrder/menuAvailability.d.ts +24 -0
- package/lib/solution/ScanOrder/menuAvailability.js +203 -0
- package/lib/solution/ScanOrder/types.d.ts +3 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +42 -10
- package/lib/solution/UnifiedBookingSales/index.js +717 -144
- package/lib/solution/UnifiedBookingSales/salesSettings.js +1 -1
- package/lib/solution/UnifiedBookingSales/types.d.ts +20 -5
- package/lib/utils/pos-receipt-auto-print.d.ts +4 -0
- package/lib/utils/pos-receipt-auto-print.js +13 -0
- package/package.json +1 -1
|
@@ -41,6 +41,8 @@ export declare function decideAfterDetail(cacheItem: any, ctx?: AddProductDecide
|
|
|
41
41
|
* @deprecated 请用 `decideAddProduct`;保留兼容:autoClose=true 仅表示可直接加车(action=add)。
|
|
42
42
|
*/
|
|
43
43
|
export interface AddProductRequiresDetailPayload {
|
|
44
|
+
/** Same prepared decision cache supplied to the Host; never a separate Flow preflight. */
|
|
45
|
+
preparedCacheItem?: any;
|
|
44
46
|
item: ProductData | Record<string, any>;
|
|
45
47
|
/** UI 需展示的子弹窗开关。 */
|
|
46
48
|
showConfig: {
|
|
@@ -65,7 +67,6 @@ export interface AddProductDecideContext extends BookingCalcContext {
|
|
|
65
67
|
type?: 'select' | 'detail';
|
|
66
68
|
quantity?: number;
|
|
67
69
|
customerId?: number | string;
|
|
68
|
-
channel?: string;
|
|
69
70
|
}
|
|
70
71
|
/**
|
|
71
72
|
* 统一补齐预约商品的运行态字段。
|
|
@@ -15,6 +15,7 @@ exports.prepareBookingCacheItem = prepareBookingCacheItem;
|
|
|
15
15
|
exports.transformDetailToProductAndBooking = transformDetailToProductAndBooking;
|
|
16
16
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
17
17
|
var _BookingContext = require("../../../modules/BookingContext");
|
|
18
|
+
var _resolveUniqueCartDetail = require("./resolveUniqueCartDetail");
|
|
18
19
|
var _transformBaseProductToOrderProduct = require("../../BaseSales/utils/transformBaseProductToOrderProduct");
|
|
19
20
|
var _weighingProductSku = require("./weighingProductSku");
|
|
20
21
|
var _platform = require("../../../utils/platform");
|
|
@@ -43,6 +44,7 @@ function needsSpecDetailModal(item) {
|
|
|
43
44
|
* 第二段:预约商品是否仍需打开资源 / 时间编辑(自助终端强制打开,其他渠道与 info2 `cacheItem.autoClose` 等价)。
|
|
44
45
|
*/
|
|
45
46
|
function needsBookingEdit(cacheItem, ctx) {
|
|
47
|
+
if ((0, _BookingContext.getCalendarBookingRange)(cacheItem, ctx)) return (0, _BookingContext.calendarBookingNeedsInput)(cacheItem);
|
|
46
48
|
if (isNormalBookingProduct(cacheItem)) return false;
|
|
47
49
|
if ((0, _platform.isSelfServicePlatform)(ctx?.channel)) return true;
|
|
48
50
|
const isAutoAllocationOn = ctx?.isAutoAllocationOn || (() => true);
|
|
@@ -61,13 +63,26 @@ function buildRequiresBookingEditPayload(cacheItem, ctx) {
|
|
|
61
63
|
*/
|
|
62
64
|
function decideAddProduct(item, ctx) {
|
|
63
65
|
const derivedCtx = withDerivedBookingCtx(ctx);
|
|
64
|
-
|
|
66
|
+
const calendarRange = (0, _BookingContext.getCalendarBookingRange)(item, derivedCtx);
|
|
67
|
+
const uniqueValue = calendarRange ? (0, _resolveUniqueCartDetail.resolveUniqueCartDetailValue)(item) : null;
|
|
68
|
+
const selectedItem = uniqueValue ? {
|
|
69
|
+
...item,
|
|
70
|
+
cartDetailValue: uniqueValue,
|
|
71
|
+
isOpenDetailModal: false
|
|
72
|
+
} : item;
|
|
73
|
+
if (needsSpecDetailModal(selectedItem)) {
|
|
74
|
+
const preparedCacheItem = calendarRange ? prepareBookingCacheItem(buildCacheItemFromCartDetail(item, derivedCtx), derivedCtx) : undefined;
|
|
65
75
|
return {
|
|
66
76
|
action: 'requiresDetail',
|
|
67
|
-
payload:
|
|
77
|
+
payload: {
|
|
78
|
+
...buildRequiresDetailPayload(item, derivedCtx),
|
|
79
|
+
...(preparedCacheItem ? {
|
|
80
|
+
preparedCacheItem
|
|
81
|
+
} : {})
|
|
82
|
+
}
|
|
68
83
|
};
|
|
69
84
|
}
|
|
70
|
-
const cacheItem = prepareBookingCacheItem(buildCacheItemFromCartDetail(
|
|
85
|
+
const cacheItem = prepareBookingCacheItem(buildCacheItemFromCartDetail(selectedItem, derivedCtx), derivedCtx);
|
|
71
86
|
if (needsBookingEdit(cacheItem, derivedCtx)) {
|
|
72
87
|
return {
|
|
73
88
|
action: 'requiresBookingEdit',
|
|
@@ -147,7 +162,22 @@ function isMultiDayLike(cacheItem) {
|
|
|
147
162
|
* `_extend.resource / capacity / startDate / endDate` 等后续 booking mapper 需要的字段。
|
|
148
163
|
*/
|
|
149
164
|
function prepareBookingCacheItem(cacheItem, ctx) {
|
|
150
|
-
if (
|
|
165
|
+
if ((0, _BookingContext.getCalendarBookingRange)(cacheItem, ctx)) {
|
|
166
|
+
if (cacheItem._data?.calendarBookingPreparationKey === (0, _BookingContext.calendarBookingPreparationKey)(cacheItem, ctx)) return cacheItem;
|
|
167
|
+
return (0, _BookingContext.getProductExtend)({
|
|
168
|
+
cacheItem,
|
|
169
|
+
ctx: ctx,
|
|
170
|
+
isDisabledTime: true
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
if (ctx?.bookingTimeRangeFromCalendar && (cacheItem.duration?.type === 'days' || cacheItem.duration_type === 'days' || cacheItem._extend?.sub_type === 'days')) {
|
|
174
|
+
ctx = {
|
|
175
|
+
...ctx,
|
|
176
|
+
bookingTimeRangeFromCalendar: undefined,
|
|
177
|
+
resourceIdFromCalendar: undefined
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
if (ctx?.rememberedTime === undefined && (isNormalBookingProduct(cacheItem) || hasPreparedBookingExtend(cacheItem))) {
|
|
151
181
|
return cacheItem;
|
|
152
182
|
}
|
|
153
183
|
return (0, _BookingContext.getProductExtend)({
|
|
@@ -30,6 +30,9 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
|
|
|
30
30
|
holder: Record<string, any> | null;
|
|
31
31
|
relation_forms: any[];
|
|
32
32
|
holder_relations?: import("../../../modules/Order/types").OrderHolderRelation[] | undefined;
|
|
33
|
+
phone: string;
|
|
34
|
+
email: string;
|
|
35
|
+
contacts_info: Record<string, any> | null;
|
|
33
36
|
order_id: number | null;
|
|
34
37
|
external_sale_number: string;
|
|
35
38
|
order_number: string | null;
|
|
@@ -43,8 +46,6 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
|
|
|
43
46
|
customer_id: number | null;
|
|
44
47
|
customer_name: string;
|
|
45
48
|
country_calling_code: string;
|
|
46
|
-
phone: string;
|
|
47
|
-
email: string;
|
|
48
49
|
is_price_include_tax: number;
|
|
49
50
|
tax_title: string;
|
|
50
51
|
tax_country_code: string;
|
|
@@ -61,7 +62,6 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
|
|
|
61
62
|
schedule_date: string;
|
|
62
63
|
bookings: any[];
|
|
63
64
|
payments: any[];
|
|
64
|
-
contacts_info: Record<string, any> | null;
|
|
65
65
|
order_meta_list?: import("../../../modules/Order/types").OrderMetaList | undefined;
|
|
66
66
|
refunds?: any[] | undefined;
|
|
67
67
|
surcharges: any[];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type RecordValue = Record<string, any>;
|
|
2
|
+
/**
|
|
3
|
+
* Resolve a whole SKU only when the original configuration proves one legal
|
|
4
|
+
* result. A default, a stock-filtered remainder, or missing detail is not proof
|
|
5
|
+
* of uniqueness. The input product and its existing selections stay untouched.
|
|
6
|
+
*/
|
|
7
|
+
export declare function resolveUniqueCartDetailValue(product: RecordValue): RecordValue | null;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.resolveUniqueCartDetailValue = resolveUniqueCartDetailValue;
|
|
7
|
+
const flag = value => value === true || value === 1 || value === '1';
|
|
8
|
+
const cleared = value => value === false || value === 0 || value === '0';
|
|
9
|
+
const enabled = item => item && !flag(item.disabled) && !cleared(item.is_enabled) && item.deleted_at == null;
|
|
10
|
+
const sellable = item => enabled(item) && (!flag(item.is_track) || flag(item.over_sold) || Number(item.stock_quantity) > 0);
|
|
11
|
+
const bound = (value, fallback = 0) => {
|
|
12
|
+
if (value == null || value === '') return fallback;
|
|
13
|
+
if (typeof value !== 'number' && typeof value !== 'string') return null;
|
|
14
|
+
const number = Number(value);
|
|
15
|
+
return Number.isInteger(number) && number >= 0 ? number : null;
|
|
16
|
+
};
|
|
17
|
+
const validId = value => (typeof value === 'number' || typeof value === 'string') && Number.isSafeInteger(Number(value)) && Number(value) > 0;
|
|
18
|
+
|
|
19
|
+
/** A choice is unique only if its complete allowed quantity interval is one value. */
|
|
20
|
+
function fixedQuantity(minimums, maximums) {
|
|
21
|
+
const min = Math.max(1, ...minimums);
|
|
22
|
+
const max = Math.min(...maximums.filter(value => value > 0), Infinity);
|
|
23
|
+
return min === max ? min : null;
|
|
24
|
+
}
|
|
25
|
+
function configuredGroups(product, key, countKey) {
|
|
26
|
+
const groups = product[key];
|
|
27
|
+
if (groups == null && product[countKey] == null) return null;
|
|
28
|
+
const count = bound(product[countKey]);
|
|
29
|
+
if (count == null || groups != null && !Array.isArray(groups)) return null;
|
|
30
|
+
if (count > 0 && (!Array.isArray(groups) || groups.length !== count)) return null;
|
|
31
|
+
return groups || [];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Resolve a whole SKU only when the original configuration proves one legal
|
|
36
|
+
* result. A default, a stock-filtered remainder, or missing detail is not proof
|
|
37
|
+
* of uniqueness. The input product and its existing selections stay untouched.
|
|
38
|
+
*/
|
|
39
|
+
function resolveUniqueCartDetailValue(product) {
|
|
40
|
+
if (!product || !validId(product.id ?? product.product_id) || flag(product.open_sold_weight)) return null;
|
|
41
|
+
const productId = product.id ?? product.product_id;
|
|
42
|
+
const existing = product.cartDetailValue;
|
|
43
|
+
const hasConfiguredSku = flag(product.is_variant) || Number(product.variant_count) > 0 || Number(product.option_group_count) > 0 || Number(product.bundle_group_count) > 0 || product.option_group?.length > 0 || product.bundle_group?.length > 0 || product.bundle_groups?.length > 0 || product.variant_group?.length > 0;
|
|
44
|
+
if (existing && !hasConfiguredSku && !(existing.option?.length || existing.bundle?.length)) {
|
|
45
|
+
return {
|
|
46
|
+
...existing,
|
|
47
|
+
product_id: productId,
|
|
48
|
+
quantity: 1
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const knowsVariantShape = cleared(product.is_variant) || product.variant_count === 0 || product.variant_count === '0' || Array.isArray(product.variant) || Array.isArray(product.variant_group);
|
|
52
|
+
if (!knowsVariantShape) return null;
|
|
53
|
+
const optionGroups = configuredGroups(product, 'option_group', 'option_group_count');
|
|
54
|
+
const bundleKey = product.bundle_group != null ? 'bundle_group' : 'bundle_groups';
|
|
55
|
+
const bundleGroups = configuredGroups(product, bundleKey, 'bundle_group_count');
|
|
56
|
+
if (!optionGroups || !bundleGroups) return null;
|
|
57
|
+
const value = {
|
|
58
|
+
...(product.cartDetailValue || {}),
|
|
59
|
+
product_id: productId,
|
|
60
|
+
product_variant_id: 0,
|
|
61
|
+
option: [],
|
|
62
|
+
bundle: [],
|
|
63
|
+
quantity: 1
|
|
64
|
+
};
|
|
65
|
+
const hasVariant = flag(product.is_variant) || Number(product.variant_count) > 0 || Array.isArray(product.variant_group) && product.variant_group.length > 0 || Array.isArray(product.variant) && product.variant.length > 0;
|
|
66
|
+
if (hasVariant) {
|
|
67
|
+
if (!Array.isArray(product.variant) || product.variant.length !== 1 || Number(product.variant_count) > 0 && Number(product.variant_count) !== 1) return null;
|
|
68
|
+
const [variant] = product.variant;
|
|
69
|
+
if (!validId(variant?.id) || !sellable(variant)) return null;
|
|
70
|
+
value.product_variant_id = variant.id;
|
|
71
|
+
if (variant.price == null || variant.price === '' || !Number.isFinite(Number(variant.price)) || Number(variant.price) < 0) return null;
|
|
72
|
+
value.price = variant.price;
|
|
73
|
+
value.production_code = variant.production_code ?? variant.code ?? '';
|
|
74
|
+
}
|
|
75
|
+
for (const group of optionGroups) {
|
|
76
|
+
// Do not silently remove configured alternatives that are disabled or out of stock.
|
|
77
|
+
if (!validId(group?.id) || !enabled(group) || !Array.isArray(group.option_item) || group.option_item.length !== 1) return null;
|
|
78
|
+
const [item] = group.option_item;
|
|
79
|
+
if (!validId(item?.id) || !sellable(item)) return null;
|
|
80
|
+
const multiple = flag(group.is_multiple);
|
|
81
|
+
const groupMin = bound(group.min_quantity);
|
|
82
|
+
const groupMax = bound(group.max_quantity);
|
|
83
|
+
const itemMin = bound(item.min_quantity);
|
|
84
|
+
const itemMax = bound(item.max_quantity, 1);
|
|
85
|
+
if ([groupMin, groupMax, itemMin, itemMax].some(value => value == null)) return null;
|
|
86
|
+
const advanced = multiple && flag(group.metadata?.advanced_settings_enabled);
|
|
87
|
+
const minTypes = advanced ? bound(group.metadata?.option_types_config?.min) : 0;
|
|
88
|
+
const maxTypes = advanced ? bound(group.metadata?.option_types_config?.max) : 0;
|
|
89
|
+
if (minTypes == null || maxTypes == null || minTypes > 1 || maxTypes > 0 && maxTypes < minTypes) return null;
|
|
90
|
+
const required = multiple ? groupMin > 0 || minTypes > 0 : flag(group.required);
|
|
91
|
+
if (!required) return null;
|
|
92
|
+
const quantity = fixedQuantity([itemMin, ...(multiple ? [groupMin] : [])], [itemMax, ...(multiple ? [groupMax] : [])]);
|
|
93
|
+
if (!quantity) return null;
|
|
94
|
+
const price = item.price ?? item.add_price ?? 0;
|
|
95
|
+
value.option.push({
|
|
96
|
+
...item,
|
|
97
|
+
id: item.id,
|
|
98
|
+
product_option_item_id: item.id,
|
|
99
|
+
option_group_item_id: item.id,
|
|
100
|
+
option_group_id: group.id,
|
|
101
|
+
product_id: productId,
|
|
102
|
+
quantity,
|
|
103
|
+
num: quantity,
|
|
104
|
+
price,
|
|
105
|
+
original_price: price
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
for (const group of bundleGroups) {
|
|
109
|
+
if (!validId(group?.id) || !enabled(group) || !Array.isArray(group.bundle_item) || group.bundle_item.length !== 1) return null;
|
|
110
|
+
const [item] = group.bundle_item;
|
|
111
|
+
if (!validId(item?.id) || !validId(item?.bundle_product_id) || !sellable(item) || item.option_group?.length || item.variant_group?.length || item.variant?.length || item.bundle_group?.length || item.bundle_groups?.length || flag(item.is_variant) || flag(item.open_sold_weight) || Number(item.variant_count) > 0 || Number(item.option_group_count) > 0 || Number(item.bundle_group_count) > 0) return null;
|
|
112
|
+
const groupMin = bound(group.min_quantity);
|
|
113
|
+
const groupMax = bound(group.max_quantity);
|
|
114
|
+
const itemMin = bound(item.min_quantity);
|
|
115
|
+
const itemMax = bound(item.max_quantity);
|
|
116
|
+
if ([groupMin, groupMax, itemMin, itemMax].some(value => value == null) || groupMin <= 0) return null;
|
|
117
|
+
const quantity = fixedQuantity([groupMin, itemMin], [groupMax, itemMax]);
|
|
118
|
+
if (!quantity) return null;
|
|
119
|
+
value.bundle.push({
|
|
120
|
+
...item,
|
|
121
|
+
id: item.id,
|
|
122
|
+
group_id: group.id,
|
|
123
|
+
bundle_group_id: group.id,
|
|
124
|
+
_bundle_product_id: item.bundle_product_id,
|
|
125
|
+
quantity,
|
|
126
|
+
num: quantity,
|
|
127
|
+
option: []
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
const key = [productId, value.product_variant_id, ...value.option.map(item => `o${item.option_group_id}:${item.id}:${item.quantity}`), ...value.bundle.map(item => `b${item.group_id}:${item.id}:${item.quantity}`), ...(value.session ? [`s${value.session.key ?? value.session.id ?? ''}`] : [])].join('_');
|
|
131
|
+
return {
|
|
132
|
+
...value,
|
|
133
|
+
key,
|
|
134
|
+
rowKey: key
|
|
135
|
+
};
|
|
136
|
+
}
|
|
@@ -289,18 +289,6 @@ async function applyGlobalScan(host, formatted, bridge) {
|
|
|
289
289
|
// batch-search 可能返回来源门店客户;先映射到当前门店,确保 Wallet
|
|
290
290
|
// 支付资产查询使用本店客户上下文。
|
|
291
291
|
const bindResult = await bindWalletPassCustomer();
|
|
292
|
-
// Voucher collection prioritizes goods coupons resolved from the wristband/order.
|
|
293
|
-
// Only this opt-in flow checks them before selecting a payment wallet asset.
|
|
294
|
-
const collectionPromotion = bridge?.scanScope === 'product-voucher-collection' && bridge.applyPromotionCode ? await bridge.applyPromotionCode(scanCode, getRealCustomerId(activeCustomer), {
|
|
295
|
-
suppressFailureNotification: true,
|
|
296
|
-
productVouchersOnly: true
|
|
297
|
-
}) : undefined;
|
|
298
|
-
if (collectionPromotion?.isAccepted ?? collectionPromotion?.isAvailable) {
|
|
299
|
-
return {
|
|
300
|
-
status: 'success',
|
|
301
|
-
kind: 'promotion'
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
292
|
const walletSelection = await trySelectWalletAsset();
|
|
305
293
|
if (walletSelection) return walletSelection;
|
|
306
294
|
if (!bridge?.applyPromotionCode) {
|
|
@@ -310,9 +298,9 @@ async function applyGlobalScan(host, formatted, bridge) {
|
|
|
310
298
|
};
|
|
311
299
|
}
|
|
312
300
|
const promotionCustomerId = getRealCustomerId(activeCustomer);
|
|
313
|
-
const promotionResult =
|
|
301
|
+
const promotionResult = bindResult.customerBound ? await bridge.applyPromotionCode(scanCode, promotionCustomerId, {
|
|
314
302
|
suppressFailureNotification: true
|
|
315
|
-
}) : await bridge.applyPromotionCode(scanCode, promotionCustomerId)
|
|
303
|
+
}) : await bridge.applyPromotionCode(scanCode, promotionCustomerId);
|
|
316
304
|
if (promotionResult?.isAccepted ?? promotionResult?.isAvailable) {
|
|
317
305
|
return {
|
|
318
306
|
status: 'success',
|
|
@@ -2,9 +2,7 @@ import type { GlobalScanHandleResult, GlobalScanHostBridge } from '../../types';
|
|
|
2
2
|
import { type GlobalScanApplyHost } from './applyGlobalScan';
|
|
3
3
|
import type { GlobalScanFormattedResult } from './formatGlobalScan';
|
|
4
4
|
export interface ProductVoucherCollectionScanHost extends GlobalScanApplyHost {
|
|
5
|
-
waitForCustomerDiscounts(): Promise<void>;
|
|
6
5
|
loadCustomerDiscounts(): Promise<Record<string, any>[]>;
|
|
7
6
|
}
|
|
8
|
-
/**
|
|
9
|
-
* Never expand a wristband's result to other orders of the same customer. */
|
|
7
|
+
/** Resolve the scanned account, then collect all of that customer's vouchers. */
|
|
10
8
|
export declare function applyProductVoucherCollectionScan(host: ProductVoucherCollectionScanHost, formatted: GlobalScanFormattedResult, bridge: GlobalScanHostBridge): Promise<GlobalScanHandleResult>;
|
|
@@ -5,15 +5,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.applyProductVoucherCollectionScan = applyProductVoucherCollectionScan;
|
|
7
7
|
var _applyGlobalScan = require("./applyGlobalScan");
|
|
8
|
-
/**
|
|
9
|
-
* Never expand a wristband's result to other orders of the same customer. */
|
|
8
|
+
/** Resolve the scanned account, then collect all of that customer's vouchers. */
|
|
10
9
|
async function applyProductVoucherCollectionScan(host, formatted, bridge) {
|
|
11
10
|
const assertCurrent = () => {
|
|
12
11
|
if (bridge.isCurrent?.() === false) {
|
|
13
12
|
throw new DOMException('Scan session ended', 'AbortError');
|
|
14
13
|
}
|
|
15
14
|
};
|
|
16
|
-
|
|
15
|
+
const isPass = formatted.searchType === 'walletPass';
|
|
16
|
+
// Order numbers and wristbands resolve through batch-search. Their returned
|
|
17
|
+
// passes identify the customer; they are not the collection's voucher list.
|
|
18
|
+
// Resolve source-shop IDs before reusing the wallet customer-binding flow.
|
|
19
|
+
const customerScan = isPass ? {
|
|
20
|
+
...formatted,
|
|
21
|
+
searchType: 'wallet',
|
|
22
|
+
customerId: formatted.customerId ?? formatted.data?.id ?? formatted.data?.customer_id,
|
|
23
|
+
isCrossShopWallet: true
|
|
24
|
+
} : formatted;
|
|
17
25
|
assertCurrent();
|
|
18
26
|
const result = await (0, _applyGlobalScan.applyGlobalScan)({
|
|
19
27
|
...host,
|
|
@@ -25,44 +33,19 @@ async function applyProductVoucherCollectionScan(host, formatted, bridge) {
|
|
|
25
33
|
assertCurrent();
|
|
26
34
|
return host.addProductToOrder(product, booking);
|
|
27
35
|
}
|
|
28
|
-
},
|
|
36
|
+
}, customerScan, {
|
|
29
37
|
...bridge,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
// before adding scanned coupons so its response cannot overwrite them.
|
|
33
|
-
await host.waitForCustomerDiscounts();
|
|
34
|
-
assertCurrent();
|
|
35
|
-
const promotion = await bridge.applyPromotionCode(code, customerId, {
|
|
36
|
-
...options,
|
|
37
|
-
productVouchersOnly: true,
|
|
38
|
-
suppressFailureNotification: true
|
|
39
|
-
});
|
|
40
|
-
assertCurrent();
|
|
41
|
-
// An empty successful search is different from a swallowed request error.
|
|
42
|
-
if (!Array.isArray(promotion.scannedDiscountList)) {
|
|
43
|
-
throw new Error('Could not resolve scanned vouchers');
|
|
44
|
-
}
|
|
45
|
-
vouchers = promotion.scannedDiscountList;
|
|
46
|
-
return promotion;
|
|
47
|
-
})
|
|
38
|
+
// Without a switch bridge, do not return the previous customer's vouchers.
|
|
39
|
+
requestCustomerSwitch: bridge.requestCustomerSwitch ?? (async () => false)
|
|
48
40
|
});
|
|
49
41
|
assertCurrent();
|
|
50
|
-
if (
|
|
51
|
-
vouchers = await host.loadCustomerDiscounts();
|
|
42
|
+
if (customerScan.searchType === 'wallet' && result.status === 'success') {
|
|
43
|
+
const vouchers = await host.loadCustomerDiscounts();
|
|
52
44
|
assertCurrent();
|
|
53
45
|
return {
|
|
54
46
|
...result,
|
|
55
47
|
redemption: {
|
|
56
|
-
source: 'wallet',
|
|
57
|
-
vouchers
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
if (formatted.searchType === 'walletPass') {
|
|
62
|
-
return {
|
|
63
|
-
...result,
|
|
64
|
-
redemption: {
|
|
65
|
-
source: 'scan',
|
|
48
|
+
source: isPass ? 'scan' : 'wallet',
|
|
66
49
|
vouchers
|
|
67
50
|
}
|
|
68
51
|
};
|
|
@@ -146,6 +146,7 @@ class OrderInvoicePreviewImpl extends _BaseModule.BaseModule {
|
|
|
146
146
|
} : {})
|
|
147
147
|
};
|
|
148
148
|
shop.default_domain || (shop.default_domain = shopCore.default_domain);
|
|
149
|
+
shop.private_domain || (shop.private_domain = shopCore.private_domain);
|
|
149
150
|
shop.private_domain_protocol || (shop.private_domain_protocol = shopCore.private_domain_protocol);
|
|
150
151
|
if (generation !== this.generation || this.disposed) throw new Error('Invoice request superseded');
|
|
151
152
|
const languageOptions = (0, _customerInvoiceLanguages.resolveCustomerInvoiceLanguages)(template.language, input.locale);
|
|
@@ -274,7 +274,7 @@ class SalesImpl extends _BaseModule.BaseModule {
|
|
|
274
274
|
} : {
|
|
275
275
|
external_sale_number: normalizedLookup
|
|
276
276
|
};
|
|
277
|
-
return this.request.post('/local/print-order', {
|
|
277
|
+
return this.request.post('/shop/local/print-order', {
|
|
278
278
|
...lookupPayload,
|
|
279
279
|
lookup_order_from_db: 1,
|
|
280
280
|
small_ticket_data_flag: 1,
|
|
@@ -100,6 +100,8 @@ export declare class ScanOrderImpl extends BaseSalesImpl implements Module {
|
|
|
100
100
|
private buildSubmitPayloadEnhancer;
|
|
101
101
|
private isScanOrderMoreMode;
|
|
102
102
|
private submitScanOrderMore;
|
|
103
|
+
/** Read both current and legacy cart snapshots without changing the product catalog. */
|
|
104
|
+
private getMenuAvailabilityProductSources;
|
|
103
105
|
submitScanOrder<T = any>(): Promise<T>;
|
|
104
106
|
addProductToOrder(product: Partial<ScanOrderOrderProduct> & ScanOrderOrderProductIdentity): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
105
107
|
updateOrderProduct(params: UpdateOrderProductParams): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
@@ -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,
|