@pisell/pisellos 3.0.76 → 3.0.78
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/core/index.js +1 -2
- package/dist/effects/index.d.ts +3 -5
- package/dist/effects/index.js +8 -40
- package/dist/modules/Account/index.js +3 -2
- package/dist/modules/AccountList/index.d.ts +1 -7
- package/dist/modules/AccountList/index.js +14 -81
- package/dist/modules/AccountList/types.d.ts +0 -28
- package/dist/modules/AccountList/types.js +0 -8
- package/dist/modules/BaseModule.d.ts +0 -3
- package/dist/modules/BaseModule.js +0 -15
- package/dist/modules/Cart/index.d.ts +0 -1
- package/dist/modules/Cart/index.js +1 -2
- package/dist/modules/Date/types.d.ts +3 -1
- package/dist/modules/Discount/index.d.ts +0 -1
- package/dist/modules/Discount/index.js +1 -1
- package/dist/modules/Guests/index.js +9 -9
- package/dist/modules/Order/index.d.ts +1 -25
- package/dist/modules/Order/index.js +3 -224
- package/dist/modules/Order/types.d.ts +0 -45
- package/dist/modules/Order/types.js +0 -8
- package/dist/modules/Order/utils.js +1 -1
- package/dist/modules/Payment/index.d.ts +9 -184
- package/dist/modules/Payment/index.js +109 -2084
- package/dist/modules/Payment/types.d.ts +30 -772
- package/dist/modules/Payment/types.js +12 -236
- package/dist/modules/ProductList/index.d.ts +1 -12
- package/dist/modules/ProductList/index.js +6 -29
- package/dist/modules/Resource/index.js +1 -1
- package/dist/modules/Rules/index.d.ts +4 -3
- package/dist/modules/Rules/index.js +121 -78
- package/dist/modules/Rules/types.d.ts +6 -1
- package/dist/modules/Rules/types.js +8 -0
- package/dist/modules/Schedule/index.d.ts +0 -9
- package/dist/modules/Schedule/index.js +0 -77
- package/dist/modules/index.d.ts +0 -1
- package/dist/modules/index.js +0 -1
- package/dist/plugins/window.d.ts +0 -1
- package/dist/solution/BookingByStep/index.d.ts +17 -0
- package/dist/solution/BookingByStep/index.js +525 -190
- package/dist/solution/BookingByStep/utils/products.d.ts +0 -6
- package/dist/solution/BookingByStep/utils/products.js +0 -10
- package/dist/solution/BookingByStep/utils/resources.js +4 -0
- package/dist/solution/BuyTickets/index.js +8 -7
- package/dist/solution/ShopDiscount/index.d.ts +12 -10
- package/dist/solution/ShopDiscount/index.js +64 -110
- package/dist/solution/ShopDiscount/types.d.ts +0 -8
- package/dist/solution/ShopDiscount/utils.js +1 -0
- package/dist/solution/index.d.ts +0 -2
- package/dist/solution/index.js +1 -3
- package/dist/types/index.d.ts +1 -4
- package/lib/core/index.js +1 -1
- package/lib/effects/index.d.ts +3 -5
- package/lib/effects/index.js +1 -17
- package/lib/modules/Account/index.js +3 -2
- package/lib/modules/AccountList/index.d.ts +1 -7
- package/lib/modules/AccountList/index.js +0 -27
- package/lib/modules/AccountList/types.d.ts +0 -28
- package/lib/modules/BaseModule.d.ts +0 -3
- package/lib/modules/BaseModule.js +0 -9
- package/lib/modules/Cart/index.d.ts +0 -1
- package/lib/modules/Cart/index.js +2 -5
- package/lib/modules/Date/types.d.ts +3 -1
- package/lib/modules/Discount/index.d.ts +0 -1
- package/lib/modules/Discount/index.js +1 -1
- package/lib/modules/Guests/index.js +9 -9
- package/lib/modules/Order/index.d.ts +1 -25
- package/lib/modules/Order/index.js +1 -186
- package/lib/modules/Order/types.d.ts +0 -45
- package/lib/modules/Order/utils.js +1 -1
- package/lib/modules/Payment/index.d.ts +9 -184
- package/lib/modules/Payment/index.js +51 -1084
- package/lib/modules/Payment/types.d.ts +30 -772
- package/lib/modules/Payment/types.js +6 -79
- package/lib/modules/ProductList/index.d.ts +1 -12
- package/lib/modules/ProductList/index.js +5 -31
- package/lib/modules/Resource/index.js +1 -1
- package/lib/modules/Rules/index.d.ts +4 -3
- package/lib/modules/Rules/index.js +64 -43
- package/lib/modules/Rules/types.d.ts +6 -1
- package/lib/modules/Rules/types.js +11 -2
- package/lib/modules/Schedule/index.d.ts +0 -9
- package/lib/modules/Schedule/index.js +0 -60
- package/lib/modules/index.d.ts +0 -1
- package/lib/modules/index.js +0 -2
- package/lib/plugins/window.d.ts +0 -1
- package/lib/solution/BookingByStep/index.d.ts +17 -0
- package/lib/solution/BookingByStep/index.js +325 -60
- package/lib/solution/BookingByStep/utils/products.d.ts +0 -6
- package/lib/solution/BookingByStep/utils/products.js +2 -8
- package/lib/solution/BookingByStep/utils/resources.js +4 -1
- package/lib/solution/BuyTickets/index.js +8 -7
- package/lib/solution/ShopDiscount/index.d.ts +12 -10
- package/lib/solution/ShopDiscount/index.js +30 -51
- package/lib/solution/ShopDiscount/types.d.ts +0 -8
- package/lib/solution/index.d.ts +0 -2
- package/lib/solution/index.js +1 -5
- package/lib/types/index.d.ts +1 -4
- package/package.json +1 -3
- package/dist/modules/Customer/constants.d.ts +0 -7
- package/dist/modules/Customer/constants.js +0 -12
- package/dist/modules/Customer/index.d.ts +0 -122
- package/dist/modules/Customer/index.js +0 -696
- package/dist/modules/Customer/types.d.ts +0 -146
- package/dist/modules/Customer/types.js +0 -41
- package/dist/modules/Payment/cash.d.ts +0 -19
- package/dist/modules/Payment/cash.js +0 -97
- package/dist/modules/Payment/cashRecommendationAlgorithm.d.ts +0 -22
- package/dist/modules/Payment/cashRecommendationAlgorithm.js +0 -423
- package/dist/modules/Payment/eftpos.d.ts +0 -11
- package/dist/modules/Payment/eftpos.js +0 -80
- package/dist/modules/Payment/mx51.d.ts +0 -0
- package/dist/modules/Payment/mx51.js +0 -0
- package/dist/modules/Payment/utils.d.ts +0 -17
- package/dist/modules/Payment/utils.js +0 -62
- package/dist/modules/Payment/walletpass.d.ts +0 -99
- package/dist/modules/Payment/walletpass.js +0 -711
- package/dist/plugins/app-types/app/app.d.ts +0 -83
- package/dist/plugins/app-types/app/const.d.ts +0 -4
- package/dist/plugins/app-types/app/index.d.ts +0 -14
- package/dist/plugins/app-types/applicationManager/application.d.ts +0 -50
- package/dist/plugins/app-types/applicationManager/index.d.ts +0 -13
- package/dist/plugins/app-types/config.d.ts +0 -3
- package/dist/plugins/app-types/cookie/index.d.ts +0 -13
- package/dist/plugins/app-types/data/index.d.ts +0 -8
- package/dist/plugins/app-types/history/config.d.ts +0 -24
- package/dist/plugins/app-types/history/index.d.ts +0 -20
- package/dist/plugins/app-types/history/type.d.ts +0 -2
- package/dist/plugins/app-types/hooks/index.d.ts +0 -12
- package/dist/plugins/app-types/hooks/useDelayedValue/index.d.ts +0 -2
- package/dist/plugins/app-types/hooks/useDispatch/index.d.ts +0 -2
- package/dist/plugins/app-types/hooks/useLowCode/index.d.ts +0 -13
- package/dist/plugins/app-types/hooks/useStore/index.d.ts +0 -6
- package/dist/plugins/app-types/index.d.ts +0 -6
- package/dist/plugins/app-types/indexDB/index.d.ts +0 -178
- package/dist/plugins/app-types/locales/en.d.ts +0 -3
- package/dist/plugins/app-types/locales/index.d.ts +0 -37
- package/dist/plugins/app-types/locales/original.d.ts +0 -3
- package/dist/plugins/app-types/locales/type.d.ts +0 -19
- package/dist/plugins/app-types/locales/zh-CN.d.ts +0 -3
- package/dist/plugins/app-types/locales/zh-HK.d.ts +0 -3
- package/dist/plugins/app-types/logger/feishu.d.ts +0 -11
- package/dist/plugins/app-types/logger/index.d.ts +0 -122
- package/dist/plugins/app-types/menuManager/hooks.d.ts +0 -17
- package/dist/plugins/app-types/menuManager/index.d.ts +0 -28
- package/dist/plugins/app-types/models/global.d.ts +0 -32
- package/dist/plugins/app-types/models/index.d.ts +0 -45
- package/dist/plugins/app-types/models/type.d.ts +0 -2
- package/dist/plugins/app-types/package.json +0 -15
- package/dist/plugins/app-types/plugin/index.d.ts +0 -0
- package/dist/plugins/app-types/pubsub/example.d.ts +0 -5
- package/dist/plugins/app-types/pubsub/index.d.ts +0 -63
- package/dist/plugins/app-types/request/cache.d.ts +0 -46
- package/dist/plugins/app-types/request/cancelToken.d.ts +0 -38
- package/dist/plugins/app-types/request/config.d.ts +0 -3
- package/dist/plugins/app-types/request/constants.d.ts +0 -2
- package/dist/plugins/app-types/request/index.d.ts +0 -24
- package/dist/plugins/app-types/request/pisell2Request.d.ts +0 -6
- package/dist/plugins/app-types/request/type.d.ts +0 -41
- package/dist/plugins/app-types/request/utils.d.ts +0 -46
- package/dist/plugins/app-types/routes/config.d.ts +0 -7
- package/dist/plugins/app-types/routes/index.d.ts +0 -28
- package/dist/plugins/app-types/socket/components/SocketMonitorPage.d.ts +0 -6
- package/dist/plugins/app-types/socket/components/index.d.ts +0 -2
- package/dist/plugins/app-types/socket/constants.d.ts +0 -33
- package/dist/plugins/app-types/socket/events.d.ts +0 -31
- package/dist/plugins/app-types/socket/heartbeat.d.ts +0 -66
- package/dist/plugins/app-types/socket/index.d.ts +0 -61
- package/dist/plugins/app-types/socket/monitor.d.ts +0 -169
- package/dist/plugins/app-types/socket/reconnect.d.ts +0 -61
- package/dist/plugins/app-types/socket/socket.d.ts +0 -129
- package/dist/plugins/app-types/socket/types.d.ts +0 -85
- package/dist/plugins/app-types/storage/index.d.ts +0 -17
- package/dist/plugins/app-types/tasks/index.d.ts +0 -77
- package/dist/plugins/app-types/tasks/type.d.ts +0 -62
- package/dist/plugins/app-types/tasks/useTasks.d.ts +0 -5
- package/dist/plugins/app-types/type.d.ts +0 -2
- package/dist/plugins/app-types/variables/VariablesProvider.d.ts +0 -7
- package/dist/plugins/app-types/variables/config.d.ts +0 -3
- package/dist/plugins/app-types/variables/index.d.ts +0 -6
- package/dist/plugins/app-types/variables/type.d.ts +0 -2
- package/dist/plugins/app-types/website/index.d.ts +0 -6
- package/dist/plugins/app.d.ts +0 -8
- package/dist/plugins/app.js +0 -1
- package/dist/solution/BookingTicket/index.d.ts +0 -184
- package/dist/solution/BookingTicket/index.js +0 -698
- package/dist/solution/BookingTicket/types.d.ts +0 -68
- package/dist/solution/BookingTicket/types.js +0 -43
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.d.ts +0 -22
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +0 -159
- package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +0 -22
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +0 -189
- package/dist/solution/BookingTicket/utils/scan/index.d.ts +0 -85
- package/dist/solution/BookingTicket/utils/scan/index.js +0 -294
- package/dist/solution/BookingTicket/utils/scan/scanCache.d.ts +0 -78
- package/dist/solution/BookingTicket/utils/scan/scanCache.js +0 -305
- package/dist/solution/Checkout/appointmentDemo.json +0 -1
- package/dist/solution/Checkout/index.d.ts +0 -432
- package/dist/solution/Checkout/index.js +0 -4452
- package/dist/solution/Checkout/types.d.ts +0 -727
- package/dist/solution/Checkout/types.js +0 -104
- package/dist/solution/Checkout/utils/index.d.ts +0 -121
- package/dist/solution/Checkout/utils/index.js +0 -511
- package/dist/utils/task.d.ts +0 -40
- package/dist/utils/task.js +0 -171
- package/dist/utils/watch.d.ts +0 -102
- package/dist/utils/watch.js +0 -294
- package/lib/modules/Customer/constants.d.ts +0 -7
- package/lib/modules/Customer/constants.js +0 -39
- package/lib/modules/Customer/index.d.ts +0 -122
- package/lib/modules/Customer/index.js +0 -439
- package/lib/modules/Customer/types.d.ts +0 -146
- package/lib/modules/Customer/types.js +0 -37
- package/lib/modules/Payment/cash.d.ts +0 -19
- package/lib/modules/Payment/cash.js +0 -64
- package/lib/modules/Payment/cashRecommendationAlgorithm.d.ts +0 -22
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +0 -342
- package/lib/modules/Payment/eftpos.d.ts +0 -11
- package/lib/modules/Payment/eftpos.js +0 -51
- package/lib/modules/Payment/mx51.d.ts +0 -0
- package/lib/modules/Payment/mx51.js +0 -0
- package/lib/modules/Payment/utils.d.ts +0 -17
- package/lib/modules/Payment/utils.js +0 -67
- package/lib/modules/Payment/walletpass.d.ts +0 -99
- package/lib/modules/Payment/walletpass.js +0 -484
- package/lib/plugins/app-types/app/app.d.ts +0 -83
- package/lib/plugins/app-types/app/const.d.ts +0 -4
- package/lib/plugins/app-types/app/index.d.ts +0 -14
- package/lib/plugins/app-types/applicationManager/application.d.ts +0 -50
- package/lib/plugins/app-types/applicationManager/index.d.ts +0 -13
- package/lib/plugins/app-types/config.d.ts +0 -3
- package/lib/plugins/app-types/cookie/index.d.ts +0 -13
- package/lib/plugins/app-types/data/index.d.ts +0 -8
- package/lib/plugins/app-types/history/config.d.ts +0 -24
- package/lib/plugins/app-types/history/index.d.ts +0 -20
- package/lib/plugins/app-types/history/type.d.ts +0 -2
- package/lib/plugins/app-types/hooks/index.d.ts +0 -12
- package/lib/plugins/app-types/hooks/useDelayedValue/index.d.ts +0 -2
- package/lib/plugins/app-types/hooks/useDispatch/index.d.ts +0 -2
- package/lib/plugins/app-types/hooks/useLowCode/index.d.ts +0 -13
- package/lib/plugins/app-types/hooks/useStore/index.d.ts +0 -6
- package/lib/plugins/app-types/index.d.ts +0 -6
- package/lib/plugins/app-types/indexDB/index.d.ts +0 -178
- package/lib/plugins/app-types/locales/en.d.ts +0 -3
- package/lib/plugins/app-types/locales/index.d.ts +0 -37
- package/lib/plugins/app-types/locales/original.d.ts +0 -3
- package/lib/plugins/app-types/locales/type.d.ts +0 -19
- package/lib/plugins/app-types/locales/zh-CN.d.ts +0 -3
- package/lib/plugins/app-types/locales/zh-HK.d.ts +0 -3
- package/lib/plugins/app-types/logger/feishu.d.ts +0 -11
- package/lib/plugins/app-types/logger/index.d.ts +0 -122
- package/lib/plugins/app-types/menuManager/hooks.d.ts +0 -17
- package/lib/plugins/app-types/menuManager/index.d.ts +0 -28
- package/lib/plugins/app-types/models/global.d.ts +0 -32
- package/lib/plugins/app-types/models/index.d.ts +0 -45
- package/lib/plugins/app-types/models/type.d.ts +0 -2
- package/lib/plugins/app-types/package.json +0 -15
- package/lib/plugins/app-types/plugin/index.d.ts +0 -0
- package/lib/plugins/app-types/pubsub/example.d.ts +0 -5
- package/lib/plugins/app-types/pubsub/index.d.ts +0 -63
- package/lib/plugins/app-types/request/cache.d.ts +0 -46
- package/lib/plugins/app-types/request/cancelToken.d.ts +0 -38
- package/lib/plugins/app-types/request/config.d.ts +0 -3
- package/lib/plugins/app-types/request/constants.d.ts +0 -2
- package/lib/plugins/app-types/request/index.d.ts +0 -24
- package/lib/plugins/app-types/request/pisell2Request.d.ts +0 -6
- package/lib/plugins/app-types/request/type.d.ts +0 -41
- package/lib/plugins/app-types/request/utils.d.ts +0 -46
- package/lib/plugins/app-types/routes/config.d.ts +0 -7
- package/lib/plugins/app-types/routes/index.d.ts +0 -28
- package/lib/plugins/app-types/socket/components/SocketMonitorPage.d.ts +0 -6
- package/lib/plugins/app-types/socket/components/index.d.ts +0 -2
- package/lib/plugins/app-types/socket/constants.d.ts +0 -33
- package/lib/plugins/app-types/socket/events.d.ts +0 -31
- package/lib/plugins/app-types/socket/heartbeat.d.ts +0 -66
- package/lib/plugins/app-types/socket/index.d.ts +0 -61
- package/lib/plugins/app-types/socket/monitor.d.ts +0 -169
- package/lib/plugins/app-types/socket/reconnect.d.ts +0 -61
- package/lib/plugins/app-types/socket/socket.d.ts +0 -129
- package/lib/plugins/app-types/socket/types.d.ts +0 -85
- package/lib/plugins/app-types/storage/index.d.ts +0 -17
- package/lib/plugins/app-types/tasks/index.d.ts +0 -77
- package/lib/plugins/app-types/tasks/type.d.ts +0 -62
- package/lib/plugins/app-types/tasks/useTasks.d.ts +0 -5
- package/lib/plugins/app-types/type.d.ts +0 -2
- package/lib/plugins/app-types/variables/VariablesProvider.d.ts +0 -7
- package/lib/plugins/app-types/variables/config.d.ts +0 -3
- package/lib/plugins/app-types/variables/index.d.ts +0 -6
- package/lib/plugins/app-types/variables/type.d.ts +0 -2
- package/lib/plugins/app-types/website/index.d.ts +0 -6
- package/lib/plugins/app.d.ts +0 -8
- package/lib/plugins/app.js +0 -17
- package/lib/solution/BookingTicket/index.d.ts +0 -184
- package/lib/solution/BookingTicket/index.js +0 -426
- package/lib/solution/BookingTicket/types.d.ts +0 -68
- package/lib/solution/BookingTicket/types.js +0 -72
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.d.ts +0 -22
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +0 -117
- package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +0 -22
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +0 -132
- package/lib/solution/BookingTicket/utils/scan/index.d.ts +0 -85
- package/lib/solution/BookingTicket/utils/scan/index.js +0 -216
- package/lib/solution/BookingTicket/utils/scan/scanCache.d.ts +0 -78
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +0 -231
- package/lib/solution/Checkout/appointmentDemo.json +0 -1
- package/lib/solution/Checkout/index.d.ts +0 -432
- package/lib/solution/Checkout/index.js +0 -2776
- package/lib/solution/Checkout/types.d.ts +0 -727
- package/lib/solution/Checkout/types.js +0 -63
- package/lib/solution/Checkout/utils/index.d.ts +0 -121
- package/lib/solution/Checkout/utils/index.js +0 -362
- package/lib/utils/task.d.ts +0 -40
- package/lib/utils/task.js +0 -109
- package/lib/utils/watch.d.ts +0 -102
- package/lib/utils/watch.js +0 -217
|
@@ -95,7 +95,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
95
95
|
"step",
|
|
96
96
|
"products",
|
|
97
97
|
"date",
|
|
98
|
-
"order"
|
|
98
|
+
"order",
|
|
99
|
+
"payment"
|
|
99
100
|
];
|
|
100
101
|
moduleArr.forEach((step) => {
|
|
101
102
|
var _a2, _b2;
|
|
@@ -116,7 +117,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
116
117
|
}
|
|
117
118
|
});
|
|
118
119
|
this.store.schedule.loadAllSchedule();
|
|
119
|
-
this.core.effects.emit(
|
|
120
|
+
this.core.effects.emit(import_types.BookingByStepHooks.onInited, {});
|
|
120
121
|
}
|
|
121
122
|
// 初始化step
|
|
122
123
|
initStep(stepList) {
|
|
@@ -185,19 +186,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
185
186
|
collection = [],
|
|
186
187
|
schedule_date
|
|
187
188
|
}) {
|
|
188
|
-
|
|
189
|
+
return this.store.products.loadProducts({
|
|
189
190
|
category_ids,
|
|
190
191
|
product_ids,
|
|
191
192
|
collection,
|
|
192
193
|
schedule_date,
|
|
193
194
|
cacheId: this.cacheId
|
|
194
195
|
});
|
|
195
|
-
this.getAvailableDate({
|
|
196
|
-
startDate: schedule_date || (0, import_dayjs.default)().format("YYYY-MM-DD"),
|
|
197
|
-
endDate: schedule_date || (0, import_dayjs.default)().format("YYYY-MM-DD"),
|
|
198
|
-
products: [...res]
|
|
199
|
-
});
|
|
200
|
-
return res;
|
|
201
196
|
}
|
|
202
197
|
/**
|
|
203
198
|
* 通过 schedule 来读取商品,适用于 session 类商品
|
|
@@ -234,12 +229,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
234
229
|
const allProductIds = [...newProductIds, ...otherProductsIds].filter(
|
|
235
230
|
(n, index, self) => self.indexOf(n) === index
|
|
236
231
|
);
|
|
237
|
-
|
|
232
|
+
return await this.loadProducts({
|
|
238
233
|
product_ids: allProductIds,
|
|
239
234
|
category_ids,
|
|
240
235
|
schedule_date: date
|
|
241
236
|
});
|
|
242
|
-
return res;
|
|
243
237
|
}
|
|
244
238
|
/**
|
|
245
239
|
* 更新完商品数据、切换日期、或者在较后的流程里登录了,检测当前购物车里是否有商品,如果有,则需要更新购物车里的商品价格
|
|
@@ -606,12 +600,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
606
600
|
quantity = 1
|
|
607
601
|
} = product || {};
|
|
608
602
|
const productData = { ...origin, product_variant_id };
|
|
609
|
-
debugger;
|
|
610
|
-
if ((0, import_products.isSessionProduct)(productData)) {
|
|
611
|
-
if (!date || !date.startTime || !date.endTime) {
|
|
612
|
-
return { success: false, errorCode: "date_or_time_required" };
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
603
|
const currentCartItems = this.store.cart.getItems();
|
|
616
604
|
const stockCheckResult = (0, import_stock.checkProductStock)({
|
|
617
605
|
productData,
|
|
@@ -1405,7 +1393,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1405
1393
|
}
|
|
1406
1394
|
// 从购物车中获取已经分配好第一步资源的所有时间片
|
|
1407
1395
|
getTimeSlotByAllResources(resources_code) {
|
|
1408
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1396
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
1409
1397
|
let dateRange = this.store.date.getDateRange();
|
|
1410
1398
|
const resources = [];
|
|
1411
1399
|
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils5.isNormalProduct)(n._productOrigin));
|
|
@@ -1415,7 +1403,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1415
1403
|
let maxCutOffTime = void 0;
|
|
1416
1404
|
let maxCutOffTimeValue = (0, import_dayjs.default)();
|
|
1417
1405
|
cartItems.forEach((item) => {
|
|
1418
|
-
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2,
|
|
1406
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2;
|
|
1419
1407
|
(_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.forEach((n) => {
|
|
1420
1408
|
if (n.code === resources_code) {
|
|
1421
1409
|
resources.push(...n.renderList || []);
|
|
@@ -1428,7 +1416,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1428
1416
|
resourcesTypeId = (_g2 = (_f2 = (_e2 = (_d2 = item == null ? void 0 : item._productOrigin) == null ? void 0 : _d2.product_resource) == null ? void 0 : _e2.resources) == null ? void 0 : _f2.find(
|
|
1429
1417
|
(n) => n.code === resources_code
|
|
1430
1418
|
)) == null ? void 0 : _g2.id;
|
|
1431
|
-
if (((_h2 = item._productOrigin) == null ? void 0 : _h2.cut_off_time) && ((
|
|
1419
|
+
if (((_h2 = item._productOrigin) == null ? void 0 : _h2.cut_off_time) && ((_i2 = item._productOrigin) == null ? void 0 : _i2.cut_off_time.type) === "advance") {
|
|
1432
1420
|
const currentCutOffTime = (0, import_dayjs.default)().add(
|
|
1433
1421
|
item._productOrigin.cut_off_time.unit,
|
|
1434
1422
|
item._productOrigin.cut_off_time.unit_type
|
|
@@ -1446,6 +1434,19 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1446
1434
|
}
|
|
1447
1435
|
});
|
|
1448
1436
|
}
|
|
1437
|
+
if (((_c = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _c.date) && resources.length) {
|
|
1438
|
+
const currentDate = (_d = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _d.date;
|
|
1439
|
+
const theDateResources = this.store.date.getResourcesListByDate(currentDate);
|
|
1440
|
+
resources.forEach((item) => {
|
|
1441
|
+
var _a2;
|
|
1442
|
+
const noCurrentDateTimes = item.times.some((n) => {
|
|
1443
|
+
return (0, import_dayjs.default)(n.start_at).isSame((0, import_dayjs.default)(currentDate), "day");
|
|
1444
|
+
});
|
|
1445
|
+
if (!noCurrentDateTimes) {
|
|
1446
|
+
item.times = ((_a2 = theDateResources == null ? void 0 : theDateResources.find((n) => n.id === item.id)) == null ? void 0 : _a2.times) || [];
|
|
1447
|
+
}
|
|
1448
|
+
});
|
|
1449
|
+
}
|
|
1449
1450
|
const resourcesMap = (0, import_utils2.getResourcesMap)(resources);
|
|
1450
1451
|
let duration = 0;
|
|
1451
1452
|
const accountList = this.store.accountList.getAccounts();
|
|
@@ -1473,7 +1474,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1473
1474
|
} else {
|
|
1474
1475
|
checkDuration(cartItems);
|
|
1475
1476
|
}
|
|
1476
|
-
if (!((
|
|
1477
|
+
if (!((_e = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _e.start_date) && !((_f = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _f.resource_id) || !(cartItems == null ? void 0 : cartItems[0].duration)) {
|
|
1477
1478
|
return [];
|
|
1478
1479
|
}
|
|
1479
1480
|
if ((cartItems == null ? void 0 : cartItems[0].start_date) && !dateRange) {
|
|
@@ -1485,7 +1486,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1485
1486
|
weekNum: 0
|
|
1486
1487
|
},
|
|
1487
1488
|
{
|
|
1488
|
-
date: ((
|
|
1489
|
+
date: ((_g = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _g.end_date) || ((_h = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _h.start_date) || "",
|
|
1489
1490
|
status: "available",
|
|
1490
1491
|
week: "",
|
|
1491
1492
|
weekNum: 0
|
|
@@ -1499,26 +1500,38 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1499
1500
|
return ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.type) === "flexible";
|
|
1500
1501
|
}
|
|
1501
1502
|
);
|
|
1502
|
-
let operating_day_boundary = (
|
|
1503
|
+
let operating_day_boundary = (_j = (_i = this.shopStore.get("core")) == null ? void 0 : _i.core) == null ? void 0 : _j.operating_day_boundary;
|
|
1503
1504
|
let maxBlockThreshold = 0;
|
|
1504
1505
|
if (hasFlexibleDuration) {
|
|
1505
1506
|
maxBlockThreshold = cartItems.reduce((max, item) => {
|
|
1506
1507
|
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
1507
1508
|
if ((_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.flexible_config) == null ? void 0 : _c2.is_enable_minimum_duration) {
|
|
1508
|
-
return Math.max(
|
|
1509
|
+
return Math.max(
|
|
1510
|
+
max,
|
|
1511
|
+
((_f2 = (_e2 = (_d2 = item._productOrigin) == null ? void 0 : _d2.duration) == null ? void 0 : _e2.flexible_config) == null ? void 0 : _f2.block_threshold) || 0
|
|
1512
|
+
);
|
|
1509
1513
|
}
|
|
1510
1514
|
return 0;
|
|
1511
1515
|
}, 0);
|
|
1512
1516
|
}
|
|
1513
1517
|
const calculateCapacityFromCartItems = (items) => {
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1518
|
+
var _a2;
|
|
1519
|
+
const firstResource = (_a2 = items[0]._resourceOrigin) == null ? void 0 : _a2[0].id;
|
|
1520
|
+
const sameResourceLength = items.filter((item) => {
|
|
1521
|
+
var _a3;
|
|
1522
|
+
return ((_a3 = item._resourceOrigin) == null ? void 0 : _a3[0].id) === firstResource;
|
|
1523
|
+
}).length;
|
|
1524
|
+
if (sameResourceLength === items.length) {
|
|
1525
|
+
return 1;
|
|
1526
|
+
}
|
|
1527
|
+
return Math.max(...items.map((item) => (0, import_capacity.getCapacityInfoByCartItem)(item).currentCapacity || 1));
|
|
1517
1528
|
};
|
|
1518
1529
|
let maxCapacity = 1;
|
|
1519
1530
|
if (cartItems == null ? void 0 : cartItems[0].holder_id) {
|
|
1520
1531
|
accountList.forEach((account) => {
|
|
1521
|
-
const accountCartItems = this.store.cart.getCartByAccount(
|
|
1532
|
+
const accountCartItems = this.store.cart.getCartByAccount(
|
|
1533
|
+
account.getId()
|
|
1534
|
+
);
|
|
1522
1535
|
const currentCapacity = calculateCapacityFromCartItems(accountCartItems);
|
|
1523
1536
|
if (currentCapacity > maxCapacity) {
|
|
1524
1537
|
maxCapacity = currentCapacity;
|
|
@@ -1542,6 +1555,172 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1542
1555
|
});
|
|
1543
1556
|
return timeSlots;
|
|
1544
1557
|
}
|
|
1558
|
+
// 从购物车中获取已经分配好第一步资源的所有时间片,批量版本,用于给日期提供能否高亮的判断
|
|
1559
|
+
async getTimeSlotByAllResourcesForDate({ resources_code, startDate, endDate }) {
|
|
1560
|
+
var _a, _b, _c, _d;
|
|
1561
|
+
if ((0, import_dayjs.default)(endDate).diff((0, import_dayjs.default)(startDate), "day") < 30) {
|
|
1562
|
+
endDate = (0, import_dayjs.default)(startDate).add(30, "day").format("YYYY-MM-DD");
|
|
1563
|
+
}
|
|
1564
|
+
await this.getAvailableDate({
|
|
1565
|
+
startDate,
|
|
1566
|
+
endDate,
|
|
1567
|
+
useCache: true
|
|
1568
|
+
});
|
|
1569
|
+
const resources = [];
|
|
1570
|
+
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils5.isNormalProduct)(n._productOrigin));
|
|
1571
|
+
const resourceIds = [];
|
|
1572
|
+
let resourcesTypeId = void 0;
|
|
1573
|
+
let isSingleResource = false;
|
|
1574
|
+
let maxCutOffTime = void 0;
|
|
1575
|
+
let maxCutOffTimeValue = (0, import_dayjs.default)();
|
|
1576
|
+
cartItems.forEach((item) => {
|
|
1577
|
+
var _a2, _b2, _c2, _d2, _e, _f, _g, _h, _i;
|
|
1578
|
+
(_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.forEach((n) => {
|
|
1579
|
+
if (n.code === resources_code) {
|
|
1580
|
+
resources.push(...n.renderList || []);
|
|
1581
|
+
isSingleResource = n.type === "single";
|
|
1582
|
+
}
|
|
1583
|
+
});
|
|
1584
|
+
if (item.resource_id && !resourceIds.includes(item.resource_id)) {
|
|
1585
|
+
resourceIds.push(item.resource_id);
|
|
1586
|
+
}
|
|
1587
|
+
resourcesTypeId = (_g = (_f = (_e = (_d2 = item == null ? void 0 : item._productOrigin) == null ? void 0 : _d2.product_resource) == null ? void 0 : _e.resources) == null ? void 0 : _f.find(
|
|
1588
|
+
(n) => n.code === resources_code
|
|
1589
|
+
)) == null ? void 0 : _g.id;
|
|
1590
|
+
if (((_h = item._productOrigin) == null ? void 0 : _h.cut_off_time) && ((_i = item._productOrigin) == null ? void 0 : _i.cut_off_time.type) === "advance") {
|
|
1591
|
+
const currentCutOffTime = (0, import_dayjs.default)().add(
|
|
1592
|
+
item._productOrigin.cut_off_time.unit,
|
|
1593
|
+
item._productOrigin.cut_off_time.unit_type
|
|
1594
|
+
);
|
|
1595
|
+
if (currentCutOffTime.isAfter(maxCutOffTimeValue, "minute")) {
|
|
1596
|
+
maxCutOffTimeValue = currentCutOffTime;
|
|
1597
|
+
maxCutOffTime = item._productOrigin.cut_off_time;
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
});
|
|
1601
|
+
if (!resources.length)
|
|
1602
|
+
return [];
|
|
1603
|
+
let duration = 0;
|
|
1604
|
+
const accountList = this.store.accountList.getAccounts();
|
|
1605
|
+
const checkDuration = (cartItems2) => {
|
|
1606
|
+
let accountDuration = 0;
|
|
1607
|
+
cartItems2.forEach((item) => {
|
|
1608
|
+
var _a2, _b2, _c2, _d2, _e, _f;
|
|
1609
|
+
if (isSingleResource) {
|
|
1610
|
+
accountDuration += ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10;
|
|
1611
|
+
} else {
|
|
1612
|
+
if (accountDuration < (((_d2 = (_c2 = item._productOrigin) == null ? void 0 : _c2.duration) == null ? void 0 : _d2.value) || 10)) {
|
|
1613
|
+
accountDuration = ((_f = (_e = item._productOrigin) == null ? void 0 : _e.duration) == null ? void 0 : _f.value) || 10;
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
});
|
|
1617
|
+
if (accountDuration > duration) {
|
|
1618
|
+
duration = accountDuration;
|
|
1619
|
+
}
|
|
1620
|
+
};
|
|
1621
|
+
if (cartItems == null ? void 0 : cartItems[0].holder_id) {
|
|
1622
|
+
accountList.forEach((account) => {
|
|
1623
|
+
const cartItems2 = this.store.cart.getCartByAccount(account.getId());
|
|
1624
|
+
checkDuration(cartItems2);
|
|
1625
|
+
});
|
|
1626
|
+
} else {
|
|
1627
|
+
checkDuration(cartItems);
|
|
1628
|
+
}
|
|
1629
|
+
if (!((_a = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _a.start_date) && !((_b = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _b.resource_id) || !(cartItems == null ? void 0 : cartItems[0].duration)) {
|
|
1630
|
+
return [];
|
|
1631
|
+
}
|
|
1632
|
+
const resourcesUseableMap = {};
|
|
1633
|
+
const hasFlexibleDuration = cartItems.some(
|
|
1634
|
+
(item) => {
|
|
1635
|
+
var _a2, _b2;
|
|
1636
|
+
return ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.type) === "flexible";
|
|
1637
|
+
}
|
|
1638
|
+
);
|
|
1639
|
+
let operating_day_boundary = (_d = (_c = this.shopStore.get("core")) == null ? void 0 : _c.core) == null ? void 0 : _d.operating_day_boundary;
|
|
1640
|
+
let maxBlockThreshold = 0;
|
|
1641
|
+
if (hasFlexibleDuration) {
|
|
1642
|
+
maxBlockThreshold = cartItems.reduce((max, item) => {
|
|
1643
|
+
var _a2, _b2, _c2, _d2, _e, _f;
|
|
1644
|
+
if ((_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.flexible_config) == null ? void 0 : _c2.is_enable_minimum_duration) {
|
|
1645
|
+
return Math.max(max, ((_f = (_e = (_d2 = item._productOrigin) == null ? void 0 : _d2.duration) == null ? void 0 : _e.flexible_config) == null ? void 0 : _f.block_threshold) || 0);
|
|
1646
|
+
}
|
|
1647
|
+
return 0;
|
|
1648
|
+
}, 0);
|
|
1649
|
+
}
|
|
1650
|
+
const calculateCapacityFromCartItems = (items) => {
|
|
1651
|
+
var _a2;
|
|
1652
|
+
const firstResource = (_a2 = items[0]._resourceOrigin) == null ? void 0 : _a2[0].id;
|
|
1653
|
+
const sameResourceLength = items.filter((item) => {
|
|
1654
|
+
var _a3;
|
|
1655
|
+
return ((_a3 = item._resourceOrigin) == null ? void 0 : _a3[0].id) === firstResource;
|
|
1656
|
+
}).length;
|
|
1657
|
+
if (sameResourceLength !== items.length) {
|
|
1658
|
+
return 1;
|
|
1659
|
+
}
|
|
1660
|
+
return Math.max(...items.map((item) => (0, import_capacity.getCapacityInfoByCartItem)(item).currentCapacity || 1));
|
|
1661
|
+
};
|
|
1662
|
+
let maxCapacity = 1;
|
|
1663
|
+
if (cartItems == null ? void 0 : cartItems[0].holder_id) {
|
|
1664
|
+
accountList.forEach((account) => {
|
|
1665
|
+
const accountCartItems = this.store.cart.getCartByAccount(account.getId());
|
|
1666
|
+
const currentCapacity = calculateCapacityFromCartItems(accountCartItems);
|
|
1667
|
+
if (currentCapacity > maxCapacity) {
|
|
1668
|
+
maxCapacity = currentCapacity;
|
|
1669
|
+
}
|
|
1670
|
+
});
|
|
1671
|
+
} else {
|
|
1672
|
+
maxCapacity = calculateCapacityFromCartItems(cartItems);
|
|
1673
|
+
}
|
|
1674
|
+
const arr = [];
|
|
1675
|
+
const today = (0, import_dayjs.default)().startOf("day");
|
|
1676
|
+
for (let i = (0, import_dayjs.default)(startDate); i.isBefore((0, import_dayjs.default)(endDate)); i = i.add(1, "day")) {
|
|
1677
|
+
const currentDate = i.format("YYYY-MM-DD");
|
|
1678
|
+
const theDateResources = this.store.date.getResourcesListByDate(currentDate);
|
|
1679
|
+
resources.forEach((item) => {
|
|
1680
|
+
var _a2;
|
|
1681
|
+
item.times = ((_a2 = theDateResources == null ? void 0 : theDateResources.find((n) => n.id === item.id)) == null ? void 0 : _a2.times) || [];
|
|
1682
|
+
});
|
|
1683
|
+
const resourcesMap = (0, import_utils2.getResourcesMap)(resources);
|
|
1684
|
+
if (i.isBefore(today)) {
|
|
1685
|
+
arr.push({
|
|
1686
|
+
date: currentDate,
|
|
1687
|
+
status: "unavailable",
|
|
1688
|
+
week: i.format("ddd"),
|
|
1689
|
+
weekNum: i.day()
|
|
1690
|
+
});
|
|
1691
|
+
continue;
|
|
1692
|
+
}
|
|
1693
|
+
const timeSlots = (0, import_resources.getTimeSlicesByResources)({
|
|
1694
|
+
resourceIds,
|
|
1695
|
+
resourcesMap,
|
|
1696
|
+
duration,
|
|
1697
|
+
currentDate,
|
|
1698
|
+
split: 10,
|
|
1699
|
+
resourcesUseableMap,
|
|
1700
|
+
capacity: maxCapacity,
|
|
1701
|
+
cut_off_time: maxCutOffTime,
|
|
1702
|
+
hasFlexibleDuration,
|
|
1703
|
+
operating_day_boundary,
|
|
1704
|
+
maxBlockThreshold
|
|
1705
|
+
});
|
|
1706
|
+
if (timeSlots.length > 0) {
|
|
1707
|
+
arr.push({
|
|
1708
|
+
date: currentDate,
|
|
1709
|
+
status: "available",
|
|
1710
|
+
week: i.format("ddd"),
|
|
1711
|
+
weekNum: i.day()
|
|
1712
|
+
});
|
|
1713
|
+
} else {
|
|
1714
|
+
arr.push({
|
|
1715
|
+
date: currentDate,
|
|
1716
|
+
status: "unavailable",
|
|
1717
|
+
week: i.format("ddd"),
|
|
1718
|
+
weekNum: i.day()
|
|
1719
|
+
});
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
return arr;
|
|
1723
|
+
}
|
|
1545
1724
|
// 提交时间切片,绑定到对应购物车的商品上,更新购物车---只有 duration 商品
|
|
1546
1725
|
submitTimeSlot(timeSlots) {
|
|
1547
1726
|
var _a, _b;
|
|
@@ -1685,7 +1864,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1685
1864
|
resources,
|
|
1686
1865
|
product
|
|
1687
1866
|
}) {
|
|
1688
|
-
var _a, _b, _c, _d, _e;
|
|
1867
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1689
1868
|
const targetProduct = this.store.currentProduct;
|
|
1690
1869
|
const targetProductData = product || targetProduct;
|
|
1691
1870
|
let targetSchedules = [];
|
|
@@ -1731,11 +1910,16 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1731
1910
|
const firstEnabledResourceId = (_e = (_d = (_c = targetProductData == null ? void 0 : targetProductData.product_resource) == null ? void 0 : _c.resources) == null ? void 0 : _d.find(
|
|
1732
1911
|
(n) => n.status === 1
|
|
1733
1912
|
)) == null ? void 0 : _e.id;
|
|
1913
|
+
const firstEnabledResourceConfig = (_g = (_f = targetProductData == null ? void 0 : targetProductData.product_resource) == null ? void 0 : _f.resources) == null ? void 0 : _g.find(
|
|
1914
|
+
(n) => n.status === 1 && n.id === firstEnabledResourceId
|
|
1915
|
+
);
|
|
1916
|
+
const isMultipleBooking = (firstEnabledResourceConfig == null ? void 0 : firstEnabledResourceConfig.type) === "multiple";
|
|
1734
1917
|
const formatScheduleTimeSlots = scheduleTimeSlots.map((item) => {
|
|
1735
1918
|
const resourcesUseableMap = {};
|
|
1736
1919
|
let count = 0;
|
|
1737
1920
|
let bookingLeft = 0;
|
|
1738
1921
|
let summaryCount = 0;
|
|
1922
|
+
let summaryConfigCount = 0;
|
|
1739
1923
|
allProductResources == null ? void 0 : allProductResources.forEach((m) => {
|
|
1740
1924
|
let currentResourcesCount = 0;
|
|
1741
1925
|
let currentResourcesSummaryCount = 0;
|
|
@@ -1771,6 +1955,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1771
1955
|
}
|
|
1772
1956
|
currentResourcesTimeSlotCanUsedArr.push(res.usable);
|
|
1773
1957
|
});
|
|
1958
|
+
if (m.form_id === firstEnabledResourceId) {
|
|
1959
|
+
if (isMultipleBooking) {
|
|
1960
|
+
summaryConfigCount += m.capacity;
|
|
1961
|
+
} else {
|
|
1962
|
+
summaryConfigCount += 1;
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1774
1965
|
if (!currentResourcesTimeSlotCanUsedArr.some(
|
|
1775
1966
|
(n) => n === false
|
|
1776
1967
|
) && // 只统计第一种资源的容量和 left
|
|
@@ -1797,13 +1988,17 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1797
1988
|
count = 0;
|
|
1798
1989
|
summaryCount = 0;
|
|
1799
1990
|
}
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1991
|
+
let otherCartItems = cartItems2.filter(
|
|
1992
|
+
(m) => {
|
|
1993
|
+
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
1994
|
+
const isTimeMatch = ((_b2 = (_a2 = m._productOrigin) == null ? void 0 : _a2.id) == null ? void 0 : _b2.toString()) !== ((_c2 = targetProductData == null ? void 0 : targetProductData.id) == null ? void 0 : _c2.toString()) && `${m.start_date} ${m.start_time}` === item.start && `${m.start_date} ${m.end_time}` === item.end;
|
|
1995
|
+
const isResourceMatch = (_f2 = (_e2 = (_d2 = m._productOrigin) == null ? void 0 : _d2.product_resource) == null ? void 0 : _e2.resources) == null ? void 0 : _f2.find((m2) => m2.type === n.type && m2.status === 1);
|
|
1996
|
+
return isTimeMatch && isResourceMatch;
|
|
1997
|
+
}
|
|
1998
|
+
);
|
|
1804
1999
|
otherCartItems.forEach((m) => {
|
|
1805
2000
|
var _a2, _b2, _c2;
|
|
1806
|
-
const sameTypeResources = (_c2 = (_b2 = (_a2 = m._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.find((m2) => m2.type === n.type);
|
|
2001
|
+
const sameTypeResources = (_c2 = (_b2 = (_a2 = m._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.find((m2) => m2.type === n.type && m2.status === 1);
|
|
1807
2002
|
const sameTypeResourcesSet = /* @__PURE__ */ new Set([...(sameTypeResources == null ? void 0 : sameTypeResources.optional_resource) || [], ...(sameTypeResources == null ? void 0 : sameTypeResources.default_resource) || []]);
|
|
1808
2003
|
sameTypeResourcesSet.forEach((resource) => currentResourcesSet.add(resource));
|
|
1809
2004
|
});
|
|
@@ -1884,6 +2079,34 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1884
2079
|
});
|
|
1885
2080
|
const startDayJs = (0, import_dayjs.default)(item.start);
|
|
1886
2081
|
const endDayJs = (0, import_dayjs.default)(item.end);
|
|
2082
|
+
let timeStatus = "sold_out";
|
|
2083
|
+
if (bookingLeft === 0)
|
|
2084
|
+
timeStatus = "sold_out";
|
|
2085
|
+
else if (isMultipleBooking) {
|
|
2086
|
+
if (summaryConfigCount === 0)
|
|
2087
|
+
timeStatus = "sold_out";
|
|
2088
|
+
else {
|
|
2089
|
+
const usageRatio = summaryCount / summaryConfigCount;
|
|
2090
|
+
if (usageRatio > 0.5)
|
|
2091
|
+
timeStatus = "lots_of_space";
|
|
2092
|
+
else if (summaryCount > 0)
|
|
2093
|
+
timeStatus = "filling_up_fast";
|
|
2094
|
+
else
|
|
2095
|
+
timeStatus = "sold_out";
|
|
2096
|
+
}
|
|
2097
|
+
} else {
|
|
2098
|
+
if (summaryConfigCount === 0)
|
|
2099
|
+
timeStatus = "sold_out";
|
|
2100
|
+
else {
|
|
2101
|
+
const usageRatio = bookingLeft / summaryConfigCount;
|
|
2102
|
+
if (usageRatio > 0.5)
|
|
2103
|
+
timeStatus = "lots_of_space";
|
|
2104
|
+
else if (count > 0)
|
|
2105
|
+
timeStatus = "filling_up_fast";
|
|
2106
|
+
else
|
|
2107
|
+
timeStatus = "sold_out";
|
|
2108
|
+
}
|
|
2109
|
+
}
|
|
1887
2110
|
return {
|
|
1888
2111
|
start_time: startDayJs.format("HH:mm"),
|
|
1889
2112
|
end_time: endDayJs.format("HH:mm"),
|
|
@@ -1891,7 +2114,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1891
2114
|
end_at: endDayJs,
|
|
1892
2115
|
count,
|
|
1893
2116
|
left: bookingLeft,
|
|
1894
|
-
summaryCount
|
|
2117
|
+
summaryCount,
|
|
2118
|
+
status: timeStatus
|
|
1895
2119
|
};
|
|
1896
2120
|
});
|
|
1897
2121
|
return formatScheduleTimeSlots;
|
|
@@ -1977,6 +2201,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1977
2201
|
if (!itemsByResourceType[resourceCode]) {
|
|
1978
2202
|
itemsByResourceType[resourceCode] = [];
|
|
1979
2203
|
}
|
|
2204
|
+
if (itemsByResourceType[resourceCode].find((item) => item.holder_id === cartItem.holder_id)) {
|
|
2205
|
+
return;
|
|
2206
|
+
}
|
|
1980
2207
|
if (!itemsByResourceType[resourceCode].find((item) => item._id === cartItem._id)) {
|
|
1981
2208
|
itemsByResourceType[resourceCode].push(cartItem);
|
|
1982
2209
|
}
|
|
@@ -2662,6 +2889,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2662
2889
|
while ((0, import_dayjs.default)(currentDate).isBefore((0, import_dayjs.default)(endDate), "day") || (0, import_dayjs.default)(currentDate).isSame((0, import_dayjs.default)(endDate), "day")) {
|
|
2663
2890
|
const currentDateStr = currentDate.format("YYYY-MM-DD");
|
|
2664
2891
|
let status = "available";
|
|
2892
|
+
let summaryCount = 0;
|
|
2893
|
+
let availableCount = 0;
|
|
2665
2894
|
const { latestStartDate, earliestEndDate } = (0, import_resources.checkSessionProductLeadTime)(tempProducts);
|
|
2666
2895
|
if (latestStartDate || earliestEndDate) {
|
|
2667
2896
|
if (latestStartDate && (0, import_dayjs.default)(currentDate).isBefore(latestStartDate, "day")) {
|
|
@@ -2686,43 +2915,64 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2686
2915
|
currentDateStr
|
|
2687
2916
|
);
|
|
2688
2917
|
const scheduleTimeSlots = (0, import_utils3.getAllSortedDateRanges)(minTimeMaxTime);
|
|
2689
|
-
|
|
2918
|
+
let timesSlotCanUse = false;
|
|
2919
|
+
scheduleTimeSlots.forEach((item) => {
|
|
2690
2920
|
const resourcesUseableMap = {};
|
|
2691
|
-
|
|
2921
|
+
let isAllResourceTypesUseable = true;
|
|
2922
|
+
openResources.forEach((resource) => {
|
|
2692
2923
|
const currentResourcesList = allProductResources.filter(
|
|
2693
2924
|
(n) => n.form_id === resource.resource_type_id
|
|
2694
2925
|
);
|
|
2695
|
-
|
|
2926
|
+
let isAnyResourceUseableInType = false;
|
|
2927
|
+
currentResourcesList == null ? void 0 : currentResourcesList.forEach((m) => {
|
|
2696
2928
|
const mTimes = m.times.filter((n) => {
|
|
2697
2929
|
return !(0, import_dayjs.default)(n.start_at).isAfter((0, import_dayjs.default)(item.start), "minute") && !(0, import_dayjs.default)(n.end_at).isBefore((0, import_dayjs.default)(item.end), "minute");
|
|
2698
2930
|
});
|
|
2699
|
-
if (mTimes.length === 0)
|
|
2931
|
+
if (mTimes.length === 0)
|
|
2700
2932
|
return;
|
|
2933
|
+
if (resource.type === "multiple") {
|
|
2934
|
+
summaryCount += m.capacity;
|
|
2935
|
+
} else {
|
|
2936
|
+
summaryCount += 1;
|
|
2701
2937
|
}
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2938
|
+
let isAnyTimeSliceUseable = false;
|
|
2939
|
+
mTimes.forEach((childTiem) => {
|
|
2940
|
+
if (isAnyTimeSliceUseable)
|
|
2941
|
+
return;
|
|
2942
|
+
const res2 = (0, import_resources.getIsUsableByTimeItem)({
|
|
2943
|
+
timeSlice: {
|
|
2944
|
+
start_time: item.start,
|
|
2945
|
+
end_time: item.end,
|
|
2946
|
+
start_at: (0, import_dayjs.default)(item.start),
|
|
2947
|
+
end_at: (0, import_dayjs.default)(item.end)
|
|
2948
|
+
},
|
|
2949
|
+
time: childTiem,
|
|
2950
|
+
resource: m,
|
|
2951
|
+
currentCount: 1,
|
|
2952
|
+
resourcesUseableMap,
|
|
2953
|
+
cut_off_time: tempProducts == null ? void 0 : tempProducts.cut_off_time
|
|
2954
|
+
});
|
|
2955
|
+
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false && res2.reason !== "capacityOnly") {
|
|
2956
|
+
resourcesUseableMap[m.id] = res2.usable;
|
|
2957
|
+
}
|
|
2958
|
+
if (res2.usable && !m.onlyComputed) {
|
|
2959
|
+
isAnyTimeSliceUseable = true;
|
|
2960
|
+
if (resource.type === "multiple") {
|
|
2961
|
+
availableCount += res2.remainingCapacity;
|
|
2962
|
+
} else {
|
|
2963
|
+
availableCount += 1;
|
|
2719
2964
|
}
|
|
2720
|
-
return res2.usable && !m.onlyComputed;
|
|
2721
2965
|
}
|
|
2722
|
-
|
|
2723
|
-
|
|
2966
|
+
;
|
|
2967
|
+
});
|
|
2968
|
+
if (isAnyTimeSliceUseable)
|
|
2969
|
+
isAnyResourceUseableInType = true;
|
|
2724
2970
|
});
|
|
2971
|
+
if (!isAnyResourceUseableInType)
|
|
2972
|
+
isAllResourceTypesUseable = false;
|
|
2725
2973
|
});
|
|
2974
|
+
if (isAllResourceTypesUseable)
|
|
2975
|
+
timesSlotCanUse = true;
|
|
2726
2976
|
});
|
|
2727
2977
|
if (!timesSlotCanUse) {
|
|
2728
2978
|
status = "unavailable";
|
|
@@ -2731,11 +2981,26 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2731
2981
|
firstAvailableDate = currentDateStr;
|
|
2732
2982
|
}
|
|
2733
2983
|
}
|
|
2984
|
+
let dateStatus;
|
|
2985
|
+
if (status === "unavailable") {
|
|
2986
|
+
if (availableCount === 0 && summaryCount > 0)
|
|
2987
|
+
dateStatus = "sold_out";
|
|
2988
|
+
else
|
|
2989
|
+
dateStatus = "unavailable";
|
|
2990
|
+
} else {
|
|
2991
|
+
const usageRatio = availableCount / summaryCount;
|
|
2992
|
+
if (usageRatio > 0.5)
|
|
2993
|
+
dateStatus = "lots_of_space";
|
|
2994
|
+
else
|
|
2995
|
+
dateStatus = "filling_up_fast";
|
|
2996
|
+
}
|
|
2734
2997
|
dates.push({
|
|
2735
2998
|
date: (0, import_dayjs.default)(currentDate).format("YYYY-MM-DD"),
|
|
2736
2999
|
week: (0, import_dayjs.default)(currentDate).format("ddd"),
|
|
2737
3000
|
weekNum: (0, import_dayjs.default)(currentDate).day(),
|
|
2738
|
-
|
|
3001
|
+
summaryCount,
|
|
3002
|
+
availableCount,
|
|
3003
|
+
status: dateStatus
|
|
2739
3004
|
});
|
|
2740
3005
|
if (firstAvailableDate && (0, import_dayjs.default)(currentDate).diff((0, import_dayjs.default)(startDate), "day") > 31) {
|
|
2741
3006
|
break;
|
|
@@ -9,9 +9,3 @@ export declare const getAvailableProductResources: (products: ProductData[]) =>
|
|
|
9
9
|
rules: any[];
|
|
10
10
|
resourcesMap: Record<number, ProductResourceItem>;
|
|
11
11
|
};
|
|
12
|
-
/**
|
|
13
|
-
* 判断商品是否是 session 商品
|
|
14
|
-
* @param product 商品数据
|
|
15
|
-
* @returns 是否是 session 商品
|
|
16
|
-
*/
|
|
17
|
-
export declare const isSessionProduct: (product: ProductData) => boolean;
|
|
@@ -19,8 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
// src/solution/BookingByStep/utils/products.ts
|
|
20
20
|
var products_exports = {};
|
|
21
21
|
__export(products_exports, {
|
|
22
|
-
getAvailableProductResources: () => getAvailableProductResources
|
|
23
|
-
isSessionProduct: () => isSessionProduct
|
|
22
|
+
getAvailableProductResources: () => getAvailableProductResources
|
|
24
23
|
});
|
|
25
24
|
module.exports = __toCommonJS(products_exports);
|
|
26
25
|
var getAvailableProductResources = (products) => {
|
|
@@ -58,12 +57,7 @@ var getAvailableProductResources = (products) => {
|
|
|
58
57
|
});
|
|
59
58
|
return { resourceIds: [...new Set(resourceIds)], rules, resourcesMap };
|
|
60
59
|
};
|
|
61
|
-
var isSessionProduct = (product) => {
|
|
62
|
-
var _a;
|
|
63
|
-
return (((_a = product == null ? void 0 : product["schedule.ids"]) == null ? void 0 : _a.length) ?? 0) > 0;
|
|
64
|
-
};
|
|
65
60
|
// Annotate the CommonJS export names for ESM import in node:
|
|
66
61
|
0 && (module.exports = {
|
|
67
|
-
getAvailableProductResources
|
|
68
|
-
isSessionProduct
|
|
62
|
+
getAvailableProductResources
|
|
69
63
|
});
|
|
@@ -353,7 +353,10 @@ var getTimeSlicesByResource = ({
|
|
|
353
353
|
});
|
|
354
354
|
times.forEach((time) => {
|
|
355
355
|
const startTime = (0, import_dayjs.default)(`${time.start_at}`);
|
|
356
|
-
|
|
356
|
+
let endTime = (0, import_dayjs.default)(`${time.end_at}`);
|
|
357
|
+
if (endTime.isAfter((0, import_dayjs.default)(currentDate).endOf("day"))) {
|
|
358
|
+
endTime = (0, import_dayjs.default)(currentDate).endOf("day");
|
|
359
|
+
}
|
|
357
360
|
let currentStart = startTime;
|
|
358
361
|
while (true) {
|
|
359
362
|
const currentEnd = currentStart.add(duration, "minute");
|