@pisell/pisellos 2.1.34 → 2.1.35
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 +1 -0
- package/dist/effects/index.js +29 -6
- package/dist/modules/Account/index.js +2 -3
- package/dist/modules/BaseModule.d.ts +3 -0
- package/dist/modules/BaseModule.js +15 -0
- package/dist/modules/Customer/index.js +9 -10
- 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 +4 -1
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +2 -3
- package/dist/modules/Resource/index.js +1 -1
- package/dist/modules/Rules/index.js +2 -3
- package/dist/solution/BookingByStep/index.js +2 -2
- package/dist/solution/BookingTicket/index.d.ts +4 -0
- package/dist/solution/BookingTicket/index.js +17 -8
- package/dist/solution/BookingTicket/utils/scan/index.d.ts +4 -0
- package/dist/solution/BookingTicket/utils/scan/index.js +25 -16
- package/dist/solution/BuyTickets/index.js +7 -8
- package/dist/solution/Checkout/index.js +35 -35
- package/dist/solution/ShopDiscount/index.js +9 -10
- package/dist/types/index.d.ts +1 -0
- package/lib/effects/index.d.ts +1 -0
- package/lib/effects/index.js +13 -0
- package/lib/modules/Account/index.js +2 -3
- package/lib/modules/BaseModule.d.ts +3 -0
- package/lib/modules/BaseModule.js +9 -0
- package/lib/modules/Customer/index.js +9 -10
- 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 +3 -1
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +2 -3
- package/lib/modules/Resource/index.js +1 -1
- package/lib/modules/Rules/index.js +2 -3
- package/lib/solution/BookingByStep/index.js +1 -1
- package/lib/solution/BookingTicket/index.d.ts +4 -0
- package/lib/solution/BookingTicket/index.js +6 -6
- package/lib/solution/BookingTicket/utils/scan/index.d.ts +4 -0
- package/lib/solution/BookingTicket/utils/scan/index.js +7 -1
- package/lib/solution/BuyTickets/index.js +7 -8
- package/lib/solution/Checkout/index.js +34 -34
- package/lib/solution/ShopDiscount/index.js +10 -11
- package/lib/types/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/effects/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ 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;
|
|
9
10
|
off(event: string, callback: EffectCallback): void;
|
|
10
11
|
offByModuleDestroy(module: string): void;
|
|
11
12
|
once(event: string, callback: EffectCallback): UnsubscribeFunction;
|
package/dist/effects/index.js
CHANGED
|
@@ -30,28 +30,51 @@ var EffectsManager = /*#__PURE__*/function () {
|
|
|
30
30
|
_this.off(event, callback);
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
+
|
|
34
|
+
// 设置单例监听器,只能存在一个,新的会替换旧的
|
|
35
|
+
}, {
|
|
36
|
+
key: "only",
|
|
37
|
+
value: function only(event, callback) {
|
|
38
|
+
var _this$listeners$get3,
|
|
39
|
+
_this2 = this;
|
|
40
|
+
// 清除该事件的所有现有监听器
|
|
41
|
+
if (this.listeners.has(event)) {
|
|
42
|
+
var _this$listeners$get2;
|
|
43
|
+
(_this$listeners$get2 = this.listeners.get(event)) === null || _this$listeners$get2 === void 0 || _this$listeners$get2.clear();
|
|
44
|
+
} else {
|
|
45
|
+
this.listeners.set(event, new Set());
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// 添加新的监听器
|
|
49
|
+
(_this$listeners$get3 = this.listeners.get(event)) === null || _this$listeners$get3 === void 0 || _this$listeners$get3.add(callback);
|
|
50
|
+
|
|
51
|
+
// 返回取消函数
|
|
52
|
+
return function () {
|
|
53
|
+
_this2.off(event, callback);
|
|
54
|
+
};
|
|
55
|
+
}
|
|
33
56
|
}, {
|
|
34
57
|
key: "off",
|
|
35
58
|
value: function off(event, callback) {
|
|
36
|
-
var _this$listeners$
|
|
37
|
-
(_this$listeners$
|
|
59
|
+
var _this$listeners$get4;
|
|
60
|
+
(_this$listeners$get4 = this.listeners.get(event)) === null || _this$listeners$get4 === void 0 || _this$listeners$get4.delete(callback);
|
|
38
61
|
}
|
|
39
62
|
|
|
40
63
|
// 模块销毁时,删除所有以模块名开头的监听
|
|
41
64
|
}, {
|
|
42
65
|
key: "offByModuleDestroy",
|
|
43
66
|
value: function offByModuleDestroy(module) {
|
|
44
|
-
var
|
|
67
|
+
var _this3 = this;
|
|
45
68
|
Array.from(this.listeners.keys()).forEach(function (item) {
|
|
46
69
|
if (item.startsWith(module)) {
|
|
47
|
-
|
|
70
|
+
_this3.listeners.delete(item);
|
|
48
71
|
}
|
|
49
72
|
});
|
|
50
73
|
}
|
|
51
74
|
}, {
|
|
52
75
|
key: "once",
|
|
53
76
|
value: function once(event, callback) {
|
|
54
|
-
var
|
|
77
|
+
var _this4 = this;
|
|
55
78
|
var wrapper = /*#__PURE__*/function () {
|
|
56
79
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(payload) {
|
|
57
80
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
@@ -60,7 +83,7 @@ var EffectsManager = /*#__PURE__*/function () {
|
|
|
60
83
|
_context.next = 2;
|
|
61
84
|
return callback(payload);
|
|
62
85
|
case 2:
|
|
63
|
-
|
|
86
|
+
_this4.off(event, wrapper);
|
|
64
87
|
case 3:
|
|
65
88
|
case "end":
|
|
66
89
|
return _context.stop();
|
|
@@ -18,7 +18,6 @@ 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 "../BaseModule";
|
|
21
|
-
import { AccountHooks } from "./types";
|
|
22
21
|
export * from "./types";
|
|
23
22
|
export var AccountModule = /*#__PURE__*/function (_BaseModule) {
|
|
24
23
|
_inherits(AccountModule, _BaseModule);
|
|
@@ -85,7 +84,7 @@ export var AccountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
85
84
|
this.store.accountInfo = account;
|
|
86
85
|
this.store.isLoggedIn = true;
|
|
87
86
|
_context2.next = 5;
|
|
88
|
-
return this.core.effects.emit(
|
|
87
|
+
return this.core.effects.emit("".concat(this.name, ":onLogin"), account);
|
|
89
88
|
case 5:
|
|
90
89
|
case "end":
|
|
91
90
|
return _context2.stop();
|
|
@@ -117,7 +116,7 @@ export var AccountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
117
116
|
case 2:
|
|
118
117
|
this.store.accountInfo = _objectSpread(_objectSpread({}, this.store.accountInfo), updates);
|
|
119
118
|
_context3.next = 5;
|
|
120
|
-
return this.core.effects.emit(
|
|
119
|
+
return this.core.effects.emit("".concat(this.name, ":onProfileUpdate"), this.store.accountInfo);
|
|
121
120
|
case 5:
|
|
122
121
|
case "end":
|
|
123
122
|
return _context3.stop();
|
|
@@ -14,4 +14,7 @@ export declare class BaseModule {
|
|
|
14
14
|
store: any;
|
|
15
15
|
cacheKey: string[];
|
|
16
16
|
}): void;
|
|
17
|
+
effectsOn(eventType: string, callback: (payload: any) => void): () => void;
|
|
18
|
+
effectsOff(eventType: string, callback: (payload: any) => void): void;
|
|
19
|
+
effectsOnce(eventType: string, callback: (payload: any) => void): () => void;
|
|
17
20
|
}
|
|
@@ -64,6 +64,21 @@ export var BaseModule = /*#__PURE__*/function () {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
+
}, {
|
|
68
|
+
key: "effectsOn",
|
|
69
|
+
value: function effectsOn(eventType, callback) {
|
|
70
|
+
return this.core.effects.on("".concat(this.name, ":").concat(eventType), callback);
|
|
71
|
+
}
|
|
72
|
+
}, {
|
|
73
|
+
key: "effectsOff",
|
|
74
|
+
value: function effectsOff(eventType, callback) {
|
|
75
|
+
return this.core.effects.off("".concat(this.name, ":").concat(eventType), callback);
|
|
76
|
+
}
|
|
77
|
+
}, {
|
|
78
|
+
key: "effectsOnce",
|
|
79
|
+
value: function effectsOnce(eventType, callback) {
|
|
80
|
+
return this.core.effects.once("".concat(this.name, ":").concat(eventType), callback);
|
|
81
|
+
}
|
|
67
82
|
}]);
|
|
68
83
|
return BaseModule;
|
|
69
84
|
}();
|
|
@@ -29,7 +29,6 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
29
29
|
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); }
|
|
30
30
|
import { cloneDeep } from 'lodash-es';
|
|
31
31
|
import { BaseModule } from "../BaseModule";
|
|
32
|
-
import { CustomerHooks } from "./types";
|
|
33
32
|
import { DEFAULT_CUSTOMER, DEFAULT_PAGE_SIZE, SORT_BY } from "./constants";
|
|
34
33
|
export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
35
34
|
_inherits(CustomerModule, _BaseModule);
|
|
@@ -203,7 +202,7 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
203
202
|
console.error("Failed to ".concat(operation, ":"), error);
|
|
204
203
|
this.store.error = error instanceof Error ? error.message : "Failed to ".concat(operation);
|
|
205
204
|
_context3.next = 4;
|
|
206
|
-
return this.core.effects.emit(
|
|
205
|
+
return this.core.effects.emit("".concat(this.name, ":onCustomerListError"), this.store.error);
|
|
207
206
|
case 4:
|
|
208
207
|
case "end":
|
|
209
208
|
return _context3.stop();
|
|
@@ -266,7 +265,7 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
266
265
|
// 设置客户列表(替换模式)
|
|
267
266
|
this.store.customerList = cloneDeep(customerList);
|
|
268
267
|
_context4.next = 20;
|
|
269
|
-
return this.core.effects.emit(
|
|
268
|
+
return this.core.effects.emit("".concat(this.name, ":onCustomerListUpdate"), this.store);
|
|
270
269
|
case 20:
|
|
271
270
|
// 触发分页变化事件
|
|
272
271
|
this.triggerPaginationChange({
|
|
@@ -329,7 +328,7 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
329
328
|
key: "setSelectedCustomer",
|
|
330
329
|
value: function setSelectedCustomer(customer) {
|
|
331
330
|
this.store.selectedCustomer = !customer ? DEFAULT_CUSTOMER : cloneDeep(customer);
|
|
332
|
-
this.core.effects.emit(
|
|
331
|
+
this.core.effects.emit("".concat(this.name, ":onCustomerSelected"), this.store.selectedCustomer);
|
|
333
332
|
this.storeChange();
|
|
334
333
|
}
|
|
335
334
|
|
|
@@ -380,7 +379,7 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
380
379
|
this.store.hasMore = true;
|
|
381
380
|
this.store.loadingMore = false;
|
|
382
381
|
this.store.searchParams = {};
|
|
383
|
-
this.core.effects.emit(
|
|
382
|
+
this.core.effects.emit("".concat(this.name, ":onCustomerListUpdate"), this.store);
|
|
384
383
|
this.storeChange();
|
|
385
384
|
}
|
|
386
385
|
|
|
@@ -401,7 +400,7 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
401
400
|
this.store.total += 1;
|
|
402
401
|
|
|
403
402
|
// 触发客户列表更新事件
|
|
404
|
-
this.core.effects.emit(
|
|
403
|
+
this.core.effects.emit("".concat(this.name, ":onCustomerListUpdate"), this.store);
|
|
405
404
|
|
|
406
405
|
// 保存状态变化
|
|
407
406
|
this.storeChange();
|
|
@@ -439,7 +438,7 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
439
438
|
}, {
|
|
440
439
|
key: "triggerPaginationChange",
|
|
441
440
|
value: function triggerPaginationChange(pagination) {
|
|
442
|
-
this.core.effects.emit(
|
|
441
|
+
this.core.effects.emit("".concat(this.name, ":onPaginationChange"), pagination);
|
|
443
442
|
}
|
|
444
443
|
|
|
445
444
|
/**
|
|
@@ -552,7 +551,7 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
552
551
|
|
|
553
552
|
// 触发滚动加载特定事件
|
|
554
553
|
_context6.next = 20;
|
|
555
|
-
return this.core.effects.emit(
|
|
554
|
+
return this.core.effects.emit("".concat(this.name, ":onScrollLoadMore"), {
|
|
556
555
|
newCustomers: newCustomers,
|
|
557
556
|
allCustomers: this.store.customerList,
|
|
558
557
|
currentPage: page,
|
|
@@ -560,7 +559,7 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
560
559
|
});
|
|
561
560
|
case 20:
|
|
562
561
|
_context6.next = 22;
|
|
563
|
-
return this.core.effects.emit(
|
|
562
|
+
return this.core.effects.emit("".concat(this.name, ":onCustomerListUpdate"), this.store);
|
|
564
563
|
case 22:
|
|
565
564
|
// 触发分页变化事件
|
|
566
565
|
this.triggerPaginationChange({
|
|
@@ -634,7 +633,7 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
634
633
|
case 8:
|
|
635
634
|
response = _context7.sent;
|
|
636
635
|
_context7.next = 11;
|
|
637
|
-
return this.core.effects.emit(
|
|
636
|
+
return this.core.effects.emit("".concat(this.name, ":onScrollLoadComplete"), {
|
|
638
637
|
customers: this.store.customerList,
|
|
639
638
|
total: this.store.total,
|
|
640
639
|
hasMore: this.store.hasMore
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ICustomer } from "../AccountList/types";
|
|
2
2
|
export declare enum CustomerHooks {
|
|
3
|
-
OnCustomerListUpdate = "customer:
|
|
3
|
+
OnCustomerListUpdate = "customer:onCustomerListUpdate",
|
|
4
4
|
OnCustomerListError = "customer:onError",
|
|
5
|
-
OnCustomerSelected = "customer:
|
|
5
|
+
OnCustomerSelected = "customer:onCustomerSelected",
|
|
6
6
|
OnPaginationChange = "customer:onPaginationChange",
|
|
7
7
|
OnScrollLoadMore = "customer:onScrollLoadMore",
|
|
8
8
|
OnScrollLoadComplete = "customer:onScrollLoadComplete"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export var CustomerHooks = /*#__PURE__*/function (CustomerHooks) {
|
|
2
|
-
CustomerHooks["OnCustomerListUpdate"] = "customer:
|
|
2
|
+
CustomerHooks["OnCustomerListUpdate"] = "customer:onCustomerListUpdate";
|
|
3
3
|
CustomerHooks["OnCustomerListError"] = "customer:onError";
|
|
4
|
-
CustomerHooks["OnCustomerSelected"] = "customer:
|
|
4
|
+
CustomerHooks["OnCustomerSelected"] = "customer:onCustomerSelected";
|
|
5
5
|
CustomerHooks["OnPaginationChange"] = "customer:onPaginationChange";
|
|
6
6
|
CustomerHooks["OnScrollLoadMore"] = "customer:onScrollLoadMore";
|
|
7
7
|
CustomerHooks["OnScrollLoadComplete"] = "customer:onScrollLoadComplete";
|
|
@@ -283,7 +283,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
283
283
|
this.store.discountList = [];
|
|
284
284
|
this.core.effects.offByModuleDestroy(this.name);
|
|
285
285
|
_context5.next = 4;
|
|
286
|
-
return this.core.effects.emit(
|
|
286
|
+
return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
|
|
287
287
|
case 4:
|
|
288
288
|
console.log('[Discount] 已销毁');
|
|
289
289
|
case 5:
|
|
@@ -70,10 +70,10 @@ export var GuestListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
70
70
|
case 0:
|
|
71
71
|
this.state.list.push(guest);
|
|
72
72
|
_context2.next = 3;
|
|
73
|
-
return this.core.effects.emit(
|
|
73
|
+
return this.core.effects.emit("".concat(this.name, ":onGuestAdd"), guest);
|
|
74
74
|
case 3:
|
|
75
75
|
_context2.next = 5;
|
|
76
|
-
return this.core.effects.emit(
|
|
76
|
+
return this.core.effects.emit("".concat(this.name, ":onGuestChange"), this.state.list);
|
|
77
77
|
case 5:
|
|
78
78
|
case "end":
|
|
79
79
|
return _context2.stop();
|
|
@@ -107,7 +107,7 @@ export var GuestListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
107
107
|
return this.core.effects.emit(GuestHooks.OnGuestUpdate, this.state.list[index]);
|
|
108
108
|
case 6:
|
|
109
109
|
_context3.next = 8;
|
|
110
|
-
return this.core.effects.emit(
|
|
110
|
+
return this.core.effects.emit("".concat(this.name, ":onGuestChange"), this.state.list);
|
|
111
111
|
case 8:
|
|
112
112
|
case "end":
|
|
113
113
|
return _context3.stop();
|
|
@@ -138,10 +138,10 @@ export var GuestListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
138
138
|
case 3:
|
|
139
139
|
_this$state$list$spli = this.state.list.splice(index, 1), _this$state$list$spli2 = _slicedToArray(_this$state$list$spli, 1), removed = _this$state$list$spli2[0];
|
|
140
140
|
_context4.next = 6;
|
|
141
|
-
return this.core.effects.emit(
|
|
141
|
+
return this.core.effects.emit("".concat(this.name, ":onGuestRemove"), removed);
|
|
142
142
|
case 6:
|
|
143
143
|
_context4.next = 8;
|
|
144
|
-
return this.core.effects.emit(
|
|
144
|
+
return this.core.effects.emit("".concat(this.name, ":onGuestChange"), this.state.list);
|
|
145
145
|
case 8:
|
|
146
146
|
case "end":
|
|
147
147
|
return _context4.stop();
|
|
@@ -196,10 +196,10 @@ export var GuestListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
196
196
|
case 3:
|
|
197
197
|
guest.items.push(item);
|
|
198
198
|
_context6.next = 6;
|
|
199
|
-
return this.core.effects.emit(
|
|
199
|
+
return this.core.effects.emit("".concat(this.name, ":onGuestUpdate"), guest);
|
|
200
200
|
case 6:
|
|
201
201
|
_context6.next = 8;
|
|
202
|
-
return this.core.effects.emit(
|
|
202
|
+
return this.core.effects.emit("".concat(this.name, ":onGuestChange"), this.state.list);
|
|
203
203
|
case 8:
|
|
204
204
|
case "end":
|
|
205
205
|
return _context6.stop();
|
|
@@ -239,10 +239,10 @@ export var GuestListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
239
239
|
case 6:
|
|
240
240
|
guest.items.splice(index, 1);
|
|
241
241
|
_context7.next = 9;
|
|
242
|
-
return this.core.effects.emit(
|
|
242
|
+
return this.core.effects.emit("".concat(this.name, ":onGuestUpdate"), guest);
|
|
243
243
|
case 9:
|
|
244
244
|
_context7.next = 11;
|
|
245
|
-
return this.core.effects.emit(
|
|
245
|
+
return this.core.effects.emit("".concat(this.name, ":onGuestChange"), this.state.list);
|
|
246
246
|
case 11:
|
|
247
247
|
case "end":
|
|
248
248
|
return _context7.stop();
|
|
@@ -35,7 +35,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
35
35
|
function OrderModule(name, version) {
|
|
36
36
|
var _this;
|
|
37
37
|
_classCallCheck(this, OrderModule);
|
|
38
|
-
_this = _super.call(this, name, version);
|
|
38
|
+
_this = _super.call(this, name || "order", version);
|
|
39
39
|
_defineProperty(_assertThisInitialized(_this), "defaultName", 'order');
|
|
40
40
|
_defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
|
|
41
41
|
_defineProperty(_assertThisInitialized(_this), "store", void 0);
|
|
@@ -21,7 +21,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
21
21
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
22
22
|
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); }
|
|
23
23
|
import { BaseModule } from "../BaseModule";
|
|
24
|
-
import { PaymentStatus,
|
|
24
|
+
import { PaymentStatus, PaymentMethodType, RoundingRule } from "./types";
|
|
25
25
|
import { getUniqueId } from "../Cart/utils";
|
|
26
26
|
import { CashPaymentImpl } from "./cash";
|
|
27
27
|
import { EftposPaymentImpl } from "./eftpos";
|
|
@@ -73,7 +73,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
73
73
|
function PaymentModule(name, version) {
|
|
74
74
|
var _this;
|
|
75
75
|
_classCallCheck(this, PaymentModule);
|
|
76
|
-
_this = _super.call(this, name, version);
|
|
76
|
+
_this = _super.call(this, name || "payment", version);
|
|
77
77
|
// 初始化支付方式实例
|
|
78
78
|
_defineProperty(_assertThisInitialized(_this), "defaultName", 'pay');
|
|
79
79
|
_defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
|
|
@@ -338,7 +338,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
338
338
|
console.warn('[PaymentModule] 无法缓存支付方式,pay_method 表不存在');
|
|
339
339
|
case 43:
|
|
340
340
|
_context3.next = 45;
|
|
341
|
-
return this.core.effects.emit(
|
|
341
|
+
return this.core.effects.emit("".concat(this.name, ":onPaymentMethodsLoaded"), payMethods);
|
|
342
342
|
case 45:
|
|
343
343
|
this.logInfo('getPayMethodListAsync completed successfully', {
|
|
344
344
|
methodCount: payMethods.length,
|
|
@@ -469,7 +469,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
469
469
|
newMethods: newPayMethods
|
|
470
470
|
};
|
|
471
471
|
_context4.next = 54;
|
|
472
|
-
return this.core.effects.emit(
|
|
472
|
+
return this.core.effects.emit("".concat(this.name, ":onPaymentMethodsChanged"), eventData);
|
|
473
473
|
case 54:
|
|
474
474
|
_context4.next = 57;
|
|
475
475
|
break;
|
|
@@ -782,7 +782,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
782
782
|
return this.dbManager.delete('order', orderUuid);
|
|
783
783
|
case 7:
|
|
784
784
|
_context8.next = 9;
|
|
785
|
-
return this.core.effects.emit(
|
|
785
|
+
return this.core.effects.emit("".concat(this.name, ":onOrderDeleted"), order);
|
|
786
786
|
case 9:
|
|
787
787
|
console.log('[PaymentModule] 支付订单删除成功:', orderUuid);
|
|
788
788
|
case 10:
|
|
@@ -831,10 +831,10 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
831
831
|
return this.dbManager.update('order', updatedOrder);
|
|
832
832
|
case 9:
|
|
833
833
|
_context9.next = 11;
|
|
834
|
-
return this.core.effects.emit(
|
|
834
|
+
return this.core.effects.emit("".concat(this.name, ":onOrderUpdated"), updatedOrder);
|
|
835
835
|
case 11:
|
|
836
836
|
_context9.next = 13;
|
|
837
|
-
return this.core.effects.emit(
|
|
837
|
+
return this.core.effects.emit("".concat(this.name, ":onOrderChanged"), {
|
|
838
838
|
action: 'update',
|
|
839
839
|
order: updatedOrder,
|
|
840
840
|
originalOrder: order
|
|
@@ -929,10 +929,10 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
929
929
|
return this.dbManager.update('order', updatedOrder);
|
|
930
930
|
case 19:
|
|
931
931
|
_context10.next = 21;
|
|
932
|
-
return this.core.effects.emit(
|
|
932
|
+
return this.core.effects.emit("".concat(this.name, ":onOrderUpdated"), updatedOrder);
|
|
933
933
|
case 21:
|
|
934
934
|
_context10.next = 23;
|
|
935
|
-
return this.core.effects.emit(
|
|
935
|
+
return this.core.effects.emit("".concat(this.name, ":onOrderChanged"), {
|
|
936
936
|
action: 'order_id_replaced',
|
|
937
937
|
order: updatedOrder,
|
|
938
938
|
originalOrder: existingOrder,
|
|
@@ -1129,7 +1129,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1129
1129
|
return this.dbManager.update('order', order);
|
|
1130
1130
|
case 21:
|
|
1131
1131
|
_context13.next = 23;
|
|
1132
|
-
return this.core.effects.emit(
|
|
1132
|
+
return this.core.effects.emit("".concat(this.name, ":onPaymentAdded"), {
|
|
1133
1133
|
orderUuid: orderUuid,
|
|
1134
1134
|
payment: newPaymentItem
|
|
1135
1135
|
});
|
|
@@ -1231,13 +1231,13 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1231
1231
|
return this.dbManager.update('order', order);
|
|
1232
1232
|
case 20:
|
|
1233
1233
|
_context14.next = 22;
|
|
1234
|
-
return this.core.effects.emit(
|
|
1234
|
+
return this.core.effects.emit("".concat(this.name, ":onPaymentDeleted"), {
|
|
1235
1235
|
order: order,
|
|
1236
1236
|
paymentItem: paymentItem
|
|
1237
1237
|
});
|
|
1238
1238
|
case 22:
|
|
1239
1239
|
_context14.next = 24;
|
|
1240
|
-
return this.core.effects.emit(
|
|
1240
|
+
return this.core.effects.emit("".concat(this.name, ":onOrderChanged"), {
|
|
1241
1241
|
action: 'payment_delete',
|
|
1242
1242
|
order: order,
|
|
1243
1243
|
paymentItem: paymentItem
|
|
@@ -1404,7 +1404,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1404
1404
|
case 50:
|
|
1405
1405
|
updatedOrder = _context15.sent;
|
|
1406
1406
|
_context15.next = 53;
|
|
1407
|
-
return this.core.effects.emit(
|
|
1407
|
+
return this.core.effects.emit("".concat(this.name, ":onPaymentAdded"), {
|
|
1408
1408
|
orderUuid: orderUuid,
|
|
1409
1409
|
order: updatedOrder,
|
|
1410
1410
|
payment: null // 批量操作不提供单个支付项
|
|
@@ -1483,13 +1483,13 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1483
1483
|
return this.dbManager.update('order', order);
|
|
1484
1484
|
case 14:
|
|
1485
1485
|
_context16.next = 16;
|
|
1486
|
-
return this.core.effects.emit(
|
|
1486
|
+
return this.core.effects.emit("".concat(this.name, ":onPaymentUpdated"), {
|
|
1487
1487
|
order: order,
|
|
1488
1488
|
paymentItem: paymentItem
|
|
1489
1489
|
});
|
|
1490
1490
|
case 16:
|
|
1491
1491
|
_context16.next = 18;
|
|
1492
|
-
return this.core.effects.emit(
|
|
1492
|
+
return this.core.effects.emit("".concat(this.name, ":onOrderChanged"), {
|
|
1493
1493
|
action: 'payment_update',
|
|
1494
1494
|
order: order,
|
|
1495
1495
|
paymentItem: paymentItem
|
|
@@ -1668,10 +1668,10 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1668
1668
|
return _context18.abrupt("return");
|
|
1669
1669
|
case 12:
|
|
1670
1670
|
_context18.next = 14;
|
|
1671
|
-
return this.core.effects.emit(
|
|
1671
|
+
return this.core.effects.emit("".concat(this.name, ":onPaymentSubmitted"), order);
|
|
1672
1672
|
case 14:
|
|
1673
1673
|
_context18.next = 16;
|
|
1674
|
-
return this.core.effects.emit(
|
|
1674
|
+
return this.core.effects.emit("".concat(this.name, ":onOrderChanged"), {
|
|
1675
1675
|
action: 'submit',
|
|
1676
1676
|
order: order
|
|
1677
1677
|
});
|
|
@@ -40,7 +40,10 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
40
40
|
key: "emitEvent",
|
|
41
41
|
value: function emitEvent(hook, data) {
|
|
42
42
|
try {
|
|
43
|
-
|
|
43
|
+
// 提取事件名称,去掉模块前缀
|
|
44
|
+
var eventName = hook.split(':')[1] || hook.replace(/^[A-Z][a-z]+/, '').replace(/^On/, '').toLowerCase();
|
|
45
|
+
var fullEventName = "".concat(this.paymentModule.name, ":").concat(eventName);
|
|
46
|
+
this.paymentModule.core.effects.emit(fullEventName, data);
|
|
44
47
|
} catch (error) {
|
|
45
48
|
this.paymentModule.logError('[WalletPass] 发送事件失败', error, {
|
|
46
49
|
hook: hook
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
|
@@ -16,7 +16,6 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
16
16
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
17
17
|
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); }
|
|
18
18
|
import { BaseModule } from "../BaseModule";
|
|
19
|
-
import { ProductListHooks } from "./types";
|
|
20
19
|
import { cloneDeep } from 'lodash-es';
|
|
21
20
|
export * from "./types";
|
|
22
21
|
export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
@@ -202,7 +201,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
202
201
|
while (1) switch (_context5.prev = _context5.next) {
|
|
203
202
|
case 0:
|
|
204
203
|
_context5.next = 2;
|
|
205
|
-
return this.core.effects.emit(
|
|
204
|
+
return this.core.effects.emit("".concat(this.name, ":onGetProducts"), this.store.list);
|
|
206
205
|
case 2:
|
|
207
206
|
return _context5.abrupt("return", cloneDeep(this.store.list));
|
|
208
207
|
case 3:
|
|
@@ -225,7 +224,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
225
224
|
while (1) switch (_context6.prev = _context6.next) {
|
|
226
225
|
case 0:
|
|
227
226
|
_context6.next = 2;
|
|
228
|
-
return this.core.effects.emit(
|
|
227
|
+
return this.core.effects.emit("".concat(this.name, ":onGetProduct"), this.store.list);
|
|
229
228
|
case 2:
|
|
230
229
|
product = this.store.list.find(function (product) {
|
|
231
230
|
return product.id === id;
|
|
@@ -89,7 +89,7 @@ export var ResourceListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
89
89
|
case 3:
|
|
90
90
|
this.store.selectedResource = resource;
|
|
91
91
|
_context3.next = 6;
|
|
92
|
-
return this.core.effects.emit(
|
|
92
|
+
return this.core.effects.emit("".concat(this.name, ":onResourceSelect"), resource);
|
|
93
93
|
case 6:
|
|
94
94
|
case "end":
|
|
95
95
|
return _context3.stop();
|
|
@@ -24,7 +24,6 @@ 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 { BaseModule } from "../BaseModule";
|
|
27
|
-
import { RulesHooks } from "./types";
|
|
28
27
|
import { uniqueById, getDiscountAmount } from "../../solution/ShopDiscount/utils";
|
|
29
28
|
import { getProductOriginTotalPrice, getProductTotalPrice } from "../Cart/utils";
|
|
30
29
|
import Decimal from 'decimal.js';
|
|
@@ -73,7 +72,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
73
72
|
case 0:
|
|
74
73
|
this.store.rulesList = rulesList;
|
|
75
74
|
_context2.next = 3;
|
|
76
|
-
return this.core.effects.emit(
|
|
75
|
+
return this.core.effects.emit("".concat(this.name, ":onRulesListChange"), rulesList);
|
|
77
76
|
case 3:
|
|
78
77
|
case "end":
|
|
79
78
|
return _context2.stop();
|
|
@@ -665,7 +664,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
665
664
|
case 0:
|
|
666
665
|
this.core.effects.offByModuleDestroy(this.name);
|
|
667
666
|
_context3.next = 3;
|
|
668
|
-
return this.core.effects.emit(
|
|
667
|
+
return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
|
|
669
668
|
case 3:
|
|
670
669
|
console.log('[Rules] 已销毁');
|
|
671
670
|
case 4:
|
|
@@ -29,7 +29,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
29
29
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
30
30
|
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); }
|
|
31
31
|
import { BaseModule } from "../../modules/BaseModule";
|
|
32
|
-
import {
|
|
32
|
+
import { createModule } from "./types";
|
|
33
33
|
import { formatProductToCartItem, createCartItemOrigin, getUniqueId, handleVariantProduct, formatDateToCartItem, formatAccountToCartItem } from "../../modules/Cart/utils";
|
|
34
34
|
import { getAvailableProductResources } from "./utils/products";
|
|
35
35
|
import { getResourcesByProduct, getTimeSlicesByResource, getTimeSlicesByResources, getIsUsableByTimeItem, getOthersSelectedResources, getOthersCartSelectedResources, filterScheduleByDateRange, checkSessionProductLeadTime, sortCombinedResources, filterResourcesByFormItem, checkTwoResourcesIntersection, isConflict } from "./utils/resources";
|
|
@@ -137,7 +137,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
137
137
|
}
|
|
138
138
|
});
|
|
139
139
|
this.store.schedule.loadAllSchedule();
|
|
140
|
-
this.core.effects.emit(
|
|
140
|
+
this.core.effects.emit("".concat(this.name, ":onInited"), {});
|
|
141
141
|
case 19:
|
|
142
142
|
case "end":
|
|
143
143
|
return _context.stop();
|
|
@@ -22,6 +22,10 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
22
22
|
* @returns 商品列表
|
|
23
23
|
*/
|
|
24
24
|
loadProducts(params?: ILoadProductsParams): Promise<any>;
|
|
25
|
+
/**
|
|
26
|
+
* 初始化外设扫码结果监听
|
|
27
|
+
*/
|
|
28
|
+
initPeripheralsListener(): void;
|
|
25
29
|
/**
|
|
26
30
|
* 获取商品列表(不加载到模块中)
|
|
27
31
|
* @returns 商品列表
|