@pisell/pisellos 0.0.44 → 0.0.46

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 (127) 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 +5 -5
  13. package/dist/modules/Cart/index.js +33 -19
  14. package/dist/modules/Cart/types.d.ts +21 -7
  15. package/dist/modules/Cart/utils.d.ts +29 -5
  16. package/dist/modules/Cart/utils.js +72 -26
  17. package/dist/modules/Date/index.d.ts +6 -6
  18. package/dist/modules/Date/index.js +41 -55
  19. package/dist/modules/Date/types.d.ts +22 -6
  20. package/dist/modules/Date/utils.d.ts +4 -3
  21. package/dist/modules/Date/utils.js +74 -23
  22. package/dist/modules/Discount/index.d.ts +4 -4
  23. package/dist/modules/Discount/index.js +11 -11
  24. package/dist/modules/Order/index.d.ts +10 -5
  25. package/dist/modules/Order/index.js +32 -16
  26. package/dist/modules/Order/types.d.ts +10 -3
  27. package/dist/modules/Product/index.d.ts +4 -1
  28. package/dist/modules/Product/index.js +22 -0
  29. package/dist/modules/Product/types.d.ts +7 -3
  30. package/dist/modules/ProductList/index.js +11 -5
  31. package/dist/modules/Resource/utils.js +1 -1
  32. package/dist/modules/Rules/index.d.ts +4 -4
  33. package/dist/modules/Rules/index.js +11 -11
  34. package/dist/modules/Rules/types.d.ts +1 -1
  35. package/dist/modules/Schedule/index.d.ts +8 -3
  36. package/dist/modules/Schedule/index.js +45 -5
  37. package/dist/modules/Schedule/type.d.ts +7 -7
  38. package/dist/modules/Schedule/types.d.ts +8 -8
  39. package/dist/modules/Schedule/utils.d.ts +9 -3
  40. package/dist/modules/Schedule/utils.js +77 -48
  41. package/dist/modules/Step/index.d.ts +14 -3
  42. package/dist/modules/Step/index.js +54 -2
  43. package/dist/modules/Summary/index.d.ts +5 -5
  44. package/dist/modules/Summary/index.js +7 -7
  45. package/dist/modules/Summary/types.d.ts +2 -2
  46. package/dist/modules/Summary/utils.d.ts +4 -4
  47. package/dist/modules/Summary/utils.js +3 -3
  48. package/dist/plugins/index.d.ts +3 -3
  49. package/dist/plugins/request.d.ts +3 -3
  50. package/dist/plugins/request.js +30 -30
  51. package/dist/plugins/shopStore.d.ts +1 -1
  52. package/dist/solution/BookingByStep/index.d.ts +71 -16
  53. package/dist/solution/BookingByStep/index.js +643 -227
  54. package/dist/solution/BookingByStep/types.d.ts +2 -2
  55. package/dist/solution/BookingByStep/types.js +9 -9
  56. package/dist/solution/BookingByStep/utils/products.d.ts +1 -1
  57. package/dist/solution/BookingByStep/utils/products.js +3 -0
  58. package/dist/solution/BookingByStep/utils/resources.d.ts +6 -5
  59. package/dist/solution/BookingByStep/utils/resources.js +37 -19
  60. package/dist/solution/ShopDiscount/index.d.ts +4 -4
  61. package/dist/solution/ShopDiscount/index.js +16 -16
  62. package/dist/solution/ShopDiscount/types.d.ts +2 -2
  63. package/dist/solution/ShopDiscount/utils.js +1 -1
  64. package/lib/core/index.js +7 -2
  65. package/lib/modules/Account/index.d.ts +2 -6
  66. package/lib/modules/Account/index.js +15 -30
  67. package/lib/modules/Account/types.d.ts +12 -1
  68. package/lib/modules/AccountList/index.d.ts +20 -1
  69. package/lib/modules/AccountList/index.js +122 -13
  70. package/lib/modules/AccountList/types.d.ts +33 -1
  71. package/lib/modules/AccountList/utils.d.ts +9 -0
  72. package/lib/modules/AccountList/utils.js +39 -0
  73. package/lib/modules/BaseModule.d.ts +2 -2
  74. package/lib/modules/BaseModule.js +14 -3
  75. package/lib/modules/Cart/index.d.ts +5 -5
  76. package/lib/modules/Cart/index.js +28 -6
  77. package/lib/modules/Cart/types.d.ts +21 -7
  78. package/lib/modules/Cart/utils.d.ts +29 -5
  79. package/lib/modules/Cart/utils.js +47 -3
  80. package/lib/modules/Date/index.d.ts +6 -6
  81. package/lib/modules/Date/index.js +6 -6
  82. package/lib/modules/Date/types.d.ts +22 -6
  83. package/lib/modules/Date/utils.d.ts +4 -3
  84. package/lib/modules/Date/utils.js +37 -6
  85. package/lib/modules/Discount/index.d.ts +4 -4
  86. package/lib/modules/Discount/index.js +9 -2
  87. package/lib/modules/Guests/index.js +4 -1
  88. package/lib/modules/Order/index.d.ts +10 -5
  89. package/lib/modules/Order/index.js +11 -1
  90. package/lib/modules/Order/types.d.ts +10 -3
  91. package/lib/modules/Payment/index.js +1 -6
  92. package/lib/modules/Product/index.d.ts +4 -1
  93. package/lib/modules/Product/index.js +16 -0
  94. package/lib/modules/Product/types.d.ts +7 -3
  95. package/lib/modules/ProductList/index.js +21 -7
  96. package/lib/modules/Resource/index.js +4 -1
  97. package/lib/modules/Resource/utils.js +7 -4
  98. package/lib/modules/Rules/index.d.ts +4 -4
  99. package/lib/modules/Rules/types.d.ts +1 -1
  100. package/lib/modules/Schedule/index.d.ts +8 -3
  101. package/lib/modules/Schedule/index.js +33 -2
  102. package/lib/modules/Schedule/type.d.ts +7 -7
  103. package/lib/modules/Schedule/types.d.ts +8 -8
  104. package/lib/modules/Schedule/utils.d.ts +9 -3
  105. package/lib/modules/Schedule/utils.js +32 -4
  106. package/lib/modules/Step/index.d.ts +14 -3
  107. package/lib/modules/Step/index.js +38 -1
  108. package/lib/modules/Summary/index.d.ts +5 -5
  109. package/lib/modules/Summary/types.d.ts +2 -2
  110. package/lib/modules/Summary/utils.d.ts +4 -4
  111. package/lib/plugins/index.d.ts +3 -3
  112. package/lib/plugins/request.d.ts +3 -3
  113. package/lib/plugins/request.js +48 -11
  114. package/lib/plugins/shopStore.d.ts +1 -1
  115. package/lib/solution/BookingByStep/index.d.ts +71 -16
  116. package/lib/solution/BookingByStep/index.js +396 -48
  117. package/lib/solution/BookingByStep/types.d.ts +2 -2
  118. package/lib/solution/BookingByStep/types.js +36 -9
  119. package/lib/solution/BookingByStep/utils/products.d.ts +1 -1
  120. package/lib/solution/BookingByStep/utils/products.js +3 -0
  121. package/lib/solution/BookingByStep/utils/resources.d.ts +6 -5
  122. package/lib/solution/BookingByStep/utils/resources.js +128 -58
  123. package/lib/solution/BuyTickets/index.js +34 -20
  124. package/lib/solution/ShopDiscount/index.d.ts +4 -4
  125. package/lib/solution/ShopDiscount/index.js +10 -2
  126. package/lib/solution/ShopDiscount/types.d.ts +2 -2
  127. package/package.json +4 -2
@@ -21,9 +21,9 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
21
21
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
22
22
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
23
23
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
24
- import { cloneDeep } from "lodash-es";
25
24
  import { BaseModule } from "../BaseModule";
26
- import { createCartItemOrigin, deleteResourceFromCartItem, deleteTimeFromCartItem, formatAccountToCartItem, formatDiscountToCartItem, formatNoteToCartItem, formatProductToCartItem, formatResourceToCartItem, getUniqueId } from "./utils";
25
+ import { createCartItemOrigin, deleteResourceFromCartItem, deleteTimeFromCartItem, formatAccountToCartItem, formatDateToCartItem, formatDiscountToCartItem, formatNoteToCartItem, formatProductToCartItem, formatResourceToCartItem, getUniqueId } from "./utils";
26
+ import { cloneDeep } from 'lodash-es';
27
27
  export * from "./types";
28
28
 
29
29
  /**
@@ -37,8 +37,8 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
37
37
  _classCallCheck(this, CartModule);
38
38
  _this = _super.call(this, name, version);
39
39
  // 提供给 baseModule 用的默认名称 和 默认版本
40
- _defineProperty(_assertThisInitialized(_this), "defaultName", "cart");
41
- _defineProperty(_assertThisInitialized(_this), "defaultVersion", "1.0.0");
40
+ _defineProperty(_assertThisInitialized(_this), "defaultName", 'cart');
41
+ _defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
42
42
  _defineProperty(_assertThisInitialized(_this), "request", void 0);
43
43
  _defineProperty(_assertThisInitialized(_this), "window", void 0);
44
44
  _defineProperty(_assertThisInitialized(_this), "store", void 0);
@@ -76,22 +76,22 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
76
76
  }
77
77
 
78
78
  // 获取依赖的插件
79
- this.request = core.getPlugin("request");
80
- this.window = core.getPlugin("window");
79
+ this.request = core.getPlugin('request');
80
+ this.window = core.getPlugin('window');
81
81
  if (this.request) {
82
82
  _context.next = 9;
83
83
  break;
84
84
  }
85
- throw new Error("购物车模块需要 request 插件支持");
85
+ throw new Error('购物车模块需要 request 插件支持');
86
86
  case 9:
87
87
  if (this.window) {
88
88
  _context.next = 11;
89
89
  break;
90
90
  }
91
- throw new Error("购物车模块需要 window 插件支持");
91
+ throw new Error('购物车模块需要 window 插件支持');
92
92
  case 11:
93
93
  // this.store.temp = {};
94
- console.log("[CartModule] 初始化完成");
94
+ console.log('[CartModule] 初始化完成');
95
95
  case 12:
96
96
  case "end":
97
97
  return _context.stop();
@@ -111,17 +111,18 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
111
111
  key: "addItem",
112
112
  value: (function () {
113
113
  var _addItem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
114
- var account, product, bundle, options, cartItem, items;
114
+ var account, product, bundle, options, date, cartItem, items;
115
115
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
116
116
  while (1) switch (_context2.prev = _context2.next) {
117
117
  case 0:
118
- account = params.account, product = params.product, bundle = params.bundle, options = params.options; // 生成一个唯一的 ID
118
+ account = params.account, product = params.product, bundle = params.bundle, options = params.options, date = params.date; // 生成一个唯一的 ID
119
119
  cartItem = {
120
120
  _id: getUniqueId(),
121
121
  _origin: createCartItemOrigin()
122
122
  };
123
123
  if (product) {
124
124
  cartItem._productOrigin = cloneDeep(product);
125
+ cartItem._productInit = cloneDeep(product);
125
126
  cartItem = formatProductToCartItem({
126
127
  cartItem: cartItem,
127
128
  product: product,
@@ -135,15 +136,21 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
135
136
  account: account
136
137
  });
137
138
  }
139
+ if (date) {
140
+ cartItem = formatDateToCartItem({
141
+ cartItem: cartItem,
142
+ date: date
143
+ });
144
+ }
138
145
 
139
146
  // 更新购物车数据
140
147
  items = [].concat(_toConsumableArray(this.store.list), [cartItem]);
141
148
  this.store.list = items;
142
149
 
143
150
  // 触发事件
144
- _context2.next = 8;
151
+ _context2.next = 9;
145
152
  return this.core.effects.emit("".concat(this.name, ":onAddItem"), cartItem);
146
- case 8:
153
+ case 9:
147
154
  case "end":
148
155
  return _context2.stop();
149
156
  }
@@ -184,7 +191,7 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
184
191
  case 8:
185
192
  _context3.prev = 8;
186
193
  _context3.t0 = _context3["catch"](0);
187
- console.error("[CartModule] 更新购物车商品失败", _context3.t0);
194
+ console.error('[CartModule] 更新购物车商品失败', _context3.t0);
188
195
  case 11:
189
196
  case "end":
190
197
  return _context3.stop();
@@ -209,12 +216,13 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
209
216
  product = params.product,
210
217
  discounts = params.discounts,
211
218
  resources = params.resources,
212
- note = params.note;
219
+ note = params.note,
220
+ date = params.date;
213
221
  var tempCartItem = this.store.list.find(function (i) {
214
222
  return i._id === _id;
215
223
  });
216
224
  if (!tempCartItem) {
217
- throw new Error("[CartModule] 格式化数据到购物车失败,商品不存在");
225
+ throw new Error('[CartModule] 格式化数据到购物车失败,商品不存在');
218
226
  }
219
227
  if (cartItem) {
220
228
  tempCartItem = cartItem;
@@ -244,6 +252,12 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
244
252
  resources: resources
245
253
  });
246
254
  }
255
+ if (date) {
256
+ tempCartItem = formatDateToCartItem({
257
+ cartItem: tempCartItem,
258
+ date: date
259
+ });
260
+ }
247
261
  if (note) {
248
262
  tempCartItem = formatNoteToCartItem({
249
263
  cartItem: tempCartItem,
@@ -356,9 +370,9 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
356
370
  value: function deleteCartItemInfo(types) {
357
371
  var list = this.store.list.map(function (item) {
358
372
  // 清除购物车商品中的资源信息
359
- if (types === "resource") {
373
+ if (types === 'resource') {
360
374
  item = deleteResourceFromCartItem(item);
361
- } else if (types === "time") {
375
+ } else if (types === 'time') {
362
376
  // 清除购物车商品中的时间信息
363
377
  item = deleteTimeFromCartItem(item);
364
378
  }
@@ -390,7 +404,7 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
390
404
  cacheId: this.cacheId,
391
405
  fatherModule: this.fatherModule,
392
406
  store: store,
393
- cacheKey: ["list"]
407
+ cacheKey: ['list']
394
408
  });
395
409
  }
396
410
  }
@@ -1,6 +1,6 @@
1
- import { ProductData } from "../Product/types";
2
- import { Account } from "../Account/types";
3
- import { Resource } from "../Resource/types";
1
+ import { ProductData } from '../Product/types';
2
+ import { Account } from '../Account/types';
3
+ import { Resource } from '../Resource/types';
4
4
  export declare enum CartHooks {
5
5
  OnAddItem = "card:onAddItem",
6
6
  OnCartChange = "card:onCartChange",
@@ -57,7 +57,7 @@ export interface CartItem {
57
57
  /** 备注 */
58
58
  note?: string;
59
59
  /** 点赞状态 */
60
- like_status?: "like" | "common";
60
+ like_status?: 'like' | 'common';
61
61
  /** 用户名称 */
62
62
  holder_title?: string;
63
63
  /** 用户ID */
@@ -96,16 +96,16 @@ export interface CartItem {
96
96
  title: string;
97
97
  }[];
98
98
  } | null;
99
- /** 原始数据 */
99
+ /** 接口原始数据 */
100
100
  _origin: any;
101
+ /** 商品加入购物车时初始数据 */
102
+ _productInit?: ProductData;
101
103
  /** 商品原始数据 */
102
104
  _productOrigin?: ProductData;
103
105
  /** 资源原始数据 */
104
106
  _resourceOrigin?: Resource[];
105
107
  /** 容量 */
106
108
  capacity?: any;
107
- /** 商品套餐 */
108
- product_bundle?: any;
109
109
  }
110
110
  /**
111
111
  * 购物车状态接口
@@ -127,6 +127,13 @@ export interface IAddItemParams {
127
127
  bundle?: any[];
128
128
  /** 商品规格信息 */
129
129
  options?: any[];
130
+ /** 日期 */
131
+ date?: {
132
+ /** 开始时间 */
133
+ startTime: string;
134
+ /** 结束时间 */
135
+ endTime: string;
136
+ };
130
137
  }
131
138
  /**
132
139
  * 更新购物车信息参数
@@ -148,6 +155,13 @@ export interface IUpdateItemParams {
148
155
  resources?: Resource[];
149
156
  /** 备注 */
150
157
  note?: string;
158
+ /** 日期 */
159
+ date?: {
160
+ /** 开始时间 */
161
+ startTime: string;
162
+ /** 结束时间 */
163
+ endTime: string;
164
+ };
151
165
  }
152
166
  /**
153
167
  * 折扣
@@ -1,8 +1,8 @@
1
- import { Account } from "../Account";
2
- import { ProductData } from "../Product/types";
3
- import { Resource } from "../Resource/types";
4
- import { CartItem, IDiscount } from "./types";
5
- import Decimal from "decimal.js";
1
+ import { Account } from '../Account';
2
+ import { ProductData } from '../Product/types';
3
+ import { Resource } from '../Resource/types';
4
+ import { CartItem, IDiscount } from './types';
5
+ import Decimal from 'decimal.js';
6
6
  /**
7
7
  * 生成一个唯一的 ID
8
8
  */
@@ -90,6 +90,30 @@ export declare const formatResourceToCartItemOrigin: (params: {
90
90
  cartItem: CartItem;
91
91
  resources: Resource[];
92
92
  }) => any;
93
+ /**
94
+ * 格式化日期到购物车
95
+ * @param date 开始时间和结束时间
96
+ * @returns 格式化后的日期
97
+ */
98
+ export declare const formatDateToCartItem: (params: {
99
+ cartItem: CartItem;
100
+ date: {
101
+ startTime: string;
102
+ endTime: string;
103
+ };
104
+ }) => CartItem;
105
+ /**
106
+ * 格式化日期到购物车原始数据
107
+ * @param date 开始时间和结束时间
108
+ * @returns 格式化后的日期原始数据
109
+ */
110
+ export declare const formatDateToCartItemOrigin: (params: {
111
+ cartItem: CartItem;
112
+ date: {
113
+ startTime: string;
114
+ endTime: string;
115
+ };
116
+ }) => any;
93
117
  /**
94
118
  * 从购物车中删除资源相关信息
95
119
  * @param cartItem 购物车
@@ -10,16 +10,16 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
10
10
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
11
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
12
12
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
13
- import dayjs from "dayjs";
14
- import Decimal from "decimal.js";
13
+ import dayjs from 'dayjs';
14
+ import Decimal from 'decimal.js';
15
15
 
16
16
  /**
17
17
  * 生成一个唯一的 ID
18
18
  */
19
19
  export var getUniqueId = function getUniqueId() {
20
- var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
20
+ var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
21
21
  var maxLength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 11;
22
- return prefix + (Math.random() + "").replace(/\D/g, "").substring(0, maxLength);
22
+ return prefix + (Math.random() + '').replace(/\D/g, '').substring(0, maxLength);
23
23
  };
24
24
 
25
25
  /**
@@ -32,7 +32,7 @@ export var createCartItemOrigin = function createCartItemOrigin() {
32
32
  // 数量 固定为1
33
33
  number: 1,
34
34
  // 客户端报名所有活动;
35
- registration_type: "all",
35
+ registration_type: 'all',
36
36
  // 暂时不用
37
37
  relation_products: [],
38
38
  // 固定
@@ -45,7 +45,7 @@ export var createCartItemOrigin = function createCartItemOrigin() {
45
45
  duration: null,
46
46
  // 资源相关
47
47
  // 资源状态 -固定
48
- like_status: "common",
48
+ like_status: 'common',
49
49
  // 资源类型 - 固定--谭景琳备注:马天宇说现在平行资源是不传这个的
50
50
  // relation_type: "form",
51
51
  // 所选资源
@@ -100,7 +100,7 @@ export var formatProductToCartItem = function formatProductToCartItem(params) {
100
100
  num: num
101
101
  });
102
102
  cartItem.image = product === null || product === void 0 ? void 0 : product.cover;
103
- cartItem.like_status = "common";
103
+ cartItem.like_status = 'common';
104
104
  cartItem.duration = product === null || product === void 0 ? void 0 : product.duration;
105
105
  cartItem.isNormalProduct = isNormalProduct(product);
106
106
  cartItem.is_charge_tax = product === null || product === void 0 ? void 0 : product.is_charge_tax;
@@ -206,7 +206,19 @@ export var formatAccountToCartItemOrigin = function formatAccountToCartItemOrigi
206
206
  account = params.account;
207
207
  var origin = cartItem._origin;
208
208
  if (account) {
209
- origin.metadata.account = account;
209
+ if ((account === null || account === void 0 ? void 0 : account.type) === 'holder') {
210
+ var _ref = (account === null || account === void 0 ? void 0 : account._origin) || {},
211
+ customer_id = _ref.customer_id,
212
+ form_id = _ref.form_id,
213
+ form_record_id = _ref.form_record_id;
214
+ origin.holder = {
215
+ customer_id: customer_id,
216
+ form_id: form_id,
217
+ form_record: form_record_id ? [form_record_id] : null
218
+ };
219
+ } else {
220
+ origin.metadata.account = account;
221
+ }
210
222
  }
211
223
  return origin;
212
224
  };
@@ -224,10 +236,10 @@ export var formatResourceToCartItem = function formatResourceToCartItem(params)
224
236
  cartItem.resource_id = firstResource === null || firstResource === void 0 ? void 0 : firstResource.id;
225
237
  cartItem.relation_form_name = firstResource === null || firstResource === void 0 ? void 0 : firstResource.main_field;
226
238
  if (firstResource.startTime && firstResource.endTime) {
227
- cartItem.start_date = dayjs(firstResource.startTime).format("YYYY-MM-DD");
228
- cartItem.start_time = dayjs(firstResource.startTime).format("HH:mm");
229
- cartItem.end_date = dayjs(firstResource.endTime).format("YYYY-MM-DD");
230
- cartItem.end_time = dayjs(firstResource.endTime).format("HH:mm");
239
+ cartItem.start_date = dayjs(firstResource.startTime).format('YYYY-MM-DD');
240
+ cartItem.start_time = dayjs(firstResource.startTime).format('HH:mm');
241
+ cartItem.end_date = dayjs(firstResource.endTime).format('YYYY-MM-DD');
242
+ cartItem.end_time = dayjs(firstResource.endTime).format('HH:mm');
231
243
  }
232
244
  } else {
233
245
  cartItem.resource_id = undefined;
@@ -257,8 +269,8 @@ export var formatResourceToCartItemOrigin = function formatResourceToCartItemOri
257
269
  checkResourcesFormat(resource.children, childArr);
258
270
  }
259
271
  var obj = {
260
- relation_type: "form",
261
- like_status: "common",
272
+ relation_type: 'form',
273
+ like_status: 'common',
262
274
  id: resource.id,
263
275
  main_field: resource.main_field,
264
276
  resourceType: resource.resourceType,
@@ -278,11 +290,11 @@ export var formatResourceToCartItemOrigin = function formatResourceToCartItemOri
278
290
  startTime = _resources$.startTime,
279
291
  endTime = _resources$.endTime;
280
292
  if (startTime && endTime) {
281
- origin.select_date = dayjs(startTime).format("YYYY-MM-DD");
282
- origin.start_date = dayjs(startTime).format("YYYY-MM-DD");
283
- origin.start_time = dayjs(startTime).format("HH:mm");
284
- origin.end_date = dayjs(endTime).format("YYYY-MM-DD");
285
- origin.end_time = dayjs(endTime).format("HH:mm");
293
+ origin.select_date = dayjs(startTime).format('YYYY-MM-DD');
294
+ origin.start_date = dayjs(startTime).format('YYYY-MM-DD');
295
+ origin.start_time = dayjs(startTime).format('HH:mm');
296
+ origin.end_date = dayjs(endTime).format('YYYY-MM-DD');
297
+ origin.end_time = dayjs(endTime).format('HH:mm');
286
298
  }
287
299
  } else if ((resources === null || resources === void 0 ? void 0 : resources.length) === 0) {
288
300
  origin.resources = [];
@@ -295,6 +307,40 @@ export var formatResourceToCartItemOrigin = function formatResourceToCartItemOri
295
307
  return origin;
296
308
  };
297
309
 
310
+ /**
311
+ * 格式化日期到购物车
312
+ * @param date 开始时间和结束时间
313
+ * @returns 格式化后的日期
314
+ */
315
+ export var formatDateToCartItem = function formatDateToCartItem(params) {
316
+ var cartItem = params.cartItem,
317
+ date = params.date;
318
+ cartItem.start_date = dayjs(date.startTime).format('YYYY-MM-DD');
319
+ cartItem.start_time = dayjs(date.startTime).format('HH:mm');
320
+ cartItem.end_date = dayjs(date.endTime).format('YYYY-MM-DD');
321
+ cartItem.end_time = dayjs(date.endTime).format('HH:mm');
322
+ var oringin = formatDateToCartItemOrigin(params);
323
+ cartItem._origin = oringin;
324
+ return cartItem;
325
+ };
326
+
327
+ /**
328
+ * 格式化日期到购物车原始数据
329
+ * @param date 开始时间和结束时间
330
+ * @returns 格式化后的日期原始数据
331
+ */
332
+ export var formatDateToCartItemOrigin = function formatDateToCartItemOrigin(params) {
333
+ var cartItem = params.cartItem,
334
+ date = params.date;
335
+ var origin = cartItem._origin;
336
+ origin.select_date = dayjs(date.startTime).format('YYYY-MM-DD');
337
+ origin.start_date = dayjs(date.startTime).format('YYYY-MM-DD');
338
+ origin.start_time = dayjs(date.startTime).format('HH:mm');
339
+ origin.end_date = dayjs(date.endTime).format('YYYY-MM-DD');
340
+ origin.end_time = dayjs(date.endTime).format('HH:mm');
341
+ return origin;
342
+ };
343
+
298
344
  /**
299
345
  * 从购物车中删除资源相关信息
300
346
  * @param cartItem 购物车
@@ -447,7 +493,7 @@ export var formatBundleToOrigin = function formatBundleToOrigin(bundle) {
447
493
  * @returns 是否是普通商品
448
494
  */
449
495
  export var isNormalProduct = function isNormalProduct(product) {
450
- return (product === null || product === void 0 ? void 0 : product.extension_type) !== "product_appointment";
496
+ return (product === null || product === void 0 ? void 0 : product.extension_type) !== 'product_appointment';
451
497
  };
452
498
 
453
499
  /**
@@ -528,14 +574,14 @@ export var getProductDeposit = function getProductDeposit(params) {
528
574
  if ((product === null || product === void 0 || (_product$custom_depos2 = product.custom_deposit_data) === null || _product$custom_depos2 === void 0 ? void 0 : _product$custom_depos2.has_deposit) == 1) {
529
575
  var protocols = [];
530
576
  var total = new Decimal(0);
531
- var _ref = (product === null || product === void 0 ? void 0 : product.custom_deposit_data) || {},
532
- deposit_fixed = _ref.deposit_fixed,
533
- deposit_percentage = _ref.deposit_percentage,
534
- deposit_policy_data = _ref.deposit_policy_data;
577
+ var _ref2 = (product === null || product === void 0 ? void 0 : product.custom_deposit_data) || {},
578
+ deposit_fixed = _ref2.deposit_fixed,
579
+ deposit_percentage = _ref2.deposit_percentage,
580
+ deposit_policy_data = _ref2.deposit_policy_data;
535
581
  // 协议数据
536
582
  protocols.push.apply(protocols, _toConsumableArray(deposit_policy_data || []));
537
583
  // 判断主商品是否有定金规则
538
- if (typeof deposit_fixed === "string" && typeof deposit_percentage === "string") {
584
+ if (typeof deposit_fixed === 'string' && typeof deposit_percentage === 'string') {
539
585
  var _handleProductDeposit = handleProductDeposit({
540
586
  depositData: product === null || product === void 0 ? void 0 : product.custom_deposit_data,
541
587
  total: cartItem.total || 0,
@@ -582,7 +628,7 @@ export var handleProductDeposit = function handleProductDeposit(params) {
582
628
  num = params.num;
583
629
  var deposit_fixed = depositData.deposit_fixed,
584
630
  deposit_percentage = depositData.deposit_percentage;
585
- if (typeof deposit_fixed === "string" && typeof deposit_percentage === "string") {
631
+ if (typeof deposit_fixed === 'string' && typeof deposit_percentage === 'string') {
586
632
  var depositFixed = Decimal(deposit_fixed || 0);
587
633
  var depositPercent = Decimal(deposit_percentage || 0);
588
634
  var productTotalPrice = Decimal(total || 0);
@@ -1,6 +1,6 @@
1
- import { Module, PisellCore, ModuleOptions } from "../../types";
2
- import { BaseModule } from "../BaseModule";
3
- import { DateModuleAPI, IGetAvailableTimeListParams, ITime } from "./types";
1
+ import { Module, PisellCore, ModuleOptions } from '../../types';
2
+ import { BaseModule } from '../BaseModule';
3
+ import { DateModuleAPI, IGetAvailableTimeListParams, ITime } from './types';
4
4
  export declare class DateModule extends BaseModule implements Module, DateModuleAPI {
5
5
  protected defaultName: string;
6
6
  protected defaultVersion: string;
@@ -13,9 +13,9 @@ export declare class DateModule extends BaseModule implements Module, DateModule
13
13
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
14
14
  setDateRange(dateRange: ITime[]): void;
15
15
  getDateRange(): ITime[];
16
- getMonthDates(params: IGetAvailableTimeListParams): Promise<ITime[]>;
17
- getDateList(): Promise<ITime[]>;
18
- getAvailableTimeList(params: IGetAvailableTimeListParams): Promise<ITime[]>;
16
+ getResourceDates(params: IGetAvailableTimeListParams): Promise<ITime[]>;
17
+ getDateList(): ITime[];
18
+ getResourceAvailableTimeList(params: IGetAvailableTimeListParams): Promise<ITime[]>;
19
19
  clearDateRange(): void;
20
20
  storeChange(): void;
21
21
  }