@pisell/pisellos 2.3.74 → 2.3.75
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 -10
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- 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.js +36 -64
- package/dist/modules/Payment/index.js +97 -162
- 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 +38 -41
- 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 +0 -2
- 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/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 +134 -134
- 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 +162 -236
- 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 -0
- 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 +122 -127
- 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.js +1713 -2118
- package/lib/modules/Order/payment-utils.js +77 -120
- 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.js +814 -647
- 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.js +4 -16
- package/lib/modules/Product/utils.js +32 -33
- package/lib/modules/ProductList/index.js +113 -123
- package/lib/modules/ProductList/types.js +9 -31
- package/lib/modules/Quotation/index.js +81 -118
- 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 +589 -770
- 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 +85 -90
- package/lib/modules/SalesSummary/types.js +4 -16
- package/lib/modules/SalesSummary/utils.js +355 -430
- 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 +3050 -2665
- package/lib/server/modules/floor-plan/index.js +118 -134
- 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 +142 -122
- package/lib/server/modules/menu/types.js +18 -31
- package/lib/server/modules/order/index.js +784 -1002
- 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 +583 -471
- 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 +220 -186
- 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 +1186 -1410
- package/lib/solution/BaseSales/types.js +42 -38
- package/lib/solution/BaseSales/utils/cartPromotion.js +642 -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.js +108 -145
- package/lib/solution/BaseSales/utils.js +158 -143
- 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 +607 -522
- package/lib/solution/BookingTicket/types.js +99 -77
- package/lib/solution/BookingTicket/utils/addProductDecision.js +226 -189
- 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 +832 -864
- package/lib/solution/ScanOrder/types.js +33 -34
- package/lib/solution/ScanOrder/utils.js +409 -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 +1035 -1201
- 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
|
@@ -1,89 +1,65 @@
|
|
|
1
|
-
|
|
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);
|
|
1
|
+
"use strict";
|
|
18
2
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
__export(orderCollectionIdentity_exports, {
|
|
22
|
-
applyOrderCollectionUidRemaps: () => applyOrderCollectionUidRemaps,
|
|
23
|
-
buildOrderCollectionFallbackUid: () => buildOrderCollectionFallbackUid,
|
|
24
|
-
createUuidV4: () => createUuidV4,
|
|
25
|
-
getOrderCollectionPersistentId: () => getOrderCollectionPersistentId,
|
|
26
|
-
getOrderCollectionReferenceUid: () => getOrderCollectionReferenceUid,
|
|
27
|
-
getOrderCollectionUid: () => getOrderCollectionUid,
|
|
28
|
-
isBlankOrderCollectionIdentity: () => isBlankOrderCollectionIdentity,
|
|
29
|
-
isSameOrderCollectionItem: () => isSameOrderCollectionItem,
|
|
30
|
-
mergeOrderCollectionItems: () => mergeOrderCollectionItems,
|
|
31
|
-
normalizeOrderCollection: () => normalizeOrderCollection,
|
|
32
|
-
normalizeOrderCollections: () => normalizeOrderCollections,
|
|
33
|
-
repairDuplicateProductLineIdentities: () => repairDuplicateProductLineIdentities,
|
|
34
|
-
setOrderCollectionUid: () => setOrderCollectionUid
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
35
5
|
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
6
|
+
exports.applyOrderCollectionUidRemaps = applyOrderCollectionUidRemaps;
|
|
7
|
+
exports.buildOrderCollectionFallbackUid = buildOrderCollectionFallbackUid;
|
|
8
|
+
exports.createUuidV4 = createUuidV4;
|
|
9
|
+
exports.getOrderCollectionPersistentId = getOrderCollectionPersistentId;
|
|
10
|
+
exports.getOrderCollectionReferenceUid = getOrderCollectionReferenceUid;
|
|
11
|
+
exports.getOrderCollectionUid = getOrderCollectionUid;
|
|
12
|
+
exports.isBlankOrderCollectionIdentity = isBlankOrderCollectionIdentity;
|
|
13
|
+
exports.isSameOrderCollectionItem = isSameOrderCollectionItem;
|
|
14
|
+
exports.mergeOrderCollectionItems = mergeOrderCollectionItems;
|
|
15
|
+
exports.normalizeOrderCollection = normalizeOrderCollection;
|
|
16
|
+
exports.normalizeOrderCollections = normalizeOrderCollections;
|
|
17
|
+
exports.repairDuplicateProductLineIdentities = repairDuplicateProductLineIdentities;
|
|
18
|
+
exports.setOrderCollectionUid = setOrderCollectionUid;
|
|
19
|
+
var _lodashEs = require("lodash-es");
|
|
20
|
+
const IDENTITY_CONFIG = {
|
|
39
21
|
product: {
|
|
40
|
-
persistentIdField:
|
|
41
|
-
uidField:
|
|
42
|
-
fallbackPrefix:
|
|
22
|
+
persistentIdField: 'order_detail_id',
|
|
23
|
+
uidField: 'unique_identification_number',
|
|
24
|
+
fallbackPrefix: 'os-fallback:product:order-detail'
|
|
43
25
|
},
|
|
44
26
|
booking: {
|
|
45
|
-
persistentIdField:
|
|
46
|
-
uidField:
|
|
47
|
-
fallbackPrefix:
|
|
27
|
+
persistentIdField: 'schedule_event_id',
|
|
28
|
+
uidField: 'unique_identification_number',
|
|
29
|
+
fallbackPrefix: 'os-fallback:booking:schedule-event'
|
|
48
30
|
},
|
|
49
31
|
payment: {
|
|
50
|
-
persistentIdField:
|
|
51
|
-
uidField:
|
|
52
|
-
fallbackPrefix:
|
|
32
|
+
persistentIdField: 'order_payment_id',
|
|
33
|
+
uidField: 'unique_payment_number',
|
|
34
|
+
fallbackPrefix: 'os-fallback:payment:order-payment'
|
|
53
35
|
}
|
|
54
36
|
};
|
|
55
37
|
function createUuidV4() {
|
|
56
|
-
const template =
|
|
57
|
-
return template.replace(/[xy]/g,
|
|
38
|
+
const template = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
|
|
39
|
+
return template.replace(/[xy]/g, char => {
|
|
58
40
|
const randomValue = Math.floor(Math.random() * 16);
|
|
59
|
-
const value = char ===
|
|
41
|
+
const value = char === 'x' ? randomValue : randomValue & 0x3 | 0x8;
|
|
60
42
|
return value.toString(16);
|
|
61
43
|
});
|
|
62
44
|
}
|
|
63
45
|
function isBlankOrderCollectionIdentity(value) {
|
|
64
|
-
return value ===
|
|
46
|
+
return value === undefined || value === null || value === '';
|
|
65
47
|
}
|
|
66
48
|
function getOrderCollectionPersistentId(kind, item) {
|
|
67
49
|
const record = item;
|
|
68
|
-
if (!record)
|
|
69
|
-
return null;
|
|
50
|
+
if (!record) return null;
|
|
70
51
|
const value = record[IDENTITY_CONFIG[kind].persistentIdField];
|
|
71
|
-
if (isBlankOrderCollectionIdentity(value))
|
|
72
|
-
return null;
|
|
52
|
+
if (isBlankOrderCollectionIdentity(value)) return null;
|
|
73
53
|
return String(value);
|
|
74
54
|
}
|
|
75
55
|
function getOrderCollectionUid(kind, item) {
|
|
76
|
-
var _a;
|
|
77
56
|
const record = item;
|
|
78
|
-
if (!record)
|
|
79
|
-
return null;
|
|
57
|
+
if (!record) return null;
|
|
80
58
|
const uidField = IDENTITY_CONFIG[kind].uidField;
|
|
81
|
-
const metadataValue =
|
|
82
|
-
if (!isBlankOrderCollectionIdentity(metadataValue))
|
|
83
|
-
return String(metadataValue);
|
|
59
|
+
const metadataValue = record.metadata?.[uidField];
|
|
60
|
+
if (!isBlankOrderCollectionIdentity(metadataValue)) return String(metadataValue);
|
|
84
61
|
const topLevelValue = record[uidField];
|
|
85
|
-
if (isBlankOrderCollectionIdentity(topLevelValue))
|
|
86
|
-
return null;
|
|
62
|
+
if (isBlankOrderCollectionIdentity(topLevelValue)) return null;
|
|
87
63
|
return String(topLevelValue);
|
|
88
64
|
}
|
|
89
65
|
function buildOrderCollectionFallbackUid(kind, persistentId) {
|
|
@@ -91,31 +67,27 @@ function buildOrderCollectionFallbackUid(kind, persistentId) {
|
|
|
91
67
|
}
|
|
92
68
|
function getOrderCollectionReferenceUid(kind, item) {
|
|
93
69
|
const uid = getOrderCollectionUid(kind, item);
|
|
94
|
-
if (uid)
|
|
95
|
-
return uid;
|
|
70
|
+
if (uid) return uid;
|
|
96
71
|
const persistentId = getOrderCollectionPersistentId(kind, item);
|
|
97
72
|
return persistentId ? buildOrderCollectionFallbackUid(kind, persistentId) : null;
|
|
98
73
|
}
|
|
99
74
|
function setOrderCollectionUid(kind, item, uid) {
|
|
100
|
-
const record = (0,
|
|
75
|
+
const record = (0, _lodashEs.cloneDeep)(item || {});
|
|
101
76
|
const uidField = IDENTITY_CONFIG[kind].uidField;
|
|
102
77
|
record.metadata = {
|
|
103
|
-
...record.metadata && typeof record.metadata ===
|
|
78
|
+
...(record.metadata && typeof record.metadata === 'object' ? record.metadata : {}),
|
|
104
79
|
[uidField]: uid
|
|
105
80
|
};
|
|
106
81
|
delete record[uidField];
|
|
107
82
|
return record;
|
|
108
83
|
}
|
|
109
84
|
function getGoodPassResourceId(product) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const type = (item == null ? void 0 : item.type) || (item == null ? void 0 : item.tag) || ((_a2 = item == null ? void 0 : item.discount) == null ? void 0 : _a2.type) || ((_b = item == null ? void 0 : item.discount) == null ? void 0 : _b.tag);
|
|
114
|
-
return type === "good_pass";
|
|
85
|
+
const goodPass = (product.discount_list || []).find(item => {
|
|
86
|
+
const type = item?.type || item?.tag || item?.discount?.type || item?.discount?.tag;
|
|
87
|
+
return type === 'good_pass';
|
|
115
88
|
});
|
|
116
|
-
if (!goodPass)
|
|
117
|
-
|
|
118
|
-
const resourceId = ((_a = goodPass.discount) == null ? void 0 : _a.resource_id) ?? goodPass.resource_id ?? goodPass.discount_id ?? goodPass.id;
|
|
89
|
+
if (!goodPass) return null;
|
|
90
|
+
const resourceId = goodPass.discount?.resource_id ?? goodPass.resource_id ?? goodPass.discount_id ?? goodPass.id;
|
|
119
91
|
return isBlankOrderCollectionIdentity(resourceId) ? null : String(resourceId);
|
|
120
92
|
}
|
|
121
93
|
function buildSplitProductUid(originalUid, product, duplicateOrdinal) {
|
|
@@ -126,54 +98,63 @@ function buildSplitProductUid(originalUid, product, duplicateOrdinal) {
|
|
|
126
98
|
}
|
|
127
99
|
return `os-split:product:${encodedOriginalUid}:duplicate:${duplicateOrdinal}`;
|
|
128
100
|
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Rules 会把同一商品按商品券拆成多条真实订单行。拆行结果会继承原商品 UID,
|
|
104
|
+
* 因此必须在通用 collection normalization 之前为后续行派生稳定身份,避免被折叠。
|
|
105
|
+
*/
|
|
129
106
|
function repairDuplicateProductLineIdentities(products, productsByUid) {
|
|
130
|
-
const repairedProducts = (0,
|
|
131
|
-
const repairedProductsByUid = productsByUid ? (0,
|
|
132
|
-
const occupiedUids = new Set(
|
|
133
|
-
|
|
134
|
-
);
|
|
135
|
-
Object.keys(repairedProductsByUid || {}).forEach((uid) => occupiedUids.add(uid));
|
|
136
|
-
const occurrences = /* @__PURE__ */ new Map();
|
|
107
|
+
const repairedProducts = (0, _lodashEs.cloneDeep)(products || []);
|
|
108
|
+
const repairedProductsByUid = productsByUid ? (0, _lodashEs.cloneDeep)(productsByUid) : undefined;
|
|
109
|
+
const occupiedUids = new Set(repairedProducts.map(product => getOrderCollectionUid('product', product)).filter(uid => Boolean(uid)));
|
|
110
|
+
Object.keys(repairedProductsByUid || {}).forEach(uid => occupiedUids.add(uid));
|
|
111
|
+
const occurrences = new Map();
|
|
137
112
|
const repairs = [];
|
|
138
113
|
repairedProducts.forEach((product, index) => {
|
|
139
|
-
const originalUid = getOrderCollectionUid(
|
|
140
|
-
if (!originalUid)
|
|
141
|
-
return;
|
|
114
|
+
const originalUid = getOrderCollectionUid('product', product);
|
|
115
|
+
if (!originalUid) return;
|
|
142
116
|
const occurrence = (occurrences.get(originalUid) || 0) + 1;
|
|
143
117
|
occurrences.set(originalUid, occurrence);
|
|
144
|
-
if (occurrence === 1)
|
|
145
|
-
return;
|
|
118
|
+
if (occurrence === 1) return;
|
|
146
119
|
const duplicateOrdinal = occurrence - 1;
|
|
147
|
-
const baseCandidate = buildSplitProductUid(
|
|
148
|
-
originalUid,
|
|
149
|
-
product,
|
|
150
|
-
duplicateOrdinal
|
|
151
|
-
);
|
|
120
|
+
const baseCandidate = buildSplitProductUid(originalUid, product, duplicateOrdinal);
|
|
152
121
|
let nextUid = baseCandidate;
|
|
153
122
|
let conflictOrdinal = 1;
|
|
154
123
|
while (occupiedUids.has(nextUid)) {
|
|
155
124
|
nextUid = `${baseCandidate}:conflict:${conflictOrdinal}`;
|
|
156
125
|
conflictOrdinal += 1;
|
|
157
126
|
}
|
|
158
|
-
const repairedProduct = setOrderCollectionUid(
|
|
127
|
+
const repairedProduct = setOrderCollectionUid('product', product, nextUid);
|
|
159
128
|
repairedProduct.identity_key = nextUid;
|
|
160
129
|
repairedProducts[index] = repairedProduct;
|
|
161
130
|
occupiedUids.add(nextUid);
|
|
162
|
-
repairs.push({
|
|
163
|
-
|
|
131
|
+
repairs.push({
|
|
132
|
+
index,
|
|
133
|
+
from: originalUid,
|
|
134
|
+
to: nextUid
|
|
135
|
+
});
|
|
136
|
+
const runtimeSource = repairedProductsByUid?.[originalUid];
|
|
164
137
|
if (runtimeSource && repairedProductsByUid) {
|
|
165
138
|
repairedProductsByUid[nextUid] = {
|
|
166
|
-
...(0,
|
|
167
|
-
...runtimeSource.rowKey !==
|
|
139
|
+
...(0, _lodashEs.cloneDeep)(runtimeSource),
|
|
140
|
+
...(runtimeSource.rowKey !== undefined ? {
|
|
141
|
+
rowKey: nextUid
|
|
142
|
+
} : {})
|
|
168
143
|
};
|
|
169
144
|
}
|
|
170
145
|
});
|
|
171
146
|
return {
|
|
172
147
|
products: repairedProducts,
|
|
173
|
-
...repairedProductsByUid ? {
|
|
148
|
+
...(repairedProductsByUid ? {
|
|
149
|
+
productsByUid: repairedProductsByUid
|
|
150
|
+
} : {}),
|
|
174
151
|
repairs
|
|
175
152
|
};
|
|
176
153
|
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* 持久化行 ID 是服务端事实主键;只有至少一侧尚未持久化时,才允许用 runtime UID 对齐。
|
|
157
|
+
*/
|
|
177
158
|
function isSameOrderCollectionItem(kind, left, right) {
|
|
178
159
|
const leftPersistentId = getOrderCollectionPersistentId(kind, left);
|
|
179
160
|
const rightPersistentId = getOrderCollectionPersistentId(kind, right);
|
|
@@ -185,9 +166,8 @@ function isSameOrderCollectionItem(kind, left, right) {
|
|
|
185
166
|
return Boolean(leftUid && rightUid && leftUid === rightUid);
|
|
186
167
|
}
|
|
187
168
|
function mergeOrderCollectionItems(kind, currentItem, incomingItem, options) {
|
|
188
|
-
|
|
189
|
-
const
|
|
190
|
-
const incoming = (0, import_lodash_es.cloneDeep)(incomingItem || {});
|
|
169
|
+
const current = (0, _lodashEs.cloneDeep)(currentItem || {});
|
|
170
|
+
const incoming = (0, _lodashEs.cloneDeep)(incomingItem || {});
|
|
191
171
|
const persistentIdField = IDENTITY_CONFIG[kind].persistentIdField;
|
|
192
172
|
const currentPersistentIdValue = current[persistentIdField];
|
|
193
173
|
const incomingPersistentIdValue = incoming[persistentIdField];
|
|
@@ -198,19 +178,19 @@ function mergeOrderCollectionItems(kind, currentItem, incomingItem, options) {
|
|
|
198
178
|
...current,
|
|
199
179
|
...incoming,
|
|
200
180
|
metadata: {
|
|
201
|
-
...current.metadata && typeof current.metadata ===
|
|
202
|
-
...incoming.metadata && typeof incoming.metadata ===
|
|
181
|
+
...(current.metadata && typeof current.metadata === 'object' ? current.metadata : {}),
|
|
182
|
+
...(incoming.metadata && typeof incoming.metadata === 'object' ? incoming.metadata : {})
|
|
203
183
|
}
|
|
204
184
|
};
|
|
185
|
+
|
|
186
|
+
// UID 对齐允许一侧尚未持久化,但稀疏 incoming 的 null/空值不能擦掉已存在行 ID。
|
|
205
187
|
if (!isBlankOrderCollectionIdentity(incomingPersistentIdValue)) {
|
|
206
188
|
merged[persistentIdField] = incomingPersistentIdValue;
|
|
207
189
|
} else if (!isBlankOrderCollectionIdentity(currentPersistentIdValue)) {
|
|
208
190
|
merged[persistentIdField] = currentPersistentIdValue;
|
|
209
191
|
}
|
|
210
|
-
const incomingUidIsDerived = Boolean(
|
|
211
|
-
|
|
212
|
-
);
|
|
213
|
-
const uid = (incomingUid && !incomingUidIsDerived ? incomingUid : null) || currentUid || incomingUid || ((options == null ? void 0 : options.ensureUid) === false ? null : persistentId ? buildOrderCollectionFallbackUid(kind, persistentId) : ((_a = options == null ? void 0 : options.createAnonymousUid) == null ? void 0 : _a.call(options)) || createUuidV4());
|
|
192
|
+
const incomingUidIsDerived = Boolean(incomingUid && persistentId && (incomingUid === buildOrderCollectionFallbackUid(kind, persistentId) || incomingUid.startsWith(`${buildOrderCollectionFallbackUid(kind, persistentId)}:conflict:`)));
|
|
193
|
+
const uid = (incomingUid && !incomingUidIsDerived ? incomingUid : null) || currentUid || incomingUid || (options?.ensureUid === false ? null : persistentId ? buildOrderCollectionFallbackUid(kind, persistentId) : options?.createAnonymousUid?.() || createUuidV4());
|
|
214
194
|
return uid ? setOrderCollectionUid(kind, merged, uid) : merged;
|
|
215
195
|
}
|
|
216
196
|
function createEmptyIdentityStats() {
|
|
@@ -223,14 +203,15 @@ function createEmptyIdentityStats() {
|
|
|
223
203
|
}
|
|
224
204
|
function allocateAnonymousUid(occupiedUids, createAnonymousUid) {
|
|
225
205
|
let uid = createAnonymousUid();
|
|
226
|
-
while (occupiedUids.has(uid))
|
|
227
|
-
uid = createAnonymousUid();
|
|
206
|
+
while (occupiedUids.has(uid)) uid = createAnonymousUid();
|
|
228
207
|
return uid;
|
|
229
208
|
}
|
|
230
209
|
function allocatePersistentConflictUid(kind, persistentId, occupiedUids) {
|
|
231
210
|
const fallbackUid = buildOrderCollectionFallbackUid(kind, persistentId);
|
|
232
|
-
if (!occupiedUids.has(fallbackUid))
|
|
233
|
-
|
|
211
|
+
if (!occupiedUids.has(fallbackUid)) return fallbackUid;
|
|
212
|
+
|
|
213
|
+
// 极端情况下其它行可能把本行 fallback 当作显式 UID 使用;继续派生稳定后缀,
|
|
214
|
+
// 避免修复冲突后仍留下重复 UID。规范化结果一旦持久化,后续读取保持幂等。
|
|
234
215
|
let suffix = 1;
|
|
235
216
|
let candidate = `${fallbackUid}:conflict:${suffix}`;
|
|
236
217
|
while (occupiedUids.has(candidate)) {
|
|
@@ -239,38 +220,32 @@ function allocatePersistentConflictUid(kind, persistentId, occupiedUids) {
|
|
|
239
220
|
}
|
|
240
221
|
return candidate;
|
|
241
222
|
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* 规范化单一数组:强身份重复时保留首次位置、用最后一条业务字段覆盖,并统一补 UID。
|
|
226
|
+
*/
|
|
242
227
|
function normalizeOrderCollection(kind, items, options) {
|
|
243
|
-
var _a, _b;
|
|
244
228
|
const stats = createEmptyIdentityStats();
|
|
245
229
|
const uidRemaps = [];
|
|
246
230
|
const result = [];
|
|
247
|
-
const ensureUid =
|
|
248
|
-
const createAnonymousUid =
|
|
231
|
+
const ensureUid = options?.ensureUid !== false;
|
|
232
|
+
const createAnonymousUid = options?.createAnonymousUid || createUuidV4;
|
|
249
233
|
for (const rawItem of items || []) {
|
|
250
|
-
const item = (0,
|
|
251
|
-
const existingIndex = result.findIndex(
|
|
252
|
-
(existing) => isSameOrderCollectionItem(kind, existing, item)
|
|
253
|
-
);
|
|
234
|
+
const item = (0, _lodashEs.cloneDeep)(rawItem);
|
|
235
|
+
const existingIndex = result.findIndex(existing => isSameOrderCollectionItem(kind, existing, item));
|
|
254
236
|
if (existingIndex === -1) {
|
|
255
237
|
result.push(item);
|
|
256
238
|
continue;
|
|
257
239
|
}
|
|
258
|
-
const previousReferenceUid = getOrderCollectionReferenceUid(
|
|
259
|
-
kind,
|
|
260
|
-
result[existingIndex]
|
|
261
|
-
);
|
|
240
|
+
const previousReferenceUid = getOrderCollectionReferenceUid(kind, result[existingIndex]);
|
|
262
241
|
const incomingReferenceUid = getOrderCollectionReferenceUid(kind, item);
|
|
263
|
-
result[existingIndex] = mergeOrderCollectionItems(
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
item,
|
|
267
|
-
{ ensureUid: false }
|
|
268
|
-
);
|
|
242
|
+
result[existingIndex] = mergeOrderCollectionItems(kind, result[existingIndex], item, {
|
|
243
|
+
ensureUid: false
|
|
244
|
+
});
|
|
269
245
|
const nextUid = getOrderCollectionUid(kind, result[existingIndex]);
|
|
270
246
|
if (nextUid) {
|
|
271
|
-
for (const from of
|
|
272
|
-
if (!from || from === nextUid)
|
|
273
|
-
continue;
|
|
247
|
+
for (const from of new Set([previousReferenceUid, incomingReferenceUid])) {
|
|
248
|
+
if (!from || from === nextUid) continue;
|
|
274
249
|
uidRemaps.push({
|
|
275
250
|
kind,
|
|
276
251
|
from,
|
|
@@ -281,23 +256,26 @@ function normalizeOrderCollection(kind, items, options) {
|
|
|
281
256
|
}
|
|
282
257
|
stats.collapsedDuplicateCount += 1;
|
|
283
258
|
}
|
|
284
|
-
if (!ensureUid)
|
|
285
|
-
|
|
286
|
-
|
|
259
|
+
if (!ensureUid) return {
|
|
260
|
+
items: result,
|
|
261
|
+
stats,
|
|
262
|
+
uidRemaps
|
|
263
|
+
};
|
|
264
|
+
const occupiedUids = new Set();
|
|
287
265
|
for (let index = 0; index < result.length; index += 1) {
|
|
288
266
|
let item = result[index];
|
|
289
267
|
const persistentId = getOrderCollectionPersistentId(kind, item);
|
|
290
268
|
let uid = getOrderCollectionUid(kind, item);
|
|
291
269
|
if (!uid) {
|
|
292
|
-
if (kind ===
|
|
270
|
+
if (kind === 'payment' && !isBlankOrderCollectionIdentity(item?.payment_number)) {
|
|
271
|
+
// payment_number 已提供稳定身份,不占用真实交易流水字段作为内部 UID。
|
|
293
272
|
continue;
|
|
294
273
|
}
|
|
295
274
|
uid = persistentId ? buildOrderCollectionFallbackUid(kind, persistentId) : allocateAnonymousUid(occupiedUids, createAnonymousUid);
|
|
296
275
|
item = setOrderCollectionUid(kind, item, uid);
|
|
297
276
|
result[index] = item;
|
|
298
277
|
stats.backfilledUidCount += 1;
|
|
299
|
-
if (!persistentId)
|
|
300
|
-
stats.anonymousRowCount += 1;
|
|
278
|
+
if (!persistentId) stats.anonymousRowCount += 1;
|
|
301
279
|
}
|
|
302
280
|
if (occupiedUids.has(uid)) {
|
|
303
281
|
const replacementUid = persistentId ? allocatePersistentConflictUid(kind, persistentId, occupiedUids) : allocateAnonymousUid(occupiedUids, createAnonymousUid);
|
|
@@ -307,123 +285,120 @@ function normalizeOrderCollection(kind, items, options) {
|
|
|
307
285
|
from: uid,
|
|
308
286
|
to: replacementUid,
|
|
309
287
|
persistentId,
|
|
310
|
-
scope:
|
|
311
|
-
referenceOwnerUid: kind ===
|
|
312
|
-
(item == null ? void 0 : item.booking_uid) || ((_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a.booking_uid) || ""
|
|
313
|
-
) || null : kind === "booking" ? String(
|
|
314
|
-
(item == null ? void 0 : item.product_uid) || ((_b = item == null ? void 0 : item.metadata) == null ? void 0 : _b.product_uid) || ""
|
|
315
|
-
) || null : null
|
|
288
|
+
scope: 'linked-owner',
|
|
289
|
+
referenceOwnerUid: kind === 'product' ? String(item?.booking_uid || item?.metadata?.booking_uid || '') || null : kind === 'booking' ? String(item?.product_uid || item?.metadata?.product_uid || '') || null : null
|
|
316
290
|
});
|
|
317
291
|
uid = replacementUid;
|
|
318
292
|
stats.uidConflictCount += 1;
|
|
319
293
|
}
|
|
320
294
|
occupiedUids.add(uid);
|
|
321
295
|
}
|
|
322
|
-
return {
|
|
296
|
+
return {
|
|
297
|
+
items: result,
|
|
298
|
+
stats,
|
|
299
|
+
uidRemaps
|
|
300
|
+
};
|
|
323
301
|
}
|
|
324
302
|
function applyOrderCollectionUidRemaps(sourceOrder, uidRemaps) {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
if (
|
|
331
|
-
|
|
332
|
-
const ownerKind = remap.kind === "product" ? "booking" : remap.kind === "booking" ? "product" : null;
|
|
333
|
-
if (!ownerKind)
|
|
334
|
-
return false;
|
|
335
|
-
return uidRemaps.some(
|
|
336
|
-
(candidate) => candidate.scope === "linked-owner" && candidate.kind === ownerKind && candidate.from === remap.referenceOwnerUid
|
|
337
|
-
);
|
|
303
|
+
if (!uidRemaps.length) return sourceOrder;
|
|
304
|
+
const order = (0, _lodashEs.cloneDeep)(sourceOrder);
|
|
305
|
+
const hasAmbiguousLinkedOwner = remap => {
|
|
306
|
+
if (remap.scope !== 'linked-owner' || !remap.referenceOwnerUid) return false;
|
|
307
|
+
const ownerKind = remap.kind === 'product' ? 'booking' : remap.kind === 'booking' ? 'product' : null;
|
|
308
|
+
if (!ownerKind) return false;
|
|
309
|
+
return uidRemaps.some(candidate => candidate.scope === 'linked-owner' && candidate.kind === ownerKind && candidate.from === remap.referenceOwnerUid);
|
|
338
310
|
};
|
|
339
311
|
for (const remap of uidRemaps) {
|
|
340
|
-
if (remap.from === remap.to)
|
|
341
|
-
continue;
|
|
312
|
+
if (remap.from === remap.to) continue;
|
|
342
313
|
const linkedOwnerIsAmbiguous = hasAmbiguousLinkedOwner(remap);
|
|
343
|
-
if (remap.kind ===
|
|
314
|
+
if (remap.kind === 'product') {
|
|
344
315
|
for (const booking of order.bookings || []) {
|
|
345
|
-
if (remap.scope ===
|
|
316
|
+
if (remap.scope === 'linked-owner' && (linkedOwnerIsAmbiguous || getOrderCollectionUid('booking', booking) !== remap.referenceOwnerUid)) {
|
|
346
317
|
continue;
|
|
347
318
|
}
|
|
348
|
-
if (String(
|
|
319
|
+
if (String(booking?.product_uid || '') === remap.from) {
|
|
349
320
|
booking.product_uid = remap.to;
|
|
350
321
|
}
|
|
351
|
-
if (String(
|
|
352
|
-
booking.metadata = {
|
|
322
|
+
if (String(booking?.metadata?.product_uid || '') === remap.from) {
|
|
323
|
+
booking.metadata = {
|
|
324
|
+
...(booking.metadata || {}),
|
|
325
|
+
product_uid: remap.to
|
|
326
|
+
};
|
|
353
327
|
}
|
|
354
328
|
}
|
|
355
|
-
|
|
329
|
+
// 冲突 UID 仍由第一条持有;赠品父引用缺少可用的持久化行定位时不能全局改写。
|
|
330
|
+
if (remap.scope !== 'linked-owner') {
|
|
356
331
|
for (const product of order.products || []) {
|
|
357
|
-
if (String(
|
|
332
|
+
if (String(product?.metadata?.parent_unique_identification_number || '') === remap.from) {
|
|
358
333
|
product.metadata = {
|
|
359
|
-
...product.metadata || {},
|
|
334
|
+
...(product.metadata || {}),
|
|
360
335
|
parent_unique_identification_number: remap.to
|
|
361
336
|
};
|
|
362
337
|
}
|
|
363
|
-
const giftInfo =
|
|
364
|
-
if (giftInfo && typeof giftInfo ===
|
|
365
|
-
const sourceProductIds = Array.isArray(giftInfo.sourceProductIds) ? giftInfo.sourceProductIds.map(
|
|
366
|
-
|
|
367
|
-
) : giftInfo.sourceProductIds;
|
|
368
|
-
const sourceProductId = String(giftInfo.sourceProductId || "") === remap.from ? remap.to : giftInfo.sourceProductId;
|
|
338
|
+
const giftInfo = product?.metadata?._giftInfo;
|
|
339
|
+
if (giftInfo && typeof giftInfo === 'object') {
|
|
340
|
+
const sourceProductIds = Array.isArray(giftInfo.sourceProductIds) ? giftInfo.sourceProductIds.map(uid => String(uid) === remap.from ? remap.to : uid) : giftInfo.sourceProductIds;
|
|
341
|
+
const sourceProductId = String(giftInfo.sourceProductId || '') === remap.from ? remap.to : giftInfo.sourceProductId;
|
|
369
342
|
product.metadata = {
|
|
370
|
-
...product.metadata || {},
|
|
343
|
+
...(product.metadata || {}),
|
|
371
344
|
_giftInfo: {
|
|
372
345
|
...giftInfo,
|
|
373
|
-
...sourceProductIds !==
|
|
374
|
-
|
|
346
|
+
...(sourceProductIds !== undefined ? {
|
|
347
|
+
sourceProductIds
|
|
348
|
+
} : {}),
|
|
349
|
+
...(sourceProductId !== undefined ? {
|
|
350
|
+
sourceProductId
|
|
351
|
+
} : {})
|
|
375
352
|
}
|
|
376
353
|
};
|
|
377
354
|
}
|
|
378
355
|
}
|
|
379
356
|
}
|
|
380
|
-
const productsByUid =
|
|
381
|
-
const cachedProduct = productsByUid
|
|
382
|
-
const cachedPersistentId = getOrderCollectionPersistentId(
|
|
383
|
-
|
|
384
|
-
(
|
|
385
|
-
|
|
386
|
-
if (productsByUid && remap.scope === "linked-owner") {
|
|
387
|
-
const retainedProduct = (order.products || []).find(
|
|
388
|
-
(product) => getOrderCollectionUid("product", product) === remap.from
|
|
389
|
-
);
|
|
390
|
-
const remappedProduct = (order.products || []).find(
|
|
391
|
-
(product) => getOrderCollectionUid("product", product) === remap.to
|
|
392
|
-
);
|
|
357
|
+
const productsByUid = order._extend?.productsByUid;
|
|
358
|
+
const cachedProduct = productsByUid?.[remap.from];
|
|
359
|
+
const cachedPersistentId = getOrderCollectionPersistentId('product', cachedProduct?.origin || cachedProduct);
|
|
360
|
+
if (productsByUid && remap.scope === 'linked-owner') {
|
|
361
|
+
const retainedProduct = (order.products || []).find(product => getOrderCollectionUid('product', product) === remap.from);
|
|
362
|
+
const remappedProduct = (order.products || []).find(product => getOrderCollectionUid('product', product) === remap.to);
|
|
393
363
|
if (cachedProduct && remap.persistentId && cachedPersistentId === remap.persistentId) {
|
|
394
364
|
productsByUid[remap.to] = {
|
|
395
|
-
...cachedProduct || {},
|
|
396
|
-
...productsByUid[remap.to] || {}
|
|
365
|
+
...(cachedProduct || {}),
|
|
366
|
+
...(productsByUid[remap.to] || {})
|
|
397
367
|
};
|
|
398
368
|
if (retainedProduct) {
|
|
399
369
|
productsByUid[remap.from] = {
|
|
400
|
-
...cachedProduct || {},
|
|
401
|
-
origin: (0,
|
|
370
|
+
...(cachedProduct || {}),
|
|
371
|
+
origin: (0, _lodashEs.cloneDeep)(retainedProduct)
|
|
402
372
|
};
|
|
403
373
|
}
|
|
404
374
|
} else if (remappedProduct && !productsByUid[remap.to]) {
|
|
405
|
-
productsByUid[remap.to] = {
|
|
375
|
+
productsByUid[remap.to] = {
|
|
376
|
+
origin: (0, _lodashEs.cloneDeep)(remappedProduct)
|
|
377
|
+
};
|
|
406
378
|
}
|
|
407
379
|
continue;
|
|
408
380
|
}
|
|
409
|
-
if (cachedProduct && remap.scope !==
|
|
381
|
+
if (cachedProduct && remap.scope !== 'linked-owner') {
|
|
410
382
|
productsByUid[remap.to] = {
|
|
411
|
-
...cachedProduct || {},
|
|
412
|
-
...productsByUid[remap.to] || {}
|
|
383
|
+
...(cachedProduct || {}),
|
|
384
|
+
...(productsByUid[remap.to] || {})
|
|
413
385
|
};
|
|
414
386
|
delete productsByUid[remap.from];
|
|
415
387
|
}
|
|
416
388
|
}
|
|
417
|
-
if (remap.kind ===
|
|
389
|
+
if (remap.kind === 'booking') {
|
|
418
390
|
for (const product of order.products || []) {
|
|
419
|
-
if (remap.scope ===
|
|
391
|
+
if (remap.scope === 'linked-owner' && (linkedOwnerIsAmbiguous || getOrderCollectionUid('product', product) !== remap.referenceOwnerUid)) {
|
|
420
392
|
continue;
|
|
421
393
|
}
|
|
422
|
-
if (String(
|
|
394
|
+
if (String(product?.booking_uid || '') === remap.from) {
|
|
423
395
|
product.booking_uid = remap.to;
|
|
424
396
|
}
|
|
425
|
-
if (String(
|
|
426
|
-
product.metadata = {
|
|
397
|
+
if (String(product?.metadata?.booking_uid || '') === remap.from) {
|
|
398
|
+
product.metadata = {
|
|
399
|
+
...(product.metadata || {}),
|
|
400
|
+
booking_uid: remap.to
|
|
401
|
+
};
|
|
427
402
|
}
|
|
428
403
|
}
|
|
429
404
|
}
|
|
@@ -431,34 +406,15 @@ function applyOrderCollectionUidRemaps(sourceOrder, uidRemaps) {
|
|
|
431
406
|
return order;
|
|
432
407
|
}
|
|
433
408
|
function normalizeOrderCollections(sourceOrder, options) {
|
|
434
|
-
let order = (0,
|
|
409
|
+
let order = (0, _lodashEs.cloneDeep)(sourceOrder || {});
|
|
435
410
|
const orderRecord = order;
|
|
436
|
-
const productResult = normalizeOrderCollection(
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
);
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
Array.isArray(orderRecord.bookings) ? orderRecord.bookings : [],
|
|
444
|
-
options
|
|
445
|
-
);
|
|
446
|
-
const paymentResult = normalizeOrderCollection(
|
|
447
|
-
"payment",
|
|
448
|
-
Array.isArray(orderRecord.payments) ? orderRecord.payments : [],
|
|
449
|
-
options
|
|
450
|
-
);
|
|
451
|
-
if (Array.isArray(orderRecord.products))
|
|
452
|
-
orderRecord.products = productResult.items;
|
|
453
|
-
if (Array.isArray(orderRecord.bookings))
|
|
454
|
-
orderRecord.bookings = bookingResult.items;
|
|
455
|
-
if (Array.isArray(orderRecord.payments))
|
|
456
|
-
orderRecord.payments = paymentResult.items;
|
|
457
|
-
const uidRemaps = [
|
|
458
|
-
...productResult.uidRemaps,
|
|
459
|
-
...bookingResult.uidRemaps,
|
|
460
|
-
...paymentResult.uidRemaps
|
|
461
|
-
];
|
|
411
|
+
const productResult = normalizeOrderCollection('product', Array.isArray(orderRecord.products) ? orderRecord.products : [], options);
|
|
412
|
+
const bookingResult = normalizeOrderCollection('booking', Array.isArray(orderRecord.bookings) ? orderRecord.bookings : [], options);
|
|
413
|
+
const paymentResult = normalizeOrderCollection('payment', Array.isArray(orderRecord.payments) ? orderRecord.payments : [], options);
|
|
414
|
+
if (Array.isArray(orderRecord.products)) orderRecord.products = productResult.items;
|
|
415
|
+
if (Array.isArray(orderRecord.bookings)) orderRecord.bookings = bookingResult.items;
|
|
416
|
+
if (Array.isArray(orderRecord.payments)) orderRecord.payments = paymentResult.items;
|
|
417
|
+
const uidRemaps = [...productResult.uidRemaps, ...bookingResult.uidRemaps, ...paymentResult.uidRemaps];
|
|
462
418
|
order = applyOrderCollectionUidRemaps(order, uidRemaps);
|
|
463
419
|
return {
|
|
464
420
|
order,
|
|
@@ -469,20 +425,4 @@ function normalizeOrderCollections(sourceOrder, options) {
|
|
|
469
425
|
},
|
|
470
426
|
uidRemaps
|
|
471
427
|
};
|
|
472
|
-
}
|
|
473
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
474
|
-
0 && (module.exports = {
|
|
475
|
-
applyOrderCollectionUidRemaps,
|
|
476
|
-
buildOrderCollectionFallbackUid,
|
|
477
|
-
createUuidV4,
|
|
478
|
-
getOrderCollectionPersistentId,
|
|
479
|
-
getOrderCollectionReferenceUid,
|
|
480
|
-
getOrderCollectionUid,
|
|
481
|
-
isBlankOrderCollectionIdentity,
|
|
482
|
-
isSameOrderCollectionItem,
|
|
483
|
-
mergeOrderCollectionItems,
|
|
484
|
-
normalizeOrderCollection,
|
|
485
|
-
normalizeOrderCollections,
|
|
486
|
-
repairDuplicateProductLineIdentities,
|
|
487
|
-
setOrderCollectionUid
|
|
488
|
-
});
|
|
428
|
+
}
|