@pisell/pisellos 2.1.35 → 2.1.36
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.
- package/dist/effects/index.d.ts +0 -1
- package/dist/effects/index.js +6 -29
- package/dist/modules/Account/index.js +3 -2
- package/dist/modules/BaseModule.d.ts +0 -3
- package/dist/modules/BaseModule.js +0 -15
- package/dist/modules/Customer/index.js +10 -9
- package/dist/modules/Customer/types.d.ts +2 -2
- package/dist/modules/Customer/types.js +2 -2
- package/dist/modules/Discount/index.js +1 -1
- package/dist/modules/Guests/index.js +9 -9
- package/dist/modules/Order/index.js +1 -1
- package/dist/modules/Payment/index.js +17 -17
- package/dist/modules/Payment/walletpass.js +1 -4
- package/dist/modules/ProductList/index.js +3 -2
- package/dist/modules/Resource/index.js +1 -1
- package/dist/modules/Rules/index.js +3 -2
- package/dist/solution/BookingByStep/index.js +3 -3
- package/dist/solution/BookingTicket/index.d.ts +0 -4
- package/dist/solution/BookingTicket/index.js +8 -17
- package/dist/solution/BookingTicket/utils/scan/index.d.ts +0 -4
- package/dist/solution/BookingTicket/utils/scan/index.js +16 -25
- package/dist/solution/BuyTickets/index.js +8 -7
- package/dist/solution/Checkout/index.js +35 -35
- package/dist/solution/ShopDiscount/index.js +10 -9
- package/dist/types/index.d.ts +0 -1
- package/lib/effects/index.d.ts +0 -1
- package/lib/effects/index.js +0 -13
- package/lib/modules/Account/index.js +3 -2
- package/lib/modules/BaseModule.d.ts +0 -3
- package/lib/modules/BaseModule.js +0 -9
- package/lib/modules/Customer/index.js +10 -9
- package/lib/modules/Customer/types.d.ts +2 -2
- package/lib/modules/Customer/types.js +2 -2
- package/lib/modules/Discount/index.js +1 -1
- package/lib/modules/Guests/index.js +9 -9
- package/lib/modules/Order/index.js +1 -1
- package/lib/modules/Payment/index.js +16 -16
- package/lib/modules/Payment/walletpass.js +1 -3
- package/lib/modules/ProductList/index.js +3 -2
- package/lib/modules/Resource/index.js +1 -1
- package/lib/modules/Rules/index.js +3 -2
- package/lib/solution/BookingByStep/index.js +2 -2
- package/lib/solution/BookingTicket/index.d.ts +0 -4
- package/lib/solution/BookingTicket/index.js +6 -6
- package/lib/solution/BookingTicket/utils/scan/index.d.ts +0 -4
- package/lib/solution/BookingTicket/utils/scan/index.js +1 -7
- package/lib/solution/BuyTickets/index.js +8 -7
- package/lib/solution/Checkout/index.js +34 -34
- package/lib/solution/ShopDiscount/index.js +11 -10
- package/lib/types/index.d.ts +0 -1
- package/package.json +1 -1
|
@@ -18,7 +18,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
18
18
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
19
19
|
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); }
|
|
20
20
|
import { BaseModule } from "../../modules/BaseModule";
|
|
21
|
-
import { createModule } from "./types";
|
|
21
|
+
import { BookingTicketHooks, createModule } from "./types";
|
|
22
22
|
import Scan from "./utils/scan";
|
|
23
23
|
import { handleGlobalScan, handleCustomerScan, handleUniversalScan } from "./utils/scan/handleScan";
|
|
24
24
|
import scanCache from "./utils/scan/scanCache";
|
|
@@ -109,7 +109,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
109
109
|
throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
|
|
110
110
|
}
|
|
111
111
|
});
|
|
112
|
-
this.core.effects.emit(
|
|
112
|
+
this.core.effects.emit(BookingTicketHooks.onInited, {});
|
|
113
113
|
case 19:
|
|
114
114
|
case "end":
|
|
115
115
|
return _context.stop();
|
|
@@ -152,7 +152,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
152
152
|
}));
|
|
153
153
|
case 5:
|
|
154
154
|
result = _context2.sent;
|
|
155
|
-
this.core.effects.emit(
|
|
155
|
+
this.core.effects.emit(BookingTicketHooks.onProductsLoaded, result);
|
|
156
156
|
return _context2.abrupt("return", result);
|
|
157
157
|
case 10:
|
|
158
158
|
_context2.prev = 10;
|
|
@@ -170,20 +170,11 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
170
170
|
}
|
|
171
171
|
return loadProducts;
|
|
172
172
|
}()
|
|
173
|
-
/**
|
|
174
|
-
* 初始化外设扫码结果监听
|
|
175
|
-
*/
|
|
176
|
-
)
|
|
177
|
-
}, {
|
|
178
|
-
key: "initPeripheralsListener",
|
|
179
|
-
value: function initPeripheralsListener() {
|
|
180
|
-
this.scan.initPeripheralsListener();
|
|
181
|
-
}
|
|
182
|
-
|
|
183
173
|
/**
|
|
184
174
|
* 获取商品列表(不加载到模块中)
|
|
185
175
|
* @returns 商品列表
|
|
186
176
|
*/
|
|
177
|
+
)
|
|
187
178
|
}, {
|
|
188
179
|
key: "getProducts",
|
|
189
180
|
value: (function () {
|
|
@@ -251,7 +242,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
251
242
|
key: "setActiveCustomer",
|
|
252
243
|
value: function setActiveCustomer(customer) {
|
|
253
244
|
this.store.customer.setSelectedCustomer(customer);
|
|
254
|
-
this.core.effects.emit(
|
|
245
|
+
this.core.effects.emit(BookingTicketHooks.onCustomerSelected, {
|
|
255
246
|
customer: customer
|
|
256
247
|
});
|
|
257
248
|
}
|
|
@@ -276,7 +267,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
276
267
|
var customer = this.store.customer.getCustomerById(customerId);
|
|
277
268
|
if (customer) {
|
|
278
269
|
this.store.customer.setSelectedCustomer(customer);
|
|
279
|
-
this.core.effects.emit(
|
|
270
|
+
this.core.effects.emit(BookingTicketHooks.onCustomerSelected, {
|
|
280
271
|
customer: customer
|
|
281
272
|
});
|
|
282
273
|
}
|
|
@@ -407,7 +398,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
407
398
|
return this.store.customer.loadMoreCustomers();
|
|
408
399
|
case 3:
|
|
409
400
|
result = _context6.sent;
|
|
410
|
-
this.core.effects.emit(
|
|
401
|
+
this.core.effects.emit(BookingTicketHooks.onCustomerListUpdate, result);
|
|
411
402
|
return _context6.abrupt("return", result);
|
|
412
403
|
case 8:
|
|
413
404
|
_context6.prev = 8;
|
|
@@ -447,7 +438,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
447
438
|
return this.store.customer.resetAndLoadCustomers(params);
|
|
448
439
|
case 4:
|
|
449
440
|
result = _context7.sent;
|
|
450
|
-
this.core.effects.emit(
|
|
441
|
+
this.core.effects.emit(BookingTicketHooks.onCustomerListReset, result);
|
|
451
442
|
return _context7.abrupt("return", result);
|
|
452
443
|
case 9:
|
|
453
444
|
_context7.prev = 9;
|
|
@@ -18,6 +18,9 @@ var ScanResultType = /*#__PURE__*/function (ScanResultType) {
|
|
|
18
18
|
}(ScanResultType || {});
|
|
19
19
|
var Scan = /*#__PURE__*/function () {
|
|
20
20
|
function Scan(solution, watchKey) {
|
|
21
|
+
var _this$solution,
|
|
22
|
+
_this$solution$mountF,
|
|
23
|
+
_this = this;
|
|
21
24
|
_classCallCheck(this, Scan);
|
|
22
25
|
_defineProperty(this, "solution", void 0);
|
|
23
26
|
_defineProperty(this, "watchKey", void 0);
|
|
@@ -25,36 +28,24 @@ var Scan = /*#__PURE__*/function () {
|
|
|
25
28
|
this.solution = solution;
|
|
26
29
|
this.watchKey = watchKey;
|
|
27
30
|
|
|
28
|
-
//
|
|
29
|
-
this.
|
|
31
|
+
// 监听扫码结果
|
|
32
|
+
(_this$solution = this.solution) === null || _this$solution === void 0 || (_this$solution = _this$solution.window) === null || _this$solution === void 0 || (_this$solution = _this$solution.interaction) === null || _this$solution === void 0 || (_this$solution = _this$solution.utils) === null || _this$solution === void 0 || (_this$solution$mountF = _this$solution.mountFunction) === null || _this$solution$mountF === void 0 || _this$solution$mountF.call(_this$solution, 'global', 'peripheralsResult', function (strVal) {
|
|
33
|
+
try {
|
|
34
|
+
var _result = JSON.parse(strVal);
|
|
35
|
+
console.log('nativeScannerResult>>>>>>>', _result);
|
|
36
|
+
_this.handleScan(_result);
|
|
37
|
+
} catch (err) {
|
|
38
|
+
console.error(err);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
30
41
|
}
|
|
31
42
|
|
|
32
43
|
/**
|
|
33
|
-
*
|
|
44
|
+
* 处理扫码事件
|
|
45
|
+
* @param eventKey 事件key
|
|
46
|
+
* @param value 扫码结果
|
|
34
47
|
*/
|
|
35
48
|
_createClass(Scan, [{
|
|
36
|
-
key: "initPeripheralsListener",
|
|
37
|
-
value: function initPeripheralsListener() {
|
|
38
|
-
var _this$solution,
|
|
39
|
-
_this$solution$mountF,
|
|
40
|
-
_this = this;
|
|
41
|
-
(_this$solution = this.solution) === null || _this$solution === void 0 || (_this$solution = _this$solution.window) === null || _this$solution === void 0 || (_this$solution = _this$solution.interaction) === null || _this$solution === void 0 || (_this$solution = _this$solution.utils) === null || _this$solution === void 0 || (_this$solution$mountF = _this$solution.mountFunction) === null || _this$solution$mountF === void 0 || _this$solution$mountF.call(_this$solution, 'global', 'peripheralsResult', function (strVal) {
|
|
42
|
-
try {
|
|
43
|
-
var _result = JSON.parse(strVal);
|
|
44
|
-
console.log('nativeScannerResult>>>>>>>', _result);
|
|
45
|
-
_this.handleScan(_result);
|
|
46
|
-
} catch (err) {
|
|
47
|
-
console.error(err);
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* 处理扫码事件
|
|
54
|
-
* @param eventKey 事件key
|
|
55
|
-
* @param value 扫码结果
|
|
56
|
-
*/
|
|
57
|
-
}, {
|
|
58
49
|
key: "handleScan",
|
|
59
50
|
value: function handleScan(result) {
|
|
60
51
|
var lastEnableEventKey = watch.getLastEnableEventKey(this.watchKey);
|
|
@@ -24,6 +24,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
24
24
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
25
25
|
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); }
|
|
26
26
|
import { ProductList } from "../../modules/";
|
|
27
|
+
import { BuyTicketsHooks } from "./types";
|
|
27
28
|
import { BaseModule } from "../../modules/BaseModule";
|
|
28
29
|
export * from "./types";
|
|
29
30
|
export var BuyTicketsImpl = /*#__PURE__*/function (_BaseModule) {
|
|
@@ -71,7 +72,7 @@ export var BuyTicketsImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
71
72
|
return this.loadProductsByIds(this.otherParams.prodctIds);
|
|
72
73
|
case 11:
|
|
73
74
|
_context.next = 13;
|
|
74
|
-
return this.core.effects.emit(
|
|
75
|
+
return this.core.effects.emit(BuyTicketsHooks.onInited, {});
|
|
75
76
|
case 13:
|
|
76
77
|
case "end":
|
|
77
78
|
return _context.stop();
|
|
@@ -111,7 +112,7 @@ export var BuyTicketsImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
111
112
|
});
|
|
112
113
|
this.store.mainProducts = mainProducts;
|
|
113
114
|
_context2.next = 8;
|
|
114
|
-
return this.core.effects.emit(
|
|
115
|
+
return this.core.effects.emit(BuyTicketsHooks.onMainProductsLoaded, {});
|
|
115
116
|
case 8:
|
|
116
117
|
case "end":
|
|
117
118
|
return _context2.stop();
|
|
@@ -148,7 +149,7 @@ export var BuyTicketsImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
148
149
|
while (1) switch (_context4.prev = _context4.next) {
|
|
149
150
|
case 0:
|
|
150
151
|
_context4.next = 2;
|
|
151
|
-
return this.core.effects.emit(
|
|
152
|
+
return this.core.effects.emit(BuyTicketsHooks.onDestroy, {});
|
|
152
153
|
case 2:
|
|
153
154
|
console.log('[BuyTickets] 已销毁');
|
|
154
155
|
case 3:
|
|
@@ -194,7 +195,7 @@ export var BuyTicketsImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
194
195
|
case 11:
|
|
195
196
|
otherData = _context5.t1;
|
|
196
197
|
_context5.next = 14;
|
|
197
|
-
return this.core.effects.emit(
|
|
198
|
+
return this.core.effects.emit(BuyTicketsHooks.OnGetProducts, [].concat(_toConsumableArray(mainData), _toConsumableArray(otherData)));
|
|
198
199
|
case 14:
|
|
199
200
|
return _context5.abrupt("return", [].concat(_toConsumableArray(mainData), _toConsumableArray(otherData)));
|
|
200
201
|
case 15:
|
|
@@ -258,7 +259,7 @@ export var BuyTicketsImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
258
259
|
while (1) switch (_context7.prev = _context7.next) {
|
|
259
260
|
case 0:
|
|
260
261
|
_context7.next = 2;
|
|
261
|
-
return this.core.effects.emit(
|
|
262
|
+
return this.core.effects.emit(BuyTicketsHooks.onListSubmit, _objectSpread(_objectSpread({}, data), {}, {
|
|
262
263
|
products: this.getProducts()
|
|
263
264
|
}));
|
|
264
265
|
case 2:
|
|
@@ -297,7 +298,7 @@ export var BuyTicketsImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
297
298
|
while (1) switch (_context8.prev = _context8.next) {
|
|
298
299
|
case 0:
|
|
299
300
|
_context8.next = 2;
|
|
300
|
-
return this.core.effects.emit(
|
|
301
|
+
return this.core.effects.emit(BuyTicketsHooks.onCartSubmit, _objectSpread(_objectSpread({}, data), {}, {
|
|
301
302
|
products: this.getProducts()
|
|
302
303
|
}));
|
|
303
304
|
case 2:
|
|
@@ -319,7 +320,7 @@ export var BuyTicketsImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
319
320
|
while (1) switch (_context9.prev = _context9.next) {
|
|
320
321
|
case 0:
|
|
321
322
|
_context9.next = 2;
|
|
322
|
-
return this.core.effects.emit(
|
|
323
|
+
return this.core.effects.emit(BuyTicketsHooks.onCheckoutSubmit, _objectSpread(_objectSpread({}, data), {}, {
|
|
323
324
|
products: this.getProducts()
|
|
324
325
|
}));
|
|
325
326
|
case 2:
|
|
@@ -32,7 +32,7 @@ import { BaseModule } from "../../modules/BaseModule";
|
|
|
32
32
|
import Decimal from 'decimal.js';
|
|
33
33
|
import { OrderModule } from "../../modules/Order";
|
|
34
34
|
import { PaymentModule } from "../../modules/Payment";
|
|
35
|
-
import { CheckoutErrorType } from "./types";
|
|
35
|
+
import { CheckoutHooks, CheckoutErrorType } from "./types";
|
|
36
36
|
import { PaymentStatus, PaymentHooks } from "../../modules/Payment/types";
|
|
37
37
|
import { validateCheckoutData, createCheckoutError, validateLocalOrderData, generateLocalOrderId, formatDateTime, extractAmountFromCartSummary, isVirtualOrderId, isCashPayment } from "./utils";
|
|
38
38
|
import { getProductDeposit } from "../../modules/Cart/utils";
|
|
@@ -123,7 +123,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
123
123
|
case 19:
|
|
124
124
|
console.log('[Checkout] 初始化完成');
|
|
125
125
|
_context.next = 22;
|
|
126
|
-
return this.core.effects.emit(
|
|
126
|
+
return this.core.effects.emit(CheckoutHooks.OnCheckoutInitialized, {
|
|
127
127
|
timestamp: Date.now()
|
|
128
128
|
});
|
|
129
129
|
case 22:
|
|
@@ -459,7 +459,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
459
459
|
});
|
|
460
460
|
// 触发钱包数据初始化完成事件
|
|
461
461
|
_context8.next = 16;
|
|
462
|
-
return this.core.effects.emit(
|
|
462
|
+
return this.core.effects.emit(CheckoutHooks.OnWalletDataInitialized, {
|
|
463
463
|
orderUuid: (_this$store$currentOr7 = this.store.currentOrder) === null || _this$store$currentOr7 === void 0 ? void 0 : _this$store$currentOr7.uuid,
|
|
464
464
|
customerId: walletBusinessData.customer_id,
|
|
465
465
|
walletBusinessData: {
|
|
@@ -629,7 +629,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
629
629
|
// // 自动支付模式标记
|
|
630
630
|
// }
|
|
631
631
|
|
|
632
|
-
this.core.effects.emit(
|
|
632
|
+
this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
|
|
633
633
|
order: paymentOrder,
|
|
634
634
|
timestamp: Date.now()
|
|
635
635
|
});
|
|
@@ -665,7 +665,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
665
665
|
return this.handleError(_context9.t0, CheckoutErrorType.OrderCreationFailed);
|
|
666
666
|
case 38:
|
|
667
667
|
this.logError('本地订单创建失败:', _context9.t0);
|
|
668
|
-
this.core.effects.emit(
|
|
668
|
+
this.core.effects.emit(CheckoutHooks.OnOrderCreationFailed, {
|
|
669
669
|
error: this.store.lastError,
|
|
670
670
|
timestamp: Date.now()
|
|
671
671
|
});
|
|
@@ -803,7 +803,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
803
803
|
|
|
804
804
|
// 事件通知(复用创建事件,便于上层监听刷新)
|
|
805
805
|
_context10.next = 38;
|
|
806
|
-
return this.core.effects.emit(
|
|
806
|
+
return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
|
|
807
807
|
order: updated,
|
|
808
808
|
timestamp: Date.now()
|
|
809
809
|
});
|
|
@@ -891,7 +891,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
891
891
|
// 清理钱包模块的所有缓存数据
|
|
892
892
|
this.payment.wallet.clearAllCache();
|
|
893
893
|
_context11.next = 11;
|
|
894
|
-
return this.core.effects.emit(
|
|
894
|
+
return this.core.effects.emit(CheckoutHooks.OnCheckoutCompleted, {
|
|
895
895
|
orderId: order.id,
|
|
896
896
|
timestamp: Date.now()
|
|
897
897
|
});
|
|
@@ -1078,7 +1078,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1078
1078
|
|
|
1079
1079
|
// 触发订单更新事件
|
|
1080
1080
|
_context13.next = 11;
|
|
1081
|
-
return this.core.effects.emit(
|
|
1081
|
+
return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
|
|
1082
1082
|
order: updatedOrder,
|
|
1083
1083
|
timestamp: Date.now()
|
|
1084
1084
|
});
|
|
@@ -1158,7 +1158,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1158
1158
|
|
|
1159
1159
|
// 触发金额变更事件
|
|
1160
1160
|
_context14.next = 12;
|
|
1161
|
-
return this.core.effects.emit(
|
|
1161
|
+
return this.core.effects.emit(CheckoutHooks.OnStateAmountChanged, {
|
|
1162
1162
|
oldAmount: oldAmount,
|
|
1163
1163
|
newAmount: formattedAmount,
|
|
1164
1164
|
timestamp: Date.now()
|
|
@@ -1385,7 +1385,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1385
1385
|
return this.handleError(new Error("EFTPOS \u652F\u4ED8\u540E\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(_context16.t0 instanceof Error ? _context16.t0.message : String(_context16.t0))), CheckoutErrorType.OrderCreationFailed);
|
|
1386
1386
|
case 39:
|
|
1387
1387
|
// 触发支付项添加事件(可以复用支付开始事件)
|
|
1388
|
-
this.core.effects.emit(
|
|
1388
|
+
this.core.effects.emit(CheckoutHooks.OnPaymentItemAdded, {
|
|
1389
1389
|
orderUuid: this.store.currentOrder.uuid,
|
|
1390
1390
|
paymentMethodCode: paymentItem.code,
|
|
1391
1391
|
paymentMethodName: paymentItem.name,
|
|
@@ -1498,7 +1498,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1498
1498
|
return this.updateStateAmountToRemaining(false);
|
|
1499
1499
|
case 23:
|
|
1500
1500
|
_context17.next = 25;
|
|
1501
|
-
return this.core.effects.emit(
|
|
1501
|
+
return this.core.effects.emit(CheckoutHooks.OnPaymentStarted, {
|
|
1502
1502
|
orderUuid: this.store.currentOrder.uuid,
|
|
1503
1503
|
paymentMethodCode: paymentItem.code,
|
|
1504
1504
|
amount: "-".concat(paymentItem.amount),
|
|
@@ -1632,7 +1632,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1632
1632
|
return this.updateStateAmountToRemaining(false);
|
|
1633
1633
|
case 29:
|
|
1634
1634
|
_context18.next = 31;
|
|
1635
|
-
return this.core.effects.emit(
|
|
1635
|
+
return this.core.effects.emit(CheckoutHooks.OnPaymentStarted, {
|
|
1636
1636
|
orderUuid: this.store.currentOrder.uuid,
|
|
1637
1637
|
paymentMethodCode: 'VOUCHER_BATCH',
|
|
1638
1638
|
amount: voucherPaymentItems.reduce(function (sum, item) {
|
|
@@ -1737,7 +1737,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1737
1737
|
|
|
1738
1738
|
// 触发订单更新事件
|
|
1739
1739
|
_context19.next = 21;
|
|
1740
|
-
return this.core.effects.emit(
|
|
1740
|
+
return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
|
|
1741
1741
|
order: this.store.currentOrder,
|
|
1742
1742
|
timestamp: Date.now()
|
|
1743
1743
|
});
|
|
@@ -1866,7 +1866,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1866
1866
|
|
|
1867
1867
|
// 触发订单更新事件
|
|
1868
1868
|
_context20.next = 23;
|
|
1869
|
-
return this.core.effects.emit(
|
|
1869
|
+
return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
|
|
1870
1870
|
order: this.store.currentOrder,
|
|
1871
1871
|
timestamp: Date.now()
|
|
1872
1872
|
});
|
|
@@ -2140,7 +2140,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2140
2140
|
|
|
2141
2141
|
// 触发订单取消事件
|
|
2142
2142
|
_context22.next = 32;
|
|
2143
|
-
return this.core.effects.emit(
|
|
2143
|
+
return this.core.effects.emit(CheckoutHooks.OnOrderCancelled, {
|
|
2144
2144
|
orderUuid: currentOrderUuid,
|
|
2145
2145
|
orderId: currentOrderId,
|
|
2146
2146
|
cancelReason: cancelReason,
|
|
@@ -2311,7 +2311,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2311
2311
|
console.warn('[Checkout] 同步备注到Payment模块失败,但本地更新成功:', _context24.t0);
|
|
2312
2312
|
case 17:
|
|
2313
2313
|
_context24.next = 19;
|
|
2314
|
-
return this.core.effects.emit(
|
|
2314
|
+
return this.core.effects.emit(CheckoutHooks.OnOrderNoteChanged, {
|
|
2315
2315
|
orderUuid: (_this$store$currentOr20 = this.store.currentOrder) === null || _this$store$currentOr20 === void 0 ? void 0 : _this$store$currentOr20.uuid,
|
|
2316
2316
|
oldNote: oldNote,
|
|
2317
2317
|
newNote: note,
|
|
@@ -2358,7 +2358,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2358
2358
|
checkoutError = error instanceof Error && 'type' in error ? error : createCheckoutError(type, error.message, error);
|
|
2359
2359
|
this.store.lastError = checkoutError;
|
|
2360
2360
|
_context25.next = 4;
|
|
2361
|
-
return this.core.effects.emit(
|
|
2361
|
+
return this.core.effects.emit(CheckoutHooks.OnError, {
|
|
2362
2362
|
error: checkoutError,
|
|
2363
2363
|
context: {},
|
|
2364
2364
|
timestamp: Date.now()
|
|
@@ -2392,7 +2392,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2392
2392
|
return this.updateStateAmountToRemaining();
|
|
2393
2393
|
case 2:
|
|
2394
2394
|
_context26.next = 4;
|
|
2395
|
-
return this.core.effects.emit(
|
|
2395
|
+
return this.core.effects.emit(CheckoutHooks.OnPaymentSuccess, {
|
|
2396
2396
|
orderUuid: data.orderUuid,
|
|
2397
2397
|
paymentMethodCode: '',
|
|
2398
2398
|
amount: ((_this$store$currentOr21 = this.store.currentOrder) === null || _this$store$currentOr21 === void 0 ? void 0 : _this$store$currentOr21.total_amount) || '0',
|
|
@@ -2430,7 +2430,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2430
2430
|
return this.handleError(error instanceof Error ? error : new Error(String(error)), CheckoutErrorType.PaymentFailed);
|
|
2431
2431
|
case 3:
|
|
2432
2432
|
_context27.next = 5;
|
|
2433
|
-
return this.core.effects.emit(
|
|
2433
|
+
return this.core.effects.emit(CheckoutHooks.OnPaymentFailed, {
|
|
2434
2434
|
orderUuid: data.orderUuid,
|
|
2435
2435
|
paymentMethodCode: '',
|
|
2436
2436
|
amount: ((_this$store$currentOr22 = this.store.currentOrder) === null || _this$store$currentOr22 === void 0 ? void 0 : _this$store$currentOr22.total_amount) || '0',
|
|
@@ -2873,7 +2873,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2873
2873
|
|
|
2874
2874
|
/**
|
|
2875
2875
|
* 计算已支付金额(从 Payment 模块获取最新数据)
|
|
2876
|
-
*
|
|
2876
|
+
*
|
|
2877
2877
|
* 注意:此方法保持独立性,可以单独调用。
|
|
2878
2878
|
* 在 updateStateAmountToRemaining 等批量操作中会使用缓存优化。
|
|
2879
2879
|
*/
|
|
@@ -2965,7 +2965,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2965
2965
|
|
|
2966
2966
|
/**
|
|
2967
2967
|
* 计算剩余未支付金额(从 Payment 模块获取最新数据)
|
|
2968
|
-
*
|
|
2968
|
+
*
|
|
2969
2969
|
* 注意:此方法保持独立性,可以单独调用。
|
|
2970
2970
|
* 在 updateStateAmountToRemaining 等批量操作中会使用缓存优化。
|
|
2971
2971
|
*/
|
|
@@ -3015,7 +3015,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3015
3015
|
}()
|
|
3016
3016
|
/**
|
|
3017
3017
|
* 计算剩余未支付金额(排除定金计算,始终使用订单总金额)
|
|
3018
|
-
*
|
|
3018
|
+
*
|
|
3019
3019
|
* 注意:此方法保持独立性,可以单独调用。
|
|
3020
3020
|
* 在 updateStateAmountToRemaining 等批量操作中会使用缓存优化。
|
|
3021
3021
|
*/
|
|
@@ -3094,7 +3094,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3094
3094
|
|
|
3095
3095
|
// 发出 balanceDueAmount 变更事件
|
|
3096
3096
|
_context35.next = 12;
|
|
3097
|
-
return this.core.effects.emit(
|
|
3097
|
+
return this.core.effects.emit(CheckoutHooks.OnBalanceDueAmountChanged, {
|
|
3098
3098
|
oldAmount: currentBalanceDueAmount,
|
|
3099
3099
|
newAmount: remainingAmount,
|
|
3100
3100
|
timestamp: Date.now(),
|
|
@@ -3132,7 +3132,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3132
3132
|
}()
|
|
3133
3133
|
/**
|
|
3134
3134
|
* 更新 stateAmount 为当前剩余未支付金额
|
|
3135
|
-
*
|
|
3135
|
+
*
|
|
3136
3136
|
* 优化版本:批量获取数据,避免重复查询数据库
|
|
3137
3137
|
*/
|
|
3138
3138
|
)
|
|
@@ -3306,7 +3306,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3306
3306
|
}()
|
|
3307
3307
|
/**
|
|
3308
3308
|
* 检查订单支付是否完成(优化版,复用已获取的数据)
|
|
3309
|
-
*
|
|
3309
|
+
*
|
|
3310
3310
|
* @param paymentItems 已获取的支付项数据
|
|
3311
3311
|
* @param remainingAmount 已计算的剩余金额
|
|
3312
3312
|
*/
|
|
@@ -3415,7 +3415,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3415
3415
|
* 检查订单支付是否完成
|
|
3416
3416
|
*
|
|
3417
3417
|
* 当剩余待付款金额 <= 0 时,触发订单支付完成事件
|
|
3418
|
-
*
|
|
3418
|
+
*
|
|
3419
3419
|
* 注意:此方法保持独立性,可以单独调用。
|
|
3420
3420
|
* 在 updateStateAmountToRemaining 中会使用优化版本。
|
|
3421
3421
|
*/
|
|
@@ -3514,7 +3514,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3514
3514
|
}
|
|
3515
3515
|
case 27:
|
|
3516
3516
|
_context38.next = 29;
|
|
3517
|
-
return this.core.effects.emit(
|
|
3517
|
+
return this.core.effects.emit(CheckoutHooks.OnOrderPaymentCompleted, {
|
|
3518
3518
|
orderUuid: this.store.currentOrder.uuid,
|
|
3519
3519
|
orderId: this.store.currentOrder.order_id,
|
|
3520
3520
|
totalAmount: totalAmount,
|
|
@@ -3752,7 +3752,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3752
3752
|
// 发送下单接口请求开始事件
|
|
3753
3753
|
startTime = Date.now();
|
|
3754
3754
|
_context39.next = 27;
|
|
3755
|
-
return this.core.effects.emit(
|
|
3755
|
+
return this.core.effects.emit(CheckoutHooks.OnOrderSubmitStart, {
|
|
3756
3756
|
orderUuid: this.store.currentOrder.uuid,
|
|
3757
3757
|
operation: isUpdateOperation ? 'update' : 'create',
|
|
3758
3758
|
isManual: isManual,
|
|
@@ -3786,7 +3786,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3786
3786
|
|
|
3787
3787
|
// 发送订单同步失败事件(网络错误或请求失败)
|
|
3788
3788
|
_context39.next = 44;
|
|
3789
|
-
return this.core.effects.emit(
|
|
3789
|
+
return this.core.effects.emit(CheckoutHooks.OnOrderSyncFailed, {
|
|
3790
3790
|
orderUuid: this.store.currentOrder.uuid,
|
|
3791
3791
|
operation: isUpdateOperation ? 'update' : 'create',
|
|
3792
3792
|
isManual: isManual,
|
|
@@ -3800,7 +3800,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3800
3800
|
case 45:
|
|
3801
3801
|
_context39.prev = 45;
|
|
3802
3802
|
_context39.next = 48;
|
|
3803
|
-
return this.core.effects.emit(
|
|
3803
|
+
return this.core.effects.emit(CheckoutHooks.OnOrderSubmitEnd, {
|
|
3804
3804
|
success: submitSuccess,
|
|
3805
3805
|
orderUuid: this.store.currentOrder.uuid,
|
|
3806
3806
|
operation: isUpdateOperation ? 'update' : 'create',
|
|
@@ -3822,7 +3822,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3822
3822
|
}
|
|
3823
3823
|
errorMessage = ((_checkoutResponse5 = checkoutResponse) === null || _checkoutResponse5 === void 0 ? void 0 : _checkoutResponse5.message) || '订单同步失败,后端返回非成功状态'; // 发送订单同步失败事件
|
|
3824
3824
|
_context39.next = 55;
|
|
3825
|
-
return this.core.effects.emit(
|
|
3825
|
+
return this.core.effects.emit(CheckoutHooks.OnOrderSyncFailed, {
|
|
3826
3826
|
orderUuid: this.store.currentOrder.uuid,
|
|
3827
3827
|
operation: isUpdateOperation ? 'update' : 'create',
|
|
3828
3828
|
isManual: isManual,
|
|
@@ -3958,7 +3958,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3958
3958
|
|
|
3959
3959
|
// 触发订单同步完成事件
|
|
3960
3960
|
_context39.next = 107;
|
|
3961
|
-
return this.core.effects.emit(
|
|
3961
|
+
return this.core.effects.emit(CheckoutHooks.OnOrderSynced, {
|
|
3962
3962
|
orderUuid: this.store.currentOrder.uuid,
|
|
3963
3963
|
realOrderId: realOrderId,
|
|
3964
3964
|
virtualOrderId: this.store.currentOrder.order_id,
|
|
@@ -4085,7 +4085,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4085
4085
|
|
|
4086
4086
|
// 触发订单备注变更事件
|
|
4087
4087
|
_context41.next = 15;
|
|
4088
|
-
return this.core.effects.emit(
|
|
4088
|
+
return this.core.effects.emit(CheckoutHooks.OnOrderNoteChanged, {
|
|
4089
4089
|
orderUuid: this.store.currentOrder.uuid,
|
|
4090
4090
|
oldNote: previousNote,
|
|
4091
4091
|
newNote: note,
|
|
@@ -4335,7 +4335,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4335
4335
|
* 重置 store 状态
|
|
4336
4336
|
*
|
|
4337
4337
|
* 在创建新订单前调用,确保状态完全干净
|
|
4338
|
-
*
|
|
4338
|
+
*
|
|
4339
4339
|
* 🚀 性能优化:改为同步方法,事件发射不阻塞主流程
|
|
4340
4340
|
*/
|
|
4341
4341
|
}, {
|
|
@@ -4376,7 +4376,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4376
4376
|
// 使用 setTimeout 确保事件处理不会阻塞状态重置
|
|
4377
4377
|
if (prevOrderInfo) {
|
|
4378
4378
|
setTimeout(function () {
|
|
4379
|
-
_this6.core.effects.emit(
|
|
4379
|
+
_this6.core.effects.emit(CheckoutHooks.OnOrderCleared, {
|
|
4380
4380
|
previousOrder: prevOrderInfo,
|
|
4381
4381
|
timestamp: Date.now()
|
|
4382
4382
|
});
|
|
@@ -25,6 +25,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
25
25
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
26
26
|
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); }
|
|
27
27
|
import { BaseModule } from "../../modules/BaseModule";
|
|
28
|
+
import { ShopDiscountHooks } from "./types";
|
|
28
29
|
import { DiscountModule } from "../../modules/Discount";
|
|
29
30
|
import { RulesModule } from "../../modules/Rules";
|
|
30
31
|
import Decimal from 'decimal.js';
|
|
@@ -103,7 +104,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
103
104
|
(_this$store$rules = this.store.rules) === null || _this$store$rules === void 0 || _this$store$rules.destroy();
|
|
104
105
|
this.core.effects.offByModuleDestroy(this.name);
|
|
105
106
|
_context2.next = 7;
|
|
106
|
-
return this.core.effects.emit(
|
|
107
|
+
return this.core.effects.emit(ShopDiscountHooks.onDestroy, {});
|
|
107
108
|
case 7:
|
|
108
109
|
console.log('[ShopDiscount] 已销毁');
|
|
109
110
|
case 8:
|
|
@@ -191,7 +192,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
191
192
|
key: "registerEventListeners",
|
|
192
193
|
value: function registerEventListeners() {
|
|
193
194
|
var _this2 = this;
|
|
194
|
-
this.core.effects.
|
|
195
|
+
this.core.effects.on(ShopDiscountHooks.onCustomerChange, function (customer) {
|
|
195
196
|
var _this2$options$otherP;
|
|
196
197
|
if ((_this2$options$otherP = _this2.options.otherParams) !== null && _this2$options$otherP !== void 0 && _this2$options$otherP.cacheId && _this2.getDiscountList().length) {
|
|
197
198
|
return;
|
|
@@ -222,7 +223,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
222
223
|
}
|
|
223
224
|
this.store.customer = customer;
|
|
224
225
|
_context4.next = 4;
|
|
225
|
-
return this.core.effects.emit(
|
|
226
|
+
return this.core.effects.emit(ShopDiscountHooks.onCustomerChange, customer);
|
|
226
227
|
case 4:
|
|
227
228
|
case "end":
|
|
228
229
|
return _context4.stop();
|
|
@@ -447,7 +448,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
447
448
|
while (1) switch (_context6.prev = _context6.next) {
|
|
448
449
|
case 0:
|
|
449
450
|
_context6.next = 2;
|
|
450
|
-
return this.core.effects.emit(
|
|
451
|
+
return this.core.effects.emit(ShopDiscountHooks.onDiscountListChange, discountList);
|
|
451
452
|
case 2:
|
|
452
453
|
case "end":
|
|
453
454
|
return _context6.stop();
|
|
@@ -578,7 +579,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
578
579
|
customer = Object.assign({}, (_objectDestructuringEmpty(_result.data), _result.data));
|
|
579
580
|
this.setCustomer(customer);
|
|
580
581
|
_context7.next = 9;
|
|
581
|
-
return this.core.effects.emit(
|
|
582
|
+
return this.core.effects.emit(ShopDiscountHooks.onScanCustomerChange, customer);
|
|
582
583
|
case 9:
|
|
583
584
|
_context7.next = 14;
|
|
584
585
|
break;
|
|
@@ -615,10 +616,10 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
615
616
|
_result2 = this.calcDiscount(this.store.productList);
|
|
616
617
|
cb === null || cb === void 0 || cb(_result2);
|
|
617
618
|
_context8.next = 7;
|
|
618
|
-
return this.core.effects.emit(
|
|
619
|
+
return this.core.effects.emit(ShopDiscountHooks.onLoadPrepareCalcResult, _result2);
|
|
619
620
|
case 7:
|
|
620
621
|
_context8.next = 9;
|
|
621
|
-
return this.core.effects.emit(
|
|
622
|
+
return this.core.effects.emit(ShopDiscountHooks.onLoadDiscountList, newDiscountList);
|
|
622
623
|
case 9:
|
|
623
624
|
case "end":
|
|
624
625
|
return _context8.stop();
|
|
@@ -669,10 +670,10 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
669
670
|
}
|
|
670
671
|
_result3 = this.calcDiscount(this.store.productList);
|
|
671
672
|
_context9.next = 15;
|
|
672
|
-
return this.core.effects.emit(
|
|
673
|
+
return this.core.effects.emit(ShopDiscountHooks.onLoadPrepareCalcResult, _result3);
|
|
673
674
|
case 15:
|
|
674
675
|
_context9.next = 17;
|
|
675
|
-
return this.core.effects.emit(
|
|
676
|
+
return this.core.effects.emit(ShopDiscountHooks.onLoadDiscountList, newDiscountList);
|
|
676
677
|
case 17:
|
|
677
678
|
_context9.next = 22;
|
|
678
679
|
break;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -40,7 +40,6 @@ export interface PisellCore {
|
|
|
40
40
|
effects: {
|
|
41
41
|
on: (event: string, callback: (payload: any) => void) => () => void;
|
|
42
42
|
once: (event: string, callback: (payload: any) => void) => () => void;
|
|
43
|
-
only: (event: string, callback: (payload: any) => void) => () => void;
|
|
44
43
|
off: (event: string, callback: (payload: any) => void) => void;
|
|
45
44
|
emit: (event: string, payload: any, value?: any) => Promise<{
|
|
46
45
|
status: boolean;
|
package/lib/effects/index.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ type UnsubscribeFunction = () => void;
|
|
|
6
6
|
declare class EffectsManager {
|
|
7
7
|
private listeners;
|
|
8
8
|
on(event: string, callback: EffectCallback): UnsubscribeFunction;
|
|
9
|
-
only(event: string, callback: EffectCallback): UnsubscribeFunction;
|
|
10
9
|
off(event: string, callback: EffectCallback): void;
|
|
11
10
|
offByModuleDestroy(module: string): void;
|
|
12
11
|
once(event: string, callback: EffectCallback): UnsubscribeFunction;
|
package/lib/effects/index.js
CHANGED
|
@@ -35,19 +35,6 @@ var EffectsManager = class {
|
|
|
35
35
|
this.off(event, callback);
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
-
// 设置单例监听器,只能存在一个,新的会替换旧的
|
|
39
|
-
only(event, callback) {
|
|
40
|
-
var _a, _b;
|
|
41
|
-
if (this.listeners.has(event)) {
|
|
42
|
-
(_a = this.listeners.get(event)) == null ? void 0 : _a.clear();
|
|
43
|
-
} else {
|
|
44
|
-
this.listeners.set(event, /* @__PURE__ */ new Set());
|
|
45
|
-
}
|
|
46
|
-
(_b = this.listeners.get(event)) == null ? void 0 : _b.add(callback);
|
|
47
|
-
return () => {
|
|
48
|
-
this.off(event, callback);
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
38
|
off(event, callback) {
|
|
52
39
|
var _a;
|
|
53
40
|
(_a = this.listeners.get(event)) == null ? void 0 : _a.delete(callback);
|