@pisell/pisellos 3.0.4 → 3.0.6
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 +20 -1
- package/dist/modules/AccountList/index.js +243 -75
- 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 +8 -5
- package/dist/modules/Cart/index.js +101 -25
- package/dist/modules/Cart/types.d.ts +82 -5
- package/dist/modules/Cart/types.js +22 -0
- package/dist/modules/Cart/utils.d.ts +106 -13
- package/dist/modules/Cart/utils.js +289 -76
- package/dist/modules/Date/index.d.ts +6 -6
- package/dist/modules/Date/index.js +41 -58
- package/dist/modules/Date/types.d.ts +22 -6
- package/dist/modules/Date/utils.d.ts +4 -3
- package/dist/modules/Date/utils.js +81 -30
- 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 +47 -18
- package/dist/modules/Order/types.d.ts +10 -3
- package/dist/modules/Order/utils.d.ts +10 -0
- package/dist/modules/Order/utils.js +15 -0
- package/dist/modules/Product/index.d.ts +14 -1
- package/dist/modules/Product/index.js +35 -0
- package/dist/modules/Product/types.d.ts +27 -3
- package/dist/modules/ProductList/index.js +11 -5
- package/dist/modules/Resource/types.d.ts +1 -0
- package/dist/modules/Resource/utils.js +1 -1
- package/dist/modules/Rules/index.d.ts +3 -3
- package/dist/modules/Rules/index.js +121 -53
- package/dist/modules/Rules/types.d.ts +5 -1
- package/dist/modules/Schedule/index.d.ts +18 -0
- package/dist/modules/Schedule/index.js +111 -0
- package/dist/modules/Schedule/type.d.ts +157 -0
- package/dist/modules/Schedule/type.js +1 -0
- package/dist/modules/Schedule/types.d.ts +182 -0
- package/dist/modules/Schedule/types.js +1 -0
- package/dist/modules/Schedule/utils.d.ts +67 -0
- package/dist/modules/Schedule/utils.js +729 -0
- package/dist/modules/Step/index.d.ts +14 -3
- package/dist/modules/Step/index.js +54 -2
- package/dist/modules/Summary/index.d.ts +12 -5
- package/dist/modules/Summary/index.js +33 -7
- package/dist/modules/Summary/types.d.ts +23 -2
- package/dist/modules/Summary/utils.d.ts +14 -4
- package/dist/modules/Summary/utils.js +46 -4
- package/dist/modules/index.d.ts +10 -0
- package/dist/modules/index.js +11 -1
- 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 +97 -24
- package/dist/solution/BookingByStep/index.js +1024 -322
- package/dist/solution/BookingByStep/types.d.ts +3 -10
- package/dist/solution/BookingByStep/types.js +11 -15
- 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 +60 -6
- package/dist/solution/BookingByStep/utils/resources.js +293 -52
- 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 +20 -1
- package/lib/modules/AccountList/index.js +122 -13
- 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 +8 -5
- package/lib/modules/Cart/index.js +81 -8
- package/lib/modules/Cart/types.d.ts +82 -5
- package/lib/modules/Cart/types.js +20 -2
- package/lib/modules/Cart/utils.d.ts +106 -13
- package/lib/modules/Cart/utils.js +188 -45
- package/lib/modules/Date/index.d.ts +6 -6
- package/lib/modules/Date/index.js +13 -28
- package/lib/modules/Date/types.d.ts +22 -6
- package/lib/modules/Date/utils.d.ts +4 -3
- package/lib/modules/Date/utils.js +47 -13
- 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 +24 -3
- package/lib/modules/Order/types.d.ts +10 -3
- package/lib/modules/Order/utils.d.ts +10 -0
- package/lib/modules/Order/utils.js +45 -0
- package/lib/modules/Payment/index.js +1 -6
- package/lib/modules/Product/index.d.ts +14 -1
- package/lib/modules/Product/index.js +19 -0
- package/lib/modules/Product/types.d.ts +27 -3
- package/lib/modules/ProductList/index.js +21 -7
- package/lib/modules/Resource/index.js +4 -1
- package/lib/modules/Resource/types.d.ts +1 -0
- package/lib/modules/Resource/utils.js +7 -4
- package/lib/modules/Rules/index.d.ts +3 -3
- package/lib/modules/Rules/index.js +118 -43
- package/lib/modules/Rules/types.d.ts +5 -1
- package/lib/modules/Schedule/index.d.ts +18 -0
- package/lib/modules/Schedule/index.js +81 -0
- package/lib/modules/Schedule/type.d.ts +157 -0
- package/lib/modules/Schedule/type.js +17 -0
- package/lib/modules/Schedule/types.d.ts +182 -0
- package/lib/modules/Schedule/types.js +17 -0
- package/lib/modules/Schedule/utils.d.ts +67 -0
- package/lib/modules/Schedule/utils.js +600 -0
- package/lib/modules/Step/index.d.ts +14 -3
- package/lib/modules/Step/index.js +38 -1
- package/lib/modules/Summary/index.d.ts +12 -5
- package/lib/modules/Summary/index.js +15 -1
- package/lib/modules/Summary/types.d.ts +23 -2
- package/lib/modules/Summary/utils.d.ts +14 -4
- package/lib/modules/Summary/utils.js +30 -1
- package/lib/modules/index.d.ts +10 -0
- package/lib/modules/index.js +21 -1
- 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 +97 -24
- package/lib/solution/BookingByStep/index.js +693 -145
- package/lib/solution/BookingByStep/types.d.ts +3 -10
- package/lib/solution/BookingByStep/types.js +37 -14
- 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 +60 -6
- package/lib/solution/BookingByStep/utils/resources.js +286 -54
- 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
- package/dist/core/index.d.ts.map +0 -1
- package/dist/effects/index.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/modules/Account/index.d.ts.map +0 -1
- package/dist/modules/Account/types.d.ts.map +0 -1
- package/dist/modules/AccountList/types.d.ts.map +0 -1
- package/dist/modules/Cart/index.d.ts.map +0 -1
- package/dist/modules/Cart/types.d.ts.map +0 -1
- package/dist/modules/Date/types.d.ts.map +0 -1
- package/dist/modules/Date/utils.d.ts.map +0 -1
- package/dist/modules/Guests/index.d.ts.map +0 -1
- package/dist/modules/Guests/types.d.ts.map +0 -1
- package/dist/modules/Order/index.d.ts.map +0 -1
- package/dist/modules/Order/types.d.ts.map +0 -1
- package/dist/modules/Payment/index.d.ts.map +0 -1
- package/dist/modules/Payment/types.d.ts.map +0 -1
- package/dist/modules/Product/index.d.ts.map +0 -1
- package/dist/modules/Product/types.d.ts.map +0 -1
- package/dist/modules/ProductList/types.d.ts.map +0 -1
- package/dist/modules/Resource/index.d.ts.map +0 -1
- package/dist/modules/Resource/types.d.ts.map +0 -1
- package/dist/modules/Resource/utils.d.ts.map +0 -1
- package/dist/modules/Rules/types.d.ts.map +0 -1
- package/dist/modules/Step/index.d.ts.map +0 -1
- package/dist/modules/Step/tyeps.d.ts.map +0 -1
- package/dist/modules/Summary/index.d.ts.map +0 -1
- package/dist/modules/Summary/types.d.ts.map +0 -1
- package/dist/modules/Summary/utils.d.ts.map +0 -1
- package/dist/modules/index.d.ts.map +0 -1
- package/dist/plugins/index.d.ts.map +0 -1
- package/dist/plugins/request.d.ts.map +0 -1
- package/dist/plugins/shopStore.d.ts.map +0 -1
- package/dist/plugins/window.d.ts.map +0 -1
- package/dist/solution/BookingByStep/types.d.ts.map +0 -1
- package/dist/solution/BookingByStep/utils/products.d.ts.map +0 -1
- package/dist/solution/BuyTickets/index.d.ts.map +0 -1
- package/dist/solution/BuyTickets/types.d.ts.map +0 -1
- package/dist/solution/PlaceOrder/index.d.ts.map +0 -1
- package/dist/solution/ShopDiscount/types.d.ts.map +0 -1
- package/dist/solution/ShopDiscount/utils.d.ts.map +0 -1
- package/dist/solution/index.d.ts.map +0 -1
- package/dist/store/createStore.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Module, PisellCore, ModuleOptions } from
|
|
2
|
-
import { BaseModule } from
|
|
3
|
-
import { Discount, DiscountModuleAPI } from
|
|
1
|
+
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
|
+
import { BaseModule } from '../BaseModule';
|
|
3
|
+
import { Discount, DiscountModuleAPI } from './types';
|
|
4
4
|
export declare class DiscountModule extends BaseModule implements Module, DiscountModuleAPI {
|
|
5
5
|
protected defaultName: string;
|
|
6
6
|
protected defaultVersion: string;
|
|
@@ -15,7 +15,7 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
|
|
|
15
15
|
setDiscountList(discountList: Discount[]): Promise<void>;
|
|
16
16
|
getDiscountList(): Discount[];
|
|
17
17
|
loadPrepareConfig(params: {
|
|
18
|
-
action?:
|
|
18
|
+
action?: 'create';
|
|
19
19
|
with_good_pass: 0 | 1;
|
|
20
20
|
customer_id: number;
|
|
21
21
|
}): Promise<Discount[]>;
|
|
@@ -88,7 +88,9 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
88
88
|
available: 1,
|
|
89
89
|
relation_product: 1
|
|
90
90
|
});
|
|
91
|
-
const resultDiscountList = this.uniqueByProductId(
|
|
91
|
+
const resultDiscountList = this.uniqueByProductId(
|
|
92
|
+
this.filterEnabledDiscountList((result == null ? void 0 : result.data) || []) || []
|
|
93
|
+
) || [];
|
|
92
94
|
return resultDiscountList;
|
|
93
95
|
}
|
|
94
96
|
filterEnabledDiscountList(discountList) {
|
|
@@ -129,7 +131,12 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
129
131
|
}
|
|
130
132
|
storeChange() {
|
|
131
133
|
if (this.openCache) {
|
|
132
|
-
this.checkSaveCache({
|
|
134
|
+
this.checkSaveCache({
|
|
135
|
+
cacheId: this.cacheId,
|
|
136
|
+
fatherModule: this.fatherModule,
|
|
137
|
+
store: this.store,
|
|
138
|
+
cacheKey: ["discountList"]
|
|
139
|
+
});
|
|
133
140
|
}
|
|
134
141
|
}
|
|
135
142
|
};
|
|
@@ -52,7 +52,10 @@ var GuestListModule = class extends import_BaseModule.BaseModule {
|
|
|
52
52
|
...this.state.list[index],
|
|
53
53
|
...updates
|
|
54
54
|
};
|
|
55
|
-
await this.core.effects.emit(
|
|
55
|
+
await this.core.effects.emit(
|
|
56
|
+
import_types.GuestHooks.OnGuestUpdate,
|
|
57
|
+
this.state.list[index]
|
|
58
|
+
);
|
|
56
59
|
await this.core.effects.emit(import_types.GuestHooks.OnGuestChange, this.state.list);
|
|
57
60
|
}
|
|
58
61
|
async removeGuest(id) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Module, PisellCore, ModuleOptions } from
|
|
2
|
-
import { BaseModule } from
|
|
3
|
-
import { OrderModuleAPI, CommitOrderParams } from
|
|
1
|
+
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
|
+
import { BaseModule } from '../BaseModule';
|
|
3
|
+
import { OrderModuleAPI, CommitOrderParams } from './types';
|
|
4
|
+
import { CartItem } from '../Cart/types';
|
|
4
5
|
export declare class OrderModule extends BaseModule implements Module, OrderModuleAPI {
|
|
5
6
|
protected defaultName: string;
|
|
6
7
|
protected defaultVersion: string;
|
|
@@ -8,7 +9,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
8
9
|
private request;
|
|
9
10
|
constructor(name?: string, version?: string);
|
|
10
11
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
11
|
-
createOrder(params: CommitOrderParams[
|
|
12
|
+
createOrder(params: CommitOrderParams['query']): {
|
|
12
13
|
type: string;
|
|
13
14
|
platform: string;
|
|
14
15
|
sales_channel: string;
|
|
@@ -16,6 +17,11 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
16
17
|
bookings: any[];
|
|
17
18
|
shop_note: string;
|
|
18
19
|
schedule_date: string;
|
|
20
|
+
is_deposit: number;
|
|
19
21
|
};
|
|
20
|
-
|
|
22
|
+
checkBeforeSubmitOrder(params: {
|
|
23
|
+
cartItems: CartItem[];
|
|
24
|
+
type: 'holder' | 'account';
|
|
25
|
+
}): boolean;
|
|
26
|
+
submitOrder(order: CommitOrderParams): Promise<void>;
|
|
21
27
|
}
|
|
@@ -23,6 +23,7 @@ __export(Order_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(Order_exports);
|
|
25
25
|
var import_BaseModule = require("../BaseModule");
|
|
26
|
+
var import_utils = require("./utils");
|
|
26
27
|
var OrderModule = class extends import_BaseModule.BaseModule {
|
|
27
28
|
constructor(name, version) {
|
|
28
29
|
super(name, version);
|
|
@@ -42,22 +43,42 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
42
43
|
order_sales_channel: "online_store",
|
|
43
44
|
bookings: [],
|
|
44
45
|
shop_note: "",
|
|
45
|
-
schedule_date: ""
|
|
46
|
+
schedule_date: "",
|
|
47
|
+
is_deposit: 0
|
|
46
48
|
};
|
|
49
|
+
let is_deposit = 0;
|
|
47
50
|
if (params.cartItems.length > 0) {
|
|
48
51
|
params.cartItems.forEach((item) => {
|
|
52
|
+
if (!item._origin.duration) {
|
|
53
|
+
const { duration, durationType } = (0, import_utils.generateDuration)(item);
|
|
54
|
+
item._origin.duration = duration;
|
|
55
|
+
item._origin.sub_type = durationType;
|
|
56
|
+
}
|
|
49
57
|
order.bookings.push(item._origin);
|
|
58
|
+
if (item == null ? void 0 : item.deposit) {
|
|
59
|
+
is_deposit = 1;
|
|
60
|
+
}
|
|
50
61
|
});
|
|
51
62
|
const firstCartItem = params.cartItems[0];
|
|
52
63
|
order.schedule_date = firstCartItem.start_date + " " + firstCartItem.start_time + ":00";
|
|
64
|
+
order.is_deposit = is_deposit;
|
|
53
65
|
}
|
|
54
66
|
return order;
|
|
55
67
|
}
|
|
56
|
-
|
|
68
|
+
checkBeforeSubmitOrder(params) {
|
|
69
|
+
const { cartItems, type } = params;
|
|
70
|
+
if (type === "holder") {
|
|
71
|
+
const hasNoHolderId = cartItems.some((item) => !item.holder_id);
|
|
72
|
+
if (hasNoHolderId) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
async submitOrder(order) {
|
|
57
79
|
const { url, query } = order;
|
|
58
80
|
const fetchUrl = url || "/order/appointment";
|
|
59
81
|
const params = this.createOrder(query);
|
|
60
|
-
console.log(params);
|
|
61
82
|
return this.request.post(fetchUrl, params);
|
|
62
83
|
}
|
|
63
84
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CartItem } from
|
|
1
|
+
import { CartItem } from '../Cart/types';
|
|
2
2
|
export declare enum OrderHooks {
|
|
3
3
|
OnOrderCreate = "order:onOrderCreate",
|
|
4
4
|
OnOrderUpdate = "order:onOrderUpdate",
|
|
@@ -25,10 +25,17 @@ export interface OrderModuleAPI {
|
|
|
25
25
|
* @param params 订单信息
|
|
26
26
|
* @returns 订单信息
|
|
27
27
|
*/
|
|
28
|
-
createOrder: (params: CommitOrderParams[
|
|
28
|
+
createOrder: (params: CommitOrderParams['query']) => any;
|
|
29
|
+
/**
|
|
30
|
+
* 检查购物车提交订单前是否符合条件
|
|
31
|
+
*/
|
|
32
|
+
checkBeforeSubmitOrder: (params: {
|
|
33
|
+
cartItems: CartItem[];
|
|
34
|
+
type: 'holder' | 'account';
|
|
35
|
+
}) => boolean;
|
|
29
36
|
/**
|
|
30
37
|
* 提交订单
|
|
31
38
|
* @param params 订单信息
|
|
32
39
|
*/
|
|
33
|
-
|
|
40
|
+
submitOrder: (params: CommitOrderParams) => Promise<void>;
|
|
34
41
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/modules/Order/utils.ts
|
|
30
|
+
var utils_exports = {};
|
|
31
|
+
__export(utils_exports, {
|
|
32
|
+
generateDuration: () => generateDuration
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(utils_exports);
|
|
35
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
36
|
+
var generateDuration = (cartItem) => {
|
|
37
|
+
const startDate = (0, import_dayjs.default)(`${cartItem.start_date} ${cartItem.start_time}`);
|
|
38
|
+
const endDate = (0, import_dayjs.default)(`${cartItem.end_date} ${cartItem.end_time}`);
|
|
39
|
+
const duration = endDate.diff(startDate, "minutes");
|
|
40
|
+
return { duration, durationType: "minutes" };
|
|
41
|
+
};
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 && (module.exports = {
|
|
44
|
+
generateDuration
|
|
45
|
+
});
|
|
@@ -72,12 +72,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
72
72
|
await this.core.effects.emit(import_types.PaymentHooks.OnPaymentRefund, payment);
|
|
73
73
|
}
|
|
74
74
|
getAvailablePaymentMethods() {
|
|
75
|
-
return [
|
|
76
|
-
"credit_card",
|
|
77
|
-
"debit_card",
|
|
78
|
-
"alipay",
|
|
79
|
-
"wechat_pay"
|
|
80
|
-
];
|
|
75
|
+
return ["credit_card", "debit_card", "alipay", "wechat_pay"];
|
|
81
76
|
}
|
|
82
77
|
async checkPaymentStatus(paymentId) {
|
|
83
78
|
const payment = this.state.paymentHistory.find((p) => p.id === paymentId);
|
|
@@ -2,16 +2,26 @@ import { Module, PisellCore } from '../../types';
|
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
3
|
import { ProductData, ProductMedia, ProductTag, ProductCategory, ProductBundleGroup } from './types';
|
|
4
4
|
export * from './types';
|
|
5
|
+
/**
|
|
6
|
+
* 商品详情模块
|
|
7
|
+
* 除了跟商品列表模块组合外,还会提供单独的商品详情页的一些方法
|
|
8
|
+
*
|
|
9
|
+
* @export
|
|
10
|
+
* @class Product
|
|
11
|
+
* @extends {BaseModule}
|
|
12
|
+
* @implements {Module}
|
|
13
|
+
*/
|
|
5
14
|
export declare class Product extends BaseModule implements Module {
|
|
6
15
|
protected defaultName: string;
|
|
7
16
|
protected defaultVersion: string;
|
|
8
17
|
private store;
|
|
18
|
+
protected otherParams: any;
|
|
9
19
|
constructor(name?: string, version?: string);
|
|
10
20
|
initialize(core: PisellCore, options: any): Promise<void>;
|
|
11
21
|
/**
|
|
12
22
|
* 获取商品数据
|
|
13
23
|
*/
|
|
14
|
-
getData(): ProductData
|
|
24
|
+
getData(): ProductData;
|
|
15
25
|
/**
|
|
16
26
|
* 获取商品ID
|
|
17
27
|
*/
|
|
@@ -36,4 +46,7 @@ export declare class Product extends BaseModule implements Module {
|
|
|
36
46
|
* 获取商品分类
|
|
37
47
|
*/
|
|
38
48
|
getCategories(): ProductCategory[];
|
|
49
|
+
setOtherParams(key: string, value: any): void;
|
|
50
|
+
getOtherParams(): any;
|
|
51
|
+
getProductType(): "duration" | "session" | "normal";
|
|
39
52
|
}
|
|
@@ -30,6 +30,9 @@ var Product = class extends import_BaseModule.BaseModule {
|
|
|
30
30
|
super(name, version);
|
|
31
31
|
this.defaultName = "product";
|
|
32
32
|
this.defaultVersion = "1.0.0";
|
|
33
|
+
this.otherParams = {
|
|
34
|
+
scheduler: []
|
|
35
|
+
};
|
|
33
36
|
}
|
|
34
37
|
async initialize(core, options) {
|
|
35
38
|
this.core = core;
|
|
@@ -79,6 +82,22 @@ var Product = class extends import_BaseModule.BaseModule {
|
|
|
79
82
|
getCategories() {
|
|
80
83
|
return this.store.categories;
|
|
81
84
|
}
|
|
85
|
+
setOtherParams(key, value) {
|
|
86
|
+
this.otherParams[key] = value;
|
|
87
|
+
}
|
|
88
|
+
getOtherParams() {
|
|
89
|
+
return this.otherParams;
|
|
90
|
+
}
|
|
91
|
+
getProductType() {
|
|
92
|
+
var _a;
|
|
93
|
+
if (this.store.duration) {
|
|
94
|
+
return "duration";
|
|
95
|
+
}
|
|
96
|
+
if ((_a = this.store["schedule.ids"]) == null ? void 0 : _a.length) {
|
|
97
|
+
return "session";
|
|
98
|
+
}
|
|
99
|
+
return "normal";
|
|
100
|
+
}
|
|
82
101
|
};
|
|
83
102
|
// Annotate the CommonJS export names for ESM import in node:
|
|
84
103
|
0 && (module.exports = {
|
|
@@ -17,7 +17,7 @@ export interface ProductData {
|
|
|
17
17
|
/** 商品slug */
|
|
18
18
|
slug: string;
|
|
19
19
|
/** draft:草稿;published:已发布;pending:待发布;archived:已归档 */
|
|
20
|
-
status:
|
|
20
|
+
status: 'draft' | 'published' | 'pending' | 'archived';
|
|
21
21
|
/** 库存数量 */
|
|
22
22
|
stock_quantity: number;
|
|
23
23
|
/** 销售数量 */
|
|
@@ -152,6 +152,30 @@ export interface ProductData {
|
|
|
152
152
|
options?: any[];
|
|
153
153
|
/** 商品原信息 */
|
|
154
154
|
origin?: any;
|
|
155
|
+
/** 容量 */
|
|
156
|
+
capacity?: any;
|
|
157
|
+
/** 商品套餐 */
|
|
158
|
+
product_bundle?: any;
|
|
159
|
+
/** 日程ids */
|
|
160
|
+
'schedule.ids'?: number[];
|
|
161
|
+
/** 商品日程信息,前端临时用,随时需要回收的 */
|
|
162
|
+
_schedule?: any;
|
|
163
|
+
/** 商品定金信息 */
|
|
164
|
+
custom_deposit_data?: {
|
|
165
|
+
/** 商品是否包含定金 1:是 0:否 */
|
|
166
|
+
has_deposit: 0 | 1;
|
|
167
|
+
/** 定金固定金额 */
|
|
168
|
+
deposit_fixed?: string;
|
|
169
|
+
/** 定金百分比 */
|
|
170
|
+
deposit_percentage?: string;
|
|
171
|
+
/** 定金协议数据 */
|
|
172
|
+
deposit_policy_data?: Array<{
|
|
173
|
+
/** 定金协议id */
|
|
174
|
+
id: number;
|
|
175
|
+
/** 定金协议标题 */
|
|
176
|
+
title: string;
|
|
177
|
+
}>;
|
|
178
|
+
};
|
|
155
179
|
}
|
|
156
180
|
/**
|
|
157
181
|
* 商品媒体信息接口
|
|
@@ -414,7 +438,7 @@ export interface ProductResourceItem {
|
|
|
414
438
|
/** 资源标题 */
|
|
415
439
|
title: string;
|
|
416
440
|
/** 资源编码 */
|
|
417
|
-
code:
|
|
441
|
+
code: 'resource';
|
|
418
442
|
/** 默认资源 */
|
|
419
443
|
default_resource?: number[];
|
|
420
444
|
/** 可选资源 */
|
|
@@ -423,7 +447,7 @@ export interface ProductResourceItem {
|
|
|
423
447
|
resource_type_id: number;
|
|
424
448
|
/** 选择类型 */
|
|
425
449
|
select_type?: {
|
|
426
|
-
type:
|
|
450
|
+
type: 'single';
|
|
427
451
|
min: 1;
|
|
428
452
|
max: 1;
|
|
429
453
|
};
|
|
@@ -35,29 +35,43 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
35
35
|
this.defaultVersion = "1.0.0";
|
|
36
36
|
}
|
|
37
37
|
async initialize(core, options) {
|
|
38
|
+
var _a;
|
|
38
39
|
this.core = core;
|
|
39
40
|
this.store = options.store;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
if (Array.isArray((_a = options.initialState) == null ? void 0 : _a.list)) {
|
|
42
|
+
this.store.list = options.initialState.list;
|
|
43
|
+
this.core.effects.emit(`${this.name}:changed`, this.store.list);
|
|
44
|
+
this.storeChange();
|
|
45
|
+
} else {
|
|
46
|
+
this.store.list = [];
|
|
47
|
+
this.store.productMap = /* @__PURE__ */ new Map();
|
|
48
|
+
this.store.selectProducts = [];
|
|
49
|
+
}
|
|
44
50
|
}
|
|
45
51
|
async storeChange(path, value) {
|
|
46
52
|
var _a;
|
|
47
53
|
(_a = this.store.list) == null ? void 0 : _a.forEach((product) => {
|
|
48
54
|
if (!this.store.productMap.has(`product-${product.id}`)) {
|
|
49
|
-
const newProductModule = new import_Product.Product(
|
|
55
|
+
const newProductModule = new import_Product.Product(
|
|
56
|
+
`product_${product.id.toString()}`
|
|
57
|
+
);
|
|
50
58
|
this.core.registerModule(newProductModule, { initialState: product });
|
|
51
59
|
this.store.productMap.set(product.id.toString(), newProductModule);
|
|
52
60
|
}
|
|
53
61
|
});
|
|
54
62
|
}
|
|
55
63
|
async getProducts() {
|
|
56
|
-
await this.core.effects.emit(
|
|
64
|
+
await this.core.effects.emit(
|
|
65
|
+
import_types.ProductListHooks.onGetProducts,
|
|
66
|
+
this.store.list
|
|
67
|
+
);
|
|
57
68
|
return (0, import_lodash_es.cloneDeep)(this.store.list);
|
|
58
69
|
}
|
|
59
70
|
async getProduct(id) {
|
|
60
|
-
await this.core.effects.emit(
|
|
71
|
+
await this.core.effects.emit(
|
|
72
|
+
import_types.ProductListHooks.onGetProduct,
|
|
73
|
+
this.store.list
|
|
74
|
+
);
|
|
61
75
|
const product = this.store.productMap.get(`${id}`);
|
|
62
76
|
if (product)
|
|
63
77
|
return product;
|
|
@@ -78,7 +78,10 @@ var ResourceListModule = class extends import_BaseModule.BaseModule {
|
|
|
78
78
|
...this.store.list[index],
|
|
79
79
|
...updates
|
|
80
80
|
};
|
|
81
|
-
await this.core.effects.emit(
|
|
81
|
+
await this.core.effects.emit(
|
|
82
|
+
import_types.ResourceHooks.OnResourceChange,
|
|
83
|
+
this.store.list[index]
|
|
84
|
+
);
|
|
82
85
|
}
|
|
83
86
|
};
|
|
84
87
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -24,10 +24,13 @@ __export(utils_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(utils_exports);
|
|
26
26
|
var getResourcesMap = (resourceList) => {
|
|
27
|
-
return resourceList.reduce(
|
|
28
|
-
pre
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
return resourceList.reduce(
|
|
28
|
+
(pre, item) => {
|
|
29
|
+
pre[item.id] = item;
|
|
30
|
+
return pre;
|
|
31
|
+
},
|
|
32
|
+
{}
|
|
33
|
+
);
|
|
31
34
|
};
|
|
32
35
|
var getResourcesByIds = (resourcesMap, ids) => {
|
|
33
36
|
return (ids || []).map((id) => resourcesMap[id]);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Module, PisellCore, ModuleOptions } from
|
|
2
|
-
import { BaseModule } from
|
|
3
|
-
import { Rules, RulesModuleAPI, DiscountResult } from
|
|
1
|
+
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
|
+
import { BaseModule } from '../BaseModule';
|
|
3
|
+
import { Rules, RulesModuleAPI, DiscountResult } from './types';
|
|
4
4
|
import { Discount } from "../Discount/types";
|
|
5
5
|
export declare class RulesModule extends BaseModule implements Module, RulesModuleAPI {
|
|
6
6
|
protected defaultName: string;
|
|
@@ -25,6 +25,7 @@ module.exports = __toCommonJS(Rules_exports);
|
|
|
25
25
|
var import_BaseModule = require("../BaseModule");
|
|
26
26
|
var import_types = require("./types");
|
|
27
27
|
var import_utils = require("../../solution/ShopDiscount/utils");
|
|
28
|
+
var import_utils2 = require("../Cart/utils");
|
|
28
29
|
var RulesModule = class extends import_BaseModule.BaseModule {
|
|
29
30
|
constructor(name, version) {
|
|
30
31
|
super(name, version);
|
|
@@ -174,53 +175,127 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
174
175
|
isManualDiscount = false;
|
|
175
176
|
}
|
|
176
177
|
if (applicableDiscounts.length === 0 || isManualDiscount) {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
178
|
+
if (product.isClient) {
|
|
179
|
+
processedProductsMap.set(
|
|
180
|
+
product._id,
|
|
181
|
+
this.hooks.setProduct(originProduct, {
|
|
182
|
+
...isManualDiscount ? {} : {
|
|
183
|
+
origin_total: (0, import_utils2.getProductOriginTotalPrice)({
|
|
184
|
+
product: {
|
|
185
|
+
original_price: product.original_price
|
|
186
|
+
},
|
|
187
|
+
bundle: product.bundle,
|
|
188
|
+
options: product.options
|
|
189
|
+
}),
|
|
190
|
+
total: (0, import_utils2.getProductTotalPrice)({
|
|
191
|
+
product: {
|
|
192
|
+
price: product.price
|
|
193
|
+
},
|
|
194
|
+
bundle: product.bundle,
|
|
195
|
+
options: product.options
|
|
196
|
+
}),
|
|
197
|
+
price: product.price
|
|
198
|
+
},
|
|
199
|
+
discount_list: []
|
|
200
|
+
})
|
|
201
|
+
);
|
|
202
|
+
} else {
|
|
203
|
+
processedProductsMap.set(
|
|
204
|
+
product._id,
|
|
205
|
+
this.hooks.setProduct(originProduct, {
|
|
206
|
+
...isManualDiscount ? {} : {
|
|
207
|
+
total: product.origin_total || product.total,
|
|
208
|
+
price: product.price
|
|
209
|
+
},
|
|
210
|
+
discount_list: []
|
|
211
|
+
})
|
|
212
|
+
);
|
|
213
|
+
return;
|
|
202
214
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
+
if (applicableDiscounts.length && product.booking_id && typeof selectedDiscount.isManualSelect === "undefined") {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
usedDiscounts.set(selectedDiscount.id, true);
|
|
219
|
+
const appliedProducts = appliedDiscountProducts.get(selectedDiscount.id) || [];
|
|
220
|
+
const discountDetail = {
|
|
221
|
+
amount: product.price,
|
|
222
|
+
type: selectedDiscount.tag,
|
|
223
|
+
discount: {
|
|
224
|
+
resource_id: selectedDiscount.id,
|
|
225
|
+
title: selectedDiscount.format_title,
|
|
226
|
+
original_amount: product.origin_total,
|
|
227
|
+
product_id: selectedDiscount.product_id
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
appliedProducts.push(discountDetail);
|
|
231
|
+
appliedDiscountProducts.set(selectedDiscount.id, appliedProducts);
|
|
232
|
+
if (product.isClient) {
|
|
233
|
+
processedProductsMap.set(
|
|
234
|
+
product._id,
|
|
235
|
+
this.hooks.setProduct(originProduct, {
|
|
236
|
+
discount_list: [discountDetail],
|
|
237
|
+
price: 0,
|
|
238
|
+
origin_total: (0, import_utils2.getProductOriginTotalPrice)({
|
|
239
|
+
product: {
|
|
240
|
+
original_price: product.original_price
|
|
241
|
+
},
|
|
242
|
+
bundle: product.bundle,
|
|
243
|
+
options: product.options
|
|
244
|
+
}),
|
|
245
|
+
total: (0, import_utils2.getProductTotalPrice)({
|
|
246
|
+
product: {
|
|
247
|
+
price: "0"
|
|
248
|
+
},
|
|
249
|
+
bundle: product.bundle,
|
|
250
|
+
options: product.options
|
|
251
|
+
})
|
|
252
|
+
})
|
|
253
|
+
);
|
|
254
|
+
} else {
|
|
255
|
+
processedProductsMap.set(
|
|
256
|
+
product._id,
|
|
257
|
+
this.hooks.setProduct(originProduct, {
|
|
258
|
+
discount_list: [discountDetail],
|
|
259
|
+
price: 0,
|
|
260
|
+
total: (product.origin_total || product.total) - product.price,
|
|
261
|
+
origin_total: product.origin_total || product.total
|
|
262
|
+
})
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
215
266
|
});
|
|
216
267
|
const processedProductList = productList.map((originProduct) => {
|
|
217
268
|
const product = this.hooks.getProduct(originProduct);
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
269
|
+
const getDefaultProduct = () => {
|
|
270
|
+
if (product.isClient) {
|
|
271
|
+
this.hooks.setProduct(originProduct, {
|
|
272
|
+
discount_list: [],
|
|
273
|
+
price: product.price,
|
|
274
|
+
origin_total: (0, import_utils2.getProductOriginTotalPrice)({
|
|
275
|
+
product: {
|
|
276
|
+
original_price: product.original_price
|
|
277
|
+
},
|
|
278
|
+
bundle: product.bundle,
|
|
279
|
+
options: product.options
|
|
280
|
+
}),
|
|
281
|
+
total: (0, import_utils2.getProductTotalPrice)({
|
|
282
|
+
product: {
|
|
283
|
+
price: product.price
|
|
284
|
+
},
|
|
285
|
+
bundle: product.bundle,
|
|
286
|
+
options: product.options
|
|
287
|
+
})
|
|
288
|
+
});
|
|
289
|
+
} else {
|
|
290
|
+
this.hooks.setProduct(originProduct, {
|
|
291
|
+
discount_list: [],
|
|
292
|
+
total: product.total,
|
|
293
|
+
origin_total: product.origin_total,
|
|
294
|
+
price: product.price
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
return processedProductsMap.get(product._id) || getDefaultProduct();
|
|
224
299
|
});
|
|
225
300
|
const updatedDiscountList = addModeDiscount.map((discount) => {
|
|
226
301
|
const applicableProducts = discountApplicability.get(discount.id) || [];
|