@pisell/pisellos 0.0.160 → 0.0.164

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.
@@ -10,6 +10,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
10
10
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
11
11
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
12
12
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
13
+ import Decimal from "decimal.js";
13
14
  export function updateAllCartItemPrice(_x, _x2, _x3, _x4) {
14
15
  return _updateAllCartItemPrice.apply(this, arguments);
15
16
  }
@@ -49,6 +50,9 @@ function _updateAllCartItemPrice() {
49
50
  var targetBundleItem = targetBundle.bundle_item.find(function (m) {
50
51
  return m.id === n.id;
51
52
  });
53
+ if (targetBundleItem.price_type === 'markdown') {
54
+ targetBundleItem.price = new Decimal(targetBundleItem.price || 0).mul(-1).toNumber();
55
+ }
52
56
  if (targetBundleItem) {
53
57
  return _objectSpread(_objectSpread({}, n), {}, {
54
58
  price: targetBundleItem.price,
@@ -232,7 +232,7 @@ export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
232
232
  cacheId: this.cacheId,
233
233
  fatherModule: this.fatherModule,
234
234
  store: store,
235
- cacheKey: ['scheduleList', 'availabilityDateList']
235
+ cacheKey: ['scheduleList', 'availabilityDateList', 'otherProductsIds']
236
236
  });
237
237
  }
238
238
  }
@@ -1410,17 +1410,27 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1410
1410
  resources.push.apply(resources, _toConsumableArray(_this10.store.date.getResourcesListByDate(n.date) || []));
1411
1411
  });
1412
1412
  }
1413
+ var cartItems = this.store.cart.getItems().filter(function (n) {
1414
+ return !isNormalProduct(n._productOrigin);
1415
+ });
1416
+
1413
1417
  // 如果此时 resources 为空,视作购物车里已经有了 dateRange 数据,此时 dateList 里明确就是那一天的数据
1414
1418
  if (!resources.length) {
1415
- var dateList = this.store.date.getDateList();
1416
- dateList.forEach(function (n) {
1417
- if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
1419
+ // 如果此时购物车里已经有了开始时间,则直接取那天的数据即可
1420
+ var firstDateCartItem = cartItems === null || cartItems === void 0 ? void 0 : cartItems.find(function (n) {
1421
+ return n.start_date;
1418
1422
  });
1423
+ if (firstDateCartItem !== null && firstDateCartItem !== void 0 && firstDateCartItem.start_date) {
1424
+ var dateResources = this.store.date.getResourcesListByDate(firstDateCartItem.start_date);
1425
+ resources.push.apply(resources, _toConsumableArray(dateResources || []));
1426
+ } else {
1427
+ var dateList = this.store.date.getDateList();
1428
+ dateList.forEach(function (n) {
1429
+ if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
1430
+ });
1431
+ }
1419
1432
  }
1420
1433
  var resourcesMap = getResourcesMap(cloneDeep(resources));
1421
- var cartItems = this.store.cart.getItems().filter(function (n) {
1422
- return !isNormalProduct(n._productOrigin);
1423
- });
1424
1434
  var arr = [];
1425
1435
  cartItems.forEach(function (cartItem) {
1426
1436
  var _cartItem$_productOri;
@@ -1,6 +1,8 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
4
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
7
  var __export = (target, all) => {
6
8
  for (var name in all)
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
14
16
  }
15
17
  return to;
16
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
+ ));
17
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
28
 
19
29
  // src/modules/Cart/utils/changePrice.ts
@@ -22,6 +32,7 @@ __export(changePrice_exports, {
22
32
  updateAllCartItemPrice: () => updateAllCartItemPrice
23
33
  });
24
34
  module.exports = __toCommonJS(changePrice_exports);
35
+ var import_decimal = __toESM(require("decimal.js"));
25
36
  async function updateAllCartItemPrice(cartItems, priceData, getProduct, updateCart) {
26
37
  for (const item of cartItems) {
27
38
  const targetProduct = priceData.find((n) => n.id === item.id);
@@ -41,6 +52,9 @@ async function updateAllCartItemPrice(cartItems, priceData, getProduct, updateCa
41
52
  const targetBundleItem = targetBundle.bundle_item.find(
42
53
  (m) => m.id === n.id
43
54
  );
55
+ if (targetBundleItem.price_type === "markdown") {
56
+ targetBundleItem.price = new import_decimal.default(targetBundleItem.price || 0).mul(-1).toNumber();
57
+ }
44
58
  if (targetBundleItem) {
45
59
  return {
46
60
  ...n,
@@ -154,7 +154,7 @@ var ScheduleModule = class extends import_BaseModule.BaseModule {
154
154
  cacheId: this.cacheId,
155
155
  fatherModule: this.fatherModule,
156
156
  store,
157
- cacheKey: ["scheduleList", "availabilityDateList"]
157
+ cacheKey: ["scheduleList", "availabilityDateList", "otherProductsIds"]
158
158
  });
159
159
  }
160
160
  }
@@ -820,15 +820,21 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
820
820
  resources.push(...this.store.date.getResourcesListByDate(n.date) || []);
821
821
  });
822
822
  }
823
+ const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
823
824
  if (!resources.length) {
824
- const dateList = this.store.date.getDateList();
825
- dateList.forEach((n) => {
826
- if (n.resource)
827
- resources.push(...n.resource);
828
- });
825
+ const firstDateCartItem = cartItems == null ? void 0 : cartItems.find((n) => n.start_date);
826
+ if (firstDateCartItem == null ? void 0 : firstDateCartItem.start_date) {
827
+ const dateResources = this.store.date.getResourcesListByDate(firstDateCartItem.start_date);
828
+ resources.push(...dateResources || []);
829
+ } else {
830
+ const dateList = this.store.date.getDateList();
831
+ dateList.forEach((n) => {
832
+ if (n.resource)
833
+ resources.push(...n.resource);
834
+ });
835
+ }
829
836
  }
830
837
  const resourcesMap = (0, import_utils.getResourcesMap)((0, import_lodash_es.cloneDeep)(resources));
831
- const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
832
838
  const arr = [];
833
839
  cartItems.forEach((cartItem) => {
834
840
  var _a, _b, _c, _d, _e, _f;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.160",
4
+ "version": "0.0.164",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",