@pisell/pisellos 2.3.219 → 2.3.221
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/modules/OpenData/index.d.ts +3 -0
- package/dist/modules/OpenData/index.js +160 -84
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.js +850 -591
- package/dist/server/modules/order/index.d.ts +1 -0
- package/dist/server/modules/order/index.js +51 -51
- package/dist/solution/BaseSales/index.d.ts +2 -0
- package/dist/solution/BaseSales/index.js +65 -37
- package/dist/solution/BaseSales/types.d.ts +2 -0
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +7 -0
- package/dist/solution/BookingTicket/index.js +510 -385
- package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +9 -9
- package/dist/solution/Sales/index.d.ts +2 -1
- package/dist/solution/Sales/index.js +123 -49
- package/dist/solution/Sales/types.d.ts +6 -0
- package/dist/solution/Sales/types.js +2 -0
- package/lib/modules/OpenData/index.d.ts +3 -0
- package/lib/modules/OpenData/index.js +51 -18
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/server/index.d.ts +3 -0
- package/lib/server/index.js +154 -17
- package/lib/server/modules/order/index.d.ts +1 -0
- package/lib/server/modules/order/index.js +4 -3
- package/lib/solution/BaseSales/index.d.ts +2 -0
- package/lib/solution/BaseSales/index.js +27 -6
- package/lib/solution/BaseSales/types.d.ts +2 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +7 -0
- package/lib/solution/BookingTicket/index.js +50 -4
- package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +9 -9
- package/lib/solution/Sales/index.d.ts +2 -1
- package/lib/solution/Sales/index.js +28 -1
- package/lib/solution/Sales/types.d.ts +6 -0
- package/lib/solution/Sales/types.js +1 -0
- package/package.json +1 -1
|
@@ -109,6 +109,7 @@ export declare class OrderModule extends BaseModule implements Module {
|
|
|
109
109
|
getLocalOrderForPaymentReadiness(lookup: OrderId): Promise<OrderData | null>;
|
|
110
110
|
getLocalOrderByLookup(lookup: OrderId, options?: {
|
|
111
111
|
operationId?: string;
|
|
112
|
+
exactOrderId?: boolean;
|
|
112
113
|
}): Promise<OrderData | null>;
|
|
113
114
|
getLocalPayment(params: {
|
|
114
115
|
saleId: OrderId;
|
|
@@ -980,6 +980,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
980
980
|
var _this5 = this;
|
|
981
981
|
var options,
|
|
982
982
|
key,
|
|
983
|
+
matches,
|
|
983
984
|
logContext,
|
|
984
985
|
memoryOrderById,
|
|
985
986
|
memoryOrder,
|
|
@@ -992,6 +993,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
992
993
|
case 0:
|
|
993
994
|
options = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : {};
|
|
994
995
|
key = this.getIdKey(lookup);
|
|
996
|
+
matches = function matches(order) {
|
|
997
|
+
return options.exactOrderId ? order.order_id != null && _this5.getIdKey(order.order_id) === key : _this5.isOrderLookupMatch(order, key);
|
|
998
|
+
};
|
|
995
999
|
logContext = {
|
|
996
1000
|
operation_id: options.operationId,
|
|
997
1001
|
lookup: key,
|
|
@@ -1001,39 +1005,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1001
1005
|
this.logInfo('getLocalOrderByLookup-localPayment-开始', logContext);
|
|
1002
1006
|
}
|
|
1003
1007
|
memoryOrderById = this.store.map.get(key);
|
|
1004
|
-
if (!memoryOrderById) {
|
|
1005
|
-
_context6.next =
|
|
1008
|
+
if (!(memoryOrderById && (!options.exactOrderId || matches(memoryOrderById)))) {
|
|
1009
|
+
_context6.next = 9;
|
|
1006
1010
|
break;
|
|
1007
1011
|
}
|
|
1008
1012
|
if (options.operationId) {
|
|
1009
1013
|
this.logInfo('getLocalOrderByLookup-localPayment-命中内存映射', _objectSpread(_objectSpread({}, logContext), this.buildLocalPaymentOrderLogContext(memoryOrderById)));
|
|
1010
1014
|
}
|
|
1011
1015
|
return _context6.abrupt("return", memoryOrderById);
|
|
1012
|
-
case
|
|
1013
|
-
memoryOrder = this.store.list.find(
|
|
1014
|
-
return _this5.isOrderLookupMatch(order, key);
|
|
1015
|
-
});
|
|
1016
|
+
case 9:
|
|
1017
|
+
memoryOrder = this.store.list.find(matches);
|
|
1016
1018
|
if (!memoryOrder) {
|
|
1017
|
-
_context6.next =
|
|
1019
|
+
_context6.next = 13;
|
|
1018
1020
|
break;
|
|
1019
1021
|
}
|
|
1020
1022
|
if (options.operationId) {
|
|
1021
1023
|
this.logInfo('getLocalOrderByLookup-localPayment-命中内存列表', _objectSpread(_objectSpread({}, logContext), this.buildLocalPaymentOrderLogContext(memoryOrder)));
|
|
1022
1024
|
}
|
|
1023
1025
|
return _context6.abrupt("return", memoryOrder);
|
|
1024
|
-
case
|
|
1026
|
+
case 13:
|
|
1025
1027
|
if (options.operationId) {
|
|
1026
1028
|
this.logInfo('getLocalOrderByLookup-localPayment-开始读取SQLite', logContext);
|
|
1027
1029
|
}
|
|
1028
|
-
_context6.next =
|
|
1030
|
+
_context6.next = 16;
|
|
1029
1031
|
return this.loadOrdersFromSQLite();
|
|
1030
|
-
case
|
|
1032
|
+
case 16:
|
|
1031
1033
|
orders = _context6.sent;
|
|
1032
|
-
localOrder = orders.find(
|
|
1033
|
-
return _this5.isOrderLookupMatch(order, key);
|
|
1034
|
-
});
|
|
1034
|
+
localOrder = orders.find(matches);
|
|
1035
1035
|
if (localOrder) {
|
|
1036
|
-
_context6.next =
|
|
1036
|
+
_context6.next = 21;
|
|
1037
1037
|
break;
|
|
1038
1038
|
}
|
|
1039
1039
|
if (options.operationId) {
|
|
@@ -1042,7 +1042,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1042
1042
|
}));
|
|
1043
1043
|
}
|
|
1044
1044
|
return _context6.abrupt("return", null);
|
|
1045
|
-
case
|
|
1045
|
+
case 21:
|
|
1046
1046
|
this.store.list = this.normalizeOrdersForMemoryList(orders, 'getLocalOrderByLookup.sqliteMemory');
|
|
1047
1047
|
this.syncOrdersMap();
|
|
1048
1048
|
normalizedOrder = this.normalizeOrderForMemoryList(localOrder);
|
|
@@ -1052,7 +1052,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1052
1052
|
}, this.buildLocalPaymentOrderLogContext(normalizedOrder)));
|
|
1053
1053
|
}
|
|
1054
1054
|
return _context6.abrupt("return", normalizedOrder);
|
|
1055
|
-
case
|
|
1055
|
+
case 26:
|
|
1056
1056
|
case "end":
|
|
1057
1057
|
return _context6.stop();
|
|
1058
1058
|
}
|
|
@@ -1913,7 +1913,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1913
1913
|
index,
|
|
1914
1914
|
_iterator8,
|
|
1915
1915
|
_step8,
|
|
1916
|
-
|
|
1916
|
+
_key,
|
|
1917
1917
|
_iterator9,
|
|
1918
1918
|
_step9,
|
|
1919
1919
|
_step9$value,
|
|
@@ -2007,9 +2007,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2007
2007
|
_iterator8 = _createForOfIteratorHelper(this.getOrderIdentityMatchKeys(updatedList[index]));
|
|
2008
2008
|
try {
|
|
2009
2009
|
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
2010
|
-
|
|
2010
|
+
_key = _step8.value;
|
|
2011
2011
|
// 同一 key 命中多张时保留最靠前的下标,与原 findIndex「取首个匹配」一致
|
|
2012
|
-
if (!identityKeyToIndex.has(
|
|
2012
|
+
if (!identityKeyToIndex.has(_key)) identityKeyToIndex.set(_key, index);
|
|
2013
2013
|
}
|
|
2014
2014
|
} catch (err) {
|
|
2015
2015
|
_iterator8.e(err);
|
|
@@ -2121,7 +2121,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2121
2121
|
value: (function () {
|
|
2122
2122
|
var _upsertLocalDraftOrders = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(draftOrders) {
|
|
2123
2123
|
var _this12 = this;
|
|
2124
|
-
var draftMap, memoryDraftMap, _iterator10, _step10, order, draftOrder, storageKey, memoryDraftOrder, storageKeyMigrations, mergeActions, updatedList, previousStorageKeys, identityKeyToIndex, index, _iterator11, _step11,
|
|
2124
|
+
var draftMap, memoryDraftMap, _iterator10, _step10, order, draftOrder, storageKey, memoryDraftOrder, storageKeyMigrations, mergeActions, updatedList, previousStorageKeys, identityKeyToIndex, index, _iterator11, _step11, _key2, _iterator12, _step12, _step12$value, _storageKey2, _draftOrder, matchIndex, existingOrder, previousStorageKey, reconciledDraftOrder, mergedOrder, nextOrder, _nextOrder$order_id3, insertIndex, patchedOrders, previousList, removedLegacyMemoryDraft;
|
|
2125
2125
|
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
2126
2126
|
while (1) switch (_context18.prev = _context18.next) {
|
|
2127
2127
|
case 0:
|
|
@@ -2201,8 +2201,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2201
2201
|
_iterator11 = _createForOfIteratorHelper(this.getOrderIdentityMatchKeys(updatedList[index]));
|
|
2202
2202
|
try {
|
|
2203
2203
|
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
2204
|
-
|
|
2205
|
-
if (!identityKeyToIndex.has(
|
|
2204
|
+
_key2 = _step11.value;
|
|
2205
|
+
if (!identityKeyToIndex.has(_key2)) identityKeyToIndex.set(_key2, index);
|
|
2206
2206
|
}
|
|
2207
2207
|
} catch (err) {
|
|
2208
2208
|
_iterator11.e(err);
|
|
@@ -2824,7 +2824,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2824
2824
|
value: (function () {
|
|
2825
2825
|
var _mergeOrdersToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(freshOrders, source) {
|
|
2826
2826
|
var _this18 = this;
|
|
2827
|
-
var storeOrderCountBefore, normalizedFreshOrders, incomingProductsHaveStableIdentity, _iterator15, _step15, order, id, rawProducts, _incomingProductsHave, allProductsHaveStableIdentity, orderIdKey, uniqueFreshOrders, uniqueFreshCount, patchedOrders, remoteProductMembershipChanges, forceWriteStorageKeys, storageKeyMigrations, mergeActions, existingProductsHaveStableIdentity, updatedList, identityKeyToIndex, index, identityKeys, _iterator16, _step16,
|
|
2827
|
+
var storeOrderCountBefore, normalizedFreshOrders, incomingProductsHaveStableIdentity, _iterator15, _step15, order, id, rawProducts, _incomingProductsHave, allProductsHaveStableIdentity, orderIdKey, uniqueFreshOrders, uniqueFreshCount, patchedOrders, remoteProductMembershipChanges, forceWriteStorageKeys, storageKeyMigrations, mergeActions, existingProductsHaveStableIdentity, updatedList, identityKeyToIndex, index, identityKeys, _iterator16, _step16, _key3, _iterator17, _step17, fresh, freshIdentityKeys, matchIndex, storageKey, mergeKey, existingOrder, previousStorageKey, _ref, _existingOrder$order_, _ref2, _external_sale_number2, _existingOrder$paymen, _fresh$payment_status, _existingOrder$need_s, _fresh$need_sync, _ref3, _existingOrder$order_2, _ref4, _external_sale_number3, _existingOrder$is_dra, _fresh$is_draft_order, mergedOrder, freshOrderId, incomingProductsAreStable, membershipChange, mergedProductsHaveStableIdentity, adjustedMatchIndex, duplicateIndexes, _iterator18, _step18, _key5, _duplicateIndex, _iterator19, _step19, duplicateIndex, _index, _iterator20, _step20, _key4, nextStorageKey, _ref5, _ref6, _mergedOrder$order_id, mergedStorageKey, insertIndex, insertCount, updateCount;
|
|
2828
2828
|
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
2829
2829
|
while (1) switch (_context23.prev = _context23.next) {
|
|
2830
2830
|
case 0:
|
|
@@ -2897,9 +2897,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2897
2897
|
_iterator16 = _createForOfIteratorHelper(identityKeys);
|
|
2898
2898
|
try {
|
|
2899
2899
|
for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
|
|
2900
|
-
|
|
2900
|
+
_key3 = _step16.value;
|
|
2901
2901
|
// 同一 key 命中多张时保留最靠前的下标,与原 findIndex「取首个匹配」一致
|
|
2902
|
-
if (!identityKeyToIndex.has(
|
|
2902
|
+
if (!identityKeyToIndex.has(_key3)) identityKeyToIndex.set(_key3, index);
|
|
2903
2903
|
}
|
|
2904
2904
|
} catch (err) {
|
|
2905
2905
|
_iterator16.e(err);
|
|
@@ -2974,8 +2974,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2974
2974
|
_context23.next = 74;
|
|
2975
2975
|
break;
|
|
2976
2976
|
}
|
|
2977
|
-
|
|
2978
|
-
_duplicateIndex = identityKeyToIndex.get(
|
|
2977
|
+
_key5 = _step18.value;
|
|
2978
|
+
_duplicateIndex = identityKeyToIndex.get(_key5);
|
|
2979
2979
|
if (!(_duplicateIndex === undefined || _duplicateIndex === matchIndex)) {
|
|
2980
2980
|
_context23.next = 71;
|
|
2981
2981
|
break;
|
|
@@ -3021,8 +3021,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3021
3021
|
_iterator20 = _createForOfIteratorHelper(this.getOrderIdentityMatchKeys(updatedList[_index]));
|
|
3022
3022
|
try {
|
|
3023
3023
|
for (_iterator20.s(); !(_step20 = _iterator20.n()).done;) {
|
|
3024
|
-
|
|
3025
|
-
if (!identityKeyToIndex.has(
|
|
3024
|
+
_key4 = _step20.value;
|
|
3025
|
+
if (!identityKeyToIndex.has(_key4)) identityKeyToIndex.set(_key4, _index);
|
|
3026
3026
|
}
|
|
3027
3027
|
} catch (err) {
|
|
3028
3028
|
_iterator20.e(err);
|
|
@@ -3135,8 +3135,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3135
3135
|
_step21;
|
|
3136
3136
|
try {
|
|
3137
3137
|
for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {
|
|
3138
|
-
var
|
|
3139
|
-
var index = identityKeyToIndex.get(
|
|
3138
|
+
var _key6 = _step21.value;
|
|
3139
|
+
var index = identityKeyToIndex.get(_key6);
|
|
3140
3140
|
if (index === undefined) continue;
|
|
3141
3141
|
if (matchIndex < 0 || index < matchIndex) matchIndex = index;
|
|
3142
3142
|
}
|
|
@@ -3259,8 +3259,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3259
3259
|
_step23;
|
|
3260
3260
|
try {
|
|
3261
3261
|
for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {
|
|
3262
|
-
var
|
|
3263
|
-
identityKeyToIndex.set(
|
|
3262
|
+
var _key7 = _step23.value;
|
|
3263
|
+
identityKeyToIndex.set(_key7, index);
|
|
3264
3264
|
}
|
|
3265
3265
|
} catch (err) {
|
|
3266
3266
|
_iterator23.e(err);
|
|
@@ -3490,8 +3490,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3490
3490
|
_step27;
|
|
3491
3491
|
try {
|
|
3492
3492
|
for (_iterator27.s(); !(_step27 = _iterator27.n()).done;) {
|
|
3493
|
-
var
|
|
3494
|
-
seenKeys.add(
|
|
3493
|
+
var _key8 = _step27.value;
|
|
3494
|
+
seenKeys.add(_key8);
|
|
3495
3495
|
}
|
|
3496
3496
|
} catch (err) {
|
|
3497
3497
|
_iterator27.e(err);
|
|
@@ -3518,8 +3518,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3518
3518
|
_step28;
|
|
3519
3519
|
try {
|
|
3520
3520
|
for (_iterator28.s(); !(_step28 = _iterator28.n()).done;) {
|
|
3521
|
-
var
|
|
3522
|
-
seenKeys.add(
|
|
3521
|
+
var _key9 = _step28.value;
|
|
3522
|
+
seenKeys.add(_key9);
|
|
3523
3523
|
}
|
|
3524
3524
|
} catch (err) {
|
|
3525
3525
|
_iterator28.e(err);
|
|
@@ -3600,8 +3600,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3600
3600
|
_step30;
|
|
3601
3601
|
try {
|
|
3602
3602
|
for (_iterator30.s(); !(_step30 = _iterator30.n()).done;) {
|
|
3603
|
-
var
|
|
3604
|
-
existingByIdentity.set(
|
|
3603
|
+
var _key10 = _step30.value;
|
|
3604
|
+
existingByIdentity.set(_key10, order);
|
|
3605
3605
|
}
|
|
3606
3606
|
} catch (err) {
|
|
3607
3607
|
_iterator30.e(err);
|
|
@@ -3715,10 +3715,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3715
3715
|
_step32;
|
|
3716
3716
|
try {
|
|
3717
3717
|
for (_iterator32.s(); !(_step32 = _iterator32.n()).done;) {
|
|
3718
|
-
var
|
|
3719
|
-
var group = groups.get(
|
|
3718
|
+
var _key11 = _step32.value;
|
|
3719
|
+
var group = groups.get(_key11) || [];
|
|
3720
3720
|
group.push(order);
|
|
3721
|
-
groups.set(
|
|
3721
|
+
groups.set(_key11, group);
|
|
3722
3722
|
}
|
|
3723
3723
|
} catch (err) {
|
|
3724
3724
|
_iterator32.e(err);
|
|
@@ -3947,7 +3947,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3947
3947
|
_context25.next = 9;
|
|
3948
3948
|
return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
3949
3949
|
var _options$onTiming;
|
|
3950
|
-
var rawReadStartedAt, orders, sqliteRawReadMs, normalizeStartedAt, _this24$deduplicateSt, list, repairs, obsoleteKeys, sqliteNormalizeMs, _iterator34, _step34,
|
|
3950
|
+
var rawReadStartedAt, orders, sqliteRawReadMs, normalizeStartedAt, _this24$deduplicateSt, list, repairs, obsoleteKeys, sqliteNormalizeMs, _iterator34, _step34, _key12;
|
|
3951
3951
|
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
3952
3952
|
while (1) switch (_context24.prev = _context24.next) {
|
|
3953
3953
|
case 0:
|
|
@@ -3978,11 +3978,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3978
3978
|
_context24.next = 24;
|
|
3979
3979
|
break;
|
|
3980
3980
|
}
|
|
3981
|
-
|
|
3981
|
+
_key12 = _step34.value;
|
|
3982
3982
|
_context24.next = 21;
|
|
3983
|
-
return _this24.dbManager.delete(INDEXDB_STORE_NAME,
|
|
3983
|
+
return _this24.dbManager.delete(INDEXDB_STORE_NAME, _key12);
|
|
3984
3984
|
case 21:
|
|
3985
|
-
_this24.recentSqliteWriteByStorageKey.delete(
|
|
3985
|
+
_this24.recentSqliteWriteByStorageKey.delete(_key12);
|
|
3986
3986
|
case 22:
|
|
3987
3987
|
_context24.next = 17;
|
|
3988
3988
|
break;
|
|
@@ -4073,9 +4073,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4073
4073
|
var id = this.getRealOrderId(order);
|
|
4074
4074
|
var external = order.external_sale_number;
|
|
4075
4075
|
if (!id || this.isBlankIdentityValue(external)) continue;
|
|
4076
|
-
var
|
|
4077
|
-
var previous = idsByExternal.get(
|
|
4078
|
-
idsByExternal.set(
|
|
4076
|
+
var _key13 = String(external);
|
|
4077
|
+
var previous = idsByExternal.get(_key13);
|
|
4078
|
+
idsByExternal.set(_key13, previous === undefined || previous === id ? id : null);
|
|
4079
4079
|
}
|
|
4080
4080
|
} catch (err) {
|
|
4081
4081
|
_iterator35.e(err);
|
|
@@ -4119,8 +4119,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4119
4119
|
try {
|
|
4120
4120
|
for (_iterator37.s(); !(_step37 = _iterator37.n()).done;) {
|
|
4121
4121
|
var _order2 = _step37.value.order;
|
|
4122
|
-
var
|
|
4123
|
-
canonicalKeyCounts.set(
|
|
4122
|
+
var _key14 = this.getOrderStorageKey(_order2);
|
|
4123
|
+
canonicalKeyCounts.set(_key14, (canonicalKeyCounts.get(_key14) || 0) + 1);
|
|
4124
4124
|
}
|
|
4125
4125
|
} catch (err) {
|
|
4126
4126
|
_iterator37.e(err);
|
|
@@ -55,6 +55,8 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
55
55
|
protected store: BaseSalesState;
|
|
56
56
|
protected otherParams: Record<string, any>;
|
|
57
57
|
getInventory(): InventoryController | undefined;
|
|
58
|
+
/** Retail and standard POS opt in per sales instance; other hosts retain their member flow. */
|
|
59
|
+
isMemberCartConsistencyEnabled(): boolean;
|
|
58
60
|
prepareCheckout(signal?: AbortSignal): Promise<CheckoutRuntimeSnapshot | undefined>;
|
|
59
61
|
protected cacheId: string | undefined;
|
|
60
62
|
/**
|
|
@@ -38,6 +38,7 @@ import { BaseModule } from "../../modules/BaseModule";
|
|
|
38
38
|
import { isLocalFinalizedPayment, PAYMENT_REFRESH_MESSAGE, requiresLocalPaymentRefresh } from "../../modules/Order/localEftposState";
|
|
39
39
|
import { BaseSalesHookNames } from "./types";
|
|
40
40
|
import { OrderModule } from "../../modules/Order";
|
|
41
|
+
import { ensureUniqueProductLineUids, consolidateDiscountFreeProductLines } from "../../modules/Order/utils/discountProductLineIdentity";
|
|
41
42
|
import { isFulfillmentTimingBooking } from "../../modules/Order/pickupTiming";
|
|
42
43
|
import { PickupTimingController } from "./pickupTiming";
|
|
43
44
|
import { FulfillmentItemRulesController } from "./fulfillmentItemRules";
|
|
@@ -176,6 +177,14 @@ function preserveManualProductDiscountProducts(previousProducts, nextProducts) {
|
|
|
176
177
|
return previous && isBaseSalesManualProductDiscountProduct(previous) ? previous : product;
|
|
177
178
|
});
|
|
178
179
|
}
|
|
180
|
+
|
|
181
|
+
/** Rules may split a coupon quantity into rows that still share the original UID. */
|
|
182
|
+
function applyDiscountProductLines(tempOrder, products, discounts, enableMemberCartConsistency) {
|
|
183
|
+
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, products);
|
|
184
|
+
if (!enableMemberCartConsistency) return;
|
|
185
|
+
ensureUniqueProductLineUids(tempOrder, discounts);
|
|
186
|
+
consolidateDiscountFreeProductLines(tempOrder);
|
|
187
|
+
}
|
|
179
188
|
function isBaseSalesHistoricalDiscountEntry(discount) {
|
|
180
189
|
return Boolean((discount === null || discount === void 0 ? void 0 : discount.isEditMode) || (discount === null || discount === void 0 ? void 0 : discount.isDisabled) || (discount === null || discount === void 0 ? void 0 : discount.order_discount_id) != null);
|
|
181
190
|
}
|
|
@@ -652,6 +661,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
652
661
|
value: function getInventory() {
|
|
653
662
|
return this.otherParams.inventory;
|
|
654
663
|
}
|
|
664
|
+
|
|
665
|
+
/** Retail and standard POS opt in per sales instance; other hosts retain their member flow. */
|
|
666
|
+
}, {
|
|
667
|
+
key: "isMemberCartConsistencyEnabled",
|
|
668
|
+
value: function isMemberCartConsistencyEnabled() {
|
|
669
|
+
return this.otherParams.enableMemberCartConsistency === true;
|
|
670
|
+
}
|
|
655
671
|
}, {
|
|
656
672
|
key: "prepareCheckout",
|
|
657
673
|
value: function () {
|
|
@@ -3707,7 +3723,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3707
3723
|
isCurrentRequest = function isCurrentRequest() {
|
|
3708
3724
|
var _this20$store$order, _this20$store$order$g, _this20$store$order2, _this20$store$order2$;
|
|
3709
3725
|
var currentTempOrder = (_this20$store$order = _this20.store.order) === null || _this20$store$order === void 0 || (_this20$store$order$g = _this20$store$order.getTempOrder) === null || _this20$store$order$g === void 0 ? void 0 : _this20$store$order$g.call(_this20$store$order);
|
|
3710
|
-
|
|
3726
|
+
var current = Boolean(currentTempOrder && (requestEpoch === undefined || ((_this20$store$order2 = _this20.store.order) === null || _this20$store$order2 === void 0 || (_this20$store$order2$ = _this20$store$order2.getCustomerWalletPrepareConfigEpoch) === null || _this20$store$order2$ === void 0 ? void 0 : _this20$store$order2$.call(_this20$store$order2)) === requestEpoch) && _this20.resolveDiscountConfigCustomerId(currentTempOrder) === customerId && _this20.getDiscountConfigOrderIdentityKey(currentTempOrder) === requestOrderIdentityKey);
|
|
3727
|
+
// Cart edits can replace the object while member configuration is pending.
|
|
3728
|
+
// Keep the logical-order guard, but apply coupons to its latest rows.
|
|
3729
|
+
if (current && _this20.isMemberCartConsistencyEnabled()) tempOrder = currentTempOrder;
|
|
3730
|
+
return current;
|
|
3711
3731
|
};
|
|
3712
3732
|
getCurrentResult = function getCurrentResult() {
|
|
3713
3733
|
var _this20$store$order3, _this20$store$order3$, _discountModule$getDi2;
|
|
@@ -3959,7 +3979,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3959
3979
|
discountList: nextDiscountList
|
|
3960
3980
|
};
|
|
3961
3981
|
if (result.productList) {
|
|
3962
|
-
tempOrder
|
|
3982
|
+
applyDiscountProductLines(tempOrder, result.productList, result.discountList || nextDiscountList, this.isMemberCartConsistencyEnabled());
|
|
3963
3983
|
}
|
|
3964
3984
|
_iterator5 = _createForOfIteratorHelper(tempOrder.products || []);
|
|
3965
3985
|
_context36.prev = 93;
|
|
@@ -4160,7 +4180,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4160
4180
|
preserveEntitlementSelection: false
|
|
4161
4181
|
}) || result;
|
|
4162
4182
|
if (result.productList) {
|
|
4163
|
-
tempOrder
|
|
4183
|
+
applyDiscountProductLines(tempOrder, result.productList, result.discountList || nextDiscountList, this.isMemberCartConsistencyEnabled());
|
|
4164
4184
|
}
|
|
4165
4185
|
if (!result.discountList) {
|
|
4166
4186
|
_context37.next = 28;
|
|
@@ -4273,7 +4293,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4273
4293
|
key: "scanPromotionCode",
|
|
4274
4294
|
value: function () {
|
|
4275
4295
|
var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(code, customerId, options) {
|
|
4276
|
-
var raw,
|
|
4296
|
+
var raw, _tempOrder;
|
|
4277
4297
|
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
4278
4298
|
while (1) switch (_context39.prev = _context39.next) {
|
|
4279
4299
|
case 0:
|
|
@@ -4298,13 +4318,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4298
4318
|
});
|
|
4299
4319
|
case 9:
|
|
4300
4320
|
this.store.order.persistTempOrder();
|
|
4301
|
-
|
|
4321
|
+
_tempOrder = this.store.order.ensureTempOrder();
|
|
4302
4322
|
_context39.next = 13;
|
|
4303
4323
|
return this.effectsEmit('onDiscountApplied', {
|
|
4304
|
-
productList:
|
|
4324
|
+
productList: _tempOrder.products || [],
|
|
4305
4325
|
discountList: this.store.order.getDiscountList(),
|
|
4306
|
-
selectedDiscountList:
|
|
4307
|
-
tempOrder:
|
|
4326
|
+
selectedDiscountList: _tempOrder.discount_list || [],
|
|
4327
|
+
tempOrder: _tempOrder
|
|
4308
4328
|
});
|
|
4309
4329
|
case 13:
|
|
4310
4330
|
return _context39.abrupt("return", _objectSpread(_objectSpread({
|
|
@@ -4336,7 +4356,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4336
4356
|
key: "setDiscountSelected",
|
|
4337
4357
|
value: function () {
|
|
4338
4358
|
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
|
|
4339
|
-
var currentOrder, _store3, _store3$setDiscountLi, list, updated,
|
|
4359
|
+
var currentOrder, _store3, _store3$setDiscountLi, list, updated, _tempOrder2, orderStore, _discountModule, rulesModule, nextDiscountList, _orderStore$summary3, orderTotalAmount, result, beforeSelectedIds, promotionCardIds, _iterator6, _step6, d, selectedResourceIds, filterSelectedDiscountDetails, _iterator7, _step7, _product$metadata8, _tempOrder2$_extend, _product$metadata$sou2, _product$metadata9, _product$metadata10, _product$original_pri2, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
|
|
4340
4360
|
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
4341
4361
|
while (1) switch (_context40.prev = _context40.next) {
|
|
4342
4362
|
case 0:
|
|
@@ -4373,7 +4393,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4373
4393
|
}) : d;
|
|
4374
4394
|
});
|
|
4375
4395
|
this.hasManualDiscountSelection = true;
|
|
4376
|
-
|
|
4396
|
+
_tempOrder2 = this.store.order.ensureTempOrder();
|
|
4377
4397
|
orderStore = this.store.order.store || {};
|
|
4378
4398
|
_discountModule = orderStore.discount;
|
|
4379
4399
|
rulesModule = orderStore.rules;
|
|
@@ -4384,22 +4404,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4384
4404
|
if (rulesModule) {
|
|
4385
4405
|
orderTotalAmount = Number(((_orderStore$summary3 = orderStore.summary) === null || _orderStore$summary3 === void 0 ? void 0 : _orderStore$summary3.total_amount) || 0);
|
|
4386
4406
|
result = rulesModule.calcDiscount({
|
|
4387
|
-
productList:
|
|
4407
|
+
productList: _tempOrder2.products,
|
|
4388
4408
|
discountList: updated,
|
|
4389
4409
|
holders: [],
|
|
4390
4410
|
isFormSubject: function isFormSubject(product) {
|
|
4391
|
-
return resolveIsFormSubject(
|
|
4411
|
+
return resolveIsFormSubject(_tempOrder2, product);
|
|
4392
4412
|
},
|
|
4393
4413
|
orderTotalAmount: orderTotalAmount
|
|
4394
4414
|
}, {
|
|
4395
4415
|
discountId: params.discountId,
|
|
4396
4416
|
isSelected: params.isSelected
|
|
4397
4417
|
}) || {
|
|
4398
|
-
productList:
|
|
4418
|
+
productList: _tempOrder2.products,
|
|
4399
4419
|
discountList: updated
|
|
4400
4420
|
};
|
|
4401
4421
|
if (result !== null && result !== void 0 && result.productList) {
|
|
4402
|
-
|
|
4422
|
+
applyDiscountProductLines(_tempOrder2, result.productList, result.discountList || updated, this.isMemberCartConsistencyEnabled());
|
|
4403
4423
|
}
|
|
4404
4424
|
if (result !== null && result !== void 0 && result.discountList) {
|
|
4405
4425
|
nextDiscountList = result.discountList;
|
|
@@ -4450,7 +4470,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4450
4470
|
return rid != null && selectedResourceIds.has(rid);
|
|
4451
4471
|
});
|
|
4452
4472
|
};
|
|
4453
|
-
_iterator7 = _createForOfIteratorHelper(
|
|
4473
|
+
_iterator7 = _createForOfIteratorHelper(_tempOrder2.products);
|
|
4454
4474
|
_context40.prev = 27;
|
|
4455
4475
|
_iterator7.s();
|
|
4456
4476
|
case 29:
|
|
@@ -4460,7 +4480,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4460
4480
|
}
|
|
4461
4481
|
product = _step7.value;
|
|
4462
4482
|
productUid = (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.unique_identification_number;
|
|
4463
|
-
runtimeOrigin = productUid ? (
|
|
4483
|
+
runtimeOrigin = productUid ? (_tempOrder2$_extend = _tempOrder2._extend) === null || _tempOrder2$_extend === void 0 || (_tempOrder2$_extend = _tempOrder2$_extend.productsByUid) === null || _tempOrder2$_extend === void 0 || (_tempOrder2$_extend = _tempOrder2$_extend[productUid]) === null || _tempOrder2$_extend === void 0 ? void 0 : _tempOrder2$_extend.origin : undefined;
|
|
4464
4484
|
if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
|
|
4465
4485
|
_context40.next = 35;
|
|
4466
4486
|
break;
|
|
@@ -4515,11 +4535,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4515
4535
|
_iterator7.f();
|
|
4516
4536
|
return _context40.finish(51);
|
|
4517
4537
|
case 54:
|
|
4518
|
-
OrderModule.populateSavedAmounts(
|
|
4538
|
+
OrderModule.populateSavedAmounts(_tempOrder2.products, nextDiscountList);
|
|
4519
4539
|
_context40.next = 57;
|
|
4520
4540
|
return _discountModule === null || _discountModule === void 0 ? void 0 : _discountModule.setDiscountList(nextDiscountList);
|
|
4521
4541
|
case 57:
|
|
4522
|
-
|
|
4542
|
+
_tempOrder2.discount_list = (nextDiscountList || []).filter(function (d) {
|
|
4523
4543
|
return d.isSelected;
|
|
4524
4544
|
});
|
|
4525
4545
|
_context40.next = 60;
|
|
@@ -4529,10 +4549,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4529
4549
|
case 60:
|
|
4530
4550
|
this.store.order.persistTempOrder();
|
|
4531
4551
|
this.effectsEmit('onDiscountApplied', {
|
|
4532
|
-
productList:
|
|
4552
|
+
productList: _tempOrder2.products,
|
|
4533
4553
|
discountList: nextDiscountList,
|
|
4534
|
-
selectedDiscountList:
|
|
4535
|
-
tempOrder:
|
|
4554
|
+
selectedDiscountList: _tempOrder2.discount_list,
|
|
4555
|
+
tempOrder: _tempOrder2
|
|
4536
4556
|
});
|
|
4537
4557
|
_context40.next = 67;
|
|
4538
4558
|
break;
|
|
@@ -4555,7 +4575,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4555
4575
|
key: "applyDiscountCalculationResult",
|
|
4556
4576
|
value: function () {
|
|
4557
4577
|
var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(result) {
|
|
4558
|
-
var
|
|
4578
|
+
var _tempOrder3, orderStore, _discountModule2;
|
|
4559
4579
|
return _regeneratorRuntime().wrap(function _callee41$(_context41) {
|
|
4560
4580
|
while (1) switch (_context41.prev = _context41.next) {
|
|
4561
4581
|
case 0:
|
|
@@ -4572,21 +4592,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4572
4592
|
}
|
|
4573
4593
|
return _context41.abrupt("return");
|
|
4574
4594
|
case 5:
|
|
4575
|
-
|
|
4595
|
+
_tempOrder3 = this.store.order.ensureTempOrder();
|
|
4576
4596
|
orderStore = this.store.order.store || {};
|
|
4577
4597
|
_discountModule2 = orderStore.discount;
|
|
4578
4598
|
if (result.productList) {
|
|
4579
|
-
|
|
4599
|
+
applyDiscountProductLines(_tempOrder3, result.productList, result.discountList || this.getDiscountList(), this.isMemberCartConsistencyEnabled());
|
|
4580
4600
|
}
|
|
4581
4601
|
if (!result.discountList) {
|
|
4582
4602
|
_context41.next = 14;
|
|
4583
4603
|
break;
|
|
4584
4604
|
}
|
|
4585
|
-
OrderModule.populateSavedAmounts(
|
|
4605
|
+
OrderModule.populateSavedAmounts(_tempOrder3.products, result.discountList);
|
|
4586
4606
|
_context41.next = 13;
|
|
4587
4607
|
return _discountModule2 === null || _discountModule2 === void 0 ? void 0 : _discountModule2.setDiscountList(result.discountList);
|
|
4588
4608
|
case 13:
|
|
4589
|
-
|
|
4609
|
+
_tempOrder3.discount_list = result.discountList.filter(function (discount) {
|
|
4590
4610
|
return discount.isSelected;
|
|
4591
4611
|
});
|
|
4592
4612
|
case 14:
|
|
@@ -4598,10 +4618,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4598
4618
|
this.store.order.persistTempOrder();
|
|
4599
4619
|
_context41.next = 19;
|
|
4600
4620
|
return this.effectsEmit('onDiscountApplied', {
|
|
4601
|
-
productList:
|
|
4621
|
+
productList: _tempOrder3.products || [],
|
|
4602
4622
|
discountList: result.discountList || [],
|
|
4603
|
-
selectedDiscountList:
|
|
4604
|
-
tempOrder:
|
|
4623
|
+
selectedDiscountList: _tempOrder3.discount_list || [],
|
|
4624
|
+
tempOrder: _tempOrder3
|
|
4605
4625
|
});
|
|
4606
4626
|
case 19:
|
|
4607
4627
|
_context41.next = 24;
|
|
@@ -7481,6 +7501,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
7481
7501
|
return this.resolveProductBookingPriceGroups(paramsList, currentOrderCustomerId);
|
|
7482
7502
|
case 9:
|
|
7483
7503
|
authoritativeProducts = _context75.sent;
|
|
7504
|
+
if (!paramsList.some(function (params, index) {
|
|
7505
|
+
return params.requireAuthoritativePrice && !authoritativeProducts[index];
|
|
7506
|
+
})) {
|
|
7507
|
+
_context75.next = 12;
|
|
7508
|
+
break;
|
|
7509
|
+
}
|
|
7510
|
+
throw new Error('The current customer product price is unavailable. Please retry before paying.');
|
|
7511
|
+
case 12:
|
|
7484
7512
|
plans = paramsList.map(function (params, index) {
|
|
7485
7513
|
if (!isPos) return null;
|
|
7486
7514
|
var product = authoritativeProducts[index];
|
|
@@ -7510,20 +7538,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
7510
7538
|
return queryIndex;
|
|
7511
7539
|
})) || [];
|
|
7512
7540
|
});
|
|
7513
|
-
_context75.next =
|
|
7541
|
+
_context75.next = 17;
|
|
7514
7542
|
return this.resolveProductBookingPriceGroups(segmentQueries, currentOrderCustomerId, true);
|
|
7515
|
-
case
|
|
7543
|
+
case 17:
|
|
7516
7544
|
segmentProducts = _context75.sent;
|
|
7517
7545
|
if (!segmentProducts.some(function (product) {
|
|
7518
7546
|
return !product;
|
|
7519
7547
|
})) {
|
|
7520
|
-
_context75.next =
|
|
7548
|
+
_context75.next = 20;
|
|
7521
7549
|
break;
|
|
7522
7550
|
}
|
|
7523
7551
|
throw durationPricingUnavailable('An authoritative product is missing for a billing unit.');
|
|
7524
|
-
case
|
|
7552
|
+
case 20:
|
|
7525
7553
|
if (useCustomerUserPricing) {
|
|
7526
|
-
_context75.next =
|
|
7554
|
+
_context75.next = 25;
|
|
7527
7555
|
break;
|
|
7528
7556
|
}
|
|
7529
7557
|
quotationContexts = new Map();
|
|
@@ -7538,13 +7566,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
7538
7566
|
customer_id: (_params$customer_id3 = params.customer_id) !== null && _params$customer_id3 !== void 0 ? _params$customer_id3 : currentOrderCustomerId
|
|
7539
7567
|
});
|
|
7540
7568
|
});
|
|
7541
|
-
_context75.next =
|
|
7569
|
+
_context75.next = 25;
|
|
7542
7570
|
return Promise.all(Array.from(quotationContexts.values()).map(function (context) {
|
|
7543
7571
|
return _this25.loadQuotationForPriceQuery(_objectSpread({
|
|
7544
7572
|
quotation: quotation
|
|
7545
7573
|
}, context));
|
|
7546
7574
|
}));
|
|
7547
|
-
case
|
|
7575
|
+
case 25:
|
|
7548
7576
|
return _context75.abrupt("return", paramsList.map(function (params, index) {
|
|
7549
7577
|
var _params$customer_id4, _authoritativeProduct2, _params$duration;
|
|
7550
7578
|
var productInput = params.product || {};
|
|
@@ -7595,7 +7623,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
7595
7623
|
duration: undefined
|
|
7596
7624
|
}) : result;
|
|
7597
7625
|
}));
|
|
7598
|
-
case
|
|
7626
|
+
case 26:
|
|
7599
7627
|
case "end":
|
|
7600
7628
|
return _context75.stop();
|
|
7601
7629
|
}
|
|
@@ -305,6 +305,8 @@ export interface BaseSalesQuotationDurationConfig {
|
|
|
305
305
|
}
|
|
306
306
|
export interface BaseSalesCalculateProductBookingPriceParams {
|
|
307
307
|
product: Record<string, any>;
|
|
308
|
+
/** Fail closed when the current customer price cannot be resolved; no old-line fallback. */
|
|
309
|
+
requireAuthoritativePrice?: boolean;
|
|
308
310
|
booking?: {
|
|
309
311
|
start_date?: string;
|
|
310
312
|
start_time?: string;
|
|
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
342
342
|
date: string;
|
|
343
343
|
status: string;
|
|
344
344
|
week: string;
|
|
345
|
-
weekNum: 0 | 2 | 1 |
|
|
345
|
+
weekNum: 0 | 2 | 1 | 5 | 3 | 4 | 6;
|
|
346
346
|
}[]>;
|
|
347
347
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
348
348
|
private getScheduleDataByIds;
|