@pisell/pisellos 3.0.51 → 3.0.53

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.
@@ -22,8 +22,9 @@ import { isNormalProduct } from "../../Product/utils";
22
22
  export var handleVariantProduct = function handleVariantProduct(product) {
23
23
  // 判断组合商品,然后直接修改 product 里的价格和 is_charge_tax
24
24
  if (product !== null && product !== void 0 && product.product_variant_id) {
25
+ var _product$variant;
25
26
  // 还需要判断 能从 variant 里找到对应的组合规格信息,才可以替换
26
- var targetVariant = product.variant.find(function (n) {
27
+ var targetVariant = product === null || product === void 0 || (_product$variant = product.variant) === null || _product$variant === void 0 ? void 0 : _product$variant.find(function (n) {
27
28
  return n.id === product.product_variant_id;
28
29
  });
29
30
  if (targetVariant) {
@@ -45,6 +46,7 @@ export var handleVariantProduct = function handleVariantProduct(product) {
45
46
  */
46
47
  export var formatProductToCartItem = function formatProductToCartItem(params) {
47
48
  var _product$custom_depos;
49
+ console.log('formatProductToCartItem>>>>>>', params);
48
50
  var cartItem = params.cartItem,
49
51
  product = params.product,
50
52
  bundle = params.bundle,
@@ -88,17 +90,17 @@ export var formatProductToCartItem = function formatProductToCartItem(params) {
88
90
  }
89
91
  // 拼装出 product_option_string
90
92
  if (product_variant_id) {
91
- var _product$variant$find;
92
- var sku_key = (_product$variant$find = product.variant.find(function (n) {
93
+ var _product$variant2;
94
+ var sku_key = product === null || product === void 0 || (_product$variant2 = product.variant) === null || _product$variant2 === void 0 || (_product$variant2 = _product$variant2.find(function (n) {
93
95
  return n.id === product_variant_id;
94
- })) === null || _product$variant$find === void 0 ? void 0 : _product$variant$find.sku_key;
96
+ })) === null || _product$variant2 === void 0 ? void 0 : _product$variant2.sku_key;
95
97
  if (sku_key) {
96
98
  var sku_key_arr = sku_key.split('_');
97
99
  var product_option_string = [];
98
100
  sku_key_arr.forEach(function (item) {
99
- var _targetVariantGroup$v;
101
+ var _product$variant_grou, _targetVariantGroup$v;
100
102
  var keyMap = item.split(':');
101
- var targetVariantGroup = product.variant_group.find(function (n) {
103
+ var targetVariantGroup = product === null || product === void 0 || (_product$variant_grou = product.variant_group) === null || _product$variant_grou === void 0 ? void 0 : _product$variant_grou.find(function (n) {
102
104
  return String(n.position_id) === keyMap[0];
103
105
  });
104
106
  var targetVariantItem = targetVariantGroup === null || targetVariantGroup === void 0 || (_targetVariantGroup$v = targetVariantGroup.variant_item) === null || _targetVariantGroup$v === void 0 ? void 0 : _targetVariantGroup$v.find(function (n) {
@@ -344,16 +346,38 @@ export var getProductDeposit = function getProductDeposit(params) {
344
346
  productHasDeposit = true;
345
347
  }
346
348
  } else {
349
+ // 组合规格商品
350
+ if (product !== null && product !== void 0 && product.product_variant_id) {
351
+ var _product$variant3;
352
+ var variantProduct = product === null || product === void 0 || (_product$variant3 = product.variant) === null || _product$variant3 === void 0 ? void 0 : _product$variant3.find(function (item) {
353
+ return (item === null || item === void 0 ? void 0 : item.id) === (product === null || product === void 0 ? void 0 : product.product_variant_id);
354
+ });
355
+ if (variantProduct) {
356
+ var depositData = variantProduct === null || variantProduct === void 0 ? void 0 : variantProduct.custom_deposit_data;
357
+ var _handleProductDeposit2 = handleProductDeposit({
358
+ depositData: depositData,
359
+ total: (cartItem === null || cartItem === void 0 ? void 0 : cartItem.total) || 0,
360
+ num: num
361
+ }),
362
+ _depositTotal = _handleProductDeposit2.depositTotal,
363
+ _result = _handleProductDeposit2.result;
364
+ if (_result) {
365
+ total = _depositTotal;
366
+ protocolIds.push.apply(protocolIds, _toConsumableArray((depositData === null || depositData === void 0 ? void 0 : depositData.self_deposit_policy_ids) || []));
367
+ productHasDeposit = true;
368
+ }
369
+ }
370
+ }
347
371
  if (bundle !== null && bundle !== void 0 && bundle.length) {
348
372
  total = bundle.reduce(function (accumulator, currBundleProduct) {
349
373
  var depositData = currBundleProduct === null || currBundleProduct === void 0 ? void 0 : currBundleProduct.custom_deposit_data;
350
- var _handleProductDeposit2 = handleProductDeposit({
374
+ var _handleProductDeposit3 = handleProductDeposit({
351
375
  depositData: depositData,
352
376
  total: currBundleProduct === null || currBundleProduct === void 0 ? void 0 : currBundleProduct.price,
353
377
  num: (currBundleProduct === null || currBundleProduct === void 0 ? void 0 : currBundleProduct.num) || 1
354
378
  }),
355
- depositTotal = _handleProductDeposit2.depositTotal,
356
- result = _handleProductDeposit2.result;
379
+ depositTotal = _handleProductDeposit3.depositTotal,
380
+ result = _handleProductDeposit3.result;
357
381
  if (result) {
358
382
  protocolIds.push.apply(protocolIds, _toConsumableArray((depositData === null || depositData === void 0 ? void 0 : depositData.self_deposit_policy_ids) || []));
359
383
  productHasDeposit = true;
@@ -46,7 +46,7 @@ export var formatResourceToCartItemOrigin = function formatResourceToCartItemOri
46
46
  }
47
47
  var obj = {
48
48
  relation_type: 'form',
49
- like_status: 'common',
49
+ like_status: resource.like_status || 'common',
50
50
  id: resource.id,
51
51
  main_field: resource.main_field,
52
52
  resourceType: resource.resourceType,
@@ -16,6 +16,7 @@ export interface ResourceTimeSlot {
16
16
  * 资源信息
17
17
  */
18
18
  export interface Resource {
19
+ like_status: 'common' | 'like';
19
20
  id: string | number;
20
21
  main_field: string;
21
22
  form_id: string | number;
@@ -140,6 +140,12 @@ var getDaysByRepeatWeek = function getDaysByRepeatWeek(params, isGetRange) {
140
140
  for (var i = 0; i < frequency_date.length; i++) {
141
141
  var item = frequency_date[i];
142
142
  var _start = startTmp.day(item);
143
+
144
+ // 如果计算出的日期早于startTmp,则跳到下一周的相同星期几
145
+ if (_start.isBefore(startTmp, 'day')) {
146
+ _start = _start.add(1, 'week');
147
+ }
148
+
143
149
  // 如果周结束的那一天还超过了deadline,则需要把_end置为deadline
144
150
  var _end = _start.add(scheduleDiff, 'second');
145
151
  if (_end.isAfter(deadline, 'day')) {
@@ -161,7 +167,7 @@ var getDaysByRepeatWeek = function getDaysByRepeatWeek(params, isGetRange) {
161
167
  daysArr.push.apply(daysArr, _toConsumableArray(getDaysByStartEnd(_start, _end)));
162
168
  }
163
169
  }
164
- startTmp = startTmp.day(1).add(frequency, 'week');
170
+ startTmp = startTmp.add(frequency, 'week');
165
171
  }
166
172
  return Array.from(new Set(daysArr));
167
173
  };
@@ -45,8 +45,9 @@ module.exports = __toCommonJS(cartProduct_exports);
45
45
  var import_decimal = __toESM(require("decimal.js"));
46
46
  var import_utils = require("../../Product/utils");
47
47
  var handleVariantProduct = (product) => {
48
+ var _a;
48
49
  if (product == null ? void 0 : product.product_variant_id) {
49
- const targetVariant = product.variant.find(
50
+ const targetVariant = (_a = product == null ? void 0 : product.variant) == null ? void 0 : _a.find(
50
51
  (n) => n.id === product.product_variant_id
51
52
  );
52
53
  if (targetVariant) {
@@ -60,7 +61,8 @@ var handleVariantProduct = (product) => {
60
61
  return product;
61
62
  };
62
63
  var formatProductToCartItem = (params) => {
63
- var _a, _b;
64
+ var _a, _b, _c;
65
+ console.log("formatProductToCartItem>>>>>>", params);
64
66
  const {
65
67
  cartItem,
66
68
  product,
@@ -98,19 +100,19 @@ var formatProductToCartItem = (params) => {
98
100
  cartItem.options = formatOptions(options);
99
101
  }
100
102
  if (product_variant_id) {
101
- const sku_key = (_a = product.variant.find(
103
+ const sku_key = (_b = (_a = product == null ? void 0 : product.variant) == null ? void 0 : _a.find(
102
104
  (n) => n.id === product_variant_id
103
- )) == null ? void 0 : _a.sku_key;
105
+ )) == null ? void 0 : _b.sku_key;
104
106
  if (sku_key) {
105
107
  const sku_key_arr = sku_key.split("_");
106
108
  const product_option_string = [];
107
109
  sku_key_arr.forEach((item) => {
108
- var _a2;
110
+ var _a2, _b2;
109
111
  const keyMap = item.split(":");
110
- const targetVariantGroup = product.variant_group.find(
112
+ const targetVariantGroup = (_a2 = product == null ? void 0 : product.variant_group) == null ? void 0 : _a2.find(
111
113
  (n) => String(n.position_id) === keyMap[0]
112
114
  );
113
- const targetVariantItem = (_a2 = targetVariantGroup == null ? void 0 : targetVariantGroup.variant_item) == null ? void 0 : _a2.find(
115
+ const targetVariantItem = (_b2 = targetVariantGroup == null ? void 0 : targetVariantGroup.variant_item) == null ? void 0 : _b2.find(
114
116
  (n) => String(n.position_id) === keyMap[1]
115
117
  );
116
118
  if (targetVariantGroup && targetVariantItem) {
@@ -122,7 +124,7 @@ var formatProductToCartItem = (params) => {
122
124
  cartItem.product_option_string = product_option_string.join(", ");
123
125
  }
124
126
  }
125
- if (((_b = product == null ? void 0 : product.custom_deposit_data) == null ? void 0 : _b.has_deposit) == 1) {
127
+ if (((_c = product == null ? void 0 : product.custom_deposit_data) == null ? void 0 : _c.has_deposit) == 1) {
126
128
  cartItem.deposit = getProductDeposit({
127
129
  cartItem,
128
130
  product,
@@ -268,7 +270,7 @@ var formatBundleToOrigin = (bundle) => {
268
270
  });
269
271
  };
270
272
  var getProductDeposit = (params) => {
271
- var _a;
273
+ var _a, _b;
272
274
  const { cartItem, product, bundle, options } = params;
273
275
  const num = (params == null ? void 0 : params.num) || 1;
274
276
  if (((_a = product == null ? void 0 : product.custom_deposit_data) == null ? void 0 : _a.has_deposit) == 1) {
@@ -294,6 +296,24 @@ var getProductDeposit = (params) => {
294
296
  productHasDeposit = true;
295
297
  }
296
298
  } else {
299
+ if (product == null ? void 0 : product.product_variant_id) {
300
+ const variantProduct = (_b = product == null ? void 0 : product.variant) == null ? void 0 : _b.find(
301
+ (item) => (item == null ? void 0 : item.id) === (product == null ? void 0 : product.product_variant_id)
302
+ );
303
+ if (variantProduct) {
304
+ const depositData = variantProduct == null ? void 0 : variantProduct.custom_deposit_data;
305
+ const { depositTotal, result } = handleProductDeposit({
306
+ depositData,
307
+ total: (cartItem == null ? void 0 : cartItem.total) || 0,
308
+ num
309
+ });
310
+ if (result) {
311
+ total = depositTotal;
312
+ protocolIds.push(...(depositData == null ? void 0 : depositData.self_deposit_policy_ids) || []);
313
+ productHasDeposit = true;
314
+ }
315
+ }
316
+ }
297
317
  if (bundle == null ? void 0 : bundle.length) {
298
318
  total = bundle.reduce((accumulator, currBundleProduct) => {
299
319
  const depositData = currBundleProduct == null ? void 0 : currBundleProduct.custom_deposit_data;
@@ -74,7 +74,7 @@ var formatResourceToCartItemOrigin = (params) => {
74
74
  }
75
75
  const obj = {
76
76
  relation_type: "form",
77
- like_status: "common",
77
+ like_status: resource.like_status || "common",
78
78
  id: resource.id,
79
79
  main_field: resource.main_field,
80
80
  resourceType: resource.resourceType,
@@ -16,6 +16,7 @@ export interface ResourceTimeSlot {
16
16
  * 资源信息
17
17
  */
18
18
  export interface Resource {
19
+ like_status: 'common' | 'like';
19
20
  id: string | number;
20
21
  main_field: string;
21
22
  form_id: string | number;
@@ -139,7 +139,10 @@ var getDaysByRepeatWeek = (params, isGetRange) => {
139
139
  while (startTmp.isBefore(deadline, "day") || startTmp.isSame(deadline, "day")) {
140
140
  for (let i = 0; i < frequency_date.length; i++) {
141
141
  const item = frequency_date[i];
142
- const _start = startTmp.day(item);
142
+ let _start = startTmp.day(item);
143
+ if (_start.isBefore(startTmp, "day")) {
144
+ _start = _start.add(1, "week");
145
+ }
143
146
  let _end = _start.add(scheduleDiff, "second");
144
147
  if (_end.isAfter(deadline, "day")) {
145
148
  _end = deadline;
@@ -160,7 +163,7 @@ var getDaysByRepeatWeek = (params, isGetRange) => {
160
163
  daysArr.push(...getDaysByStartEnd(_start, _end));
161
164
  }
162
165
  }
163
- startTmp = startTmp.day(1).add(frequency, "week");
166
+ startTmp = startTmp.add(frequency, "week");
164
167
  }
165
168
  return Array.from(new Set(daysArr));
166
169
  };
@@ -585,7 +588,9 @@ function getAllSortedDateRanges(schedules) {
585
588
  return durationA - durationB;
586
589
  });
587
590
  const uniqueDateRanges = sortedDateRanges.filter(
588
- (range, index, self) => index === self.findIndex((t) => (0, import_dayjs.default)(t.start).isSame((0, import_dayjs.default)(range.start)) && (0, import_dayjs.default)(t.end).isSame((0, import_dayjs.default)(range.end)))
591
+ (range, index, self) => index === self.findIndex(
592
+ (t) => (0, import_dayjs.default)(t.start).isSame((0, import_dayjs.default)(range.start)) && (0, import_dayjs.default)(t.end).isSame((0, import_dayjs.default)(range.end))
593
+ )
589
594
  );
590
595
  return uniqueDateRanges;
591
596
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "3.0.51",
4
+ "version": "3.0.53",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",