@pisell/pisellos 0.0.230 → 0.0.232

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 (54) hide show
  1. package/dist/modules/Order/index.d.ts +13 -2
  2. package/dist/modules/Order/index.js +93 -1
  3. package/dist/modules/Order/types.d.ts +45 -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 +34 -124
  11. package/dist/modules/Payment/index.js +662 -1280
  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 +323 -45
  15. package/dist/modules/Payment/types.js +101 -2
  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/Checkout/index.d.ts +254 -2
  23. package/dist/solution/Checkout/index.js +2472 -320
  24. package/dist/solution/Checkout/types.d.ts +207 -6
  25. package/dist/solution/Checkout/types.js +5 -0
  26. package/lib/modules/Order/index.d.ts +13 -2
  27. package/lib/modules/Order/index.js +65 -1
  28. package/lib/modules/Order/types.d.ts +45 -0
  29. package/lib/modules/Payment/cash.d.ts +8 -0
  30. package/lib/modules/Payment/cash.js +14 -1
  31. package/lib/modules/Payment/cashRecommendationAlgorithm.d.ts +22 -0
  32. package/lib/modules/Payment/cashRecommendationAlgorithm.js +342 -0
  33. package/lib/modules/Payment/eftpos.js +1 -1
  34. package/lib/modules/Payment/index.d.ts +34 -124
  35. package/lib/modules/Payment/index.js +232 -533
  36. package/lib/modules/Payment/mx51.d.ts +0 -0
  37. package/lib/modules/Payment/mx51.js +0 -0
  38. package/lib/modules/Payment/types.d.ts +323 -45
  39. package/lib/modules/Payment/types.js +37 -2
  40. package/lib/modules/Payment/utils.d.ts +17 -0
  41. package/lib/modules/Payment/utils.js +67 -0
  42. package/lib/modules/Payment/walletpass.d.ts +96 -0
  43. package/lib/modules/Payment/walletpass.js +304 -0
  44. package/lib/modules/Schedule/index.d.ts +9 -0
  45. package/lib/modules/Schedule/index.js +36 -0
  46. package/lib/solution/Checkout/index.d.ts +254 -2
  47. package/lib/solution/Checkout/index.js +1361 -39
  48. package/lib/solution/Checkout/types.d.ts +207 -6
  49. package/lib/solution/Checkout/types.js +5 -0
  50. package/package.json +1 -1
  51. package/dist/modules/Payment/wallet.d.ts +0 -11
  52. package/dist/modules/Payment/wallet.js +0 -78
  53. package/lib/modules/Payment/wallet.d.ts +0 -11
  54. package/lib/modules/Payment/wallet.js +0 -51
@@ -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);
@@ -2,8 +2,8 @@ import { Module, PisellCore, ModuleOptions } from '../../types';
2
2
  import { BaseModule } from '../../modules/BaseModule';
3
3
  import { OrderModule } from '../../modules/Order';
4
4
  import { PaymentModule } from '../../modules/Payment';
5
- import { CheckoutModuleAPI, CheckoutStep, CheckoutInitParams, CreateLocalOrderParams, PlaceOrderParams, CreateOrderParams, ProcessPaymentParams, CheckoutStatusInfo, CheckoutSummary, CurrentOrderInfo } from './types';
6
- import { PaymentOrder, PaymentMethod } from '../../modules/Payment/types';
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
7
  export * from './types';
8
8
  /**
9
9
  * 结账解决方案实现
@@ -18,6 +18,8 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
18
18
  private request;
19
19
  private store;
20
20
  private otherParams;
21
+ order: OrderModule;
22
+ payment: PaymentModule;
21
23
  constructor(name?: string, version?: string);
22
24
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
23
25
  /**
@@ -32,6 +34,12 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
32
34
  * 初始化结账流程
33
35
  */
34
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
+ }[];
35
43
  /**
36
44
  * 创建本地订单 (前端模拟下单流程)
37
45
  *
@@ -87,12 +95,22 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
87
95
  * 强制重新从服务器获取支付方式列表,更新本地缓存
88
96
  */
89
97
  refreshPaymentMethodsAsync(): Promise<PaymentMethod[]>;
98
+ /**
99
+ * 获取订单原始数据
100
+ */
101
+ getOrderOriginalData(): any;
90
102
  /**
91
103
  * 获取当前订单基础信息
92
104
  *
93
105
  * 返回当前订单的基础信息,包括订单状态、金额、支付状态等
94
106
  */
95
107
  getCurrentOrderInfo(): CurrentOrderInfo | null;
108
+ /**
109
+ * 获取当前订单的支付项
110
+ *
111
+ * 返回当前订单的所有支付项,包括活跃和已撤销的支付项
112
+ */
113
+ getCurrentOrderPaymentItemsAsync(): Promise<PaymentItem[]>;
96
114
  /**
97
115
  * 验证结账前置条件
98
116
  */
@@ -125,6 +143,171 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
125
143
  * @returns 更新后的订单对象,如果当前没有订单则返回null
126
144
  */
127
145
  replaceLocalOrderIdAsync(newOrderId: string): Promise<PaymentOrder | null>;
146
+ /**
147
+ * 设置自定义支付金额
148
+ *
149
+ * 允许UI自定义本次支付的金额,通常用于部分支付或调整支付金额场景
150
+ *
151
+ * @param amount 自定义支付金额,必须是有效的数字字符串
152
+ */
153
+ setStateAmountAsync(amount: string): Promise<void>;
154
+ /**
155
+ * 获取当前自定义支付金额
156
+ *
157
+ * @returns 当前设置的自定义支付金额
158
+ */
159
+ getStateAmount(): string;
160
+ /**
161
+ * 刷新 stateAmount 为当前剩余未支付金额
162
+ *
163
+ * UI 可以调用此方法来主动刷新支付金额状态
164
+ */
165
+ refreshStateAmountAsync(): Promise<void>;
166
+ /**
167
+ * 获取购物车小计数据
168
+ *
169
+ * 返回当前结账流程中的购物车小计项数据,包含各种费用明细
170
+ *
171
+ * @returns 购物车小计数据数组,如果没有则返回 null
172
+ */
173
+ getCartSummary(): CartSummaryItem[] | null;
174
+ /**
175
+ * 获取提取的金额详细信息
176
+ *
177
+ * 从当前的购物车小计数据中提取结构化的金额信息
178
+ *
179
+ * @returns 提取的金额信息对象,如果没有小计数据则返回 null
180
+ */
181
+ getExtractedAmountInfo(): ExtractedAmountInfo | null;
182
+ /**
183
+ * 获取支付方式列表
184
+ *
185
+ * 直接调用 Payment 模块的 getPayMethodListAsync 方法
186
+ *
187
+ * @returns 支付方式列表
188
+ */
189
+ getPaymentMethodsAsync(): Promise<PaymentMethod[]>;
190
+ /**
191
+ * 为当前订单添加支付项
192
+ *
193
+ * 向当前活跃订单添加一个支付项,支付项包含支付方式信息和金额
194
+ *
195
+ * @param paymentItem 支付项数据
196
+ * @throws 当前没有活跃订单时抛出错误
197
+ */
198
+ addPaymentItemAsync(paymentItem: PaymentItemInput): Promise<void>;
199
+ /**
200
+ * 删除当前订单的支付项
201
+ *
202
+ * 从当前活跃订单中删除指定的支付项,支付项将被标记为已撤销状态
203
+ *
204
+ * @param paymentUuid 要删除的支付项UUID
205
+ * @throws 当前没有活跃订单时抛出错误
206
+ * @throws 支付项不存在时抛出错误
207
+ */
208
+ deletePaymentItemAsync(paymentUuid: string): Promise<void>;
209
+ /**
210
+ * 批量更新当前订单的代金券支付项(覆盖更新)
211
+ *
212
+ * 删除所有现有的代金券支付项,然后添加新的代金券支付项。
213
+ * 这是一个覆盖式更新操作,确保代金券支付项的一致性。
214
+ *
215
+ * @param voucherPaymentItems 新的代金券支付项列表,每个都必须包含 voucher_id
216
+ * @throws 当前没有活跃订单时抛出错误
217
+ * @throws 支付项缺少 voucher_id 时抛出错误
218
+ */
219
+ updateVoucherPaymentItemsAsync(voucherPaymentItems: PaymentItemInput[]): Promise<void>;
220
+ /**
221
+ * 修改当前订单的定金状态
222
+ *
223
+ * 更新当前订单的 is_deposit 字段,用于标识订单是否为定金订单
224
+ *
225
+ * @param isDeposit 定金状态 (1: 定金订单, 0: 全款订单)
226
+ * @throws 当前没有活跃订单时抛出错误
227
+ */
228
+ updateOrderDepositStatusAsync(isDeposit: number): Promise<void>;
229
+ /**
230
+ * 更新当前订单的客户信息
231
+ *
232
+ * 更新当前订单关联的客户信息,用于标识订单的所属客户
233
+ *
234
+ * @param customer 客户信息 (customer_id 和/或 customer_name)
235
+ * @throws 当前没有活跃订单时抛出错误
236
+ */
237
+ updateOrderCustomerAsync(customer: {
238
+ customer_id?: string;
239
+ customer_name?: string;
240
+ }): Promise<void>;
241
+ /**
242
+ * 获取当前订单的客户信息
243
+ *
244
+ * @returns 当前客户信息,如果没有则返回 null
245
+ */
246
+ getCurrentCustomer(): {
247
+ customer_id?: string;
248
+ customer_name?: string;
249
+ } | null;
250
+ /**
251
+ * 检查订单是否需要手动同步
252
+ *
253
+ * 返回订单是否为纯代金券支付且待付金额<=0但未同步的状态
254
+ */
255
+ needsManualSync(): boolean;
256
+ /**
257
+ * 手动同步订单到后端
258
+ *
259
+ * 用于强制同步订单到后端,特别适用于纯代金券支付完成的订单
260
+ */
261
+ manualSyncOrderAsync(): Promise<{
262
+ success: boolean;
263
+ message?: string;
264
+ orderId?: string;
265
+ orderUuid?: string;
266
+ }>;
267
+ /**
268
+ * 获取当前订单备注
269
+ *
270
+ * @returns 当前订单的备注内容,如果没有则返回空字符串
271
+ */
272
+ getOrderNote(): string;
273
+ /**
274
+ * 获取当前订单ID
275
+ *
276
+ * @returns 当前订单的ID,如果没有订单则返回null
277
+ */
278
+ getCurrentOrderId(): string | null;
279
+ /**
280
+ * 保存订单并稍后支付
281
+ *
282
+ * 将当前订单保存到后端,但排除代金券类支付项(voucher_id),
283
+ * 适用于用户想要保存订单但稍后完成支付的场景
284
+ */
285
+ saveForLaterPaymentAsync(): Promise<{
286
+ success: boolean;
287
+ message?: string;
288
+ orderId?: string;
289
+ orderUuid?: string;
290
+ }>;
291
+ /**
292
+ * 获取当前商店折扣金额
293
+ *
294
+ * @returns 当前的商店折扣金额,如果没有则返回0
295
+ */
296
+ getShopDiscount(): number;
297
+ /**
298
+ * 更新订单商店折扣
299
+ *
300
+ * 同时更新cartSummary和localOrderData中的shop_discount值
301
+ *
302
+ * @param discountAmount 商店折扣金额
303
+ */
304
+ updateShopDiscountAsync(discountAmount: number): Promise<void>;
305
+ /**
306
+ * 更新订单备注
307
+ *
308
+ * @param note 订单备注内容
309
+ */
310
+ updateOrderNoteAsync(note: string): Promise<void>;
128
311
  /**
129
312
  * 设置状态
130
313
  */
@@ -157,6 +340,13 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
157
340
  * 生成本地订单ID
158
341
  */
159
342
  private generateLocalOrderId;
343
+ /**
344
+ * 格式化日期时间为 YYYY-MM-DD hh:mm:ss 格式
345
+ *
346
+ * @param date 要格式化的日期对象
347
+ * @returns 格式化后的日期时间字符串
348
+ */
349
+ private formatDateTime;
160
350
  /**
161
351
  * 从购物车小计数据中提取金额信息
162
352
  */
@@ -173,9 +363,71 @@ export declare class CheckoutImpl extends BaseModule implements Module, Checkout
173
363
  * 计算已支付金额
174
364
  */
175
365
  private calculatePaidAmount;
366
+ /**
367
+ * 计算剩余未支付金额
368
+ */
369
+ private calculateRemainingAmount;
370
+ /**
371
+ * 更新 stateAmount 为当前剩余未支付金额
372
+ */
373
+ private updateStateAmountToRemaining;
374
+ /**
375
+ * 检查订单支付是否完成
376
+ *
377
+ * 当剩余待付款金额 <= 0 时,触发订单支付完成事件
378
+ */
379
+ private checkOrderPaymentCompletion;
380
+ /**
381
+ * 判断支付方式是否需要同步订单到后端
382
+ *
383
+ * 现金支付(CASHMANUAL)和自定义支付不需要同步,其他支付方式需要同步
384
+ *
385
+ * @param paymentCode 支付方式代码
386
+ * @param paymentType 支付方式类型
387
+ * @returns 是否需要同步订单
388
+ */
389
+ private shouldSyncOrderForPayment;
390
+ /**
391
+ * 同步订单到后端
392
+ *
393
+ * 调用后端 /order/checkout 接口创建真实订单
394
+ */
395
+ /**
396
+ * 判断订单ID是否为本地生成的虚拟ID
397
+ *
398
+ * @param orderId 订单ID
399
+ * @returns true 表示是虚拟ID,false 表示是真实的后端ID
400
+ */
401
+ private isVirtualOrderId;
402
+ /**
403
+ * 同步订单到后端并返回真实订单ID
404
+ *
405
+ * @param isManual 是否为手动同步,默认为 false
406
+ * @param customPaymentItems 自定义支付项列表,如果提供则使用此列表而不是从数据库获取
407
+ * @returns 后端返回的真实订单ID
408
+ */
409
+ private syncOrderToBackendWithReturn;
410
+ private syncOrderToBackend;
176
411
  /**
177
412
  * 获取状态消息
178
413
  */
179
414
  private getStatusMessage;
415
+ setOtherParams(params: Record<string, any>, { cover }?: {
416
+ cover?: boolean;
417
+ }): Promise<void>;
418
+ /**
419
+ * 通过订单ID编辑订单备注
420
+ *
421
+ * 用于修改已同步到后端的订单备注,通常在支付成功后的弹窗中使用
422
+ *
423
+ * @param orderId 后端订单ID
424
+ * @param note 新的订单备注
425
+ * @returns 修改结果
426
+ */
427
+ editOrderNoteByOrderIdAsync(orderId: string | number, note: string): Promise<{
428
+ success: boolean;
429
+ message?: string;
430
+ orderId?: string | number;
431
+ }>;
180
432
  destroy(): Promise<void>;
181
433
  }