@pisell/pisellos 2.1.39 → 2.1.41
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 +8 -4
- package/dist/solution/BookingTicket/index.d.ts +5 -1
- 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/RegisterAndLogin/config.js +2 -2
- package/dist/solution/RegisterAndLogin/index.js +2 -1
- package/dist/solution/ShopDiscount/index.js +36 -19
- 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 +3 -3
- package/lib/solution/BookingTicket/index.d.ts +5 -1
- package/lib/solution/BookingTicket/index.js +12 -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/RegisterAndLogin/config.js +2 -2
- package/lib/solution/RegisterAndLogin/index.js +2 -1
- package/lib/solution/ShopDiscount/index.js +19 -11
- package/lib/types/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -25,7 +25,6 @@ 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";
|
|
29
28
|
import { DiscountModule } from "../../modules/Discount";
|
|
30
29
|
import { RulesModule } from "../../modules/Rules";
|
|
31
30
|
import Decimal from 'decimal.js';
|
|
@@ -104,7 +103,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
104
103
|
(_this$store$rules = this.store.rules) === null || _this$store$rules === void 0 || _this$store$rules.destroy();
|
|
105
104
|
this.core.effects.offByModuleDestroy(this.name);
|
|
106
105
|
_context2.next = 7;
|
|
107
|
-
return this.core.effects.emit(
|
|
106
|
+
return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
|
|
108
107
|
case 7:
|
|
109
108
|
console.log('[ShopDiscount] 已销毁');
|
|
110
109
|
case 8:
|
|
@@ -192,7 +191,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
192
191
|
key: "registerEventListeners",
|
|
193
192
|
value: function registerEventListeners() {
|
|
194
193
|
var _this2 = this;
|
|
195
|
-
this.core.effects.
|
|
194
|
+
this.core.effects.only("".concat(this.name, ":onCustomerChange"), function (customer) {
|
|
196
195
|
var _this2$options$otherP;
|
|
197
196
|
if ((_this2$options$otherP = _this2.options.otherParams) !== null && _this2$options$otherP !== void 0 && _this2$options$otherP.cacheId && _this2.getDiscountList().length) {
|
|
198
197
|
return;
|
|
@@ -223,7 +222,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
223
222
|
}
|
|
224
223
|
this.store.customer = customer;
|
|
225
224
|
_context4.next = 4;
|
|
226
|
-
return this.core.effects.emit(
|
|
225
|
+
return this.core.effects.emit("".concat(this.name, ":onCustomerChange"), customer);
|
|
227
226
|
case 4:
|
|
228
227
|
case "end":
|
|
229
228
|
return _context4.stop();
|
|
@@ -321,7 +320,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
321
320
|
key: "scanCode",
|
|
322
321
|
value: function () {
|
|
323
322
|
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code, customerId) {
|
|
324
|
-
var _this$store$discount3, resultDiscountList, rulesModule, withScanList, _ref2, newProductList, newDiscountList, isAvailable, _this$options$otherPa6;
|
|
323
|
+
var _this$store$discount3, resultDiscountList, rulesModule, withScanList, currentSelectedDiscountList, _ref2, newProductList, newDiscountList, isAvailable, _this$options$otherPa6;
|
|
325
324
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
326
325
|
while (1) switch (_context5.prev = _context5.next) {
|
|
327
326
|
case 0:
|
|
@@ -364,7 +363,25 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
364
363
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
365
364
|
isScan: true
|
|
366
365
|
});
|
|
366
|
+
}); // 如果扫回来的券当前有选中的,则不进行计算
|
|
367
|
+
currentSelectedDiscountList = this.getDiscountList().filter(function (n) {
|
|
368
|
+
return n.isSelected;
|
|
367
369
|
});
|
|
370
|
+
if (!(currentSelectedDiscountList.length && currentSelectedDiscountList.some(function (n) {
|
|
371
|
+
return withScanList.some(function (m) {
|
|
372
|
+
return m.id === n.id;
|
|
373
|
+
});
|
|
374
|
+
}))) {
|
|
375
|
+
_context5.next = 16;
|
|
376
|
+
break;
|
|
377
|
+
}
|
|
378
|
+
return _context5.abrupt("return", {
|
|
379
|
+
type: "clientCalc",
|
|
380
|
+
isAvailable: true,
|
|
381
|
+
productList: this.store.productList || [],
|
|
382
|
+
discountList: this.getDiscountList()
|
|
383
|
+
});
|
|
384
|
+
case 16:
|
|
368
385
|
_ref2 = rulesModule.isDiscountListAvailable({
|
|
369
386
|
productList: this.store.productList || [],
|
|
370
387
|
oldDiscountList: this.getDiscountList(),
|
|
@@ -375,27 +392,27 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
375
392
|
discountList: this.getDiscountList()
|
|
376
393
|
}, newProductList = _ref2.productList, newDiscountList = _ref2.discountList, isAvailable = _ref2.isAvailable;
|
|
377
394
|
if (!isAvailable) {
|
|
378
|
-
_context5.next =
|
|
395
|
+
_context5.next = 24;
|
|
379
396
|
break;
|
|
380
397
|
}
|
|
381
398
|
this.setDiscountList(newDiscountList || []);
|
|
382
399
|
this.store.originalDiscountList = newDiscountList || [];
|
|
383
400
|
this.setProductList(newProductList || []);
|
|
384
401
|
if (!(this.isWalkIn() && resultDiscountList.length && ((_this$options$otherPa6 = this.options.otherParams) === null || _this$options$otherPa6 === void 0 ? void 0 : _this$options$otherPa6.platform) === 'shop')) {
|
|
385
|
-
_context5.next =
|
|
402
|
+
_context5.next = 24;
|
|
386
403
|
break;
|
|
387
404
|
}
|
|
388
|
-
_context5.next =
|
|
405
|
+
_context5.next = 24;
|
|
389
406
|
return this.getCustomerWallet(resultDiscountList[0].customer_id);
|
|
390
|
-
case
|
|
407
|
+
case 24:
|
|
391
408
|
return _context5.abrupt("return", {
|
|
392
409
|
type: "clientCalc",
|
|
393
410
|
isAvailable: isAvailable || false,
|
|
394
411
|
productList: newProductList || this.store.productList || [],
|
|
395
412
|
discountList: newDiscountList || this.getDiscountList()
|
|
396
413
|
});
|
|
397
|
-
case
|
|
398
|
-
_context5.prev =
|
|
414
|
+
case 27:
|
|
415
|
+
_context5.prev = 27;
|
|
399
416
|
_context5.t1 = _context5["catch"](0);
|
|
400
417
|
console.error('[ShopDiscount] 扫码出错:', _context5.t1);
|
|
401
418
|
return _context5.abrupt("return", {
|
|
@@ -404,11 +421,11 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
404
421
|
productList: this.store.productList || [],
|
|
405
422
|
discountList: this.getDiscountList()
|
|
406
423
|
});
|
|
407
|
-
case
|
|
424
|
+
case 31:
|
|
408
425
|
case "end":
|
|
409
426
|
return _context5.stop();
|
|
410
427
|
}
|
|
411
|
-
}, _callee5, this, [[0,
|
|
428
|
+
}, _callee5, this, [[0, 27]]);
|
|
412
429
|
}));
|
|
413
430
|
function scanCode(_x4, _x5) {
|
|
414
431
|
return _scanCode.apply(this, arguments);
|
|
@@ -448,7 +465,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
448
465
|
while (1) switch (_context6.prev = _context6.next) {
|
|
449
466
|
case 0:
|
|
450
467
|
_context6.next = 2;
|
|
451
|
-
return this.core.effects.emit(
|
|
468
|
+
return this.core.effects.emit("".concat(this.name, ":onDiscountListChange"), discountList);
|
|
452
469
|
case 2:
|
|
453
470
|
case "end":
|
|
454
471
|
return _context6.stop();
|
|
@@ -579,7 +596,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
579
596
|
customer = Object.assign({}, (_objectDestructuringEmpty(_result.data), _result.data));
|
|
580
597
|
this.setCustomer(customer);
|
|
581
598
|
_context7.next = 9;
|
|
582
|
-
return this.core.effects.emit(
|
|
599
|
+
return this.core.effects.emit("".concat(this.name, ":onScanCustomerChange"), customer);
|
|
583
600
|
case 9:
|
|
584
601
|
_context7.next = 14;
|
|
585
602
|
break;
|
|
@@ -616,10 +633,10 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
616
633
|
_result2 = this.calcDiscount(this.store.productList);
|
|
617
634
|
cb === null || cb === void 0 || cb(_result2);
|
|
618
635
|
_context8.next = 7;
|
|
619
|
-
return this.core.effects.emit(
|
|
636
|
+
return this.core.effects.emit("".concat(this.name, ":onLoadPrepareCalcResult"), _result2);
|
|
620
637
|
case 7:
|
|
621
638
|
_context8.next = 9;
|
|
622
|
-
return this.core.effects.emit(
|
|
639
|
+
return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"), newDiscountList);
|
|
623
640
|
case 9:
|
|
624
641
|
case "end":
|
|
625
642
|
return _context8.stop();
|
|
@@ -670,10 +687,10 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
670
687
|
}
|
|
671
688
|
_result3 = this.calcDiscount(this.store.productList);
|
|
672
689
|
_context9.next = 15;
|
|
673
|
-
return this.core.effects.emit(
|
|
690
|
+
return this.core.effects.emit("".concat(this.name, ":onLoadPrepareCalcResult"), _result3);
|
|
674
691
|
case 15:
|
|
675
692
|
_context9.next = 17;
|
|
676
|
-
return this.core.effects.emit(
|
|
693
|
+
return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"), newDiscountList);
|
|
677
694
|
case 17:
|
|
678
695
|
_context9.next = 22;
|
|
679
696
|
break;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ 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;
|
|
43
44
|
off: (event: string, callback: (payload: any) => void) => void;
|
|
44
45
|
emit: (event: string, payload: any, value?: any) => Promise<{
|
|
45
46
|
status: boolean;
|
package/lib/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/lib/effects/index.js
CHANGED
|
@@ -35,6 +35,19 @@ 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
|
+
}
|
|
38
51
|
off(event, callback) {
|
|
39
52
|
var _a;
|
|
40
53
|
(_a = this.listeners.get(event)) == null ? void 0 : _a.delete(callback);
|
|
@@ -24,7 +24,6 @@ __export(Account_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(Account_exports);
|
|
26
26
|
var import_BaseModule = require("../BaseModule");
|
|
27
|
-
var import_types = require("./types");
|
|
28
27
|
__reExport(Account_exports, require("./types"), module.exports);
|
|
29
28
|
var AccountModule = class extends import_BaseModule.BaseModule {
|
|
30
29
|
constructor(name, version) {
|
|
@@ -59,7 +58,7 @@ var AccountModule = class extends import_BaseModule.BaseModule {
|
|
|
59
58
|
};
|
|
60
59
|
this.store.accountInfo = account;
|
|
61
60
|
this.store.isLoggedIn = true;
|
|
62
|
-
await this.core.effects.emit(
|
|
61
|
+
await this.core.effects.emit(`${this.name}:onLogin`, account);
|
|
63
62
|
}
|
|
64
63
|
getCurrentAccount() {
|
|
65
64
|
return this.store.accountInfo;
|
|
@@ -72,7 +71,7 @@ var AccountModule = class extends import_BaseModule.BaseModule {
|
|
|
72
71
|
...updates
|
|
73
72
|
};
|
|
74
73
|
await this.core.effects.emit(
|
|
75
|
-
|
|
74
|
+
`${this.name}:onProfileUpdate`,
|
|
76
75
|
this.store.accountInfo
|
|
77
76
|
);
|
|
78
77
|
}
|
|
@@ -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
|
}
|
|
@@ -82,6 +82,15 @@ var BaseModule = class {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
+
effectsOn(eventType, callback) {
|
|
86
|
+
return this.core.effects.on(`${this.name}:${eventType}`, callback);
|
|
87
|
+
}
|
|
88
|
+
effectsOff(eventType, callback) {
|
|
89
|
+
return this.core.effects.off(`${this.name}:${eventType}`, callback);
|
|
90
|
+
}
|
|
91
|
+
effectsOnce(eventType, callback) {
|
|
92
|
+
return this.core.effects.once(`${this.name}:${eventType}`, callback);
|
|
93
|
+
}
|
|
85
94
|
};
|
|
86
95
|
// Annotate the CommonJS export names for ESM import in node:
|
|
87
96
|
0 && (module.exports = {
|
|
@@ -25,7 +25,6 @@ __export(Customer_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(Customer_exports);
|
|
26
26
|
var import_lodash_es = require("lodash-es");
|
|
27
27
|
var import_BaseModule = require("../BaseModule");
|
|
28
|
-
var import_types = require("./types");
|
|
29
28
|
var import_constants = require("./constants");
|
|
30
29
|
__reExport(Customer_exports, require("./types"), module.exports);
|
|
31
30
|
var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
@@ -128,7 +127,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
128
127
|
console.error(`Failed to ${operation}:`, error);
|
|
129
128
|
this.store.error = error instanceof Error ? error.message : `Failed to ${operation}`;
|
|
130
129
|
await this.core.effects.emit(
|
|
131
|
-
|
|
130
|
+
`${this.name}:onCustomerListError`,
|
|
132
131
|
this.store.error
|
|
133
132
|
);
|
|
134
133
|
}
|
|
@@ -150,7 +149,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
150
149
|
this.store.hasMore = page * pageSize < total;
|
|
151
150
|
this.store.customerList = (0, import_lodash_es.cloneDeep)(customerList);
|
|
152
151
|
await this.core.effects.emit(
|
|
153
|
-
|
|
152
|
+
`${this.name}:onCustomerListUpdate`,
|
|
154
153
|
this.store
|
|
155
154
|
);
|
|
156
155
|
this.triggerPaginationChange({
|
|
@@ -193,7 +192,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
193
192
|
setSelectedCustomer(customer) {
|
|
194
193
|
this.store.selectedCustomer = !customer ? import_constants.DEFAULT_CUSTOMER : (0, import_lodash_es.cloneDeep)(customer);
|
|
195
194
|
this.core.effects.emit(
|
|
196
|
-
|
|
195
|
+
`${this.name}:onCustomerSelected`,
|
|
197
196
|
this.store.selectedCustomer
|
|
198
197
|
);
|
|
199
198
|
this.storeChange();
|
|
@@ -233,7 +232,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
233
232
|
this.store.loadingMore = false;
|
|
234
233
|
this.store.searchParams = {};
|
|
235
234
|
this.core.effects.emit(
|
|
236
|
-
|
|
235
|
+
`${this.name}:onCustomerListUpdate`,
|
|
237
236
|
this.store
|
|
238
237
|
);
|
|
239
238
|
this.storeChange();
|
|
@@ -247,7 +246,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
247
246
|
this.store.customerList = [newCustomer, ...this.store.customerList];
|
|
248
247
|
this.store.total += 1;
|
|
249
248
|
this.core.effects.emit(
|
|
250
|
-
|
|
249
|
+
`${this.name}:onCustomerListUpdate`,
|
|
251
250
|
this.store
|
|
252
251
|
);
|
|
253
252
|
this.storeChange();
|
|
@@ -277,7 +276,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
277
276
|
*/
|
|
278
277
|
triggerPaginationChange(pagination) {
|
|
279
278
|
this.core.effects.emit(
|
|
280
|
-
|
|
279
|
+
`${this.name}:onPaginationChange`,
|
|
281
280
|
pagination
|
|
282
281
|
);
|
|
283
282
|
}
|
|
@@ -344,7 +343,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
344
343
|
this.store.total = total;
|
|
345
344
|
this.store.hasMore = page * pageSize < total;
|
|
346
345
|
await this.core.effects.emit(
|
|
347
|
-
|
|
346
|
+
`${this.name}:onScrollLoadMore`,
|
|
348
347
|
{
|
|
349
348
|
newCustomers,
|
|
350
349
|
allCustomers: this.store.customerList,
|
|
@@ -353,7 +352,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
353
352
|
}
|
|
354
353
|
);
|
|
355
354
|
await this.core.effects.emit(
|
|
356
|
-
|
|
355
|
+
`${this.name}:onCustomerListUpdate`,
|
|
357
356
|
this.store
|
|
358
357
|
);
|
|
359
358
|
this.triggerPaginationChange({
|
|
@@ -395,7 +394,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
395
394
|
};
|
|
396
395
|
const response = await this.getCustomerList(resetParams);
|
|
397
396
|
await this.core.effects.emit(
|
|
398
|
-
|
|
397
|
+
`${this.name}:onScrollLoadComplete`,
|
|
399
398
|
{
|
|
400
399
|
customers: this.store.customerList,
|
|
401
400
|
total: this.store.total,
|
|
@@ -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"
|
|
@@ -23,9 +23,9 @@ __export(types_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(types_exports);
|
|
25
25
|
var CustomerHooks = /* @__PURE__ */ ((CustomerHooks2) => {
|
|
26
|
-
CustomerHooks2["OnCustomerListUpdate"] = "customer:
|
|
26
|
+
CustomerHooks2["OnCustomerListUpdate"] = "customer:onCustomerListUpdate";
|
|
27
27
|
CustomerHooks2["OnCustomerListError"] = "customer:onError";
|
|
28
|
-
CustomerHooks2["OnCustomerSelected"] = "customer:
|
|
28
|
+
CustomerHooks2["OnCustomerSelected"] = "customer:onCustomerSelected";
|
|
29
29
|
CustomerHooks2["OnPaginationChange"] = "customer:onPaginationChange";
|
|
30
30
|
CustomerHooks2["OnScrollLoadMore"] = "customer:onScrollLoadMore";
|
|
31
31
|
CustomerHooks2["OnScrollLoadComplete"] = "customer:onScrollLoadComplete";
|
|
@@ -171,7 +171,7 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
171
171
|
async destroy() {
|
|
172
172
|
this.store.discountList = [];
|
|
173
173
|
this.core.effects.offByModuleDestroy(this.name);
|
|
174
|
-
await this.core.effects.emit(
|
|
174
|
+
await this.core.effects.emit(`${this.name}:onDestroy`, {});
|
|
175
175
|
console.log("[Discount] 已销毁");
|
|
176
176
|
}
|
|
177
177
|
async clear() {
|
|
@@ -41,8 +41,8 @@ var GuestListModule = class extends import_BaseModule.BaseModule {
|
|
|
41
41
|
}
|
|
42
42
|
async addGuest(guest) {
|
|
43
43
|
this.state.list.push(guest);
|
|
44
|
-
await this.core.effects.emit(
|
|
45
|
-
await this.core.effects.emit(
|
|
44
|
+
await this.core.effects.emit(`${this.name}:onGuestAdd`, guest);
|
|
45
|
+
await this.core.effects.emit(`${this.name}:onGuestChange`, this.state.list);
|
|
46
46
|
}
|
|
47
47
|
async updateGuest(id, updates) {
|
|
48
48
|
const index = this.state.list.findIndex((g) => g.id === id);
|
|
@@ -56,15 +56,15 @@ var GuestListModule = class extends import_BaseModule.BaseModule {
|
|
|
56
56
|
import_types.GuestHooks.OnGuestUpdate,
|
|
57
57
|
this.state.list[index]
|
|
58
58
|
);
|
|
59
|
-
await this.core.effects.emit(
|
|
59
|
+
await this.core.effects.emit(`${this.name}:onGuestChange`, this.state.list);
|
|
60
60
|
}
|
|
61
61
|
async removeGuest(id) {
|
|
62
62
|
const index = this.state.list.findIndex((g) => g.id === id);
|
|
63
63
|
if (index === -1)
|
|
64
64
|
return;
|
|
65
65
|
const [removed] = this.state.list.splice(index, 1);
|
|
66
|
-
await this.core.effects.emit(
|
|
67
|
-
await this.core.effects.emit(
|
|
66
|
+
await this.core.effects.emit(`${this.name}:onGuestRemove`, removed);
|
|
67
|
+
await this.core.effects.emit(`${this.name}:onGuestChange`, this.state.list);
|
|
68
68
|
}
|
|
69
69
|
async getGuests() {
|
|
70
70
|
return this.state.list;
|
|
@@ -77,8 +77,8 @@ var GuestListModule = class extends import_BaseModule.BaseModule {
|
|
|
77
77
|
if (!guest)
|
|
78
78
|
return;
|
|
79
79
|
guest.items.push(item);
|
|
80
|
-
await this.core.effects.emit(
|
|
81
|
-
await this.core.effects.emit(
|
|
80
|
+
await this.core.effects.emit(`${this.name}:onGuestUpdate`, guest);
|
|
81
|
+
await this.core.effects.emit(`${this.name}:onGuestChange`, this.state.list);
|
|
82
82
|
}
|
|
83
83
|
async removeItemFromGuest(guestId, itemId) {
|
|
84
84
|
const guest = this.state.list.find((g) => g.id === guestId);
|
|
@@ -88,8 +88,8 @@ var GuestListModule = class extends import_BaseModule.BaseModule {
|
|
|
88
88
|
if (index === -1)
|
|
89
89
|
return;
|
|
90
90
|
guest.items.splice(index, 1);
|
|
91
|
-
await this.core.effects.emit(
|
|
92
|
-
await this.core.effects.emit(
|
|
91
|
+
await this.core.effects.emit(`${this.name}:onGuestUpdate`, guest);
|
|
92
|
+
await this.core.effects.emit(`${this.name}:onGuestChange`, this.state.list);
|
|
93
93
|
}
|
|
94
94
|
};
|
|
95
95
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -39,7 +39,7 @@ var import_dayjs = __toESM(require("dayjs"));
|
|
|
39
39
|
var OrderModule = class extends import_BaseModule.BaseModule {
|
|
40
40
|
// LoggerManager 实例
|
|
41
41
|
constructor(name, version) {
|
|
42
|
-
super(name, version);
|
|
42
|
+
super(name || "order", version);
|
|
43
43
|
this.defaultName = "order";
|
|
44
44
|
this.defaultVersion = "1.0.0";
|
|
45
45
|
}
|
|
@@ -55,7 +55,7 @@ function generateRequestUniqueId() {
|
|
|
55
55
|
}
|
|
56
56
|
var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
57
57
|
constructor(name, version) {
|
|
58
|
-
super(name, version);
|
|
58
|
+
super(name || "payment", version);
|
|
59
59
|
this.defaultName = "pay";
|
|
60
60
|
this.defaultVersion = "1.0.0";
|
|
61
61
|
// LoggerManager 实例
|
|
@@ -193,7 +193,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
193
193
|
console.warn("[PaymentModule] 无法缓存支付方式,pay_method 表不存在");
|
|
194
194
|
}
|
|
195
195
|
await this.core.effects.emit(
|
|
196
|
-
|
|
196
|
+
`${this.name}:onPaymentMethodsLoaded`,
|
|
197
197
|
payMethods
|
|
198
198
|
);
|
|
199
199
|
this.logInfo("getPayMethodListAsync completed successfully", {
|
|
@@ -243,7 +243,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
243
243
|
newMethods: newPayMethods
|
|
244
244
|
};
|
|
245
245
|
await this.core.effects.emit(
|
|
246
|
-
|
|
246
|
+
`${this.name}:onPaymentMethodsChanged`,
|
|
247
247
|
eventData
|
|
248
248
|
);
|
|
249
249
|
} else {
|
|
@@ -368,7 +368,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
368
368
|
const order = await this.dbManager.get("order", orderUuid);
|
|
369
369
|
if (order) {
|
|
370
370
|
await this.dbManager.delete("order", orderUuid);
|
|
371
|
-
await this.core.effects.emit(
|
|
371
|
+
await this.core.effects.emit(`${this.name}:onOrderDeleted`, order);
|
|
372
372
|
console.log("[PaymentModule] 支付订单删除成功:", orderUuid);
|
|
373
373
|
}
|
|
374
374
|
} catch (error) {
|
|
@@ -386,8 +386,8 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
386
386
|
const updatedOrder = { ...order, ...params };
|
|
387
387
|
this.recalculateOrderAmount(updatedOrder);
|
|
388
388
|
await this.dbManager.update("order", updatedOrder);
|
|
389
|
-
await this.core.effects.emit(
|
|
390
|
-
await this.core.effects.emit(
|
|
389
|
+
await this.core.effects.emit(`${this.name}:onOrderUpdated`, updatedOrder);
|
|
390
|
+
await this.core.effects.emit(`${this.name}:onOrderChanged`, {
|
|
391
391
|
action: "update",
|
|
392
392
|
order: updatedOrder,
|
|
393
393
|
originalOrder: order
|
|
@@ -445,8 +445,8 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
445
445
|
}
|
|
446
446
|
};
|
|
447
447
|
await this.dbManager.update("order", updatedOrder);
|
|
448
|
-
await this.core.effects.emit(
|
|
449
|
-
await this.core.effects.emit(
|
|
448
|
+
await this.core.effects.emit(`${this.name}:onOrderUpdated`, updatedOrder);
|
|
449
|
+
await this.core.effects.emit(`${this.name}:onOrderChanged`, {
|
|
450
450
|
action: "order_id_replaced",
|
|
451
451
|
order: updatedOrder,
|
|
452
452
|
originalOrder: existingOrder,
|
|
@@ -563,7 +563,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
563
563
|
order.payment.push(newPaymentItem);
|
|
564
564
|
this.recalculateOrderAmount(order);
|
|
565
565
|
await this.dbManager.update("order", order);
|
|
566
|
-
await this.core.effects.emit(
|
|
566
|
+
await this.core.effects.emit(`${this.name}:onPaymentAdded`, {
|
|
567
567
|
orderUuid,
|
|
568
568
|
payment: newPaymentItem
|
|
569
569
|
});
|
|
@@ -619,11 +619,11 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
619
619
|
});
|
|
620
620
|
this.recalculateOrderAmount(order);
|
|
621
621
|
await this.dbManager.update("order", order);
|
|
622
|
-
await this.core.effects.emit(
|
|
622
|
+
await this.core.effects.emit(`${this.name}:onPaymentDeleted`, {
|
|
623
623
|
order,
|
|
624
624
|
paymentItem
|
|
625
625
|
});
|
|
626
|
-
await this.core.effects.emit(
|
|
626
|
+
await this.core.effects.emit(`${this.name}:onOrderChanged`, {
|
|
627
627
|
action: "payment_delete",
|
|
628
628
|
order,
|
|
629
629
|
paymentItem
|
|
@@ -700,7 +700,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
700
700
|
await this.addPaymentItemAsync(orderUuid, voucherItem);
|
|
701
701
|
}
|
|
702
702
|
const updatedOrder = await this.getPaymentOrderByUuidAsync(orderUuid);
|
|
703
|
-
await this.core.effects.emit(
|
|
703
|
+
await this.core.effects.emit(`${this.name}:onPaymentAdded`, {
|
|
704
704
|
orderUuid,
|
|
705
705
|
order: updatedOrder,
|
|
706
706
|
payment: null
|
|
@@ -741,11 +741,11 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
741
741
|
Object.assign(paymentItem, formattedParams);
|
|
742
742
|
this.recalculateOrderAmount(order);
|
|
743
743
|
await this.dbManager.update("order", order);
|
|
744
|
-
await this.core.effects.emit(
|
|
744
|
+
await this.core.effects.emit(`${this.name}:onPaymentUpdated`, {
|
|
745
745
|
order,
|
|
746
746
|
paymentItem
|
|
747
747
|
});
|
|
748
|
-
await this.core.effects.emit(
|
|
748
|
+
await this.core.effects.emit(`${this.name}:onOrderChanged`, {
|
|
749
749
|
action: "payment_update",
|
|
750
750
|
order,
|
|
751
751
|
paymentItem
|
|
@@ -833,8 +833,8 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
833
833
|
});
|
|
834
834
|
return;
|
|
835
835
|
}
|
|
836
|
-
await this.core.effects.emit(
|
|
837
|
-
await this.core.effects.emit(
|
|
836
|
+
await this.core.effects.emit(`${this.name}:onPaymentSubmitted`, order);
|
|
837
|
+
await this.core.effects.emit(`${this.name}:onOrderChanged`, {
|
|
838
838
|
action: "submit",
|
|
839
839
|
order
|
|
840
840
|
});
|
|
@@ -38,7 +38,9 @@ var WalletPassPaymentImpl = class {
|
|
|
38
38
|
*/
|
|
39
39
|
emitEvent(hook, data) {
|
|
40
40
|
try {
|
|
41
|
-
|
|
41
|
+
const eventName = hook.split(":")[1] || hook.replace(/^[A-Z][a-z]+/, "").replace(/^On/, "").toLowerCase();
|
|
42
|
+
const fullEventName = `${this.paymentModule.name}:${eventName}`;
|
|
43
|
+
this.paymentModule.core.effects.emit(fullEventName, data);
|
|
42
44
|
} catch (error) {
|
|
43
45
|
this.paymentModule.logError("[WalletPass] 发送事件失败", error, { hook });
|
|
44
46
|
}
|
|
@@ -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
|
}
|
|
@@ -24,7 +24,6 @@ __export(ProductList_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(ProductList_exports);
|
|
26
26
|
var import_BaseModule = require("../BaseModule");
|
|
27
|
-
var import_types = require("./types");
|
|
28
27
|
var import_lodash_es = require("lodash-es");
|
|
29
28
|
__reExport(ProductList_exports, require("./types"), module.exports);
|
|
30
29
|
var ProductList = class extends import_BaseModule.BaseModule {
|
|
@@ -134,14 +133,14 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
134
133
|
}
|
|
135
134
|
async getProducts() {
|
|
136
135
|
await this.core.effects.emit(
|
|
137
|
-
|
|
136
|
+
`${this.name}:onGetProducts`,
|
|
138
137
|
this.store.list
|
|
139
138
|
);
|
|
140
139
|
return (0, import_lodash_es.cloneDeep)(this.store.list);
|
|
141
140
|
}
|
|
142
141
|
async getProduct(id) {
|
|
143
142
|
await this.core.effects.emit(
|
|
144
|
-
|
|
143
|
+
`${this.name}:onGetProduct`,
|
|
145
144
|
this.store.list
|
|
146
145
|
);
|
|
147
146
|
const product = this.store.list.find((product2) => product2.id === id);
|
|
@@ -42,7 +42,7 @@ var ResourceListModule = class extends import_BaseModule.BaseModule {
|
|
|
42
42
|
if (!resource)
|
|
43
43
|
return;
|
|
44
44
|
this.store.selectedResource = resource;
|
|
45
|
-
await this.core.effects.emit(
|
|
45
|
+
await this.core.effects.emit(`${this.name}:onResourceSelect`, resource);
|
|
46
46
|
}
|
|
47
47
|
getSelectedResource() {
|
|
48
48
|
return this.store.selectedResource;
|
|
@@ -33,7 +33,6 @@ __export(Rules_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(Rules_exports);
|
|
35
35
|
var import_BaseModule = require("../BaseModule");
|
|
36
|
-
var import_types = require("./types");
|
|
37
36
|
var import_utils = require("../../solution/ShopDiscount/utils");
|
|
38
37
|
var import_utils2 = require("../Cart/utils");
|
|
39
38
|
var import_decimal = __toESM(require("decimal.js"));
|
|
@@ -52,7 +51,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
52
51
|
}
|
|
53
52
|
async setRulesList(rulesList) {
|
|
54
53
|
this.store.rulesList = rulesList;
|
|
55
|
-
await this.core.effects.emit(
|
|
54
|
+
await this.core.effects.emit(`${this.name}:onRulesListChange`, rulesList);
|
|
56
55
|
}
|
|
57
56
|
getRulesList() {
|
|
58
57
|
return this.store.rulesList;
|
|
@@ -489,7 +488,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
489
488
|
}
|
|
490
489
|
async destroy() {
|
|
491
490
|
this.core.effects.offByModuleDestroy(this.name);
|
|
492
|
-
await this.core.effects.emit(
|
|
491
|
+
await this.core.effects.emit(`${this.name}:onDestroy`, {});
|
|
493
492
|
console.log("[Rules] 已销毁");
|
|
494
493
|
}
|
|
495
494
|
async clear() {
|