@pisell/pisellos 2.2.178 → 2.2.180
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 -87
- package/dist/modules/Order/index.js +501 -1357
- package/dist/modules/Order/types.d.ts +19 -198
- package/dist/modules/Order/types.js +0 -31
- package/dist/modules/Order/utils.d.ts +1 -50
- package/dist/modules/Order/utils.js +32 -261
- 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/SalesSummary/utils.js +7 -21
- 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 +29 -87
- package/dist/server/modules/order/index.d.ts +0 -23
- package/dist/server/modules/order/index.js +46 -123
- package/dist/server/modules/order/types.d.ts +2 -0
- 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 -89
- package/dist/solution/BaseSales/index.js +375 -1494
- package/dist/solution/BaseSales/types.d.ts +1 -67
- package/dist/solution/BaseSales/types.js +1 -3
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +1 -1
- 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 -780
- package/dist/solution/BookingTicket/types.d.ts +0 -2
- package/dist/solution/BookingTicket/types.js +0 -3
- package/dist/solution/BookingTicket/utils/cartView.js +2 -4
- 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/model/strategy/adapter/promotion/index.js +0 -49
- 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 -87
- package/lib/modules/Order/index.js +150 -677
- package/lib/modules/Order/types.d.ts +19 -198
- package/lib/modules/Order/types.js +0 -1
- package/lib/modules/Order/utils.d.ts +1 -50
- package/lib/modules/Order/utils.js +22 -229
- 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/SalesSummary/utils.js +7 -21
- 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 +4 -41
- package/lib/server/modules/order/index.d.ts +0 -23
- package/lib/server/modules/order/index.js +14 -46
- package/lib/server/modules/order/types.d.ts +2 -0
- 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 -89
- package/lib/solution/BaseSales/index.js +22 -736
- package/lib/solution/BaseSales/types.d.ts +1 -67
- package/lib/solution/BaseSales/types.js +1 -3
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +1 -0
- 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 -352
- package/lib/solution/BookingTicket/types.d.ts +0 -2
- package/lib/solution/BookingTicket/types.js +0 -6
- package/lib/solution/BookingTicket/utils/cartView.js +2 -4
- 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/cartPromotion.d.ts +0 -275
- package/dist/solution/BaseSales/utils/cartPromotion.js +0 -1258
- 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/cartPromotion.d.ts +0 -275
- package/lib/solution/BaseSales/utils/cartPromotion.js +0 -836
- 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,182 +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
|
-
getPriceQueryProductId(product) {
|
|
141
|
-
const productId = Number((product == null ? void 0 : product.product_id) ?? (product == null ? void 0 : product.id));
|
|
142
|
-
if (!Number.isFinite(productId))
|
|
143
|
-
return null;
|
|
144
|
-
return productId;
|
|
145
|
-
}
|
|
146
|
-
getPriceQuerySchedule(params) {
|
|
147
|
-
const booking = params.booking || {};
|
|
148
|
-
if (typeof booking.start_date === "string" && booking.start_date.trim()) {
|
|
149
|
-
const scheduleDate = booking.start_date.trim();
|
|
150
|
-
const startTime = typeof booking.start_time === "string" && booking.start_time.trim() ? booking.start_time.trim() : "00:00:00";
|
|
151
|
-
const datetime = (0, import_dayjs.default)(`${scheduleDate} ${startTime}`);
|
|
152
|
-
return {
|
|
153
|
-
schedule_date: scheduleDate,
|
|
154
|
-
schedule_datetime: datetime.isValid() ? datetime.format("YYYY-MM-DD HH:mm:ss") : `${scheduleDate} ${startTime}`
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
if (typeof params.datetime === "string" && params.datetime.trim()) {
|
|
158
|
-
const datetime = (0, import_dayjs.default)(params.datetime.trim());
|
|
159
|
-
if (datetime.isValid()) {
|
|
160
|
-
return {
|
|
161
|
-
schedule_date: datetime.format("YYYY-MM-DD"),
|
|
162
|
-
schedule_datetime: datetime.format("YYYY-MM-DD HH:mm:ss")
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
const now = (0, import_dayjs.default)();
|
|
167
|
-
return {
|
|
168
|
-
schedule_date: now.format("YYYY-MM-DD"),
|
|
169
|
-
schedule_datetime: now.format("YYYY-MM-DD HH:mm:ss")
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
async loadProductForPriceQuery(params, customerId) {
|
|
173
|
-
var _a, _b;
|
|
174
|
-
const product = params.product || {};
|
|
175
|
-
const productId = this.getPriceQueryProductId(product);
|
|
176
|
-
if (productId === null || !this.request)
|
|
177
|
-
return null;
|
|
178
|
-
const schedule = this.getPriceQuerySchedule(params);
|
|
179
|
-
try {
|
|
180
|
-
const response = await this.request.post("/product/query", {
|
|
181
|
-
ids: [productId],
|
|
182
|
-
open_quotation: 1,
|
|
183
|
-
open_bundle: 1,
|
|
184
|
-
status: "published",
|
|
185
|
-
num: 1,
|
|
186
|
-
skip: 1,
|
|
187
|
-
customer_id: customerId,
|
|
188
|
-
schedule_date: schedule.schedule_date,
|
|
189
|
-
schedule_datetime: schedule.schedule_datetime,
|
|
190
|
-
application_code: params.channel || ((_a = this.otherParams) == null ? void 0 : _a.channel)
|
|
191
|
-
}, {
|
|
192
|
-
osServer: true,
|
|
193
|
-
customToast: () => {
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
const list = ((_b = response == null ? void 0 : response.data) == null ? void 0 : _b.list) || (response == null ? void 0 : response.list) || [];
|
|
197
|
-
if (!Array.isArray(list))
|
|
198
|
-
return null;
|
|
199
|
-
return list.find((item) => Number((item == null ? void 0 : item.id) ?? (item == null ? void 0 : item.product_id)) === productId) || null;
|
|
200
|
-
} catch (error) {
|
|
201
|
-
this.logWarning("loadProductForPriceQuery: 商品重查失败,使用入参 fallback", {
|
|
202
|
-
productId,
|
|
203
|
-
error: error instanceof Error ? error.message : String(error)
|
|
204
|
-
});
|
|
205
|
-
return null;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
getAuthoritativeBundleItems(product) {
|
|
209
|
-
if (Array.isArray(product == null ? void 0 : product.product_bundle))
|
|
210
|
-
return product.product_bundle;
|
|
211
|
-
const groups = Array.isArray(product == null ? void 0 : product.bundle_group) ? product.bundle_group : Array.isArray(product == null ? void 0 : product.bundleGroup) ? product.bundleGroup : [];
|
|
212
|
-
return groups.flatMap((group) => {
|
|
213
|
-
const items = Array.isArray(group == null ? void 0 : group.bundle_item) ? group.bundle_item : Array.isArray(group == null ? void 0 : group.bundleItem) ? group.bundleItem : [];
|
|
214
|
-
return items.map((item) => ({
|
|
215
|
-
...item,
|
|
216
|
-
group_id: (item == null ? void 0 : item.group_id) ?? (group == null ? void 0 : group.id),
|
|
217
|
-
bundle_group_id: (item == null ? void 0 : item.bundle_group_id) ?? (item == null ? void 0 : item.group_id) ?? (group == null ? void 0 : group.id)
|
|
218
|
-
}));
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
findAuthoritativeBundleItem(bundle, candidates) {
|
|
222
|
-
const bundleId = bundle.bundle_id ?? bundle.id;
|
|
223
|
-
if (bundleId != null) {
|
|
224
|
-
const matchedById = candidates.find((item) => String((item == null ? void 0 : item.bundle_id) ?? (item == null ? void 0 : item.id)) === String(bundleId));
|
|
225
|
-
if (matchedById)
|
|
226
|
-
return matchedById;
|
|
227
|
-
}
|
|
228
|
-
const productId = bundle.bundle_product_id ?? bundle._bundle_product_id;
|
|
229
|
-
const groupId = bundle.bundle_group_id ?? bundle.group_id;
|
|
230
|
-
return candidates.find((item) => {
|
|
231
|
-
const itemProductId = (item == null ? void 0 : item.bundle_product_id) ?? (item == null ? void 0 : item._bundle_product_id);
|
|
232
|
-
const itemGroupId = (item == null ? void 0 : item.bundle_group_id) ?? (item == null ? void 0 : item.group_id);
|
|
233
|
-
if (productId == null || String(itemProductId) !== String(productId))
|
|
234
|
-
return false;
|
|
235
|
-
if (groupId == null)
|
|
236
|
-
return true;
|
|
237
|
-
return String(itemGroupId) === String(groupId);
|
|
238
|
-
}) || null;
|
|
239
|
-
}
|
|
240
|
-
getAuthoritativeBundleUnitPrice(bundle) {
|
|
241
|
-
return bundle.price ?? bundle.bundle_selling_price ?? bundle.custom_price ?? bundle.product_price ?? bundle.base_price;
|
|
242
|
-
}
|
|
243
|
-
mergeProductForPriceQuery(product, authoritativeProduct) {
|
|
244
|
-
if (!authoritativeProduct)
|
|
245
|
-
return product;
|
|
246
|
-
const selectedBundles = Array.isArray(product.product_bundle) ? product.product_bundle : [];
|
|
247
|
-
const authoritativeBundles = this.getAuthoritativeBundleItems(authoritativeProduct);
|
|
248
|
-
const productBundle = selectedBundles.map((bundle) => {
|
|
249
|
-
const authoritativeBundle = this.findAuthoritativeBundleItem(bundle, authoritativeBundles);
|
|
250
|
-
const unitPrice = authoritativeBundle ? this.getAuthoritativeBundleUnitPrice(authoritativeBundle) : void 0;
|
|
251
|
-
if (unitPrice === void 0 || unitPrice === null || unitPrice === "")
|
|
252
|
-
return bundle;
|
|
253
|
-
return {
|
|
254
|
-
...bundle,
|
|
255
|
-
price: unitPrice,
|
|
256
|
-
bundle_selling_price: unitPrice,
|
|
257
|
-
base_price: (authoritativeBundle == null ? void 0 : authoritativeBundle.base_price) ?? bundle.base_price,
|
|
258
|
-
product_price: (authoritativeBundle == null ? void 0 : authoritativeBundle.product_price) ?? bundle.product_price
|
|
259
|
-
};
|
|
260
|
-
});
|
|
261
|
-
return {
|
|
262
|
-
...product,
|
|
263
|
-
...authoritativeProduct,
|
|
264
|
-
id: product.id ?? authoritativeProduct.id,
|
|
265
|
-
product_id: product.product_id ?? authoritativeProduct.product_id ?? authoritativeProduct.id,
|
|
266
|
-
product_variant_id: product.product_variant_id ?? authoritativeProduct.product_variant_id ?? 0,
|
|
267
|
-
num: product.num ?? product.quantity ?? authoritativeProduct.num,
|
|
268
|
-
quantity: product.quantity ?? product.num ?? authoritativeProduct.quantity,
|
|
269
|
-
product_option_item: product.product_option_item ?? authoritativeProduct.product_option_item,
|
|
270
|
-
product_bundle: productBundle,
|
|
271
|
-
metadata: product.metadata ?? authoritativeProduct.metadata
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
|
-
getSubmitOrderSalesChannel() {
|
|
275
|
-
var _a;
|
|
276
|
-
return (_a = this.otherParams) == null ? void 0 : _a.channel;
|
|
277
|
-
}
|
|
278
108
|
/**
|
|
279
109
|
* 工厂入口:根据子模块名实例化对应模块。
|
|
280
110
|
* 默认使用 BookingByStep 公共 `createModule`。子类若需引入额外类型(如 customer),
|
|
281
111
|
* 可覆盖此方法并把未识别的 name 委托给 `super.createSubModule(name)`。
|
|
282
112
|
*/
|
|
283
113
|
createSubModule(moduleName) {
|
|
284
|
-
|
|
285
|
-
return new import_Quotation.QuotationModule(`${this.name}_quotation`);
|
|
286
|
-
}
|
|
287
|
-
return (0, import_types2.createModule)(moduleName, this.name);
|
|
114
|
+
return (0, import_types.createModule)(moduleName, this.name);
|
|
288
115
|
}
|
|
289
116
|
getSubModuleHooks(moduleName) {
|
|
290
117
|
var _a, _b;
|
|
@@ -313,51 +140,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
313
140
|
return {};
|
|
314
141
|
}
|
|
315
142
|
}
|
|
316
|
-
getAppData(key) {
|
|
317
|
-
var _a, _b, _c, _d, _e, _f;
|
|
318
|
-
const getData = (_b = (_a = this.appPlugin).getData) == null ? void 0 : _b.call(_a);
|
|
319
|
-
if (typeof getData === "function")
|
|
320
|
-
return getData(key);
|
|
321
|
-
const app = this.appPlugin.getApp();
|
|
322
|
-
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");
|
|
323
|
-
return coreData == null ? void 0 : coreData[key];
|
|
324
|
-
}
|
|
325
|
-
syncAppDataToTempOrder(tempOrder) {
|
|
326
|
-
const isPriceIncludeTax = this.getAppData("is_price_include_tax");
|
|
327
|
-
const taxCountryCode = this.getAppData("tax_country_code");
|
|
328
|
-
const currencyCode = this.getAppData("shop_currency_code");
|
|
329
|
-
const currencySymbol = this.getAppData("shop_symbol");
|
|
330
|
-
let isChanged = false;
|
|
331
|
-
if (isPriceIncludeTax !== void 0) {
|
|
332
|
-
const nextIsPriceIncludeTax = Number(isPriceIncludeTax);
|
|
333
|
-
if ((nextIsPriceIncludeTax === 0 || nextIsPriceIncludeTax === 1) && tempOrder.is_price_include_tax !== nextIsPriceIncludeTax) {
|
|
334
|
-
tempOrder.is_price_include_tax = nextIsPriceIncludeTax;
|
|
335
|
-
isChanged = true;
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
if (taxCountryCode !== void 0) {
|
|
339
|
-
const nextTaxCountryCode = String(taxCountryCode || "");
|
|
340
|
-
if (tempOrder.tax_country_code !== nextTaxCountryCode) {
|
|
341
|
-
tempOrder.tax_country_code = nextTaxCountryCode;
|
|
342
|
-
isChanged = true;
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
if (currencyCode !== void 0) {
|
|
346
|
-
const nextCurrencyCode = String(currencyCode || "");
|
|
347
|
-
if (tempOrder.currency_code !== nextCurrencyCode) {
|
|
348
|
-
tempOrder.currency_code = nextCurrencyCode;
|
|
349
|
-
isChanged = true;
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
if (currencySymbol !== void 0) {
|
|
353
|
-
const nextCurrencySymbol = String(currencySymbol || "");
|
|
354
|
-
if (tempOrder.currency_symbol !== nextCurrencySymbol) {
|
|
355
|
-
tempOrder.currency_symbol = nextCurrencySymbol;
|
|
356
|
-
isChanged = true;
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
return isChanged;
|
|
360
|
-
}
|
|
361
143
|
async initialize(core, options = {}) {
|
|
362
144
|
var _a;
|
|
363
145
|
this.core = core;
|
|
@@ -366,11 +148,11 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
366
148
|
this.cacheId = (_a = this.otherParams) == null ? void 0 : _a.cacheId;
|
|
367
149
|
this.window = core.getPlugin("window");
|
|
368
150
|
this.request = core.getPlugin("request");
|
|
369
|
-
|
|
370
|
-
if (!
|
|
151
|
+
const appPlugin = core.getPlugin("app");
|
|
152
|
+
if (!appPlugin) {
|
|
371
153
|
throw new Error("Checkout 解决方案需要 app 插件支持");
|
|
372
154
|
}
|
|
373
|
-
const app =
|
|
155
|
+
const app = appPlugin.getApp();
|
|
374
156
|
this.logger = app.logger;
|
|
375
157
|
const targetCacheData = this.readSessionCacheData();
|
|
376
158
|
const moduleNames = this.getRegisteredModuleNames();
|
|
@@ -504,13 +286,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
504
286
|
const result = ((_a = this.store.order) == null ? void 0 : _a.getTempOrder()) || null;
|
|
505
287
|
return result;
|
|
506
288
|
}
|
|
507
|
-
async replaceTempOrder(tempOrder) {
|
|
508
|
-
if (!this.store.order)
|
|
509
|
-
throw new Error("order 模块未初始化");
|
|
510
|
-
const nextTempOrder = await this.store.order.replaceTempOrder(tempOrder);
|
|
511
|
-
await this.effectsEmit("onTempOrderReplaced", { tempOrder: nextTempOrder });
|
|
512
|
-
return nextTempOrder;
|
|
513
|
-
}
|
|
514
289
|
getOrderIdentity() {
|
|
515
290
|
if (!this.store.order)
|
|
516
291
|
return null;
|
|
@@ -536,21 +311,16 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
536
311
|
return "";
|
|
537
312
|
return this.store.order.getTempOrderNote();
|
|
538
313
|
}
|
|
539
|
-
updateTempOrderNote(note
|
|
314
|
+
updateTempOrderNote(note) {
|
|
540
315
|
try {
|
|
541
316
|
if (!this.store.order)
|
|
542
317
|
throw new Error("order 模块未初始化");
|
|
543
|
-
const result = this.store.order.updateTempOrderNote(note
|
|
318
|
+
const result = this.store.order.updateTempOrderNote(note);
|
|
544
319
|
return result;
|
|
545
320
|
} catch (error) {
|
|
546
321
|
throw error;
|
|
547
322
|
}
|
|
548
323
|
}
|
|
549
|
-
updateRemoteOrderNote(orderId, note) {
|
|
550
|
-
if (!this.store.order)
|
|
551
|
-
throw new Error("order 模块未初始化");
|
|
552
|
-
this.store.order.syncTempOrderNoteToRemote(orderId, note);
|
|
553
|
-
}
|
|
554
324
|
updateTempOrderShopDiscount(amount) {
|
|
555
325
|
if (!this.store.order)
|
|
556
326
|
throw new Error("order 模块未初始化");
|
|
@@ -561,18 +331,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
561
331
|
throw new Error("order 模块未初始化");
|
|
562
332
|
return this.store.order.updateTempOrderContactsInfo(contactsInfo);
|
|
563
333
|
}
|
|
564
|
-
/** @deprecated OrderModule 不再负责 tempOrder localStorage 持久化。 */
|
|
565
|
-
setEnableTempOrderPersist(enabled) {
|
|
566
|
-
if (!this.store.order)
|
|
567
|
-
throw new Error("order 模块未初始化");
|
|
568
|
-
this.store.order.setEnableTempOrderPersist(enabled);
|
|
569
|
-
}
|
|
570
|
-
/** @deprecated OrderModule 不再负责 tempOrder localStorage 持久化。 */
|
|
571
|
-
isTempOrderPersistEnabled() {
|
|
572
|
-
if (!this.store.order)
|
|
573
|
-
return false;
|
|
574
|
-
return this.store.order.isTempOrderPersistEnabled();
|
|
575
|
-
}
|
|
576
334
|
ensureTempOrder() {
|
|
577
335
|
if (!this.store.order)
|
|
578
336
|
throw new Error("order 模块未初始化");
|
|
@@ -584,10 +342,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
584
342
|
if (!this.store.order)
|
|
585
343
|
throw new Error("order 模块未初始化");
|
|
586
344
|
const tempOrder = await this.store.order.addNewOrder();
|
|
587
|
-
if (this.syncAppDataToTempOrder(tempOrder)) {
|
|
588
|
-
this.store.order.persistTempOrder();
|
|
589
|
-
await this.store.order.saveDraft();
|
|
590
|
-
}
|
|
591
345
|
return tempOrder;
|
|
592
346
|
} catch (error) {
|
|
593
347
|
throw error;
|
|
@@ -606,43 +360,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
606
360
|
throw new Error("scanOrder 解决方案需要 order 模块支持");
|
|
607
361
|
}
|
|
608
362
|
const tempOrder = this.store.order.restoreOrder();
|
|
609
|
-
this.currentSalesDetail = null;
|
|
610
|
-
this.discountConfigCacheKey = null;
|
|
611
|
-
this.hasManualDiscountSelection = false;
|
|
612
|
-
await this.effectsEmit("onTempOrderReplaced", { tempOrder });
|
|
613
|
-
if (this.syncAppDataToTempOrder(tempOrder)) {
|
|
614
|
-
this.store.order.persistTempOrder();
|
|
615
|
-
await this.store.order.saveDraft();
|
|
616
|
-
}
|
|
617
|
-
return tempOrder;
|
|
618
|
-
} catch (error) {
|
|
619
|
-
throw error;
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
/**
|
|
623
|
-
* 仅清空 tempOrder 购物车行(products / bookings / discount_list)。
|
|
624
|
-
* 同步清空内存中的 salesDetail 商品/预约视图,避免编辑态仍读到旧 bookings。
|
|
625
|
-
*/
|
|
626
|
-
async clearOrderCartLines() {
|
|
627
|
-
try {
|
|
628
|
-
if (!this.store.order)
|
|
629
|
-
throw new Error("order 模块未初始化");
|
|
630
|
-
const tempOrder = await this.store.order.clearOrderCartLines();
|
|
631
|
-
if (this.currentSalesDetail) {
|
|
632
|
-
this.currentSalesDetail = {
|
|
633
|
-
...this.currentSalesDetail,
|
|
634
|
-
products: [],
|
|
635
|
-
bookings: [],
|
|
636
|
-
rootBooking: null,
|
|
637
|
-
bookingsByProductUid: {},
|
|
638
|
-
discount_list: []
|
|
639
|
-
};
|
|
640
|
-
}
|
|
641
|
-
await this.effectsEmit("onTempOrderReplaced", { tempOrder });
|
|
642
|
-
if (this.syncAppDataToTempOrder(tempOrder)) {
|
|
643
|
-
this.store.order.persistTempOrder();
|
|
644
|
-
await this.store.order.saveDraft();
|
|
645
|
-
}
|
|
646
363
|
return tempOrder;
|
|
647
364
|
} catch (error) {
|
|
648
365
|
throw error;
|
|
@@ -664,246 +381,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
664
381
|
throw error;
|
|
665
382
|
}
|
|
666
383
|
}
|
|
667
|
-
getHistoricalProductDiscountList(products) {
|
|
668
|
-
const historyDiscountList = [];
|
|
669
|
-
products.forEach((item) => {
|
|
670
|
-
if (!this.isPersistedOrderProduct(item))
|
|
671
|
-
return;
|
|
672
|
-
(item.discount_list || []).forEach((discount) => {
|
|
673
|
-
var _a, _b, _c, _d, _e, _f;
|
|
674
|
-
const discountId = ((_a = discount.discount) == null ? void 0 : _a.resource_id) || discount.id;
|
|
675
|
-
if (!discountId || !["good_pass", "discount_card"].includes(discount.type))
|
|
676
|
-
return;
|
|
677
|
-
const quantity = item.quantity || item.num || item.product_quantity || 1;
|
|
678
|
-
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);
|
|
679
|
-
const index = historyDiscountList.findIndex((n) => n.id === discountId);
|
|
680
|
-
if (index !== -1) {
|
|
681
|
-
historyDiscountList[index] = {
|
|
682
|
-
...historyDiscountList[index],
|
|
683
|
-
amount: new import_decimal.default(historyDiscountList[index].amount || 0).plus(discount.amount || 0).toNumber(),
|
|
684
|
-
savedAmount: savedAmount.plus(historyDiscountList[index].savedAmount || 0).toNumber()
|
|
685
|
-
};
|
|
686
|
-
return;
|
|
687
|
-
}
|
|
688
|
-
historyDiscountList.push({
|
|
689
|
-
...discount,
|
|
690
|
-
id: discountId,
|
|
691
|
-
tag: discount.tag || discount.type,
|
|
692
|
-
name: discount.name || ((_d = (_c = discount.discount) == null ? void 0 : _c.title) == null ? void 0 : _d.auto),
|
|
693
|
-
format_title: ((_e = discount.discount) == null ? void 0 : _e.title) || discount.format_title,
|
|
694
|
-
isEditMode: true,
|
|
695
|
-
limited_relation_product_data: {},
|
|
696
|
-
savedAmount: savedAmount.toNumber(),
|
|
697
|
-
isAvailable: true,
|
|
698
|
-
isDisabled: true,
|
|
699
|
-
isSelected: true,
|
|
700
|
-
product_id: ((_f = discount.discount) == null ? void 0 : _f.product_id) || discount.product_id
|
|
701
|
-
});
|
|
702
|
-
});
|
|
703
|
-
});
|
|
704
|
-
return historyDiscountList;
|
|
705
|
-
}
|
|
706
|
-
isPersistedOrderProduct(product) {
|
|
707
|
-
const orderDetailId = product.order_detail_id ?? product.orderDetailId;
|
|
708
|
-
if (orderDetailId !== void 0 && orderDetailId !== null && orderDetailId !== "") {
|
|
709
|
-
return true;
|
|
710
|
-
}
|
|
711
|
-
const bookingId = product.booking_id ?? product.bookingId;
|
|
712
|
-
return bookingId !== void 0 && bookingId !== null && bookingId !== "";
|
|
713
|
-
}
|
|
714
|
-
mergeHistoricalDiscountList(discountList, products) {
|
|
715
|
-
const historyDiscountList = this.getHistoricalProductDiscountList(products);
|
|
716
|
-
const historyIds = new Set(historyDiscountList.map((discount) => discount.id));
|
|
717
|
-
return [
|
|
718
|
-
...historyDiscountList,
|
|
719
|
-
...(discountList || []).filter((discount) => !historyIds.has(discount.id))
|
|
720
|
-
];
|
|
721
|
-
}
|
|
722
|
-
mergeCurrentDiscountSelectionState(discountList, currentDiscountList) {
|
|
723
|
-
if (!currentDiscountList.length)
|
|
724
|
-
return discountList;
|
|
725
|
-
const currentDiscountMap = new Map(
|
|
726
|
-
currentDiscountList.map((discount) => [discount.id, discount])
|
|
727
|
-
);
|
|
728
|
-
return discountList.map((discount) => {
|
|
729
|
-
const currentDiscount = currentDiscountMap.get(discount.id);
|
|
730
|
-
if (!currentDiscount)
|
|
731
|
-
return discount;
|
|
732
|
-
if (currentDiscount.isManualSelect) {
|
|
733
|
-
return {
|
|
734
|
-
...discount,
|
|
735
|
-
isSelected: false,
|
|
736
|
-
isManualSelect: true
|
|
737
|
-
};
|
|
738
|
-
}
|
|
739
|
-
if (currentDiscount.isSelected) {
|
|
740
|
-
return {
|
|
741
|
-
...discount,
|
|
742
|
-
isSelected: true,
|
|
743
|
-
isManualSelect: false
|
|
744
|
-
};
|
|
745
|
-
}
|
|
746
|
-
return discount;
|
|
747
|
-
});
|
|
748
|
-
}
|
|
749
|
-
async loadDiscountConfig(params) {
|
|
750
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
751
|
-
if (!this.store.order)
|
|
752
|
-
throw new Error("order 模块未初始化");
|
|
753
|
-
const tempOrder = this.store.order.ensureTempOrder();
|
|
754
|
-
const orderStore = this.store.order.store || {};
|
|
755
|
-
const discountModule = orderStore.discount;
|
|
756
|
-
const rulesModule = orderStore.rules;
|
|
757
|
-
const orderId = tempOrder.order_id || ((_b = (_a = this.getOrderIdentity) == null ? void 0 : _a.call(this)) == null ? void 0 : _b.orderId);
|
|
758
|
-
const customerId = Number(
|
|
759
|
-
(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
|
|
760
|
-
);
|
|
761
|
-
const currentDiscountList = ((_h = discountModule == null ? void 0 : discountModule.getDiscountList) == null ? void 0 : _h.call(discountModule)) || [];
|
|
762
|
-
const originalDiscountList = ((_i = discountModule == null ? void 0 : discountModule.getOriginalDiscountList) == null ? void 0 : _i.call(discountModule)) || [];
|
|
763
|
-
const hasManualDiscountSelection = this.hasManualDiscountSelection || currentDiscountList.some((discount) => discount.isManualSelect);
|
|
764
|
-
const discountAction = (params == null ? void 0 : params.action) || (orderId ? "edit" : "create");
|
|
765
|
-
const discountConfigCacheKey = [
|
|
766
|
-
customerId,
|
|
767
|
-
discountAction,
|
|
768
|
-
Number(orderId) || 0
|
|
769
|
-
].join(":");
|
|
770
|
-
let preparedDiscountList = [];
|
|
771
|
-
if (customerId && customerId !== 1) {
|
|
772
|
-
if (this.discountConfigCacheKey === discountConfigCacheKey) {
|
|
773
|
-
preparedDiscountList = originalDiscountList;
|
|
774
|
-
} else {
|
|
775
|
-
preparedDiscountList = await this.store.order.loadDiscountConfig({
|
|
776
|
-
customerId,
|
|
777
|
-
action: discountAction,
|
|
778
|
-
orderId: Number(orderId) || void 0,
|
|
779
|
-
apply: false
|
|
780
|
-
});
|
|
781
|
-
this.discountConfigCacheKey = discountConfigCacheKey;
|
|
782
|
-
await ((_j = discountModule == null ? void 0 : discountModule.setOriginalDiscountList) == null ? void 0 : _j.call(discountModule, preparedDiscountList));
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
|
-
if (hasManualDiscountSelection && currentDiscountList.length) {
|
|
786
|
-
return {
|
|
787
|
-
productList: tempOrder.products || [],
|
|
788
|
-
discountList: currentDiscountList
|
|
789
|
-
};
|
|
790
|
-
}
|
|
791
|
-
let nextDiscountList = this.mergeHistoricalDiscountList(
|
|
792
|
-
preparedDiscountList || ((_k = discountModule == null ? void 0 : discountModule.getDiscountList) == null ? void 0 : _k.call(discountModule)) || [],
|
|
793
|
-
tempOrder.products || []
|
|
794
|
-
);
|
|
795
|
-
nextDiscountList = this.mergeCurrentDiscountSelectionState(
|
|
796
|
-
nextDiscountList,
|
|
797
|
-
currentDiscountList
|
|
798
|
-
);
|
|
799
|
-
await (discountModule == null ? void 0 : discountModule.setDiscountList(nextDiscountList));
|
|
800
|
-
if (rulesModule) {
|
|
801
|
-
const holders = ((_l = tempOrder.holder) == null ? void 0 : _l.form_record_id) ? [{ form_record_id: tempOrder.holder.form_record_id }] : [];
|
|
802
|
-
const result = rulesModule.calcDiscount({
|
|
803
|
-
productList: tempOrder.products,
|
|
804
|
-
discountList: nextDiscountList,
|
|
805
|
-
holders,
|
|
806
|
-
isFormSubject: !!((_m = tempOrder.holder) == null ? void 0 : _m.type) && tempOrder.holder.type === "form",
|
|
807
|
-
orderTotalAmount: Number(((_n = orderStore.summary) == null ? void 0 : _n.total_amount) || 0)
|
|
808
|
-
}) || { productList: tempOrder.products, discountList: nextDiscountList };
|
|
809
|
-
if (result.productList) {
|
|
810
|
-
tempOrder.products = result.productList;
|
|
811
|
-
}
|
|
812
|
-
for (const product of tempOrder.products || []) {
|
|
813
|
-
const productUid = (_o = product.metadata) == null ? void 0 : _o.unique_identification_number;
|
|
814
|
-
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;
|
|
815
|
-
if ((runtimeOrigin == null ? void 0 : runtimeOrigin.isManualDiscount) || ((_s = product.metadata) == null ? void 0 : _s.is_manual_discount))
|
|
816
|
-
continue;
|
|
817
|
-
const totalPerUnitDiscount = (product.discount_list || []).reduce(
|
|
818
|
-
(sum, pd) => sum + Number(pd.amount || 0),
|
|
819
|
-
0
|
|
820
|
-
);
|
|
821
|
-
const optionSum = (0, import_utils.sumOptionUnitPrice)(product.product_option_item);
|
|
822
|
-
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");
|
|
823
|
-
const newSourceSellingPrice = new import_decimal.default(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
824
|
-
const newMainSellingPrice = new import_decimal.default(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
825
|
-
if (product.metadata) {
|
|
826
|
-
product.metadata.main_product_selling_price = newMainSellingPrice;
|
|
827
|
-
product.metadata.price_schema_version = 2;
|
|
828
|
-
}
|
|
829
|
-
product.selling_price = (0, import_utils.composeLinePrice)({
|
|
830
|
-
mainPrice: newMainSellingPrice,
|
|
831
|
-
bundle: product.product_bundle
|
|
832
|
-
});
|
|
833
|
-
}
|
|
834
|
-
if (result.discountList) {
|
|
835
|
-
nextDiscountList = this.mergeHistoricalDiscountList(
|
|
836
|
-
result.discountList,
|
|
837
|
-
tempOrder.products || []
|
|
838
|
-
);
|
|
839
|
-
import_Order.OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
840
|
-
await (discountModule == null ? void 0 : discountModule.setDiscountList(nextDiscountList));
|
|
841
|
-
tempOrder.discount_list = nextDiscountList.filter((discount) => discount.isSelected);
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
const summary = await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
845
|
-
this.store.order.persistTempOrder();
|
|
846
|
-
await this.effectsEmit("onDiscountApplied", {
|
|
847
|
-
productList: tempOrder.products || [],
|
|
848
|
-
discountList: nextDiscountList,
|
|
849
|
-
selectedDiscountList: tempOrder.discount_list || [],
|
|
850
|
-
tempOrder
|
|
851
|
-
});
|
|
852
|
-
return {
|
|
853
|
-
productList: tempOrder.products || [],
|
|
854
|
-
discountList: nextDiscountList
|
|
855
|
-
};
|
|
856
|
-
}
|
|
857
|
-
async bestDiscount(cb) {
|
|
858
|
-
var _a, _b, _c, _d, _e;
|
|
859
|
-
if (!this.store.order)
|
|
860
|
-
throw new Error("order 模块未初始化");
|
|
861
|
-
const tempOrder = this.store.order.ensureTempOrder();
|
|
862
|
-
const orderStore = this.store.order.store || {};
|
|
863
|
-
const discountModule = orderStore.discount;
|
|
864
|
-
const rulesModule = orderStore.rules;
|
|
865
|
-
const originalDiscountList = ((_a = discountModule == null ? void 0 : discountModule.getOriginalDiscountList) == null ? void 0 : _a.call(discountModule)) || this.getDiscountList();
|
|
866
|
-
const currentDiscountList = ((_b = discountModule == null ? void 0 : discountModule.getDiscountList) == null ? void 0 : _b.call(discountModule)) || [];
|
|
867
|
-
let nextDiscountList = this.mergeHistoricalDiscountList(
|
|
868
|
-
originalDiscountList || [],
|
|
869
|
-
tempOrder.products || []
|
|
870
|
-
);
|
|
871
|
-
let result = {
|
|
872
|
-
productList: tempOrder.products || [],
|
|
873
|
-
discountList: nextDiscountList
|
|
874
|
-
};
|
|
875
|
-
await (discountModule == null ? void 0 : discountModule.setDiscountList(nextDiscountList));
|
|
876
|
-
if (rulesModule) {
|
|
877
|
-
const holders = ((_c = tempOrder.holder) == null ? void 0 : _c.form_record_id) ? [{ form_record_id: tempOrder.holder.form_record_id }] : [];
|
|
878
|
-
result = rulesModule.calcDiscount({
|
|
879
|
-
productList: tempOrder.products,
|
|
880
|
-
discountList: nextDiscountList,
|
|
881
|
-
holders,
|
|
882
|
-
isFormSubject: !!((_d = tempOrder.holder) == null ? void 0 : _d.type) && tempOrder.holder.type === "form",
|
|
883
|
-
orderTotalAmount: Number(((_e = orderStore.summary) == null ? void 0 : _e.total_amount) || 0)
|
|
884
|
-
}) || result;
|
|
885
|
-
if (result.productList) {
|
|
886
|
-
tempOrder.products = result.productList;
|
|
887
|
-
}
|
|
888
|
-
if (result.discountList) {
|
|
889
|
-
nextDiscountList = this.mergeHistoricalDiscountList(
|
|
890
|
-
result.discountList,
|
|
891
|
-
tempOrder.products || []
|
|
892
|
-
);
|
|
893
|
-
import_Order.OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
894
|
-
await (discountModule == null ? void 0 : discountModule.setDiscountList(nextDiscountList));
|
|
895
|
-
tempOrder.discount_list = nextDiscountList.filter((discount) => discount.isSelected);
|
|
896
|
-
result = {
|
|
897
|
-
productList: tempOrder.products,
|
|
898
|
-
discountList: nextDiscountList
|
|
899
|
-
};
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
903
|
-
this.store.order.persistTempOrder();
|
|
904
|
-
cb == null ? void 0 : cb(result);
|
|
905
|
-
return result;
|
|
906
|
-
}
|
|
907
384
|
getDiscountList() {
|
|
908
385
|
if (!this.store.order)
|
|
909
386
|
return [];
|
|
@@ -941,7 +418,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
941
418
|
isManualSelect: !params.isSelected
|
|
942
419
|
} : d
|
|
943
420
|
);
|
|
944
|
-
this.hasManualDiscountSelection = true;
|
|
945
421
|
const tempOrder = this.store.order.ensureTempOrder();
|
|
946
422
|
const orderStore = this.store.order.store || {};
|
|
947
423
|
const discountModule = orderStore.discount;
|
|
@@ -974,7 +450,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
974
450
|
for (const d of nextDiscountList) {
|
|
975
451
|
if (d.isSelected && !beforeSelectedIds.has(d.id)) {
|
|
976
452
|
d.isSelected = false;
|
|
977
|
-
d.isManualSelect = true;
|
|
978
453
|
}
|
|
979
454
|
}
|
|
980
455
|
}
|
|
@@ -1015,40 +490,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1015
490
|
tempOrder.discount_list = (nextDiscountList || []).filter((d) => d.isSelected);
|
|
1016
491
|
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
1017
492
|
this.store.order.persistTempOrder();
|
|
1018
|
-
this.effectsEmit("onDiscountApplied", {
|
|
1019
|
-
productList: tempOrder.products,
|
|
1020
|
-
discountList: nextDiscountList,
|
|
1021
|
-
selectedDiscountList: tempOrder.discount_list,
|
|
1022
|
-
tempOrder
|
|
1023
|
-
});
|
|
1024
|
-
} catch (error) {
|
|
1025
|
-
throw error;
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
async applyDiscountCalculationResult(result) {
|
|
1029
|
-
try {
|
|
1030
|
-
if (!this.store.order)
|
|
1031
|
-
throw new Error("order 模块未初始化");
|
|
1032
|
-
if (!result)
|
|
1033
|
-
return;
|
|
1034
|
-
const tempOrder = this.store.order.ensureTempOrder();
|
|
1035
|
-
const orderStore = this.store.order.store || {};
|
|
1036
|
-
const discountModule = orderStore.discount;
|
|
1037
|
-
if (result.productList) {
|
|
1038
|
-
tempOrder.products = result.productList;
|
|
1039
|
-
}
|
|
1040
|
-
if (result.discountList) {
|
|
1041
|
-
import_Order.OrderModule.populateSavedAmounts(
|
|
1042
|
-
tempOrder.products,
|
|
1043
|
-
result.discountList
|
|
1044
|
-
);
|
|
1045
|
-
await (discountModule == null ? void 0 : discountModule.setDiscountList(result.discountList));
|
|
1046
|
-
tempOrder.discount_list = result.discountList.filter(
|
|
1047
|
-
(discount) => discount.isSelected
|
|
1048
|
-
);
|
|
1049
|
-
}
|
|
1050
|
-
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
1051
|
-
this.store.order.persistTempOrder();
|
|
1052
493
|
} catch (error) {
|
|
1053
494
|
throw error;
|
|
1054
495
|
}
|
|
@@ -1063,7 +504,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1063
504
|
* payments 会交给 OrderModule 统一映射为 Sales 协议支付项。
|
|
1064
505
|
*/
|
|
1065
506
|
async submitSalesOrder(params) {
|
|
1066
|
-
var _a, _b, _c;
|
|
507
|
+
var _a, _b, _c, _d;
|
|
1067
508
|
if (!this.store.order) {
|
|
1068
509
|
throw new Error("BaseSales 解决方案需要 order 模块支持");
|
|
1069
510
|
}
|
|
@@ -1072,57 +513,19 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1072
513
|
cacheId: this.cacheId,
|
|
1073
514
|
platform: (_a = this.otherParams) == null ? void 0 : _a.platform,
|
|
1074
515
|
businessCode: (_b = this.otherParams) == null ? void 0 : _b.businessCode,
|
|
1075
|
-
channel: this.
|
|
1076
|
-
type: (
|
|
516
|
+
channel: (_c = this.otherParams) == null ? void 0 : _c.channel,
|
|
517
|
+
type: (_d = this.otherParams) == null ? void 0 : _d.type,
|
|
1077
518
|
...(params == null ? void 0 : params.payments) !== void 0 ? { payments: params.payments } : {},
|
|
1078
519
|
...(params == null ? void 0 : params.paymentStatus) !== void 0 ? { paymentStatus: params.paymentStatus } : {},
|
|
1079
520
|
...(params == null ? void 0 : params.smallTicketDataFlag) !== void 0 ? { smallTicketDataFlag: params.smallTicketDataFlag } : {},
|
|
1080
521
|
...(params == null ? void 0 : params.enhancePayload) !== void 0 ? { enhancePayload: params.enhancePayload } : {}
|
|
1081
522
|
};
|
|
1082
|
-
console.log(submitParams, "submitParams123");
|
|
1083
523
|
return this.store.order.submitTempOrder(submitParams);
|
|
1084
524
|
}
|
|
1085
525
|
async syncPaymentsToOrder(params) {
|
|
1086
526
|
if (!this.store.order)
|
|
1087
527
|
throw new Error("order 模块未初始化");
|
|
1088
|
-
|
|
1089
|
-
const syncParams = {
|
|
1090
|
-
...params,
|
|
1091
|
-
...channel !== void 0 ? { channel } : {}
|
|
1092
|
-
};
|
|
1093
|
-
const syncState = this.store.order.getOrderSyncState();
|
|
1094
|
-
if (params.submitWhenPaid && syncState === "submitting") {
|
|
1095
|
-
return this.store.order.syncPaymentsToOrder(syncParams);
|
|
1096
|
-
}
|
|
1097
|
-
const payments = params.payments || [];
|
|
1098
|
-
await this.effectsEmit(import_types.BaseSalesHookNames.onPaymentSyncStart, {
|
|
1099
|
-
payments,
|
|
1100
|
-
params: syncParams,
|
|
1101
|
-
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
1102
|
-
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
1103
|
-
});
|
|
1104
|
-
try {
|
|
1105
|
-
const syncResult = await this.store.order.syncPaymentsToOrder(syncParams);
|
|
1106
|
-
await this.effectsEmit(import_types.BaseSalesHookNames.onPaymentSyncEnd, {
|
|
1107
|
-
ok: true,
|
|
1108
|
-
syncResult,
|
|
1109
|
-
payments: this.store.order.getOrderPayments(),
|
|
1110
|
-
params: syncParams,
|
|
1111
|
-
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
1112
|
-
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
1113
|
-
});
|
|
1114
|
-
return syncResult;
|
|
1115
|
-
} catch (error) {
|
|
1116
|
-
await this.effectsEmit(import_types.BaseSalesHookNames.onPaymentSyncEnd, {
|
|
1117
|
-
ok: false,
|
|
1118
|
-
error,
|
|
1119
|
-
payments: this.store.order.getOrderPayments(),
|
|
1120
|
-
params: syncParams,
|
|
1121
|
-
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
1122
|
-
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
1123
|
-
});
|
|
1124
|
-
throw error;
|
|
1125
|
-
}
|
|
528
|
+
return this.store.order.syncPaymentsToOrder(params);
|
|
1126
529
|
}
|
|
1127
530
|
/** 读取当前 BaseSales 订单上下文中的 Sales 协议支付项。 */
|
|
1128
531
|
getOrderPayments() {
|
|
@@ -1140,31 +543,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1140
543
|
addOrderPayment(payment) {
|
|
1141
544
|
if (!this.store.order)
|
|
1142
545
|
throw new Error("order 模块未初始化");
|
|
1143
|
-
|
|
1144
|
-
const metadata = paymentRecord.metadata && typeof paymentRecord.metadata === "object" ? { ...paymentRecord.metadata } : {};
|
|
1145
|
-
if (!metadata.unique_identification_number) {
|
|
1146
|
-
metadata.unique_identification_number = (0, import_utils.createUuidV4)();
|
|
1147
|
-
}
|
|
1148
|
-
const payments = this.store.order.addOrderPayment({
|
|
1149
|
-
...paymentRecord,
|
|
1150
|
-
metadata
|
|
1151
|
-
});
|
|
1152
|
-
const amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
1153
|
-
const syncState = this.store.order.getOrderSyncState();
|
|
1154
|
-
if (amountSnapshot && syncState !== "submitting") {
|
|
1155
|
-
const paymentStatus = Number(amountSnapshot.amountGap || 0) <= 0 ? "paid" : "partially_paid";
|
|
1156
|
-
void this.syncPaymentsToOrder({
|
|
1157
|
-
payments,
|
|
1158
|
-
paymentStatus,
|
|
1159
|
-
submitWhenPaid: true,
|
|
1160
|
-
smallTicketDataFlag: 1
|
|
1161
|
-
}).catch((error) => {
|
|
1162
|
-
this.logError("auto sync payments failed", {
|
|
1163
|
-
error: error instanceof Error ? error.message : String(error)
|
|
1164
|
-
});
|
|
1165
|
-
});
|
|
1166
|
-
}
|
|
1167
|
-
return payments;
|
|
546
|
+
return this.store.order.addOrderPayment(payment);
|
|
1168
547
|
}
|
|
1169
548
|
/** 更新当前订单中的指定支付项。 */
|
|
1170
549
|
updateOrderPayment(paymentIdentity, updates) {
|
|
@@ -1185,12 +564,11 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1185
564
|
return this.store.order.updateVoucherOrderPayments(payments);
|
|
1186
565
|
}
|
|
1187
566
|
getWalletProductList() {
|
|
1188
|
-
var _a, _b
|
|
567
|
+
var _a, _b;
|
|
1189
568
|
const tempOrder = (_a = this.store.order) == null ? void 0 : _a.getTempOrder();
|
|
1190
569
|
if (!((_b = tempOrder == null ? void 0 : tempOrder.products) == null ? void 0 : _b.length))
|
|
1191
570
|
return [];
|
|
1192
|
-
|
|
1193
|
-
return products.map((product) => {
|
|
571
|
+
return tempOrder.products.map((product) => {
|
|
1194
572
|
const metadata = product.metadata || {};
|
|
1195
573
|
return {
|
|
1196
574
|
product_id: product.product_id,
|
|
@@ -1200,7 +578,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1200
578
|
is_charge_tax: product.is_charge_tax ?? 0,
|
|
1201
579
|
tax_fee: product.tax_fee,
|
|
1202
580
|
selling_price: Number(product.selling_price || 0),
|
|
1203
|
-
discount_list: product.discount_list || [],
|
|
1204
581
|
holder_id: product.holder_id ?? metadata.holder_id,
|
|
1205
582
|
original_price: product.original_price,
|
|
1206
583
|
main_product_original_price: metadata.main_product_original_price ?? product.original_price,
|
|
@@ -1214,10 +591,8 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1214
591
|
const bundleMetadata = bundle.metadata || {};
|
|
1215
592
|
return {
|
|
1216
593
|
is_price_include_tax: tempOrder.is_price_include_tax,
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
bundle_product_id: bundle.bundle_product_id ?? bundle._bundle_product_id,
|
|
1220
|
-
bundle_group_id: bundle.bundle_group_id ?? bundle.group_id,
|
|
594
|
+
bundle_id: bundle.bundle_id,
|
|
595
|
+
bundle_product_id: bundle.bundle_product_id,
|
|
1221
596
|
bundle_variant_id: bundle.bundle_variant_id,
|
|
1222
597
|
price_type: bundle.price_type,
|
|
1223
598
|
price_type_ext: bundle.price_type_ext,
|
|
@@ -1356,24 +731,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1356
731
|
transformBaseProductToOrderProduct(params) {
|
|
1357
732
|
return (0, import_transformBaseProductToOrderProduct.transformBaseProductToOrderProduct)(params);
|
|
1358
733
|
}
|
|
1359
|
-
async calculateProductBookingPrice(params) {
|
|
1360
|
-
const quotation = this.store.quotation;
|
|
1361
|
-
const customerId = params.customer_id ?? this.getCurrentOrderCustomerId();
|
|
1362
|
-
const authoritativeProduct = await this.loadProductForPriceQuery(params, customerId);
|
|
1363
|
-
const product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
|
|
1364
|
-
await this.loadQuotationForPriceQuery({
|
|
1365
|
-
quotation,
|
|
1366
|
-
customer_id: customerId,
|
|
1367
|
-
channel: params.channel
|
|
1368
|
-
});
|
|
1369
|
-
return (0, import_quotationPrice.calculateBaseSalesProductBookingPrice)({
|
|
1370
|
-
...params,
|
|
1371
|
-
product,
|
|
1372
|
-
fallback_price: authoritativeProduct ? void 0 : params.fallback_price,
|
|
1373
|
-
customer_id: customerId,
|
|
1374
|
-
quotation
|
|
1375
|
-
});
|
|
1376
|
-
}
|
|
1377
734
|
async addProductToOrder(product, booking) {
|
|
1378
735
|
try {
|
|
1379
736
|
if (!this.store.order)
|
|
@@ -1384,35 +741,16 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1384
741
|
throw error;
|
|
1385
742
|
}
|
|
1386
743
|
}
|
|
1387
|
-
async
|
|
1388
|
-
try {
|
|
1389
|
-
if (!this.store.order)
|
|
1390
|
-
throw new Error("order 模块未初始化");
|
|
1391
|
-
const products = await this.store.order.updateOrderProduct(params);
|
|
1392
|
-
return products;
|
|
1393
|
-
} catch (error) {
|
|
1394
|
-
throw error;
|
|
1395
|
-
}
|
|
1396
|
-
}
|
|
1397
|
-
async updateOrderProductQuantity(params) {
|
|
744
|
+
async updateProductInOrder(params) {
|
|
1398
745
|
try {
|
|
1399
746
|
if (!this.store.order)
|
|
1400
747
|
throw new Error("order 模块未初始化");
|
|
1401
|
-
const products = await this.store.order.
|
|
748
|
+
const products = await this.store.order.updateProductInOrder(params);
|
|
1402
749
|
return products;
|
|
1403
750
|
} catch (error) {
|
|
1404
751
|
throw error;
|
|
1405
752
|
}
|
|
1406
753
|
}
|
|
1407
|
-
updateOrderBooking(params) {
|
|
1408
|
-
try {
|
|
1409
|
-
if (!this.store.order)
|
|
1410
|
-
throw new Error("order 模块未初始化");
|
|
1411
|
-
return this.store.order.updateOrderBooking(params);
|
|
1412
|
-
} catch (error) {
|
|
1413
|
-
throw error;
|
|
1414
|
-
}
|
|
1415
|
-
}
|
|
1416
754
|
/**
|
|
1417
755
|
* 设置单行商品备注(与整单 `updateTempOrderNote` 区分)。
|
|
1418
756
|
* 多行同 SKU 时必须传入与删除/更新一致的 unique_identification_number。
|
|
@@ -1432,7 +770,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1432
770
|
}
|
|
1433
771
|
if (identity.product_bundle !== void 0)
|
|
1434
772
|
params.product_bundle = identity.product_bundle;
|
|
1435
|
-
const products = await this.
|
|
773
|
+
const products = await this.updateProductInOrder(params);
|
|
1436
774
|
return products;
|
|
1437
775
|
} catch (error) {
|
|
1438
776
|
throw error;
|
|
@@ -1448,58 +786,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1448
786
|
throw error;
|
|
1449
787
|
}
|
|
1450
788
|
}
|
|
1451
|
-
// ─── 促销/赠品 透传(迁移自 booking usePromotion) ────────────────
|
|
1452
|
-
/**
|
|
1453
|
-
* 注入促销评估器到底层 OrderModule。
|
|
1454
|
-
*
|
|
1455
|
-
* @example
|
|
1456
|
-
* solution.setPromotionEvaluator(appHelper.utils.promotionEvaluator);
|
|
1457
|
-
*/
|
|
1458
|
-
setPromotionEvaluator(evaluator) {
|
|
1459
|
-
if (!this.store.order)
|
|
1460
|
-
throw new Error("order 模块未初始化");
|
|
1461
|
-
this.store.order.setPromotionEvaluator(evaluator);
|
|
1462
|
-
}
|
|
1463
|
-
/**
|
|
1464
|
-
* 注入赠品选择 resolver。UI 层(SalesSdk)通过 bridge 提供。
|
|
1465
|
-
*
|
|
1466
|
-
* @example
|
|
1467
|
-
* solution.setGiftSelectResolver(async (ctx) => bridge.request(ctx));
|
|
1468
|
-
*/
|
|
1469
|
-
setGiftSelectResolver(resolver) {
|
|
1470
|
-
if (!this.store.order)
|
|
1471
|
-
throw new Error("order 模块未初始化");
|
|
1472
|
-
this.store.order.setGiftSelectResolver(resolver);
|
|
1473
|
-
}
|
|
1474
|
-
/**
|
|
1475
|
-
* 为商品目录追加促销标签,供 SalesSdkProductProvider 等商品列表入口复用。
|
|
1476
|
-
*
|
|
1477
|
-
* @example
|
|
1478
|
-
* const products = solution.appendPromotionTags(catalogProducts);
|
|
1479
|
-
*/
|
|
1480
|
-
appendPromotionTags(products) {
|
|
1481
|
-
if (!this.store.order)
|
|
1482
|
-
throw new Error("order 模块未初始化");
|
|
1483
|
-
return this.store.order.appendPromotionTags(products);
|
|
1484
|
-
}
|
|
1485
|
-
/**
|
|
1486
|
-
* 主动触发一次促销应用(一般写路径会自动触发,少数场景如客户切换后可手动调)。
|
|
1487
|
-
*/
|
|
1488
|
-
async applyPromotion() {
|
|
1489
|
-
if (!this.store.order)
|
|
1490
|
-
throw new Error("order 模块未初始化");
|
|
1491
|
-
await this.store.order.applyPromotion();
|
|
1492
|
-
}
|
|
1493
|
-
/** 最近一次促销计算输出的未满足提示。 */
|
|
1494
|
-
getUnfulfilledPromotions() {
|
|
1495
|
-
var _a;
|
|
1496
|
-
return ((_a = this.store.order) == null ? void 0 : _a.getUnfulfilledPromotions()) || [];
|
|
1497
|
-
}
|
|
1498
|
-
/** 最近一次促销计算输出的赠品操作 diff。 */
|
|
1499
|
-
getLastGiftActions() {
|
|
1500
|
-
var _a;
|
|
1501
|
-
return ((_a = this.store.order) == null ? void 0 : _a.getLastGiftActions()) || null;
|
|
1502
|
-
}
|
|
1503
789
|
// 获取商品列表
|
|
1504
790
|
// TODO 需要跟 webpos 内的对齐一下
|
|
1505
791
|
async getProductList() {
|