@pisell/pisellos 2.3.42 → 2.3.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/Discount/index.d.ts +1 -0
- package/dist/modules/Discount/index.js +40 -11
- package/dist/modules/Discount/types.d.ts +1 -0
- package/dist/modules/Holder/index.d.ts +48 -0
- package/dist/modules/Holder/index.js +640 -0
- package/dist/modules/Holder/types.d.ts +123 -0
- package/dist/modules/Holder/types.js +1 -0
- package/dist/modules/Holder/utils.d.ts +13 -0
- package/dist/modules/Holder/utils.js +34 -0
- package/dist/modules/OpenData/index.js +2 -2
- package/dist/modules/Order/index.d.ts +5 -2
- package/dist/modules/Order/index.js +127 -53
- package/dist/modules/Order/types.d.ts +11 -0
- package/dist/modules/Order/utils.d.ts +10 -0
- package/dist/modules/Order/utils.js +35 -3
- package/dist/modules/Payment/walletpass.d.ts +10 -3
- package/dist/modules/Payment/walletpass.js +425 -282
- package/dist/modules/Product/types.d.ts +1 -0
- package/dist/modules/ProductList/index.js +33 -14
- package/dist/modules/Quotation/index.d.ts +1 -1
- package/dist/modules/Quotation/index.js +2 -2
- package/dist/modules/ResourcePlanner/index.d.ts +24 -0
- package/dist/modules/ResourcePlanner/index.js +181 -0
- package/dist/modules/ResourcePlanner/planner.d.ts +14 -0
- package/dist/modules/ResourcePlanner/planner.js +1069 -0
- package/dist/modules/ResourcePlanner/types.d.ts +227 -0
- package/dist/modules/ResourcePlanner/types.js +1 -0
- package/dist/modules/Rules/index.d.ts +2 -0
- package/dist/modules/Rules/index.js +106 -68
- package/dist/modules/SalesSummary/index.js +12 -13
- package/dist/modules/ScanOrderLogger/index.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/index.js +15 -2
- package/dist/modules/ScanOrderLogger/providers/feishu.js +45 -27
- package/dist/modules/ScanOrderLogger/types.d.ts +1 -0
- package/dist/modules/Schedule/index.d.ts +3 -1
- package/dist/modules/Schedule/index.js +21 -16
- package/dist/modules/Summary/utils.js +38 -13
- package/dist/modules/index.d.ts +2 -0
- package/dist/modules/index.js +3 -1
- package/dist/plugins/window.d.ts +1 -0
- package/dist/server/index.d.ts +14 -0
- package/dist/server/index.js +772 -657
- package/dist/solution/BaseSales/index.d.ts +7 -0
- package/dist/solution/BaseSales/index.js +70 -45
- package/dist/solution/BaseSales/types.d.ts +3 -1
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -3
- package/dist/solution/BookingByStep/index.d.ts +17 -2
- package/dist/solution/BookingByStep/index.js +294 -215
- package/dist/solution/BookingByStep/types.d.ts +2 -1
- package/dist/solution/BookingByStep/types.js +3 -1
- package/dist/solution/BookingByStep/utils/capacity.js +17 -1
- package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
- package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
- package/dist/solution/BookingTicket/index.js +8 -5
- package/dist/solution/BookingTicket/types.d.ts +1 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +3 -3
- package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +10 -2
- package/dist/solution/ScanOrder/index.d.ts +26 -14
- package/dist/solution/ScanOrder/index.js +1142 -739
- package/dist/solution/ScanOrder/types.d.ts +21 -1
- package/dist/solution/ScanOrder/utils.d.ts +8 -0
- package/dist/solution/ScanOrder/utils.js +66 -25
- package/dist/solution/ShopDiscount/index.d.ts +1 -0
- package/dist/solution/ShopDiscount/index.js +125 -87
- package/dist/solution/UnifiedBookingSales/index.d.ts +183 -0
- package/dist/solution/UnifiedBookingSales/index.js +1891 -0
- package/dist/solution/UnifiedBookingSales/types.d.ts +143 -0
- package/dist/solution/UnifiedBookingSales/types.js +11 -0
- package/dist/solution/VenueBooking/index.d.ts +40 -11
- package/dist/solution/VenueBooking/index.js +1167 -841
- package/dist/solution/VenueBooking/types.d.ts +3 -0
- package/dist/solution/VenueBooking/utils/resource.js +1 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
- package/dist/solution/VenueBooking/utils/slotMerge.js +10 -5
- package/dist/solution/index.d.ts +1 -0
- package/dist/solution/index.js +2 -1
- package/dist/types/index.d.ts +1 -0
- package/lib/modules/Discount/index.d.ts +1 -0
- package/lib/modules/Discount/index.js +9 -0
- package/lib/modules/Discount/types.d.ts +1 -0
- package/lib/modules/Holder/index.d.ts +48 -0
- package/lib/modules/Holder/index.js +402 -0
- package/lib/modules/Holder/types.d.ts +123 -0
- package/lib/modules/Holder/types.js +17 -0
- package/lib/modules/Holder/utils.d.ts +13 -0
- package/lib/modules/Holder/utils.js +71 -0
- package/lib/modules/OpenData/index.js +1 -1
- package/lib/modules/Order/index.d.ts +5 -2
- package/lib/modules/Order/index.js +72 -17
- package/lib/modules/Order/types.d.ts +11 -0
- package/lib/modules/Order/utils.d.ts +10 -0
- package/lib/modules/Order/utils.js +36 -5
- package/lib/modules/Payment/walletpass.d.ts +10 -3
- package/lib/modules/Payment/walletpass.js +218 -56
- package/lib/modules/Product/types.d.ts +1 -0
- package/lib/modules/ProductList/index.js +40 -31
- package/lib/modules/Quotation/index.d.ts +1 -1
- package/lib/modules/Quotation/index.js +2 -2
- package/lib/modules/ResourcePlanner/index.d.ts +24 -0
- package/lib/modules/ResourcePlanner/index.js +148 -0
- package/lib/modules/ResourcePlanner/planner.d.ts +14 -0
- package/lib/modules/ResourcePlanner/planner.js +933 -0
- package/lib/modules/ResourcePlanner/types.d.ts +227 -0
- package/lib/modules/ResourcePlanner/types.js +17 -0
- package/lib/modules/Rules/index.d.ts +2 -0
- package/lib/modules/Rules/index.js +41 -19
- package/lib/modules/SalesSummary/index.js +6 -7
- package/lib/modules/ScanOrderLogger/index.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/index.js +13 -1
- package/lib/modules/ScanOrderLogger/providers/feishu.js +15 -6
- package/lib/modules/ScanOrderLogger/types.d.ts +1 -0
- package/lib/modules/Schedule/index.d.ts +3 -1
- package/lib/modules/Schedule/index.js +10 -8
- package/lib/modules/Summary/utils.js +21 -1
- package/lib/modules/index.d.ts +2 -0
- package/lib/modules/index.js +5 -1
- package/lib/plugins/window.d.ts +1 -0
- package/lib/server/index.d.ts +14 -0
- package/lib/server/index.js +65 -5
- package/lib/solution/BaseSales/index.d.ts +7 -0
- package/lib/solution/BaseSales/index.js +25 -8
- package/lib/solution/BaseSales/types.d.ts +3 -1
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +3 -2
- package/lib/solution/BookingByStep/index.d.ts +17 -2
- package/lib/solution/BookingByStep/index.js +60 -18
- package/lib/solution/BookingByStep/types.d.ts +2 -1
- package/lib/solution/BookingByStep/types.js +5 -0
- package/lib/solution/BookingByStep/utils/capacity.js +20 -1
- package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
- package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
- package/lib/solution/BookingTicket/index.js +11 -2
- package/lib/solution/BookingTicket/types.d.ts +1 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +2 -2
- package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -2
- package/lib/solution/ScanOrder/index.d.ts +26 -14
- package/lib/solution/ScanOrder/index.js +449 -182
- package/lib/solution/ScanOrder/types.d.ts +21 -1
- package/lib/solution/ScanOrder/utils.d.ts +8 -0
- package/lib/solution/ScanOrder/utils.js +31 -0
- package/lib/solution/ShopDiscount/index.d.ts +1 -0
- package/lib/solution/ShopDiscount/index.js +14 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +183 -0
- package/lib/solution/UnifiedBookingSales/index.js +1084 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +143 -0
- package/lib/solution/UnifiedBookingSales/types.js +33 -0
- package/lib/solution/VenueBooking/index.d.ts +40 -11
- package/lib/solution/VenueBooking/index.js +322 -110
- package/lib/solution/VenueBooking/types.d.ts +3 -0
- package/lib/solution/VenueBooking/utils/resource.js +1 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
- package/lib/solution/VenueBooking/utils/slotMerge.js +6 -4
- package/lib/solution/index.d.ts +1 -0
- package/lib/solution/index.js +3 -1
- package/lib/types/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { ProductData } from '../Product/types';
|
|
2
|
+
/**
|
|
3
|
+
* 商品 holder 配置
|
|
4
|
+
*/
|
|
5
|
+
export interface IHolderConfig {
|
|
6
|
+
required?: number;
|
|
7
|
+
resource_id: number;
|
|
8
|
+
status?: string;
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 表单记录
|
|
13
|
+
*/
|
|
14
|
+
export interface IFormRecord {
|
|
15
|
+
form_id: number;
|
|
16
|
+
form_record_id: number;
|
|
17
|
+
main_field: string;
|
|
18
|
+
customer_cover?: string;
|
|
19
|
+
created_at?: string;
|
|
20
|
+
customer_id?: number;
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 表单配置/定义
|
|
25
|
+
*/
|
|
26
|
+
export interface IFormInfo {
|
|
27
|
+
form_id: number;
|
|
28
|
+
name: string;
|
|
29
|
+
fields?: Record<string, any>[];
|
|
30
|
+
[key: string]: any;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* 单个 form_id 下的数据结构
|
|
34
|
+
*/
|
|
35
|
+
export interface IFormItemData {
|
|
36
|
+
records: IFormRecord[];
|
|
37
|
+
form: IFormInfo | Record<string, any>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* form_id 为 key 的 map 结构,如 948: { records: [], form: {} }
|
|
41
|
+
*/
|
|
42
|
+
export type HolderFormMap = Record<string, IFormItemData>;
|
|
43
|
+
/**
|
|
44
|
+
* Holder 模块 reactive store,仅 holderMap 会触发 changed 事件
|
|
45
|
+
*/
|
|
46
|
+
export interface HolderState {
|
|
47
|
+
holderMap: HolderFormMap;
|
|
48
|
+
}
|
|
49
|
+
export interface IFetchFormInfoParams {
|
|
50
|
+
url?: string;
|
|
51
|
+
query: {
|
|
52
|
+
form_id: string | number;
|
|
53
|
+
};
|
|
54
|
+
useCache?: boolean;
|
|
55
|
+
}
|
|
56
|
+
export interface IFetchFormRecordsParams {
|
|
57
|
+
url?: string;
|
|
58
|
+
query: {
|
|
59
|
+
customer_id?: number;
|
|
60
|
+
form_id: string | number;
|
|
61
|
+
shop_id: string | number;
|
|
62
|
+
num?: number;
|
|
63
|
+
skip?: number;
|
|
64
|
+
[key: string]: any;
|
|
65
|
+
};
|
|
66
|
+
useCache?: boolean;
|
|
67
|
+
}
|
|
68
|
+
export interface IAddFormRecordParams {
|
|
69
|
+
url?: string;
|
|
70
|
+
body: {
|
|
71
|
+
form_id: number;
|
|
72
|
+
shop_id: number | string;
|
|
73
|
+
customer_id?: number;
|
|
74
|
+
[key: string]: any;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* UI 层自行调用添加接口后,将返回记录写入 holderMap
|
|
79
|
+
*/
|
|
80
|
+
export interface IAppendFormRecordParams {
|
|
81
|
+
/** 接口返回的 data,或完整响应 { data: {...} } */
|
|
82
|
+
record: IFormRecord | Record<string, any>;
|
|
83
|
+
/** 可选,未传则从 record.form_id 读取 */
|
|
84
|
+
form_id?: number | string;
|
|
85
|
+
}
|
|
86
|
+
export interface IEnsureFormDataParams {
|
|
87
|
+
form_id: number | string;
|
|
88
|
+
shop_id: number | string;
|
|
89
|
+
customer_id?: number;
|
|
90
|
+
useCache?: boolean;
|
|
91
|
+
forceRefresh?: boolean;
|
|
92
|
+
formInfoUrl?: string;
|
|
93
|
+
recordsUrl?: string;
|
|
94
|
+
skip?: number;
|
|
95
|
+
num?: number;
|
|
96
|
+
}
|
|
97
|
+
export interface IEnsureFormByProductParams {
|
|
98
|
+
product: ProductData | Record<string, any>;
|
|
99
|
+
customer_id?: number;
|
|
100
|
+
shop_id?: number | string;
|
|
101
|
+
useCache?: boolean;
|
|
102
|
+
}
|
|
103
|
+
export interface IRefreshAllFormRecordsParams {
|
|
104
|
+
customer_id?: number;
|
|
105
|
+
useCache?: boolean;
|
|
106
|
+
recordsUrl?: string;
|
|
107
|
+
num?: number;
|
|
108
|
+
skip?: number;
|
|
109
|
+
}
|
|
110
|
+
export interface HolderModuleAPI {
|
|
111
|
+
getHolderFormMap: () => HolderFormMap;
|
|
112
|
+
getHolderFormData: (formId: number | string) => IFormItemData | undefined;
|
|
113
|
+
setFormData: (formId: number | string, data: Partial<IFormItemData>) => void;
|
|
114
|
+
fetchFormInfo: (params: IFetchFormInfoParams) => Promise<IFormInfo | IFormInfo[]>;
|
|
115
|
+
fetchRecords: (params: IFetchFormRecordsParams) => Promise<IFormRecord[]>;
|
|
116
|
+
ensureFormData: (params: IEnsureFormDataParams) => Promise<IFormItemData>;
|
|
117
|
+
ensureFormByProduct: (params: IEnsureFormByProductParams) => Promise<IFormItemData | null>;
|
|
118
|
+
addFormRecord: (params: IAddFormRecordParams) => Promise<IFormRecord>;
|
|
119
|
+
appendFormRecord: (params: IAppendFormRecordParams) => IFormRecord;
|
|
120
|
+
removeFormRecord: (formId: number | string, formRecordId: number) => void;
|
|
121
|
+
clearFormData: (formId?: number | string) => void;
|
|
122
|
+
refreshAllFormRecords: (params?: IRefreshAllFormRecordsParams) => Promise<HolderFormMap>;
|
|
123
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
|
|
15
|
+
// src/modules/Holder/types.ts
|
|
16
|
+
var types_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(types_exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ProductData } from '../Product/types';
|
|
2
|
+
import { IFormItemData, IHolderConfig } from './types';
|
|
3
|
+
export declare function getProductHolderConfig(product?: ProductData | Record<string, any> | null): IHolderConfig | null;
|
|
4
|
+
export declare function getFormIdFromHolderConfig(config: IHolderConfig): number;
|
|
5
|
+
export declare function normalizeFormId(formId: number | string): number;
|
|
6
|
+
export declare function createEmptyFormItemData(): {
|
|
7
|
+
records: any[];
|
|
8
|
+
form: Record<string, any>;
|
|
9
|
+
};
|
|
10
|
+
export declare function resolveFormMetaFromHolderItem(mapKey: string, item: IFormItemData): {
|
|
11
|
+
form_id: string | number;
|
|
12
|
+
shop_id: number | string;
|
|
13
|
+
} | null;
|
|
@@ -0,0 +1,71 @@
|
|
|
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/modules/Holder/utils.ts
|
|
20
|
+
var utils_exports = {};
|
|
21
|
+
__export(utils_exports, {
|
|
22
|
+
createEmptyFormItemData: () => createEmptyFormItemData,
|
|
23
|
+
getFormIdFromHolderConfig: () => getFormIdFromHolderConfig,
|
|
24
|
+
getProductHolderConfig: () => getProductHolderConfig,
|
|
25
|
+
normalizeFormId: () => normalizeFormId,
|
|
26
|
+
resolveFormMetaFromHolderItem: () => resolveFormMetaFromHolderItem
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(utils_exports);
|
|
29
|
+
function getProductHolderConfig(product) {
|
|
30
|
+
var _a;
|
|
31
|
+
if (!product)
|
|
32
|
+
return null;
|
|
33
|
+
const config = (product == null ? void 0 : product.holder_config) ?? ((_a = product == null ? void 0 : product.origin) == null ? void 0 : _a.holder_config);
|
|
34
|
+
if ((config == null ? void 0 : config.status) && (config == null ? void 0 : config.status) !== "enable")
|
|
35
|
+
return null;
|
|
36
|
+
if (!(config == null ? void 0 : config.resource_id))
|
|
37
|
+
return null;
|
|
38
|
+
return config;
|
|
39
|
+
}
|
|
40
|
+
function getFormIdFromHolderConfig(config) {
|
|
41
|
+
return Number(config == null ? void 0 : config.resource_id);
|
|
42
|
+
}
|
|
43
|
+
function normalizeFormId(formId) {
|
|
44
|
+
return Number(formId);
|
|
45
|
+
}
|
|
46
|
+
function createEmptyFormItemData() {
|
|
47
|
+
return {
|
|
48
|
+
records: [],
|
|
49
|
+
form: {}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function resolveFormMetaFromHolderItem(mapKey, item) {
|
|
53
|
+
const formInfo = item.form || {};
|
|
54
|
+
const nestedForm = formInfo.form || {};
|
|
55
|
+
const form_id = normalizeFormId(
|
|
56
|
+
nestedForm.id ?? formInfo.form_id ?? formInfo.id ?? mapKey
|
|
57
|
+
);
|
|
58
|
+
const shop_id = nestedForm.shop_id ?? formInfo.shop_id;
|
|
59
|
+
if (shop_id === void 0 || shop_id === null || shop_id === "") {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
return { form_id, shop_id };
|
|
63
|
+
}
|
|
64
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
65
|
+
0 && (module.exports = {
|
|
66
|
+
createEmptyFormItemData,
|
|
67
|
+
getFormIdFromHolderConfig,
|
|
68
|
+
getProductHolderConfig,
|
|
69
|
+
normalizeFormId,
|
|
70
|
+
resolveFormMetaFromHolderItem
|
|
71
|
+
});
|
|
@@ -73,7 +73,7 @@ var OpenDataModule = class extends import_BaseModule.BaseModule {
|
|
|
73
73
|
}
|
|
74
74
|
async fetchOpenData(params) {
|
|
75
75
|
var _a, _b;
|
|
76
|
-
const getData = (_b = (_a = this.appPlugin).getData) == null ? void 0 : _b.call(_a);
|
|
76
|
+
const getData = (_b = (_a = this.appPlugin) == null ? void 0 : _a.getData) == null ? void 0 : _b.call(_a);
|
|
77
77
|
const shopId = getData == null ? void 0 : getData("shop_id");
|
|
78
78
|
if (!shopId)
|
|
79
79
|
throw new Error("[OpenDataModule] 无法获取 shop_id");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import { OrderModuleAPI, CommitOrderParams, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams,
|
|
3
|
+
import { OrderModuleAPI, CommitOrderParams, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, CancelOrderParams, ChangeBookingStatusParams, CheckoutOrderParams } from './types';
|
|
4
4
|
import { CartItem } from '../Cart/types';
|
|
5
5
|
import { type SubmitPayloadEnhancer } from './utils';
|
|
6
6
|
import type { OrderAmountSnapshot, AddProductBookingInput, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, ReplaceTempOrderOptions, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions } from './types';
|
|
@@ -81,6 +81,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
81
81
|
private ensureEditDiscountConfigForProductChange;
|
|
82
82
|
scanCode(code: string, customerId?: number): Promise<{
|
|
83
83
|
isAvailable: boolean;
|
|
84
|
+
isAccepted?: boolean;
|
|
84
85
|
discountList: Discount[];
|
|
85
86
|
type: 'server' | 'clientCalc';
|
|
86
87
|
unavailableReason?: UnavailableReason;
|
|
@@ -146,6 +147,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
146
147
|
isTempOrderPersistEnabled(): boolean;
|
|
147
148
|
/** @deprecated OrderModule 不再负责 tempOrder localStorage 持久化;草稿保存请使用 IndexedDB saveDraft。 */
|
|
148
149
|
persistTempOrder(): void;
|
|
150
|
+
notifyTempOrderChanged(): void;
|
|
149
151
|
private createDefaultTempOrderInstance;
|
|
150
152
|
private createExternalSaleNumber;
|
|
151
153
|
private ensureExternalSaleNumber;
|
|
@@ -485,7 +487,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
485
487
|
generateIdempotencyToken(): string;
|
|
486
488
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
487
489
|
createOrder(params: CommitOrderParams['query']): {
|
|
488
|
-
type: "
|
|
490
|
+
type: "virtual" | "appointment_booking";
|
|
489
491
|
platform: string;
|
|
490
492
|
sales_channel: string;
|
|
491
493
|
order_sales_channel: string;
|
|
@@ -495,6 +497,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
495
497
|
is_deposit: number;
|
|
496
498
|
relation_products: any[];
|
|
497
499
|
relation_forms: any[];
|
|
500
|
+
business_code: string | undefined;
|
|
498
501
|
};
|
|
499
502
|
checkBeforeSubmitOrder(params: {
|
|
500
503
|
cartItems: CartItem[];
|
|
@@ -70,6 +70,24 @@ function isManualProductDiscountProduct(product) {
|
|
|
70
70
|
}
|
|
71
71
|
var ORDER_PAYMENT_STATUS_PAID = "paid";
|
|
72
72
|
var ORDER_PAYMENT_STATUS_PENDING = "payment_pending";
|
|
73
|
+
var CUSTOMER_PROMOTION_DISCOUNT_TAGS = /* @__PURE__ */ new Set([
|
|
74
|
+
"good_pass",
|
|
75
|
+
"product_discount_card",
|
|
76
|
+
"discount_card"
|
|
77
|
+
]);
|
|
78
|
+
function isCustomerPromotionDiscount(discount) {
|
|
79
|
+
return CUSTOMER_PROMOTION_DISCOUNT_TAGS.has(
|
|
80
|
+
String((discount == null ? void 0 : discount.tag) || (discount == null ? void 0 : discount.type) || "").toLowerCase()
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
function markScannedDiscounts(discountList, scannedDiscountList) {
|
|
84
|
+
const scannedIds = new Set(
|
|
85
|
+
scannedDiscountList.map((discount) => discount == null ? void 0 : discount.id).filter((id) => id !== void 0 && id !== null).map(String)
|
|
86
|
+
);
|
|
87
|
+
return discountList.map(
|
|
88
|
+
(discount) => scannedIds.has(String(discount == null ? void 0 : discount.id)) ? { ...discount, isScan: true } : discount
|
|
89
|
+
);
|
|
90
|
+
}
|
|
73
91
|
function isVoucherPaymentRecord(payment) {
|
|
74
92
|
return (payment == null ? void 0 : payment.voucher_id) !== void 0 && Number(payment.voucher_id) !== 0;
|
|
75
93
|
}
|
|
@@ -122,6 +140,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
122
140
|
const type = (item == null ? void 0 : item.type) ?? (item == null ? void 0 : item.tag);
|
|
123
141
|
if (!type || type === "product")
|
|
124
142
|
continue;
|
|
143
|
+
const isDiscountCard = type === "discount_card" || type === "product_discount_card";
|
|
125
144
|
const resourceId = ((_a = item == null ? void 0 : item.discount) == null ? void 0 : _a.resource_id) ?? (item == null ? void 0 : item.resource_id) ?? (item == null ? void 0 : item.discount_id) ?? (item == null ? void 0 : item.order_discount_id);
|
|
126
145
|
if (resourceId === void 0 || resourceId === null || resourceId === "")
|
|
127
146
|
continue;
|
|
@@ -144,7 +163,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
144
163
|
if (existed) {
|
|
145
164
|
existed.amount = Number(existed.amount || 0) + amount;
|
|
146
165
|
existed.used_par_value = String(Number(existed.used_par_value || 0) + amount);
|
|
147
|
-
|
|
166
|
+
if (!isDiscountCard) {
|
|
167
|
+
existed.balance = String(Number(existed.balance || 0) + amount);
|
|
168
|
+
}
|
|
148
169
|
const productIds = Array.isArray((_f = existed.limited_relation_product_data) == null ? void 0 : _f.product_ids) ? existed.limited_relation_product_data.product_ids : [];
|
|
149
170
|
if ((product == null ? void 0 : product.product_id) !== void 0 && (product == null ? void 0 : product.product_id) !== null && !productIds.includes(product.product_id)) {
|
|
150
171
|
existed.limited_relation_product_data = {
|
|
@@ -181,7 +202,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
181
202
|
filter: 0,
|
|
182
203
|
exclude_product_ids: []
|
|
183
204
|
},
|
|
184
|
-
balance: String((item == null ? void 0 : item.amount) ?? "0"),
|
|
205
|
+
balance: isDiscountCard ? void 0 : String((item == null ? void 0 : item.amount) ?? "0"),
|
|
185
206
|
format_title: title,
|
|
186
207
|
product: {
|
|
187
208
|
id: (product == null ? void 0 : product.product_id) ?? 0,
|
|
@@ -307,7 +328,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
307
328
|
});
|
|
308
329
|
}
|
|
309
330
|
async initialize(core, options) {
|
|
310
|
-
var _a, _b, _c;
|
|
331
|
+
var _a, _b, _c, _d;
|
|
311
332
|
this.core = core;
|
|
312
333
|
this.store = options.store;
|
|
313
334
|
if (!this.store.tempOrder) {
|
|
@@ -320,19 +341,19 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
320
341
|
this.store.availableWalletIds = [];
|
|
321
342
|
}
|
|
322
343
|
this.request = this.core.getPlugin("request");
|
|
323
|
-
|
|
324
|
-
if (!
|
|
325
|
-
|
|
344
|
+
const appPlugin = this.core.getPlugin("app");
|
|
345
|
+
if (!appPlugin) {
|
|
346
|
+
console.error("Order 模块需要 app 插件支持");
|
|
326
347
|
}
|
|
327
|
-
const app =
|
|
328
|
-
this.logger = app.logger;
|
|
348
|
+
const app = (_a = appPlugin == null ? void 0 : appPlugin.getApp) == null ? void 0 : _a.call(appPlugin);
|
|
349
|
+
this.logger = app == null ? void 0 : app.logger;
|
|
329
350
|
this.window = this.core.getPlugin("window");
|
|
330
351
|
const otherParams = options.otherParams || {};
|
|
331
352
|
this.cacheId = otherParams.cacheId;
|
|
332
353
|
this.salesSummaryModuleName = otherParams.salesSummaryModuleName;
|
|
333
|
-
this.rulesHooksOverride = (
|
|
354
|
+
this.rulesHooksOverride = (_b = otherParams.rules) == null ? void 0 : _b.hooks;
|
|
334
355
|
this.moduleHooksOverride = options.hooks;
|
|
335
|
-
this.orderHooks = this.moduleHooksOverride || ((
|
|
356
|
+
this.orderHooks = this.moduleHooksOverride || ((_c = otherParams.order) == null ? void 0 : _c.hooks) || ((_d = otherParams.hooks) == null ? void 0 : _d.order);
|
|
336
357
|
this.otherParams = otherParams;
|
|
337
358
|
this.registerDiscountModules(options);
|
|
338
359
|
this.logInfo("OrderModule initialized successfully");
|
|
@@ -528,7 +549,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
528
549
|
});
|
|
529
550
|
}
|
|
530
551
|
async scanCode(code, customerId) {
|
|
531
|
-
var _a, _b, _c, _d;
|
|
552
|
+
var _a, _b, _c, _d, _e;
|
|
532
553
|
const resultDiscountWithReason = await ((_a = this.store.discount) == null ? void 0 : _a.batchSearch(code, { customerId })) || { discountList: [], unavailableReasonKey: null };
|
|
533
554
|
const { discountList: resultDiscountList, unavailableReasonKey } = resultDiscountWithReason;
|
|
534
555
|
const rulesModule = this.store.rules;
|
|
@@ -536,6 +557,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
536
557
|
return {
|
|
537
558
|
type: "clientCalc",
|
|
538
559
|
isAvailable: false,
|
|
560
|
+
isAccepted: false,
|
|
539
561
|
discountList: this.getDiscountList(),
|
|
540
562
|
scannedDiscountList: resultDiscountList,
|
|
541
563
|
unavailableReason: import_types2.UnavailableReason.Unknown
|
|
@@ -545,6 +567,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
545
567
|
return {
|
|
546
568
|
type: "server",
|
|
547
569
|
isAvailable: false,
|
|
570
|
+
isAccepted: false,
|
|
548
571
|
discountList: this.getDiscountList(),
|
|
549
572
|
scannedDiscountList: resultDiscountList,
|
|
550
573
|
unavailableReasonKey
|
|
@@ -560,13 +583,19 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
560
583
|
return {
|
|
561
584
|
type: "clientCalc",
|
|
562
585
|
isAvailable: true,
|
|
586
|
+
isAccepted: true,
|
|
563
587
|
discountList: this.getDiscountList(),
|
|
564
588
|
scannedDiscountList: resultDiscountList
|
|
565
589
|
};
|
|
566
590
|
}
|
|
567
591
|
const tempOrder = this.store.tempOrder;
|
|
568
592
|
const holders = ((_b = tempOrder == null ? void 0 : tempOrder.holder) == null ? void 0 : _b.form_record) || [];
|
|
569
|
-
const {
|
|
593
|
+
const {
|
|
594
|
+
isAvailable,
|
|
595
|
+
discountList: newDiscountList,
|
|
596
|
+
evaluatedDiscountList,
|
|
597
|
+
unavailableReason
|
|
598
|
+
} = rulesModule.isDiscountListAvailable({
|
|
570
599
|
productList: (tempOrder == null ? void 0 : tempOrder.products) || [],
|
|
571
600
|
oldDiscountList: this.getDiscountList(),
|
|
572
601
|
newDiscountList: withScanList,
|
|
@@ -574,15 +603,25 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
574
603
|
holders,
|
|
575
604
|
isFormSubject: (product) => (0, import_utils.resolveIsFormSubject)(tempOrder, product)
|
|
576
605
|
}) || { isAvailable: false, discountList: this.getDiscountList() };
|
|
577
|
-
|
|
578
|
-
|
|
606
|
+
const shouldRetainForLater = !isAvailable && unavailableReason === import_types2.UnavailableReason.ProductNotApplicable && withScanList.some(isCustomerPromotionDiscount);
|
|
607
|
+
const normalizedNewDiscountList = newDiscountList ? markScannedDiscounts(newDiscountList, withScanList) : void 0;
|
|
608
|
+
const retainedDiscountList = evaluatedDiscountList ? markScannedDiscounts(evaluatedDiscountList, withScanList) : normalizedNewDiscountList;
|
|
609
|
+
let resolvedDiscountList = normalizedNewDiscountList || this.getDiscountList();
|
|
610
|
+
if (isAvailable && normalizedNewDiscountList) {
|
|
611
|
+
await ((_d = this.store.discount) == null ? void 0 : _d.setDiscountList(normalizedNewDiscountList));
|
|
579
612
|
this.applyDiscount();
|
|
580
613
|
await this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
614
|
+
resolvedDiscountList = this.getDiscountList();
|
|
615
|
+
} else if (shouldRetainForLater && retainedDiscountList) {
|
|
616
|
+
await ((_e = this.store.discount) == null ? void 0 : _e.setDiscountList(retainedDiscountList));
|
|
617
|
+
await this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
618
|
+
resolvedDiscountList = this.getDiscountList();
|
|
581
619
|
}
|
|
582
620
|
return {
|
|
583
621
|
type: "clientCalc",
|
|
584
622
|
isAvailable: isAvailable || false,
|
|
585
|
-
|
|
623
|
+
isAccepted: Boolean(isAvailable || shouldRetainForLater),
|
|
624
|
+
discountList: resolvedDiscountList,
|
|
586
625
|
scannedDiscountList: resultDiscountList,
|
|
587
626
|
unavailableReason
|
|
588
627
|
};
|
|
@@ -841,6 +880,16 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
841
880
|
/** @deprecated OrderModule 不再负责 tempOrder localStorage 持久化;草稿保存请使用 IndexedDB saveDraft。 */
|
|
842
881
|
persistTempOrder() {
|
|
843
882
|
}
|
|
883
|
+
notifyTempOrderChanged() {
|
|
884
|
+
if (!this.store.tempOrder)
|
|
885
|
+
return;
|
|
886
|
+
this.store.tempOrder = {
|
|
887
|
+
...this.store.tempOrder,
|
|
888
|
+
products: [...this.store.tempOrder.products],
|
|
889
|
+
bookings: this.store.tempOrder.bookings ? [...this.store.tempOrder.bookings] : []
|
|
890
|
+
};
|
|
891
|
+
this.persistTempOrder();
|
|
892
|
+
}
|
|
844
893
|
// ─── TempOrder: 创建 & 获取 ───
|
|
845
894
|
createDefaultTempOrderInstance() {
|
|
846
895
|
return (0, import_utils.createDefaultTempOrder)({
|
|
@@ -3879,7 +3928,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
3879
3928
|
tempOrder,
|
|
3880
3929
|
effectivePayments
|
|
3881
3930
|
);
|
|
3882
|
-
const
|
|
3931
|
+
const submitParams = {
|
|
3883
3932
|
payments: effectivePayments,
|
|
3884
3933
|
paymentStatus,
|
|
3885
3934
|
smallTicketDataFlag: params.smallTicketDataFlag,
|
|
@@ -3893,7 +3942,8 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
3893
3942
|
};
|
|
3894
3943
|
return nextPayload;
|
|
3895
3944
|
}
|
|
3896
|
-
}
|
|
3945
|
+
};
|
|
3946
|
+
const submitResult = params.checkoutSyncTaskEnabled === false ? await this.submitTempOrderAsync(submitParams) : await this.submitTempOrder(submitParams);
|
|
3897
3947
|
return { ...completion, submitResult };
|
|
3898
3948
|
}
|
|
3899
3949
|
createOrder(params) {
|
|
@@ -3910,11 +3960,13 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
3910
3960
|
is_deposit: 0,
|
|
3911
3961
|
relation_products: [],
|
|
3912
3962
|
relation_forms: [],
|
|
3963
|
+
business_code: params == null ? void 0 : params.business_code,
|
|
3913
3964
|
...(params == null ? void 0 : params.extraData) || {}
|
|
3914
3965
|
};
|
|
3915
3966
|
let is_deposit = 0;
|
|
3916
3967
|
if (params.cartItems.length > 0) {
|
|
3917
3968
|
params.cartItems.forEach((item) => {
|
|
3969
|
+
var _a2;
|
|
3918
3970
|
if (!item._origin.duration) {
|
|
3919
3971
|
const { duration, durationType } = (0, import_utils.generateDuration)(item);
|
|
3920
3972
|
item._origin.duration = duration;
|
|
@@ -3923,6 +3975,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
3923
3975
|
item._origin.sub_type = (0, import_utils.normalizeBookingSubType)(item._origin);
|
|
3924
3976
|
const discountList = (0, import_utils.getAllDiscountList)(item);
|
|
3925
3977
|
item._origin.product.discount_list = discountList;
|
|
3978
|
+
if ((_a2 = params == null ? void 0 : params.extraData) == null ? void 0 : _a2.is_add_holder_info) {
|
|
3979
|
+
(0, import_utils.ensureCartItemOriginHolder)(item, this.window);
|
|
3980
|
+
}
|
|
3926
3981
|
if ((0, import_utils2.isNormalProduct)(item._origin)) {
|
|
3927
3982
|
order.relation_products.push(item._origin.product);
|
|
3928
3983
|
const relationForms = item._origin.relation_forms || [];
|
|
@@ -165,6 +165,8 @@ export interface OrderCustomerChangePayload {
|
|
|
165
165
|
}
|
|
166
166
|
export interface OrderScanCodeResult {
|
|
167
167
|
isAvailable: boolean;
|
|
168
|
+
/** 卡券已加入当前订单折扣列表,但不一定能立即应用。 */
|
|
169
|
+
isAccepted?: boolean;
|
|
168
170
|
discountList: Discount[];
|
|
169
171
|
scannedDiscountList: Discount[];
|
|
170
172
|
type: 'server' | 'clientCalc';
|
|
@@ -394,6 +396,7 @@ export interface CommitOrderParams {
|
|
|
394
396
|
type: 'virtual' | 'appointment_booking';
|
|
395
397
|
platform?: string;
|
|
396
398
|
extraData?: Record<string, any>;
|
|
399
|
+
business_code?: string;
|
|
397
400
|
};
|
|
398
401
|
}
|
|
399
402
|
export interface OrderSubmitBooking {
|
|
@@ -569,6 +572,12 @@ export interface SyncPaymentsToOrderParams {
|
|
|
569
572
|
payments: OrderPaymentSource[];
|
|
570
573
|
paymentStatus?: SubmitSalesOrderParams['query']['payment_status'];
|
|
571
574
|
submitWhenPaid?: boolean;
|
|
575
|
+
/**
|
|
576
|
+
* Whether the checkout should be queued as the local `sync_sales` task.
|
|
577
|
+
* Defaults to true to preserve the WebPOS retry path. Set to false when
|
|
578
|
+
* the caller must wait for the cloud checkout response before proceeding.
|
|
579
|
+
*/
|
|
580
|
+
checkoutSyncTaskEnabled?: boolean;
|
|
572
581
|
smallTicketDataFlag?: number;
|
|
573
582
|
businessCode?: string;
|
|
574
583
|
channel?: string;
|
|
@@ -731,6 +740,8 @@ export interface OrderModuleAPI {
|
|
|
731
740
|
setEnableTempOrderPersist: (enabled: boolean) => void;
|
|
732
741
|
/** 是否允许 saveDraft 写入 IndexedDB 草稿。 */
|
|
733
742
|
isTempOrderPersistEnabled: () => boolean;
|
|
743
|
+
/** 提交 tempOrder 变更并触发 `{moduleName}:changed` 事件 */
|
|
744
|
+
notifyTempOrderChanged: () => void;
|
|
734
745
|
submitTempOrder: <T = any>(params?: {
|
|
735
746
|
cacheId?: string;
|
|
736
747
|
platform?: string;
|
|
@@ -15,6 +15,7 @@ export interface OrderProductsDepositSummary {
|
|
|
15
15
|
deposit_policy_ids: number[];
|
|
16
16
|
hasDeposit: boolean;
|
|
17
17
|
}
|
|
18
|
+
import type { WindowPlugin } from '../../plugins';
|
|
18
19
|
/**
|
|
19
20
|
* 把"含 option 的主商品单价"与 bundle 合成"单行 composite 单价"。
|
|
20
21
|
*
|
|
@@ -177,6 +178,15 @@ export declare const mergeRelationForms: (relationForms: {
|
|
|
177
178
|
form_id: number;
|
|
178
179
|
form_record_ids: number[];
|
|
179
180
|
}[];
|
|
181
|
+
export interface CartOrderHolder {
|
|
182
|
+
customer_id?: number;
|
|
183
|
+
form_id: number | string;
|
|
184
|
+
form_record: (number | string)[] | null;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* 为购物车行补齐订单所需的 holder 信息(与 cartAccount 结构保持一致)
|
|
188
|
+
*/
|
|
189
|
+
export declare function ensureCartItemOriginHolder(cartItem: CartItem, window?: WindowPlugin): void;
|
|
180
190
|
export declare const getAllDiscountList: (cartItem: CartItem) => any;
|
|
181
191
|
export { createUuidV4 };
|
|
182
192
|
export declare function isTempOrder(data: any): data is OrderTempOrder;
|
|
@@ -36,8 +36,9 @@ __export(utils_exports, {
|
|
|
36
36
|
composeLinePrice: () => composeLinePrice,
|
|
37
37
|
createDefaultOrderRulesHooks: () => createDefaultOrderRulesHooks,
|
|
38
38
|
createDefaultTempOrder: () => createDefaultTempOrder,
|
|
39
|
-
createEmptySummary: () =>
|
|
39
|
+
createEmptySummary: () => import_utils3.createEmptySummary,
|
|
40
40
|
createUuidV4: () => import_orderCollectionIdentity.createUuidV4,
|
|
41
|
+
ensureCartItemOriginHolder: () => ensureCartItemOriginHolder,
|
|
41
42
|
ensureManualProductDiscountList: () => import_manualProductDiscount.ensureManualProductDiscountList,
|
|
42
43
|
ensureProductSku: () => ensureProductSku,
|
|
43
44
|
findManualProductDiscountItem: () => import_manualProductDiscount.findManualProductDiscountItem,
|
|
@@ -85,9 +86,10 @@ __export(utils_exports, {
|
|
|
85
86
|
module.exports = __toCommonJS(utils_exports);
|
|
86
87
|
var import_dayjs = __toESM(require("dayjs"));
|
|
87
88
|
var import_decimal = __toESM(require("decimal.js"));
|
|
88
|
-
var import_utils = require("
|
|
89
|
-
var import_orderCollectionIdentity = require("./utils/orderCollectionIdentity");
|
|
89
|
+
var import_utils = require("../Holder/utils");
|
|
90
90
|
var import_utils2 = require("../../solution/ScanOrder/utils");
|
|
91
|
+
var import_orderCollectionIdentity = require("./utils/orderCollectionIdentity");
|
|
92
|
+
var import_utils3 = require("../../solution/ScanOrder/utils");
|
|
91
93
|
var import_manualProductDiscount = require("./utils/manualProductDiscount");
|
|
92
94
|
function composeLinePrice(params) {
|
|
93
95
|
const { mainPrice, bundle, useOriginalBundle } = params;
|
|
@@ -546,7 +548,7 @@ function createDefaultOrderRulesHooks() {
|
|
|
546
548
|
// 否则同 SKU 不同小料会在 calcDiscount 重组时互相覆盖。
|
|
547
549
|
// 不透明 identity 契约下,normalizeOrderProduct / hydrate 已保证唯一值存在;
|
|
548
550
|
// 留 fingerprint 分支仅作 Rules 单测里直接传裸 product 时的兜底。
|
|
549
|
-
_id: ((_a = product.metadata) == null ? void 0 : _a.unique_identification_number) ? `${product.product_id}_${product.product_variant_id}_${product.metadata.unique_identification_number}` : `${product.product_id}_${product.product_variant_id}_${(0,
|
|
551
|
+
_id: ((_a = product.metadata) == null ? void 0 : _a.unique_identification_number) ? `${product.product_id}_${product.product_variant_id}_${product.metadata.unique_identification_number}` : `${product.product_id}_${product.product_variant_id}_${(0, import_utils2.buildProductLineFingerprint)(
|
|
550
552
|
getProductSkuOptions(product),
|
|
551
553
|
product.product_bundle
|
|
552
554
|
)}`,
|
|
@@ -638,6 +640,34 @@ var mergeRelationForms = (relationForms) => {
|
|
|
638
640
|
}, {})
|
|
639
641
|
).filter((item) => item.form_record_ids.length > 0);
|
|
640
642
|
};
|
|
643
|
+
function getCustomerIdFromStorage(window) {
|
|
644
|
+
var _a;
|
|
645
|
+
try {
|
|
646
|
+
const customer = JSON.parse(((_a = window == null ? void 0 : window.getLocalStorage) == null ? void 0 : _a.call(window, "customer")) || "{}");
|
|
647
|
+
const customerId = Number(customer == null ? void 0 : customer.id);
|
|
648
|
+
return Number.isFinite(customerId) && customerId > 0 ? customerId : void 0;
|
|
649
|
+
} catch {
|
|
650
|
+
return void 0;
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
function ensureCartItemOriginHolder(cartItem, window) {
|
|
654
|
+
var _a;
|
|
655
|
+
if ((_a = cartItem == null ? void 0 : cartItem._origin) == null ? void 0 : _a.holder) {
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
const holderConfig = (0, import_utils.getProductHolderConfig)(
|
|
659
|
+
(cartItem == null ? void 0 : cartItem._productInit) ?? (cartItem == null ? void 0 : cartItem._productOrigin)
|
|
660
|
+
);
|
|
661
|
+
const formRecordId = cartItem == null ? void 0 : cartItem.holder_id;
|
|
662
|
+
if (!(holderConfig == null ? void 0 : holderConfig.resource_id) || formRecordId == null) {
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
cartItem._origin.holder = {
|
|
666
|
+
customer_id: getCustomerIdFromStorage(window),
|
|
667
|
+
form_id: holderConfig.resource_id,
|
|
668
|
+
form_record: [formRecordId]
|
|
669
|
+
};
|
|
670
|
+
}
|
|
641
671
|
var getAllDiscountList = (cartItem) => {
|
|
642
672
|
var _a, _b, _c, _d;
|
|
643
673
|
let discountList = ((_b = (_a = cartItem == null ? void 0 : cartItem._origin) == null ? void 0 : _a.product) == null ? void 0 : _b.discount_list) || [];
|
|
@@ -1003,7 +1033,7 @@ function buildSubmitPayload(params) {
|
|
|
1003
1033
|
// contacts: tempOrder.contacts || [],
|
|
1004
1034
|
contacts_info: tempOrder.contacts_info && !Array.isArray(tempOrder.contacts_info) ? tempOrder.contacts_info : null,
|
|
1005
1035
|
// holder: tempOrder.holder || null,
|
|
1006
|
-
summary: summary || tempOrder.summary || (0,
|
|
1036
|
+
summary: summary || tempOrder.summary || (0, import_utils2.createEmptySummary)(),
|
|
1007
1037
|
metadata: (() => {
|
|
1008
1038
|
const {
|
|
1009
1039
|
collect_pax: _collectPax,
|
|
@@ -1252,6 +1282,7 @@ function indexOrderProductsByUid(products) {
|
|
|
1252
1282
|
createDefaultTempOrder,
|
|
1253
1283
|
createEmptySummary,
|
|
1254
1284
|
createUuidV4,
|
|
1285
|
+
ensureCartItemOriginHolder,
|
|
1255
1286
|
ensureManualProductDiscountList,
|
|
1256
1287
|
ensureProductSku,
|
|
1257
1288
|
findManualProductDiscountItem,
|