@pisell/pisellos 2.2.162 → 2.2.164
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/BookingContext/index.d.ts +37 -0
- package/dist/modules/BookingContext/index.js +436 -0
- package/dist/modules/BookingContext/types.d.ts +102 -0
- package/dist/modules/BookingContext/types.js +51 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +157 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +107 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +65 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +191 -0
- package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/dist/modules/BookingContext/utils/flexible.js +56 -0
- package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/dist/modules/BookingContext/utils/formatResourceList.js +38 -0
- package/dist/modules/BookingContext/utils/index.d.ts +11 -0
- package/dist/modules/BookingContext/utils/index.js +11 -0
- package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/dist/modules/BookingContext/utils/noResource.js +77 -0
- package/dist/modules/BookingContext/utils/productExtend.d.ts +72 -0
- package/dist/modules/BookingContext/utils/productExtend.js +339 -0
- package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/dist/modules/BookingContext/utils/resourceErrors.js +74 -0
- package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/dist/modules/BookingContext/utils/resourceSelection.js +24 -0
- package/dist/modules/BookingContext/utils/resources.d.ts +80 -0
- package/dist/modules/BookingContext/utils/resources.js +486 -0
- package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/dist/modules/BookingContext/utils/serviceTimes.js +151 -0
- package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/dist/modules/BookingContext/utils/timeSlices.js +100 -0
- package/dist/modules/Customer/index.js +23 -22
- package/dist/modules/Discount/index.js +4 -3
- package/dist/modules/Order/index.d.ts +17 -6
- package/dist/modules/Order/index.js +474 -287
- package/dist/modules/Order/types.d.ts +32 -12
- package/dist/modules/Order/utils.js +9 -8
- package/dist/modules/SalesSummary/index.js +4 -2
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +2 -1
- package/dist/solution/BaseSales/index.d.ts +38 -7
- package/dist/solution/BaseSales/index.js +797 -310
- package/dist/solution/BaseSales/types.d.ts +48 -1
- package/dist/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
- package/dist/solution/BaseSales/utils/quotationPrice.js +159 -0
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingTicket/index.d.ts +121 -1
- package/dist/solution/BookingTicket/index.js +401 -72
- package/dist/solution/BookingTicket/types.d.ts +2 -0
- package/dist/solution/BookingTicket/types.js +3 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +111 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.js +326 -0
- package/dist/solution/ScanOrder/index.d.ts +9 -3
- package/dist/solution/ScanOrder/index.js +231 -128
- package/dist/solution/VenueBooking/index.d.ts +4 -2
- package/dist/solution/VenueBooking/index.js +103 -55
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +10 -0
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/BookingContext/index.d.ts +37 -0
- package/lib/modules/BookingContext/index.js +297 -0
- package/lib/modules/BookingContext/types.d.ts +102 -0
- package/lib/modules/BookingContext/types.js +34 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +174 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +115 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +65 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +177 -0
- package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/lib/modules/BookingContext/utils/flexible.js +80 -0
- package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/lib/modules/BookingContext/utils/formatResourceList.js +50 -0
- package/lib/modules/BookingContext/utils/index.d.ts +11 -0
- package/lib/modules/BookingContext/utils/index.js +43 -0
- package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/lib/modules/BookingContext/utils/noResource.js +90 -0
- package/lib/modules/BookingContext/utils/productExtend.d.ts +72 -0
- package/lib/modules/BookingContext/utils/productExtend.js +283 -0
- package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/lib/modules/BookingContext/utils/resourceErrors.js +80 -0
- package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/lib/modules/BookingContext/utils/resourceSelection.js +46 -0
- package/lib/modules/BookingContext/utils/resources.d.ts +80 -0
- package/lib/modules/BookingContext/utils/resources.js +377 -0
- package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/lib/modules/BookingContext/utils/serviceTimes.js +162 -0
- package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/lib/modules/BookingContext/utils/timeSlices.js +124 -0
- package/lib/modules/Customer/index.js +8 -8
- package/lib/modules/Discount/index.js +5 -1
- package/lib/modules/Order/index.d.ts +17 -6
- package/lib/modules/Order/index.js +164 -68
- package/lib/modules/Order/types.d.ts +32 -12
- package/lib/modules/Order/utils.js +8 -6
- package/lib/modules/SalesSummary/index.js +4 -2
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +3 -1
- package/lib/solution/BaseSales/index.d.ts +38 -7
- package/lib/solution/BaseSales/index.js +304 -14
- package/lib/solution/BaseSales/types.d.ts +48 -1
- package/lib/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
- package/lib/solution/BaseSales/utils/quotationPrice.js +201 -0
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingTicket/index.d.ts +121 -1
- package/lib/solution/BookingTicket/index.js +207 -2
- package/lib/solution/BookingTicket/types.d.ts +2 -0
- package/lib/solution/BookingTicket/types.js +6 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +111 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.js +300 -0
- package/lib/solution/ScanOrder/index.d.ts +9 -3
- package/lib/solution/ScanOrder/index.js +147 -66
- package/lib/solution/VenueBooking/index.d.ts +4 -2
- package/lib/solution/VenueBooking/index.js +50 -14
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +10 -0
- package/package.json +1 -1
|
@@ -40,7 +40,9 @@ 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_Quotation = require("../../modules/Quotation");
|
|
43
44
|
var import_transformBaseProductToOrderProduct = require("./utils/transformBaseProductToOrderProduct");
|
|
45
|
+
var import_quotationPrice = require("./utils/quotationPrice");
|
|
44
46
|
var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
45
47
|
constructor(name, version) {
|
|
46
48
|
super(name, version);
|
|
@@ -48,7 +50,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
48
50
|
this.defaultVersion = "1.0.0";
|
|
49
51
|
this.isSolution = true;
|
|
50
52
|
this.initializeOptions = {};
|
|
51
|
-
// LoggerManager 实例
|
|
52
53
|
this.store = {
|
|
53
54
|
order: void 0
|
|
54
55
|
};
|
|
@@ -58,10 +59,10 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
58
59
|
}
|
|
59
60
|
/**
|
|
60
61
|
* 子类可覆盖此方法以追加/收敛要注册的子模块。
|
|
61
|
-
* 默认包含通用销售模块:products / order / salesSummary / schedule / payment。
|
|
62
|
+
* 默认包含通用销售模块:products / order / salesSummary / schedule / payment / quotation。
|
|
62
63
|
*/
|
|
63
64
|
getRegisteredModuleNames() {
|
|
64
|
-
return ["products", "order", "salesSummary", "schedule", "payment"];
|
|
65
|
+
return ["products", "order", "salesSummary", "schedule", "payment", "quotation"];
|
|
65
66
|
}
|
|
66
67
|
/**
|
|
67
68
|
* 记录信息日志
|
|
@@ -105,12 +106,47 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
105
106
|
get payment() {
|
|
106
107
|
return this.store.payment;
|
|
107
108
|
}
|
|
109
|
+
getCurrentOrderCustomerId() {
|
|
110
|
+
var _a, _b;
|
|
111
|
+
const tempOrder = (_b = (_a = this.store.order) == null ? void 0 : _a.getTempOrder) == null ? void 0 : _b.call(_a);
|
|
112
|
+
const customerId = tempOrder == null ? void 0 : tempOrder.customer_id;
|
|
113
|
+
if (customerId === null || customerId === void 0)
|
|
114
|
+
return void 0;
|
|
115
|
+
return customerId;
|
|
116
|
+
}
|
|
117
|
+
applyQuotationScheduleResolver(quotation) {
|
|
118
|
+
const scheduleModule = this.store.schedule;
|
|
119
|
+
if (!scheduleModule)
|
|
120
|
+
return;
|
|
121
|
+
quotation.setScheduleResolver((id) => {
|
|
122
|
+
var _a;
|
|
123
|
+
const schedules = ((_a = scheduleModule.getScheduleListByIds) == null ? void 0 : _a.call(scheduleModule, [id])) || [];
|
|
124
|
+
return schedules[0];
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
async loadQuotationForPriceQuery(params) {
|
|
128
|
+
var _a;
|
|
129
|
+
if (!params.quotation)
|
|
130
|
+
return;
|
|
131
|
+
this.applyQuotationScheduleResolver(params.quotation);
|
|
132
|
+
await params.quotation.loadQuotations({
|
|
133
|
+
channel: params.channel || ((_a = this.otherParams) == null ? void 0 : _a.channel),
|
|
134
|
+
customer_id: params.customer_id
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
getSubmitOrderSalesChannel() {
|
|
138
|
+
var _a;
|
|
139
|
+
return (_a = this.otherParams) == null ? void 0 : _a.channel;
|
|
140
|
+
}
|
|
108
141
|
/**
|
|
109
142
|
* 工厂入口:根据子模块名实例化对应模块。
|
|
110
143
|
* 默认使用 BookingByStep 公共 `createModule`。子类若需引入额外类型(如 customer),
|
|
111
144
|
* 可覆盖此方法并把未识别的 name 委托给 `super.createSubModule(name)`。
|
|
112
145
|
*/
|
|
113
146
|
createSubModule(moduleName) {
|
|
147
|
+
if (moduleName === "quotation") {
|
|
148
|
+
return new import_Quotation.QuotationModule(`${this.name}_quotation`);
|
|
149
|
+
}
|
|
114
150
|
return (0, import_types.createModule)(moduleName, this.name);
|
|
115
151
|
}
|
|
116
152
|
getSubModuleHooks(moduleName) {
|
|
@@ -140,6 +176,43 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
140
176
|
return {};
|
|
141
177
|
}
|
|
142
178
|
}
|
|
179
|
+
getAppData(key) {
|
|
180
|
+
var _a, _b, _c, _d, _e, _f;
|
|
181
|
+
const getData = (_b = (_a = this.appPlugin).getData) == null ? void 0 : _b.call(_a);
|
|
182
|
+
if (typeof getData === "function")
|
|
183
|
+
return getData(key);
|
|
184
|
+
const app = this.appPlugin.getApp();
|
|
185
|
+
const coreData = (_f = (_d = (_c = app == null ? void 0 : app.models) == null ? void 0 : _c.getStore) == null ? void 0 : (_e = _d.call(_c)).getDataByModel) == null ? void 0 : _f.call(_e, "core", "core");
|
|
186
|
+
return coreData == null ? void 0 : coreData[key];
|
|
187
|
+
}
|
|
188
|
+
syncAppDataToTempOrder(tempOrder) {
|
|
189
|
+
const taxCountryCode = this.getAppData("tax_country_code");
|
|
190
|
+
const currencyCode = this.getAppData("shop_currency_code");
|
|
191
|
+
const currencySymbol = this.getAppData("shop_symbol");
|
|
192
|
+
let isChanged = false;
|
|
193
|
+
if (taxCountryCode !== void 0) {
|
|
194
|
+
const nextTaxCountryCode = String(taxCountryCode || "");
|
|
195
|
+
if (tempOrder.tax_country_code !== nextTaxCountryCode) {
|
|
196
|
+
tempOrder.tax_country_code = nextTaxCountryCode;
|
|
197
|
+
isChanged = true;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (currencyCode !== void 0) {
|
|
201
|
+
const nextCurrencyCode = String(currencyCode || "");
|
|
202
|
+
if (tempOrder.currency_code !== nextCurrencyCode) {
|
|
203
|
+
tempOrder.currency_code = nextCurrencyCode;
|
|
204
|
+
isChanged = true;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (currencySymbol !== void 0) {
|
|
208
|
+
const nextCurrencySymbol = String(currencySymbol || "");
|
|
209
|
+
if (tempOrder.currency_symbol !== nextCurrencySymbol) {
|
|
210
|
+
tempOrder.currency_symbol = nextCurrencySymbol;
|
|
211
|
+
isChanged = true;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return isChanged;
|
|
215
|
+
}
|
|
143
216
|
async initialize(core, options = {}) {
|
|
144
217
|
var _a;
|
|
145
218
|
this.core = core;
|
|
@@ -148,11 +221,11 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
148
221
|
this.cacheId = (_a = this.otherParams) == null ? void 0 : _a.cacheId;
|
|
149
222
|
this.window = core.getPlugin("window");
|
|
150
223
|
this.request = core.getPlugin("request");
|
|
151
|
-
|
|
152
|
-
if (!appPlugin) {
|
|
224
|
+
this.appPlugin = core.getPlugin("app");
|
|
225
|
+
if (!this.appPlugin) {
|
|
153
226
|
throw new Error("Checkout 解决方案需要 app 插件支持");
|
|
154
227
|
}
|
|
155
|
-
const app = appPlugin.getApp();
|
|
228
|
+
const app = this.appPlugin.getApp();
|
|
156
229
|
this.logger = app.logger;
|
|
157
230
|
const targetCacheData = this.readSessionCacheData();
|
|
158
231
|
const moduleNames = this.getRegisteredModuleNames();
|
|
@@ -286,6 +359,13 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
286
359
|
const result = ((_a = this.store.order) == null ? void 0 : _a.getTempOrder()) || null;
|
|
287
360
|
return result;
|
|
288
361
|
}
|
|
362
|
+
async replaceTempOrder(tempOrder) {
|
|
363
|
+
if (!this.store.order)
|
|
364
|
+
throw new Error("order 模块未初始化");
|
|
365
|
+
const nextTempOrder = await this.store.order.replaceTempOrder(tempOrder);
|
|
366
|
+
await this.effectsEmit("onTempOrderReplaced", { tempOrder: nextTempOrder });
|
|
367
|
+
return nextTempOrder;
|
|
368
|
+
}
|
|
289
369
|
getOrderIdentity() {
|
|
290
370
|
if (!this.store.order)
|
|
291
371
|
return null;
|
|
@@ -311,11 +391,11 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
311
391
|
return "";
|
|
312
392
|
return this.store.order.getTempOrderNote();
|
|
313
393
|
}
|
|
314
|
-
updateTempOrderNote(note) {
|
|
394
|
+
updateTempOrderNote(note, sync = false) {
|
|
315
395
|
try {
|
|
316
396
|
if (!this.store.order)
|
|
317
397
|
throw new Error("order 模块未初始化");
|
|
318
|
-
const result = this.store.order.updateTempOrderNote(note);
|
|
398
|
+
const result = this.store.order.updateTempOrderNote(note, sync);
|
|
319
399
|
return result;
|
|
320
400
|
} catch (error) {
|
|
321
401
|
throw error;
|
|
@@ -342,6 +422,10 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
342
422
|
if (!this.store.order)
|
|
343
423
|
throw new Error("order 模块未初始化");
|
|
344
424
|
const tempOrder = await this.store.order.addNewOrder();
|
|
425
|
+
if (this.syncAppDataToTempOrder(tempOrder)) {
|
|
426
|
+
this.store.order.persistTempOrder();
|
|
427
|
+
await this.store.order.saveDraft();
|
|
428
|
+
}
|
|
345
429
|
return tempOrder;
|
|
346
430
|
} catch (error) {
|
|
347
431
|
throw error;
|
|
@@ -360,6 +444,10 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
360
444
|
throw new Error("scanOrder 解决方案需要 order 模块支持");
|
|
361
445
|
}
|
|
362
446
|
const tempOrder = this.store.order.restoreOrder();
|
|
447
|
+
if (this.syncAppDataToTempOrder(tempOrder)) {
|
|
448
|
+
this.store.order.persistTempOrder();
|
|
449
|
+
await this.store.order.saveDraft();
|
|
450
|
+
}
|
|
363
451
|
return tempOrder;
|
|
364
452
|
} catch (error) {
|
|
365
453
|
throw error;
|
|
@@ -381,6 +469,155 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
381
469
|
throw error;
|
|
382
470
|
}
|
|
383
471
|
}
|
|
472
|
+
getHistoricalProductDiscountList(products) {
|
|
473
|
+
const historyDiscountList = [];
|
|
474
|
+
products.forEach((item) => {
|
|
475
|
+
(item.discount_list || []).forEach((discount) => {
|
|
476
|
+
var _a, _b, _c, _d, _e, _f;
|
|
477
|
+
const discountId = ((_a = discount.discount) == null ? void 0 : _a.resource_id) || discount.id;
|
|
478
|
+
if (!discountId || !["good_pass", "discount_card"].includes(discount.type))
|
|
479
|
+
return;
|
|
480
|
+
const quantity = item.quantity || item.num || item.product_quantity || 1;
|
|
481
|
+
const savedAmount = new import_decimal.default(discount.amount || 0).times(quantity).plus(((_b = discount == null ? void 0 : discount.metadata) == null ? void 0 : _b.product_discount_difference) || 0);
|
|
482
|
+
const index = historyDiscountList.findIndex((n) => n.id === discountId);
|
|
483
|
+
if (index !== -1) {
|
|
484
|
+
historyDiscountList[index] = {
|
|
485
|
+
...historyDiscountList[index],
|
|
486
|
+
amount: new import_decimal.default(historyDiscountList[index].amount || 0).plus(discount.amount || 0).toNumber(),
|
|
487
|
+
savedAmount: savedAmount.plus(historyDiscountList[index].savedAmount || 0).toNumber()
|
|
488
|
+
};
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
historyDiscountList.push({
|
|
492
|
+
...discount,
|
|
493
|
+
id: discountId,
|
|
494
|
+
tag: discount.tag || discount.type,
|
|
495
|
+
name: discount.name || ((_d = (_c = discount.discount) == null ? void 0 : _c.title) == null ? void 0 : _d.auto),
|
|
496
|
+
format_title: ((_e = discount.discount) == null ? void 0 : _e.title) || discount.format_title,
|
|
497
|
+
isEditMode: true,
|
|
498
|
+
limited_relation_product_data: {},
|
|
499
|
+
savedAmount: savedAmount.toNumber(),
|
|
500
|
+
isAvailable: true,
|
|
501
|
+
isDisabled: true,
|
|
502
|
+
isSelected: true,
|
|
503
|
+
product_id: ((_f = discount.discount) == null ? void 0 : _f.product_id) || discount.product_id
|
|
504
|
+
});
|
|
505
|
+
});
|
|
506
|
+
});
|
|
507
|
+
return historyDiscountList;
|
|
508
|
+
}
|
|
509
|
+
mergeHistoricalDiscountList(discountList, products) {
|
|
510
|
+
const historyDiscountList = this.getHistoricalProductDiscountList(products);
|
|
511
|
+
const historyIds = new Set(historyDiscountList.map((discount) => discount.id));
|
|
512
|
+
return [
|
|
513
|
+
...historyDiscountList,
|
|
514
|
+
...(discountList || []).filter((discount) => !historyIds.has(discount.id))
|
|
515
|
+
];
|
|
516
|
+
}
|
|
517
|
+
async loadDiscountConfig(params) {
|
|
518
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
519
|
+
if (!this.store.order)
|
|
520
|
+
throw new Error("order 模块未初始化");
|
|
521
|
+
const tempOrder = this.store.order.ensureTempOrder();
|
|
522
|
+
const orderStore = this.store.order.store || {};
|
|
523
|
+
const discountModule = orderStore.discount;
|
|
524
|
+
const rulesModule = orderStore.rules;
|
|
525
|
+
const orderId = tempOrder.order_id || ((_b = (_a = this.getOrderIdentity) == null ? void 0 : _a.call(this)) == null ? void 0 : _b.orderId);
|
|
526
|
+
const customerId = Number(
|
|
527
|
+
(params == null ? void 0 : params.customerId) || tempOrder.customer_id || ((_c = tempOrder.customer) == null ? void 0 : _c.id) || ((_e = (_d = tempOrder._extend) == null ? void 0 : _d.customerSnapshot) == null ? void 0 : _e.id) || ((_g = (_f = tempOrder._extend) == null ? void 0 : _f.customerSnapshot) == null ? void 0 : _g.customer_id) || 0
|
|
528
|
+
);
|
|
529
|
+
let preparedDiscountList = [];
|
|
530
|
+
if (customerId && customerId !== 1) {
|
|
531
|
+
preparedDiscountList = await this.store.order.loadDiscountConfig({
|
|
532
|
+
customerId,
|
|
533
|
+
action: (params == null ? void 0 : params.action) || (orderId ? "edit" : "create"),
|
|
534
|
+
orderId: Number(orderId) || void 0,
|
|
535
|
+
apply: false
|
|
536
|
+
});
|
|
537
|
+
await ((_h = discountModule == null ? void 0 : discountModule.setOriginalDiscountList) == null ? void 0 : _h.call(discountModule, preparedDiscountList));
|
|
538
|
+
}
|
|
539
|
+
let nextDiscountList = this.mergeHistoricalDiscountList(
|
|
540
|
+
preparedDiscountList || ((_i = discountModule == null ? void 0 : discountModule.getDiscountList) == null ? void 0 : _i.call(discountModule)) || [],
|
|
541
|
+
tempOrder.products || []
|
|
542
|
+
);
|
|
543
|
+
await (discountModule == null ? void 0 : discountModule.setDiscountList(nextDiscountList));
|
|
544
|
+
if (rulesModule) {
|
|
545
|
+
const holders = ((_j = tempOrder.holder) == null ? void 0 : _j.form_record_id) ? [{ form_record_id: tempOrder.holder.form_record_id }] : [];
|
|
546
|
+
const result = rulesModule.calcDiscount({
|
|
547
|
+
productList: tempOrder.products,
|
|
548
|
+
discountList: nextDiscountList,
|
|
549
|
+
holders,
|
|
550
|
+
isFormSubject: !!((_k = tempOrder.holder) == null ? void 0 : _k.type) && tempOrder.holder.type === "form",
|
|
551
|
+
orderTotalAmount: Number(((_l = orderStore.summary) == null ? void 0 : _l.total_amount) || 0)
|
|
552
|
+
}) || { productList: tempOrder.products, discountList: nextDiscountList };
|
|
553
|
+
if (result.productList) {
|
|
554
|
+
tempOrder.products = result.productList;
|
|
555
|
+
}
|
|
556
|
+
if (result.discountList) {
|
|
557
|
+
nextDiscountList = this.mergeHistoricalDiscountList(
|
|
558
|
+
result.discountList,
|
|
559
|
+
tempOrder.products || []
|
|
560
|
+
);
|
|
561
|
+
import_Order.OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
562
|
+
await (discountModule == null ? void 0 : discountModule.setDiscountList(nextDiscountList));
|
|
563
|
+
tempOrder.discount_list = nextDiscountList.filter((discount) => discount.isSelected);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
this.store.order.persistTempOrder();
|
|
567
|
+
return {
|
|
568
|
+
productList: tempOrder.products || [],
|
|
569
|
+
discountList: nextDiscountList
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
async bestDiscount(cb) {
|
|
573
|
+
var _a, _b, _c, _d;
|
|
574
|
+
if (!this.store.order)
|
|
575
|
+
throw new Error("order 模块未初始化");
|
|
576
|
+
const tempOrder = this.store.order.ensureTempOrder();
|
|
577
|
+
const orderStore = this.store.order.store || {};
|
|
578
|
+
const discountModule = orderStore.discount;
|
|
579
|
+
const rulesModule = orderStore.rules;
|
|
580
|
+
const originalDiscountList = ((_a = discountModule == null ? void 0 : discountModule.getOriginalDiscountList) == null ? void 0 : _a.call(discountModule)) || this.getDiscountList();
|
|
581
|
+
let nextDiscountList = this.mergeHistoricalDiscountList(
|
|
582
|
+
originalDiscountList || [],
|
|
583
|
+
tempOrder.products || []
|
|
584
|
+
);
|
|
585
|
+
let result = {
|
|
586
|
+
productList: tempOrder.products || [],
|
|
587
|
+
discountList: nextDiscountList
|
|
588
|
+
};
|
|
589
|
+
await (discountModule == null ? void 0 : discountModule.setDiscountList(nextDiscountList));
|
|
590
|
+
if (rulesModule) {
|
|
591
|
+
const holders = ((_b = tempOrder.holder) == null ? void 0 : _b.form_record_id) ? [{ form_record_id: tempOrder.holder.form_record_id }] : [];
|
|
592
|
+
result = rulesModule.calcDiscount({
|
|
593
|
+
productList: tempOrder.products,
|
|
594
|
+
discountList: nextDiscountList,
|
|
595
|
+
holders,
|
|
596
|
+
isFormSubject: !!((_c = tempOrder.holder) == null ? void 0 : _c.type) && tempOrder.holder.type === "form",
|
|
597
|
+
orderTotalAmount: Number(((_d = orderStore.summary) == null ? void 0 : _d.total_amount) || 0)
|
|
598
|
+
}) || result;
|
|
599
|
+
if (result.productList) {
|
|
600
|
+
tempOrder.products = result.productList;
|
|
601
|
+
}
|
|
602
|
+
if (result.discountList) {
|
|
603
|
+
nextDiscountList = this.mergeHistoricalDiscountList(
|
|
604
|
+
result.discountList,
|
|
605
|
+
tempOrder.products || []
|
|
606
|
+
);
|
|
607
|
+
import_Order.OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
608
|
+
await (discountModule == null ? void 0 : discountModule.setDiscountList(nextDiscountList));
|
|
609
|
+
tempOrder.discount_list = nextDiscountList.filter((discount) => discount.isSelected);
|
|
610
|
+
result = {
|
|
611
|
+
productList: tempOrder.products,
|
|
612
|
+
discountList: nextDiscountList
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
617
|
+
this.store.order.persistTempOrder();
|
|
618
|
+
cb == null ? void 0 : cb(result);
|
|
619
|
+
return result;
|
|
620
|
+
}
|
|
384
621
|
getDiscountList() {
|
|
385
622
|
if (!this.store.order)
|
|
386
623
|
return [];
|
|
@@ -494,6 +731,34 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
494
731
|
throw error;
|
|
495
732
|
}
|
|
496
733
|
}
|
|
734
|
+
async applyDiscountCalculationResult(result) {
|
|
735
|
+
try {
|
|
736
|
+
if (!this.store.order)
|
|
737
|
+
throw new Error("order 模块未初始化");
|
|
738
|
+
if (!result)
|
|
739
|
+
return;
|
|
740
|
+
const tempOrder = this.store.order.ensureTempOrder();
|
|
741
|
+
const orderStore = this.store.order.store || {};
|
|
742
|
+
const discountModule = orderStore.discount;
|
|
743
|
+
if (result.productList) {
|
|
744
|
+
tempOrder.products = result.productList;
|
|
745
|
+
}
|
|
746
|
+
if (result.discountList) {
|
|
747
|
+
import_Order.OrderModule.populateSavedAmounts(
|
|
748
|
+
tempOrder.products,
|
|
749
|
+
result.discountList
|
|
750
|
+
);
|
|
751
|
+
await (discountModule == null ? void 0 : discountModule.setDiscountList(result.discountList));
|
|
752
|
+
tempOrder.discount_list = result.discountList.filter(
|
|
753
|
+
(discount) => discount.isSelected
|
|
754
|
+
);
|
|
755
|
+
}
|
|
756
|
+
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
757
|
+
this.store.order.persistTempOrder();
|
|
758
|
+
} catch (error) {
|
|
759
|
+
throw error;
|
|
760
|
+
}
|
|
761
|
+
}
|
|
497
762
|
async submitScanOrder(params) {
|
|
498
763
|
return this.submitSalesOrder(params);
|
|
499
764
|
}
|
|
@@ -504,7 +769,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
504
769
|
* payments 会交给 OrderModule 统一映射为 Sales 协议支付项。
|
|
505
770
|
*/
|
|
506
771
|
async submitSalesOrder(params) {
|
|
507
|
-
var _a, _b, _c
|
|
772
|
+
var _a, _b, _c;
|
|
508
773
|
if (!this.store.order) {
|
|
509
774
|
throw new Error("BaseSales 解决方案需要 order 模块支持");
|
|
510
775
|
}
|
|
@@ -513,13 +778,14 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
513
778
|
cacheId: this.cacheId,
|
|
514
779
|
platform: (_a = this.otherParams) == null ? void 0 : _a.platform,
|
|
515
780
|
businessCode: (_b = this.otherParams) == null ? void 0 : _b.businessCode,
|
|
516
|
-
channel:
|
|
517
|
-
type: (
|
|
781
|
+
channel: this.getSubmitOrderSalesChannel(),
|
|
782
|
+
type: (_c = this.otherParams) == null ? void 0 : _c.type,
|
|
518
783
|
...(params == null ? void 0 : params.payments) !== void 0 ? { payments: params.payments } : {},
|
|
519
784
|
...(params == null ? void 0 : params.paymentStatus) !== void 0 ? { paymentStatus: params.paymentStatus } : {},
|
|
520
785
|
...(params == null ? void 0 : params.smallTicketDataFlag) !== void 0 ? { smallTicketDataFlag: params.smallTicketDataFlag } : {},
|
|
521
786
|
...(params == null ? void 0 : params.enhancePayload) !== void 0 ? { enhancePayload: params.enhancePayload } : {}
|
|
522
787
|
};
|
|
788
|
+
console.log(submitParams, "submitParams123");
|
|
523
789
|
return this.store.order.submitTempOrder(submitParams);
|
|
524
790
|
}
|
|
525
791
|
async syncPaymentsToOrder(params) {
|
|
@@ -578,6 +844,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
578
844
|
is_charge_tax: product.is_charge_tax ?? 0,
|
|
579
845
|
tax_fee: product.tax_fee,
|
|
580
846
|
selling_price: Number(product.selling_price || 0),
|
|
847
|
+
discount_list: product.discount_list || [],
|
|
581
848
|
holder_id: product.holder_id ?? metadata.holder_id,
|
|
582
849
|
original_price: product.original_price,
|
|
583
850
|
main_product_original_price: metadata.main_product_original_price ?? product.original_price,
|
|
@@ -731,6 +998,20 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
731
998
|
transformBaseProductToOrderProduct(params) {
|
|
732
999
|
return (0, import_transformBaseProductToOrderProduct.transformBaseProductToOrderProduct)(params);
|
|
733
1000
|
}
|
|
1001
|
+
async calculateProductBookingPrice(params) {
|
|
1002
|
+
const quotation = this.store.quotation;
|
|
1003
|
+
const customerId = params.customer_id ?? this.getCurrentOrderCustomerId();
|
|
1004
|
+
await this.loadQuotationForPriceQuery({
|
|
1005
|
+
quotation,
|
|
1006
|
+
customer_id: customerId,
|
|
1007
|
+
channel: params.channel
|
|
1008
|
+
});
|
|
1009
|
+
return (0, import_quotationPrice.calculateBaseSalesProductBookingPrice)({
|
|
1010
|
+
...params,
|
|
1011
|
+
customer_id: customerId,
|
|
1012
|
+
quotation
|
|
1013
|
+
});
|
|
1014
|
+
}
|
|
734
1015
|
async addProductToOrder(product, booking) {
|
|
735
1016
|
try {
|
|
736
1017
|
if (!this.store.order)
|
|
@@ -741,16 +1022,25 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
741
1022
|
throw error;
|
|
742
1023
|
}
|
|
743
1024
|
}
|
|
744
|
-
async
|
|
1025
|
+
async updateOrderProduct(params) {
|
|
745
1026
|
try {
|
|
746
1027
|
if (!this.store.order)
|
|
747
1028
|
throw new Error("order 模块未初始化");
|
|
748
|
-
const products = await this.store.order.
|
|
1029
|
+
const products = await this.store.order.updateOrderProduct(params);
|
|
749
1030
|
return products;
|
|
750
1031
|
} catch (error) {
|
|
751
1032
|
throw error;
|
|
752
1033
|
}
|
|
753
1034
|
}
|
|
1035
|
+
updateOrderBooking(params) {
|
|
1036
|
+
try {
|
|
1037
|
+
if (!this.store.order)
|
|
1038
|
+
throw new Error("order 模块未初始化");
|
|
1039
|
+
return this.store.order.updateOrderBooking(params);
|
|
1040
|
+
} catch (error) {
|
|
1041
|
+
throw error;
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
754
1044
|
/**
|
|
755
1045
|
* 设置单行商品备注(与整单 `updateTempOrderNote` 区分)。
|
|
756
1046
|
* 多行同 SKU 时必须传入与删除/更新一致的 unique_identification_number。
|
|
@@ -770,7 +1060,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
770
1060
|
}
|
|
771
1061
|
if (identity.product_bundle !== void 0)
|
|
772
1062
|
params.product_bundle = identity.product_bundle;
|
|
773
|
-
const products = await this.
|
|
1063
|
+
const products = await this.updateOrderProduct(params);
|
|
774
1064
|
return products;
|
|
775
1065
|
} catch (error) {
|
|
776
1066
|
throw error;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OrderModule, ProductList, SalesSummaryModule, ScanOrderLoggerModule as BaseSalesLoggerModule, ScheduleModule } from '../../modules';
|
|
1
|
+
import { OrderModule, ProductList, QuotationModule, SalesSummaryModule, ScanOrderLoggerModule as BaseSalesLoggerModule, ScheduleModule } from '../../modules';
|
|
2
2
|
import type { ScanOrderLogInput as BaseSalesLogInput, ScanOrderLoggerProviderConfig as BaseSalesLoggerProviderConfig, ScanOrderLoggerProviderType as BaseSalesLoggerProviderType } from '../../modules/ScanOrderLogger/types';
|
|
3
3
|
import type { QuantityCheckResult, QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
|
|
4
4
|
/**
|
|
@@ -203,6 +203,52 @@ export interface BaseSalesSubmitPayload extends Omit<BaseSalesTempOrder, 'platfo
|
|
|
203
203
|
}>;
|
|
204
204
|
products: BaseSalesSubmitProduct[];
|
|
205
205
|
}
|
|
206
|
+
export interface BaseSalesQuotationDurationConfig {
|
|
207
|
+
type: string;
|
|
208
|
+
value: number;
|
|
209
|
+
flexible_config?: {
|
|
210
|
+
is_enable_minimum_duration?: 0 | 1;
|
|
211
|
+
warning_threshold?: number;
|
|
212
|
+
block_threshold?: number;
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
export interface BaseSalesCalculateProductBookingPriceParams {
|
|
216
|
+
product: Record<string, any>;
|
|
217
|
+
booking?: {
|
|
218
|
+
start_date?: string;
|
|
219
|
+
start_time?: string;
|
|
220
|
+
end_date?: string;
|
|
221
|
+
end_time?: string;
|
|
222
|
+
[key: string]: any;
|
|
223
|
+
};
|
|
224
|
+
duration?: BaseSalesQuotationDurationConfig;
|
|
225
|
+
customer_id?: number | string;
|
|
226
|
+
fallback_price?: number | string;
|
|
227
|
+
datetime?: string;
|
|
228
|
+
channel?: string;
|
|
229
|
+
}
|
|
230
|
+
export type BaseSalesProductBookingPriceSegmentSource = 'quotation' | 'fallback';
|
|
231
|
+
export interface BaseSalesProductBookingPriceSegment {
|
|
232
|
+
start_datetime: string;
|
|
233
|
+
end_datetime?: string;
|
|
234
|
+
time_point: string;
|
|
235
|
+
unit_price: string;
|
|
236
|
+
quantity: number;
|
|
237
|
+
total_price: string;
|
|
238
|
+
quotation_shelf_id: number;
|
|
239
|
+
source: BaseSalesProductBookingPriceSegmentSource;
|
|
240
|
+
}
|
|
241
|
+
export interface BaseSalesProductBookingPriceResult {
|
|
242
|
+
product_id: number | null;
|
|
243
|
+
product_variant_id: number;
|
|
244
|
+
customer_id?: number | string;
|
|
245
|
+
unit_price: string;
|
|
246
|
+
total_price: string;
|
|
247
|
+
quantity: number;
|
|
248
|
+
duration?: BaseSalesQuotationDurationConfig;
|
|
249
|
+
quotation_shelf_id: number;
|
|
250
|
+
segments: BaseSalesProductBookingPriceSegment[];
|
|
251
|
+
}
|
|
206
252
|
export type BaseSalesAvailabilityMode = 'idle' | 'shop_closed' | 'submit_disabled' | 'resource_busy' | 'additional_order_with_code' | 'additional_order';
|
|
207
253
|
export interface BaseSalesTableFormRecord {
|
|
208
254
|
policy?: string | null;
|
|
@@ -281,6 +327,7 @@ export interface BaseSalesState {
|
|
|
281
327
|
error: string | null;
|
|
282
328
|
products?: ProductList;
|
|
283
329
|
order?: OrderModule;
|
|
330
|
+
quotation?: QuotationModule;
|
|
284
331
|
salesSummary?: SalesSummaryModule;
|
|
285
332
|
baseSalesLogger?: BaseSalesLoggerModule;
|
|
286
333
|
schedule?: ScheduleModule;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { QuotationModule } from '../../../modules/Quotation';
|
|
2
|
+
import type { BaseSalesCalculateProductBookingPriceParams, BaseSalesProductBookingPriceResult } from '../types';
|
|
3
|
+
interface BuildBaseSalesQuotationPriceParams extends BaseSalesCalculateProductBookingPriceParams {
|
|
4
|
+
quotation?: Pick<QuotationModule, 'getPriceForProduct' | 'getQuotationShelfId'> | null;
|
|
5
|
+
}
|
|
6
|
+
export declare function calculateBaseSalesProductBookingPrice(params: BuildBaseSalesQuotationPriceParams): BaseSalesProductBookingPriceResult;
|
|
7
|
+
export {};
|