@pisell/pisellos 0.0.433 → 0.0.435
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/Product/index.d.ts +1 -1
- package/dist/modules/Summary/utils.js +2 -3
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingByStep/index.js +23 -8
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Summary/utils.js +2 -3
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingByStep/index.js +9 -8
- package/package.json +1 -1
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
|
@@ -336,7 +336,6 @@ var processItemsTax = function processItemsTax(items, _ref2, options) {
|
|
|
336
336
|
var bundlePreciseTax = new Decimal(0);
|
|
337
337
|
var bundleRoundedOriginTax = new Decimal(0);
|
|
338
338
|
var bundleRoundedTax = new Decimal(0);
|
|
339
|
-
debugger;
|
|
340
339
|
if (Array.isArray(item === null || item === void 0 ? void 0 : item.bundle)) {
|
|
341
340
|
var _iterator3 = _createForOfIteratorHelper(item === null || item === void 0 ? void 0 : item.bundle),
|
|
342
341
|
_step3;
|
|
@@ -678,9 +677,9 @@ var getDiscountAmount = function getDiscountAmount(discounts) {
|
|
|
678
677
|
* 获取主商品加价减价后的总价 (主商品价格 + 子商品加价减价)
|
|
679
678
|
*/
|
|
680
679
|
var getMainProductTotal = function getMainProductTotal(item) {
|
|
681
|
-
var _ref7, _ref8, _item$main_product_se, _item$metadata, _item$_origin3, _item$_originData
|
|
680
|
+
var _ref7, _ref8, _item$main_product_se, _item$metadata, _item$_origin3, _item$_originData;
|
|
682
681
|
var total = new Decimal((_ref7 = (_ref8 = (_item$main_product_se = item === null || item === void 0 ? void 0 : item.main_product_selling_price) !== null && _item$main_product_se !== void 0 ? _item$main_product_se : item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.main_product_selling_price) !== null && _ref8 !== void 0 ? _ref8 : item.price) !== null && _ref7 !== void 0 ? _ref7 : 0);
|
|
683
|
-
var mainProductDiscountAmount = getDiscountAmount((item === null || item === void 0 || (_item$_origin3 = item._origin) === null || _item$_origin3 === void 0 || (_item$_origin3 = _item$_origin3.product) === null || _item$_origin3 === void 0 ? void 0 : _item$_origin3.discount_list) || (item === null || item === void 0 || (_item$_originData
|
|
682
|
+
var mainProductDiscountAmount = getDiscountAmount((item === null || item === void 0 || (_item$_origin3 = item._origin) === null || _item$_origin3 === void 0 || (_item$_origin3 = _item$_origin3.product) === null || _item$_origin3 === void 0 ? void 0 : _item$_origin3.discount_list) || (item === null || item === void 0 || (_item$_originData = item._originData) === null || _item$_originData === void 0 || (_item$_originData = _item$_originData.product) === null || _item$_originData === void 0 ? void 0 : _item$_originData.discount_list) || []);
|
|
684
683
|
total = total.minus(mainProductDiscountAmount);
|
|
685
684
|
|
|
686
685
|
// 单规格
|
|
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
311
|
date: string;
|
|
312
312
|
status: string;
|
|
313
313
|
week: string;
|
|
314
|
-
weekNum: 0 |
|
|
314
|
+
weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -358,7 +358,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
358
358
|
};
|
|
359
359
|
setOtherData(key: string, value: any): void;
|
|
360
360
|
getOtherData(key: string): any;
|
|
361
|
-
getProductTypeById(id: number): Promise<"
|
|
361
|
+
getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
|
|
362
362
|
/**
|
|
363
363
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
364
364
|
*
|
|
@@ -1163,7 +1163,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1163
1163
|
var productData = _objectSpread(_objectSpread({}, origin), {}, {
|
|
1164
1164
|
product_variant_id: product_variant_id
|
|
1165
1165
|
});
|
|
1166
|
-
debugger;
|
|
1167
1166
|
// 保护,如果进来的是 session 商品,则必须要有 date 和时间片,否则不允许添加
|
|
1168
1167
|
if (isSessionProduct(productData)) {
|
|
1169
1168
|
if (!date || !date.startTime || !date.endTime) {
|
|
@@ -2138,6 +2137,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2138
2137
|
}
|
|
2139
2138
|
});
|
|
2140
2139
|
}
|
|
2140
|
+
|
|
2141
|
+
// 如果依然 resources 空的,则证明他是切换日期了,此时直接从 date 模块里取
|
|
2142
|
+
if (resources.length === 0) {
|
|
2143
|
+
resources.push.apply(resources, _toConsumableArray(this.store.date.getResourcesListByDate(dateRange[0].date) || []));
|
|
2144
|
+
}
|
|
2141
2145
|
var resourcesMap = getResourcesMap(resources);
|
|
2142
2146
|
var duration = 0;
|
|
2143
2147
|
// duration = 不同账号的最长时间
|
|
@@ -2217,12 +2221,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2217
2221
|
var _item$_resourceOrigin;
|
|
2218
2222
|
return ((_item$_resourceOrigin = item._resourceOrigin) === null || _item$_resourceOrigin === void 0 ? void 0 : _item$_resourceOrigin[0].id) === firstResource;
|
|
2219
2223
|
}).length;
|
|
2220
|
-
if (sameResourceLength
|
|
2224
|
+
if (sameResourceLength === items.length) {
|
|
2221
2225
|
return 1;
|
|
2222
2226
|
}
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2227
|
+
// 找出单个购物车里最大的需求 capacity 即可
|
|
2228
|
+
return Math.max.apply(Math, _toConsumableArray(items.map(function (item) {
|
|
2229
|
+
return getCapacityInfoByCartItem(item).currentCapacity || 1;
|
|
2230
|
+
})));
|
|
2231
|
+
// return items.reduce((total, item) => {
|
|
2232
|
+
// return total + (getCapacityInfoByCartItem(item).currentCapacity || 0);
|
|
2233
|
+
// }, 0);
|
|
2226
2234
|
};
|
|
2227
2235
|
|
|
2228
2236
|
// 如果是多个人预约,去要求出几个 holder 下最大的商品需求容量capacity
|
|
@@ -2390,9 +2398,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2390
2398
|
if (sameResourceLength !== items.length) {
|
|
2391
2399
|
return 1;
|
|
2392
2400
|
}
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2401
|
+
// 找出单个购物车里最大的需求 capacity 即可
|
|
2402
|
+
return Math.max.apply(Math, _toConsumableArray(items.map(function (item) {
|
|
2403
|
+
return getCapacityInfoByCartItem(item).currentCapacity || 1;
|
|
2404
|
+
})));
|
|
2396
2405
|
}; // 如果是多个预约,去要求出几个 holder 下最大的需求容量capacity
|
|
2397
2406
|
maxCapacity = 1;
|
|
2398
2407
|
if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
|
|
@@ -3155,6 +3164,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3155
3164
|
itemsByResourceType[resourceCode] = [];
|
|
3156
3165
|
}
|
|
3157
3166
|
// 避免重复添加同一个商品
|
|
3167
|
+
// 如果之前添加过的依赖相同资源的跟我现在是同一个 holder,也不需要重复添加
|
|
3168
|
+
if (itemsByResourceType[resourceCode].find(function (item) {
|
|
3169
|
+
return item.holder_id === cartItem.holder_id;
|
|
3170
|
+
})) {
|
|
3171
|
+
return;
|
|
3172
|
+
}
|
|
3158
3173
|
if (!itemsByResourceType[resourceCode].find(function (item) {
|
|
3159
3174
|
return item._id === cartItem._id;
|
|
3160
3175
|
})) {
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
|
@@ -212,7 +212,6 @@ var processItemsTax = (items, { bookingDetail, bookingId }, options) => {
|
|
|
212
212
|
let bundlePreciseTax = new import_decimal.default(0);
|
|
213
213
|
let bundleRoundedOriginTax = new import_decimal.default(0);
|
|
214
214
|
let bundleRoundedTax = new import_decimal.default(0);
|
|
215
|
-
debugger;
|
|
216
215
|
if (Array.isArray(item == null ? void 0 : item.bundle)) {
|
|
217
216
|
for (let bundleItem of item == null ? void 0 : item.bundle) {
|
|
218
217
|
if (getBundleItemIsOriginalPrice(bundleItem)) {
|
|
@@ -409,9 +408,9 @@ var getDiscountAmount = (discounts) => {
|
|
|
409
408
|
}, new import_decimal.default(0)).toNumber();
|
|
410
409
|
};
|
|
411
410
|
var getMainProductTotal = (item) => {
|
|
412
|
-
var _a, _b, _c, _d;
|
|
411
|
+
var _a, _b, _c, _d, _e;
|
|
413
412
|
let total = new import_decimal.default((item == null ? void 0 : item.main_product_selling_price) ?? ((_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a.main_product_selling_price) ?? item.price ?? 0);
|
|
414
|
-
const mainProductDiscountAmount = getDiscountAmount(((_c = (_b = item == null ? void 0 : item._origin) == null ? void 0 : _b.product) == null ? void 0 : _c.discount_list) || ((_d = item == null ? void 0 : item._originData.product) == null ? void 0 :
|
|
413
|
+
const mainProductDiscountAmount = getDiscountAmount(((_c = (_b = item == null ? void 0 : item._origin) == null ? void 0 : _b.product) == null ? void 0 : _c.discount_list) || ((_e = (_d = item == null ? void 0 : item._originData) == null ? void 0 : _d.product) == null ? void 0 : _e.discount_list) || []);
|
|
415
414
|
total = total.minus(mainProductDiscountAmount);
|
|
416
415
|
if ((item == null ? void 0 : item.option) && Array.isArray(item == null ? void 0 : item.option)) {
|
|
417
416
|
total = total.add(item == null ? void 0 : item.option.reduce((t, option) => {
|
|
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
311
|
date: string;
|
|
312
312
|
status: string;
|
|
313
313
|
week: string;
|
|
314
|
-
weekNum: 0 |
|
|
314
|
+
weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -358,7 +358,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
358
358
|
};
|
|
359
359
|
setOtherData(key: string, value: any): void;
|
|
360
360
|
getOtherData(key: string): any;
|
|
361
|
-
getProductTypeById(id: number): Promise<"
|
|
361
|
+
getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
|
|
362
362
|
/**
|
|
363
363
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
364
364
|
*
|
|
@@ -608,7 +608,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
608
608
|
quantity = 1
|
|
609
609
|
} = product || {};
|
|
610
610
|
const productData = { ...origin, product_variant_id };
|
|
611
|
-
debugger;
|
|
612
611
|
if ((0, import_products.isSessionProduct)(productData)) {
|
|
613
612
|
if (!date || !date.startTime || !date.endTime) {
|
|
614
613
|
return { success: false, errorCode: "date_or_time_required" };
|
|
@@ -1464,6 +1463,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1464
1463
|
}
|
|
1465
1464
|
});
|
|
1466
1465
|
}
|
|
1466
|
+
if (resources.length === 0) {
|
|
1467
|
+
resources.push(...this.store.date.getResourcesListByDate(dateRange[0].date) || []);
|
|
1468
|
+
}
|
|
1467
1469
|
const resourcesMap = (0, import_utils2.getResourcesMap)(resources);
|
|
1468
1470
|
let duration = 0;
|
|
1469
1471
|
const accountList = this.store.accountList.getAccounts();
|
|
@@ -1538,12 +1540,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1538
1540
|
var _a3;
|
|
1539
1541
|
return ((_a3 = item._resourceOrigin) == null ? void 0 : _a3[0].id) === firstResource;
|
|
1540
1542
|
}).length;
|
|
1541
|
-
if (sameResourceLength
|
|
1543
|
+
if (sameResourceLength === items.length) {
|
|
1542
1544
|
return 1;
|
|
1543
1545
|
}
|
|
1544
|
-
return items.
|
|
1545
|
-
return total + ((0, import_capacity.getCapacityInfoByCartItem)(item).currentCapacity || 0);
|
|
1546
|
-
}, 0);
|
|
1546
|
+
return Math.max(...items.map((item) => (0, import_capacity.getCapacityInfoByCartItem)(item).currentCapacity || 1));
|
|
1547
1547
|
};
|
|
1548
1548
|
let maxCapacity = 1;
|
|
1549
1549
|
if (cartItems == null ? void 0 : cartItems[0].holder_id) {
|
|
@@ -1676,9 +1676,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1676
1676
|
if (sameResourceLength !== items.length) {
|
|
1677
1677
|
return 1;
|
|
1678
1678
|
}
|
|
1679
|
-
return items.
|
|
1680
|
-
return total + ((0, import_capacity.getCapacityInfoByCartItem)(item).currentCapacity || 0);
|
|
1681
|
-
}, 0);
|
|
1679
|
+
return Math.max(...items.map((item) => (0, import_capacity.getCapacityInfoByCartItem)(item).currentCapacity || 1));
|
|
1682
1680
|
};
|
|
1683
1681
|
let maxCapacity = 1;
|
|
1684
1682
|
if (cartItems == null ? void 0 : cartItems[0].holder_id) {
|
|
@@ -2267,6 +2265,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2267
2265
|
if (!itemsByResourceType[resourceCode]) {
|
|
2268
2266
|
itemsByResourceType[resourceCode] = [];
|
|
2269
2267
|
}
|
|
2268
|
+
if (itemsByResourceType[resourceCode].find((item) => item.holder_id === cartItem.holder_id)) {
|
|
2269
|
+
return;
|
|
2270
|
+
}
|
|
2270
2271
|
if (!itemsByResourceType[resourceCode].find((item) => item._id === cartItem._id)) {
|
|
2271
2272
|
itemsByResourceType[resourceCode].push(cartItem);
|
|
2272
2273
|
}
|