@pisell/pisellos 2.2.148 → 2.2.149
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/apis/picoding.d.ts +0 -0
- package/dist/apis/picoding.js +1 -0
- package/dist/model/strategy/adapter/index.d.ts +2 -0
- package/dist/model/strategy/adapter/index.js +3 -1
- package/dist/model/strategy/adapter/itemRule/adapter.d.ts +67 -0
- package/dist/model/strategy/adapter/itemRule/adapter.js +483 -0
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
- package/dist/model/strategy/adapter/itemRule/evaluator.js +169 -0
- package/dist/model/strategy/adapter/itemRule/examples.d.ts +79 -0
- package/dist/model/strategy/adapter/itemRule/examples.js +382 -0
- package/dist/model/strategy/adapter/itemRule/index.d.ts +5 -0
- package/dist/model/strategy/adapter/itemRule/index.js +5 -0
- package/dist/model/strategy/adapter/itemRule/type.d.ts +225 -0
- package/dist/model/strategy/adapter/itemRule/type.js +101 -0
- package/dist/modules/Cart/types.d.ts +2 -0
- package/dist/modules/Cart/utils/cartProduct.js +22 -1
- package/dist/modules/Cart/utils/changePrice.js +6 -0
- package/dist/modules/Date/index.d.ts +1 -1
- package/dist/modules/Date/index.js +16 -8
- package/dist/modules/Date/types.d.ts +3 -1
- package/dist/modules/OpenData/index.d.ts +24 -0
- package/dist/modules/OpenData/index.js +173 -0
- package/dist/modules/OpenData/types.d.ts +73 -0
- package/dist/modules/OpenData/types.js +1 -0
- package/dist/modules/OpenData/utils.d.ts +2 -0
- package/dist/modules/OpenData/utils.js +75 -0
- package/dist/modules/Order/index.d.ts +171 -1
- package/dist/modules/Order/index.js +2052 -112
- package/dist/modules/Order/types.d.ts +441 -20
- package/dist/modules/Order/types.js +23 -0
- package/dist/modules/Order/utils.d.ts +120 -0
- package/dist/modules/Order/utils.js +653 -2
- package/dist/modules/Product/utils.js +2 -2
- package/dist/modules/ProductList/index.js +2 -1
- package/dist/modules/Quotation/index.d.ts +8 -1
- package/dist/modules/Quotation/index.js +40 -10
- package/dist/modules/Quotation/types.d.ts +5 -0
- package/dist/modules/Rules/index.d.ts +3 -1
- package/dist/modules/Rules/index.js +136 -50
- package/dist/modules/Rules/types.d.ts +6 -0
- package/dist/modules/Rules/types.js +8 -0
- package/dist/modules/SalesSummary/index.d.ts +70 -0
- package/dist/modules/SalesSummary/index.js +175 -0
- package/dist/modules/SalesSummary/types.d.ts +64 -0
- package/dist/modules/SalesSummary/types.js +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +34 -0
- package/dist/modules/SalesSummary/utils.js +488 -0
- package/dist/modules/ScanOrderLogger/index.d.ts +21 -0
- package/dist/modules/ScanOrderLogger/index.js +161 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.js +203 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.js +50 -0
- package/dist/modules/ScanOrderLogger/types.d.ts +52 -0
- package/dist/modules/ScanOrderLogger/types.js +1 -0
- package/dist/modules/Schedule/getDateIsInSchedule.js +7 -7
- package/dist/modules/Schedule/index.d.ts +4 -13
- package/dist/modules/Schedule/index.js +6 -23
- package/dist/modules/Schedule/utils.d.ts +1 -1
- package/dist/modules/Summary/index.d.ts +3 -0
- package/dist/modules/Summary/index.js +134 -15
- package/dist/modules/Summary/types.d.ts +7 -0
- package/dist/modules/Summary/utils.d.ts +104 -1
- package/dist/modules/Summary/utils.js +1116 -13
- package/dist/modules/index.d.ts +4 -0
- package/dist/modules/index.js +5 -1
- package/dist/server/index.d.ts +41 -4
- package/dist/server/index.js +900 -405
- package/dist/server/modules/order/index.d.ts +10 -2
- package/dist/server/modules/order/index.js +246 -193
- package/dist/server/modules/products/index.d.ts +26 -0
- package/dist/server/modules/products/index.js +618 -338
- package/dist/server/modules/products/types.d.ts +5 -1
- package/dist/solution/BaseSales/index.d.ts +175 -0
- package/dist/solution/BaseSales/index.js +1293 -0
- package/dist/solution/BaseSales/types.d.ts +305 -0
- package/dist/solution/BaseSales/types.js +38 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +143 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +159 -0
- package/dist/solution/BaseSales/utils.d.ts +40 -0
- package/dist/solution/BaseSales/utils.js +222 -0
- package/dist/solution/BookingByStep/index.d.ts +14 -0
- package/dist/solution/BookingByStep/index.js +699 -212
- package/dist/solution/BookingByStep/types.d.ts +3 -1
- package/dist/solution/BookingByStep/types.js +5 -1
- package/dist/solution/BookingByStep/utils/capacity.js +1 -1
- package/dist/solution/BookingByStep/utils/resources.js +6 -1
- package/dist/solution/BookingTicket/index.d.ts +113 -15
- package/dist/solution/BookingTicket/index.js +534 -196
- package/dist/solution/BookingTicket/types.d.ts +69 -6
- package/dist/solution/BookingTicket/types.js +40 -9
- package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +37 -0
- package/dist/solution/BookingTicket/utils/bookingStatus.js +66 -0
- package/dist/solution/BookingTicket/utils/cartView.d.ts +26 -0
- package/dist/solution/BookingTicket/utils/cartView.js +84 -0
- package/dist/solution/Sales/index.d.ts +1 -0
- package/dist/solution/Sales/index.js +1 -0
- package/dist/solution/ScanOrder/index.d.ts +146 -0
- package/dist/solution/ScanOrder/index.js +3029 -0
- package/dist/solution/ScanOrder/types.d.ts +305 -0
- package/dist/solution/ScanOrder/types.js +35 -0
- package/dist/solution/ScanOrder/utils.d.ts +167 -0
- package/dist/solution/ScanOrder/utils.js +768 -0
- package/dist/solution/ShopDiscount/index.d.ts +2 -0
- package/dist/solution/ShopDiscount/index.js +9 -5
- package/dist/solution/ShopDiscount/types.d.ts +4 -0
- package/dist/solution/VenueBooking/index.d.ts +197 -0
- package/dist/solution/VenueBooking/index.js +3411 -0
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/dist/solution/VenueBooking/types.d.ts +153 -0
- package/dist/solution/VenueBooking/types.js +21 -0
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +104 -0
- package/dist/solution/VenueBooking/utils/resource.d.ts +14 -0
- package/dist/solution/VenueBooking/utils/resource.js +130 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +34 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +224 -0
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/dist/solution/VenueBooking/utils/timeSlot.js +453 -0
- package/dist/solution/VenueBooking/utils.d.ts +1 -0
- package/dist/solution/VenueBooking/utils.js +1 -0
- package/dist/solution/index.d.ts +3 -0
- package/dist/solution/index.js +4 -1
- package/lib/apis/picoding.d.ts +0 -0
- package/lib/apis/picoding.js +0 -0
- package/lib/model/strategy/adapter/index.d.ts +2 -0
- package/lib/model/strategy/adapter/index.js +6 -0
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +67 -0
- package/lib/model/strategy/adapter/itemRule/adapter.js +377 -0
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
- package/lib/model/strategy/adapter/itemRule/evaluator.js +124 -0
- package/lib/model/strategy/adapter/itemRule/examples.d.ts +79 -0
- package/lib/model/strategy/adapter/itemRule/examples.js +316 -0
- package/lib/model/strategy/adapter/itemRule/index.d.ts +5 -0
- package/lib/model/strategy/adapter/itemRule/index.js +60 -0
- package/lib/model/strategy/adapter/itemRule/type.d.ts +225 -0
- package/lib/model/strategy/adapter/itemRule/type.js +46 -0
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/Cart/types.d.ts +2 -0
- package/lib/modules/Cart/utils/cartProduct.js +17 -1
- package/lib/modules/Cart/utils/changePrice.js +5 -0
- package/lib/modules/Date/index.d.ts +1 -1
- package/lib/modules/Date/index.js +7 -1
- package/lib/modules/Date/types.d.ts +3 -1
- package/lib/modules/OpenData/index.d.ts +24 -0
- package/lib/modules/OpenData/index.js +119 -0
- package/lib/modules/OpenData/types.d.ts +73 -0
- package/lib/modules/OpenData/types.js +17 -0
- package/lib/modules/OpenData/utils.d.ts +2 -0
- package/lib/modules/OpenData/utils.js +111 -0
- package/lib/modules/Order/index.d.ts +171 -1
- package/lib/modules/Order/index.js +1396 -5
- package/lib/modules/Order/types.d.ts +441 -20
- package/lib/modules/Order/types.js +1 -0
- package/lib/modules/Order/utils.d.ts +120 -0
- package/lib/modules/Order/utils.js +562 -2
- package/lib/modules/Product/utils.js +2 -2
- package/lib/modules/ProductList/index.js +2 -1
- package/lib/modules/Quotation/index.d.ts +8 -1
- package/lib/modules/Quotation/index.js +33 -4
- package/lib/modules/Quotation/types.d.ts +5 -0
- package/lib/modules/Rules/index.d.ts +3 -1
- package/lib/modules/Rules/index.js +46 -6
- package/lib/modules/Rules/types.d.ts +6 -0
- package/lib/modules/Rules/types.js +11 -2
- package/lib/modules/SalesSummary/index.d.ts +70 -0
- package/lib/modules/SalesSummary/index.js +106 -0
- package/lib/modules/SalesSummary/types.d.ts +64 -0
- package/lib/modules/SalesSummary/types.js +17 -0
- package/lib/modules/SalesSummary/utils.d.ts +34 -0
- package/lib/modules/SalesSummary/utils.js +430 -0
- package/lib/modules/ScanOrderLogger/index.d.ts +21 -0
- package/lib/modules/ScanOrderLogger/index.js +135 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.js +148 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.js +52 -0
- package/lib/modules/ScanOrderLogger/types.d.ts +52 -0
- package/lib/modules/ScanOrderLogger/types.js +17 -0
- package/lib/modules/Schedule/getDateIsInSchedule.js +5 -5
- package/lib/modules/Schedule/index.d.ts +4 -13
- package/lib/modules/Schedule/index.js +4 -15
- package/lib/modules/Schedule/utils.d.ts +1 -1
- package/lib/modules/Summary/index.d.ts +3 -0
- package/lib/modules/Summary/index.js +61 -2
- package/lib/modules/Summary/types.d.ts +7 -0
- package/lib/modules/Summary/utils.d.ts +104 -1
- package/lib/modules/Summary/utils.js +659 -8
- package/lib/modules/index.d.ts +4 -0
- package/lib/modules/index.js +9 -1
- package/lib/server/index.d.ts +41 -4
- package/lib/server/index.js +272 -10
- package/lib/server/modules/order/index.d.ts +10 -2
- package/lib/server/modules/order/index.js +26 -1
- package/lib/server/modules/products/index.d.ts +26 -0
- package/lib/server/modules/products/index.js +174 -22
- package/lib/server/modules/products/types.d.ts +5 -1
- package/lib/solution/BaseSales/index.d.ts +175 -0
- package/lib/solution/BaseSales/index.js +655 -0
- package/lib/solution/BaseSales/types.d.ts +305 -0
- package/lib/solution/BaseSales/types.js +40 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +143 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +160 -0
- package/lib/solution/BaseSales/utils.d.ts +40 -0
- package/lib/solution/BaseSales/utils.js +200 -0
- package/lib/solution/BookingByStep/index.d.ts +14 -0
- package/lib/solution/BookingByStep/index.js +469 -91
- package/lib/solution/BookingByStep/types.d.ts +3 -1
- package/lib/solution/BookingByStep/types.js +10 -0
- package/lib/solution/BookingByStep/utils/capacity.js +1 -1
- package/lib/solution/BookingByStep/utils/resources.js +5 -2
- package/lib/solution/BookingTicket/index.d.ts +113 -15
- package/lib/solution/BookingTicket/index.js +253 -61
- package/lib/solution/BookingTicket/types.d.ts +69 -6
- package/lib/solution/BookingTicket/types.js +16 -14
- package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +37 -0
- package/lib/solution/BookingTicket/utils/bookingStatus.js +65 -0
- package/lib/solution/BookingTicket/utils/cartView.d.ts +26 -0
- package/lib/solution/BookingTicket/utils/cartView.js +103 -0
- package/lib/solution/Sales/index.d.ts +1 -0
- package/lib/solution/ScanOrder/index.d.ts +146 -0
- package/lib/solution/ScanOrder/index.js +1820 -0
- package/lib/solution/ScanOrder/types.d.ts +305 -0
- package/lib/solution/ScanOrder/types.js +36 -0
- package/lib/solution/ScanOrder/utils.d.ts +167 -0
- package/lib/solution/ScanOrder/utils.js +639 -0
- package/lib/solution/ShopDiscount/index.d.ts +2 -0
- package/lib/solution/ShopDiscount/index.js +9 -4
- package/lib/solution/ShopDiscount/types.d.ts +4 -0
- package/lib/solution/VenueBooking/index.d.ts +197 -0
- package/lib/solution/VenueBooking/index.js +1892 -0
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/lib/solution/VenueBooking/types.d.ts +153 -0
- package/lib/solution/VenueBooking/types.js +44 -0
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +110 -0
- package/lib/solution/VenueBooking/utils/resource.d.ts +14 -0
- package/lib/solution/VenueBooking/utils/resource.js +91 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +34 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +225 -0
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/lib/solution/VenueBooking/utils/timeSlot.js +339 -0
- package/lib/solution/VenueBooking/utils.d.ts +1 -0
- package/lib/solution/VenueBooking/utils.js +69 -0
- package/lib/solution/index.d.ts +3 -0
- package/lib/solution/index.js +7 -1
- package/package.json +1 -1
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import { OrderModule, ProductList, SalesSummaryModule, ScanOrderLoggerModule as BaseSalesLoggerModule, ScheduleModule } from '../../modules';
|
|
2
|
+
import type { ScanOrderLogInput as BaseSalesLogInput, ScanOrderLoggerProviderConfig as BaseSalesLoggerProviderConfig, ScanOrderLoggerProviderType as BaseSalesLoggerProviderType } from '../../modules/ScanOrderLogger/types';
|
|
3
|
+
import type { QuantityCheckResult, QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
|
|
4
|
+
/**
|
|
5
|
+
* BaseSales 流程 hook 后缀。
|
|
6
|
+
* 完整事件名应由当前模块名动态拼接,避免多个实例共享固定事件 key。
|
|
7
|
+
*/
|
|
8
|
+
export declare const BaseSalesHookNames: {
|
|
9
|
+
readonly onInited: "onInited";
|
|
10
|
+
readonly onDestroy: "onDestroy";
|
|
11
|
+
readonly onRetryInit: "onRetryInit";
|
|
12
|
+
readonly onRefresh: "onRefresh";
|
|
13
|
+
readonly onCartValidationChanged: "onCartValidationChanged";
|
|
14
|
+
};
|
|
15
|
+
export type BaseSalesHookName = typeof BaseSalesHookNames[keyof typeof BaseSalesHookNames];
|
|
16
|
+
export declare function createBaseSalesHook(moduleName: string, hookName: BaseSalesHookName): string;
|
|
17
|
+
export type BaseSalesStatus = 'idle' | 'initializing' | 'ready' | 'error';
|
|
18
|
+
export type BaseSalesPaymentStatus = 'paid' | 'partially_paid' | 'unpaid' | 'payment_processing' | string;
|
|
19
|
+
export interface BaseSalesEntryContext {
|
|
20
|
+
biz: string;
|
|
21
|
+
mode: 'scan' | 'append';
|
|
22
|
+
resourceId?: string;
|
|
23
|
+
sourceOrderId?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface BaseSalesConfig {
|
|
26
|
+
orderSource: 'local' | 'remote';
|
|
27
|
+
scanTimeout: number;
|
|
28
|
+
allowAppend: boolean;
|
|
29
|
+
maxAppendCount: number;
|
|
30
|
+
features: {
|
|
31
|
+
autoMerge: boolean;
|
|
32
|
+
verifyResource: boolean;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export interface BaseSalesOrderProductIdentity {
|
|
36
|
+
product_id: number | null;
|
|
37
|
+
product_variant_id: number;
|
|
38
|
+
/** @deprecated 行级唯一值统一使用 metadata.unique_identification_number */
|
|
39
|
+
identity_key?: string;
|
|
40
|
+
unique_identification_number?: string;
|
|
41
|
+
/** 参与合并/匹配;与 remove 通配语义见 isSkuOnlyDeleteIdentity */
|
|
42
|
+
product_option_item?: any[];
|
|
43
|
+
product_bundle?: any[];
|
|
44
|
+
}
|
|
45
|
+
export interface BaseSalesOrderProduct extends BaseSalesOrderProductIdentity {
|
|
46
|
+
order_detail_id: number | null;
|
|
47
|
+
num: number;
|
|
48
|
+
product_option_item: any[];
|
|
49
|
+
/**
|
|
50
|
+
* 券后 **行 composite 单价** = `metadata.main_product_selling_price`
|
|
51
|
+
* + Σ((bundle.bundle_selling_price ?? bundle.price) × (bundle.num ?? 1))
|
|
52
|
+
*
|
|
53
|
+
* 新语义 v2 下 `metadata.main_product_selling_price` 已经**含 option**、含主商品折扣,
|
|
54
|
+
* 因此本字段不再叠加 option。未应用券时等同 `original_price`。
|
|
55
|
+
* Rules 钩子、主商品计税、Summary 统一读 metadata,不以此字段反推。
|
|
56
|
+
*/
|
|
57
|
+
selling_price: string;
|
|
58
|
+
/**
|
|
59
|
+
* 券前 **行 composite 单价** = `metadata.main_product_original_price`
|
|
60
|
+
* + Σ(bundle 原价 × num)
|
|
61
|
+
*
|
|
62
|
+
* 新语义 v2 下 `metadata.main_product_original_price` 已经**含 option**、不含折扣。
|
|
63
|
+
* 不承载后台划线价语义。
|
|
64
|
+
*/
|
|
65
|
+
original_price: string;
|
|
66
|
+
tax_fee: string;
|
|
67
|
+
is_charge_tax: number;
|
|
68
|
+
discount_list: any[];
|
|
69
|
+
product_bundle: any[];
|
|
70
|
+
/** 关联 booking.metadata.unique_identification_number */
|
|
71
|
+
booking_uid?: string;
|
|
72
|
+
/**
|
|
73
|
+
* 行级扩展 metadata。价格相关的权威字段:
|
|
74
|
+
*
|
|
75
|
+
* - `source_product_price`:主商品/variant 基础价(已应用报价单),**不含 option、不含折扣**。
|
|
76
|
+
* 是派生 `main_product_*` 的唯一源。variant 分支优先读 `metadata.origin.variant[vid].price`。
|
|
77
|
+
* - `main_product_original_price` = `source_product_price + Σ(option.price × option.num)`,
|
|
78
|
+
* **含 option、不含折扣**。
|
|
79
|
+
* - `main_product_selling_price` = `main_product_original_price − 主商品券 per-unit amount`,
|
|
80
|
+
* **含 option、含主商品折扣**。Rules 钩子 / Summary / 计税均以此为主商品权威源。
|
|
81
|
+
* - `price_schema_version`(当前 = 2):schema 版本 sentinel,用于跨端协商价格口径、
|
|
82
|
+
* 区分 v1 旧缓存以便 `normalizeOrderProduct` 触发迁移。
|
|
83
|
+
*/
|
|
84
|
+
metadata: Record<string, any>;
|
|
85
|
+
/** 商品行备注(如顾客对单品的特殊要求) */
|
|
86
|
+
note?: string;
|
|
87
|
+
/** @deprecated UI/SDK 运行态数据迁移到 tempOrder._extend */
|
|
88
|
+
_origin?: Record<string, any>;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* 出站 payload 版本的商品行。
|
|
92
|
+
*
|
|
93
|
+
* 与 tempOrder 内部 `BaseSalesOrderProduct` 的字段差异:
|
|
94
|
+
* - `product_option_item[*]`:内部为 `{ product_option_item_id, option_group_id, num, price, ... }`,
|
|
95
|
+
* 出站由 `normalizeSubmitProduct` 重命名为 `{ option_group_item_id, option_group_id, num }`
|
|
96
|
+
* (后端 checkout 协议;丢弃 `price` 等运行时辅助字段)。
|
|
97
|
+
* - `product_bundle[*].option[*]`:同上重命名规则。
|
|
98
|
+
*
|
|
99
|
+
* 运行时(UI 显示、加购合并、指纹、持久化)全部消费内部字段名 `product_option_item_id`,
|
|
100
|
+
* 仅在 SDK 提交边界做一次出站映射,不影响 opaque identity 契约。
|
|
101
|
+
*/
|
|
102
|
+
export interface BaseSalesSubmitProduct extends Omit<BaseSalesOrderProduct, '_origin' | 'identity_key'> {
|
|
103
|
+
/**
|
|
104
|
+
* 出站兼容字段:SDK 内部不再消费 payment_price,
|
|
105
|
+
* 仅在提交后端时由 selling_price 派生,保持原有后端契约。
|
|
106
|
+
* 新语义 v2 下 selling_price 是 composite(含 option、含 bundle、含主商品折扣),
|
|
107
|
+
* 因此 payment_price 同样是 composite。
|
|
108
|
+
*/
|
|
109
|
+
payment_price: string;
|
|
110
|
+
}
|
|
111
|
+
export interface BaseSalesSummary {
|
|
112
|
+
product_quantity: number;
|
|
113
|
+
product_original_amount: string;
|
|
114
|
+
product_amount: string;
|
|
115
|
+
product_expect_amount: string;
|
|
116
|
+
product_tax_fee: string;
|
|
117
|
+
shipping_fee: string;
|
|
118
|
+
shipping_tax_fee: string;
|
|
119
|
+
tax_fee: string;
|
|
120
|
+
surcharge_fee: string;
|
|
121
|
+
discount_amount: string;
|
|
122
|
+
deposit_amount: string;
|
|
123
|
+
deposit?: {
|
|
124
|
+
total: string;
|
|
125
|
+
deposit_policy_ids: number[];
|
|
126
|
+
hasDeposit: boolean;
|
|
127
|
+
};
|
|
128
|
+
expect_amount: string;
|
|
129
|
+
total_amount: string;
|
|
130
|
+
amount_gap: string;
|
|
131
|
+
rounding_amount: string;
|
|
132
|
+
pay_service_charge_amount: string;
|
|
133
|
+
tax_title?: string;
|
|
134
|
+
tax_rate?: number;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* BaseSales 临时订单(runtime-clean 版本)
|
|
138
|
+
* 只保留运行时字段,不包含任何 __comment 字段
|
|
139
|
+
*/
|
|
140
|
+
export interface BaseSalesTempOrder {
|
|
141
|
+
order_id: number | null;
|
|
142
|
+
/** @deprecated 资源运行态迁移到 Solution store */
|
|
143
|
+
relation_id?: string;
|
|
144
|
+
/** @deprecated 资源运行态迁移到 Solution store */
|
|
145
|
+
table_form_id?: string;
|
|
146
|
+
/** @deprecated 资源运行态迁移到 Solution store */
|
|
147
|
+
resource_id?: string;
|
|
148
|
+
external_sale_number: string;
|
|
149
|
+
order_number: string;
|
|
150
|
+
shop_order_number: string;
|
|
151
|
+
shop_full_order_number: string;
|
|
152
|
+
type: string;
|
|
153
|
+
business_code: string;
|
|
154
|
+
platform: string;
|
|
155
|
+
sales_channel: string;
|
|
156
|
+
order_sales_channel: string;
|
|
157
|
+
status: string;
|
|
158
|
+
payment_status: string;
|
|
159
|
+
shipping_status: string;
|
|
160
|
+
customer_id: number | null;
|
|
161
|
+
customer_name: string;
|
|
162
|
+
country_calling_code: string;
|
|
163
|
+
phone: string;
|
|
164
|
+
email: string;
|
|
165
|
+
is_price_include_tax: number;
|
|
166
|
+
tax_title: string;
|
|
167
|
+
tax_country_code: string;
|
|
168
|
+
currency_code: string;
|
|
169
|
+
currency_symbol: string;
|
|
170
|
+
currency_format: string;
|
|
171
|
+
is_deposit: number;
|
|
172
|
+
deposit_amount: string;
|
|
173
|
+
shop_discount: string;
|
|
174
|
+
surcharge_fee: string;
|
|
175
|
+
note: string;
|
|
176
|
+
buzzer?: string;
|
|
177
|
+
delivery_type?: string;
|
|
178
|
+
table_number?: Record<string, any>;
|
|
179
|
+
schedule_date: string;
|
|
180
|
+
created_at: string;
|
|
181
|
+
request_unique_idempotency_token?: string;
|
|
182
|
+
products: BaseSalesOrderProduct[];
|
|
183
|
+
bookings: any[];
|
|
184
|
+
payments: any[];
|
|
185
|
+
surcharges: any[];
|
|
186
|
+
discount_list: any[];
|
|
187
|
+
relation_forms: any[];
|
|
188
|
+
contacts: any[];
|
|
189
|
+
contacts_info: Record<string, any> | null;
|
|
190
|
+
holder: Record<string, any> | null;
|
|
191
|
+
metadata: Record<string, any>;
|
|
192
|
+
_extend?: {
|
|
193
|
+
productsByUid?: Record<string, Record<string, any>>;
|
|
194
|
+
[key: string]: any;
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
export interface BaseSalesSubmitPayload extends Omit<BaseSalesTempOrder, 'platform' | 'products' | '_extend' | 'shop_full_order_number'> {
|
|
198
|
+
platform: string;
|
|
199
|
+
request_unique_idempotency_token?: string;
|
|
200
|
+
form_record_ids?: Array<{
|
|
201
|
+
form_id: number | string;
|
|
202
|
+
form_record_id: number | string;
|
|
203
|
+
}>;
|
|
204
|
+
products: BaseSalesSubmitProduct[];
|
|
205
|
+
}
|
|
206
|
+
export type BaseSalesAvailabilityMode = 'idle' | 'shop_closed' | 'submit_disabled' | 'resource_busy' | 'additional_order_with_code' | 'additional_order';
|
|
207
|
+
export interface BaseSalesTableFormRecord {
|
|
208
|
+
policy?: string | null;
|
|
209
|
+
partyroom_booking?: string | null;
|
|
210
|
+
capacity?: number | string | null;
|
|
211
|
+
[key: string]: any;
|
|
212
|
+
}
|
|
213
|
+
export interface BaseSalesAvailabilityInfo {
|
|
214
|
+
mode: BaseSalesAvailabilityMode;
|
|
215
|
+
order_id?: string;
|
|
216
|
+
relation_id?: string;
|
|
217
|
+
table_form_id?: string;
|
|
218
|
+
deskmate_valid?: boolean;
|
|
219
|
+
errorTips?: string;
|
|
220
|
+
/** 透传 `availability.closed_behavior`,便于 UI 识别拦截类型(如 show_menu_disabled) */
|
|
221
|
+
closed_behavior?: string;
|
|
222
|
+
/** `/order/resource/occupy-detail` 返回的 `form_record` 原样透出 */
|
|
223
|
+
table_form_record?: BaseSalesTableFormRecord | null;
|
|
224
|
+
policy?: string | null;
|
|
225
|
+
partyroom_booking?: string | null;
|
|
226
|
+
/** 预约规则关联商品存在 custom 容量时,由 checkResourceAvailable 置为 1 */
|
|
227
|
+
requestEntryPax?: number;
|
|
228
|
+
/** 首个 `capacity.type === 'custom'` 商品里 `custom[0]` 的 min(人数下限) */
|
|
229
|
+
requestPaxMin?: number;
|
|
230
|
+
/** 首个 `capacity.type === 'custom'` 商品里 `custom[0]` 的 max(人数上限) */
|
|
231
|
+
requestPaxMax?: number;
|
|
232
|
+
}
|
|
233
|
+
/** `resource_capacity[i].capacity_list[j]` */
|
|
234
|
+
export interface BaseSalesResourceCapacitySlot {
|
|
235
|
+
start_at?: string;
|
|
236
|
+
end_at?: string;
|
|
237
|
+
pax?: number | string;
|
|
238
|
+
}
|
|
239
|
+
export interface BaseSalesResourceCapacity {
|
|
240
|
+
capacity?: number | string;
|
|
241
|
+
capacity_list?: BaseSalesResourceCapacitySlot[];
|
|
242
|
+
}
|
|
243
|
+
/** `/order/resource/occupy-detail` 单条 `occupy_details[i]` */
|
|
244
|
+
export interface BaseSalesResourceOccupyDetail {
|
|
245
|
+
form_record_id?: number | string | null;
|
|
246
|
+
form_id?: number | string | null;
|
|
247
|
+
order_id?: number | string | null;
|
|
248
|
+
last_order_id?: number | string | null;
|
|
249
|
+
resource_capacity?: BaseSalesResourceCapacity[] | null;
|
|
250
|
+
form_record?: BaseSalesTableFormRecord | null;
|
|
251
|
+
[key: string]: any;
|
|
252
|
+
}
|
|
253
|
+
export interface BaseSalesResourceOccupyDetailApiResponse {
|
|
254
|
+
status?: boolean;
|
|
255
|
+
code?: number;
|
|
256
|
+
message?: string;
|
|
257
|
+
data?: {
|
|
258
|
+
occupy_details?: BaseSalesResourceOccupyDetail[] | null;
|
|
259
|
+
} | null;
|
|
260
|
+
}
|
|
261
|
+
export type BaseSalesResourceSelectType = 'single' | 'multiple' | 'capacity';
|
|
262
|
+
export interface BaseSalesResourceState extends BaseSalesAvailabilityInfo {
|
|
263
|
+
relationId?: string;
|
|
264
|
+
tableFormId?: string;
|
|
265
|
+
currentOrderId?: string;
|
|
266
|
+
lastOrderId?: string;
|
|
267
|
+
allowSnack: boolean;
|
|
268
|
+
deskmateValid: boolean;
|
|
269
|
+
isExclusive: boolean;
|
|
270
|
+
isFull: boolean;
|
|
271
|
+
/** 来自首个预约规则商品 product_resource.resources 中与 form_id 匹配的 resource type */
|
|
272
|
+
resourceSelectType?: BaseSalesResourceSelectType;
|
|
273
|
+
raw: BaseSalesResourceOccupyDetail | null;
|
|
274
|
+
}
|
|
275
|
+
export interface BaseSalesState {
|
|
276
|
+
entryContext: BaseSalesEntryContext | null;
|
|
277
|
+
status: BaseSalesStatus;
|
|
278
|
+
config: Record<string, any> | null;
|
|
279
|
+
resource: BaseSalesResourceState | null;
|
|
280
|
+
flow: Record<string, any>;
|
|
281
|
+
error: string | null;
|
|
282
|
+
products?: ProductList;
|
|
283
|
+
order?: OrderModule;
|
|
284
|
+
salesSummary?: SalesSummaryModule;
|
|
285
|
+
baseSalesLogger?: BaseSalesLoggerModule;
|
|
286
|
+
schedule?: ScheduleModule;
|
|
287
|
+
itemRuleQuantityLimits: QuantityLimitResult[];
|
|
288
|
+
cartValidation: {
|
|
289
|
+
passed: boolean | null;
|
|
290
|
+
failures: QuantityCheckResult[];
|
|
291
|
+
};
|
|
292
|
+
entryPaxNumber: number | null;
|
|
293
|
+
}
|
|
294
|
+
export interface BaseSalesLoggerRuntimeConfig {
|
|
295
|
+
provider?: BaseSalesLoggerProviderType;
|
|
296
|
+
providerConfig?: BaseSalesLoggerProviderConfig;
|
|
297
|
+
}
|
|
298
|
+
export interface BaseSalesAddLogParams extends BaseSalesLogInput {
|
|
299
|
+
}
|
|
300
|
+
/** BaseSales.scanPromotionCode 对外的轻量结果(不含 discountList,UI 在 resolve 后调 getDiscountList) */
|
|
301
|
+
export interface BaseSalesScanCodeResult {
|
|
302
|
+
isAvailable: boolean;
|
|
303
|
+
type?: 'server' | string;
|
|
304
|
+
unavailableReason?: 'time_limit' | string;
|
|
305
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BaseSales 流程 hook 后缀。
|
|
3
|
+
* 完整事件名应由当前模块名动态拼接,避免多个实例共享固定事件 key。
|
|
4
|
+
*/
|
|
5
|
+
export var BaseSalesHookNames = {
|
|
6
|
+
onInited: 'onInited',
|
|
7
|
+
onDestroy: 'onDestroy',
|
|
8
|
+
onRetryInit: 'onRetryInit',
|
|
9
|
+
onRefresh: 'onRefresh',
|
|
10
|
+
onCartValidationChanged: 'onCartValidationChanged'
|
|
11
|
+
};
|
|
12
|
+
export function createBaseSalesHook(moduleName, hookName) {
|
|
13
|
+
return "".concat(moduleName, ":").concat(hookName);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 出站 payload 版本的商品行。
|
|
18
|
+
*
|
|
19
|
+
* 与 tempOrder 内部 `BaseSalesOrderProduct` 的字段差异:
|
|
20
|
+
* - `product_option_item[*]`:内部为 `{ product_option_item_id, option_group_id, num, price, ... }`,
|
|
21
|
+
* 出站由 `normalizeSubmitProduct` 重命名为 `{ option_group_item_id, option_group_id, num }`
|
|
22
|
+
* (后端 checkout 协议;丢弃 `price` 等运行时辅助字段)。
|
|
23
|
+
* - `product_bundle[*].option[*]`:同上重命名规则。
|
|
24
|
+
*
|
|
25
|
+
* 运行时(UI 显示、加购合并、指纹、持久化)全部消费内部字段名 `product_option_item_id`,
|
|
26
|
+
* 仅在 SDK 提交边界做一次出站映射,不影响 opaque identity 契约。
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* BaseSales 临时订单(runtime-clean 版本)
|
|
31
|
+
* 只保留运行时字段,不包含任何 __comment 字段
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/** `resource_capacity[i].capacity_list[j]` */
|
|
35
|
+
|
|
36
|
+
/** `/order/resource/occupy-detail` 单条 `occupy_details[i]` */
|
|
37
|
+
|
|
38
|
+
/** BaseSales.scanPromotionCode 对外的轻量结果(不含 discountList,UI 在 resolve 后调 getDiscountList) */
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 把 `/order/sales/{id}` 响应(OrderData)解析为 ISalesDetail。
|
|
3
|
+
*
|
|
4
|
+
* - 纯函数:不依赖任何运行时模块/插件,便于单测与 view-model 适配
|
|
5
|
+
* - products 保留 tempOrder / 后端详情原字段,仅做浅拷贝,避免丢失 product_sku 等协议字段
|
|
6
|
+
* - bookings 平铺保留服务端原顺序,同时输出 byProductUid 反查表与 rootBooking
|
|
7
|
+
* - header 收敛"非数组顶层字段",便于 ticketBooking view-model 直接消费
|
|
8
|
+
*
|
|
9
|
+
* 设计原则参考 `.cursor/rules/data-field-semantics.mdc`:
|
|
10
|
+
* - 字段命名以《统一 Sales 数据协议》为准(OrderData 类型)
|
|
11
|
+
* - root booking 以 `parent_id === 0` 判定,沿用 ticketBooking 现有约定
|
|
12
|
+
* (`packages/private-materials/src/components/ticketBooking/index.tsx`:
|
|
13
|
+
* `booking.parent_id === 0 ? 'list' : 'detail'`)
|
|
14
|
+
* - 不在此处发明等价关系;UI 侧(ticketBooking)若需要别的字段,由 view-model 适配层做转换
|
|
15
|
+
*/
|
|
16
|
+
import type { BaseSalesOrderProduct } from '../types';
|
|
17
|
+
export interface ISalesDetailHeader {
|
|
18
|
+
order_id: number | string | null;
|
|
19
|
+
order_number?: string;
|
|
20
|
+
shop_order_number?: string;
|
|
21
|
+
shop_full_order_number?: string;
|
|
22
|
+
type?: string;
|
|
23
|
+
business_code?: string;
|
|
24
|
+
platform?: string;
|
|
25
|
+
sales_channel?: string;
|
|
26
|
+
order_sales_channel?: string;
|
|
27
|
+
status?: string;
|
|
28
|
+
payment_status?: string;
|
|
29
|
+
shipping_status?: string;
|
|
30
|
+
customer_id?: number | string | null;
|
|
31
|
+
customer_name?: string;
|
|
32
|
+
country_calling_code?: string;
|
|
33
|
+
phone?: string;
|
|
34
|
+
email?: string;
|
|
35
|
+
is_price_include_tax?: 0 | 1;
|
|
36
|
+
tax_title?: string;
|
|
37
|
+
tax_country_code?: string;
|
|
38
|
+
currency_code?: string;
|
|
39
|
+
currency_symbol?: string;
|
|
40
|
+
currency_format?: string;
|
|
41
|
+
is_deposit?: 0 | 1;
|
|
42
|
+
deposit_amount?: string;
|
|
43
|
+
shop_discount?: string;
|
|
44
|
+
surcharge_fee?: string;
|
|
45
|
+
note?: string;
|
|
46
|
+
schedule_date?: string;
|
|
47
|
+
created_at?: string;
|
|
48
|
+
updated_at?: string | number;
|
|
49
|
+
metadata?: Record<string, any> | null;
|
|
50
|
+
total_amount?: string | number;
|
|
51
|
+
[key: string]: any;
|
|
52
|
+
}
|
|
53
|
+
export interface ISalesDetailCustomer {
|
|
54
|
+
id: number | string | null;
|
|
55
|
+
name: string;
|
|
56
|
+
phone?: string;
|
|
57
|
+
email?: string;
|
|
58
|
+
country_calling_code?: string;
|
|
59
|
+
[key: string]: any;
|
|
60
|
+
}
|
|
61
|
+
export interface ISalesBooking {
|
|
62
|
+
schedule_event_id?: number | null;
|
|
63
|
+
booking_id?: string;
|
|
64
|
+
appointment_status?: string;
|
|
65
|
+
status?: string;
|
|
66
|
+
start_date?: string;
|
|
67
|
+
start_time?: string;
|
|
68
|
+
end_date?: string;
|
|
69
|
+
end_time?: string;
|
|
70
|
+
duration?: number;
|
|
71
|
+
sub_type?: string;
|
|
72
|
+
number?: number;
|
|
73
|
+
resources?: any[];
|
|
74
|
+
product?: any;
|
|
75
|
+
relation_products?: any[];
|
|
76
|
+
relation_type?: string;
|
|
77
|
+
relation_id?: number;
|
|
78
|
+
parent_id?: number | null;
|
|
79
|
+
item_type?: string;
|
|
80
|
+
product_uid?: string;
|
|
81
|
+
metadata?: Record<string, any> | null;
|
|
82
|
+
[key: string]: any;
|
|
83
|
+
}
|
|
84
|
+
export interface ISalesPayment {
|
|
85
|
+
order_payment_id?: number | null;
|
|
86
|
+
custom_payment_id?: number;
|
|
87
|
+
code?: string;
|
|
88
|
+
name?: string;
|
|
89
|
+
type?: string;
|
|
90
|
+
voucher_id?: number | null;
|
|
91
|
+
amount: string;
|
|
92
|
+
origin_amount?: string;
|
|
93
|
+
rounding_amount?: string;
|
|
94
|
+
status?: string;
|
|
95
|
+
payment_time?: string | null;
|
|
96
|
+
service_charge?: Record<string, any> | null;
|
|
97
|
+
metadata?: Record<string, any> | null;
|
|
98
|
+
[key: string]: any;
|
|
99
|
+
}
|
|
100
|
+
export interface ISalesSurcharge {
|
|
101
|
+
order_surcharge_id?: number | null;
|
|
102
|
+
surcharge_id?: number;
|
|
103
|
+
type?: string;
|
|
104
|
+
name?: Record<string, string>;
|
|
105
|
+
description?: Record<string, string>;
|
|
106
|
+
percentage?: string | null;
|
|
107
|
+
fixed?: string | null;
|
|
108
|
+
amount?: string;
|
|
109
|
+
[key: string]: any;
|
|
110
|
+
}
|
|
111
|
+
export interface ISalesDetail {
|
|
112
|
+
/** 顶部订单字段集合(不含 products / bookings / payments / surcharges 等大数组) */
|
|
113
|
+
header: ISalesDetailHeader;
|
|
114
|
+
/** 商品行快照(保留 tempOrder / 后端详情原字段) */
|
|
115
|
+
products: BaseSalesOrderProduct[];
|
|
116
|
+
/** 全部 bookings,按服务端原始顺序输出(含 root + child) */
|
|
117
|
+
bookings: ISalesBooking[];
|
|
118
|
+
/** root booking(parent_id === 0),多个时取首个,无则为 null */
|
|
119
|
+
rootBooking: ISalesBooking | null;
|
|
120
|
+
/** product_uid → bookings 反查表,便于商品行 ↔ booking 映射 */
|
|
121
|
+
bookingsByProductUid: Record<string, ISalesBooking[]>;
|
|
122
|
+
/** 支付列表 */
|
|
123
|
+
payments: ISalesPayment[];
|
|
124
|
+
/** 附加费 */
|
|
125
|
+
surcharges: ISalesSurcharge[];
|
|
126
|
+
/** 订单级折扣列表 */
|
|
127
|
+
discount_list: any[];
|
|
128
|
+
/** 客户信息(按 header 抽取,必要时透传 raw.customer) */
|
|
129
|
+
customer: ISalesDetailCustomer | null;
|
|
130
|
+
/** 服务端 summary(仅输出) */
|
|
131
|
+
summary: Record<string, any>;
|
|
132
|
+
/** 原始响应快照,方便 UI 兜底使用 */
|
|
133
|
+
raw: Record<string, any>;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* 将 `/order/sales/{id}` 响应解析为 ISalesDetail。
|
|
137
|
+
*
|
|
138
|
+
* 注意:
|
|
139
|
+
* - 入参允许是 `{ data: OrderData }` 或直接 `OrderData`,自动识别。
|
|
140
|
+
* - products 保留原字段;字段补齐由 OrderModule hydrate 负责。
|
|
141
|
+
* - 不做远程请求;不修改入参;返回新对象。
|
|
142
|
+
*/
|
|
143
|
+
export declare function parseSalesResponse(input: Record<string, any> | null | undefined): ISalesDetail;
|
|
@@ -0,0 +1,159 @@
|
|
|
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 _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; }
|
|
4
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
5
|
+
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); }
|
|
6
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
7
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
9
|
+
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); }
|
|
10
|
+
/**
|
|
11
|
+
* 把 `/order/sales/{id}` 响应(OrderData)解析为 ISalesDetail。
|
|
12
|
+
*
|
|
13
|
+
* - 纯函数:不依赖任何运行时模块/插件,便于单测与 view-model 适配
|
|
14
|
+
* - products 保留 tempOrder / 后端详情原字段,仅做浅拷贝,避免丢失 product_sku 等协议字段
|
|
15
|
+
* - bookings 平铺保留服务端原顺序,同时输出 byProductUid 反查表与 rootBooking
|
|
16
|
+
* - header 收敛"非数组顶层字段",便于 ticketBooking view-model 直接消费
|
|
17
|
+
*
|
|
18
|
+
* 设计原则参考 `.cursor/rules/data-field-semantics.mdc`:
|
|
19
|
+
* - 字段命名以《统一 Sales 数据协议》为准(OrderData 类型)
|
|
20
|
+
* - root booking 以 `parent_id === 0` 判定,沿用 ticketBooking 现有约定
|
|
21
|
+
* (`packages/private-materials/src/components/ticketBooking/index.tsx`:
|
|
22
|
+
* `booking.parent_id === 0 ? 'list' : 'detail'`)
|
|
23
|
+
* - 不在此处发明等价关系;UI 侧(ticketBooking)若需要别的字段,由 view-model 适配层做转换
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/** OrderData 中除大数组外的"顶层 header 字段"白名单,按需扩展。 */
|
|
27
|
+
var HEADER_KEYS = ['order_id', 'order_number', 'shop_order_number', 'shop_full_order_number', 'type', 'business_code', 'platform', 'sales_channel', 'order_sales_channel', 'status', 'payment_status', 'shipping_status', 'customer_id', 'customer_name', 'country_calling_code', 'phone', 'email', 'is_price_include_tax', 'tax_title', 'tax_country_code', 'currency_code', 'currency_symbol', 'currency_format', 'is_deposit', 'deposit_amount', 'shop_discount', 'surcharge_fee', 'note', 'schedule_date', 'created_at', 'updated_at', 'metadata', 'total_amount', 'shop_id', 'create_date', 'holder', 'relation_forms', 'contacts', 'contacts_info'];
|
|
28
|
+
function pickHeader(raw) {
|
|
29
|
+
var _raw$order_id;
|
|
30
|
+
var header = {
|
|
31
|
+
order_id: (_raw$order_id = raw === null || raw === void 0 ? void 0 : raw.order_id) !== null && _raw$order_id !== void 0 ? _raw$order_id : null
|
|
32
|
+
};
|
|
33
|
+
if (!raw || _typeof(raw) !== 'object') return header;
|
|
34
|
+
var _iterator = _createForOfIteratorHelper(HEADER_KEYS),
|
|
35
|
+
_step;
|
|
36
|
+
try {
|
|
37
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
38
|
+
var _key = _step.value;
|
|
39
|
+
if (raw[_key] !== undefined) header[_key] = raw[_key];
|
|
40
|
+
}
|
|
41
|
+
} catch (err) {
|
|
42
|
+
_iterator.e(err);
|
|
43
|
+
} finally {
|
|
44
|
+
_iterator.f();
|
|
45
|
+
}
|
|
46
|
+
return header;
|
|
47
|
+
}
|
|
48
|
+
function pickCustomer(raw) {
|
|
49
|
+
var _raw$customer_id, _raw$customer_name;
|
|
50
|
+
if (!raw || _typeof(raw) !== 'object') return null;
|
|
51
|
+
var explicit = raw.customer;
|
|
52
|
+
if (explicit && _typeof(explicit) === 'object') {
|
|
53
|
+
var _ref, _explicit$id, _ref2, _explicit$name, _explicit$phone, _explicit$email, _explicit$country_cal;
|
|
54
|
+
return _objectSpread({
|
|
55
|
+
id: (_ref = (_explicit$id = explicit.id) !== null && _explicit$id !== void 0 ? _explicit$id : raw.customer_id) !== null && _ref !== void 0 ? _ref : null,
|
|
56
|
+
name: (_ref2 = (_explicit$name = explicit.name) !== null && _explicit$name !== void 0 ? _explicit$name : raw.customer_name) !== null && _ref2 !== void 0 ? _ref2 : '',
|
|
57
|
+
phone: (_explicit$phone = explicit.phone) !== null && _explicit$phone !== void 0 ? _explicit$phone : raw.phone,
|
|
58
|
+
email: (_explicit$email = explicit.email) !== null && _explicit$email !== void 0 ? _explicit$email : raw.email,
|
|
59
|
+
country_calling_code: (_explicit$country_cal = explicit.country_calling_code) !== null && _explicit$country_cal !== void 0 ? _explicit$country_cal : raw.country_calling_code
|
|
60
|
+
}, explicit);
|
|
61
|
+
}
|
|
62
|
+
if (raw.customer_id == null && !raw.customer_name) return null;
|
|
63
|
+
return {
|
|
64
|
+
id: (_raw$customer_id = raw.customer_id) !== null && _raw$customer_id !== void 0 ? _raw$customer_id : null,
|
|
65
|
+
name: (_raw$customer_name = raw.customer_name) !== null && _raw$customer_name !== void 0 ? _raw$customer_name : '',
|
|
66
|
+
phone: raw.phone,
|
|
67
|
+
email: raw.email,
|
|
68
|
+
country_calling_code: raw.country_calling_code
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 判定根 booking。沿用 ticketBooking 现有约定:
|
|
74
|
+
* `parent_id === 0` 视为根;其余为子(item_type === 'recurring_booking' 也按 parent_id 判定)。
|
|
75
|
+
* 见 `packages/private-materials/src/components/ticketBooking/index.tsx`:
|
|
76
|
+
* `type: booking.parent_id === 0 ? 'list' : 'detail'`。
|
|
77
|
+
*/
|
|
78
|
+
function isRootBooking(booking) {
|
|
79
|
+
if (!booking || _typeof(booking) !== 'object') return false;
|
|
80
|
+
var parentId = booking.parent_id;
|
|
81
|
+
if (parentId === 0 || parentId === null || parentId === undefined) return true;
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
function indexBookingsByProductUid(bookings) {
|
|
85
|
+
var result = {};
|
|
86
|
+
var _iterator2 = _createForOfIteratorHelper(bookings),
|
|
87
|
+
_step2;
|
|
88
|
+
try {
|
|
89
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
90
|
+
var _b$metadata;
|
|
91
|
+
var b = _step2.value;
|
|
92
|
+
var uid = b && (b.product_uid || ((_b$metadata = b.metadata) === null || _b$metadata === void 0 ? void 0 : _b$metadata.product_uid)) || '';
|
|
93
|
+
if (!uid) continue;
|
|
94
|
+
var _key2 = String(uid);
|
|
95
|
+
if (!result[_key2]) result[_key2] = [];
|
|
96
|
+
result[_key2].push(b);
|
|
97
|
+
}
|
|
98
|
+
} catch (err) {
|
|
99
|
+
_iterator2.e(err);
|
|
100
|
+
} finally {
|
|
101
|
+
_iterator2.f();
|
|
102
|
+
}
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* 将 `/order/sales/{id}` 响应解析为 ISalesDetail。
|
|
108
|
+
*
|
|
109
|
+
* 注意:
|
|
110
|
+
* - 入参允许是 `{ data: OrderData }` 或直接 `OrderData`,自动识别。
|
|
111
|
+
* - products 保留原字段;字段补齐由 OrderModule hydrate 负责。
|
|
112
|
+
* - 不做远程请求;不修改入参;返回新对象。
|
|
113
|
+
*/
|
|
114
|
+
export function parseSalesResponse(input) {
|
|
115
|
+
var raw = input && _typeof(input) === 'object' && input.data && input.order_id == null ? input.data : input || {};
|
|
116
|
+
var productsRaw = Array.isArray(raw === null || raw === void 0 ? void 0 : raw.products) ? raw.products : [];
|
|
117
|
+
var products = productsRaw.map(function (p, index) {
|
|
118
|
+
var row = _objectSpread({}, p || {});
|
|
119
|
+
var metadata = row.metadata && _typeof(row.metadata) === 'object' ? _objectSpread({}, row.metadata) : {};
|
|
120
|
+
if (!metadata.unique_identification_number) {
|
|
121
|
+
var _row$product_id, _row$product_variant_;
|
|
122
|
+
metadata.unique_identification_number = "sales-product-".concat((_row$product_id = row.product_id) !== null && _row$product_id !== void 0 ? _row$product_id : 'unknown', "-").concat((_row$product_variant_ = row.product_variant_id) !== null && _row$product_variant_ !== void 0 ? _row$product_variant_ : 0, "-").concat(index);
|
|
123
|
+
}
|
|
124
|
+
delete metadata.price_schema_version;
|
|
125
|
+
delete row.identity_key;
|
|
126
|
+
return _objectSpread(_objectSpread({}, row), {}, {
|
|
127
|
+
metadata: metadata
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
var bookingsRaw = Array.isArray(raw === null || raw === void 0 ? void 0 : raw.bookings) ? raw.bookings : [];
|
|
131
|
+
var bookings = bookingsRaw.map(function (b) {
|
|
132
|
+
return _objectSpread({}, b || {});
|
|
133
|
+
});
|
|
134
|
+
var rootBooking = bookings.find(isRootBooking) || null;
|
|
135
|
+
var bookingsByProductUid = indexBookingsByProductUid(bookings);
|
|
136
|
+
var payments = Array.isArray(raw === null || raw === void 0 ? void 0 : raw.payments) ? raw.payments.map(function (p) {
|
|
137
|
+
return _objectSpread({}, p || {});
|
|
138
|
+
}) : [];
|
|
139
|
+
var surcharges = Array.isArray(raw === null || raw === void 0 ? void 0 : raw.surcharges) ? raw.surcharges.map(function (s) {
|
|
140
|
+
return _objectSpread({}, s || {});
|
|
141
|
+
}) : [];
|
|
142
|
+
var discount_list = Array.isArray(raw === null || raw === void 0 ? void 0 : raw.discount_list) ? raw.discount_list.map(function (d) {
|
|
143
|
+
return _objectSpread({}, d || {});
|
|
144
|
+
}) : [];
|
|
145
|
+
var summary = raw !== null && raw !== void 0 && raw.summary && _typeof(raw.summary) === 'object' ? _objectSpread({}, raw.summary) : {};
|
|
146
|
+
return {
|
|
147
|
+
header: pickHeader(raw),
|
|
148
|
+
products: products,
|
|
149
|
+
bookings: bookings,
|
|
150
|
+
rootBooking: rootBooking,
|
|
151
|
+
bookingsByProductUid: bookingsByProductUid,
|
|
152
|
+
payments: payments,
|
|
153
|
+
surcharges: surcharges,
|
|
154
|
+
discount_list: discount_list,
|
|
155
|
+
customer: pickCustomer(raw),
|
|
156
|
+
summary: summary,
|
|
157
|
+
raw: raw
|
|
158
|
+
};
|
|
159
|
+
}
|