@pisell/pisellos 2.3.63 → 2.3.64
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 +0 -1
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/model/strategy/adapter/walletPass/evaluator.js +0 -1
- package/dist/model/strategy/adapter/walletPass/utils.js +0 -2
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +7 -3
- package/dist/modules/Customer/index.d.ts +4 -0
- package/dist/modules/Customer/index.js +91 -59
- package/dist/modules/Customer/types.d.ts +2 -0
- package/dist/modules/Order/index.js +4 -1
- package/dist/modules/Order/utils.js +36 -30
- package/dist/modules/Payment/walletpass.js +4 -5
- package/dist/server/index.js +1 -1
- package/dist/server/modules/order/index.d.ts +1 -0
- package/dist/server/modules/order/index.js +252 -94
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -3
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +2 -0
- package/dist/solution/BookingTicket/index.js +34 -10
- package/lib/core/index.js +0 -1
- package/lib/model/strategy/adapter/promotion/index.js +0 -51
- package/lib/model/strategy/adapter/walletPass/evaluator.js +0 -1
- package/lib/model/strategy/adapter/walletPass/utils.js +0 -1
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +3 -0
- package/lib/modules/Customer/index.d.ts +4 -0
- package/lib/modules/Customer/index.js +11 -0
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Order/index.js +3 -2
- package/lib/modules/Order/utils.js +3 -0
- package/lib/modules/Payment/walletpass.js +0 -1
- package/lib/server/index.js +1 -1
- package/lib/server/modules/order/index.d.ts +1 -0
- package/lib/server/modules/order/index.js +66 -2
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +2 -0
- package/lib/solution/BookingTicket/index.js +18 -2
- package/package.json +1 -1
|
@@ -41,6 +41,7 @@ import { getOrderPaymentIdentityKeys, isIdentifiedPendingOrderPayment, isPending
|
|
|
41
41
|
* SQLite 存储名称
|
|
42
42
|
*/
|
|
43
43
|
var INDEXDB_STORE_NAME = 'orders';
|
|
44
|
+
var ORDER_STORAGE_KEY_FIELD = '__order_storage_key';
|
|
44
45
|
var ORDER_LAST_FULL_FETCH_AT_STORAGE_KEY = 'server_order_last_full_fetch_at';
|
|
45
46
|
var ORDER_SYNC_THROTTLE_MS_STORAGE_KEY = 'order_sync_throttle_ms';
|
|
46
47
|
var DEFAULT_ORDER_SYNC_THROTTLE_MS = 2000;
|
|
@@ -64,7 +65,6 @@ var ORDER_COLLECTION_KIND_BY_FIELD = {
|
|
|
64
65
|
bookings: 'booking',
|
|
65
66
|
payments: 'payment'
|
|
66
67
|
};
|
|
67
|
-
|
|
68
68
|
/**
|
|
69
69
|
* Order 模块 - 基础框架
|
|
70
70
|
*/
|
|
@@ -2327,7 +2327,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2327
2327
|
value: (function () {
|
|
2328
2328
|
var _mergeOrdersToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(freshOrders, source) {
|
|
2329
2329
|
var _this16 = this;
|
|
2330
|
-
var storeOrderCountBefore, normalizedFreshOrders, incomingProductsHaveStableIdentity, _iterator14, _step14, order, id, rawProducts, _incomingProductsHave, allProductsHaveStableIdentity, orderIdKey, uniqueFreshOrders, uniqueFreshCount, patchedOrders, remoteProductMembershipChanges, forceWriteStorageKeys, mergeActions, existingProductsHaveStableIdentity, updatedList, identityKeyToIndex, index, identityKeys, _iterator15, _step15, key, _iterator16, _step16, fresh, freshIdentityKeys, matchIndex, storageKey, mergeKey, existingOrder, _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, _iterator17, _step17, _key2, _duplicateIndex, _iterator18, _step18, duplicateIndex, _index, _iterator19, _step19, _key, mergedStorageKey, insertIndex, insertCount, updateCount;
|
|
2330
|
+
var storeOrderCountBefore, normalizedFreshOrders, incomingProductsHaveStableIdentity, _iterator14, _step14, order, id, rawProducts, _incomingProductsHave, allProductsHaveStableIdentity, orderIdKey, uniqueFreshOrders, uniqueFreshCount, patchedOrders, remoteProductMembershipChanges, forceWriteStorageKeys, storageKeyMigrations, mergeActions, existingProductsHaveStableIdentity, updatedList, identityKeyToIndex, index, identityKeys, _iterator15, _step15, key, _iterator16, _step16, 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, _iterator17, _step17, _key2, _duplicateIndex, _iterator18, _step18, duplicateIndex, _index, _iterator19, _step19, _key, nextStorageKey, _ref5, _ref6, _mergedOrder$order_id, mergedStorageKey, insertIndex, insertCount, updateCount;
|
|
2331
2331
|
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
2332
2332
|
while (1) switch (_context19.prev = _context19.next) {
|
|
2333
2333
|
case 0:
|
|
@@ -2384,6 +2384,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2384
2384
|
patchedOrders = [];
|
|
2385
2385
|
remoteProductMembershipChanges = [];
|
|
2386
2386
|
forceWriteStorageKeys = new Set();
|
|
2387
|
+
storageKeyMigrations = [];
|
|
2387
2388
|
mergeActions = {};
|
|
2388
2389
|
existingProductsHaveStableIdentity = this.store.list.map(function (order) {
|
|
2389
2390
|
return _this16.doProductsHaveStableMembershipIdentity(order.products);
|
|
@@ -2410,11 +2411,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2410
2411
|
}
|
|
2411
2412
|
}
|
|
2412
2413
|
_iterator16 = _createForOfIteratorHelper(uniqueFreshOrders);
|
|
2413
|
-
_context19.prev =
|
|
2414
|
+
_context19.prev = 38;
|
|
2414
2415
|
_iterator16.s();
|
|
2415
|
-
case
|
|
2416
|
+
case 40:
|
|
2416
2417
|
if ((_step16 = _iterator16.n()).done) {
|
|
2417
|
-
_context19.next =
|
|
2418
|
+
_context19.next = 100;
|
|
2418
2419
|
break;
|
|
2419
2420
|
}
|
|
2420
2421
|
fresh = _step16.value;
|
|
@@ -2423,12 +2424,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2423
2424
|
storageKey = this.getOrderStorageKey(fresh);
|
|
2424
2425
|
mergeKey = storageKey || (fresh.order_id !== undefined && fresh.order_id !== null ? this.getIdKey(fresh.order_id) : '');
|
|
2425
2426
|
if (!(matchIndex >= 0)) {
|
|
2426
|
-
_context19.next =
|
|
2427
|
+
_context19.next = 92;
|
|
2427
2428
|
break;
|
|
2428
2429
|
}
|
|
2429
2430
|
existingOrder = updatedList[matchIndex];
|
|
2431
|
+
previousStorageKey = this.getPersistedOrderStorageKey(existingOrder);
|
|
2430
2432
|
if (!(this.isPendingSyncOrder(existingOrder) && this.isRemoteEchoMergeSource(source))) {
|
|
2431
|
-
_context19.next =
|
|
2433
|
+
_context19.next = 52;
|
|
2432
2434
|
break;
|
|
2433
2435
|
}
|
|
2434
2436
|
this.logInfo('mergeOrdersToStore-跳过 pending 订单远端覆盖', {
|
|
@@ -2441,10 +2443,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2441
2443
|
remote_need_sync: (_fresh$need_sync = fresh.need_sync) !== null && _fresh$need_sync !== void 0 ? _fresh$need_sync : null,
|
|
2442
2444
|
reason: 'protect_pending_sync_order_from_remote_echo'
|
|
2443
2445
|
});
|
|
2444
|
-
return _context19.abrupt("continue",
|
|
2445
|
-
case
|
|
2446
|
+
return _context19.abrupt("continue", 98);
|
|
2447
|
+
case 52:
|
|
2446
2448
|
if (!(this.isDraftOrder(existingOrder) && this.shouldProtectDraftOrderFromIncoming(source))) {
|
|
2447
|
-
_context19.next =
|
|
2449
|
+
_context19.next = 55;
|
|
2448
2450
|
break;
|
|
2449
2451
|
}
|
|
2450
2452
|
this.logInfo('mergeOrdersToStore-跳过 draft 订单远端覆盖', {
|
|
@@ -2455,8 +2457,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2455
2457
|
remote_is_draft_order: (_fresh$is_draft_order = fresh.is_draft_order) !== null && _fresh$is_draft_order !== void 0 ? _fresh$is_draft_order : null,
|
|
2456
2458
|
reason: 'protect_draft_order_from_remote_echo'
|
|
2457
2459
|
});
|
|
2458
|
-
return _context19.abrupt("continue",
|
|
2459
|
-
case
|
|
2460
|
+
return _context19.abrupt("continue", 98);
|
|
2461
|
+
case 55:
|
|
2460
2462
|
mergedOrder = this.mergeOrderRecords(existingOrder, fresh);
|
|
2461
2463
|
freshOrderId = fresh.order_id;
|
|
2462
2464
|
incomingProductsAreStable = freshOrderId !== undefined && freshOrderId !== null && incomingProductsHaveStableIdentity.get(this.getIdKey(freshOrderId)) !== false;
|
|
@@ -2468,37 +2470,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2468
2470
|
adjustedMatchIndex = matchIndex;
|
|
2469
2471
|
duplicateIndexes = new Set();
|
|
2470
2472
|
_iterator17 = _createForOfIteratorHelper(freshIdentityKeys);
|
|
2471
|
-
_context19.prev =
|
|
2473
|
+
_context19.prev = 64;
|
|
2472
2474
|
_iterator17.s();
|
|
2473
|
-
case
|
|
2475
|
+
case 66:
|
|
2474
2476
|
if ((_step17 = _iterator17.n()).done) {
|
|
2475
|
-
_context19.next =
|
|
2477
|
+
_context19.next = 74;
|
|
2476
2478
|
break;
|
|
2477
2479
|
}
|
|
2478
2480
|
_key2 = _step17.value;
|
|
2479
2481
|
_duplicateIndex = identityKeyToIndex.get(_key2);
|
|
2480
2482
|
if (!(_duplicateIndex === undefined || _duplicateIndex === matchIndex)) {
|
|
2481
|
-
_context19.next =
|
|
2483
|
+
_context19.next = 71;
|
|
2482
2484
|
break;
|
|
2483
2485
|
}
|
|
2484
|
-
return _context19.abrupt("continue",
|
|
2485
|
-
case
|
|
2486
|
+
return _context19.abrupt("continue", 72);
|
|
2487
|
+
case 71:
|
|
2486
2488
|
duplicateIndexes.add(_duplicateIndex);
|
|
2487
|
-
case 70:
|
|
2488
|
-
_context19.next = 64;
|
|
2489
|
-
break;
|
|
2490
2489
|
case 72:
|
|
2491
|
-
_context19.next =
|
|
2490
|
+
_context19.next = 66;
|
|
2492
2491
|
break;
|
|
2493
2492
|
case 74:
|
|
2494
|
-
_context19.
|
|
2495
|
-
|
|
2493
|
+
_context19.next = 79;
|
|
2494
|
+
break;
|
|
2495
|
+
case 76:
|
|
2496
|
+
_context19.prev = 76;
|
|
2497
|
+
_context19.t1 = _context19["catch"](64);
|
|
2496
2498
|
_iterator17.e(_context19.t1);
|
|
2497
|
-
case
|
|
2498
|
-
_context19.prev =
|
|
2499
|
+
case 79:
|
|
2500
|
+
_context19.prev = 79;
|
|
2499
2501
|
_iterator17.f();
|
|
2500
|
-
return _context19.finish(
|
|
2501
|
-
case
|
|
2502
|
+
return _context19.finish(79);
|
|
2503
|
+
case 82:
|
|
2502
2504
|
if (duplicateIndexes.size > 0) {
|
|
2503
2505
|
_iterator18 = _createForOfIteratorHelper(_toConsumableArray(duplicateIndexes).sort(function (left, right) {
|
|
2504
2506
|
return right - left;
|
|
@@ -2532,6 +2534,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2532
2534
|
}
|
|
2533
2535
|
}
|
|
2534
2536
|
}
|
|
2537
|
+
nextStorageKey = this.getOrderStorageKey(mergedOrder);
|
|
2538
|
+
if (previousStorageKey && nextStorageKey && previousStorageKey !== nextStorageKey) {
|
|
2539
|
+
storageKeyMigrations.push({
|
|
2540
|
+
orderId: (_ref5 = (_ref6 = (_mergedOrder$order_id = mergedOrder.order_id) !== null && _mergedOrder$order_id !== void 0 ? _mergedOrder$order_id : existingOrder.order_id) !== null && _ref6 !== void 0 ? _ref6 : fresh.order_id) !== null && _ref5 !== void 0 ? _ref5 : null,
|
|
2541
|
+
from: previousStorageKey,
|
|
2542
|
+
to: nextStorageKey
|
|
2543
|
+
});
|
|
2544
|
+
}
|
|
2535
2545
|
updatedList[adjustedMatchIndex] = mergedOrder;
|
|
2536
2546
|
existingProductsHaveStableIdentity[adjustedMatchIndex] = mergedProductsHaveStableIdentity;
|
|
2537
2547
|
if (membershipChange) {
|
|
@@ -2544,29 +2554,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2544
2554
|
this.registerOrderIdentityKeys(identityKeyToIndex, mergedOrder, adjustedMatchIndex);
|
|
2545
2555
|
patchedOrders.push(mergedOrder);
|
|
2546
2556
|
if (mergeKey) mergeActions[mergeKey] = 'update';
|
|
2547
|
-
return _context19.abrupt("continue",
|
|
2548
|
-
case
|
|
2557
|
+
return _context19.abrupt("continue", 98);
|
|
2558
|
+
case 92:
|
|
2549
2559
|
insertIndex = updatedList.length;
|
|
2550
2560
|
updatedList.push(fresh);
|
|
2551
2561
|
existingProductsHaveStableIdentity.push(fresh.order_id !== undefined && fresh.order_id !== null && incomingProductsHaveStableIdentity.get(this.getIdKey(fresh.order_id)) !== false);
|
|
2552
2562
|
this.registerOrderIdentityKeys(identityKeyToIndex, fresh, insertIndex);
|
|
2553
2563
|
patchedOrders.push(fresh);
|
|
2554
2564
|
if (mergeKey) mergeActions[mergeKey] = 'insert';
|
|
2555
|
-
case
|
|
2556
|
-
_context19.next =
|
|
2565
|
+
case 98:
|
|
2566
|
+
_context19.next = 40;
|
|
2557
2567
|
break;
|
|
2558
|
-
case
|
|
2559
|
-
_context19.next =
|
|
2568
|
+
case 100:
|
|
2569
|
+
_context19.next = 105;
|
|
2560
2570
|
break;
|
|
2561
|
-
case
|
|
2562
|
-
_context19.prev =
|
|
2563
|
-
_context19.t2 = _context19["catch"](
|
|
2571
|
+
case 102:
|
|
2572
|
+
_context19.prev = 102;
|
|
2573
|
+
_context19.t2 = _context19["catch"](38);
|
|
2564
2574
|
_iterator16.e(_context19.t2);
|
|
2565
|
-
case
|
|
2566
|
-
_context19.prev =
|
|
2575
|
+
case 105:
|
|
2576
|
+
_context19.prev = 105;
|
|
2567
2577
|
_iterator16.f();
|
|
2568
|
-
return _context19.finish(
|
|
2569
|
-
case
|
|
2578
|
+
return _context19.finish(105);
|
|
2579
|
+
case 108:
|
|
2570
2580
|
insertCount = Object.values(mergeActions).filter(function (v) {
|
|
2571
2581
|
return v === 'insert';
|
|
2572
2582
|
}).length;
|
|
@@ -2582,25 +2592,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2582
2592
|
// 仅在自检开关开启时做一次兜底校验。
|
|
2583
2593
|
this.store.list = this.runOrderStoreSelfCheck(updatedList, "".concat(source, ".store"));
|
|
2584
2594
|
this.syncOrdersMap();
|
|
2585
|
-
_context19.next =
|
|
2586
|
-
return this.patchOrdersInSQLite(patchedOrders, source, mergeActions, {
|
|
2587
|
-
|
|
2595
|
+
_context19.next = 115;
|
|
2596
|
+
return this.patchOrdersInSQLite(patchedOrders, source, mergeActions, {
|
|
2597
|
+
storageKeyMigrations: storageKeyMigrations
|
|
2598
|
+
}, forceWriteStorageKeys);
|
|
2599
|
+
case 115:
|
|
2588
2600
|
this.logInfo('mergeOrdersToStore-结束', {
|
|
2589
2601
|
uniqueFreshCount: uniqueFreshCount,
|
|
2590
2602
|
storeOrderCountAfter: this.store.list.length,
|
|
2591
2603
|
insertCount: insertCount,
|
|
2592
2604
|
updateCount: updateCount
|
|
2593
2605
|
});
|
|
2594
|
-
_context19.next =
|
|
2606
|
+
_context19.next = 118;
|
|
2595
2607
|
return this.emitRemoteProductMembershipChanges(remoteProductMembershipChanges);
|
|
2596
|
-
case
|
|
2597
|
-
_context19.next =
|
|
2608
|
+
case 118:
|
|
2609
|
+
_context19.next = 120;
|
|
2598
2610
|
return this.emitOrdersChanged(patchedOrders, source);
|
|
2599
|
-
case
|
|
2611
|
+
case 120:
|
|
2600
2612
|
case "end":
|
|
2601
2613
|
return _context19.stop();
|
|
2602
2614
|
}
|
|
2603
|
-
}, _callee19, this, [[6, 20, 23, 26], [
|
|
2615
|
+
}, _callee19, this, [[6, 20, 23, 26], [38, 102, 105, 108], [64, 76, 79, 82]]);
|
|
2604
2616
|
}));
|
|
2605
2617
|
function mergeOrdersToStore(_x13, _x14) {
|
|
2606
2618
|
return _mergeOrdersToStore.apply(this, arguments);
|
|
@@ -2683,7 +2695,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2683
2695
|
key: "getRemoteProductMembershipChange",
|
|
2684
2696
|
value: function getRemoteProductMembershipChange(existingOrder, mergedOrder, source) {
|
|
2685
2697
|
var _this17 = this,
|
|
2686
|
-
_mergedOrder$
|
|
2698
|
+
_mergedOrder$order_id2;
|
|
2687
2699
|
if (!this.isRemoteProductMembershipChangeSource(source)) return null;
|
|
2688
2700
|
var previousProducts = Array.isArray(existingOrder.products) ? existingOrder.products : [];
|
|
2689
2701
|
var currentProducts = Array.isArray(mergedOrder.products) ? mergedOrder.products : [];
|
|
@@ -2720,7 +2732,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2720
2732
|
if (addedProductKeys.length === 0 && removedProductKeys.length === 0) {
|
|
2721
2733
|
return null;
|
|
2722
2734
|
}
|
|
2723
|
-
var orderId = (_mergedOrder$
|
|
2735
|
+
var orderId = (_mergedOrder$order_id2 = mergedOrder.order_id) !== null && _mergedOrder$order_id2 !== void 0 ? _mergedOrder$order_id2 : existingOrder.order_id;
|
|
2724
2736
|
if (orderId === undefined || orderId === null) return null;
|
|
2725
2737
|
return {
|
|
2726
2738
|
order_id: orderId,
|
|
@@ -2859,6 +2871,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2859
2871
|
}
|
|
2860
2872
|
return '';
|
|
2861
2873
|
}
|
|
2874
|
+
}, {
|
|
2875
|
+
key: "getPersistedOrderStorageKey",
|
|
2876
|
+
value: function getPersistedOrderStorageKey(order) {
|
|
2877
|
+
var persistedStorageKey = order === null || order === void 0 ? void 0 : order[ORDER_STORAGE_KEY_FIELD];
|
|
2878
|
+
if (persistedStorageKey !== undefined && persistedStorageKey !== null && persistedStorageKey !== '') {
|
|
2879
|
+
return String(persistedStorageKey);
|
|
2880
|
+
}
|
|
2881
|
+
return this.getOrderStorageKey(order);
|
|
2882
|
+
}
|
|
2862
2883
|
}, {
|
|
2863
2884
|
key: "getOrderIdentityMatchKeys",
|
|
2864
2885
|
value: function getOrderIdentityMatchKeys(order) {
|
|
@@ -3060,10 +3081,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3060
3081
|
if (_field2 === 'payments') {
|
|
3061
3082
|
var preservedPending = this.getUnmatchedIdentifiedPendingPayments(existingRecord[_field2], incomingRecord[_field2]);
|
|
3062
3083
|
if (preservedPending.length > 0) {
|
|
3063
|
-
var
|
|
3084
|
+
var _ref7, _existing$order_id, _ref8, _existingRecord$exter;
|
|
3064
3085
|
this.logInfo('mergeOrderRecords-保留本地 pending 支付项', {
|
|
3065
|
-
order_id: (
|
|
3066
|
-
external_sale_number: (
|
|
3086
|
+
order_id: (_ref7 = (_existing$order_id = existing.order_id) !== null && _existing$order_id !== void 0 ? _existing$order_id : incoming.order_id) !== null && _ref7 !== void 0 ? _ref7 : null,
|
|
3087
|
+
external_sale_number: (_ref8 = (_existingRecord$exter = existingRecord.external_sale_number) !== null && _existingRecord$exter !== void 0 ? _existingRecord$exter : incomingRecord.external_sale_number) !== null && _ref8 !== void 0 ? _ref8 : null,
|
|
3067
3088
|
preserved_pending_count: preservedPending.length,
|
|
3068
3089
|
preserved_payment_identities: preservedPending.map(function (payment) {
|
|
3069
3090
|
return getOrderPaymentIdentityKeys(payment);
|
|
@@ -3116,14 +3137,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3116
3137
|
} finally {
|
|
3117
3138
|
_iterator28.f();
|
|
3118
3139
|
}
|
|
3119
|
-
return _toConsumableArray(groups.entries()).filter(function (
|
|
3120
|
-
var _ref8 = _slicedToArray(_ref7, 2),
|
|
3121
|
-
group = _ref8[1];
|
|
3122
|
-
return group.length > 1;
|
|
3123
|
-
}).slice(0, 20).map(function (_ref9) {
|
|
3140
|
+
return _toConsumableArray(groups.entries()).filter(function (_ref9) {
|
|
3124
3141
|
var _ref10 = _slicedToArray(_ref9, 2),
|
|
3125
|
-
key = _ref10[0],
|
|
3126
3142
|
group = _ref10[1];
|
|
3143
|
+
return group.length > 1;
|
|
3144
|
+
}).slice(0, 20).map(function (_ref11) {
|
|
3145
|
+
var _ref12 = _slicedToArray(_ref11, 2),
|
|
3146
|
+
key = _ref12[0],
|
|
3147
|
+
group = _ref12[1];
|
|
3127
3148
|
return {
|
|
3128
3149
|
key: key,
|
|
3129
3150
|
count: group.length,
|
|
@@ -3430,11 +3451,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3430
3451
|
var mergeActions,
|
|
3431
3452
|
options,
|
|
3432
3453
|
forceWriteStorageKeys,
|
|
3454
|
+
migrationTargetStorageKeys,
|
|
3433
3455
|
ordersSnapshot,
|
|
3434
3456
|
_this$filterRedundant2,
|
|
3435
3457
|
toWrite,
|
|
3436
3458
|
skipped,
|
|
3437
3459
|
compactedToWrite,
|
|
3460
|
+
writtenStorageKeys,
|
|
3461
|
+
storageKeyMigrations,
|
|
3462
|
+
_iterator32,
|
|
3463
|
+
_step32,
|
|
3464
|
+
migration,
|
|
3438
3465
|
_args23 = arguments;
|
|
3439
3466
|
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
3440
3467
|
while (1) switch (_context23.prev = _context23.next) {
|
|
@@ -3460,35 +3487,83 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3460
3487
|
case 8:
|
|
3461
3488
|
return _context23.abrupt("return");
|
|
3462
3489
|
case 9:
|
|
3490
|
+
migrationTargetStorageKeys = new Set((options.storageKeyMigrations || []).map(function (migration) {
|
|
3491
|
+
return migration.to;
|
|
3492
|
+
}));
|
|
3463
3493
|
ordersSnapshot = cloneDeep(orders).map(function (order) {
|
|
3464
3494
|
return _this22.normalizeOrderCollectionsForIngress(order, "".concat(source, ".sqliteIngress"));
|
|
3495
|
+
}).map(function (order) {
|
|
3496
|
+
var storageKey = _this22.getOrderStorageKey(order);
|
|
3497
|
+
if (!storageKey || !migrationTargetStorageKeys.has(storageKey)) return order;
|
|
3498
|
+
return _objectSpread(_objectSpread({}, order), {}, _defineProperty({}, ORDER_STORAGE_KEY_FIELD, storageKey));
|
|
3465
3499
|
}).filter(function (order) {
|
|
3466
3500
|
return _this22.getOrderStorageKey(order);
|
|
3467
3501
|
});
|
|
3468
3502
|
if (!(ordersSnapshot.length === 0)) {
|
|
3469
|
-
_context23.next =
|
|
3503
|
+
_context23.next = 13;
|
|
3470
3504
|
break;
|
|
3471
3505
|
}
|
|
3472
3506
|
return _context23.abrupt("return");
|
|
3473
|
-
case
|
|
3507
|
+
case 13:
|
|
3474
3508
|
_this$filterRedundant2 = this.filterRedundantPatchOrders(source, ordersSnapshot, mergeActions, forceWriteStorageKeys), toWrite = _this$filterRedundant2.toWrite, skipped = _this$filterRedundant2.skipped;
|
|
3475
3509
|
if (!(toWrite.length === 0)) {
|
|
3476
|
-
_context23.next =
|
|
3510
|
+
_context23.next = 16;
|
|
3477
3511
|
break;
|
|
3478
3512
|
}
|
|
3479
3513
|
return _context23.abrupt("return");
|
|
3480
|
-
case
|
|
3514
|
+
case 16:
|
|
3481
3515
|
compactedToWrite = this.compactOrderListByIdentity(toWrite, "".concat(source, ".sqlitePatch")).list;
|
|
3482
3516
|
if (!(compactedToWrite.length === 0)) {
|
|
3483
|
-
_context23.next =
|
|
3517
|
+
_context23.next = 19;
|
|
3484
3518
|
break;
|
|
3485
3519
|
}
|
|
3486
3520
|
return _context23.abrupt("return");
|
|
3487
|
-
case
|
|
3488
|
-
|
|
3489
|
-
|
|
3521
|
+
case 19:
|
|
3522
|
+
writtenStorageKeys = new Set(compactedToWrite.map(function (order) {
|
|
3523
|
+
return _this22.getOrderStorageKey(order);
|
|
3524
|
+
}).filter(Boolean));
|
|
3525
|
+
storageKeyMigrations = new Map();
|
|
3526
|
+
_iterator32 = _createForOfIteratorHelper(options.storageKeyMigrations || []);
|
|
3527
|
+
_context23.prev = 22;
|
|
3528
|
+
_iterator32.s();
|
|
3529
|
+
case 24:
|
|
3530
|
+
if ((_step32 = _iterator32.n()).done) {
|
|
3531
|
+
_context23.next = 33;
|
|
3532
|
+
break;
|
|
3533
|
+
}
|
|
3534
|
+
migration = _step32.value;
|
|
3535
|
+
if (writtenStorageKeys.has(migration.to)) {
|
|
3536
|
+
_context23.next = 28;
|
|
3537
|
+
break;
|
|
3538
|
+
}
|
|
3539
|
+
return _context23.abrupt("continue", 31);
|
|
3540
|
+
case 28:
|
|
3541
|
+
if (!writtenStorageKeys.has(migration.from)) {
|
|
3542
|
+
_context23.next = 30;
|
|
3543
|
+
break;
|
|
3544
|
+
}
|
|
3545
|
+
return _context23.abrupt("continue", 31);
|
|
3546
|
+
case 30:
|
|
3547
|
+
storageKeyMigrations.set(migration.from, migration);
|
|
3548
|
+
case 31:
|
|
3549
|
+
_context23.next = 24;
|
|
3550
|
+
break;
|
|
3551
|
+
case 33:
|
|
3552
|
+
_context23.next = 38;
|
|
3553
|
+
break;
|
|
3554
|
+
case 35:
|
|
3555
|
+
_context23.prev = 35;
|
|
3556
|
+
_context23.t0 = _context23["catch"](22);
|
|
3557
|
+
_iterator32.e(_context23.t0);
|
|
3558
|
+
case 38:
|
|
3559
|
+
_context23.prev = 38;
|
|
3560
|
+
_iterator32.f();
|
|
3561
|
+
return _context23.finish(38);
|
|
3562
|
+
case 41:
|
|
3563
|
+
_context23.prev = 41;
|
|
3564
|
+
_context23.next = 44;
|
|
3490
3565
|
return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
|
|
3491
|
-
var writeMethod,
|
|
3566
|
+
var writeMethod, _iterator33, _step33, order, _iterator34, _step34, migration, _iterator35, _step35, _orderRecord$ORDER_ST, _order, orderRecord;
|
|
3492
3567
|
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
3493
3568
|
while (1) switch (_context22.prev = _context22.next) {
|
|
3494
3569
|
case 0:
|
|
@@ -3525,15 +3600,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3525
3600
|
break;
|
|
3526
3601
|
}
|
|
3527
3602
|
writeMethod = 'update';
|
|
3528
|
-
|
|
3603
|
+
_iterator33 = _createForOfIteratorHelper(compactedToWrite);
|
|
3529
3604
|
_context22.prev = 17;
|
|
3530
|
-
|
|
3605
|
+
_iterator33.s();
|
|
3531
3606
|
case 19:
|
|
3532
|
-
if ((
|
|
3607
|
+
if ((_step33 = _iterator33.n()).done) {
|
|
3533
3608
|
_context22.next = 25;
|
|
3534
3609
|
break;
|
|
3535
3610
|
}
|
|
3536
|
-
order =
|
|
3611
|
+
order = _step33.value;
|
|
3537
3612
|
_context22.next = 23;
|
|
3538
3613
|
return _this22.dbManager.update(INDEXDB_STORE_NAME, order);
|
|
3539
3614
|
case 23:
|
|
@@ -3545,10 +3620,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3545
3620
|
case 27:
|
|
3546
3621
|
_context22.prev = 27;
|
|
3547
3622
|
_context22.t0 = _context22["catch"](17);
|
|
3548
|
-
|
|
3623
|
+
_iterator33.e(_context22.t0);
|
|
3549
3624
|
case 30:
|
|
3550
3625
|
_context22.prev = 30;
|
|
3551
|
-
|
|
3626
|
+
_iterator33.f();
|
|
3552
3627
|
return _context22.finish(30);
|
|
3553
3628
|
case 33:
|
|
3554
3629
|
_context22.next = 37;
|
|
@@ -3561,38 +3636,121 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3561
3636
|
throw new Error('订单 SQLite 数据库不支持写入');
|
|
3562
3637
|
case 37:
|
|
3563
3638
|
_this22.recordRecentSqliteWrite(source, compactedToWrite);
|
|
3639
|
+
if (!(writeMethod !== 'none')) {
|
|
3640
|
+
_context22.next = 84;
|
|
3641
|
+
break;
|
|
3642
|
+
}
|
|
3643
|
+
_iterator34 = _createForOfIteratorHelper(storageKeyMigrations.values());
|
|
3644
|
+
_context22.prev = 40;
|
|
3645
|
+
_iterator34.s();
|
|
3646
|
+
case 42:
|
|
3647
|
+
if ((_step34 = _iterator34.n()).done) {
|
|
3648
|
+
_context22.next = 76;
|
|
3649
|
+
break;
|
|
3650
|
+
}
|
|
3651
|
+
migration = _step34.value;
|
|
3652
|
+
_context22.prev = 44;
|
|
3653
|
+
_context22.next = 47;
|
|
3654
|
+
return _this22.dbManager.delete(INDEXDB_STORE_NAME, migration.from);
|
|
3655
|
+
case 47:
|
|
3656
|
+
_this22.recentSqliteWriteByStorageKey.delete(migration.from);
|
|
3657
|
+
_iterator35 = _createForOfIteratorHelper(orders);
|
|
3658
|
+
_context22.prev = 49;
|
|
3659
|
+
_iterator35.s();
|
|
3660
|
+
case 51:
|
|
3661
|
+
if ((_step35 = _iterator35.n()).done) {
|
|
3662
|
+
_context22.next = 61;
|
|
3663
|
+
break;
|
|
3664
|
+
}
|
|
3665
|
+
_order = _step35.value;
|
|
3666
|
+
if (!(_this22.getOrderStorageKey(_order) !== migration.to)) {
|
|
3667
|
+
_context22.next = 55;
|
|
3668
|
+
break;
|
|
3669
|
+
}
|
|
3670
|
+
return _context22.abrupt("continue", 59);
|
|
3671
|
+
case 55:
|
|
3672
|
+
orderRecord = _order;
|
|
3673
|
+
if (!(String((_orderRecord$ORDER_ST = orderRecord[ORDER_STORAGE_KEY_FIELD]) !== null && _orderRecord$ORDER_ST !== void 0 ? _orderRecord$ORDER_ST : '') !== migration.from)) {
|
|
3674
|
+
_context22.next = 58;
|
|
3675
|
+
break;
|
|
3676
|
+
}
|
|
3677
|
+
return _context22.abrupt("continue", 59);
|
|
3678
|
+
case 58:
|
|
3679
|
+
orderRecord[ORDER_STORAGE_KEY_FIELD] = migration.to;
|
|
3680
|
+
case 59:
|
|
3681
|
+
_context22.next = 51;
|
|
3682
|
+
break;
|
|
3683
|
+
case 61:
|
|
3684
|
+
_context22.next = 66;
|
|
3685
|
+
break;
|
|
3686
|
+
case 63:
|
|
3687
|
+
_context22.prev = 63;
|
|
3688
|
+
_context22.t1 = _context22["catch"](49);
|
|
3689
|
+
_iterator35.e(_context22.t1);
|
|
3690
|
+
case 66:
|
|
3691
|
+
_context22.prev = 66;
|
|
3692
|
+
_iterator35.f();
|
|
3693
|
+
return _context22.finish(66);
|
|
3694
|
+
case 69:
|
|
3695
|
+
_context22.next = 74;
|
|
3696
|
+
break;
|
|
3697
|
+
case 71:
|
|
3698
|
+
_context22.prev = 71;
|
|
3699
|
+
_context22.t2 = _context22["catch"](44);
|
|
3700
|
+
_this22.logError('删除订单旧 SQLite storage key 失败', {
|
|
3701
|
+
source: source,
|
|
3702
|
+
order_id: migration.orderId,
|
|
3703
|
+
oldStorageKey: migration.from,
|
|
3704
|
+
newStorageKey: migration.to,
|
|
3705
|
+
error: _context22.t2 instanceof Error ? _context22.t2.message : String(_context22.t2)
|
|
3706
|
+
});
|
|
3707
|
+
case 74:
|
|
3708
|
+
_context22.next = 42;
|
|
3709
|
+
break;
|
|
3710
|
+
case 76:
|
|
3711
|
+
_context22.next = 81;
|
|
3712
|
+
break;
|
|
3713
|
+
case 78:
|
|
3714
|
+
_context22.prev = 78;
|
|
3715
|
+
_context22.t3 = _context22["catch"](40);
|
|
3716
|
+
_iterator34.e(_context22.t3);
|
|
3717
|
+
case 81:
|
|
3718
|
+
_context22.prev = 81;
|
|
3719
|
+
_iterator34.f();
|
|
3720
|
+
return _context22.finish(81);
|
|
3721
|
+
case 84:
|
|
3564
3722
|
_this22.logInfo('patchOrdersInSQLite-完成', {
|
|
3565
3723
|
source: source,
|
|
3566
3724
|
count: compactedToWrite.length,
|
|
3567
3725
|
writeMethod: writeMethod,
|
|
3568
3726
|
dedupedCount: skipped.length
|
|
3569
3727
|
});
|
|
3570
|
-
case
|
|
3728
|
+
case 85:
|
|
3571
3729
|
case "end":
|
|
3572
3730
|
return _context22.stop();
|
|
3573
3731
|
}
|
|
3574
|
-
}, _callee22, null, [[17, 27, 30, 33]]);
|
|
3732
|
+
}, _callee22, null, [[17, 27, 30, 33], [40, 78, 81, 84], [44, 71], [49, 63, 66, 69]]);
|
|
3575
3733
|
})));
|
|
3576
|
-
case
|
|
3577
|
-
_context23.next =
|
|
3734
|
+
case 44:
|
|
3735
|
+
_context23.next = 51;
|
|
3578
3736
|
break;
|
|
3579
|
-
case
|
|
3580
|
-
_context23.prev =
|
|
3581
|
-
_context23.
|
|
3737
|
+
case 46:
|
|
3738
|
+
_context23.prev = 46;
|
|
3739
|
+
_context23.t1 = _context23["catch"](41);
|
|
3582
3740
|
this.logError('增量保存订单到 SQLite 失败', {
|
|
3583
|
-
error: _context23.
|
|
3741
|
+
error: _context23.t1 instanceof Error ? _context23.t1.message : String(_context23.t1),
|
|
3584
3742
|
orderCount: ordersSnapshot.length
|
|
3585
3743
|
});
|
|
3586
3744
|
if (!options.throwOnError) {
|
|
3587
|
-
_context23.next =
|
|
3745
|
+
_context23.next = 51;
|
|
3588
3746
|
break;
|
|
3589
3747
|
}
|
|
3590
|
-
throw _context23.
|
|
3591
|
-
case
|
|
3748
|
+
throw _context23.t1;
|
|
3749
|
+
case 51:
|
|
3592
3750
|
case "end":
|
|
3593
3751
|
return _context23.stop();
|
|
3594
3752
|
}
|
|
3595
|
-
}, _callee23, this, [[
|
|
3753
|
+
}, _callee23, this, [[22, 35, 38, 41], [41, 46]]);
|
|
3596
3754
|
}));
|
|
3597
3755
|
function patchOrdersInSQLite(_x16, _x17) {
|
|
3598
3756
|
return _patchOrdersInSQLite.apply(this, arguments);
|
|
@@ -3773,7 +3931,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3773
3931
|
_context27.prev = 5;
|
|
3774
3932
|
_context27.next = 8;
|
|
3775
3933
|
return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
|
|
3776
|
-
var existingOrders, protectedLocalOrders,
|
|
3934
|
+
var existingOrders, protectedLocalOrders, _iterator36, _step36, rawCurrentOrder, currentOrder, protectedIndex, currentNeedsProtection, orderListSnapshot;
|
|
3777
3935
|
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
3778
3936
|
while (1) switch (_context26.prev = _context26.next) {
|
|
3779
3937
|
case 0:
|
|
@@ -3796,15 +3954,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3796
3954
|
}).filter(function (order) {
|
|
3797
3955
|
return _this24.shouldProtectLocalOrderFromRemoteSnapshot(order);
|
|
3798
3956
|
});
|
|
3799
|
-
|
|
3957
|
+
_iterator36 = _createForOfIteratorHelper(existingOrders || []);
|
|
3800
3958
|
_context26.prev = 10;
|
|
3801
|
-
|
|
3959
|
+
_iterator36.s();
|
|
3802
3960
|
case 12:
|
|
3803
|
-
if ((
|
|
3961
|
+
if ((_step36 = _iterator36.n()).done) {
|
|
3804
3962
|
_context26.next = 23;
|
|
3805
3963
|
break;
|
|
3806
3964
|
}
|
|
3807
|
-
rawCurrentOrder =
|
|
3965
|
+
rawCurrentOrder = _step36.value;
|
|
3808
3966
|
currentOrder = _this24.normalizeOrderCollectionsForIngress(rawCurrentOrder, "".concat(source, ".currentSQLite"));
|
|
3809
3967
|
protectedIndex = _this24.findOrderIndexByIdentity(protectedLocalOrders, currentOrder);
|
|
3810
3968
|
currentNeedsProtection = _this24.shouldProtectLocalOrderFromRemoteSnapshot(currentOrder);
|
|
@@ -3829,10 +3987,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3829
3987
|
case 25:
|
|
3830
3988
|
_context26.prev = 25;
|
|
3831
3989
|
_context26.t1 = _context26["catch"](10);
|
|
3832
|
-
|
|
3990
|
+
_iterator36.e(_context26.t1);
|
|
3833
3991
|
case 28:
|
|
3834
3992
|
_context26.prev = 28;
|
|
3835
|
-
|
|
3993
|
+
_iterator36.f();
|
|
3836
3994
|
return _context26.finish(28);
|
|
3837
3995
|
case 31:
|
|
3838
3996
|
orderListSnapshot = _this24.mergeRemoteSnapshotWithPendingOrders(remoteSnapshot, protectedLocalOrders);
|
|
@@ -195,7 +195,7 @@ export function transformBaseProductToOrderProduct(params) {
|
|
|
195
195
|
var productTitle = _objectSpread(_objectSpread({}, (sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.title_i18n) || {}), {}, {
|
|
196
196
|
original: (sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.original_title) || (sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.title) || ''
|
|
197
197
|
});
|
|
198
|
-
return {
|
|
198
|
+
return _objectSpread(_objectSpread({
|
|
199
199
|
product_id: productId,
|
|
200
200
|
product_variant_id: productVariantId,
|
|
201
201
|
unique_identification_number: uniqueIdentificationNumber ? String(uniqueIdentificationNumber) : undefined,
|
|
@@ -204,7 +204,10 @@ export function transformBaseProductToOrderProduct(params) {
|
|
|
204
204
|
option: productOptionItem
|
|
205
205
|
}),
|
|
206
206
|
product_bundle: productBundle,
|
|
207
|
-
discount_list: manualDiscountList
|
|
207
|
+
discount_list: manualDiscountList
|
|
208
|
+
}, payload.bundle_edit !== undefined ? {
|
|
209
|
+
bundle_edit: payload.bundle_edit
|
|
210
|
+
} : {}), {}, {
|
|
208
211
|
// 折后行价由 normalizeOrderProduct 按 main + bundle 合成;手动改价时 bundle 已为分摊后单价
|
|
209
212
|
selling_price: lineCompositeTotal,
|
|
210
213
|
original_price: lineOriginalPrice,
|
|
@@ -217,5 +220,5 @@ export function transformBaseProductToOrderProduct(params) {
|
|
|
217
220
|
_origin: _objectSpread(_objectSpread({}, sourceProduct || {}), {}, {
|
|
218
221
|
callbackData: payload
|
|
219
222
|
})
|
|
220
|
-
};
|
|
223
|
+
});
|
|
221
224
|
}
|
|
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
326
326
|
date: string;
|
|
327
327
|
status: string;
|
|
328
328
|
week: string;
|
|
329
|
-
weekNum: 0 |
|
|
329
|
+
weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
|
|
330
330
|
}[]>;
|
|
331
331
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
332
332
|
private getScheduleDataByIds;
|