@pisell/pisellos 0.10.15 → 0.10.17
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 +6 -9
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/model/strategy/adapter/walletPass/example.js +3 -26
- package/dist/model/strategy/strategy-example.js +5 -19
- package/dist/modules/Cart/index.js +0 -3
- package/dist/modules/Cart/utils/cartProduct.js +0 -1
- package/dist/modules/Date/index.js +1 -5
- package/dist/modules/Discount/index.js +2 -4
- package/dist/modules/OpenData/index.d.ts +5 -2
- package/dist/modules/OpenData/index.js +27 -14
- package/dist/modules/OpenData/types.d.ts +42 -0
- package/dist/modules/OpenData/types.js +7 -1
- package/dist/modules/OpenData/utils.d.ts +15 -1
- package/dist/modules/OpenData/utils.js +85 -0
- package/dist/modules/Order/index.d.ts +4 -2
- package/dist/modules/Order/index.js +131 -123
- package/dist/modules/Order/types.d.ts +8 -1
- package/dist/modules/Order/types.js +1 -0
- package/dist/modules/Order/utils.js +7 -1
- package/dist/modules/Payment/index.js +97 -162
- package/dist/modules/Product/types.d.ts +2 -0
- package/dist/modules/ProductList/index.js +96 -74
- package/dist/modules/Rules/index.js +12 -12
- package/dist/modules/SalesSummary/index.js +6 -4
- package/dist/modules/Schedule/index.js +0 -1
- package/dist/modules/Schedule/utils.js +0 -1
- package/dist/modules/Step/index.js +0 -1
- package/dist/plugins/request.js +1 -4
- package/dist/plugins/window.js +2 -6
- package/dist/server/index.d.ts +11 -0
- package/dist/server/index.js +977 -641
- package/dist/server/modules/menu/index.js +32 -41
- package/dist/server/modules/order/index.d.ts +8 -0
- package/dist/server/modules/order/index.js +253 -219
- package/dist/server/modules/products/index.js +24 -42
- package/dist/server/modules/quotation/index.js +29 -38
- package/dist/server/modules/resource/index.js +3 -4
- package/dist/server/modules/schedule/index.js +27 -35
- package/dist/server/utils/product.js +0 -1
- package/dist/server/utils/small-ticket.d.ts +9 -1
- package/dist/server/utils/small-ticket.js +117 -43
- package/dist/solution/BaseSales/index.d.ts +7 -0
- package/dist/solution/BaseSales/index.js +350 -215
- package/dist/solution/BaseSales/types.d.ts +2 -0
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +5 -0
- package/dist/solution/BaseSales/utils/cartPromotion.js +15 -6
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +3 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +7 -1
- package/dist/solution/BaseSales/utils.js +6 -3
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingByStep/index.js +7 -59
- package/dist/solution/BookingByStep/utils/capacity.js +1 -11
- package/dist/solution/BookingByStep/utils/resources.js +1 -3
- package/dist/solution/BookingByStep/utils/timeslots.js +2 -43
- package/dist/solution/BookingTicket/index.d.ts +14 -19
- package/dist/solution/BookingTicket/index.js +553 -433
- package/dist/solution/BookingTicket/utils/addProductDecision.js +3 -1
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +6 -7
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +25 -31
- package/dist/solution/BookingTicket/utils/scan/index.js +6 -10
- package/dist/solution/BuyTickets/index.js +9 -12
- package/dist/solution/Checkout/index.js +177 -252
- package/dist/solution/Checkout/utils/index.js +4 -16
- package/dist/solution/RegisterAndLogin/index.js +30 -76
- package/dist/solution/Sales/index.d.ts +20 -4
- package/dist/solution/Sales/index.js +348 -75
- package/dist/solution/Sales/types.d.ts +10 -0
- package/dist/solution/ScanOrder/index.js +50 -60
- package/dist/solution/ScanOrder/types.d.ts +2 -0
- package/dist/solution/ScanOrder/utils.js +6 -3
- package/dist/solution/ShopDiscount/index.js +2 -7
- package/dist/solution/UnifiedBookingSales/index.d.ts +5 -4
- package/dist/solution/UnifiedBookingSales/index.js +495 -422
- package/dist/solution/UnifiedBookingSales/types.d.ts +7 -1
- package/dist/solution/VenueBooking/index.js +45 -55
- package/dist/utils/task.js +15 -18
- package/dist/utils/watch.js +0 -1
- package/lib/apis/picoding.js +2 -0
- package/lib/core/index.js +131 -131
- package/lib/effects/index.js +46 -57
- package/lib/index.js +82 -49
- package/lib/model/index.js +14 -21
- package/lib/model/strategy/adapter/dataVariant/adapter.js +38 -50
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +209 -315
- package/lib/model/strategy/adapter/dataVariant/examples.js +229 -237
- package/lib/model/strategy/adapter/dataVariant/index.js +39 -34
- package/lib/model/strategy/adapter/dataVariant/type.js +57 -28
- package/lib/model/strategy/adapter/index.js +100 -64
- package/lib/model/strategy/adapter/itemRule/adapter.js +156 -144
- package/lib/model/strategy/adapter/itemRule/evaluator.js +36 -48
- package/lib/model/strategy/adapter/itemRule/examples.js +295 -225
- package/lib/model/strategy/adapter/itemRule/index.js +83 -57
- package/lib/model/strategy/adapter/itemRule/type.js +97 -36
- package/lib/model/strategy/adapter/promotion/adapter.js +91 -69
- package/lib/model/strategy/adapter/promotion/evaluator.js +444 -310
- package/lib/model/strategy/adapter/promotion/examples.js +222 -234
- package/lib/model/strategy/adapter/promotion/index.js +1 -51
- package/lib/model/strategy/adapter/promotion/type.js +243 -36
- package/lib/model/strategy/adapter/type.js +4 -16
- package/lib/model/strategy/adapter/walletPass/evaluator.js +180 -150
- package/lib/model/strategy/adapter/walletPass/example.js +217 -190
- package/lib/model/strategy/adapter/walletPass/index.js +75 -51
- package/lib/model/strategy/adapter/walletPass/locales.js +36 -58
- package/lib/model/strategy/adapter/walletPass/type.js +4 -16
- package/lib/model/strategy/adapter/walletPass/utils.js +588 -378
- package/lib/model/strategy/engine.js +270 -168
- package/lib/model/strategy/index.js +49 -34
- package/lib/model/strategy/strategy-example.js +243 -239
- package/lib/model/strategy/type.js +100 -40
- package/lib/modules/Account/index.js +39 -53
- package/lib/modules/Account/types.js +20 -33
- package/lib/modules/AccountList/index.js +116 -154
- package/lib/modules/AccountList/types.js +30 -31
- package/lib/modules/AccountList/utils.js +18 -30
- package/lib/modules/BaseModule.js +23 -42
- package/lib/modules/BookingContext/index.js +158 -136
- package/lib/modules/BookingContext/types.js +46 -32
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +138 -146
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +78 -83
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +170 -150
- package/lib/modules/BookingContext/utils/flexible.js +38 -55
- package/lib/modules/BookingContext/utils/formatResourceList.js +19 -34
- package/lib/modules/BookingContext/utils/index.js +124 -41
- package/lib/modules/BookingContext/utils/noResource.js +58 -70
- package/lib/modules/BookingContext/utils/orderLineDisplay.js +14 -41
- package/lib/modules/BookingContext/utils/productExtend.js +202 -155
- package/lib/modules/BookingContext/utils/resourceErrors.js +53 -53
- package/lib/modules/BookingContext/utils/resourceSelection.js +19 -41
- package/lib/modules/BookingContext/utils/resources.js +209 -167
- package/lib/modules/BookingContext/utils/serviceTimes.js +115 -116
- package/lib/modules/BookingContext/utils/timeSlices.js +76 -86
- package/lib/modules/Cart/index.js +170 -124
- package/lib/modules/Cart/types.js +46 -51
- package/lib/modules/Cart/utils/cartAccount.js +40 -39
- package/lib/modules/Cart/utils/cartDate.js +56 -61
- package/lib/modules/Cart/utils/cartDiscount.js +28 -33
- package/lib/modules/Cart/utils/cartNote.js +27 -32
- package/lib/modules/Cart/utils/cartProduct.js +321 -251
- package/lib/modules/Cart/utils/cartRelationForms.js +29 -35
- package/lib/modules/Cart/utils/cartResource.js +70 -78
- package/lib/modules/Cart/utils/changePrice.js +22 -50
- package/lib/modules/Cart/utils/index.js +106 -48
- package/lib/modules/Customer/constants.js +13 -34
- package/lib/modules/Customer/index.js +235 -172
- package/lib/modules/Customer/types.js +38 -35
- package/lib/modules/Date/index.js +116 -115
- package/lib/modules/Date/types.js +16 -28
- package/lib/modules/Date/utils.js +174 -123
- package/lib/modules/Discount/index.js +133 -143
- package/lib/modules/Discount/types.js +9 -31
- package/lib/modules/Guests/index.js +30 -56
- package/lib/modules/Guests/types.js +23 -33
- package/lib/modules/Holder/index.js +209 -189
- package/lib/modules/Holder/types.js +4 -16
- package/lib/modules/Holder/utils.js +20 -49
- package/lib/modules/OpenData/index.d.ts +5 -2
- package/lib/modules/OpenData/index.js +119 -78
- package/lib/modules/OpenData/types.d.ts +42 -0
- package/lib/modules/OpenData/types.js +12 -16
- package/lib/modules/OpenData/utils.d.ts +15 -1
- package/lib/modules/OpenData/utils.js +129 -78
- package/lib/modules/Order/index.d.ts +4 -2
- package/lib/modules/Order/index.js +1843 -2251
- package/lib/modules/Order/payment-utils.js +77 -120
- package/lib/modules/Order/types.d.ts +8 -1
- package/lib/modules/Order/types.js +88 -35
- package/lib/modules/Order/utils/bundleDiscountHydration.js +41 -74
- package/lib/modules/Order/utils/discountProductLineIdentity.js +142 -100
- package/lib/modules/Order/utils/manualProductDiscount.js +124 -123
- package/lib/modules/Order/utils/orderCollectionIdentity.js +184 -244
- package/lib/modules/Order/utils/virtualSettlement.js +120 -171
- package/lib/modules/Order/utils.js +834 -668
- package/lib/modules/Payment/cash.js +20 -33
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +145 -76
- package/lib/modules/Payment/eftpos.js +16 -30
- package/lib/modules/Payment/index.js +532 -399
- package/lib/modules/Payment/mx51.js +1 -0
- package/lib/modules/Payment/types.js +230 -108
- package/lib/modules/Payment/utils.js +52 -51
- package/lib/modules/Payment/walletpass.js +485 -660
- package/lib/modules/Product/index.js +51 -46
- package/lib/modules/Product/types.d.ts +2 -0
- package/lib/modules/Product/types.js +4 -16
- package/lib/modules/Product/utils.js +32 -33
- package/lib/modules/ProductList/index.js +141 -161
- package/lib/modules/ProductList/types.js +9 -31
- package/lib/modules/Quotation/index.js +66 -100
- package/lib/modules/Quotation/types.js +4 -16
- package/lib/modules/Resource/index.js +27 -59
- package/lib/modules/Resource/types.js +22 -32
- package/lib/modules/Resource/utils.js +30 -38
- package/lib/modules/ResourcePlanner/index.js +25 -23
- package/lib/modules/ResourcePlanner/localClock.js +54 -119
- package/lib/modules/ResourcePlanner/planner.js +591 -772
- package/lib/modules/ResourcePlanner/types.js +10 -29
- package/lib/modules/Rules/index.js +1224 -963
- package/lib/modules/Rules/types.js +17 -40
- package/lib/modules/SalesSummary/index.js +80 -89
- package/lib/modules/SalesSummary/types.js +4 -16
- package/lib/modules/SalesSummary/utils.js +359 -442
- package/lib/modules/ScanOrderLogger/index.js +59 -79
- package/lib/modules/ScanOrderLogger/providers/feishu.js +54 -78
- package/lib/modules/ScanOrderLogger/providers/grafana.js +13 -36
- package/lib/modules/ScanOrderLogger/types.js +4 -16
- package/lib/modules/Schedule/getDateIsInSchedule.js +334 -163
- package/lib/modules/Schedule/index.js +100 -114
- package/lib/modules/Schedule/type.js +4 -16
- package/lib/modules/Schedule/types.js +4 -16
- package/lib/modules/Schedule/utils.js +433 -291
- package/lib/modules/Step/index.js +40 -52
- package/lib/modules/Step/tyeps.js +4 -16
- package/lib/modules/Summary/index.js +66 -71
- package/lib/modules/Summary/types.js +4 -16
- package/lib/modules/Summary/utils.js +773 -418
- package/lib/modules/SurchargeList/index.js +46 -60
- package/lib/modules/SurchargeList/types.js +4 -16
- package/lib/modules/index.js +245 -63
- package/lib/plugins/app.js +4 -16
- package/lib/plugins/index.js +36 -25
- package/lib/plugins/request.js +137 -126
- package/lib/plugins/shopStore.js +4 -16
- package/lib/plugins/user.js +4 -16
- package/lib/plugins/window.js +171 -179
- package/lib/server/index.d.ts +11 -0
- package/lib/server/index.js +3432 -2757
- package/lib/server/modules/floor-plan/index.js +102 -123
- package/lib/server/modules/floor-plan/types.js +15 -30
- package/lib/server/modules/index.js +106 -68
- package/lib/server/modules/menu/index.js +146 -122
- package/lib/server/modules/menu/types.js +18 -31
- package/lib/server/modules/order/index.d.ts +8 -0
- package/lib/server/modules/order/index.js +781 -956
- package/lib/server/modules/order/types.js +122 -33
- package/lib/server/modules/order/utils/filterBookings.js +219 -194
- package/lib/server/modules/order/utils/filterOrders.js +118 -92
- package/lib/server/modules/payment/index.js +59 -83
- package/lib/server/modules/payment/types.js +4 -16
- package/lib/server/modules/products/index.js +575 -459
- package/lib/server/modules/products/types.js +44 -34
- package/lib/server/modules/quotation/index.js +137 -172
- package/lib/server/modules/quotation/types.js +21 -31
- package/lib/server/modules/resource/index.js +213 -184
- package/lib/server/modules/resource/types.js +42 -33
- package/lib/server/modules/schedule/index.js +135 -123
- package/lib/server/modules/schedule/types.js +14 -21
- package/lib/server/modules/schedule/utils.js +334 -163
- package/lib/server/types.js +4 -16
- package/lib/server/utils/index.js +25 -23
- package/lib/server/utils/product.js +196 -139
- package/lib/server/utils/schedule.js +34 -41
- package/lib/server/utils/small-ticket.d.ts +9 -1
- package/lib/server/utils/small-ticket.js +565 -470
- package/lib/server/utils/time.js +40 -49
- package/lib/solution/BaseSales/index.d.ts +7 -0
- package/lib/solution/BaseSales/index.js +1385 -1503
- package/lib/solution/BaseSales/types.d.ts +2 -0
- package/lib/solution/BaseSales/types.js +42 -38
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +5 -0
- package/lib/solution/BaseSales/utils/cartPromotion.js +652 -498
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +85 -105
- package/lib/solution/BaseSales/utils/quotationPrice.js +56 -114
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +3 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +138 -180
- package/lib/solution/BaseSales/utils.js +161 -143
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingByStep/index.js +1527 -1340
- package/lib/solution/BookingByStep/types.js +40 -99
- package/lib/solution/BookingByStep/utils/capacity.js +192 -160
- package/lib/solution/BookingByStep/utils/products.js +42 -52
- package/lib/solution/BookingByStep/utils/resources.js +527 -330
- package/lib/solution/BookingByStep/utils/stock.js +65 -44
- package/lib/solution/BookingByStep/utils/timeslots.js +129 -131
- package/lib/solution/BookingTicket/index.d.ts +14 -19
- package/lib/solution/BookingTicket/index.js +663 -526
- package/lib/solution/BookingTicket/types.js +99 -77
- package/lib/solution/BookingTicket/utils/addProductDecision.js +229 -190
- package/lib/solution/BookingTicket/utils/addTimeAvailability.js +58 -89
- package/lib/solution/BookingTicket/utils/bookingStatus.js +107 -78
- package/lib/solution/BookingTicket/utils/cartView.js +114 -99
- package/lib/solution/BookingTicket/utils/exampleData.js +185 -0
- package/lib/solution/BookingTicket/utils/orderCustomer.js +18 -41
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +219 -86
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +168 -116
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +79 -91
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +54 -41
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +84 -81
- package/lib/solution/BookingTicket/utils/scan/index.js +98 -104
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +90 -43
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +52 -64
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +56 -58
- package/lib/solution/BookingTicket/utils/weighingProductSku.js +34 -48
- package/lib/solution/BuyTickets/index.js +67 -70
- package/lib/solution/BuyTickets/types.js +22 -38
- package/lib/solution/Checkout/index.js +1451 -1158
- package/lib/solution/Checkout/types.js +91 -61
- package/lib/solution/Checkout/utils/index.js +228 -156
- package/lib/solution/PlaceOrder/index.js +55 -0
- package/lib/solution/RegisterAndLogin/config.js +493 -460
- package/lib/solution/RegisterAndLogin/index.js +633 -630
- package/lib/solution/RegisterAndLogin/types.js +189 -76
- package/lib/solution/RegisterAndLogin/utils.js +183 -125
- package/lib/solution/Sales/index.d.ts +20 -4
- package/lib/solution/Sales/index.js +502 -330
- package/lib/solution/Sales/types.d.ts +10 -0
- package/lib/solution/Sales/types.js +27 -33
- package/lib/solution/ScanOrder/index.js +822 -852
- package/lib/solution/ScanOrder/types.d.ts +2 -0
- package/lib/solution/ScanOrder/types.js +33 -34
- package/lib/solution/ScanOrder/utils.js +412 -374
- package/lib/solution/ShopDiscount/index.js +226 -232
- package/lib/solution/ShopDiscount/types.js +15 -37
- package/lib/solution/ShopDiscount/utils.js +300 -172
- package/lib/solution/UnifiedBookingSales/index.d.ts +5 -4
- package/lib/solution/UnifiedBookingSales/index.js +1087 -1222
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +99 -159
- package/lib/solution/UnifiedBookingSales/types.d.ts +7 -1
- package/lib/solution/UnifiedBookingSales/types.js +10 -32
- package/lib/solution/VenueBooking/index.js +811 -879
- package/lib/solution/VenueBooking/types.js +19 -39
- package/lib/solution/VenueBooking/utils/dateSummary.js +27 -56
- package/lib/solution/VenueBooking/utils/resource.js +31 -54
- package/lib/solution/VenueBooking/utils/slotMerge.js +94 -107
- package/lib/solution/VenueBooking/utils/timeSlot.js +132 -132
- package/lib/solution/VenueBooking/utils.js +130 -67
- package/lib/solution/index.js +124 -41
- package/lib/store/createStore.js +32 -29
- package/lib/types/index.js +4 -16
- package/lib/utils/payment-number.js +26 -46
- package/lib/utils/task.js +36 -36
- package/lib/utils/watch.js +81 -47
- package/package.json +2 -1
|
@@ -1,190 +1,159 @@
|
|
|
1
|
-
|
|
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);
|
|
1
|
+
"use strict";
|
|
28
2
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
__export(virtualSettlement_exports, {
|
|
32
|
-
OrderSettlementConflictError: () => OrderSettlementConflictError,
|
|
33
|
-
VirtualCurrencyAssetNotFoundError: () => VirtualCurrencyAssetNotFoundError,
|
|
34
|
-
VirtualCurrencyBalanceError: () => VirtualCurrencyBalanceError,
|
|
35
|
-
applyTempOrderSettlementState: () => applyTempOrderSettlementState,
|
|
36
|
-
buildCurrencyDisplaySnapshot: () => buildCurrencyDisplaySnapshot,
|
|
37
|
-
getSelectedSettlementSnapshot: () => getSelectedSettlementSnapshot,
|
|
38
|
-
getSettlementKey: () => getSettlementKey,
|
|
39
|
-
getTempOrderSettlementKey: () => getTempOrderSettlementKey,
|
|
40
|
-
getTempOrderSettlementSnapshot: () => getTempOrderSettlementSnapshot,
|
|
41
|
-
isVirtualSettlementDisplayOrder: () => isVirtualSettlementDisplayOrder,
|
|
42
|
-
isVirtualSettlementOrder: () => isVirtualSettlementOrder,
|
|
43
|
-
isVirtualSettlementProduct: () => isVirtualSettlementProduct,
|
|
44
|
-
normalizeVirtualSettlementOrderProduct: () => normalizeVirtualSettlementOrderProduct,
|
|
45
|
-
normalizeVirtualSettlementProducts: () => normalizeVirtualSettlementProducts,
|
|
46
|
-
releaseTempOrderSettlementState: () => releaseTempOrderSettlementState,
|
|
47
|
-
resolveSettlementDisplayValue: () => resolveSettlementDisplayValue
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
48
5
|
});
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
6
|
+
exports.VirtualCurrencyBalanceError = exports.VirtualCurrencyAssetNotFoundError = exports.OrderSettlementConflictError = void 0;
|
|
7
|
+
exports.applyTempOrderSettlementState = applyTempOrderSettlementState;
|
|
8
|
+
exports.buildCurrencyDisplaySnapshot = buildCurrencyDisplaySnapshot;
|
|
9
|
+
exports.getSelectedSettlementSnapshot = getSelectedSettlementSnapshot;
|
|
10
|
+
exports.getSettlementKey = getSettlementKey;
|
|
11
|
+
exports.getTempOrderSettlementKey = getTempOrderSettlementKey;
|
|
12
|
+
exports.getTempOrderSettlementSnapshot = getTempOrderSettlementSnapshot;
|
|
13
|
+
exports.isVirtualSettlementDisplayOrder = isVirtualSettlementDisplayOrder;
|
|
14
|
+
exports.isVirtualSettlementOrder = isVirtualSettlementOrder;
|
|
15
|
+
exports.isVirtualSettlementProduct = isVirtualSettlementProduct;
|
|
16
|
+
exports.normalizeVirtualSettlementOrderProduct = normalizeVirtualSettlementOrderProduct;
|
|
17
|
+
exports.normalizeVirtualSettlementProducts = normalizeVirtualSettlementProducts;
|
|
18
|
+
exports.releaseTempOrderSettlementState = releaseTempOrderSettlementState;
|
|
19
|
+
exports.resolveSettlementDisplayValue = resolveSettlementDisplayValue;
|
|
20
|
+
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
21
|
+
var _lodashEs = require("lodash-es");
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
52
23
|
function buildCurrencyDisplaySnapshot(snapshot) {
|
|
53
|
-
return (0,
|
|
54
|
-
amount_format: String(snapshot.amount_format ||
|
|
24
|
+
return (0, _lodashEs.cloneDeep)({
|
|
25
|
+
amount_format: String(snapshot.amount_format || '').trim(),
|
|
55
26
|
symbol: snapshot.symbol ?? {},
|
|
56
27
|
unit_label: snapshot.unit_label ?? {}
|
|
57
28
|
});
|
|
58
29
|
}
|
|
59
30
|
function resolveSettlementDisplayValue(value) {
|
|
60
|
-
if (value ===
|
|
61
|
-
|
|
62
|
-
if (typeof value === "string" || typeof value === "number") {
|
|
31
|
+
if (value === undefined || value === null) return '';
|
|
32
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
63
33
|
return String(value);
|
|
64
34
|
}
|
|
65
35
|
const localized = value;
|
|
66
|
-
return String(
|
|
67
|
-
localized.auto ?? localized.default ?? localized.original ?? localized.en ?? localized["zh-CN"] ?? localized["zh-HK"] ?? ""
|
|
68
|
-
);
|
|
36
|
+
return String(localized.auto ?? localized.default ?? localized.original ?? localized.en ?? localized['zh-CN'] ?? localized['zh-HK'] ?? '');
|
|
69
37
|
}
|
|
70
|
-
|
|
38
|
+
class OrderSettlementConflictError extends Error {
|
|
39
|
+
code = 'ORDER_SETTLEMENT_CONFLICT';
|
|
71
40
|
constructor(currentSettlementKey, incomingSettlementKey) {
|
|
72
|
-
super(
|
|
41
|
+
super('Different currencies and WalletPass units cannot be mixed in one cart.');
|
|
73
42
|
this.currentSettlementKey = currentSettlementKey;
|
|
74
43
|
this.incomingSettlementKey = incomingSettlementKey;
|
|
75
|
-
this.
|
|
76
|
-
this.name = "OrderSettlementConflictError";
|
|
44
|
+
this.name = 'OrderSettlementConflictError';
|
|
77
45
|
}
|
|
78
|
-
}
|
|
79
|
-
|
|
46
|
+
}
|
|
47
|
+
exports.OrderSettlementConflictError = OrderSettlementConflictError;
|
|
48
|
+
class VirtualCurrencyAssetNotFoundError extends Error {
|
|
49
|
+
code = 'VIRTUAL_CURRENCY_ASSET_NOT_FOUND';
|
|
80
50
|
constructor(currencyProductId) {
|
|
81
|
-
super(
|
|
51
|
+
super('No matching virtual currency card is available.');
|
|
82
52
|
this.currencyProductId = currencyProductId;
|
|
83
|
-
this.
|
|
84
|
-
this.name = "VirtualCurrencyAssetNotFoundError";
|
|
53
|
+
this.name = 'VirtualCurrencyAssetNotFoundError';
|
|
85
54
|
}
|
|
86
|
-
}
|
|
87
|
-
|
|
55
|
+
}
|
|
56
|
+
exports.VirtualCurrencyAssetNotFoundError = VirtualCurrencyAssetNotFoundError;
|
|
57
|
+
class VirtualCurrencyBalanceError extends Error {
|
|
58
|
+
code = 'VIRTUAL_CURRENCY_BALANCE_INSUFFICIENT';
|
|
88
59
|
constructor(balance, requiredAmount) {
|
|
89
|
-
super(
|
|
60
|
+
super('Insufficient virtual currency balance.');
|
|
90
61
|
this.balance = balance;
|
|
91
62
|
this.requiredAmount = requiredAmount;
|
|
92
|
-
this.
|
|
93
|
-
this.name = "VirtualCurrencyBalanceError";
|
|
63
|
+
this.name = 'VirtualCurrencyBalanceError';
|
|
94
64
|
}
|
|
95
|
-
}
|
|
65
|
+
}
|
|
66
|
+
exports.VirtualCurrencyBalanceError = VirtualCurrencyBalanceError;
|
|
96
67
|
function getSelectedSettlementSnapshot(product) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (
|
|
100
|
-
return null;
|
|
101
|
-
if (snapshot.settlement_type !== "legal_currency" && snapshot.settlement_type !== "virtual_currency") {
|
|
68
|
+
const snapshot = product?.metadata?.selected_settlement_snapshot;
|
|
69
|
+
if (!snapshot || typeof snapshot !== 'object') return null;
|
|
70
|
+
if (snapshot.settlement_type !== 'legal_currency' && snapshot.settlement_type !== 'virtual_currency') {
|
|
102
71
|
return null;
|
|
103
72
|
}
|
|
104
73
|
return snapshot;
|
|
105
74
|
}
|
|
106
75
|
function getTempOrderSettlementSnapshot(tempOrder) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
if (snapshot && typeof snapshot === "object" && (snapshot.settlement_type === "legal_currency" || snapshot.settlement_type === "virtual_currency")) {
|
|
76
|
+
const snapshot = tempOrder?.metadata?.cart_settlement_snapshot;
|
|
77
|
+
if (snapshot && typeof snapshot === 'object' && (snapshot.settlement_type === 'legal_currency' || snapshot.settlement_type === 'virtual_currency')) {
|
|
110
78
|
return snapshot;
|
|
111
79
|
}
|
|
112
|
-
return getSelectedSettlementSnapshot(
|
|
80
|
+
return getSelectedSettlementSnapshot(tempOrder?.products?.[0]);
|
|
113
81
|
}
|
|
114
82
|
function isVirtualSettlementProduct(product) {
|
|
115
|
-
|
|
116
|
-
return ((_a = getSelectedSettlementSnapshot(product)) == null ? void 0 : _a.settlement_type) === "virtual_currency";
|
|
83
|
+
return getSelectedSettlementSnapshot(product)?.settlement_type === 'virtual_currency';
|
|
117
84
|
}
|
|
118
85
|
function getSettlementKey(snapshot) {
|
|
119
|
-
if (!snapshot)
|
|
120
|
-
|
|
121
|
-
if (snapshot.settlement_type === "legal_currency")
|
|
122
|
-
return "legal_currency";
|
|
86
|
+
if (!snapshot) return null;
|
|
87
|
+
if (snapshot.settlement_type === 'legal_currency') return 'legal_currency';
|
|
123
88
|
const currencyProductId = Number(snapshot.currency_product_id);
|
|
124
89
|
return Number.isFinite(currencyProductId) && currencyProductId > 0 ? `virtual_currency:${currencyProductId}` : null;
|
|
125
90
|
}
|
|
126
91
|
function getTempOrderSettlementKey(tempOrder) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
if (typeof storedKey === "string" && storedKey)
|
|
132
|
-
return storedKey;
|
|
133
|
-
return getSettlementKey(getTempOrderSettlementSnapshot(tempOrder)) || "legal_currency";
|
|
92
|
+
if (!tempOrder?.products?.length) return null;
|
|
93
|
+
const storedKey = tempOrder.metadata?.cart_settlement_key;
|
|
94
|
+
if (typeof storedKey === 'string' && storedKey) return storedKey;
|
|
95
|
+
return getSettlementKey(getTempOrderSettlementSnapshot(tempOrder)) || 'legal_currency';
|
|
134
96
|
}
|
|
135
97
|
function isVirtualSettlementOrder(tempOrder) {
|
|
136
|
-
|
|
137
|
-
return ((_a = getTempOrderSettlementKey(tempOrder)) == null ? void 0 : _a.startsWith("virtual_currency:")) === true;
|
|
98
|
+
return getTempOrderSettlementKey(tempOrder)?.startsWith('virtual_currency:') === true;
|
|
138
99
|
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* 详情展示识别同时支持已提交订单的 currency_settlement_config。
|
|
103
|
+
* cart_settlement_* 是交易过程内部状态,服务端详情不保证返回。
|
|
104
|
+
*/
|
|
139
105
|
function isVirtualSettlementDisplayOrder(tempOrder) {
|
|
140
|
-
|
|
141
|
-
return ((_b = (_a = tempOrder == null ? void 0 : tempOrder.metadata) == null ? void 0 : _a.currency_settlement_config) == null ? void 0 : _b.settlement_type) === "virtual_currency" || isVirtualSettlementOrder(tempOrder);
|
|
106
|
+
return tempOrder?.metadata?.currency_settlement_config?.settlement_type === 'virtual_currency' || isVirtualSettlementOrder(tempOrder);
|
|
142
107
|
}
|
|
143
108
|
function getLegalCurrencySnapshot(tempOrder) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
if (!snapshot || typeof snapshot !== "object")
|
|
147
|
-
return null;
|
|
109
|
+
const snapshot = tempOrder.metadata?.legal_currency_snapshot;
|
|
110
|
+
if (!snapshot || typeof snapshot !== 'object') return null;
|
|
148
111
|
return {
|
|
149
|
-
currency_code: String(snapshot.currency_code ||
|
|
150
|
-
currency_symbol: String(snapshot.currency_symbol ||
|
|
151
|
-
currency_format: String(snapshot.currency_format ||
|
|
112
|
+
currency_code: String(snapshot.currency_code || ''),
|
|
113
|
+
currency_symbol: String(snapshot.currency_symbol || ''),
|
|
114
|
+
currency_format: String(snapshot.currency_format || 'symbol_first')
|
|
152
115
|
};
|
|
153
116
|
}
|
|
154
117
|
function captureLegalCurrencySnapshot(tempOrder) {
|
|
155
118
|
tempOrder.metadata = tempOrder.metadata || {};
|
|
156
|
-
if (getLegalCurrencySnapshot(tempOrder))
|
|
157
|
-
return;
|
|
119
|
+
if (getLegalCurrencySnapshot(tempOrder)) return;
|
|
158
120
|
tempOrder.metadata.legal_currency_snapshot = {
|
|
159
|
-
currency_code: String(tempOrder.currency_code ||
|
|
160
|
-
currency_symbol: String(tempOrder.currency_symbol ||
|
|
161
|
-
currency_format: String(tempOrder.currency_format ||
|
|
121
|
+
currency_code: String(tempOrder.currency_code || ''),
|
|
122
|
+
currency_symbol: String(tempOrder.currency_symbol || ''),
|
|
123
|
+
currency_format: String(tempOrder.currency_format || 'symbol_first')
|
|
162
124
|
};
|
|
163
125
|
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* 将购物车锁定的结算单位提升为订单级状态。
|
|
129
|
+
* 商品行快照同时负责价格归一化和生成订单级多语言展示快照;
|
|
130
|
+
* 交易中的即时展示仍统一读取 tempOrder.currency_*。
|
|
131
|
+
*/
|
|
164
132
|
function applyTempOrderSettlementState(tempOrder, snapshot) {
|
|
165
|
-
var _a;
|
|
166
133
|
tempOrder.metadata = tempOrder.metadata || {};
|
|
167
|
-
const settlementKey = getSettlementKey(snapshot) ||
|
|
168
|
-
if (snapshot.settlement_type ===
|
|
134
|
+
const settlementKey = getSettlementKey(snapshot) || 'legal_currency';
|
|
135
|
+
if (snapshot.settlement_type === 'virtual_currency') {
|
|
169
136
|
captureLegalCurrencySnapshot(tempOrder);
|
|
170
137
|
const currencyProductId = Number(snapshot.currency_product_id);
|
|
171
|
-
const existingDisplaySnapshot =
|
|
138
|
+
const existingDisplaySnapshot = tempOrder.metadata.currency_settlement_config?.currency_display_snapshot;
|
|
172
139
|
tempOrder.metadata.currency_settlement_config = {
|
|
173
|
-
settlement_type:
|
|
140
|
+
settlement_type: 'virtual_currency',
|
|
174
141
|
settlement_ids: Number.isFinite(currencyProductId) && currencyProductId > 0 ? [currencyProductId] : [],
|
|
175
|
-
currency_display_snapshot: existingDisplaySnapshot ? (0,
|
|
142
|
+
currency_display_snapshot: existingDisplaySnapshot ? (0, _lodashEs.cloneDeep)(existingDisplaySnapshot) : buildCurrencyDisplaySnapshot(snapshot)
|
|
176
143
|
};
|
|
177
144
|
} else {
|
|
178
145
|
delete tempOrder.metadata.currency_settlement_config;
|
|
179
146
|
}
|
|
180
147
|
tempOrder.metadata.cart_settlement_key = settlementKey;
|
|
181
|
-
tempOrder.metadata.cart_settlement_snapshot = {
|
|
148
|
+
tempOrder.metadata.cart_settlement_snapshot = {
|
|
149
|
+
...snapshot
|
|
150
|
+
};
|
|
182
151
|
tempOrder.currency_code = resolveSettlementDisplayValue(snapshot.unit_label) || tempOrder.currency_code;
|
|
183
152
|
tempOrder.currency_symbol = resolveSettlementDisplayValue(snapshot.symbol) || tempOrder.currency_symbol;
|
|
184
|
-
tempOrder.currency_format = String(
|
|
185
|
-
snapshot.amount_format || tempOrder.currency_format || "symbol_first"
|
|
186
|
-
);
|
|
153
|
+
tempOrder.currency_format = String(snapshot.amount_format || tempOrder.currency_format || 'symbol_first');
|
|
187
154
|
}
|
|
155
|
+
|
|
156
|
+
/** 清空购物车结算锁,并恢复进入虚拟币结算前的店铺法币。 */
|
|
188
157
|
function releaseTempOrderSettlementState(tempOrder) {
|
|
189
158
|
tempOrder.metadata = tempOrder.metadata || {};
|
|
190
159
|
const legalCurrency = getLegalCurrencySnapshot(tempOrder);
|
|
@@ -199,23 +168,21 @@ function releaseTempOrderSettlementState(tempOrder) {
|
|
|
199
168
|
}
|
|
200
169
|
function toMoney(value) {
|
|
201
170
|
try {
|
|
202
|
-
return new
|
|
171
|
+
return new _decimal.default(String(value ?? 0)).toDecimalPlaces(2).toFixed(2);
|
|
203
172
|
} catch {
|
|
204
|
-
return
|
|
173
|
+
return '0.00';
|
|
205
174
|
}
|
|
206
175
|
}
|
|
207
176
|
function zeroOptions(options) {
|
|
208
|
-
if (!Array.isArray(options))
|
|
209
|
-
|
|
210
|
-
return options.map((option) => ({
|
|
177
|
+
if (!Array.isArray(options)) return [];
|
|
178
|
+
return options.map(option => ({
|
|
211
179
|
...option,
|
|
212
180
|
add_price: 0
|
|
213
181
|
}));
|
|
214
182
|
}
|
|
215
183
|
function zeroBundles(bundles) {
|
|
216
|
-
if (!Array.isArray(bundles))
|
|
217
|
-
|
|
218
|
-
return bundles.map((bundle) => ({
|
|
184
|
+
if (!Array.isArray(bundles)) return [];
|
|
185
|
+
return bundles.map(bundle => ({
|
|
219
186
|
...bundle,
|
|
220
187
|
price: 0,
|
|
221
188
|
custom_price: 0,
|
|
@@ -227,37 +194,40 @@ function zeroBundles(bundles) {
|
|
|
227
194
|
is_charge_tax: 0,
|
|
228
195
|
discount_list: [],
|
|
229
196
|
relation_surcharge_ids: [],
|
|
230
|
-
option: zeroOptions(bundle
|
|
197
|
+
option: zeroOptions(bundle?.option),
|
|
231
198
|
metadata: {
|
|
232
|
-
...(bundle
|
|
233
|
-
surcharge_fee:
|
|
199
|
+
...(bundle?.metadata || {}),
|
|
200
|
+
surcharge_fee: '0.00',
|
|
234
201
|
relation_surcharge_ids: [],
|
|
235
|
-
product_discount_difference:
|
|
236
|
-
tax_fee_rounding_remainder:
|
|
237
|
-
surcharge_rounding_remainder:
|
|
202
|
+
product_discount_difference: '',
|
|
203
|
+
tax_fee_rounding_remainder: '0.00',
|
|
204
|
+
surcharge_rounding_remainder: '0.00'
|
|
238
205
|
}
|
|
239
206
|
}));
|
|
240
207
|
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* 将已选择虚拟币的订单商品行固化为最终价语义。
|
|
211
|
+
* 函数幂等,可安全用于加车、合并、hydrate 和提交前兜底。
|
|
212
|
+
*/
|
|
241
213
|
function normalizeVirtualSettlementOrderProduct(product) {
|
|
242
|
-
var _a;
|
|
243
214
|
const snapshot = getSelectedSettlementSnapshot(product);
|
|
244
|
-
if (
|
|
245
|
-
return product;
|
|
215
|
+
if (snapshot?.settlement_type !== 'virtual_currency') return product;
|
|
246
216
|
const virtualPrice = toMoney(snapshot.price);
|
|
247
217
|
const metadata = {
|
|
248
|
-
...product.metadata || {},
|
|
218
|
+
...(product.metadata || {}),
|
|
249
219
|
source_product_price: virtualPrice,
|
|
250
220
|
main_product_original_price: virtualPrice,
|
|
251
221
|
main_product_selling_price: virtualPrice,
|
|
252
222
|
main_product_attached_bundle_selling_price: virtualPrice,
|
|
253
223
|
main_product_attached_bundle_payment_price: virtualPrice,
|
|
254
|
-
main_product_attached_bundle_surcharge_fee:
|
|
255
|
-
main_product_attached_bundle_tax_fee:
|
|
256
|
-
surcharge_rounding_remainder:
|
|
257
|
-
tax_fee_rounding_remainder:
|
|
224
|
+
main_product_attached_bundle_surcharge_fee: '0.00',
|
|
225
|
+
main_product_attached_bundle_tax_fee: '0.00',
|
|
226
|
+
surcharge_rounding_remainder: '0.00',
|
|
227
|
+
tax_fee_rounding_remainder: '0.00',
|
|
258
228
|
relation_surcharge_ids: [],
|
|
259
|
-
average_discount_amount_rate:
|
|
260
|
-
product_discount_difference:
|
|
229
|
+
average_discount_amount_rate: '1',
|
|
230
|
+
product_discount_difference: '',
|
|
261
231
|
discountable_flag: 0,
|
|
262
232
|
price_schema_version: 2,
|
|
263
233
|
selected_settlement_snapshot: {
|
|
@@ -272,42 +242,21 @@ function normalizeVirtualSettlementOrderProduct(product) {
|
|
|
272
242
|
payment_price: virtualPrice,
|
|
273
243
|
discount_list: [],
|
|
274
244
|
is_charge_tax: 0,
|
|
275
|
-
tax_fee:
|
|
245
|
+
tax_fee: '0.00',
|
|
276
246
|
original_tax_fee: 0,
|
|
277
247
|
tax_fee_rounding_remainder: 0,
|
|
278
248
|
original_tax_fee_rounding_remainder: 0,
|
|
279
|
-
surcharge_fee:
|
|
249
|
+
surcharge_fee: '0.00',
|
|
280
250
|
surcharge_rounding_remainder: 0,
|
|
281
251
|
relation_surcharge_ids: [],
|
|
282
252
|
product_sku: {
|
|
283
|
-
...product.product_sku || {},
|
|
284
|
-
option: zeroOptions(
|
|
253
|
+
...(product.product_sku || {}),
|
|
254
|
+
option: zeroOptions(product.product_sku?.option)
|
|
285
255
|
},
|
|
286
256
|
product_bundle: zeroBundles(product.product_bundle),
|
|
287
257
|
metadata
|
|
288
258
|
};
|
|
289
259
|
}
|
|
290
260
|
function normalizeVirtualSettlementProducts(products) {
|
|
291
|
-
return (products || []).map(
|
|
292
|
-
|
|
293
|
-
);
|
|
294
|
-
}
|
|
295
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
296
|
-
0 && (module.exports = {
|
|
297
|
-
OrderSettlementConflictError,
|
|
298
|
-
VirtualCurrencyAssetNotFoundError,
|
|
299
|
-
VirtualCurrencyBalanceError,
|
|
300
|
-
applyTempOrderSettlementState,
|
|
301
|
-
buildCurrencyDisplaySnapshot,
|
|
302
|
-
getSelectedSettlementSnapshot,
|
|
303
|
-
getSettlementKey,
|
|
304
|
-
getTempOrderSettlementKey,
|
|
305
|
-
getTempOrderSettlementSnapshot,
|
|
306
|
-
isVirtualSettlementDisplayOrder,
|
|
307
|
-
isVirtualSettlementOrder,
|
|
308
|
-
isVirtualSettlementProduct,
|
|
309
|
-
normalizeVirtualSettlementOrderProduct,
|
|
310
|
-
normalizeVirtualSettlementProducts,
|
|
311
|
-
releaseTempOrderSettlementState,
|
|
312
|
-
resolveSettlementDisplayValue
|
|
313
|
-
});
|
|
261
|
+
return (products || []).map(product => normalizeVirtualSettlementOrderProduct(product));
|
|
262
|
+
}
|