@pisell/pisellos 2.2.326 → 2.2.328

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.
Files changed (32) hide show
  1. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +2 -1
  2. package/dist/model/strategy/adapter/dataVariant/evaluator.js +60 -15
  3. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  4. package/dist/modules/OpenData/index.d.ts +8 -1
  5. package/dist/modules/OpenData/index.js +276 -95
  6. package/dist/modules/Order/index.d.ts +1 -1
  7. package/dist/modules/Product/index.d.ts +1 -1
  8. package/dist/server/index.d.ts +3 -0
  9. package/dist/server/index.js +857 -598
  10. package/dist/server/modules/order/index.d.ts +1 -0
  11. package/dist/server/modules/order/index.js +51 -51
  12. package/dist/solution/BookingByStep/index.d.ts +1 -1
  13. package/dist/solution/Sales/index.d.ts +2 -5
  14. package/dist/solution/Sales/index.js +117 -143
  15. package/dist/solution/Sales/types.d.ts +6 -0
  16. package/dist/solution/Sales/types.js +2 -0
  17. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +2 -1
  18. package/lib/model/strategy/adapter/dataVariant/evaluator.js +40 -6
  19. package/lib/modules/OpenData/index.d.ts +8 -1
  20. package/lib/modules/OpenData/index.js +123 -21
  21. package/lib/modules/Order/index.d.ts +1 -1
  22. package/lib/modules/Product/index.d.ts +1 -1
  23. package/lib/server/index.d.ts +3 -0
  24. package/lib/server/index.js +155 -18
  25. package/lib/server/modules/order/index.d.ts +1 -0
  26. package/lib/server/modules/order/index.js +4 -3
  27. package/lib/solution/BookingByStep/index.d.ts +1 -1
  28. package/lib/solution/Sales/index.d.ts +2 -5
  29. package/lib/solution/Sales/index.js +32 -66
  30. package/lib/solution/Sales/types.d.ts +6 -0
  31. package/lib/solution/Sales/types.js +1 -0
  32. package/package.json +1 -1
@@ -29,12 +29,9 @@ import dayjs from 'dayjs';
29
29
  import { cloneDeep } from 'lodash-es';
30
30
  import { BaseModule } from "../../modules/BaseModule";
31
31
  import { SalesHooks } from "./types";
32
- import { getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings, OpenDataModule } from "../../modules/OpenData";
32
+ import { getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings, OpenDataModule, normalizeInvoiceLayoutFromTemplateSettings } from "../../modules/OpenData";
33
33
  export * from "./types";
34
34
  var UNPAID_PAYMENT_STATUSES = new Set(['unpaid', 'partially_paid', 'payment_processing']);
35
- var INVOICE_OPEN_DATA_SECTION_CODES = ['documents'];
36
- var INVOICE_OPEN_DATA_CACHE_TTL = 5 * 60 * 1000;
37
-
38
35
  /**
39
36
  * Sales 解决方案基础骨架
40
37
  *
@@ -64,9 +61,6 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
64
61
  _defineProperty(_assertThisInitialized(_this), "logger", void 0);
65
62
  // LoggerManager 实例
66
63
  _defineProperty(_assertThisInitialized(_this), "invoiceOpenDataModule", null);
67
- _defineProperty(_assertThisInitialized(_this), "invoiceOpenDataTarget", null);
68
- _defineProperty(_assertThisInitialized(_this), "invoiceOpenDataInFlight", null);
69
- _defineProperty(_assertThisInitialized(_this), "invoiceOpenDataInFlightTarget", null);
70
64
  return _this;
71
65
  }
72
66
  _createClass(SalesImpl, [{
@@ -110,9 +104,6 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
110
104
  // 在这里补充从 Server/Order 读取 currentDay 原始数据并转换为预约列表。
111
105
 
112
106
  this.logger = appPlugin === null || appPlugin === void 0 ? void 0 : appPlugin.getApp().logger;
113
- this.invoiceOpenDataTarget = null;
114
- this.invoiceOpenDataInFlight = null;
115
- this.invoiceOpenDataInFlightTarget = null;
116
107
  this.invoiceOpenDataModule = new OpenDataModule("".concat(this.name, "_invoiceOpenData"));
117
108
  this.core.registerModule(this.invoiceOpenDataModule, {
118
109
  initialState: {},
@@ -122,9 +113,9 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
122
113
  platform: (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.platform
123
114
  }
124
115
  });
125
- _context.next = 18;
116
+ _context.next = 15;
126
117
  return this.core.effects.emit("".concat(this.name, ":onInited"), {});
127
- case 18:
118
+ case 15:
128
119
  case "end":
129
120
  return _context.stop();
130
121
  }
@@ -259,93 +250,6 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
259
250
  var normalized = String((_ref = channel !== null && channel !== void 0 ? channel : contextChannel) !== null && _ref !== void 0 ? _ref : '').trim();
260
251
  return !normalized || normalized === 'system' ? 'pos' : normalized;
261
252
  }
262
- }, {
263
- key: "loadInvoiceOpenData",
264
- value: function () {
265
- var _loadInvoiceOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(businessCode, channel) {
266
- var target, cachedData, lastFetchedAt, request, openData;
267
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
268
- while (1) switch (_context4.prev = _context4.next) {
269
- case 0:
270
- if (this.invoiceOpenDataModule) {
271
- _context4.next = 2;
272
- break;
273
- }
274
- throw new Error('Sales Invoice OpenData 模块未初始化');
275
- case 2:
276
- target = "".concat(businessCode, "+").concat(channel);
277
- cachedData = this.invoiceOpenDataModule.getOpenData();
278
- lastFetchedAt = this.invoiceOpenDataModule.getLastFetchedAt();
279
- if (!(cachedData && this.invoiceOpenDataTarget === target && typeof lastFetchedAt === 'number' && Date.now() - lastFetchedAt < INVOICE_OPEN_DATA_CACHE_TTL)) {
280
- _context4.next = 10;
281
- break;
282
- }
283
- if (!(typeof this.invoiceOpenDataModule.ensureInvoiceTemplateSettings === 'function')) {
284
- _context4.next = 9;
285
- break;
286
- }
287
- _context4.next = 9;
288
- return this.invoiceOpenDataModule.ensureInvoiceTemplateSettings(target);
289
- case 9:
290
- return _context4.abrupt("return", cachedData);
291
- case 10:
292
- if (!this.invoiceOpenDataInFlight) {
293
- _context4.next = 21;
294
- break;
295
- }
296
- if (!(this.invoiceOpenDataInFlightTarget === target)) {
297
- _context4.next = 13;
298
- break;
299
- }
300
- return _context4.abrupt("return", this.invoiceOpenDataInFlight);
301
- case 13:
302
- _context4.prev = 13;
303
- _context4.next = 16;
304
- return this.invoiceOpenDataInFlight;
305
- case 16:
306
- _context4.next = 20;
307
- break;
308
- case 18:
309
- _context4.prev = 18;
310
- _context4.t0 = _context4["catch"](13);
311
- case 20:
312
- return _context4.abrupt("return", this.loadInvoiceOpenData(businessCode, channel));
313
- case 21:
314
- request = this.invoiceOpenDataModule.fetchOpenData({
315
- scope: 'board',
316
- target: target,
317
- section_code: [].concat(INVOICE_OPEN_DATA_SECTION_CODES)
318
- });
319
- this.invoiceOpenDataInFlight = request;
320
- this.invoiceOpenDataInFlightTarget = target;
321
- _context4.prev = 24;
322
- _context4.next = 27;
323
- return request;
324
- case 27:
325
- openData = _context4.sent;
326
- // clearOpenDataCache() 或后续请求接管后,旧响应不得复活 target 归属。
327
- if (this.invoiceOpenDataInFlight === request) {
328
- this.invoiceOpenDataTarget = target;
329
- }
330
- return _context4.abrupt("return", openData);
331
- case 30:
332
- _context4.prev = 30;
333
- if (this.invoiceOpenDataInFlight === request) {
334
- this.invoiceOpenDataInFlight = null;
335
- this.invoiceOpenDataInFlightTarget = null;
336
- }
337
- return _context4.finish(30);
338
- case 33:
339
- case "end":
340
- return _context4.stop();
341
- }
342
- }, _callee4, this, [[13, 18], [24,, 30, 33]]);
343
- }));
344
- function loadInvoiceOpenData(_x4, _x5) {
345
- return _loadInvoiceOpenData.apply(this, arguments);
346
- }
347
- return loadInvoiceOpenData;
348
- }()
349
253
  }, {
350
254
  key: "logInvoiceOpenDataFallback",
351
255
  value: function logInvoiceOpenDataFallback(error) {
@@ -366,43 +270,41 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
366
270
  }, {
367
271
  key: "resolveInvoiceConfigs",
368
272
  value: function () {
369
- var _resolveInvoiceConfigs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(businessCode, channel) {
370
- var _this$invoiceOpenData, _this$invoiceOpenData2, _this$invoiceOpenData3, _this$invoiceOpenData4;
371
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
372
- while (1) switch (_context5.prev = _context5.next) {
273
+ var _resolveInvoiceConfigs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(businessCode, channel) {
274
+ var templateSettings;
275
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
276
+ while (1) switch (_context4.prev = _context4.next) {
373
277
  case 0:
374
- _context5.prev = 0;
375
- _context5.next = 3;
376
- return this.loadInvoiceOpenData(businessCode, channel);
377
- case 3:
378
- if (!(this.invoiceOpenDataTarget !== "".concat(businessCode, "+").concat(channel))) {
379
- _context5.next = 5;
278
+ _context4.prev = 0;
279
+ if (this.invoiceOpenDataModule) {
280
+ _context4.next = 3;
380
281
  break;
381
282
  }
382
- return _context5.abrupt("return", {
383
- invoice: getDefaultInvoiceLayoutConfig(),
384
- templateSettings: getDefaultInvoiceTemplateSettings()
385
- });
283
+ throw new Error('Sales Invoice OpenData 模块未初始化');
284
+ case 3:
285
+ _context4.next = 5;
286
+ return this.invoiceOpenDataModule.loadPrintInvoiceTemplate("".concat(businessCode, "+").concat(channel), 'manual');
386
287
  case 5:
387
- return _context5.abrupt("return", {
388
- invoice: (_this$invoiceOpenData = (_this$invoiceOpenData2 = this.invoiceOpenDataModule) === null || _this$invoiceOpenData2 === void 0 ? void 0 : _this$invoiceOpenData2.getInvoiceLayoutConfig()) !== null && _this$invoiceOpenData !== void 0 ? _this$invoiceOpenData : getDefaultInvoiceLayoutConfig(),
389
- templateSettings: (_this$invoiceOpenData3 = (_this$invoiceOpenData4 = this.invoiceOpenDataModule) === null || _this$invoiceOpenData4 === void 0 ? void 0 : _this$invoiceOpenData4.getInvoiceTemplateSettings()) !== null && _this$invoiceOpenData3 !== void 0 ? _this$invoiceOpenData3 : getDefaultInvoiceTemplateSettings()
288
+ templateSettings = _context4.sent;
289
+ return _context4.abrupt("return", {
290
+ invoice: normalizeInvoiceLayoutFromTemplateSettings(templateSettings),
291
+ templateSettings: templateSettings
390
292
  });
391
- case 8:
392
- _context5.prev = 8;
393
- _context5.t0 = _context5["catch"](0);
394
- this.logInvoiceOpenDataFallback(_context5.t0);
395
- return _context5.abrupt("return", {
293
+ case 9:
294
+ _context4.prev = 9;
295
+ _context4.t0 = _context4["catch"](0);
296
+ this.logInvoiceOpenDataFallback(_context4.t0);
297
+ return _context4.abrupt("return", {
396
298
  invoice: getDefaultInvoiceLayoutConfig(),
397
299
  templateSettings: getDefaultInvoiceTemplateSettings()
398
300
  });
399
- case 12:
301
+ case 13:
400
302
  case "end":
401
- return _context5.stop();
303
+ return _context4.stop();
402
304
  }
403
- }, _callee5, this, [[0, 8]]);
305
+ }, _callee4, this, [[0, 9]]);
404
306
  }));
405
- function resolveInvoiceConfigs(_x6, _x7) {
307
+ function resolveInvoiceConfigs(_x4, _x5) {
406
308
  return _resolveInvoiceConfigs.apply(this, arguments);
407
309
  }
408
310
  return resolveInvoiceConfigs;
@@ -410,31 +312,31 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
410
312
  }, {
411
313
  key: "printLocalOrderReceipt",
412
314
  value: function () {
413
- var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(lookup, options) {
315
+ var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(lookup, options) {
414
316
  var _options$businessCode;
415
317
  var normalizedLookup, businessCode, channel, _yield$this$resolveIn, invoice, templateSettings, lookupPayload;
416
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
417
- while (1) switch (_context6.prev = _context6.next) {
318
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
319
+ while (1) switch (_context5.prev = _context5.next) {
418
320
  case 0:
419
321
  normalizedLookup = typeof lookup === 'string' ? lookup.trim() : lookup;
420
322
  if (!(normalizedLookup === '' || normalizedLookup === null || normalizedLookup === undefined)) {
421
- _context6.next = 3;
323
+ _context5.next = 3;
422
324
  break;
423
325
  }
424
326
  throw new Error('Sales 本地小票打印需要订单标识');
425
327
  case 3:
426
328
  businessCode = String((_options$businessCode = options === null || options === void 0 ? void 0 : options.businessCode) !== null && _options$businessCode !== void 0 ? _options$businessCode : '').trim();
427
329
  if (businessCode) {
428
- _context6.next = 6;
330
+ _context5.next = 6;
429
331
  break;
430
332
  }
431
333
  throw new Error('Sales 本地小票打印需要 businessCode');
432
334
  case 6:
433
335
  channel = this.getInvoiceSalesChannel(options === null || options === void 0 ? void 0 : options.channel);
434
- _context6.next = 9;
336
+ _context5.next = 9;
435
337
  return this.resolveInvoiceConfigs(businessCode, channel);
436
338
  case 9:
437
- _yield$this$resolveIn = _context6.sent;
339
+ _yield$this$resolveIn = _context5.sent;
438
340
  invoice = _yield$this$resolveIn.invoice;
439
341
  templateSettings = _yield$this$resolveIn.templateSettings;
440
342
  lookupPayload = typeof normalizedLookup === 'number' ? {
@@ -442,7 +344,7 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
442
344
  } : {
443
345
  external_sale_number: normalizedLookup
444
346
  };
445
- return _context6.abrupt("return", this.request.post('/shop/local/print-order', _objectSpread(_objectSpread({}, lookupPayload), {}, {
347
+ return _context5.abrupt("return", this.request.post('/shop/local/print-order', _objectSpread(_objectSpread({}, lookupPayload), {}, {
446
348
  lookup_order_from_db: 1,
447
349
  small_ticket_data_flag: 1,
448
350
  business_code: businessCode,
@@ -455,23 +357,95 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
455
357
  }));
456
358
  case 14:
457
359
  case "end":
458
- return _context6.stop();
360
+ return _context5.stop();
459
361
  }
460
- }, _callee6, this);
362
+ }, _callee5, this);
461
363
  }));
462
- function printLocalOrderReceipt(_x8, _x9) {
364
+ function printLocalOrderReceipt(_x6, _x7) {
463
365
  return _printLocalOrderReceipt.apply(this, arguments);
464
366
  }
465
367
  return printLocalOrderReceipt;
368
+ }()
369
+ }, {
370
+ key: "printCloudOrderInvoice",
371
+ value: function () {
372
+ var _printCloudOrderInvoice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(input) {
373
+ var _lookup$data;
374
+ var orderId, channel, openData, requestOptions, lookup, businessCode, settings, result;
375
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
376
+ while (1) switch (_context6.prev = _context6.next) {
377
+ case 0:
378
+ orderId = input === null || input === void 0 ? void 0 : input.order_id;
379
+ channel = typeof (input === null || input === void 0 ? void 0 : input.channel) === 'string' ? input.channel.trim() : '';
380
+ if (channel) {
381
+ _context6.next = 4;
382
+ break;
383
+ }
384
+ throw new Error('Cloud Invoice requires a channel');
385
+ case 4:
386
+ openData = this.invoiceOpenDataModule;
387
+ if (openData) {
388
+ _context6.next = 7;
389
+ break;
390
+ }
391
+ throw new Error('Cloud Invoice is not initialized');
392
+ case 7:
393
+ requestOptions = {
394
+ osServer: true,
395
+ customToast: function customToast() {}
396
+ };
397
+ _context6.next = 10;
398
+ return this.request.post('/shop/local/cloud-order-invoice/lookup', {
399
+ order_id: orderId
400
+ }, requestOptions);
401
+ case 10:
402
+ lookup = _context6.sent;
403
+ if (!((lookup === null || lookup === void 0 ? void 0 : lookup.status) !== true || lookup.code !== 200)) {
404
+ _context6.next = 13;
405
+ break;
406
+ }
407
+ throw new Error((lookup === null || lookup === void 0 ? void 0 : lookup.message) || 'Cloud Invoice order lookup failed');
408
+ case 13:
409
+ businessCode = (_lookup$data = lookup.data) === null || _lookup$data === void 0 || (_lookup$data = _lookup$data.business_code) === null || _lookup$data === void 0 ? void 0 : _lookup$data.trim();
410
+ if (businessCode) {
411
+ _context6.next = 16;
412
+ break;
413
+ }
414
+ throw new Error('Cloud Invoice order has no business_code');
415
+ case 16:
416
+ _context6.next = 18;
417
+ return openData.loadCloudInvoiceTemplate("".concat(businessCode, "+").concat(channel));
418
+ case 18:
419
+ settings = _context6.sent;
420
+ _context6.next = 21;
421
+ return this.request.post('/shop/local/cloud-order-invoice/submit', {
422
+ order_id: orderId,
423
+ business_code: businessCode,
424
+ template_settings: settings
425
+ }, requestOptions);
426
+ case 21:
427
+ result = _context6.sent;
428
+ if (!((result === null || result === void 0 ? void 0 : result.status) !== true || result.code !== 200)) {
429
+ _context6.next = 24;
430
+ break;
431
+ }
432
+ throw new Error((result === null || result === void 0 ? void 0 : result.message) || 'Cloud Invoice dispatch failed');
433
+ case 24:
434
+ case "end":
435
+ return _context6.stop();
436
+ }
437
+ }, _callee6, this);
438
+ }));
439
+ function printCloudOrderInvoice(_x8) {
440
+ return _printCloudOrderInvoice.apply(this, arguments);
441
+ }
442
+ return printCloudOrderInvoice;
466
443
  }() /** 清除独立 Documents 缓存;下一次打印会按当前 target 重新获取。 */
467
444
  }, {
468
445
  key: "clearOpenDataCache",
469
446
  value: function clearOpenDataCache() {
470
- var _this$invoiceOpenData5;
471
- this.invoiceOpenDataInFlight = null;
472
- this.invoiceOpenDataInFlightTarget = null;
473
- this.invoiceOpenDataTarget = null;
474
- (_this$invoiceOpenData5 = this.invoiceOpenDataModule) === null || _this$invoiceOpenData5 === void 0 || _this$invoiceOpenData5.clearCache();
447
+ var _this$invoiceOpenData;
448
+ (_this$invoiceOpenData = this.invoiceOpenDataModule) === null || _this$invoiceOpenData === void 0 || _this$invoiceOpenData.clearCache();
475
449
  }
476
450
 
477
451
  // -------------------------------------------------------------------------
@@ -1197,7 +1171,7 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
1197
1171
  }
1198
1172
  }, _callee8, this);
1199
1173
  }));
1200
- function getResourceBookingList(_x10) {
1174
+ function getResourceBookingList(_x9) {
1201
1175
  return _getResourceBookingList.apply(this, arguments);
1202
1176
  }
1203
1177
  return getResourceBookingList;
@@ -1320,7 +1294,7 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
1320
1294
  }
1321
1295
  }, _callee9, this);
1322
1296
  }));
1323
- function getResourceBookingItem(_x11) {
1297
+ function getResourceBookingItem(_x10) {
1324
1298
  return _getResourceBookingItem.apply(this, arguments);
1325
1299
  }
1326
1300
  return getResourceBookingItem;
@@ -56,6 +56,11 @@ export interface SalesPrintLocalOrderReceiptOptions {
56
56
  /** 当前销售入口;缺失或为 system 时按 pos 处理。 */
57
57
  channel?: string;
58
58
  }
59
+ /** Native cloud-order notification. */
60
+ export interface CloudOrderInvoiceRequest {
61
+ order_id: string | number;
62
+ channel: string;
63
+ }
59
64
  /**
60
65
  * Sales 解决方案状态
61
66
  *
@@ -90,6 +95,7 @@ export interface SalesModuleAPI {
90
95
  changeBookingStatus: (params: ChangeBookingStatusParams) => Promise<any>;
91
96
  /** 按本地订单标识打印小票;本地未命中时由 OS Server 负责远端兜底。 */
92
97
  printLocalOrderReceipt: <T = any>(lookup: string | number, options: SalesPrintLocalOrderReceiptOptions) => Promise<T>;
98
+ printCloudOrderInvoice: (request: CloudOrderInvoiceRequest) => Promise<void>;
93
99
  /** 清除 Legacy Sales 独立维护的 Documents OpenData 缓存。 */
94
100
  clearOpenDataCache: () => void;
95
101
  /** 获取资源维度的预约占用列表 */
@@ -14,6 +14,8 @@ export var SalesHooks = /*#__PURE__*/function (SalesHooks) {
14
14
  * 当前不要直接把 OrderData 当作最终 UI 数据结构。
15
15
  */
16
16
 
17
+ /** Native cloud-order notification. */
18
+
17
19
  /**
18
20
  * Sales 解决方案状态
19
21
  *
@@ -44,7 +44,7 @@ export declare class DataVariantEvaluator {
44
44
  * 返回 null 表示接口没有提供该字段;空 Map 表示已计算但没有任何命中。
45
45
  */
46
46
  private getAuthoritativeVariantPriorities;
47
- private normalizeDataVariantId;
47
+ private normalizeId;
48
48
  private buildGlobalEffectiveRuleMap;
49
49
  private resolveProduct;
50
50
  /**
@@ -90,6 +90,7 @@ export declare class DataVariantEvaluator {
90
90
  private timeToMinutes;
91
91
  private isProductInMenuScope;
92
92
  private mergeMatchedVariants;
93
+ private mergeSkuVariants;
93
94
  private getProductDataVariants;
94
95
  private normalizeStrategyConfigs;
95
96
  private isStrategyActive;
@@ -158,14 +158,14 @@ class DataVariantEvaluator {
158
158
  const orderedIds = [];
159
159
  const seen = new Set();
160
160
  for (const rawId of rawIds) {
161
- const id = this.normalizeDataVariantId(rawId);
161
+ const id = this.normalizeId(rawId);
162
162
  if (id === null || seen.has(id)) continue;
163
163
  seen.add(id);
164
164
  orderedIds.push(id);
165
165
  }
166
166
  return new Map(orderedIds.map((id, index) => [id, orderedIds.length - index]));
167
167
  }
168
- normalizeDataVariantId(value) {
168
+ normalizeId(value) {
169
169
  if (value === undefined || value === null) return null;
170
170
  const normalized = String(value).trim();
171
171
  return normalized || null;
@@ -206,7 +206,7 @@ class DataVariantEvaluator {
206
206
  for (const variant of dataVariants) {
207
207
  if (variant.business_type === 'multi_currency_settlement') continue;
208
208
  if (authoritativeVariantPriorities !== null) {
209
- const variantId = this.normalizeDataVariantId(variant.id);
209
+ const variantId = this.normalizeId(variant.id);
210
210
  const priority = variantId === null ? undefined : authoritativeVariantPriorities.get(variantId);
211
211
  if (priority === undefined) continue;
212
212
  matchedVariants.push({
@@ -250,7 +250,7 @@ class DataVariantEvaluator {
250
250
  const ruleId = String(variant.data_variant_rule_id);
251
251
  const isDefault = Number(variant.data_variant_rule_id) === 0;
252
252
  const rule = isDefault ? undefined : globalEffectiveRuleMap.get(ruleId);
253
- const variantId = this.normalizeDataVariantId(variant.id);
253
+ const variantId = this.normalizeId(variant.id);
254
254
  const authoritativePriority = variantId === null ? undefined : authoritativeVariantPriorities?.get(variantId);
255
255
  let available;
256
256
  let priority;
@@ -575,20 +575,54 @@ class DataVariantEvaluator {
575
575
  const appliedFields = new Set();
576
576
  for (const matched of sortedVariants) {
577
577
  for (const [key, value] of Object.entries(matched.data)) {
578
- if (value === undefined) continue;
578
+ if (value === undefined || key === 'variant_overrides') continue;
579
579
  result[key] = value;
580
580
  appliedFields.add(key);
581
581
  }
582
+ const mergedVariants = this.mergeSkuVariants(result.variant, matched.data.variant_overrides);
583
+ if (mergedVariants) {
584
+ result.variant = mergedVariants;
585
+ appliedFields.add('variant');
586
+ }
582
587
  appliedRuleIds.push(matched.ruleId);
583
588
  }
584
589
  result._dataVariant = {
585
590
  appliedRuleIds,
586
- appliedVariantIds: Array.from(new Set([...sortedVariants].reverse().map(matched => this.normalizeDataVariantId(matched.variant.id)).filter(id => id !== null))),
591
+ appliedVariantIds: Array.from(new Set([...sortedVariants].reverse().map(matched => this.normalizeId(matched.variant.id)).filter(id => id !== null))),
587
592
  appliedFields: Array.from(appliedFields),
588
593
  original
589
594
  };
590
595
  return result;
591
596
  }
597
+ mergeSkuVariants(variants, overrides) {
598
+ if (!Array.isArray(variants) || !Array.isArray(overrides)) return;
599
+ const overridesById = new Map();
600
+ for (const override of overrides) {
601
+ const rawId = override?.id;
602
+ if (typeof rawId !== 'number' && typeof rawId !== 'string') continue;
603
+ const id = this.normalizeId(rawId);
604
+ if (id === null) continue;
605
+ const fields = Object.entries(override).filter(([key, value]) => key !== 'id' && value !== undefined);
606
+ if (fields.length === 0) continue;
607
+ overridesById.set(id, {
608
+ ...overridesById.get(id),
609
+ ...Object.fromEntries(fields)
610
+ });
611
+ }
612
+ if (overridesById.size === 0) return;
613
+ let hasUpdates = false;
614
+ const merged = variants.map(variant => {
615
+ const id = this.normalizeId(variant?.id);
616
+ const fields = id === null ? undefined : overridesById.get(id);
617
+ if (!fields) return variant;
618
+ hasUpdates = true;
619
+ return {
620
+ ...variant,
621
+ ...fields
622
+ };
623
+ });
624
+ return hasUpdates ? merged : undefined;
625
+ }
592
626
  getProductDataVariants(product) {
593
627
  return Array.isArray(product.data_variants) ? product.data_variants : [];
594
628
  }
@@ -19,6 +19,8 @@ export declare class OpenDataModule extends BaseModule implements Module {
19
19
  private otherParams;
20
20
  private fetchRevision;
21
21
  private invoiceTemplateCacheRevision;
22
+ private printInvoiceTemplates;
23
+ private lastManualPrintKey?;
22
24
  private invoiceTemplateDocumentCache;
23
25
  private invoiceTemplateDocumentInFlight;
24
26
  constructor(name?: string, version?: string);
@@ -32,13 +34,18 @@ export declare class OpenDataModule extends BaseModule implements Module {
32
34
  updateOtherParams(params: Record<string, any>): void;
33
35
  private shouldSkipInvoiceTemplateDocument;
34
36
  fetchOpenData(params: OpenDataFetchParams): Promise<OpenDataConfig>;
37
+ private requestOpenData;
38
+ loadCloudInvoiceTemplate(target: string): Promise<InvoiceTemplateSettings>;
39
+ /** 手动和云单打印共用已成功解析的模板及进行中的请求。每个订单仍单独派单。 */
40
+ loadPrintInvoiceTemplate(target: string, mode: 'manual' | 'cloud'): Promise<InvoiceTemplateSettings>;
41
+ private fetchPrintInvoiceTemplate;
35
42
  getOpenData(): OpenDataConfig | null;
36
43
  getInvoiceLayoutConfig(): InvoiceLayoutConfig;
37
44
  getInvoiceTemplateSettings(): InvoiceTemplateSettings;
38
45
  ensureInvoiceTemplateSettings(target: string, openDataConfig?: OpenDataConfig): Promise<InvoiceTemplateSettings>;
39
46
  private commitInvoiceTemplateSettings;
40
47
  private resolveInvoiceTemplateSettings;
41
- private buildInvoiceTemplateCacheKey;
48
+ private buildInvoiceCacheKey;
42
49
  private fetchInvoiceTemplateDocument;
43
50
  private logInvoiceTemplateDocumentFallback;
44
51
  getLastFetchedAt(): number | null;