@pisell/pisellos 2.2.153 → 2.2.154
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/core/index.js +1 -0
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/Cart/utils/cartProduct.js +1 -1
- package/dist/modules/Order/index.d.ts +2 -0
- package/dist/modules/Order/index.js +231 -160
- package/dist/modules/Order/types.d.ts +19 -0
- package/dist/modules/Order/utils.js +7 -6
- package/dist/modules/Payment/index.d.ts +4 -0
- package/dist/modules/Payment/index.js +567 -505
- package/dist/modules/Payment/types.d.ts +29 -9
- package/dist/modules/SalesSummary/index.d.ts +7 -5
- package/dist/modules/SalesSummary/index.js +35 -11
- package/dist/plugins/app.d.ts +2 -0
- package/dist/server/index.d.ts +2 -5
- package/dist/server/index.js +58 -66
- package/dist/server/modules/index.d.ts +1 -1
- package/dist/server/modules/products/index.d.ts +12 -1
- package/dist/server/modules/products/index.js +169 -78
- package/dist/server/modules/products/types.d.ts +11 -0
- package/dist/server/modules/products/types.js +4 -0
- package/dist/server/utils/product.js +2 -2
- package/dist/solution/BaseSales/index.d.ts +26 -2
- package/dist/solution/BaseSales/index.js +342 -112
- package/dist/solution/BaseSales/types.d.ts +4 -4
- package/dist/solution/BaseSales/types.js +4 -4
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +62 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +116 -0
- package/dist/solution/BaseSales/utils.js +3 -3
- package/dist/solution/BookingTicket/index.d.ts +11 -13
- package/dist/solution/BookingTicket/index.js +23 -37
- package/dist/solution/BookingTicket/types.d.ts +9 -6
- package/dist/solution/BookingTicket/types.js +6 -3
- package/dist/solution/BookingTicket/utils/cartView.d.ts +7 -12
- package/dist/solution/BookingTicket/utils/cartView.js +52 -14
- package/dist/solution/BookingTicket/utils/orderCustomer.d.ts +4 -0
- package/dist/solution/BookingTicket/utils/orderCustomer.js +31 -0
- package/dist/solution/Sales/index.d.ts +3 -0
- package/dist/solution/Sales/index.js +85 -43
- package/dist/solution/Sales/types.d.ts +3 -0
- package/dist/solution/ScanOrder/types.d.ts +4 -4
- package/dist/solution/ScanOrder/types.js +4 -4
- package/dist/solution/ScanOrder/utils.js +3 -3
- package/lib/core/index.js +1 -0
- package/lib/modules/Cart/utils/cartProduct.js +1 -1
- package/lib/modules/Order/index.d.ts +2 -0
- package/lib/modules/Order/index.js +39 -7
- package/lib/modules/Order/types.d.ts +19 -0
- package/lib/modules/Order/utils.js +4 -2
- package/lib/modules/Payment/index.d.ts +4 -0
- package/lib/modules/Payment/index.js +26 -2
- package/lib/modules/Payment/types.d.ts +29 -9
- package/lib/modules/SalesSummary/index.d.ts +7 -5
- package/lib/modules/SalesSummary/index.js +29 -9
- package/lib/plugins/app.d.ts +2 -0
- package/lib/server/index.d.ts +2 -5
- package/lib/server/index.js +38 -58
- package/lib/server/modules/index.d.ts +1 -1
- package/lib/server/modules/products/index.d.ts +12 -1
- package/lib/server/modules/products/index.js +69 -9
- package/lib/server/modules/products/types.d.ts +11 -0
- package/lib/server/utils/product.js +2 -2
- package/lib/solution/BaseSales/index.d.ts +26 -2
- package/lib/solution/BaseSales/index.js +169 -3
- package/lib/solution/BaseSales/types.d.ts +4 -4
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +62 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +155 -0
- package/lib/solution/BaseSales/utils.js +3 -3
- package/lib/solution/BookingTicket/index.d.ts +11 -13
- package/lib/solution/BookingTicket/index.js +17 -27
- package/lib/solution/BookingTicket/types.d.ts +9 -6
- package/lib/solution/BookingTicket/utils/cartView.d.ts +7 -12
- package/lib/solution/BookingTicket/utils/cartView.js +44 -18
- package/lib/solution/BookingTicket/utils/orderCustomer.d.ts +4 -0
- package/lib/solution/BookingTicket/utils/orderCustomer.js +58 -0
- package/lib/solution/Sales/index.d.ts +3 -0
- package/lib/solution/Sales/index.js +50 -15
- package/lib/solution/Sales/types.d.ts +3 -0
- package/lib/solution/ScanOrder/types.d.ts +4 -4
- package/lib/solution/ScanOrder/utils.js +3 -3
- package/package.json +1 -1
|
@@ -8,12 +8,15 @@ import type { Discount } from '../../modules/Discount/types';
|
|
|
8
8
|
import { RequestPlugin, WindowPlugin } from '../../plugins';
|
|
9
9
|
export * from './types';
|
|
10
10
|
import { ProductList } from '../../modules/ProductList';
|
|
11
|
+
import { PaymentModule } from '../../modules/Payment';
|
|
11
12
|
import type { SalesSummaryModule } from '../../modules/SalesSummary';
|
|
12
13
|
import type { ScheduleModule } from '../../modules/Schedule';
|
|
13
14
|
import type { ISalesDetail, ISalesDetailHeader, ISalesBooking, ISalesPayment, ISalesSurcharge } from './utils/parseSalesResponse';
|
|
15
|
+
import { type TransformBaseProductToOrderProductParams } from './utils/transformBaseProductToOrderProduct';
|
|
14
16
|
export interface BaseSalesState {
|
|
15
17
|
order?: OrderModule;
|
|
16
18
|
products?: ProductList;
|
|
19
|
+
payment?: PaymentModule;
|
|
17
20
|
salesSummary?: SalesSummaryModule;
|
|
18
21
|
schedule?: ScheduleModule;
|
|
19
22
|
}
|
|
@@ -22,6 +25,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
22
25
|
protected defaultVersion: string;
|
|
23
26
|
isSolution: boolean;
|
|
24
27
|
protected initializeOptions: ModuleOptions;
|
|
28
|
+
private logger;
|
|
25
29
|
protected store: BaseSalesState;
|
|
26
30
|
protected otherParams: Record<string, any>;
|
|
27
31
|
protected cacheId: string | undefined;
|
|
@@ -35,15 +39,29 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
35
39
|
constructor(name?: string, version?: string);
|
|
36
40
|
/**
|
|
37
41
|
* 子类可覆盖此方法以追加/收敛要注册的子模块。
|
|
38
|
-
* 默认包含通用销售模块:products / order / salesSummary / schedule。
|
|
42
|
+
* 默认包含通用销售模块:products / order / salesSummary / schedule / payment。
|
|
39
43
|
*/
|
|
40
44
|
protected getRegisteredModuleNames(): readonly string[];
|
|
45
|
+
/**
|
|
46
|
+
* 记录信息日志
|
|
47
|
+
*/
|
|
48
|
+
private logInfo;
|
|
49
|
+
/**
|
|
50
|
+
* 记录警告日志
|
|
51
|
+
*/
|
|
52
|
+
private logWarning;
|
|
53
|
+
/**
|
|
54
|
+
* 记录错误日志
|
|
55
|
+
*/
|
|
56
|
+
private logError;
|
|
57
|
+
get payment(): PaymentModule | undefined;
|
|
41
58
|
/**
|
|
42
59
|
* 工厂入口:根据子模块名实例化对应模块。
|
|
43
60
|
* 默认使用 BookingByStep 公共 `createModule`。子类若需引入额外类型(如 customer),
|
|
44
61
|
* 可覆盖此方法并把未识别的 name 委托给 `super.createSubModule(name)`。
|
|
45
62
|
*/
|
|
46
63
|
protected createSubModule(moduleName: string): Module | null;
|
|
64
|
+
protected getSubModuleHooks(moduleName: string): any;
|
|
47
65
|
/**
|
|
48
66
|
* 读取 sessionStorage[this.name][cacheId],作为子模块 initialState 的来源。
|
|
49
67
|
* sessionStorage 损坏时静默忽略,按空状态注册。
|
|
@@ -80,7 +98,8 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
80
98
|
getOrderAmountSnapshot(): import("../../modules/Order/types").OrderAmountSnapshot | null;
|
|
81
99
|
getTempOrderNote(): string;
|
|
82
100
|
updateTempOrderNote(note: string): string;
|
|
83
|
-
|
|
101
|
+
updateTempOrderShopDiscount(amount: string | number): string;
|
|
102
|
+
updateTempOrderContactsInfo(contactsInfo: Record<string, any> | null): Record<string, any> | null;
|
|
84
103
|
private ensureTempOrder;
|
|
85
104
|
addNewOrder(): Promise<import("../../modules/Order/types").OrderTempOrder>;
|
|
86
105
|
saveDraft(): Promise<void>;
|
|
@@ -124,6 +143,10 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
124
143
|
deleteOrderPayment(paymentIdentity: string | number): OrderPaymentData[];
|
|
125
144
|
/** 覆盖 wallet pass 支付项,同时保留普通支付项。 */
|
|
126
145
|
updateVoucherOrderPayments(payments: OrderPaymentSource[]): OrderPaymentData[];
|
|
146
|
+
private getWalletProductList;
|
|
147
|
+
initWalletData(params?: {
|
|
148
|
+
order_wait_pay_amount?: number;
|
|
149
|
+
}): Promise<import("../../modules/Payment").WalletInitializationResult>;
|
|
127
150
|
/**
|
|
128
151
|
* 更新当前订单客户字段。
|
|
129
152
|
*
|
|
@@ -159,6 +182,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
159
182
|
order_ids?: Array<number | string>;
|
|
160
183
|
submitBeforeSend?: boolean;
|
|
161
184
|
}): Promise<T>;
|
|
185
|
+
transformBaseProductToOrderProduct(params: TransformBaseProductToOrderProductParams): import("./utils/transformBaseProductToOrderProduct").BaseProductOrderProductInput | null;
|
|
162
186
|
addProductToOrder(product: Partial<BaseSalesOrderProduct> & BaseSalesOrderProductIdentity, booking?: AddProductBookingInput): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
163
187
|
updateProductInOrder(params: UpdateProductInOrderParams): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
164
188
|
/**
|
|
@@ -40,6 +40,7 @@ var import_types = require("../BookingByStep/types");
|
|
|
40
40
|
var import_utils = require("../../modules/Order/utils");
|
|
41
41
|
var import_dayjs = __toESM(require("dayjs"));
|
|
42
42
|
__reExport(BaseSales_exports, require("./types"), module.exports);
|
|
43
|
+
var import_transformBaseProductToOrderProduct = require("./utils/transformBaseProductToOrderProduct");
|
|
43
44
|
var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
44
45
|
constructor(name, version) {
|
|
45
46
|
super(name, version);
|
|
@@ -47,6 +48,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
47
48
|
this.defaultVersion = "1.0.0";
|
|
48
49
|
this.isSolution = true;
|
|
49
50
|
this.initializeOptions = {};
|
|
51
|
+
// LoggerManager 实例
|
|
50
52
|
this.store = {
|
|
51
53
|
order: void 0
|
|
52
54
|
};
|
|
@@ -56,10 +58,52 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
56
58
|
}
|
|
57
59
|
/**
|
|
58
60
|
* 子类可覆盖此方法以追加/收敛要注册的子模块。
|
|
59
|
-
* 默认包含通用销售模块:products / order / salesSummary / schedule。
|
|
61
|
+
* 默认包含通用销售模块:products / order / salesSummary / schedule / payment。
|
|
60
62
|
*/
|
|
61
63
|
getRegisteredModuleNames() {
|
|
62
|
-
return ["products", "order", "salesSummary", "schedule"];
|
|
64
|
+
return ["products", "order", "salesSummary", "schedule", "payment"];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* 记录信息日志
|
|
68
|
+
*/
|
|
69
|
+
logInfo(title, metadata) {
|
|
70
|
+
if (this.logger) {
|
|
71
|
+
const tempOrder = this.getTempOrder();
|
|
72
|
+
this.logger.addLog({
|
|
73
|
+
type: "info",
|
|
74
|
+
title: `[BaseSales] ${tempOrder == null ? void 0 : tempOrder.order_id} ${tempOrder == null ? void 0 : tempOrder.external_sale_number} ${title}`,
|
|
75
|
+
metadata: metadata || {}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* 记录警告日志
|
|
81
|
+
*/
|
|
82
|
+
logWarning(title, metadata) {
|
|
83
|
+
if (this.logger) {
|
|
84
|
+
const tempOrder = this.getTempOrder();
|
|
85
|
+
this.logger.addLog({
|
|
86
|
+
type: "warning",
|
|
87
|
+
title: `[BaseSales] ${tempOrder == null ? void 0 : tempOrder.order_id} ${tempOrder == null ? void 0 : tempOrder.external_sale_number} ${title}`,
|
|
88
|
+
metadata: metadata || {}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* 记录错误日志
|
|
94
|
+
*/
|
|
95
|
+
logError(title, metadata) {
|
|
96
|
+
if (this.logger) {
|
|
97
|
+
const tempOrder = this.getTempOrder();
|
|
98
|
+
this.logger.addLog({
|
|
99
|
+
type: "error",
|
|
100
|
+
title: `[BaseSales] ${tempOrder == null ? void 0 : tempOrder.order_id} ${tempOrder == null ? void 0 : tempOrder.external_sale_number} ${title}`,
|
|
101
|
+
metadata: metadata || {}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
get payment() {
|
|
106
|
+
return this.store.payment;
|
|
63
107
|
}
|
|
64
108
|
/**
|
|
65
109
|
* 工厂入口:根据子模块名实例化对应模块。
|
|
@@ -69,6 +113,16 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
69
113
|
createSubModule(moduleName) {
|
|
70
114
|
return (0, import_types.createModule)(moduleName, this.name);
|
|
71
115
|
}
|
|
116
|
+
getSubModuleHooks(moduleName) {
|
|
117
|
+
var _a, _b;
|
|
118
|
+
const optionHooks = this.initializeOptions.hooks || {};
|
|
119
|
+
const otherHooks = this.otherParams.hooks || {};
|
|
120
|
+
if (moduleName === "order") {
|
|
121
|
+
const directOrderHooks = optionHooks;
|
|
122
|
+
return optionHooks.order || ((_a = this.otherParams.order) == null ? void 0 : _a.hooks) || otherHooks.order || (directOrderHooks.onBeforeMergeProductToOrder ? directOrderHooks : void 0);
|
|
123
|
+
}
|
|
124
|
+
return optionHooks[moduleName] || ((_b = this.otherParams[moduleName]) == null ? void 0 : _b.hooks) || otherHooks[moduleName];
|
|
125
|
+
}
|
|
72
126
|
/**
|
|
73
127
|
* 读取 sessionStorage[this.name][cacheId],作为子模块 initialState 的来源。
|
|
74
128
|
* sessionStorage 损坏时静默忽略,按空状态注册。
|
|
@@ -94,6 +148,12 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
94
148
|
this.cacheId = (_a = this.otherParams) == null ? void 0 : _a.cacheId;
|
|
95
149
|
this.window = core.getPlugin("window");
|
|
96
150
|
this.request = core.getPlugin("request");
|
|
151
|
+
const appPlugin = core.getPlugin("app");
|
|
152
|
+
if (!appPlugin) {
|
|
153
|
+
throw new Error("Checkout 解决方案需要 app 插件支持");
|
|
154
|
+
}
|
|
155
|
+
const app = appPlugin.getApp();
|
|
156
|
+
this.logger = app.logger;
|
|
97
157
|
const targetCacheData = this.readSessionCacheData();
|
|
98
158
|
const moduleNames = this.getRegisteredModuleNames();
|
|
99
159
|
moduleNames.forEach((step) => {
|
|
@@ -101,9 +161,11 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
101
161
|
if (!targetModule) {
|
|
102
162
|
throw new Error(`模块 ${step} 不存在`);
|
|
103
163
|
}
|
|
164
|
+
const hooks = this.getSubModuleHooks(step);
|
|
104
165
|
this.store[step] = targetModule;
|
|
105
166
|
this.core.registerModule(targetModule, {
|
|
106
167
|
initialState: (targetCacheData == null ? void 0 : targetCacheData[targetModule.name]) || {},
|
|
168
|
+
...hooks ? { hooks } : {},
|
|
107
169
|
otherParams: {
|
|
108
170
|
...this.otherParams,
|
|
109
171
|
salesSummaryModuleName: `${this.name}_salesSummary`,
|
|
@@ -259,11 +321,16 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
259
321
|
throw error;
|
|
260
322
|
}
|
|
261
323
|
}
|
|
262
|
-
|
|
324
|
+
updateTempOrderShopDiscount(amount) {
|
|
263
325
|
if (!this.store.order)
|
|
264
326
|
throw new Error("order 模块未初始化");
|
|
265
327
|
return this.store.order.updateTempOrderShopDiscount(amount);
|
|
266
328
|
}
|
|
329
|
+
updateTempOrderContactsInfo(contactsInfo) {
|
|
330
|
+
if (!this.store.order)
|
|
331
|
+
throw new Error("order 模块未初始化");
|
|
332
|
+
return this.store.order.updateTempOrderContactsInfo(contactsInfo);
|
|
333
|
+
}
|
|
267
334
|
ensureTempOrder() {
|
|
268
335
|
if (!this.store.order)
|
|
269
336
|
throw new Error("order 模块未初始化");
|
|
@@ -496,6 +563,99 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
496
563
|
throw new Error("order 模块未初始化");
|
|
497
564
|
return this.store.order.updateVoucherOrderPayments(payments);
|
|
498
565
|
}
|
|
566
|
+
getWalletProductList() {
|
|
567
|
+
var _a, _b;
|
|
568
|
+
const tempOrder = (_a = this.store.order) == null ? void 0 : _a.getTempOrder();
|
|
569
|
+
if (!((_b = tempOrder == null ? void 0 : tempOrder.products) == null ? void 0 : _b.length))
|
|
570
|
+
return [];
|
|
571
|
+
return tempOrder.products.map((product) => {
|
|
572
|
+
const metadata = product.metadata || {};
|
|
573
|
+
return {
|
|
574
|
+
product_id: product.product_id,
|
|
575
|
+
product_variant_id: String(product.product_variant_id ?? ""),
|
|
576
|
+
quantity: product.num || 1,
|
|
577
|
+
is_price_include_tax: tempOrder.is_price_include_tax,
|
|
578
|
+
is_charge_tax: product.is_charge_tax ?? 0,
|
|
579
|
+
tax_fee: product.tax_fee,
|
|
580
|
+
selling_price: Number(product.selling_price || 0),
|
|
581
|
+
holder_id: product.holder_id ?? metadata.holder_id,
|
|
582
|
+
original_price: product.original_price,
|
|
583
|
+
main_product_original_price: metadata.main_product_original_price ?? product.original_price,
|
|
584
|
+
main_product_selling_price: metadata.main_product_selling_price ?? product.selling_price,
|
|
585
|
+
metadata: {
|
|
586
|
+
main_product_attached_bundle_tax_fee: metadata.main_product_attached_bundle_tax_fee,
|
|
587
|
+
main_product_attached_bundle_surcharge_fee: metadata.main_product_attached_bundle_surcharge_fee,
|
|
588
|
+
surcharge_rounding_remainder: metadata.surcharge_rounding_remainder
|
|
589
|
+
},
|
|
590
|
+
product_bundle: (product.product_bundle || []).map((bundle) => {
|
|
591
|
+
const bundleMetadata = bundle.metadata || {};
|
|
592
|
+
return {
|
|
593
|
+
is_price_include_tax: tempOrder.is_price_include_tax,
|
|
594
|
+
bundle_id: bundle.bundle_id,
|
|
595
|
+
bundle_product_id: bundle.bundle_product_id,
|
|
596
|
+
bundle_variant_id: bundle.bundle_variant_id,
|
|
597
|
+
price_type: bundle.price_type,
|
|
598
|
+
price_type_ext: bundle.price_type_ext,
|
|
599
|
+
bundle_sum_price: bundle.bundle_sum_price,
|
|
600
|
+
bundle_selling_price: bundle.bundle_selling_price,
|
|
601
|
+
num: bundle.num,
|
|
602
|
+
is_charge_tax: bundle.is_charge_tax,
|
|
603
|
+
tax_fee: bundle.tax_fee,
|
|
604
|
+
metadata: {
|
|
605
|
+
surcharge_fee: bundleMetadata.surcharge_fee,
|
|
606
|
+
surcharge_rounding_remainder: bundleMetadata.surcharge_rounding_remainder
|
|
607
|
+
}
|
|
608
|
+
};
|
|
609
|
+
})
|
|
610
|
+
};
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
async initWalletData(params) {
|
|
614
|
+
if (!this.store.order)
|
|
615
|
+
throw new Error("order 模块未初始化");
|
|
616
|
+
if (!this.store.payment)
|
|
617
|
+
throw new Error("payment 模块未初始化");
|
|
618
|
+
const snapshot = this.store.order.getOrderSnapshot();
|
|
619
|
+
const tempOrder = snapshot == null ? void 0 : snapshot.tempOrder;
|
|
620
|
+
const amount = snapshot == null ? void 0 : snapshot.amount;
|
|
621
|
+
if (!tempOrder || !amount) {
|
|
622
|
+
return {
|
|
623
|
+
walletRecommendList: [],
|
|
624
|
+
userIdentificationCodes: [],
|
|
625
|
+
transformList: [],
|
|
626
|
+
noApplicableVoucher: [],
|
|
627
|
+
products: []
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
const walletBusinessData = {
|
|
631
|
+
customer_id: tempOrder.customer_id ? Number(tempOrder.customer_id) : void 0,
|
|
632
|
+
holder: tempOrder.holder,
|
|
633
|
+
amountInfo: {
|
|
634
|
+
totalAmount: amount.totalAmount,
|
|
635
|
+
subTotal: amount.summary.product_amount || amount.summary.product_expect_amount || amount.totalAmount,
|
|
636
|
+
depositAmount: amount.depositAmount,
|
|
637
|
+
isDeposit: tempOrder.is_deposit
|
|
638
|
+
},
|
|
639
|
+
products: this.getWalletProductList(),
|
|
640
|
+
order_wait_pay_amount: (params == null ? void 0 : params.order_wait_pay_amount) ?? Number(amount.amountGap || 0),
|
|
641
|
+
is_price_include_tax: tempOrder.is_price_include_tax ?? this.otherParams.is_price_include_tax ?? 1,
|
|
642
|
+
...snapshot.identity.orderId ? { payment_order_id: String(snapshot.identity.orderId) } : {}
|
|
643
|
+
};
|
|
644
|
+
const result = await this.store.payment.wallet.initializeWalletDataFromBusinessAsync(
|
|
645
|
+
walletBusinessData
|
|
646
|
+
);
|
|
647
|
+
await this.core.effects.emit(`${this.name}:onWalletDataInitialized`, {
|
|
648
|
+
orderId: snapshot.identity.orderId,
|
|
649
|
+
customerId: walletBusinessData.customer_id,
|
|
650
|
+
walletBusinessData: {
|
|
651
|
+
customer_id: walletBusinessData.customer_id,
|
|
652
|
+
amountInfo: walletBusinessData.amountInfo,
|
|
653
|
+
order_wait_pay_amount: walletBusinessData.order_wait_pay_amount
|
|
654
|
+
},
|
|
655
|
+
timestamp: Date.now()
|
|
656
|
+
});
|
|
657
|
+
return result;
|
|
658
|
+
}
|
|
499
659
|
/**
|
|
500
660
|
* 更新当前订单客户字段。
|
|
501
661
|
*
|
|
@@ -512,6 +672,9 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
512
672
|
}
|
|
513
673
|
/** 获取可用支付方式列表,供 PaymentModal 渲染支付选项。 */
|
|
514
674
|
async getPaymentMethodsAsync() {
|
|
675
|
+
if (this.store.payment) {
|
|
676
|
+
return this.store.payment.getPayMethodListAsync();
|
|
677
|
+
}
|
|
515
678
|
const response = await this.request.get("/pay/custom-payment/all");
|
|
516
679
|
return (response == null ? void 0 : response.data) || [];
|
|
517
680
|
}
|
|
@@ -565,6 +728,9 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
565
728
|
order_ids: orderIds
|
|
566
729
|
});
|
|
567
730
|
}
|
|
731
|
+
transformBaseProductToOrderProduct(params) {
|
|
732
|
+
return (0, import_transformBaseProductToOrderProduct.transformBaseProductToOrderProduct)(params);
|
|
733
|
+
}
|
|
568
734
|
async addProductToOrder(product, booking) {
|
|
569
735
|
try {
|
|
570
736
|
if (!this.store.order)
|
|
@@ -91,13 +91,13 @@ export interface BaseSalesOrderProduct extends BaseSalesOrderProductIdentity {
|
|
|
91
91
|
* 出站 payload 版本的商品行。
|
|
92
92
|
*
|
|
93
93
|
* 与 tempOrder 内部 `BaseSalesOrderProduct` 的字段差异:
|
|
94
|
-
* - `product_option_item[*]`:内部为 `{
|
|
95
|
-
*
|
|
94
|
+
* - `product_option_item[*]`:内部为 `{ option_group_item_id, option_group_id, num, price, ... }`,
|
|
95
|
+
* 出站保留 `{ option_group_item_id, option_group_id, num }`
|
|
96
96
|
* (后端 checkout 协议;丢弃 `price` 等运行时辅助字段)。
|
|
97
97
|
* - `product_bundle[*].option[*]`:同上重命名规则。
|
|
98
98
|
*
|
|
99
|
-
* 运行时(UI
|
|
100
|
-
*
|
|
99
|
+
* 运行时(UI 显示、加购合并、指纹、持久化)与提交边界统一消费字段名
|
|
100
|
+
* `option_group_item_id`,保持 tempOrder 与后端协议一致。
|
|
101
101
|
*/
|
|
102
102
|
export interface BaseSalesSubmitProduct extends Omit<BaseSalesOrderProduct, '_origin' | 'identity_key'> {
|
|
103
103
|
/**
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { OrderProduct, OrderProductIdentity } from '../../../modules/Order/types';
|
|
2
|
+
import type { ProductData } from '../../../modules/Product/types';
|
|
3
|
+
export interface BaseProductDetailOptionItem {
|
|
4
|
+
option_group_item_id?: number | string;
|
|
5
|
+
option_group_id?: number | string;
|
|
6
|
+
num?: number | string;
|
|
7
|
+
quantity?: number | string;
|
|
8
|
+
price?: number | string;
|
|
9
|
+
add_price?: number | string;
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
}
|
|
12
|
+
export interface BaseProductDetailBundleItem {
|
|
13
|
+
option?: BaseProductDetailOptionItem[];
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}
|
|
16
|
+
export interface BaseProductDetailPayload {
|
|
17
|
+
id?: number | string | null;
|
|
18
|
+
product_id?: number | string | null;
|
|
19
|
+
variant_id?: number | string | null;
|
|
20
|
+
product_variant_id?: number | string | null;
|
|
21
|
+
quantity?: number | string;
|
|
22
|
+
num?: number | string;
|
|
23
|
+
option?: BaseProductDetailOptionItem[];
|
|
24
|
+
options?: BaseProductDetailOptionItem[];
|
|
25
|
+
product_option_item?: BaseProductDetailOptionItem[];
|
|
26
|
+
bundle?: BaseProductDetailBundleItem[];
|
|
27
|
+
product_bundle?: BaseProductDetailBundleItem[];
|
|
28
|
+
unique?: string;
|
|
29
|
+
unique_identification_number?: string;
|
|
30
|
+
session?: any;
|
|
31
|
+
form?: any;
|
|
32
|
+
service_times?: any;
|
|
33
|
+
machine_code?: string;
|
|
34
|
+
schedule_id?: number[];
|
|
35
|
+
duration?: number;
|
|
36
|
+
policy_id?: number;
|
|
37
|
+
source_shop_id?: number;
|
|
38
|
+
origin?: Record<string, any>;
|
|
39
|
+
_origin?: Record<string, any>;
|
|
40
|
+
price?: number | string;
|
|
41
|
+
selling_price?: number | string;
|
|
42
|
+
original_price?: number | string;
|
|
43
|
+
tax_fee?: number | string;
|
|
44
|
+
is_charge_tax?: number;
|
|
45
|
+
note?: string;
|
|
46
|
+
[key: string]: any;
|
|
47
|
+
}
|
|
48
|
+
export interface TransformBaseProductToOrderProductParams {
|
|
49
|
+
payload: BaseProductDetailPayload;
|
|
50
|
+
fallbackProductId?: number | string | null;
|
|
51
|
+
sourceProduct?: ProductData | Record<string, any> | null;
|
|
52
|
+
sourceItem?: ProductData | Record<string, any> | null;
|
|
53
|
+
}
|
|
54
|
+
export type BaseProductOrderProductInput = Partial<OrderProduct> & OrderProductIdentity & {
|
|
55
|
+
_origin?: Record<string, any>;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* 将商品列表原始数据 + 商品详情选择回调转换成 OrderModule.addProductToOrder 入参。
|
|
59
|
+
*
|
|
60
|
+
* 注意:这里不生成 identity,缺省时由 OrderModule 自动补齐。
|
|
61
|
+
*/
|
|
62
|
+
export declare function transformBaseProductToOrderProduct(params: TransformBaseProductToOrderProductParams): BaseProductOrderProductInput | null;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/solution/BaseSales/utils/transformBaseProductToOrderProduct.ts
|
|
20
|
+
var transformBaseProductToOrderProduct_exports = {};
|
|
21
|
+
__export(transformBaseProductToOrderProduct_exports, {
|
|
22
|
+
transformBaseProductToOrderProduct: () => transformBaseProductToOrderProduct
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(transformBaseProductToOrderProduct_exports);
|
|
25
|
+
function toNumber(value, fallback = 0) {
|
|
26
|
+
const parsedValue = Number(value);
|
|
27
|
+
if (!Number.isFinite(parsedValue))
|
|
28
|
+
return fallback;
|
|
29
|
+
return parsedValue;
|
|
30
|
+
}
|
|
31
|
+
function toProductId(value) {
|
|
32
|
+
if (value === null || value === void 0 || value === "")
|
|
33
|
+
return null;
|
|
34
|
+
const parsedValue = Number(value);
|
|
35
|
+
if (!Number.isFinite(parsedValue))
|
|
36
|
+
return null;
|
|
37
|
+
return parsedValue;
|
|
38
|
+
}
|
|
39
|
+
function toSafePositiveInt(value, fallback = 1) {
|
|
40
|
+
const parsedValue = Math.floor(Number(value));
|
|
41
|
+
if (!Number.isFinite(parsedValue) || parsedValue < 1)
|
|
42
|
+
return fallback;
|
|
43
|
+
return parsedValue;
|
|
44
|
+
}
|
|
45
|
+
function toPriceString(value, fallback = "0.00") {
|
|
46
|
+
const parsedValue = Number(value);
|
|
47
|
+
if (!Number.isFinite(parsedValue))
|
|
48
|
+
return fallback;
|
|
49
|
+
return parsedValue.toFixed(2);
|
|
50
|
+
}
|
|
51
|
+
function normalizeOptionItems(optionItems) {
|
|
52
|
+
if (!Array.isArray(optionItems))
|
|
53
|
+
return [];
|
|
54
|
+
return optionItems.map((optionItem) => {
|
|
55
|
+
const optionGroupItemId = toNumber(optionItem == null ? void 0 : optionItem.option_group_item_id);
|
|
56
|
+
const price = (optionItem == null ? void 0 : optionItem.price) ?? (optionItem == null ? void 0 : optionItem.add_price) ?? 0;
|
|
57
|
+
return {
|
|
58
|
+
option_group_item_id: optionGroupItemId,
|
|
59
|
+
option_group_id: toNumber(optionItem == null ? void 0 : optionItem.option_group_id),
|
|
60
|
+
num: toSafePositiveInt((optionItem == null ? void 0 : optionItem.num) ?? (optionItem == null ? void 0 : optionItem.quantity), 1),
|
|
61
|
+
price: toNumber(price, 0)
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function normalizeBundleItems(bundleItems) {
|
|
66
|
+
if (!Array.isArray(bundleItems))
|
|
67
|
+
return [];
|
|
68
|
+
return bundleItems.map((bundleItem) => ({
|
|
69
|
+
...bundleItem,
|
|
70
|
+
option: normalizeOptionItems(bundleItem == null ? void 0 : bundleItem.option)
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
function findVariantById(origin, variantId) {
|
|
74
|
+
if (!origin || !variantId || variantId <= 0)
|
|
75
|
+
return null;
|
|
76
|
+
const variants = Array.isArray(origin == null ? void 0 : origin.variant) ? origin.variant : [];
|
|
77
|
+
return variants.find((variant) => Number(variant == null ? void 0 : variant.id) === variantId) || null;
|
|
78
|
+
}
|
|
79
|
+
function transformBaseProductToOrderProduct(params) {
|
|
80
|
+
var _a, _b;
|
|
81
|
+
const { payload, fallbackProductId = null } = params;
|
|
82
|
+
if (!payload || typeof payload !== "object")
|
|
83
|
+
return null;
|
|
84
|
+
const sourceProduct = params.sourceProduct || params.sourceItem || {};
|
|
85
|
+
const productId = toProductId(
|
|
86
|
+
payload.product_id ?? payload.id ?? (sourceProduct == null ? void 0 : sourceProduct.product_id) ?? (sourceProduct == null ? void 0 : sourceProduct.id) ?? fallbackProductId
|
|
87
|
+
);
|
|
88
|
+
if (productId === null)
|
|
89
|
+
return null;
|
|
90
|
+
const productVariantId = toNumber(
|
|
91
|
+
payload.product_variant_id ?? payload.variant_id ?? (sourceProduct == null ? void 0 : sourceProduct.product_variant_id) ?? (sourceProduct == null ? void 0 : sourceProduct.variant_id),
|
|
92
|
+
0
|
|
93
|
+
);
|
|
94
|
+
const callbackOrigin = payload.origin || ((_a = payload._origin) == null ? void 0 : _a.sourceProduct) || ((_b = payload._origin) == null ? void 0 : _b.sourceItem) || payload._origin || {};
|
|
95
|
+
const origin = {
|
|
96
|
+
...sourceProduct || {},
|
|
97
|
+
...callbackOrigin || {}
|
|
98
|
+
};
|
|
99
|
+
const matchedVariant = findVariantById(callbackOrigin, productVariantId) ?? findVariantById(sourceProduct, productVariantId) ?? findVariantById(origin, productVariantId);
|
|
100
|
+
const sourceProductPrice = toPriceString(
|
|
101
|
+
payload.price ?? payload.selling_price ?? (matchedVariant == null ? void 0 : matchedVariant.price) ?? (matchedVariant == null ? void 0 : matchedVariant.base_price) ?? (origin == null ? void 0 : origin.price) ?? (origin == null ? void 0 : origin.base_price) ?? (sourceProduct == null ? void 0 : sourceProduct.price) ?? (sourceProduct == null ? void 0 : sourceProduct.selling_price) ?? (sourceProduct == null ? void 0 : sourceProduct.base_price),
|
|
102
|
+
"0.00"
|
|
103
|
+
);
|
|
104
|
+
const productOptionItem = normalizeOptionItems(
|
|
105
|
+
payload.option ?? payload.options ?? payload.product_option_item
|
|
106
|
+
);
|
|
107
|
+
const productBundle = normalizeBundleItems(
|
|
108
|
+
payload.bundle ?? payload.product_bundle
|
|
109
|
+
);
|
|
110
|
+
const uniqueIdentificationNumber = payload.unique_identification_number ?? payload.unique;
|
|
111
|
+
const metadata = {
|
|
112
|
+
unique: payload.unique,
|
|
113
|
+
session: payload.session,
|
|
114
|
+
form: payload.form,
|
|
115
|
+
service_times: payload.service_times,
|
|
116
|
+
machine_code: payload.machine_code,
|
|
117
|
+
schedule_id: payload.schedule_id,
|
|
118
|
+
duration: payload.duration,
|
|
119
|
+
policy_id: payload.policy_id,
|
|
120
|
+
source_shop_id: payload.source_shop_id,
|
|
121
|
+
origin,
|
|
122
|
+
source_product_price: sourceProductPrice
|
|
123
|
+
};
|
|
124
|
+
if (uniqueIdentificationNumber) {
|
|
125
|
+
metadata.unique_identification_number = String(uniqueIdentificationNumber);
|
|
126
|
+
}
|
|
127
|
+
return {
|
|
128
|
+
product_id: productId,
|
|
129
|
+
product_variant_id: productVariantId,
|
|
130
|
+
unique_identification_number: uniqueIdentificationNumber ? String(uniqueIdentificationNumber) : void 0,
|
|
131
|
+
num: toSafePositiveInt(payload.quantity ?? payload.num, 1),
|
|
132
|
+
product_option_item: productOptionItem,
|
|
133
|
+
product_bundle: productBundle,
|
|
134
|
+
selling_price: sourceProductPrice,
|
|
135
|
+
original_price: sourceProductPrice,
|
|
136
|
+
tax_fee: toPriceString(
|
|
137
|
+
payload.tax_fee ?? (matchedVariant == null ? void 0 : matchedVariant.tax_fee) ?? (origin == null ? void 0 : origin.tax_fee) ?? (sourceProduct == null ? void 0 : sourceProduct.tax_fee),
|
|
138
|
+
"0.00"
|
|
139
|
+
),
|
|
140
|
+
is_charge_tax: toNumber(
|
|
141
|
+
payload.is_charge_tax ?? (matchedVariant == null ? void 0 : matchedVariant.is_charge_tax) ?? (origin == null ? void 0 : origin.is_charge_tax) ?? (sourceProduct == null ? void 0 : sourceProduct.is_charge_tax),
|
|
142
|
+
0
|
|
143
|
+
),
|
|
144
|
+
metadata,
|
|
145
|
+
note: payload.note != null ? String(payload.note) : "",
|
|
146
|
+
_origin: {
|
|
147
|
+
...sourceProduct || {},
|
|
148
|
+
callbackData: payload
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
153
|
+
0 && (module.exports = {
|
|
154
|
+
transformBaseProductToOrderProduct
|
|
155
|
+
});
|
|
@@ -61,13 +61,13 @@ function createEmptySummary() {
|
|
|
61
61
|
function buildProductLineFingerprint(productOptionItem, productBundle) {
|
|
62
62
|
const optArr = Array.isArray(productOptionItem) ? productOptionItem : [];
|
|
63
63
|
const normalizedOpts = optArr.map((item) => ({
|
|
64
|
-
|
|
64
|
+
option_group_item_id: Number(item == null ? void 0 : item.option_group_item_id) || 0,
|
|
65
65
|
option_group_id: Number(item == null ? void 0 : item.option_group_id) || 0,
|
|
66
66
|
num: typeof (item == null ? void 0 : item.num) === "number" && !Number.isNaN(item.num) ? Math.max(1, Math.floor(item.num)) : 1,
|
|
67
67
|
price: String((item == null ? void 0 : item.price) ?? "")
|
|
68
68
|
})).sort((p, q) => {
|
|
69
|
-
if (p.
|
|
70
|
-
return p.
|
|
69
|
+
if (p.option_group_item_id !== q.option_group_item_id) {
|
|
70
|
+
return p.option_group_item_id - q.option_group_item_id;
|
|
71
71
|
}
|
|
72
72
|
if (p.option_group_id !== q.option_group_id)
|
|
73
73
|
return p.option_group_id - q.option_group_id;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Module, ModuleOptions, PisellCore } from '../../types';
|
|
2
|
-
import { BookingTicketCartView,
|
|
2
|
+
import { BookingTicketCartView, BookingTicketProductCatalogView, BookingTicketState, IGetCustomerListParams, ICustomer, ILoadProductsParams, ILoadProductDetailParams, IScanResult } from './types';
|
|
3
3
|
import type { ProductData } from '../../modules';
|
|
4
|
-
import type { OrderCustomerView
|
|
4
|
+
import type { OrderCustomerView } from '../../modules/Order/types';
|
|
5
5
|
import { BaseSalesImpl } from '../BaseSales';
|
|
6
6
|
import type { ISalesDetail } from '../BaseSales/utils/parseSalesResponse';
|
|
7
7
|
import type { LoadSalesDetailParams } from '../../modules/Order/types';
|
|
@@ -13,7 +13,6 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
13
13
|
* 父类按 `getRegisteredModuleNames` 注入成员到该 store。
|
|
14
14
|
*/
|
|
15
15
|
protected store: BookingTicketState;
|
|
16
|
-
private shopStore;
|
|
17
16
|
private platform;
|
|
18
17
|
private scan;
|
|
19
18
|
private productCatalog;
|
|
@@ -102,16 +101,13 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
102
101
|
/**
|
|
103
102
|
* 获取购物车 UI 视图。
|
|
104
103
|
*
|
|
105
|
-
* tempOrder 仍是 checkout
|
|
106
|
-
* 商品行展示字段在 Solution 层合并,避免 UI 直接读取 tempOrder 原始结构。
|
|
104
|
+
* tempOrder 仍是 checkout 协议对象;商品行直接透传 products,bookings 附带关联商品。
|
|
107
105
|
*/
|
|
108
106
|
getCart(): BookingTicketCartView;
|
|
109
107
|
/**
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
* 优先使用 CustomerModule 的 selected customer;缺失时回退到 tempOrder 顶层客户字段。
|
|
108
|
+
* 获取当前下单客户(与 OrderModule.tempOrder snapshot 一致)。
|
|
113
109
|
*/
|
|
114
|
-
getCustomer():
|
|
110
|
+
getCustomer(): ICustomer | null;
|
|
115
111
|
/**
|
|
116
112
|
* 通过 ids 获取商品列表(不加载到模块中)
|
|
117
113
|
* @returns 商品列表
|
|
@@ -169,13 +165,15 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
169
165
|
/**
|
|
170
166
|
* 设置当前下单客户。
|
|
171
167
|
*
|
|
172
|
-
* @param
|
|
173
|
-
*
|
|
168
|
+
* @param customer 完整客户对象;null 表示清空
|
|
169
|
+
*
|
|
170
|
+
* 内部将 customer 格式化为 tempOrder 协议字段后写入 OrderModule,
|
|
171
|
+
* 并以 customer 作为 snapshot 保存富字段。
|
|
174
172
|
*
|
|
175
173
|
* 同时透传 OrderModule 内部 emit 的 `order:onOrderCustomerChange` 之外,
|
|
176
174
|
* 在 BookingTicket 命名空间也 emit 一次,方便上层统一从 Solution 订阅。
|
|
177
175
|
*/
|
|
178
|
-
setOrderCustomer(
|
|
176
|
+
setOrderCustomer(customer: ICustomer | null): void;
|
|
179
177
|
/**
|
|
180
178
|
* 读取 tempOrder 上的下单客户协议字段;customer_id 缺失时返回 null。
|
|
181
179
|
*/
|
|
@@ -233,7 +231,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
233
231
|
* 获取当前的客户搜索条件
|
|
234
232
|
* @returns 当前搜索条件
|
|
235
233
|
*/
|
|
236
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
234
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
237
235
|
/**
|
|
238
236
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
239
237
|
* @returns 客户状态
|