@pisell/pisellos 2.2.153 → 2.2.156

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 (88) hide show
  1. package/dist/core/index.js +1 -0
  2. package/dist/modules/Cart/utils/cartProduct.js +1 -1
  3. package/dist/modules/Order/index.d.ts +3 -1
  4. package/dist/modules/Order/index.js +231 -160
  5. package/dist/modules/Order/types.d.ts +19 -0
  6. package/dist/modules/Order/utils.js +7 -6
  7. package/dist/modules/Payment/index.d.ts +4 -0
  8. package/dist/modules/Payment/index.js +567 -505
  9. package/dist/modules/Payment/types.d.ts +29 -9
  10. package/dist/modules/SalesSummary/index.d.ts +7 -5
  11. package/dist/modules/SalesSummary/index.js +35 -11
  12. package/dist/plugins/app.d.ts +2 -0
  13. package/dist/server/index.d.ts +2 -5
  14. package/dist/server/index.js +58 -66
  15. package/dist/server/modules/index.d.ts +1 -1
  16. package/dist/server/modules/products/index.d.ts +12 -1
  17. package/dist/server/modules/products/index.js +169 -78
  18. package/dist/server/modules/products/types.d.ts +11 -0
  19. package/dist/server/modules/products/types.js +4 -0
  20. package/dist/server/utils/product.js +2 -2
  21. package/dist/solution/BaseSales/index.d.ts +26 -2
  22. package/dist/solution/BaseSales/index.js +342 -112
  23. package/dist/solution/BaseSales/types.d.ts +4 -4
  24. package/dist/solution/BaseSales/types.js +4 -4
  25. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +62 -0
  26. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +116 -0
  27. package/dist/solution/BaseSales/utils.js +3 -3
  28. package/dist/solution/BookingByStep/index.d.ts +2 -2
  29. package/dist/solution/BookingTicket/index.d.ts +11 -13
  30. package/dist/solution/BookingTicket/index.js +23 -37
  31. package/dist/solution/BookingTicket/types.d.ts +9 -6
  32. package/dist/solution/BookingTicket/types.js +6 -3
  33. package/dist/solution/BookingTicket/utils/cartView.d.ts +7 -12
  34. package/dist/solution/BookingTicket/utils/cartView.js +52 -14
  35. package/dist/solution/BookingTicket/utils/orderCustomer.d.ts +4 -0
  36. package/dist/solution/BookingTicket/utils/orderCustomer.js +31 -0
  37. package/dist/solution/BookingTicket/utils/scan/cloudSearch.d.ts +4 -0
  38. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +36 -0
  39. package/dist/solution/BookingTicket/utils/scan/handleScan.js +2 -2
  40. package/dist/solution/Sales/index.d.ts +3 -0
  41. package/dist/solution/Sales/index.js +85 -43
  42. package/dist/solution/Sales/types.d.ts +3 -0
  43. package/dist/solution/ScanOrder/types.d.ts +4 -4
  44. package/dist/solution/ScanOrder/types.js +4 -4
  45. package/dist/solution/ScanOrder/utils.js +3 -3
  46. package/lib/core/index.js +1 -0
  47. package/lib/model/strategy/adapter/promotion/index.js +49 -0
  48. package/lib/modules/Cart/utils/cartProduct.js +1 -1
  49. package/lib/modules/Order/index.d.ts +3 -1
  50. package/lib/modules/Order/index.js +39 -7
  51. package/lib/modules/Order/types.d.ts +19 -0
  52. package/lib/modules/Order/utils.js +4 -2
  53. package/lib/modules/Payment/index.d.ts +4 -0
  54. package/lib/modules/Payment/index.js +26 -2
  55. package/lib/modules/Payment/types.d.ts +29 -9
  56. package/lib/modules/SalesSummary/index.d.ts +7 -5
  57. package/lib/modules/SalesSummary/index.js +29 -9
  58. package/lib/plugins/app.d.ts +2 -0
  59. package/lib/server/index.d.ts +2 -5
  60. package/lib/server/index.js +38 -58
  61. package/lib/server/modules/index.d.ts +1 -1
  62. package/lib/server/modules/products/index.d.ts +12 -1
  63. package/lib/server/modules/products/index.js +69 -9
  64. package/lib/server/modules/products/types.d.ts +11 -0
  65. package/lib/server/utils/product.js +2 -2
  66. package/lib/solution/BaseSales/index.d.ts +26 -2
  67. package/lib/solution/BaseSales/index.js +169 -3
  68. package/lib/solution/BaseSales/types.d.ts +4 -4
  69. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +62 -0
  70. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +155 -0
  71. package/lib/solution/BaseSales/utils.js +3 -3
  72. package/lib/solution/BookingByStep/index.d.ts +2 -2
  73. package/lib/solution/BookingTicket/index.d.ts +11 -13
  74. package/lib/solution/BookingTicket/index.js +17 -27
  75. package/lib/solution/BookingTicket/types.d.ts +9 -6
  76. package/lib/solution/BookingTicket/utils/cartView.d.ts +7 -12
  77. package/lib/solution/BookingTicket/utils/cartView.js +44 -18
  78. package/lib/solution/BookingTicket/utils/orderCustomer.d.ts +4 -0
  79. package/lib/solution/BookingTicket/utils/orderCustomer.js +58 -0
  80. package/lib/solution/BookingTicket/utils/scan/cloudSearch.d.ts +4 -0
  81. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +14 -0
  82. package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -1
  83. package/lib/solution/Sales/index.d.ts +3 -0
  84. package/lib/solution/Sales/index.js +50 -15
  85. package/lib/solution/Sales/types.d.ts +3 -0
  86. package/lib/solution/ScanOrder/types.d.ts +4 -4
  87. package/lib/solution/ScanOrder/utils.js +3 -3
  88. package/package.json +1 -1
@@ -0,0 +1,31 @@
1
+ /** 从 ICustomer 富字段解析展示名(与 SalesSdk getClientName 语义对齐)。 */
2
+ function resolveCustomerDisplayName(customer) {
3
+ var _customer$name;
4
+ var c = customer;
5
+ var displayName = c.display_name;
6
+ if (typeof displayName === 'string' && displayName) return displayName;
7
+ var nickname = c.nickname;
8
+ if (typeof nickname === 'string' && nickname) return nickname;
9
+ var firstName = c.first_name;
10
+ var lastName = c.last_name;
11
+ if (typeof firstName === 'string' && firstName || typeof lastName === 'string' && lastName) {
12
+ return "".concat(typeof firstName === 'string' ? firstName : '', " ").concat(typeof lastName === 'string' ? lastName : '').trim();
13
+ }
14
+ var customerName = c.customer_name;
15
+ if (typeof customerName === 'string' && customerName) return customerName;
16
+ return (_customer$name = customer.name) !== null && _customer$name !== void 0 ? _customer$name : '';
17
+ }
18
+
19
+ /** 将 ICustomer 格式化为写入 tempOrder 的协议字段。 */
20
+ export function formatOrderCustomerPatch(customer) {
21
+ var _customer$phone, _customer$email, _country_calling_code, _country_calling_code2;
22
+ var rawId = customer.id;
23
+ var numericId = typeof rawId === 'number' ? rawId : rawId !== undefined && rawId !== null && rawId !== '' ? Number(rawId) : null;
24
+ return {
25
+ customer_id: Number.isFinite(numericId) ? numericId : null,
26
+ customer_name: resolveCustomerDisplayName(customer),
27
+ phone: (_customer$phone = customer.phone) !== null && _customer$phone !== void 0 ? _customer$phone : '',
28
+ email: (_customer$email = customer.email) !== null && _customer$email !== void 0 ? _customer$email : '',
29
+ country_calling_code: (_country_calling_code = (_country_calling_code2 = customer.country_calling_code) === null || _country_calling_code2 === void 0 ? void 0 : _country_calling_code2.toString()) !== null && _country_calling_code !== void 0 ? _country_calling_code : ''
30
+ };
31
+ }
@@ -20,3 +20,7 @@ export declare const searchProduct: (request: RequestPlugin, code: string) => Pr
20
20
  searchType: string;
21
21
  response: any;
22
22
  }>;
23
+ export declare const searchOrder: (request: RequestPlugin, code: string) => Promise<{
24
+ searchType: string;
25
+ response: any;
26
+ }>;
@@ -156,4 +156,40 @@ export var searchProduct = /*#__PURE__*/function () {
156
156
  return function searchProduct(_x5, _x6) {
157
157
  return _ref3.apply(this, arguments);
158
158
  };
159
+ }();
160
+ export var searchOrder = /*#__PURE__*/function () {
161
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(request, code) {
162
+ var res;
163
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
164
+ while (1) switch (_context4.prev = _context4.next) {
165
+ case 0:
166
+ _context4.prev = 0;
167
+ _context4.next = 3;
168
+ return request === null || request === void 0 ? void 0 : request.get("/order/sales/".concat(code));
169
+ case 3:
170
+ res = _context4.sent;
171
+ console.log('searchOrder>>>>>>>', res);
172
+ if (!((res === null || res === void 0 ? void 0 : res.code) == 200 && !!(res !== null && res !== void 0 && res.data))) {
173
+ _context4.next = 7;
174
+ break;
175
+ }
176
+ return _context4.abrupt("return", {
177
+ searchType: 'order',
178
+ response: res
179
+ });
180
+ case 7:
181
+ throw new Error('没有找到对应的识别码');
182
+ case 10:
183
+ _context4.prev = 10;
184
+ _context4.t0 = _context4["catch"](0);
185
+ throw _context4.t0;
186
+ case 13:
187
+ case "end":
188
+ return _context4.stop();
189
+ }
190
+ }, _callee4, null, [[0, 10]]);
191
+ }));
192
+ return function searchOrder(_x7, _x8) {
193
+ return _ref4.apply(this, arguments);
194
+ };
159
195
  }();
@@ -2,7 +2,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
2
2
  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
3
  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
4
  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); }); }; }
5
- import { searchWalletPass, searchWallet, searchProduct } from "./cloudSearch";
5
+ import { searchWalletPass, searchWallet, searchProduct, searchOrder } from "./cloudSearch";
6
6
  import scanCache from "./scanCache";
7
7
 
8
8
  /**
@@ -159,7 +159,7 @@ export var handleGlobalScan = function handleGlobalScan(request, localSearch) {
159
159
  if (value.startsWith('WL')) {
160
160
  requestList = [searchWallet(request, value)];
161
161
  } else {
162
- requestList = [searchWalletPass(request, value), searchWallet(request, value), searchProduct(request, value)];
162
+ requestList = [searchWalletPass(request, value), searchWallet(request, value), searchProduct(request, value), searchOrder(request, value)];
163
163
  }
164
164
  return requestList;
165
165
  };
@@ -82,6 +82,9 @@ export declare class SalesImpl extends BaseModule implements Module, SalesModule
82
82
  private getResourceId;
83
83
  private getBookingAppointmentStatus;
84
84
  private getBookingOrderPaymentStatus;
85
+ private countBookingOrders;
86
+ private countCompletedBookings;
87
+ private groupBookingsByResource;
85
88
  private isBookingMatchedResource;
86
89
  private sortMatchedBookings;
87
90
  /**
@@ -409,6 +409,43 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
409
409
  var _booking$order$paymen, _booking$order;
410
410
  return String((_booking$order$paymen = (_booking$order = booking.order) === null || _booking$order === void 0 ? void 0 : _booking$order.payment_status) !== null && _booking$order$paymen !== void 0 ? _booking$order$paymen : '');
411
411
  }
412
+ }, {
413
+ key: "countBookingOrders",
414
+ value: function countBookingOrders(bookings) {
415
+ var orderIds = new Set();
416
+ bookings.forEach(function (booking) {
417
+ var _order_id, _booking$order2;
418
+ var orderId = (_order_id = booking.order_id) !== null && _order_id !== void 0 ? _order_id : (_booking$order2 = booking.order) === null || _booking$order2 === void 0 ? void 0 : _booking$order2.order_id;
419
+ if (orderId === undefined || orderId === null) return;
420
+ orderIds.add(String(orderId));
421
+ });
422
+ return orderIds.size;
423
+ }
424
+ }, {
425
+ key: "countCompletedBookings",
426
+ value: function countCompletedBookings(bookings) {
427
+ var _this2 = this;
428
+ return bookings.filter(function (booking) {
429
+ return _this2.getBookingAppointmentStatus(booking) === 'completed';
430
+ }).length;
431
+ }
432
+ }, {
433
+ key: "groupBookingsByResource",
434
+ value: function groupBookingsByResource(bookingList) {
435
+ var bookingMap = new Map();
436
+ bookingList.forEach(function (booking) {
437
+ if (!Array.isArray(booking.resources)) return;
438
+ booking.resources.forEach(function (resource) {
439
+ var relationId = resource === null || resource === void 0 ? void 0 : resource.relation_id;
440
+ if (relationId === undefined || relationId === null) return;
441
+ var key = String(relationId);
442
+ var list = bookingMap.get(key) || [];
443
+ list.push(booking);
444
+ bookingMap.set(key, list);
445
+ });
446
+ });
447
+ return bookingMap;
448
+ }
412
449
  }, {
413
450
  key: "isBookingMatchedResource",
414
451
  value: function isBookingMatchedResource(booking, resourceId) {
@@ -422,10 +459,10 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
422
459
  }, {
423
460
  key: "sortMatchedBookings",
424
461
  value: function sortMatchedBookings(bookings) {
425
- var _this2 = this;
462
+ var _this3 = this;
426
463
  return _toConsumableArray(bookings).sort(function (left, right) {
427
- var leftStartAt = _this2.toBookingDateTime(left.start_date, left.start_time).valueOf();
428
- var rightStartAt = _this2.toBookingDateTime(right.start_date, right.start_time).valueOf();
464
+ var leftStartAt = _this3.toBookingDateTime(left.start_date, left.start_time).valueOf();
465
+ var rightStartAt = _this3.toBookingDateTime(right.start_date, right.start_time).valueOf();
429
466
  return leftStartAt - rightStartAt;
430
467
  });
431
468
  }
@@ -440,17 +477,17 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
440
477
  }, {
441
478
  key: "pickBookingsForCurrentPoint",
442
479
  value: function pickBookingsForCurrentPoint(current, bookings) {
443
- var _this3 = this;
480
+ var _this4 = this;
444
481
  if (bookings.length === 0) return [];
445
482
  var currentDayStart = current.startOf('day');
446
483
  var currentDayEnd = current.endOf('day');
447
484
 
448
485
  // 仅保留与 current 当天有时间交集的预约,避免跨天误命中
449
486
  var dayScopedBookings = bookings.filter(function (booking) {
450
- var startAt = _this3.toBookingDateTime(booking.start_date, booking.start_time);
451
- var endAt = _this3.toBookingDateTime(booking.end_date, booking.end_time);
487
+ var startAt = _this4.toBookingDateTime(booking.start_date, booking.start_time);
488
+ var endAt = _this4.toBookingDateTime(booking.end_date, booking.end_time);
452
489
  if (!startAt.isValid() || !endAt.isValid()) return false;
453
- return _this3.isSameOrBefore(startAt, currentDayEnd) && _this3.isSameOrAfter(endAt, currentDayStart);
490
+ return _this4.isSameOrBefore(startAt, currentDayEnd) && _this4.isSameOrAfter(endAt, currentDayStart);
454
491
  });
455
492
  if (dayScopedBookings.length === 0) return [];
456
493
  var appendNextStartGroupIfNeeded = function appendNextStartGroupIfNeeded(selectedBookings) {
@@ -460,21 +497,21 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
460
497
  });
461
498
  if (!shouldAppendNextGroup) return selectedBookings;
462
499
  var selectedStartValues = new Set(selectedBookings.map(function (booking) {
463
- return _this3.toBookingDateTime(booking.start_date, booking.start_time);
500
+ return _this4.toBookingDateTime(booking.start_date, booking.start_time);
464
501
  }).filter(function (startAt) {
465
502
  return startAt.isValid();
466
503
  }).map(function (startAt) {
467
504
  return startAt.valueOf();
468
505
  }));
469
506
  var futureCandidates = dayScopedBookings.filter(function (booking) {
470
- var startAt = _this3.toBookingDateTime(booking.start_date, booking.start_time);
507
+ var startAt = _this4.toBookingDateTime(booking.start_date, booking.start_time);
471
508
  if (!startAt.isValid()) return false;
472
509
  return startAt.isAfter(current) && !selectedStartValues.has(startAt.valueOf());
473
510
  });
474
511
  if (futureCandidates.length === 0) return selectedBookings;
475
- var nextStartAt = _this3.toBookingDateTime(futureCandidates[0].start_date, futureCandidates[0].start_time).valueOf();
512
+ var nextStartAt = _this4.toBookingDateTime(futureCandidates[0].start_date, futureCandidates[0].start_time).valueOf();
476
513
  var nextStartGroup = futureCandidates.filter(function (booking) {
477
- var startAt = _this3.toBookingDateTime(booking.start_date, booking.start_time);
514
+ var startAt = _this4.toBookingDateTime(booking.start_date, booking.start_time);
478
515
  return startAt.isValid() && startAt.valueOf() === nextStartAt;
479
516
  });
480
517
  if (nextStartGroup.length === 0) return selectedBookings;
@@ -486,10 +523,10 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
486
523
 
487
524
  // active: current 处于 [startAt, endAt] 区间
488
525
  var activeBookings = dayScopedBookings.filter(function (booking) {
489
- var startAt = _this3.toBookingDateTime(booking.start_date, booking.start_time);
490
- var endAt = _this3.toBookingDateTime(booking.end_date, booking.end_time);
526
+ var startAt = _this4.toBookingDateTime(booking.start_date, booking.start_time);
527
+ var endAt = _this4.toBookingDateTime(booking.end_date, booking.end_time);
491
528
  if (!startAt.isValid() || !endAt.isValid()) return false;
492
- return _this3.isSameOrAfter(current, startAt) && _this3.isSameOrBefore(current, endAt);
529
+ return _this4.isSameOrAfter(current, startAt) && _this4.isSameOrBefore(current, endAt);
493
530
  });
494
531
  if (activeBookings.length > 0) return appendNextStartGroupIfNeeded(activeBookings);
495
532
 
@@ -501,13 +538,13 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
501
538
 
502
539
  // upcoming: 从未来预约里只取最早那一组(同 start_time)
503
540
  var upcoming = dayScopedBookings.filter(function (booking) {
504
- var startAt = _this3.toBookingDateTime(booking.start_date, booking.start_time);
541
+ var startAt = _this4.toBookingDateTime(booking.start_date, booking.start_time);
505
542
  return startAt.isValid() && startAt.isAfter(current) && startAt.isSame(current, 'day');
506
543
  });
507
544
  if (upcoming.length > 0) {
508
545
  var firstStartAt = this.toBookingDateTime(upcoming[0].start_date, upcoming[0].start_time).valueOf();
509
546
  var upcomingStartGroup = upcoming.filter(function (booking) {
510
- var startAt = _this3.toBookingDateTime(booking.start_date, booking.start_time);
547
+ var startAt = _this4.toBookingDateTime(booking.start_date, booking.start_time);
511
548
  return startAt.valueOf() === firstStartAt;
512
549
  });
513
550
  return appendNextStartGroupIfNeeded(upcomingStartGroup);
@@ -560,10 +597,10 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
560
597
  }, {
561
598
  key: "normalizeResourceBookings",
562
599
  value: function normalizeResourceBookings(current, deviceCurrent, bookingList) {
563
- var _this4 = this;
600
+ var _this5 = this;
564
601
  var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
565
602
  var normalizedBookings = bookingList.map(function (booking) {
566
- return _this4.normalizeMatchedBooking(current, deviceCurrent, booking, options);
603
+ return _this5.normalizeMatchedBooking(current, deviceCurrent, booking, options);
567
604
  }).filter(function (booking) {
568
605
  return Boolean(booking);
569
606
  }).filter(function (booking) {
@@ -693,7 +730,7 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
693
730
  var _getResourceBookingList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(currentTime) {
694
731
  var _resourceResponse$dat,
695
732
  _resourceResponse$dat2,
696
- _this5 = this;
733
+ _this6 = this;
697
734
  var bookingList,
698
735
  deviceTime,
699
736
  current,
@@ -701,6 +738,7 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
701
738
  resourceResponse,
702
739
  resourceList,
703
740
  normalizedBookings,
741
+ rawBookingMap,
704
742
  bookingMap,
705
743
  list,
706
744
  _args5 = arguments;
@@ -745,26 +783,21 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
745
783
  case 14:
746
784
  // 全局先做 booking 标准化 + start_time 升序,后续映射直接复用
747
785
  normalizedBookings = this.normalizeResourceBookings(current, deviceCurrent, bookingList); // 建立 resourceId -> bookings[] 倒排索引,加速资源匹配
748
- bookingMap = new Map();
749
- normalizedBookings.forEach(function (booking) {
750
- if (!Array.isArray(booking.resources)) return;
751
- booking.resources.forEach(function (resource) {
752
- var relationId = resource === null || resource === void 0 ? void 0 : resource.relation_id;
753
- if (relationId === undefined || relationId === null) return;
754
- var key = String(relationId);
755
- var list = bookingMap.get(key) || [];
756
- list.push(booking);
757
- bookingMap.set(key, list);
758
- });
759
- });
760
-
761
- // 输出:每个资源都返回;bookings 可能是 0 / 1 / 多条(并发场景)
786
+ rawBookingMap = this.groupBookingsByResource(bookingList);
787
+ bookingMap = this.groupBookingsByResource(normalizedBookings); // 输出:每个资源都返回;bookings 可能是 0 / 1 / 多条(并发场景)
762
788
  list = resourceList.map(function (resource) {
763
- var resourceId = _this5.getResourceId(resource);
789
+ var resourceId = _this6.getResourceId(resource);
790
+ var rawMatchedBookings = rawBookingMap.get(String(resourceId)) || [];
764
791
  var matchedBookings = bookingMap.get(String(resourceId)) || [];
765
- var bookings = _this5.pickBookingsForCurrentPoint(current, matchedBookings);
792
+ var orderCount = _this6.countBookingOrders(rawMatchedBookings);
793
+ var bookingCount = rawMatchedBookings.length;
794
+ var compeleteBookingCount = _this6.countCompletedBookings(rawMatchedBookings);
795
+ var bookings = _this6.pickBookingsForCurrentPoint(current, matchedBookings);
766
796
  return _objectSpread(_objectSpread({}, resource), {}, {
767
797
  resource_id: resourceId,
798
+ orderCount: orderCount,
799
+ bookingCount: bookingCount,
800
+ compeleteBookingCount: compeleteBookingCount,
768
801
  bookings: bookings
769
802
  });
770
803
  });
@@ -796,9 +829,9 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
796
829
  var _getResourceBookingItem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(params) {
797
830
  var _resourceResponse$dat3,
798
831
  _resourceResponse$dat4,
799
- _this6 = this,
832
+ _this7 = this,
800
833
  _params$bookingList;
801
- var current, deviceCurrent, resourceResponse, resourceList, targetResource, resourceId, matchedBookingList, completedBookingList, unpaidBookingList, bookings, completedBookings, unpaidBookings;
834
+ var current, deviceCurrent, resourceResponse, resourceList, targetResource, resourceId, matchedBookingList, completedBookingList, unpaidBookingList, bookings, completedBookings, unpaidBookings, orderCount, bookingCount, compeleteBookingCount;
802
835
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
803
836
  while (1) switch (_context6.prev = _context6.next) {
804
837
  case 0:
@@ -836,7 +869,7 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
836
869
  return _context6.abrupt("return", null);
837
870
  case 12:
838
871
  targetResource = resourceList.find(function (resource) {
839
- return String(_this6.getResourceId(resource)) === String(params.resourceId);
872
+ return String(_this7.getResourceId(resource)) === String(params.resourceId);
840
873
  });
841
874
  if (targetResource) {
842
875
  _context6.next = 15;
@@ -846,19 +879,22 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
846
879
  case 15:
847
880
  resourceId = this.getResourceId(targetResource);
848
881
  matchedBookingList = params.bookingList.filter(function (booking) {
849
- return _this6.isBookingMatchedResource(booking, resourceId);
882
+ return _this7.isBookingMatchedResource(booking, resourceId);
850
883
  });
851
884
  completedBookingList = matchedBookingList.filter(function (booking) {
852
- return _this6.getBookingAppointmentStatus(booking) === 'completed';
885
+ return _this7.getBookingAppointmentStatus(booking) === 'completed';
853
886
  });
854
887
  unpaidBookingList = matchedBookingList.filter(function (booking) {
855
- return _this6.getBookingOrderPaymentStatus(booking) === 'unpaid' || _this6.getBookingOrderPaymentStatus(booking) === 'payment_processing';
888
+ return _this7.getBookingOrderPaymentStatus(booking) === 'unpaid' || _this7.getBookingOrderPaymentStatus(booking) === 'payment_processing';
856
889
  });
857
890
  bookings = this.pickBookingsForCurrentPoint(current, this.normalizeResourceBookings(current, deviceCurrent, matchedBookingList));
858
891
  completedBookings = this.pickBookingsForCurrentPoint(current, this.normalizeResourceBookings(current, deviceCurrent, completedBookingList, {
859
892
  includeCompleted: true
860
893
  }));
861
894
  unpaidBookings = this.pickBookingsForCurrentPoint(current, this.normalizeResourceBookings(current, deviceCurrent, unpaidBookingList));
895
+ orderCount = this.countBookingOrders(matchedBookingList);
896
+ bookingCount = matchedBookingList.length;
897
+ compeleteBookingCount = completedBookingList.length;
862
898
  this.logger.addLog({
863
899
  type: 'info',
864
900
  title: 'getResourceBookingItem',
@@ -869,16 +905,22 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
869
905
  bookingList: (_params$bookingList = params.bookingList) === null || _params$bookingList === void 0 ? void 0 : _params$bookingList.length,
870
906
  bookings: bookings.length,
871
907
  completedBookings: completedBookings.length,
872
- unpaidBookings: unpaidBookings.length
908
+ unpaidBookings: unpaidBookings.length,
909
+ orderCount: orderCount,
910
+ bookingCount: bookingCount,
911
+ compeleteBookingCount: compeleteBookingCount
873
912
  }
874
913
  });
875
914
  return _context6.abrupt("return", _objectSpread(_objectSpread({}, targetResource), {}, {
876
915
  resource_id: resourceId,
916
+ orderCount: orderCount,
917
+ bookingCount: bookingCount,
918
+ compeleteBookingCount: compeleteBookingCount,
877
919
  bookings: bookings,
878
920
  completedBookings: completedBookings,
879
921
  unpaidBookings: unpaidBookings
880
922
  }));
881
- case 24:
923
+ case 27:
882
924
  case "end":
883
925
  return _context6.stop();
884
926
  }
@@ -30,6 +30,9 @@ export interface SalesResourceMatchedBooking extends Omit<BookingData, 'status'>
30
30
  }
31
31
  export interface SalesResourceBookingItem extends Omit<ResourceData, 'bookings'> {
32
32
  resource_id: ResourceId;
33
+ orderCount: number;
34
+ bookingCount: number;
35
+ compeleteBookingCount: number;
33
36
  bookings: SalesResourceMatchedBooking[];
34
37
  }
35
38
  export interface SalesResourceBookingItemWithGroups extends SalesResourceBookingItem {
@@ -85,13 +85,13 @@ export interface ScanOrderOrderProduct extends ScanOrderOrderProductIdentity {
85
85
  * 出站 payload 版本的商品行。
86
86
  *
87
87
  * 与 tempOrder 内部 `ScanOrderOrderProduct` 的字段差异:
88
- * - `product_option_item[*]`:内部为 `{ product_option_item_id, option_group_id, num, price, ... }`,
89
- * 出站由 `normalizeSubmitProduct` 重命名为 `{ option_group_item_id, option_group_id, num }`
88
+ * - `product_option_item[*]`:内部为 `{ option_group_item_id, option_group_id, num, price, ... }`,
89
+ * 出站保留 `{ option_group_item_id, option_group_id, num }`
90
90
  * (后端 checkout 协议;丢弃 `price` 等运行时辅助字段)。
91
91
  * - `product_bundle[*].option[*]`:同上重命名规则。
92
92
  *
93
- * 运行时(UI 显示、加购合并、指纹、持久化)全部消费内部字段名 `product_option_item_id`,
94
- * 仅在 SDK 提交边界做一次出站映射,不影响 opaque identity 契约。
93
+ * 运行时(UI 显示、加购合并、指纹、持久化)与提交边界统一消费字段名
94
+ * `option_group_item_id`,保持 tempOrder 与后端协议一致。
95
95
  */
96
96
  export interface ScanOrderSubmitProduct extends Omit<ScanOrderOrderProduct, '_origin' | 'identity_key'> {
97
97
  /**
@@ -14,13 +14,13 @@ export var ScanOrderHooks = /*#__PURE__*/function (ScanOrderHooks) {
14
14
  * 出站 payload 版本的商品行。
15
15
  *
16
16
  * 与 tempOrder 内部 `ScanOrderOrderProduct` 的字段差异:
17
- * - `product_option_item[*]`:内部为 `{ product_option_item_id, option_group_id, num, price, ... }`,
18
- * 出站由 `normalizeSubmitProduct` 重命名为 `{ option_group_item_id, option_group_id, num }`
17
+ * - `product_option_item[*]`:内部为 `{ option_group_item_id, option_group_id, num, price, ... }`,
18
+ * 出站保留 `{ option_group_item_id, option_group_id, num }`
19
19
  * (后端 checkout 协议;丢弃 `price` 等运行时辅助字段)。
20
20
  * - `product_bundle[*].option[*]`:同上重命名规则。
21
21
  *
22
- * 运行时(UI 显示、加购合并、指纹、持久化)全部消费内部字段名 `product_option_item_id`,
23
- * 仅在 SDK 提交边界做一次出站映射,不影响 opaque identity 契约。
22
+ * 运行时(UI 显示、加购合并、指纹、持久化)与提交边界统一消费字段名
23
+ * `option_group_item_id`,保持 tempOrder 与后端协议一致。
24
24
  */
25
25
 
26
26
  /**
@@ -381,14 +381,14 @@ export function buildProductLineFingerprint(productOptionItem, productBundle) {
381
381
  var normalizedOpts = optArr.map(function (item) {
382
382
  var _item$price;
383
383
  return {
384
- product_option_item_id: Number(item === null || item === void 0 ? void 0 : item.product_option_item_id) || 0,
384
+ option_group_item_id: Number(item === null || item === void 0 ? void 0 : item.option_group_item_id) || 0,
385
385
  option_group_id: Number(item === null || item === void 0 ? void 0 : item.option_group_id) || 0,
386
386
  num: typeof (item === null || item === void 0 ? void 0 : item.num) === 'number' && !Number.isNaN(item.num) ? Math.max(1, Math.floor(item.num)) : 1,
387
387
  price: String((_item$price = item === null || item === void 0 ? void 0 : item.price) !== null && _item$price !== void 0 ? _item$price : '')
388
388
  };
389
389
  }).sort(function (p, q) {
390
- if (p.product_option_item_id !== q.product_option_item_id) {
391
- return p.product_option_item_id - q.product_option_item_id;
390
+ if (p.option_group_item_id !== q.option_group_item_id) {
391
+ return p.option_group_item_id - q.option_group_item_id;
392
392
  }
393
393
  if (p.option_group_id !== q.option_group_id) return p.option_group_id - q.option_group_id;
394
394
  if (p.num !== q.num) return p.num - q.num;
package/lib/core/index.js CHANGED
@@ -50,6 +50,7 @@ var PisellOSCore = class {
50
50
  this.serverOptions = options.server;
51
51
  }
52
52
  this.initialize(options);
53
+ console.log("constructor1234");
53
54
  }
54
55
  initialize(options) {
55
56
  if (options == null ? void 0 : options.plugins) {
@@ -0,0 +1,49 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/model/strategy/adapter/promotion/index.ts
30
+ var promotion_exports = {};
31
+ __export(promotion_exports, {
32
+ BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
33
+ PromotionAdapter: () => import_adapter.PromotionAdapter,
34
+ PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
35
+ X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
36
+ default: () => import_adapter2.default
37
+ });
38
+ module.exports = __toCommonJS(promotion_exports);
39
+ var import_evaluator = require("./evaluator");
40
+ var import_adapter = require("./adapter");
41
+ var import_adapter2 = __toESM(require("./adapter"));
42
+ var import_examples = require("./examples");
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ BUY_X_GET_Y_FREE_STRATEGY,
46
+ PromotionAdapter,
47
+ PromotionEvaluator,
48
+ X_ITEMS_FOR_Y_PRICE_STRATEGY
49
+ });
@@ -289,7 +289,7 @@ var formatOptionsToOrigin = (options) => {
289
289
  return options.map((d) => {
290
290
  return {
291
291
  num: d.num,
292
- option_group_item_id: d.product_option_item_id,
292
+ option_group_item_id: d.option_group_item_id,
293
293
  option_group_id: d.option_group_id
294
294
  };
295
295
  });
@@ -18,6 +18,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
18
18
  private cacheId;
19
19
  private salesSummaryModuleName;
20
20
  private rulesHooksOverride?;
21
+ private orderHooks?;
21
22
  private otherParams?;
22
23
  /**
23
24
  * Populate `savedAmount` on each discount based on product-level discount details.
@@ -143,6 +144,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
143
144
  * 视为 wallet pass;其它支付项保持不变。
144
145
  */
145
146
  updateVoucherOrderPayments(payments: OrderPaymentSource[]): OrderPaymentData[];
147
+ private shouldMergeProductToOrder;
146
148
  addProductToOrder(product: Partial<OrderProduct> & OrderProductIdentity, booking?: AddProductBookingInput): Promise<OrderProduct[]>;
147
149
  private hasGoodPassDiscount;
148
150
  updateProductInOrder(params: UpdateProductInOrderParams): Promise<OrderProduct[]>;
@@ -171,7 +173,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
171
173
  private logSubmitBackendRejected;
172
174
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
173
175
  createOrder(params: CommitOrderParams['query']): {
174
- type: "virtual" | "appointment_booking";
176
+ type: "appointment_booking" | "virtual";
175
177
  platform: string;
176
178
  sales_channel: string;
177
179
  order_sales_channel: string;