@pisell/pisellos 2.3.191 → 2.3.193
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 +0 -9
- package/dist/modules/BookingContext/index.d.ts +2 -2
- package/dist/modules/BookingContext/index.js +55 -25
- package/dist/modules/BookingContext/types.d.ts +2 -0
- package/dist/modules/Order/index.d.ts +13 -5
- package/dist/modules/Order/index.js +1053 -554
- package/dist/modules/Order/types.d.ts +20 -1
- package/dist/modules/Order/types.js +4 -0
- package/dist/modules/Order/utils.d.ts +3 -1
- package/dist/modules/Order/utils.js +5 -2
- package/dist/modules/ProductList/clientDataVariants.js +6 -2
- package/dist/modules/ProductList/index.d.ts +2 -0
- package/dist/modules/ProductList/index.js +125 -39
- package/dist/modules/ResourcePlanner/planner.js +5 -0
- package/dist/modules/Rules/index.js +30 -19
- package/dist/server/index.js +5 -2
- package/dist/solution/BaseSales/index.d.ts +14 -3
- package/dist/solution/BaseSales/index.js +285 -195
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/UnifiedBookingSales/catalogQueryBatch.d.ts +21 -0
- package/dist/solution/UnifiedBookingSales/catalogQueryBatch.js +202 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +49 -1
- package/dist/solution/UnifiedBookingSales/index.js +2276 -902
- package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +2 -0
- package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.js +4 -0
- package/dist/solution/UnifiedBookingSales/sessionResourceCache.d.ts +27 -0
- package/dist/solution/UnifiedBookingSales/sessionResourceCache.js +271 -0
- package/dist/solution/UnifiedBookingSales/types.d.ts +64 -1
- package/dist/solution/UnifiedBookingSales/types.js +7 -1
- package/dist/solution/UnifiedBookingSales/venueCatalogSession.d.ts +32 -0
- package/dist/solution/UnifiedBookingSales/venueCatalogSession.js +277 -0
- package/lib/modules/BookingContext/index.d.ts +2 -2
- package/lib/modules/BookingContext/index.js +42 -10
- package/lib/modules/BookingContext/types.d.ts +2 -0
- package/lib/modules/Order/index.d.ts +13 -5
- package/lib/modules/Order/index.js +208 -7
- package/lib/modules/Order/types.d.ts +20 -1
- package/lib/modules/Order/types.js +2 -0
- package/lib/modules/Order/utils.d.ts +3 -1
- package/lib/modules/Order/utils.js +5 -2
- package/lib/modules/ProductList/clientDataVariants.js +6 -2
- package/lib/modules/ProductList/index.d.ts +2 -0
- package/lib/modules/ProductList/index.js +56 -0
- package/lib/modules/ResourcePlanner/planner.js +4 -0
- package/lib/modules/Rules/index.js +19 -9
- package/lib/server/index.js +5 -1
- package/lib/solution/BaseSales/index.d.ts +14 -3
- package/lib/solution/BaseSales/index.js +67 -2
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/UnifiedBookingSales/catalogQueryBatch.d.ts +21 -0
- package/lib/solution/UnifiedBookingSales/catalogQueryBatch.js +109 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +49 -1
- package/lib/solution/UnifiedBookingSales/index.js +872 -55
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +2 -0
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +2 -0
- package/lib/solution/UnifiedBookingSales/sessionResourceCache.d.ts +27 -0
- package/lib/solution/UnifiedBookingSales/sessionResourceCache.js +199 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +64 -1
- package/lib/solution/UnifiedBookingSales/types.js +4 -1
- package/lib/solution/UnifiedBookingSales/venueCatalogSession.d.ts +32 -0
- package/lib/solution/UnifiedBookingSales/venueCatalogSession.js +151 -0
- package/package.json +1 -1
|
@@ -5987,6 +5987,312 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5987
5987
|
}
|
|
5988
5988
|
return addProductToOrderDraft;
|
|
5989
5989
|
}()
|
|
5990
|
+
/**
|
|
5991
|
+
* Replaces one local Party booking and its confirmed children on a detached draft.
|
|
5992
|
+
* All fallible preparation precedes a guarded synchronous publication; never rolls
|
|
5993
|
+
* an old whole-order snapshot over concurrent edits or a newly selected order.
|
|
5994
|
+
*/
|
|
5995
|
+
}, {
|
|
5996
|
+
key: "replaceBookingProductWithRelatedRetail",
|
|
5997
|
+
value: (function () {
|
|
5998
|
+
var _replaceBookingProductWithRelatedRetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
|
|
5999
|
+
var _this40 = this;
|
|
6000
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context30) {
|
|
6001
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
6002
|
+
case 0:
|
|
6003
|
+
return _context30.abrupt("return", this.queueCartCommand(function () {
|
|
6004
|
+
return _this40.replaceBookingProductWithRelatedRetailDraft(params);
|
|
6005
|
+
}));
|
|
6006
|
+
case 1:
|
|
6007
|
+
case "end":
|
|
6008
|
+
return _context30.stop();
|
|
6009
|
+
}
|
|
6010
|
+
}, _callee29, this);
|
|
6011
|
+
}));
|
|
6012
|
+
function replaceBookingProductWithRelatedRetail(_x34) {
|
|
6013
|
+
return _replaceBookingProductWithRelatedRetail.apply(this, arguments);
|
|
6014
|
+
}
|
|
6015
|
+
return replaceBookingProductWithRelatedRetail;
|
|
6016
|
+
}())
|
|
6017
|
+
}, {
|
|
6018
|
+
key: "replaceBookingProductWithRelatedRetailDraft",
|
|
6019
|
+
value: function () {
|
|
6020
|
+
var _replaceBookingProductWithRelatedRetailDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
|
|
6021
|
+
var _target$metadata,
|
|
6022
|
+
_target$metadata2,
|
|
6023
|
+
_params$product$num,
|
|
6024
|
+
_target$metadata3,
|
|
6025
|
+
_params$product$metad,
|
|
6026
|
+
_params$product$metad2,
|
|
6027
|
+
_params$booking$metad,
|
|
6028
|
+
_this41 = this;
|
|
6029
|
+
var live, mutation, beforeCommit, uid, getUid, targetIndex, target, scopeKey, targetBookingUid, children, start, serviceDatetime, ownedUids, nextUids, retainedChildUids, nextChildren, _iterator23, _step23, _loop2, publishedFields, guardedFields, readFields, baseline, identity, isCurrentOrder, draft, removed, _iterator24, _step24, line, _iterator25, _step25, _draft$_extend, _line, replacement, _iterator26, _step26, _step26$value, index, child, beforePublish;
|
|
6030
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context32) {
|
|
6031
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
6032
|
+
case 0:
|
|
6033
|
+
params.availabilityCommitGuard();
|
|
6034
|
+
live = this.ensureTempOrder();
|
|
6035
|
+
mutation = this.beginCartMutation();
|
|
6036
|
+
beforeCommit = this.createCartIntentCommitGuard('update_product', live);
|
|
6037
|
+
uid = String(params.productLineUid || '');
|
|
6038
|
+
getUid = function getUid(line) {
|
|
6039
|
+
var _line$metadata2;
|
|
6040
|
+
return String(((_line$metadata2 = line.metadata) === null || _line$metadata2 === void 0 ? void 0 : _line$metadata2.unique_identification_number) || line.unique_identification_number || '');
|
|
6041
|
+
};
|
|
6042
|
+
targetIndex = live.products.findIndex(function (line) {
|
|
6043
|
+
return getUid(line) === uid;
|
|
6044
|
+
});
|
|
6045
|
+
target = live.products[targetIndex];
|
|
6046
|
+
scopeKey = String((target === null || target === void 0 || (_target$metadata = target.metadata) === null || _target$metadata === void 0 ? void 0 : _target$metadata.venue_booking_scope_key) || '');
|
|
6047
|
+
targetBookingUid = String((target === null || target === void 0 ? void 0 : target.booking_uid) || (target === null || target === void 0 || (_target$metadata2 = target.metadata) === null || _target$metadata2 === void 0 ? void 0 : _target$metadata2.booking_uid) || '');
|
|
6048
|
+
if (!(!uid || !target || !scopeKey || live.order_id || target.order_detail_id != null || Number(target.num) !== 1 || Number((_params$product$num = params.product.num) !== null && _params$product$num !== void 0 ? _params$product$num : 1) !== 1 || ((_target$metadata3 = target.metadata) === null || _target$metadata3 === void 0 ? void 0 : _target$metadata3.venue_booking_role) !== 'party_main' || ((_params$product$metad = params.product.metadata) === null || _params$product$metad === void 0 ? void 0 : _params$product$metad.venue_booking_role) !== 'party_main' || ((_params$product$metad2 = params.product.metadata) === null || _params$product$metad2 === void 0 ? void 0 : _params$product$metad2.venue_booking_scope_key) !== scopeKey || !Array.isArray(params.relatedRetailProducts) || (live.payments || []).length > 0 || !targetBookingUid || String(((_params$booking$metad = params.booking.metadata) === null || _params$booking$metad === void 0 ? void 0 : _params$booking$metad.unique_identification_number) || '') !== targetBookingUid || (live.bookings || []).filter(function (booking) {
|
|
6049
|
+
return _this41.getBookingUniqueIdentificationNumber(booking) === targetBookingUid;
|
|
6050
|
+
}).length !== 1 || live.products.filter(function (line) {
|
|
6051
|
+
var _line$metadata3, _line$metadata4;
|
|
6052
|
+
return ((_line$metadata3 = line.metadata) === null || _line$metadata3 === void 0 ? void 0 : _line$metadata3.venue_booking_role) === 'party_main' && ((_line$metadata4 = line.metadata) === null || _line$metadata4 === void 0 ? void 0 : _line$metadata4.venue_booking_scope_key) === scopeKey;
|
|
6053
|
+
}).length !== 1)) {
|
|
6054
|
+
_context32.next = 12;
|
|
6055
|
+
break;
|
|
6056
|
+
}
|
|
6057
|
+
throw new Error('[Order] Party replacement requires one unsubmitted, unpaid main booking in the same scope');
|
|
6058
|
+
case 12:
|
|
6059
|
+
children = live.products.filter(function (line) {
|
|
6060
|
+
var _line$metadata5, _line$metadata6;
|
|
6061
|
+
return ((_line$metadata5 = line.metadata) === null || _line$metadata5 === void 0 ? void 0 : _line$metadata5.venue_booking_role) === 'party_extra' && String(((_line$metadata6 = line.metadata) === null || _line$metadata6 === void 0 ? void 0 : _line$metadata6.venue_booking_parent_uid) || '') === uid;
|
|
6062
|
+
});
|
|
6063
|
+
if (!children.some(function (line) {
|
|
6064
|
+
var _line$metadata7;
|
|
6065
|
+
return !getUid(line) || ((_line$metadata7 = line.metadata) === null || _line$metadata7 === void 0 ? void 0 : _line$metadata7.venue_booking_scope_key) !== scopeKey || line.order_detail_id != null || _this41.hasLinkedBookingUid(line);
|
|
6066
|
+
})) {
|
|
6067
|
+
_context32.next = 15;
|
|
6068
|
+
break;
|
|
6069
|
+
}
|
|
6070
|
+
throw new Error('[Order] Related retail line does not belong to this local Party scope');
|
|
6071
|
+
case 15:
|
|
6072
|
+
start = params.booking.start_at || "".concat(params.booking.start_date || '', " ").concat(params.booking.start_time || '').trim();
|
|
6073
|
+
if (!(!start || !dayjs(start).isValid())) {
|
|
6074
|
+
_context32.next = 18;
|
|
6075
|
+
break;
|
|
6076
|
+
}
|
|
6077
|
+
throw new Error('[Order] Party service datetime is required');
|
|
6078
|
+
case 18:
|
|
6079
|
+
serviceDatetime = dayjs(start).format('YYYY-MM-DD HH:mm:ss');
|
|
6080
|
+
ownedUids = new Set(children.map(getUid));
|
|
6081
|
+
nextUids = new Set();
|
|
6082
|
+
retainedChildUids = new Set();
|
|
6083
|
+
nextChildren = cloneDeep(params.relatedRetailProducts);
|
|
6084
|
+
_iterator23 = _createForOfIteratorHelper(nextChildren);
|
|
6085
|
+
_context32.prev = 24;
|
|
6086
|
+
_loop2 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop2() {
|
|
6087
|
+
var _child$metadata, _child$metadata2, _child$metadata3, _child$metadata4, _child$num;
|
|
6088
|
+
var child, childUid, purchaseDatetime, normalizedPurchaseDatetime, previous, _live$_extend, _rawChild$_origin, previousForms, rawChild;
|
|
6089
|
+
return _regeneratorRuntime().wrap(function _loop2$(_context31) {
|
|
6090
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
6091
|
+
case 0:
|
|
6092
|
+
child = _step23.value;
|
|
6093
|
+
childUid = getUid(child);
|
|
6094
|
+
purchaseDatetime = String(((_child$metadata = child.metadata) === null || _child$metadata === void 0 ? void 0 : _child$metadata.venue_booking_service_datetime) || '');
|
|
6095
|
+
normalizedPurchaseDatetime = purchaseDatetime.length === 16 ? "".concat(purchaseDatetime, ":00") : purchaseDatetime;
|
|
6096
|
+
if (!(((_child$metadata2 = child.metadata) === null || _child$metadata2 === void 0 ? void 0 : _child$metadata2.venue_booking_role) !== 'party_extra' || String(((_child$metadata3 = child.metadata) === null || _child$metadata3 === void 0 ? void 0 : _child$metadata3.venue_booking_parent_uid) || '') !== uid || ((_child$metadata4 = child.metadata) === null || _child$metadata4 === void 0 ? void 0 : _child$metadata4.venue_booking_scope_key) !== scopeKey || !/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(:\d{2})?$/.test(purchaseDatetime) || !dayjs(purchaseDatetime).isValid() || dayjs(purchaseDatetime).format('YYYY-MM-DD HH:mm:ss') !== normalizedPurchaseDatetime || _this41.hasLinkedBookingUid(child) || child.order_detail_id != null || childUid && (nextUids.has(childUid) || live.products.some(function (line) {
|
|
6097
|
+
return getUid(line) === childUid && !ownedUids.has(childUid);
|
|
6098
|
+
})))) {
|
|
6099
|
+
_context31.next = 6;
|
|
6100
|
+
break;
|
|
6101
|
+
}
|
|
6102
|
+
throw new Error('[Order] Invalid Party extra ownership, identity, or purchase quote datetime');
|
|
6103
|
+
case 6:
|
|
6104
|
+
if (childUid) nextUids.add(childUid);
|
|
6105
|
+
previous = children.find(function (line) {
|
|
6106
|
+
return getUid(line) === childUid;
|
|
6107
|
+
});
|
|
6108
|
+
if (previous && previous.product_id === child.product_id && Number(previous.product_variant_id || 0) === Number(child.product_variant_id || 0) && Number(previous.num) === Number((_child$num = child.num) !== null && _child$num !== void 0 ? _child$num : 1) && buildProductLineFingerprint(getProductSkuOptions(previous), previous.product_bundle) === buildProductLineFingerprint(getProductSkuOptions(child), child.product_bundle)) {
|
|
6109
|
+
retainedChildUids.add(childUid);
|
|
6110
|
+
// The same configured extra keeps completed product forms unless explicitly replaced.
|
|
6111
|
+
previousForms = (_live$_extend = live._extend) === null || _live$_extend === void 0 || (_live$_extend = _live$_extend.productsByUid) === null || _live$_extend === void 0 || (_live$_extend = _live$_extend[childUid]) === null || _live$_extend === void 0 || (_live$_extend = _live$_extend.origin) === null || _live$_extend === void 0 ? void 0 : _live$_extend.relation_forms;
|
|
6112
|
+
rawChild = child;
|
|
6113
|
+
if (previousForms !== undefined && ((_rawChild$_origin = rawChild._origin) === null || _rawChild$_origin === void 0 ? void 0 : _rawChild$_origin.relation_forms) === undefined) {
|
|
6114
|
+
rawChild._origin = _objectSpread(_objectSpread({}, rawChild._origin || {}), {}, {
|
|
6115
|
+
relation_forms: cloneDeep(previousForms)
|
|
6116
|
+
});
|
|
6117
|
+
}
|
|
6118
|
+
}
|
|
6119
|
+
case 9:
|
|
6120
|
+
case "end":
|
|
6121
|
+
return _context31.stop();
|
|
6122
|
+
}
|
|
6123
|
+
}, _loop2);
|
|
6124
|
+
});
|
|
6125
|
+
_iterator23.s();
|
|
6126
|
+
case 27:
|
|
6127
|
+
if ((_step23 = _iterator23.n()).done) {
|
|
6128
|
+
_context32.next = 31;
|
|
6129
|
+
break;
|
|
6130
|
+
}
|
|
6131
|
+
return _context32.delegateYield(_loop2(), "t0", 29);
|
|
6132
|
+
case 29:
|
|
6133
|
+
_context32.next = 27;
|
|
6134
|
+
break;
|
|
6135
|
+
case 31:
|
|
6136
|
+
_context32.next = 36;
|
|
6137
|
+
break;
|
|
6138
|
+
case 33:
|
|
6139
|
+
_context32.prev = 33;
|
|
6140
|
+
_context32.t1 = _context32["catch"](24);
|
|
6141
|
+
_iterator23.e(_context32.t1);
|
|
6142
|
+
case 36:
|
|
6143
|
+
_context32.prev = 36;
|
|
6144
|
+
_iterator23.f();
|
|
6145
|
+
return _context32.finish(36);
|
|
6146
|
+
case 39:
|
|
6147
|
+
publishedFields = ['products', 'bookings', 'notes', '_extend', 'metadata', 'holder', 'holder_relations', 'currency_code', 'currency_symbol', 'currency_format'];
|
|
6148
|
+
guardedFields = [].concat(publishedFields, ['customer_id', 'discount_list', 'shop_discount', 'payments']);
|
|
6149
|
+
readFields = function readFields(order, fields) {
|
|
6150
|
+
return Object.fromEntries(fields.map(function (key) {
|
|
6151
|
+
return [key, order[key]];
|
|
6152
|
+
}));
|
|
6153
|
+
};
|
|
6154
|
+
baseline = cloneDeep(readFields(live, guardedFields));
|
|
6155
|
+
identity = [live.order_id, live.external_sale_number];
|
|
6156
|
+
isCurrentOrder = function isCurrentOrder() {
|
|
6157
|
+
var _params$availabilityC, _params$availabilityC2;
|
|
6158
|
+
return _this41.store.tempOrder === live && live.order_id === identity[0] && live.external_sale_number === identity[1] && ((_params$availabilityC = (_params$availabilityC2 = params.availabilityCommitTargetGuard) === null || _params$availabilityC2 === void 0 ? void 0 : _params$availabilityC2.call(params)) !== null && _params$availabilityC !== void 0 ? _params$availabilityC : true);
|
|
6159
|
+
};
|
|
6160
|
+
draft = mutation.commit ? mutation.draft : cloneDeep(live);
|
|
6161
|
+
this.ensureSalesNotesLoadedForMutation(draft);
|
|
6162
|
+
removed = draft.products.filter(function (line) {
|
|
6163
|
+
return getUid(line) === uid || ownedUids.has(getUid(line));
|
|
6164
|
+
});
|
|
6165
|
+
draft.products = draft.products.filter(function (line) {
|
|
6166
|
+
return getUid(line) !== uid && !ownedUids.has(getUid(line));
|
|
6167
|
+
});
|
|
6168
|
+
_iterator24 = _createForOfIteratorHelper(removed);
|
|
6169
|
+
try {
|
|
6170
|
+
for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
|
|
6171
|
+
line = _step24.value;
|
|
6172
|
+
this.removeLinkedBookingsForProduct(draft, line);
|
|
6173
|
+
}
|
|
6174
|
+
} catch (err) {
|
|
6175
|
+
_iterator24.e(err);
|
|
6176
|
+
} finally {
|
|
6177
|
+
_iterator24.f();
|
|
6178
|
+
}
|
|
6179
|
+
removeProductHolderRelations(draft, removed.filter(function (line) {
|
|
6180
|
+
return !retainedChildUids.has(getUid(line));
|
|
6181
|
+
}));
|
|
6182
|
+
_iterator25 = _createForOfIteratorHelper(removed);
|
|
6183
|
+
try {
|
|
6184
|
+
for (_iterator25.s(); !(_step25 = _iterator25.n()).done;) {
|
|
6185
|
+
_line = _step25.value;
|
|
6186
|
+
if ((_draft$_extend = draft._extend) !== null && _draft$_extend !== void 0 && _draft$_extend.productsByUid && !retainedChildUids.has(getUid(_line))) {
|
|
6187
|
+
delete draft._extend.productsByUid[getUid(_line)];
|
|
6188
|
+
}
|
|
6189
|
+
}
|
|
6190
|
+
} catch (err) {
|
|
6191
|
+
_iterator25.e(err);
|
|
6192
|
+
} finally {
|
|
6193
|
+
_iterator25.f();
|
|
6194
|
+
}
|
|
6195
|
+
replacement = cloneDeep(params.product);
|
|
6196
|
+
replacement.metadata = _objectSpread(_objectSpread({}, replacement.metadata || {}), {}, {
|
|
6197
|
+
unique_identification_number: uid,
|
|
6198
|
+
venue_booking_service_datetime: serviceDatetime
|
|
6199
|
+
});
|
|
6200
|
+
replacement.unique_identification_number = uid;
|
|
6201
|
+
_context32.next = 59;
|
|
6202
|
+
return this.appendProductLineToTempOrder(draft, replacement, cloneDeep(params.booking), {
|
|
6203
|
+
insertAtIndex: targetIndex,
|
|
6204
|
+
disableMerge: true,
|
|
6205
|
+
beforeCommit: beforeCommit
|
|
6206
|
+
});
|
|
6207
|
+
case 59:
|
|
6208
|
+
_iterator26 = _createForOfIteratorHelper(nextChildren.entries());
|
|
6209
|
+
_context32.prev = 60;
|
|
6210
|
+
_iterator26.s();
|
|
6211
|
+
case 62:
|
|
6212
|
+
if ((_step26 = _iterator26.n()).done) {
|
|
6213
|
+
_context32.next = 68;
|
|
6214
|
+
break;
|
|
6215
|
+
}
|
|
6216
|
+
_step26$value = _slicedToArray(_step26.value, 2), index = _step26$value[0], child = _step26$value[1];
|
|
6217
|
+
_context32.next = 66;
|
|
6218
|
+
return this.appendProductLineToTempOrder(draft, child, undefined, {
|
|
6219
|
+
insertAtIndex: targetIndex + index + 1,
|
|
6220
|
+
disableMerge: true,
|
|
6221
|
+
beforeCommit: beforeCommit
|
|
6222
|
+
});
|
|
6223
|
+
case 66:
|
|
6224
|
+
_context32.next = 62;
|
|
6225
|
+
break;
|
|
6226
|
+
case 68:
|
|
6227
|
+
_context32.next = 73;
|
|
6228
|
+
break;
|
|
6229
|
+
case 70:
|
|
6230
|
+
_context32.prev = 70;
|
|
6231
|
+
_context32.t2 = _context32["catch"](60);
|
|
6232
|
+
_iterator26.e(_context32.t2);
|
|
6233
|
+
case 73:
|
|
6234
|
+
_context32.prev = 73;
|
|
6235
|
+
_iterator26.f();
|
|
6236
|
+
return _context32.finish(73);
|
|
6237
|
+
case 76:
|
|
6238
|
+
this.removeSalesNotesForMissingProductLines(draft);
|
|
6239
|
+
this.syncTempOrderHolderFromBookings(draft);
|
|
6240
|
+
beforePublish = function beforePublish() {
|
|
6241
|
+
params.availabilityCommitGuard();
|
|
6242
|
+
beforeCommit();
|
|
6243
|
+
if (!isCurrentOrder() || !isEqual(readFields(live, guardedFields), baseline)) {
|
|
6244
|
+
throw Object.assign(new Error('Party replacement interrupted by an order change'), {
|
|
6245
|
+
code: 'AVAILABILITY_SELECTION_STALE'
|
|
6246
|
+
});
|
|
6247
|
+
}
|
|
6248
|
+
};
|
|
6249
|
+
beforePublish();
|
|
6250
|
+
if (!mutation.commit) {
|
|
6251
|
+
_context32.next = 85;
|
|
6252
|
+
break;
|
|
6253
|
+
}
|
|
6254
|
+
_context32.next = 83;
|
|
6255
|
+
return mutation.commit({
|
|
6256
|
+
beforeCommit: beforePublish
|
|
6257
|
+
});
|
|
6258
|
+
case 83:
|
|
6259
|
+
_context32.next = 86;
|
|
6260
|
+
break;
|
|
6261
|
+
case 85:
|
|
6262
|
+
// No await between the final CAS and publication; preserve every unrelated live field.
|
|
6263
|
+
Object.assign(live, readFields(draft, publishedFields));
|
|
6264
|
+
case 86:
|
|
6265
|
+
_context32.prev = 86;
|
|
6266
|
+
if (isCurrentOrder()) this.persistTempOrder();
|
|
6267
|
+
_context32.next = 90;
|
|
6268
|
+
return this.finalizeProductOrderMutation(live, {
|
|
6269
|
+
isCurrentOrder: isCurrentOrder
|
|
6270
|
+
});
|
|
6271
|
+
case 90:
|
|
6272
|
+
_context32.next = 95;
|
|
6273
|
+
break;
|
|
6274
|
+
case 92:
|
|
6275
|
+
_context32.prev = 92;
|
|
6276
|
+
_context32.t3 = _context32["catch"](86);
|
|
6277
|
+
// Already committed. Do not invite a second replacement or restore a stale snapshot.
|
|
6278
|
+
this.logWarning('Party replacement committed; finalization failed', {
|
|
6279
|
+
productLineUid: uid,
|
|
6280
|
+
committed: true,
|
|
6281
|
+
error: _context32.t3 instanceof Error ? _context32.t3.message : String(_context32.t3)
|
|
6282
|
+
});
|
|
6283
|
+
case 95:
|
|
6284
|
+
return _context32.abrupt("return", live.products);
|
|
6285
|
+
case 96:
|
|
6286
|
+
case "end":
|
|
6287
|
+
return _context32.stop();
|
|
6288
|
+
}
|
|
6289
|
+
}, _callee30, this, [[24, 33, 36, 39], [60, 70, 73, 76], [86, 92]]);
|
|
6290
|
+
}));
|
|
6291
|
+
function replaceBookingProductWithRelatedRetailDraft(_x35) {
|
|
6292
|
+
return _replaceBookingProductWithRelatedRetailDraft.apply(this, arguments);
|
|
6293
|
+
}
|
|
6294
|
+
return replaceBookingProductWithRelatedRetailDraft;
|
|
6295
|
+
}()
|
|
5990
6296
|
/**
|
|
5991
6297
|
* 批量添加商品行,所有行追加完成后只触发一次促销、折扣、summary 重算与持久化。
|
|
5992
6298
|
*
|
|
@@ -5999,21 +6305,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5999
6305
|
}, {
|
|
6000
6306
|
key: "addProductsToOrder",
|
|
6001
6307
|
value: (function () {
|
|
6002
|
-
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6003
|
-
var
|
|
6004
|
-
return _regeneratorRuntime().wrap(function
|
|
6005
|
-
while (1) switch (
|
|
6308
|
+
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(items, options) {
|
|
6309
|
+
var _this42 = this;
|
|
6310
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context33) {
|
|
6311
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
6006
6312
|
case 0:
|
|
6007
|
-
return
|
|
6008
|
-
return
|
|
6313
|
+
return _context33.abrupt("return", this.queueCartCommand(function () {
|
|
6314
|
+
return _this42.addProductsToOrderDraft(items, options);
|
|
6009
6315
|
}));
|
|
6010
6316
|
case 1:
|
|
6011
6317
|
case "end":
|
|
6012
|
-
return
|
|
6318
|
+
return _context33.stop();
|
|
6013
6319
|
}
|
|
6014
|
-
},
|
|
6320
|
+
}, _callee31, this);
|
|
6015
6321
|
}));
|
|
6016
|
-
function addProductsToOrder(
|
|
6322
|
+
function addProductsToOrder(_x36, _x37) {
|
|
6017
6323
|
return _addProductsToOrder.apply(this, arguments);
|
|
6018
6324
|
}
|
|
6019
6325
|
return addProductsToOrder;
|
|
@@ -6021,51 +6327,51 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6021
6327
|
}, {
|
|
6022
6328
|
key: "addProductsToOrderDraft",
|
|
6023
6329
|
value: function () {
|
|
6024
|
-
var _addProductsToOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6025
|
-
var mutation, tempOrder, beforeCommit, beforeAppend,
|
|
6026
|
-
return _regeneratorRuntime().wrap(function
|
|
6027
|
-
while (1) switch (
|
|
6330
|
+
var _addProductsToOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(items, options) {
|
|
6331
|
+
var mutation, tempOrder, beforeCommit, beforeAppend, _iterator27, _step27, item, product, booking, _ref73, _productRecord$num2, productRecord, splitCount, i, splitLine, _appendResult, appendResult;
|
|
6332
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context34) {
|
|
6333
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
6028
6334
|
case 0:
|
|
6029
6335
|
mutation = this.beginCartMutation();
|
|
6030
6336
|
tempOrder = mutation.draft;
|
|
6031
6337
|
if (!(!Array.isArray(items) || items.length === 0)) {
|
|
6032
|
-
|
|
6338
|
+
_context34.next = 4;
|
|
6033
6339
|
break;
|
|
6034
6340
|
}
|
|
6035
|
-
return
|
|
6341
|
+
return _context34.abrupt("return", tempOrder.products);
|
|
6036
6342
|
case 4:
|
|
6037
6343
|
beforeCommit = this.createCartIntentCommitGuard('add_product');
|
|
6038
6344
|
beforeAppend = mutation.commit ? undefined : beforeCommit;
|
|
6039
|
-
|
|
6040
|
-
|
|
6041
|
-
|
|
6345
|
+
_iterator27 = _createForOfIteratorHelper(items || []);
|
|
6346
|
+
_context34.prev = 7;
|
|
6347
|
+
_iterator27.s();
|
|
6042
6348
|
case 9:
|
|
6043
|
-
if ((
|
|
6044
|
-
|
|
6349
|
+
if ((_step27 = _iterator27.n()).done) {
|
|
6350
|
+
_context34.next = 35;
|
|
6045
6351
|
break;
|
|
6046
6352
|
}
|
|
6047
|
-
item =
|
|
6353
|
+
item = _step27.value;
|
|
6048
6354
|
product = item.product, booking = item.booking;
|
|
6049
6355
|
if (product) {
|
|
6050
|
-
|
|
6356
|
+
_context34.next = 14;
|
|
6051
6357
|
break;
|
|
6052
6358
|
}
|
|
6053
|
-
return
|
|
6359
|
+
return _context34.abrupt("continue", 33);
|
|
6054
6360
|
case 14:
|
|
6055
6361
|
if (!booking) {
|
|
6056
|
-
|
|
6362
|
+
_context34.next = 29;
|
|
6057
6363
|
break;
|
|
6058
6364
|
}
|
|
6059
6365
|
productRecord = product;
|
|
6060
6366
|
splitCount = getSafeProductNum((_ref73 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref73 !== void 0 ? _ref73 : 1);
|
|
6061
6367
|
if (!(splitCount > 1)) {
|
|
6062
|
-
|
|
6368
|
+
_context34.next = 29;
|
|
6063
6369
|
break;
|
|
6064
6370
|
}
|
|
6065
6371
|
i = 0;
|
|
6066
6372
|
case 19:
|
|
6067
6373
|
if (!(i < splitCount)) {
|
|
6068
|
-
|
|
6374
|
+
_context34.next = 28;
|
|
6069
6375
|
break;
|
|
6070
6376
|
}
|
|
6071
6377
|
splitLine = this.createSplitBookingLine(productRecord, booking, i, splitCount);
|
|
@@ -6073,67 +6379,67 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6073
6379
|
beforeCommit: beforeAppend
|
|
6074
6380
|
});
|
|
6075
6381
|
if (!_appendResult) {
|
|
6076
|
-
|
|
6382
|
+
_context34.next = 25;
|
|
6077
6383
|
break;
|
|
6078
6384
|
}
|
|
6079
|
-
|
|
6385
|
+
_context34.next = 25;
|
|
6080
6386
|
return _appendResult;
|
|
6081
6387
|
case 25:
|
|
6082
6388
|
i += 1;
|
|
6083
|
-
|
|
6389
|
+
_context34.next = 19;
|
|
6084
6390
|
break;
|
|
6085
6391
|
case 28:
|
|
6086
|
-
return
|
|
6392
|
+
return _context34.abrupt("continue", 33);
|
|
6087
6393
|
case 29:
|
|
6088
6394
|
appendResult = this.appendProductLineToTempOrder(tempOrder, product, booking, {
|
|
6089
6395
|
beforeCommit: beforeAppend
|
|
6090
6396
|
});
|
|
6091
6397
|
if (!appendResult) {
|
|
6092
|
-
|
|
6398
|
+
_context34.next = 33;
|
|
6093
6399
|
break;
|
|
6094
6400
|
}
|
|
6095
|
-
|
|
6401
|
+
_context34.next = 33;
|
|
6096
6402
|
return appendResult;
|
|
6097
6403
|
case 33:
|
|
6098
|
-
|
|
6404
|
+
_context34.next = 9;
|
|
6099
6405
|
break;
|
|
6100
6406
|
case 35:
|
|
6101
|
-
|
|
6407
|
+
_context34.next = 40;
|
|
6102
6408
|
break;
|
|
6103
6409
|
case 37:
|
|
6104
|
-
|
|
6105
|
-
|
|
6106
|
-
|
|
6410
|
+
_context34.prev = 37;
|
|
6411
|
+
_context34.t0 = _context34["catch"](7);
|
|
6412
|
+
_iterator27.e(_context34.t0);
|
|
6107
6413
|
case 40:
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
return
|
|
6414
|
+
_context34.prev = 40;
|
|
6415
|
+
_iterator27.f();
|
|
6416
|
+
return _context34.finish(40);
|
|
6111
6417
|
case 43:
|
|
6112
6418
|
if (!mutation.commit) {
|
|
6113
|
-
|
|
6419
|
+
_context34.next = 47;
|
|
6114
6420
|
break;
|
|
6115
6421
|
}
|
|
6116
|
-
|
|
6422
|
+
_context34.next = 46;
|
|
6117
6423
|
return mutation.commit({
|
|
6118
6424
|
beforeCommit: beforeCommit
|
|
6119
6425
|
});
|
|
6120
6426
|
case 46:
|
|
6121
|
-
tempOrder =
|
|
6427
|
+
tempOrder = _context34.sent;
|
|
6122
6428
|
case 47:
|
|
6123
|
-
|
|
6429
|
+
_context34.next = 49;
|
|
6124
6430
|
return this.finalizeProductOrderMutation(tempOrder, options);
|
|
6125
6431
|
case 49:
|
|
6126
6432
|
this.logInfo('addProductsToOrder success', {
|
|
6127
6433
|
itemsCount: items.length
|
|
6128
6434
|
});
|
|
6129
|
-
return
|
|
6435
|
+
return _context34.abrupt("return", tempOrder.products);
|
|
6130
6436
|
case 51:
|
|
6131
6437
|
case "end":
|
|
6132
|
-
return
|
|
6438
|
+
return _context34.stop();
|
|
6133
6439
|
}
|
|
6134
|
-
},
|
|
6440
|
+
}, _callee32, this, [[7, 37, 40, 43]]);
|
|
6135
6441
|
}));
|
|
6136
|
-
function addProductsToOrderDraft(
|
|
6442
|
+
function addProductsToOrderDraft(_x38, _x39) {
|
|
6137
6443
|
return _addProductsToOrderDraft.apply(this, arguments);
|
|
6138
6444
|
}
|
|
6139
6445
|
return addProductsToOrderDraft;
|
|
@@ -6185,7 +6491,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6185
6491
|
}, {
|
|
6186
6492
|
key: "hasSameEntitlementMergePriceConfig",
|
|
6187
6493
|
value: function hasSameEntitlementMergePriceConfig(incoming, existing) {
|
|
6188
|
-
var
|
|
6494
|
+
var _this43 = this;
|
|
6189
6495
|
var buildPriceConfig = function buildPriceConfig(product) {
|
|
6190
6496
|
var metadata = product.metadata || {};
|
|
6191
6497
|
var bundle = (product.product_bundle || []).map(function (item) {
|
|
@@ -6201,10 +6507,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6201
6507
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
6202
6508
|
});
|
|
6203
6509
|
return JSON.stringify({
|
|
6204
|
-
original_price:
|
|
6205
|
-
source_product_price:
|
|
6206
|
-
main_product_original_price:
|
|
6207
|
-
price_override:
|
|
6510
|
+
original_price: _this43.normalizeFingerprintMoney(product.original_price),
|
|
6511
|
+
source_product_price: _this43.normalizeFingerprintMoney(metadata.source_product_price),
|
|
6512
|
+
main_product_original_price: _this43.normalizeFingerprintMoney(metadata.main_product_original_price),
|
|
6513
|
+
price_override: _this43.normalizeFingerprintMoney(metadata.price_override),
|
|
6208
6514
|
is_manual_discount: Boolean(metadata.is_manual_discount),
|
|
6209
6515
|
bundle: bundle
|
|
6210
6516
|
});
|
|
@@ -6221,17 +6527,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6221
6527
|
}, {
|
|
6222
6528
|
key: "preservePersistedBundlePriceFields",
|
|
6223
6529
|
value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
|
|
6224
|
-
var
|
|
6530
|
+
var _this44 = this;
|
|
6225
6531
|
if (!Array.isArray(nextBundles)) return nextBundles;
|
|
6226
6532
|
if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
|
|
6227
6533
|
var previousByIdentity = new Map();
|
|
6228
6534
|
previousBundles.forEach(function (bundle) {
|
|
6229
|
-
var identity =
|
|
6535
|
+
var identity = _this44.getBundleRuntimeIdentity(bundle);
|
|
6230
6536
|
if (identity) previousByIdentity.set(identity, bundle);
|
|
6231
6537
|
});
|
|
6232
6538
|
return nextBundles.map(function (bundle, index) {
|
|
6233
6539
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
6234
|
-
var previous = previousByIdentity.get(
|
|
6540
|
+
var previous = previousByIdentity.get(_this44.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
|
|
6235
6541
|
if (!previous || _typeof(previous) !== 'object') return bundle;
|
|
6236
6542
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
|
|
6237
6543
|
cover: previous.cover
|
|
@@ -6503,21 +6809,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6503
6809
|
}, {
|
|
6504
6810
|
key: "updateOrderProduct",
|
|
6505
6811
|
value: function () {
|
|
6506
|
-
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6507
|
-
var
|
|
6508
|
-
return _regeneratorRuntime().wrap(function
|
|
6509
|
-
while (1) switch (
|
|
6812
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
|
|
6813
|
+
var _this45 = this;
|
|
6814
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context35) {
|
|
6815
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
6510
6816
|
case 0:
|
|
6511
|
-
return
|
|
6512
|
-
return
|
|
6817
|
+
return _context35.abrupt("return", this.queueCartCommand(function () {
|
|
6818
|
+
return _this45.updateOrderProductDraft(params);
|
|
6513
6819
|
}));
|
|
6514
6820
|
case 1:
|
|
6515
6821
|
case "end":
|
|
6516
|
-
return
|
|
6822
|
+
return _context35.stop();
|
|
6517
6823
|
}
|
|
6518
|
-
},
|
|
6824
|
+
}, _callee33, this);
|
|
6519
6825
|
}));
|
|
6520
|
-
function updateOrderProduct(
|
|
6826
|
+
function updateOrderProduct(_x40) {
|
|
6521
6827
|
return _updateOrderProduct.apply(this, arguments);
|
|
6522
6828
|
}
|
|
6523
6829
|
return updateOrderProduct;
|
|
@@ -6525,10 +6831,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6525
6831
|
}, {
|
|
6526
6832
|
key: "updateOrderProductDraft",
|
|
6527
6833
|
value: function () {
|
|
6528
|
-
var _updateOrderProductDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6834
|
+
var _updateOrderProductDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
|
|
6529
6835
|
var mutation, tempOrder, beforeCommit, reapplyWeighedDiscountProductUids, updatedProductUid, promotionPayload;
|
|
6530
|
-
return _regeneratorRuntime().wrap(function
|
|
6531
|
-
while (1) switch (
|
|
6836
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context36) {
|
|
6837
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
6532
6838
|
case 0:
|
|
6533
6839
|
mutation = this.beginCartMutation();
|
|
6534
6840
|
tempOrder = mutation.draft;
|
|
@@ -6537,26 +6843,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6537
6843
|
reapplyWeighedDiscountProductUids = [];
|
|
6538
6844
|
updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
|
|
6539
6845
|
if (!mutation.commit) {
|
|
6540
|
-
|
|
6846
|
+
_context36.next = 10;
|
|
6541
6847
|
break;
|
|
6542
6848
|
}
|
|
6543
|
-
|
|
6849
|
+
_context36.next = 9;
|
|
6544
6850
|
return mutation.commit({
|
|
6545
6851
|
beforeCommit: beforeCommit
|
|
6546
6852
|
});
|
|
6547
6853
|
case 9:
|
|
6548
|
-
tempOrder =
|
|
6854
|
+
tempOrder = _context36.sent;
|
|
6549
6855
|
case 10:
|
|
6550
|
-
|
|
6856
|
+
_context36.next = 12;
|
|
6551
6857
|
return this.evaluatePromotion();
|
|
6552
6858
|
case 12:
|
|
6553
|
-
promotionPayload =
|
|
6859
|
+
promotionPayload = _context36.sent;
|
|
6554
6860
|
this.applyDiscount({
|
|
6555
6861
|
reapplyWeighedDiscountProductUids: reapplyWeighedDiscountProductUids,
|
|
6556
6862
|
reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
|
|
6557
6863
|
});
|
|
6558
6864
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
6559
|
-
|
|
6865
|
+
_context36.next = 17;
|
|
6560
6866
|
return this.recalculateSummary({
|
|
6561
6867
|
createIfMissing: true
|
|
6562
6868
|
});
|
|
@@ -6566,14 +6872,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6566
6872
|
this.logInfo('updateOrderProduct success', {
|
|
6567
6873
|
params: params
|
|
6568
6874
|
});
|
|
6569
|
-
return
|
|
6875
|
+
return _context36.abrupt("return", tempOrder.products);
|
|
6570
6876
|
case 21:
|
|
6571
6877
|
case "end":
|
|
6572
|
-
return
|
|
6878
|
+
return _context36.stop();
|
|
6573
6879
|
}
|
|
6574
|
-
},
|
|
6880
|
+
}, _callee34, this);
|
|
6575
6881
|
}));
|
|
6576
|
-
function updateOrderProductDraft(
|
|
6882
|
+
function updateOrderProductDraft(_x41) {
|
|
6577
6883
|
return _updateOrderProductDraft.apply(this, arguments);
|
|
6578
6884
|
}
|
|
6579
6885
|
return updateOrderProductDraft;
|
|
@@ -6581,21 +6887,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6581
6887
|
}, {
|
|
6582
6888
|
key: "updateOrderProducts",
|
|
6583
6889
|
value: function () {
|
|
6584
|
-
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6585
|
-
var
|
|
6586
|
-
return _regeneratorRuntime().wrap(function
|
|
6587
|
-
while (1) switch (
|
|
6890
|
+
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(paramsList, options) {
|
|
6891
|
+
var _this46 = this;
|
|
6892
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context37) {
|
|
6893
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
6588
6894
|
case 0:
|
|
6589
|
-
return
|
|
6590
|
-
return
|
|
6895
|
+
return _context37.abrupt("return", this.queueCartCommand(function () {
|
|
6896
|
+
return _this46.updateOrderProductsDraft(paramsList, options);
|
|
6591
6897
|
}));
|
|
6592
6898
|
case 1:
|
|
6593
6899
|
case "end":
|
|
6594
|
-
return
|
|
6900
|
+
return _context37.stop();
|
|
6595
6901
|
}
|
|
6596
|
-
},
|
|
6902
|
+
}, _callee35, this);
|
|
6597
6903
|
}));
|
|
6598
|
-
function updateOrderProducts(
|
|
6904
|
+
function updateOrderProducts(_x42, _x43) {
|
|
6599
6905
|
return _updateOrderProducts.apply(this, arguments);
|
|
6600
6906
|
}
|
|
6601
6907
|
return updateOrderProducts;
|
|
@@ -6603,27 +6909,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6603
6909
|
}, {
|
|
6604
6910
|
key: "updateOrderProductsDraft",
|
|
6605
6911
|
value: function () {
|
|
6606
|
-
var _updateOrderProductsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6607
|
-
var
|
|
6912
|
+
var _updateOrderProductsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(paramsList, options) {
|
|
6913
|
+
var _this47 = this;
|
|
6608
6914
|
var mutation, tempOrder, beforeCommit, reapplyWeighedDiscountProductUids, reapplyBookingDiscountProductUids;
|
|
6609
|
-
return _regeneratorRuntime().wrap(function
|
|
6610
|
-
while (1) switch (
|
|
6915
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context38) {
|
|
6916
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
6611
6917
|
case 0:
|
|
6918
|
+
if (!options) {
|
|
6919
|
+
_context38.next = 2;
|
|
6920
|
+
break;
|
|
6921
|
+
}
|
|
6922
|
+
return _context38.abrupt("return", this.updateOrderProductsGuarded(paramsList, options));
|
|
6923
|
+
case 2:
|
|
6612
6924
|
mutation = this.beginCartMutation();
|
|
6613
6925
|
tempOrder = mutation.draft;
|
|
6614
6926
|
if (paramsList.length) {
|
|
6615
|
-
|
|
6927
|
+
_context38.next = 6;
|
|
6616
6928
|
break;
|
|
6617
6929
|
}
|
|
6618
|
-
return
|
|
6619
|
-
case
|
|
6930
|
+
return _context38.abrupt("return", tempOrder.products);
|
|
6931
|
+
case 6:
|
|
6620
6932
|
beforeCommit = paramsList.some(function (params) {
|
|
6621
|
-
return
|
|
6933
|
+
return _this47.isRestrictedCartProductUpdate(tempOrder, params);
|
|
6622
6934
|
}) ? this.createCartIntentCommitGuard('update_product') : undefined;
|
|
6623
6935
|
if (!mutation.commit) beforeCommit === null || beforeCommit === void 0 || beforeCommit();
|
|
6624
6936
|
reapplyWeighedDiscountProductUids = [];
|
|
6625
6937
|
reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
|
|
6626
|
-
var updatedProductUid =
|
|
6938
|
+
var updatedProductUid = _this47.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
|
|
6627
6939
|
// 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
|
|
6628
6940
|
if (params.allow_booking_discount_reapply && updatedProductUid) {
|
|
6629
6941
|
acc.push(String(updatedProductUid));
|
|
@@ -6631,55 +6943,206 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6631
6943
|
return acc;
|
|
6632
6944
|
}, []);
|
|
6633
6945
|
if (!mutation.commit) {
|
|
6634
|
-
|
|
6946
|
+
_context38.next = 14;
|
|
6635
6947
|
break;
|
|
6636
6948
|
}
|
|
6637
|
-
|
|
6949
|
+
_context38.next = 13;
|
|
6638
6950
|
return mutation.commit({
|
|
6639
6951
|
beforeCommit: beforeCommit
|
|
6640
6952
|
});
|
|
6641
|
-
case
|
|
6642
|
-
tempOrder =
|
|
6643
|
-
case
|
|
6644
|
-
|
|
6953
|
+
case 13:
|
|
6954
|
+
tempOrder = _context38.sent;
|
|
6955
|
+
case 14:
|
|
6956
|
+
_context38.next = 16;
|
|
6645
6957
|
return this.finalizeAfterProductsMutation(tempOrder, {
|
|
6646
6958
|
reapplyWeighedDiscountProductUids: reapplyWeighedDiscountProductUids,
|
|
6647
6959
|
reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
|
|
6648
6960
|
});
|
|
6649
|
-
case
|
|
6961
|
+
case 16:
|
|
6650
6962
|
this.logInfo('updateOrderProduct success', {
|
|
6651
6963
|
paramsList: paramsList
|
|
6652
6964
|
});
|
|
6653
|
-
return
|
|
6654
|
-
case
|
|
6965
|
+
return _context38.abrupt("return", tempOrder.products);
|
|
6966
|
+
case 18:
|
|
6655
6967
|
case "end":
|
|
6656
|
-
return
|
|
6968
|
+
return _context38.stop();
|
|
6657
6969
|
}
|
|
6658
|
-
},
|
|
6970
|
+
}, _callee36, this);
|
|
6659
6971
|
}));
|
|
6660
|
-
function updateOrderProductsDraft(
|
|
6972
|
+
function updateOrderProductsDraft(_x44, _x45) {
|
|
6661
6973
|
return _updateOrderProductsDraft.apply(this, arguments);
|
|
6662
6974
|
}
|
|
6663
6975
|
return updateOrderProductsDraft;
|
|
6664
6976
|
}()
|
|
6977
|
+
}, {
|
|
6978
|
+
key: "updateOrderProductsGuarded",
|
|
6979
|
+
value: function () {
|
|
6980
|
+
var _updateOrderProductsGuarded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(paramsList, options) {
|
|
6981
|
+
var _options$beforeApply,
|
|
6982
|
+
_this48 = this;
|
|
6983
|
+
var stale, live, mutation, identity, isCurrentOrder, beforeCommit, publishedFields, guardedFields, readFields, baseline, draft, seen, reapplyWeighedDiscountProductUids, reapplyBookingDiscountProductUids, _iterator28, _step28, _loop3, beforePublish;
|
|
6984
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context40) {
|
|
6985
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
6986
|
+
case 0:
|
|
6987
|
+
stale = function stale() {
|
|
6988
|
+
return Object.assign(new Error('Order product update interrupted by an order change'), {
|
|
6989
|
+
code: 'AVAILABILITY_SELECTION_STALE'
|
|
6990
|
+
});
|
|
6991
|
+
};
|
|
6992
|
+
(_options$beforeApply = options.beforeApply) === null || _options$beforeApply === void 0 || _options$beforeApply.call(options);
|
|
6993
|
+
if (!(options.isCurrentOrder && !options.isCurrentOrder())) {
|
|
6994
|
+
_context40.next = 4;
|
|
6995
|
+
break;
|
|
6996
|
+
}
|
|
6997
|
+
throw stale();
|
|
6998
|
+
case 4:
|
|
6999
|
+
live = this.ensureTempOrder();
|
|
7000
|
+
if (paramsList.length) {
|
|
7001
|
+
_context40.next = 7;
|
|
7002
|
+
break;
|
|
7003
|
+
}
|
|
7004
|
+
return _context40.abrupt("return", live.products);
|
|
7005
|
+
case 7:
|
|
7006
|
+
mutation = this.beginCartMutation();
|
|
7007
|
+
identity = [live.order_id, live.external_sale_number];
|
|
7008
|
+
isCurrentOrder = function isCurrentOrder() {
|
|
7009
|
+
var _options$isCurrentOrd, _options$isCurrentOrd2;
|
|
7010
|
+
return _this48.store.tempOrder === live && live.order_id === identity[0] && live.external_sale_number === identity[1] && ((_options$isCurrentOrd = (_options$isCurrentOrd2 = options.isCurrentOrder) === null || _options$isCurrentOrd2 === void 0 ? void 0 : _options$isCurrentOrd2.call(options)) !== null && _options$isCurrentOrd !== void 0 ? _options$isCurrentOrd : true);
|
|
7011
|
+
};
|
|
7012
|
+
beforeCommit = this.createCartIntentCommitGuard('update_product', live);
|
|
7013
|
+
publishedFields = ['products', 'bookings', 'notes', '_extend', 'metadata', 'holder', 'holder_relations'];
|
|
7014
|
+
guardedFields = [].concat(publishedFields, ['customer_id', 'discount_list', 'shop_discount', 'payments']);
|
|
7015
|
+
readFields = function readFields(order, fields) {
|
|
7016
|
+
return Object.fromEntries(fields.map(function (key) {
|
|
7017
|
+
return [key, order[key]];
|
|
7018
|
+
}));
|
|
7019
|
+
};
|
|
7020
|
+
baseline = cloneDeep(readFields(live, guardedFields));
|
|
7021
|
+
draft = mutation.commit ? mutation.draft : cloneDeep(live);
|
|
7022
|
+
seen = new Set();
|
|
7023
|
+
reapplyWeighedDiscountProductUids = [];
|
|
7024
|
+
reapplyBookingDiscountProductUids = [];
|
|
7025
|
+
_iterator28 = _createForOfIteratorHelper(paramsList);
|
|
7026
|
+
_context40.prev = 20;
|
|
7027
|
+
_loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
|
|
7028
|
+
var params, uid, matches, target, updatedUid;
|
|
7029
|
+
return _regeneratorRuntime().wrap(function _loop3$(_context39) {
|
|
7030
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
7031
|
+
case 0:
|
|
7032
|
+
params = _step28.value;
|
|
7033
|
+
uid = String(params.unique_identification_number || '');
|
|
7034
|
+
matches = draft.products.filter(function (line) {
|
|
7035
|
+
var _line$metadata8;
|
|
7036
|
+
return String(((_line$metadata8 = line.metadata) === null || _line$metadata8 === void 0 ? void 0 : _line$metadata8.unique_identification_number) || line.unique_identification_number || '') === uid;
|
|
7037
|
+
});
|
|
7038
|
+
target = matches[0]; // Guarded re-quotation must identify the exact row; never fall back to another same-SKU line.
|
|
7039
|
+
if (!(!uid || seen.has(uid) || matches.length !== 1 || !target || target.product_id !== params.product_id || Number(target.product_variant_id || 0) !== Number(params.product_variant_id || 0))) {
|
|
7040
|
+
_context39.next = 6;
|
|
7041
|
+
break;
|
|
7042
|
+
}
|
|
7043
|
+
throw stale();
|
|
7044
|
+
case 6:
|
|
7045
|
+
seen.add(uid);
|
|
7046
|
+
updatedUid = _this48.applyOrderProductUpdateToTempOrder(draft, cloneDeep(params), reapplyWeighedDiscountProductUids);
|
|
7047
|
+
if (params.allow_booking_discount_reapply && updatedUid) reapplyBookingDiscountProductUids.push(updatedUid);
|
|
7048
|
+
case 9:
|
|
7049
|
+
case "end":
|
|
7050
|
+
return _context39.stop();
|
|
7051
|
+
}
|
|
7052
|
+
}, _loop3);
|
|
7053
|
+
});
|
|
7054
|
+
_iterator28.s();
|
|
7055
|
+
case 23:
|
|
7056
|
+
if ((_step28 = _iterator28.n()).done) {
|
|
7057
|
+
_context40.next = 27;
|
|
7058
|
+
break;
|
|
7059
|
+
}
|
|
7060
|
+
return _context40.delegateYield(_loop3(), "t0", 25);
|
|
7061
|
+
case 25:
|
|
7062
|
+
_context40.next = 23;
|
|
7063
|
+
break;
|
|
7064
|
+
case 27:
|
|
7065
|
+
_context40.next = 32;
|
|
7066
|
+
break;
|
|
7067
|
+
case 29:
|
|
7068
|
+
_context40.prev = 29;
|
|
7069
|
+
_context40.t1 = _context40["catch"](20);
|
|
7070
|
+
_iterator28.e(_context40.t1);
|
|
7071
|
+
case 32:
|
|
7072
|
+
_context40.prev = 32;
|
|
7073
|
+
_iterator28.f();
|
|
7074
|
+
return _context40.finish(32);
|
|
7075
|
+
case 35:
|
|
7076
|
+
beforePublish = function beforePublish() {
|
|
7077
|
+
var _options$beforeApply2;
|
|
7078
|
+
(_options$beforeApply2 = options.beforeApply) === null || _options$beforeApply2 === void 0 || _options$beforeApply2.call(options);
|
|
7079
|
+
beforeCommit();
|
|
7080
|
+
if (!isCurrentOrder() || !isEqual(readFields(live, guardedFields), baseline)) throw stale();
|
|
7081
|
+
};
|
|
7082
|
+
beforePublish();
|
|
7083
|
+
if (!mutation.commit) {
|
|
7084
|
+
_context40.next = 42;
|
|
7085
|
+
break;
|
|
7086
|
+
}
|
|
7087
|
+
_context40.next = 40;
|
|
7088
|
+
return mutation.commit({
|
|
7089
|
+
beforeCommit: beforePublish
|
|
7090
|
+
});
|
|
7091
|
+
case 40:
|
|
7092
|
+
_context40.next = 43;
|
|
7093
|
+
break;
|
|
7094
|
+
case 42:
|
|
7095
|
+
Object.assign(live, readFields(draft, publishedFields));
|
|
7096
|
+
case 43:
|
|
7097
|
+
_context40.prev = 43;
|
|
7098
|
+
if (isCurrentOrder()) this.persistTempOrder();
|
|
7099
|
+
_context40.next = 47;
|
|
7100
|
+
return this.finalizeAfterProductsMutation(live, {
|
|
7101
|
+
reapplyWeighedDiscountProductUids: reapplyWeighedDiscountProductUids,
|
|
7102
|
+
reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids,
|
|
7103
|
+
isCurrentOrder: isCurrentOrder
|
|
7104
|
+
});
|
|
7105
|
+
case 47:
|
|
7106
|
+
_context40.next = 52;
|
|
7107
|
+
break;
|
|
7108
|
+
case 49:
|
|
7109
|
+
_context40.prev = 49;
|
|
7110
|
+
_context40.t2 = _context40["catch"](43);
|
|
7111
|
+
this.logWarning('Order product update committed; finalization failed', {
|
|
7112
|
+
committed: true,
|
|
7113
|
+
error: _context40.t2 instanceof Error ? _context40.t2.message : String(_context40.t2)
|
|
7114
|
+
});
|
|
7115
|
+
case 52:
|
|
7116
|
+
return _context40.abrupt("return", live.products);
|
|
7117
|
+
case 53:
|
|
7118
|
+
case "end":
|
|
7119
|
+
return _context40.stop();
|
|
7120
|
+
}
|
|
7121
|
+
}, _callee37, this, [[20, 29, 32, 35], [43, 49]]);
|
|
7122
|
+
}));
|
|
7123
|
+
function updateOrderProductsGuarded(_x46, _x47) {
|
|
7124
|
+
return _updateOrderProductsGuarded.apply(this, arguments);
|
|
7125
|
+
}
|
|
7126
|
+
return updateOrderProductsGuarded;
|
|
7127
|
+
}()
|
|
6665
7128
|
}, {
|
|
6666
7129
|
key: "updateOrderProductQuantity",
|
|
6667
7130
|
value: function () {
|
|
6668
|
-
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6669
|
-
var
|
|
6670
|
-
return _regeneratorRuntime().wrap(function
|
|
6671
|
-
while (1) switch (
|
|
7131
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params, options) {
|
|
7132
|
+
var _this49 = this;
|
|
7133
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context41) {
|
|
7134
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
6672
7135
|
case 0:
|
|
6673
|
-
return
|
|
6674
|
-
return
|
|
7136
|
+
return _context41.abrupt("return", this.queueCartCommand(function () {
|
|
7137
|
+
return _this49.updateOrderProductQuantityDraft(params, options);
|
|
6675
7138
|
}));
|
|
6676
7139
|
case 1:
|
|
6677
7140
|
case "end":
|
|
6678
|
-
return
|
|
7141
|
+
return _context41.stop();
|
|
6679
7142
|
}
|
|
6680
|
-
},
|
|
7143
|
+
}, _callee38, this);
|
|
6681
7144
|
}));
|
|
6682
|
-
function updateOrderProductQuantity(
|
|
7145
|
+
function updateOrderProductQuantity(_x48, _x49) {
|
|
6683
7146
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
6684
7147
|
}
|
|
6685
7148
|
return updateOrderProductQuantity;
|
|
@@ -6687,18 +7150,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6687
7150
|
}, {
|
|
6688
7151
|
key: "updateOrderProductQuantityDraft",
|
|
6689
7152
|
value: function () {
|
|
6690
|
-
var _updateOrderProductQuantityDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7153
|
+
var _updateOrderProductQuantityDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params, options) {
|
|
6691
7154
|
var _this$store$tempOrder10, _targetProduct$metada22;
|
|
6692
7155
|
var isCurrentOrder, product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, mutation, tempOrder, identityLookup, productIndex, targetUid, targetProduct, isPersistedOrderLine, normalizedProduct, settlementSnapshot, currencyProductId, asset, requiredAmount, balance, beforeCommit, isVirtualSettlement, promotionPayload;
|
|
6693
|
-
return _regeneratorRuntime().wrap(function
|
|
6694
|
-
while (1) switch (
|
|
7156
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context42) {
|
|
7157
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
6695
7158
|
case 0:
|
|
6696
7159
|
isCurrentOrder = options === null || options === void 0 ? void 0 : options.isCurrentOrder;
|
|
6697
7160
|
if (!(isCurrentOrder && !isCurrentOrder())) {
|
|
6698
|
-
|
|
7161
|
+
_context42.next = 3;
|
|
6699
7162
|
break;
|
|
6700
7163
|
}
|
|
6701
|
-
return
|
|
7164
|
+
return _context42.abrupt("return", ((_this$store$tempOrder10 = this.store.tempOrder) === null || _this$store$tempOrder10 === void 0 ? void 0 : _this$store$tempOrder10.products) || []);
|
|
6702
7165
|
case 3:
|
|
6703
7166
|
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;
|
|
6704
7167
|
mutation = this.beginCartMutation();
|
|
@@ -6729,7 +7192,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6729
7192
|
productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
|
|
6730
7193
|
}
|
|
6731
7194
|
if (!(productIndex === -1)) {
|
|
6732
|
-
|
|
7195
|
+
_context42.next = 17;
|
|
6733
7196
|
break;
|
|
6734
7197
|
}
|
|
6735
7198
|
throw new Error('[Order] 目标商品不存在,无法更新数量');
|
|
@@ -6745,7 +7208,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6745
7208
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(isPersistedOrderLine ? syncReducedEntitlementPassUsageCount(normalizedProduct.discount_list, targetProduct.num, normalizedProduct.num) : normalizedProduct.discount_list);
|
|
6746
7209
|
settlementSnapshot = getSelectedSettlementSnapshot(normalizedProduct);
|
|
6747
7210
|
if (!(this.isMultiCurrencySettlementEnabled() && (settlementSnapshot === null || settlementSnapshot === void 0 ? void 0 : settlementSnapshot.settlement_type) === 'virtual_currency' && tempOrder.customer_id && Number(tempOrder.customer_id) !== 1)) {
|
|
6748
|
-
|
|
7211
|
+
_context42.next = 31;
|
|
6749
7212
|
break;
|
|
6750
7213
|
}
|
|
6751
7214
|
currencyProductId = Number(settlementSnapshot.currency_product_id);
|
|
@@ -6753,7 +7216,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6753
7216
|
return Number(item === null || item === void 0 ? void 0 : item.product_id) === currencyProductId;
|
|
6754
7217
|
});
|
|
6755
7218
|
if (asset) {
|
|
6756
|
-
|
|
7219
|
+
_context42.next = 27;
|
|
6757
7220
|
break;
|
|
6758
7221
|
}
|
|
6759
7222
|
throw new VirtualCurrencyAssetNotFoundError(currencyProductId);
|
|
@@ -6765,7 +7228,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6765
7228
|
}, new Decimal(0));
|
|
6766
7229
|
balance = new Decimal(asset.balance || 0);
|
|
6767
7230
|
if (!balance.lt(requiredAmount)) {
|
|
6768
|
-
|
|
7231
|
+
_context42.next = 31;
|
|
6769
7232
|
break;
|
|
6770
7233
|
}
|
|
6771
7234
|
throw new VirtualCurrencyBalanceError(balance.toFixed(2), requiredAmount.toFixed(2));
|
|
@@ -6773,58 +7236,58 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6773
7236
|
beforeCommit = normalizedProduct.num > targetProduct.num ? this.createCartIntentCommitGuard('increase_quantity') : undefined;
|
|
6774
7237
|
if (!mutation.commit) beforeCommit === null || beforeCommit === void 0 || beforeCommit();
|
|
6775
7238
|
if (!(isCurrentOrder && !isCurrentOrder())) {
|
|
6776
|
-
|
|
7239
|
+
_context42.next = 35;
|
|
6777
7240
|
break;
|
|
6778
7241
|
}
|
|
6779
|
-
return
|
|
7242
|
+
return _context42.abrupt("return", tempOrder.products);
|
|
6780
7243
|
case 35:
|
|
6781
7244
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
6782
7245
|
if (!mutation.commit) {
|
|
6783
|
-
|
|
7246
|
+
_context42.next = 40;
|
|
6784
7247
|
break;
|
|
6785
7248
|
}
|
|
6786
|
-
|
|
7249
|
+
_context42.next = 39;
|
|
6787
7250
|
return mutation.commit({
|
|
6788
7251
|
beforeCommit: beforeCommit,
|
|
6789
7252
|
isCurrentOrder: isCurrentOrder
|
|
6790
7253
|
});
|
|
6791
7254
|
case 39:
|
|
6792
|
-
tempOrder =
|
|
7255
|
+
tempOrder = _context42.sent;
|
|
6793
7256
|
case 40:
|
|
6794
7257
|
if (!isCurrentOrder) {
|
|
6795
|
-
|
|
7258
|
+
_context42.next = 45;
|
|
6796
7259
|
break;
|
|
6797
7260
|
}
|
|
6798
|
-
|
|
7261
|
+
_context42.next = 43;
|
|
6799
7262
|
return this.finalizeProductOrderMutation(tempOrder, {
|
|
6800
7263
|
skipEditDiscountConfigRefresh: true,
|
|
6801
7264
|
isCurrentOrder: isCurrentOrder
|
|
6802
7265
|
});
|
|
6803
7266
|
case 43:
|
|
6804
|
-
|
|
7267
|
+
_context42.next = 61;
|
|
6805
7268
|
break;
|
|
6806
7269
|
case 45:
|
|
6807
7270
|
this.prepareVirtualSettlementTempOrder(tempOrder);
|
|
6808
7271
|
isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder);
|
|
6809
7272
|
if (isVirtualSettlement) {
|
|
6810
|
-
|
|
7273
|
+
_context42.next = 53;
|
|
6811
7274
|
break;
|
|
6812
7275
|
}
|
|
6813
|
-
|
|
7276
|
+
_context42.next = 50;
|
|
6814
7277
|
return this.evaluatePromotion();
|
|
6815
7278
|
case 50:
|
|
6816
|
-
|
|
6817
|
-
|
|
7279
|
+
_context42.t0 = _context42.sent;
|
|
7280
|
+
_context42.next = 54;
|
|
6818
7281
|
break;
|
|
6819
7282
|
case 53:
|
|
6820
|
-
|
|
7283
|
+
_context42.t0 = null;
|
|
6821
7284
|
case 54:
|
|
6822
|
-
promotionPayload =
|
|
7285
|
+
promotionPayload = _context42.t0;
|
|
6823
7286
|
if (!isVirtualSettlement) {
|
|
6824
7287
|
this.applyDiscount();
|
|
6825
7288
|
}
|
|
6826
7289
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
6827
|
-
|
|
7290
|
+
_context42.next = 59;
|
|
6828
7291
|
return this.recalculateSummary({
|
|
6829
7292
|
createIfMissing: true
|
|
6830
7293
|
});
|
|
@@ -6835,14 +7298,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6835
7298
|
this.logInfo('updateOrderProductQuantity success', {
|
|
6836
7299
|
params: params
|
|
6837
7300
|
});
|
|
6838
|
-
return
|
|
7301
|
+
return _context42.abrupt("return", tempOrder.products);
|
|
6839
7302
|
case 63:
|
|
6840
7303
|
case "end":
|
|
6841
|
-
return
|
|
7304
|
+
return _context42.stop();
|
|
6842
7305
|
}
|
|
6843
|
-
},
|
|
7306
|
+
}, _callee39, this);
|
|
6844
7307
|
}));
|
|
6845
|
-
function updateOrderProductQuantityDraft(
|
|
7308
|
+
function updateOrderProductQuantityDraft(_x50, _x51) {
|
|
6846
7309
|
return _updateOrderProductQuantityDraft.apply(this, arguments);
|
|
6847
7310
|
}
|
|
6848
7311
|
return updateOrderProductQuantityDraft;
|
|
@@ -6883,35 +7346,59 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6883
7346
|
}, {
|
|
6884
7347
|
key: "finalizeAfterProductsMutation",
|
|
6885
7348
|
value: (function () {
|
|
6886
|
-
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6887
|
-
var promotionPayload;
|
|
6888
|
-
return _regeneratorRuntime().wrap(function
|
|
6889
|
-
while (1) switch (
|
|
7349
|
+
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(tempOrder, options) {
|
|
7350
|
+
var isCurrentOrder, promotionPayload, summary;
|
|
7351
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context43) {
|
|
7352
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
6890
7353
|
case 0:
|
|
6891
|
-
|
|
6892
|
-
|
|
6893
|
-
|
|
7354
|
+
isCurrentOrder = options === null || options === void 0 ? void 0 : options.isCurrentOrder;
|
|
7355
|
+
if (!(isCurrentOrder && !isCurrentOrder())) {
|
|
7356
|
+
_context43.next = 3;
|
|
7357
|
+
break;
|
|
7358
|
+
}
|
|
7359
|
+
return _context43.abrupt("return");
|
|
6894
7360
|
case 3:
|
|
6895
|
-
|
|
7361
|
+
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
7362
|
+
_context43.next = 6;
|
|
7363
|
+
return this.evaluatePromotion(isCurrentOrder ? {
|
|
7364
|
+
isCurrentOrder: isCurrentOrder
|
|
7365
|
+
} : undefined);
|
|
7366
|
+
case 6:
|
|
7367
|
+
promotionPayload = _context43.sent;
|
|
7368
|
+
if (!(isCurrentOrder && !isCurrentOrder())) {
|
|
7369
|
+
_context43.next = 9;
|
|
7370
|
+
break;
|
|
7371
|
+
}
|
|
7372
|
+
return _context43.abrupt("return");
|
|
7373
|
+
case 9:
|
|
6896
7374
|
this.applyDiscount({
|
|
6897
7375
|
reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids,
|
|
6898
7376
|
reapplyWeighedDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyWeighedDiscountProductUids
|
|
6899
7377
|
});
|
|
6900
7378
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
6901
|
-
|
|
6902
|
-
return this.recalculateSummary({
|
|
7379
|
+
_context43.next = 13;
|
|
7380
|
+
return this.recalculateSummary(_objectSpread({
|
|
6903
7381
|
createIfMissing: true
|
|
6904
|
-
}
|
|
6905
|
-
|
|
7382
|
+
}, isCurrentOrder ? {
|
|
7383
|
+
isCurrentOrder: isCurrentOrder
|
|
7384
|
+
} : {}));
|
|
7385
|
+
case 13:
|
|
7386
|
+
summary = _context43.sent;
|
|
7387
|
+
if (!(isCurrentOrder && (!isCurrentOrder() || !summary))) {
|
|
7388
|
+
_context43.next = 16;
|
|
7389
|
+
break;
|
|
7390
|
+
}
|
|
7391
|
+
return _context43.abrupt("return");
|
|
7392
|
+
case 16:
|
|
6906
7393
|
this.persistTempOrder();
|
|
6907
7394
|
this.emitPromotionApplied(promotionPayload);
|
|
6908
|
-
case
|
|
7395
|
+
case 18:
|
|
6909
7396
|
case "end":
|
|
6910
|
-
return
|
|
7397
|
+
return _context43.stop();
|
|
6911
7398
|
}
|
|
6912
|
-
},
|
|
7399
|
+
}, _callee40, this);
|
|
6913
7400
|
}));
|
|
6914
|
-
function finalizeAfterProductsMutation(
|
|
7401
|
+
function finalizeAfterProductsMutation(_x52, _x53) {
|
|
6915
7402
|
return _finalizeAfterProductsMutation.apply(this, arguments);
|
|
6916
7403
|
}
|
|
6917
7404
|
return finalizeAfterProductsMutation;
|
|
@@ -6926,21 +7413,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6926
7413
|
}, {
|
|
6927
7414
|
key: "removeProductsFromOrder",
|
|
6928
7415
|
value: (function () {
|
|
6929
|
-
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6930
|
-
var
|
|
6931
|
-
return _regeneratorRuntime().wrap(function
|
|
6932
|
-
while (1) switch (
|
|
7416
|
+
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(identities, options) {
|
|
7417
|
+
var _this50 = this;
|
|
7418
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context44) {
|
|
7419
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
6933
7420
|
case 0:
|
|
6934
|
-
return
|
|
6935
|
-
return
|
|
7421
|
+
return _context44.abrupt("return", this.queueCartCommand(function () {
|
|
7422
|
+
return _this50.removeProductsFromOrderDraft(identities, options);
|
|
6936
7423
|
}));
|
|
6937
7424
|
case 1:
|
|
6938
7425
|
case "end":
|
|
6939
|
-
return
|
|
7426
|
+
return _context44.stop();
|
|
6940
7427
|
}
|
|
6941
|
-
},
|
|
7428
|
+
}, _callee41, this);
|
|
6942
7429
|
}));
|
|
6943
|
-
function removeProductsFromOrder(
|
|
7430
|
+
function removeProductsFromOrder(_x54, _x55) {
|
|
6944
7431
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
6945
7432
|
}
|
|
6946
7433
|
return removeProductsFromOrder;
|
|
@@ -6948,28 +7435,39 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6948
7435
|
}, {
|
|
6949
7436
|
key: "removeProductsFromOrderDraft",
|
|
6950
7437
|
value: function () {
|
|
6951
|
-
var _removeProductsFromOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7438
|
+
var _removeProductsFromOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(identities, options) {
|
|
6952
7439
|
var _this$store$tempOrder11,
|
|
6953
|
-
|
|
6954
|
-
|
|
6955
|
-
|
|
6956
|
-
|
|
7440
|
+
_options$beforeApply3,
|
|
7441
|
+
_this$store$tempOrder12,
|
|
7442
|
+
_this51 = this;
|
|
7443
|
+
var isCurrentOrder, mutation, tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator29, _step29, _loop4, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
|
|
7444
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context46) {
|
|
7445
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
6957
7446
|
case 0:
|
|
6958
7447
|
isCurrentOrder = options === null || options === void 0 ? void 0 : options.isCurrentOrder;
|
|
6959
7448
|
if (!(isCurrentOrder && !isCurrentOrder())) {
|
|
6960
|
-
|
|
7449
|
+
_context46.next = 3;
|
|
6961
7450
|
break;
|
|
6962
7451
|
}
|
|
6963
|
-
return
|
|
7452
|
+
return _context46.abrupt("return", ((_this$store$tempOrder11 = this.store.tempOrder) === null || _this$store$tempOrder11 === void 0 ? void 0 : _this$store$tempOrder11.products) || []);
|
|
6964
7453
|
case 3:
|
|
7454
|
+
// Keep the pre-removal snapshot guard separate from the ownership guard:
|
|
7455
|
+
// deleting these rows must not make the async finalization reject its own mutation.
|
|
7456
|
+
if (identities.length) options === null || options === void 0 || (_options$beforeApply3 = options.beforeApply) === null || _options$beforeApply3 === void 0 || _options$beforeApply3.call(options);
|
|
7457
|
+
if (!(isCurrentOrder && !isCurrentOrder())) {
|
|
7458
|
+
_context46.next = 6;
|
|
7459
|
+
break;
|
|
7460
|
+
}
|
|
7461
|
+
return _context46.abrupt("return", ((_this$store$tempOrder12 = this.store.tempOrder) === null || _this$store$tempOrder12 === void 0 ? void 0 : _this$store$tempOrder12.products) || []);
|
|
7462
|
+
case 6:
|
|
6965
7463
|
mutation = this.beginCartMutation();
|
|
6966
7464
|
tempOrder = mutation.draft;
|
|
6967
7465
|
if (identities.length) {
|
|
6968
|
-
|
|
7466
|
+
_context46.next = 10;
|
|
6969
7467
|
break;
|
|
6970
7468
|
}
|
|
6971
|
-
return
|
|
6972
|
-
case
|
|
7469
|
+
return _context46.abrupt("return", tempOrder.products);
|
|
7470
|
+
case 10:
|
|
6973
7471
|
// 商品删除会同步删除以商品行为主关系的 Notes;快照不完整时禁止产生孤儿 Relation。
|
|
6974
7472
|
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
6975
7473
|
this.repairDuplicateProductLineIdentities(tempOrder);
|
|
@@ -7000,30 +7498,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7000
7498
|
this.removeLinkedBookingsForProduct(tempOrder, product);
|
|
7001
7499
|
}
|
|
7002
7500
|
linkedBookingUidsToRemove = new Set();
|
|
7003
|
-
|
|
7004
|
-
|
|
7005
|
-
|
|
7501
|
+
_iterator29 = _createForOfIteratorHelper(matchedProducts);
|
|
7502
|
+
_context46.prev = 23;
|
|
7503
|
+
_loop4 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop4() {
|
|
7006
7504
|
var _metadata11, _metadata12, _metadata13, _metadata14;
|
|
7007
7505
|
var product, productUid, productBookingUid, isAddTimeProduct;
|
|
7008
|
-
return _regeneratorRuntime().wrap(function
|
|
7009
|
-
while (1) switch (
|
|
7506
|
+
return _regeneratorRuntime().wrap(function _loop4$(_context45) {
|
|
7507
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
7010
7508
|
case 0:
|
|
7011
|
-
product =
|
|
7509
|
+
product = _step29.value;
|
|
7012
7510
|
productUid = (product === null || product === void 0 || (_metadata11 = product.metadata) === null || _metadata11 === void 0 ? void 0 : _metadata11.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
7013
7511
|
productBookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_metadata12 = product.metadata) === null || _metadata12 === void 0 ? void 0 : _metadata12.booking_uid);
|
|
7014
7512
|
isAddTimeProduct = (product === null || product === void 0 || (_metadata13 = product.metadata) === null || _metadata13 === void 0 ? void 0 : _metadata13.product_add_schedule_time) !== undefined && (product === null || product === void 0 || (_metadata14 = product.metadata) === null || _metadata14 === void 0 ? void 0 : _metadata14.product_add_schedule_time) !== null;
|
|
7015
7513
|
if (!isAddTimeProduct) {
|
|
7016
|
-
|
|
7514
|
+
_context45.next = 6;
|
|
7017
7515
|
break;
|
|
7018
7516
|
}
|
|
7019
|
-
return
|
|
7517
|
+
return _context45.abrupt("return", 1);
|
|
7020
7518
|
case 6:
|
|
7021
7519
|
if (productBookingUid !== undefined && productBookingUid !== null && productBookingUid !== '') {
|
|
7022
7520
|
linkedBookingUidsToRemove.add(String(productBookingUid));
|
|
7023
7521
|
}
|
|
7024
7522
|
if (productUid !== undefined && productUid !== null && productUid !== '') {
|
|
7025
7523
|
bookingsBeforeRemove.forEach(function (booking) {
|
|
7026
|
-
var bookingUid =
|
|
7524
|
+
var bookingUid = _this51.getBookingUniqueIdentificationNumber(booking);
|
|
7027
7525
|
if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
|
|
7028
7526
|
linkedBookingUidsToRemove.add(bookingUid);
|
|
7029
7527
|
}
|
|
@@ -7031,44 +7529,44 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7031
7529
|
}
|
|
7032
7530
|
case 8:
|
|
7033
7531
|
case "end":
|
|
7034
|
-
return
|
|
7532
|
+
return _context45.stop();
|
|
7035
7533
|
}
|
|
7036
|
-
},
|
|
7534
|
+
}, _loop4);
|
|
7037
7535
|
});
|
|
7038
|
-
|
|
7039
|
-
case
|
|
7040
|
-
if ((
|
|
7041
|
-
|
|
7536
|
+
_iterator29.s();
|
|
7537
|
+
case 26:
|
|
7538
|
+
if ((_step29 = _iterator29.n()).done) {
|
|
7539
|
+
_context46.next = 32;
|
|
7042
7540
|
break;
|
|
7043
7541
|
}
|
|
7044
|
-
return
|
|
7045
|
-
case
|
|
7046
|
-
if (!
|
|
7047
|
-
|
|
7542
|
+
return _context46.delegateYield(_loop4(), "t0", 28);
|
|
7543
|
+
case 28:
|
|
7544
|
+
if (!_context46.t0) {
|
|
7545
|
+
_context46.next = 30;
|
|
7048
7546
|
break;
|
|
7049
7547
|
}
|
|
7050
|
-
return
|
|
7051
|
-
case
|
|
7052
|
-
|
|
7548
|
+
return _context46.abrupt("continue", 30);
|
|
7549
|
+
case 30:
|
|
7550
|
+
_context46.next = 26;
|
|
7053
7551
|
break;
|
|
7054
|
-
case
|
|
7055
|
-
|
|
7552
|
+
case 32:
|
|
7553
|
+
_context46.next = 37;
|
|
7056
7554
|
break;
|
|
7057
|
-
case 31:
|
|
7058
|
-
_context41.prev = 31;
|
|
7059
|
-
_context41.t1 = _context41["catch"](20);
|
|
7060
|
-
_iterator24.e(_context41.t1);
|
|
7061
7555
|
case 34:
|
|
7062
|
-
|
|
7063
|
-
|
|
7064
|
-
|
|
7556
|
+
_context46.prev = 34;
|
|
7557
|
+
_context46.t1 = _context46["catch"](23);
|
|
7558
|
+
_iterator29.e(_context46.t1);
|
|
7065
7559
|
case 37:
|
|
7560
|
+
_context46.prev = 37;
|
|
7561
|
+
_iterator29.f();
|
|
7562
|
+
return _context46.finish(37);
|
|
7563
|
+
case 40:
|
|
7066
7564
|
if (linkedBookingUidsToRemove.size > 0) {
|
|
7067
7565
|
// 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
|
|
7068
7566
|
tempOrder.products = (tempOrder.products || []).filter(function (line) {
|
|
7069
|
-
var _line$
|
|
7070
|
-
var lineBookingUid = (line === null || line === void 0 || (_line$
|
|
7071
|
-
var isAddTimeProduct = (line === null || line === void 0 || (_line$
|
|
7567
|
+
var _line$metadata9, _line$metadata10, _line$metadata11;
|
|
7568
|
+
var lineBookingUid = (line === null || line === void 0 || (_line$metadata9 = line.metadata) === null || _line$metadata9 === void 0 ? void 0 : _line$metadata9.booking_uid) || (line === null || line === void 0 ? void 0 : line.booking_uid);
|
|
7569
|
+
var isAddTimeProduct = (line === null || line === void 0 || (_line$metadata10 = line.metadata) === null || _line$metadata10 === void 0 ? void 0 : _line$metadata10.product_add_schedule_time) !== undefined && (line === null || line === void 0 || (_line$metadata11 = line.metadata) === null || _line$metadata11 === void 0 ? void 0 : _line$metadata11.product_add_schedule_time) !== null;
|
|
7072
7570
|
return !(isAddTimeProduct && lineBookingUid !== undefined && lineBookingUid !== null && linkedBookingUidsToRemove.has(String(lineBookingUid)));
|
|
7073
7571
|
});
|
|
7074
7572
|
}
|
|
@@ -7097,43 +7595,44 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7097
7595
|
tempOrder.shop_discount = '0.00';
|
|
7098
7596
|
}
|
|
7099
7597
|
if (!mutation.commit) {
|
|
7100
|
-
|
|
7598
|
+
_context46.next = 49;
|
|
7101
7599
|
break;
|
|
7102
7600
|
}
|
|
7103
|
-
|
|
7601
|
+
_context46.next = 48;
|
|
7104
7602
|
return mutation.commit({
|
|
7105
|
-
isCurrentOrder: isCurrentOrder
|
|
7603
|
+
isCurrentOrder: isCurrentOrder,
|
|
7604
|
+
beforeCommit: options === null || options === void 0 ? void 0 : options.beforeApply
|
|
7106
7605
|
});
|
|
7107
|
-
case
|
|
7108
|
-
tempOrder =
|
|
7109
|
-
case
|
|
7606
|
+
case 48:
|
|
7607
|
+
tempOrder = _context46.sent;
|
|
7608
|
+
case 49:
|
|
7110
7609
|
if (!isCurrentOrder) {
|
|
7111
|
-
|
|
7610
|
+
_context46.next = 54;
|
|
7112
7611
|
break;
|
|
7113
7612
|
}
|
|
7114
|
-
|
|
7613
|
+
_context46.next = 52;
|
|
7115
7614
|
return this.finalizeProductOrderMutation(tempOrder, {
|
|
7116
7615
|
skipEditDiscountConfigRefresh: true,
|
|
7117
7616
|
isCurrentOrder: isCurrentOrder
|
|
7118
7617
|
});
|
|
7119
|
-
case
|
|
7120
|
-
|
|
7618
|
+
case 52:
|
|
7619
|
+
_context46.next = 56;
|
|
7121
7620
|
break;
|
|
7122
|
-
case
|
|
7123
|
-
|
|
7621
|
+
case 54:
|
|
7622
|
+
_context46.next = 56;
|
|
7124
7623
|
return this.finalizeAfterProductsMutation(tempOrder);
|
|
7125
|
-
case
|
|
7624
|
+
case 56:
|
|
7126
7625
|
this.logInfo('removeProductsFromOrder success', {
|
|
7127
7626
|
identities: identities
|
|
7128
7627
|
});
|
|
7129
|
-
return
|
|
7130
|
-
case
|
|
7628
|
+
return _context46.abrupt("return", tempOrder.products);
|
|
7629
|
+
case 58:
|
|
7131
7630
|
case "end":
|
|
7132
|
-
return
|
|
7631
|
+
return _context46.stop();
|
|
7133
7632
|
}
|
|
7134
|
-
},
|
|
7633
|
+
}, _callee42, this, [[23, 34, 37, 40]]);
|
|
7135
7634
|
}));
|
|
7136
|
-
function removeProductsFromOrderDraft(
|
|
7635
|
+
function removeProductsFromOrderDraft(_x56, _x57) {
|
|
7137
7636
|
return _removeProductsFromOrderDraft.apply(this, arguments);
|
|
7138
7637
|
}
|
|
7139
7638
|
return removeProductsFromOrderDraft;
|
|
@@ -7141,18 +7640,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7141
7640
|
}, {
|
|
7142
7641
|
key: "removeProductFromOrder",
|
|
7143
7642
|
value: function () {
|
|
7144
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7145
|
-
return _regeneratorRuntime().wrap(function
|
|
7146
|
-
while (1) switch (
|
|
7643
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(identity, options) {
|
|
7644
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context47) {
|
|
7645
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
7147
7646
|
case 0:
|
|
7148
|
-
return
|
|
7647
|
+
return _context47.abrupt("return", this.removeProductsFromOrder([identity], options));
|
|
7149
7648
|
case 1:
|
|
7150
7649
|
case "end":
|
|
7151
|
-
return
|
|
7650
|
+
return _context47.stop();
|
|
7152
7651
|
}
|
|
7153
|
-
},
|
|
7652
|
+
}, _callee43, this);
|
|
7154
7653
|
}));
|
|
7155
|
-
function removeProductFromOrder(
|
|
7654
|
+
function removeProductFromOrder(_x58, _x59) {
|
|
7156
7655
|
return _removeProductFromOrder.apply(this, arguments);
|
|
7157
7656
|
}
|
|
7158
7657
|
return removeProductFromOrder;
|
|
@@ -7164,19 +7663,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7164
7663
|
}, {
|
|
7165
7664
|
key: "clearOrderCartLines",
|
|
7166
7665
|
value: (function () {
|
|
7167
|
-
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7168
|
-
var
|
|
7169
|
-
return _regeneratorRuntime().wrap(function
|
|
7170
|
-
while (1) switch (
|
|
7666
|
+
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
|
|
7667
|
+
var _this52 = this;
|
|
7668
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context48) {
|
|
7669
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
7171
7670
|
case 0:
|
|
7172
|
-
return
|
|
7173
|
-
return
|
|
7671
|
+
return _context48.abrupt("return", this.queueCartCommand(function () {
|
|
7672
|
+
return _this52.clearOrderCartLinesDraft();
|
|
7174
7673
|
}));
|
|
7175
7674
|
case 1:
|
|
7176
7675
|
case "end":
|
|
7177
|
-
return
|
|
7676
|
+
return _context48.stop();
|
|
7178
7677
|
}
|
|
7179
|
-
},
|
|
7678
|
+
}, _callee44, this);
|
|
7180
7679
|
}));
|
|
7181
7680
|
function clearOrderCartLines() {
|
|
7182
7681
|
return _clearOrderCartLines.apply(this, arguments);
|
|
@@ -7186,10 +7685,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7186
7685
|
}, {
|
|
7187
7686
|
key: "clearOrderCartLinesDraft",
|
|
7188
7687
|
value: function () {
|
|
7189
|
-
var _clearOrderCartLinesDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7688
|
+
var _clearOrderCartLinesDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45() {
|
|
7190
7689
|
var mutation, tempOrder, promotionPayload;
|
|
7191
|
-
return _regeneratorRuntime().wrap(function
|
|
7192
|
-
while (1) switch (
|
|
7690
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context49) {
|
|
7691
|
+
while (1) switch (_context49.prev = _context49.next) {
|
|
7193
7692
|
case 0:
|
|
7194
7693
|
mutation = this.beginCartMutation();
|
|
7195
7694
|
tempOrder = mutation.draft;
|
|
@@ -7207,21 +7706,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7207
7706
|
});
|
|
7208
7707
|
}
|
|
7209
7708
|
if (!mutation.commit) {
|
|
7210
|
-
|
|
7709
|
+
_context49.next = 15;
|
|
7211
7710
|
break;
|
|
7212
7711
|
}
|
|
7213
|
-
|
|
7712
|
+
_context49.next = 14;
|
|
7214
7713
|
return mutation.commit();
|
|
7215
7714
|
case 14:
|
|
7216
|
-
tempOrder =
|
|
7715
|
+
tempOrder = _context49.sent;
|
|
7217
7716
|
case 15:
|
|
7218
|
-
|
|
7717
|
+
_context49.next = 17;
|
|
7219
7718
|
return this.evaluatePromotion();
|
|
7220
7719
|
case 17:
|
|
7221
|
-
promotionPayload =
|
|
7720
|
+
promotionPayload = _context49.sent;
|
|
7222
7721
|
this.applyDiscount();
|
|
7223
7722
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
7224
|
-
|
|
7723
|
+
_context49.next = 22;
|
|
7225
7724
|
return this.recalculateSummary({
|
|
7226
7725
|
createIfMissing: true
|
|
7227
7726
|
});
|
|
@@ -7229,12 +7728,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7229
7728
|
this.persistTempOrder();
|
|
7230
7729
|
this.emitPromotionApplied(promotionPayload);
|
|
7231
7730
|
this.logInfo('clearOrderCartLines success', {});
|
|
7232
|
-
return
|
|
7731
|
+
return _context49.abrupt("return", tempOrder);
|
|
7233
7732
|
case 26:
|
|
7234
7733
|
case "end":
|
|
7235
|
-
return
|
|
7734
|
+
return _context49.stop();
|
|
7236
7735
|
}
|
|
7237
|
-
},
|
|
7736
|
+
}, _callee45, this);
|
|
7238
7737
|
}));
|
|
7239
7738
|
function clearOrderCartLinesDraft() {
|
|
7240
7739
|
return _clearOrderCartLinesDraft.apply(this, arguments);
|
|
@@ -7247,11 +7746,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7247
7746
|
}, {
|
|
7248
7747
|
key: "clearOrderForSettlementSwitch",
|
|
7249
7748
|
value: (function () {
|
|
7250
|
-
var _clearOrderForSettlementSwitch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7749
|
+
var _clearOrderForSettlementSwitch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
|
|
7251
7750
|
var _this$store$discount22, _this$store$discount23;
|
|
7252
7751
|
var tempOrder;
|
|
7253
|
-
return _regeneratorRuntime().wrap(function
|
|
7254
|
-
while (1) switch (
|
|
7752
|
+
return _regeneratorRuntime().wrap(function _callee46$(_context50) {
|
|
7753
|
+
while (1) switch (_context50.prev = _context50.next) {
|
|
7255
7754
|
case 0:
|
|
7256
7755
|
tempOrder = this.ensureTempOrder();
|
|
7257
7756
|
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
@@ -7271,28 +7770,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7271
7770
|
productsByUid: {}
|
|
7272
7771
|
});
|
|
7273
7772
|
}
|
|
7274
|
-
|
|
7773
|
+
_context50.next = 16;
|
|
7275
7774
|
return (_this$store$discount22 = this.store.discount) === null || _this$store$discount22 === void 0 ? void 0 : _this$store$discount22.setDiscountList([]);
|
|
7276
7775
|
case 16:
|
|
7277
|
-
|
|
7776
|
+
_context50.next = 18;
|
|
7278
7777
|
return (_this$store$discount23 = this.store.discount) === null || _this$store$discount23 === void 0 ? void 0 : _this$store$discount23.setOriginalDiscountList([]);
|
|
7279
7778
|
case 18:
|
|
7280
7779
|
this.hasActiveCustomerBoundDiscount = false;
|
|
7281
7780
|
this.lastUnfulfilledPromotions = [];
|
|
7282
7781
|
this.lastGiftActions = null;
|
|
7283
|
-
|
|
7782
|
+
_context50.next = 23;
|
|
7284
7783
|
return this.recalculateSummary({
|
|
7285
7784
|
createIfMissing: true
|
|
7286
7785
|
});
|
|
7287
7786
|
case 23:
|
|
7288
7787
|
this.persistTempOrder();
|
|
7289
7788
|
this.logInfo('clearOrderForSettlementSwitch success', {});
|
|
7290
|
-
return
|
|
7789
|
+
return _context50.abrupt("return", tempOrder);
|
|
7291
7790
|
case 26:
|
|
7292
7791
|
case "end":
|
|
7293
|
-
return
|
|
7792
|
+
return _context50.stop();
|
|
7294
7793
|
}
|
|
7295
|
-
},
|
|
7794
|
+
}, _callee46, this);
|
|
7296
7795
|
}));
|
|
7297
7796
|
function clearOrderForSettlementSwitch() {
|
|
7298
7797
|
return _clearOrderForSettlementSwitch.apply(this, arguments);
|
|
@@ -7330,17 +7829,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7330
7829
|
}, {
|
|
7331
7830
|
key: "applyLocalPrintOrderNumbers",
|
|
7332
7831
|
value: function () {
|
|
7333
|
-
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7832
|
+
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(order) {
|
|
7334
7833
|
var tempOrder, shopOrderNumber, shopFullOrderNumber;
|
|
7335
|
-
return _regeneratorRuntime().wrap(function
|
|
7336
|
-
while (1) switch (
|
|
7834
|
+
return _regeneratorRuntime().wrap(function _callee47$(_context51) {
|
|
7835
|
+
while (1) switch (_context51.prev = _context51.next) {
|
|
7337
7836
|
case 0:
|
|
7338
7837
|
tempOrder = this.ensureTempOrder();
|
|
7339
7838
|
if (!(!order || _typeof(order) !== 'object')) {
|
|
7340
|
-
|
|
7839
|
+
_context51.next = 3;
|
|
7341
7840
|
break;
|
|
7342
7841
|
}
|
|
7343
|
-
return
|
|
7842
|
+
return _context51.abrupt("return", tempOrder);
|
|
7344
7843
|
case 3:
|
|
7345
7844
|
shopOrderNumber = order.shop_order_number;
|
|
7346
7845
|
shopFullOrderNumber = order.shop_full_order_number;
|
|
@@ -7351,17 +7850,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7351
7850
|
tempOrder.shop_full_order_number = String(shopFullOrderNumber);
|
|
7352
7851
|
}
|
|
7353
7852
|
this.persistTempOrder();
|
|
7354
|
-
|
|
7853
|
+
_context51.next = 10;
|
|
7355
7854
|
return this.saveDraft();
|
|
7356
7855
|
case 10:
|
|
7357
|
-
return
|
|
7856
|
+
return _context51.abrupt("return", tempOrder);
|
|
7358
7857
|
case 11:
|
|
7359
7858
|
case "end":
|
|
7360
|
-
return
|
|
7859
|
+
return _context51.stop();
|
|
7361
7860
|
}
|
|
7362
|
-
},
|
|
7861
|
+
}, _callee47, this);
|
|
7363
7862
|
}));
|
|
7364
|
-
function applyLocalPrintOrderNumbers(
|
|
7863
|
+
function applyLocalPrintOrderNumbers(_x60) {
|
|
7365
7864
|
return _applyLocalPrintOrderNumbers.apply(this, arguments);
|
|
7366
7865
|
}
|
|
7367
7866
|
return applyLocalPrintOrderNumbers;
|
|
@@ -7369,35 +7868,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7369
7868
|
}, {
|
|
7370
7869
|
key: "saveTempOrderAsDraft",
|
|
7371
7870
|
value: function () {
|
|
7372
|
-
var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7871
|
+
var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(params) {
|
|
7373
7872
|
var _params$cacheId2, _this$otherParams8, _this$otherParams9, _this$otherParams10, _params$type, _this$otherParams11, _payload$products;
|
|
7374
7873
|
var tempOrder, latestSummary, payload;
|
|
7375
|
-
return _regeneratorRuntime().wrap(function
|
|
7376
|
-
while (1) switch (
|
|
7874
|
+
return _regeneratorRuntime().wrap(function _callee48$(_context52) {
|
|
7875
|
+
while (1) switch (_context52.prev = _context52.next) {
|
|
7377
7876
|
case 0:
|
|
7378
7877
|
tempOrder = this.ensureTempOrder();
|
|
7379
7878
|
this.ensureExternalSaleNumber(tempOrder);
|
|
7380
7879
|
this.persistTempOrder();
|
|
7381
|
-
|
|
7880
|
+
_context52.next = 5;
|
|
7382
7881
|
return this.recalculateSummary({
|
|
7383
7882
|
createIfMissing: true
|
|
7384
7883
|
});
|
|
7385
7884
|
case 5:
|
|
7386
|
-
|
|
7387
|
-
if (
|
|
7388
|
-
|
|
7885
|
+
_context52.t1 = _context52.sent;
|
|
7886
|
+
if (_context52.t1) {
|
|
7887
|
+
_context52.next = 8;
|
|
7389
7888
|
break;
|
|
7390
7889
|
}
|
|
7391
|
-
|
|
7890
|
+
_context52.t1 = this.store.summary;
|
|
7392
7891
|
case 8:
|
|
7393
|
-
|
|
7394
|
-
if (
|
|
7395
|
-
|
|
7892
|
+
_context52.t0 = _context52.t1;
|
|
7893
|
+
if (_context52.t0) {
|
|
7894
|
+
_context52.next = 11;
|
|
7396
7895
|
break;
|
|
7397
7896
|
}
|
|
7398
|
-
|
|
7897
|
+
_context52.t0 = createEmptySummary();
|
|
7399
7898
|
case 11:
|
|
7400
|
-
latestSummary =
|
|
7899
|
+
latestSummary = _context52.t0;
|
|
7401
7900
|
payload = buildSubmitPayload({
|
|
7402
7901
|
tempOrder: tempOrder,
|
|
7403
7902
|
cacheId: (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId,
|
|
@@ -7418,17 +7917,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7418
7917
|
externalSaleNumber: payload.external_sale_number,
|
|
7419
7918
|
productsCount: ((_payload$products = payload.products) === null || _payload$products === void 0 ? void 0 : _payload$products.length) || 0
|
|
7420
7919
|
});
|
|
7421
|
-
return
|
|
7920
|
+
return _context52.abrupt("return", this.request.post('/order/sales/draft', payload, {
|
|
7422
7921
|
osServer: true,
|
|
7423
7922
|
customToast: function customToast() {}
|
|
7424
7923
|
}));
|
|
7425
7924
|
case 18:
|
|
7426
7925
|
case "end":
|
|
7427
|
-
return
|
|
7926
|
+
return _context52.stop();
|
|
7428
7927
|
}
|
|
7429
|
-
},
|
|
7928
|
+
}, _callee48, this);
|
|
7430
7929
|
}));
|
|
7431
|
-
function saveTempOrderAsDraft(
|
|
7930
|
+
function saveTempOrderAsDraft(_x61) {
|
|
7432
7931
|
return _saveTempOrderAsDraft.apply(this, arguments);
|
|
7433
7932
|
}
|
|
7434
7933
|
return saveTempOrderAsDraft;
|
|
@@ -7442,18 +7941,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7442
7941
|
}, {
|
|
7443
7942
|
key: "submitTempOrder",
|
|
7444
7943
|
value: (function () {
|
|
7445
|
-
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7446
|
-
return _regeneratorRuntime().wrap(function
|
|
7447
|
-
while (1) switch (
|
|
7944
|
+
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(params) {
|
|
7945
|
+
return _regeneratorRuntime().wrap(function _callee49$(_context53) {
|
|
7946
|
+
while (1) switch (_context53.prev = _context53.next) {
|
|
7448
7947
|
case 0:
|
|
7449
|
-
return
|
|
7948
|
+
return _context53.abrupt("return", this.runSubmitTempOrder(params));
|
|
7450
7949
|
case 1:
|
|
7451
7950
|
case "end":
|
|
7452
|
-
return
|
|
7951
|
+
return _context53.stop();
|
|
7453
7952
|
}
|
|
7454
|
-
},
|
|
7953
|
+
}, _callee49, this);
|
|
7455
7954
|
}));
|
|
7456
|
-
function submitTempOrder(
|
|
7955
|
+
function submitTempOrder(_x62) {
|
|
7457
7956
|
return _submitTempOrder.apply(this, arguments);
|
|
7458
7957
|
}
|
|
7459
7958
|
return submitTempOrder;
|
|
@@ -7461,20 +7960,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7461
7960
|
}, {
|
|
7462
7961
|
key: "submitTempOrderAsync",
|
|
7463
7962
|
value: function () {
|
|
7464
|
-
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7465
|
-
return _regeneratorRuntime().wrap(function
|
|
7466
|
-
while (1) switch (
|
|
7963
|
+
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(params) {
|
|
7964
|
+
return _regeneratorRuntime().wrap(function _callee50$(_context54) {
|
|
7965
|
+
while (1) switch (_context54.prev = _context54.next) {
|
|
7467
7966
|
case 0:
|
|
7468
|
-
return
|
|
7967
|
+
return _context54.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
7469
7968
|
syncMode: true
|
|
7470
7969
|
})));
|
|
7471
7970
|
case 1:
|
|
7472
7971
|
case "end":
|
|
7473
|
-
return
|
|
7972
|
+
return _context54.stop();
|
|
7474
7973
|
}
|
|
7475
|
-
},
|
|
7974
|
+
}, _callee50, this);
|
|
7476
7975
|
}));
|
|
7477
|
-
function submitTempOrderAsync(
|
|
7976
|
+
function submitTempOrderAsync(_x63) {
|
|
7478
7977
|
return _submitTempOrderAsync.apply(this, arguments);
|
|
7479
7978
|
}
|
|
7480
7979
|
return submitTempOrderAsync;
|
|
@@ -7482,15 +7981,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7482
7981
|
}, {
|
|
7483
7982
|
key: "runSubmitTempOrder",
|
|
7484
7983
|
value: function () {
|
|
7485
|
-
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7984
|
+
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
|
|
7486
7985
|
var _params$cacheId3, _this$otherParams12, _ref93, _ref94, _submitSnapshot$busin, _this$otherParams13, _this$otherParams14, _submitSnapshot$type;
|
|
7487
7986
|
var tempOrder, isOnlineStorePlatform, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, shouldOverridePaymentStatus, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, isLocalPendingSubmit, salesNotesState, submittedOrderId, resultRecord;
|
|
7488
|
-
return _regeneratorRuntime().wrap(function
|
|
7489
|
-
while (1) switch (
|
|
7987
|
+
return _regeneratorRuntime().wrap(function _callee51$(_context55) {
|
|
7988
|
+
while (1) switch (_context55.prev = _context55.next) {
|
|
7490
7989
|
case 0:
|
|
7491
7990
|
tempOrder = this.ensureTempOrder();
|
|
7492
7991
|
if (!requiresLocalPaymentRefresh(tempOrder)) {
|
|
7493
|
-
|
|
7992
|
+
_context55.next = 3;
|
|
7494
7993
|
break;
|
|
7495
7994
|
}
|
|
7496
7995
|
throw new Error(PAYMENT_REFRESH_MESSAGE);
|
|
@@ -7517,26 +8016,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7517
8016
|
}
|
|
7518
8017
|
}
|
|
7519
8018
|
this.persistTempOrder();
|
|
7520
|
-
|
|
8019
|
+
_context55.next = 13;
|
|
7521
8020
|
return this.recalculateSummary({
|
|
7522
8021
|
createIfMissing: true
|
|
7523
8022
|
});
|
|
7524
8023
|
case 13:
|
|
7525
|
-
|
|
7526
|
-
if (
|
|
7527
|
-
|
|
8024
|
+
_context55.t1 = _context55.sent;
|
|
8025
|
+
if (_context55.t1) {
|
|
8026
|
+
_context55.next = 16;
|
|
7528
8027
|
break;
|
|
7529
8028
|
}
|
|
7530
|
-
|
|
8029
|
+
_context55.t1 = this.store.summary;
|
|
7531
8030
|
case 16:
|
|
7532
|
-
|
|
7533
|
-
if (
|
|
7534
|
-
|
|
8031
|
+
_context55.t0 = _context55.t1;
|
|
8032
|
+
if (_context55.t0) {
|
|
8033
|
+
_context55.next = 19;
|
|
7535
8034
|
break;
|
|
7536
8035
|
}
|
|
7537
|
-
|
|
8036
|
+
_context55.t0 = createEmptySummary();
|
|
7538
8037
|
case 19:
|
|
7539
|
-
latestSummary =
|
|
8038
|
+
latestSummary = _context55.t0;
|
|
7540
8039
|
effectiveCacheId = (_params$cacheId3 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId3 !== void 0 ? _params$cacheId3 : this.cacheId;
|
|
7541
8040
|
hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
|
|
7542
8041
|
shouldOverridePaymentStatus = hasPaymentStatusOverride && !isOnlineStorePlatform && !shouldConfirmPendingVoucherPayments;
|
|
@@ -7572,10 +8071,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7572
8071
|
if (!payload.created_at) {
|
|
7573
8072
|
payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
7574
8073
|
}
|
|
7575
|
-
|
|
8074
|
+
_context55.next = 31;
|
|
7576
8075
|
return this.saveDraft();
|
|
7577
8076
|
case 31:
|
|
7578
|
-
|
|
8077
|
+
_context55.prev = 31;
|
|
7579
8078
|
this.logInfo('submitTempOrder calling sales checkout', {
|
|
7580
8079
|
orderId: payload.order_id,
|
|
7581
8080
|
externalSaleNumber: payload.external_sale_number,
|
|
@@ -7585,43 +8084,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7585
8084
|
smallTicketDataFlag: payload.small_ticket_data_flag,
|
|
7586
8085
|
syncMode: payload.sync_mode
|
|
7587
8086
|
});
|
|
7588
|
-
|
|
8087
|
+
_context55.next = 35;
|
|
7589
8088
|
return this.submitSalesOrder({
|
|
7590
8089
|
query: payload
|
|
7591
8090
|
});
|
|
7592
8091
|
case 35:
|
|
7593
|
-
result =
|
|
7594
|
-
|
|
8092
|
+
result = _context55.sent;
|
|
8093
|
+
_context55.next = 48;
|
|
7595
8094
|
break;
|
|
7596
8095
|
case 38:
|
|
7597
|
-
|
|
7598
|
-
|
|
7599
|
-
backendErrorResponse = this.extractSubmitErrorResponse(
|
|
8096
|
+
_context55.prev = 38;
|
|
8097
|
+
_context55.t2 = _context55["catch"](31);
|
|
8098
|
+
backendErrorResponse = this.extractSubmitErrorResponse(_context55.t2);
|
|
7600
8099
|
if (!backendErrorResponse) {
|
|
7601
|
-
|
|
8100
|
+
_context55.next = 45;
|
|
7602
8101
|
break;
|
|
7603
8102
|
}
|
|
7604
8103
|
this.store.syncState = 'failed';
|
|
7605
8104
|
this.logSubmitBackendRejected(backendErrorResponse, payload);
|
|
7606
|
-
return
|
|
8105
|
+
return _context55.abrupt("return", backendErrorResponse);
|
|
7607
8106
|
case 45:
|
|
7608
8107
|
this.store.syncState = 'failed';
|
|
7609
8108
|
this.logError('submitTempOrder failed', {
|
|
7610
|
-
error:
|
|
8109
|
+
error: _context55.t2 instanceof Error ? _context55.t2.message : String(_context55.t2),
|
|
7611
8110
|
orderId: payload.order_id,
|
|
7612
8111
|
externalSaleNumber: payload.external_sale_number,
|
|
7613
8112
|
paymentStatus: payload.payment_status,
|
|
7614
8113
|
paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
|
|
7615
8114
|
});
|
|
7616
|
-
throw
|
|
8115
|
+
throw _context55.t2;
|
|
7617
8116
|
case 48:
|
|
7618
8117
|
if (!this.isSubmitResponseRejected(result)) {
|
|
7619
|
-
|
|
8118
|
+
_context55.next = 52;
|
|
7620
8119
|
break;
|
|
7621
8120
|
}
|
|
7622
8121
|
this.store.syncState = 'failed';
|
|
7623
8122
|
this.logSubmitBackendRejected(result, payload);
|
|
7624
|
-
return
|
|
8123
|
+
return _context55.abrupt("return", result);
|
|
7625
8124
|
case 52:
|
|
7626
8125
|
isLocalPendingSubmit = this.isLocalPendingSubmitResult(result); // need_sync=1 仅表示已进入本地同步队列,不能视为远端已确认 Notes。
|
|
7627
8126
|
if (Object.prototype.hasOwnProperty.call(payload, 'notes') && !isLocalPendingSubmit) {
|
|
@@ -7637,12 +8136,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7637
8136
|
})
|
|
7638
8137
|
});
|
|
7639
8138
|
if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
|
|
7640
|
-
|
|
8139
|
+
_context55.next = 61;
|
|
7641
8140
|
break;
|
|
7642
8141
|
}
|
|
7643
8142
|
tempOrder.order_id = submittedOrderId;
|
|
7644
8143
|
resultRecord = result;
|
|
7645
|
-
|
|
8144
|
+
_context55.next = 61;
|
|
7646
8145
|
return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
|
|
7647
8146
|
case 61:
|
|
7648
8147
|
if (isLocalPendingSubmit) {
|
|
@@ -7650,14 +8149,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7650
8149
|
} else if (submittedOrderId === null || submittedOrderId === undefined) {
|
|
7651
8150
|
this.store.syncState = 'submitted';
|
|
7652
8151
|
}
|
|
7653
|
-
return
|
|
8152
|
+
return _context55.abrupt("return", result);
|
|
7654
8153
|
case 63:
|
|
7655
8154
|
case "end":
|
|
7656
|
-
return
|
|
8155
|
+
return _context55.stop();
|
|
7657
8156
|
}
|
|
7658
|
-
},
|
|
8157
|
+
}, _callee51, this, [[31, 38]]);
|
|
7659
8158
|
}));
|
|
7660
|
-
function runSubmitTempOrder(
|
|
8159
|
+
function runSubmitTempOrder(_x64) {
|
|
7661
8160
|
return _runSubmitTempOrder.apply(this, arguments);
|
|
7662
8161
|
}
|
|
7663
8162
|
return runSubmitTempOrder;
|
|
@@ -7665,10 +8164,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7665
8164
|
}, {
|
|
7666
8165
|
key: "markLocalOrderSynced",
|
|
7667
8166
|
value: function () {
|
|
7668
|
-
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8167
|
+
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(orderId, remoteOrder) {
|
|
7669
8168
|
var tempOrder;
|
|
7670
|
-
return _regeneratorRuntime().wrap(function
|
|
7671
|
-
while (1) switch (
|
|
8169
|
+
return _regeneratorRuntime().wrap(function _callee52$(_context56) {
|
|
8170
|
+
while (1) switch (_context56.prev = _context56.next) {
|
|
7672
8171
|
case 0:
|
|
7673
8172
|
tempOrder = this.ensureTempOrder();
|
|
7674
8173
|
tempOrder.order_id = orderId;
|
|
@@ -7676,15 +8175,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7676
8175
|
this.store.lastOrderInfo = remoteOrder;
|
|
7677
8176
|
this.store.syncState = 'submitted';
|
|
7678
8177
|
this.persistTempOrder();
|
|
7679
|
-
|
|
8178
|
+
_context56.next = 8;
|
|
7680
8179
|
return this.saveDraft();
|
|
7681
8180
|
case 8:
|
|
7682
8181
|
case "end":
|
|
7683
|
-
return
|
|
8182
|
+
return _context56.stop();
|
|
7684
8183
|
}
|
|
7685
|
-
},
|
|
8184
|
+
}, _callee52, this);
|
|
7686
8185
|
}));
|
|
7687
|
-
function markLocalOrderSynced(
|
|
8186
|
+
function markLocalOrderSynced(_x65, _x66) {
|
|
7688
8187
|
return _markLocalOrderSynced.apply(this, arguments);
|
|
7689
8188
|
}
|
|
7690
8189
|
return markLocalOrderSynced;
|
|
@@ -7727,10 +8226,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7727
8226
|
value: function extractSubmitErrorResponse(error) {
|
|
7728
8227
|
var _error$response,
|
|
7729
8228
|
_error$response2,
|
|
7730
|
-
|
|
8229
|
+
_this53 = this;
|
|
7731
8230
|
var candidates = [error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data, error === null || error === void 0 ? void 0 : error.data, error === null || error === void 0 || (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.body, error === null || error === void 0 ? void 0 : error.body];
|
|
7732
8231
|
return candidates.find(function (candidate) {
|
|
7733
|
-
return
|
|
8232
|
+
return _this53.isSubmitErrorResponse(candidate);
|
|
7734
8233
|
}) || null;
|
|
7735
8234
|
}
|
|
7736
8235
|
}, {
|
|
@@ -7757,33 +8256,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7757
8256
|
}, {
|
|
7758
8257
|
key: "syncPaymentsToOrder",
|
|
7759
8258
|
value: function () {
|
|
7760
|
-
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7761
|
-
var
|
|
8259
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(params) {
|
|
8260
|
+
var _this54 = this,
|
|
7762
8261
|
_params$confirmPendin;
|
|
7763
8262
|
var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, enhancePayload, submitParams, submitResult;
|
|
7764
|
-
return _regeneratorRuntime().wrap(function
|
|
7765
|
-
while (1) switch (
|
|
8263
|
+
return _regeneratorRuntime().wrap(function _callee53$(_context57) {
|
|
8264
|
+
while (1) switch (_context57.prev = _context57.next) {
|
|
7766
8265
|
case 0:
|
|
7767
8266
|
tempOrder = this.ensureTempOrder();
|
|
7768
8267
|
needsPaymentNumber = (params.payments || []).some(function (payment) {
|
|
7769
8268
|
return String(payment.payment_number || '').trim() === '';
|
|
7770
8269
|
});
|
|
7771
8270
|
if (!needsPaymentNumber) {
|
|
7772
|
-
|
|
8271
|
+
_context57.next = 8;
|
|
7773
8272
|
break;
|
|
7774
8273
|
}
|
|
7775
|
-
|
|
8274
|
+
_context57.next = 5;
|
|
7776
8275
|
return this.getPaymentNumberDevicePrefixAsync();
|
|
7777
8276
|
case 5:
|
|
7778
|
-
|
|
7779
|
-
|
|
8277
|
+
_context57.t0 = _context57.sent;
|
|
8278
|
+
_context57.next = 9;
|
|
7780
8279
|
break;
|
|
7781
8280
|
case 8:
|
|
7782
|
-
|
|
8281
|
+
_context57.t0 = 'LOCAL';
|
|
7783
8282
|
case 9:
|
|
7784
|
-
devicePrefix =
|
|
8283
|
+
devicePrefix = _context57.t0;
|
|
7785
8284
|
mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
|
|
7786
|
-
return
|
|
8285
|
+
return _this54.normalizePaymentSource(payment, {
|
|
7787
8286
|
defaultPaid: false,
|
|
7788
8287
|
devicePrefix: devicePrefix
|
|
7789
8288
|
});
|
|
@@ -7796,20 +8295,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7796
8295
|
tempOrder.payments = effectivePayments;
|
|
7797
8296
|
tempOrder.payment_status = paymentStatus;
|
|
7798
8297
|
this.persistTempOrder();
|
|
7799
|
-
|
|
8298
|
+
_context57.next = 21;
|
|
7800
8299
|
return this.saveDraft();
|
|
7801
8300
|
case 21:
|
|
7802
8301
|
if (params.submitWhenPaid) {
|
|
7803
|
-
|
|
8302
|
+
_context57.next = 23;
|
|
7804
8303
|
break;
|
|
7805
8304
|
}
|
|
7806
|
-
return
|
|
8305
|
+
return _context57.abrupt("return", completion);
|
|
7807
8306
|
case 23:
|
|
7808
8307
|
if (!(this.store.syncState === 'submitting')) {
|
|
7809
|
-
|
|
8308
|
+
_context57.next = 25;
|
|
7810
8309
|
break;
|
|
7811
8310
|
}
|
|
7812
|
-
return
|
|
8311
|
+
return _context57.abrupt("return", completion);
|
|
7813
8312
|
case 25:
|
|
7814
8313
|
this.store.syncState = 'submitting';
|
|
7815
8314
|
paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, effectivePayments);
|
|
@@ -7829,32 +8328,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7829
8328
|
enhancePayload: enhancePayload
|
|
7830
8329
|
};
|
|
7831
8330
|
if (!(params.checkoutSyncTaskEnabled === false)) {
|
|
7832
|
-
|
|
8331
|
+
_context57.next = 35;
|
|
7833
8332
|
break;
|
|
7834
8333
|
}
|
|
7835
|
-
|
|
8334
|
+
_context57.next = 32;
|
|
7836
8335
|
return this.submitTempOrderAsync(submitParams);
|
|
7837
8336
|
case 32:
|
|
7838
|
-
|
|
7839
|
-
|
|
8337
|
+
_context57.t1 = _context57.sent;
|
|
8338
|
+
_context57.next = 38;
|
|
7840
8339
|
break;
|
|
7841
8340
|
case 35:
|
|
7842
|
-
|
|
8341
|
+
_context57.next = 37;
|
|
7843
8342
|
return this.submitTempOrder(submitParams);
|
|
7844
8343
|
case 37:
|
|
7845
|
-
|
|
8344
|
+
_context57.t1 = _context57.sent;
|
|
7846
8345
|
case 38:
|
|
7847
|
-
submitResult =
|
|
7848
|
-
return
|
|
8346
|
+
submitResult = _context57.t1;
|
|
8347
|
+
return _context57.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
|
|
7849
8348
|
submitResult: submitResult
|
|
7850
8349
|
}));
|
|
7851
8350
|
case 40:
|
|
7852
8351
|
case "end":
|
|
7853
|
-
return
|
|
8352
|
+
return _context57.stop();
|
|
7854
8353
|
}
|
|
7855
|
-
},
|
|
8354
|
+
}, _callee53, this);
|
|
7856
8355
|
}));
|
|
7857
|
-
function syncPaymentsToOrder(
|
|
8356
|
+
function syncPaymentsToOrder(_x67) {
|
|
7858
8357
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
7859
8358
|
}
|
|
7860
8359
|
return syncPaymentsToOrder;
|
|
@@ -7862,7 +8361,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7862
8361
|
}, {
|
|
7863
8362
|
key: "createOrder",
|
|
7864
8363
|
value: function createOrder(params) {
|
|
7865
|
-
var
|
|
8364
|
+
var _this55 = this;
|
|
7866
8365
|
var order = _objectSpread({
|
|
7867
8366
|
type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
|
|
7868
8367
|
// 要从外面拿,virtual
|
|
@@ -7894,7 +8393,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7894
8393
|
|
|
7895
8394
|
// 为预约补齐 holder 信息
|
|
7896
8395
|
if (params !== null && params !== void 0 && (_params$extraData = params.extraData) !== null && _params$extraData !== void 0 && _params$extraData.is_add_holder_info) {
|
|
7897
|
-
ensureCartItemOriginHolder(item,
|
|
8396
|
+
ensureCartItemOriginHolder(item, _this55.window);
|
|
7898
8397
|
}
|
|
7899
8398
|
|
|
7900
8399
|
// 购物车是否为普通商品
|
|
@@ -7951,11 +8450,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7951
8450
|
}, {
|
|
7952
8451
|
key: "submitOrder",
|
|
7953
8452
|
value: function () {
|
|
7954
|
-
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8453
|
+
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(order) {
|
|
7955
8454
|
var _order$query$cartItem, _params$bookings, _params$relation_prod;
|
|
7956
8455
|
var url, query, fetchUrl, params;
|
|
7957
|
-
return _regeneratorRuntime().wrap(function
|
|
7958
|
-
while (1) switch (
|
|
8456
|
+
return _regeneratorRuntime().wrap(function _callee54$(_context58) {
|
|
8457
|
+
while (1) switch (_context58.prev = _context58.next) {
|
|
7959
8458
|
case 0:
|
|
7960
8459
|
this.logInfo('submitOrder called', {
|
|
7961
8460
|
url: order.url,
|
|
@@ -7975,14 +8474,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7975
8474
|
relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
|
|
7976
8475
|
scheduleDate: params.schedule_date
|
|
7977
8476
|
});
|
|
7978
|
-
return
|
|
8477
|
+
return _context58.abrupt("return", this.request.post(fetchUrl, params));
|
|
7979
8478
|
case 6:
|
|
7980
8479
|
case "end":
|
|
7981
|
-
return
|
|
8480
|
+
return _context58.stop();
|
|
7982
8481
|
}
|
|
7983
|
-
},
|
|
8482
|
+
}, _callee54, this);
|
|
7984
8483
|
}));
|
|
7985
|
-
function submitOrder(
|
|
8484
|
+
function submitOrder(_x68) {
|
|
7986
8485
|
return _submitOrder.apply(this, arguments);
|
|
7987
8486
|
}
|
|
7988
8487
|
return submitOrder;
|
|
@@ -7990,13 +8489,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7990
8489
|
}, {
|
|
7991
8490
|
key: "cancelOrder",
|
|
7992
8491
|
value: function () {
|
|
7993
|
-
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8492
|
+
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(params) {
|
|
7994
8493
|
var payload;
|
|
7995
|
-
return _regeneratorRuntime().wrap(function
|
|
7996
|
-
while (1) switch (
|
|
8494
|
+
return _regeneratorRuntime().wrap(function _callee55$(_context59) {
|
|
8495
|
+
while (1) switch (_context59.prev = _context59.next) {
|
|
7997
8496
|
case 0:
|
|
7998
8497
|
if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
|
|
7999
|
-
|
|
8498
|
+
_context59.next = 2;
|
|
8000
8499
|
break;
|
|
8001
8500
|
}
|
|
8002
8501
|
throw new Error('取消订单失败:order_ids 不能为空');
|
|
@@ -8012,16 +8511,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8012
8511
|
method: 'PUT',
|
|
8013
8512
|
orderIdsCount: params.order_ids.length
|
|
8014
8513
|
});
|
|
8015
|
-
return
|
|
8514
|
+
return _context59.abrupt("return", this.request.put('/order/update-status', payload, {
|
|
8016
8515
|
isShopApi: true
|
|
8017
8516
|
}));
|
|
8018
8517
|
case 5:
|
|
8019
8518
|
case "end":
|
|
8020
|
-
return
|
|
8519
|
+
return _context59.stop();
|
|
8021
8520
|
}
|
|
8022
|
-
},
|
|
8521
|
+
}, _callee55, this);
|
|
8023
8522
|
}));
|
|
8024
|
-
function cancelOrder(
|
|
8523
|
+
function cancelOrder(_x69) {
|
|
8025
8524
|
return _cancelOrder.apply(this, arguments);
|
|
8026
8525
|
}
|
|
8027
8526
|
return cancelOrder;
|
|
@@ -8029,19 +8528,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8029
8528
|
}, {
|
|
8030
8529
|
key: "changeBookingStatus",
|
|
8031
8530
|
value: function () {
|
|
8032
|
-
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8531
|
+
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(params) {
|
|
8033
8532
|
var url, payload;
|
|
8034
|
-
return _regeneratorRuntime().wrap(function
|
|
8035
|
-
while (1) switch (
|
|
8533
|
+
return _regeneratorRuntime().wrap(function _callee56$(_context60) {
|
|
8534
|
+
while (1) switch (_context60.prev = _context60.next) {
|
|
8036
8535
|
case 0:
|
|
8037
8536
|
if (params.booking_id) {
|
|
8038
|
-
|
|
8537
|
+
_context60.next = 2;
|
|
8039
8538
|
break;
|
|
8040
8539
|
}
|
|
8041
8540
|
throw new Error('变更预约状态失败:booking_id 不能为空');
|
|
8042
8541
|
case 2:
|
|
8043
8542
|
if (params.appointment_status) {
|
|
8044
|
-
|
|
8543
|
+
_context60.next = 4;
|
|
8045
8544
|
break;
|
|
8046
8545
|
}
|
|
8047
8546
|
throw new Error('变更预约状态失败:appointment_status 不能为空');
|
|
@@ -8056,16 +8555,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8056
8555
|
bookingId: params.booking_id,
|
|
8057
8556
|
appointmentStatus: params.appointment_status
|
|
8058
8557
|
});
|
|
8059
|
-
return
|
|
8558
|
+
return _context60.abrupt("return", this.request.put(url, payload, {
|
|
8060
8559
|
isShopApi: true
|
|
8061
8560
|
}));
|
|
8062
8561
|
case 8:
|
|
8063
8562
|
case "end":
|
|
8064
|
-
return
|
|
8563
|
+
return _context60.stop();
|
|
8065
8564
|
}
|
|
8066
|
-
},
|
|
8565
|
+
}, _callee56, this);
|
|
8067
8566
|
}));
|
|
8068
|
-
function changeBookingStatus(
|
|
8567
|
+
function changeBookingStatus(_x70) {
|
|
8069
8568
|
return _changeBookingStatus.apply(this, arguments);
|
|
8070
8569
|
}
|
|
8071
8570
|
return changeBookingStatus;
|
|
@@ -8083,11 +8582,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8083
8582
|
}, {
|
|
8084
8583
|
key: "createOrderByCheckout",
|
|
8085
8584
|
value: (function () {
|
|
8086
|
-
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8585
|
+
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
|
|
8087
8586
|
var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3;
|
|
8088
8587
|
var onlineStorePaymentCodeList, _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, orderData, response;
|
|
8089
|
-
return _regeneratorRuntime().wrap(function
|
|
8090
|
-
while (1) switch (
|
|
8588
|
+
return _regeneratorRuntime().wrap(function _callee57$(_context61) {
|
|
8589
|
+
while (1) switch (_context61.prev = _context61.next) {
|
|
8091
8590
|
case 0:
|
|
8092
8591
|
// 过滤掉由在线店铺下单的 payment 支付数据
|
|
8093
8592
|
onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
|
|
@@ -8112,7 +8611,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8112
8611
|
return p.code;
|
|
8113
8612
|
})) || []
|
|
8114
8613
|
});
|
|
8115
|
-
|
|
8614
|
+
_context61.prev = 3;
|
|
8116
8615
|
// 构建订单数据,设置默认值并允许 params 覆盖
|
|
8117
8616
|
orderData = _objectSpread({
|
|
8118
8617
|
sales_channel: 'my_pisel',
|
|
@@ -8160,32 +8659,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8160
8659
|
hasOrderId: !!orderData.order_id,
|
|
8161
8660
|
smallTicketDataFlag: orderData.small_ticket_data_flag
|
|
8162
8661
|
});
|
|
8163
|
-
|
|
8662
|
+
_context61.next = 10;
|
|
8164
8663
|
return this.request.post('/order/checkout', orderData, {
|
|
8165
8664
|
osServer: true,
|
|
8166
8665
|
customToast: function customToast() {}
|
|
8167
8666
|
});
|
|
8168
8667
|
case 10:
|
|
8169
|
-
response =
|
|
8668
|
+
response = _context61.sent;
|
|
8170
8669
|
this.logInfo('Order API called successfully', {
|
|
8171
8670
|
response: response
|
|
8172
8671
|
});
|
|
8173
|
-
return
|
|
8672
|
+
return _context61.abrupt("return", response);
|
|
8174
8673
|
case 15:
|
|
8175
|
-
|
|
8176
|
-
|
|
8177
|
-
console.error('[Order] createOrderByCheckout 创建订单失败:',
|
|
8674
|
+
_context61.prev = 15;
|
|
8675
|
+
_context61.t0 = _context61["catch"](3);
|
|
8676
|
+
console.error('[Order] createOrderByCheckout 创建订单失败:', _context61.t0);
|
|
8178
8677
|
this.logInfo('Order API called failed', {
|
|
8179
|
-
error:
|
|
8678
|
+
error: _context61.t0 instanceof Error ? _context61.t0.message : String(_context61.t0)
|
|
8180
8679
|
});
|
|
8181
|
-
throw
|
|
8680
|
+
throw _context61.t0;
|
|
8182
8681
|
case 20:
|
|
8183
8682
|
case "end":
|
|
8184
|
-
return
|
|
8683
|
+
return _context61.stop();
|
|
8185
8684
|
}
|
|
8186
|
-
},
|
|
8685
|
+
}, _callee57, this, [[3, 15]]);
|
|
8187
8686
|
}));
|
|
8188
|
-
function createOrderByCheckout(
|
|
8687
|
+
function createOrderByCheckout(_x71) {
|
|
8189
8688
|
return _createOrderByCheckout.apply(this, arguments);
|
|
8190
8689
|
}
|
|
8191
8690
|
return createOrderByCheckout;
|
|
@@ -8193,25 +8692,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8193
8692
|
}, {
|
|
8194
8693
|
key: "submitSalesOrder",
|
|
8195
8694
|
value: function () {
|
|
8196
|
-
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8695
|
+
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(params) {
|
|
8197
8696
|
var url, query, fetchUrl, requestQuery;
|
|
8198
|
-
return _regeneratorRuntime().wrap(function
|
|
8199
|
-
while (1) switch (
|
|
8697
|
+
return _regeneratorRuntime().wrap(function _callee58$(_context62) {
|
|
8698
|
+
while (1) switch (_context62.prev = _context62.next) {
|
|
8200
8699
|
case 0:
|
|
8201
8700
|
url = params.url, query = params.query;
|
|
8202
8701
|
fetchUrl = url || '/order/sales/checkout';
|
|
8203
8702
|
requestQuery = this.isSalesCheckoutHandledByOsServer(fetchUrl) ? query : stripLocalEftposState(stripOsPrivatePayloadFields(query));
|
|
8204
|
-
return
|
|
8703
|
+
return _context62.abrupt("return", this.request.post(fetchUrl, requestQuery, {
|
|
8205
8704
|
osServer: true,
|
|
8206
8705
|
customToast: function customToast() {}
|
|
8207
8706
|
}));
|
|
8208
8707
|
case 4:
|
|
8209
8708
|
case "end":
|
|
8210
|
-
return
|
|
8709
|
+
return _context62.stop();
|
|
8211
8710
|
}
|
|
8212
|
-
},
|
|
8711
|
+
}, _callee58, this);
|
|
8213
8712
|
}));
|
|
8214
|
-
function submitSalesOrder(
|
|
8713
|
+
function submitSalesOrder(_x72) {
|
|
8215
8714
|
return _submitSalesOrder.apply(this, arguments);
|
|
8216
8715
|
}
|
|
8217
8716
|
return submitSalesOrder;
|
|
@@ -8238,37 +8737,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8238
8737
|
}, {
|
|
8239
8738
|
key: "sendCustomerPayLink",
|
|
8240
8739
|
value: (function () {
|
|
8241
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8740
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(params) {
|
|
8242
8741
|
var _params$emails;
|
|
8243
8742
|
var orderIds;
|
|
8244
|
-
return _regeneratorRuntime().wrap(function
|
|
8245
|
-
while (1) switch (
|
|
8743
|
+
return _regeneratorRuntime().wrap(function _callee59$(_context63) {
|
|
8744
|
+
while (1) switch (_context63.prev = _context63.next) {
|
|
8246
8745
|
case 0:
|
|
8247
8746
|
orderIds = params.order_ids || params.orderIds || [];
|
|
8248
8747
|
if (orderIds.length) {
|
|
8249
|
-
|
|
8748
|
+
_context63.next = 3;
|
|
8250
8749
|
break;
|
|
8251
8750
|
}
|
|
8252
8751
|
throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
|
|
8253
8752
|
case 3:
|
|
8254
8753
|
if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
|
|
8255
|
-
|
|
8754
|
+
_context63.next = 5;
|
|
8256
8755
|
break;
|
|
8257
8756
|
}
|
|
8258
8757
|
throw new Error('发送支付链接需要至少一个邮箱');
|
|
8259
8758
|
case 5:
|
|
8260
|
-
return
|
|
8759
|
+
return _context63.abrupt("return", this.request.post('/order/batch-email', {
|
|
8261
8760
|
order_ids: orderIds,
|
|
8262
8761
|
notify_action: params.notify_action || 'order_payment_reminder',
|
|
8263
8762
|
emails: params.emails
|
|
8264
8763
|
}));
|
|
8265
8764
|
case 6:
|
|
8266
8765
|
case "end":
|
|
8267
|
-
return
|
|
8766
|
+
return _context63.stop();
|
|
8268
8767
|
}
|
|
8269
|
-
},
|
|
8768
|
+
}, _callee59, this);
|
|
8270
8769
|
}));
|
|
8271
|
-
function sendCustomerPayLink(
|
|
8770
|
+
function sendCustomerPayLink(_x73) {
|
|
8272
8771
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
8273
8772
|
}
|
|
8274
8773
|
return sendCustomerPayLink;
|
|
@@ -8276,14 +8775,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8276
8775
|
}, {
|
|
8277
8776
|
key: "getSalesOrderByLookup",
|
|
8278
8777
|
value: function () {
|
|
8279
|
-
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8778
|
+
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(params) {
|
|
8280
8779
|
var lookup, res;
|
|
8281
|
-
return _regeneratorRuntime().wrap(function
|
|
8282
|
-
while (1) switch (
|
|
8780
|
+
return _regeneratorRuntime().wrap(function _callee60$(_context64) {
|
|
8781
|
+
while (1) switch (_context64.prev = _context64.next) {
|
|
8283
8782
|
case 0:
|
|
8284
8783
|
lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
|
|
8285
8784
|
if (lookup) {
|
|
8286
|
-
|
|
8785
|
+
_context64.next = 3;
|
|
8287
8786
|
break;
|
|
8288
8787
|
}
|
|
8289
8788
|
throw new Error('加载销售详情需要 lookup');
|
|
@@ -8292,25 +8791,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8292
8791
|
if (lookup.startsWith('LOCAL_')) {
|
|
8293
8792
|
params.forceRemote = false;
|
|
8294
8793
|
}
|
|
8295
|
-
|
|
8794
|
+
_context64.next = 6;
|
|
8296
8795
|
return loadSalesOrderSnapshot(this.request, {
|
|
8297
8796
|
lookup: lookup,
|
|
8298
8797
|
transport: 'os-server',
|
|
8299
8798
|
forceRemote: params.forceRemote
|
|
8300
8799
|
});
|
|
8301
8800
|
case 6:
|
|
8302
|
-
res =
|
|
8801
|
+
res = _context64.sent;
|
|
8303
8802
|
if (res.code === 200) {
|
|
8304
8803
|
this.store.lastOrderInfo = res.data;
|
|
8305
8804
|
}
|
|
8306
|
-
return
|
|
8805
|
+
return _context64.abrupt("return", res);
|
|
8307
8806
|
case 9:
|
|
8308
8807
|
case "end":
|
|
8309
|
-
return
|
|
8808
|
+
return _context64.stop();
|
|
8310
8809
|
}
|
|
8311
|
-
},
|
|
8810
|
+
}, _callee60, this);
|
|
8312
8811
|
}));
|
|
8313
|
-
function getSalesOrderByLookup(
|
|
8812
|
+
function getSalesOrderByLookup(_x74) {
|
|
8314
8813
|
return _getSalesOrderByLookup.apply(this, arguments);
|
|
8315
8814
|
}
|
|
8316
8815
|
return getSalesOrderByLookup;
|
|
@@ -8324,35 +8823,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8324
8823
|
}, {
|
|
8325
8824
|
key: "hydrateTempOrderFromRecord",
|
|
8326
8825
|
value: (function () {
|
|
8327
|
-
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8826
|
+
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(record, options) {
|
|
8328
8827
|
var replacement, nextTempOrder;
|
|
8329
|
-
return _regeneratorRuntime().wrap(function
|
|
8330
|
-
while (1) switch (
|
|
8828
|
+
return _regeneratorRuntime().wrap(function _callee61$(_context65) {
|
|
8829
|
+
while (1) switch (_context65.prev = _context65.next) {
|
|
8331
8830
|
case 0:
|
|
8332
8831
|
replacement = this.beginOrderReplacement(options === null || options === void 0 ? void 0 : options.preserveOrderSessionId);
|
|
8333
|
-
|
|
8334
|
-
|
|
8832
|
+
_context65.prev = 1;
|
|
8833
|
+
_context65.next = 4;
|
|
8335
8834
|
return this.prepareHydratedTempOrder(record, options, replacement);
|
|
8336
8835
|
case 4:
|
|
8337
|
-
nextTempOrder =
|
|
8836
|
+
nextTempOrder = _context65.sent;
|
|
8338
8837
|
this.assertOrderReplacementCurrent(replacement);
|
|
8339
8838
|
this.persistTempOrder();
|
|
8340
8839
|
this.completeOrderReplacement(replacement, nextTempOrder, options === null || options === void 0 ? void 0 : options.preserveOrderSessionId);
|
|
8341
|
-
return
|
|
8840
|
+
return _context65.abrupt("return", nextTempOrder);
|
|
8342
8841
|
case 11:
|
|
8343
|
-
|
|
8344
|
-
|
|
8345
|
-
|
|
8842
|
+
_context65.prev = 11;
|
|
8843
|
+
_context65.t0 = _context65["catch"](1);
|
|
8844
|
+
_context65.next = 15;
|
|
8346
8845
|
return this.rollbackOrderReplacement(replacement);
|
|
8347
8846
|
case 15:
|
|
8348
|
-
throw
|
|
8847
|
+
throw _context65.t0;
|
|
8349
8848
|
case 16:
|
|
8350
8849
|
case "end":
|
|
8351
|
-
return
|
|
8850
|
+
return _context65.stop();
|
|
8352
8851
|
}
|
|
8353
|
-
},
|
|
8852
|
+
}, _callee61, this, [[1, 11]]);
|
|
8354
8853
|
}));
|
|
8355
|
-
function hydrateTempOrderFromRecord(
|
|
8854
|
+
function hydrateTempOrderFromRecord(_x75, _x76) {
|
|
8356
8855
|
return _hydrateTempOrderFromRecord.apply(this, arguments);
|
|
8357
8856
|
}
|
|
8358
8857
|
return hydrateTempOrderFromRecord;
|
|
@@ -8360,13 +8859,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8360
8859
|
}, {
|
|
8361
8860
|
key: "prepareHydratedTempOrder",
|
|
8362
8861
|
value: function () {
|
|
8363
|
-
var _prepareHydratedTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8862
|
+
var _prepareHydratedTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(record, options, replacement) {
|
|
8364
8863
|
var _sourceRaw$_extend,
|
|
8365
|
-
|
|
8864
|
+
_this56 = this,
|
|
8366
8865
|
_this$store$discount26;
|
|
8367
8866
|
var sourceRaw, duplicateProductIdentityRepair, duplicateIdentityReadySource, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, isSessionStorageHydrate, isMergedSalesDetailHydrate, nextTempOrder, _this$store$discount24, _this$store$discount25, restoredSessionDiscounts, nextExtend, sourceLastOrderInfo, isDraftOrder, syntheticIdentityOptions, rawSummary, historicalDepositSnapshot, summarySurcharges, hadSyntheticDraftOrderId, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount27, _this$store$discount28;
|
|
8368
|
-
return _regeneratorRuntime().wrap(function
|
|
8369
|
-
while (1) switch (
|
|
8867
|
+
return _regeneratorRuntime().wrap(function _callee62$(_context66) {
|
|
8868
|
+
while (1) switch (_context66.prev = _context66.next) {
|
|
8370
8869
|
case 0:
|
|
8371
8870
|
sourceRaw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
|
|
8372
8871
|
duplicateProductIdentityRepair = repairDuplicateOrderProductLineIdentities(Array.isArray(sourceRaw.products) ? sourceRaw.products : [], (_sourceRaw$_extend = sourceRaw._extend) === null || _sourceRaw$_extend === void 0 ? void 0 : _sourceRaw$_extend.productsByUid);
|
|
@@ -8408,7 +8907,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8408
8907
|
this.store.tempOrder = nextTempOrder;
|
|
8409
8908
|
this.clearCustomerWalletRuntimeState();
|
|
8410
8909
|
if (!isSessionStorageHydrate) {
|
|
8411
|
-
|
|
8910
|
+
_context66.next = 32;
|
|
8412
8911
|
break;
|
|
8413
8912
|
}
|
|
8414
8913
|
// 会话快照是未提交购物车,不应获得编辑订单的 saved/edit 标记与服务端基线。
|
|
@@ -8424,27 +8923,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8424
8923
|
nextTempOrder.discount_list = restoredSessionDiscounts;
|
|
8425
8924
|
this.store.summary = createEmptySummary();
|
|
8426
8925
|
this.store.lastOrderInfo = undefined;
|
|
8427
|
-
|
|
8926
|
+
_context66.next = 24;
|
|
8428
8927
|
return (_this$store$discount24 = this.store.discount) === null || _this$store$discount24 === void 0 ? void 0 : _this$store$discount24.setOriginalDiscountList(cloneDeep(restoredSessionDiscounts));
|
|
8429
8928
|
case 24:
|
|
8430
8929
|
this.assertOrderReplacementCurrent(replacement);
|
|
8431
|
-
|
|
8930
|
+
_context66.next = 27;
|
|
8432
8931
|
return (_this$store$discount25 = this.store.discount) === null || _this$store$discount25 === void 0 ? void 0 : _this$store$discount25.setDiscountList(cloneDeep(restoredSessionDiscounts));
|
|
8433
8932
|
case 27:
|
|
8434
8933
|
this.assertOrderReplacementCurrent(replacement);
|
|
8435
8934
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
8436
|
-
|
|
8935
|
+
_context66.next = 31;
|
|
8437
8936
|
break;
|
|
8438
8937
|
}
|
|
8439
|
-
|
|
8938
|
+
_context66.next = 31;
|
|
8440
8939
|
return this.recalculateSummary({
|
|
8441
8940
|
createIfMissing: false,
|
|
8442
8941
|
isCurrentOrder: function isCurrentOrder() {
|
|
8443
|
-
return
|
|
8942
|
+
return _this56.orderReplacement === replacement;
|
|
8444
8943
|
}
|
|
8445
8944
|
});
|
|
8446
8945
|
case 31:
|
|
8447
|
-
return
|
|
8946
|
+
return _context66.abrupt("return", nextTempOrder);
|
|
8448
8947
|
case 32:
|
|
8449
8948
|
// Server list compatibility may synthesize order_id from external_sale_number; tempOrder must not.
|
|
8450
8949
|
sourceLastOrderInfo = sourceRaw.lastOrderInfo || sourceRaw;
|
|
@@ -8497,39 +8996,39 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8497
8996
|
nextDiscounts = [].concat(_toConsumableArray(hydratedEditDiscounts), _toConsumableArray(retainedScanDiscounts));
|
|
8498
8997
|
shouldSkipEmptyDiscountSync = nextDiscounts.length === 0 && currentDiscounts.length === 0;
|
|
8499
8998
|
if (shouldSkipEmptyDiscountSync) {
|
|
8500
|
-
|
|
8999
|
+
_context66.next = 58;
|
|
8501
9000
|
break;
|
|
8502
9001
|
}
|
|
8503
9002
|
OrderModule.populateSavedAmounts(nextTempOrder.products, nextDiscounts);
|
|
8504
|
-
|
|
9003
|
+
_context66.next = 54;
|
|
8505
9004
|
return (_this$store$discount27 = this.store.discount) === null || _this$store$discount27 === void 0 ? void 0 : _this$store$discount27.setOriginalDiscountList(nextDiscounts);
|
|
8506
9005
|
case 54:
|
|
8507
9006
|
this.assertOrderReplacementCurrent(replacement);
|
|
8508
|
-
|
|
9007
|
+
_context66.next = 57;
|
|
8509
9008
|
return (_this$store$discount28 = this.store.discount) === null || _this$store$discount28 === void 0 ? void 0 : _this$store$discount28.setDiscountList(nextDiscounts);
|
|
8510
9009
|
case 57:
|
|
8511
9010
|
this.assertOrderReplacementCurrent(replacement);
|
|
8512
9011
|
case 58:
|
|
8513
9012
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
8514
|
-
|
|
9013
|
+
_context66.next = 61;
|
|
8515
9014
|
break;
|
|
8516
9015
|
}
|
|
8517
|
-
|
|
9016
|
+
_context66.next = 61;
|
|
8518
9017
|
return this.recalculateSummary({
|
|
8519
9018
|
createIfMissing: false,
|
|
8520
9019
|
isCurrentOrder: function isCurrentOrder() {
|
|
8521
|
-
return
|
|
9020
|
+
return _this56.orderReplacement === replacement;
|
|
8522
9021
|
}
|
|
8523
9022
|
});
|
|
8524
9023
|
case 61:
|
|
8525
|
-
return
|
|
9024
|
+
return _context66.abrupt("return", nextTempOrder);
|
|
8526
9025
|
case 62:
|
|
8527
9026
|
case "end":
|
|
8528
|
-
return
|
|
9027
|
+
return _context66.stop();
|
|
8529
9028
|
}
|
|
8530
|
-
},
|
|
9029
|
+
}, _callee62, this);
|
|
8531
9030
|
}));
|
|
8532
|
-
function prepareHydratedTempOrder(
|
|
9031
|
+
function prepareHydratedTempOrder(_x77, _x78, _x79) {
|
|
8533
9032
|
return _prepareHydratedTempOrder.apply(this, arguments);
|
|
8534
9033
|
}
|
|
8535
9034
|
return prepareHydratedTempOrder;
|
|
@@ -8577,12 +9076,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8577
9076
|
if (!raw || _typeof(raw) !== 'object') return {};
|
|
8578
9077
|
if (!Array.isArray(raw.bookings) || !Array.isArray(raw.products)) return raw;
|
|
8579
9078
|
var bookingUidsByProductUid = new Map();
|
|
8580
|
-
var
|
|
8581
|
-
|
|
9079
|
+
var _iterator30 = _createForOfIteratorHelper(raw.products),
|
|
9080
|
+
_step30;
|
|
8582
9081
|
try {
|
|
8583
|
-
for (
|
|
9082
|
+
for (_iterator30.s(); !(_step30 = _iterator30.n()).done;) {
|
|
8584
9083
|
var _product$metadata13;
|
|
8585
|
-
var product =
|
|
9084
|
+
var product = _step30.value;
|
|
8586
9085
|
var productUid = getOrderCollectionUid('product', product);
|
|
8587
9086
|
var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata13 = product.metadata) === null || _product$metadata13 === void 0 ? void 0 : _product$metadata13.booking_uid);
|
|
8588
9087
|
if (!productUid || bookingUid === undefined || bookingUid === null || bookingUid === '') {
|
|
@@ -8593,18 +9092,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8593
9092
|
bookingUidsByProductUid.set(productUid, candidates);
|
|
8594
9093
|
}
|
|
8595
9094
|
} catch (err) {
|
|
8596
|
-
|
|
9095
|
+
_iterator30.e(err);
|
|
8597
9096
|
} finally {
|
|
8598
|
-
|
|
9097
|
+
_iterator30.f();
|
|
8599
9098
|
}
|
|
8600
9099
|
if (bookingUidsByProductUid.size === 0) return raw;
|
|
8601
9100
|
var anonymousBookingCountByProductUid = new Map();
|
|
8602
|
-
var
|
|
8603
|
-
|
|
9101
|
+
var _iterator31 = _createForOfIteratorHelper(raw.bookings),
|
|
9102
|
+
_step31;
|
|
8604
9103
|
try {
|
|
8605
|
-
for (
|
|
9104
|
+
for (_iterator31.s(); !(_step31 = _iterator31.n()).done;) {
|
|
8606
9105
|
var _booking$metadata9;
|
|
8607
|
-
var booking =
|
|
9106
|
+
var booking = _step31.value;
|
|
8608
9107
|
if (getOrderCollectionPersistentId('booking', booking) || getOrderCollectionUid('booking', booking)) {
|
|
8609
9108
|
continue;
|
|
8610
9109
|
}
|
|
@@ -8614,9 +9113,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8614
9113
|
anonymousBookingCountByProductUid.set(key, (anonymousBookingCountByProductUid.get(key) || 0) + 1);
|
|
8615
9114
|
}
|
|
8616
9115
|
} catch (err) {
|
|
8617
|
-
|
|
9116
|
+
_iterator31.e(err);
|
|
8618
9117
|
} finally {
|
|
8619
|
-
|
|
9118
|
+
_iterator31.f();
|
|
8620
9119
|
}
|
|
8621
9120
|
return _objectSpread(_objectSpread({}, raw), {}, {
|
|
8622
9121
|
bookings: raw.bookings.map(function (booking) {
|
|
@@ -8642,7 +9141,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8642
9141
|
}, {
|
|
8643
9142
|
key: "normalizeTempOrderForRuntime",
|
|
8644
9143
|
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
8645
|
-
var
|
|
9144
|
+
var _this57 = this,
|
|
8646
9145
|
_raw$_extend;
|
|
8647
9146
|
var runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
|
|
8648
9147
|
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
|
|
@@ -8670,12 +9169,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8670
9169
|
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
8671
9170
|
var rawProducts = Array.isArray(raw.products) ? raw.products : [];
|
|
8672
9171
|
nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
|
|
8673
|
-
return
|
|
9172
|
+
return _this57.normalizeHydratedOrderProduct(p, {
|
|
8674
9173
|
makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
|
|
8675
9174
|
});
|
|
8676
9175
|
}) : [];
|
|
8677
9176
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
8678
|
-
var booking =
|
|
9177
|
+
var booking = _this57.normalizeHydratedBookingHolder(b || {});
|
|
8679
9178
|
return _objectSpread(_objectSpread({}, booking), {}, {
|
|
8680
9179
|
is_all: normalizeBookingIsAll(booking),
|
|
8681
9180
|
sub_type: normalizeBookingSubType(booking)
|
|
@@ -8721,14 +9220,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8721
9220
|
dirty: decodedSalesNotes.complete && ((restoredSalesNotesState === null || restoredSalesNotesState === void 0 ? void 0 : restoredSalesNotesState.dirty) === true || allowUnresolvedSalesNotes && hasUnresolvedSalesNoteOrderTarget)
|
|
8722
9221
|
};
|
|
8723
9222
|
var productsByUid = tempOrderExtend.productsByUid || {};
|
|
8724
|
-
var
|
|
8725
|
-
|
|
9223
|
+
var _iterator32 = _createForOfIteratorHelper(nextTempOrder.products.entries()),
|
|
9224
|
+
_step32;
|
|
8726
9225
|
try {
|
|
8727
|
-
for (
|
|
9226
|
+
for (_iterator32.s(); !(_step32 = _iterator32.n()).done;) {
|
|
8728
9227
|
var _product$metadata14, _ref95, _ref96, _existed$origin, _rawProduct$metadata;
|
|
8729
|
-
var
|
|
8730
|
-
index =
|
|
8731
|
-
product =
|
|
9228
|
+
var _step32$value = _slicedToArray(_step32.value, 2),
|
|
9229
|
+
index = _step32$value[0],
|
|
9230
|
+
product = _step32$value[1];
|
|
8732
9231
|
var uid = (_product$metadata14 = product.metadata) === null || _product$metadata14 === void 0 ? void 0 : _product$metadata14.unique_identification_number;
|
|
8733
9232
|
if (!uid) continue;
|
|
8734
9233
|
var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
|
|
@@ -8749,14 +9248,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8749
9248
|
});
|
|
8750
9249
|
}
|
|
8751
9250
|
} catch (err) {
|
|
8752
|
-
|
|
9251
|
+
_iterator32.e(err);
|
|
8753
9252
|
} finally {
|
|
8754
|
-
|
|
9253
|
+
_iterator32.f();
|
|
8755
9254
|
}
|
|
8756
9255
|
tempOrderExtend.productsByUid = productsByUid;
|
|
8757
9256
|
this.hydrateLinkedBookingIdentity(nextTempOrder);
|
|
8758
9257
|
nextTempOrder.products.forEach(function (product) {
|
|
8759
|
-
return
|
|
9258
|
+
return _this57.sanitizeOrderProductForTempOrder(product);
|
|
8760
9259
|
});
|
|
8761
9260
|
if ((options === null || options === void 0 ? void 0 : options.ensureIdentity) !== false) {
|
|
8762
9261
|
this.ensureExternalSaleNumber(nextTempOrder);
|
|
@@ -8846,18 +9345,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8846
9345
|
var segments = [];
|
|
8847
9346
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
8848
9347
|
if (Array.isArray(sku.variant)) {
|
|
8849
|
-
var
|
|
8850
|
-
|
|
9348
|
+
var _iterator33 = _createForOfIteratorHelper(sku.variant),
|
|
9349
|
+
_step33;
|
|
8851
9350
|
try {
|
|
8852
|
-
for (
|
|
8853
|
-
var variant =
|
|
9351
|
+
for (_iterator33.s(); !(_step33 = _iterator33.n()).done;) {
|
|
9352
|
+
var variant = _step33.value;
|
|
8854
9353
|
var segment = this.formatHydratedNamePair(variant === null || variant === void 0 ? void 0 : variant.group, variant === null || variant === void 0 ? void 0 : variant.item);
|
|
8855
9354
|
if (segment) segments.push(segment);
|
|
8856
9355
|
}
|
|
8857
9356
|
} catch (err) {
|
|
8858
|
-
|
|
9357
|
+
_iterator33.e(err);
|
|
8859
9358
|
} finally {
|
|
8860
|
-
|
|
9359
|
+
_iterator33.f();
|
|
8861
9360
|
}
|
|
8862
9361
|
}
|
|
8863
9362
|
return segments.join(', ');
|
|
@@ -8885,7 +9384,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8885
9384
|
}, {
|
|
8886
9385
|
key: "normalizeHydratedOrderProduct",
|
|
8887
9386
|
value: function normalizeHydratedOrderProduct(product, options) {
|
|
8888
|
-
var
|
|
9387
|
+
var _this58 = this;
|
|
8889
9388
|
var row = _objectSpread({}, product || {});
|
|
8890
9389
|
if (row.num === undefined && row.product_quantity !== undefined) {
|
|
8891
9390
|
row.num = row.product_quantity;
|
|
@@ -8893,7 +9392,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8893
9392
|
var productSku = ensureProductSku(row);
|
|
8894
9393
|
row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
|
|
8895
9394
|
option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
|
|
8896
|
-
return
|
|
9395
|
+
return _this58.normalizeHydratedProductOptionItem(optionItem || {});
|
|
8897
9396
|
}))
|
|
8898
9397
|
});
|
|
8899
9398
|
delete row["product_".concat('option', "_item")];
|
|
@@ -8953,27 +9452,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8953
9452
|
}, {
|
|
8954
9453
|
key: "getOrderInfo",
|
|
8955
9454
|
value: function () {
|
|
8956
|
-
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
9455
|
+
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(order_id) {
|
|
8957
9456
|
var res;
|
|
8958
|
-
return _regeneratorRuntime().wrap(function
|
|
8959
|
-
while (1) switch (
|
|
9457
|
+
return _regeneratorRuntime().wrap(function _callee63$(_context67) {
|
|
9458
|
+
while (1) switch (_context67.prev = _context67.next) {
|
|
8960
9459
|
case 0:
|
|
8961
|
-
|
|
9460
|
+
_context67.next = 2;
|
|
8962
9461
|
return this.request.get("/order/sales/".concat(order_id), {
|
|
8963
9462
|
with: ['products', 'bookings', 'notes']
|
|
8964
9463
|
}, {
|
|
8965
9464
|
osServer: true
|
|
8966
9465
|
});
|
|
8967
9466
|
case 2:
|
|
8968
|
-
res =
|
|
8969
|
-
return
|
|
9467
|
+
res = _context67.sent;
|
|
9468
|
+
return _context67.abrupt("return", res);
|
|
8970
9469
|
case 4:
|
|
8971
9470
|
case "end":
|
|
8972
|
-
return
|
|
9471
|
+
return _context67.stop();
|
|
8973
9472
|
}
|
|
8974
|
-
},
|
|
9473
|
+
}, _callee63, this);
|
|
8975
9474
|
}));
|
|
8976
|
-
function getOrderInfo(
|
|
9475
|
+
function getOrderInfo(_x80) {
|
|
8977
9476
|
return _getOrderInfo.apply(this, arguments);
|
|
8978
9477
|
}
|
|
8979
9478
|
return getOrderInfo;
|
|
@@ -8981,8 +9480,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8981
9480
|
}, {
|
|
8982
9481
|
key: "getVouchers",
|
|
8983
9482
|
value: function getVouchers() {
|
|
8984
|
-
var _this$store$
|
|
8985
|
-
return ((_this$store$
|
|
9483
|
+
var _this$store$tempOrder13;
|
|
9484
|
+
return ((_this$store$tempOrder13 = this.store.tempOrder) === null || _this$store$tempOrder13 === void 0 ? void 0 : _this$store$tempOrder13.vouchers) || [];
|
|
8986
9485
|
}
|
|
8987
9486
|
}], [{
|
|
8988
9487
|
key: "populateSavedAmounts",
|
|
@@ -9009,69 +9508,69 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
9009
9508
|
addDiscountAmount(savedMap, discountKey, amount);
|
|
9010
9509
|
addDiscountAmount(isPersistedProduct || discount.order_discount_id != null ? editModeSavedMap : runtimeSavedMap, discountKey, amount);
|
|
9011
9510
|
};
|
|
9012
|
-
var
|
|
9013
|
-
|
|
9511
|
+
var _iterator34 = _createForOfIteratorHelper(productList),
|
|
9512
|
+
_step34;
|
|
9014
9513
|
try {
|
|
9015
|
-
for (
|
|
9016
|
-
var product =
|
|
9514
|
+
for (_iterator34.s(); !(_step34 = _iterator34.n()).done;) {
|
|
9515
|
+
var product = _step34.value;
|
|
9017
9516
|
var qty = product.num || 1;
|
|
9018
9517
|
var isPersistedProduct = Boolean(product.order_detail_id || product.orderDetailId || product.booking_id);
|
|
9019
|
-
var
|
|
9020
|
-
|
|
9518
|
+
var _iterator36 = _createForOfIteratorHelper(product.discount_list || []),
|
|
9519
|
+
_step36;
|
|
9021
9520
|
try {
|
|
9022
|
-
for (
|
|
9023
|
-
var pd =
|
|
9521
|
+
for (_iterator36.s(); !(_step36 = _iterator36.n()).done;) {
|
|
9522
|
+
var pd = _step36.value;
|
|
9024
9523
|
addProductDiscountAmount(pd, qty, isPersistedProduct);
|
|
9025
9524
|
}
|
|
9026
9525
|
} catch (err) {
|
|
9027
|
-
|
|
9526
|
+
_iterator36.e(err);
|
|
9028
9527
|
} finally {
|
|
9029
|
-
|
|
9528
|
+
_iterator36.f();
|
|
9030
9529
|
}
|
|
9031
|
-
var
|
|
9032
|
-
|
|
9530
|
+
var _iterator37 = _createForOfIteratorHelper(product.product_bundle || []),
|
|
9531
|
+
_step37;
|
|
9033
9532
|
try {
|
|
9034
|
-
for (
|
|
9035
|
-
var bundle =
|
|
9533
|
+
for (_iterator37.s(); !(_step37 = _iterator37.n()).done;) {
|
|
9534
|
+
var bundle = _step37.value;
|
|
9036
9535
|
var isPersistedBundleProduct = isPersistedProduct || Boolean((bundle === null || bundle === void 0 ? void 0 : bundle.order_detail_id) || (bundle === null || bundle === void 0 ? void 0 : bundle.orderDetailId) || (bundle === null || bundle === void 0 ? void 0 : bundle.booking_id));
|
|
9037
9536
|
var bundleQty = Number(qty) || 1;
|
|
9038
|
-
var
|
|
9039
|
-
|
|
9537
|
+
var _iterator38 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
|
|
9538
|
+
_step38;
|
|
9040
9539
|
try {
|
|
9041
|
-
for (
|
|
9042
|
-
var _pd =
|
|
9540
|
+
for (_iterator38.s(); !(_step38 = _iterator38.n()).done;) {
|
|
9541
|
+
var _pd = _step38.value;
|
|
9043
9542
|
addProductDiscountAmount(_pd, bundleQty, isPersistedBundleProduct);
|
|
9044
9543
|
}
|
|
9045
9544
|
} catch (err) {
|
|
9046
|
-
|
|
9545
|
+
_iterator38.e(err);
|
|
9047
9546
|
} finally {
|
|
9048
|
-
|
|
9547
|
+
_iterator38.f();
|
|
9049
9548
|
}
|
|
9050
9549
|
}
|
|
9051
9550
|
} catch (err) {
|
|
9052
|
-
|
|
9551
|
+
_iterator37.e(err);
|
|
9053
9552
|
} finally {
|
|
9054
|
-
|
|
9553
|
+
_iterator37.f();
|
|
9055
9554
|
}
|
|
9056
9555
|
}
|
|
9057
9556
|
} catch (err) {
|
|
9058
|
-
|
|
9557
|
+
_iterator34.e(err);
|
|
9059
9558
|
} finally {
|
|
9060
|
-
|
|
9559
|
+
_iterator34.f();
|
|
9061
9560
|
}
|
|
9062
|
-
var
|
|
9063
|
-
|
|
9561
|
+
var _iterator35 = _createForOfIteratorHelper(discountList),
|
|
9562
|
+
_step35;
|
|
9064
9563
|
try {
|
|
9065
|
-
for (
|
|
9066
|
-
var d =
|
|
9564
|
+
for (_iterator35.s(); !(_step35 = _iterator35.n()).done;) {
|
|
9565
|
+
var d = _step35.value;
|
|
9067
9566
|
var key = d.id;
|
|
9068
9567
|
var sourceMap = d.isEditMode ? editModeSavedMap : editModeDiscountKeys.has(key) ? runtimeSavedMap : savedMap;
|
|
9069
9568
|
d.savedAmount = d.isSelected && key != null && sourceMap.has(key) ? sourceMap.get(key).toNumber() : 0;
|
|
9070
9569
|
}
|
|
9071
9570
|
} catch (err) {
|
|
9072
|
-
|
|
9571
|
+
_iterator35.e(err);
|
|
9073
9572
|
} finally {
|
|
9074
|
-
|
|
9573
|
+
_iterator35.f();
|
|
9075
9574
|
}
|
|
9076
9575
|
}
|
|
9077
9576
|
}]);
|