@pisell/pisellos 2.3.124 → 2.3.126

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  2. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +0 -2
  3. package/dist/model/strategy/adapter/walletPass/evaluator.js +2 -4
  4. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +19 -58
  5. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +12 -24
  6. package/dist/modules/Customer/index.js +3 -6
  7. package/dist/modules/Customer/types.d.ts +0 -2
  8. package/dist/modules/Discount/index.d.ts +2 -2
  9. package/dist/modules/Discount/index.js +151 -37
  10. package/dist/modules/Discount/types.d.ts +5 -36
  11. package/dist/modules/Order/index.d.ts +12 -7
  12. package/dist/modules/Order/index.js +307 -432
  13. package/dist/modules/Order/types.d.ts +5 -0
  14. package/dist/modules/Order/utils/orderCollectionIdentity.js +12 -16
  15. package/dist/modules/Order/utils.d.ts +11 -1
  16. package/dist/modules/Order/utils.js +127 -122
  17. package/dist/modules/Payment/types.d.ts +1 -21
  18. package/dist/modules/Payment/types.js +0 -2
  19. package/dist/modules/Payment/walletpass.d.ts +1 -1
  20. package/dist/modules/Payment/walletpass.js +47 -80
  21. package/dist/modules/Rules/index.d.ts +2 -2
  22. package/dist/modules/Rules/index.js +186 -480
  23. package/dist/modules/Rules/types.d.ts +0 -4
  24. package/dist/server/modules/order/types.d.ts +0 -2
  25. package/dist/solution/BaseSales/index.d.ts +0 -1
  26. package/dist/solution/BaseSales/index.js +59 -51
  27. package/dist/solution/BaseSales/types.d.ts +2 -2
  28. package/dist/solution/BaseSales/utils/cartPromotion.js +126 -141
  29. package/dist/solution/BookingByStep/index.d.ts +1 -1
  30. package/dist/solution/BookingTicket/index.d.ts +2 -1
  31. package/dist/solution/BookingTicket/index.js +63 -60
  32. package/dist/solution/BookingTicket/types.d.ts +1 -5
  33. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -2
  34. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +147 -338
  35. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +4 -8
  36. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +0 -6
  37. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +6 -19
  38. package/dist/solution/ShopDiscount/index.d.ts +0 -2
  39. package/dist/solution/ShopDiscount/index.js +42 -99
  40. package/dist/solution/ShopDiscount/utils.d.ts +2 -4
  41. package/dist/solution/ShopDiscount/utils.js +23 -43
  42. package/dist/solution/UnifiedBookingSales/index.js +2 -2
  43. package/lib/model/strategy/adapter/promotion/index.js +1 -46
  44. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +0 -2
  45. package/lib/model/strategy/adapter/walletPass/evaluator.js +0 -2
  46. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +6 -35
  47. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +6 -13
  48. package/lib/modules/Customer/index.js +1 -5
  49. package/lib/modules/Customer/types.d.ts +0 -2
  50. package/lib/modules/Discount/index.d.ts +2 -2
  51. package/lib/modules/Discount/index.js +129 -23
  52. package/lib/modules/Discount/types.d.ts +5 -36
  53. package/lib/modules/Order/index.d.ts +12 -7
  54. package/lib/modules/Order/index.js +107 -215
  55. package/lib/modules/Order/types.d.ts +5 -0
  56. package/lib/modules/Order/utils/orderCollectionIdentity.js +11 -14
  57. package/lib/modules/Order/utils.d.ts +11 -1
  58. package/lib/modules/Order/utils.js +45 -39
  59. package/lib/modules/Payment/types.d.ts +1 -21
  60. package/lib/modules/Payment/types.js +0 -1
  61. package/lib/modules/Payment/walletpass.d.ts +1 -1
  62. package/lib/modules/Payment/walletpass.js +9 -29
  63. package/lib/modules/Rules/index.d.ts +2 -2
  64. package/lib/modules/Rules/index.js +110 -357
  65. package/lib/modules/Rules/types.d.ts +0 -4
  66. package/lib/server/modules/order/types.d.ts +0 -2
  67. package/lib/solution/BaseSales/index.d.ts +0 -1
  68. package/lib/solution/BaseSales/index.js +12 -5
  69. package/lib/solution/BaseSales/types.d.ts +2 -2
  70. package/lib/solution/BaseSales/utils/cartPromotion.js +4 -12
  71. package/lib/solution/BookingByStep/index.d.ts +1 -1
  72. package/lib/solution/BookingTicket/index.d.ts +2 -1
  73. package/lib/solution/BookingTicket/index.js +33 -36
  74. package/lib/solution/BookingTicket/types.d.ts +1 -5
  75. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -2
  76. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +42 -174
  77. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +4 -8
  78. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +0 -6
  79. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +3 -11
  80. package/lib/solution/ShopDiscount/index.d.ts +0 -2
  81. package/lib/solution/ShopDiscount/index.js +9 -55
  82. package/lib/solution/ShopDiscount/utils.d.ts +2 -4
  83. package/lib/solution/ShopDiscount/utils.js +25 -42
  84. package/lib/solution/UnifiedBookingSales/index.js +2 -2
  85. package/package.json +1 -1
  86. package/dist/modules/Discount/availability.d.ts +0 -7
  87. package/dist/modules/Discount/availability.js +0 -49
  88. package/dist/modules/Discount/entitlementPass.d.ts +0 -34
  89. package/dist/modules/Discount/entitlementPass.js +0 -147
  90. package/lib/modules/Discount/availability.d.ts +0 -7
  91. package/lib/modules/Discount/availability.js +0 -43
  92. package/lib/modules/Discount/entitlementPass.d.ts +0 -34
  93. package/lib/modules/Discount/entitlementPass.js +0 -141
@@ -11,24 +11,10 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
11
11
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
12
12
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
13
13
  import { buildRequiresDetailPayload } from "../addProductDecision";
14
+ import { isWalkInCustomer } from "../cartView";
14
15
  import { countScanVariantMatches, genScanProductValues, isScanProductBundle, isScanProductOption } from "./scanProductValues";
15
16
 
16
17
  /** applyGlobalScan 所需的 BookingTicket 运行时能力 */
17
-
18
- function getRealCustomerId(customer) {
19
- var _customer$id;
20
- var customerId = Number((_customer$id = customer === null || customer === void 0 ? void 0 : customer.id) !== null && _customer$id !== void 0 ? _customer$id : customer === null || customer === void 0 ? void 0 : customer.customer_id);
21
- return Number.isInteger(customerId) && customerId > 1 ? customerId : undefined;
22
- }
23
- function getWalletAssetCustomerId(asset) {
24
- var _asset$customer_id, _asset$holder;
25
- var customerId = Number((_asset$customer_id = asset === null || asset === void 0 ? void 0 : asset.customer_id) !== null && _asset$customer_id !== void 0 ? _asset$customer_id : asset === null || asset === void 0 || (_asset$holder = asset.holder) === null || _asset$holder === void 0 ? void 0 : _asset$holder.customer_id);
26
- return Number.isInteger(customerId) && customerId > 1 ? customerId : undefined;
27
- }
28
- function getErrorMessage(error) {
29
- return error instanceof Error ? error.message : String(error || '');
30
- }
31
-
32
18
  /**
33
19
  * 处理单条扫码商品的加车决策(含弹窗链)。
34
20
  */
@@ -205,477 +191,300 @@ export function applyGlobalScan(_x14, _x15, _x16) {
205
191
  return _applyGlobalScan.apply(this, arguments);
206
192
  }
207
193
  function _applyGlobalScan() {
208
- _applyGlobalScan = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(host, formatted, bridge) {
209
- var searchType, data, scanCode, formattedCustomerId, isCrossShopWallet, isWalletPassUnavailableAtStore, _getRealCustomerId, _bridge$onNotify5, currentCustomer, currentCustomerId, _customer, sourceCustomerId, _bridge$onNotify, _bridge$onNotify2, _customerId, _bridge$onNotify3, orderCustomer, switched, _bridge$onNotify4, _promotionResult$isAc, _bridge$onNotify6, snapshot, activeCustomer, bindWalletPassCustomer, trySelectWalletAsset, bindResult, walletSelection, promotionCustomerId, promotionResult, list, _bridge$onNotify12, addedCount, _iterator, _step, _item, outcome, _bridge$onNotify13, _data$order_id, _data$business_code, orderId, _bridge$onNotify14;
210
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
211
- while (1) switch (_context6.prev = _context6.next) {
194
+ _applyGlobalScan = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(host, formatted, bridge) {
195
+ var searchType, data, scanCode, _bridge$onNotify2, _bridge$onNotify, _host$refreshWalletAs, _bridge$onNotify5, snapshot, scannedCustomerIsWalkIn, trySelectWalletAsset, _result$isAccepted, _walletSelection, result, walletSelection, _data$id, _promotionResult$isAc, promotionResult, list, _bridge$onNotify6, addedCount, _iterator, _step, _item, outcome, _bridge$onNotify7, _data$order_id, _data$business_code, orderId, _bridge$onNotify8;
196
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
197
+ while (1) switch (_context5.prev = _context5.next) {
212
198
  case 0:
213
- searchType = formatted.searchType, data = formatted.data, scanCode = formatted.scanCode, formattedCustomerId = formatted.customerId, isCrossShopWallet = formatted.isCrossShopWallet, isWalletPassUnavailableAtStore = formatted.isWalletPassUnavailableAtStore;
199
+ searchType = formatted.searchType, data = formatted.data, scanCode = formatted.scanCode;
214
200
  if (!(searchType === 'wallet')) {
215
- _context6.next = 44;
216
- break;
217
- }
218
- currentCustomer = host.getOrderCustomerSnapshot();
219
- currentCustomerId = getRealCustomerId(currentCustomer);
220
- _customer = data;
221
- if (!isCrossShopWallet) {
222
- _context6.next = 20;
201
+ _context5.next = 8;
223
202
  break;
224
203
  }
225
- sourceCustomerId = getRealCustomerId({
226
- id: formattedCustomerId
227
- });
228
- if (!(sourceCustomerId === undefined || !host.resolveCustomerById)) {
229
- _context6.next = 10;
204
+ if (data) {
205
+ _context5.next = 5;
230
206
  break;
231
207
  }
232
208
  bridge === null || bridge === void 0 || (_bridge$onNotify = bridge.onNotify) === null || _bridge$onNotify === void 0 || _bridge$onNotify.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
233
- return _context6.abrupt("return", {
234
- status: 'failed',
235
- reason: 'invalid_data'
236
- });
237
- case 10:
238
- _context6.prev = 10;
239
- _context6.next = 13;
240
- return host.resolveCustomerById(sourceCustomerId);
241
- case 13:
242
- _customer = _context6.sent;
243
- _context6.next = 20;
244
- break;
245
- case 16:
246
- _context6.prev = 16;
247
- _context6.t0 = _context6["catch"](10);
248
- bridge === null || bridge === void 0 || (_bridge$onNotify2 = bridge.onNotify) === null || _bridge$onNotify2 === void 0 || _bridge$onNotify2.call(bridge, 'fail', getErrorMessage(_context6.t0) || 'pisell2.text.scan-global-failed');
249
- return _context6.abrupt("return", {
250
- status: 'failed',
251
- reason: 'invalid_data'
252
- });
253
- case 20:
254
- _customerId = (_getRealCustomerId = getRealCustomerId(_customer)) !== null && _getRealCustomerId !== void 0 ? _getRealCustomerId : !isCrossShopWallet ? getRealCustomerId({
255
- id: formattedCustomerId
256
- }) : undefined;
257
- if (!(!_customer || _customerId === undefined)) {
258
- _context6.next = 24;
259
- break;
260
- }
261
- bridge === null || bridge === void 0 || (_bridge$onNotify3 = bridge.onNotify) === null || _bridge$onNotify3 === void 0 || _bridge$onNotify3.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
262
- return _context6.abrupt("return", {
263
- status: 'failed',
264
- reason: 'invalid_data'
265
- });
266
- case 24:
267
- orderCustomer = _customer.id === undefined || _customer.id === null ? _objectSpread(_objectSpread({}, _customer), {}, {
268
- id: _customerId
269
- }) : _customer;
270
- if (!(currentCustomerId === _customerId)) {
271
- _context6.next = 27;
272
- break;
273
- }
274
- return _context6.abrupt("return", {
275
- status: 'success',
276
- kind: 'customer'
277
- });
278
- case 27:
279
- if (!(currentCustomerId !== undefined)) {
280
- _context6.next = 41;
281
- break;
282
- }
283
- if (bridge !== null && bridge !== void 0 && bridge.requestCustomerSwitch) {
284
- _context6.next = 30;
285
- break;
286
- }
287
- return _context6.abrupt("return", {
288
- status: 'success',
289
- kind: 'customer'
290
- });
291
- case 30:
292
- _context6.prev = 30;
293
- _context6.next = 33;
294
- return bridge.requestCustomerSwitch(orderCustomer);
295
- case 33:
296
- switched = _context6.sent;
297
- return _context6.abrupt("return", switched ? {
298
- status: 'success',
299
- kind: 'customer'
300
- } : {
301
- status: 'cancelled'
302
- });
303
- case 37:
304
- _context6.prev = 37;
305
- _context6.t1 = _context6["catch"](30);
306
- (_bridge$onNotify4 = bridge.onNotify) === null || _bridge$onNotify4 === void 0 || _bridge$onNotify4.call(bridge, 'fail', getErrorMessage(_context6.t1) || 'pisell2.text.scan-global-failed');
307
- return _context6.abrupt("return", {
209
+ return _context5.abrupt("return", {
308
210
  status: 'failed',
309
211
  reason: 'invalid_data'
310
212
  });
311
- case 41:
312
- host.setOrderCustomer(orderCustomer);
313
- bridge === null || bridge === void 0 || (_bridge$onNotify5 = bridge.onNotify) === null || _bridge$onNotify5 === void 0 || _bridge$onNotify5.call(bridge, 'success', 'pisell2.text.add-client-success');
314
- return _context6.abrupt("return", {
213
+ case 5:
214
+ host.setOrderCustomer(data);
215
+ bridge === null || bridge === void 0 || (_bridge$onNotify2 = bridge.onNotify) === null || _bridge$onNotify2 === void 0 || _bridge$onNotify2.call(bridge, 'success', 'pisell2.text.add-client-success');
216
+ return _context5.abrupt("return", {
315
217
  status: 'success',
316
218
  kind: 'customer'
317
219
  });
318
- case 44:
220
+ case 8:
319
221
  if (!(searchType === 'walletPass')) {
320
- _context6.next = 78;
321
- break;
322
- }
323
- if (!isWalletPassUnavailableAtStore) {
324
- _context6.next = 48;
222
+ _context5.next = 42;
325
223
  break;
326
224
  }
327
- bridge === null || bridge === void 0 || (_bridge$onNotify6 = bridge.onNotify) === null || _bridge$onNotify6 === void 0 || _bridge$onNotify6.call(bridge, 'fail', 'pisell2.text.wallet-pass-not-available-at-store');
328
- return _context6.abrupt("return", {
329
- status: 'failed',
330
- reason: 'invalid_data'
331
- });
332
- case 48:
333
225
  snapshot = host.getOrderCustomerSnapshot();
334
- activeCustomer = snapshot;
335
- bindWalletPassCustomer = /*#__PURE__*/function () {
336
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(asset) {
337
- var _getWalletAssetCustom, _host$refreshWalletAs;
338
- var assetCustomerId, customer, _bridge$onNotify7, _bridge$onNotify8, customerId, _bridge$onNotify9, orderCustomer;
226
+ scannedCustomerIsWalkIn = isWalkInCustomer(data);
227
+ trySelectWalletAsset = /*#__PURE__*/function () {
228
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
229
+ var _bridge$onNotify4;
230
+ var walletResult, _bridge$onNotify3;
339
231
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
340
232
  while (1) switch (_context4.prev = _context4.next) {
341
- case 0:
342
- if (!(getRealCustomerId(activeCustomer) !== undefined)) {
343
- _context4.next = 2;
344
- break;
345
- }
346
- return _context4.abrupt("return", {
347
- resolveFailed: false,
348
- customerBound: false
349
- });
350
- case 2:
351
- assetCustomerId = (_getWalletAssetCustom = getWalletAssetCustomerId(asset)) !== null && _getWalletAssetCustom !== void 0 ? _getWalletAssetCustom : getRealCustomerId({
352
- id: formattedCustomerId
353
- });
354
- customer = null;
355
- if (!(assetCustomerId !== undefined)) {
356
- _context4.next = 19;
357
- break;
358
- }
359
- if (host.resolveCustomerById) {
360
- _context4.next = 8;
361
- break;
362
- }
363
- bridge === null || bridge === void 0 || (_bridge$onNotify7 = bridge.onNotify) === null || _bridge$onNotify7 === void 0 || _bridge$onNotify7.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
364
- return _context4.abrupt("return", {
365
- resolveFailed: true,
366
- customerBound: false
367
- });
368
- case 8:
369
- _context4.prev = 8;
370
- _context4.next = 11;
371
- return host.resolveCustomerById(assetCustomerId);
372
- case 11:
373
- customer = _context4.sent;
374
- _context4.next = 19;
375
- break;
376
- case 14:
377
- _context4.prev = 14;
378
- _context4.t0 = _context4["catch"](8);
379
- console.warn('[GlobalScan] Wallet asset customer lookup failed', _context4.t0);
380
- bridge === null || bridge === void 0 || (_bridge$onNotify8 = bridge.onNotify) === null || _bridge$onNotify8 === void 0 || _bridge$onNotify8.call(bridge, 'fail', getErrorMessage(_context4.t0) || 'pisell2.text.scan-global-failed');
381
- return _context4.abrupt("return", {
382
- resolveFailed: true,
383
- customerBound: false
384
- });
385
- case 19:
386
- customerId = getRealCustomerId(customer);
387
- if (!(!customer || customerId === undefined)) {
388
- _context4.next = 23;
389
- break;
390
- }
391
- if (assetCustomerId !== undefined) {
392
- bridge === null || bridge === void 0 || (_bridge$onNotify9 = bridge.onNotify) === null || _bridge$onNotify9 === void 0 || _bridge$onNotify9.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
393
- }
394
- return _context4.abrupt("return", {
395
- resolveFailed: assetCustomerId !== undefined,
396
- customerBound: false
397
- });
398
- case 23:
399
- orderCustomer = customer.id === undefined || customer.id === null ? _objectSpread(_objectSpread({}, customer), {}, {
400
- id: customerId
401
- }) : customer;
402
- host.setOrderCustomer(orderCustomer);
403
- activeCustomer = orderCustomer;
404
- _context4.next = 28;
405
- return (_host$refreshWalletAs = host.refreshWalletAssets) === null || _host$refreshWalletAs === void 0 ? void 0 : _host$refreshWalletAs.call(host, {
406
- preserveSelection: false,
407
- retainSearchResultCodes: [scanCode]
408
- });
409
- case 28:
410
- return _context4.abrupt("return", {
411
- resolveFailed: false,
412
- customerBound: true
413
- });
414
- case 29:
415
- case "end":
416
- return _context4.stop();
417
- }
418
- }, _callee4, null, [[8, 14]]);
419
- }));
420
- return function bindWalletPassCustomer(_x17) {
421
- return _ref2.apply(this, arguments);
422
- };
423
- }();
424
- trySelectWalletAsset = /*#__PURE__*/function () {
425
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
426
- var walletResult, bindResult, _bridge$onNotify10, _bridge$onNotify11;
427
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
428
- while (1) switch (_context5.prev = _context5.next) {
429
233
  case 0:
430
234
  if (host.scanWalletAsset) {
431
- _context5.next = 2;
235
+ _context4.next = 2;
432
236
  break;
433
237
  }
434
- return _context5.abrupt("return", null);
238
+ return _context4.abrupt("return", null);
435
239
  case 2:
436
- _context5.next = 4;
240
+ _context4.next = 4;
437
241
  return host.scanWalletAsset(scanCode).catch(function (error) {
438
242
  console.warn('[GlobalScan] Wallet asset lookup failed', error);
439
243
  return null;
440
244
  });
441
245
  case 4:
442
- walletResult = _context5.sent;
246
+ walletResult = _context4.sent;
443
247
  if (walletResult) {
444
- _context5.next = 7;
248
+ _context4.next = 7;
445
249
  break;
446
250
  }
447
- return _context5.abrupt("return", null);
251
+ return _context4.abrupt("return", null);
448
252
  case 7:
449
253
  if (!(walletResult.type !== 'normalCode' || !walletResult.asset)) {
450
- _context5.next = 9;
254
+ _context4.next = 9;
451
255
  break;
452
256
  }
453
- return _context5.abrupt("return", null);
257
+ return _context4.abrupt("return", null);
454
258
  case 9:
455
- _context5.next = 11;
456
- return bindWalletPassCustomer(walletResult.asset);
457
- case 11:
458
- bindResult = _context5.sent;
459
259
  if (!walletResult.selected) {
460
- _context5.next = 15;
260
+ _context4.next = 12;
461
261
  break;
462
262
  }
463
- if (!bindResult.resolveFailed) {
464
- bridge === null || bridge === void 0 || (_bridge$onNotify10 = bridge.onNotify) === null || _bridge$onNotify10 === void 0 || _bridge$onNotify10.call(bridge, 'success');
465
- }
466
- return _context5.abrupt("return", {
263
+ bridge === null || bridge === void 0 || (_bridge$onNotify3 = bridge.onNotify) === null || _bridge$onNotify3 === void 0 || _bridge$onNotify3.call(bridge, 'success');
264
+ return _context4.abrupt("return", {
467
265
  status: 'success',
468
266
  kind: 'promotion'
469
267
  });
470
- case 15:
268
+ case 12:
471
269
  // 已识别为 Wallet 支付资产但当前不可用:保留禁用展示,不回退优惠码。
472
- if (!bindResult.resolveFailed) {
473
- bridge === null || bridge === void 0 || (_bridge$onNotify11 = bridge.onNotify) === null || _bridge$onNotify11 === void 0 || _bridge$onNotify11.call(bridge, 'fail', 'pisell2.text.goodpass.code-invalid-cart');
474
- }
475
- return _context5.abrupt("return", {
270
+ bridge === null || bridge === void 0 || (_bridge$onNotify4 = bridge.onNotify) === null || _bridge$onNotify4 === void 0 || _bridge$onNotify4.call(bridge, 'fail', 'pisell2.text.goodpass.code-invalid-cart');
271
+ return _context4.abrupt("return", {
476
272
  status: 'failed',
477
273
  reason: 'invalid_data'
478
274
  });
479
- case 17:
275
+ case 14:
480
276
  case "end":
481
- return _context5.stop();
277
+ return _context4.stop();
482
278
  }
483
- }, _callee5);
279
+ }, _callee4);
484
280
  }));
485
281
  return function trySelectWalletAsset() {
486
- return _ref3.apply(this, arguments);
282
+ return _ref2.apply(this, arguments);
487
283
  };
488
- }(); // batch-search 可能返回来源门店客户;先映射到当前门店,确保 Wallet
489
- // 支付资产查询使用本店客户上下文。
490
- _context6.next = 54;
491
- return bindWalletPassCustomer();
492
- case 54:
493
- bindResult = _context6.sent;
494
- _context6.next = 57;
284
+ }();
285
+ if (!(isWalkInCustomer(snapshot) || scannedCustomerIsWalkIn)) {
286
+ _context5.next = 26;
287
+ break;
288
+ }
289
+ _context5.next = 15;
495
290
  return trySelectWalletAsset();
496
- case 57:
497
- walletSelection = _context6.sent;
498
- if (!walletSelection) {
499
- _context6.next = 60;
291
+ case 15:
292
+ _walletSelection = _context5.sent;
293
+ if (!_walletSelection) {
294
+ _context5.next = 18;
500
295
  break;
501
296
  }
502
- return _context6.abrupt("return", walletSelection);
503
- case 60:
297
+ return _context5.abrupt("return", _walletSelection);
298
+ case 18:
504
299
  if (bridge !== null && bridge !== void 0 && bridge.applyPromotionCode) {
505
- _context6.next = 62;
300
+ _context5.next = 20;
506
301
  break;
507
302
  }
508
- return _context6.abrupt("return", {
303
+ return _context5.abrupt("return", {
509
304
  status: 'failed',
510
305
  reason: 'no_bridge'
511
306
  });
512
- case 62:
513
- promotionCustomerId = getRealCustomerId(activeCustomer);
514
- if (!bindResult.customerBound) {
515
- _context6.next = 69;
307
+ case 20:
308
+ _context5.next = 22;
309
+ return bridge.applyPromotionCode(scanCode);
310
+ case 22:
311
+ result = _context5.sent;
312
+ if (!((_result$isAccepted = result === null || result === void 0 ? void 0 : result.isAccepted) !== null && _result$isAccepted !== void 0 ? _result$isAccepted : result === null || result === void 0 ? void 0 : result.isAvailable)) {
313
+ _context5.next = 25;
516
314
  break;
517
315
  }
518
- _context6.next = 66;
519
- return bridge.applyPromotionCode(scanCode, promotionCustomerId, {
520
- suppressFailureNotification: true
316
+ return _context5.abrupt("return", {
317
+ status: 'success',
318
+ kind: 'promotion'
521
319
  });
522
- case 66:
523
- _context6.t2 = _context6.sent;
524
- _context6.next = 72;
525
- break;
526
- case 69:
527
- _context6.next = 71;
528
- return bridge.applyPromotionCode(scanCode, promotionCustomerId);
529
- case 71:
530
- _context6.t2 = _context6.sent;
531
- case 72:
532
- promotionResult = _context6.t2;
320
+ case 25:
321
+ return _context5.abrupt("return", {
322
+ status: 'failed',
323
+ reason: 'invalid_data'
324
+ });
325
+ case 26:
326
+ host.setOrderCustomer(data);
327
+ _context5.next = 29;
328
+ return (_host$refreshWalletAs = host.refreshWalletAssets) === null || _host$refreshWalletAs === void 0 ? void 0 : _host$refreshWalletAs.call(host, {
329
+ preserveSelection: false
330
+ });
331
+ case 29:
332
+ _context5.next = 31;
333
+ return trySelectWalletAsset();
334
+ case 31:
335
+ walletSelection = _context5.sent;
336
+ if (!walletSelection) {
337
+ _context5.next = 34;
338
+ break;
339
+ }
340
+ return _context5.abrupt("return", walletSelection);
341
+ case 34:
342
+ if (!(bridge !== null && bridge !== void 0 && bridge.applyPromotionCode)) {
343
+ _context5.next = 40;
344
+ break;
345
+ }
346
+ _context5.next = 37;
347
+ return bridge.applyPromotionCode(scanCode, Number((_data$id = data === null || data === void 0 ? void 0 : data.id) !== null && _data$id !== void 0 ? _data$id : data === null || data === void 0 ? void 0 : data.customer_id) || undefined);
348
+ case 37:
349
+ promotionResult = _context5.sent;
533
350
  if (!((_promotionResult$isAc = promotionResult === null || promotionResult === void 0 ? void 0 : promotionResult.isAccepted) !== null && _promotionResult$isAc !== void 0 ? _promotionResult$isAc : promotionResult === null || promotionResult === void 0 ? void 0 : promotionResult.isAvailable)) {
534
- _context6.next = 75;
351
+ _context5.next = 40;
535
352
  break;
536
353
  }
537
- return _context6.abrupt("return", {
354
+ return _context5.abrupt("return", {
538
355
  status: 'success',
539
356
  kind: 'promotion'
540
357
  });
541
- case 75:
542
- if (!bindResult.customerBound) {
543
- _context6.next = 77;
544
- break;
545
- }
546
- return _context6.abrupt("return", {
358
+ case 40:
359
+ bridge === null || bridge === void 0 || (_bridge$onNotify5 = bridge.onNotify) === null || _bridge$onNotify5 === void 0 || _bridge$onNotify5.call(bridge, 'success', 'pisell2.text.add-client-success');
360
+ return _context5.abrupt("return", {
547
361
  status: 'success',
548
362
  kind: 'customer'
549
363
  });
550
- case 77:
551
- return _context6.abrupt("return", {
552
- status: 'failed',
553
- reason: 'invalid_data'
554
- });
555
- case 78:
364
+ case 42:
556
365
  if (!(searchType === 'product' || searchType === 'local_product')) {
557
- _context6.next = 111;
366
+ _context5.next = 75;
558
367
  break;
559
368
  }
560
369
  list = data === null || data === void 0 ? void 0 : data.list;
561
370
  if (!(!Array.isArray(list) || list.length === 0)) {
562
- _context6.next = 83;
371
+ _context5.next = 47;
563
372
  break;
564
373
  }
565
- bridge === null || bridge === void 0 || (_bridge$onNotify12 = bridge.onNotify) === null || _bridge$onNotify12 === void 0 || _bridge$onNotify12.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
566
- return _context6.abrupt("return", {
374
+ bridge === null || bridge === void 0 || (_bridge$onNotify6 = bridge.onNotify) === null || _bridge$onNotify6 === void 0 || _bridge$onNotify6.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
375
+ return _context5.abrupt("return", {
567
376
  status: 'failed',
568
377
  reason: 'invalid_data'
569
378
  });
570
- case 83:
379
+ case 47:
571
380
  addedCount = 0;
572
381
  _iterator = _createForOfIteratorHelper(list);
573
- _context6.prev = 85;
382
+ _context5.prev = 49;
574
383
  _iterator.s();
575
- case 87:
384
+ case 51:
576
385
  if ((_step = _iterator.n()).done) {
577
- _context6.next = 99;
386
+ _context5.next = 63;
578
387
  break;
579
388
  }
580
389
  _item = _step.value;
581
- _context6.next = 91;
390
+ _context5.next = 55;
582
391
  return processScannedProductItem(host, _item, scanCode, bridge);
583
- case 91:
584
- outcome = _context6.sent;
392
+ case 55:
393
+ outcome = _context5.sent;
585
394
  if (outcome === 'added') {
586
395
  addedCount += 1;
587
396
  }
588
397
  if (!(outcome === 'cancelled')) {
589
- _context6.next = 95;
398
+ _context5.next = 59;
590
399
  break;
591
400
  }
592
- return _context6.abrupt("return", {
401
+ return _context5.abrupt("return", {
593
402
  status: 'cancelled'
594
403
  });
595
- case 95:
404
+ case 59:
596
405
  if (!(outcome === 'pending')) {
597
- _context6.next = 97;
406
+ _context5.next = 61;
598
407
  break;
599
408
  }
600
- return _context6.abrupt("return", {
409
+ return _context5.abrupt("return", {
601
410
  status: 'pending',
602
411
  kind: 'requiresDetail'
603
412
  });
604
- case 97:
605
- _context6.next = 87;
413
+ case 61:
414
+ _context5.next = 51;
606
415
  break;
607
- case 99:
608
- _context6.next = 104;
416
+ case 63:
417
+ _context5.next = 68;
609
418
  break;
610
- case 101:
611
- _context6.prev = 101;
612
- _context6.t3 = _context6["catch"](85);
613
- _iterator.e(_context6.t3);
614
- case 104:
615
- _context6.prev = 104;
419
+ case 65:
420
+ _context5.prev = 65;
421
+ _context5.t0 = _context5["catch"](49);
422
+ _iterator.e(_context5.t0);
423
+ case 68:
424
+ _context5.prev = 68;
616
425
  _iterator.f();
617
- return _context6.finish(104);
618
- case 107:
426
+ return _context5.finish(68);
427
+ case 71:
619
428
  if (!(addedCount > 0)) {
620
- _context6.next = 110;
429
+ _context5.next = 74;
621
430
  break;
622
431
  }
623
- bridge === null || bridge === void 0 || (_bridge$onNotify13 = bridge.onNotify) === null || _bridge$onNotify13 === void 0 || _bridge$onNotify13.call(bridge, 'success');
624
- return _context6.abrupt("return", {
432
+ bridge === null || bridge === void 0 || (_bridge$onNotify7 = bridge.onNotify) === null || _bridge$onNotify7 === void 0 || _bridge$onNotify7.call(bridge, 'success');
433
+ return _context5.abrupt("return", {
625
434
  status: 'success',
626
435
  kind: 'products',
627
436
  meta: {
628
437
  count: addedCount
629
438
  }
630
439
  });
631
- case 110:
632
- return _context6.abrupt("return", {
440
+ case 74:
441
+ return _context5.abrupt("return", {
633
442
  status: 'failed',
634
443
  reason: 'no_bridge'
635
444
  });
636
- case 111:
445
+ case 75:
637
446
  if (!(searchType === 'order')) {
638
- _context6.next = 120;
447
+ _context5.next = 84;
639
448
  break;
640
449
  }
641
450
  orderId = (_data$order_id = data === null || data === void 0 ? void 0 : data.order_id) !== null && _data$order_id !== void 0 ? _data$order_id : data === null || data === void 0 ? void 0 : data.id;
642
451
  if (orderId) {
643
- _context6.next = 116;
452
+ _context5.next = 80;
644
453
  break;
645
454
  }
646
- bridge === null || bridge === void 0 || (_bridge$onNotify14 = bridge.onNotify) === null || _bridge$onNotify14 === void 0 || _bridge$onNotify14.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
647
- return _context6.abrupt("return", {
455
+ bridge === null || bridge === void 0 || (_bridge$onNotify8 = bridge.onNotify) === null || _bridge$onNotify8 === void 0 || _bridge$onNotify8.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
456
+ return _context5.abrupt("return", {
648
457
  status: 'failed',
649
458
  reason: 'invalid_data'
650
459
  });
651
- case 116:
460
+ case 80:
652
461
  if (bridge !== null && bridge !== void 0 && bridge.openOrder) {
653
- _context6.next = 118;
462
+ _context5.next = 82;
654
463
  break;
655
464
  }
656
- return _context6.abrupt("return", {
465
+ return _context5.abrupt("return", {
657
466
  status: 'pending',
658
467
  kind: 'openOrder'
659
468
  });
660
- case 118:
469
+ case 82:
661
470
  bridge.openOrder({
662
471
  order_id: Number(orderId),
663
472
  business_code: (_data$business_code = data === null || data === void 0 ? void 0 : data.business_code) !== null && _data$business_code !== void 0 ? _data$business_code : host.getBusinessCode()
664
473
  });
665
- return _context6.abrupt("return", {
474
+ return _context5.abrupt("return", {
666
475
  status: 'pending',
667
476
  kind: 'openOrder'
668
477
  });
669
- case 120:
670
- return _context6.abrupt("return", {
478
+ case 84:
479
+ return _context5.abrupt("return", {
671
480
  status: 'failed',
672
481
  reason: 'invalid_data'
673
482
  });
674
- case 121:
483
+ case 85:
675
484
  case "end":
676
- return _context6.stop();
485
+ return _context5.stop();
677
486
  }
678
- }, _callee6, null, [[10, 16], [30, 37], [85, 101, 104, 107]]);
487
+ }, _callee5, null, [[49, 65, 68, 71]]);
679
488
  }));
680
489
  return _applyGlobalScan.apply(this, arguments);
681
490
  }