@pisell/pisellos 3.0.36 → 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.
- package/dist/modules/Discount/index.js +2 -2
- package/dist/solution/BookingByStep/index.js +45 -30
- package/dist/solution/ShopDiscount/index.js +5 -4
- package/lib/modules/Discount/index.js +3 -7
- package/lib/solution/BookingByStep/index.js +11 -7
- package/lib/solution/ShopDiscount/index.js +5 -9
- package/package.json +3 -3
|
@@ -122,7 +122,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
122
122
|
return this.request.post("/order/prepare/config", params);
|
|
123
123
|
case 2:
|
|
124
124
|
prepareConfig = _context3.sent;
|
|
125
|
-
goodPassList = this.
|
|
125
|
+
goodPassList = this.filterEnabledDiscountList((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data = prepareConfig.data) === null || _prepareConfig$data === void 0 ? void 0 : _prepareConfig$data.good_pass_list) || []) || [];
|
|
126
126
|
return _context3.abrupt("return", goodPassList);
|
|
127
127
|
case 5:
|
|
128
128
|
case "end":
|
|
@@ -153,7 +153,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
153
153
|
});
|
|
154
154
|
case 2:
|
|
155
155
|
result = _context4.sent;
|
|
156
|
-
resultDiscountList = this.
|
|
156
|
+
resultDiscountList = this.filterEnabledDiscountList((result === null || result === void 0 ? void 0 : result.data) || []) || [];
|
|
157
157
|
return _context4.abrupt("return", resultDiscountList);
|
|
158
158
|
case 5:
|
|
159
159
|
case "end":
|
|
@@ -272,8 +272,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
272
272
|
key: "loadProductByScheduleDate",
|
|
273
273
|
value: function () {
|
|
274
274
|
var _loadProductByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref2) {
|
|
275
|
-
var
|
|
276
|
-
var date, _ref2$product_ids, product_ids, _ref2$category_ids, category_ids, scheduleList,
|
|
275
|
+
var _schedule$product_ids;
|
|
276
|
+
var date, _ref2$product_ids, product_ids, _ref2$category_ids, category_ids, scheduleList, schedule, otherProductsIds, allProductIds;
|
|
277
277
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
278
278
|
while (1) switch (_context3.prev = _context3.next) {
|
|
279
279
|
case 0:
|
|
@@ -296,29 +296,34 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
296
296
|
// .filter((n) => n !== null && n !== undefined);
|
|
297
297
|
|
|
298
298
|
// 如果外面没传 product_ids,尝试从对应 schedule 里拿 product_ids
|
|
299
|
-
if (!
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
299
|
+
// if (!product_ids?.length) {
|
|
300
|
+
// const schedule = scheduleList.find((n) => n.date === date);
|
|
301
|
+
// if (schedule && schedule.product_ids?.length) {
|
|
302
|
+
// product_ids = schedule.product_ids;
|
|
303
|
+
// }
|
|
304
|
+
// }
|
|
305
|
+
// V2接口修改后,只能从schedule 接口里拿数据,不可以从外面拿,外面给的是装修数据
|
|
306
|
+
schedule = scheduleList.find(function (n) {
|
|
307
|
+
return n.date === date;
|
|
308
|
+
});
|
|
309
|
+
if (schedule && (_schedule$product_ids = schedule.product_ids) !== null && _schedule$product_ids !== void 0 && _schedule$product_ids.length) {
|
|
310
|
+
product_ids = schedule.product_ids;
|
|
306
311
|
}
|
|
307
312
|
// 尝试去拿schedule 里的 other_product_ids 和 product_ids 拼在一起去重
|
|
308
313
|
otherProductsIds = this.store.schedule.getOtherProductsIds() || [];
|
|
309
314
|
allProductIds = [].concat(_toConsumableArray(product_ids), _toConsumableArray(otherProductsIds)).filter(function (n, index, self) {
|
|
310
315
|
return self.indexOf(n) === index;
|
|
311
316
|
});
|
|
312
|
-
_context3.next =
|
|
317
|
+
_context3.next = 9;
|
|
313
318
|
return this.loadProducts({
|
|
314
319
|
// schedule_ids: scheduleIds,
|
|
315
320
|
product_ids: allProductIds,
|
|
316
321
|
category_ids: category_ids
|
|
317
322
|
// schedule_date: date,
|
|
318
323
|
});
|
|
319
|
-
case 8:
|
|
320
|
-
return _context3.abrupt("return", _context3.sent);
|
|
321
324
|
case 9:
|
|
325
|
+
return _context3.abrupt("return", _context3.sent);
|
|
326
|
+
case 10:
|
|
322
327
|
case "end":
|
|
323
328
|
return _context3.stop();
|
|
324
329
|
}
|
|
@@ -341,7 +346,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
341
346
|
// 更新完商品数据以后,检测当前购物车里是否有商品,如果有,则需要更新购物车里的商品价格
|
|
342
347
|
cartItems = this.store.cart.getItems();
|
|
343
348
|
if (!cartItems.length) {
|
|
344
|
-
_context5.next =
|
|
349
|
+
_context5.next = 25;
|
|
345
350
|
break;
|
|
346
351
|
}
|
|
347
352
|
userPlugin = this.core.getPlugin('user');
|
|
@@ -433,6 +438,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
433
438
|
_iterator.f();
|
|
434
439
|
return _context5.finish(21);
|
|
435
440
|
case 24:
|
|
441
|
+
this.core.effects.emit("".concat(this.store.cart.name, ":onUpdateQuotationPrice"), {});
|
|
442
|
+
case 25:
|
|
436
443
|
case "end":
|
|
437
444
|
return _context5.stop();
|
|
438
445
|
}
|
|
@@ -2889,6 +2896,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2889
2896
|
var params,
|
|
2890
2897
|
startDate,
|
|
2891
2898
|
endDate,
|
|
2899
|
+
endDateAfterMonth,
|
|
2892
2900
|
tempProducts,
|
|
2893
2901
|
schedule,
|
|
2894
2902
|
filteredSchedule,
|
|
@@ -2913,13 +2921,20 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2913
2921
|
startDate = dayjs().format('YYYY-MM-DD');
|
|
2914
2922
|
}
|
|
2915
2923
|
// 不管前端传什么 endDate 默认查一个月的,以今天为开始日期。用于找到一个月内最近可用的日期
|
|
2916
|
-
|
|
2924
|
+
// 优化策略:
|
|
2925
|
+
// 在 endDate 添加完一个月以后,如果 endDate 还小于 startDate + 7 天,则还需要 endDate+7 天
|
|
2926
|
+
endDateAfterMonth = dayjs().add(1, 'month').format('YYYY-MM-DD');
|
|
2927
|
+
if (dayjs(startDate).add(7, 'day').isAfter(dayjs(endDateAfterMonth), 'day')) {
|
|
2928
|
+
endDate = dayjs(startDate).add(7, 'day').format('YYYY-MM-DD');
|
|
2929
|
+
} else {
|
|
2930
|
+
endDate = endDateAfterMonth;
|
|
2931
|
+
}
|
|
2917
2932
|
// 如果当前打开了某个的商品详情弹窗,则应该默认用这个商品
|
|
2918
2933
|
tempProducts = (_this$store$currentPr3 = this.store.currentProduct) === null || _this$store$currentPr3 === void 0 ? void 0 : _this$store$currentPr3.getData();
|
|
2919
2934
|
schedule = (_this$store$currentPr4 = this.store.currentProduct) === null || _this$store$currentPr4 === void 0 ? void 0 : _this$store$currentPr4.getOtherParams()['schedule'];
|
|
2920
2935
|
filteredSchedule = filterScheduleByDateRange(schedule, startDate || '', endDate || ''); // 1.后端返回的数据,确定资源在每一天的可用和使用情况
|
|
2921
2936
|
tempResourceIds = getResourcesIdsByProduct(tempProducts);
|
|
2922
|
-
_context32.next =
|
|
2937
|
+
_context32.next = 11;
|
|
2923
2938
|
return this.store.date.fetchResourceDates({
|
|
2924
2939
|
query: {
|
|
2925
2940
|
start_date: startDate || '',
|
|
@@ -2927,17 +2942,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2927
2942
|
resource_ids: tempResourceIds
|
|
2928
2943
|
}
|
|
2929
2944
|
});
|
|
2930
|
-
case
|
|
2945
|
+
case 11:
|
|
2931
2946
|
res = _context32.sent;
|
|
2932
2947
|
// 先去读缓存结果,因为正常 UI 调用的是 7 天,而下面我会直接计算 30 天(最少也是 14 天),所以先去读缓存结果,如果缓存结果存在,则直接返回
|
|
2933
2948
|
// TODO 优化关于为什么要放在接口后,因为在获取时间切片的时候还需要读一次接口数据,其实可以直接从这个结果里拿了,需要优化
|
|
2934
2949
|
cache = (_this$store$currentPr5 = this.store.currentProduct) === null || _this$store$currentPr5 === void 0 ? void 0 : _this$store$currentPr5.getOtherParams()['timeSlotBySchedule'];
|
|
2935
2950
|
if (!cache) {
|
|
2936
|
-
_context32.next =
|
|
2951
|
+
_context32.next = 17;
|
|
2937
2952
|
break;
|
|
2938
2953
|
}
|
|
2939
2954
|
if (!(dayjs(params.startDate).isSameOrAfter(dayjs(cache.startDate), 'day') && dayjs(params.endDate).isSameOrBefore(dayjs(cache.endDate), 'day'))) {
|
|
2940
|
-
_context32.next =
|
|
2955
|
+
_context32.next = 17;
|
|
2941
2956
|
break;
|
|
2942
2957
|
}
|
|
2943
2958
|
this.store.date.setDateList(cache.dateList);
|
|
@@ -2945,7 +2960,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2945
2960
|
dateList: cache.dateList,
|
|
2946
2961
|
firstAvailableDate: cache.firstAvailableDate
|
|
2947
2962
|
});
|
|
2948
|
-
case
|
|
2963
|
+
case 17:
|
|
2949
2964
|
// 2. 商品 schedule 数据,确定日程在每一天的时间片
|
|
2950
2965
|
// 3. 把后端返回的和 schedule 的数据进行合并,确定每一天的可用和使用情况
|
|
2951
2966
|
dates = [];
|
|
@@ -3072,22 +3087,22 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3072
3087
|
}
|
|
3073
3088
|
}, _loop3);
|
|
3074
3089
|
});
|
|
3075
|
-
case
|
|
3090
|
+
case 25:
|
|
3076
3091
|
if (!(dayjs(currentDate).isBefore(dayjs(endDate), 'day') || dayjs(currentDate).isSame(dayjs(endDate), 'day'))) {
|
|
3077
|
-
_context32.next =
|
|
3092
|
+
_context32.next = 31;
|
|
3078
3093
|
break;
|
|
3079
3094
|
}
|
|
3080
|
-
return _context32.delegateYield(_loop3(), "t0",
|
|
3081
|
-
case
|
|
3095
|
+
return _context32.delegateYield(_loop3(), "t0", 27);
|
|
3096
|
+
case 27:
|
|
3082
3097
|
if (!_context32.t0) {
|
|
3083
|
-
_context32.next =
|
|
3098
|
+
_context32.next = 29;
|
|
3084
3099
|
break;
|
|
3085
3100
|
}
|
|
3086
|
-
return _context32.abrupt("break",
|
|
3087
|
-
case
|
|
3088
|
-
_context32.next =
|
|
3101
|
+
return _context32.abrupt("break", 31);
|
|
3102
|
+
case 29:
|
|
3103
|
+
_context32.next = 25;
|
|
3089
3104
|
break;
|
|
3090
|
-
case
|
|
3105
|
+
case 31:
|
|
3091
3106
|
// 最终把资源数据也加到日期内
|
|
3092
3107
|
dates = handleAvailableDateByResource(res.data, dates);
|
|
3093
3108
|
this.store.date.setDateList(dates);
|
|
@@ -3097,13 +3112,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3097
3112
|
dateList: dates,
|
|
3098
3113
|
firstAvailableDate: firstAvailableDate,
|
|
3099
3114
|
startDate: startDate,
|
|
3100
|
-
endDate:
|
|
3115
|
+
endDate: dayjs(currentDate).format('YYYY-MM-DD')
|
|
3101
3116
|
});
|
|
3102
3117
|
return _context32.abrupt("return", {
|
|
3103
3118
|
dateList: dates,
|
|
3104
3119
|
firstAvailableDate: firstAvailableDate
|
|
3105
3120
|
});
|
|
3106
|
-
case
|
|
3121
|
+
case 35:
|
|
3107
3122
|
case "end":
|
|
3108
3123
|
return _context32.stop();
|
|
3109
3124
|
}
|
|
@@ -30,7 +30,6 @@ import { BaseModule } from "../../modules/BaseModule";
|
|
|
30
30
|
import { ShopDiscountHooks } from "./types";
|
|
31
31
|
import { DiscountModule } from "../../modules/Discount";
|
|
32
32
|
import { RulesModule } from "../../modules/Rules";
|
|
33
|
-
import { uniqueById } from "./utils";
|
|
34
33
|
export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
35
34
|
_inherits(ShopDiscountImpl, _BaseModule);
|
|
36
35
|
var _super = _createSuper(ShopDiscountImpl);
|
|
@@ -278,7 +277,9 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
278
277
|
isManualSelect: !isSelected
|
|
279
278
|
});
|
|
280
279
|
}
|
|
281
|
-
return discount
|
|
280
|
+
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
281
|
+
isManualSelect: !(discount !== null && discount !== void 0 && discount.isSelected)
|
|
282
|
+
});
|
|
282
283
|
});
|
|
283
284
|
|
|
284
285
|
// 更新优惠券列表
|
|
@@ -451,9 +452,9 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
451
452
|
});
|
|
452
453
|
}
|
|
453
454
|
});
|
|
454
|
-
var newDiscountList =
|
|
455
|
+
var newDiscountList = [].concat(editModeDiscountList, _toConsumableArray(discountList.filter(function (item) {
|
|
455
456
|
return !item.isDisabled;
|
|
456
|
-
})))
|
|
457
|
+
})));
|
|
457
458
|
(_this$store$discount5 = this.store.discount) === null || _this$store$discount5 === void 0 || _this$store$discount5.setDiscountList(newDiscountList);
|
|
458
459
|
this.emitDiscountListChange(newDiscountList);
|
|
459
460
|
return newDiscountList;
|
|
@@ -73,10 +73,8 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
73
73
|
`/order/prepare/config`,
|
|
74
74
|
params
|
|
75
75
|
);
|
|
76
|
-
const goodPassList = this.
|
|
77
|
-
|
|
78
|
-
((_a = prepareConfig == null ? void 0 : prepareConfig.data) == null ? void 0 : _a.good_pass_list) || []
|
|
79
|
-
) || []
|
|
76
|
+
const goodPassList = this.filterEnabledDiscountList(
|
|
77
|
+
((_a = prepareConfig == null ? void 0 : prepareConfig.data) == null ? void 0 : _a.good_pass_list) || []
|
|
80
78
|
) || [];
|
|
81
79
|
return goodPassList;
|
|
82
80
|
}
|
|
@@ -88,9 +86,7 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
88
86
|
available: 1,
|
|
89
87
|
relation_product: 1
|
|
90
88
|
});
|
|
91
|
-
const resultDiscountList = this.
|
|
92
|
-
this.filterEnabledDiscountList((result == null ? void 0 : result.data) || []) || []
|
|
93
|
-
) || [];
|
|
89
|
+
const resultDiscountList = this.filterEnabledDiscountList((result == null ? void 0 : result.data) || []) || [];
|
|
94
90
|
return resultDiscountList;
|
|
95
91
|
}
|
|
96
92
|
filterEnabledDiscountList(discountList) {
|
|
@@ -216,11 +216,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
216
216
|
{ date, status: "available", week: "", weekNum: 0 },
|
|
217
217
|
{ date, status: "available", week: "", weekNum: 0 }
|
|
218
218
|
]);
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
product_ids = schedule.product_ids;
|
|
223
|
-
}
|
|
219
|
+
const schedule = scheduleList.find((n) => n.date === date);
|
|
220
|
+
if (schedule && ((_a = schedule.product_ids) == null ? void 0 : _a.length)) {
|
|
221
|
+
product_ids = schedule.product_ids;
|
|
224
222
|
}
|
|
225
223
|
const otherProductsIds = this.store.schedule.getOtherProductsIds() || [];
|
|
226
224
|
const allProductIds = [...product_ids, ...otherProductsIds].filter(
|
|
@@ -283,6 +281,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
283
281
|
bundle
|
|
284
282
|
});
|
|
285
283
|
}
|
|
284
|
+
this.core.effects.emit(`${this.store.cart.name}:onUpdateQuotationPrice`, {});
|
|
286
285
|
}
|
|
287
286
|
}
|
|
288
287
|
// 加载当前店铺下所有 schedule
|
|
@@ -2037,7 +2036,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2037
2036
|
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"))) {
|
|
2038
2037
|
startDate = (0, import_dayjs.default)().format("YYYY-MM-DD");
|
|
2039
2038
|
}
|
|
2040
|
-
|
|
2039
|
+
const endDateAfterMonth = (0, import_dayjs.default)().add(1, "month").format("YYYY-MM-DD");
|
|
2040
|
+
if ((0, import_dayjs.default)(startDate).add(7, "day").isAfter((0, import_dayjs.default)(endDateAfterMonth), "day")) {
|
|
2041
|
+
endDate = (0, import_dayjs.default)(startDate).add(7, "day").format("YYYY-MM-DD");
|
|
2042
|
+
} else {
|
|
2043
|
+
endDate = endDateAfterMonth;
|
|
2044
|
+
}
|
|
2041
2045
|
let tempProducts;
|
|
2042
2046
|
tempProducts = (_a = this.store.currentProduct) == null ? void 0 : _a.getData();
|
|
2043
2047
|
const schedule = (_b = this.store.currentProduct) == null ? void 0 : _b.getOtherParams()["schedule"];
|
|
@@ -2170,7 +2174,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2170
2174
|
dateList: dates,
|
|
2171
2175
|
firstAvailableDate,
|
|
2172
2176
|
startDate,
|
|
2173
|
-
endDate
|
|
2177
|
+
endDate: (0, import_dayjs.default)(currentDate).format("YYYY-MM-DD")
|
|
2174
2178
|
});
|
|
2175
2179
|
return {
|
|
2176
2180
|
dateList: dates,
|
|
@@ -27,7 +27,6 @@ var import_BaseModule = require("../../modules/BaseModule");
|
|
|
27
27
|
var import_types = require("./types");
|
|
28
28
|
var import_Discount = require("../../modules/Discount");
|
|
29
29
|
var import_Rules = require("../../modules/Rules");
|
|
30
|
-
var import_utils = require("./utils");
|
|
31
30
|
var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
32
31
|
constructor(name, version) {
|
|
33
32
|
super(name, version);
|
|
@@ -173,7 +172,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
173
172
|
isManualSelect: !isSelected
|
|
174
173
|
};
|
|
175
174
|
}
|
|
176
|
-
return discount;
|
|
175
|
+
return { ...discount, isManualSelect: !(discount == null ? void 0 : discount.isSelected) };
|
|
177
176
|
});
|
|
178
177
|
this.setDiscountList(newDiscountList);
|
|
179
178
|
return this.calcDiscount(this.store.productList || [], {
|
|
@@ -288,13 +287,10 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
288
287
|
});
|
|
289
288
|
}
|
|
290
289
|
});
|
|
291
|
-
const newDiscountList =
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
],
|
|
296
|
-
"product_id"
|
|
297
|
-
);
|
|
290
|
+
const newDiscountList = [
|
|
291
|
+
...editModeDiscountList,
|
|
292
|
+
...discountList.filter((item) => !item.isDisabled)
|
|
293
|
+
];
|
|
298
294
|
(_a = this.store.discount) == null ? void 0 : _a.setDiscountList(newDiscountList);
|
|
299
295
|
this.emitDiscountListChange(newDiscountList);
|
|
300
296
|
return newDiscountList;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": false,
|
|
3
3
|
"name": "@pisell/pisellos",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.37",
|
|
5
5
|
"description": "一个可扩展的前端模块化SDK框架,支持插件系统",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"docs": "typedoc --out docs src/index.ts",
|
|
23
23
|
"sync": "node sync.js",
|
|
24
24
|
"prepublishOnly": "npm run build",
|
|
25
|
-
"deploy": "
|
|
25
|
+
"deploy": "npm run build && npm run changeset && npm run version && npm run release"
|
|
26
26
|
},
|
|
27
27
|
"repository": {
|
|
28
28
|
"type": "git",
|
|
@@ -67,4 +67,4 @@
|
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"access": "public"
|
|
69
69
|
}
|
|
70
|
-
}
|
|
70
|
+
}
|