@pisell/pisellos 2.2.174 → 2.2.175
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/Customer/index.d.ts +0 -6
- package/dist/modules/Customer/index.js +83 -129
- package/dist/modules/Customer/types.d.ts +0 -2
- package/dist/modules/Discount/index.d.ts +4 -2
- package/dist/modules/Discount/index.js +93 -8
- package/dist/modules/Discount/types.d.ts +7 -1
- package/dist/modules/Order/index.d.ts +17 -33
- package/dist/modules/Order/index.js +395 -757
- package/dist/modules/Order/types.d.ts +17 -58
- package/dist/modules/Order/types.js +0 -2
- package/dist/modules/Order/utils.d.ts +1 -39
- package/dist/modules/Order/utils.js +31 -220
- package/dist/modules/Quotation/index.d.ts +1 -0
- package/dist/modules/Quotation/index.js +21 -23
- package/dist/modules/Rules/index.d.ts +0 -4
- package/dist/modules/Rules/index.js +10 -26
- package/dist/modules/SalesSummary/index.js +2 -4
- package/dist/modules/Schedule/index.js +2 -6
- package/dist/modules/index.d.ts +0 -1
- package/dist/modules/index.js +1 -2
- package/dist/server/index.js +6 -10
- package/dist/server/modules/order/utils/filterOrders.js +6 -20
- package/dist/server/modules/products/index.d.ts +1 -1
- package/dist/server/modules/products/index.js +113 -130
- package/dist/server/modules/schedule/index.js +6 -13
- package/dist/solution/BaseSales/index.d.ts +7 -53
- package/dist/solution/BaseSales/index.js +340 -1165
- package/dist/solution/BaseSales/types.d.ts +1 -67
- package/dist/solution/BaseSales/types.js +1 -3
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +16 -68
- package/dist/solution/BaseSales/utils.js +8 -46
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -133
- package/dist/solution/BookingTicket/index.js +175 -776
- package/dist/solution/BookingTicket/types.d.ts +0 -2
- package/dist/solution/BookingTicket/types.js +0 -3
- package/dist/solution/ScanOrder/index.d.ts +3 -9
- package/dist/solution/ScanOrder/index.js +128 -231
- package/dist/solution/ScanOrder/utils.js +8 -46
- package/dist/solution/ShopDiscount/index.d.ts +1 -0
- package/dist/solution/ShopDiscount/index.js +23 -18
- package/dist/solution/VenueBooking/index.d.ts +9 -5
- package/dist/solution/VenueBooking/index.js +55 -103
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
- package/dist/solution/VenueBooking/utils/slotMerge.js +0 -10
- package/lib/modules/Customer/index.d.ts +0 -6
- package/lib/modules/Customer/index.js +11 -26
- package/lib/modules/Customer/types.d.ts +0 -2
- package/lib/modules/Discount/index.d.ts +4 -2
- package/lib/modules/Discount/index.js +63 -8
- package/lib/modules/Discount/types.d.ts +7 -1
- package/lib/modules/Order/index.d.ts +17 -33
- package/lib/modules/Order/index.js +148 -402
- package/lib/modules/Order/types.d.ts +17 -58
- package/lib/modules/Order/utils.d.ts +1 -39
- package/lib/modules/Order/utils.js +22 -198
- package/lib/modules/Quotation/index.d.ts +1 -0
- package/lib/modules/Quotation/index.js +15 -18
- package/lib/modules/Rules/index.d.ts +0 -4
- package/lib/modules/Rules/index.js +14 -22
- package/lib/modules/SalesSummary/index.js +2 -4
- package/lib/modules/Schedule/index.js +1 -3
- package/lib/modules/index.d.ts +0 -1
- package/lib/modules/index.js +1 -3
- package/lib/server/index.js +0 -2
- package/lib/server/modules/order/utils/filterOrders.js +4 -12
- package/lib/server/modules/products/index.d.ts +1 -1
- package/lib/server/modules/products/index.js +20 -30
- package/lib/server/modules/schedule/index.js +1 -2
- package/lib/solution/BaseSales/index.d.ts +7 -53
- package/lib/solution/BaseSales/index.js +22 -530
- package/lib/solution/BaseSales/types.d.ts +1 -67
- package/lib/solution/BaseSales/types.js +1 -3
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +12 -71
- package/lib/solution/BaseSales/utils.js +6 -46
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -133
- package/lib/solution/BookingTicket/index.js +8 -349
- package/lib/solution/BookingTicket/types.d.ts +0 -2
- package/lib/solution/BookingTicket/types.js +0 -6
- package/lib/solution/ScanOrder/index.d.ts +3 -9
- package/lib/solution/ScanOrder/index.js +66 -147
- package/lib/solution/ScanOrder/utils.js +6 -46
- package/lib/solution/ShopDiscount/index.d.ts +1 -0
- package/lib/solution/ShopDiscount/index.js +4 -2
- package/lib/solution/VenueBooking/index.d.ts +9 -5
- package/lib/solution/VenueBooking/index.js +14 -50
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
- package/lib/solution/VenueBooking/utils/slotMerge.js +0 -10
- package/package.json +2 -2
- package/dist/modules/BookingContext/index.d.ts +0 -37
- package/dist/modules/BookingContext/index.js +0 -436
- package/dist/modules/BookingContext/types.d.ts +0 -102
- package/dist/modules/BookingContext/types.js +0 -51
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -193
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -137
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -215
- package/dist/modules/BookingContext/utils/flexible.d.ts +0 -28
- package/dist/modules/BookingContext/utils/flexible.js +0 -56
- package/dist/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
- package/dist/modules/BookingContext/utils/formatResourceList.js +0 -38
- package/dist/modules/BookingContext/utils/index.d.ts +0 -11
- package/dist/modules/BookingContext/utils/index.js +0 -11
- package/dist/modules/BookingContext/utils/noResource.d.ts +0 -13
- package/dist/modules/BookingContext/utils/noResource.js +0 -77
- package/dist/modules/BookingContext/utils/productExtend.d.ts +0 -72
- package/dist/modules/BookingContext/utils/productExtend.js +0 -339
- package/dist/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
- package/dist/modules/BookingContext/utils/resourceErrors.js +0 -74
- package/dist/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
- package/dist/modules/BookingContext/utils/resourceSelection.js +0 -24
- package/dist/modules/BookingContext/utils/resources.d.ts +0 -80
- package/dist/modules/BookingContext/utils/resources.js +0 -486
- package/dist/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
- package/dist/modules/BookingContext/utils/serviceTimes.js +0 -151
- package/dist/modules/BookingContext/utils/timeSlices.d.ts +0 -42
- package/dist/modules/BookingContext/utils/timeSlices.js +0 -100
- package/dist/modules/Order/utils/manualProductDiscount.d.ts +0 -106
- package/dist/modules/Order/utils/manualProductDiscount.js +0 -212
- package/dist/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
- package/dist/solution/BaseSales/utils/quotationPrice.js +0 -237
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
- package/dist/solution/BookingTicket/utils/addProductDecision.js +0 -346
- package/lib/modules/BookingContext/index.d.ts +0 -37
- package/lib/modules/BookingContext/index.js +0 -297
- package/lib/modules/BookingContext/types.d.ts +0 -102
- package/lib/modules/BookingContext/types.js +0 -34
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -207
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -141
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -198
- package/lib/modules/BookingContext/utils/flexible.d.ts +0 -28
- package/lib/modules/BookingContext/utils/flexible.js +0 -80
- package/lib/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
- package/lib/modules/BookingContext/utils/formatResourceList.js +0 -50
- package/lib/modules/BookingContext/utils/index.d.ts +0 -11
- package/lib/modules/BookingContext/utils/index.js +0 -43
- package/lib/modules/BookingContext/utils/noResource.d.ts +0 -13
- package/lib/modules/BookingContext/utils/noResource.js +0 -90
- package/lib/modules/BookingContext/utils/productExtend.d.ts +0 -72
- package/lib/modules/BookingContext/utils/productExtend.js +0 -283
- package/lib/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
- package/lib/modules/BookingContext/utils/resourceErrors.js +0 -80
- package/lib/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
- package/lib/modules/BookingContext/utils/resourceSelection.js +0 -46
- package/lib/modules/BookingContext/utils/resources.d.ts +0 -80
- package/lib/modules/BookingContext/utils/resources.js +0 -377
- package/lib/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
- package/lib/modules/BookingContext/utils/serviceTimes.js +0 -162
- package/lib/modules/BookingContext/utils/timeSlices.d.ts +0 -42
- package/lib/modules/BookingContext/utils/timeSlices.js +0 -124
- package/lib/modules/Order/utils/manualProductDiscount.d.ts +0 -106
- package/lib/modules/Order/utils/manualProductDiscount.js +0 -207
- package/lib/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
- package/lib/solution/BaseSales/utils/quotationPrice.js +0 -277
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
- package/lib/solution/BookingTicket/utils/addProductDecision.js +0 -318
|
@@ -34,16 +34,13 @@ __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");
|
|
38
37
|
var import_Order = require("../../modules/Order");
|
|
39
38
|
var import_decimal = __toESM(require("decimal.js"));
|
|
40
|
-
var
|
|
39
|
+
var import_types = require("../BookingByStep/types");
|
|
41
40
|
var import_utils = require("../../modules/Order/utils");
|
|
42
41
|
var import_dayjs = __toESM(require("dayjs"));
|
|
43
42
|
__reExport(BaseSales_exports, require("./types"), module.exports);
|
|
44
|
-
var import_Quotation = require("../../modules/Quotation");
|
|
45
43
|
var import_transformBaseProductToOrderProduct = require("./utils/transformBaseProductToOrderProduct");
|
|
46
|
-
var import_quotationPrice = require("./utils/quotationPrice");
|
|
47
44
|
var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
48
45
|
constructor(name, version) {
|
|
49
46
|
super(name, version);
|
|
@@ -51,21 +48,20 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
51
48
|
this.defaultVersion = "1.0.0";
|
|
52
49
|
this.isSolution = true;
|
|
53
50
|
this.initializeOptions = {};
|
|
51
|
+
// LoggerManager 实例
|
|
54
52
|
this.store = {
|
|
55
53
|
order: void 0
|
|
56
54
|
};
|
|
57
55
|
this.otherParams = {};
|
|
58
56
|
// 当前缓存中已加载的最新 SalesDetail;只读 getter 走它对外暴露详情数据。
|
|
59
57
|
this.currentSalesDetail = null;
|
|
60
|
-
this.discountConfigCacheKey = null;
|
|
61
|
-
this.hasManualDiscountSelection = false;
|
|
62
58
|
}
|
|
63
59
|
/**
|
|
64
60
|
* 子类可覆盖此方法以追加/收敛要注册的子模块。
|
|
65
|
-
* 默认包含通用销售模块:products / order / salesSummary / schedule / payment
|
|
61
|
+
* 默认包含通用销售模块:products / order / salesSummary / schedule / payment。
|
|
66
62
|
*/
|
|
67
63
|
getRegisteredModuleNames() {
|
|
68
|
-
return ["products", "order", "salesSummary", "schedule", "payment"
|
|
64
|
+
return ["products", "order", "salesSummary", "schedule", "payment"];
|
|
69
65
|
}
|
|
70
66
|
/**
|
|
71
67
|
* 记录信息日志
|
|
@@ -109,48 +105,13 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
109
105
|
get payment() {
|
|
110
106
|
return this.store.payment;
|
|
111
107
|
}
|
|
112
|
-
getCurrentOrderCustomerId() {
|
|
113
|
-
var _a, _b;
|
|
114
|
-
const tempOrder = (_b = (_a = this.store.order) == null ? void 0 : _a.getTempOrder) == null ? void 0 : _b.call(_a);
|
|
115
|
-
const customerId = tempOrder == null ? void 0 : tempOrder.customer_id;
|
|
116
|
-
if (customerId === null || customerId === void 0)
|
|
117
|
-
return void 0;
|
|
118
|
-
return customerId;
|
|
119
|
-
}
|
|
120
|
-
applyQuotationScheduleResolver(quotation) {
|
|
121
|
-
const scheduleModule = this.store.schedule;
|
|
122
|
-
if (!scheduleModule)
|
|
123
|
-
return;
|
|
124
|
-
quotation.setScheduleResolver((id) => {
|
|
125
|
-
var _a;
|
|
126
|
-
const schedules = ((_a = scheduleModule.getScheduleListByIds) == null ? void 0 : _a.call(scheduleModule, [id])) || [];
|
|
127
|
-
return schedules[0];
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
async loadQuotationForPriceQuery(params) {
|
|
131
|
-
var _a;
|
|
132
|
-
if (!params.quotation)
|
|
133
|
-
return;
|
|
134
|
-
this.applyQuotationScheduleResolver(params.quotation);
|
|
135
|
-
await params.quotation.loadQuotations({
|
|
136
|
-
channel: params.channel || ((_a = this.otherParams) == null ? void 0 : _a.channel),
|
|
137
|
-
customer_id: params.customer_id
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
getSubmitOrderSalesChannel() {
|
|
141
|
-
var _a;
|
|
142
|
-
return (_a = this.otherParams) == null ? void 0 : _a.channel;
|
|
143
|
-
}
|
|
144
108
|
/**
|
|
145
109
|
* 工厂入口:根据子模块名实例化对应模块。
|
|
146
110
|
* 默认使用 BookingByStep 公共 `createModule`。子类若需引入额外类型(如 customer),
|
|
147
111
|
* 可覆盖此方法并把未识别的 name 委托给 `super.createSubModule(name)`。
|
|
148
112
|
*/
|
|
149
113
|
createSubModule(moduleName) {
|
|
150
|
-
|
|
151
|
-
return new import_Quotation.QuotationModule(`${this.name}_quotation`);
|
|
152
|
-
}
|
|
153
|
-
return (0, import_types2.createModule)(moduleName, this.name);
|
|
114
|
+
return (0, import_types.createModule)(moduleName, this.name);
|
|
154
115
|
}
|
|
155
116
|
getSubModuleHooks(moduleName) {
|
|
156
117
|
var _a, _b;
|
|
@@ -179,43 +140,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
179
140
|
return {};
|
|
180
141
|
}
|
|
181
142
|
}
|
|
182
|
-
getAppData(key) {
|
|
183
|
-
var _a, _b, _c, _d, _e, _f;
|
|
184
|
-
const getData = (_b = (_a = this.appPlugin).getData) == null ? void 0 : _b.call(_a);
|
|
185
|
-
if (typeof getData === "function")
|
|
186
|
-
return getData(key);
|
|
187
|
-
const app = this.appPlugin.getApp();
|
|
188
|
-
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");
|
|
189
|
-
return coreData == null ? void 0 : coreData[key];
|
|
190
|
-
}
|
|
191
|
-
syncAppDataToTempOrder(tempOrder) {
|
|
192
|
-
const taxCountryCode = this.getAppData("tax_country_code");
|
|
193
|
-
const currencyCode = this.getAppData("shop_currency_code");
|
|
194
|
-
const currencySymbol = this.getAppData("shop_symbol");
|
|
195
|
-
let isChanged = false;
|
|
196
|
-
if (taxCountryCode !== void 0) {
|
|
197
|
-
const nextTaxCountryCode = String(taxCountryCode || "");
|
|
198
|
-
if (tempOrder.tax_country_code !== nextTaxCountryCode) {
|
|
199
|
-
tempOrder.tax_country_code = nextTaxCountryCode;
|
|
200
|
-
isChanged = true;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
if (currencyCode !== void 0) {
|
|
204
|
-
const nextCurrencyCode = String(currencyCode || "");
|
|
205
|
-
if (tempOrder.currency_code !== nextCurrencyCode) {
|
|
206
|
-
tempOrder.currency_code = nextCurrencyCode;
|
|
207
|
-
isChanged = true;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
if (currencySymbol !== void 0) {
|
|
211
|
-
const nextCurrencySymbol = String(currencySymbol || "");
|
|
212
|
-
if (tempOrder.currency_symbol !== nextCurrencySymbol) {
|
|
213
|
-
tempOrder.currency_symbol = nextCurrencySymbol;
|
|
214
|
-
isChanged = true;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
return isChanged;
|
|
218
|
-
}
|
|
219
143
|
async initialize(core, options = {}) {
|
|
220
144
|
var _a;
|
|
221
145
|
this.core = core;
|
|
@@ -224,11 +148,11 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
224
148
|
this.cacheId = (_a = this.otherParams) == null ? void 0 : _a.cacheId;
|
|
225
149
|
this.window = core.getPlugin("window");
|
|
226
150
|
this.request = core.getPlugin("request");
|
|
227
|
-
|
|
228
|
-
if (!
|
|
151
|
+
const appPlugin = core.getPlugin("app");
|
|
152
|
+
if (!appPlugin) {
|
|
229
153
|
throw new Error("Checkout 解决方案需要 app 插件支持");
|
|
230
154
|
}
|
|
231
|
-
const app =
|
|
155
|
+
const app = appPlugin.getApp();
|
|
232
156
|
this.logger = app.logger;
|
|
233
157
|
const targetCacheData = this.readSessionCacheData();
|
|
234
158
|
const moduleNames = this.getRegisteredModuleNames();
|
|
@@ -362,13 +286,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
362
286
|
const result = ((_a = this.store.order) == null ? void 0 : _a.getTempOrder()) || null;
|
|
363
287
|
return result;
|
|
364
288
|
}
|
|
365
|
-
async replaceTempOrder(tempOrder) {
|
|
366
|
-
if (!this.store.order)
|
|
367
|
-
throw new Error("order 模块未初始化");
|
|
368
|
-
const nextTempOrder = await this.store.order.replaceTempOrder(tempOrder);
|
|
369
|
-
await this.effectsEmit("onTempOrderReplaced", { tempOrder: nextTempOrder });
|
|
370
|
-
return nextTempOrder;
|
|
371
|
-
}
|
|
372
289
|
getOrderIdentity() {
|
|
373
290
|
if (!this.store.order)
|
|
374
291
|
return null;
|
|
@@ -394,21 +311,16 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
394
311
|
return "";
|
|
395
312
|
return this.store.order.getTempOrderNote();
|
|
396
313
|
}
|
|
397
|
-
updateTempOrderNote(note
|
|
314
|
+
updateTempOrderNote(note) {
|
|
398
315
|
try {
|
|
399
316
|
if (!this.store.order)
|
|
400
317
|
throw new Error("order 模块未初始化");
|
|
401
|
-
const result = this.store.order.updateTempOrderNote(note
|
|
318
|
+
const result = this.store.order.updateTempOrderNote(note);
|
|
402
319
|
return result;
|
|
403
320
|
} catch (error) {
|
|
404
321
|
throw error;
|
|
405
322
|
}
|
|
406
323
|
}
|
|
407
|
-
updateRemoteOrderNote(orderId, note) {
|
|
408
|
-
if (!this.store.order)
|
|
409
|
-
throw new Error("order 模块未初始化");
|
|
410
|
-
this.store.order.syncTempOrderNoteToRemote(orderId, note);
|
|
411
|
-
}
|
|
412
324
|
updateTempOrderShopDiscount(amount) {
|
|
413
325
|
if (!this.store.order)
|
|
414
326
|
throw new Error("order 模块未初始化");
|
|
@@ -419,18 +331,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
419
331
|
throw new Error("order 模块未初始化");
|
|
420
332
|
return this.store.order.updateTempOrderContactsInfo(contactsInfo);
|
|
421
333
|
}
|
|
422
|
-
/** @deprecated OrderModule 不再负责 tempOrder localStorage 持久化。 */
|
|
423
|
-
setEnableTempOrderPersist(enabled) {
|
|
424
|
-
if (!this.store.order)
|
|
425
|
-
throw new Error("order 模块未初始化");
|
|
426
|
-
this.store.order.setEnableTempOrderPersist(enabled);
|
|
427
|
-
}
|
|
428
|
-
/** @deprecated OrderModule 不再负责 tempOrder localStorage 持久化。 */
|
|
429
|
-
isTempOrderPersistEnabled() {
|
|
430
|
-
if (!this.store.order)
|
|
431
|
-
return false;
|
|
432
|
-
return this.store.order.isTempOrderPersistEnabled();
|
|
433
|
-
}
|
|
434
334
|
ensureTempOrder() {
|
|
435
335
|
if (!this.store.order)
|
|
436
336
|
throw new Error("order 模块未初始化");
|
|
@@ -442,10 +342,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
442
342
|
if (!this.store.order)
|
|
443
343
|
throw new Error("order 模块未初始化");
|
|
444
344
|
const tempOrder = await this.store.order.addNewOrder();
|
|
445
|
-
if (this.syncAppDataToTempOrder(tempOrder)) {
|
|
446
|
-
this.store.order.persistTempOrder();
|
|
447
|
-
await this.store.order.saveDraft();
|
|
448
|
-
}
|
|
449
345
|
return tempOrder;
|
|
450
346
|
} catch (error) {
|
|
451
347
|
throw error;
|
|
@@ -464,43 +360,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
464
360
|
throw new Error("scanOrder 解决方案需要 order 模块支持");
|
|
465
361
|
}
|
|
466
362
|
const tempOrder = this.store.order.restoreOrder();
|
|
467
|
-
this.currentSalesDetail = null;
|
|
468
|
-
this.discountConfigCacheKey = null;
|
|
469
|
-
this.hasManualDiscountSelection = false;
|
|
470
|
-
await this.effectsEmit("onTempOrderReplaced", { tempOrder });
|
|
471
|
-
if (this.syncAppDataToTempOrder(tempOrder)) {
|
|
472
|
-
this.store.order.persistTempOrder();
|
|
473
|
-
await this.store.order.saveDraft();
|
|
474
|
-
}
|
|
475
|
-
return tempOrder;
|
|
476
|
-
} catch (error) {
|
|
477
|
-
throw error;
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
/**
|
|
481
|
-
* 仅清空 tempOrder 购物车行(products / bookings / discount_list)。
|
|
482
|
-
* 同步清空内存中的 salesDetail 商品/预约视图,避免编辑态仍读到旧 bookings。
|
|
483
|
-
*/
|
|
484
|
-
async clearOrderCartLines() {
|
|
485
|
-
try {
|
|
486
|
-
if (!this.store.order)
|
|
487
|
-
throw new Error("order 模块未初始化");
|
|
488
|
-
const tempOrder = await this.store.order.clearOrderCartLines();
|
|
489
|
-
if (this.currentSalesDetail) {
|
|
490
|
-
this.currentSalesDetail = {
|
|
491
|
-
...this.currentSalesDetail,
|
|
492
|
-
products: [],
|
|
493
|
-
bookings: [],
|
|
494
|
-
rootBooking: null,
|
|
495
|
-
bookingsByProductUid: {},
|
|
496
|
-
discount_list: []
|
|
497
|
-
};
|
|
498
|
-
}
|
|
499
|
-
await this.effectsEmit("onTempOrderReplaced", { tempOrder });
|
|
500
|
-
if (this.syncAppDataToTempOrder(tempOrder)) {
|
|
501
|
-
this.store.order.persistTempOrder();
|
|
502
|
-
await this.store.order.saveDraft();
|
|
503
|
-
}
|
|
504
363
|
return tempOrder;
|
|
505
364
|
} catch (error) {
|
|
506
365
|
throw error;
|
|
@@ -522,246 +381,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
522
381
|
throw error;
|
|
523
382
|
}
|
|
524
383
|
}
|
|
525
|
-
getHistoricalProductDiscountList(products) {
|
|
526
|
-
const historyDiscountList = [];
|
|
527
|
-
products.forEach((item) => {
|
|
528
|
-
if (!this.isPersistedOrderProduct(item))
|
|
529
|
-
return;
|
|
530
|
-
(item.discount_list || []).forEach((discount) => {
|
|
531
|
-
var _a, _b, _c, _d, _e, _f;
|
|
532
|
-
const discountId = ((_a = discount.discount) == null ? void 0 : _a.resource_id) || discount.id;
|
|
533
|
-
if (!discountId || !["good_pass", "discount_card"].includes(discount.type))
|
|
534
|
-
return;
|
|
535
|
-
const quantity = item.quantity || item.num || item.product_quantity || 1;
|
|
536
|
-
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);
|
|
537
|
-
const index = historyDiscountList.findIndex((n) => n.id === discountId);
|
|
538
|
-
if (index !== -1) {
|
|
539
|
-
historyDiscountList[index] = {
|
|
540
|
-
...historyDiscountList[index],
|
|
541
|
-
amount: new import_decimal.default(historyDiscountList[index].amount || 0).plus(discount.amount || 0).toNumber(),
|
|
542
|
-
savedAmount: savedAmount.plus(historyDiscountList[index].savedAmount || 0).toNumber()
|
|
543
|
-
};
|
|
544
|
-
return;
|
|
545
|
-
}
|
|
546
|
-
historyDiscountList.push({
|
|
547
|
-
...discount,
|
|
548
|
-
id: discountId,
|
|
549
|
-
tag: discount.tag || discount.type,
|
|
550
|
-
name: discount.name || ((_d = (_c = discount.discount) == null ? void 0 : _c.title) == null ? void 0 : _d.auto),
|
|
551
|
-
format_title: ((_e = discount.discount) == null ? void 0 : _e.title) || discount.format_title,
|
|
552
|
-
isEditMode: true,
|
|
553
|
-
limited_relation_product_data: {},
|
|
554
|
-
savedAmount: savedAmount.toNumber(),
|
|
555
|
-
isAvailable: true,
|
|
556
|
-
isDisabled: true,
|
|
557
|
-
isSelected: true,
|
|
558
|
-
product_id: ((_f = discount.discount) == null ? void 0 : _f.product_id) || discount.product_id
|
|
559
|
-
});
|
|
560
|
-
});
|
|
561
|
-
});
|
|
562
|
-
return historyDiscountList;
|
|
563
|
-
}
|
|
564
|
-
isPersistedOrderProduct(product) {
|
|
565
|
-
const orderDetailId = product.order_detail_id ?? product.orderDetailId;
|
|
566
|
-
if (orderDetailId !== void 0 && orderDetailId !== null && orderDetailId !== "") {
|
|
567
|
-
return true;
|
|
568
|
-
}
|
|
569
|
-
const bookingId = product.booking_id ?? product.bookingId;
|
|
570
|
-
return bookingId !== void 0 && bookingId !== null && bookingId !== "";
|
|
571
|
-
}
|
|
572
|
-
mergeHistoricalDiscountList(discountList, products) {
|
|
573
|
-
const historyDiscountList = this.getHistoricalProductDiscountList(products);
|
|
574
|
-
const historyIds = new Set(historyDiscountList.map((discount) => discount.id));
|
|
575
|
-
return [
|
|
576
|
-
...historyDiscountList,
|
|
577
|
-
...(discountList || []).filter((discount) => !historyIds.has(discount.id))
|
|
578
|
-
];
|
|
579
|
-
}
|
|
580
|
-
mergeCurrentDiscountSelectionState(discountList, currentDiscountList) {
|
|
581
|
-
if (!currentDiscountList.length)
|
|
582
|
-
return discountList;
|
|
583
|
-
const currentDiscountMap = new Map(
|
|
584
|
-
currentDiscountList.map((discount) => [discount.id, discount])
|
|
585
|
-
);
|
|
586
|
-
return discountList.map((discount) => {
|
|
587
|
-
const currentDiscount = currentDiscountMap.get(discount.id);
|
|
588
|
-
if (!currentDiscount)
|
|
589
|
-
return discount;
|
|
590
|
-
if (currentDiscount.isManualSelect) {
|
|
591
|
-
return {
|
|
592
|
-
...discount,
|
|
593
|
-
isSelected: false,
|
|
594
|
-
isManualSelect: true
|
|
595
|
-
};
|
|
596
|
-
}
|
|
597
|
-
if (currentDiscount.isSelected) {
|
|
598
|
-
return {
|
|
599
|
-
...discount,
|
|
600
|
-
isSelected: true,
|
|
601
|
-
isManualSelect: false
|
|
602
|
-
};
|
|
603
|
-
}
|
|
604
|
-
return discount;
|
|
605
|
-
});
|
|
606
|
-
}
|
|
607
|
-
async loadDiscountConfig(params) {
|
|
608
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
609
|
-
if (!this.store.order)
|
|
610
|
-
throw new Error("order 模块未初始化");
|
|
611
|
-
const tempOrder = this.store.order.ensureTempOrder();
|
|
612
|
-
const orderStore = this.store.order.store || {};
|
|
613
|
-
const discountModule = orderStore.discount;
|
|
614
|
-
const rulesModule = orderStore.rules;
|
|
615
|
-
const orderId = tempOrder.order_id || ((_b = (_a = this.getOrderIdentity) == null ? void 0 : _a.call(this)) == null ? void 0 : _b.orderId);
|
|
616
|
-
const customerId = Number(
|
|
617
|
-
(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
|
|
618
|
-
);
|
|
619
|
-
const currentDiscountList = ((_h = discountModule == null ? void 0 : discountModule.getDiscountList) == null ? void 0 : _h.call(discountModule)) || [];
|
|
620
|
-
const originalDiscountList = ((_i = discountModule == null ? void 0 : discountModule.getOriginalDiscountList) == null ? void 0 : _i.call(discountModule)) || [];
|
|
621
|
-
const hasManualDiscountSelection = this.hasManualDiscountSelection || currentDiscountList.some((discount) => discount.isManualSelect);
|
|
622
|
-
const discountAction = (params == null ? void 0 : params.action) || (orderId ? "edit" : "create");
|
|
623
|
-
const discountConfigCacheKey = [
|
|
624
|
-
customerId,
|
|
625
|
-
discountAction,
|
|
626
|
-
Number(orderId) || 0
|
|
627
|
-
].join(":");
|
|
628
|
-
let preparedDiscountList = [];
|
|
629
|
-
if (customerId && customerId !== 1) {
|
|
630
|
-
if (this.discountConfigCacheKey === discountConfigCacheKey) {
|
|
631
|
-
preparedDiscountList = originalDiscountList;
|
|
632
|
-
} else {
|
|
633
|
-
preparedDiscountList = await this.store.order.loadDiscountConfig({
|
|
634
|
-
customerId,
|
|
635
|
-
action: discountAction,
|
|
636
|
-
orderId: Number(orderId) || void 0,
|
|
637
|
-
apply: false
|
|
638
|
-
});
|
|
639
|
-
this.discountConfigCacheKey = discountConfigCacheKey;
|
|
640
|
-
await ((_j = discountModule == null ? void 0 : discountModule.setOriginalDiscountList) == null ? void 0 : _j.call(discountModule, preparedDiscountList));
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
if (hasManualDiscountSelection && currentDiscountList.length) {
|
|
644
|
-
return {
|
|
645
|
-
productList: tempOrder.products || [],
|
|
646
|
-
discountList: currentDiscountList
|
|
647
|
-
};
|
|
648
|
-
}
|
|
649
|
-
let nextDiscountList = this.mergeHistoricalDiscountList(
|
|
650
|
-
preparedDiscountList || ((_k = discountModule == null ? void 0 : discountModule.getDiscountList) == null ? void 0 : _k.call(discountModule)) || [],
|
|
651
|
-
tempOrder.products || []
|
|
652
|
-
);
|
|
653
|
-
nextDiscountList = this.mergeCurrentDiscountSelectionState(
|
|
654
|
-
nextDiscountList,
|
|
655
|
-
currentDiscountList
|
|
656
|
-
);
|
|
657
|
-
await (discountModule == null ? void 0 : discountModule.setDiscountList(nextDiscountList));
|
|
658
|
-
if (rulesModule) {
|
|
659
|
-
const holders = ((_l = tempOrder.holder) == null ? void 0 : _l.form_record_id) ? [{ form_record_id: tempOrder.holder.form_record_id }] : [];
|
|
660
|
-
const result = rulesModule.calcDiscount({
|
|
661
|
-
productList: tempOrder.products,
|
|
662
|
-
discountList: nextDiscountList,
|
|
663
|
-
holders,
|
|
664
|
-
isFormSubject: !!((_m = tempOrder.holder) == null ? void 0 : _m.type) && tempOrder.holder.type === "form",
|
|
665
|
-
orderTotalAmount: Number(((_n = orderStore.summary) == null ? void 0 : _n.total_amount) || 0)
|
|
666
|
-
}) || { productList: tempOrder.products, discountList: nextDiscountList };
|
|
667
|
-
if (result.productList) {
|
|
668
|
-
tempOrder.products = result.productList;
|
|
669
|
-
}
|
|
670
|
-
for (const product of tempOrder.products || []) {
|
|
671
|
-
const productUid = (_o = product.metadata) == null ? void 0 : _o.unique_identification_number;
|
|
672
|
-
const runtimeOrigin = productUid ? (_r = (_q = (_p = tempOrder._extend) == null ? void 0 : _p.productsByUid) == null ? void 0 : _q[productUid]) == null ? void 0 : _r.origin : void 0;
|
|
673
|
-
if ((runtimeOrigin == null ? void 0 : runtimeOrigin.isManualDiscount) || ((_s = product.metadata) == null ? void 0 : _s.is_manual_discount))
|
|
674
|
-
continue;
|
|
675
|
-
const totalPerUnitDiscount = (product.discount_list || []).reduce(
|
|
676
|
-
(sum, pd) => sum + Number(pd.amount || 0),
|
|
677
|
-
0
|
|
678
|
-
);
|
|
679
|
-
const optionSum = (0, import_utils.sumOptionUnitPrice)(product.product_option_item);
|
|
680
|
-
const sourcePrice = ((_t = product.metadata) == null ? void 0 : _t.source_product_price) ?? (((_u = product.metadata) == null ? void 0 : _u.main_product_original_price) != null ? new import_decimal.default(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : product.original_price ?? "0");
|
|
681
|
-
const newSourceSellingPrice = new import_decimal.default(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
682
|
-
const newMainSellingPrice = new import_decimal.default(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
683
|
-
if (product.metadata) {
|
|
684
|
-
product.metadata.main_product_selling_price = newMainSellingPrice;
|
|
685
|
-
product.metadata.price_schema_version = 2;
|
|
686
|
-
}
|
|
687
|
-
product.selling_price = (0, import_utils.composeLinePrice)({
|
|
688
|
-
mainPrice: newMainSellingPrice,
|
|
689
|
-
bundle: product.product_bundle
|
|
690
|
-
});
|
|
691
|
-
}
|
|
692
|
-
if (result.discountList) {
|
|
693
|
-
nextDiscountList = this.mergeHistoricalDiscountList(
|
|
694
|
-
result.discountList,
|
|
695
|
-
tempOrder.products || []
|
|
696
|
-
);
|
|
697
|
-
import_Order.OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
698
|
-
await (discountModule == null ? void 0 : discountModule.setDiscountList(nextDiscountList));
|
|
699
|
-
tempOrder.discount_list = nextDiscountList.filter((discount) => discount.isSelected);
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
const summary = await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
703
|
-
this.store.order.persistTempOrder();
|
|
704
|
-
await this.effectsEmit("onDiscountApplied", {
|
|
705
|
-
productList: tempOrder.products || [],
|
|
706
|
-
discountList: nextDiscountList,
|
|
707
|
-
selectedDiscountList: tempOrder.discount_list || [],
|
|
708
|
-
tempOrder
|
|
709
|
-
});
|
|
710
|
-
return {
|
|
711
|
-
productList: tempOrder.products || [],
|
|
712
|
-
discountList: nextDiscountList
|
|
713
|
-
};
|
|
714
|
-
}
|
|
715
|
-
async bestDiscount(cb) {
|
|
716
|
-
var _a, _b, _c, _d, _e;
|
|
717
|
-
if (!this.store.order)
|
|
718
|
-
throw new Error("order 模块未初始化");
|
|
719
|
-
const tempOrder = this.store.order.ensureTempOrder();
|
|
720
|
-
const orderStore = this.store.order.store || {};
|
|
721
|
-
const discountModule = orderStore.discount;
|
|
722
|
-
const rulesModule = orderStore.rules;
|
|
723
|
-
const originalDiscountList = ((_a = discountModule == null ? void 0 : discountModule.getOriginalDiscountList) == null ? void 0 : _a.call(discountModule)) || this.getDiscountList();
|
|
724
|
-
const currentDiscountList = ((_b = discountModule == null ? void 0 : discountModule.getDiscountList) == null ? void 0 : _b.call(discountModule)) || [];
|
|
725
|
-
let nextDiscountList = this.mergeHistoricalDiscountList(
|
|
726
|
-
originalDiscountList || [],
|
|
727
|
-
tempOrder.products || []
|
|
728
|
-
);
|
|
729
|
-
let result = {
|
|
730
|
-
productList: tempOrder.products || [],
|
|
731
|
-
discountList: nextDiscountList
|
|
732
|
-
};
|
|
733
|
-
await (discountModule == null ? void 0 : discountModule.setDiscountList(nextDiscountList));
|
|
734
|
-
if (rulesModule) {
|
|
735
|
-
const holders = ((_c = tempOrder.holder) == null ? void 0 : _c.form_record_id) ? [{ form_record_id: tempOrder.holder.form_record_id }] : [];
|
|
736
|
-
result = rulesModule.calcDiscount({
|
|
737
|
-
productList: tempOrder.products,
|
|
738
|
-
discountList: nextDiscountList,
|
|
739
|
-
holders,
|
|
740
|
-
isFormSubject: !!((_d = tempOrder.holder) == null ? void 0 : _d.type) && tempOrder.holder.type === "form",
|
|
741
|
-
orderTotalAmount: Number(((_e = orderStore.summary) == null ? void 0 : _e.total_amount) || 0)
|
|
742
|
-
}) || result;
|
|
743
|
-
if (result.productList) {
|
|
744
|
-
tempOrder.products = result.productList;
|
|
745
|
-
}
|
|
746
|
-
if (result.discountList) {
|
|
747
|
-
nextDiscountList = this.mergeHistoricalDiscountList(
|
|
748
|
-
result.discountList,
|
|
749
|
-
tempOrder.products || []
|
|
750
|
-
);
|
|
751
|
-
import_Order.OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
752
|
-
await (discountModule == null ? void 0 : discountModule.setDiscountList(nextDiscountList));
|
|
753
|
-
tempOrder.discount_list = nextDiscountList.filter((discount) => discount.isSelected);
|
|
754
|
-
result = {
|
|
755
|
-
productList: tempOrder.products,
|
|
756
|
-
discountList: nextDiscountList
|
|
757
|
-
};
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
761
|
-
this.store.order.persistTempOrder();
|
|
762
|
-
cb == null ? void 0 : cb(result);
|
|
763
|
-
return result;
|
|
764
|
-
}
|
|
765
384
|
getDiscountList() {
|
|
766
385
|
if (!this.store.order)
|
|
767
386
|
return [];
|
|
@@ -799,7 +418,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
799
418
|
isManualSelect: !params.isSelected
|
|
800
419
|
} : d
|
|
801
420
|
);
|
|
802
|
-
this.hasManualDiscountSelection = true;
|
|
803
421
|
const tempOrder = this.store.order.ensureTempOrder();
|
|
804
422
|
const orderStore = this.store.order.store || {};
|
|
805
423
|
const discountModule = orderStore.discount;
|
|
@@ -832,7 +450,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
832
450
|
for (const d of nextDiscountList) {
|
|
833
451
|
if (d.isSelected && !beforeSelectedIds.has(d.id)) {
|
|
834
452
|
d.isSelected = false;
|
|
835
|
-
d.isManualSelect = true;
|
|
836
453
|
}
|
|
837
454
|
}
|
|
838
455
|
}
|
|
@@ -873,40 +490,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
873
490
|
tempOrder.discount_list = (nextDiscountList || []).filter((d) => d.isSelected);
|
|
874
491
|
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
875
492
|
this.store.order.persistTempOrder();
|
|
876
|
-
this.effectsEmit("onDiscountApplied", {
|
|
877
|
-
productList: tempOrder.products,
|
|
878
|
-
discountList: nextDiscountList,
|
|
879
|
-
selectedDiscountList: tempOrder.discount_list,
|
|
880
|
-
tempOrder
|
|
881
|
-
});
|
|
882
|
-
} catch (error) {
|
|
883
|
-
throw error;
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
async applyDiscountCalculationResult(result) {
|
|
887
|
-
try {
|
|
888
|
-
if (!this.store.order)
|
|
889
|
-
throw new Error("order 模块未初始化");
|
|
890
|
-
if (!result)
|
|
891
|
-
return;
|
|
892
|
-
const tempOrder = this.store.order.ensureTempOrder();
|
|
893
|
-
const orderStore = this.store.order.store || {};
|
|
894
|
-
const discountModule = orderStore.discount;
|
|
895
|
-
if (result.productList) {
|
|
896
|
-
tempOrder.products = result.productList;
|
|
897
|
-
}
|
|
898
|
-
if (result.discountList) {
|
|
899
|
-
import_Order.OrderModule.populateSavedAmounts(
|
|
900
|
-
tempOrder.products,
|
|
901
|
-
result.discountList
|
|
902
|
-
);
|
|
903
|
-
await (discountModule == null ? void 0 : discountModule.setDiscountList(result.discountList));
|
|
904
|
-
tempOrder.discount_list = result.discountList.filter(
|
|
905
|
-
(discount) => discount.isSelected
|
|
906
|
-
);
|
|
907
|
-
}
|
|
908
|
-
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
909
|
-
this.store.order.persistTempOrder();
|
|
910
493
|
} catch (error) {
|
|
911
494
|
throw error;
|
|
912
495
|
}
|
|
@@ -921,7 +504,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
921
504
|
* payments 会交给 OrderModule 统一映射为 Sales 协议支付项。
|
|
922
505
|
*/
|
|
923
506
|
async submitSalesOrder(params) {
|
|
924
|
-
var _a, _b, _c;
|
|
507
|
+
var _a, _b, _c, _d;
|
|
925
508
|
if (!this.store.order) {
|
|
926
509
|
throw new Error("BaseSales 解决方案需要 order 模块支持");
|
|
927
510
|
}
|
|
@@ -930,57 +513,19 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
930
513
|
cacheId: this.cacheId,
|
|
931
514
|
platform: (_a = this.otherParams) == null ? void 0 : _a.platform,
|
|
932
515
|
businessCode: (_b = this.otherParams) == null ? void 0 : _b.businessCode,
|
|
933
|
-
channel: this.
|
|
934
|
-
type: (
|
|
516
|
+
channel: (_c = this.otherParams) == null ? void 0 : _c.channel,
|
|
517
|
+
type: (_d = this.otherParams) == null ? void 0 : _d.type,
|
|
935
518
|
...(params == null ? void 0 : params.payments) !== void 0 ? { payments: params.payments } : {},
|
|
936
519
|
...(params == null ? void 0 : params.paymentStatus) !== void 0 ? { paymentStatus: params.paymentStatus } : {},
|
|
937
520
|
...(params == null ? void 0 : params.smallTicketDataFlag) !== void 0 ? { smallTicketDataFlag: params.smallTicketDataFlag } : {},
|
|
938
521
|
...(params == null ? void 0 : params.enhancePayload) !== void 0 ? { enhancePayload: params.enhancePayload } : {}
|
|
939
522
|
};
|
|
940
|
-
console.log(submitParams, "submitParams123");
|
|
941
523
|
return this.store.order.submitTempOrder(submitParams);
|
|
942
524
|
}
|
|
943
525
|
async syncPaymentsToOrder(params) {
|
|
944
526
|
if (!this.store.order)
|
|
945
527
|
throw new Error("order 模块未初始化");
|
|
946
|
-
|
|
947
|
-
const syncParams = {
|
|
948
|
-
...params,
|
|
949
|
-
...channel !== void 0 ? { channel } : {}
|
|
950
|
-
};
|
|
951
|
-
const syncState = this.store.order.getOrderSyncState();
|
|
952
|
-
if (params.submitWhenPaid && syncState === "submitting") {
|
|
953
|
-
return this.store.order.syncPaymentsToOrder(syncParams);
|
|
954
|
-
}
|
|
955
|
-
const payments = params.payments || [];
|
|
956
|
-
await this.effectsEmit(import_types.BaseSalesHookNames.onPaymentSyncStart, {
|
|
957
|
-
payments,
|
|
958
|
-
params: syncParams,
|
|
959
|
-
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
960
|
-
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
961
|
-
});
|
|
962
|
-
try {
|
|
963
|
-
const syncResult = await this.store.order.syncPaymentsToOrder(syncParams);
|
|
964
|
-
await this.effectsEmit(import_types.BaseSalesHookNames.onPaymentSyncEnd, {
|
|
965
|
-
ok: true,
|
|
966
|
-
syncResult,
|
|
967
|
-
payments: this.store.order.getOrderPayments(),
|
|
968
|
-
params: syncParams,
|
|
969
|
-
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
970
|
-
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
971
|
-
});
|
|
972
|
-
return syncResult;
|
|
973
|
-
} catch (error) {
|
|
974
|
-
await this.effectsEmit(import_types.BaseSalesHookNames.onPaymentSyncEnd, {
|
|
975
|
-
ok: false,
|
|
976
|
-
error,
|
|
977
|
-
payments: this.store.order.getOrderPayments(),
|
|
978
|
-
params: syncParams,
|
|
979
|
-
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
980
|
-
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
981
|
-
});
|
|
982
|
-
throw error;
|
|
983
|
-
}
|
|
528
|
+
return this.store.order.syncPaymentsToOrder(params);
|
|
984
529
|
}
|
|
985
530
|
/** 读取当前 BaseSales 订单上下文中的 Sales 协议支付项。 */
|
|
986
531
|
getOrderPayments() {
|
|
@@ -998,23 +543,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
998
543
|
addOrderPayment(payment) {
|
|
999
544
|
if (!this.store.order)
|
|
1000
545
|
throw new Error("order 模块未初始化");
|
|
1001
|
-
|
|
1002
|
-
const amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
1003
|
-
const syncState = this.store.order.getOrderSyncState();
|
|
1004
|
-
if (amountSnapshot && syncState !== "submitting") {
|
|
1005
|
-
const paymentStatus = Number(amountSnapshot.amountGap || 0) <= 0 ? "paid" : "partially_paid";
|
|
1006
|
-
void this.syncPaymentsToOrder({
|
|
1007
|
-
payments,
|
|
1008
|
-
paymentStatus,
|
|
1009
|
-
submitWhenPaid: true,
|
|
1010
|
-
smallTicketDataFlag: 1
|
|
1011
|
-
}).catch((error) => {
|
|
1012
|
-
this.logError("auto sync payments failed", {
|
|
1013
|
-
error: error instanceof Error ? error.message : String(error)
|
|
1014
|
-
});
|
|
1015
|
-
});
|
|
1016
|
-
}
|
|
1017
|
-
return payments;
|
|
546
|
+
return this.store.order.addOrderPayment(payment);
|
|
1018
547
|
}
|
|
1019
548
|
/** 更新当前订单中的指定支付项。 */
|
|
1020
549
|
updateOrderPayment(paymentIdentity, updates) {
|
|
@@ -1035,12 +564,11 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1035
564
|
return this.store.order.updateVoucherOrderPayments(payments);
|
|
1036
565
|
}
|
|
1037
566
|
getWalletProductList() {
|
|
1038
|
-
var _a, _b
|
|
567
|
+
var _a, _b;
|
|
1039
568
|
const tempOrder = (_a = this.store.order) == null ? void 0 : _a.getTempOrder();
|
|
1040
569
|
if (!((_b = tempOrder == null ? void 0 : tempOrder.products) == null ? void 0 : _b.length))
|
|
1041
570
|
return [];
|
|
1042
|
-
|
|
1043
|
-
return products.map((product) => {
|
|
571
|
+
return tempOrder.products.map((product) => {
|
|
1044
572
|
const metadata = product.metadata || {};
|
|
1045
573
|
return {
|
|
1046
574
|
product_id: product.product_id,
|
|
@@ -1050,7 +578,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1050
578
|
is_charge_tax: product.is_charge_tax ?? 0,
|
|
1051
579
|
tax_fee: product.tax_fee,
|
|
1052
580
|
selling_price: Number(product.selling_price || 0),
|
|
1053
|
-
discount_list: product.discount_list || [],
|
|
1054
581
|
holder_id: product.holder_id ?? metadata.holder_id,
|
|
1055
582
|
original_price: product.original_price,
|
|
1056
583
|
main_product_original_price: metadata.main_product_original_price ?? product.original_price,
|
|
@@ -1064,10 +591,8 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1064
591
|
const bundleMetadata = bundle.metadata || {};
|
|
1065
592
|
return {
|
|
1066
593
|
is_price_include_tax: tempOrder.is_price_include_tax,
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
bundle_product_id: bundle.bundle_product_id ?? bundle._bundle_product_id,
|
|
1070
|
-
bundle_group_id: bundle.bundle_group_id ?? bundle.group_id,
|
|
594
|
+
bundle_id: bundle.bundle_id,
|
|
595
|
+
bundle_product_id: bundle.bundle_product_id,
|
|
1071
596
|
bundle_variant_id: bundle.bundle_variant_id,
|
|
1072
597
|
price_type: bundle.price_type,
|
|
1073
598
|
price_type_ext: bundle.price_type_ext,
|
|
@@ -1206,20 +731,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1206
731
|
transformBaseProductToOrderProduct(params) {
|
|
1207
732
|
return (0, import_transformBaseProductToOrderProduct.transformBaseProductToOrderProduct)(params);
|
|
1208
733
|
}
|
|
1209
|
-
async calculateProductBookingPrice(params) {
|
|
1210
|
-
const quotation = this.store.quotation;
|
|
1211
|
-
const customerId = params.customer_id ?? this.getCurrentOrderCustomerId();
|
|
1212
|
-
await this.loadQuotationForPriceQuery({
|
|
1213
|
-
quotation,
|
|
1214
|
-
customer_id: customerId,
|
|
1215
|
-
channel: params.channel
|
|
1216
|
-
});
|
|
1217
|
-
return (0, import_quotationPrice.calculateBaseSalesProductBookingPrice)({
|
|
1218
|
-
...params,
|
|
1219
|
-
customer_id: customerId,
|
|
1220
|
-
quotation
|
|
1221
|
-
});
|
|
1222
|
-
}
|
|
1223
734
|
async addProductToOrder(product, booking) {
|
|
1224
735
|
try {
|
|
1225
736
|
if (!this.store.order)
|
|
@@ -1230,35 +741,16 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1230
741
|
throw error;
|
|
1231
742
|
}
|
|
1232
743
|
}
|
|
1233
|
-
async
|
|
744
|
+
async updateProductInOrder(params) {
|
|
1234
745
|
try {
|
|
1235
746
|
if (!this.store.order)
|
|
1236
747
|
throw new Error("order 模块未初始化");
|
|
1237
|
-
const products = await this.store.order.
|
|
748
|
+
const products = await this.store.order.updateProductInOrder(params);
|
|
1238
749
|
return products;
|
|
1239
750
|
} catch (error) {
|
|
1240
751
|
throw error;
|
|
1241
752
|
}
|
|
1242
753
|
}
|
|
1243
|
-
async updateOrderProductQuantity(params) {
|
|
1244
|
-
try {
|
|
1245
|
-
if (!this.store.order)
|
|
1246
|
-
throw new Error("order 模块未初始化");
|
|
1247
|
-
const products = await this.store.order.updateOrderProductQuantity(params);
|
|
1248
|
-
return products;
|
|
1249
|
-
} catch (error) {
|
|
1250
|
-
throw error;
|
|
1251
|
-
}
|
|
1252
|
-
}
|
|
1253
|
-
updateOrderBooking(params) {
|
|
1254
|
-
try {
|
|
1255
|
-
if (!this.store.order)
|
|
1256
|
-
throw new Error("order 模块未初始化");
|
|
1257
|
-
return this.store.order.updateOrderBooking(params);
|
|
1258
|
-
} catch (error) {
|
|
1259
|
-
throw error;
|
|
1260
|
-
}
|
|
1261
|
-
}
|
|
1262
754
|
/**
|
|
1263
755
|
* 设置单行商品备注(与整单 `updateTempOrderNote` 区分)。
|
|
1264
756
|
* 多行同 SKU 时必须传入与删除/更新一致的 unique_identification_number。
|
|
@@ -1278,7 +770,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1278
770
|
}
|
|
1279
771
|
if (identity.product_bundle !== void 0)
|
|
1280
772
|
params.product_bundle = identity.product_bundle;
|
|
1281
|
-
const products = await this.
|
|
773
|
+
const products = await this.updateProductInOrder(params);
|
|
1282
774
|
return products;
|
|
1283
775
|
} catch (error) {
|
|
1284
776
|
throw error;
|