@pisell/pisellos 0.0.51 → 0.0.52
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.
|
@@ -598,8 +598,15 @@ export var handleProductDeposit = function handleProductDeposit(params) {
|
|
|
598
598
|
var depositData = params.depositData,
|
|
599
599
|
total = params.total,
|
|
600
600
|
num = params.num;
|
|
601
|
-
|
|
602
|
-
|
|
601
|
+
if (!depositData) {
|
|
602
|
+
return {
|
|
603
|
+
result: false,
|
|
604
|
+
depositTotal: new Decimal(0)
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
var _ref3 = depositData || {},
|
|
608
|
+
deposit_fixed = _ref3.deposit_fixed,
|
|
609
|
+
deposit_percentage = _ref3.deposit_percentage;
|
|
603
610
|
if (typeof deposit_fixed === 'string' && typeof deposit_percentage === 'string') {
|
|
604
611
|
var depositFixed = Decimal(deposit_fixed || 0);
|
|
605
612
|
var depositPercent = Decimal(deposit_percentage || 0);
|
|
@@ -1311,11 +1311,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1311
1311
|
var accountCartItems = cartItems.filter(function (n) {
|
|
1312
1312
|
return n.holder_id === holder_id;
|
|
1313
1313
|
}) || [];
|
|
1314
|
-
//
|
|
1314
|
+
// 账号下没商品则处理所有购物车
|
|
1315
1315
|
if (!accountCartItems.length) {
|
|
1316
|
-
|
|
1317
|
-
selectedResource: null
|
|
1318
|
-
};
|
|
1316
|
+
accountCartItems = cartItems;
|
|
1319
1317
|
}
|
|
1320
1318
|
// duration=所有商品时间的集合
|
|
1321
1319
|
var duration = accountCartItems.reduce(function (acc, n) {
|
|
@@ -1413,8 +1411,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1413
1411
|
// 一个账号一个账号处理
|
|
1414
1412
|
var errorList = [];
|
|
1415
1413
|
var selectResourcesMap = {};
|
|
1416
|
-
this.store.accountList.getAccounts()
|
|
1417
|
-
|
|
1414
|
+
var accountList = this.store.accountList.getAccounts();
|
|
1415
|
+
var selectForCartResources = function selectForCartResources(cartItems) {
|
|
1418
1416
|
var recordTimeSlots = cloneDeep(timeSlots);
|
|
1419
1417
|
// timeSlots 传进来的只是用户选中的时间片,但是实际上需要根据多个商品时间进行累加
|
|
1420
1418
|
// 假设 timeSlots.start_time 是15:40 duration 是 30min
|
|
@@ -1429,7 +1427,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1429
1427
|
var currentCapacity = getSumCapacity({
|
|
1430
1428
|
capacity: formatCapacity
|
|
1431
1429
|
});
|
|
1432
|
-
|
|
1430
|
+
// 如果商品已经有时间数据了,意味着是通过先选日期再选商品流程进来的,相当于时间切片已经选中了
|
|
1431
|
+
if (item._origin.start_time && !(timeSlots !== null && timeSlots !== void 0 && timeSlots.start_time)) {
|
|
1432
|
+
recordTimeSlots = {
|
|
1433
|
+
start_time: item._origin.start_time,
|
|
1434
|
+
end_time: item._origin.end_time,
|
|
1435
|
+
start_at: dayjs("".concat(item.start_date, " ").concat(item._origin.start_time)),
|
|
1436
|
+
end_at: dayjs("".concat(item.end_date, " ").concat(item._origin.end_time))
|
|
1437
|
+
};
|
|
1438
|
+
}
|
|
1439
|
+
if (recordTimeSlots) {
|
|
1433
1440
|
if (index !== 0 && recordTimeSlots) {
|
|
1434
1441
|
var _item$_productOrigin$, _item$_productOrigin3, _ref10, _item$_productOrigin4, _item$_productOrigin$2, _item$_productOrigin5, _ref11, _item$_productOrigin6;
|
|
1435
1442
|
var start_at = dayjs(recordTimeSlots.end_time).add((_item$_productOrigin$ = (_item$_productOrigin3 = item._productOrigin) === null || _item$_productOrigin3 === void 0 || (_item$_productOrigin3 = _item$_productOrigin3.duration) === null || _item$_productOrigin3 === void 0 ? void 0 : _item$_productOrigin3.value) !== null && _item$_productOrigin$ !== void 0 ? _item$_productOrigin$ : 0, (_ref10 = (_item$_productOrigin4 = item._productOrigin) === null || _item$_productOrigin4 === void 0 || (_item$_productOrigin4 = _item$_productOrigin4.duration) === null || _item$_productOrigin4 === void 0 ? void 0 : _item$_productOrigin4.type) !== null && _ref10 !== void 0 ? _ref10 : 'minutes');
|
|
@@ -1506,14 +1513,24 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1506
1513
|
return existingRes.resourceType !== targetRenderList[0].resourceType;
|
|
1507
1514
|
})), [targetResource])
|
|
1508
1515
|
});
|
|
1509
|
-
console.log(account, '已分配');
|
|
1510
1516
|
} else {
|
|
1511
1517
|
// 如果没有可用的技师了,推到错误列表里让 UI 去提示
|
|
1512
1518
|
errorList.push(item._id);
|
|
1513
1519
|
}
|
|
1514
1520
|
}
|
|
1515
1521
|
});
|
|
1516
|
-
}
|
|
1522
|
+
};
|
|
1523
|
+
var cartItems = this.store.cart.getItems();
|
|
1524
|
+
|
|
1525
|
+
// 如果购物车里没有 holderid数据,证明不按 holder 类流程预约走,给所有购物车一次性分派即可,不做账号下资源互斥逻辑
|
|
1526
|
+
if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
|
|
1527
|
+
accountList.forEach(function (account) {
|
|
1528
|
+
var cartItems = _this7.store.cart.getCartByAccount(account.getId());
|
|
1529
|
+
selectForCartResources(cartItems);
|
|
1530
|
+
});
|
|
1531
|
+
} else {
|
|
1532
|
+
selectForCartResources(cartItems);
|
|
1533
|
+
}
|
|
1517
1534
|
return {
|
|
1518
1535
|
errorList: errorList
|
|
1519
1536
|
};
|
|
@@ -475,7 +475,10 @@ var getProductDeposit = (params) => {
|
|
|
475
475
|
};
|
|
476
476
|
var handleProductDeposit = (params) => {
|
|
477
477
|
const { depositData, total, num } = params;
|
|
478
|
-
|
|
478
|
+
if (!depositData) {
|
|
479
|
+
return { result: false, depositTotal: new import_decimal.default(0) };
|
|
480
|
+
}
|
|
481
|
+
const { deposit_fixed, deposit_percentage } = depositData || {};
|
|
479
482
|
if (typeof deposit_fixed === "string" && typeof deposit_percentage === "string") {
|
|
480
483
|
const depositFixed = (0, import_decimal.default)(deposit_fixed || 0);
|
|
481
484
|
const depositPercent = (0, import_decimal.default)(deposit_percentage || 0);
|
|
@@ -744,11 +744,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
744
744
|
}) {
|
|
745
745
|
const dateRange = this.store.date.getDateRange();
|
|
746
746
|
const cartItems = this.store.cart.getItems();
|
|
747
|
-
|
|
747
|
+
let accountCartItems = cartItems.filter((n) => n.holder_id === holder_id) || [];
|
|
748
748
|
if (!accountCartItems.length) {
|
|
749
|
-
|
|
750
|
-
selectedResource: null
|
|
751
|
-
};
|
|
749
|
+
accountCartItems = cartItems;
|
|
752
750
|
}
|
|
753
751
|
let duration = accountCartItems.reduce((acc, n) => {
|
|
754
752
|
var _a, _b;
|
|
@@ -815,17 +813,25 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
815
813
|
const resourcesMap = (0, import_utils.getResourcesMap)((0, import_lodash_es.cloneDeep)(resources));
|
|
816
814
|
const errorList = [];
|
|
817
815
|
const selectResourcesMap = {};
|
|
818
|
-
this.store.accountList.getAccounts()
|
|
819
|
-
|
|
816
|
+
const accountList = this.store.accountList.getAccounts();
|
|
817
|
+
const selectForCartResources = (cartItems2) => {
|
|
820
818
|
let recordTimeSlots = (0, import_lodash_es.cloneDeep)(timeSlots);
|
|
821
|
-
|
|
819
|
+
cartItems2.forEach((item, index) => {
|
|
822
820
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
823
821
|
const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
|
|
824
822
|
capacity: (_a = item._productOrigin) == null ? void 0 : _a.capacity,
|
|
825
823
|
product_bundle: item._origin.product.product_bundle
|
|
826
824
|
});
|
|
827
825
|
const currentCapacity = (0, import_resources.getSumCapacity)({ capacity: formatCapacity });
|
|
828
|
-
if (timeSlots) {
|
|
826
|
+
if (item._origin.start_time && !(timeSlots == null ? void 0 : timeSlots.start_time)) {
|
|
827
|
+
recordTimeSlots = {
|
|
828
|
+
start_time: item._origin.start_time,
|
|
829
|
+
end_time: item._origin.end_time,
|
|
830
|
+
start_at: (0, import_dayjs.default)(`${item.start_date} ${item._origin.start_time}`),
|
|
831
|
+
end_at: (0, import_dayjs.default)(`${item.end_date} ${item._origin.end_time}`)
|
|
832
|
+
};
|
|
833
|
+
}
|
|
834
|
+
if (recordTimeSlots) {
|
|
829
835
|
if (index !== 0 && recordTimeSlots) {
|
|
830
836
|
let start_at = (0, import_dayjs.default)(recordTimeSlots.end_time).add(
|
|
831
837
|
((_c = (_b = item._productOrigin) == null ? void 0 : _b.duration) == null ? void 0 : _c.value) ?? 0,
|
|
@@ -913,13 +919,21 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
913
919
|
targetResource
|
|
914
920
|
]
|
|
915
921
|
});
|
|
916
|
-
console.log(account, "已分配");
|
|
917
922
|
} else {
|
|
918
923
|
errorList.push(item._id);
|
|
919
924
|
}
|
|
920
925
|
}
|
|
921
926
|
});
|
|
922
|
-
}
|
|
927
|
+
};
|
|
928
|
+
const cartItems = this.store.cart.getItems();
|
|
929
|
+
if (cartItems == null ? void 0 : cartItems[0].holder_id) {
|
|
930
|
+
accountList.forEach((account) => {
|
|
931
|
+
const cartItems2 = this.store.cart.getCartByAccount(account.getId());
|
|
932
|
+
selectForCartResources(cartItems2);
|
|
933
|
+
});
|
|
934
|
+
} else {
|
|
935
|
+
selectForCartResources(cartItems);
|
|
936
|
+
}
|
|
923
937
|
return { errorList };
|
|
924
938
|
}
|
|
925
939
|
// 从购物车中获取已经分配好第一步资源的所有时间片
|
|
@@ -964,14 +978,17 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
964
978
|
// 提交时间切片,绑定到对应购物车的商品上,更新购物车
|
|
965
979
|
submitTimeSlot(timeSlots) {
|
|
966
980
|
const cartItems = this.store.cart.getItems();
|
|
967
|
-
const itemsByAccount = cartItems.reduce(
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
acc[holderId]
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
981
|
+
const itemsByAccount = cartItems.reduce(
|
|
982
|
+
(acc, item) => {
|
|
983
|
+
const holderId = item.holder_id;
|
|
984
|
+
if (!acc[holderId]) {
|
|
985
|
+
acc[holderId] = [];
|
|
986
|
+
}
|
|
987
|
+
acc[holderId].push(item);
|
|
988
|
+
return acc;
|
|
989
|
+
},
|
|
990
|
+
{}
|
|
991
|
+
);
|
|
975
992
|
Object.values(itemsByAccount).forEach((accountItems) => {
|
|
976
993
|
let currentStartTime = timeSlots.start_at.format("YYYY-MM-DD HH:mm");
|
|
977
994
|
accountItems.forEach((item, index) => {
|
|
@@ -1123,7 +1140,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1123
1140
|
});
|
|
1124
1141
|
if (date) {
|
|
1125
1142
|
const cartItems = this.store.cart.getItems();
|
|
1126
|
-
const cartItemsByDate = cartItems.filter(
|
|
1143
|
+
const cartItemsByDate = cartItems.filter(
|
|
1144
|
+
(n) => !(0, import_dayjs.default)(n.start_date).isSame((0, import_dayjs.default)(date.startTime), "day")
|
|
1145
|
+
);
|
|
1127
1146
|
if (cartItemsByDate.length) {
|
|
1128
1147
|
cartItemsByDate.forEach((n) => {
|
|
1129
1148
|
this.store.cart.removeItem(n._id);
|