@pisell/pisellos 3.0.92 → 3.0.94
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/Discount/types.d.ts +2 -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/Order/index.d.ts +2 -1
- package/dist/modules/Order/index.js +18 -1
- package/dist/modules/Order/types.d.ts +2 -0
- package/dist/modules/Order/utils.d.ts +10 -0
- package/dist/modules/Order/utils.js +35 -3
- package/dist/modules/Product/types.d.ts +7 -0
- package/dist/modules/Rules/index.js +13 -0
- package/dist/modules/Summary/utils.js +42 -21
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +2 -1
- package/dist/plugins/window.d.ts +1 -0
- package/dist/solution/BookingByStep/index.d.ts +16 -1
- package/dist/solution/BookingByStep/index.js +276 -204
- package/dist/solution/BookingByStep/types.d.ts +2 -1
- package/dist/solution/BookingByStep/types.js +3 -1
- package/dist/solution/ScanOrder/types.d.ts +1 -0
- package/dist/solution/VenueBooking/index.d.ts +24 -0
- package/dist/solution/VenueBooking/index.js +1010 -733
- package/dist/solution/VenueBooking/types.d.ts +2 -0
- package/dist/types/index.d.ts +1 -0
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/Discount/types.d.ts +2 -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/Order/index.d.ts +2 -1
- package/lib/modules/Order/index.js +14 -0
- package/lib/modules/Order/types.d.ts +2 -0
- package/lib/modules/Order/utils.d.ts +10 -0
- package/lib/modules/Order/utils.js +36 -5
- package/lib/modules/Product/types.d.ts +7 -0
- package/lib/modules/Rules/index.js +8 -0
- package/lib/modules/Summary/utils.js +23 -3
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +3 -1
- package/lib/plugins/window.d.ts +1 -0
- package/lib/solution/BookingByStep/index.d.ts +16 -1
- package/lib/solution/BookingByStep/index.js +39 -0
- package/lib/solution/BookingByStep/types.d.ts +2 -1
- package/lib/solution/BookingByStep/types.js +5 -0
- package/lib/solution/ScanOrder/types.d.ts +1 -0
- package/lib/solution/VenueBooking/index.d.ts +24 -0
- package/lib/solution/VenueBooking/index.js +152 -16
- package/lib/solution/VenueBooking/types.d.ts +2 -0
- 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 @@
|
|
|
1
|
+
export {};
|
|
@@ -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: number | string;
|
|
12
|
+
shop_id: number | string;
|
|
13
|
+
} | null;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export function getProductHolderConfig(product) {
|
|
2
|
+
var _product$holder_confi, _product$origin;
|
|
3
|
+
if (!product) return null;
|
|
4
|
+
var config = (_product$holder_confi = product === null || product === void 0 ? void 0 : product.holder_config) !== null && _product$holder_confi !== void 0 ? _product$holder_confi : product === null || product === void 0 || (_product$origin = product.origin) === null || _product$origin === void 0 ? void 0 : _product$origin.holder_config;
|
|
5
|
+
if (config !== null && config !== void 0 && config.status && (config === null || config === void 0 ? void 0 : config.status) !== 'enable') return null;
|
|
6
|
+
if (!(config !== null && config !== void 0 && config.resource_id)) return null;
|
|
7
|
+
return config;
|
|
8
|
+
}
|
|
9
|
+
export function getFormIdFromHolderConfig(config) {
|
|
10
|
+
return Number(config === null || config === void 0 ? void 0 : config.resource_id);
|
|
11
|
+
}
|
|
12
|
+
export function normalizeFormId(formId) {
|
|
13
|
+
return Number(formId);
|
|
14
|
+
}
|
|
15
|
+
export function createEmptyFormItemData() {
|
|
16
|
+
return {
|
|
17
|
+
records: [],
|
|
18
|
+
form: {}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export function resolveFormMetaFromHolderItem(mapKey, item) {
|
|
22
|
+
var _ref, _ref2, _nestedForm$id, _nestedForm$shop_id;
|
|
23
|
+
var formInfo = item.form || {};
|
|
24
|
+
var nestedForm = formInfo.form || {};
|
|
25
|
+
var form_id = normalizeFormId((_ref = (_ref2 = (_nestedForm$id = nestedForm.id) !== null && _nestedForm$id !== void 0 ? _nestedForm$id : formInfo.form_id) !== null && _ref2 !== void 0 ? _ref2 : formInfo.id) !== null && _ref !== void 0 ? _ref : mapKey);
|
|
26
|
+
var shop_id = (_nestedForm$shop_id = nestedForm.shop_id) !== null && _nestedForm$shop_id !== void 0 ? _nestedForm$shop_id : formInfo.shop_id;
|
|
27
|
+
if (shop_id === undefined || shop_id === null || shop_id === '') {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
form_id: form_id,
|
|
32
|
+
shop_id: shop_id
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -44,6 +44,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
44
44
|
private getTempOrderStorageKey;
|
|
45
45
|
private restoreTempOrderFromStorage;
|
|
46
46
|
persistTempOrder(): void;
|
|
47
|
+
notifyTempOrderChanged(): void;
|
|
47
48
|
private createDefaultTempOrderInstance;
|
|
48
49
|
ensureTempOrder(): ScanOrderTempOrder;
|
|
49
50
|
restoreOrder(): ScanOrderTempOrder;
|
|
@@ -70,7 +71,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
70
71
|
enhancePayload?: SubmitPayloadEnhancer;
|
|
71
72
|
}): Promise<T>;
|
|
72
73
|
createOrder(params: CommitOrderParams['query']): {
|
|
73
|
-
type: "
|
|
74
|
+
type: "appointment_booking" | "virtual";
|
|
74
75
|
platform: string;
|
|
75
76
|
sales_channel: string;
|
|
76
77
|
order_sales_channel: string;
|
|
@@ -25,7 +25,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
25
25
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
26
26
|
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); }
|
|
27
27
|
import { BaseModule } from "../BaseModule";
|
|
28
|
-
import { generateDuration, getAllDiscountList, mergeRelationForms, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, filterProductsForScanOrderMore, isTempOrder } from "./utils";
|
|
28
|
+
import { generateDuration, getAllDiscountList, mergeRelationForms, ensureCartItemOriginHolder, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, filterProductsForScanOrderMore, isTempOrder } from "./utils";
|
|
29
29
|
import { isNormalProduct } from "../Product/utils";
|
|
30
30
|
import { buildProductLineFingerprint, getProductIdentityIndex, getSafeProductNum, isIdentityMatch, normalizeOrderProduct } from "../../solution/ScanOrder/utils";
|
|
31
31
|
import { DiscountModule } from "../Discount";
|
|
@@ -378,6 +378,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
378
378
|
if (!this.window) return;
|
|
379
379
|
this.window.localStorage.setItem(key, JSON.stringify(this.store.tempOrder));
|
|
380
380
|
}
|
|
381
|
+
}, {
|
|
382
|
+
key: "notifyTempOrderChanged",
|
|
383
|
+
value: function notifyTempOrderChanged() {
|
|
384
|
+
if (!this.store.tempOrder) return;
|
|
385
|
+
this.store.tempOrder = _objectSpread(_objectSpread({}, this.store.tempOrder), {}, {
|
|
386
|
+
products: _toConsumableArray(this.store.tempOrder.products),
|
|
387
|
+
bookings: this.store.tempOrder.bookings ? _toConsumableArray(this.store.tempOrder.bookings) : []
|
|
388
|
+
});
|
|
389
|
+
this.persistTempOrder();
|
|
390
|
+
}
|
|
381
391
|
|
|
382
392
|
// ─── TempOrder: 创建 & 获取 ───
|
|
383
393
|
}, {
|
|
@@ -799,6 +809,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
799
809
|
}, {
|
|
800
810
|
key: "createOrder",
|
|
801
811
|
value: function createOrder(params) {
|
|
812
|
+
var _this2 = this;
|
|
802
813
|
var order = _objectSpread({
|
|
803
814
|
type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
|
|
804
815
|
// 要从外面拿,virtual
|
|
@@ -815,6 +826,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
815
826
|
var is_deposit = 0; // 是否存在定金,0 不存在,1 存在
|
|
816
827
|
if (params.cartItems.length > 0) {
|
|
817
828
|
params.cartItems.forEach(function (item) {
|
|
829
|
+
var _params$extraData;
|
|
818
830
|
if (!item._origin.duration) {
|
|
819
831
|
var _generateDuration = generateDuration(item),
|
|
820
832
|
duration = _generateDuration.duration,
|
|
@@ -825,6 +837,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
825
837
|
var discountList = getAllDiscountList(item);
|
|
826
838
|
item._origin.product.discount_list = discountList;
|
|
827
839
|
|
|
840
|
+
// 为预约补齐 holder 信息
|
|
841
|
+
if (params !== null && params !== void 0 && (_params$extraData = params.extraData) !== null && _params$extraData !== void 0 && _params$extraData.is_add_holder_info) {
|
|
842
|
+
ensureCartItemOriginHolder(item, _this2.window);
|
|
843
|
+
}
|
|
844
|
+
|
|
828
845
|
// 购物车是否为普通商品
|
|
829
846
|
if (isNormalProduct(item._origin)) {
|
|
830
847
|
var _order$relation_forms;
|
|
@@ -189,6 +189,8 @@ export interface OrderModuleAPI {
|
|
|
189
189
|
updateProductInOrder: (params: UpdateProductInOrderParams) => Promise<ScanOrderOrderProduct[]>;
|
|
190
190
|
removeProductFromOrder: (identity: ScanOrderOrderProductIdentity) => Promise<ScanOrderOrderProduct[]>;
|
|
191
191
|
persistTempOrder: () => void;
|
|
192
|
+
/** 提交 tempOrder 变更并触发 `{moduleName}:changed` 事件 */
|
|
193
|
+
notifyTempOrderChanged: () => void;
|
|
192
194
|
submitTempOrder: <T = any>(params?: {
|
|
193
195
|
cacheId?: string;
|
|
194
196
|
platform?: string;
|
|
@@ -2,6 +2,7 @@ import Decimal from 'decimal.js';
|
|
|
2
2
|
import { CartItem } from "../Cart";
|
|
3
3
|
import type { ScanOrderSubmitPayload, ScanOrderSubmitProduct, ScanOrderSummary, ScanOrderTempOrder } from '../../solution/ScanOrder/types';
|
|
4
4
|
import type { RulesParamsHooks } from '../Rules/types';
|
|
5
|
+
import type { WindowPlugin } from '../../plugins';
|
|
5
6
|
/**
|
|
6
7
|
* 把"含 option 的主商品单价"与 bundle 合成"单行 composite 单价"。
|
|
7
8
|
*
|
|
@@ -86,6 +87,15 @@ export declare const mergeRelationForms: (relationForms: {
|
|
|
86
87
|
form_id: number;
|
|
87
88
|
form_record_ids: number[];
|
|
88
89
|
}[];
|
|
90
|
+
export interface CartOrderHolder {
|
|
91
|
+
customer_id?: number;
|
|
92
|
+
form_id: number | string;
|
|
93
|
+
form_record: (number | string)[] | null;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* 为购物车行补齐订单所需的 holder 信息(与 cartAccount 结构保持一致)
|
|
97
|
+
*/
|
|
98
|
+
export declare function ensureCartItemOriginHolder(cartItem: CartItem, window?: WindowPlugin): void;
|
|
89
99
|
export declare const getAllDiscountList: (cartItem: CartItem) => any;
|
|
90
100
|
export declare function createUuidV4(): string;
|
|
91
101
|
export declare function isTempOrder(data: any): data is ScanOrderTempOrder;
|
|
@@ -18,6 +18,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
18
18
|
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; }
|
|
19
19
|
import dayjs from "dayjs";
|
|
20
20
|
import Decimal from 'decimal.js';
|
|
21
|
+
import { getProductHolderConfig } from "../Holder/utils";
|
|
21
22
|
import { buildProductLineFingerprint, createEmptySummary } from "../../solution/ScanOrder/utils";
|
|
22
23
|
/**
|
|
23
24
|
* 把"含 option 的主商品单价"与 bundle 合成"单行 composite 单价"。
|
|
@@ -259,10 +260,41 @@ export var mergeRelationForms = function mergeRelationForms(relationForms) {
|
|
|
259
260
|
return item.form_record_ids.length > 0;
|
|
260
261
|
}); // 过滤掉没有有效记录的表单
|
|
261
262
|
};
|
|
263
|
+
function getCustomerIdFromStorage(window) {
|
|
264
|
+
try {
|
|
265
|
+
var _window$getLocalStora;
|
|
266
|
+
var customer = JSON.parse((window === null || window === void 0 || (_window$getLocalStora = window.getLocalStorage) === null || _window$getLocalStora === void 0 ? void 0 : _window$getLocalStora.call(window, 'customer')) || '{}');
|
|
267
|
+
var customerId = Number(customer === null || customer === void 0 ? void 0 : customer.id);
|
|
268
|
+
return Number.isFinite(customerId) && customerId > 0 ? customerId : undefined;
|
|
269
|
+
} catch (_unused) {
|
|
270
|
+
return undefined;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* 为购物车行补齐订单所需的 holder 信息(与 cartAccount 结构保持一致)
|
|
276
|
+
*/
|
|
277
|
+
export function ensureCartItemOriginHolder(cartItem, window) {
|
|
278
|
+
var _cartItem$_origin, _cartItem$_productIni;
|
|
279
|
+
if (cartItem !== null && cartItem !== void 0 && (_cartItem$_origin = cartItem._origin) !== null && _cartItem$_origin !== void 0 && _cartItem$_origin.holder) {
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
var holderConfig = getProductHolderConfig((_cartItem$_productIni = cartItem === null || cartItem === void 0 ? void 0 : cartItem._productInit) !== null && _cartItem$_productIni !== void 0 ? _cartItem$_productIni : cartItem === null || cartItem === void 0 ? void 0 : cartItem._productOrigin);
|
|
283
|
+
var formRecordId = cartItem === null || cartItem === void 0 ? void 0 : cartItem.holder_id;
|
|
284
|
+
if (!(holderConfig !== null && holderConfig !== void 0 && holderConfig.resource_id) || formRecordId == null) {
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
cartItem._origin.holder = {
|
|
288
|
+
customer_id: getCustomerIdFromStorage(window),
|
|
289
|
+
form_id: holderConfig.resource_id,
|
|
290
|
+
form_record: [formRecordId]
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
;
|
|
262
294
|
export var getAllDiscountList = function getAllDiscountList(cartItem) {
|
|
263
|
-
var _cartItem$
|
|
264
|
-
var discountList = (cartItem === null || cartItem === void 0 || (_cartItem$
|
|
265
|
-
((cartItem === null || cartItem === void 0 || (_cartItem$
|
|
295
|
+
var _cartItem$_origin2, _cartItem$_origin3;
|
|
296
|
+
var discountList = (cartItem === null || cartItem === void 0 || (_cartItem$_origin2 = cartItem._origin) === null || _cartItem$_origin2 === void 0 || (_cartItem$_origin2 = _cartItem$_origin2.product) === null || _cartItem$_origin2 === void 0 ? void 0 : _cartItem$_origin2.discount_list) || [];
|
|
297
|
+
((cartItem === null || cartItem === void 0 || (_cartItem$_origin3 = cartItem._origin) === null || _cartItem$_origin3 === void 0 || (_cartItem$_origin3 = _cartItem$_origin3.product) === null || _cartItem$_origin3 === void 0 ? void 0 : _cartItem$_origin3.product_bundle) || []).forEach(function (item) {
|
|
266
298
|
discountList = [].concat(_toConsumableArray(discountList), _toConsumableArray(item.discount_list || []));
|
|
267
299
|
item.discount_list = undefined;
|
|
268
300
|
});
|
|
@@ -189,6 +189,13 @@ export interface ProductData {
|
|
|
189
189
|
};
|
|
190
190
|
/** 购物车行键,用于唯一标识购物车中的商品,用于相同 SKU商品合并 */
|
|
191
191
|
rowKey?: string;
|
|
192
|
+
/** holder 表单配置 */
|
|
193
|
+
holder_config?: {
|
|
194
|
+
required?: number;
|
|
195
|
+
resource_id?: number;
|
|
196
|
+
status?: string;
|
|
197
|
+
[key: string]: any;
|
|
198
|
+
};
|
|
192
199
|
}
|
|
193
200
|
/**
|
|
194
201
|
* 商品媒体信息接口
|
|
@@ -526,6 +526,15 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
526
526
|
return priceB.minus(priceA).toNumber();
|
|
527
527
|
});
|
|
528
528
|
|
|
529
|
+
// 检查商品是否被排除(全品类)
|
|
530
|
+
var isProductIncludedByLimitedData = function isProductIncludedByLimitedData(limitedData, productId) {
|
|
531
|
+
var excludedIds = (limitedData === null || limitedData === void 0 ? void 0 : limitedData.exclude_product_ids) || [];
|
|
532
|
+
var isExcluded = (limitedData === null || limitedData === void 0 ? void 0 : limitedData.filter) === 1 && excludedIds.some(function (id) {
|
|
533
|
+
return String(id) === String(productId);
|
|
534
|
+
});
|
|
535
|
+
return !isExcluded;
|
|
536
|
+
};
|
|
537
|
+
|
|
529
538
|
/**
|
|
530
539
|
// 对productList按价格降序排序(用于应用优惠券时优先选择高价商品) 价格相同时使用quantity 排序
|
|
531
540
|
const sortedProductList = [...productList].sort((a, b) => {
|
|
@@ -914,6 +923,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
914
923
|
|
|
915
924
|
// 判断优惠券是否适用于该商品
|
|
916
925
|
if (limitedData.type === 'product_all') {
|
|
926
|
+
if (!isProductIncludedByLimitedData(limitedData, product.id)) {
|
|
927
|
+
return false;
|
|
928
|
+
}
|
|
929
|
+
|
|
917
930
|
// 检查 package_sub_item_usage_rules
|
|
918
931
|
if (!_this3.checkPackageSubItemUsageRules(discount, flatItem)) {
|
|
919
932
|
return false;
|
|
@@ -595,6 +595,27 @@ export var calculateTaxFee = function calculateTaxFee(shopInfo, items) {
|
|
|
595
595
|
}, new Decimal(0));
|
|
596
596
|
return totalTaxFee;
|
|
597
597
|
};
|
|
598
|
+
var getCartItemDepositData = function getCartItemDepositData(item) {
|
|
599
|
+
var _target$_productOrigi, _target$_origin, _target$_origin2;
|
|
600
|
+
var target = item;
|
|
601
|
+
return (target === null || target === void 0 || (_target$_productOrigi = target._productOrigin) === null || _target$_productOrigi === void 0 ? void 0 : _target$_productOrigi.custom_deposit_data) || (target === null || target === void 0 || (_target$_origin = target._origin) === null || _target$_origin === void 0 ? void 0 : _target$_origin.custom_deposit_data) || (target === null || target === void 0 || (_target$_origin2 = target._origin) === null || _target$_origin2 === void 0 || (_target$_origin2 = _target$_origin2.product) === null || _target$_origin2 === void 0 ? void 0 : _target$_origin2.custom_deposit_data);
|
|
602
|
+
};
|
|
603
|
+
var getCartItemQuantity = function getCartItemQuantity(item) {
|
|
604
|
+
return new Decimal((item === null || item === void 0 ? void 0 : item.num) || 1);
|
|
605
|
+
};
|
|
606
|
+
var calculateCartItemDepositTotal = function calculateCartItemDepositTotal(item) {
|
|
607
|
+
var _item$deposit;
|
|
608
|
+
var depositData = getCartItemDepositData(item);
|
|
609
|
+
if ((depositData === null || depositData === void 0 ? void 0 : depositData.has_deposit) == 1 && typeof (depositData === null || depositData === void 0 ? void 0 : depositData.deposit_fixed) === 'string' && typeof (depositData === null || depositData === void 0 ? void 0 : depositData.deposit_percentage) === 'string') {
|
|
610
|
+
var _ref7, _summaryTotal;
|
|
611
|
+
var lineTotal = new Decimal((_ref7 = (_summaryTotal = item.summaryTotal) !== null && _summaryTotal !== void 0 ? _summaryTotal : item.total) !== null && _ref7 !== void 0 ? _ref7 : 0);
|
|
612
|
+
var quantity = getCartItemQuantity(item);
|
|
613
|
+
var fixedTotal = new Decimal(depositData.deposit_fixed || 0).times(quantity);
|
|
614
|
+
var percentageTotal = new Decimal(depositData.deposit_percentage || 0).times(lineTotal);
|
|
615
|
+
return fixedTotal.plus(percentageTotal);
|
|
616
|
+
}
|
|
617
|
+
return new Decimal((item === null || item === void 0 || (_item$deposit = item.deposit) === null || _item$deposit === void 0 ? void 0 : _item$deposit.total) || 0);
|
|
618
|
+
};
|
|
598
619
|
|
|
599
620
|
/**
|
|
600
621
|
* @title: 计算定金
|
|
@@ -609,9 +630,9 @@ export var calculateDeposit = function calculateDeposit(items) {
|
|
|
609
630
|
var hasDeposit = false;
|
|
610
631
|
var total = items.reduce(function (sum, item) {
|
|
611
632
|
if (item !== null && item !== void 0 && item.deposit) {
|
|
612
|
-
var _item$
|
|
633
|
+
var _item$deposit2;
|
|
613
634
|
hasDeposit = true;
|
|
614
|
-
var cartItemTotalPrice =
|
|
635
|
+
var cartItemTotalPrice = calculateCartItemDepositTotal(item);
|
|
615
636
|
// 将协议数据去重合并
|
|
616
637
|
item === null || item === void 0 || (_item$deposit2 = item.deposit) === null || _item$deposit2 === void 0 || (_item$deposit2 = _item$deposit2.protocols) === null || _item$deposit2 === void 0 || _item$deposit2.forEach(function (protocol) {
|
|
617
638
|
if (protocols.findIndex(function (p) {
|
|
@@ -648,9 +669,9 @@ export var calculateDeposit = function calculateDeposit(items) {
|
|
|
648
669
|
* @param options.isEdit 是否处于“编辑中”。`false` 时会优先走后端金额直取逻辑(若存在)
|
|
649
670
|
* @returns 订单附加费金额(number,金额单位与商品价格一致)
|
|
650
671
|
*/
|
|
651
|
-
export var getSurchargeAmount = function getSurchargeAmount(
|
|
652
|
-
var bookingDetail =
|
|
653
|
-
bookingId =
|
|
672
|
+
export var getSurchargeAmount = function getSurchargeAmount(_ref8, surcharge, options) {
|
|
673
|
+
var bookingDetail = _ref8.bookingDetail,
|
|
674
|
+
bookingId = _ref8.bookingId;
|
|
654
675
|
var isEdit = options.isEdit;
|
|
655
676
|
// 订单未变更过
|
|
656
677
|
if (!isEdit) {
|
|
@@ -695,17 +716,17 @@ var getDiscountAmount = function getDiscountAmount(discounts) {
|
|
|
695
716
|
* 获取主商品加价减价后的总价 (主商品价格 + 子商品加价减价)
|
|
696
717
|
*/
|
|
697
718
|
var getMainProductTotal = function getMainProductTotal(item) {
|
|
698
|
-
var
|
|
719
|
+
var _ref9, _ref10, _item$main_product_se, _item$metadata, _item$metadata2, _item$metadata3, _item$metadata4;
|
|
699
720
|
// 新语义 v2 下 `main_product_selling_price` / `metadata.main_product_selling_price`
|
|
700
721
|
// 已经是"含 option、含主商品折扣"的主价,直接作为主商品基准,无需再减折扣或加 option。
|
|
701
722
|
// 仅需叠加 markup / markdown 类 bundle(原价 bundle 的税费单独处理)。
|
|
702
|
-
var total = new Decimal((
|
|
723
|
+
var total = new Decimal((_ref9 = (_ref10 = (_item$main_product_se = item === null || item === void 0 ? void 0 : item.main_product_selling_price) !== null && _item$main_product_se !== void 0 ? _item$main_product_se : item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.main_product_selling_price) !== null && _ref10 !== void 0 ? _ref10 : item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.main_product_original_price) !== null && _ref9 !== void 0 ? _ref9 : 0);
|
|
703
724
|
|
|
704
725
|
// 做个兜底 如果新语义价格字段都没有,则切换回老逻辑
|
|
705
726
|
var hasMainProductPrice = (item === null || item === void 0 ? void 0 : item.main_product_selling_price) != null || (item === null || item === void 0 || (_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.main_product_selling_price) != null || (item === null || item === void 0 || (_item$metadata4 = item.metadata) === null || _item$metadata4 === void 0 ? void 0 : _item$metadata4.main_product_original_price) != null;
|
|
706
727
|
if (!hasMainProductPrice) {
|
|
707
|
-
var
|
|
708
|
-
total = new Decimal((
|
|
728
|
+
var _ref11, _ref12, _item$main_product_se2, _item$metadata5, _item$_origin3, _item$_originData;
|
|
729
|
+
total = new Decimal((_ref11 = (_ref12 = (_item$main_product_se2 = item === null || item === void 0 ? void 0 : item.main_product_selling_price) !== null && _item$main_product_se2 !== void 0 ? _item$main_product_se2 : item === null || item === void 0 || (_item$metadata5 = item.metadata) === null || _item$metadata5 === void 0 ? void 0 : _item$metadata5.main_product_selling_price) !== null && _ref12 !== void 0 ? _ref12 : item.price) !== null && _ref11 !== void 0 ? _ref11 : 0);
|
|
709
730
|
var discount = (item === null || item === void 0 || (_item$_origin3 = item._origin) === null || _item$_origin3 === void 0 || (_item$_origin3 = _item$_origin3.product) === null || _item$_origin3 === void 0 ? void 0 : _item$_origin3.discount_list) || (item === null || item === void 0 || (_item$_originData = item._originData) === null || _item$_originData === void 0 || (_item$_originData = _item$_originData.product) === null || _item$_originData === void 0 || (_item$_originData = _item$_originData.discount_list) === null || _item$_originData === void 0 ? void 0 : _item$_originData.filter(function (item) {
|
|
710
731
|
var _item$metadata6;
|
|
711
732
|
return !(item !== null && item !== void 0 && (_item$metadata6 = item.metadata) !== null && _item$metadata6 !== void 0 && _item$metadata6.custom_product_bundle_map_id);
|
|
@@ -726,9 +747,9 @@ var getMainProductTotal = function getMainProductTotal(item) {
|
|
|
726
747
|
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
727
748
|
var bundleItem = _step4.value;
|
|
728
749
|
if (getBundleItemIsMarkupOrDiscountPrice(bundleItem)) {
|
|
729
|
-
var
|
|
750
|
+
var _ref13, _bundleItem$bundle_se2;
|
|
730
751
|
// IMPORTANT: 套餐子商品如果应用了 discount,bundle_selling_price 和 price 其实都已经是折后价格了,不需要单独再减一次
|
|
731
|
-
var bundleItemTotal = new Decimal((
|
|
752
|
+
var bundleItemTotal = new Decimal((_ref13 = (_bundleItem$bundle_se2 = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se2 !== void 0 ? _bundleItem$bundle_se2 : bundleItem.price) !== null && _ref13 !== void 0 ? _ref13 : 0);
|
|
732
753
|
total = total.add(bundleItemTotal);
|
|
733
754
|
}
|
|
734
755
|
}
|
|
@@ -848,12 +869,12 @@ var isProductMatchSurchargeCondition = function isProductMatchSurchargeCondition
|
|
|
848
869
|
* @param options.scheduleById schedule 映射表:`{ [scheduleId]: schedule }`(用于根据配置的 `available_schedule_ids` 做日程匹配)
|
|
849
870
|
* @returns 附加费列表(仅返回金额 > 0 的项)
|
|
850
871
|
*/
|
|
851
|
-
export var getSurcharge = function getSurcharge(
|
|
872
|
+
export var getSurcharge = function getSurcharge(_ref14, options) {
|
|
852
873
|
var _service$filter;
|
|
853
|
-
var service =
|
|
854
|
-
addons =
|
|
855
|
-
bookingDetail =
|
|
856
|
-
bookingId =
|
|
874
|
+
var service = _ref14.service,
|
|
875
|
+
addons = _ref14.addons,
|
|
876
|
+
bookingDetail = _ref14.bookingDetail,
|
|
877
|
+
bookingId = _ref14.bookingId;
|
|
857
878
|
var isEdit = options.isEdit,
|
|
858
879
|
isInScheduleByDate = options.isInScheduleByDate,
|
|
859
880
|
surcharge_list = options.surcharge_list,
|
|
@@ -975,11 +996,11 @@ export var getSurcharge = function getSurcharge(_ref13, options) {
|
|
|
975
996
|
scheduleById: scheduleById || {},
|
|
976
997
|
isInScheduleByDate: isInScheduleByDate
|
|
977
998
|
})) {
|
|
978
|
-
var
|
|
999
|
+
var _ref15, _bundleItem$bundle_se3;
|
|
979
1000
|
var _mainQuantity = item.num || 1;
|
|
980
1001
|
matchedItems.push({
|
|
981
1002
|
isMain: false,
|
|
982
|
-
total: Number((
|
|
1003
|
+
total: Number((_ref15 = (_bundleItem$bundle_se3 = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se3 !== void 0 ? _bundleItem$bundle_se3 : bundleItem.price) !== null && _ref15 !== void 0 ? _ref15 : 0),
|
|
983
1004
|
quantity: bundleItem.num || bundleItem.quantity || 1,
|
|
984
1005
|
item: bundleItem,
|
|
985
1006
|
mainQuantity: _mainQuantity // 子商品的mainQuantity是所属主商品的quantity
|
|
@@ -1195,9 +1216,9 @@ export var getSurcharge = function getSurcharge(_ref13, options) {
|
|
|
1195
1216
|
}
|
|
1196
1217
|
return surchargeWithAmount;
|
|
1197
1218
|
};
|
|
1198
|
-
function resetItemsSurchargeSideEffects(
|
|
1199
|
-
var service =
|
|
1200
|
-
addons =
|
|
1219
|
+
function resetItemsSurchargeSideEffects(_ref16) {
|
|
1220
|
+
var service = _ref16.service,
|
|
1221
|
+
addons = _ref16.addons;
|
|
1201
1222
|
var resetItem = function resetItem(item) {
|
|
1202
1223
|
if (!item) return;
|
|
1203
1224
|
item.surcharge_fee = 0;
|
package/dist/modules/index.d.ts
CHANGED
package/dist/modules/index.js
CHANGED
package/dist/plugins/window.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { ITime } from '../../modules/Date/types';
|
|
|
10
10
|
import dayjs from 'dayjs';
|
|
11
11
|
import { LoadScheduleAvailableDateParams } from '../../modules/Schedule/types';
|
|
12
12
|
import { IHolder, IFetchHolderAccountsParams } from '../../modules/AccountList/types';
|
|
13
|
+
import { IAppendFormRecordParams } from '../../modules/Holder/types';
|
|
13
14
|
export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
14
15
|
protected defaultName: string;
|
|
15
16
|
protected defaultVersion: string;
|
|
@@ -126,6 +127,20 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
126
127
|
* @param params
|
|
127
128
|
*/
|
|
128
129
|
fetchHolderAccountsAsync(params: IFetchHolderAccountsParams): Promise<void>;
|
|
130
|
+
/**
|
|
131
|
+
* 获取 holder 表单 map
|
|
132
|
+
*/
|
|
133
|
+
getHolderFormMap(): import("../../modules").HolderFormMap;
|
|
134
|
+
/**
|
|
135
|
+
* 登录后或外部触发时,按当前 holderMap 批量刷新所有表单的 records
|
|
136
|
+
*/
|
|
137
|
+
refreshAllHolderFormRecords(params?: {
|
|
138
|
+
customer_id?: number;
|
|
139
|
+
}): Promise<import("../../modules").HolderFormMap>;
|
|
140
|
+
/**
|
|
141
|
+
* 添加表单记录
|
|
142
|
+
*/
|
|
143
|
+
appendFormRecord(params: IAppendFormRecordParams): import("../../modules").IFormRecord;
|
|
129
144
|
setDateRange(dateRange: ITime[]): Promise<void>;
|
|
130
145
|
clearDateRange(): void;
|
|
131
146
|
getDateRange(): Promise<ITime[]>;
|
|
@@ -310,7 +325,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
310
325
|
date: string;
|
|
311
326
|
status: string;
|
|
312
327
|
week: string;
|
|
313
|
-
weekNum: 0 |
|
|
328
|
+
weekNum: 0 | 5 | 1 | 4 | 2 | 3 | 6;
|
|
314
329
|
}[]>;
|
|
315
330
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
316
331
|
private getScheduleDataByIds;
|