@pisell/pisellos 2.2.233 → 2.2.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/Order/index.d.ts +36 -1
- package/dist/modules/Order/index.js +496 -308
- package/dist/modules/Order/types.d.ts +11 -0
- package/dist/modules/Order/utils.d.ts +1 -0
- package/dist/modules/Order/utils.js +1 -1
- package/dist/server/index.d.ts +5 -0
- package/dist/server/index.js +855 -633
- package/dist/server/modules/order/index.d.ts +2 -0
- package/dist/server/modules/order/index.js +86 -32
- package/dist/solution/BaseSales/index.d.ts +6 -0
- package/dist/solution/BaseSales/index.js +240 -197
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +38 -2
- package/dist/solution/BookingTicket/index.js +642 -313
- package/dist/solution/BookingTicket/types.d.ts +62 -0
- package/dist/solution/BookingTicket/types.js +30 -0
- package/dist/solution/BookingTicket/utils/addTimeAvailability.d.ts +35 -0
- package/dist/solution/BookingTicket/utils/addTimeAvailability.js +95 -0
- package/dist/solution/BookingTicket/utils/cartView.d.ts +9 -1
- package/dist/solution/BookingTicket/utils/cartView.js +76 -5
- package/dist/solution/BookingTicket/utils/exampleData.d.ts +123 -0
- package/dist/solution/BookingTicket/utils/exampleData.js +183 -0
- package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +9 -13
- package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.js +42 -33
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/Order/index.d.ts +36 -1
- package/lib/modules/Order/index.js +98 -10
- package/lib/modules/Order/types.d.ts +11 -0
- package/lib/modules/Order/utils.d.ts +1 -0
- package/lib/modules/Order/utils.js +1 -1
- package/lib/server/index.d.ts +5 -0
- package/lib/server/index.js +224 -63
- package/lib/server/modules/order/index.d.ts +2 -0
- package/lib/server/modules/order/index.js +43 -1
- package/lib/solution/BaseSales/index.d.ts +6 -0
- package/lib/solution/BaseSales/index.js +20 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +38 -2
- package/lib/solution/BookingTicket/index.js +194 -3
- package/lib/solution/BookingTicket/types.d.ts +62 -0
- package/lib/solution/BookingTicket/utils/addTimeAvailability.d.ts +35 -0
- package/lib/solution/BookingTicket/utils/addTimeAvailability.js +125 -0
- package/lib/solution/BookingTicket/utils/cartView.d.ts +9 -1
- package/lib/solution/BookingTicket/utils/cartView.js +48 -2
- package/lib/solution/BookingTicket/utils/exampleData.d.ts +123 -0
- package/lib/solution/BookingTicket/utils/exampleData.js +0 -0
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +9 -13
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +41 -28
- package/package.json +1 -1
|
@@ -2951,6 +2951,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2951
2951
|
return typeof (product === null || product === void 0 ? void 0 : product.note) === 'string' && product.note.trim().length > 0;
|
|
2952
2952
|
}
|
|
2953
2953
|
|
|
2954
|
+
/**
|
|
2955
|
+
* 判断商品行是否显式绑定了 booking。
|
|
2956
|
+
*
|
|
2957
|
+
* @example
|
|
2958
|
+
* this.hasLinkedBookingUid({ metadata: { booking_uid: 'booking-1' } });
|
|
2959
|
+
*/
|
|
2960
|
+
}, {
|
|
2961
|
+
key: "hasLinkedBookingUid",
|
|
2962
|
+
value: function hasLinkedBookingUid(product) {
|
|
2963
|
+
var _product$booking_uid, _product$metadata7;
|
|
2964
|
+
var bookingUid = (_product$booking_uid = product === null || product === void 0 ? void 0 : product.booking_uid) !== null && _product$booking_uid !== void 0 ? _product$booking_uid : product === null || product === void 0 || (_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.booking_uid;
|
|
2965
|
+
return bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '';
|
|
2966
|
+
}
|
|
2967
|
+
|
|
2954
2968
|
// ─── TempOrder: 商品 CRUD ───
|
|
2955
2969
|
|
|
2956
2970
|
/**
|
|
@@ -2962,32 +2976,42 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2962
2976
|
}, {
|
|
2963
2977
|
key: "finalizeProductOrderMutation",
|
|
2964
2978
|
value: function () {
|
|
2965
|
-
var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(tempOrder) {
|
|
2979
|
+
var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(tempOrder, options) {
|
|
2966
2980
|
return _regeneratorRuntime().wrap(function _callee14$(_context16) {
|
|
2967
2981
|
while (1) switch (_context16.prev = _context16.next) {
|
|
2968
2982
|
case 0:
|
|
2969
2983
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
2970
|
-
|
|
2984
|
+
if (options !== null && options !== void 0 && options.skipEditDiscountConfigRefresh) {
|
|
2985
|
+
_context16.next = 4;
|
|
2986
|
+
break;
|
|
2987
|
+
}
|
|
2988
|
+
_context16.next = 4;
|
|
2971
2989
|
return this.ensureEditDiscountConfigForProductChange(tempOrder);
|
|
2972
|
-
case
|
|
2973
|
-
|
|
2990
|
+
case 4:
|
|
2991
|
+
if (options !== null && options !== void 0 && options.skipDiscountRecalculation) {
|
|
2992
|
+
_context16.next = 7;
|
|
2993
|
+
break;
|
|
2994
|
+
}
|
|
2995
|
+
_context16.next = 7;
|
|
2974
2996
|
return this.applyPromotion();
|
|
2975
|
-
case
|
|
2976
|
-
|
|
2997
|
+
case 7:
|
|
2998
|
+
if (!(options !== null && options !== void 0 && options.skipDiscountRecalculation)) {
|
|
2999
|
+
this.applyDiscount();
|
|
3000
|
+
}
|
|
2977
3001
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
2978
|
-
_context16.next =
|
|
3002
|
+
_context16.next = 11;
|
|
2979
3003
|
return this.recalculateSummary({
|
|
2980
3004
|
createIfMissing: true
|
|
2981
3005
|
});
|
|
2982
|
-
case
|
|
3006
|
+
case 11:
|
|
2983
3007
|
this.persistTempOrder();
|
|
2984
|
-
case
|
|
3008
|
+
case 12:
|
|
2985
3009
|
case "end":
|
|
2986
3010
|
return _context16.stop();
|
|
2987
3011
|
}
|
|
2988
3012
|
}, _callee14, this);
|
|
2989
3013
|
}));
|
|
2990
|
-
function finalizeProductOrderMutation(_x14) {
|
|
3014
|
+
function finalizeProductOrderMutation(_x14, _x15) {
|
|
2991
3015
|
return _finalizeProductOrderMutation.apply(this, arguments);
|
|
2992
3016
|
}
|
|
2993
3017
|
return finalizeProductOrderMutation;
|
|
@@ -3003,8 +3027,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3003
3027
|
key: "appendProductLineToTempOrder",
|
|
3004
3028
|
value: (function () {
|
|
3005
3029
|
var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(tempOrder, product, booking) {
|
|
3006
|
-
var
|
|
3007
|
-
|
|
3030
|
+
var _booking_uid,
|
|
3031
|
+
_metadata,
|
|
3032
|
+
_this16 = this;
|
|
3033
|
+
var linked, productToAdd, incomingFingerprint, normalizedIncoming, incomingBookingUid, hasIncomingGoodPass, hasIncomingProductNote, hasIncomingBookingUid, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList;
|
|
3008
3034
|
return _regeneratorRuntime().wrap(function _callee15$(_context17) {
|
|
3009
3035
|
while (1) switch (_context17.prev = _context17.next) {
|
|
3010
3036
|
case 0:
|
|
@@ -3015,10 +3041,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3015
3041
|
productToAdd = (linked === null || linked === void 0 ? void 0 : linked.product) || product;
|
|
3016
3042
|
incomingFingerprint = buildProductLineFingerprint(getProductSkuOptions(productToAdd), productToAdd.product_bundle);
|
|
3017
3043
|
normalizedIncoming = mergeOrderProductDisplayFields(productToAdd, normalizeOrderProduct(productToAdd));
|
|
3044
|
+
incomingBookingUid = (_booking_uid = productToAdd.booking_uid) !== null && _booking_uid !== void 0 ? _booking_uid : (_metadata = productToAdd.metadata) === null || _metadata === void 0 ? void 0 : _metadata.booking_uid;
|
|
3045
|
+
if (incomingBookingUid !== undefined && incomingBookingUid !== null && String(incomingBookingUid) !== '') {
|
|
3046
|
+
normalizedIncoming.booking_uid = String(incomingBookingUid);
|
|
3047
|
+
normalizedIncoming.metadata = _objectSpread(_objectSpread({}, normalizedIncoming.metadata || {}), {}, {
|
|
3048
|
+
booking_uid: String(incomingBookingUid)
|
|
3049
|
+
});
|
|
3050
|
+
}
|
|
3018
3051
|
normalizedIncoming.discount_list = normalizeOrderProductDiscountList(normalizedIncoming.discount_list);
|
|
3019
3052
|
hasIncomingGoodPass = this.hasGoodPassDiscount(normalizedIncoming);
|
|
3020
3053
|
hasIncomingProductNote = this.hasOrderProductLineNote(normalizedIncoming);
|
|
3021
|
-
|
|
3054
|
+
hasIncomingBookingUid = this.hasLinkedBookingUid(productToAdd) || this.hasLinkedBookingUid(normalizedIncoming);
|
|
3055
|
+
shouldForceNewLine = !!booking || hasIncomingProductNote || hasIncomingBookingUid;
|
|
3022
3056
|
matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
3023
3057
|
if (_this16.hasGoodPassDiscount(item)) return false;
|
|
3024
3058
|
if (_this16.hasOrderProductLineNote(item)) return false;
|
|
@@ -3031,10 +3065,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3031
3065
|
matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
|
|
3032
3066
|
existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
|
|
3033
3067
|
if (!matchedProduct) {
|
|
3034
|
-
_context17.next =
|
|
3068
|
+
_context17.next = 20;
|
|
3035
3069
|
break;
|
|
3036
3070
|
}
|
|
3037
|
-
_context17.next =
|
|
3071
|
+
_context17.next = 17;
|
|
3038
3072
|
return this.shouldMergeProductToOrder({
|
|
3039
3073
|
incomingProduct: productToAdd,
|
|
3040
3074
|
normalizedIncoming: normalizedIncoming,
|
|
@@ -3045,13 +3079,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3045
3079
|
tempOrder: tempOrder,
|
|
3046
3080
|
booking: booking
|
|
3047
3081
|
});
|
|
3048
|
-
case
|
|
3082
|
+
case 17:
|
|
3049
3083
|
_context17.t0 = _context17.sent;
|
|
3050
|
-
_context17.next =
|
|
3084
|
+
_context17.next = 21;
|
|
3051
3085
|
break;
|
|
3052
|
-
case
|
|
3086
|
+
case 20:
|
|
3053
3087
|
_context17.t0 = false;
|
|
3054
|
-
case
|
|
3088
|
+
case 21:
|
|
3055
3089
|
shouldMerge = _context17.t0;
|
|
3056
3090
|
if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
|
|
3057
3091
|
this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
|
|
@@ -3061,7 +3095,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3061
3095
|
booking_uid: linked.bookingUid
|
|
3062
3096
|
});
|
|
3063
3097
|
}
|
|
3064
|
-
tempOrder.products.push(normalizedIncoming);
|
|
3098
|
+
// tempOrder.products.push(normalizedIncoming);
|
|
3099
|
+
tempOrder.products = [].concat(_toConsumableArray(tempOrder.products), [normalizedIncoming]);
|
|
3065
3100
|
} else {
|
|
3066
3101
|
targetProduct = matchedProduct;
|
|
3067
3102
|
targetUid = (_targetProduct$metada = targetProduct.metadata) === null || _targetProduct$metada === void 0 ? void 0 : _targetProduct$metada.unique_identification_number;
|
|
@@ -3103,13 +3138,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3103
3138
|
if (linked) {
|
|
3104
3139
|
tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
|
|
3105
3140
|
}
|
|
3106
|
-
case
|
|
3141
|
+
case 24:
|
|
3107
3142
|
case "end":
|
|
3108
3143
|
return _context17.stop();
|
|
3109
3144
|
}
|
|
3110
3145
|
}, _callee15, this);
|
|
3111
3146
|
}));
|
|
3112
|
-
function appendProductLineToTempOrder(
|
|
3147
|
+
function appendProductLineToTempOrder(_x16, _x17, _x18) {
|
|
3113
3148
|
return _appendProductLineToTempOrder.apply(this, arguments);
|
|
3114
3149
|
}
|
|
3115
3150
|
return appendProductLineToTempOrder;
|
|
@@ -3175,10 +3210,111 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3175
3210
|
}
|
|
3176
3211
|
}, _callee16, this);
|
|
3177
3212
|
}));
|
|
3178
|
-
function addProductToOrder(
|
|
3213
|
+
function addProductToOrder(_x19, _x20) {
|
|
3179
3214
|
return _addProductToOrder.apply(this, arguments);
|
|
3180
3215
|
}
|
|
3181
3216
|
return addProductToOrder;
|
|
3217
|
+
}()
|
|
3218
|
+
/**
|
|
3219
|
+
* 批量添加商品行,所有行追加完成后只触发一次促销、折扣、summary 重算与持久化。
|
|
3220
|
+
*
|
|
3221
|
+
* @example
|
|
3222
|
+
* await order.addProductsToOrder([
|
|
3223
|
+
* { product: { product_id: 1, product_variant_id: 0, num: 1 } },
|
|
3224
|
+
* { product: { product_id: 2, product_variant_id: 0, num: 1 } },
|
|
3225
|
+
* ]);
|
|
3226
|
+
*/
|
|
3227
|
+
)
|
|
3228
|
+
}, {
|
|
3229
|
+
key: "addProductsToOrder",
|
|
3230
|
+
value: (function () {
|
|
3231
|
+
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(items, options) {
|
|
3232
|
+
var tempOrder, _iterator20, _step20, item, product, booking, _ref60, _productRecord$num2, productRecord, splitCount, i, singleLine;
|
|
3233
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context19) {
|
|
3234
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
3235
|
+
case 0:
|
|
3236
|
+
tempOrder = this.ensureTempOrder();
|
|
3237
|
+
if (!(!Array.isArray(items) || items.length === 0)) {
|
|
3238
|
+
_context19.next = 3;
|
|
3239
|
+
break;
|
|
3240
|
+
}
|
|
3241
|
+
return _context19.abrupt("return", tempOrder.products);
|
|
3242
|
+
case 3:
|
|
3243
|
+
_iterator20 = _createForOfIteratorHelper(items || []);
|
|
3244
|
+
_context19.prev = 4;
|
|
3245
|
+
_iterator20.s();
|
|
3246
|
+
case 6:
|
|
3247
|
+
if ((_step20 = _iterator20.n()).done) {
|
|
3248
|
+
_context19.next = 30;
|
|
3249
|
+
break;
|
|
3250
|
+
}
|
|
3251
|
+
item = _step20.value;
|
|
3252
|
+
product = item.product, booking = item.booking;
|
|
3253
|
+
if (product) {
|
|
3254
|
+
_context19.next = 11;
|
|
3255
|
+
break;
|
|
3256
|
+
}
|
|
3257
|
+
return _context19.abrupt("continue", 28);
|
|
3258
|
+
case 11:
|
|
3259
|
+
if (!booking) {
|
|
3260
|
+
_context19.next = 26;
|
|
3261
|
+
break;
|
|
3262
|
+
}
|
|
3263
|
+
productRecord = product;
|
|
3264
|
+
splitCount = getSafeProductNum((_ref60 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref60 !== void 0 ? _ref60 : 1);
|
|
3265
|
+
if (!(splitCount > 1)) {
|
|
3266
|
+
_context19.next = 26;
|
|
3267
|
+
break;
|
|
3268
|
+
}
|
|
3269
|
+
i = 0;
|
|
3270
|
+
case 16:
|
|
3271
|
+
if (!(i < splitCount)) {
|
|
3272
|
+
_context19.next = 25;
|
|
3273
|
+
break;
|
|
3274
|
+
}
|
|
3275
|
+
singleLine = cloneDeep(productRecord);
|
|
3276
|
+
singleLine.num = 1;
|
|
3277
|
+
delete singleLine.product_quantity;
|
|
3278
|
+
_context19.next = 22;
|
|
3279
|
+
return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
|
|
3280
|
+
case 22:
|
|
3281
|
+
i += 1;
|
|
3282
|
+
_context19.next = 16;
|
|
3283
|
+
break;
|
|
3284
|
+
case 25:
|
|
3285
|
+
return _context19.abrupt("continue", 28);
|
|
3286
|
+
case 26:
|
|
3287
|
+
_context19.next = 28;
|
|
3288
|
+
return this.appendProductLineToTempOrder(tempOrder, product, booking);
|
|
3289
|
+
case 28:
|
|
3290
|
+
_context19.next = 6;
|
|
3291
|
+
break;
|
|
3292
|
+
case 30:
|
|
3293
|
+
_context19.next = 35;
|
|
3294
|
+
break;
|
|
3295
|
+
case 32:
|
|
3296
|
+
_context19.prev = 32;
|
|
3297
|
+
_context19.t0 = _context19["catch"](4);
|
|
3298
|
+
_iterator20.e(_context19.t0);
|
|
3299
|
+
case 35:
|
|
3300
|
+
_context19.prev = 35;
|
|
3301
|
+
_iterator20.f();
|
|
3302
|
+
return _context19.finish(35);
|
|
3303
|
+
case 38:
|
|
3304
|
+
_context19.next = 40;
|
|
3305
|
+
return this.finalizeProductOrderMutation(tempOrder, options);
|
|
3306
|
+
case 40:
|
|
3307
|
+
return _context19.abrupt("return", tempOrder.products);
|
|
3308
|
+
case 41:
|
|
3309
|
+
case "end":
|
|
3310
|
+
return _context19.stop();
|
|
3311
|
+
}
|
|
3312
|
+
}, _callee17, this, [[4, 32, 35, 38]]);
|
|
3313
|
+
}));
|
|
3314
|
+
function addProductsToOrder(_x21, _x22) {
|
|
3315
|
+
return _addProductsToOrder.apply(this, arguments);
|
|
3316
|
+
}
|
|
3317
|
+
return addProductsToOrder;
|
|
3182
3318
|
}())
|
|
3183
3319
|
}, {
|
|
3184
3320
|
key: "hasGoodPassDiscount",
|
|
@@ -3202,9 +3338,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3202
3338
|
}, {
|
|
3203
3339
|
key: "getBundleRuntimeIdentity",
|
|
3204
3340
|
value: function getBundleRuntimeIdentity(bundle) {
|
|
3205
|
-
var
|
|
3341
|
+
var _ref61, _bundle$bundle_id2, _ref62, _bundle$bundle_group_2, _ref63, _ref64, _bundle$bundle_produc3, _ref65, _bundle$bundle_varian3;
|
|
3206
3342
|
if (!bundle || _typeof(bundle) !== 'object') return '';
|
|
3207
|
-
return [(
|
|
3343
|
+
return [(_ref61 = (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id) !== null && _ref61 !== void 0 ? _ref61 : '', (_ref62 = (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id) !== null && _ref62 !== void 0 ? _ref62 : '', (_ref63 = (_ref64 = (_bundle$bundle_produc3 = bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle._bundle_product_id) !== null && _ref64 !== void 0 ? _ref64 : bundle.product_id) !== null && _ref63 !== void 0 ? _ref63 : '', (_ref65 = (_bundle$bundle_varian3 = bundle.bundle_variant_id) !== null && _bundle$bundle_varian3 !== void 0 ? _bundle$bundle_varian3 : bundle.product_variant_id) !== null && _ref65 !== void 0 ? _ref65 : 0].join('|');
|
|
3208
3344
|
}
|
|
3209
3345
|
}, {
|
|
3210
3346
|
key: "preservePersistedBundlePriceFields",
|
|
@@ -3234,11 +3370,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3234
3370
|
}, {
|
|
3235
3371
|
key: "updateOrderProduct",
|
|
3236
3372
|
value: function () {
|
|
3237
|
-
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3238
|
-
var _targetProduct$metada2, _product_sku,
|
|
3373
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(params) {
|
|
3374
|
+
var _targetProduct$metada2, _product_sku, _metadata2, _metadata3, _metadata4, _metadata5, _metadata6, _metadata7, _nextProduct$metadata, _targetProduct$metada8, _tempOrder$products$p;
|
|
3239
3375
|
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, callerAllowsBookingReprice, _targetProduct$metada3, _targetProduct$metada4, _targetProduct$metada5, _targetProduct$metada6, _targetProduct$metada7, existedMeta, normalizedProduct, preservedBookingUid, _normalizedProduct$me, _targetProduct$metada9, productUid, linked;
|
|
3240
|
-
return _regeneratorRuntime().wrap(function
|
|
3241
|
-
while (1) switch (
|
|
3376
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context20) {
|
|
3377
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
3242
3378
|
case 0:
|
|
3243
3379
|
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;
|
|
3244
3380
|
tempOrder = this.ensureTempOrder();
|
|
@@ -3269,7 +3405,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3269
3405
|
productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
|
|
3270
3406
|
}
|
|
3271
3407
|
if (!(productIndex === -1)) {
|
|
3272
|
-
|
|
3408
|
+
_context20.next = 12;
|
|
3273
3409
|
break;
|
|
3274
3410
|
}
|
|
3275
3411
|
throw new Error('[Order] 目标商品不存在,无法更新');
|
|
@@ -3295,10 +3431,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3295
3431
|
// main_selling / composite;否则旧 metadata 会反压顶层新值,触发口径不一致。
|
|
3296
3432
|
// 如果 caller 走推荐路径(updates.metadata.* 显式指定主价),保留 metadata 由 normalize 认它。
|
|
3297
3433
|
callerUpdatesTopPrice = Object.prototype.hasOwnProperty.call(updates || {}, 'selling_price') || Object.prototype.hasOwnProperty.call(updates || {}, 'original_price');
|
|
3298
|
-
callerUpdatesMainMeta = (updates === null || updates === void 0 || (
|
|
3434
|
+
callerUpdatesMainMeta = (updates === null || updates === void 0 || (_metadata2 = updates.metadata) === null || _metadata2 === void 0 ? void 0 : _metadata2.main_product_selling_price) !== undefined || (updates === null || updates === void 0 || (_metadata3 = updates.metadata) === null || _metadata3 === void 0 ? void 0 : _metadata3.main_product_original_price) !== undefined || (updates === null || updates === void 0 || (_metadata4 = updates.metadata) === null || _metadata4 === void 0 ? void 0 : _metadata4.source_product_price) !== undefined;
|
|
3299
3435
|
isPersistedOrderLine = targetProduct.order_detail_id !== undefined && targetProduct.order_detail_id !== null;
|
|
3300
3436
|
callerChangesDiscountList = Array.isArray(updates === null || updates === void 0 ? void 0 : updates.discount_list) && updates.discount_list.length > 0 && !isSameDiscountList(updates.discount_list, targetProduct.discount_list);
|
|
3301
|
-
callerUpdatesManualPrice = (updates === null || updates === void 0 || (
|
|
3437
|
+
callerUpdatesManualPrice = (updates === null || updates === void 0 || (_metadata5 = updates.metadata) === null || _metadata5 === void 0 ? void 0 : _metadata5.price_override) !== undefined || (updates === null || updates === void 0 || (_metadata6 = updates.metadata) === null || _metadata6 === void 0 ? void 0 : _metadata6.is_manual_discount) !== undefined || (updates === null || updates === void 0 || (_metadata7 = updates.metadata) === null || _metadata7 === void 0 ? void 0 : _metadata7.product_discount_reason) !== undefined || callerChangesDiscountList;
|
|
3302
3438
|
callerAllowsBookingReprice = function () {
|
|
3303
3439
|
if (params.allow_booking_reprice !== true || !booking || !callerUpdatesTopPrice || !callerUpdatesMainMeta) {
|
|
3304
3440
|
return false;
|
|
@@ -3365,25 +3501,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3365
3501
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
3366
3502
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
3367
3503
|
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);
|
|
3368
|
-
|
|
3504
|
+
_context20.next = 32;
|
|
3369
3505
|
return this.applyPromotion();
|
|
3370
3506
|
case 32:
|
|
3371
3507
|
this.applyDiscount();
|
|
3372
3508
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
3373
|
-
|
|
3509
|
+
_context20.next = 36;
|
|
3374
3510
|
return this.recalculateSummary({
|
|
3375
3511
|
createIfMissing: true
|
|
3376
3512
|
});
|
|
3377
3513
|
case 36:
|
|
3378
3514
|
this.persistTempOrder();
|
|
3379
|
-
return
|
|
3515
|
+
return _context20.abrupt("return", tempOrder.products);
|
|
3380
3516
|
case 38:
|
|
3381
3517
|
case "end":
|
|
3382
|
-
return
|
|
3518
|
+
return _context20.stop();
|
|
3383
3519
|
}
|
|
3384
|
-
},
|
|
3520
|
+
}, _callee18, this);
|
|
3385
3521
|
}));
|
|
3386
|
-
function updateOrderProduct(
|
|
3522
|
+
function updateOrderProduct(_x23) {
|
|
3387
3523
|
return _updateOrderProduct.apply(this, arguments);
|
|
3388
3524
|
}
|
|
3389
3525
|
return updateOrderProduct;
|
|
@@ -3391,11 +3527,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3391
3527
|
}, {
|
|
3392
3528
|
key: "updateOrderProductQuantity",
|
|
3393
3529
|
value: function () {
|
|
3394
|
-
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3530
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
|
|
3395
3531
|
var _targetProduct$metada10;
|
|
3396
3532
|
var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct;
|
|
3397
|
-
return _regeneratorRuntime().wrap(function
|
|
3398
|
-
while (1) switch (
|
|
3533
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context21) {
|
|
3534
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
3399
3535
|
case 0:
|
|
3400
3536
|
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;
|
|
3401
3537
|
tempOrder = this.ensureTempOrder();
|
|
@@ -3424,7 +3560,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3424
3560
|
productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
|
|
3425
3561
|
}
|
|
3426
3562
|
if (!(productIndex === -1)) {
|
|
3427
|
-
|
|
3563
|
+
_context21.next = 12;
|
|
3428
3564
|
break;
|
|
3429
3565
|
}
|
|
3430
3566
|
throw new Error('[Order] 目标商品不存在,无法更新数量');
|
|
@@ -3438,25 +3574,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3438
3574
|
}));
|
|
3439
3575
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
3440
3576
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
3441
|
-
|
|
3577
|
+
_context21.next = 18;
|
|
3442
3578
|
return this.applyPromotion();
|
|
3443
3579
|
case 18:
|
|
3444
3580
|
this.applyDiscount();
|
|
3445
3581
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
3446
|
-
|
|
3582
|
+
_context21.next = 22;
|
|
3447
3583
|
return this.recalculateSummary({
|
|
3448
3584
|
createIfMissing: true
|
|
3449
3585
|
});
|
|
3450
3586
|
case 22:
|
|
3451
3587
|
this.persistTempOrder();
|
|
3452
|
-
return
|
|
3588
|
+
return _context21.abrupt("return", tempOrder.products);
|
|
3453
3589
|
case 24:
|
|
3454
3590
|
case "end":
|
|
3455
|
-
return
|
|
3591
|
+
return _context21.stop();
|
|
3456
3592
|
}
|
|
3457
|
-
},
|
|
3593
|
+
}, _callee19, this);
|
|
3458
3594
|
}));
|
|
3459
|
-
function updateOrderProductQuantity(
|
|
3595
|
+
function updateOrderProductQuantity(_x24) {
|
|
3460
3596
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
3461
3597
|
}
|
|
3462
3598
|
return updateOrderProductQuantity;
|
|
@@ -3497,17 +3633,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3497
3633
|
}, {
|
|
3498
3634
|
key: "finalizeAfterProductsMutation",
|
|
3499
3635
|
value: (function () {
|
|
3500
|
-
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3501
|
-
return _regeneratorRuntime().wrap(function
|
|
3502
|
-
while (1) switch (
|
|
3636
|
+
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(tempOrder) {
|
|
3637
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context22) {
|
|
3638
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
3503
3639
|
case 0:
|
|
3504
3640
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
3505
|
-
|
|
3641
|
+
_context22.next = 3;
|
|
3506
3642
|
return this.applyPromotion();
|
|
3507
3643
|
case 3:
|
|
3508
3644
|
this.applyDiscount();
|
|
3509
3645
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
3510
|
-
|
|
3646
|
+
_context22.next = 7;
|
|
3511
3647
|
return this.recalculateSummary({
|
|
3512
3648
|
createIfMissing: true
|
|
3513
3649
|
});
|
|
@@ -3515,11 +3651,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3515
3651
|
this.persistTempOrder();
|
|
3516
3652
|
case 8:
|
|
3517
3653
|
case "end":
|
|
3518
|
-
return
|
|
3654
|
+
return _context22.stop();
|
|
3519
3655
|
}
|
|
3520
|
-
},
|
|
3656
|
+
}, _callee20, this);
|
|
3521
3657
|
}));
|
|
3522
|
-
function finalizeAfterProductsMutation(
|
|
3658
|
+
function finalizeAfterProductsMutation(_x25) {
|
|
3523
3659
|
return _finalizeAfterProductsMutation.apply(this, arguments);
|
|
3524
3660
|
}
|
|
3525
3661
|
return finalizeAfterProductsMutation;
|
|
@@ -3534,17 +3670,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3534
3670
|
}, {
|
|
3535
3671
|
key: "removeProductsFromOrder",
|
|
3536
3672
|
value: (function () {
|
|
3537
|
-
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3673
|
+
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(identities) {
|
|
3538
3674
|
var tempOrder, removedProducts, _i, _removedProducts, product;
|
|
3539
|
-
return _regeneratorRuntime().wrap(function
|
|
3540
|
-
while (1) switch (
|
|
3675
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context23) {
|
|
3676
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
3541
3677
|
case 0:
|
|
3542
3678
|
tempOrder = this.ensureTempOrder();
|
|
3543
3679
|
if (identities.length) {
|
|
3544
|
-
|
|
3680
|
+
_context23.next = 3;
|
|
3545
3681
|
break;
|
|
3546
3682
|
}
|
|
3547
|
-
return
|
|
3683
|
+
return _context23.abrupt("return", tempOrder.products);
|
|
3548
3684
|
case 3:
|
|
3549
3685
|
removedProducts = [];
|
|
3550
3686
|
tempOrder.products = tempOrder.products.filter(function (item) {
|
|
@@ -3558,17 +3694,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3558
3694
|
product = _removedProducts[_i];
|
|
3559
3695
|
this.removeLinkedBookingsForProduct(tempOrder, product);
|
|
3560
3696
|
}
|
|
3561
|
-
|
|
3697
|
+
_context23.next = 8;
|
|
3562
3698
|
return this.finalizeAfterProductsMutation(tempOrder);
|
|
3563
3699
|
case 8:
|
|
3564
|
-
return
|
|
3700
|
+
return _context23.abrupt("return", tempOrder.products);
|
|
3565
3701
|
case 9:
|
|
3566
3702
|
case "end":
|
|
3567
|
-
return
|
|
3703
|
+
return _context23.stop();
|
|
3568
3704
|
}
|
|
3569
|
-
},
|
|
3705
|
+
}, _callee21, this);
|
|
3570
3706
|
}));
|
|
3571
|
-
function removeProductsFromOrder(
|
|
3707
|
+
function removeProductsFromOrder(_x26) {
|
|
3572
3708
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
3573
3709
|
}
|
|
3574
3710
|
return removeProductsFromOrder;
|
|
@@ -3576,18 +3712,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3576
3712
|
}, {
|
|
3577
3713
|
key: "removeProductFromOrder",
|
|
3578
3714
|
value: function () {
|
|
3579
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3580
|
-
return _regeneratorRuntime().wrap(function
|
|
3581
|
-
while (1) switch (
|
|
3715
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(identity) {
|
|
3716
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context24) {
|
|
3717
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
3582
3718
|
case 0:
|
|
3583
|
-
return
|
|
3719
|
+
return _context24.abrupt("return", this.removeProductsFromOrder([identity]));
|
|
3584
3720
|
case 1:
|
|
3585
3721
|
case "end":
|
|
3586
|
-
return
|
|
3722
|
+
return _context24.stop();
|
|
3587
3723
|
}
|
|
3588
|
-
},
|
|
3724
|
+
}, _callee22, this);
|
|
3589
3725
|
}));
|
|
3590
|
-
function removeProductFromOrder(
|
|
3726
|
+
function removeProductFromOrder(_x27) {
|
|
3591
3727
|
return _removeProductFromOrder.apply(this, arguments);
|
|
3592
3728
|
}
|
|
3593
3729
|
return removeProductFromOrder;
|
|
@@ -3599,10 +3735,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3599
3735
|
}, {
|
|
3600
3736
|
key: "clearOrderCartLines",
|
|
3601
3737
|
value: (function () {
|
|
3602
|
-
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3738
|
+
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
3603
3739
|
var tempOrder;
|
|
3604
|
-
return _regeneratorRuntime().wrap(function
|
|
3605
|
-
while (1) switch (
|
|
3740
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context25) {
|
|
3741
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
3606
3742
|
case 0:
|
|
3607
3743
|
tempOrder = this.ensureTempOrder();
|
|
3608
3744
|
tempOrder.products = [];
|
|
@@ -3613,23 +3749,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3613
3749
|
productsByUid: {}
|
|
3614
3750
|
});
|
|
3615
3751
|
}
|
|
3616
|
-
|
|
3752
|
+
_context25.next = 7;
|
|
3617
3753
|
return this.applyPromotion();
|
|
3618
3754
|
case 7:
|
|
3619
3755
|
this.applyDiscount();
|
|
3620
3756
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
3621
|
-
|
|
3757
|
+
_context25.next = 11;
|
|
3622
3758
|
return this.recalculateSummary({
|
|
3623
3759
|
createIfMissing: true
|
|
3624
3760
|
});
|
|
3625
3761
|
case 11:
|
|
3626
3762
|
this.persistTempOrder();
|
|
3627
|
-
return
|
|
3763
|
+
return _context25.abrupt("return", tempOrder);
|
|
3628
3764
|
case 13:
|
|
3629
3765
|
case "end":
|
|
3630
|
-
return
|
|
3766
|
+
return _context25.stop();
|
|
3631
3767
|
}
|
|
3632
|
-
},
|
|
3768
|
+
}, _callee23, this);
|
|
3633
3769
|
}));
|
|
3634
3770
|
function clearOrderCartLines() {
|
|
3635
3771
|
return _clearOrderCartLines.apply(this, arguments);
|
|
@@ -3640,23 +3776,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3640
3776
|
}, {
|
|
3641
3777
|
key: "buildCurrentSubmitPayloadForLocalPrint",
|
|
3642
3778
|
value: function buildCurrentSubmitPayloadForLocalPrint(params) {
|
|
3643
|
-
var _params$cacheId, _this$otherParams2,
|
|
3779
|
+
var _params$cacheId, _this$otherParams2, _ref66, _params$businessCode, _this$otherParams3, _this$otherParams4;
|
|
3644
3780
|
var tempOrder = this.ensureTempOrder();
|
|
3645
3781
|
this.persistTempOrder();
|
|
3646
3782
|
var payload = buildSubmitPayload({
|
|
3647
3783
|
tempOrder: tempOrder,
|
|
3648
3784
|
cacheId: (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId,
|
|
3649
3785
|
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.platform),
|
|
3650
|
-
businessCode: (
|
|
3786
|
+
businessCode: (_ref66 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.businessCode) !== null && _ref66 !== void 0 ? _ref66 : (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.business_code,
|
|
3651
3787
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
3652
3788
|
type: params === null || params === void 0 ? void 0 : params.type,
|
|
3653
3789
|
summary: this.store.summary || createEmptySummary(),
|
|
3654
3790
|
enhance: function enhance(nextPayload) {
|
|
3655
|
-
var
|
|
3791
|
+
var _ref67, _tempOrder$order_numb, _ref68, _tempOrder$shop_order, _ref69, _tempOrder$shop_full_;
|
|
3656
3792
|
return _objectSpread(_objectSpread({}, nextPayload), {}, {
|
|
3657
|
-
order_number: (
|
|
3658
|
-
shop_order_number: (
|
|
3659
|
-
shop_full_order_number: (
|
|
3793
|
+
order_number: (_ref67 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref67 !== void 0 ? _ref67 : null,
|
|
3794
|
+
shop_order_number: (_ref68 = (_tempOrder$shop_order = tempOrder.shop_order_number) !== null && _tempOrder$shop_order !== void 0 ? _tempOrder$shop_order : nextPayload.shop_order_number) !== null && _ref68 !== void 0 ? _ref68 : null,
|
|
3795
|
+
shop_full_order_number: (_ref69 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref69 !== void 0 ? _ref69 : null,
|
|
3660
3796
|
small_ticket_data_flag: 1
|
|
3661
3797
|
});
|
|
3662
3798
|
}
|
|
@@ -3667,17 +3803,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3667
3803
|
}, {
|
|
3668
3804
|
key: "applyLocalPrintOrderNumbers",
|
|
3669
3805
|
value: function () {
|
|
3670
|
-
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3806
|
+
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(order) {
|
|
3671
3807
|
var tempOrder, shopOrderNumber, shopFullOrderNumber;
|
|
3672
|
-
return _regeneratorRuntime().wrap(function
|
|
3673
|
-
while (1) switch (
|
|
3808
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context26) {
|
|
3809
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
3674
3810
|
case 0:
|
|
3675
3811
|
tempOrder = this.ensureTempOrder();
|
|
3676
3812
|
if (!(!order || _typeof(order) !== 'object')) {
|
|
3677
|
-
|
|
3813
|
+
_context26.next = 3;
|
|
3678
3814
|
break;
|
|
3679
3815
|
}
|
|
3680
|
-
return
|
|
3816
|
+
return _context26.abrupt("return", tempOrder);
|
|
3681
3817
|
case 3:
|
|
3682
3818
|
shopOrderNumber = order.shop_order_number;
|
|
3683
3819
|
shopFullOrderNumber = order.shop_full_order_number;
|
|
@@ -3688,17 +3824,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3688
3824
|
tempOrder.shop_full_order_number = String(shopFullOrderNumber);
|
|
3689
3825
|
}
|
|
3690
3826
|
this.persistTempOrder();
|
|
3691
|
-
|
|
3827
|
+
_context26.next = 10;
|
|
3692
3828
|
return this.saveDraft();
|
|
3693
3829
|
case 10:
|
|
3694
|
-
return
|
|
3830
|
+
return _context26.abrupt("return", tempOrder);
|
|
3695
3831
|
case 11:
|
|
3696
3832
|
case "end":
|
|
3697
|
-
return
|
|
3833
|
+
return _context26.stop();
|
|
3698
3834
|
}
|
|
3699
|
-
},
|
|
3835
|
+
}, _callee24, this);
|
|
3700
3836
|
}));
|
|
3701
|
-
function applyLocalPrintOrderNumbers(
|
|
3837
|
+
function applyLocalPrintOrderNumbers(_x28) {
|
|
3702
3838
|
return _applyLocalPrintOrderNumbers.apply(this, arguments);
|
|
3703
3839
|
}
|
|
3704
3840
|
return applyLocalPrintOrderNumbers;
|
|
@@ -3712,34 +3848,74 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3712
3848
|
}, {
|
|
3713
3849
|
key: "submitTempOrder",
|
|
3714
3850
|
value: (function () {
|
|
3715
|
-
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3716
|
-
|
|
3851
|
+
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
|
|
3852
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context27) {
|
|
3853
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
3854
|
+
case 0:
|
|
3855
|
+
return _context27.abrupt("return", this.runSubmitTempOrder(params));
|
|
3856
|
+
case 1:
|
|
3857
|
+
case "end":
|
|
3858
|
+
return _context27.stop();
|
|
3859
|
+
}
|
|
3860
|
+
}, _callee25, this);
|
|
3861
|
+
}));
|
|
3862
|
+
function submitTempOrder(_x29) {
|
|
3863
|
+
return _submitTempOrder.apply(this, arguments);
|
|
3864
|
+
}
|
|
3865
|
+
return submitTempOrder;
|
|
3866
|
+
}())
|
|
3867
|
+
}, {
|
|
3868
|
+
key: "submitTempOrderAsync",
|
|
3869
|
+
value: function () {
|
|
3870
|
+
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
|
|
3871
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context28) {
|
|
3872
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
3873
|
+
case 0:
|
|
3874
|
+
return _context28.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
3875
|
+
syncMode: true
|
|
3876
|
+
})));
|
|
3877
|
+
case 1:
|
|
3878
|
+
case "end":
|
|
3879
|
+
return _context28.stop();
|
|
3880
|
+
}
|
|
3881
|
+
}, _callee26, this);
|
|
3882
|
+
}));
|
|
3883
|
+
function submitTempOrderAsync(_x30) {
|
|
3884
|
+
return _submitTempOrderAsync.apply(this, arguments);
|
|
3885
|
+
}
|
|
3886
|
+
return submitTempOrderAsync;
|
|
3887
|
+
}()
|
|
3888
|
+
}, {
|
|
3889
|
+
key: "runSubmitTempOrder",
|
|
3890
|
+
value: function () {
|
|
3891
|
+
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
|
|
3892
|
+
var _params$cacheId2, _this$otherParams5, _ref70, _params$businessCode2, _this$otherParams6, _this$otherParams7;
|
|
3717
3893
|
var tempOrder, latestSummary, effectiveCacheId, hasPaymentOverride, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
|
|
3718
|
-
return _regeneratorRuntime().wrap(function
|
|
3719
|
-
while (1) switch (
|
|
3894
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context29) {
|
|
3895
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
3720
3896
|
case 0:
|
|
3721
3897
|
tempOrder = this.ensureTempOrder();
|
|
3722
3898
|
this.persistTempOrder();
|
|
3723
|
-
|
|
3899
|
+
_context29.next = 4;
|
|
3724
3900
|
return this.recalculateSummary({
|
|
3725
3901
|
createIfMissing: true
|
|
3726
3902
|
});
|
|
3727
3903
|
case 4:
|
|
3728
|
-
|
|
3729
|
-
if (
|
|
3730
|
-
|
|
3904
|
+
_context29.t1 = _context29.sent;
|
|
3905
|
+
if (_context29.t1) {
|
|
3906
|
+
_context29.next = 7;
|
|
3731
3907
|
break;
|
|
3732
3908
|
}
|
|
3733
|
-
|
|
3909
|
+
_context29.t1 = this.store.summary;
|
|
3734
3910
|
case 7:
|
|
3735
|
-
|
|
3736
|
-
if (
|
|
3737
|
-
|
|
3911
|
+
_context29.t0 = _context29.t1;
|
|
3912
|
+
if (_context29.t0) {
|
|
3913
|
+
_context29.next = 10;
|
|
3738
3914
|
break;
|
|
3739
3915
|
}
|
|
3740
|
-
|
|
3916
|
+
_context29.t0 = createEmptySummary();
|
|
3741
3917
|
case 10:
|
|
3742
|
-
latestSummary =
|
|
3918
|
+
latestSummary = _context29.t0;
|
|
3743
3919
|
effectiveCacheId = (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId;
|
|
3744
3920
|
hasPaymentOverride = (params === null || params === void 0 ? void 0 : params.payments) !== undefined;
|
|
3745
3921
|
hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
|
|
@@ -3759,103 +3935,109 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3759
3935
|
tempOrder: tempOrder,
|
|
3760
3936
|
cacheId: effectiveCacheId,
|
|
3761
3937
|
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.platform),
|
|
3762
|
-
businessCode: (
|
|
3938
|
+
businessCode: (_ref70 = (_params$businessCode2 = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode2 !== void 0 ? _params$businessCode2 : (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.businessCode) !== null && _ref70 !== void 0 ? _ref70 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.business_code,
|
|
3763
3939
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
3764
3940
|
type: params === null || params === void 0 ? void 0 : params.type,
|
|
3765
3941
|
summary: latestSummary,
|
|
3942
|
+
request_unique_idempotency_token: params === null || params === void 0 ? void 0 : params.request_unique_idempotency_token,
|
|
3766
3943
|
enhance: enhancePayload
|
|
3767
|
-
});
|
|
3944
|
+
});
|
|
3945
|
+
if (params !== null && params !== void 0 && params.syncMode) {
|
|
3946
|
+
payload.sync_mode = true;
|
|
3947
|
+
}
|
|
3948
|
+
// TODO: 前端生成的时间现在是有问题的,后面要统一优化
|
|
3768
3949
|
if (!payload.created_at) {
|
|
3769
3950
|
payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
3770
3951
|
}
|
|
3771
|
-
|
|
3952
|
+
_context29.next = 21;
|
|
3772
3953
|
return this.saveDraft();
|
|
3773
|
-
case
|
|
3774
|
-
|
|
3954
|
+
case 21:
|
|
3955
|
+
_context29.prev = 21;
|
|
3775
3956
|
this.logInfo('submitTempOrder calling sales checkout', {
|
|
3776
3957
|
orderId: payload.order_id,
|
|
3777
3958
|
externalSaleNumber: payload.external_sale_number,
|
|
3778
3959
|
requestUniqueIdempotencyToken: payload.request_unique_idempotency_token,
|
|
3779
3960
|
paymentStatus: payload.payment_status,
|
|
3780
3961
|
paymentsCount: ((_payload$payments = payload.payments) === null || _payload$payments === void 0 ? void 0 : _payload$payments.length) || 0,
|
|
3781
|
-
smallTicketDataFlag: payload.small_ticket_data_flag
|
|
3962
|
+
smallTicketDataFlag: payload.small_ticket_data_flag,
|
|
3963
|
+
syncMode: payload.sync_mode
|
|
3782
3964
|
});
|
|
3783
|
-
|
|
3965
|
+
_context29.next = 25;
|
|
3784
3966
|
return this.submitSalesOrder({
|
|
3785
3967
|
query: payload
|
|
3786
3968
|
});
|
|
3787
|
-
case
|
|
3788
|
-
result =
|
|
3789
|
-
|
|
3969
|
+
case 25:
|
|
3970
|
+
result = _context29.sent;
|
|
3971
|
+
_context29.next = 38;
|
|
3790
3972
|
break;
|
|
3791
|
-
case
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
backendErrorResponse = this.extractSubmitErrorResponse(
|
|
3973
|
+
case 28:
|
|
3974
|
+
_context29.prev = 28;
|
|
3975
|
+
_context29.t2 = _context29["catch"](21);
|
|
3976
|
+
backendErrorResponse = this.extractSubmitErrorResponse(_context29.t2);
|
|
3795
3977
|
if (!backendErrorResponse) {
|
|
3796
|
-
|
|
3978
|
+
_context29.next = 35;
|
|
3797
3979
|
break;
|
|
3798
3980
|
}
|
|
3799
3981
|
this.store.syncState = 'failed';
|
|
3800
3982
|
this.logSubmitBackendRejected(backendErrorResponse, payload);
|
|
3801
|
-
return
|
|
3802
|
-
case
|
|
3983
|
+
return _context29.abrupt("return", backendErrorResponse);
|
|
3984
|
+
case 35:
|
|
3803
3985
|
this.store.syncState = 'failed';
|
|
3804
3986
|
this.logError('submitTempOrder failed', {
|
|
3805
|
-
error:
|
|
3987
|
+
error: _context29.t2 instanceof Error ? _context29.t2.message : String(_context29.t2),
|
|
3806
3988
|
orderId: payload.order_id,
|
|
3807
3989
|
externalSaleNumber: payload.external_sale_number,
|
|
3808
3990
|
paymentStatus: payload.payment_status,
|
|
3809
3991
|
paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
|
|
3810
3992
|
});
|
|
3811
|
-
throw
|
|
3812
|
-
case
|
|
3993
|
+
throw _context29.t2;
|
|
3994
|
+
case 38:
|
|
3813
3995
|
if (!this.isSubmitResponseRejected(result)) {
|
|
3814
|
-
|
|
3996
|
+
_context29.next = 42;
|
|
3815
3997
|
break;
|
|
3816
3998
|
}
|
|
3817
3999
|
this.store.syncState = 'failed';
|
|
3818
4000
|
this.logSubmitBackendRejected(result, payload);
|
|
3819
|
-
return
|
|
3820
|
-
case
|
|
4001
|
+
return _context29.abrupt("return", result);
|
|
4002
|
+
case 42:
|
|
3821
4003
|
submittedOrderId = this.extractOrderIdFromSubmitResult(result);
|
|
3822
4004
|
if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
|
|
3823
|
-
|
|
4005
|
+
_context29.next = 50;
|
|
3824
4006
|
break;
|
|
3825
4007
|
}
|
|
3826
4008
|
tempOrder.order_id = submittedOrderId;
|
|
3827
4009
|
resultRecord = result;
|
|
3828
|
-
|
|
4010
|
+
_context29.next = 48;
|
|
3829
4011
|
return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
|
|
3830
|
-
case
|
|
3831
|
-
|
|
4012
|
+
case 48:
|
|
4013
|
+
_context29.next = 51;
|
|
3832
4014
|
break;
|
|
3833
|
-
case
|
|
4015
|
+
case 50:
|
|
3834
4016
|
if (this.isLocalPendingSubmitResult(result)) {
|
|
3835
4017
|
this.store.syncState = 'local';
|
|
3836
4018
|
} else {
|
|
3837
4019
|
this.store.syncState = 'submitted';
|
|
3838
4020
|
}
|
|
3839
|
-
case 50:
|
|
3840
|
-
return _context26.abrupt("return", result);
|
|
3841
4021
|
case 51:
|
|
4022
|
+
return _context29.abrupt("return", result);
|
|
4023
|
+
case 52:
|
|
3842
4024
|
case "end":
|
|
3843
|
-
return
|
|
4025
|
+
return _context29.stop();
|
|
3844
4026
|
}
|
|
3845
|
-
},
|
|
4027
|
+
}, _callee27, this, [[21, 28]]);
|
|
3846
4028
|
}));
|
|
3847
|
-
function
|
|
3848
|
-
return
|
|
4029
|
+
function runSubmitTempOrder(_x31) {
|
|
4030
|
+
return _runSubmitTempOrder.apply(this, arguments);
|
|
3849
4031
|
}
|
|
3850
|
-
return
|
|
3851
|
-
}()
|
|
4032
|
+
return runSubmitTempOrder;
|
|
4033
|
+
}()
|
|
3852
4034
|
}, {
|
|
3853
4035
|
key: "markLocalOrderSynced",
|
|
3854
4036
|
value: function () {
|
|
3855
|
-
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4037
|
+
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(orderId, remoteOrder) {
|
|
3856
4038
|
var tempOrder;
|
|
3857
|
-
return _regeneratorRuntime().wrap(function
|
|
3858
|
-
while (1) switch (
|
|
4039
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context30) {
|
|
4040
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
3859
4041
|
case 0:
|
|
3860
4042
|
tempOrder = this.ensureTempOrder();
|
|
3861
4043
|
tempOrder.order_id = orderId;
|
|
@@ -3863,15 +4045,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3863
4045
|
this.store.lastOrderInfo = remoteOrder;
|
|
3864
4046
|
this.store.syncState = 'submitted';
|
|
3865
4047
|
this.persistTempOrder();
|
|
3866
|
-
|
|
4048
|
+
_context30.next = 8;
|
|
3867
4049
|
return this.saveDraft();
|
|
3868
4050
|
case 8:
|
|
3869
4051
|
case "end":
|
|
3870
|
-
return
|
|
4052
|
+
return _context30.stop();
|
|
3871
4053
|
}
|
|
3872
|
-
},
|
|
4054
|
+
}, _callee28, this);
|
|
3873
4055
|
}));
|
|
3874
|
-
function markLocalOrderSynced(
|
|
4056
|
+
function markLocalOrderSynced(_x32, _x33) {
|
|
3875
4057
|
return _markLocalOrderSynced.apply(this, arguments);
|
|
3876
4058
|
}
|
|
3877
4059
|
return markLocalOrderSynced;
|
|
@@ -3934,13 +4116,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3934
4116
|
}
|
|
3935
4117
|
});
|
|
3936
4118
|
}
|
|
4119
|
+
}, {
|
|
4120
|
+
key: "generateIdempotencyToken",
|
|
4121
|
+
value: function generateIdempotencyToken() {
|
|
4122
|
+
var tempOrder = this.ensureTempOrder();
|
|
4123
|
+
var token = this.buildPaymentSyncIdempotencyToken(tempOrder, tempOrder.payments);
|
|
4124
|
+
return "".concat(token, "_").concat(Date.now());
|
|
4125
|
+
}
|
|
3937
4126
|
}, {
|
|
3938
4127
|
key: "syncPaymentsToOrder",
|
|
3939
4128
|
value: function () {
|
|
3940
|
-
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4129
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
|
|
3941
4130
|
var tempOrder, mappedPayments, paymentTotal, targetAmount, isFullyPaid, paymentStatus, paymentSyncIdempotencyToken, submitResult;
|
|
3942
|
-
return _regeneratorRuntime().wrap(function
|
|
3943
|
-
while (1) switch (
|
|
4131
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context31) {
|
|
4132
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
3944
4133
|
case 0:
|
|
3945
4134
|
tempOrder = this.ensureTempOrder();
|
|
3946
4135
|
mappedPayments = mapPaymentItemsToOrderPayments(params.payments || []);
|
|
@@ -3951,28 +4140,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3951
4140
|
tempOrder.payments = mappedPayments;
|
|
3952
4141
|
tempOrder.payment_status = paymentStatus;
|
|
3953
4142
|
this.persistTempOrder();
|
|
3954
|
-
|
|
4143
|
+
_context31.next = 11;
|
|
3955
4144
|
return this.saveDraft();
|
|
3956
4145
|
case 11:
|
|
3957
4146
|
if (params.submitWhenPaid) {
|
|
3958
|
-
|
|
4147
|
+
_context31.next = 13;
|
|
3959
4148
|
break;
|
|
3960
4149
|
}
|
|
3961
|
-
return
|
|
4150
|
+
return _context31.abrupt("return", {
|
|
3962
4151
|
isFullyPaid: isFullyPaid
|
|
3963
4152
|
});
|
|
3964
4153
|
case 13:
|
|
3965
4154
|
if (!(this.store.syncState === 'submitting')) {
|
|
3966
|
-
|
|
4155
|
+
_context31.next = 15;
|
|
3967
4156
|
break;
|
|
3968
4157
|
}
|
|
3969
|
-
return
|
|
4158
|
+
return _context31.abrupt("return", {
|
|
3970
4159
|
isFullyPaid: isFullyPaid
|
|
3971
4160
|
});
|
|
3972
4161
|
case 15:
|
|
3973
4162
|
this.store.syncState = 'submitting';
|
|
3974
4163
|
paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, mappedPayments);
|
|
3975
|
-
|
|
4164
|
+
_context31.next = 19;
|
|
3976
4165
|
return this.submitTempOrder({
|
|
3977
4166
|
payments: mappedPayments,
|
|
3978
4167
|
paymentStatus: paymentStatus,
|
|
@@ -3987,18 +4176,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3987
4176
|
}
|
|
3988
4177
|
});
|
|
3989
4178
|
case 19:
|
|
3990
|
-
submitResult =
|
|
3991
|
-
return
|
|
4179
|
+
submitResult = _context31.sent;
|
|
4180
|
+
return _context31.abrupt("return", {
|
|
3992
4181
|
isFullyPaid: isFullyPaid,
|
|
3993
4182
|
submitResult: submitResult
|
|
3994
4183
|
});
|
|
3995
4184
|
case 21:
|
|
3996
4185
|
case "end":
|
|
3997
|
-
return
|
|
4186
|
+
return _context31.stop();
|
|
3998
4187
|
}
|
|
3999
|
-
},
|
|
4188
|
+
}, _callee29, this);
|
|
4000
4189
|
}));
|
|
4001
|
-
function syncPaymentsToOrder(
|
|
4190
|
+
function syncPaymentsToOrder(_x34) {
|
|
4002
4191
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
4003
4192
|
}
|
|
4004
4193
|
return syncPaymentsToOrder;
|
|
@@ -4087,11 +4276,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4087
4276
|
}, {
|
|
4088
4277
|
key: "submitOrder",
|
|
4089
4278
|
value: function () {
|
|
4090
|
-
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4279
|
+
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(order) {
|
|
4091
4280
|
var _order$query$cartItem, _params$bookings, _params$relation_prod;
|
|
4092
4281
|
var url, query, fetchUrl, params;
|
|
4093
|
-
return _regeneratorRuntime().wrap(function
|
|
4094
|
-
while (1) switch (
|
|
4282
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context32) {
|
|
4283
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
4095
4284
|
case 0:
|
|
4096
4285
|
this.logInfo('submitOrder called', {
|
|
4097
4286
|
url: order.url,
|
|
@@ -4111,14 +4300,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4111
4300
|
relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
|
|
4112
4301
|
scheduleDate: params.schedule_date
|
|
4113
4302
|
});
|
|
4114
|
-
return
|
|
4303
|
+
return _context32.abrupt("return", this.request.post(fetchUrl, params));
|
|
4115
4304
|
case 6:
|
|
4116
4305
|
case "end":
|
|
4117
|
-
return
|
|
4306
|
+
return _context32.stop();
|
|
4118
4307
|
}
|
|
4119
|
-
},
|
|
4308
|
+
}, _callee30, this);
|
|
4120
4309
|
}));
|
|
4121
|
-
function submitOrder(
|
|
4310
|
+
function submitOrder(_x35) {
|
|
4122
4311
|
return _submitOrder.apply(this, arguments);
|
|
4123
4312
|
}
|
|
4124
4313
|
return submitOrder;
|
|
@@ -4126,13 +4315,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4126
4315
|
}, {
|
|
4127
4316
|
key: "cancelOrder",
|
|
4128
4317
|
value: function () {
|
|
4129
|
-
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4318
|
+
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
|
|
4130
4319
|
var payload;
|
|
4131
|
-
return _regeneratorRuntime().wrap(function
|
|
4132
|
-
while (1) switch (
|
|
4320
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context33) {
|
|
4321
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
4133
4322
|
case 0:
|
|
4134
4323
|
if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
|
|
4135
|
-
|
|
4324
|
+
_context33.next = 2;
|
|
4136
4325
|
break;
|
|
4137
4326
|
}
|
|
4138
4327
|
throw new Error('取消订单失败:order_ids 不能为空');
|
|
@@ -4148,16 +4337,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4148
4337
|
method: 'PUT',
|
|
4149
4338
|
orderIdsCount: params.order_ids.length
|
|
4150
4339
|
});
|
|
4151
|
-
return
|
|
4340
|
+
return _context33.abrupt("return", this.request.put('/order/update-status', payload, {
|
|
4152
4341
|
isShopApi: true
|
|
4153
4342
|
}));
|
|
4154
4343
|
case 5:
|
|
4155
4344
|
case "end":
|
|
4156
|
-
return
|
|
4345
|
+
return _context33.stop();
|
|
4157
4346
|
}
|
|
4158
|
-
},
|
|
4347
|
+
}, _callee31, this);
|
|
4159
4348
|
}));
|
|
4160
|
-
function cancelOrder(
|
|
4349
|
+
function cancelOrder(_x36) {
|
|
4161
4350
|
return _cancelOrder.apply(this, arguments);
|
|
4162
4351
|
}
|
|
4163
4352
|
return cancelOrder;
|
|
@@ -4165,19 +4354,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4165
4354
|
}, {
|
|
4166
4355
|
key: "changeBookingStatus",
|
|
4167
4356
|
value: function () {
|
|
4168
|
-
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4357
|
+
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
|
|
4169
4358
|
var url, payload;
|
|
4170
|
-
return _regeneratorRuntime().wrap(function
|
|
4171
|
-
while (1) switch (
|
|
4359
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context34) {
|
|
4360
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
4172
4361
|
case 0:
|
|
4173
4362
|
if (params.booking_id) {
|
|
4174
|
-
|
|
4363
|
+
_context34.next = 2;
|
|
4175
4364
|
break;
|
|
4176
4365
|
}
|
|
4177
4366
|
throw new Error('变更预约状态失败:booking_id 不能为空');
|
|
4178
4367
|
case 2:
|
|
4179
4368
|
if (params.appointment_status) {
|
|
4180
|
-
|
|
4369
|
+
_context34.next = 4;
|
|
4181
4370
|
break;
|
|
4182
4371
|
}
|
|
4183
4372
|
throw new Error('变更预约状态失败:appointment_status 不能为空');
|
|
@@ -4192,16 +4381,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4192
4381
|
bookingId: params.booking_id,
|
|
4193
4382
|
appointmentStatus: params.appointment_status
|
|
4194
4383
|
});
|
|
4195
|
-
return
|
|
4384
|
+
return _context34.abrupt("return", this.request.put(url, payload, {
|
|
4196
4385
|
isShopApi: true
|
|
4197
4386
|
}));
|
|
4198
4387
|
case 8:
|
|
4199
4388
|
case "end":
|
|
4200
|
-
return
|
|
4389
|
+
return _context34.stop();
|
|
4201
4390
|
}
|
|
4202
|
-
},
|
|
4391
|
+
}, _callee32, this);
|
|
4203
4392
|
}));
|
|
4204
|
-
function changeBookingStatus(
|
|
4393
|
+
function changeBookingStatus(_x37) {
|
|
4205
4394
|
return _changeBookingStatus.apply(this, arguments);
|
|
4206
4395
|
}
|
|
4207
4396
|
return changeBookingStatus;
|
|
@@ -4219,11 +4408,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4219
4408
|
}, {
|
|
4220
4409
|
key: "createOrderByCheckout",
|
|
4221
4410
|
value: (function () {
|
|
4222
|
-
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4411
|
+
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
|
|
4223
4412
|
var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3, _params$bookings3, _params$relation_prod3, _params$payments4;
|
|
4224
4413
|
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;
|
|
4225
|
-
return _regeneratorRuntime().wrap(function
|
|
4226
|
-
while (1) switch (
|
|
4414
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context35) {
|
|
4415
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
4227
4416
|
case 0:
|
|
4228
4417
|
// 过滤掉由在线店铺下单的 payment 支付数据
|
|
4229
4418
|
onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
|
|
@@ -4257,7 +4446,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4257
4446
|
relationProductsCount: ((_params$relation_prod3 = params.relation_products) === null || _params$relation_prod3 === void 0 ? void 0 : _params$relation_prod3.length) || 0,
|
|
4258
4447
|
paymentsCount: ((_params$payments4 = params.payments) === null || _params$payments4 === void 0 ? void 0 : _params$payments4.length) || 0
|
|
4259
4448
|
});
|
|
4260
|
-
|
|
4449
|
+
_context35.prev = 4;
|
|
4261
4450
|
// 构建订单数据,设置默认值并允许 params 覆盖
|
|
4262
4451
|
orderData = _objectSpread({
|
|
4263
4452
|
sales_channel: 'my_pisel',
|
|
@@ -4319,13 +4508,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4319
4508
|
hasOrderId: !!orderData.order_id,
|
|
4320
4509
|
smallTicketDataFlag: orderData.small_ticket_data_flag
|
|
4321
4510
|
});
|
|
4322
|
-
|
|
4511
|
+
_context35.next = 12;
|
|
4323
4512
|
return this.request.post('/order/checkout', orderData, {
|
|
4324
4513
|
osServer: true,
|
|
4325
4514
|
customToast: function customToast() {}
|
|
4326
4515
|
});
|
|
4327
4516
|
case 12:
|
|
4328
|
-
response =
|
|
4517
|
+
response = _context35.sent;
|
|
4329
4518
|
this.logInfo('Order API called successfully', {
|
|
4330
4519
|
response: response
|
|
4331
4520
|
});
|
|
@@ -4333,22 +4522,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4333
4522
|
success: !!response,
|
|
4334
4523
|
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)
|
|
4335
4524
|
});
|
|
4336
|
-
return
|
|
4525
|
+
return _context35.abrupt("return", response);
|
|
4337
4526
|
case 18:
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
console.error('[Order] createOrderByCheckout 创建订单失败:',
|
|
4527
|
+
_context35.prev = 18;
|
|
4528
|
+
_context35.t0 = _context35["catch"](4);
|
|
4529
|
+
console.error('[Order] createOrderByCheckout 创建订单失败:', _context35.t0);
|
|
4341
4530
|
this.logInfo('Order API called failed', {
|
|
4342
|
-
error:
|
|
4531
|
+
error: _context35.t0 instanceof Error ? _context35.t0.message : String(_context35.t0)
|
|
4343
4532
|
});
|
|
4344
|
-
throw
|
|
4533
|
+
throw _context35.t0;
|
|
4345
4534
|
case 23:
|
|
4346
4535
|
case "end":
|
|
4347
|
-
return
|
|
4536
|
+
return _context35.stop();
|
|
4348
4537
|
}
|
|
4349
|
-
},
|
|
4538
|
+
}, _callee33, this, [[4, 18]]);
|
|
4350
4539
|
}));
|
|
4351
|
-
function createOrderByCheckout(
|
|
4540
|
+
function createOrderByCheckout(_x38) {
|
|
4352
4541
|
return _createOrderByCheckout.apply(this, arguments);
|
|
4353
4542
|
}
|
|
4354
4543
|
return createOrderByCheckout;
|
|
@@ -4356,24 +4545,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4356
4545
|
}, {
|
|
4357
4546
|
key: "submitSalesOrder",
|
|
4358
4547
|
value: function () {
|
|
4359
|
-
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4548
|
+
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
|
|
4360
4549
|
var url, query, fetchUrl;
|
|
4361
|
-
return _regeneratorRuntime().wrap(function
|
|
4362
|
-
while (1) switch (
|
|
4550
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context36) {
|
|
4551
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
4363
4552
|
case 0:
|
|
4364
4553
|
url = params.url, query = params.query;
|
|
4365
4554
|
fetchUrl = url || '/order/sales/checkout';
|
|
4366
|
-
return
|
|
4555
|
+
return _context36.abrupt("return", this.request.post(fetchUrl, query, {
|
|
4367
4556
|
osServer: true,
|
|
4368
4557
|
customToast: function customToast() {}
|
|
4369
4558
|
}));
|
|
4370
4559
|
case 3:
|
|
4371
4560
|
case "end":
|
|
4372
|
-
return
|
|
4561
|
+
return _context36.stop();
|
|
4373
4562
|
}
|
|
4374
|
-
},
|
|
4563
|
+
}, _callee34, this);
|
|
4375
4564
|
}));
|
|
4376
|
-
function submitSalesOrder(
|
|
4565
|
+
function submitSalesOrder(_x39) {
|
|
4377
4566
|
return _submitSalesOrder.apply(this, arguments);
|
|
4378
4567
|
}
|
|
4379
4568
|
return submitSalesOrder;
|
|
@@ -4387,37 +4576,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4387
4576
|
}, {
|
|
4388
4577
|
key: "sendCustomerPayLink",
|
|
4389
4578
|
value: (function () {
|
|
4390
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4579
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
|
|
4391
4580
|
var _params$emails;
|
|
4392
4581
|
var orderIds;
|
|
4393
|
-
return _regeneratorRuntime().wrap(function
|
|
4394
|
-
while (1) switch (
|
|
4582
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context37) {
|
|
4583
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
4395
4584
|
case 0:
|
|
4396
4585
|
orderIds = params.order_ids || params.orderIds || [];
|
|
4397
4586
|
if (orderIds.length) {
|
|
4398
|
-
|
|
4587
|
+
_context37.next = 3;
|
|
4399
4588
|
break;
|
|
4400
4589
|
}
|
|
4401
4590
|
throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
|
|
4402
4591
|
case 3:
|
|
4403
4592
|
if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
|
|
4404
|
-
|
|
4593
|
+
_context37.next = 5;
|
|
4405
4594
|
break;
|
|
4406
4595
|
}
|
|
4407
4596
|
throw new Error('发送支付链接需要至少一个邮箱');
|
|
4408
4597
|
case 5:
|
|
4409
|
-
return
|
|
4598
|
+
return _context37.abrupt("return", this.request.post('/order/batch-email', {
|
|
4410
4599
|
order_ids: orderIds,
|
|
4411
4600
|
notify_action: params.notify_action || 'order_payment_reminder',
|
|
4412
4601
|
emails: params.emails
|
|
4413
4602
|
}));
|
|
4414
4603
|
case 6:
|
|
4415
4604
|
case "end":
|
|
4416
|
-
return
|
|
4605
|
+
return _context37.stop();
|
|
4417
4606
|
}
|
|
4418
|
-
},
|
|
4607
|
+
}, _callee35, this);
|
|
4419
4608
|
}));
|
|
4420
|
-
function sendCustomerPayLink(
|
|
4609
|
+
function sendCustomerPayLink(_x40) {
|
|
4421
4610
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
4422
4611
|
}
|
|
4423
4612
|
return sendCustomerPayLink;
|
|
@@ -4425,14 +4614,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4425
4614
|
}, {
|
|
4426
4615
|
key: "getSalesOrderByLookup",
|
|
4427
4616
|
value: function () {
|
|
4428
|
-
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4617
|
+
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
|
|
4429
4618
|
var lookup, res;
|
|
4430
|
-
return _regeneratorRuntime().wrap(function
|
|
4431
|
-
while (1) switch (
|
|
4619
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context38) {
|
|
4620
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
4432
4621
|
case 0:
|
|
4433
4622
|
lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
|
|
4434
4623
|
if (lookup) {
|
|
4435
|
-
|
|
4624
|
+
_context38.next = 3;
|
|
4436
4625
|
break;
|
|
4437
4626
|
}
|
|
4438
4627
|
throw new Error('加载销售详情需要 lookup');
|
|
@@ -4441,7 +4630,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4441
4630
|
if (lookup.startsWith('LOCAL_')) {
|
|
4442
4631
|
params.forceRemote = false;
|
|
4443
4632
|
}
|
|
4444
|
-
|
|
4633
|
+
_context38.next = 6;
|
|
4445
4634
|
return this.request.get("/order/sales/".concat(encodeURIComponent(lookup)), _objectSpread({
|
|
4446
4635
|
with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info']
|
|
4447
4636
|
}, params.forceRemote ? {
|
|
@@ -4450,19 +4639,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4450
4639
|
osServer: true
|
|
4451
4640
|
});
|
|
4452
4641
|
case 6:
|
|
4453
|
-
res =
|
|
4454
|
-
debugger;
|
|
4642
|
+
res = _context38.sent;
|
|
4455
4643
|
if (res.code === 200) {
|
|
4456
4644
|
this.store.lastOrderInfo = res.data;
|
|
4457
4645
|
}
|
|
4458
|
-
return
|
|
4459
|
-
case
|
|
4646
|
+
return _context38.abrupt("return", res);
|
|
4647
|
+
case 9:
|
|
4460
4648
|
case "end":
|
|
4461
|
-
return
|
|
4649
|
+
return _context38.stop();
|
|
4462
4650
|
}
|
|
4463
|
-
},
|
|
4651
|
+
}, _callee36, this);
|
|
4464
4652
|
}));
|
|
4465
|
-
function getSalesOrderByLookup(
|
|
4653
|
+
function getSalesOrderByLookup(_x41) {
|
|
4466
4654
|
return _getSalesOrderByLookup.apply(this, arguments);
|
|
4467
4655
|
}
|
|
4468
4656
|
return getSalesOrderByLookup;
|
|
@@ -4476,11 +4664,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4476
4664
|
}, {
|
|
4477
4665
|
key: "hydrateTempOrderFromRecord",
|
|
4478
4666
|
value: (function () {
|
|
4479
|
-
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4667
|
+
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(record, options) {
|
|
4480
4668
|
var _this$store$discount13;
|
|
4481
4669
|
var raw, nextTempOrder, rawSummary, summarySurcharges, hydratedEditDiscounts, currentDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount14, _this$store$discount15;
|
|
4482
|
-
return _regeneratorRuntime().wrap(function
|
|
4483
|
-
while (1) switch (
|
|
4670
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context39) {
|
|
4671
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
4484
4672
|
case 0:
|
|
4485
4673
|
raw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
|
|
4486
4674
|
nextTempOrder = this.normalizeTempOrderForRuntime(raw);
|
|
@@ -4506,33 +4694,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4506
4694
|
currentDiscounts = typeof ((_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.getDiscountList) === 'function' ? this.store.discount.getDiscountList() || [] : [];
|
|
4507
4695
|
shouldSkipEmptyDiscountSync = hydratedEditDiscounts.length === 0 && currentDiscounts.length === 0;
|
|
4508
4696
|
if (shouldSkipEmptyDiscountSync) {
|
|
4509
|
-
|
|
4697
|
+
_context39.next = 16;
|
|
4510
4698
|
break;
|
|
4511
4699
|
}
|
|
4512
|
-
|
|
4700
|
+
_context39.next = 14;
|
|
4513
4701
|
return (_this$store$discount14 = this.store.discount) === null || _this$store$discount14 === void 0 ? void 0 : _this$store$discount14.setOriginalDiscountList(hydratedEditDiscounts);
|
|
4514
4702
|
case 14:
|
|
4515
|
-
|
|
4703
|
+
_context39.next = 16;
|
|
4516
4704
|
return (_this$store$discount15 = this.store.discount) === null || _this$store$discount15 === void 0 ? void 0 : _this$store$discount15.setDiscountList(hydratedEditDiscounts);
|
|
4517
4705
|
case 16:
|
|
4518
4706
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
4519
|
-
|
|
4707
|
+
_context39.next = 19;
|
|
4520
4708
|
break;
|
|
4521
4709
|
}
|
|
4522
|
-
|
|
4710
|
+
_context39.next = 19;
|
|
4523
4711
|
return this.recalculateSummary({
|
|
4524
4712
|
createIfMissing: false
|
|
4525
4713
|
});
|
|
4526
4714
|
case 19:
|
|
4527
4715
|
this.persistTempOrder();
|
|
4528
|
-
return
|
|
4716
|
+
return _context39.abrupt("return", nextTempOrder);
|
|
4529
4717
|
case 21:
|
|
4530
4718
|
case "end":
|
|
4531
|
-
return
|
|
4719
|
+
return _context39.stop();
|
|
4532
4720
|
}
|
|
4533
|
-
},
|
|
4721
|
+
}, _callee37, this);
|
|
4534
4722
|
}));
|
|
4535
|
-
function hydrateTempOrderFromRecord(
|
|
4723
|
+
function hydrateTempOrderFromRecord(_x42, _x43) {
|
|
4536
4724
|
return _hydrateTempOrderFromRecord.apply(this, arguments);
|
|
4537
4725
|
}
|
|
4538
4726
|
return hydrateTempOrderFromRecord;
|
|
@@ -4587,19 +4775,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4587
4775
|
};
|
|
4588
4776
|
var tempOrderExtend = nextTempOrder._extend;
|
|
4589
4777
|
var productsByUid = tempOrderExtend.productsByUid || {};
|
|
4590
|
-
var
|
|
4591
|
-
|
|
4778
|
+
var _iterator21 = _createForOfIteratorHelper(nextTempOrder.products.entries()),
|
|
4779
|
+
_step21;
|
|
4592
4780
|
try {
|
|
4593
|
-
for (
|
|
4594
|
-
var _product$
|
|
4595
|
-
var
|
|
4596
|
-
index =
|
|
4597
|
-
product =
|
|
4598
|
-
var uid = (_product$
|
|
4781
|
+
for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {
|
|
4782
|
+
var _product$metadata8, _ref71, _ref72, _existed$origin, _rawProduct$metadata;
|
|
4783
|
+
var _step21$value = _slicedToArray(_step21.value, 2),
|
|
4784
|
+
index = _step21$value[0],
|
|
4785
|
+
product = _step21$value[1];
|
|
4786
|
+
var uid = (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.unique_identification_number;
|
|
4599
4787
|
if (!uid) continue;
|
|
4600
4788
|
var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
|
|
4601
4789
|
var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
|
|
4602
|
-
var origin = (
|
|
4790
|
+
var origin = (_ref71 = (_ref72 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref72 !== void 0 ? _ref72 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref71 !== void 0 ? _ref71 : rawProduct;
|
|
4603
4791
|
var originSnapshot = cloneDeep(origin);
|
|
4604
4792
|
var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
|
|
4605
4793
|
if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
|
|
@@ -4615,9 +4803,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4615
4803
|
});
|
|
4616
4804
|
}
|
|
4617
4805
|
} catch (err) {
|
|
4618
|
-
|
|
4806
|
+
_iterator21.e(err);
|
|
4619
4807
|
} finally {
|
|
4620
|
-
|
|
4808
|
+
_iterator21.f();
|
|
4621
4809
|
}
|
|
4622
4810
|
tempOrderExtend.productsByUid = productsByUid;
|
|
4623
4811
|
if ((options === null || options === void 0 ? void 0 : options.ensureIdentity) !== false) {
|
|
@@ -4648,18 +4836,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4648
4836
|
var segments = [];
|
|
4649
4837
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
4650
4838
|
if (Array.isArray(sku.variant)) {
|
|
4651
|
-
var
|
|
4652
|
-
|
|
4839
|
+
var _iterator22 = _createForOfIteratorHelper(sku.variant),
|
|
4840
|
+
_step22;
|
|
4653
4841
|
try {
|
|
4654
|
-
for (
|
|
4655
|
-
var variant =
|
|
4842
|
+
for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
|
|
4843
|
+
var variant = _step22.value;
|
|
4656
4844
|
var segment = this.formatHydratedNamePair(variant === null || variant === void 0 ? void 0 : variant.group, variant === null || variant === void 0 ? void 0 : variant.item);
|
|
4657
4845
|
if (segment) segments.push(segment);
|
|
4658
4846
|
}
|
|
4659
4847
|
} catch (err) {
|
|
4660
|
-
|
|
4848
|
+
_iterator22.e(err);
|
|
4661
4849
|
} finally {
|
|
4662
|
-
|
|
4850
|
+
_iterator22.f();
|
|
4663
4851
|
}
|
|
4664
4852
|
}
|
|
4665
4853
|
return segments.join(', ');
|
|
@@ -4667,10 +4855,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4667
4855
|
}, {
|
|
4668
4856
|
key: "normalizeHydratedProductOptionItem",
|
|
4669
4857
|
value: function normalizeHydratedProductOptionItem(optionItem) {
|
|
4670
|
-
var
|
|
4671
|
-
var rawNum = (
|
|
4858
|
+
var _ref73, _optionItem$num, _ref74, _optionItem$add_price;
|
|
4859
|
+
var rawNum = (_ref73 = (_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 && _ref73 !== void 0 ? _ref73 : 1;
|
|
4672
4860
|
var parsedNum = Number(rawNum);
|
|
4673
|
-
var rawPrice = (
|
|
4861
|
+
var rawPrice = (_ref74 = (_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 && _ref74 !== void 0 ? _ref74 : 0;
|
|
4674
4862
|
var parsedPrice = Number(rawPrice);
|
|
4675
4863
|
var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
|
|
4676
4864
|
option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
|
|
@@ -4726,25 +4914,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4726
4914
|
}, {
|
|
4727
4915
|
key: "getOrderInfo",
|
|
4728
4916
|
value: function () {
|
|
4729
|
-
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4917
|
+
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(order_id) {
|
|
4730
4918
|
var res;
|
|
4731
|
-
return _regeneratorRuntime().wrap(function
|
|
4732
|
-
while (1) switch (
|
|
4919
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context40) {
|
|
4920
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
4733
4921
|
case 0:
|
|
4734
|
-
|
|
4922
|
+
_context40.next = 2;
|
|
4735
4923
|
return this.request.get("/order/sales/".concat(order_id), {
|
|
4736
4924
|
with: ['products', 'bookings']
|
|
4737
4925
|
});
|
|
4738
4926
|
case 2:
|
|
4739
|
-
res =
|
|
4740
|
-
return
|
|
4927
|
+
res = _context40.sent;
|
|
4928
|
+
return _context40.abrupt("return", res);
|
|
4741
4929
|
case 4:
|
|
4742
4930
|
case "end":
|
|
4743
|
-
return
|
|
4931
|
+
return _context40.stop();
|
|
4744
4932
|
}
|
|
4745
|
-
},
|
|
4933
|
+
}, _callee38, this);
|
|
4746
4934
|
}));
|
|
4747
|
-
function getOrderInfo(
|
|
4935
|
+
function getOrderInfo(_x44) {
|
|
4748
4936
|
return _getOrderInfo.apply(this, arguments);
|
|
4749
4937
|
}
|
|
4750
4938
|
return getOrderInfo;
|
|
@@ -4761,67 +4949,67 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4761
4949
|
var amount = new Decimal(discount.amount || 0).times(qty).plus(((_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.product_discount_difference) || 0);
|
|
4762
4950
|
savedMap.set(discountKey, (savedMap.get(discountKey) || new Decimal(0)).plus(amount));
|
|
4763
4951
|
};
|
|
4764
|
-
var
|
|
4765
|
-
|
|
4952
|
+
var _iterator23 = _createForOfIteratorHelper(productList),
|
|
4953
|
+
_step23;
|
|
4766
4954
|
try {
|
|
4767
|
-
for (
|
|
4768
|
-
var product =
|
|
4955
|
+
for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {
|
|
4956
|
+
var product = _step23.value;
|
|
4769
4957
|
var qty = product.num || 1;
|
|
4770
|
-
var
|
|
4771
|
-
|
|
4958
|
+
var _iterator25 = _createForOfIteratorHelper(product.discount_list || []),
|
|
4959
|
+
_step25;
|
|
4772
4960
|
try {
|
|
4773
|
-
for (
|
|
4774
|
-
var pd =
|
|
4961
|
+
for (_iterator25.s(); !(_step25 = _iterator25.n()).done;) {
|
|
4962
|
+
var pd = _step25.value;
|
|
4775
4963
|
addDiscountAmount(pd, qty);
|
|
4776
4964
|
}
|
|
4777
4965
|
} catch (err) {
|
|
4778
|
-
|
|
4966
|
+
_iterator25.e(err);
|
|
4779
4967
|
} finally {
|
|
4780
|
-
|
|
4968
|
+
_iterator25.f();
|
|
4781
4969
|
}
|
|
4782
|
-
var
|
|
4783
|
-
|
|
4970
|
+
var _iterator26 = _createForOfIteratorHelper(product.product_bundle || []),
|
|
4971
|
+
_step26;
|
|
4784
4972
|
try {
|
|
4785
|
-
for (
|
|
4786
|
-
var
|
|
4787
|
-
var bundle =
|
|
4788
|
-
var bundleQty = new Decimal(Number(qty) || 1).times(Number((
|
|
4789
|
-
var
|
|
4790
|
-
|
|
4973
|
+
for (_iterator26.s(); !(_step26 = _iterator26.n()).done;) {
|
|
4974
|
+
var _ref75, _bundle$num3;
|
|
4975
|
+
var bundle = _step26.value;
|
|
4976
|
+
var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref75 = (_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 && _ref75 !== void 0 ? _ref75 : 1) || 1).toNumber();
|
|
4977
|
+
var _iterator27 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
|
|
4978
|
+
_step27;
|
|
4791
4979
|
try {
|
|
4792
|
-
for (
|
|
4793
|
-
var _pd =
|
|
4980
|
+
for (_iterator27.s(); !(_step27 = _iterator27.n()).done;) {
|
|
4981
|
+
var _pd = _step27.value;
|
|
4794
4982
|
addDiscountAmount(_pd, bundleQty);
|
|
4795
4983
|
}
|
|
4796
4984
|
} catch (err) {
|
|
4797
|
-
|
|
4985
|
+
_iterator27.e(err);
|
|
4798
4986
|
} finally {
|
|
4799
|
-
|
|
4987
|
+
_iterator27.f();
|
|
4800
4988
|
}
|
|
4801
4989
|
}
|
|
4802
4990
|
} catch (err) {
|
|
4803
|
-
|
|
4991
|
+
_iterator26.e(err);
|
|
4804
4992
|
} finally {
|
|
4805
|
-
|
|
4993
|
+
_iterator26.f();
|
|
4806
4994
|
}
|
|
4807
4995
|
}
|
|
4808
4996
|
} catch (err) {
|
|
4809
|
-
|
|
4997
|
+
_iterator23.e(err);
|
|
4810
4998
|
} finally {
|
|
4811
|
-
|
|
4999
|
+
_iterator23.f();
|
|
4812
5000
|
}
|
|
4813
|
-
var
|
|
4814
|
-
|
|
5001
|
+
var _iterator24 = _createForOfIteratorHelper(discountList),
|
|
5002
|
+
_step24;
|
|
4815
5003
|
try {
|
|
4816
|
-
for (
|
|
4817
|
-
var d =
|
|
5004
|
+
for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
|
|
5005
|
+
var d = _step24.value;
|
|
4818
5006
|
var key = d.id;
|
|
4819
5007
|
d.savedAmount = d.isSelected && key != null && savedMap.has(key) ? savedMap.get(key).toNumber() : 0;
|
|
4820
5008
|
}
|
|
4821
5009
|
} catch (err) {
|
|
4822
|
-
|
|
5010
|
+
_iterator24.e(err);
|
|
4823
5011
|
} finally {
|
|
4824
|
-
|
|
5012
|
+
_iterator24.f();
|
|
4825
5013
|
}
|
|
4826
5014
|
}
|
|
4827
5015
|
}]);
|