@pisell/pisellos 2.2.265 → 2.2.267

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 (66) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  2. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -3
  3. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +6 -3
  4. package/dist/modules/Order/index.d.ts +8 -27
  5. package/dist/modules/Order/index.js +490 -743
  6. package/dist/modules/Order/types.d.ts +1 -33
  7. package/dist/modules/Order/utils/orderCollectionIdentity.js +2 -7
  8. package/dist/modules/Order/utils.js +5 -8
  9. package/dist/modules/Payment/index.d.ts +0 -2
  10. package/dist/modules/Payment/index.js +50 -79
  11. package/dist/modules/Payment/types.d.ts +27 -29
  12. package/dist/modules/Payment/types.js +3 -5
  13. package/dist/server/index.d.ts +0 -16
  14. package/dist/server/index.js +1036 -1933
  15. package/dist/server/modules/order/index.d.ts +4 -49
  16. package/dist/server/modules/order/index.js +695 -1574
  17. package/dist/server/modules/order/types.d.ts +3 -11
  18. package/dist/server/modules/order/types.js +1 -1
  19. package/dist/solution/BaseSales/index.d.ts +11 -42
  20. package/dist/solution/BaseSales/index.js +385 -676
  21. package/dist/solution/BaseSales/utils/cartPromotion.js +5 -3
  22. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
  23. package/dist/solution/BookingTicket/index.d.ts +1 -1
  24. package/dist/solution/BookingTicket/index.js +1 -2
  25. package/dist/solution/BookingTicket/utils/addProductDecision.js +6 -0
  26. package/dist/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
  27. package/dist/solution/BookingTicket/utils/weighingProductSku.js +45 -0
  28. package/dist/solution/Sales/index.d.ts +0 -1
  29. package/dist/solution/Sales/index.js +2 -10
  30. package/lib/model/strategy/adapter/promotion/index.js +0 -49
  31. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +2 -1
  32. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
  33. package/lib/modules/Order/index.d.ts +8 -27
  34. package/lib/modules/Order/index.js +69 -184
  35. package/lib/modules/Order/types.d.ts +1 -33
  36. package/lib/modules/Order/utils/orderCollectionIdentity.js +0 -3
  37. package/lib/modules/Order/utils.js +3 -5
  38. package/lib/modules/Payment/index.d.ts +0 -2
  39. package/lib/modules/Payment/index.js +13 -34
  40. package/lib/modules/Payment/types.d.ts +27 -29
  41. package/lib/modules/Payment/types.js +3 -3
  42. package/lib/server/index.d.ts +0 -16
  43. package/lib/server/index.js +18 -670
  44. package/lib/server/modules/order/index.d.ts +4 -49
  45. package/lib/server/modules/order/index.js +66 -657
  46. package/lib/server/modules/order/types.d.ts +3 -11
  47. package/lib/solution/BaseSales/index.d.ts +11 -42
  48. package/lib/solution/BaseSales/index.js +35 -214
  49. package/lib/solution/BaseSales/utils/cartPromotion.js +5 -2
  50. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
  51. package/lib/solution/BookingTicket/index.d.ts +1 -1
  52. package/lib/solution/BookingTicket/index.js +1 -2
  53. package/lib/solution/BookingTicket/utils/addProductDecision.js +4 -0
  54. package/lib/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
  55. package/lib/solution/BookingTicket/utils/weighingProductSku.js +63 -0
  56. package/lib/solution/Sales/index.d.ts +0 -1
  57. package/lib/solution/Sales/index.js +3 -5
  58. package/package.json +2 -2
  59. package/dist/modules/Order/payment-utils.d.ts +0 -26
  60. package/dist/modules/Order/payment-utils.js +0 -225
  61. package/dist/utils/payment-number.d.ts +0 -9
  62. package/dist/utils/payment-number.js +0 -69
  63. package/lib/modules/Order/payment-utils.d.ts +0 -26
  64. package/lib/modules/Order/payment-utils.js +0 -224
  65. package/lib/utils/payment-number.d.ts +0 -9
  66. package/lib/utils/payment-number.js +0 -64
@@ -468,8 +468,6 @@ export interface SubmitSalesOrderParams {
468
468
  export interface PaymentItemData {
469
469
  /** 当前支付项的唯一 ID */
470
470
  uuid: string;
471
- /** 支付项稳定唯一号 */
472
- payment_number?: string;
473
471
  /** 当前支付方式付出去多少钱 */
474
472
  amount: string;
475
473
  /** 支付类型代码 */
@@ -492,22 +490,13 @@ export interface PaymentItemData {
492
490
  export interface OrderPaymentMetadata {
493
491
  rounding_rule?: Record<string, any>;
494
492
  unique_payment_number?: string;
495
- /** 刷卡机设备快照;OS 不解析内部字段,仅透传并持久化 */
496
- card_reader_snapshot?: Record<string, unknown>;
497
493
  shop_wallet_pass_id?: number | string;
498
494
  actual_paid_amount?: number | string;
499
495
  change_given_amount?: number | string;
500
- transactions?: OrderPaymentTransaction[];
501
496
  [key: string]: any;
502
497
  }
503
- export interface OrderPaymentTransaction {
504
- number: string;
505
- status: 'success' | 'fail';
506
- }
507
498
  export interface OrderPaymentData {
508
499
  order_payment_id?: number | string;
509
- /** 支付项稳定唯一号;历史支付项允许缺失 */
510
- payment_number?: string;
511
500
  amount: string;
512
501
  code: string;
513
502
  custom_payment_id: number;
@@ -534,15 +523,6 @@ export interface OrderPaymentData {
534
523
  created_at?: string;
535
524
  updated_at?: string;
536
525
  }
537
- export interface OrderPaymentUpdateOptions {
538
- matchBy?: 'payment_number' | 'compat' | 'legacy';
539
- }
540
- export interface OrderPaymentUpdateResult {
541
- updated: boolean;
542
- payment: OrderPaymentData | null;
543
- payments: OrderPaymentData[];
544
- summary: OrderSummary | null;
545
- }
546
526
  export type OrderPaymentSource = PaymentItem | OrderPaymentData | Record<string, any>;
547
527
  export interface MapOrderPaymentsOptions {
548
528
  includeVoided?: boolean;
@@ -693,14 +673,6 @@ export interface OrderModuleAPI {
693
673
  channel?: string;
694
674
  type?: string;
695
675
  }) => OrderSubmitPayload;
696
- saveTempOrderAsDraft: <T = any>(params?: {
697
- cacheId?: string;
698
- platform?: string;
699
- businessCode?: string;
700
- channel?: string;
701
- type?: string;
702
- enhancePayload?: SubmitPayloadEnhancer;
703
- }) => Promise<T>;
704
676
  applyLocalPrintOrderNumbers: (order?: Record<string, any> | null) => Promise<OrderTempOrder>;
705
677
  getTempOrderNote: () => string;
706
678
  updateTempOrderNote: {
@@ -758,15 +730,11 @@ export interface OrderModuleAPI {
758
730
  getOrderPayments: () => OrderPaymentData[];
759
731
  setOrderPayments: (payments: OrderPaymentSource[]) => OrderPaymentData[];
760
732
  addOrderPayment: (payment: OrderPaymentSource) => OrderPaymentData[];
761
- addOrderPaymentAsync: (payment: OrderPaymentSource) => Promise<OrderPaymentData[]>;
762
- updateOrderPayment: (paymentIdentity: string | number, updates: Partial<OrderPaymentData> & Record<string, any>, options?: OrderPaymentUpdateOptions) => Promise<OrderPaymentUpdateResult>;
733
+ updateOrderPayment: (paymentIdentity: string | number, updates: Partial<OrderPaymentData> & Record<string, any>) => OrderPaymentData[];
763
734
  deleteOrderPayment: (paymentIdentity: string | number) => OrderPaymentData[];
764
735
  updateVoucherOrderPayments: (payments: OrderPaymentSource[], options?: {
765
736
  status?: 'paid' | 'payment_pending';
766
737
  }) => OrderPaymentData[];
767
- updateVoucherOrderPaymentsAsync: (payments: OrderPaymentSource[], options?: {
768
- status?: 'paid' | 'payment_pending';
769
- }) => Promise<OrderPaymentData[]>;
770
738
  confirmPendingVoucherPayments: (options?: {
771
739
  persist?: boolean;
772
740
  recalculateSummary?: boolean;
@@ -209,11 +209,6 @@ export function normalizeOrderCollection(kind, items, options) {
209
209
  var persistentId = getOrderCollectionPersistentId(kind, item);
210
210
  var uid = getOrderCollectionUid(kind, item);
211
211
  if (!uid) {
212
- var _item;
213
- if (kind === 'payment' && !isBlankOrderCollectionIdentity((_item = item) === null || _item === void 0 ? void 0 : _item.payment_number)) {
214
- // payment_number 已提供稳定身份,不占用真实交易流水字段作为内部 UID。
215
- continue;
216
- }
217
212
  uid = persistentId ? buildOrderCollectionFallbackUid(kind, persistentId) : allocateAnonymousUid(occupiedUids, createAnonymousUid);
218
213
  item = setOrderCollectionUid(kind, item, uid);
219
214
  result[index] = item;
@@ -221,7 +216,7 @@ export function normalizeOrderCollection(kind, items, options) {
221
216
  if (!persistentId) stats.anonymousRowCount += 1;
222
217
  }
223
218
  if (occupiedUids.has(uid)) {
224
- var _item2, _item3, _item4, _item5;
219
+ var _item, _item2, _item3, _item4;
225
220
  var replacementUid = persistentId ? allocatePersistentConflictUid(kind, persistentId, occupiedUids) : allocateAnonymousUid(occupiedUids, createAnonymousUid);
226
221
  result[index] = setOrderCollectionUid(kind, item, replacementUid);
227
222
  uidRemaps.push({
@@ -230,7 +225,7 @@ export function normalizeOrderCollection(kind, items, options) {
230
225
  to: replacementUid,
231
226
  persistentId: persistentId,
232
227
  scope: 'linked-owner',
233
- referenceOwnerUid: kind === 'product' ? String(((_item2 = item) === null || _item2 === void 0 ? void 0 : _item2.booking_uid) || ((_item3 = item) === null || _item3 === void 0 || (_item3 = _item3.metadata) === null || _item3 === void 0 ? void 0 : _item3.booking_uid) || '') || null : kind === 'booking' ? String(((_item4 = item) === null || _item4 === void 0 ? void 0 : _item4.product_uid) || ((_item5 = item) === null || _item5 === void 0 || (_item5 = _item5.metadata) === null || _item5 === void 0 ? void 0 : _item5.product_uid) || '') || null : null
228
+ referenceOwnerUid: kind === 'product' ? String(((_item = item) === null || _item === void 0 ? void 0 : _item.booking_uid) || ((_item2 = item) === null || _item2 === void 0 || (_item2 = _item2.metadata) === null || _item2 === void 0 ? void 0 : _item2.booking_uid) || '') || null : kind === 'booking' ? String(((_item3 = item) === null || _item3 === void 0 ? void 0 : _item3.product_uid) || ((_item4 = item) === null || _item4 === void 0 || (_item4 = _item4.metadata) === null || _item4 === void 0 ? void 0 : _item4.product_uid) || '') || null : null
234
229
  });
235
230
  uid = replacementUid;
236
231
  stats.uidConflictCount += 1;
@@ -1047,7 +1047,7 @@ export function createDefaultTempOrder(params) {
1047
1047
  };
1048
1048
  }
1049
1049
  export function buildSubmitPayload(params) {
1050
- var _tempOrder$customer_i, _tempOrder$country_ca, _tempOrder$phone, _tempOrder$email, _tempOrder$order_numb, _tempOrder$shop_order, _tempOrder$shop_full_, _ref30, _tempOrder$is_price_i, _tempOrder$is_deposit, _enhancedPayload$summ;
1050
+ var _tempOrder$customer_i, _tempOrder$order_numb, _tempOrder$shop_order, _tempOrder$shop_full_, _ref30, _tempOrder$is_price_i, _tempOrder$is_deposit, _enhancedPayload$summ;
1051
1051
  var tempOrder = params.tempOrder,
1052
1052
  cacheId = params.cacheId,
1053
1053
  _params$now = params.now,
@@ -1093,9 +1093,6 @@ export function buildSubmitPayload(params) {
1093
1093
  var payload = _objectSpread(_objectSpread({}, tempOrderRest), {}, {
1094
1094
  customer_id: (_tempOrder$customer_i = tempOrder.customer_id) !== null && _tempOrder$customer_i !== void 0 ? _tempOrder$customer_i : 1,
1095
1095
  customer_name: tempOrder.customer_name || 'Walk-In',
1096
- country_calling_code: String((_tempOrder$country_ca = tempOrder.country_calling_code) !== null && _tempOrder$country_ca !== void 0 ? _tempOrder$country_ca : ''),
1097
- phone: String((_tempOrder$phone = tempOrder.phone) !== null && _tempOrder$phone !== void 0 ? _tempOrder$phone : ''),
1098
- email: String((_tempOrder$email = tempOrder.email) !== null && _tempOrder$email !== void 0 ? _tempOrder$email : ''),
1099
1096
  order_number: (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : null,
1100
1097
  shop_order_number: (_tempOrder$shop_order = tempOrder.shop_order_number) !== null && _tempOrder$shop_order !== void 0 ? _tempOrder$shop_order : null,
1101
1098
  shop_full_order_number: (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : null,
@@ -1155,7 +1152,9 @@ export function mapPaymentItemToOrderPayment(paymentItem) {
1155
1152
  var item = paymentItem;
1156
1153
  var customPaymentId = (_item$custom_payment_ = item.custom_payment_id) !== null && _item$custom_payment_ !== void 0 ? _item$custom_payment_ : item.id;
1157
1154
  var metadata = item.metadata && _typeof(item.metadata) === 'object' ? _objectSpread({}, item.metadata) : {};
1158
- var paymentNumber = item.payment_number;
1155
+ if (item.uuid && !metadata.unique_payment_number) {
1156
+ metadata.unique_payment_number = String(item.uuid);
1157
+ }
1159
1158
  var paymentMetadataKeys = ['rounding_rule', 'shop_wallet_pass_id', 'actual_paid_amount', 'change_given_amount'];
1160
1159
  for (var _i3 = 0, _paymentMetadataKeys = paymentMetadataKeys; _i3 < _paymentMetadataKeys.length; _i3++) {
1161
1160
  var key = _paymentMetadataKeys[_i3];
@@ -1166,10 +1165,8 @@ export function mapPaymentItemToOrderPayment(paymentItem) {
1166
1165
  var timestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
1167
1166
  var paymentTime = (_item$payment_time = item.payment_time) !== null && _item$payment_time !== void 0 ? _item$payment_time : timestamp;
1168
1167
  var createdAt = (_item$created_at = item.created_at) !== null && _item$created_at !== void 0 ? _item$created_at : timestamp;
1169
- return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, item.order_payment_id !== undefined ? {
1168
+ return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, item.order_payment_id !== undefined ? {
1170
1169
  order_payment_id: item.order_payment_id
1171
- } : {}), paymentNumber !== undefined && paymentNumber !== null && paymentNumber !== '' ? {
1172
- payment_number: String(paymentNumber)
1173
1170
  } : {}), {}, {
1174
1171
  amount: String((_item$amount = item.amount) !== null && _item$amount !== void 0 ? _item$amount : '0.00'),
1175
1172
  code: String(item.code || ''),
@@ -20,7 +20,6 @@ export declare class PaymentModule extends BaseModule implements Module, Payment
20
20
  protected defaultVersion: string;
21
21
  request: RequestPlugin;
22
22
  private app;
23
- private appPlugin;
24
23
  private store;
25
24
  window: WindowPlugin;
26
25
  private dbManager;
@@ -41,7 +40,6 @@ export declare class PaymentModule extends BaseModule implements Module, Payment
41
40
  * paymentModule.updateOtherParams({ fatherModule: 'bookingTicket' });
42
41
  */
43
42
  updateOtherParams(params: Record<string, any>): void;
44
- private getPaymentNumberAppData;
45
43
  /**
46
44
  * 记录信息日志
47
45
  */
@@ -27,9 +27,6 @@ import { CashPaymentImpl } from "./cash";
27
27
  import { EftposPaymentImpl } from "./eftpos";
28
28
  import { WalletPassPaymentImpl } from "./walletpass";
29
29
  import { Decimal } from 'decimal.js';
30
- import { ensureOrderPaymentNumber } from "../Order/payment-utils";
31
- import { createUuidV4 } from "../Order/utils";
32
- import { resolvePaymentNumberDevicePrefix } from "../../utils/payment-number";
33
30
  export * from "./types";
34
31
  export { generateRequestUniqueId };
35
32
 
@@ -105,7 +102,6 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
105
102
  _defineProperty(_assertThisInitialized(_this), "request", void 0);
106
103
  _defineProperty(_assertThisInitialized(_this), "app", void 0);
107
104
  // App instance
108
- _defineProperty(_assertThisInitialized(_this), "appPlugin", void 0);
109
105
  _defineProperty(_assertThisInitialized(_this), "store", void 0);
110
106
  _defineProperty(_assertThisInitialized(_this), "window", void 0);
111
107
  // WindowPlugin 实例
@@ -172,6 +168,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
172
168
  key: "initialize",
173
169
  value: function () {
174
170
  var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
171
+ var appPlugin;
175
172
  return _regeneratorRuntime().wrap(function _callee$(_context) {
176
173
  while (1) switch (_context.prev = _context.next) {
177
174
  case 0:
@@ -181,7 +178,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
181
178
 
182
179
  // 获取依赖的插件
183
180
  this.request = core.getPlugin('request');
184
- this.appPlugin = core.getPlugin('app');
181
+ appPlugin = core.getPlugin('app');
185
182
  this.window = core.getPlugin('window');
186
183
  if (this.request) {
187
184
  _context.next = 8;
@@ -189,13 +186,13 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
189
186
  }
190
187
  throw new Error('支付模块需要 request 插件支持');
191
188
  case 8:
192
- if (this.appPlugin) {
189
+ if (appPlugin) {
193
190
  _context.next = 10;
194
191
  break;
195
192
  }
196
193
  throw new Error('支付模块需要 app 插件支持');
197
194
  case 10:
198
- this.app = this.appPlugin.getApp();
195
+ this.app = appPlugin.getApp();
199
196
  this.dbManager = this.app.dbManager;
200
197
  this.logger = this.app.logger;
201
198
 
@@ -231,15 +228,6 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
231
228
  value: function updateOtherParams(params) {
232
229
  this.otherParams = params || {};
233
230
  }
234
- }, {
235
- key: "getPaymentNumberAppData",
236
- value: function getPaymentNumberAppData(key) {
237
- var _this$appPlugin, _this$appPlugin$getDa, _this$app, _this$app$getStore, _this$app$getStore$ca, _this$app$getStore$ca2;
238
- var getData = (_this$appPlugin = this.appPlugin) === null || _this$appPlugin === void 0 || (_this$appPlugin$getDa = _this$appPlugin.getData) === null || _this$appPlugin$getDa === void 0 ? void 0 : _this$appPlugin$getDa.call(_this$appPlugin);
239
- if (typeof getData === 'function') return getData(key);
240
- var coreData = (_this$app = this.app) === null || _this$app === void 0 || (_this$app = _this$app.models) === null || _this$app === void 0 || (_this$app$getStore = _this$app.getStore) === null || _this$app$getStore === void 0 || (_this$app$getStore$ca = (_this$app$getStore$ca2 = _this$app$getStore.call(_this$app)).getDataByModel) === null || _this$app$getStore$ca === void 0 ? void 0 : _this$app$getStore$ca.call(_this$app$getStore$ca2, 'core', 'core');
241
- return coreData === null || coreData === void 0 ? void 0 : coreData[key];
242
- }
243
231
 
244
232
  /**
245
233
  * 记录信息日志
@@ -896,8 +884,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
896
884
  key: "addPaymentItemAsync",
897
885
  value: (function () {
898
886
  var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(orderUuid, paymentItem) {
899
- var _this5 = this;
900
- var _paymentItem$metadata, _newPaymentItem$metad, _newPaymentItem$metad2, _newPaymentItem$metad3, order, expectAmount, paidDepositAmount, expectedDepositAmount, warningMessage, paymentUuid, currentTime, hasPaymentNumber, paymentNumberDevicePrefix, paymentNumber, newPaymentItem;
887
+ var _paymentItem$metadata, _newPaymentItem$metad, _newPaymentItem$metad2, _newPaymentItem$metad3, order, expectAmount, paidDepositAmount, expectedDepositAmount, warningMessage, paymentUuid, currentTime, newPaymentItem;
901
888
  return _regeneratorRuntime().wrap(function _callee12$(_context12) {
902
889
  while (1) switch (_context12.prev = _context12.next) {
903
890
  case 0:
@@ -953,29 +940,14 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
953
940
  });
954
941
  throw new Error(warningMessage);
955
942
  case 17:
956
- paymentUuid = paymentItem.uuid || ((_paymentItem$metadata = paymentItem.metadata) === null || _paymentItem$metadata === void 0 ? void 0 : _paymentItem$metadata.unique_payment_number) || getUniqueId('payment_');
957
- currentTime = formatDateTime(new Date());
958
- hasPaymentNumber = String(paymentItem.payment_number || '').trim() !== '';
959
- if (!hasPaymentNumber) {
960
- _context12.next = 24;
961
- break;
943
+ if ((_paymentItem$metadata = paymentItem.metadata) !== null && _paymentItem$metadata !== void 0 && _paymentItem$metadata.unique_payment_number) {
944
+ paymentUuid = paymentItem.metadata.unique_payment_number;
945
+ } else {
946
+ paymentUuid = getUniqueId('payment_');
962
947
  }
963
- _context12.t0 = 'LOCAL';
964
- _context12.next = 27;
965
- break;
966
- case 24:
967
- _context12.next = 26;
968
- return resolvePaymentNumberDevicePrefix(function (key) {
969
- return _this5.getPaymentNumberAppData(key);
970
- });
971
- case 26:
972
- _context12.t0 = _context12.sent;
973
- case 27:
974
- paymentNumberDevicePrefix = _context12.t0;
975
- paymentNumber = ensureOrderPaymentNumber(paymentItem, paymentNumberDevicePrefix, createUuidV4).payment_number;
948
+ currentTime = formatDateTime(new Date());
976
949
  newPaymentItem = {
977
950
  uuid: paymentUuid,
978
- payment_number: paymentNumber,
979
951
  custom_payment_id: normalizeCustomPaymentId(paymentItem),
980
952
  name: paymentItem.name,
981
953
  code: paymentItem.code,
@@ -994,7 +966,10 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
994
966
  // 创建时间
995
967
  updated_at: currentTime,
996
968
  // 更新时间
997
- metadata: _objectSpread({}, paymentItem.metadata)
969
+ metadata: _objectSpread(_objectSpread({}, paymentItem.metadata), {}, {
970
+ // 保留传入的所有 metadata 字段
971
+ unique_payment_number: paymentUuid // 设置唯一支付号为支付项的 uuid
972
+ })
998
973
  };
999
974
  order.payment.push(newPaymentItem);
1000
975
  this.recalculateOrderAmount(order);
@@ -1002,9 +977,9 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1002
977
  orderUuid: orderUuid,
1003
978
  order: order
1004
979
  });
1005
- _context12.next = 35;
980
+ _context12.next = 25;
1006
981
  return this.dbManager.update('order', order, true);
1007
- case 35:
982
+ case 25:
1008
983
  this.logInfo('更新订单支付项完成', {
1009
984
  orderUuid: orderUuid
1010
985
  });
@@ -1025,22 +1000,22 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1025
1000
  actualPaidAmount: (_newPaymentItem$metad2 = newPaymentItem.metadata) === null || _newPaymentItem$metad2 === void 0 ? void 0 : _newPaymentItem$metad2.actual_paid_amount,
1026
1001
  changeGivenAmount: (_newPaymentItem$metad3 = newPaymentItem.metadata) === null || _newPaymentItem$metad3 === void 0 ? void 0 : _newPaymentItem$metad3.change_given_amount
1027
1002
  });
1028
- _context12.next = 45;
1003
+ _context12.next = 35;
1029
1004
  break;
1030
- case 40:
1031
- _context12.prev = 40;
1032
- _context12.t1 = _context12["catch"](1);
1033
- console.error('[PaymentModule] 添加支付项失败', _context12.t1);
1034
- this.logError('addPaymentItemAsync failed', _context12.t1, {
1005
+ case 30:
1006
+ _context12.prev = 30;
1007
+ _context12.t0 = _context12["catch"](1);
1008
+ console.error('[PaymentModule] 添加支付项失败', _context12.t0);
1009
+ this.logError('addPaymentItemAsync failed', _context12.t0, {
1035
1010
  orderUuid: orderUuid,
1036
1011
  paymentItem: paymentItem
1037
1012
  });
1038
- throw _context12.t1;
1039
- case 45:
1013
+ throw _context12.t0;
1014
+ case 35:
1040
1015
  case "end":
1041
1016
  return _context12.stop();
1042
1017
  }
1043
- }, _callee12, this, [[1, 40]]);
1018
+ }, _callee12, this, [[1, 30]]);
1044
1019
  }));
1045
1020
  function addPaymentItemAsync(_x13, _x14) {
1046
1021
  return _addPaymentItemAsync.apply(this, arguments);
@@ -1160,17 +1135,17 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1160
1135
  key: "updateVoucherPaymentItemsAsync",
1161
1136
  value: (function () {
1162
1137
  var _updateVoucherPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(orderUuid, voucherPaymentItems) {
1163
- var _this6 = this;
1138
+ var _this5 = this;
1164
1139
  return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1165
1140
  while (1) switch (_context15.prev = _context15.next) {
1166
1141
  case 0:
1167
1142
  return _context15.abrupt("return", this.runVoucherUpdateLocked(orderUuid, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
1168
- var _this6$normalizeVouch, normalizedVoucherItems, originalCount, normalizedCount, order, existingVoucherItems, _iterator2, _step2, voucherItem, orderAfterDelete, existingActiveVoucherKeys, _iterator3, _step3, _voucherItem, orderPaymentType, key, updatedOrder;
1143
+ var _this5$normalizeVouch, normalizedVoucherItems, originalCount, normalizedCount, order, existingVoucherItems, _iterator2, _step2, voucherItem, orderAfterDelete, existingActiveVoucherKeys, _iterator3, _step3, _voucherItem, orderPaymentType, key, updatedOrder;
1169
1144
  return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1170
1145
  while (1) switch (_context14.prev = _context14.next) {
1171
1146
  case 0:
1172
- _this6$normalizeVouch = _this6.normalizeVoucherPaymentItems(voucherPaymentItems), normalizedVoucherItems = _this6$normalizeVouch.items, originalCount = _this6$normalizeVouch.originalCount, normalizedCount = _this6$normalizeVouch.normalizedCount;
1173
- _this6.logInfo('Starting updateVoucherPaymentItemsAsync', {
1147
+ _this5$normalizeVouch = _this5.normalizeVoucherPaymentItems(voucherPaymentItems), normalizedVoucherItems = _this5$normalizeVouch.items, originalCount = _this5$normalizeVouch.originalCount, normalizedCount = _this5$normalizeVouch.normalizedCount;
1148
+ _this5.logInfo('Starting updateVoucherPaymentItemsAsync', {
1174
1149
  orderUuid: orderUuid,
1175
1150
  originalVoucherCount: originalCount,
1176
1151
  normalizedVoucherCount: normalizedCount,
@@ -1192,7 +1167,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1192
1167
  }
1193
1168
  _context14.prev = 3;
1194
1169
  _context14.next = 6;
1195
- return _this6.getPaymentOrderByUuidAsync(orderUuid);
1170
+ return _this5.getPaymentOrderByUuidAsync(orderUuid);
1196
1171
  case 6:
1197
1172
  order = _context14.sent;
1198
1173
  if (order) {
@@ -1232,7 +1207,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1232
1207
  voucherItem = _step2.value;
1233
1208
  console.log("[PaymentModule] \u5220\u9664\u73B0\u6709\u4EE3\u91D1\u5238\u652F\u4ED8\u9879: ".concat(voucherItem.uuid));
1234
1209
  _context14.next = 19;
1235
- return _this6.deletePaymentAsync(orderUuid, voucherItem.uuid);
1210
+ return _this5.deletePaymentAsync(orderUuid, voucherItem.uuid);
1236
1211
  case 19:
1237
1212
  _context14.next = 14;
1238
1213
  break;
@@ -1249,7 +1224,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1249
1224
  return _context14.finish(26);
1250
1225
  case 29:
1251
1226
  _context14.next = 31;
1252
- return _this6.getPaymentOrderByUuidAsync(orderUuid);
1227
+ return _this5.getPaymentOrderByUuidAsync(orderUuid);
1253
1228
  case 31:
1254
1229
  orderAfterDelete = _context14.sent;
1255
1230
  if (orderAfterDelete) {
@@ -1296,7 +1271,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1296
1271
  order_payment_type: orderPaymentType
1297
1272
  }));
1298
1273
  _context14.next = 49;
1299
- return _this6.addPaymentItemAsync(orderUuid, _voucherItem);
1274
+ return _this5.addPaymentItemAsync(orderUuid, _voucherItem);
1300
1275
  case 49:
1301
1276
  existingActiveVoucherKeys.add(key);
1302
1277
  case 50:
@@ -1315,17 +1290,17 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1315
1290
  return _context14.finish(57);
1316
1291
  case 60:
1317
1292
  _context14.next = 62;
1318
- return _this6.getPaymentOrderByUuidAsync(orderUuid);
1293
+ return _this5.getPaymentOrderByUuidAsync(orderUuid);
1319
1294
  case 62:
1320
1295
  updatedOrder = _context14.sent;
1321
1296
  _context14.next = 65;
1322
- return _this6.core.effects.emit("".concat(_this6.name, ":onPaymentAdded"), {
1297
+ return _this5.core.effects.emit("".concat(_this5.name, ":onPaymentAdded"), {
1323
1298
  orderUuid: orderUuid,
1324
1299
  order: updatedOrder,
1325
1300
  payment: null // 批量操作不提供单个支付项
1326
1301
  });
1327
1302
  case 65:
1328
- _this6.logInfo('updateVoucherPaymentItemsAsync completed successfully', {
1303
+ _this5.logInfo('updateVoucherPaymentItemsAsync completed successfully', {
1329
1304
  orderUuid: orderUuid,
1330
1305
  removedVoucherCount: existingVoucherItems.length,
1331
1306
  addedVoucherCount: normalizedVoucherItems.length,
@@ -1337,7 +1312,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1337
1312
  _context14.prev = 68;
1338
1313
  _context14.t2 = _context14["catch"](3);
1339
1314
  console.error('[PaymentModule] 批量更新代金券支付项失败:', _context14.t2);
1340
- _this6.logError('updateVoucherPaymentItemsAsync failed', _context14.t2, {
1315
+ _this5.logError('updateVoucherPaymentItemsAsync failed', _context14.t2, {
1341
1316
  orderUuid: orderUuid,
1342
1317
  voucherPaymentItems: voucherPaymentItems
1343
1318
  });
@@ -1386,7 +1361,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1386
1361
  return payment.uuid === paymentUuid;
1387
1362
  });
1388
1363
  if (!paymentItem) {
1389
- _context16.next = 19;
1364
+ _context16.next = 18;
1390
1365
  break;
1391
1366
  }
1392
1367
  // 如果更新参数中包含 amount,先格式化
@@ -1394,43 +1369,40 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1394
1369
  if ('amount' in formattedParams && formattedParams.amount !== undefined) {
1395
1370
  formattedParams.amount = formatAmount(formattedParams.amount);
1396
1371
  }
1397
- if (formattedParams.metadata && _typeof(formattedParams.metadata) === 'object') {
1398
- formattedParams.metadata = _objectSpread(_objectSpread({}, paymentItem.metadata || {}), formattedParams.metadata);
1399
- }
1400
1372
  Object.assign(paymentItem, formattedParams);
1401
1373
 
1402
1374
  // 重新计算待付金额
1403
1375
  this.recalculateOrderAmount(order);
1404
1376
 
1405
1377
  // 更新到 IndexDB
1406
- _context16.next = 15;
1378
+ _context16.next = 14;
1407
1379
  return this.dbManager.update('order', order);
1408
- case 15:
1409
- _context16.next = 17;
1380
+ case 14:
1381
+ _context16.next = 16;
1410
1382
  return this.core.effects.emit("".concat(this.name, ":onPaymentUpdated"), {
1411
1383
  order: order,
1412
1384
  paymentItem: paymentItem
1413
1385
  });
1414
- case 17:
1415
- _context16.next = 19;
1386
+ case 16:
1387
+ _context16.next = 18;
1416
1388
  return this.core.effects.emit("".concat(this.name, ":onOrderChanged"), {
1417
1389
  action: 'payment_update',
1418
1390
  order: order,
1419
1391
  paymentItem: paymentItem
1420
1392
  });
1421
- case 19:
1422
- _context16.next = 25;
1393
+ case 18:
1394
+ _context16.next = 24;
1423
1395
  break;
1424
- case 21:
1425
- _context16.prev = 21;
1396
+ case 20:
1397
+ _context16.prev = 20;
1426
1398
  _context16.t0 = _context16["catch"](0);
1427
1399
  console.error('[PaymentModule] 更新支付项失败', _context16.t0);
1428
1400
  throw _context16.t0;
1429
- case 25:
1401
+ case 24:
1430
1402
  case "end":
1431
1403
  return _context16.stop();
1432
1404
  }
1433
- }, _callee16, this, [[0, 21]]);
1405
+ }, _callee16, this, [[0, 20]]);
1434
1406
  }));
1435
1407
  function updatePaymentAsync(_x19, _x20, _x21) {
1436
1408
  return _updatePaymentAsync.apply(this, arguments);
@@ -1546,7 +1518,6 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1546
1518
  payments: order.payment.map(function (payment) {
1547
1519
  return {
1548
1520
  uuid: payment.uuid,
1549
- payment_number: payment.payment_number,
1550
1521
  amount: payment.amount,
1551
1522
  code: payment.code,
1552
1523
  custom_payment_id: payment.custom_payment_id,
@@ -2009,7 +1980,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
2009
1980
  baseValue = amount.div(roundingInterval);
2010
1981
  console.log("[PaymentModule] \u820D\u5165\u8BA1\u7B97 - \u539F\u59CB\u91D1\u989D: ".concat(amount.toString(), ", \u95F4\u9694: ").concat(intervalValue, ", \u57FA\u7840\u503C: ").concat(baseValue.toString(), ", \u89C4\u5219: ").concat(rule));
2011
1982
  _context26.t0 = rule;
2012
- _context26.next = _context26.t0 === RoundingRule.Standard ? 13 : _context26.t0 === 'standard' ? 13 : _context26.t0 === RoundingRule.StandardDown ? 15 : _context26.t0 === 'standard_down' ? 15 : _context26.t0 === RoundingRule.AlwaysUp ? 17 : _context26.t0 === 'always_up' ? 17 : _context26.t0 === RoundingRule.AlwaysDown ? 19 : _context26.t0 === 'always_down' ? 19 : 21;
1983
+ _context26.next = _context26.t0 === RoundingRule.Standard ? 13 : _context26.t0 === 'standard' ? 13 : _context26.t0 === RoundingRule.StandardDown ? 15 : _context26.t0 === 'standard_rounding_midpoint_down' ? 15 : _context26.t0 === RoundingRule.AlwaysUp ? 17 : _context26.t0 === 'always_up' ? 17 : _context26.t0 === RoundingRule.AlwaysDown ? 19 : _context26.t0 === 'always_down' ? 19 : 21;
2013
1984
  break;
2014
1985
  case 13:
2015
1986
  // 标准舍入(中点向上)
@@ -40,11 +40,11 @@ export declare enum RoundingRule {
40
40
  /** 标准舍入(中点向上) */
41
41
  Standard = "standard_rounding",
42
42
  /** 标准舍入(中点向下) */
43
- StandardDown = "standard_down",
43
+ StandardDown = "standard_rounding_midpoint_down",
44
44
  /** 总是向上舍入 */
45
- AlwaysUp = "always_up",
45
+ AlwaysUp = "round_up",
46
46
  /** 总是向下舍入 */
47
- AlwaysDown = "always_down"
47
+ AlwaysDown = "round_down"
48
48
  }
49
49
  /**
50
50
  * 舍入结果
@@ -87,30 +87,12 @@ export interface PaymentMethod {
87
87
  /** 其他配置信息 */
88
88
  [key: string]: any;
89
89
  }
90
- /** 支付项扩展元数据 */
91
- export interface PaymentItemMetadata {
92
- /** 钱箱 ID */
93
- shop_wallet_pass_id?: string;
94
- /** 三方支付交易流水号 */
95
- unique_payment_number?: string;
96
- /** 刷卡机设备快照;PaymentModule 不解析内部字段 */
97
- card_reader_snapshot?: Record<string, unknown>;
98
- /** rounding 规则 */
99
- rounding_rule?: any;
100
- /** 实付金额(现金支付时的实际给出金额) */
101
- actual_paid_amount?: number;
102
- /** 找零金额(现金支付时的找零金额) */
103
- change_given_amount?: number;
104
- [key: string]: unknown;
105
- }
106
90
  /**
107
91
  * 支付项
108
92
  */
109
93
  export interface PaymentItem {
110
94
  /** 当前支付项的唯一 ID */
111
95
  uuid: string;
112
- /** 支付项稳定唯一号 */
113
- payment_number?: string;
114
96
  /** 当前支付方式付出去多少钱 */
115
97
  amount: string;
116
98
  /** 支付类型,跟支付列表上对应的支付方式保持一致 */
@@ -128,7 +110,18 @@ export interface PaymentItem {
128
110
  /** Wallet Pass 本次使用值 */
129
111
  wallet_pass_use_value?: string | number | null;
130
112
  /** 拓展参数字段 */
131
- metadata?: PaymentItemMetadata;
113
+ metadata?: {
114
+ /** 钱箱 ID */
115
+ shop_wallet_pass_id?: string;
116
+ /** 唯一支付号 */
117
+ unique_payment_number?: string;
118
+ /** rouding规则 */
119
+ rounding_rule?: any;
120
+ /** 实付金额(现金支付时的实际给出金额) */
121
+ actual_paid_amount?: number;
122
+ /** 找零金额(现金支付时的找零金额) */
123
+ change_given_amount?: number;
124
+ };
132
125
  /** rouding金额 */
133
126
  rounding_amount?: string;
134
127
  /** 三方支付手续费 */
@@ -235,10 +228,6 @@ export interface UpdateOrderParams {
235
228
  * 支付项输入类型(允许 amount 为数字)
236
229
  */
237
230
  export interface PaymentItemInput {
238
- /** 调用方已有的支付项运行态 UUID;存在时复用为 payment_number 的唯一号段 */
239
- uuid?: string;
240
- /** 支付项稳定唯一号 */
241
- payment_number?: string;
242
231
  /** 当前支付方式付出去多少钱 */
243
232
  amount: string | number;
244
233
  /** 支付类型,跟支付列表上对应的支付方式保持一致 */
@@ -267,7 +256,18 @@ export interface PaymentItemInput {
267
256
  /** 订单支付类型 */
268
257
  order_payment_type?: 'normal' | 'deposit';
269
258
  /** 扩展参数字段 */
270
- metadata?: PaymentItemMetadata;
259
+ metadata?: {
260
+ /** 钱箱 ID */
261
+ shop_wallet_pass_id?: string;
262
+ /** 唯一支付号 */
263
+ unique_payment_number?: string;
264
+ /** rounding规则 */
265
+ rounding_rule?: any;
266
+ /** 实付金额(现金支付时的实际给出金额) */
267
+ actual_paid_amount?: number;
268
+ /** 找零金额(现金支付时的找零金额) */
269
+ change_given_amount?: number;
270
+ };
271
271
  /** 支付项创建时间 (格式: YYYY-MM-DD HH:mm:ss, 可选,不传则自动生成) */
272
272
  created_at?: string;
273
273
  /** 支付项更新时间 (格式: YYYY-MM-DD HH:mm:ss, 可选,不传则自动生成) */
@@ -302,8 +302,6 @@ export interface PaymentUpdateFields {
302
302
  voucher_id?: string;
303
303
  /** 该支付项是否已经同步给后端服务器(只有网络请求成功后才为true) */
304
304
  isSynced?: boolean;
305
- /** 支付项扩展元数据;更新时与原 metadata 浅合并 */
306
- metadata?: PaymentItemMetadata;
307
305
  /** 同步错误信息(业务错误时记录错误信息,用于区分"未同步"和"同步失败") */
308
306
  syncError?: {
309
307
  error: string;
@@ -40,9 +40,9 @@ export var TaskRunStatus = /*#__PURE__*/function (TaskRunStatus) {
40
40
  */
41
41
  export var RoundingRule = /*#__PURE__*/function (RoundingRule) {
42
42
  RoundingRule["Standard"] = "standard_rounding";
43
- RoundingRule["StandardDown"] = "standard_down";
44
- RoundingRule["AlwaysUp"] = "always_up";
45
- RoundingRule["AlwaysDown"] = "always_down";
43
+ RoundingRule["StandardDown"] = "standard_rounding_midpoint_down";
44
+ RoundingRule["AlwaysUp"] = "round_up";
45
+ RoundingRule["AlwaysDown"] = "round_down";
46
46
  return RoundingRule;
47
47
  }({});
48
48
 
@@ -65,8 +65,6 @@ export var RoundingInterval = /*#__PURE__*/function (RoundingInterval) {
65
65
  * 支付方式信息
66
66
  */
67
67
 
68
- /** 支付项扩展元数据 */
69
-
70
68
  /**
71
69
  * 支付项
72
70
  */