@pisell/private-materials 6.3.175 → 6.3.177

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 (29) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/meta.js +1 -1
  5. package/build/lowcode/render/default/view.css +1 -1
  6. package/build/lowcode/render/default/view.js +9 -9
  7. package/build/lowcode/view.css +1 -1
  8. package/build/lowcode/view.js +1 -1
  9. package/es/components/appointmentBooking/components/Voucher/index.js +1 -1
  10. package/es/components/scanOrder/components/Check/index.js +187 -46
  11. package/es/components/scanOrder/components/Check/index.less +39 -0
  12. package/es/components/scanOrder/components/Content/index.js +189 -72
  13. package/es/components/scanOrder/components/Menu/index.js +11 -5
  14. package/es/components/scanOrder/hooks.js +7 -0
  15. package/es/components/scanOrder/locales.d.ts +75 -0
  16. package/es/components/scanOrder/locales.js +75 -0
  17. package/es/components/venueBooking/components/Voucher/index.js +6 -1
  18. package/es/pro/Login2.0/locales.js +1 -1
  19. package/lib/components/appointmentBooking/components/Voucher/index.js +1 -1
  20. package/lib/components/scanOrder/components/Check/index.js +116 -3
  21. package/lib/components/scanOrder/components/Check/index.less +39 -0
  22. package/lib/components/scanOrder/components/Content/index.js +106 -25
  23. package/lib/components/scanOrder/components/Menu/index.js +2 -0
  24. package/lib/components/scanOrder/hooks.js +7 -0
  25. package/lib/components/scanOrder/locales.d.ts +75 -0
  26. package/lib/components/scanOrder/locales.js +75 -0
  27. package/lib/components/venueBooking/components/Voucher/index.js +5 -1
  28. package/lib/pro/Login2.0/locales.js +1 -1
  29. package/package.json +1 -1
@@ -146,7 +146,7 @@ var VoucherCard = function VoucherCard(props) {
146
146
  var _bundleItem$originBun, _bundleItem$originBun2, _originBundle$metadat;
147
147
  var originBundleProductId = (originBundle === null || originBundle === void 0 ? void 0 : originBundle.bundle_product_id) || (originBundle === null || originBundle === void 0 ? void 0 : originBundle.bundle_id);
148
148
  var bundleProductId = (bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem._bundle_product_id) || (bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.product_id) || (bundleItem === null || bundleItem === void 0 || (_bundleItem$originBun = bundleItem.originBundleItem) === null || _bundleItem$originBun === void 0 ? void 0 : _bundleItem$originBun._bundle_product_id) || (bundleItem === null || bundleItem === void 0 || (_bundleItem$originBun2 = bundleItem.originBundleItem) === null || _bundleItem$originBun2 === void 0 ? void 0 : _bundleItem$originBun2.product_id);
149
- return String(originBundleProductId || '') === String(bundleProductId || '') || String((originBundle === null || originBundle === void 0 || (_originBundle$metadat = originBundle.metadata) === null || _originBundle$metadat === void 0 ? void 0 : _originBundle$metadat.custom_product_bundle_map_id) || '') === String((bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem._id) || '');
149
+ return (String(originBundleProductId || '') === String(bundleProductId || '') || String((originBundle === null || originBundle === void 0 || (_originBundle$metadat = originBundle.metadata) === null || _originBundle$metadat === void 0 ? void 0 : _originBundle$metadat.custom_product_bundle_map_id) || '') === String((bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem._id) || '')) && (originBundle === null || originBundle === void 0 ? void 0 : originBundle.bundle_id) === (bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.bundle_id);
150
150
  };
151
151
  var syncOriginProductBundles = function syncOriginProductBundles(item) {
152
152
  var _item$_origin2;
@@ -9,9 +9,9 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
9
9
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
10
10
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
11
  import React, { useMemo, useState, useCallback, useEffect } from 'react';
12
- import { Input, message } from 'antd';
12
+ import { Input, message, Modal } from 'antd';
13
13
  import { locales } from '@pisell/utils';
14
- import { PisellLoading, PisellToast } from '@pisell/materials';
14
+ import { Button, PisellLoading, PisellToast } from '@pisell/materials';
15
15
  import Cart from "../Cart";
16
16
  import FulfillmentMode from "../FulfillmentMode";
17
17
  import ManualPickupRefModal from "../ManualPickupRefModal";
@@ -25,7 +25,8 @@ export default function Check() {
25
25
  refreshViewModel = _useScanOrderContext.refreshViewModel,
26
26
  tableName = _useScanOrderContext.tableName,
27
27
  entryMode = _useScanOrderContext.entryMode,
28
- clearStepCache = _useScanOrderContext.clearStepCache;
28
+ clearStepCache = _useScanOrderContext.clearStepCache,
29
+ entryContext = _useScanOrderContext.entryContext;
29
30
  var isAdditionalOrder = entryMode === 'additional_order';
30
31
  var _useState = useState(false),
31
32
  _useState2 = _slicedToArray(_useState, 2),
@@ -39,15 +40,19 @@ export default function Check() {
39
40
  _useState6 = _slicedToArray(_useState5, 2),
40
41
  pickupRefOpen = _useState6[0],
41
42
  setPickupRefOpen = _useState6[1];
42
- var utils = contextUtils();
43
- var _useState7 = useState(null),
43
+ var _useState7 = useState(false),
44
44
  _useState8 = _slicedToArray(_useState7, 2),
45
- dineInConfig = _useState8[0],
46
- setDineInConfig = _useState8[1];
47
- var _useState9 = useState(''),
45
+ addOnConfirmOpen = _useState8[0],
46
+ setAddOnConfirmOpen = _useState8[1];
47
+ var utils = contextUtils();
48
+ var _useState9 = useState(null),
48
49
  _useState10 = _slicedToArray(_useState9, 2),
49
- channel = _useState10[0],
50
- setChannel = _useState10[1];
50
+ dineInConfig = _useState10[0],
51
+ setDineInConfig = _useState10[1];
52
+ var _useState11 = useState(''),
53
+ _useState12 = _slicedToArray(_useState11, 2),
54
+ channel = _useState12[0],
55
+ setChannel = _useState12[1];
51
56
  // 去读 pisellos 内的配置
52
57
  var getConfig = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
53
58
  var _otherParams$dineInCo, _otherParams$channel;
@@ -89,6 +94,18 @@ export default function Check() {
89
94
  var productsTitle = useMemo(function () {
90
95
  return String(locales.getText('pisell2.scan.order.products.title') || 'Products');
91
96
  }, []);
97
+ var addOnConfirmTitle = useMemo(function () {
98
+ return String(locales.getText('pisell2.scan.order.add.on.confirm.title') || 'This table has already started ordering');
99
+ }, []);
100
+ var addOnConfirmDescription = useMemo(function () {
101
+ return String(locales.getText('pisell2.scan.order.add.on.confirm.description') || 'Someone at your table has placed the order. This will be submitted as an add-on order.');
102
+ }, []);
103
+ var addOnConfirmButtonText = useMemo(function () {
104
+ return String(locales.getText('pisell2.scan.order.add.on.confirm.button') || 'Confirm Add-on Order');
105
+ }, []);
106
+ var addOnReturnButtonText = useMemo(function () {
107
+ return String(locales.getText('pisell2.scan.order.add.on.return.button') || 'Return to Cart');
108
+ }, []);
92
109
  var showCheckStepEmptyCartTip = function showCheckStepEmptyCartTip() {
93
110
  message.error(locales.getText('pisell2.scan.order.check.cart.empty.tip') || 'Please go back to add products');
94
111
  };
@@ -98,9 +115,31 @@ export default function Check() {
98
115
  content: content
99
116
  });
100
117
  }, []);
118
+ var showInventoryInsufficientModal = useCallback(function (error) {
119
+ var _error$data;
120
+ setSubmitting(false);
121
+ var unavailableProducts = Array.isArray(error === null || error === void 0 || (_error$data = error.data) === null || _error$data === void 0 ? void 0 : _error$data.unavailable_products) ? error.data.unavailable_products : [];
122
+ var productNames = unavailableProducts.map(function (product) {
123
+ return String((product === null || product === void 0 ? void 0 : product.title) || (product === null || product === void 0 ? void 0 : product.product_id) || '').trim();
124
+ }).filter(Boolean);
125
+ var title = String(locales.getText('pisell2.scan.order.inventory.insufficient.title') || 'Insufficient inventory');
126
+ var description = String(locales.getText('pisell2.scan.order.inventory.insufficient.description') || 'The following items are out of stock or do not have enough inventory. Please adjust your cart and try again.');
127
+ var productsLabel = String(locales.getText('pisell2.scan.order.inventory.insufficient.products.label') || 'Unavailable products:');
128
+ var fallbackMessage = String((error === null || error === void 0 ? void 0 : error.message) || description);
129
+ Modal.info({
130
+ title: title,
131
+ content: /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", null, description), /*#__PURE__*/React.createElement("div", null, productsLabel), productNames.length > 0 ? /*#__PURE__*/React.createElement("ul", null, productNames.map(function (name, index) {
132
+ return /*#__PURE__*/React.createElement("li", {
133
+ key: "".concat(name, "-").concat(index)
134
+ }, name);
135
+ })) : /*#__PURE__*/React.createElement("div", null, fallbackMessage)),
136
+ okText: String(locales.getText('pisell2.event.confirm') || 'OK'),
137
+ maskClosable: false
138
+ });
139
+ }, []);
101
140
  var doSubmit = /*#__PURE__*/function () {
102
141
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
103
- var items, _res$data, res, orderId, shouldPayOnSubmit, channelMap, saleChannel, _res$data2, _viewModel$summary, _utils$history, _utils$history2, link;
142
+ var items, _res$data, res, orderId, shouldPayOnSubmit, channelMap, saleChannel, _res$data2, _viewModel$summary, _utils$history, _utils$history2, link, reservationResourceSelectType, allowAddItems, _res;
104
143
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
105
144
  while (1) switch (_context3.prev = _context3.next) {
106
145
  case 0:
@@ -124,31 +163,39 @@ export default function Check() {
124
163
  res = _context3.sent;
125
164
  console.log('submitScanOrder >>>>> ', res);
126
165
  if (!((res === null || res === void 0 ? void 0 : res.status) === false)) {
166
+ _context3.next = 20;
167
+ break;
168
+ }
169
+ if (!((res === null || res === void 0 ? void 0 : res.code) === 6008)) {
127
170
  _context3.next = 17;
128
171
  break;
129
172
  }
173
+ showInventoryInsufficientModal(res);
174
+ return _context3.abrupt("return");
175
+ case 17:
130
176
  setSubmitting(false);
131
177
  showSubmitFailedTip(res === null || res === void 0 ? void 0 : res.message);
132
178
  return _context3.abrupt("return");
133
- case 17:
179
+ case 20:
134
180
  orderId = res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.order_id;
135
181
  shouldPayOnSubmit = (dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['sale.require_payment_on_submit']) && !isAdditionalOrder;
136
182
  if (orderId) {
137
- _context3.next = 22;
183
+ _context3.next = 25;
138
184
  break;
139
185
  }
140
186
  showSubmitFailedTip(res === null || res === void 0 ? void 0 : res.message);
141
187
  return _context3.abrupt("return");
142
- case 22:
188
+ case 25:
143
189
  // 下单成功:清空步骤缓存(step / gate / entryContext),避免残留影响下次扫码
144
190
  clearStepCache();
145
191
  channelMap = {
146
192
  'scan_to_order': 'table-order',
147
- 'scan_to_order_2': 'mobile_order'
193
+ 'scan_to_order_2': 'mobile_order',
194
+ 'scan_to_order_3': 'scantoorder3'
148
195
  };
149
196
  saleChannel = channelMap[channel] || channel;
150
197
  if (!shouldPayOnSubmit) {
151
- _context3.next = 30;
198
+ _context3.next = 33;
152
199
  break;
153
200
  }
154
201
  setSubmitting(false);
@@ -186,20 +233,20 @@ export default function Check() {
186
233
  return callback;
187
234
  }()
188
235
  });
189
- _context3.next = 48;
236
+ _context3.next = 51;
190
237
  break;
191
- case 30:
192
- _context3.prev = 30;
193
- _context3.next = 33;
194
- return runModuleAction('restoreOrder');
195
238
  case 33:
196
- _context3.next = 38;
239
+ _context3.prev = 33;
240
+ _context3.next = 36;
241
+ return runModuleAction('restoreOrder');
242
+ case 36:
243
+ _context3.next = 41;
197
244
  break;
198
- case 35:
199
- _context3.prev = 35;
200
- _context3.t0 = _context3["catch"](30);
201
- console.warn('[scanOrder] restoreOrder before redirect failed', _context3.t0);
202
245
  case 38:
246
+ _context3.prev = 38;
247
+ _context3.t0 = _context3["catch"](33);
248
+ console.warn('[scanOrder] restoreOrder before redirect failed', _context3.t0);
249
+ case 41:
203
250
  link = "/order/details?id=".concat(orderId);
204
251
  if (utils !== null && utils !== void 0 && (_utils$history = utils.history) !== null && _utils$history !== void 0 && _utils$history.replace) {
205
252
  utils.history.replace(link);
@@ -208,35 +255,75 @@ export default function Check() {
208
255
  } else {
209
256
  location.replace(link);
210
257
  }
211
- _context3.prev = 40;
212
- _context3.next = 43;
258
+ _context3.prev = 43;
259
+ _context3.next = 46;
213
260
  return runModuleAction('restoreOrder');
214
- case 43:
215
- _context3.next = 48;
261
+ case 46:
262
+ _context3.next = 51;
216
263
  break;
217
- case 45:
218
- _context3.prev = 45;
219
- _context3.t1 = _context3["catch"](40);
220
- console.warn('[scanOrder] restoreOrder after payment failed', _context3.t1);
221
264
  case 48:
222
- _context3.next = 50;
265
+ _context3.prev = 48;
266
+ _context3.t1 = _context3["catch"](43);
267
+ console.warn('[scanOrder] restoreOrder after payment failed', _context3.t1);
268
+ case 51:
269
+ _context3.next = 53;
223
270
  return refreshViewModel();
224
- case 50:
225
- _context3.next = 56;
271
+ case 53:
272
+ _context3.next = 77;
226
273
  break;
227
- case 52:
228
- _context3.prev = 52;
274
+ case 55:
275
+ _context3.prev = 55;
229
276
  _context3.t2 = _context3["catch"](5);
230
277
  console.error('[scanOrder] submitScanOrder failed', _context3.t2);
231
- showSubmitFailedTip(_context3.t2 === null || _context3.t2 === void 0 ? void 0 : _context3.t2.message);
232
- case 56:
233
- _context3.prev = 56;
234
- return _context3.finish(56);
235
- case 58:
278
+ if (!((_context3.t2 === null || _context3.t2 === void 0 ? void 0 : _context3.t2.code) === 670005)) {
279
+ _context3.next = 63;
280
+ break;
281
+ }
282
+ setSubmitting(false);
283
+ showSubmitFailedTip(String(locales.getText('pisell2.scan.order.settled.cannot.add.tip') || ''));
284
+ _context3.next = 77;
285
+ break;
286
+ case 63:
287
+ if (!((_context3.t2 === null || _context3.t2 === void 0 ? void 0 : _context3.t2.code) === 670007 && entryContext !== null && entryContext !== void 0 && entryContext.resource_id)) {
288
+ _context3.next = 76;
289
+ break;
290
+ }
291
+ _context3.next = 66;
292
+ return runModuleAction('getReservationResourceSelectType');
293
+ case 66:
294
+ reservationResourceSelectType = _context3.sent;
295
+ _context3.next = 69;
296
+ return runModuleAction('checkAllowAddItems');
297
+ case 69:
298
+ allowAddItems = _context3.sent;
299
+ _context3.next = 72;
300
+ return runModuleAction('syncAdditionalOrderFromResource', entryContext === null || entryContext === void 0 ? void 0 : entryContext.resource_id);
301
+ case 72:
302
+ _res = _context3.sent;
303
+ if (reservationResourceSelectType.resourceSelectType === 'single' && allowAddItems !== null && allowAddItems !== void 0 && allowAddItems.enabled && _res !== null && _res !== void 0 && _res.matched) {
304
+ setSubmitting(false);
305
+ setAddOnConfirmOpen(true);
306
+ } else {
307
+ setSubmitting(false);
308
+ showSubmitFailedTip(_context3.t2 === null || _context3.t2 === void 0 ? void 0 : _context3.t2.message);
309
+ }
310
+ _context3.next = 77;
311
+ break;
312
+ case 76:
313
+ if ((_context3.t2 === null || _context3.t2 === void 0 ? void 0 : _context3.t2.code) === 6008) {
314
+ showInventoryInsufficientModal(_context3.t2);
315
+ } else {
316
+ setSubmitting(false);
317
+ showSubmitFailedTip(_context3.t2 === null || _context3.t2 === void 0 ? void 0 : _context3.t2.message);
318
+ }
319
+ case 77:
320
+ _context3.prev = 77;
321
+ return _context3.finish(77);
322
+ case 79:
236
323
  case "end":
237
324
  return _context3.stop();
238
325
  }
239
- }, _callee3, null, [[5, 52, 56, 58], [30, 35], [40, 45]]);
326
+ }, _callee3, null, [[5, 55, 77, 79], [33, 38], [43, 48]]);
240
327
  }));
241
328
  return function doSubmit() {
242
329
  return _ref2.apply(this, arguments);
@@ -344,6 +431,35 @@ export default function Check() {
344
431
  if (submitting) return;
345
432
  setPickupRefOpen(false);
346
433
  };
434
+ var handleAddOnConfirm = /*#__PURE__*/function () {
435
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
436
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
437
+ while (1) switch (_context6.prev = _context6.next) {
438
+ case 0:
439
+ if (!submitting) {
440
+ _context6.next = 2;
441
+ break;
442
+ }
443
+ return _context6.abrupt("return");
444
+ case 2:
445
+ setAddOnConfirmOpen(false);
446
+ // 再次提交时,OS 会自动代理到加餐模式。
447
+ _context6.next = 5;
448
+ return doSubmit();
449
+ case 5:
450
+ case "end":
451
+ return _context6.stop();
452
+ }
453
+ }, _callee6);
454
+ }));
455
+ return function handleAddOnConfirm() {
456
+ return _ref5.apply(this, arguments);
457
+ };
458
+ }();
459
+ var handleAddOnReturn = function handleAddOnReturn() {
460
+ if (submitting) return;
461
+ setAddOnConfirmOpen(false);
462
+ };
347
463
  var noteContent = /*#__PURE__*/React.createElement("div", {
348
464
  className: "pisell-scan-order-check-note"
349
465
  }, /*#__PURE__*/React.createElement("div", {
@@ -384,7 +500,32 @@ export default function Check() {
384
500
  confirmLoading: submitting,
385
501
  onCancel: handlePickupRefCancel,
386
502
  onConfirm: handlePickupRefConfirm
387
- }), submitting ? /*#__PURE__*/React.createElement("div", {
503
+ }), /*#__PURE__*/React.createElement(Modal, {
504
+ open: addOnConfirmOpen,
505
+ footer: null,
506
+ onCancel: handleAddOnReturn,
507
+ maskClosable: false,
508
+ destroyOnClose: true,
509
+ centered: true,
510
+ className: "pisell-scan-order-add-on-confirm-modal"
511
+ }, /*#__PURE__*/React.createElement("div", {
512
+ className: "pisell-scan-order-add-on-confirm-body"
513
+ }, /*#__PURE__*/React.createElement("div", {
514
+ className: "pisell-scan-order-add-on-confirm-title"
515
+ }, addOnConfirmTitle), /*#__PURE__*/React.createElement("div", {
516
+ className: "pisell-scan-order-add-on-confirm-desc"
517
+ }, addOnConfirmDescription), /*#__PURE__*/React.createElement(Button, {
518
+ type: "primary",
519
+ block: true,
520
+ size: "large",
521
+ loading: submitting,
522
+ onClick: handleAddOnConfirm
523
+ }, addOnConfirmButtonText), /*#__PURE__*/React.createElement(Button, {
524
+ block: true,
525
+ size: "large",
526
+ disabled: submitting,
527
+ onClick: handleAddOnReturn
528
+ }, addOnReturnButtonText))), submitting ? /*#__PURE__*/React.createElement("div", {
388
529
  className: "pisell-scan-order-check-loading-mask"
389
530
  }, /*#__PURE__*/React.createElement("div", {
390
531
  className: "pisell-scan-order-check-loading-panel"
@@ -80,3 +80,42 @@
80
80
  width: 64px;
81
81
  height: 64px;
82
82
  }
83
+
84
+ .pisell-scan-order-add-on-confirm-modal {
85
+ .pisell-lowcode-modal-content {
86
+ border-radius: 28px;
87
+ }
88
+
89
+ .pisell-lowcode-modal-body {
90
+ padding: 42px 32px 32px;
91
+ }
92
+ }
93
+
94
+ .pisell-scan-order-add-on-confirm-body {
95
+ display: flex;
96
+ flex-direction: column;
97
+ gap: 16px;
98
+ text-align: center;
99
+
100
+ .pisell-lowcode-btn {
101
+ height: 56px;
102
+ border-radius: 18px;
103
+ font-size: 18px;
104
+ font-weight: 700;
105
+ }
106
+ }
107
+
108
+ .pisell-scan-order-add-on-confirm-title {
109
+ color: #1f2937;
110
+ font-size: 28px;
111
+ font-weight: 800;
112
+ line-height: 1.25;
113
+ }
114
+
115
+ .pisell-scan-order-add-on-confirm-desc {
116
+ margin-bottom: 18px;
117
+ color: #667085;
118
+ font-size: 20px;
119
+ font-weight: 400;
120
+ line-height: 1.35;
121
+ }