@pisell/pisellos 2.2.148 → 2.2.150
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/apis/picoding.d.ts +0 -0
- package/dist/apis/picoding.js +1 -0
- package/dist/model/strategy/adapter/index.d.ts +2 -0
- package/dist/model/strategy/adapter/index.js +3 -1
- package/dist/model/strategy/adapter/itemRule/adapter.d.ts +67 -0
- package/dist/model/strategy/adapter/itemRule/adapter.js +483 -0
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
- package/dist/model/strategy/adapter/itemRule/evaluator.js +169 -0
- package/dist/model/strategy/adapter/itemRule/examples.d.ts +79 -0
- package/dist/model/strategy/adapter/itemRule/examples.js +382 -0
- package/dist/model/strategy/adapter/itemRule/index.d.ts +5 -0
- package/dist/model/strategy/adapter/itemRule/index.js +5 -0
- package/dist/model/strategy/adapter/itemRule/type.d.ts +225 -0
- package/dist/model/strategy/adapter/itemRule/type.js +101 -0
- package/dist/modules/Cart/types.d.ts +2 -0
- package/dist/modules/Cart/utils/cartProduct.js +22 -1
- package/dist/modules/Cart/utils/changePrice.js +6 -0
- package/dist/modules/Date/index.d.ts +1 -1
- package/dist/modules/Date/index.js +16 -8
- package/dist/modules/Date/types.d.ts +3 -1
- package/dist/modules/OpenData/index.d.ts +24 -0
- package/dist/modules/OpenData/index.js +173 -0
- package/dist/modules/OpenData/types.d.ts +73 -0
- package/dist/modules/OpenData/types.js +1 -0
- package/dist/modules/OpenData/utils.d.ts +2 -0
- package/dist/modules/OpenData/utils.js +75 -0
- package/dist/modules/Order/index.d.ts +171 -1
- package/dist/modules/Order/index.js +2052 -112
- package/dist/modules/Order/types.d.ts +441 -20
- package/dist/modules/Order/types.js +23 -0
- package/dist/modules/Order/utils.d.ts +120 -0
- package/dist/modules/Order/utils.js +653 -2
- package/dist/modules/Product/utils.js +2 -2
- package/dist/modules/ProductList/index.js +2 -1
- package/dist/modules/Quotation/index.d.ts +8 -1
- package/dist/modules/Quotation/index.js +40 -10
- package/dist/modules/Quotation/types.d.ts +5 -0
- package/dist/modules/Rules/index.d.ts +3 -1
- package/dist/modules/Rules/index.js +136 -50
- package/dist/modules/Rules/types.d.ts +6 -0
- package/dist/modules/Rules/types.js +8 -0
- package/dist/modules/SalesSummary/index.d.ts +70 -0
- package/dist/modules/SalesSummary/index.js +175 -0
- package/dist/modules/SalesSummary/types.d.ts +64 -0
- package/dist/modules/SalesSummary/types.js +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +34 -0
- package/dist/modules/SalesSummary/utils.js +488 -0
- package/dist/modules/ScanOrderLogger/index.d.ts +21 -0
- package/dist/modules/ScanOrderLogger/index.js +161 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.js +203 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.js +50 -0
- package/dist/modules/ScanOrderLogger/types.d.ts +52 -0
- package/dist/modules/ScanOrderLogger/types.js +1 -0
- package/dist/modules/Schedule/getDateIsInSchedule.js +7 -7
- package/dist/modules/Schedule/index.d.ts +4 -13
- package/dist/modules/Schedule/index.js +6 -23
- package/dist/modules/Schedule/utils.d.ts +1 -1
- package/dist/modules/Summary/index.d.ts +3 -0
- package/dist/modules/Summary/index.js +134 -15
- package/dist/modules/Summary/types.d.ts +7 -0
- package/dist/modules/Summary/utils.d.ts +104 -1
- package/dist/modules/Summary/utils.js +1116 -13
- package/dist/modules/index.d.ts +4 -0
- package/dist/modules/index.js +5 -1
- package/dist/server/index.d.ts +41 -4
- package/dist/server/index.js +900 -405
- package/dist/server/modules/order/index.d.ts +10 -2
- package/dist/server/modules/order/index.js +246 -193
- package/dist/server/modules/products/index.d.ts +26 -0
- package/dist/server/modules/products/index.js +618 -338
- package/dist/server/modules/products/types.d.ts +5 -1
- package/dist/solution/BaseSales/index.d.ts +175 -0
- package/dist/solution/BaseSales/index.js +1293 -0
- package/dist/solution/BaseSales/types.d.ts +305 -0
- package/dist/solution/BaseSales/types.js +38 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +143 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +159 -0
- package/dist/solution/BaseSales/utils.d.ts +40 -0
- package/dist/solution/BaseSales/utils.js +222 -0
- package/dist/solution/BookingByStep/index.d.ts +14 -0
- package/dist/solution/BookingByStep/index.js +699 -212
- package/dist/solution/BookingByStep/types.d.ts +3 -1
- package/dist/solution/BookingByStep/types.js +5 -1
- package/dist/solution/BookingByStep/utils/capacity.js +1 -1
- package/dist/solution/BookingByStep/utils/resources.js +6 -1
- package/dist/solution/BookingTicket/index.d.ts +113 -15
- package/dist/solution/BookingTicket/index.js +534 -196
- package/dist/solution/BookingTicket/types.d.ts +69 -6
- package/dist/solution/BookingTicket/types.js +40 -9
- package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +37 -0
- package/dist/solution/BookingTicket/utils/bookingStatus.js +66 -0
- package/dist/solution/BookingTicket/utils/cartView.d.ts +26 -0
- package/dist/solution/BookingTicket/utils/cartView.js +84 -0
- package/dist/solution/Sales/index.d.ts +1 -0
- package/dist/solution/Sales/index.js +1 -0
- package/dist/solution/ScanOrder/index.d.ts +146 -0
- package/dist/solution/ScanOrder/index.js +3029 -0
- package/dist/solution/ScanOrder/types.d.ts +305 -0
- package/dist/solution/ScanOrder/types.js +35 -0
- package/dist/solution/ScanOrder/utils.d.ts +167 -0
- package/dist/solution/ScanOrder/utils.js +768 -0
- package/dist/solution/ShopDiscount/index.d.ts +2 -0
- package/dist/solution/ShopDiscount/index.js +9 -5
- package/dist/solution/ShopDiscount/types.d.ts +4 -0
- package/dist/solution/VenueBooking/index.d.ts +197 -0
- package/dist/solution/VenueBooking/index.js +3411 -0
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/dist/solution/VenueBooking/types.d.ts +153 -0
- package/dist/solution/VenueBooking/types.js +21 -0
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +104 -0
- package/dist/solution/VenueBooking/utils/resource.d.ts +14 -0
- package/dist/solution/VenueBooking/utils/resource.js +130 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +34 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +224 -0
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/dist/solution/VenueBooking/utils/timeSlot.js +453 -0
- package/dist/solution/VenueBooking/utils.d.ts +1 -0
- package/dist/solution/VenueBooking/utils.js +1 -0
- package/dist/solution/index.d.ts +3 -0
- package/dist/solution/index.js +4 -1
- package/lib/apis/picoding.d.ts +0 -0
- package/lib/apis/picoding.js +0 -0
- package/lib/model/strategy/adapter/index.d.ts +2 -0
- package/lib/model/strategy/adapter/index.js +6 -0
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +67 -0
- package/lib/model/strategy/adapter/itemRule/adapter.js +377 -0
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
- package/lib/model/strategy/adapter/itemRule/evaluator.js +124 -0
- package/lib/model/strategy/adapter/itemRule/examples.d.ts +79 -0
- package/lib/model/strategy/adapter/itemRule/examples.js +316 -0
- package/lib/model/strategy/adapter/itemRule/index.d.ts +5 -0
- package/lib/model/strategy/adapter/itemRule/index.js +60 -0
- package/lib/model/strategy/adapter/itemRule/type.d.ts +225 -0
- package/lib/model/strategy/adapter/itemRule/type.js +46 -0
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/Cart/types.d.ts +2 -0
- package/lib/modules/Cart/utils/cartProduct.js +17 -1
- package/lib/modules/Cart/utils/changePrice.js +5 -0
- package/lib/modules/Date/index.d.ts +1 -1
- package/lib/modules/Date/index.js +7 -1
- package/lib/modules/Date/types.d.ts +3 -1
- package/lib/modules/OpenData/index.d.ts +24 -0
- package/lib/modules/OpenData/index.js +119 -0
- package/lib/modules/OpenData/types.d.ts +73 -0
- package/lib/modules/OpenData/types.js +17 -0
- package/lib/modules/OpenData/utils.d.ts +2 -0
- package/lib/modules/OpenData/utils.js +111 -0
- package/lib/modules/Order/index.d.ts +171 -1
- package/lib/modules/Order/index.js +1396 -5
- package/lib/modules/Order/types.d.ts +441 -20
- package/lib/modules/Order/types.js +1 -0
- package/lib/modules/Order/utils.d.ts +120 -0
- package/lib/modules/Order/utils.js +562 -2
- package/lib/modules/Product/utils.js +2 -2
- package/lib/modules/ProductList/index.js +2 -1
- package/lib/modules/Quotation/index.d.ts +8 -1
- package/lib/modules/Quotation/index.js +33 -4
- package/lib/modules/Quotation/types.d.ts +5 -0
- package/lib/modules/Rules/index.d.ts +3 -1
- package/lib/modules/Rules/index.js +46 -6
- package/lib/modules/Rules/types.d.ts +6 -0
- package/lib/modules/Rules/types.js +11 -2
- package/lib/modules/SalesSummary/index.d.ts +70 -0
- package/lib/modules/SalesSummary/index.js +106 -0
- package/lib/modules/SalesSummary/types.d.ts +64 -0
- package/lib/modules/SalesSummary/types.js +17 -0
- package/lib/modules/SalesSummary/utils.d.ts +34 -0
- package/lib/modules/SalesSummary/utils.js +430 -0
- package/lib/modules/ScanOrderLogger/index.d.ts +21 -0
- package/lib/modules/ScanOrderLogger/index.js +135 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.js +148 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.js +52 -0
- package/lib/modules/ScanOrderLogger/types.d.ts +52 -0
- package/lib/modules/ScanOrderLogger/types.js +17 -0
- package/lib/modules/Schedule/getDateIsInSchedule.js +5 -5
- package/lib/modules/Schedule/index.d.ts +4 -13
- package/lib/modules/Schedule/index.js +4 -15
- package/lib/modules/Schedule/utils.d.ts +1 -1
- package/lib/modules/Summary/index.d.ts +3 -0
- package/lib/modules/Summary/index.js +61 -2
- package/lib/modules/Summary/types.d.ts +7 -0
- package/lib/modules/Summary/utils.d.ts +104 -1
- package/lib/modules/Summary/utils.js +659 -8
- package/lib/modules/index.d.ts +4 -0
- package/lib/modules/index.js +9 -1
- package/lib/server/index.d.ts +41 -4
- package/lib/server/index.js +272 -10
- package/lib/server/modules/order/index.d.ts +10 -2
- package/lib/server/modules/order/index.js +26 -1
- package/lib/server/modules/products/index.d.ts +26 -0
- package/lib/server/modules/products/index.js +174 -22
- package/lib/server/modules/products/types.d.ts +5 -1
- package/lib/solution/BaseSales/index.d.ts +175 -0
- package/lib/solution/BaseSales/index.js +655 -0
- package/lib/solution/BaseSales/types.d.ts +305 -0
- package/lib/solution/BaseSales/types.js +40 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +143 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +160 -0
- package/lib/solution/BaseSales/utils.d.ts +40 -0
- package/lib/solution/BaseSales/utils.js +200 -0
- package/lib/solution/BookingByStep/index.d.ts +14 -0
- package/lib/solution/BookingByStep/index.js +469 -91
- package/lib/solution/BookingByStep/types.d.ts +3 -1
- package/lib/solution/BookingByStep/types.js +10 -0
- package/lib/solution/BookingByStep/utils/capacity.js +1 -1
- package/lib/solution/BookingByStep/utils/resources.js +5 -2
- package/lib/solution/BookingTicket/index.d.ts +113 -15
- package/lib/solution/BookingTicket/index.js +253 -61
- package/lib/solution/BookingTicket/types.d.ts +69 -6
- package/lib/solution/BookingTicket/types.js +16 -14
- package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +37 -0
- package/lib/solution/BookingTicket/utils/bookingStatus.js +65 -0
- package/lib/solution/BookingTicket/utils/cartView.d.ts +26 -0
- package/lib/solution/BookingTicket/utils/cartView.js +103 -0
- package/lib/solution/Sales/index.d.ts +1 -0
- package/lib/solution/ScanOrder/index.d.ts +146 -0
- package/lib/solution/ScanOrder/index.js +1820 -0
- package/lib/solution/ScanOrder/types.d.ts +305 -0
- package/lib/solution/ScanOrder/types.js +36 -0
- package/lib/solution/ScanOrder/utils.d.ts +167 -0
- package/lib/solution/ScanOrder/utils.js +639 -0
- package/lib/solution/ShopDiscount/index.d.ts +2 -0
- package/lib/solution/ShopDiscount/index.js +9 -4
- package/lib/solution/ShopDiscount/types.d.ts +4 -0
- package/lib/solution/VenueBooking/index.d.ts +197 -0
- package/lib/solution/VenueBooking/index.js +1892 -0
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/lib/solution/VenueBooking/types.d.ts +153 -0
- package/lib/solution/VenueBooking/types.js +44 -0
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +110 -0
- package/lib/solution/VenueBooking/utils/resource.d.ts +14 -0
- package/lib/solution/VenueBooking/utils/resource.js +91 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +34 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +225 -0
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/lib/solution/VenueBooking/utils/timeSlot.js +339 -0
- package/lib/solution/VenueBooking/utils.d.ts +1 -0
- package/lib/solution/VenueBooking/utils.js +69 -0
- package/lib/solution/index.d.ts +3 -0
- package/lib/solution/index.js +7 -1
- package/package.json +1 -1
|
@@ -23,7 +23,7 @@ __export(products_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(products_exports);
|
|
25
25
|
var import_BaseModule = require("../../../modules/BaseModule");
|
|
26
|
-
var
|
|
26
|
+
var import_Quotation = require("../../../modules/Quotation");
|
|
27
27
|
var import_types = require("./types");
|
|
28
28
|
var import_product = require("../../utils/product");
|
|
29
29
|
var INDEXDB_STORE_NAME = "products";
|
|
@@ -137,38 +137,30 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
137
137
|
*/
|
|
138
138
|
async loadProductsPrice({
|
|
139
139
|
ids = [],
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
schedule_date,
|
|
141
|
+
schedule_datetime,
|
|
142
|
+
customer_id
|
|
142
143
|
}) {
|
|
143
|
-
var _a;
|
|
144
144
|
this.logInfo("开始加载商品价格", {
|
|
145
145
|
productCount: ids.length,
|
|
146
146
|
schedule_date,
|
|
147
|
+
schedule_datetime,
|
|
147
148
|
customer_id
|
|
148
149
|
});
|
|
149
150
|
const startTime = Date.now();
|
|
151
|
+
const datetime = schedule_datetime || schedule_date;
|
|
150
152
|
try {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
customer_id,
|
|
156
|
-
schedule_date
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
cache: {
|
|
160
|
-
mode: import_plugins.RequestModeENUM.REMOTE_LOCAL,
|
|
161
|
-
type: "memory"
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
);
|
|
153
|
+
await this.ensureQuotationBridgeReady(customer_id);
|
|
154
|
+
const idSet = new Set(ids);
|
|
155
|
+
const products = this.getProductsRef().filter((product) => idSet.has(product.id));
|
|
156
|
+
const priceData = products.map((product) => this.buildPriceDataFromQuotation(product, datetime, customer_id));
|
|
165
157
|
const duration = Date.now() - startTime;
|
|
166
158
|
this.logInfo("加载商品价格成功", {
|
|
167
159
|
productCount: ids.length,
|
|
168
|
-
priceDataCount:
|
|
160
|
+
priceDataCount: priceData.length,
|
|
169
161
|
duration: `${duration}ms`
|
|
170
162
|
});
|
|
171
|
-
return
|
|
163
|
+
return priceData;
|
|
172
164
|
} catch (error) {
|
|
173
165
|
const duration = Date.now() - startTime;
|
|
174
166
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -180,6 +172,152 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
180
172
|
return [];
|
|
181
173
|
}
|
|
182
174
|
}
|
|
175
|
+
/**
|
|
176
|
+
* 设置报价单价格桥接器。
|
|
177
|
+
* Server 层负责传入完整 schedule 模块,Products 只负责把报价单计算结果转成价格响应形状。
|
|
178
|
+
*/
|
|
179
|
+
async setupQuotationPriceBridge(params) {
|
|
180
|
+
var _a, _b, _c;
|
|
181
|
+
if (!this.core) {
|
|
182
|
+
this.logWarning("setupQuotationPriceBridge: core 尚未初始化");
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
const channel = params.channel || ((_a = this.otherParams) == null ? void 0 : _a.channel);
|
|
186
|
+
this.quotationBridgeChannel = channel;
|
|
187
|
+
if (!this.quotationPriceBridge) {
|
|
188
|
+
const quotation = new import_Quotation.QuotationModule(`${this.name}_quotation_price_bridge`);
|
|
189
|
+
await quotation.initialize(this.core, {});
|
|
190
|
+
this.quotationPriceBridge = quotation;
|
|
191
|
+
}
|
|
192
|
+
if (params.scheduleModule) {
|
|
193
|
+
const scheduleList = ((_c = (_b = params.scheduleModule).getScheduleList) == null ? void 0 : _c.call(_b)) || [];
|
|
194
|
+
const scheduleMap = new Map(
|
|
195
|
+
scheduleList.map((schedule) => [schedule.id, schedule])
|
|
196
|
+
);
|
|
197
|
+
this.quotationPriceBridge.setScheduleResolver((id) => {
|
|
198
|
+
var _a2, _b2;
|
|
199
|
+
if (scheduleMap.has(id))
|
|
200
|
+
return scheduleMap.get(id);
|
|
201
|
+
const schedules = ((_b2 = (_a2 = params.scheduleModule).getScheduleByIds) == null ? void 0 : _b2.call(_a2, [id])) || [];
|
|
202
|
+
return schedules[0];
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
await this.refreshQuotationPriceBridge({ customer_id: params.customer_id });
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* 刷新桥接器内的报价单列表。
|
|
209
|
+
*/
|
|
210
|
+
async refreshQuotationPriceBridge(params) {
|
|
211
|
+
if (!this.quotationPriceBridge)
|
|
212
|
+
return;
|
|
213
|
+
const customerId = params && "customer_id" in params ? params.customer_id : this.quotationBridgeCustomerId;
|
|
214
|
+
const refreshKey = this.getQuotationBridgeScopeKey(customerId);
|
|
215
|
+
if (this.quotationBridgeRefreshPromise && this.quotationBridgeRefreshKey === refreshKey) {
|
|
216
|
+
await this.quotationBridgeRefreshPromise;
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
if (this.quotationBridgeRefreshPromise) {
|
|
220
|
+
await this.quotationBridgeRefreshPromise;
|
|
221
|
+
}
|
|
222
|
+
this.quotationBridgeRefreshKey = refreshKey;
|
|
223
|
+
this.quotationBridgeRefreshPromise = this.quotationPriceBridge.loadQuotations({
|
|
224
|
+
channel: this.quotationBridgeChannel,
|
|
225
|
+
customer_id: customerId
|
|
226
|
+
}).then(() => {
|
|
227
|
+
this.quotationBridgeCustomerId = customerId;
|
|
228
|
+
}).finally(() => {
|
|
229
|
+
this.quotationBridgeRefreshPromise = void 0;
|
|
230
|
+
this.quotationBridgeRefreshKey = void 0;
|
|
231
|
+
});
|
|
232
|
+
await this.quotationBridgeRefreshPromise;
|
|
233
|
+
}
|
|
234
|
+
async ensureQuotationBridgeReady(customerId) {
|
|
235
|
+
var _a;
|
|
236
|
+
if (!this.quotationPriceBridge) {
|
|
237
|
+
await this.setupQuotationPriceBridge({
|
|
238
|
+
channel: (_a = this.otherParams) == null ? void 0 : _a.channel,
|
|
239
|
+
customer_id: customerId
|
|
240
|
+
});
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
if (this.quotationBridgeRefreshPromise) {
|
|
244
|
+
await this.quotationBridgeRefreshPromise;
|
|
245
|
+
}
|
|
246
|
+
if (this.getQuotationBridgeScopeKey(customerId) !== this.getQuotationBridgeScopeKey(this.quotationBridgeCustomerId)) {
|
|
247
|
+
await this.refreshQuotationPriceBridge({ customer_id: customerId });
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
getQuotationBridgeScopeKey(customerId) {
|
|
251
|
+
return `${this.quotationBridgeChannel || ""}:${customerId ?? ""}`;
|
|
252
|
+
}
|
|
253
|
+
buildPriceDataFromQuotation(product, datetime, customerId) {
|
|
254
|
+
var _a;
|
|
255
|
+
const quotedPrice = (_a = this.quotationPriceBridge) == null ? void 0 : _a.getPriceForProduct({
|
|
256
|
+
productId: product.id,
|
|
257
|
+
datetime,
|
|
258
|
+
customer_id: customerId
|
|
259
|
+
});
|
|
260
|
+
const productPrice = quotedPrice ?? product.price;
|
|
261
|
+
return {
|
|
262
|
+
id: product.id,
|
|
263
|
+
price: String(productPrice ?? 0),
|
|
264
|
+
base_price: String(product.base_price ?? product.price ?? 0),
|
|
265
|
+
variant: this.buildVariantPriceData(product, datetime, customerId),
|
|
266
|
+
bundle_group: this.buildBundleGroupPriceData(product, datetime, customerId)
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
buildVariantPriceData(product, datetime, customerId) {
|
|
270
|
+
if (!Array.isArray(product.variant))
|
|
271
|
+
return [];
|
|
272
|
+
return product.variant.map((variant) => {
|
|
273
|
+
var _a;
|
|
274
|
+
const quotedPrice = (_a = this.quotationPriceBridge) == null ? void 0 : _a.getPriceForProduct({
|
|
275
|
+
productId: product.id,
|
|
276
|
+
variantId: Number(variant.id),
|
|
277
|
+
datetime,
|
|
278
|
+
customer_id: customerId
|
|
279
|
+
});
|
|
280
|
+
const price = quotedPrice ?? variant.price ?? product.price ?? 0;
|
|
281
|
+
const basePrice = variant.base_price ?? variant.price ?? product.base_price ?? product.price ?? 0;
|
|
282
|
+
return {
|
|
283
|
+
id: Number(variant.id),
|
|
284
|
+
product_id: Number(variant.product_id ?? product.id),
|
|
285
|
+
base_price: Number(basePrice),
|
|
286
|
+
price: Number(price)
|
|
287
|
+
};
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
buildBundleGroupPriceData(product, datetime, customerId) {
|
|
291
|
+
if (!Array.isArray(product.bundle_group))
|
|
292
|
+
return [];
|
|
293
|
+
return product.bundle_group.map((group) => ({
|
|
294
|
+
id: Number(group.id),
|
|
295
|
+
bundle_item: (group.bundle_item || []).map((item) => {
|
|
296
|
+
var _a;
|
|
297
|
+
const bundleProductId = Number(item.bundle_product_id);
|
|
298
|
+
const bundleVariantId = Number(item.bundle_variant_id || 0);
|
|
299
|
+
const quotedPrice = (_a = this.quotationPriceBridge) == null ? void 0 : _a.getPriceForProduct({
|
|
300
|
+
productId: bundleProductId,
|
|
301
|
+
variantId: bundleVariantId,
|
|
302
|
+
datetime,
|
|
303
|
+
customer_id: customerId
|
|
304
|
+
});
|
|
305
|
+
const price = quotedPrice ?? item.price ?? 0;
|
|
306
|
+
const basePrice = item.base_price ?? item.price ?? 0;
|
|
307
|
+
return {
|
|
308
|
+
id: Number(item.id),
|
|
309
|
+
product_id: Number(item.product_id ?? product.id),
|
|
310
|
+
group_id: Number(item.group_id ?? group.id),
|
|
311
|
+
bundle_product_id: bundleProductId,
|
|
312
|
+
bundle_variant_id: bundleVariantId,
|
|
313
|
+
price: Number(price),
|
|
314
|
+
base_price: basePrice,
|
|
315
|
+
price_type: item.price_type,
|
|
316
|
+
price_type_ext: item.price_type_ext
|
|
317
|
+
};
|
|
318
|
+
})
|
|
319
|
+
}));
|
|
320
|
+
}
|
|
183
321
|
/**
|
|
184
322
|
* 获取应用了价格的商品列表(带缓存)
|
|
185
323
|
* 使用日期作为缓存 key,同一天的商品价格会被缓存
|
|
@@ -192,7 +330,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
192
330
|
*/
|
|
193
331
|
async getProductsWithPrice(schedule_date, extraContext, options) {
|
|
194
332
|
const t0 = performance.now();
|
|
195
|
-
const cacheKey = schedule_date;
|
|
333
|
+
const cacheKey = this.getProductsPriceCacheKey(schedule_date, extraContext);
|
|
196
334
|
const changedIds = options == null ? void 0 : options.changedIds;
|
|
197
335
|
if (this.productsPriceCache.has(cacheKey)) {
|
|
198
336
|
const cachedProducts = this.productsPriceCache.get(cacheKey);
|
|
@@ -313,12 +451,16 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
313
451
|
const tPrice = performance.now();
|
|
314
452
|
const priceData = await this.loadProductsPrice({
|
|
315
453
|
ids,
|
|
316
|
-
schedule_date
|
|
454
|
+
schedule_date,
|
|
455
|
+
schedule_datetime: extraContext == null ? void 0 : extraContext.schedule_datetime,
|
|
456
|
+
customer_id: extraContext == null ? void 0 : extraContext.customer_id
|
|
317
457
|
});
|
|
318
458
|
(0, import_product.perfMark)("prepareProducts.loadPrice", performance.now() - tPrice, { count: ids.length });
|
|
319
459
|
this.logInfo("获取商品报价单价格成功", { priceDataCount: (priceData == null ? void 0 : priceData.length) ?? 0 });
|
|
320
460
|
const context = {
|
|
321
461
|
schedule_date,
|
|
462
|
+
schedule_datetime: extraContext == null ? void 0 : extraContext.schedule_datetime,
|
|
463
|
+
customer_id: extraContext == null ? void 0 : extraContext.customer_id,
|
|
322
464
|
priceData,
|
|
323
465
|
locale: (_b = (_a = this.core) == null ? void 0 : _a.context) == null ? void 0 : _b.locale,
|
|
324
466
|
...extraContext
|
|
@@ -357,6 +499,10 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
357
499
|
}
|
|
358
500
|
return [];
|
|
359
501
|
}
|
|
502
|
+
getProductsPriceCacheKey(schedule_date, extraContext) {
|
|
503
|
+
const datetime = (extraContext == null ? void 0 : extraContext.schedule_datetime) || schedule_date;
|
|
504
|
+
return `${datetime}:customer:${(extraContext == null ? void 0 : extraContext.customer_id) ?? ""}`;
|
|
505
|
+
}
|
|
360
506
|
/**
|
|
361
507
|
* 应用所有已注册的格式化器
|
|
362
508
|
* @param products 商品列表
|
|
@@ -1021,6 +1167,12 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
1021
1167
|
return;
|
|
1022
1168
|
}
|
|
1023
1169
|
if (shouldClearPriceCache) {
|
|
1170
|
+
try {
|
|
1171
|
+
await this.refreshQuotationPriceBridge();
|
|
1172
|
+
} catch (error) {
|
|
1173
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1174
|
+
this.logError("报价单桥接刷新失败,将继续清理价格缓存", { error: errorMessage });
|
|
1175
|
+
}
|
|
1024
1176
|
this.clearPriceCache();
|
|
1025
1177
|
}
|
|
1026
1178
|
await this.core.effects.emit(import_types.ProductsHooks.onProductsSyncCompleted, {
|
|
@@ -23,7 +23,8 @@ export interface FormattedProductData extends ProductData {
|
|
|
23
23
|
export interface LoadProductsPriceParams {
|
|
24
24
|
ids: number[];
|
|
25
25
|
schedule_date: string;
|
|
26
|
-
|
|
26
|
+
schedule_datetime?: string;
|
|
27
|
+
customer_id?: number | string;
|
|
27
28
|
}
|
|
28
29
|
/**
|
|
29
30
|
* 加载报价单商品价格返回数据
|
|
@@ -47,6 +48,7 @@ export interface LoadProductsPriceData {
|
|
|
47
48
|
bundle_product_id: number;
|
|
48
49
|
bundle_variant_id: number;
|
|
49
50
|
price: number;
|
|
51
|
+
base_price?: number | string;
|
|
50
52
|
price_type: string;
|
|
51
53
|
price_type_ext: string;
|
|
52
54
|
}[];
|
|
@@ -107,6 +109,8 @@ export interface ProductSyncMessage {
|
|
|
107
109
|
*/
|
|
108
110
|
export interface ProductFormatterContext {
|
|
109
111
|
schedule_date: string;
|
|
112
|
+
schedule_datetime?: string;
|
|
113
|
+
customer_id?: number | string;
|
|
110
114
|
priceData?: LoadProductsPriceData[];
|
|
111
115
|
scheduleModule?: any;
|
|
112
116
|
locale?: string;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { Module, ModuleOptions, PisellCore } from '../../types';
|
|
2
|
+
import { BaseModule } from '../../modules/BaseModule';
|
|
3
|
+
import { BaseSalesOrderProduct, BaseSalesOrderProductIdentity, BaseSalesPaymentStatus, BaseSalesScanCodeResult } from './types';
|
|
4
|
+
import { OrderModule } from '../../modules/Order';
|
|
5
|
+
import type { AddProductBookingInput, LoadSalesDetailParams, OrderPaymentData, OrderPaymentSource, SendCustomerPayLinkParams, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, UpdateTempOrderCustomerInput, UpdateProductInOrderParams } from '../../modules/Order/types';
|
|
6
|
+
import type { SubmitPayloadEnhancer } from '../../modules/Order/utils';
|
|
7
|
+
import type { Discount } from '../../modules/Discount/types';
|
|
8
|
+
import { RequestPlugin, WindowPlugin } from '../../plugins';
|
|
9
|
+
export * from './types';
|
|
10
|
+
import { ProductList } from '../../modules/ProductList';
|
|
11
|
+
import type { SalesSummaryModule } from '../../modules/SalesSummary';
|
|
12
|
+
import type { ScheduleModule } from '../../modules/Schedule';
|
|
13
|
+
import type { ISalesDetail, ISalesDetailHeader, ISalesBooking, ISalesPayment, ISalesSurcharge } from './utils/parseSalesResponse';
|
|
14
|
+
export interface BaseSalesState {
|
|
15
|
+
order?: OrderModule;
|
|
16
|
+
products?: ProductList;
|
|
17
|
+
salesSummary?: SalesSummaryModule;
|
|
18
|
+
schedule?: ScheduleModule;
|
|
19
|
+
}
|
|
20
|
+
export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
21
|
+
protected defaultName: string;
|
|
22
|
+
protected defaultVersion: string;
|
|
23
|
+
isSolution: boolean;
|
|
24
|
+
protected initializeOptions: ModuleOptions;
|
|
25
|
+
protected store: BaseSalesState;
|
|
26
|
+
protected otherParams: Record<string, any>;
|
|
27
|
+
protected cacheId: string | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* window / request 暴露为 public:现存外部工具(如 BookingTicket Scan)通过
|
|
30
|
+
* `solution.window` / `solution.request` 直接访问插件,保持原有契约不破坏。
|
|
31
|
+
*/
|
|
32
|
+
window: WindowPlugin;
|
|
33
|
+
request: RequestPlugin;
|
|
34
|
+
protected currentSalesDetail: ISalesDetail | null;
|
|
35
|
+
constructor(name?: string, version?: string);
|
|
36
|
+
/**
|
|
37
|
+
* 子类可覆盖此方法以追加/收敛要注册的子模块。
|
|
38
|
+
* 默认包含通用销售模块:products / order / salesSummary / schedule。
|
|
39
|
+
*/
|
|
40
|
+
protected getRegisteredModuleNames(): readonly string[];
|
|
41
|
+
/**
|
|
42
|
+
* 工厂入口:根据子模块名实例化对应模块。
|
|
43
|
+
* 默认使用 BookingByStep 公共 `createModule`。子类若需引入额外类型(如 customer),
|
|
44
|
+
* 可覆盖此方法并把未识别的 name 委托给 `super.createSubModule(name)`。
|
|
45
|
+
*/
|
|
46
|
+
protected createSubModule(moduleName: string): Module | null;
|
|
47
|
+
/**
|
|
48
|
+
* 读取 sessionStorage[this.name][cacheId],作为子模块 initialState 的来源。
|
|
49
|
+
* sessionStorage 损坏时静默忽略,按空状态注册。
|
|
50
|
+
*/
|
|
51
|
+
protected readSessionCacheData(): Record<string, any>;
|
|
52
|
+
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
53
|
+
destroy(): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* 加载销售订单到统一 tempOrder 工作区。
|
|
56
|
+
* 有 app.sqlite 时优先读取本地记录;本地未命中或 forceRemote=true 时再拉云端。
|
|
57
|
+
*
|
|
58
|
+
* 子类可在 `super.loadSalesDetail` 之后基于返回的 `sales` 做业务侧装配
|
|
59
|
+
* (比如把 `sales.customer` 写入 CustomerModule、emit 业务 hook 等)。
|
|
60
|
+
*/
|
|
61
|
+
loadSalesDetail(orderIdOrParams: number | string | LoadSalesDetailParams): Promise<ISalesDetail>;
|
|
62
|
+
/** 获取当前已加载的销售详情(只读快照)。未加载过则返回 null。 */
|
|
63
|
+
getSalesOrder(): ISalesDetail | null;
|
|
64
|
+
/** 获取销售详情顶部业务字段(订单号/状态/金额等通用字段集合)。 */
|
|
65
|
+
getOrderHeader(): ISalesDetailHeader | null;
|
|
66
|
+
/** 获取所有 booking(含 root + children),按服务端原始顺序输出。 */
|
|
67
|
+
getBookings(): ISalesBooking[];
|
|
68
|
+
/** 获取根 booking(is_next === 0 / is_root === 1),多个时取第一个。 */
|
|
69
|
+
getRootBooking(): ISalesBooking | null;
|
|
70
|
+
/** 按 product_uid 反查 booking 列表(用于商品行 ↔ booking 映射)。 */
|
|
71
|
+
getChildBookingsByProductUid(productUid: string): ISalesBooking[];
|
|
72
|
+
/** 获取支付列表(已支付/退款等明细)。 */
|
|
73
|
+
getPayments(): ISalesPayment[];
|
|
74
|
+
/** 获取附加费用(运费/服务费/税费等)。 */
|
|
75
|
+
getSurcharges(): ISalesSurcharge[];
|
|
76
|
+
getTempOrder(): import("../../modules/Order/types").OrderTempOrder | null;
|
|
77
|
+
getOrderIdentity(): import("../../modules/Order/types").OrderIdentitySnapshot | null;
|
|
78
|
+
getOrderSnapshot(): import("../../modules/Order/types").OrderSnapshot | null;
|
|
79
|
+
getOrderSyncState(): import("../../modules/Order/types").OrderSyncState;
|
|
80
|
+
getOrderAmountSnapshot(): import("../../modules/Order/types").OrderAmountSnapshot | null;
|
|
81
|
+
getTempOrderNote(): string;
|
|
82
|
+
updateTempOrderNote(note: string): string;
|
|
83
|
+
updateOrderShopDiscount(amount: string | number): string;
|
|
84
|
+
private ensureTempOrder;
|
|
85
|
+
addNewOrder(): Promise<import("../../modules/Order/types").OrderTempOrder>;
|
|
86
|
+
saveDraft(): Promise<void>;
|
|
87
|
+
restoreOrder(): Promise<import("../../modules/Order/types").OrderTempOrder>;
|
|
88
|
+
getOrderProducts(): import("../../modules/Order/types").OrderProduct[];
|
|
89
|
+
getSummary(): Promise<import("../../modules/Order/types").OrderSummary>;
|
|
90
|
+
getDiscountList(): Discount[];
|
|
91
|
+
scanPromotionCode(code: string, customerId?: number): Promise<BaseSalesScanCodeResult>;
|
|
92
|
+
setDiscountSelected(params: {
|
|
93
|
+
discountId: number;
|
|
94
|
+
isSelected: boolean;
|
|
95
|
+
}): Promise<void>;
|
|
96
|
+
submitScanOrder<T = any>(params?: {
|
|
97
|
+
payments?: OrderPaymentSource[];
|
|
98
|
+
paymentStatus?: BaseSalesPaymentStatus;
|
|
99
|
+
smallTicketDataFlag?: number;
|
|
100
|
+
enhancePayload?: SubmitPayloadEnhancer;
|
|
101
|
+
}): Promise<T>;
|
|
102
|
+
/**
|
|
103
|
+
* 提交当前 Sales 订单。
|
|
104
|
+
*
|
|
105
|
+
* PaymentModal 场景通过 smallTicketDataFlag=1 请求 B 端小票数据;
|
|
106
|
+
* payments 会交给 OrderModule 统一映射为 Sales 协议支付项。
|
|
107
|
+
*/
|
|
108
|
+
submitSalesOrder<T = any>(params?: {
|
|
109
|
+
payments?: OrderPaymentSource[];
|
|
110
|
+
paymentStatus?: BaseSalesPaymentStatus;
|
|
111
|
+
smallTicketDataFlag?: number;
|
|
112
|
+
enhancePayload?: SubmitPayloadEnhancer;
|
|
113
|
+
}): Promise<T>;
|
|
114
|
+
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
115
|
+
/** 读取当前 BaseSales 订单上下文中的 Sales 协议支付项。 */
|
|
116
|
+
getOrderPayments(): OrderPaymentData[];
|
|
117
|
+
/** 覆盖当前订单支付项,内部由 OrderModule 清洗为 Sales 协议字段。 */
|
|
118
|
+
setOrderPayments(payments: OrderPaymentSource[]): OrderPaymentData[];
|
|
119
|
+
/** 追加单个支付项到当前订单。 */
|
|
120
|
+
addOrderPayment(payment: OrderPaymentSource): OrderPaymentData[];
|
|
121
|
+
/** 更新当前订单中的指定支付项。 */
|
|
122
|
+
updateOrderPayment(paymentIdentity: string | number, updates: Partial<OrderPaymentData> & Record<string, any>): OrderPaymentData[];
|
|
123
|
+
/** 删除当前订单中的指定支付项。 */
|
|
124
|
+
deleteOrderPayment(paymentIdentity: string | number): OrderPaymentData[];
|
|
125
|
+
/** 覆盖 wallet pass 支付项,同时保留普通支付项。 */
|
|
126
|
+
updateVoucherOrderPayments(payments: OrderPaymentSource[]): OrderPaymentData[];
|
|
127
|
+
/**
|
|
128
|
+
* 更新当前订单客户字段。
|
|
129
|
+
*
|
|
130
|
+
* 这是 PaymentModal 客户切换的订单事实入口;外部客户模块同步应由
|
|
131
|
+
* 调用方通过 onCustomerChange 回调完成。
|
|
132
|
+
*/
|
|
133
|
+
updateOrderCustomer(customer: UpdateTempOrderCustomerInput): {
|
|
134
|
+
customerId: number | null;
|
|
135
|
+
customerName: string;
|
|
136
|
+
phone: string;
|
|
137
|
+
email: string;
|
|
138
|
+
};
|
|
139
|
+
/** 获取可用支付方式列表,供 PaymentModal 渲染支付选项。 */
|
|
140
|
+
getPaymentMethodsAsync(): Promise<any[]>;
|
|
141
|
+
/** 轻量舍入能力,供现金支付 UI 计算 rounding_amount。 */
|
|
142
|
+
roundAmount(params: {
|
|
143
|
+
amount: string | number;
|
|
144
|
+
interval?: string | number;
|
|
145
|
+
rule?: 'standard_rounding' | 'standard_down' | 'always_up' | 'always_down' | string;
|
|
146
|
+
}): {
|
|
147
|
+
originalAmount: string;
|
|
148
|
+
roundedAmount: string;
|
|
149
|
+
roundingDifference: string;
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* 发送支付链接。
|
|
153
|
+
*
|
|
154
|
+
* 如果没有 orderIds 或显式 submitBeforeSend,会先提交当前本地订单到云端;
|
|
155
|
+
* 只有成功拿到远端 order_id 后才调用 OrderModule 发送邮件。
|
|
156
|
+
*/
|
|
157
|
+
sendCustomerPayLink<T = any>(params: Omit<SendCustomerPayLinkParams, 'orderIds' | 'order_ids'> & {
|
|
158
|
+
orderIds?: Array<number | string>;
|
|
159
|
+
order_ids?: Array<number | string>;
|
|
160
|
+
submitBeforeSend?: boolean;
|
|
161
|
+
}): Promise<T>;
|
|
162
|
+
addProductToOrder(product: Partial<BaseSalesOrderProduct> & BaseSalesOrderProductIdentity, booking?: AddProductBookingInput): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
163
|
+
updateProductInOrder(params: UpdateProductInOrderParams): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
164
|
+
/**
|
|
165
|
+
* 设置单行商品备注(与整单 `updateTempOrderNote` 区分)。
|
|
166
|
+
* 多行同 SKU 时必须传入与删除/更新一致的 unique_identification_number。
|
|
167
|
+
*/
|
|
168
|
+
setOrderProductLineNote(identity: BaseSalesOrderProductIdentity, note: string): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
169
|
+
removeProductFromOrder(identity: BaseSalesOrderProductIdentity): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
170
|
+
getProductList(): Promise<any>;
|
|
171
|
+
getOtherParams(): Record<string, any>;
|
|
172
|
+
setOtherParams(params: Record<string, any>, { cover }?: {
|
|
173
|
+
cover?: boolean;
|
|
174
|
+
}): Promise<void>;
|
|
175
|
+
}
|