@pisell/pisellos 2.3.29 → 2.3.30

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 (98) hide show
  1. package/dist/model/strategy/adapter/index.d.ts +0 -4
  2. package/dist/model/strategy/adapter/index.js +1 -5
  3. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  4. package/dist/modules/Discount/index.d.ts +2 -5
  5. package/dist/modules/Discount/index.js +7 -30
  6. package/dist/modules/Discount/types.d.ts +0 -4
  7. package/dist/modules/Order/index.d.ts +28 -10
  8. package/dist/modules/Order/index.js +747 -498
  9. package/dist/modules/Order/payment-utils.d.ts +23 -0
  10. package/dist/modules/Order/payment-utils.js +203 -0
  11. package/dist/modules/Order/types.d.ts +33 -3
  12. package/dist/modules/Order/utils.js +4 -4
  13. package/dist/modules/Payment/index.d.ts +2 -0
  14. package/dist/modules/Payment/index.js +78 -49
  15. package/dist/modules/Payment/types.d.ts +26 -24
  16. package/dist/modules/Payment/types.js +2 -0
  17. package/dist/modules/Product/index.d.ts +1 -1
  18. package/dist/modules/Product/types.d.ts +0 -22
  19. package/dist/modules/ProductList/index.d.ts +1 -1
  20. package/dist/modules/ProductList/index.js +2 -4
  21. package/dist/modules/ProductList/types.d.ts +0 -2
  22. package/dist/server/index.d.ts +14 -50
  23. package/dist/server/index.js +1975 -1395
  24. package/dist/server/modules/order/index.d.ts +40 -3
  25. package/dist/server/modules/order/index.js +1200 -501
  26. package/dist/server/modules/order/types.d.ts +11 -3
  27. package/dist/server/modules/order/types.js +1 -1
  28. package/dist/server/modules/products/index.d.ts +7 -26
  29. package/dist/server/modules/products/index.js +76 -167
  30. package/dist/server/modules/products/types.d.ts +0 -14
  31. package/dist/solution/BaseSales/index.d.ts +33 -5
  32. package/dist/solution/BaseSales/index.js +622 -345
  33. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
  34. package/dist/solution/BookingByStep/index.d.ts +1 -1
  35. package/dist/solution/BookingTicket/index.d.ts +1 -1
  36. package/dist/solution/BookingTicket/index.js +2 -1
  37. package/dist/solution/BookingTicket/types.d.ts +0 -2
  38. package/dist/solution/ShopDiscount/index.js +14 -15
  39. package/dist/utils/payment-number.d.ts +9 -0
  40. package/dist/utils/payment-number.js +69 -0
  41. package/lib/model/strategy/adapter/index.d.ts +0 -4
  42. package/lib/model/strategy/adapter/index.js +2 -13
  43. package/lib/modules/Discount/index.d.ts +2 -5
  44. package/lib/modules/Discount/index.js +3 -23
  45. package/lib/modules/Discount/types.d.ts +0 -4
  46. package/lib/modules/Order/index.d.ts +28 -10
  47. package/lib/modules/Order/index.js +181 -73
  48. package/lib/modules/Order/payment-utils.d.ts +23 -0
  49. package/lib/modules/Order/payment-utils.js +193 -0
  50. package/lib/modules/Order/types.d.ts +33 -3
  51. package/lib/modules/Order/utils.js +2 -3
  52. package/lib/modules/Payment/index.d.ts +2 -0
  53. package/lib/modules/Payment/index.js +33 -12
  54. package/lib/modules/Payment/types.d.ts +26 -24
  55. package/lib/modules/Product/index.d.ts +1 -1
  56. package/lib/modules/Product/types.d.ts +0 -22
  57. package/lib/modules/ProductList/index.d.ts +1 -1
  58. package/lib/modules/ProductList/index.js +2 -4
  59. package/lib/modules/ProductList/types.d.ts +0 -2
  60. package/lib/server/index.d.ts +14 -50
  61. package/lib/server/index.js +633 -214
  62. package/lib/server/modules/order/index.d.ts +40 -3
  63. package/lib/server/modules/order/index.js +434 -31
  64. package/lib/server/modules/order/types.d.ts +11 -3
  65. package/lib/server/modules/products/index.d.ts +7 -26
  66. package/lib/server/modules/products/index.js +35 -114
  67. package/lib/server/modules/products/types.d.ts +0 -14
  68. package/lib/solution/BaseSales/index.d.ts +33 -5
  69. package/lib/solution/BaseSales/index.js +170 -19
  70. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
  71. package/lib/solution/BookingByStep/index.d.ts +1 -1
  72. package/lib/solution/BookingTicket/index.d.ts +1 -1
  73. package/lib/solution/BookingTicket/index.js +2 -1
  74. package/lib/solution/BookingTicket/types.d.ts +0 -2
  75. package/lib/solution/ShopDiscount/index.js +1 -2
  76. package/lib/utils/payment-number.d.ts +9 -0
  77. package/lib/utils/payment-number.js +64 -0
  78. package/package.json +1 -1
  79. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
  80. package/dist/model/strategy/adapter/dataVariant/adapter.js +0 -167
  81. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
  82. package/dist/model/strategy/adapter/dataVariant/evaluator.js +0 -780
  83. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
  84. package/dist/model/strategy/adapter/dataVariant/examples.js +0 -277
  85. package/dist/model/strategy/adapter/dataVariant/index.d.ts +0 -4
  86. package/dist/model/strategy/adapter/dataVariant/index.js +0 -4
  87. package/dist/model/strategy/adapter/dataVariant/type.d.ts +0 -148
  88. package/dist/model/strategy/adapter/dataVariant/type.js +0 -54
  89. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
  90. package/lib/model/strategy/adapter/dataVariant/adapter.js +0 -149
  91. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
  92. package/lib/model/strategy/adapter/dataVariant/evaluator.js +0 -583
  93. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
  94. package/lib/model/strategy/adapter/dataVariant/examples.js +0 -293
  95. package/lib/model/strategy/adapter/dataVariant/index.d.ts +0 -4
  96. package/lib/model/strategy/adapter/dataVariant/index.js +0 -38
  97. package/lib/model/strategy/adapter/dataVariant/type.d.ts +0 -148
  98. package/lib/model/strategy/adapter/dataVariant/type.js +0 -31
@@ -40,6 +40,8 @@ var import_decimal = __toESM(require("decimal.js"));
40
40
  var import_lodash_es = require("lodash-es");
41
41
  var import_types2 = require("../BookingByStep/types");
42
42
  var import_utils = require("../../modules/Order/utils");
43
+ var import_payment_utils = require("../../modules/Order/payment-utils");
44
+ var import_payment_number = require("../../utils/payment-number");
43
45
  var import_orderCollectionIdentity = require("../../modules/Order/utils/orderCollectionIdentity");
44
46
  var import_dayjs = __toESM(require("dayjs"));
45
47
  __reExport(BaseSales_exports, require("./types"), module.exports);
@@ -77,6 +79,11 @@ function isBaseSalesHistoricalDiscountEntry(discount) {
77
79
  (discount == null ? void 0 : discount.isEditMode) || (discount == null ? void 0 : discount.isDisabled) || (discount == null ? void 0 : discount.order_discount_id) != null
78
80
  );
79
81
  }
82
+ function getBaseSalesUniqueArrayMetadataKey(key) {
83
+ if (key === "products" || key === "bookings")
84
+ return "unique_identification_number";
85
+ return null;
86
+ }
80
87
  var BASE_SALES_PERSISTENT_ID_FIELD_BY_KIND = {
81
88
  product: "order_detail_id",
82
89
  booking: "schedule_event_id",
@@ -209,6 +216,35 @@ function normalizeBaseSalesRecordCollections(sourceRecord, options) {
209
216
  }
210
217
  return normalizedRecord;
211
218
  }
219
+ function getBaseSalesMetadataUid(item, metadataKey) {
220
+ var _a;
221
+ const uid = ((_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a[metadataKey]) ?? (item == null ? void 0 : item[metadataKey]);
222
+ if (uid === void 0 || uid === null || uid === "")
223
+ return null;
224
+ return String(uid);
225
+ }
226
+ function mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey) {
227
+ const result = [];
228
+ const indexByUid = /* @__PURE__ */ new Map();
229
+ const appendOrReplaceByUid = (item) => {
230
+ const clonedItem = (0, import_lodash_es.cloneDeep)(item);
231
+ const uid = getBaseSalesMetadataUid(clonedItem, metadataKey);
232
+ if (!uid) {
233
+ result.push(clonedItem);
234
+ return;
235
+ }
236
+ const existingIndex = indexByUid.get(uid);
237
+ if (existingIndex !== void 0) {
238
+ result[existingIndex] = clonedItem;
239
+ return;
240
+ }
241
+ indexByUid.set(uid, result.length);
242
+ result.push(clonedItem);
243
+ };
244
+ currentValue.forEach(appendOrReplaceByUid);
245
+ loadedValue.forEach(appendOrReplaceByUid);
246
+ return result;
247
+ }
212
248
  function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, strategy) {
213
249
  const normalizedLoadedRecord = normalizeBaseSalesRecordCollections(
214
250
  loadedRecord || {},
@@ -237,6 +273,15 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, str
237
273
  );
238
274
  }
239
275
  if (Array.isArray(currentValue) && Array.isArray(loadedValue)) {
276
+ if (key === "payments" || key === "payment") {
277
+ return (0, import_payment_utils.mergeOrderPaymentListsByIdentity)(currentValue, loadedValue, {
278
+ preserveUnmatchedExisting: true
279
+ });
280
+ }
281
+ const metadataKey = getBaseSalesUniqueArrayMetadataKey(key);
282
+ if (metadataKey) {
283
+ return mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey);
284
+ }
240
285
  return [
241
286
  ...(0, import_lodash_es.cloneDeep)(currentValue),
242
287
  ...(0, import_lodash_es.cloneDeep)(loadedValue)
@@ -796,6 +841,16 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
796
841
  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");
797
842
  return coreData == null ? void 0 : coreData[key];
798
843
  }
844
+ getPaymentNumberDevicePrefixSync() {
845
+ if (!this.appPlugin)
846
+ return "LOCAL";
847
+ return (0, import_payment_number.resolvePaymentNumberDevicePrefixFromDeviceId)((key) => this.getAppData(key));
848
+ }
849
+ getPaymentNumberDevicePrefixAsync() {
850
+ if (!this.appPlugin)
851
+ return Promise.resolve("LOCAL");
852
+ return (0, import_payment_number.resolvePaymentNumberDevicePrefix)((key) => this.getAppData(key));
853
+ }
799
854
  syncAppDataToTempOrder(tempOrder) {
800
855
  const isPriceIncludeTax = this.getAppData("is_price_include_tax");
801
856
  const taxCountryCode = this.getAppData("tax_country_code");
@@ -1323,8 +1378,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
1323
1378
  if (hasManualDiscountSelection && currentDiscountList.length) {
1324
1379
  return {
1325
1380
  productList: tempOrder.products || [],
1326
- discountList: currentDiscountList,
1327
- availableWalletIds: this.getAvailableWalletIds()
1381
+ discountList: currentDiscountList
1328
1382
  };
1329
1383
  }
1330
1384
  let nextDiscountList = this.mergeHistoricalDiscountList(
@@ -1353,8 +1407,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
1353
1407
  });
1354
1408
  return {
1355
1409
  productList: tempOrder.products || [],
1356
- discountList: nextDiscountList,
1357
- availableWalletIds: this.getAvailableWalletIds()
1410
+ discountList: nextDiscountList
1358
1411
  };
1359
1412
  }
1360
1413
  if (rulesModule) {
@@ -1415,16 +1468,9 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
1415
1468
  });
1416
1469
  return {
1417
1470
  productList: tempOrder.products || [],
1418
- discountList: nextDiscountList,
1419
- availableWalletIds: this.getAvailableWalletIds()
1471
+ discountList: nextDiscountList
1420
1472
  };
1421
1473
  }
1422
- getAvailableWalletIds() {
1423
- var _a;
1424
- if (!((_a = this.store.order) == null ? void 0 : _a.getAvailableWalletIds))
1425
- return [];
1426
- return this.store.order.getAvailableWalletIds();
1427
- }
1428
1474
  async bestDiscount(cb) {
1429
1475
  var _a, _b, _c;
1430
1476
  if (!this.store.order)
@@ -1727,6 +1773,20 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
1727
1773
  };
1728
1774
  return this.store.order.submitTempOrder(submitParams);
1729
1775
  }
1776
+ async saveSalesOrderDraft(params) {
1777
+ var _a, _b, _c, _d;
1778
+ if (!this.store.order) {
1779
+ throw new Error("BaseSales 解决方案需要 order 模块支持");
1780
+ }
1781
+ return this.store.order.saveTempOrderAsDraft({
1782
+ cacheId: this.cacheId,
1783
+ platform: (params == null ? void 0 : params.platform) ?? ((_a = this.otherParams) == null ? void 0 : _a.platform),
1784
+ businessCode: (params == null ? void 0 : params.businessCode) ?? ((_b = this.otherParams) == null ? void 0 : _b.businessCode) ?? ((_c = this.otherParams) == null ? void 0 : _c.business_code),
1785
+ channel: (params == null ? void 0 : params.channel) ?? this.getSubmitOrderSalesChannel(),
1786
+ type: (params == null ? void 0 : params.type) ?? ((_d = this.otherParams) == null ? void 0 : _d.type),
1787
+ ...(params == null ? void 0 : params.enhancePayload) !== void 0 ? { enhancePayload: params.enhancePayload } : {}
1788
+ });
1789
+ }
1730
1790
  async submitTempOrderAsync(params) {
1731
1791
  var _a, _b, _c, _d;
1732
1792
  if (!this.store.order) {
@@ -1927,8 +1987,26 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
1927
1987
  }
1928
1988
  }
1929
1989
  }
1930
- /** 追加单个支付项到当前订单。 */
1990
+ /**
1991
+ * 同步兼容入口。无法等待 IoT 短号时,按调用当下的 device_id 或 LOCAL 生成。
1992
+ */
1931
1993
  addOrderPayment(payment) {
1994
+ const hasPaymentNumber = String(
1995
+ payment.payment_number || ""
1996
+ ).trim() !== "";
1997
+ return this.addOrderPaymentWithDevicePrefix(
1998
+ payment,
1999
+ hasPaymentNumber ? "LOCAL" : this.getPaymentNumberDevicePrefixSync()
2000
+ );
2001
+ }
2002
+ /** 创建新支付项时读取最新设备短号,不缓存运行时设备信息。 */
2003
+ async addOrderPaymentAsync(payment) {
2004
+ const paymentRecord = payment;
2005
+ const hasPaymentNumber = String(paymentRecord.payment_number || "").trim() !== "";
2006
+ const devicePrefix = hasPaymentNumber ? "LOCAL" : await this.getPaymentNumberDevicePrefixAsync();
2007
+ return this.addOrderPaymentWithDevicePrefix(payment, devicePrefix);
2008
+ }
2009
+ addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
1932
2010
  var _a;
1933
2011
  if (!this.store.order)
1934
2012
  throw new Error("order 模块未初始化");
@@ -1945,21 +2023,26 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
1945
2023
  if (shopWalletPassId !== void 0 && shopWalletPassId !== null) {
1946
2024
  metadata.shop_wallet_pass_id = shopWalletPassId;
1947
2025
  }
1948
- if (!metadata.unique_payment_number) {
1949
- metadata.unique_payment_number = (0, import_utils.createUuidV4)();
1950
- }
2026
+ const normalizedPaymentRecord = (0, import_payment_utils.ensureOrderPaymentNumber)(
2027
+ paymentRecord,
2028
+ devicePrefix,
2029
+ import_utils.createUuidV4
2030
+ );
1951
2031
  const paymentTimestamp = (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
1952
2032
  const paymentTime = paymentRecord.payment_time ?? paymentTimestamp;
1953
2033
  const createdAt = paymentRecord.created_at ?? paymentTimestamp;
1954
2034
  const serviceCharge = paymentRecord.service_charge && typeof paymentRecord.service_charge === "object" ? paymentRecord.service_charge : null;
1955
2035
  const calculatedServiceFee = serviceCharge ? new import_decimal.default(paymentRecord.origin_amount ?? paymentRecord.amount ?? 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : void 0;
1956
2036
  const payments = this.store.order.addOrderPayment({
1957
- ...paymentRecord,
2037
+ ...normalizedPaymentRecord,
1958
2038
  ...calculatedServiceFee !== void 0 ? { service_fee: calculatedServiceFee } : {},
1959
2039
  metadata,
1960
2040
  payment_time: paymentTime,
1961
2041
  created_at: createdAt
1962
2042
  });
2043
+ if (paymentRecord.status === "payment_pending") {
2044
+ return payments;
2045
+ }
1963
2046
  const amountSnapshot = this.store.order.getOrderAmountSnapshot();
1964
2047
  const syncState = this.store.order.getOrderSyncState();
1965
2048
  if (amountSnapshot) {
@@ -1981,10 +2064,73 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
1981
2064
  return payments;
1982
2065
  }
1983
2066
  /** 更新当前订单中的指定支付项。 */
1984
- updateOrderPayment(paymentIdentity, updates) {
2067
+ async updateOrderPayment(paymentIdentity, updates, options = {}) {
2068
+ var _a, _b, _c;
1985
2069
  if (!this.store.order)
1986
2070
  throw new Error("order 模块未初始化");
1987
- return this.store.order.updateOrderPayment(paymentIdentity, updates);
2071
+ const matchMode = options.matchBy === "compat" || options.matchBy === "legacy" ? "compat" : "payment_number";
2072
+ const previousMatch = (0, import_payment_utils.resolveOrderPaymentIdentity)(
2073
+ this.store.order.getOrderPayments(),
2074
+ paymentIdentity,
2075
+ matchMode
2076
+ );
2077
+ const previousPayment = previousMatch == null ? void 0 : previousMatch.payment;
2078
+ if ((previousPayment == null ? void 0 : previousPayment.status) === "paid" && !options.applyUpdatesWhenPaid) {
2079
+ const currentPayments = this.store.order.getOrderPayments();
2080
+ let syncResult2;
2081
+ if (options.submitWhenPaid && options.forceSubmitIfPaid) {
2082
+ syncResult2 = await this.syncPaymentsToOrder({
2083
+ payments: currentPayments,
2084
+ paymentStatus: this.getPaymentStatusForSync(currentPayments),
2085
+ submitWhenPaid: true,
2086
+ smallTicketDataFlag: options.smallTicketDataFlag ?? 1
2087
+ });
2088
+ }
2089
+ return {
2090
+ updated: false,
2091
+ payment: previousPayment,
2092
+ payments: currentPayments,
2093
+ summary: ((_a = this.store.order.getOrderAmountSnapshot()) == null ? void 0 : _a.summary) || null,
2094
+ ...syncResult2 !== void 0 ? { syncResult: syncResult2 } : {}
2095
+ };
2096
+ }
2097
+ const result = await this.store.order.updateOrderPayment(paymentIdentity, updates, {
2098
+ matchBy: matchMode
2099
+ });
2100
+ let draftResult;
2101
+ let draftError;
2102
+ if (options.persistDraft !== false) {
2103
+ try {
2104
+ draftResult = await this.saveSalesOrderDraft();
2105
+ } catch (error) {
2106
+ draftError = error;
2107
+ this.logError("updateOrderPayment: 保存支付草稿失败", {
2108
+ paymentIdentity,
2109
+ error: error instanceof Error ? error.message : String(error)
2110
+ });
2111
+ if (!options.submitWhenPaid)
2112
+ throw error;
2113
+ }
2114
+ }
2115
+ const becamePaid = (previousPayment == null ? void 0 : previousPayment.status) !== "paid" && ((_b = result.payment) == null ? void 0 : _b.status) === "paid";
2116
+ const shouldSubmit = Boolean(
2117
+ options.submitWhenPaid && ((_c = result.payment) == null ? void 0 : _c.status) === "paid" && (becamePaid || options.forceSubmitIfPaid)
2118
+ );
2119
+ let syncResult;
2120
+ if (shouldSubmit) {
2121
+ syncResult = await this.syncPaymentsToOrder({
2122
+ payments: result.payments,
2123
+ paymentStatus: this.getPaymentStatusForSync(result.payments),
2124
+ submitWhenPaid: true,
2125
+ smallTicketDataFlag: options.smallTicketDataFlag ?? 1
2126
+ });
2127
+ }
2128
+ return {
2129
+ ...result,
2130
+ ...draftResult !== void 0 ? { draftResult } : {},
2131
+ ...draftError !== void 0 ? { draftError } : {},
2132
+ ...syncResult !== void 0 ? { syncResult } : {}
2133
+ };
1988
2134
  }
1989
2135
  /** 删除当前订单中的指定支付项。 */
1990
2136
  deleteOrderPayment(paymentIdentity) {
@@ -1998,6 +2144,11 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
1998
2144
  throw new Error("order 模块未初始化");
1999
2145
  return this.store.order.updateVoucherOrderPayments(payments, options);
2000
2146
  }
2147
+ async updateVoucherOrderPaymentsAsync(payments, options) {
2148
+ if (!this.store.order)
2149
+ throw new Error("order 模块未初始化");
2150
+ return this.store.order.updateVoucherOrderPaymentsAsync(payments, options);
2151
+ }
2001
2152
  confirmPendingVoucherPayments() {
2002
2153
  if (!this.store.order)
2003
2154
  throw new Error("order 模块未初始化");
@@ -82,8 +82,13 @@ export interface ISalesBooking {
82
82
  metadata?: Record<string, any> | null;
83
83
  [key: string]: any;
84
84
  }
85
+ export interface ISalesPaymentMetadata extends Record<string, any> {
86
+ /** 刷卡机设备快照;OS 不解析内部字段 */
87
+ card_reader_snapshot?: Record<string, unknown>;
88
+ }
85
89
  export interface ISalesPayment {
86
90
  order_payment_id?: number | null;
91
+ payment_number?: string;
87
92
  custom_payment_id?: number;
88
93
  code?: string;
89
94
  name?: string;
@@ -95,7 +100,7 @@ export interface ISalesPayment {
95
100
  status?: string;
96
101
  payment_time?: string | null;
97
102
  service_charge?: Record<string, any> | null;
98
- metadata?: Record<string, any> | null;
103
+ metadata?: ISalesPaymentMetadata | null;
99
104
  [key: string]: any;
100
105
  }
101
106
  export interface ISalesSurcharge {
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
311
311
  date: string;
312
312
  status: string;
313
313
  week: string;
314
- weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
314
+ weekNum: 0 | 2 | 1 | 6 | 4 | 3 | 5;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -322,7 +322,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
322
322
  * 获取当前的客户搜索条件
323
323
  * @returns 当前搜索条件
324
324
  */
325
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
325
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
326
326
  /**
327
327
  * 获取客户列表状态(包含滚动加载相关状态)
328
328
  * @returns 客户状态
@@ -1153,7 +1153,8 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
1153
1153
  }
1154
1154
  /** 读取当前 booking config。 */
1155
1155
  getBookingConfig() {
1156
- return this.store.bookingContext.getBookingConfig();
1156
+ var _a;
1157
+ return (_a = this.store.bookingContext) == null ? void 0 : _a.getBookingConfig();
1157
1158
  }
1158
1159
  /** 写入资源全集(来源:`/form/schedule`),同步派生 resourcesOriginMap。 */
1159
1160
  setResources(resources) {
@@ -83,8 +83,6 @@ export interface ILoadProductsParams {
83
83
  extension_type?: string[];
84
84
  /** 商品发布状态 */
85
85
  status?: string;
86
- /** 智能定价条件上下文,仅影响策略命中,不参与商品集合筛选 */
87
- strategy_context?: Record<string, any>;
88
86
  }
89
87
  /**
90
88
  * 加载商品详情的参数
@@ -505,7 +505,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
505
505
  try {
506
506
  const orderId = this.store.orderId;
507
507
  const customerId = params.customerId || ((_a = this.getCustomer()) == null ? void 0 : _a.id);
508
- const prepareConfigResult = await ((_b = this.store.discount) == null ? void 0 : _b.loadPrepareConfig({
508
+ const goodPassList = await ((_b = this.store.discount) == null ? void 0 : _b.loadPrepareConfig({
509
509
  customer_id: customerId,
510
510
  action: orderId ? "edit" : "create",
511
511
  with_good_pass: 1,
@@ -514,7 +514,6 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
514
514
  request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
515
515
  ...orderId ? { order_id: orderId } : {}
516
516
  }));
517
- const goodPassList = (prepareConfigResult == null ? void 0 : prepareConfigResult.discountList) || [];
518
517
  const scanDiscount = (_c = this.getDiscountList()) == null ? void 0 : _c.filter(
519
518
  (item) => item.isScan
520
519
  );
@@ -0,0 +1,9 @@
1
+ export type PaymentNumberAppDataGetter = (key: string) => unknown;
2
+ /**
3
+ * Resolve the synchronous fallback without caching runtime device data.
4
+ */
5
+ export declare function resolvePaymentNumberDevicePrefixFromDeviceId(getAppData: PaymentNumberAppDataGetter): string;
6
+ /**
7
+ * Resolve the latest device segment when a new payment number is generated.
8
+ */
9
+ export declare function resolvePaymentNumberDevicePrefix(getAppData: PaymentNumberAppDataGetter): Promise<string>;
@@ -0,0 +1,64 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/utils/payment-number.ts
20
+ var payment_number_exports = {};
21
+ __export(payment_number_exports, {
22
+ resolvePaymentNumberDevicePrefix: () => resolvePaymentNumberDevicePrefix,
23
+ resolvePaymentNumberDevicePrefixFromDeviceId: () => resolvePaymentNumberDevicePrefixFromDeviceId
24
+ });
25
+ module.exports = __toCommonJS(payment_number_exports);
26
+ function normalizeNonEmptyString(value) {
27
+ if (value === void 0 || value === null)
28
+ return null;
29
+ if (typeof value !== "string" && typeof value !== "number")
30
+ return null;
31
+ if (typeof value === "number" && !Number.isFinite(value))
32
+ return null;
33
+ const normalized = String(value).trim();
34
+ return normalized || null;
35
+ }
36
+ function resolvePaymentNumberDevicePrefixFromDeviceId(getAppData) {
37
+ try {
38
+ const deviceId = normalizeNonEmptyString(getAppData("device_id"));
39
+ if (deviceId && deviceId !== "0")
40
+ return deviceId.slice(-2);
41
+ } catch {
42
+ }
43
+ return "LOCAL";
44
+ }
45
+ async function resolvePaymentNumberDevicePrefix(getAppData) {
46
+ try {
47
+ const getAsyncIotDeviceInfo = getAppData("async_iot_device_info");
48
+ if (typeof getAsyncIotDeviceInfo === "function") {
49
+ const info = await getAsyncIotDeviceInfo();
50
+ const shortNumber = normalizeNonEmptyString(
51
+ info == null ? void 0 : info.short_number
52
+ );
53
+ if (shortNumber && shortNumber !== "0")
54
+ return shortNumber;
55
+ }
56
+ } catch {
57
+ }
58
+ return resolvePaymentNumberDevicePrefixFromDeviceId(getAppData);
59
+ }
60
+ // Annotate the CommonJS export names for ESM import in node:
61
+ 0 && (module.exports = {
62
+ resolvePaymentNumberDevicePrefix,
63
+ resolvePaymentNumberDevicePrefixFromDeviceId
64
+ });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.29",
4
+ "version": "2.3.30",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -1,50 +0,0 @@
1
- import type { EvaluationResult, RuntimeContext } from '../../type';
2
- import type { BusinessAdapter } from '../type';
3
- import type { DataVariantBusinessData, DataVariantProduct } from './type';
4
- /**
5
- * Data Variant 适配器。
6
- *
7
- * 负责把智能定价运行态数据转换为 StrategyEngine 能识别的 attributes。
8
- */
9
- export declare class DataVariantAdapter implements BusinessAdapter {
10
- name: string;
11
- version: string;
12
- /**
13
- * 准备批量全局上下文。
14
- *
15
- * 这里只放不依赖单个商品的字段,用于预计算 schedule/channel/orderType 等条件。
16
- */
17
- prepareContext(businessData: DataVariantBusinessData): RuntimeContext;
18
- /**
19
- * 准备全局预计算上下文。
20
- */
21
- prepareGlobalContext(businessData: DataVariantBusinessData): RuntimeContext;
22
- /**
23
- * 准备单商品上下文。
24
- *
25
- * 商品级条件只在当前商品 data_variants 引用到对应规则后才评估。
26
- */
27
- prepareProductContext(businessData: DataVariantBusinessData, product: DataVariantProduct): RuntimeContext;
28
- transformResult(result: EvaluationResult): EvaluationResult;
29
- formatConfig(result: EvaluationResult, businessData?: DataVariantBusinessData): {
30
- result: EvaluationResult;
31
- businessData?: DataVariantBusinessData;
32
- };
33
- /**
34
- * 构建 menu_match 使用的轻量商品对象。
35
- *
36
- * collection_ids 来自商品 collection 字段,避免 operator 读取复杂商品对象。
37
- */
38
- buildProductValue(product: DataVariantProduct): {
39
- id: number;
40
- product_variant_id: number;
41
- collection_ids: number[];
42
- };
43
- private toNumber;
44
- /**
45
- * 归一化客户 id:无效值返回 undefined,有效值统一为 number。
46
- */
47
- private normalizeCustomerId;
48
- private normalizeNumberArray;
49
- }
50
- export default DataVariantAdapter;