@pisell/pisellos 2.3.155 → 2.3.157

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";
@@ -31,6 +31,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
31
31
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
32
32
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
33
33
  import { loadSalesOrderSnapshot } from "../../shared/sales/loadSalesOrderSnapshot";
34
+ import { PAYMENT_REFRESH_MESSAGE, requiresLocalPaymentRefresh, stripLocalEftposState } from "./localEftposState";
34
35
  import { BaseModule } from "../BaseModule";
35
36
  import { OrderHooks } from "./types";
36
37
  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, collectPointCardSnapshotCodeCandidates, mergePointCardSnapshotCodes as _mergePointCardSnapshotCodes, buildVirtualCurrencySnapshotFromList, mergeOrderProductDisplayFields, resolveIsFormSubject, isMarkdownBundle } from "./utils";
@@ -4545,6 +4546,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4545
4546
  identity,
4546
4547
  matchMode,
4547
4548
  matchedPayment,
4549
+ _this$logger,
4550
+ _this$logger$addLog,
4548
4551
  updatedPayment,
4549
4552
  summary,
4550
4553
  payments,
@@ -4558,11 +4561,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4558
4561
  matchMode = options.matchBy === 'compat' || options.matchBy === 'legacy' ? 'compat' : 'payment_number';
4559
4562
  matchedPayment = resolveOrderPaymentIdentity(tempOrder.payments || [], identity, matchMode);
4560
4563
  if (matchedPayment) {
4561
- _context22.next = 7;
4564
+ _context22.next = 8;
4562
4565
  break;
4563
4566
  }
4567
+ try {
4568
+ void Promise.resolve((_this$logger = this.logger) === null || _this$logger === void 0 || (_this$logger$addLog = _this$logger.addLog) === null || _this$logger$addLog === void 0 ? void 0 : _this$logger$addLog.call(_this$logger, {
4569
+ type: 'warning',
4570
+ title: '[PaymentTrace] payment-missing',
4571
+ metadata: {
4572
+ moduleName: this.name,
4573
+ saleId: tempOrder.external_sale_number,
4574
+ paymentNumber: identity,
4575
+ currentPaymentNumbers: (tempOrder.payments || []).map(function (p) {
4576
+ return p.payment_number;
4577
+ })
4578
+ }
4579
+ })).catch(function () {});
4580
+ } catch (_unused4) {/* 日志失败不影响原异常。 */}
4564
4581
  throw new Error("\u672A\u627E\u5230\u652F\u4ED8\u9879: ".concat(identity));
4565
- case 7:
4582
+ case 8:
4566
4583
  updatedPayment = null;
4567
4584
  tempOrder.payments = (tempOrder.payments || []).map(function (payment, index) {
4568
4585
  if (index !== matchedPayment.index) return payment;
@@ -4573,11 +4590,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4573
4590
  return nextPayment;
4574
4591
  });
4575
4592
  this.persistTempOrder();
4576
- _context22.next = 12;
4593
+ _context22.next = 13;
4577
4594
  return this.recalculateSummary({
4578
4595
  createIfMissing: true
4579
4596
  });
4580
- case 12:
4597
+ case 13:
4581
4598
  summary = _context22.sent;
4582
4599
  this.persistTempOrder();
4583
4600
  payments = tempOrder.payments;
@@ -4587,7 +4604,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4587
4604
  payments: payments,
4588
4605
  summary: summary
4589
4606
  });
4590
- case 16:
4607
+ case 17:
4591
4608
  case "end":
4592
4609
  return _context22.stop();
4593
4610
  }
@@ -6808,6 +6825,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6808
6825
  while (1) switch (_context40.prev = _context40.next) {
6809
6826
  case 0:
6810
6827
  tempOrder = this.ensureTempOrder();
6828
+ if (!requiresLocalPaymentRefresh(tempOrder)) {
6829
+ _context40.next = 3;
6830
+ break;
6831
+ }
6832
+ throw new Error(PAYMENT_REFRESH_MESSAGE);
6833
+ case 3:
6811
6834
  this.prepareVirtualSettlementTempOrder(tempOrder);
6812
6835
  isOnlineStorePlatform = this.isOnlineStorePlatform();
6813
6836
  shouldConfirmPendingVoucherPayments = (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== false;
@@ -6829,25 +6852,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6829
6852
  }
6830
6853
  }
6831
6854
  this.persistTempOrder();
6832
- _context40.next = 10;
6855
+ _context40.next = 12;
6833
6856
  return this.recalculateSummary({
6834
6857
  createIfMissing: true
6835
6858
  });
6836
- case 10:
6859
+ case 12:
6837
6860
  _context40.t1 = _context40.sent;
6838
6861
  if (_context40.t1) {
6839
- _context40.next = 13;
6862
+ _context40.next = 15;
6840
6863
  break;
6841
6864
  }
6842
6865
  _context40.t1 = this.store.summary;
6843
- case 13:
6866
+ case 15:
6844
6867
  _context40.t0 = _context40.t1;
6845
6868
  if (_context40.t0) {
6846
- _context40.next = 16;
6869
+ _context40.next = 18;
6847
6870
  break;
6848
6871
  }
6849
6872
  _context40.t0 = createEmptySummary();
6850
- case 16:
6873
+ case 18:
6851
6874
  latestSummary = _context40.t0;
6852
6875
  effectiveCacheId = (_params$cacheId3 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId3 !== void 0 ? _params$cacheId3 : this.cacheId;
6853
6876
  hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
@@ -6884,10 +6907,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6884
6907
  if (!payload.created_at) {
6885
6908
  payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
6886
6909
  }
6887
- _context40.next = 28;
6910
+ _context40.next = 30;
6888
6911
  return this.saveDraft();
6889
- case 28:
6890
- _context40.prev = 28;
6912
+ case 30:
6913
+ _context40.prev = 30;
6891
6914
  this.logInfo('submitTempOrder calling sales checkout', {
6892
6915
  orderId: payload.order_id,
6893
6916
  externalSaleNumber: payload.external_sale_number,
@@ -6897,26 +6920,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6897
6920
  smallTicketDataFlag: payload.small_ticket_data_flag,
6898
6921
  syncMode: payload.sync_mode
6899
6922
  });
6900
- _context40.next = 32;
6923
+ _context40.next = 34;
6901
6924
  return this.submitSalesOrder({
6902
6925
  query: payload
6903
6926
  });
6904
- case 32:
6927
+ case 34:
6905
6928
  result = _context40.sent;
6906
- _context40.next = 45;
6929
+ _context40.next = 47;
6907
6930
  break;
6908
- case 35:
6909
- _context40.prev = 35;
6910
- _context40.t2 = _context40["catch"](28);
6931
+ case 37:
6932
+ _context40.prev = 37;
6933
+ _context40.t2 = _context40["catch"](30);
6911
6934
  backendErrorResponse = this.extractSubmitErrorResponse(_context40.t2);
6912
6935
  if (!backendErrorResponse) {
6913
- _context40.next = 42;
6936
+ _context40.next = 44;
6914
6937
  break;
6915
6938
  }
6916
6939
  this.store.syncState = 'failed';
6917
6940
  this.logSubmitBackendRejected(backendErrorResponse, payload);
6918
6941
  return _context40.abrupt("return", backendErrorResponse);
6919
- case 42:
6942
+ case 44:
6920
6943
  this.store.syncState = 'failed';
6921
6944
  this.logError('submitTempOrder failed', {
6922
6945
  error: _context40.t2 instanceof Error ? _context40.t2.message : String(_context40.t2),
@@ -6926,15 +6949,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6926
6949
  paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
6927
6950
  });
6928
6951
  throw _context40.t2;
6929
- case 45:
6952
+ case 47:
6930
6953
  if (!this.isSubmitResponseRejected(result)) {
6931
- _context40.next = 49;
6954
+ _context40.next = 51;
6932
6955
  break;
6933
6956
  }
6934
6957
  this.store.syncState = 'failed';
6935
6958
  this.logSubmitBackendRejected(result, payload);
6936
6959
  return _context40.abrupt("return", result);
6937
- case 49:
6960
+ case 51:
6938
6961
  isLocalPendingSubmit = this.isLocalPendingSubmitResult(result); // need_sync=1 仅表示已进入本地同步队列,不能视为远端已确认 Notes。
6939
6962
  if (Object.prototype.hasOwnProperty.call(payload, 'notes') && !isLocalPendingSubmit) {
6940
6963
  salesNotesState = this.ensureSalesNotesRuntimeState(tempOrder);
@@ -6949,25 +6972,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6949
6972
  })
6950
6973
  });
6951
6974
  if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
6952
- _context40.next = 58;
6975
+ _context40.next = 60;
6953
6976
  break;
6954
6977
  }
6955
6978
  tempOrder.order_id = submittedOrderId;
6956
6979
  resultRecord = result;
6957
- _context40.next = 58;
6980
+ _context40.next = 60;
6958
6981
  return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
6959
- case 58:
6982
+ case 60:
6960
6983
  if (isLocalPendingSubmit) {
6961
6984
  this.store.syncState = 'local';
6962
6985
  } else if (submittedOrderId === null || submittedOrderId === undefined) {
6963
6986
  this.store.syncState = 'submitted';
6964
6987
  }
6965
6988
  return _context40.abrupt("return", result);
6966
- case 60:
6989
+ case 62:
6967
6990
  case "end":
6968
6991
  return _context40.stop();
6969
6992
  }
6970
- }, _callee37, this, [[28, 35]]);
6993
+ }, _callee37, this, [[30, 37]]);
6971
6994
  }));
6972
6995
  function runSubmitTempOrder(_x43) {
6973
6996
  return _runSubmitTempOrder.apply(this, arguments);
@@ -7512,7 +7535,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7512
7535
  case 0:
7513
7536
  url = params.url, query = params.query;
7514
7537
  fetchUrl = url || '/order/sales/checkout';
7515
- requestQuery = this.isSalesCheckoutHandledByOsServer(fetchUrl) ? query : stripOsPrivatePayloadFields(query);
7538
+ requestQuery = this.isSalesCheckoutHandledByOsServer(fetchUrl) ? query : stripLocalEftposState(stripOsPrivatePayloadFields(query));
7516
7539
  return _context47.abrupt("return", this.request.post(fetchUrl, requestQuery, {
7517
7540
  osServer: true,
7518
7541
  customToast: function customToast() {}
@@ -0,0 +1,13 @@
1
+ /** Local reconciliation state; never part of a cloud checkout payload. */
2
+ export declare const LOCAL_EFTPOS_REFRESH_REQUIRED = "_local_eftpos_refresh_required";
3
+ export declare const LOCAL_EFTPOS_FINALIZED = "_local_eftpos_finalized";
4
+ export declare const PAYMENT_REFRESH_MESSAGE = "\u8BA2\u5355\u9700\u8981\u5237\u65B0\uFF0C\u8BF7\u8054\u7F51\u5237\u65B0\u8BA2\u5355\u540E\u518D\u4ED8\u6B3E";
5
+ export interface LocalEftposFinalization {
6
+ saleId: string | number;
7
+ paymentNumber: string;
8
+ result: 'failed' | 'not_started';
9
+ failedTransactionNumbers: string[];
10
+ }
11
+ export declare function requiresLocalPaymentRefresh(order: any): boolean;
12
+ export declare function isLocalFinalizedPayment(payment: any): boolean;
13
+ export declare function stripLocalEftposState<T extends Record<string, any>>(order: T): T;
@@ -0,0 +1,39 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ /** Local reconciliation state; never part of a cloud checkout payload. */
8
+ export var LOCAL_EFTPOS_REFRESH_REQUIRED = '_local_eftpos_refresh_required';
9
+ export var LOCAL_EFTPOS_FINALIZED = '_local_eftpos_finalized';
10
+ export var PAYMENT_REFRESH_MESSAGE = '订单需要刷新,请联网刷新订单后再付款';
11
+ export function requiresLocalPaymentRefresh(order) {
12
+ var _order$metadata;
13
+ return (order === null || order === void 0 || (_order$metadata = order.metadata) === null || _order$metadata === void 0 ? void 0 : _order$metadata[LOCAL_EFTPOS_REFRESH_REQUIRED]) === true;
14
+ }
15
+ export function isLocalFinalizedPayment(payment) {
16
+ var _payment$metadata;
17
+ return (payment === null || payment === void 0 ? void 0 : payment.status) === 'voided' && (payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata[LOCAL_EFTPOS_FINALIZED]) === true;
18
+ }
19
+ export function stripLocalEftposState(order) {
20
+ var result = _objectSpread({}, order);
21
+ if (order.metadata) {
22
+ result.metadata = _objectSpread({}, order.metadata);
23
+ delete result.metadata[LOCAL_EFTPOS_REFRESH_REQUIRED];
24
+ }
25
+ if (Array.isArray(order.payments)) {
26
+ result.payments = order.payments.filter(function (payment) {
27
+ return !isLocalFinalizedPayment(payment);
28
+ }).map(function (payment) {
29
+ var _payment$metadata2;
30
+ if (!((_payment$metadata2 = payment.metadata) !== null && _payment$metadata2 !== void 0 && _payment$metadata2[LOCAL_EFTPOS_FINALIZED])) return payment;
31
+ var metadata = _objectSpread({}, payment.metadata);
32
+ delete metadata[LOCAL_EFTPOS_FINALIZED];
33
+ return _objectSpread(_objectSpread({}, payment), {}, {
34
+ metadata: metadata
35
+ });
36
+ });
37
+ }
38
+ return result;
39
+ }
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "duration" | "normal" | "session";
52
+ getProductType(): "normal" | "duration" | "session";
53
53
  }
@@ -499,6 +499,7 @@ declare class Server {
499
499
  private buildLocalPaymentSurchargeUpdate;
500
500
  private handleGetLocalPayment;
501
501
  private handleUpdateLocalPayment;
502
+ private handleFinalizeLocalEftposPayment;
502
503
  private runLocalPaymentUpdateInQueue;
503
504
  private processLocalPaymentUpdate;
504
505
  private processSuccessfulLocalPayment;