@pisell/pisellos 2.2.171 → 2.2.172
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 +193 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +137 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +75 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +215 -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.d.ts +6 -0
- package/dist/modules/Customer/index.js +129 -83
- package/dist/modules/Customer/types.d.ts +2 -0
- package/dist/modules/Discount/index.d.ts +2 -4
- package/dist/modules/Discount/index.js +8 -93
- package/dist/modules/Discount/types.d.ts +1 -7
- package/dist/modules/Order/index.d.ts +47 -16
- package/dist/modules/Order/index.js +743 -334
- package/dist/modules/Order/types.d.ts +57 -17
- package/dist/modules/Order/types.js +2 -0
- package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/dist/modules/Order/utils/manualProductDiscount.js +212 -0
- package/dist/modules/Order/utils.d.ts +23 -1
- package/dist/modules/Order/utils.js +139 -30
- package/dist/modules/Quotation/index.js +16 -5
- package/dist/modules/Rules/index.d.ts +4 -0
- package/dist/modules/Rules/index.js +26 -10
- package/dist/modules/SalesSummary/index.js +4 -2
- package/dist/modules/Schedule/index.js +6 -2
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +2 -1
- package/dist/server/index.js +10 -6
- package/dist/server/modules/order/utils/filterOrders.js +20 -6
- package/dist/server/modules/products/index.js +9 -8
- package/dist/server/modules/schedule/index.js +13 -6
- package/dist/solution/BaseSales/index.d.ts +65 -7
- package/dist/solution/BaseSales/index.js +1066 -315
- package/dist/solution/BaseSales/types.d.ts +53 -1
- package/dist/solution/BaseSales/types.js +3 -1
- package/dist/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
- package/dist/solution/BaseSales/utils/quotationPrice.js +159 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +65 -15
- package/dist/solution/BaseSales/utils.js +46 -8
- package/dist/solution/BookingTicket/index.d.ts +134 -2
- package/dist/solution/BookingTicket/index.js +768 -175
- 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 +113 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.js +346 -0
- package/dist/solution/ScanOrder/index.d.ts +9 -3
- package/dist/solution/ScanOrder/index.js +231 -128
- package/dist/solution/ScanOrder/utils.js +46 -8
- package/dist/solution/ShopDiscount/index.d.ts +0 -1
- package/dist/solution/ShopDiscount/index.js +18 -23
- package/dist/solution/VenueBooking/index.d.ts +5 -9
- 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/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 +207 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +141 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +75 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +198 -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.d.ts +6 -0
- package/lib/modules/Customer/index.js +26 -11
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Discount/index.d.ts +2 -4
- package/lib/modules/Discount/index.js +8 -63
- package/lib/modules/Discount/types.d.ts +1 -7
- package/lib/modules/Order/index.d.ts +47 -16
- package/lib/modules/Order/index.js +389 -90
- package/lib/modules/Order/types.d.ts +57 -17
- package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/lib/modules/Order/utils/manualProductDiscount.js +207 -0
- package/lib/modules/Order/utils.d.ts +23 -1
- package/lib/modules/Order/utils.js +145 -21
- package/lib/modules/Quotation/index.js +17 -6
- package/lib/modules/Rules/index.d.ts +4 -0
- package/lib/modules/Rules/index.js +22 -14
- package/lib/modules/SalesSummary/index.js +4 -2
- package/lib/modules/Schedule/index.js +3 -1
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +3 -1
- package/lib/server/index.js +2 -0
- package/lib/server/modules/order/utils/filterOrders.js +12 -4
- package/lib/server/modules/products/index.js +8 -9
- package/lib/server/modules/schedule/index.js +2 -1
- package/lib/solution/BaseSales/index.d.ts +65 -7
- package/lib/solution/BaseSales/index.js +492 -20
- package/lib/solution/BaseSales/types.d.ts +53 -1
- package/lib/solution/BaseSales/types.js +3 -1
- package/lib/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
- package/lib/solution/BaseSales/utils/quotationPrice.js +201 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +70 -11
- package/lib/solution/BaseSales/utils.js +46 -6
- package/lib/solution/BookingTicket/index.d.ts +134 -2
- package/lib/solution/BookingTicket/index.js +341 -8
- 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 +113 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.js +318 -0
- package/lib/solution/ScanOrder/index.d.ts +9 -3
- package/lib/solution/ScanOrder/index.js +147 -66
- package/lib/solution/ScanOrder/utils.js +46 -6
- package/lib/solution/ShopDiscount/index.d.ts +0 -1
- package/lib/solution/ShopDiscount/index.js +2 -4
- package/lib/solution/VenueBooking/index.d.ts +5 -9
- 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 +2 -2
|
@@ -34,13 +34,16 @@ __export(BaseSales_exports, {
|
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(BaseSales_exports);
|
|
36
36
|
var import_BaseModule = require("../../modules/BaseModule");
|
|
37
|
+
var import_types = require("./types");
|
|
37
38
|
var import_Order = require("../../modules/Order");
|
|
38
39
|
var import_decimal = __toESM(require("decimal.js"));
|
|
39
|
-
var
|
|
40
|
+
var import_types2 = require("../BookingByStep/types");
|
|
40
41
|
var import_utils = require("../../modules/Order/utils");
|
|
41
42
|
var import_dayjs = __toESM(require("dayjs"));
|
|
42
43
|
__reExport(BaseSales_exports, require("./types"), module.exports);
|
|
44
|
+
var import_Quotation = require("../../modules/Quotation");
|
|
43
45
|
var import_transformBaseProductToOrderProduct = require("./utils/transformBaseProductToOrderProduct");
|
|
46
|
+
var import_quotationPrice = require("./utils/quotationPrice");
|
|
44
47
|
var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
45
48
|
constructor(name, version) {
|
|
46
49
|
super(name, version);
|
|
@@ -48,7 +51,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
48
51
|
this.defaultVersion = "1.0.0";
|
|
49
52
|
this.isSolution = true;
|
|
50
53
|
this.initializeOptions = {};
|
|
51
|
-
// LoggerManager 实例
|
|
52
54
|
this.store = {
|
|
53
55
|
order: void 0
|
|
54
56
|
};
|
|
@@ -58,10 +60,10 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
58
60
|
}
|
|
59
61
|
/**
|
|
60
62
|
* 子类可覆盖此方法以追加/收敛要注册的子模块。
|
|
61
|
-
* 默认包含通用销售模块:products / order / salesSummary / schedule / payment。
|
|
63
|
+
* 默认包含通用销售模块:products / order / salesSummary / schedule / payment / quotation。
|
|
62
64
|
*/
|
|
63
65
|
getRegisteredModuleNames() {
|
|
64
|
-
return ["products", "order", "salesSummary", "schedule", "payment"];
|
|
66
|
+
return ["products", "order", "salesSummary", "schedule", "payment", "quotation"];
|
|
65
67
|
}
|
|
66
68
|
/**
|
|
67
69
|
* 记录信息日志
|
|
@@ -105,13 +107,48 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
105
107
|
get payment() {
|
|
106
108
|
return this.store.payment;
|
|
107
109
|
}
|
|
110
|
+
getCurrentOrderCustomerId() {
|
|
111
|
+
var _a, _b;
|
|
112
|
+
const tempOrder = (_b = (_a = this.store.order) == null ? void 0 : _a.getTempOrder) == null ? void 0 : _b.call(_a);
|
|
113
|
+
const customerId = tempOrder == null ? void 0 : tempOrder.customer_id;
|
|
114
|
+
if (customerId === null || customerId === void 0)
|
|
115
|
+
return void 0;
|
|
116
|
+
return customerId;
|
|
117
|
+
}
|
|
118
|
+
applyQuotationScheduleResolver(quotation) {
|
|
119
|
+
const scheduleModule = this.store.schedule;
|
|
120
|
+
if (!scheduleModule)
|
|
121
|
+
return;
|
|
122
|
+
quotation.setScheduleResolver((id) => {
|
|
123
|
+
var _a;
|
|
124
|
+
const schedules = ((_a = scheduleModule.getScheduleListByIds) == null ? void 0 : _a.call(scheduleModule, [id])) || [];
|
|
125
|
+
return schedules[0];
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
async loadQuotationForPriceQuery(params) {
|
|
129
|
+
var _a;
|
|
130
|
+
if (!params.quotation)
|
|
131
|
+
return;
|
|
132
|
+
this.applyQuotationScheduleResolver(params.quotation);
|
|
133
|
+
await params.quotation.loadQuotations({
|
|
134
|
+
channel: params.channel || ((_a = this.otherParams) == null ? void 0 : _a.channel),
|
|
135
|
+
customer_id: params.customer_id
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
getSubmitOrderSalesChannel() {
|
|
139
|
+
var _a;
|
|
140
|
+
return (_a = this.otherParams) == null ? void 0 : _a.channel;
|
|
141
|
+
}
|
|
108
142
|
/**
|
|
109
143
|
* 工厂入口:根据子模块名实例化对应模块。
|
|
110
144
|
* 默认使用 BookingByStep 公共 `createModule`。子类若需引入额外类型(如 customer),
|
|
111
145
|
* 可覆盖此方法并把未识别的 name 委托给 `super.createSubModule(name)`。
|
|
112
146
|
*/
|
|
113
147
|
createSubModule(moduleName) {
|
|
114
|
-
|
|
148
|
+
if (moduleName === "quotation") {
|
|
149
|
+
return new import_Quotation.QuotationModule(`${this.name}_quotation`);
|
|
150
|
+
}
|
|
151
|
+
return (0, import_types2.createModule)(moduleName, this.name);
|
|
115
152
|
}
|
|
116
153
|
getSubModuleHooks(moduleName) {
|
|
117
154
|
var _a, _b;
|
|
@@ -140,6 +177,43 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
140
177
|
return {};
|
|
141
178
|
}
|
|
142
179
|
}
|
|
180
|
+
getAppData(key) {
|
|
181
|
+
var _a, _b, _c, _d, _e, _f;
|
|
182
|
+
const getData = (_b = (_a = this.appPlugin).getData) == null ? void 0 : _b.call(_a);
|
|
183
|
+
if (typeof getData === "function")
|
|
184
|
+
return getData(key);
|
|
185
|
+
const app = this.appPlugin.getApp();
|
|
186
|
+
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");
|
|
187
|
+
return coreData == null ? void 0 : coreData[key];
|
|
188
|
+
}
|
|
189
|
+
syncAppDataToTempOrder(tempOrder) {
|
|
190
|
+
const taxCountryCode = this.getAppData("tax_country_code");
|
|
191
|
+
const currencyCode = this.getAppData("shop_currency_code");
|
|
192
|
+
const currencySymbol = this.getAppData("shop_symbol");
|
|
193
|
+
let isChanged = false;
|
|
194
|
+
if (taxCountryCode !== void 0) {
|
|
195
|
+
const nextTaxCountryCode = String(taxCountryCode || "");
|
|
196
|
+
if (tempOrder.tax_country_code !== nextTaxCountryCode) {
|
|
197
|
+
tempOrder.tax_country_code = nextTaxCountryCode;
|
|
198
|
+
isChanged = true;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (currencyCode !== void 0) {
|
|
202
|
+
const nextCurrencyCode = String(currencyCode || "");
|
|
203
|
+
if (tempOrder.currency_code !== nextCurrencyCode) {
|
|
204
|
+
tempOrder.currency_code = nextCurrencyCode;
|
|
205
|
+
isChanged = true;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (currencySymbol !== void 0) {
|
|
209
|
+
const nextCurrencySymbol = String(currencySymbol || "");
|
|
210
|
+
if (tempOrder.currency_symbol !== nextCurrencySymbol) {
|
|
211
|
+
tempOrder.currency_symbol = nextCurrencySymbol;
|
|
212
|
+
isChanged = true;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return isChanged;
|
|
216
|
+
}
|
|
143
217
|
async initialize(core, options = {}) {
|
|
144
218
|
var _a;
|
|
145
219
|
this.core = core;
|
|
@@ -148,11 +222,11 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
148
222
|
this.cacheId = (_a = this.otherParams) == null ? void 0 : _a.cacheId;
|
|
149
223
|
this.window = core.getPlugin("window");
|
|
150
224
|
this.request = core.getPlugin("request");
|
|
151
|
-
|
|
152
|
-
if (!appPlugin) {
|
|
225
|
+
this.appPlugin = core.getPlugin("app");
|
|
226
|
+
if (!this.appPlugin) {
|
|
153
227
|
throw new Error("Checkout 解决方案需要 app 插件支持");
|
|
154
228
|
}
|
|
155
|
-
const app = appPlugin.getApp();
|
|
229
|
+
const app = this.appPlugin.getApp();
|
|
156
230
|
this.logger = app.logger;
|
|
157
231
|
const targetCacheData = this.readSessionCacheData();
|
|
158
232
|
const moduleNames = this.getRegisteredModuleNames();
|
|
@@ -286,6 +360,13 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
286
360
|
const result = ((_a = this.store.order) == null ? void 0 : _a.getTempOrder()) || null;
|
|
287
361
|
return result;
|
|
288
362
|
}
|
|
363
|
+
async replaceTempOrder(tempOrder) {
|
|
364
|
+
if (!this.store.order)
|
|
365
|
+
throw new Error("order 模块未初始化");
|
|
366
|
+
const nextTempOrder = await this.store.order.replaceTempOrder(tempOrder);
|
|
367
|
+
await this.effectsEmit("onTempOrderReplaced", { tempOrder: nextTempOrder });
|
|
368
|
+
return nextTempOrder;
|
|
369
|
+
}
|
|
289
370
|
getOrderIdentity() {
|
|
290
371
|
if (!this.store.order)
|
|
291
372
|
return null;
|
|
@@ -311,16 +392,21 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
311
392
|
return "";
|
|
312
393
|
return this.store.order.getTempOrderNote();
|
|
313
394
|
}
|
|
314
|
-
updateTempOrderNote(note) {
|
|
395
|
+
updateTempOrderNote(note, sync = false) {
|
|
315
396
|
try {
|
|
316
397
|
if (!this.store.order)
|
|
317
398
|
throw new Error("order 模块未初始化");
|
|
318
|
-
const result = this.store.order.updateTempOrderNote(note);
|
|
399
|
+
const result = this.store.order.updateTempOrderNote(note, sync);
|
|
319
400
|
return result;
|
|
320
401
|
} catch (error) {
|
|
321
402
|
throw error;
|
|
322
403
|
}
|
|
323
404
|
}
|
|
405
|
+
updateRemoteOrderNote(orderId, note) {
|
|
406
|
+
if (!this.store.order)
|
|
407
|
+
throw new Error("order 模块未初始化");
|
|
408
|
+
this.store.order.syncTempOrderNoteToRemote(orderId, note);
|
|
409
|
+
}
|
|
324
410
|
updateTempOrderShopDiscount(amount) {
|
|
325
411
|
if (!this.store.order)
|
|
326
412
|
throw new Error("order 模块未初始化");
|
|
@@ -331,6 +417,32 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
331
417
|
throw new Error("order 模块未初始化");
|
|
332
418
|
return this.store.order.updateTempOrderContactsInfo(contactsInfo);
|
|
333
419
|
}
|
|
420
|
+
/**
|
|
421
|
+
* 运行时切换 tempOrder 是否写入 localStorage(委托 OrderModule)。
|
|
422
|
+
* SalesSdk 等内存态场景可在挂载后设为 false,避免污染本地缓存。
|
|
423
|
+
*
|
|
424
|
+
* @example
|
|
425
|
+
* bookingTicket.setEnableTempOrderPersist(false);
|
|
426
|
+
* await bookingTicket.addProductToOrder(product);
|
|
427
|
+
*/
|
|
428
|
+
setEnableTempOrderPersist(enabled) {
|
|
429
|
+
if (!this.store.order)
|
|
430
|
+
throw new Error("order 模块未初始化");
|
|
431
|
+
this.store.order.setEnableTempOrderPersist(enabled);
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* 读取当前 tempOrder localStorage 持久化开关(委托 OrderModule)。
|
|
435
|
+
*
|
|
436
|
+
* @example
|
|
437
|
+
* if (bookingTicket.isTempOrderPersistEnabled()) {
|
|
438
|
+
* bookingTicket.restoreOrder();
|
|
439
|
+
* }
|
|
440
|
+
*/
|
|
441
|
+
isTempOrderPersistEnabled() {
|
|
442
|
+
if (!this.store.order)
|
|
443
|
+
return true;
|
|
444
|
+
return this.store.order.isTempOrderPersistEnabled();
|
|
445
|
+
}
|
|
334
446
|
ensureTempOrder() {
|
|
335
447
|
if (!this.store.order)
|
|
336
448
|
throw new Error("order 模块未初始化");
|
|
@@ -342,6 +454,10 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
342
454
|
if (!this.store.order)
|
|
343
455
|
throw new Error("order 模块未初始化");
|
|
344
456
|
const tempOrder = await this.store.order.addNewOrder();
|
|
457
|
+
if (this.syncAppDataToTempOrder(tempOrder)) {
|
|
458
|
+
this.store.order.persistTempOrder();
|
|
459
|
+
await this.store.order.saveDraft();
|
|
460
|
+
}
|
|
345
461
|
return tempOrder;
|
|
346
462
|
} catch (error) {
|
|
347
463
|
throw error;
|
|
@@ -360,6 +476,41 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
360
476
|
throw new Error("scanOrder 解决方案需要 order 模块支持");
|
|
361
477
|
}
|
|
362
478
|
const tempOrder = this.store.order.restoreOrder();
|
|
479
|
+
this.currentSalesDetail = null;
|
|
480
|
+
await this.effectsEmit("onTempOrderReplaced", { tempOrder });
|
|
481
|
+
if (this.syncAppDataToTempOrder(tempOrder)) {
|
|
482
|
+
this.store.order.persistTempOrder();
|
|
483
|
+
await this.store.order.saveDraft();
|
|
484
|
+
}
|
|
485
|
+
return tempOrder;
|
|
486
|
+
} catch (error) {
|
|
487
|
+
throw error;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* 仅清空 tempOrder 购物车行(products / bookings / discount_list)。
|
|
492
|
+
* 同步清空内存中的 salesDetail 商品/预约视图,避免编辑态仍读到旧 bookings。
|
|
493
|
+
*/
|
|
494
|
+
async clearOrderCartLines() {
|
|
495
|
+
try {
|
|
496
|
+
if (!this.store.order)
|
|
497
|
+
throw new Error("order 模块未初始化");
|
|
498
|
+
const tempOrder = await this.store.order.clearOrderCartLines();
|
|
499
|
+
if (this.currentSalesDetail) {
|
|
500
|
+
this.currentSalesDetail = {
|
|
501
|
+
...this.currentSalesDetail,
|
|
502
|
+
products: [],
|
|
503
|
+
bookings: [],
|
|
504
|
+
rootBooking: null,
|
|
505
|
+
bookingsByProductUid: {},
|
|
506
|
+
discount_list: []
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
await this.effectsEmit("onTempOrderReplaced", { tempOrder });
|
|
510
|
+
if (this.syncAppDataToTempOrder(tempOrder)) {
|
|
511
|
+
this.store.order.persistTempOrder();
|
|
512
|
+
await this.store.order.saveDraft();
|
|
513
|
+
}
|
|
363
514
|
return tempOrder;
|
|
364
515
|
} catch (error) {
|
|
365
516
|
throw error;
|
|
@@ -381,6 +532,203 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
381
532
|
throw error;
|
|
382
533
|
}
|
|
383
534
|
}
|
|
535
|
+
getHistoricalProductDiscountList(products) {
|
|
536
|
+
const historyDiscountList = [];
|
|
537
|
+
products.forEach((item) => {
|
|
538
|
+
if (!this.isPersistedOrderProduct(item))
|
|
539
|
+
return;
|
|
540
|
+
(item.discount_list || []).forEach((discount) => {
|
|
541
|
+
var _a, _b, _c, _d, _e, _f;
|
|
542
|
+
const discountId = ((_a = discount.discount) == null ? void 0 : _a.resource_id) || discount.id;
|
|
543
|
+
if (!discountId || !["good_pass", "discount_card"].includes(discount.type))
|
|
544
|
+
return;
|
|
545
|
+
const quantity = item.quantity || item.num || item.product_quantity || 1;
|
|
546
|
+
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);
|
|
547
|
+
const index = historyDiscountList.findIndex((n) => n.id === discountId);
|
|
548
|
+
if (index !== -1) {
|
|
549
|
+
historyDiscountList[index] = {
|
|
550
|
+
...historyDiscountList[index],
|
|
551
|
+
amount: new import_decimal.default(historyDiscountList[index].amount || 0).plus(discount.amount || 0).toNumber(),
|
|
552
|
+
savedAmount: savedAmount.plus(historyDiscountList[index].savedAmount || 0).toNumber()
|
|
553
|
+
};
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
historyDiscountList.push({
|
|
557
|
+
...discount,
|
|
558
|
+
id: discountId,
|
|
559
|
+
tag: discount.tag || discount.type,
|
|
560
|
+
name: discount.name || ((_d = (_c = discount.discount) == null ? void 0 : _c.title) == null ? void 0 : _d.auto),
|
|
561
|
+
format_title: ((_e = discount.discount) == null ? void 0 : _e.title) || discount.format_title,
|
|
562
|
+
isEditMode: true,
|
|
563
|
+
limited_relation_product_data: {},
|
|
564
|
+
savedAmount: savedAmount.toNumber(),
|
|
565
|
+
isAvailable: true,
|
|
566
|
+
isDisabled: true,
|
|
567
|
+
isSelected: true,
|
|
568
|
+
product_id: ((_f = discount.discount) == null ? void 0 : _f.product_id) || discount.product_id
|
|
569
|
+
});
|
|
570
|
+
});
|
|
571
|
+
});
|
|
572
|
+
return historyDiscountList;
|
|
573
|
+
}
|
|
574
|
+
isPersistedOrderProduct(product) {
|
|
575
|
+
const orderDetailId = product.order_detail_id ?? product.orderDetailId;
|
|
576
|
+
if (orderDetailId !== void 0 && orderDetailId !== null && orderDetailId !== "") {
|
|
577
|
+
return true;
|
|
578
|
+
}
|
|
579
|
+
const bookingId = product.booking_id ?? product.bookingId;
|
|
580
|
+
return bookingId !== void 0 && bookingId !== null && bookingId !== "";
|
|
581
|
+
}
|
|
582
|
+
mergeHistoricalDiscountList(discountList, products) {
|
|
583
|
+
const historyDiscountList = this.getHistoricalProductDiscountList(products);
|
|
584
|
+
const historyIds = new Set(historyDiscountList.map((discount) => discount.id));
|
|
585
|
+
return [
|
|
586
|
+
...historyDiscountList,
|
|
587
|
+
...(discountList || []).filter((discount) => !historyIds.has(discount.id))
|
|
588
|
+
];
|
|
589
|
+
}
|
|
590
|
+
mergeCurrentDiscountSelectionState(discountList, currentDiscountList) {
|
|
591
|
+
if (!currentDiscountList.length)
|
|
592
|
+
return discountList;
|
|
593
|
+
const currentDiscountMap = new Map(
|
|
594
|
+
currentDiscountList.map((discount) => [discount.id, discount])
|
|
595
|
+
);
|
|
596
|
+
return discountList.map((discount) => {
|
|
597
|
+
const currentDiscount = currentDiscountMap.get(discount.id);
|
|
598
|
+
if (!currentDiscount)
|
|
599
|
+
return discount;
|
|
600
|
+
if (currentDiscount.isManualSelect) {
|
|
601
|
+
return {
|
|
602
|
+
...discount,
|
|
603
|
+
isSelected: false,
|
|
604
|
+
isManualSelect: true
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
if (currentDiscount.isSelected) {
|
|
608
|
+
return {
|
|
609
|
+
...discount,
|
|
610
|
+
isSelected: true,
|
|
611
|
+
isManualSelect: false
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
return discount;
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
async loadDiscountConfig(params) {
|
|
618
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
619
|
+
if (!this.store.order)
|
|
620
|
+
throw new Error("order 模块未初始化");
|
|
621
|
+
const tempOrder = this.store.order.ensureTempOrder();
|
|
622
|
+
const orderStore = this.store.order.store || {};
|
|
623
|
+
const discountModule = orderStore.discount;
|
|
624
|
+
const rulesModule = orderStore.rules;
|
|
625
|
+
const orderId = tempOrder.order_id || ((_b = (_a = this.getOrderIdentity) == null ? void 0 : _a.call(this)) == null ? void 0 : _b.orderId);
|
|
626
|
+
const customerId = Number(
|
|
627
|
+
(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
|
|
628
|
+
);
|
|
629
|
+
const currentDiscountList = ((_h = discountModule == null ? void 0 : discountModule.getDiscountList) == null ? void 0 : _h.call(discountModule)) || [];
|
|
630
|
+
let preparedDiscountList = [];
|
|
631
|
+
if (customerId && customerId !== 1) {
|
|
632
|
+
preparedDiscountList = await this.store.order.loadDiscountConfig({
|
|
633
|
+
customerId,
|
|
634
|
+
action: (params == null ? void 0 : params.action) || (orderId ? "edit" : "create"),
|
|
635
|
+
orderId: Number(orderId) || void 0,
|
|
636
|
+
apply: false
|
|
637
|
+
});
|
|
638
|
+
await ((_i = discountModule == null ? void 0 : discountModule.setOriginalDiscountList) == null ? void 0 : _i.call(discountModule, preparedDiscountList));
|
|
639
|
+
}
|
|
640
|
+
let nextDiscountList = this.mergeHistoricalDiscountList(
|
|
641
|
+
preparedDiscountList || ((_j = discountModule == null ? void 0 : discountModule.getDiscountList) == null ? void 0 : _j.call(discountModule)) || [],
|
|
642
|
+
tempOrder.products || []
|
|
643
|
+
);
|
|
644
|
+
nextDiscountList = this.mergeCurrentDiscountSelectionState(
|
|
645
|
+
nextDiscountList,
|
|
646
|
+
currentDiscountList
|
|
647
|
+
);
|
|
648
|
+
await (discountModule == null ? void 0 : discountModule.setDiscountList(nextDiscountList));
|
|
649
|
+
if (rulesModule) {
|
|
650
|
+
const holders = ((_k = tempOrder.holder) == null ? void 0 : _k.form_record_id) ? [{ form_record_id: tempOrder.holder.form_record_id }] : [];
|
|
651
|
+
const result = rulesModule.calcDiscount({
|
|
652
|
+
productList: tempOrder.products,
|
|
653
|
+
discountList: nextDiscountList,
|
|
654
|
+
holders,
|
|
655
|
+
isFormSubject: !!((_l = tempOrder.holder) == null ? void 0 : _l.type) && tempOrder.holder.type === "form",
|
|
656
|
+
orderTotalAmount: Number(((_m = orderStore.summary) == null ? void 0 : _m.total_amount) || 0)
|
|
657
|
+
}) || { productList: tempOrder.products, discountList: nextDiscountList };
|
|
658
|
+
if (result.productList) {
|
|
659
|
+
tempOrder.products = result.productList;
|
|
660
|
+
}
|
|
661
|
+
if (result.discountList) {
|
|
662
|
+
nextDiscountList = this.mergeHistoricalDiscountList(
|
|
663
|
+
result.discountList,
|
|
664
|
+
tempOrder.products || []
|
|
665
|
+
);
|
|
666
|
+
import_Order.OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
667
|
+
await (discountModule == null ? void 0 : discountModule.setDiscountList(nextDiscountList));
|
|
668
|
+
tempOrder.discount_list = nextDiscountList.filter((discount) => discount.isSelected);
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
this.store.order.persistTempOrder();
|
|
672
|
+
await this.effectsEmit("onDiscountApplied", {
|
|
673
|
+
productList: tempOrder.products || [],
|
|
674
|
+
discountList: nextDiscountList,
|
|
675
|
+
selectedDiscountList: tempOrder.discount_list || [],
|
|
676
|
+
tempOrder
|
|
677
|
+
});
|
|
678
|
+
return {
|
|
679
|
+
productList: tempOrder.products || [],
|
|
680
|
+
discountList: nextDiscountList
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
async bestDiscount(cb) {
|
|
684
|
+
var _a, _b, _c, _d;
|
|
685
|
+
if (!this.store.order)
|
|
686
|
+
throw new Error("order 模块未初始化");
|
|
687
|
+
const tempOrder = this.store.order.ensureTempOrder();
|
|
688
|
+
const orderStore = this.store.order.store || {};
|
|
689
|
+
const discountModule = orderStore.discount;
|
|
690
|
+
const rulesModule = orderStore.rules;
|
|
691
|
+
const originalDiscountList = ((_a = discountModule == null ? void 0 : discountModule.getOriginalDiscountList) == null ? void 0 : _a.call(discountModule)) || this.getDiscountList();
|
|
692
|
+
let nextDiscountList = this.mergeHistoricalDiscountList(
|
|
693
|
+
originalDiscountList || [],
|
|
694
|
+
tempOrder.products || []
|
|
695
|
+
);
|
|
696
|
+
let result = {
|
|
697
|
+
productList: tempOrder.products || [],
|
|
698
|
+
discountList: nextDiscountList
|
|
699
|
+
};
|
|
700
|
+
await (discountModule == null ? void 0 : discountModule.setDiscountList(nextDiscountList));
|
|
701
|
+
if (rulesModule) {
|
|
702
|
+
const holders = ((_b = tempOrder.holder) == null ? void 0 : _b.form_record_id) ? [{ form_record_id: tempOrder.holder.form_record_id }] : [];
|
|
703
|
+
result = rulesModule.calcDiscount({
|
|
704
|
+
productList: tempOrder.products,
|
|
705
|
+
discountList: nextDiscountList,
|
|
706
|
+
holders,
|
|
707
|
+
isFormSubject: !!((_c = tempOrder.holder) == null ? void 0 : _c.type) && tempOrder.holder.type === "form",
|
|
708
|
+
orderTotalAmount: Number(((_d = orderStore.summary) == null ? void 0 : _d.total_amount) || 0)
|
|
709
|
+
}) || result;
|
|
710
|
+
if (result.productList) {
|
|
711
|
+
tempOrder.products = result.productList;
|
|
712
|
+
}
|
|
713
|
+
if (result.discountList) {
|
|
714
|
+
nextDiscountList = this.mergeHistoricalDiscountList(
|
|
715
|
+
result.discountList,
|
|
716
|
+
tempOrder.products || []
|
|
717
|
+
);
|
|
718
|
+
import_Order.OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
719
|
+
await (discountModule == null ? void 0 : discountModule.setDiscountList(nextDiscountList));
|
|
720
|
+
tempOrder.discount_list = nextDiscountList.filter((discount) => discount.isSelected);
|
|
721
|
+
result = {
|
|
722
|
+
productList: tempOrder.products,
|
|
723
|
+
discountList: nextDiscountList
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
728
|
+
this.store.order.persistTempOrder();
|
|
729
|
+
cb == null ? void 0 : cb(result);
|
|
730
|
+
return result;
|
|
731
|
+
}
|
|
384
732
|
getDiscountList() {
|
|
385
733
|
if (!this.store.order)
|
|
386
734
|
return [];
|
|
@@ -490,6 +838,40 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
490
838
|
tempOrder.discount_list = (nextDiscountList || []).filter((d) => d.isSelected);
|
|
491
839
|
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
492
840
|
this.store.order.persistTempOrder();
|
|
841
|
+
this.effectsEmit("onDiscountApplied", {
|
|
842
|
+
productList: tempOrder.products,
|
|
843
|
+
discountList: nextDiscountList,
|
|
844
|
+
selectedDiscountList: tempOrder.discount_list,
|
|
845
|
+
tempOrder
|
|
846
|
+
});
|
|
847
|
+
} catch (error) {
|
|
848
|
+
throw error;
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
async applyDiscountCalculationResult(result) {
|
|
852
|
+
try {
|
|
853
|
+
if (!this.store.order)
|
|
854
|
+
throw new Error("order 模块未初始化");
|
|
855
|
+
if (!result)
|
|
856
|
+
return;
|
|
857
|
+
const tempOrder = this.store.order.ensureTempOrder();
|
|
858
|
+
const orderStore = this.store.order.store || {};
|
|
859
|
+
const discountModule = orderStore.discount;
|
|
860
|
+
if (result.productList) {
|
|
861
|
+
tempOrder.products = result.productList;
|
|
862
|
+
}
|
|
863
|
+
if (result.discountList) {
|
|
864
|
+
import_Order.OrderModule.populateSavedAmounts(
|
|
865
|
+
tempOrder.products,
|
|
866
|
+
result.discountList
|
|
867
|
+
);
|
|
868
|
+
await (discountModule == null ? void 0 : discountModule.setDiscountList(result.discountList));
|
|
869
|
+
tempOrder.discount_list = result.discountList.filter(
|
|
870
|
+
(discount) => discount.isSelected
|
|
871
|
+
);
|
|
872
|
+
}
|
|
873
|
+
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
874
|
+
this.store.order.persistTempOrder();
|
|
493
875
|
} catch (error) {
|
|
494
876
|
throw error;
|
|
495
877
|
}
|
|
@@ -504,7 +886,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
504
886
|
* payments 会交给 OrderModule 统一映射为 Sales 协议支付项。
|
|
505
887
|
*/
|
|
506
888
|
async submitSalesOrder(params) {
|
|
507
|
-
var _a, _b, _c
|
|
889
|
+
var _a, _b, _c;
|
|
508
890
|
if (!this.store.order) {
|
|
509
891
|
throw new Error("BaseSales 解决方案需要 order 模块支持");
|
|
510
892
|
}
|
|
@@ -513,19 +895,57 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
513
895
|
cacheId: this.cacheId,
|
|
514
896
|
platform: (_a = this.otherParams) == null ? void 0 : _a.platform,
|
|
515
897
|
businessCode: (_b = this.otherParams) == null ? void 0 : _b.businessCode,
|
|
516
|
-
channel:
|
|
517
|
-
type: (
|
|
898
|
+
channel: this.getSubmitOrderSalesChannel(),
|
|
899
|
+
type: (_c = this.otherParams) == null ? void 0 : _c.type,
|
|
518
900
|
...(params == null ? void 0 : params.payments) !== void 0 ? { payments: params.payments } : {},
|
|
519
901
|
...(params == null ? void 0 : params.paymentStatus) !== void 0 ? { paymentStatus: params.paymentStatus } : {},
|
|
520
902
|
...(params == null ? void 0 : params.smallTicketDataFlag) !== void 0 ? { smallTicketDataFlag: params.smallTicketDataFlag } : {},
|
|
521
903
|
...(params == null ? void 0 : params.enhancePayload) !== void 0 ? { enhancePayload: params.enhancePayload } : {}
|
|
522
904
|
};
|
|
905
|
+
console.log(submitParams, "submitParams123");
|
|
523
906
|
return this.store.order.submitTempOrder(submitParams);
|
|
524
907
|
}
|
|
525
908
|
async syncPaymentsToOrder(params) {
|
|
526
909
|
if (!this.store.order)
|
|
527
910
|
throw new Error("order 模块未初始化");
|
|
528
|
-
|
|
911
|
+
const channel = params.channel ?? this.getSubmitOrderSalesChannel();
|
|
912
|
+
const syncParams = {
|
|
913
|
+
...params,
|
|
914
|
+
...channel !== void 0 ? { channel } : {}
|
|
915
|
+
};
|
|
916
|
+
const syncState = this.store.order.getOrderSyncState();
|
|
917
|
+
if (params.submitWhenPaid && syncState === "submitting") {
|
|
918
|
+
return this.store.order.syncPaymentsToOrder(syncParams);
|
|
919
|
+
}
|
|
920
|
+
const payments = params.payments || [];
|
|
921
|
+
await this.effectsEmit(import_types.BaseSalesHookNames.onPaymentSyncStart, {
|
|
922
|
+
payments,
|
|
923
|
+
params: syncParams,
|
|
924
|
+
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
925
|
+
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
926
|
+
});
|
|
927
|
+
try {
|
|
928
|
+
const syncResult = await this.store.order.syncPaymentsToOrder(syncParams);
|
|
929
|
+
await this.effectsEmit(import_types.BaseSalesHookNames.onPaymentSyncEnd, {
|
|
930
|
+
ok: true,
|
|
931
|
+
syncResult,
|
|
932
|
+
payments: this.store.order.getOrderPayments(),
|
|
933
|
+
params: syncParams,
|
|
934
|
+
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
935
|
+
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
936
|
+
});
|
|
937
|
+
return syncResult;
|
|
938
|
+
} catch (error) {
|
|
939
|
+
await this.effectsEmit(import_types.BaseSalesHookNames.onPaymentSyncEnd, {
|
|
940
|
+
ok: false,
|
|
941
|
+
error,
|
|
942
|
+
payments: this.store.order.getOrderPayments(),
|
|
943
|
+
params: syncParams,
|
|
944
|
+
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
945
|
+
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
946
|
+
});
|
|
947
|
+
throw error;
|
|
948
|
+
}
|
|
529
949
|
}
|
|
530
950
|
/** 读取当前 BaseSales 订单上下文中的 Sales 协议支付项。 */
|
|
531
951
|
getOrderPayments() {
|
|
@@ -543,7 +963,23 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
543
963
|
addOrderPayment(payment) {
|
|
544
964
|
if (!this.store.order)
|
|
545
965
|
throw new Error("order 模块未初始化");
|
|
546
|
-
|
|
966
|
+
const payments = this.store.order.addOrderPayment(payment);
|
|
967
|
+
const amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
968
|
+
const syncState = this.store.order.getOrderSyncState();
|
|
969
|
+
if (amountSnapshot && syncState !== "submitting") {
|
|
970
|
+
const paymentStatus = Number(amountSnapshot.amountGap || 0) <= 0 ? "paid" : "partially_paid";
|
|
971
|
+
void this.syncPaymentsToOrder({
|
|
972
|
+
payments,
|
|
973
|
+
paymentStatus,
|
|
974
|
+
submitWhenPaid: true,
|
|
975
|
+
smallTicketDataFlag: 1
|
|
976
|
+
}).catch((error) => {
|
|
977
|
+
this.logError("auto sync payments failed", {
|
|
978
|
+
error: error instanceof Error ? error.message : String(error)
|
|
979
|
+
});
|
|
980
|
+
});
|
|
981
|
+
}
|
|
982
|
+
return payments;
|
|
547
983
|
}
|
|
548
984
|
/** 更新当前订单中的指定支付项。 */
|
|
549
985
|
updateOrderPayment(paymentIdentity, updates) {
|
|
@@ -578,6 +1014,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
578
1014
|
is_charge_tax: product.is_charge_tax ?? 0,
|
|
579
1015
|
tax_fee: product.tax_fee,
|
|
580
1016
|
selling_price: Number(product.selling_price || 0),
|
|
1017
|
+
discount_list: product.discount_list || [],
|
|
581
1018
|
holder_id: product.holder_id ?? metadata.holder_id,
|
|
582
1019
|
original_price: product.original_price,
|
|
583
1020
|
main_product_original_price: metadata.main_product_original_price ?? product.original_price,
|
|
@@ -591,8 +1028,10 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
591
1028
|
const bundleMetadata = bundle.metadata || {};
|
|
592
1029
|
return {
|
|
593
1030
|
is_price_include_tax: tempOrder.is_price_include_tax,
|
|
594
|
-
|
|
595
|
-
|
|
1031
|
+
// 套餐子项在 tempOrder 上常为 id(如 1718),prepare/deduction 协议要求 bundle_id
|
|
1032
|
+
bundle_id: bundle.bundle_id ?? bundle.id,
|
|
1033
|
+
bundle_product_id: bundle.bundle_product_id ?? bundle._bundle_product_id,
|
|
1034
|
+
bundle_group_id: bundle.bundle_group_id ?? bundle.group_id,
|
|
596
1035
|
bundle_variant_id: bundle.bundle_variant_id,
|
|
597
1036
|
price_type: bundle.price_type,
|
|
598
1037
|
price_type_ext: bundle.price_type_ext,
|
|
@@ -731,6 +1170,20 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
731
1170
|
transformBaseProductToOrderProduct(params) {
|
|
732
1171
|
return (0, import_transformBaseProductToOrderProduct.transformBaseProductToOrderProduct)(params);
|
|
733
1172
|
}
|
|
1173
|
+
async calculateProductBookingPrice(params) {
|
|
1174
|
+
const quotation = this.store.quotation;
|
|
1175
|
+
const customerId = params.customer_id ?? this.getCurrentOrderCustomerId();
|
|
1176
|
+
await this.loadQuotationForPriceQuery({
|
|
1177
|
+
quotation,
|
|
1178
|
+
customer_id: customerId,
|
|
1179
|
+
channel: params.channel
|
|
1180
|
+
});
|
|
1181
|
+
return (0, import_quotationPrice.calculateBaseSalesProductBookingPrice)({
|
|
1182
|
+
...params,
|
|
1183
|
+
customer_id: customerId,
|
|
1184
|
+
quotation
|
|
1185
|
+
});
|
|
1186
|
+
}
|
|
734
1187
|
async addProductToOrder(product, booking) {
|
|
735
1188
|
try {
|
|
736
1189
|
if (!this.store.order)
|
|
@@ -741,16 +1194,35 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
741
1194
|
throw error;
|
|
742
1195
|
}
|
|
743
1196
|
}
|
|
744
|
-
async
|
|
1197
|
+
async updateOrderProduct(params) {
|
|
1198
|
+
try {
|
|
1199
|
+
if (!this.store.order)
|
|
1200
|
+
throw new Error("order 模块未初始化");
|
|
1201
|
+
const products = await this.store.order.updateOrderProduct(params);
|
|
1202
|
+
return products;
|
|
1203
|
+
} catch (error) {
|
|
1204
|
+
throw error;
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
async updateOrderProductQuantity(params) {
|
|
745
1208
|
try {
|
|
746
1209
|
if (!this.store.order)
|
|
747
1210
|
throw new Error("order 模块未初始化");
|
|
748
|
-
const products = await this.store.order.
|
|
1211
|
+
const products = await this.store.order.updateOrderProductQuantity(params);
|
|
749
1212
|
return products;
|
|
750
1213
|
} catch (error) {
|
|
751
1214
|
throw error;
|
|
752
1215
|
}
|
|
753
1216
|
}
|
|
1217
|
+
updateOrderBooking(params) {
|
|
1218
|
+
try {
|
|
1219
|
+
if (!this.store.order)
|
|
1220
|
+
throw new Error("order 模块未初始化");
|
|
1221
|
+
return this.store.order.updateOrderBooking(params);
|
|
1222
|
+
} catch (error) {
|
|
1223
|
+
throw error;
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
754
1226
|
/**
|
|
755
1227
|
* 设置单行商品备注(与整单 `updateTempOrderNote` 区分)。
|
|
756
1228
|
* 多行同 SKU 时必须传入与删除/更新一致的 unique_identification_number。
|
|
@@ -770,7 +1242,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
770
1242
|
}
|
|
771
1243
|
if (identity.product_bundle !== void 0)
|
|
772
1244
|
params.product_bundle = identity.product_bundle;
|
|
773
|
-
const products = await this.
|
|
1245
|
+
const products = await this.updateOrderProduct(params);
|
|
774
1246
|
return products;
|
|
775
1247
|
} catch (error) {
|
|
776
1248
|
throw error;
|