@pisell/pisellos 2.2.202 → 2.2.204
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/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/Order/index.d.ts +38 -1
- package/dist/modules/Order/index.js +381 -223
- package/dist/modules/Order/types.d.ts +2 -0
- package/dist/solution/BaseSales/index.d.ts +7 -0
- package/dist/solution/BaseSales/index.js +65 -42
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/Order/index.d.ts +38 -1
- package/lib/modules/Order/index.js +90 -19
- package/lib/modules/Order/types.d.ts +2 -0
- package/lib/solution/BaseSales/index.d.ts +7 -0
- package/lib/solution/BaseSales/index.js +11 -4
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -2635,7 +2635,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2635
2635
|
};
|
|
2636
2636
|
var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
|
|
2637
2637
|
return _this15.normalizePaymentSource(payment, {
|
|
2638
|
-
defaultPaid:
|
|
2638
|
+
defaultPaid: true
|
|
2639
2639
|
});
|
|
2640
2640
|
})).filter(function (payment) {
|
|
2641
2641
|
return isVoucherPayment(payment);
|
|
@@ -2715,16 +2715,60 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2715
2715
|
}
|
|
2716
2716
|
return shouldMergeProductToOrder;
|
|
2717
2717
|
}() // ─── TempOrder: 商品 CRUD ───
|
|
2718
|
+
/**
|
|
2719
|
+
* 预约商品加车后的统一收尾:促销、折扣、summary 重算与持久化(批量拆行时只调用一次)。
|
|
2720
|
+
*
|
|
2721
|
+
* @example
|
|
2722
|
+
* await this.finalizeProductOrderMutation(tempOrder);
|
|
2723
|
+
*/
|
|
2718
2724
|
}, {
|
|
2719
|
-
key: "
|
|
2725
|
+
key: "finalizeProductOrderMutation",
|
|
2720
2726
|
value: function () {
|
|
2721
|
-
var
|
|
2722
|
-
var _this16 = this;
|
|
2723
|
-
var tempOrder, linked, productToAdd, incomingFingerprint, normalizedIncoming, hasIncomingGoodPass, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList;
|
|
2727
|
+
var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(tempOrder) {
|
|
2724
2728
|
return _regeneratorRuntime().wrap(function _callee14$(_context16) {
|
|
2725
2729
|
while (1) switch (_context16.prev = _context16.next) {
|
|
2726
2730
|
case 0:
|
|
2727
|
-
|
|
2731
|
+
_context16.next = 2;
|
|
2732
|
+
return this.ensureEditDiscountConfigForProductChange(tempOrder);
|
|
2733
|
+
case 2:
|
|
2734
|
+
_context16.next = 4;
|
|
2735
|
+
return this.applyPromotion();
|
|
2736
|
+
case 4:
|
|
2737
|
+
this.applyDiscount();
|
|
2738
|
+
this.sanitizeTempOrderProducts(tempOrder);
|
|
2739
|
+
_context16.next = 8;
|
|
2740
|
+
return this.recalculateSummary({
|
|
2741
|
+
createIfMissing: true
|
|
2742
|
+
});
|
|
2743
|
+
case 8:
|
|
2744
|
+
this.persistTempOrder();
|
|
2745
|
+
case 9:
|
|
2746
|
+
case "end":
|
|
2747
|
+
return _context16.stop();
|
|
2748
|
+
}
|
|
2749
|
+
}, _callee14, this);
|
|
2750
|
+
}));
|
|
2751
|
+
function finalizeProductOrderMutation(_x14) {
|
|
2752
|
+
return _finalizeProductOrderMutation.apply(this, arguments);
|
|
2753
|
+
}
|
|
2754
|
+
return finalizeProductOrderMutation;
|
|
2755
|
+
}()
|
|
2756
|
+
/**
|
|
2757
|
+
* 向 tempOrder 追加一条商品行(及可选 booking),不触发 summary 重算。
|
|
2758
|
+
* 带 booking 且 num>1 时由 `addProductToOrder` 拆成多次本方法调用(每次 num=1)。
|
|
2759
|
+
*
|
|
2760
|
+
* @example
|
|
2761
|
+
* await this.appendProductLineToTempOrder(tempOrder, { product_id: 1, num: 1 }, booking);
|
|
2762
|
+
*/
|
|
2763
|
+
}, {
|
|
2764
|
+
key: "appendProductLineToTempOrder",
|
|
2765
|
+
value: (function () {
|
|
2766
|
+
var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(tempOrder, product, booking) {
|
|
2767
|
+
var _this16 = this;
|
|
2768
|
+
var linked, productToAdd, incomingFingerprint, normalizedIncoming, hasIncomingGoodPass, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList;
|
|
2769
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context17) {
|
|
2770
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
2771
|
+
case 0:
|
|
2728
2772
|
linked = booking ? this.createLinkedProductAndBooking({
|
|
2729
2773
|
product: product,
|
|
2730
2774
|
booking: booking
|
|
@@ -2745,10 +2789,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2745
2789
|
matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
|
|
2746
2790
|
existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
|
|
2747
2791
|
if (!matchedProduct) {
|
|
2748
|
-
|
|
2792
|
+
_context17.next = 16;
|
|
2749
2793
|
break;
|
|
2750
2794
|
}
|
|
2751
|
-
|
|
2795
|
+
_context17.next = 13;
|
|
2752
2796
|
return this.shouldMergeProductToOrder({
|
|
2753
2797
|
incomingProduct: productToAdd,
|
|
2754
2798
|
normalizedIncoming: normalizedIncoming,
|
|
@@ -2759,14 +2803,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2759
2803
|
tempOrder: tempOrder,
|
|
2760
2804
|
booking: booking
|
|
2761
2805
|
});
|
|
2762
|
-
case
|
|
2763
|
-
|
|
2764
|
-
|
|
2806
|
+
case 13:
|
|
2807
|
+
_context17.t0 = _context17.sent;
|
|
2808
|
+
_context17.next = 17;
|
|
2765
2809
|
break;
|
|
2810
|
+
case 16:
|
|
2811
|
+
_context17.t0 = false;
|
|
2766
2812
|
case 17:
|
|
2767
|
-
|
|
2768
|
-
case 18:
|
|
2769
|
-
shouldMerge = _context16.t0;
|
|
2813
|
+
shouldMerge = _context17.t0;
|
|
2770
2814
|
if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
|
|
2771
2815
|
this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
|
|
2772
2816
|
if (linked) {
|
|
@@ -2817,32 +2861,83 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2817
2861
|
if (linked) {
|
|
2818
2862
|
tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
|
|
2819
2863
|
}
|
|
2820
|
-
|
|
2821
|
-
|
|
2864
|
+
case 20:
|
|
2865
|
+
case "end":
|
|
2866
|
+
return _context17.stop();
|
|
2867
|
+
}
|
|
2868
|
+
}, _callee15, this);
|
|
2869
|
+
}));
|
|
2870
|
+
function appendProductLineToTempOrder(_x15, _x16, _x17) {
|
|
2871
|
+
return _appendProductLineToTempOrder.apply(this, arguments);
|
|
2872
|
+
}
|
|
2873
|
+
return appendProductLineToTempOrder;
|
|
2874
|
+
}()
|
|
2875
|
+
/**
|
|
2876
|
+
* 添加商品行。带 booking 时强制独立行;num>1 时拆成多条 num=1 的 product+booking(对齐 BookingByStep / ticketBooking addService)。
|
|
2877
|
+
*
|
|
2878
|
+
* @example
|
|
2879
|
+
* await order.addProductToOrder({ product_id: 1, num: 3 }, { start_time: '10:00' });
|
|
2880
|
+
* // → tempOrder.products 新增 3 行,每行 num=1,bookings 3 条
|
|
2881
|
+
*/
|
|
2882
|
+
)
|
|
2883
|
+
}, {
|
|
2884
|
+
key: "addProductToOrder",
|
|
2885
|
+
value: (function () {
|
|
2886
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(product, booking) {
|
|
2887
|
+
var tempOrder, _ref58, _productRecord$num, productRecord, splitCount, i, singleLine;
|
|
2888
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context18) {
|
|
2889
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
2890
|
+
case 0:
|
|
2891
|
+
tempOrder = this.ensureTempOrder();
|
|
2892
|
+
if (!booking) {
|
|
2893
|
+
_context18.next = 18;
|
|
2894
|
+
break;
|
|
2895
|
+
}
|
|
2896
|
+
productRecord = product;
|
|
2897
|
+
splitCount = getSafeProductNum((_ref58 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref58 !== void 0 ? _ref58 : 1);
|
|
2898
|
+
if (!(splitCount > 1)) {
|
|
2899
|
+
_context18.next = 18;
|
|
2900
|
+
break;
|
|
2901
|
+
}
|
|
2902
|
+
i = 0;
|
|
2903
|
+
case 6:
|
|
2904
|
+
if (!(i < splitCount)) {
|
|
2905
|
+
_context18.next = 15;
|
|
2906
|
+
break;
|
|
2907
|
+
}
|
|
2908
|
+
singleLine = cloneDeep(productRecord);
|
|
2909
|
+
singleLine.num = 1;
|
|
2910
|
+
delete singleLine.product_quantity;
|
|
2911
|
+
_context18.next = 12;
|
|
2912
|
+
return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
|
|
2913
|
+
case 12:
|
|
2914
|
+
i += 1;
|
|
2915
|
+
_context18.next = 6;
|
|
2916
|
+
break;
|
|
2917
|
+
case 15:
|
|
2918
|
+
_context18.next = 17;
|
|
2919
|
+
return this.finalizeProductOrderMutation(tempOrder);
|
|
2920
|
+
case 17:
|
|
2921
|
+
return _context18.abrupt("return", tempOrder.products);
|
|
2922
|
+
case 18:
|
|
2923
|
+
_context18.next = 20;
|
|
2924
|
+
return this.appendProductLineToTempOrder(tempOrder, product, booking);
|
|
2925
|
+
case 20:
|
|
2926
|
+
_context18.next = 22;
|
|
2927
|
+
return this.finalizeProductOrderMutation(tempOrder);
|
|
2928
|
+
case 22:
|
|
2929
|
+
return _context18.abrupt("return", tempOrder.products);
|
|
2822
2930
|
case 23:
|
|
2823
|
-
_context16.next = 25;
|
|
2824
|
-
return this.applyPromotion();
|
|
2825
|
-
case 25:
|
|
2826
|
-
this.applyDiscount();
|
|
2827
|
-
this.sanitizeTempOrderProducts(tempOrder);
|
|
2828
|
-
_context16.next = 29;
|
|
2829
|
-
return this.recalculateSummary({
|
|
2830
|
-
createIfMissing: true
|
|
2831
|
-
});
|
|
2832
|
-
case 29:
|
|
2833
|
-
this.persistTempOrder();
|
|
2834
|
-
return _context16.abrupt("return", tempOrder.products);
|
|
2835
|
-
case 31:
|
|
2836
2931
|
case "end":
|
|
2837
|
-
return
|
|
2932
|
+
return _context18.stop();
|
|
2838
2933
|
}
|
|
2839
|
-
},
|
|
2934
|
+
}, _callee16, this);
|
|
2840
2935
|
}));
|
|
2841
|
-
function addProductToOrder(
|
|
2936
|
+
function addProductToOrder(_x18, _x19) {
|
|
2842
2937
|
return _addProductToOrder.apply(this, arguments);
|
|
2843
2938
|
}
|
|
2844
2939
|
return addProductToOrder;
|
|
2845
|
-
}()
|
|
2940
|
+
}())
|
|
2846
2941
|
}, {
|
|
2847
2942
|
key: "hasGoodPassDiscount",
|
|
2848
2943
|
value: function hasGoodPassDiscount(product) {
|
|
@@ -2865,9 +2960,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2865
2960
|
}, {
|
|
2866
2961
|
key: "getBundleRuntimeIdentity",
|
|
2867
2962
|
value: function getBundleRuntimeIdentity(bundle) {
|
|
2868
|
-
var
|
|
2963
|
+
var _ref59, _bundle$bundle_id2, _ref60, _bundle$bundle_group_2, _ref61, _ref62, _bundle$bundle_produc3, _ref63, _bundle$bundle_varian3;
|
|
2869
2964
|
if (!bundle || _typeof(bundle) !== 'object') return '';
|
|
2870
|
-
return [(
|
|
2965
|
+
return [(_ref59 = (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id) !== null && _ref59 !== void 0 ? _ref59 : '', (_ref60 = (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id) !== null && _ref60 !== void 0 ? _ref60 : '', (_ref61 = (_ref62 = (_bundle$bundle_produc3 = bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle._bundle_product_id) !== null && _ref62 !== void 0 ? _ref62 : bundle.product_id) !== null && _ref61 !== void 0 ? _ref61 : '', (_ref63 = (_bundle$bundle_varian3 = bundle.bundle_variant_id) !== null && _bundle$bundle_varian3 !== void 0 ? _bundle$bundle_varian3 : bundle.product_variant_id) !== null && _ref63 !== void 0 ? _ref63 : 0].join('|');
|
|
2871
2966
|
}
|
|
2872
2967
|
}, {
|
|
2873
2968
|
key: "preservePersistedBundlePriceFields",
|
|
@@ -2897,11 +2992,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2897
2992
|
}, {
|
|
2898
2993
|
key: "updateOrderProduct",
|
|
2899
2994
|
value: function () {
|
|
2900
|
-
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2995
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params) {
|
|
2901
2996
|
var _targetProduct$metada2, _product_sku, _metadata, _metadata2, _metadata3, _metadata4, _metadata5, _metadata6, _nextProduct$metadata, _targetProduct$metada8, _tempOrder$products$p;
|
|
2902
2997
|
var product_id, product_variant_id, updates, unique_identification_number, identity_key, product_sku, product_bundle, booking, tempOrder, identityLookup, productIndex, targetUid, targetProduct, nextProduct, callerUpdatesTopPrice, callerUpdatesMainMeta, isPersistedOrderLine, callerChangesDiscountList, callerUpdatesManualPrice, _targetProduct$metada3, _targetProduct$metada4, _targetProduct$metada5, _targetProduct$metada6, _targetProduct$metada7, existedMeta, normalizedProduct, preservedBookingUid, _normalizedProduct$me, _targetProduct$metada9, productUid, linked;
|
|
2903
|
-
return _regeneratorRuntime().wrap(function
|
|
2904
|
-
while (1) switch (
|
|
2998
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context19) {
|
|
2999
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
2905
3000
|
case 0:
|
|
2906
3001
|
product_id = params.product_id, product_variant_id = params.product_variant_id, updates = params.updates, unique_identification_number = params.unique_identification_number, identity_key = params.identity_key, product_sku = params.product_sku, product_bundle = params.product_bundle, booking = params.booking;
|
|
2907
3002
|
tempOrder = this.ensureTempOrder();
|
|
@@ -2932,7 +3027,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2932
3027
|
productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
|
|
2933
3028
|
}
|
|
2934
3029
|
if (!(productIndex === -1)) {
|
|
2935
|
-
|
|
3030
|
+
_context19.next = 12;
|
|
2936
3031
|
break;
|
|
2937
3032
|
}
|
|
2938
3033
|
throw new Error('[Order] 目标商品不存在,无法更新');
|
|
@@ -3015,25 +3110,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3015
3110
|
}
|
|
3016
3111
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
3017
3112
|
this.captureProductRuntime(tempOrder, updates, tempOrder.products[productIndex], (_tempOrder$products$p = tempOrder.products[productIndex].metadata) === null || _tempOrder$products$p === void 0 ? void 0 : _tempOrder$products$p.unique_identification_number);
|
|
3018
|
-
|
|
3113
|
+
_context19.next = 30;
|
|
3019
3114
|
return this.applyPromotion();
|
|
3020
3115
|
case 30:
|
|
3021
3116
|
this.applyDiscount();
|
|
3022
3117
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
3023
|
-
|
|
3118
|
+
_context19.next = 34;
|
|
3024
3119
|
return this.recalculateSummary({
|
|
3025
3120
|
createIfMissing: true
|
|
3026
3121
|
});
|
|
3027
3122
|
case 34:
|
|
3028
3123
|
this.persistTempOrder();
|
|
3029
|
-
return
|
|
3124
|
+
return _context19.abrupt("return", tempOrder.products);
|
|
3030
3125
|
case 36:
|
|
3031
3126
|
case "end":
|
|
3032
|
-
return
|
|
3127
|
+
return _context19.stop();
|
|
3033
3128
|
}
|
|
3034
|
-
},
|
|
3129
|
+
}, _callee17, this);
|
|
3035
3130
|
}));
|
|
3036
|
-
function updateOrderProduct(
|
|
3131
|
+
function updateOrderProduct(_x20) {
|
|
3037
3132
|
return _updateOrderProduct.apply(this, arguments);
|
|
3038
3133
|
}
|
|
3039
3134
|
return updateOrderProduct;
|
|
@@ -3041,11 +3136,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3041
3136
|
}, {
|
|
3042
3137
|
key: "updateOrderProductQuantity",
|
|
3043
3138
|
value: function () {
|
|
3044
|
-
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3139
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(params) {
|
|
3045
3140
|
var _targetProduct$metada10;
|
|
3046
3141
|
var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct;
|
|
3047
|
-
return _regeneratorRuntime().wrap(function
|
|
3048
|
-
while (1) switch (
|
|
3142
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context20) {
|
|
3143
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
3049
3144
|
case 0:
|
|
3050
3145
|
product_id = params.product_id, product_variant_id = params.product_variant_id, num = params.num, unique_identification_number = params.unique_identification_number, identity_key = params.identity_key, product_sku = params.product_sku, product_bundle = params.product_bundle;
|
|
3051
3146
|
tempOrder = this.ensureTempOrder();
|
|
@@ -3074,7 +3169,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3074
3169
|
productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
|
|
3075
3170
|
}
|
|
3076
3171
|
if (!(productIndex === -1)) {
|
|
3077
|
-
|
|
3172
|
+
_context20.next = 12;
|
|
3078
3173
|
break;
|
|
3079
3174
|
}
|
|
3080
3175
|
throw new Error('[Order] 目标商品不存在,无法更新数量');
|
|
@@ -3088,25 +3183,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3088
3183
|
}));
|
|
3089
3184
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
3090
3185
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
3091
|
-
|
|
3186
|
+
_context20.next = 18;
|
|
3092
3187
|
return this.applyPromotion();
|
|
3093
3188
|
case 18:
|
|
3094
3189
|
this.applyDiscount();
|
|
3095
3190
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
3096
|
-
|
|
3191
|
+
_context20.next = 22;
|
|
3097
3192
|
return this.recalculateSummary({
|
|
3098
3193
|
createIfMissing: true
|
|
3099
3194
|
});
|
|
3100
3195
|
case 22:
|
|
3101
3196
|
this.persistTempOrder();
|
|
3102
|
-
return
|
|
3197
|
+
return _context20.abrupt("return", tempOrder.products);
|
|
3103
3198
|
case 24:
|
|
3104
3199
|
case "end":
|
|
3105
|
-
return
|
|
3200
|
+
return _context20.stop();
|
|
3106
3201
|
}
|
|
3107
|
-
},
|
|
3202
|
+
}, _callee18, this);
|
|
3108
3203
|
}));
|
|
3109
|
-
function updateOrderProductQuantity(
|
|
3204
|
+
function updateOrderProductQuantity(_x21) {
|
|
3110
3205
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
3111
3206
|
}
|
|
3112
3207
|
return updateOrderProductQuantity;
|
|
@@ -3134,18 +3229,70 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3134
3229
|
this.persistTempOrder();
|
|
3135
3230
|
return tempOrder.bookings;
|
|
3136
3231
|
}
|
|
3232
|
+
|
|
3233
|
+
/**
|
|
3234
|
+
* 商品行写路径收尾:促销 → 折扣 → 清洗 → summary → 持久化。
|
|
3235
|
+
* 批量删除等多行变更场景只应调用一次,避免 N 次 applyPromotion。
|
|
3236
|
+
*
|
|
3237
|
+
* @example
|
|
3238
|
+
* await this.finalizeAfterProductsMutation(tempOrder);
|
|
3239
|
+
*/
|
|
3137
3240
|
}, {
|
|
3138
|
-
key: "
|
|
3139
|
-
value: function () {
|
|
3140
|
-
var
|
|
3241
|
+
key: "finalizeAfterProductsMutation",
|
|
3242
|
+
value: (function () {
|
|
3243
|
+
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(tempOrder) {
|
|
3244
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context21) {
|
|
3245
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
3246
|
+
case 0:
|
|
3247
|
+
_context21.next = 2;
|
|
3248
|
+
return this.applyPromotion();
|
|
3249
|
+
case 2:
|
|
3250
|
+
this.applyDiscount();
|
|
3251
|
+
this.sanitizeTempOrderProducts(tempOrder);
|
|
3252
|
+
_context21.next = 6;
|
|
3253
|
+
return this.recalculateSummary({
|
|
3254
|
+
createIfMissing: true
|
|
3255
|
+
});
|
|
3256
|
+
case 6:
|
|
3257
|
+
this.persistTempOrder();
|
|
3258
|
+
case 7:
|
|
3259
|
+
case "end":
|
|
3260
|
+
return _context21.stop();
|
|
3261
|
+
}
|
|
3262
|
+
}, _callee19, this);
|
|
3263
|
+
}));
|
|
3264
|
+
function finalizeAfterProductsMutation(_x22) {
|
|
3265
|
+
return _finalizeAfterProductsMutation.apply(this, arguments);
|
|
3266
|
+
}
|
|
3267
|
+
return finalizeAfterProductsMutation;
|
|
3268
|
+
}()
|
|
3269
|
+
/**
|
|
3270
|
+
* 批量按 identity 删除购物车行,末尾仅一次促销重算。
|
|
3271
|
+
*
|
|
3272
|
+
* @example
|
|
3273
|
+
* await order.removeProductsFromOrder([identityA, identityB]);
|
|
3274
|
+
*/
|
|
3275
|
+
)
|
|
3276
|
+
}, {
|
|
3277
|
+
key: "removeProductsFromOrder",
|
|
3278
|
+
value: (function () {
|
|
3279
|
+
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(identities) {
|
|
3141
3280
|
var tempOrder, removedProducts, _i, _removedProducts, product;
|
|
3142
|
-
return _regeneratorRuntime().wrap(function
|
|
3143
|
-
while (1) switch (
|
|
3281
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context22) {
|
|
3282
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
3144
3283
|
case 0:
|
|
3145
3284
|
tempOrder = this.ensureTempOrder();
|
|
3285
|
+
if (identities.length) {
|
|
3286
|
+
_context22.next = 3;
|
|
3287
|
+
break;
|
|
3288
|
+
}
|
|
3289
|
+
return _context22.abrupt("return", tempOrder.products);
|
|
3290
|
+
case 3:
|
|
3146
3291
|
removedProducts = [];
|
|
3147
3292
|
tempOrder.products = tempOrder.products.filter(function (item) {
|
|
3148
|
-
var shouldRemove =
|
|
3293
|
+
var shouldRemove = identities.some(function (identity) {
|
|
3294
|
+
return isIdentityMatch(item, identity);
|
|
3295
|
+
});
|
|
3149
3296
|
if (shouldRemove) removedProducts.push(item);
|
|
3150
3297
|
return !shouldRemove;
|
|
3151
3298
|
});
|
|
@@ -3153,25 +3300,36 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3153
3300
|
product = _removedProducts[_i];
|
|
3154
3301
|
this.removeLinkedBookingsForProduct(tempOrder, product);
|
|
3155
3302
|
}
|
|
3156
|
-
|
|
3157
|
-
return this.
|
|
3158
|
-
case
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
_context19.next = 10;
|
|
3162
|
-
return this.recalculateSummary({
|
|
3163
|
-
createIfMissing: true
|
|
3164
|
-
});
|
|
3165
|
-
case 10:
|
|
3166
|
-
this.persistTempOrder();
|
|
3167
|
-
return _context19.abrupt("return", tempOrder.products);
|
|
3168
|
-
case 12:
|
|
3303
|
+
_context22.next = 8;
|
|
3304
|
+
return this.finalizeAfterProductsMutation(tempOrder);
|
|
3305
|
+
case 8:
|
|
3306
|
+
return _context22.abrupt("return", tempOrder.products);
|
|
3307
|
+
case 9:
|
|
3169
3308
|
case "end":
|
|
3170
|
-
return
|
|
3309
|
+
return _context22.stop();
|
|
3171
3310
|
}
|
|
3172
|
-
},
|
|
3311
|
+
}, _callee20, this);
|
|
3173
3312
|
}));
|
|
3174
|
-
function
|
|
3313
|
+
function removeProductsFromOrder(_x23) {
|
|
3314
|
+
return _removeProductsFromOrder.apply(this, arguments);
|
|
3315
|
+
}
|
|
3316
|
+
return removeProductsFromOrder;
|
|
3317
|
+
}())
|
|
3318
|
+
}, {
|
|
3319
|
+
key: "removeProductFromOrder",
|
|
3320
|
+
value: function () {
|
|
3321
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(identity) {
|
|
3322
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context23) {
|
|
3323
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
3324
|
+
case 0:
|
|
3325
|
+
return _context23.abrupt("return", this.removeProductsFromOrder([identity]));
|
|
3326
|
+
case 1:
|
|
3327
|
+
case "end":
|
|
3328
|
+
return _context23.stop();
|
|
3329
|
+
}
|
|
3330
|
+
}, _callee21, this);
|
|
3331
|
+
}));
|
|
3332
|
+
function removeProductFromOrder(_x24) {
|
|
3175
3333
|
return _removeProductFromOrder.apply(this, arguments);
|
|
3176
3334
|
}
|
|
3177
3335
|
return removeProductFromOrder;
|
|
@@ -3183,10 +3341,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3183
3341
|
}, {
|
|
3184
3342
|
key: "clearOrderCartLines",
|
|
3185
3343
|
value: (function () {
|
|
3186
|
-
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3344
|
+
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
|
|
3187
3345
|
var tempOrder;
|
|
3188
|
-
return _regeneratorRuntime().wrap(function
|
|
3189
|
-
while (1) switch (
|
|
3346
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context24) {
|
|
3347
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
3190
3348
|
case 0:
|
|
3191
3349
|
tempOrder = this.ensureTempOrder();
|
|
3192
3350
|
tempOrder.products = [];
|
|
@@ -3196,23 +3354,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3196
3354
|
productsByUid: {}
|
|
3197
3355
|
});
|
|
3198
3356
|
}
|
|
3199
|
-
|
|
3357
|
+
_context24.next = 6;
|
|
3200
3358
|
return this.applyPromotion();
|
|
3201
3359
|
case 6:
|
|
3202
3360
|
this.applyDiscount();
|
|
3203
3361
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
3204
|
-
|
|
3362
|
+
_context24.next = 10;
|
|
3205
3363
|
return this.recalculateSummary({
|
|
3206
3364
|
createIfMissing: true
|
|
3207
3365
|
});
|
|
3208
3366
|
case 10:
|
|
3209
3367
|
this.persistTempOrder();
|
|
3210
|
-
return
|
|
3368
|
+
return _context24.abrupt("return", tempOrder);
|
|
3211
3369
|
case 12:
|
|
3212
3370
|
case "end":
|
|
3213
|
-
return
|
|
3371
|
+
return _context24.stop();
|
|
3214
3372
|
}
|
|
3215
|
-
},
|
|
3373
|
+
}, _callee22, this);
|
|
3216
3374
|
}));
|
|
3217
3375
|
function clearOrderCartLines() {
|
|
3218
3376
|
return _clearOrderCartLines.apply(this, arguments);
|
|
@@ -3229,11 +3387,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3229
3387
|
}, {
|
|
3230
3388
|
key: "submitTempOrder",
|
|
3231
3389
|
value: function () {
|
|
3232
|
-
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3233
|
-
var _params$cacheId, _this$otherParams,
|
|
3390
|
+
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
|
|
3391
|
+
var _params$cacheId, _this$otherParams, _ref64, _params$businessCode, _this$otherParams2, _this$otherParams3;
|
|
3234
3392
|
var tempOrder, effectiveCacheId, hasPaymentOverride, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
|
|
3235
|
-
return _regeneratorRuntime().wrap(function
|
|
3236
|
-
while (1) switch (
|
|
3393
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context25) {
|
|
3394
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
3237
3395
|
case 0:
|
|
3238
3396
|
tempOrder = this.ensureTempOrder();
|
|
3239
3397
|
this.persistTempOrder();
|
|
@@ -3256,16 +3414,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3256
3414
|
tempOrder: tempOrder,
|
|
3257
3415
|
cacheId: effectiveCacheId,
|
|
3258
3416
|
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.platform),
|
|
3259
|
-
businessCode: (
|
|
3417
|
+
businessCode: (_ref64 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.businessCode) !== null && _ref64 !== void 0 ? _ref64 : (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.business_code,
|
|
3260
3418
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
3261
3419
|
type: params === null || params === void 0 ? void 0 : params.type,
|
|
3262
3420
|
enhance: enhancePayload
|
|
3263
3421
|
}); // TODO: 前端生成的时间现在是有问题的,后面要统一优化
|
|
3264
3422
|
payload.created_at = undefined;
|
|
3265
|
-
|
|
3423
|
+
_context25.next = 11;
|
|
3266
3424
|
return this.saveDraft();
|
|
3267
3425
|
case 11:
|
|
3268
|
-
|
|
3426
|
+
_context25.prev = 11;
|
|
3269
3427
|
this.logInfo('submitTempOrder calling sales checkout', {
|
|
3270
3428
|
orderId: payload.order_id,
|
|
3271
3429
|
externalSaleNumber: payload.external_sale_number,
|
|
@@ -3274,62 +3432,62 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3274
3432
|
paymentsCount: ((_payload$payments = payload.payments) === null || _payload$payments === void 0 ? void 0 : _payload$payments.length) || 0,
|
|
3275
3433
|
smallTicketDataFlag: payload.small_ticket_data_flag
|
|
3276
3434
|
});
|
|
3277
|
-
|
|
3435
|
+
_context25.next = 15;
|
|
3278
3436
|
return this.submitSalesOrder({
|
|
3279
3437
|
query: payload
|
|
3280
3438
|
});
|
|
3281
3439
|
case 15:
|
|
3282
|
-
result =
|
|
3283
|
-
|
|
3440
|
+
result = _context25.sent;
|
|
3441
|
+
_context25.next = 28;
|
|
3284
3442
|
break;
|
|
3285
3443
|
case 18:
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
backendErrorResponse = this.extractSubmitErrorResponse(
|
|
3444
|
+
_context25.prev = 18;
|
|
3445
|
+
_context25.t0 = _context25["catch"](11);
|
|
3446
|
+
backendErrorResponse = this.extractSubmitErrorResponse(_context25.t0);
|
|
3289
3447
|
if (!backendErrorResponse) {
|
|
3290
|
-
|
|
3448
|
+
_context25.next = 25;
|
|
3291
3449
|
break;
|
|
3292
3450
|
}
|
|
3293
3451
|
this.store.syncState = 'failed';
|
|
3294
3452
|
this.logSubmitBackendRejected(backendErrorResponse, payload);
|
|
3295
|
-
return
|
|
3453
|
+
return _context25.abrupt("return", backendErrorResponse);
|
|
3296
3454
|
case 25:
|
|
3297
3455
|
this.store.syncState = 'failed';
|
|
3298
3456
|
this.logError('submitTempOrder failed', {
|
|
3299
|
-
error:
|
|
3457
|
+
error: _context25.t0 instanceof Error ? _context25.t0.message : String(_context25.t0),
|
|
3300
3458
|
orderId: payload.order_id,
|
|
3301
3459
|
externalSaleNumber: payload.external_sale_number,
|
|
3302
3460
|
paymentStatus: payload.payment_status,
|
|
3303
3461
|
paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
|
|
3304
3462
|
});
|
|
3305
|
-
throw
|
|
3463
|
+
throw _context25.t0;
|
|
3306
3464
|
case 28:
|
|
3307
3465
|
if (!this.isSubmitResponseRejected(result)) {
|
|
3308
|
-
|
|
3466
|
+
_context25.next = 32;
|
|
3309
3467
|
break;
|
|
3310
3468
|
}
|
|
3311
3469
|
this.store.syncState = 'failed';
|
|
3312
3470
|
this.logSubmitBackendRejected(result, payload);
|
|
3313
|
-
return
|
|
3471
|
+
return _context25.abrupt("return", result);
|
|
3314
3472
|
case 32:
|
|
3315
3473
|
submittedOrderId = this.extractOrderIdFromSubmitResult(result);
|
|
3316
3474
|
if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
|
|
3317
|
-
|
|
3475
|
+
_context25.next = 38;
|
|
3318
3476
|
break;
|
|
3319
3477
|
}
|
|
3320
3478
|
tempOrder.order_id = submittedOrderId;
|
|
3321
3479
|
resultRecord = result;
|
|
3322
|
-
|
|
3480
|
+
_context25.next = 38;
|
|
3323
3481
|
return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
|
|
3324
3482
|
case 38:
|
|
3325
|
-
return
|
|
3483
|
+
return _context25.abrupt("return", result);
|
|
3326
3484
|
case 39:
|
|
3327
3485
|
case "end":
|
|
3328
|
-
return
|
|
3486
|
+
return _context25.stop();
|
|
3329
3487
|
}
|
|
3330
|
-
},
|
|
3488
|
+
}, _callee23, this, [[11, 18]]);
|
|
3331
3489
|
}));
|
|
3332
|
-
function submitTempOrder(
|
|
3490
|
+
function submitTempOrder(_x25) {
|
|
3333
3491
|
return _submitTempOrder.apply(this, arguments);
|
|
3334
3492
|
}
|
|
3335
3493
|
return submitTempOrder;
|
|
@@ -3337,25 +3495,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3337
3495
|
}, {
|
|
3338
3496
|
key: "markLocalOrderSynced",
|
|
3339
3497
|
value: function () {
|
|
3340
|
-
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3498
|
+
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(orderId, remoteOrder) {
|
|
3341
3499
|
var tempOrder;
|
|
3342
|
-
return _regeneratorRuntime().wrap(function
|
|
3343
|
-
while (1) switch (
|
|
3500
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context26) {
|
|
3501
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
3344
3502
|
case 0:
|
|
3345
3503
|
tempOrder = this.ensureTempOrder();
|
|
3346
3504
|
tempOrder.order_id = orderId;
|
|
3347
3505
|
this.store.lastOrderInfo = remoteOrder;
|
|
3348
3506
|
this.store.syncState = 'submitted';
|
|
3349
3507
|
this.persistTempOrder();
|
|
3350
|
-
|
|
3508
|
+
_context26.next = 7;
|
|
3351
3509
|
return this.saveDraft();
|
|
3352
3510
|
case 7:
|
|
3353
3511
|
case "end":
|
|
3354
|
-
return
|
|
3512
|
+
return _context26.stop();
|
|
3355
3513
|
}
|
|
3356
|
-
},
|
|
3514
|
+
}, _callee24, this);
|
|
3357
3515
|
}));
|
|
3358
|
-
function markLocalOrderSynced(
|
|
3516
|
+
function markLocalOrderSynced(_x26, _x27) {
|
|
3359
3517
|
return _markLocalOrderSynced.apply(this, arguments);
|
|
3360
3518
|
}
|
|
3361
3519
|
return markLocalOrderSynced;
|
|
@@ -3402,10 +3560,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3402
3560
|
}, {
|
|
3403
3561
|
key: "syncPaymentsToOrder",
|
|
3404
3562
|
value: function () {
|
|
3405
|
-
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3563
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
|
|
3406
3564
|
var tempOrder, mappedPayments, paymentTotal, targetAmount, isFullyPaid, paymentStatus, paymentSyncIdempotencyToken, submitResult;
|
|
3407
|
-
return _regeneratorRuntime().wrap(function
|
|
3408
|
-
while (1) switch (
|
|
3565
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context27) {
|
|
3566
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
3409
3567
|
case 0:
|
|
3410
3568
|
tempOrder = this.ensureTempOrder();
|
|
3411
3569
|
mappedPayments = mapPaymentItemsToOrderPayments(params.payments || []);
|
|
@@ -3416,28 +3574,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3416
3574
|
tempOrder.payments = mappedPayments;
|
|
3417
3575
|
tempOrder.payment_status = paymentStatus;
|
|
3418
3576
|
this.persistTempOrder();
|
|
3419
|
-
|
|
3577
|
+
_context27.next = 11;
|
|
3420
3578
|
return this.saveDraft();
|
|
3421
3579
|
case 11:
|
|
3422
3580
|
if (params.submitWhenPaid) {
|
|
3423
|
-
|
|
3581
|
+
_context27.next = 13;
|
|
3424
3582
|
break;
|
|
3425
3583
|
}
|
|
3426
|
-
return
|
|
3584
|
+
return _context27.abrupt("return", {
|
|
3427
3585
|
isFullyPaid: isFullyPaid
|
|
3428
3586
|
});
|
|
3429
3587
|
case 13:
|
|
3430
3588
|
if (!(this.store.syncState === 'submitting')) {
|
|
3431
|
-
|
|
3589
|
+
_context27.next = 15;
|
|
3432
3590
|
break;
|
|
3433
3591
|
}
|
|
3434
|
-
return
|
|
3592
|
+
return _context27.abrupt("return", {
|
|
3435
3593
|
isFullyPaid: isFullyPaid
|
|
3436
3594
|
});
|
|
3437
3595
|
case 15:
|
|
3438
3596
|
this.store.syncState = 'submitting';
|
|
3439
3597
|
paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, mappedPayments);
|
|
3440
|
-
|
|
3598
|
+
_context27.next = 19;
|
|
3441
3599
|
return this.submitTempOrder({
|
|
3442
3600
|
payments: mappedPayments,
|
|
3443
3601
|
paymentStatus: paymentStatus,
|
|
@@ -3452,18 +3610,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3452
3610
|
}
|
|
3453
3611
|
});
|
|
3454
3612
|
case 19:
|
|
3455
|
-
submitResult =
|
|
3456
|
-
return
|
|
3613
|
+
submitResult = _context27.sent;
|
|
3614
|
+
return _context27.abrupt("return", {
|
|
3457
3615
|
isFullyPaid: isFullyPaid,
|
|
3458
3616
|
submitResult: submitResult
|
|
3459
3617
|
});
|
|
3460
3618
|
case 21:
|
|
3461
3619
|
case "end":
|
|
3462
|
-
return
|
|
3620
|
+
return _context27.stop();
|
|
3463
3621
|
}
|
|
3464
|
-
},
|
|
3622
|
+
}, _callee25, this);
|
|
3465
3623
|
}));
|
|
3466
|
-
function syncPaymentsToOrder(
|
|
3624
|
+
function syncPaymentsToOrder(_x28) {
|
|
3467
3625
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
3468
3626
|
}
|
|
3469
3627
|
return syncPaymentsToOrder;
|
|
@@ -3552,11 +3710,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3552
3710
|
}, {
|
|
3553
3711
|
key: "submitOrder",
|
|
3554
3712
|
value: function () {
|
|
3555
|
-
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3713
|
+
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(order) {
|
|
3556
3714
|
var _order$query$cartItem, _params$bookings, _params$relation_prod;
|
|
3557
3715
|
var url, query, fetchUrl, params;
|
|
3558
|
-
return _regeneratorRuntime().wrap(function
|
|
3559
|
-
while (1) switch (
|
|
3716
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context28) {
|
|
3717
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
3560
3718
|
case 0:
|
|
3561
3719
|
this.logInfo('submitOrder called', {
|
|
3562
3720
|
url: order.url,
|
|
@@ -3576,14 +3734,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3576
3734
|
relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
|
|
3577
3735
|
scheduleDate: params.schedule_date
|
|
3578
3736
|
});
|
|
3579
|
-
return
|
|
3737
|
+
return _context28.abrupt("return", this.request.post(fetchUrl, params));
|
|
3580
3738
|
case 6:
|
|
3581
3739
|
case "end":
|
|
3582
|
-
return
|
|
3740
|
+
return _context28.stop();
|
|
3583
3741
|
}
|
|
3584
|
-
},
|
|
3742
|
+
}, _callee26, this);
|
|
3585
3743
|
}));
|
|
3586
|
-
function submitOrder(
|
|
3744
|
+
function submitOrder(_x29) {
|
|
3587
3745
|
return _submitOrder.apply(this, arguments);
|
|
3588
3746
|
}
|
|
3589
3747
|
return submitOrder;
|
|
@@ -3591,13 +3749,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3591
3749
|
}, {
|
|
3592
3750
|
key: "cancelOrder",
|
|
3593
3751
|
value: function () {
|
|
3594
|
-
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3752
|
+
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
|
|
3595
3753
|
var payload;
|
|
3596
|
-
return _regeneratorRuntime().wrap(function
|
|
3597
|
-
while (1) switch (
|
|
3754
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context29) {
|
|
3755
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
3598
3756
|
case 0:
|
|
3599
3757
|
if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
|
|
3600
|
-
|
|
3758
|
+
_context29.next = 2;
|
|
3601
3759
|
break;
|
|
3602
3760
|
}
|
|
3603
3761
|
throw new Error('取消订单失败:order_ids 不能为空');
|
|
@@ -3613,16 +3771,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3613
3771
|
method: 'PUT',
|
|
3614
3772
|
orderIdsCount: params.order_ids.length
|
|
3615
3773
|
});
|
|
3616
|
-
return
|
|
3774
|
+
return _context29.abrupt("return", this.request.put('/order/update-status', payload, {
|
|
3617
3775
|
isShopApi: true
|
|
3618
3776
|
}));
|
|
3619
3777
|
case 5:
|
|
3620
3778
|
case "end":
|
|
3621
|
-
return
|
|
3779
|
+
return _context29.stop();
|
|
3622
3780
|
}
|
|
3623
|
-
},
|
|
3781
|
+
}, _callee27, this);
|
|
3624
3782
|
}));
|
|
3625
|
-
function cancelOrder(
|
|
3783
|
+
function cancelOrder(_x30) {
|
|
3626
3784
|
return _cancelOrder.apply(this, arguments);
|
|
3627
3785
|
}
|
|
3628
3786
|
return cancelOrder;
|
|
@@ -3630,19 +3788,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3630
3788
|
}, {
|
|
3631
3789
|
key: "changeBookingStatus",
|
|
3632
3790
|
value: function () {
|
|
3633
|
-
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3791
|
+
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
|
|
3634
3792
|
var url, payload;
|
|
3635
|
-
return _regeneratorRuntime().wrap(function
|
|
3636
|
-
while (1) switch (
|
|
3793
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context30) {
|
|
3794
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
3637
3795
|
case 0:
|
|
3638
3796
|
if (params.booking_id) {
|
|
3639
|
-
|
|
3797
|
+
_context30.next = 2;
|
|
3640
3798
|
break;
|
|
3641
3799
|
}
|
|
3642
3800
|
throw new Error('变更预约状态失败:booking_id 不能为空');
|
|
3643
3801
|
case 2:
|
|
3644
3802
|
if (params.appointment_status) {
|
|
3645
|
-
|
|
3803
|
+
_context30.next = 4;
|
|
3646
3804
|
break;
|
|
3647
3805
|
}
|
|
3648
3806
|
throw new Error('变更预约状态失败:appointment_status 不能为空');
|
|
@@ -3657,16 +3815,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3657
3815
|
bookingId: params.booking_id,
|
|
3658
3816
|
appointmentStatus: params.appointment_status
|
|
3659
3817
|
});
|
|
3660
|
-
return
|
|
3818
|
+
return _context30.abrupt("return", this.request.put(url, payload, {
|
|
3661
3819
|
isShopApi: true
|
|
3662
3820
|
}));
|
|
3663
3821
|
case 8:
|
|
3664
3822
|
case "end":
|
|
3665
|
-
return
|
|
3823
|
+
return _context30.stop();
|
|
3666
3824
|
}
|
|
3667
|
-
},
|
|
3825
|
+
}, _callee28, this);
|
|
3668
3826
|
}));
|
|
3669
|
-
function changeBookingStatus(
|
|
3827
|
+
function changeBookingStatus(_x31) {
|
|
3670
3828
|
return _changeBookingStatus.apply(this, arguments);
|
|
3671
3829
|
}
|
|
3672
3830
|
return changeBookingStatus;
|
|
@@ -3684,11 +3842,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3684
3842
|
}, {
|
|
3685
3843
|
key: "createOrderByCheckout",
|
|
3686
3844
|
value: (function () {
|
|
3687
|
-
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3845
|
+
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
|
|
3688
3846
|
var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3, _params$bookings3, _params$relation_prod3, _params$payments4;
|
|
3689
3847
|
var onlineStorePaymentCodeList, _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, _orderData$bookings2, _orderData$relation_p2, _orderData$payments4, _orderData$payments5, _response$data, orderData, response;
|
|
3690
|
-
return _regeneratorRuntime().wrap(function
|
|
3691
|
-
while (1) switch (
|
|
3848
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context31) {
|
|
3849
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
3692
3850
|
case 0:
|
|
3693
3851
|
// 过滤掉由在线店铺下单的 payment 支付数据
|
|
3694
3852
|
onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
|
|
@@ -3722,7 +3880,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3722
3880
|
relationProductsCount: ((_params$relation_prod3 = params.relation_products) === null || _params$relation_prod3 === void 0 ? void 0 : _params$relation_prod3.length) || 0,
|
|
3723
3881
|
paymentsCount: ((_params$payments4 = params.payments) === null || _params$payments4 === void 0 ? void 0 : _params$payments4.length) || 0
|
|
3724
3882
|
});
|
|
3725
|
-
|
|
3883
|
+
_context31.prev = 4;
|
|
3726
3884
|
// 构建订单数据,设置默认值并允许 params 覆盖
|
|
3727
3885
|
orderData = _objectSpread({
|
|
3728
3886
|
sales_channel: 'my_pisel',
|
|
@@ -3784,13 +3942,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3784
3942
|
hasOrderId: !!orderData.order_id,
|
|
3785
3943
|
smallTicketDataFlag: orderData.small_ticket_data_flag
|
|
3786
3944
|
});
|
|
3787
|
-
|
|
3945
|
+
_context31.next = 12;
|
|
3788
3946
|
return this.request.post('/shop/order/checkout', orderData, {
|
|
3789
3947
|
osServer: true,
|
|
3790
3948
|
customToast: function customToast() {}
|
|
3791
3949
|
});
|
|
3792
3950
|
case 12:
|
|
3793
|
-
response =
|
|
3951
|
+
response = _context31.sent;
|
|
3794
3952
|
this.logInfo('Order API called successfully', {
|
|
3795
3953
|
response: response
|
|
3796
3954
|
});
|
|
@@ -3798,22 +3956,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3798
3956
|
success: !!response,
|
|
3799
3957
|
hasOrderId: !!(response !== null && response !== void 0 && (_response$data = response.data) !== null && _response$data !== void 0 && _response$data.order_id || response !== null && response !== void 0 && response.order_id)
|
|
3800
3958
|
});
|
|
3801
|
-
return
|
|
3959
|
+
return _context31.abrupt("return", response);
|
|
3802
3960
|
case 18:
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
console.error('[Order] createOrderByCheckout 创建订单失败:',
|
|
3961
|
+
_context31.prev = 18;
|
|
3962
|
+
_context31.t0 = _context31["catch"](4);
|
|
3963
|
+
console.error('[Order] createOrderByCheckout 创建订单失败:', _context31.t0);
|
|
3806
3964
|
this.logInfo('Order API called failed', {
|
|
3807
|
-
error:
|
|
3965
|
+
error: _context31.t0 instanceof Error ? _context31.t0.message : String(_context31.t0)
|
|
3808
3966
|
});
|
|
3809
|
-
throw
|
|
3967
|
+
throw _context31.t0;
|
|
3810
3968
|
case 23:
|
|
3811
3969
|
case "end":
|
|
3812
|
-
return
|
|
3970
|
+
return _context31.stop();
|
|
3813
3971
|
}
|
|
3814
|
-
},
|
|
3972
|
+
}, _callee29, this, [[4, 18]]);
|
|
3815
3973
|
}));
|
|
3816
|
-
function createOrderByCheckout(
|
|
3974
|
+
function createOrderByCheckout(_x32) {
|
|
3817
3975
|
return _createOrderByCheckout.apply(this, arguments);
|
|
3818
3976
|
}
|
|
3819
3977
|
return createOrderByCheckout;
|
|
@@ -3821,24 +3979,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3821
3979
|
}, {
|
|
3822
3980
|
key: "submitSalesOrder",
|
|
3823
3981
|
value: function () {
|
|
3824
|
-
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3982
|
+
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
|
|
3825
3983
|
var url, query, fetchUrl;
|
|
3826
|
-
return _regeneratorRuntime().wrap(function
|
|
3827
|
-
while (1) switch (
|
|
3984
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context32) {
|
|
3985
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
3828
3986
|
case 0:
|
|
3829
3987
|
url = params.url, query = params.query;
|
|
3830
3988
|
fetchUrl = url || '/order/sales/checkout';
|
|
3831
|
-
return
|
|
3989
|
+
return _context32.abrupt("return", this.request.post(fetchUrl, query, {
|
|
3832
3990
|
osServer: true,
|
|
3833
3991
|
customToast: function customToast() {}
|
|
3834
3992
|
}));
|
|
3835
3993
|
case 3:
|
|
3836
3994
|
case "end":
|
|
3837
|
-
return
|
|
3995
|
+
return _context32.stop();
|
|
3838
3996
|
}
|
|
3839
|
-
},
|
|
3997
|
+
}, _callee30, this);
|
|
3840
3998
|
}));
|
|
3841
|
-
function submitSalesOrder(
|
|
3999
|
+
function submitSalesOrder(_x33) {
|
|
3842
4000
|
return _submitSalesOrder.apply(this, arguments);
|
|
3843
4001
|
}
|
|
3844
4002
|
return submitSalesOrder;
|
|
@@ -3852,37 +4010,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3852
4010
|
}, {
|
|
3853
4011
|
key: "sendCustomerPayLink",
|
|
3854
4012
|
value: (function () {
|
|
3855
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4013
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
|
|
3856
4014
|
var _params$emails;
|
|
3857
4015
|
var orderIds;
|
|
3858
|
-
return _regeneratorRuntime().wrap(function
|
|
3859
|
-
while (1) switch (
|
|
4016
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context33) {
|
|
4017
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
3860
4018
|
case 0:
|
|
3861
4019
|
orderIds = params.order_ids || params.orderIds || [];
|
|
3862
4020
|
if (orderIds.length) {
|
|
3863
|
-
|
|
4021
|
+
_context33.next = 3;
|
|
3864
4022
|
break;
|
|
3865
4023
|
}
|
|
3866
4024
|
throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
|
|
3867
4025
|
case 3:
|
|
3868
4026
|
if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
|
|
3869
|
-
|
|
4027
|
+
_context33.next = 5;
|
|
3870
4028
|
break;
|
|
3871
4029
|
}
|
|
3872
4030
|
throw new Error('发送支付链接需要至少一个邮箱');
|
|
3873
4031
|
case 5:
|
|
3874
|
-
return
|
|
4032
|
+
return _context33.abrupt("return", this.request.post('/order/batch-email', {
|
|
3875
4033
|
order_ids: orderIds,
|
|
3876
4034
|
notify_action: params.notify_action || 'order_payment_reminder',
|
|
3877
4035
|
emails: params.emails
|
|
3878
4036
|
}));
|
|
3879
4037
|
case 6:
|
|
3880
4038
|
case "end":
|
|
3881
|
-
return
|
|
4039
|
+
return _context33.stop();
|
|
3882
4040
|
}
|
|
3883
|
-
},
|
|
4041
|
+
}, _callee31, this);
|
|
3884
4042
|
}));
|
|
3885
|
-
function sendCustomerPayLink(
|
|
4043
|
+
function sendCustomerPayLink(_x34) {
|
|
3886
4044
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
3887
4045
|
}
|
|
3888
4046
|
return sendCustomerPayLink;
|
|
@@ -3890,19 +4048,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3890
4048
|
}, {
|
|
3891
4049
|
key: "getSalesOrderByLookup",
|
|
3892
4050
|
value: function () {
|
|
3893
|
-
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4051
|
+
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
|
|
3894
4052
|
var lookup, res;
|
|
3895
|
-
return _regeneratorRuntime().wrap(function
|
|
3896
|
-
while (1) switch (
|
|
4053
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context34) {
|
|
4054
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
3897
4055
|
case 0:
|
|
3898
4056
|
lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
|
|
3899
4057
|
if (lookup) {
|
|
3900
|
-
|
|
4058
|
+
_context34.next = 3;
|
|
3901
4059
|
break;
|
|
3902
4060
|
}
|
|
3903
4061
|
throw new Error('加载销售详情需要 lookup');
|
|
3904
4062
|
case 3:
|
|
3905
|
-
|
|
4063
|
+
_context34.next = 5;
|
|
3906
4064
|
return this.request.get("/order/sales/".concat(encodeURIComponent(lookup)), _objectSpread({
|
|
3907
4065
|
with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info']
|
|
3908
4066
|
}, params.forceRemote ? {
|
|
@@ -3911,18 +4069,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3911
4069
|
osServer: true
|
|
3912
4070
|
});
|
|
3913
4071
|
case 5:
|
|
3914
|
-
res =
|
|
4072
|
+
res = _context34.sent;
|
|
3915
4073
|
if (res.code === 200) {
|
|
3916
4074
|
this.store.lastOrderInfo = res.data;
|
|
3917
4075
|
}
|
|
3918
|
-
return
|
|
4076
|
+
return _context34.abrupt("return", res);
|
|
3919
4077
|
case 8:
|
|
3920
4078
|
case "end":
|
|
3921
|
-
return
|
|
4079
|
+
return _context34.stop();
|
|
3922
4080
|
}
|
|
3923
|
-
},
|
|
4081
|
+
}, _callee32, this);
|
|
3924
4082
|
}));
|
|
3925
|
-
function getSalesOrderByLookup(
|
|
4083
|
+
function getSalesOrderByLookup(_x35) {
|
|
3926
4084
|
return _getSalesOrderByLookup.apply(this, arguments);
|
|
3927
4085
|
}
|
|
3928
4086
|
return getSalesOrderByLookup;
|
|
@@ -3936,11 +4094,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3936
4094
|
}, {
|
|
3937
4095
|
key: "hydrateTempOrderFromRecord",
|
|
3938
4096
|
value: (function () {
|
|
3939
|
-
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4097
|
+
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(record, options) {
|
|
3940
4098
|
var _this$store$discount13, _this$store$discount14;
|
|
3941
4099
|
var raw, nextTempOrder, rawSummary, summarySurcharges, hydratedEditDiscounts;
|
|
3942
|
-
return _regeneratorRuntime().wrap(function
|
|
3943
|
-
while (1) switch (
|
|
4100
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context35) {
|
|
4101
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
3944
4102
|
case 0:
|
|
3945
4103
|
raw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
|
|
3946
4104
|
nextTempOrder = this.normalizeTempOrderForRuntime(raw);
|
|
@@ -3963,30 +4121,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3963
4121
|
});
|
|
3964
4122
|
this.store.lastOrderInfo = raw.lastOrderInfo || raw;
|
|
3965
4123
|
hydratedEditDiscounts = this.collectHydratedEditDiscounts(nextTempOrder.products);
|
|
3966
|
-
|
|
4124
|
+
_context35.next = 11;
|
|
3967
4125
|
return (_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.setOriginalDiscountList(hydratedEditDiscounts);
|
|
3968
4126
|
case 11:
|
|
3969
|
-
|
|
4127
|
+
_context35.next = 13;
|
|
3970
4128
|
return (_this$store$discount14 = this.store.discount) === null || _this$store$discount14 === void 0 ? void 0 : _this$store$discount14.setDiscountList(hydratedEditDiscounts);
|
|
3971
4129
|
case 13:
|
|
3972
4130
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
3973
|
-
|
|
4131
|
+
_context35.next = 16;
|
|
3974
4132
|
break;
|
|
3975
4133
|
}
|
|
3976
|
-
|
|
4134
|
+
_context35.next = 16;
|
|
3977
4135
|
return this.recalculateSummary({
|
|
3978
4136
|
createIfMissing: false
|
|
3979
4137
|
});
|
|
3980
4138
|
case 16:
|
|
3981
4139
|
this.persistTempOrder();
|
|
3982
|
-
return
|
|
4140
|
+
return _context35.abrupt("return", nextTempOrder);
|
|
3983
4141
|
case 18:
|
|
3984
4142
|
case "end":
|
|
3985
|
-
return
|
|
4143
|
+
return _context35.stop();
|
|
3986
4144
|
}
|
|
3987
|
-
},
|
|
4145
|
+
}, _callee33, this);
|
|
3988
4146
|
}));
|
|
3989
|
-
function hydrateTempOrderFromRecord(
|
|
4147
|
+
function hydrateTempOrderFromRecord(_x36, _x37) {
|
|
3990
4148
|
return _hydrateTempOrderFromRecord.apply(this, arguments);
|
|
3991
4149
|
}
|
|
3992
4150
|
return hydrateTempOrderFromRecord;
|
|
@@ -4045,7 +4203,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4045
4203
|
_step18;
|
|
4046
4204
|
try {
|
|
4047
4205
|
for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
|
|
4048
|
-
var _product$metadata7,
|
|
4206
|
+
var _product$metadata7, _ref65, _ref66, _existed$origin, _rawProduct$metadata;
|
|
4049
4207
|
var _step18$value = _slicedToArray(_step18.value, 2),
|
|
4050
4208
|
index = _step18$value[0],
|
|
4051
4209
|
product = _step18$value[1];
|
|
@@ -4053,7 +4211,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4053
4211
|
if (!uid) continue;
|
|
4054
4212
|
var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
|
|
4055
4213
|
var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
|
|
4056
|
-
var origin = (
|
|
4214
|
+
var origin = (_ref65 = (_ref66 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref66 !== void 0 ? _ref66 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref65 !== void 0 ? _ref65 : rawProduct;
|
|
4057
4215
|
var originSnapshot = cloneDeep(origin);
|
|
4058
4216
|
var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
|
|
4059
4217
|
if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
|
|
@@ -4121,10 +4279,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4121
4279
|
}, {
|
|
4122
4280
|
key: "normalizeHydratedProductOptionItem",
|
|
4123
4281
|
value: function normalizeHydratedProductOptionItem(optionItem) {
|
|
4124
|
-
var
|
|
4125
|
-
var rawNum = (
|
|
4282
|
+
var _ref67, _optionItem$num, _ref68, _optionItem$add_price;
|
|
4283
|
+
var rawNum = (_ref67 = (_optionItem$num = optionItem === null || optionItem === void 0 ? void 0 : optionItem.num) !== null && _optionItem$num !== void 0 ? _optionItem$num : optionItem === null || optionItem === void 0 ? void 0 : optionItem.quantity) !== null && _ref67 !== void 0 ? _ref67 : 1;
|
|
4126
4284
|
var parsedNum = Number(rawNum);
|
|
4127
|
-
var rawPrice = (
|
|
4285
|
+
var rawPrice = (_ref68 = (_optionItem$add_price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _optionItem$add_price !== void 0 ? _optionItem$add_price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _ref68 !== void 0 ? _ref68 : 0;
|
|
4128
4286
|
var parsedPrice = Number(rawPrice);
|
|
4129
4287
|
var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
|
|
4130
4288
|
option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
|
|
@@ -4180,25 +4338,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4180
4338
|
}, {
|
|
4181
4339
|
key: "getOrderInfo",
|
|
4182
4340
|
value: function () {
|
|
4183
|
-
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4341
|
+
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(order_id) {
|
|
4184
4342
|
var res;
|
|
4185
|
-
return _regeneratorRuntime().wrap(function
|
|
4186
|
-
while (1) switch (
|
|
4343
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context36) {
|
|
4344
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
4187
4345
|
case 0:
|
|
4188
|
-
|
|
4346
|
+
_context36.next = 2;
|
|
4189
4347
|
return this.request.get("/order/sales/".concat(order_id), {
|
|
4190
4348
|
with: ['products', 'bookings']
|
|
4191
4349
|
});
|
|
4192
4350
|
case 2:
|
|
4193
|
-
res =
|
|
4194
|
-
return
|
|
4351
|
+
res = _context36.sent;
|
|
4352
|
+
return _context36.abrupt("return", res);
|
|
4195
4353
|
case 4:
|
|
4196
4354
|
case "end":
|
|
4197
|
-
return
|
|
4355
|
+
return _context36.stop();
|
|
4198
4356
|
}
|
|
4199
|
-
},
|
|
4357
|
+
}, _callee34, this);
|
|
4200
4358
|
}));
|
|
4201
|
-
function getOrderInfo(
|
|
4359
|
+
function getOrderInfo(_x38) {
|
|
4202
4360
|
return _getOrderInfo.apply(this, arguments);
|
|
4203
4361
|
}
|
|
4204
4362
|
return getOrderInfo;
|
|
@@ -4237,9 +4395,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4237
4395
|
_step23;
|
|
4238
4396
|
try {
|
|
4239
4397
|
for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {
|
|
4240
|
-
var
|
|
4398
|
+
var _ref69, _bundle$num3;
|
|
4241
4399
|
var bundle = _step23.value;
|
|
4242
|
-
var bundleQty = new Decimal(Number(qty) || 1).times(Number((
|
|
4400
|
+
var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref69 = (_bundle$num3 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num3 !== void 0 ? _bundle$num3 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity) !== null && _ref69 !== void 0 ? _ref69 : 1) || 1).toNumber();
|
|
4243
4401
|
var _iterator24 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
|
|
4244
4402
|
_step24;
|
|
4245
4403
|
try {
|