@pisell/pisellos 3.0.35 → 3.0.37

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 (53) 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/Discount/index.js +2 -2
  19. package/dist/modules/Order/index.js +10 -4
  20. package/dist/modules/Product/types.d.ts +4 -0
  21. package/dist/modules/Product/utils.d.ts +17 -0
  22. package/dist/modules/Product/utils.js +41 -0
  23. package/dist/solution/BookingByStep/index.d.ts +8 -1
  24. package/dist/solution/BookingByStep/index.js +212 -78
  25. package/dist/solution/ShopDiscount/index.js +5 -4
  26. package/lib/modules/Cart/index.js +16 -24
  27. package/lib/modules/Cart/utils/cartAccount.d.ts +21 -0
  28. package/lib/modules/Cart/utils/cartAccount.js +65 -0
  29. package/lib/modules/Cart/utils/cartDate.d.ts +31 -0
  30. package/lib/modules/Cart/utils/cartDate.js +75 -0
  31. package/lib/modules/Cart/utils/cartDiscount.d.ts +19 -0
  32. package/lib/modules/Cart/utils/cartDiscount.js +52 -0
  33. package/lib/modules/Cart/utils/cartNote.d.ts +19 -0
  34. package/lib/modules/Cart/utils/cartNote.js +46 -0
  35. package/lib/modules/Cart/utils/cartProduct.d.ts +107 -0
  36. package/lib/modules/Cart/{utils.js → utils/cartProduct.js} +78 -328
  37. package/lib/modules/Cart/utils/cartRelationForms.d.ts +26 -0
  38. package/lib/modules/Cart/utils/cartRelationForms.js +48 -0
  39. package/lib/modules/Cart/utils/cartResource.d.ts +21 -0
  40. package/lib/modules/Cart/utils/cartResource.js +124 -0
  41. package/lib/modules/Cart/utils/index.d.ts +34 -0
  42. package/lib/modules/Cart/utils/index.js +91 -0
  43. package/lib/modules/Discount/index.js +3 -7
  44. package/lib/modules/Order/index.js +7 -3
  45. package/lib/modules/Product/types.d.ts +4 -0
  46. package/lib/modules/Product/utils.d.ts +17 -0
  47. package/lib/modules/Product/utils.js +46 -0
  48. package/lib/solution/BookingByStep/index.d.ts +8 -1
  49. package/lib/solution/BookingByStep/index.js +117 -47
  50. package/lib/solution/ShopDiscount/index.js +5 -9
  51. package/package.json +3 -3
  52. package/dist/modules/Cart/utils.d.ts +0 -257
  53. package/lib/modules/Cart/utils.d.ts +0 -257
@@ -10,63 +10,29 @@ 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
13
  import Decimal from 'decimal.js';
14
+ import { isNormalProduct } from "../../Product/utils";
15
15
 
16
16
  /**
17
- * 生成一个唯一的 ID
18
- */
19
- export var getUniqueId = function getUniqueId() {
20
- var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
21
- var maxLength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 11;
22
- return prefix + (Math.random() + '').replace(/\D/g, '').substring(0, maxLength);
23
- };
24
-
25
- /**
26
- * 创建购物车原始数据
17
+ * @title 处理组合商品
18
+ * @description 组合商品需要直接修改 product 里的价格和 is_charge_tax
19
+ * @param product 商品
20
+ * @returns 处理后的商品
27
21
  */
28
- export var createCartItemOrigin = function createCartItemOrigin() {
29
- return {
30
- // 新增为0
31
- id: 0,
32
- // 数量 固定为1
33
- number: 1,
34
- // 客户端报名所有活动;
35
- registration_type: 'all',
36
- // 暂时不用
37
- relation_products: [],
38
- // 固定
39
- is_all: false,
40
- // 商品相关
41
- product: null,
42
- // 时长类型
43
- sub_type: null,
44
- // 时长
45
- duration: null,
46
- // 资源相关
47
- // 资源状态 -固定
48
- like_status: 'common',
49
- // 资源类型 - 固定--谭景琳备注:马天宇说现在平行资源是不传这个的
50
- // relation_type: "form",
51
- // 所选资源
52
- resources: null,
53
- // 日程id - 固定
54
- schedule_id: 0,
55
- // 所选开始时间
56
- start_date: null,
57
- // 所选开始时间
58
- start_time: null,
59
- // 所选开始时间
60
- select_date: null,
61
- // 所选结束时间
62
- end_time: null,
63
- // 所选结束时间
64
- end_date: null,
65
- // 额外信息
66
- metadata: {},
67
- // holder相关
68
- holder: null
69
- };
22
+ export var handleVariantProduct = function handleVariantProduct(product) {
23
+ // 判断组合商品,然后直接修改 product 里的价格和 is_charge_tax
24
+ if (product !== null && product !== void 0 && product.product_variant_id) {
25
+ // 还需要判断 能从 variant 里找到对应的组合规格信息,才可以替换
26
+ var targetVariant = product.variant.find(function (n) {
27
+ return n.id === product.product_variant_id;
28
+ });
29
+ if (targetVariant) {
30
+ product.price = targetVariant.price;
31
+ product.original_price = targetVariant.original_price;
32
+ product.is_charge_tax = targetVariant.is_charge_tax;
33
+ }
34
+ }
35
+ return product;
70
36
  };
71
37
 
72
38
  /**
@@ -80,8 +46,10 @@ export var formatProductToCartItem = function formatProductToCartItem(params) {
80
46
  product = params.product,
81
47
  bundle = params.bundle,
82
48
  options = params.options,
83
- product_variant_id = params.product_variant_id;
84
- var num = 1; // 当前按照单个商品加入购物车
49
+ product_variant_id = params.product_variant_id,
50
+ _params$quantity = params.quantity,
51
+ quantity = _params$quantity === void 0 ? 1 : _params$quantity;
52
+ var num = quantity; // 当前按照单个商品加入购物车
85
53
  if (product) {
86
54
  cartItem.id = product === null || product === void 0 ? void 0 : product.id;
87
55
  cartItem.name = product === null || product === void 0 ? void 0 : product.title;
@@ -156,12 +124,14 @@ export var formatProductToCartItemOrigin = function formatProductToCartItemOrigi
156
124
  product = params.product,
157
125
  bundle = params.bundle,
158
126
  options = params.options,
159
- product_variant_id = params.product_variant_id;
127
+ product_variant_id = params.product_variant_id,
128
+ _params$quantity2 = params.quantity,
129
+ quantity = _params$quantity2 === void 0 ? 1 : _params$quantity2;
160
130
  var origin = cartItem._origin;
161
131
  if (product) {
162
132
  var _origin$product, _origin$product2, _product$duration, _product$duration2;
163
133
  origin.product = _objectSpread(_objectSpread({}, origin.product || {}), {}, {
164
- num: 1,
134
+ num: quantity,
165
135
  product_id: product.id,
166
136
  product_variant_id: product_variant_id || 0,
167
137
  product_bundle: ((_origin$product = origin.product) === null || _origin$product === void 0 ? void 0 : _origin$product.product_bundle) || [],
@@ -182,244 +152,60 @@ export var formatProductToCartItemOrigin = function formatProductToCartItemOrigi
182
152
  };
183
153
 
184
154
  /**
185
- * 格式化折扣到购物车
186
- * @param params 参数
187
- * @returns 格式化后的购物车
188
- */
189
- export var formatDiscountToCartItem = function formatDiscountToCartItem(params) {
190
- var cartItem = params.cartItem;
191
- var oringin = formatDiscountToCartItemOrigin(params);
192
- cartItem._origin = oringin;
193
- return cartItem;
194
- };
195
-
196
- /**
197
- * 格式化折扣到购物车原始数据
198
- * @param params 参数
199
- * @returns 格式化后的购物车原始数据
155
+ * 获取商品总价
156
+ * @description 当前总价计算基于商品数量为1
157
+ * @param item 商品
158
+ * @returns 商品总价
200
159
  */
201
- export var formatDiscountToCartItemOrigin = function formatDiscountToCartItemOrigin(params) {
202
- var cartItem = params.cartItem,
203
- discounts = params.discounts;
204
- var origin = cartItem._origin;
205
- if (discounts && discounts !== null && discounts !== void 0 && discounts.length) {
206
- if (!origin.product) {
207
- origin.product = {};
208
- }
209
- origin.product.discount_list = discounts;
210
- } else {
211
- // 如果折扣为空,则清空折扣列表
212
- if (!origin.product) {
213
- origin.product = {};
214
- }
215
- origin.product.discount_list = [];
160
+ export var getProductTotalPrice = function getProductTotalPrice(params) {
161
+ var product = params.product,
162
+ bundle = params.bundle,
163
+ options = params.options;
164
+ var num = params.num || 1;
165
+ var price = Number(product.price);
166
+ if (bundle !== null && bundle !== void 0 && bundle.length) {
167
+ price = bundle.reduce(function (accumulator, currentValue) {
168
+ return accumulator + Number(currentValue.price) * Number(currentValue.num);
169
+ }, price);
216
170
  }
217
- return origin;
218
- };
219
171
 
220
- /**
221
- * 格式化账户到购物车
222
- * @param account 账户
223
- * @returns 格式化后的账户
224
- */
225
- export var formatAccountToCartItem = function formatAccountToCartItem(params) {
226
- var cartItem = params.cartItem,
227
- account = params.account;
228
- if (account) {
229
- cartItem.holder_id = account.id;
230
- cartItem.holder_title = account.username;
231
- }
232
- var oringin = formatAccountToCartItemOrigin(params);
233
- cartItem._origin = oringin;
234
- return cartItem;
235
- };
236
- export var formatAccountToCartItemOrigin = function formatAccountToCartItemOrigin(params) {
237
- var cartItem = params.cartItem,
238
- account = params.account;
239
- var origin = cartItem._origin;
240
- if (account) {
241
- if ((account === null || account === void 0 ? void 0 : account.type) === 'holder') {
242
- var _ref = (account === null || account === void 0 ? void 0 : account._origin) || {},
243
- customer_id = _ref.customer_id,
244
- form_id = _ref.form_id,
245
- form_record_id = _ref.form_record_id;
246
- origin.holder = {
247
- customer_id: customer_id,
248
- form_id: form_id,
249
- form_record: form_record_id ? [form_record_id] : null
250
- };
251
- } else {
252
- origin.metadata.account = account;
253
- }
172
+ // 单规格
173
+ if (options !== null && options !== void 0 && options.length) {
174
+ price = options.reduce(function (accumulator, currentValue) {
175
+ return accumulator + Number(currentValue.price) * Number(currentValue.num);
176
+ }, price);
254
177
  }
255
- return origin;
178
+ return price * num;
256
179
  };
257
180
 
258
181
  /**
259
- * 格式化资源到购物车
260
- * @param resource 资源
261
- * @returns 格式化后的资源
182
+ * 获取商品原始总价
183
+ * @description 当前总价计算基于商品数量为1
184
+ * @param item 商品
185
+ * @returns 商品原始总价
262
186
  */
263
- export var formatResourceToCartItem = function formatResourceToCartItem(params) {
264
- var cartItem = params.cartItem,
265
- resources = params.resources;
266
- if (resources && resources !== null && resources !== void 0 && resources.length) {
267
- var firstResource = resources[0];
268
- cartItem.resource_id = firstResource === null || firstResource === void 0 ? void 0 : firstResource.id;
269
- cartItem.relation_form_name = firstResource === null || firstResource === void 0 ? void 0 : firstResource.main_field;
270
- if (firstResource.startTime && firstResource.endTime) {
271
- cartItem.start_date = dayjs(firstResource.startTime).format('YYYY-MM-DD');
272
- cartItem.start_time = dayjs(firstResource.startTime).format('HH:mm');
273
- cartItem.end_date = dayjs(firstResource.endTime).format('YYYY-MM-DD');
274
- cartItem.end_time = dayjs(firstResource.endTime).format('HH:mm');
275
- }
276
- } else {
277
- cartItem.resource_id = undefined;
278
- cartItem.relation_form_name = undefined;
279
- cartItem.start_date = undefined;
280
- cartItem.start_time = undefined;
281
- cartItem.end_date = undefined;
282
- cartItem.end_time = undefined;
187
+ export var getProductOriginTotalPrice = function getProductOriginTotalPrice(params) {
188
+ var product = params.product,
189
+ bundle = params.bundle,
190
+ options = params.options;
191
+ var num = (params === null || params === void 0 ? void 0 : params.num) || 1;
192
+ var price = Number(product.original_price);
193
+ if (isNaN(price) || price === 0) {
194
+ return undefined;
283
195
  }
284
- var oringin = formatResourceToCartItemOrigin(params);
285
- cartItem._origin = oringin;
286
- cartItem._resourceOrigin = resources;
287
- return cartItem;
288
- };
289
- export var formatResourceToCartItemOrigin = function formatResourceToCartItemOrigin(params) {
290
- var cartItem = params.cartItem,
291
- resources = params.resources;
292
- var origin = cartItem._origin;
293
- if (resources && resources !== null && resources !== void 0 && resources.length) {
294
- origin.resources = [];
295
- // 接口只需要部分字段,需要处理
296
- var checkResourcesFormat = function checkResourcesFormat(resources, arr) {
297
- resources.forEach(function (resource) {
298
- var _resource$children;
299
- var childArr = [];
300
- if (resource !== null && resource !== void 0 && (_resource$children = resource.children) !== null && _resource$children !== void 0 && _resource$children.length) {
301
- checkResourcesFormat(resource.children, childArr);
302
- }
303
- var obj = {
304
- relation_type: 'form',
305
- like_status: 'common',
306
- id: resource.id,
307
- main_field: resource.main_field,
308
- resourceType: resource.resourceType,
309
- form_id: resource.form_id,
310
- relation_id: resource.id,
311
- capacity: (resource === null || resource === void 0 ? void 0 : resource.capacity) || 0,
312
- metadata: (resource === null || resource === void 0 ? void 0 : resource.metadata) || {} // 后端可以在这里挂一个前端用于计算的数据
313
- };
314
- if (childArr.length) {
315
- obj.children = childArr;
316
- }
317
- arr.push(obj);
318
- });
319
- };
320
- checkResourcesFormat(resources, origin.resources);
321
- var _resources$ = resources[0],
322
- startTime = _resources$.startTime,
323
- endTime = _resources$.endTime;
324
- if (startTime && endTime) {
325
- origin.select_date = dayjs(startTime).format('YYYY-MM-DD');
326
- origin.start_date = dayjs(startTime).format('YYYY-MM-DD');
327
- origin.start_time = dayjs(startTime).format('HH:mm');
328
- origin.end_date = dayjs(endTime).format('YYYY-MM-DD');
329
- origin.end_time = dayjs(endTime).format('HH:mm');
330
- }
331
- } else if ((resources === null || resources === void 0 ? void 0 : resources.length) === 0) {
332
- origin.resources = [];
333
- origin.select_date = null;
334
- origin.start_date = null;
335
- origin.start_time = null;
336
- origin.end_date = null;
337
- origin.end_time = null;
196
+ if (bundle !== null && bundle !== void 0 && bundle.length) {
197
+ price = bundle.reduce(function (accumulator, currentValue) {
198
+ return accumulator + Number(currentValue.price) * Number(currentValue.num);
199
+ }, price);
338
200
  }
339
- return origin;
340
- };
341
201
 
342
- /**
343
- * 格式化关联表单到购物车
344
- * @param params 参数
345
- * @returns 格式化后的购物车
346
- */
347
- export var formatRelationFormsToCartItem = function formatRelationFormsToCartItem(params) {
348
- var cartItem = params.cartItem;
349
- var oringin = formatRelationFormsToCartItemOrigin(params);
350
- cartItem._origin = oringin;
351
- return cartItem;
352
- };
353
- export var formatRelationFormsToCartItemOrigin = function formatRelationFormsToCartItemOrigin(params) {
354
- var cartItem = params.cartItem,
355
- relationForms = params.relationForms;
356
- var origin = cartItem._origin;
357
- origin.relation_forms = relationForms;
358
- return origin;
359
- };
360
-
361
- /**
362
- * 格式化日期到购物车
363
- * @param date 开始时间和结束时间
364
- * @returns 格式化后的日期
365
- */
366
- export var formatDateToCartItem = function formatDateToCartItem(params) {
367
- var cartItem = params.cartItem,
368
- date = params.date;
369
- cartItem.start_date = dayjs(date.startTime).format('YYYY-MM-DD');
370
- cartItem.start_time = dayjs(date.startTime).format('HH:mm');
371
- cartItem.end_date = dayjs(date.endTime).format('YYYY-MM-DD');
372
- cartItem.end_time = dayjs(date.endTime).format('HH:mm');
373
- var oringin = formatDateToCartItemOrigin(params);
374
- cartItem._origin = oringin;
375
- return cartItem;
376
- };
377
-
378
- /**
379
- * 格式化日期到购物车原始数据
380
- * @param date 开始时间和结束时间
381
- * @returns 格式化后的日期原始数据
382
- */
383
- export var formatDateToCartItemOrigin = function formatDateToCartItemOrigin(params) {
384
- var cartItem = params.cartItem,
385
- date = params.date;
386
- var origin = cartItem._origin;
387
- origin.select_date = dayjs(date.startTime).format('YYYY-MM-DD');
388
- origin.start_date = dayjs(date.startTime).format('YYYY-MM-DD');
389
- origin.start_time = dayjs(date.startTime).format('HH:mm');
390
- origin.end_date = dayjs(date.endTime).format('YYYY-MM-DD');
391
- origin.end_time = dayjs(date.endTime).format('HH:mm');
392
- return origin;
393
- };
394
-
395
- /**
396
- * 格式化备注到购物车
397
- * @param params 参数
398
- * @returns 格式化后的购物车
399
- */
400
- export var formatNoteToCartItem = function formatNoteToCartItem(params) {
401
- var cartItem = params.cartItem,
402
- note = params.note;
403
- cartItem.note = note;
404
- var oringin = formatNoteToCartItemOrigin(params);
405
- cartItem._origin = oringin;
406
- return cartItem;
407
- };
408
-
409
- /**
410
- * 格式化备注到购物车原始数据
411
- * @param params 参数
412
- * @returns 格式化后的购物车原始数据
413
- */
414
- export var formatNoteToCartItemOrigin = function formatNoteToCartItemOrigin(params) {
415
- var cartItem = params.cartItem,
416
- note = params.note;
417
- var origin = cartItem._origin;
418
- if (!origin.product) {
419
- origin.product = {};
202
+ // 单规格
203
+ if (options !== null && options !== void 0 && options.length) {
204
+ price = options.reduce(function (accumulator, currentValue) {
205
+ return accumulator + Number(currentValue.price) * Number(currentValue.num);
206
+ }, price);
420
207
  }
421
- origin.product.note = note;
422
- return origin;
208
+ return price * num;
423
209
  };
424
210
 
425
211
  /**
@@ -490,72 +276,6 @@ export var formatBundleToOrigin = function formatBundleToOrigin(bundle) {
490
276
  });
491
277
  };
492
278
 
493
- /**
494
- * 判断是否是普通商品
495
- * @param product 商品
496
- * @returns 是否是普通商品
497
- */
498
- export var isNormalProduct = function isNormalProduct(product) {
499
- return (product === null || product === void 0 ? void 0 : product.extension_type) !== 'product_appointment';
500
- };
501
-
502
- /**
503
- * 获取商品总价
504
- * @description 当前总价计算基于商品数量为1
505
- * @param item 商品
506
- * @returns 商品总价
507
- */
508
- export var getProductTotalPrice = function getProductTotalPrice(params) {
509
- var product = params.product,
510
- bundle = params.bundle,
511
- options = params.options;
512
- var num = params.num || 1;
513
- var price = Number(product.price);
514
- if (bundle !== null && bundle !== void 0 && bundle.length) {
515
- price = bundle.reduce(function (accumulator, currentValue) {
516
- return accumulator + Number(currentValue.price) * Number(currentValue.num);
517
- }, price);
518
- }
519
-
520
- // 单规格
521
- if (options !== null && options !== void 0 && options.length) {
522
- price = options.reduce(function (accumulator, currentValue) {
523
- return accumulator + Number(currentValue.price) * Number(currentValue.num);
524
- }, price);
525
- }
526
- return price * num;
527
- };
528
-
529
- /**
530
- * 获取商品原始总价
531
- * @description 当前总价计算基于商品数量为1
532
- * @param item 商品
533
- * @returns 商品原始总价
534
- */
535
- export var getProductOriginTotalPrice = function getProductOriginTotalPrice(params) {
536
- var product = params.product,
537
- bundle = params.bundle,
538
- options = params.options;
539
- var num = (params === null || params === void 0 ? void 0 : params.num) || 1;
540
- var price = Number(product.original_price);
541
- if (isNaN(price) || price === 0) {
542
- return undefined;
543
- }
544
- if (bundle !== null && bundle !== void 0 && bundle.length) {
545
- price = bundle.reduce(function (accumulator, currentValue) {
546
- return accumulator + Number(currentValue.price) * Number(currentValue.num);
547
- }, price);
548
- }
549
-
550
- // 单规格
551
- if (options !== null && options !== void 0 && options.length) {
552
- price = options.reduce(function (accumulator, currentValue) {
553
- return accumulator + Number(currentValue.price) * Number(currentValue.num);
554
- }, price);
555
- }
556
- return price * num;
557
- };
558
-
559
279
  /**
560
280
  * 获取商品定金
561
281
  * @description 定金基于商品售价来算,最终乘商品数量
@@ -576,11 +296,11 @@ export var getProductDeposit = function getProductDeposit(params) {
576
296
  // 判定商品是否有定金规则
577
297
  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) {
578
298
  var total = new Decimal(0);
579
- var _ref2 = (product === null || product === void 0 ? void 0 : product.custom_deposit_data) || {},
580
- deposit_fixed = _ref2.deposit_fixed,
581
- deposit_percentage = _ref2.deposit_percentage,
582
- deposit_policy_data = _ref2.deposit_policy_data,
583
- self_deposit_policy_ids = _ref2.self_deposit_policy_ids;
299
+ var _ref = (product === null || product === void 0 ? void 0 : product.custom_deposit_data) || {},
300
+ deposit_fixed = _ref.deposit_fixed,
301
+ deposit_percentage = _ref.deposit_percentage,
302
+ deposit_policy_data = _ref.deposit_policy_data,
303
+ self_deposit_policy_ids = _ref.self_deposit_policy_ids;
584
304
  // 所有协议数据
585
305
  var allProtocols = deposit_policy_data || [];
586
306
  // 是否存在定金,主商品has_deposit为1,但是自身没有定金设置,需要判定子商品是否存在定金,如果不存在最终判定也是不存在定金
@@ -652,9 +372,9 @@ export var handleProductDeposit = function handleProductDeposit(params) {
652
372
  depositTotal: new Decimal(0)
653
373
  };
654
374
  }
655
- var _ref3 = depositData || {},
656
- deposit_fixed = _ref3.deposit_fixed,
657
- deposit_percentage = _ref3.deposit_percentage;
375
+ var _ref2 = depositData || {},
376
+ deposit_fixed = _ref2.deposit_fixed,
377
+ deposit_percentage = _ref2.deposit_percentage;
658
378
  if (typeof deposit_fixed === 'string' && typeof deposit_percentage === 'string') {
659
379
  var depositFixed = Decimal(deposit_fixed || 0);
660
380
  var depositPercent = Decimal(deposit_percentage || 0);
@@ -669,63 +389,4 @@ export var handleProductDeposit = function handleProductDeposit(params) {
669
389
  result: false,
670
390
  depositTotal: new Decimal(0)
671
391
  };
672
- };
673
-
674
- /**
675
- * 从购物车中删除资源相关信息
676
- * @param cartItem 购物车
677
- * @returns 删除后的购物车
678
- */
679
- export var deleteResourceFromCartItem = function deleteResourceFromCartItem(cartItem) {
680
- // 删除UI层的数据
681
- cartItem.resource_id = undefined;
682
- cartItem.relation_form_name = undefined;
683
-
684
- // 删除资源原始数据
685
- delete cartItem._resourceOrigin;
686
-
687
- // 删除原始数据
688
- cartItem._origin.resources = null;
689
- return cartItem;
690
- };
691
-
692
- /**
693
- * 从购物车中删除时间
694
- * @param cartItem 购物车
695
- * @returns 删除后的购物车
696
- */
697
- export var deleteTimeFromCartItem = function deleteTimeFromCartItem(cartItem) {
698
- // 删除UI层的数据
699
- cartItem.start_date = undefined;
700
- cartItem.start_time = undefined;
701
- cartItem.end_date = undefined;
702
- cartItem.end_time = undefined;
703
-
704
- // 删除原始数据
705
- cartItem._origin.select_date = null;
706
- cartItem._origin.start_date = null;
707
- cartItem._origin.start_time = null;
708
- cartItem._origin.end_date = null;
709
- cartItem._origin.end_time = null;
710
- return cartItem;
711
- };
712
-
713
- /**
714
- * 从购物车中删除关联表单信息
715
- * @param cartItem 购物车
716
- * @returns 删除后的购物车
717
- */
718
- export var deleteRelationFormsFromCartItem = function deleteRelationFormsFromCartItem(cartItem) {
719
- // 删除原始数据
720
- cartItem._origin.relation_forms = null;
721
- return cartItem;
722
- };
723
- export var deleteHolderFromCartItem = function deleteHolderFromCartItem(cartItem) {
724
- // 删除UI层的数据
725
- cartItem.holder_id = undefined;
726
- cartItem.holder_title = undefined;
727
-
728
- // 删除原始数据
729
- cartItem._origin.holder = null;
730
- return cartItem;
731
392
  };
@@ -0,0 +1,26 @@
1
+ import { CartItem } from '../types';
2
+ /**
3
+ * 格式化关联表单到购物车
4
+ * @param params 参数
5
+ * @returns 格式化后的购物车
6
+ */
7
+ export declare const formatRelationFormsToCartItem: (params: {
8
+ cartItem: CartItem;
9
+ relationForms: {
10
+ form_id: number;
11
+ form_record_ids: number[];
12
+ }[];
13
+ }) => CartItem;
14
+ export declare const formatRelationFormsToCartItemOrigin: (params: {
15
+ cartItem: CartItem;
16
+ relationForms: {
17
+ form_id: number;
18
+ form_record_ids: number[];
19
+ }[];
20
+ }) => any;
21
+ /**
22
+ * 从购物车中删除关联表单信息
23
+ * @param cartItem 购物车
24
+ * @returns 删除后的购物车
25
+ */
26
+ export declare const deleteRelationFormsFromCartItem: (cartItem: CartItem) => CartItem;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * 格式化关联表单到购物车
3
+ * @param params 参数
4
+ * @returns 格式化后的购物车
5
+ */
6
+ export var formatRelationFormsToCartItem = function formatRelationFormsToCartItem(params) {
7
+ var cartItem = params.cartItem;
8
+ var oringin = formatRelationFormsToCartItemOrigin(params);
9
+ cartItem._origin = oringin;
10
+ return cartItem;
11
+ };
12
+ export var formatRelationFormsToCartItemOrigin = function formatRelationFormsToCartItemOrigin(params) {
13
+ var cartItem = params.cartItem,
14
+ relationForms = params.relationForms;
15
+ var origin = cartItem._origin;
16
+ origin.relation_forms = relationForms;
17
+ return origin;
18
+ };
19
+
20
+ /**
21
+ * 从购物车中删除关联表单信息
22
+ * @param cartItem 购物车
23
+ * @returns 删除后的购物车
24
+ */
25
+ export var deleteRelationFormsFromCartItem = function deleteRelationFormsFromCartItem(cartItem) {
26
+ // 删除原始数据
27
+ cartItem._origin.relation_forms = null;
28
+ return cartItem;
29
+ };
@@ -0,0 +1,21 @@
1
+ import { Resource } from '../../Resource/types';
2
+ import { CartItem } from '../types';
3
+ /**
4
+ * 格式化资源到购物车
5
+ * @param resource 资源
6
+ * @returns 格式化后的资源
7
+ */
8
+ export declare const formatResourceToCartItem: (params: {
9
+ cartItem: CartItem;
10
+ resources: Resource[];
11
+ }) => CartItem;
12
+ export declare const formatResourceToCartItemOrigin: (params: {
13
+ cartItem: CartItem;
14
+ resources: Resource[];
15
+ }) => any;
16
+ /**
17
+ * 从购物车中删除资源相关信息
18
+ * @param cartItem 购物车
19
+ * @returns 删除后的购物车
20
+ */
21
+ export declare const deleteResourceFromCartItem: (cartItem: CartItem) => CartItem;