@pisell/pisellos 2.3.108 → 2.3.110

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.
@@ -1,9 +0,0 @@
1
- // 导出评估器
2
- export { PromotionEvaluator } from "./evaluator";
3
-
4
- // 导出适配器
5
- export { PromotionAdapter } from "./adapter";
6
- export { default } from "./adapter";
7
-
8
- // 导出策略配置示例常量
9
- export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY, ITEM_REWARD_STRATEGY } from "./examples";
@@ -33,7 +33,7 @@ export declare class OpenDataModule extends BaseModule implements Module {
33
33
  getOpenData(): OpenDataConfig | null;
34
34
  getInvoiceLayoutConfig(): InvoiceLayoutConfig;
35
35
  getInvoiceTemplateSettings(): InvoiceTemplateSettings;
36
- ensureInvoiceTemplateSettings(target: string): Promise<InvoiceTemplateSettings>;
36
+ ensureInvoiceTemplateSettings(target: string, openDataConfig?: OpenDataConfig): Promise<InvoiceTemplateSettings>;
37
37
  private commitInvoiceTemplateSettings;
38
38
  private resolveInvoiceTemplateSettings;
39
39
  private buildInvoiceTemplateCacheKey;
@@ -233,39 +233,47 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
233
233
  }, {
234
234
  key: "ensureInvoiceTemplateSettings",
235
235
  value: function () {
236
- var _ensureInvoiceTemplateSettings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(target) {
236
+ var _ensureInvoiceTemplateSettings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(target, openDataConfig) {
237
237
  var normalizedTarget, config, fetchRevision, resolved;
238
238
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
239
239
  while (1) switch (_context3.prev = _context3.next) {
240
240
  case 0:
241
241
  normalizedTarget = String(target || '').trim();
242
+ if (openDataConfig && openDataConfig !== this.store.data) {
243
+ // 部分解决方案会在初始化参数中直接收到已经拉取完成的 OpenData。
244
+ // 将它纳入模块状态后再解析 Document,避免为了 Invoice 重复请求 setting,
245
+ // 同时让后续同步 getter 能校验同一份 document id 与 target。
246
+ this.fetchRevision += 1;
247
+ this.store.data = openDataConfig;
248
+ this.store.lastFetchedAt = Date.now();
249
+ }
242
250
  config = this.store.data;
243
251
  if (!(!normalizedTarget || !config)) {
244
- _context3.next = 4;
252
+ _context3.next = 5;
245
253
  break;
246
254
  }
247
255
  return _context3.abrupt("return", getDefaultInvoiceTemplateSettings());
248
- case 4:
256
+ case 5:
249
257
  fetchRevision = this.fetchRevision;
250
- _context3.next = 7;
258
+ _context3.next = 8;
251
259
  return this.resolveInvoiceTemplateSettings(config, normalizedTarget);
252
- case 7:
260
+ case 8:
253
261
  resolved = _context3.sent;
254
262
  if (!(fetchRevision !== this.fetchRevision || this.store.data !== config)) {
255
- _context3.next = 10;
263
+ _context3.next = 11;
256
264
  break;
257
265
  }
258
266
  return _context3.abrupt("return", getDefaultInvoiceTemplateSettings());
259
- case 10:
267
+ case 11:
260
268
  this.commitInvoiceTemplateSettings(normalizedTarget, resolved);
261
269
  return _context3.abrupt("return", normalizeRawInvoiceTemplateSettings(resolved.settings));
262
- case 12:
270
+ case 13:
263
271
  case "end":
264
272
  return _context3.stop();
265
273
  }
266
274
  }, _callee3, this);
267
275
  }));
268
- function ensureInvoiceTemplateSettings(_x4) {
276
+ function ensureInvoiceTemplateSettings(_x4, _x5) {
269
277
  return _ensureInvoiceTemplateSettings.apply(this, arguments);
270
278
  }
271
279
  return ensureInvoiceTemplateSettings;
@@ -367,7 +375,7 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
367
375
  }
368
376
  }, _callee4, this);
369
377
  }));
370
- function resolveInvoiceTemplateSettings(_x5, _x6) {
378
+ function resolveInvoiceTemplateSettings(_x6, _x7) {
371
379
  return _resolveInvoiceTemplateSettings.apply(this, arguments);
372
380
  }
373
381
  return resolveInvoiceTemplateSettings;
@@ -424,7 +432,7 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
424
432
  }
425
433
  }, _callee5, this);
426
434
  }));
427
- function fetchInvoiceTemplateDocument(_x7) {
435
+ function fetchInvoiceTemplateDocument(_x8) {
428
436
  return _fetchInvoiceTemplateDocument.apply(this, arguments);
429
437
  }
430
438
  return fetchInvoiceTemplateDocument;
@@ -588,6 +588,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
588
588
  */
589
589
  createOrderByCheckout(params: CheckoutOrderParams): Promise<any>;
590
590
  submitSalesOrder<T = any>(params: SubmitSalesOrderParams): Promise<T>;
591
+ private isSalesCheckoutHandledByOsServer;
591
592
  /**
592
593
  * 发送支付链接邮件。
593
594
  *
@@ -35,6 +35,7 @@ import { OrderHooks } from "./types";
35
35
  import { composeLinePrice, generateDuration, getAllDiscountList, mergeRelationForms, ensureCartItemOriginHolder, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeOrderMetaList, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments, normalizeOrderProductDiscountList, resolveEffectivePerUnitDiscount, ensureProductSku, getProductSkuOptions, normalizeProductSkuOptions, sumOptionUnitPrice, clearTempOrderHolderAssignments, getOrderProductLineUid, indexOrderProductsByUid, calculateOrderProductsDeposit, buildPointCardSnapshotFromWalletPassList, mergeOrderProductDisplayFields, resolveIsFormSubject, isMarkdownBundle } from "./utils";
36
36
  import { isNormalProduct } from "../Product/utils";
37
37
  import dayjs from 'dayjs';
38
+ import { stripOsPrivatePayloadFields } from "../../utils/os-private-payload";
38
39
  import { buildSalesNoteText, decodeSalesNotesSnapshot, getSalesNotePolicy } from "./salesNotes";
39
40
  import { ensureOrderPaymentNumber, mergeOrderPaymentRecord, resolveOrderPaymentIdentity } from "./payment-utils";
40
41
  import { resolvePaymentNumberDevicePrefix, resolvePaymentNumberDevicePrefixFromDeviceId } from "../../utils/payment-number";
@@ -107,13 +108,6 @@ function getVoucherPaymentLifecycleKey(payment) {
107
108
  if (!isVoucherPaymentRecord(payment)) return null;
108
109
  return "".concat(String(payment.voucher_id), "::").concat(String(payment.status || ''));
109
110
  }
110
- function hasPersistedOrderId(orderId) {
111
- if (orderId === undefined || orderId === null || orderId === '') return false;
112
- if (typeof orderId === 'string' && orderId.startsWith('LOCAL_')) return false;
113
- var normalizedOrderId = Number(orderId);
114
- if (Number.isFinite(normalizedOrderId)) return normalizedOrderId > 0;
115
- return String(orderId).trim() !== '';
116
- }
117
111
  export var OrderModule = /*#__PURE__*/function (_BaseModule) {
118
112
  _inherits(OrderModule, _BaseModule);
119
113
  var _super = _createSuper(OrderModule);
@@ -595,7 +589,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
595
589
  this.store.virtualCurrencyList = (prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.virtualCurrencyList) || [];
596
590
  if (prepareConfigResult) {
597
591
  this.writePointCardSnapshotFromPrepareConfig({
598
- orderId: orderId,
599
592
  customerId: params.customerId,
600
593
  availableWalletPassList: prepareConfigResult.availableWalletPassList || []
601
594
  });
@@ -1533,12 +1526,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1533
1526
  }, {
1534
1527
  key: "writePointCardSnapshotFromPrepareConfig",
1535
1528
  value: function writePointCardSnapshotFromPrepareConfig(params) {
1536
- var _tempOrder$customer_i, _params$orderId;
1529
+ var _tempOrder$customer_i;
1537
1530
  var tempOrder = this.store.tempOrder;
1538
1531
  if (!tempOrder) return;
1539
1532
  if (String((_tempOrder$customer_i = tempOrder.customer_id) !== null && _tempOrder$customer_i !== void 0 ? _tempOrder$customer_i : '') !== String(params.customerId)) return;
1540
- var effectiveOrderId = (_params$orderId = params.orderId) !== null && _params$orderId !== void 0 ? _params$orderId : tempOrder.order_id;
1541
- if (hasPersistedOrderId(effectiveOrderId)) return;
1542
1533
  tempOrder.order_meta_list = _objectSpread(_objectSpread({}, normalizeOrderMetaList(tempOrder.order_meta_list) || {}), {}, {
1543
1534
  point_cards_snapshot: buildPointCardSnapshotFromWalletPassList(params.availableWalletPassList)
1544
1535
  });
@@ -3871,7 +3862,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3871
3862
  email: tempOrder.email
3872
3863
  });
3873
3864
  var nextCustomerId = (_tempOrder$customer_i4 = tempOrder.customer_id) !== null && _tempOrder$customer_i4 !== void 0 ? _tempOrder$customer_i4 : null;
3874
- if (String(previousCustomerId !== null && previousCustomerId !== void 0 ? previousCustomerId : '') !== String(nextCustomerId !== null && nextCustomerId !== void 0 ? nextCustomerId : '') && !hasPersistedOrderId(tempOrder.order_id)) {
3865
+ if (String(previousCustomerId !== null && previousCustomerId !== void 0 ? previousCustomerId : '') !== String(nextCustomerId !== null && nextCustomerId !== void 0 ? nextCustomerId : '')) {
3875
3866
  this.store.availableWalletIds = [];
3876
3867
  this.clearTempOrderPointCardSnapshot(tempOrder);
3877
3868
  }
@@ -3914,9 +3905,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3914
3905
  if (String(previousCustomerId !== null && previousCustomerId !== void 0 ? previousCustomerId : '') !== String(nextCustomerId !== null && nextCustomerId !== void 0 ? nextCustomerId : '')) {
3915
3906
  this.store.availableWalletIds = [];
3916
3907
  this.store.virtualCurrencyList = [];
3917
- if (!hasPersistedOrderId(tempOrder.order_id)) {
3918
- this.clearTempOrderPointCardSnapshot(tempOrder);
3919
- }
3908
+ this.clearTempOrderPointCardSnapshot(tempOrder);
3920
3909
  clearTempOrderHolderAssignments(tempOrder);
3921
3910
  this.clearCustomerBoundDiscounts(tempOrder);
3922
3911
  this.applyDiscount();
@@ -3963,9 +3952,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3963
3952
  if (tempOrder._extend) delete tempOrder._extend.customerSnapshot;
3964
3953
  this.store.availableWalletIds = [];
3965
3954
  this.store.virtualCurrencyList = [];
3966
- if (!hasPersistedOrderId(tempOrder.order_id)) {
3967
- this.clearTempOrderPointCardSnapshot(tempOrder);
3968
- }
3955
+ this.clearTempOrderPointCardSnapshot(tempOrder);
3969
3956
  this.clearCustomerBoundDiscounts(tempOrder);
3970
3957
  this.applyDiscount();
3971
3958
  this.persistTempOrder();
@@ -6754,17 +6741,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6754
6741
  key: "submitSalesOrder",
6755
6742
  value: function () {
6756
6743
  var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(params) {
6757
- var url, query, fetchUrl;
6744
+ var url, query, fetchUrl, requestQuery;
6758
6745
  return _regeneratorRuntime().wrap(function _callee44$(_context47) {
6759
6746
  while (1) switch (_context47.prev = _context47.next) {
6760
6747
  case 0:
6761
6748
  url = params.url, query = params.query;
6762
6749
  fetchUrl = url || '/order/sales/checkout';
6763
- return _context47.abrupt("return", this.request.post(fetchUrl, query, {
6750
+ requestQuery = this.isSalesCheckoutHandledByOsServer(fetchUrl) ? query : stripOsPrivatePayloadFields(query);
6751
+ return _context47.abrupt("return", this.request.post(fetchUrl, requestQuery, {
6764
6752
  osServer: true,
6765
6753
  customToast: function customToast() {}
6766
6754
  }));
6767
- case 3:
6755
+ case 4:
6768
6756
  case "end":
6769
6757
  return _context47.stop();
6770
6758
  }
@@ -6775,6 +6763,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6775
6763
  }
6776
6764
  return submitSalesOrder;
6777
6765
  }()
6766
+ }, {
6767
+ key: "isSalesCheckoutHandledByOsServer",
6768
+ value: function isSalesCheckoutHandledByOsServer(fetchUrl) {
6769
+ var _this$core2, _this$request;
6770
+ var server = (_this$core2 = this.core) === null || _this$core2 === void 0 ? void 0 : _this$core2.server;
6771
+ if (!server || typeof server.hasRoute !== 'function') return false;
6772
+ var requestBaseUrl = String(((_this$request = this.request) === null || _this$request === void 0 ? void 0 : _this$request.baseUrl) || '/shop').replace(/\/+$/, '');
6773
+ if (!requestBaseUrl.startsWith('/')) return false;
6774
+ var normalizedFetchUrl = fetchUrl.startsWith('/') ? fetchUrl : "/".concat(fetchUrl);
6775
+ var routePath = normalizedFetchUrl === requestBaseUrl || normalizedFetchUrl.startsWith("".concat(requestBaseUrl, "/")) ? normalizedFetchUrl : "".concat(requestBaseUrl).concat(normalizedFetchUrl);
6776
+ return server.hasRoute('post', routePath) === true;
6777
+ }
6778
+
6778
6779
  /**
6779
6780
  * 发送支付链接邮件。
6780
6781
  *
@@ -45,6 +45,7 @@ import { BaseSalesImpl } from "../solution/BaseSales";
45
45
  import { getOrderPaymentIdentityKeys, isIdentifiedPendingOrderPayment, isPendingOrderPayment, mergeOrderPaymentListsByIdentity } from "../modules/Order/payment-utils";
46
46
  import { finalizeSalesNotesForCheckout } from "../modules/Order/salesNotes";
47
47
  import { normalizeOrderCollections } from "../modules/Order/utils/orderCollectionIdentity";
48
+ import { stripOsPrivatePayloadFields } from "../utils/os-private-payload";
48
49
  import { getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings, resolveInvoiceReceiptLocales } from "../modules/OpenData";
49
50
  var OS_FULFILLMENT_REF_MODE_FIELD = '_os_fulfillment_ref_mode';
50
51
  var OS_INVOICE_LAYOUT_CONFIG_FIELD = '_os_invoice_layout_config';
@@ -2574,7 +2575,7 @@ var Server = /*#__PURE__*/function () {
2574
2575
  return this.ensureCheckoutOrderNumbers(normalizedData, title);
2575
2576
  case 6:
2576
2577
  numberedData = _context32.sent;
2577
- checkoutData = this.normalizeCheckoutCollections(this.applyCheckoutFulfillmentBuzzer(numberedData, title));
2578
+ checkoutData = this.normalizeCheckoutCollections(stripOsPrivatePayloadFields(this.applyCheckoutFulfillmentBuzzer(numberedData, title)));
2578
2579
  remoteCheckoutData = this.buildRemoteCheckoutData(checkoutData, title);
2579
2580
  _context32.next = 11;
2580
2581
  return this.buildCheckoutDeviceHeaders(title);
@@ -2676,11 +2677,9 @@ var Server = /*#__PURE__*/function () {
2676
2677
  }, {
2677
2678
  key: "buildRemoteCheckoutData",
2678
2679
  value: function buildRemoteCheckoutData(data, title) {
2679
- var next = cloneDeep(this.omitCheckoutSyncMode(data));
2680
+ var next = stripOsPrivatePayloadFields(this.omitCheckoutSyncMode(data));
2680
2681
  if (!next || _typeof(next) !== 'object') return next;
2681
2682
  var record = next;
2682
- delete record[OS_FULFILLMENT_REF_MODE_FIELD];
2683
- delete record[OS_INVOICE_LAYOUT_CONFIG_FIELD];
2684
2683
  this.applyKioskCheckoutOperator(record);
2685
2684
  if (!Array.isArray(record.payments)) return next;
2686
2685
  var originalPayments = record.payments;
@@ -6414,7 +6413,7 @@ var Server = /*#__PURE__*/function () {
6414
6413
  return this.ensureCheckoutOrderNumbers(normalizedData, title);
6415
6414
  case 14:
6416
6415
  numberedData = _context62.sent;
6417
- checkoutData = this.normalizeCheckoutCollections(this.applyCheckoutFulfillmentBuzzer(numberedData, title));
6416
+ checkoutData = this.normalizeCheckoutCollections(stripOsPrivatePayloadFields(this.applyCheckoutFulfillmentBuzzer(numberedData, title)));
6418
6417
  _context62.next = 18;
6419
6418
  return this.handlePendingSyncCheckoutOrder({
6420
6419
  backendPath: backendPath,
@@ -28,14 +28,19 @@ export interface SmallTicketItem {
28
28
  value: string;
29
29
  size?: number;
30
30
  align?: string;
31
+ product_uid?: string | number;
32
+ booking_uid?: string | number;
31
33
  }
32
34
  export interface SmallTicketProduct {
33
35
  product_title: string;
34
36
  product_quantity: number;
35
37
  selling_price: string;
38
+ total_selling_price: string;
36
39
  original_price: string;
37
40
  base_price?: string;
38
41
  total_original_price: string;
42
+ options_total_price?: string;
43
+ package_items_total_price?: string;
39
44
  extension_list: any[];
40
45
  product_uid?: string | number;
41
46
  booking_uid?: string | number;
@@ -44,16 +49,13 @@ export interface SmallTicketProduct {
44
49
  name: string;
45
50
  num?: number;
46
51
  price?: string;
52
+ total_price: string;
47
53
  value?: string;
48
54
  }>;
49
55
  variant?: string;
50
56
  combinations?: any[];
51
57
  }
52
- export interface SmallTicketBookingSnapshot extends Record<string, any> {
53
- product_uid?: string | number;
54
- booking_uid?: string | number;
55
- }
56
- export type SmallTicketAppointment = SmallTicketItem[] | SmallTicketBookingSnapshot[];
58
+ export type SmallTicketAppointment = SmallTicketItem[];
57
59
  export interface SmallTicketLocaleData {
58
60
  base_data: Record<string, any>;
59
61
  products: SmallTicketProduct[];