@pisell/pisellos 2.3.212 → 2.3.213

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.
@@ -1358,7 +1358,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1358
1358
  return 1;
1359
1359
  };
1360
1360
  return function (payload, _ref3) {
1361
- var _resourceState$relati, _tempOrder$metadata, _ref4, _pickOriginal, _resourceState$table_2, _resourceState$relati2, _pickFirstCustomCapac;
1361
+ var _resourceState$relati, _tempOrder$metadata, _resourceState$table_2, _this5$core, _this5$core$getPlugin, _this5$core$getPlugin2, _coreState$core, _ref4, _ref5, _ref6, _ref7, _pickFromCandidates, _resourceState$table_3, _resourceState$relati2, _pickFirstCustomCapac;
1362
1362
  var bookingUuid = _ref3.bookingUuid,
1363
1363
  tempOrder = _ref3.tempOrder,
1364
1364
  now = _ref3.now;
@@ -1373,14 +1373,46 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1373
1373
  var rawCollectPax = (_tempOrder$metadata = tempOrder.metadata) === null || _tempOrder$metadata === void 0 ? void 0 : _tempOrder$metadata.collect_pax;
1374
1374
  var hasExplicitCollectPax = rawCollectPax !== null && rawCollectPax !== undefined && rawCollectPax !== '';
1375
1375
  var bookingCapacityValue = resolveBookingCapacityValue();
1376
- var pickOriginal = function pickOriginal(value) {
1377
- if (value && _typeof(value) === 'object' && !Array.isArray(value)) {
1378
- var original = value.original;
1379
- return typeof original === 'string' && original.length > 0 ? original : undefined;
1376
+ var resourceNameCandidates = [tempOrder.table_number, resourceState === null || resourceState === void 0 || (_resourceState$table_2 = resourceState.table_form_record) === null || _resourceState$table_2 === void 0 ? void 0 : _resourceState$table_2.name];
1377
+ var toNonEmptyString = function toNonEmptyString(value) {
1378
+ return typeof value === 'string' && value.trim().length > 0 ? value : undefined;
1379
+ };
1380
+ var toNameMap = function toNameMap(value) {
1381
+ return value && _typeof(value) === 'object' && !Array.isArray(value) ? value : undefined;
1382
+ };
1383
+ var pickFromCandidates = function pickFromCandidates(picker) {
1384
+ for (var _i3 = 0, _resourceNameCandidat = resourceNameCandidates; _i3 < _resourceNameCandidat.length; _i3++) {
1385
+ var candidate = _resourceNameCandidat[_i3];
1386
+ var resolved = picker(candidate);
1387
+ if (resolved !== undefined) return resolved;
1388
+ }
1389
+ return undefined;
1390
+ };
1391
+ var pickDirectOrOriginal = function pickDirectOrOriginal(value) {
1392
+ var _toNonEmptyString, _toNameMap;
1393
+ return (_toNonEmptyString = toNonEmptyString(value)) !== null && _toNonEmptyString !== void 0 ? _toNonEmptyString : toNonEmptyString((_toNameMap = toNameMap(value)) === null || _toNameMap === void 0 ? void 0 : _toNameMap.original);
1394
+ };
1395
+ var pickLocalized = function pickLocalized(value, locale) {
1396
+ var _toNameMap2;
1397
+ return toNonEmptyString((_toNameMap2 = toNameMap(value)) === null || _toNameMap2 === void 0 ? void 0 : _toNameMap2[locale]);
1398
+ };
1399
+ var pickFirstNonEmpty = function pickFirstNonEmpty(value) {
1400
+ var nameMap = toNameMap(value);
1401
+ if (!nameMap) return undefined;
1402
+ for (var _i4 = 0, _Object$values = Object.values(nameMap); _i4 < _Object$values.length; _i4++) {
1403
+ var candidate = _Object$values[_i4];
1404
+ var resolved = toNonEmptyString(candidate);
1405
+ if (resolved !== undefined) return resolved;
1380
1406
  }
1381
1407
  return undefined;
1382
1408
  };
1383
- var mainField = (_ref4 = (_pickOriginal = pickOriginal(tempOrder.table_number)) !== null && _pickOriginal !== void 0 ? _pickOriginal : pickOriginal(resourceState === null || resourceState === void 0 || (_resourceState$table_2 = resourceState.table_form_record) === null || _resourceState$table_2 === void 0 ? void 0 : _resourceState$table_2.name)) !== null && _ref4 !== void 0 ? _ref4 : '';
1409
+ var coreState = (_this5$core = _this5.core) === null || _this5$core === void 0 || (_this5$core$getPlugin = _this5$core.getPlugin) === null || _this5$core$getPlugin === void 0 || (_this5$core$getPlugin = _this5$core$getPlugin.call(_this5$core, 'shopStore')) === null || _this5$core$getPlugin === void 0 || (_this5$core$getPlugin2 = _this5$core$getPlugin.get) === null || _this5$core$getPlugin2 === void 0 ? void 0 : _this5$core$getPlugin2.call(_this5$core$getPlugin, 'core');
1410
+ var activeLocale = String((coreState === null || coreState === void 0 ? void 0 : coreState.translateLocale) || (coreState === null || coreState === void 0 || (_coreState$core = coreState.core) === null || _coreState$core === void 0 || (_coreState$core = _coreState$core.shop) === null || _coreState$core === void 0 ? void 0 : _coreState$core.primary_locale) || 'en');
1411
+ var mainField = (_ref4 = (_ref5 = (_ref6 = (_ref7 = (_pickFromCandidates = pickFromCandidates(pickDirectOrOriginal)) !== null && _pickFromCandidates !== void 0 ? _pickFromCandidates : toNonEmptyString(resourceState === null || resourceState === void 0 || (_resourceState$table_3 = resourceState.table_form_record) === null || _resourceState$table_3 === void 0 ? void 0 : _resourceState$table_3.main_field)) !== null && _ref7 !== void 0 ? _ref7 : pickFromCandidates(function (value) {
1412
+ return pickLocalized(value, activeLocale);
1413
+ })) !== null && _ref6 !== void 0 ? _ref6 : pickFromCandidates(function (value) {
1414
+ return pickLocalized(value, 'en');
1415
+ })) !== null && _ref5 !== void 0 ? _ref5 : pickFromCandidates(pickFirstNonEmpty)) !== null && _ref4 !== void 0 ? _ref4 : '';
1384
1416
  var resourceEntry = resourceState && resourceId ? {
1385
1417
  relation_type: 'form',
1386
1418
  like_status: 'common',
@@ -1448,9 +1480,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1448
1480
  var nextProducts = _toConsumableArray(payload.products || []);
1449
1481
  // 加餐(已有 order_id)走 scanOrderMore,原单已含 booking 规则行,勿再追加虚拟规则商品
1450
1482
  if (ruleProduct && ruleProductUid && !tempOrder.order_id) {
1451
- var _ruleProduct$price, _ref5, _ruleProduct$original, _ruleProduct$is_gst;
1483
+ var _ruleProduct$price, _ref8, _ruleProduct$original, _ruleProduct$is_gst;
1452
1484
  var sellingPrice = String((_ruleProduct$price = ruleProduct.price) !== null && _ruleProduct$price !== void 0 ? _ruleProduct$price : '0.00');
1453
- var originalPrice = String((_ref5 = (_ruleProduct$original = ruleProduct.original_price) !== null && _ruleProduct$original !== void 0 ? _ruleProduct$original : ruleProduct.price) !== null && _ref5 !== void 0 ? _ref5 : '0.00');
1485
+ var originalPrice = String((_ref8 = (_ruleProduct$original = ruleProduct.original_price) !== null && _ruleProduct$original !== void 0 ? _ruleProduct$original : ruleProduct.price) !== null && _ref8 !== void 0 ? _ref8 : '0.00');
1454
1486
  nextProducts.push({
1455
1487
  product_id: ruleProduct.id,
1456
1488
  product_variant_id: 0,
@@ -1570,8 +1602,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1570
1602
  var product = _step5.value;
1571
1603
  var uid = (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.unique_identification_number;
1572
1604
  var origins = [product._origin, (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.origin, uid ? (_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 || (_tempOrder$_extend = _tempOrder$_extend.productsByUid) === null || _tempOrder$_extend === void 0 || (_tempOrder$_extend = _tempOrder$_extend[String(uid)]) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend.origin : undefined];
1573
- for (var _i3 = 0, _origins = origins; _i3 < _origins.length; _i3++) {
1574
- var origin = _origins[_i3];
1605
+ for (var _i5 = 0, _origins = origins; _i5 < _origins.length; _i5++) {
1606
+ var origin = _origins[_i5];
1575
1607
  if (origin && _typeof(origin) === 'object' && !Array.isArray(origin)) {
1576
1608
  sources.push(_objectSpread(_objectSpread({}, origin), {}, {
1577
1609
  product_id: product.product_id
@@ -2105,16 +2137,16 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2105
2137
  var rawProductId = (_node$product_id = node.product_id) !== null && _node$product_id !== void 0 ? _node$product_id : node.id;
2106
2138
  var productId = Number(rawProductId);
2107
2139
  if (Number.isFinite(productId) && productId > 0) {
2108
- var _ref6, _node$product_variant;
2109
- var productVariantId = Number((_ref6 = (_node$product_variant = node.product_variant_id) !== null && _node$product_variant !== void 0 ? _node$product_variant : node.variant_id) !== null && _ref6 !== void 0 ? _ref6 : 0);
2140
+ var _ref9, _node$product_variant;
2141
+ var productVariantId = Number((_ref9 = (_node$product_variant = node.product_variant_id) !== null && _node$product_variant !== void 0 ? _node$product_variant : node.variant_id) !== null && _ref9 !== void 0 ? _ref9 : 0);
2110
2142
  var normalizedVariantId = Number.isNaN(productVariantId) ? 0 : productVariantId;
2111
2143
  var key = buildProductKey(productId, normalizedVariantId);
2112
2144
  if (!sourceMap.has(key)) {
2113
2145
  sourceMap.set(key, node);
2114
2146
  }
2115
2147
  }
2116
- for (var _i4 = 0, _Object$values = Object.values(node); _i4 < _Object$values.length; _i4++) {
2117
- var childValue = _Object$values[_i4];
2148
+ for (var _i6 = 0, _Object$values2 = Object.values(node); _i6 < _Object$values2.length; _i6++) {
2149
+ var childValue = _Object$values2[_i6];
2118
2150
  if (childValue && _typeof(childValue) === 'object') {
2119
2151
  collectFromValue(childValue);
2120
2152
  }
@@ -2143,10 +2175,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2143
2175
  }, {
2144
2176
  key: "getItemRuleRuntimeConfig",
2145
2177
  value: function getItemRuleRuntimeConfig() {
2146
- var _ref7, _runtimeConfig$channe, _runtimeConfig$custom, _this$otherParams14;
2178
+ var _ref10, _runtimeConfig$channe, _runtimeConfig$custom, _this$otherParams14;
2147
2179
  var runtimeConfig = this.itemRuleRuntimeConfig || {};
2148
2180
  return _objectSpread(_objectSpread({}, runtimeConfig), {}, {
2149
- channel: (_ref7 = (_runtimeConfig$channe = runtimeConfig.channel) !== null && _runtimeConfig$channe !== void 0 ? _runtimeConfig$channe : (_runtimeConfig$custom = runtimeConfig.custom) === null || _runtimeConfig$custom === void 0 ? void 0 : _runtimeConfig$custom.channel) !== null && _ref7 !== void 0 ? _ref7 : (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.channel
2181
+ channel: (_ref10 = (_runtimeConfig$channe = runtimeConfig.channel) !== null && _runtimeConfig$channe !== void 0 ? _runtimeConfig$channe : (_runtimeConfig$custom = runtimeConfig.custom) === null || _runtimeConfig$custom === void 0 ? void 0 : _runtimeConfig$custom.channel) !== null && _ref10 !== void 0 ? _ref10 : (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.channel
2150
2182
  });
2151
2183
  }
2152
2184
  }, {
@@ -3367,14 +3399,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3367
3399
  key: "setOtherParams",
3368
3400
  value: function () {
3369
3401
  var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
3370
- var _ref9,
3371
- _ref9$cover,
3402
+ var _ref12,
3403
+ _ref12$cover,
3372
3404
  cover,
3373
3405
  _args41 = arguments;
3374
3406
  return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3375
3407
  while (1) switch (_context41.prev = _context41.next) {
3376
3408
  case 0:
3377
- _ref9 = _args41.length > 1 && _args41[1] !== undefined ? _args41[1] : {}, _ref9$cover = _ref9.cover, cover = _ref9$cover === void 0 ? false : _ref9$cover;
3409
+ _ref12 = _args41.length > 1 && _args41[1] !== undefined ? _args41[1] : {}, _ref12$cover = _ref12.cover, cover = _ref12$cover === void 0 ? false : _ref12$cover;
3378
3410
  if (cover) {
3379
3411
  this.otherParams = params;
3380
3412
  } else {
@@ -3525,7 +3557,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3525
3557
  key: "syncAdditionalOrderFromResource",
3526
3558
  value: function () {
3527
3559
  var _syncAdditionalOrderFromResource = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(resourceId) {
3528
- var _ref10, _ref11, _ref12, _this$store$resource5, _this$store$resource6, _occupyDetails$2, _this$store$resource7, _this$otherParams22, _this$store$resource8, _this$store$order8;
3560
+ var _ref13, _ref14, _ref15, _this$store$resource5, _this$store$resource6, _occupyDetails$2, _this$store$resource7, _this$otherParams22, _this$store$resource8, _this$store$order8;
3529
3561
  var tempOrder, normalizedResourceId, _result, occupyDetails, occupyDetail, resourceSelectType, allowAddItems, result, resourceState;
3530
3562
  return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3531
3563
  while (1) switch (_context43.prev = _context43.next) {
@@ -3537,7 +3569,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3537
3569
  throw new Error('order 模块未初始化');
3538
3570
  case 2:
3539
3571
  tempOrder = this.store.order.ensureTempOrder();
3540
- normalizedResourceId = String((_ref10 = (_ref11 = (_ref12 = resourceId !== null && resourceId !== void 0 ? resourceId : tempOrder.resource_id) !== null && _ref12 !== void 0 ? _ref12 : (_this$store$resource5 = this.store.resource) === null || _this$store$resource5 === void 0 ? void 0 : _this$store$resource5.relationId) !== null && _ref11 !== void 0 ? _ref11 : (_this$store$resource6 = this.store.resource) === null || _this$store$resource6 === void 0 ? void 0 : _this$store$resource6.relation_id) !== null && _ref10 !== void 0 ? _ref10 : '').trim();
3572
+ normalizedResourceId = String((_ref13 = (_ref14 = (_ref15 = resourceId !== null && resourceId !== void 0 ? resourceId : tempOrder.resource_id) !== null && _ref15 !== void 0 ? _ref15 : (_this$store$resource5 = this.store.resource) === null || _this$store$resource5 === void 0 ? void 0 : _this$store$resource5.relationId) !== null && _ref14 !== void 0 ? _ref14 : (_this$store$resource6 = this.store.resource) === null || _this$store$resource6 === void 0 ? void 0 : _this$store$resource6.relation_id) !== null && _ref13 !== void 0 ? _ref13 : '').trim();
3541
3573
  this.logMethodStart('syncAdditionalOrderFromResource', {
3542
3574
  resourceId: normalizedResourceId
3543
3575
  });
@@ -1,46 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "BUY_X_GET_Y_FREE_STRATEGY", {
7
- enumerable: true,
8
- get: function () {
9
- return _examples.BUY_X_GET_Y_FREE_STRATEGY;
10
- }
11
- });
12
- Object.defineProperty(exports, "ITEM_REWARD_STRATEGY", {
13
- enumerable: true,
14
- get: function () {
15
- return _examples.ITEM_REWARD_STRATEGY;
16
- }
17
- });
18
- Object.defineProperty(exports, "PromotionAdapter", {
19
- enumerable: true,
20
- get: function () {
21
- return _adapter.PromotionAdapter;
22
- }
23
- });
24
- Object.defineProperty(exports, "PromotionEvaluator", {
25
- enumerable: true,
26
- get: function () {
27
- return _evaluator.PromotionEvaluator;
28
- }
29
- });
30
- Object.defineProperty(exports, "X_ITEMS_FOR_Y_PRICE_STRATEGY", {
31
- enumerable: true,
32
- get: function () {
33
- return _examples.X_ITEMS_FOR_Y_PRICE_STRATEGY;
34
- }
35
- });
36
- Object.defineProperty(exports, "default", {
37
- enumerable: true,
38
- get: function () {
39
- return _adapter.default;
40
- }
41
- });
42
- var _evaluator = require("./evaluator");
43
- var _adapter = _interopRequireWildcard(require("./adapter"));
44
- var _examples = require("./examples");
45
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
46
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
1
+ "use strict";
@@ -835,14 +835,30 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
835
835
  const rawCollectPax = tempOrder.metadata?.collect_pax;
836
836
  const hasExplicitCollectPax = rawCollectPax !== null && rawCollectPax !== undefined && rawCollectPax !== '';
837
837
  const bookingCapacityValue = resolveBookingCapacityValue();
838
- const pickOriginal = value => {
839
- if (value && typeof value === 'object' && !Array.isArray(value)) {
840
- const original = value.original;
841
- return typeof original === 'string' && original.length > 0 ? original : undefined;
838
+ const resourceNameCandidates = [tempOrder.table_number, resourceState?.table_form_record?.name];
839
+ const toNonEmptyString = value => typeof value === 'string' && value.trim().length > 0 ? value : undefined;
840
+ const toNameMap = value => value && typeof value === 'object' && !Array.isArray(value) ? value : undefined;
841
+ const pickFromCandidates = picker => {
842
+ for (const candidate of resourceNameCandidates) {
843
+ const resolved = picker(candidate);
844
+ if (resolved !== undefined) return resolved;
842
845
  }
843
846
  return undefined;
844
847
  };
845
- const mainField = pickOriginal(tempOrder.table_number) ?? pickOriginal(resourceState?.table_form_record?.name) ?? '';
848
+ const pickDirectOrOriginal = value => toNonEmptyString(value) ?? toNonEmptyString(toNameMap(value)?.original);
849
+ const pickLocalized = (value, locale) => toNonEmptyString(toNameMap(value)?.[locale]);
850
+ const pickFirstNonEmpty = value => {
851
+ const nameMap = toNameMap(value);
852
+ if (!nameMap) return undefined;
853
+ for (const candidate of Object.values(nameMap)) {
854
+ const resolved = toNonEmptyString(candidate);
855
+ if (resolved !== undefined) return resolved;
856
+ }
857
+ return undefined;
858
+ };
859
+ const coreState = this.core?.getPlugin?.('shopStore')?.get?.('core');
860
+ const activeLocale = String(coreState?.translateLocale || coreState?.core?.shop?.primary_locale || 'en');
861
+ const mainField = pickFromCandidates(pickDirectOrOriginal) ?? toNonEmptyString(resourceState?.table_form_record?.main_field) ?? pickFromCandidates(value => pickLocalized(value, activeLocale)) ?? pickFromCandidates(value => pickLocalized(value, 'en')) ?? pickFromCandidates(pickFirstNonEmpty) ?? '';
846
862
  const resourceEntry = resourceState && resourceId ? {
847
863
  relation_type: 'form',
848
864
  like_status: 'common',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.212",
4
+ "version": "2.3.213",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",