@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,80 +1,37 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
2
18
|
|
|
3
|
-
|
|
4
|
-
|
|
19
|
+
// src/modules/Order/types.ts
|
|
20
|
+
var types_exports = {};
|
|
21
|
+
__export(types_exports, {
|
|
22
|
+
OrderHooks: () => OrderHooks
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(types_exports);
|
|
25
|
+
var OrderHooks = /* @__PURE__ */ ((OrderHooks2) => {
|
|
26
|
+
OrderHooks2["OnOrderCreate"] = "order:onOrderCreate";
|
|
27
|
+
OrderHooks2["OnOrderUpdate"] = "order:onOrderUpdate";
|
|
28
|
+
OrderHooks2["OnOrderCancel"] = "order:onOrderCancel";
|
|
29
|
+
OrderHooks2["OnOrderStatusChange"] = "order:onOrderStatusChange";
|
|
30
|
+
OrderHooks2["OnOrderCustomerChange"] = "order:onOrderCustomerChange";
|
|
31
|
+
OrderHooks2["OnPromotionApplied"] = "order:onPromotionApplied";
|
|
32
|
+
return OrderHooks2;
|
|
33
|
+
})(OrderHooks || {});
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
OrderHooks
|
|
5
37
|
});
|
|
6
|
-
exports.OrderHooks = void 0;
|
|
7
|
-
let OrderHooks = exports.OrderHooks = /*#__PURE__*/function (OrderHooks) {
|
|
8
|
-
OrderHooks["OnOrderCreate"] = "order:onOrderCreate";
|
|
9
|
-
OrderHooks["OnOrderUpdate"] = "order:onOrderUpdate";
|
|
10
|
-
OrderHooks["OnOrderCancel"] = "order:onOrderCancel";
|
|
11
|
-
OrderHooks["OnOrderStatusChange"] = "order:onOrderStatusChange";
|
|
12
|
-
OrderHooks["OnOrderCustomerChange"] = "order:onOrderCustomerChange";
|
|
13
|
-
OrderHooks["OnPromotionApplied"] = "order:onPromotionApplied";
|
|
14
|
-
return OrderHooks;
|
|
15
|
-
}({});
|
|
16
|
-
/**
|
|
17
|
-
* 促销评估器协议(OS 与 PromotionEvaluator 之间的桥接接口)。
|
|
18
|
-
*
|
|
19
|
-
* 与 `pisell_os/src/model/strategy/adapter/promotion/evaluator.ts` 中的
|
|
20
|
-
* `PromotionEvaluator` 实例结构保持兼容。SalesSdkProvider 会从 `appHelper.utils.promotionEvaluator`
|
|
21
|
-
* 读取实例并通过 `setPromotionEvaluator` 注入到 OrderModule。
|
|
22
|
-
*
|
|
23
|
-
* 这里只声明 OrderModule 需要调用的子集,避免反向依赖具体 evaluator 实现。
|
|
24
|
-
*/
|
|
25
|
-
/** 赠品解析回调 context(OS → SDK 的请求体) */
|
|
26
|
-
/**
|
|
27
|
-
* 赠品 resolver 返回值。
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* return { products: [giftProduct], bookings: [giftBooking] };
|
|
31
|
-
*/
|
|
32
|
-
/**
|
|
33
|
-
* 赠品解析回调签名(SDK → OS 的返回值)。
|
|
34
|
-
*
|
|
35
|
-
* - 单选项:SDK 内部自动构造商品,不弹窗
|
|
36
|
-
* - 多选项:SDK 弹窗等用户确认后构造
|
|
37
|
-
* - 用户取消:抛错或返回空数组(OS 视为放弃本次添加)
|
|
38
|
-
*
|
|
39
|
-
* 返回数组时沿用旧协议,只写 tempOrder.products;返回对象时可同时写入预约 bookings。
|
|
40
|
-
*/
|
|
41
|
-
/** 未满足的促销策略(购物车底部 alert 渲染源) */
|
|
42
|
-
/** 上一次 applyPromotion 计算出的赠品操作(仅供调试/读取使用) */
|
|
43
|
-
/** onPromotionApplied 事件 payload */
|
|
44
|
-
/**
|
|
45
|
-
* tempOrder 上的下单客户协议字段视图。
|
|
46
|
-
* 这些字段会随订单提交到后端。
|
|
47
|
-
*
|
|
48
|
-
* customer_id 与 OrderTempOrder.customer_id 保持一致(number | null),
|
|
49
|
-
* 调用方若持有 string id(如 ICustomer.id 联合类型),需自行 Number() 转型。
|
|
50
|
-
*/
|
|
51
|
-
/**
|
|
52
|
-
* 写入下单客户的协议字段输入。
|
|
53
|
-
* `customer_id` 必传(null 表示无客户);其余字段缺省视为「清空」(全量覆盖语义)。
|
|
54
|
-
*/
|
|
55
|
-
/**
|
|
56
|
-
* 下单客户变更事件 payload。
|
|
57
|
-
* - `patch`:tempOrder 上的协议字段视图(会随订单提交)
|
|
58
|
-
* - `snapshot`:UI 富字段快照(仅本地,不随订单提交)
|
|
59
|
-
* 清空时整个 payload 为 null。
|
|
60
|
-
*/
|
|
61
|
-
/** 更新购物车行:仅传 SKU 时命中同 SKU 第一行;多行同 SKU 须传 unique_identification_number / 选项指纹等 */
|
|
62
|
-
/** 仅更新购物车行数量;行定位语义与 updateOrderProduct / removeProductFromOrder 保持一致 */
|
|
63
|
-
/**
|
|
64
|
-
* 订单信息
|
|
65
|
-
*/
|
|
66
|
-
/**
|
|
67
|
-
* 支付项数据
|
|
68
|
-
*/
|
|
69
|
-
/**
|
|
70
|
-
* Checkout 专用订单创建参数
|
|
71
|
-
*/
|
|
72
|
-
/**
|
|
73
|
-
* 取消订单参数
|
|
74
|
-
*/
|
|
75
|
-
/**
|
|
76
|
-
* 变更预约状态参数
|
|
77
|
-
*/
|
|
78
|
-
/**
|
|
79
|
-
* 订单模块 API
|
|
80
|
-
*/
|
|
@@ -1,72 +1,99 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
2
18
|
|
|
3
|
-
|
|
4
|
-
|
|
19
|
+
// src/modules/Order/utils/bundleDiscountHydration.ts
|
|
20
|
+
var bundleDiscountHydration_exports = {};
|
|
21
|
+
__export(bundleDiscountHydration_exports, {
|
|
22
|
+
expandHydratedProductsForDiscountCollection: () => expandHydratedProductsForDiscountCollection,
|
|
23
|
+
restoreHydratedBundleDiscounts: () => restoreHydratedBundleDiscounts
|
|
5
24
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
const BUNDLE_MAP_ID_KEY = 'custom_product_bundle_map_id';
|
|
25
|
+
module.exports = __toCommonJS(bundleDiscountHydration_exports);
|
|
26
|
+
var BUNDLE_MAP_ID_KEY = "custom_product_bundle_map_id";
|
|
9
27
|
function getBundleMapId(bundle) {
|
|
10
|
-
|
|
11
|
-
|
|
28
|
+
var _a;
|
|
29
|
+
const metadataMapId = (_a = bundle == null ? void 0 : bundle.metadata) == null ? void 0 : _a[BUNDLE_MAP_ID_KEY];
|
|
30
|
+
if (metadataMapId !== void 0 && metadataMapId !== null && metadataMapId !== "") {
|
|
12
31
|
return String(metadataMapId);
|
|
13
32
|
}
|
|
14
|
-
if (bundle
|
|
33
|
+
if ((bundle == null ? void 0 : bundle._id) !== void 0 && bundle._id !== null && bundle._id !== "") {
|
|
15
34
|
return String(bundle._id);
|
|
16
35
|
}
|
|
17
36
|
return null;
|
|
18
37
|
}
|
|
19
38
|
function getDiscountBundleMapId(discount) {
|
|
20
|
-
|
|
21
|
-
|
|
39
|
+
var _a;
|
|
40
|
+
const mapId = (_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a[BUNDLE_MAP_ID_KEY];
|
|
41
|
+
if (mapId === void 0 || mapId === null || mapId === "")
|
|
42
|
+
return null;
|
|
22
43
|
return String(mapId);
|
|
23
44
|
}
|
|
24
45
|
function hasSameBundleDiscount(discountList, discount) {
|
|
46
|
+
var _a;
|
|
25
47
|
const targetOrderDiscountId = discount.order_discount_id;
|
|
26
|
-
if (targetOrderDiscountId !==
|
|
27
|
-
return discountList.some(item => item
|
|
48
|
+
if (targetOrderDiscountId !== void 0 && targetOrderDiscountId !== null) {
|
|
49
|
+
return discountList.some((item) => (item == null ? void 0 : item.order_discount_id) === targetOrderDiscountId);
|
|
28
50
|
}
|
|
29
|
-
const targetResourceId = discount
|
|
51
|
+
const targetResourceId = ((_a = discount == null ? void 0 : discount.discount) == null ? void 0 : _a.resource_id) ?? (discount == null ? void 0 : discount.resource_id) ?? (discount == null ? void 0 : discount.discount_id);
|
|
30
52
|
const targetMapId = getDiscountBundleMapId(discount);
|
|
31
|
-
return discountList.some(item => {
|
|
32
|
-
|
|
33
|
-
|
|
53
|
+
return discountList.some((item) => {
|
|
54
|
+
var _a2;
|
|
55
|
+
const resourceId = ((_a2 = item == null ? void 0 : item.discount) == null ? void 0 : _a2.resource_id) ?? (item == null ? void 0 : item.resource_id) ?? (item == null ? void 0 : item.discount_id);
|
|
56
|
+
return resourceId === targetResourceId && String((item == null ? void 0 : item.amount) ?? "") === String((discount == null ? void 0 : discount.amount) ?? "") && getDiscountBundleMapId(item) === targetMapId;
|
|
34
57
|
});
|
|
35
58
|
}
|
|
36
59
|
function restoreHydratedBundleDiscounts(product, normalizeDiscountList) {
|
|
37
60
|
if (!Array.isArray(product.product_bundle) || !Array.isArray(product.discount_list)) {
|
|
38
61
|
return product;
|
|
39
62
|
}
|
|
40
|
-
const bundleByMapId = new Map();
|
|
41
|
-
product.product_bundle.forEach(bundle => {
|
|
42
|
-
if (!bundle || typeof bundle !==
|
|
63
|
+
const bundleByMapId = /* @__PURE__ */ new Map();
|
|
64
|
+
product.product_bundle.forEach((bundle) => {
|
|
65
|
+
if (!bundle || typeof bundle !== "object")
|
|
66
|
+
return;
|
|
43
67
|
const mapId = getBundleMapId(bundle);
|
|
44
|
-
if (mapId)
|
|
68
|
+
if (mapId)
|
|
69
|
+
bundleByMapId.set(mapId, bundle);
|
|
45
70
|
});
|
|
46
|
-
if (!bundleByMapId.size)
|
|
71
|
+
if (!bundleByMapId.size)
|
|
72
|
+
return product;
|
|
47
73
|
const mainDiscountList = [];
|
|
48
74
|
const bundleDiscounts = [];
|
|
49
|
-
product.discount_list.forEach(discount => {
|
|
75
|
+
product.discount_list.forEach((discount) => {
|
|
50
76
|
const mapId = getDiscountBundleMapId(discount);
|
|
51
77
|
if (mapId && bundleByMapId.has(mapId)) {
|
|
52
|
-
bundleDiscounts.push({
|
|
53
|
-
mapId,
|
|
54
|
-
discount
|
|
55
|
-
});
|
|
78
|
+
bundleDiscounts.push({ mapId, discount });
|
|
56
79
|
} else {
|
|
57
80
|
mainDiscountList.push(discount);
|
|
58
81
|
}
|
|
59
82
|
});
|
|
60
|
-
if (!bundleDiscounts.length)
|
|
83
|
+
if (!bundleDiscounts.length)
|
|
84
|
+
return product;
|
|
61
85
|
return {
|
|
62
86
|
...product,
|
|
63
87
|
discount_list: normalizeDiscountList(mainDiscountList),
|
|
64
|
-
product_bundle: product.product_bundle.map(bundle => {
|
|
65
|
-
if (!bundle || typeof bundle !==
|
|
88
|
+
product_bundle: product.product_bundle.map((bundle) => {
|
|
89
|
+
if (!bundle || typeof bundle !== "object")
|
|
90
|
+
return bundle;
|
|
66
91
|
const mapId = getBundleMapId(bundle);
|
|
67
|
-
if (!mapId)
|
|
68
|
-
|
|
69
|
-
|
|
92
|
+
if (!mapId)
|
|
93
|
+
return bundle;
|
|
94
|
+
const matchedDiscounts = bundleDiscounts.filter((item) => item.mapId === mapId).map((item) => item.discount);
|
|
95
|
+
if (!matchedDiscounts.length)
|
|
96
|
+
return bundle;
|
|
70
97
|
const currentDiscountList = Array.isArray(bundle.discount_list) ? [...bundle.discount_list] : [];
|
|
71
98
|
for (const discount of matchedDiscounts) {
|
|
72
99
|
if (!hasSameBundleDiscount(currentDiscountList, discount)) {
|
|
@@ -77,7 +104,7 @@ function restoreHydratedBundleDiscounts(product, normalizeDiscountList) {
|
|
|
77
104
|
...bundle,
|
|
78
105
|
discount_list: normalizeDiscountList(currentDiscountList),
|
|
79
106
|
metadata: {
|
|
80
|
-
...
|
|
107
|
+
...bundle.metadata || {},
|
|
81
108
|
[BUNDLE_MAP_ID_KEY]: mapId
|
|
82
109
|
}
|
|
83
110
|
};
|
|
@@ -88,19 +115,25 @@ function expandHydratedProductsForDiscountCollection(products) {
|
|
|
88
115
|
const expanded = [];
|
|
89
116
|
for (const product of products || []) {
|
|
90
117
|
expanded.push(product);
|
|
91
|
-
for (const bundle of product
|
|
92
|
-
if (!Array.isArray(bundle
|
|
118
|
+
for (const bundle of (product == null ? void 0 : product.product_bundle) || []) {
|
|
119
|
+
if (!Array.isArray(bundle == null ? void 0 : bundle.discount_list) || bundle.discount_list.length === 0)
|
|
120
|
+
continue;
|
|
93
121
|
expanded.push({
|
|
94
122
|
...product,
|
|
95
|
-
product_id: bundle.bundle_product_id ?? bundle._bundle_product_id ?? bundle.product_id ?? product
|
|
96
|
-
num: bundle.num ?? bundle.quantity ?? product
|
|
97
|
-
product_quantity: bundle.quantity ?? bundle.num ?? product
|
|
123
|
+
product_id: bundle.bundle_product_id ?? bundle._bundle_product_id ?? bundle.product_id ?? (product == null ? void 0 : product.product_id),
|
|
124
|
+
num: bundle.num ?? bundle.quantity ?? (product == null ? void 0 : product.num),
|
|
125
|
+
product_quantity: bundle.quantity ?? bundle.num ?? (product == null ? void 0 : product.product_quantity),
|
|
98
126
|
original_price: bundle.original_price ?? bundle.product_price ?? bundle.price,
|
|
99
127
|
selling_price: bundle.bundle_selling_price ?? bundle.price,
|
|
100
|
-
is_charge_tax: bundle.is_charge_tax ?? product
|
|
128
|
+
is_charge_tax: bundle.is_charge_tax ?? (product == null ? void 0 : product.is_charge_tax),
|
|
101
129
|
discount_list: bundle.discount_list
|
|
102
130
|
});
|
|
103
131
|
}
|
|
104
132
|
}
|
|
105
133
|
return expanded;
|
|
106
|
-
}
|
|
134
|
+
}
|
|
135
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
136
|
+
0 && (module.exports = {
|
|
137
|
+
expandHydratedProductsForDiscountCollection,
|
|
138
|
+
restoreHydratedBundleDiscounts
|
|
139
|
+
});
|
|
@@ -1,98 +1,113 @@
|
|
|
1
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
2
28
|
|
|
3
|
-
|
|
4
|
-
|
|
29
|
+
// src/modules/Order/utils/manualProductDiscount.ts
|
|
30
|
+
var manualProductDiscount_exports = {};
|
|
31
|
+
__export(manualProductDiscount_exports, {
|
|
32
|
+
buildManualProductDiscountItem: () => buildManualProductDiscountItem,
|
|
33
|
+
ensureManualProductDiscountList: () => ensureManualProductDiscountList,
|
|
34
|
+
findManualProductDiscountItem: () => findManualProductDiscountItem,
|
|
35
|
+
hasManualProductDiscountFlag: () => hasManualProductDiscountFlag,
|
|
36
|
+
mergeManualProductDiscountIntoList: () => mergeManualProductDiscountIntoList,
|
|
37
|
+
resolveManualDiscountMessage: () => resolveManualDiscountMessage,
|
|
38
|
+
resolveManualDiscountOriginTotal: () => resolveManualDiscountOriginTotal,
|
|
39
|
+
resolveManualDiscountReasonFromSources: () => resolveManualDiscountReasonFromSources,
|
|
40
|
+
resolveSafeProductNum: () => resolveSafeProductNum,
|
|
41
|
+
shouldBuildManualProductDiscount: () => shouldBuildManualProductDiscount,
|
|
42
|
+
stripManualProductDiscountItems: () => stripManualProductDiscountItems,
|
|
43
|
+
syncManualProductDiscountProductNum: () => syncManualProductDiscountProductNum
|
|
5
44
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
exports.findManualProductDiscountItem = findManualProductDiscountItem;
|
|
9
|
-
exports.hasManualProductDiscountFlag = hasManualProductDiscountFlag;
|
|
10
|
-
exports.mergeManualProductDiscountIntoList = mergeManualProductDiscountIntoList;
|
|
11
|
-
exports.resolveManualDiscountMessage = resolveManualDiscountMessage;
|
|
12
|
-
exports.resolveManualDiscountOriginTotal = resolveManualDiscountOriginTotal;
|
|
13
|
-
exports.resolveManualDiscountReasonFromSources = resolveManualDiscountReasonFromSources;
|
|
14
|
-
exports.resolveSafeProductNum = resolveSafeProductNum;
|
|
15
|
-
exports.shouldBuildManualProductDiscount = shouldBuildManualProductDiscount;
|
|
16
|
-
exports.stripManualProductDiscountItems = stripManualProductDiscountItems;
|
|
17
|
-
exports.syncManualProductDiscountProductNum = syncManualProductDiscountProductNum;
|
|
18
|
-
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
19
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
|
-
/** 解析商品行数量(checkout 协议 product_num 语义 = 当前行 num) */
|
|
45
|
+
module.exports = __toCommonJS(manualProductDiscount_exports);
|
|
46
|
+
var import_decimal = __toESM(require("decimal.js"));
|
|
21
47
|
function resolveSafeProductNum(num) {
|
|
22
48
|
const parsed = Number(num);
|
|
23
|
-
if (!Number.isFinite(parsed) || parsed <= 0)
|
|
49
|
+
if (!Number.isFinite(parsed) || parsed <= 0)
|
|
50
|
+
return 1;
|
|
24
51
|
return Math.floor(parsed);
|
|
25
52
|
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* 将 discount_list 中 type=product 项的 product_num 同步为当前商品数量。
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* syncManualProductDiscountProductNum(line.discount_list, line.num);
|
|
32
|
-
*/
|
|
33
53
|
function syncManualProductDiscountProductNum(discountList, productNum) {
|
|
34
54
|
const quantity = resolveSafeProductNum(productNum);
|
|
35
|
-
return (discountList || []).map(item => {
|
|
36
|
-
if (item
|
|
55
|
+
return (discountList || []).map((item) => {
|
|
56
|
+
if ((item == null ? void 0 : item.type) !== "product")
|
|
57
|
+
return item;
|
|
37
58
|
return {
|
|
38
59
|
...item,
|
|
39
60
|
discount: {
|
|
40
|
-
...
|
|
61
|
+
...item.discount || {},
|
|
41
62
|
product_num: quantity
|
|
42
63
|
}
|
|
43
64
|
};
|
|
44
65
|
});
|
|
45
66
|
}
|
|
46
|
-
|
|
47
|
-
/** 从多源解析改价前行总价(与 cacheItem._extend.origin_total 语义一致) */
|
|
48
67
|
function resolveManualDiscountOriginTotal(sources) {
|
|
49
|
-
const candidates = [
|
|
68
|
+
const candidates = [
|
|
69
|
+
sources.originTotal,
|
|
70
|
+
sources.extendOriginTotal,
|
|
71
|
+
sources.originExtendOriginTotal,
|
|
72
|
+
sources.sourceExtendOriginTotal
|
|
73
|
+
];
|
|
50
74
|
for (const candidate of candidates) {
|
|
51
|
-
if (candidate ===
|
|
75
|
+
if (candidate === void 0 || candidate === null || candidate === "")
|
|
76
|
+
continue;
|
|
52
77
|
const parsed = Number(candidate);
|
|
53
|
-
if (Number.isFinite(parsed))
|
|
78
|
+
if (Number.isFinite(parsed))
|
|
79
|
+
return parsed;
|
|
54
80
|
}
|
|
55
81
|
const unit = Number(sources.catalogUnitPrice);
|
|
56
82
|
const quantity = sources.quantity ?? 1;
|
|
57
83
|
if (Number.isFinite(unit) && unit > 0) {
|
|
58
|
-
return new
|
|
84
|
+
return new import_decimal.default(unit).mul(quantity).toNumber();
|
|
59
85
|
}
|
|
60
86
|
return NaN;
|
|
61
87
|
}
|
|
62
|
-
|
|
63
|
-
/** 从 payload / extend / origin 解析手动折扣原因 */
|
|
64
88
|
function resolveManualDiscountReasonFromSources(sources) {
|
|
65
|
-
for (const candidate of [
|
|
66
|
-
|
|
89
|
+
for (const candidate of [
|
|
90
|
+
sources.discountReason,
|
|
91
|
+
sources.extendDiscountReason,
|
|
92
|
+
sources.originExtendDiscountReason
|
|
93
|
+
]) {
|
|
94
|
+
if (candidate != null && String(candidate).trim() !== "") {
|
|
67
95
|
return String(candidate);
|
|
68
96
|
}
|
|
69
97
|
}
|
|
70
|
-
return
|
|
98
|
+
return "";
|
|
71
99
|
}
|
|
72
|
-
|
|
73
|
-
/** 是否带手动改价标记(price_override / is_manual_discount) */
|
|
74
100
|
function hasManualProductDiscountFlag(metadata) {
|
|
75
|
-
if (!metadata)
|
|
101
|
+
if (!metadata)
|
|
102
|
+
return false;
|
|
76
103
|
const override = metadata.price_override;
|
|
77
|
-
if (override !==
|
|
104
|
+
if (override !== void 0 && override !== null && override !== "") {
|
|
78
105
|
return true;
|
|
79
106
|
}
|
|
80
107
|
return metadata.is_manual_discount === 1 || metadata.is_manual_discount === true;
|
|
81
108
|
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* normalize 兜底:手动改价但 discount_list 缺 type=product 时,按行级原价/折后价补写。
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* ensureManualProductDiscountList({
|
|
88
|
-
* discountList: [],
|
|
89
|
-
* metadata: { price_override: '5', is_manual_discount: 1 },
|
|
90
|
-
* originalPrice: '11.00',
|
|
91
|
-
* sellingPrice: '5.00',
|
|
92
|
-
* quantity: 1,
|
|
93
|
-
* });
|
|
94
|
-
*/
|
|
95
109
|
function ensureManualProductDiscountList(params) {
|
|
110
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
96
111
|
const list = params.discountList || [];
|
|
97
112
|
const quantity = resolveSafeProductNum(params.quantity);
|
|
98
113
|
if (findManualProductDiscountItem(list)) {
|
|
@@ -113,95 +128,79 @@ function ensureManualProductDiscountList(params) {
|
|
|
113
128
|
if (!Number.isFinite(originalNum) || !Number.isFinite(sellingNum) || originalNum === sellingNum) {
|
|
114
129
|
return list;
|
|
115
130
|
}
|
|
116
|
-
const message = resolveManualDiscountMessage(
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
131
|
+
const message = resolveManualDiscountMessage(
|
|
132
|
+
list,
|
|
133
|
+
resolveManualDiscountReasonFromSources({
|
|
134
|
+
extendDiscountReason: (_b = (_a = metadata.origin) == null ? void 0 : _a._extend) == null ? void 0 : _b.discount_reason,
|
|
135
|
+
originExtendDiscountReason: (_d = (_c = metadata.origin) == null ? void 0 : _c._extend) == null ? void 0 : _d.discount_reason
|
|
136
|
+
})
|
|
137
|
+
);
|
|
138
|
+
return mergeManualProductDiscountIntoList(
|
|
139
|
+
list,
|
|
140
|
+
buildManualProductDiscountItem({
|
|
141
|
+
originTotal: originalNum,
|
|
142
|
+
sellingTotal: sellingNum,
|
|
143
|
+
quantity,
|
|
144
|
+
message,
|
|
145
|
+
discountway: (_f = (_e = metadata.origin) == null ? void 0 : _e._extend) == null ? void 0 : _f.discountway,
|
|
146
|
+
discount_per: (_h = (_g = metadata.origin) == null ? void 0 : _g._extend) == null ? void 0 : _h.discount_per
|
|
147
|
+
})
|
|
148
|
+
);
|
|
128
149
|
}
|
|
129
|
-
|
|
130
|
-
/** 商品手动折扣 discount_list 项(checkout 协议,type = product) */
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* 从 discount_list 中取手动改价项(type = product)。
|
|
134
|
-
*
|
|
135
|
-
* @example
|
|
136
|
-
* const manual = findManualProductDiscountItem(product.discount_list);
|
|
137
|
-
* manual?.discount.message; // 折扣原因
|
|
138
|
-
*/
|
|
139
150
|
function findManualProductDiscountItem(discountList) {
|
|
140
|
-
return (discountList || []).find(item => item
|
|
151
|
+
return (discountList || []).find((item) => (item == null ? void 0 : item.type) === "product");
|
|
141
152
|
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* 解析折扣原因:优先 discount_list[type=product].discount.message。
|
|
145
|
-
*
|
|
146
|
-
* @example
|
|
147
|
-
* resolveManualDiscountMessage(line.discount_list, line.metadata?.legacy_reason);
|
|
148
|
-
*/
|
|
149
153
|
function resolveManualDiscountMessage(discountList, fallback) {
|
|
150
|
-
|
|
151
|
-
|
|
154
|
+
var _a, _b;
|
|
155
|
+
const message = (_b = (_a = findManualProductDiscountItem(discountList)) == null ? void 0 : _a.discount) == null ? void 0 : _b.message;
|
|
156
|
+
if (message != null && String(message).trim() !== "") {
|
|
152
157
|
return String(message);
|
|
153
158
|
}
|
|
154
|
-
return fallback ??
|
|
159
|
+
return fallback ?? "";
|
|
155
160
|
}
|
|
156
|
-
|
|
157
|
-
/** 去掉 discount_list 中已有的手动改价项,避免重复叠加 */
|
|
158
161
|
function stripManualProductDiscountItems(discountList) {
|
|
159
|
-
return (discountList || []).filter(item => item
|
|
162
|
+
return (discountList || []).filter((item) => (item == null ? void 0 : item.type) !== "product");
|
|
160
163
|
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* 由改价前后行总价构建手动折扣项;amount = |originTotal - sellingTotal|(行级差额)。
|
|
164
|
-
*
|
|
165
|
-
* @example
|
|
166
|
-
* buildManualProductDiscountItem({
|
|
167
|
-
* originTotal: 11,
|
|
168
|
-
* sellingTotal: 4,
|
|
169
|
-
* quantity: 1,
|
|
170
|
-
* message: 'VIP',
|
|
171
|
-
* });
|
|
172
|
-
*/
|
|
173
164
|
function buildManualProductDiscountItem(params) {
|
|
174
|
-
const origin = new
|
|
175
|
-
const selling = new
|
|
165
|
+
const origin = new import_decimal.default(Number(params.originTotal) || 0);
|
|
166
|
+
const selling = new import_decimal.default(Number(params.sellingTotal) || 0);
|
|
176
167
|
const diff = origin.minus(selling);
|
|
177
168
|
const quantity = resolveSafeProductNum(params.quantity);
|
|
178
169
|
return {
|
|
179
170
|
amount: diff.toDecimalPlaces(2).toNumber(),
|
|
180
|
-
type:
|
|
171
|
+
type: "product",
|
|
181
172
|
discount: {
|
|
182
|
-
message: params.message ??
|
|
183
|
-
discountway: params.discountway ??
|
|
173
|
+
message: params.message ?? "",
|
|
174
|
+
discountway: params.discountway ?? "num",
|
|
184
175
|
product_num: quantity,
|
|
185
|
-
discount_per: params.discount_per ??
|
|
186
|
-
discount_type: diff.isNegative() ?
|
|
176
|
+
discount_per: params.discount_per ?? "",
|
|
177
|
+
discount_type: diff.isNegative() ? "change_price" : "discount"
|
|
187
178
|
}
|
|
188
179
|
};
|
|
189
180
|
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* 将手动改价项合并进 discount_list(替换已有 type=product 项)。
|
|
193
|
-
*
|
|
194
|
-
* @example
|
|
195
|
-
* mergeManualProductDiscountIntoList(coupons, manualItem);
|
|
196
|
-
*/
|
|
197
181
|
function mergeManualProductDiscountIntoList(discountList, manualItem) {
|
|
198
182
|
const base = stripManualProductDiscountItems(discountList);
|
|
199
|
-
if (!manualItem)
|
|
200
|
-
|
|
183
|
+
if (!manualItem)
|
|
184
|
+
return base;
|
|
185
|
+
if (manualItem.amount === 0 && !manualItem.discount.message)
|
|
186
|
+
return base;
|
|
201
187
|
return [...base, manualItem];
|
|
202
188
|
}
|
|
203
|
-
|
|
204
|
-
/** 是否应写入手动改价 discount_list 项 */
|
|
205
189
|
function shouldBuildManualProductDiscount(params) {
|
|
206
190
|
return Boolean(params.hasPriceOverride);
|
|
207
|
-
}
|
|
191
|
+
}
|
|
192
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
193
|
+
0 && (module.exports = {
|
|
194
|
+
buildManualProductDiscountItem,
|
|
195
|
+
ensureManualProductDiscountList,
|
|
196
|
+
findManualProductDiscountItem,
|
|
197
|
+
hasManualProductDiscountFlag,
|
|
198
|
+
mergeManualProductDiscountIntoList,
|
|
199
|
+
resolveManualDiscountMessage,
|
|
200
|
+
resolveManualDiscountOriginTotal,
|
|
201
|
+
resolveManualDiscountReasonFromSources,
|
|
202
|
+
resolveSafeProductNum,
|
|
203
|
+
shouldBuildManualProductDiscount,
|
|
204
|
+
stripManualProductDiscountItems,
|
|
205
|
+
syncManualProductDiscountProductNum
|
|
206
|
+
});
|