@pisell/pisellos 0.0.43 → 0.0.45
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/modules/Account/index.d.ts +2 -6
- package/dist/modules/Account/index.js +21 -103
- package/dist/modules/Account/types.d.ts +12 -1
- package/dist/modules/AccountList/index.d.ts +19 -0
- package/dist/modules/AccountList/index.js +224 -70
- package/dist/modules/AccountList/types.d.ts +33 -1
- package/dist/modules/AccountList/types.js +8 -0
- package/dist/modules/AccountList/utils.d.ts +9 -0
- package/dist/modules/AccountList/utils.js +25 -0
- package/dist/modules/BaseModule.d.ts +2 -2
- package/dist/modules/BaseModule.js +1 -1
- package/dist/modules/Cart/index.d.ts +5 -5
- package/dist/modules/Cart/index.js +32 -19
- package/dist/modules/Cart/types.d.ts +18 -4
- package/dist/modules/Cart/utils.d.ts +29 -5
- package/dist/modules/Cart/utils.js +72 -26
- package/dist/modules/Date/index.d.ts +6 -6
- package/dist/modules/Date/index.js +41 -55
- package/dist/modules/Date/types.d.ts +22 -6
- package/dist/modules/Date/utils.d.ts +4 -3
- package/dist/modules/Date/utils.js +74 -23
- package/dist/modules/Discount/index.d.ts +4 -4
- package/dist/modules/Discount/index.js +11 -11
- package/dist/modules/Order/index.d.ts +11 -5
- package/dist/modules/Order/index.js +39 -18
- package/dist/modules/Order/types.d.ts +10 -3
- package/dist/modules/Product/index.d.ts +4 -1
- package/dist/modules/Product/index.js +22 -0
- package/dist/modules/Product/types.d.ts +7 -3
- package/dist/modules/ProductList/index.js +11 -5
- package/dist/modules/Resource/utils.js +1 -1
- package/dist/modules/Rules/index.d.ts +4 -4
- package/dist/modules/Rules/index.js +11 -11
- package/dist/modules/Rules/types.d.ts +1 -1
- package/dist/modules/Schedule/index.d.ts +8 -3
- package/dist/modules/Schedule/index.js +45 -5
- package/dist/modules/Schedule/type.d.ts +7 -7
- package/dist/modules/Schedule/types.d.ts +8 -8
- package/dist/modules/Schedule/utils.d.ts +9 -3
- package/dist/modules/Schedule/utils.js +77 -48
- package/dist/modules/Step/index.d.ts +14 -3
- package/dist/modules/Step/index.js +54 -2
- package/dist/modules/Summary/index.d.ts +5 -5
- package/dist/modules/Summary/index.js +7 -7
- package/dist/modules/Summary/types.d.ts +2 -2
- package/dist/modules/Summary/utils.d.ts +4 -4
- package/dist/modules/Summary/utils.js +3 -3
- package/dist/plugins/index.d.ts +3 -3
- package/dist/plugins/request.d.ts +3 -3
- package/dist/plugins/request.js +30 -30
- package/dist/plugins/shopStore.d.ts +1 -1
- package/dist/solution/BookingByStep/index.d.ts +65 -16
- package/dist/solution/BookingByStep/index.js +553 -216
- package/dist/solution/BookingByStep/types.d.ts +2 -2
- package/dist/solution/BookingByStep/types.js +9 -9
- package/dist/solution/BookingByStep/utils/products.d.ts +1 -1
- package/dist/solution/BookingByStep/utils/products.js +3 -0
- package/dist/solution/BookingByStep/utils/resources.d.ts +5 -5
- package/dist/solution/BookingByStep/utils/resources.js +11 -11
- package/dist/solution/ShopDiscount/index.d.ts +4 -4
- package/dist/solution/ShopDiscount/index.js +16 -16
- package/dist/solution/ShopDiscount/types.d.ts +2 -2
- package/dist/solution/ShopDiscount/utils.js +1 -1
- package/lib/core/index.js +7 -2
- package/lib/modules/Account/index.d.ts +2 -6
- package/lib/modules/Account/index.js +15 -30
- package/lib/modules/Account/types.d.ts +12 -1
- package/lib/modules/AccountList/index.d.ts +19 -0
- package/lib/modules/AccountList/index.js +109 -12
- package/lib/modules/AccountList/types.d.ts +33 -1
- package/lib/modules/AccountList/utils.d.ts +9 -0
- package/lib/modules/AccountList/utils.js +39 -0
- package/lib/modules/BaseModule.d.ts +2 -2
- package/lib/modules/BaseModule.js +14 -3
- package/lib/modules/Cart/index.d.ts +5 -5
- package/lib/modules/Cart/index.js +27 -6
- package/lib/modules/Cart/types.d.ts +18 -4
- package/lib/modules/Cart/utils.d.ts +29 -5
- package/lib/modules/Cart/utils.js +47 -3
- package/lib/modules/Date/index.d.ts +6 -6
- package/lib/modules/Date/index.js +6 -6
- package/lib/modules/Date/types.d.ts +22 -6
- package/lib/modules/Date/utils.d.ts +4 -3
- package/lib/modules/Date/utils.js +37 -6
- package/lib/modules/Discount/index.d.ts +4 -4
- package/lib/modules/Discount/index.js +9 -2
- package/lib/modules/Guests/index.js +4 -1
- package/lib/modules/Order/index.d.ts +11 -5
- package/lib/modules/Order/index.js +18 -3
- package/lib/modules/Order/types.d.ts +10 -3
- package/lib/modules/Payment/index.js +1 -6
- package/lib/modules/Product/index.d.ts +4 -1
- package/lib/modules/Product/index.js +16 -0
- package/lib/modules/Product/types.d.ts +7 -3
- package/lib/modules/ProductList/index.js +21 -7
- package/lib/modules/Resource/index.js +4 -1
- package/lib/modules/Resource/utils.js +7 -4
- package/lib/modules/Rules/index.d.ts +4 -4
- package/lib/modules/Rules/types.d.ts +1 -1
- package/lib/modules/Schedule/index.d.ts +8 -3
- package/lib/modules/Schedule/index.js +33 -2
- package/lib/modules/Schedule/type.d.ts +7 -7
- package/lib/modules/Schedule/types.d.ts +8 -8
- package/lib/modules/Schedule/utils.d.ts +9 -3
- package/lib/modules/Schedule/utils.js +32 -4
- package/lib/modules/Step/index.d.ts +14 -3
- package/lib/modules/Step/index.js +38 -1
- package/lib/modules/Summary/index.d.ts +5 -5
- package/lib/modules/Summary/types.d.ts +2 -2
- package/lib/modules/Summary/utils.d.ts +4 -4
- package/lib/plugins/index.d.ts +3 -3
- package/lib/plugins/request.d.ts +3 -3
- package/lib/plugins/request.js +48 -11
- package/lib/plugins/shopStore.d.ts +1 -1
- package/lib/solution/BookingByStep/index.d.ts +65 -16
- package/lib/solution/BookingByStep/index.js +351 -39
- package/lib/solution/BookingByStep/types.d.ts +2 -2
- package/lib/solution/BookingByStep/types.js +36 -9
- package/lib/solution/BookingByStep/utils/products.d.ts +1 -1
- package/lib/solution/BookingByStep/utils/products.js +3 -0
- package/lib/solution/BookingByStep/utils/resources.d.ts +5 -5
- package/lib/solution/BookingByStep/utils/resources.js +103 -52
- package/lib/solution/BuyTickets/index.js +34 -20
- package/lib/solution/ShopDiscount/index.d.ts +4 -4
- package/lib/solution/ShopDiscount/index.js +10 -2
- package/lib/solution/ShopDiscount/types.d.ts +2 -2
- package/package.json +4 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ProductList, CartModule, Product, AccountModule, AccountListModule, DateModule, GuestListModule, OrderModule, PaymentModule, ResourceListModule, StepModule, SummaryModule, ScheduleModule } from
|
|
1
|
+
import { ProductList, CartModule, Product, AccountModule, AccountListModule, DateModule, GuestListModule, OrderModule, PaymentModule, ResourceListModule, StepModule, SummaryModule, ScheduleModule } from '../../modules';
|
|
2
2
|
export interface BookingByStepState {
|
|
3
3
|
cart: CartModule;
|
|
4
4
|
summary: SummaryModule;
|
|
@@ -11,7 +11,7 @@ export interface BookingByStepState {
|
|
|
11
11
|
accountList: AccountListModule;
|
|
12
12
|
order: OrderModule;
|
|
13
13
|
payment: PaymentModule;
|
|
14
|
-
currentProduct
|
|
14
|
+
currentProduct?: Product;
|
|
15
15
|
schedule: ScheduleModule;
|
|
16
16
|
}
|
|
17
17
|
export declare function createModule<T extends keyof BookingByStepState>(moduleName: T, solutionName: string, name?: string, version?: string): BookingByStepState[T];
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { ProductList, CartModule, AccountListModule, DateModule, OrderModule, PaymentModule, StepModule, SummaryModule, ScheduleModule } from "../../modules";
|
|
2
2
|
export function createModule(moduleName, solutionName, name, version) {
|
|
3
3
|
switch (moduleName) {
|
|
4
|
-
case
|
|
4
|
+
case 'cart':
|
|
5
5
|
return new CartModule("".concat(solutionName, "_").concat(name || moduleName), version);
|
|
6
|
-
case
|
|
6
|
+
case 'summary':
|
|
7
7
|
return new SummaryModule("".concat(solutionName, "_").concat(name || moduleName), version);
|
|
8
|
-
case
|
|
8
|
+
case 'step':
|
|
9
9
|
return new StepModule("".concat(solutionName, "_").concat(name || moduleName), version);
|
|
10
|
-
case
|
|
10
|
+
case 'products':
|
|
11
11
|
return new ProductList("".concat(solutionName, "_").concat(name || moduleName), version);
|
|
12
|
-
case
|
|
12
|
+
case 'date':
|
|
13
13
|
return new DateModule("".concat(solutionName, "_").concat(name || moduleName), version);
|
|
14
|
-
case
|
|
14
|
+
case 'accountList':
|
|
15
15
|
return new AccountListModule("".concat(solutionName, "_").concat(name || moduleName), version);
|
|
16
|
-
case
|
|
16
|
+
case 'order':
|
|
17
17
|
return new OrderModule("".concat(solutionName, "_").concat(name || moduleName), version);
|
|
18
|
-
case
|
|
18
|
+
case 'payment':
|
|
19
19
|
return new PaymentModule("".concat(solutionName, "_").concat(name || moduleName), version);
|
|
20
|
-
case
|
|
20
|
+
case 'schedule':
|
|
21
21
|
return new ScheduleModule("".concat(solutionName, "_").concat(name || moduleName), version);
|
|
22
22
|
default:
|
|
23
23
|
throw new Error("Unknown module type: ".concat(moduleName));
|
|
@@ -37,6 +37,9 @@ export var getAvailableProductResources = function getAvailableProductResources(
|
|
|
37
37
|
if (tempResourceIds) {
|
|
38
38
|
rule.resourceFormIds = _toConsumableArray(new Set(tempResourceIds));
|
|
39
39
|
}
|
|
40
|
+
if (product !== null && product !== void 0 && product._schedule) {
|
|
41
|
+
rule.schedule = product === null || product === void 0 ? void 0 : product._schedule;
|
|
42
|
+
}
|
|
40
43
|
rules.push(rule);
|
|
41
44
|
});
|
|
42
45
|
return {
|
|
@@ -27,7 +27,7 @@ interface BookingItem {
|
|
|
27
27
|
* @return {*}
|
|
28
28
|
* @Author: zhiwei.Wang
|
|
29
29
|
*/
|
|
30
|
-
export declare const getIsUsableByTimeItem: ({ timeSlice, time, resource, currentCount }: {
|
|
30
|
+
export declare const getIsUsableByTimeItem: ({ timeSlice, time, resource, currentCount, }: {
|
|
31
31
|
timeSlice: TimeSliceItem;
|
|
32
32
|
time: any;
|
|
33
33
|
resource: ResourceItem;
|
|
@@ -53,7 +53,7 @@ export declare const getResourcesByProduct: (resourcesMap: Record<string, Resour
|
|
|
53
53
|
* @Author: zhiwei.Wang
|
|
54
54
|
* @Date: 2024-01-09 13:38
|
|
55
55
|
*/
|
|
56
|
-
export declare const formatResources: ({ booking, resources }: {
|
|
56
|
+
export declare const formatResources: ({ booking, resources, }: {
|
|
57
57
|
booking: BookingItem;
|
|
58
58
|
resources: ResourceItem[];
|
|
59
59
|
}) => {
|
|
@@ -66,7 +66,7 @@ export declare const formatResources: ({ booking, resources }: {
|
|
|
66
66
|
* @return {*}
|
|
67
67
|
* @Author: zhiwei.Wang
|
|
68
68
|
*/
|
|
69
|
-
export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate, capacity }: {
|
|
69
|
+
export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate, capacity, }: {
|
|
70
70
|
resource: ResourceItem;
|
|
71
71
|
duration: number;
|
|
72
72
|
split: number;
|
|
@@ -100,7 +100,7 @@ export declare const getResourcesByIds: (resourcesMap: Record<string, ResourceIt
|
|
|
100
100
|
* @return {*}
|
|
101
101
|
* @Author: zhiwei.Wang
|
|
102
102
|
*/
|
|
103
|
-
export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split, capacity }: {
|
|
103
|
+
export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split, capacity, }: {
|
|
104
104
|
resourceIds: number[];
|
|
105
105
|
resourcesMap: any;
|
|
106
106
|
duration: number;
|
|
@@ -129,7 +129,7 @@ interface CapacityItem {
|
|
|
129
129
|
* @return {*}
|
|
130
130
|
* @Author: zhiwei.Wang
|
|
131
131
|
*/
|
|
132
|
-
export declare const formatDefaultCapacitys: ({ capacity, product_bundle }: any) => CapacityItem[];
|
|
132
|
+
export declare const formatDefaultCapacitys: ({ capacity, product_bundle, }: any) => CapacityItem[];
|
|
133
133
|
/**
|
|
134
134
|
* @title: 获取总容量
|
|
135
135
|
* @description:
|
|
@@ -17,12 +17,12 @@ import dayjs from 'dayjs';
|
|
|
17
17
|
* 1. 获取资源列表
|
|
18
18
|
* 2. 根据当前选择的商品过滤出来对应的资源列表 getResourcesByProduct
|
|
19
19
|
* 3. 格式化资源相关 格式化资源列表 --> 格式化资源 --> 获取时间切片列表 --> 判断单个时间切片是否可用 formatResources
|
|
20
|
-
*
|
|
20
|
+
*
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* @title: 获取重叠剩余量
|
|
25
|
-
* @description:
|
|
25
|
+
* @description:
|
|
26
26
|
* @param {any} eventList
|
|
27
27
|
* @param {number} current
|
|
28
28
|
* @return {*}
|
|
@@ -36,7 +36,7 @@ var getUseableEventCount = function getUseableEventCount(eventList, current) {
|
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* @title: 判断两个时间段是否有重叠
|
|
39
|
-
* @description:
|
|
39
|
+
* @description:
|
|
40
40
|
* @param {object} event
|
|
41
41
|
* @param {object} current
|
|
42
42
|
* @return {*}
|
|
@@ -61,7 +61,7 @@ var isConflict = function isConflict(event, current) {
|
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
63
|
* @title: 判断传入日期是否在当前日期之后
|
|
64
|
-
* @description:
|
|
64
|
+
* @description:
|
|
65
65
|
* @param {any} date
|
|
66
66
|
* @param {any} today
|
|
67
67
|
* @return {*}
|
|
@@ -99,7 +99,7 @@ var formatResource = function formatResource(resourceItem, booking) {
|
|
|
99
99
|
|
|
100
100
|
/**
|
|
101
101
|
* @title: 判断资源容量是否可用
|
|
102
|
-
* @description:
|
|
102
|
+
* @description:
|
|
103
103
|
* @param {object} param1
|
|
104
104
|
* @return {*}
|
|
105
105
|
* @Author: zhiwei.Wang
|
|
@@ -185,7 +185,7 @@ export var getIsUsableByTimeItem = function getIsUsableByTimeItem(_ref2) {
|
|
|
185
185
|
|
|
186
186
|
/**
|
|
187
187
|
* @title: 获取商品下绑定的资源列表
|
|
188
|
-
* @description:
|
|
188
|
+
* @description:
|
|
189
189
|
* @param {any} resourcesMap
|
|
190
190
|
* @param {any} product
|
|
191
191
|
* @return {*}
|
|
@@ -312,7 +312,7 @@ export var formatResources = function formatResources(_ref3) {
|
|
|
312
312
|
|
|
313
313
|
/**
|
|
314
314
|
* @title: 获取资源的时间切片列表
|
|
315
|
-
* @description:
|
|
315
|
+
* @description:
|
|
316
316
|
* @return {*}
|
|
317
317
|
* @Author: zhiwei.Wang
|
|
318
318
|
*/
|
|
@@ -457,7 +457,7 @@ export var getTimeSlicesByResources = function getTimeSlicesByResources(_ref5) {
|
|
|
457
457
|
|
|
458
458
|
/**
|
|
459
459
|
* @title: 获取其他人的已选资源
|
|
460
|
-
* @description:
|
|
460
|
+
* @description:
|
|
461
461
|
* @param {CartItem[]} cartItems
|
|
462
462
|
* @param {number | string} accountId
|
|
463
463
|
* @return {*}
|
|
@@ -498,7 +498,7 @@ export var getOthersSelectedResources = function getOthersSelectedResources(cart
|
|
|
498
498
|
};
|
|
499
499
|
/**
|
|
500
500
|
* @title: 基于选择的商品格式化容量
|
|
501
|
-
* @description:
|
|
501
|
+
* @description:
|
|
502
502
|
* @param {any} param1
|
|
503
503
|
* @return {*}
|
|
504
504
|
* @Author: zhiwei.Wang
|
|
@@ -539,7 +539,7 @@ export var formatDefaultCapacitys = function formatDefaultCapacitys(_ref6) {
|
|
|
539
539
|
|
|
540
540
|
/**
|
|
541
541
|
* @title: 获取总容量
|
|
542
|
-
* @description:
|
|
542
|
+
* @description:
|
|
543
543
|
* @param {object} capacity 为 formatDefaultCapacitys()的结果
|
|
544
544
|
* @return {*}
|
|
545
545
|
* @Author: zhiwei.Wang
|
|
@@ -564,7 +564,7 @@ export var getSumCapacity = function getSumCapacity(_ref7) {
|
|
|
564
564
|
|
|
565
565
|
/**
|
|
566
566
|
* @title: 传入资源,如果有子资源,会根据组合资源的 capacity 计算修改子资源的 capacity
|
|
567
|
-
* @description:
|
|
567
|
+
* @description:
|
|
568
568
|
* @param {object} resource
|
|
569
569
|
* @return {*}
|
|
570
570
|
* @Author: jinglin.tan
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Module, PisellCore } from
|
|
2
|
-
import { BaseModule } from
|
|
3
|
-
import { Customer } from
|
|
4
|
-
import { Discount } from
|
|
1
|
+
import { Module, PisellCore } from '../../types';
|
|
2
|
+
import { BaseModule } from '../../modules/BaseModule';
|
|
3
|
+
import { Customer } from './types';
|
|
4
|
+
import { Discount } from '../../modules/Discount/types';
|
|
5
5
|
export declare class ShopDiscountImpl extends BaseModule implements Module {
|
|
6
6
|
protected defaultName: string;
|
|
7
7
|
protected defaultVersion: string;
|
|
@@ -39,8 +39,8 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
39
39
|
_classCallCheck(this, ShopDiscountImpl);
|
|
40
40
|
_this = _super.call(this, name, version);
|
|
41
41
|
// 初始化所有必要的状态属性
|
|
42
|
-
_defineProperty(_assertThisInitialized(_this), "defaultName",
|
|
43
|
-
_defineProperty(_assertThisInitialized(_this), "defaultVersion",
|
|
42
|
+
_defineProperty(_assertThisInitialized(_this), "defaultName", 'shopDiscount');
|
|
43
|
+
_defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
|
|
44
44
|
_defineProperty(_assertThisInitialized(_this), "isSolution", true);
|
|
45
45
|
_defineProperty(_assertThisInitialized(_this), "request", void 0);
|
|
46
46
|
_defineProperty(_assertThisInitialized(_this), "window", void 0);
|
|
@@ -66,7 +66,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
66
66
|
this.core = core;
|
|
67
67
|
this.options = options;
|
|
68
68
|
this.store = _objectSpread(_objectSpread({}, this.store), options.store || {});
|
|
69
|
-
console.log(
|
|
69
|
+
console.log('[ShopDiscount] 初始化完成');
|
|
70
70
|
|
|
71
71
|
// 获取依赖的插件
|
|
72
72
|
this.initializePlugins();
|
|
@@ -103,7 +103,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
103
103
|
_context2.next = 7;
|
|
104
104
|
return this.core.effects.emit(ShopDiscountHooks.onDestroy, {});
|
|
105
105
|
case 7:
|
|
106
|
-
console.log(
|
|
106
|
+
console.log('[ShopDiscount] 已销毁');
|
|
107
107
|
case 8:
|
|
108
108
|
case "end":
|
|
109
109
|
return _context2.stop();
|
|
@@ -127,7 +127,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
127
127
|
this.store.customer = null;
|
|
128
128
|
(_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 || _this$store$discount2.clear();
|
|
129
129
|
(_this$store$rules2 = this.store.rules) === null || _this$store$rules2 === void 0 || _this$store$rules2.clear();
|
|
130
|
-
console.log(
|
|
130
|
+
console.log('[ShopDiscount] clear');
|
|
131
131
|
case 5:
|
|
132
132
|
case "end":
|
|
133
133
|
return _context3.stop();
|
|
@@ -142,13 +142,13 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
142
142
|
}, {
|
|
143
143
|
key: "initializePlugins",
|
|
144
144
|
value: function initializePlugins() {
|
|
145
|
-
this.request = this.core.getPlugin(
|
|
146
|
-
this.window = this.core.getPlugin(
|
|
145
|
+
this.request = this.core.getPlugin('request');
|
|
146
|
+
this.window = this.core.getPlugin('window');
|
|
147
147
|
if (!this.request) {
|
|
148
|
-
throw new Error(
|
|
148
|
+
throw new Error('ShopDiscount需要 request 插件支持');
|
|
149
149
|
}
|
|
150
150
|
if (!this.window) {
|
|
151
|
-
throw new Error(
|
|
151
|
+
throw new Error('ShopDiscount需要 window 插件支持');
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
}, {
|
|
@@ -196,7 +196,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
196
196
|
}
|
|
197
197
|
_this2.loadPrepareConfig({
|
|
198
198
|
customerId: customer.id,
|
|
199
|
-
action:
|
|
199
|
+
action: 'create',
|
|
200
200
|
with_good_pass: 1
|
|
201
201
|
});
|
|
202
202
|
});
|
|
@@ -363,7 +363,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
363
363
|
case 21:
|
|
364
364
|
_context5.prev = 21;
|
|
365
365
|
_context5.t1 = _context5["catch"](0);
|
|
366
|
-
console.error(
|
|
366
|
+
console.error('[ShopDiscount] 扫码出错:', _context5.t1);
|
|
367
367
|
return _context5.abrupt("return", {
|
|
368
368
|
isAvailable: false,
|
|
369
369
|
productList: this.store.productList || [],
|
|
@@ -453,7 +453,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
453
453
|
});
|
|
454
454
|
var newDiscountList = uniqueById([].concat(editModeDiscountList, _toConsumableArray(discountList.filter(function (item) {
|
|
455
455
|
return !item.isDisabled;
|
|
456
|
-
}))),
|
|
456
|
+
}))), 'product_id');
|
|
457
457
|
(_this$store$discount5 = this.store.discount) === null || _this$store$discount5 === void 0 || _this$store$discount5.setDiscountList(newDiscountList);
|
|
458
458
|
this.emitDiscountListChange(newDiscountList);
|
|
459
459
|
return newDiscountList;
|
|
@@ -479,7 +479,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
479
479
|
_context7.prev = 0;
|
|
480
480
|
_context7.next = 3;
|
|
481
481
|
return this.request.get("/customer/info/wallet/".concat(id), {
|
|
482
|
-
wallet_pass_tags: [
|
|
482
|
+
wallet_pass_tags: ['good_pass']
|
|
483
483
|
});
|
|
484
484
|
case 3:
|
|
485
485
|
result = _context7.sent;
|
|
@@ -492,7 +492,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
492
492
|
case 7:
|
|
493
493
|
_context7.prev = 7;
|
|
494
494
|
_context7.t0 = _context7["catch"](0);
|
|
495
|
-
console.error(
|
|
495
|
+
console.error('[ShopDiscount] 获取客户钱包信息出错:', _context7.t0);
|
|
496
496
|
case 10:
|
|
497
497
|
case "end":
|
|
498
498
|
return _context7.stop();
|
|
@@ -519,7 +519,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
519
519
|
_context8.next = 4;
|
|
520
520
|
return (_this$store$discount7 = this.store.discount) === null || _this$store$discount7 === void 0 ? void 0 : _this$store$discount7.loadPrepareConfig({
|
|
521
521
|
customer_id: customerId,
|
|
522
|
-
action:
|
|
522
|
+
action: 'create',
|
|
523
523
|
with_good_pass: 1
|
|
524
524
|
});
|
|
525
525
|
case 4:
|
|
@@ -545,7 +545,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
545
545
|
case 16:
|
|
546
546
|
_context8.prev = 16;
|
|
547
547
|
_context8.t0 = _context8["catch"](0);
|
|
548
|
-
console.error(
|
|
548
|
+
console.error('[ShopDiscount] 加载准备配置出错:', _context8.t0);
|
|
549
549
|
case 19:
|
|
550
550
|
case "end":
|
|
551
551
|
return _context8.stop();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DiscountModule } from
|
|
2
|
-
import { RulesModule } from
|
|
1
|
+
import { DiscountModule } from '../../modules/Discount';
|
|
2
|
+
import { RulesModule } from '../../modules/Rules';
|
|
3
3
|
export declare enum ShopDiscountHooks {
|
|
4
4
|
onInited = "shopDiscount:onInited",
|
|
5
5
|
onDestroy = "shopDiscount:onDestroy",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export var uniqueById = function uniqueById(arr) {
|
|
2
|
-
var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] :
|
|
2
|
+
var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'id';
|
|
3
3
|
var seen = new Set();
|
|
4
4
|
return arr.filter(function (item) {
|
|
5
5
|
return !seen.has(item[key]) && seen.add(item[key]);
|
package/lib/core/index.js
CHANGED
|
@@ -116,7 +116,9 @@ var PisellOSCore = class {
|
|
|
116
116
|
if (options == null ? void 0 : options.plugins) {
|
|
117
117
|
for (const plugin of options.plugins) {
|
|
118
118
|
if (!this.plugins.has(plugin)) {
|
|
119
|
-
throw new Error(
|
|
119
|
+
throw new Error(
|
|
120
|
+
`注册模块 ${module2.name} 失败:缺少依赖插件 ${plugin}`
|
|
121
|
+
);
|
|
120
122
|
}
|
|
121
123
|
}
|
|
122
124
|
}
|
|
@@ -193,7 +195,10 @@ var PisellOSCore = class {
|
|
|
193
195
|
for (const rule of config.validations) {
|
|
194
196
|
const value = this.context[rule.name];
|
|
195
197
|
if (rule.required && (value === void 0 || value === null)) {
|
|
196
|
-
this.log(
|
|
198
|
+
this.log(
|
|
199
|
+
`模块 ${config.name} 缺少必需的上下文参数: ${rule.name}`,
|
|
200
|
+
"error"
|
|
201
|
+
);
|
|
197
202
|
return false;
|
|
198
203
|
}
|
|
199
204
|
if (rule.validate && value !== void 0 && value !== null) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import { Account
|
|
3
|
+
import { Account } from './types';
|
|
4
4
|
export * from './types';
|
|
5
|
-
export declare class AccountModule extends BaseModule implements Module
|
|
5
|
+
export declare class AccountModule extends BaseModule implements Module {
|
|
6
6
|
protected defaultName: string;
|
|
7
7
|
protected defaultVersion: string;
|
|
8
8
|
isGuest: boolean;
|
|
@@ -14,13 +14,9 @@ export declare class AccountModule extends BaseModule implements Module, Account
|
|
|
14
14
|
username: string;
|
|
15
15
|
password: string;
|
|
16
16
|
}): Promise<void>;
|
|
17
|
-
logout(): Promise<void>;
|
|
18
|
-
register(account: Omit<Account, 'id'>): Promise<void>;
|
|
19
17
|
getCurrentAccount(): Account | null;
|
|
20
18
|
updateProfile(updates: Partial<Account>): Promise<void>;
|
|
21
19
|
isLoggedIn(): boolean;
|
|
22
|
-
resetPassword(email: string): Promise<void>;
|
|
23
|
-
updatePassword(oldPassword: string, newPassword: string): Promise<void>;
|
|
24
20
|
getLoginStatus(): boolean;
|
|
25
21
|
getAccount(): Account | null;
|
|
26
22
|
setAccountInfo(account: Account): void;
|
|
@@ -33,7 +33,7 @@ var AccountModule = class extends import_BaseModule.BaseModule {
|
|
|
33
33
|
this.defaultVersion = "1.0.0";
|
|
34
34
|
this.isGuest = false;
|
|
35
35
|
this.store = {
|
|
36
|
-
|
|
36
|
+
accountInfo: null,
|
|
37
37
|
isLoggedIn: false,
|
|
38
38
|
active: false
|
|
39
39
|
};
|
|
@@ -45,7 +45,7 @@ var AccountModule = class extends import_BaseModule.BaseModule {
|
|
|
45
45
|
}
|
|
46
46
|
getId() {
|
|
47
47
|
var _a;
|
|
48
|
-
return ((_a = this.store.
|
|
48
|
+
return ((_a = this.store.accountInfo) == null ? void 0 : _a.id) || "";
|
|
49
49
|
}
|
|
50
50
|
async login(credentials) {
|
|
51
51
|
const account = {
|
|
@@ -54,54 +54,39 @@ var AccountModule = class extends import_BaseModule.BaseModule {
|
|
|
54
54
|
username: credentials.username,
|
|
55
55
|
email: `${credentials.username}@example.com`,
|
|
56
56
|
name: credentials.username,
|
|
57
|
-
isGuest: false
|
|
57
|
+
isGuest: false,
|
|
58
|
+
type: "account"
|
|
58
59
|
};
|
|
59
|
-
this.store.
|
|
60
|
+
this.store.accountInfo = account;
|
|
60
61
|
this.store.isLoggedIn = true;
|
|
61
62
|
await this.core.effects.emit(import_types.AccountHooks.OnLogin, account);
|
|
62
63
|
}
|
|
63
|
-
async logout() {
|
|
64
|
-
this.store.currentAccount = null;
|
|
65
|
-
this.store.isLoggedIn = false;
|
|
66
|
-
await this.core.effects.emit(import_types.AccountHooks.OnLogout, {});
|
|
67
|
-
}
|
|
68
|
-
async register(account) {
|
|
69
|
-
const newAccount = {
|
|
70
|
-
id: "1",
|
|
71
|
-
// 实际应该从 API 返回
|
|
72
|
-
...account
|
|
73
|
-
};
|
|
74
|
-
this.store.currentAccount = newAccount;
|
|
75
|
-
this.store.isLoggedIn = true;
|
|
76
|
-
await this.core.effects.emit(import_types.AccountHooks.OnRegister, newAccount);
|
|
77
|
-
}
|
|
78
64
|
getCurrentAccount() {
|
|
79
|
-
return this.store.
|
|
65
|
+
return this.store.accountInfo;
|
|
80
66
|
}
|
|
81
67
|
async updateProfile(updates) {
|
|
82
|
-
if (!this.store.
|
|
68
|
+
if (!this.store.accountInfo)
|
|
83
69
|
return;
|
|
84
|
-
this.store.
|
|
85
|
-
...this.store.
|
|
70
|
+
this.store.accountInfo = {
|
|
71
|
+
...this.store.accountInfo,
|
|
86
72
|
...updates
|
|
87
73
|
};
|
|
88
|
-
await this.core.effects.emit(
|
|
74
|
+
await this.core.effects.emit(
|
|
75
|
+
import_types.AccountHooks.OnProfileUpdate,
|
|
76
|
+
this.store.accountInfo
|
|
77
|
+
);
|
|
89
78
|
}
|
|
90
79
|
isLoggedIn() {
|
|
91
80
|
return this.store.isLoggedIn;
|
|
92
81
|
}
|
|
93
|
-
async resetPassword(email) {
|
|
94
|
-
}
|
|
95
|
-
async updatePassword(oldPassword, newPassword) {
|
|
96
|
-
}
|
|
97
82
|
getLoginStatus() {
|
|
98
83
|
return this.store.isLoggedIn;
|
|
99
84
|
}
|
|
100
85
|
getAccount() {
|
|
101
|
-
return this.store.
|
|
86
|
+
return this.store.accountInfo;
|
|
102
87
|
}
|
|
103
88
|
setAccountInfo(account) {
|
|
104
|
-
this.store.
|
|
89
|
+
this.store.accountInfo = account;
|
|
105
90
|
if (account.isGuest) {
|
|
106
91
|
this.isGuest = true;
|
|
107
92
|
}
|
|
@@ -9,19 +9,30 @@ export declare enum AccountHooks {
|
|
|
9
9
|
*/
|
|
10
10
|
export interface Account {
|
|
11
11
|
id: string | number;
|
|
12
|
+
/** 用户名 */
|
|
12
13
|
username: string;
|
|
14
|
+
/** 邮箱 */
|
|
13
15
|
email?: string;
|
|
16
|
+
/** 手机号 */
|
|
14
17
|
phone?: string;
|
|
18
|
+
/** 昵称 */
|
|
15
19
|
name?: string;
|
|
20
|
+
/** 头像 */
|
|
16
21
|
avatar?: string;
|
|
22
|
+
/** 元数据 */
|
|
17
23
|
metadata?: Record<string, any>;
|
|
24
|
+
/** 是否为游客 */
|
|
18
25
|
isGuest?: boolean;
|
|
26
|
+
/** 账户类型 */
|
|
27
|
+
type?: 'account' | 'holder';
|
|
28
|
+
/** 账户信息原始数据 */
|
|
29
|
+
_origin?: Record<string, any>;
|
|
19
30
|
}
|
|
20
31
|
/**
|
|
21
32
|
* 账户模块状态
|
|
22
33
|
*/
|
|
23
34
|
export interface AccountState {
|
|
24
|
-
|
|
35
|
+
accountInfo: Account | null;
|
|
25
36
|
isLoggedIn: boolean;
|
|
26
37
|
active: boolean;
|
|
27
38
|
}
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { AccountModule, Account } from '../Account';
|
|
3
3
|
import { BaseModule } from '../BaseModule';
|
|
4
|
+
import { IFetchHolderAccountsParams, IHolder } from './types';
|
|
4
5
|
export declare class AccountListModule extends BaseModule implements Module {
|
|
5
6
|
protected defaultName: string;
|
|
6
7
|
protected defaultVersion: string;
|
|
7
8
|
private store;
|
|
9
|
+
private request;
|
|
8
10
|
private cacheId;
|
|
9
11
|
private openCache;
|
|
10
12
|
private fatherModule;
|
|
11
13
|
constructor(name?: string, version?: string);
|
|
12
14
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* 创建账号并添加到列表中
|
|
17
|
+
* @param account 账号信息
|
|
18
|
+
* @param needEmit 是否需要触发事件
|
|
19
|
+
*/
|
|
20
|
+
private createAccountAndAdd;
|
|
13
21
|
addAccount(account: Account): Promise<void>;
|
|
14
22
|
updateAccount(id: string, updates: Account): Promise<void>;
|
|
15
23
|
updateAccountListById(id: string | number, updates: Account): Promise<void>;
|
|
@@ -20,4 +28,15 @@ export declare class AccountListModule extends BaseModule implements Module {
|
|
|
20
28
|
setActiveAccount(id: string | number): void;
|
|
21
29
|
getActiveAccount(): AccountModule | null;
|
|
22
30
|
storeChange(): void;
|
|
31
|
+
/**
|
|
32
|
+
* 批量添加holder类型账号
|
|
33
|
+
* @param holders 账号信息列表
|
|
34
|
+
* @param customerId 账户id
|
|
35
|
+
*/
|
|
36
|
+
addHolderAccounts(holders: IHolder[], customerId: number): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* 获取holder类型账户列表
|
|
39
|
+
* @param params
|
|
40
|
+
*/
|
|
41
|
+
fetchHolderAccounts(params: IFetchHolderAccountsParams): Promise<void>;
|
|
23
42
|
}
|