@pisell/pisellos 0.0.51 → 0.0.53
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/Cart/types.d.ts +1 -1
- package/dist/modules/Cart/utils.d.ts +3 -3
- package/dist/modules/Cart/utils.js +9 -11
- package/dist/solution/BookingByStep/index.js +34 -13
- package/lib/modules/Cart/types.d.ts +1 -1
- package/lib/modules/Cart/utils.d.ts +3 -3
- package/lib/modules/Cart/utils.js +4 -10
- package/lib/solution/BookingByStep/index.js +49 -25
- package/package.json +1 -1
|
@@ -98,14 +98,14 @@ export declare const formatResourceToCartItemOrigin: (params: {
|
|
|
98
98
|
export declare const formatRelationFormsToCartItem: (params: {
|
|
99
99
|
cartItem: CartItem;
|
|
100
100
|
relationForms: {
|
|
101
|
-
form_id: number
|
|
101
|
+
form_id: number;
|
|
102
102
|
form_record_ids: number[];
|
|
103
103
|
}[];
|
|
104
104
|
}) => CartItem;
|
|
105
105
|
export declare const formatRelationFormsToCartItemOrigin: (params: {
|
|
106
106
|
cartItem: CartItem;
|
|
107
107
|
relationForms: {
|
|
108
|
-
form_id: number
|
|
108
|
+
form_id: number;
|
|
109
109
|
form_record_ids: number[];
|
|
110
110
|
}[];
|
|
111
111
|
}) => any;
|
|
@@ -230,8 +230,8 @@ export declare const handleProductDeposit: (params: {
|
|
|
230
230
|
total: string | number;
|
|
231
231
|
num: number;
|
|
232
232
|
}) => {
|
|
233
|
-
depositTotal: Decimal;
|
|
234
233
|
result: boolean;
|
|
234
|
+
depositTotal: Decimal;
|
|
235
235
|
};
|
|
236
236
|
/**
|
|
237
237
|
* 从购物车中删除资源相关信息
|
|
@@ -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);
|
|
@@ -625,21 +632,12 @@ export var deleteResourceFromCartItem = function deleteResourceFromCartItem(cart
|
|
|
625
632
|
// 删除UI层的数据
|
|
626
633
|
cartItem.resource_id = undefined;
|
|
627
634
|
cartItem.relation_form_name = undefined;
|
|
628
|
-
cartItem.start_date = undefined;
|
|
629
|
-
cartItem.start_time = undefined;
|
|
630
|
-
cartItem.end_date = undefined;
|
|
631
|
-
cartItem.end_time = undefined;
|
|
632
635
|
|
|
633
636
|
// 删除资源原始数据
|
|
634
637
|
delete cartItem._resourceOrigin;
|
|
635
638
|
|
|
636
639
|
// 删除原始数据
|
|
637
640
|
cartItem._origin.resources = null;
|
|
638
|
-
cartItem._origin.select_date = null;
|
|
639
|
-
cartItem._origin.start_date = null;
|
|
640
|
-
cartItem._origin.start_time = null;
|
|
641
|
-
cartItem._origin.end_date = null;
|
|
642
|
-
cartItem._origin.end_time = null;
|
|
643
641
|
return cartItem;
|
|
644
642
|
};
|
|
645
643
|
|
|
@@ -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) {
|
|
@@ -1403,18 +1401,21 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1403
1401
|
}, {
|
|
1404
1402
|
key: "autoSelectAllProductResources",
|
|
1405
1403
|
value: function autoSelectAllProductResources(resources_code, timeSlots) {
|
|
1406
|
-
var
|
|
1404
|
+
var _dateRange$,
|
|
1405
|
+
_this7 = this;
|
|
1407
1406
|
var dateRange = this.store.date.getDateRange();
|
|
1408
1407
|
var resources = [];
|
|
1409
|
-
dateRange
|
|
1410
|
-
|
|
1411
|
-
|
|
1408
|
+
if (dateRange !== null && dateRange !== void 0 && (_dateRange$ = dateRange[0]) !== null && _dateRange$ !== void 0 && _dateRange$.date) {
|
|
1409
|
+
dateRange.forEach(function (n) {
|
|
1410
|
+
if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
|
|
1411
|
+
});
|
|
1412
|
+
}
|
|
1412
1413
|
var resourcesMap = getResourcesMap(cloneDeep(resources));
|
|
1413
1414
|
// 一个账号一个账号处理
|
|
1414
1415
|
var errorList = [];
|
|
1415
1416
|
var selectResourcesMap = {};
|
|
1416
|
-
this.store.accountList.getAccounts()
|
|
1417
|
-
|
|
1417
|
+
var accountList = this.store.accountList.getAccounts();
|
|
1418
|
+
var selectForCartResources = function selectForCartResources(cartItems) {
|
|
1418
1419
|
var recordTimeSlots = cloneDeep(timeSlots);
|
|
1419
1420
|
// timeSlots 传进来的只是用户选中的时间片,但是实际上需要根据多个商品时间进行累加
|
|
1420
1421
|
// 假设 timeSlots.start_time 是15:40 duration 是 30min
|
|
@@ -1429,7 +1430,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1429
1430
|
var currentCapacity = getSumCapacity({
|
|
1430
1431
|
capacity: formatCapacity
|
|
1431
1432
|
});
|
|
1432
|
-
|
|
1433
|
+
// 如果商品已经有时间数据了,意味着是通过先选日期再选商品流程进来的,相当于时间切片已经选中了
|
|
1434
|
+
if (item._origin.start_time && !(timeSlots !== null && timeSlots !== void 0 && timeSlots.start_time)) {
|
|
1435
|
+
recordTimeSlots = {
|
|
1436
|
+
start_time: item._origin.start_time,
|
|
1437
|
+
end_time: item._origin.end_time,
|
|
1438
|
+
start_at: dayjs("".concat(item.start_date, " ").concat(item._origin.start_time)),
|
|
1439
|
+
end_at: dayjs("".concat(item.end_date, " ").concat(item._origin.end_time))
|
|
1440
|
+
};
|
|
1441
|
+
}
|
|
1442
|
+
if (recordTimeSlots) {
|
|
1433
1443
|
if (index !== 0 && recordTimeSlots) {
|
|
1434
1444
|
var _item$_productOrigin$, _item$_productOrigin3, _ref10, _item$_productOrigin4, _item$_productOrigin$2, _item$_productOrigin5, _ref11, _item$_productOrigin6;
|
|
1435
1445
|
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 +1516,24 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1506
1516
|
return existingRes.resourceType !== targetRenderList[0].resourceType;
|
|
1507
1517
|
})), [targetResource])
|
|
1508
1518
|
});
|
|
1509
|
-
console.log(account, '已分配');
|
|
1510
1519
|
} else {
|
|
1511
1520
|
// 如果没有可用的技师了,推到错误列表里让 UI 去提示
|
|
1512
1521
|
errorList.push(item._id);
|
|
1513
1522
|
}
|
|
1514
1523
|
}
|
|
1515
1524
|
});
|
|
1516
|
-
}
|
|
1525
|
+
};
|
|
1526
|
+
var cartItems = this.store.cart.getItems();
|
|
1527
|
+
|
|
1528
|
+
// 如果购物车里没有 holderid数据,证明不按 holder 类流程预约走,给所有购物车一次性分派即可,不做账号下资源互斥逻辑
|
|
1529
|
+
if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
|
|
1530
|
+
accountList.forEach(function (account) {
|
|
1531
|
+
var cartItems = _this7.store.cart.getCartByAccount(account.getId());
|
|
1532
|
+
selectForCartResources(cartItems);
|
|
1533
|
+
});
|
|
1534
|
+
} else {
|
|
1535
|
+
selectForCartResources(cartItems);
|
|
1536
|
+
}
|
|
1517
1537
|
return {
|
|
1518
1538
|
errorList: errorList
|
|
1519
1539
|
};
|
|
@@ -1527,6 +1547,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1527
1547
|
// 取出购物车中所有一已选择的第一步资源
|
|
1528
1548
|
var resources = [];
|
|
1529
1549
|
var cartItems = this.store.cart.getItems();
|
|
1550
|
+
if (cartItems !== null && cartItems !== void 0 && cartItems[0].start_date) return [];
|
|
1530
1551
|
var resourceIds = [];
|
|
1531
1552
|
cartItems.forEach(function (item) {
|
|
1532
1553
|
var _item$_productOrigin8;
|
|
@@ -98,14 +98,14 @@ export declare const formatResourceToCartItemOrigin: (params: {
|
|
|
98
98
|
export declare const formatRelationFormsToCartItem: (params: {
|
|
99
99
|
cartItem: CartItem;
|
|
100
100
|
relationForms: {
|
|
101
|
-
form_id: number
|
|
101
|
+
form_id: number;
|
|
102
102
|
form_record_ids: number[];
|
|
103
103
|
}[];
|
|
104
104
|
}) => CartItem;
|
|
105
105
|
export declare const formatRelationFormsToCartItemOrigin: (params: {
|
|
106
106
|
cartItem: CartItem;
|
|
107
107
|
relationForms: {
|
|
108
|
-
form_id: number
|
|
108
|
+
form_id: number;
|
|
109
109
|
form_record_ids: number[];
|
|
110
110
|
}[];
|
|
111
111
|
}) => any;
|
|
@@ -230,8 +230,8 @@ export declare const handleProductDeposit: (params: {
|
|
|
230
230
|
total: string | number;
|
|
231
231
|
num: number;
|
|
232
232
|
}) => {
|
|
233
|
-
depositTotal: Decimal;
|
|
234
233
|
result: boolean;
|
|
234
|
+
depositTotal: Decimal;
|
|
235
235
|
};
|
|
236
236
|
/**
|
|
237
237
|
* 从购物车中删除资源相关信息
|
|
@@ -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);
|
|
@@ -488,17 +491,8 @@ var handleProductDeposit = (params) => {
|
|
|
488
491
|
var deleteResourceFromCartItem = (cartItem) => {
|
|
489
492
|
cartItem.resource_id = void 0;
|
|
490
493
|
cartItem.relation_form_name = void 0;
|
|
491
|
-
cartItem.start_date = void 0;
|
|
492
|
-
cartItem.start_time = void 0;
|
|
493
|
-
cartItem.end_date = void 0;
|
|
494
|
-
cartItem.end_time = void 0;
|
|
495
494
|
delete cartItem._resourceOrigin;
|
|
496
495
|
cartItem._origin.resources = null;
|
|
497
|
-
cartItem._origin.select_date = null;
|
|
498
|
-
cartItem._origin.start_date = null;
|
|
499
|
-
cartItem._origin.start_time = null;
|
|
500
|
-
cartItem._origin.end_date = null;
|
|
501
|
-
cartItem._origin.end_time = null;
|
|
502
496
|
return cartItem;
|
|
503
497
|
};
|
|
504
498
|
var deleteTimeFromCartItem = (cartItem) => {
|
|
@@ -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;
|
|
@@ -806,26 +804,37 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
806
804
|
}
|
|
807
805
|
// 给所有购物车里的商品先分配一个资源
|
|
808
806
|
autoSelectAllProductResources(resources_code, timeSlots) {
|
|
807
|
+
var _a;
|
|
809
808
|
const dateRange = this.store.date.getDateRange();
|
|
810
809
|
const resources = [];
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
810
|
+
if ((_a = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _a.date) {
|
|
811
|
+
dateRange.forEach((n) => {
|
|
812
|
+
if (n.resource)
|
|
813
|
+
resources.push(...n.resource);
|
|
814
|
+
});
|
|
815
|
+
}
|
|
815
816
|
const resourcesMap = (0, import_utils.getResourcesMap)((0, import_lodash_es.cloneDeep)(resources));
|
|
816
817
|
const errorList = [];
|
|
817
818
|
const selectResourcesMap = {};
|
|
818
|
-
this.store.accountList.getAccounts()
|
|
819
|
-
|
|
819
|
+
const accountList = this.store.accountList.getAccounts();
|
|
820
|
+
const selectForCartResources = (cartItems2) => {
|
|
820
821
|
let recordTimeSlots = (0, import_lodash_es.cloneDeep)(timeSlots);
|
|
821
|
-
|
|
822
|
-
var
|
|
822
|
+
cartItems2.forEach((item, index) => {
|
|
823
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
823
824
|
const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
|
|
824
|
-
capacity: (
|
|
825
|
+
capacity: (_a2 = item._productOrigin) == null ? void 0 : _a2.capacity,
|
|
825
826
|
product_bundle: item._origin.product.product_bundle
|
|
826
827
|
});
|
|
827
828
|
const currentCapacity = (0, import_resources.getSumCapacity)({ capacity: formatCapacity });
|
|
828
|
-
if (timeSlots) {
|
|
829
|
+
if (item._origin.start_time && !(timeSlots == null ? void 0 : timeSlots.start_time)) {
|
|
830
|
+
recordTimeSlots = {
|
|
831
|
+
start_time: item._origin.start_time,
|
|
832
|
+
end_time: item._origin.end_time,
|
|
833
|
+
start_at: (0, import_dayjs.default)(`${item.start_date} ${item._origin.start_time}`),
|
|
834
|
+
end_at: (0, import_dayjs.default)(`${item.end_date} ${item._origin.end_time}`)
|
|
835
|
+
};
|
|
836
|
+
}
|
|
837
|
+
if (recordTimeSlots) {
|
|
829
838
|
if (index !== 0 && recordTimeSlots) {
|
|
830
839
|
let start_at = (0, import_dayjs.default)(recordTimeSlots.end_time).add(
|
|
831
840
|
((_c = (_b = item._productOrigin) == null ? void 0 : _b.duration) == null ? void 0 : _c.value) ?? 0,
|
|
@@ -913,13 +922,21 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
913
922
|
targetResource
|
|
914
923
|
]
|
|
915
924
|
});
|
|
916
|
-
console.log(account, "已分配");
|
|
917
925
|
} else {
|
|
918
926
|
errorList.push(item._id);
|
|
919
927
|
}
|
|
920
928
|
}
|
|
921
929
|
});
|
|
922
|
-
}
|
|
930
|
+
};
|
|
931
|
+
const cartItems = this.store.cart.getItems();
|
|
932
|
+
if (cartItems == null ? void 0 : cartItems[0].holder_id) {
|
|
933
|
+
accountList.forEach((account) => {
|
|
934
|
+
const cartItems2 = this.store.cart.getCartByAccount(account.getId());
|
|
935
|
+
selectForCartResources(cartItems2);
|
|
936
|
+
});
|
|
937
|
+
} else {
|
|
938
|
+
selectForCartResources(cartItems);
|
|
939
|
+
}
|
|
923
940
|
return { errorList };
|
|
924
941
|
}
|
|
925
942
|
// 从购物车中获取已经分配好第一步资源的所有时间片
|
|
@@ -927,6 +944,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
927
944
|
const dateRange = this.store.date.getDateRange();
|
|
928
945
|
const resources = [];
|
|
929
946
|
const cartItems = this.store.cart.getItems();
|
|
947
|
+
if (cartItems == null ? void 0 : cartItems[0].start_date)
|
|
948
|
+
return [];
|
|
930
949
|
const resourceIds = [];
|
|
931
950
|
cartItems.forEach((item) => {
|
|
932
951
|
var _a, _b, _c;
|
|
@@ -964,14 +983,17 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
964
983
|
// 提交时间切片,绑定到对应购物车的商品上,更新购物车
|
|
965
984
|
submitTimeSlot(timeSlots) {
|
|
966
985
|
const cartItems = this.store.cart.getItems();
|
|
967
|
-
const itemsByAccount = cartItems.reduce(
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
acc[holderId]
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
986
|
+
const itemsByAccount = cartItems.reduce(
|
|
987
|
+
(acc, item) => {
|
|
988
|
+
const holderId = item.holder_id;
|
|
989
|
+
if (!acc[holderId]) {
|
|
990
|
+
acc[holderId] = [];
|
|
991
|
+
}
|
|
992
|
+
acc[holderId].push(item);
|
|
993
|
+
return acc;
|
|
994
|
+
},
|
|
995
|
+
{}
|
|
996
|
+
);
|
|
975
997
|
Object.values(itemsByAccount).forEach((accountItems) => {
|
|
976
998
|
let currentStartTime = timeSlots.start_at.format("YYYY-MM-DD HH:mm");
|
|
977
999
|
accountItems.forEach((item, index) => {
|
|
@@ -1123,7 +1145,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1123
1145
|
});
|
|
1124
1146
|
if (date) {
|
|
1125
1147
|
const cartItems = this.store.cart.getItems();
|
|
1126
|
-
const cartItemsByDate = cartItems.filter(
|
|
1148
|
+
const cartItemsByDate = cartItems.filter(
|
|
1149
|
+
(n) => !(0, import_dayjs.default)(n.start_date).isSame((0, import_dayjs.default)(date.startTime), "day")
|
|
1150
|
+
);
|
|
1127
1151
|
if (cartItemsByDate.length) {
|
|
1128
1152
|
cartItemsByDate.forEach((n) => {
|
|
1129
1153
|
this.store.cart.removeItem(n._id);
|