@pisell/pisellos 2.3.226 → 2.3.228
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/Customer/types.d.ts +0 -4
- package/dist/modules/Order/index.d.ts +2 -0
- package/dist/modules/Order/index.js +82 -125
- package/dist/modules/Order/types.d.ts +0 -2
- package/dist/modules/Order/utils.js +0 -2
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Rules/index.js +1 -1
- package/dist/modules/Rules/types.d.ts +2 -0
- package/dist/modules/Summary/utils.d.ts +1 -1
- package/dist/solution/BaseSales/index.js +0 -3
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +14 -14
- package/dist/solution/Checkout/index.js +69 -104
- package/dist/solution/Checkout/types.d.ts +0 -1
- package/dist/solution/ScanOrder/additionalOrderPayload.d.ts +40 -0
- package/dist/solution/ScanOrder/additionalOrderPayload.js +52 -0
- package/dist/solution/ScanOrder/index.js +13 -19
- package/dist/solution/UnifiedBookingSales/draftDiscounts.d.ts +8 -0
- package/dist/solution/UnifiedBookingSales/draftDiscounts.js +101 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +7 -0
- package/dist/solution/UnifiedBookingSales/index.js +1253 -1072
- package/dist/solution/UnifiedBookingSales/types.d.ts +5 -0
- package/dist/solution/VenueBooking/index.js +490 -522
- package/lib/model/strategy/adapter/promotion/index.js +46 -1
- package/lib/modules/Customer/types.d.ts +0 -4
- package/lib/modules/Order/index.d.ts +2 -0
- package/lib/modules/Order/index.js +9 -46
- package/lib/modules/Order/types.d.ts +0 -2
- package/lib/modules/Order/utils.js +1 -5
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Rules/index.js +1 -1
- package/lib/modules/Rules/types.d.ts +2 -0
- package/lib/modules/Summary/utils.d.ts +1 -1
- package/lib/solution/BaseSales/index.js +0 -3
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +14 -14
- package/lib/solution/Checkout/index.js +0 -21
- package/lib/solution/Checkout/types.d.ts +0 -1
- package/lib/solution/ScanOrder/additionalOrderPayload.d.ts +40 -0
- package/lib/solution/ScanOrder/additionalOrderPayload.js +50 -0
- package/lib/solution/ScanOrder/index.js +5 -9
- package/lib/solution/UnifiedBookingSales/draftDiscounts.d.ts +8 -0
- package/lib/solution/UnifiedBookingSales/draftDiscounts.js +36 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +7 -0
- package/lib/solution/UnifiedBookingSales/index.js +78 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +5 -0
- package/lib/solution/VenueBooking/index.js +1 -6
- package/package.json +1 -1
- package/dist/modules/Order/utils/bookingUuid.d.ts +0 -4
- package/dist/modules/Order/utils/bookingUuid.js +0 -24
- package/lib/modules/Order/utils/bookingUuid.d.ts +0 -4
- package/lib/modules/Order/utils/bookingUuid.js +0 -25
|
@@ -1 +1,46 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "BUY_X_GET_Y_FREE_STRATEGY", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _examples.BUY_X_GET_Y_FREE_STRATEGY;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "ITEM_REWARD_STRATEGY", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _examples.ITEM_REWARD_STRATEGY;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "PromotionAdapter", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _adapter.PromotionAdapter;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "PromotionEvaluator", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _evaluator.PromotionEvaluator;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "X_ITEMS_FOR_Y_PRICE_STRATEGY", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _examples.X_ITEMS_FOR_Y_PRICE_STRATEGY;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "default", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _adapter.default;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
var _evaluator = require("./evaluator");
|
|
43
|
+
var _adapter = _interopRequireWildcard(require("./adapter"));
|
|
44
|
+
var _examples = require("./examples");
|
|
45
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
46
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -44,10 +44,6 @@ export interface ShopGetCustomerListParams {
|
|
|
44
44
|
num?: number;
|
|
45
45
|
/** 搜索关键词 */
|
|
46
46
|
search?: string;
|
|
47
|
-
/** Full national phone number, without the international calling code. */
|
|
48
|
-
phone?: string;
|
|
49
|
-
/** Exact email lookup, independent from the generic search keyword. */
|
|
50
|
-
email?: string;
|
|
51
47
|
/** 关联查询参数 */
|
|
52
48
|
with?: CustomerWith[];
|
|
53
49
|
/** wallet搜索标识 */
|
|
@@ -131,6 +131,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
131
131
|
scannedDiscountList?: Discount[];
|
|
132
132
|
}>;
|
|
133
133
|
applyDiscount(options?: {
|
|
134
|
+
/** Draft recovery must remove stale discounts even when no card survives revalidation. */
|
|
135
|
+
force?: boolean;
|
|
134
136
|
reapplyBookingDiscountProductUids?: string[];
|
|
135
137
|
reapplyWeighedDiscountProductUids?: string[];
|
|
136
138
|
preferredEntitlementPassIds?: number[];
|
|
@@ -11,7 +11,6 @@ Object.defineProperty(exports, "isFulfillmentTimingBooking", {
|
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
13
|
var _loadSalesOrderSnapshot = require("../../shared/sales/loadSalesOrderSnapshot");
|
|
14
|
-
var _bookingUuid = require("./utils/bookingUuid");
|
|
15
14
|
var _localEftposState = require("./localEftposState");
|
|
16
15
|
var _BaseModule = require("../BaseModule");
|
|
17
16
|
var _types = require("./types");
|
|
@@ -945,7 +944,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
945
944
|
delete tempOrder.discount_list;
|
|
946
945
|
const discountList = this.store.discount?.getDiscountList() || [];
|
|
947
946
|
const shouldSkipDiscountCalculation = this.shouldSkipDiscountCalculation(tempOrder);
|
|
948
|
-
if (shouldSkipDiscountCalculation) return;
|
|
947
|
+
if (shouldSkipDiscountCalculation && !options?.force) return;
|
|
949
948
|
const rulesModule = this.store.rules;
|
|
950
949
|
if (!rulesModule) return;
|
|
951
950
|
const result = rulesModule.calcDiscount({
|
|
@@ -957,7 +956,8 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
957
956
|
}, {
|
|
958
957
|
reapplyBookingDiscountProductUids: options?.reapplyBookingDiscountProductUids,
|
|
959
958
|
reapplyWeighedDiscountProductUids: options?.reapplyWeighedDiscountProductUids,
|
|
960
|
-
preferredEntitlementPassIds: options?.preferredEntitlementPassIds
|
|
959
|
+
preferredEntitlementPassIds: options?.preferredEntitlementPassIds,
|
|
960
|
+
force: options?.force
|
|
961
961
|
});
|
|
962
962
|
if (result?.productList) {
|
|
963
963
|
const previousProductsByUid = (0, _utils.indexOrderProductsByUid)(tempOrder.products);
|
|
@@ -2585,7 +2585,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
2585
2585
|
booking_uid: bookingUid
|
|
2586
2586
|
},
|
|
2587
2587
|
booking: {
|
|
2588
|
-
...
|
|
2588
|
+
...params.booking,
|
|
2589
2589
|
is_all: (0, _utils.normalizeBookingIsAll)(params.booking),
|
|
2590
2590
|
product_uid: productUid,
|
|
2591
2591
|
sub_type: (0, _utils.normalizeBookingSubType)(params.booking),
|
|
@@ -3200,7 +3200,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3200
3200
|
const tempOrder = this.ensureTempOrder();
|
|
3201
3201
|
const bookings = tempOrder.bookings || [];
|
|
3202
3202
|
const firstIndex = bookings.findIndex(_pickupTiming.isFulfillmentTimingBooking);
|
|
3203
|
-
const nextBooking = (0,
|
|
3203
|
+
const nextBooking = (0, _pickupTiming.buildPickupTimingBooking)(input, bookings[firstIndex]);
|
|
3204
3204
|
// Keep the first row's identity and position; repair duplicate marked rows only.
|
|
3205
3205
|
tempOrder.bookings = firstIndex === -1 ? [...bookings, nextBooking] : bookings.flatMap((booking, index) => index === firstIndex ? [nextBooking] : (0, _pickupTiming.isFulfillmentTimingBooking)(booking) ? [] : [booking]);
|
|
3206
3206
|
this.notifyTempOrderChanged();
|
|
@@ -3852,16 +3852,6 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3852
3852
|
* if (pending) await pending;
|
|
3853
3853
|
*/
|
|
3854
3854
|
appendProductLineToTempOrder(tempOrder, product, booking, options) {
|
|
3855
|
-
const incomingBookingUuid = booking?.uuid;
|
|
3856
|
-
if (booking && incomingBookingUuid && tempOrder.bookings?.some(item => item.uuid === incomingBookingUuid)) {
|
|
3857
|
-
// Appending a copy creates a different booking; editing uses the update path below.
|
|
3858
|
-
booking = {
|
|
3859
|
-
...booking,
|
|
3860
|
-
uuid: (0, _utils.createUuidV4)(),
|
|
3861
|
-
id: undefined,
|
|
3862
|
-
schedule_event_id: undefined
|
|
3863
|
-
};
|
|
3864
|
-
}
|
|
3865
3855
|
const linked = booking ? this.createLinkedProductAndBooking({
|
|
3866
3856
|
product,
|
|
3867
3857
|
booking
|
|
@@ -4026,12 +4016,6 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4026
4016
|
singleLine.num = 1;
|
|
4027
4017
|
delete singleLine.product_quantity;
|
|
4028
4018
|
const singleBooking = (0, _lodashEs.cloneDeep)(booking);
|
|
4029
|
-
if (index > 0) {
|
|
4030
|
-
// Both single-add and batch-add quantity splits create separate appointments.
|
|
4031
|
-
delete singleBooking.uuid;
|
|
4032
|
-
delete singleBooking.schedule_event_id;
|
|
4033
|
-
delete singleBooking.id;
|
|
4034
|
-
}
|
|
4035
4019
|
const bookingHolder = booking?.holder && typeof booking.holder === 'object' ? booking.holder : null;
|
|
4036
4020
|
const metadataHolder = booking?.metadata?.holder && typeof booking.metadata.holder === 'object' ? booking.metadata.holder : null;
|
|
4037
4021
|
const rawHolderIds = bookingHolder?.form_record ?? booking?.metadata?.holder_id ?? metadataHolder?.form_record ?? product?.metadata?.holder_id;
|
|
@@ -4282,8 +4266,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4282
4266
|
const target = live.products[targetIndex];
|
|
4283
4267
|
const scopeKey = String(target?.metadata?.venue_booking_scope_key || '');
|
|
4284
4268
|
const targetBookingUid = String(target?.booking_uid || target?.metadata?.booking_uid || '');
|
|
4285
|
-
|
|
4286
|
-
if (!uid || !target || !scopeKey || live.order_id || target.order_detail_id != null || Number(target.num) !== 1 || Number(params.product.num ?? 1) !== 1 || target.metadata?.venue_booking_role !== 'party_main' || params.product.metadata?.venue_booking_role !== 'party_main' || params.product.metadata?.venue_booking_scope_key !== scopeKey || !Array.isArray(params.relatedRetailProducts) || (live.payments || []).length > 0 || !targetBookingUid || String(params.booking.metadata?.unique_identification_number || '') !== targetBookingUid || targetBookings.length !== 1 || live.products.filter(line => line.metadata?.venue_booking_role === 'party_main' && line.metadata?.venue_booking_scope_key === scopeKey).length !== 1) {
|
|
4269
|
+
if (!uid || !target || !scopeKey || live.order_id || target.order_detail_id != null || Number(target.num) !== 1 || Number(params.product.num ?? 1) !== 1 || target.metadata?.venue_booking_role !== 'party_main' || params.product.metadata?.venue_booking_role !== 'party_main' || params.product.metadata?.venue_booking_scope_key !== scopeKey || !Array.isArray(params.relatedRetailProducts) || (live.payments || []).length > 0 || !targetBookingUid || String(params.booking.metadata?.unique_identification_number || '') !== targetBookingUid || (live.bookings || []).filter(booking => this.getBookingUniqueIdentificationNumber(booking) === targetBookingUid).length !== 1 || live.products.filter(line => line.metadata?.venue_booking_role === 'party_main' && line.metadata?.venue_booking_scope_key === scopeKey).length !== 1) {
|
|
4287
4270
|
throw new Error('[Order] Party replacement requires one unsubmitted, unpaid main booking in the same scope');
|
|
4288
4271
|
}
|
|
4289
4272
|
const children = live.products.filter(line => line.metadata?.venue_booking_role === 'party_extra' && String(line.metadata?.venue_booking_parent_uid || '') === uid);
|
|
@@ -4343,9 +4326,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4343
4326
|
venue_booking_service_datetime: serviceDatetime
|
|
4344
4327
|
};
|
|
4345
4328
|
replacement.unique_identification_number = uid;
|
|
4346
|
-
|
|
4347
|
-
replacementBooking.uuid = targetBookings[0].uuid || replacementBooking.uuid;
|
|
4348
|
-
await this.appendProductLineToTempOrder(draft, replacement, replacementBooking, {
|
|
4329
|
+
await this.appendProductLineToTempOrder(draft, replacement, (0, _lodashEs.cloneDeep)(params.booking), {
|
|
4349
4330
|
insertAtIndex: targetIndex,
|
|
4350
4331
|
disableMerge: true,
|
|
4351
4332
|
beforeCommit
|
|
@@ -4753,22 +4734,12 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4753
4734
|
...(normalizedProduct.metadata || {}),
|
|
4754
4735
|
unique_identification_number: productUid
|
|
4755
4736
|
};
|
|
4756
|
-
const originalBookingUid = targetProduct.booking_uid || targetProduct.metadata?.booking_uid || preservedBookingUid;
|
|
4757
|
-
const bookings = tempOrder.bookings || [];
|
|
4758
|
-
const eventId = booking.schedule_event_id;
|
|
4759
|
-
const originalBooking = bookings.find(row => Number(eventId) > 0 && String(row.schedule_event_id) === String(eventId)) ?? bookings.find(row => originalBookingUid && row.metadata?.unique_identification_number === originalBookingUid);
|
|
4760
|
-
const {
|
|
4761
|
-
uuid: incomingUuid = originalBooking?.uuid
|
|
4762
|
-
} = booking;
|
|
4763
4737
|
const linked = this.createLinkedProductAndBooking({
|
|
4764
4738
|
product: {
|
|
4765
4739
|
...normalizedProduct,
|
|
4766
4740
|
unique_identification_number: productUid
|
|
4767
4741
|
},
|
|
4768
|
-
booking
|
|
4769
|
-
...booking,
|
|
4770
|
-
uuid: originalBooking?.uuid || incomingUuid
|
|
4771
|
-
}
|
|
4742
|
+
booking
|
|
4772
4743
|
});
|
|
4773
4744
|
this.removeLinkedBookingsForProduct(tempOrder, targetProduct);
|
|
4774
4745
|
normalizedProduct = {
|
|
@@ -5030,13 +5001,9 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
5030
5001
|
throw new Error('[Order] 目标 booking 不存在,无法更新');
|
|
5031
5002
|
}
|
|
5032
5003
|
const targetBooking = tempOrder.bookings[bookingIndex] || {};
|
|
5033
|
-
const {
|
|
5034
|
-
uuid: incomingUuid = targetBooking.uuid
|
|
5035
|
-
} = updates;
|
|
5036
5004
|
const nextBooking = {
|
|
5037
5005
|
...targetBooking,
|
|
5038
5006
|
...updates,
|
|
5039
|
-
uuid: targetBooking.uuid || incomingUuid,
|
|
5040
5007
|
metadata: {
|
|
5041
5008
|
...(targetBooking.metadata || {}),
|
|
5042
5009
|
...(updates.metadata || {}),
|
|
@@ -5046,7 +5013,6 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
5046
5013
|
unique_identification_number: bookingUid
|
|
5047
5014
|
}
|
|
5048
5015
|
};
|
|
5049
|
-
(0, _bookingUuid.assignBookingUuid)(nextBooking);
|
|
5050
5016
|
this.syncBookingMetadataHolder(nextBooking, nextBooking.metadata);
|
|
5051
5017
|
nextBooking.is_all = (0, _utils.normalizeBookingIsAll)(nextBooking);
|
|
5052
5018
|
nextBooking.sub_type = (0, _utils.normalizeBookingSubType)(nextBooking);
|
|
@@ -5747,7 +5713,6 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
5747
5713
|
* @returns 后端返回的订单数据(包含订单ID等)
|
|
5748
5714
|
*/
|
|
5749
5715
|
async createOrderByCheckout(params) {
|
|
5750
|
-
params.bookings?.forEach(_bookingUuid.assignBookingUuid);
|
|
5751
5716
|
// 过滤掉由在线店铺下单的 payment 支付数据
|
|
5752
5717
|
const onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
|
|
5753
5718
|
params.payments = params.payments?.filter(p => !onlineStorePaymentCodeList.includes(p.code));
|
|
@@ -5835,7 +5800,6 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
5835
5800
|
url,
|
|
5836
5801
|
query
|
|
5837
5802
|
} = params;
|
|
5838
|
-
query.bookings?.forEach(_bookingUuid.assignBookingUuid);
|
|
5839
5803
|
const fetchUrl = url || '/order/sales/checkout';
|
|
5840
5804
|
const handledByOsServer = this.isSalesCheckoutHandledByOsServer(fetchUrl);
|
|
5841
5805
|
const requestQuery = handledByOsServer ? query : (0, _localEftposState.stripLocalEftposState)((0, _osPrivatePayload.stripOsPrivatePayloadFields)(query));
|
|
@@ -6190,9 +6154,8 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
6190
6154
|
})) : [];
|
|
6191
6155
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(b => {
|
|
6192
6156
|
const booking = this.normalizeHydratedBookingHolder(b || {});
|
|
6193
|
-
const submitted = (0, _pickupTiming.isFulfillmentTimingBooking)(booking) || Number(booking.parent_id) !== 0;
|
|
6194
6157
|
return {
|
|
6195
|
-
...
|
|
6158
|
+
...booking,
|
|
6196
6159
|
is_all: (0, _utils.normalizeBookingIsAll)(booking),
|
|
6197
6160
|
sub_type: (0, _utils.normalizeBookingSubType)(booking)
|
|
6198
6161
|
};
|
|
@@ -617,8 +617,6 @@ export interface CommitOrderParams {
|
|
|
617
617
|
};
|
|
618
618
|
}
|
|
619
619
|
export interface OrderSubmitBooking {
|
|
620
|
-
/** Stable booking identity, created once and shared with external allocations. */
|
|
621
|
-
uuid?: string | null;
|
|
622
620
|
relation_id?: string;
|
|
623
621
|
form_id?: string;
|
|
624
622
|
collect_pax?: number;
|
|
@@ -140,7 +140,6 @@ var _manualProductDiscount = require("./utils/manualProductDiscount");
|
|
|
140
140
|
var _utils = require("../Holder/utils");
|
|
141
141
|
var _utils2 = require("../../solution/ScanOrder/utils");
|
|
142
142
|
var _orderCollectionIdentity = require("./utils/orderCollectionIdentity");
|
|
143
|
-
var _bookingUuid = require("./utils/bookingUuid");
|
|
144
143
|
var _salesNotes = require("./salesNotes");
|
|
145
144
|
var _pickupTiming = require("./pickupTiming");
|
|
146
145
|
var _holderRelations = require("./holderRelations");
|
|
@@ -1665,10 +1664,7 @@ function buildSubmitPayload(params) {
|
|
|
1665
1664
|
delivery_type: tempOrder.delivery_type || 'shop_service',
|
|
1666
1665
|
schedule_date: scheduleDate,
|
|
1667
1666
|
// created_at: tempOrder.created_at || formatDateTime(now), 和后端协定这个字段先不提交到接口
|
|
1668
|
-
bookings: (tempOrder.bookings || []).filter(booking => (0, _pickupTiming.isFulfillmentTimingBooking)(booking) || Number(booking.parent_id) !== 0).map(booking =>
|
|
1669
|
-
(0, _bookingUuid.assignBookingUuid)(booking);
|
|
1670
|
-
return normalizeSubmitBooking(booking);
|
|
1671
|
-
}),
|
|
1667
|
+
bookings: (tempOrder.bookings || []).filter(booking => (0, _pickupTiming.isFulfillmentTimingBooking)(booking) || Number(booking.parent_id) !== 0).map(booking => normalizeSubmitBooking(booking)),
|
|
1672
1668
|
payments: tempOrder.payments || [],
|
|
1673
1669
|
relation_forms: tempOrder.relation_forms || [],
|
|
1674
1670
|
// contacts: tempOrder.contacts || [],
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
|
@@ -307,7 +307,7 @@ class RulesModule extends _BaseModule.BaseModule {
|
|
|
307
307
|
}
|
|
308
308
|
});
|
|
309
309
|
}
|
|
310
|
-
const hasDiscountInput = editModeDiscount.length > 0 || addModeDiscount.length > 0 || Boolean(options?.discountId) || Boolean(options?.selectedList?.length) || Boolean(options?.scan);
|
|
310
|
+
const hasDiscountInput = options?.force === true || editModeDiscount.length > 0 || addModeDiscount.length > 0 || Boolean(options?.discountId) || Boolean(options?.selectedList?.length) || Boolean(options?.scan);
|
|
311
311
|
if (!hasDiscountInput) {
|
|
312
312
|
return {
|
|
313
313
|
discountList,
|
|
@@ -34,6 +34,8 @@ export interface RulesCalcDiscountParams {
|
|
|
34
34
|
orderTotalAmount: number;
|
|
35
35
|
}
|
|
36
36
|
export interface RulesCalcDiscountOptions {
|
|
37
|
+
/** Clear stale line discounts when draft revalidation yields no eligible cards. */
|
|
38
|
+
force?: boolean;
|
|
37
39
|
isSelected?: boolean;
|
|
38
40
|
discountId?: number;
|
|
39
41
|
selectedList?: SetDiscountSelectedParams[];
|
|
@@ -72,7 +72,7 @@ export declare const calculateOriginSubtotal: (items: CartItem[]) => string;
|
|
|
72
72
|
* @return {*}
|
|
73
73
|
* @Author: xiangfeng.xue
|
|
74
74
|
*/
|
|
75
|
-
export declare const calculateTaxFee: (shopInfo: any, items: CartItem[]) =>
|
|
75
|
+
export declare const calculateTaxFee: (shopInfo: any, items: CartItem[]) => "0.00" | Decimal;
|
|
76
76
|
/**
|
|
77
77
|
* @title: 计算定金
|
|
78
78
|
* @param items - 购物车商品数组
|
|
@@ -223,9 +223,6 @@ function mergeBaseSalesCollectionItem(kind, currentItem, incomingItem, uidRemaps
|
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
const mergedItem = mergedUid ? (0, _orderCollectionIdentity.setOrderCollectionUid)(kind, incomingItem, mergedUid) : (0, _lodashEs.cloneDeep)(incomingItem);
|
|
226
|
-
if (kind === 'booking' && !mergedItem.uuid && currentItem.uuid !== undefined) {
|
|
227
|
-
mergedItem.uuid = currentItem.uuid;
|
|
228
|
-
}
|
|
229
226
|
const persistentIdField = BASE_SALES_PERSISTENT_ID_FIELD_BY_KIND[kind];
|
|
230
227
|
if (isBaseSalesBlankValue(mergedItem[persistentIdField]) && !isBaseSalesBlankValue(identityMergedItem[persistentIdField])) {
|
|
231
228
|
mergedItem[persistentIdField] = identityMergedItem[persistentIdField];
|
|
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
342
342
|
date: string;
|
|
343
343
|
status: string;
|
|
344
344
|
week: string;
|
|
345
|
-
weekNum: 0 |
|
|
345
|
+
weekNum: 0 | 1 | 2 | 6 | 4 | 5 | 3;
|
|
346
346
|
}[]>;
|
|
347
347
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
348
348
|
private getScheduleDataByIds;
|
|
@@ -389,7 +389,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
389
389
|
};
|
|
390
390
|
setOtherData(key: string, value: any): void;
|
|
391
391
|
getOtherData(key: string): any;
|
|
392
|
-
getProductTypeById(id: number): Promise<"
|
|
392
|
+
getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
|
|
393
393
|
/**
|
|
394
394
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
395
395
|
*
|
|
@@ -25,28 +25,23 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
|
|
|
25
25
|
notes?: import("../../../modules/Order/types").SalesNote[] | undefined;
|
|
26
26
|
summary?: import("../../../modules/Order/types").OrderSummary | undefined;
|
|
27
27
|
small_ticket_data_flag?: number | undefined;
|
|
28
|
-
status: string;
|
|
29
28
|
metadata: Record<string, any>;
|
|
30
|
-
business_code?: string | undefined;
|
|
31
|
-
customer_id: number | null;
|
|
32
|
-
type: string;
|
|
33
|
-
holder: Record<string, any> | null;
|
|
34
|
-
email: string;
|
|
35
|
-
phone: string;
|
|
36
29
|
note: string;
|
|
37
|
-
relation_forms: any[];
|
|
38
|
-
holder_relations?: import("../../../modules/Order/types").OrderHolderRelation[] | undefined;
|
|
39
|
-
country_calling_code: string;
|
|
40
|
-
contacts_info: Record<string, any> | null;
|
|
41
30
|
order_id: number | null;
|
|
42
|
-
external_sale_number: string;
|
|
43
31
|
order_number: string | null;
|
|
44
32
|
shop_order_number: string | null;
|
|
45
33
|
shop_full_order_number: string | null;
|
|
34
|
+
type: string;
|
|
35
|
+
business_code?: string | undefined;
|
|
46
36
|
sales_channel: string;
|
|
47
37
|
order_sales_channel: string;
|
|
38
|
+
status: string;
|
|
48
39
|
shipping_status: string;
|
|
40
|
+
customer_id: number | null;
|
|
49
41
|
customer_name: string;
|
|
42
|
+
country_calling_code: string;
|
|
43
|
+
phone: string;
|
|
44
|
+
email: string;
|
|
50
45
|
is_price_include_tax: number;
|
|
51
46
|
tax_title: string;
|
|
52
47
|
tax_country_code: string;
|
|
@@ -63,10 +58,15 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
|
|
|
63
58
|
schedule_date: string;
|
|
64
59
|
bookings: any[];
|
|
65
60
|
payments: any[];
|
|
66
|
-
order_meta_list?: import("../../../modules/Order/types").OrderMetaList | undefined;
|
|
67
|
-
refunds?: any[] | undefined;
|
|
68
61
|
surcharges: any[];
|
|
62
|
+
relation_forms: any[];
|
|
69
63
|
contacts: any[];
|
|
64
|
+
contacts_info: Record<string, any> | null;
|
|
65
|
+
holder: Record<string, any> | null;
|
|
66
|
+
external_sale_number: string;
|
|
67
|
+
holder_relations?: import("../../../modules/Order/types").OrderHolderRelation[] | undefined;
|
|
68
|
+
refunds?: any[] | undefined;
|
|
69
|
+
order_meta_list?: import("../../../modules/Order/types").OrderMetaList | undefined;
|
|
70
70
|
};
|
|
71
71
|
export declare function describeChangedBookings(before: OrderTempOrder['bookings'], after: OrderTempOrder['bookings']): {
|
|
72
72
|
schedule_event_id: any;
|
|
@@ -10,8 +10,6 @@ exports.CheckoutImpl = void 0;
|
|
|
10
10
|
var _BaseModule = require("../../modules/BaseModule");
|
|
11
11
|
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
12
12
|
var _Order = require("../../modules/Order");
|
|
13
|
-
var _bookingUuid = require("../../modules/Order/utils/bookingUuid");
|
|
14
|
-
var _orderCollectionIdentity = require("../../modules/Order/utils/orderCollectionIdentity");
|
|
15
13
|
var _Payment = require("../../modules/Payment");
|
|
16
14
|
var _types = require("./types");
|
|
17
15
|
Object.keys(_types).forEach(function (key) {
|
|
@@ -460,7 +458,6 @@ class CheckoutImpl extends _BaseModule.BaseModule {
|
|
|
460
458
|
params.orderData.tax_fee = params.totalInfo?.total?.tax;
|
|
461
459
|
|
|
462
460
|
// 保存原始订单数据和小计数据到状态中
|
|
463
|
-
params.orderData.bookings?.forEach(_bookingUuid.assignBookingUuid);
|
|
464
461
|
this.store.localOrderData = params.orderData;
|
|
465
462
|
this.store.cartSummary = params.cartSummary;
|
|
466
463
|
|
|
@@ -593,24 +590,6 @@ class CheckoutImpl extends _BaseModule.BaseModule {
|
|
|
593
590
|
// 保留原有支付项:通过 orderId 找到现有订单(按 id 或 order_id 匹配)
|
|
594
591
|
const allOrders = await this.payment.getOrderListAsync();
|
|
595
592
|
const existingOrder = allOrders.find(o => String(o.id) === String(params.orderId) || String(o.order_id) === String(params.orderId));
|
|
596
|
-
|
|
597
|
-
// POS 再次保存会重建预约行;按已有行标识复用上次保存的 UUID。
|
|
598
|
-
const previousBookings = existingOrder?.order_info?.original_order_data?.bookings;
|
|
599
|
-
const previousUuids = new Map();
|
|
600
|
-
if (Array.isArray(previousBookings)) {
|
|
601
|
-
for (const booking of previousBookings) {
|
|
602
|
-
const uid = (0, _orderCollectionIdentity.getOrderCollectionUid)('booking', booking);
|
|
603
|
-
if (uid && booking.uuid !== undefined) previousUuids.set(uid, booking.uuid);
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
for (const booking of params.orderData.bookings || []) {
|
|
607
|
-
const uid = (0, _orderCollectionIdentity.getOrderCollectionUid)('booking', booking);
|
|
608
|
-
if (uid && previousUuids.has(uid)) {
|
|
609
|
-
booking.uuid ?? (booking.uuid = previousUuids.get(uid));
|
|
610
|
-
previousUuids.delete(uid);
|
|
611
|
-
}
|
|
612
|
-
(0, _bookingUuid.assignBookingUuid)(booking);
|
|
613
|
-
}
|
|
614
593
|
if (existingOrder) {
|
|
615
594
|
// 🔧 新增: 如果传入了 existPayment,需要更新支付项列表
|
|
616
595
|
if (params.existPayment && params.existPayment.length > 0) {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { OrderSubmitProduct } from '../../modules/Order/types';
|
|
2
|
+
interface ScanOrderMoreOption {
|
|
3
|
+
product_option_item_id: number;
|
|
4
|
+
option_group_id: number;
|
|
5
|
+
num: number;
|
|
6
|
+
price: string | number;
|
|
7
|
+
}
|
|
8
|
+
interface ScanOrderMoreBundle {
|
|
9
|
+
id: number;
|
|
10
|
+
group_id: number;
|
|
11
|
+
bundle_product_id: number;
|
|
12
|
+
_bundle_product_id: number;
|
|
13
|
+
bundle_variant_id: number;
|
|
14
|
+
num: number;
|
|
15
|
+
price: string | number;
|
|
16
|
+
price_type: string;
|
|
17
|
+
price_type_ext: string;
|
|
18
|
+
extension_id: number;
|
|
19
|
+
extension_type: string;
|
|
20
|
+
option: ScanOrderMoreOption[];
|
|
21
|
+
}
|
|
22
|
+
export interface ScanOrderMoreProduct {
|
|
23
|
+
product_id: number | null;
|
|
24
|
+
product_variant_id: number;
|
|
25
|
+
num: number;
|
|
26
|
+
note: string;
|
|
27
|
+
key: string;
|
|
28
|
+
rowKey: string;
|
|
29
|
+
unique: string;
|
|
30
|
+
session: null;
|
|
31
|
+
option: ScanOrderMoreOption[];
|
|
32
|
+
bundle: ScanOrderMoreBundle[];
|
|
33
|
+
}
|
|
34
|
+
export interface ScanOrderMorePayload {
|
|
35
|
+
products: ScanOrderMoreProduct[];
|
|
36
|
+
request_unique_idempotency_token?: string;
|
|
37
|
+
}
|
|
38
|
+
/** The add-on PUT still consumes V1 selections, while checkout consumes V2 products. */
|
|
39
|
+
export declare function formatScanOrderMoreProducts(products: readonly OrderSubmitProduct[]): ScanOrderMoreProduct[];
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.formatScanOrderMoreProducts = formatScanOrderMoreProducts;
|
|
7
|
+
function formatOptions(options = []) {
|
|
8
|
+
return options.map(option => ({
|
|
9
|
+
product_option_item_id: option.option_group_item_id ?? option.product_option_item_id,
|
|
10
|
+
option_group_id: option.option_group_id,
|
|
11
|
+
num: option.num ?? 1,
|
|
12
|
+
price: option.add_price ?? option.price ?? 0
|
|
13
|
+
}));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** The add-on PUT still consumes V1 selections, while checkout consumes V2 products. */
|
|
17
|
+
function formatScanOrderMoreProducts(products) {
|
|
18
|
+
return products.map((product, index) => {
|
|
19
|
+
// Canonical cart rows already have a UID. Keep old UID-less snapshots stable
|
|
20
|
+
// within the same request without merging distinct rows of the same SKU.
|
|
21
|
+
const lineKey = String(product.metadata?.unique_identification_number || `scan-order-more:${product.product_id}:${product.product_variant_id}:${index}`);
|
|
22
|
+
return {
|
|
23
|
+
product_id: product.product_id,
|
|
24
|
+
product_variant_id: product.product_variant_id,
|
|
25
|
+
num: product.product_quantity,
|
|
26
|
+
note: String(product.note ?? ''),
|
|
27
|
+
key: lineKey,
|
|
28
|
+
rowKey: lineKey,
|
|
29
|
+
unique: lineKey,
|
|
30
|
+
session: null,
|
|
31
|
+
option: formatOptions(product.product_sku?.option),
|
|
32
|
+
bundle: (product.product_bundle || []).map(bundle => ({
|
|
33
|
+
id: bundle.bundle_id,
|
|
34
|
+
group_id: bundle.bundle_group_id,
|
|
35
|
+
// V1 calls the selection/map ID bundle_product_id; the actual child
|
|
36
|
+
// product ID is stored separately as _bundle_product_id.
|
|
37
|
+
bundle_product_id: bundle.bundle_id,
|
|
38
|
+
_bundle_product_id: bundle.bundle_product_id,
|
|
39
|
+
bundle_variant_id: bundle.bundle_variant_id ?? 0,
|
|
40
|
+
num: bundle.num ?? bundle.quantity ?? 1,
|
|
41
|
+
price: bundle.price ?? 0,
|
|
42
|
+
price_type: bundle.price_type ?? '',
|
|
43
|
+
price_type_ext: bundle.price_type_ext ?? '',
|
|
44
|
+
extension_id: bundle.extension_id ?? 0,
|
|
45
|
+
extension_type: bundle.extension_type ?? 'normal',
|
|
46
|
+
option: formatOptions(bundle.option)
|
|
47
|
+
}))
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
}
|
|
@@ -32,6 +32,7 @@ var _utils2 = require("../../modules/Order/utils");
|
|
|
32
32
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
33
33
|
var _itemRule = require("../../model/strategy/adapter/itemRule");
|
|
34
34
|
var _menuAvailability = require("./menuAvailability");
|
|
35
|
+
var _additionalOrderPayload = require("./additionalOrderPayload");
|
|
35
36
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
36
37
|
function isItemRewardProductDiscount(discount) {
|
|
37
38
|
return discount?.type === 'product' && discount?.metadata?.source === 'promotion' && discount?.metadata?.actionType === 'ITEM_REWARD';
|
|
@@ -876,16 +877,10 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
|
|
|
876
877
|
const bookingCapacityDimensionId = (0, _utils.pickFirstCustomCapacityDimensionId)(this.enabledReservationRuleProducts) ?? 0;
|
|
877
878
|
let bookings = payload.bookings || [];
|
|
878
879
|
if (!tempOrder.order_id && bookings.length === 0) {
|
|
879
|
-
const extend = tempOrder._extend ?? (tempOrder._extend = {});
|
|
880
|
-
if (!extend.scanOrderBookingUuid) {
|
|
881
|
-
extend.scanOrderBookingUuid = (0, _utils2.createUuidV4)();
|
|
882
|
-
this.store.order?.persistTempOrder?.();
|
|
883
|
-
}
|
|
884
880
|
const bookingStart = (0, _dayjs.default)(now);
|
|
885
881
|
const bookingDuration = (0, _utils2.resolveTableOccupancyDuration)(tempOrder);
|
|
886
882
|
const bookingEnd = bookingStart.add(bookingDuration, 'minute');
|
|
887
883
|
bookings = [(0, _utils2.normalizeSubmitBooking)({
|
|
888
|
-
uuid: extend.scanOrderBookingUuid,
|
|
889
884
|
relation_id: 0,
|
|
890
885
|
form_id: 0,
|
|
891
886
|
start_time: bookingStart.format('HH:mm'),
|
|
@@ -999,12 +994,13 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
|
|
|
999
994
|
summary: latestSummary,
|
|
1000
995
|
enhance: enhancePayload
|
|
1001
996
|
});
|
|
1002
|
-
const products = (0, _utils.filterProductsForScanOrderMore)(payload.products);
|
|
997
|
+
const products = (0, _additionalOrderPayload.formatScanOrderMoreProducts)((0, _utils.filterProductsForScanOrderMore)(payload.products));
|
|
1003
998
|
const orderId = tempOrder.order_id;
|
|
1004
|
-
const
|
|
999
|
+
const requestBody = {
|
|
1005
1000
|
products,
|
|
1006
1001
|
request_unique_idempotency_token: payload.request_unique_idempotency_token
|
|
1007
|
-
}
|
|
1002
|
+
};
|
|
1003
|
+
const result = await this.request.put(`/order/order/product/${orderId}`, requestBody, {
|
|
1008
1004
|
customToast: () => {}
|
|
1009
1005
|
});
|
|
1010
1006
|
if (result?.code === 200 && !result?.data) {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Persist selection intent only; availability and pricing must come from fresh OS data. */
|
|
2
|
+
export interface DraftDiscountSelection {
|
|
3
|
+
id: string;
|
|
4
|
+
code?: string;
|
|
5
|
+
selected: boolean;
|
|
6
|
+
isScan?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function collectDraftDiscountSelection(order: Record<string, any>, runtime?: Record<string, any>[]): DraftDiscountSelection[];
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.collectDraftDiscountSelection = collectDraftDiscountSelection;
|
|
7
|
+
/** Persist selection intent only; availability and pricing must come from fresh OS data. */
|
|
8
|
+
|
|
9
|
+
const voucherTypes = new Set(['discount_card', 'product_discount_card', 'good_pass', 'entitlement_pass']);
|
|
10
|
+
function collectDraftDiscountSelection(order, runtime) {
|
|
11
|
+
const selections = new Map();
|
|
12
|
+
const append = (discount, line = false) => {
|
|
13
|
+
if (!voucherTypes.has(discount?.tag || discount?.type) || discount.isEditMode) return;
|
|
14
|
+
const id = String(line ? discount.discount?.resource_id || discount.id || '' : discount.id || '');
|
|
15
|
+
if (!id || !Number.isFinite(Number(id)) || Number(id) <= 0) return;
|
|
16
|
+
const machineCode = discount.data?.discount_card_list?.[0] || discount.discount_card_list?.[0] || discount.machinecode || discount.machine_code || discount;
|
|
17
|
+
const code = machineCode.encoded || discount.metadata?.encoded;
|
|
18
|
+
const previous = selections.get(id);
|
|
19
|
+
selections.set(id, {
|
|
20
|
+
id,
|
|
21
|
+
code: typeof code === 'string' && code.trim() ? code.trim() : previous?.code,
|
|
22
|
+
selected: line || discount.isSelected !== false,
|
|
23
|
+
isScan: Boolean(discount.isScan || previous?.isScan)
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
// Old venue drafts may have lost the root list on reload, while line discounts retain the code.
|
|
27
|
+
for (const product of order.products || []) {
|
|
28
|
+
for (const discount of product.discount_list || []) append(discount, true);
|
|
29
|
+
for (const bundle of product.product_bundle || []) {
|
|
30
|
+
for (const discount of bundle.discount_list || []) append(discount, true);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
for (const discount of order.discount_list || []) append(discount);
|
|
34
|
+
for (const discount of runtime || []) append(discount);
|
|
35
|
+
return [...selections.values()];
|
|
36
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type DraftDiscountSelection } from './draftDiscounts';
|
|
1
2
|
import type { Module, ModuleOptions, PisellCore } from '../../types';
|
|
2
3
|
import type { ProductData } from '../../modules';
|
|
3
4
|
import type { BookingCalcContext } from '../../modules/BookingContext';
|
|
@@ -195,6 +196,12 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
195
196
|
protected getRegisteredModuleNames(): readonly string[];
|
|
196
197
|
protected createSubModule(moduleName: string): Module | null;
|
|
197
198
|
addNewOrder(): Promise<import("../../modules/Order/types").OrderTempOrder>;
|
|
199
|
+
getDraftDiscountSelection(): DraftDiscountSelection[];
|
|
200
|
+
/** Restore a local draft's cards as editable runtime entries, never as settled historical cards. */
|
|
201
|
+
restoreDraftDiscountSelection(snapshot: {
|
|
202
|
+
order: Record<string, any>;
|
|
203
|
+
discountSelection?: DraftDiscountSelection[];
|
|
204
|
+
}): Promise<void>;
|
|
198
205
|
syncAuthenticatedOrderCustomer(): Promise<boolean>;
|
|
199
206
|
private isAuthenticatedCustomerUserPlatform;
|
|
200
207
|
private resolveDiscountOrderIdentity;
|