@pisell/pisellos 0.0.66 → 0.0.69
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/Date/index.js +2 -0
- package/dist/modules/Rules/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.js +22 -9
- package/dist/solution/ShopDiscount/index.js +13 -8
- package/dist/solution/ShopDiscount/types.d.ts +1 -0
- package/dist/solution/ShopDiscount/types.js +1 -0
- package/lib/modules/Date/index.js +2 -0
- package/lib/modules/Rules/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +21 -10
- package/lib/solution/ShopDiscount/index.js +4 -0
- package/lib/solution/ShopDiscount/types.d.ts +1 -0
- package/lib/solution/ShopDiscount/types.js +1 -0
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
3
|
import { Rules, RulesModuleAPI, DiscountResult } from './types';
|
|
4
|
-
import { Discount } from
|
|
4
|
+
import { Discount } from "../Discount/types";
|
|
5
5
|
export declare class RulesModule extends BaseModule implements Module, RulesModuleAPI {
|
|
6
6
|
protected defaultName: string;
|
|
7
7
|
protected defaultVersion: string;
|
|
@@ -1182,17 +1182,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1182
1182
|
if (cartItem._origin.start_time) {
|
|
1183
1183
|
var startTime = dayjs("".concat(cartItem._origin.start_date, " ").concat(cartItem._origin.start_time));
|
|
1184
1184
|
var endTime = dayjs("".concat(cartItem._origin.end_date, " ").concat(cartItem._origin.end_time));
|
|
1185
|
-
// 资源排下序,把单个资源靠前,组合资源排在后面
|
|
1186
|
-
productResources.sort(function (a, b) {
|
|
1187
|
-
var _a$metadata, _b$metadata;
|
|
1188
|
-
var aIsCombined = ((_a$metadata = a.metadata) === null || _a$metadata === void 0 || (_a$metadata = _a$metadata.combined_resource) === null || _a$metadata === void 0 ? void 0 : _a$metadata.status) === 1;
|
|
1189
|
-
var bIsCombined = ((_b$metadata = b.metadata) === null || _b$metadata === void 0 || (_b$metadata = _b$metadata.combined_resource) === null || _b$metadata === void 0 ? void 0 : _b$metadata.status) === 1;
|
|
1190
|
-
if (aIsCombined && !bIsCombined) return 1;
|
|
1191
|
-
if (!aIsCombined && bIsCombined) return -1;
|
|
1192
|
-
return 0;
|
|
1193
|
-
});
|
|
1194
1185
|
var resourcesUseableMap = {};
|
|
1195
1186
|
productResources.forEach(function (n) {
|
|
1187
|
+
// 资源排下序,把单个资源靠前,组合资源排在后面
|
|
1188
|
+
n.renderList = n.renderList.sort(function (a, b) {
|
|
1189
|
+
var _a$metadata, _b$metadata;
|
|
1190
|
+
var aIsCombined = ((_a$metadata = a.metadata) === null || _a$metadata === void 0 || (_a$metadata = _a$metadata.combined_resource) === null || _a$metadata === void 0 ? void 0 : _a$metadata.status) === 1;
|
|
1191
|
+
var bIsCombined = ((_b$metadata = b.metadata) === null || _b$metadata === void 0 || (_b$metadata = _b$metadata.combined_resource) === null || _b$metadata === void 0 ? void 0 : _b$metadata.status) === 1;
|
|
1192
|
+
if (aIsCombined && !bIsCombined) return 1;
|
|
1193
|
+
if (!aIsCombined && bIsCombined) return -1;
|
|
1194
|
+
return 0;
|
|
1195
|
+
});
|
|
1196
1196
|
n.renderList = n.renderList.filter(function (m) {
|
|
1197
1197
|
var recordCount = capacityMap[m.id] || 0;
|
|
1198
1198
|
var canUseTime = m.times.find(function (item) {
|
|
@@ -1216,6 +1216,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1216
1216
|
return canUseTime;
|
|
1217
1217
|
});
|
|
1218
1218
|
});
|
|
1219
|
+
} else {
|
|
1220
|
+
productResources.forEach(function (item) {
|
|
1221
|
+
// 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
|
|
1222
|
+
item.renderList = item.renderList.filter(function (n) {
|
|
1223
|
+
var recordCount = n.capacity || 0;
|
|
1224
|
+
return recordCount < currentCapacity;
|
|
1225
|
+
});
|
|
1226
|
+
});
|
|
1219
1227
|
}
|
|
1220
1228
|
arr.push({
|
|
1221
1229
|
id: cartItem.id,
|
|
@@ -1510,6 +1518,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1510
1518
|
_resources.forEach(function (n) {
|
|
1511
1519
|
var _n$renderList;
|
|
1512
1520
|
if ((_n$renderList = n.renderList) !== null && _n$renderList !== void 0 && _n$renderList.length) {
|
|
1521
|
+
// 过滤掉 capacity 小于 currentCapacity 的资源
|
|
1522
|
+
n.renderList = n.renderList.filter(function (m) {
|
|
1523
|
+
var recordCount = m.capacity || 0;
|
|
1524
|
+
return recordCount >= currentCapacity;
|
|
1525
|
+
});
|
|
1513
1526
|
currentResourcesRenderList.push.apply(currentResourcesRenderList, _toConsumableArray(n.renderList || []));
|
|
1514
1527
|
}
|
|
1515
1528
|
});
|
|
@@ -483,21 +483,26 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
483
483
|
});
|
|
484
484
|
case 3:
|
|
485
485
|
result = _context7.sent;
|
|
486
|
-
if (result !== null && result !== void 0 && result.data) {
|
|
487
|
-
|
|
488
|
-
|
|
486
|
+
if (!(result !== null && result !== void 0 && result.data)) {
|
|
487
|
+
_context7.next = 9;
|
|
488
|
+
break;
|
|
489
489
|
}
|
|
490
|
-
|
|
490
|
+
_result$data = result.data, wallet_pass_list = _result$data.wallet_pass_list, customer = _objectWithoutProperties(_result$data, _excluded);
|
|
491
|
+
this.setCustomer(customer);
|
|
492
|
+
_context7.next = 9;
|
|
493
|
+
return this.core.effects.emit(ShopDiscountHooks.onScanCustomerChange, customer);
|
|
494
|
+
case 9:
|
|
495
|
+
_context7.next = 14;
|
|
491
496
|
break;
|
|
492
|
-
case
|
|
493
|
-
_context7.prev =
|
|
497
|
+
case 11:
|
|
498
|
+
_context7.prev = 11;
|
|
494
499
|
_context7.t0 = _context7["catch"](0);
|
|
495
500
|
console.error('[ShopDiscount] 获取客户钱包信息出错:', _context7.t0);
|
|
496
|
-
case
|
|
501
|
+
case 14:
|
|
497
502
|
case "end":
|
|
498
503
|
return _context7.stop();
|
|
499
504
|
}
|
|
500
|
-
}, _callee7, this, [[0,
|
|
505
|
+
}, _callee7, this, [[0, 11]]);
|
|
501
506
|
}));
|
|
502
507
|
function getCustomerWallet(_x6) {
|
|
503
508
|
return _getCustomerWallet.apply(this, arguments);
|
|
@@ -5,6 +5,7 @@ export declare enum ShopDiscountHooks {
|
|
|
5
5
|
onDestroy = "shopDiscount:onDestroy",
|
|
6
6
|
onLoadDiscountList = "shopDiscount:onLoadDiscountList",
|
|
7
7
|
onCustomerChange = "shopDiscount:onCustomerChange",
|
|
8
|
+
onScanCustomerChange = "shopDiscount:onScanCustomerChange",
|
|
8
9
|
onDiscountListChange = "shopDiscount:onDiscountListChange",
|
|
9
10
|
onRulesListChange = "shopDiscount:onRulesListChange",
|
|
10
11
|
onLoadPrepareCalcResult = "shopDiscount:onLoadPrepareCalcResult"
|
|
@@ -3,6 +3,7 @@ export var ShopDiscountHooks = /*#__PURE__*/function (ShopDiscountHooks) {
|
|
|
3
3
|
ShopDiscountHooks["onDestroy"] = "shopDiscount:onDestroy";
|
|
4
4
|
ShopDiscountHooks["onLoadDiscountList"] = "shopDiscount:onLoadDiscountList";
|
|
5
5
|
ShopDiscountHooks["onCustomerChange"] = "shopDiscount:onCustomerChange";
|
|
6
|
+
ShopDiscountHooks["onScanCustomerChange"] = "shopDiscount:onScanCustomerChange";
|
|
6
7
|
ShopDiscountHooks["onDiscountListChange"] = "shopDiscount:onDiscountListChange";
|
|
7
8
|
ShopDiscountHooks["onRulesListChange"] = "shopDiscount:onRulesListChange";
|
|
8
9
|
ShopDiscountHooks["onLoadPrepareCalcResult"] = "shopDiscount:onLoadPrepareCalcResult";
|
|
@@ -83,6 +83,8 @@ var DateModule = class extends import_BaseModule.BaseModule {
|
|
|
83
83
|
end_date,
|
|
84
84
|
resource_ids,
|
|
85
85
|
front_end_cache_id: this.cacheId
|
|
86
|
+
}, {
|
|
87
|
+
useCache: true
|
|
86
88
|
});
|
|
87
89
|
if (!((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.length)) {
|
|
88
90
|
return (0, import_utils.disableAllDates)(dates);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
3
|
import { Rules, RulesModuleAPI, DiscountResult } from './types';
|
|
4
|
-
import { Discount } from
|
|
4
|
+
import { Discount } from "../Discount/types";
|
|
5
5
|
export declare class RulesModule extends BaseModule implements Module, RulesModuleAPI {
|
|
6
6
|
protected defaultName: string;
|
|
7
7
|
protected defaultVersion: string;
|
|
@@ -632,18 +632,18 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
632
632
|
const endTime = (0, import_dayjs.default)(
|
|
633
633
|
`${cartItem._origin.end_date} ${cartItem._origin.end_time}`
|
|
634
634
|
);
|
|
635
|
-
productResources.sort((a, b) => {
|
|
636
|
-
var _a2, _b2, _c2, _d;
|
|
637
|
-
const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
|
|
638
|
-
const bIsCombined = ((_d = (_c2 = b.metadata) == null ? void 0 : _c2.combined_resource) == null ? void 0 : _d.status) === 1;
|
|
639
|
-
if (aIsCombined && !bIsCombined)
|
|
640
|
-
return 1;
|
|
641
|
-
if (!aIsCombined && bIsCombined)
|
|
642
|
-
return -1;
|
|
643
|
-
return 0;
|
|
644
|
-
});
|
|
645
635
|
const resourcesUseableMap = {};
|
|
646
636
|
productResources.forEach((n) => {
|
|
637
|
+
n.renderList = n.renderList.sort((a, b) => {
|
|
638
|
+
var _a2, _b2, _c2, _d;
|
|
639
|
+
const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
|
|
640
|
+
const bIsCombined = ((_d = (_c2 = b.metadata) == null ? void 0 : _c2.combined_resource) == null ? void 0 : _d.status) === 1;
|
|
641
|
+
if (aIsCombined && !bIsCombined)
|
|
642
|
+
return 1;
|
|
643
|
+
if (!aIsCombined && bIsCombined)
|
|
644
|
+
return -1;
|
|
645
|
+
return 0;
|
|
646
|
+
});
|
|
647
647
|
n.renderList = n.renderList.filter((m) => {
|
|
648
648
|
const recordCount = capacityMap[m.id] || 0;
|
|
649
649
|
const canUseTime = m.times.find((item) => {
|
|
@@ -667,6 +667,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
667
667
|
return canUseTime;
|
|
668
668
|
});
|
|
669
669
|
});
|
|
670
|
+
} else {
|
|
671
|
+
productResources.forEach((item) => {
|
|
672
|
+
item.renderList = item.renderList.filter((n) => {
|
|
673
|
+
const recordCount = n.capacity || 0;
|
|
674
|
+
return recordCount < currentCapacity;
|
|
675
|
+
});
|
|
676
|
+
});
|
|
670
677
|
}
|
|
671
678
|
arr.push({
|
|
672
679
|
id: cartItem.id,
|
|
@@ -918,6 +925,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
918
925
|
resources2.forEach((n) => {
|
|
919
926
|
var _a3;
|
|
920
927
|
if ((_a3 = n.renderList) == null ? void 0 : _a3.length) {
|
|
928
|
+
n.renderList = n.renderList.filter((m) => {
|
|
929
|
+
const recordCount = m.capacity || 0;
|
|
930
|
+
return recordCount >= currentCapacity;
|
|
931
|
+
});
|
|
921
932
|
currentResourcesRenderList.push(...n.renderList || []);
|
|
922
933
|
}
|
|
923
934
|
});
|
|
@@ -313,6 +313,10 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
313
313
|
if (result == null ? void 0 : result.data) {
|
|
314
314
|
const { wallet_pass_list, ...customer } = result.data;
|
|
315
315
|
this.setCustomer(customer);
|
|
316
|
+
await this.core.effects.emit(
|
|
317
|
+
import_types.ShopDiscountHooks.onScanCustomerChange,
|
|
318
|
+
customer
|
|
319
|
+
);
|
|
316
320
|
}
|
|
317
321
|
} catch (error) {
|
|
318
322
|
console.error("[ShopDiscount] 获取客户钱包信息出错:", error);
|
|
@@ -5,6 +5,7 @@ export declare enum ShopDiscountHooks {
|
|
|
5
5
|
onDestroy = "shopDiscount:onDestroy",
|
|
6
6
|
onLoadDiscountList = "shopDiscount:onLoadDiscountList",
|
|
7
7
|
onCustomerChange = "shopDiscount:onCustomerChange",
|
|
8
|
+
onScanCustomerChange = "shopDiscount:onScanCustomerChange",
|
|
8
9
|
onDiscountListChange = "shopDiscount:onDiscountListChange",
|
|
9
10
|
onRulesListChange = "shopDiscount:onRulesListChange",
|
|
10
11
|
onLoadPrepareCalcResult = "shopDiscount:onLoadPrepareCalcResult"
|
|
@@ -27,6 +27,7 @@ var ShopDiscountHooks = /* @__PURE__ */ ((ShopDiscountHooks2) => {
|
|
|
27
27
|
ShopDiscountHooks2["onDestroy"] = "shopDiscount:onDestroy";
|
|
28
28
|
ShopDiscountHooks2["onLoadDiscountList"] = "shopDiscount:onLoadDiscountList";
|
|
29
29
|
ShopDiscountHooks2["onCustomerChange"] = "shopDiscount:onCustomerChange";
|
|
30
|
+
ShopDiscountHooks2["onScanCustomerChange"] = "shopDiscount:onScanCustomerChange";
|
|
30
31
|
ShopDiscountHooks2["onDiscountListChange"] = "shopDiscount:onDiscountListChange";
|
|
31
32
|
ShopDiscountHooks2["onRulesListChange"] = "shopDiscount:onRulesListChange";
|
|
32
33
|
ShopDiscountHooks2["onLoadPrepareCalcResult"] = "shopDiscount:onLoadPrepareCalcResult";
|