@pisell/private-materials 6.3.139 → 6.3.140

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 (47) 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/index.js +1 -1
  5. package/build/lowcode/meta.js +1 -1
  6. package/build/lowcode/preview.js +5 -5
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +7 -7
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +6 -6
  11. package/es/components/scanOrder/components/Cart/index.js +127 -56
  12. package/es/components/scanOrder/components/Cart/index.less +11 -5
  13. package/es/components/scanOrder/components/Check/index.js +85 -80
  14. package/es/components/scanOrder/components/Content/index.js +345 -162
  15. package/es/components/scanOrder/components/Menu/index.d.ts +11 -0
  16. package/es/components/scanOrder/components/Menu/index.js +140 -169
  17. package/es/components/scanOrder/components/Voucher/index.d.ts +8 -0
  18. package/es/components/scanOrder/components/Voucher/index.js +250 -0
  19. package/es/components/scanOrder/context.js +38 -13
  20. package/es/components/scanOrder/hooks.js +4 -1
  21. package/es/components/scanOrder/locales.d.ts +65 -0
  22. package/es/components/scanOrder/locales.js +65 -0
  23. package/es/components/scanOrder/types.d.ts +10 -0
  24. package/es/components/scanOrder/utils/toShoppingCartProducts.d.ts +1 -0
  25. package/es/components/scanOrder/utils/toShoppingCartProducts.js +137 -9
  26. package/es/components/scanOrder/utils/transformProductDetail.js +21 -4
  27. package/es/components/venueBooking/components/Addons/index.js +42 -33
  28. package/es/components/venueBooking/components/Cart/index.js +26 -14
  29. package/lib/components/scanOrder/components/Cart/index.js +79 -24
  30. package/lib/components/scanOrder/components/Cart/index.less +11 -5
  31. package/lib/components/scanOrder/components/Check/index.js +28 -23
  32. package/lib/components/scanOrder/components/Content/index.js +132 -42
  33. package/lib/components/scanOrder/components/Menu/index.d.ts +11 -0
  34. package/lib/components/scanOrder/components/Menu/index.js +23 -36
  35. package/lib/components/scanOrder/components/Voucher/index.d.ts +8 -0
  36. package/lib/components/scanOrder/components/Voucher/index.js +162 -0
  37. package/lib/components/scanOrder/context.js +21 -10
  38. package/lib/components/scanOrder/hooks.js +4 -1
  39. package/lib/components/scanOrder/locales.d.ts +65 -0
  40. package/lib/components/scanOrder/locales.js +65 -0
  41. package/lib/components/scanOrder/types.d.ts +10 -0
  42. package/lib/components/scanOrder/utils/toShoppingCartProducts.d.ts +1 -0
  43. package/lib/components/scanOrder/utils/toShoppingCartProducts.js +88 -6
  44. package/lib/components/scanOrder/utils/transformProductDetail.js +10 -3
  45. package/lib/components/venueBooking/components/Addons/index.js +15 -8
  46. package/lib/components/venueBooking/components/Cart/index.js +8 -2
  47. package/package.json +1 -1
@@ -1,4 +1,8 @@
1
1
  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); }
2
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
2
6
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
7
  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); } }
4
8
  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); }); }; }
@@ -8,14 +12,17 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
8
12
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
9
13
  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
14
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
- import React, { useEffect, useMemo, useState } from 'react';
15
+ import React, { useEffect, useMemo, useState, useCallback } from 'react';
12
16
  import { Button } from '@pisell/materials';
13
17
  import { locales } from '@pisell/utils';
14
18
  import ShoppingCart from "../../../shoppingCart";
15
19
  import { useScanOrderContext } from "../../context";
20
+ import useEngineContext from "../../../../hooks/useEngineContext";
16
21
  import SubTotal from "../../../subTotal";
22
+ import VoucherCard from "../Voucher";
17
23
  import "./index.less";
18
24
  export default function Cart(props) {
25
+ var _engineContext$appHel, _engineContext$engine, _businessUtils$getApp, _businessUtils$getApp2;
19
26
  var open = props.open,
20
27
  onCancel = props.onCancel,
21
28
  onNext = props.onNext,
@@ -32,6 +39,13 @@ export default function Cart(props) {
32
39
  runModuleAction = _useScanOrderContext.runModuleAction,
33
40
  refreshViewModel = _useScanOrderContext.refreshViewModel,
34
41
  scanOrderModule = _useScanOrderContext.scanOrderModule;
42
+ var engineContext = useEngineContext();
43
+ var businessUtils = engineContext === null || engineContext === void 0 || (_engineContext$appHel = engineContext.appHelper) === null || _engineContext$appHel === void 0 || (_engineContext$appHel = _engineContext$appHel.utils) === null || _engineContext$appHel === void 0 ? void 0 : _engineContext$appHel.businessUtils;
44
+ var locale = (engineContext === null || engineContext === void 0 || (_engineContext$engine = engineContext.engine) === null || _engineContext$engine === void 0 || (_engineContext$engine = _engineContext$engine.props) === null || _engineContext$engine === void 0 ? void 0 : _engineContext$engine.locale) || 'en';
45
+ // 是否安装商品券/折扣卡应用(与 venueBooking Cart 保持一致的判定)
46
+ var hasGoodPassApp = !!(businessUtils !== null && businessUtils !== void 0 && (_businessUtils$getApp = businessUtils.getAppByModal) !== null && _businessUtils$getApp !== void 0 && _businessUtils$getApp.call(businessUtils, 'goodpass'));
47
+ var hasDiscountCardApp = !!(businessUtils !== null && businessUtils !== void 0 && (_businessUtils$getApp2 = businessUtils.getAppByModal) !== null && _businessUtils$getApp2 !== void 0 && _businessUtils$getApp2.call(businessUtils, 'discountcard'));
48
+ var showVoucher = hasGoodPassApp || hasDiscountCardApp;
35
49
  var isVisible = embedded || open;
36
50
  if (!isVisible) return null;
37
51
  var _useState = useState(null),
@@ -39,31 +53,28 @@ export default function Cart(props) {
39
53
  dineInConfig = _useState2[0],
40
54
  setDineInConfig = _useState2[1];
41
55
  // 去读 pisellos 内的配置
42
- var getConfig = /*#__PURE__*/function () {
43
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
44
- var _otherParams$dineInCo;
45
- var otherParams, dineInConfig;
46
- return _regeneratorRuntime().wrap(function _callee$(_context) {
47
- while (1) switch (_context.prev = _context.next) {
48
- case 0:
49
- _context.next = 2;
50
- return runModuleAction('getOtherParams');
51
- case 2:
52
- otherParams = _context.sent;
53
- console.log('otherParams >>>>> ', otherParams);
54
- dineInConfig = (_otherParams$dineInCo = otherParams === null || otherParams === void 0 ? void 0 : otherParams.dineInConfig) !== null && _otherParams$dineInCo !== void 0 ? _otherParams$dineInCo : {};
55
- setDineInConfig(dineInConfig);
56
- case 6:
57
- case "end":
58
- return _context.stop();
59
- }
60
- }, _callee);
61
- }));
62
- return function getConfig() {
63
- return _ref.apply(this, arguments);
64
- };
65
- }();
66
- getConfig();
56
+ var getConfig = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
57
+ var _otherParams$dineInCo;
58
+ var otherParams, dineInConfig;
59
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
60
+ while (1) switch (_context.prev = _context.next) {
61
+ case 0:
62
+ _context.next = 2;
63
+ return runModuleAction('getOtherParams');
64
+ case 2:
65
+ otherParams = _context.sent;
66
+ console.log('otherParams >>>>> ', otherParams);
67
+ dineInConfig = (_otherParams$dineInCo = otherParams === null || otherParams === void 0 ? void 0 : otherParams.dineInConfig) !== null && _otherParams$dineInCo !== void 0 ? _otherParams$dineInCo : {};
68
+ setDineInConfig(dineInConfig);
69
+ case 6:
70
+ case "end":
71
+ return _context.stop();
72
+ }
73
+ }, _callee);
74
+ })), [runModuleAction]);
75
+ useEffect(function () {
76
+ getConfig();
77
+ }, []);
67
78
 
68
79
  // 是否显示给商品添加备注
69
80
  var isShowNote = useMemo(function () {
@@ -90,10 +101,23 @@ export default function Cart(props) {
90
101
  var rawTaxRate = Number((_tempSummary$tax_rate = tempSummary === null || tempSummary === void 0 ? void 0 : tempSummary.tax_rate) !== null && _tempSummary$tax_rate !== void 0 ? _tempSummary$tax_rate : summary === null || summary === void 0 ? void 0 : summary.tax_rate);
91
102
  var normalizedTaxRate = Number.isNaN(rawTaxRate) ? 0 : rawTaxRate > 1 ? rawTaxRate / 100 : rawTaxRate;
92
103
  var isPriceIncludeTax = Boolean((_ref8 = (_tempSummary$is_price = tempSummary === null || tempSummary === void 0 ? void 0 : tempSummary.is_price_include_tax) !== null && _tempSummary$is_price !== void 0 ? _tempSummary$is_price : tempSummary === null || tempSummary === void 0 ? void 0 : tempSummary.isPriceIncludeTax) !== null && _ref8 !== void 0 ? _ref8 : summary === null || summary === void 0 ? void 0 : summary.is_price_include_tax);
104
+
105
+ /** 将 surcharges 数组映射为 SubTotalItem,amount > 0 才展示(与 venueBooking Cart 一致) */
106
+ var surchargeItems = ((summary === null || summary === void 0 ? void 0 : summary.surcharges) || []).filter(function (s) {
107
+ return Number(s === null || s === void 0 ? void 0 : s.amount) > 0;
108
+ }).map(function (s) {
109
+ var labelObj = (s === null || s === void 0 ? void 0 : s.label) || (s === null || s === void 0 ? void 0 : s.name) || {};
110
+ var label = labelObj[locale] || labelObj.en || labelObj.original || (s === null || s === void 0 ? void 0 : s.key) || '';
111
+ return {
112
+ key: (s === null || s === void 0 ? void 0 : s.key) || "surcharge_".concat(s === null || s === void 0 ? void 0 : s.surcharge_id),
113
+ label: label,
114
+ value: Number(s === null || s === void 0 ? void 0 : s.amount)
115
+ };
116
+ });
93
117
  return [{
94
118
  key: 'sub_total',
95
119
  value: Number.isNaN(subTotal) ? 0 : subTotal
96
- }, {
120
+ }].concat(_toConsumableArray(surchargeItems), [{
97
121
  key: 'tax',
98
122
  value: Number.isNaN(totalTaxFee) ? 0 : totalTaxFee,
99
123
  hidden: Number.isNaN(totalTaxFee) ? true : totalTaxFee <= 0,
@@ -107,55 +131,101 @@ export default function Cart(props) {
107
131
  value: Number.isNaN(total) ? 0 : total,
108
132
  label: locales.getText('pisell2.event.total'),
109
133
  bold: true
110
- }];
111
- }, [summary, scanOrderModule]);
134
+ }]);
135
+ }, [summary, scanOrderModule, locale]);
112
136
  var handleCartChange = /*#__PURE__*/function () {
113
137
  var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(item, type) {
114
- var _ref10, _item$product_id, _item$product_variant;
115
- var productId, productVariantId, identityKey;
138
+ var _ref10, _item$product_id, _item$product_variant, productId, productVariantId, identityKey, identity, _item$note, _ref11, _item$product_id2, _item$product_variant2, _productId, _productVariantId, _identityKey;
116
139
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
117
140
  while (1) switch (_context2.prev = _context2.next) {
118
141
  case 0:
119
- if (!(type !== 'delete')) {
120
- _context2.next = 2;
142
+ if (!(type === 'note')) {
143
+ _context2.next = 21;
121
144
  break;
122
145
  }
123
- return _context2.abrupt("return");
124
- case 2:
125
146
  productId = (_ref10 = (_item$product_id = item === null || item === void 0 ? void 0 : item.product_id) !== null && _item$product_id !== void 0 ? _item$product_id : item === null || item === void 0 ? void 0 : item.id) !== null && _ref10 !== void 0 ? _ref10 : null;
126
- productVariantId = Number((_item$product_variant = item === null || item === void 0 ? void 0 : item.product_variant_id) !== null && _item$product_variant !== void 0 ? _item$product_variant : 0);
127
- identityKey = (item === null || item === void 0 ? void 0 : item.identity_key) || (item === null || item === void 0 ? void 0 : item.rowKey) || undefined;
147
+ productVariantId = Number((_item$product_variant = item === null || item === void 0 ? void 0 : item.product_variant_id) !== null && _item$product_variant !== void 0 ? _item$product_variant : 0); // 不透明 identity 契约:UI 行级操作只信任 SDK 回灌的 identity_key,
148
+ // 禁用 rowKey 等回退路径,避免误命中其它 SKU/选项相同的行。
149
+ identityKey = item === null || item === void 0 ? void 0 : item.identity_key;
128
150
  if (!(productId === null && Number.isNaN(productVariantId))) {
129
- _context2.next = 7;
151
+ _context2.next = 6;
130
152
  break;
131
153
  }
132
154
  return _context2.abrupt("return");
133
- case 7:
134
- _context2.prev = 7;
135
- _context2.next = 10;
136
- return runModuleAction('removeProductFromOrder', {
155
+ case 6:
156
+ identity = {
137
157
  product_id: productId,
138
- product_variant_id: Number.isNaN(productVariantId) ? 0 : productVariantId,
139
- identity_key: identityKey
158
+ product_variant_id: Number.isNaN(productVariantId) ? 0 : productVariantId
159
+ };
160
+ if (typeof identityKey === 'string' && identityKey.length > 0) {
161
+ identity.identity_key = identityKey;
162
+ }
163
+ _context2.prev = 8;
164
+ _context2.next = 11;
165
+ return runModuleAction('setOrderProductLineNote', identity, String((_item$note = item === null || item === void 0 ? void 0 : item.note) !== null && _item$note !== void 0 ? _item$note : ''));
166
+ case 11:
167
+ _context2.next = 13;
168
+ return refreshViewModel();
169
+ case 13:
170
+ _context2.next = 18;
171
+ break;
172
+ case 15:
173
+ _context2.prev = 15;
174
+ _context2.t0 = _context2["catch"](8);
175
+ console.error('[scanOrder] setOrderProductLineNote failed', {
176
+ error: _context2.t0,
177
+ item: item
178
+ });
179
+ case 18:
180
+ return _context2.abrupt("return");
181
+ case 21:
182
+ if (!(type === 'delete')) {
183
+ _context2.next = 40;
184
+ break;
185
+ }
186
+ _productId = (_ref11 = (_item$product_id2 = item === null || item === void 0 ? void 0 : item.product_id) !== null && _item$product_id2 !== void 0 ? _item$product_id2 : item === null || item === void 0 ? void 0 : item.id) !== null && _ref11 !== void 0 ? _ref11 : null;
187
+ _productVariantId = Number((_item$product_variant2 = item === null || item === void 0 ? void 0 : item.product_variant_id) !== null && _item$product_variant2 !== void 0 ? _item$product_variant2 : 0);
188
+ _identityKey = item === null || item === void 0 ? void 0 : item.identity_key;
189
+ if (!(_productId === null && Number.isNaN(_productVariantId))) {
190
+ _context2.next = 27;
191
+ break;
192
+ }
193
+ return _context2.abrupt("return");
194
+ case 27:
195
+ if (!(typeof _identityKey !== 'string' || _identityKey.length === 0)) {
196
+ _context2.next = 30;
197
+ break;
198
+ }
199
+ console.error('[scanOrder] removeProductFromOrder skipped: missing identity_key', {
200
+ item: item
140
201
  });
141
- case 10:
142
- _context2.next = 12;
202
+ return _context2.abrupt("return");
203
+ case 30:
204
+ _context2.prev = 30;
205
+ _context2.next = 33;
206
+ return runModuleAction('removeProductFromOrder', {
207
+ product_id: _productId,
208
+ product_variant_id: Number.isNaN(_productVariantId) ? 0 : _productVariantId,
209
+ identity_key: _identityKey
210
+ });
211
+ case 33:
212
+ _context2.next = 35;
143
213
  return refreshViewModel();
144
- case 12:
145
- _context2.next = 17;
214
+ case 35:
215
+ _context2.next = 40;
146
216
  break;
147
- case 14:
148
- _context2.prev = 14;
149
- _context2.t0 = _context2["catch"](7);
217
+ case 37:
218
+ _context2.prev = 37;
219
+ _context2.t1 = _context2["catch"](30);
150
220
  console.error('[scanOrder] removeProductFromOrder failed', {
151
- error: _context2.t0,
221
+ error: _context2.t1,
152
222
  item: item
153
223
  });
154
- case 17:
224
+ case 40:
155
225
  case "end":
156
226
  return _context2.stop();
157
227
  }
158
- }, _callee2, null, [[7, 14]]);
228
+ }, _callee2, null, [[8, 15], [30, 37]]);
159
229
  }));
160
230
  return function handleCartChange(_x, _x2) {
161
231
  return _ref9.apply(this, arguments);
@@ -183,7 +253,7 @@ export default function Cart(props) {
183
253
  isHideClearCart: true,
184
254
  onChange: handleCartChange
185
255
  });
186
- var cartSubtotalSection = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SubTotal, {
256
+ var cartSubtotalSection = /*#__PURE__*/React.createElement(React.Fragment, null, showVoucher ? /*#__PURE__*/React.createElement(VoucherCard, null) : null, /*#__PURE__*/React.createElement(SubTotal, {
187
257
  list: subTotalList,
188
258
  style: {
189
259
  padding: 0
@@ -191,8 +261,9 @@ export default function Cart(props) {
191
261
  }), extraContent ? /*#__PURE__*/React.createElement("div", {
192
262
  className: "pisell-scan-order-cart-extra-content"
193
263
  }, extraContent) : null);
264
+ var cartBodyClassName = embedded ? 'pisell-scan-order-cart-body pisell-scan-order-cart-body-embedded' : 'pisell-scan-order-cart-body';
194
265
  var cartBodyContent = /*#__PURE__*/React.createElement("div", {
195
- className: "pisell-scan-order-cart-body"
266
+ className: cartBodyClassName
196
267
  }, cartLineItems, cartSubtotalSection);
197
268
  if (embedded) {
198
269
  return /*#__PURE__*/React.createElement(React.Fragment, null, cartBodyContent, /*#__PURE__*/React.createElement("div", {
@@ -118,16 +118,22 @@
118
118
  cursor: not-allowed;
119
119
  }
120
120
 
121
+ /* 移动端:结算内嵌卡 — 与 pisell-scan-order-content-mobile-wrap 的底部留白配合;
122
+ * 不再在 cart-body 上重复 96px,否则与外层叠加会出现大块空白,sticky 在整页滚动时也会与内容同步位移 */
121
123
  .pisell-scan-order-content-mobile-wrap {
122
- .pisell-scan-order-cart-body {
123
- padding-bottom: 96px;
124
+ .pisell-scan-order-cart-body-embedded {
125
+ padding-bottom: 16px;
124
126
  }
125
127
 
126
128
  .pisell-scan-order-cart-embedded-footer {
127
- position: sticky;
129
+ position: fixed;
130
+ left: 0;
131
+ right: 0;
128
132
  bottom: 0;
129
- z-index: 5;
130
- padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
133
+ z-index: 28;
134
+ padding: 12px 16px calc(20px + env(safe-area-inset-bottom, 0px));
135
+ border-top: 1px solid #eaecf0;
136
+ background: #fff;
131
137
  box-shadow: 0 -4px 10px rgba(16, 24, 40, 0.06);
132
138
  }
133
139
  }
@@ -8,10 +8,9 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
8
8
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
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
- import React, { useMemo, useState } from 'react';
11
+ import React, { useMemo, useState, useCallback, useEffect } from 'react';
12
12
  import { Input, message } from 'antd';
13
13
  import { locales } from '@pisell/utils';
14
- import { PisellToast } from '@pisell/materials';
15
14
  import Cart from "../Cart";
16
15
  import FulfillmentMode from "../FulfillmentMode";
17
16
  import ManualPickupRefModal from "../ManualPickupRefModal";
@@ -45,31 +44,28 @@ export default function Check() {
45
44
  dineInConfig = _useState8[0],
46
45
  setDineInConfig = _useState8[1];
47
46
  // 去读 pisellos 内的配置
48
- var getConfig = /*#__PURE__*/function () {
49
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
50
- var _otherParams$dineInCo;
51
- var otherParams, dineInConfig;
52
- return _regeneratorRuntime().wrap(function _callee$(_context) {
53
- while (1) switch (_context.prev = _context.next) {
54
- case 0:
55
- _context.next = 2;
56
- return runModuleAction('getOtherParams');
57
- case 2:
58
- otherParams = _context.sent;
59
- console.log('otherParams >>>>> ', otherParams);
60
- dineInConfig = (_otherParams$dineInCo = otherParams === null || otherParams === void 0 ? void 0 : otherParams.dineInConfig) !== null && _otherParams$dineInCo !== void 0 ? _otherParams$dineInCo : {};
61
- setDineInConfig(dineInConfig);
62
- case 6:
63
- case "end":
64
- return _context.stop();
65
- }
66
- }, _callee);
67
- }));
68
- return function getConfig() {
69
- return _ref.apply(this, arguments);
70
- };
71
- }();
72
- getConfig();
47
+ var getConfig = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
48
+ var _otherParams$dineInCo;
49
+ var otherParams, dineInConfig;
50
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
51
+ while (1) switch (_context.prev = _context.next) {
52
+ case 0:
53
+ _context.next = 2;
54
+ return runModuleAction('getOtherParams');
55
+ case 2:
56
+ otherParams = _context.sent;
57
+ console.log('otherParams >>>>> ', otherParams);
58
+ dineInConfig = (_otherParams$dineInCo = otherParams === null || otherParams === void 0 ? void 0 : otherParams.dineInConfig) !== null && _otherParams$dineInCo !== void 0 ? _otherParams$dineInCo : {};
59
+ setDineInConfig(dineInConfig);
60
+ case 6:
61
+ case "end":
62
+ return _context.stop();
63
+ }
64
+ }, _callee);
65
+ })), [runModuleAction]);
66
+ useEffect(function () {
67
+ getConfig();
68
+ }, []);
73
69
 
74
70
  // 是否展示订单级备注
75
71
  var isShowOrderNote = useMemo(function () {
@@ -87,54 +83,66 @@ export default function Check() {
87
83
  var productsTitle = useMemo(function () {
88
84
  return String(locales.getText('pisell2.scan.order.products.title') || 'Products');
89
85
  }, []);
86
+ var showCheckStepEmptyCartTip = function showCheckStepEmptyCartTip() {
87
+ message.error(locales.getText('pisell2.scan.order.check.cart.empty.tip') || 'Please go back to add products');
88
+ };
90
89
  var doSubmit = /*#__PURE__*/function () {
91
90
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
92
- var res, _res$data, _viewModel$summary, _res$data2, _res$data3, _utils$getApp, _app$history, _app$history2, link, app;
91
+ var items, res, _res$data, _res$data2, _viewModel$summary, _res$data3, _res$data4, _utils$getApp, _app$history, _app$history2, link, app;
93
92
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
94
93
  while (1) switch (_context3.prev = _context3.next) {
95
94
  case 0:
96
- _context3.prev = 0;
95
+ items = (viewModel === null || viewModel === void 0 ? void 0 : viewModel.cartItems) || [];
96
+ if (!(items.length === 0)) {
97
+ _context3.next = 5;
98
+ break;
99
+ }
100
+ showCheckStepEmptyCartTip();
101
+ setSubmitting(false);
102
+ return _context3.abrupt("return");
103
+ case 5:
104
+ _context3.prev = 5;
97
105
  setSubmitting(true);
98
- _context3.next = 4;
106
+ _context3.next = 9;
99
107
  return runModuleAction('updateTempOrderNote', note);
100
- case 4:
101
- _context3.next = 6;
108
+ case 9:
109
+ _context3.next = 11;
102
110
  return runModuleAction('submitScanOrder');
103
- case 6:
111
+ case 11:
104
112
  res = _context3.sent;
105
113
  console.log('submitScanOrder >>>>> ', res);
106
114
  // 下单成功:清空步骤缓存(step / gate / entryContext),避免残留影响下次扫码
107
115
  clearStepCache();
108
- if (!(dineInConfig !== null && dineInConfig !== void 0 && dineInConfig['workflow.require_payment_on_submit'])) {
109
- _context3.next = 13;
116
+ if (!(dineInConfig !== null && dineInConfig !== void 0 && dineInConfig['sale.require_payment_on_submit'] && !isAdditionalOrder)) {
117
+ _context3.next = 26;
110
118
  break;
111
119
  }
120
+ _context3.prev = 15;
121
+ _context3.next = 18;
122
+ return runModuleAction('restoreOrder');
123
+ case 18:
124
+ _context3.next = 23;
125
+ break;
126
+ case 20:
127
+ _context3.prev = 20;
128
+ _context3.t0 = _context3["catch"](15);
129
+ console.warn('[scanOrder] restoreOrder after payment failed', _context3.t0);
130
+ case 23:
112
131
  utils.action({
113
132
  type: 'pisell1.payment',
114
133
  data: {
115
134
  order_id: res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.order_id,
116
- total_amount: viewModel === null || viewModel === void 0 || (_viewModel$summary = viewModel.summary) === null || _viewModel$summary === void 0 ? void 0 : _viewModel$summary.total_amount
135
+ total_amount: (res === null || res === void 0 || (_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : _res$data2.order_wait_pay_amount) || (viewModel === null || viewModel === void 0 || (_viewModel$summary = viewModel.summary) === null || _viewModel$summary === void 0 ? void 0 : _viewModel$summary.total_amount)
117
136
  },
118
137
  callback: function () {
119
138
  var _callback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_e) {
120
139
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
121
140
  while (1) switch (_context2.prev = _context2.next) {
122
141
  case 0:
123
- _context2.prev = 0;
124
- _context2.next = 3;
125
- return runModuleAction('restoreOrder');
126
- case 3:
127
- _context2.next = 8;
128
- break;
129
- case 5:
130
- _context2.prev = 5;
131
- _context2.t0 = _context2["catch"](0);
132
- console.warn('[scanOrder] restoreOrder after payment failed', _context2.t0);
133
- case 8:
134
142
  case "end":
135
143
  return _context2.stop();
136
144
  }
137
- }, _callee2, null, [[0, 5]]);
145
+ }, _callee2);
138
146
  }));
139
147
  function callback(_x) {
140
148
  return _callback.apply(this, arguments);
@@ -142,25 +150,25 @@ export default function Check() {
142
150
  return callback;
143
151
  }()
144
152
  });
145
- _context3.next = 25;
153
+ _context3.next = 38;
146
154
  break;
147
- case 13:
148
- if (!(res !== null && res !== void 0 && (_res$data2 = res.data) !== null && _res$data2 !== void 0 && _res$data2.order_id)) {
149
- _context3.next = 25;
155
+ case 26:
156
+ if (!(res !== null && res !== void 0 && (_res$data3 = res.data) !== null && _res$data3 !== void 0 && _res$data3.order_id)) {
157
+ _context3.next = 38;
150
158
  break;
151
159
  }
152
- _context3.prev = 14;
153
- _context3.next = 17;
160
+ _context3.prev = 27;
161
+ _context3.next = 30;
154
162
  return runModuleAction('restoreOrder');
155
- case 17:
156
- _context3.next = 22;
163
+ case 30:
164
+ _context3.next = 35;
157
165
  break;
158
- case 19:
159
- _context3.prev = 19;
160
- _context3.t0 = _context3["catch"](14);
161
- console.warn('[scanOrder] restoreOrder before redirect failed', _context3.t0);
162
- case 22:
163
- link = "/order/details?id=".concat(res === null || res === void 0 || (_res$data3 = res.data) === null || _res$data3 === void 0 ? void 0 : _res$data3.order_id);
166
+ case 32:
167
+ _context3.prev = 32;
168
+ _context3.t1 = _context3["catch"](27);
169
+ console.warn('[scanOrder] restoreOrder before redirect failed', _context3.t1);
170
+ case 35:
171
+ link = "/order/details?id=".concat(res === null || res === void 0 || (_res$data4 = res.data) === null || _res$data4 === void 0 ? void 0 : _res$data4.order_id);
164
172
  app = utils === null || utils === void 0 || (_utils$getApp = utils.getApp) === null || _utils$getApp === void 0 ? void 0 : _utils$getApp.call(utils);
165
173
  if (app !== null && app !== void 0 && (_app$history = app.history) !== null && _app$history !== void 0 && _app$history.replace) {
166
174
  app.history.replace(link);
@@ -169,26 +177,26 @@ export default function Check() {
169
177
  } else {
170
178
  location.replace(link);
171
179
  }
172
- case 25:
173
- _context3.next = 27;
180
+ case 38:
181
+ _context3.next = 40;
174
182
  return refreshViewModel();
175
- case 27:
176
- _context3.next = 33;
183
+ case 40:
184
+ _context3.next = 46;
177
185
  break;
178
- case 29:
179
- _context3.prev = 29;
180
- _context3.t1 = _context3["catch"](0);
181
- console.error('[scanOrder] submitScanOrder failed', _context3.t1);
182
- message.error((_context3.t1 === null || _context3.t1 === void 0 ? void 0 : _context3.t1.message) || 'Submit order failed');
183
- case 33:
184
- _context3.prev = 33;
186
+ case 42:
187
+ _context3.prev = 42;
188
+ _context3.t2 = _context3["catch"](5);
189
+ console.error('[scanOrder] submitScanOrder failed', _context3.t2);
190
+ message.error((_context3.t2 === null || _context3.t2 === void 0 ? void 0 : _context3.t2.message) || 'Submit order failed');
191
+ case 46:
192
+ _context3.prev = 46;
185
193
  setSubmitting(false);
186
- return _context3.finish(33);
187
- case 36:
194
+ return _context3.finish(46);
195
+ case 49:
188
196
  case "end":
189
197
  return _context3.stop();
190
198
  }
191
- }, _callee3, null, [[0, 29, 33, 36], [14, 19]]);
199
+ }, _callee3, null, [[5, 42, 46, 49], [15, 20], [27, 32]]);
192
200
  }));
193
201
  return function doSubmit() {
194
202
  return _ref2.apply(this, arguments);
@@ -211,10 +219,7 @@ export default function Check() {
211
219
  _context4.next = 6;
212
220
  break;
213
221
  }
214
- PisellToast({
215
- content: String(locales.getText('pisell2.scan.order.products.empty.tip') || 'Please select products'),
216
- duration: 2
217
- });
222
+ showCheckStepEmptyCartTip();
218
223
  return _context4.abrupt("return");
219
224
  case 6:
220
225
  if (!isAdditionalOrder) {