@pisell/pisellos 3.0.74 → 3.0.76
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 +2 -1
- package/dist/effects/index.d.ts +5 -3
- package/dist/effects/index.js +40 -8
- package/dist/modules/Account/index.js +2 -3
- package/dist/modules/AccountList/index.d.ts +7 -1
- package/dist/modules/AccountList/index.js +81 -14
- package/dist/modules/AccountList/types.d.ts +28 -0
- package/dist/modules/AccountList/types.js +8 -0
- package/dist/modules/BaseModule.d.ts +3 -0
- package/dist/modules/BaseModule.js +15 -0
- package/dist/modules/Cart/index.d.ts +1 -0
- package/dist/modules/Cart/index.js +2 -1
- package/dist/modules/Cart/utils/cartProduct.js +21 -4
- package/dist/modules/Customer/constants.d.ts +7 -0
- package/dist/modules/Customer/constants.js +12 -0
- package/dist/modules/Customer/index.d.ts +122 -0
- package/dist/modules/Customer/index.js +696 -0
- package/dist/modules/Customer/types.d.ts +146 -0
- package/dist/modules/Customer/types.js +41 -0
- package/dist/modules/Discount/index.d.ts +1 -0
- package/dist/modules/Discount/index.js +3 -3
- package/dist/modules/Discount/types.d.ts +9 -0
- package/dist/modules/Guests/index.js +9 -9
- package/dist/modules/Order/index.d.ts +25 -1
- package/dist/modules/Order/index.js +224 -3
- package/dist/modules/Order/types.d.ts +45 -0
- package/dist/modules/Order/types.js +8 -0
- package/dist/modules/Order/utils.js +1 -1
- package/dist/modules/Payment/cash.d.ts +19 -0
- package/dist/modules/Payment/cash.js +97 -0
- package/dist/modules/Payment/cashRecommendationAlgorithm.d.ts +22 -0
- package/dist/modules/Payment/cashRecommendationAlgorithm.js +423 -0
- package/dist/modules/Payment/eftpos.d.ts +11 -0
- package/dist/modules/Payment/eftpos.js +80 -0
- package/dist/modules/Payment/index.d.ts +184 -9
- package/dist/modules/Payment/index.js +2084 -109
- package/dist/modules/Payment/mx51.d.ts +0 -0
- package/dist/modules/Payment/mx51.js +0 -0
- package/dist/modules/Payment/types.d.ts +772 -30
- package/dist/modules/Payment/types.js +236 -12
- package/dist/modules/Payment/utils.d.ts +17 -0
- package/dist/modules/Payment/utils.js +62 -0
- package/dist/modules/Payment/walletpass.d.ts +99 -0
- package/dist/modules/Payment/walletpass.js +711 -0
- package/dist/modules/ProductList/index.d.ts +12 -1
- package/dist/modules/ProductList/index.js +37 -15
- package/dist/modules/Resource/index.js +1 -1
- package/dist/modules/Rules/index.d.ts +2 -1
- package/dist/modules/Rules/index.js +470 -127
- package/dist/modules/Rules/types.d.ts +1 -0
- package/dist/modules/Schedule/index.d.ts +9 -0
- package/dist/modules/Schedule/index.js +77 -0
- package/dist/modules/Summary/utils.d.ts +5 -0
- package/dist/modules/Summary/utils.js +36 -1
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +1 -0
- package/dist/plugins/app-types/app/app.d.ts +83 -0
- package/dist/plugins/app-types/app/const.d.ts +4 -0
- package/dist/plugins/app-types/app/index.d.ts +14 -0
- package/dist/plugins/app-types/applicationManager/application.d.ts +50 -0
- package/dist/plugins/app-types/applicationManager/index.d.ts +13 -0
- package/dist/plugins/app-types/config.d.ts +3 -0
- package/dist/plugins/app-types/cookie/index.d.ts +13 -0
- package/dist/plugins/app-types/data/index.d.ts +8 -0
- package/dist/plugins/app-types/history/config.d.ts +24 -0
- package/dist/plugins/app-types/history/index.d.ts +20 -0
- package/dist/plugins/app-types/history/type.d.ts +2 -0
- package/dist/plugins/app-types/hooks/index.d.ts +12 -0
- package/dist/plugins/app-types/hooks/useDelayedValue/index.d.ts +2 -0
- package/dist/plugins/app-types/hooks/useDispatch/index.d.ts +2 -0
- package/dist/plugins/app-types/hooks/useLowCode/index.d.ts +13 -0
- package/dist/plugins/app-types/hooks/useStore/index.d.ts +6 -0
- package/dist/plugins/app-types/index.d.ts +6 -0
- package/dist/plugins/app-types/indexDB/index.d.ts +178 -0
- package/dist/plugins/app-types/locales/en.d.ts +3 -0
- package/dist/plugins/app-types/locales/index.d.ts +37 -0
- package/dist/plugins/app-types/locales/original.d.ts +3 -0
- package/dist/plugins/app-types/locales/type.d.ts +19 -0
- package/dist/plugins/app-types/locales/zh-CN.d.ts +3 -0
- package/dist/plugins/app-types/locales/zh-HK.d.ts +3 -0
- package/dist/plugins/app-types/logger/feishu.d.ts +11 -0
- package/dist/plugins/app-types/logger/index.d.ts +122 -0
- package/dist/plugins/app-types/menuManager/hooks.d.ts +17 -0
- package/dist/plugins/app-types/menuManager/index.d.ts +28 -0
- package/dist/plugins/app-types/models/global.d.ts +32 -0
- package/dist/plugins/app-types/models/index.d.ts +45 -0
- package/dist/plugins/app-types/models/type.d.ts +2 -0
- package/dist/plugins/app-types/package.json +15 -0
- package/dist/plugins/app-types/plugin/index.d.ts +0 -0
- package/dist/plugins/app-types/pubsub/example.d.ts +5 -0
- package/dist/plugins/app-types/pubsub/index.d.ts +63 -0
- package/dist/plugins/app-types/request/cache.d.ts +46 -0
- package/dist/plugins/app-types/request/cancelToken.d.ts +38 -0
- package/dist/plugins/app-types/request/config.d.ts +3 -0
- package/dist/plugins/app-types/request/constants.d.ts +2 -0
- package/dist/plugins/app-types/request/index.d.ts +24 -0
- package/dist/plugins/app-types/request/pisell2Request.d.ts +6 -0
- package/dist/plugins/app-types/request/type.d.ts +41 -0
- package/dist/plugins/app-types/request/utils.d.ts +46 -0
- package/dist/plugins/app-types/routes/config.d.ts +7 -0
- package/dist/plugins/app-types/routes/index.d.ts +28 -0
- package/dist/plugins/app-types/socket/components/SocketMonitorPage.d.ts +6 -0
- package/dist/plugins/app-types/socket/components/index.d.ts +2 -0
- package/dist/plugins/app-types/socket/constants.d.ts +33 -0
- package/dist/plugins/app-types/socket/events.d.ts +31 -0
- package/dist/plugins/app-types/socket/heartbeat.d.ts +66 -0
- package/dist/plugins/app-types/socket/index.d.ts +61 -0
- package/dist/plugins/app-types/socket/monitor.d.ts +169 -0
- package/dist/plugins/app-types/socket/reconnect.d.ts +61 -0
- package/dist/plugins/app-types/socket/socket.d.ts +129 -0
- package/dist/plugins/app-types/socket/types.d.ts +85 -0
- package/dist/plugins/app-types/storage/index.d.ts +17 -0
- package/dist/plugins/app-types/tasks/index.d.ts +77 -0
- package/dist/plugins/app-types/tasks/type.d.ts +62 -0
- package/dist/plugins/app-types/tasks/useTasks.d.ts +5 -0
- package/dist/plugins/app-types/type.d.ts +2 -0
- package/dist/plugins/app-types/variables/VariablesProvider.d.ts +7 -0
- package/dist/plugins/app-types/variables/config.d.ts +3 -0
- package/dist/plugins/app-types/variables/index.d.ts +6 -0
- package/dist/plugins/app-types/variables/type.d.ts +2 -0
- package/dist/plugins/app-types/website/index.d.ts +6 -0
- package/dist/plugins/app.d.ts +8 -0
- package/dist/plugins/app.js +1 -0
- package/dist/plugins/window.d.ts +1 -0
- package/dist/solution/BookingByStep/index.js +43 -13
- package/dist/solution/BookingByStep/utils/capacity.js +1 -1
- package/dist/solution/BookingByStep/utils/products.d.ts +6 -0
- package/dist/solution/BookingByStep/utils/products.js +10 -0
- package/dist/solution/BookingTicket/index.d.ts +184 -0
- package/dist/solution/BookingTicket/index.js +698 -0
- package/dist/solution/BookingTicket/types.d.ts +68 -0
- package/dist/solution/BookingTicket/types.js +43 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.d.ts +22 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +159 -0
- package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +22 -0
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +189 -0
- package/dist/solution/BookingTicket/utils/scan/index.d.ts +85 -0
- package/dist/solution/BookingTicket/utils/scan/index.js +294 -0
- package/dist/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
- package/dist/solution/BookingTicket/utils/scan/scanCache.js +305 -0
- package/dist/solution/BuyTickets/index.js +7 -8
- package/dist/solution/Checkout/appointmentDemo.json +1 -0
- package/dist/solution/Checkout/index.d.ts +432 -0
- package/dist/solution/Checkout/index.js +4452 -0
- package/dist/solution/Checkout/types.d.ts +727 -0
- package/dist/solution/Checkout/types.js +104 -0
- package/dist/solution/Checkout/utils/index.d.ts +121 -0
- package/dist/solution/Checkout/utils/index.js +511 -0
- package/dist/solution/ShopDiscount/index.d.ts +10 -10
- package/dist/solution/ShopDiscount/index.js +111 -60
- package/dist/solution/ShopDiscount/types.d.ts +8 -0
- package/dist/solution/ShopDiscount/utils.d.ts +24 -0
- package/dist/solution/ShopDiscount/utils.js +135 -1
- package/dist/solution/index.d.ts +2 -0
- package/dist/solution/index.js +3 -1
- package/dist/types/index.d.ts +4 -1
- package/dist/utils/task.d.ts +40 -0
- package/dist/utils/task.js +171 -0
- package/dist/utils/watch.d.ts +102 -0
- package/dist/utils/watch.js +294 -0
- package/lib/core/index.js +1 -1
- package/lib/effects/index.d.ts +5 -3
- package/lib/effects/index.js +17 -1
- package/lib/modules/Account/index.js +2 -3
- package/lib/modules/AccountList/index.d.ts +7 -1
- package/lib/modules/AccountList/index.js +27 -0
- package/lib/modules/AccountList/types.d.ts +28 -0
- package/lib/modules/BaseModule.d.ts +3 -0
- package/lib/modules/BaseModule.js +9 -0
- package/lib/modules/Cart/index.d.ts +1 -0
- package/lib/modules/Cart/index.js +5 -2
- package/lib/modules/Cart/utils/cartProduct.js +22 -6
- package/lib/modules/Customer/constants.d.ts +7 -0
- package/lib/modules/Customer/constants.js +39 -0
- package/lib/modules/Customer/index.d.ts +122 -0
- package/lib/modules/Customer/index.js +439 -0
- package/lib/modules/Customer/types.d.ts +146 -0
- package/lib/modules/Customer/types.js +37 -0
- package/lib/modules/Discount/index.d.ts +1 -0
- package/lib/modules/Discount/index.js +3 -3
- package/lib/modules/Discount/types.d.ts +9 -0
- package/lib/modules/Guests/index.js +9 -9
- package/lib/modules/Order/index.d.ts +25 -1
- package/lib/modules/Order/index.js +186 -1
- package/lib/modules/Order/types.d.ts +45 -0
- package/lib/modules/Order/utils.js +1 -1
- package/lib/modules/Payment/cash.d.ts +19 -0
- package/lib/modules/Payment/cash.js +64 -0
- package/lib/modules/Payment/cashRecommendationAlgorithm.d.ts +22 -0
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +342 -0
- package/lib/modules/Payment/eftpos.d.ts +11 -0
- package/lib/modules/Payment/eftpos.js +51 -0
- package/lib/modules/Payment/index.d.ts +184 -9
- package/lib/modules/Payment/index.js +1084 -51
- package/lib/modules/Payment/mx51.d.ts +0 -0
- package/lib/modules/Payment/mx51.js +0 -0
- package/lib/modules/Payment/types.d.ts +772 -30
- package/lib/modules/Payment/types.js +79 -6
- package/lib/modules/Payment/utils.d.ts +17 -0
- package/lib/modules/Payment/utils.js +67 -0
- package/lib/modules/Payment/walletpass.d.ts +99 -0
- package/lib/modules/Payment/walletpass.js +484 -0
- package/lib/modules/ProductList/index.d.ts +12 -1
- package/lib/modules/ProductList/index.js +31 -12
- package/lib/modules/Resource/index.js +1 -1
- package/lib/modules/Rules/index.d.ts +2 -1
- package/lib/modules/Rules/index.js +318 -72
- package/lib/modules/Rules/types.d.ts +1 -0
- package/lib/modules/Schedule/index.d.ts +9 -0
- package/lib/modules/Schedule/index.js +60 -0
- package/lib/modules/Summary/utils.d.ts +5 -0
- package/lib/modules/Summary/utils.js +27 -3
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +2 -0
- package/lib/plugins/app-types/app/app.d.ts +83 -0
- package/lib/plugins/app-types/app/const.d.ts +4 -0
- package/lib/plugins/app-types/app/index.d.ts +14 -0
- package/lib/plugins/app-types/applicationManager/application.d.ts +50 -0
- package/lib/plugins/app-types/applicationManager/index.d.ts +13 -0
- package/lib/plugins/app-types/config.d.ts +3 -0
- package/lib/plugins/app-types/cookie/index.d.ts +13 -0
- package/lib/plugins/app-types/data/index.d.ts +8 -0
- package/lib/plugins/app-types/history/config.d.ts +24 -0
- package/lib/plugins/app-types/history/index.d.ts +20 -0
- package/lib/plugins/app-types/history/type.d.ts +2 -0
- package/lib/plugins/app-types/hooks/index.d.ts +12 -0
- package/lib/plugins/app-types/hooks/useDelayedValue/index.d.ts +2 -0
- package/lib/plugins/app-types/hooks/useDispatch/index.d.ts +2 -0
- package/lib/plugins/app-types/hooks/useLowCode/index.d.ts +13 -0
- package/lib/plugins/app-types/hooks/useStore/index.d.ts +6 -0
- package/lib/plugins/app-types/index.d.ts +6 -0
- package/lib/plugins/app-types/indexDB/index.d.ts +178 -0
- package/lib/plugins/app-types/locales/en.d.ts +3 -0
- package/lib/plugins/app-types/locales/index.d.ts +37 -0
- package/lib/plugins/app-types/locales/original.d.ts +3 -0
- package/lib/plugins/app-types/locales/type.d.ts +19 -0
- package/lib/plugins/app-types/locales/zh-CN.d.ts +3 -0
- package/lib/plugins/app-types/locales/zh-HK.d.ts +3 -0
- package/lib/plugins/app-types/logger/feishu.d.ts +11 -0
- package/lib/plugins/app-types/logger/index.d.ts +122 -0
- package/lib/plugins/app-types/menuManager/hooks.d.ts +17 -0
- package/lib/plugins/app-types/menuManager/index.d.ts +28 -0
- package/lib/plugins/app-types/models/global.d.ts +32 -0
- package/lib/plugins/app-types/models/index.d.ts +45 -0
- package/lib/plugins/app-types/models/type.d.ts +2 -0
- package/lib/plugins/app-types/package.json +15 -0
- package/lib/plugins/app-types/plugin/index.d.ts +0 -0
- package/lib/plugins/app-types/pubsub/example.d.ts +5 -0
- package/lib/plugins/app-types/pubsub/index.d.ts +63 -0
- package/lib/plugins/app-types/request/cache.d.ts +46 -0
- package/lib/plugins/app-types/request/cancelToken.d.ts +38 -0
- package/lib/plugins/app-types/request/config.d.ts +3 -0
- package/lib/plugins/app-types/request/constants.d.ts +2 -0
- package/lib/plugins/app-types/request/index.d.ts +24 -0
- package/lib/plugins/app-types/request/pisell2Request.d.ts +6 -0
- package/lib/plugins/app-types/request/type.d.ts +41 -0
- package/lib/plugins/app-types/request/utils.d.ts +46 -0
- package/lib/plugins/app-types/routes/config.d.ts +7 -0
- package/lib/plugins/app-types/routes/index.d.ts +28 -0
- package/lib/plugins/app-types/socket/components/SocketMonitorPage.d.ts +6 -0
- package/lib/plugins/app-types/socket/components/index.d.ts +2 -0
- package/lib/plugins/app-types/socket/constants.d.ts +33 -0
- package/lib/plugins/app-types/socket/events.d.ts +31 -0
- package/lib/plugins/app-types/socket/heartbeat.d.ts +66 -0
- package/lib/plugins/app-types/socket/index.d.ts +61 -0
- package/lib/plugins/app-types/socket/monitor.d.ts +169 -0
- package/lib/plugins/app-types/socket/reconnect.d.ts +61 -0
- package/lib/plugins/app-types/socket/socket.d.ts +129 -0
- package/lib/plugins/app-types/socket/types.d.ts +85 -0
- package/lib/plugins/app-types/storage/index.d.ts +17 -0
- package/lib/plugins/app-types/tasks/index.d.ts +77 -0
- package/lib/plugins/app-types/tasks/type.d.ts +62 -0
- package/lib/plugins/app-types/tasks/useTasks.d.ts +5 -0
- package/lib/plugins/app-types/type.d.ts +2 -0
- package/lib/plugins/app-types/variables/VariablesProvider.d.ts +7 -0
- package/lib/plugins/app-types/variables/config.d.ts +3 -0
- package/lib/plugins/app-types/variables/index.d.ts +6 -0
- package/lib/plugins/app-types/variables/type.d.ts +2 -0
- package/lib/plugins/app-types/website/index.d.ts +6 -0
- package/lib/plugins/app.d.ts +8 -0
- package/lib/plugins/app.js +17 -0
- package/lib/plugins/window.d.ts +1 -0
- package/lib/solution/BookingByStep/index.js +18 -6
- package/lib/solution/BookingByStep/utils/capacity.js +1 -1
- package/lib/solution/BookingByStep/utils/products.d.ts +6 -0
- package/lib/solution/BookingByStep/utils/products.js +8 -2
- package/lib/solution/BookingTicket/index.d.ts +184 -0
- package/lib/solution/BookingTicket/index.js +426 -0
- package/lib/solution/BookingTicket/types.d.ts +68 -0
- package/lib/solution/BookingTicket/types.js +72 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.d.ts +22 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +117 -0
- package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +22 -0
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +132 -0
- package/lib/solution/BookingTicket/utils/scan/index.d.ts +85 -0
- package/lib/solution/BookingTicket/utils/scan/index.js +216 -0
- package/lib/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +231 -0
- package/lib/solution/BuyTickets/index.js +7 -8
- package/lib/solution/Checkout/appointmentDemo.json +1 -0
- package/lib/solution/Checkout/index.d.ts +432 -0
- package/lib/solution/Checkout/index.js +2776 -0
- package/lib/solution/Checkout/types.d.ts +727 -0
- package/lib/solution/Checkout/types.js +63 -0
- package/lib/solution/Checkout/utils/index.d.ts +121 -0
- package/lib/solution/Checkout/utils/index.js +362 -0
- package/lib/solution/ShopDiscount/index.d.ts +10 -10
- package/lib/solution/ShopDiscount/index.js +53 -27
- package/lib/solution/ShopDiscount/types.d.ts +8 -0
- package/lib/solution/ShopDiscount/utils.d.ts +24 -0
- package/lib/solution/ShopDiscount/utils.js +88 -1
- package/lib/solution/index.d.ts +2 -0
- package/lib/solution/index.js +5 -1
- package/lib/types/index.d.ts +4 -1
- package/lib/utils/task.d.ts +40 -0
- package/lib/utils/task.js +109 -0
- package/lib/utils/watch.d.ts +102 -0
- package/lib/utils/watch.js +217 -0
- package/package.json +3 -1
|
@@ -33,10 +33,10 @@ __export(Rules_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(Rules_exports);
|
|
35
35
|
var import_BaseModule = require("../BaseModule");
|
|
36
|
-
var import_types = require("./types");
|
|
37
36
|
var import_utils = require("../../solution/ShopDiscount/utils");
|
|
38
37
|
var import_utils2 = require("../Cart/utils");
|
|
39
38
|
var import_decimal = __toESM(require("decimal.js"));
|
|
39
|
+
var import_lodash_es = require("lodash-es");
|
|
40
40
|
var import_dayjs = __toESM(require("dayjs"));
|
|
41
41
|
var RulesModule = class extends import_BaseModule.BaseModule {
|
|
42
42
|
constructor(name, version) {
|
|
@@ -52,7 +52,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
52
52
|
}
|
|
53
53
|
async setRulesList(rulesList) {
|
|
54
54
|
this.store.rulesList = rulesList;
|
|
55
|
-
await this.core.effects.emit(
|
|
55
|
+
await this.core.effects.emit(`${this.name}:onRulesListChange`, rulesList);
|
|
56
56
|
}
|
|
57
57
|
getRulesList() {
|
|
58
58
|
return this.store.rulesList;
|
|
@@ -96,11 +96,13 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
96
96
|
productList
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
|
-
const filteredOldDiscountList = oldDiscountList.filter(
|
|
100
|
-
|
|
99
|
+
const filteredOldDiscountList = oldDiscountList.filter(
|
|
100
|
+
(discount) => !discount.isEditMode && (discount.tag !== "good_pass" || discount.isScan)
|
|
101
|
+
);
|
|
102
|
+
const mergedDiscountList = (0, import_utils.uniqueById)([
|
|
101
103
|
...filteredOldDiscountList,
|
|
102
104
|
...newDiscountList
|
|
103
|
-
])
|
|
105
|
+
]);
|
|
104
106
|
const result = this.calcDiscount({
|
|
105
107
|
discountList: mergedDiscountList,
|
|
106
108
|
productList: [...productList],
|
|
@@ -151,6 +153,20 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
151
153
|
addModeDiscount.push(discount);
|
|
152
154
|
}
|
|
153
155
|
});
|
|
156
|
+
const editModeOrderLevelProductIds = /* @__PURE__ */ new Set();
|
|
157
|
+
editModeDiscount.forEach((discount) => {
|
|
158
|
+
var _a, _b;
|
|
159
|
+
if (((_a = discount.discount) == null ? void 0 : _a.discount_calculation_mode) === "order_level") {
|
|
160
|
+
editModeOrderLevelProductIds.add((_b = discount == null ? void 0 : discount.discount) == null ? void 0 : _b.discount_product_id);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
if (editModeOrderLevelProductIds.size > 0) {
|
|
164
|
+
addModeDiscount.forEach((discount) => {
|
|
165
|
+
if (editModeOrderLevelProductIds.has(discount.product_id)) {
|
|
166
|
+
discount.isDisabled = true;
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
}
|
|
154
170
|
const filteredDiscountList = addModeDiscount.filter((discount) => {
|
|
155
171
|
return !discount.isManualSelect;
|
|
156
172
|
});
|
|
@@ -198,51 +214,95 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
198
214
|
return flattened;
|
|
199
215
|
};
|
|
200
216
|
const sortedDiscountList = [...filteredDiscountList].sort((a, b) => {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
return
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
217
|
+
const isHolderDiscount = (discount) => {
|
|
218
|
+
var _a, _b;
|
|
219
|
+
return ((_b = (_a = discount.metadata) == null ? void 0 : _a.holder) == null ? void 0 : _b.type) === "custom";
|
|
220
|
+
};
|
|
221
|
+
const isGoodPass = (discount) => discount.tag === "good_pass";
|
|
222
|
+
const isOrderLevelDiscount = (discount) => {
|
|
223
|
+
var _a;
|
|
224
|
+
return discount.tag === "product_discount_card" && ((_a = discount.metadata) == null ? void 0 : _a.discount_calculation_mode) === "order_level";
|
|
225
|
+
};
|
|
226
|
+
const isItemLevelDiscount = (discount) => {
|
|
227
|
+
var _a;
|
|
228
|
+
return discount.tag === "product_discount_card" && ((_a = discount.metadata) == null ? void 0 : _a.discount_calculation_mode) !== "order_level";
|
|
229
|
+
};
|
|
230
|
+
const getPriority = (discount) => {
|
|
231
|
+
const isHolder = isHolderDiscount(discount);
|
|
232
|
+
if (isHolder) {
|
|
233
|
+
if (isGoodPass(discount))
|
|
234
|
+
return 1;
|
|
235
|
+
if (isItemLevelDiscount(discount))
|
|
236
|
+
return 2;
|
|
237
|
+
if (isOrderLevelDiscount(discount))
|
|
238
|
+
return 3;
|
|
239
|
+
} else {
|
|
240
|
+
if (isGoodPass(discount))
|
|
241
|
+
return 4;
|
|
242
|
+
if (isItemLevelDiscount(discount))
|
|
243
|
+
return 5;
|
|
244
|
+
if (isOrderLevelDiscount(discount))
|
|
245
|
+
return 6;
|
|
246
|
+
}
|
|
247
|
+
return 7;
|
|
248
|
+
};
|
|
249
|
+
function compareByExpireTime(itemA, itemB) {
|
|
250
|
+
if (itemA.expire_time && itemB.expire_time) {
|
|
251
|
+
const timeA = new Date(itemA.expire_time).getTime();
|
|
252
|
+
const timeB = new Date(itemB.expire_time).getTime();
|
|
253
|
+
return timeA - timeB;
|
|
254
|
+
}
|
|
255
|
+
return itemA.expire_time ? -1 : itemB.expire_time ? 1 : 0;
|
|
256
|
+
}
|
|
257
|
+
function compareDiscountCardValue(itemA, itemB) {
|
|
258
|
+
var _a, _b;
|
|
259
|
+
const typeA = ((_a = itemA.metadata) == null ? void 0 : _a.discount_card_type) || "percent";
|
|
260
|
+
const typeB = ((_b = itemB.metadata) == null ? void 0 : _b.discount_card_type) || "percent";
|
|
211
261
|
if (typeA === "fixed_amount" && typeB === "percent")
|
|
212
262
|
return -1;
|
|
213
263
|
if (typeA === "percent" && typeB === "fixed_amount")
|
|
214
264
|
return 1;
|
|
215
265
|
if (typeA === "fixed_amount" && typeB === "fixed_amount") {
|
|
216
|
-
if (
|
|
217
|
-
const valueA = new import_decimal.default(
|
|
218
|
-
const valueB = new import_decimal.default(
|
|
266
|
+
if (itemA.par_value !== itemB.par_value) {
|
|
267
|
+
const valueA = new import_decimal.default(itemA.par_value || 0);
|
|
268
|
+
const valueB = new import_decimal.default(itemB.par_value || 0);
|
|
219
269
|
return valueB.minus(valueA).toNumber();
|
|
220
270
|
}
|
|
221
271
|
}
|
|
222
272
|
if (typeA === "percent" && typeB === "percent") {
|
|
223
|
-
if (
|
|
224
|
-
const valueA = new import_decimal.default(100).minus(
|
|
225
|
-
const valueB = new import_decimal.default(100).minus(
|
|
273
|
+
if (itemA.par_value !== itemB.par_value) {
|
|
274
|
+
const valueA = new import_decimal.default(100).minus(itemA.par_value || 0);
|
|
275
|
+
const valueB = new import_decimal.default(100).minus(itemB.par_value || 0);
|
|
226
276
|
return valueA.minus(valueB).toNumber();
|
|
227
277
|
}
|
|
228
278
|
}
|
|
279
|
+
return 0;
|
|
280
|
+
}
|
|
281
|
+
const priorityA = getPriority(a);
|
|
282
|
+
const priorityB = getPriority(b);
|
|
283
|
+
if (priorityA !== priorityB) {
|
|
284
|
+
return priorityA - priorityB;
|
|
285
|
+
}
|
|
286
|
+
if (isGoodPass(a) && isGoodPass(b)) {
|
|
229
287
|
return compareByExpireTime(a, b);
|
|
230
288
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
if (
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
return timeA - timeB;
|
|
237
|
-
}
|
|
238
|
-
return itemA.expire_time ? -1 : itemB.expire_time ? 1 : 0;
|
|
289
|
+
if (a.tag === "product_discount_card" && b.tag === "product_discount_card") {
|
|
290
|
+
const valueCompare = compareDiscountCardValue(a, b);
|
|
291
|
+
if (valueCompare !== 0)
|
|
292
|
+
return valueCompare;
|
|
293
|
+
return compareByExpireTime(a, b);
|
|
239
294
|
}
|
|
295
|
+
return compareByExpireTime(a, b);
|
|
240
296
|
});
|
|
241
297
|
const flattenedList = flattenProductsWithBundle(productList);
|
|
242
298
|
const sortedFlattenedList = flattenedList.sort((a, b) => {
|
|
243
299
|
var _a, _b;
|
|
244
|
-
const priceA = new import_decimal.default(
|
|
245
|
-
|
|
300
|
+
const priceA = new import_decimal.default(
|
|
301
|
+
a.type === "bundle" ? a.original_price ?? a.price ?? "0" : a.price || "0"
|
|
302
|
+
);
|
|
303
|
+
const priceB = new import_decimal.default(
|
|
304
|
+
b.type === "bundle" ? b.original_price ?? b.price ?? "0" : b.price || "0"
|
|
305
|
+
);
|
|
246
306
|
if (priceA.equals(priceB)) {
|
|
247
307
|
if (a.type !== b.type) {
|
|
248
308
|
return a.type === "main" ? -1 : 1;
|
|
@@ -266,6 +326,129 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
266
326
|
discountApplicability.set(discount.id, []);
|
|
267
327
|
discountApplicableProducts.set(discount.id, []);
|
|
268
328
|
});
|
|
329
|
+
const orderLevelDiscountAllocations = /* @__PURE__ */ new Map();
|
|
330
|
+
const orderLevelDiscountApplicableItems = /* @__PURE__ */ new Map();
|
|
331
|
+
const itemApplicableDiscounts = /* @__PURE__ */ new Map();
|
|
332
|
+
const checkItemApplicableForDiscount = (flatItem, discount) => {
|
|
333
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
334
|
+
let product;
|
|
335
|
+
if (flatItem.type === "main") {
|
|
336
|
+
product = flatItem.product;
|
|
337
|
+
} else {
|
|
338
|
+
product = {
|
|
339
|
+
_id: flatItem._id,
|
|
340
|
+
id: flatItem.id,
|
|
341
|
+
price: flatItem.price,
|
|
342
|
+
quantity: flatItem.quantity,
|
|
343
|
+
num: flatItem.num,
|
|
344
|
+
booking_id: flatItem.booking_id,
|
|
345
|
+
discount_list: flatItem.discount_list || [],
|
|
346
|
+
startDate: (_a = flatItem.parentProduct) == null ? void 0 : _a.startDate
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
const isAvailableProduct = flatItem.type === "main" ? !((product == null ? void 0 : product.booking_id) && ((_b = product == null ? void 0 : product.discount_list) == null ? void 0 : _b.length) && ((_c = product == null ? void 0 : product.discount_list) == null ? void 0 : _c.every((d) => d.id && ["good_pass", "discount_card", "product_discount_card"].includes(d.tag || d.type)))) : !((flatItem == null ? void 0 : flatItem.booking_id) && !!((_e = (_d = flatItem == null ? void 0 : flatItem.bundleItem) == null ? void 0 : _d.discount_list) == null ? void 0 : _e.length) && ((_g = (_f = flatItem == null ? void 0 : flatItem.bundleItem) == null ? void 0 : _f.discount_list) == null ? void 0 : _g.every((d) => d.id)));
|
|
350
|
+
if (!isAvailableProduct) {
|
|
351
|
+
return false;
|
|
352
|
+
}
|
|
353
|
+
if ((0, import_lodash_es.isBoolean)(product.vouchersApplicable) && !product.vouchersApplicable) {
|
|
354
|
+
return false;
|
|
355
|
+
}
|
|
356
|
+
if (Number(product.price) <= 0 || !product.price) {
|
|
357
|
+
return false;
|
|
358
|
+
}
|
|
359
|
+
const limitedData = discount.limited_relation_product_data;
|
|
360
|
+
const timeLimit = !!(0, import_utils.filterDiscountListByBookingTime)([discount], ((product == null ? void 0 : product.startDate) || (0, import_dayjs.default)()).format("YYYY-MM-DD HH:mm:ss")).length;
|
|
361
|
+
if (!timeLimit) {
|
|
362
|
+
return false;
|
|
363
|
+
}
|
|
364
|
+
let isLimitedProduct = false;
|
|
365
|
+
if (limitedData.type === "product_all") {
|
|
366
|
+
if (limitedData.filter === 1 && ((_h = limitedData.exclude_product_ids) == null ? void 0 : _h.includes(product.id))) {
|
|
367
|
+
isLimitedProduct = false;
|
|
368
|
+
} else {
|
|
369
|
+
isLimitedProduct = true;
|
|
370
|
+
}
|
|
371
|
+
} else if (limitedData.product_ids && limitedData.product_ids.includes(product.id)) {
|
|
372
|
+
isLimitedProduct = true;
|
|
373
|
+
}
|
|
374
|
+
const isBundleAvailable = this.checkPackageSubItemUsageRules(discount, flatItem);
|
|
375
|
+
return isLimitedProduct && isBundleAvailable;
|
|
376
|
+
};
|
|
377
|
+
const selectedOrderLevelDiscounts = sortedDiscountList.filter((discount) => {
|
|
378
|
+
return (0, import_utils.isOrderLevelFixedAmountDiscount)(discount) && discount.isSelected !== false;
|
|
379
|
+
});
|
|
380
|
+
selectedOrderLevelDiscounts.forEach((discount) => {
|
|
381
|
+
const applicableItemIds = /* @__PURE__ */ new Set();
|
|
382
|
+
sortedFlattenedList.forEach((flatItem) => {
|
|
383
|
+
if (checkItemApplicableForDiscount(flatItem, discount)) {
|
|
384
|
+
applicableItemIds.add(flatItem._id);
|
|
385
|
+
if (!itemApplicableDiscounts.has(flatItem._id)) {
|
|
386
|
+
itemApplicableDiscounts.set(flatItem._id, /* @__PURE__ */ new Set());
|
|
387
|
+
}
|
|
388
|
+
itemApplicableDiscounts.get(flatItem._id).add(discount.id);
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
orderLevelDiscountApplicableItems.set(discount.id, applicableItemIds);
|
|
392
|
+
});
|
|
393
|
+
const occupiedItems = /* @__PURE__ */ new Map();
|
|
394
|
+
selectedOrderLevelDiscounts.forEach((discount) => {
|
|
395
|
+
const limitedData = discount.limited_relation_product_data;
|
|
396
|
+
const isExclusiveDiscount = limitedData.type !== "product_all";
|
|
397
|
+
if (isExclusiveDiscount) {
|
|
398
|
+
const applicableItems = orderLevelDiscountApplicableItems.get(discount.id);
|
|
399
|
+
if (applicableItems) {
|
|
400
|
+
applicableItems.forEach((itemId) => {
|
|
401
|
+
if (!occupiedItems.has(itemId)) {
|
|
402
|
+
occupiedItems.set(itemId, discount.id);
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
console.log("occupiedItems", occupiedItems, "orderLevelDiscountApplicableItems", orderLevelDiscountApplicableItems);
|
|
409
|
+
sortedDiscountList.forEach((discount) => {
|
|
410
|
+
if (!(0, import_utils.isOrderLevelFixedAmountDiscount)(discount)) {
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
const applicableProducts = [];
|
|
414
|
+
sortedFlattenedList.forEach((flatItem) => {
|
|
415
|
+
var _a, _b;
|
|
416
|
+
const occupyingDiscountId = occupiedItems.get(flatItem._id);
|
|
417
|
+
if (occupyingDiscountId !== void 0 && occupyingDiscountId !== discount.id) {
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
if (!checkItemApplicableForDiscount(flatItem, discount)) {
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
let product;
|
|
424
|
+
if (flatItem.type === "main") {
|
|
425
|
+
product = flatItem.product;
|
|
426
|
+
} else {
|
|
427
|
+
product = {
|
|
428
|
+
_id: flatItem._id,
|
|
429
|
+
id: flatItem.id,
|
|
430
|
+
price: flatItem.price,
|
|
431
|
+
quantity: flatItem.quantity,
|
|
432
|
+
num: flatItem.num
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
const quantity = flatItem.type === "main" ? product.quantity || 1 : (product.num || 1) * (((_a = flatItem.parentProduct) == null ? void 0 : _a.quantity) || 1);
|
|
436
|
+
const originalAmount = flatItem.type === "main" ? Number(product.price ?? 0) : Number(flatItem.original_price ?? flatItem.price ?? 0);
|
|
437
|
+
const productData = {
|
|
438
|
+
productId: flatItem._id,
|
|
439
|
+
amount: originalAmount,
|
|
440
|
+
quantity
|
|
441
|
+
};
|
|
442
|
+
if (flatItem.type === "bundle") {
|
|
443
|
+
productData.parentQuantity = ((_b = flatItem.parentProduct) == null ? void 0 : _b.quantity) || 1;
|
|
444
|
+
}
|
|
445
|
+
applicableProducts.push(productData);
|
|
446
|
+
});
|
|
447
|
+
if (applicableProducts.length > 0) {
|
|
448
|
+
const allocation = (0, import_utils.calculateOrderLevelDiscountAllocation)(discount, applicableProducts);
|
|
449
|
+
orderLevelDiscountAllocations.set(discount.id, allocation);
|
|
450
|
+
}
|
|
451
|
+
});
|
|
269
452
|
const processedProductsMap = /* @__PURE__ */ new Map();
|
|
270
453
|
const appliedDiscountProducts = /* @__PURE__ */ new Map();
|
|
271
454
|
sortedFlattenedList.forEach((flatItem) => {
|
|
@@ -290,7 +473,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
290
473
|
originProduct = flatItem.originProduct;
|
|
291
474
|
}
|
|
292
475
|
addModeDiscount.forEach((discount) => {
|
|
293
|
-
var _a2, _b, _c, _d, _e, _f;
|
|
476
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
294
477
|
const limitedData = discount == null ? void 0 : discount.limited_relation_product_data;
|
|
295
478
|
const _tempVar = (flatItem == null ? void 0 : flatItem.type) === "bundle" ? flatItem == null ? void 0 : flatItem.parentProduct : flatItem == null ? void 0 : flatItem.product;
|
|
296
479
|
const isHolderMatch = this.checkHolderMatch(
|
|
@@ -304,10 +487,16 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
304
487
|
let timeLimit = true;
|
|
305
488
|
timeLimit = !!(0, import_utils.filterDiscountListByBookingTime)([discount], ((product == null ? void 0 : product.startDate) || (0, import_dayjs.default)()).format("YYYY-MM-DD HH:mm:ss")).length;
|
|
306
489
|
const isLimitedProduct = (limitedData.type === "product_all" || limitedData.product_ids && limitedData.product_ids.includes(product.id)) && isHolderMatch;
|
|
307
|
-
const isAvailableProduct = flatItem.type === "main" ? !((product == null ? void 0 : product.booking_id) && ((_a2 = product == null ? void 0 : product.discount_list) == null ? void 0 : _a2.length) && ((_b = product == null ? void 0 : product.discount_list) == null ? void 0 : _b.every(
|
|
490
|
+
const isAvailableProduct = flatItem.type === "main" ? !((product == null ? void 0 : product.booking_id) && ((_a2 = product == null ? void 0 : product.discount_list) == null ? void 0 : _a2.length) && ((_b = product == null ? void 0 : product.discount_list) == null ? void 0 : _b.every(
|
|
491
|
+
(discount2) => discount2.id && [
|
|
492
|
+
"good_pass",
|
|
493
|
+
"discount_card",
|
|
494
|
+
"product_discount_card"
|
|
495
|
+
].includes(discount2.tag || discount2.type)
|
|
496
|
+
))) : !((flatItem == null ? void 0 : flatItem.booking_id) && !!((_d = (_c = flatItem == null ? void 0 : flatItem.bundleItem) == null ? void 0 : _c.discount_list) == null ? void 0 : _d.length) && ((_f = (_e = flatItem == null ? void 0 : flatItem.bundleItem) == null ? void 0 : _e.discount_list) == null ? void 0 : _f.every((discount2) => discount2.id)));
|
|
308
497
|
const isBundleAvailable = this.checkPackageSubItemUsageRules(discount, flatItem);
|
|
309
|
-
if (isAvailableProduct && isLimitedProduct &&
|
|
310
|
-
(
|
|
498
|
+
if (isAvailableProduct && isLimitedProduct && timeLimit && isBundleAvailable) {
|
|
499
|
+
(_g = discountApplicability.get(discount.id)) == null ? void 0 : _g.push(product.id);
|
|
311
500
|
const applicableProducts = discountApplicableProducts.get(discount.id) || [];
|
|
312
501
|
const discountType = discount.tag || discount.type;
|
|
313
502
|
const isGoodPass = discountType === "good_pass";
|
|
@@ -317,8 +506,9 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
317
506
|
type: discountType,
|
|
318
507
|
tag: discountType,
|
|
319
508
|
discount: {
|
|
320
|
-
discount_card_type: (
|
|
509
|
+
discount_card_type: (_h = discount == null ? void 0 : discount.metadata) == null ? void 0 : _h.discount_card_type,
|
|
321
510
|
fixed_amount: product.price,
|
|
511
|
+
discount_calculation_mode: (_i = discount == null ? void 0 : discount.metadata) == null ? void 0 : _i.discount_calculation_mode,
|
|
322
512
|
resource_id: discount.id,
|
|
323
513
|
title: discount.format_title,
|
|
324
514
|
original_amount: product.price || product.origin_total,
|
|
@@ -336,7 +526,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
336
526
|
});
|
|
337
527
|
const processedFlatItemsMap = /* @__PURE__ */ new Map();
|
|
338
528
|
sortedFlattenedList.forEach((flatItem, index) => {
|
|
339
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
529
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B;
|
|
340
530
|
let product, originProduct;
|
|
341
531
|
if (flatItem.type === "main") {
|
|
342
532
|
product = flatItem.product;
|
|
@@ -372,7 +562,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
372
562
|
var _a2, _b2;
|
|
373
563
|
if ((Number(product.price) <= 0 || !product.price) && !((_a2 = product.discount_list) == null ? void 0 : _a2.length) && (discount.tag || discount.type) === "good_pass")
|
|
374
564
|
return false;
|
|
375
|
-
if ((Number(product.price)
|
|
565
|
+
if ((Number(product.price) <= 0 || !product.price) && !((_b2 = product.discount_list) == null ? void 0 : _b2.find((n) => {
|
|
376
566
|
var _a3;
|
|
377
567
|
return ((_a3 = n.discount) == null ? void 0 : _a3.resource_id) === discount.id;
|
|
378
568
|
})) && (discount.tag || discount.type) !== "good_pass")
|
|
@@ -474,7 +664,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
474
664
|
}
|
|
475
665
|
}
|
|
476
666
|
}
|
|
477
|
-
if (applicableDiscounts.length === 0 || isManualDiscount) {
|
|
667
|
+
if (applicableDiscounts.length === 0 || isManualDiscount || (0, import_lodash_es.isBoolean)(product.vouchersApplicable) && !product.vouchersApplicable) {
|
|
478
668
|
if (flatItem.type === "main") {
|
|
479
669
|
if (product.isClient) {
|
|
480
670
|
processedProductsMap.set(
|
|
@@ -506,7 +696,10 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
506
696
|
processedProductsMap.set(
|
|
507
697
|
product._id,
|
|
508
698
|
[this.hooks.setProduct(originProduct, {
|
|
509
|
-
...isManualDiscount ? {
|
|
699
|
+
...isManualDiscount ? {
|
|
700
|
+
price: product.price,
|
|
701
|
+
main_product_selling_price: product.price
|
|
702
|
+
} : {
|
|
510
703
|
_id: product._id.split("___")[0] + "___" + index,
|
|
511
704
|
total: product.origin_total || product.total,
|
|
512
705
|
price: product.price,
|
|
@@ -520,7 +713,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
520
713
|
processedFlatItemsMap.set(flatItem._id, [{
|
|
521
714
|
...flatItem,
|
|
522
715
|
discount_list: [],
|
|
523
|
-
price: flatItem.bundleItem.original_price,
|
|
716
|
+
price: isManualDiscount ? flatItem.bundleItem.price : flatItem.bundleItem.original_price,
|
|
524
717
|
processed: true
|
|
525
718
|
}]);
|
|
526
719
|
}
|
|
@@ -553,16 +746,29 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
553
746
|
if (Number(((_v = originProduct == null ? void 0 : originProduct._productInit) == null ? void 0 : _v.original_price) || 0) > 0 && product.origin_total && product.total && product.origin_total !== product.total) {
|
|
554
747
|
productOriginTotal = product.total;
|
|
555
748
|
}
|
|
556
|
-
const
|
|
749
|
+
const isOrderLevel = (0, import_utils.isOrderLevelFixedAmountDiscount)(selectedDiscount2);
|
|
750
|
+
const orderLevelAllocation = isOrderLevel ? orderLevelDiscountAllocations.get(selectedDiscount2.id) : null;
|
|
751
|
+
const productAllocation = orderLevelAllocation == null ? void 0 : orderLevelAllocation.get(flatItem._id);
|
|
752
|
+
let targetProductTotal;
|
|
753
|
+
let amount;
|
|
754
|
+
let productDiscountDifference;
|
|
755
|
+
if (isOrderLevel && productAllocation) {
|
|
756
|
+
amount = productAllocation.discountAmount;
|
|
757
|
+
productDiscountDifference = productAllocation.difference;
|
|
758
|
+
targetProductTotal = Math.max(new import_decimal.default(product.price).minus(amount).toNumber(), 0);
|
|
759
|
+
} else {
|
|
760
|
+
targetProductTotal = (0, import_utils.getDiscountAmount)(selectedDiscount2, product.price, product.price);
|
|
761
|
+
amount = new import_decimal.default(product.price).minus(new import_decimal.default(targetProductTotal)).toNumber();
|
|
762
|
+
}
|
|
557
763
|
const discountType = selectedDiscount2.tag || selectedDiscount2.type;
|
|
558
764
|
const isGoodPass = discountType === "good_pass";
|
|
559
|
-
const amount = new import_decimal.default(product.price).minus(new import_decimal.default(targetProductTotal)).toNumber();
|
|
560
765
|
const discountDetail = {
|
|
561
766
|
amount,
|
|
562
767
|
type: selectedDiscount2.tag === "product_discount_card" ? "discount_card" : discountType,
|
|
563
768
|
discount: {
|
|
564
769
|
discount_card_type: (_w = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _w.discount_card_type,
|
|
565
770
|
fixed_amount: amount,
|
|
771
|
+
discount_calculation_mode: (_x = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _x.discount_calculation_mode,
|
|
566
772
|
resource_id: selectedDiscount2.id,
|
|
567
773
|
title: selectedDiscount2.format_title,
|
|
568
774
|
original_amount: product.price,
|
|
@@ -572,7 +778,9 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
572
778
|
// 前端使用的num数量,为了计算优惠金额
|
|
573
779
|
_num: isGoodPass ? 1 : product.num,
|
|
574
780
|
metadata: {
|
|
575
|
-
num: 1
|
|
781
|
+
num: 1,
|
|
782
|
+
// 🔥 order_level 分摊差值
|
|
783
|
+
...productDiscountDifference !== void 0 && { product_discount_difference: productDiscountDifference }
|
|
576
784
|
}
|
|
577
785
|
};
|
|
578
786
|
appliedProducts.push(discountDetail);
|
|
@@ -629,6 +837,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
629
837
|
type: "good_pass",
|
|
630
838
|
discount: {
|
|
631
839
|
fixed_amount: product.origin_total,
|
|
840
|
+
discount_calculation_mode: (_y = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _y.discount_calculation_mode,
|
|
632
841
|
resource_id: selectedDiscount2.id,
|
|
633
842
|
title: selectedDiscount2.format_title,
|
|
634
843
|
original_amount: product.origin_total,
|
|
@@ -673,18 +882,33 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
673
882
|
const selectedDiscount2 = selectedDiscountCard || applicableDiscounts[0];
|
|
674
883
|
usedDiscounts.set(selectedDiscount2.id, true);
|
|
675
884
|
const productOriginTotal = product.original_price || product.price || 0;
|
|
676
|
-
const
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
885
|
+
const isOrderLevel = (0, import_utils.isOrderLevelFixedAmountDiscount)(selectedDiscount2);
|
|
886
|
+
const orderLevelAllocation = isOrderLevel ? orderLevelDiscountAllocations.get(selectedDiscount2.id) : null;
|
|
887
|
+
const productAllocation = orderLevelAllocation == null ? void 0 : orderLevelAllocation.get(flatItem._id);
|
|
888
|
+
let targetProductTotal;
|
|
889
|
+
let fixedAmountPerItem;
|
|
890
|
+
let productDiscountDifference;
|
|
891
|
+
if (isOrderLevel && productAllocation) {
|
|
892
|
+
fixedAmountPerItem = productAllocation.discountAmount;
|
|
893
|
+
productDiscountDifference = productAllocation.difference;
|
|
894
|
+
targetProductTotal = Math.max(new import_decimal.default(productOriginTotal).minus(fixedAmountPerItem).toNumber(), 0);
|
|
895
|
+
} else {
|
|
896
|
+
targetProductTotal = (0, import_utils.getDiscountAmount)(
|
|
897
|
+
selectedDiscount2,
|
|
898
|
+
productOriginTotal,
|
|
899
|
+
productOriginTotal
|
|
900
|
+
);
|
|
901
|
+
fixedAmountPerItem = new import_decimal.default(productOriginTotal).minus(targetProductTotal).toNumber();
|
|
902
|
+
}
|
|
903
|
+
debugger;
|
|
681
904
|
const uniqueId = flatItem._id;
|
|
682
905
|
const discountDetail = {
|
|
683
|
-
amount:
|
|
906
|
+
amount: fixedAmountPerItem * (product.num || 1),
|
|
684
907
|
type: selectedDiscount2.tag === "product_discount_card" ? "discount_card" : selectedDiscount2.tag,
|
|
685
908
|
discount: {
|
|
686
|
-
discount_card_type: (
|
|
687
|
-
fixed_amount:
|
|
909
|
+
discount_card_type: (_z = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _z.discount_card_type,
|
|
910
|
+
fixed_amount: fixedAmountPerItem,
|
|
911
|
+
discount_calculation_mode: (_A = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _A.discount_calculation_mode,
|
|
688
912
|
resource_id: selectedDiscount2.id,
|
|
689
913
|
title: selectedDiscount2.format_title,
|
|
690
914
|
original_amount: product.original_price,
|
|
@@ -694,9 +918,11 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
694
918
|
metadata: {
|
|
695
919
|
// 🔥 使用唯一的 _id
|
|
696
920
|
custom_product_bundle_map_id: uniqueId,
|
|
697
|
-
num: product.num || 1
|
|
921
|
+
num: product.num || 1,
|
|
922
|
+
// 🔥 order_level 分摊差值
|
|
923
|
+
...productDiscountDifference !== void 0 && { product_discount_difference: productDiscountDifference }
|
|
698
924
|
},
|
|
699
|
-
_num: (product.num || 1) * (((
|
|
925
|
+
_num: (product.num || 1) * (((_B = flatItem == null ? void 0 : flatItem.parentProduct) == null ? void 0 : _B.num) || 1)
|
|
700
926
|
};
|
|
701
927
|
const appliedProducts = appliedDiscountProducts.get(selectedDiscount2.id) || [];
|
|
702
928
|
appliedProducts.push(discountDetail);
|
|
@@ -704,7 +930,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
704
930
|
processedItems.push({
|
|
705
931
|
...flatItem,
|
|
706
932
|
total: targetProductTotal,
|
|
707
|
-
price: new import_decimal.default(productOriginTotal || 0).minus(
|
|
933
|
+
price: new import_decimal.default(productOriginTotal || 0).minus(fixedAmountPerItem).toNumber(),
|
|
708
934
|
discount_list: [discountDetail],
|
|
709
935
|
processed: true
|
|
710
936
|
});
|
|
@@ -794,6 +1020,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
794
1020
|
return {
|
|
795
1021
|
...discount,
|
|
796
1022
|
metadata: {
|
|
1023
|
+
...discount.metadata,
|
|
797
1024
|
num: item.num,
|
|
798
1025
|
custom_product_bundle_map_id: (_a = item.metadata) == null ? void 0 : _a.custom_product_bundle_map_id
|
|
799
1026
|
}
|
|
@@ -817,6 +1044,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
817
1044
|
return {
|
|
818
1045
|
...discount,
|
|
819
1046
|
metadata: {
|
|
1047
|
+
...discount.metadata,
|
|
820
1048
|
num: item.num,
|
|
821
1049
|
custom_product_bundle_map_id: (_a = item.metadata) == null ? void 0 : _a.custom_product_bundle_map_id
|
|
822
1050
|
}
|
|
@@ -847,6 +1075,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
847
1075
|
...discount,
|
|
848
1076
|
// num: 1,
|
|
849
1077
|
metadata: {
|
|
1078
|
+
...discount.metadata,
|
|
850
1079
|
custom_product_bundle_map_id: (_b = discount == null ? void 0 : discount.metadata) == null ? void 0 : _b.custom_product_bundle_map_id,
|
|
851
1080
|
num: 1
|
|
852
1081
|
}
|
|
@@ -860,14 +1089,16 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
860
1089
|
const allDiscountAmount = (0, import_utils.getDiscountListAmountTotal)(mainDiscountList);
|
|
861
1090
|
newTotalWithDiscount = new import_decimal.default(mainProductData.price || 0).minus(allDiscountAmount).toNumber() ?? newTotalWithDiscount;
|
|
862
1091
|
newOriginTotalWithDiscount = mainProductData.origin_total ?? newOriginTotalWithDiscount;
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
1092
|
+
}
|
|
1093
|
+
if (newBundleWithDiscount.length > 0) {
|
|
1094
|
+
newBundleWithDiscount.forEach((item) => {
|
|
1095
|
+
newTotalWithDiscount += Number(item.price) * Number(item.num);
|
|
1096
|
+
});
|
|
1097
|
+
newBundleWithDiscount.forEach((item) => {
|
|
1098
|
+
var _a, _b, _c;
|
|
1099
|
+
const originalPrice = ((_c = (_b = (_a = item.discount_list) == null ? void 0 : _a[0]) == null ? void 0 : _b.discount) == null ? void 0 : _c.original_amount) || item.price;
|
|
1100
|
+
newOriginTotalWithDiscount += Number(originalPrice) * Number(item.num);
|
|
1101
|
+
});
|
|
871
1102
|
}
|
|
872
1103
|
if (product == null ? void 0 : product.options) {
|
|
873
1104
|
newTotalWithDiscount = product.options.reduce((accumulator, currentValue) => {
|
|
@@ -905,6 +1136,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
905
1136
|
return {
|
|
906
1137
|
...discount,
|
|
907
1138
|
metadata: {
|
|
1139
|
+
...discount.metadata,
|
|
908
1140
|
num: mainProductQuantity - 1,
|
|
909
1141
|
custom_product_bundle_map_id: (_b = discount == null ? void 0 : discount.metadata) == null ? void 0 : _b.custom_product_bundle_map_id
|
|
910
1142
|
}
|
|
@@ -919,12 +1151,12 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
919
1151
|
const allDiscountAmount = (0, import_utils.getDiscountListAmount)(mainDiscountListOriginal);
|
|
920
1152
|
newTotalOriginal = new import_decimal.default(mainProductData.price || 0).minus(allDiscountAmount).toNumber() ?? newTotalOriginal;
|
|
921
1153
|
newOriginTotalOriginal = mainProductData.origin_total ?? newOriginTotalOriginal;
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
}
|
|
1154
|
+
}
|
|
1155
|
+
if (newBundleOriginal.length > 0) {
|
|
1156
|
+
newBundleOriginal.forEach((item) => {
|
|
1157
|
+
newTotalOriginal += Number(item.price) * Number(item.num);
|
|
1158
|
+
newOriginTotalOriginal += Number(item.price) * Number(item.num);
|
|
1159
|
+
});
|
|
928
1160
|
}
|
|
929
1161
|
if (product == null ? void 0 : product.options) {
|
|
930
1162
|
newTotalOriginal = product.options.reduce((accumulator, currentValue) => {
|
|
@@ -963,6 +1195,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
963
1195
|
return {
|
|
964
1196
|
...discount,
|
|
965
1197
|
metadata: {
|
|
1198
|
+
...discount.metadata,
|
|
966
1199
|
num: item.num,
|
|
967
1200
|
custom_product_bundle_map_id: (_a2 = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a2.custom_product_bundle_map_id
|
|
968
1201
|
}
|
|
@@ -999,8 +1232,10 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
999
1232
|
}
|
|
1000
1233
|
if (newBundle.length > 0) {
|
|
1001
1234
|
newBundle.forEach((item) => {
|
|
1002
|
-
var _a2, _b2, _c2;
|
|
1003
1235
|
newTotal += Number(item.price) * Number(item.num);
|
|
1236
|
+
});
|
|
1237
|
+
newBundle.forEach((item) => {
|
|
1238
|
+
var _a2, _b2, _c2;
|
|
1004
1239
|
const originalPrice = ((_c2 = (_b2 = (_a2 = item.discount_list) == null ? void 0 : _a2[0]) == null ? void 0 : _b2.discount) == null ? void 0 : _c2.original_amount) || item.price;
|
|
1005
1240
|
newOriginTotal += Number(originalPrice) * Number(item.num);
|
|
1006
1241
|
});
|
|
@@ -1141,7 +1376,18 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1141
1376
|
if (isBundleItem) {
|
|
1142
1377
|
const priceType = (_c = flatItem.bundleItem) == null ? void 0 : _c.price_type;
|
|
1143
1378
|
const priceTypeExt = (_d = flatItem.bundleItem) == null ? void 0 : _d.price_type_ext;
|
|
1144
|
-
|
|
1379
|
+
const isOriginalPrice = priceType === "markup" && priceTypeExt === "product_price";
|
|
1380
|
+
const isMarkupPrice = priceType === "markup" && (priceTypeExt === "" || !priceTypeExt);
|
|
1381
|
+
if (rules.length > 0) {
|
|
1382
|
+
if (isOriginalPrice && rules.includes("original_price")) {
|
|
1383
|
+
return true;
|
|
1384
|
+
}
|
|
1385
|
+
if (isMarkupPrice && rules.includes("markup_price")) {
|
|
1386
|
+
return true;
|
|
1387
|
+
}
|
|
1388
|
+
return false;
|
|
1389
|
+
}
|
|
1390
|
+
return isOriginalPrice;
|
|
1145
1391
|
}
|
|
1146
1392
|
return false;
|
|
1147
1393
|
}
|
|
@@ -1152,7 +1398,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1152
1398
|
}
|
|
1153
1399
|
async destroy() {
|
|
1154
1400
|
this.core.effects.offByModuleDestroy(this.name);
|
|
1155
|
-
await this.core.effects.emit(
|
|
1401
|
+
await this.core.effects.emit(`${this.name}:onDestroy`, {});
|
|
1156
1402
|
console.log("[Rules] 已销毁");
|
|
1157
1403
|
}
|
|
1158
1404
|
async clear() {
|
|
@@ -25,4 +25,13 @@ export declare class ScheduleModule extends BaseModule implements Module, Schedu
|
|
|
25
25
|
setOtherProductsIds(ids: number[]): void;
|
|
26
26
|
getOtherProductsIds(): number[];
|
|
27
27
|
storeChange(): void;
|
|
28
|
+
/**
|
|
29
|
+
* 传入一个时间, 判断改时间是否在schedule 内
|
|
30
|
+
* @param param0 { date: string, schedule: any } date: 日期, schedule: schedule
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
static isInScheduleByDate({ date, schedule, }: {
|
|
34
|
+
date: string;
|
|
35
|
+
schedule: any;
|
|
36
|
+
}): boolean | undefined;
|
|
28
37
|
}
|