@pisell/pisellos 2.2.302 → 2.2.303
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/dataVariant/evaluator.d.ts +18 -2
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +287 -101
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +25 -0
- package/dist/model/strategy/adapter/itemRule/adapter.d.ts +4 -1
- package/dist/model/strategy/adapter/itemRule/adapter.js +135 -35
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +8 -1
- package/dist/model/strategy/adapter/itemRule/evaluator.js +25 -1
- package/dist/model/strategy/adapter/itemRule/type.d.ts +44 -0
- package/dist/model/strategy/adapter/itemRule/type.js +19 -1
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +10 -7
- package/dist/modules/Discount/index.d.ts +2 -0
- package/dist/modules/Discount/index.js +41 -5
- package/dist/modules/Discount/types.d.ts +21 -0
- package/dist/modules/OpenData/index.d.ts +15 -2
- package/dist/modules/OpenData/index.js +307 -19
- package/dist/modules/OpenData/types.d.ts +55 -0
- package/dist/modules/OpenData/types.js +7 -1
- package/dist/modules/OpenData/utils.d.ts +21 -1
- package/dist/modules/OpenData/utils.js +138 -0
- package/dist/modules/Order/index.d.ts +50 -7
- package/dist/modules/Order/index.js +1690 -815
- package/dist/modules/Order/salesNotes.d.ts +31 -0
- package/dist/modules/Order/salesNotes.js +492 -0
- package/dist/modules/Order/types.d.ts +117 -10
- package/dist/modules/Order/types.js +6 -1
- package/dist/modules/Order/utils/virtualSettlement.d.ts +63 -0
- package/dist/modules/Order/utils/virtualSettlement.js +284 -0
- package/dist/modules/Order/utils.d.ts +5 -1
- package/dist/modules/Order/utils.js +138 -33
- package/dist/modules/Payment/walletpass.js +20 -21
- package/dist/modules/Product/types.d.ts +23 -0
- package/dist/modules/ProductList/index.d.ts +2 -1
- package/dist/modules/ProductList/index.js +100 -20
- package/dist/modules/ProductList/types.d.ts +10 -0
- package/dist/modules/Rules/index.d.ts +5 -0
- package/dist/modules/Rules/index.js +30 -14
- package/dist/modules/SalesSummary/index.d.ts +1 -0
- package/dist/modules/SalesSummary/index.js +4 -3
- package/dist/modules/SalesSummary/types.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.js +21 -1
- package/dist/plugins/request.d.ts +2 -1
- package/dist/plugins/request.js +4 -2
- package/dist/server/index.d.ts +21 -0
- package/dist/server/index.js +1774 -1285
- package/dist/server/modules/order/types.d.ts +50 -0
- package/dist/server/modules/order/types.js +2 -0
- package/dist/server/utils/small-ticket.d.ts +4 -1
- package/dist/server/utils/small-ticket.js +461 -96
- package/dist/solution/BaseSales/index.d.ts +24 -3
- package/dist/solution/BaseSales/index.js +1484 -873
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +2 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +1 -1
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +72 -9
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +22 -5
- package/dist/solution/BookingTicket/index.js +558 -443
- package/dist/solution/BookingTicket/utils/addProductDecision.js +2 -1
- package/dist/solution/BookingTicket/utils/orderCustomer.js +3 -2
- package/dist/solution/RegisterAndLogin/config.d.ts +9 -3
- package/dist/solution/RegisterAndLogin/config.js +95 -40
- package/dist/solution/RegisterAndLogin/index.js +4 -1
- package/dist/solution/Sales/index.d.ts +16 -1
- package/dist/solution/Sales/index.js +338 -63
- package/dist/solution/Sales/types.d.ts +10 -0
- package/dist/solution/ScanOrder/index.d.ts +1 -0
- package/dist/solution/ScanOrder/index.js +31 -27
- package/dist/solution/ScanOrder/utils.d.ts +1 -0
- package/dist/solution/ScanOrder/utils.js +2 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +20 -6
- package/dist/solution/UnifiedBookingSales/index.js +874 -527
- package/dist/solution/UnifiedBookingSales/types.d.ts +21 -2
- package/dist/solution/VenueBooking/index.d.ts +1 -0
- package/dist/solution/VenueBooking/index.js +8 -4
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +137 -6
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +25 -0
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +4 -1
- package/lib/model/strategy/adapter/itemRule/adapter.js +73 -4
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +8 -1
- package/lib/model/strategy/adapter/itemRule/evaluator.js +23 -1
- package/lib/model/strategy/adapter/itemRule/type.d.ts +44 -0
- package/lib/model/strategy/adapter/itemRule/type.js +19 -1
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +4 -0
- package/lib/modules/Discount/index.d.ts +2 -0
- package/lib/modules/Discount/index.js +34 -2
- package/lib/modules/Discount/types.d.ts +21 -0
- package/lib/modules/OpenData/index.d.ts +15 -2
- package/lib/modules/OpenData/index.js +230 -3
- package/lib/modules/OpenData/types.d.ts +55 -0
- package/lib/modules/OpenData/types.js +9 -1
- package/lib/modules/OpenData/utils.d.ts +21 -1
- package/lib/modules/OpenData/utils.js +126 -0
- package/lib/modules/Order/index.d.ts +50 -7
- package/lib/modules/Order/index.js +704 -64
- package/lib/modules/Order/salesNotes.d.ts +31 -0
- package/lib/modules/Order/salesNotes.js +382 -0
- package/lib/modules/Order/types.d.ts +117 -10
- package/lib/modules/Order/types.js +5 -1
- package/lib/modules/Order/utils/virtualSettlement.d.ts +63 -0
- package/lib/modules/Order/utils/virtualSettlement.js +262 -0
- package/lib/modules/Order/utils.d.ts +5 -1
- package/lib/modules/Order/utils.js +127 -21
- package/lib/modules/Payment/walletpass.js +14 -11
- package/lib/modules/Product/types.d.ts +23 -0
- package/lib/modules/ProductList/index.d.ts +2 -1
- package/lib/modules/ProductList/index.js +47 -2
- package/lib/modules/ProductList/types.d.ts +10 -0
- package/lib/modules/Rules/index.d.ts +5 -0
- package/lib/modules/Rules/index.js +22 -12
- package/lib/modules/SalesSummary/index.d.ts +1 -0
- package/lib/modules/SalesSummary/index.js +4 -2
- package/lib/modules/SalesSummary/types.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.js +17 -1
- package/lib/plugins/request.d.ts +2 -1
- package/lib/plugins/request.js +3 -2
- package/lib/server/index.d.ts +21 -0
- package/lib/server/index.js +492 -108
- package/lib/server/modules/order/types.d.ts +50 -0
- package/lib/server/modules/order/types.js +1 -0
- package/lib/server/utils/small-ticket.d.ts +4 -1
- package/lib/server/utils/small-ticket.js +427 -72
- package/lib/solution/BaseSales/index.d.ts +24 -3
- package/lib/solution/BaseSales/index.js +433 -30
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +2 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +1 -1
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +38 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +22 -5
- package/lib/solution/BookingTicket/index.js +60 -15
- package/lib/solution/BookingTicket/utils/addProductDecision.js +1 -0
- package/lib/solution/BookingTicket/utils/orderCustomer.js +2 -1
- package/lib/solution/RegisterAndLogin/config.d.ts +9 -3
- package/lib/solution/RegisterAndLogin/config.js +49 -8
- package/lib/solution/RegisterAndLogin/index.js +4 -1
- package/lib/solution/Sales/index.d.ts +16 -1
- package/lib/solution/Sales/index.js +168 -1
- package/lib/solution/Sales/types.d.ts +10 -0
- package/lib/solution/ScanOrder/index.d.ts +1 -0
- package/lib/solution/ScanOrder/index.js +5 -1
- package/lib/solution/ScanOrder/utils.d.ts +1 -0
- package/lib/solution/ScanOrder/utils.js +1 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +20 -6
- package/lib/solution/UnifiedBookingSales/index.js +169 -16
- package/lib/solution/UnifiedBookingSales/types.d.ts +21 -2
- package/lib/solution/VenueBooking/index.d.ts +1 -0
- package/lib/solution/VenueBooking/index.js +5 -1
- package/package.json +1 -1
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import { CartItem } from '../Cart/types';
|
|
2
2
|
import type { DiscountModule } from '../Discount';
|
|
3
3
|
import type { RulesModule } from '../Rules';
|
|
4
|
-
import type { Discount } from '../Discount/types';
|
|
4
|
+
import type { Discount, VirtualCurrencyAsset } from '../Discount/types';
|
|
5
5
|
import type { UnavailableReason } from '../Rules/types';
|
|
6
6
|
import type { SubmitPayloadEnhancer } from './utils';
|
|
7
7
|
import type { PaymentItem } from '../Payment/types';
|
|
8
8
|
import type { ICustomer } from '../AccountList/types';
|
|
9
9
|
import type { OrderProductDiscountItem } from '../../server/modules/order/types';
|
|
10
10
|
export type { OrderProductDiscountItem } from '../../server/modules/order/types';
|
|
11
|
+
export type PickupReferenceMode = 'counter_pickup' | 'table_service';
|
|
12
|
+
export type ShopServiceType = 'dine_in' | 'takeaway';
|
|
13
|
+
export interface ShopServiceData {
|
|
14
|
+
pickup_reference_mode?: PickupReferenceMode;
|
|
15
|
+
service_type?: ShopServiceType | '';
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
}
|
|
11
18
|
export declare enum OrderHooks {
|
|
12
19
|
OnOrderCreate = "order:onOrderCreate",
|
|
13
20
|
OnOrderUpdate = "order:onOrderUpdate",
|
|
@@ -110,7 +117,7 @@ export interface OrderLastGiftActions {
|
|
|
110
117
|
}>;
|
|
111
118
|
toRemove: string[];
|
|
112
119
|
}
|
|
113
|
-
/** onPromotionApplied
|
|
120
|
+
/** onPromotionApplied 稳定态事件 payload(促销、折扣与 summary 均已完成)。 */
|
|
114
121
|
export interface OrderPromotionAppliedPayload {
|
|
115
122
|
unfulfilledPromotions: OrderUnfulfilledPromotion[];
|
|
116
123
|
giftActions: OrderLastGiftActions;
|
|
@@ -124,7 +131,7 @@ export interface OrderPromotionAppliedPayload {
|
|
|
124
131
|
product_variant_id: number;
|
|
125
132
|
}>;
|
|
126
133
|
}>;
|
|
127
|
-
/**
|
|
134
|
+
/** 折扣重算后的最终商品列表 */
|
|
128
135
|
products: OrderProduct[];
|
|
129
136
|
}
|
|
130
137
|
/**
|
|
@@ -188,6 +195,17 @@ export interface OrderProductSku {
|
|
|
188
195
|
export interface OrderLocalizedText {
|
|
189
196
|
[locale: string]: string | null;
|
|
190
197
|
}
|
|
198
|
+
export interface PointCardSnapshotItem {
|
|
199
|
+
id: number | string;
|
|
200
|
+
tag: 'point_card';
|
|
201
|
+
product_id?: number | string;
|
|
202
|
+
product_name: string;
|
|
203
|
+
par_value: string;
|
|
204
|
+
used_par_value: string;
|
|
205
|
+
}
|
|
206
|
+
export interface OrderMetaList {
|
|
207
|
+
point_cards_snapshot?: PointCardSnapshotItem[];
|
|
208
|
+
}
|
|
191
209
|
export interface OrderProduct extends OrderProductIdentity {
|
|
192
210
|
order_detail_id: number | null;
|
|
193
211
|
num: number;
|
|
@@ -198,6 +216,7 @@ export interface OrderProduct extends OrderProductIdentity {
|
|
|
198
216
|
gift_card?: number;
|
|
199
217
|
selling_price: string;
|
|
200
218
|
original_price: string;
|
|
219
|
+
payment_price?: string;
|
|
201
220
|
tax_fee: string;
|
|
202
221
|
is_charge_tax: number;
|
|
203
222
|
discount_list: OrderProductDiscountItem[];
|
|
@@ -238,6 +257,72 @@ export interface OrderSummary {
|
|
|
238
257
|
tax_title?: string;
|
|
239
258
|
tax_rate?: number;
|
|
240
259
|
}
|
|
260
|
+
export type SalesNoteRelationType = 'about' | 'related_to';
|
|
261
|
+
export type SalesNoteTargetType = 'order' | 'order_detail';
|
|
262
|
+
export type SalesNoteLocalizedText = string | Record<string, string>;
|
|
263
|
+
export interface SalesNoteLocalizedSelection {
|
|
264
|
+
id: string;
|
|
265
|
+
label: SalesNoteLocalizedText;
|
|
266
|
+
}
|
|
267
|
+
export type SalesNoteTextInput = {
|
|
268
|
+
kind: 'localizedSelections';
|
|
269
|
+
selections: SalesNoteLocalizedSelection[];
|
|
270
|
+
locale: string;
|
|
271
|
+
input?: string;
|
|
272
|
+
} | {
|
|
273
|
+
kind: 'plain';
|
|
274
|
+
input: string;
|
|
275
|
+
} | {
|
|
276
|
+
kind: 'resolved';
|
|
277
|
+
text: Record<string, string>;
|
|
278
|
+
};
|
|
279
|
+
export interface SalesNoteRelation {
|
|
280
|
+
uuid: string;
|
|
281
|
+
relation_type: SalesNoteRelationType;
|
|
282
|
+
target_type: SalesNoteTargetType;
|
|
283
|
+
target_uuid: string;
|
|
284
|
+
is_primary: 0 | 1;
|
|
285
|
+
}
|
|
286
|
+
export interface SalesNote {
|
|
287
|
+
uuid: string;
|
|
288
|
+
note_type: string;
|
|
289
|
+
content: {
|
|
290
|
+
text: Record<string, string>;
|
|
291
|
+
};
|
|
292
|
+
importance: string;
|
|
293
|
+
note_relations: SalesNoteRelation[];
|
|
294
|
+
}
|
|
295
|
+
export interface SalesNoteTarget {
|
|
296
|
+
target_type: 'order_detail';
|
|
297
|
+
target_uuid: string;
|
|
298
|
+
}
|
|
299
|
+
export interface SetSalesNoteInput {
|
|
300
|
+
note_type: string;
|
|
301
|
+
target: SalesNoteTarget;
|
|
302
|
+
text: SalesNoteTextInput;
|
|
303
|
+
}
|
|
304
|
+
export interface SalesNoteDraftInput {
|
|
305
|
+
note_type: string;
|
|
306
|
+
text: SalesNoteTextInput;
|
|
307
|
+
}
|
|
308
|
+
export interface SalesNotesRuntimeState {
|
|
309
|
+
loaded: boolean;
|
|
310
|
+
dirty: boolean;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Sales Notes 乐观写入前的可恢复快照。
|
|
314
|
+
* 该对象应视为 opaque token,只用于原样传回 restoreSalesNotesMutationSnapshot。
|
|
315
|
+
*/
|
|
316
|
+
export interface SalesNotesMutationSnapshot {
|
|
317
|
+
orderIdentity: {
|
|
318
|
+
orderId: number | string | null;
|
|
319
|
+
externalSaleNumber: string;
|
|
320
|
+
};
|
|
321
|
+
notes: SalesNote[];
|
|
322
|
+
state: SalesNotesRuntimeState;
|
|
323
|
+
}
|
|
324
|
+
export type SalesNoteProtocolRelation = SalesNoteRelation;
|
|
325
|
+
export type SalesNoteProtocol = SalesNote;
|
|
241
326
|
export interface OrderTempOrder {
|
|
242
327
|
order_id: number | null;
|
|
243
328
|
external_sale_number: string;
|
|
@@ -277,18 +362,22 @@ export interface OrderTempOrder {
|
|
|
277
362
|
created_at: string | undefined;
|
|
278
363
|
request_unique_idempotency_token?: string;
|
|
279
364
|
products: OrderProduct[];
|
|
365
|
+
notes: SalesNote[];
|
|
280
366
|
bookings: any[];
|
|
281
367
|
payments: any[];
|
|
368
|
+
refunds?: any[];
|
|
282
369
|
surcharges: any[];
|
|
283
370
|
discount_list?: any[];
|
|
284
371
|
relation_forms: any[];
|
|
285
372
|
contacts: any[];
|
|
286
373
|
contacts_info: Record<string, any> | null;
|
|
287
374
|
holder: Record<string, any> | null;
|
|
375
|
+
order_meta_list?: OrderMetaList;
|
|
288
376
|
metadata: Record<string, any>;
|
|
289
377
|
summary?: OrderSummary;
|
|
290
378
|
_extend?: {
|
|
291
379
|
productsByUid?: Record<string, Record<string, any>>;
|
|
380
|
+
salesNotesState?: SalesNotesRuntimeState;
|
|
292
381
|
[key: string]: any;
|
|
293
382
|
};
|
|
294
383
|
}
|
|
@@ -297,8 +386,9 @@ export interface OrderSubmitProduct extends Omit<OrderProduct, 'unique_identific
|
|
|
297
386
|
payment_price: string;
|
|
298
387
|
product_sku: OrderProductSku;
|
|
299
388
|
}
|
|
300
|
-
export interface OrderSubmitPayload extends Omit<OrderTempOrder, 'platform' | 'products' | '_extend' | 'customer' | 'discount_list' | 'created_at'> {
|
|
389
|
+
export interface OrderSubmitPayload extends Omit<OrderTempOrder, 'platform' | 'products' | 'notes' | '_extend' | 'customer' | 'discount_list' | 'created_at' | 'payment_status'> {
|
|
301
390
|
platform: string;
|
|
391
|
+
payment_status?: string;
|
|
302
392
|
created_at?: string | undefined;
|
|
303
393
|
request_unique_idempotency_token?: string;
|
|
304
394
|
form_record_ids?: Array<{
|
|
@@ -306,6 +396,7 @@ export interface OrderSubmitPayload extends Omit<OrderTempOrder, 'platform' | 'p
|
|
|
306
396
|
form_record_id: number | string;
|
|
307
397
|
}>;
|
|
308
398
|
products: OrderSubmitProduct[];
|
|
399
|
+
notes?: SalesNoteProtocol[];
|
|
309
400
|
summary?: OrderSummary;
|
|
310
401
|
small_ticket_data_flag?: number;
|
|
311
402
|
}
|
|
@@ -316,6 +407,7 @@ export interface OrderState {
|
|
|
316
407
|
syncState?: OrderSyncState;
|
|
317
408
|
discountList: any[];
|
|
318
409
|
availableWalletIds?: number[];
|
|
410
|
+
virtualCurrencyList?: VirtualCurrencyAsset[];
|
|
319
411
|
discount: DiscountModule | null;
|
|
320
412
|
rules: RulesModule | null;
|
|
321
413
|
}
|
|
@@ -334,6 +426,8 @@ export interface AddProductToOrderOptions {
|
|
|
334
426
|
insertAfterProductUid?: string;
|
|
335
427
|
/** 跳过同商品/规格匹配,始终新增购物车行。 */
|
|
336
428
|
disableMerge?: boolean;
|
|
429
|
+
/** 商品行 UID 落定后,由 OrderModule 原子绑定到该行的 Sales Notes 草稿。 */
|
|
430
|
+
salesNotes?: SalesNoteDraftInput[];
|
|
337
431
|
}
|
|
338
432
|
/**
|
|
339
433
|
* 删除商品后的可选位置保持策略。
|
|
@@ -452,7 +546,7 @@ export interface SubmitSalesOrderParams {
|
|
|
452
546
|
sales_channel: string;
|
|
453
547
|
order_sales_channel: string;
|
|
454
548
|
status: string;
|
|
455
|
-
payment_status
|
|
549
|
+
payment_status?: string;
|
|
456
550
|
shipping_status: string;
|
|
457
551
|
customer_id: number | null;
|
|
458
552
|
customer_name: string;
|
|
@@ -484,6 +578,7 @@ export interface SubmitSalesOrderParams {
|
|
|
484
578
|
contacts: any[];
|
|
485
579
|
contacts_info: Record<string, any> | null;
|
|
486
580
|
holder: Record<string, any> | null;
|
|
581
|
+
order_meta_list?: OrderMetaList;
|
|
487
582
|
metadata: Record<string, any>;
|
|
488
583
|
summary?: OrderSummary;
|
|
489
584
|
small_ticket_data_flag?: number;
|
|
@@ -716,6 +811,8 @@ export interface OrderModuleAPI {
|
|
|
716
811
|
addNewOrder: () => Promise<OrderTempOrder>;
|
|
717
812
|
restoreOrder: () => OrderTempOrder;
|
|
718
813
|
getOrderProducts: () => OrderProduct[];
|
|
814
|
+
getVirtualCurrencyList: () => VirtualCurrencyAsset[];
|
|
815
|
+
clearOrderForSettlementSwitch: () => Promise<OrderTempOrder>;
|
|
719
816
|
getOrderSummary: () => Promise<OrderSummary>;
|
|
720
817
|
recalculateSummary: (options?: {
|
|
721
818
|
createIfMissing?: boolean;
|
|
@@ -749,9 +846,17 @@ export interface OrderModuleAPI {
|
|
|
749
846
|
updateTempOrderShopDiscount: (amount: string | number) => string;
|
|
750
847
|
updateTempOrderDepositAmount: (amount: string | number) => OrderSummary;
|
|
751
848
|
updateTempOrderCustomer: (customer: UpdateTempOrderCustomerInput) => OrderSnapshot['customer'];
|
|
849
|
+
updateTempOrderPickupReferenceMode: (mode: PickupReferenceMode) => ShopServiceData;
|
|
850
|
+
updateTempOrderServiceType: (serviceType: ShopServiceType) => ShopServiceData;
|
|
752
851
|
updateTempOrderBuzzer: (buzzer: string) => string;
|
|
753
852
|
updateTempOrderContactsInfo: (contactsInfo: Record<string, any> | null) => Record<string, any> | null;
|
|
754
853
|
addProductToOrder: (product: Partial<OrderProduct> & OrderProductIdentity, booking?: AddProductBookingInput, options?: AddProductToOrderOptions) => Promise<OrderProduct[]>;
|
|
854
|
+
getSalesNotes: () => SalesNote[];
|
|
855
|
+
createSalesNotesMutationSnapshot: () => SalesNotesMutationSnapshot;
|
|
856
|
+
restoreSalesNotesMutationSnapshot: (snapshot: SalesNotesMutationSnapshot) => void;
|
|
857
|
+
setSalesNote: (input: SetSalesNoteInput) => Promise<SalesNote>;
|
|
858
|
+
removeSalesNote: (uuid: string) => Promise<void>;
|
|
859
|
+
clearSalesNotes: () => Promise<void>;
|
|
755
860
|
updateOrderProduct: (params: UpdateOrderProductParams) => Promise<OrderProduct[]>;
|
|
756
861
|
/** 批量更新购物车行,末尾仅触发一次促销重算与 summary 刷新 */
|
|
757
862
|
updateOrderProducts: (paramsList: UpdateOrderProductParams[]) => Promise<OrderProduct[]>;
|
|
@@ -778,6 +883,8 @@ export interface OrderModuleAPI {
|
|
|
778
883
|
isTempOrderPersistEnabled: () => boolean;
|
|
779
884
|
/** 提交 tempOrder 变更并触发 `{moduleName}:changed` 事件 */
|
|
780
885
|
notifyTempOrderChanged: () => void;
|
|
886
|
+
/** PC/H5 为在线店铺;其它或缺失平台统一按 POS 处理。 */
|
|
887
|
+
isOnlineStorePlatform: () => boolean;
|
|
781
888
|
submitTempOrder: <T = any>(params?: {
|
|
782
889
|
cacheId?: string;
|
|
783
890
|
platform?: string;
|
|
@@ -885,7 +992,7 @@ export interface OrderModuleAPI {
|
|
|
885
992
|
*/
|
|
886
993
|
appendPromotionTags: <T extends Record<string, any>>(products: T[]) => T[];
|
|
887
994
|
/**
|
|
888
|
-
* 应用购物车促销(评估 → 差异化赠品 →
|
|
995
|
+
* 应用购物车促销(评估 → 差异化赠品 → 折扣/summary 重算 → emit onPromotionApplied)。
|
|
889
996
|
*
|
|
890
997
|
* 自动在 addProductToOrder / updateOrderProductQuantity / removeProductFromOrder /
|
|
891
998
|
* clearOrderCartLines / setOrderCustomer 等写路径末尾触发,业务一般无需手动调用。
|
|
@@ -899,10 +1006,10 @@ export interface OrderModuleAPI {
|
|
|
899
1006
|
/** 读取上次 applyPromotion 产出的赠品操作 diff(toAdd / toReduce / toRemove) */
|
|
900
1007
|
getLastGiftActions: () => OrderLastGiftActions | null;
|
|
901
1008
|
/**
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
1009
|
+
* 取消订单
|
|
1010
|
+
* @param params 取消订单参数
|
|
1011
|
+
* @returns 后端返回结果
|
|
1012
|
+
*/
|
|
906
1013
|
cancelOrder: (params: CancelOrderParams) => Promise<any>;
|
|
907
1014
|
/**
|
|
908
1015
|
* 变更预约状态
|
|
@@ -41,7 +41,7 @@ export var OrderHooks = /*#__PURE__*/function (OrderHooks) {
|
|
|
41
41
|
|
|
42
42
|
/** 上一次 applyPromotion 计算出的赠品操作(仅供调试/读取使用) */
|
|
43
43
|
|
|
44
|
-
/** onPromotionApplied
|
|
44
|
+
/** onPromotionApplied 稳定态事件 payload(促销、折扣与 summary 均已完成)。 */
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* tempOrder 上的下单客户协议字段视图。
|
|
@@ -64,6 +64,11 @@ export var OrderHooks = /*#__PURE__*/function (OrderHooks) {
|
|
|
64
64
|
* 清空时整个 payload 为 null。
|
|
65
65
|
*/
|
|
66
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Sales Notes 乐观写入前的可恢复快照。
|
|
69
|
+
* 该对象应视为 opaque token,只用于原样传回 restoreSalesNotesMutationSnapshot。
|
|
70
|
+
*/
|
|
71
|
+
|
|
67
72
|
/**
|
|
68
73
|
* 添加商品行时的顺序控制。
|
|
69
74
|
* 默认追加到 products 尾部;预约数量同步可插入到既有预约组的最新行之后,
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { OrderProduct, OrderTempOrder } from '../types';
|
|
2
|
+
export interface SelectedSettlementSnapshot extends Record<string, any> {
|
|
3
|
+
settlement_type: 'legal_currency' | 'virtual_currency';
|
|
4
|
+
currency_product_id?: number;
|
|
5
|
+
price: string | number;
|
|
6
|
+
unit_label?: any;
|
|
7
|
+
symbol?: any;
|
|
8
|
+
amount_format?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface LegalCurrencySnapshot {
|
|
11
|
+
currency_code: string;
|
|
12
|
+
currency_symbol: string;
|
|
13
|
+
currency_format: string;
|
|
14
|
+
}
|
|
15
|
+
export interface CurrencyDisplaySnapshot {
|
|
16
|
+
amount_format: string;
|
|
17
|
+
symbol: unknown;
|
|
18
|
+
unit_label: unknown;
|
|
19
|
+
}
|
|
20
|
+
export declare function buildCurrencyDisplaySnapshot(snapshot: Pick<SelectedSettlementSnapshot, 'amount_format' | 'symbol' | 'unit_label'>): CurrencyDisplaySnapshot;
|
|
21
|
+
export declare function resolveSettlementDisplayValue(value: unknown): string;
|
|
22
|
+
export declare class OrderSettlementConflictError extends Error {
|
|
23
|
+
readonly currentSettlementKey: string;
|
|
24
|
+
readonly incomingSettlementKey: string;
|
|
25
|
+
readonly code = "ORDER_SETTLEMENT_CONFLICT";
|
|
26
|
+
constructor(currentSettlementKey: string, incomingSettlementKey: string);
|
|
27
|
+
}
|
|
28
|
+
export declare class VirtualCurrencyAssetNotFoundError extends Error {
|
|
29
|
+
readonly currencyProductId: number;
|
|
30
|
+
readonly code = "VIRTUAL_CURRENCY_ASSET_NOT_FOUND";
|
|
31
|
+
constructor(currencyProductId: number);
|
|
32
|
+
}
|
|
33
|
+
export declare class VirtualCurrencyBalanceError extends Error {
|
|
34
|
+
readonly balance: string;
|
|
35
|
+
readonly requiredAmount: string;
|
|
36
|
+
readonly code = "VIRTUAL_CURRENCY_BALANCE_INSUFFICIENT";
|
|
37
|
+
constructor(balance: string, requiredAmount: string);
|
|
38
|
+
}
|
|
39
|
+
export declare function getSelectedSettlementSnapshot(product: Partial<OrderProduct> | null | undefined): SelectedSettlementSnapshot | null;
|
|
40
|
+
export declare function getTempOrderSettlementSnapshot(tempOrder: OrderTempOrder | null | undefined): SelectedSettlementSnapshot | null;
|
|
41
|
+
export declare function isVirtualSettlementProduct(product: Partial<OrderProduct> | null | undefined): boolean;
|
|
42
|
+
export declare function getSettlementKey(snapshot: SelectedSettlementSnapshot | null | undefined): string | null;
|
|
43
|
+
export declare function getTempOrderSettlementKey(tempOrder: OrderTempOrder | null | undefined): string | null;
|
|
44
|
+
export declare function isVirtualSettlementOrder(tempOrder: OrderTempOrder | null | undefined): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* 详情展示识别同时支持已提交订单的 currency_settlement_config。
|
|
47
|
+
* cart_settlement_* 是交易过程内部状态,服务端详情不保证返回。
|
|
48
|
+
*/
|
|
49
|
+
export declare function isVirtualSettlementDisplayOrder(tempOrder: OrderTempOrder | null | undefined): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* 将购物车锁定的结算单位提升为订单级状态。
|
|
52
|
+
* 商品行快照同时负责价格归一化和生成订单级多语言展示快照;
|
|
53
|
+
* 交易中的即时展示仍统一读取 tempOrder.currency_*。
|
|
54
|
+
*/
|
|
55
|
+
export declare function applyTempOrderSettlementState(tempOrder: OrderTempOrder, snapshot: SelectedSettlementSnapshot): void;
|
|
56
|
+
/** 清空购物车结算锁,并恢复进入虚拟币结算前的店铺法币。 */
|
|
57
|
+
export declare function releaseTempOrderSettlementState(tempOrder: OrderTempOrder): void;
|
|
58
|
+
/**
|
|
59
|
+
* 将已选择虚拟币的订单商品行固化为最终价语义。
|
|
60
|
+
* 函数幂等,可安全用于加车、合并、hydrate 和提交前兜底。
|
|
61
|
+
*/
|
|
62
|
+
export declare function normalizeVirtualSettlementOrderProduct<T extends Partial<OrderProduct>>(product: T): T;
|
|
63
|
+
export declare function normalizeVirtualSettlementProducts<T extends Partial<OrderProduct>>(products: T[]): T[];
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
5
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
6
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
7
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
8
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
9
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
10
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
11
|
+
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
|
12
|
+
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
13
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
14
|
+
function _isNativeFunction(fn) { try { return Function.toString.call(fn).indexOf("[native code]") !== -1; } catch (e) { return typeof fn === "function"; } }
|
|
15
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
16
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
17
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
18
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
19
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
20
|
+
import Decimal from 'decimal.js';
|
|
21
|
+
import { cloneDeep } from 'lodash-es';
|
|
22
|
+
export function buildCurrencyDisplaySnapshot(snapshot) {
|
|
23
|
+
var _snapshot$symbol, _snapshot$unit_label;
|
|
24
|
+
return cloneDeep({
|
|
25
|
+
amount_format: String(snapshot.amount_format || '').trim(),
|
|
26
|
+
symbol: (_snapshot$symbol = snapshot.symbol) !== null && _snapshot$symbol !== void 0 ? _snapshot$symbol : {},
|
|
27
|
+
unit_label: (_snapshot$unit_label = snapshot.unit_label) !== null && _snapshot$unit_label !== void 0 ? _snapshot$unit_label : {}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export function resolveSettlementDisplayValue(value) {
|
|
31
|
+
var _ref, _ref2, _ref3, _ref4, _ref5, _localized$auto;
|
|
32
|
+
if (value === undefined || value === null) return '';
|
|
33
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
34
|
+
return String(value);
|
|
35
|
+
}
|
|
36
|
+
var localized = value;
|
|
37
|
+
return String((_ref = (_ref2 = (_ref3 = (_ref4 = (_ref5 = (_localized$auto = localized.auto) !== null && _localized$auto !== void 0 ? _localized$auto : localized.default) !== null && _ref5 !== void 0 ? _ref5 : localized.original) !== null && _ref4 !== void 0 ? _ref4 : localized.en) !== null && _ref3 !== void 0 ? _ref3 : localized['zh-CN']) !== null && _ref2 !== void 0 ? _ref2 : localized['zh-HK']) !== null && _ref !== void 0 ? _ref : '');
|
|
38
|
+
}
|
|
39
|
+
export var OrderSettlementConflictError = /*#__PURE__*/function (_Error) {
|
|
40
|
+
_inherits(OrderSettlementConflictError, _Error);
|
|
41
|
+
var _super = _createSuper(OrderSettlementConflictError);
|
|
42
|
+
function OrderSettlementConflictError(currentSettlementKey, incomingSettlementKey) {
|
|
43
|
+
var _this;
|
|
44
|
+
_classCallCheck(this, OrderSettlementConflictError);
|
|
45
|
+
_this = _super.call(this, 'Different currencies and WalletPass units cannot be mixed in one cart.');
|
|
46
|
+
_defineProperty(_assertThisInitialized(_this), "code", 'ORDER_SETTLEMENT_CONFLICT');
|
|
47
|
+
_this.currentSettlementKey = currentSettlementKey;
|
|
48
|
+
_this.incomingSettlementKey = incomingSettlementKey;
|
|
49
|
+
_this.name = 'OrderSettlementConflictError';
|
|
50
|
+
return _this;
|
|
51
|
+
}
|
|
52
|
+
return _createClass(OrderSettlementConflictError);
|
|
53
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
54
|
+
export var VirtualCurrencyAssetNotFoundError = /*#__PURE__*/function (_Error2) {
|
|
55
|
+
_inherits(VirtualCurrencyAssetNotFoundError, _Error2);
|
|
56
|
+
var _super2 = _createSuper(VirtualCurrencyAssetNotFoundError);
|
|
57
|
+
function VirtualCurrencyAssetNotFoundError(currencyProductId) {
|
|
58
|
+
var _this2;
|
|
59
|
+
_classCallCheck(this, VirtualCurrencyAssetNotFoundError);
|
|
60
|
+
_this2 = _super2.call(this, 'No matching virtual currency card is available.');
|
|
61
|
+
_defineProperty(_assertThisInitialized(_this2), "code", 'VIRTUAL_CURRENCY_ASSET_NOT_FOUND');
|
|
62
|
+
_this2.currencyProductId = currencyProductId;
|
|
63
|
+
_this2.name = 'VirtualCurrencyAssetNotFoundError';
|
|
64
|
+
return _this2;
|
|
65
|
+
}
|
|
66
|
+
return _createClass(VirtualCurrencyAssetNotFoundError);
|
|
67
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
68
|
+
export var VirtualCurrencyBalanceError = /*#__PURE__*/function (_Error3) {
|
|
69
|
+
_inherits(VirtualCurrencyBalanceError, _Error3);
|
|
70
|
+
var _super3 = _createSuper(VirtualCurrencyBalanceError);
|
|
71
|
+
function VirtualCurrencyBalanceError(balance, requiredAmount) {
|
|
72
|
+
var _this3;
|
|
73
|
+
_classCallCheck(this, VirtualCurrencyBalanceError);
|
|
74
|
+
_this3 = _super3.call(this, 'Insufficient virtual currency balance.');
|
|
75
|
+
_defineProperty(_assertThisInitialized(_this3), "code", 'VIRTUAL_CURRENCY_BALANCE_INSUFFICIENT');
|
|
76
|
+
_this3.balance = balance;
|
|
77
|
+
_this3.requiredAmount = requiredAmount;
|
|
78
|
+
_this3.name = 'VirtualCurrencyBalanceError';
|
|
79
|
+
return _this3;
|
|
80
|
+
}
|
|
81
|
+
return _createClass(VirtualCurrencyBalanceError);
|
|
82
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
83
|
+
export function getSelectedSettlementSnapshot(product) {
|
|
84
|
+
var _product$metadata;
|
|
85
|
+
var snapshot = product === null || product === void 0 || (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.selected_settlement_snapshot;
|
|
86
|
+
if (!snapshot || _typeof(snapshot) !== 'object') return null;
|
|
87
|
+
if (snapshot.settlement_type !== 'legal_currency' && snapshot.settlement_type !== 'virtual_currency') {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
return snapshot;
|
|
91
|
+
}
|
|
92
|
+
export function getTempOrderSettlementSnapshot(tempOrder) {
|
|
93
|
+
var _tempOrder$metadata, _tempOrder$products;
|
|
94
|
+
var snapshot = tempOrder === null || tempOrder === void 0 || (_tempOrder$metadata = tempOrder.metadata) === null || _tempOrder$metadata === void 0 ? void 0 : _tempOrder$metadata.cart_settlement_snapshot;
|
|
95
|
+
if (snapshot && _typeof(snapshot) === 'object' && (snapshot.settlement_type === 'legal_currency' || snapshot.settlement_type === 'virtual_currency')) {
|
|
96
|
+
return snapshot;
|
|
97
|
+
}
|
|
98
|
+
return getSelectedSettlementSnapshot(tempOrder === null || tempOrder === void 0 || (_tempOrder$products = tempOrder.products) === null || _tempOrder$products === void 0 ? void 0 : _tempOrder$products[0]);
|
|
99
|
+
}
|
|
100
|
+
export function isVirtualSettlementProduct(product) {
|
|
101
|
+
var _getSelectedSettlemen;
|
|
102
|
+
return ((_getSelectedSettlemen = getSelectedSettlementSnapshot(product)) === null || _getSelectedSettlemen === void 0 ? void 0 : _getSelectedSettlemen.settlement_type) === 'virtual_currency';
|
|
103
|
+
}
|
|
104
|
+
export function getSettlementKey(snapshot) {
|
|
105
|
+
if (!snapshot) return null;
|
|
106
|
+
if (snapshot.settlement_type === 'legal_currency') return 'legal_currency';
|
|
107
|
+
var currencyProductId = Number(snapshot.currency_product_id);
|
|
108
|
+
return Number.isFinite(currencyProductId) && currencyProductId > 0 ? "virtual_currency:".concat(currencyProductId) : null;
|
|
109
|
+
}
|
|
110
|
+
export function getTempOrderSettlementKey(tempOrder) {
|
|
111
|
+
var _tempOrder$products2, _tempOrder$metadata2;
|
|
112
|
+
if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$products2 = tempOrder.products) !== null && _tempOrder$products2 !== void 0 && _tempOrder$products2.length)) return null;
|
|
113
|
+
var storedKey = (_tempOrder$metadata2 = tempOrder.metadata) === null || _tempOrder$metadata2 === void 0 ? void 0 : _tempOrder$metadata2.cart_settlement_key;
|
|
114
|
+
if (typeof storedKey === 'string' && storedKey) return storedKey;
|
|
115
|
+
return getSettlementKey(getTempOrderSettlementSnapshot(tempOrder)) || 'legal_currency';
|
|
116
|
+
}
|
|
117
|
+
export function isVirtualSettlementOrder(tempOrder) {
|
|
118
|
+
var _getTempOrderSettleme;
|
|
119
|
+
return ((_getTempOrderSettleme = getTempOrderSettlementKey(tempOrder)) === null || _getTempOrderSettleme === void 0 ? void 0 : _getTempOrderSettleme.startsWith('virtual_currency:')) === true;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* 详情展示识别同时支持已提交订单的 currency_settlement_config。
|
|
124
|
+
* cart_settlement_* 是交易过程内部状态,服务端详情不保证返回。
|
|
125
|
+
*/
|
|
126
|
+
export function isVirtualSettlementDisplayOrder(tempOrder) {
|
|
127
|
+
var _tempOrder$metadata3;
|
|
128
|
+
return (tempOrder === null || tempOrder === void 0 || (_tempOrder$metadata3 = tempOrder.metadata) === null || _tempOrder$metadata3 === void 0 || (_tempOrder$metadata3 = _tempOrder$metadata3.currency_settlement_config) === null || _tempOrder$metadata3 === void 0 ? void 0 : _tempOrder$metadata3.settlement_type) === 'virtual_currency' || isVirtualSettlementOrder(tempOrder);
|
|
129
|
+
}
|
|
130
|
+
function getLegalCurrencySnapshot(tempOrder) {
|
|
131
|
+
var _tempOrder$metadata4;
|
|
132
|
+
var snapshot = (_tempOrder$metadata4 = tempOrder.metadata) === null || _tempOrder$metadata4 === void 0 ? void 0 : _tempOrder$metadata4.legal_currency_snapshot;
|
|
133
|
+
if (!snapshot || _typeof(snapshot) !== 'object') return null;
|
|
134
|
+
return {
|
|
135
|
+
currency_code: String(snapshot.currency_code || ''),
|
|
136
|
+
currency_symbol: String(snapshot.currency_symbol || ''),
|
|
137
|
+
currency_format: String(snapshot.currency_format || 'symbol_first')
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function captureLegalCurrencySnapshot(tempOrder) {
|
|
141
|
+
tempOrder.metadata = tempOrder.metadata || {};
|
|
142
|
+
if (getLegalCurrencySnapshot(tempOrder)) return;
|
|
143
|
+
tempOrder.metadata.legal_currency_snapshot = {
|
|
144
|
+
currency_code: String(tempOrder.currency_code || ''),
|
|
145
|
+
currency_symbol: String(tempOrder.currency_symbol || ''),
|
|
146
|
+
currency_format: String(tempOrder.currency_format || 'symbol_first')
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* 将购物车锁定的结算单位提升为订单级状态。
|
|
152
|
+
* 商品行快照同时负责价格归一化和生成订单级多语言展示快照;
|
|
153
|
+
* 交易中的即时展示仍统一读取 tempOrder.currency_*。
|
|
154
|
+
*/
|
|
155
|
+
export function applyTempOrderSettlementState(tempOrder, snapshot) {
|
|
156
|
+
tempOrder.metadata = tempOrder.metadata || {};
|
|
157
|
+
var settlementKey = getSettlementKey(snapshot) || 'legal_currency';
|
|
158
|
+
if (snapshot.settlement_type === 'virtual_currency') {
|
|
159
|
+
var _tempOrder$metadata$c;
|
|
160
|
+
captureLegalCurrencySnapshot(tempOrder);
|
|
161
|
+
var _currencyProductId = Number(snapshot.currency_product_id);
|
|
162
|
+
var existingDisplaySnapshot = (_tempOrder$metadata$c = tempOrder.metadata.currency_settlement_config) === null || _tempOrder$metadata$c === void 0 ? void 0 : _tempOrder$metadata$c.currency_display_snapshot;
|
|
163
|
+
tempOrder.metadata.currency_settlement_config = {
|
|
164
|
+
settlement_type: 'virtual_currency',
|
|
165
|
+
settlement_ids: Number.isFinite(_currencyProductId) && _currencyProductId > 0 ? [_currencyProductId] : [],
|
|
166
|
+
currency_display_snapshot: existingDisplaySnapshot ? cloneDeep(existingDisplaySnapshot) : buildCurrencyDisplaySnapshot(snapshot)
|
|
167
|
+
};
|
|
168
|
+
} else {
|
|
169
|
+
delete tempOrder.metadata.currency_settlement_config;
|
|
170
|
+
}
|
|
171
|
+
tempOrder.metadata.cart_settlement_key = settlementKey;
|
|
172
|
+
tempOrder.metadata.cart_settlement_snapshot = _objectSpread({}, snapshot);
|
|
173
|
+
tempOrder.currency_code = resolveSettlementDisplayValue(snapshot.unit_label) || tempOrder.currency_code;
|
|
174
|
+
tempOrder.currency_symbol = resolveSettlementDisplayValue(snapshot.symbol) || tempOrder.currency_symbol;
|
|
175
|
+
tempOrder.currency_format = String(snapshot.amount_format || tempOrder.currency_format || 'symbol_first');
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** 清空购物车结算锁,并恢复进入虚拟币结算前的店铺法币。 */
|
|
179
|
+
export function releaseTempOrderSettlementState(tempOrder) {
|
|
180
|
+
tempOrder.metadata = tempOrder.metadata || {};
|
|
181
|
+
var legalCurrency = getLegalCurrencySnapshot(tempOrder);
|
|
182
|
+
if (legalCurrency) {
|
|
183
|
+
tempOrder.currency_code = legalCurrency.currency_code;
|
|
184
|
+
tempOrder.currency_symbol = legalCurrency.currency_symbol;
|
|
185
|
+
tempOrder.currency_format = legalCurrency.currency_format;
|
|
186
|
+
}
|
|
187
|
+
delete tempOrder.metadata.cart_settlement_key;
|
|
188
|
+
delete tempOrder.metadata.cart_settlement_snapshot;
|
|
189
|
+
delete tempOrder.metadata.currency_settlement_config;
|
|
190
|
+
}
|
|
191
|
+
function toMoney(value) {
|
|
192
|
+
try {
|
|
193
|
+
return new Decimal(String(value !== null && value !== void 0 ? value : 0)).toDecimalPlaces(2).toFixed(2);
|
|
194
|
+
} catch (_unused) {
|
|
195
|
+
return '0.00';
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function zeroOptions(options) {
|
|
199
|
+
if (!Array.isArray(options)) return [];
|
|
200
|
+
return options.map(function (option) {
|
|
201
|
+
return _objectSpread(_objectSpread({}, option), {}, {
|
|
202
|
+
add_price: 0
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
function zeroBundles(bundles) {
|
|
207
|
+
if (!Array.isArray(bundles)) return [];
|
|
208
|
+
return bundles.map(function (bundle) {
|
|
209
|
+
return _objectSpread(_objectSpread({}, bundle), {}, {
|
|
210
|
+
price: 0,
|
|
211
|
+
custom_price: 0,
|
|
212
|
+
bundle_selling_price: 0,
|
|
213
|
+
bundle_payment_price: 0,
|
|
214
|
+
surcharge_fee: 0,
|
|
215
|
+
tax_fee: 0,
|
|
216
|
+
original_tax_fee: 0,
|
|
217
|
+
is_charge_tax: 0,
|
|
218
|
+
discount_list: [],
|
|
219
|
+
relation_surcharge_ids: [],
|
|
220
|
+
option: zeroOptions(bundle === null || bundle === void 0 ? void 0 : bundle.option),
|
|
221
|
+
metadata: _objectSpread(_objectSpread({}, (bundle === null || bundle === void 0 ? void 0 : bundle.metadata) || {}), {}, {
|
|
222
|
+
surcharge_fee: '0.00',
|
|
223
|
+
relation_surcharge_ids: [],
|
|
224
|
+
product_discount_difference: '',
|
|
225
|
+
tax_fee_rounding_remainder: '0.00',
|
|
226
|
+
surcharge_rounding_remainder: '0.00'
|
|
227
|
+
})
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* 将已选择虚拟币的订单商品行固化为最终价语义。
|
|
234
|
+
* 函数幂等,可安全用于加车、合并、hydrate 和提交前兜底。
|
|
235
|
+
*/
|
|
236
|
+
export function normalizeVirtualSettlementOrderProduct(product) {
|
|
237
|
+
var _product$product_sku;
|
|
238
|
+
var snapshot = getSelectedSettlementSnapshot(product);
|
|
239
|
+
if ((snapshot === null || snapshot === void 0 ? void 0 : snapshot.settlement_type) !== 'virtual_currency') return product;
|
|
240
|
+
var virtualPrice = toMoney(snapshot.price);
|
|
241
|
+
var metadata = _objectSpread(_objectSpread({}, product.metadata || {}), {}, {
|
|
242
|
+
source_product_price: virtualPrice,
|
|
243
|
+
main_product_original_price: virtualPrice,
|
|
244
|
+
main_product_selling_price: virtualPrice,
|
|
245
|
+
main_product_attached_bundle_selling_price: virtualPrice,
|
|
246
|
+
main_product_attached_bundle_payment_price: virtualPrice,
|
|
247
|
+
main_product_attached_bundle_surcharge_fee: '0.00',
|
|
248
|
+
main_product_attached_bundle_tax_fee: '0.00',
|
|
249
|
+
surcharge_rounding_remainder: '0.00',
|
|
250
|
+
tax_fee_rounding_remainder: '0.00',
|
|
251
|
+
relation_surcharge_ids: [],
|
|
252
|
+
average_discount_amount_rate: '1',
|
|
253
|
+
product_discount_difference: '',
|
|
254
|
+
discountable_flag: 0,
|
|
255
|
+
price_schema_version: 2,
|
|
256
|
+
selected_settlement_snapshot: _objectSpread(_objectSpread({}, snapshot), {}, {
|
|
257
|
+
price: virtualPrice
|
|
258
|
+
})
|
|
259
|
+
});
|
|
260
|
+
return _objectSpread(_objectSpread({}, product), {}, {
|
|
261
|
+
selling_price: virtualPrice,
|
|
262
|
+
original_price: virtualPrice,
|
|
263
|
+
payment_price: virtualPrice,
|
|
264
|
+
discount_list: [],
|
|
265
|
+
is_charge_tax: 0,
|
|
266
|
+
tax_fee: '0.00',
|
|
267
|
+
original_tax_fee: 0,
|
|
268
|
+
tax_fee_rounding_remainder: 0,
|
|
269
|
+
original_tax_fee_rounding_remainder: 0,
|
|
270
|
+
surcharge_fee: '0.00',
|
|
271
|
+
surcharge_rounding_remainder: 0,
|
|
272
|
+
relation_surcharge_ids: [],
|
|
273
|
+
product_sku: _objectSpread(_objectSpread({}, product.product_sku || {}), {}, {
|
|
274
|
+
option: zeroOptions((_product$product_sku = product.product_sku) === null || _product$product_sku === void 0 ? void 0 : _product$product_sku.option)
|
|
275
|
+
}),
|
|
276
|
+
product_bundle: zeroBundles(product.product_bundle),
|
|
277
|
+
metadata: metadata
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
export function normalizeVirtualSettlementProducts(products) {
|
|
281
|
+
return (products || []).map(function (product) {
|
|
282
|
+
return normalizeVirtualSettlementOrderProduct(product);
|
|
283
|
+
});
|
|
284
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Decimal from 'decimal.js';
|
|
2
2
|
import type { CartItem } from "../Cart";
|
|
3
|
-
import type { OrderProductDiscountItem, OrderProduct, OrderSubmitPayload, OrderSubmitProduct, OrderSummary, OrderTempOrder } from './types';
|
|
3
|
+
import type { OrderProductDiscountItem, OrderMetaList, OrderProduct, OrderSubmitPayload, OrderSubmitProduct, OrderSummary, OrderTempOrder, PointCardSnapshotItem } from './types';
|
|
4
4
|
import type { RulesParamsHooks } from '../Rules/types';
|
|
5
5
|
import type { MapOrderPaymentsOptions, OrderPaymentData, OrderPaymentSource } from './types';
|
|
6
6
|
import { createUuidV4 } from './utils/orderCollectionIdentity';
|
|
@@ -16,6 +16,9 @@ export interface OrderProductsDepositSummary {
|
|
|
16
16
|
hasDeposit: boolean;
|
|
17
17
|
}
|
|
18
18
|
import type { WindowPlugin } from '../../plugins';
|
|
19
|
+
export declare function normalizePointCardSnapshotItem(value: unknown): PointCardSnapshotItem | null;
|
|
20
|
+
export declare function buildPointCardSnapshotFromWalletPassList(value: unknown): PointCardSnapshotItem[];
|
|
21
|
+
export declare function normalizeOrderMetaList(value: unknown): OrderMetaList | undefined;
|
|
19
22
|
/**
|
|
20
23
|
* 把"含 option 的主商品单价"与 bundle 合成"单行 composite 单价"。
|
|
21
24
|
*
|
|
@@ -232,6 +235,7 @@ export declare function buildSubmitPayload(params: {
|
|
|
232
235
|
type?: string;
|
|
233
236
|
summary?: OrderSummary | null;
|
|
234
237
|
request_unique_idempotency_token?: string;
|
|
238
|
+
includePaymentStatus?: boolean;
|
|
235
239
|
enhance?: SubmitPayloadEnhancer;
|
|
236
240
|
}): OrderSubmitPayload;
|
|
237
241
|
export declare function mapPaymentItemToOrderPayment(paymentItem: OrderPaymentSource): OrderPaymentData;
|