@pisell/pisellos 2.3.232 → 2.3.234
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/Customer/types.d.ts +4 -0
- package/dist/modules/Order/index.d.ts +10 -0
- package/dist/modules/Order/index.js +1392 -1157
- package/dist/modules/Order/types.d.ts +3 -0
- package/dist/modules/Order/utils/bookingUuid.d.ts +4 -0
- package/dist/modules/Order/utils/bookingUuid.js +24 -0
- package/dist/modules/Order/utils/virtualSettlement.d.ts +4 -0
- package/dist/modules/Order/utils/virtualSettlement.js +13 -0
- package/dist/modules/Order/utils.d.ts +1 -0
- package/dist/modules/Order/utils.js +12 -6
- package/dist/shared/payment/loadPaymentMethods.d.ts +5 -1
- package/dist/shared/payment/loadPaymentMethods.js +36 -2
- package/dist/solution/BaseSales/index.d.ts +4 -0
- package/dist/solution/BaseSales/index.js +571 -435
- package/dist/solution/BookingTicket/index.d.ts +3 -1
- package/dist/solution/BookingTicket/index.js +49 -43
- package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +1 -0
- package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +1 -1
- package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +69 -13
- package/dist/solution/Checkout/index.js +104 -69
- package/dist/solution/Checkout/types.d.ts +1 -0
- package/dist/solution/ScanOrder/index.js +10 -2
- package/dist/solution/VenueBooking/index.js +522 -490
- package/dist/utils/platform.d.ts +3 -0
- package/dist/utils/platform.js +8 -0
- package/lib/modules/Customer/types.d.ts +4 -0
- package/lib/modules/Order/index.d.ts +10 -0
- package/lib/modules/Order/index.js +155 -20
- package/lib/modules/Order/types.d.ts +3 -0
- package/lib/modules/Order/utils/bookingUuid.d.ts +4 -0
- package/lib/modules/Order/utils/bookingUuid.js +25 -0
- package/lib/modules/Order/utils/virtualSettlement.d.ts +4 -0
- package/lib/modules/Order/utils/virtualSettlement.js +9 -1
- package/lib/modules/Order/utils.d.ts +1 -0
- package/lib/modules/Order/utils.js +14 -5
- package/lib/shared/payment/loadPaymentMethods.d.ts +5 -1
- package/lib/shared/payment/loadPaymentMethods.js +14 -0
- package/lib/solution/BaseSales/index.d.ts +4 -0
- package/lib/solution/BaseSales/index.js +78 -16
- package/lib/solution/BookingTicket/index.d.ts +3 -1
- package/lib/solution/BookingTicket/index.js +4 -1
- package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +1 -0
- package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +1 -1
- package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +44 -5
- package/lib/solution/Checkout/index.js +21 -0
- package/lib/solution/Checkout/types.d.ts +1 -0
- package/lib/solution/ScanOrder/index.js +6 -0
- package/lib/solution/VenueBooking/index.js +6 -1
- package/lib/utils/platform.d.ts +3 -0
- package/lib/utils/platform.js +10 -0
- package/package.json +1 -1
|
@@ -85,7 +85,9 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
85
85
|
* 让现有 setActiveCustomer / getActiveCustomer 调用方零成本拿到详情态客户。
|
|
86
86
|
*/
|
|
87
87
|
loadSalesDetail(orderIdOrParams: number | string | LoadSalesDetailParams): Promise<ISalesDetail>;
|
|
88
|
-
scanPromotionCode(code: string, customerId?: number
|
|
88
|
+
scanPromotionCode(code: string, customerId?: number, options?: {
|
|
89
|
+
productVouchersOnly?: boolean;
|
|
90
|
+
}): Promise<BaseSalesScanCodeResult>;
|
|
89
91
|
private hydrateOrderCustomerFromScanDiscounts;
|
|
90
92
|
private getDiscountCustomerId;
|
|
91
93
|
resolveCustomerById(customerId: string | number): Promise<ICustomer | null>;
|
|
@@ -822,63 +822,69 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
822
822
|
}, {
|
|
823
823
|
key: "scanPromotionCode",
|
|
824
824
|
value: function () {
|
|
825
|
-
var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(code, customerId) {
|
|
825
|
+
var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(code, customerId, options) {
|
|
826
826
|
var raw, scannedList, extractedCustomerId, hasOrderCustomer, isUserPlatform, tempOrder;
|
|
827
827
|
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
828
828
|
while (1) switch (_context12.prev = _context12.next) {
|
|
829
829
|
case 0:
|
|
830
|
-
if (
|
|
830
|
+
if (!(options !== null && options !== void 0 && options.productVouchersOnly && (customerId === 0 || customerId === 1))) {
|
|
831
831
|
_context12.next = 2;
|
|
832
832
|
break;
|
|
833
833
|
}
|
|
834
|
-
|
|
834
|
+
return _context12.abrupt("return", _get(_getPrototypeOf(BookingTicketImpl.prototype), "scanPromotionCode", this).call(this, code, customerId, options));
|
|
835
835
|
case 2:
|
|
836
|
-
|
|
837
|
-
|
|
836
|
+
if (this.store.order) {
|
|
837
|
+
_context12.next = 4;
|
|
838
|
+
break;
|
|
839
|
+
}
|
|
840
|
+
throw new Error('order 模块未初始化');
|
|
838
841
|
case 4:
|
|
842
|
+
_context12.next = 6;
|
|
843
|
+
return this.store.order.scanCode(code, customerId);
|
|
844
|
+
case 6:
|
|
839
845
|
raw = _context12.sent;
|
|
840
846
|
scannedList = raw.scannedDiscountList || [];
|
|
841
847
|
extractedCustomerId = this.getDiscountCustomerId(scannedList);
|
|
842
848
|
hasOrderCustomer = Boolean(this.store.order.getOrderCustomer());
|
|
843
849
|
isUserPlatform = USER_PLATFORM.includes(this.otherParams.platform); // 缺 Holder 等场景 isAvailable=false,但仍需把 Pass 归属客户带入订单,供 Holder 弹窗使用。
|
|
844
850
|
if (!(!hasOrderCustomer && extractedCustomerId && !isUserPlatform)) {
|
|
845
|
-
_context12.next =
|
|
851
|
+
_context12.next = 20;
|
|
846
852
|
break;
|
|
847
853
|
}
|
|
848
|
-
_context12.prev =
|
|
849
|
-
_context12.next =
|
|
854
|
+
_context12.prev = 12;
|
|
855
|
+
_context12.next = 15;
|
|
850
856
|
return this.hydrateOrderCustomerFromScanDiscounts(scannedList);
|
|
851
|
-
case 13:
|
|
852
|
-
_context12.next = 18;
|
|
853
|
-
break;
|
|
854
857
|
case 15:
|
|
855
|
-
_context12.
|
|
856
|
-
|
|
858
|
+
_context12.next = 20;
|
|
859
|
+
break;
|
|
860
|
+
case 17:
|
|
861
|
+
_context12.prev = 17;
|
|
862
|
+
_context12.t0 = _context12["catch"](12);
|
|
857
863
|
// 客户映射失败不能阻断原有 Pass 的可用性、展示或优惠处理。
|
|
858
864
|
console.warn('[BookingTicket] scan discount customer resolve failed', {
|
|
859
865
|
customerId: extractedCustomerId,
|
|
860
866
|
error: _context12.t0
|
|
861
867
|
});
|
|
862
|
-
case
|
|
868
|
+
case 20:
|
|
863
869
|
if (!raw.isAvailable) {
|
|
864
|
-
_context12.next =
|
|
870
|
+
_context12.next = 27;
|
|
865
871
|
break;
|
|
866
872
|
}
|
|
867
|
-
_context12.next =
|
|
873
|
+
_context12.next = 23;
|
|
868
874
|
return this.store.order.recalculateSummary({
|
|
869
875
|
createIfMissing: true
|
|
870
876
|
});
|
|
871
|
-
case
|
|
877
|
+
case 23:
|
|
872
878
|
this.store.order.persistTempOrder();
|
|
873
879
|
tempOrder = this.store.order.ensureTempOrder();
|
|
874
|
-
_context12.next =
|
|
880
|
+
_context12.next = 27;
|
|
875
881
|
return this.effectsEmit('onDiscountApplied', {
|
|
876
882
|
productList: tempOrder.products || [],
|
|
877
883
|
discountList: this.store.order.getDiscountList(),
|
|
878
884
|
selectedDiscountList: tempOrder.discount_list || [],
|
|
879
885
|
tempOrder: tempOrder
|
|
880
886
|
});
|
|
881
|
-
case
|
|
887
|
+
case 27:
|
|
882
888
|
return _context12.abrupt("return", _objectSpread(_objectSpread({
|
|
883
889
|
isAvailable: raw.isAvailable
|
|
884
890
|
}, raw.isAccepted !== undefined ? {
|
|
@@ -889,13 +895,13 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
889
895
|
unavailableReasonKey: raw.unavailableReasonKey,
|
|
890
896
|
scannedDiscountList: raw.scannedDiscountList
|
|
891
897
|
}));
|
|
892
|
-
case
|
|
898
|
+
case 28:
|
|
893
899
|
case "end":
|
|
894
900
|
return _context12.stop();
|
|
895
901
|
}
|
|
896
|
-
}, _callee12, this, [[
|
|
902
|
+
}, _callee12, this, [[12, 17]]);
|
|
897
903
|
}));
|
|
898
|
-
function scanPromotionCode(_x4, _x5) {
|
|
904
|
+
function scanPromotionCode(_x4, _x5, _x6) {
|
|
899
905
|
return _scanPromotionCode.apply(this, arguments);
|
|
900
906
|
}
|
|
901
907
|
return scanPromotionCode;
|
|
@@ -940,7 +946,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
940
946
|
}
|
|
941
947
|
}, _callee13, this);
|
|
942
948
|
}));
|
|
943
|
-
function hydrateOrderCustomerFromScanDiscounts(
|
|
949
|
+
function hydrateOrderCustomerFromScanDiscounts(_x7) {
|
|
944
950
|
return _hydrateOrderCustomerFromScanDiscounts.apply(this, arguments);
|
|
945
951
|
}
|
|
946
952
|
return hydrateOrderCustomerFromScanDiscounts;
|
|
@@ -1021,7 +1027,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1021
1027
|
}
|
|
1022
1028
|
}, _callee14, this);
|
|
1023
1029
|
}));
|
|
1024
|
-
function resolveCustomerById(
|
|
1030
|
+
function resolveCustomerById(_x8) {
|
|
1025
1031
|
return _resolveCustomerById.apply(this, arguments);
|
|
1026
1032
|
}
|
|
1027
1033
|
return resolveCustomerById;
|
|
@@ -1126,7 +1132,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1126
1132
|
}
|
|
1127
1133
|
}, _callee15, this, [[11, 21]]);
|
|
1128
1134
|
}));
|
|
1129
|
-
function setBookingStatus(
|
|
1135
|
+
function setBookingStatus(_x9) {
|
|
1130
1136
|
return _setBookingStatus.apply(this, arguments);
|
|
1131
1137
|
}
|
|
1132
1138
|
return setBookingStatus;
|
|
@@ -1221,7 +1227,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1221
1227
|
}
|
|
1222
1228
|
}, _callee16, this, [[14, 24]]);
|
|
1223
1229
|
}));
|
|
1224
|
-
function transitionChildBooking(
|
|
1230
|
+
function transitionChildBooking(_x10) {
|
|
1225
1231
|
return _transitionChildBooking.apply(this, arguments);
|
|
1226
1232
|
}
|
|
1227
1233
|
return transitionChildBooking;
|
|
@@ -1427,7 +1433,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1427
1433
|
}
|
|
1428
1434
|
}, _callee20, this, [[1, 9]]);
|
|
1429
1435
|
}));
|
|
1430
|
-
function queryProductDetail(
|
|
1436
|
+
function queryProductDetail(_x11, _x12) {
|
|
1431
1437
|
return _queryProductDetail.apply(this, arguments);
|
|
1432
1438
|
}
|
|
1433
1439
|
return queryProductDetail;
|
|
@@ -1461,7 +1467,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1461
1467
|
}
|
|
1462
1468
|
}, _callee21, this);
|
|
1463
1469
|
}));
|
|
1464
|
-
function loadProductDetail(
|
|
1470
|
+
function loadProductDetail(_x13, _x14) {
|
|
1465
1471
|
return _loadProductDetail.apply(this, arguments);
|
|
1466
1472
|
}
|
|
1467
1473
|
return loadProductDetail;
|
|
@@ -1643,7 +1649,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1643
1649
|
}
|
|
1644
1650
|
}, _callee23, this);
|
|
1645
1651
|
}));
|
|
1646
|
-
function getProductByIds(
|
|
1652
|
+
function getProductByIds(_x15, _x16) {
|
|
1647
1653
|
return _getProductByIds.apply(this, arguments);
|
|
1648
1654
|
}
|
|
1649
1655
|
return getProductByIds;
|
|
@@ -1677,7 +1683,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1677
1683
|
}
|
|
1678
1684
|
}, _callee24, this);
|
|
1679
1685
|
}));
|
|
1680
|
-
function getScheduleTimePoints(
|
|
1686
|
+
function getScheduleTimePoints(_x17) {
|
|
1681
1687
|
return _getScheduleTimePoints.apply(this, arguments);
|
|
1682
1688
|
}
|
|
1683
1689
|
return getScheduleTimePoints;
|
|
@@ -2042,7 +2048,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2042
2048
|
}
|
|
2043
2049
|
}, _callee29, this);
|
|
2044
2050
|
}));
|
|
2045
|
-
function applyDefaultOrderCustomerContactInfo(
|
|
2051
|
+
function applyDefaultOrderCustomerContactInfo(_x18) {
|
|
2046
2052
|
return _applyDefaultOrderCustomerContactInfo.apply(this, arguments);
|
|
2047
2053
|
}
|
|
2048
2054
|
return applyDefaultOrderCustomerContactInfo;
|
|
@@ -2204,7 +2210,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2204
2210
|
}
|
|
2205
2211
|
}, _callee31);
|
|
2206
2212
|
}));
|
|
2207
|
-
return function (
|
|
2213
|
+
return function (_x19) {
|
|
2208
2214
|
return _ref13.apply(this, arguments);
|
|
2209
2215
|
};
|
|
2210
2216
|
}()).catch(function () {
|
|
@@ -2501,7 +2507,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2501
2507
|
}
|
|
2502
2508
|
}, _callee36, this);
|
|
2503
2509
|
}));
|
|
2504
|
-
function prepareProductPriceQueryContext(
|
|
2510
|
+
function prepareProductPriceQueryContext(_x20) {
|
|
2505
2511
|
return _prepareProductPriceQueryContext.apply(this, arguments);
|
|
2506
2512
|
}
|
|
2507
2513
|
return prepareProductPriceQueryContext;
|
|
@@ -2576,7 +2582,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2576
2582
|
}
|
|
2577
2583
|
}, _callee37, this, [[0, 7]]);
|
|
2578
2584
|
}));
|
|
2579
|
-
function changeCustomerPage(
|
|
2585
|
+
function changeCustomerPage(_x21, _x22) {
|
|
2580
2586
|
return _changeCustomerPage.apply(this, arguments);
|
|
2581
2587
|
}
|
|
2582
2588
|
return changeCustomerPage;
|
|
@@ -3178,7 +3184,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3178
3184
|
}
|
|
3179
3185
|
}, _callee41, this);
|
|
3180
3186
|
}));
|
|
3181
|
-
function updateProductInOrder(
|
|
3187
|
+
function updateProductInOrder(_x23) {
|
|
3182
3188
|
return _updateProductInOrder.apply(this, arguments);
|
|
3183
3189
|
}
|
|
3184
3190
|
return updateProductInOrder;
|
|
@@ -3412,7 +3418,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3412
3418
|
}
|
|
3413
3419
|
}, _callee43, this, [[4, 40]]);
|
|
3414
3420
|
}));
|
|
3415
|
-
function handleGlobalScanCode(
|
|
3421
|
+
function handleGlobalScanCode(_x24, _x25) {
|
|
3416
3422
|
return _handleGlobalScanCode.apply(this, arguments);
|
|
3417
3423
|
}
|
|
3418
3424
|
return handleGlobalScanCode;
|
|
@@ -3452,7 +3458,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3452
3458
|
}
|
|
3453
3459
|
}, _callee44, this);
|
|
3454
3460
|
}));
|
|
3455
|
-
function getGlobalScanCodeType(
|
|
3461
|
+
function getGlobalScanCodeType(_x26) {
|
|
3456
3462
|
return _getGlobalScanCodeType.apply(this, arguments);
|
|
3457
3463
|
}
|
|
3458
3464
|
return getGlobalScanCodeType;
|
|
@@ -3550,7 +3556,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3550
3556
|
}
|
|
3551
3557
|
}, _callee45, this);
|
|
3552
3558
|
}));
|
|
3553
|
-
function addAddTimeProductToBooking(
|
|
3559
|
+
function addAddTimeProductToBooking(_x27) {
|
|
3554
3560
|
return _addAddTimeProductToBooking.apply(this, arguments);
|
|
3555
3561
|
}
|
|
3556
3562
|
return addAddTimeProductToBooking;
|
|
@@ -3650,7 +3656,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3650
3656
|
}
|
|
3651
3657
|
}, _callee46, this, [[13, 31, 34, 37]]);
|
|
3652
3658
|
}));
|
|
3653
|
-
function addAddTimeProductsToBooking(
|
|
3659
|
+
function addAddTimeProductsToBooking(_x28) {
|
|
3654
3660
|
return _addAddTimeProductsToBooking.apply(this, arguments);
|
|
3655
3661
|
}
|
|
3656
3662
|
return addAddTimeProductsToBooking;
|
|
@@ -3700,7 +3706,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3700
3706
|
}
|
|
3701
3707
|
}, _callee47, this);
|
|
3702
3708
|
}));
|
|
3703
|
-
function setOtherParams(
|
|
3709
|
+
function setOtherParams(_x29) {
|
|
3704
3710
|
return _setOtherParams.apply(this, arguments);
|
|
3705
3711
|
}
|
|
3706
3712
|
return setOtherParams;
|
|
@@ -3774,7 +3780,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3774
3780
|
}
|
|
3775
3781
|
}, _callee48, this);
|
|
3776
3782
|
}));
|
|
3777
|
-
function handlePrintWristband(
|
|
3783
|
+
function handlePrintWristband(_x30) {
|
|
3778
3784
|
return _handlePrintWristband.apply(this, arguments);
|
|
3779
3785
|
}
|
|
3780
3786
|
return handlePrintWristband;
|
|
@@ -3871,7 +3877,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3871
3877
|
}
|
|
3872
3878
|
}, _callee49, this, [[11,, 14, 17]]);
|
|
3873
3879
|
}));
|
|
3874
|
-
function handleRedeem(
|
|
3880
|
+
function handleRedeem(_x31) {
|
|
3875
3881
|
return _handleRedeem.apply(this, arguments);
|
|
3876
3882
|
}
|
|
3877
3883
|
return handleRedeem;
|
|
@@ -4067,7 +4073,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
4067
4073
|
}
|
|
4068
4074
|
}, _callee51, this);
|
|
4069
4075
|
}));
|
|
4070
|
-
function updateTicketArrival(
|
|
4076
|
+
function updateTicketArrival(_x32) {
|
|
4071
4077
|
return _updateTicketArrival.apply(this, arguments);
|
|
4072
4078
|
}
|
|
4073
4079
|
return updateTicketArrival;
|
|
@@ -24,6 +24,7 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
|
|
|
24
24
|
products: import("../../../modules/Order/types").OrderSubmitProduct[];
|
|
25
25
|
notes?: import("../../../modules/Order/types").SalesNote[] | undefined;
|
|
26
26
|
summary?: import("../../../modules/Order/types").OrderSummary | undefined;
|
|
27
|
+
product_tax_fee?: string | undefined;
|
|
27
28
|
small_ticket_data_flag?: number | undefined;
|
|
28
29
|
status: string;
|
|
29
30
|
metadata: Record<string, any>;
|
|
@@ -4,5 +4,5 @@ import type { GlobalScanFormattedResult } from './formatGlobalScan';
|
|
|
4
4
|
export interface ProductVoucherCollectionScanHost extends GlobalScanApplyHost {
|
|
5
5
|
loadCustomerDiscounts(): Promise<Record<string, any>[]>;
|
|
6
6
|
}
|
|
7
|
-
/**
|
|
7
|
+
/** Collect vouchers by member account or by scan code for a walk-in. */
|
|
8
8
|
export declare function applyProductVoucherCollectionScan(host: ProductVoucherCollectionScanHost, formatted: GlobalScanFormattedResult, bridge: GlobalScanHostBridge): Promise<GlobalScanHandleResult>;
|
|
@@ -7,15 +7,16 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
7
7
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
8
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
9
9
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
10
|
+
import { isWalkInCustomer } from "../cartView";
|
|
10
11
|
import { applyGlobalScan } from "./applyGlobalScan";
|
|
11
|
-
/**
|
|
12
|
+
/** Collect vouchers by member account or by scan code for a walk-in. */
|
|
12
13
|
export function applyProductVoucherCollectionScan(_x, _x2, _x3) {
|
|
13
14
|
return _applyProductVoucherCollectionScan.apply(this, arguments);
|
|
14
15
|
}
|
|
15
16
|
function _applyProductVoucherCollectionScan() {
|
|
16
17
|
_applyProductVoucherCollectionScan = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(host, formatted, bridge) {
|
|
17
18
|
var _ref, _formatted$customerId, _formatted$data, _formatted$data2, _bridge$requestCustom;
|
|
18
|
-
var assertCurrent, isPass, customerScan, result, vouchers;
|
|
19
|
+
var assertCurrent, isPass, customerId, _promotion$isAccepted, promotion, redemption, customerScan, result, vouchers;
|
|
19
20
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
20
21
|
while (1) switch (_context2.prev = _context2.next) {
|
|
21
22
|
case 0:
|
|
@@ -25,16 +26,71 @@ function _applyProductVoucherCollectionScan() {
|
|
|
25
26
|
throw new DOMException('Scan session ended', 'AbortError');
|
|
26
27
|
}
|
|
27
28
|
};
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
assertCurrent();
|
|
30
|
+
isPass = formatted.searchType === 'walletPass';
|
|
31
|
+
customerId = (_ref = (_formatted$customerId = formatted.customerId) !== null && _formatted$customerId !== void 0 ? _formatted$customerId : (_formatted$data = formatted.data) === null || _formatted$data === void 0 ? void 0 : _formatted$data.id) !== null && _ref !== void 0 ? _ref : (_formatted$data2 = formatted.data) === null || _formatted$data2 === void 0 ? void 0 : _formatted$data2.customer_id;
|
|
32
|
+
if (!(isPass && customerId != null && customerId !== '' && isWalkInCustomer({
|
|
33
|
+
id: customerId
|
|
34
|
+
}))) {
|
|
35
|
+
_context2.next = 17;
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
if (!formatted.isWalletPassUnavailableAtStore) {
|
|
39
|
+
_context2.next = 7;
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
return _context2.abrupt("return", {
|
|
43
|
+
status: 'failed',
|
|
44
|
+
reason: 'invalid_data'
|
|
45
|
+
});
|
|
46
|
+
case 7:
|
|
47
|
+
if (bridge.applyPromotionCode) {
|
|
48
|
+
_context2.next = 9;
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
return _context2.abrupt("return", {
|
|
52
|
+
status: 'failed',
|
|
53
|
+
reason: 'no_bridge'
|
|
54
|
+
});
|
|
55
|
+
case 9:
|
|
56
|
+
_context2.next = 11;
|
|
57
|
+
return bridge.applyPromotionCode(formatted.scanCode, Number(customerId), {
|
|
58
|
+
productVouchersOnly: true,
|
|
59
|
+
suppressFailureNotification: true
|
|
60
|
+
});
|
|
61
|
+
case 11:
|
|
62
|
+
promotion = _context2.sent;
|
|
63
|
+
assertCurrent();
|
|
64
|
+
if (Array.isArray(promotion.scannedDiscountList)) {
|
|
65
|
+
_context2.next = 15;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
return _context2.abrupt("return", {
|
|
69
|
+
status: 'failed',
|
|
70
|
+
reason: 'entry_resolution_failed'
|
|
71
|
+
});
|
|
72
|
+
case 15:
|
|
73
|
+
redemption = {
|
|
74
|
+
source: 'scan',
|
|
75
|
+
vouchers: promotion.scannedDiscountList
|
|
76
|
+
};
|
|
77
|
+
return _context2.abrupt("return", ((_promotion$isAccepted = promotion.isAccepted) !== null && _promotion$isAccepted !== void 0 ? _promotion$isAccepted : promotion.isAvailable) ? {
|
|
78
|
+
status: 'success',
|
|
79
|
+
kind: 'promotion',
|
|
80
|
+
redemption: redemption
|
|
81
|
+
} : {
|
|
82
|
+
status: 'failed',
|
|
83
|
+
reason: 'not_found',
|
|
84
|
+
redemption: redemption
|
|
85
|
+
});
|
|
86
|
+
case 17:
|
|
30
87
|
// Resolve source-shop IDs before reusing the wallet customer-binding flow.
|
|
31
88
|
customerScan = isPass ? _objectSpread(_objectSpread({}, formatted), {}, {
|
|
32
89
|
searchType: 'wallet',
|
|
33
|
-
customerId:
|
|
90
|
+
customerId: customerId,
|
|
34
91
|
isCrossShopWallet: true
|
|
35
92
|
}) : formatted;
|
|
36
|
-
|
|
37
|
-
_context2.next = 6;
|
|
93
|
+
_context2.next = 20;
|
|
38
94
|
return applyGlobalScan(_objectSpread(_objectSpread({}, host), {}, {
|
|
39
95
|
setOrderCustomer: function setOrderCustomer(customer) {
|
|
40
96
|
assertCurrent();
|
|
@@ -58,16 +114,16 @@ function _applyProductVoucherCollectionScan() {
|
|
|
58
114
|
}, _callee);
|
|
59
115
|
}))
|
|
60
116
|
}));
|
|
61
|
-
case
|
|
117
|
+
case 20:
|
|
62
118
|
result = _context2.sent;
|
|
63
119
|
assertCurrent();
|
|
64
120
|
if (!(customerScan.searchType === 'wallet' && result.status === 'success')) {
|
|
65
|
-
_context2.next =
|
|
121
|
+
_context2.next = 28;
|
|
66
122
|
break;
|
|
67
123
|
}
|
|
68
|
-
_context2.next =
|
|
124
|
+
_context2.next = 25;
|
|
69
125
|
return host.loadCustomerDiscounts();
|
|
70
|
-
case
|
|
126
|
+
case 25:
|
|
71
127
|
vouchers = _context2.sent;
|
|
72
128
|
assertCurrent();
|
|
73
129
|
return _context2.abrupt("return", _objectSpread(_objectSpread({}, result), {}, {
|
|
@@ -76,9 +132,9 @@ function _applyProductVoucherCollectionScan() {
|
|
|
76
132
|
vouchers: vouchers
|
|
77
133
|
}
|
|
78
134
|
}));
|
|
79
|
-
case
|
|
135
|
+
case 28:
|
|
80
136
|
return _context2.abrupt("return", result);
|
|
81
|
-
case
|
|
137
|
+
case 29:
|
|
82
138
|
case "end":
|
|
83
139
|
return _context2.stop();
|
|
84
140
|
}
|