@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,211 +1,198 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
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 });
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/solution/BookingTicket/index.ts
|
|
31
|
+
var BookingTicket_exports = {};
|
|
32
|
+
__export(BookingTicket_exports, {
|
|
33
|
+
BookingTicket: () => BookingTicketImpl,
|
|
34
|
+
BookingTicketImpl: () => BookingTicketImpl
|
|
23
35
|
});
|
|
24
|
-
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
var
|
|
29
|
-
var
|
|
30
|
-
var
|
|
31
|
-
var
|
|
32
|
-
var
|
|
33
|
-
var
|
|
34
|
-
var
|
|
35
|
-
var
|
|
36
|
-
var
|
|
37
|
-
var
|
|
38
|
-
var
|
|
39
|
-
var
|
|
40
|
-
var
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* const bookingUid = resolveBookingUidForAddTime(booking);
|
|
50
|
-
*/
|
|
36
|
+
module.exports = __toCommonJS(BookingTicket_exports);
|
|
37
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
38
|
+
var import_types = require("./types");
|
|
39
|
+
var import_BookingContext = require("../../modules/BookingContext");
|
|
40
|
+
var import_BaseSales = require("../BaseSales");
|
|
41
|
+
var import_scan = __toESM(require("./utils/scan"));
|
|
42
|
+
var import_orderCustomer = require("./utils/orderCustomer");
|
|
43
|
+
var import_handleScan = require("./utils/scan/handleScan");
|
|
44
|
+
var import_scanCache = __toESM(require("./utils/scan/scanCache"));
|
|
45
|
+
var import_formatGlobalScan = require("./utils/scan/formatGlobalScan");
|
|
46
|
+
var import_applyGlobalScan = require("./utils/scan/applyGlobalScan");
|
|
47
|
+
var import_cartView = require("./utils/cartView");
|
|
48
|
+
var import_addProductDecision = require("./utils/addProductDecision");
|
|
49
|
+
var import_buildCacheItemFromOrderLine = require("../../modules/BookingContext/utils/buildCacheItemFromOrderLine");
|
|
50
|
+
var import_sessionCatalogStale = require("./utils/sessionCatalogStale");
|
|
51
|
+
var import_buildNormalProductCacheItemFromOrderLine = require("../../modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine");
|
|
52
|
+
var import_orderLineDisplay = require("../../modules/BookingContext/utils/orderLineDisplay");
|
|
53
|
+
var import_bookingStatus = require("./utils/bookingStatus");
|
|
54
|
+
var import_resolveBestAddTimePlan = require("./utils/resolveBestAddTimePlan");
|
|
55
|
+
var import_utils = require("../../modules/Order/utils");
|
|
56
|
+
__reExport(BookingTicket_exports, require("./types"), module.exports);
|
|
57
|
+
var OPEN_DATA_SECTION_CODES = ["sale", "reservation", "fulfillment", "menu", "workflow"];
|
|
58
|
+
var OPEN_DATA_CACHE_TTL = 5 * 60 * 1e3;
|
|
51
59
|
function resolveBookingUidForAddTime(booking) {
|
|
52
|
-
|
|
53
|
-
|
|
60
|
+
var _a;
|
|
61
|
+
const uid = (_a = booking == null ? void 0 : booking.metadata) == null ? void 0 : _a.unique_identification_number;
|
|
62
|
+
return uid === void 0 || uid === null ? "" : String(uid);
|
|
54
63
|
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* 规范化加车数量,避免非法值进入 OrderModule。
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* const quantity = normalizeAddTimeQuantity(product.num);
|
|
61
|
-
*/
|
|
62
64
|
function normalizeAddTimeQuantity(value) {
|
|
63
65
|
const parsed = Math.floor(Number(value));
|
|
64
66
|
return Number.isFinite(parsed) && parsed > 0 ? parsed : 1;
|
|
65
67
|
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* 解析加时时长,优先使用显式入参,其次回退商品字段。
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
* const minutes = resolveAddTimeScheduleMinutes(input.product_add_schedule_time, product);
|
|
72
|
-
*/
|
|
73
68
|
function resolveAddTimeScheduleMinutes(explicitValue, product) {
|
|
74
|
-
const raw = explicitValue ?? product
|
|
75
|
-
if (raw ===
|
|
69
|
+
const raw = explicitValue ?? (product == null ? void 0 : product.product_add_schedule_time);
|
|
70
|
+
if (raw === void 0 || raw === null || raw === "")
|
|
71
|
+
return void 0;
|
|
76
72
|
const parsed = Number(raw);
|
|
77
|
-
return Number.isFinite(parsed) ? parsed :
|
|
73
|
+
return Number.isFinite(parsed) ? parsed : void 0;
|
|
78
74
|
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* 计算加时商品行价格字段,保持 `price` 与 `selling_price` 输入口径一致。
|
|
82
|
-
*
|
|
83
|
-
* @example
|
|
84
|
-
* const price = resolveAddTimeProductPrice(input.price, product);
|
|
85
|
-
*/
|
|
86
75
|
function resolveAddTimeProductPrice(explicitValue, product) {
|
|
87
|
-
return explicitValue ?? product
|
|
76
|
+
return explicitValue ?? (product == null ? void 0 : product.price) ?? (product == null ? void 0 : product.selling_price) ?? (product == null ? void 0 : product.base_price);
|
|
88
77
|
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* 规范化加时覆盖分钟数。
|
|
92
|
-
*
|
|
93
|
-
* @example
|
|
94
|
-
* const minutes = normalizeCoveredMinutes(input.coveredMinutes);
|
|
95
|
-
*/
|
|
96
78
|
function normalizeCoveredMinutes(value) {
|
|
97
79
|
const parsed = Math.ceil(Number(value));
|
|
98
80
|
return Number.isFinite(parsed) && parsed > 0 ? parsed : 0;
|
|
99
81
|
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* 计算 booking 加时后的结束时间与时长。
|
|
103
|
-
*
|
|
104
|
-
* @example
|
|
105
|
-
* const updates = buildAddTimeBookingTimePatch(booking, 30);
|
|
106
|
-
*/
|
|
107
82
|
function buildAddTimeBookingTimePatch(booking, coveredMinutes) {
|
|
108
|
-
if (coveredMinutes <= 0)
|
|
109
|
-
|
|
110
|
-
const
|
|
83
|
+
if (coveredMinutes <= 0)
|
|
84
|
+
return null;
|
|
85
|
+
const endDate = booking == null ? void 0 : booking.end_date;
|
|
86
|
+
const endTime = booking == null ? void 0 : booking.end_time;
|
|
111
87
|
if (!endDate || !endTime) {
|
|
112
|
-
throw new Error(
|
|
88
|
+
throw new Error("[BookingTicket] addAddTimeProductsToBooking: booking.end_date/end_time 缺失");
|
|
113
89
|
}
|
|
114
|
-
const currentEnd = (0,
|
|
90
|
+
const currentEnd = (0, import_dayjs.default)(`${endDate} ${endTime}`);
|
|
115
91
|
if (!currentEnd.isValid()) {
|
|
116
|
-
throw new Error(
|
|
92
|
+
throw new Error("[BookingTicket] addAddTimeProductsToBooking: booking.end_date/end_time 无效");
|
|
117
93
|
}
|
|
118
|
-
const nextEnd = currentEnd.add(coveredMinutes,
|
|
119
|
-
const currentDuration = Number(booking
|
|
94
|
+
const nextEnd = currentEnd.add(coveredMinutes, "minute");
|
|
95
|
+
const currentDuration = Number(booking == null ? void 0 : booking.duration);
|
|
120
96
|
let duration = Number.isFinite(currentDuration) ? currentDuration + coveredMinutes : coveredMinutes;
|
|
121
|
-
if (booking
|
|
122
|
-
const start = (0,
|
|
97
|
+
if ((booking == null ? void 0 : booking.start_date) && (booking == null ? void 0 : booking.start_time)) {
|
|
98
|
+
const start = (0, import_dayjs.default)(`${booking.start_date} ${booking.start_time}`);
|
|
123
99
|
if (start.isValid()) {
|
|
124
|
-
const diffMinutes = nextEnd.diff(start,
|
|
100
|
+
const diffMinutes = nextEnd.diff(start, "minute");
|
|
125
101
|
duration = diffMinutes > 0 ? diffMinutes : duration;
|
|
126
102
|
}
|
|
127
103
|
}
|
|
128
104
|
return {
|
|
129
|
-
end_date: nextEnd.format(
|
|
130
|
-
end_time: nextEnd.format(
|
|
105
|
+
end_date: nextEnd.format("YYYY-MM-DD"),
|
|
106
|
+
end_time: nextEnd.format("HH:mm"),
|
|
131
107
|
duration
|
|
132
108
|
};
|
|
133
109
|
}
|
|
134
110
|
function withProductOptionString(cacheItem) {
|
|
135
|
-
|
|
136
|
-
|
|
111
|
+
var _a;
|
|
112
|
+
const productOptionString = (0, import_orderLineDisplay.buildProductOptionStringFromOrderLine)(cacheItem);
|
|
113
|
+
if (!productOptionString)
|
|
114
|
+
return cacheItem;
|
|
137
115
|
return {
|
|
138
116
|
...cacheItem,
|
|
139
|
-
product_option_string: cacheItem
|
|
117
|
+
product_option_string: (cacheItem == null ? void 0 : cacheItem.product_option_string) || productOptionString,
|
|
140
118
|
_extend: {
|
|
141
|
-
...(cacheItem
|
|
142
|
-
product_option_string: cacheItem
|
|
119
|
+
...(cacheItem == null ? void 0 : cacheItem._extend) || {},
|
|
120
|
+
product_option_string: ((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.product_option_string) || productOptionString
|
|
143
121
|
}
|
|
144
122
|
};
|
|
145
123
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
124
|
+
var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
125
|
+
constructor() {
|
|
126
|
+
super(...arguments);
|
|
127
|
+
this.defaultName = "bookingTicket";
|
|
128
|
+
this.defaultVersion = "1.0.0";
|
|
129
|
+
/**
|
|
130
|
+
* 子类覆盖 store 类型为 BookingTicket 子模块清单(在父类基础上追加 customer)。
|
|
131
|
+
* 父类按 `getRegisteredModuleNames` 注入成员到该 store。
|
|
132
|
+
*/
|
|
133
|
+
this.store = {};
|
|
134
|
+
this.productCatalog = [];
|
|
135
|
+
this.addTimeProductsCatalog = [];
|
|
136
|
+
this.orderCustomerDiscountRefreshInFlight = null;
|
|
137
|
+
this.orderCustomerDiscountRefreshCustomerId = null;
|
|
138
|
+
this.loadOpenDataConfigInFlight = null;
|
|
139
|
+
}
|
|
163
140
|
/**
|
|
164
141
|
* 在 BaseSales 默认模块清单(products/order/salesSummary/schedule)基础上追加 customer + bookingContext。
|
|
165
142
|
* bookingContext 是 SalesSdk 加车下沉所需的「预约 UI 上下文」(bookingConfig / resourcesOrigin / date)。
|
|
166
143
|
*/
|
|
167
144
|
getRegisteredModuleNames() {
|
|
168
|
-
return [...super.getRegisteredModuleNames(),
|
|
145
|
+
return [...super.getRegisteredModuleNames(), "customer", "bookingContext", "openData"];
|
|
169
146
|
}
|
|
170
147
|
getSubmitOrderSalesChannel() {
|
|
171
|
-
|
|
172
|
-
|
|
148
|
+
var _a, _b, _c;
|
|
149
|
+
const channel = (_c = (_b = (_a = this.core) == null ? void 0 : _a.context) == null ? void 0 : _b.getChannel) == null ? void 0 : _c.call(_b);
|
|
150
|
+
return !channel || channel === "system" ? "pos" : channel;
|
|
173
151
|
}
|
|
174
|
-
|
|
175
152
|
/**
|
|
176
153
|
* 业务侧子模块工厂:BookingTicket 自带的 createBookingTicketModule 优先匹配;
|
|
177
154
|
* 未识别的模块名(如 BookingByStep 公共类型)回退到父类工厂。
|
|
178
155
|
*/
|
|
179
156
|
createSubModule(moduleName) {
|
|
180
|
-
const localModule = (0,
|
|
181
|
-
|
|
157
|
+
const localModule = (0, import_types.createBookingTicketModule)(
|
|
158
|
+
moduleName,
|
|
159
|
+
this.name
|
|
160
|
+
);
|
|
161
|
+
if (localModule)
|
|
162
|
+
return localModule;
|
|
182
163
|
return super.createSubModule(moduleName);
|
|
183
164
|
}
|
|
184
165
|
async initialize(core, options = {}) {
|
|
185
|
-
|
|
166
|
+
var _a;
|
|
167
|
+
this.scan = new import_scan.default(this, `BOOKING_TICKET_SCAN:${this.name}`);
|
|
186
168
|
await super.initialize(core, options);
|
|
187
169
|
if (!this.request) {
|
|
188
|
-
throw new Error(
|
|
170
|
+
throw new Error("bookingTicket解决方案需要 request 插件支持");
|
|
189
171
|
}
|
|
190
|
-
this.platform = this.otherParams
|
|
172
|
+
this.platform = (_a = this.otherParams) == null ? void 0 : _a.platform;
|
|
191
173
|
await this.configureIdGeneratorFromOpenData();
|
|
174
|
+
console.log("[BookingTicket] 初始化完成");
|
|
192
175
|
}
|
|
193
176
|
getBookingTicketBusinessCode() {
|
|
194
|
-
|
|
195
|
-
|
|
177
|
+
var _a, _b;
|
|
178
|
+
const businessCode = ((_a = this.otherParams) == null ? void 0 : _a.businessCode) ?? ((_b = this.otherParams) == null ? void 0 : _b.business_code);
|
|
179
|
+
if (businessCode === void 0 || businessCode === null)
|
|
180
|
+
return null;
|
|
196
181
|
const normalized = String(businessCode).trim();
|
|
197
182
|
return normalized || null;
|
|
198
183
|
}
|
|
199
184
|
getIdGeneratorPlugin() {
|
|
200
|
-
|
|
201
|
-
const
|
|
202
|
-
|
|
185
|
+
var _a, _b;
|
|
186
|
+
const appPlugin = this.core.getPlugin("app");
|
|
187
|
+
const app = (_a = appPlugin == null ? void 0 : appPlugin.getApp) == null ? void 0 : _a.call(appPlugin);
|
|
188
|
+
return ((_b = app == null ? void 0 : app.getPlugin) == null ? void 0 : _b.call(app, "idGenerator")) || null;
|
|
203
189
|
}
|
|
204
190
|
async loadOpenDataConfig() {
|
|
205
|
-
if (!this.store.openData)
|
|
191
|
+
if (!this.store.openData)
|
|
192
|
+
throw new Error("openData 模块未初始化");
|
|
206
193
|
const businessCode = this.getBookingTicketBusinessCode();
|
|
207
194
|
if (!businessCode) {
|
|
208
|
-
console.warn(
|
|
195
|
+
console.warn("[BookingTicket] businessCode 缺失,跳过 OpenData 配置加载,当前 module name: ", this.name);
|
|
209
196
|
return null;
|
|
210
197
|
}
|
|
211
198
|
const lastFetchedAt = this.store.openData.getLastFetchedAt();
|
|
@@ -214,10 +201,11 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
214
201
|
this.otherParams.openData = cachedData;
|
|
215
202
|
return cachedData;
|
|
216
203
|
}
|
|
217
|
-
if (this.loadOpenDataConfigInFlight)
|
|
204
|
+
if (this.loadOpenDataConfigInFlight)
|
|
205
|
+
return await this.loadOpenDataConfigInFlight;
|
|
218
206
|
const channel = this.getSubmitOrderSalesChannel();
|
|
219
207
|
this.loadOpenDataConfigInFlight = this.store.openData.fetchOpenData({
|
|
220
|
-
scope:
|
|
208
|
+
scope: "board",
|
|
221
209
|
target: `${businessCode}+${channel}`,
|
|
222
210
|
// target: `dine_in+pos`,
|
|
223
211
|
section_code: [...OPEN_DATA_SECTION_CODES]
|
|
@@ -231,44 +219,54 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
231
219
|
}
|
|
232
220
|
}
|
|
233
221
|
async getOpenData() {
|
|
234
|
-
|
|
222
|
+
var _a;
|
|
223
|
+
return (_a = this.store.openData) == null ? void 0 : _a.getOpenData();
|
|
235
224
|
}
|
|
236
225
|
async getShortNumberOrDeviceId() {
|
|
237
|
-
const getAsyncIotDeviceInfo = this.getAppData(
|
|
226
|
+
const getAsyncIotDeviceInfo = this.getAppData("async_iot_device_info");
|
|
238
227
|
if (getAsyncIotDeviceInfo) {
|
|
239
|
-
const res = await getAsyncIotDeviceInfo
|
|
240
|
-
if (res
|
|
241
|
-
return res
|
|
228
|
+
const res = await (getAsyncIotDeviceInfo == null ? void 0 : getAsyncIotDeviceInfo());
|
|
229
|
+
if (res == null ? void 0 : res.short_number) {
|
|
230
|
+
return res == null ? void 0 : res.short_number;
|
|
242
231
|
}
|
|
243
232
|
}
|
|
244
|
-
return String(this.getAppData(
|
|
233
|
+
return String(this.getAppData("device_id") || 0).slice(-2);
|
|
245
234
|
}
|
|
246
235
|
async configureIdGeneratorFromOpenData() {
|
|
247
236
|
let openDataConfig = null;
|
|
248
237
|
try {
|
|
249
238
|
openDataConfig = await this.loadOpenDataConfig();
|
|
250
239
|
} catch (error) {
|
|
251
|
-
console.warn(
|
|
240
|
+
console.warn("[BookingTicket] OpenData 配置加载失败,跳过 idGenerator 配置", error);
|
|
252
241
|
return;
|
|
253
242
|
}
|
|
254
|
-
|
|
255
|
-
// if (!openDataConfig) return;
|
|
256
|
-
|
|
257
243
|
const idGenerator = this.getIdGeneratorPlugin();
|
|
258
|
-
if (!idGenerator
|
|
259
|
-
console.warn(
|
|
244
|
+
if (!(idGenerator == null ? void 0 : idGenerator.configure)) {
|
|
245
|
+
console.warn("[BookingTicket] idGenerator 插件不可用,跳过配置");
|
|
260
246
|
return;
|
|
261
247
|
}
|
|
262
|
-
const receiptSequenceLength = this.normalizePositiveInteger(
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
const
|
|
267
|
-
|
|
248
|
+
const receiptSequenceLength = this.normalizePositiveInteger(
|
|
249
|
+
openDataConfig == null ? void 0 : openDataConfig["sale.short_number_digits"],
|
|
250
|
+
5
|
|
251
|
+
);
|
|
252
|
+
const receiptSequenceStart = this.normalizePositiveInteger(
|
|
253
|
+
openDataConfig == null ? void 0 : openDataConfig["sale.short_number_start_number"],
|
|
254
|
+
1
|
|
255
|
+
);
|
|
256
|
+
const prefix = this.normalizeIdPrefix(
|
|
257
|
+
openDataConfig == null ? void 0 : openDataConfig["sale.short_number_prefix"],
|
|
258
|
+
""
|
|
259
|
+
);
|
|
260
|
+
const shopOrderPrefix = this.normalizeIdPrefix(
|
|
261
|
+
openDataConfig == null ? void 0 : openDataConfig["sale.sale_number_prefix"],
|
|
262
|
+
""
|
|
263
|
+
);
|
|
264
|
+
const resetReceiptSequenceDaily = typeof (openDataConfig == null ? void 0 : openDataConfig["sale.short_number_daily_reset"]) === "boolean" ? openDataConfig == null ? void 0 : openDataConfig["sale.short_number_daily_reset"] : false;
|
|
265
|
+
const operatingDayBoundary = this.getAppData("operating_day_boundary");
|
|
268
266
|
const deviceId = await this.getShortNumberOrDeviceId();
|
|
269
267
|
const businessCode = this.getBookingTicketBusinessCode();
|
|
270
268
|
if (!businessCode) {
|
|
271
|
-
console.warn(
|
|
269
|
+
console.warn("[BookingTicket] businessCode 缺失,跳过 idGenerator 配置");
|
|
272
270
|
return;
|
|
273
271
|
}
|
|
274
272
|
try {
|
|
@@ -287,20 +285,21 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
287
285
|
}
|
|
288
286
|
});
|
|
289
287
|
} catch (error) {
|
|
290
|
-
console.warn(
|
|
288
|
+
console.warn("[BookingTicket] idGenerator 配置失败", error);
|
|
291
289
|
}
|
|
292
290
|
}
|
|
293
291
|
normalizePositiveInteger(value, fallback) {
|
|
294
292
|
const numeric = Number(value);
|
|
295
|
-
if (!Number.isInteger(numeric) || numeric <= 0)
|
|
293
|
+
if (!Number.isInteger(numeric) || numeric <= 0)
|
|
294
|
+
return fallback;
|
|
296
295
|
return numeric;
|
|
297
296
|
}
|
|
298
297
|
normalizeIdPrefix(value, fallback) {
|
|
299
|
-
if (value ===
|
|
298
|
+
if (value === void 0 || value === null)
|
|
299
|
+
return fallback;
|
|
300
300
|
const normalized = String(value).trim().toUpperCase();
|
|
301
301
|
return normalized || fallback;
|
|
302
302
|
}
|
|
303
|
-
|
|
304
303
|
/**
|
|
305
304
|
* 加载销售详情,并在父类基础上把 customer 信息装配到 CustomerModule。
|
|
306
305
|
*
|
|
@@ -311,55 +310,48 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
311
310
|
async loadSalesDetail(orderIdOrParams) {
|
|
312
311
|
const sales = await super.loadSalesDetail(orderIdOrParams);
|
|
313
312
|
const customerModule = this.store.customer;
|
|
314
|
-
const detailCustomer = sales
|
|
313
|
+
const detailCustomer = sales == null ? void 0 : sales.customer;
|
|
315
314
|
const orderCustomerSnapshot = this.store.order.getOrderCustomerSnapshot();
|
|
316
|
-
const protocolCustomerId = sales
|
|
317
|
-
const protocolCustomer = protocolCustomerId !==
|
|
315
|
+
const protocolCustomerId = sales == null ? void 0 : sales.customer_id;
|
|
316
|
+
const protocolCustomer = protocolCustomerId !== void 0 && protocolCustomerId !== null ? {
|
|
318
317
|
id: protocolCustomerId,
|
|
319
|
-
name: String(sales
|
|
320
|
-
phone: sales
|
|
321
|
-
email: sales
|
|
322
|
-
country_calling_code: sales
|
|
318
|
+
name: String((sales == null ? void 0 : sales.customer_name) || ""),
|
|
319
|
+
phone: sales == null ? void 0 : sales.phone,
|
|
320
|
+
email: sales == null ? void 0 : sales.email,
|
|
321
|
+
country_calling_code: sales == null ? void 0 : sales.country_calling_code
|
|
323
322
|
} : null;
|
|
324
323
|
const selectedCustomer = detailCustomer ?? orderCustomerSnapshot ?? protocolCustomer;
|
|
325
324
|
if (customerModule && selectedCustomer) {
|
|
326
|
-
const {
|
|
327
|
-
|
|
328
|
-
...detailCustomerRest
|
|
329
|
-
} = selectedCustomer ?? {};
|
|
330
|
-
const rawId = detailCustomerId ?? '';
|
|
325
|
+
const { id: detailCustomerId, ...detailCustomerRest } = selectedCustomer ?? {};
|
|
326
|
+
const rawId = detailCustomerId ?? "";
|
|
331
327
|
const customer = {
|
|
332
328
|
...detailCustomerRest,
|
|
333
|
-
id: rawId == null ?
|
|
334
|
-
name: selectedCustomer
|
|
335
|
-
phone: selectedCustomer
|
|
336
|
-
email: selectedCustomer
|
|
337
|
-
country_calling_code: selectedCustomer
|
|
329
|
+
id: rawId == null ? "" : rawId,
|
|
330
|
+
name: (selectedCustomer == null ? void 0 : selectedCustomer.name) ?? "",
|
|
331
|
+
phone: selectedCustomer == null ? void 0 : selectedCustomer.phone,
|
|
332
|
+
email: selectedCustomer == null ? void 0 : selectedCustomer.email,
|
|
333
|
+
country_calling_code: selectedCustomer == null ? void 0 : selectedCustomer.country_calling_code
|
|
338
334
|
};
|
|
339
335
|
customerModule.setSelectedCustomer(customer);
|
|
340
336
|
this.setOrderCustomer(customer);
|
|
341
|
-
// await this.store.order.saveDraft();
|
|
342
337
|
}
|
|
343
338
|
return sales;
|
|
344
339
|
}
|
|
345
340
|
async scanPromotionCode(code, customerId) {
|
|
346
|
-
if (!this.store.order)
|
|
341
|
+
if (!this.store.order)
|
|
342
|
+
throw new Error("order 模块未初始化");
|
|
347
343
|
const raw = await this.store.order.scanCode(code, customerId);
|
|
348
344
|
const scannedList = raw.scannedDiscountList || [];
|
|
349
345
|
const extractedCustomerId = this.getDiscountCustomerId(scannedList);
|
|
350
346
|
const hasOrderCustomer = Boolean(this.store.order.getOrderCustomer());
|
|
351
|
-
|
|
352
|
-
// 缺 Holder 等场景 isAvailable=false,但仍需把 Pass 归属客户带入订单,供 Holder 弹窗使用。
|
|
353
347
|
if (!hasOrderCustomer && extractedCustomerId) {
|
|
354
348
|
await this.hydrateOrderCustomerFromScanDiscounts(scannedList);
|
|
355
349
|
}
|
|
356
350
|
if (raw.isAvailable) {
|
|
357
|
-
await this.store.order.recalculateSummary({
|
|
358
|
-
createIfMissing: true
|
|
359
|
-
});
|
|
351
|
+
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
360
352
|
this.store.order.persistTempOrder();
|
|
361
353
|
const tempOrder = this.store.order.ensureTempOrder();
|
|
362
|
-
await this.effectsEmit(
|
|
354
|
+
await this.effectsEmit("onDiscountApplied", {
|
|
363
355
|
productList: tempOrder.products || [],
|
|
364
356
|
discountList: this.store.order.getDiscountList(),
|
|
365
357
|
selectedDiscountList: tempOrder.discount_list || [],
|
|
@@ -375,11 +367,14 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
375
367
|
}
|
|
376
368
|
async hydrateOrderCustomerFromScanDiscounts(discounts) {
|
|
377
369
|
const currentOrderCustomer = this.store.order.getOrderCustomer();
|
|
378
|
-
if (currentOrderCustomer)
|
|
370
|
+
if (currentOrderCustomer)
|
|
371
|
+
return;
|
|
379
372
|
const customerId = this.getDiscountCustomerId(discounts);
|
|
380
|
-
if (!customerId)
|
|
373
|
+
if (!customerId)
|
|
374
|
+
return;
|
|
381
375
|
const customer = await this.resolveCustomerByDiscountCustomerId(customerId);
|
|
382
|
-
if (!customer)
|
|
376
|
+
if (!customer)
|
|
377
|
+
return;
|
|
383
378
|
this.store.customer.setSelectedCustomer(customer);
|
|
384
379
|
this.setOrderCustomer(customer);
|
|
385
380
|
}
|
|
@@ -393,6 +388,7 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
393
388
|
return null;
|
|
394
389
|
}
|
|
395
390
|
async resolveCustomerByDiscountCustomerId(customerId) {
|
|
391
|
+
var _a;
|
|
396
392
|
const localCustomers = this.store.customer.getCustomers();
|
|
397
393
|
const localCustomer = this.findCustomerById(localCustomers, customerId);
|
|
398
394
|
const normalizedLocalCustomer = localCustomer ? this.normalizeCustomer(localCustomer) : null;
|
|
@@ -404,11 +400,11 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
404
400
|
skip: 1,
|
|
405
401
|
num: 1
|
|
406
402
|
});
|
|
407
|
-
const remoteCustomer = this.findCustomerById(result
|
|
403
|
+
const remoteCustomer = this.findCustomerById((result == null ? void 0 : result.list) || [], customerId) || ((_a = result == null ? void 0 : result.list) == null ? void 0 : _a[0]) || null;
|
|
408
404
|
return remoteCustomer ? this.normalizeCustomer(remoteCustomer) : null;
|
|
409
405
|
}
|
|
410
406
|
findCustomerById(customers = [], customerId) {
|
|
411
|
-
return customers.find(customer => {
|
|
407
|
+
return customers.find((customer) => {
|
|
412
408
|
const rawId = this.getRawCustomerId(customer);
|
|
413
409
|
return rawId !== null && String(rawId) === String(customerId);
|
|
414
410
|
}) || null;
|
|
@@ -416,14 +412,14 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
416
412
|
normalizeCustomer(customer) {
|
|
417
413
|
const raw = customer;
|
|
418
414
|
const rawId = this.getRawCustomerId(customer);
|
|
419
|
-
const name = customer.name || raw.display_name || raw.nickname || raw.customer_name || [raw.first_name, raw.last_name].filter(Boolean).join(
|
|
415
|
+
const name = customer.name || raw.display_name || raw.nickname || raw.customer_name || [raw.first_name, raw.last_name].filter(Boolean).join(" ") || "";
|
|
420
416
|
return {
|
|
421
417
|
...customer,
|
|
422
418
|
id: rawId ?? customer.id,
|
|
423
419
|
name,
|
|
424
|
-
phone: customer.phone ?? raw.phone ?? raw.mobile ??
|
|
425
|
-
email: customer.email ?? raw.email ??
|
|
426
|
-
country_calling_code: customer.country_calling_code ?? raw.country_calling_code ??
|
|
420
|
+
phone: customer.phone ?? raw.phone ?? raw.mobile ?? "",
|
|
421
|
+
email: customer.email ?? raw.email ?? "",
|
|
422
|
+
country_calling_code: customer.country_calling_code ?? raw.country_calling_code ?? ""
|
|
427
423
|
};
|
|
428
424
|
}
|
|
429
425
|
getRawCustomerId(customer) {
|
|
@@ -433,7 +429,6 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
433
429
|
hasUsableCustomerDetails(customer) {
|
|
434
430
|
return !!(customer.name || customer.phone || customer.email || customer.display_name || customer.customer_name);
|
|
435
431
|
}
|
|
436
|
-
|
|
437
432
|
/**
|
|
438
433
|
* 更新当前预约的 appointment_status。
|
|
439
434
|
*
|
|
@@ -449,36 +444,39 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
449
444
|
* @returns 接口返回的 data
|
|
450
445
|
*/
|
|
451
446
|
async setBookingStatus(status) {
|
|
452
|
-
|
|
447
|
+
var _a, _b;
|
|
448
|
+
const tempOrder = (_b = (_a = this.store.order) == null ? void 0 : _a.getTempOrder) == null ? void 0 : _b.call(_a);
|
|
453
449
|
if (!tempOrder) {
|
|
454
|
-
throw new Error(
|
|
450
|
+
throw new Error("setBookingStatus: tempOrder 未加载");
|
|
455
451
|
}
|
|
456
452
|
const orderId = tempOrder.order_id;
|
|
457
|
-
if (orderId ===
|
|
458
|
-
throw new Error(
|
|
453
|
+
if (orderId === void 0 || orderId === null) {
|
|
454
|
+
throw new Error("setBookingStatus: tempOrder.order_id 缺失");
|
|
459
455
|
}
|
|
460
|
-
const scheduleId = (0,
|
|
456
|
+
const scheduleId = (0, import_bookingStatus.resolveScheduleId)(tempOrder);
|
|
461
457
|
if (scheduleId === null) {
|
|
462
|
-
throw new Error(
|
|
458
|
+
throw new Error(
|
|
459
|
+
"setBookingStatus: 无法解析 schedule id(metadata 与 root booking 均缺失)"
|
|
460
|
+
);
|
|
463
461
|
}
|
|
464
462
|
const bookings = Array.isArray(tempOrder.bookings) ? tempOrder.bookings : [];
|
|
465
|
-
const previous = (0,
|
|
463
|
+
const previous = (0, import_bookingStatus.applyBookingsStatus)(bookings, status);
|
|
466
464
|
try {
|
|
467
|
-
const res = await this.request.put(
|
|
468
|
-
|
|
469
|
-
|
|
465
|
+
const res = await this.request.put(
|
|
466
|
+
`/schedule/booking/appointment-status/${scheduleId}`,
|
|
467
|
+
{ appointment_status: status }
|
|
468
|
+
);
|
|
470
469
|
await this.refreshSalesDetail();
|
|
471
470
|
this.core.effects.emit(`${this.name}:onBookingStatusChange`, {
|
|
472
471
|
orderId,
|
|
473
472
|
status
|
|
474
473
|
});
|
|
475
|
-
return res
|
|
474
|
+
return (res == null ? void 0 : res.data) ?? res;
|
|
476
475
|
} catch (error) {
|
|
477
|
-
(0,
|
|
476
|
+
(0, import_bookingStatus.restoreBookingsStatus)(bookings, previous);
|
|
478
477
|
throw error;
|
|
479
478
|
}
|
|
480
479
|
}
|
|
481
|
-
|
|
482
480
|
/**
|
|
483
481
|
* 子预约状态机转移(POST /schedule/booking-transition/{schedule_event_id})。
|
|
484
482
|
*
|
|
@@ -500,31 +498,30 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
500
498
|
* });
|
|
501
499
|
*/
|
|
502
500
|
async transitionChildBooking(params) {
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
if (schedule_event_id === undefined || schedule_event_id === null || schedule_event_id === '') {
|
|
508
|
-
throw new Error('transitionChildBooking: schedule_event_id 不能为空');
|
|
501
|
+
var _a, _b;
|
|
502
|
+
const { schedule_event_id, action } = params;
|
|
503
|
+
if (schedule_event_id === void 0 || schedule_event_id === null || schedule_event_id === "") {
|
|
504
|
+
throw new Error("transitionChildBooking: schedule_event_id 不能为空");
|
|
509
505
|
}
|
|
510
506
|
if (!action) {
|
|
511
|
-
throw new Error(
|
|
507
|
+
throw new Error("transitionChildBooking: action 不能为空");
|
|
512
508
|
}
|
|
513
|
-
const tempOrder = this.store.order
|
|
509
|
+
const tempOrder = (_b = (_a = this.store.order) == null ? void 0 : _a.getTempOrder) == null ? void 0 : _b.call(_a);
|
|
514
510
|
if (!tempOrder) {
|
|
515
|
-
throw new Error(
|
|
511
|
+
throw new Error("transitionChildBooking: tempOrder 未加载");
|
|
516
512
|
}
|
|
517
513
|
const orderId = tempOrder.order_id;
|
|
518
|
-
if (orderId ===
|
|
519
|
-
throw new Error(
|
|
514
|
+
if (orderId === void 0 || orderId === null) {
|
|
515
|
+
throw new Error("transitionChildBooking: tempOrder.order_id 缺失");
|
|
520
516
|
}
|
|
521
517
|
const bookings = Array.isArray(tempOrder.bookings) ? tempOrder.bookings : [];
|
|
522
|
-
const targetStatus = (0,
|
|
523
|
-
const previous = targetStatus !== null ? (0,
|
|
518
|
+
const targetStatus = (0, import_bookingStatus.resolveStatusAfterTransition)(action);
|
|
519
|
+
const previous = targetStatus !== null ? (0, import_bookingStatus.applyChildBookingStatus)(bookings, schedule_event_id, targetStatus) : void 0;
|
|
524
520
|
try {
|
|
525
|
-
const res = await this.request.post(
|
|
526
|
-
|
|
527
|
-
|
|
521
|
+
const res = await this.request.post(
|
|
522
|
+
`/schedule/booking-transition/${schedule_event_id}`,
|
|
523
|
+
{ action }
|
|
524
|
+
);
|
|
528
525
|
await this.refreshSalesDetail();
|
|
529
526
|
this.core.effects.emit(`${this.name}:onChildBookingStatusChange`, {
|
|
530
527
|
orderId,
|
|
@@ -532,15 +529,14 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
532
529
|
action,
|
|
533
530
|
status: targetStatus
|
|
534
531
|
});
|
|
535
|
-
return res
|
|
532
|
+
return (res == null ? void 0 : res.data) ?? res;
|
|
536
533
|
} catch (error) {
|
|
537
|
-
if (previous !==
|
|
538
|
-
(0,
|
|
534
|
+
if (previous !== void 0) {
|
|
535
|
+
(0, import_bookingStatus.restoreChildBookingStatus)(bookings, schedule_event_id, previous);
|
|
539
536
|
}
|
|
540
537
|
throw error;
|
|
541
538
|
}
|
|
542
539
|
}
|
|
543
|
-
|
|
544
540
|
/**
|
|
545
541
|
* 基于当前 tempOrder.order_id 强制从远端重新拉取销售详情。
|
|
546
542
|
*
|
|
@@ -552,44 +548,36 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
552
548
|
* @returns loadSalesDetail 的返回值
|
|
553
549
|
*/
|
|
554
550
|
async refreshSalesDetail(params = {}) {
|
|
555
|
-
|
|
551
|
+
var _a, _b;
|
|
552
|
+
const tempOrder = (_b = (_a = this.store.order) == null ? void 0 : _a.getTempOrder) == null ? void 0 : _b.call(_a);
|
|
556
553
|
if (!tempOrder) {
|
|
557
|
-
throw new Error(
|
|
554
|
+
throw new Error("refreshSalesDetail: tempOrder 未加载");
|
|
558
555
|
}
|
|
559
556
|
debugger;
|
|
560
557
|
const orderId = tempOrder.order_id || tempOrder.external_sale_number;
|
|
561
|
-
if (orderId ===
|
|
558
|
+
if (orderId === void 0 || orderId === null) {
|
|
562
559
|
return {};
|
|
563
560
|
}
|
|
564
561
|
return this.loadSalesDetail({
|
|
565
|
-
orderId
|
|
562
|
+
orderId,
|
|
566
563
|
// merge: true
|
|
567
564
|
forceRemote: params.forceRemote
|
|
568
565
|
});
|
|
569
566
|
}
|
|
570
|
-
|
|
571
567
|
/**
|
|
572
568
|
* 获取商品列表
|
|
573
569
|
* @param params 包含 schedule_date 的参数
|
|
574
570
|
* @returns 商品列表
|
|
575
571
|
*/
|
|
576
572
|
async loadProducts(params = {}, options) {
|
|
577
|
-
const {
|
|
578
|
-
|
|
579
|
-
customer_id,
|
|
580
|
-
menu_list_ids,
|
|
581
|
-
schedule_datetime
|
|
582
|
-
} = params;
|
|
583
|
-
|
|
584
|
-
// 优先写入 schedule_datetime(含时分),供加购 presetStartTime 与 TimeBar 对齐;
|
|
585
|
-
// requiresDetail 弹窗仍通过 formatBookingDateForUI 只取日历日 YYYY-MM-DD。
|
|
586
|
-
const bookingDate = schedule_datetime || schedule_date || '';
|
|
573
|
+
const { schedule_date, customer_id, menu_list_ids, schedule_datetime } = params;
|
|
574
|
+
const bookingDate = schedule_datetime || schedule_date || "";
|
|
587
575
|
if (bookingDate) {
|
|
588
576
|
this.setBookingDate(bookingDate);
|
|
589
577
|
}
|
|
590
578
|
try {
|
|
591
579
|
const result = await this.store.products.loadProducts({
|
|
592
|
-
with_count: [
|
|
580
|
+
with_count: ["bundleGroup", "optionGroup"],
|
|
593
581
|
with_schedule: 1,
|
|
594
582
|
...params,
|
|
595
583
|
cacheId: this.cacheId
|
|
@@ -598,11 +586,10 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
598
586
|
this.core.effects.emit(`${this.name}:onProductsLoaded`, result);
|
|
599
587
|
return result;
|
|
600
588
|
} catch (error) {
|
|
601
|
-
console.error(
|
|
589
|
+
console.error("Failed to load products:", error);
|
|
602
590
|
throw error;
|
|
603
591
|
}
|
|
604
592
|
}
|
|
605
|
-
|
|
606
593
|
/**
|
|
607
594
|
* 获取加时商品列表。
|
|
608
595
|
*
|
|
@@ -617,7 +604,6 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
617
604
|
this.addTimeProductsCatalog = Array.isArray(result) ? [...result] : [];
|
|
618
605
|
return result;
|
|
619
606
|
}
|
|
620
|
-
|
|
621
607
|
/**
|
|
622
608
|
* 只读查询单商品详情:走 ProductList 报价查询,但不写 productCatalog、
|
|
623
609
|
* 不 emit onProductsLoaded、不修改 BookingDate。
|
|
@@ -633,57 +619,52 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
633
619
|
* });
|
|
634
620
|
*/
|
|
635
621
|
async queryProductDetail(params, options) {
|
|
636
|
-
const {
|
|
637
|
-
product_id,
|
|
638
|
-
...queryParams
|
|
639
|
-
} = params;
|
|
622
|
+
const { product_id, ...queryParams } = params;
|
|
640
623
|
try {
|
|
641
624
|
const result = await this.store.products.loadProducts({
|
|
642
|
-
with_count: [
|
|
625
|
+
with_count: ["bundleGroup", "optionGroup"],
|
|
643
626
|
with_schedule: 1,
|
|
644
627
|
...queryParams,
|
|
645
628
|
product_ids: [product_id],
|
|
646
629
|
cacheId: this.cacheId
|
|
647
630
|
}, options);
|
|
648
631
|
const list = Array.isArray(result) ? result : [];
|
|
649
|
-
return list.find(
|
|
632
|
+
return list.find(
|
|
633
|
+
(product) => Number(product.id) === Number(product_id)
|
|
634
|
+
);
|
|
650
635
|
} catch (error) {
|
|
651
|
-
console.error(
|
|
636
|
+
console.error("Failed to query product detail:", error);
|
|
652
637
|
throw error;
|
|
653
638
|
}
|
|
654
639
|
}
|
|
655
|
-
|
|
656
640
|
/**
|
|
657
641
|
* 按预约时间加载单个商品详情。
|
|
658
642
|
* 价格仍由 server products 的报价单桥接统一计算,避免 solution 实例重复请求报价单。
|
|
659
643
|
*/
|
|
660
644
|
async loadProductDetail(params, options) {
|
|
661
|
-
const {
|
|
662
|
-
product_id,
|
|
663
|
-
...queryParams
|
|
664
|
-
} = params;
|
|
645
|
+
const { product_id, ...queryParams } = params;
|
|
665
646
|
const products = await this.loadProducts({
|
|
666
647
|
...queryParams,
|
|
667
648
|
product_ids: [product_id]
|
|
668
649
|
}, options);
|
|
669
|
-
return products.find(
|
|
650
|
+
return products.find(
|
|
651
|
+
(product) => Number(product.id) === Number(product_id)
|
|
652
|
+
);
|
|
670
653
|
}
|
|
671
|
-
|
|
672
654
|
/**
|
|
673
655
|
* 取消商品查询订阅
|
|
674
656
|
* @param subscriberId 订阅时传入的 subscriberId
|
|
675
657
|
*/
|
|
676
658
|
unsubscribeProductQuery(subscriberId) {
|
|
677
|
-
|
|
659
|
+
var _a;
|
|
660
|
+
(_a = this.core.server) == null ? void 0 : _a.removeProductQuerySubscriber(subscriberId);
|
|
678
661
|
}
|
|
679
|
-
|
|
680
662
|
/**
|
|
681
663
|
* 初始化外设扫码结果监听
|
|
682
664
|
*/
|
|
683
665
|
initPeripheralsListener() {
|
|
684
666
|
this.scan.initPeripheralsListener();
|
|
685
667
|
}
|
|
686
|
-
|
|
687
668
|
/**
|
|
688
669
|
* 获取商品列表(不加载到模块中)
|
|
689
670
|
* @returns 商品列表
|
|
@@ -691,7 +672,6 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
691
672
|
async getProducts() {
|
|
692
673
|
return this.store.products.getProducts();
|
|
693
674
|
}
|
|
694
|
-
|
|
695
675
|
/**
|
|
696
676
|
* 获取当前已加载的商品池 UI 视图。
|
|
697
677
|
*
|
|
@@ -703,38 +683,36 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
703
683
|
products: [...this.productCatalog]
|
|
704
684
|
};
|
|
705
685
|
}
|
|
706
|
-
|
|
707
686
|
/**
|
|
708
687
|
* 获取购物车 UI 视图。
|
|
709
688
|
*
|
|
710
689
|
* tempOrder 仍是 checkout 协议对象;商品行直接透传 products,bookings 附带关联商品。
|
|
711
690
|
*/
|
|
712
691
|
getCart() {
|
|
713
|
-
|
|
692
|
+
var _a, _b;
|
|
693
|
+
const tempOrder = ((_a = this.store.order) == null ? void 0 : _a.getTempOrder()) ?? null;
|
|
714
694
|
const salesDetail = this.getSalesOrder();
|
|
715
|
-
const bookings = salesDetail
|
|
695
|
+
const bookings = (salesDetail == null ? void 0 : salesDetail.bookings) ?? ((tempOrder == null ? void 0 : tempOrder.bookings) || []);
|
|
716
696
|
let operatingDayBoundary;
|
|
717
697
|
try {
|
|
718
|
-
operatingDayBoundary = this.getAppData(
|
|
698
|
+
operatingDayBoundary = this.getAppData("operating_day_boundary");
|
|
719
699
|
} catch {
|
|
720
|
-
operatingDayBoundary =
|
|
700
|
+
operatingDayBoundary = void 0;
|
|
721
701
|
}
|
|
722
|
-
const shopOpeningHours = operatingDayBoundary
|
|
723
|
-
return (0,
|
|
702
|
+
const shopOpeningHours = (operatingDayBoundary == null ? void 0 : operatingDayBoundary.type) === "start_time" ? "23:59" : operatingDayBoundary == null ? void 0 : operatingDayBoundary.time;
|
|
703
|
+
return (0, import_cartView.buildCartView)((tempOrder == null ? void 0 : tempOrder.products) || [], bookings, {
|
|
724
704
|
addTimeProducts: this.addTimeProductsCatalog,
|
|
725
705
|
bookingConfig: this.getBookingConfig(),
|
|
726
|
-
productsByUid: tempOrder
|
|
706
|
+
productsByUid: (_b = tempOrder == null ? void 0 : tempOrder._extend) == null ? void 0 : _b.productsByUid,
|
|
727
707
|
shopOpeningHours
|
|
728
708
|
});
|
|
729
709
|
}
|
|
730
|
-
|
|
731
710
|
/**
|
|
732
711
|
* 获取当前下单客户(与 OrderModule.tempOrder snapshot 一致)。
|
|
733
712
|
*/
|
|
734
713
|
getCustomer() {
|
|
735
714
|
return this.getOrderCustomerSnapshot();
|
|
736
715
|
}
|
|
737
|
-
|
|
738
716
|
/**
|
|
739
717
|
* 通过 ids 获取商品列表(不加载到模块中)
|
|
740
718
|
* @returns 商品列表
|
|
@@ -742,21 +720,19 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
742
720
|
async getProductByIds(ids) {
|
|
743
721
|
return this.store.products.getProductByIds(ids);
|
|
744
722
|
}
|
|
745
|
-
|
|
746
723
|
/**
|
|
747
724
|
* 获取日程时间段点
|
|
748
725
|
* @param params 参数
|
|
749
726
|
* @returns 日程时间段点
|
|
750
727
|
*/
|
|
751
728
|
async getScheduleTimePoints(params) {
|
|
752
|
-
const result = await this.request.post(
|
|
729
|
+
const result = await this.request.post("/menu/schedule-time-points", {
|
|
753
730
|
menu_list_ids: params.menu_list_ids
|
|
754
731
|
}, {
|
|
755
732
|
osServer: true
|
|
756
733
|
});
|
|
757
734
|
return result.data || [];
|
|
758
735
|
}
|
|
759
|
-
|
|
760
736
|
/**
|
|
761
737
|
* 获取客户列表
|
|
762
738
|
* @param params 查询参数
|
|
@@ -767,11 +743,10 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
767
743
|
const result = await this.store.customer.getCustomerList(params);
|
|
768
744
|
return result;
|
|
769
745
|
} catch (error) {
|
|
770
|
-
console.error(
|
|
746
|
+
console.error("Failed to get customer list:", error);
|
|
771
747
|
throw error;
|
|
772
748
|
}
|
|
773
749
|
}
|
|
774
|
-
|
|
775
750
|
/**
|
|
776
751
|
* 设置活跃客户
|
|
777
752
|
* @param customer 客户信息
|
|
@@ -782,7 +757,6 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
782
757
|
customer
|
|
783
758
|
});
|
|
784
759
|
}
|
|
785
|
-
|
|
786
760
|
/**
|
|
787
761
|
* 获取当前活跃客户
|
|
788
762
|
* @returns 当前活跃客户
|
|
@@ -790,7 +764,6 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
790
764
|
getActiveCustomer() {
|
|
791
765
|
return this.store.customer.getSelectedCustomer();
|
|
792
766
|
}
|
|
793
|
-
|
|
794
767
|
/**
|
|
795
768
|
* 根据ID设置选中的客户
|
|
796
769
|
* @param customerId 客户ID
|
|
@@ -804,7 +777,6 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
804
777
|
});
|
|
805
778
|
}
|
|
806
779
|
}
|
|
807
|
-
|
|
808
780
|
/**
|
|
809
781
|
* 获取所有客户
|
|
810
782
|
* @returns 客户列表
|
|
@@ -812,7 +784,6 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
812
784
|
getCustomers() {
|
|
813
785
|
return this.store.customer.getCustomers();
|
|
814
786
|
}
|
|
815
|
-
|
|
816
787
|
/**
|
|
817
788
|
* 根据ID获取客户
|
|
818
789
|
* @param customerId 客户ID
|
|
@@ -821,14 +792,12 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
821
792
|
getCustomerById(customerId) {
|
|
822
793
|
return this.store.customer.getCustomerById(customerId);
|
|
823
794
|
}
|
|
824
|
-
|
|
825
795
|
/**
|
|
826
796
|
* 清空客户列表
|
|
827
797
|
*/
|
|
828
798
|
clearCustomers() {
|
|
829
799
|
this.store.customer.clearCustomers();
|
|
830
800
|
}
|
|
831
|
-
|
|
832
801
|
/**
|
|
833
802
|
* 添加客户到列表第一位
|
|
834
803
|
* @param customer 要添加的客户信息
|
|
@@ -836,13 +805,11 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
836
805
|
addCustomerToFirst(customer) {
|
|
837
806
|
this.store.customer.addCustomerToFirst(customer);
|
|
838
807
|
}
|
|
839
|
-
|
|
840
808
|
// ─── 下单客户(基于 OrderModule.tempOrder,单一真源)───
|
|
841
809
|
// 与老的 setActiveCustomer/getActiveCustomer 解耦:
|
|
842
810
|
// - 老路:写入 CustomerModule.selectedCustomer(保留兼容,存量调用方不动)
|
|
843
811
|
// - 新路:写入 tempOrder 的 customer 协议字段 + _extend.customerSnapshot
|
|
844
812
|
// 新业务(如 SalesSdk)应优先使用本组方法。
|
|
845
|
-
|
|
846
813
|
/**
|
|
847
814
|
* 设置当前下单客户。
|
|
848
815
|
*
|
|
@@ -855,13 +822,14 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
855
822
|
* 在 BookingTicket 命名空间也 emit 一次,方便上层统一从 Solution 订阅。
|
|
856
823
|
*/
|
|
857
824
|
setOrderCustomer(customer) {
|
|
825
|
+
var _a;
|
|
858
826
|
if (!customer) {
|
|
859
827
|
this.clearOrderCustomer();
|
|
860
828
|
return;
|
|
861
829
|
}
|
|
862
|
-
const previousCustomerId = this.store.order.getOrderCustomer()
|
|
830
|
+
const previousCustomerId = (_a = this.store.order.getOrderCustomer()) == null ? void 0 : _a.customer_id;
|
|
863
831
|
const snapshotBeforeSet = this.store.order.getOrderCustomerSnapshot();
|
|
864
|
-
const patch = (0,
|
|
832
|
+
const patch = (0, import_orderCustomer.formatOrderCustomerPatch)(customer);
|
|
865
833
|
const customerUnchanged = Number(previousCustomerId || 0) === Number(patch.customer_id || 0);
|
|
866
834
|
if (!customerUnchanged) {
|
|
867
835
|
this.discountConfigCacheKey = null;
|
|
@@ -870,67 +838,60 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
870
838
|
this.store.order.setOrderCustomer(patch, customer);
|
|
871
839
|
const snapshotAfterOrderSet = this.store.order.getOrderCustomerSnapshot();
|
|
872
840
|
if (customerUnchanged) {
|
|
873
|
-
// hydrate 后 customer_id 已存在但 _extend.customerSnapshot 仍为空时,
|
|
874
|
-
// 须通知 SalesSdk 刷新 selected(否则会一直停在 onSalesOrderLoaded 时的 null)。
|
|
875
841
|
const snapshotReplenished = !snapshotBeforeSet && Boolean(snapshotAfterOrderSet);
|
|
876
842
|
if (snapshotReplenished) {
|
|
877
|
-
const
|
|
878
|
-
this.core.effects.emit(`${this.name}:onOrderCustomerChange`,
|
|
843
|
+
const next2 = this.buildOrderCustomerPayload();
|
|
844
|
+
this.core.effects.emit(`${this.name}:onOrderCustomerChange`, next2);
|
|
879
845
|
}
|
|
880
846
|
return;
|
|
881
847
|
}
|
|
882
848
|
const next = this.buildOrderCustomerPayload();
|
|
883
849
|
this.core.effects.emit(`${this.name}:onOrderCustomerChange`, next);
|
|
884
850
|
this.refreshDiscountConfigAfterOrderCustomerChange(patch.customer_id);
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
console.error('[BookingTicket] applyPromotion after customer change failed', error);
|
|
851
|
+
void this.store.order.applyPromotion().catch((error) => {
|
|
852
|
+
console.error("[BookingTicket] applyPromotion after customer change failed", error);
|
|
888
853
|
});
|
|
889
854
|
}
|
|
890
|
-
|
|
891
855
|
/**
|
|
892
856
|
* 读取 tempOrder 上的下单客户协议字段;customer_id 缺失时返回 null。
|
|
893
857
|
*/
|
|
894
858
|
getOrderCustomer() {
|
|
895
859
|
return this.store.order.getOrderCustomer();
|
|
896
860
|
}
|
|
897
|
-
|
|
898
861
|
/**
|
|
899
862
|
* 读取 tempOrder._extend.customerSnapshot 中的完整客户对象。
|
|
900
863
|
*/
|
|
901
864
|
getOrderCustomerSnapshot() {
|
|
902
865
|
return this.store.order.getOrderCustomerSnapshot();
|
|
903
866
|
}
|
|
904
|
-
|
|
905
867
|
/**
|
|
906
868
|
* 清空下单客户(协议字段 + snapshot)。
|
|
907
869
|
*/
|
|
908
870
|
clearOrderCustomer() {
|
|
871
|
+
var _a, _b;
|
|
909
872
|
this.store.order.clearOrderCustomer();
|
|
910
873
|
this.discountConfigCacheKey = null;
|
|
911
874
|
this.hasManualDiscountSelection = false;
|
|
912
875
|
const orderStore = this.store.order.store || {};
|
|
913
876
|
const discountModule = orderStore.discount;
|
|
914
|
-
void discountModule
|
|
915
|
-
void discountModule
|
|
877
|
+
void ((_a = discountModule == null ? void 0 : discountModule.setOriginalDiscountList) == null ? void 0 : _a.call(discountModule, []));
|
|
878
|
+
void ((_b = discountModule == null ? void 0 : discountModule.setDiscountList) == null ? void 0 : _b.call(discountModule, []));
|
|
916
879
|
this.store.order.applyDiscount();
|
|
917
|
-
void this.store.order.recalculateSummary({
|
|
918
|
-
|
|
919
|
-
}).then(() => {
|
|
880
|
+
void this.store.order.recalculateSummary({ createIfMissing: true }).then(() => {
|
|
881
|
+
var _a2;
|
|
920
882
|
const tempOrder = this.store.order.ensureTempOrder();
|
|
921
883
|
this.store.order.persistTempOrder();
|
|
922
|
-
return this.effectsEmit(
|
|
884
|
+
return this.effectsEmit("onDiscountApplied", {
|
|
923
885
|
productList: tempOrder.products || [],
|
|
924
|
-
discountList: discountModule
|
|
886
|
+
discountList: ((_a2 = discountModule == null ? void 0 : discountModule.getDiscountList) == null ? void 0 : _a2.call(discountModule)) || [],
|
|
925
887
|
selectedDiscountList: tempOrder.discount_list || [],
|
|
926
888
|
tempOrder
|
|
927
889
|
});
|
|
928
|
-
}).catch(error => {
|
|
929
|
-
console.error(
|
|
890
|
+
}).catch((error) => {
|
|
891
|
+
console.error("Failed to recalculate summary after clearing customer:", error);
|
|
930
892
|
});
|
|
931
893
|
this.core.effects.emit(`${this.name}:onOrderCustomerChange`, null);
|
|
932
894
|
}
|
|
933
|
-
|
|
934
895
|
/**
|
|
935
896
|
* 重置 tempOrder,并同步清空下单客户运行态。
|
|
936
897
|
*
|
|
@@ -941,50 +902,50 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
941
902
|
* 因此在 super.restoreOrder 之后显式清客户,保证 SalesSdk / ticketBooking 订阅方与 tempOrder 一致。
|
|
942
903
|
*/
|
|
943
904
|
async restoreOrder() {
|
|
905
|
+
var _a;
|
|
944
906
|
const tempOrder = await super.restoreOrder();
|
|
945
907
|
this.clearOrderCustomer();
|
|
946
|
-
this.store.customer
|
|
908
|
+
(_a = this.store.customer) == null ? void 0 : _a.setSelectedCustomer(null);
|
|
947
909
|
return tempOrder;
|
|
948
910
|
}
|
|
949
|
-
|
|
950
911
|
/** 内部:基于 OrderModule 当前状态构造一份 OrderCustomerChangePayload。 */
|
|
951
912
|
buildOrderCustomerPayload() {
|
|
952
913
|
const patch = this.store.order.getOrderCustomer();
|
|
953
|
-
if (!patch)
|
|
914
|
+
if (!patch)
|
|
915
|
+
return null;
|
|
954
916
|
return {
|
|
955
917
|
patch,
|
|
956
918
|
snapshot: this.store.order.getOrderCustomerSnapshot()
|
|
957
919
|
};
|
|
958
920
|
}
|
|
959
921
|
refreshDiscountConfigAfterOrderCustomerChange(customerId) {
|
|
960
|
-
if (!customerId || customerId === 1)
|
|
922
|
+
if (!customerId || customerId === 1)
|
|
923
|
+
return;
|
|
961
924
|
if (this.orderCustomerDiscountRefreshInFlight && this.orderCustomerDiscountRefreshCustomerId === customerId) {
|
|
962
925
|
return;
|
|
963
926
|
}
|
|
964
927
|
const previousRefresh = this.orderCustomerDiscountRefreshInFlight;
|
|
965
928
|
const refreshTask = (async () => {
|
|
966
929
|
if (previousRefresh) {
|
|
967
|
-
await previousRefresh.catch(() =>
|
|
930
|
+
await previousRefresh.catch(() => void 0);
|
|
968
931
|
}
|
|
969
932
|
const currentCustomer = this.store.order.getOrderCustomer();
|
|
970
933
|
if (!currentCustomer || Number(currentCustomer.customer_id) !== customerId) {
|
|
971
934
|
return;
|
|
972
935
|
}
|
|
973
|
-
await this.loadDiscountConfig({
|
|
974
|
-
customerId
|
|
975
|
-
});
|
|
936
|
+
await this.loadDiscountConfig({ customerId });
|
|
976
937
|
})();
|
|
977
938
|
this.orderCustomerDiscountRefreshInFlight = refreshTask;
|
|
978
939
|
this.orderCustomerDiscountRefreshCustomerId = customerId;
|
|
979
|
-
refreshTask.catch(error => {
|
|
980
|
-
console.error(
|
|
940
|
+
refreshTask.catch((error) => {
|
|
941
|
+
console.error("Failed to load discount config after customer change:", error);
|
|
981
942
|
}).finally(() => {
|
|
982
|
-
if (this.orderCustomerDiscountRefreshInFlight !== refreshTask)
|
|
943
|
+
if (this.orderCustomerDiscountRefreshInFlight !== refreshTask)
|
|
944
|
+
return;
|
|
983
945
|
this.orderCustomerDiscountRefreshInFlight = null;
|
|
984
946
|
this.orderCustomerDiscountRefreshCustomerId = null;
|
|
985
947
|
});
|
|
986
948
|
}
|
|
987
|
-
|
|
988
949
|
/**
|
|
989
950
|
* 获取客户分页信息
|
|
990
951
|
* @returns 分页信息
|
|
@@ -992,7 +953,6 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
992
953
|
getCustomerPaginationInfo() {
|
|
993
954
|
return this.store.customer.getPaginationInfo();
|
|
994
955
|
}
|
|
995
|
-
|
|
996
956
|
/**
|
|
997
957
|
* 获取客户列表总数
|
|
998
958
|
* @returns 总数
|
|
@@ -1000,7 +960,6 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1000
960
|
getCustomerTotal() {
|
|
1001
961
|
return this.store.customer.getState().total;
|
|
1002
962
|
}
|
|
1003
|
-
|
|
1004
963
|
/**
|
|
1005
964
|
* 设置客户分页信息
|
|
1006
965
|
* @param page 页码
|
|
@@ -1009,7 +968,6 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1009
968
|
setCustomerPaginationInfo(page, pageSize) {
|
|
1010
969
|
this.store.customer.setPaginationInfo(page, pageSize);
|
|
1011
970
|
}
|
|
1012
|
-
|
|
1013
971
|
/**
|
|
1014
972
|
* 便捷方法:切换客户分页并自动获取数据
|
|
1015
973
|
* @param page 页码
|
|
@@ -1018,14 +976,16 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1018
976
|
*/
|
|
1019
977
|
async changeCustomerPage(page, pageSize) {
|
|
1020
978
|
try {
|
|
1021
|
-
const result = await this.store.customer.changeCustomerPage(
|
|
979
|
+
const result = await this.store.customer.changeCustomerPage(
|
|
980
|
+
page,
|
|
981
|
+
pageSize
|
|
982
|
+
);
|
|
1022
983
|
return result;
|
|
1023
984
|
} catch (error) {
|
|
1024
|
-
console.error(
|
|
985
|
+
console.error("Failed to change customer page:", error);
|
|
1025
986
|
throw error;
|
|
1026
987
|
}
|
|
1027
988
|
}
|
|
1028
|
-
|
|
1029
989
|
/**
|
|
1030
990
|
* 滚动加载更多客户数据 - 数据会追加到现有列表中
|
|
1031
991
|
* @returns 客户列表响应
|
|
@@ -1036,11 +996,10 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1036
996
|
this.core.effects.emit(`${this.name}:onCustomerListUpdate`, result);
|
|
1037
997
|
return result;
|
|
1038
998
|
} catch (error) {
|
|
1039
|
-
console.error(
|
|
999
|
+
console.error("Failed to load more customers:", error);
|
|
1040
1000
|
throw error;
|
|
1041
1001
|
}
|
|
1042
1002
|
}
|
|
1043
|
-
|
|
1044
1003
|
/**
|
|
1045
1004
|
* 重置并重新开始滚动加载客户数据
|
|
1046
1005
|
* @param params 查询参数
|
|
@@ -1052,11 +1011,10 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1052
1011
|
this.core.effects.emit(`${this.name}:onCustomerListReset`, result);
|
|
1053
1012
|
return result;
|
|
1054
1013
|
} catch (error) {
|
|
1055
|
-
console.error(
|
|
1014
|
+
console.error("Failed to reset and load customers:", error);
|
|
1056
1015
|
throw error;
|
|
1057
1016
|
}
|
|
1058
1017
|
}
|
|
1059
|
-
|
|
1060
1018
|
/**
|
|
1061
1019
|
* 检查是否还有更多客户数据可以加载
|
|
1062
1020
|
* @returns 是否还有更多数据
|
|
@@ -1064,7 +1022,6 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1064
1022
|
hasMoreCustomers() {
|
|
1065
1023
|
return this.store.customer.hasMoreCustomers();
|
|
1066
1024
|
}
|
|
1067
|
-
|
|
1068
1025
|
/**
|
|
1069
1026
|
* 获取当前的客户搜索条件
|
|
1070
1027
|
* @returns 当前搜索条件
|
|
@@ -1072,7 +1029,6 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1072
1029
|
getCurrentCustomerSearchParams() {
|
|
1073
1030
|
return this.store.customer.getCurrentSearchParams();
|
|
1074
1031
|
}
|
|
1075
|
-
|
|
1076
1032
|
/**
|
|
1077
1033
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
1078
1034
|
* @returns 客户状态
|
|
@@ -1080,105 +1036,96 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1080
1036
|
getCustomerState() {
|
|
1081
1037
|
return this.store.customer.getState();
|
|
1082
1038
|
}
|
|
1083
|
-
|
|
1084
1039
|
/**
|
|
1085
1040
|
* 全局扫描监听
|
|
1086
1041
|
* @param callback 回调
|
|
1087
1042
|
*/
|
|
1088
1043
|
scanGlobalListener(callback) {
|
|
1089
|
-
const localSearch = v => this.store.products.findProductsByCodeOrBarcode(v);
|
|
1090
|
-
const scanCallback = (0,
|
|
1091
|
-
|
|
1044
|
+
const localSearch = (v) => this.store.products.findProductsByCodeOrBarcode(v);
|
|
1045
|
+
const scanCallback = (0, import_handleScan.handleGlobalScan)(
|
|
1046
|
+
this.request,
|
|
1047
|
+
localSearch,
|
|
1048
|
+
this.getSubmitOrderSalesChannel()
|
|
1049
|
+
);
|
|
1050
|
+
const safeCallback = (d) => {
|
|
1092
1051
|
try {
|
|
1093
1052
|
callback(d);
|
|
1094
1053
|
} catch (error) {
|
|
1095
|
-
console.error(
|
|
1054
|
+
console.error("scanGlobalListener传入的回调函数异常", error);
|
|
1096
1055
|
}
|
|
1097
1056
|
};
|
|
1098
|
-
const listener = {
|
|
1099
|
-
key: 'global',
|
|
1100
|
-
callback: safeCallback
|
|
1101
|
-
};
|
|
1057
|
+
const listener = { key: "global", callback: safeCallback };
|
|
1102
1058
|
const removeListener = this.scan.addListener(listener, scanCallback);
|
|
1103
1059
|
return removeListener;
|
|
1104
1060
|
}
|
|
1105
|
-
|
|
1106
1061
|
/**
|
|
1107
1062
|
* 客户扫描监听
|
|
1108
1063
|
* @param callback 回调
|
|
1109
1064
|
*/
|
|
1110
1065
|
scanCustomerListener(callback) {
|
|
1111
|
-
const scanCallback = (0,
|
|
1112
|
-
const safeCallback = d => {
|
|
1066
|
+
const scanCallback = (0, import_handleScan.handleCustomerScan)();
|
|
1067
|
+
const safeCallback = (d) => {
|
|
1113
1068
|
try {
|
|
1114
1069
|
callback(d);
|
|
1115
1070
|
} catch (error) {
|
|
1116
|
-
console.error(
|
|
1071
|
+
console.error("scanCustomerListener传入的回调函数异常", error);
|
|
1117
1072
|
}
|
|
1118
1073
|
};
|
|
1119
|
-
const listener = {
|
|
1120
|
-
key: 'customer',
|
|
1121
|
-
callback: safeCallback
|
|
1122
|
-
};
|
|
1074
|
+
const listener = { key: "customer", callback: safeCallback };
|
|
1123
1075
|
const removeListener = this.scan.addListener(listener, scanCallback);
|
|
1124
1076
|
return removeListener;
|
|
1125
1077
|
}
|
|
1126
|
-
|
|
1127
1078
|
/**
|
|
1128
1079
|
* @title 通用扫描监听
|
|
1129
1080
|
* @description 直接将扫描结果返回给调用方
|
|
1130
1081
|
* @param callback 回调
|
|
1131
1082
|
*/
|
|
1132
1083
|
scanUniversalListener(callback, key) {
|
|
1133
|
-
const scanCallback = (0,
|
|
1134
|
-
const safeCallback = d => {
|
|
1084
|
+
const scanCallback = (0, import_handleScan.handleUniversalScan)();
|
|
1085
|
+
const safeCallback = (d) => {
|
|
1135
1086
|
try {
|
|
1136
1087
|
callback(d);
|
|
1137
1088
|
} catch (error) {
|
|
1138
|
-
console.error(
|
|
1089
|
+
console.error(
|
|
1090
|
+
`scanUniversalListener传入的回调函数异常, key: ${key}`,
|
|
1091
|
+
error
|
|
1092
|
+
);
|
|
1139
1093
|
}
|
|
1140
1094
|
};
|
|
1141
|
-
const listener = {
|
|
1142
|
-
key,
|
|
1143
|
-
callback: safeCallback
|
|
1144
|
-
};
|
|
1095
|
+
const listener = { key, callback: safeCallback };
|
|
1145
1096
|
const removeListener = this.scan.addListener(listener, scanCallback);
|
|
1146
1097
|
return removeListener;
|
|
1147
1098
|
}
|
|
1148
|
-
|
|
1149
1099
|
/**
|
|
1150
1100
|
* 调用摄像头
|
|
1151
1101
|
* @param data 用户自定义数据
|
|
1152
1102
|
*/
|
|
1153
1103
|
activateCamera(data) {
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1104
|
+
var _a, _b, _c, _d;
|
|
1105
|
+
(_d = (_c = (_b = (_a = this.window) == null ? void 0 : _a.interaction) == null ? void 0 : _b.utils) == null ? void 0 : _c.postMessageToApp) == null ? void 0 : _d.call(_c, {
|
|
1106
|
+
module: "global",
|
|
1107
|
+
key: "active_native_scanner",
|
|
1157
1108
|
data
|
|
1158
1109
|
});
|
|
1159
1110
|
}
|
|
1160
|
-
|
|
1161
1111
|
/**
|
|
1162
1112
|
* 禁用所有扫描监听
|
|
1163
1113
|
*/
|
|
1164
1114
|
disableAllScanListeners() {
|
|
1165
1115
|
this.scan.disableAllListeners();
|
|
1166
1116
|
}
|
|
1167
|
-
|
|
1168
1117
|
/**
|
|
1169
1118
|
* 启用所有扫描监听
|
|
1170
1119
|
*/
|
|
1171
1120
|
enableAllScanListeners() {
|
|
1172
1121
|
this.scan.enableAllListeners();
|
|
1173
1122
|
}
|
|
1174
|
-
|
|
1175
1123
|
/**
|
|
1176
1124
|
* 清空所有扫描监听对应的任务执行队列
|
|
1177
1125
|
*/
|
|
1178
1126
|
clearAllScanListenersTaskQueue() {
|
|
1179
1127
|
this.scan.clearTaskQueue();
|
|
1180
1128
|
}
|
|
1181
|
-
|
|
1182
1129
|
/**
|
|
1183
1130
|
* 获取其他参数
|
|
1184
1131
|
* @returns 其他参数
|
|
@@ -1186,128 +1133,109 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1186
1133
|
async getOtherParams() {
|
|
1187
1134
|
return this.otherParams;
|
|
1188
1135
|
}
|
|
1189
|
-
|
|
1190
1136
|
// ─── BookingContext API(透传给 BookingContextModule) ──────────────────────
|
|
1191
1137
|
// SalesSdkProvider 挂载时默认调 initBookingContext;也可由 UI 显式 set* 灌入已有数据。
|
|
1192
|
-
|
|
1193
1138
|
/** 拉取 board config 并写入 BookingContext。 */
|
|
1194
1139
|
loadBookingConfig(params) {
|
|
1195
1140
|
return this.store.bookingContext.loadBookingConfig(params);
|
|
1196
1141
|
}
|
|
1197
|
-
|
|
1198
1142
|
/** 拉取资源全集并写入 BookingContext。 */
|
|
1199
1143
|
loadBookingResources(params) {
|
|
1200
1144
|
return this.store.bookingContext.loadResources(params);
|
|
1201
1145
|
}
|
|
1202
|
-
|
|
1203
1146
|
/** 初始化 BookingContext(date + config + resources)。 */
|
|
1204
1147
|
initBookingContext(params) {
|
|
1205
1148
|
return this.store.bookingContext.initBookingContext(params);
|
|
1206
1149
|
}
|
|
1207
|
-
|
|
1208
1150
|
/** 当前 store 是否已具备与入参等价的 config / resources(无需再请求接口)。 */
|
|
1209
1151
|
isBookingContextReady(params) {
|
|
1210
1152
|
return this.store.bookingContext.isBookingContextReady(params);
|
|
1211
1153
|
}
|
|
1212
|
-
|
|
1213
1154
|
/** 写入 booking config(来源:`/core/board/management/config`)。 */
|
|
1214
1155
|
setBookingConfig(config) {
|
|
1215
1156
|
this.store.bookingContext.setBookingConfig(config);
|
|
1216
1157
|
}
|
|
1217
|
-
|
|
1218
1158
|
/** 读取当前 booking config。 */
|
|
1219
1159
|
getBookingConfig() {
|
|
1220
1160
|
return this.store.bookingContext.getBookingConfig();
|
|
1221
1161
|
}
|
|
1222
|
-
|
|
1223
1162
|
/** 写入资源全集(来源:`/form/schedule`),同步派生 resourcesOriginMap。 */
|
|
1224
1163
|
setResources(resources) {
|
|
1225
1164
|
this.store.bookingContext.setResources(resources);
|
|
1226
1165
|
}
|
|
1227
|
-
|
|
1228
1166
|
/** 读取资源全集(浅克隆)。 */
|
|
1229
1167
|
getResourcesOrigin() {
|
|
1230
1168
|
return this.store.bookingContext.getResourcesOrigin();
|
|
1231
1169
|
}
|
|
1232
|
-
|
|
1233
1170
|
/** 读取资源全集 map(id → resource)。 */
|
|
1234
1171
|
getResourcesOriginMap() {
|
|
1235
1172
|
return this.store.bookingContext.getResourcesOriginMap();
|
|
1236
1173
|
}
|
|
1237
|
-
|
|
1238
1174
|
/** 写入当前选择的日期;支持 dayjs / Date / string。 */
|
|
1239
1175
|
setBookingDate(date) {
|
|
1240
1176
|
this.store.bookingContext.setDate(date);
|
|
1241
1177
|
}
|
|
1242
|
-
|
|
1243
1178
|
/** 读取当前选择的日期(统一 string)。 */
|
|
1244
1179
|
getBookingDate() {
|
|
1245
1180
|
return this.store.bookingContext.getDate();
|
|
1246
1181
|
}
|
|
1247
|
-
|
|
1248
1182
|
/** 读取 BookingContext 完整 store(调试 / 测试 / 透传给 SDK 使用)。 */
|
|
1249
1183
|
getBookingContextState() {
|
|
1250
1184
|
return this.store.bookingContext.getState();
|
|
1251
1185
|
}
|
|
1252
|
-
|
|
1253
1186
|
/** 清空 BookingContext(切租户 / destroy 场景)。 */
|
|
1254
1187
|
clearBookingContext() {
|
|
1255
1188
|
this.store.bookingContext.clear();
|
|
1256
1189
|
}
|
|
1257
|
-
|
|
1258
1190
|
/**
|
|
1259
1191
|
* 构造 BookingContext 计算上下文(供 getProductExtend / getResourceByIds 等读 API 复用)。
|
|
1260
1192
|
*/
|
|
1261
1193
|
buildBookingCalcContext(extra) {
|
|
1262
1194
|
const state = this.store.bookingContext.getState();
|
|
1263
|
-
const date = extra
|
|
1195
|
+
const date = (extra == null ? void 0 : extra.date) ?? state.date;
|
|
1264
1196
|
return {
|
|
1265
1197
|
bookingConfig: state.bookingConfig,
|
|
1266
1198
|
resourcesOrigin: state.resourcesOrigin,
|
|
1267
1199
|
resourcesOriginMap: state.resourcesOriginMap,
|
|
1268
1200
|
date,
|
|
1269
|
-
presetStartTime: extra
|
|
1270
|
-
...
|
|
1201
|
+
presetStartTime: (extra == null ? void 0 : extra.presetStartTime) ?? (0, import_BookingContext.derivePresetStartTimeFromDate)(date),
|
|
1202
|
+
...extra || {}
|
|
1271
1203
|
};
|
|
1272
1204
|
}
|
|
1273
|
-
|
|
1274
1205
|
/**
|
|
1275
1206
|
* 取商品当前可选资源列表(透传 OS BookingContext utils#getResourceByIds)。
|
|
1276
1207
|
* `extraResources` 用于把拖入未绑定的资源也展示出来。
|
|
1277
1208
|
*/
|
|
1278
1209
|
getResourcesForProduct(product, options) {
|
|
1210
|
+
var _a, _b;
|
|
1279
1211
|
const ctx = this.buildBookingCalcContext();
|
|
1280
|
-
return (0,
|
|
1281
|
-
resourceTab: ctx.bookingConfig
|
|
1212
|
+
return (0, import_BookingContext.getResourceByIds)(ctx.resourcesOriginMap || {}, product, {
|
|
1213
|
+
resourceTab: (_b = (_a = ctx.bookingConfig) == null ? void 0 : _a.config) == null ? void 0 : _b.resource_tab,
|
|
1282
1214
|
resourcesOrigin: ctx.resourcesOrigin,
|
|
1283
|
-
extraResources: options
|
|
1215
|
+
extraResources: (options == null ? void 0 : options.extraResources) || []
|
|
1284
1216
|
});
|
|
1285
1217
|
}
|
|
1286
|
-
|
|
1287
1218
|
/**
|
|
1288
1219
|
* 拼装 cacheItem 的 _extend / _data(资源 / 容量 / timeObj),与 info2 `getProductExtend` 等价。
|
|
1289
1220
|
*/
|
|
1290
1221
|
getProductExtend(cacheItem, extra) {
|
|
1291
1222
|
const preparedCacheItem = withProductOptionString(cacheItem);
|
|
1292
|
-
const result = (0,
|
|
1223
|
+
const result = (0, import_BookingContext.getProductExtend)({
|
|
1293
1224
|
cacheItem: preparedCacheItem,
|
|
1294
1225
|
ctx: this.buildBookingCalcContext(extra)
|
|
1295
1226
|
});
|
|
1296
1227
|
return result;
|
|
1297
1228
|
}
|
|
1298
|
-
|
|
1299
1229
|
/**
|
|
1300
1230
|
* 取资源不可用原因列表(结构化 enum + params,i18n 文案由 UI 渲染)。
|
|
1301
1231
|
*/
|
|
1302
1232
|
getResourceErrors(resource, cacheItem) {
|
|
1303
|
-
return (0,
|
|
1233
|
+
return (0, import_BookingContext.getResourceErrors)(resource, cacheItem);
|
|
1304
1234
|
}
|
|
1305
|
-
|
|
1306
1235
|
// ─── addProduct 决策 / 转换 API(SDK 加车下沉所需) ─────────────────────────
|
|
1307
1236
|
// 这一组方法是 SalesSdkCartContext.addProduct / confirmDetail 的 OS 后端。
|
|
1308
1237
|
// 调用方传入 ProductData,OS 自取 bookingContext / customer / date 等上下文,
|
|
1309
1238
|
// 输出 (a) autoClose 决策结果或 (b) `{ product, booking }` 协议入参。
|
|
1310
|
-
|
|
1311
1239
|
/**
|
|
1312
1240
|
* session 商品 catalog 日期与 TimeBar 不一致时写业务日志。
|
|
1313
1241
|
*
|
|
@@ -1315,53 +1243,51 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1315
1243
|
* this.logSessionCatalogDateMismatch(product, ctx.date);
|
|
1316
1244
|
*/
|
|
1317
1245
|
logSessionCatalogDateMismatch(item, bookingDate) {
|
|
1246
|
+
var _a, _b;
|
|
1318
1247
|
const logger = this.logger;
|
|
1319
|
-
if (!logger
|
|
1320
|
-
|
|
1321
|
-
const
|
|
1248
|
+
if (!(logger == null ? void 0 : logger.addLog))
|
|
1249
|
+
return;
|
|
1250
|
+
const tempOrder = (_a = this.getTempOrder) == null ? void 0 : _a.call(this);
|
|
1251
|
+
const staleInfo = (0, import_sessionCatalogStale.buildSessionCatalogStaleInfo)(item, bookingDate);
|
|
1322
1252
|
logger.addLog({
|
|
1323
|
-
type:
|
|
1253
|
+
type: "warning",
|
|
1324
1254
|
title: `[BookingTicket] session catalog date mismatch, reload products`,
|
|
1325
1255
|
metadata: {
|
|
1326
|
-
order_id: tempOrder
|
|
1327
|
-
external_sale_number: tempOrder
|
|
1256
|
+
order_id: (tempOrder == null ? void 0 : tempOrder.order_id) ?? null,
|
|
1257
|
+
external_sale_number: (tempOrder == null ? void 0 : tempOrder.external_sale_number) ?? null,
|
|
1328
1258
|
...staleInfo,
|
|
1329
|
-
cartDetailValueSession: item
|
|
1259
|
+
cartDetailValueSession: ((_b = item == null ? void 0 : item.cartDetailValue) == null ? void 0 : _b.session) ?? null
|
|
1330
1260
|
}
|
|
1331
1261
|
});
|
|
1332
1262
|
}
|
|
1333
|
-
|
|
1334
1263
|
/**
|
|
1335
1264
|
* 加车前:session 商品 catalog 日历日与 bookingDate 不一致时中断加购,交由 SDK reload products。
|
|
1336
1265
|
*/
|
|
1337
1266
|
resolveSessionCatalogBeforeAdd(item, ctx) {
|
|
1338
|
-
if (!(0,
|
|
1267
|
+
if (!(0, import_sessionCatalogStale.isSessionCatalogDateStale)(item, ctx.date)) {
|
|
1339
1268
|
return null;
|
|
1340
1269
|
}
|
|
1341
1270
|
this.logSessionCatalogDateMismatch(item, ctx.date);
|
|
1342
|
-
return {
|
|
1343
|
-
action: 'reloadCatalog'
|
|
1344
|
-
};
|
|
1271
|
+
return { action: "reloadCatalog" };
|
|
1345
1272
|
}
|
|
1346
|
-
|
|
1347
1273
|
/**
|
|
1348
1274
|
* 拼装 addProductDecision 通用上下文(从 store 自取)。
|
|
1349
1275
|
*/
|
|
1350
1276
|
buildAddProductCtx(extra) {
|
|
1277
|
+
var _a, _b;
|
|
1351
1278
|
const bookingContextState = this.store.bookingContext.getState();
|
|
1352
|
-
const date = extra
|
|
1353
|
-
const orderCustomerId = this.getOrderCustomerSnapshot()
|
|
1279
|
+
const date = (extra == null ? void 0 : extra.date) ?? bookingContextState.date;
|
|
1280
|
+
const orderCustomerId = ((_a = this.getOrderCustomerSnapshot()) == null ? void 0 : _a.id) ?? ((_b = this.store.order.getTempOrder()) == null ? void 0 : _b.customer_id) ?? void 0;
|
|
1354
1281
|
return {
|
|
1355
1282
|
bookingConfig: bookingContextState.bookingConfig,
|
|
1356
1283
|
resourcesOrigin: bookingContextState.resourcesOrigin,
|
|
1357
1284
|
resourcesOriginMap: bookingContextState.resourcesOriginMap,
|
|
1358
1285
|
date,
|
|
1359
|
-
presetStartTime: extra
|
|
1286
|
+
presetStartTime: (extra == null ? void 0 : extra.presetStartTime) ?? (0, import_BookingContext.derivePresetStartTimeFromDate)(date),
|
|
1360
1287
|
customerId: orderCustomerId,
|
|
1361
|
-
...
|
|
1288
|
+
...extra || {}
|
|
1362
1289
|
};
|
|
1363
1290
|
}
|
|
1364
|
-
|
|
1365
1291
|
/**
|
|
1366
1292
|
* 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
|
|
1367
1293
|
* 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
|
|
@@ -1372,75 +1298,60 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1372
1298
|
if (staleDecision) {
|
|
1373
1299
|
return staleDecision;
|
|
1374
1300
|
}
|
|
1375
|
-
return (0,
|
|
1301
|
+
return (0, import_addProductDecision.decideAddProduct)(item, ctx);
|
|
1376
1302
|
}
|
|
1377
|
-
|
|
1378
1303
|
/** 规格弹窗 callback 后的第二段决策。 */
|
|
1379
1304
|
decideAfterDetail(cacheItem, options) {
|
|
1380
|
-
return (0,
|
|
1305
|
+
return (0, import_addProductDecision.decideAfterDetail)(cacheItem, this.buildAddProductCtx(options));
|
|
1381
1306
|
}
|
|
1382
|
-
|
|
1383
1307
|
/**
|
|
1384
1308
|
* @deprecated 请用 `decideAddProduct`;`autoClose=true` 仅当 action=add。
|
|
1385
1309
|
*/
|
|
1386
1310
|
decideAutoClose(item, options) {
|
|
1387
|
-
return (0,
|
|
1311
|
+
return (0, import_addProductDecision.decideAutoClose)(item, this.buildAddProductCtx(options));
|
|
1388
1312
|
}
|
|
1389
|
-
|
|
1390
1313
|
/** 替代 info2 `getIsEject`:商品是否需要弹窗(0/1)。 */
|
|
1391
|
-
getIsEject(item, type =
|
|
1392
|
-
return (0,
|
|
1314
|
+
getIsEject(item, type = "select") {
|
|
1315
|
+
return (0, import_addProductDecision.getIsEject)(item, type);
|
|
1393
1316
|
}
|
|
1394
|
-
|
|
1395
1317
|
/** 仅 session 商品(无 variant/option/package)→ true。 */
|
|
1396
1318
|
getIsOnlySession(item) {
|
|
1397
|
-
return (0,
|
|
1319
|
+
return (0, import_addProductDecision.getIsOnlySession)(item);
|
|
1398
1320
|
}
|
|
1399
|
-
|
|
1400
1321
|
/**
|
|
1401
1322
|
* 拼装 requiresDetail payload(给 SDK 直接 return 给 UI 用)。
|
|
1402
1323
|
*/
|
|
1403
1324
|
buildRequiresDetailPayload(item, options) {
|
|
1404
1325
|
const ctx = this.buildAddProductCtx(options);
|
|
1405
|
-
return (0,
|
|
1326
|
+
return (0, import_addProductDecision.buildRequiresDetailPayload)(item, ctx);
|
|
1406
1327
|
}
|
|
1407
|
-
|
|
1408
1328
|
/**
|
|
1409
1329
|
* 把 detail 弹窗回调结果(e, extension_type, detail)转换为 `(product, booking)` 入参。
|
|
1410
1330
|
* 内部会先拼 cacheItem,再走 cacheItemToBookingInput 严格协议对齐。
|
|
1411
1331
|
*/
|
|
1412
1332
|
transformDetailToProductAndBooking(input) {
|
|
1413
|
-
const {
|
|
1414
|
-
item,
|
|
1415
|
-
cacheItem: preparedCacheItem,
|
|
1416
|
-
detailResult,
|
|
1417
|
-
options
|
|
1418
|
-
} = input;
|
|
1333
|
+
const { item, cacheItem: preparedCacheItem, detailResult, options } = input;
|
|
1419
1334
|
const ctx = this.buildAddProductCtx(options);
|
|
1420
|
-
const cacheItem = preparedCacheItem || (detailResult ? (0,
|
|
1421
|
-
return (0,
|
|
1335
|
+
const cacheItem = preparedCacheItem || (detailResult ? (0, import_addProductDecision.buildCacheItemFromDetail)(item, detailResult, ctx) : (0, import_addProductDecision.buildCacheItemFromCartDetail)(item, ctx));
|
|
1336
|
+
return (0, import_addProductDecision.transformDetailToProductAndBooking)(cacheItem, ctx);
|
|
1422
1337
|
}
|
|
1423
|
-
|
|
1424
1338
|
/**
|
|
1425
1339
|
* 从已加车的 order line + booking 反查资源编辑抽屉所需的 cacheItem。
|
|
1426
1340
|
* 供 SalesSdk「编辑资源」等场景使用;字段语义与 buildCacheItemFromDetail 产出对齐。
|
|
1427
1341
|
*/
|
|
1428
1342
|
buildCacheItemFromOrderLine(input) {
|
|
1429
|
-
return (0,
|
|
1343
|
+
return (0, import_buildCacheItemFromOrderLine.buildCacheItemFromOrderLine)(input);
|
|
1430
1344
|
}
|
|
1431
|
-
|
|
1432
1345
|
/**
|
|
1433
1346
|
* 从已加车的普通商品 order line 反查 SkuDetailModal edit 所需的 cacheItem。
|
|
1434
1347
|
*/
|
|
1435
1348
|
buildNormalProductCacheItemFromOrderLine(input) {
|
|
1436
|
-
return (0,
|
|
1349
|
+
return (0, import_buildNormalProductCacheItemFromOrderLine.buildNormalProductCacheItemFromOrderLine)(input);
|
|
1437
1350
|
}
|
|
1438
|
-
|
|
1439
1351
|
/** 文档别名:与 OrderModule.updateOrderProduct 一致。 */
|
|
1440
1352
|
async updateProductInOrder(params) {
|
|
1441
1353
|
return this.updateOrderProduct(params);
|
|
1442
1354
|
}
|
|
1443
|
-
|
|
1444
1355
|
/**
|
|
1445
1356
|
* 全局扫码 pubsub 入口:解析码值 → 搜索 → 业务分发(客户 / 加车 / 开单)。
|
|
1446
1357
|
* UI 层在 pubsub 订阅回调里注入 `bridge`(uiHosts / action / cart.confirm*)。
|
|
@@ -1455,54 +1366,53 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1455
1366
|
* ```
|
|
1456
1367
|
*/
|
|
1457
1368
|
async handleGlobalScanCode(code, bridge) {
|
|
1458
|
-
|
|
1369
|
+
var _a, _b, _c, _d;
|
|
1370
|
+
const trimmed = typeof code === "string" ? code.trim() : "";
|
|
1459
1371
|
if (!trimmed) {
|
|
1460
|
-
bridge
|
|
1461
|
-
return {
|
|
1462
|
-
status: 'failed',
|
|
1463
|
-
reason: 'empty_code'
|
|
1464
|
-
};
|
|
1372
|
+
(_a = bridge == null ? void 0 : bridge.onNotify) == null ? void 0 : _a.call(bridge, "fail", "pisell2.text.scan-global-failed");
|
|
1373
|
+
return { status: "failed", reason: "empty_code" };
|
|
1465
1374
|
}
|
|
1466
1375
|
try {
|
|
1467
|
-
const localSearch = v => this.store.products.findProductsByCodeOrBarcode(v);
|
|
1468
|
-
const scanCallback = (0,
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
const
|
|
1376
|
+
const localSearch = (v) => this.store.products.findProductsByCodeOrBarcode(v);
|
|
1377
|
+
const scanCallback = (0, import_handleScan.handleGlobalScan)(
|
|
1378
|
+
this.request,
|
|
1379
|
+
localSearch,
|
|
1380
|
+
this.getSubmitOrderSalesChannel()
|
|
1381
|
+
);
|
|
1382
|
+
const raw = await scanCallback({ type: "nativeScanner", value: trimmed });
|
|
1383
|
+
const formatted = (0, import_formatGlobalScan.formatGlobalScanResult)(raw, trimmed);
|
|
1474
1384
|
if (!formatted) {
|
|
1475
|
-
bridge
|
|
1476
|
-
return {
|
|
1477
|
-
status: 'failed',
|
|
1478
|
-
reason: 'not_found'
|
|
1479
|
-
};
|
|
1385
|
+
(_b = bridge == null ? void 0 : bridge.onNotify) == null ? void 0 : _b.call(bridge, "fail", "pisell2.text.scan-global-failed");
|
|
1386
|
+
return { status: "failed", reason: "not_found" };
|
|
1480
1387
|
}
|
|
1481
|
-
const result = await (0,
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1388
|
+
const result = await (0, import_applyGlobalScan.applyGlobalScan)(
|
|
1389
|
+
{
|
|
1390
|
+
setOrderCustomer: (customer) => this.setOrderCustomer(customer),
|
|
1391
|
+
getOrderCustomerSnapshot: () => this.getOrderCustomerSnapshot(),
|
|
1392
|
+
getBusinessCode: () => {
|
|
1393
|
+
var _a2;
|
|
1394
|
+
return (_a2 = this.otherParams) == null ? void 0 : _a2.businessCode;
|
|
1395
|
+
},
|
|
1396
|
+
buildAddProductCtx: (extra) => this.buildAddProductCtx(extra),
|
|
1397
|
+
decideAddProduct: (item, options) => this.decideAddProduct(item, options),
|
|
1398
|
+
decideAfterDetail: (cacheItem, options) => this.decideAfterDetail(cacheItem, options),
|
|
1399
|
+
transformDetailToProductAndBooking: (input) => this.transformDetailToProductAndBooking(input),
|
|
1400
|
+
addProductToOrder: (product, booking) => this.addProductToOrder(product, booking)
|
|
1401
|
+
},
|
|
1402
|
+
formatted,
|
|
1403
|
+
bridge
|
|
1404
|
+
);
|
|
1405
|
+
(_c = bridge == null ? void 0 : bridge.refresh) == null ? void 0 : _c.call(bridge);
|
|
1492
1406
|
return result;
|
|
1493
1407
|
} catch (error) {
|
|
1494
|
-
console.error(
|
|
1495
|
-
bridge
|
|
1496
|
-
return {
|
|
1497
|
-
status: 'failed',
|
|
1498
|
-
reason: 'not_found'
|
|
1499
|
-
};
|
|
1408
|
+
console.error("[BookingTicket] handleGlobalScanCode failed", error);
|
|
1409
|
+
(_d = bridge == null ? void 0 : bridge.onNotify) == null ? void 0 : _d.call(bridge, "fail", "pisell2.text.scan-global-failed");
|
|
1410
|
+
return { status: "failed", reason: "not_found" };
|
|
1500
1411
|
}
|
|
1501
1412
|
}
|
|
1502
1413
|
resolveBestAddTimePlan(addTimeProducts, targetMinutes) {
|
|
1503
|
-
return (0,
|
|
1414
|
+
return (0, import_resolveBestAddTimePlan.resolveBestAddTimePlan)(addTimeProducts, targetMinutes);
|
|
1504
1415
|
}
|
|
1505
|
-
|
|
1506
1416
|
/**
|
|
1507
1417
|
* 构造一条绑定到已有 booking 的加时商品行。
|
|
1508
1418
|
*
|
|
@@ -1510,13 +1420,17 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1510
1420
|
* const line = this.buildAddTimeOrderLine({ product, product_add_schedule_time: 30 }, 'booking-1');
|
|
1511
1421
|
*/
|
|
1512
1422
|
buildAddTimeOrderLine(input, bookingUid) {
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1423
|
+
var _a;
|
|
1424
|
+
const product = input == null ? void 0 : input.product;
|
|
1425
|
+
if (!product || typeof product !== "object") {
|
|
1426
|
+
throw new Error("[BookingTicket] addAddTimeProductToBooking: product 不能为空");
|
|
1516
1427
|
}
|
|
1517
1428
|
const quantity = normalizeAddTimeQuantity(input.num ?? product.num);
|
|
1518
1429
|
const price = resolveAddTimeProductPrice(input.price, product);
|
|
1519
|
-
const addScheduleTime = resolveAddTimeScheduleMinutes(
|
|
1430
|
+
const addScheduleTime = resolveAddTimeScheduleMinutes(
|
|
1431
|
+
input.product_add_schedule_time,
|
|
1432
|
+
product
|
|
1433
|
+
);
|
|
1520
1434
|
const payload = {
|
|
1521
1435
|
id: product.id ?? product.product_id,
|
|
1522
1436
|
product_id: product.product_id ?? product.id,
|
|
@@ -1530,7 +1444,7 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1530
1444
|
line_total: price,
|
|
1531
1445
|
total: price,
|
|
1532
1446
|
product_sku: product.product_sku,
|
|
1533
|
-
option: product.option ?? product.options ?? product.product_sku
|
|
1447
|
+
option: product.option ?? product.options ?? ((_a = product.product_sku) == null ? void 0 : _a.option) ?? [],
|
|
1534
1448
|
bundle: product.bundle ?? product.bundles ?? product.product_bundle ?? []
|
|
1535
1449
|
};
|
|
1536
1450
|
const orderLine = this.transformBaseProductToOrderProduct({
|
|
@@ -1540,13 +1454,13 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1540
1454
|
sourceItem: product
|
|
1541
1455
|
});
|
|
1542
1456
|
if (!orderLine) {
|
|
1543
|
-
throw new Error(
|
|
1457
|
+
throw new Error(
|
|
1458
|
+
"[BookingTicket] addAddTimeProductToBooking: product transform failed"
|
|
1459
|
+
);
|
|
1544
1460
|
}
|
|
1545
1461
|
const metadata = {
|
|
1546
|
-
...
|
|
1547
|
-
...
|
|
1548
|
-
product_add_schedule_time: addScheduleTime
|
|
1549
|
-
} : {}),
|
|
1462
|
+
...orderLine.metadata || {},
|
|
1463
|
+
...addScheduleTime !== void 0 ? { product_add_schedule_time: addScheduleTime } : {},
|
|
1550
1464
|
booking_uid: bookingUid
|
|
1551
1465
|
};
|
|
1552
1466
|
return {
|
|
@@ -1555,7 +1469,6 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1555
1469
|
metadata
|
|
1556
1470
|
};
|
|
1557
1471
|
}
|
|
1558
|
-
|
|
1559
1472
|
/**
|
|
1560
1473
|
* 将加时商品作为独立商品行绑定到已有 booking。
|
|
1561
1474
|
*
|
|
@@ -1579,7 +1492,6 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1579
1492
|
bookingPatch: input.bookingPatch
|
|
1580
1493
|
});
|
|
1581
1494
|
}
|
|
1582
|
-
|
|
1583
1495
|
/**
|
|
1584
1496
|
* 批量将加时商品作为独立商品行绑定到已有 booking,并只触发一次购物车重算。
|
|
1585
1497
|
*
|
|
@@ -1590,14 +1502,17 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1590
1502
|
* });
|
|
1591
1503
|
*/
|
|
1592
1504
|
async addAddTimeProductsToBooking(input) {
|
|
1593
|
-
const bookingUid = resolveBookingUidForAddTime(input
|
|
1505
|
+
const bookingUid = resolveBookingUidForAddTime(input == null ? void 0 : input.booking);
|
|
1594
1506
|
if (!bookingUid) {
|
|
1595
|
-
throw new Error(
|
|
1507
|
+
throw new Error(
|
|
1508
|
+
"[BookingTicket] addAddTimeProductToBooking: booking.metadata.unique_identification_number 缺失"
|
|
1509
|
+
);
|
|
1596
1510
|
}
|
|
1597
|
-
const orderLines = (input.products || []).map(line => ({
|
|
1511
|
+
const orderLines = (input.products || []).map((line) => ({
|
|
1598
1512
|
product: this.buildAddTimeOrderLine(line, bookingUid)
|
|
1599
1513
|
}));
|
|
1600
|
-
if (!this.store.order)
|
|
1514
|
+
if (!this.store.order)
|
|
1515
|
+
throw new Error("order 模块未初始化");
|
|
1601
1516
|
const coveredMinutes = normalizeCoveredMinutes(input.coveredMinutes);
|
|
1602
1517
|
const bookingTimePatch = input.bookingPatch ?? buildAddTimeBookingTimePatch(input.booking, coveredMinutes);
|
|
1603
1518
|
if (bookingTimePatch) {
|
|
@@ -1606,7 +1521,7 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1606
1521
|
updates: bookingTimePatch
|
|
1607
1522
|
});
|
|
1608
1523
|
}
|
|
1609
|
-
if (typeof this.store.order.addProductsToOrder ===
|
|
1524
|
+
if (typeof this.store.order.addProductsToOrder === "function") {
|
|
1610
1525
|
return this.store.order.addProductsToOrder(orderLines, {
|
|
1611
1526
|
skipEditDiscountConfigRefresh: true,
|
|
1612
1527
|
skipDiscountRecalculation: true
|
|
@@ -1614,32 +1529,29 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1614
1529
|
}
|
|
1615
1530
|
const result = [];
|
|
1616
1531
|
for (const line of orderLines) {
|
|
1617
|
-
result.splice(0, result.length, ...
|
|
1532
|
+
result.splice(0, result.length, ...await this.addProductToOrder(line.product));
|
|
1618
1533
|
}
|
|
1619
1534
|
return result;
|
|
1620
1535
|
}
|
|
1621
|
-
async setOtherParams(params, {
|
|
1622
|
-
cover
|
|
1623
|
-
|
|
1624
|
-
super.setOtherParams(params, {
|
|
1625
|
-
cover
|
|
1626
|
-
});
|
|
1627
|
-
if (params?.businessCode) {
|
|
1536
|
+
async setOtherParams(params, { cover = false } = {}) {
|
|
1537
|
+
super.setOtherParams(params, { cover });
|
|
1538
|
+
if (params == null ? void 0 : params.businessCode) {
|
|
1628
1539
|
await this.configureIdGeneratorFromOpenData();
|
|
1629
1540
|
}
|
|
1630
1541
|
}
|
|
1631
1542
|
getDeviceTaskPlugin() {
|
|
1632
|
-
|
|
1633
|
-
|
|
1543
|
+
var _a;
|
|
1544
|
+
const app = this.core.getPlugin("app");
|
|
1545
|
+
return ((_a = app == null ? void 0 : app.getApp()) == null ? void 0 : _a.getPlugin("deviceTask")) || null;
|
|
1634
1546
|
}
|
|
1635
|
-
|
|
1636
1547
|
// 打印手环,单个或批量都可以
|
|
1637
1548
|
async handlePrintWristband(params) {
|
|
1549
|
+
var _a;
|
|
1638
1550
|
const deviceTask = this.getDeviceTaskPlugin();
|
|
1639
|
-
if (!deviceTask
|
|
1551
|
+
if (!(deviceTask == null ? void 0 : deviceTask.dispatch)) {
|
|
1640
1552
|
this.logger.addLog({
|
|
1641
|
-
type:
|
|
1642
|
-
title:
|
|
1553
|
+
type: "info",
|
|
1554
|
+
title: "[BookingTicket] handlePrintWristband: deviceTask.dispatch 不可用",
|
|
1643
1555
|
metadata: {
|
|
1644
1556
|
voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids]
|
|
1645
1557
|
}
|
|
@@ -1647,50 +1559,51 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1647
1559
|
return;
|
|
1648
1560
|
}
|
|
1649
1561
|
this.logger.addLog({
|
|
1650
|
-
type:
|
|
1651
|
-
title:
|
|
1562
|
+
type: "info",
|
|
1563
|
+
title: "[BookingTicket] handlePrintWristband",
|
|
1652
1564
|
metadata: {
|
|
1653
1565
|
voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids]
|
|
1654
1566
|
}
|
|
1655
1567
|
});
|
|
1656
1568
|
const deviceId = await this.getShortNumberOrDeviceId();
|
|
1657
|
-
const idempotencyKey = (0,
|
|
1569
|
+
const idempotencyKey = (0, import_utils.createUuidV4)();
|
|
1658
1570
|
deviceTask.dispatch({
|
|
1659
|
-
action:
|
|
1571
|
+
action: "print_all",
|
|
1660
1572
|
device_id: deviceId,
|
|
1661
1573
|
payload: {
|
|
1662
|
-
type:
|
|
1574
|
+
type: "WRISTBAND",
|
|
1663
1575
|
data: {
|
|
1664
|
-
order_id: this.getOrderIdentity()
|
|
1576
|
+
order_id: (_a = this.getOrderIdentity()) == null ? void 0 : _a.orderId,
|
|
1665
1577
|
voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids]
|
|
1666
1578
|
}
|
|
1667
1579
|
},
|
|
1668
1580
|
idempotency_key: idempotencyKey,
|
|
1669
|
-
name:
|
|
1670
|
-
source:
|
|
1671
|
-
source_type:
|
|
1581
|
+
name: "PRINT_WRISTBAND",
|
|
1582
|
+
source: "bookingTicket",
|
|
1583
|
+
source_type: "handlePrintWristband",
|
|
1672
1584
|
source_id: idempotencyKey
|
|
1673
1585
|
});
|
|
1674
1586
|
}
|
|
1675
|
-
|
|
1676
1587
|
// 触发核销
|
|
1677
1588
|
async handleRedeem(params) {
|
|
1589
|
+
var _a, _b, _c;
|
|
1678
1590
|
const voucherIds = Array.isArray(params.voucher_ids) ? params.voucher_ids : [];
|
|
1679
|
-
const status = params.is_checkin ?
|
|
1591
|
+
const status = params.is_checkin ? "used" : "unused";
|
|
1680
1592
|
this.logger.addLog({
|
|
1681
|
-
type:
|
|
1682
|
-
title:
|
|
1593
|
+
type: "info",
|
|
1594
|
+
title: "[BookingTicket] handleRedeem",
|
|
1683
1595
|
metadata: {
|
|
1684
1596
|
voucher_ids: voucherIds,
|
|
1685
1597
|
status
|
|
1686
1598
|
}
|
|
1687
1599
|
});
|
|
1688
1600
|
const voucherIdSet = new Set(voucherIds);
|
|
1689
|
-
const tempOrder = this.store.order
|
|
1690
|
-
const vouchers = tempOrder
|
|
1601
|
+
const tempOrder = (_b = (_a = this.store.order) == null ? void 0 : _a.getTempOrder) == null ? void 0 : _b.call(_a);
|
|
1602
|
+
const vouchers = (tempOrder == null ? void 0 : tempOrder.vouchers) || ((_c = this.store.order) == null ? void 0 : _c.getVouchers()) || [];
|
|
1691
1603
|
let hasUpdatedVoucher = false;
|
|
1692
|
-
const nextVouchers = vouchers.map(voucher => {
|
|
1693
|
-
if (!voucherIdSet.has(voucher.voucher_id))
|
|
1604
|
+
const nextVouchers = vouchers.map((voucher) => {
|
|
1605
|
+
if (!voucherIdSet.has(voucher.voucher_id))
|
|
1606
|
+
return voucher;
|
|
1694
1607
|
hasUpdatedVoucher = true;
|
|
1695
1608
|
return {
|
|
1696
1609
|
...voucher,
|
|
@@ -1708,15 +1621,15 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1708
1621
|
return {
|
|
1709
1622
|
code: 200,
|
|
1710
1623
|
status: true,
|
|
1711
|
-
message:
|
|
1624
|
+
message: "",
|
|
1712
1625
|
data: []
|
|
1713
1626
|
};
|
|
1714
1627
|
}
|
|
1715
1628
|
const identity = this.getOrderIdentity();
|
|
1716
|
-
const externalSaleNumber = tempOrder
|
|
1717
|
-
const orderId = tempOrder
|
|
1718
|
-
const orderLookup = externalSaleNumber || orderId || identity
|
|
1719
|
-
return this.request.post(
|
|
1629
|
+
const externalSaleNumber = (tempOrder == null ? void 0 : tempOrder.external_sale_number) || (identity == null ? void 0 : identity.externalSaleNumber) || void 0;
|
|
1630
|
+
const orderId = (tempOrder == null ? void 0 : tempOrder.order_id) ?? (identity == null ? void 0 : identity.orderId) ?? void 0;
|
|
1631
|
+
const orderLookup = externalSaleNumber || orderId || (identity == null ? void 0 : identity.orderNumber) || (identity == null ? void 0 : identity.shopOrderNumber) || (identity == null ? void 0 : identity.shopFullOrderNumber) || void 0;
|
|
1632
|
+
return this.request.post("/machinecode/batch", {
|
|
1720
1633
|
ids: voucherIds,
|
|
1721
1634
|
status,
|
|
1722
1635
|
order_lookup: orderLookup,
|
|
@@ -1726,21 +1639,24 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1726
1639
|
osServer: true
|
|
1727
1640
|
});
|
|
1728
1641
|
}
|
|
1729
|
-
|
|
1730
1642
|
/**
|
|
1731
1643
|
* 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
|
|
1732
1644
|
* 再清理 BookingTicket 自有资源(scan 监听 + scan 内存缓存)。
|
|
1733
1645
|
*/
|
|
1734
1646
|
async destroy() {
|
|
1647
|
+
var _a;
|
|
1735
1648
|
await super.destroy();
|
|
1736
1649
|
try {
|
|
1737
|
-
this.scan
|
|
1650
|
+
(_a = this.scan) == null ? void 0 : _a.removeAllListeners();
|
|
1738
1651
|
} catch (error) {
|
|
1739
|
-
console.warn(
|
|
1652
|
+
console.warn("[BookingTicket] scan removeAllListeners 失败", error);
|
|
1740
1653
|
}
|
|
1741
|
-
|
|
1654
|
+
import_scanCache.default.clear();
|
|
1742
1655
|
}
|
|
1743
|
-
}
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1656
|
+
};
|
|
1657
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1658
|
+
0 && (module.exports = {
|
|
1659
|
+
BookingTicket,
|
|
1660
|
+
BookingTicketImpl,
|
|
1661
|
+
...require("./types")
|
|
1662
|
+
});
|