@pisell/pisellos 2.3.39 → 2.3.41

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 (226) hide show
  1. package/dist/core/index.d.ts +2 -0
  2. package/dist/core/index.js +7 -0
  3. package/dist/model/strategy/adapter/promotion/adapter.d.ts +4 -0
  4. package/dist/model/strategy/adapter/promotion/adapter.js +23 -0
  5. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
  6. package/dist/model/strategy/adapter/promotion/evaluator.js +279 -6
  7. package/dist/model/strategy/adapter/promotion/examples.d.ts +86 -0
  8. package/dist/model/strategy/adapter/promotion/examples.js +99 -0
  9. package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
  10. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  11. package/dist/model/strategy/adapter/promotion/type.d.ts +90 -2
  12. package/dist/model/strategy/adapter/promotion/type.js +45 -0
  13. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -3
  14. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +6 -3
  15. package/dist/modules/Discount/index.d.ts +0 -1
  16. package/dist/modules/Discount/index.js +11 -40
  17. package/dist/modules/Discount/types.d.ts +0 -1
  18. package/dist/modules/OpenData/index.d.ts +2 -0
  19. package/dist/modules/OpenData/index.js +10 -2
  20. package/dist/modules/Order/index.d.ts +29 -12
  21. package/dist/modules/Order/index.js +750 -509
  22. package/dist/modules/Order/payment-utils.d.ts +26 -0
  23. package/dist/modules/Order/payment-utils.js +225 -0
  24. package/dist/modules/Order/types.d.ts +33 -10
  25. package/dist/modules/Order/utils/orderCollectionIdentity.js +7 -2
  26. package/dist/modules/Order/utils.d.ts +0 -10
  27. package/dist/modules/Order/utils.js +13 -41
  28. package/dist/modules/Payment/index.d.ts +2 -0
  29. package/dist/modules/Payment/index.js +79 -50
  30. package/dist/modules/Payment/types.d.ts +99 -28
  31. package/dist/modules/Payment/types.js +20 -3
  32. package/dist/modules/Payment/walletpass.d.ts +25 -1
  33. package/dist/modules/Payment/walletpass.js +707 -157
  34. package/dist/modules/Product/types.d.ts +0 -1
  35. package/dist/modules/ProductList/index.js +14 -33
  36. package/dist/modules/Quotation/index.d.ts +1 -1
  37. package/dist/modules/Quotation/index.js +2 -2
  38. package/dist/modules/Rules/index.d.ts +1 -0
  39. package/dist/modules/Rules/index.js +89 -96
  40. package/dist/modules/SalesSummary/index.js +13 -12
  41. package/dist/modules/ScanOrderLogger/index.d.ts +0 -2
  42. package/dist/modules/ScanOrderLogger/index.js +2 -15
  43. package/dist/modules/ScanOrderLogger/providers/feishu.js +27 -45
  44. package/dist/modules/ScanOrderLogger/types.d.ts +0 -1
  45. package/dist/modules/Schedule/index.d.ts +1 -3
  46. package/dist/modules/Schedule/index.js +16 -21
  47. package/dist/modules/Summary/utils.js +13 -38
  48. package/dist/modules/index.d.ts +0 -2
  49. package/dist/modules/index.js +1 -3
  50. package/dist/plugins/window.d.ts +0 -1
  51. package/dist/server/index.d.ts +16 -14
  52. package/dist/server/index.js +1925 -1143
  53. package/dist/server/modules/order/index.d.ts +54 -4
  54. package/dist/server/modules/order/index.js +1600 -700
  55. package/dist/server/modules/order/types.d.ts +11 -3
  56. package/dist/server/modules/order/types.js +1 -1
  57. package/dist/solution/BaseSales/index.d.ts +109 -20
  58. package/dist/solution/BaseSales/index.js +1800 -480
  59. package/dist/solution/BaseSales/types.d.ts +52 -0
  60. package/dist/solution/BaseSales/types.js +2 -1
  61. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
  62. package/dist/solution/BaseSales/utils/cartPromotion.js +90 -31
  63. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
  64. package/dist/solution/BookingByStep/index.d.ts +2 -17
  65. package/dist/solution/BookingByStep/index.js +215 -294
  66. package/dist/solution/BookingByStep/types.d.ts +1 -2
  67. package/dist/solution/BookingByStep/types.js +1 -3
  68. package/dist/solution/BookingByStep/utils/capacity.js +1 -17
  69. package/dist/solution/BookingByStep/utils/timeslots.d.ts +1 -3
  70. package/dist/solution/BookingByStep/utils/timeslots.js +12 -19
  71. package/dist/solution/BookingTicket/index.d.ts +7 -3
  72. package/dist/solution/BookingTicket/index.js +132 -49
  73. package/dist/solution/BookingTicket/utils/addProductDecision.js +6 -0
  74. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
  75. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +172 -82
  76. package/dist/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
  77. package/dist/solution/BookingTicket/utils/weighingProductSku.js +45 -0
  78. package/dist/solution/Sales/index.d.ts +1 -0
  79. package/dist/solution/Sales/index.js +10 -2
  80. package/dist/solution/ScanOrder/index.d.ts +14 -26
  81. package/dist/solution/ScanOrder/index.js +756 -1148
  82. package/dist/solution/ScanOrder/types.d.ts +1 -21
  83. package/dist/solution/ScanOrder/utils.d.ts +0 -8
  84. package/dist/solution/ScanOrder/utils.js +25 -66
  85. package/dist/solution/ShopDiscount/index.d.ts +0 -1
  86. package/dist/solution/ShopDiscount/index.js +87 -125
  87. package/dist/solution/VenueBooking/index.d.ts +11 -39
  88. package/dist/solution/VenueBooking/index.js +860 -1176
  89. package/dist/solution/VenueBooking/types.d.ts +0 -3
  90. package/dist/solution/VenueBooking/utils/resource.js +0 -1
  91. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  92. package/dist/solution/VenueBooking/utils/slotMerge.js +5 -10
  93. package/dist/solution/index.d.ts +0 -1
  94. package/dist/solution/index.js +1 -2
  95. package/dist/types/index.d.ts +1 -1
  96. package/dist/utils/payment-number.d.ts +9 -0
  97. package/dist/utils/payment-number.js +69 -0
  98. package/lib/core/index.d.ts +2 -0
  99. package/lib/core/index.js +4 -0
  100. package/lib/model/strategy/adapter/promotion/adapter.d.ts +4 -0
  101. package/lib/model/strategy/adapter/promotion/adapter.js +20 -0
  102. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
  103. package/lib/model/strategy/adapter/promotion/evaluator.js +235 -0
  104. package/lib/model/strategy/adapter/promotion/examples.d.ts +86 -0
  105. package/lib/model/strategy/adapter/promotion/examples.js +91 -0
  106. package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
  107. package/lib/model/strategy/adapter/promotion/index.js +51 -0
  108. package/lib/model/strategy/adapter/promotion/type.d.ts +90 -2
  109. package/lib/model/strategy/adapter/promotion/type.js +2 -0
  110. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +2 -1
  111. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
  112. package/lib/modules/Discount/index.d.ts +0 -1
  113. package/lib/modules/Discount/index.js +0 -9
  114. package/lib/modules/Discount/types.d.ts +0 -1
  115. package/lib/modules/OpenData/index.d.ts +2 -0
  116. package/lib/modules/OpenData/index.js +6 -1
  117. package/lib/modules/Order/index.d.ts +29 -12
  118. package/lib/modules/Order/index.js +196 -86
  119. package/lib/modules/Order/payment-utils.d.ts +26 -0
  120. package/lib/modules/Order/payment-utils.js +224 -0
  121. package/lib/modules/Order/types.d.ts +33 -10
  122. package/lib/modules/Order/utils/orderCollectionIdentity.js +3 -0
  123. package/lib/modules/Order/utils.d.ts +0 -10
  124. package/lib/modules/Order/utils.js +16 -40
  125. package/lib/modules/Payment/index.d.ts +2 -0
  126. package/lib/modules/Payment/index.js +34 -13
  127. package/lib/modules/Payment/types.d.ts +99 -28
  128. package/lib/modules/Payment/types.js +4 -3
  129. package/lib/modules/Payment/walletpass.d.ts +25 -1
  130. package/lib/modules/Payment/walletpass.js +470 -21
  131. package/lib/modules/Product/types.d.ts +0 -1
  132. package/lib/modules/ProductList/index.js +31 -40
  133. package/lib/modules/Quotation/index.d.ts +1 -1
  134. package/lib/modules/Quotation/index.js +2 -2
  135. package/lib/modules/Rules/index.d.ts +1 -0
  136. package/lib/modules/Rules/index.js +47 -40
  137. package/lib/modules/SalesSummary/index.js +7 -6
  138. package/lib/modules/ScanOrderLogger/index.d.ts +0 -2
  139. package/lib/modules/ScanOrderLogger/index.js +1 -13
  140. package/lib/modules/ScanOrderLogger/providers/feishu.js +6 -15
  141. package/lib/modules/ScanOrderLogger/types.d.ts +0 -1
  142. package/lib/modules/Schedule/index.d.ts +1 -3
  143. package/lib/modules/Schedule/index.js +8 -10
  144. package/lib/modules/Summary/utils.js +1 -21
  145. package/lib/modules/index.d.ts +0 -2
  146. package/lib/modules/index.js +1 -5
  147. package/lib/plugins/window.d.ts +0 -1
  148. package/lib/server/index.d.ts +16 -14
  149. package/lib/server/index.js +675 -83
  150. package/lib/server/modules/order/index.d.ts +54 -4
  151. package/lib/server/modules/order/index.js +679 -66
  152. package/lib/server/modules/order/types.d.ts +11 -3
  153. package/lib/solution/BaseSales/index.d.ts +109 -20
  154. package/lib/solution/BaseSales/index.js +883 -70
  155. package/lib/solution/BaseSales/types.d.ts +52 -0
  156. package/lib/solution/BaseSales/types.js +2 -1
  157. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
  158. package/lib/solution/BaseSales/utils/cartPromotion.js +63 -12
  159. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
  160. package/lib/solution/BookingByStep/index.d.ts +2 -17
  161. package/lib/solution/BookingByStep/index.js +18 -60
  162. package/lib/solution/BookingByStep/types.d.ts +1 -2
  163. package/lib/solution/BookingByStep/types.js +0 -5
  164. package/lib/solution/BookingByStep/utils/capacity.js +1 -20
  165. package/lib/solution/BookingByStep/utils/timeslots.d.ts +1 -3
  166. package/lib/solution/BookingByStep/utils/timeslots.js +11 -19
  167. package/lib/solution/BookingTicket/index.d.ts +7 -3
  168. package/lib/solution/BookingTicket/index.js +62 -9
  169. package/lib/solution/BookingTicket/utils/addProductDecision.js +4 -0
  170. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
  171. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +36 -4
  172. package/lib/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
  173. package/lib/solution/BookingTicket/utils/weighingProductSku.js +63 -0
  174. package/lib/solution/Sales/index.d.ts +1 -0
  175. package/lib/solution/Sales/index.js +5 -3
  176. package/lib/solution/ScanOrder/index.d.ts +14 -26
  177. package/lib/solution/ScanOrder/index.js +190 -449
  178. package/lib/solution/ScanOrder/types.d.ts +1 -21
  179. package/lib/solution/ScanOrder/utils.d.ts +0 -8
  180. package/lib/solution/ScanOrder/utils.js +0 -31
  181. package/lib/solution/ShopDiscount/index.d.ts +0 -1
  182. package/lib/solution/ShopDiscount/index.js +0 -14
  183. package/lib/solution/VenueBooking/index.d.ts +11 -39
  184. package/lib/solution/VenueBooking/index.js +123 -328
  185. package/lib/solution/VenueBooking/types.d.ts +0 -3
  186. package/lib/solution/VenueBooking/utils/resource.js +0 -1
  187. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  188. package/lib/solution/VenueBooking/utils/slotMerge.js +4 -6
  189. package/lib/solution/index.d.ts +0 -1
  190. package/lib/solution/index.js +1 -3
  191. package/lib/types/index.d.ts +1 -1
  192. package/lib/utils/payment-number.d.ts +9 -0
  193. package/lib/utils/payment-number.js +64 -0
  194. package/package.json +1 -1
  195. package/dist/modules/Holder/index.d.ts +0 -48
  196. package/dist/modules/Holder/index.js +0 -640
  197. package/dist/modules/Holder/types.d.ts +0 -123
  198. package/dist/modules/Holder/types.js +0 -1
  199. package/dist/modules/Holder/utils.d.ts +0 -13
  200. package/dist/modules/Holder/utils.js +0 -34
  201. package/dist/modules/ResourcePlanner/index.d.ts +0 -24
  202. package/dist/modules/ResourcePlanner/index.js +0 -181
  203. package/dist/modules/ResourcePlanner/planner.d.ts +0 -14
  204. package/dist/modules/ResourcePlanner/planner.js +0 -1069
  205. package/dist/modules/ResourcePlanner/types.d.ts +0 -227
  206. package/dist/modules/ResourcePlanner/types.js +0 -1
  207. package/dist/solution/UnifiedBookingSales/index.d.ts +0 -183
  208. package/dist/solution/UnifiedBookingSales/index.js +0 -1871
  209. package/dist/solution/UnifiedBookingSales/types.d.ts +0 -143
  210. package/dist/solution/UnifiedBookingSales/types.js +0 -11
  211. package/lib/modules/Holder/index.d.ts +0 -48
  212. package/lib/modules/Holder/index.js +0 -402
  213. package/lib/modules/Holder/types.d.ts +0 -123
  214. package/lib/modules/Holder/types.js +0 -17
  215. package/lib/modules/Holder/utils.d.ts +0 -13
  216. package/lib/modules/Holder/utils.js +0 -71
  217. package/lib/modules/ResourcePlanner/index.d.ts +0 -24
  218. package/lib/modules/ResourcePlanner/index.js +0 -148
  219. package/lib/modules/ResourcePlanner/planner.d.ts +0 -14
  220. package/lib/modules/ResourcePlanner/planner.js +0 -933
  221. package/lib/modules/ResourcePlanner/types.d.ts +0 -227
  222. package/lib/modules/ResourcePlanner/types.js +0 -17
  223. package/lib/solution/UnifiedBookingSales/index.d.ts +0 -183
  224. package/lib/solution/UnifiedBookingSales/index.js +0 -1076
  225. package/lib/solution/UnifiedBookingSales/types.d.ts +0 -143
  226. package/lib/solution/UnifiedBookingSales/types.js +0 -33
@@ -32,9 +32,11 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
32
32
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
33
33
  import { BaseModule } from "../BaseModule";
34
34
  import { OrderHooks } from "./types";
35
- import { composeLinePrice, generateDuration, getAllDiscountList, mergeRelationForms, ensureCartItemOriginHolder, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments, normalizeOrderProductDiscountList, resolveEffectivePerUnitDiscount, ensureProductSku, getProductSkuOptions, normalizeProductSkuOptions, sumOptionUnitPrice, clearTempOrderHolderAssignments, getOrderProductLineUid, indexOrderProductsByUid, calculateOrderProductsDeposit, mergeOrderProductDisplayFields, resolveIsFormSubject } from "./utils";
35
+ import { composeLinePrice, generateDuration, getAllDiscountList, mergeRelationForms, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments, normalizeOrderProductDiscountList, resolveEffectivePerUnitDiscount, ensureProductSku, getProductSkuOptions, normalizeProductSkuOptions, sumOptionUnitPrice, clearTempOrderHolderAssignments, getOrderProductLineUid, indexOrderProductsByUid, calculateOrderProductsDeposit, mergeOrderProductDisplayFields, resolveIsFormSubject } from "./utils";
36
36
  import { isNormalProduct } from "../Product/utils";
37
37
  import dayjs from 'dayjs';
38
+ import { ensureOrderPaymentNumber, mergeOrderPaymentRecord, resolveOrderPaymentIdentity } from "./payment-utils";
39
+ import { resolvePaymentNumberDevicePrefix, resolvePaymentNumberDevicePrefixFromDeviceId } from "../../utils/payment-number";
38
40
  import { processCartPromotion, appendPromotionTags as _appendPromotionTags, getOrderProductUid as getPromotionUid } from "../../solution/BaseSales/utils/cartPromotion";
39
41
  import { buildProductLineFingerprint, getProductIdentityIndex, getSafeProductNum, isIdentityMatch, normalizeOrderProduct } from "../../solution/ScanOrder/utils";
40
42
  import { syncManualProductDiscountProductNum } from "./utils/manualProductDiscount";
@@ -83,6 +85,10 @@ function isPaidPaymentRecord(payment) {
83
85
  function isCommittedVoucherPaymentRecord(payment) {
84
86
  return isVoucherPaymentRecord(payment) && (payment === null || payment === void 0 ? void 0 : payment.status) !== 'voided' && (hasSyncedOrderPaymentRecord(payment) || isPaidPaymentRecord(payment));
85
87
  }
88
+ function getVoucherPaymentLifecycleKey(payment) {
89
+ if (!isVoucherPaymentRecord(payment)) return null;
90
+ return "".concat(String(payment.voucher_id), "::").concat(String(payment.status || ''));
91
+ }
86
92
  export var OrderModule = /*#__PURE__*/function (_BaseModule) {
87
93
  _inherits(OrderModule, _BaseModule);
88
94
  var _super = _createSuper(OrderModule);
@@ -97,6 +103,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
97
103
  _defineProperty(_assertThisInitialized(_this), "logger", void 0);
98
104
  // LoggerManager 实例
99
105
  _defineProperty(_assertThisInitialized(_this), "window", void 0);
106
+ _defineProperty(_assertThisInitialized(_this), "appPlugin", void 0);
100
107
  _defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
101
108
  _defineProperty(_assertThisInitialized(_this), "salesSummaryModuleName", void 0);
102
109
  _defineProperty(_assertThisInitialized(_this), "rulesHooksOverride", void 0);
@@ -283,8 +290,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
283
290
  key: "initialize",
284
291
  value: function () {
285
292
  var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
286
- var _appPlugin$getApp, _otherParams$rules, _otherParams$order, _otherParams$hooks;
287
- var appPlugin, app, otherParams;
293
+ var _otherParams$rules, _otherParams$order, _otherParams$hooks;
294
+ var app, otherParams;
288
295
  return _regeneratorRuntime().wrap(function _callee$(_context) {
289
296
  while (1) switch (_context.prev = _context.next) {
290
297
  case 0:
@@ -300,12 +307,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
300
307
  this.store.availableWalletIds = [];
301
308
  }
302
309
  this.request = this.core.getPlugin('request');
303
- appPlugin = this.core.getPlugin('app');
304
- if (!appPlugin) {
305
- console.error('Order 模块需要 app 插件支持');
310
+ this.appPlugin = this.core.getPlugin('app');
311
+ if (this.appPlugin) {
312
+ _context.next = 9;
313
+ break;
306
314
  }
307
- app = appPlugin === null || appPlugin === void 0 || (_appPlugin$getApp = appPlugin.getApp) === null || _appPlugin$getApp === void 0 ? void 0 : _appPlugin$getApp.call(appPlugin);
308
- this.logger = app === null || app === void 0 ? void 0 : app.logger;
315
+ throw new Error('Order 模块需要 app 插件支持');
316
+ case 9:
317
+ app = this.appPlugin.getApp();
318
+ this.logger = app.logger;
309
319
  this.window = this.core.getPlugin('window');
310
320
  otherParams = options.otherParams || {};
311
321
  this.cacheId = otherParams.cacheId;
@@ -316,7 +326,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
316
326
  this.otherParams = otherParams;
317
327
  this.registerDiscountModules(options);
318
328
  this.logInfo('OrderModule initialized successfully');
319
- case 20:
329
+ case 21:
320
330
  case "end":
321
331
  return _context.stop();
322
332
  }
@@ -1221,16 +1231,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1221
1231
  value: function persistTempOrder() {
1222
1232
  // no-op: OrderModule 的刷新恢复不再依赖 localStorage。
1223
1233
  }
1224
- }, {
1225
- key: "notifyTempOrderChanged",
1226
- value: function notifyTempOrderChanged() {
1227
- if (!this.store.tempOrder) return;
1228
- this.store.tempOrder = _objectSpread(_objectSpread({}, this.store.tempOrder), {}, {
1229
- products: _toConsumableArray(this.store.tempOrder.products),
1230
- bookings: this.store.tempOrder.bookings ? _toConsumableArray(this.store.tempOrder.bookings) : []
1231
- });
1232
- this.persistTempOrder();
1233
- }
1234
1234
 
1235
1235
  // ─── TempOrder: 创建 & 获取 ───
1236
1236
  }, {
@@ -1517,19 +1517,44 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1517
1517
  var depositPaidAmount = this.calculateDepositPaidAmount(tempOrder.payments || []);
1518
1518
  return depositPaidAmount.lt(depositAmount) ? 'deposit' : 'normal';
1519
1519
  }
1520
+ }, {
1521
+ key: "getPaymentNumberAppData",
1522
+ value: function getPaymentNumberAppData(key) {
1523
+ var _appPlugin$getData, _app$models, _app$models$getStore, _app$models$getStore$, _app$models$getStore$2;
1524
+ var appPlugin = this.appPlugin;
1525
+ if (!appPlugin) return undefined;
1526
+ var getData = (_appPlugin$getData = appPlugin.getData) === null || _appPlugin$getData === void 0 ? void 0 : _appPlugin$getData.call(appPlugin);
1527
+ if (typeof getData === 'function') return getData(key);
1528
+ var app = appPlugin.getApp();
1529
+ 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');
1530
+ return coreData === null || coreData === void 0 ? void 0 : coreData[key];
1531
+ }
1532
+ }, {
1533
+ key: "getPaymentNumberDevicePrefixSync",
1534
+ value: function getPaymentNumberDevicePrefixSync() {
1535
+ var _this7 = this;
1536
+ return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
1537
+ return _this7.getPaymentNumberAppData(key);
1538
+ });
1539
+ }
1540
+ }, {
1541
+ key: "getPaymentNumberDevicePrefixAsync",
1542
+ value: function getPaymentNumberDevicePrefixAsync() {
1543
+ var _this8 = this;
1544
+ return resolvePaymentNumberDevicePrefix(function (key) {
1545
+ return _this8.getPaymentNumberAppData(key);
1546
+ });
1547
+ }
1520
1548
  }, {
1521
1549
  key: "normalizePaymentSource",
1522
1550
  value: function normalizePaymentSource(payment, options) {
1523
1551
  var _ref19, _paymentRecord$origin;
1524
1552
  var paymentRecord = payment;
1525
1553
  var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
1526
- if (!metadata.unique_payment_number) {
1527
- metadata.unique_payment_number = createUuidV4();
1528
- }
1529
- var normalized = _objectSpread(_objectSpread({}, paymentRecord), {}, {
1554
+ var normalized = ensureOrderPaymentNumber(_objectSpread(_objectSpread({}, paymentRecord), {}, {
1530
1555
  metadata: metadata,
1531
1556
  origin_amount: (_ref19 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref19 !== void 0 ? _ref19 : '0.00'
1532
- });
1557
+ }), (options === null || options === void 0 ? void 0 : options.devicePrefix) || this.getPaymentNumberDevicePrefixSync(), createUuidV4);
1533
1558
  if (paymentRecord.status !== undefined) {
1534
1559
  normalized.status = paymentRecord.status;
1535
1560
  } else if ((options === null || options === void 0 ? void 0 : options.defaultPaid) !== false) {
@@ -1647,16 +1672,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1647
1672
  }, {
1648
1673
  key: "calculatePaidPaymentSummary",
1649
1674
  value: function calculatePaidPaymentSummary(payments) {
1650
- var _this7 = this;
1675
+ var _this9 = this;
1651
1676
  return (payments || []).reduce(function (summary, payment) {
1652
1677
  var paymentRecord = payment;
1653
1678
  if (!isPaidPaymentRecord(paymentRecord)) return summary;
1654
1679
  return {
1655
1680
  customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
1656
- orderPaidAmount: summary.orderPaidAmount.plus(_this7.calculatePaymentOrderAmount(paymentRecord)),
1657
- gapPaidAmount: summary.gapPaidAmount.plus(_this7.calculatePaymentGapAmount(paymentRecord)),
1658
- payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this7.calculatePaymentServiceFee(paymentRecord)),
1659
- roundingAmount: summary.roundingAmount.plus(_this7.calculatePaymentRoundingAmount(paymentRecord))
1681
+ orderPaidAmount: summary.orderPaidAmount.plus(_this9.calculatePaymentOrderAmount(paymentRecord)),
1682
+ gapPaidAmount: summary.gapPaidAmount.plus(_this9.calculatePaymentGapAmount(paymentRecord)),
1683
+ payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this9.calculatePaymentServiceFee(paymentRecord)),
1684
+ roundingAmount: summary.roundingAmount.plus(_this9.calculatePaymentRoundingAmount(paymentRecord))
1660
1685
  };
1661
1686
  }, {
1662
1687
  customerPaidAmount: new Decimal(0),
@@ -1858,15 +1883,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1858
1883
  }, {
1859
1884
  key: "normalizeFingerprintValue",
1860
1885
  value: function normalizeFingerprintValue(value) {
1861
- var _this8 = this;
1886
+ var _this10 = this;
1862
1887
  if (Array.isArray(value)) {
1863
1888
  return value.map(function (item) {
1864
- return _this8.normalizeFingerprintValue(item);
1889
+ return _this10.normalizeFingerprintValue(item);
1865
1890
  });
1866
1891
  }
1867
1892
  if (!value || _typeof(value) !== 'object') return value !== null && value !== void 0 ? value : '';
1868
1893
  return Object.keys(value).sort().reduce(function (result, key) {
1869
- result[key] = _this8.normalizeFingerprintValue(value[key]);
1894
+ result[key] = _this10.normalizeFingerprintValue(value[key]);
1870
1895
  return result;
1871
1896
  }, {});
1872
1897
  }
@@ -1881,7 +1906,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1881
1906
  _sku$barcode,
1882
1907
  _ref20,
1883
1908
  _sku$variant_id,
1884
- _this9 = this;
1909
+ _this11 = this;
1885
1910
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
1886
1911
  var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
1887
1912
  var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
@@ -1915,7 +1940,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1915
1940
  option_group_id: (_option$option_group_ = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_ !== void 0 ? _option$option_group_ : null,
1916
1941
  option_group_item_id: (_ref22 = (_option$option_group_2 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_2 !== void 0 ? _option$option_group_2 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref22 !== void 0 ? _ref22 : null,
1917
1942
  num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
1918
- add_price: _this9.normalizeFingerprintMoney((_option$add_price = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price !== void 0 ? _option$add_price : option === null || option === void 0 ? void 0 : option.price)
1943
+ add_price: _this11.normalizeFingerprintMoney((_option$add_price = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price !== void 0 ? _option$add_price : option === null || option === void 0 ? void 0 : option.price)
1919
1944
  };
1920
1945
  })
1921
1946
  }),
@@ -1925,8 +1950,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1925
1950
  bundle_product_id: (_ref23 = (_ref24 = (_bundle$bundle_produc = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref24 !== void 0 ? _ref24 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref23 !== void 0 ? _ref23 : null,
1926
1951
  bundle_variant_id: (_ref25 = (_bundle$bundle_varian = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle === null || bundle === void 0 ? void 0 : bundle.product_variant_id) !== null && _ref25 !== void 0 ? _ref25 : 0,
1927
1952
  num: getSafeProductNum((_bundle$num = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num !== void 0 ? _bundle$num : bundle === null || bundle === void 0 ? void 0 : bundle.quantity),
1928
- price: _this9.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
1929
- bundle_selling_price: _this9.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
1953
+ price: _this11.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
1954
+ bundle_selling_price: _this11.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
1930
1955
  price_type: (_bundle$price_type = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type !== void 0 ? _bundle$price_type : '',
1931
1956
  price_type_ext: (_bundle$price_type_ex = bundle === null || bundle === void 0 ? void 0 : bundle.price_type_ext) !== null && _bundle$price_type_ex !== void 0 ? _bundle$price_type_ex : ''
1932
1957
  };
@@ -1936,7 +1961,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1936
1961
  return {
1937
1962
  type: (_ref26 = (_discount$type2 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type2 !== void 0 ? _discount$type2 : discount === null || discount === void 0 ? void 0 : discount.tag) !== null && _ref26 !== void 0 ? _ref26 : '',
1938
1963
  discount_id: (_ref27 = (_ref28 = (_discount$discount_id = discount === null || discount === void 0 ? void 0 : discount.discount_id) !== null && _discount$discount_id !== void 0 ? _discount$discount_id : discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null && _ref28 !== void 0 ? _ref28 : discount === null || discount === void 0 || (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) !== null && _ref27 !== void 0 ? _ref27 : null,
1939
- amount: _this9.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
1964
+ amount: _this11.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
1940
1965
  };
1941
1966
  }))
1942
1967
  };
@@ -1944,9 +1969,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1944
1969
  }, {
1945
1970
  key: "buildOrderProductsFingerprint",
1946
1971
  value: function buildOrderProductsFingerprint(products) {
1947
- var _this10 = this;
1972
+ var _this12 = this;
1948
1973
  var items = (products || []).map(function (product) {
1949
- return _this10.buildProductFingerprintItem(product);
1974
+ return _this12.buildProductFingerprintItem(product);
1950
1975
  });
1951
1976
  items.sort(function (left, right) {
1952
1977
  return JSON.stringify(left).localeCompare(JSON.stringify(right));
@@ -1968,7 +1993,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1968
1993
  _sku$barcode2,
1969
1994
  _ref30,
1970
1995
  _sku$variant_id2,
1971
- _this11 = this;
1996
+ _this13 = this;
1972
1997
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
1973
1998
  var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
1974
1999
  var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
@@ -1999,7 +2024,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1999
2024
  option_group_id: (_option$option_group_3 = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_3 !== void 0 ? _option$option_group_3 : null,
2000
2025
  option_group_item_id: (_ref32 = (_option$option_group_4 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_4 !== void 0 ? _option$option_group_4 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref32 !== void 0 ? _ref32 : null,
2001
2026
  num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
2002
- add_price: _this11.normalizeFingerprintMoney((_option$add_price2 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price2 !== void 0 ? _option$add_price2 : option === null || option === void 0 ? void 0 : option.price)
2027
+ add_price: _this13.normalizeFingerprintMoney((_option$add_price2 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price2 !== void 0 ? _option$add_price2 : option === null || option === void 0 ? void 0 : option.price)
2003
2028
  };
2004
2029
  })
2005
2030
  }),
@@ -2013,14 +2038,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2013
2038
  num: getSafeProductNum((_bundle$num2 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num2 !== void 0 ? _bundle$num2 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity),
2014
2039
  price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
2015
2040
  price_type_ext: (_bundle$price_type_ex2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type_ext) !== null && _bundle$price_type_ex2 !== void 0 ? _bundle$price_type_ex2 : '',
2016
- option: _this11.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
2041
+ option: _this13.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
2017
2042
  var _ref38, _option$id3, _option$option_group_5, _ref39, _option$option_group_6, _option$num3, _option$add_price3;
2018
2043
  return {
2019
2044
  id: (_ref38 = (_option$id3 = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id3 !== void 0 ? _option$id3 : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref38 !== void 0 ? _ref38 : null,
2020
2045
  option_group_id: (_option$option_group_5 = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_5 !== void 0 ? _option$option_group_5 : null,
2021
2046
  option_group_item_id: (_ref39 = (_option$option_group_6 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_6 !== void 0 ? _option$option_group_6 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref39 !== void 0 ? _ref39 : null,
2022
2047
  num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
2023
- add_price: _this11.normalizeFingerprintMoney((_option$add_price3 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price3 !== void 0 ? _option$add_price3 : option === null || option === void 0 ? void 0 : option.price)
2048
+ add_price: _this13.normalizeFingerprintMoney((_option$add_price3 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price3 !== void 0 ? _option$add_price3 : option === null || option === void 0 ? void 0 : option.price)
2024
2049
  };
2025
2050
  }))
2026
2051
  };
@@ -2030,7 +2055,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2030
2055
  return {
2031
2056
  type: (_ref40 = (_discount$type4 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type4 !== void 0 ? _discount$type4 : discount === null || discount === void 0 ? void 0 : discount.tag) !== null && _ref40 !== void 0 ? _ref40 : '',
2032
2057
  discount_id: (_ref41 = (_ref42 = (_discount$discount_id2 = discount === null || discount === void 0 ? void 0 : discount.discount_id) !== null && _discount$discount_id2 !== void 0 ? _discount$discount_id2 : discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null && _ref42 !== void 0 ? _ref42 : discount === null || discount === void 0 || (_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) !== null && _ref41 !== void 0 ? _ref41 : null,
2033
- amount: _this11.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2058
+ amount: _this13.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2034
2059
  };
2035
2060
  }))
2036
2061
  };
@@ -2038,9 +2063,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2038
2063
  }, {
2039
2064
  key: "buildOrderProductsStructuralFingerprint",
2040
2065
  value: function buildOrderProductsStructuralFingerprint(products) {
2041
- var _this12 = this;
2066
+ var _this14 = this;
2042
2067
  var items = (products || []).map(function (product) {
2043
- return _this12.buildProductStructuralFingerprintItem(product);
2068
+ return _this14.buildProductStructuralFingerprintItem(product);
2044
2069
  });
2045
2070
  items.sort(function (left, right) {
2046
2071
  return JSON.stringify(left).localeCompare(JSON.stringify(right));
@@ -2468,9 +2493,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2468
2493
  }, {
2469
2494
  key: "sanitizeTempOrderProducts",
2470
2495
  value: function sanitizeTempOrderProducts(tempOrder) {
2471
- var _this13 = this;
2496
+ var _this15 = this;
2472
2497
  tempOrder.products = (tempOrder.products || []).map(function (product) {
2473
- return _this13.sanitizeOrderProductForTempOrder(product);
2498
+ return _this15.sanitizeOrderProductForTempOrder(product);
2474
2499
  });
2475
2500
  }
2476
2501
  }, {
@@ -2573,7 +2598,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2573
2598
  }, {
2574
2599
  key: "syncLinkedBookingHoldersToProducts",
2575
2600
  value: function syncLinkedBookingHoldersToProducts(tempOrder) {
2576
- var _this14 = this;
2601
+ var _this16 = this;
2577
2602
  var bookings = tempOrder.bookings || [];
2578
2603
  var products = tempOrder.products || [];
2579
2604
  if (!bookings.length || !products.length) return;
@@ -2598,7 +2623,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2598
2623
  var bookingUid = product.booking_uid || ((_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.booking_uid);
2599
2624
  var linkedBooking = (productUid !== undefined && productUid !== null && String(productUid) !== '' ? bookingByProductUid.get(String(productUid)) : undefined) || (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '' ? bookingByBookingUid.get(String(bookingUid)) : undefined);
2600
2625
  if (linkedBooking) {
2601
- _this14.setProductHolderFromBooking(product, linkedBooking);
2626
+ _this16.setProductHolderFromBooking(product, linkedBooking);
2602
2627
  }
2603
2628
  });
2604
2629
  }
@@ -2726,9 +2751,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2726
2751
  }, {
2727
2752
  key: "findBookingIndexByUniqueIdentificationNumber",
2728
2753
  value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
2729
- var _this15 = this;
2754
+ var _this17 = this;
2730
2755
  return (tempOrder.bookings || []).findIndex(function (booking) {
2731
- return _this15.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
2756
+ return _this17.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
2732
2757
  });
2733
2758
  }
2734
2759
  }, {
@@ -2736,12 +2761,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2736
2761
  value: function removeLinkedBookingsForProduct(tempOrder, product) {
2737
2762
  var _product$metadata7,
2738
2763
  _product$metadata8,
2739
- _this16 = this;
2764
+ _this18 = this;
2740
2765
  var productUid = (product === null || product === void 0 || (_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
2741
2766
  var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.booking_uid);
2742
2767
  if (!productUid && !bookingUid) return;
2743
2768
  tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
2744
- var currentBookingUid = _this16.getBookingUniqueIdentificationNumber(booking);
2769
+ var currentBookingUid = _this18.getBookingUniqueIdentificationNumber(booking);
2745
2770
  if (bookingUid && currentBookingUid === String(bookingUid)) return false;
2746
2771
  if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
2747
2772
  return true;
@@ -3074,15 +3099,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3074
3099
  }, {
3075
3100
  key: "productHasCustomerBoundDiscount",
3076
3101
  value: function productHasCustomerBoundDiscount(product) {
3077
- var _this17 = this;
3102
+ var _this19 = this;
3078
3103
  if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
3079
- return _this17.isCustomerBoundDiscount(discount);
3104
+ return _this19.isCustomerBoundDiscount(discount);
3080
3105
  })) {
3081
3106
  return true;
3082
3107
  }
3083
3108
  return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
3084
3109
  return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
3085
- return _this17.isCustomerBoundDiscount(discount);
3110
+ return _this19.isCustomerBoundDiscount(discount);
3086
3111
  });
3087
3112
  });
3088
3113
  }
@@ -3091,18 +3116,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3091
3116
  value: function shouldSkipDiscountCalculation(tempOrder) {
3092
3117
  var _this$store$discount17,
3093
3118
  _this$store$discount18,
3094
- _this18 = this;
3119
+ _this20 = this;
3095
3120
  if (this.hasActiveCustomerBoundDiscount) return false;
3096
3121
  var discountList = ((_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 || (_this$store$discount18 = _this$store$discount17.getDiscountList) === null || _this$store$discount18 === void 0 ? void 0 : _this$store$discount18.call(_this$store$discount17)) || [];
3097
3122
  if (discountList.length > 0) return false;
3098
3123
  return !(tempOrder.products || []).some(function (product) {
3099
- return _this18.productHasCustomerBoundDiscount(product);
3124
+ return _this20.productHasCustomerBoundDiscount(product);
3100
3125
  });
3101
3126
  }
3102
3127
  }, {
3103
3128
  key: "clearCustomerBoundDiscounts",
3104
3129
  value: function clearCustomerBoundDiscounts(tempOrder) {
3105
- var _this19 = this,
3130
+ var _this21 = this,
3106
3131
  _discountModule$getDi,
3107
3132
  _discountModule$getOr,
3108
3133
  _discountModule$setDi,
@@ -3111,7 +3136,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3111
3136
  var filterDiscountList = function filterDiscountList(discountList) {
3112
3137
  if (!Array.isArray(discountList)) return [];
3113
3138
  return discountList.filter(function (discount) {
3114
- var shouldRemove = _this19.isCustomerBoundDiscount(discount);
3139
+ var shouldRemove = _this21.isCustomerBoundDiscount(discount);
3115
3140
  if (shouldRemove) didRemoveCustomerBoundDiscount = true;
3116
3141
  return !shouldRemove;
3117
3142
  });
@@ -3138,12 +3163,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3138
3163
  var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
3139
3164
  var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
3140
3165
  var nextDiscounts = currentDiscounts.filter(function (discount) {
3141
- if (_this19.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3142
- return !_this19.isCustomerBoundDiscount(discount);
3166
+ if (_this21.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3167
+ return !_this21.isCustomerBoundDiscount(discount);
3143
3168
  });
3144
3169
  var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
3145
- if (_this19.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3146
- return !_this19.isCustomerBoundDiscount(discount);
3170
+ if (_this21.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3171
+ return !_this21.isCustomerBoundDiscount(discount);
3147
3172
  });
3148
3173
  void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
3149
3174
  void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
@@ -3297,23 +3322,71 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3297
3322
  * 用一组支付来源覆盖当前订单支付项。
3298
3323
  *
3299
3324
  * 入参允许来自 PaymentModule 的 PaymentItem,内部统一映射为 Sales 协议:
3300
- * uuid -> metadata.unique_payment_number,id -> custom_payment_id,
3325
+ * 新支付来源的 uuid 会作为 payment_number 的唯一号段,id -> custom_payment_id,
3301
3326
  * isSynced 等运行态字段不会进入 tempOrder.payments。
3302
3327
  */
3303
3328
  }, {
3304
3329
  key: "setOrderPayments",
3305
3330
  value: function setOrderPayments(payments) {
3331
+ var _this22 = this;
3306
3332
  var tempOrder = this.ensureTempOrder();
3307
- tempOrder.payments = mapPaymentItemsToOrderPayments(payments);
3333
+ tempOrder.payments = mapPaymentItemsToOrderPayments((payments || []).map(function (payment) {
3334
+ return _this22.normalizePaymentSource(payment, {
3335
+ defaultPaid: false
3336
+ });
3337
+ }));
3308
3338
  this.persistTempOrder();
3309
3339
  return tempOrder.payments;
3310
3340
  }
3311
3341
 
3312
- /** 追加单个支付项,并立即持久化当前 tempOrder。 */
3342
+ /** 同步兼容入口:按调用当下的 device_id 或 LOCAL 生成支付编号。 */
3313
3343
  }, {
3314
3344
  key: "addOrderPayment",
3315
3345
  value: function addOrderPayment(payment) {
3316
- var _this20 = this;
3346
+ var hasPaymentNumber = String(payment.payment_number || '').trim() !== '';
3347
+ return this.addOrderPaymentWithDevicePrefix(payment, hasPaymentNumber ? 'LOCAL' : this.getPaymentNumberDevicePrefixSync());
3348
+ }
3349
+
3350
+ /** 异步入口:创建支付项时读取最新 IoT 设备短号。 */
3351
+ }, {
3352
+ key: "addOrderPaymentAsync",
3353
+ value: (function () {
3354
+ var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(payment) {
3355
+ var hasPaymentNumber, devicePrefix;
3356
+ return _regeneratorRuntime().wrap(function _callee15$(_context17) {
3357
+ while (1) switch (_context17.prev = _context17.next) {
3358
+ case 0:
3359
+ hasPaymentNumber = String(payment.payment_number || '').trim() !== '';
3360
+ if (!hasPaymentNumber) {
3361
+ _context17.next = 5;
3362
+ break;
3363
+ }
3364
+ _context17.t0 = 'LOCAL';
3365
+ _context17.next = 8;
3366
+ break;
3367
+ case 5:
3368
+ _context17.next = 7;
3369
+ return this.getPaymentNumberDevicePrefixAsync();
3370
+ case 7:
3371
+ _context17.t0 = _context17.sent;
3372
+ case 8:
3373
+ devicePrefix = _context17.t0;
3374
+ return _context17.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
3375
+ case 10:
3376
+ case "end":
3377
+ return _context17.stop();
3378
+ }
3379
+ }, _callee15, this);
3380
+ }));
3381
+ function addOrderPaymentAsync(_x14) {
3382
+ return _addOrderPaymentAsync.apply(this, arguments);
3383
+ }
3384
+ return addOrderPaymentAsync;
3385
+ }())
3386
+ }, {
3387
+ key: "addOrderPaymentWithDevicePrefix",
3388
+ value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
3389
+ var _this23 = this;
3317
3390
  this.logInfo('addOrderPayment', {
3318
3391
  payment: payment
3319
3392
  });
@@ -3323,14 +3396,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3323
3396
  type: orderPaymentType,
3324
3397
  order_payment_type: orderPaymentType
3325
3398
  }), {
3326
- defaultPaid: true
3399
+ defaultPaid: true,
3400
+ devicePrefix: devicePrefix
3327
3401
  })]);
3328
3402
  tempOrder.payments = [].concat(_toConsumableArray(tempOrder.payments || []), _toConsumableArray(mapped));
3329
3403
  this.persistTempOrder();
3330
3404
  void this.recalculateSummary({
3331
3405
  createIfMissing: true
3332
3406
  }).catch(function (error) {
3333
- _this20.logError('recalculate summary after addOrderPayment failed', {
3407
+ _this23.logError('recalculate summary after addOrderPayment failed', {
3334
3408
  error: error instanceof Error ? error.message : String(error)
3335
3409
  });
3336
3410
  });
@@ -3338,49 +3412,80 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3338
3412
  }
3339
3413
 
3340
3414
  /**
3341
- * 按支付唯一号、后端支付 ID、自定义支付方式 ID 或旧 uuid 更新支付项。
3342
- *
3343
- * 该方法服务 PaymentModal 的 void / 编辑场景;更新 metadata 时会做浅合并,
3344
- * 避免覆盖 unique_payment_number、现金实付/找零等已有元数据。
3415
+ * 默认按支付唯一号精确更新;仅显式指定 legacy 时兼容历史支付标识。
3416
+ * metadata 与 transactions 会分别合并,避免覆盖支付会话号和已有交易记录。
3345
3417
  */
3346
3418
  }, {
3347
3419
  key: "updateOrderPayment",
3348
- value: function updateOrderPayment(paymentIdentity, updates) {
3349
- var tempOrder = this.ensureTempOrder();
3350
- var identity = String(paymentIdentity);
3351
- tempOrder.payments = (tempOrder.payments || []).map(function (payment) {
3352
- var _payment$metadata;
3353
- var uniquePaymentNumber = payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.unique_payment_number;
3354
- var orderPaymentId = payment === null || payment === void 0 ? void 0 : payment.order_payment_id;
3355
- var customPaymentId = payment === null || payment === void 0 ? void 0 : payment.custom_payment_id;
3356
- var uuid = payment === null || payment === void 0 ? void 0 : payment.uuid;
3357
- var matched = [uniquePaymentNumber, orderPaymentId, customPaymentId, uuid].some(function (value) {
3358
- return value !== undefined && String(value) === identity;
3359
- });
3360
- if (!matched) return payment;
3361
- return _objectSpread(_objectSpread(_objectSpread({}, payment), updates), {}, {
3362
- metadata: _objectSpread(_objectSpread({}, payment.metadata || {}), updates.metadata || {})
3363
- });
3364
- });
3365
- this.persistTempOrder();
3366
- return tempOrder.payments;
3367
- }
3368
-
3369
- /** 从当前订单支付项中移除指定支付项。 */
3420
+ value: (function () {
3421
+ var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(paymentIdentity, updates) {
3422
+ var options,
3423
+ tempOrder,
3424
+ identity,
3425
+ matchMode,
3426
+ matchedPayment,
3427
+ updatedPayment,
3428
+ summary,
3429
+ payments,
3430
+ _args18 = arguments;
3431
+ return _regeneratorRuntime().wrap(function _callee16$(_context18) {
3432
+ while (1) switch (_context18.prev = _context18.next) {
3433
+ case 0:
3434
+ options = _args18.length > 2 && _args18[2] !== undefined ? _args18[2] : {};
3435
+ tempOrder = this.ensureTempOrder();
3436
+ identity = String(paymentIdentity);
3437
+ matchMode = options.matchBy === 'compat' || options.matchBy === 'legacy' ? 'compat' : 'payment_number';
3438
+ matchedPayment = resolveOrderPaymentIdentity(tempOrder.payments || [], identity, matchMode);
3439
+ if (matchedPayment) {
3440
+ _context18.next = 7;
3441
+ break;
3442
+ }
3443
+ throw new Error("\u672A\u627E\u5230\u652F\u4ED8\u9879: ".concat(identity));
3444
+ case 7:
3445
+ updatedPayment = null;
3446
+ tempOrder.payments = (tempOrder.payments || []).map(function (payment, index) {
3447
+ if (index !== matchedPayment.index) return payment;
3448
+ var nextPayment = mergeOrderPaymentRecord(payment, _objectSpread(_objectSpread({}, updates), {}, {
3449
+ updated_at: updates.updated_at || dayjs().format('YYYY-MM-DD HH:mm:ss')
3450
+ }));
3451
+ updatedPayment = nextPayment;
3452
+ return nextPayment;
3453
+ });
3454
+ this.persistTempOrder();
3455
+ _context18.next = 12;
3456
+ return this.recalculateSummary({
3457
+ createIfMissing: true
3458
+ });
3459
+ case 12:
3460
+ summary = _context18.sent;
3461
+ this.persistTempOrder();
3462
+ payments = tempOrder.payments;
3463
+ return _context18.abrupt("return", {
3464
+ updated: true,
3465
+ payment: payments[matchedPayment.index] || updatedPayment,
3466
+ payments: payments,
3467
+ summary: summary
3468
+ });
3469
+ case 16:
3470
+ case "end":
3471
+ return _context18.stop();
3472
+ }
3473
+ }, _callee16, this);
3474
+ }));
3475
+ function updateOrderPayment(_x15, _x16) {
3476
+ return _updateOrderPayment.apply(this, arguments);
3477
+ }
3478
+ return updateOrderPayment;
3479
+ }() /** 从当前订单支付项中移除指定支付项。 */)
3370
3480
  }, {
3371
3481
  key: "deleteOrderPayment",
3372
3482
  value: function deleteOrderPayment(paymentIdentity) {
3373
3483
  var tempOrder = this.ensureTempOrder();
3374
3484
  var identity = String(paymentIdentity);
3375
- tempOrder.payments = (tempOrder.payments || []).filter(function (payment) {
3376
- var _payment$metadata2;
3377
- var uniquePaymentNumber = payment === null || payment === void 0 || (_payment$metadata2 = payment.metadata) === null || _payment$metadata2 === void 0 ? void 0 : _payment$metadata2.unique_payment_number;
3378
- var orderPaymentId = payment === null || payment === void 0 ? void 0 : payment.order_payment_id;
3379
- var customPaymentId = payment === null || payment === void 0 ? void 0 : payment.custom_payment_id;
3380
- var uuid = payment === null || payment === void 0 ? void 0 : payment.uuid;
3381
- return ![uniquePaymentNumber, orderPaymentId, customPaymentId, uuid].some(function (value) {
3382
- return value !== undefined && String(value) === identity;
3383
- });
3485
+ var matchedPayment = resolveOrderPaymentIdentity(tempOrder.payments || [], identity, 'compat');
3486
+ if (!matchedPayment) return tempOrder.payments;
3487
+ tempOrder.payments = (tempOrder.payments || []).filter(function (_, index) {
3488
+ return index !== matchedPayment.index;
3384
3489
  });
3385
3490
  this.persistTempOrder();
3386
3491
  return tempOrder.payments;
@@ -3412,7 +3517,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3412
3517
  }, {
3413
3518
  key: "applyPaymentLifecycleChange",
3414
3519
  value: function applyPaymentLifecycleChange(tempOrder, options) {
3415
- var _this21 = this;
3520
+ var _this24 = this;
3416
3521
  this.updateTempOrderPaymentStatus(tempOrder);
3417
3522
  if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
3418
3523
  this.persistTempOrder();
@@ -3422,7 +3527,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3422
3527
  void this.recalculateSummary({
3423
3528
  createIfMissing: true
3424
3529
  }).catch(function (error) {
3425
- _this21.logError("recalculate summary after ".concat(logContext, " failed"), {
3530
+ _this24.logError("recalculate summary after ".concat(logContext, " failed"), {
3426
3531
  error: error instanceof Error ? error.message : String(error)
3427
3532
  });
3428
3533
  });
@@ -3466,7 +3571,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3466
3571
  }, {
3467
3572
  key: "updateVoucherOrderPayments",
3468
3573
  value: function updateVoucherOrderPayments(payments, options) {
3469
- var _this22 = this;
3574
+ var _this25 = this;
3470
3575
  var tempOrder = this.ensureTempOrder();
3471
3576
  var isOrderPaymentType = function isOrderPaymentType(value) {
3472
3577
  return value === 'normal' || value === 'deposit';
@@ -3501,8 +3606,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3501
3606
  });
3502
3607
  };
3503
3608
  var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
3504
- return _this22.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
3505
- defaultPaid: false
3609
+ return _this25.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
3610
+ defaultPaid: false,
3611
+ devicePrefix: options === null || options === void 0 ? void 0 : options.devicePrefix
3506
3612
  });
3507
3613
  })).filter(function (payment) {
3508
3614
  return isVoucherPaymentRecord(payment);
@@ -3528,14 +3634,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3528
3634
  }).map(function (payment) {
3529
3635
  return String(payment.order_payment_id);
3530
3636
  }));
3531
- var committedVoucherIds = new Set(committedVoucherPayments.map(function (payment) {
3532
- return String(payment.voucher_id);
3637
+ var committedVoucherLifecycleKeys = new Set(committedVoucherPayments.map(function (payment) {
3638
+ return getVoucherPaymentLifecycleKey(payment);
3639
+ }).filter(function (key) {
3640
+ return key !== null;
3533
3641
  }));
3534
3642
  var replaceableVouchers = mappedVouchers.filter(function (payment) {
3535
3643
  if (hasSyncedOrderPaymentRecord(payment) && committedVoucherPaymentIds.has(String(payment.order_payment_id))) {
3536
3644
  return false;
3537
3645
  }
3538
- if (payment.voucher_id !== undefined && committedVoucherIds.has(String(payment.voucher_id))) {
3646
+ var lifecycleKey = getVoucherPaymentLifecycleKey(payment);
3647
+ if (lifecycleKey && committedVoucherLifecycleKeys.has(lifecycleKey)) {
3539
3648
  return false;
3540
3649
  }
3541
3650
  return true;
@@ -3550,54 +3659,93 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3550
3659
  void this.recalculateSummary({
3551
3660
  createIfMissing: true
3552
3661
  }).catch(function (error) {
3553
- _this22.logError('recalculate summary after updateVoucherOrderPayments failed', {
3662
+ _this25.logError('recalculate summary after updateVoucherOrderPayments failed', {
3554
3663
  error: error instanceof Error ? error.message : String(error)
3555
3664
  });
3556
3665
  });
3557
3666
  return tempOrder.payments;
3558
3667
  }
3668
+ }, {
3669
+ key: "updateVoucherOrderPaymentsAsync",
3670
+ value: function () {
3671
+ var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(payments, options) {
3672
+ var needsPaymentNumber, devicePrefix;
3673
+ return _regeneratorRuntime().wrap(function _callee17$(_context19) {
3674
+ while (1) switch (_context19.prev = _context19.next) {
3675
+ case 0:
3676
+ needsPaymentNumber = (payments || []).some(function (payment) {
3677
+ return String(payment.payment_number || '').trim() === '';
3678
+ });
3679
+ if (!needsPaymentNumber) {
3680
+ _context19.next = 7;
3681
+ break;
3682
+ }
3683
+ _context19.next = 4;
3684
+ return this.getPaymentNumberDevicePrefixAsync();
3685
+ case 4:
3686
+ _context19.t0 = _context19.sent;
3687
+ _context19.next = 8;
3688
+ break;
3689
+ case 7:
3690
+ _context19.t0 = 'LOCAL';
3691
+ case 8:
3692
+ devicePrefix = _context19.t0;
3693
+ return _context19.abrupt("return", this.updateVoucherOrderPayments(payments, _objectSpread(_objectSpread({}, options), {}, {
3694
+ devicePrefix: devicePrefix
3695
+ })));
3696
+ case 10:
3697
+ case "end":
3698
+ return _context19.stop();
3699
+ }
3700
+ }, _callee17, this);
3701
+ }));
3702
+ function updateVoucherOrderPaymentsAsync(_x17, _x18) {
3703
+ return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
3704
+ }
3705
+ return updateVoucherOrderPaymentsAsync;
3706
+ }()
3559
3707
  }, {
3560
3708
  key: "shouldMergeProductToOrder",
3561
3709
  value: function () {
3562
- var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
3710
+ var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(params) {
3563
3711
  var _this$orderHooks;
3564
3712
  var onBeforeMergeProductToOrder, result;
3565
- return _regeneratorRuntime().wrap(function _callee15$(_context17) {
3566
- while (1) switch (_context17.prev = _context17.next) {
3713
+ return _regeneratorRuntime().wrap(function _callee18$(_context20) {
3714
+ while (1) switch (_context20.prev = _context20.next) {
3567
3715
  case 0:
3568
3716
  onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
3569
3717
  if (onBeforeMergeProductToOrder) {
3570
- _context17.next = 3;
3718
+ _context20.next = 3;
3571
3719
  break;
3572
3720
  }
3573
- return _context17.abrupt("return", true);
3721
+ return _context20.abrupt("return", true);
3574
3722
  case 3:
3575
- _context17.next = 5;
3723
+ _context20.next = 5;
3576
3724
  return onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
3577
3725
  defaultShouldMerge: true
3578
3726
  }));
3579
3727
  case 5:
3580
- result = _context17.sent;
3728
+ result = _context20.sent;
3581
3729
  if (!(typeof result === 'boolean')) {
3582
- _context17.next = 8;
3730
+ _context20.next = 8;
3583
3731
  break;
3584
3732
  }
3585
- return _context17.abrupt("return", result);
3733
+ return _context20.abrupt("return", result);
3586
3734
  case 8:
3587
3735
  if (!(result && _typeof(result) === 'object' && typeof result.shouldMerge === 'boolean')) {
3588
- _context17.next = 10;
3736
+ _context20.next = 10;
3589
3737
  break;
3590
3738
  }
3591
- return _context17.abrupt("return", result.shouldMerge);
3739
+ return _context20.abrupt("return", result.shouldMerge);
3592
3740
  case 10:
3593
- return _context17.abrupt("return", true);
3741
+ return _context20.abrupt("return", true);
3594
3742
  case 11:
3595
3743
  case "end":
3596
- return _context17.stop();
3744
+ return _context20.stop();
3597
3745
  }
3598
- }, _callee15, this);
3746
+ }, _callee18, this);
3599
3747
  }));
3600
- function shouldMergeProductToOrder(_x14) {
3748
+ function shouldMergeProductToOrder(_x19) {
3601
3749
  return _shouldMergeProductToOrder.apply(this, arguments);
3602
3750
  }
3603
3751
  return shouldMergeProductToOrder;
@@ -3633,30 +3781,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3633
3781
  }, {
3634
3782
  key: "finalizeProductOrderMutation",
3635
3783
  value: function () {
3636
- var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(tempOrder, options) {
3637
- return _regeneratorRuntime().wrap(function _callee16$(_context18) {
3638
- while (1) switch (_context18.prev = _context18.next) {
3784
+ var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(tempOrder, options) {
3785
+ return _regeneratorRuntime().wrap(function _callee19$(_context21) {
3786
+ while (1) switch (_context21.prev = _context21.next) {
3639
3787
  case 0:
3640
3788
  this.syncTempOrderHolderFromBookings(tempOrder);
3641
3789
  if (options !== null && options !== void 0 && options.skipEditDiscountConfigRefresh) {
3642
- _context18.next = 4;
3790
+ _context21.next = 4;
3643
3791
  break;
3644
3792
  }
3645
- _context18.next = 4;
3793
+ _context21.next = 4;
3646
3794
  return this.ensureEditDiscountConfigForProductChange(tempOrder);
3647
3795
  case 4:
3648
3796
  if (options !== null && options !== void 0 && options.skipDiscountRecalculation) {
3649
- _context18.next = 7;
3797
+ _context21.next = 7;
3650
3798
  break;
3651
3799
  }
3652
- _context18.next = 7;
3800
+ _context21.next = 7;
3653
3801
  return this.applyPromotion();
3654
3802
  case 7:
3655
3803
  if (!(options !== null && options !== void 0 && options.skipDiscountRecalculation)) {
3656
3804
  this.applyDiscount();
3657
3805
  }
3658
3806
  this.sanitizeTempOrderProducts(tempOrder);
3659
- _context18.next = 11;
3807
+ _context21.next = 11;
3660
3808
  return this.recalculateSummary({
3661
3809
  createIfMissing: true
3662
3810
  });
@@ -3664,11 +3812,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3664
3812
  this.persistTempOrder();
3665
3813
  case 12:
3666
3814
  case "end":
3667
- return _context18.stop();
3815
+ return _context21.stop();
3668
3816
  }
3669
- }, _callee16, this);
3817
+ }, _callee19, this);
3670
3818
  }));
3671
- function finalizeProductOrderMutation(_x15, _x16) {
3819
+ function finalizeProductOrderMutation(_x20, _x21) {
3672
3820
  return _finalizeProductOrderMutation.apply(this, arguments);
3673
3821
  }
3674
3822
  return finalizeProductOrderMutation;
@@ -3683,13 +3831,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3683
3831
  }, {
3684
3832
  key: "appendProductLineToTempOrder",
3685
3833
  value: (function () {
3686
- var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(tempOrder, product, booking) {
3834
+ var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(tempOrder, product, booking) {
3687
3835
  var _booking_uid,
3688
3836
  _metadata,
3689
- _this23 = this;
3837
+ _this26 = this;
3690
3838
  var linked, productToAdd, incomingFingerprint, normalizedIncoming, incomingBookingUid, hasIncomingGoodPass, hasIncomingProductNote, hasIncomingBookingUid, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList;
3691
- return _regeneratorRuntime().wrap(function _callee17$(_context19) {
3692
- while (1) switch (_context19.prev = _context19.next) {
3839
+ return _regeneratorRuntime().wrap(function _callee20$(_context22) {
3840
+ while (1) switch (_context22.prev = _context22.next) {
3693
3841
  case 0:
3694
3842
  linked = booking ? this.createLinkedProductAndBooking({
3695
3843
  product: product,
@@ -3712,8 +3860,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3712
3860
  shouldForceNewLine = !!booking || hasIncomingProductNote || hasIncomingBookingUid;
3713
3861
  matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
3714
3862
  var _item$metadata3;
3715
- if (_this23.hasGoodPassDiscount(item)) return false;
3716
- if (_this23.hasOrderProductLineNote(item)) return false;
3863
+ if (_this26.hasGoodPassDiscount(item)) return false;
3864
+ if (_this26.hasOrderProductLineNote(item)) return false;
3717
3865
  if (item.order_detail_id !== undefined && item.order_detail_id !== null) return false;
3718
3866
  if ((_item$metadata3 = item.metadata) !== null && _item$metadata3 !== void 0 && _item$metadata3.is_edit_for_runtime) return false;
3719
3867
  if (item.product_id !== productToAdd.product_id) return false;
@@ -3724,10 +3872,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3724
3872
  matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
3725
3873
  existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
3726
3874
  if (!matchedProduct) {
3727
- _context19.next = 20;
3875
+ _context22.next = 20;
3728
3876
  break;
3729
3877
  }
3730
- _context19.next = 17;
3878
+ _context22.next = 17;
3731
3879
  return this.shouldMergeProductToOrder({
3732
3880
  incomingProduct: productToAdd,
3733
3881
  normalizedIncoming: normalizedIncoming,
@@ -3739,13 +3887,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3739
3887
  booking: booking
3740
3888
  });
3741
3889
  case 17:
3742
- _context19.t0 = _context19.sent;
3743
- _context19.next = 21;
3890
+ _context22.t0 = _context22.sent;
3891
+ _context22.next = 21;
3744
3892
  break;
3745
3893
  case 20:
3746
- _context19.t0 = false;
3894
+ _context22.t0 = false;
3747
3895
  case 21:
3748
- shouldMerge = _context19.t0;
3896
+ shouldMerge = _context22.t0;
3749
3897
  if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
3750
3898
  this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
3751
3899
  if (linked) {
@@ -3799,11 +3947,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3799
3947
  }
3800
3948
  case 24:
3801
3949
  case "end":
3802
- return _context19.stop();
3950
+ return _context22.stop();
3803
3951
  }
3804
- }, _callee17, this);
3952
+ }, _callee20, this);
3805
3953
  }));
3806
- function appendProductLineToTempOrder(_x17, _x18, _x19) {
3954
+ function appendProductLineToTempOrder(_x22, _x23, _x24) {
3807
3955
  return _appendProductLineToTempOrder.apply(this, arguments);
3808
3956
  }
3809
3957
  return appendProductLineToTempOrder;
@@ -3819,61 +3967,61 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3819
3967
  }, {
3820
3968
  key: "addProductToOrder",
3821
3969
  value: (function () {
3822
- var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(product, booking) {
3970
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(product, booking) {
3823
3971
  var tempOrder, _ref61, _productRecord$num, productRecord, splitCount, i, singleLine;
3824
- return _regeneratorRuntime().wrap(function _callee18$(_context20) {
3825
- while (1) switch (_context20.prev = _context20.next) {
3972
+ return _regeneratorRuntime().wrap(function _callee21$(_context23) {
3973
+ while (1) switch (_context23.prev = _context23.next) {
3826
3974
  case 0:
3827
3975
  tempOrder = this.ensureTempOrder();
3828
3976
  if (!booking) {
3829
- _context20.next = 18;
3977
+ _context23.next = 18;
3830
3978
  break;
3831
3979
  }
3832
3980
  productRecord = product;
3833
3981
  splitCount = getSafeProductNum((_ref61 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref61 !== void 0 ? _ref61 : 1);
3834
3982
  if (!(splitCount > 1)) {
3835
- _context20.next = 18;
3983
+ _context23.next = 18;
3836
3984
  break;
3837
3985
  }
3838
3986
  i = 0;
3839
3987
  case 6:
3840
3988
  if (!(i < splitCount)) {
3841
- _context20.next = 15;
3989
+ _context23.next = 15;
3842
3990
  break;
3843
3991
  }
3844
3992
  singleLine = cloneDeep(productRecord);
3845
3993
  singleLine.num = 1;
3846
3994
  delete singleLine.product_quantity;
3847
- _context20.next = 12;
3995
+ _context23.next = 12;
3848
3996
  return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
3849
3997
  case 12:
3850
3998
  i += 1;
3851
- _context20.next = 6;
3999
+ _context23.next = 6;
3852
4000
  break;
3853
4001
  case 15:
3854
- _context20.next = 17;
4002
+ _context23.next = 17;
3855
4003
  return this.finalizeProductOrderMutation(tempOrder);
3856
4004
  case 17:
3857
- return _context20.abrupt("return", tempOrder.products);
4005
+ return _context23.abrupt("return", tempOrder.products);
3858
4006
  case 18:
3859
- _context20.next = 20;
4007
+ _context23.next = 20;
3860
4008
  return this.appendProductLineToTempOrder(tempOrder, product, booking);
3861
4009
  case 20:
3862
- _context20.next = 22;
4010
+ _context23.next = 22;
3863
4011
  return this.finalizeProductOrderMutation(tempOrder);
3864
4012
  case 22:
3865
4013
  this.logInfo('addProductToOrder success', {
3866
4014
  product_id: product.product_id,
3867
4015
  with_booking: !!booking
3868
4016
  });
3869
- return _context20.abrupt("return", tempOrder.products);
4017
+ return _context23.abrupt("return", tempOrder.products);
3870
4018
  case 24:
3871
4019
  case "end":
3872
- return _context20.stop();
4020
+ return _context23.stop();
3873
4021
  }
3874
- }, _callee18, this);
4022
+ }, _callee21, this);
3875
4023
  }));
3876
- function addProductToOrder(_x20, _x21) {
4024
+ function addProductToOrder(_x25, _x26) {
3877
4025
  return _addProductToOrder.apply(this, arguments);
3878
4026
  }
3879
4027
  return addProductToOrder;
@@ -3891,93 +4039,93 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3891
4039
  }, {
3892
4040
  key: "addProductsToOrder",
3893
4041
  value: (function () {
3894
- var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(items, options) {
4042
+ var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(items, options) {
3895
4043
  var tempOrder, _iterator20, _step20, item, product, booking, _ref62, _productRecord$num2, productRecord, splitCount, i, singleLine;
3896
- return _regeneratorRuntime().wrap(function _callee19$(_context21) {
3897
- while (1) switch (_context21.prev = _context21.next) {
4044
+ return _regeneratorRuntime().wrap(function _callee22$(_context24) {
4045
+ while (1) switch (_context24.prev = _context24.next) {
3898
4046
  case 0:
3899
4047
  tempOrder = this.ensureTempOrder();
3900
4048
  if (!(!Array.isArray(items) || items.length === 0)) {
3901
- _context21.next = 3;
4049
+ _context24.next = 3;
3902
4050
  break;
3903
4051
  }
3904
- return _context21.abrupt("return", tempOrder.products);
4052
+ return _context24.abrupt("return", tempOrder.products);
3905
4053
  case 3:
3906
4054
  _iterator20 = _createForOfIteratorHelper(items || []);
3907
- _context21.prev = 4;
4055
+ _context24.prev = 4;
3908
4056
  _iterator20.s();
3909
4057
  case 6:
3910
4058
  if ((_step20 = _iterator20.n()).done) {
3911
- _context21.next = 30;
4059
+ _context24.next = 30;
3912
4060
  break;
3913
4061
  }
3914
4062
  item = _step20.value;
3915
4063
  product = item.product, booking = item.booking;
3916
4064
  if (product) {
3917
- _context21.next = 11;
4065
+ _context24.next = 11;
3918
4066
  break;
3919
4067
  }
3920
- return _context21.abrupt("continue", 28);
4068
+ return _context24.abrupt("continue", 28);
3921
4069
  case 11:
3922
4070
  if (!booking) {
3923
- _context21.next = 26;
4071
+ _context24.next = 26;
3924
4072
  break;
3925
4073
  }
3926
4074
  productRecord = product;
3927
4075
  splitCount = getSafeProductNum((_ref62 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref62 !== void 0 ? _ref62 : 1);
3928
4076
  if (!(splitCount > 1)) {
3929
- _context21.next = 26;
4077
+ _context24.next = 26;
3930
4078
  break;
3931
4079
  }
3932
4080
  i = 0;
3933
4081
  case 16:
3934
4082
  if (!(i < splitCount)) {
3935
- _context21.next = 25;
4083
+ _context24.next = 25;
3936
4084
  break;
3937
4085
  }
3938
4086
  singleLine = cloneDeep(productRecord);
3939
4087
  singleLine.num = 1;
3940
4088
  delete singleLine.product_quantity;
3941
- _context21.next = 22;
4089
+ _context24.next = 22;
3942
4090
  return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
3943
4091
  case 22:
3944
4092
  i += 1;
3945
- _context21.next = 16;
4093
+ _context24.next = 16;
3946
4094
  break;
3947
4095
  case 25:
3948
- return _context21.abrupt("continue", 28);
4096
+ return _context24.abrupt("continue", 28);
3949
4097
  case 26:
3950
- _context21.next = 28;
4098
+ _context24.next = 28;
3951
4099
  return this.appendProductLineToTempOrder(tempOrder, product, booking);
3952
4100
  case 28:
3953
- _context21.next = 6;
4101
+ _context24.next = 6;
3954
4102
  break;
3955
4103
  case 30:
3956
- _context21.next = 35;
4104
+ _context24.next = 35;
3957
4105
  break;
3958
4106
  case 32:
3959
- _context21.prev = 32;
3960
- _context21.t0 = _context21["catch"](4);
3961
- _iterator20.e(_context21.t0);
4107
+ _context24.prev = 32;
4108
+ _context24.t0 = _context24["catch"](4);
4109
+ _iterator20.e(_context24.t0);
3962
4110
  case 35:
3963
- _context21.prev = 35;
4111
+ _context24.prev = 35;
3964
4112
  _iterator20.f();
3965
- return _context21.finish(35);
4113
+ return _context24.finish(35);
3966
4114
  case 38:
3967
- _context21.next = 40;
4115
+ _context24.next = 40;
3968
4116
  return this.finalizeProductOrderMutation(tempOrder, options);
3969
4117
  case 40:
3970
4118
  this.logInfo('addProductsToOrder success', {
3971
4119
  itemsCount: items.length
3972
4120
  });
3973
- return _context21.abrupt("return", tempOrder.products);
4121
+ return _context24.abrupt("return", tempOrder.products);
3974
4122
  case 42:
3975
4123
  case "end":
3976
- return _context21.stop();
4124
+ return _context24.stop();
3977
4125
  }
3978
- }, _callee19, this, [[4, 32, 35, 38]]);
4126
+ }, _callee22, this, [[4, 32, 35, 38]]);
3979
4127
  }));
3980
- function addProductsToOrder(_x22, _x23) {
4128
+ function addProductsToOrder(_x27, _x28) {
3981
4129
  return _addProductsToOrder.apply(this, arguments);
3982
4130
  }
3983
4131
  return addProductsToOrder;
@@ -4011,17 +4159,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4011
4159
  }, {
4012
4160
  key: "preservePersistedBundlePriceFields",
4013
4161
  value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
4014
- var _this24 = this;
4162
+ var _this27 = this;
4015
4163
  if (!Array.isArray(nextBundles)) return nextBundles;
4016
4164
  if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
4017
4165
  var previousByIdentity = new Map();
4018
4166
  previousBundles.forEach(function (bundle) {
4019
- var identity = _this24.getBundleRuntimeIdentity(bundle);
4167
+ var identity = _this27.getBundleRuntimeIdentity(bundle);
4020
4168
  if (identity) previousByIdentity.set(identity, bundle);
4021
4169
  });
4022
4170
  return nextBundles.map(function (bundle, index) {
4023
4171
  if (!bundle || _typeof(bundle) !== 'object') return bundle;
4024
- var previous = previousByIdentity.get(_this24.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
4172
+ var previous = previousByIdentity.get(_this27.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
4025
4173
  if (!previous || _typeof(previous) !== 'object') return bundle;
4026
4174
  return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
4027
4175
  cover: previous.cover
@@ -4222,21 +4370,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4222
4370
  }, {
4223
4371
  key: "updateOrderProduct",
4224
4372
  value: function () {
4225
- var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
4373
+ var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
4226
4374
  var tempOrder, updatedProductUid;
4227
- return _regeneratorRuntime().wrap(function _callee20$(_context22) {
4228
- while (1) switch (_context22.prev = _context22.next) {
4375
+ return _regeneratorRuntime().wrap(function _callee23$(_context25) {
4376
+ while (1) switch (_context25.prev = _context25.next) {
4229
4377
  case 0:
4230
4378
  tempOrder = this.ensureTempOrder();
4231
4379
  updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params);
4232
- _context22.next = 4;
4380
+ _context25.next = 4;
4233
4381
  return this.applyPromotion();
4234
4382
  case 4:
4235
4383
  this.applyDiscount({
4236
4384
  reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
4237
4385
  });
4238
4386
  this.sanitizeTempOrderProducts(tempOrder);
4239
- _context22.next = 8;
4387
+ _context25.next = 8;
4240
4388
  return this.recalculateSummary({
4241
4389
  createIfMissing: true
4242
4390
  });
@@ -4245,14 +4393,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4245
4393
  this.logInfo('updateOrderProduct success', {
4246
4394
  params: params
4247
4395
  });
4248
- return _context22.abrupt("return", tempOrder.products);
4396
+ return _context25.abrupt("return", tempOrder.products);
4249
4397
  case 11:
4250
4398
  case "end":
4251
- return _context22.stop();
4399
+ return _context25.stop();
4252
4400
  }
4253
- }, _callee20, this);
4401
+ }, _callee23, this);
4254
4402
  }));
4255
- function updateOrderProduct(_x24) {
4403
+ function updateOrderProduct(_x29) {
4256
4404
  return _updateOrderProduct.apply(this, arguments);
4257
4405
  }
4258
4406
  return updateOrderProduct;
@@ -4260,28 +4408,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4260
4408
  }, {
4261
4409
  key: "updateOrderProducts",
4262
4410
  value: function () {
4263
- var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(paramsList) {
4264
- var _this25 = this;
4411
+ var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(paramsList) {
4412
+ var _this28 = this;
4265
4413
  var tempOrder, reapplyBookingDiscountProductUids;
4266
- return _regeneratorRuntime().wrap(function _callee21$(_context23) {
4267
- while (1) switch (_context23.prev = _context23.next) {
4414
+ return _regeneratorRuntime().wrap(function _callee24$(_context26) {
4415
+ while (1) switch (_context26.prev = _context26.next) {
4268
4416
  case 0:
4269
4417
  tempOrder = this.ensureTempOrder();
4270
4418
  if (paramsList.length) {
4271
- _context23.next = 3;
4419
+ _context26.next = 3;
4272
4420
  break;
4273
4421
  }
4274
- return _context23.abrupt("return", tempOrder.products);
4422
+ return _context26.abrupt("return", tempOrder.products);
4275
4423
  case 3:
4276
4424
  reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
4277
- var updatedProductUid = _this25.applyOrderProductUpdateToTempOrder(tempOrder, params);
4425
+ var updatedProductUid = _this28.applyOrderProductUpdateToTempOrder(tempOrder, params);
4278
4426
  // 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
4279
4427
  if (params.allow_booking_discount_reapply && updatedProductUid) {
4280
4428
  acc.push(String(updatedProductUid));
4281
4429
  }
4282
4430
  return acc;
4283
4431
  }, []);
4284
- _context23.next = 6;
4432
+ _context26.next = 6;
4285
4433
  return this.finalizeAfterProductsMutation(tempOrder, {
4286
4434
  reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
4287
4435
  });
@@ -4289,14 +4437,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4289
4437
  this.logInfo('updateOrderProduct success', {
4290
4438
  paramsList: paramsList
4291
4439
  });
4292
- return _context23.abrupt("return", tempOrder.products);
4440
+ return _context26.abrupt("return", tempOrder.products);
4293
4441
  case 8:
4294
4442
  case "end":
4295
- return _context23.stop();
4443
+ return _context26.stop();
4296
4444
  }
4297
- }, _callee21, this);
4445
+ }, _callee24, this);
4298
4446
  }));
4299
- function updateOrderProducts(_x25) {
4447
+ function updateOrderProducts(_x30) {
4300
4448
  return _updateOrderProducts.apply(this, arguments);
4301
4449
  }
4302
4450
  return updateOrderProducts;
@@ -4304,11 +4452,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4304
4452
  }, {
4305
4453
  key: "updateOrderProductQuantity",
4306
4454
  value: function () {
4307
- var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
4455
+ var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
4308
4456
  var _targetProduct$metada17;
4309
4457
  var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct;
4310
- return _regeneratorRuntime().wrap(function _callee22$(_context24) {
4311
- while (1) switch (_context24.prev = _context24.next) {
4458
+ return _regeneratorRuntime().wrap(function _callee25$(_context27) {
4459
+ while (1) switch (_context27.prev = _context27.next) {
4312
4460
  case 0:
4313
4461
  product_id = params.product_id, product_variant_id = params.product_variant_id, num = params.num, unique_identification_number = params.unique_identification_number, identity_key = params.identity_key, product_sku = params.product_sku, product_bundle = params.product_bundle;
4314
4462
  tempOrder = this.ensureTempOrder();
@@ -4337,7 +4485,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4337
4485
  productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
4338
4486
  }
4339
4487
  if (!(productIndex === -1)) {
4340
- _context24.next = 12;
4488
+ _context27.next = 12;
4341
4489
  break;
4342
4490
  }
4343
4491
  throw new Error('[Order] 目标商品不存在,无法更新数量');
@@ -4351,12 +4499,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4351
4499
  }));
4352
4500
  normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
4353
4501
  tempOrder.products[productIndex] = normalizedProduct;
4354
- _context24.next = 18;
4502
+ _context27.next = 18;
4355
4503
  return this.applyPromotion();
4356
4504
  case 18:
4357
4505
  this.applyDiscount();
4358
4506
  this.sanitizeTempOrderProducts(tempOrder);
4359
- _context24.next = 22;
4507
+ _context27.next = 22;
4360
4508
  return this.recalculateSummary({
4361
4509
  createIfMissing: true
4362
4510
  });
@@ -4365,14 +4513,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4365
4513
  this.logInfo('updateOrderProductQuantity success', {
4366
4514
  params: params
4367
4515
  });
4368
- return _context24.abrupt("return", tempOrder.products);
4516
+ return _context27.abrupt("return", tempOrder.products);
4369
4517
  case 25:
4370
4518
  case "end":
4371
- return _context24.stop();
4519
+ return _context27.stop();
4372
4520
  }
4373
- }, _callee22, this);
4521
+ }, _callee25, this);
4374
4522
  }));
4375
- function updateOrderProductQuantity(_x26) {
4523
+ function updateOrderProductQuantity(_x31) {
4376
4524
  return _updateOrderProductQuantity.apply(this, arguments);
4377
4525
  }
4378
4526
  return updateOrderProductQuantity;
@@ -4413,19 +4561,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4413
4561
  }, {
4414
4562
  key: "finalizeAfterProductsMutation",
4415
4563
  value: (function () {
4416
- var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(tempOrder, options) {
4417
- return _regeneratorRuntime().wrap(function _callee23$(_context25) {
4418
- while (1) switch (_context25.prev = _context25.next) {
4564
+ var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(tempOrder, options) {
4565
+ return _regeneratorRuntime().wrap(function _callee26$(_context28) {
4566
+ while (1) switch (_context28.prev = _context28.next) {
4419
4567
  case 0:
4420
4568
  this.syncTempOrderHolderFromBookings(tempOrder);
4421
- _context25.next = 3;
4569
+ _context28.next = 3;
4422
4570
  return this.applyPromotion();
4423
4571
  case 3:
4424
4572
  this.applyDiscount({
4425
4573
  reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids
4426
4574
  });
4427
4575
  this.sanitizeTempOrderProducts(tempOrder);
4428
- _context25.next = 7;
4576
+ _context28.next = 7;
4429
4577
  return this.recalculateSummary({
4430
4578
  createIfMissing: true
4431
4579
  });
@@ -4433,11 +4581,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4433
4581
  this.persistTempOrder();
4434
4582
  case 8:
4435
4583
  case "end":
4436
- return _context25.stop();
4584
+ return _context28.stop();
4437
4585
  }
4438
- }, _callee23, this);
4586
+ }, _callee26, this);
4439
4587
  }));
4440
- function finalizeAfterProductsMutation(_x27, _x28) {
4588
+ function finalizeAfterProductsMutation(_x32, _x33) {
4441
4589
  return _finalizeAfterProductsMutation.apply(this, arguments);
4442
4590
  }
4443
4591
  return finalizeAfterProductsMutation;
@@ -4452,18 +4600,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4452
4600
  }, {
4453
4601
  key: "removeProductsFromOrder",
4454
4602
  value: (function () {
4455
- var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(identities) {
4456
- var _this26 = this;
4603
+ var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(identities) {
4604
+ var _this29 = this;
4457
4605
  var tempOrder, productsBeforeRemove, bookingsBeforeRemove, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3;
4458
- return _regeneratorRuntime().wrap(function _callee24$(_context27) {
4459
- while (1) switch (_context27.prev = _context27.next) {
4606
+ return _regeneratorRuntime().wrap(function _callee27$(_context30) {
4607
+ while (1) switch (_context30.prev = _context30.next) {
4460
4608
  case 0:
4461
4609
  tempOrder = this.ensureTempOrder();
4462
4610
  if (identities.length) {
4463
- _context27.next = 3;
4611
+ _context30.next = 3;
4464
4612
  break;
4465
4613
  }
4466
- return _context27.abrupt("return", tempOrder.products);
4614
+ return _context30.abrupt("return", tempOrder.products);
4467
4615
  case 3:
4468
4616
  productsBeforeRemove = tempOrder.products || [];
4469
4617
  bookingsBeforeRemove = tempOrder.bookings || [];
@@ -4486,29 +4634,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4486
4634
  }
4487
4635
  linkedBookingUidsToRemove = new Set();
4488
4636
  _iterator21 = _createForOfIteratorHelper(matchedProducts);
4489
- _context27.prev = 11;
4637
+ _context30.prev = 11;
4490
4638
  _loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
4491
4639
  var _metadata11, _metadata12, _metadata13, _metadata14;
4492
4640
  var product, productUid, productBookingUid, isAddTimeProduct;
4493
- return _regeneratorRuntime().wrap(function _loop3$(_context26) {
4494
- while (1) switch (_context26.prev = _context26.next) {
4641
+ return _regeneratorRuntime().wrap(function _loop3$(_context29) {
4642
+ while (1) switch (_context29.prev = _context29.next) {
4495
4643
  case 0:
4496
4644
  product = _step21.value;
4497
4645
  productUid = (product === null || product === void 0 || (_metadata11 = product.metadata) === null || _metadata11 === void 0 ? void 0 : _metadata11.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
4498
4646
  productBookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_metadata12 = product.metadata) === null || _metadata12 === void 0 ? void 0 : _metadata12.booking_uid);
4499
4647
  isAddTimeProduct = (product === null || product === void 0 || (_metadata13 = product.metadata) === null || _metadata13 === void 0 ? void 0 : _metadata13.product_add_schedule_time) !== undefined && (product === null || product === void 0 || (_metadata14 = product.metadata) === null || _metadata14 === void 0 ? void 0 : _metadata14.product_add_schedule_time) !== null;
4500
4648
  if (!isAddTimeProduct) {
4501
- _context26.next = 6;
4649
+ _context29.next = 6;
4502
4650
  break;
4503
4651
  }
4504
- return _context26.abrupt("return", 1);
4652
+ return _context29.abrupt("return", 1);
4505
4653
  case 6:
4506
4654
  if (productBookingUid !== undefined && productBookingUid !== null && productBookingUid !== '') {
4507
4655
  linkedBookingUidsToRemove.add(String(productBookingUid));
4508
4656
  }
4509
4657
  if (productUid !== undefined && productUid !== null && productUid !== '') {
4510
4658
  bookingsBeforeRemove.forEach(function (booking) {
4511
- var bookingUid = _this26.getBookingUniqueIdentificationNumber(booking);
4659
+ var bookingUid = _this29.getBookingUniqueIdentificationNumber(booking);
4512
4660
  if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
4513
4661
  linkedBookingUidsToRemove.add(bookingUid);
4514
4662
  }
@@ -4516,37 +4664,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4516
4664
  }
4517
4665
  case 8:
4518
4666
  case "end":
4519
- return _context26.stop();
4667
+ return _context29.stop();
4520
4668
  }
4521
4669
  }, _loop3);
4522
4670
  });
4523
4671
  _iterator21.s();
4524
4672
  case 14:
4525
4673
  if ((_step21 = _iterator21.n()).done) {
4526
- _context27.next = 20;
4674
+ _context30.next = 20;
4527
4675
  break;
4528
4676
  }
4529
- return _context27.delegateYield(_loop3(), "t0", 16);
4677
+ return _context30.delegateYield(_loop3(), "t0", 16);
4530
4678
  case 16:
4531
- if (!_context27.t0) {
4532
- _context27.next = 18;
4679
+ if (!_context30.t0) {
4680
+ _context30.next = 18;
4533
4681
  break;
4534
4682
  }
4535
- return _context27.abrupt("continue", 18);
4683
+ return _context30.abrupt("continue", 18);
4536
4684
  case 18:
4537
- _context27.next = 14;
4685
+ _context30.next = 14;
4538
4686
  break;
4539
4687
  case 20:
4540
- _context27.next = 25;
4688
+ _context30.next = 25;
4541
4689
  break;
4542
4690
  case 22:
4543
- _context27.prev = 22;
4544
- _context27.t1 = _context27["catch"](11);
4545
- _iterator21.e(_context27.t1);
4691
+ _context30.prev = 22;
4692
+ _context30.t1 = _context30["catch"](11);
4693
+ _iterator21.e(_context30.t1);
4546
4694
  case 25:
4547
- _context27.prev = 25;
4695
+ _context30.prev = 25;
4548
4696
  _iterator21.f();
4549
- return _context27.finish(25);
4697
+ return _context30.finish(25);
4550
4698
  case 28:
4551
4699
  if (linkedBookingUidsToRemove.size > 0) {
4552
4700
  // 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
@@ -4557,20 +4705,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4557
4705
  return !(isAddTimeProduct && lineBookingUid !== undefined && lineBookingUid !== null && linkedBookingUidsToRemove.has(String(lineBookingUid)));
4558
4706
  });
4559
4707
  }
4560
- _context27.next = 31;
4708
+ _context30.next = 31;
4561
4709
  return this.finalizeAfterProductsMutation(tempOrder);
4562
4710
  case 31:
4563
4711
  this.logInfo('removeProductsFromOrder success', {
4564
4712
  identities: identities
4565
4713
  });
4566
- return _context27.abrupt("return", tempOrder.products);
4714
+ return _context30.abrupt("return", tempOrder.products);
4567
4715
  case 33:
4568
4716
  case "end":
4569
- return _context27.stop();
4717
+ return _context30.stop();
4570
4718
  }
4571
- }, _callee24, this, [[11, 22, 25, 28]]);
4719
+ }, _callee27, this, [[11, 22, 25, 28]]);
4572
4720
  }));
4573
- function removeProductsFromOrder(_x29) {
4721
+ function removeProductsFromOrder(_x34) {
4574
4722
  return _removeProductsFromOrder.apply(this, arguments);
4575
4723
  }
4576
4724
  return removeProductsFromOrder;
@@ -4578,18 +4726,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4578
4726
  }, {
4579
4727
  key: "removeProductFromOrder",
4580
4728
  value: function () {
4581
- var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(identity) {
4582
- return _regeneratorRuntime().wrap(function _callee25$(_context28) {
4583
- while (1) switch (_context28.prev = _context28.next) {
4729
+ var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(identity) {
4730
+ return _regeneratorRuntime().wrap(function _callee28$(_context31) {
4731
+ while (1) switch (_context31.prev = _context31.next) {
4584
4732
  case 0:
4585
- return _context28.abrupt("return", this.removeProductsFromOrder([identity]));
4733
+ return _context31.abrupt("return", this.removeProductsFromOrder([identity]));
4586
4734
  case 1:
4587
4735
  case "end":
4588
- return _context28.stop();
4736
+ return _context31.stop();
4589
4737
  }
4590
- }, _callee25, this);
4738
+ }, _callee28, this);
4591
4739
  }));
4592
- function removeProductFromOrder(_x30) {
4740
+ function removeProductFromOrder(_x35) {
4593
4741
  return _removeProductFromOrder.apply(this, arguments);
4594
4742
  }
4595
4743
  return removeProductFromOrder;
@@ -4601,10 +4749,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4601
4749
  }, {
4602
4750
  key: "clearOrderCartLines",
4603
4751
  value: (function () {
4604
- var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
4752
+ var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
4605
4753
  var tempOrder;
4606
- return _regeneratorRuntime().wrap(function _callee26$(_context29) {
4607
- while (1) switch (_context29.prev = _context29.next) {
4754
+ return _regeneratorRuntime().wrap(function _callee29$(_context32) {
4755
+ while (1) switch (_context32.prev = _context32.next) {
4608
4756
  case 0:
4609
4757
  tempOrder = this.ensureTempOrder();
4610
4758
  tempOrder.products = [];
@@ -4615,24 +4763,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4615
4763
  productsByUid: {}
4616
4764
  });
4617
4765
  }
4618
- _context29.next = 7;
4766
+ _context32.next = 7;
4619
4767
  return this.applyPromotion();
4620
4768
  case 7:
4621
4769
  this.applyDiscount();
4622
4770
  this.sanitizeTempOrderProducts(tempOrder);
4623
- _context29.next = 11;
4771
+ _context32.next = 11;
4624
4772
  return this.recalculateSummary({
4625
4773
  createIfMissing: true
4626
4774
  });
4627
4775
  case 11:
4628
4776
  this.persistTempOrder();
4629
4777
  this.logInfo('clearOrderCartLines success', {});
4630
- return _context29.abrupt("return", tempOrder);
4778
+ return _context32.abrupt("return", tempOrder);
4631
4779
  case 14:
4632
4780
  case "end":
4633
- return _context29.stop();
4781
+ return _context32.stop();
4634
4782
  }
4635
- }, _callee26, this);
4783
+ }, _callee29, this);
4636
4784
  }));
4637
4785
  function clearOrderCartLines() {
4638
4786
  return _clearOrderCartLines.apply(this, arguments);
@@ -4670,17 +4818,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4670
4818
  }, {
4671
4819
  key: "applyLocalPrintOrderNumbers",
4672
4820
  value: function () {
4673
- var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(order) {
4821
+ var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(order) {
4674
4822
  var tempOrder, shopOrderNumber, shopFullOrderNumber;
4675
- return _regeneratorRuntime().wrap(function _callee27$(_context30) {
4676
- while (1) switch (_context30.prev = _context30.next) {
4823
+ return _regeneratorRuntime().wrap(function _callee30$(_context33) {
4824
+ while (1) switch (_context33.prev = _context33.next) {
4677
4825
  case 0:
4678
4826
  tempOrder = this.ensureTempOrder();
4679
4827
  if (!(!order || _typeof(order) !== 'object')) {
4680
- _context30.next = 3;
4828
+ _context33.next = 3;
4681
4829
  break;
4682
4830
  }
4683
- return _context30.abrupt("return", tempOrder);
4831
+ return _context33.abrupt("return", tempOrder);
4684
4832
  case 3:
4685
4833
  shopOrderNumber = order.shop_order_number;
4686
4834
  shopFullOrderNumber = order.shop_full_order_number;
@@ -4691,21 +4839,88 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4691
4839
  tempOrder.shop_full_order_number = String(shopFullOrderNumber);
4692
4840
  }
4693
4841
  this.persistTempOrder();
4694
- _context30.next = 10;
4842
+ _context33.next = 10;
4695
4843
  return this.saveDraft();
4696
4844
  case 10:
4697
- return _context30.abrupt("return", tempOrder);
4845
+ return _context33.abrupt("return", tempOrder);
4698
4846
  case 11:
4699
4847
  case "end":
4700
- return _context30.stop();
4848
+ return _context33.stop();
4701
4849
  }
4702
- }, _callee27, this);
4850
+ }, _callee30, this);
4703
4851
  }));
4704
- function applyLocalPrintOrderNumbers(_x31) {
4852
+ function applyLocalPrintOrderNumbers(_x36) {
4705
4853
  return _applyLocalPrintOrderNumbers.apply(this, arguments);
4706
4854
  }
4707
4855
  return applyLocalPrintOrderNumbers;
4708
4856
  }()
4857
+ }, {
4858
+ key: "saveTempOrderAsDraft",
4859
+ value: function () {
4860
+ var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
4861
+ var _params$cacheId2, _this$otherParams6, _this$otherParams7, _this$otherParams8, _params$type, _this$otherParams9, _payload$products;
4862
+ var tempOrder, latestSummary, payload;
4863
+ return _regeneratorRuntime().wrap(function _callee31$(_context34) {
4864
+ while (1) switch (_context34.prev = _context34.next) {
4865
+ case 0:
4866
+ tempOrder = this.ensureTempOrder();
4867
+ this.ensureExternalSaleNumber(tempOrder);
4868
+ this.persistTempOrder();
4869
+ _context34.next = 5;
4870
+ return this.recalculateSummary({
4871
+ createIfMissing: true
4872
+ });
4873
+ case 5:
4874
+ _context34.t1 = _context34.sent;
4875
+ if (_context34.t1) {
4876
+ _context34.next = 8;
4877
+ break;
4878
+ }
4879
+ _context34.t1 = this.store.summary;
4880
+ case 8:
4881
+ _context34.t0 = _context34.t1;
4882
+ if (_context34.t0) {
4883
+ _context34.next = 11;
4884
+ break;
4885
+ }
4886
+ _context34.t0 = createEmptySummary();
4887
+ case 11:
4888
+ latestSummary = _context34.t0;
4889
+ payload = buildSubmitPayload({
4890
+ tempOrder: tempOrder,
4891
+ cacheId: (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId,
4892
+ platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform),
4893
+ businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.businessCode) || ((_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.business_code) || tempOrder.business_code,
4894
+ channel: params === null || params === void 0 ? void 0 : params.channel,
4895
+ type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.type,
4896
+ summary: latestSummary,
4897
+ enhance: params === null || params === void 0 ? void 0 : params.enhancePayload
4898
+ });
4899
+ if (!payload.created_at) {
4900
+ payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
4901
+ }
4902
+ payload.need_sync = 0;
4903
+ payload.is_draft_order = 1;
4904
+ this.logInfo('saveTempOrderAsDraft calling sales draft', {
4905
+ orderId: payload.order_id,
4906
+ externalSaleNumber: payload.external_sale_number,
4907
+ productsCount: ((_payload$products = payload.products) === null || _payload$products === void 0 ? void 0 : _payload$products.length) || 0
4908
+ });
4909
+ return _context34.abrupt("return", this.request.post('/order/sales/draft', payload, {
4910
+ osServer: true,
4911
+ customToast: function customToast() {}
4912
+ }));
4913
+ case 18:
4914
+ case "end":
4915
+ return _context34.stop();
4916
+ }
4917
+ }, _callee31, this);
4918
+ }));
4919
+ function saveTempOrderAsDraft(_x37) {
4920
+ return _saveTempOrderAsDraft.apply(this, arguments);
4921
+ }
4922
+ return saveTempOrderAsDraft;
4923
+ }()
4709
4924
  /**
4710
4925
  * 提交当前 Sales tempOrder。
4711
4926
  *
@@ -4715,18 +4930,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4715
4930
  }, {
4716
4931
  key: "submitTempOrder",
4717
4932
  value: (function () {
4718
- var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
4719
- return _regeneratorRuntime().wrap(function _callee28$(_context31) {
4720
- while (1) switch (_context31.prev = _context31.next) {
4933
+ var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
4934
+ return _regeneratorRuntime().wrap(function _callee32$(_context35) {
4935
+ while (1) switch (_context35.prev = _context35.next) {
4721
4936
  case 0:
4722
- return _context31.abrupt("return", this.runSubmitTempOrder(params));
4937
+ return _context35.abrupt("return", this.runSubmitTempOrder(params));
4723
4938
  case 1:
4724
4939
  case "end":
4725
- return _context31.stop();
4940
+ return _context35.stop();
4726
4941
  }
4727
- }, _callee28, this);
4942
+ }, _callee32, this);
4728
4943
  }));
4729
- function submitTempOrder(_x32) {
4944
+ function submitTempOrder(_x38) {
4730
4945
  return _submitTempOrder.apply(this, arguments);
4731
4946
  }
4732
4947
  return submitTempOrder;
@@ -4734,20 +4949,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4734
4949
  }, {
4735
4950
  key: "submitTempOrderAsync",
4736
4951
  value: function () {
4737
- var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
4738
- return _regeneratorRuntime().wrap(function _callee29$(_context32) {
4739
- while (1) switch (_context32.prev = _context32.next) {
4952
+ var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
4953
+ return _regeneratorRuntime().wrap(function _callee33$(_context36) {
4954
+ while (1) switch (_context36.prev = _context36.next) {
4740
4955
  case 0:
4741
- return _context32.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
4956
+ return _context36.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
4742
4957
  syncMode: true
4743
4958
  })));
4744
4959
  case 1:
4745
4960
  case "end":
4746
- return _context32.stop();
4961
+ return _context36.stop();
4747
4962
  }
4748
- }, _callee29, this);
4963
+ }, _callee33, this);
4749
4964
  }));
4750
- function submitTempOrderAsync(_x33) {
4965
+ function submitTempOrderAsync(_x39) {
4751
4966
  return _submitTempOrderAsync.apply(this, arguments);
4752
4967
  }
4753
4968
  return submitTempOrderAsync;
@@ -4755,11 +4970,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4755
4970
  }, {
4756
4971
  key: "runSubmitTempOrder",
4757
4972
  value: function () {
4758
- var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
4759
- var _params$cacheId2, _this$otherParams6, _ref74, _ref75, _submitSnapshot$busin, _this$otherParams7, _this$otherParams8, _submitSnapshot$type;
4973
+ var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
4974
+ var _params$cacheId3, _this$otherParams10, _ref74, _ref75, _submitSnapshot$busin, _this$otherParams11, _this$otherParams12, _submitSnapshot$type;
4760
4975
  var tempOrder, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
4761
- return _regeneratorRuntime().wrap(function _callee30$(_context33) {
4762
- while (1) switch (_context33.prev = _context33.next) {
4976
+ return _regeneratorRuntime().wrap(function _callee34$(_context37) {
4977
+ while (1) switch (_context37.prev = _context37.next) {
4763
4978
  case 0:
4764
4979
  tempOrder = this.ensureTempOrder();
4765
4980
  shouldConfirmPendingVoucherPayments = (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== false;
@@ -4779,27 +4994,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4779
4994
  }
4780
4995
  }
4781
4996
  this.persistTempOrder();
4782
- _context33.next = 8;
4997
+ _context37.next = 8;
4783
4998
  return this.recalculateSummary({
4784
4999
  createIfMissing: true
4785
5000
  });
4786
5001
  case 8:
4787
- _context33.t1 = _context33.sent;
4788
- if (_context33.t1) {
4789
- _context33.next = 11;
5002
+ _context37.t1 = _context37.sent;
5003
+ if (_context37.t1) {
5004
+ _context37.next = 11;
4790
5005
  break;
4791
5006
  }
4792
- _context33.t1 = this.store.summary;
5007
+ _context37.t1 = this.store.summary;
4793
5008
  case 11:
4794
- _context33.t0 = _context33.t1;
4795
- if (_context33.t0) {
4796
- _context33.next = 14;
5009
+ _context37.t0 = _context37.t1;
5010
+ if (_context37.t0) {
5011
+ _context37.next = 14;
4797
5012
  break;
4798
5013
  }
4799
- _context33.t0 = createEmptySummary();
5014
+ _context37.t0 = createEmptySummary();
4800
5015
  case 14:
4801
- latestSummary = _context33.t0;
4802
- effectiveCacheId = (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId;
5016
+ latestSummary = _context37.t0;
5017
+ effectiveCacheId = (_params$cacheId3 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId3 !== void 0 ? _params$cacheId3 : this.cacheId;
4803
5018
  hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
4804
5019
  hasSmallTicketDataFlagOverride = (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined;
4805
5020
  enhancePayload = hasPaymentOverride || hasPaymentStatusOverride || hasSmallTicketDataFlagOverride || params !== null && params !== void 0 && params.enhancePayload ? function (payload, ctx) {
@@ -4817,8 +5032,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4817
5032
  payload = buildSubmitPayload({
4818
5033
  tempOrder: tempOrder,
4819
5034
  cacheId: effectiveCacheId,
4820
- platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform),
4821
- businessCode: (_ref74 = (_ref75 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref75 !== void 0 ? _ref75 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.businessCode) !== null && _ref74 !== void 0 ? _ref74 : (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.business_code,
5035
+ platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.platform),
5036
+ businessCode: (_ref74 = (_ref75 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref75 !== void 0 ? _ref75 : (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.businessCode) !== null && _ref74 !== void 0 ? _ref74 : (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.business_code,
4822
5037
  channel: params === null || params === void 0 ? void 0 : params.channel,
4823
5038
  type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
4824
5039
  summary: latestSummary,
@@ -4833,10 +5048,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4833
5048
  if (!payload.created_at) {
4834
5049
  payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
4835
5050
  }
4836
- _context33.next = 26;
5051
+ _context37.next = 26;
4837
5052
  return this.saveDraft();
4838
5053
  case 26:
4839
- _context33.prev = 26;
5054
+ _context37.prev = 26;
4840
5055
  this.logInfo('submitTempOrder calling sales checkout', {
4841
5056
  orderId: payload.order_id,
4842
5057
  externalSaleNumber: payload.external_sale_number,
@@ -4846,43 +5061,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4846
5061
  smallTicketDataFlag: payload.small_ticket_data_flag,
4847
5062
  syncMode: payload.sync_mode
4848
5063
  });
4849
- _context33.next = 30;
5064
+ _context37.next = 30;
4850
5065
  return this.submitSalesOrder({
4851
5066
  query: payload
4852
5067
  });
4853
5068
  case 30:
4854
- result = _context33.sent;
4855
- _context33.next = 43;
5069
+ result = _context37.sent;
5070
+ _context37.next = 43;
4856
5071
  break;
4857
5072
  case 33:
4858
- _context33.prev = 33;
4859
- _context33.t2 = _context33["catch"](26);
4860
- backendErrorResponse = this.extractSubmitErrorResponse(_context33.t2);
5073
+ _context37.prev = 33;
5074
+ _context37.t2 = _context37["catch"](26);
5075
+ backendErrorResponse = this.extractSubmitErrorResponse(_context37.t2);
4861
5076
  if (!backendErrorResponse) {
4862
- _context33.next = 40;
5077
+ _context37.next = 40;
4863
5078
  break;
4864
5079
  }
4865
5080
  this.store.syncState = 'failed';
4866
5081
  this.logSubmitBackendRejected(backendErrorResponse, payload);
4867
- return _context33.abrupt("return", backendErrorResponse);
5082
+ return _context37.abrupt("return", backendErrorResponse);
4868
5083
  case 40:
4869
5084
  this.store.syncState = 'failed';
4870
5085
  this.logError('submitTempOrder failed', {
4871
- error: _context33.t2 instanceof Error ? _context33.t2.message : String(_context33.t2),
5086
+ error: _context37.t2 instanceof Error ? _context37.t2.message : String(_context37.t2),
4872
5087
  orderId: payload.order_id,
4873
5088
  externalSaleNumber: payload.external_sale_number,
4874
5089
  paymentStatus: payload.payment_status,
4875
5090
  paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
4876
5091
  });
4877
- throw _context33.t2;
5092
+ throw _context37.t2;
4878
5093
  case 43:
4879
5094
  if (!this.isSubmitResponseRejected(result)) {
4880
- _context33.next = 47;
5095
+ _context37.next = 47;
4881
5096
  break;
4882
5097
  }
4883
5098
  this.store.syncState = 'failed';
4884
5099
  this.logSubmitBackendRejected(result, payload);
4885
- return _context33.abrupt("return", result);
5100
+ return _context37.abrupt("return", result);
4886
5101
  case 47:
4887
5102
  submittedOrderId = this.extractOrderIdFromSubmitResult(result);
4888
5103
  this.logInfo('runSubmitTempOrder: 提交成功', {
@@ -4893,15 +5108,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4893
5108
  })
4894
5109
  });
4895
5110
  if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
4896
- _context33.next = 56;
5111
+ _context37.next = 56;
4897
5112
  break;
4898
5113
  }
4899
5114
  tempOrder.order_id = submittedOrderId;
4900
5115
  resultRecord = result;
4901
- _context33.next = 54;
5116
+ _context37.next = 54;
4902
5117
  return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
4903
5118
  case 54:
4904
- _context33.next = 57;
5119
+ _context37.next = 57;
4905
5120
  break;
4906
5121
  case 56:
4907
5122
  if (this.isLocalPendingSubmitResult(result)) {
@@ -4910,14 +5125,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4910
5125
  this.store.syncState = 'submitted';
4911
5126
  }
4912
5127
  case 57:
4913
- return _context33.abrupt("return", result);
5128
+ return _context37.abrupt("return", result);
4914
5129
  case 58:
4915
5130
  case "end":
4916
- return _context33.stop();
5131
+ return _context37.stop();
4917
5132
  }
4918
- }, _callee30, this, [[26, 33]]);
5133
+ }, _callee34, this, [[26, 33]]);
4919
5134
  }));
4920
- function runSubmitTempOrder(_x34) {
5135
+ function runSubmitTempOrder(_x40) {
4921
5136
  return _runSubmitTempOrder.apply(this, arguments);
4922
5137
  }
4923
5138
  return runSubmitTempOrder;
@@ -4925,10 +5140,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4925
5140
  }, {
4926
5141
  key: "markLocalOrderSynced",
4927
5142
  value: function () {
4928
- var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(orderId, remoteOrder) {
5143
+ var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(orderId, remoteOrder) {
4929
5144
  var tempOrder;
4930
- return _regeneratorRuntime().wrap(function _callee31$(_context34) {
4931
- while (1) switch (_context34.prev = _context34.next) {
5145
+ return _regeneratorRuntime().wrap(function _callee35$(_context38) {
5146
+ while (1) switch (_context38.prev = _context38.next) {
4932
5147
  case 0:
4933
5148
  tempOrder = this.ensureTempOrder();
4934
5149
  tempOrder.order_id = orderId;
@@ -4936,15 +5151,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4936
5151
  this.store.lastOrderInfo = remoteOrder;
4937
5152
  this.store.syncState = 'submitted';
4938
5153
  this.persistTempOrder();
4939
- _context34.next = 8;
5154
+ _context38.next = 8;
4940
5155
  return this.saveDraft();
4941
5156
  case 8:
4942
5157
  case "end":
4943
- return _context34.stop();
5158
+ return _context38.stop();
4944
5159
  }
4945
- }, _callee31, this);
5160
+ }, _callee35, this);
4946
5161
  }));
4947
- function markLocalOrderSynced(_x35, _x36) {
5162
+ function markLocalOrderSynced(_x41, _x42) {
4948
5163
  return _markLocalOrderSynced.apply(this, arguments);
4949
5164
  }
4950
5165
  return markLocalOrderSynced;
@@ -4987,10 +5202,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4987
5202
  value: function extractSubmitErrorResponse(error) {
4988
5203
  var _error$response,
4989
5204
  _error$response2,
4990
- _this27 = this;
5205
+ _this30 = this;
4991
5206
  var candidates = [error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data, error === null || error === void 0 ? void 0 : error.data, error === null || error === void 0 || (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.body, error === null || error === void 0 ? void 0 : error.body];
4992
5207
  return candidates.find(function (candidate) {
4993
- return _this27.isSubmitErrorResponse(candidate);
5208
+ return _this30.isSubmitErrorResponse(candidate);
4994
5209
  }) || null;
4995
5210
  }
4996
5211
  }, {
@@ -5017,14 +5232,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5017
5232
  }, {
5018
5233
  key: "syncPaymentsToOrder",
5019
5234
  value: function () {
5020
- var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
5021
- var _params$confirmPendin;
5022
- var tempOrder, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, submitParams, submitResult;
5023
- return _regeneratorRuntime().wrap(function _callee32$(_context35) {
5024
- while (1) switch (_context35.prev = _context35.next) {
5235
+ var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
5236
+ var _this31 = this,
5237
+ _params$confirmPendin;
5238
+ var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, submitResult;
5239
+ return _regeneratorRuntime().wrap(function _callee36$(_context39) {
5240
+ while (1) switch (_context39.prev = _context39.next) {
5025
5241
  case 0:
5026
5242
  tempOrder = this.ensureTempOrder();
5027
- mappedPayments = mapPaymentItemsToOrderPayments(params.payments || []);
5243
+ needsPaymentNumber = (params.payments || []).some(function (payment) {
5244
+ return String(payment.payment_number || '').trim() === '';
5245
+ });
5246
+ if (!needsPaymentNumber) {
5247
+ _context39.next = 8;
5248
+ break;
5249
+ }
5250
+ _context39.next = 5;
5251
+ return this.getPaymentNumberDevicePrefixAsync();
5252
+ case 5:
5253
+ _context39.t0 = _context39.sent;
5254
+ _context39.next = 9;
5255
+ break;
5256
+ case 8:
5257
+ _context39.t0 = 'LOCAL';
5258
+ case 9:
5259
+ devicePrefix = _context39.t0;
5260
+ mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
5261
+ return _this31.normalizePaymentSource(payment, {
5262
+ defaultPaid: false,
5263
+ devicePrefix: devicePrefix
5264
+ });
5265
+ }));
5028
5266
  shouldConfirmPendingVoucherPayments = (_params$confirmPendin = params.confirmPendingVoucherPayments) !== null && _params$confirmPendin !== void 0 ? _params$confirmPendin : params.submitWhenPaid === true;
5029
5267
  effectivePayments = shouldConfirmPendingVoucherPayments ? this.confirmPendingVoucherPaymentsInList(mappedPayments) : params.confirmPendingVoucherPayments === false ? this.discardPendingVoucherPaymentsFromList(mappedPayments) : mappedPayments;
5030
5268
  completion = this.getPaymentCompletion(effectivePayments);
@@ -5033,24 +5271,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5033
5271
  tempOrder.payments = effectivePayments;
5034
5272
  tempOrder.payment_status = paymentStatus;
5035
5273
  this.persistTempOrder();
5036
- _context35.next = 12;
5274
+ _context39.next = 21;
5037
5275
  return this.saveDraft();
5038
- case 12:
5276
+ case 21:
5039
5277
  if (params.submitWhenPaid) {
5040
- _context35.next = 14;
5278
+ _context39.next = 23;
5041
5279
  break;
5042
5280
  }
5043
- return _context35.abrupt("return", completion);
5044
- case 14:
5281
+ return _context39.abrupt("return", completion);
5282
+ case 23:
5045
5283
  if (!(this.store.syncState === 'submitting')) {
5046
- _context35.next = 16;
5284
+ _context39.next = 25;
5047
5285
  break;
5048
5286
  }
5049
- return _context35.abrupt("return", completion);
5050
- case 16:
5287
+ return _context39.abrupt("return", completion);
5288
+ case 25:
5051
5289
  this.store.syncState = 'submitting';
5052
5290
  paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, effectivePayments);
5053
- submitParams = {
5291
+ _context39.next = 29;
5292
+ return this.submitTempOrder({
5054
5293
  payments: effectivePayments,
5055
5294
  paymentStatus: paymentStatus,
5056
5295
  smallTicketDataFlag: params.smallTicketDataFlag,
@@ -5063,34 +5302,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5063
5302
  });
5064
5303
  return nextPayload;
5065
5304
  }
5066
- };
5067
- if (!(params.checkoutSyncTaskEnabled === false)) {
5068
- _context35.next = 25;
5069
- break;
5070
- }
5071
- _context35.next = 22;
5072
- return this.submitTempOrderAsync(submitParams);
5073
- case 22:
5074
- _context35.t0 = _context35.sent;
5075
- _context35.next = 28;
5076
- break;
5077
- case 25:
5078
- _context35.next = 27;
5079
- return this.submitTempOrder(submitParams);
5080
- case 27:
5081
- _context35.t0 = _context35.sent;
5082
- case 28:
5083
- submitResult = _context35.t0;
5084
- return _context35.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
5305
+ });
5306
+ case 29:
5307
+ submitResult = _context39.sent;
5308
+ return _context39.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
5085
5309
  submitResult: submitResult
5086
5310
  }));
5087
- case 30:
5311
+ case 31:
5088
5312
  case "end":
5089
- return _context35.stop();
5313
+ return _context39.stop();
5090
5314
  }
5091
- }, _callee32, this);
5315
+ }, _callee36, this);
5092
5316
  }));
5093
- function syncPaymentsToOrder(_x37) {
5317
+ function syncPaymentsToOrder(_x43) {
5094
5318
  return _syncPaymentsToOrder.apply(this, arguments);
5095
5319
  }
5096
5320
  return syncPaymentsToOrder;
@@ -5098,7 +5322,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5098
5322
  }, {
5099
5323
  key: "createOrder",
5100
5324
  value: function createOrder(params) {
5101
- var _this28 = this;
5102
5325
  var order = _objectSpread({
5103
5326
  type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
5104
5327
  // 要从外面拿,virtual
@@ -5110,13 +5333,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5110
5333
  schedule_date: '',
5111
5334
  is_deposit: 0,
5112
5335
  relation_products: [],
5113
- relation_forms: [],
5114
- business_code: params === null || params === void 0 ? void 0 : params.business_code
5336
+ relation_forms: []
5115
5337
  }, (params === null || params === void 0 ? void 0 : params.extraData) || {});
5116
5338
  var is_deposit = 0; // 是否存在定金,0 不存在,1 存在
5117
5339
  if (params.cartItems.length > 0) {
5118
5340
  params.cartItems.forEach(function (item) {
5119
- var _params$extraData;
5120
5341
  if (!item._origin.duration) {
5121
5342
  var _generateDuration = generateDuration(item),
5122
5343
  duration = _generateDuration.duration,
@@ -5128,11 +5349,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5128
5349
  var discountList = getAllDiscountList(item);
5129
5350
  item._origin.product.discount_list = discountList;
5130
5351
 
5131
- // 为预约补齐 holder 信息
5132
- if (params !== null && params !== void 0 && (_params$extraData = params.extraData) !== null && _params$extraData !== void 0 && _params$extraData.is_add_holder_info) {
5133
- ensureCartItemOriginHolder(item, _this28.window);
5134
- }
5135
-
5136
5352
  // 购物车是否为普通商品
5137
5353
  if (isNormalProduct(item._origin)) {
5138
5354
  var _order$relation_forms;
@@ -5187,11 +5403,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5187
5403
  }, {
5188
5404
  key: "submitOrder",
5189
5405
  value: function () {
5190
- var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(order) {
5406
+ var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(order) {
5191
5407
  var _order$query$cartItem, _params$bookings, _params$relation_prod;
5192
5408
  var url, query, fetchUrl, params;
5193
- return _regeneratorRuntime().wrap(function _callee33$(_context36) {
5194
- while (1) switch (_context36.prev = _context36.next) {
5409
+ return _regeneratorRuntime().wrap(function _callee37$(_context40) {
5410
+ while (1) switch (_context40.prev = _context40.next) {
5195
5411
  case 0:
5196
5412
  this.logInfo('submitOrder called', {
5197
5413
  url: order.url,
@@ -5211,14 +5427,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5211
5427
  relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
5212
5428
  scheduleDate: params.schedule_date
5213
5429
  });
5214
- return _context36.abrupt("return", this.request.post(fetchUrl, params));
5430
+ return _context40.abrupt("return", this.request.post(fetchUrl, params));
5215
5431
  case 6:
5216
5432
  case "end":
5217
- return _context36.stop();
5433
+ return _context40.stop();
5218
5434
  }
5219
- }, _callee33, this);
5435
+ }, _callee37, this);
5220
5436
  }));
5221
- function submitOrder(_x38) {
5437
+ function submitOrder(_x44) {
5222
5438
  return _submitOrder.apply(this, arguments);
5223
5439
  }
5224
5440
  return submitOrder;
@@ -5226,13 +5442,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5226
5442
  }, {
5227
5443
  key: "cancelOrder",
5228
5444
  value: function () {
5229
- var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
5445
+ var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
5230
5446
  var payload;
5231
- return _regeneratorRuntime().wrap(function _callee34$(_context37) {
5232
- while (1) switch (_context37.prev = _context37.next) {
5447
+ return _regeneratorRuntime().wrap(function _callee38$(_context41) {
5448
+ while (1) switch (_context41.prev = _context41.next) {
5233
5449
  case 0:
5234
5450
  if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
5235
- _context37.next = 2;
5451
+ _context41.next = 2;
5236
5452
  break;
5237
5453
  }
5238
5454
  throw new Error('取消订单失败:order_ids 不能为空');
@@ -5248,16 +5464,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5248
5464
  method: 'PUT',
5249
5465
  orderIdsCount: params.order_ids.length
5250
5466
  });
5251
- return _context37.abrupt("return", this.request.put('/order/update-status', payload, {
5467
+ return _context41.abrupt("return", this.request.put('/order/update-status', payload, {
5252
5468
  isShopApi: true
5253
5469
  }));
5254
5470
  case 5:
5255
5471
  case "end":
5256
- return _context37.stop();
5472
+ return _context41.stop();
5257
5473
  }
5258
- }, _callee34, this);
5474
+ }, _callee38, this);
5259
5475
  }));
5260
- function cancelOrder(_x39) {
5476
+ function cancelOrder(_x45) {
5261
5477
  return _cancelOrder.apply(this, arguments);
5262
5478
  }
5263
5479
  return cancelOrder;
@@ -5265,19 +5481,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5265
5481
  }, {
5266
5482
  key: "changeBookingStatus",
5267
5483
  value: function () {
5268
- var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
5484
+ var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
5269
5485
  var url, payload;
5270
- return _regeneratorRuntime().wrap(function _callee35$(_context38) {
5271
- while (1) switch (_context38.prev = _context38.next) {
5486
+ return _regeneratorRuntime().wrap(function _callee39$(_context42) {
5487
+ while (1) switch (_context42.prev = _context42.next) {
5272
5488
  case 0:
5273
5489
  if (params.booking_id) {
5274
- _context38.next = 2;
5490
+ _context42.next = 2;
5275
5491
  break;
5276
5492
  }
5277
5493
  throw new Error('变更预约状态失败:booking_id 不能为空');
5278
5494
  case 2:
5279
5495
  if (params.appointment_status) {
5280
- _context38.next = 4;
5496
+ _context42.next = 4;
5281
5497
  break;
5282
5498
  }
5283
5499
  throw new Error('变更预约状态失败:appointment_status 不能为空');
@@ -5292,16 +5508,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5292
5508
  bookingId: params.booking_id,
5293
5509
  appointmentStatus: params.appointment_status
5294
5510
  });
5295
- return _context38.abrupt("return", this.request.put(url, payload, {
5511
+ return _context42.abrupt("return", this.request.put(url, payload, {
5296
5512
  isShopApi: true
5297
5513
  }));
5298
5514
  case 8:
5299
5515
  case "end":
5300
- return _context38.stop();
5516
+ return _context42.stop();
5301
5517
  }
5302
- }, _callee35, this);
5518
+ }, _callee39, this);
5303
5519
  }));
5304
- function changeBookingStatus(_x40) {
5520
+ function changeBookingStatus(_x46) {
5305
5521
  return _changeBookingStatus.apply(this, arguments);
5306
5522
  }
5307
5523
  return changeBookingStatus;
@@ -5319,11 +5535,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5319
5535
  }, {
5320
5536
  key: "createOrderByCheckout",
5321
5537
  value: (function () {
5322
- var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
5538
+ var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
5323
5539
  var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3, _params$bookings3, _params$relation_prod3, _params$payments4;
5324
5540
  var onlineStorePaymentCodeList, _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, _orderData$bookings2, _orderData$relation_p2, _orderData$payments4, _orderData$payments5, _response$data, orderData, response;
5325
- return _regeneratorRuntime().wrap(function _callee36$(_context39) {
5326
- while (1) switch (_context39.prev = _context39.next) {
5541
+ return _regeneratorRuntime().wrap(function _callee40$(_context43) {
5542
+ while (1) switch (_context43.prev = _context43.next) {
5327
5543
  case 0:
5328
5544
  // 过滤掉由在线店铺下单的 payment 支付数据
5329
5545
  onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
@@ -5357,7 +5573,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5357
5573
  relationProductsCount: ((_params$relation_prod3 = params.relation_products) === null || _params$relation_prod3 === void 0 ? void 0 : _params$relation_prod3.length) || 0,
5358
5574
  paymentsCount: ((_params$payments4 = params.payments) === null || _params$payments4 === void 0 ? void 0 : _params$payments4.length) || 0
5359
5575
  });
5360
- _context39.prev = 4;
5576
+ _context43.prev = 4;
5361
5577
  // 构建订单数据,设置默认值并允许 params 覆盖
5362
5578
  orderData = _objectSpread({
5363
5579
  sales_channel: 'my_pisel',
@@ -5419,13 +5635,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5419
5635
  hasOrderId: !!orderData.order_id,
5420
5636
  smallTicketDataFlag: orderData.small_ticket_data_flag
5421
5637
  });
5422
- _context39.next = 12;
5638
+ _context43.next = 12;
5423
5639
  return this.request.post('/order/checkout', orderData, {
5424
5640
  osServer: true,
5425
5641
  customToast: function customToast() {}
5426
5642
  });
5427
5643
  case 12:
5428
- response = _context39.sent;
5644
+ response = _context43.sent;
5429
5645
  this.logInfo('Order API called successfully', {
5430
5646
  response: response
5431
5647
  });
@@ -5433,22 +5649,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5433
5649
  success: !!response,
5434
5650
  hasOrderId: !!(response !== null && response !== void 0 && (_response$data = response.data) !== null && _response$data !== void 0 && _response$data.order_id || response !== null && response !== void 0 && response.order_id)
5435
5651
  });
5436
- return _context39.abrupt("return", response);
5652
+ return _context43.abrupt("return", response);
5437
5653
  case 18:
5438
- _context39.prev = 18;
5439
- _context39.t0 = _context39["catch"](4);
5440
- console.error('[Order] createOrderByCheckout 创建订单失败:', _context39.t0);
5654
+ _context43.prev = 18;
5655
+ _context43.t0 = _context43["catch"](4);
5656
+ console.error('[Order] createOrderByCheckout 创建订单失败:', _context43.t0);
5441
5657
  this.logInfo('Order API called failed', {
5442
- error: _context39.t0 instanceof Error ? _context39.t0.message : String(_context39.t0)
5658
+ error: _context43.t0 instanceof Error ? _context43.t0.message : String(_context43.t0)
5443
5659
  });
5444
- throw _context39.t0;
5660
+ throw _context43.t0;
5445
5661
  case 23:
5446
5662
  case "end":
5447
- return _context39.stop();
5663
+ return _context43.stop();
5448
5664
  }
5449
- }, _callee36, this, [[4, 18]]);
5665
+ }, _callee40, this, [[4, 18]]);
5450
5666
  }));
5451
- function createOrderByCheckout(_x41) {
5667
+ function createOrderByCheckout(_x47) {
5452
5668
  return _createOrderByCheckout.apply(this, arguments);
5453
5669
  }
5454
5670
  return createOrderByCheckout;
@@ -5456,24 +5672,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5456
5672
  }, {
5457
5673
  key: "submitSalesOrder",
5458
5674
  value: function () {
5459
- var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
5675
+ var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
5460
5676
  var url, query, fetchUrl;
5461
- return _regeneratorRuntime().wrap(function _callee37$(_context40) {
5462
- while (1) switch (_context40.prev = _context40.next) {
5677
+ return _regeneratorRuntime().wrap(function _callee41$(_context44) {
5678
+ while (1) switch (_context44.prev = _context44.next) {
5463
5679
  case 0:
5464
5680
  url = params.url, query = params.query;
5465
5681
  fetchUrl = url || '/order/sales/checkout';
5466
- return _context40.abrupt("return", this.request.post(fetchUrl, query, {
5682
+ return _context44.abrupt("return", this.request.post(fetchUrl, query, {
5467
5683
  osServer: true,
5468
5684
  customToast: function customToast() {}
5469
5685
  }));
5470
5686
  case 3:
5471
5687
  case "end":
5472
- return _context40.stop();
5688
+ return _context44.stop();
5473
5689
  }
5474
- }, _callee37, this);
5690
+ }, _callee41, this);
5475
5691
  }));
5476
- function submitSalesOrder(_x42) {
5692
+ function submitSalesOrder(_x48) {
5477
5693
  return _submitSalesOrder.apply(this, arguments);
5478
5694
  }
5479
5695
  return submitSalesOrder;
@@ -5487,37 +5703,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5487
5703
  }, {
5488
5704
  key: "sendCustomerPayLink",
5489
5705
  value: (function () {
5490
- var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
5706
+ var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
5491
5707
  var _params$emails;
5492
5708
  var orderIds;
5493
- return _regeneratorRuntime().wrap(function _callee38$(_context41) {
5494
- while (1) switch (_context41.prev = _context41.next) {
5709
+ return _regeneratorRuntime().wrap(function _callee42$(_context45) {
5710
+ while (1) switch (_context45.prev = _context45.next) {
5495
5711
  case 0:
5496
5712
  orderIds = params.order_ids || params.orderIds || [];
5497
5713
  if (orderIds.length) {
5498
- _context41.next = 3;
5714
+ _context45.next = 3;
5499
5715
  break;
5500
5716
  }
5501
5717
  throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
5502
5718
  case 3:
5503
5719
  if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
5504
- _context41.next = 5;
5720
+ _context45.next = 5;
5505
5721
  break;
5506
5722
  }
5507
5723
  throw new Error('发送支付链接需要至少一个邮箱');
5508
5724
  case 5:
5509
- return _context41.abrupt("return", this.request.post('/order/batch-email', {
5725
+ return _context45.abrupt("return", this.request.post('/order/batch-email', {
5510
5726
  order_ids: orderIds,
5511
5727
  notify_action: params.notify_action || 'order_payment_reminder',
5512
5728
  emails: params.emails
5513
5729
  }));
5514
5730
  case 6:
5515
5731
  case "end":
5516
- return _context41.stop();
5732
+ return _context45.stop();
5517
5733
  }
5518
- }, _callee38, this);
5734
+ }, _callee42, this);
5519
5735
  }));
5520
- function sendCustomerPayLink(_x43) {
5736
+ function sendCustomerPayLink(_x49) {
5521
5737
  return _sendCustomerPayLink.apply(this, arguments);
5522
5738
  }
5523
5739
  return sendCustomerPayLink;
@@ -5525,14 +5741,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5525
5741
  }, {
5526
5742
  key: "getSalesOrderByLookup",
5527
5743
  value: function () {
5528
- var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
5744
+ var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
5529
5745
  var lookup, res;
5530
- return _regeneratorRuntime().wrap(function _callee39$(_context42) {
5531
- while (1) switch (_context42.prev = _context42.next) {
5746
+ return _regeneratorRuntime().wrap(function _callee43$(_context46) {
5747
+ while (1) switch (_context46.prev = _context46.next) {
5532
5748
  case 0:
5533
5749
  lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
5534
5750
  if (lookup) {
5535
- _context42.next = 3;
5751
+ _context46.next = 3;
5536
5752
  break;
5537
5753
  }
5538
5754
  throw new Error('加载销售详情需要 lookup');
@@ -5541,7 +5757,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5541
5757
  if (lookup.startsWith('LOCAL_')) {
5542
5758
  params.forceRemote = false;
5543
5759
  }
5544
- _context42.next = 6;
5760
+ _context46.next = 6;
5545
5761
  return this.request.get("/order/sales/".concat(encodeURIComponent(lookup)), _objectSpread({
5546
5762
  with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info']
5547
5763
  }, params.forceRemote ? {
@@ -5550,18 +5766,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5550
5766
  osServer: true
5551
5767
  });
5552
5768
  case 6:
5553
- res = _context42.sent;
5769
+ res = _context46.sent;
5554
5770
  if (res.code === 200) {
5555
5771
  this.store.lastOrderInfo = res.data;
5556
5772
  }
5557
- return _context42.abrupt("return", res);
5773
+ return _context46.abrupt("return", res);
5558
5774
  case 9:
5559
5775
  case "end":
5560
- return _context42.stop();
5776
+ return _context46.stop();
5561
5777
  }
5562
- }, _callee39, this);
5778
+ }, _callee43, this);
5563
5779
  }));
5564
- function getSalesOrderByLookup(_x44) {
5780
+ function getSalesOrderByLookup(_x50) {
5565
5781
  return _getSalesOrderByLookup.apply(this, arguments);
5566
5782
  }
5567
5783
  return getSalesOrderByLookup;
@@ -5575,11 +5791,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5575
5791
  }, {
5576
5792
  key: "hydrateTempOrderFromRecord",
5577
5793
  value: (function () {
5578
- var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(record, options) {
5794
+ var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(record, options) {
5579
5795
  var _this$store$discount19;
5580
- var sourceRaw, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, nextTempOrder, rawSummary, summarySurcharges, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount20, _this$store$discount21;
5581
- return _regeneratorRuntime().wrap(function _callee40$(_context43) {
5582
- while (1) switch (_context43.prev = _context43.next) {
5796
+ var sourceRaw, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, nextTempOrder, sourceLastOrderInfo, isDraftOrder, syntheticIdentityOptions, rawSummary, summarySurcharges, hadSyntheticDraftOrderId, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount20, _this$store$discount21;
5797
+ return _regeneratorRuntime().wrap(function _callee44$(_context47) {
5798
+ while (1) switch (_context47.prev = _context47.next) {
5583
5799
  case 0:
5584
5800
  sourceRaw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
5585
5801
  identityReadySource = this.seedAnonymousBookingUidsFromProducts(sourceRaw);
@@ -5604,7 +5820,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5604
5820
  }
5605
5821
  nextTempOrder = this.normalizeTempOrderForRuntime(raw, {
5606
5822
  makeEditMark: true
5607
- });
5823
+ }); // Server list compatibility may synthesize order_id from external_sale_number; tempOrder must not.
5824
+ sourceLastOrderInfo = raw.lastOrderInfo || raw;
5825
+ isDraftOrder = Number(nextTempOrder.is_draft_order || 0) === 1;
5826
+ syntheticIdentityOptions = {
5827
+ isDraftOrder: isDraftOrder,
5828
+ externalSaleNumber: nextTempOrder.external_sale_number
5829
+ };
5608
5830
  rawSummary = raw.summary && _typeof(raw.summary) === 'object' ? raw.summary : {};
5609
5831
  summarySurcharges = Array.isArray(rawSummary.surcharges) ? rawSummary.surcharges.map(function (s) {
5610
5832
  return _objectSpread({}, s || {});
@@ -5624,10 +5846,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5624
5846
  productFingerprint: this.buildOrderProductsFingerprint(nextTempOrder.products || [])
5625
5847
  }
5626
5848
  });
5627
- // lastOrderInfo carries the exact backend snapshot used by deposit/type recovery.
5628
- // Runtime collection repair lives in tempOrder/originalSalesSnapshot and must not
5629
- // rewrite this protocol snapshot as a side effect of hydration.
5630
- this.store.lastOrderInfo = sourceRaw.lastOrderInfo || sourceRaw;
5849
+ this.store.lastOrderInfo = this.withoutSyntheticDraftOrderIdForRuntime(sourceLastOrderInfo, syntheticIdentityOptions);
5850
+ hadSyntheticDraftOrderId = this.isSyntheticDraftOrderIdForRuntime(raw, syntheticIdentityOptions) || this.isSyntheticDraftOrderIdForRuntime(sourceLastOrderInfo, syntheticIdentityOptions);
5851
+ if (hadSyntheticDraftOrderId && this.store.syncState !== 'submitting') {
5852
+ this.store.syncState = 'local';
5853
+ }
5631
5854
  hydratedEditDiscounts = this.collectHydratedEditDiscounts(nextTempOrder.products);
5632
5855
  currentDiscounts = typeof ((_this$store$discount19 = this.store.discount) === null || _this$store$discount19 === void 0 ? void 0 : _this$store$discount19.getDiscountList) === 'function' ? this.store.discount.getDiscountList() || [] : [];
5633
5856
  currentScanDiscounts = currentDiscounts.filter(function (discount) {
@@ -5642,34 +5865,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5642
5865
  nextDiscounts = [].concat(_toConsumableArray(hydratedEditDiscounts), _toConsumableArray(retainedScanDiscounts));
5643
5866
  shouldSkipEmptyDiscountSync = nextDiscounts.length === 0 && currentDiscounts.length === 0;
5644
5867
  if (shouldSkipEmptyDiscountSync) {
5645
- _context43.next = 26;
5868
+ _context47.next = 31;
5646
5869
  break;
5647
5870
  }
5648
5871
  OrderModule.populateSavedAmounts(nextTempOrder.products, nextDiscounts);
5649
- _context43.next = 24;
5872
+ _context47.next = 29;
5650
5873
  return (_this$store$discount20 = this.store.discount) === null || _this$store$discount20 === void 0 ? void 0 : _this$store$discount20.setOriginalDiscountList(nextDiscounts);
5651
- case 24:
5652
- _context43.next = 26;
5874
+ case 29:
5875
+ _context47.next = 31;
5653
5876
  return (_this$store$discount21 = this.store.discount) === null || _this$store$discount21 === void 0 ? void 0 : _this$store$discount21.setDiscountList(nextDiscounts);
5654
- case 26:
5877
+ case 31:
5655
5878
  if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
5656
- _context43.next = 29;
5879
+ _context47.next = 34;
5657
5880
  break;
5658
5881
  }
5659
- _context43.next = 29;
5882
+ _context47.next = 34;
5660
5883
  return this.recalculateSummary({
5661
5884
  createIfMissing: false
5662
5885
  });
5663
- case 29:
5886
+ case 34:
5664
5887
  this.persistTempOrder();
5665
- return _context43.abrupt("return", nextTempOrder);
5666
- case 31:
5888
+ return _context47.abrupt("return", nextTempOrder);
5889
+ case 36:
5667
5890
  case "end":
5668
- return _context43.stop();
5891
+ return _context47.stop();
5669
5892
  }
5670
- }, _callee40, this);
5893
+ }, _callee44, this);
5671
5894
  }));
5672
- function hydrateTempOrderFromRecord(_x45, _x46) {
5895
+ function hydrateTempOrderFromRecord(_x51, _x52) {
5673
5896
  return _hydrateTempOrderFromRecord.apply(this, arguments);
5674
5897
  }
5675
5898
  return hydrateTempOrderFromRecord;
@@ -5783,11 +6006,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5783
6006
  }, {
5784
6007
  key: "normalizeTempOrderForRuntime",
5785
6008
  value: function normalizeTempOrderForRuntime(raw, options) {
5786
- var _this29 = this;
5787
- var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), raw || {});
6009
+ var _this32 = this;
6010
+ var runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
6011
+ var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
5788
6012
  // ES 列表详情使用 id 表示订单主键;OS 详情态统一依赖 order_id 驱动操作按钮。
5789
- if ((nextTempOrder.order_id === undefined || nextTempOrder.order_id === null) && (raw === null || raw === void 0 ? void 0 : raw.id) !== undefined && (raw === null || raw === void 0 ? void 0 : raw.id) !== null) {
5790
- nextTempOrder.order_id = raw.id;
6013
+ if ((nextTempOrder.order_id === undefined || nextTempOrder.order_id === null) && (runtimeRaw === null || runtimeRaw === void 0 ? void 0 : runtimeRaw.id) !== undefined && (runtimeRaw === null || runtimeRaw === void 0 ? void 0 : runtimeRaw.id) !== null) {
6014
+ nextTempOrder.order_id = runtimeRaw.id;
5791
6015
  }
5792
6016
  delete nextTempOrder.summary;
5793
6017
  delete nextTempOrder.lastOrderInfo;
@@ -5806,12 +6030,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5806
6030
  nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
5807
6031
  var rawProducts = Array.isArray(raw.products) ? raw.products : [];
5808
6032
  nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
5809
- return _this29.normalizeHydratedOrderProduct(p, {
6033
+ return _this32.normalizeHydratedOrderProduct(p, {
5810
6034
  makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
5811
6035
  });
5812
6036
  }) : [];
5813
6037
  nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
5814
- var booking = _this29.normalizeHydratedBookingHolder(b || {});
6038
+ var booking = _this32.normalizeHydratedBookingHolder(b || {});
5815
6039
  return _objectSpread(_objectSpread({}, booking), {}, {
5816
6040
  is_all: normalizeBookingIsAll(booking),
5817
6041
  sub_type: normalizeBookingSubType(booking)
@@ -5877,6 +6101,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5877
6101
  nextTempOrder.vouchers = raw.vouchers || [];
5878
6102
  return nextTempOrder;
5879
6103
  }
6104
+ }, {
6105
+ key: "isSyntheticDraftOrderIdForRuntime",
6106
+ value: function isSyntheticDraftOrderIdForRuntime(record, options) {
6107
+ var _options$isDraftOrder, _record$external_sale;
6108
+ var isDraftOrder = (_options$isDraftOrder = options === null || options === void 0 ? void 0 : options.isDraftOrder) !== null && _options$isDraftOrder !== void 0 ? _options$isDraftOrder : Number((record === null || record === void 0 ? void 0 : record.is_draft_order) || 0) === 1;
6109
+ var externalSaleNumber = (_record$external_sale = record === null || record === void 0 ? void 0 : record.external_sale_number) !== null && _record$external_sale !== void 0 ? _record$external_sale : options === null || options === void 0 ? void 0 : options.externalSaleNumber;
6110
+ var orderId = record === null || record === void 0 ? void 0 : record.order_id;
6111
+ return Boolean(isDraftOrder && orderId !== undefined && orderId !== null && orderId !== '' && externalSaleNumber !== undefined && externalSaleNumber !== null && externalSaleNumber !== '' && String(orderId) === String(externalSaleNumber));
6112
+ }
6113
+ }, {
6114
+ key: "withoutSyntheticDraftOrderIdForRuntime",
6115
+ value: function withoutSyntheticDraftOrderIdForRuntime(record, options) {
6116
+ if (!this.isSyntheticDraftOrderIdForRuntime(record, options)) return record;
6117
+ return _objectSpread(_objectSpread({}, record), {}, {
6118
+ order_id: null
6119
+ });
6120
+ }
5880
6121
  }, {
5881
6122
  key: "hydrateLinkedBookingIdentity",
5882
6123
  value: function hydrateLinkedBookingIdentity(tempOrder) {
@@ -5981,7 +6222,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5981
6222
  }, {
5982
6223
  key: "normalizeHydratedOrderProduct",
5983
6224
  value: function normalizeHydratedOrderProduct(product, options) {
5984
- var _this30 = this;
6225
+ var _this33 = this;
5985
6226
  var row = _objectSpread({}, product || {});
5986
6227
  if (row.num === undefined && row.product_quantity !== undefined) {
5987
6228
  row.num = row.product_quantity;
@@ -5989,7 +6230,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5989
6230
  var productSku = ensureProductSku(row);
5990
6231
  row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
5991
6232
  option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
5992
- return _this30.normalizeHydratedProductOptionItem(optionItem || {});
6233
+ return _this33.normalizeHydratedProductOptionItem(optionItem || {});
5993
6234
  }))
5994
6235
  });
5995
6236
  delete row["product_".concat('option', "_item")];
@@ -6026,27 +6267,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6026
6267
  }, {
6027
6268
  key: "getOrderInfo",
6028
6269
  value: function () {
6029
- var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(order_id) {
6270
+ var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(order_id) {
6030
6271
  var res;
6031
- return _regeneratorRuntime().wrap(function _callee41$(_context44) {
6032
- while (1) switch (_context44.prev = _context44.next) {
6272
+ return _regeneratorRuntime().wrap(function _callee45$(_context48) {
6273
+ while (1) switch (_context48.prev = _context48.next) {
6033
6274
  case 0:
6034
- _context44.next = 2;
6275
+ _context48.next = 2;
6035
6276
  return this.request.get("/order/sales/".concat(order_id), {
6036
6277
  with: ['products', 'bookings']
6037
6278
  }, {
6038
6279
  osServer: true
6039
6280
  });
6040
6281
  case 2:
6041
- res = _context44.sent;
6042
- return _context44.abrupt("return", res);
6282
+ res = _context48.sent;
6283
+ return _context48.abrupt("return", res);
6043
6284
  case 4:
6044
6285
  case "end":
6045
- return _context44.stop();
6286
+ return _context48.stop();
6046
6287
  }
6047
- }, _callee41, this);
6288
+ }, _callee45, this);
6048
6289
  }));
6049
- function getOrderInfo(_x47) {
6290
+ function getOrderInfo(_x53) {
6050
6291
  return _getOrderInfo.apply(this, arguments);
6051
6292
  }
6052
6293
  return getOrderInfo;