@pisell/pisellos 0.0.174 → 0.0.176

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.
@@ -172,11 +172,11 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
172
172
  key: "fetchResourceDates",
173
173
  value: function () {
174
174
  var _fetchResourceDates = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
175
- var url, query, fetchUrl, _ref, start_date, end_date, resource_ids, res;
175
+ var url, query, _params$useCache, useCache, fetchUrl, _ref, start_date, end_date, resource_ids, res;
176
176
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
177
177
  while (1) switch (_context3.prev = _context3.next) {
178
178
  case 0:
179
- url = params.url, query = params.query;
179
+ url = params.url, query = params.query, _params$useCache = params.useCache, useCache = _params$useCache === void 0 ? true : _params$useCache;
180
180
  fetchUrl = url || '/schedule/resource/list';
181
181
  _ref = query || {}, start_date = _ref.start_date, end_date = _ref.end_date, resource_ids = _ref.resource_ids;
182
182
  _context3.prev = 3;
@@ -185,9 +185,9 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
185
185
  start_date: start_date,
186
186
  end_date: end_date,
187
187
  resource_ids: resource_ids,
188
- front_end_cache_id: this.cacheId
188
+ front_end_cache_id: useCache && this.cacheId
189
189
  }, {
190
- useCache: true
190
+ useCache: useCache
191
191
  });
192
192
  case 6:
193
193
  res = _context3.sent;
@@ -43,6 +43,8 @@ export interface DateModuleAPI {
43
43
  }
44
44
  export interface IGetAvailableTimeListParams {
45
45
  url?: string;
46
+ /** 是否使用缓存 */
47
+ useCache?: boolean;
46
48
  /** 查询参数 */
47
49
  query?: {
48
50
  /** 开始日期 */
@@ -328,7 +328,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
328
328
  // 找到适用于此商品的所有优惠券,仅考虑isSelected不为false的优惠券
329
329
  var applicableDiscounts = sortedDiscountList.filter(function (discount) {
330
330
  // 如果商品价格为 0,其实不需要使用任何优惠券,直接 return true
331
- if (Number(product.price) === 0 || !product.price) return false;
331
+ if (Number(product.price) === 0 && discount.tag === 'good_pass' || Number(product.total) === 0 && discount.tag !== 'good_pass' || !product.price) return false;
332
332
  // 如果优惠券已被使用,则跳过
333
333
  var targetUsedDiscounts = usedDiscounts.get(discount.id);
334
334
  if (targetUsedDiscounts && (discount.tag || discount.type) === 'good_pass') return false;
@@ -131,6 +131,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
131
131
  getCart(): CartItem[];
132
132
  getAvailableDate(params?: {
133
133
  url?: string;
134
+ useCache?: boolean;
134
135
  products?: ProductData[];
135
136
  startDate?: string;
136
137
  endDate?: string;
@@ -681,6 +681,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
681
681
  startDate,
682
682
  endDate,
683
683
  type,
684
+ _params$useCache,
685
+ useCache,
684
686
  tempProducts,
685
687
  dateRange,
686
688
  tempStartDate,
@@ -696,7 +698,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
696
698
  case 0:
697
699
  params = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : {};
698
700
  // 开始日期如果小于今天,直接以今天当做开始日期
699
- products = params.products, startDate = params.startDate, endDate = params.endDate, type = params.type; // 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天 且 endDate 小于或等于今天,需要把 startDate 置为今天
701
+ products = params.products, startDate = params.startDate, endDate = params.endDate, type = params.type, _params$useCache = params.useCache, useCache = _params$useCache === void 0 ? true : _params$useCache; // 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天 且 endDate 小于或等于今天,需要把 startDate 置为今天
700
702
  if (dayjs(startDate).isBefore(dayjs(), 'day') && (dayjs(endDate).isAfter(dayjs(), 'day') || dayjs(endDate).isSame(dayjs(), 'day'))) {
701
703
  startDate = dayjs().format('YYYY-MM-DD');
702
704
  }
@@ -738,7 +740,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
738
740
  resource_ids: resourceIds
739
741
  },
740
742
  rules: rules,
741
- type: type
743
+ type: type,
744
+ useCache: useCache
742
745
  });
743
746
  case 15:
744
747
  res = _context12.sent;
@@ -117,22 +117,18 @@ var DateModule = class extends import_BaseModule.BaseModule {
117
117
  this.store.dateList = currentDateList;
118
118
  }
119
119
  async fetchResourceDates(params) {
120
- const { url, query } = params;
120
+ const { url, query, useCache = true } = params;
121
121
  const fetchUrl = url || "/schedule/resource/list";
122
122
  const { start_date, end_date, resource_ids } = query || {};
123
123
  try {
124
- const res = await this.request.get(
125
- fetchUrl,
126
- {
127
- start_date,
128
- end_date,
129
- resource_ids,
130
- front_end_cache_id: this.cacheId
131
- },
132
- {
133
- useCache: true
134
- }
135
- );
124
+ const res = await this.request.get(fetchUrl, {
125
+ start_date,
126
+ end_date,
127
+ resource_ids,
128
+ front_end_cache_id: useCache && this.cacheId
129
+ }, {
130
+ useCache
131
+ });
136
132
  return res;
137
133
  } catch (error) {
138
134
  console.error(error);
@@ -43,6 +43,8 @@ export interface DateModuleAPI {
43
43
  }
44
44
  export interface IGetAvailableTimeListParams {
45
45
  url?: string;
46
+ /** 是否使用缓存 */
47
+ useCache?: boolean;
46
48
  /** 查询参数 */
47
49
  query?: {
48
50
  /** 开始日期 */
@@ -213,7 +213,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
213
213
  return;
214
214
  }
215
215
  const applicableDiscounts = sortedDiscountList.filter((discount) => {
216
- if (Number(product.price) === 0 || !product.price)
216
+ if (Number(product.price) === 0 && discount.tag === "good_pass" || Number(product.total) === 0 && discount.tag !== "good_pass" || !product.price)
217
217
  return false;
218
218
  const targetUsedDiscounts = usedDiscounts.get(discount.id);
219
219
  if (targetUsedDiscounts && (discount.tag || discount.type) === "good_pass")
@@ -131,6 +131,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
131
131
  getCart(): CartItem[];
132
132
  getAvailableDate(params?: {
133
133
  url?: string;
134
+ useCache?: boolean;
134
135
  products?: ProductData[];
135
136
  startDate?: string;
136
137
  endDate?: string;
@@ -388,7 +388,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
388
388
  // 获取商品/服务的可用日期
389
389
  async getAvailableDate(params = {}) {
390
390
  var _a, _b, _c;
391
- let { products, startDate, endDate, type } = params;
391
+ let { products, startDate, endDate, type, useCache = true } = params;
392
392
  if ((0, import_dayjs.default)(startDate).isBefore((0, import_dayjs.default)(), "day") && ((0, import_dayjs.default)(endDate).isAfter((0, import_dayjs.default)(), "day") || (0, import_dayjs.default)(endDate).isSame((0, import_dayjs.default)(), "day"))) {
393
393
  startDate = (0, import_dayjs.default)().format("YYYY-MM-DD");
394
394
  }
@@ -425,7 +425,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
425
425
  resource_ids: resourceIds
426
426
  },
427
427
  rules,
428
- type
428
+ type,
429
+ useCache
429
430
  });
430
431
  return res;
431
432
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.174",
4
+ "version": "0.0.176",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",