@pisell/pisellos 0.10.14 → 0.10.16
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/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.js +0 -2
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Order/index.js +75 -91
- package/dist/modules/Order/types.d.ts +5 -1
- package/dist/modules/Order/utils/virtualSettlement.d.ts +8 -1
- package/dist/modules/Order/utils/virtualSettlement.js +15 -2
- 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/Rules/index.js +1 -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.js +97 -129
- package/dist/server/modules/menu/index.js +32 -41
- package/dist/server/modules/order/index.js +2 -4
- 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/solution/BaseSales/index.js +107 -76
- 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.js +8 -4
- 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/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/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 +43 -48
- 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.js +70 -76
- package/lib/modules/OpenData/types.js +4 -16
- package/lib/modules/OpenData/utils.js +44 -78
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Order/index.js +1810 -2238
- package/lib/modules/Order/payment-utils.js +77 -120
- package/lib/modules/Order/types.d.ts +5 -1
- package/lib/modules/Order/types.js +87 -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.d.ts +8 -1
- package/lib/modules/Order/utils/virtualSettlement.js +126 -164
- 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 +138 -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 +1218 -959
- package/lib/modules/Rules/types.js +17 -40
- package/lib/modules/SalesSummary/index.js +78 -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.js +3027 -2655
- 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.js +758 -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.js +479 -456
- package/lib/server/utils/time.js +40 -49
- package/lib/solution/BaseSales/index.js +1276 -1485
- 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.js +598 -514
- 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.js +328 -324
- 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.js +1052 -1213
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +99 -159
- 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
|
@@ -12,6 +12,12 @@ export interface LegalCurrencySnapshot {
|
|
|
12
12
|
currency_symbol: string;
|
|
13
13
|
currency_format: string;
|
|
14
14
|
}
|
|
15
|
+
export interface CurrencyDisplaySnapshot {
|
|
16
|
+
amount_format: string;
|
|
17
|
+
symbol: unknown;
|
|
18
|
+
unit_label: unknown;
|
|
19
|
+
}
|
|
20
|
+
export declare function buildCurrencyDisplaySnapshot(snapshot: Pick<SelectedSettlementSnapshot, 'amount_format' | 'symbol' | 'unit_label'>): CurrencyDisplaySnapshot;
|
|
15
21
|
export declare function resolveSettlementDisplayValue(value: unknown): string;
|
|
16
22
|
export declare class OrderSettlementConflictError extends Error {
|
|
17
23
|
readonly currentSettlementKey: string;
|
|
@@ -43,7 +49,8 @@ export declare function isVirtualSettlementOrder(tempOrder: OrderTempOrder | nul
|
|
|
43
49
|
export declare function isVirtualSettlementDisplayOrder(tempOrder: OrderTempOrder | null | undefined): boolean;
|
|
44
50
|
/**
|
|
45
51
|
* 将购物车锁定的结算单位提升为订单级状态。
|
|
46
|
-
*
|
|
52
|
+
* 商品行快照同时负责价格归一化和生成订单级多语言展示快照;
|
|
53
|
+
* 交易中的即时展示仍统一读取 tempOrder.currency_*。
|
|
47
54
|
*/
|
|
48
55
|
export declare function applyTempOrderSettlementState(tempOrder: OrderTempOrder, snapshot: SelectedSettlementSnapshot): void;
|
|
49
56
|
/** 清空购物车结算锁,并恢复进入虚拟币结算前的店铺法币。 */
|
|
@@ -1,178 +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
|
-
getSelectedSettlementSnapshot: () => getSelectedSettlementSnapshot,
|
|
37
|
-
getSettlementKey: () => getSettlementKey,
|
|
38
|
-
getTempOrderSettlementKey: () => getTempOrderSettlementKey,
|
|
39
|
-
getTempOrderSettlementSnapshot: () => getTempOrderSettlementSnapshot,
|
|
40
|
-
isVirtualSettlementDisplayOrder: () => isVirtualSettlementDisplayOrder,
|
|
41
|
-
isVirtualSettlementOrder: () => isVirtualSettlementOrder,
|
|
42
|
-
isVirtualSettlementProduct: () => isVirtualSettlementProduct,
|
|
43
|
-
normalizeVirtualSettlementOrderProduct: () => normalizeVirtualSettlementOrderProduct,
|
|
44
|
-
normalizeVirtualSettlementProducts: () => normalizeVirtualSettlementProducts,
|
|
45
|
-
releaseTempOrderSettlementState: () => releaseTempOrderSettlementState,
|
|
46
|
-
resolveSettlementDisplayValue: () => resolveSettlementDisplayValue
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
47
5
|
});
|
|
48
|
-
|
|
49
|
-
|
|
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 }; }
|
|
23
|
+
function buildCurrencyDisplaySnapshot(snapshot) {
|
|
24
|
+
return (0, _lodashEs.cloneDeep)({
|
|
25
|
+
amount_format: String(snapshot.amount_format || '').trim(),
|
|
26
|
+
symbol: snapshot.symbol ?? {},
|
|
27
|
+
unit_label: snapshot.unit_label ?? {}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
50
30
|
function resolveSettlementDisplayValue(value) {
|
|
51
|
-
if (value ===
|
|
52
|
-
|
|
53
|
-
if (typeof value === "string" || typeof value === "number") {
|
|
31
|
+
if (value === undefined || value === null) return '';
|
|
32
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
54
33
|
return String(value);
|
|
55
34
|
}
|
|
56
35
|
const localized = value;
|
|
57
|
-
return String(
|
|
58
|
-
localized.auto ?? localized.default ?? localized.original ?? localized.en ?? localized["zh-CN"] ?? localized["zh-HK"] ?? ""
|
|
59
|
-
);
|
|
36
|
+
return String(localized.auto ?? localized.default ?? localized.original ?? localized.en ?? localized['zh-CN'] ?? localized['zh-HK'] ?? '');
|
|
60
37
|
}
|
|
61
|
-
|
|
38
|
+
class OrderSettlementConflictError extends Error {
|
|
39
|
+
code = 'ORDER_SETTLEMENT_CONFLICT';
|
|
62
40
|
constructor(currentSettlementKey, incomingSettlementKey) {
|
|
63
|
-
super(
|
|
41
|
+
super('Different currencies and WalletPass units cannot be mixed in one cart.');
|
|
64
42
|
this.currentSettlementKey = currentSettlementKey;
|
|
65
43
|
this.incomingSettlementKey = incomingSettlementKey;
|
|
66
|
-
this.
|
|
67
|
-
this.name = "OrderSettlementConflictError";
|
|
44
|
+
this.name = 'OrderSettlementConflictError';
|
|
68
45
|
}
|
|
69
|
-
}
|
|
70
|
-
|
|
46
|
+
}
|
|
47
|
+
exports.OrderSettlementConflictError = OrderSettlementConflictError;
|
|
48
|
+
class VirtualCurrencyAssetNotFoundError extends Error {
|
|
49
|
+
code = 'VIRTUAL_CURRENCY_ASSET_NOT_FOUND';
|
|
71
50
|
constructor(currencyProductId) {
|
|
72
|
-
super(
|
|
51
|
+
super('No matching virtual currency card is available.');
|
|
73
52
|
this.currencyProductId = currencyProductId;
|
|
74
|
-
this.
|
|
75
|
-
this.name = "VirtualCurrencyAssetNotFoundError";
|
|
53
|
+
this.name = 'VirtualCurrencyAssetNotFoundError';
|
|
76
54
|
}
|
|
77
|
-
}
|
|
78
|
-
|
|
55
|
+
}
|
|
56
|
+
exports.VirtualCurrencyAssetNotFoundError = VirtualCurrencyAssetNotFoundError;
|
|
57
|
+
class VirtualCurrencyBalanceError extends Error {
|
|
58
|
+
code = 'VIRTUAL_CURRENCY_BALANCE_INSUFFICIENT';
|
|
79
59
|
constructor(balance, requiredAmount) {
|
|
80
|
-
super(
|
|
60
|
+
super('Insufficient virtual currency balance.');
|
|
81
61
|
this.balance = balance;
|
|
82
62
|
this.requiredAmount = requiredAmount;
|
|
83
|
-
this.
|
|
84
|
-
this.name = "VirtualCurrencyBalanceError";
|
|
63
|
+
this.name = 'VirtualCurrencyBalanceError';
|
|
85
64
|
}
|
|
86
|
-
}
|
|
65
|
+
}
|
|
66
|
+
exports.VirtualCurrencyBalanceError = VirtualCurrencyBalanceError;
|
|
87
67
|
function getSelectedSettlementSnapshot(product) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if (
|
|
91
|
-
return null;
|
|
92
|
-
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') {
|
|
93
71
|
return null;
|
|
94
72
|
}
|
|
95
73
|
return snapshot;
|
|
96
74
|
}
|
|
97
75
|
function getTempOrderSettlementSnapshot(tempOrder) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
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')) {
|
|
101
78
|
return snapshot;
|
|
102
79
|
}
|
|
103
|
-
return getSelectedSettlementSnapshot(
|
|
80
|
+
return getSelectedSettlementSnapshot(tempOrder?.products?.[0]);
|
|
104
81
|
}
|
|
105
82
|
function isVirtualSettlementProduct(product) {
|
|
106
|
-
|
|
107
|
-
return ((_a = getSelectedSettlementSnapshot(product)) == null ? void 0 : _a.settlement_type) === "virtual_currency";
|
|
83
|
+
return getSelectedSettlementSnapshot(product)?.settlement_type === 'virtual_currency';
|
|
108
84
|
}
|
|
109
85
|
function getSettlementKey(snapshot) {
|
|
110
|
-
if (!snapshot)
|
|
111
|
-
|
|
112
|
-
if (snapshot.settlement_type === "legal_currency")
|
|
113
|
-
return "legal_currency";
|
|
86
|
+
if (!snapshot) return null;
|
|
87
|
+
if (snapshot.settlement_type === 'legal_currency') return 'legal_currency';
|
|
114
88
|
const currencyProductId = Number(snapshot.currency_product_id);
|
|
115
89
|
return Number.isFinite(currencyProductId) && currencyProductId > 0 ? `virtual_currency:${currencyProductId}` : null;
|
|
116
90
|
}
|
|
117
91
|
function getTempOrderSettlementKey(tempOrder) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
if (typeof storedKey === "string" && storedKey)
|
|
123
|
-
return storedKey;
|
|
124
|
-
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';
|
|
125
96
|
}
|
|
126
97
|
function isVirtualSettlementOrder(tempOrder) {
|
|
127
|
-
|
|
128
|
-
return ((_a = getTempOrderSettlementKey(tempOrder)) == null ? void 0 : _a.startsWith("virtual_currency:")) === true;
|
|
98
|
+
return getTempOrderSettlementKey(tempOrder)?.startsWith('virtual_currency:') === true;
|
|
129
99
|
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* 详情展示识别同时支持已提交订单的 currency_settlement_config。
|
|
103
|
+
* cart_settlement_* 是交易过程内部状态,服务端详情不保证返回。
|
|
104
|
+
*/
|
|
130
105
|
function isVirtualSettlementDisplayOrder(tempOrder) {
|
|
131
|
-
|
|
132
|
-
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);
|
|
133
107
|
}
|
|
134
108
|
function getLegalCurrencySnapshot(tempOrder) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
if (!snapshot || typeof snapshot !== "object")
|
|
138
|
-
return null;
|
|
109
|
+
const snapshot = tempOrder.metadata?.legal_currency_snapshot;
|
|
110
|
+
if (!snapshot || typeof snapshot !== 'object') return null;
|
|
139
111
|
return {
|
|
140
|
-
currency_code: String(snapshot.currency_code ||
|
|
141
|
-
currency_symbol: String(snapshot.currency_symbol ||
|
|
142
|
-
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')
|
|
143
115
|
};
|
|
144
116
|
}
|
|
145
117
|
function captureLegalCurrencySnapshot(tempOrder) {
|
|
146
118
|
tempOrder.metadata = tempOrder.metadata || {};
|
|
147
|
-
if (getLegalCurrencySnapshot(tempOrder))
|
|
148
|
-
return;
|
|
119
|
+
if (getLegalCurrencySnapshot(tempOrder)) return;
|
|
149
120
|
tempOrder.metadata.legal_currency_snapshot = {
|
|
150
|
-
currency_code: String(tempOrder.currency_code ||
|
|
151
|
-
currency_symbol: String(tempOrder.currency_symbol ||
|
|
152
|
-
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')
|
|
153
124
|
};
|
|
154
125
|
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* 将购物车锁定的结算单位提升为订单级状态。
|
|
129
|
+
* 商品行快照同时负责价格归一化和生成订单级多语言展示快照;
|
|
130
|
+
* 交易中的即时展示仍统一读取 tempOrder.currency_*。
|
|
131
|
+
*/
|
|
155
132
|
function applyTempOrderSettlementState(tempOrder, snapshot) {
|
|
156
133
|
tempOrder.metadata = tempOrder.metadata || {};
|
|
157
|
-
const settlementKey = getSettlementKey(snapshot) ||
|
|
158
|
-
if (snapshot.settlement_type ===
|
|
134
|
+
const settlementKey = getSettlementKey(snapshot) || 'legal_currency';
|
|
135
|
+
if (snapshot.settlement_type === 'virtual_currency') {
|
|
159
136
|
captureLegalCurrencySnapshot(tempOrder);
|
|
160
137
|
const currencyProductId = Number(snapshot.currency_product_id);
|
|
138
|
+
const existingDisplaySnapshot = tempOrder.metadata.currency_settlement_config?.currency_display_snapshot;
|
|
161
139
|
tempOrder.metadata.currency_settlement_config = {
|
|
162
|
-
settlement_type:
|
|
163
|
-
settlement_ids: Number.isFinite(currencyProductId) && currencyProductId > 0 ? [currencyProductId] : []
|
|
140
|
+
settlement_type: 'virtual_currency',
|
|
141
|
+
settlement_ids: Number.isFinite(currencyProductId) && currencyProductId > 0 ? [currencyProductId] : [],
|
|
142
|
+
currency_display_snapshot: existingDisplaySnapshot ? (0, _lodashEs.cloneDeep)(existingDisplaySnapshot) : buildCurrencyDisplaySnapshot(snapshot)
|
|
164
143
|
};
|
|
165
144
|
} else {
|
|
166
145
|
delete tempOrder.metadata.currency_settlement_config;
|
|
167
146
|
}
|
|
168
147
|
tempOrder.metadata.cart_settlement_key = settlementKey;
|
|
169
|
-
tempOrder.metadata.cart_settlement_snapshot = {
|
|
148
|
+
tempOrder.metadata.cart_settlement_snapshot = {
|
|
149
|
+
...snapshot
|
|
150
|
+
};
|
|
170
151
|
tempOrder.currency_code = resolveSettlementDisplayValue(snapshot.unit_label) || tempOrder.currency_code;
|
|
171
152
|
tempOrder.currency_symbol = resolveSettlementDisplayValue(snapshot.symbol) || tempOrder.currency_symbol;
|
|
172
|
-
tempOrder.currency_format = String(
|
|
173
|
-
snapshot.amount_format || tempOrder.currency_format || "symbol_first"
|
|
174
|
-
);
|
|
153
|
+
tempOrder.currency_format = String(snapshot.amount_format || tempOrder.currency_format || 'symbol_first');
|
|
175
154
|
}
|
|
155
|
+
|
|
156
|
+
/** 清空购物车结算锁,并恢复进入虚拟币结算前的店铺法币。 */
|
|
176
157
|
function releaseTempOrderSettlementState(tempOrder) {
|
|
177
158
|
tempOrder.metadata = tempOrder.metadata || {};
|
|
178
159
|
const legalCurrency = getLegalCurrencySnapshot(tempOrder);
|
|
@@ -187,23 +168,21 @@ function releaseTempOrderSettlementState(tempOrder) {
|
|
|
187
168
|
}
|
|
188
169
|
function toMoney(value) {
|
|
189
170
|
try {
|
|
190
|
-
return new
|
|
171
|
+
return new _decimal.default(String(value ?? 0)).toDecimalPlaces(2).toFixed(2);
|
|
191
172
|
} catch {
|
|
192
|
-
return
|
|
173
|
+
return '0.00';
|
|
193
174
|
}
|
|
194
175
|
}
|
|
195
176
|
function zeroOptions(options) {
|
|
196
|
-
if (!Array.isArray(options))
|
|
197
|
-
|
|
198
|
-
return options.map((option) => ({
|
|
177
|
+
if (!Array.isArray(options)) return [];
|
|
178
|
+
return options.map(option => ({
|
|
199
179
|
...option,
|
|
200
180
|
add_price: 0
|
|
201
181
|
}));
|
|
202
182
|
}
|
|
203
183
|
function zeroBundles(bundles) {
|
|
204
|
-
if (!Array.isArray(bundles))
|
|
205
|
-
|
|
206
|
-
return bundles.map((bundle) => ({
|
|
184
|
+
if (!Array.isArray(bundles)) return [];
|
|
185
|
+
return bundles.map(bundle => ({
|
|
207
186
|
...bundle,
|
|
208
187
|
price: 0,
|
|
209
188
|
custom_price: 0,
|
|
@@ -215,37 +194,40 @@ function zeroBundles(bundles) {
|
|
|
215
194
|
is_charge_tax: 0,
|
|
216
195
|
discount_list: [],
|
|
217
196
|
relation_surcharge_ids: [],
|
|
218
|
-
option: zeroOptions(bundle
|
|
197
|
+
option: zeroOptions(bundle?.option),
|
|
219
198
|
metadata: {
|
|
220
|
-
...(bundle
|
|
221
|
-
surcharge_fee:
|
|
199
|
+
...(bundle?.metadata || {}),
|
|
200
|
+
surcharge_fee: '0.00',
|
|
222
201
|
relation_surcharge_ids: [],
|
|
223
|
-
product_discount_difference:
|
|
224
|
-
tax_fee_rounding_remainder:
|
|
225
|
-
surcharge_rounding_remainder:
|
|
202
|
+
product_discount_difference: '',
|
|
203
|
+
tax_fee_rounding_remainder: '0.00',
|
|
204
|
+
surcharge_rounding_remainder: '0.00'
|
|
226
205
|
}
|
|
227
206
|
}));
|
|
228
207
|
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* 将已选择虚拟币的订单商品行固化为最终价语义。
|
|
211
|
+
* 函数幂等,可安全用于加车、合并、hydrate 和提交前兜底。
|
|
212
|
+
*/
|
|
229
213
|
function normalizeVirtualSettlementOrderProduct(product) {
|
|
230
|
-
var _a;
|
|
231
214
|
const snapshot = getSelectedSettlementSnapshot(product);
|
|
232
|
-
if (
|
|
233
|
-
return product;
|
|
215
|
+
if (snapshot?.settlement_type !== 'virtual_currency') return product;
|
|
234
216
|
const virtualPrice = toMoney(snapshot.price);
|
|
235
217
|
const metadata = {
|
|
236
|
-
...product.metadata || {},
|
|
218
|
+
...(product.metadata || {}),
|
|
237
219
|
source_product_price: virtualPrice,
|
|
238
220
|
main_product_original_price: virtualPrice,
|
|
239
221
|
main_product_selling_price: virtualPrice,
|
|
240
222
|
main_product_attached_bundle_selling_price: virtualPrice,
|
|
241
223
|
main_product_attached_bundle_payment_price: virtualPrice,
|
|
242
|
-
main_product_attached_bundle_surcharge_fee:
|
|
243
|
-
main_product_attached_bundle_tax_fee:
|
|
244
|
-
surcharge_rounding_remainder:
|
|
245
|
-
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',
|
|
246
228
|
relation_surcharge_ids: [],
|
|
247
|
-
average_discount_amount_rate:
|
|
248
|
-
product_discount_difference:
|
|
229
|
+
average_discount_amount_rate: '1',
|
|
230
|
+
product_discount_difference: '',
|
|
249
231
|
discountable_flag: 0,
|
|
250
232
|
price_schema_version: 2,
|
|
251
233
|
selected_settlement_snapshot: {
|
|
@@ -260,41 +242,21 @@ function normalizeVirtualSettlementOrderProduct(product) {
|
|
|
260
242
|
payment_price: virtualPrice,
|
|
261
243
|
discount_list: [],
|
|
262
244
|
is_charge_tax: 0,
|
|
263
|
-
tax_fee:
|
|
245
|
+
tax_fee: '0.00',
|
|
264
246
|
original_tax_fee: 0,
|
|
265
247
|
tax_fee_rounding_remainder: 0,
|
|
266
248
|
original_tax_fee_rounding_remainder: 0,
|
|
267
|
-
surcharge_fee:
|
|
249
|
+
surcharge_fee: '0.00',
|
|
268
250
|
surcharge_rounding_remainder: 0,
|
|
269
251
|
relation_surcharge_ids: [],
|
|
270
252
|
product_sku: {
|
|
271
|
-
...product.product_sku || {},
|
|
272
|
-
option: zeroOptions(
|
|
253
|
+
...(product.product_sku || {}),
|
|
254
|
+
option: zeroOptions(product.product_sku?.option)
|
|
273
255
|
},
|
|
274
256
|
product_bundle: zeroBundles(product.product_bundle),
|
|
275
257
|
metadata
|
|
276
258
|
};
|
|
277
259
|
}
|
|
278
260
|
function normalizeVirtualSettlementProducts(products) {
|
|
279
|
-
return (products || []).map(
|
|
280
|
-
|
|
281
|
-
);
|
|
282
|
-
}
|
|
283
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
284
|
-
0 && (module.exports = {
|
|
285
|
-
OrderSettlementConflictError,
|
|
286
|
-
VirtualCurrencyAssetNotFoundError,
|
|
287
|
-
VirtualCurrencyBalanceError,
|
|
288
|
-
applyTempOrderSettlementState,
|
|
289
|
-
getSelectedSettlementSnapshot,
|
|
290
|
-
getSettlementKey,
|
|
291
|
-
getTempOrderSettlementKey,
|
|
292
|
-
getTempOrderSettlementSnapshot,
|
|
293
|
-
isVirtualSettlementDisplayOrder,
|
|
294
|
-
isVirtualSettlementOrder,
|
|
295
|
-
isVirtualSettlementProduct,
|
|
296
|
-
normalizeVirtualSettlementOrderProduct,
|
|
297
|
-
normalizeVirtualSettlementProducts,
|
|
298
|
-
releaseTempOrderSettlementState,
|
|
299
|
-
resolveSettlementDisplayValue
|
|
300
|
-
});
|
|
261
|
+
return (products || []).map(product => normalizeVirtualSettlementOrderProduct(product));
|
|
262
|
+
}
|