@pisell/pisellos 2.2.266 → 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 (93) hide show
  1. package/dist/model/strategy/adapter/promotion/adapter.d.ts +0 -4
  2. package/dist/model/strategy/adapter/promotion/adapter.js +0 -23
  3. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
  4. package/dist/model/strategy/adapter/promotion/evaluator.js +6 -279
  5. package/dist/model/strategy/adapter/promotion/examples.d.ts +0 -86
  6. package/dist/model/strategy/adapter/promotion/examples.js +0 -99
  7. package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
  8. package/dist/model/strategy/adapter/promotion/type.d.ts +2 -90
  9. package/dist/model/strategy/adapter/promotion/type.js +0 -45
  10. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -3
  11. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +6 -3
  12. package/dist/modules/Order/index.d.ts +8 -27
  13. package/dist/modules/Order/index.js +493 -753
  14. package/dist/modules/Order/types.d.ts +1 -33
  15. package/dist/modules/Order/utils/orderCollectionIdentity.js +2 -7
  16. package/dist/modules/Order/utils.js +6 -10
  17. package/dist/modules/Payment/index.d.ts +0 -2
  18. package/dist/modules/Payment/index.js +50 -79
  19. package/dist/modules/Payment/types.d.ts +27 -29
  20. package/dist/modules/Payment/types.js +3 -5
  21. package/dist/modules/Rules/index.d.ts +0 -1
  22. package/dist/modules/Rules/index.js +14 -34
  23. package/dist/server/index.d.ts +0 -16
  24. package/dist/server/index.js +1036 -1933
  25. package/dist/server/modules/order/index.d.ts +4 -49
  26. package/dist/server/modules/order/index.js +695 -1574
  27. package/dist/server/modules/order/types.d.ts +3 -11
  28. package/dist/server/modules/order/types.js +1 -1
  29. package/dist/solution/BaseSales/index.d.ts +11 -55
  30. package/dist/solution/BaseSales/index.js +396 -711
  31. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
  32. package/dist/solution/BaseSales/utils/cartPromotion.js +36 -93
  33. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
  34. package/dist/solution/BookingTicket/index.d.ts +1 -1
  35. package/dist/solution/BookingTicket/index.js +29 -35
  36. package/dist/solution/BookingTicket/utils/addProductDecision.js +6 -0
  37. package/dist/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
  38. package/dist/solution/BookingTicket/utils/weighingProductSku.js +45 -0
  39. package/dist/solution/Sales/index.d.ts +0 -1
  40. package/dist/solution/Sales/index.js +2 -10
  41. package/dist/solution/ScanOrder/index.js +20 -31
  42. package/dist/solution/VenueBooking/index.js +19 -30
  43. package/lib/model/strategy/adapter/promotion/adapter.d.ts +0 -4
  44. package/lib/model/strategy/adapter/promotion/adapter.js +0 -20
  45. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
  46. package/lib/model/strategy/adapter/promotion/evaluator.js +0 -235
  47. package/lib/model/strategy/adapter/promotion/examples.d.ts +0 -86
  48. package/lib/model/strategy/adapter/promotion/examples.js +0 -91
  49. package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
  50. package/lib/model/strategy/adapter/promotion/index.js +0 -51
  51. package/lib/model/strategy/adapter/promotion/type.d.ts +2 -90
  52. package/lib/model/strategy/adapter/promotion/type.js +0 -2
  53. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +2 -1
  54. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
  55. package/lib/modules/Order/index.d.ts +8 -27
  56. package/lib/modules/Order/index.js +72 -193
  57. package/lib/modules/Order/types.d.ts +1 -33
  58. package/lib/modules/Order/utils/orderCollectionIdentity.js +0 -3
  59. package/lib/modules/Order/utils.js +4 -11
  60. package/lib/modules/Payment/index.d.ts +0 -2
  61. package/lib/modules/Payment/index.js +13 -34
  62. package/lib/modules/Payment/types.d.ts +27 -29
  63. package/lib/modules/Payment/types.js +3 -3
  64. package/lib/modules/Rules/index.d.ts +0 -1
  65. package/lib/modules/Rules/index.js +4 -23
  66. package/lib/server/index.d.ts +0 -16
  67. package/lib/server/index.js +18 -670
  68. package/lib/server/modules/order/index.d.ts +4 -49
  69. package/lib/server/modules/order/index.js +66 -657
  70. package/lib/server/modules/order/types.d.ts +3 -11
  71. package/lib/solution/BaseSales/index.d.ts +11 -55
  72. package/lib/solution/BaseSales/index.js +35 -235
  73. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
  74. package/lib/solution/BaseSales/utils/cartPromotion.js +17 -65
  75. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
  76. package/lib/solution/BookingTicket/index.d.ts +1 -1
  77. package/lib/solution/BookingTicket/index.js +3 -6
  78. package/lib/solution/BookingTicket/utils/addProductDecision.js +4 -0
  79. package/lib/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
  80. package/lib/solution/BookingTicket/utils/weighingProductSku.js +63 -0
  81. package/lib/solution/Sales/index.d.ts +0 -1
  82. package/lib/solution/Sales/index.js +3 -5
  83. package/lib/solution/ScanOrder/index.js +0 -8
  84. package/lib/solution/VenueBooking/index.js +0 -8
  85. package/package.json +2 -2
  86. package/dist/modules/Order/payment-utils.d.ts +0 -26
  87. package/dist/modules/Order/payment-utils.js +0 -225
  88. package/dist/utils/payment-number.d.ts +0 -9
  89. package/dist/utils/payment-number.js +0 -69
  90. package/lib/modules/Order/payment-utils.d.ts +0 -26
  91. package/lib/modules/Order/payment-utils.js +0 -224
  92. package/lib/utils/payment-number.d.ts +0 -9
  93. package/lib/utils/payment-number.js +0 -64
@@ -37,8 +37,6 @@ import Decimal from 'decimal.js';
37
37
  import { cloneDeep, mergeWith } from 'lodash-es';
38
38
  import { createModule } from "../BookingByStep/types";
39
39
  import { composeLinePrice, createUuidV4, ensureProductSku, getProductSkuOptions, resolveIsFormSubject, sumOptionUnitPrice } from "../../modules/Order/utils";
40
- import { ensureOrderPaymentNumber, isIdentifiedPendingOrderPayment, isPendingOrderPayment, mergeOrderPaymentListsByIdentity, resolveOrderPaymentIdentity } from "../../modules/Order/payment-utils";
41
- import { resolvePaymentNumberDevicePrefix, resolvePaymentNumberDevicePrefixFromDeviceId } from "../../utils/payment-number";
42
40
  import { applyOrderCollectionUidRemaps, getOrderCollectionPersistentId, getOrderCollectionReferenceUid, getOrderCollectionUid, isSameOrderCollectionItem, mergeOrderCollectionItems, normalizeOrderCollection, normalizeOrderCollections, setOrderCollectionUid } from "../../modules/Order/utils/orderCollectionIdentity";
43
41
  import dayjs from 'dayjs';
44
42
  export * from "./types";
@@ -74,10 +72,6 @@ function preserveManualProductDiscountProducts(previousProducts, nextProducts) {
74
72
  function isBaseSalesHistoricalDiscountEntry(discount) {
75
73
  return Boolean((discount === null || discount === void 0 ? void 0 : discount.isEditMode) || (discount === null || discount === void 0 ? void 0 : discount.isDisabled) || (discount === null || discount === void 0 ? void 0 : discount.order_discount_id) != null);
76
74
  }
77
- function getBaseSalesUniqueArrayMetadataKey(key) {
78
- if (key === 'products' || key === 'bookings') return 'unique_identification_number';
79
- return null;
80
- }
81
75
  var BASE_SALES_PERSISTENT_ID_FIELD_BY_KIND = {
82
76
  product: 'order_detail_id',
83
77
  booking: 'schedule_event_id',
@@ -149,15 +143,6 @@ function mergeBaseSalesCollectionItem(kind, currentItem, incomingItem, uidRemaps
149
143
  return kind === 'product' ? mergeBaseSalesProductSnapshotFields(currentItem, mergedItem) : mergedItem;
150
144
  }
151
145
  function mergeBaseSalesOrderCollection(kind, currentValue, incomingValue, strategy, uidRemaps) {
152
- if (kind === 'payment') {
153
- return mergeOrderPaymentListsByIdentity(currentValue, incomingValue, strategy === 'preserve-local' ? {
154
- preserveUnmatchedExisting: true
155
- } : {
156
- preserveUnmatchedExistingWhen: function preserveUnmatchedExistingWhen(payment) {
157
- return isIdentifiedPendingOrderPayment(payment) || !getOrderCollectionPersistentId('payment', payment);
158
- }
159
- });
160
- }
161
146
  var currentItems = normalizeOrderCollection(kind, currentValue, {
162
147
  ensureUid: false
163
148
  }).items;
@@ -204,34 +189,6 @@ function normalizeBaseSalesRecordCollections(sourceRecord, options) {
204
189
  }
205
190
  return normalizedRecord;
206
191
  }
207
- function getBaseSalesMetadataUid(item, metadataKey) {
208
- var _item$metadata$metada, _item$metadata;
209
- var uid = (_item$metadata$metada = item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata[metadataKey]) !== null && _item$metadata$metada !== void 0 ? _item$metadata$metada : item === null || item === void 0 ? void 0 : item[metadataKey];
210
- if (uid === undefined || uid === null || uid === '') return null;
211
- return String(uid);
212
- }
213
- function mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey) {
214
- var result = [];
215
- var indexByUid = new Map();
216
- var appendOrReplaceByUid = function appendOrReplaceByUid(item) {
217
- var clonedItem = cloneDeep(item);
218
- var uid = getBaseSalesMetadataUid(clonedItem, metadataKey);
219
- if (!uid) {
220
- result.push(clonedItem);
221
- return;
222
- }
223
- var existingIndex = indexByUid.get(uid);
224
- if (existingIndex !== undefined) {
225
- result[existingIndex] = clonedItem;
226
- return;
227
- }
228
- indexByUid.set(uid, result.length);
229
- result.push(clonedItem);
230
- };
231
- currentValue.forEach(appendOrReplaceByUid);
232
- loadedValue.forEach(appendOrReplaceByUid);
233
- return result;
234
- }
235
192
  function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, strategy) {
236
193
  var normalizedLoadedRecord = normalizeBaseSalesRecordCollections(loadedRecord || {}, {
237
194
  ensureUid: false
@@ -249,15 +206,6 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, str
249
206
  return mergeBaseSalesOrderCollection(collectionKind, Array.isArray(currentValue) ? currentValue : [], loadedValue, strategy, uidRemaps);
250
207
  }
251
208
  if (Array.isArray(currentValue) && Array.isArray(loadedValue)) {
252
- if (key === 'payments' || key === 'payment') {
253
- return mergeOrderPaymentListsByIdentity(currentValue, loadedValue, {
254
- preserveUnmatchedExisting: true
255
- });
256
- }
257
- var metadataKey = getBaseSalesUniqueArrayMetadataKey(key);
258
- if (metadataKey) {
259
- return mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey);
260
- }
261
209
  return [].concat(_toConsumableArray(cloneDeep(currentValue)), _toConsumableArray(cloneDeep(loadedValue)));
262
210
  }
263
211
  if (Array.isArray(loadedValue)) return cloneDeep(loadedValue);
@@ -269,22 +217,6 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, str
269
217
  delete mergedRecord.request_unique_idempotency_token;
270
218
  return normalizeBaseSalesRecordCollections(applyOrderCollectionUidRemaps(mergedRecord, uidRemaps));
271
219
  }
272
- function filterPendingPaymentsFromLoadedSalesDetail(sourceRecord) {
273
- if (!sourceRecord || _typeof(sourceRecord) !== 'object') return sourceRecord;
274
- var record = _objectSpread({}, sourceRecord);
275
- if (Array.isArray(sourceRecord.payments)) {
276
- record.payments = sourceRecord.payments.filter(function (payment) {
277
- return !isPendingOrderPayment(payment);
278
- });
279
- }
280
- // 兼容少量历史详情数据使用的单数 payment 字段。
281
- if (Array.isArray(sourceRecord.payment)) {
282
- record.payment = sourceRecord.payment.filter(function (payment) {
283
- return !isPendingOrderPayment(payment);
284
- });
285
- }
286
- return record;
287
- }
288
220
  export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
289
221
  _inherits(BaseSalesImpl, _BaseModule);
290
222
  var _super = _createSuper(BaseSalesImpl);
@@ -304,11 +236,6 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
304
236
  });
305
237
  _defineProperty(_assertThisInitialized(_this), "otherParams", {});
306
238
  _defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
307
- /**
308
- * 由已在初始化阶段解析过设备短号的业务解决方案写入。
309
- * 未设置时,支付编号仍按原逻辑实时读取设备信息。
310
- */
311
- _defineProperty(_assertThisInitialized(_this), "paymentNumberDevicePrefix", null);
312
239
  /**
313
240
  * window / request 暴露为 public:现存外部工具(如 BookingTicket Scan)通过
314
241
  * `solution.window` / `solution.request` 直接访问插件,保持原有契约不破坏。
@@ -1153,38 +1080,6 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1153
1080
  var coreData = app === null || app === void 0 || (_app$models = app.models) === null || _app$models === void 0 || (_app$models$getStore = _app$models.getStore) === null || _app$models$getStore === void 0 || (_app$models$getStore$ = (_app$models$getStore$2 = _app$models$getStore.call(_app$models)).getDataByModel) === null || _app$models$getStore$ === void 0 ? void 0 : _app$models$getStore$.call(_app$models$getStore$2, 'core', 'core');
1154
1081
  return coreData === null || coreData === void 0 ? void 0 : coreData[key];
1155
1082
  }
1156
-
1157
- /**
1158
- * 复用业务解决方案初始化时已解析的支付设备短号。
1159
- * 空值会清除缓存,使后续支付恢复实时读取设备信息的兼容路径。
1160
- */
1161
- }, {
1162
- key: "setPaymentNumberDevicePrefix",
1163
- value: function setPaymentNumberDevicePrefix(prefix) {
1164
- var normalized = String(prefix !== null && prefix !== void 0 ? prefix : '').trim();
1165
- this.paymentNumberDevicePrefix = normalized || null;
1166
- }
1167
- }, {
1168
- key: "getPaymentNumberDevicePrefixSync",
1169
- value: function getPaymentNumberDevicePrefixSync() {
1170
- var _this7 = this;
1171
- if (!this.appPlugin) return 'LOCAL';
1172
- return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
1173
- return _this7.getAppData(key);
1174
- });
1175
- }
1176
- }, {
1177
- key: "getPaymentNumberDevicePrefixAsync",
1178
- value: function getPaymentNumberDevicePrefixAsync() {
1179
- var _this8 = this;
1180
- if (!this.appPlugin) return Promise.resolve('LOCAL');
1181
- if (this.paymentNumberDevicePrefix) {
1182
- return Promise.resolve(this.paymentNumberDevicePrefix);
1183
- }
1184
- return resolvePaymentNumberDevicePrefix(function (key) {
1185
- return _this8.getAppData(key);
1186
- });
1187
- }
1188
1083
  }, {
1189
1084
  key: "syncAppDataToTempOrder",
1190
1085
  value: function syncAppDataToTempOrder(tempOrder) {
@@ -1228,7 +1123,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1228
1123
  value: function () {
1229
1124
  var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(core) {
1230
1125
  var _this$otherParams4,
1231
- _this9 = this,
1126
+ _this7 = this,
1232
1127
  _this$otherParams5;
1233
1128
  var options,
1234
1129
  app,
@@ -1241,7 +1136,6 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1241
1136
  options = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {};
1242
1137
  this.core = core;
1243
1138
  this.initializeOptions = options || {};
1244
- this.paymentNumberDevicePrefix = null;
1245
1139
  // this.store = { ...this.store, ...(options.store as Partial<BaseSalesState>) };
1246
1140
  this.otherParams = options.otherParams || {};
1247
1141
  this.cacheId = (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.cacheId;
@@ -1252,52 +1146,52 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1252
1146
  // 获取 logger 实例
1253
1147
  this.appPlugin = core.getPlugin('app');
1254
1148
  if (this.appPlugin) {
1255
- _context11.next = 12;
1149
+ _context11.next = 11;
1256
1150
  break;
1257
1151
  }
1258
1152
  throw new Error('Checkout 解决方案需要 app 插件支持');
1259
- case 12:
1153
+ case 11:
1260
1154
  app = this.appPlugin.getApp();
1261
1155
  this.logger = app.logger;
1262
1156
  targetCacheData = this.readSessionCacheData();
1263
1157
  moduleNames = this.getRegisteredModuleNames();
1264
1158
  moduleNames.forEach(function (step) {
1265
- var reusedModule = _this9.getReusableSharedSubModule(step);
1159
+ var reusedModule = _this7.getReusableSharedSubModule(step);
1266
1160
  if (reusedModule) {
1267
- _this9.store[step] = reusedModule;
1268
- _this9.reusedSharedSubModuleNames.add(step);
1161
+ _this7.store[step] = reusedModule;
1162
+ _this7.reusedSharedSubModuleNames.add(step);
1269
1163
  return;
1270
1164
  }
1271
- var targetModule = _this9.createSubModule(step);
1165
+ var targetModule = _this7.createSubModule(step);
1272
1166
  if (!targetModule) {
1273
1167
  throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
1274
1168
  }
1275
- var hooks = _this9.getSubModuleHooks(step);
1276
- _this9.store[step] = targetModule;
1277
- _this9.core.registerModule(targetModule, _objectSpread(_objectSpread({
1169
+ var hooks = _this7.getSubModuleHooks(step);
1170
+ _this7.store[step] = targetModule;
1171
+ _this7.core.registerModule(targetModule, _objectSpread(_objectSpread({
1278
1172
  initialState: (targetCacheData === null || targetCacheData === void 0 ? void 0 : targetCacheData[targetModule.name]) || {}
1279
1173
  }, hooks ? {
1280
1174
  hooks: hooks
1281
1175
  } : {}), {}, {
1282
- otherParams: _this9.buildSubModuleOtherParams()
1176
+ otherParams: _this7.buildSubModuleOtherParams()
1283
1177
  }));
1284
1178
  });
1285
1179
  if (!(this.store.schedule && !this.isScheduleListLoaded(this.store.schedule))) {
1286
- _context11.next = 20;
1180
+ _context11.next = 19;
1287
1181
  break;
1288
1182
  }
1289
- _context11.next = 20;
1183
+ _context11.next = 19;
1290
1184
  return this.store.schedule.loadAllSchedule();
1291
- case 20:
1185
+ case 19:
1292
1186
  if (this.store.order && typeof ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.enableTempOrderPersist) === 'boolean') {
1293
1187
  this.store.order.setEnableTempOrderPersist(this.otherParams.enableTempOrderPersist);
1294
1188
  }
1295
- _context11.next = 23;
1189
+ _context11.next = 22;
1296
1190
  return this.getPaymentMethodsAsync();
1297
- case 23:
1191
+ case 22:
1298
1192
  this.registerServerOrderChangeSync();
1299
1193
  this.core.effects.emit("".concat(this.name, ":onInited"), {});
1300
- case 25:
1194
+ case 24:
1301
1195
  case "end":
1302
1196
  return _context11.stop();
1303
1197
  }
@@ -1313,15 +1207,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1313
1207
  value: function () {
1314
1208
  var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
1315
1209
  var _this$serverOrderChan2,
1316
- _this10 = this;
1210
+ _this8 = this;
1317
1211
  return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1318
1212
  while (1) switch (_context12.prev = _context12.next) {
1319
1213
  case 0:
1320
1214
  (_this$serverOrderChan2 = this.serverOrderChangeUnsubscribe) === null || _this$serverOrderChan2 === void 0 || _this$serverOrderChan2.call(this);
1321
1215
  this.serverOrderChangeUnsubscribe = null;
1322
1216
  Object.keys(this.store).forEach(function (key) {
1323
- if (_this10.reusedSharedSubModuleNames.has(key)) return;
1324
- var sub = _this10.store[key];
1217
+ if (_this8.reusedSharedSubModuleNames.has(key)) return;
1218
+ var sub = _this8.store[key];
1325
1219
  if (sub && typeof sub.destroy === 'function') {
1326
1220
  try {
1327
1221
  sub.destroy();
@@ -1331,14 +1225,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1331
1225
  }
1332
1226
  });
1333
1227
  this.currentSalesDetail = null;
1334
- this.paymentNumberDevicePrefix = null;
1335
1228
  this.queuedServerOrderChanges = [];
1336
1229
  this.salesDetailLoadSequence += 1;
1337
- _context12.next = 9;
1230
+ _context12.next = 8;
1338
1231
  return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
1339
- case 9:
1232
+ case 8:
1340
1233
  _get(_getPrototypeOf(BaseSalesImpl.prototype), "destroy", this).call(this);
1341
- case 10:
1234
+ case 9:
1342
1235
  case "end":
1343
1236
  return _context12.stop();
1344
1237
  }
@@ -1360,7 +1253,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1360
1253
  key: "loadSalesDetail",
1361
1254
  value: (function () {
1362
1255
  var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderIdOrParams) {
1363
- var loadSequence, _ref17, _ref18, _ref19, _ref20, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, remoteRecord, currentTempOrder, mergedRecord, record;
1256
+ var loadSequence, _ref17, _ref18, _ref19, _ref20, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, remoteRecord, currentTempOrder, record;
1364
1257
  return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1365
1258
  while (1) switch (_context13.prev = _context13.next) {
1366
1259
  case 0:
@@ -1409,40 +1302,39 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1409
1302
  message = loadedRecord && (loadedRecord.message || loadedRecord.msg) || "\u52A0\u8F7D\u9500\u552E\u8BE6\u60C5\u5931\u8D25: ".concat(lookup);
1410
1303
  throw new Error(message);
1411
1304
  case 22:
1412
- remoteRecord = filterPendingPaymentsFromLoadedSalesDetail(preloadedSalesDetail !== null && preloadedSalesDetail !== void 0 ? preloadedSalesDetail : loadedRecord.data);
1305
+ remoteRecord = preloadedSalesDetail !== null && preloadedSalesDetail !== void 0 ? preloadedSalesDetail : loadedRecord.data;
1413
1306
  currentTempOrder = params.merge ? this.store.order.getTempOrder() : null;
1414
- mergedRecord = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder, remoteRecord, 'preserve-local') : remoteRecord;
1415
- record = filterPendingPaymentsFromLoadedSalesDetail(mergedRecord);
1416
- _context13.next = 28;
1307
+ record = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder, remoteRecord, 'preserve-local') : remoteRecord;
1308
+ _context13.next = 27;
1417
1309
  return this.hydrateLatestLoadedSalesDetail(record, loadSequence);
1418
- case 28:
1310
+ case 27:
1419
1311
  return _context13.abrupt("return", _context13.sent);
1420
- case 29:
1421
- _context13.prev = 29;
1312
+ case 28:
1313
+ _context13.prev = 28;
1422
1314
  this.salesDetailLoadInFlightCount = Math.max(0, this.salesDetailLoadInFlightCount - 1);
1423
1315
  if (!(this.salesDetailLoadInFlightCount === 0)) {
1424
- _context13.next = 40;
1316
+ _context13.next = 39;
1425
1317
  break;
1426
1318
  }
1427
- _context13.prev = 32;
1428
- _context13.next = 35;
1319
+ _context13.prev = 31;
1320
+ _context13.next = 34;
1429
1321
  return this.drainQueuedServerOrderChanges();
1430
- case 35:
1431
- _context13.next = 40;
1322
+ case 34:
1323
+ _context13.next = 39;
1432
1324
  break;
1433
- case 37:
1434
- _context13.prev = 37;
1435
- _context13.t1 = _context13["catch"](32);
1325
+ case 36:
1326
+ _context13.prev = 36;
1327
+ _context13.t1 = _context13["catch"](31);
1436
1328
  this.logError('drain queued server order changes failed', {
1437
1329
  error: _context13.t1 instanceof Error ? _context13.t1.message : String(_context13.t1)
1438
1330
  });
1331
+ case 39:
1332
+ return _context13.finish(28);
1439
1333
  case 40:
1440
- return _context13.finish(29);
1441
- case 41:
1442
1334
  case "end":
1443
1335
  return _context13.stop();
1444
1336
  }
1445
- }, _callee13, this, [[4,, 29, 41], [32, 37]]);
1337
+ }, _callee13, this, [[4,, 28, 40], [31, 36]]);
1446
1338
  }));
1447
1339
  function loadSalesDetail(_x11) {
1448
1340
  return _loadSalesDetail.apply(this, arguments);
@@ -1870,10 +1762,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1870
1762
  }, {
1871
1763
  key: "getHistoricalProductDiscountList",
1872
1764
  value: function getHistoricalProductDiscountList(products) {
1873
- var _this11 = this;
1765
+ var _this9 = this;
1874
1766
  var historyDiscountList = [];
1875
1767
  products.forEach(function (item) {
1876
- if (!_this11.isPersistedOrderProduct(item)) return;
1768
+ if (!_this9.isPersistedOrderProduct(item)) return;
1877
1769
  (item.discount_list || []).forEach(function (discount) {
1878
1770
  var _discount$discount, _discount$metadata, _discount$discount2, _discount$discount3, _discount$discount4;
1879
1771
  var discountId = ((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) || discount.id;
@@ -1933,11 +1825,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1933
1825
  }, {
1934
1826
  key: "shouldSkipAutoApplyFetchedDiscountsInEditMode",
1935
1827
  value: function shouldSkipAutoApplyFetchedDiscountsInEditMode(params) {
1936
- var _this12 = this;
1828
+ var _this10 = this;
1937
1829
  if (params.discountAction !== 'edit') return false;
1938
1830
  if (!params.products.length) return false;
1939
1831
  var hasDraftProduct = params.products.some(function (product) {
1940
- return !_this12.isPersistedOrderProduct(product);
1832
+ return !_this10.isPersistedOrderProduct(product);
1941
1833
  });
1942
1834
  if (hasDraftProduct) return false;
1943
1835
  var hasSelectedDiscount = params.currentDiscountList.some(function (discount) {
@@ -2740,10 +2632,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2740
2632
  return submitSalesOrder;
2741
2633
  }())
2742
2634
  }, {
2743
- key: "saveSalesOrderDraft",
2635
+ key: "submitTempOrderAsync",
2744
2636
  value: function () {
2745
- var _saveSalesOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
2746
- var _params$platform, _this$otherParams10, _ref22, _params$businessCode, _this$otherParams11, _this$otherParams12, _params$channel, _params$type, _this$otherParams13;
2637
+ var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
2638
+ var _this$otherParams10, _this$otherParams11, _this$otherParams12, _this$otherParams13;
2639
+ var inferredPaymentStatus, submitParams;
2747
2640
  return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2748
2641
  while (1) switch (_context28.prev = _context28.next) {
2749
2642
  case 0:
@@ -2752,49 +2645,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2752
2645
  break;
2753
2646
  }
2754
2647
  throw new Error('BaseSales 解决方案需要 order 模块支持');
2755
- case 2:
2756
- return _context28.abrupt("return", this.store.order.saveTempOrderAsDraft(_objectSpread({
2757
- cacheId: this.cacheId,
2758
- platform: (_params$platform = params === null || params === void 0 ? void 0 : params.platform) !== null && _params$platform !== void 0 ? _params$platform : (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.platform,
2759
- businessCode: (_ref22 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.businessCode) !== null && _ref22 !== void 0 ? _ref22 : (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.business_code,
2760
- channel: (_params$channel = params === null || params === void 0 ? void 0 : params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel(),
2761
- type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.type
2762
- }, (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
2763
- enhancePayload: params.enhancePayload
2764
- } : {})));
2765
- case 3:
2766
- case "end":
2767
- return _context28.stop();
2768
- }
2769
- }, _callee28, this);
2770
- }));
2771
- function saveSalesOrderDraft(_x22) {
2772
- return _saveSalesOrderDraft.apply(this, arguments);
2773
- }
2774
- return saveSalesOrderDraft;
2775
- }()
2776
- }, {
2777
- key: "submitTempOrderAsync",
2778
- value: function () {
2779
- var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
2780
- var _this$otherParams14, _this$otherParams15, _this$otherParams16, _this$otherParams17;
2781
- var inferredPaymentStatus, submitParams;
2782
- return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2783
- while (1) switch (_context29.prev = _context29.next) {
2784
- case 0:
2785
- if (this.store.order) {
2786
- _context29.next = 2;
2787
- break;
2788
- }
2789
- throw new Error('BaseSales 解决方案需要 order 模块支持');
2790
2648
  case 2:
2791
2649
  inferredPaymentStatus = this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
2792
2650
  submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
2793
2651
  cacheId: this.cacheId,
2794
- platform: (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.platform,
2795
- businessCode: ((_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.businessCode) || ((_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.business_code),
2652
+ platform: (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.platform,
2653
+ businessCode: ((_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.businessCode) || ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.business_code),
2796
2654
  channel: this.getSubmitOrderSalesChannel(),
2797
- type: (_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.type
2655
+ type: (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.type
2798
2656
  }, (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
2799
2657
  payments: params.payments
2800
2658
  } : {}), inferredPaymentStatus !== undefined ? {
@@ -2806,14 +2664,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2806
2664
  } : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
2807
2665
  enhancePayload: params.enhancePayload
2808
2666
  } : {});
2809
- return _context29.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
2667
+ return _context28.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
2810
2668
  case 5:
2811
2669
  case "end":
2812
- return _context29.stop();
2670
+ return _context28.stop();
2813
2671
  }
2814
- }, _callee29, this);
2672
+ }, _callee28, this);
2815
2673
  }));
2816
- function submitTempOrderAsync(_x23) {
2674
+ function submitTempOrderAsync(_x22) {
2817
2675
  return _submitTempOrderAsync.apply(this, arguments);
2818
2676
  }
2819
2677
  return submitTempOrderAsync;
@@ -2821,14 +2679,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2821
2679
  }, {
2822
2680
  key: "printLocalOrderReceipt",
2823
2681
  value: function () {
2824
- var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(lookup) {
2825
- var _this$otherParams18, _this$otherParams19, _this$otherParams20, _this$otherParams21;
2682
+ var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(lookup) {
2683
+ var _this$otherParams14, _this$otherParams15, _this$otherParams16, _this$otherParams17;
2826
2684
  var hasLookup, lookupPayload, context, payload, response, _this$store$order$app, _this$store$order5, _data;
2827
- return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2828
- while (1) switch (_context30.prev = _context30.next) {
2685
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2686
+ while (1) switch (_context29.prev = _context29.next) {
2829
2687
  case 0:
2830
2688
  if (this.store.order) {
2831
- _context30.next = 2;
2689
+ _context29.next = 2;
2832
2690
  break;
2833
2691
  }
2834
2692
  throw new Error('BaseSales 解决方案需要 order 模块支持');
@@ -2840,10 +2698,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2840
2698
  external_sale_number: lookup
2841
2699
  };
2842
2700
  context = {
2843
- platform: (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.platform,
2844
- businessCode: ((_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.businessCode) || ((_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.business_code),
2701
+ platform: (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.platform,
2702
+ businessCode: ((_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.businessCode) || ((_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.business_code),
2845
2703
  channel: this.getSubmitOrderSalesChannel(),
2846
- type: (_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.type
2704
+ type: (_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.type
2847
2705
  };
2848
2706
  payload = hasLookup ? _objectSpread(_objectSpread({}, lookupPayload), {}, {
2849
2707
  lookup_order_from_db: 1,
@@ -2859,28 +2717,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2859
2717
  channel: context.channel,
2860
2718
  type: context.type
2861
2719
  });
2862
- _context30.next = 8;
2720
+ _context29.next = 8;
2863
2721
  return this.request.post('/local/print-order', payload, {
2864
2722
  osServer: true,
2865
2723
  customToast: function customToast() {}
2866
2724
  });
2867
2725
  case 8:
2868
- response = _context30.sent;
2726
+ response = _context29.sent;
2869
2727
  if (hasLookup) {
2870
- _context30.next = 12;
2728
+ _context29.next = 12;
2871
2729
  break;
2872
2730
  }
2873
- _context30.next = 12;
2731
+ _context29.next = 12;
2874
2732
  return (_this$store$order$app = (_this$store$order5 = this.store.order).applyLocalPrintOrderNumbers) === null || _this$store$order$app === void 0 ? void 0 : _this$store$order$app.call(_this$store$order5, response === null || response === void 0 || (_data = response.data) === null || _data === void 0 ? void 0 : _data.order);
2875
2733
  case 12:
2876
- return _context30.abrupt("return", response);
2734
+ return _context29.abrupt("return", response);
2877
2735
  case 13:
2878
2736
  case "end":
2879
- return _context30.stop();
2737
+ return _context29.stop();
2880
2738
  }
2881
- }, _callee30, this);
2739
+ }, _callee29, this);
2882
2740
  }));
2883
- function printLocalOrderReceipt(_x24) {
2741
+ function printLocalOrderReceipt(_x23) {
2884
2742
  return _printLocalOrderReceipt.apply(this, arguments);
2885
2743
  }
2886
2744
  return printLocalOrderReceipt;
@@ -2901,20 +2759,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2901
2759
  }, {
2902
2760
  key: "syncPaymentsToOrder",
2903
2761
  value: function () {
2904
- var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
2905
- var _ref23, _params$businessCode2, _this$otherParams22, _this$otherParams23, _params$channel2;
2762
+ var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
2763
+ var _ref22, _params$businessCode, _this$otherParams18, _this$otherParams19, _params$channel;
2906
2764
  var businessCode, channel, syncParams, syncState, payments, syncResult, latestPayments, amountSnapshot, orderSnapshot, syncPayload;
2907
- return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2908
- while (1) switch (_context31.prev = _context31.next) {
2765
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2766
+ while (1) switch (_context30.prev = _context30.next) {
2909
2767
  case 0:
2910
2768
  if (this.store.order) {
2911
- _context31.next = 2;
2769
+ _context30.next = 2;
2912
2770
  break;
2913
2771
  }
2914
2772
  throw new Error('order 模块未初始化');
2915
2773
  case 2:
2916
- businessCode = (_ref23 = (_params$businessCode2 = params.businessCode) !== null && _params$businessCode2 !== void 0 ? _params$businessCode2 : (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.businessCode) !== null && _ref23 !== void 0 ? _ref23 : (_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.business_code;
2917
- channel = (_params$channel2 = params.channel) !== null && _params$channel2 !== void 0 ? _params$channel2 : this.getSubmitOrderSalesChannel();
2774
+ businessCode = (_ref22 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.businessCode) !== null && _ref22 !== void 0 ? _ref22 : (_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.business_code;
2775
+ channel = (_params$channel = params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel();
2918
2776
  syncParams = _objectSpread(_objectSpread(_objectSpread({}, params), businessCode !== undefined ? {
2919
2777
  businessCode: businessCode
2920
2778
  } : {}), channel !== undefined ? {
@@ -2922,14 +2780,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2922
2780
  } : {});
2923
2781
  syncState = this.store.order.getOrderSyncState();
2924
2782
  if (!(params.submitWhenPaid && syncState === 'submitting')) {
2925
- _context31.next = 9;
2783
+ _context30.next = 9;
2926
2784
  break;
2927
2785
  }
2928
2786
  this.queueLatestAutoPaymentSync();
2929
- return _context31.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
2787
+ return _context30.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
2930
2788
  case 9:
2931
2789
  payments = params.payments || [];
2932
- _context31.next = 12;
2790
+ _context30.next = 12;
2933
2791
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncStart, {
2934
2792
  payments: payments,
2935
2793
  params: syncParams,
@@ -2937,11 +2795,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2937
2795
  orderSnapshot: this.store.order.getOrderSnapshot()
2938
2796
  });
2939
2797
  case 12:
2940
- _context31.prev = 12;
2941
- _context31.next = 15;
2798
+ _context30.prev = 12;
2799
+ _context30.next = 15;
2942
2800
  return this.store.order.syncPaymentsToOrder(syncParams);
2943
2801
  case 15:
2944
- syncResult = _context31.sent;
2802
+ syncResult = _context30.sent;
2945
2803
  latestPayments = this.store.order.getOrderPayments();
2946
2804
  amountSnapshot = this.store.order.getOrderAmountSnapshot();
2947
2805
  orderSnapshot = this.store.order.getOrderSnapshot();
@@ -2959,25 +2817,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2959
2817
  depositAmount: syncResult.depositAmount,
2960
2818
  orderExpectedAmount: syncResult.orderExpectedAmount
2961
2819
  };
2962
- _context31.next = 22;
2820
+ _context30.next = 22;
2963
2821
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, syncPayload);
2964
2822
  case 22:
2965
2823
  if (!(syncResult.isDepositFullyPaid && !syncResult.isOrderFullyPaid)) {
2966
- _context31.next = 25;
2824
+ _context30.next = 25;
2967
2825
  break;
2968
2826
  }
2969
- _context31.next = 25;
2827
+ _context30.next = 25;
2970
2828
  return this.effectsEmit(BaseSalesHookNames.onDepositPaymentSyncEnd, syncPayload);
2971
2829
  case 25:
2972
2830
  this.scheduleQueuedAutoPaymentSyncFlush(0);
2973
- return _context31.abrupt("return", syncResult);
2831
+ return _context30.abrupt("return", syncResult);
2974
2832
  case 29:
2975
- _context31.prev = 29;
2976
- _context31.t0 = _context31["catch"](12);
2977
- _context31.next = 33;
2833
+ _context30.prev = 29;
2834
+ _context30.t0 = _context30["catch"](12);
2835
+ _context30.next = 33;
2978
2836
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
2979
2837
  ok: false,
2980
- error: _context31.t0,
2838
+ error: _context30.t0,
2981
2839
  payments: this.store.order.getOrderPayments(),
2982
2840
  params: syncParams,
2983
2841
  amountSnapshot: this.store.order.getOrderAmountSnapshot(),
@@ -2985,14 +2843,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2985
2843
  });
2986
2844
  case 33:
2987
2845
  this.scheduleQueuedAutoPaymentSyncFlush(0);
2988
- throw _context31.t0;
2846
+ throw _context30.t0;
2989
2847
  case 35:
2990
2848
  case "end":
2991
- return _context31.stop();
2849
+ return _context30.stop();
2992
2850
  }
2993
- }, _callee31, this, [[12, 29]]);
2851
+ }, _callee30, this, [[12, 29]]);
2994
2852
  }));
2995
- function syncPaymentsToOrder(_x25) {
2853
+ function syncPaymentsToOrder(_x24) {
2996
2854
  return _syncPaymentsToOrder.apply(this, arguments);
2997
2855
  }
2998
2856
  return syncPaymentsToOrder;
@@ -3029,58 +2887,58 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3029
2887
  }, {
3030
2888
  key: "scheduleQueuedAutoPaymentSyncFlush",
3031
2889
  value: function scheduleQueuedAutoPaymentSyncFlush() {
3032
- var _this13 = this;
2890
+ var _this11 = this;
3033
2891
  var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;
3034
2892
  if (!this.queuedAutoPaymentSync) return;
3035
2893
  if (this.autoPaymentSyncTimer) return;
3036
2894
  this.autoPaymentSyncTimer = setTimeout(function () {
3037
- _this13.autoPaymentSyncTimer = null;
3038
- void _this13.flushQueuedAutoPaymentSync();
2895
+ _this11.autoPaymentSyncTimer = null;
2896
+ void _this11.flushQueuedAutoPaymentSync();
3039
2897
  }, delay);
3040
2898
  }
3041
2899
  }, {
3042
2900
  key: "flushQueuedAutoPaymentSync",
3043
2901
  value: function () {
3044
- var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
2902
+ var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
3045
2903
  var payments;
3046
- return _regeneratorRuntime().wrap(function _callee32$(_context32) {
3047
- while (1) switch (_context32.prev = _context32.next) {
2904
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2905
+ while (1) switch (_context31.prev = _context31.next) {
3048
2906
  case 0:
3049
2907
  if (this.store.order) {
3050
- _context32.next = 2;
2908
+ _context31.next = 2;
3051
2909
  break;
3052
2910
  }
3053
- return _context32.abrupt("return");
2911
+ return _context31.abrupt("return");
3054
2912
  case 2:
3055
2913
  if (!(!this.queuedAutoPaymentSync || this.autoPaymentSyncFlushing)) {
3056
- _context32.next = 4;
2914
+ _context31.next = 4;
3057
2915
  break;
3058
2916
  }
3059
- return _context32.abrupt("return");
2917
+ return _context31.abrupt("return");
3060
2918
  case 4:
3061
2919
  if (!(this.store.order.getOrderSyncState() === 'submitting')) {
3062
- _context32.next = 7;
2920
+ _context31.next = 7;
3063
2921
  break;
3064
2922
  }
3065
2923
  this.scheduleQueuedAutoPaymentSyncFlush();
3066
- return _context32.abrupt("return");
2924
+ return _context31.abrupt("return");
3067
2925
  case 7:
3068
2926
  this.autoPaymentSyncFlushing = true;
3069
- _context32.prev = 8;
2927
+ _context31.prev = 8;
3070
2928
  case 9:
3071
2929
  if (!this.queuedAutoPaymentSync) {
3072
- _context32.next = 18;
2930
+ _context31.next = 18;
3073
2931
  break;
3074
2932
  }
3075
2933
  this.queuedAutoPaymentSync = false;
3076
2934
  payments = this.store.order.getOrderPayments();
3077
2935
  if (payments.length) {
3078
- _context32.next = 14;
2936
+ _context31.next = 14;
3079
2937
  break;
3080
2938
  }
3081
- return _context32.abrupt("continue", 9);
2939
+ return _context31.abrupt("continue", 9);
3082
2940
  case 14:
3083
- _context32.next = 16;
2941
+ _context31.next = 16;
3084
2942
  return this.syncPaymentsToOrder({
3085
2943
  payments: payments,
3086
2944
  paymentStatus: this.getPaymentStatusForSync(payments),
@@ -3088,94 +2946,44 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3088
2946
  smallTicketDataFlag: 1
3089
2947
  });
3090
2948
  case 16:
3091
- _context32.next = 9;
2949
+ _context31.next = 9;
3092
2950
  break;
3093
2951
  case 18:
3094
- _context32.next = 23;
2952
+ _context31.next = 23;
3095
2953
  break;
3096
2954
  case 20:
3097
- _context32.prev = 20;
3098
- _context32.t0 = _context32["catch"](8);
2955
+ _context31.prev = 20;
2956
+ _context31.t0 = _context31["catch"](8);
3099
2957
  this.logError('queued auto sync payments failed', {
3100
- error: _context32.t0 instanceof Error ? _context32.t0.message : String(_context32.t0)
2958
+ error: _context31.t0 instanceof Error ? _context31.t0.message : String(_context31.t0)
3101
2959
  });
3102
2960
  case 23:
3103
- _context32.prev = 23;
2961
+ _context31.prev = 23;
3104
2962
  this.autoPaymentSyncFlushing = false;
3105
2963
  if (this.queuedAutoPaymentSync) {
3106
2964
  this.scheduleQueuedAutoPaymentSyncFlush(0);
3107
2965
  }
3108
- return _context32.finish(23);
2966
+ return _context31.finish(23);
3109
2967
  case 27:
3110
2968
  case "end":
3111
- return _context32.stop();
2969
+ return _context31.stop();
3112
2970
  }
3113
- }, _callee32, this, [[8, 20, 23, 27]]);
2971
+ }, _callee31, this, [[8, 20, 23, 27]]);
3114
2972
  }));
3115
2973
  function flushQueuedAutoPaymentSync() {
3116
2974
  return _flushQueuedAutoPaymentSync.apply(this, arguments);
3117
2975
  }
3118
2976
  return flushQueuedAutoPaymentSync;
3119
- }()
3120
- /**
3121
- * 同步兼容入口。无法等待 IoT 短号时,按调用当下的 device_id 或 LOCAL 生成。
3122
- */
2977
+ }() /** 追加单个支付项到当前订单。 */
3123
2978
  }, {
3124
2979
  key: "addOrderPayment",
3125
2980
  value: function addOrderPayment(payment) {
3126
- var hasPaymentNumber = String(payment.payment_number || '').trim() !== '';
3127
- return this.addOrderPaymentWithDevicePrefix(payment, hasPaymentNumber ? 'LOCAL' : this.getPaymentNumberDevicePrefixSync());
3128
- }
3129
-
3130
- /**
3131
- * 创建新支付项时优先使用业务解决方案初始化阶段缓存的设备短号;
3132
- * 未缓存的通用 BaseSales 保持实时读取设备信息的兼容语义。
3133
- */
3134
- }, {
3135
- key: "addOrderPaymentAsync",
3136
- value: (function () {
3137
- var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(payment) {
3138
- var paymentRecord, hasPaymentNumber, devicePrefix;
3139
- return _regeneratorRuntime().wrap(function _callee33$(_context33) {
3140
- while (1) switch (_context33.prev = _context33.next) {
3141
- case 0:
3142
- paymentRecord = payment;
3143
- hasPaymentNumber = String(paymentRecord.payment_number || '').trim() !== '';
3144
- if (!hasPaymentNumber) {
3145
- _context33.next = 6;
3146
- break;
3147
- }
3148
- _context33.t0 = 'LOCAL';
3149
- _context33.next = 9;
3150
- break;
3151
- case 6:
3152
- _context33.next = 8;
3153
- return this.getPaymentNumberDevicePrefixAsync();
3154
- case 8:
3155
- _context33.t0 = _context33.sent;
3156
- case 9:
3157
- devicePrefix = _context33.t0;
3158
- return _context33.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
3159
- case 11:
3160
- case "end":
3161
- return _context33.stop();
3162
- }
3163
- }, _callee33, this);
3164
- }));
3165
- function addOrderPaymentAsync(_x26) {
3166
- return _addOrderPaymentAsync.apply(this, arguments);
3167
- }
3168
- return addOrderPaymentAsync;
3169
- }())
3170
- }, {
3171
- key: "addOrderPaymentWithDevicePrefix",
3172
- value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
3173
- var _this$otherParams24,
2981
+ var _this$otherParams20,
3174
2982
  _paymentRecord$paymen,
3175
2983
  _paymentRecord$create,
3176
- _ref24,
2984
+ _ref23,
3177
2985
  _paymentRecord$origin,
3178
- _this14 = this;
2986
+ _this12 = this;
3179
2987
  if (!this.store.order) throw new Error('order 模块未初始化');
3180
2988
  var paymentRecord = payment;
3181
2989
  var paymentAmount = new Decimal(paymentRecord.amount || 0);
@@ -3186,26 +2994,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3186
2994
  return this.store.order.getOrderPayments();
3187
2995
  }
3188
2996
  var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
3189
- var shopWalletPassId = (_this$otherParams24 = this.otherParams) === null || _this$otherParams24 === void 0 ? void 0 : _this$otherParams24.shop_wallet_pass_id;
2997
+ var shopWalletPassId = (_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.shop_wallet_pass_id;
3190
2998
  if (shopWalletPassId !== undefined && shopWalletPassId !== null) {
3191
2999
  metadata.shop_wallet_pass_id = shopWalletPassId;
3192
3000
  }
3193
- var normalizedPaymentRecord = ensureOrderPaymentNumber(paymentRecord, devicePrefix, createUuidV4);
3001
+ if (!metadata.unique_payment_number) {
3002
+ metadata.unique_payment_number = createUuidV4();
3003
+ }
3194
3004
  var paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
3195
3005
  var paymentTime = (_paymentRecord$paymen = paymentRecord.payment_time) !== null && _paymentRecord$paymen !== void 0 ? _paymentRecord$paymen : paymentTimestamp;
3196
3006
  var createdAt = (_paymentRecord$create = paymentRecord.created_at) !== null && _paymentRecord$create !== void 0 ? _paymentRecord$create : paymentTimestamp;
3197
3007
  var serviceCharge = paymentRecord.service_charge && _typeof(paymentRecord.service_charge) === 'object' ? paymentRecord.service_charge : null;
3198
- var calculatedServiceFee = serviceCharge ? new Decimal((_ref24 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref24 !== void 0 ? _ref24 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
3199
- var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({}, normalizedPaymentRecord), calculatedServiceFee !== undefined ? {
3008
+ var calculatedServiceFee = serviceCharge ? new Decimal((_ref23 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref23 !== void 0 ? _ref23 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
3009
+ var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({}, paymentRecord), calculatedServiceFee !== undefined ? {
3200
3010
  service_fee: calculatedServiceFee
3201
3011
  } : {}), {}, {
3202
3012
  metadata: metadata,
3203
3013
  payment_time: paymentTime,
3204
3014
  created_at: createdAt
3205
3015
  }));
3206
- if (paymentRecord.status === 'payment_pending') {
3207
- return payments;
3208
- }
3209
3016
  var amountSnapshot = this.store.order.getOrderAmountSnapshot();
3210
3017
  var syncState = this.store.order.getOrderSyncState();
3211
3018
  if (amountSnapshot) {
@@ -3219,7 +3026,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3219
3026
  submitWhenPaid: true,
3220
3027
  smallTicketDataFlag: 1
3221
3028
  }).catch(function (error) {
3222
- _this14.logError('auto sync payments failed', {
3029
+ _this12.logError('auto sync payments failed', {
3223
3030
  error: error instanceof Error ? error.message : String(error)
3224
3031
  });
3225
3032
  });
@@ -3230,131 +3037,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3230
3037
  /** 更新当前订单中的指定支付项。 */
3231
3038
  }, {
3232
3039
  key: "updateOrderPayment",
3233
- value: (function () {
3234
- var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(paymentIdentity, updates) {
3235
- var _result$payment, _result$payment2;
3236
- var options,
3237
- matchMode,
3238
- previousMatch,
3239
- previousPayment,
3240
- _this$store$order$get2,
3241
- currentPayments,
3242
- _syncResult,
3243
- _options$smallTicketD,
3244
- result,
3245
- draftResult,
3246
- draftError,
3247
- becamePaid,
3248
- shouldSubmit,
3249
- syncResult,
3250
- _options$smallTicketD2,
3251
- _args34 = arguments;
3252
- return _regeneratorRuntime().wrap(function _callee34$(_context34) {
3253
- while (1) switch (_context34.prev = _context34.next) {
3254
- case 0:
3255
- options = _args34.length > 2 && _args34[2] !== undefined ? _args34[2] : {};
3256
- if (this.store.order) {
3257
- _context34.next = 3;
3258
- break;
3259
- }
3260
- throw new Error('order 模块未初始化');
3261
- case 3:
3262
- matchMode = options.matchBy === 'compat' || options.matchBy === 'legacy' ? 'compat' : 'payment_number';
3263
- previousMatch = resolveOrderPaymentIdentity(this.store.order.getOrderPayments(), paymentIdentity, matchMode);
3264
- previousPayment = previousMatch === null || previousMatch === void 0 ? void 0 : previousMatch.payment;
3265
- if (!((previousPayment === null || previousPayment === void 0 ? void 0 : previousPayment.status) === 'paid' && !options.applyUpdatesWhenPaid)) {
3266
- _context34.next = 13;
3267
- break;
3268
- }
3269
- currentPayments = this.store.order.getOrderPayments();
3270
- if (!(options.submitWhenPaid && options.forceSubmitIfPaid)) {
3271
- _context34.next = 12;
3272
- break;
3273
- }
3274
- _context34.next = 11;
3275
- return this.syncPaymentsToOrder({
3276
- payments: currentPayments,
3277
- paymentStatus: this.getPaymentStatusForSync(currentPayments),
3278
- submitWhenPaid: true,
3279
- smallTicketDataFlag: (_options$smallTicketD = options.smallTicketDataFlag) !== null && _options$smallTicketD !== void 0 ? _options$smallTicketD : 1
3280
- });
3281
- case 11:
3282
- _syncResult = _context34.sent;
3283
- case 12:
3284
- return _context34.abrupt("return", _objectSpread({
3285
- updated: false,
3286
- payment: previousPayment,
3287
- payments: currentPayments,
3288
- summary: ((_this$store$order$get2 = this.store.order.getOrderAmountSnapshot()) === null || _this$store$order$get2 === void 0 ? void 0 : _this$store$order$get2.summary) || null
3289
- }, _syncResult !== undefined ? {
3290
- syncResult: _syncResult
3291
- } : {}));
3292
- case 13:
3293
- _context34.next = 15;
3294
- return this.store.order.updateOrderPayment(paymentIdentity, updates, {
3295
- matchBy: matchMode
3296
- });
3297
- case 15:
3298
- result = _context34.sent;
3299
- if (!(options.persistDraft !== false)) {
3300
- _context34.next = 29;
3301
- break;
3302
- }
3303
- _context34.prev = 17;
3304
- _context34.next = 20;
3305
- return this.saveSalesOrderDraft();
3306
- case 20:
3307
- draftResult = _context34.sent;
3308
- _context34.next = 29;
3309
- break;
3310
- case 23:
3311
- _context34.prev = 23;
3312
- _context34.t0 = _context34["catch"](17);
3313
- draftError = _context34.t0;
3314
- this.logError('updateOrderPayment: 保存支付草稿失败', {
3315
- paymentIdentity: paymentIdentity,
3316
- error: _context34.t0 instanceof Error ? _context34.t0.message : String(_context34.t0)
3317
- });
3318
- if (options.submitWhenPaid) {
3319
- _context34.next = 29;
3320
- break;
3321
- }
3322
- throw _context34.t0;
3323
- case 29:
3324
- becamePaid = (previousPayment === null || previousPayment === void 0 ? void 0 : previousPayment.status) !== 'paid' && ((_result$payment = result.payment) === null || _result$payment === void 0 ? void 0 : _result$payment.status) === 'paid';
3325
- shouldSubmit = Boolean(options.submitWhenPaid && ((_result$payment2 = result.payment) === null || _result$payment2 === void 0 ? void 0 : _result$payment2.status) === 'paid' && (becamePaid || options.forceSubmitIfPaid));
3326
- if (!shouldSubmit) {
3327
- _context34.next = 35;
3328
- break;
3329
- }
3330
- _context34.next = 34;
3331
- return this.syncPaymentsToOrder({
3332
- payments: result.payments,
3333
- paymentStatus: this.getPaymentStatusForSync(result.payments),
3334
- submitWhenPaid: true,
3335
- smallTicketDataFlag: (_options$smallTicketD2 = options.smallTicketDataFlag) !== null && _options$smallTicketD2 !== void 0 ? _options$smallTicketD2 : 1
3336
- });
3337
- case 34:
3338
- syncResult = _context34.sent;
3339
- case 35:
3340
- return _context34.abrupt("return", _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, result), draftResult !== undefined ? {
3341
- draftResult: draftResult
3342
- } : {}), draftError !== undefined ? {
3343
- draftError: draftError
3344
- } : {}), syncResult !== undefined ? {
3345
- syncResult: syncResult
3346
- } : {}));
3347
- case 36:
3348
- case "end":
3349
- return _context34.stop();
3350
- }
3351
- }, _callee34, this, [[17, 23]]);
3352
- }));
3353
- function updateOrderPayment(_x27, _x28) {
3354
- return _updateOrderPayment.apply(this, arguments);
3355
- }
3356
- return updateOrderPayment;
3357
- }() /** 删除当前订单中的指定支付项。 */)
3040
+ value: function updateOrderPayment(paymentIdentity, updates) {
3041
+ if (!this.store.order) throw new Error('order 模块未初始化');
3042
+ return this.store.order.updateOrderPayment(paymentIdentity, updates);
3043
+ }
3044
+
3045
+ /** 删除当前订单中的指定支付项。 */
3358
3046
  }, {
3359
3047
  key: "deleteOrderPayment",
3360
3048
  value: function deleteOrderPayment(paymentIdentity) {
@@ -3369,31 +3057,6 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3369
3057
  if (!this.store.order) throw new Error('order 模块未初始化');
3370
3058
  return this.store.order.updateVoucherOrderPayments(payments, options);
3371
3059
  }
3372
- }, {
3373
- key: "updateVoucherOrderPaymentsAsync",
3374
- value: function () {
3375
- var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(payments, options) {
3376
- return _regeneratorRuntime().wrap(function _callee35$(_context35) {
3377
- while (1) switch (_context35.prev = _context35.next) {
3378
- case 0:
3379
- if (this.store.order) {
3380
- _context35.next = 2;
3381
- break;
3382
- }
3383
- throw new Error('order 模块未初始化');
3384
- case 2:
3385
- return _context35.abrupt("return", this.store.order.updateVoucherOrderPaymentsAsync(payments, options));
3386
- case 3:
3387
- case "end":
3388
- return _context35.stop();
3389
- }
3390
- }, _callee35, this);
3391
- }));
3392
- function updateVoucherOrderPaymentsAsync(_x29, _x30) {
3393
- return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
3394
- }
3395
- return updateVoucherOrderPaymentsAsync;
3396
- }()
3397
3060
  }, {
3398
3061
  key: "confirmPendingVoucherPayments",
3399
3062
  value: function confirmPendingVoucherPayments() {
@@ -3470,20 +3133,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3470
3133
  }, {
3471
3134
  key: "initWalletData",
3472
3135
  value: function () {
3473
- var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
3474
- var _params$order_wait_pa, _ref25, _tempOrder$is_price_i;
3136
+ var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
3137
+ var _params$order_wait_pa, _ref24, _tempOrder$is_price_i;
3475
3138
  var snapshot, tempOrder, amount, walletBusinessData, result;
3476
- return _regeneratorRuntime().wrap(function _callee36$(_context36) {
3477
- while (1) switch (_context36.prev = _context36.next) {
3139
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
3140
+ while (1) switch (_context32.prev = _context32.next) {
3478
3141
  case 0:
3479
3142
  if (this.store.order) {
3480
- _context36.next = 2;
3143
+ _context32.next = 2;
3481
3144
  break;
3482
3145
  }
3483
3146
  throw new Error('order 模块未初始化');
3484
3147
  case 2:
3485
3148
  if (this.store.payment) {
3486
- _context36.next = 4;
3149
+ _context32.next = 4;
3487
3150
  break;
3488
3151
  }
3489
3152
  throw new Error('payment 模块未初始化');
@@ -3492,10 +3155,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3492
3155
  tempOrder = snapshot === null || snapshot === void 0 ? void 0 : snapshot.tempOrder;
3493
3156
  amount = snapshot === null || snapshot === void 0 ? void 0 : snapshot.amount;
3494
3157
  if (!(!tempOrder || !amount)) {
3495
- _context36.next = 9;
3158
+ _context32.next = 9;
3496
3159
  break;
3497
3160
  }
3498
- return _context36.abrupt("return", {
3161
+ return _context32.abrupt("return", {
3499
3162
  walletRecommendList: [],
3500
3163
  userIdentificationCodes: [],
3501
3164
  transformList: [],
@@ -3514,15 +3177,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3514
3177
  },
3515
3178
  products: this.getWalletProductList(),
3516
3179
  order_wait_pay_amount: (_params$order_wait_pa = params === null || params === void 0 ? void 0 : params.order_wait_pay_amount) !== null && _params$order_wait_pa !== void 0 ? _params$order_wait_pa : Number(amount.amountGap || 0),
3517
- is_price_include_tax: (_ref25 = (_tempOrder$is_price_i = tempOrder.is_price_include_tax) !== null && _tempOrder$is_price_i !== void 0 ? _tempOrder$is_price_i : this.otherParams.is_price_include_tax) !== null && _ref25 !== void 0 ? _ref25 : 1
3180
+ is_price_include_tax: (_ref24 = (_tempOrder$is_price_i = tempOrder.is_price_include_tax) !== null && _tempOrder$is_price_i !== void 0 ? _tempOrder$is_price_i : this.otherParams.is_price_include_tax) !== null && _ref24 !== void 0 ? _ref24 : 1
3518
3181
  }, snapshot.identity.orderId ? {
3519
3182
  payment_order_id: String(snapshot.identity.orderId)
3520
3183
  } : {});
3521
- _context36.next = 12;
3184
+ _context32.next = 12;
3522
3185
  return this.store.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
3523
3186
  case 12:
3524
- result = _context36.sent;
3525
- _context36.next = 15;
3187
+ result = _context32.sent;
3188
+ _context32.next = 15;
3526
3189
  return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
3527
3190
  orderId: snapshot.identity.orderId,
3528
3191
  customerId: walletBusinessData.customer_id,
@@ -3534,14 +3197,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3534
3197
  timestamp: Date.now()
3535
3198
  });
3536
3199
  case 15:
3537
- return _context36.abrupt("return", result);
3200
+ return _context32.abrupt("return", result);
3538
3201
  case 16:
3539
3202
  case "end":
3540
- return _context36.stop();
3203
+ return _context32.stop();
3541
3204
  }
3542
- }, _callee36, this);
3205
+ }, _callee32, this);
3543
3206
  }));
3544
- function initWalletData(_x31) {
3207
+ function initWalletData(_x25) {
3545
3208
  return _initWalletData.apply(this, arguments);
3546
3209
  }
3547
3210
  return initWalletData;
@@ -3568,35 +3231,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3568
3231
  }, {
3569
3232
  key: "getPaymentMethodsAsync",
3570
3233
  value: (function () {
3571
- var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {
3234
+ var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
3572
3235
  var response, paymentMethods;
3573
- return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3574
- while (1) switch (_context37.prev = _context37.next) {
3236
+ return _regeneratorRuntime().wrap(function _callee33$(_context33) {
3237
+ while (1) switch (_context33.prev = _context33.next) {
3575
3238
  case 0:
3576
- _context37.prev = 0;
3577
- _context37.next = 3;
3239
+ _context33.prev = 0;
3240
+ _context33.next = 3;
3578
3241
  return this.request.get('/pay/custom-payment/all', {
3579
3242
  filterPaymentMethods: true
3580
3243
  }, {
3581
3244
  osServer: true
3582
3245
  });
3583
3246
  case 3:
3584
- response = _context37.sent;
3247
+ response = _context33.sent;
3585
3248
  paymentMethods = (response === null || response === void 0 ? void 0 : response.data) || [];
3586
3249
  this.paymentMethodsCache = Array.isArray(paymentMethods) ? _toConsumableArray(paymentMethods) : [];
3587
- return _context37.abrupt("return", this.getPaymentMethods());
3250
+ return _context33.abrupt("return", this.getPaymentMethods());
3588
3251
  case 9:
3589
- _context37.prev = 9;
3590
- _context37.t0 = _context37["catch"](0);
3252
+ _context33.prev = 9;
3253
+ _context33.t0 = _context33["catch"](0);
3591
3254
  this.logWarning('getPaymentMethodsAsync: 获取支付方式列表失败,使用缓存列表', {
3592
- error: _context37.t0 instanceof Error ? _context37.t0.message : String(_context37.t0)
3255
+ error: _context33.t0 instanceof Error ? _context33.t0.message : String(_context33.t0)
3593
3256
  });
3594
- return _context37.abrupt("return", this.getPaymentMethods());
3257
+ return _context33.abrupt("return", this.getPaymentMethods());
3595
3258
  case 13:
3596
3259
  case "end":
3597
- return _context37.stop();
3260
+ return _context33.stop();
3598
3261
  }
3599
- }, _callee37, this, [[0, 9]]);
3262
+ }, _callee33, this, [[0, 9]]);
3600
3263
  }));
3601
3264
  function getPaymentMethodsAsync() {
3602
3265
  return _getPaymentMethodsAsync.apply(this, arguments);
@@ -3609,84 +3272,106 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3609
3272
  return _toConsumableArray(this.paymentMethodsCache);
3610
3273
  }
3611
3274
 
3612
- /** 轻量舍入能力,供现金支付 UI 计算 rounding_amount。 */
3275
+ /**
3276
+ * 按当前店铺的现金舍入配置计算金额,供现金支付 UI 使用。
3277
+ *
3278
+ * 舍入开关取自 CASHMANUAL 支付方式;舍入规则取自
3279
+ * otherParams.order_rounding_setting,金额算法统一由 PaymentModule 维护。
3280
+ */
3613
3281
  }, {
3614
3282
  key: "roundAmount",
3615
- value: function roundAmount(params) {
3616
- var amount = new Decimal(params.amount || 0);
3617
- var interval = new Decimal(params.interval || 0.05);
3618
- var rule = params.rule || 'standard_rounding';
3619
- var quotient = amount.div(interval);
3620
- var roundedQuotient;
3621
- if (rule === 'always_up') {
3622
- roundedQuotient = quotient.ceil();
3623
- } else if (rule === 'always_down') {
3624
- roundedQuotient = quotient.floor();
3625
- } else if (rule === 'standard_down') {
3626
- roundedQuotient = quotient.toDecimalPlaces(0, Decimal.ROUND_HALF_DOWN);
3627
- } else {
3628
- roundedQuotient = quotient.toDecimalPlaces(0, Decimal.ROUND_HALF_UP);
3283
+ value: (function () {
3284
+ var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
3285
+ var _cashManualPayment$me, _this$otherParams$ord2, _this$otherParams$ord3;
3286
+ var amount, cashManualPayment;
3287
+ return _regeneratorRuntime().wrap(function _callee34$(_context34) {
3288
+ while (1) switch (_context34.prev = _context34.next) {
3289
+ case 0:
3290
+ amount = params.amount;
3291
+ cashManualPayment = this.paymentMethodsCache.find(function (paymentMethod) {
3292
+ return paymentMethod.code === 'CASHMANUAL';
3293
+ });
3294
+ if (cashManualPayment !== null && cashManualPayment !== void 0 && (_cashManualPayment$me = cashManualPayment.metadata) !== null && _cashManualPayment$me !== void 0 && _cashManualPayment$me.order_rounding_switch) {
3295
+ _context34.next = 4;
3296
+ break;
3297
+ }
3298
+ return _context34.abrupt("return", {
3299
+ originalAmount: amount.toString(),
3300
+ roundedAmount: amount.toString(),
3301
+ roundingDifference: '0.00'
3302
+ });
3303
+ case 4:
3304
+ if (this.payment) {
3305
+ _context34.next = 6;
3306
+ break;
3307
+ }
3308
+ throw new Error('payment 模块未初始化');
3309
+ case 6:
3310
+ return _context34.abrupt("return", this.payment.roundAmountAsync(amount, (_this$otherParams$ord2 = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord2 === void 0 ? void 0 : _this$otherParams$ord2.interval, (_this$otherParams$ord3 = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord3 === void 0 ? void 0 : _this$otherParams$ord3.type));
3311
+ case 7:
3312
+ case "end":
3313
+ return _context34.stop();
3314
+ }
3315
+ }, _callee34, this);
3316
+ }));
3317
+ function roundAmount(_x26) {
3318
+ return _roundAmount.apply(this, arguments);
3629
3319
  }
3630
- var roundedAmount = roundedQuotient.times(interval).toDecimalPlaces(2);
3631
- return {
3632
- originalAmount: amount.toFixed(2),
3633
- roundedAmount: roundedAmount.toFixed(2),
3634
- roundingDifference: roundedAmount.minus(amount).toFixed(2)
3635
- };
3636
- }
3637
-
3320
+ return roundAmount;
3321
+ }()
3638
3322
  /**
3639
3323
  * 发送支付链接。
3640
3324
  *
3641
3325
  * 如果没有 orderIds 或显式 submitBeforeSend,会先提交当前本地订单到云端;
3642
3326
  * 只有成功拿到远端 order_id 后才调用 OrderModule 发送邮件。
3643
3327
  */
3328
+ )
3644
3329
  }, {
3645
3330
  key: "sendCustomerPayLink",
3646
3331
  value: (function () {
3647
- var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
3648
- var orderIds, _ref26, _ref27, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
3649
- return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3650
- while (1) switch (_context38.prev = _context38.next) {
3332
+ var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
3333
+ var orderIds, _ref25, _ref26, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
3334
+ return _regeneratorRuntime().wrap(function _callee35$(_context35) {
3335
+ while (1) switch (_context35.prev = _context35.next) {
3651
3336
  case 0:
3652
3337
  if (this.store.order) {
3653
- _context38.next = 2;
3338
+ _context35.next = 2;
3654
3339
  break;
3655
3340
  }
3656
3341
  throw new Error('order 模块未初始化');
3657
3342
  case 2:
3658
3343
  orderIds = params.order_ids || params.orderIds || [];
3659
3344
  if (!(!orderIds.length || params.submitBeforeSend)) {
3660
- _context38.next = 11;
3345
+ _context35.next = 11;
3661
3346
  break;
3662
3347
  }
3663
- _context38.next = 6;
3348
+ _context35.next = 6;
3664
3349
  return this.submitSalesOrder({
3665
3350
  smallTicketDataFlag: 1
3666
3351
  });
3667
3352
  case 6:
3668
- submitResult = _context38.sent;
3669
- orderId = (_ref26 = (_ref27 = (_submitResult$data$or = submitResult === null || submitResult === void 0 || (_submitResult$data = submitResult.data) === null || _submitResult$data === void 0 ? void 0 : _submitResult$data.order_id) !== null && _submitResult$data$or !== void 0 ? _submitResult$data$or : submitResult === null || submitResult === void 0 ? void 0 : submitResult.order_id) !== null && _ref27 !== void 0 ? _ref27 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref26 !== void 0 ? _ref26 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
3353
+ submitResult = _context35.sent;
3354
+ orderId = (_ref25 = (_ref26 = (_submitResult$data$or = submitResult === null || submitResult === void 0 || (_submitResult$data = submitResult.data) === null || _submitResult$data === void 0 ? void 0 : _submitResult$data.order_id) !== null && _submitResult$data$or !== void 0 ? _submitResult$data$or : submitResult === null || submitResult === void 0 ? void 0 : submitResult.order_id) !== null && _ref26 !== void 0 ? _ref26 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref25 !== void 0 ? _ref25 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
3670
3355
  if (orderId) {
3671
- _context38.next = 10;
3356
+ _context35.next = 10;
3672
3357
  break;
3673
3358
  }
3674
3359
  throw new Error('本地订单提交云端失败,无法发送支付链接');
3675
3360
  case 10:
3676
3361
  orderIds = [orderId];
3677
3362
  case 11:
3678
- return _context38.abrupt("return", this.store.order.sendCustomerPayLink({
3363
+ return _context35.abrupt("return", this.store.order.sendCustomerPayLink({
3679
3364
  emails: params.emails,
3680
3365
  notify_action: params.notify_action,
3681
3366
  order_ids: orderIds
3682
3367
  }));
3683
3368
  case 12:
3684
3369
  case "end":
3685
- return _context38.stop();
3370
+ return _context35.stop();
3686
3371
  }
3687
- }, _callee38, this);
3372
+ }, _callee35, this);
3688
3373
  }));
3689
- function sendCustomerPayLink(_x32) {
3374
+ function sendCustomerPayLink(_x27) {
3690
3375
  return _sendCustomerPayLink.apply(this, arguments);
3691
3376
  }
3692
3377
  return sendCustomerPayLink;
@@ -3699,27 +3384,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3699
3384
  }, {
3700
3385
  key: "calculateProductBookingPrice",
3701
3386
  value: function () {
3702
- var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
3387
+ var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
3703
3388
  var _params$customer_id;
3704
3389
  var quotation, customerId, authoritativeProduct, product;
3705
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3706
- while (1) switch (_context39.prev = _context39.next) {
3390
+ return _regeneratorRuntime().wrap(function _callee36$(_context36) {
3391
+ while (1) switch (_context36.prev = _context36.next) {
3707
3392
  case 0:
3708
3393
  quotation = this.store.quotation;
3709
3394
  customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : this.getCurrentOrderCustomerId();
3710
- _context39.next = 4;
3395
+ _context36.next = 4;
3711
3396
  return this.loadProductForPriceQuery(params, customerId);
3712
3397
  case 4:
3713
- authoritativeProduct = _context39.sent;
3398
+ authoritativeProduct = _context36.sent;
3714
3399
  product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
3715
- _context39.next = 8;
3400
+ _context36.next = 8;
3716
3401
  return this.loadQuotationForPriceQuery({
3717
3402
  quotation: quotation,
3718
3403
  customer_id: customerId,
3719
3404
  channel: params.channel
3720
3405
  });
3721
3406
  case 8:
3722
- return _context39.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
3407
+ return _context36.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
3723
3408
  product: product,
3724
3409
  fallback_price: authoritativeProduct ? undefined : params.fallback_price,
3725
3410
  customer_id: customerId,
@@ -3727,11 +3412,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3727
3412
  })));
3728
3413
  case 9:
3729
3414
  case "end":
3730
- return _context39.stop();
3415
+ return _context36.stop();
3731
3416
  }
3732
- }, _callee39, this);
3417
+ }, _callee36, this);
3733
3418
  }));
3734
- function calculateProductBookingPrice(_x33) {
3419
+ function calculateProductBookingPrice(_x28) {
3735
3420
  return _calculateProductBookingPrice.apply(this, arguments);
3736
3421
  }
3737
3422
  return calculateProductBookingPrice;
@@ -3739,7 +3424,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3739
3424
  }, {
3740
3425
  key: "getQuotationCustomerScopeInfo",
3741
3426
  value: function getQuotationCustomerScopeInfo() {
3742
- var _this15 = this;
3427
+ var _this13 = this;
3743
3428
  var quotation = this.store.quotation;
3744
3429
  if (quotation && typeof quotation.getQuotationCustomerScopeInfo === 'function') {
3745
3430
  return quotation.getQuotationCustomerScopeInfo();
@@ -3751,7 +3436,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3751
3436
  }).map(function (item) {
3752
3437
  var localSeen = new Set();
3753
3438
  var customers = item.customer.filter(function (customer) {
3754
- var customerId = _this15.normalizePriceContextCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
3439
+ var customerId = _this13.normalizePriceContextCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
3755
3440
  if (!customerId || localSeen.has(customerId)) return false;
3756
3441
  localSeen.add(customerId);
3757
3442
  if (!customerById.has(customerId)) customerById.set(customerId, customer);
@@ -3801,32 +3486,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3801
3486
  }, {
3802
3487
  key: "calculateProductBookingPrices",
3803
3488
  value: function () {
3804
- var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(paramsList) {
3489
+ var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(paramsList) {
3805
3490
  var _paramsList$0$custome,
3806
3491
  _paramsList$,
3807
- _this16 = this,
3492
+ _this14 = this,
3808
3493
  _paramsList$2;
3809
3494
  var quotation, customerId, productMapsByGroup, groups;
3810
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3811
- while (1) switch (_context41.prev = _context41.next) {
3495
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3496
+ while (1) switch (_context38.prev = _context38.next) {
3812
3497
  case 0:
3813
3498
  if (paramsList.length) {
3814
- _context41.next = 2;
3499
+ _context38.next = 2;
3815
3500
  break;
3816
3501
  }
3817
- return _context41.abrupt("return", []);
3502
+ return _context38.abrupt("return", []);
3818
3503
  case 2:
3819
3504
  quotation = this.store.quotation;
3820
3505
  customerId = (_paramsList$0$custome = (_paramsList$ = paramsList[0]) === null || _paramsList$ === void 0 ? void 0 : _paramsList$.customer_id) !== null && _paramsList$0$custome !== void 0 ? _paramsList$0$custome : this.getCurrentOrderCustomerId();
3821
3506
  productMapsByGroup = new Map();
3822
3507
  groups = new Map();
3823
3508
  paramsList.forEach(function (params) {
3824
- var _this16$otherParams;
3509
+ var _this14$otherParams;
3825
3510
  var product = params.product || {};
3826
- var productId = _this16.getPriceQueryProductId(product);
3511
+ var productId = _this14.getPriceQueryProductId(product);
3827
3512
  if (productId === null) return;
3828
- var schedule = _this16.getPriceQuerySchedule(params);
3829
- var channel = params.channel || ((_this16$otherParams = _this16.otherParams) === null || _this16$otherParams === void 0 ? void 0 : _this16$otherParams.channel);
3513
+ var schedule = _this14.getPriceQuerySchedule(params);
3514
+ var channel = params.channel || ((_this14$otherParams = _this14.otherParams) === null || _this14$otherParams === void 0 ? void 0 : _this14$otherParams.channel);
3830
3515
  var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || ''].join('|');
3831
3516
  var group = groups.get(groupKey) || {
3832
3517
  ids: new Set(),
@@ -3836,51 +3521,51 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3836
3521
  group.ids.add(productId);
3837
3522
  groups.set(groupKey, group);
3838
3523
  });
3839
- _context41.next = 9;
3524
+ _context38.next = 9;
3840
3525
  return Promise.all(Array.from(groups.entries()).map( /*#__PURE__*/function () {
3841
- var _ref29 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(_ref28) {
3842
- var _ref30, groupKey, group, productsById;
3843
- return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3844
- while (1) switch (_context40.prev = _context40.next) {
3526
+ var _ref28 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(_ref27) {
3527
+ var _ref29, groupKey, group, productsById;
3528
+ return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3529
+ while (1) switch (_context37.prev = _context37.next) {
3845
3530
  case 0:
3846
- _ref30 = _slicedToArray(_ref28, 2), groupKey = _ref30[0], group = _ref30[1];
3847
- _context40.next = 3;
3848
- return _this16.loadProductsForPriceQuery({
3531
+ _ref29 = _slicedToArray(_ref27, 2), groupKey = _ref29[0], group = _ref29[1];
3532
+ _context37.next = 3;
3533
+ return _this14.loadProductsForPriceQuery({
3849
3534
  ids: Array.from(group.ids),
3850
3535
  schedule: group.schedule,
3851
3536
  customerId: customerId,
3852
3537
  channel: group.channel
3853
3538
  });
3854
3539
  case 3:
3855
- productsById = _context40.sent;
3540
+ productsById = _context37.sent;
3856
3541
  productMapsByGroup.set(groupKey, productsById);
3857
3542
  case 5:
3858
3543
  case "end":
3859
- return _context40.stop();
3544
+ return _context37.stop();
3860
3545
  }
3861
- }, _callee40);
3546
+ }, _callee37);
3862
3547
  }));
3863
- return function (_x35) {
3864
- return _ref29.apply(this, arguments);
3548
+ return function (_x30) {
3549
+ return _ref28.apply(this, arguments);
3865
3550
  };
3866
3551
  }()));
3867
3552
  case 9:
3868
- _context41.next = 11;
3553
+ _context38.next = 11;
3869
3554
  return this.loadQuotationForPriceQuery({
3870
3555
  quotation: quotation,
3871
3556
  customer_id: customerId,
3872
3557
  channel: (_paramsList$2 = paramsList[0]) === null || _paramsList$2 === void 0 ? void 0 : _paramsList$2.channel
3873
3558
  });
3874
3559
  case 11:
3875
- return _context41.abrupt("return", paramsList.map(function (params) {
3876
- var _this16$otherParams2, _productMapsByGroup$g;
3560
+ return _context38.abrupt("return", paramsList.map(function (params) {
3561
+ var _this14$otherParams2, _productMapsByGroup$g;
3877
3562
  var productInput = params.product || {};
3878
- var productId = _this16.getPriceQueryProductId(productInput);
3879
- var schedule = _this16.getPriceQuerySchedule(params);
3880
- var channel = params.channel || ((_this16$otherParams2 = _this16.otherParams) === null || _this16$otherParams2 === void 0 ? void 0 : _this16$otherParams2.channel);
3563
+ var productId = _this14.getPriceQueryProductId(productInput);
3564
+ var schedule = _this14.getPriceQuerySchedule(params);
3565
+ var channel = params.channel || ((_this14$otherParams2 = _this14.otherParams) === null || _this14$otherParams2 === void 0 ? void 0 : _this14$otherParams2.channel);
3881
3566
  var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || ''].join('|');
3882
3567
  var authoritativeProduct = productId === null ? null : ((_productMapsByGroup$g = productMapsByGroup.get(groupKey)) === null || _productMapsByGroup$g === void 0 ? void 0 : _productMapsByGroup$g.get(productId)) || null;
3883
- var product = _this16.mergeProductForPriceQuery(productInput, authoritativeProduct);
3568
+ var product = _this14.mergeProductForPriceQuery(productInput, authoritativeProduct);
3884
3569
  return calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
3885
3570
  product: product,
3886
3571
  fallback_price: authoritativeProduct ? undefined : params.fallback_price,
@@ -3890,11 +3575,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3890
3575
  }));
3891
3576
  case 12:
3892
3577
  case "end":
3893
- return _context41.stop();
3578
+ return _context38.stop();
3894
3579
  }
3895
- }, _callee41, this);
3580
+ }, _callee38, this);
3896
3581
  }));
3897
- function calculateProductBookingPrices(_x34) {
3582
+ function calculateProductBookingPrices(_x29) {
3898
3583
  return _calculateProductBookingPrices.apply(this, arguments);
3899
3584
  }
3900
3585
  return calculateProductBookingPrices;
@@ -3902,34 +3587,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3902
3587
  }, {
3903
3588
  key: "addProductToOrder",
3904
3589
  value: function () {
3905
- var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(product, booking) {
3590
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(product, booking) {
3906
3591
  var products;
3907
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3908
- while (1) switch (_context42.prev = _context42.next) {
3592
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3593
+ while (1) switch (_context39.prev = _context39.next) {
3909
3594
  case 0:
3910
- _context42.prev = 0;
3595
+ _context39.prev = 0;
3911
3596
  if (this.store.order) {
3912
- _context42.next = 3;
3597
+ _context39.next = 3;
3913
3598
  break;
3914
3599
  }
3915
3600
  throw new Error('order 模块未初始化');
3916
3601
  case 3:
3917
- _context42.next = 5;
3602
+ _context39.next = 5;
3918
3603
  return this.store.order.addProductToOrder(product, booking);
3919
3604
  case 5:
3920
- products = _context42.sent;
3921
- return _context42.abrupt("return", products);
3605
+ products = _context39.sent;
3606
+ return _context39.abrupt("return", products);
3922
3607
  case 9:
3923
- _context42.prev = 9;
3924
- _context42.t0 = _context42["catch"](0);
3925
- throw _context42.t0;
3608
+ _context39.prev = 9;
3609
+ _context39.t0 = _context39["catch"](0);
3610
+ throw _context39.t0;
3926
3611
  case 12:
3927
3612
  case "end":
3928
- return _context42.stop();
3613
+ return _context39.stop();
3929
3614
  }
3930
- }, _callee42, this, [[0, 9]]);
3615
+ }, _callee39, this, [[0, 9]]);
3931
3616
  }));
3932
- function addProductToOrder(_x36, _x37) {
3617
+ function addProductToOrder(_x31, _x32) {
3933
3618
  return _addProductToOrder.apply(this, arguments);
3934
3619
  }
3935
3620
  return addProductToOrder;
@@ -3937,34 +3622,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3937
3622
  }, {
3938
3623
  key: "updateOrderProduct",
3939
3624
  value: function () {
3940
- var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
3625
+ var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
3941
3626
  var products;
3942
- return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3943
- while (1) switch (_context43.prev = _context43.next) {
3627
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3628
+ while (1) switch (_context40.prev = _context40.next) {
3944
3629
  case 0:
3945
- _context43.prev = 0;
3630
+ _context40.prev = 0;
3946
3631
  if (this.store.order) {
3947
- _context43.next = 3;
3632
+ _context40.next = 3;
3948
3633
  break;
3949
3634
  }
3950
3635
  throw new Error('order 模块未初始化');
3951
3636
  case 3:
3952
- _context43.next = 5;
3637
+ _context40.next = 5;
3953
3638
  return this.store.order.updateOrderProduct(params);
3954
3639
  case 5:
3955
- products = _context43.sent;
3956
- return _context43.abrupt("return", products);
3640
+ products = _context40.sent;
3641
+ return _context40.abrupt("return", products);
3957
3642
  case 9:
3958
- _context43.prev = 9;
3959
- _context43.t0 = _context43["catch"](0);
3960
- throw _context43.t0;
3643
+ _context40.prev = 9;
3644
+ _context40.t0 = _context40["catch"](0);
3645
+ throw _context40.t0;
3961
3646
  case 12:
3962
3647
  case "end":
3963
- return _context43.stop();
3648
+ return _context40.stop();
3964
3649
  }
3965
- }, _callee43, this, [[0, 9]]);
3650
+ }, _callee40, this, [[0, 9]]);
3966
3651
  }));
3967
- function updateOrderProduct(_x38) {
3652
+ function updateOrderProduct(_x33) {
3968
3653
  return _updateOrderProduct.apply(this, arguments);
3969
3654
  }
3970
3655
  return updateOrderProduct;
@@ -3972,34 +3657,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3972
3657
  }, {
3973
3658
  key: "updateOrderProducts",
3974
3659
  value: function () {
3975
- var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(paramsList) {
3660
+ var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(paramsList) {
3976
3661
  var products;
3977
- return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3978
- while (1) switch (_context44.prev = _context44.next) {
3662
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3663
+ while (1) switch (_context41.prev = _context41.next) {
3979
3664
  case 0:
3980
- _context44.prev = 0;
3665
+ _context41.prev = 0;
3981
3666
  if (this.store.order) {
3982
- _context44.next = 3;
3667
+ _context41.next = 3;
3983
3668
  break;
3984
3669
  }
3985
3670
  throw new Error('order 模块未初始化');
3986
3671
  case 3:
3987
- _context44.next = 5;
3672
+ _context41.next = 5;
3988
3673
  return this.store.order.updateOrderProducts(paramsList);
3989
3674
  case 5:
3990
- products = _context44.sent;
3991
- return _context44.abrupt("return", products);
3675
+ products = _context41.sent;
3676
+ return _context41.abrupt("return", products);
3992
3677
  case 9:
3993
- _context44.prev = 9;
3994
- _context44.t0 = _context44["catch"](0);
3995
- throw _context44.t0;
3678
+ _context41.prev = 9;
3679
+ _context41.t0 = _context41["catch"](0);
3680
+ throw _context41.t0;
3996
3681
  case 12:
3997
3682
  case "end":
3998
- return _context44.stop();
3683
+ return _context41.stop();
3999
3684
  }
4000
- }, _callee44, this, [[0, 9]]);
3685
+ }, _callee41, this, [[0, 9]]);
4001
3686
  }));
4002
- function updateOrderProducts(_x39) {
3687
+ function updateOrderProducts(_x34) {
4003
3688
  return _updateOrderProducts.apply(this, arguments);
4004
3689
  }
4005
3690
  return updateOrderProducts;
@@ -4007,34 +3692,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4007
3692
  }, {
4008
3693
  key: "updateOrderProductQuantity",
4009
3694
  value: function () {
4010
- var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(params) {
3695
+ var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
4011
3696
  var products;
4012
- return _regeneratorRuntime().wrap(function _callee45$(_context45) {
4013
- while (1) switch (_context45.prev = _context45.next) {
3697
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3698
+ while (1) switch (_context42.prev = _context42.next) {
4014
3699
  case 0:
4015
- _context45.prev = 0;
3700
+ _context42.prev = 0;
4016
3701
  if (this.store.order) {
4017
- _context45.next = 3;
3702
+ _context42.next = 3;
4018
3703
  break;
4019
3704
  }
4020
3705
  throw new Error('order 模块未初始化');
4021
3706
  case 3:
4022
- _context45.next = 5;
3707
+ _context42.next = 5;
4023
3708
  return this.store.order.updateOrderProductQuantity(params);
4024
3709
  case 5:
4025
- products = _context45.sent;
4026
- return _context45.abrupt("return", products);
3710
+ products = _context42.sent;
3711
+ return _context42.abrupt("return", products);
4027
3712
  case 9:
4028
- _context45.prev = 9;
4029
- _context45.t0 = _context45["catch"](0);
4030
- throw _context45.t0;
3713
+ _context42.prev = 9;
3714
+ _context42.t0 = _context42["catch"](0);
3715
+ throw _context42.t0;
4031
3716
  case 12:
4032
3717
  case "end":
4033
- return _context45.stop();
3718
+ return _context42.stop();
4034
3719
  }
4035
- }, _callee45, this, [[0, 9]]);
3720
+ }, _callee42, this, [[0, 9]]);
4036
3721
  }));
4037
- function updateOrderProductQuantity(_x40) {
3722
+ function updateOrderProductQuantity(_x35) {
4038
3723
  return _updateOrderProductQuantity.apply(this, arguments);
4039
3724
  }
4040
3725
  return updateOrderProductQuantity;
@@ -4057,12 +3742,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4057
3742
  }, {
4058
3743
  key: "setOrderProductLineNote",
4059
3744
  value: (function () {
4060
- var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(identity, note) {
3745
+ var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(identity, note) {
4061
3746
  var params, products;
4062
- return _regeneratorRuntime().wrap(function _callee46$(_context46) {
4063
- while (1) switch (_context46.prev = _context46.next) {
3747
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3748
+ while (1) switch (_context43.prev = _context43.next) {
4064
3749
  case 0:
4065
- _context46.prev = 0;
3750
+ _context43.prev = 0;
4066
3751
  params = {
4067
3752
  product_id: identity.product_id,
4068
3753
  product_variant_id: identity.product_variant_id,
@@ -4077,22 +3762,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4077
3762
  params.product_sku = identity.product_sku;
4078
3763
  }
4079
3764
  if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
4080
- _context46.next = 7;
3765
+ _context43.next = 7;
4081
3766
  return this.updateOrderProduct(params);
4082
3767
  case 7:
4083
- products = _context46.sent;
4084
- return _context46.abrupt("return", products);
3768
+ products = _context43.sent;
3769
+ return _context43.abrupt("return", products);
4085
3770
  case 11:
4086
- _context46.prev = 11;
4087
- _context46.t0 = _context46["catch"](0);
4088
- throw _context46.t0;
3771
+ _context43.prev = 11;
3772
+ _context43.t0 = _context43["catch"](0);
3773
+ throw _context43.t0;
4089
3774
  case 14:
4090
3775
  case "end":
4091
- return _context46.stop();
3776
+ return _context43.stop();
4092
3777
  }
4093
- }, _callee46, this, [[0, 11]]);
3778
+ }, _callee43, this, [[0, 11]]);
4094
3779
  }));
4095
- function setOrderProductLineNote(_x41, _x42) {
3780
+ function setOrderProductLineNote(_x36, _x37) {
4096
3781
  return _setOrderProductLineNote.apply(this, arguments);
4097
3782
  }
4098
3783
  return setOrderProductLineNote;
@@ -4107,32 +3792,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4107
3792
  }, {
4108
3793
  key: "removeProductsFromOrder",
4109
3794
  value: (function () {
4110
- var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(identities) {
4111
- return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4112
- while (1) switch (_context47.prev = _context47.next) {
3795
+ var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(identities) {
3796
+ return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3797
+ while (1) switch (_context44.prev = _context44.next) {
4113
3798
  case 0:
4114
- _context47.prev = 0;
3799
+ _context44.prev = 0;
4115
3800
  if (this.store.order) {
4116
- _context47.next = 3;
3801
+ _context44.next = 3;
4117
3802
  break;
4118
3803
  }
4119
3804
  throw new Error('order 模块未初始化');
4120
3805
  case 3:
4121
- _context47.next = 5;
3806
+ _context44.next = 5;
4122
3807
  return this.store.order.removeProductsFromOrder(identities);
4123
3808
  case 5:
4124
- return _context47.abrupt("return", _context47.sent);
3809
+ return _context44.abrupt("return", _context44.sent);
4125
3810
  case 8:
4126
- _context47.prev = 8;
4127
- _context47.t0 = _context47["catch"](0);
4128
- throw _context47.t0;
3811
+ _context44.prev = 8;
3812
+ _context44.t0 = _context44["catch"](0);
3813
+ throw _context44.t0;
4129
3814
  case 11:
4130
3815
  case "end":
4131
- return _context47.stop();
3816
+ return _context44.stop();
4132
3817
  }
4133
- }, _callee47, this, [[0, 8]]);
3818
+ }, _callee44, this, [[0, 8]]);
4134
3819
  }));
4135
- function removeProductsFromOrder(_x43) {
3820
+ function removeProductsFromOrder(_x38) {
4136
3821
  return _removeProductsFromOrder.apply(this, arguments);
4137
3822
  }
4138
3823
  return removeProductsFromOrder;
@@ -4140,18 +3825,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4140
3825
  }, {
4141
3826
  key: "removeProductFromOrder",
4142
3827
  value: function () {
4143
- var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(identity) {
4144
- return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4145
- while (1) switch (_context48.prev = _context48.next) {
3828
+ var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(identity) {
3829
+ return _regeneratorRuntime().wrap(function _callee45$(_context45) {
3830
+ while (1) switch (_context45.prev = _context45.next) {
4146
3831
  case 0:
4147
- return _context48.abrupt("return", this.removeProductsFromOrder([identity]));
3832
+ return _context45.abrupt("return", this.removeProductsFromOrder([identity]));
4148
3833
  case 1:
4149
3834
  case "end":
4150
- return _context48.stop();
3835
+ return _context45.stop();
4151
3836
  }
4152
- }, _callee48, this);
3837
+ }, _callee45, this);
4153
3838
  }));
4154
- function removeProductFromOrder(_x44) {
3839
+ function removeProductFromOrder(_x39) {
4155
3840
  return _removeProductFromOrder.apply(this, arguments);
4156
3841
  }
4157
3842
  return removeProductFromOrder;
@@ -4201,23 +3886,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4201
3886
  }, {
4202
3887
  key: "applyPromotion",
4203
3888
  value: (function () {
4204
- var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49() {
4205
- return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4206
- while (1) switch (_context49.prev = _context49.next) {
3889
+ var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
3890
+ return _regeneratorRuntime().wrap(function _callee46$(_context46) {
3891
+ while (1) switch (_context46.prev = _context46.next) {
4207
3892
  case 0:
4208
3893
  if (this.store.order) {
4209
- _context49.next = 2;
3894
+ _context46.next = 2;
4210
3895
  break;
4211
3896
  }
4212
3897
  throw new Error('order 模块未初始化');
4213
3898
  case 2:
4214
- _context49.next = 4;
3899
+ _context46.next = 4;
4215
3900
  return this.store.order.applyPromotion();
4216
3901
  case 4:
4217
3902
  case "end":
4218
- return _context49.stop();
3903
+ return _context46.stop();
4219
3904
  }
4220
- }, _callee49, this);
3905
+ }, _callee46, this);
4221
3906
  }));
4222
3907
  function applyPromotion() {
4223
3908
  return _applyPromotion.apply(this, arguments);
@@ -4244,18 +3929,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4244
3929
  }, {
4245
3930
  key: "getProductList",
4246
3931
  value: function () {
4247
- var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50() {
4248
- var _this$otherParams25;
3932
+ var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47() {
3933
+ var _this$otherParams21;
4249
3934
  var menu_list_ids, _this$store$products, res;
4250
- return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4251
- while (1) switch (_context50.prev = _context50.next) {
3935
+ return _regeneratorRuntime().wrap(function _callee47$(_context47) {
3936
+ while (1) switch (_context47.prev = _context47.next) {
4252
3937
  case 0:
4253
3938
  // 可以直接通过配置里的 menu 读取
4254
- menu_list_ids = ((_this$otherParams25 = this.otherParams) === null || _this$otherParams25 === void 0 || (_this$otherParams25 = _this$otherParams25.dineInConfig) === null || _this$otherParams25 === void 0 ? void 0 : _this$otherParams25['menu.associated_menus'].map(function (n) {
3939
+ menu_list_ids = ((_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 || (_this$otherParams21 = _this$otherParams21.dineInConfig) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21['menu.associated_menus'].map(function (n) {
4255
3940
  return Number(n.value);
4256
3941
  })) || [];
4257
- _context50.prev = 1;
4258
- _context50.next = 4;
3942
+ _context47.prev = 1;
3943
+ _context47.next = 4;
4259
3944
  return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
4260
3945
  menu_list_ids: menu_list_ids,
4261
3946
  cacheId: this.cacheId,
@@ -4263,17 +3948,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4263
3948
  schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
4264
3949
  });
4265
3950
  case 4:
4266
- res = _context50.sent;
4267
- return _context50.abrupt("return", res);
3951
+ res = _context47.sent;
3952
+ return _context47.abrupt("return", res);
4268
3953
  case 8:
4269
- _context50.prev = 8;
4270
- _context50.t0 = _context50["catch"](1);
4271
- throw _context50.t0;
3954
+ _context47.prev = 8;
3955
+ _context47.t0 = _context47["catch"](1);
3956
+ throw _context47.t0;
4272
3957
  case 11:
4273
3958
  case "end":
4274
- return _context50.stop();
3959
+ return _context47.stop();
4275
3960
  }
4276
- }, _callee50, this, [[1, 8]]);
3961
+ }, _callee47, this, [[1, 8]]);
4277
3962
  }));
4278
3963
  function getProductList() {
4279
3964
  return _getProductList.apply(this, arguments);
@@ -4288,33 +3973,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4288
3973
  }, {
4289
3974
  key: "setOtherParams",
4290
3975
  value: function () {
4291
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
4292
- var _this$otherParams26;
4293
- var _ref31,
4294
- _ref31$cover,
3976
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(params) {
3977
+ var _this$otherParams22;
3978
+ var _ref30,
3979
+ _ref30$cover,
4295
3980
  cover,
4296
- _args51 = arguments;
4297
- return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4298
- while (1) switch (_context51.prev = _context51.next) {
3981
+ _args48 = arguments;
3982
+ return _regeneratorRuntime().wrap(function _callee48$(_context48) {
3983
+ while (1) switch (_context48.prev = _context48.next) {
4299
3984
  case 0:
4300
- _ref31 = _args51.length > 1 && _args51[1] !== undefined ? _args51[1] : {}, _ref31$cover = _ref31.cover, cover = _ref31$cover === void 0 ? false : _ref31$cover;
3985
+ _ref30 = _args48.length > 1 && _args48[1] !== undefined ? _args48[1] : {}, _ref30$cover = _ref30.cover, cover = _ref30$cover === void 0 ? false : _ref30$cover;
4301
3986
  if (cover) {
4302
3987
  this.otherParams = _objectSpread({}, params);
4303
3988
  } else {
4304
3989
  this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
4305
3990
  }
4306
- this.cacheId = (_this$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26.cacheId;
4307
- _context51.next = 5;
3991
+ this.cacheId = (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.cacheId;
3992
+ _context48.next = 5;
4308
3993
  return this.syncOtherParamsToSubModules(params, {
4309
3994
  cover: cover
4310
3995
  });
4311
3996
  case 5:
4312
3997
  case "end":
4313
- return _context51.stop();
3998
+ return _context48.stop();
4314
3999
  }
4315
- }, _callee51, this);
4000
+ }, _callee48, this);
4316
4001
  }));
4317
- function setOtherParams(_x45) {
4002
+ function setOtherParams(_x40) {
4318
4003
  return _setOtherParams.apply(this, arguments);
4319
4004
  }
4320
4005
  return setOtherParams;