@pisell/pisellos 3.0.5 → 3.0.7

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.
Files changed (148) hide show
  1. package/dist/modules/Account/index.d.ts +2 -6
  2. package/dist/modules/Account/index.js +21 -103
  3. package/dist/modules/Account/types.d.ts +12 -1
  4. package/dist/modules/AccountList/index.d.ts +20 -1
  5. package/dist/modules/AccountList/index.js +243 -75
  6. package/dist/modules/AccountList/types.d.ts +33 -1
  7. package/dist/modules/AccountList/types.js +8 -0
  8. package/dist/modules/AccountList/utils.d.ts +9 -0
  9. package/dist/modules/AccountList/utils.js +25 -0
  10. package/dist/modules/BaseModule.d.ts +2 -2
  11. package/dist/modules/BaseModule.js +1 -1
  12. package/dist/modules/Cart/index.d.ts +8 -5
  13. package/dist/modules/Cart/index.js +101 -25
  14. package/dist/modules/Cart/types.d.ts +82 -5
  15. package/dist/modules/Cart/types.js +22 -0
  16. package/dist/modules/Cart/utils.d.ts +106 -13
  17. package/dist/modules/Cart/utils.js +289 -76
  18. package/dist/modules/Date/index.d.ts +6 -6
  19. package/dist/modules/Date/index.js +41 -58
  20. package/dist/modules/Date/types.d.ts +22 -6
  21. package/dist/modules/Date/utils.d.ts +4 -3
  22. package/dist/modules/Date/utils.js +81 -30
  23. package/dist/modules/Discount/index.d.ts +4 -4
  24. package/dist/modules/Discount/index.js +11 -11
  25. package/dist/modules/Order/index.d.ts +11 -5
  26. package/dist/modules/Order/index.js +47 -18
  27. package/dist/modules/Order/types.d.ts +10 -3
  28. package/dist/modules/Order/utils.d.ts +10 -0
  29. package/dist/modules/Order/utils.js +15 -0
  30. package/dist/modules/Product/index.d.ts +14 -1
  31. package/dist/modules/Product/index.js +35 -0
  32. package/dist/modules/Product/types.d.ts +27 -3
  33. package/dist/modules/ProductList/index.js +11 -5
  34. package/dist/modules/Resource/types.d.ts +1 -0
  35. package/dist/modules/Resource/utils.js +1 -1
  36. package/dist/modules/Rules/index.d.ts +3 -3
  37. package/dist/modules/Rules/index.js +97 -29
  38. package/dist/modules/Rules/types.d.ts +5 -1
  39. package/dist/modules/Schedule/index.d.ts +18 -0
  40. package/dist/modules/Schedule/index.js +111 -0
  41. package/dist/modules/Schedule/type.d.ts +157 -0
  42. package/dist/modules/Schedule/type.js +1 -0
  43. package/dist/modules/Schedule/types.d.ts +182 -0
  44. package/dist/modules/Schedule/types.js +1 -0
  45. package/dist/modules/Schedule/utils.d.ts +67 -0
  46. package/dist/modules/Schedule/utils.js +729 -0
  47. package/dist/modules/Step/index.d.ts +14 -3
  48. package/dist/modules/Step/index.js +54 -2
  49. package/dist/modules/Summary/index.d.ts +12 -5
  50. package/dist/modules/Summary/index.js +33 -7
  51. package/dist/modules/Summary/types.d.ts +23 -2
  52. package/dist/modules/Summary/utils.d.ts +14 -4
  53. package/dist/modules/Summary/utils.js +46 -4
  54. package/dist/modules/index.d.ts +10 -0
  55. package/dist/modules/index.js +11 -1
  56. package/dist/plugins/index.d.ts +3 -3
  57. package/dist/plugins/request.d.ts +3 -3
  58. package/dist/plugins/request.js +30 -30
  59. package/dist/plugins/shopStore.d.ts +1 -1
  60. package/dist/solution/BookingByStep/index.d.ts +97 -24
  61. package/dist/solution/BookingByStep/index.js +1024 -322
  62. package/dist/solution/BookingByStep/types.d.ts +3 -10
  63. package/dist/solution/BookingByStep/types.js +11 -15
  64. package/dist/solution/BookingByStep/utils/products.d.ts +1 -1
  65. package/dist/solution/BookingByStep/utils/products.js +3 -0
  66. package/dist/solution/BookingByStep/utils/resources.d.ts +60 -6
  67. package/dist/solution/BookingByStep/utils/resources.js +293 -52
  68. package/dist/solution/ShopDiscount/index.d.ts +4 -4
  69. package/dist/solution/ShopDiscount/index.js +29 -24
  70. package/dist/solution/ShopDiscount/types.d.ts +3 -2
  71. package/dist/solution/ShopDiscount/types.js +1 -0
  72. package/dist/solution/ShopDiscount/utils.js +1 -1
  73. package/lib/core/index.js +7 -2
  74. package/lib/modules/Account/index.d.ts +2 -6
  75. package/lib/modules/Account/index.js +15 -30
  76. package/lib/modules/Account/types.d.ts +12 -1
  77. package/lib/modules/AccountList/index.d.ts +20 -1
  78. package/lib/modules/AccountList/index.js +122 -13
  79. package/lib/modules/AccountList/types.d.ts +33 -1
  80. package/lib/modules/AccountList/utils.d.ts +9 -0
  81. package/lib/modules/AccountList/utils.js +39 -0
  82. package/lib/modules/BaseModule.d.ts +2 -2
  83. package/lib/modules/BaseModule.js +14 -3
  84. package/lib/modules/Cart/index.d.ts +8 -5
  85. package/lib/modules/Cart/index.js +81 -8
  86. package/lib/modules/Cart/types.d.ts +82 -5
  87. package/lib/modules/Cart/types.js +20 -2
  88. package/lib/modules/Cart/utils.d.ts +106 -13
  89. package/lib/modules/Cart/utils.js +188 -45
  90. package/lib/modules/Date/index.d.ts +6 -6
  91. package/lib/modules/Date/index.js +13 -28
  92. package/lib/modules/Date/types.d.ts +22 -6
  93. package/lib/modules/Date/utils.d.ts +4 -3
  94. package/lib/modules/Date/utils.js +47 -13
  95. package/lib/modules/Discount/index.d.ts +4 -4
  96. package/lib/modules/Discount/index.js +9 -2
  97. package/lib/modules/Guests/index.js +4 -1
  98. package/lib/modules/Order/index.d.ts +11 -5
  99. package/lib/modules/Order/index.js +24 -3
  100. package/lib/modules/Order/types.d.ts +10 -3
  101. package/lib/modules/Order/utils.d.ts +10 -0
  102. package/lib/modules/Order/utils.js +45 -0
  103. package/lib/modules/Payment/index.js +1 -6
  104. package/lib/modules/Product/index.d.ts +14 -1
  105. package/lib/modules/Product/index.js +19 -0
  106. package/lib/modules/Product/types.d.ts +27 -3
  107. package/lib/modules/ProductList/index.js +21 -7
  108. package/lib/modules/Resource/index.js +4 -1
  109. package/lib/modules/Resource/types.d.ts +1 -0
  110. package/lib/modules/Resource/utils.js +7 -4
  111. package/lib/modules/Rules/index.d.ts +3 -3
  112. package/lib/modules/Rules/index.js +100 -25
  113. package/lib/modules/Rules/types.d.ts +5 -1
  114. package/lib/modules/Schedule/index.d.ts +18 -0
  115. package/lib/modules/Schedule/index.js +81 -0
  116. package/lib/modules/Schedule/type.d.ts +157 -0
  117. package/lib/modules/Schedule/type.js +17 -0
  118. package/lib/modules/Schedule/types.d.ts +182 -0
  119. package/lib/modules/Schedule/types.js +17 -0
  120. package/lib/modules/Schedule/utils.d.ts +67 -0
  121. package/lib/modules/Schedule/utils.js +600 -0
  122. package/lib/modules/Step/index.d.ts +14 -3
  123. package/lib/modules/Step/index.js +38 -1
  124. package/lib/modules/Summary/index.d.ts +12 -5
  125. package/lib/modules/Summary/index.js +15 -1
  126. package/lib/modules/Summary/types.d.ts +23 -2
  127. package/lib/modules/Summary/utils.d.ts +14 -4
  128. package/lib/modules/Summary/utils.js +30 -1
  129. package/lib/modules/index.d.ts +10 -0
  130. package/lib/modules/index.js +21 -1
  131. package/lib/plugins/index.d.ts +3 -3
  132. package/lib/plugins/request.d.ts +3 -3
  133. package/lib/plugins/request.js +48 -11
  134. package/lib/plugins/shopStore.d.ts +1 -1
  135. package/lib/solution/BookingByStep/index.d.ts +97 -24
  136. package/lib/solution/BookingByStep/index.js +693 -145
  137. package/lib/solution/BookingByStep/types.d.ts +3 -10
  138. package/lib/solution/BookingByStep/types.js +37 -14
  139. package/lib/solution/BookingByStep/utils/products.d.ts +1 -1
  140. package/lib/solution/BookingByStep/utils/products.js +3 -0
  141. package/lib/solution/BookingByStep/utils/resources.d.ts +60 -6
  142. package/lib/solution/BookingByStep/utils/resources.js +286 -54
  143. package/lib/solution/BuyTickets/index.js +34 -20
  144. package/lib/solution/ShopDiscount/index.d.ts +4 -4
  145. package/lib/solution/ShopDiscount/index.js +14 -2
  146. package/lib/solution/ShopDiscount/types.d.ts +3 -2
  147. package/lib/solution/ShopDiscount/types.js +1 -0
  148. package/package.json +4 -2
@@ -1,6 +1,6 @@
1
- import { Module, PisellCore, ModuleOptions } from "../../types";
2
- import { BaseModule } from "../BaseModule";
3
- import { Discount, DiscountModuleAPI } from "./types";
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?: "create";
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(this.filterEnabledDiscountList((result == null ? void 0 : result.data) || []) || []) || [];
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({ cacheId: this.cacheId, fatherModule: this.fatherModule, store: this.store, cacheKey: ["discountList"] });
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(import_types.GuestHooks.OnGuestUpdate, this.state.list[index]);
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 "../../types";
2
- import { BaseModule } from "../BaseModule";
3
- import { OrderModuleAPI, CommitOrderParams } from "./types";
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["query"]): {
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
- commitOrder(order: CommitOrderParams): Promise<void>;
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
- async commitOrder(order) {
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 "../Cart/types";
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["query"]) => any;
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
- commitOrder: (params: CommitOrderParams) => Promise<void>;
40
+ submitOrder: (params: CommitOrderParams) => Promise<void>;
34
41
  }
@@ -0,0 +1,10 @@
1
+ import { CartItem } from "../Cart";
2
+ /**
3
+ * 通过 session 类商品的开始时间结束时间生成商品的时长
4
+ * @param {CartItem} cartItem
5
+ * @return {*}
6
+ */
7
+ export declare const generateDuration: (cartItem: CartItem) => {
8
+ duration: number;
9
+ durationType: string;
10
+ };
@@ -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 | null;
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: "draft" | "published" | "pending" | "archived";
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: "resource";
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: "single";
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
- this.store.productMap = /* @__PURE__ */ new Map();
41
- this.store.list = [];
42
- this.store.selectProducts = [];
43
- this.storeChange();
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(`product_${product.id.toString()}`);
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(import_types.ProductListHooks.onGetProducts, this.store.list);
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(import_types.ProductListHooks.onGetProduct, this.store.list);
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(import_types.ResourceHooks.OnResourceChange, this.store.list[index]);
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:
@@ -26,6 +26,7 @@ export interface Resource {
26
26
  startTime?: string;
27
27
  endTime?: string;
28
28
  resourceType?: string;
29
+ children?: Resource[];
29
30
  }
30
31
  /**
31
32
  * 资源列表状态
@@ -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((pre, item) => {
28
- pre[item.id] = item;
29
- return pre;
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 "../../types";
2
- import { BaseModule } from "../BaseModule";
3
- import { Rules, RulesModuleAPI, DiscountResult } from "./types";
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,16 +175,42 @@ var RulesModule = class extends import_BaseModule.BaseModule {
174
175
  isManualDiscount = false;
175
176
  }
176
177
  if (applicableDiscounts.length === 0 || isManualDiscount) {
177
- processedProductsMap.set(
178
- product._id,
179
- this.hooks.setProduct(originProduct, {
180
- ...isManualDiscount ? {} : {
181
- total: product.origin_total || product.total,
182
- price: product.price
183
- },
184
- discount_list: []
185
- })
186
- );
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
+ }
187
214
  return;
188
215
  }
189
216
  if (applicableDiscounts.length && product.booking_id && typeof selectedDiscount.isManualSelect === "undefined") {
@@ -203,24 +230,72 @@ var RulesModule = class extends import_BaseModule.BaseModule {
203
230
  };
204
231
  appliedProducts.push(discountDetail);
205
232
  appliedDiscountProducts.set(selectedDiscount.id, appliedProducts);
206
- processedProductsMap.set(
207
- product._id,
208
- this.hooks.setProduct(originProduct, {
209
- discount_list: [discountDetail],
210
- price: 0,
211
- total: (product.origin_total || product.total) - product.price,
212
- origin_total: product.origin_total || product.total
213
- })
214
- );
233
+ if (product.isClient) {
234
+ processedProductsMap.set(
235
+ product._id,
236
+ this.hooks.setProduct(originProduct, {
237
+ discount_list: [discountDetail],
238
+ price: 0,
239
+ origin_total: (0, import_utils2.getProductOriginTotalPrice)({
240
+ product: {
241
+ original_price: product.original_price
242
+ },
243
+ bundle: product.bundle,
244
+ options: product.options
245
+ }),
246
+ total: (0, import_utils2.getProductTotalPrice)({
247
+ product: {
248
+ price: "0"
249
+ },
250
+ bundle: product.bundle,
251
+ options: product.options
252
+ })
253
+ })
254
+ );
255
+ } else {
256
+ processedProductsMap.set(
257
+ product._id,
258
+ this.hooks.setProduct(originProduct, {
259
+ discount_list: [discountDetail],
260
+ price: 0,
261
+ total: (product.origin_total || product.total) - product.price,
262
+ origin_total: product.origin_total || product.total
263
+ })
264
+ );
265
+ }
215
266
  });
216
267
  const processedProductList = productList.map((originProduct) => {
217
268
  const product = this.hooks.getProduct(originProduct);
218
- return processedProductsMap.get(product._id) || this.hooks.setProduct(originProduct, {
219
- discount_list: [],
220
- total: product.total,
221
- origin_total: product.origin_total,
222
- price: product.price
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) || [];
@@ -1,4 +1,4 @@
1
- import { Discount } from "../Discount/types";
1
+ import { Discount } from '../Discount/types';
2
2
  export declare enum RulesHooks {
3
3
  OnRulesListChange = "rules:onRulesListChange",
4
4
  OnDestroy = "rules:onDestroy"
@@ -25,6 +25,7 @@ export interface RulesModuleAPI {
25
25
  }) => DiscountResult;
26
26
  }
27
27
  type ProductDetail = {
28
+ isClient?: boolean;
28
29
  isManualDiscount?: boolean;
29
30
  booking_id: any;
30
31
  id: number;
@@ -33,6 +34,9 @@ type ProductDetail = {
33
34
  discount_list: Discount[];
34
35
  origin_total: number;
35
36
  _id: string;
37
+ options?: any[];
38
+ bundle?: any[];
39
+ original_price?: number | string;
36
40
  };
37
41
  export interface RulesParamsHooks {
38
42
  getProduct: (product: Record<string, any>) => ProductDetail;
@@ -0,0 +1,18 @@
1
+ import { Module, PisellCore, ModuleOptions } from '../../types';
2
+ import { BaseModule } from '../BaseModule';
3
+ import { ScheduleModuleAPI, ScheduleAvailabilityDateItem, ScheduleItem } from './types';
4
+ export declare class ScheduleModule extends BaseModule implements Module, ScheduleModuleAPI {
5
+ protected defaultName: string;
6
+ protected defaultVersion: string;
7
+ private store;
8
+ private cacheId;
9
+ private openCache;
10
+ private fatherModule;
11
+ constructor(name?: string, version?: string);
12
+ initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
13
+ setScheduleList(list: ScheduleItem[]): void;
14
+ getScheduleListByIds(ids: number[]): ScheduleItem[];
15
+ setAvailabilityScheduleDateList(list: ScheduleAvailabilityDateItem[]): void;
16
+ getAvailabilityScheduleDateList(): ScheduleAvailabilityDateItem[];
17
+ storeChange(): void;
18
+ }