@pisell/pisellos 0.0.569 → 0.10.2
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 +10 -6
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -3
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.js +7 -5
- package/dist/model/strategy/adapter/walletPass/example.js +26 -3
- package/dist/model/strategy/adapter/walletPass/index.js +5 -5
- package/dist/model/strategy/adapter/walletPass/type.d.ts +0 -3
- package/dist/model/strategy/adapter/walletPass/utils.d.ts +0 -26
- package/dist/model/strategy/adapter/walletPass/utils.js +17 -92
- package/dist/model/strategy/strategy-example.js +19 -5
- package/dist/modules/BaseModule.d.ts +1 -1
- package/dist/modules/BaseModule.js +8 -10
- package/dist/modules/Cart/index.js +3 -0
- package/dist/modules/Cart/utils/cartProduct.js +1 -0
- package/dist/modules/Cart/utils/cartResource.js +0 -2
- package/dist/modules/Cart/utils/changePrice.js +9 -16
- package/dist/modules/Date/index.js +5 -1
- package/dist/modules/Discount/index.d.ts +0 -1
- package/dist/modules/Discount/index.js +7 -22
- package/dist/modules/Discount/types.d.ts +0 -1
- package/dist/modules/OpenData/index.js +2 -0
- package/dist/modules/Order/index.js +70 -40
- package/dist/modules/Payment/index.js +162 -97
- package/dist/modules/Payment/types.d.ts +4 -8
- package/dist/modules/Payment/walletpass.d.ts +0 -2
- package/dist/modules/Payment/walletpass.js +5 -4
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +3 -12
- package/dist/modules/ProductList/types.d.ts +0 -1
- package/dist/modules/Rules/index.js +126 -427
- package/dist/modules/SalesSummary/utils.js +1 -2
- package/dist/modules/Schedule/getDateIsInSchedule.js +0 -5
- package/dist/modules/Schedule/index.js +1 -0
- package/dist/modules/Schedule/utils.js +1 -0
- package/dist/modules/Step/index.js +1 -0
- package/dist/modules/Summary/utils.js +22 -43
- package/dist/plugins/request.js +4 -1
- package/dist/plugins/window.js +6 -2
- package/dist/server/index.js +129 -97
- package/dist/server/modules/menu/index.js +41 -32
- package/dist/server/modules/order/index.js +4 -2
- package/dist/server/modules/products/index.js +42 -24
- package/dist/server/modules/quotation/index.js +38 -29
- package/dist/server/modules/resource/index.js +4 -3
- package/dist/server/modules/schedule/index.js +35 -27
- package/dist/server/utils/product.js +1 -0
- package/dist/solution/BaseSales/index.js +41 -38
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.js +60 -11
- package/dist/solution/BookingByStep/utils/capacity.js +11 -1
- package/dist/solution/BookingByStep/utils/resources.js +3 -1
- package/dist/solution/BookingByStep/utils/timeslots.js +43 -2
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +2 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +7 -6
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +31 -25
- package/dist/solution/BookingTicket/utils/scan/index.js +10 -6
- package/dist/solution/BuyTickets/index.js +12 -9
- package/dist/solution/Checkout/index.js +252 -177
- package/dist/solution/Checkout/utils/index.js +16 -4
- package/dist/solution/RegisterAndLogin/index.js +76 -30
- package/dist/solution/ScanOrder/index.js +60 -50
- package/dist/solution/ShopDiscount/index.js +14 -15
- package/dist/solution/ShopDiscount/types.d.ts +4 -5
- package/dist/solution/ShopDiscount/utils.d.ts +0 -9
- package/dist/solution/ShopDiscount/utils.js +0 -9
- package/dist/solution/VenueBooking/index.d.ts +3 -31
- package/dist/solution/VenueBooking/index.js +496 -651
- package/dist/solution/VenueBooking/types.d.ts +1 -3
- package/dist/solution/VenueBooking/types.js +0 -1
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
- package/dist/solution/VenueBooking/utils/dateSummary.js +25 -12
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
- package/dist/solution/VenueBooking/utils/timeSlot.js +4 -9
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/task.js +18 -15
- package/dist/utils/watch.js +1 -0
- package/lib/apis/picoding.js +0 -2
- package/lib/core/index.js +132 -130
- package/lib/effects/index.js +57 -46
- package/lib/index.d.ts +0 -1
- package/lib/index.js +50 -92
- package/lib/model/index.js +21 -14
- package/lib/model/strategy/adapter/dataVariant/adapter.js +50 -38
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +236 -162
- package/lib/model/strategy/adapter/dataVariant/examples.js +237 -229
- package/lib/model/strategy/adapter/dataVariant/index.js +34 -39
- package/lib/model/strategy/adapter/dataVariant/type.js +28 -57
- package/lib/model/strategy/adapter/index.js +64 -100
- package/lib/model/strategy/adapter/itemRule/adapter.js +144 -156
- package/lib/model/strategy/adapter/itemRule/evaluator.js +48 -36
- package/lib/model/strategy/adapter/itemRule/examples.js +225 -295
- package/lib/model/strategy/adapter/itemRule/index.js +57 -83
- package/lib/model/strategy/adapter/itemRule/type.js +36 -97
- package/lib/model/strategy/adapter/promotion/adapter.js +63 -84
- package/lib/model/strategy/adapter/promotion/evaluator.js +231 -381
- package/lib/model/strategy/adapter/promotion/examples.js +159 -139
- package/lib/model/strategy/adapter/promotion/index.js +49 -1
- package/lib/model/strategy/adapter/promotion/type.js +35 -199
- package/lib/model/strategy/adapter/type.js +16 -4
- package/lib/model/strategy/adapter/walletPass/evaluator.js +152 -180
- package/lib/model/strategy/adapter/walletPass/example.js +190 -217
- package/lib/model/strategy/adapter/walletPass/index.js +51 -75
- package/lib/model/strategy/adapter/walletPass/locales.js +58 -36
- package/lib/model/strategy/adapter/walletPass/type.d.ts +0 -3
- package/lib/model/strategy/adapter/walletPass/type.js +16 -4
- package/lib/model/strategy/adapter/walletPass/utils.d.ts +0 -26
- package/lib/model/strategy/adapter/walletPass/utils.js +383 -678
- package/lib/model/strategy/engine.js +168 -270
- package/lib/model/strategy/index.js +34 -49
- package/lib/model/strategy/strategy-example.js +239 -243
- package/lib/model/strategy/type.js +40 -100
- package/lib/modules/Account/index.js +53 -39
- package/lib/modules/Account/types.js +33 -20
- package/lib/modules/AccountList/index.js +154 -116
- package/lib/modules/AccountList/types.js +31 -30
- package/lib/modules/AccountList/utils.js +30 -18
- package/lib/modules/BaseModule.d.ts +1 -1
- package/lib/modules/BaseModule.js +46 -25
- package/lib/modules/BookingContext/index.js +136 -158
- package/lib/modules/BookingContext/types.js +32 -46
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +143 -131
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +82 -75
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +150 -170
- package/lib/modules/BookingContext/utils/flexible.js +55 -38
- package/lib/modules/BookingContext/utils/formatResourceList.js +34 -19
- package/lib/modules/BookingContext/utils/index.js +41 -124
- package/lib/modules/BookingContext/utils/noResource.js +70 -58
- package/lib/modules/BookingContext/utils/orderLineDisplay.js +41 -14
- package/lib/modules/BookingContext/utils/productExtend.js +155 -202
- package/lib/modules/BookingContext/utils/resourceErrors.js +53 -53
- package/lib/modules/BookingContext/utils/resourceSelection.js +41 -19
- package/lib/modules/BookingContext/utils/resources.js +167 -209
- package/lib/modules/BookingContext/utils/serviceTimes.js +116 -115
- package/lib/modules/BookingContext/utils/timeSlices.js +80 -70
- package/lib/modules/Cart/index.js +124 -170
- package/lib/modules/Cart/types.js +51 -46
- package/lib/modules/Cart/utils/cartAccount.js +39 -40
- package/lib/modules/Cart/utils/cartDate.js +61 -56
- package/lib/modules/Cart/utils/cartDiscount.js +33 -28
- package/lib/modules/Cart/utils/cartNote.js +32 -27
- package/lib/modules/Cart/utils/cartProduct.js +251 -321
- package/lib/modules/Cart/utils/cartRelationForms.js +35 -29
- package/lib/modules/Cart/utils/cartResource.js +78 -72
- package/lib/modules/Cart/utils/changePrice.js +50 -28
- package/lib/modules/Cart/utils/index.js +48 -106
- package/lib/modules/Customer/constants.js +34 -13
- package/lib/modules/Customer/index.js +169 -232
- package/lib/modules/Customer/types.js +35 -38
- package/lib/modules/Date/index.js +115 -116
- package/lib/modules/Date/types.js +28 -16
- package/lib/modules/Date/utils.js +123 -174
- package/lib/modules/Discount/index.d.ts +0 -1
- package/lib/modules/Discount/index.js +128 -130
- package/lib/modules/Discount/types.d.ts +0 -1
- package/lib/modules/Discount/types.js +31 -9
- package/lib/modules/Guests/index.js +56 -30
- package/lib/modules/Guests/types.js +33 -23
- package/lib/modules/Holder/index.js +189 -209
- package/lib/modules/Holder/types.js +16 -4
- package/lib/modules/Holder/utils.js +49 -20
- package/lib/modules/OpenData/index.js +76 -69
- package/lib/modules/OpenData/types.js +16 -4
- package/lib/modules/OpenData/utils.js +78 -44
- package/lib/modules/Order/index.js +1909 -1572
- package/lib/modules/Order/types.js +35 -78
- package/lib/modules/Order/utils/bundleDiscountHydration.js +74 -41
- package/lib/modules/Order/utils/manualProductDiscount.js +123 -124
- package/lib/modules/Order/utils/orderCollectionIdentity.js +210 -148
- package/lib/modules/Order/utils.js +634 -799
- package/lib/modules/Payment/cash.js +33 -20
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +76 -145
- package/lib/modules/Payment/eftpos.js +30 -16
- package/lib/modules/Payment/index.js +378 -518
- package/lib/modules/Payment/mx51.js +0 -1
- package/lib/modules/Payment/types.d.ts +4 -8
- package/lib/modules/Payment/types.js +107 -216
- package/lib/modules/Payment/utils.js +48 -51
- package/lib/modules/Payment/walletpass.d.ts +0 -2
- package/lib/modules/Payment/walletpass.js +211 -226
- package/lib/modules/Product/index.js +46 -51
- package/lib/modules/Product/types.js +16 -4
- package/lib/modules/Product/utils.js +33 -32
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +117 -117
- package/lib/modules/ProductList/types.d.ts +0 -1
- package/lib/modules/ProductList/types.js +31 -9
- package/lib/modules/Quotation/index.js +100 -66
- package/lib/modules/Quotation/types.js +16 -4
- package/lib/modules/Resource/index.js +59 -27
- package/lib/modules/Resource/types.js +32 -22
- package/lib/modules/Resource/utils.js +38 -30
- package/lib/modules/ResourcePlanner/index.js +61 -60
- package/lib/modules/ResourcePlanner/planner.js +384 -346
- package/lib/modules/ResourcePlanner/types.js +16 -4
- package/lib/modules/Rules/index.js +903 -1475
- package/lib/modules/Rules/types.js +40 -17
- package/lib/modules/SalesSummary/index.js +90 -85
- package/lib/modules/SalesSummary/types.js +16 -4
- package/lib/modules/SalesSummary/utils.js +427 -351
- package/lib/modules/ScanOrderLogger/index.js +79 -59
- package/lib/modules/ScanOrderLogger/providers/feishu.js +78 -54
- package/lib/modules/ScanOrderLogger/providers/grafana.js +36 -13
- package/lib/modules/ScanOrderLogger/types.js +16 -4
- package/lib/modules/Schedule/getDateIsInSchedule.js +163 -339
- package/lib/modules/Schedule/index.js +114 -100
- package/lib/modules/Schedule/type.js +16 -4
- package/lib/modules/Schedule/types.js +16 -4
- package/lib/modules/Schedule/utils.js +291 -433
- package/lib/modules/Step/index.js +52 -40
- package/lib/modules/Step/tyeps.js +16 -4
- package/lib/modules/Summary/index.js +71 -66
- package/lib/modules/Summary/types.js +16 -4
- package/lib/modules/Summary/utils.js +418 -791
- package/lib/modules/SurchargeList/index.js +60 -46
- package/lib/modules/SurchargeList/types.js +16 -4
- package/lib/modules/index.js +63 -245
- package/lib/plugins/app.js +16 -4
- package/lib/plugins/index.js +25 -36
- package/lib/plugins/request.js +126 -137
- package/lib/plugins/shopStore.js +16 -4
- package/lib/plugins/user.js +16 -4
- package/lib/plugins/window.js +179 -171
- package/lib/server/index.js +2337 -2675
- package/lib/server/modules/floor-plan/index.js +123 -102
- package/lib/server/modules/floor-plan/types.js +30 -15
- package/lib/server/modules/index.js +68 -106
- package/lib/server/modules/menu/index.js +122 -146
- package/lib/server/modules/menu/types.js +31 -18
- package/lib/server/modules/order/index.js +642 -567
- package/lib/server/modules/order/types.js +32 -117
- package/lib/server/modules/order/utils/filterBookings.js +194 -219
- package/lib/server/modules/order/utils/filterOrders.js +92 -118
- package/lib/server/modules/payment/index.js +83 -59
- package/lib/server/modules/payment/types.js +16 -4
- package/lib/server/modules/products/index.js +459 -575
- package/lib/server/modules/products/types.js +34 -44
- package/lib/server/modules/quotation/index.js +172 -137
- package/lib/server/modules/quotation/types.js +31 -21
- package/lib/server/modules/resource/index.js +184 -213
- package/lib/server/modules/resource/types.js +33 -42
- package/lib/server/modules/schedule/index.js +123 -135
- package/lib/server/modules/schedule/types.js +21 -14
- package/lib/server/modules/schedule/utils.js +163 -334
- package/lib/server/types.js +16 -4
- package/lib/server/utils/index.js +23 -25
- package/lib/server/utils/product.js +139 -196
- package/lib/server/utils/schedule.js +41 -34
- package/lib/server/utils/small-ticket.js +456 -478
- package/lib/server/utils/time.js +49 -40
- package/lib/solution/BaseSales/index.js +1016 -850
- package/lib/solution/BaseSales/types.js +37 -41
- package/lib/solution/BaseSales/utils/cartPromotion.js +460 -611
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +105 -85
- package/lib/solution/BaseSales/utils/quotationPrice.js +114 -56
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +143 -102
- package/lib/solution/BaseSales/utils.js +140 -155
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +1340 -1530
- package/lib/solution/BookingByStep/types.js +99 -40
- package/lib/solution/BookingByStep/utils/capacity.js +160 -192
- package/lib/solution/BookingByStep/utils/products.js +52 -42
- package/lib/solution/BookingByStep/utils/resources.js +330 -527
- package/lib/solution/BookingByStep/utils/stock.js +44 -65
- package/lib/solution/BookingByStep/utils/timeslots.js +131 -129
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +459 -543
- package/lib/solution/BookingTicket/types.js +77 -99
- package/lib/solution/BookingTicket/utils/addProductDecision.js +184 -219
- package/lib/solution/BookingTicket/utils/addTimeAvailability.js +89 -58
- package/lib/solution/BookingTicket/utils/bookingStatus.js +78 -107
- package/lib/solution/BookingTicket/utils/cartView.js +94 -110
- package/lib/solution/BookingTicket/utils/exampleData.js +0 -185
- package/lib/solution/BookingTicket/utils/orderCustomer.js +41 -18
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +86 -219
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +93 -144
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +91 -79
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +41 -54
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +81 -84
- package/lib/solution/BookingTicket/utils/scan/index.js +104 -98
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +43 -90
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +64 -52
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +58 -56
- package/lib/solution/BuyTickets/index.js +70 -67
- package/lib/solution/BuyTickets/types.js +38 -22
- package/lib/solution/Checkout/index.js +1158 -1451
- package/lib/solution/Checkout/types.js +61 -91
- package/lib/solution/Checkout/utils/index.js +156 -228
- package/lib/solution/PlaceOrder/index.js +0 -55
- package/lib/solution/RegisterAndLogin/config.js +460 -493
- package/lib/solution/RegisterAndLogin/index.js +630 -633
- package/lib/solution/RegisterAndLogin/types.js +76 -189
- package/lib/solution/RegisterAndLogin/utils.js +125 -183
- package/lib/solution/Sales/index.js +320 -317
- package/lib/solution/Sales/types.js +33 -27
- package/lib/solution/ScanOrder/index.js +862 -831
- package/lib/solution/ScanOrder/types.js +34 -33
- package/lib/solution/ScanOrder/utils.js +371 -406
- package/lib/solution/ShopDiscount/index.js +233 -235
- package/lib/solution/ShopDiscount/types.d.ts +4 -5
- package/lib/solution/ShopDiscount/types.js +37 -15
- package/lib/solution/ShopDiscount/utils.d.ts +0 -9
- package/lib/solution/ShopDiscount/utils.js +172 -309
- package/lib/solution/UnifiedBookingSales/index.js +405 -379
- package/lib/solution/UnifiedBookingSales/types.js +31 -12
- package/lib/solution/VenueBooking/index.d.ts +3 -31
- package/lib/solution/VenueBooking/index.js +916 -967
- package/lib/solution/VenueBooking/types.d.ts +1 -3
- package/lib/solution/VenueBooking/types.js +39 -20
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
- package/lib/solution/VenueBooking/utils/dateSummary.js +62 -25
- package/lib/solution/VenueBooking/utils/resource.js +54 -31
- package/lib/solution/VenueBooking/utils/slotMerge.js +107 -94
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
- package/lib/solution/VenueBooking/utils/timeSlot.js +133 -138
- package/lib/solution/VenueBooking/utils.js +67 -130
- package/lib/solution/index.js +41 -124
- package/lib/store/createStore.js +29 -32
- package/lib/types/index.d.ts +1 -1
- package/lib/types/index.js +16 -4
- package/lib/utils/task.js +36 -36
- package/lib/utils/watch.js +47 -81
- package/package.json +2 -4
- package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
- package/dist/solution/VenueBooking/utils/smartPricing.js +0 -233
- package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
- package/lib/solution/VenueBooking/utils/smartPricing.js +0 -192
|
@@ -1,137 +1,152 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/solution/ShopDiscount/index.ts
|
|
30
|
+
var ShopDiscount_exports = {};
|
|
31
|
+
__export(ShopDiscount_exports, {
|
|
32
|
+
ShopDiscountImpl: () => ShopDiscountImpl,
|
|
33
|
+
default: () => ShopDiscount_default
|
|
5
34
|
});
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
class ShopDiscountImpl extends _BaseModule.BaseModule {
|
|
16
|
-
defaultName = 'shopDiscount';
|
|
17
|
-
defaultVersion = '1.0.0';
|
|
18
|
-
isSolution = true;
|
|
19
|
-
request;
|
|
20
|
-
window;
|
|
21
|
-
store;
|
|
22
|
-
options = {};
|
|
23
|
-
hooks;
|
|
35
|
+
module.exports = __toCommonJS(ShopDiscount_exports);
|
|
36
|
+
var import_BaseModule = require("../../modules/BaseModule");
|
|
37
|
+
var import_Discount = require("../../modules/Discount");
|
|
38
|
+
var import_Rules = require("../../modules/Rules");
|
|
39
|
+
var import_utils = require("./utils");
|
|
40
|
+
var import_types = require("../../modules/Rules/types");
|
|
41
|
+
var import_decimal = __toESM(require("decimal.js"));
|
|
42
|
+
var import_lodash_es = require("lodash-es");
|
|
43
|
+
var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
24
44
|
constructor(name, version) {
|
|
25
45
|
super(name, version);
|
|
26
|
-
|
|
46
|
+
this.defaultName = "shopDiscount";
|
|
47
|
+
this.defaultVersion = "1.0.0";
|
|
48
|
+
this.isSolution = true;
|
|
49
|
+
this.options = {};
|
|
27
50
|
this.store = {
|
|
28
51
|
customer: null,
|
|
29
52
|
productList: [],
|
|
30
53
|
discount: null,
|
|
31
54
|
rules: null,
|
|
55
|
+
holders: [],
|
|
32
56
|
originalDiscountList: [],
|
|
33
57
|
currentBookingTime: "",
|
|
34
58
|
filteredDiscountList: [],
|
|
59
|
+
bookingSubject: void 0,
|
|
35
60
|
orderTotalAmount: 0,
|
|
36
|
-
|
|
37
|
-
bookingSubject: undefined,
|
|
38
|
-
orderId: undefined
|
|
61
|
+
orderId: void 0
|
|
39
62
|
};
|
|
40
63
|
}
|
|
41
|
-
|
|
42
64
|
// =========== 生命周期方法 ===========
|
|
43
|
-
|
|
44
65
|
async initialize(core, options) {
|
|
66
|
+
var _a, _b;
|
|
45
67
|
this.core = core;
|
|
46
68
|
this.options = options;
|
|
47
|
-
this.store = {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
};
|
|
51
|
-
this.hooks = options.otherParams?.rules?.hooks;
|
|
52
|
-
// 获取依赖的插件
|
|
69
|
+
this.store = { ...this.store, ...options.store || {} };
|
|
70
|
+
this.hooks = (_b = (_a = options.otherParams) == null ? void 0 : _a.rules) == null ? void 0 : _b.hooks;
|
|
71
|
+
console.log("[ShopDiscount] 初始化完成");
|
|
53
72
|
this.initializePlugins();
|
|
54
|
-
|
|
55
|
-
// 注册依赖模块
|
|
56
73
|
this.registerDependentModules();
|
|
57
|
-
|
|
58
|
-
// 注册事件监听
|
|
59
74
|
this.registerEventListeners();
|
|
60
75
|
}
|
|
61
76
|
async destroy() {
|
|
77
|
+
var _a, _b;
|
|
62
78
|
this.store.productList = [];
|
|
63
79
|
this.store.customer = null;
|
|
64
|
-
this.store.discount
|
|
65
|
-
this.store.rules
|
|
80
|
+
(_a = this.store.discount) == null ? void 0 : _a.destroy();
|
|
81
|
+
(_b = this.store.rules) == null ? void 0 : _b.destroy();
|
|
66
82
|
this.core.effects.offByModuleDestroy(this.name);
|
|
67
83
|
await this.core.effects.emit(`${this.name}:onDestroy`, {});
|
|
84
|
+
console.log("[ShopDiscount] 已销毁");
|
|
68
85
|
}
|
|
69
86
|
async clear() {
|
|
87
|
+
var _a, _b;
|
|
70
88
|
this.store.productList = [];
|
|
71
89
|
this.store.customer = null;
|
|
72
|
-
this.store.discount
|
|
73
|
-
this.store.rules
|
|
90
|
+
(_a = this.store.discount) == null ? void 0 : _a.clear();
|
|
91
|
+
(_b = this.store.rules) == null ? void 0 : _b.clear();
|
|
92
|
+
console.log("[ShopDiscount] clear");
|
|
74
93
|
}
|
|
75
|
-
|
|
76
94
|
// =========== 初始化辅助方法 ===========
|
|
77
|
-
|
|
78
95
|
initializePlugins() {
|
|
79
|
-
this.request = this.core.getPlugin(
|
|
80
|
-
this.window = this.core.getPlugin(
|
|
96
|
+
this.request = this.core.getPlugin("request");
|
|
97
|
+
this.window = this.core.getPlugin("window");
|
|
81
98
|
if (!this.request) {
|
|
82
|
-
throw new Error(
|
|
99
|
+
throw new Error("ShopDiscount需要 request 插件支持");
|
|
83
100
|
}
|
|
84
101
|
if (!this.window) {
|
|
85
|
-
throw new Error(
|
|
102
|
+
throw new Error("ShopDiscount需要 window 插件支持");
|
|
86
103
|
}
|
|
87
104
|
}
|
|
88
105
|
registerDependentModules() {
|
|
89
|
-
|
|
90
|
-
// 并且在上面 registerModule 的时候,读取 sessionStroage 里的数据,塞进默认值
|
|
106
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
91
107
|
let targetCacheData = {};
|
|
92
|
-
if (this.options.otherParams
|
|
108
|
+
if ((_a = this.options.otherParams) == null ? void 0 : _a.cacheId) {
|
|
93
109
|
const sessionData = this.window.sessionStorage.getItem(this.name);
|
|
94
110
|
if (sessionData) {
|
|
95
111
|
const data = JSON.parse(sessionData);
|
|
96
112
|
targetCacheData = data[this.options.otherParams.cacheId];
|
|
97
113
|
}
|
|
98
114
|
}
|
|
99
|
-
|
|
100
|
-
const discount = new _Discount.DiscountModule(`${this.name}_discount`);
|
|
115
|
+
const discount = new import_Discount.DiscountModule(`${this.name}_discount`);
|
|
101
116
|
this.core.registerModule(discount, {
|
|
102
|
-
initialState: targetCacheData
|
|
103
|
-
hooks: this.options.otherParams
|
|
117
|
+
initialState: targetCacheData == null ? void 0 : targetCacheData[discount.name],
|
|
118
|
+
hooks: (_c = (_b = this.options.otherParams) == null ? void 0 : _b.discount) == null ? void 0 : _c.hooks,
|
|
104
119
|
otherParams: {
|
|
105
120
|
fatherModule: this.name,
|
|
106
|
-
openCache: this.options.otherParams
|
|
107
|
-
cacheId: this.options.otherParams
|
|
121
|
+
openCache: ((_d = this.options.otherParams) == null ? void 0 : _d.cacheId) ? true : false,
|
|
122
|
+
cacheId: (_e = this.options.otherParams) == null ? void 0 : _e.cacheId
|
|
108
123
|
}
|
|
109
124
|
});
|
|
110
125
|
this.store.discount = discount;
|
|
111
|
-
|
|
112
|
-
// 注册规则模块
|
|
113
|
-
const rules = new _Rules.RulesModule(`${this.name}_rules`);
|
|
126
|
+
const rules = new import_Rules.RulesModule(`${this.name}_rules`);
|
|
114
127
|
this.core.registerModule(rules, {
|
|
115
|
-
hooks: this.options.otherParams
|
|
128
|
+
hooks: (_g = (_f = this.options.otherParams) == null ? void 0 : _f.rules) == null ? void 0 : _g.hooks
|
|
116
129
|
});
|
|
117
130
|
this.store.rules = rules;
|
|
118
131
|
}
|
|
119
132
|
registerEventListeners() {
|
|
120
|
-
this.core.effects.only(
|
|
121
|
-
|
|
122
|
-
|
|
133
|
+
this.core.effects.only(
|
|
134
|
+
`${this.name}:onCustomerChange`,
|
|
135
|
+
(customer) => {
|
|
136
|
+
var _a;
|
|
137
|
+
if (((_a = this.options.otherParams) == null ? void 0 : _a.cacheId) && this.getDiscountList().length) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
this.loadPrepareConfig({
|
|
141
|
+
customerId: customer.id,
|
|
142
|
+
action: "create",
|
|
143
|
+
with_good_pass: 1,
|
|
144
|
+
with_discount_card: 1
|
|
145
|
+
});
|
|
123
146
|
}
|
|
124
|
-
|
|
125
|
-
customerId: customer.id,
|
|
126
|
-
action: 'create',
|
|
127
|
-
with_good_pass: 1,
|
|
128
|
-
with_discount_card: 1
|
|
129
|
-
});
|
|
130
|
-
});
|
|
147
|
+
);
|
|
131
148
|
}
|
|
132
|
-
|
|
133
149
|
// =========== 公共 API ===========
|
|
134
|
-
|
|
135
150
|
// 设置预约时间
|
|
136
151
|
// public async setBookingTime(bookingTime: string | null): Promise<void> {
|
|
137
152
|
// if (this.store.currentBookingTime !== bookingTime) {
|
|
@@ -141,23 +156,17 @@ class ShopDiscountImpl extends _BaseModule.BaseModule {
|
|
|
141
156
|
// await this.updateFilteredDiscountList();
|
|
142
157
|
// }
|
|
143
158
|
// }
|
|
144
|
-
|
|
145
159
|
// 获取当前预约时间
|
|
146
160
|
getCurrentBookingTime() {
|
|
147
161
|
return this.store.currentBookingTime;
|
|
148
162
|
}
|
|
149
|
-
|
|
150
163
|
// 根据预约时间过滤优惠券列表
|
|
151
164
|
filterDiscountListByBookingTime(discountList, bookingTime) {
|
|
152
|
-
|
|
153
|
-
if ((0, _utils.isAllNormalProduct)(this.store.productList || [])) {
|
|
165
|
+
if ((0, import_utils.isAllNormalProduct)(this.store.productList || [])) {
|
|
154
166
|
return discountList;
|
|
155
167
|
}
|
|
156
|
-
|
|
157
|
-
// 否则使用 bookingTime 进行过滤
|
|
158
|
-
return (0, _utils.filterDiscountListByBookingTime)(discountList, bookingTime);
|
|
168
|
+
return (0, import_utils.filterDiscountListByBookingTime)(discountList, bookingTime);
|
|
159
169
|
}
|
|
160
|
-
|
|
161
170
|
// 更新过滤后的优惠券列表
|
|
162
171
|
// private async updateFilteredDiscountList(): Promise<void> {
|
|
163
172
|
// const originalList = this.store.originalDiscountList;
|
|
@@ -176,18 +185,20 @@ class ShopDiscountImpl extends _BaseModule.BaseModule {
|
|
|
176
185
|
// );
|
|
177
186
|
// }
|
|
178
187
|
// }
|
|
179
|
-
|
|
180
188
|
// 设置客户
|
|
181
189
|
async setCustomer(customer) {
|
|
182
|
-
|
|
190
|
+
var _a;
|
|
191
|
+
if (((_a = this.store.customer) == null ? void 0 : _a.id) !== customer.id) {
|
|
183
192
|
this.store.customer = customer;
|
|
184
|
-
await this.core.effects.emit(
|
|
193
|
+
await this.core.effects.emit(
|
|
194
|
+
`${this.name}:onCustomerChange`,
|
|
195
|
+
customer
|
|
196
|
+
);
|
|
185
197
|
}
|
|
186
198
|
}
|
|
187
199
|
setOriginTotalAmount(amount) {
|
|
188
200
|
this.store.orderTotalAmount = amount;
|
|
189
201
|
}
|
|
190
|
-
|
|
191
202
|
// 设置holders
|
|
192
203
|
setHolders(holders) {
|
|
193
204
|
this.store.holders = holders;
|
|
@@ -198,30 +209,24 @@ class ShopDiscountImpl extends _BaseModule.BaseModule {
|
|
|
198
209
|
setOrderId(id) {
|
|
199
210
|
this.store.orderId = id;
|
|
200
211
|
}
|
|
201
|
-
|
|
202
212
|
// 计算优惠券
|
|
203
213
|
calcDiscount(productList, options) {
|
|
214
|
+
var _a;
|
|
204
215
|
this.store.productList = productList;
|
|
205
216
|
const rulesModule = this.core.getModule(`${this.name}_rules`);
|
|
206
217
|
if (!rulesModule) {
|
|
207
|
-
return {
|
|
208
|
-
productList,
|
|
209
|
-
discountList: this.getDiscountList()
|
|
210
|
-
};
|
|
218
|
+
return { productList, discountList: this.getDiscountList() };
|
|
211
219
|
}
|
|
212
|
-
let {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
productList,
|
|
223
|
-
discountList: this.getDiscountList()
|
|
224
|
-
};
|
|
220
|
+
let { productList: newProductList, discountList: newDiscountList } = rulesModule.calcDiscount(
|
|
221
|
+
{
|
|
222
|
+
productList,
|
|
223
|
+
discountList: this.getDiscountList(),
|
|
224
|
+
orderTotalAmount: this.store.orderTotalAmount || 0,
|
|
225
|
+
holders: this.store.holders || [],
|
|
226
|
+
isFormSubject: ((_a = this.store.bookingSubject) == null ? void 0 : _a.type) === "form"
|
|
227
|
+
},
|
|
228
|
+
options
|
|
229
|
+
) || { productList, discountList: this.getDiscountList() };
|
|
225
230
|
if (newDiscountList) {
|
|
226
231
|
newDiscountList = this.setDiscountList(newDiscountList);
|
|
227
232
|
}
|
|
@@ -230,35 +235,24 @@ class ShopDiscountImpl extends _BaseModule.BaseModule {
|
|
|
230
235
|
discountList: newDiscountList || this.getDiscountList()
|
|
231
236
|
};
|
|
232
237
|
}
|
|
233
|
-
|
|
234
238
|
// 设置优惠券使用状态
|
|
235
239
|
setDiscountSelected(params) {
|
|
236
|
-
// 获取当前优惠券列表
|
|
237
240
|
const discountList = this.getDiscountList();
|
|
238
|
-
|
|
239
|
-
// 构建选择操作列表
|
|
240
241
|
const selectionOperations = [];
|
|
241
|
-
|
|
242
|
-
// 主要操作
|
|
243
242
|
selectionOperations.push({
|
|
244
243
|
discountId: params.discountId,
|
|
245
244
|
isSelected: params.isSelected
|
|
246
245
|
});
|
|
247
|
-
|
|
248
|
-
// 如果有批量操作列表,添加到操作列表中
|
|
249
246
|
if (params.selectedList && params.selectedList.length > 0) {
|
|
250
247
|
selectionOperations.push(...params.selectedList);
|
|
251
248
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
const selectionMap = new Map();
|
|
255
|
-
selectionOperations.forEach(operation => {
|
|
249
|
+
const selectionMap = /* @__PURE__ */ new Map();
|
|
250
|
+
selectionOperations.forEach((operation) => {
|
|
256
251
|
selectionMap.set(operation.discountId, operation.isSelected);
|
|
257
252
|
});
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
if (discount.isEditMode) return discount;
|
|
253
|
+
const newDiscountList = discountList.map((discount) => {
|
|
254
|
+
if (discount.isEditMode)
|
|
255
|
+
return discount;
|
|
262
256
|
if (selectionMap.has(discount.id)) {
|
|
263
257
|
const targetIsSelected = selectionMap.get(discount.id);
|
|
264
258
|
return {
|
|
@@ -268,13 +262,8 @@ class ShopDiscountImpl extends _BaseModule.BaseModule {
|
|
|
268
262
|
isManualSelect: !targetIsSelected
|
|
269
263
|
};
|
|
270
264
|
}
|
|
271
|
-
return {
|
|
272
|
-
...discount,
|
|
273
|
-
isManualSelect: !discount?.isSelected
|
|
274
|
-
};
|
|
265
|
+
return { ...discount, isManualSelect: !(discount == null ? void 0 : discount.isSelected) };
|
|
275
266
|
});
|
|
276
|
-
|
|
277
|
-
// 更新优惠券列表
|
|
278
267
|
this.setDiscountList(newDiscountList);
|
|
279
268
|
return this.calcDiscount(this.store.productList || [], params);
|
|
280
269
|
}
|
|
@@ -282,8 +271,9 @@ class ShopDiscountImpl extends _BaseModule.BaseModule {
|
|
|
282
271
|
this.store.productList = productList;
|
|
283
272
|
}
|
|
284
273
|
async batchSearchByProductIds(productIds) {
|
|
285
|
-
|
|
286
|
-
resultDiscountList =
|
|
274
|
+
var _a;
|
|
275
|
+
let resultDiscountList = await ((_a = this.store.discount) == null ? void 0 : _a.batchSearchByProductIds(productIds)) || [];
|
|
276
|
+
resultDiscountList = resultDiscountList.map((item) => {
|
|
287
277
|
return {
|
|
288
278
|
...item,
|
|
289
279
|
discount_rule_uncheck_flag: true
|
|
@@ -294,21 +284,12 @@ class ShopDiscountImpl extends _BaseModule.BaseModule {
|
|
|
294
284
|
this.setDiscountList(newDiscountList);
|
|
295
285
|
return newDiscountList;
|
|
296
286
|
}
|
|
297
|
-
|
|
298
287
|
// 扫码输入code
|
|
299
288
|
async scanCode(code, customerId) {
|
|
289
|
+
var _a, _b, _c;
|
|
300
290
|
try {
|
|
301
|
-
const resultDiscountWithReason =
|
|
302
|
-
|
|
303
|
-
orderId: this.store.orderId
|
|
304
|
-
})) || {
|
|
305
|
-
discountList: [],
|
|
306
|
-
unavailableReasonKey: null
|
|
307
|
-
};
|
|
308
|
-
const {
|
|
309
|
-
discountList: resultDiscountList,
|
|
310
|
-
unavailableReasonKey
|
|
311
|
-
} = resultDiscountWithReason;
|
|
291
|
+
const resultDiscountWithReason = await ((_a = this.store.discount) == null ? void 0 : _a.batchSearch(code, { customerId, orderId: this.store.orderId })) || { discountList: [], unavailableReasonKey: null };
|
|
292
|
+
const { discountList: resultDiscountList, unavailableReasonKey } = resultDiscountWithReason;
|
|
312
293
|
const rulesModule = this.store.rules;
|
|
313
294
|
if (!rulesModule) {
|
|
314
295
|
return {
|
|
@@ -316,7 +297,7 @@ class ShopDiscountImpl extends _BaseModule.BaseModule {
|
|
|
316
297
|
isAvailable: false,
|
|
317
298
|
productList: this.store.productList || [],
|
|
318
299
|
discountList: this.getDiscountList(),
|
|
319
|
-
unavailableReason:
|
|
300
|
+
unavailableReason: import_types.UnavailableReason.Unknown
|
|
320
301
|
};
|
|
321
302
|
}
|
|
322
303
|
if (!resultDiscountList.length) {
|
|
@@ -328,15 +309,14 @@ class ShopDiscountImpl extends _BaseModule.BaseModule {
|
|
|
328
309
|
unavailableReasonKey
|
|
329
310
|
};
|
|
330
311
|
}
|
|
331
|
-
const withScanList = resultDiscountList.map(item => {
|
|
312
|
+
const withScanList = resultDiscountList.map((item) => {
|
|
332
313
|
return {
|
|
333
314
|
...item,
|
|
334
315
|
isScan: true
|
|
335
316
|
};
|
|
336
317
|
});
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
if (currentSelectedDiscountList.length && currentSelectedDiscountList.some(n => withScanList.some(m => m.id === n.id))) {
|
|
318
|
+
const currentSelectedDiscountList = this.getDiscountList().filter((n) => n.isSelected);
|
|
319
|
+
if (currentSelectedDiscountList.length && currentSelectedDiscountList.some((n) => withScanList.some((m) => m.id === n.id))) {
|
|
340
320
|
return {
|
|
341
321
|
type: "clientCalc",
|
|
342
322
|
isAvailable: true,
|
|
@@ -354,7 +334,7 @@ class ShopDiscountImpl extends _BaseModule.BaseModule {
|
|
|
354
334
|
oldDiscountList: this.getDiscountList(),
|
|
355
335
|
newDiscountList: withScanList,
|
|
356
336
|
holders: this.store.holders || [],
|
|
357
|
-
isFormSubject: this.store.bookingSubject
|
|
337
|
+
isFormSubject: ((_b = this.store.bookingSubject) == null ? void 0 : _b.type) === "form",
|
|
358
338
|
orderTotalAmount: this.store.orderTotalAmount || 0
|
|
359
339
|
}) || {
|
|
360
340
|
isAvailable: false,
|
|
@@ -365,8 +345,10 @@ class ShopDiscountImpl extends _BaseModule.BaseModule {
|
|
|
365
345
|
this.setDiscountList(newDiscountList || []);
|
|
366
346
|
this.store.originalDiscountList = newDiscountList || [];
|
|
367
347
|
this.setProductList(newProductList || []);
|
|
368
|
-
if (this.isWalkIn() && resultDiscountList.length && this.options.otherParams
|
|
369
|
-
await this.getCustomerWallet(
|
|
348
|
+
if (this.isWalkIn() && resultDiscountList.length && ((_c = this.options.otherParams) == null ? void 0 : _c.platform) === "shop" && !((resultDiscountList[0].customer_id || 1) === 1)) {
|
|
349
|
+
await this.getCustomerWallet(
|
|
350
|
+
resultDiscountList[0].customer_id
|
|
351
|
+
);
|
|
370
352
|
}
|
|
371
353
|
}
|
|
372
354
|
return {
|
|
@@ -377,56 +359,60 @@ class ShopDiscountImpl extends _BaseModule.BaseModule {
|
|
|
377
359
|
unavailableReason
|
|
378
360
|
};
|
|
379
361
|
} catch (error) {
|
|
380
|
-
console.error(
|
|
362
|
+
console.error("[ShopDiscount] 扫码出错:", error);
|
|
381
363
|
return {
|
|
382
364
|
type: "clientCalc",
|
|
383
365
|
isAvailable: false,
|
|
384
366
|
productList: this.store.productList || [],
|
|
385
367
|
discountList: this.getDiscountList(),
|
|
386
|
-
unavailableReason:
|
|
368
|
+
unavailableReason: import_types.UnavailableReason.Unknown
|
|
387
369
|
};
|
|
388
370
|
}
|
|
389
371
|
}
|
|
390
372
|
calcDiscountApplicableProductTotalPrice(discount) {
|
|
391
|
-
|
|
373
|
+
var _a;
|
|
374
|
+
return (_a = this.store.discount) == null ? void 0 : _a.calcDiscountApplicableProductTotalPrice(
|
|
375
|
+
discount
|
|
376
|
+
);
|
|
392
377
|
}
|
|
393
|
-
|
|
394
378
|
// =========== 私有辅助方法 ===========
|
|
395
|
-
|
|
396
379
|
// 获取客户
|
|
397
380
|
getCustomer() {
|
|
398
381
|
return this.store.customer;
|
|
399
382
|
}
|
|
400
|
-
|
|
401
383
|
// 是否是walkIn
|
|
402
384
|
isWalkIn() {
|
|
403
|
-
|
|
385
|
+
var _a;
|
|
386
|
+
return (((_a = this.getCustomer()) == null ? void 0 : _a.id) || 1) === 1;
|
|
404
387
|
}
|
|
405
|
-
|
|
406
388
|
// 触发优惠列表变更事件
|
|
407
389
|
async emitDiscountListChange(discountList) {
|
|
408
|
-
await this.core.effects.emit(
|
|
390
|
+
await this.core.effects.emit(
|
|
391
|
+
`${this.name}:onDiscountListChange`,
|
|
392
|
+
discountList
|
|
393
|
+
);
|
|
409
394
|
}
|
|
410
|
-
|
|
411
395
|
// 设置优惠券列表
|
|
412
396
|
setDiscountList(discountList) {
|
|
397
|
+
var _a;
|
|
413
398
|
const productList = this.store.productList || [];
|
|
414
399
|
const editModeDiscountList = [];
|
|
415
|
-
productList.forEach(item => {
|
|
400
|
+
productList.forEach((item) => {
|
|
401
|
+
var _a2;
|
|
416
402
|
if (item.booking_id) {
|
|
417
|
-
const product = this.hooks
|
|
418
|
-
(item.discount_list || []).forEach(discount => {
|
|
419
|
-
|
|
420
|
-
|
|
403
|
+
const product = (_a2 = this.hooks) == null ? void 0 : _a2.getProduct(item);
|
|
404
|
+
(item.discount_list || []).forEach((discount) => {
|
|
405
|
+
var _a3, _b, _c, _d, _e;
|
|
406
|
+
if (discount.id && ["good_pass", "discount_card"].includes(discount.type)) {
|
|
407
|
+
const index = editModeDiscountList.findIndex((n) => {
|
|
408
|
+
var _a4;
|
|
409
|
+
return n.id === (((_a4 = discount.discount) == null ? void 0 : _a4.resource_id) || discount.id);
|
|
410
|
+
});
|
|
421
411
|
if (index !== -1) {
|
|
422
412
|
editModeDiscountList[index] = {
|
|
423
413
|
...editModeDiscountList[index],
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
num: (editModeDiscountList?.[index]?.metadata?.num || 1) + (discount.metadata?.num || 1)
|
|
427
|
-
},
|
|
428
|
-
amount: new _decimal.default(discount.amount || 0).plus(new _decimal.default(editModeDiscountList[index].amount || 0)).toNumber(),
|
|
429
|
-
savedAmount: new _decimal.default(discount.amount || 0).times(product?.quantity || product?.num || 1).plus(discount?.metadata?.product_discount_difference || 0).plus(new _decimal.default(editModeDiscountList[index].savedAmount || 0)).toNumber()
|
|
414
|
+
amount: new import_decimal.default(discount.amount || 0).plus(new import_decimal.default(editModeDiscountList[index].amount || 0)).toNumber(),
|
|
415
|
+
savedAmount: new import_decimal.default(discount.amount || 0).times((product == null ? void 0 : product.quantity) || (product == null ? void 0 : product.num) || 1).plus(((_a3 = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a3.product_discount_difference) || 0).plus(new import_decimal.default(editModeDiscountList[index].savedAmount || 0)).toNumber()
|
|
430
416
|
};
|
|
431
417
|
} else {
|
|
432
418
|
if (discount.type && !discount.tag) {
|
|
@@ -434,41 +420,47 @@ class ShopDiscountImpl extends _BaseModule.BaseModule {
|
|
|
434
420
|
}
|
|
435
421
|
editModeDiscountList.push({
|
|
436
422
|
...discount,
|
|
437
|
-
metadata: {
|
|
438
|
-
...(discount.metadata || {}),
|
|
439
|
-
num: discount.metadata?.num || 1
|
|
440
|
-
},
|
|
441
423
|
name: discount.name || discount.discount.title.auto,
|
|
442
424
|
isEditMode: true,
|
|
443
425
|
limited_relation_product_data: {},
|
|
444
|
-
savedAmount: new
|
|
426
|
+
savedAmount: new import_decimal.default(discount.amount || 0).times((product == null ? void 0 : product.quantity) || (product == null ? void 0 : product.num) || 1).plus(((_b = discount == null ? void 0 : discount.metadata) == null ? void 0 : _b.product_discount_difference) || 0).toNumber(),
|
|
445
427
|
isAvailable: true,
|
|
446
|
-
id: discount.discount
|
|
447
|
-
format_title: discount.discount
|
|
428
|
+
id: ((_c = discount.discount) == null ? void 0 : _c.resource_id) || discount.id,
|
|
429
|
+
format_title: ((_d = discount.discount) == null ? void 0 : _d.title) || discount.format_title,
|
|
448
430
|
isDisabled: true,
|
|
449
431
|
isSelected: true,
|
|
450
|
-
product_id: discount.discount
|
|
432
|
+
product_id: ((_e = discount.discount) == null ? void 0 : _e.product_id) || discount.product_id
|
|
451
433
|
});
|
|
452
434
|
}
|
|
453
435
|
}
|
|
454
436
|
});
|
|
455
437
|
}
|
|
456
438
|
});
|
|
457
|
-
const newDiscountList = [
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
439
|
+
const newDiscountList = [
|
|
440
|
+
...editModeDiscountList,
|
|
441
|
+
...discountList.filter((item) => !item.isDisabled)
|
|
442
|
+
];
|
|
443
|
+
const isProductFree = (id) => {
|
|
444
|
+
var _a2;
|
|
445
|
+
const targetProduct = productList.find((n) => n.id === id);
|
|
446
|
+
if (!targetProduct)
|
|
447
|
+
return false;
|
|
448
|
+
const product = (_a2 = this.hooks) == null ? void 0 : _a2.getProduct(targetProduct);
|
|
449
|
+
return Number(product == null ? void 0 : product.total) <= 0 && (Number(product == null ? void 0 : product.origin_total) <= 0 || !(product == null ? void 0 : product.origin_total)) || (0, import_lodash_es.isBoolean)(product == null ? void 0 : product.vouchersApplicable) && !(product == null ? void 0 : product.vouchersApplicable);
|
|
465
450
|
};
|
|
466
|
-
const allUsedProductIds = newDiscountList.filter(item => !item
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
451
|
+
const allUsedProductIds = newDiscountList.filter((item) => !(item == null ? void 0 : item.isEditMode)).map((n) => {
|
|
452
|
+
var _a2;
|
|
453
|
+
return n.isSelected ? ((_a2 = n.appliedProductDetails) == null ? void 0 : _a2.map((n2) => {
|
|
454
|
+
var _a3;
|
|
455
|
+
return (_a3 = n2.discount) == null ? void 0 : _a3.product_id;
|
|
456
|
+
})) || n.product_id : [];
|
|
457
|
+
}).flat();
|
|
458
|
+
newDiscountList.forEach((item) => {
|
|
459
|
+
var _a2;
|
|
460
|
+
const isAllProductUsedOrFree = (_a2 = item.applicableProductIds) == null ? void 0 : _a2.every((id) => {
|
|
461
|
+
var _a3;
|
|
462
|
+
const sameIdTimes = ((_a3 = item.applicableProductIds) == null ? void 0 : _a3.filter((n) => n === id).length) || 1;
|
|
463
|
+
const targetIdTimes = (allUsedProductIds == null ? void 0 : allUsedProductIds.filter((n) => n === id).length) || 0;
|
|
472
464
|
return targetIdTimes >= sameIdTimes || isProductFree(id);
|
|
473
465
|
});
|
|
474
466
|
if (!item.isSelected && isAllProductUsedOrFree) {
|
|
@@ -477,89 +469,95 @@ class ShopDiscountImpl extends _BaseModule.BaseModule {
|
|
|
477
469
|
item.isDisabledForProductUsed = false;
|
|
478
470
|
}
|
|
479
471
|
});
|
|
480
|
-
this.store.discount
|
|
472
|
+
(_a = this.store.discount) == null ? void 0 : _a.setDiscountList(newDiscountList);
|
|
481
473
|
this.emitDiscountListChange(newDiscountList);
|
|
482
474
|
return newDiscountList;
|
|
483
475
|
}
|
|
484
|
-
|
|
485
476
|
// 获取优惠券列表
|
|
486
477
|
getDiscountList() {
|
|
487
|
-
|
|
478
|
+
var _a;
|
|
479
|
+
return ((_a = this.store.discount) == null ? void 0 : _a.getDiscountList()) || [];
|
|
488
480
|
}
|
|
489
|
-
|
|
490
481
|
// 获取客户钱包信息
|
|
491
482
|
async getCustomerWallet(id) {
|
|
492
483
|
try {
|
|
493
484
|
const result = await this.request.get(`/customer/info/${id}`, {
|
|
494
485
|
with_trashed: 1
|
|
495
486
|
});
|
|
496
|
-
if (result
|
|
497
|
-
const {
|
|
498
|
-
...customer
|
|
499
|
-
} = result.data;
|
|
487
|
+
if (result == null ? void 0 : result.data) {
|
|
488
|
+
const { ...customer } = result.data;
|
|
500
489
|
this.setCustomer(customer);
|
|
501
|
-
await this.core.effects.emit(
|
|
490
|
+
await this.core.effects.emit(
|
|
491
|
+
`${this.name}:onScanCustomerChange`,
|
|
492
|
+
customer
|
|
493
|
+
);
|
|
502
494
|
}
|
|
503
495
|
} catch (error) {
|
|
504
|
-
console.error(
|
|
496
|
+
console.error("[ShopDiscount] 获取客户钱包信息出错:", error);
|
|
505
497
|
}
|
|
506
498
|
}
|
|
507
499
|
async bestDiscount(cb) {
|
|
500
|
+
var _a;
|
|
508
501
|
const newDiscountList = this.store.originalDiscountList;
|
|
509
502
|
this.setDiscountList(newDiscountList);
|
|
510
|
-
if (this.store.productList
|
|
503
|
+
if ((_a = this.store.productList) == null ? void 0 : _a.length) {
|
|
511
504
|
const result = this.calcDiscount(this.store.productList);
|
|
512
|
-
cb
|
|
513
|
-
await this.core.effects.emit(
|
|
505
|
+
cb == null ? void 0 : cb(result);
|
|
506
|
+
await this.core.effects.emit(
|
|
507
|
+
`${this.name}:onLoadPrepareCalcResult`,
|
|
508
|
+
result
|
|
509
|
+
);
|
|
514
510
|
}
|
|
515
|
-
await this.core.effects.emit(
|
|
511
|
+
await this.core.effects.emit(
|
|
512
|
+
`${this.name}:onLoadDiscountList`,
|
|
513
|
+
newDiscountList
|
|
514
|
+
);
|
|
516
515
|
}
|
|
517
|
-
|
|
518
516
|
// 加载准备配置
|
|
519
517
|
async loadPrepareConfig(params) {
|
|
518
|
+
var _a, _b, _c, _d, _e;
|
|
520
519
|
try {
|
|
521
520
|
const orderId = this.store.orderId;
|
|
522
|
-
const customerId = params.customerId || this.getCustomer()
|
|
523
|
-
|
|
524
|
-
// return
|
|
525
|
-
// }
|
|
526
|
-
|
|
527
|
-
const prepareConfigResult = await this.store.discount?.loadPrepareConfig({
|
|
521
|
+
const customerId = params.customerId || ((_a = this.getCustomer()) == null ? void 0 : _a.id);
|
|
522
|
+
const prepareConfigResult = await ((_b = this.store.discount) == null ? void 0 : _b.loadPrepareConfig({
|
|
528
523
|
customer_id: customerId,
|
|
529
|
-
action: orderId ?
|
|
524
|
+
action: orderId ? "edit" : "create",
|
|
530
525
|
with_good_pass: 1,
|
|
531
526
|
with_discount_card: 1,
|
|
532
527
|
with_wallet_pass_holder: 1,
|
|
533
528
|
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
534
|
-
...
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
const
|
|
543
|
-
const newGoodPassList = goodPassList.filter(n => !scanDiscountIds.includes(n.id));
|
|
544
|
-
const newDiscountList = [...scanDiscount, ...(newGoodPassList || [])];
|
|
545
|
-
|
|
546
|
-
// 存储原始优惠券列表
|
|
529
|
+
...orderId ? { order_id: orderId } : {}
|
|
530
|
+
}));
|
|
531
|
+
const goodPassList = (prepareConfigResult == null ? void 0 : prepareConfigResult.discountList) || [];
|
|
532
|
+
const scanDiscount = (_c = this.getDiscountList()) == null ? void 0 : _c.filter(
|
|
533
|
+
(item) => item.isScan
|
|
534
|
+
);
|
|
535
|
+
const scanDiscountIds = scanDiscount.map((n) => n.id);
|
|
536
|
+
const newGoodPassList = goodPassList == null ? void 0 : goodPassList.filter((n) => !scanDiscountIds.includes(n.id));
|
|
537
|
+
const newDiscountList = [...scanDiscount, ...newGoodPassList || []];
|
|
547
538
|
this.store.originalDiscountList = newDiscountList;
|
|
548
|
-
await this.store.discount
|
|
549
|
-
|
|
550
|
-
// 根据当前预约时间过滤优惠券列表
|
|
539
|
+
await ((_d = this.store.discount) == null ? void 0 : _d.setOriginalDiscountList(newDiscountList));
|
|
551
540
|
const filteredDiscountList = this.filterDiscountListByBookingTime(newDiscountList, this.store.currentBookingTime);
|
|
552
541
|
this.store.filteredDiscountList = filteredDiscountList;
|
|
553
542
|
this.setDiscountList(filteredDiscountList || []);
|
|
554
|
-
if (this.store.productList
|
|
543
|
+
if ((_e = this.store.productList) == null ? void 0 : _e.length) {
|
|
555
544
|
const result = this.calcDiscount(this.store.productList);
|
|
556
|
-
await this.core.effects.emit(
|
|
545
|
+
await this.core.effects.emit(
|
|
546
|
+
`${this.name}:onLoadPrepareCalcResult`,
|
|
547
|
+
result
|
|
548
|
+
);
|
|
557
549
|
}
|
|
558
|
-
await this.core.effects.emit(
|
|
550
|
+
await this.core.effects.emit(
|
|
551
|
+
`${this.name}:onLoadDiscountList`,
|
|
552
|
+
filteredDiscountList
|
|
553
|
+
);
|
|
559
554
|
} catch (error) {
|
|
560
|
-
console.error(
|
|
555
|
+
console.error("[ShopDiscount] 加载准备配置出错:", error);
|
|
561
556
|
}
|
|
562
557
|
}
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
|
|
558
|
+
};
|
|
559
|
+
var ShopDiscount_default = ShopDiscountImpl;
|
|
560
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
561
|
+
0 && (module.exports = {
|
|
562
|
+
ShopDiscountImpl
|
|
563
|
+
});
|