@pisell/pisellos 2.2.228 → 2.2.230

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.
@@ -372,6 +372,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
372
372
  enhancePayload?: SubmitPayloadEnhancer;
373
373
  }): Promise<T>;
374
374
  private markLocalOrderSynced;
375
+ private applyRemoteOrderNumbersToTempOrder;
375
376
  private isSubmitResponseRejected;
376
377
  private isLocalPendingSubmitResult;
377
378
  private isSubmitErrorResponse;
@@ -3115,7 +3115,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3115
3115
  return _regeneratorRuntime().wrap(function _callee16$(_context18) {
3116
3116
  while (1) switch (_context18.prev = _context18.next) {
3117
3117
  case 0:
3118
- tempOrder = this.ensureTempOrder(); // TODO note 改对象
3118
+ tempOrder = this.ensureTempOrder();
3119
3119
  if (!booking) {
3120
3120
  _context18.next = 18;
3121
3121
  break;
@@ -3740,7 +3740,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3740
3740
  var enhancedPayload = params !== null && params !== void 0 && params.enhancePayload ? params.enhancePayload(nextPayload, ctx) : nextPayload;
3741
3741
  return enhancedPayload;
3742
3742
  } : undefined;
3743
- debugger;
3744
3743
  payload = buildSubmitPayload({
3745
3744
  tempOrder: tempOrder,
3746
3745
  cacheId: effectiveCacheId,
@@ -3754,10 +3753,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3754
3753
  if (!payload.created_at) {
3755
3754
  payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
3756
3755
  }
3757
- _context26.next = 21;
3756
+ _context26.next = 20;
3758
3757
  return this.saveDraft();
3759
- case 21:
3760
- _context26.prev = 21;
3758
+ case 20:
3759
+ _context26.prev = 20;
3761
3760
  this.logInfo('submitTempOrder calling sales checkout', {
3762
3761
  orderId: payload.order_id,
3763
3762
  externalSaleNumber: payload.external_sale_number,
@@ -3766,26 +3765,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3766
3765
  paymentsCount: ((_payload$payments = payload.payments) === null || _payload$payments === void 0 ? void 0 : _payload$payments.length) || 0,
3767
3766
  smallTicketDataFlag: payload.small_ticket_data_flag
3768
3767
  });
3769
- _context26.next = 25;
3768
+ _context26.next = 24;
3770
3769
  return this.submitSalesOrder({
3771
3770
  query: payload
3772
3771
  });
3773
- case 25:
3772
+ case 24:
3774
3773
  result = _context26.sent;
3775
- _context26.next = 38;
3774
+ _context26.next = 37;
3776
3775
  break;
3777
- case 28:
3778
- _context26.prev = 28;
3779
- _context26.t2 = _context26["catch"](21);
3776
+ case 27:
3777
+ _context26.prev = 27;
3778
+ _context26.t2 = _context26["catch"](20);
3780
3779
  backendErrorResponse = this.extractSubmitErrorResponse(_context26.t2);
3781
3780
  if (!backendErrorResponse) {
3782
- _context26.next = 35;
3781
+ _context26.next = 34;
3783
3782
  break;
3784
3783
  }
3785
3784
  this.store.syncState = 'failed';
3786
3785
  this.logSubmitBackendRejected(backendErrorResponse, payload);
3787
3786
  return _context26.abrupt("return", backendErrorResponse);
3788
- case 35:
3787
+ case 34:
3789
3788
  this.store.syncState = 'failed';
3790
3789
  this.logError('submitTempOrder failed', {
3791
3790
  error: _context26.t2 instanceof Error ? _context26.t2.message : String(_context26.t2),
@@ -3795,40 +3794,40 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3795
3794
  paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
3796
3795
  });
3797
3796
  throw _context26.t2;
3798
- case 38:
3797
+ case 37:
3799
3798
  if (!this.isSubmitResponseRejected(result)) {
3800
- _context26.next = 42;
3799
+ _context26.next = 41;
3801
3800
  break;
3802
3801
  }
3803
3802
  this.store.syncState = 'failed';
3804
3803
  this.logSubmitBackendRejected(result, payload);
3805
3804
  return _context26.abrupt("return", result);
3806
- case 42:
3805
+ case 41:
3807
3806
  submittedOrderId = this.extractOrderIdFromSubmitResult(result);
3808
3807
  if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
3809
- _context26.next = 50;
3808
+ _context26.next = 49;
3810
3809
  break;
3811
3810
  }
3812
3811
  tempOrder.order_id = submittedOrderId;
3813
3812
  resultRecord = result;
3814
- _context26.next = 48;
3813
+ _context26.next = 47;
3815
3814
  return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
3816
- case 48:
3817
- _context26.next = 51;
3815
+ case 47:
3816
+ _context26.next = 50;
3818
3817
  break;
3819
- case 50:
3818
+ case 49:
3820
3819
  if (this.isLocalPendingSubmitResult(result)) {
3821
3820
  this.store.syncState = 'local';
3822
3821
  } else {
3823
3822
  this.store.syncState = 'submitted';
3824
3823
  }
3825
- case 51:
3824
+ case 50:
3826
3825
  return _context26.abrupt("return", result);
3827
- case 52:
3826
+ case 51:
3828
3827
  case "end":
3829
3828
  return _context26.stop();
3830
3829
  }
3831
- }, _callee24, this, [[21, 28]]);
3830
+ }, _callee24, this, [[20, 27]]);
3832
3831
  }));
3833
3832
  function submitTempOrder(_x26) {
3834
3833
  return _submitTempOrder.apply(this, arguments);
@@ -3845,12 +3844,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3845
3844
  case 0:
3846
3845
  tempOrder = this.ensureTempOrder();
3847
3846
  tempOrder.order_id = orderId;
3847
+ this.applyRemoteOrderNumbersToTempOrder(tempOrder, remoteOrder);
3848
3848
  this.store.lastOrderInfo = remoteOrder;
3849
3849
  this.store.syncState = 'submitted';
3850
3850
  this.persistTempOrder();
3851
- _context27.next = 7;
3851
+ _context27.next = 8;
3852
3852
  return this.saveDraft();
3853
- case 7:
3853
+ case 8:
3854
3854
  case "end":
3855
3855
  return _context27.stop();
3856
3856
  }
@@ -3861,6 +3861,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3861
3861
  }
3862
3862
  return markLocalOrderSynced;
3863
3863
  }()
3864
+ }, {
3865
+ key: "applyRemoteOrderNumbersToTempOrder",
3866
+ value: function applyRemoteOrderNumbersToTempOrder(tempOrder, remoteOrder) {
3867
+ var applyOrderNumber = function applyOrderNumber(key) {
3868
+ var value = remoteOrder === null || remoteOrder === void 0 ? void 0 : remoteOrder[key];
3869
+ if (value !== undefined && value !== null && value !== '') {
3870
+ tempOrder[key] = String(value);
3871
+ }
3872
+ };
3873
+ applyOrderNumber('order_number');
3874
+ applyOrderNumber('shop_order_number');
3875
+ applyOrderNumber('shop_full_order_number');
3876
+ }
3864
3877
  }, {
3865
3878
  key: "isSubmitResponseRejected",
3866
3879
  value: function isSubmitResponseRejected(response) {
@@ -3785,7 +3785,7 @@ var Server = /*#__PURE__*/function () {
3785
3785
  key: "normalizeCheckoutSubmitData",
3786
3786
  value: function () {
3787
3787
  var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(data, title) {
3788
- var next, externalSaleNumber, shouldClearLocalOrderId, localOrder;
3788
+ var next, externalSaleNumber, shouldClearLocalOrderId, hasCheckoutOrderNumbers, localOrder;
3789
3789
  return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3790
3790
  while (1) switch (_context40.prev = _context40.next) {
3791
3791
  case 0:
@@ -3799,8 +3799,22 @@ var Server = /*#__PURE__*/function () {
3799
3799
  externalSaleNumber = next.external_sale_number;
3800
3800
  shouldClearLocalOrderId = this.isLocalCheckoutOrderId(next.order_id);
3801
3801
  if (shouldClearLocalOrderId) next.order_id = null;
3802
+ hasCheckoutOrderNumbers = !this.isBlankCheckoutValue(next.shop_order_number) && !this.isBlankCheckoutValue(next.shop_full_order_number);
3803
+ if (!hasCheckoutOrderNumbers) {
3804
+ _context40.next = 10;
3805
+ break;
3806
+ }
3807
+ this.logInfo("".concat(title, ": checkout \u5DF2\u643A\u5E26\u8BA2\u5355\u53F7\uFF0C\u8DF3\u8FC7\u67E5\u91CD"), {
3808
+ original_order_id: data.order_id,
3809
+ order_id: next.order_id,
3810
+ external_sale_number: externalSaleNumber,
3811
+ shop_order_number: next.shop_order_number,
3812
+ shop_full_order_number: next.shop_full_order_number
3813
+ });
3814
+ return _context40.abrupt("return", next);
3815
+ case 10:
3802
3816
  if (!this.isBlankCheckoutValue(externalSaleNumber)) {
3803
- _context40.next = 9;
3817
+ _context40.next = 13;
3804
3818
  break;
3805
3819
  }
3806
3820
  if (shouldClearLocalOrderId) {
@@ -3810,9 +3824,9 @@ var Server = /*#__PURE__*/function () {
3810
3824
  });
3811
3825
  }
3812
3826
  return _context40.abrupt("return", next);
3813
- case 9:
3814
- if (!(!this.order || typeof this.order.getLocalOrderByLookup !== 'function')) {
3815
- _context40.next = 12;
3827
+ case 13:
3828
+ if (!(!this.order || typeof this.order.getLocalOrderFromMemoryByLookup !== 'function')) {
3829
+ _context40.next = 16;
3816
3830
  break;
3817
3831
  }
3818
3832
  if (shouldClearLocalOrderId) {
@@ -3822,14 +3836,11 @@ var Server = /*#__PURE__*/function () {
3822
3836
  });
3823
3837
  }
3824
3838
  return _context40.abrupt("return", next);
3825
- case 12:
3826
- _context40.prev = 12;
3827
- _context40.next = 15;
3828
- return this.order.getLocalOrderByLookup(externalSaleNumber);
3829
- case 15:
3830
- localOrder = _context40.sent;
3839
+ case 16:
3840
+ _context40.prev = 16;
3841
+ localOrder = this.order.getLocalOrderFromMemoryByLookup(externalSaleNumber);
3831
3842
  if (localOrder) {
3832
- _context40.next = 19;
3843
+ _context40.next = 21;
3833
3844
  break;
3834
3845
  }
3835
3846
  if (shouldClearLocalOrderId) {
@@ -3840,7 +3851,7 @@ var Server = /*#__PURE__*/function () {
3840
3851
  });
3841
3852
  }
3842
3853
  return _context40.abrupt("return", next);
3843
- case 19:
3854
+ case 21:
3844
3855
  if (this.isBlankCheckoutValue(next.shop_order_number)) {
3845
3856
  next.shop_order_number = localOrder.shop_order_number;
3846
3857
  }
@@ -3856,20 +3867,20 @@ var Server = /*#__PURE__*/function () {
3856
3867
  shop_full_order_number: next.shop_full_order_number
3857
3868
  });
3858
3869
  return _context40.abrupt("return", next);
3859
- case 25:
3860
- _context40.prev = 25;
3861
- _context40.t0 = _context40["catch"](12);
3870
+ case 27:
3871
+ _context40.prev = 27;
3872
+ _context40.t0 = _context40["catch"](16);
3862
3873
  this.logWarning("".concat(title, ": checkout \u67E5\u627E\u672C\u5730\u8BA2\u5355\u5931\u8D25"), {
3863
3874
  external_sale_number: externalSaleNumber,
3864
3875
  error: this.getUnknownErrorMessage(_context40.t0),
3865
3876
  error_detail: this.normalizeUnknownError(_context40.t0)
3866
3877
  });
3867
3878
  return _context40.abrupt("return", next);
3868
- case 29:
3879
+ case 31:
3869
3880
  case "end":
3870
3881
  return _context40.stop();
3871
3882
  }
3872
- }, _callee40, this, [[12, 25]]);
3883
+ }, _callee40, this, [[16, 27]]);
3873
3884
  }));
3874
3885
  function normalizeCheckoutSubmitData(_x42, _x43) {
3875
3886
  return _normalizeCheckoutSubmitData.apply(this, arguments);
@@ -79,6 +79,7 @@ export declare class OrderModule extends BaseModule implements Module {
79
79
  getOrderById(id: OrderId): OrderData | undefined;
80
80
  /** 按 order_id 查询内存订单。 */
81
81
  getOrderByOrderId(orderId: OrderId): OrderData | undefined;
82
+ getLocalOrderFromMemoryByLookup(lookup: OrderId): OrderData | null;
82
83
  getLocalOrderByLookup(lookup: OrderId): Promise<OrderData | null>;
83
84
  loadOrdersByServer(): Promise<OrderData[]>;
84
85
  /**
@@ -561,11 +561,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
561
561
  value: function getOrderByOrderId(orderId) {
562
562
  return this.store.map.get(this.getIdKey(orderId));
563
563
  }
564
+ }, {
565
+ key: "getLocalOrderFromMemoryByLookup",
566
+ value: function getLocalOrderFromMemoryByLookup(lookup) {
567
+ var _this5 = this;
568
+ var key = this.getIdKey(lookup);
569
+ var memoryOrderById = this.store.map.get(key);
570
+ if (memoryOrderById) return memoryOrderById;
571
+ var memoryOrder = this.store.list.find(function (order) {
572
+ return _this5.isOrderLookupMatch(order, key);
573
+ });
574
+ return memoryOrder || null;
575
+ }
564
576
  }, {
565
577
  key: "getLocalOrderByLookup",
566
578
  value: function () {
567
579
  var _getLocalOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(lookup) {
568
- var _this5 = this;
580
+ var _this6 = this;
569
581
  var key, memoryOrderById, memoryOrder, orders, localOrder;
570
582
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
571
583
  while (1) switch (_context5.prev = _context5.next) {
@@ -579,7 +591,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
579
591
  return _context5.abrupt("return", memoryOrderById);
580
592
  case 4:
581
593
  memoryOrder = this.store.list.find(function (order) {
582
- return _this5.isOrderLookupMatch(order, key);
594
+ return _this6.isOrderLookupMatch(order, key);
583
595
  });
584
596
  if (!memoryOrder) {
585
597
  _context5.next = 7;
@@ -592,7 +604,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
592
604
  case 9:
593
605
  orders = _context5.sent;
594
606
  localOrder = orders.find(function (order) {
595
- return _this5.isOrderLookupMatch(order, key);
607
+ return _this6.isOrderLookupMatch(order, key);
596
608
  });
597
609
  if (localOrder) {
598
610
  _context5.next = 13;
@@ -601,7 +613,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
601
613
  return _context5.abrupt("return", null);
602
614
  case 13:
603
615
  this.store.list = orders.map(function (order) {
604
- return _this5.normalizeOrderForMemoryList(order);
616
+ return _this6.normalizeOrderForMemoryList(order);
605
617
  });
606
618
  this.syncOrdersMap();
607
619
  return _context5.abrupt("return", this.normalizeOrderForMemoryList(localOrder));
@@ -621,7 +633,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
621
633
  value: function () {
622
634
  var _loadOrdersByServer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
623
635
  var _this$store,
624
- _this6 = this;
636
+ _this7 = this;
625
637
  var orderList, data, mergedOrders, memoryOrders;
626
638
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
627
639
  while (1) switch (_context6.prev = _context6.next) {
@@ -663,7 +675,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
663
675
  case 19:
664
676
  mergedOrders = _context6.sent;
665
677
  memoryOrders = mergedOrders.map(function (order) {
666
- return _this6.normalizeOrderForMemoryList(order);
678
+ return _this7.normalizeOrderForMemoryList(order);
667
679
  });
668
680
  this.logInfo('loadOrdersByServer-结束', {
669
681
  count: memoryOrders.length
@@ -753,10 +765,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
753
765
  }, {
754
766
  key: "getOrdersByResourceId",
755
767
  value: function getOrdersByResourceId(resourceId) {
756
- var _this7 = this;
768
+ var _this8 = this;
757
769
  var ids = this.resourceIdIndex.get(String(resourceId)) || [];
758
770
  return ids.map(function (id) {
759
- return _this7.store.map.get(id);
771
+ return _this8.store.map.get(id);
760
772
  }).filter(function (order) {
761
773
  return !!order;
762
774
  });
@@ -784,7 +796,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
784
796
  key: "overwriteExistingOrder",
785
797
  value: (function () {
786
798
  var _overwriteExistingOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(fresh) {
787
- var _this8 = this;
799
+ var _this9 = this;
788
800
  var orderId, key;
789
801
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
790
802
  while (1) switch (_context8.prev = _context8.next) {
@@ -818,7 +830,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
818
830
  this.store.list = this.store.list.map(function (order) {
819
831
  var id = order === null || order === void 0 ? void 0 : order.order_id;
820
832
  if (id === undefined || id === null) return order;
821
- return _this8.getIdKey(id) === key ? fresh : order;
833
+ return _this9.getIdKey(id) === key ? fresh : order;
822
834
  });
823
835
  this.syncOrdersMap();
824
836
  _context8.next = 13;
@@ -884,7 +896,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
884
896
  key: "markOrderSyncedByExternalSaleNumber",
885
897
  value: function () {
886
898
  var _markOrderSyncedByExternalSaleNumber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
887
- var _this9 = this,
899
+ var _this10 = this,
888
900
  _existing$external_sa,
889
901
  _nextOrder$order_id;
890
902
  var externalSaleNumber, key, targetIndex, existing, nextOrder, storageKey;
@@ -905,7 +917,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
905
917
  targetIndex = this.store.list.findIndex(function (order) {
906
918
  var value = order === null || order === void 0 ? void 0 : order.external_sale_number;
907
919
  if (value === undefined || value === null || value === '') return false;
908
- return _this9.getIdKey(value) === key;
920
+ return _this10.getIdKey(value) === key;
909
921
  });
910
922
  if (!(targetIndex < 0)) {
911
923
  _context10.next = 9;
@@ -1162,7 +1174,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1162
1174
  }, {
1163
1175
  key: "syncOrdersMap",
1164
1176
  value: function syncOrdersMap() {
1165
- var _this10 = this;
1177
+ var _this11 = this;
1166
1178
  this.store.map.clear();
1167
1179
  this.resourceIdIndex.clear();
1168
1180
  var _iterator7 = _createForOfIteratorHelper(this.store.list),
@@ -1170,22 +1182,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1170
1182
  try {
1171
1183
  var _loop = function _loop() {
1172
1184
  var order = _step7.value;
1173
- var primaryIdentity = _this10.getOrderMapKey(order);
1185
+ var primaryIdentity = _this11.getOrderMapKey(order);
1174
1186
  if (!primaryIdentity) return 1; // continue
1175
- _this10.store.map.set(primaryIdentity, order);
1176
- var resourceIds = _this10.extractResourceIds(order);
1187
+ _this11.store.map.set(primaryIdentity, order);
1188
+ var resourceIds = _this11.extractResourceIds(order);
1177
1189
  var _iterator8 = _createForOfIteratorHelper(resourceIds),
1178
1190
  _step8;
1179
1191
  try {
1180
1192
  for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
1181
1193
  var resourceId = _step8.value;
1182
1194
  var key = String(resourceId);
1183
- var existing = _this10.resourceIdIndex.get(key) || [];
1195
+ var existing = _this11.resourceIdIndex.get(key) || [];
1184
1196
  if (existing.some(function (eid) {
1185
- return _this10.getIdKey(eid) === primaryIdentity;
1197
+ return _this11.getIdKey(eid) === primaryIdentity;
1186
1198
  })) continue;
1187
1199
  existing.push(primaryIdentity);
1188
- _this10.resourceIdIndex.set(key, existing);
1200
+ _this11.resourceIdIndex.set(key, existing);
1189
1201
  }
1190
1202
  } catch (err) {
1191
1203
  _iterator8.e(err);
@@ -1223,7 +1235,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1223
1235
  }, {
1224
1236
  key: "getOrderIdentityEntries",
1225
1237
  value: function getOrderIdentityEntries(order) {
1226
- var _this11 = this;
1238
+ var _this12 = this;
1227
1239
  if (!order) return [];
1228
1240
  var record = order;
1229
1241
  var candidates = [{
@@ -1242,8 +1254,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1242
1254
  var entries = [];
1243
1255
  var _loop2 = function _loop2() {
1244
1256
  var candidate = _candidates[_i];
1245
- if (_this11.isBlankIdentityValue(candidate.value)) return 0; // continue
1246
- var key = _this11.getIdKey(candidate.value);
1257
+ if (_this12.isBlankIdentityValue(candidate.value)) return 0; // continue
1258
+ var key = _this12.getIdKey(candidate.value);
1247
1259
  if (entries.some(function (entry) {
1248
1260
  return entry.field === candidate.field && entry.key === key;
1249
1261
  })) return 0; // continue
@@ -1329,7 +1341,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1329
1341
  }, {
1330
1342
  key: "setupOrderSync",
1331
1343
  value: function setupOrderSync() {
1332
- var _this12 = this;
1344
+ var _this13 = this;
1333
1345
  if (!this.orderDataSource) return;
1334
1346
  this.orderDataSource.run({
1335
1347
  pubsub: {
@@ -1337,22 +1349,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1337
1349
  var _message$id, _message$order_id, _message$type;
1338
1350
  console.log('orderDataSource', res);
1339
1351
  var pubsubReceivedAt = Date.now();
1340
- var message = _this12.normalizeOrderSyncMessage(res);
1352
+ var message = _this13.normalizeOrderSyncMessage(res);
1341
1353
  if (!message) return;
1342
1354
  message._pubsubReceivedAt = pubsubReceivedAt;
1343
- _this12.pendingSyncMessages.push(message);
1344
- var throttleMs = _this12.getOrderSyncThrottleMs();
1345
- var routeInfo = _this12.resolveSyncMessageRoute(message);
1346
- _this12.logInfo('orderSync-收到消息并入队', {
1355
+ _this13.pendingSyncMessages.push(message);
1356
+ var throttleMs = _this13.getOrderSyncThrottleMs();
1357
+ var routeInfo = _this13.resolveSyncMessageRoute(message);
1358
+ _this13.logInfo('orderSync-收到消息并入队', {
1347
1359
  id: (_message$id = message.id) !== null && _message$id !== void 0 ? _message$id : null,
1348
1360
  order_id: (_message$order_id = message.order_id) !== null && _message$order_id !== void 0 ? _message$order_id : null,
1349
1361
  type: (_message$type = message.type) !== null && _message$type !== void 0 ? _message$type : null,
1350
- pendingCount: _this12.pendingSyncMessages.length,
1362
+ pendingCount: _this13.pendingSyncMessages.length,
1351
1363
  throttleMs: throttleMs,
1352
1364
  pubsubReceivedAt: new Date(pubsubReceivedAt).toISOString(),
1353
1365
  fullMessage: JSON.stringify(message)
1354
1366
  });
1355
- _this12.scheduleOrderSyncThrottle();
1367
+ _this13.scheduleOrderSyncThrottle();
1356
1368
  }
1357
1369
  }
1358
1370
  }).catch(function () {
@@ -1369,7 +1381,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1369
1381
  }, {
1370
1382
  key: "scheduleOrderSyncThrottle",
1371
1383
  value: function scheduleOrderSyncThrottle() {
1372
- var _this13 = this;
1384
+ var _this14 = this;
1373
1385
  if (this.isProcessingSyncBatch) return;
1374
1386
  if (this.isIdlePhase) {
1375
1387
  this.isIdlePhase = false;
@@ -1380,8 +1392,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1380
1392
  if (this.syncTimer) return;
1381
1393
  var throttleMs = this.getOrderSyncThrottleMs();
1382
1394
  this.syncTimer = setTimeout(function () {
1383
- _this13.syncTimer = undefined;
1384
- void _this13.flushOrderSyncMessagesByThrottle();
1395
+ _this14.syncTimer = undefined;
1396
+ void _this14.flushOrderSyncMessagesByThrottle();
1385
1397
  }, throttleMs);
1386
1398
  }
1387
1399
 
@@ -1449,7 +1461,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1449
1461
  key: "processOrderSyncMessages",
1450
1462
  value: (function () {
1451
1463
  var _processOrderSyncMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
1452
- var _this14 = this;
1464
+ var _this15 = this;
1453
1465
  var messages, batchProcessStartAt, earliestReceivedAt, upsertOrders, refreshIds, uniqueRefreshIds, upsertList, _this$filterRedundant, toFetch, skipped, freshOrders, batchProcessEndAt;
1454
1466
  return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1455
1467
  while (1) switch (_context14.prev = _context14.next) {
@@ -1476,13 +1488,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1476
1488
  upsertOrders = new Map();
1477
1489
  refreshIds = [];
1478
1490
  messages.forEach(function (msg, msgIndex) {
1479
- var routeInfo = _this14.resolveSyncMessageRoute(msg);
1491
+ var routeInfo = _this15.resolveSyncMessageRoute(msg);
1480
1492
  var hasBatchIds = routeInfo.hasBatchIds;
1481
1493
  var singleId = routeInfo.singleId;
1482
1494
  var hasSingleId = routeInfo.hasSingleId;
1483
- var normalizedBody = _this14.normalizeOrderSyncPayload(msg.body || msg.data);
1495
+ var normalizedBody = _this15.normalizeOrderSyncPayload(msg.body || msg.data);
1484
1496
  if (routeInfo.route === 'bodyUpsert' && normalizedBody) {
1485
- upsertOrders.set(_this14.getIdKey(normalizedBody.order_id), normalizedBody);
1497
+ upsertOrders.set(_this15.getIdKey(normalizedBody.order_id), normalizedBody);
1486
1498
  return;
1487
1499
  }
1488
1500
  if (hasBatchIds) refreshIds.push.apply(refreshIds, _toConsumableArray(routeInfo.batchIds));else if (routeInfo.route === 'httpRefresh.singleId' && singleId !== null) refreshIds.push(singleId);else if (routeInfo.route === 'httpRefresh.relationIds') refreshIds.push.apply(refreshIds, _toConsumableArray(routeInfo.batchIds));
@@ -1797,12 +1809,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1797
1809
  }, {
1798
1810
  key: "isOrderLookupMatch",
1799
1811
  value: function isOrderLookupMatch(order, lookupKey) {
1800
- var _this15 = this;
1812
+ var _this16 = this;
1801
1813
  if (!order || !lookupKey) return false;
1802
1814
  var candidates = [order.order_id, order.external_sale_number, order.order_number, order.shop_order_number, order.shop_full_order_number];
1803
1815
  return candidates.some(function (value) {
1804
1816
  if (value === undefined || value === null || value === '') return false;
1805
- return _this15.getIdKey(value) === lookupKey;
1817
+ return _this16.getIdKey(value) === lookupKey;
1806
1818
  });
1807
1819
  }
1808
1820
 
@@ -1845,10 +1857,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1845
1857
  }, {
1846
1858
  key: "findOrderIndexByIdentity",
1847
1859
  value: function findOrderIndexByIdentity(orders, target) {
1848
- var _this16 = this;
1860
+ var _this17 = this;
1849
1861
  if (this.getOrderIdentityMatchKeys(target).length === 0) return -1;
1850
1862
  return orders.findIndex(function (order) {
1851
- return _this16.doOrdersShareIdentity(order, target);
1863
+ return _this17.doOrdersShareIdentity(order, target);
1852
1864
  });
1853
1865
  }
1854
1866
  }, {
@@ -2137,9 +2149,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2137
2149
  }, {
2138
2150
  key: "mergeRemoteSnapshotWithPendingOrders",
2139
2151
  value: function mergeRemoteSnapshotWithPendingOrders(remoteOrders, existingOrders) {
2140
- var _this17 = this;
2152
+ var _this18 = this;
2141
2153
  var merged = remoteOrders.map(function (order) {
2142
- return _this17.normalizeRemoteSyncedOrder(order);
2154
+ return _this18.normalizeRemoteSyncedOrder(order);
2143
2155
  });
2144
2156
  var _iterator16 = _createForOfIteratorHelper(existingOrders),
2145
2157
  _step16;
@@ -2208,7 +2220,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2208
2220
  key: "patchOrdersInSQLite",
2209
2221
  value: (function () {
2210
2222
  var _patchOrdersInSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(orders, source) {
2211
- var _this18 = this;
2223
+ var _this19 = this;
2212
2224
  var mergeActions,
2213
2225
  ordersSnapshot,
2214
2226
  _this$filterRedundant2,
@@ -2227,7 +2239,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2227
2239
  return _context20.abrupt("return");
2228
2240
  case 3:
2229
2241
  ordersSnapshot = cloneDeep(orders).filter(function (order) {
2230
- return _this18.getOrderStorageKey(order);
2242
+ return _this19.getOrderStorageKey(order);
2231
2243
  });
2232
2244
  if (!(ordersSnapshot.length === 0)) {
2233
2245
  _context20.next = 6;
@@ -2257,34 +2269,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2257
2269
  while (1) switch (_context19.prev = _context19.next) {
2258
2270
  case 0:
2259
2271
  writeMethod = 'none';
2260
- _this18.logInfo('patchOrdersInSQLite-开始', {
2272
+ _this19.logInfo('patchOrdersInSQLite-开始', {
2261
2273
  source: source,
2262
2274
  count: compactedToWrite.length,
2263
2275
  dedupedCount: skipped.length
2264
2276
  });
2265
- if (!(typeof _this18.dbManager.bulkUpdate === 'function')) {
2277
+ if (!(typeof _this19.dbManager.bulkUpdate === 'function')) {
2266
2278
  _context19.next = 8;
2267
2279
  break;
2268
2280
  }
2269
2281
  writeMethod = 'bulkUpdate';
2270
2282
  _context19.next = 6;
2271
- return _this18.dbManager.bulkUpdate(INDEXDB_STORE_NAME, compactedToWrite);
2283
+ return _this19.dbManager.bulkUpdate(INDEXDB_STORE_NAME, compactedToWrite);
2272
2284
  case 6:
2273
2285
  _context19.next = 33;
2274
2286
  break;
2275
2287
  case 8:
2276
- if (!(typeof _this18.dbManager.bulkAdd === 'function')) {
2288
+ if (!(typeof _this19.dbManager.bulkAdd === 'function')) {
2277
2289
  _context19.next = 14;
2278
2290
  break;
2279
2291
  }
2280
2292
  writeMethod = 'bulkAdd';
2281
2293
  _context19.next = 12;
2282
- return _this18.dbManager.bulkAdd(INDEXDB_STORE_NAME, compactedToWrite);
2294
+ return _this19.dbManager.bulkAdd(INDEXDB_STORE_NAME, compactedToWrite);
2283
2295
  case 12:
2284
2296
  _context19.next = 33;
2285
2297
  break;
2286
2298
  case 14:
2287
- if (!(typeof _this18.dbManager.update === 'function')) {
2299
+ if (!(typeof _this19.dbManager.update === 'function')) {
2288
2300
  _context19.next = 33;
2289
2301
  break;
2290
2302
  }
@@ -2299,7 +2311,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2299
2311
  }
2300
2312
  order = _step17.value;
2301
2313
  _context19.next = 23;
2302
- return _this18.dbManager.update(INDEXDB_STORE_NAME, order);
2314
+ return _this19.dbManager.update(INDEXDB_STORE_NAME, order);
2303
2315
  case 23:
2304
2316
  _context19.next = 19;
2305
2317
  break;
@@ -2315,8 +2327,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2315
2327
  _iterator17.f();
2316
2328
  return _context19.finish(30);
2317
2329
  case 33:
2318
- _this18.recordRecentSqliteWrite(source, compactedToWrite);
2319
- _this18.logInfo('patchOrdersInSQLite-完成', {
2330
+ _this19.recordRecentSqliteWrite(source, compactedToWrite);
2331
+ _this19.logInfo('patchOrdersInSQLite-完成', {
2320
2332
  source: source,
2321
2333
  count: compactedToWrite.length,
2322
2334
  writeMethod: writeMethod,
@@ -2360,7 +2372,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2360
2372
  key: "updateOrderInSQLite",
2361
2373
  value: (function () {
2362
2374
  var _updateOrderInSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(order, source) {
2363
- var _this19 = this;
2375
+ var _this20 = this;
2364
2376
  var orderSnapshot, _orderSnapshot$order_3;
2365
2377
  return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2366
2378
  while (1) switch (_context22.prev = _context22.next) {
@@ -2381,43 +2393,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2381
2393
  while (1) switch (_context21.prev = _context21.next) {
2382
2394
  case 0:
2383
2395
  writeMethod = 'none';
2384
- _this19.logInfo('updateOrderInSQLite-开始', {
2396
+ _this20.logInfo('updateOrderInSQLite-开始', {
2385
2397
  source: source,
2386
2398
  orderId: (_orderSnapshot$order_ = orderSnapshot.order_id) !== null && _orderSnapshot$order_ !== void 0 ? _orderSnapshot$order_ : null,
2387
- storageKey: _this19.getOrderStorageKey(orderSnapshot)
2399
+ storageKey: _this20.getOrderStorageKey(orderSnapshot)
2388
2400
  });
2389
- if (!(typeof _this19.dbManager.update === 'function')) {
2401
+ if (!(typeof _this20.dbManager.update === 'function')) {
2390
2402
  _context21.next = 8;
2391
2403
  break;
2392
2404
  }
2393
2405
  writeMethod = 'update';
2394
2406
  _context21.next = 6;
2395
- return _this19.dbManager.update(INDEXDB_STORE_NAME, orderSnapshot);
2407
+ return _this20.dbManager.update(INDEXDB_STORE_NAME, orderSnapshot);
2396
2408
  case 6:
2397
2409
  _context21.next = 18;
2398
2410
  break;
2399
2411
  case 8:
2400
- if (!(typeof _this19.dbManager.bulkUpdate === 'function')) {
2412
+ if (!(typeof _this20.dbManager.bulkUpdate === 'function')) {
2401
2413
  _context21.next = 14;
2402
2414
  break;
2403
2415
  }
2404
2416
  writeMethod = 'bulkUpdate';
2405
2417
  _context21.next = 12;
2406
- return _this19.dbManager.bulkUpdate(INDEXDB_STORE_NAME, [orderSnapshot]);
2418
+ return _this20.dbManager.bulkUpdate(INDEXDB_STORE_NAME, [orderSnapshot]);
2407
2419
  case 12:
2408
2420
  _context21.next = 18;
2409
2421
  break;
2410
2422
  case 14:
2411
- if (!(typeof _this19.dbManager.bulkAdd === 'function')) {
2423
+ if (!(typeof _this20.dbManager.bulkAdd === 'function')) {
2412
2424
  _context21.next = 18;
2413
2425
  break;
2414
2426
  }
2415
2427
  writeMethod = 'bulkAdd';
2416
2428
  _context21.next = 18;
2417
- return _this19.dbManager.bulkAdd(INDEXDB_STORE_NAME, [orderSnapshot]);
2429
+ return _this20.dbManager.bulkAdd(INDEXDB_STORE_NAME, [orderSnapshot]);
2418
2430
  case 18:
2419
- _this19.recordRecentSqliteWrite(source, [orderSnapshot]);
2420
- _this19.logInfo('updateOrderInSQLite-完成', {
2431
+ _this20.recordRecentSqliteWrite(source, [orderSnapshot]);
2432
+ _this20.logInfo('updateOrderInSQLite-完成', {
2421
2433
  source: source,
2422
2434
  orderId: (_orderSnapshot$order_2 = orderSnapshot.order_id) !== null && _orderSnapshot$order_2 !== void 0 ? _orderSnapshot$order_2 : null,
2423
2435
  writeMethod: writeMethod
@@ -2460,7 +2472,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2460
2472
  key: "replaceOrdersSnapshotInSQLite",
2461
2473
  value: (function () {
2462
2474
  var _replaceOrdersSnapshotInSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(orderList, source) {
2463
- var _this20 = this;
2475
+ var _this21 = this;
2464
2476
  var remoteSnapshot, mergedSnapshot;
2465
2477
  return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2466
2478
  while (1) switch (_context24.prev = _context24.next) {
@@ -2470,12 +2482,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2470
2482
  break;
2471
2483
  }
2472
2484
  return _context24.abrupt("return", this.compactOrderListByIdentity(orderList.map(function (order) {
2473
- return _this20.normalizeRemoteSyncedOrder(order);
2485
+ return _this21.normalizeRemoteSyncedOrder(order);
2474
2486
  }), "".concat(source, ".snapshotNoDb")).list);
2475
2487
  case 2:
2476
2488
  remoteSnapshot = cloneDeep(orderList);
2477
2489
  mergedSnapshot = this.compactOrderListByIdentity(remoteSnapshot.map(function (order) {
2478
- return _this20.normalizeRemoteSyncedOrder(order);
2490
+ return _this21.normalizeRemoteSyncedOrder(order);
2479
2491
  }), "".concat(source, ".remoteSnapshot")).list;
2480
2492
  _context24.prev = 4;
2481
2493
  _context24.next = 7;
@@ -2484,12 +2496,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2484
2496
  return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2485
2497
  while (1) switch (_context23.prev = _context23.next) {
2486
2498
  case 0:
2487
- if (!(typeof _this20.dbManager.getAll === 'function')) {
2499
+ if (!(typeof _this21.dbManager.getAll === 'function')) {
2488
2500
  _context23.next = 6;
2489
2501
  break;
2490
2502
  }
2491
2503
  _context23.next = 3;
2492
- return _this20.dbManager.getAll(INDEXDB_STORE_NAME);
2504
+ return _this21.dbManager.getAll(INDEXDB_STORE_NAME);
2493
2505
  case 3:
2494
2506
  _context23.t0 = _context23.sent;
2495
2507
  _context23.next = 7;
@@ -2498,18 +2510,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2498
2510
  _context23.t0 = [];
2499
2511
  case 7:
2500
2512
  existingOrders = _context23.t0;
2501
- orderListSnapshot = _this20.mergeRemoteSnapshotWithPendingOrders(remoteSnapshot, existingOrders || []);
2502
- mergedSnapshot = _this20.compactOrderListByIdentity(orderListSnapshot, "".concat(source, ".sqliteSnapshot")).list;
2503
- _this20.logInfo('replaceOrdersSnapshotInSQLite-开始', {
2513
+ orderListSnapshot = _this21.mergeRemoteSnapshotWithPendingOrders(remoteSnapshot, existingOrders || []);
2514
+ mergedSnapshot = _this21.compactOrderListByIdentity(orderListSnapshot, "".concat(source, ".sqliteSnapshot")).list;
2515
+ _this21.logInfo('replaceOrdersSnapshotInSQLite-开始', {
2504
2516
  source: source,
2505
2517
  count: mergedSnapshot.length,
2506
2518
  remoteCount: remoteSnapshot.length,
2507
2519
  preservedPendingCount: mergedSnapshot.length - remoteSnapshot.length
2508
2520
  });
2509
2521
  _context23.next = 13;
2510
- return _this20.dbManager.clear(INDEXDB_STORE_NAME);
2522
+ return _this21.dbManager.clear(INDEXDB_STORE_NAME);
2511
2523
  case 13:
2512
- _this20.logInfo('replaceOrdersSnapshotInSQLite-clear完成', {
2524
+ _this21.logInfo('replaceOrdersSnapshotInSQLite-clear完成', {
2513
2525
  count: mergedSnapshot.length
2514
2526
  });
2515
2527
  if (!(mergedSnapshot.length === 0)) {
@@ -2519,10 +2531,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2519
2531
  return _context23.abrupt("return");
2520
2532
  case 16:
2521
2533
  _context23.next = 18;
2522
- return _this20.dbManager.bulkAdd(INDEXDB_STORE_NAME, mergedSnapshot);
2534
+ return _this21.dbManager.bulkAdd(INDEXDB_STORE_NAME, mergedSnapshot);
2523
2535
  case 18:
2524
- _this20.recordRecentSqliteWrite(source, mergedSnapshot);
2525
- _this20.logInfo('replaceOrdersSnapshotInSQLite-bulkAdd完成', {
2536
+ _this21.recordRecentSqliteWrite(source, mergedSnapshot);
2537
+ _this21.logInfo('replaceOrdersSnapshotInSQLite-bulkAdd完成', {
2526
2538
  source: source,
2527
2539
  count: mergedSnapshot.length
2528
2540
  });
@@ -2566,7 +2578,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2566
2578
  key: "clear",
2567
2579
  value: (function () {
2568
2580
  var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
2569
- var _this21 = this;
2581
+ var _this22 = this;
2570
2582
  return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2571
2583
  while (1) switch (_context26.prev = _context26.next) {
2572
2584
  case 0:
@@ -2583,7 +2595,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2583
2595
  while (1) switch (_context25.prev = _context25.next) {
2584
2596
  case 0:
2585
2597
  _context25.next = 2;
2586
- return _this21.dbManager.clear(INDEXDB_STORE_NAME);
2598
+ return _this22.dbManager.clear(INDEXDB_STORE_NAME);
2587
2599
  case 2:
2588
2600
  case "end":
2589
2601
  return _context25.stop();
@@ -2719,7 +2719,6 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2719
2719
  params = {
2720
2720
  product_id: identity.product_id,
2721
2721
  product_variant_id: identity.product_variant_id,
2722
- // TODO: 改成对象
2723
2722
  updates: {
2724
2723
  note: String(note || '')
2725
2724
  }
@@ -0,0 +1,49 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/model/strategy/adapter/promotion/index.ts
30
+ var promotion_exports = {};
31
+ __export(promotion_exports, {
32
+ BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
33
+ PromotionAdapter: () => import_adapter.PromotionAdapter,
34
+ PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
35
+ X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
36
+ default: () => import_adapter2.default
37
+ });
38
+ module.exports = __toCommonJS(promotion_exports);
39
+ var import_evaluator = require("./evaluator");
40
+ var import_adapter = require("./adapter");
41
+ var import_adapter2 = __toESM(require("./adapter"));
42
+ var import_examples = require("./examples");
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ BUY_X_GET_Y_FREE_STRATEGY,
46
+ PromotionAdapter,
47
+ PromotionEvaluator,
48
+ X_ITEMS_FOR_Y_PRICE_STRATEGY
49
+ });
@@ -372,6 +372,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
372
372
  enhancePayload?: SubmitPayloadEnhancer;
373
373
  }): Promise<T>;
374
374
  private markLocalOrderSynced;
375
+ private applyRemoteOrderNumbersToTempOrder;
375
376
  private isSubmitResponseRejected;
376
377
  private isLocalPendingSubmitResult;
377
378
  private isSubmitErrorResponse;
@@ -2761,7 +2761,6 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2761
2761
  const enhancedPayload = (params == null ? void 0 : params.enhancePayload) ? params.enhancePayload(nextPayload, ctx) : nextPayload;
2762
2762
  return enhancedPayload;
2763
2763
  } : void 0;
2764
- debugger;
2765
2764
  const payload = (0, import_utils.buildSubmitPayload)({
2766
2765
  tempOrder,
2767
2766
  cacheId: effectiveCacheId,
@@ -2829,11 +2828,23 @@ var OrderModule = class extends import_BaseModule.BaseModule {
2829
2828
  async markLocalOrderSynced(orderId, remoteOrder) {
2830
2829
  const tempOrder = this.ensureTempOrder();
2831
2830
  tempOrder.order_id = orderId;
2831
+ this.applyRemoteOrderNumbersToTempOrder(tempOrder, remoteOrder);
2832
2832
  this.store.lastOrderInfo = remoteOrder;
2833
2833
  this.store.syncState = "submitted";
2834
2834
  this.persistTempOrder();
2835
2835
  await this.saveDraft();
2836
2836
  }
2837
+ applyRemoteOrderNumbersToTempOrder(tempOrder, remoteOrder) {
2838
+ const applyOrderNumber = (key) => {
2839
+ const value = remoteOrder == null ? void 0 : remoteOrder[key];
2840
+ if (value !== void 0 && value !== null && value !== "") {
2841
+ tempOrder[key] = String(value);
2842
+ }
2843
+ };
2844
+ applyOrderNumber("order_number");
2845
+ applyOrderNumber("shop_order_number");
2846
+ applyOrderNumber("shop_full_order_number");
2847
+ }
2837
2848
  isSubmitResponseRejected(response) {
2838
2849
  const isErrorCode = (response == null ? void 0 : response.code) !== void 0 && response.code !== 200 && response.code !== "200";
2839
2850
  const isErrorStatus = (response == null ? void 0 : response.status) === false || typeof (response == null ? void 0 : response.status) === "number" && response.status >= 400;
@@ -2373,6 +2373,17 @@ var Server = class {
2373
2373
  const shouldClearLocalOrderId = this.isLocalCheckoutOrderId(next.order_id);
2374
2374
  if (shouldClearLocalOrderId)
2375
2375
  next.order_id = null;
2376
+ const hasCheckoutOrderNumbers = !this.isBlankCheckoutValue(next.shop_order_number) && !this.isBlankCheckoutValue(next.shop_full_order_number);
2377
+ if (hasCheckoutOrderNumbers) {
2378
+ this.logInfo(`${title}: checkout 已携带订单号,跳过查重`, {
2379
+ original_order_id: data.order_id,
2380
+ order_id: next.order_id,
2381
+ external_sale_number: externalSaleNumber,
2382
+ shop_order_number: next.shop_order_number,
2383
+ shop_full_order_number: next.shop_full_order_number
2384
+ });
2385
+ return next;
2386
+ }
2376
2387
  if (this.isBlankCheckoutValue(externalSaleNumber)) {
2377
2388
  if (shouldClearLocalOrderId) {
2378
2389
  this.logInfo(`${title}: checkout 本地订单号已清理`, {
@@ -2382,7 +2393,7 @@ var Server = class {
2382
2393
  }
2383
2394
  return next;
2384
2395
  }
2385
- if (!this.order || typeof this.order.getLocalOrderByLookup !== "function") {
2396
+ if (!this.order || typeof this.order.getLocalOrderFromMemoryByLookup !== "function") {
2386
2397
  if (shouldClearLocalOrderId) {
2387
2398
  this.logInfo(`${title}: checkout 本地订单号已清理`, {
2388
2399
  original_order_id: data.order_id,
@@ -2392,7 +2403,7 @@ var Server = class {
2392
2403
  return next;
2393
2404
  }
2394
2405
  try {
2395
- const localOrder = await this.order.getLocalOrderByLookup(externalSaleNumber);
2406
+ const localOrder = this.order.getLocalOrderFromMemoryByLookup(externalSaleNumber);
2396
2407
  if (!localOrder) {
2397
2408
  if (shouldClearLocalOrderId) {
2398
2409
  this.logInfo(`${title}: checkout 本地订单号已清理`, {
@@ -79,6 +79,7 @@ export declare class OrderModule extends BaseModule implements Module {
79
79
  getOrderById(id: OrderId): OrderData | undefined;
80
80
  /** 按 order_id 查询内存订单。 */
81
81
  getOrderByOrderId(orderId: OrderId): OrderData | undefined;
82
+ getLocalOrderFromMemoryByLookup(lookup: OrderId): OrderData | null;
82
83
  getLocalOrderByLookup(lookup: OrderId): Promise<OrderData | null>;
83
84
  loadOrdersByServer(): Promise<OrderData[]>;
84
85
  /**
@@ -379,6 +379,14 @@ var OrderModule = class extends import_BaseModule.BaseModule {
379
379
  getOrderByOrderId(orderId) {
380
380
  return this.store.map.get(this.getIdKey(orderId));
381
381
  }
382
+ getLocalOrderFromMemoryByLookup(lookup) {
383
+ const key = this.getIdKey(lookup);
384
+ const memoryOrderById = this.store.map.get(key);
385
+ if (memoryOrderById)
386
+ return memoryOrderById;
387
+ const memoryOrder = this.store.list.find((order) => this.isOrderLookupMatch(order, key));
388
+ return memoryOrder || null;
389
+ }
382
390
  async getLocalOrderByLookup(lookup) {
383
391
  const key = this.getIdKey(lookup);
384
392
  const memoryOrderById = this.store.map.get(key);
@@ -1721,7 +1721,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
1721
1721
  const params = {
1722
1722
  product_id: identity.product_id,
1723
1723
  product_variant_id: identity.product_variant_id,
1724
- // TODO: 改成对象
1725
1724
  updates: { note: String(note || "") }
1726
1725
  };
1727
1726
  if (identity.unique_identification_number !== void 0) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.228",
4
+ "version": "2.2.230",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",