@pisell/pisellos 2.3.21 → 2.3.23
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/Order/index.d.ts +2 -1
- package/dist/modules/Order/index.js +27 -12
- package/dist/modules/Order/utils.d.ts +2 -2
- package/dist/modules/Order/utils.js +41 -49
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +40 -6
- package/dist/server/modules/order/types.d.ts +2 -0
- package/dist/solution/BaseSales/index.d.ts +12 -0
- package/dist/solution/BaseSales/index.js +384 -320
- package/dist/solution/BaseSales/types.d.ts +4 -1
- package/dist/solution/BaseSales/types.js +1 -1
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +12 -1
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingTicket/index.js +42 -24
- package/lib/modules/Order/index.d.ts +2 -1
- package/lib/modules/Order/index.js +15 -3
- package/lib/modules/Order/utils.d.ts +2 -2
- package/lib/modules/Order/utils.js +7 -5
- package/lib/server/index.d.ts +1 -0
- package/lib/server/index.js +41 -3
- package/lib/server/modules/order/types.d.ts +2 -0
- package/lib/solution/BaseSales/index.d.ts +12 -0
- package/lib/solution/BaseSales/index.js +31 -2
- package/lib/solution/BaseSales/types.d.ts +4 -1
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +7 -1
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingTicket/index.js +15 -7
- package/package.json +1 -1
|
@@ -276,6 +276,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
276
276
|
updateTempOrderContactsInfo(contactsInfo: Record<string, any> | null): Record<string, any> | null;
|
|
277
277
|
private buildTempOrderCustomer;
|
|
278
278
|
private isCustomerBoundDiscount;
|
|
279
|
+
private shouldKeepCustomerBoundDiscountAfterCustomerChange;
|
|
279
280
|
private productHasCustomerBoundDiscount;
|
|
280
281
|
private shouldSkipDiscountCalculation;
|
|
281
282
|
private clearCustomerBoundDiscounts;
|
|
@@ -463,7 +464,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
463
464
|
generateIdempotencyToken(): string;
|
|
464
465
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
465
466
|
createOrder(params: CommitOrderParams['query']): {
|
|
466
|
-
type: "
|
|
467
|
+
type: "virtual" | "appointment_booking";
|
|
467
468
|
platform: string;
|
|
468
469
|
sales_channel: string;
|
|
469
470
|
order_sales_channel: string;
|
|
@@ -492,7 +492,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
492
492
|
value: function () {
|
|
493
493
|
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
494
494
|
var _this$store$tempOrder, _this$store$discount, _this$store$tempOrder2;
|
|
495
|
-
var orderId, discountList, _this$store$discount2, _this$store$discount3, _this$store$discount4, currentEditDiscounts, runtimeDiscountIds, runtimeDiscounts, mergedDiscountList;
|
|
495
|
+
var orderId, discountList, _this$store$discount2, _this$store$discount3, _this$store$discount4, currentDiscountList, currentEditDiscounts, currentScanDiscounts, currentScanDiscountIds, runtimeDiscountIds, runtimeDiscounts, mergedDiscountList;
|
|
496
496
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
497
497
|
while (1) switch (_context3.prev = _context3.next) {
|
|
498
498
|
case 0:
|
|
@@ -511,30 +511,38 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
511
511
|
case 3:
|
|
512
512
|
discountList = _context3.sent;
|
|
513
513
|
if (!discountList) {
|
|
514
|
-
_context3.next =
|
|
514
|
+
_context3.next = 16;
|
|
515
515
|
break;
|
|
516
516
|
}
|
|
517
|
-
|
|
517
|
+
currentDiscountList = ((_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 ? void 0 : _this$store$discount2.getDiscountList()) || [];
|
|
518
|
+
currentEditDiscounts = currentDiscountList.filter(function (discount) {
|
|
518
519
|
return discount === null || discount === void 0 ? void 0 : discount.isEditMode;
|
|
519
520
|
});
|
|
521
|
+
currentScanDiscounts = currentDiscountList.filter(function (discount) {
|
|
522
|
+
return discount === null || discount === void 0 ? void 0 : discount.isScan;
|
|
523
|
+
});
|
|
524
|
+
currentScanDiscountIds = new Set(currentScanDiscounts.map(function (discount) {
|
|
525
|
+
return discount === null || discount === void 0 ? void 0 : discount.id;
|
|
526
|
+
}));
|
|
520
527
|
runtimeDiscountIds = new Set();
|
|
521
528
|
runtimeDiscounts = discountList.filter(function (discount) {
|
|
529
|
+
if (currentScanDiscountIds.has(discount === null || discount === void 0 ? void 0 : discount.id)) return false;
|
|
522
530
|
if (runtimeDiscountIds.has(discount === null || discount === void 0 ? void 0 : discount.id)) return false;
|
|
523
531
|
runtimeDiscountIds.add(discount === null || discount === void 0 ? void 0 : discount.id);
|
|
524
532
|
return true;
|
|
525
533
|
});
|
|
526
|
-
mergedDiscountList = [].concat(_toConsumableArray(currentEditDiscounts), _toConsumableArray(runtimeDiscounts));
|
|
527
|
-
_context3.next =
|
|
534
|
+
mergedDiscountList = [].concat(_toConsumableArray(currentEditDiscounts), _toConsumableArray(currentScanDiscounts), _toConsumableArray(runtimeDiscounts));
|
|
535
|
+
_context3.next = 14;
|
|
528
536
|
return (_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.setOriginalDiscountList(mergedDiscountList);
|
|
529
|
-
case
|
|
530
|
-
_context3.next =
|
|
537
|
+
case 14:
|
|
538
|
+
_context3.next = 16;
|
|
531
539
|
return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.setDiscountList(mergedDiscountList);
|
|
532
|
-
case
|
|
540
|
+
case 16:
|
|
533
541
|
if (params.apply !== false && (_this$store$tempOrder2 = this.store.tempOrder) !== null && _this$store$tempOrder2 !== void 0 && (_this$store$tempOrder2 = _this$store$tempOrder2.products) !== null && _this$store$tempOrder2 !== void 0 && _this$store$tempOrder2.length) {
|
|
534
542
|
this.applyDiscount();
|
|
535
543
|
}
|
|
536
544
|
return _context3.abrupt("return", this.getDiscountList());
|
|
537
|
-
case
|
|
545
|
+
case 18:
|
|
538
546
|
case "end":
|
|
539
547
|
return _context3.stop();
|
|
540
548
|
}
|
|
@@ -2962,6 +2970,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2962
2970
|
var type = (_discount$type5 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type5 !== void 0 ? _discount$type5 : discount === null || discount === void 0 ? void 0 : discount.tag;
|
|
2963
2971
|
return type === 'good_pass' || type === 'discount_card' || type === 'product_discount_card';
|
|
2964
2972
|
}
|
|
2973
|
+
}, {
|
|
2974
|
+
key: "shouldKeepCustomerBoundDiscountAfterCustomerChange",
|
|
2975
|
+
value: function shouldKeepCustomerBoundDiscountAfterCustomerChange(discount) {
|
|
2976
|
+
return Boolean((discount === null || discount === void 0 ? void 0 : discount.isScan) || (discount === null || discount === void 0 ? void 0 : discount.isEditMode));
|
|
2977
|
+
}
|
|
2965
2978
|
}, {
|
|
2966
2979
|
key: "productHasCustomerBoundDiscount",
|
|
2967
2980
|
value: function productHasCustomerBoundDiscount(product) {
|
|
@@ -3029,11 +3042,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3029
3042
|
var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
|
|
3030
3043
|
var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
|
|
3031
3044
|
var nextDiscounts = currentDiscounts.filter(function (discount) {
|
|
3032
|
-
if (discount
|
|
3045
|
+
if (_this18.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
3033
3046
|
return !_this18.isCustomerBoundDiscount(discount);
|
|
3034
3047
|
});
|
|
3035
3048
|
var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
|
|
3036
|
-
if (discount
|
|
3049
|
+
if (_this18.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
3037
3050
|
return !_this18.isCustomerBoundDiscount(discount);
|
|
3038
3051
|
});
|
|
3039
3052
|
void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
|
|
@@ -3910,7 +3923,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3910
3923
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
3911
3924
|
var previous = previousByIdentity.get(_this23.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
|
|
3912
3925
|
if (!previous || _typeof(previous) !== 'object') return bundle;
|
|
3913
|
-
return _objectSpread(_objectSpread({}, bundle),
|
|
3926
|
+
return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
|
|
3927
|
+
cover: previous.cover
|
|
3928
|
+
} : {}), {}, {
|
|
3914
3929
|
price: previous.price,
|
|
3915
3930
|
custom_price: previous.custom_price,
|
|
3916
3931
|
bundle_payment_price: previous.bundle_payment_price,
|
|
@@ -67,8 +67,8 @@ export declare function sumOptionUnitPrice(options?: Array<{
|
|
|
67
67
|
/**
|
|
68
68
|
* 仅基于 tempOrder.products 重算整单定金。
|
|
69
69
|
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
70
|
+
* 商品折扣在进入定金计算前已体现在商品行价格字段中,
|
|
71
|
+
* 因此这里只按商品定金规则汇总,不再扣减 discount_list;tempOrder.bookings 不参与这里的计算。
|
|
72
72
|
*/
|
|
73
73
|
export declare function calculateOrderProductsDeposit(products?: OrderProduct[], options?: {
|
|
74
74
|
productsByUid?: Record<string, Record<string, any>>;
|
|
@@ -252,8 +252,8 @@ function getOrderProductDeposit(product, runtimeOrigin) {
|
|
|
252
252
|
/**
|
|
253
253
|
* 仅基于 tempOrder.products 重算整单定金。
|
|
254
254
|
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
255
|
+
* 商品折扣在进入定金计算前已体现在商品行价格字段中,
|
|
256
|
+
* 因此这里只按商品定金规则汇总,不再扣减 discount_list;tempOrder.bookings 不参与这里的计算。
|
|
257
257
|
*/
|
|
258
258
|
export function calculateOrderProductsDeposit() {
|
|
259
259
|
var products = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
@@ -273,30 +273,18 @@ export function calculateOrderProductsDeposit() {
|
|
|
273
273
|
product.deposit = deposit;
|
|
274
274
|
if (!(deposit !== null && deposit !== void 0 && deposit.total) || Number(deposit.total) <= 0) continue;
|
|
275
275
|
total = total.plus(deposit.total);
|
|
276
|
-
var _iterator4 = _createForOfIteratorHelper(
|
|
276
|
+
var _iterator4 = _createForOfIteratorHelper(deposit.protocols || []),
|
|
277
277
|
_step4;
|
|
278
278
|
try {
|
|
279
279
|
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
280
|
-
var
|
|
281
|
-
|
|
280
|
+
var protocol = _step4.value;
|
|
281
|
+
if (!protocolMap.has(protocol.id)) protocolMap.set(protocol.id, protocol);
|
|
282
282
|
}
|
|
283
283
|
} catch (err) {
|
|
284
284
|
_iterator4.e(err);
|
|
285
285
|
} finally {
|
|
286
286
|
_iterator4.f();
|
|
287
287
|
}
|
|
288
|
-
var _iterator5 = _createForOfIteratorHelper(deposit.protocols || []),
|
|
289
|
-
_step5;
|
|
290
|
-
try {
|
|
291
|
-
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
292
|
-
var protocol = _step5.value;
|
|
293
|
-
if (!protocolMap.has(protocol.id)) protocolMap.set(protocol.id, protocol);
|
|
294
|
-
}
|
|
295
|
-
} catch (err) {
|
|
296
|
-
_iterator5.e(err);
|
|
297
|
-
} finally {
|
|
298
|
-
_iterator5.f();
|
|
299
|
-
}
|
|
300
288
|
hasDeposit = true;
|
|
301
289
|
}
|
|
302
290
|
} catch (err) {
|
|
@@ -460,19 +448,19 @@ function resolveSubmitBundleMapId(bundle) {
|
|
|
460
448
|
}
|
|
461
449
|
function collectSubmitProductDiscountList(product) {
|
|
462
450
|
var submitDiscountList = Array.isArray(product === null || product === void 0 ? void 0 : product.discount_list) ? _toConsumableArray(product.discount_list) : [];
|
|
463
|
-
var
|
|
464
|
-
|
|
451
|
+
var _iterator5 = _createForOfIteratorHelper((product === null || product === void 0 ? void 0 : product.product_bundle) || []),
|
|
452
|
+
_step5;
|
|
465
453
|
try {
|
|
466
|
-
for (
|
|
467
|
-
var bundle =
|
|
454
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
455
|
+
var bundle = _step5.value;
|
|
468
456
|
if (!bundle || _typeof(bundle) !== 'object') continue;
|
|
469
457
|
var bundleMapId = resolveSubmitBundleMapId(bundle);
|
|
470
458
|
var bundleDiscountList = Array.isArray(bundle.discount_list) ? bundle.discount_list : [];
|
|
471
|
-
var
|
|
472
|
-
|
|
459
|
+
var _iterator6 = _createForOfIteratorHelper(bundleDiscountList),
|
|
460
|
+
_step6;
|
|
473
461
|
try {
|
|
474
|
-
for (
|
|
475
|
-
var discount =
|
|
462
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
463
|
+
var discount = _step6.value;
|
|
476
464
|
if (!discount || _typeof(discount) !== 'object') continue;
|
|
477
465
|
var discountMetadata = discount.metadata && _typeof(discount.metadata) === 'object' ? discount.metadata : {};
|
|
478
466
|
var discountMapId = discountMetadata.custom_product_bundle_map_id !== undefined && discountMetadata.custom_product_bundle_map_id !== null && discountMetadata.custom_product_bundle_map_id !== '' ? discountMetadata.custom_product_bundle_map_id : bundleMapId;
|
|
@@ -483,15 +471,15 @@ function collectSubmitProductDiscountList(product) {
|
|
|
483
471
|
} : {}));
|
|
484
472
|
}
|
|
485
473
|
} catch (err) {
|
|
486
|
-
|
|
474
|
+
_iterator6.e(err);
|
|
487
475
|
} finally {
|
|
488
|
-
|
|
476
|
+
_iterator6.f();
|
|
489
477
|
}
|
|
490
478
|
}
|
|
491
479
|
} catch (err) {
|
|
492
|
-
|
|
480
|
+
_iterator5.e(err);
|
|
493
481
|
} finally {
|
|
494
|
-
|
|
482
|
+
_iterator5.f();
|
|
495
483
|
}
|
|
496
484
|
return normalizeOrderProductDiscountList(submitDiscountList);
|
|
497
485
|
}
|
|
@@ -586,11 +574,14 @@ export function createDefaultOrderRulesHooks() {
|
|
|
586
574
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
587
575
|
var current = currentByIdentity.get(getBundleIdentity(bundle));
|
|
588
576
|
if (!current) return bundle;
|
|
577
|
+
var bundleWithDisplayFields = _objectSpread(_objectSpread({}, bundle), isEmptyOrderProductDisplayValue(bundle.cover) && !isEmptyOrderProductDisplayValue(current.cover) ? {
|
|
578
|
+
cover: current.cover
|
|
579
|
+
} : {});
|
|
589
580
|
var isProductPriceBundle = ((_bundle$price_type_ex2 = bundle.price_type_ext) !== null && _bundle$price_type_ex2 !== void 0 ? _bundle$price_type_ex2 : current.price_type_ext) === 'product_price';
|
|
590
|
-
if (!isProductPriceBundle) return
|
|
581
|
+
if (!isProductPriceBundle) return bundleWithDisplayFields;
|
|
591
582
|
var sourcePrice = (_ref18 = (_ref19 = (_current$price = current.price) !== null && _current$price !== void 0 ? _current$price : current.custom_price) !== null && _ref19 !== void 0 ? _ref19 : current.original_price) !== null && _ref18 !== void 0 ? _ref18 : current.bundle_selling_price;
|
|
592
583
|
var originalPrice = (_ref20 = (_ref21 = (_ref22 = (_current$original_pri = current.original_price) !== null && _current$original_pri !== void 0 ? _current$original_pri : current.product_price) !== null && _ref22 !== void 0 ? _ref22 : current.price) !== null && _ref21 !== void 0 ? _ref21 : current.custom_price) !== null && _ref20 !== void 0 ? _ref20 : sourcePrice;
|
|
593
|
-
return _objectSpread(_objectSpread(_objectSpread(_objectSpread({},
|
|
584
|
+
return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, bundleWithDisplayFields), sourcePrice !== undefined ? {
|
|
594
585
|
price: sourcePrice
|
|
595
586
|
} : {}), originalPrice !== undefined ? {
|
|
596
587
|
original_price: originalPrice
|
|
@@ -863,6 +854,7 @@ function formatSubmitBundleItems(bundle) {
|
|
|
863
854
|
bundle_group_id: (_rawBundle$bundle_gro = rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.bundle_group_id) !== null && _rawBundle$bundle_gro !== void 0 ? _rawBundle$bundle_gro : rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.group_id,
|
|
864
855
|
bundle_id: (_rawBundle$bundle_id = rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.bundle_id) !== null && _rawBundle$bundle_id !== void 0 ? _rawBundle$bundle_id : rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.id,
|
|
865
856
|
bundle_product_id: (_rawBundle$bundle_pro = rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.bundle_product_id) !== null && _rawBundle$bundle_pro !== void 0 ? _rawBundle$bundle_pro : rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle._bundle_product_id,
|
|
857
|
+
cover: rawBundle.cover,
|
|
866
858
|
metadata: _objectSpread(_objectSpread(_objectSpread({}, submitMetadata), hasSubmitBundleDiscounts && bundleMapId !== undefined ? {
|
|
867
859
|
custom_product_bundle_map_id: bundleMapId
|
|
868
860
|
} : {}), {}, {
|
|
@@ -957,19 +949,19 @@ export function normalizeBookingSubType(booking) {
|
|
|
957
949
|
export function normalizeSubmitBooking(booking) {
|
|
958
950
|
var rawMetadata = booking.metadata || {};
|
|
959
951
|
var cleanMetadata = {};
|
|
960
|
-
var
|
|
961
|
-
|
|
952
|
+
var _iterator7 = _createForOfIteratorHelper(SUBMIT_BOOKING_METADATA_WHITELIST),
|
|
953
|
+
_step7;
|
|
962
954
|
try {
|
|
963
|
-
for (
|
|
964
|
-
var key =
|
|
955
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
956
|
+
var key = _step7.value;
|
|
965
957
|
if (rawMetadata[key] !== undefined) {
|
|
966
958
|
cleanMetadata[key] = rawMetadata[key];
|
|
967
959
|
}
|
|
968
960
|
}
|
|
969
961
|
} catch (err) {
|
|
970
|
-
|
|
962
|
+
_iterator7.e(err);
|
|
971
963
|
} finally {
|
|
972
|
-
|
|
964
|
+
_iterator7.f();
|
|
973
965
|
}
|
|
974
966
|
if (cleanMetadata.holder_id === undefined) cleanMetadata.holder_id = null;
|
|
975
967
|
var bookingRecord = booking;
|
|
@@ -1282,25 +1274,25 @@ export function clearTempOrderHolderAssignments(tempOrder) {
|
|
|
1282
1274
|
target[key] = null;
|
|
1283
1275
|
changed = true;
|
|
1284
1276
|
};
|
|
1285
|
-
var
|
|
1286
|
-
|
|
1277
|
+
var _iterator8 = _createForOfIteratorHelper(tempOrder.products || []),
|
|
1278
|
+
_step8;
|
|
1287
1279
|
try {
|
|
1288
|
-
for (
|
|
1289
|
-
var product =
|
|
1280
|
+
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
1281
|
+
var product = _step8.value;
|
|
1290
1282
|
if (product.metadata && _typeof(product.metadata) === 'object') {
|
|
1291
1283
|
resetHolderField(product.metadata);
|
|
1292
1284
|
}
|
|
1293
1285
|
}
|
|
1294
1286
|
} catch (err) {
|
|
1295
|
-
|
|
1287
|
+
_iterator8.e(err);
|
|
1296
1288
|
} finally {
|
|
1297
|
-
|
|
1289
|
+
_iterator8.f();
|
|
1298
1290
|
}
|
|
1299
|
-
var
|
|
1300
|
-
|
|
1291
|
+
var _iterator9 = _createForOfIteratorHelper(tempOrder.bookings || []),
|
|
1292
|
+
_step9;
|
|
1301
1293
|
try {
|
|
1302
|
-
for (
|
|
1303
|
-
var booking =
|
|
1294
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
1295
|
+
var booking = _step9.value;
|
|
1304
1296
|
var bookingRecord = booking;
|
|
1305
1297
|
if (booking.metadata && _typeof(booking.metadata) === 'object') {
|
|
1306
1298
|
resetHolderField(booking.metadata);
|
|
@@ -1311,9 +1303,9 @@ export function clearTempOrderHolderAssignments(tempOrder) {
|
|
|
1311
1303
|
}
|
|
1312
1304
|
}
|
|
1313
1305
|
} catch (err) {
|
|
1314
|
-
|
|
1306
|
+
_iterator9.e(err);
|
|
1315
1307
|
} finally {
|
|
1316
|
-
|
|
1308
|
+
_iterator9.f();
|
|
1317
1309
|
}
|
|
1318
1310
|
var productsByUid = (_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend.productsByUid;
|
|
1319
1311
|
if (productsByUid && _typeof(productsByUid) === 'object') {
|
package/dist/server/index.d.ts
CHANGED
|
@@ -448,6 +448,7 @@ declare class Server {
|
|
|
448
448
|
private collectSalesDetailProductIds;
|
|
449
449
|
private buildSalesDetailProductSnapshotMap;
|
|
450
450
|
private withProductCatalogSnapshots;
|
|
451
|
+
private withBundleCatalogSnapshots;
|
|
451
452
|
private withSalesDetailProductSnapshots;
|
|
452
453
|
private withPendingSyncProductTitles;
|
|
453
454
|
private buildProductTitleSnapshot;
|
package/dist/server/index.js
CHANGED
|
@@ -5123,12 +5123,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
5123
5123
|
value: function collectSalesDetailProductIds(order) {
|
|
5124
5124
|
var products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : [];
|
|
5125
5125
|
var productIds = new Set();
|
|
5126
|
-
|
|
5127
|
-
var _product$product_id2;
|
|
5128
|
-
var rawProductId = (_product$product_id2 = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : product === null || product === void 0 ? void 0 : product.id;
|
|
5126
|
+
var addProductId = function addProductId(rawProductId) {
|
|
5129
5127
|
if (rawProductId === undefined || rawProductId === null || rawProductId === '') return;
|
|
5130
5128
|
var productId = Number(rawProductId);
|
|
5131
5129
|
if (Number.isFinite(productId)) productIds.add(productId);
|
|
5130
|
+
};
|
|
5131
|
+
products.forEach(function (product) {
|
|
5132
|
+
var _product$product_id2;
|
|
5133
|
+
addProductId((_product$product_id2 = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : product === null || product === void 0 ? void 0 : product.id);
|
|
5134
|
+
if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
|
|
5135
|
+
product.product_bundle.forEach(function (bundle) {
|
|
5136
|
+
var _ref61, _bundle$bundle_produc2;
|
|
5137
|
+
addProductId((_ref61 = (_bundle$bundle_produc2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref61 !== void 0 ? _ref61 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id);
|
|
5138
|
+
});
|
|
5139
|
+
}
|
|
5132
5140
|
});
|
|
5133
5141
|
return Array.from(productIds);
|
|
5134
5142
|
}
|
|
@@ -5196,6 +5204,31 @@ var Server = /*#__PURE__*/function () {
|
|
|
5196
5204
|
})
|
|
5197
5205
|
} : {});
|
|
5198
5206
|
}
|
|
5207
|
+
}, {
|
|
5208
|
+
key: "withBundleCatalogSnapshots",
|
|
5209
|
+
value: function withBundleCatalogSnapshots(product, snapshotMap) {
|
|
5210
|
+
if (!Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) return product;
|
|
5211
|
+
var hasChanged = false;
|
|
5212
|
+
var productBundle = product.product_bundle.map(function (bundle) {
|
|
5213
|
+
var _ref62, _bundle$bundle_produc3;
|
|
5214
|
+
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
5215
|
+
var rawProductId = (_ref62 = (_bundle$bundle_produc3 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref62 !== void 0 ? _ref62 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
|
|
5216
|
+
if (rawProductId === undefined || rawProductId === null || rawProductId === '') return bundle;
|
|
5217
|
+
var productId = Number(rawProductId);
|
|
5218
|
+
if (!Number.isFinite(productId)) return bundle;
|
|
5219
|
+
var snapshot = snapshotMap[String(productId)];
|
|
5220
|
+
var shouldFillCover = (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && (snapshot === null || snapshot === void 0 ? void 0 : snapshot.cover) !== undefined && snapshot.cover !== null && snapshot.cover !== '';
|
|
5221
|
+
if (!shouldFillCover) return bundle;
|
|
5222
|
+
hasChanged = true;
|
|
5223
|
+
return _objectSpread(_objectSpread({}, bundle), {}, {
|
|
5224
|
+
cover: snapshot.cover
|
|
5225
|
+
});
|
|
5226
|
+
});
|
|
5227
|
+
if (!hasChanged) return product;
|
|
5228
|
+
return _objectSpread(_objectSpread({}, product), {}, {
|
|
5229
|
+
product_bundle: productBundle
|
|
5230
|
+
});
|
|
5231
|
+
}
|
|
5199
5232
|
}, {
|
|
5200
5233
|
key: "withSalesDetailProductSnapshots",
|
|
5201
5234
|
value: function () {
|
|
@@ -5224,7 +5257,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
5224
5257
|
case 8:
|
|
5225
5258
|
hasChanged = false;
|
|
5226
5259
|
enrichedProducts = products.map(function (product) {
|
|
5227
|
-
var
|
|
5260
|
+
var productWithBundleSnapshots = _this13.withBundleCatalogSnapshots(product, snapshotMap);
|
|
5261
|
+
var nextProduct = _this13.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
|
|
5228
5262
|
if (nextProduct !== product) hasChanged = true;
|
|
5229
5263
|
return nextProduct;
|
|
5230
5264
|
});
|
|
@@ -5302,7 +5336,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5302
5336
|
}, {
|
|
5303
5337
|
key: "resolveProductTitleValue",
|
|
5304
5338
|
value: function resolveProductTitleValue(value, key, currentLocale) {
|
|
5305
|
-
var
|
|
5339
|
+
var _ref63, _ref64, _value$key;
|
|
5306
5340
|
if (value === undefined || value === null || value === '') return null;
|
|
5307
5341
|
if (_typeof(value) !== 'object') {
|
|
5308
5342
|
var title = String(value);
|
|
@@ -5312,7 +5346,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5312
5346
|
}
|
|
5313
5347
|
var normalizedKey = key.replace('-', '_');
|
|
5314
5348
|
var dashedKey = key.replace('_', '-');
|
|
5315
|
-
var rawValue = (
|
|
5349
|
+
var rawValue = (_ref63 = (_ref64 = (_value$key = value[key]) !== null && _value$key !== void 0 ? _value$key : value[normalizedKey]) !== null && _ref64 !== void 0 ? _ref64 : value[dashedKey]) !== null && _ref63 !== void 0 ? _ref63 : key === 'auto' ? value.default : undefined;
|
|
5316
5350
|
if (rawValue === undefined || rawValue === null || rawValue === '') return null;
|
|
5317
5351
|
if (_typeof(rawValue) === 'object') return this.resolveFirstProductTitleValue(rawValue);
|
|
5318
5352
|
return String(rawValue);
|
|
@@ -52,6 +52,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
52
52
|
private salesDetailLoadInFlight;
|
|
53
53
|
private serverOrderChangeUnsubscribe;
|
|
54
54
|
private serverOrderChangeHydrateInFlight;
|
|
55
|
+
private serverOrderChangeSyncEnabled;
|
|
55
56
|
constructor(name?: string, version?: string);
|
|
56
57
|
/**
|
|
57
58
|
* 子类可覆盖此方法以追加/收敛要注册的子模块。
|
|
@@ -73,6 +74,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
73
74
|
*/
|
|
74
75
|
private logError;
|
|
75
76
|
private isCurrentSalesOrderRecord;
|
|
77
|
+
setServerOrderChangeSyncEnabled(enabled: boolean): void;
|
|
76
78
|
private syncCurrentSalesDetailFromServerOrderChange;
|
|
77
79
|
private registerServerOrderChangeSync;
|
|
78
80
|
private hydrateOrderPaymentNames;
|
|
@@ -191,6 +193,16 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
191
193
|
discountList: Discount[];
|
|
192
194
|
}>;
|
|
193
195
|
getDiscountList(): Discount[];
|
|
196
|
+
/** 读取 Discount 模块原始券列表(未经过 bookingTime 等过滤)。 */
|
|
197
|
+
getOriginalDiscountList(): Discount[];
|
|
198
|
+
/**
|
|
199
|
+
* 同步写入 Discount 模块的 discountList / originalDiscountList。
|
|
200
|
+
* 供 Holder 补全等场景在 OS store 层更新 machinecode holder 字段。
|
|
201
|
+
*/
|
|
202
|
+
replaceDiscountStoreLists(params: {
|
|
203
|
+
discountList: Discount[];
|
|
204
|
+
originalDiscountList?: Discount[];
|
|
205
|
+
}): Promise<void>;
|
|
194
206
|
scanPromotionCode(code: string, customerId?: number): Promise<BaseSalesScanCodeResult>;
|
|
195
207
|
setDiscountSelected(params: {
|
|
196
208
|
discountId: number;
|