@pisell/pisellos 2.3.232 → 2.3.234
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 +4 -0
- package/dist/modules/Order/index.d.ts +10 -0
- package/dist/modules/Order/index.js +1392 -1157
- package/dist/modules/Order/types.d.ts +3 -0
- package/dist/modules/Order/utils/bookingUuid.d.ts +4 -0
- package/dist/modules/Order/utils/bookingUuid.js +24 -0
- package/dist/modules/Order/utils/virtualSettlement.d.ts +4 -0
- package/dist/modules/Order/utils/virtualSettlement.js +13 -0
- package/dist/modules/Order/utils.d.ts +1 -0
- package/dist/modules/Order/utils.js +12 -6
- package/dist/shared/payment/loadPaymentMethods.d.ts +5 -1
- package/dist/shared/payment/loadPaymentMethods.js +36 -2
- package/dist/solution/BaseSales/index.d.ts +4 -0
- package/dist/solution/BaseSales/index.js +571 -435
- package/dist/solution/BookingTicket/index.d.ts +3 -1
- package/dist/solution/BookingTicket/index.js +49 -43
- package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +1 -0
- package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +1 -1
- package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +69 -13
- package/dist/solution/Checkout/index.js +104 -69
- package/dist/solution/Checkout/types.d.ts +1 -0
- package/dist/solution/ScanOrder/index.js +10 -2
- package/dist/solution/VenueBooking/index.js +522 -490
- package/dist/utils/platform.d.ts +3 -0
- package/dist/utils/platform.js +8 -0
- package/lib/modules/Customer/types.d.ts +4 -0
- package/lib/modules/Order/index.d.ts +10 -0
- package/lib/modules/Order/index.js +155 -20
- package/lib/modules/Order/types.d.ts +3 -0
- package/lib/modules/Order/utils/bookingUuid.d.ts +4 -0
- package/lib/modules/Order/utils/bookingUuid.js +25 -0
- package/lib/modules/Order/utils/virtualSettlement.d.ts +4 -0
- package/lib/modules/Order/utils/virtualSettlement.js +9 -1
- package/lib/modules/Order/utils.d.ts +1 -0
- package/lib/modules/Order/utils.js +14 -5
- package/lib/shared/payment/loadPaymentMethods.d.ts +5 -1
- package/lib/shared/payment/loadPaymentMethods.js +14 -0
- package/lib/solution/BaseSales/index.d.ts +4 -0
- package/lib/solution/BaseSales/index.js +78 -16
- package/lib/solution/BookingTicket/index.d.ts +3 -1
- package/lib/solution/BookingTicket/index.js +4 -1
- package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +1 -0
- package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +1 -1
- package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +44 -5
- package/lib/solution/Checkout/index.js +21 -0
- package/lib/solution/Checkout/types.d.ts +1 -0
- package/lib/solution/ScanOrder/index.js +6 -0
- package/lib/solution/VenueBooking/index.js +6 -1
- package/lib/utils/platform.d.ts +3 -0
- package/lib/utils/platform.js +10 -0
- package/package.json +1 -1
package/dist/utils/platform.d.ts
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
* Normalize the runtime platform passed through solution/module otherParams.
|
|
3
3
|
*/
|
|
4
4
|
export declare function normalizeRuntimePlatform(platform: unknown): string;
|
|
5
|
+
export declare function isPosTerminalPlatform(platform: unknown): boolean;
|
|
6
|
+
export type TerminalVirtualCurrencyChannel = 'pos' | 'kiosk';
|
|
7
|
+
export declare function resolveTerminalVirtualCurrencyChannel(platform: unknown, businessCode: unknown): TerminalVirtualCurrencyChannel | undefined;
|
|
5
8
|
/**
|
|
6
9
|
* PC and H5 are authenticated-customer clients rather than staff terminals.
|
|
7
10
|
*/
|
package/dist/utils/platform.js
CHANGED
|
@@ -7,6 +7,14 @@ var SELF_SERVICE_PLATFORMS = new Set(['kiosk', 'vending']);
|
|
|
7
7
|
export function normalizeRuntimePlatform(platform) {
|
|
8
8
|
return String(platform !== null && platform !== void 0 ? platform : '').trim().toLowerCase();
|
|
9
9
|
}
|
|
10
|
+
export function isPosTerminalPlatform(platform) {
|
|
11
|
+
var normalized = normalizeRuntimePlatform(platform);
|
|
12
|
+
return normalized === 'pos' || normalized === 'webpos';
|
|
13
|
+
}
|
|
14
|
+
export function resolveTerminalVirtualCurrencyChannel(platform, businessCode) {
|
|
15
|
+
if (isPosTerminalPlatform(platform)) return 'pos';
|
|
16
|
+
if (normalizeRuntimePlatform(platform) === 'kiosk' && businessCode === 'retail') return 'kiosk';
|
|
17
|
+
}
|
|
10
18
|
|
|
11
19
|
/**
|
|
12
20
|
* PC and H5 are authenticated-customer clients rather than staff terminals.
|
|
@@ -44,6 +44,10 @@ 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;
|
|
47
51
|
/** 关联查询参数 */
|
|
48
52
|
with?: CustomerWith[];
|
|
49
53
|
/** wallet搜索标识 */
|
|
@@ -7,6 +7,8 @@ import { type PickupTimingBooking, type PickupTimingBookingInput } from './picku
|
|
|
7
7
|
import { type ProductVoucherGroup } from './utils/productVoucherGroups';
|
|
8
8
|
import type { OrderAmountSnapshot, AddProductBookingInput, AddProductToOrderOptions, ReplaceBookingProductWithRelatedRetailParams, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, OrderHooksConfig, OrderCartIntentCommitContext, ReplaceTempOrderOptions, HydrateTempOrderOptions, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions, RemoveProductsFromOrderOptions, SalesNote, SalesNotesMutationSnapshot, SetSalesNoteInput, PickupReferenceMode, PointCardSnapshotMergeContext, PointCardSnapshotItem, ShopServiceData, ShopServiceType } from './types';
|
|
9
9
|
import type { ICustomer } from '../AccountList/types';
|
|
10
|
+
import { type TerminalVirtualCurrencyChannel } from '../../utils/platform';
|
|
11
|
+
import type { PaymentMethod } from '../Payment/types';
|
|
10
12
|
import type { Discount } from '../Discount/types';
|
|
11
13
|
import { UnavailableReason } from '../Rules/types';
|
|
12
14
|
export declare class OrderModule extends BaseModule implements Module, OrderModuleAPI {
|
|
@@ -35,6 +37,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
35
37
|
private moduleHooksOverride?;
|
|
36
38
|
private orderHooks?;
|
|
37
39
|
private cartCommandQueue;
|
|
40
|
+
private terminalVirtualPaymentRevision;
|
|
41
|
+
private terminalVirtualPaymentSnapshots;
|
|
38
42
|
private queueCartCommand;
|
|
39
43
|
/** Use the exact Order normalizers/merge rules on a private draft, not a second projection. */
|
|
40
44
|
private beginCartMutation;
|
|
@@ -477,6 +481,12 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
477
481
|
*/
|
|
478
482
|
private hasLinkedBookingUid;
|
|
479
483
|
private isMultiCurrencySettlementEnabled;
|
|
484
|
+
private getVirtualCurrencyPaymentChannel;
|
|
485
|
+
private getVirtualPaymentShopId;
|
|
486
|
+
syncTerminalVirtualCurrencyPaymentMethods(channel: TerminalVirtualCurrencyChannel, methods: readonly PaymentMethod[]): void;
|
|
487
|
+
getTerminalVirtualCurrencyPaymentMethod(channel: TerminalVirtualCurrencyChannel, initialMethods?: readonly PaymentMethod[]): PaymentMethod;
|
|
488
|
+
refreshTerminalVirtualCurrencyPaymentMethod(channel: TerminalVirtualCurrencyChannel): Promise<PaymentMethod>;
|
|
489
|
+
private validateTerminalVirtualCurrencyCart;
|
|
480
490
|
private isActiveVirtualSettlementOrder;
|
|
481
491
|
private shouldUseVirtualSettlementSummary;
|
|
482
492
|
private normalizeVirtualSettlementProductIfEnabled;
|
|
@@ -11,6 +11,7 @@ Object.defineProperty(exports, "isFulfillmentTimingBooking", {
|
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
13
|
var _loadSalesOrderSnapshot = require("../../shared/sales/loadSalesOrderSnapshot");
|
|
14
|
+
var _bookingUuid = require("./utils/bookingUuid");
|
|
14
15
|
var _localEftposState = require("./localEftposState");
|
|
15
16
|
var _BaseModule = require("../BaseModule");
|
|
16
17
|
var _types = require("./types");
|
|
@@ -34,6 +35,8 @@ var _bundleDiscountHydration = require("./utils/bundleDiscountHydration");
|
|
|
34
35
|
var _orderCollectionIdentity = require("./utils/orderCollectionIdentity");
|
|
35
36
|
var _discountProductLineIdentity = require("./utils/discountProductLineIdentity");
|
|
36
37
|
var _virtualSettlement = require("./utils/virtualSettlement");
|
|
38
|
+
var _loadPaymentMethods = require("../../shared/payment/loadPaymentMethods");
|
|
39
|
+
var _platform = require("../../utils/platform");
|
|
37
40
|
var _Discount = require("../Discount");
|
|
38
41
|
var _Rules = require("../Rules");
|
|
39
42
|
var _entitlementPass = require("../Discount/entitlementPass");
|
|
@@ -41,6 +44,19 @@ var _types2 = require("../Rules/types");
|
|
|
41
44
|
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
42
45
|
var _lodashEs = require("lodash-es");
|
|
43
46
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
47
|
+
const SUMMARY_LINE_FIELDS = ['tax_fee', 'original_tax_fee', 'tax_fee_rounding_remainder', 'original_tax_fee_rounding_remainder', 'surcharge_fee', 'surcharge_rounding_remainder', 'relation_surcharge_ids'];
|
|
48
|
+
const SUMMARY_LINE_METADATA_FIELDS = ['tax_fee_rounding_remainder', 'surcharge_rounding_remainder', 'relation_surcharge_ids'];
|
|
49
|
+
function getFixedGiftProductSnapshot(product) {
|
|
50
|
+
// 赠品预约等待期间,recalculateSummary 可以更新金额字段。赠品写回后会重新计算这些金额。
|
|
51
|
+
return {
|
|
52
|
+
...(0, _lodashEs.omit)(product, [...SUMMARY_LINE_FIELDS, 'main_product_attached_bundle_tax_fee', 'main_product_attached_bundle_surcharge_fee', 'payment_price', 'deposit']),
|
|
53
|
+
metadata: (0, _lodashEs.omit)(product.metadata, [...SUMMARY_LINE_METADATA_FIELDS, 'main_product_attached_bundle_tax_fee', 'main_product_attached_bundle_surcharge_fee', 'main_product_attached_bundle_selling_price', 'main_product_attached_bundle_payment_price', 'average_discount_amount_rate']),
|
|
54
|
+
product_bundle: Array.isArray(product.product_bundle) ? product.product_bundle.map(bundle => ({
|
|
55
|
+
...(0, _lodashEs.omit)(bundle, [...SUMMARY_LINE_FIELDS, 'bundle_payment_price']),
|
|
56
|
+
metadata: (0, _lodashEs.omit)(bundle?.metadata, [...SUMMARY_LINE_METADATA_FIELDS, 'surcharge_fee'])
|
|
57
|
+
})) : product.product_bundle
|
|
58
|
+
};
|
|
59
|
+
}
|
|
44
60
|
function normalizeDiscountListSignature(discountList) {
|
|
45
61
|
return (discountList || []).map(item => ({
|
|
46
62
|
type: item?.type ?? '',
|
|
@@ -154,6 +170,8 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
154
170
|
moduleHooksOverride;
|
|
155
171
|
orderHooks;
|
|
156
172
|
cartCommandQueue = Promise.resolve();
|
|
173
|
+
terminalVirtualPaymentRevision = 0;
|
|
174
|
+
terminalVirtualPaymentSnapshots = new Map();
|
|
157
175
|
queueCartCommand(run) {
|
|
158
176
|
if (!this.orderHooks?.onBeforeCartCommit && !this.store.tempOrder?._extend?.productVoucherGroups?.length) return run();
|
|
159
177
|
const pending = this.cartCommandQueue.then(run, run);
|
|
@@ -1112,10 +1130,16 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
1112
1130
|
// 唯一候选也可能有规格/套餐。每次补赠都交给 SDK 判断,不能复用旧赠品的选择。
|
|
1113
1131
|
|
|
1114
1132
|
const fixedGiftQuotas = addAction.giftQuotas;
|
|
1115
|
-
const
|
|
1116
|
-
products: tempOrder.products,
|
|
1117
|
-
bookings: tempOrder.bookings
|
|
1118
|
-
|
|
1133
|
+
const getGiftMutationState = () => ({
|
|
1134
|
+
products: fixedGiftQuotas ? tempOrder.products.map(getFixedGiftProductSnapshot) : tempOrder.products,
|
|
1135
|
+
bookings: tempOrder.bookings,
|
|
1136
|
+
...(fixedGiftQuotas && {
|
|
1137
|
+
holderRelations: tempOrder.holder_relations,
|
|
1138
|
+
shopDiscount: tempOrder.shop_discount
|
|
1139
|
+
})
|
|
1140
|
+
});
|
|
1141
|
+
const giftMutationBaseline = options?.isCurrentOrder || fixedGiftQuotas ? (0, _lodashEs.cloneDeep)(getGiftMutationState()) : null;
|
|
1142
|
+
const isGiftDraftCurrent = () => isCurrentOrder() && (!giftMutationBaseline || (0, _lodashEs.isEqual)(getGiftMutationState(), giftMutationBaseline));
|
|
1119
1143
|
try {
|
|
1120
1144
|
const inventoryProducts = fixedGiftQuotas ? nextOrder.products : tempOrder.products;
|
|
1121
1145
|
const giftResult = await giftSelectResolver({
|
|
@@ -1126,11 +1150,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
1126
1150
|
quantity: Number(line.num) || 0
|
|
1127
1151
|
}))
|
|
1128
1152
|
});
|
|
1129
|
-
if (!
|
|
1130
|
-
if (giftMutationBaseline && !(0, _lodashEs.isEqual)({
|
|
1131
|
-
products: tempOrder.products,
|
|
1132
|
-
bookings: tempOrder.bookings
|
|
1133
|
-
}, giftMutationBaseline)) return null;
|
|
1153
|
+
if (!isGiftDraftCurrent()) return null;
|
|
1134
1154
|
const giftProducts = Array.isArray(giftResult) ? giftResult : giftResult?.products;
|
|
1135
1155
|
const giftBookings = Array.isArray(giftResult) ? [] : giftResult?.bookings || [];
|
|
1136
1156
|
if (Array.isArray(giftProducts) && giftProducts.length > 0) {
|
|
@@ -1179,11 +1199,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
1179
1199
|
publishGiftChanges();
|
|
1180
1200
|
}
|
|
1181
1201
|
} catch (error) {
|
|
1182
|
-
if (!
|
|
1183
|
-
if (giftMutationBaseline && !(0, _lodashEs.isEqual)({
|
|
1184
|
-
products: tempOrder.products,
|
|
1185
|
-
bookings: tempOrder.bookings
|
|
1186
|
-
}, giftMutationBaseline)) return null;
|
|
1202
|
+
if (!isGiftDraftCurrent()) return null;
|
|
1187
1203
|
// 用户取消 / 选择失败 → 视为放弃本次新增
|
|
1188
1204
|
console.warn('[OrderModule] giftSelectResolver rejected, skip add gift', addAction.strategyId, error);
|
|
1189
1205
|
}
|
|
@@ -2655,7 +2671,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
2655
2671
|
booking_uid: bookingUid
|
|
2656
2672
|
},
|
|
2657
2673
|
booking: {
|
|
2658
|
-
...params.booking,
|
|
2674
|
+
...(0, _bookingUuid.ensureBookingUuid)(params.booking),
|
|
2659
2675
|
is_all: (0, _utils.normalizeBookingIsAll)(params.booking),
|
|
2660
2676
|
product_uid: productUid,
|
|
2661
2677
|
sub_type: (0, _utils.normalizeBookingSubType)(params.booking),
|
|
@@ -3270,7 +3286,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3270
3286
|
const tempOrder = this.ensureTempOrder();
|
|
3271
3287
|
const bookings = tempOrder.bookings || [];
|
|
3272
3288
|
const firstIndex = bookings.findIndex(_pickupTiming.isFulfillmentTimingBooking);
|
|
3273
|
-
const nextBooking = (0, _pickupTiming.buildPickupTimingBooking)(input, bookings[firstIndex]);
|
|
3289
|
+
const nextBooking = (0, _bookingUuid.ensureBookingUuid)((0, _pickupTiming.buildPickupTimingBooking)(input, bookings[firstIndex]));
|
|
3274
3290
|
// Keep the first row's identity and position; repair duplicate marked rows only.
|
|
3275
3291
|
tempOrder.bookings = firstIndex === -1 ? [...bookings, nextBooking] : bookings.flatMap((booking, index) => index === firstIndex ? [nextBooking] : (0, _pickupTiming.isFulfillmentTimingBooking)(booking) ? [] : [booking]);
|
|
3276
3292
|
this.notifyTempOrderChanged();
|
|
@@ -3802,6 +3818,64 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3802
3818
|
isMultiCurrencySettlementEnabled() {
|
|
3803
3819
|
return this.otherParams?.enableMultiCurrencySettlement === true;
|
|
3804
3820
|
}
|
|
3821
|
+
getVirtualCurrencyPaymentChannel() {
|
|
3822
|
+
if (!this.isMultiCurrencySettlementEnabled()) return undefined;
|
|
3823
|
+
return (0, _platform.resolveTerminalVirtualCurrencyChannel)(this.otherParams?.platform, this.otherParams?.businessCode ?? this.otherParams?.business_code);
|
|
3824
|
+
}
|
|
3825
|
+
getVirtualPaymentShopId() {
|
|
3826
|
+
return String(this.core?.context?.getData?.('shop_id') ?? '');
|
|
3827
|
+
}
|
|
3828
|
+
syncTerminalVirtualCurrencyPaymentMethods(channel, methods) {
|
|
3829
|
+
const shopId = this.getVirtualPaymentShopId();
|
|
3830
|
+
const sourceShopId = methods.find(method => Number(method?.shop_id) > 0)?.shop_id;
|
|
3831
|
+
if (shopId && sourceShopId != null && String(sourceShopId) !== shopId) return;
|
|
3832
|
+
this.terminalVirtualPaymentSnapshots.set(channel, {
|
|
3833
|
+
shopId,
|
|
3834
|
+
methods,
|
|
3835
|
+
revision: ++this.terminalVirtualPaymentRevision
|
|
3836
|
+
});
|
|
3837
|
+
}
|
|
3838
|
+
getTerminalVirtualCurrencyPaymentMethod(channel, initialMethods = []) {
|
|
3839
|
+
const shopId = this.getVirtualPaymentShopId();
|
|
3840
|
+
const snapshot = this.terminalVirtualPaymentSnapshots.get(channel);
|
|
3841
|
+
return (0, _loadPaymentMethods.requireTerminalVirtualCurrencyPaymentMethod)(snapshot?.shopId === shopId ? snapshot.methods : initialMethods, channel, shopId);
|
|
3842
|
+
}
|
|
3843
|
+
async refreshTerminalVirtualCurrencyPaymentMethod(channel) {
|
|
3844
|
+
const shopId = this.getVirtualPaymentShopId();
|
|
3845
|
+
const revision = ++this.terminalVirtualPaymentRevision;
|
|
3846
|
+
const publish = methods => {
|
|
3847
|
+
const snapshot = this.terminalVirtualPaymentSnapshots.get(channel);
|
|
3848
|
+
// A slow lookup must not overwrite a newer lookup or payment methods event.
|
|
3849
|
+
if (snapshot?.shopId !== shopId || snapshot.revision < revision) {
|
|
3850
|
+
this.terminalVirtualPaymentSnapshots.set(channel, {
|
|
3851
|
+
shopId,
|
|
3852
|
+
methods,
|
|
3853
|
+
revision
|
|
3854
|
+
});
|
|
3855
|
+
}
|
|
3856
|
+
};
|
|
3857
|
+
let methods;
|
|
3858
|
+
try {
|
|
3859
|
+
methods = await (0, _loadPaymentMethods.loadPaymentMethods)(this.request, {
|
|
3860
|
+
transport: 'remote',
|
|
3861
|
+
filterPaymentMethods: false
|
|
3862
|
+
});
|
|
3863
|
+
} catch (error) {
|
|
3864
|
+
if (channel === 'kiosk' && shopId === this.getVirtualPaymentShopId()) publish([]);
|
|
3865
|
+
throw error;
|
|
3866
|
+
}
|
|
3867
|
+
if (shopId !== this.getVirtualPaymentShopId()) {
|
|
3868
|
+
throw new Error('[Order] Payment methods belong to a previous shop');
|
|
3869
|
+
}
|
|
3870
|
+
publish(methods);
|
|
3871
|
+
return this.getTerminalVirtualCurrencyPaymentMethod(channel);
|
|
3872
|
+
}
|
|
3873
|
+
async validateTerminalVirtualCurrencyCart(order, channel) {
|
|
3874
|
+
await this.refreshTerminalVirtualCurrencyPaymentMethod(channel);
|
|
3875
|
+
if (this.getTempOrder() !== order || this.getVirtualCurrencyPaymentChannel() !== channel) {
|
|
3876
|
+
throw new Error('[Order] Cart intent belongs to a previous order or business');
|
|
3877
|
+
}
|
|
3878
|
+
}
|
|
3805
3879
|
isActiveVirtualSettlementOrder(tempOrder) {
|
|
3806
3880
|
return this.isMultiCurrencySettlementEnabled() && (0, _virtualSettlement.isVirtualSettlementOrder)(tempOrder);
|
|
3807
3881
|
}
|
|
@@ -3922,6 +3996,16 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3922
3996
|
* if (pending) await pending;
|
|
3923
3997
|
*/
|
|
3924
3998
|
appendProductLineToTempOrder(tempOrder, product, booking, options) {
|
|
3999
|
+
const incomingBookingUuid = booking?.uuid;
|
|
4000
|
+
if (booking && incomingBookingUuid && tempOrder.bookings?.some(item => item.uuid === incomingBookingUuid)) {
|
|
4001
|
+
// Appending a copy creates a different booking; editing uses the update path below.
|
|
4002
|
+
booking = {
|
|
4003
|
+
...booking,
|
|
4004
|
+
uuid: (0, _utils.createUuidV4)(),
|
|
4005
|
+
id: undefined,
|
|
4006
|
+
schedule_event_id: undefined
|
|
4007
|
+
};
|
|
4008
|
+
}
|
|
3925
4009
|
const linked = booking ? this.createLinkedProductAndBooking({
|
|
3926
4010
|
product,
|
|
3927
4011
|
booking
|
|
@@ -4086,6 +4170,12 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4086
4170
|
singleLine.num = 1;
|
|
4087
4171
|
delete singleLine.product_quantity;
|
|
4088
4172
|
const singleBooking = (0, _lodashEs.cloneDeep)(booking);
|
|
4173
|
+
if (index > 0) {
|
|
4174
|
+
// Both single-add and batch-add quantity splits create separate appointments.
|
|
4175
|
+
delete singleBooking.uuid;
|
|
4176
|
+
delete singleBooking.schedule_event_id;
|
|
4177
|
+
delete singleBooking.id;
|
|
4178
|
+
}
|
|
4089
4179
|
const bookingHolder = booking?.holder && typeof booking.holder === 'object' ? booking.holder : null;
|
|
4090
4180
|
const metadataHolder = booking?.metadata?.holder && typeof booking.metadata.holder === 'object' ? booking.metadata.holder : null;
|
|
4091
4181
|
const rawHolderIds = bookingHolder?.form_record ?? booking?.metadata?.holder_id ?? metadataHolder?.form_record ?? product?.metadata?.holder_id;
|
|
@@ -4153,6 +4243,11 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4153
4243
|
availabilityCommitGuard?.();
|
|
4154
4244
|
const liveTempOrder = this.ensureTempOrder();
|
|
4155
4245
|
const beforeCommit = this.createCartIntentCommitGuard('add_product', liveTempOrder);
|
|
4246
|
+
const virtualPaymentChannel = this.getVirtualCurrencyPaymentChannel();
|
|
4247
|
+
if (virtualPaymentChannel && (0, _virtualSettlement.isVirtualSettlementProduct)(product)) {
|
|
4248
|
+
await this.validateTerminalVirtualCurrencyCart(liveTempOrder, virtualPaymentChannel);
|
|
4249
|
+
availabilityCommitGuard?.();
|
|
4250
|
+
}
|
|
4156
4251
|
const mutation = this.beginCartMutation();
|
|
4157
4252
|
// 库存/商品券校验与自动预约共用草稿,全部门禁通过后才发布完整批次。
|
|
4158
4253
|
const tempOrder = availabilityCommitGuard && !mutation.commit ? (0, _lodashEs.cloneDeep)(liveTempOrder) : mutation.draft;
|
|
@@ -4336,7 +4431,8 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4336
4431
|
const target = live.products[targetIndex];
|
|
4337
4432
|
const scopeKey = String(target?.metadata?.venue_booking_scope_key || '');
|
|
4338
4433
|
const targetBookingUid = String(target?.booking_uid || target?.metadata?.booking_uid || '');
|
|
4339
|
-
|
|
4434
|
+
const targetBookings = (live.bookings || []).filter(row => this.getBookingUniqueIdentificationNumber(row) === targetBookingUid);
|
|
4435
|
+
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) {
|
|
4340
4436
|
throw new Error('[Order] Party replacement requires one unsubmitted, unpaid main booking in the same scope');
|
|
4341
4437
|
}
|
|
4342
4438
|
const children = live.products.filter(line => line.metadata?.venue_booking_role === 'party_extra' && String(line.metadata?.venue_booking_parent_uid || '') === uid);
|
|
@@ -4396,7 +4492,9 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4396
4492
|
venue_booking_service_datetime: serviceDatetime
|
|
4397
4493
|
};
|
|
4398
4494
|
replacement.unique_identification_number = uid;
|
|
4399
|
-
|
|
4495
|
+
const replacementBooking = (0, _lodashEs.cloneDeep)(params.booking);
|
|
4496
|
+
replacementBooking.uuid = targetBookings[0].uuid || replacementBooking.uuid;
|
|
4497
|
+
await this.appendProductLineToTempOrder(draft, replacement, replacementBooking, {
|
|
4400
4498
|
insertAtIndex: targetIndex,
|
|
4401
4499
|
disableMerge: true,
|
|
4402
4500
|
beforeCommit
|
|
@@ -4463,6 +4561,12 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4463
4561
|
if (!Array.isArray(items) || items.length === 0) return tempOrder.products;
|
|
4464
4562
|
const beforeCommit = this.createCartIntentCommitGuard('add_product');
|
|
4465
4563
|
const beforeAppend = mutation.commit ? undefined : beforeCommit;
|
|
4564
|
+
const virtualPaymentChannel = this.getVirtualCurrencyPaymentChannel();
|
|
4565
|
+
if (virtualPaymentChannel && items.some(({
|
|
4566
|
+
product
|
|
4567
|
+
}) => product && (0, _virtualSettlement.isVirtualSettlementProduct)(product))) {
|
|
4568
|
+
await this.validateTerminalVirtualCurrencyCart(this.ensureTempOrder(), virtualPaymentChannel);
|
|
4569
|
+
}
|
|
4466
4570
|
for (const item of items || []) {
|
|
4467
4571
|
const {
|
|
4468
4572
|
product,
|
|
@@ -4804,12 +4908,22 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4804
4908
|
...(normalizedProduct.metadata || {}),
|
|
4805
4909
|
unique_identification_number: productUid
|
|
4806
4910
|
};
|
|
4911
|
+
const originalBookingUid = targetProduct.booking_uid || targetProduct.metadata?.booking_uid || preservedBookingUid;
|
|
4912
|
+
const bookings = tempOrder.bookings || [];
|
|
4913
|
+
const eventId = booking.schedule_event_id;
|
|
4914
|
+
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);
|
|
4915
|
+
const {
|
|
4916
|
+
uuid: incomingUuid = originalBooking?.uuid
|
|
4917
|
+
} = booking;
|
|
4807
4918
|
const linked = this.createLinkedProductAndBooking({
|
|
4808
4919
|
product: {
|
|
4809
4920
|
...normalizedProduct,
|
|
4810
4921
|
unique_identification_number: productUid
|
|
4811
4922
|
},
|
|
4812
|
-
booking
|
|
4923
|
+
booking: {
|
|
4924
|
+
...booking,
|
|
4925
|
+
uuid: originalBooking?.uuid || incomingUuid
|
|
4926
|
+
}
|
|
4813
4927
|
});
|
|
4814
4928
|
this.removeLinkedBookingsForProduct(tempOrder, targetProduct);
|
|
4815
4929
|
normalizedProduct = {
|
|
@@ -5026,6 +5140,18 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
5026
5140
|
}
|
|
5027
5141
|
}
|
|
5028
5142
|
const beforeCommit = normalizedProduct.num > targetProduct.num ? this.createCartIntentCommitGuard('increase_quantity') : undefined;
|
|
5143
|
+
const virtualPaymentChannel = this.getVirtualCurrencyPaymentChannel();
|
|
5144
|
+
if (beforeCommit && virtualPaymentChannel && (0, _virtualSettlement.isVirtualSettlementProduct)(normalizedProduct)) {
|
|
5145
|
+
const liveOrder = this.ensureTempOrder();
|
|
5146
|
+
const products = (0, _lodashEs.cloneDeep)(liveOrder.products);
|
|
5147
|
+
const customerId = liveOrder.customer_id;
|
|
5148
|
+
await this.validateTerminalVirtualCurrencyCart(liveOrder, virtualPaymentChannel);
|
|
5149
|
+
if (liveOrder.customer_id !== customerId || !(0, _lodashEs.isEqual)(liveOrder.products, products)) {
|
|
5150
|
+
throw Object.assign(new Error('The cart changed. Please try again.'), {
|
|
5151
|
+
code: 'SALES_GUARD_REJECTED'
|
|
5152
|
+
});
|
|
5153
|
+
}
|
|
5154
|
+
}
|
|
5029
5155
|
if (!mutation.commit) beforeCommit?.();
|
|
5030
5156
|
if (isCurrentOrder && !isCurrentOrder()) return tempOrder.products;
|
|
5031
5157
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
@@ -5071,9 +5197,13 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
5071
5197
|
throw new Error('[Order] 目标 booking 不存在,无法更新');
|
|
5072
5198
|
}
|
|
5073
5199
|
const targetBooking = tempOrder.bookings[bookingIndex] || {};
|
|
5200
|
+
const {
|
|
5201
|
+
uuid: incomingUuid = targetBooking.uuid
|
|
5202
|
+
} = updates;
|
|
5074
5203
|
const nextBooking = {
|
|
5075
5204
|
...targetBooking,
|
|
5076
5205
|
...updates,
|
|
5206
|
+
uuid: targetBooking.uuid || incomingUuid,
|
|
5077
5207
|
metadata: {
|
|
5078
5208
|
...(targetBooking.metadata || {}),
|
|
5079
5209
|
...(updates.metadata || {}),
|
|
@@ -5083,6 +5213,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
5083
5213
|
unique_identification_number: bookingUid
|
|
5084
5214
|
}
|
|
5085
5215
|
};
|
|
5216
|
+
(0, _bookingUuid.assignBookingUuid)(nextBooking);
|
|
5086
5217
|
this.syncBookingMetadataHolder(nextBooking, nextBooking.metadata);
|
|
5087
5218
|
nextBooking.is_all = (0, _utils.normalizeBookingIsAll)(nextBooking);
|
|
5088
5219
|
nextBooking.sub_type = (0, _utils.normalizeBookingSubType)(nextBooking);
|
|
@@ -5454,6 +5585,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
5454
5585
|
summary: latestSummary,
|
|
5455
5586
|
request_unique_idempotency_token: params?.request_unique_idempotency_token,
|
|
5456
5587
|
includePaymentStatus: !isOnlineStorePlatform,
|
|
5588
|
+
enableMultiCurrencySettlement: this.isMultiCurrencySettlementEnabled(),
|
|
5457
5589
|
enhance: enhancePayload
|
|
5458
5590
|
});
|
|
5459
5591
|
if (params?.syncMode) {
|
|
@@ -5784,6 +5916,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
5784
5916
|
* @returns 后端返回的订单数据(包含订单ID等)
|
|
5785
5917
|
*/
|
|
5786
5918
|
async createOrderByCheckout(params) {
|
|
5919
|
+
params.bookings?.forEach(_bookingUuid.assignBookingUuid);
|
|
5787
5920
|
// 过滤掉由在线店铺下单的 payment 支付数据
|
|
5788
5921
|
const onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
|
|
5789
5922
|
params.payments = params.payments?.filter(p => !onlineStorePaymentCodeList.includes(p.code));
|
|
@@ -5871,6 +6004,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
5871
6004
|
url,
|
|
5872
6005
|
query
|
|
5873
6006
|
} = params;
|
|
6007
|
+
query.bookings?.forEach(_bookingUuid.assignBookingUuid);
|
|
5874
6008
|
const fetchUrl = url || '/order/sales/checkout';
|
|
5875
6009
|
const handledByOsServer = this.isSalesCheckoutHandledByOsServer(fetchUrl);
|
|
5876
6010
|
const requestQuery = handledByOsServer ? query : (0, _localEftposState.stripLocalEftposState)((0, _osPrivatePayload.stripOsPrivatePayloadFields)(query));
|
|
@@ -6225,8 +6359,9 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
6225
6359
|
})) : [];
|
|
6226
6360
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(b => {
|
|
6227
6361
|
const booking = this.normalizeHydratedBookingHolder(b || {});
|
|
6362
|
+
const submitted = (0, _pickupTiming.isFulfillmentTimingBooking)(booking) || Number(booking.parent_id) !== 0;
|
|
6228
6363
|
return {
|
|
6229
|
-
...booking,
|
|
6364
|
+
...(submitted ? (0, _bookingUuid.ensureBookingUuid)(booking) : booking),
|
|
6230
6365
|
is_all: (0, _utils.normalizeBookingIsAll)(booking),
|
|
6231
6366
|
sub_type: (0, _utils.normalizeBookingSubType)(booking)
|
|
6232
6367
|
};
|
|
@@ -419,6 +419,7 @@ export interface OrderSubmitPayload extends Omit<OrderTempOrder, 'platform' | 'p
|
|
|
419
419
|
products: OrderSubmitProduct[];
|
|
420
420
|
notes?: SalesNoteProtocol[];
|
|
421
421
|
summary?: OrderSummary;
|
|
422
|
+
product_tax_fee?: string;
|
|
422
423
|
small_ticket_data_flag?: number;
|
|
423
424
|
}
|
|
424
425
|
export interface OrderState {
|
|
@@ -596,6 +597,8 @@ export interface CommitOrderParams {
|
|
|
596
597
|
};
|
|
597
598
|
}
|
|
598
599
|
export interface OrderSubmitBooking {
|
|
600
|
+
/** Stable booking identity, created once and shared with external allocations. */
|
|
601
|
+
uuid?: string | null;
|
|
599
602
|
relation_id?: string;
|
|
600
603
|
form_id?: string;
|
|
601
604
|
collect_pax?: number;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Cross-system booking identity; independent from the legacy cart-line UID. */
|
|
2
|
+
export declare function ensureBookingUuid<T extends Record<string, any>>(booking: T): T;
|
|
3
|
+
/** Retain a generated UUID on the draft so a checkout retry sends the same value. */
|
|
4
|
+
export declare function assignBookingUuid(booking: Record<string, any> | null | undefined): void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.assignBookingUuid = assignBookingUuid;
|
|
7
|
+
exports.ensureBookingUuid = ensureBookingUuid;
|
|
8
|
+
var _orderCollectionIdentity = require("./orderCollectionIdentity");
|
|
9
|
+
/** Cross-system booking identity; independent from the legacy cart-line UID. */
|
|
10
|
+
function ensureBookingUuid(booking) {
|
|
11
|
+
if (booking.uuid) return booking;
|
|
12
|
+
// Only an explicit null confirms that an existing booking needs a UUID when saved.
|
|
13
|
+
if (booking.uuid !== null && Number(booking.schedule_event_id || booking.id) > 0) return booking;
|
|
14
|
+
return {
|
|
15
|
+
...booking,
|
|
16
|
+
uuid: (0, _orderCollectionIdentity.createUuidV4)()
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Retain a generated UUID on the draft so a checkout retry sends the same value. */
|
|
21
|
+
function assignBookingUuid(booking) {
|
|
22
|
+
if (!booking) return;
|
|
23
|
+
const resolved = ensureBookingUuid(booking);
|
|
24
|
+
if (resolved !== booking) booking.uuid = resolved.uuid;
|
|
25
|
+
}
|
|
@@ -36,6 +36,10 @@ export declare class VirtualCurrencyBalanceError extends Error {
|
|
|
36
36
|
readonly code = "VIRTUAL_CURRENCY_BALANCE_INSUFFICIENT";
|
|
37
37
|
constructor(balance: string, requiredAmount: string);
|
|
38
38
|
}
|
|
39
|
+
export declare class VirtualCurrencyCustomerRequiredError extends Error {
|
|
40
|
+
readonly code = "VIRTUAL_CURRENCY_CUSTOMER_REQUIRED";
|
|
41
|
+
constructor();
|
|
42
|
+
}
|
|
39
43
|
export declare function getSelectedSettlementSnapshot(product: Partial<OrderProduct> | null | undefined): SelectedSettlementSnapshot | null;
|
|
40
44
|
export declare function getTempOrderSettlementSnapshot(tempOrder: OrderTempOrder | null | undefined): SelectedSettlementSnapshot | null;
|
|
41
45
|
export declare function isVirtualSettlementProduct(product: Partial<OrderProduct> | null | undefined): boolean;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.VirtualCurrencyBalanceError = exports.VirtualCurrencyAssetNotFoundError = exports.OrderSettlementConflictError = void 0;
|
|
6
|
+
exports.VirtualCurrencyCustomerRequiredError = exports.VirtualCurrencyBalanceError = exports.VirtualCurrencyAssetNotFoundError = exports.OrderSettlementConflictError = void 0;
|
|
7
7
|
exports.applyTempOrderSettlementState = applyTempOrderSettlementState;
|
|
8
8
|
exports.buildCurrencyDisplaySnapshot = buildCurrencyDisplaySnapshot;
|
|
9
9
|
exports.getSelectedSettlementSnapshot = getSelectedSettlementSnapshot;
|
|
@@ -64,6 +64,14 @@ class VirtualCurrencyBalanceError extends Error {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
exports.VirtualCurrencyBalanceError = VirtualCurrencyBalanceError;
|
|
67
|
+
class VirtualCurrencyCustomerRequiredError extends Error {
|
|
68
|
+
code = 'VIRTUAL_CURRENCY_CUSTOMER_REQUIRED';
|
|
69
|
+
constructor() {
|
|
70
|
+
super('Select a customer before paying with virtual currency.');
|
|
71
|
+
this.name = 'VirtualCurrencyCustomerRequiredError';
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.VirtualCurrencyCustomerRequiredError = VirtualCurrencyCustomerRequiredError;
|
|
67
75
|
function getSelectedSettlementSnapshot(product) {
|
|
68
76
|
const snapshot = product?.metadata?.selected_settlement_snapshot;
|
|
69
77
|
if (!snapshot || typeof snapshot !== 'object') return null;
|
|
@@ -257,6 +257,7 @@ export declare function buildSubmitPayload(params: {
|
|
|
257
257
|
summary?: OrderSummary | null;
|
|
258
258
|
request_unique_idempotency_token?: string;
|
|
259
259
|
includePaymentStatus?: boolean;
|
|
260
|
+
enableMultiCurrencySettlement?: boolean;
|
|
260
261
|
enhance?: SubmitPayloadEnhancer;
|
|
261
262
|
}): OrderSubmitPayload;
|
|
262
263
|
export declare function mapPaymentItemToOrderPayment(paymentItem: OrderPaymentSource): OrderPaymentData;
|
|
@@ -138,8 +138,10 @@ var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
|
138
138
|
var _weighedProduct = require("./utils/weighedProduct");
|
|
139
139
|
var _manualProductDiscount = require("./utils/manualProductDiscount");
|
|
140
140
|
var _utils = require("../Holder/utils");
|
|
141
|
+
var _platform = require("../../utils/platform");
|
|
141
142
|
var _utils2 = require("../../solution/ScanOrder/utils");
|
|
142
143
|
var _orderCollectionIdentity = require("./utils/orderCollectionIdentity");
|
|
144
|
+
var _bookingUuid = require("./utils/bookingUuid");
|
|
143
145
|
var _salesNotes = require("./salesNotes");
|
|
144
146
|
var _pickupTiming = require("./pickupTiming");
|
|
145
147
|
var _holderRelations = require("./holderRelations");
|
|
@@ -1664,7 +1666,10 @@ function buildSubmitPayload(params) {
|
|
|
1664
1666
|
delivery_type: tempOrder.delivery_type || 'shop_service',
|
|
1665
1667
|
schedule_date: scheduleDate,
|
|
1666
1668
|
// created_at: tempOrder.created_at || formatDateTime(now), 和后端协定这个字段先不提交到接口
|
|
1667
|
-
bookings: (tempOrder.bookings || []).filter(booking => (0, _pickupTiming.isFulfillmentTimingBooking)(booking) || Number(booking.parent_id) !== 0).map(booking =>
|
|
1669
|
+
bookings: (tempOrder.bookings || []).filter(booking => (0, _pickupTiming.isFulfillmentTimingBooking)(booking) || Number(booking.parent_id) !== 0).map(booking => {
|
|
1670
|
+
(0, _bookingUuid.assignBookingUuid)(booking);
|
|
1671
|
+
return normalizeSubmitBooking(booking);
|
|
1672
|
+
}),
|
|
1668
1673
|
payments: tempOrder.payments || [],
|
|
1669
1674
|
relation_forms: tempOrder.relation_forms || [],
|
|
1670
1675
|
// contacts: tempOrder.contacts || [],
|
|
@@ -1696,15 +1701,19 @@ function buildSubmitPayload(params) {
|
|
|
1696
1701
|
order_meta_list: normalizedOrderMetaList
|
|
1697
1702
|
} : {})
|
|
1698
1703
|
};
|
|
1699
|
-
|
|
1700
|
-
const enhancedPayload = enhance(payload, {
|
|
1704
|
+
const enhancedPayload = enhance?.(payload, {
|
|
1701
1705
|
tempOrder,
|
|
1702
1706
|
bookingUuid,
|
|
1703
1707
|
now
|
|
1704
|
-
});
|
|
1708
|
+
}) ?? payload;
|
|
1709
|
+
const submitSummary = enhancedPayload.summary ?? payload.summary;
|
|
1710
|
+
const retailKioskSettlement = params.enableMultiCurrencySettlement === true && (0, _platform.resolveTerminalVirtualCurrencyChannel)(enhancedPayload.platform, resolvedBusinessCode) === 'kiosk';
|
|
1705
1711
|
return {
|
|
1706
1712
|
...enhancedPayload,
|
|
1707
|
-
summary:
|
|
1713
|
+
summary: submitSummary,
|
|
1714
|
+
...((0, _platform.isPosTerminalPlatform)(enhancedPayload.platform) || retailKioskSettlement ? {
|
|
1715
|
+
product_tax_fee: virtualSettlementMode ? '0.00' : submitSummary?.tax_fee ?? '0.00'
|
|
1716
|
+
} : {})
|
|
1708
1717
|
};
|
|
1709
1718
|
}
|
|
1710
1719
|
function mapPaymentItemToOrderPayment(paymentItem) {
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import type { RequestPlugin } from '../../plugins/request';
|
|
2
2
|
import type { PaymentMethod } from '../../modules/Payment/types';
|
|
3
|
+
import type { TerminalVirtualCurrencyChannel } from '../../utils/platform';
|
|
4
|
+
type PaymentMethodsTransport = 'remote' | 'os-server';
|
|
3
5
|
/** Shared read-only transport; customer hosts route the remote path under /h5. */
|
|
4
6
|
export declare function loadPaymentMethods(request: RequestPlugin, options: {
|
|
5
|
-
transport:
|
|
7
|
+
transport: PaymentMethodsTransport;
|
|
6
8
|
filterPaymentMethods: boolean;
|
|
7
9
|
}): Promise<PaymentMethod[]>;
|
|
10
|
+
export declare function requireTerminalVirtualCurrencyPaymentMethod(methods: readonly PaymentMethod[], channel: TerminalVirtualCurrencyChannel, shopId?: string): PaymentMethod;
|
|
8
11
|
/** Enrich a copy: never overwrite historical names or change payment amounts. */
|
|
9
12
|
export declare function withPaymentMethodNames(order: Record<string, any>, methods: PaymentMethod[]): Record<string, any>;
|
|
13
|
+
export {};
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.loadPaymentMethods = loadPaymentMethods;
|
|
7
|
+
exports.requireTerminalVirtualCurrencyPaymentMethod = requireTerminalVirtualCurrencyPaymentMethod;
|
|
7
8
|
exports.withPaymentMethodNames = withPaymentMethodNames;
|
|
8
9
|
/** Shared read-only transport; customer hosts route the remote path under /h5. */
|
|
9
10
|
async function loadPaymentMethods(request, options) {
|
|
@@ -19,6 +20,19 @@ async function loadPaymentMethods(request, options) {
|
|
|
19
20
|
if (!Array.isArray(methods)) throw new Error('Payment methods are unavailable');
|
|
20
21
|
return methods;
|
|
21
22
|
}
|
|
23
|
+
class TerminalVirtualCurrencyPaymentUnavailableError extends Error {
|
|
24
|
+
code;
|
|
25
|
+
constructor(channel) {
|
|
26
|
+
super(channel === 'kiosk' ? 'Virtual currency payment is not enabled on this Kiosk.' : 'Virtual currency payment is not enabled on this POS.');
|
|
27
|
+
this.code = channel === 'kiosk' ? 'KIOSK_VIRTUAL_CURRENCY_PAYMENT_UNAVAILABLE' : 'POS_VIRTUAL_CURRENCY_PAYMENT_UNAVAILABLE';
|
|
28
|
+
this.name = channel === 'kiosk' ? 'KioskVirtualCurrencyPaymentUnavailableError' : 'PosVirtualCurrencyPaymentUnavailableError';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function requireTerminalVirtualCurrencyPaymentMethod(methods, channel, shopId) {
|
|
32
|
+
const method = methods.find(candidate => candidate?.code === 'VIRTUALCURRENCY' && (channel === 'pos' || Boolean(shopId)) && (!shopId || candidate.shop_id == null || String(candidate.shop_id) === shopId) && candidate.status === 1 && candidate.disable === 0 && Array.isArray(candidate.channel_application) && candidate.channel_application.includes(channel));
|
|
33
|
+
if (!method) throw new TerminalVirtualCurrencyPaymentUnavailableError(channel);
|
|
34
|
+
return method;
|
|
35
|
+
}
|
|
22
36
|
|
|
23
37
|
/** Enrich a copy: never overwrite historical names or change payment amounts. */
|
|
24
38
|
function withPaymentMethodNames(order, methods) {
|
|
@@ -246,6 +246,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
246
246
|
private getPaymentNumberDevicePrefixSync;
|
|
247
247
|
private getPaymentNumberDevicePrefixAsync;
|
|
248
248
|
private isMultiCurrencySettlementEnabled;
|
|
249
|
+
private getTerminalVirtualCurrencyChannel;
|
|
249
250
|
private isActiveVirtualSettlementOrder;
|
|
250
251
|
private isHistoricalVirtualSettlementOrder;
|
|
251
252
|
private syncAppDataToTempOrder;
|
|
@@ -503,6 +504,9 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
503
504
|
getPaymentMethodsAsync(): Promise<PaymentMethod[]>;
|
|
504
505
|
/** 同步读取初始化时缓存的支付方式列表。 */
|
|
505
506
|
getPaymentMethods(): PaymentMethod[];
|
|
507
|
+
private checkTerminalVirtualCurrencyPaymentMethod;
|
|
508
|
+
hasPosVirtualCurrencyPaymentMethod(): Promise<boolean>;
|
|
509
|
+
hasTerminalVirtualCurrencyPaymentMethod(): Promise<boolean>;
|
|
506
510
|
private findCashPaymentMethod;
|
|
507
511
|
private getPendingWalletPaymentAmount;
|
|
508
512
|
/** 读取现金 action 所需的支付方式、待付金额和快捷金额。 */
|