@pisell/pisellos 0.0.229 → 0.0.231

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 (65) hide show
  1. package/dist/modules/Order/index.d.ts +13 -2
  2. package/dist/modules/Order/index.js +84 -1
  3. package/dist/modules/Order/types.d.ts +43 -0
  4. package/dist/modules/Order/types.js +8 -0
  5. package/dist/modules/Payment/cash.d.ts +8 -0
  6. package/dist/modules/Payment/cash.js +20 -1
  7. package/dist/modules/Payment/cashRecommendationAlgorithm.d.ts +22 -0
  8. package/dist/modules/Payment/cashRecommendationAlgorithm.js +423 -0
  9. package/dist/modules/Payment/eftpos.js +1 -1
  10. package/dist/modules/Payment/index.d.ts +57 -94
  11. package/dist/modules/Payment/index.js +810 -1109
  12. package/dist/modules/Payment/mx51.d.ts +0 -0
  13. package/dist/modules/Payment/mx51.js +0 -0
  14. package/dist/modules/Payment/types.d.ts +358 -50
  15. package/dist/modules/Payment/types.js +103 -4
  16. package/dist/modules/Payment/utils.d.ts +17 -0
  17. package/dist/modules/Payment/utils.js +62 -0
  18. package/dist/modules/Payment/walletpass.d.ts +96 -0
  19. package/dist/modules/Payment/walletpass.js +492 -0
  20. package/dist/modules/Schedule/index.d.ts +9 -0
  21. package/dist/modules/Schedule/index.js +60 -0
  22. package/dist/solution/BookingTicket/index.d.ts +1 -1
  23. package/dist/solution/Checkout/appointmentDemo.json +1 -0
  24. package/dist/solution/Checkout/index.d.ts +415 -0
  25. package/dist/solution/Checkout/index.js +3622 -0
  26. package/dist/solution/Checkout/types.d.ts +737 -0
  27. package/dist/solution/Checkout/types.js +137 -0
  28. package/dist/solution/Checkout/utils/index.d.ts +73 -0
  29. package/dist/{modules/Payment/wallet.js → solution/Checkout/utils/index.js} +363 -70
  30. package/dist/solution/index.d.ts +1 -0
  31. package/dist/solution/index.js +2 -1
  32. package/lib/modules/Order/index.d.ts +13 -2
  33. package/lib/modules/Order/index.js +58 -1
  34. package/lib/modules/Order/types.d.ts +43 -0
  35. package/lib/modules/Payment/cash.d.ts +8 -0
  36. package/lib/modules/Payment/cash.js +14 -1
  37. package/lib/modules/Payment/cashRecommendationAlgorithm.d.ts +22 -0
  38. package/lib/modules/Payment/cashRecommendationAlgorithm.js +342 -0
  39. package/lib/modules/Payment/eftpos.js +1 -1
  40. package/lib/modules/Payment/index.d.ts +57 -94
  41. package/lib/modules/Payment/index.js +363 -525
  42. package/lib/modules/Payment/mx51.d.ts +0 -0
  43. package/lib/modules/Payment/mx51.js +0 -0
  44. package/lib/modules/Payment/types.d.ts +358 -50
  45. package/lib/modules/Payment/types.js +37 -2
  46. package/lib/modules/Payment/utils.d.ts +17 -0
  47. package/lib/modules/Payment/utils.js +67 -0
  48. package/lib/modules/Payment/walletpass.d.ts +96 -0
  49. package/lib/modules/Payment/walletpass.js +304 -0
  50. package/lib/modules/Schedule/index.d.ts +9 -0
  51. package/lib/modules/Schedule/index.js +36 -0
  52. package/lib/solution/BookingTicket/index.d.ts +1 -1
  53. package/lib/solution/Checkout/appointmentDemo.json +1 -0
  54. package/lib/solution/Checkout/index.d.ts +415 -0
  55. package/lib/solution/Checkout/index.js +2107 -0
  56. package/lib/solution/Checkout/types.d.ts +737 -0
  57. package/lib/solution/Checkout/types.js +80 -0
  58. package/lib/solution/Checkout/utils/index.d.ts +73 -0
  59. package/lib/solution/Checkout/utils/index.js +266 -0
  60. package/lib/solution/index.d.ts +1 -0
  61. package/lib/solution/index.js +3 -1
  62. package/package.json +1 -1
  63. package/dist/modules/Payment/wallet.d.ts +0 -11
  64. package/lib/modules/Payment/wallet.d.ts +0 -11
  65. package/lib/modules/Payment/wallet.js +0 -51
@@ -25,4 +25,13 @@ export declare class ScheduleModule extends BaseModule implements Module, Schedu
25
25
  setOtherProductsIds(ids: number[]): void;
26
26
  getOtherProductsIds(): number[];
27
27
  storeChange(): void;
28
+ /**
29
+ * 传入一个时间, 判断改时间是否在schedule 内
30
+ * @param param0 { date: string, schedule: any } date: 日期, schedule: schedule
31
+ * @returns
32
+ */
33
+ static isInScheduleByDate({ date, schedule }: {
34
+ date: string;
35
+ schedule: any;
36
+ }): true | undefined;
28
37
  }
@@ -1,4 +1,9 @@
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 _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ 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; }
5
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2
7
  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
8
  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
9
  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); }); }; }
@@ -21,6 +26,7 @@ import dayjs from 'dayjs';
21
26
  import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
22
27
  import isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
23
28
  import { generateMonthDates, disableAllDates, disableDatesBeforeOneDay } from "../Date/utils";
29
+ import { calcScheduleDateRange } from "./utils";
24
30
  dayjs.extend(isSameOrBefore);
25
31
  dayjs.extend(isSameOrAfter);
26
32
  export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
@@ -236,6 +242,60 @@ export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
236
242
  });
237
243
  }
238
244
  }
245
+
246
+ /**
247
+ * 传入一个时间, 判断改时间是否在schedule 内
248
+ * @param param0 { date: string, schedule: any } date: 日期, schedule: schedule
249
+ * @returns
250
+ */
251
+ }], [{
252
+ key: "isInScheduleByDate",
253
+ value: function isInScheduleByDate(_ref2) {
254
+ var _schedule$repeat_rule, _schedule$repeat_rule2;
255
+ var date = _ref2.date,
256
+ schedule = _ref2.schedule;
257
+ // 节约性能, 强制将schedule的时间范围改为前后一天,避免大量计算.
258
+ var _schedule = _objectSpread(_objectSpread({}, schedule), {}, {
259
+ // 开始时间向前推一天
260
+ start_time: dayjs(date).subtract(1, "day").format("YYYY-MM-DD HH:mm:ss"),
261
+ end_time: dayjs(date).add(1, "day").format("YYYY-MM-DD HH:mm:ss")
262
+ });
263
+
264
+ // 不限制的 改为后一天
265
+ if (((_schedule$repeat_rule = _schedule.repeat_rule) === null || _schedule$repeat_rule === void 0 || (_schedule$repeat_rule = _schedule$repeat_rule.end) === null || _schedule$repeat_rule === void 0 ? void 0 : _schedule$repeat_rule.type) === "never") {
266
+ _schedule.repeat_rule.end = {
267
+ type: "date",
268
+ end_date: _schedule.end_time,
269
+ occurrence: null
270
+ };
271
+ }
272
+
273
+ // 限制结束日期的也改为后一天
274
+ if (((_schedule$repeat_rule2 = _schedule.repeat_rule) === null || _schedule$repeat_rule2 === void 0 || (_schedule$repeat_rule2 = _schedule$repeat_rule2.end) === null || _schedule$repeat_rule2 === void 0 ? void 0 : _schedule$repeat_rule2.type) === "date") {
275
+ _schedule.repeat_rule.end = _objectSpread(_objectSpread({}, _schedule.repeat_rule.end), {}, {
276
+ end_date: _schedule.end_time
277
+ });
278
+ }
279
+ var dateRanges = calcScheduleDateRange(_objectSpread({}, _schedule));
280
+ var _iterator = _createForOfIteratorHelper(dateRanges),
281
+ _step;
282
+ try {
283
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
284
+ var range = _step.value;
285
+ var startTime = dayjs(range.start);
286
+ var endTime = dayjs(range.end);
287
+
288
+ // 如果输入时间在这个范围内(包含边界)
289
+ if (dayjs(date).isSameOrAfter(startTime) && dayjs(date).isSameOrBefore(endTime)) {
290
+ return true;
291
+ }
292
+ }
293
+ } catch (err) {
294
+ _iterator.e(err);
295
+ } finally {
296
+ _iterator.f();
297
+ }
298
+ }
239
299
  }]);
240
300
  return ScheduleModule;
241
301
  }(BaseModule);
@@ -111,7 +111,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
111
111
  * 获取当前的客户搜索条件
112
112
  * @returns 当前搜索条件
113
113
  */
114
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
114
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
115
115
  /**
116
116
  * 获取客户列表状态(包含滚动加载相关状态)
117
117
  * @returns 客户状态
@@ -0,0 +1 @@
1
+ {"type":"appointment_booking","platform":"PC","sales_channel":"my_pisel","order_sales_channel":"online_store","bookings":[{"id":0,"number":1,"registration_type":"all","relation_products":[],"is_all":false,"product":{"num":1,"product_id":61170,"product_variant_id":0,"product_bundle":[],"product_option_item":[],"discount_list":[{"amount":100,"type":"good_pass","discount":{"resource_id":64523,"title":{"auto":"玄-商品券","original":"玄-商品券","en":null,"zh-CN":null,"zh-HK":null},"original_amount":100,"product_id":61170,"percent":"1.00"}}]},"sub_type":"minutes","duration":480,"like_status":"common","resources":[{"relation_type":"form","like_status":"common","form_id":35,"relation_id":40357,"capacity":1,"metadata":{"combined_resource":{"status":1,"resource_ids":[40262,40263]},"form_name":"桌台","resource_name":"组合资源测试table-0422-01"},"children":[{"relation_type":"form","like_status":"common","id":40262,"main_field":"A01(组合资源-小桌-4 人)","resourceType":"single","form_id":35,"relation_id":40262,"capacity":1,"metadata":{"combined_resource":null,"form_name":"桌台","resource_name":"A01(组合资源-小桌-4 人)"}},{"relation_type":"form","like_status":"common","id":40263,"main_field":"A02(组合资源-小桌-4 人)","resourceType":"single","form_id":35,"relation_id":40263,"capacity":0,"metadata":{"combined_resource":null,"form_name":"桌台","resource_name":"A02(组合资源-小桌-4 人)"}}]},{"relation_type":"form","like_status":"common","form_id":214,"relation_id":38350,"capacity":1,"metadata":{"combined_resource":null,"form_name":"校区2","resource_name":"West Campus"}}],"schedule_id":0,"start_date":"2025-08-22","start_time":"09:00","select_date":"2025-08-22","end_time":"17:00","end_date":"2025-08-22","metadata":{"account":{"id":13433,"username":"a a"},"capacity":[{"id":0,"value":1,"name":""}]},"holder":null,"relation_forms":[]}],"shop_note":"","schedule_date":"2025-08-22 09:00:00","is_deposit":0,"relation_products":[],"relation_forms":[]}
@@ -0,0 +1,415 @@
1
+ import { Module, PisellCore, ModuleOptions } from '../../types';
2
+ import { BaseModule } from '../../modules/BaseModule';
3
+ import { OrderModule } from '../../modules/Order';
4
+ import { PaymentModule } from '../../modules/Payment';
5
+ import { CheckoutModuleAPI, CheckoutStep, CheckoutInitParams, CreateLocalOrderParams, PlaceOrderParams, CreateOrderParams, ProcessPaymentParams, CheckoutStatusInfo, CheckoutSummary, CurrentOrderInfo, CartSummaryItem, ExtractedAmountInfo } from './types';
6
+ import { PaymentOrder, PaymentMethod, PaymentItem, PaymentItemInput } from '../../modules/Payment/types';
7
+ export * from './types';
8
+ /**
9
+ * 结账解决方案实现
10
+ *
11
+ * 整合订单处理和支付功能,提供完整的结账流程管理。
12
+ * 支持多种支付方式,提供实时状态跟踪和错误处理。
13
+ */
14
+ export declare class CheckoutImpl extends BaseModule implements Module, CheckoutModuleAPI {
15
+ protected defaultName: string;
16
+ protected defaultVersion: string;
17
+ isSolution: boolean;
18
+ private request;
19
+ private store;
20
+ private otherParams;
21
+ order: OrderModule;
22
+ payment: PaymentModule;
23
+ constructor(name?: string, version?: string);
24
+ initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
25
+ /**
26
+ * 初始化子模块
27
+ */
28
+ private initializeSubModules;
29
+ /**
30
+ * 设置支付模块事件监听
31
+ */
32
+ private setupPaymentEventListeners;
33
+ /**
34
+ * 初始化结账流程
35
+ */
36
+ initializeCheckoutAsync(params: CheckoutInitParams): Promise<void>;
37
+ getProductListByOrder(): {
38
+ product_id: number;
39
+ product_variant_id: string;
40
+ quantity: number;
41
+ selling_price: number;
42
+ }[];
43
+ /**
44
+ * 创建本地订单 (前端模拟下单流程)
45
+ *
46
+ * 此方法用于在前端模拟整个下单流程,创建一个本地的虚拟订单。
47
+ * 用户在购物车点击下单时,会把购物车参数传递给此方法,
48
+ * 方法会记录参数并创建本地虚拟订单,然后用 Payment 模块管理支付流程。
49
+ */
50
+ createLocalOrderAsync(params: CreateLocalOrderParams): Promise<PaymentOrder>;
51
+ /**
52
+ * 手动下单 (根据虚拟订单生成实际订单)
53
+ *
54
+ * 使用当前存储的本地订单数据调用 Order 模块创建真实订单
55
+ */
56
+ placeOrderAsync(params?: PlaceOrderParams): Promise<{
57
+ success: boolean;
58
+ orderId?: string;
59
+ error?: string;
60
+ }>;
61
+ /**
62
+ * 创建订单
63
+ */
64
+ createOrderAsync(params: CreateOrderParams): Promise<PaymentOrder>;
65
+ /**
66
+ * 处理支付
67
+ */
68
+ processPaymentAsync(params: ProcessPaymentParams): Promise<void>;
69
+ /**
70
+ * 完成结账
71
+ */
72
+ completeCheckoutAsync(): Promise<{
73
+ success: boolean;
74
+ orderId?: string;
75
+ }>;
76
+ /**
77
+ * 取消结账
78
+ */
79
+ cancelCheckoutAsync(): Promise<void>;
80
+ /**
81
+ * 获取结账状态
82
+ */
83
+ getCheckoutStatus(): CheckoutStatusInfo;
84
+ /**
85
+ * 获取结账摘要
86
+ */
87
+ getCheckoutSummaryAsync(): Promise<CheckoutSummary>;
88
+ /**
89
+ * 获取可用支付方式
90
+ */
91
+ getAvailablePaymentMethodsAsync(): Promise<PaymentMethod[]>;
92
+ /**
93
+ * 刷新支付方式缓存
94
+ *
95
+ * 强制重新从服务器获取支付方式列表,更新本地缓存
96
+ */
97
+ refreshPaymentMethodsAsync(): Promise<PaymentMethod[]>;
98
+ /**
99
+ * 获取当前订单基础信息
100
+ *
101
+ * 返回当前订单的基础信息,包括订单状态、金额、支付状态等
102
+ */
103
+ getCurrentOrderInfo(): CurrentOrderInfo | null;
104
+ /**
105
+ * 获取当前订单的支付项
106
+ *
107
+ * 返回当前订单的所有支付项,包括活跃和已撤销的支付项
108
+ */
109
+ getCurrentOrderPaymentItemsAsync(): Promise<PaymentItem[]>;
110
+ /**
111
+ * 验证结账前置条件
112
+ */
113
+ validateCheckoutAsync(): Promise<{
114
+ valid: boolean;
115
+ errors: string[];
116
+ }>;
117
+ /**
118
+ * 重试失败的操作
119
+ */
120
+ retryFailedOperationAsync(): Promise<void>;
121
+ /**
122
+ * 设置当前步骤
123
+ */
124
+ setCurrentStep(step: CheckoutStep): void;
125
+ /**
126
+ * 获取订单模块
127
+ */
128
+ getOrderModule(): OrderModule;
129
+ /**
130
+ * 获取支付模块
131
+ */
132
+ getPaymentModule(): PaymentModule;
133
+ /**
134
+ * 替换本地订单ID为真实订单ID
135
+ *
136
+ * 当后端订单创建完成后,调用此方法将本地虚拟订单ID替换为真实订单ID
137
+ *
138
+ * @param newOrderId 后端返回的真实订单ID
139
+ * @returns 更新后的订单对象,如果当前没有订单则返回null
140
+ */
141
+ replaceLocalOrderIdAsync(newOrderId: string): Promise<PaymentOrder | null>;
142
+ /**
143
+ * 设置自定义支付金额
144
+ *
145
+ * 允许UI自定义本次支付的金额,通常用于部分支付或调整支付金额场景
146
+ *
147
+ * @param amount 自定义支付金额,必须是有效的数字字符串
148
+ */
149
+ setStateAmountAsync(amount: string): Promise<void>;
150
+ /**
151
+ * 获取当前自定义支付金额
152
+ *
153
+ * @returns 当前设置的自定义支付金额
154
+ */
155
+ getStateAmount(): string;
156
+ /**
157
+ * 刷新 stateAmount 为当前剩余未支付金额
158
+ *
159
+ * UI 可以调用此方法来主动刷新支付金额状态
160
+ */
161
+ refreshStateAmountAsync(): Promise<void>;
162
+ /**
163
+ * 获取购物车小计数据
164
+ *
165
+ * 返回当前结账流程中的购物车小计项数据,包含各种费用明细
166
+ *
167
+ * @returns 购物车小计数据数组,如果没有则返回 null
168
+ */
169
+ getCartSummary(): CartSummaryItem[] | null;
170
+ /**
171
+ * 获取提取的金额详细信息
172
+ *
173
+ * 从当前的购物车小计数据中提取结构化的金额信息
174
+ *
175
+ * @returns 提取的金额信息对象,如果没有小计数据则返回 null
176
+ */
177
+ getExtractedAmountInfo(): ExtractedAmountInfo | null;
178
+ /**
179
+ * 获取支付方式列表
180
+ *
181
+ * 直接调用 Payment 模块的 getPayMethodListAsync 方法
182
+ *
183
+ * @returns 支付方式列表
184
+ */
185
+ getPaymentMethodsAsync(): Promise<PaymentMethod[]>;
186
+ /**
187
+ * 为当前订单添加支付项
188
+ *
189
+ * 向当前活跃订单添加一个支付项,支付项包含支付方式信息和金额
190
+ *
191
+ * @param paymentItem 支付项数据
192
+ * @throws 当前没有活跃订单时抛出错误
193
+ */
194
+ addPaymentItemAsync(paymentItem: PaymentItemInput): Promise<void>;
195
+ /**
196
+ * 删除当前订单的支付项
197
+ *
198
+ * 从当前活跃订单中删除指定的支付项,支付项将被标记为已撤销状态
199
+ *
200
+ * @param paymentUuid 要删除的支付项UUID
201
+ * @throws 当前没有活跃订单时抛出错误
202
+ * @throws 支付项不存在时抛出错误
203
+ */
204
+ deletePaymentItemAsync(paymentUuid: string): Promise<void>;
205
+ /**
206
+ * 批量更新当前订单的代金券支付项(覆盖更新)
207
+ *
208
+ * 删除所有现有的代金券支付项,然后添加新的代金券支付项。
209
+ * 这是一个覆盖式更新操作,确保代金券支付项的一致性。
210
+ *
211
+ * @param voucherPaymentItems 新的代金券支付项列表,每个都必须包含 voucher_id
212
+ * @throws 当前没有活跃订单时抛出错误
213
+ * @throws 支付项缺少 voucher_id 时抛出错误
214
+ */
215
+ updateVoucherPaymentItemsAsync(voucherPaymentItems: PaymentItemInput[]): Promise<void>;
216
+ /**
217
+ * 修改当前订单的定金状态
218
+ *
219
+ * 更新当前订单的 is_deposit 字段,用于标识订单是否为定金订单
220
+ *
221
+ * @param isDeposit 定金状态 (1: 定金订单, 0: 全款订单)
222
+ * @throws 当前没有活跃订单时抛出错误
223
+ */
224
+ updateOrderDepositStatusAsync(isDeposit: number): Promise<void>;
225
+ /**
226
+ * 更新当前订单的客户信息
227
+ *
228
+ * 更新当前订单关联的客户信息,用于标识订单的所属客户
229
+ *
230
+ * @param customer 客户信息 (customer_id 和/或 customer_name)
231
+ * @throws 当前没有活跃订单时抛出错误
232
+ */
233
+ updateOrderCustomerAsync(customer: {
234
+ customer_id?: string;
235
+ customer_name?: string;
236
+ }): Promise<void>;
237
+ /**
238
+ * 获取当前订单的客户信息
239
+ *
240
+ * @returns 当前客户信息,如果没有则返回 null
241
+ */
242
+ getCurrentCustomer(): {
243
+ customer_id?: string;
244
+ customer_name?: string;
245
+ } | null;
246
+ /**
247
+ * 检查订单是否需要手动同步
248
+ *
249
+ * 返回订单是否为纯代金券支付且待付金额<=0但未同步的状态
250
+ */
251
+ needsManualSync(): boolean;
252
+ /**
253
+ * 手动同步订单到后端
254
+ *
255
+ * 用于强制同步订单到后端,特别适用于纯代金券支付完成的订单
256
+ */
257
+ manualSyncOrderAsync(): Promise<{
258
+ success: boolean;
259
+ message?: string;
260
+ orderId?: string;
261
+ orderUuid?: string;
262
+ }>;
263
+ /**
264
+ * 获取当前订单备注
265
+ *
266
+ * @returns 当前订单的备注内容,如果没有则返回空字符串
267
+ */
268
+ getOrderNote(): string;
269
+ /**
270
+ * 获取当前订单ID
271
+ *
272
+ * @returns 当前订单的ID,如果没有订单则返回null
273
+ */
274
+ getCurrentOrderId(): string | null;
275
+ /**
276
+ * 保存订单并稍后支付
277
+ *
278
+ * 将当前订单保存到后端,但排除代金券类支付项(voucher_id),
279
+ * 适用于用户想要保存订单但稍后完成支付的场景
280
+ */
281
+ saveForLaterPaymentAsync(): Promise<{
282
+ success: boolean;
283
+ message?: string;
284
+ orderId?: string;
285
+ orderUuid?: string;
286
+ }>;
287
+ /**
288
+ * 获取当前商店折扣金额
289
+ *
290
+ * @returns 当前的商店折扣金额,如果没有则返回0
291
+ */
292
+ getShopDiscount(): number;
293
+ /**
294
+ * 更新订单商店折扣
295
+ *
296
+ * 同时更新cartSummary和localOrderData中的shop_discount值
297
+ *
298
+ * @param discountAmount 商店折扣金额
299
+ */
300
+ updateShopDiscountAsync(discountAmount: number): Promise<void>;
301
+ /**
302
+ * 更新订单备注
303
+ *
304
+ * @param note 订单备注内容
305
+ */
306
+ updateOrderNoteAsync(note: string): Promise<void>;
307
+ /**
308
+ * 设置状态
309
+ */
310
+ private setStatus;
311
+ /**
312
+ * 设置步骤
313
+ */
314
+ private setStep;
315
+ /**
316
+ * 处理错误
317
+ */
318
+ private handleError;
319
+ /**
320
+ * 处理支付成功
321
+ */
322
+ private handlePaymentSuccess;
323
+ /**
324
+ * 处理支付错误
325
+ */
326
+ private handlePaymentError;
327
+ /**
328
+ * 验证结账参数
329
+ */
330
+ private validateCheckoutParams;
331
+ /**
332
+ * 验证本地订单数据
333
+ */
334
+ private validateLocalOrderData;
335
+ /**
336
+ * 生成本地订单ID
337
+ */
338
+ private generateLocalOrderId;
339
+ /**
340
+ * 格式化日期时间为 YYYY-MM-DD hh:mm:ss 格式
341
+ *
342
+ * @param date 要格式化的日期对象
343
+ * @returns 格式化后的日期时间字符串
344
+ */
345
+ private formatDateTime;
346
+ /**
347
+ * 从购物车小计数据中提取金额信息
348
+ */
349
+ private extractAmountFromCartSummary;
350
+ /**
351
+ * 预加载支付方式(在初始化时调用)
352
+ */
353
+ private preloadPaymentMethods;
354
+ /**
355
+ * 计算总金额
356
+ */
357
+ private calculateTotalAmount;
358
+ /**
359
+ * 计算已支付金额
360
+ */
361
+ private calculatePaidAmount;
362
+ /**
363
+ * 计算剩余未支付金额
364
+ */
365
+ private calculateRemainingAmount;
366
+ /**
367
+ * 更新 stateAmount 为当前剩余未支付金额
368
+ */
369
+ private updateStateAmountToRemaining;
370
+ /**
371
+ * 检查订单支付是否完成
372
+ *
373
+ * 当剩余待付款金额 <= 0 时,触发订单支付完成事件
374
+ */
375
+ private checkOrderPaymentCompletion;
376
+ /**
377
+ * 判断支付方式是否需要同步订单到后端
378
+ *
379
+ * 现金支付(CASHMANUAL)和自定义支付不需要同步,其他支付方式需要同步
380
+ *
381
+ * @param paymentCode 支付方式代码
382
+ * @param paymentType 支付方式类型
383
+ * @returns 是否需要同步订单
384
+ */
385
+ private shouldSyncOrderForPayment;
386
+ /**
387
+ * 同步订单到后端
388
+ *
389
+ * 调用后端 /order/checkout 接口创建真实订单
390
+ */
391
+ /**
392
+ * 判断订单ID是否为本地生成的虚拟ID
393
+ *
394
+ * @param orderId 订单ID
395
+ * @returns true 表示是虚拟ID,false 表示是真实的后端ID
396
+ */
397
+ private isVirtualOrderId;
398
+ /**
399
+ * 同步订单到后端并返回真实订单ID
400
+ *
401
+ * @param isManual 是否为手动同步,默认为 false
402
+ * @param customPaymentItems 自定义支付项列表,如果提供则使用此列表而不是从数据库获取
403
+ * @returns 后端返回的真实订单ID
404
+ */
405
+ private syncOrderToBackendWithReturn;
406
+ private syncOrderToBackend;
407
+ /**
408
+ * 获取状态消息
409
+ */
410
+ private getStatusMessage;
411
+ setOtherParams(params: Record<string, any>, { cover }?: {
412
+ cover?: boolean;
413
+ }): Promise<void>;
414
+ destroy(): Promise<void>;
415
+ }