@pisell/pisellos 2.1.89 → 2.1.91
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/Rules/index.js +6 -6
- package/dist/solution/BookingByStep/index.js +3 -1
- package/dist/solution/BookingByStep/utils/resources.js +2 -1
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Rules/index.js +6 -6
- package/lib/solution/BookingByStep/index.js +5 -1
- package/lib/solution/BookingByStep/utils/resources.js +1 -1
- 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(): "duration" | "session" | "normal";
|
|
53
53
|
}
|
|
@@ -1533,8 +1533,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1533
1533
|
quantity: 1,
|
|
1534
1534
|
discount_list: updatedMainDiscountList,
|
|
1535
1535
|
bundle: newBundleWithDiscount,
|
|
1536
|
-
total: new Decimal(newTotalWithDiscount).toDecimalPlaces(2, Decimal.
|
|
1537
|
-
origin_total: new Decimal(newOriginTotalWithDiscount).toDecimalPlaces(2, Decimal.
|
|
1536
|
+
total: new Decimal(newTotalWithDiscount).toDecimalPlaces(2, Decimal.ROUND_HALF_UP).toNumber(),
|
|
1537
|
+
origin_total: new Decimal(newOriginTotalWithDiscount).toDecimalPlaces(2, Decimal.ROUND_HALF_UP).toNumber()
|
|
1538
1538
|
})));
|
|
1539
1539
|
|
|
1540
1540
|
// 第二个:包含原始bundle (qty=原quantity-1)
|
|
@@ -1596,8 +1596,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1596
1596
|
return accumulator.add(currentPrice.mul(currentNum));
|
|
1597
1597
|
}, new Decimal(newTotalOriginal)).toNumber();
|
|
1598
1598
|
}
|
|
1599
|
-
newTotalOriginal = new Decimal(newTotalOriginal).toDecimalPlaces(2, Decimal.
|
|
1600
|
-
newOriginTotalOriginal = new Decimal(newOriginTotalOriginal).toDecimalPlaces(2, Decimal.
|
|
1599
|
+
newTotalOriginal = new Decimal(newTotalOriginal).toDecimalPlaces(2, Decimal.ROUND_HALF_UP).toNumber();
|
|
1600
|
+
newOriginTotalOriginal = new Decimal(newOriginTotalOriginal).toDecimalPlaces(2, Decimal.ROUND_HALF_UP).toNumber();
|
|
1601
1601
|
|
|
1602
1602
|
// 添加第二个主商品:qty=原quantity-1,包含原始bundle
|
|
1603
1603
|
result.push(_this3.hooks.setProduct(mainProduct, _objectSpread(_objectSpread({}, mainProductData), {}, {
|
|
@@ -1702,8 +1702,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1702
1702
|
return accumulator.add(currentPrice.mul(currentNum));
|
|
1703
1703
|
}, new Decimal(newTotal)).toNumber();
|
|
1704
1704
|
}
|
|
1705
|
-
newTotal = new Decimal(newTotal).toDecimalPlaces(2, Decimal.
|
|
1706
|
-
newOriginTotal = new Decimal(newOriginTotal).toDecimalPlaces(2, Decimal.
|
|
1705
|
+
newTotal = new Decimal(newTotal).toDecimalPlaces(2, Decimal.ROUND_HALF_UP).toNumber();
|
|
1706
|
+
newOriginTotal = new Decimal(newOriginTotal).toDecimalPlaces(2, Decimal.ROUND_HALF_UP).toNumber();
|
|
1707
1707
|
|
|
1708
1708
|
// 生成最终的主商品
|
|
1709
1709
|
result.push(_this3.hooks.setProduct(mainProduct, _objectSpread(_objectSpread({}, mainProductData), {}, {
|
|
@@ -1818,7 +1818,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1818
1818
|
timeSlots: timeSlots,
|
|
1819
1819
|
currentCapacity: totalCapacity + (capacity || 0)
|
|
1820
1820
|
});
|
|
1821
|
-
if (canUseTime && !n.onlyComputed && currentResourceIdleTime > targetResourceTime) {
|
|
1821
|
+
if (canUseTime && !n.onlyComputed && currentResourceIdleTime > targetResourceTime && n.capacity >= (capacity || 0)) {
|
|
1822
1822
|
targetResource = n;
|
|
1823
1823
|
targetResourceTime = currentResourceIdleTime;
|
|
1824
1824
|
return 1; // break
|
|
@@ -2213,6 +2213,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2213
2213
|
// 计算容量的辅助函数
|
|
2214
2214
|
var calculateCapacityFromCartItems = function calculateCapacityFromCartItems(items) {
|
|
2215
2215
|
var _items$0$_resourceOri;
|
|
2216
|
+
if (items.length === 0) return 0;
|
|
2216
2217
|
// 还需要增加一个判断,maxCapacity 必须是我单个人里选择的资源只有同一种的情况下才可以累加,否则单个账号都是 1
|
|
2217
2218
|
var firstResource = (_items$0$_resourceOri = items[0]._resourceOrigin) === null || _items$0$_resourceOri === void 0 ? void 0 : _items$0$_resourceOri[0].id;
|
|
2218
2219
|
var sameResourceLength = items.filter(function (item) {
|
|
@@ -2387,6 +2388,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2387
2388
|
// 计算容量的辅助函数
|
|
2388
2389
|
calculateCapacityFromCartItems = function calculateCapacityFromCartItems(items) {
|
|
2389
2390
|
var _items$0$_resourceOri2;
|
|
2391
|
+
if (items.length === 0) return 0;
|
|
2390
2392
|
// 还需要增加一个判断,maxCapacity 必须是我单个人里选择的资源只有同一种的情况下才可以累加,否则单个账号都是 1
|
|
2391
2393
|
var firstResource = (_items$0$_resourceOri2 = items[0]._resourceOrigin) === null || _items$0$_resourceOri2 === void 0 ? void 0 : _items$0$_resourceOri2[0].id;
|
|
2392
2394
|
var sameResourceLength = items.filter(function (item) {
|
|
@@ -349,7 +349,8 @@ export var getResourcesByProduct = function getResourcesByProduct(resourcesMap,
|
|
|
349
349
|
return dayjs(current.end_at).isAfter(dayjs(latest.end_at)) ? current : latest;
|
|
350
350
|
}, d.times[0]);
|
|
351
351
|
// TODO,在这拉时间切片出来,如果可用 timeSlots.length > 1 才可以被选择
|
|
352
|
-
|
|
352
|
+
// 当前资源的配置容量需要大于当前需求的 capacity
|
|
353
|
+
return dayjs(latestTime.end_at).isAfter(dayjs()) && d.capacity >= capacity;
|
|
353
354
|
});
|
|
354
355
|
item.form_id = form_id;
|
|
355
356
|
acc.push(item);
|
|
@@ -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(): "duration" | "session" | "normal";
|
|
53
53
|
}
|
|
@@ -1153,8 +1153,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1153
1153
|
quantity: 1,
|
|
1154
1154
|
discount_list: updatedMainDiscountList,
|
|
1155
1155
|
bundle: newBundleWithDiscount,
|
|
1156
|
-
total: new import_decimal.default(newTotalWithDiscount).toDecimalPlaces(2, import_decimal.default.
|
|
1157
|
-
origin_total: new import_decimal.default(newOriginTotalWithDiscount).toDecimalPlaces(2, import_decimal.default.
|
|
1156
|
+
total: new import_decimal.default(newTotalWithDiscount).toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP).toNumber(),
|
|
1157
|
+
origin_total: new import_decimal.default(newOriginTotalWithDiscount).toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP).toNumber()
|
|
1158
1158
|
})
|
|
1159
1159
|
);
|
|
1160
1160
|
if (mainProductQuantity > 1) {
|
|
@@ -1204,8 +1204,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1204
1204
|
return accumulator.add(currentPrice.mul(currentNum));
|
|
1205
1205
|
}, new import_decimal.default(newTotalOriginal)).toNumber();
|
|
1206
1206
|
}
|
|
1207
|
-
newTotalOriginal = new import_decimal.default(newTotalOriginal).toDecimalPlaces(2, import_decimal.default.
|
|
1208
|
-
newOriginTotalOriginal = new import_decimal.default(newOriginTotalOriginal).toDecimalPlaces(2, import_decimal.default.
|
|
1207
|
+
newTotalOriginal = new import_decimal.default(newTotalOriginal).toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP).toNumber();
|
|
1208
|
+
newOriginTotalOriginal = new import_decimal.default(newOriginTotalOriginal).toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP).toNumber();
|
|
1209
1209
|
result.push(
|
|
1210
1210
|
this.hooks.setProduct(mainProduct, {
|
|
1211
1211
|
...mainProductData,
|
|
@@ -1289,8 +1289,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1289
1289
|
return accumulator.add(currentPrice.mul(currentNum));
|
|
1290
1290
|
}, new import_decimal.default(newTotal)).toNumber();
|
|
1291
1291
|
}
|
|
1292
|
-
newTotal = new import_decimal.default(newTotal).toDecimalPlaces(2, import_decimal.default.
|
|
1293
|
-
newOriginTotal = new import_decimal.default(newOriginTotal).toDecimalPlaces(2, import_decimal.default.
|
|
1292
|
+
newTotal = new import_decimal.default(newTotal).toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP).toNumber();
|
|
1293
|
+
newOriginTotal = new import_decimal.default(newOriginTotal).toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP).toNumber();
|
|
1294
1294
|
result.push(
|
|
1295
1295
|
this.hooks.setProduct(mainProduct, {
|
|
1296
1296
|
...mainProductData,
|
|
@@ -1181,7 +1181,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1181
1181
|
timeSlots,
|
|
1182
1182
|
currentCapacity: totalCapacity + (capacity || 0)
|
|
1183
1183
|
});
|
|
1184
|
-
if (canUseTime && !n.onlyComputed && currentResourceIdleTime > targetResourceTime) {
|
|
1184
|
+
if (canUseTime && !n.onlyComputed && currentResourceIdleTime > targetResourceTime && n.capacity >= (capacity || 0)) {
|
|
1185
1185
|
targetResource = n;
|
|
1186
1186
|
targetResourceTime = currentResourceIdleTime;
|
|
1187
1187
|
break;
|
|
@@ -1533,6 +1533,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1533
1533
|
}
|
|
1534
1534
|
const calculateCapacityFromCartItems = (items) => {
|
|
1535
1535
|
var _a2;
|
|
1536
|
+
if (items.length === 0)
|
|
1537
|
+
return 0;
|
|
1536
1538
|
const firstResource = (_a2 = items[0]._resourceOrigin) == null ? void 0 : _a2[0].id;
|
|
1537
1539
|
const sameResourceLength = items.filter((item) => {
|
|
1538
1540
|
var _a3;
|
|
@@ -1666,6 +1668,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1666
1668
|
}
|
|
1667
1669
|
const calculateCapacityFromCartItems = (items) => {
|
|
1668
1670
|
var _a2;
|
|
1671
|
+
if (items.length === 0)
|
|
1672
|
+
return 0;
|
|
1669
1673
|
const firstResource = (_a2 = items[0]._resourceOrigin) == null ? void 0 : _a2[0].id;
|
|
1670
1674
|
const sameResourceLength = items.filter((item) => {
|
|
1671
1675
|
var _a3;
|
|
@@ -298,7 +298,7 @@ var getResourcesByProduct = (resourcesMap, resources, selectedResources, capacit
|
|
|
298
298
|
const latestTime = d.times.reduce((latest, current) => {
|
|
299
299
|
return (0, import_dayjs.default)(current.end_at).isAfter((0, import_dayjs.default)(latest.end_at)) ? current : latest;
|
|
300
300
|
}, d.times[0]);
|
|
301
|
-
return (0, import_dayjs.default)(latestTime.end_at).isAfter((0, import_dayjs.default)());
|
|
301
|
+
return (0, import_dayjs.default)(latestTime.end_at).isAfter((0, import_dayjs.default)()) && d.capacity >= capacity;
|
|
302
302
|
});
|
|
303
303
|
item.form_id = form_id;
|
|
304
304
|
acc.push(item);
|