@pisell/pisellos 2.3.29 → 2.3.30

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 (98) hide show
  1. package/dist/model/strategy/adapter/index.d.ts +0 -4
  2. package/dist/model/strategy/adapter/index.js +1 -5
  3. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  4. package/dist/modules/Discount/index.d.ts +2 -5
  5. package/dist/modules/Discount/index.js +7 -30
  6. package/dist/modules/Discount/types.d.ts +0 -4
  7. package/dist/modules/Order/index.d.ts +28 -10
  8. package/dist/modules/Order/index.js +747 -498
  9. package/dist/modules/Order/payment-utils.d.ts +23 -0
  10. package/dist/modules/Order/payment-utils.js +203 -0
  11. package/dist/modules/Order/types.d.ts +33 -3
  12. package/dist/modules/Order/utils.js +4 -4
  13. package/dist/modules/Payment/index.d.ts +2 -0
  14. package/dist/modules/Payment/index.js +78 -49
  15. package/dist/modules/Payment/types.d.ts +26 -24
  16. package/dist/modules/Payment/types.js +2 -0
  17. package/dist/modules/Product/index.d.ts +1 -1
  18. package/dist/modules/Product/types.d.ts +0 -22
  19. package/dist/modules/ProductList/index.d.ts +1 -1
  20. package/dist/modules/ProductList/index.js +2 -4
  21. package/dist/modules/ProductList/types.d.ts +0 -2
  22. package/dist/server/index.d.ts +14 -50
  23. package/dist/server/index.js +1975 -1395
  24. package/dist/server/modules/order/index.d.ts +40 -3
  25. package/dist/server/modules/order/index.js +1200 -501
  26. package/dist/server/modules/order/types.d.ts +11 -3
  27. package/dist/server/modules/order/types.js +1 -1
  28. package/dist/server/modules/products/index.d.ts +7 -26
  29. package/dist/server/modules/products/index.js +76 -167
  30. package/dist/server/modules/products/types.d.ts +0 -14
  31. package/dist/solution/BaseSales/index.d.ts +33 -5
  32. package/dist/solution/BaseSales/index.js +622 -345
  33. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
  34. package/dist/solution/BookingByStep/index.d.ts +1 -1
  35. package/dist/solution/BookingTicket/index.d.ts +1 -1
  36. package/dist/solution/BookingTicket/index.js +2 -1
  37. package/dist/solution/BookingTicket/types.d.ts +0 -2
  38. package/dist/solution/ShopDiscount/index.js +14 -15
  39. package/dist/utils/payment-number.d.ts +9 -0
  40. package/dist/utils/payment-number.js +69 -0
  41. package/lib/model/strategy/adapter/index.d.ts +0 -4
  42. package/lib/model/strategy/adapter/index.js +2 -13
  43. package/lib/modules/Discount/index.d.ts +2 -5
  44. package/lib/modules/Discount/index.js +3 -23
  45. package/lib/modules/Discount/types.d.ts +0 -4
  46. package/lib/modules/Order/index.d.ts +28 -10
  47. package/lib/modules/Order/index.js +181 -73
  48. package/lib/modules/Order/payment-utils.d.ts +23 -0
  49. package/lib/modules/Order/payment-utils.js +193 -0
  50. package/lib/modules/Order/types.d.ts +33 -3
  51. package/lib/modules/Order/utils.js +2 -3
  52. package/lib/modules/Payment/index.d.ts +2 -0
  53. package/lib/modules/Payment/index.js +33 -12
  54. package/lib/modules/Payment/types.d.ts +26 -24
  55. package/lib/modules/Product/index.d.ts +1 -1
  56. package/lib/modules/Product/types.d.ts +0 -22
  57. package/lib/modules/ProductList/index.d.ts +1 -1
  58. package/lib/modules/ProductList/index.js +2 -4
  59. package/lib/modules/ProductList/types.d.ts +0 -2
  60. package/lib/server/index.d.ts +14 -50
  61. package/lib/server/index.js +633 -214
  62. package/lib/server/modules/order/index.d.ts +40 -3
  63. package/lib/server/modules/order/index.js +434 -31
  64. package/lib/server/modules/order/types.d.ts +11 -3
  65. package/lib/server/modules/products/index.d.ts +7 -26
  66. package/lib/server/modules/products/index.js +35 -114
  67. package/lib/server/modules/products/types.d.ts +0 -14
  68. package/lib/solution/BaseSales/index.d.ts +33 -5
  69. package/lib/solution/BaseSales/index.js +170 -19
  70. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
  71. package/lib/solution/BookingByStep/index.d.ts +1 -1
  72. package/lib/solution/BookingTicket/index.d.ts +1 -1
  73. package/lib/solution/BookingTicket/index.js +2 -1
  74. package/lib/solution/BookingTicket/types.d.ts +0 -2
  75. package/lib/solution/ShopDiscount/index.js +1 -2
  76. package/lib/utils/payment-number.d.ts +9 -0
  77. package/lib/utils/payment-number.js +64 -0
  78. package/package.json +1 -1
  79. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
  80. package/dist/model/strategy/adapter/dataVariant/adapter.js +0 -167
  81. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
  82. package/dist/model/strategy/adapter/dataVariant/evaluator.js +0 -780
  83. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
  84. package/dist/model/strategy/adapter/dataVariant/examples.js +0 -277
  85. package/dist/model/strategy/adapter/dataVariant/index.d.ts +0 -4
  86. package/dist/model/strategy/adapter/dataVariant/index.js +0 -4
  87. package/dist/model/strategy/adapter/dataVariant/type.d.ts +0 -148
  88. package/dist/model/strategy/adapter/dataVariant/type.js +0 -54
  89. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
  90. package/lib/model/strategy/adapter/dataVariant/adapter.js +0 -149
  91. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
  92. package/lib/model/strategy/adapter/dataVariant/evaluator.js +0 -583
  93. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
  94. package/lib/model/strategy/adapter/dataVariant/examples.js +0 -293
  95. package/lib/model/strategy/adapter/dataVariant/index.d.ts +0 -4
  96. package/lib/model/strategy/adapter/dataVariant/index.js +0 -38
  97. package/lib/model/strategy/adapter/dataVariant/type.d.ts +0 -148
  98. package/lib/model/strategy/adapter/dataVariant/type.js +0 -31
@@ -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, 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',
@@ -189,6 +195,34 @@ function normalizeBaseSalesRecordCollections(sourceRecord, options) {
189
195
  }
190
196
  return normalizedRecord;
191
197
  }
198
+ function getBaseSalesMetadataUid(item, metadataKey) {
199
+ var _item$metadata$metada, _item$metadata;
200
+ 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];
201
+ if (uid === undefined || uid === null || uid === '') return null;
202
+ return String(uid);
203
+ }
204
+ function mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey) {
205
+ var result = [];
206
+ var indexByUid = new Map();
207
+ var appendOrReplaceByUid = function appendOrReplaceByUid(item) {
208
+ var clonedItem = cloneDeep(item);
209
+ var uid = getBaseSalesMetadataUid(clonedItem, metadataKey);
210
+ if (!uid) {
211
+ result.push(clonedItem);
212
+ return;
213
+ }
214
+ var existingIndex = indexByUid.get(uid);
215
+ if (existingIndex !== undefined) {
216
+ result[existingIndex] = clonedItem;
217
+ return;
218
+ }
219
+ indexByUid.set(uid, result.length);
220
+ result.push(clonedItem);
221
+ };
222
+ currentValue.forEach(appendOrReplaceByUid);
223
+ loadedValue.forEach(appendOrReplaceByUid);
224
+ return result;
225
+ }
192
226
  function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, strategy) {
193
227
  var normalizedLoadedRecord = normalizeBaseSalesRecordCollections(loadedRecord || {}, {
194
228
  ensureUid: false
@@ -206,6 +240,15 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, str
206
240
  return mergeBaseSalesOrderCollection(collectionKind, Array.isArray(currentValue) ? currentValue : [], loadedValue, strategy, uidRemaps);
207
241
  }
208
242
  if (Array.isArray(currentValue) && Array.isArray(loadedValue)) {
243
+ if (key === 'payments' || key === 'payment') {
244
+ return mergeOrderPaymentListsByIdentity(currentValue, loadedValue, {
245
+ preserveUnmatchedExisting: true
246
+ });
247
+ }
248
+ var metadataKey = getBaseSalesUniqueArrayMetadataKey(key);
249
+ if (metadataKey) {
250
+ return mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey);
251
+ }
209
252
  return [].concat(_toConsumableArray(cloneDeep(currentValue)), _toConsumableArray(cloneDeep(loadedValue)));
210
253
  }
211
254
  if (Array.isArray(loadedValue)) return cloneDeep(loadedValue);
@@ -1080,6 +1123,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1080
1123
  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
1124
  return coreData === null || coreData === void 0 ? void 0 : coreData[key];
1082
1125
  }
1126
+ }, {
1127
+ key: "getPaymentNumberDevicePrefixSync",
1128
+ value: function getPaymentNumberDevicePrefixSync() {
1129
+ var _this7 = this;
1130
+ if (!this.appPlugin) return 'LOCAL';
1131
+ return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
1132
+ return _this7.getAppData(key);
1133
+ });
1134
+ }
1135
+ }, {
1136
+ key: "getPaymentNumberDevicePrefixAsync",
1137
+ value: function getPaymentNumberDevicePrefixAsync() {
1138
+ var _this8 = this;
1139
+ if (!this.appPlugin) return Promise.resolve('LOCAL');
1140
+ return resolvePaymentNumberDevicePrefix(function (key) {
1141
+ return _this8.getAppData(key);
1142
+ });
1143
+ }
1083
1144
  }, {
1084
1145
  key: "syncAppDataToTempOrder",
1085
1146
  value: function syncAppDataToTempOrder(tempOrder) {
@@ -1123,7 +1184,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1123
1184
  value: function () {
1124
1185
  var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(core) {
1125
1186
  var _this$otherParams4,
1126
- _this7 = this,
1187
+ _this9 = this,
1127
1188
  _this$otherParams5;
1128
1189
  var options,
1129
1190
  app,
@@ -1156,24 +1217,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1156
1217
  targetCacheData = this.readSessionCacheData();
1157
1218
  moduleNames = this.getRegisteredModuleNames();
1158
1219
  moduleNames.forEach(function (step) {
1159
- var reusedModule = _this7.getReusableSharedSubModule(step);
1220
+ var reusedModule = _this9.getReusableSharedSubModule(step);
1160
1221
  if (reusedModule) {
1161
- _this7.store[step] = reusedModule;
1162
- _this7.reusedSharedSubModuleNames.add(step);
1222
+ _this9.store[step] = reusedModule;
1223
+ _this9.reusedSharedSubModuleNames.add(step);
1163
1224
  return;
1164
1225
  }
1165
- var targetModule = _this7.createSubModule(step);
1226
+ var targetModule = _this9.createSubModule(step);
1166
1227
  if (!targetModule) {
1167
1228
  throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
1168
1229
  }
1169
- var hooks = _this7.getSubModuleHooks(step);
1170
- _this7.store[step] = targetModule;
1171
- _this7.core.registerModule(targetModule, _objectSpread(_objectSpread({
1230
+ var hooks = _this9.getSubModuleHooks(step);
1231
+ _this9.store[step] = targetModule;
1232
+ _this9.core.registerModule(targetModule, _objectSpread(_objectSpread({
1172
1233
  initialState: (targetCacheData === null || targetCacheData === void 0 ? void 0 : targetCacheData[targetModule.name]) || {}
1173
1234
  }, hooks ? {
1174
1235
  hooks: hooks
1175
1236
  } : {}), {}, {
1176
- otherParams: _this7.buildSubModuleOtherParams()
1237
+ otherParams: _this9.buildSubModuleOtherParams()
1177
1238
  }));
1178
1239
  });
1179
1240
  if (!(this.store.schedule && !this.isScheduleListLoaded(this.store.schedule))) {
@@ -1207,15 +1268,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1207
1268
  value: function () {
1208
1269
  var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
1209
1270
  var _this$serverOrderChan2,
1210
- _this8 = this;
1271
+ _this10 = this;
1211
1272
  return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1212
1273
  while (1) switch (_context12.prev = _context12.next) {
1213
1274
  case 0:
1214
1275
  (_this$serverOrderChan2 = this.serverOrderChangeUnsubscribe) === null || _this$serverOrderChan2 === void 0 || _this$serverOrderChan2.call(this);
1215
1276
  this.serverOrderChangeUnsubscribe = null;
1216
1277
  Object.keys(this.store).forEach(function (key) {
1217
- if (_this8.reusedSharedSubModuleNames.has(key)) return;
1218
- var sub = _this8.store[key];
1278
+ if (_this10.reusedSharedSubModuleNames.has(key)) return;
1279
+ var sub = _this10.store[key];
1219
1280
  if (sub && typeof sub.destroy === 'function') {
1220
1281
  try {
1221
1282
  sub.destroy();
@@ -1762,10 +1823,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1762
1823
  }, {
1763
1824
  key: "getHistoricalProductDiscountList",
1764
1825
  value: function getHistoricalProductDiscountList(products) {
1765
- var _this9 = this;
1826
+ var _this11 = this;
1766
1827
  var historyDiscountList = [];
1767
1828
  products.forEach(function (item) {
1768
- if (!_this9.isPersistedOrderProduct(item)) return;
1829
+ if (!_this11.isPersistedOrderProduct(item)) return;
1769
1830
  (item.discount_list || []).forEach(function (discount) {
1770
1831
  var _discount$discount, _discount$metadata, _discount$discount2, _discount$discount3, _discount$discount4;
1771
1832
  var discountId = ((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) || discount.id;
@@ -1825,11 +1886,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1825
1886
  }, {
1826
1887
  key: "shouldSkipAutoApplyFetchedDiscountsInEditMode",
1827
1888
  value: function shouldSkipAutoApplyFetchedDiscountsInEditMode(params) {
1828
- var _this10 = this;
1889
+ var _this12 = this;
1829
1890
  if (params.discountAction !== 'edit') return false;
1830
1891
  if (!params.products.length) return false;
1831
1892
  var hasDraftProduct = params.products.some(function (product) {
1832
- return !_this10.isPersistedOrderProduct(product);
1893
+ return !_this12.isPersistedOrderProduct(product);
1833
1894
  });
1834
1895
  if (hasDraftProduct) return false;
1835
1896
  var hasSelectedDiscount = params.currentDiscountList.some(function (discount) {
@@ -1926,8 +1987,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1926
1987
  }
1927
1988
  return _context20.abrupt("return", {
1928
1989
  productList: tempOrder.products || [],
1929
- discountList: currentDiscountList,
1930
- availableWalletIds: this.getAvailableWalletIds()
1990
+ discountList: currentDiscountList
1931
1991
  });
1932
1992
  case 27:
1933
1993
  nextDiscountList = this.mergeHistoricalDiscountList(preparedDiscountList || (discountModule === null || discountModule === void 0 || (_discountModule$getDi2 = discountModule.getDiscountList) === null || _discountModule$getDi2 === void 0 ? void 0 : _discountModule$getDi2.call(discountModule)) || [], tempOrder.products || []);
@@ -1962,8 +2022,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1962
2022
  case 39:
1963
2023
  return _context20.abrupt("return", {
1964
2024
  productList: tempOrder.products || [],
1965
- discountList: nextDiscountList,
1966
- availableWalletIds: this.getAvailableWalletIds()
2025
+ discountList: nextDiscountList
1967
2026
  });
1968
2027
  case 40:
1969
2028
  if (!rulesModule) {
@@ -2064,8 +2123,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2064
2123
  case 83:
2065
2124
  return _context20.abrupt("return", {
2066
2125
  productList: tempOrder.products || [],
2067
- discountList: nextDiscountList,
2068
- availableWalletIds: this.getAvailableWalletIds()
2126
+ discountList: nextDiscountList
2069
2127
  });
2070
2128
  case 84:
2071
2129
  case "end":
@@ -2078,13 +2136,6 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2078
2136
  }
2079
2137
  return loadDiscountConfig;
2080
2138
  }()
2081
- }, {
2082
- key: "getAvailableWalletIds",
2083
- value: function getAvailableWalletIds() {
2084
- var _this$store$order4;
2085
- if (!((_this$store$order4 = this.store.order) !== null && _this$store$order4 !== void 0 && _this$store$order4.getAvailableWalletIds)) return [];
2086
- return this.store.order.getAvailableWalletIds();
2087
- }
2088
2139
  }, {
2089
2140
  key: "bestDiscount",
2090
2141
  value: function () {
@@ -2632,11 +2683,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2632
2683
  return submitSalesOrder;
2633
2684
  }())
2634
2685
  }, {
2635
- key: "submitTempOrderAsync",
2686
+ key: "saveSalesOrderDraft",
2636
2687
  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;
2688
+ var _saveSalesOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
2689
+ var _params$platform, _this$otherParams10, _ref22, _params$businessCode, _this$otherParams11, _this$otherParams12, _params$channel, _params$type, _this$otherParams13;
2640
2690
  return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2641
2691
  while (1) switch (_context28.prev = _context28.next) {
2642
2692
  case 0:
@@ -2645,14 +2695,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2645
2695
  break;
2646
2696
  }
2647
2697
  throw new Error('BaseSales 解决方案需要 order 模块支持');
2698
+ case 2:
2699
+ return _context28.abrupt("return", this.store.order.saveTempOrderAsDraft(_objectSpread({
2700
+ cacheId: this.cacheId,
2701
+ 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,
2702
+ 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,
2703
+ channel: (_params$channel = params === null || params === void 0 ? void 0 : params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel(),
2704
+ 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
2705
+ }, (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
2706
+ enhancePayload: params.enhancePayload
2707
+ } : {})));
2708
+ case 3:
2709
+ case "end":
2710
+ return _context28.stop();
2711
+ }
2712
+ }, _callee28, this);
2713
+ }));
2714
+ function saveSalesOrderDraft(_x22) {
2715
+ return _saveSalesOrderDraft.apply(this, arguments);
2716
+ }
2717
+ return saveSalesOrderDraft;
2718
+ }()
2719
+ }, {
2720
+ key: "submitTempOrderAsync",
2721
+ value: function () {
2722
+ var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
2723
+ var _this$otherParams14, _this$otherParams15, _this$otherParams16, _this$otherParams17;
2724
+ var inferredPaymentStatus, submitParams;
2725
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2726
+ while (1) switch (_context29.prev = _context29.next) {
2727
+ case 0:
2728
+ if (this.store.order) {
2729
+ _context29.next = 2;
2730
+ break;
2731
+ }
2732
+ throw new Error('BaseSales 解决方案需要 order 模块支持');
2648
2733
  case 2:
2649
2734
  inferredPaymentStatus = this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
2650
2735
  submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
2651
2736
  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),
2737
+ platform: (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.platform,
2738
+ 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
2739
  channel: this.getSubmitOrderSalesChannel(),
2655
- type: (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.type
2740
+ type: (_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.type
2656
2741
  }, (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
2657
2742
  payments: params.payments
2658
2743
  } : {}), inferredPaymentStatus !== undefined ? {
@@ -2664,14 +2749,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2664
2749
  } : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
2665
2750
  enhancePayload: params.enhancePayload
2666
2751
  } : {});
2667
- return _context28.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
2752
+ return _context29.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
2668
2753
  case 5:
2669
2754
  case "end":
2670
- return _context28.stop();
2755
+ return _context29.stop();
2671
2756
  }
2672
- }, _callee28, this);
2757
+ }, _callee29, this);
2673
2758
  }));
2674
- function submitTempOrderAsync(_x22) {
2759
+ function submitTempOrderAsync(_x23) {
2675
2760
  return _submitTempOrderAsync.apply(this, arguments);
2676
2761
  }
2677
2762
  return submitTempOrderAsync;
@@ -2679,14 +2764,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2679
2764
  }, {
2680
2765
  key: "printLocalOrderReceipt",
2681
2766
  value: function () {
2682
- var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(lookup) {
2683
- var _this$otherParams14, _this$otherParams15, _this$otherParams16, _this$otherParams17;
2684
- 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) {
2767
+ var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(lookup) {
2768
+ var _this$otherParams18, _this$otherParams19, _this$otherParams20, _this$otherParams21;
2769
+ var hasLookup, lookupPayload, context, payload, response, _this$store$order$app, _this$store$order4, _data;
2770
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2771
+ while (1) switch (_context30.prev = _context30.next) {
2687
2772
  case 0:
2688
2773
  if (this.store.order) {
2689
- _context29.next = 2;
2774
+ _context30.next = 2;
2690
2775
  break;
2691
2776
  }
2692
2777
  throw new Error('BaseSales 解决方案需要 order 模块支持');
@@ -2698,10 +2783,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2698
2783
  external_sale_number: lookup
2699
2784
  };
2700
2785
  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),
2786
+ platform: (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.platform,
2787
+ 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
2788
  channel: this.getSubmitOrderSalesChannel(),
2704
- type: (_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.type
2789
+ type: (_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.type
2705
2790
  };
2706
2791
  payload = hasLookup ? _objectSpread(_objectSpread({}, lookupPayload), {}, {
2707
2792
  lookup_order_from_db: 1,
@@ -2717,28 +2802,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2717
2802
  channel: context.channel,
2718
2803
  type: context.type
2719
2804
  });
2720
- _context29.next = 8;
2805
+ _context30.next = 8;
2721
2806
  return this.request.post('/local/print-order', payload, {
2722
2807
  osServer: true,
2723
2808
  customToast: function customToast() {}
2724
2809
  });
2725
2810
  case 8:
2726
- response = _context29.sent;
2811
+ response = _context30.sent;
2727
2812
  if (hasLookup) {
2728
- _context29.next = 12;
2813
+ _context30.next = 12;
2729
2814
  break;
2730
2815
  }
2731
- _context29.next = 12;
2732
- return (_this$store$order$app = (_this$store$order5 = this.store.order).applyLocalPrintOrderNumbers) === null || _this$store$order$app === void 0 ? void 0 : _this$store$order$app.call(_this$store$order5, response === null || response === void 0 || (_data = response.data) === null || _data === void 0 ? void 0 : _data.order);
2816
+ _context30.next = 12;
2817
+ return (_this$store$order$app = (_this$store$order4 = this.store.order).applyLocalPrintOrderNumbers) === null || _this$store$order$app === void 0 ? void 0 : _this$store$order$app.call(_this$store$order4, response === null || response === void 0 || (_data = response.data) === null || _data === void 0 ? void 0 : _data.order);
2733
2818
  case 12:
2734
- return _context29.abrupt("return", response);
2819
+ return _context30.abrupt("return", response);
2735
2820
  case 13:
2736
2821
  case "end":
2737
- return _context29.stop();
2822
+ return _context30.stop();
2738
2823
  }
2739
- }, _callee29, this);
2824
+ }, _callee30, this);
2740
2825
  }));
2741
- function printLocalOrderReceipt(_x23) {
2826
+ function printLocalOrderReceipt(_x24) {
2742
2827
  return _printLocalOrderReceipt.apply(this, arguments);
2743
2828
  }
2744
2829
  return printLocalOrderReceipt;
@@ -2746,9 +2831,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2746
2831
  }, {
2747
2832
  key: "getSubmitPaymentStatus",
2748
2833
  value: function getSubmitPaymentStatus(paymentStatus) {
2749
- var _this$store$order6, _this$store$order6$ge;
2834
+ var _this$store$order5, _this$store$order5$ge;
2750
2835
  if (paymentStatus !== undefined) return paymentStatus;
2751
- var amountSnapshot = (_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 || (_this$store$order6$ge = _this$store$order6.getOrderAmountSnapshot) === null || _this$store$order6$ge === void 0 ? void 0 : _this$store$order6$ge.call(_this$store$order6);
2836
+ var amountSnapshot = (_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 || (_this$store$order5$ge = _this$store$order5.getOrderAmountSnapshot) === null || _this$store$order5$ge === void 0 ? void 0 : _this$store$order5$ge.call(_this$store$order5);
2752
2837
  if (!amountSnapshot) return undefined;
2753
2838
  try {
2754
2839
  return new Decimal(amountSnapshot.amountGap || 0).lte(0) ? 'paid' : undefined;
@@ -2759,20 +2844,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2759
2844
  }, {
2760
2845
  key: "syncPaymentsToOrder",
2761
2846
  value: function () {
2762
- var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
2763
- var _ref22, _params$businessCode, _this$otherParams18, _this$otherParams19, _params$channel;
2847
+ var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
2848
+ var _ref23, _params$businessCode2, _this$otherParams22, _this$otherParams23, _params$channel2;
2764
2849
  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) {
2850
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2851
+ while (1) switch (_context31.prev = _context31.next) {
2767
2852
  case 0:
2768
2853
  if (this.store.order) {
2769
- _context30.next = 2;
2854
+ _context31.next = 2;
2770
2855
  break;
2771
2856
  }
2772
2857
  throw new Error('order 模块未初始化');
2773
2858
  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();
2859
+ 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;
2860
+ channel = (_params$channel2 = params.channel) !== null && _params$channel2 !== void 0 ? _params$channel2 : this.getSubmitOrderSalesChannel();
2776
2861
  syncParams = _objectSpread(_objectSpread(_objectSpread({}, params), businessCode !== undefined ? {
2777
2862
  businessCode: businessCode
2778
2863
  } : {}), channel !== undefined ? {
@@ -2780,14 +2865,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2780
2865
  } : {});
2781
2866
  syncState = this.store.order.getOrderSyncState();
2782
2867
  if (!(params.submitWhenPaid && syncState === 'submitting')) {
2783
- _context30.next = 9;
2868
+ _context31.next = 9;
2784
2869
  break;
2785
2870
  }
2786
2871
  this.queueLatestAutoPaymentSync();
2787
- return _context30.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
2872
+ return _context31.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
2788
2873
  case 9:
2789
2874
  payments = params.payments || [];
2790
- _context30.next = 12;
2875
+ _context31.next = 12;
2791
2876
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncStart, {
2792
2877
  payments: payments,
2793
2878
  params: syncParams,
@@ -2795,11 +2880,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2795
2880
  orderSnapshot: this.store.order.getOrderSnapshot()
2796
2881
  });
2797
2882
  case 12:
2798
- _context30.prev = 12;
2799
- _context30.next = 15;
2883
+ _context31.prev = 12;
2884
+ _context31.next = 15;
2800
2885
  return this.store.order.syncPaymentsToOrder(syncParams);
2801
2886
  case 15:
2802
- syncResult = _context30.sent;
2887
+ syncResult = _context31.sent;
2803
2888
  latestPayments = this.store.order.getOrderPayments();
2804
2889
  amountSnapshot = this.store.order.getOrderAmountSnapshot();
2805
2890
  orderSnapshot = this.store.order.getOrderSnapshot();
@@ -2817,25 +2902,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2817
2902
  depositAmount: syncResult.depositAmount,
2818
2903
  orderExpectedAmount: syncResult.orderExpectedAmount
2819
2904
  };
2820
- _context30.next = 22;
2905
+ _context31.next = 22;
2821
2906
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, syncPayload);
2822
2907
  case 22:
2823
2908
  if (!(syncResult.isDepositFullyPaid && !syncResult.isOrderFullyPaid)) {
2824
- _context30.next = 25;
2909
+ _context31.next = 25;
2825
2910
  break;
2826
2911
  }
2827
- _context30.next = 25;
2912
+ _context31.next = 25;
2828
2913
  return this.effectsEmit(BaseSalesHookNames.onDepositPaymentSyncEnd, syncPayload);
2829
2914
  case 25:
2830
2915
  this.scheduleQueuedAutoPaymentSyncFlush(0);
2831
- return _context30.abrupt("return", syncResult);
2916
+ return _context31.abrupt("return", syncResult);
2832
2917
  case 29:
2833
- _context30.prev = 29;
2834
- _context30.t0 = _context30["catch"](12);
2835
- _context30.next = 33;
2918
+ _context31.prev = 29;
2919
+ _context31.t0 = _context31["catch"](12);
2920
+ _context31.next = 33;
2836
2921
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
2837
2922
  ok: false,
2838
- error: _context30.t0,
2923
+ error: _context31.t0,
2839
2924
  payments: this.store.order.getOrderPayments(),
2840
2925
  params: syncParams,
2841
2926
  amountSnapshot: this.store.order.getOrderAmountSnapshot(),
@@ -2843,14 +2928,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2843
2928
  });
2844
2929
  case 33:
2845
2930
  this.scheduleQueuedAutoPaymentSyncFlush(0);
2846
- throw _context30.t0;
2931
+ throw _context31.t0;
2847
2932
  case 35:
2848
2933
  case "end":
2849
- return _context30.stop();
2934
+ return _context31.stop();
2850
2935
  }
2851
- }, _callee30, this, [[12, 29]]);
2936
+ }, _callee31, this, [[12, 29]]);
2852
2937
  }));
2853
- function syncPaymentsToOrder(_x24) {
2938
+ function syncPaymentsToOrder(_x25) {
2854
2939
  return _syncPaymentsToOrder.apply(this, arguments);
2855
2940
  }
2856
2941
  return syncPaymentsToOrder;
@@ -2887,58 +2972,58 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2887
2972
  }, {
2888
2973
  key: "scheduleQueuedAutoPaymentSyncFlush",
2889
2974
  value: function scheduleQueuedAutoPaymentSyncFlush() {
2890
- var _this11 = this;
2975
+ var _this13 = this;
2891
2976
  var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;
2892
2977
  if (!this.queuedAutoPaymentSync) return;
2893
2978
  if (this.autoPaymentSyncTimer) return;
2894
2979
  this.autoPaymentSyncTimer = setTimeout(function () {
2895
- _this11.autoPaymentSyncTimer = null;
2896
- void _this11.flushQueuedAutoPaymentSync();
2980
+ _this13.autoPaymentSyncTimer = null;
2981
+ void _this13.flushQueuedAutoPaymentSync();
2897
2982
  }, delay);
2898
2983
  }
2899
2984
  }, {
2900
2985
  key: "flushQueuedAutoPaymentSync",
2901
2986
  value: function () {
2902
- var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
2987
+ var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
2903
2988
  var payments;
2904
- return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2905
- while (1) switch (_context31.prev = _context31.next) {
2989
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2990
+ while (1) switch (_context32.prev = _context32.next) {
2906
2991
  case 0:
2907
2992
  if (this.store.order) {
2908
- _context31.next = 2;
2993
+ _context32.next = 2;
2909
2994
  break;
2910
2995
  }
2911
- return _context31.abrupt("return");
2996
+ return _context32.abrupt("return");
2912
2997
  case 2:
2913
2998
  if (!(!this.queuedAutoPaymentSync || this.autoPaymentSyncFlushing)) {
2914
- _context31.next = 4;
2999
+ _context32.next = 4;
2915
3000
  break;
2916
3001
  }
2917
- return _context31.abrupt("return");
3002
+ return _context32.abrupt("return");
2918
3003
  case 4:
2919
3004
  if (!(this.store.order.getOrderSyncState() === 'submitting')) {
2920
- _context31.next = 7;
3005
+ _context32.next = 7;
2921
3006
  break;
2922
3007
  }
2923
3008
  this.scheduleQueuedAutoPaymentSyncFlush();
2924
- return _context31.abrupt("return");
3009
+ return _context32.abrupt("return");
2925
3010
  case 7:
2926
3011
  this.autoPaymentSyncFlushing = true;
2927
- _context31.prev = 8;
3012
+ _context32.prev = 8;
2928
3013
  case 9:
2929
3014
  if (!this.queuedAutoPaymentSync) {
2930
- _context31.next = 18;
3015
+ _context32.next = 18;
2931
3016
  break;
2932
3017
  }
2933
3018
  this.queuedAutoPaymentSync = false;
2934
3019
  payments = this.store.order.getOrderPayments();
2935
3020
  if (payments.length) {
2936
- _context31.next = 14;
3021
+ _context32.next = 14;
2937
3022
  break;
2938
3023
  }
2939
- return _context31.abrupt("continue", 9);
3024
+ return _context32.abrupt("continue", 9);
2940
3025
  case 14:
2941
- _context31.next = 16;
3026
+ _context32.next = 16;
2942
3027
  return this.syncPaymentsToOrder({
2943
3028
  payments: payments,
2944
3029
  paymentStatus: this.getPaymentStatusForSync(payments),
@@ -2946,44 +3031,91 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2946
3031
  smallTicketDataFlag: 1
2947
3032
  });
2948
3033
  case 16:
2949
- _context31.next = 9;
3034
+ _context32.next = 9;
2950
3035
  break;
2951
3036
  case 18:
2952
- _context31.next = 23;
3037
+ _context32.next = 23;
2953
3038
  break;
2954
3039
  case 20:
2955
- _context31.prev = 20;
2956
- _context31.t0 = _context31["catch"](8);
3040
+ _context32.prev = 20;
3041
+ _context32.t0 = _context32["catch"](8);
2957
3042
  this.logError('queued auto sync payments failed', {
2958
- error: _context31.t0 instanceof Error ? _context31.t0.message : String(_context31.t0)
3043
+ error: _context32.t0 instanceof Error ? _context32.t0.message : String(_context32.t0)
2959
3044
  });
2960
3045
  case 23:
2961
- _context31.prev = 23;
3046
+ _context32.prev = 23;
2962
3047
  this.autoPaymentSyncFlushing = false;
2963
3048
  if (this.queuedAutoPaymentSync) {
2964
3049
  this.scheduleQueuedAutoPaymentSyncFlush(0);
2965
3050
  }
2966
- return _context31.finish(23);
3051
+ return _context32.finish(23);
2967
3052
  case 27:
2968
3053
  case "end":
2969
- return _context31.stop();
3054
+ return _context32.stop();
2970
3055
  }
2971
- }, _callee31, this, [[8, 20, 23, 27]]);
3056
+ }, _callee32, this, [[8, 20, 23, 27]]);
2972
3057
  }));
2973
3058
  function flushQueuedAutoPaymentSync() {
2974
3059
  return _flushQueuedAutoPaymentSync.apply(this, arguments);
2975
3060
  }
2976
3061
  return flushQueuedAutoPaymentSync;
2977
- }() /** 追加单个支付项到当前订单。 */
3062
+ }()
3063
+ /**
3064
+ * 同步兼容入口。无法等待 IoT 短号时,按调用当下的 device_id 或 LOCAL 生成。
3065
+ */
2978
3066
  }, {
2979
3067
  key: "addOrderPayment",
2980
3068
  value: function addOrderPayment(payment) {
2981
- var _this$otherParams20,
3069
+ var hasPaymentNumber = String(payment.payment_number || '').trim() !== '';
3070
+ return this.addOrderPaymentWithDevicePrefix(payment, hasPaymentNumber ? 'LOCAL' : this.getPaymentNumberDevicePrefixSync());
3071
+ }
3072
+
3073
+ /** 创建新支付项时读取最新设备短号,不缓存运行时设备信息。 */
3074
+ }, {
3075
+ key: "addOrderPaymentAsync",
3076
+ value: (function () {
3077
+ var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(payment) {
3078
+ var paymentRecord, hasPaymentNumber, devicePrefix;
3079
+ return _regeneratorRuntime().wrap(function _callee33$(_context33) {
3080
+ while (1) switch (_context33.prev = _context33.next) {
3081
+ case 0:
3082
+ paymentRecord = payment;
3083
+ hasPaymentNumber = String(paymentRecord.payment_number || '').trim() !== '';
3084
+ if (!hasPaymentNumber) {
3085
+ _context33.next = 6;
3086
+ break;
3087
+ }
3088
+ _context33.t0 = 'LOCAL';
3089
+ _context33.next = 9;
3090
+ break;
3091
+ case 6:
3092
+ _context33.next = 8;
3093
+ return this.getPaymentNumberDevicePrefixAsync();
3094
+ case 8:
3095
+ _context33.t0 = _context33.sent;
3096
+ case 9:
3097
+ devicePrefix = _context33.t0;
3098
+ return _context33.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
3099
+ case 11:
3100
+ case "end":
3101
+ return _context33.stop();
3102
+ }
3103
+ }, _callee33, this);
3104
+ }));
3105
+ function addOrderPaymentAsync(_x26) {
3106
+ return _addOrderPaymentAsync.apply(this, arguments);
3107
+ }
3108
+ return addOrderPaymentAsync;
3109
+ }())
3110
+ }, {
3111
+ key: "addOrderPaymentWithDevicePrefix",
3112
+ value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
3113
+ var _this$otherParams24,
2982
3114
  _paymentRecord$paymen,
2983
3115
  _paymentRecord$create,
2984
- _ref23,
3116
+ _ref24,
2985
3117
  _paymentRecord$origin,
2986
- _this12 = this;
3118
+ _this14 = this;
2987
3119
  if (!this.store.order) throw new Error('order 模块未初始化');
2988
3120
  var paymentRecord = payment;
2989
3121
  var paymentAmount = new Decimal(paymentRecord.amount || 0);
@@ -2994,25 +3126,26 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2994
3126
  return this.store.order.getOrderPayments();
2995
3127
  }
2996
3128
  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;
3129
+ var shopWalletPassId = (_this$otherParams24 = this.otherParams) === null || _this$otherParams24 === void 0 ? void 0 : _this$otherParams24.shop_wallet_pass_id;
2998
3130
  if (shopWalletPassId !== undefined && shopWalletPassId !== null) {
2999
3131
  metadata.shop_wallet_pass_id = shopWalletPassId;
3000
3132
  }
3001
- if (!metadata.unique_payment_number) {
3002
- metadata.unique_payment_number = createUuidV4();
3003
- }
3133
+ var normalizedPaymentRecord = ensureOrderPaymentNumber(paymentRecord, devicePrefix, createUuidV4);
3004
3134
  var paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
3005
3135
  var paymentTime = (_paymentRecord$paymen = paymentRecord.payment_time) !== null && _paymentRecord$paymen !== void 0 ? _paymentRecord$paymen : paymentTimestamp;
3006
3136
  var createdAt = (_paymentRecord$create = paymentRecord.created_at) !== null && _paymentRecord$create !== void 0 ? _paymentRecord$create : paymentTimestamp;
3007
3137
  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 ? {
3138
+ 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;
3139
+ var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({}, normalizedPaymentRecord), calculatedServiceFee !== undefined ? {
3010
3140
  service_fee: calculatedServiceFee
3011
3141
  } : {}), {}, {
3012
3142
  metadata: metadata,
3013
3143
  payment_time: paymentTime,
3014
3144
  created_at: createdAt
3015
3145
  }));
3146
+ if (paymentRecord.status === 'payment_pending') {
3147
+ return payments;
3148
+ }
3016
3149
  var amountSnapshot = this.store.order.getOrderAmountSnapshot();
3017
3150
  var syncState = this.store.order.getOrderSyncState();
3018
3151
  if (amountSnapshot) {
@@ -3026,7 +3159,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3026
3159
  submitWhenPaid: true,
3027
3160
  smallTicketDataFlag: 1
3028
3161
  }).catch(function (error) {
3029
- _this12.logError('auto sync payments failed', {
3162
+ _this14.logError('auto sync payments failed', {
3030
3163
  error: error instanceof Error ? error.message : String(error)
3031
3164
  });
3032
3165
  });
@@ -3037,12 +3170,131 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3037
3170
  /** 更新当前订单中的指定支付项。 */
3038
3171
  }, {
3039
3172
  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
- /** 删除当前订单中的指定支付项。 */
3173
+ value: (function () {
3174
+ var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(paymentIdentity, updates) {
3175
+ var _result$payment, _result$payment2;
3176
+ var options,
3177
+ matchMode,
3178
+ previousMatch,
3179
+ previousPayment,
3180
+ _this$store$order$get2,
3181
+ currentPayments,
3182
+ _syncResult,
3183
+ _options$smallTicketD,
3184
+ result,
3185
+ draftResult,
3186
+ draftError,
3187
+ becamePaid,
3188
+ shouldSubmit,
3189
+ syncResult,
3190
+ _options$smallTicketD2,
3191
+ _args34 = arguments;
3192
+ return _regeneratorRuntime().wrap(function _callee34$(_context34) {
3193
+ while (1) switch (_context34.prev = _context34.next) {
3194
+ case 0:
3195
+ options = _args34.length > 2 && _args34[2] !== undefined ? _args34[2] : {};
3196
+ if (this.store.order) {
3197
+ _context34.next = 3;
3198
+ break;
3199
+ }
3200
+ throw new Error('order 模块未初始化');
3201
+ case 3:
3202
+ matchMode = options.matchBy === 'compat' || options.matchBy === 'legacy' ? 'compat' : 'payment_number';
3203
+ previousMatch = resolveOrderPaymentIdentity(this.store.order.getOrderPayments(), paymentIdentity, matchMode);
3204
+ previousPayment = previousMatch === null || previousMatch === void 0 ? void 0 : previousMatch.payment;
3205
+ if (!((previousPayment === null || previousPayment === void 0 ? void 0 : previousPayment.status) === 'paid' && !options.applyUpdatesWhenPaid)) {
3206
+ _context34.next = 13;
3207
+ break;
3208
+ }
3209
+ currentPayments = this.store.order.getOrderPayments();
3210
+ if (!(options.submitWhenPaid && options.forceSubmitIfPaid)) {
3211
+ _context34.next = 12;
3212
+ break;
3213
+ }
3214
+ _context34.next = 11;
3215
+ return this.syncPaymentsToOrder({
3216
+ payments: currentPayments,
3217
+ paymentStatus: this.getPaymentStatusForSync(currentPayments),
3218
+ submitWhenPaid: true,
3219
+ smallTicketDataFlag: (_options$smallTicketD = options.smallTicketDataFlag) !== null && _options$smallTicketD !== void 0 ? _options$smallTicketD : 1
3220
+ });
3221
+ case 11:
3222
+ _syncResult = _context34.sent;
3223
+ case 12:
3224
+ return _context34.abrupt("return", _objectSpread({
3225
+ updated: false,
3226
+ payment: previousPayment,
3227
+ payments: currentPayments,
3228
+ summary: ((_this$store$order$get2 = this.store.order.getOrderAmountSnapshot()) === null || _this$store$order$get2 === void 0 ? void 0 : _this$store$order$get2.summary) || null
3229
+ }, _syncResult !== undefined ? {
3230
+ syncResult: _syncResult
3231
+ } : {}));
3232
+ case 13:
3233
+ _context34.next = 15;
3234
+ return this.store.order.updateOrderPayment(paymentIdentity, updates, {
3235
+ matchBy: matchMode
3236
+ });
3237
+ case 15:
3238
+ result = _context34.sent;
3239
+ if (!(options.persistDraft !== false)) {
3240
+ _context34.next = 29;
3241
+ break;
3242
+ }
3243
+ _context34.prev = 17;
3244
+ _context34.next = 20;
3245
+ return this.saveSalesOrderDraft();
3246
+ case 20:
3247
+ draftResult = _context34.sent;
3248
+ _context34.next = 29;
3249
+ break;
3250
+ case 23:
3251
+ _context34.prev = 23;
3252
+ _context34.t0 = _context34["catch"](17);
3253
+ draftError = _context34.t0;
3254
+ this.logError('updateOrderPayment: 保存支付草稿失败', {
3255
+ paymentIdentity: paymentIdentity,
3256
+ error: _context34.t0 instanceof Error ? _context34.t0.message : String(_context34.t0)
3257
+ });
3258
+ if (options.submitWhenPaid) {
3259
+ _context34.next = 29;
3260
+ break;
3261
+ }
3262
+ throw _context34.t0;
3263
+ case 29:
3264
+ 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';
3265
+ shouldSubmit = Boolean(options.submitWhenPaid && ((_result$payment2 = result.payment) === null || _result$payment2 === void 0 ? void 0 : _result$payment2.status) === 'paid' && (becamePaid || options.forceSubmitIfPaid));
3266
+ if (!shouldSubmit) {
3267
+ _context34.next = 35;
3268
+ break;
3269
+ }
3270
+ _context34.next = 34;
3271
+ return this.syncPaymentsToOrder({
3272
+ payments: result.payments,
3273
+ paymentStatus: this.getPaymentStatusForSync(result.payments),
3274
+ submitWhenPaid: true,
3275
+ smallTicketDataFlag: (_options$smallTicketD2 = options.smallTicketDataFlag) !== null && _options$smallTicketD2 !== void 0 ? _options$smallTicketD2 : 1
3276
+ });
3277
+ case 34:
3278
+ syncResult = _context34.sent;
3279
+ case 35:
3280
+ return _context34.abrupt("return", _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, result), draftResult !== undefined ? {
3281
+ draftResult: draftResult
3282
+ } : {}), draftError !== undefined ? {
3283
+ draftError: draftError
3284
+ } : {}), syncResult !== undefined ? {
3285
+ syncResult: syncResult
3286
+ } : {}));
3287
+ case 36:
3288
+ case "end":
3289
+ return _context34.stop();
3290
+ }
3291
+ }, _callee34, this, [[17, 23]]);
3292
+ }));
3293
+ function updateOrderPayment(_x27, _x28) {
3294
+ return _updateOrderPayment.apply(this, arguments);
3295
+ }
3296
+ return updateOrderPayment;
3297
+ }() /** 删除当前订单中的指定支付项。 */)
3046
3298
  }, {
3047
3299
  key: "deleteOrderPayment",
3048
3300
  value: function deleteOrderPayment(paymentIdentity) {
@@ -3057,6 +3309,31 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3057
3309
  if (!this.store.order) throw new Error('order 模块未初始化');
3058
3310
  return this.store.order.updateVoucherOrderPayments(payments, options);
3059
3311
  }
3312
+ }, {
3313
+ key: "updateVoucherOrderPaymentsAsync",
3314
+ value: function () {
3315
+ var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(payments, options) {
3316
+ return _regeneratorRuntime().wrap(function _callee35$(_context35) {
3317
+ while (1) switch (_context35.prev = _context35.next) {
3318
+ case 0:
3319
+ if (this.store.order) {
3320
+ _context35.next = 2;
3321
+ break;
3322
+ }
3323
+ throw new Error('order 模块未初始化');
3324
+ case 2:
3325
+ return _context35.abrupt("return", this.store.order.updateVoucherOrderPaymentsAsync(payments, options));
3326
+ case 3:
3327
+ case "end":
3328
+ return _context35.stop();
3329
+ }
3330
+ }, _callee35, this);
3331
+ }));
3332
+ function updateVoucherOrderPaymentsAsync(_x29, _x30) {
3333
+ return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
3334
+ }
3335
+ return updateVoucherOrderPaymentsAsync;
3336
+ }()
3060
3337
  }, {
3061
3338
  key: "confirmPendingVoucherPayments",
3062
3339
  value: function confirmPendingVoucherPayments() {
@@ -3072,8 +3349,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3072
3349
  }, {
3073
3350
  key: "getWalletProductList",
3074
3351
  value: function getWalletProductList() {
3075
- var _this$store$order7, _tempOrder$products;
3076
- var tempOrder = (_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 ? void 0 : _this$store$order7.getTempOrder();
3352
+ var _this$store$order6, _tempOrder$products;
3353
+ var tempOrder = (_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 ? void 0 : _this$store$order6.getTempOrder();
3077
3354
  if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$products = tempOrder.products) !== null && _tempOrder$products !== void 0 && _tempOrder$products.length)) return [];
3078
3355
  // 过滤出有 product_id的商品来,如果没有代表他是自定义商品,不需要参与 wallet
3079
3356
  // debugger
@@ -3133,20 +3410,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3133
3410
  }, {
3134
3411
  key: "initWalletData",
3135
3412
  value: function () {
3136
- var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
3137
- var _params$order_wait_pa, _ref24, _tempOrder$is_price_i;
3413
+ var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
3414
+ var _params$order_wait_pa, _ref25, _tempOrder$is_price_i;
3138
3415
  var snapshot, tempOrder, amount, walletBusinessData, result;
3139
- return _regeneratorRuntime().wrap(function _callee32$(_context32) {
3140
- while (1) switch (_context32.prev = _context32.next) {
3416
+ return _regeneratorRuntime().wrap(function _callee36$(_context36) {
3417
+ while (1) switch (_context36.prev = _context36.next) {
3141
3418
  case 0:
3142
3419
  if (this.store.order) {
3143
- _context32.next = 2;
3420
+ _context36.next = 2;
3144
3421
  break;
3145
3422
  }
3146
3423
  throw new Error('order 模块未初始化');
3147
3424
  case 2:
3148
3425
  if (this.store.payment) {
3149
- _context32.next = 4;
3426
+ _context36.next = 4;
3150
3427
  break;
3151
3428
  }
3152
3429
  throw new Error('payment 模块未初始化');
@@ -3155,10 +3432,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3155
3432
  tempOrder = snapshot === null || snapshot === void 0 ? void 0 : snapshot.tempOrder;
3156
3433
  amount = snapshot === null || snapshot === void 0 ? void 0 : snapshot.amount;
3157
3434
  if (!(!tempOrder || !amount)) {
3158
- _context32.next = 9;
3435
+ _context36.next = 9;
3159
3436
  break;
3160
3437
  }
3161
- return _context32.abrupt("return", {
3438
+ return _context36.abrupt("return", {
3162
3439
  walletRecommendList: [],
3163
3440
  userIdentificationCodes: [],
3164
3441
  transformList: [],
@@ -3177,15 +3454,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3177
3454
  },
3178
3455
  products: this.getWalletProductList(),
3179
3456
  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
3457
+ 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
3458
  }, snapshot.identity.orderId ? {
3182
3459
  payment_order_id: String(snapshot.identity.orderId)
3183
3460
  } : {});
3184
- _context32.next = 12;
3461
+ _context36.next = 12;
3185
3462
  return this.store.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
3186
3463
  case 12:
3187
- result = _context32.sent;
3188
- _context32.next = 15;
3464
+ result = _context36.sent;
3465
+ _context36.next = 15;
3189
3466
  return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
3190
3467
  orderId: snapshot.identity.orderId,
3191
3468
  customerId: walletBusinessData.customer_id,
@@ -3197,14 +3474,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3197
3474
  timestamp: Date.now()
3198
3475
  });
3199
3476
  case 15:
3200
- return _context32.abrupt("return", result);
3477
+ return _context36.abrupt("return", result);
3201
3478
  case 16:
3202
3479
  case "end":
3203
- return _context32.stop();
3480
+ return _context36.stop();
3204
3481
  }
3205
- }, _callee32, this);
3482
+ }, _callee36, this);
3206
3483
  }));
3207
- function initWalletData(_x25) {
3484
+ function initWalletData(_x31) {
3208
3485
  return _initWalletData.apply(this, arguments);
3209
3486
  }
3210
3487
  return initWalletData;
@@ -3231,35 +3508,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3231
3508
  }, {
3232
3509
  key: "getPaymentMethodsAsync",
3233
3510
  value: (function () {
3234
- var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
3511
+ var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {
3235
3512
  var response, paymentMethods;
3236
- return _regeneratorRuntime().wrap(function _callee33$(_context33) {
3237
- while (1) switch (_context33.prev = _context33.next) {
3513
+ return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3514
+ while (1) switch (_context37.prev = _context37.next) {
3238
3515
  case 0:
3239
- _context33.prev = 0;
3240
- _context33.next = 3;
3516
+ _context37.prev = 0;
3517
+ _context37.next = 3;
3241
3518
  return this.request.get('/pay/custom-payment/all', {
3242
3519
  filterPaymentMethods: true
3243
3520
  }, {
3244
3521
  osServer: true
3245
3522
  });
3246
3523
  case 3:
3247
- response = _context33.sent;
3524
+ response = _context37.sent;
3248
3525
  paymentMethods = (response === null || response === void 0 ? void 0 : response.data) || [];
3249
3526
  this.paymentMethodsCache = Array.isArray(paymentMethods) ? _toConsumableArray(paymentMethods) : [];
3250
- return _context33.abrupt("return", this.getPaymentMethods());
3527
+ return _context37.abrupt("return", this.getPaymentMethods());
3251
3528
  case 9:
3252
- _context33.prev = 9;
3253
- _context33.t0 = _context33["catch"](0);
3529
+ _context37.prev = 9;
3530
+ _context37.t0 = _context37["catch"](0);
3254
3531
  this.logWarning('getPaymentMethodsAsync: 获取支付方式列表失败,使用缓存列表', {
3255
- error: _context33.t0 instanceof Error ? _context33.t0.message : String(_context33.t0)
3532
+ error: _context37.t0 instanceof Error ? _context37.t0.message : String(_context37.t0)
3256
3533
  });
3257
- return _context33.abrupt("return", this.getPaymentMethods());
3534
+ return _context37.abrupt("return", this.getPaymentMethods());
3258
3535
  case 13:
3259
3536
  case "end":
3260
- return _context33.stop();
3537
+ return _context37.stop();
3261
3538
  }
3262
- }, _callee33, this, [[0, 9]]);
3539
+ }, _callee37, this, [[0, 9]]);
3263
3540
  }));
3264
3541
  function getPaymentMethodsAsync() {
3265
3542
  return _getPaymentMethodsAsync.apply(this, arguments);
@@ -3307,49 +3584,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3307
3584
  }, {
3308
3585
  key: "sendCustomerPayLink",
3309
3586
  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) {
3587
+ var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
3588
+ var orderIds, _ref26, _ref27, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
3589
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3590
+ while (1) switch (_context38.prev = _context38.next) {
3314
3591
  case 0:
3315
3592
  if (this.store.order) {
3316
- _context34.next = 2;
3593
+ _context38.next = 2;
3317
3594
  break;
3318
3595
  }
3319
3596
  throw new Error('order 模块未初始化');
3320
3597
  case 2:
3321
3598
  orderIds = params.order_ids || params.orderIds || [];
3322
3599
  if (!(!orderIds.length || params.submitBeforeSend)) {
3323
- _context34.next = 11;
3600
+ _context38.next = 11;
3324
3601
  break;
3325
3602
  }
3326
- _context34.next = 6;
3603
+ _context38.next = 6;
3327
3604
  return this.submitSalesOrder({
3328
3605
  smallTicketDataFlag: 1
3329
3606
  });
3330
3607
  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;
3608
+ submitResult = _context38.sent;
3609
+ 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
3610
  if (orderId) {
3334
- _context34.next = 10;
3611
+ _context38.next = 10;
3335
3612
  break;
3336
3613
  }
3337
3614
  throw new Error('本地订单提交云端失败,无法发送支付链接');
3338
3615
  case 10:
3339
3616
  orderIds = [orderId];
3340
3617
  case 11:
3341
- return _context34.abrupt("return", this.store.order.sendCustomerPayLink({
3618
+ return _context38.abrupt("return", this.store.order.sendCustomerPayLink({
3342
3619
  emails: params.emails,
3343
3620
  notify_action: params.notify_action,
3344
3621
  order_ids: orderIds
3345
3622
  }));
3346
3623
  case 12:
3347
3624
  case "end":
3348
- return _context34.stop();
3625
+ return _context38.stop();
3349
3626
  }
3350
- }, _callee34, this);
3627
+ }, _callee38, this);
3351
3628
  }));
3352
- function sendCustomerPayLink(_x26) {
3629
+ function sendCustomerPayLink(_x32) {
3353
3630
  return _sendCustomerPayLink.apply(this, arguments);
3354
3631
  }
3355
3632
  return sendCustomerPayLink;
@@ -3362,27 +3639,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3362
3639
  }, {
3363
3640
  key: "calculateProductBookingPrice",
3364
3641
  value: function () {
3365
- var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
3642
+ var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
3366
3643
  var _params$customer_id;
3367
3644
  var quotation, customerId, authoritativeProduct, product;
3368
- return _regeneratorRuntime().wrap(function _callee35$(_context35) {
3369
- while (1) switch (_context35.prev = _context35.next) {
3645
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3646
+ while (1) switch (_context39.prev = _context39.next) {
3370
3647
  case 0:
3371
3648
  quotation = this.store.quotation;
3372
3649
  customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : this.getCurrentOrderCustomerId();
3373
- _context35.next = 4;
3650
+ _context39.next = 4;
3374
3651
  return this.loadProductForPriceQuery(params, customerId);
3375
3652
  case 4:
3376
- authoritativeProduct = _context35.sent;
3653
+ authoritativeProduct = _context39.sent;
3377
3654
  product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
3378
- _context35.next = 8;
3655
+ _context39.next = 8;
3379
3656
  return this.loadQuotationForPriceQuery({
3380
3657
  quotation: quotation,
3381
3658
  customer_id: customerId,
3382
3659
  channel: params.channel
3383
3660
  });
3384
3661
  case 8:
3385
- return _context35.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
3662
+ return _context39.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
3386
3663
  product: product,
3387
3664
  fallback_price: authoritativeProduct ? undefined : params.fallback_price,
3388
3665
  customer_id: customerId,
@@ -3390,11 +3667,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3390
3667
  })));
3391
3668
  case 9:
3392
3669
  case "end":
3393
- return _context35.stop();
3670
+ return _context39.stop();
3394
3671
  }
3395
- }, _callee35, this);
3672
+ }, _callee39, this);
3396
3673
  }));
3397
- function calculateProductBookingPrice(_x27) {
3674
+ function calculateProductBookingPrice(_x33) {
3398
3675
  return _calculateProductBookingPrice.apply(this, arguments);
3399
3676
  }
3400
3677
  return calculateProductBookingPrice;
@@ -3402,7 +3679,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3402
3679
  }, {
3403
3680
  key: "getQuotationCustomerScopeInfo",
3404
3681
  value: function getQuotationCustomerScopeInfo() {
3405
- var _this13 = this;
3682
+ var _this15 = this;
3406
3683
  var quotation = this.store.quotation;
3407
3684
  if (quotation && typeof quotation.getQuotationCustomerScopeInfo === 'function') {
3408
3685
  return quotation.getQuotationCustomerScopeInfo();
@@ -3414,7 +3691,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3414
3691
  }).map(function (item) {
3415
3692
  var localSeen = new Set();
3416
3693
  var customers = item.customer.filter(function (customer) {
3417
- var customerId = _this13.normalizePriceContextCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
3694
+ var customerId = _this15.normalizePriceContextCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
3418
3695
  if (!customerId || localSeen.has(customerId)) return false;
3419
3696
  localSeen.add(customerId);
3420
3697
  if (!customerById.has(customerId)) customerById.set(customerId, customer);
@@ -3464,32 +3741,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3464
3741
  }, {
3465
3742
  key: "calculateProductBookingPrices",
3466
3743
  value: function () {
3467
- var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(paramsList) {
3744
+ var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(paramsList) {
3468
3745
  var _paramsList$0$custome,
3469
3746
  _paramsList$,
3470
- _this14 = this,
3747
+ _this16 = this,
3471
3748
  _paramsList$2;
3472
3749
  var quotation, customerId, productMapsByGroup, groups;
3473
- return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3474
- while (1) switch (_context37.prev = _context37.next) {
3750
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3751
+ while (1) switch (_context41.prev = _context41.next) {
3475
3752
  case 0:
3476
3753
  if (paramsList.length) {
3477
- _context37.next = 2;
3754
+ _context41.next = 2;
3478
3755
  break;
3479
3756
  }
3480
- return _context37.abrupt("return", []);
3757
+ return _context41.abrupt("return", []);
3481
3758
  case 2:
3482
3759
  quotation = this.store.quotation;
3483
3760
  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
3761
  productMapsByGroup = new Map();
3485
3762
  groups = new Map();
3486
3763
  paramsList.forEach(function (params) {
3487
- var _this14$otherParams;
3764
+ var _this16$otherParams;
3488
3765
  var product = params.product || {};
3489
- var productId = _this14.getPriceQueryProductId(product);
3766
+ var productId = _this16.getPriceQueryProductId(product);
3490
3767
  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);
3768
+ var schedule = _this16.getPriceQuerySchedule(params);
3769
+ var channel = params.channel || ((_this16$otherParams = _this16.otherParams) === null || _this16$otherParams === void 0 ? void 0 : _this16$otherParams.channel);
3493
3770
  var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || ''].join('|');
3494
3771
  var group = groups.get(groupKey) || {
3495
3772
  ids: new Set(),
@@ -3499,51 +3776,51 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3499
3776
  group.ids.add(productId);
3500
3777
  groups.set(groupKey, group);
3501
3778
  });
3502
- _context37.next = 9;
3779
+ _context41.next = 9;
3503
3780
  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) {
3781
+ var _ref29 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(_ref28) {
3782
+ var _ref30, groupKey, group, productsById;
3783
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3784
+ while (1) switch (_context40.prev = _context40.next) {
3508
3785
  case 0:
3509
- _ref29 = _slicedToArray(_ref27, 2), groupKey = _ref29[0], group = _ref29[1];
3510
- _context36.next = 3;
3511
- return _this14.loadProductsForPriceQuery({
3786
+ _ref30 = _slicedToArray(_ref28, 2), groupKey = _ref30[0], group = _ref30[1];
3787
+ _context40.next = 3;
3788
+ return _this16.loadProductsForPriceQuery({
3512
3789
  ids: Array.from(group.ids),
3513
3790
  schedule: group.schedule,
3514
3791
  customerId: customerId,
3515
3792
  channel: group.channel
3516
3793
  });
3517
3794
  case 3:
3518
- productsById = _context36.sent;
3795
+ productsById = _context40.sent;
3519
3796
  productMapsByGroup.set(groupKey, productsById);
3520
3797
  case 5:
3521
3798
  case "end":
3522
- return _context36.stop();
3799
+ return _context40.stop();
3523
3800
  }
3524
- }, _callee36);
3801
+ }, _callee40);
3525
3802
  }));
3526
- return function (_x29) {
3527
- return _ref28.apply(this, arguments);
3803
+ return function (_x35) {
3804
+ return _ref29.apply(this, arguments);
3528
3805
  };
3529
3806
  }()));
3530
3807
  case 9:
3531
- _context37.next = 11;
3808
+ _context41.next = 11;
3532
3809
  return this.loadQuotationForPriceQuery({
3533
3810
  quotation: quotation,
3534
3811
  customer_id: customerId,
3535
3812
  channel: (_paramsList$2 = paramsList[0]) === null || _paramsList$2 === void 0 ? void 0 : _paramsList$2.channel
3536
3813
  });
3537
3814
  case 11:
3538
- return _context37.abrupt("return", paramsList.map(function (params) {
3539
- var _this14$otherParams2, _productMapsByGroup$g;
3815
+ return _context41.abrupt("return", paramsList.map(function (params) {
3816
+ var _this16$otherParams2, _productMapsByGroup$g;
3540
3817
  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);
3818
+ var productId = _this16.getPriceQueryProductId(productInput);
3819
+ var schedule = _this16.getPriceQuerySchedule(params);
3820
+ var channel = params.channel || ((_this16$otherParams2 = _this16.otherParams) === null || _this16$otherParams2 === void 0 ? void 0 : _this16$otherParams2.channel);
3544
3821
  var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || ''].join('|');
3545
3822
  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);
3823
+ var product = _this16.mergeProductForPriceQuery(productInput, authoritativeProduct);
3547
3824
  return calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
3548
3825
  product: product,
3549
3826
  fallback_price: authoritativeProduct ? undefined : params.fallback_price,
@@ -3553,11 +3830,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3553
3830
  }));
3554
3831
  case 12:
3555
3832
  case "end":
3556
- return _context37.stop();
3833
+ return _context41.stop();
3557
3834
  }
3558
- }, _callee37, this);
3835
+ }, _callee41, this);
3559
3836
  }));
3560
- function calculateProductBookingPrices(_x28) {
3837
+ function calculateProductBookingPrices(_x34) {
3561
3838
  return _calculateProductBookingPrices.apply(this, arguments);
3562
3839
  }
3563
3840
  return calculateProductBookingPrices;
@@ -3565,34 +3842,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3565
3842
  }, {
3566
3843
  key: "addProductToOrder",
3567
3844
  value: function () {
3568
- var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(product, booking) {
3845
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(product, booking) {
3569
3846
  var products;
3570
- return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3571
- while (1) switch (_context38.prev = _context38.next) {
3847
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3848
+ while (1) switch (_context42.prev = _context42.next) {
3572
3849
  case 0:
3573
- _context38.prev = 0;
3850
+ _context42.prev = 0;
3574
3851
  if (this.store.order) {
3575
- _context38.next = 3;
3852
+ _context42.next = 3;
3576
3853
  break;
3577
3854
  }
3578
3855
  throw new Error('order 模块未初始化');
3579
3856
  case 3:
3580
- _context38.next = 5;
3857
+ _context42.next = 5;
3581
3858
  return this.store.order.addProductToOrder(product, booking);
3582
3859
  case 5:
3583
- products = _context38.sent;
3584
- return _context38.abrupt("return", products);
3860
+ products = _context42.sent;
3861
+ return _context42.abrupt("return", products);
3585
3862
  case 9:
3586
- _context38.prev = 9;
3587
- _context38.t0 = _context38["catch"](0);
3588
- throw _context38.t0;
3863
+ _context42.prev = 9;
3864
+ _context42.t0 = _context42["catch"](0);
3865
+ throw _context42.t0;
3589
3866
  case 12:
3590
3867
  case "end":
3591
- return _context38.stop();
3868
+ return _context42.stop();
3592
3869
  }
3593
- }, _callee38, this, [[0, 9]]);
3870
+ }, _callee42, this, [[0, 9]]);
3594
3871
  }));
3595
- function addProductToOrder(_x30, _x31) {
3872
+ function addProductToOrder(_x36, _x37) {
3596
3873
  return _addProductToOrder.apply(this, arguments);
3597
3874
  }
3598
3875
  return addProductToOrder;
@@ -3600,34 +3877,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3600
3877
  }, {
3601
3878
  key: "updateOrderProduct",
3602
3879
  value: function () {
3603
- var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
3880
+ var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
3604
3881
  var products;
3605
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3606
- while (1) switch (_context39.prev = _context39.next) {
3882
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3883
+ while (1) switch (_context43.prev = _context43.next) {
3607
3884
  case 0:
3608
- _context39.prev = 0;
3885
+ _context43.prev = 0;
3609
3886
  if (this.store.order) {
3610
- _context39.next = 3;
3887
+ _context43.next = 3;
3611
3888
  break;
3612
3889
  }
3613
3890
  throw new Error('order 模块未初始化');
3614
3891
  case 3:
3615
- _context39.next = 5;
3892
+ _context43.next = 5;
3616
3893
  return this.store.order.updateOrderProduct(params);
3617
3894
  case 5:
3618
- products = _context39.sent;
3619
- return _context39.abrupt("return", products);
3895
+ products = _context43.sent;
3896
+ return _context43.abrupt("return", products);
3620
3897
  case 9:
3621
- _context39.prev = 9;
3622
- _context39.t0 = _context39["catch"](0);
3623
- throw _context39.t0;
3898
+ _context43.prev = 9;
3899
+ _context43.t0 = _context43["catch"](0);
3900
+ throw _context43.t0;
3624
3901
  case 12:
3625
3902
  case "end":
3626
- return _context39.stop();
3903
+ return _context43.stop();
3627
3904
  }
3628
- }, _callee39, this, [[0, 9]]);
3905
+ }, _callee43, this, [[0, 9]]);
3629
3906
  }));
3630
- function updateOrderProduct(_x32) {
3907
+ function updateOrderProduct(_x38) {
3631
3908
  return _updateOrderProduct.apply(this, arguments);
3632
3909
  }
3633
3910
  return updateOrderProduct;
@@ -3635,34 +3912,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3635
3912
  }, {
3636
3913
  key: "updateOrderProducts",
3637
3914
  value: function () {
3638
- var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(paramsList) {
3915
+ var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(paramsList) {
3639
3916
  var products;
3640
- return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3641
- while (1) switch (_context40.prev = _context40.next) {
3917
+ return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3918
+ while (1) switch (_context44.prev = _context44.next) {
3642
3919
  case 0:
3643
- _context40.prev = 0;
3920
+ _context44.prev = 0;
3644
3921
  if (this.store.order) {
3645
- _context40.next = 3;
3922
+ _context44.next = 3;
3646
3923
  break;
3647
3924
  }
3648
3925
  throw new Error('order 模块未初始化');
3649
3926
  case 3:
3650
- _context40.next = 5;
3927
+ _context44.next = 5;
3651
3928
  return this.store.order.updateOrderProducts(paramsList);
3652
3929
  case 5:
3653
- products = _context40.sent;
3654
- return _context40.abrupt("return", products);
3930
+ products = _context44.sent;
3931
+ return _context44.abrupt("return", products);
3655
3932
  case 9:
3656
- _context40.prev = 9;
3657
- _context40.t0 = _context40["catch"](0);
3658
- throw _context40.t0;
3933
+ _context44.prev = 9;
3934
+ _context44.t0 = _context44["catch"](0);
3935
+ throw _context44.t0;
3659
3936
  case 12:
3660
3937
  case "end":
3661
- return _context40.stop();
3938
+ return _context44.stop();
3662
3939
  }
3663
- }, _callee40, this, [[0, 9]]);
3940
+ }, _callee44, this, [[0, 9]]);
3664
3941
  }));
3665
- function updateOrderProducts(_x33) {
3942
+ function updateOrderProducts(_x39) {
3666
3943
  return _updateOrderProducts.apply(this, arguments);
3667
3944
  }
3668
3945
  return updateOrderProducts;
@@ -3670,34 +3947,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3670
3947
  }, {
3671
3948
  key: "updateOrderProductQuantity",
3672
3949
  value: function () {
3673
- var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
3950
+ var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(params) {
3674
3951
  var products;
3675
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3676
- while (1) switch (_context41.prev = _context41.next) {
3952
+ return _regeneratorRuntime().wrap(function _callee45$(_context45) {
3953
+ while (1) switch (_context45.prev = _context45.next) {
3677
3954
  case 0:
3678
- _context41.prev = 0;
3955
+ _context45.prev = 0;
3679
3956
  if (this.store.order) {
3680
- _context41.next = 3;
3957
+ _context45.next = 3;
3681
3958
  break;
3682
3959
  }
3683
3960
  throw new Error('order 模块未初始化');
3684
3961
  case 3:
3685
- _context41.next = 5;
3962
+ _context45.next = 5;
3686
3963
  return this.store.order.updateOrderProductQuantity(params);
3687
3964
  case 5:
3688
- products = _context41.sent;
3689
- return _context41.abrupt("return", products);
3965
+ products = _context45.sent;
3966
+ return _context45.abrupt("return", products);
3690
3967
  case 9:
3691
- _context41.prev = 9;
3692
- _context41.t0 = _context41["catch"](0);
3693
- throw _context41.t0;
3968
+ _context45.prev = 9;
3969
+ _context45.t0 = _context45["catch"](0);
3970
+ throw _context45.t0;
3694
3971
  case 12:
3695
3972
  case "end":
3696
- return _context41.stop();
3973
+ return _context45.stop();
3697
3974
  }
3698
- }, _callee41, this, [[0, 9]]);
3975
+ }, _callee45, this, [[0, 9]]);
3699
3976
  }));
3700
- function updateOrderProductQuantity(_x34) {
3977
+ function updateOrderProductQuantity(_x40) {
3701
3978
  return _updateOrderProductQuantity.apply(this, arguments);
3702
3979
  }
3703
3980
  return updateOrderProductQuantity;
@@ -3720,12 +3997,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3720
3997
  }, {
3721
3998
  key: "setOrderProductLineNote",
3722
3999
  value: (function () {
3723
- var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(identity, note) {
4000
+ var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(identity, note) {
3724
4001
  var params, products;
3725
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3726
- while (1) switch (_context42.prev = _context42.next) {
4002
+ return _regeneratorRuntime().wrap(function _callee46$(_context46) {
4003
+ while (1) switch (_context46.prev = _context46.next) {
3727
4004
  case 0:
3728
- _context42.prev = 0;
4005
+ _context46.prev = 0;
3729
4006
  params = {
3730
4007
  product_id: identity.product_id,
3731
4008
  product_variant_id: identity.product_variant_id,
@@ -3740,22 +4017,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3740
4017
  params.product_sku = identity.product_sku;
3741
4018
  }
3742
4019
  if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
3743
- _context42.next = 7;
4020
+ _context46.next = 7;
3744
4021
  return this.updateOrderProduct(params);
3745
4022
  case 7:
3746
- products = _context42.sent;
3747
- return _context42.abrupt("return", products);
4023
+ products = _context46.sent;
4024
+ return _context46.abrupt("return", products);
3748
4025
  case 11:
3749
- _context42.prev = 11;
3750
- _context42.t0 = _context42["catch"](0);
3751
- throw _context42.t0;
4026
+ _context46.prev = 11;
4027
+ _context46.t0 = _context46["catch"](0);
4028
+ throw _context46.t0;
3752
4029
  case 14:
3753
4030
  case "end":
3754
- return _context42.stop();
4031
+ return _context46.stop();
3755
4032
  }
3756
- }, _callee42, this, [[0, 11]]);
4033
+ }, _callee46, this, [[0, 11]]);
3757
4034
  }));
3758
- function setOrderProductLineNote(_x35, _x36) {
4035
+ function setOrderProductLineNote(_x41, _x42) {
3759
4036
  return _setOrderProductLineNote.apply(this, arguments);
3760
4037
  }
3761
4038
  return setOrderProductLineNote;
@@ -3770,32 +4047,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3770
4047
  }, {
3771
4048
  key: "removeProductsFromOrder",
3772
4049
  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) {
4050
+ var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(identities) {
4051
+ return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4052
+ while (1) switch (_context47.prev = _context47.next) {
3776
4053
  case 0:
3777
- _context43.prev = 0;
4054
+ _context47.prev = 0;
3778
4055
  if (this.store.order) {
3779
- _context43.next = 3;
4056
+ _context47.next = 3;
3780
4057
  break;
3781
4058
  }
3782
4059
  throw new Error('order 模块未初始化');
3783
4060
  case 3:
3784
- _context43.next = 5;
4061
+ _context47.next = 5;
3785
4062
  return this.store.order.removeProductsFromOrder(identities);
3786
4063
  case 5:
3787
- return _context43.abrupt("return", _context43.sent);
4064
+ return _context47.abrupt("return", _context47.sent);
3788
4065
  case 8:
3789
- _context43.prev = 8;
3790
- _context43.t0 = _context43["catch"](0);
3791
- throw _context43.t0;
4066
+ _context47.prev = 8;
4067
+ _context47.t0 = _context47["catch"](0);
4068
+ throw _context47.t0;
3792
4069
  case 11:
3793
4070
  case "end":
3794
- return _context43.stop();
4071
+ return _context47.stop();
3795
4072
  }
3796
- }, _callee43, this, [[0, 8]]);
4073
+ }, _callee47, this, [[0, 8]]);
3797
4074
  }));
3798
- function removeProductsFromOrder(_x37) {
4075
+ function removeProductsFromOrder(_x43) {
3799
4076
  return _removeProductsFromOrder.apply(this, arguments);
3800
4077
  }
3801
4078
  return removeProductsFromOrder;
@@ -3803,18 +4080,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3803
4080
  }, {
3804
4081
  key: "removeProductFromOrder",
3805
4082
  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) {
4083
+ var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(identity) {
4084
+ return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4085
+ while (1) switch (_context48.prev = _context48.next) {
3809
4086
  case 0:
3810
- return _context44.abrupt("return", this.removeProductsFromOrder([identity]));
4087
+ return _context48.abrupt("return", this.removeProductsFromOrder([identity]));
3811
4088
  case 1:
3812
4089
  case "end":
3813
- return _context44.stop();
4090
+ return _context48.stop();
3814
4091
  }
3815
- }, _callee44, this);
4092
+ }, _callee48, this);
3816
4093
  }));
3817
- function removeProductFromOrder(_x38) {
4094
+ function removeProductFromOrder(_x44) {
3818
4095
  return _removeProductFromOrder.apply(this, arguments);
3819
4096
  }
3820
4097
  return removeProductFromOrder;
@@ -3864,23 +4141,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3864
4141
  }, {
3865
4142
  key: "applyPromotion",
3866
4143
  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) {
4144
+ var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49() {
4145
+ return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4146
+ while (1) switch (_context49.prev = _context49.next) {
3870
4147
  case 0:
3871
4148
  if (this.store.order) {
3872
- _context45.next = 2;
4149
+ _context49.next = 2;
3873
4150
  break;
3874
4151
  }
3875
4152
  throw new Error('order 模块未初始化');
3876
4153
  case 2:
3877
- _context45.next = 4;
4154
+ _context49.next = 4;
3878
4155
  return this.store.order.applyPromotion();
3879
4156
  case 4:
3880
4157
  case "end":
3881
- return _context45.stop();
4158
+ return _context49.stop();
3882
4159
  }
3883
- }, _callee45, this);
4160
+ }, _callee49, this);
3884
4161
  }));
3885
4162
  function applyPromotion() {
3886
4163
  return _applyPromotion.apply(this, arguments);
@@ -3890,16 +4167,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3890
4167
  }, {
3891
4168
  key: "getUnfulfilledPromotions",
3892
4169
  value: function getUnfulfilledPromotions() {
3893
- var _this$store$order8;
3894
- return ((_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 ? void 0 : _this$store$order8.getUnfulfilledPromotions()) || [];
4170
+ var _this$store$order7;
4171
+ return ((_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 ? void 0 : _this$store$order7.getUnfulfilledPromotions()) || [];
3895
4172
  }
3896
4173
 
3897
4174
  /** 最近一次促销计算输出的赠品操作 diff。 */
3898
4175
  }, {
3899
4176
  key: "getLastGiftActions",
3900
4177
  value: function getLastGiftActions() {
3901
- var _this$store$order9;
3902
- return ((_this$store$order9 = this.store.order) === null || _this$store$order9 === void 0 ? void 0 : _this$store$order9.getLastGiftActions()) || null;
4178
+ var _this$store$order8;
4179
+ return ((_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 ? void 0 : _this$store$order8.getLastGiftActions()) || null;
3903
4180
  }
3904
4181
 
3905
4182
  // 获取商品列表
@@ -3907,18 +4184,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3907
4184
  }, {
3908
4185
  key: "getProductList",
3909
4186
  value: function () {
3910
- var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
3911
- var _this$otherParams21;
4187
+ var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50() {
4188
+ var _this$otherParams25;
3912
4189
  var menu_list_ids, _this$store$products, res;
3913
- return _regeneratorRuntime().wrap(function _callee46$(_context46) {
3914
- while (1) switch (_context46.prev = _context46.next) {
4190
+ return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4191
+ while (1) switch (_context50.prev = _context50.next) {
3915
4192
  case 0:
3916
4193
  // 可以直接通过配置里的 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) {
4194
+ 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
4195
  return Number(n.value);
3919
4196
  })) || [];
3920
- _context46.prev = 1;
3921
- _context46.next = 4;
4197
+ _context50.prev = 1;
4198
+ _context50.next = 4;
3922
4199
  return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
3923
4200
  menu_list_ids: menu_list_ids,
3924
4201
  cacheId: this.cacheId,
@@ -3926,17 +4203,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3926
4203
  schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
3927
4204
  });
3928
4205
  case 4:
3929
- res = _context46.sent;
3930
- return _context46.abrupt("return", res);
4206
+ res = _context50.sent;
4207
+ return _context50.abrupt("return", res);
3931
4208
  case 8:
3932
- _context46.prev = 8;
3933
- _context46.t0 = _context46["catch"](1);
3934
- throw _context46.t0;
4209
+ _context50.prev = 8;
4210
+ _context50.t0 = _context50["catch"](1);
4211
+ throw _context50.t0;
3935
4212
  case 11:
3936
4213
  case "end":
3937
- return _context46.stop();
4214
+ return _context50.stop();
3938
4215
  }
3939
- }, _callee46, this, [[1, 8]]);
4216
+ }, _callee50, this, [[1, 8]]);
3940
4217
  }));
3941
4218
  function getProductList() {
3942
4219
  return _getProductList.apply(this, arguments);
@@ -3951,33 +4228,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3951
4228
  }, {
3952
4229
  key: "setOtherParams",
3953
4230
  value: function () {
3954
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
3955
- var _this$otherParams22;
3956
- var _ref30,
3957
- _ref30$cover,
4231
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
4232
+ var _this$otherParams26;
4233
+ var _ref31,
4234
+ _ref31$cover,
3958
4235
  cover,
3959
- _args47 = arguments;
3960
- return _regeneratorRuntime().wrap(function _callee47$(_context47) {
3961
- while (1) switch (_context47.prev = _context47.next) {
4236
+ _args51 = arguments;
4237
+ return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4238
+ while (1) switch (_context51.prev = _context51.next) {
3962
4239
  case 0:
3963
- _ref30 = _args47.length > 1 && _args47[1] !== undefined ? _args47[1] : {}, _ref30$cover = _ref30.cover, cover = _ref30$cover === void 0 ? false : _ref30$cover;
4240
+ _ref31 = _args51.length > 1 && _args51[1] !== undefined ? _args51[1] : {}, _ref31$cover = _ref31.cover, cover = _ref31$cover === void 0 ? false : _ref31$cover;
3964
4241
  if (cover) {
3965
4242
  this.otherParams = _objectSpread({}, params);
3966
4243
  } else {
3967
4244
  this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
3968
4245
  }
3969
- this.cacheId = (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.cacheId;
3970
- _context47.next = 5;
4246
+ this.cacheId = (_this$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26.cacheId;
4247
+ _context51.next = 5;
3971
4248
  return this.syncOtherParamsToSubModules(params, {
3972
4249
  cover: cover
3973
4250
  });
3974
4251
  case 5:
3975
4252
  case "end":
3976
- return _context47.stop();
4253
+ return _context51.stop();
3977
4254
  }
3978
- }, _callee47, this);
4255
+ }, _callee51, this);
3979
4256
  }));
3980
- function setOtherParams(_x39) {
4257
+ function setOtherParams(_x45) {
3981
4258
  return _setOtherParams.apply(this, arguments);
3982
4259
  }
3983
4260
  return setOtherParams;