@pisell/pisellos 2.2.263 → 2.2.265

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 (52) hide show
  1. package/dist/modules/Order/index.d.ts +27 -8
  2. package/dist/modules/Order/index.js +736 -473
  3. package/dist/modules/Order/payment-utils.d.ts +26 -0
  4. package/dist/modules/Order/payment-utils.js +225 -0
  5. package/dist/modules/Order/types.d.ts +33 -1
  6. package/dist/modules/Order/utils/orderCollectionIdentity.js +7 -2
  7. package/dist/modules/Order/utils.js +8 -5
  8. package/dist/modules/Payment/index.d.ts +2 -0
  9. package/dist/modules/Payment/index.js +78 -49
  10. package/dist/modules/Payment/types.d.ts +26 -24
  11. package/dist/modules/Payment/types.js +2 -0
  12. package/dist/server/index.d.ts +16 -0
  13. package/dist/server/index.js +1940 -1043
  14. package/dist/server/modules/order/index.d.ts +49 -4
  15. package/dist/server/modules/order/index.js +1577 -698
  16. package/dist/server/modules/order/types.d.ts +11 -3
  17. package/dist/server/modules/order/types.js +1 -1
  18. package/dist/solution/BaseSales/index.d.ts +33 -3
  19. package/dist/solution/BaseSales/index.js +653 -340
  20. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
  21. package/dist/solution/BookingByStep/index.d.ts +1 -1
  22. package/dist/solution/BookingTicket/index.js +2 -1
  23. package/dist/solution/Sales/index.d.ts +1 -0
  24. package/dist/solution/Sales/index.js +10 -2
  25. package/dist/utils/payment-number.d.ts +9 -0
  26. package/dist/utils/payment-number.js +69 -0
  27. package/lib/model/strategy/adapter/promotion/index.js +49 -0
  28. package/lib/modules/Order/index.d.ts +27 -8
  29. package/lib/modules/Order/index.js +180 -60
  30. package/lib/modules/Order/payment-utils.d.ts +26 -0
  31. package/lib/modules/Order/payment-utils.js +224 -0
  32. package/lib/modules/Order/types.d.ts +33 -1
  33. package/lib/modules/Order/utils/orderCollectionIdentity.js +3 -0
  34. package/lib/modules/Order/utils.js +5 -3
  35. package/lib/modules/Payment/index.d.ts +2 -0
  36. package/lib/modules/Payment/index.js +33 -12
  37. package/lib/modules/Payment/types.d.ts +26 -24
  38. package/lib/server/index.d.ts +16 -0
  39. package/lib/server/index.js +670 -18
  40. package/lib/server/modules/order/index.d.ts +49 -4
  41. package/lib/server/modules/order/index.js +657 -66
  42. package/lib/server/modules/order/types.d.ts +11 -3
  43. package/lib/solution/BaseSales/index.d.ts +33 -3
  44. package/lib/solution/BaseSales/index.js +193 -9
  45. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
  46. package/lib/solution/BookingByStep/index.d.ts +1 -1
  47. package/lib/solution/BookingTicket/index.js +2 -1
  48. package/lib/solution/Sales/index.d.ts +1 -0
  49. package/lib/solution/Sales/index.js +5 -3
  50. package/lib/utils/payment-number.d.ts +9 -0
  51. package/lib/utils/payment-number.js +64 -0
  52. package/package.json +1 -1
@@ -37,6 +37,8 @@ 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";
40
42
  import { applyOrderCollectionUidRemaps, getOrderCollectionPersistentId, getOrderCollectionReferenceUid, getOrderCollectionUid, isSameOrderCollectionItem, mergeOrderCollectionItems, normalizeOrderCollection, normalizeOrderCollections, setOrderCollectionUid } from "../../modules/Order/utils/orderCollectionIdentity";
41
43
  import dayjs from 'dayjs';
42
44
  export * from "./types";
@@ -72,6 +74,10 @@ function preserveManualProductDiscountProducts(previousProducts, nextProducts) {
72
74
  function isBaseSalesHistoricalDiscountEntry(discount) {
73
75
  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);
74
76
  }
77
+ function getBaseSalesUniqueArrayMetadataKey(key) {
78
+ if (key === 'products' || key === 'bookings') return 'unique_identification_number';
79
+ return null;
80
+ }
75
81
  var BASE_SALES_PERSISTENT_ID_FIELD_BY_KIND = {
76
82
  product: 'order_detail_id',
77
83
  booking: 'schedule_event_id',
@@ -143,6 +149,15 @@ function mergeBaseSalesCollectionItem(kind, currentItem, incomingItem, uidRemaps
143
149
  return kind === 'product' ? mergeBaseSalesProductSnapshotFields(currentItem, mergedItem) : mergedItem;
144
150
  }
145
151
  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
+ }
146
161
  var currentItems = normalizeOrderCollection(kind, currentValue, {
147
162
  ensureUid: false
148
163
  }).items;
@@ -189,6 +204,34 @@ function normalizeBaseSalesRecordCollections(sourceRecord, options) {
189
204
  }
190
205
  return normalizedRecord;
191
206
  }
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
+ }
192
235
  function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, strategy) {
193
236
  var normalizedLoadedRecord = normalizeBaseSalesRecordCollections(loadedRecord || {}, {
194
237
  ensureUid: false
@@ -206,6 +249,15 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, str
206
249
  return mergeBaseSalesOrderCollection(collectionKind, Array.isArray(currentValue) ? currentValue : [], loadedValue, strategy, uidRemaps);
207
250
  }
208
251
  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
+ }
209
261
  return [].concat(_toConsumableArray(cloneDeep(currentValue)), _toConsumableArray(cloneDeep(loadedValue)));
210
262
  }
211
263
  if (Array.isArray(loadedValue)) return cloneDeep(loadedValue);
@@ -217,6 +269,22 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, str
217
269
  delete mergedRecord.request_unique_idempotency_token;
218
270
  return normalizeBaseSalesRecordCollections(applyOrderCollectionUidRemaps(mergedRecord, uidRemaps));
219
271
  }
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
+ }
220
288
  export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
221
289
  _inherits(BaseSalesImpl, _BaseModule);
222
290
  var _super = _createSuper(BaseSalesImpl);
@@ -1080,6 +1148,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1080
1148
  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');
1081
1149
  return coreData === null || coreData === void 0 ? void 0 : coreData[key];
1082
1150
  }
1151
+ }, {
1152
+ key: "getPaymentNumberDevicePrefixSync",
1153
+ value: function getPaymentNumberDevicePrefixSync() {
1154
+ var _this7 = this;
1155
+ if (!this.appPlugin) return 'LOCAL';
1156
+ return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
1157
+ return _this7.getAppData(key);
1158
+ });
1159
+ }
1160
+ }, {
1161
+ key: "getPaymentNumberDevicePrefixAsync",
1162
+ value: function getPaymentNumberDevicePrefixAsync() {
1163
+ var _this8 = this;
1164
+ if (!this.appPlugin) return Promise.resolve('LOCAL');
1165
+ return resolvePaymentNumberDevicePrefix(function (key) {
1166
+ return _this8.getAppData(key);
1167
+ });
1168
+ }
1083
1169
  }, {
1084
1170
  key: "syncAppDataToTempOrder",
1085
1171
  value: function syncAppDataToTempOrder(tempOrder) {
@@ -1123,7 +1209,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1123
1209
  value: function () {
1124
1210
  var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(core) {
1125
1211
  var _this$otherParams4,
1126
- _this7 = this,
1212
+ _this9 = this,
1127
1213
  _this$otherParams5;
1128
1214
  var options,
1129
1215
  app,
@@ -1156,24 +1242,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1156
1242
  targetCacheData = this.readSessionCacheData();
1157
1243
  moduleNames = this.getRegisteredModuleNames();
1158
1244
  moduleNames.forEach(function (step) {
1159
- var reusedModule = _this7.getReusableSharedSubModule(step);
1245
+ var reusedModule = _this9.getReusableSharedSubModule(step);
1160
1246
  if (reusedModule) {
1161
- _this7.store[step] = reusedModule;
1162
- _this7.reusedSharedSubModuleNames.add(step);
1247
+ _this9.store[step] = reusedModule;
1248
+ _this9.reusedSharedSubModuleNames.add(step);
1163
1249
  return;
1164
1250
  }
1165
- var targetModule = _this7.createSubModule(step);
1251
+ var targetModule = _this9.createSubModule(step);
1166
1252
  if (!targetModule) {
1167
1253
  throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
1168
1254
  }
1169
- var hooks = _this7.getSubModuleHooks(step);
1170
- _this7.store[step] = targetModule;
1171
- _this7.core.registerModule(targetModule, _objectSpread(_objectSpread({
1255
+ var hooks = _this9.getSubModuleHooks(step);
1256
+ _this9.store[step] = targetModule;
1257
+ _this9.core.registerModule(targetModule, _objectSpread(_objectSpread({
1172
1258
  initialState: (targetCacheData === null || targetCacheData === void 0 ? void 0 : targetCacheData[targetModule.name]) || {}
1173
1259
  }, hooks ? {
1174
1260
  hooks: hooks
1175
1261
  } : {}), {}, {
1176
- otherParams: _this7.buildSubModuleOtherParams()
1262
+ otherParams: _this9.buildSubModuleOtherParams()
1177
1263
  }));
1178
1264
  });
1179
1265
  if (!(this.store.schedule && !this.isScheduleListLoaded(this.store.schedule))) {
@@ -1207,15 +1293,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1207
1293
  value: function () {
1208
1294
  var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
1209
1295
  var _this$serverOrderChan2,
1210
- _this8 = this;
1296
+ _this10 = this;
1211
1297
  return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1212
1298
  while (1) switch (_context12.prev = _context12.next) {
1213
1299
  case 0:
1214
1300
  (_this$serverOrderChan2 = this.serverOrderChangeUnsubscribe) === null || _this$serverOrderChan2 === void 0 || _this$serverOrderChan2.call(this);
1215
1301
  this.serverOrderChangeUnsubscribe = null;
1216
1302
  Object.keys(this.store).forEach(function (key) {
1217
- if (_this8.reusedSharedSubModuleNames.has(key)) return;
1218
- var sub = _this8.store[key];
1303
+ if (_this10.reusedSharedSubModuleNames.has(key)) return;
1304
+ var sub = _this10.store[key];
1219
1305
  if (sub && typeof sub.destroy === 'function') {
1220
1306
  try {
1221
1307
  sub.destroy();
@@ -1253,7 +1339,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1253
1339
  key: "loadSalesDetail",
1254
1340
  value: (function () {
1255
1341
  var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderIdOrParams) {
1256
- var loadSequence, _ref17, _ref18, _ref19, _ref20, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, remoteRecord, currentTempOrder, record;
1342
+ var loadSequence, _ref17, _ref18, _ref19, _ref20, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, remoteRecord, currentTempOrder, mergedRecord, record;
1257
1343
  return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1258
1344
  while (1) switch (_context13.prev = _context13.next) {
1259
1345
  case 0:
@@ -1302,39 +1388,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1302
1388
  message = loadedRecord && (loadedRecord.message || loadedRecord.msg) || "\u52A0\u8F7D\u9500\u552E\u8BE6\u60C5\u5931\u8D25: ".concat(lookup);
1303
1389
  throw new Error(message);
1304
1390
  case 22:
1305
- remoteRecord = preloadedSalesDetail !== null && preloadedSalesDetail !== void 0 ? preloadedSalesDetail : loadedRecord.data;
1391
+ remoteRecord = filterPendingPaymentsFromLoadedSalesDetail(preloadedSalesDetail !== null && preloadedSalesDetail !== void 0 ? preloadedSalesDetail : loadedRecord.data);
1306
1392
  currentTempOrder = params.merge ? this.store.order.getTempOrder() : null;
1307
- record = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder, remoteRecord, 'preserve-local') : remoteRecord;
1308
- _context13.next = 27;
1393
+ mergedRecord = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder, remoteRecord, 'preserve-local') : remoteRecord;
1394
+ record = filterPendingPaymentsFromLoadedSalesDetail(mergedRecord);
1395
+ _context13.next = 28;
1309
1396
  return this.hydrateLatestLoadedSalesDetail(record, loadSequence);
1310
- case 27:
1311
- return _context13.abrupt("return", _context13.sent);
1312
1397
  case 28:
1313
- _context13.prev = 28;
1398
+ return _context13.abrupt("return", _context13.sent);
1399
+ case 29:
1400
+ _context13.prev = 29;
1314
1401
  this.salesDetailLoadInFlightCount = Math.max(0, this.salesDetailLoadInFlightCount - 1);
1315
1402
  if (!(this.salesDetailLoadInFlightCount === 0)) {
1316
- _context13.next = 39;
1403
+ _context13.next = 40;
1317
1404
  break;
1318
1405
  }
1319
- _context13.prev = 31;
1320
- _context13.next = 34;
1406
+ _context13.prev = 32;
1407
+ _context13.next = 35;
1321
1408
  return this.drainQueuedServerOrderChanges();
1322
- case 34:
1323
- _context13.next = 39;
1409
+ case 35:
1410
+ _context13.next = 40;
1324
1411
  break;
1325
- case 36:
1326
- _context13.prev = 36;
1327
- _context13.t1 = _context13["catch"](31);
1412
+ case 37:
1413
+ _context13.prev = 37;
1414
+ _context13.t1 = _context13["catch"](32);
1328
1415
  this.logError('drain queued server order changes failed', {
1329
1416
  error: _context13.t1 instanceof Error ? _context13.t1.message : String(_context13.t1)
1330
1417
  });
1331
- case 39:
1332
- return _context13.finish(28);
1333
1418
  case 40:
1419
+ return _context13.finish(29);
1420
+ case 41:
1334
1421
  case "end":
1335
1422
  return _context13.stop();
1336
1423
  }
1337
- }, _callee13, this, [[4,, 28, 40], [31, 36]]);
1424
+ }, _callee13, this, [[4,, 29, 41], [32, 37]]);
1338
1425
  }));
1339
1426
  function loadSalesDetail(_x11) {
1340
1427
  return _loadSalesDetail.apply(this, arguments);
@@ -1762,10 +1849,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1762
1849
  }, {
1763
1850
  key: "getHistoricalProductDiscountList",
1764
1851
  value: function getHistoricalProductDiscountList(products) {
1765
- var _this9 = this;
1852
+ var _this11 = this;
1766
1853
  var historyDiscountList = [];
1767
1854
  products.forEach(function (item) {
1768
- if (!_this9.isPersistedOrderProduct(item)) return;
1855
+ if (!_this11.isPersistedOrderProduct(item)) return;
1769
1856
  (item.discount_list || []).forEach(function (discount) {
1770
1857
  var _discount$discount, _discount$metadata, _discount$discount2, _discount$discount3, _discount$discount4;
1771
1858
  var discountId = ((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) || discount.id;
@@ -1825,11 +1912,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1825
1912
  }, {
1826
1913
  key: "shouldSkipAutoApplyFetchedDiscountsInEditMode",
1827
1914
  value: function shouldSkipAutoApplyFetchedDiscountsInEditMode(params) {
1828
- var _this10 = this;
1915
+ var _this12 = this;
1829
1916
  if (params.discountAction !== 'edit') return false;
1830
1917
  if (!params.products.length) return false;
1831
1918
  var hasDraftProduct = params.products.some(function (product) {
1832
- return !_this10.isPersistedOrderProduct(product);
1919
+ return !_this12.isPersistedOrderProduct(product);
1833
1920
  });
1834
1921
  if (hasDraftProduct) return false;
1835
1922
  var hasSelectedDiscount = params.currentDiscountList.some(function (discount) {
@@ -2632,11 +2719,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2632
2719
  return submitSalesOrder;
2633
2720
  }())
2634
2721
  }, {
2635
- key: "submitTempOrderAsync",
2722
+ key: "saveSalesOrderDraft",
2636
2723
  value: function () {
2637
- var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
2638
- var _this$otherParams10, _this$otherParams11, _this$otherParams12, _this$otherParams13;
2639
- var inferredPaymentStatus, submitParams;
2724
+ var _saveSalesOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
2725
+ var _params$platform, _this$otherParams10, _ref22, _params$businessCode, _this$otherParams11, _this$otherParams12, _params$channel, _params$type, _this$otherParams13;
2640
2726
  return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2641
2727
  while (1) switch (_context28.prev = _context28.next) {
2642
2728
  case 0:
@@ -2645,14 +2731,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2645
2731
  break;
2646
2732
  }
2647
2733
  throw new Error('BaseSales 解决方案需要 order 模块支持');
2734
+ case 2:
2735
+ return _context28.abrupt("return", this.store.order.saveTempOrderAsDraft(_objectSpread({
2736
+ cacheId: this.cacheId,
2737
+ 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,
2738
+ 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,
2739
+ channel: (_params$channel = params === null || params === void 0 ? void 0 : params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel(),
2740
+ 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
2741
+ }, (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
2742
+ enhancePayload: params.enhancePayload
2743
+ } : {})));
2744
+ case 3:
2745
+ case "end":
2746
+ return _context28.stop();
2747
+ }
2748
+ }, _callee28, this);
2749
+ }));
2750
+ function saveSalesOrderDraft(_x22) {
2751
+ return _saveSalesOrderDraft.apply(this, arguments);
2752
+ }
2753
+ return saveSalesOrderDraft;
2754
+ }()
2755
+ }, {
2756
+ key: "submitTempOrderAsync",
2757
+ value: function () {
2758
+ var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
2759
+ var _this$otherParams14, _this$otherParams15, _this$otherParams16, _this$otherParams17;
2760
+ var inferredPaymentStatus, submitParams;
2761
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2762
+ while (1) switch (_context29.prev = _context29.next) {
2763
+ case 0:
2764
+ if (this.store.order) {
2765
+ _context29.next = 2;
2766
+ break;
2767
+ }
2768
+ throw new Error('BaseSales 解决方案需要 order 模块支持');
2648
2769
  case 2:
2649
2770
  inferredPaymentStatus = this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
2650
2771
  submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
2651
2772
  cacheId: this.cacheId,
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),
2773
+ platform: (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.platform,
2774
+ 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),
2654
2775
  channel: this.getSubmitOrderSalesChannel(),
2655
- type: (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.type
2776
+ type: (_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.type
2656
2777
  }, (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
2657
2778
  payments: params.payments
2658
2779
  } : {}), inferredPaymentStatus !== undefined ? {
@@ -2664,14 +2785,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2664
2785
  } : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
2665
2786
  enhancePayload: params.enhancePayload
2666
2787
  } : {});
2667
- return _context28.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
2788
+ return _context29.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
2668
2789
  case 5:
2669
2790
  case "end":
2670
- return _context28.stop();
2791
+ return _context29.stop();
2671
2792
  }
2672
- }, _callee28, this);
2793
+ }, _callee29, this);
2673
2794
  }));
2674
- function submitTempOrderAsync(_x22) {
2795
+ function submitTempOrderAsync(_x23) {
2675
2796
  return _submitTempOrderAsync.apply(this, arguments);
2676
2797
  }
2677
2798
  return submitTempOrderAsync;
@@ -2679,14 +2800,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2679
2800
  }, {
2680
2801
  key: "printLocalOrderReceipt",
2681
2802
  value: function () {
2682
- var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(lookup) {
2683
- var _this$otherParams14, _this$otherParams15, _this$otherParams16, _this$otherParams17;
2803
+ var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(lookup) {
2804
+ var _this$otherParams18, _this$otherParams19, _this$otherParams20, _this$otherParams21;
2684
2805
  var hasLookup, lookupPayload, context, payload, response, _this$store$order$app, _this$store$order5, _data;
2685
- return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2686
- while (1) switch (_context29.prev = _context29.next) {
2806
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2807
+ while (1) switch (_context30.prev = _context30.next) {
2687
2808
  case 0:
2688
2809
  if (this.store.order) {
2689
- _context29.next = 2;
2810
+ _context30.next = 2;
2690
2811
  break;
2691
2812
  }
2692
2813
  throw new Error('BaseSales 解决方案需要 order 模块支持');
@@ -2698,10 +2819,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2698
2819
  external_sale_number: lookup
2699
2820
  };
2700
2821
  context = {
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),
2822
+ platform: (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.platform,
2823
+ 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),
2703
2824
  channel: this.getSubmitOrderSalesChannel(),
2704
- type: (_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.type
2825
+ type: (_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.type
2705
2826
  };
2706
2827
  payload = hasLookup ? _objectSpread(_objectSpread({}, lookupPayload), {}, {
2707
2828
  lookup_order_from_db: 1,
@@ -2717,28 +2838,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2717
2838
  channel: context.channel,
2718
2839
  type: context.type
2719
2840
  });
2720
- _context29.next = 8;
2841
+ _context30.next = 8;
2721
2842
  return this.request.post('/local/print-order', payload, {
2722
2843
  osServer: true,
2723
2844
  customToast: function customToast() {}
2724
2845
  });
2725
2846
  case 8:
2726
- response = _context29.sent;
2847
+ response = _context30.sent;
2727
2848
  if (hasLookup) {
2728
- _context29.next = 12;
2849
+ _context30.next = 12;
2729
2850
  break;
2730
2851
  }
2731
- _context29.next = 12;
2852
+ _context30.next = 12;
2732
2853
  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);
2733
2854
  case 12:
2734
- return _context29.abrupt("return", response);
2855
+ return _context30.abrupt("return", response);
2735
2856
  case 13:
2736
2857
  case "end":
2737
- return _context29.stop();
2858
+ return _context30.stop();
2738
2859
  }
2739
- }, _callee29, this);
2860
+ }, _callee30, this);
2740
2861
  }));
2741
- function printLocalOrderReceipt(_x23) {
2862
+ function printLocalOrderReceipt(_x24) {
2742
2863
  return _printLocalOrderReceipt.apply(this, arguments);
2743
2864
  }
2744
2865
  return printLocalOrderReceipt;
@@ -2759,20 +2880,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2759
2880
  }, {
2760
2881
  key: "syncPaymentsToOrder",
2761
2882
  value: function () {
2762
- var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
2763
- var _ref22, _params$businessCode, _this$otherParams18, _this$otherParams19, _params$channel;
2883
+ var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
2884
+ var _ref23, _params$businessCode2, _this$otherParams22, _this$otherParams23, _params$channel2;
2764
2885
  var businessCode, channel, syncParams, syncState, payments, syncResult, latestPayments, amountSnapshot, orderSnapshot, syncPayload;
2765
- return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2766
- while (1) switch (_context30.prev = _context30.next) {
2886
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2887
+ while (1) switch (_context31.prev = _context31.next) {
2767
2888
  case 0:
2768
2889
  if (this.store.order) {
2769
- _context30.next = 2;
2890
+ _context31.next = 2;
2770
2891
  break;
2771
2892
  }
2772
2893
  throw new Error('order 模块未初始化');
2773
2894
  case 2:
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();
2895
+ 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;
2896
+ channel = (_params$channel2 = params.channel) !== null && _params$channel2 !== void 0 ? _params$channel2 : this.getSubmitOrderSalesChannel();
2776
2897
  syncParams = _objectSpread(_objectSpread(_objectSpread({}, params), businessCode !== undefined ? {
2777
2898
  businessCode: businessCode
2778
2899
  } : {}), channel !== undefined ? {
@@ -2780,14 +2901,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2780
2901
  } : {});
2781
2902
  syncState = this.store.order.getOrderSyncState();
2782
2903
  if (!(params.submitWhenPaid && syncState === 'submitting')) {
2783
- _context30.next = 9;
2904
+ _context31.next = 9;
2784
2905
  break;
2785
2906
  }
2786
2907
  this.queueLatestAutoPaymentSync();
2787
- return _context30.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
2908
+ return _context31.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
2788
2909
  case 9:
2789
2910
  payments = params.payments || [];
2790
- _context30.next = 12;
2911
+ _context31.next = 12;
2791
2912
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncStart, {
2792
2913
  payments: payments,
2793
2914
  params: syncParams,
@@ -2795,11 +2916,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2795
2916
  orderSnapshot: this.store.order.getOrderSnapshot()
2796
2917
  });
2797
2918
  case 12:
2798
- _context30.prev = 12;
2799
- _context30.next = 15;
2919
+ _context31.prev = 12;
2920
+ _context31.next = 15;
2800
2921
  return this.store.order.syncPaymentsToOrder(syncParams);
2801
2922
  case 15:
2802
- syncResult = _context30.sent;
2923
+ syncResult = _context31.sent;
2803
2924
  latestPayments = this.store.order.getOrderPayments();
2804
2925
  amountSnapshot = this.store.order.getOrderAmountSnapshot();
2805
2926
  orderSnapshot = this.store.order.getOrderSnapshot();
@@ -2817,25 +2938,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2817
2938
  depositAmount: syncResult.depositAmount,
2818
2939
  orderExpectedAmount: syncResult.orderExpectedAmount
2819
2940
  };
2820
- _context30.next = 22;
2941
+ _context31.next = 22;
2821
2942
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, syncPayload);
2822
2943
  case 22:
2823
2944
  if (!(syncResult.isDepositFullyPaid && !syncResult.isOrderFullyPaid)) {
2824
- _context30.next = 25;
2945
+ _context31.next = 25;
2825
2946
  break;
2826
2947
  }
2827
- _context30.next = 25;
2948
+ _context31.next = 25;
2828
2949
  return this.effectsEmit(BaseSalesHookNames.onDepositPaymentSyncEnd, syncPayload);
2829
2950
  case 25:
2830
2951
  this.scheduleQueuedAutoPaymentSyncFlush(0);
2831
- return _context30.abrupt("return", syncResult);
2952
+ return _context31.abrupt("return", syncResult);
2832
2953
  case 29:
2833
- _context30.prev = 29;
2834
- _context30.t0 = _context30["catch"](12);
2835
- _context30.next = 33;
2954
+ _context31.prev = 29;
2955
+ _context31.t0 = _context31["catch"](12);
2956
+ _context31.next = 33;
2836
2957
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
2837
2958
  ok: false,
2838
- error: _context30.t0,
2959
+ error: _context31.t0,
2839
2960
  payments: this.store.order.getOrderPayments(),
2840
2961
  params: syncParams,
2841
2962
  amountSnapshot: this.store.order.getOrderAmountSnapshot(),
@@ -2843,14 +2964,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2843
2964
  });
2844
2965
  case 33:
2845
2966
  this.scheduleQueuedAutoPaymentSyncFlush(0);
2846
- throw _context30.t0;
2967
+ throw _context31.t0;
2847
2968
  case 35:
2848
2969
  case "end":
2849
- return _context30.stop();
2970
+ return _context31.stop();
2850
2971
  }
2851
- }, _callee30, this, [[12, 29]]);
2972
+ }, _callee31, this, [[12, 29]]);
2852
2973
  }));
2853
- function syncPaymentsToOrder(_x24) {
2974
+ function syncPaymentsToOrder(_x25) {
2854
2975
  return _syncPaymentsToOrder.apply(this, arguments);
2855
2976
  }
2856
2977
  return syncPaymentsToOrder;
@@ -2887,58 +3008,58 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2887
3008
  }, {
2888
3009
  key: "scheduleQueuedAutoPaymentSyncFlush",
2889
3010
  value: function scheduleQueuedAutoPaymentSyncFlush() {
2890
- var _this11 = this;
3011
+ var _this13 = this;
2891
3012
  var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;
2892
3013
  if (!this.queuedAutoPaymentSync) return;
2893
3014
  if (this.autoPaymentSyncTimer) return;
2894
3015
  this.autoPaymentSyncTimer = setTimeout(function () {
2895
- _this11.autoPaymentSyncTimer = null;
2896
- void _this11.flushQueuedAutoPaymentSync();
3016
+ _this13.autoPaymentSyncTimer = null;
3017
+ void _this13.flushQueuedAutoPaymentSync();
2897
3018
  }, delay);
2898
3019
  }
2899
3020
  }, {
2900
3021
  key: "flushQueuedAutoPaymentSync",
2901
3022
  value: function () {
2902
- var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
3023
+ var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
2903
3024
  var payments;
2904
- return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2905
- while (1) switch (_context31.prev = _context31.next) {
3025
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
3026
+ while (1) switch (_context32.prev = _context32.next) {
2906
3027
  case 0:
2907
3028
  if (this.store.order) {
2908
- _context31.next = 2;
3029
+ _context32.next = 2;
2909
3030
  break;
2910
3031
  }
2911
- return _context31.abrupt("return");
3032
+ return _context32.abrupt("return");
2912
3033
  case 2:
2913
3034
  if (!(!this.queuedAutoPaymentSync || this.autoPaymentSyncFlushing)) {
2914
- _context31.next = 4;
3035
+ _context32.next = 4;
2915
3036
  break;
2916
3037
  }
2917
- return _context31.abrupt("return");
3038
+ return _context32.abrupt("return");
2918
3039
  case 4:
2919
3040
  if (!(this.store.order.getOrderSyncState() === 'submitting')) {
2920
- _context31.next = 7;
3041
+ _context32.next = 7;
2921
3042
  break;
2922
3043
  }
2923
3044
  this.scheduleQueuedAutoPaymentSyncFlush();
2924
- return _context31.abrupt("return");
3045
+ return _context32.abrupt("return");
2925
3046
  case 7:
2926
3047
  this.autoPaymentSyncFlushing = true;
2927
- _context31.prev = 8;
3048
+ _context32.prev = 8;
2928
3049
  case 9:
2929
3050
  if (!this.queuedAutoPaymentSync) {
2930
- _context31.next = 18;
3051
+ _context32.next = 18;
2931
3052
  break;
2932
3053
  }
2933
3054
  this.queuedAutoPaymentSync = false;
2934
3055
  payments = this.store.order.getOrderPayments();
2935
3056
  if (payments.length) {
2936
- _context31.next = 14;
3057
+ _context32.next = 14;
2937
3058
  break;
2938
3059
  }
2939
- return _context31.abrupt("continue", 9);
3060
+ return _context32.abrupt("continue", 9);
2940
3061
  case 14:
2941
- _context31.next = 16;
3062
+ _context32.next = 16;
2942
3063
  return this.syncPaymentsToOrder({
2943
3064
  payments: payments,
2944
3065
  paymentStatus: this.getPaymentStatusForSync(payments),
@@ -2946,44 +3067,91 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2946
3067
  smallTicketDataFlag: 1
2947
3068
  });
2948
3069
  case 16:
2949
- _context31.next = 9;
3070
+ _context32.next = 9;
2950
3071
  break;
2951
3072
  case 18:
2952
- _context31.next = 23;
3073
+ _context32.next = 23;
2953
3074
  break;
2954
3075
  case 20:
2955
- _context31.prev = 20;
2956
- _context31.t0 = _context31["catch"](8);
3076
+ _context32.prev = 20;
3077
+ _context32.t0 = _context32["catch"](8);
2957
3078
  this.logError('queued auto sync payments failed', {
2958
- error: _context31.t0 instanceof Error ? _context31.t0.message : String(_context31.t0)
3079
+ error: _context32.t0 instanceof Error ? _context32.t0.message : String(_context32.t0)
2959
3080
  });
2960
3081
  case 23:
2961
- _context31.prev = 23;
3082
+ _context32.prev = 23;
2962
3083
  this.autoPaymentSyncFlushing = false;
2963
3084
  if (this.queuedAutoPaymentSync) {
2964
3085
  this.scheduleQueuedAutoPaymentSyncFlush(0);
2965
3086
  }
2966
- return _context31.finish(23);
3087
+ return _context32.finish(23);
2967
3088
  case 27:
2968
3089
  case "end":
2969
- return _context31.stop();
3090
+ return _context32.stop();
2970
3091
  }
2971
- }, _callee31, this, [[8, 20, 23, 27]]);
3092
+ }, _callee32, this, [[8, 20, 23, 27]]);
2972
3093
  }));
2973
3094
  function flushQueuedAutoPaymentSync() {
2974
3095
  return _flushQueuedAutoPaymentSync.apply(this, arguments);
2975
3096
  }
2976
3097
  return flushQueuedAutoPaymentSync;
2977
- }() /** 追加单个支付项到当前订单。 */
3098
+ }()
3099
+ /**
3100
+ * 同步兼容入口。无法等待 IoT 短号时,按调用当下的 device_id 或 LOCAL 生成。
3101
+ */
2978
3102
  }, {
2979
3103
  key: "addOrderPayment",
2980
3104
  value: function addOrderPayment(payment) {
2981
- var _this$otherParams20,
3105
+ var hasPaymentNumber = String(payment.payment_number || '').trim() !== '';
3106
+ return this.addOrderPaymentWithDevicePrefix(payment, hasPaymentNumber ? 'LOCAL' : this.getPaymentNumberDevicePrefixSync());
3107
+ }
3108
+
3109
+ /** 创建新支付项时读取最新设备短号,不缓存运行时设备信息。 */
3110
+ }, {
3111
+ key: "addOrderPaymentAsync",
3112
+ value: (function () {
3113
+ var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(payment) {
3114
+ var paymentRecord, hasPaymentNumber, devicePrefix;
3115
+ return _regeneratorRuntime().wrap(function _callee33$(_context33) {
3116
+ while (1) switch (_context33.prev = _context33.next) {
3117
+ case 0:
3118
+ paymentRecord = payment;
3119
+ hasPaymentNumber = String(paymentRecord.payment_number || '').trim() !== '';
3120
+ if (!hasPaymentNumber) {
3121
+ _context33.next = 6;
3122
+ break;
3123
+ }
3124
+ _context33.t0 = 'LOCAL';
3125
+ _context33.next = 9;
3126
+ break;
3127
+ case 6:
3128
+ _context33.next = 8;
3129
+ return this.getPaymentNumberDevicePrefixAsync();
3130
+ case 8:
3131
+ _context33.t0 = _context33.sent;
3132
+ case 9:
3133
+ devicePrefix = _context33.t0;
3134
+ return _context33.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
3135
+ case 11:
3136
+ case "end":
3137
+ return _context33.stop();
3138
+ }
3139
+ }, _callee33, this);
3140
+ }));
3141
+ function addOrderPaymentAsync(_x26) {
3142
+ return _addOrderPaymentAsync.apply(this, arguments);
3143
+ }
3144
+ return addOrderPaymentAsync;
3145
+ }())
3146
+ }, {
3147
+ key: "addOrderPaymentWithDevicePrefix",
3148
+ value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
3149
+ var _this$otherParams24,
2982
3150
  _paymentRecord$paymen,
2983
3151
  _paymentRecord$create,
2984
- _ref23,
3152
+ _ref24,
2985
3153
  _paymentRecord$origin,
2986
- _this12 = this;
3154
+ _this14 = this;
2987
3155
  if (!this.store.order) throw new Error('order 模块未初始化');
2988
3156
  var paymentRecord = payment;
2989
3157
  var paymentAmount = new Decimal(paymentRecord.amount || 0);
@@ -2994,25 +3162,26 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2994
3162
  return this.store.order.getOrderPayments();
2995
3163
  }
2996
3164
  var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
2997
- var shopWalletPassId = (_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.shop_wallet_pass_id;
3165
+ var shopWalletPassId = (_this$otherParams24 = this.otherParams) === null || _this$otherParams24 === void 0 ? void 0 : _this$otherParams24.shop_wallet_pass_id;
2998
3166
  if (shopWalletPassId !== undefined && shopWalletPassId !== null) {
2999
3167
  metadata.shop_wallet_pass_id = shopWalletPassId;
3000
3168
  }
3001
- if (!metadata.unique_payment_number) {
3002
- metadata.unique_payment_number = createUuidV4();
3003
- }
3169
+ var normalizedPaymentRecord = ensureOrderPaymentNumber(paymentRecord, devicePrefix, createUuidV4);
3004
3170
  var paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
3005
3171
  var paymentTime = (_paymentRecord$paymen = paymentRecord.payment_time) !== null && _paymentRecord$paymen !== void 0 ? _paymentRecord$paymen : paymentTimestamp;
3006
3172
  var createdAt = (_paymentRecord$create = paymentRecord.created_at) !== null && _paymentRecord$create !== void 0 ? _paymentRecord$create : paymentTimestamp;
3007
3173
  var serviceCharge = paymentRecord.service_charge && _typeof(paymentRecord.service_charge) === 'object' ? paymentRecord.service_charge : null;
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 ? {
3174
+ 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;
3175
+ var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({}, normalizedPaymentRecord), calculatedServiceFee !== undefined ? {
3010
3176
  service_fee: calculatedServiceFee
3011
3177
  } : {}), {}, {
3012
3178
  metadata: metadata,
3013
3179
  payment_time: paymentTime,
3014
3180
  created_at: createdAt
3015
3181
  }));
3182
+ if (paymentRecord.status === 'payment_pending') {
3183
+ return payments;
3184
+ }
3016
3185
  var amountSnapshot = this.store.order.getOrderAmountSnapshot();
3017
3186
  var syncState = this.store.order.getOrderSyncState();
3018
3187
  if (amountSnapshot) {
@@ -3026,7 +3195,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3026
3195
  submitWhenPaid: true,
3027
3196
  smallTicketDataFlag: 1
3028
3197
  }).catch(function (error) {
3029
- _this12.logError('auto sync payments failed', {
3198
+ _this14.logError('auto sync payments failed', {
3030
3199
  error: error instanceof Error ? error.message : String(error)
3031
3200
  });
3032
3201
  });
@@ -3037,12 +3206,131 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3037
3206
  /** 更新当前订单中的指定支付项。 */
3038
3207
  }, {
3039
3208
  key: "updateOrderPayment",
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
- /** 删除当前订单中的指定支付项。 */
3209
+ value: (function () {
3210
+ var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(paymentIdentity, updates) {
3211
+ var _result$payment, _result$payment2;
3212
+ var options,
3213
+ matchMode,
3214
+ previousMatch,
3215
+ previousPayment,
3216
+ _this$store$order$get2,
3217
+ currentPayments,
3218
+ _syncResult,
3219
+ _options$smallTicketD,
3220
+ result,
3221
+ draftResult,
3222
+ draftError,
3223
+ becamePaid,
3224
+ shouldSubmit,
3225
+ syncResult,
3226
+ _options$smallTicketD2,
3227
+ _args34 = arguments;
3228
+ return _regeneratorRuntime().wrap(function _callee34$(_context34) {
3229
+ while (1) switch (_context34.prev = _context34.next) {
3230
+ case 0:
3231
+ options = _args34.length > 2 && _args34[2] !== undefined ? _args34[2] : {};
3232
+ if (this.store.order) {
3233
+ _context34.next = 3;
3234
+ break;
3235
+ }
3236
+ throw new Error('order 模块未初始化');
3237
+ case 3:
3238
+ matchMode = options.matchBy === 'compat' || options.matchBy === 'legacy' ? 'compat' : 'payment_number';
3239
+ previousMatch = resolveOrderPaymentIdentity(this.store.order.getOrderPayments(), paymentIdentity, matchMode);
3240
+ previousPayment = previousMatch === null || previousMatch === void 0 ? void 0 : previousMatch.payment;
3241
+ if (!((previousPayment === null || previousPayment === void 0 ? void 0 : previousPayment.status) === 'paid' && !options.applyUpdatesWhenPaid)) {
3242
+ _context34.next = 13;
3243
+ break;
3244
+ }
3245
+ currentPayments = this.store.order.getOrderPayments();
3246
+ if (!(options.submitWhenPaid && options.forceSubmitIfPaid)) {
3247
+ _context34.next = 12;
3248
+ break;
3249
+ }
3250
+ _context34.next = 11;
3251
+ return this.syncPaymentsToOrder({
3252
+ payments: currentPayments,
3253
+ paymentStatus: this.getPaymentStatusForSync(currentPayments),
3254
+ submitWhenPaid: true,
3255
+ smallTicketDataFlag: (_options$smallTicketD = options.smallTicketDataFlag) !== null && _options$smallTicketD !== void 0 ? _options$smallTicketD : 1
3256
+ });
3257
+ case 11:
3258
+ _syncResult = _context34.sent;
3259
+ case 12:
3260
+ return _context34.abrupt("return", _objectSpread({
3261
+ updated: false,
3262
+ payment: previousPayment,
3263
+ payments: currentPayments,
3264
+ summary: ((_this$store$order$get2 = this.store.order.getOrderAmountSnapshot()) === null || _this$store$order$get2 === void 0 ? void 0 : _this$store$order$get2.summary) || null
3265
+ }, _syncResult !== undefined ? {
3266
+ syncResult: _syncResult
3267
+ } : {}));
3268
+ case 13:
3269
+ _context34.next = 15;
3270
+ return this.store.order.updateOrderPayment(paymentIdentity, updates, {
3271
+ matchBy: matchMode
3272
+ });
3273
+ case 15:
3274
+ result = _context34.sent;
3275
+ if (!(options.persistDraft !== false)) {
3276
+ _context34.next = 29;
3277
+ break;
3278
+ }
3279
+ _context34.prev = 17;
3280
+ _context34.next = 20;
3281
+ return this.saveSalesOrderDraft();
3282
+ case 20:
3283
+ draftResult = _context34.sent;
3284
+ _context34.next = 29;
3285
+ break;
3286
+ case 23:
3287
+ _context34.prev = 23;
3288
+ _context34.t0 = _context34["catch"](17);
3289
+ draftError = _context34.t0;
3290
+ this.logError('updateOrderPayment: 保存支付草稿失败', {
3291
+ paymentIdentity: paymentIdentity,
3292
+ error: _context34.t0 instanceof Error ? _context34.t0.message : String(_context34.t0)
3293
+ });
3294
+ if (options.submitWhenPaid) {
3295
+ _context34.next = 29;
3296
+ break;
3297
+ }
3298
+ throw _context34.t0;
3299
+ case 29:
3300
+ 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';
3301
+ shouldSubmit = Boolean(options.submitWhenPaid && ((_result$payment2 = result.payment) === null || _result$payment2 === void 0 ? void 0 : _result$payment2.status) === 'paid' && (becamePaid || options.forceSubmitIfPaid));
3302
+ if (!shouldSubmit) {
3303
+ _context34.next = 35;
3304
+ break;
3305
+ }
3306
+ _context34.next = 34;
3307
+ return this.syncPaymentsToOrder({
3308
+ payments: result.payments,
3309
+ paymentStatus: this.getPaymentStatusForSync(result.payments),
3310
+ submitWhenPaid: true,
3311
+ smallTicketDataFlag: (_options$smallTicketD2 = options.smallTicketDataFlag) !== null && _options$smallTicketD2 !== void 0 ? _options$smallTicketD2 : 1
3312
+ });
3313
+ case 34:
3314
+ syncResult = _context34.sent;
3315
+ case 35:
3316
+ return _context34.abrupt("return", _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, result), draftResult !== undefined ? {
3317
+ draftResult: draftResult
3318
+ } : {}), draftError !== undefined ? {
3319
+ draftError: draftError
3320
+ } : {}), syncResult !== undefined ? {
3321
+ syncResult: syncResult
3322
+ } : {}));
3323
+ case 36:
3324
+ case "end":
3325
+ return _context34.stop();
3326
+ }
3327
+ }, _callee34, this, [[17, 23]]);
3328
+ }));
3329
+ function updateOrderPayment(_x27, _x28) {
3330
+ return _updateOrderPayment.apply(this, arguments);
3331
+ }
3332
+ return updateOrderPayment;
3333
+ }() /** 删除当前订单中的指定支付项。 */)
3046
3334
  }, {
3047
3335
  key: "deleteOrderPayment",
3048
3336
  value: function deleteOrderPayment(paymentIdentity) {
@@ -3057,6 +3345,31 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3057
3345
  if (!this.store.order) throw new Error('order 模块未初始化');
3058
3346
  return this.store.order.updateVoucherOrderPayments(payments, options);
3059
3347
  }
3348
+ }, {
3349
+ key: "updateVoucherOrderPaymentsAsync",
3350
+ value: function () {
3351
+ var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(payments, options) {
3352
+ return _regeneratorRuntime().wrap(function _callee35$(_context35) {
3353
+ while (1) switch (_context35.prev = _context35.next) {
3354
+ case 0:
3355
+ if (this.store.order) {
3356
+ _context35.next = 2;
3357
+ break;
3358
+ }
3359
+ throw new Error('order 模块未初始化');
3360
+ case 2:
3361
+ return _context35.abrupt("return", this.store.order.updateVoucherOrderPaymentsAsync(payments, options));
3362
+ case 3:
3363
+ case "end":
3364
+ return _context35.stop();
3365
+ }
3366
+ }, _callee35, this);
3367
+ }));
3368
+ function updateVoucherOrderPaymentsAsync(_x29, _x30) {
3369
+ return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
3370
+ }
3371
+ return updateVoucherOrderPaymentsAsync;
3372
+ }()
3060
3373
  }, {
3061
3374
  key: "confirmPendingVoucherPayments",
3062
3375
  value: function confirmPendingVoucherPayments() {
@@ -3133,20 +3446,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3133
3446
  }, {
3134
3447
  key: "initWalletData",
3135
3448
  value: function () {
3136
- var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
3137
- var _params$order_wait_pa, _ref24, _tempOrder$is_price_i;
3449
+ var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
3450
+ var _params$order_wait_pa, _ref25, _tempOrder$is_price_i;
3138
3451
  var snapshot, tempOrder, amount, walletBusinessData, result;
3139
- return _regeneratorRuntime().wrap(function _callee32$(_context32) {
3140
- while (1) switch (_context32.prev = _context32.next) {
3452
+ return _regeneratorRuntime().wrap(function _callee36$(_context36) {
3453
+ while (1) switch (_context36.prev = _context36.next) {
3141
3454
  case 0:
3142
3455
  if (this.store.order) {
3143
- _context32.next = 2;
3456
+ _context36.next = 2;
3144
3457
  break;
3145
3458
  }
3146
3459
  throw new Error('order 模块未初始化');
3147
3460
  case 2:
3148
3461
  if (this.store.payment) {
3149
- _context32.next = 4;
3462
+ _context36.next = 4;
3150
3463
  break;
3151
3464
  }
3152
3465
  throw new Error('payment 模块未初始化');
@@ -3155,10 +3468,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3155
3468
  tempOrder = snapshot === null || snapshot === void 0 ? void 0 : snapshot.tempOrder;
3156
3469
  amount = snapshot === null || snapshot === void 0 ? void 0 : snapshot.amount;
3157
3470
  if (!(!tempOrder || !amount)) {
3158
- _context32.next = 9;
3471
+ _context36.next = 9;
3159
3472
  break;
3160
3473
  }
3161
- return _context32.abrupt("return", {
3474
+ return _context36.abrupt("return", {
3162
3475
  walletRecommendList: [],
3163
3476
  userIdentificationCodes: [],
3164
3477
  transformList: [],
@@ -3177,15 +3490,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3177
3490
  },
3178
3491
  products: this.getWalletProductList(),
3179
3492
  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),
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
3493
+ 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
3181
3494
  }, snapshot.identity.orderId ? {
3182
3495
  payment_order_id: String(snapshot.identity.orderId)
3183
3496
  } : {});
3184
- _context32.next = 12;
3497
+ _context36.next = 12;
3185
3498
  return this.store.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
3186
3499
  case 12:
3187
- result = _context32.sent;
3188
- _context32.next = 15;
3500
+ result = _context36.sent;
3501
+ _context36.next = 15;
3189
3502
  return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
3190
3503
  orderId: snapshot.identity.orderId,
3191
3504
  customerId: walletBusinessData.customer_id,
@@ -3197,14 +3510,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3197
3510
  timestamp: Date.now()
3198
3511
  });
3199
3512
  case 15:
3200
- return _context32.abrupt("return", result);
3513
+ return _context36.abrupt("return", result);
3201
3514
  case 16:
3202
3515
  case "end":
3203
- return _context32.stop();
3516
+ return _context36.stop();
3204
3517
  }
3205
- }, _callee32, this);
3518
+ }, _callee36, this);
3206
3519
  }));
3207
- function initWalletData(_x25) {
3520
+ function initWalletData(_x31) {
3208
3521
  return _initWalletData.apply(this, arguments);
3209
3522
  }
3210
3523
  return initWalletData;
@@ -3231,35 +3544,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3231
3544
  }, {
3232
3545
  key: "getPaymentMethodsAsync",
3233
3546
  value: (function () {
3234
- var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
3547
+ var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {
3235
3548
  var response, paymentMethods;
3236
- return _regeneratorRuntime().wrap(function _callee33$(_context33) {
3237
- while (1) switch (_context33.prev = _context33.next) {
3549
+ return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3550
+ while (1) switch (_context37.prev = _context37.next) {
3238
3551
  case 0:
3239
- _context33.prev = 0;
3240
- _context33.next = 3;
3552
+ _context37.prev = 0;
3553
+ _context37.next = 3;
3241
3554
  return this.request.get('/pay/custom-payment/all', {
3242
3555
  filterPaymentMethods: true
3243
3556
  }, {
3244
3557
  osServer: true
3245
3558
  });
3246
3559
  case 3:
3247
- response = _context33.sent;
3560
+ response = _context37.sent;
3248
3561
  paymentMethods = (response === null || response === void 0 ? void 0 : response.data) || [];
3249
3562
  this.paymentMethodsCache = Array.isArray(paymentMethods) ? _toConsumableArray(paymentMethods) : [];
3250
- return _context33.abrupt("return", this.getPaymentMethods());
3563
+ return _context37.abrupt("return", this.getPaymentMethods());
3251
3564
  case 9:
3252
- _context33.prev = 9;
3253
- _context33.t0 = _context33["catch"](0);
3565
+ _context37.prev = 9;
3566
+ _context37.t0 = _context37["catch"](0);
3254
3567
  this.logWarning('getPaymentMethodsAsync: 获取支付方式列表失败,使用缓存列表', {
3255
- error: _context33.t0 instanceof Error ? _context33.t0.message : String(_context33.t0)
3568
+ error: _context37.t0 instanceof Error ? _context37.t0.message : String(_context37.t0)
3256
3569
  });
3257
- return _context33.abrupt("return", this.getPaymentMethods());
3570
+ return _context37.abrupt("return", this.getPaymentMethods());
3258
3571
  case 13:
3259
3572
  case "end":
3260
- return _context33.stop();
3573
+ return _context37.stop();
3261
3574
  }
3262
- }, _callee33, this, [[0, 9]]);
3575
+ }, _callee37, this, [[0, 9]]);
3263
3576
  }));
3264
3577
  function getPaymentMethodsAsync() {
3265
3578
  return _getPaymentMethodsAsync.apply(this, arguments);
@@ -3307,49 +3620,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3307
3620
  }, {
3308
3621
  key: "sendCustomerPayLink",
3309
3622
  value: (function () {
3310
- var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
3311
- var orderIds, _ref25, _ref26, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
3312
- return _regeneratorRuntime().wrap(function _callee34$(_context34) {
3313
- while (1) switch (_context34.prev = _context34.next) {
3623
+ var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
3624
+ var orderIds, _ref26, _ref27, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
3625
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3626
+ while (1) switch (_context38.prev = _context38.next) {
3314
3627
  case 0:
3315
3628
  if (this.store.order) {
3316
- _context34.next = 2;
3629
+ _context38.next = 2;
3317
3630
  break;
3318
3631
  }
3319
3632
  throw new Error('order 模块未初始化');
3320
3633
  case 2:
3321
3634
  orderIds = params.order_ids || params.orderIds || [];
3322
3635
  if (!(!orderIds.length || params.submitBeforeSend)) {
3323
- _context34.next = 11;
3636
+ _context38.next = 11;
3324
3637
  break;
3325
3638
  }
3326
- _context34.next = 6;
3639
+ _context38.next = 6;
3327
3640
  return this.submitSalesOrder({
3328
3641
  smallTicketDataFlag: 1
3329
3642
  });
3330
3643
  case 6:
3331
- submitResult = _context34.sent;
3332
- 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;
3644
+ submitResult = _context38.sent;
3645
+ 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;
3333
3646
  if (orderId) {
3334
- _context34.next = 10;
3647
+ _context38.next = 10;
3335
3648
  break;
3336
3649
  }
3337
3650
  throw new Error('本地订单提交云端失败,无法发送支付链接');
3338
3651
  case 10:
3339
3652
  orderIds = [orderId];
3340
3653
  case 11:
3341
- return _context34.abrupt("return", this.store.order.sendCustomerPayLink({
3654
+ return _context38.abrupt("return", this.store.order.sendCustomerPayLink({
3342
3655
  emails: params.emails,
3343
3656
  notify_action: params.notify_action,
3344
3657
  order_ids: orderIds
3345
3658
  }));
3346
3659
  case 12:
3347
3660
  case "end":
3348
- return _context34.stop();
3661
+ return _context38.stop();
3349
3662
  }
3350
- }, _callee34, this);
3663
+ }, _callee38, this);
3351
3664
  }));
3352
- function sendCustomerPayLink(_x26) {
3665
+ function sendCustomerPayLink(_x32) {
3353
3666
  return _sendCustomerPayLink.apply(this, arguments);
3354
3667
  }
3355
3668
  return sendCustomerPayLink;
@@ -3362,27 +3675,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3362
3675
  }, {
3363
3676
  key: "calculateProductBookingPrice",
3364
3677
  value: function () {
3365
- var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
3678
+ var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
3366
3679
  var _params$customer_id;
3367
3680
  var quotation, customerId, authoritativeProduct, product;
3368
- return _regeneratorRuntime().wrap(function _callee35$(_context35) {
3369
- while (1) switch (_context35.prev = _context35.next) {
3681
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3682
+ while (1) switch (_context39.prev = _context39.next) {
3370
3683
  case 0:
3371
3684
  quotation = this.store.quotation;
3372
3685
  customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : this.getCurrentOrderCustomerId();
3373
- _context35.next = 4;
3686
+ _context39.next = 4;
3374
3687
  return this.loadProductForPriceQuery(params, customerId);
3375
3688
  case 4:
3376
- authoritativeProduct = _context35.sent;
3689
+ authoritativeProduct = _context39.sent;
3377
3690
  product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
3378
- _context35.next = 8;
3691
+ _context39.next = 8;
3379
3692
  return this.loadQuotationForPriceQuery({
3380
3693
  quotation: quotation,
3381
3694
  customer_id: customerId,
3382
3695
  channel: params.channel
3383
3696
  });
3384
3697
  case 8:
3385
- return _context35.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
3698
+ return _context39.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
3386
3699
  product: product,
3387
3700
  fallback_price: authoritativeProduct ? undefined : params.fallback_price,
3388
3701
  customer_id: customerId,
@@ -3390,11 +3703,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3390
3703
  })));
3391
3704
  case 9:
3392
3705
  case "end":
3393
- return _context35.stop();
3706
+ return _context39.stop();
3394
3707
  }
3395
- }, _callee35, this);
3708
+ }, _callee39, this);
3396
3709
  }));
3397
- function calculateProductBookingPrice(_x27) {
3710
+ function calculateProductBookingPrice(_x33) {
3398
3711
  return _calculateProductBookingPrice.apply(this, arguments);
3399
3712
  }
3400
3713
  return calculateProductBookingPrice;
@@ -3402,7 +3715,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3402
3715
  }, {
3403
3716
  key: "getQuotationCustomerScopeInfo",
3404
3717
  value: function getQuotationCustomerScopeInfo() {
3405
- var _this13 = this;
3718
+ var _this15 = this;
3406
3719
  var quotation = this.store.quotation;
3407
3720
  if (quotation && typeof quotation.getQuotationCustomerScopeInfo === 'function') {
3408
3721
  return quotation.getQuotationCustomerScopeInfo();
@@ -3414,7 +3727,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3414
3727
  }).map(function (item) {
3415
3728
  var localSeen = new Set();
3416
3729
  var customers = item.customer.filter(function (customer) {
3417
- var customerId = _this13.normalizePriceContextCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
3730
+ var customerId = _this15.normalizePriceContextCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
3418
3731
  if (!customerId || localSeen.has(customerId)) return false;
3419
3732
  localSeen.add(customerId);
3420
3733
  if (!customerById.has(customerId)) customerById.set(customerId, customer);
@@ -3464,32 +3777,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3464
3777
  }, {
3465
3778
  key: "calculateProductBookingPrices",
3466
3779
  value: function () {
3467
- var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(paramsList) {
3780
+ var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(paramsList) {
3468
3781
  var _paramsList$0$custome,
3469
3782
  _paramsList$,
3470
- _this14 = this,
3783
+ _this16 = this,
3471
3784
  _paramsList$2;
3472
3785
  var quotation, customerId, productMapsByGroup, groups;
3473
- return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3474
- while (1) switch (_context37.prev = _context37.next) {
3786
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3787
+ while (1) switch (_context41.prev = _context41.next) {
3475
3788
  case 0:
3476
3789
  if (paramsList.length) {
3477
- _context37.next = 2;
3790
+ _context41.next = 2;
3478
3791
  break;
3479
3792
  }
3480
- return _context37.abrupt("return", []);
3793
+ return _context41.abrupt("return", []);
3481
3794
  case 2:
3482
3795
  quotation = this.store.quotation;
3483
3796
  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();
3484
3797
  productMapsByGroup = new Map();
3485
3798
  groups = new Map();
3486
3799
  paramsList.forEach(function (params) {
3487
- var _this14$otherParams;
3800
+ var _this16$otherParams;
3488
3801
  var product = params.product || {};
3489
- var productId = _this14.getPriceQueryProductId(product);
3802
+ var productId = _this16.getPriceQueryProductId(product);
3490
3803
  if (productId === null) return;
3491
- var schedule = _this14.getPriceQuerySchedule(params);
3492
- var channel = params.channel || ((_this14$otherParams = _this14.otherParams) === null || _this14$otherParams === void 0 ? void 0 : _this14$otherParams.channel);
3804
+ var schedule = _this16.getPriceQuerySchedule(params);
3805
+ var channel = params.channel || ((_this16$otherParams = _this16.otherParams) === null || _this16$otherParams === void 0 ? void 0 : _this16$otherParams.channel);
3493
3806
  var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || ''].join('|');
3494
3807
  var group = groups.get(groupKey) || {
3495
3808
  ids: new Set(),
@@ -3499,51 +3812,51 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3499
3812
  group.ids.add(productId);
3500
3813
  groups.set(groupKey, group);
3501
3814
  });
3502
- _context37.next = 9;
3815
+ _context41.next = 9;
3503
3816
  return Promise.all(Array.from(groups.entries()).map( /*#__PURE__*/function () {
3504
- var _ref28 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(_ref27) {
3505
- var _ref29, groupKey, group, productsById;
3506
- return _regeneratorRuntime().wrap(function _callee36$(_context36) {
3507
- while (1) switch (_context36.prev = _context36.next) {
3817
+ var _ref29 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(_ref28) {
3818
+ var _ref30, groupKey, group, productsById;
3819
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3820
+ while (1) switch (_context40.prev = _context40.next) {
3508
3821
  case 0:
3509
- _ref29 = _slicedToArray(_ref27, 2), groupKey = _ref29[0], group = _ref29[1];
3510
- _context36.next = 3;
3511
- return _this14.loadProductsForPriceQuery({
3822
+ _ref30 = _slicedToArray(_ref28, 2), groupKey = _ref30[0], group = _ref30[1];
3823
+ _context40.next = 3;
3824
+ return _this16.loadProductsForPriceQuery({
3512
3825
  ids: Array.from(group.ids),
3513
3826
  schedule: group.schedule,
3514
3827
  customerId: customerId,
3515
3828
  channel: group.channel
3516
3829
  });
3517
3830
  case 3:
3518
- productsById = _context36.sent;
3831
+ productsById = _context40.sent;
3519
3832
  productMapsByGroup.set(groupKey, productsById);
3520
3833
  case 5:
3521
3834
  case "end":
3522
- return _context36.stop();
3835
+ return _context40.stop();
3523
3836
  }
3524
- }, _callee36);
3837
+ }, _callee40);
3525
3838
  }));
3526
- return function (_x29) {
3527
- return _ref28.apply(this, arguments);
3839
+ return function (_x35) {
3840
+ return _ref29.apply(this, arguments);
3528
3841
  };
3529
3842
  }()));
3530
3843
  case 9:
3531
- _context37.next = 11;
3844
+ _context41.next = 11;
3532
3845
  return this.loadQuotationForPriceQuery({
3533
3846
  quotation: quotation,
3534
3847
  customer_id: customerId,
3535
3848
  channel: (_paramsList$2 = paramsList[0]) === null || _paramsList$2 === void 0 ? void 0 : _paramsList$2.channel
3536
3849
  });
3537
3850
  case 11:
3538
- return _context37.abrupt("return", paramsList.map(function (params) {
3539
- var _this14$otherParams2, _productMapsByGroup$g;
3851
+ return _context41.abrupt("return", paramsList.map(function (params) {
3852
+ var _this16$otherParams2, _productMapsByGroup$g;
3540
3853
  var productInput = params.product || {};
3541
- var productId = _this14.getPriceQueryProductId(productInput);
3542
- var schedule = _this14.getPriceQuerySchedule(params);
3543
- var channel = params.channel || ((_this14$otherParams2 = _this14.otherParams) === null || _this14$otherParams2 === void 0 ? void 0 : _this14$otherParams2.channel);
3854
+ var productId = _this16.getPriceQueryProductId(productInput);
3855
+ var schedule = _this16.getPriceQuerySchedule(params);
3856
+ var channel = params.channel || ((_this16$otherParams2 = _this16.otherParams) === null || _this16$otherParams2 === void 0 ? void 0 : _this16$otherParams2.channel);
3544
3857
  var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || ''].join('|');
3545
3858
  var authoritativeProduct = productId === null ? null : ((_productMapsByGroup$g = productMapsByGroup.get(groupKey)) === null || _productMapsByGroup$g === void 0 ? void 0 : _productMapsByGroup$g.get(productId)) || null;
3546
- var product = _this14.mergeProductForPriceQuery(productInput, authoritativeProduct);
3859
+ var product = _this16.mergeProductForPriceQuery(productInput, authoritativeProduct);
3547
3860
  return calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
3548
3861
  product: product,
3549
3862
  fallback_price: authoritativeProduct ? undefined : params.fallback_price,
@@ -3553,11 +3866,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3553
3866
  }));
3554
3867
  case 12:
3555
3868
  case "end":
3556
- return _context37.stop();
3869
+ return _context41.stop();
3557
3870
  }
3558
- }, _callee37, this);
3871
+ }, _callee41, this);
3559
3872
  }));
3560
- function calculateProductBookingPrices(_x28) {
3873
+ function calculateProductBookingPrices(_x34) {
3561
3874
  return _calculateProductBookingPrices.apply(this, arguments);
3562
3875
  }
3563
3876
  return calculateProductBookingPrices;
@@ -3565,34 +3878,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3565
3878
  }, {
3566
3879
  key: "addProductToOrder",
3567
3880
  value: function () {
3568
- var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(product, booking) {
3881
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(product, booking) {
3569
3882
  var products;
3570
- return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3571
- while (1) switch (_context38.prev = _context38.next) {
3883
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3884
+ while (1) switch (_context42.prev = _context42.next) {
3572
3885
  case 0:
3573
- _context38.prev = 0;
3886
+ _context42.prev = 0;
3574
3887
  if (this.store.order) {
3575
- _context38.next = 3;
3888
+ _context42.next = 3;
3576
3889
  break;
3577
3890
  }
3578
3891
  throw new Error('order 模块未初始化');
3579
3892
  case 3:
3580
- _context38.next = 5;
3893
+ _context42.next = 5;
3581
3894
  return this.store.order.addProductToOrder(product, booking);
3582
3895
  case 5:
3583
- products = _context38.sent;
3584
- return _context38.abrupt("return", products);
3896
+ products = _context42.sent;
3897
+ return _context42.abrupt("return", products);
3585
3898
  case 9:
3586
- _context38.prev = 9;
3587
- _context38.t0 = _context38["catch"](0);
3588
- throw _context38.t0;
3899
+ _context42.prev = 9;
3900
+ _context42.t0 = _context42["catch"](0);
3901
+ throw _context42.t0;
3589
3902
  case 12:
3590
3903
  case "end":
3591
- return _context38.stop();
3904
+ return _context42.stop();
3592
3905
  }
3593
- }, _callee38, this, [[0, 9]]);
3906
+ }, _callee42, this, [[0, 9]]);
3594
3907
  }));
3595
- function addProductToOrder(_x30, _x31) {
3908
+ function addProductToOrder(_x36, _x37) {
3596
3909
  return _addProductToOrder.apply(this, arguments);
3597
3910
  }
3598
3911
  return addProductToOrder;
@@ -3600,34 +3913,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3600
3913
  }, {
3601
3914
  key: "updateOrderProduct",
3602
3915
  value: function () {
3603
- var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
3916
+ var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
3604
3917
  var products;
3605
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3606
- while (1) switch (_context39.prev = _context39.next) {
3918
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3919
+ while (1) switch (_context43.prev = _context43.next) {
3607
3920
  case 0:
3608
- _context39.prev = 0;
3921
+ _context43.prev = 0;
3609
3922
  if (this.store.order) {
3610
- _context39.next = 3;
3923
+ _context43.next = 3;
3611
3924
  break;
3612
3925
  }
3613
3926
  throw new Error('order 模块未初始化');
3614
3927
  case 3:
3615
- _context39.next = 5;
3928
+ _context43.next = 5;
3616
3929
  return this.store.order.updateOrderProduct(params);
3617
3930
  case 5:
3618
- products = _context39.sent;
3619
- return _context39.abrupt("return", products);
3931
+ products = _context43.sent;
3932
+ return _context43.abrupt("return", products);
3620
3933
  case 9:
3621
- _context39.prev = 9;
3622
- _context39.t0 = _context39["catch"](0);
3623
- throw _context39.t0;
3934
+ _context43.prev = 9;
3935
+ _context43.t0 = _context43["catch"](0);
3936
+ throw _context43.t0;
3624
3937
  case 12:
3625
3938
  case "end":
3626
- return _context39.stop();
3939
+ return _context43.stop();
3627
3940
  }
3628
- }, _callee39, this, [[0, 9]]);
3941
+ }, _callee43, this, [[0, 9]]);
3629
3942
  }));
3630
- function updateOrderProduct(_x32) {
3943
+ function updateOrderProduct(_x38) {
3631
3944
  return _updateOrderProduct.apply(this, arguments);
3632
3945
  }
3633
3946
  return updateOrderProduct;
@@ -3635,34 +3948,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3635
3948
  }, {
3636
3949
  key: "updateOrderProducts",
3637
3950
  value: function () {
3638
- var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(paramsList) {
3951
+ var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(paramsList) {
3639
3952
  var products;
3640
- return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3641
- while (1) switch (_context40.prev = _context40.next) {
3953
+ return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3954
+ while (1) switch (_context44.prev = _context44.next) {
3642
3955
  case 0:
3643
- _context40.prev = 0;
3956
+ _context44.prev = 0;
3644
3957
  if (this.store.order) {
3645
- _context40.next = 3;
3958
+ _context44.next = 3;
3646
3959
  break;
3647
3960
  }
3648
3961
  throw new Error('order 模块未初始化');
3649
3962
  case 3:
3650
- _context40.next = 5;
3963
+ _context44.next = 5;
3651
3964
  return this.store.order.updateOrderProducts(paramsList);
3652
3965
  case 5:
3653
- products = _context40.sent;
3654
- return _context40.abrupt("return", products);
3966
+ products = _context44.sent;
3967
+ return _context44.abrupt("return", products);
3655
3968
  case 9:
3656
- _context40.prev = 9;
3657
- _context40.t0 = _context40["catch"](0);
3658
- throw _context40.t0;
3969
+ _context44.prev = 9;
3970
+ _context44.t0 = _context44["catch"](0);
3971
+ throw _context44.t0;
3659
3972
  case 12:
3660
3973
  case "end":
3661
- return _context40.stop();
3974
+ return _context44.stop();
3662
3975
  }
3663
- }, _callee40, this, [[0, 9]]);
3976
+ }, _callee44, this, [[0, 9]]);
3664
3977
  }));
3665
- function updateOrderProducts(_x33) {
3978
+ function updateOrderProducts(_x39) {
3666
3979
  return _updateOrderProducts.apply(this, arguments);
3667
3980
  }
3668
3981
  return updateOrderProducts;
@@ -3670,34 +3983,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3670
3983
  }, {
3671
3984
  key: "updateOrderProductQuantity",
3672
3985
  value: function () {
3673
- var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
3986
+ var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(params) {
3674
3987
  var products;
3675
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3676
- while (1) switch (_context41.prev = _context41.next) {
3988
+ return _regeneratorRuntime().wrap(function _callee45$(_context45) {
3989
+ while (1) switch (_context45.prev = _context45.next) {
3677
3990
  case 0:
3678
- _context41.prev = 0;
3991
+ _context45.prev = 0;
3679
3992
  if (this.store.order) {
3680
- _context41.next = 3;
3993
+ _context45.next = 3;
3681
3994
  break;
3682
3995
  }
3683
3996
  throw new Error('order 模块未初始化');
3684
3997
  case 3:
3685
- _context41.next = 5;
3998
+ _context45.next = 5;
3686
3999
  return this.store.order.updateOrderProductQuantity(params);
3687
4000
  case 5:
3688
- products = _context41.sent;
3689
- return _context41.abrupt("return", products);
4001
+ products = _context45.sent;
4002
+ return _context45.abrupt("return", products);
3690
4003
  case 9:
3691
- _context41.prev = 9;
3692
- _context41.t0 = _context41["catch"](0);
3693
- throw _context41.t0;
4004
+ _context45.prev = 9;
4005
+ _context45.t0 = _context45["catch"](0);
4006
+ throw _context45.t0;
3694
4007
  case 12:
3695
4008
  case "end":
3696
- return _context41.stop();
4009
+ return _context45.stop();
3697
4010
  }
3698
- }, _callee41, this, [[0, 9]]);
4011
+ }, _callee45, this, [[0, 9]]);
3699
4012
  }));
3700
- function updateOrderProductQuantity(_x34) {
4013
+ function updateOrderProductQuantity(_x40) {
3701
4014
  return _updateOrderProductQuantity.apply(this, arguments);
3702
4015
  }
3703
4016
  return updateOrderProductQuantity;
@@ -3720,12 +4033,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3720
4033
  }, {
3721
4034
  key: "setOrderProductLineNote",
3722
4035
  value: (function () {
3723
- var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(identity, note) {
4036
+ var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(identity, note) {
3724
4037
  var params, products;
3725
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3726
- while (1) switch (_context42.prev = _context42.next) {
4038
+ return _regeneratorRuntime().wrap(function _callee46$(_context46) {
4039
+ while (1) switch (_context46.prev = _context46.next) {
3727
4040
  case 0:
3728
- _context42.prev = 0;
4041
+ _context46.prev = 0;
3729
4042
  params = {
3730
4043
  product_id: identity.product_id,
3731
4044
  product_variant_id: identity.product_variant_id,
@@ -3740,22 +4053,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3740
4053
  params.product_sku = identity.product_sku;
3741
4054
  }
3742
4055
  if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
3743
- _context42.next = 7;
4056
+ _context46.next = 7;
3744
4057
  return this.updateOrderProduct(params);
3745
4058
  case 7:
3746
- products = _context42.sent;
3747
- return _context42.abrupt("return", products);
4059
+ products = _context46.sent;
4060
+ return _context46.abrupt("return", products);
3748
4061
  case 11:
3749
- _context42.prev = 11;
3750
- _context42.t0 = _context42["catch"](0);
3751
- throw _context42.t0;
4062
+ _context46.prev = 11;
4063
+ _context46.t0 = _context46["catch"](0);
4064
+ throw _context46.t0;
3752
4065
  case 14:
3753
4066
  case "end":
3754
- return _context42.stop();
4067
+ return _context46.stop();
3755
4068
  }
3756
- }, _callee42, this, [[0, 11]]);
4069
+ }, _callee46, this, [[0, 11]]);
3757
4070
  }));
3758
- function setOrderProductLineNote(_x35, _x36) {
4071
+ function setOrderProductLineNote(_x41, _x42) {
3759
4072
  return _setOrderProductLineNote.apply(this, arguments);
3760
4073
  }
3761
4074
  return setOrderProductLineNote;
@@ -3770,32 +4083,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3770
4083
  }, {
3771
4084
  key: "removeProductsFromOrder",
3772
4085
  value: (function () {
3773
- var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(identities) {
3774
- return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3775
- while (1) switch (_context43.prev = _context43.next) {
4086
+ var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(identities) {
4087
+ return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4088
+ while (1) switch (_context47.prev = _context47.next) {
3776
4089
  case 0:
3777
- _context43.prev = 0;
4090
+ _context47.prev = 0;
3778
4091
  if (this.store.order) {
3779
- _context43.next = 3;
4092
+ _context47.next = 3;
3780
4093
  break;
3781
4094
  }
3782
4095
  throw new Error('order 模块未初始化');
3783
4096
  case 3:
3784
- _context43.next = 5;
4097
+ _context47.next = 5;
3785
4098
  return this.store.order.removeProductsFromOrder(identities);
3786
4099
  case 5:
3787
- return _context43.abrupt("return", _context43.sent);
4100
+ return _context47.abrupt("return", _context47.sent);
3788
4101
  case 8:
3789
- _context43.prev = 8;
3790
- _context43.t0 = _context43["catch"](0);
3791
- throw _context43.t0;
4102
+ _context47.prev = 8;
4103
+ _context47.t0 = _context47["catch"](0);
4104
+ throw _context47.t0;
3792
4105
  case 11:
3793
4106
  case "end":
3794
- return _context43.stop();
4107
+ return _context47.stop();
3795
4108
  }
3796
- }, _callee43, this, [[0, 8]]);
4109
+ }, _callee47, this, [[0, 8]]);
3797
4110
  }));
3798
- function removeProductsFromOrder(_x37) {
4111
+ function removeProductsFromOrder(_x43) {
3799
4112
  return _removeProductsFromOrder.apply(this, arguments);
3800
4113
  }
3801
4114
  return removeProductsFromOrder;
@@ -3803,18 +4116,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3803
4116
  }, {
3804
4117
  key: "removeProductFromOrder",
3805
4118
  value: function () {
3806
- var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(identity) {
3807
- return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3808
- while (1) switch (_context44.prev = _context44.next) {
4119
+ var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(identity) {
4120
+ return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4121
+ while (1) switch (_context48.prev = _context48.next) {
3809
4122
  case 0:
3810
- return _context44.abrupt("return", this.removeProductsFromOrder([identity]));
4123
+ return _context48.abrupt("return", this.removeProductsFromOrder([identity]));
3811
4124
  case 1:
3812
4125
  case "end":
3813
- return _context44.stop();
4126
+ return _context48.stop();
3814
4127
  }
3815
- }, _callee44, this);
4128
+ }, _callee48, this);
3816
4129
  }));
3817
- function removeProductFromOrder(_x38) {
4130
+ function removeProductFromOrder(_x44) {
3818
4131
  return _removeProductFromOrder.apply(this, arguments);
3819
4132
  }
3820
4133
  return removeProductFromOrder;
@@ -3864,23 +4177,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3864
4177
  }, {
3865
4178
  key: "applyPromotion",
3866
4179
  value: (function () {
3867
- var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45() {
3868
- return _regeneratorRuntime().wrap(function _callee45$(_context45) {
3869
- while (1) switch (_context45.prev = _context45.next) {
4180
+ var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49() {
4181
+ return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4182
+ while (1) switch (_context49.prev = _context49.next) {
3870
4183
  case 0:
3871
4184
  if (this.store.order) {
3872
- _context45.next = 2;
4185
+ _context49.next = 2;
3873
4186
  break;
3874
4187
  }
3875
4188
  throw new Error('order 模块未初始化');
3876
4189
  case 2:
3877
- _context45.next = 4;
4190
+ _context49.next = 4;
3878
4191
  return this.store.order.applyPromotion();
3879
4192
  case 4:
3880
4193
  case "end":
3881
- return _context45.stop();
4194
+ return _context49.stop();
3882
4195
  }
3883
- }, _callee45, this);
4196
+ }, _callee49, this);
3884
4197
  }));
3885
4198
  function applyPromotion() {
3886
4199
  return _applyPromotion.apply(this, arguments);
@@ -3907,18 +4220,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3907
4220
  }, {
3908
4221
  key: "getProductList",
3909
4222
  value: function () {
3910
- var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
3911
- var _this$otherParams21;
4223
+ var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50() {
4224
+ var _this$otherParams25;
3912
4225
  var menu_list_ids, _this$store$products, res;
3913
- return _regeneratorRuntime().wrap(function _callee46$(_context46) {
3914
- while (1) switch (_context46.prev = _context46.next) {
4226
+ return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4227
+ while (1) switch (_context50.prev = _context50.next) {
3915
4228
  case 0:
3916
4229
  // 可以直接通过配置里的 menu 读取
3917
- 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) {
4230
+ 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) {
3918
4231
  return Number(n.value);
3919
4232
  })) || [];
3920
- _context46.prev = 1;
3921
- _context46.next = 4;
4233
+ _context50.prev = 1;
4234
+ _context50.next = 4;
3922
4235
  return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
3923
4236
  menu_list_ids: menu_list_ids,
3924
4237
  cacheId: this.cacheId,
@@ -3926,17 +4239,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3926
4239
  schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
3927
4240
  });
3928
4241
  case 4:
3929
- res = _context46.sent;
3930
- return _context46.abrupt("return", res);
4242
+ res = _context50.sent;
4243
+ return _context50.abrupt("return", res);
3931
4244
  case 8:
3932
- _context46.prev = 8;
3933
- _context46.t0 = _context46["catch"](1);
3934
- throw _context46.t0;
4245
+ _context50.prev = 8;
4246
+ _context50.t0 = _context50["catch"](1);
4247
+ throw _context50.t0;
3935
4248
  case 11:
3936
4249
  case "end":
3937
- return _context46.stop();
4250
+ return _context50.stop();
3938
4251
  }
3939
- }, _callee46, this, [[1, 8]]);
4252
+ }, _callee50, this, [[1, 8]]);
3940
4253
  }));
3941
4254
  function getProductList() {
3942
4255
  return _getProductList.apply(this, arguments);
@@ -3951,33 +4264,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3951
4264
  }, {
3952
4265
  key: "setOtherParams",
3953
4266
  value: function () {
3954
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
3955
- var _this$otherParams22;
3956
- var _ref30,
3957
- _ref30$cover,
4267
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
4268
+ var _this$otherParams26;
4269
+ var _ref31,
4270
+ _ref31$cover,
3958
4271
  cover,
3959
- _args47 = arguments;
3960
- return _regeneratorRuntime().wrap(function _callee47$(_context47) {
3961
- while (1) switch (_context47.prev = _context47.next) {
4272
+ _args51 = arguments;
4273
+ return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4274
+ while (1) switch (_context51.prev = _context51.next) {
3962
4275
  case 0:
3963
- _ref30 = _args47.length > 1 && _args47[1] !== undefined ? _args47[1] : {}, _ref30$cover = _ref30.cover, cover = _ref30$cover === void 0 ? false : _ref30$cover;
4276
+ _ref31 = _args51.length > 1 && _args51[1] !== undefined ? _args51[1] : {}, _ref31$cover = _ref31.cover, cover = _ref31$cover === void 0 ? false : _ref31$cover;
3964
4277
  if (cover) {
3965
4278
  this.otherParams = _objectSpread({}, params);
3966
4279
  } else {
3967
4280
  this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
3968
4281
  }
3969
- this.cacheId = (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.cacheId;
3970
- _context47.next = 5;
4282
+ this.cacheId = (_this$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26.cacheId;
4283
+ _context51.next = 5;
3971
4284
  return this.syncOtherParamsToSubModules(params, {
3972
4285
  cover: cover
3973
4286
  });
3974
4287
  case 5:
3975
4288
  case "end":
3976
- return _context47.stop();
4289
+ return _context51.stop();
3977
4290
  }
3978
- }, _callee47, this);
4291
+ }, _callee51, this);
3979
4292
  }));
3980
- function setOtherParams(_x39) {
4293
+ function setOtherParams(_x45) {
3981
4294
  return _setOtherParams.apply(this, arguments);
3982
4295
  }
3983
4296
  return setOtherParams;