@pisell/pisellos 2.3.37 → 2.3.38

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 (90) 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/type.d.ts +90 -2
  11. package/dist/model/strategy/adapter/promotion/type.js +45 -0
  12. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -3
  13. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +6 -3
  14. package/dist/modules/OpenData/index.d.ts +2 -0
  15. package/dist/modules/OpenData/index.js +8 -0
  16. package/dist/modules/Order/index.js +21 -14
  17. package/dist/modules/Order/utils.js +2 -1
  18. package/dist/modules/Payment/index.js +1 -1
  19. package/dist/modules/Payment/types.d.ts +73 -4
  20. package/dist/modules/Payment/types.js +18 -3
  21. package/dist/modules/Payment/walletpass.d.ts +25 -1
  22. package/dist/modules/Payment/walletpass.js +707 -157
  23. package/dist/modules/Rules/index.d.ts +1 -0
  24. package/dist/modules/Rules/index.js +75 -49
  25. package/dist/server/index.js +19 -18
  26. package/dist/server/modules/order/index.d.ts +5 -0
  27. package/dist/server/modules/order/index.js +52 -31
  28. package/dist/solution/BaseSales/index.d.ts +77 -11
  29. package/dist/solution/BaseSales/index.js +1322 -297
  30. package/dist/solution/BaseSales/types.d.ts +52 -0
  31. package/dist/solution/BaseSales/types.js +2 -1
  32. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
  33. package/dist/solution/BaseSales/utils/cartPromotion.js +90 -31
  34. package/dist/solution/BookingByStep/index.d.ts +1 -1
  35. package/dist/solution/BookingTicket/index.d.ts +7 -3
  36. package/dist/solution/BookingTicket/index.js +130 -48
  37. package/dist/solution/BookingTicket/utils/addProductDecision.js +6 -0
  38. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
  39. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +172 -82
  40. package/dist/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
  41. package/dist/solution/BookingTicket/utils/weighingProductSku.js +45 -0
  42. package/dist/solution/ScanOrder/index.js +31 -20
  43. package/dist/solution/VenueBooking/index.js +30 -19
  44. package/dist/types/index.d.ts +1 -0
  45. package/lib/core/index.d.ts +2 -0
  46. package/lib/core/index.js +4 -0
  47. package/lib/model/strategy/adapter/promotion/adapter.d.ts +4 -0
  48. package/lib/model/strategy/adapter/promotion/adapter.js +20 -0
  49. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
  50. package/lib/model/strategy/adapter/promotion/evaluator.js +235 -0
  51. package/lib/model/strategy/adapter/promotion/examples.d.ts +86 -0
  52. package/lib/model/strategy/adapter/promotion/examples.js +91 -0
  53. package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
  54. package/lib/model/strategy/adapter/promotion/index.js +51 -0
  55. package/lib/model/strategy/adapter/promotion/type.d.ts +90 -2
  56. package/lib/model/strategy/adapter/promotion/type.js +2 -0
  57. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +2 -1
  58. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
  59. package/lib/modules/OpenData/index.d.ts +2 -0
  60. package/lib/modules/OpenData/index.js +5 -0
  61. package/lib/modules/Order/index.js +10 -4
  62. package/lib/modules/Order/utils.js +6 -1
  63. package/lib/modules/Payment/index.js +1 -1
  64. package/lib/modules/Payment/types.d.ts +73 -4
  65. package/lib/modules/Payment/types.js +4 -3
  66. package/lib/modules/Payment/walletpass.d.ts +25 -1
  67. package/lib/modules/Payment/walletpass.js +470 -21
  68. package/lib/modules/Rules/index.d.ts +1 -0
  69. package/lib/modules/Rules/index.js +30 -7
  70. package/lib/server/index.js +5 -3
  71. package/lib/server/modules/order/index.d.ts +5 -0
  72. package/lib/server/modules/order/index.js +24 -2
  73. package/lib/solution/BaseSales/index.d.ts +77 -11
  74. package/lib/solution/BaseSales/index.js +682 -39
  75. package/lib/solution/BaseSales/types.d.ts +52 -0
  76. package/lib/solution/BaseSales/types.js +2 -1
  77. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
  78. package/lib/solution/BaseSales/utils/cartPromotion.js +63 -12
  79. package/lib/solution/BookingByStep/index.d.ts +1 -1
  80. package/lib/solution/BookingTicket/index.d.ts +7 -3
  81. package/lib/solution/BookingTicket/index.js +60 -8
  82. package/lib/solution/BookingTicket/utils/addProductDecision.js +4 -0
  83. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
  84. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +36 -4
  85. package/lib/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
  86. package/lib/solution/BookingTicket/utils/weighingProductSku.js +63 -0
  87. package/lib/solution/ScanOrder/index.js +8 -0
  88. package/lib/solution/VenueBooking/index.js +8 -0
  89. package/lib/types/index.d.ts +1 -0
  90. package/package.json +2 -2
@@ -191,210 +191,300 @@ export function applyGlobalScan(_x14, _x15, _x16) {
191
191
  return _applyGlobalScan.apply(this, arguments);
192
192
  }
193
193
  function _applyGlobalScan() {
194
- _applyGlobalScan = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(host, formatted, bridge) {
195
- var searchType, data, scanCode, _bridge$onNotify2, _bridge$onNotify, _bridge$onNotify4, _bridge$onNotify3, snapshot, scannedCustomerIsWalkIn, result, list, _bridge$onNotify5, addedCount, _iterator, _step, _item, outcome, _bridge$onNotify6, _data$order_id, _data$business_code, orderId, _bridge$onNotify7;
196
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
197
- while (1) switch (_context4.prev = _context4.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, _walletSelection, result, walletSelection, _data$id, 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) {
198
198
  case 0:
199
199
  searchType = formatted.searchType, data = formatted.data, scanCode = formatted.scanCode;
200
200
  if (!(searchType === 'wallet')) {
201
- _context4.next = 8;
201
+ _context5.next = 8;
202
202
  break;
203
203
  }
204
204
  if (data) {
205
- _context4.next = 5;
205
+ _context5.next = 5;
206
206
  break;
207
207
  }
208
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');
209
- return _context4.abrupt("return", {
209
+ return _context5.abrupt("return", {
210
210
  status: 'failed',
211
211
  reason: 'invalid_data'
212
212
  });
213
213
  case 5:
214
214
  host.setOrderCustomer(data);
215
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 _context4.abrupt("return", {
216
+ return _context5.abrupt("return", {
217
217
  status: 'success',
218
218
  kind: 'customer'
219
219
  });
220
220
  case 8:
221
221
  if (!(searchType === 'walletPass')) {
222
- _context4.next = 26;
222
+ _context5.next = 42;
223
223
  break;
224
224
  }
225
- if (data) {
226
- _context4.next = 12;
227
- break;
228
- }
229
- bridge === null || bridge === void 0 || (_bridge$onNotify3 = bridge.onNotify) === null || _bridge$onNotify3 === void 0 || _bridge$onNotify3.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
230
- return _context4.abrupt("return", {
231
- status: 'failed',
232
- reason: 'invalid_data'
233
- });
234
- case 12:
235
225
  snapshot = host.getOrderCustomerSnapshot();
236
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;
231
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
232
+ while (1) switch (_context4.prev = _context4.next) {
233
+ case 0:
234
+ if (host.scanWalletAsset) {
235
+ _context4.next = 2;
236
+ break;
237
+ }
238
+ return _context4.abrupt("return", null);
239
+ case 2:
240
+ _context4.next = 4;
241
+ return host.scanWalletAsset(scanCode).catch(function (error) {
242
+ console.warn('[GlobalScan] Wallet asset lookup failed', error);
243
+ return null;
244
+ });
245
+ case 4:
246
+ walletResult = _context4.sent;
247
+ if (walletResult) {
248
+ _context4.next = 7;
249
+ break;
250
+ }
251
+ return _context4.abrupt("return", null);
252
+ case 7:
253
+ if (!(walletResult.type !== 'normalCode' || !walletResult.asset)) {
254
+ _context4.next = 9;
255
+ break;
256
+ }
257
+ return _context4.abrupt("return", null);
258
+ case 9:
259
+ if (!walletResult.selected) {
260
+ _context4.next = 12;
261
+ break;
262
+ }
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", {
265
+ status: 'success',
266
+ kind: 'promotion'
267
+ });
268
+ case 12:
269
+ // 已识别为 Wallet 支付资产但当前不可用:保留禁用展示,不回退优惠码。
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", {
272
+ status: 'failed',
273
+ reason: 'invalid_data'
274
+ });
275
+ case 14:
276
+ case "end":
277
+ return _context4.stop();
278
+ }
279
+ }, _callee4);
280
+ }));
281
+ return function trySelectWalletAsset() {
282
+ return _ref2.apply(this, arguments);
283
+ };
284
+ }();
237
285
  if (!(isWalkInCustomer(snapshot) || scannedCustomerIsWalkIn)) {
238
- _context4.next = 23;
286
+ _context5.next = 26;
287
+ break;
288
+ }
289
+ _context5.next = 15;
290
+ return trySelectWalletAsset();
291
+ case 15:
292
+ _walletSelection = _context5.sent;
293
+ if (!_walletSelection) {
294
+ _context5.next = 18;
239
295
  break;
240
296
  }
297
+ return _context5.abrupt("return", _walletSelection);
298
+ case 18:
241
299
  if (bridge !== null && bridge !== void 0 && bridge.applyPromotionCode) {
242
- _context4.next = 17;
300
+ _context5.next = 20;
243
301
  break;
244
302
  }
245
- return _context4.abrupt("return", {
303
+ return _context5.abrupt("return", {
246
304
  status: 'failed',
247
305
  reason: 'no_bridge'
248
306
  });
249
- case 17:
250
- _context4.next = 19;
307
+ case 20:
308
+ _context5.next = 22;
251
309
  return bridge.applyPromotionCode(scanCode);
252
- case 19:
253
- result = _context4.sent;
310
+ case 22:
311
+ result = _context5.sent;
254
312
  if (!(result !== null && result !== void 0 && result.isAvailable)) {
255
- _context4.next = 22;
313
+ _context5.next = 25;
256
314
  break;
257
315
  }
258
- return _context4.abrupt("return", {
316
+ return _context5.abrupt("return", {
259
317
  status: 'success',
260
318
  kind: 'promotion'
261
319
  });
262
- case 22:
263
- return _context4.abrupt("return", {
320
+ case 25:
321
+ return _context5.abrupt("return", {
264
322
  status: 'failed',
265
323
  reason: 'invalid_data'
266
324
  });
267
- case 23:
325
+ case 26:
268
326
  host.setOrderCustomer(data);
269
- bridge === null || bridge === void 0 || (_bridge$onNotify4 = bridge.onNotify) === null || _bridge$onNotify4 === void 0 || _bridge$onNotify4.call(bridge, 'success', 'pisell2.text.add-client-success');
270
- return _context4.abrupt("return", {
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;
350
+ if (!(promotionResult !== null && promotionResult !== void 0 && promotionResult.isAvailable)) {
351
+ _context5.next = 40;
352
+ break;
353
+ }
354
+ return _context5.abrupt("return", {
355
+ status: 'success',
356
+ kind: 'promotion'
357
+ });
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", {
271
361
  status: 'success',
272
362
  kind: 'customer'
273
363
  });
274
- case 26:
364
+ case 42:
275
365
  if (!(searchType === 'product' || searchType === 'local_product')) {
276
- _context4.next = 59;
366
+ _context5.next = 75;
277
367
  break;
278
368
  }
279
369
  list = data === null || data === void 0 ? void 0 : data.list;
280
370
  if (!(!Array.isArray(list) || list.length === 0)) {
281
- _context4.next = 31;
371
+ _context5.next = 47;
282
372
  break;
283
373
  }
284
- bridge === null || bridge === void 0 || (_bridge$onNotify5 = bridge.onNotify) === null || _bridge$onNotify5 === void 0 || _bridge$onNotify5.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
285
- return _context4.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", {
286
376
  status: 'failed',
287
377
  reason: 'invalid_data'
288
378
  });
289
- case 31:
379
+ case 47:
290
380
  addedCount = 0;
291
381
  _iterator = _createForOfIteratorHelper(list);
292
- _context4.prev = 33;
382
+ _context5.prev = 49;
293
383
  _iterator.s();
294
- case 35:
384
+ case 51:
295
385
  if ((_step = _iterator.n()).done) {
296
- _context4.next = 47;
386
+ _context5.next = 63;
297
387
  break;
298
388
  }
299
389
  _item = _step.value;
300
- _context4.next = 39;
390
+ _context5.next = 55;
301
391
  return processScannedProductItem(host, _item, scanCode, bridge);
302
- case 39:
303
- outcome = _context4.sent;
392
+ case 55:
393
+ outcome = _context5.sent;
304
394
  if (outcome === 'added') {
305
395
  addedCount += 1;
306
396
  }
307
397
  if (!(outcome === 'cancelled')) {
308
- _context4.next = 43;
398
+ _context5.next = 59;
309
399
  break;
310
400
  }
311
- return _context4.abrupt("return", {
401
+ return _context5.abrupt("return", {
312
402
  status: 'cancelled'
313
403
  });
314
- case 43:
404
+ case 59:
315
405
  if (!(outcome === 'pending')) {
316
- _context4.next = 45;
406
+ _context5.next = 61;
317
407
  break;
318
408
  }
319
- return _context4.abrupt("return", {
409
+ return _context5.abrupt("return", {
320
410
  status: 'pending',
321
411
  kind: 'requiresDetail'
322
412
  });
323
- case 45:
324
- _context4.next = 35;
413
+ case 61:
414
+ _context5.next = 51;
325
415
  break;
326
- case 47:
327
- _context4.next = 52;
416
+ case 63:
417
+ _context5.next = 68;
328
418
  break;
329
- case 49:
330
- _context4.prev = 49;
331
- _context4.t0 = _context4["catch"](33);
332
- _iterator.e(_context4.t0);
333
- case 52:
334
- _context4.prev = 52;
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;
335
425
  _iterator.f();
336
- return _context4.finish(52);
337
- case 55:
426
+ return _context5.finish(68);
427
+ case 71:
338
428
  if (!(addedCount > 0)) {
339
- _context4.next = 58;
429
+ _context5.next = 74;
340
430
  break;
341
431
  }
342
- bridge === null || bridge === void 0 || (_bridge$onNotify6 = bridge.onNotify) === null || _bridge$onNotify6 === void 0 || _bridge$onNotify6.call(bridge, 'success');
343
- return _context4.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", {
344
434
  status: 'success',
345
435
  kind: 'products',
346
436
  meta: {
347
437
  count: addedCount
348
438
  }
349
439
  });
350
- case 58:
351
- return _context4.abrupt("return", {
440
+ case 74:
441
+ return _context5.abrupt("return", {
352
442
  status: 'failed',
353
443
  reason: 'no_bridge'
354
444
  });
355
- case 59:
445
+ case 75:
356
446
  if (!(searchType === 'order')) {
357
- _context4.next = 68;
447
+ _context5.next = 84;
358
448
  break;
359
449
  }
360
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;
361
451
  if (orderId) {
362
- _context4.next = 64;
452
+ _context5.next = 80;
363
453
  break;
364
454
  }
365
- bridge === null || bridge === void 0 || (_bridge$onNotify7 = bridge.onNotify) === null || _bridge$onNotify7 === void 0 || _bridge$onNotify7.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
366
- return _context4.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", {
367
457
  status: 'failed',
368
458
  reason: 'invalid_data'
369
459
  });
370
- case 64:
460
+ case 80:
371
461
  if (bridge !== null && bridge !== void 0 && bridge.openOrder) {
372
- _context4.next = 66;
462
+ _context5.next = 82;
373
463
  break;
374
464
  }
375
- return _context4.abrupt("return", {
465
+ return _context5.abrupt("return", {
376
466
  status: 'pending',
377
467
  kind: 'openOrder'
378
468
  });
379
- case 66:
469
+ case 82:
380
470
  bridge.openOrder({
381
471
  order_id: Number(orderId),
382
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()
383
473
  });
384
- return _context4.abrupt("return", {
474
+ return _context5.abrupt("return", {
385
475
  status: 'pending',
386
476
  kind: 'openOrder'
387
477
  });
388
- case 68:
389
- return _context4.abrupt("return", {
478
+ case 84:
479
+ return _context5.abrupt("return", {
390
480
  status: 'failed',
391
481
  reason: 'invalid_data'
392
482
  });
393
- case 69:
483
+ case 85:
394
484
  case "end":
395
- return _context4.stop();
485
+ return _context5.stop();
396
486
  }
397
- }, _callee4, null, [[33, 49, 52, 55]]);
487
+ }, _callee5, null, [[49, 65, 68, 71]]);
398
488
  }));
399
489
  return _applyGlobalScan.apply(this, arguments);
400
490
  }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * 将规格弹窗的称重结果写入订单行权威字段 product_sku。
3
+ * 商品目录已有的 SKU 字段会保留,本次称重结果只覆盖运行态称重字段。
4
+ */
5
+ export declare function buildProductSkuFromCacheItem(cacheItem: Record<string, any> | null | undefined): Record<string, any> | undefined;
@@ -0,0 +1,45 @@
1
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
5
+ 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); }
6
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
7
+ var WEIGHT_UNIT_MAP = {
8
+ KILOGRAMS: 'kg',
9
+ GRAMS: 'g',
10
+ POUNDS: 'lb',
11
+ OUNCES: 'oz'
12
+ };
13
+ function isRecord(value) {
14
+ return Boolean(value) && _typeof(value) === 'object' && !Array.isArray(value);
15
+ }
16
+
17
+ /**
18
+ * 将规格弹窗的称重结果写入订单行权威字段 product_sku。
19
+ * 商品目录已有的 SKU 字段会保留,本次称重结果只覆盖运行态称重字段。
20
+ */
21
+ export function buildProductSkuFromCacheItem(cacheItem) {
22
+ var _cacheItem$_extend, _cacheItem$_extend2, _weighing$unit_weight, _weighing$tare$label, _weighing$tare, _weighing$tare$value, _weighing$tare2, _weighing$weight, _weighing$net_weight;
23
+ var currentSku = isRecord(cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.product_sku) ? cacheItem.product_sku : undefined;
24
+ var weighing = isRecord(cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend = cacheItem._extend) === null || _cacheItem$_extend === void 0 ? void 0 : _cacheItem$_extend.weighing) ? cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend2 = cacheItem._extend) === null || _cacheItem$_extend2 === void 0 ? void 0 : _cacheItem$_extend2.weighing : undefined;
25
+ var hasRuntimeWeighingSku = Number((currentSku === null || currentSku === void 0 ? void 0 : currentSku.open_sold_weight) || 0) === 1 && ((currentSku === null || currentSku === void 0 ? void 0 : currentSku.weight) !== undefined || (currentSku === null || currentSku === void 0 ? void 0 : currentSku.net_weight) !== undefined || (currentSku === null || currentSku === void 0 ? void 0 : currentSku.weight_source) !== undefined);
26
+ var isWeighingSku = Number((currentSku === null || currentSku === void 0 ? void 0 : currentSku.open_sold_weight) || 0) === 1;
27
+
28
+ // 普通商品维持旧转换行为,不把目录侧完整 SKU 引入订单行。
29
+ if (!isWeighingSku && !weighing) return undefined;
30
+ // 新版 SkuDetailModal 已直接生成 product_sku;_extend.weighing 只作为旧调用方回退。
31
+ if (hasRuntimeWeighingSku) return _objectSpread({}, currentSku);
32
+ if (!weighing) return currentSku ? _objectSpread({}, currentSku) : undefined;
33
+ return _objectSpread(_objectSpread({}, currentSku || {}), {}, {
34
+ open_sold_weight: 1,
35
+ unit_data_snapshot: weighing.scalePriceProduct,
36
+ unit: WEIGHT_UNIT_MAP[String(weighing.unit)] || weighing.unit,
37
+ unit_weight: (_weighing$unit_weight = weighing.unit_weight) !== null && _weighing$unit_weight !== void 0 ? _weighing$unit_weight : '1.000',
38
+ unit_price: weighing.unit_price,
39
+ weight_source: weighing.mode,
40
+ tare_name: (_weighing$tare$label = (_weighing$tare = weighing.tare) === null || _weighing$tare === void 0 ? void 0 : _weighing$tare.label) !== null && _weighing$tare$label !== void 0 ? _weighing$tare$label : '',
41
+ tare_weight: (_weighing$tare$value = (_weighing$tare2 = weighing.tare) === null || _weighing$tare2 === void 0 ? void 0 : _weighing$tare2.value) !== null && _weighing$tare$value !== void 0 ? _weighing$tare$value : 0,
42
+ weight: (_weighing$weight = weighing.weight) !== null && _weighing$weight !== void 0 ? _weighing$weight : 0,
43
+ net_weight: (_weighing$net_weight = weighing.net_weight) !== null && _weighing$net_weight !== void 0 ? _weighing$net_weight : 0
44
+ });
45
+ }
@@ -41,6 +41,10 @@ import { composeLinePrice, createUuidV4, getProductSkuOptions, normalizeSubmitCo
41
41
  import dayjs from 'dayjs';
42
42
  import { ItemRuleEvaluator } from "../../model/strategy/adapter/itemRule";
43
43
  export * from "./types";
44
+ function isItemRewardProductDiscount(discount) {
45
+ var _discount$metadata, _discount$metadata2;
46
+ return (discount === null || discount === void 0 ? void 0 : discount.type) === 'product' && (discount === null || discount === void 0 || (_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.source) === 'promotion' && (discount === null || discount === void 0 || (_discount$metadata2 = discount.metadata) === null || _discount$metadata2 === void 0 ? void 0 : _discount$metadata2.actionType) === 'ITEM_REWARD';
47
+ }
44
48
  export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
45
49
  _inherits(ScanOrderImpl, _BaseModule);
46
50
  var _super = _createSuper(ScanOrderImpl);
@@ -1177,7 +1181,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1177
1181
  _iterator3.s();
1178
1182
  case 19:
1179
1183
  if ((_step3 = _iterator3.n()).done) {
1180
- _context15.next = 33;
1184
+ _context15.next = 36;
1181
1185
  break;
1182
1186
  }
1183
1187
  product = _step3.value;
@@ -1185,8 +1189,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1185
1189
  _context15.next = 23;
1186
1190
  break;
1187
1191
  }
1188
- return _context15.abrupt("continue", 31);
1192
+ return _context15.abrupt("continue", 34);
1189
1193
  case 23:
1194
+ if (!(product.discount_list || []).some(isItemRewardProductDiscount)) {
1195
+ _context15.next = 26;
1196
+ break;
1197
+ }
1198
+ product.discount_list = (product.discount_list || []).filter(isItemRewardProductDiscount);
1199
+ return _context15.abrupt("continue", 34);
1200
+ case 26:
1190
1201
  product.discount_list = (product.discount_list || []).filter(function (pd) {
1191
1202
  var _pd$discount$resource, _pd$discount;
1192
1203
  var rid = (_pd$discount$resource = (_pd$discount = pd.discount) === null || _pd$discount === void 0 ? void 0 : _pd$discount.resource_id) !== null && _pd$discount$resource !== void 0 ? _pd$discount$resource : pd.id;
@@ -1210,47 +1221,47 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1210
1221
  mainPrice: newMainSellingPrice,
1211
1222
  bundle: product.product_bundle
1212
1223
  });
1213
- case 31:
1224
+ case 34:
1214
1225
  _context15.next = 19;
1215
1226
  break;
1216
- case 33:
1217
- _context15.next = 38;
1227
+ case 36:
1228
+ _context15.next = 41;
1218
1229
  break;
1219
- case 35:
1220
- _context15.prev = 35;
1221
- _context15.t0 = _context15["catch"](17);
1222
- _iterator3.e(_context15.t0);
1223
1230
  case 38:
1224
1231
  _context15.prev = 38;
1225
- _iterator3.f();
1226
- return _context15.finish(38);
1232
+ _context15.t0 = _context15["catch"](17);
1233
+ _iterator3.e(_context15.t0);
1227
1234
  case 41:
1235
+ _context15.prev = 41;
1236
+ _iterator3.f();
1237
+ return _context15.finish(41);
1238
+ case 44:
1228
1239
  OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
1229
- _context15.next = 44;
1240
+ _context15.next = 47;
1230
1241
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
1231
- case 44:
1242
+ case 47:
1232
1243
  tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
1233
1244
  return d.isSelected;
1234
1245
  });
1235
- _context15.next = 47;
1246
+ _context15.next = 50;
1236
1247
  return this.store.order.recalculateSummary({
1237
1248
  createIfMissing: true
1238
1249
  });
1239
- case 47:
1250
+ case 50:
1240
1251
  this.store.order.persistTempOrder();
1241
1252
  this.logMethodSuccess('setDiscountSelected', params);
1242
- _context15.next = 55;
1253
+ _context15.next = 58;
1243
1254
  break;
1244
- case 51:
1245
- _context15.prev = 51;
1255
+ case 54:
1256
+ _context15.prev = 54;
1246
1257
  _context15.t1 = _context15["catch"](1);
1247
1258
  this.logMethodError('setDiscountSelected', _context15.t1);
1248
1259
  throw _context15.t1;
1249
- case 55:
1260
+ case 58:
1250
1261
  case "end":
1251
1262
  return _context15.stop();
1252
1263
  }
1253
- }, _callee15, this, [[1, 51], [17, 35, 38, 41]]);
1264
+ }, _callee15, this, [[1, 54], [17, 38, 41, 44]]);
1254
1265
  }));
1255
1266
  function setDiscountSelected(_x8) {
1256
1267
  return _setDiscountSelected.apply(this, arguments);
@@ -51,6 +51,10 @@ import { RegisterAndLoginHooks } from "../RegisterAndLogin/types";
51
51
  import Decimal from 'decimal.js';
52
52
  export * from "./types";
53
53
  var OPEN_DATA_SECTION_CODES = ['basic', 'fulfillment', 'reservation', 'sale', 'menu', 'availability', 'workflow', 'checkout'];
54
+ function isItemRewardProductDiscount(discount) {
55
+ var _discount$metadata, _discount$metadata2;
56
+ return (discount === null || discount === void 0 ? void 0 : discount.type) === 'product' && (discount === null || discount === void 0 || (_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.source) === 'promotion' && (discount === null || discount === void 0 || (_discount$metadata2 = discount.metadata) === null || _discount$metadata2 === void 0 ? void 0 : _discount$metadata2.actionType) === 'ITEM_REWARD';
57
+ }
54
58
  function cloneCustomDepositData(customDepositData) {
55
59
  if (!customDepositData || _typeof(customDepositData) !== 'object') return undefined;
56
60
  return _objectSpread(_objectSpread({}, customDepositData), {}, {
@@ -2163,7 +2167,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2163
2167
  _iterator14.s();
2164
2168
  case 21:
2165
2169
  if ((_step14 = _iterator14.n()).done) {
2166
- _context21.next = 35;
2170
+ _context21.next = 38;
2167
2171
  break;
2168
2172
  }
2169
2173
  product = _step14.value;
@@ -2171,8 +2175,15 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2171
2175
  _context21.next = 25;
2172
2176
  break;
2173
2177
  }
2174
- return _context21.abrupt("continue", 33);
2178
+ return _context21.abrupt("continue", 36);
2175
2179
  case 25:
2180
+ if (!(product.discount_list || []).some(isItemRewardProductDiscount)) {
2181
+ _context21.next = 28;
2182
+ break;
2183
+ }
2184
+ product.discount_list = (product.discount_list || []).filter(isItemRewardProductDiscount);
2185
+ return _context21.abrupt("continue", 36);
2186
+ case 28:
2176
2187
  // 1. 把 product.discount_list 和当前选中的 discount 对齐(剔除已取消的券)
2177
2188
  product.discount_list = (product.discount_list || []).filter(function (pd) {
2178
2189
  var _pd$discount$resource, _pd$discount;
@@ -2197,36 +2208,36 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2197
2208
  mainPrice: newMainSellingPrice,
2198
2209
  bundle: product.product_bundle
2199
2210
  });
2200
- case 33:
2211
+ case 36:
2201
2212
  _context21.next = 21;
2202
2213
  break;
2203
- case 35:
2204
- _context21.next = 40;
2214
+ case 38:
2215
+ _context21.next = 43;
2205
2216
  break;
2206
- case 37:
2207
- _context21.prev = 37;
2208
- _context21.t0 = _context21["catch"](19);
2209
- _iterator14.e(_context21.t0);
2210
2217
  case 40:
2211
2218
  _context21.prev = 40;
2212
- _iterator14.f();
2213
- return _context21.finish(40);
2219
+ _context21.t0 = _context21["catch"](19);
2220
+ _iterator14.e(_context21.t0);
2214
2221
  case 43:
2222
+ _context21.prev = 43;
2223
+ _iterator14.f();
2224
+ return _context21.finish(43);
2225
+ case 46:
2215
2226
  OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
2216
- _context21.next = 46;
2227
+ _context21.next = 49;
2217
2228
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
2218
- case 46:
2229
+ case 49:
2219
2230
  tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
2220
2231
  return d.isSelected;
2221
2232
  });
2222
2233
  afterApplyTarget = this.store.order.getDiscountList().find(function (d) {
2223
2234
  return d.id === params.discountId;
2224
2235
  }) || null;
2225
- _context21.next = 50;
2236
+ _context21.next = 53;
2226
2237
  return this.store.order.recalculateSummary({
2227
2238
  createIfMissing: true
2228
2239
  });
2229
- case 50:
2240
+ case 53:
2230
2241
  this.store.order.persistTempOrder();
2231
2242
  finalSummary = ((_this$store$order$get = this.store.order.getTempOrder()) === null || _this$store$order$get === void 0 ? void 0 : _this$store$order$get.summary) || null;
2232
2243
  finalProduct = ((_this$store$order$get2 = this.store.order.getTempOrder()) === null || _this$store$order$get2 === void 0 || (_this$store$order$get2 = _this$store$order$get2.products) === null || _this$store$order$get2 === void 0 ? void 0 : _this$store$order$get2[0]) || null;
@@ -2235,16 +2246,16 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2235
2246
  return d.id === params.discountId;
2236
2247
  }) || null;
2237
2248
  return _context21.abrupt("return", this.store.order.getDiscountList());
2238
- case 58:
2239
- _context21.prev = 58;
2249
+ case 61:
2250
+ _context21.prev = 61;
2240
2251
  _context21.t1 = _context21["catch"](1);
2241
2252
  this.logMethodError('setDiscountSelected', _context21.t1);
2242
2253
  throw _context21.t1;
2243
- case 62:
2254
+ case 65:
2244
2255
  case "end":
2245
2256
  return _context21.stop();
2246
2257
  }
2247
- }, _callee21, this, [[1, 58], [19, 37, 40, 43]]);
2258
+ }, _callee21, this, [[1, 61], [19, 40, 43, 46]]);
2248
2259
  }));
2249
2260
  function setDiscountSelected(_x15) {
2250
2261
  return _setDiscountSelected.apply(this, arguments);