@pisell/pisellos 3.0.35 → 3.0.36

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 (49) hide show
  1. package/dist/modules/Cart/index.js +20 -34
  2. package/dist/modules/Cart/utils/cartAccount.d.ts +21 -0
  3. package/dist/modules/Cart/utils/cartAccount.js +52 -0
  4. package/dist/modules/Cart/utils/cartDate.d.ts +31 -0
  5. package/dist/modules/Cart/utils/cartDate.js +55 -0
  6. package/dist/modules/Cart/utils/cartDiscount.d.ts +19 -0
  7. package/dist/modules/Cart/utils/cartDiscount.js +35 -0
  8. package/dist/modules/Cart/utils/cartNote.d.ts +19 -0
  9. package/dist/modules/Cart/utils/cartNote.js +29 -0
  10. package/dist/modules/Cart/utils/cartProduct.d.ts +107 -0
  11. package/dist/modules/Cart/{utils.js → utils/cartProduct.js} +77 -416
  12. package/dist/modules/Cart/utils/cartRelationForms.d.ts +26 -0
  13. package/dist/modules/Cart/utils/cartRelationForms.js +29 -0
  14. package/dist/modules/Cart/utils/cartResource.d.ts +21 -0
  15. package/dist/modules/Cart/utils/cartResource.js +102 -0
  16. package/dist/modules/Cart/utils/index.d.ts +34 -0
  17. package/dist/modules/Cart/utils/index.js +63 -0
  18. package/dist/modules/Order/index.js +10 -4
  19. package/dist/modules/Product/types.d.ts +4 -0
  20. package/dist/modules/Product/utils.d.ts +17 -0
  21. package/dist/modules/Product/utils.js +41 -0
  22. package/dist/solution/BookingByStep/index.d.ts +8 -1
  23. package/dist/solution/BookingByStep/index.js +182 -63
  24. package/lib/modules/Cart/index.js +16 -24
  25. package/lib/modules/Cart/utils/cartAccount.d.ts +21 -0
  26. package/lib/modules/Cart/utils/cartAccount.js +65 -0
  27. package/lib/modules/Cart/utils/cartDate.d.ts +31 -0
  28. package/lib/modules/Cart/utils/cartDate.js +75 -0
  29. package/lib/modules/Cart/utils/cartDiscount.d.ts +19 -0
  30. package/lib/modules/Cart/utils/cartDiscount.js +52 -0
  31. package/lib/modules/Cart/utils/cartNote.d.ts +19 -0
  32. package/lib/modules/Cart/utils/cartNote.js +46 -0
  33. package/lib/modules/Cart/utils/cartProduct.d.ts +107 -0
  34. package/lib/modules/Cart/{utils.js → utils/cartProduct.js} +78 -328
  35. package/lib/modules/Cart/utils/cartRelationForms.d.ts +26 -0
  36. package/lib/modules/Cart/utils/cartRelationForms.js +48 -0
  37. package/lib/modules/Cart/utils/cartResource.d.ts +21 -0
  38. package/lib/modules/Cart/utils/cartResource.js +124 -0
  39. package/lib/modules/Cart/utils/index.d.ts +34 -0
  40. package/lib/modules/Cart/utils/index.js +91 -0
  41. package/lib/modules/Order/index.js +7 -3
  42. package/lib/modules/Product/types.d.ts +4 -0
  43. package/lib/modules/Product/utils.d.ts +17 -0
  44. package/lib/modules/Product/utils.js +46 -0
  45. package/lib/solution/BookingByStep/index.d.ts +8 -1
  46. package/lib/solution/BookingByStep/index.js +106 -40
  47. package/package.json +1 -1
  48. package/dist/modules/Cart/utils.d.ts +0 -257
  49. package/lib/modules/Cart/utils.d.ts +0 -257
@@ -0,0 +1,124 @@
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/Cart/utils/cartResource.ts
30
+ var cartResource_exports = {};
31
+ __export(cartResource_exports, {
32
+ deleteResourceFromCartItem: () => deleteResourceFromCartItem,
33
+ formatResourceToCartItem: () => formatResourceToCartItem,
34
+ formatResourceToCartItemOrigin: () => formatResourceToCartItemOrigin
35
+ });
36
+ module.exports = __toCommonJS(cartResource_exports);
37
+ var import_dayjs = __toESM(require("dayjs"));
38
+ var formatResourceToCartItem = (params) => {
39
+ const { cartItem, resources } = params;
40
+ if (resources && (resources == null ? void 0 : resources.length)) {
41
+ const firstResource = resources[0];
42
+ cartItem.resource_id = firstResource == null ? void 0 : firstResource.id;
43
+ cartItem.relation_form_name = firstResource == null ? void 0 : firstResource.main_field;
44
+ if (firstResource.startTime && firstResource.endTime) {
45
+ cartItem.start_date = (0, import_dayjs.default)(firstResource.startTime).format("YYYY-MM-DD");
46
+ cartItem.start_time = (0, import_dayjs.default)(firstResource.startTime).format("HH:mm");
47
+ cartItem.end_date = (0, import_dayjs.default)(firstResource.endTime).format("YYYY-MM-DD");
48
+ cartItem.end_time = (0, import_dayjs.default)(firstResource.endTime).format("HH:mm");
49
+ }
50
+ } else {
51
+ cartItem.resource_id = void 0;
52
+ cartItem.relation_form_name = void 0;
53
+ cartItem.start_date = void 0;
54
+ cartItem.start_time = void 0;
55
+ cartItem.end_date = void 0;
56
+ cartItem.end_time = void 0;
57
+ }
58
+ const oringin = formatResourceToCartItemOrigin(params);
59
+ cartItem._origin = oringin;
60
+ cartItem._resourceOrigin = resources;
61
+ return cartItem;
62
+ };
63
+ var formatResourceToCartItemOrigin = (params) => {
64
+ const { cartItem, resources } = params;
65
+ let origin = cartItem._origin;
66
+ if (resources && (resources == null ? void 0 : resources.length)) {
67
+ origin.resources = [];
68
+ const checkResourcesFormat = (resources2, arr) => {
69
+ resources2.forEach((resource) => {
70
+ var _a;
71
+ const childArr = [];
72
+ if ((_a = resource == null ? void 0 : resource.children) == null ? void 0 : _a.length) {
73
+ checkResourcesFormat(resource.children, childArr);
74
+ }
75
+ const obj = {
76
+ relation_type: "form",
77
+ like_status: "common",
78
+ id: resource.id,
79
+ main_field: resource.main_field,
80
+ resourceType: resource.resourceType,
81
+ form_id: resource.form_id,
82
+ relation_id: resource.id,
83
+ capacity: (resource == null ? void 0 : resource.capacity) || 0,
84
+ metadata: (resource == null ? void 0 : resource.metadata) || {}
85
+ // 后端可以在这里挂一个前端用于计算的数据
86
+ };
87
+ if (childArr.length) {
88
+ obj.children = childArr;
89
+ }
90
+ arr.push(obj);
91
+ });
92
+ };
93
+ checkResourcesFormat(resources, origin.resources);
94
+ const { startTime, endTime } = resources[0];
95
+ if (startTime && endTime) {
96
+ origin.select_date = (0, import_dayjs.default)(startTime).format("YYYY-MM-DD");
97
+ origin.start_date = (0, import_dayjs.default)(startTime).format("YYYY-MM-DD");
98
+ origin.start_time = (0, import_dayjs.default)(startTime).format("HH:mm");
99
+ origin.end_date = (0, import_dayjs.default)(endTime).format("YYYY-MM-DD");
100
+ origin.end_time = (0, import_dayjs.default)(endTime).format("HH:mm");
101
+ }
102
+ } else if ((resources == null ? void 0 : resources.length) === 0) {
103
+ origin.resources = [];
104
+ origin.select_date = null;
105
+ origin.start_date = null;
106
+ origin.start_time = null;
107
+ origin.end_date = null;
108
+ origin.end_time = null;
109
+ }
110
+ return origin;
111
+ };
112
+ var deleteResourceFromCartItem = (cartItem) => {
113
+ cartItem.resource_id = void 0;
114
+ cartItem.relation_form_name = void 0;
115
+ delete cartItem._resourceOrigin;
116
+ cartItem._origin.resources = null;
117
+ return cartItem;
118
+ };
119
+ // Annotate the CommonJS export names for ESM import in node:
120
+ 0 && (module.exports = {
121
+ deleteResourceFromCartItem,
122
+ formatResourceToCartItem,
123
+ formatResourceToCartItemOrigin
124
+ });
@@ -0,0 +1,34 @@
1
+ export * from './cartAccount';
2
+ export * from './cartDate';
3
+ export * from './cartDiscount';
4
+ export * from './cartNote';
5
+ export * from './cartProduct';
6
+ export * from './cartRelationForms';
7
+ export * from './cartResource';
8
+ /**
9
+ * 生成一个唯一的 ID
10
+ */
11
+ export declare const getUniqueId: (prefix?: string, maxLength?: number) => string;
12
+ /**
13
+ * 创建购物车原始数据
14
+ */
15
+ export declare const createCartItemOrigin: () => {
16
+ id: number;
17
+ number: number;
18
+ registration_type: string;
19
+ relation_products: never[];
20
+ is_all: boolean;
21
+ product: null;
22
+ sub_type: null;
23
+ duration: null;
24
+ like_status: string;
25
+ resources: null;
26
+ schedule_id: number;
27
+ start_date: null;
28
+ start_time: null;
29
+ select_date: null;
30
+ end_time: null;
31
+ end_date: null;
32
+ metadata: {};
33
+ holder: null;
34
+ };
@@ -0,0 +1,91 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/modules/Cart/utils/index.ts
21
+ var utils_exports = {};
22
+ __export(utils_exports, {
23
+ createCartItemOrigin: () => createCartItemOrigin,
24
+ getUniqueId: () => getUniqueId
25
+ });
26
+ module.exports = __toCommonJS(utils_exports);
27
+ __reExport(utils_exports, require("./cartAccount"), module.exports);
28
+ __reExport(utils_exports, require("./cartDate"), module.exports);
29
+ __reExport(utils_exports, require("./cartDiscount"), module.exports);
30
+ __reExport(utils_exports, require("./cartNote"), module.exports);
31
+ __reExport(utils_exports, require("./cartProduct"), module.exports);
32
+ __reExport(utils_exports, require("./cartRelationForms"), module.exports);
33
+ __reExport(utils_exports, require("./cartResource"), module.exports);
34
+ var getUniqueId = (prefix = "", maxLength = 11) => {
35
+ return prefix + (Math.random() + "").replace(/\D/g, "").substring(0, maxLength);
36
+ };
37
+ var createCartItemOrigin = () => {
38
+ return {
39
+ // 新增为0
40
+ id: 0,
41
+ // 数量 固定为1
42
+ number: 1,
43
+ // 客户端报名所有活动;
44
+ registration_type: "all",
45
+ // 暂时不用
46
+ relation_products: [],
47
+ // 固定
48
+ is_all: false,
49
+ // 商品相关
50
+ product: null,
51
+ // 时长类型
52
+ sub_type: null,
53
+ // 时长
54
+ duration: null,
55
+ // 资源相关
56
+ // 资源状态 -固定
57
+ like_status: "common",
58
+ // 资源类型 - 固定--谭景琳备注:马天宇说现在平行资源是不传这个的
59
+ // relation_type: "form",
60
+ // 所选资源
61
+ resources: null,
62
+ // 日程id - 固定
63
+ schedule_id: 0,
64
+ // 所选开始时间
65
+ start_date: null,
66
+ // 所选开始时间
67
+ start_time: null,
68
+ // 所选开始时间
69
+ select_date: null,
70
+ // 所选结束时间
71
+ end_time: null,
72
+ // 所选结束时间
73
+ end_date: null,
74
+ // 额外信息
75
+ metadata: {},
76
+ // holder相关
77
+ holder: null
78
+ };
79
+ };
80
+ // Annotate the CommonJS export names for ESM import in node:
81
+ 0 && (module.exports = {
82
+ createCartItemOrigin,
83
+ getUniqueId,
84
+ ...require("./cartAccount"),
85
+ ...require("./cartDate"),
86
+ ...require("./cartDiscount"),
87
+ ...require("./cartNote"),
88
+ ...require("./cartProduct"),
89
+ ...require("./cartRelationForms"),
90
+ ...require("./cartResource")
91
+ });
@@ -24,6 +24,7 @@ __export(Order_exports, {
24
24
  module.exports = __toCommonJS(Order_exports);
25
25
  var import_BaseModule = require("../BaseModule");
26
26
  var import_utils = require("./utils");
27
+ var import_utils2 = require("../Product/utils");
27
28
  var OrderModule = class extends import_BaseModule.BaseModule {
28
29
  constructor(name, version) {
29
30
  super(name, version);
@@ -36,6 +37,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
36
37
  this.request = this.core.getPlugin("request");
37
38
  }
38
39
  createOrder(params) {
40
+ var _a;
39
41
  const order = {
40
42
  type: params.type || "appointment_booking",
41
43
  // 要从外面拿,virtual
@@ -57,7 +59,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
57
59
  item._origin.duration = duration;
58
60
  item._origin.sub_type = durationType;
59
61
  }
60
- if (order.type === "virtual") {
62
+ if ((0, import_utils2.isNormalProduct)(item._origin)) {
61
63
  order.relation_products.push(item._origin.product);
62
64
  const relationForms = item._origin.relation_forms || [];
63
65
  order.relation_forms.push(...relationForms);
@@ -70,8 +72,10 @@ var OrderModule = class extends import_BaseModule.BaseModule {
70
72
  }
71
73
  });
72
74
  if (order.type === "appointment_booking") {
73
- const firstCartItem = params.cartItems[0];
74
- order.schedule_date = firstCartItem.start_date + " " + firstCartItem.start_time + ":00";
75
+ const firstAppointmentCartItem = (_a = params.cartItems.filter((n) => !(0, import_utils2.isNormalProduct)(n._productOrigin))) == null ? void 0 : _a[0];
76
+ if (firstAppointmentCartItem) {
77
+ order.schedule_date = firstAppointmentCartItem.start_date + " " + firstAppointmentCartItem.start_time + ":00";
78
+ }
75
79
  }
76
80
  order.is_deposit = is_deposit;
77
81
  }
@@ -2,6 +2,8 @@
2
2
  * 商品基本信息接口
3
3
  */
4
4
  export interface ProductData {
5
+ /** 商品数量 */
6
+ quantity?: number;
5
7
  /** 商品id */
6
8
  id: number;
7
9
  /** 商品所属账户id */
@@ -180,6 +182,8 @@ export interface ProductData {
180
182
  title: string;
181
183
  }>;
182
184
  };
185
+ /** 购物车行键,用于唯一标识购物车中的商品,用于相同 SKU商品合并 */
186
+ rowKey?: string;
183
187
  }
184
188
  /**
185
189
  * 商品媒体信息接口
@@ -0,0 +1,17 @@
1
+ import type { ProductData } from './types';
2
+ /**
3
+ * 传入单个商品信息,通过商品上是否有 duration 或者 schedule.ids 来判断是否是普通商品
4
+ *
5
+ * @export
6
+ * @param {ProductData} product
7
+ * @return {*} {boolean}
8
+ */
9
+ export declare function isNormalProduct(product: ProductData): boolean;
10
+ /**
11
+ * 传入多个商品信息,确定这些商品是否都是普通商品
12
+ *
13
+ * @export
14
+ * @param {ProductData[]} products
15
+ * @return {*} {boolean}
16
+ */
17
+ export declare function areAllNormalProducts(products: ProductData[]): boolean;
@@ -0,0 +1,46 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/modules/Product/utils.ts
20
+ var utils_exports = {};
21
+ __export(utils_exports, {
22
+ areAllNormalProducts: () => areAllNormalProducts,
23
+ isNormalProduct: () => isNormalProduct
24
+ });
25
+ module.exports = __toCommonJS(utils_exports);
26
+ function isNormalProduct(product) {
27
+ var _a;
28
+ if (product.duration) {
29
+ return false;
30
+ }
31
+ if ((_a = product["schedule.ids"]) == null ? void 0 : _a.length) {
32
+ return false;
33
+ }
34
+ return true;
35
+ }
36
+ function areAllNormalProducts(products) {
37
+ if (!products.length) {
38
+ return false;
39
+ }
40
+ return products.every((product) => isNormalProduct(product));
41
+ }
42
+ // Annotate the CommonJS export names for ESM import in node:
43
+ 0 && (module.exports = {
44
+ areAllNormalProducts,
45
+ isNormalProduct
46
+ });
@@ -171,6 +171,9 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
171
171
  }[]>;
172
172
  capacity?: number;
173
173
  }): {
174
+ selectedResource?: undefined;
175
+ timeSlots?: undefined;
176
+ } | {
174
177
  selectedResource: any;
175
178
  timeSlots?: undefined;
176
179
  } | {
@@ -210,7 +213,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
210
213
  }): void;
211
214
  setOtherData(key: string, value: any): void;
212
215
  getOtherData(key: string): any;
213
- getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
216
+ getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
214
217
  /**
215
218
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
216
219
  *
@@ -246,4 +249,8 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
246
249
  dateList: any;
247
250
  firstAvailableDate: any;
248
251
  }>;
252
+ isCartAllNormalProducts(): boolean;
253
+ isCartHasDurationProduct(): boolean;
254
+ isTargetNormalProduct(product: ProductData): boolean;
255
+ isTargetCartIdNormalProduct(id: string): boolean | undefined;
249
256
  }