@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,6 +1,6 @@
1
1
  import { Module } from '../../types';
2
2
  import { OrderModule } from '../../modules/Order';
3
- import { PaymentModule, PaymentModuleAPI, PaymentOrder, PaymentMethod, PaymentStatus } from '../../modules/Payment';
3
+ import { PaymentModuleAPI, PaymentOrder, PaymentMethod, PaymentStatus, PaymentItem, PaymentItemInput } from '../../modules/Payment';
4
4
  import { CartItem } from '../../modules/Cart/types';
5
5
  /**
6
6
  * 结账状态枚举
@@ -125,6 +125,7 @@ export interface CreateLocalOrderParams {
125
125
  cartSummary: CartSummaryItem[];
126
126
  /** 是否自动进入支付流程 */
127
127
  autoPayment?: boolean;
128
+ totalInfo: any;
128
129
  }
129
130
  /**
130
131
  * 手动下单参数
@@ -159,6 +160,16 @@ export interface LocalOrderData {
159
160
  relation_products: any[];
160
161
  /** 关联表单 */
161
162
  relation_forms: any[];
163
+ /** 客户ID */
164
+ customer_id?: string;
165
+ /** 客户姓名 */
166
+ customer_name?: string;
167
+ /** 创建时间 (YYYY-MM-DD hh:mm:ss) */
168
+ created_at?: string;
169
+ /** 附加费用 */
170
+ surcharge_fee?: number;
171
+ /** 商店折扣金额 */
172
+ shop_discount?: number;
162
173
  }
163
174
  /**
164
175
  * 本地预订项
@@ -368,16 +379,22 @@ export declare enum CheckoutHooks {
368
379
  /** 结账取消 */
369
380
  OnCheckoutCancelled = "checkout:onCancelled",
370
381
  /** 错误发生 */
371
- OnError = "checkout:onError"
382
+ OnError = "checkout:onError",
383
+ /** 自定义支付金额变更 */
384
+ OnStateAmountChanged = "checkout:onStateAmountChanged",
385
+ /** 订单支付完成(待付款金额 ≤ 0) */
386
+ OnOrderPaymentCompleted = "checkout:onOrderPaymentCompleted",
387
+ /** 订单同步到后端完成 */
388
+ OnOrderSynced = "checkout:onOrderSynced",
389
+ /** 订单备注变更 */
390
+ OnOrderNoteChanged = "checkout:onOrderNoteChanged",
391
+ /** 商店折扣变更 */
392
+ OnShopDiscountChanged = "checkout:onShopDiscountChanged"
372
393
  }
373
394
  /**
374
395
  * 结账状态数据
375
396
  */
376
397
  export interface CheckoutState {
377
- /** 订单模块 */
378
- order: OrderModule;
379
- /** 支付模块 */
380
- payment: PaymentModule;
381
398
  /** 当前状态 */
382
399
  status: CheckoutStatus;
383
400
  /** 当前步骤 */
@@ -388,10 +405,21 @@ export interface CheckoutState {
388
405
  cartItems: CartItem[];
389
406
  /** 本地订单数据 */
390
407
  localOrderData?: LocalOrderData;
408
+ /** 购物车小计数据 */
409
+ cartSummary?: CartSummaryItem[];
391
410
  /** 可用支付方式 */
392
411
  paymentMethods: PaymentMethod[];
393
412
  /** 错误信息 */
394
413
  lastError?: CheckoutError;
414
+ /** UI 自定义支付金额 */
415
+ stateAmount: string;
416
+ /** 订单是否已同步到后端 */
417
+ isOrderSynced: boolean;
418
+ /** 当前客户信息 */
419
+ currentCustomer?: {
420
+ customer_id?: string;
421
+ customer_name?: string;
422
+ };
395
423
  }
396
424
  /**
397
425
  * 当前订单基础信息
@@ -485,6 +513,10 @@ export interface CheckoutModuleAPI extends Module {
485
513
  * 获取当前订单基础信息
486
514
  */
487
515
  getCurrentOrderInfo(): CurrentOrderInfo | null;
516
+ /**
517
+ * 获取当前订单的支付项
518
+ */
519
+ getCurrentOrderPaymentItemsAsync(): Promise<PaymentItem[]>;
488
520
  /**
489
521
  * 验证结账前置条件
490
522
  */
@@ -512,6 +544,137 @@ export interface CheckoutModuleAPI extends Module {
512
544
  * 替换本地订单ID为真实订单ID
513
545
  */
514
546
  replaceLocalOrderIdAsync(newOrderId: string): Promise<PaymentOrder | null>;
547
+ /**
548
+ * 设置自定义支付金额
549
+ */
550
+ setStateAmountAsync(amount: string): Promise<void>;
551
+ /**
552
+ * 获取当前自定义支付金额
553
+ */
554
+ getStateAmount(): string;
555
+ /**
556
+ * 刷新 stateAmount 为当前剩余未支付金额
557
+ */
558
+ refreshStateAmountAsync(): Promise<void>;
559
+ /**
560
+ * 获取购物车小计数据
561
+ */
562
+ getCartSummary(): CartSummaryItem[] | null;
563
+ /**
564
+ * 获取提取的金额详细信息
565
+ */
566
+ getExtractedAmountInfo(): ExtractedAmountInfo | null;
567
+ /**
568
+ * 获取支付方式列表(直接调用 Payment 模块)
569
+ */
570
+ getPaymentMethodsAsync(): Promise<PaymentMethod[]>;
571
+ /**
572
+ * 为当前订单添加支付项
573
+ */
574
+ addPaymentItemAsync(paymentItem: PaymentItemInput): Promise<void>;
575
+ /**
576
+ * 删除当前订单的支付项
577
+ */
578
+ deletePaymentItemAsync(paymentUuid: string): Promise<void>;
579
+ /**
580
+ * 批量更新当前订单的代金券支付项(覆盖更新)
581
+ */
582
+ updateVoucherPaymentItemsAsync(voucherPaymentItems: PaymentItemInput[]): Promise<void>;
583
+ /**
584
+ * 修改当前订单的定金状态
585
+ */
586
+ updateOrderDepositStatusAsync(isDeposit: number): Promise<void>;
587
+ /**
588
+ * 更新当前订单的客户信息
589
+ */
590
+ updateOrderCustomerAsync(customer: {
591
+ customer_id?: string;
592
+ customer_name?: string;
593
+ }): Promise<void>;
594
+ /**
595
+ * 获取当前订单的客户信息
596
+ */
597
+ getCurrentCustomer(): {
598
+ customer_id?: string;
599
+ customer_name?: string;
600
+ } | null;
601
+ /**
602
+ * 手动同步订单到后端
603
+ *
604
+ * 用于强制同步订单到后端,特别适用于纯代金券支付完成的订单
605
+ */
606
+ manualSyncOrderAsync(): Promise<{
607
+ success: boolean;
608
+ message?: string;
609
+ orderId?: string;
610
+ orderUuid?: string;
611
+ }>;
612
+ /**
613
+ * 检查订单是否需要手动同步
614
+ *
615
+ * 返回订单是否为纯代金券支付且待付金额<=0但未同步的状态
616
+ */
617
+ needsManualSync(): boolean;
618
+ /**
619
+ * 更新订单备注
620
+ *
621
+ * @param note 订单备注内容
622
+ */
623
+ updateOrderNoteAsync(note: string): Promise<void>;
624
+ /**
625
+ * 获取当前订单备注
626
+ *
627
+ * @returns 当前订单的备注内容,如果没有则返回空字符串
628
+ */
629
+ getOrderNote(): string;
630
+ /**
631
+ * 获取当前订单ID
632
+ *
633
+ * @returns 当前订单的ID,如果没有订单则返回null
634
+ */
635
+ getCurrentOrderId(): string | null;
636
+ /**
637
+ * 更新订单商店折扣
638
+ *
639
+ * 同时更新cartSummary和localOrderData中的shop_discount值
640
+ *
641
+ * @param discountAmount 商店折扣金额
642
+ */
643
+ updateShopDiscountAsync(discountAmount: number): Promise<void>;
644
+ /**
645
+ * 获取当前商店折扣金额
646
+ *
647
+ * @returns 当前的商店折扣金额,如果没有则返回0
648
+ */
649
+ getShopDiscount(): number;
650
+ /**
651
+ * 保存订单并稍后支付
652
+ *
653
+ * 将当前订单保存到后端,但排除代金券类支付项(voucher_id),
654
+ * 适用于用户想要保存订单但稍后完成支付的场景
655
+ *
656
+ * @returns 保存结果,包含订单ID和状态
657
+ */
658
+ saveForLaterPaymentAsync(): Promise<{
659
+ success: boolean;
660
+ message?: string;
661
+ orderId?: string;
662
+ orderUuid?: string;
663
+ }>;
664
+ /**
665
+ * 通过订单ID编辑订单备注
666
+ *
667
+ * 用于修改已同步到后端的订单备注,通常在支付成功后的弹窗中使用
668
+ *
669
+ * @param orderId 后端订单ID
670
+ * @param note 新的订单备注
671
+ * @returns 修改结果
672
+ */
673
+ editOrderNoteByOrderIdAsync(orderId: string | number, note: string): Promise<{
674
+ success: boolean;
675
+ message?: string;
676
+ orderId?: string | number;
677
+ }>;
515
678
  }
516
679
  /**
517
680
  * 结账事件数据类型
@@ -547,4 +710,42 @@ export interface CheckoutEventData {
547
710
  context?: any;
548
711
  timestamp: number;
549
712
  };
713
+ /** 自定义支付金额变更事件 */
714
+ stateAmountChanged: {
715
+ oldAmount: string;
716
+ newAmount: string;
717
+ timestamp: number;
718
+ };
719
+ /** 订单支付完成事件 */
720
+ orderPaymentCompleted: {
721
+ orderUuid: string;
722
+ orderId: string;
723
+ totalAmount: string;
724
+ paidAmount: string;
725
+ remainingAmount: string;
726
+ timestamp: number;
727
+ };
728
+ /** 订单同步到后端完成事件 */
729
+ orderSynced: {
730
+ orderUuid: string;
731
+ realOrderId: string;
732
+ virtualOrderId: string;
733
+ timestamp: number;
734
+ /** 是否为手动同步 */
735
+ isManual?: boolean;
736
+ };
737
+ /** 订单备注变更事件 */
738
+ orderNoteChanged: {
739
+ orderUuid?: string;
740
+ oldNote: string;
741
+ newNote: string;
742
+ timestamp: number;
743
+ };
744
+ /** 商店折扣变更事件 */
745
+ shopDiscountChanged: {
746
+ orderUuid?: string;
747
+ oldDiscount: number;
748
+ newDiscount: number;
749
+ timestamp: number;
750
+ };
550
751
  }
@@ -64,6 +64,11 @@ var CheckoutHooks = /* @__PURE__ */ ((CheckoutHooks2) => {
64
64
  CheckoutHooks2["OnCheckoutCompleted"] = "checkout:onCompleted";
65
65
  CheckoutHooks2["OnCheckoutCancelled"] = "checkout:onCancelled";
66
66
  CheckoutHooks2["OnError"] = "checkout:onError";
67
+ CheckoutHooks2["OnStateAmountChanged"] = "checkout:onStateAmountChanged";
68
+ CheckoutHooks2["OnOrderPaymentCompleted"] = "checkout:onOrderPaymentCompleted";
69
+ CheckoutHooks2["OnOrderSynced"] = "checkout:onOrderSynced";
70
+ CheckoutHooks2["OnOrderNoteChanged"] = "checkout:onOrderNoteChanged";
71
+ CheckoutHooks2["OnShopDiscountChanged"] = "checkout:onShopDiscountChanged";
67
72
  return CheckoutHooks2;
68
73
  })(CheckoutHooks || {});
69
74
  // Annotate the CommonJS export names for ESM import in node:
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.230",
4
+ "version": "0.0.232",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -1,11 +0,0 @@
1
- import { WalletPayment } from './types';
2
- import type { PaymentModule } from './index';
3
- /**
4
- * 钱包支付实现
5
- */
6
- export declare class WalletPaymentImpl implements WalletPayment {
7
- private paymentModule;
8
- constructor(paymentModule: PaymentModule);
9
- processWalletPayment(amount: number, orderUuid: string, voucherId?: string): Promise<void>;
10
- getWalletBalance(voucherId: string): Promise<number>;
11
- }
@@ -1,78 +0,0 @@
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 _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
- 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
- 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
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
7
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
8
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
- /**
11
- * 钱包支付实现
12
- */
13
- export var WalletPaymentImpl = /*#__PURE__*/function () {
14
- function WalletPaymentImpl(paymentModule) {
15
- _classCallCheck(this, WalletPaymentImpl);
16
- this.paymentModule = paymentModule;
17
- }
18
- _createClass(WalletPaymentImpl, [{
19
- key: "processWalletPayment",
20
- value: function () {
21
- var _processWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(amount, orderUuid, voucherId) {
22
- var walletMethod, paymentItem;
23
- return _regeneratorRuntime().wrap(function _callee$(_context) {
24
- while (1) switch (_context.prev = _context.next) {
25
- case 0:
26
- _context.next = 2;
27
- return this.paymentModule.getWalletPaymentMethod();
28
- case 2:
29
- walletMethod = _context.sent;
30
- if (walletMethod) {
31
- _context.next = 5;
32
- break;
33
- }
34
- throw new Error('钱包支付方式未找到');
35
- case 5:
36
- paymentItem = {
37
- amount: amount.toString(),
38
- code: walletMethod.code,
39
- id: walletMethod.id,
40
- name: walletMethod.name,
41
- type: walletMethod.type,
42
- voucher_id: voucherId || ''
43
- };
44
- _context.next = 8;
45
- return this.paymentModule.pushPaymentAsync(orderUuid, paymentItem);
46
- case 8:
47
- case "end":
48
- return _context.stop();
49
- }
50
- }, _callee, this);
51
- }));
52
- function processWalletPayment(_x, _x2, _x3) {
53
- return _processWalletPayment.apply(this, arguments);
54
- }
55
- return processWalletPayment;
56
- }()
57
- }, {
58
- key: "getWalletBalance",
59
- value: function () {
60
- var _getWalletBalance = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(voucherId) {
61
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
62
- while (1) switch (_context2.prev = _context2.next) {
63
- case 0:
64
- return _context2.abrupt("return", 0);
65
- case 1:
66
- case "end":
67
- return _context2.stop();
68
- }
69
- }, _callee2);
70
- }));
71
- function getWalletBalance(_x4) {
72
- return _getWalletBalance.apply(this, arguments);
73
- }
74
- return getWalletBalance;
75
- }()
76
- }]);
77
- return WalletPaymentImpl;
78
- }();
@@ -1,11 +0,0 @@
1
- import { WalletPayment } from './types';
2
- import type { PaymentModule } from './index';
3
- /**
4
- * 钱包支付实现
5
- */
6
- export declare class WalletPaymentImpl implements WalletPayment {
7
- private paymentModule;
8
- constructor(paymentModule: PaymentModule);
9
- processWalletPayment(amount: number, orderUuid: string, voucherId?: string): Promise<void>;
10
- getWalletBalance(voucherId: string): Promise<number>;
11
- }
@@ -1,51 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/modules/Payment/wallet.ts
20
- var wallet_exports = {};
21
- __export(wallet_exports, {
22
- WalletPaymentImpl: () => WalletPaymentImpl
23
- });
24
- module.exports = __toCommonJS(wallet_exports);
25
- var WalletPaymentImpl = class {
26
- constructor(paymentModule) {
27
- this.paymentModule = paymentModule;
28
- }
29
- async processWalletPayment(amount, orderUuid, voucherId) {
30
- const walletMethod = await this.paymentModule.getWalletPaymentMethod();
31
- if (!walletMethod) {
32
- throw new Error("钱包支付方式未找到");
33
- }
34
- const paymentItem = {
35
- amount: amount.toString(),
36
- code: walletMethod.code,
37
- id: walletMethod.id,
38
- name: walletMethod.name,
39
- type: walletMethod.type,
40
- voucher_id: voucherId || ""
41
- };
42
- await this.paymentModule.pushPaymentAsync(orderUuid, paymentItem);
43
- }
44
- async getWalletBalance(voucherId) {
45
- return 0;
46
- }
47
- };
48
- // Annotate the CommonJS export names for ESM import in node:
49
- 0 && (module.exports = {
50
- WalletPaymentImpl
51
- });