@pisell/pisellos 2.2.291 → 2.2.293
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/core/index.d.ts +7 -0
- package/dist/core/index.js +108 -65
- package/dist/model/strategy/adapter/itemRule/adapter.d.ts +4 -1
- package/dist/model/strategy/adapter/itemRule/adapter.js +135 -35
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +8 -1
- package/dist/model/strategy/adapter/itemRule/evaluator.js +25 -1
- package/dist/model/strategy/adapter/itemRule/type.d.ts +44 -0
- package/dist/model/strategy/adapter/itemRule/type.js +19 -1
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/BookingContext/index.d.ts +3 -0
- package/dist/modules/BookingContext/index.js +42 -13
- package/dist/modules/BookingContext/types.d.ts +4 -4
- package/dist/modules/BookingContext/types.js +3 -3
- package/dist/modules/OpenData/types.d.ts +1 -0
- package/dist/modules/Order/index.d.ts +18 -3
- package/dist/modules/Order/index.js +885 -485
- package/dist/modules/Order/salesNotes.d.ts +31 -0
- package/dist/modules/Order/salesNotes.js +492 -0
- package/dist/modules/Order/types.d.ts +93 -5
- package/dist/modules/Order/types.js +5 -0
- package/dist/modules/Order/utils.d.ts +12 -0
- package/dist/modules/Order/utils.js +96 -31
- package/dist/modules/Product/types.d.ts +2 -0
- package/dist/modules/ProductList/clientDataVariants.d.ts +50 -0
- package/dist/modules/ProductList/clientDataVariants.js +216 -0
- package/dist/modules/ProductList/index.d.ts +18 -3
- package/dist/modules/ProductList/index.js +220 -38
- package/dist/modules/ProductList/types.d.ts +10 -0
- package/dist/modules/Quotation/index.d.ts +22 -0
- package/dist/modules/Quotation/index.js +293 -28
- package/dist/modules/ResourcePlanner/index.d.ts +0 -22
- package/dist/modules/ResourcePlanner/index.js +1 -180
- package/dist/modules/ResourcePlanner/localClock.d.ts +33 -0
- package/dist/modules/ResourcePlanner/localClock.js +183 -0
- package/dist/modules/ResourcePlanner/planner.d.ts +5 -14
- package/dist/modules/ResourcePlanner/planner.js +2111 -958
- package/dist/modules/ResourcePlanner/types.d.ts +359 -187
- package/dist/modules/ResourcePlanner/types.js +33 -1
- package/dist/plugins/request.d.ts +1 -0
- package/dist/server/index.d.ts +17 -2
- package/dist/server/index.js +1134 -932
- package/dist/server/modules/floor-plan/index.d.ts +4 -0
- package/dist/server/modules/floor-plan/index.js +240 -98
- package/dist/server/modules/menu/index.js +48 -23
- package/dist/server/modules/order/index.d.ts +17 -7
- package/dist/server/modules/order/index.js +419 -207
- package/dist/server/modules/products/index.d.ts +10 -4
- package/dist/server/modules/products/index.js +177 -84
- package/dist/server/modules/resource/index.js +21 -13
- package/dist/server/utils/product.d.ts +1 -1
- package/dist/server/utils/product.js +186 -22
- package/dist/server/utils/small-ticket.d.ts +9 -1
- package/dist/server/utils/small-ticket.js +131 -84
- package/dist/solution/BaseSales/index.d.ts +26 -3
- package/dist/solution/BaseSales/index.js +1384 -905
- package/dist/solution/BaseSales/types.d.ts +2 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +3 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +10 -3
- package/dist/solution/BaseSales/utils.js +6 -3
- package/dist/solution/BookingByStep/index.d.ts +4 -4
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +4 -2
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
- package/dist/solution/BookingTicket/utils/addProductDecision.js +6 -3
- package/dist/solution/BookingTicket/utils/orderCustomer.js +3 -2
- package/dist/solution/RegisterAndLogin/config.d.ts +9 -3
- package/dist/solution/RegisterAndLogin/config.js +95 -40
- package/dist/solution/RegisterAndLogin/index.js +4 -1
- package/dist/solution/ScanOrder/index.d.ts +1 -0
- package/dist/solution/ScanOrder/index.js +31 -27
- package/dist/solution/ScanOrder/types.d.ts +2 -0
- package/dist/solution/ScanOrder/utils.d.ts +1 -0
- package/dist/solution/ScanOrder/utils.js +8 -3
- package/dist/solution/UnifiedBookingSales/index.d.ts +128 -74
- package/dist/solution/UnifiedBookingSales/index.js +3877 -963
- package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +49 -0
- package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.js +430 -0
- package/dist/solution/UnifiedBookingSales/types.d.ts +161 -77
- package/dist/solution/UnifiedBookingSales/types.js +4 -9
- package/dist/solution/VenueBooking/index.d.ts +3 -0
- package/dist/solution/VenueBooking/index.js +549 -497
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +3 -1
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +2 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +3 -1
- package/dist/utils/platform.d.ts +8 -0
- package/dist/utils/platform.js +15 -0
- package/lib/core/index.d.ts +7 -0
- package/lib/core/index.js +20 -2
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +4 -1
- package/lib/model/strategy/adapter/itemRule/adapter.js +73 -4
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +8 -1
- package/lib/model/strategy/adapter/itemRule/evaluator.js +23 -1
- package/lib/model/strategy/adapter/itemRule/type.d.ts +44 -0
- package/lib/model/strategy/adapter/itemRule/type.js +19 -1
- package/lib/modules/BookingContext/index.d.ts +3 -0
- package/lib/modules/BookingContext/index.js +35 -8
- package/lib/modules/BookingContext/types.d.ts +4 -4
- package/lib/modules/BookingContext/types.js +3 -3
- package/lib/modules/OpenData/types.d.ts +1 -0
- package/lib/modules/Order/index.d.ts +18 -3
- package/lib/modules/Order/index.js +325 -28
- package/lib/modules/Order/salesNotes.d.ts +31 -0
- package/lib/modules/Order/salesNotes.js +382 -0
- package/lib/modules/Order/types.d.ts +93 -5
- package/lib/modules/Order/types.js +4 -0
- package/lib/modules/Order/utils.d.ts +12 -0
- package/lib/modules/Order/utils.js +85 -16
- package/lib/modules/Product/types.d.ts +2 -0
- package/lib/modules/ProductList/clientDataVariants.d.ts +50 -0
- package/lib/modules/ProductList/clientDataVariants.js +204 -0
- package/lib/modules/ProductList/index.d.ts +18 -3
- package/lib/modules/ProductList/index.js +137 -8
- package/lib/modules/ProductList/types.d.ts +10 -0
- package/lib/modules/Quotation/index.d.ts +22 -0
- package/lib/modules/Quotation/index.js +158 -11
- package/lib/modules/ResourcePlanner/index.d.ts +0 -22
- package/lib/modules/ResourcePlanner/index.js +9 -129
- package/lib/modules/ResourcePlanner/localClock.d.ts +33 -0
- package/lib/modules/ResourcePlanner/localClock.js +205 -0
- package/lib/modules/ResourcePlanner/planner.d.ts +5 -14
- package/lib/modules/ResourcePlanner/planner.js +1807 -783
- package/lib/modules/ResourcePlanner/types.d.ts +359 -187
- package/lib/modules/ResourcePlanner/types.js +13 -1
- package/lib/plugins/request.d.ts +1 -0
- package/lib/server/index.d.ts +17 -2
- package/lib/server/index.js +149 -21
- package/lib/server/modules/floor-plan/index.d.ts +4 -0
- package/lib/server/modules/floor-plan/index.js +60 -7
- package/lib/server/modules/menu/index.js +26 -4
- package/lib/server/modules/order/index.d.ts +17 -7
- package/lib/server/modules/order/index.js +194 -57
- package/lib/server/modules/products/index.d.ts +10 -4
- package/lib/server/modules/products/index.js +93 -23
- package/lib/server/modules/resource/index.js +12 -2
- package/lib/server/utils/product.d.ts +1 -1
- package/lib/server/utils/product.js +163 -3
- package/lib/server/utils/small-ticket.d.ts +9 -1
- package/lib/server/utils/small-ticket.js +123 -79
- package/lib/solution/BaseSales/index.d.ts +26 -3
- package/lib/solution/BaseSales/index.js +396 -70
- package/lib/solution/BaseSales/types.d.ts +2 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +3 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +9 -2
- package/lib/solution/BaseSales/utils.js +3 -0
- package/lib/solution/BookingByStep/index.d.ts +4 -4
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +2 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.js +5 -2
- package/lib/solution/BookingTicket/utils/orderCustomer.js +2 -1
- package/lib/solution/RegisterAndLogin/config.d.ts +9 -3
- package/lib/solution/RegisterAndLogin/config.js +49 -8
- package/lib/solution/RegisterAndLogin/index.js +4 -1
- package/lib/solution/ScanOrder/index.d.ts +1 -0
- package/lib/solution/ScanOrder/index.js +5 -1
- package/lib/solution/ScanOrder/types.d.ts +2 -0
- package/lib/solution/ScanOrder/utils.d.ts +1 -0
- package/lib/solution/ScanOrder/utils.js +4 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +128 -74
- package/lib/solution/UnifiedBookingSales/index.js +2592 -424
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +49 -0
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +316 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +161 -77
- package/lib/solution/UnifiedBookingSales/types.js +4 -6
- package/lib/solution/VenueBooking/index.d.ts +3 -0
- package/lib/solution/VenueBooking/index.js +33 -9
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +3 -1
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +2 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +3 -1
- package/lib/utils/platform.d.ts +8 -0
- package/lib/utils/platform.js +22 -0
- package/package.json +1 -1
|
@@ -34,7 +34,7 @@ import { BaseModule } from "../../modules/BaseModule";
|
|
|
34
34
|
import { BaseSalesHookNames } from "./types";
|
|
35
35
|
import { OrderModule } from "../../modules/Order";
|
|
36
36
|
import Decimal from 'decimal.js';
|
|
37
|
-
import { cloneDeep, mergeWith } from 'lodash-es';
|
|
37
|
+
import { cloneDeep, isEqual, mergeWith } from 'lodash-es';
|
|
38
38
|
import { createModule } from "../BookingByStep/types";
|
|
39
39
|
import { composeLinePrice, createUuidV4, ensureProductSku, getProductSkuOptions, resolveIsFormSubject, sumOptionUnitPrice } from "../../modules/Order/utils";
|
|
40
40
|
import { ensureOrderPaymentNumber, isIdentifiedPendingOrderPayment, isPendingOrderPayment, mergeOrderPaymentListsByIdentity, resolveOrderPaymentIdentity } from "../../modules/Order/payment-utils";
|
|
@@ -42,6 +42,8 @@ import { resolvePaymentNumberDevicePrefix, resolvePaymentNumberDevicePrefixFromD
|
|
|
42
42
|
import { applyOrderCollectionUidRemaps, getOrderCollectionPersistentId, getOrderCollectionReferenceUid, getOrderCollectionUid, isSameOrderCollectionItem, mergeOrderCollectionItems, normalizeOrderCollection, normalizeOrderCollections, setOrderCollectionUid } from "../../modules/Order/utils/orderCollectionIdentity";
|
|
43
43
|
import dayjs from 'dayjs';
|
|
44
44
|
export * from "./types";
|
|
45
|
+
import { isProductQueryHandledByOsServer, PRODUCT_QUERY_DATA_VARIANT_RELATIONS, resolveClientDataVariants, tryResolveClientDataVariants } from "../../modules/ProductList/clientDataVariants";
|
|
46
|
+
import { isCustomerUserPlatform } from "../../utils/platform";
|
|
45
47
|
import { QuotationModule } from "../../modules/Quotation";
|
|
46
48
|
import { transformBaseProductToOrderProduct as _transformBaseProductToOrderProduct } from "./utils/transformBaseProductToOrderProduct";
|
|
47
49
|
import { calculateBaseSalesProductBookingPrice } from "./utils/quotationPrice";
|
|
@@ -318,7 +320,66 @@ function mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey) {
|
|
|
318
320
|
loadedValue.forEach(appendOrReplaceByUid);
|
|
319
321
|
return result;
|
|
320
322
|
}
|
|
323
|
+
|
|
324
|
+
// checkout / realtime snapshots may reorder protocol arrays or append persistence fields.
|
|
325
|
+
// Compare only the Sales Note protocol fields so a matching remote echo can acknowledge dirty state.
|
|
326
|
+
function normalizeBaseSalesNotesForComparison(value, options) {
|
|
327
|
+
var _options$unresolvedOr;
|
|
328
|
+
if (!Array.isArray(value)) return null;
|
|
329
|
+
var unresolvedOrderTargetUuid = String((_options$unresolvedOr = options === null || options === void 0 ? void 0 : options.unresolvedOrderTargetUuid) !== null && _options$unresolvedOr !== void 0 ? _options$unresolvedOr : '').trim();
|
|
330
|
+
return value.map(function (note) {
|
|
331
|
+
var _noteRecord$content;
|
|
332
|
+
if (!note || _typeof(note) !== 'object' || Array.isArray(note)) {
|
|
333
|
+
return cloneDeep(note);
|
|
334
|
+
}
|
|
335
|
+
var noteRecord = note;
|
|
336
|
+
var relations = Array.isArray(noteRecord.note_relations) ? noteRecord.note_relations.map(function (relation) {
|
|
337
|
+
var _relation$target_uuid;
|
|
338
|
+
if (!relation || _typeof(relation) !== 'object' || Array.isArray(relation)) {
|
|
339
|
+
return cloneDeep(relation);
|
|
340
|
+
}
|
|
341
|
+
var shouldResolveOrderTarget = relation.is_primary === 0 && relation.relation_type === 'related_to' && relation.target_type === 'order' && String((_relation$target_uuid = relation.target_uuid) !== null && _relation$target_uuid !== void 0 ? _relation$target_uuid : '').trim() === '' && unresolvedOrderTargetUuid.length > 0;
|
|
342
|
+
return {
|
|
343
|
+
uuid: relation.uuid,
|
|
344
|
+
relation_type: relation.relation_type,
|
|
345
|
+
target_type: relation.target_type,
|
|
346
|
+
target_uuid: shouldResolveOrderTarget ? unresolvedOrderTargetUuid : relation.target_uuid,
|
|
347
|
+
is_primary: relation.is_primary
|
|
348
|
+
};
|
|
349
|
+
}).sort(function (left, right) {
|
|
350
|
+
var _left$uuid, _right$uuid;
|
|
351
|
+
return String((_left$uuid = left === null || left === void 0 ? void 0 : left.uuid) !== null && _left$uuid !== void 0 ? _left$uuid : '').localeCompare(String((_right$uuid = right === null || right === void 0 ? void 0 : right.uuid) !== null && _right$uuid !== void 0 ? _right$uuid : ''));
|
|
352
|
+
}) : cloneDeep(noteRecord.note_relations);
|
|
353
|
+
return {
|
|
354
|
+
uuid: noteRecord.uuid,
|
|
355
|
+
note_type: noteRecord.note_type,
|
|
356
|
+
content: {
|
|
357
|
+
text: cloneDeep((_noteRecord$content = noteRecord.content) === null || _noteRecord$content === void 0 ? void 0 : _noteRecord$content.text)
|
|
358
|
+
},
|
|
359
|
+
importance: noteRecord.importance,
|
|
360
|
+
note_relations: relations
|
|
361
|
+
};
|
|
362
|
+
}).sort(function (left, right) {
|
|
363
|
+
var _left$uuid2, _right$uuid2;
|
|
364
|
+
return String((_left$uuid2 = left === null || left === void 0 ? void 0 : left.uuid) !== null && _left$uuid2 !== void 0 ? _left$uuid2 : '').localeCompare(String((_right$uuid2 = right === null || right === void 0 ? void 0 : right.uuid) !== null && _right$uuid2 !== void 0 ? _right$uuid2 : ''));
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
function areBaseSalesNotesEquivalent(currentValue, loadedValue, options) {
|
|
368
|
+
var currentNotes = normalizeBaseSalesNotesForComparison(currentValue, {
|
|
369
|
+
unresolvedOrderTargetUuid: options === null || options === void 0 ? void 0 : options.currentOrderTargetUuid
|
|
370
|
+
});
|
|
371
|
+
var loadedNotes = normalizeBaseSalesNotesForComparison(loadedValue);
|
|
372
|
+
return currentNotes !== null && loadedNotes !== null && isEqual(currentNotes, loadedNotes);
|
|
373
|
+
}
|
|
321
374
|
function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, strategy) {
|
|
375
|
+
var _currentTempOrder$_ex, _normalizedLoadedReco;
|
|
376
|
+
var loadedHasSalesNotes = Object.prototype.hasOwnProperty.call(loadedRecord || {}, 'notes');
|
|
377
|
+
var hasDirtyLocalSalesNotes = (currentTempOrder === null || currentTempOrder === void 0 || (_currentTempOrder$_ex = currentTempOrder._extend) === null || _currentTempOrder$_ex === void 0 || (_currentTempOrder$_ex = _currentTempOrder$_ex.salesNotesState) === null || _currentTempOrder$_ex === void 0 ? void 0 : _currentTempOrder$_ex.dirty) === true;
|
|
378
|
+
var incomingSalesNotesMatchLocal = loadedHasSalesNotes && areBaseSalesNotesEquivalent(currentTempOrder === null || currentTempOrder === void 0 ? void 0 : currentTempOrder.notes, loadedRecord.notes, {
|
|
379
|
+
currentOrderTargetUuid: (loadedRecord === null || loadedRecord === void 0 ? void 0 : loadedRecord.shop_order_number) || (currentTempOrder === null || currentTempOrder === void 0 ? void 0 : currentTempOrder.shop_order_number)
|
|
380
|
+
});
|
|
381
|
+
var shouldAwaitAuthoritativeSalesNotes = strategy === 'authoritative-incoming' && hasDirtyLocalSalesNotes && (Number(loadedRecord === null || loadedRecord === void 0 ? void 0 : loadedRecord.need_sync) === 1 || !incomingSalesNotesMatchLocal);
|
|
382
|
+
var preserveDirtyLocalSalesNotes = hasDirtyLocalSalesNotes && (strategy === 'preserve-local' || shouldAwaitAuthoritativeSalesNotes);
|
|
322
383
|
var normalizedLoadedRecord = normalizeBaseSalesRecordCollections(loadedRecord || {}, {
|
|
323
384
|
ensureUid: false
|
|
324
385
|
});
|
|
@@ -330,6 +391,12 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, str
|
|
|
330
391
|
});
|
|
331
392
|
var uidRemaps = [];
|
|
332
393
|
var mergedRecord = mergeWith(normalizedCurrentTempOrder, normalizedLoadedRecord, function (currentValue, loadedValue, key) {
|
|
394
|
+
if (key === 'notes') {
|
|
395
|
+
if (preserveDirtyLocalSalesNotes && Array.isArray(currentValue)) {
|
|
396
|
+
return cloneDeep(currentValue);
|
|
397
|
+
}
|
|
398
|
+
if (Array.isArray(loadedValue)) return cloneDeep(loadedValue);
|
|
399
|
+
}
|
|
333
400
|
var collectionKind = getBaseSalesOrderCollectionKind(key);
|
|
334
401
|
if (collectionKind && Array.isArray(loadedValue)) {
|
|
335
402
|
return mergeBaseSalesOrderCollection(collectionKind, Array.isArray(currentValue) ? currentValue : [], loadedValue, strategy, uidRemaps);
|
|
@@ -353,7 +420,23 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, str
|
|
|
353
420
|
return undefined;
|
|
354
421
|
});
|
|
355
422
|
delete mergedRecord.request_unique_idempotency_token;
|
|
356
|
-
|
|
423
|
+
var normalizedMergedRecord = normalizeBaseSalesRecordCollections(applyOrderCollectionUidRemaps(mergedRecord, uidRemaps));
|
|
424
|
+
normalizedMergedRecord._extend = _objectSpread(_objectSpread({}, normalizedMergedRecord._extend || {}), {}, {
|
|
425
|
+
salesNotesState: preserveDirtyLocalSalesNotes ? {
|
|
426
|
+
loaded: true,
|
|
427
|
+
dirty: true
|
|
428
|
+
} : loadedHasSalesNotes ? {
|
|
429
|
+
loaded: true,
|
|
430
|
+
dirty: ((_normalizedLoadedReco = normalizedLoadedRecord._extend) === null || _normalizedLoadedReco === void 0 || (_normalizedLoadedReco = _normalizedLoadedReco.salesNotesState) === null || _normalizedLoadedReco === void 0 ? void 0 : _normalizedLoadedReco.dirty) === true
|
|
431
|
+
} : {
|
|
432
|
+
loaded: false,
|
|
433
|
+
dirty: false
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
if (!loadedHasSalesNotes && !preserveDirtyLocalSalesNotes) {
|
|
437
|
+
delete normalizedMergedRecord.notes;
|
|
438
|
+
}
|
|
439
|
+
return normalizedMergedRecord;
|
|
357
440
|
}
|
|
358
441
|
function filterPendingPaymentsFromLoadedSalesDetail(sourceRecord) {
|
|
359
442
|
if (!sourceRecord || _typeof(sourceRecord) !== 'object') return sourceRecord;
|
|
@@ -860,7 +943,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
860
943
|
key: "loadQuotationForPriceQuery",
|
|
861
944
|
value: function () {
|
|
862
945
|
var _loadQuotationForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(params) {
|
|
863
|
-
var
|
|
946
|
+
var quotation, load;
|
|
864
947
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
865
948
|
while (1) switch (_context6.prev = _context6.next) {
|
|
866
949
|
case 0:
|
|
@@ -871,12 +954,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
871
954
|
return _context6.abrupt("return");
|
|
872
955
|
case 2:
|
|
873
956
|
this.applyQuotationScheduleResolver(params.quotation);
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
957
|
+
quotation = params.quotation;
|
|
958
|
+
load = typeof quotation.ensureQuotations === 'function' ? quotation.ensureQuotations.bind(quotation) : quotation.loadQuotations.bind(quotation);
|
|
959
|
+
_context6.next = 7;
|
|
960
|
+
return load({
|
|
961
|
+
channel: this.getPriceQueryChannel(params.channel),
|
|
877
962
|
customer_id: params.customer_id
|
|
878
963
|
});
|
|
879
|
-
case
|
|
964
|
+
case 7:
|
|
880
965
|
case "end":
|
|
881
966
|
return _context6.stop();
|
|
882
967
|
}
|
|
@@ -903,9 +988,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
903
988
|
}, {
|
|
904
989
|
key: "getPriceQueryChannel",
|
|
905
990
|
value: function getPriceQueryChannel(channel) {
|
|
906
|
-
var _this$
|
|
907
|
-
var strategyContext = (_this$
|
|
908
|
-
var value = (_ref12 = (_ref13 = channel !== null && channel !== void 0 ? channel : strategyContext.channel) !== null && _ref13 !== void 0 ? _ref13 : (_this$
|
|
991
|
+
var _this$otherParams, _ref12, _ref13, _this$otherParams2, _this$otherParams3;
|
|
992
|
+
var strategyContext = (_this$otherParams = this.otherParams) !== null && _this$otherParams !== void 0 && _this$otherParams.strategy_context && _typeof(this.otherParams.strategy_context) === 'object' ? this.otherParams.strategy_context : {};
|
|
993
|
+
var value = (_ref12 = (_ref13 = channel !== null && channel !== void 0 ? channel : strategyContext.channel) !== null && _ref13 !== void 0 ? _ref13 : (_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.channel) !== null && _ref12 !== void 0 ? _ref12 : (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.platform;
|
|
909
994
|
if (value === undefined || value === null || String(value).trim() === '') {
|
|
910
995
|
return undefined;
|
|
911
996
|
}
|
|
@@ -918,11 +1003,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
918
1003
|
}, {
|
|
919
1004
|
key: "getPriceQueryStrategyContext",
|
|
920
1005
|
value: function getPriceQueryStrategyContext(channel) {
|
|
921
|
-
var _this$
|
|
922
|
-
var inherited = (_this$
|
|
1006
|
+
var _this$otherParams4, _ref14, _strategyContext$busi, _this$otherParams5, _this$otherParams6;
|
|
1007
|
+
var inherited = (_this$otherParams4 = this.otherParams) !== null && _this$otherParams4 !== void 0 && _this$otherParams4.strategy_context && _typeof(this.otherParams.strategy_context) === 'object' ? this.otherParams.strategy_context : {};
|
|
923
1008
|
var strategyContext = _objectSpread({}, inherited);
|
|
924
1009
|
var resolvedChannel = this.getPriceQueryChannel(channel);
|
|
925
|
-
var businessCode = (_ref14 = (_strategyContext$busi = strategyContext.business_code) !== null && _strategyContext$busi !== void 0 ? _strategyContext$busi : (_this$
|
|
1010
|
+
var businessCode = (_ref14 = (_strategyContext$busi = strategyContext.business_code) !== null && _strategyContext$busi !== void 0 ? _strategyContext$busi : (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.businessCode) !== null && _ref14 !== void 0 ? _ref14 : (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.business_code;
|
|
926
1011
|
if (resolvedChannel) strategyContext.channel = resolvedChannel;
|
|
927
1012
|
if (businessCode !== undefined && businessCode !== null && String(businessCode).trim() !== '') {
|
|
928
1013
|
strategyContext.business_code = String(businessCode).trim();
|
|
@@ -992,11 +1077,167 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
992
1077
|
schedule_datetime: now.format('YYYY-MM-DD HH:mm:ss')
|
|
993
1078
|
};
|
|
994
1079
|
}
|
|
1080
|
+
}, {
|
|
1081
|
+
key: "isCustomerUserPriceQuery",
|
|
1082
|
+
value: function isCustomerUserPriceQuery() {
|
|
1083
|
+
var _this$otherParams7;
|
|
1084
|
+
return isCustomerUserPlatform((_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.platform);
|
|
1085
|
+
}
|
|
1086
|
+
}, {
|
|
1087
|
+
key: "getPriceQueryScheduleList",
|
|
1088
|
+
value: function getPriceQueryScheduleList() {
|
|
1089
|
+
var _this$store$schedule, _this$store$schedule$, _this$core3;
|
|
1090
|
+
var storeScheduleList = (_this$store$schedule = this.store.schedule) === null || _this$store$schedule === void 0 || (_this$store$schedule$ = _this$store$schedule.getScheduleList) === null || _this$store$schedule$ === void 0 ? void 0 : _this$store$schedule$.call(_this$store$schedule);
|
|
1091
|
+
if (Array.isArray(storeScheduleList) && storeScheduleList.length > 0) {
|
|
1092
|
+
return storeScheduleList;
|
|
1093
|
+
}
|
|
1094
|
+
var contextScheduleList = (_this$core3 = this.core) === null || _this$core3 === void 0 || (_this$core3 = _this$core3.context) === null || _this$core3 === void 0 ? void 0 : _this$core3.scheduleList;
|
|
1095
|
+
return Array.isArray(contextScheduleList) && contextScheduleList.length > 0 ? contextScheduleList : undefined;
|
|
1096
|
+
}
|
|
1097
|
+
}, {
|
|
1098
|
+
key: "buildPriceQueryPayload",
|
|
1099
|
+
value: function buildPriceQueryPayload(params) {
|
|
1100
|
+
var channel = this.getPriceQueryChannel(params.channel);
|
|
1101
|
+
var strategyContext = this.getPriceQueryStrategyContext(channel);
|
|
1102
|
+
return _objectSpread(_objectSpread({
|
|
1103
|
+
ids: params.ids
|
|
1104
|
+
}, this.isCustomerUserPriceQuery() ? {} : {
|
|
1105
|
+
open_quotation: 1
|
|
1106
|
+
}), {}, {
|
|
1107
|
+
open_bundle: 1,
|
|
1108
|
+
with: _toConsumableArray(PRODUCT_QUERY_DATA_VARIANT_RELATIONS),
|
|
1109
|
+
status: 'published',
|
|
1110
|
+
num: Math.max(params.ids.length, 1),
|
|
1111
|
+
skip: 1,
|
|
1112
|
+
customer_id: params.customerId,
|
|
1113
|
+
schedule_date: params.schedule.schedule_date,
|
|
1114
|
+
schedule_datetime: params.schedule.schedule_datetime,
|
|
1115
|
+
application_code: channel
|
|
1116
|
+
}, Object.keys(strategyContext).length ? {
|
|
1117
|
+
strategy_context: strategyContext
|
|
1118
|
+
} : {});
|
|
1119
|
+
}
|
|
1120
|
+
}, {
|
|
1121
|
+
key: "getRawProductPriceSources",
|
|
1122
|
+
value: function getRawProductPriceSources(ids) {
|
|
1123
|
+
var products = this.store.products;
|
|
1124
|
+
if (typeof (products === null || products === void 0 ? void 0 : products.getRawProductPriceSources) !== 'function') {
|
|
1125
|
+
return new Map();
|
|
1126
|
+
}
|
|
1127
|
+
try {
|
|
1128
|
+
var result = products.getRawProductPriceSources(ids);
|
|
1129
|
+
return result instanceof Map ? result : new Map();
|
|
1130
|
+
} catch (error) {
|
|
1131
|
+
this.logWarning('getRawProductPriceSources: 读取商品原始报价源失败', {
|
|
1132
|
+
ids: ids,
|
|
1133
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1134
|
+
});
|
|
1135
|
+
return new Map();
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
}, {
|
|
1139
|
+
key: "rememberRawProductPriceSources",
|
|
1140
|
+
value: function rememberRawProductPriceSources(products) {
|
|
1141
|
+
var productList = this.store.products;
|
|
1142
|
+
if (typeof (productList === null || productList === void 0 ? void 0 : productList.rememberRawProductQueryResult) !== 'function') return;
|
|
1143
|
+
try {
|
|
1144
|
+
productList.rememberRawProductQueryResult(products);
|
|
1145
|
+
} catch (error) {
|
|
1146
|
+
this.logWarning('rememberRawProductPriceSources: 保存商品原始报价源失败', {
|
|
1147
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1148
|
+
});
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
}, {
|
|
1152
|
+
key: "getSelectedProductVariantId",
|
|
1153
|
+
value: function getSelectedProductVariantId(product) {
|
|
1154
|
+
var _ref15, _product$product_vari;
|
|
1155
|
+
var variantId = Number((_ref15 = (_product$product_vari = product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : product === null || product === void 0 ? void 0 : product.variant_id) !== null && _ref15 !== void 0 ? _ref15 : 0);
|
|
1156
|
+
return Number.isFinite(variantId) && variantId > 0 ? variantId : 0;
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
/**
|
|
1160
|
+
* 将目录原始商品还原为本次选择的 SKU 基线。
|
|
1161
|
+
*
|
|
1162
|
+
* 这里绝不能复用已评估后的目录商品,否则从命中智能价切回不命中的
|
|
1163
|
+
* 日期时会残留旧价格。套餐仅验证所选关系存在,最终仍由 merge 方法把
|
|
1164
|
+
* 评估后的套餐价格映射回用户的选择数据。
|
|
1165
|
+
*/
|
|
1166
|
+
}, {
|
|
1167
|
+
key: "prepareRawProductForPriceQuery",
|
|
1168
|
+
value: function prepareRawProductForPriceQuery(rawProduct, selectedProduct) {
|
|
1169
|
+
var _product$product_id2,
|
|
1170
|
+
_this5 = this;
|
|
1171
|
+
var product = cloneDeep(rawProduct);
|
|
1172
|
+
var rawProductId = this.getPriceQueryProductId(product);
|
|
1173
|
+
var selectedProductId = this.getPriceQueryProductId(selectedProduct);
|
|
1174
|
+
if (rawProductId === null || selectedProductId === null || rawProductId !== selectedProductId) {
|
|
1175
|
+
return null;
|
|
1176
|
+
}
|
|
1177
|
+
var selectedVariantId = this.getSelectedProductVariantId(selectedProduct);
|
|
1178
|
+
product.product_id = (_product$product_id2 = product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : product.id;
|
|
1179
|
+
product.product_variant_id = selectedVariantId;
|
|
1180
|
+
product.variant_id = selectedVariantId;
|
|
1181
|
+
if (selectedVariantId > 0) {
|
|
1182
|
+
var _ref16, _selectedVariant$pric, _selectedVariant$sell, _selectedVariant$base;
|
|
1183
|
+
var variants = Array.isArray(product.variant) ? product.variant : [];
|
|
1184
|
+
var selectedVariant = variants.find(function (variant) {
|
|
1185
|
+
return Number(variant === null || variant === void 0 ? void 0 : variant.id) === selectedVariantId;
|
|
1186
|
+
});
|
|
1187
|
+
if (!selectedVariant) return null;
|
|
1188
|
+
var variantPrice = (_ref16 = (_selectedVariant$pric = selectedVariant.price) !== null && _selectedVariant$pric !== void 0 ? _selectedVariant$pric : selectedVariant.selling_price) !== null && _ref16 !== void 0 ? _ref16 : selectedVariant.base_price;
|
|
1189
|
+
if (variantPrice === undefined || variantPrice === null || variantPrice === '') {
|
|
1190
|
+
return null;
|
|
1191
|
+
}
|
|
1192
|
+
product.price = variantPrice;
|
|
1193
|
+
product.selling_price = (_selectedVariant$sell = selectedVariant.selling_price) !== null && _selectedVariant$sell !== void 0 ? _selectedVariant$sell : variantPrice;
|
|
1194
|
+
product.base_price = (_selectedVariant$base = selectedVariant.base_price) !== null && _selectedVariant$base !== void 0 ? _selectedVariant$base : variantPrice;
|
|
1195
|
+
}
|
|
1196
|
+
var selectedBundles = Array.isArray(selectedProduct.product_bundle) ? selectedProduct.product_bundle : [];
|
|
1197
|
+
if (selectedBundles.length > 0) {
|
|
1198
|
+
var rawBundleItems = this.getAuthoritativeBundleItems(product);
|
|
1199
|
+
var allSelectedBundlesExist = selectedBundles.every(function (bundle) {
|
|
1200
|
+
var _ref17, _bundle$bundle_varian, _ref18, _authoritativeBundle$;
|
|
1201
|
+
var authoritativeBundle = _this5.findAuthoritativeBundleItem(bundle, rawBundleItems);
|
|
1202
|
+
if (!authoritativeBundle) return false;
|
|
1203
|
+
var selectedBundleVariantId = Number((_ref17 = (_bundle$bundle_varian = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle === null || bundle === void 0 ? void 0 : bundle.variant_id) !== null && _ref17 !== void 0 ? _ref17 : 0);
|
|
1204
|
+
var authoritativeBundleVariantId = Number((_ref18 = (_authoritativeBundle$ = authoritativeBundle === null || authoritativeBundle === void 0 ? void 0 : authoritativeBundle.bundle_variant_id) !== null && _authoritativeBundle$ !== void 0 ? _authoritativeBundle$ : authoritativeBundle === null || authoritativeBundle === void 0 ? void 0 : authoritativeBundle.variant_id) !== null && _ref18 !== void 0 ? _ref18 : 0);
|
|
1205
|
+
if ((Number.isFinite(selectedBundleVariantId) ? selectedBundleVariantId : 0) !== (Number.isFinite(authoritativeBundleVariantId) ? authoritativeBundleVariantId : 0)) {
|
|
1206
|
+
return false;
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
// 省略字段表示该套餐子商品关系没有被价格查询完整水合,不能把它
|
|
1210
|
+
// 当作“没有规则”而静默使用基础价。
|
|
1211
|
+
return Array.isArray(authoritativeBundle.data_variants);
|
|
1212
|
+
});
|
|
1213
|
+
if (!allSelectedBundlesExist) return null;
|
|
1214
|
+
}
|
|
1215
|
+
return product;
|
|
1216
|
+
}
|
|
1217
|
+
}, {
|
|
1218
|
+
key: "resolveLocalProductForPriceQuery",
|
|
1219
|
+
value: function resolveLocalProductForPriceQuery(params) {
|
|
1220
|
+
if (!params.rawProduct) return null;
|
|
1221
|
+
var preparedProduct = this.prepareRawProductForPriceQuery(params.rawProduct, params.selectedProduct);
|
|
1222
|
+
if (!preparedProduct) return null;
|
|
1223
|
+
var scheduleList = this.getPriceQueryScheduleList();
|
|
1224
|
+
var result = tryResolveClientDataVariants(_objectSpread({
|
|
1225
|
+
core: this.core,
|
|
1226
|
+
otherParams: this.otherParams,
|
|
1227
|
+
products: [preparedProduct],
|
|
1228
|
+
queryPayload: params.queryPayload,
|
|
1229
|
+
handledByOsServer: false
|
|
1230
|
+
}, scheduleList ? {
|
|
1231
|
+
scheduleList: scheduleList
|
|
1232
|
+
} : {}));
|
|
1233
|
+
if (result.status !== 'resolved') return null;
|
|
1234
|
+
return result.products[0] || null;
|
|
1235
|
+
}
|
|
995
1236
|
}, {
|
|
996
1237
|
key: "loadProductsForPriceQuery",
|
|
997
1238
|
value: function () {
|
|
998
1239
|
var _loadProductsForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params) {
|
|
999
|
-
var ids, productsById,
|
|
1240
|
+
var ids, productsById, handledByOsServer, _response$data, queryPayload, response, list, scheduleList, resolvedList;
|
|
1000
1241
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
1001
1242
|
while (1) switch (_context8.prev = _context8.next) {
|
|
1002
1243
|
case 0:
|
|
@@ -1010,24 +1251,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1010
1251
|
}
|
|
1011
1252
|
return _context8.abrupt("return", productsById);
|
|
1012
1253
|
case 4:
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1254
|
+
handledByOsServer = isProductQueryHandledByOsServer(this.core, this.request);
|
|
1255
|
+
_context8.prev = 5;
|
|
1256
|
+
queryPayload = this.buildPriceQueryPayload(_objectSpread(_objectSpread({}, params), {}, {
|
|
1257
|
+
ids: ids
|
|
1258
|
+
}));
|
|
1016
1259
|
_context8.next = 9;
|
|
1017
|
-
return this.request.post('/product/query',
|
|
1018
|
-
ids: ids,
|
|
1019
|
-
open_quotation: 1,
|
|
1020
|
-
open_bundle: 1,
|
|
1021
|
-
status: 'published',
|
|
1022
|
-
num: 1,
|
|
1023
|
-
skip: 1,
|
|
1024
|
-
customer_id: params.customerId,
|
|
1025
|
-
schedule_date: params.schedule.schedule_date,
|
|
1026
|
-
schedule_datetime: params.schedule.schedule_datetime,
|
|
1027
|
-
application_code: channel
|
|
1028
|
-
}, Object.keys(strategyContext).length ? {
|
|
1029
|
-
strategy_context: strategyContext
|
|
1030
|
-
} : {}), {
|
|
1260
|
+
return this.request.post('/product/query', queryPayload, {
|
|
1031
1261
|
osServer: true,
|
|
1032
1262
|
customToast: function customToast() {}
|
|
1033
1263
|
});
|
|
@@ -1040,6 +1270,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1040
1270
|
}
|
|
1041
1271
|
return _context8.abrupt("return", productsById);
|
|
1042
1272
|
case 13:
|
|
1273
|
+
if (!(this.isCustomerUserPriceQuery() && !handledByOsServer)) {
|
|
1274
|
+
_context8.next = 17;
|
|
1275
|
+
break;
|
|
1276
|
+
}
|
|
1277
|
+
this.rememberRawProductPriceSources(list);
|
|
1043
1278
|
list.forEach(function (item) {
|
|
1044
1279
|
var _item$id;
|
|
1045
1280
|
var productId = Number((_item$id = item === null || item === void 0 ? void 0 : item.id) !== null && _item$id !== void 0 ? _item$id : item === null || item === void 0 ? void 0 : item.product_id);
|
|
@@ -1047,18 +1282,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1047
1282
|
});
|
|
1048
1283
|
return _context8.abrupt("return", productsById);
|
|
1049
1284
|
case 17:
|
|
1050
|
-
|
|
1051
|
-
|
|
1285
|
+
scheduleList = this.getPriceQueryScheduleList();
|
|
1286
|
+
resolvedList = resolveClientDataVariants(_objectSpread({
|
|
1287
|
+
core: this.core,
|
|
1288
|
+
otherParams: this.otherParams,
|
|
1289
|
+
products: list,
|
|
1290
|
+
queryPayload: queryPayload,
|
|
1291
|
+
handledByOsServer: handledByOsServer
|
|
1292
|
+
}, scheduleList ? {
|
|
1293
|
+
scheduleList: scheduleList
|
|
1294
|
+
} : {}));
|
|
1295
|
+
resolvedList.forEach(function (item) {
|
|
1296
|
+
var _item$id2;
|
|
1297
|
+
var productId = Number((_item$id2 = item === null || item === void 0 ? void 0 : item.id) !== null && _item$id2 !== void 0 ? _item$id2 : item === null || item === void 0 ? void 0 : item.product_id);
|
|
1298
|
+
if (Number.isFinite(productId)) productsById.set(productId, item);
|
|
1299
|
+
});
|
|
1300
|
+
return _context8.abrupt("return", productsById);
|
|
1301
|
+
case 23:
|
|
1302
|
+
_context8.prev = 23;
|
|
1303
|
+
_context8.t0 = _context8["catch"](5);
|
|
1052
1304
|
this.logWarning('loadProductsForPriceQuery: 商品批量重查失败,使用入参 fallback', {
|
|
1053
1305
|
ids: ids,
|
|
1054
1306
|
error: _context8.t0 instanceof Error ? _context8.t0.message : String(_context8.t0)
|
|
1055
1307
|
});
|
|
1056
1308
|
return _context8.abrupt("return", productsById);
|
|
1057
|
-
case
|
|
1309
|
+
case 27:
|
|
1058
1310
|
case "end":
|
|
1059
1311
|
return _context8.stop();
|
|
1060
1312
|
}
|
|
1061
|
-
}, _callee8, this, [[
|
|
1313
|
+
}, _callee8, this, [[5, 23]]);
|
|
1062
1314
|
}));
|
|
1063
1315
|
function loadProductsForPriceQuery(_x7) {
|
|
1064
1316
|
return _loadProductsForPriceQuery.apply(this, arguments);
|
|
@@ -1066,42 +1318,127 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1066
1318
|
return loadProductsForPriceQuery;
|
|
1067
1319
|
}()
|
|
1068
1320
|
}, {
|
|
1069
|
-
key: "
|
|
1321
|
+
key: "resolveProductsForPriceQuery",
|
|
1070
1322
|
value: function () {
|
|
1071
|
-
var
|
|
1072
|
-
var
|
|
1323
|
+
var _resolveProductsForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
|
|
1324
|
+
var _this6 = this;
|
|
1325
|
+
var selectedProducts, productIds, ids, handledByOsServer, canUseLocalFastPath, productsById, queryPayload, cachedRawProducts, authoritativeProducts, missingIds, remoteRawProducts;
|
|
1073
1326
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
1074
1327
|
while (1) switch (_context9.prev = _context9.next) {
|
|
1075
1328
|
case 0:
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1329
|
+
selectedProducts = params.priceQueries.map(function (item) {
|
|
1330
|
+
return item.product || {};
|
|
1331
|
+
});
|
|
1332
|
+
productIds = selectedProducts.map(function (product) {
|
|
1333
|
+
return _this6.getPriceQueryProductId(product);
|
|
1334
|
+
});
|
|
1335
|
+
ids = Array.from(new Set(productIds.filter(function (id) {
|
|
1336
|
+
return id !== null;
|
|
1337
|
+
})));
|
|
1338
|
+
if (ids.length) {
|
|
1339
|
+
_context9.next = 5;
|
|
1080
1340
|
break;
|
|
1081
1341
|
}
|
|
1082
|
-
return _context9.abrupt("return",
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1342
|
+
return _context9.abrupt("return", selectedProducts.map(function () {
|
|
1343
|
+
return null;
|
|
1344
|
+
}));
|
|
1345
|
+
case 5:
|
|
1346
|
+
handledByOsServer = this.request ? isProductQueryHandledByOsServer(this.core, this.request) : false;
|
|
1347
|
+
canUseLocalFastPath = this.isCustomerUserPriceQuery() && !handledByOsServer;
|
|
1348
|
+
if (canUseLocalFastPath) {
|
|
1349
|
+
_context9.next = 14;
|
|
1350
|
+
break;
|
|
1351
|
+
}
|
|
1352
|
+
if (this.request) {
|
|
1353
|
+
_context9.next = 10;
|
|
1354
|
+
break;
|
|
1355
|
+
}
|
|
1356
|
+
return _context9.abrupt("return", selectedProducts.map(function () {
|
|
1357
|
+
return null;
|
|
1358
|
+
}));
|
|
1359
|
+
case 10:
|
|
1360
|
+
_context9.next = 12;
|
|
1086
1361
|
return this.loadProductsForPriceQuery({
|
|
1087
|
-
ids:
|
|
1088
|
-
schedule: schedule,
|
|
1089
|
-
customerId: customerId,
|
|
1362
|
+
ids: ids,
|
|
1363
|
+
schedule: params.schedule,
|
|
1364
|
+
customerId: params.customerId,
|
|
1090
1365
|
channel: params.channel
|
|
1091
1366
|
});
|
|
1092
|
-
case
|
|
1367
|
+
case 12:
|
|
1093
1368
|
productsById = _context9.sent;
|
|
1094
|
-
return _context9.abrupt("return",
|
|
1095
|
-
|
|
1369
|
+
return _context9.abrupt("return", productIds.map(function (productId) {
|
|
1370
|
+
return productId === null ? null : productsById.get(productId) || null;
|
|
1371
|
+
}));
|
|
1372
|
+
case 14:
|
|
1373
|
+
queryPayload = this.buildPriceQueryPayload({
|
|
1374
|
+
ids: ids,
|
|
1375
|
+
schedule: params.schedule,
|
|
1376
|
+
customerId: params.customerId,
|
|
1377
|
+
channel: params.channel
|
|
1378
|
+
});
|
|
1379
|
+
cachedRawProducts = this.getRawProductPriceSources(ids);
|
|
1380
|
+
authoritativeProducts = selectedProducts.map(function (selectedProduct, index) {
|
|
1381
|
+
var productId = productIds[index];
|
|
1382
|
+
return productId === null ? null : _this6.resolveLocalProductForPriceQuery({
|
|
1383
|
+
selectedProduct: selectedProduct,
|
|
1384
|
+
rawProduct: cachedRawProducts.get(productId),
|
|
1385
|
+
queryPayload: queryPayload
|
|
1386
|
+
});
|
|
1387
|
+
});
|
|
1388
|
+
missingIds = Array.from(new Set(productIds.filter(function (productId, index) {
|
|
1389
|
+
return productId !== null && !authoritativeProducts[index];
|
|
1390
|
+
})));
|
|
1391
|
+
if (missingIds.length) {
|
|
1392
|
+
_context9.next = 20;
|
|
1393
|
+
break;
|
|
1394
|
+
}
|
|
1395
|
+
return _context9.abrupt("return", authoritativeProducts);
|
|
1396
|
+
case 20:
|
|
1397
|
+
if (this.request) {
|
|
1398
|
+
_context9.next = 22;
|
|
1399
|
+
break;
|
|
1400
|
+
}
|
|
1401
|
+
return _context9.abrupt("return", authoritativeProducts);
|
|
1402
|
+
case 22:
|
|
1403
|
+
_context9.next = 24;
|
|
1404
|
+
return this.loadProductsForPriceQuery({
|
|
1405
|
+
ids: missingIds,
|
|
1406
|
+
schedule: params.schedule,
|
|
1407
|
+
customerId: params.customerId,
|
|
1408
|
+
channel: params.channel
|
|
1409
|
+
});
|
|
1410
|
+
case 24:
|
|
1411
|
+
remoteRawProducts = _context9.sent;
|
|
1412
|
+
authoritativeProducts.forEach(function (authoritativeProduct, index) {
|
|
1413
|
+
if (authoritativeProduct) return;
|
|
1414
|
+
var productId = productIds[index];
|
|
1415
|
+
if (productId === null) return;
|
|
1416
|
+
var rawProduct = remoteRawProducts.get(productId);
|
|
1417
|
+
var locallyResolved = _this6.resolveLocalProductForPriceQuery({
|
|
1418
|
+
selectedProduct: selectedProducts[index],
|
|
1419
|
+
rawProduct: rawProduct,
|
|
1420
|
+
queryPayload: queryPayload
|
|
1421
|
+
});
|
|
1422
|
+
if (locallyResolved) {
|
|
1423
|
+
authoritativeProducts[index] = locallyResolved;
|
|
1424
|
+
return;
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1427
|
+
// 严格客户端能力仍不可用时,真实请求已经是最后的权威降级。
|
|
1428
|
+
// 尽量应用所选 SKU 基线;关系不完整时保持旧的远端商品语义。
|
|
1429
|
+
authoritativeProducts[index] = rawProduct ? _this6.prepareRawProductForPriceQuery(rawProduct, selectedProducts[index]) || rawProduct : null;
|
|
1430
|
+
});
|
|
1431
|
+
return _context9.abrupt("return", authoritativeProducts);
|
|
1432
|
+
case 27:
|
|
1096
1433
|
case "end":
|
|
1097
1434
|
return _context9.stop();
|
|
1098
1435
|
}
|
|
1099
1436
|
}, _callee9, this);
|
|
1100
1437
|
}));
|
|
1101
|
-
function
|
|
1102
|
-
return
|
|
1438
|
+
function resolveProductsForPriceQuery(_x8) {
|
|
1439
|
+
return _resolveProductsForPriceQuery.apply(this, arguments);
|
|
1103
1440
|
}
|
|
1104
|
-
return
|
|
1441
|
+
return resolveProductsForPriceQuery;
|
|
1105
1442
|
}()
|
|
1106
1443
|
}, {
|
|
1107
1444
|
key: "getAuthoritativeBundleItems",
|
|
@@ -1111,10 +1448,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1111
1448
|
return groups.flatMap(function (group) {
|
|
1112
1449
|
var items = Array.isArray(group === null || group === void 0 ? void 0 : group.bundle_item) ? group.bundle_item : Array.isArray(group === null || group === void 0 ? void 0 : group.bundleItem) ? group.bundleItem : [];
|
|
1113
1450
|
return items.map(function (item) {
|
|
1114
|
-
var _item$group_id,
|
|
1451
|
+
var _item$group_id, _ref19, _item$bundle_group_id;
|
|
1115
1452
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
1116
1453
|
group_id: (_item$group_id = item === null || item === void 0 ? void 0 : item.group_id) !== null && _item$group_id !== void 0 ? _item$group_id : group === null || group === void 0 ? void 0 : group.id,
|
|
1117
|
-
bundle_group_id: (
|
|
1454
|
+
bundle_group_id: (_ref19 = (_item$bundle_group_id = item === null || item === void 0 ? void 0 : item.bundle_group_id) !== null && _item$bundle_group_id !== void 0 ? _item$bundle_group_id : item === null || item === void 0 ? void 0 : item.group_id) !== null && _ref19 !== void 0 ? _ref19 : group === null || group === void 0 ? void 0 : group.id
|
|
1118
1455
|
});
|
|
1119
1456
|
});
|
|
1120
1457
|
});
|
|
@@ -1145,44 +1482,44 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1145
1482
|
}, {
|
|
1146
1483
|
key: "getAuthoritativeBundleUnitPrice",
|
|
1147
1484
|
value: function getAuthoritativeBundleUnitPrice(bundle) {
|
|
1148
|
-
var
|
|
1149
|
-
return (
|
|
1485
|
+
var _ref20, _ref21, _ref22, _bundle$price;
|
|
1486
|
+
return (_ref20 = (_ref21 = (_ref22 = (_bundle$price = bundle.price) !== null && _bundle$price !== void 0 ? _bundle$price : bundle.bundle_selling_price) !== null && _ref22 !== void 0 ? _ref22 : bundle.custom_price) !== null && _ref21 !== void 0 ? _ref21 : bundle.product_price) !== null && _ref20 !== void 0 ? _ref20 : bundle.base_price;
|
|
1150
1487
|
}
|
|
1151
1488
|
}, {
|
|
1152
1489
|
key: "mergeProductForPriceQuery",
|
|
1153
1490
|
value: function mergeProductForPriceQuery(product, authoritativeProduct) {
|
|
1154
|
-
var
|
|
1491
|
+
var _this7 = this,
|
|
1155
1492
|
_product$id,
|
|
1156
|
-
|
|
1157
|
-
_product$
|
|
1158
|
-
|
|
1159
|
-
_product$
|
|
1160
|
-
|
|
1493
|
+
_ref23,
|
|
1494
|
+
_product$product_id3,
|
|
1495
|
+
_ref24,
|
|
1496
|
+
_product$product_vari2,
|
|
1497
|
+
_ref25,
|
|
1161
1498
|
_product$num,
|
|
1162
|
-
|
|
1499
|
+
_ref26,
|
|
1163
1500
|
_product$quantity,
|
|
1164
1501
|
_product$metadata4;
|
|
1165
1502
|
if (!authoritativeProduct) return product;
|
|
1166
1503
|
var selectedBundles = Array.isArray(product.product_bundle) ? product.product_bundle : [];
|
|
1167
1504
|
var authoritativeBundles = this.getAuthoritativeBundleItems(authoritativeProduct);
|
|
1168
1505
|
var productBundle = selectedBundles.map(function (bundle) {
|
|
1169
|
-
var _authoritativeBundle
|
|
1170
|
-
var authoritativeBundle =
|
|
1171
|
-
var unitPrice = authoritativeBundle ?
|
|
1506
|
+
var _authoritativeBundle$2, _authoritativeBundle$3;
|
|
1507
|
+
var authoritativeBundle = _this7.findAuthoritativeBundleItem(bundle, authoritativeBundles);
|
|
1508
|
+
var unitPrice = authoritativeBundle ? _this7.getAuthoritativeBundleUnitPrice(authoritativeBundle) : undefined;
|
|
1172
1509
|
if (unitPrice === undefined || unitPrice === null || unitPrice === '') return bundle;
|
|
1173
1510
|
return _objectSpread(_objectSpread({}, bundle), {}, {
|
|
1174
1511
|
price: unitPrice,
|
|
1175
1512
|
bundle_selling_price: unitPrice,
|
|
1176
|
-
base_price: (_authoritativeBundle$ = authoritativeBundle === null || authoritativeBundle === void 0 ? void 0 : authoritativeBundle.base_price) !== null && _authoritativeBundle$ !== void 0 ? _authoritativeBundle$ : bundle.base_price,
|
|
1177
|
-
product_price: (_authoritativeBundle$
|
|
1513
|
+
base_price: (_authoritativeBundle$2 = authoritativeBundle === null || authoritativeBundle === void 0 ? void 0 : authoritativeBundle.base_price) !== null && _authoritativeBundle$2 !== void 0 ? _authoritativeBundle$2 : bundle.base_price,
|
|
1514
|
+
product_price: (_authoritativeBundle$3 = authoritativeBundle === null || authoritativeBundle === void 0 ? void 0 : authoritativeBundle.product_price) !== null && _authoritativeBundle$3 !== void 0 ? _authoritativeBundle$3 : bundle.product_price
|
|
1178
1515
|
});
|
|
1179
1516
|
});
|
|
1180
1517
|
return _objectSpread(_objectSpread(_objectSpread({}, product), authoritativeProduct), {}, {
|
|
1181
1518
|
id: (_product$id = product.id) !== null && _product$id !== void 0 ? _product$id : authoritativeProduct.id,
|
|
1182
|
-
product_id: (
|
|
1183
|
-
product_variant_id: (
|
|
1184
|
-
num: (
|
|
1185
|
-
quantity: (
|
|
1519
|
+
product_id: (_ref23 = (_product$product_id3 = product.product_id) !== null && _product$product_id3 !== void 0 ? _product$product_id3 : authoritativeProduct.product_id) !== null && _ref23 !== void 0 ? _ref23 : authoritativeProduct.id,
|
|
1520
|
+
product_variant_id: (_ref24 = (_product$product_vari2 = product.product_variant_id) !== null && _product$product_vari2 !== void 0 ? _product$product_vari2 : authoritativeProduct.product_variant_id) !== null && _ref24 !== void 0 ? _ref24 : 0,
|
|
1521
|
+
num: (_ref25 = (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : product.quantity) !== null && _ref25 !== void 0 ? _ref25 : authoritativeProduct.num,
|
|
1522
|
+
quantity: (_ref26 = (_product$quantity = product.quantity) !== null && _product$quantity !== void 0 ? _product$quantity : product.num) !== null && _ref26 !== void 0 ? _ref26 : authoritativeProduct.quantity,
|
|
1186
1523
|
product_sku: function () {
|
|
1187
1524
|
var authoritativeSku = ensureProductSku(authoritativeProduct);
|
|
1188
1525
|
var productSku = ensureProductSku(product);
|
|
@@ -1306,24 +1643,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1306
1643
|
key: "syncOtherParamsToSubModules",
|
|
1307
1644
|
value: (function () {
|
|
1308
1645
|
var _syncOtherParamsToSubModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(changedParams) {
|
|
1309
|
-
var
|
|
1310
|
-
var
|
|
1311
|
-
|
|
1646
|
+
var _this8 = this;
|
|
1647
|
+
var _ref27,
|
|
1648
|
+
_ref27$cover,
|
|
1312
1649
|
cover,
|
|
1313
1650
|
_args11 = arguments;
|
|
1314
1651
|
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
1315
1652
|
while (1) switch (_context11.prev = _context11.next) {
|
|
1316
1653
|
case 0:
|
|
1317
|
-
|
|
1654
|
+
_ref27 = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {}, _ref27$cover = _ref27.cover, cover = _ref27$cover === void 0 ? false : _ref27$cover;
|
|
1318
1655
|
_context11.next = 3;
|
|
1319
1656
|
return Promise.all(Object.entries(this.store).map( /*#__PURE__*/function () {
|
|
1320
|
-
var
|
|
1321
|
-
var
|
|
1657
|
+
var _ref29 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(_ref28) {
|
|
1658
|
+
var _ref30, moduleName, subModule, targetModule, nextSubModuleOtherParams;
|
|
1322
1659
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
1323
1660
|
while (1) switch (_context10.prev = _context10.next) {
|
|
1324
1661
|
case 0:
|
|
1325
|
-
|
|
1326
|
-
if (!
|
|
1662
|
+
_ref30 = _slicedToArray(_ref28, 2), moduleName = _ref30[0], subModule = _ref30[1];
|
|
1663
|
+
if (!_this8.reusedSharedSubModuleNames.has(moduleName)) {
|
|
1327
1664
|
_context10.next = 3;
|
|
1328
1665
|
break;
|
|
1329
1666
|
}
|
|
@@ -1336,7 +1673,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1336
1673
|
}
|
|
1337
1674
|
return _context10.abrupt("return");
|
|
1338
1675
|
case 6:
|
|
1339
|
-
nextSubModuleOtherParams =
|
|
1676
|
+
nextSubModuleOtherParams = _this8.buildSubModuleOtherParams(moduleName);
|
|
1340
1677
|
_context10.next = 9;
|
|
1341
1678
|
return targetModule.updateOtherParams(nextSubModuleOtherParams, {
|
|
1342
1679
|
changedParams: changedParams,
|
|
@@ -1348,8 +1685,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1348
1685
|
}
|
|
1349
1686
|
}, _callee10);
|
|
1350
1687
|
}));
|
|
1351
|
-
return function (
|
|
1352
|
-
return
|
|
1688
|
+
return function (_x10) {
|
|
1689
|
+
return _ref29.apply(this, arguments);
|
|
1353
1690
|
};
|
|
1354
1691
|
}()));
|
|
1355
1692
|
case 3:
|
|
@@ -1358,7 +1695,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1358
1695
|
}
|
|
1359
1696
|
}, _callee11, this);
|
|
1360
1697
|
}));
|
|
1361
|
-
function syncOtherParamsToSubModules(
|
|
1698
|
+
function syncOtherParamsToSubModules(_x9) {
|
|
1362
1699
|
return _syncOtherParamsToSubModules.apply(this, arguments);
|
|
1363
1700
|
}
|
|
1364
1701
|
return syncOtherParamsToSubModules;
|
|
@@ -1408,22 +1745,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1408
1745
|
}, {
|
|
1409
1746
|
key: "getPaymentNumberDevicePrefixSync",
|
|
1410
1747
|
value: function getPaymentNumberDevicePrefixSync() {
|
|
1411
|
-
var
|
|
1748
|
+
var _this9 = this;
|
|
1412
1749
|
if (!this.appPlugin) return 'LOCAL';
|
|
1413
1750
|
return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
|
|
1414
|
-
return
|
|
1751
|
+
return _this9.getAppData(key);
|
|
1415
1752
|
});
|
|
1416
1753
|
}
|
|
1417
1754
|
}, {
|
|
1418
1755
|
key: "getPaymentNumberDevicePrefixAsync",
|
|
1419
1756
|
value: function getPaymentNumberDevicePrefixAsync() {
|
|
1420
|
-
var
|
|
1757
|
+
var _this10 = this;
|
|
1421
1758
|
if (!this.appPlugin) return Promise.resolve('LOCAL');
|
|
1422
1759
|
if (this.paymentNumberDevicePrefix) {
|
|
1423
1760
|
return Promise.resolve(this.paymentNumberDevicePrefix);
|
|
1424
1761
|
}
|
|
1425
1762
|
return resolvePaymentNumberDevicePrefix(function (key) {
|
|
1426
|
-
return
|
|
1763
|
+
return _this10.getAppData(key);
|
|
1427
1764
|
});
|
|
1428
1765
|
}
|
|
1429
1766
|
}, {
|
|
@@ -1471,7 +1808,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1471
1808
|
var _this$otherParams11,
|
|
1472
1809
|
_this$appPlugin2,
|
|
1473
1810
|
_this$appPlugin2$getA,
|
|
1474
|
-
|
|
1811
|
+
_this11 = this,
|
|
1475
1812
|
_this$otherParams12;
|
|
1476
1813
|
var options,
|
|
1477
1814
|
app,
|
|
@@ -1502,24 +1839,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1502
1839
|
targetCacheData = this.readSessionCacheData();
|
|
1503
1840
|
moduleNames = this.getRegisteredModuleNames();
|
|
1504
1841
|
moduleNames.forEach(function (step) {
|
|
1505
|
-
var reusedModule =
|
|
1842
|
+
var reusedModule = _this11.getReusableSharedSubModule(step);
|
|
1506
1843
|
if (reusedModule) {
|
|
1507
|
-
|
|
1508
|
-
|
|
1844
|
+
_this11.store[step] = reusedModule;
|
|
1845
|
+
_this11.reusedSharedSubModuleNames.add(step);
|
|
1509
1846
|
return;
|
|
1510
1847
|
}
|
|
1511
|
-
var targetModule =
|
|
1848
|
+
var targetModule = _this11.createSubModule(step);
|
|
1512
1849
|
if (!targetModule) {
|
|
1513
1850
|
throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
|
|
1514
1851
|
}
|
|
1515
|
-
var hooks =
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
initialState:
|
|
1852
|
+
var hooks = _this11.getSubModuleHooks(step);
|
|
1853
|
+
_this11.store[step] = targetModule;
|
|
1854
|
+
_this11.core.registerModule(targetModule, _objectSpread(_objectSpread({
|
|
1855
|
+
initialState: _this11.shouldUseSessionStorageForSubModule(step) ? (targetCacheData === null || targetCacheData === void 0 ? void 0 : targetCacheData[targetModule.name]) || {} : {}
|
|
1519
1856
|
}, hooks ? {
|
|
1520
1857
|
hooks: hooks
|
|
1521
1858
|
} : {}), {}, {
|
|
1522
|
-
otherParams:
|
|
1859
|
+
otherParams: _this11.buildSubModuleOtherParams(step)
|
|
1523
1860
|
}));
|
|
1524
1861
|
});
|
|
1525
1862
|
if (!(this.store.schedule && !this.isScheduleListLoaded(this.store.schedule))) {
|
|
@@ -1543,7 +1880,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1543
1880
|
}
|
|
1544
1881
|
}, _callee12, this);
|
|
1545
1882
|
}));
|
|
1546
|
-
function initialize(
|
|
1883
|
+
function initialize(_x11) {
|
|
1547
1884
|
return _initialize.apply(this, arguments);
|
|
1548
1885
|
}
|
|
1549
1886
|
return initialize;
|
|
@@ -1553,15 +1890,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1553
1890
|
value: function () {
|
|
1554
1891
|
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
1555
1892
|
var _this$serverOrderChan2,
|
|
1556
|
-
|
|
1893
|
+
_this12 = this;
|
|
1557
1894
|
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1558
1895
|
while (1) switch (_context13.prev = _context13.next) {
|
|
1559
1896
|
case 0:
|
|
1560
1897
|
(_this$serverOrderChan2 = this.serverOrderChangeUnsubscribe) === null || _this$serverOrderChan2 === void 0 || _this$serverOrderChan2.call(this);
|
|
1561
1898
|
this.serverOrderChangeUnsubscribe = null;
|
|
1562
1899
|
Object.keys(this.store).forEach(function (key) {
|
|
1563
|
-
if (
|
|
1564
|
-
var sub =
|
|
1900
|
+
if (_this12.reusedSharedSubModuleNames.has(key)) return;
|
|
1901
|
+
var sub = _this12.store[key];
|
|
1565
1902
|
if (sub && typeof sub.destroy === 'function') {
|
|
1566
1903
|
try {
|
|
1567
1904
|
sub.destroy();
|
|
@@ -1601,7 +1938,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1601
1938
|
key: "loadSalesDetail",
|
|
1602
1939
|
value: (function () {
|
|
1603
1940
|
var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(orderIdOrParams) {
|
|
1604
|
-
var loadSequence,
|
|
1941
|
+
var loadSequence, _ref31, _ref32, _ref33, _ref34, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, loadedSalesDetail, shouldFilterPendingPayments, remoteRecord, mergeSourceRecord, currentTempOrder, mergedRecord, record;
|
|
1605
1942
|
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1606
1943
|
while (1) switch (_context14.prev = _context14.next) {
|
|
1607
1944
|
case 0:
|
|
@@ -1619,7 +1956,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1619
1956
|
};
|
|
1620
1957
|
externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
|
|
1621
1958
|
preloadedSalesDetail = params.preloadedSalesDetail;
|
|
1622
|
-
lookup = (
|
|
1959
|
+
lookup = (_ref31 = (_ref32 = (_ref33 = (_ref34 = (_params$orderId = params.orderId) !== null && _params$orderId !== void 0 ? _params$orderId : externalSaleNumber) !== null && _ref34 !== void 0 ? _ref34 : params.orderNumber) !== null && _ref33 !== void 0 ? _ref33 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_id) !== null && _ref32 !== void 0 ? _ref32 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.external_sale_number) !== null && _ref31 !== void 0 ? _ref31 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_number;
|
|
1623
1960
|
if (!(!preloadedSalesDetail && (lookup === undefined || lookup === null || lookup === ''))) {
|
|
1624
1961
|
_context14.next = 11;
|
|
1625
1962
|
break;
|
|
@@ -1691,7 +2028,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1691
2028
|
}
|
|
1692
2029
|
}, _callee14, this, [[4,, 32, 44], [35, 40]]);
|
|
1693
2030
|
}));
|
|
1694
|
-
function loadSalesDetail(
|
|
2031
|
+
function loadSalesDetail(_x12) {
|
|
1695
2032
|
return _loadSalesDetail.apply(this, arguments);
|
|
1696
2033
|
}
|
|
1697
2034
|
return loadSalesDetail;
|
|
@@ -1798,7 +2135,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1798
2135
|
}
|
|
1799
2136
|
}, _callee15, this);
|
|
1800
2137
|
}));
|
|
1801
|
-
function replaceTempOrder(
|
|
2138
|
+
function replaceTempOrder(_x13, _x14) {
|
|
1802
2139
|
return _replaceTempOrder.apply(this, arguments);
|
|
1803
2140
|
}
|
|
1804
2141
|
return replaceTempOrder;
|
|
@@ -1833,6 +2170,101 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1833
2170
|
if (!this.store.order) return '';
|
|
1834
2171
|
return this.store.order.getTempOrderNote();
|
|
1835
2172
|
}
|
|
2173
|
+
}, {
|
|
2174
|
+
key: "getSalesNotes",
|
|
2175
|
+
value: function getSalesNotes() {
|
|
2176
|
+
if (!this.store.order) return [];
|
|
2177
|
+
return this.store.order.getSalesNotes();
|
|
2178
|
+
}
|
|
2179
|
+
}, {
|
|
2180
|
+
key: "createSalesNotesMutationSnapshot",
|
|
2181
|
+
value: function createSalesNotesMutationSnapshot() {
|
|
2182
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
2183
|
+
return this.store.order.createSalesNotesMutationSnapshot();
|
|
2184
|
+
}
|
|
2185
|
+
}, {
|
|
2186
|
+
key: "restoreSalesNotesMutationSnapshot",
|
|
2187
|
+
value: function restoreSalesNotesMutationSnapshot(snapshot) {
|
|
2188
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
2189
|
+
this.store.order.restoreSalesNotesMutationSnapshot(snapshot);
|
|
2190
|
+
}
|
|
2191
|
+
}, {
|
|
2192
|
+
key: "setSalesNote",
|
|
2193
|
+
value: function () {
|
|
2194
|
+
var _setSalesNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(input) {
|
|
2195
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
2196
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
2197
|
+
case 0:
|
|
2198
|
+
if (this.store.order) {
|
|
2199
|
+
_context16.next = 2;
|
|
2200
|
+
break;
|
|
2201
|
+
}
|
|
2202
|
+
throw new Error('order 模块未初始化');
|
|
2203
|
+
case 2:
|
|
2204
|
+
return _context16.abrupt("return", this.store.order.setSalesNote(input));
|
|
2205
|
+
case 3:
|
|
2206
|
+
case "end":
|
|
2207
|
+
return _context16.stop();
|
|
2208
|
+
}
|
|
2209
|
+
}, _callee16, this);
|
|
2210
|
+
}));
|
|
2211
|
+
function setSalesNote(_x15) {
|
|
2212
|
+
return _setSalesNote.apply(this, arguments);
|
|
2213
|
+
}
|
|
2214
|
+
return setSalesNote;
|
|
2215
|
+
}()
|
|
2216
|
+
}, {
|
|
2217
|
+
key: "removeSalesNote",
|
|
2218
|
+
value: function () {
|
|
2219
|
+
var _removeSalesNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(uuid) {
|
|
2220
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
2221
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
2222
|
+
case 0:
|
|
2223
|
+
if (this.store.order) {
|
|
2224
|
+
_context17.next = 2;
|
|
2225
|
+
break;
|
|
2226
|
+
}
|
|
2227
|
+
throw new Error('order 模块未初始化');
|
|
2228
|
+
case 2:
|
|
2229
|
+
_context17.next = 4;
|
|
2230
|
+
return this.store.order.removeSalesNote(uuid);
|
|
2231
|
+
case 4:
|
|
2232
|
+
case "end":
|
|
2233
|
+
return _context17.stop();
|
|
2234
|
+
}
|
|
2235
|
+
}, _callee17, this);
|
|
2236
|
+
}));
|
|
2237
|
+
function removeSalesNote(_x16) {
|
|
2238
|
+
return _removeSalesNote.apply(this, arguments);
|
|
2239
|
+
}
|
|
2240
|
+
return removeSalesNote;
|
|
2241
|
+
}()
|
|
2242
|
+
}, {
|
|
2243
|
+
key: "clearSalesNotes",
|
|
2244
|
+
value: function () {
|
|
2245
|
+
var _clearSalesNotes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
2246
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
2247
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
2248
|
+
case 0:
|
|
2249
|
+
if (this.store.order) {
|
|
2250
|
+
_context18.next = 2;
|
|
2251
|
+
break;
|
|
2252
|
+
}
|
|
2253
|
+
throw new Error('order 模块未初始化');
|
|
2254
|
+
case 2:
|
|
2255
|
+
_context18.next = 4;
|
|
2256
|
+
return this.store.order.clearSalesNotes();
|
|
2257
|
+
case 4:
|
|
2258
|
+
case "end":
|
|
2259
|
+
return _context18.stop();
|
|
2260
|
+
}
|
|
2261
|
+
}, _callee18, this);
|
|
2262
|
+
}));
|
|
2263
|
+
function clearSalesNotes() {
|
|
2264
|
+
return _clearSalesNotes.apply(this, arguments);
|
|
2265
|
+
}
|
|
2266
|
+
return clearSalesNotes;
|
|
2267
|
+
}()
|
|
1836
2268
|
}, {
|
|
1837
2269
|
key: "updateTempOrderNote",
|
|
1838
2270
|
value: function updateTempOrderNote(note) {
|
|
@@ -1863,6 +2295,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1863
2295
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
1864
2296
|
return this.store.order.updateTempOrderDepositAmount(amount);
|
|
1865
2297
|
}
|
|
2298
|
+
}, {
|
|
2299
|
+
key: "setPickupReferenceMode",
|
|
2300
|
+
value: function setPickupReferenceMode(mode) {
|
|
2301
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
2302
|
+
return this.store.order.updateTempOrderPickupReferenceMode(mode);
|
|
2303
|
+
}
|
|
2304
|
+
}, {
|
|
2305
|
+
key: "setServiceType",
|
|
2306
|
+
value: function setServiceType(serviceType) {
|
|
2307
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
2308
|
+
return this.store.order.updateTempOrderServiceType(serviceType);
|
|
2309
|
+
}
|
|
1866
2310
|
}, {
|
|
1867
2311
|
key: "updateTempOrderContactsInfo",
|
|
1868
2312
|
value: function updateTempOrderContactsInfo(contactsInfo) {
|
|
@@ -1896,40 +2340,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1896
2340
|
}, {
|
|
1897
2341
|
key: "addNewOrder",
|
|
1898
2342
|
value: function () {
|
|
1899
|
-
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2343
|
+
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
|
|
1900
2344
|
var tempOrder;
|
|
1901
|
-
return _regeneratorRuntime().wrap(function
|
|
1902
|
-
while (1) switch (
|
|
2345
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
2346
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1903
2347
|
case 0:
|
|
1904
|
-
|
|
2348
|
+
_context19.prev = 0;
|
|
1905
2349
|
if (this.store.order) {
|
|
1906
|
-
|
|
2350
|
+
_context19.next = 3;
|
|
1907
2351
|
break;
|
|
1908
2352
|
}
|
|
1909
2353
|
throw new Error('order 模块未初始化');
|
|
1910
2354
|
case 3:
|
|
1911
|
-
|
|
2355
|
+
_context19.next = 5;
|
|
1912
2356
|
return this.store.order.addNewOrder();
|
|
1913
2357
|
case 5:
|
|
1914
|
-
tempOrder =
|
|
2358
|
+
tempOrder = _context19.sent;
|
|
1915
2359
|
if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
|
|
1916
|
-
|
|
2360
|
+
_context19.next = 10;
|
|
1917
2361
|
break;
|
|
1918
2362
|
}
|
|
1919
2363
|
this.store.order.persistTempOrder();
|
|
1920
|
-
|
|
2364
|
+
_context19.next = 10;
|
|
1921
2365
|
return this.store.order.saveDraft();
|
|
1922
2366
|
case 10:
|
|
1923
|
-
return
|
|
2367
|
+
return _context19.abrupt("return", tempOrder);
|
|
1924
2368
|
case 13:
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
throw
|
|
2369
|
+
_context19.prev = 13;
|
|
2370
|
+
_context19.t0 = _context19["catch"](0);
|
|
2371
|
+
throw _context19.t0;
|
|
1928
2372
|
case 16:
|
|
1929
2373
|
case "end":
|
|
1930
|
-
return
|
|
2374
|
+
return _context19.stop();
|
|
1931
2375
|
}
|
|
1932
|
-
},
|
|
2376
|
+
}, _callee19, this, [[0, 13]]);
|
|
1933
2377
|
}));
|
|
1934
2378
|
function addNewOrder() {
|
|
1935
2379
|
return _addNewOrder.apply(this, arguments);
|
|
@@ -1939,22 +2383,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1939
2383
|
}, {
|
|
1940
2384
|
key: "saveDraft",
|
|
1941
2385
|
value: function () {
|
|
1942
|
-
var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1943
|
-
return _regeneratorRuntime().wrap(function
|
|
1944
|
-
while (1) switch (
|
|
2386
|
+
var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
2387
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
2388
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1945
2389
|
case 0:
|
|
1946
2390
|
if (this.store.order) {
|
|
1947
|
-
|
|
2391
|
+
_context20.next = 2;
|
|
1948
2392
|
break;
|
|
1949
2393
|
}
|
|
1950
2394
|
throw new Error('order 模块未初始化');
|
|
1951
2395
|
case 2:
|
|
1952
|
-
return
|
|
2396
|
+
return _context20.abrupt("return", this.store.order.saveDraft());
|
|
1953
2397
|
case 3:
|
|
1954
2398
|
case "end":
|
|
1955
|
-
return
|
|
2399
|
+
return _context20.stop();
|
|
1956
2400
|
}
|
|
1957
|
-
},
|
|
2401
|
+
}, _callee20, this);
|
|
1958
2402
|
}));
|
|
1959
2403
|
function saveDraft() {
|
|
1960
2404
|
return _saveDraft.apply(this, arguments);
|
|
@@ -1965,56 +2409,57 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1965
2409
|
}, {
|
|
1966
2410
|
key: "restoreOrder",
|
|
1967
2411
|
value: function () {
|
|
1968
|
-
var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1969
|
-
var _this$store$payment, tempOrder, wallet;
|
|
1970
|
-
return _regeneratorRuntime().wrap(function
|
|
1971
|
-
while (1) switch (
|
|
2412
|
+
var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
2413
|
+
var _this$store$payment, tempOrder, appDataChanged, wallet;
|
|
2414
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
2415
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1972
2416
|
case 0:
|
|
1973
|
-
|
|
2417
|
+
_context21.prev = 0;
|
|
1974
2418
|
if (this.store.order) {
|
|
1975
|
-
|
|
2419
|
+
_context21.next = 3;
|
|
1976
2420
|
break;
|
|
1977
2421
|
}
|
|
1978
2422
|
throw new Error('scanOrder 解决方案需要 order 模块支持');
|
|
1979
2423
|
case 3:
|
|
1980
2424
|
// this.store.resource = null;
|
|
1981
|
-
tempOrder = this.store.order.restoreOrder();
|
|
2425
|
+
tempOrder = this.store.order.restoreOrder(); // 先补齐店铺级订单字段,再通知监听方,避免发布带空税区/币种的中间快照。
|
|
2426
|
+
appDataChanged = this.syncAppDataToTempOrder(tempOrder);
|
|
1982
2427
|
this.currentSalesDetail = null;
|
|
1983
2428
|
this.discountConfigCacheKey = null;
|
|
1984
2429
|
this.hasManualDiscountSelection = false;
|
|
1985
2430
|
wallet = (_this$store$payment = this.store.payment) === null || _this$store$payment === void 0 ? void 0 : _this$store$payment.wallet;
|
|
1986
2431
|
if (!wallet) {
|
|
1987
|
-
|
|
2432
|
+
_context21.next = 14;
|
|
1988
2433
|
break;
|
|
1989
2434
|
}
|
|
1990
2435
|
this.walletAssetsRefreshSequence += 1;
|
|
1991
2436
|
wallet.clearAllCache();
|
|
1992
|
-
|
|
2437
|
+
_context21.next = 14;
|
|
1993
2438
|
return this.publishWalletAssetsState(wallet.getWalletAssetsState());
|
|
1994
|
-
case
|
|
1995
|
-
|
|
2439
|
+
case 14:
|
|
2440
|
+
_context21.next = 16;
|
|
1996
2441
|
return this.effectsEmit('onTempOrderReplaced', {
|
|
1997
2442
|
tempOrder: tempOrder
|
|
1998
2443
|
});
|
|
1999
|
-
case
|
|
2000
|
-
if (!(
|
|
2001
|
-
|
|
2444
|
+
case 16:
|
|
2445
|
+
if (!(appDataChanged && this.isTempOrderPersistEnabled())) {
|
|
2446
|
+
_context21.next = 20;
|
|
2002
2447
|
break;
|
|
2003
2448
|
}
|
|
2004
2449
|
this.store.order.persistTempOrder();
|
|
2005
|
-
|
|
2450
|
+
_context21.next = 20;
|
|
2006
2451
|
return this.store.order.saveDraft();
|
|
2007
|
-
case
|
|
2008
|
-
return
|
|
2009
|
-
case
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
throw
|
|
2013
|
-
case
|
|
2452
|
+
case 20:
|
|
2453
|
+
return _context21.abrupt("return", tempOrder);
|
|
2454
|
+
case 23:
|
|
2455
|
+
_context21.prev = 23;
|
|
2456
|
+
_context21.t0 = _context21["catch"](0);
|
|
2457
|
+
throw _context21.t0;
|
|
2458
|
+
case 26:
|
|
2014
2459
|
case "end":
|
|
2015
|
-
return
|
|
2460
|
+
return _context21.stop();
|
|
2016
2461
|
}
|
|
2017
|
-
},
|
|
2462
|
+
}, _callee21, this, [[0, 23]]);
|
|
2018
2463
|
}));
|
|
2019
2464
|
function restoreOrder() {
|
|
2020
2465
|
return _restoreOrder.apply(this, arguments);
|
|
@@ -2028,22 +2473,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2028
2473
|
}, {
|
|
2029
2474
|
key: "clearOrderCartLines",
|
|
2030
2475
|
value: (function () {
|
|
2031
|
-
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2476
|
+
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
|
|
2032
2477
|
var tempOrder;
|
|
2033
|
-
return _regeneratorRuntime().wrap(function
|
|
2034
|
-
while (1) switch (
|
|
2478
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
2479
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
2035
2480
|
case 0:
|
|
2036
|
-
|
|
2481
|
+
_context22.prev = 0;
|
|
2037
2482
|
if (this.store.order) {
|
|
2038
|
-
|
|
2483
|
+
_context22.next = 3;
|
|
2039
2484
|
break;
|
|
2040
2485
|
}
|
|
2041
2486
|
throw new Error('order 模块未初始化');
|
|
2042
2487
|
case 3:
|
|
2043
|
-
|
|
2488
|
+
_context22.next = 5;
|
|
2044
2489
|
return this.store.order.clearOrderCartLines();
|
|
2045
2490
|
case 5:
|
|
2046
|
-
tempOrder =
|
|
2491
|
+
tempOrder = _context22.sent;
|
|
2047
2492
|
if (this.currentSalesDetail) {
|
|
2048
2493
|
this.currentSalesDetail = _objectSpread(_objectSpread({}, this.currentSalesDetail), {}, {
|
|
2049
2494
|
products: [],
|
|
@@ -2053,29 +2498,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2053
2498
|
discount_list: []
|
|
2054
2499
|
});
|
|
2055
2500
|
}
|
|
2056
|
-
|
|
2501
|
+
_context22.next = 9;
|
|
2057
2502
|
return this.effectsEmit('onTempOrderReplaced', {
|
|
2058
2503
|
tempOrder: tempOrder
|
|
2059
2504
|
});
|
|
2060
2505
|
case 9:
|
|
2061
2506
|
if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
|
|
2062
|
-
|
|
2507
|
+
_context22.next = 13;
|
|
2063
2508
|
break;
|
|
2064
2509
|
}
|
|
2065
2510
|
this.store.order.persistTempOrder();
|
|
2066
|
-
|
|
2511
|
+
_context22.next = 13;
|
|
2067
2512
|
return this.store.order.saveDraft();
|
|
2068
2513
|
case 13:
|
|
2069
|
-
return
|
|
2514
|
+
return _context22.abrupt("return", tempOrder);
|
|
2070
2515
|
case 16:
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
throw
|
|
2516
|
+
_context22.prev = 16;
|
|
2517
|
+
_context22.t0 = _context22["catch"](0);
|
|
2518
|
+
throw _context22.t0;
|
|
2074
2519
|
case 19:
|
|
2075
2520
|
case "end":
|
|
2076
|
-
return
|
|
2521
|
+
return _context22.stop();
|
|
2077
2522
|
}
|
|
2078
|
-
},
|
|
2523
|
+
}, _callee22, this, [[0, 16]]);
|
|
2079
2524
|
}));
|
|
2080
2525
|
function clearOrderCartLines() {
|
|
2081
2526
|
return _clearOrderCartLines.apply(this, arguments);
|
|
@@ -2092,32 +2537,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2092
2537
|
}, {
|
|
2093
2538
|
key: "getSummary",
|
|
2094
2539
|
value: function () {
|
|
2095
|
-
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2540
|
+
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
2096
2541
|
var summary;
|
|
2097
|
-
return _regeneratorRuntime().wrap(function
|
|
2098
|
-
while (1) switch (
|
|
2542
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
2543
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
2099
2544
|
case 0:
|
|
2100
|
-
|
|
2545
|
+
_context23.prev = 0;
|
|
2101
2546
|
if (this.store.order) {
|
|
2102
|
-
|
|
2547
|
+
_context23.next = 3;
|
|
2103
2548
|
break;
|
|
2104
2549
|
}
|
|
2105
2550
|
throw new Error('order 模块未初始化');
|
|
2106
2551
|
case 3:
|
|
2107
|
-
|
|
2552
|
+
_context23.next = 5;
|
|
2108
2553
|
return this.store.order.getOrderSummary();
|
|
2109
2554
|
case 5:
|
|
2110
|
-
summary =
|
|
2111
|
-
return
|
|
2555
|
+
summary = _context23.sent;
|
|
2556
|
+
return _context23.abrupt("return", summary);
|
|
2112
2557
|
case 9:
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
throw
|
|
2558
|
+
_context23.prev = 9;
|
|
2559
|
+
_context23.t0 = _context23["catch"](0);
|
|
2560
|
+
throw _context23.t0;
|
|
2116
2561
|
case 12:
|
|
2117
2562
|
case "end":
|
|
2118
|
-
return
|
|
2563
|
+
return _context23.stop();
|
|
2119
2564
|
}
|
|
2120
|
-
},
|
|
2565
|
+
}, _callee23, this, [[0, 9]]);
|
|
2121
2566
|
}));
|
|
2122
2567
|
function getSummary() {
|
|
2123
2568
|
return _getSummary.apply(this, arguments);
|
|
@@ -2127,10 +2572,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2127
2572
|
}, {
|
|
2128
2573
|
key: "getHistoricalProductDiscountList",
|
|
2129
2574
|
value: function getHistoricalProductDiscountList(products) {
|
|
2130
|
-
var
|
|
2575
|
+
var _this13 = this;
|
|
2131
2576
|
var historyDiscountList = [];
|
|
2132
2577
|
products.forEach(function (item) {
|
|
2133
|
-
if (!
|
|
2578
|
+
if (!_this13.isPersistedOrderProduct(item)) return;
|
|
2134
2579
|
(item.discount_list || []).forEach(function (discount) {
|
|
2135
2580
|
var _discount$discount, _discount$metadata, _discount$discount2, _discount$discount3, _discount$discount4;
|
|
2136
2581
|
var discountId = ((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) || discount.id;
|
|
@@ -2190,11 +2635,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2190
2635
|
}, {
|
|
2191
2636
|
key: "shouldSkipAutoApplyFetchedDiscountsInEditMode",
|
|
2192
2637
|
value: function shouldSkipAutoApplyFetchedDiscountsInEditMode(params) {
|
|
2193
|
-
var
|
|
2638
|
+
var _this14 = this;
|
|
2194
2639
|
if (params.discountAction !== 'edit') return false;
|
|
2195
2640
|
if (!params.products.length) return false;
|
|
2196
2641
|
var hasDraftProduct = params.products.some(function (product) {
|
|
2197
|
-
return !
|
|
2642
|
+
return !_this14.isPersistedOrderProduct(product);
|
|
2198
2643
|
});
|
|
2199
2644
|
if (hasDraftProduct) return false;
|
|
2200
2645
|
|
|
@@ -2245,14 +2690,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2245
2690
|
}, {
|
|
2246
2691
|
key: "loadDiscountConfig",
|
|
2247
2692
|
value: function () {
|
|
2248
|
-
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2693
|
+
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
|
|
2249
2694
|
var _this$getOrderIdentit, _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _discountModule$getDi, _discountModule$getOr, _discountModule$getDi2;
|
|
2250
2695
|
var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, discountConfigCacheKey, preparedDiscountList, _discountModule$setOr, nextDiscountList, shouldSkipAutoApplyFetchedDiscounts, _summary, _orderStore$summary, orderTotalAmount, result, _iterator3, _step3, _product$metadata5, _tempOrder$_extend3, _product$metadata$sou, _product$metadata6, _product$metadata7, _product$original_pri, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice, summary;
|
|
2251
|
-
return _regeneratorRuntime().wrap(function
|
|
2252
|
-
while (1) switch (
|
|
2696
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
2697
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
2253
2698
|
case 0:
|
|
2254
2699
|
if (this.store.order) {
|
|
2255
|
-
|
|
2700
|
+
_context24.next = 2;
|
|
2256
2701
|
break;
|
|
2257
2702
|
}
|
|
2258
2703
|
throw new Error('order 模块未初始化');
|
|
@@ -2272,18 +2717,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2272
2717
|
discountConfigCacheKey = [customerId, discountAction, Number(orderId) || 0].join(':');
|
|
2273
2718
|
preparedDiscountList = [];
|
|
2274
2719
|
if (!(customerId && customerId !== 1)) {
|
|
2275
|
-
|
|
2720
|
+
_context24.next = 25;
|
|
2276
2721
|
break;
|
|
2277
2722
|
}
|
|
2278
2723
|
if (!(this.discountConfigCacheKey === discountConfigCacheKey)) {
|
|
2279
|
-
|
|
2724
|
+
_context24.next = 19;
|
|
2280
2725
|
break;
|
|
2281
2726
|
}
|
|
2282
2727
|
preparedDiscountList = originalDiscountList;
|
|
2283
|
-
|
|
2728
|
+
_context24.next = 25;
|
|
2284
2729
|
break;
|
|
2285
2730
|
case 19:
|
|
2286
|
-
|
|
2731
|
+
_context24.next = 21;
|
|
2287
2732
|
return this.store.order.loadDiscountConfig({
|
|
2288
2733
|
customerId: customerId,
|
|
2289
2734
|
action: discountAction,
|
|
@@ -2291,16 +2736,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2291
2736
|
apply: false
|
|
2292
2737
|
});
|
|
2293
2738
|
case 21:
|
|
2294
|
-
preparedDiscountList =
|
|
2739
|
+
preparedDiscountList = _context24.sent;
|
|
2295
2740
|
this.discountConfigCacheKey = discountConfigCacheKey;
|
|
2296
|
-
|
|
2741
|
+
_context24.next = 25;
|
|
2297
2742
|
return discountModule === null || discountModule === void 0 || (_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, preparedDiscountList);
|
|
2298
2743
|
case 25:
|
|
2299
2744
|
if (!(hasManualDiscountSelection && currentDiscountList.length)) {
|
|
2300
|
-
|
|
2745
|
+
_context24.next = 27;
|
|
2301
2746
|
break;
|
|
2302
2747
|
}
|
|
2303
|
-
return
|
|
2748
|
+
return _context24.abrupt("return", {
|
|
2304
2749
|
productList: tempOrder.products || [],
|
|
2305
2750
|
discountList: currentDiscountList,
|
|
2306
2751
|
availableWalletIds: this.getAvailableWalletIds()
|
|
@@ -2308,7 +2753,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2308
2753
|
case 27:
|
|
2309
2754
|
nextDiscountList = this.mergeHistoricalDiscountList(preparedDiscountList || (discountModule === null || discountModule === void 0 || (_discountModule$getDi2 = discountModule.getDiscountList) === null || _discountModule$getDi2 === void 0 ? void 0 : _discountModule$getDi2.call(discountModule)) || [], tempOrder.products || []);
|
|
2310
2755
|
nextDiscountList = this.mergeCurrentDiscountSelectionState(nextDiscountList, currentDiscountList);
|
|
2311
|
-
|
|
2756
|
+
_context24.next = 31;
|
|
2312
2757
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
2313
2758
|
case 31:
|
|
2314
2759
|
shouldSkipAutoApplyFetchedDiscounts = this.shouldSkipAutoApplyFetchedDiscountsInEditMode({
|
|
@@ -2318,17 +2763,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2318
2763
|
nextDiscountList: nextDiscountList
|
|
2319
2764
|
});
|
|
2320
2765
|
if (!shouldSkipAutoApplyFetchedDiscounts) {
|
|
2321
|
-
|
|
2766
|
+
_context24.next = 40;
|
|
2322
2767
|
break;
|
|
2323
2768
|
}
|
|
2324
|
-
|
|
2769
|
+
_context24.next = 35;
|
|
2325
2770
|
return this.store.order.recalculateSummary({
|
|
2326
2771
|
createIfMissing: true
|
|
2327
2772
|
});
|
|
2328
2773
|
case 35:
|
|
2329
|
-
_summary =
|
|
2774
|
+
_summary = _context24.sent;
|
|
2330
2775
|
this.store.order.persistTempOrder();
|
|
2331
|
-
|
|
2776
|
+
_context24.next = 39;
|
|
2332
2777
|
return this.effectsEmit('onDiscountApplied', {
|
|
2333
2778
|
productList: tempOrder.products || [],
|
|
2334
2779
|
discountList: nextDiscountList,
|
|
@@ -2336,14 +2781,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2336
2781
|
tempOrder: tempOrder
|
|
2337
2782
|
});
|
|
2338
2783
|
case 39:
|
|
2339
|
-
return
|
|
2784
|
+
return _context24.abrupt("return", {
|
|
2340
2785
|
productList: tempOrder.products || [],
|
|
2341
2786
|
discountList: nextDiscountList,
|
|
2342
2787
|
availableWalletIds: this.getAvailableWalletIds()
|
|
2343
2788
|
});
|
|
2344
2789
|
case 40:
|
|
2345
2790
|
if (!rulesModule) {
|
|
2346
|
-
|
|
2791
|
+
_context24.next = 76;
|
|
2347
2792
|
break;
|
|
2348
2793
|
}
|
|
2349
2794
|
orderTotalAmount = Number(((_orderStore$summary = orderStore.summary) === null || _orderStore$summary === void 0 ? void 0 : _orderStore$summary.total_amount) || 0);
|
|
@@ -2363,21 +2808,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2363
2808
|
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
2364
2809
|
}
|
|
2365
2810
|
_iterator3 = _createForOfIteratorHelper(tempOrder.products || []);
|
|
2366
|
-
|
|
2811
|
+
_context24.prev = 45;
|
|
2367
2812
|
_iterator3.s();
|
|
2368
2813
|
case 47:
|
|
2369
2814
|
if ((_step3 = _iterator3.n()).done) {
|
|
2370
|
-
|
|
2815
|
+
_context24.next = 62;
|
|
2371
2816
|
break;
|
|
2372
2817
|
}
|
|
2373
2818
|
product = _step3.value;
|
|
2374
2819
|
productUid = (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number;
|
|
2375
2820
|
runtimeOrigin = productUid ? (_tempOrder$_extend3 = tempOrder._extend) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3.productsByUid) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3[productUid]) === null || _tempOrder$_extend3 === void 0 ? void 0 : _tempOrder$_extend3.origin : undefined;
|
|
2376
2821
|
if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
|
|
2377
|
-
|
|
2822
|
+
_context24.next = 53;
|
|
2378
2823
|
break;
|
|
2379
2824
|
}
|
|
2380
|
-
return
|
|
2825
|
+
return _context24.abrupt("continue", 60);
|
|
2381
2826
|
case 53:
|
|
2382
2827
|
totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
|
|
2383
2828
|
return sum + Number(pd.amount || 0);
|
|
@@ -2395,41 +2840,41 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2395
2840
|
bundle: product.product_bundle
|
|
2396
2841
|
});
|
|
2397
2842
|
case 60:
|
|
2398
|
-
|
|
2843
|
+
_context24.next = 47;
|
|
2399
2844
|
break;
|
|
2400
2845
|
case 62:
|
|
2401
|
-
|
|
2846
|
+
_context24.next = 67;
|
|
2402
2847
|
break;
|
|
2403
2848
|
case 64:
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
_iterator3.e(
|
|
2849
|
+
_context24.prev = 64;
|
|
2850
|
+
_context24.t0 = _context24["catch"](45);
|
|
2851
|
+
_iterator3.e(_context24.t0);
|
|
2407
2852
|
case 67:
|
|
2408
|
-
|
|
2853
|
+
_context24.prev = 67;
|
|
2409
2854
|
_iterator3.f();
|
|
2410
|
-
return
|
|
2855
|
+
return _context24.finish(67);
|
|
2411
2856
|
case 70:
|
|
2412
2857
|
if (!result.discountList) {
|
|
2413
|
-
|
|
2858
|
+
_context24.next = 76;
|
|
2414
2859
|
break;
|
|
2415
2860
|
}
|
|
2416
2861
|
nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
|
|
2417
2862
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
2418
|
-
|
|
2863
|
+
_context24.next = 75;
|
|
2419
2864
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
2420
2865
|
case 75:
|
|
2421
2866
|
tempOrder.discount_list = nextDiscountList.filter(function (discount) {
|
|
2422
2867
|
return discount.isSelected;
|
|
2423
2868
|
});
|
|
2424
2869
|
case 76:
|
|
2425
|
-
|
|
2870
|
+
_context24.next = 78;
|
|
2426
2871
|
return this.store.order.recalculateSummary({
|
|
2427
2872
|
createIfMissing: true
|
|
2428
2873
|
});
|
|
2429
2874
|
case 78:
|
|
2430
|
-
summary =
|
|
2875
|
+
summary = _context24.sent;
|
|
2431
2876
|
this.store.order.persistTempOrder();
|
|
2432
|
-
|
|
2877
|
+
_context24.next = 82;
|
|
2433
2878
|
return this.effectsEmit('onDiscountApplied', {
|
|
2434
2879
|
productList: tempOrder.products || [],
|
|
2435
2880
|
discountList: nextDiscountList,
|
|
@@ -2437,18 +2882,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2437
2882
|
tempOrder: tempOrder
|
|
2438
2883
|
});
|
|
2439
2884
|
case 82:
|
|
2440
|
-
return
|
|
2885
|
+
return _context24.abrupt("return", {
|
|
2441
2886
|
productList: tempOrder.products || [],
|
|
2442
2887
|
discountList: nextDiscountList,
|
|
2443
2888
|
availableWalletIds: this.getAvailableWalletIds()
|
|
2444
2889
|
});
|
|
2445
2890
|
case 83:
|
|
2446
2891
|
case "end":
|
|
2447
|
-
return
|
|
2892
|
+
return _context24.stop();
|
|
2448
2893
|
}
|
|
2449
|
-
},
|
|
2894
|
+
}, _callee24, this, [[45, 64, 67, 70]]);
|
|
2450
2895
|
}));
|
|
2451
|
-
function loadDiscountConfig(
|
|
2896
|
+
function loadDiscountConfig(_x17) {
|
|
2452
2897
|
return _loadDiscountConfig.apply(this, arguments);
|
|
2453
2898
|
}
|
|
2454
2899
|
return loadDiscountConfig;
|
|
@@ -2463,14 +2908,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2463
2908
|
}, {
|
|
2464
2909
|
key: "bestDiscount",
|
|
2465
2910
|
value: function () {
|
|
2466
|
-
var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2911
|
+
var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(cb) {
|
|
2467
2912
|
var _discountModule$getOr2, _discountModule$getDi3;
|
|
2468
2913
|
var tempOrder, orderStore, discountModule, rulesModule, originalDiscountList, currentDiscountList, nextDiscountList, result, _orderStore$summary2, orderTotalAmount;
|
|
2469
|
-
return _regeneratorRuntime().wrap(function
|
|
2470
|
-
while (1) switch (
|
|
2914
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
2915
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
2471
2916
|
case 0:
|
|
2472
2917
|
if (this.store.order) {
|
|
2473
|
-
|
|
2918
|
+
_context25.next = 2;
|
|
2474
2919
|
break;
|
|
2475
2920
|
}
|
|
2476
2921
|
throw new Error('order 模块未初始化');
|
|
@@ -2486,11 +2931,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2486
2931
|
productList: tempOrder.products || [],
|
|
2487
2932
|
discountList: nextDiscountList
|
|
2488
2933
|
};
|
|
2489
|
-
|
|
2934
|
+
_context25.next = 12;
|
|
2490
2935
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
2491
2936
|
case 12:
|
|
2492
2937
|
if (!rulesModule) {
|
|
2493
|
-
|
|
2938
|
+
_context25.next = 23;
|
|
2494
2939
|
break;
|
|
2495
2940
|
}
|
|
2496
2941
|
orderTotalAmount = Number(((_orderStore$summary2 = orderStore.summary) === null || _orderStore$summary2 === void 0 ? void 0 : _orderStore$summary2.total_amount) || 0);
|
|
@@ -2507,12 +2952,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2507
2952
|
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
2508
2953
|
}
|
|
2509
2954
|
if (!result.discountList) {
|
|
2510
|
-
|
|
2955
|
+
_context25.next = 23;
|
|
2511
2956
|
break;
|
|
2512
2957
|
}
|
|
2513
2958
|
nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
|
|
2514
2959
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
2515
|
-
|
|
2960
|
+
_context25.next = 21;
|
|
2516
2961
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
2517
2962
|
case 21:
|
|
2518
2963
|
tempOrder.discount_list = nextDiscountList.filter(function (discount) {
|
|
@@ -2523,13 +2968,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2523
2968
|
discountList: nextDiscountList
|
|
2524
2969
|
};
|
|
2525
2970
|
case 23:
|
|
2526
|
-
|
|
2971
|
+
_context25.next = 25;
|
|
2527
2972
|
return this.store.order.recalculateSummary({
|
|
2528
2973
|
createIfMissing: true
|
|
2529
2974
|
});
|
|
2530
2975
|
case 25:
|
|
2531
2976
|
this.store.order.persistTempOrder();
|
|
2532
|
-
|
|
2977
|
+
_context25.next = 28;
|
|
2533
2978
|
return this.effectsEmit('onDiscountApplied', {
|
|
2534
2979
|
productList: tempOrder.products || [],
|
|
2535
2980
|
discountList: nextDiscountList,
|
|
@@ -2538,14 +2983,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2538
2983
|
});
|
|
2539
2984
|
case 28:
|
|
2540
2985
|
cb === null || cb === void 0 || cb(result);
|
|
2541
|
-
return
|
|
2986
|
+
return _context25.abrupt("return", result);
|
|
2542
2987
|
case 30:
|
|
2543
2988
|
case "end":
|
|
2544
|
-
return
|
|
2989
|
+
return _context25.stop();
|
|
2545
2990
|
}
|
|
2546
|
-
},
|
|
2991
|
+
}, _callee25, this);
|
|
2547
2992
|
}));
|
|
2548
|
-
function bestDiscount(
|
|
2993
|
+
function bestDiscount(_x18) {
|
|
2549
2994
|
return _bestDiscount.apply(this, arguments);
|
|
2550
2995
|
}
|
|
2551
2996
|
return bestDiscount;
|
|
@@ -2574,41 +3019,41 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2574
3019
|
}, {
|
|
2575
3020
|
key: "replaceDiscountStoreLists",
|
|
2576
3021
|
value: (function () {
|
|
2577
|
-
var _replaceDiscountStoreLists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3022
|
+
var _replaceDiscountStoreLists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
|
|
2578
3023
|
var _store2;
|
|
2579
3024
|
var discountModule;
|
|
2580
|
-
return _regeneratorRuntime().wrap(function
|
|
2581
|
-
while (1) switch (
|
|
3025
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
3026
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
2582
3027
|
case 0:
|
|
2583
3028
|
if (this.store.order) {
|
|
2584
|
-
|
|
3029
|
+
_context26.next = 2;
|
|
2585
3030
|
break;
|
|
2586
3031
|
}
|
|
2587
3032
|
throw new Error('order 模块未初始化');
|
|
2588
3033
|
case 2:
|
|
2589
3034
|
discountModule = (_store2 = this.store.order.store) === null || _store2 === void 0 ? void 0 : _store2.discount;
|
|
2590
3035
|
if (discountModule) {
|
|
2591
|
-
|
|
3036
|
+
_context26.next = 5;
|
|
2592
3037
|
break;
|
|
2593
3038
|
}
|
|
2594
|
-
return
|
|
3039
|
+
return _context26.abrupt("return");
|
|
2595
3040
|
case 5:
|
|
2596
3041
|
if (!params.originalDiscountList) {
|
|
2597
|
-
|
|
3042
|
+
_context26.next = 8;
|
|
2598
3043
|
break;
|
|
2599
3044
|
}
|
|
2600
|
-
|
|
3045
|
+
_context26.next = 8;
|
|
2601
3046
|
return discountModule.setOriginalDiscountList(params.originalDiscountList);
|
|
2602
3047
|
case 8:
|
|
2603
|
-
|
|
3048
|
+
_context26.next = 10;
|
|
2604
3049
|
return discountModule.setDiscountList(params.discountList);
|
|
2605
3050
|
case 10:
|
|
2606
3051
|
case "end":
|
|
2607
|
-
return
|
|
3052
|
+
return _context26.stop();
|
|
2608
3053
|
}
|
|
2609
|
-
},
|
|
3054
|
+
}, _callee26, this);
|
|
2610
3055
|
}));
|
|
2611
|
-
function replaceDiscountStoreLists(
|
|
3056
|
+
function replaceDiscountStoreLists(_x19) {
|
|
2612
3057
|
return _replaceDiscountStoreLists.apply(this, arguments);
|
|
2613
3058
|
}
|
|
2614
3059
|
return replaceDiscountStoreLists;
|
|
@@ -2616,34 +3061,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2616
3061
|
}, {
|
|
2617
3062
|
key: "scanPromotionCode",
|
|
2618
3063
|
value: function () {
|
|
2619
|
-
var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3064
|
+
var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(code, customerId) {
|
|
2620
3065
|
var raw, tempOrder;
|
|
2621
|
-
return _regeneratorRuntime().wrap(function
|
|
2622
|
-
while (1) switch (
|
|
3066
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
3067
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
2623
3068
|
case 0:
|
|
2624
|
-
|
|
3069
|
+
_context27.prev = 0;
|
|
2625
3070
|
if (this.store.order) {
|
|
2626
|
-
|
|
3071
|
+
_context27.next = 3;
|
|
2627
3072
|
break;
|
|
2628
3073
|
}
|
|
2629
3074
|
throw new Error('order 模块未初始化');
|
|
2630
3075
|
case 3:
|
|
2631
|
-
|
|
3076
|
+
_context27.next = 5;
|
|
2632
3077
|
return this.store.order.scanCode(code, customerId);
|
|
2633
3078
|
case 5:
|
|
2634
|
-
raw =
|
|
3079
|
+
raw = _context27.sent;
|
|
2635
3080
|
if (!raw.isAvailable) {
|
|
2636
|
-
|
|
3081
|
+
_context27.next = 13;
|
|
2637
3082
|
break;
|
|
2638
3083
|
}
|
|
2639
|
-
|
|
3084
|
+
_context27.next = 9;
|
|
2640
3085
|
return this.store.order.recalculateSummary({
|
|
2641
3086
|
createIfMissing: true
|
|
2642
3087
|
});
|
|
2643
3088
|
case 9:
|
|
2644
3089
|
this.store.order.persistTempOrder();
|
|
2645
3090
|
tempOrder = this.store.order.ensureTempOrder();
|
|
2646
|
-
|
|
3091
|
+
_context27.next = 13;
|
|
2647
3092
|
return this.effectsEmit('onDiscountApplied', {
|
|
2648
3093
|
productList: tempOrder.products || [],
|
|
2649
3094
|
discountList: this.store.order.getDiscountList(),
|
|
@@ -2651,7 +3096,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2651
3096
|
tempOrder: tempOrder
|
|
2652
3097
|
});
|
|
2653
3098
|
case 13:
|
|
2654
|
-
return
|
|
3099
|
+
return _context27.abrupt("return", _objectSpread(_objectSpread({
|
|
2655
3100
|
isAvailable: raw.isAvailable
|
|
2656
3101
|
}, raw.isAccepted !== undefined ? {
|
|
2657
3102
|
isAccepted: raw.isAccepted
|
|
@@ -2661,16 +3106,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2661
3106
|
scannedDiscountList: raw.scannedDiscountList
|
|
2662
3107
|
}));
|
|
2663
3108
|
case 16:
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
throw
|
|
3109
|
+
_context27.prev = 16;
|
|
3110
|
+
_context27.t0 = _context27["catch"](0);
|
|
3111
|
+
throw _context27.t0;
|
|
2667
3112
|
case 19:
|
|
2668
3113
|
case "end":
|
|
2669
|
-
return
|
|
3114
|
+
return _context27.stop();
|
|
2670
3115
|
}
|
|
2671
|
-
},
|
|
3116
|
+
}, _callee27, this, [[0, 16]]);
|
|
2672
3117
|
}));
|
|
2673
|
-
function scanPromotionCode(
|
|
3118
|
+
function scanPromotionCode(_x20, _x21) {
|
|
2674
3119
|
return _scanPromotionCode.apply(this, arguments);
|
|
2675
3120
|
}
|
|
2676
3121
|
return scanPromotionCode;
|
|
@@ -2678,14 +3123,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2678
3123
|
}, {
|
|
2679
3124
|
key: "setDiscountSelected",
|
|
2680
3125
|
value: function () {
|
|
2681
|
-
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3126
|
+
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
|
|
2682
3127
|
var list, updated, tempOrder, orderStore, discountModule, rulesModule, nextDiscountList, _orderStore$summary3, orderTotalAmount, result, beforeSelectedIds, _iterator4, _step4, d, selectedResourceIds, filterSelectedDiscountDetails, _iterator5, _step5, _product$metadata8, _tempOrder$_extend4, _product$metadata$sou2, _product$metadata9, _product$metadata10, _product$original_pri2, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
|
|
2683
|
-
return _regeneratorRuntime().wrap(function
|
|
2684
|
-
while (1) switch (
|
|
3128
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
3129
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
2685
3130
|
case 0:
|
|
2686
|
-
|
|
3131
|
+
_context28.prev = 0;
|
|
2687
3132
|
if (this.store.order) {
|
|
2688
|
-
|
|
3133
|
+
_context28.next = 3;
|
|
2689
3134
|
break;
|
|
2690
3135
|
}
|
|
2691
3136
|
throw new Error('order 模块未初始化');
|
|
@@ -2703,7 +3148,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2703
3148
|
discountModule = orderStore.discount;
|
|
2704
3149
|
rulesModule = orderStore.rules;
|
|
2705
3150
|
nextDiscountList = updated;
|
|
2706
|
-
|
|
3151
|
+
_context28.next = 13;
|
|
2707
3152
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(updated);
|
|
2708
3153
|
case 13:
|
|
2709
3154
|
if (rulesModule) {
|
|
@@ -2765,29 +3210,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2765
3210
|
});
|
|
2766
3211
|
};
|
|
2767
3212
|
_iterator5 = _createForOfIteratorHelper(tempOrder.products);
|
|
2768
|
-
|
|
3213
|
+
_context28.prev = 17;
|
|
2769
3214
|
_iterator5.s();
|
|
2770
3215
|
case 19:
|
|
2771
3216
|
if ((_step5 = _iterator5.n()).done) {
|
|
2772
|
-
|
|
3217
|
+
_context28.next = 36;
|
|
2773
3218
|
break;
|
|
2774
3219
|
}
|
|
2775
3220
|
product = _step5.value;
|
|
2776
3221
|
productUid = (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.unique_identification_number;
|
|
2777
3222
|
runtimeOrigin = productUid ? (_tempOrder$_extend4 = tempOrder._extend) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4.productsByUid) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4[productUid]) === null || _tempOrder$_extend4 === void 0 ? void 0 : _tempOrder$_extend4.origin : undefined;
|
|
2778
3223
|
if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
|
|
2779
|
-
|
|
3224
|
+
_context28.next = 25;
|
|
2780
3225
|
break;
|
|
2781
3226
|
}
|
|
2782
|
-
return
|
|
3227
|
+
return _context28.abrupt("continue", 34);
|
|
2783
3228
|
case 25:
|
|
2784
3229
|
product.discount_list = filterSelectedDiscountDetails(product.discount_list);
|
|
2785
3230
|
if (Array.isArray(product.product_bundle)) {
|
|
2786
3231
|
product.product_bundle = product.product_bundle.map(function (bundle) {
|
|
2787
|
-
var
|
|
3232
|
+
var _ref35, _bundle$original_pric;
|
|
2788
3233
|
var nextBundleDiscountList = filterSelectedDiscountDetails(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list);
|
|
2789
3234
|
var shouldRestoreBundlePrice = nextBundleDiscountList.length === 0;
|
|
2790
|
-
var restoredBundlePrice = (
|
|
3235
|
+
var restoredBundlePrice = (_ref35 = (_bundle$original_pric = bundle === null || bundle === void 0 ? void 0 : bundle.original_price) !== null && _bundle$original_pric !== void 0 ? _bundle$original_pric : bundle === null || bundle === void 0 ? void 0 : bundle.product_price) !== null && _ref35 !== void 0 ? _ref35 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
|
|
2791
3236
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), shouldRestoreBundlePrice ? {
|
|
2792
3237
|
price: restoredBundlePrice,
|
|
2793
3238
|
bundle_selling_price: restoredBundlePrice
|
|
@@ -2815,28 +3260,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2815
3260
|
bundle: product.product_bundle
|
|
2816
3261
|
});
|
|
2817
3262
|
case 34:
|
|
2818
|
-
|
|
3263
|
+
_context28.next = 19;
|
|
2819
3264
|
break;
|
|
2820
3265
|
case 36:
|
|
2821
|
-
|
|
3266
|
+
_context28.next = 41;
|
|
2822
3267
|
break;
|
|
2823
3268
|
case 38:
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
_iterator5.e(
|
|
3269
|
+
_context28.prev = 38;
|
|
3270
|
+
_context28.t0 = _context28["catch"](17);
|
|
3271
|
+
_iterator5.e(_context28.t0);
|
|
2827
3272
|
case 41:
|
|
2828
|
-
|
|
3273
|
+
_context28.prev = 41;
|
|
2829
3274
|
_iterator5.f();
|
|
2830
|
-
return
|
|
3275
|
+
return _context28.finish(41);
|
|
2831
3276
|
case 44:
|
|
2832
3277
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
2833
|
-
|
|
3278
|
+
_context28.next = 47;
|
|
2834
3279
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
2835
3280
|
case 47:
|
|
2836
3281
|
tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
|
|
2837
3282
|
return d.isSelected;
|
|
2838
3283
|
});
|
|
2839
|
-
|
|
3284
|
+
_context28.next = 50;
|
|
2840
3285
|
return this.store.order.recalculateSummary({
|
|
2841
3286
|
createIfMissing: true
|
|
2842
3287
|
});
|
|
@@ -2848,19 +3293,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2848
3293
|
selectedDiscountList: tempOrder.discount_list,
|
|
2849
3294
|
tempOrder: tempOrder
|
|
2850
3295
|
});
|
|
2851
|
-
|
|
3296
|
+
_context28.next = 57;
|
|
2852
3297
|
break;
|
|
2853
3298
|
case 54:
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
throw
|
|
3299
|
+
_context28.prev = 54;
|
|
3300
|
+
_context28.t1 = _context28["catch"](0);
|
|
3301
|
+
throw _context28.t1;
|
|
2857
3302
|
case 57:
|
|
2858
3303
|
case "end":
|
|
2859
|
-
return
|
|
3304
|
+
return _context28.stop();
|
|
2860
3305
|
}
|
|
2861
|
-
},
|
|
3306
|
+
}, _callee28, this, [[0, 54], [17, 38, 41, 44]]);
|
|
2862
3307
|
}));
|
|
2863
|
-
function setDiscountSelected(
|
|
3308
|
+
function setDiscountSelected(_x22) {
|
|
2864
3309
|
return _setDiscountSelected.apply(this, arguments);
|
|
2865
3310
|
}
|
|
2866
3311
|
return setDiscountSelected;
|
|
@@ -2868,23 +3313,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2868
3313
|
}, {
|
|
2869
3314
|
key: "applyDiscountCalculationResult",
|
|
2870
3315
|
value: function () {
|
|
2871
|
-
var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3316
|
+
var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(result) {
|
|
2872
3317
|
var tempOrder, orderStore, discountModule;
|
|
2873
|
-
return _regeneratorRuntime().wrap(function
|
|
2874
|
-
while (1) switch (
|
|
3318
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
3319
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
2875
3320
|
case 0:
|
|
2876
|
-
|
|
3321
|
+
_context29.prev = 0;
|
|
2877
3322
|
if (this.store.order) {
|
|
2878
|
-
|
|
3323
|
+
_context29.next = 3;
|
|
2879
3324
|
break;
|
|
2880
3325
|
}
|
|
2881
3326
|
throw new Error('order 模块未初始化');
|
|
2882
3327
|
case 3:
|
|
2883
3328
|
if (result) {
|
|
2884
|
-
|
|
3329
|
+
_context29.next = 5;
|
|
2885
3330
|
break;
|
|
2886
3331
|
}
|
|
2887
|
-
return
|
|
3332
|
+
return _context29.abrupt("return");
|
|
2888
3333
|
case 5:
|
|
2889
3334
|
tempOrder = this.store.order.ensureTempOrder();
|
|
2890
3335
|
orderStore = this.store.order.store || {};
|
|
@@ -2893,24 +3338,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2893
3338
|
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
2894
3339
|
}
|
|
2895
3340
|
if (!result.discountList) {
|
|
2896
|
-
|
|
3341
|
+
_context29.next = 14;
|
|
2897
3342
|
break;
|
|
2898
3343
|
}
|
|
2899
3344
|
OrderModule.populateSavedAmounts(tempOrder.products, result.discountList);
|
|
2900
|
-
|
|
3345
|
+
_context29.next = 13;
|
|
2901
3346
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(result.discountList);
|
|
2902
3347
|
case 13:
|
|
2903
3348
|
tempOrder.discount_list = result.discountList.filter(function (discount) {
|
|
2904
3349
|
return discount.isSelected;
|
|
2905
3350
|
});
|
|
2906
3351
|
case 14:
|
|
2907
|
-
|
|
3352
|
+
_context29.next = 16;
|
|
2908
3353
|
return this.store.order.recalculateSummary({
|
|
2909
3354
|
createIfMissing: true
|
|
2910
3355
|
});
|
|
2911
3356
|
case 16:
|
|
2912
3357
|
this.store.order.persistTempOrder();
|
|
2913
|
-
|
|
3358
|
+
_context29.next = 19;
|
|
2914
3359
|
return this.effectsEmit('onDiscountApplied', {
|
|
2915
3360
|
productList: tempOrder.products || [],
|
|
2916
3361
|
discountList: result.discountList || [],
|
|
@@ -2918,19 +3363,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2918
3363
|
tempOrder: tempOrder
|
|
2919
3364
|
});
|
|
2920
3365
|
case 19:
|
|
2921
|
-
|
|
3366
|
+
_context29.next = 24;
|
|
2922
3367
|
break;
|
|
2923
3368
|
case 21:
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
throw
|
|
3369
|
+
_context29.prev = 21;
|
|
3370
|
+
_context29.t0 = _context29["catch"](0);
|
|
3371
|
+
throw _context29.t0;
|
|
2927
3372
|
case 24:
|
|
2928
3373
|
case "end":
|
|
2929
|
-
return
|
|
3374
|
+
return _context29.stop();
|
|
2930
3375
|
}
|
|
2931
|
-
},
|
|
3376
|
+
}, _callee29, this, [[0, 21]]);
|
|
2932
3377
|
}));
|
|
2933
|
-
function applyDiscountCalculationResult(
|
|
3378
|
+
function applyDiscountCalculationResult(_x23) {
|
|
2934
3379
|
return _applyDiscountCalculationResult.apply(this, arguments);
|
|
2935
3380
|
}
|
|
2936
3381
|
return applyDiscountCalculationResult;
|
|
@@ -2938,18 +3383,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2938
3383
|
}, {
|
|
2939
3384
|
key: "submitScanOrder",
|
|
2940
3385
|
value: function () {
|
|
2941
|
-
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2942
|
-
return _regeneratorRuntime().wrap(function
|
|
2943
|
-
while (1) switch (
|
|
3386
|
+
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
|
|
3387
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
3388
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
2944
3389
|
case 0:
|
|
2945
|
-
return
|
|
3390
|
+
return _context30.abrupt("return", this.submitSalesOrder(params));
|
|
2946
3391
|
case 1:
|
|
2947
3392
|
case "end":
|
|
2948
|
-
return
|
|
3393
|
+
return _context30.stop();
|
|
2949
3394
|
}
|
|
2950
|
-
},
|
|
3395
|
+
}, _callee30, this);
|
|
2951
3396
|
}));
|
|
2952
|
-
function submitScanOrder(
|
|
3397
|
+
function submitScanOrder(_x24) {
|
|
2953
3398
|
return _submitScanOrder.apply(this, arguments);
|
|
2954
3399
|
}
|
|
2955
3400
|
return submitScanOrder;
|
|
@@ -2963,14 +3408,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2963
3408
|
}, {
|
|
2964
3409
|
key: "submitSalesOrder",
|
|
2965
3410
|
value: (function () {
|
|
2966
|
-
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3411
|
+
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
|
|
2967
3412
|
var _params$smallTicketDa, _this$otherParams13, _this$otherParams14, _this$otherParams15, _this$otherParams16;
|
|
2968
3413
|
var inferredPaymentStatus, smallTicketDataFlag, enhancePayload, submitParams;
|
|
2969
|
-
return _regeneratorRuntime().wrap(function
|
|
2970
|
-
while (1) switch (
|
|
3414
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
3415
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
2971
3416
|
case 0:
|
|
2972
3417
|
if (this.store.order) {
|
|
2973
|
-
|
|
3418
|
+
_context31.next = 2;
|
|
2974
3419
|
break;
|
|
2975
3420
|
}
|
|
2976
3421
|
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
@@ -2997,14 +3442,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2997
3442
|
} : {}), enhancePayload !== undefined ? {
|
|
2998
3443
|
enhancePayload: enhancePayload
|
|
2999
3444
|
} : {});
|
|
3000
|
-
return
|
|
3445
|
+
return _context31.abrupt("return", this.shouldUseCheckoutSyncTask() ? this.store.order.submitTempOrder(submitParams) : this.store.order.submitTempOrderAsync(submitParams));
|
|
3001
3446
|
case 7:
|
|
3002
3447
|
case "end":
|
|
3003
|
-
return
|
|
3448
|
+
return _context31.stop();
|
|
3004
3449
|
}
|
|
3005
|
-
},
|
|
3450
|
+
}, _callee31, this);
|
|
3006
3451
|
}));
|
|
3007
|
-
function submitSalesOrder(
|
|
3452
|
+
function submitSalesOrder(_x25) {
|
|
3008
3453
|
return _submitSalesOrder.apply(this, arguments);
|
|
3009
3454
|
}
|
|
3010
3455
|
return submitSalesOrder;
|
|
@@ -3012,18 +3457,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3012
3457
|
}, {
|
|
3013
3458
|
key: "saveSalesOrderDraft",
|
|
3014
3459
|
value: function () {
|
|
3015
|
-
var _saveSalesOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3460
|
+
var _saveSalesOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
|
|
3016
3461
|
var _params$platform, _this$otherParams17, _this$otherParams18, _this$otherParams19, _params$channel, _params$type, _this$otherParams20;
|
|
3017
|
-
return _regeneratorRuntime().wrap(function
|
|
3018
|
-
while (1) switch (
|
|
3462
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
3463
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
3019
3464
|
case 0:
|
|
3020
3465
|
if (this.store.order) {
|
|
3021
|
-
|
|
3466
|
+
_context32.next = 2;
|
|
3022
3467
|
break;
|
|
3023
3468
|
}
|
|
3024
3469
|
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
3025
3470
|
case 2:
|
|
3026
|
-
return
|
|
3471
|
+
return _context32.abrupt("return", this.store.order.saveTempOrderAsDraft(_objectSpread({
|
|
3027
3472
|
cacheId: this.cacheId,
|
|
3028
3473
|
platform: (_params$platform = params === null || params === void 0 ? void 0 : params.platform) !== null && _params$platform !== void 0 ? _params$platform : (_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.platform,
|
|
3029
3474
|
businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.businessCode) || ((_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.business_code),
|
|
@@ -3034,11 +3479,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3034
3479
|
} : {})));
|
|
3035
3480
|
case 3:
|
|
3036
3481
|
case "end":
|
|
3037
|
-
return
|
|
3482
|
+
return _context32.stop();
|
|
3038
3483
|
}
|
|
3039
|
-
},
|
|
3484
|
+
}, _callee32, this);
|
|
3040
3485
|
}));
|
|
3041
|
-
function saveSalesOrderDraft(
|
|
3486
|
+
function saveSalesOrderDraft(_x26) {
|
|
3042
3487
|
return _saveSalesOrderDraft.apply(this, arguments);
|
|
3043
3488
|
}
|
|
3044
3489
|
return saveSalesOrderDraft;
|
|
@@ -3046,14 +3491,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3046
3491
|
}, {
|
|
3047
3492
|
key: "submitTempOrderAsync",
|
|
3048
3493
|
value: function () {
|
|
3049
|
-
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3494
|
+
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
|
|
3050
3495
|
var _params$smallTicketDa2, _this$otherParams21, _this$otherParams22, _this$otherParams23, _this$otherParams24;
|
|
3051
3496
|
var inferredPaymentStatus, smallTicketDataFlag, enhancePayload, submitParams;
|
|
3052
|
-
return _regeneratorRuntime().wrap(function
|
|
3053
|
-
while (1) switch (
|
|
3497
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
3498
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
3054
3499
|
case 0:
|
|
3055
3500
|
if (this.store.order) {
|
|
3056
|
-
|
|
3501
|
+
_context33.next = 2;
|
|
3057
3502
|
break;
|
|
3058
3503
|
}
|
|
3059
3504
|
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
@@ -3079,14 +3524,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3079
3524
|
} : {}), enhancePayload !== undefined ? {
|
|
3080
3525
|
enhancePayload: enhancePayload
|
|
3081
3526
|
} : {});
|
|
3082
|
-
return
|
|
3527
|
+
return _context33.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
|
|
3083
3528
|
case 7:
|
|
3084
3529
|
case "end":
|
|
3085
|
-
return
|
|
3530
|
+
return _context33.stop();
|
|
3086
3531
|
}
|
|
3087
|
-
},
|
|
3532
|
+
}, _callee33, this);
|
|
3088
3533
|
}));
|
|
3089
|
-
function submitTempOrderAsync(
|
|
3534
|
+
function submitTempOrderAsync(_x27) {
|
|
3090
3535
|
return _submitTempOrderAsync.apply(this, arguments);
|
|
3091
3536
|
}
|
|
3092
3537
|
return submitTempOrderAsync;
|
|
@@ -3112,14 +3557,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3112
3557
|
}, {
|
|
3113
3558
|
key: "printLocalOrderReceipt",
|
|
3114
3559
|
value: function () {
|
|
3115
|
-
var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3560
|
+
var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(lookup) {
|
|
3116
3561
|
var _this$otherParams26, _this$otherParams27, _this$otherParams28, _this$otherParams29;
|
|
3117
3562
|
var hasLookup, lookupPayload, context, payload, response, _this$store$order$app, _this$store$order5, _data;
|
|
3118
|
-
return _regeneratorRuntime().wrap(function
|
|
3119
|
-
while (1) switch (
|
|
3563
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
3564
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
3120
3565
|
case 0:
|
|
3121
3566
|
if (this.store.order) {
|
|
3122
|
-
|
|
3567
|
+
_context34.next = 2;
|
|
3123
3568
|
break;
|
|
3124
3569
|
}
|
|
3125
3570
|
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
@@ -3150,28 +3595,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3150
3595
|
channel: context.channel,
|
|
3151
3596
|
type: context.type
|
|
3152
3597
|
});
|
|
3153
|
-
|
|
3598
|
+
_context34.next = 8;
|
|
3154
3599
|
return this.request.post('/local/print-order', payload, {
|
|
3155
3600
|
osServer: true,
|
|
3156
3601
|
customToast: function customToast() {}
|
|
3157
3602
|
});
|
|
3158
3603
|
case 8:
|
|
3159
|
-
response =
|
|
3604
|
+
response = _context34.sent;
|
|
3160
3605
|
if (hasLookup) {
|
|
3161
|
-
|
|
3606
|
+
_context34.next = 12;
|
|
3162
3607
|
break;
|
|
3163
3608
|
}
|
|
3164
|
-
|
|
3609
|
+
_context34.next = 12;
|
|
3165
3610
|
return (_this$store$order$app = (_this$store$order5 = this.store.order).applyLocalPrintOrderNumbers) === null || _this$store$order$app === void 0 ? void 0 : _this$store$order$app.call(_this$store$order5, response === null || response === void 0 || (_data = response.data) === null || _data === void 0 ? void 0 : _data.order);
|
|
3166
3611
|
case 12:
|
|
3167
|
-
return
|
|
3612
|
+
return _context34.abrupt("return", response);
|
|
3168
3613
|
case 13:
|
|
3169
3614
|
case "end":
|
|
3170
|
-
return
|
|
3615
|
+
return _context34.stop();
|
|
3171
3616
|
}
|
|
3172
|
-
},
|
|
3617
|
+
}, _callee34, this);
|
|
3173
3618
|
}));
|
|
3174
|
-
function printLocalOrderReceipt(
|
|
3619
|
+
function printLocalOrderReceipt(_x28) {
|
|
3175
3620
|
return _printLocalOrderReceipt.apply(this, arguments);
|
|
3176
3621
|
}
|
|
3177
3622
|
return printLocalOrderReceipt;
|
|
@@ -3192,19 +3637,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3192
3637
|
}, {
|
|
3193
3638
|
key: "syncPaymentsToOrder",
|
|
3194
3639
|
value: function () {
|
|
3195
|
-
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3196
|
-
var
|
|
3640
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
|
|
3641
|
+
var _ref36, _params$businessCode, _this$otherParams30, _this$otherParams31, _params$channel2;
|
|
3197
3642
|
var businessCode, channel, enhancePayload, syncParams, syncState, payments, syncResult, latestPayments, amountSnapshot, orderSnapshot, syncPayload;
|
|
3198
|
-
return _regeneratorRuntime().wrap(function
|
|
3199
|
-
while (1) switch (
|
|
3643
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
3644
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
3200
3645
|
case 0:
|
|
3201
3646
|
if (this.store.order) {
|
|
3202
|
-
|
|
3647
|
+
_context35.next = 2;
|
|
3203
3648
|
break;
|
|
3204
3649
|
}
|
|
3205
3650
|
throw new Error('order 模块未初始化');
|
|
3206
3651
|
case 2:
|
|
3207
|
-
businessCode = (
|
|
3652
|
+
businessCode = (_ref36 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams30 = this.otherParams) === null || _this$otherParams30 === void 0 ? void 0 : _this$otherParams30.businessCode) !== null && _ref36 !== void 0 ? _ref36 : (_this$otherParams31 = this.otherParams) === null || _this$otherParams31 === void 0 ? void 0 : _this$otherParams31.business_code;
|
|
3208
3653
|
channel = (_params$channel2 = params.channel) !== null && _params$channel2 !== void 0 ? _params$channel2 : this.getSubmitOrderSalesChannel();
|
|
3209
3654
|
enhancePayload = this.buildSubmitPayloadEnhancerWithFulfillmentRefMode(params.enhancePayload);
|
|
3210
3655
|
syncParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, params), {}, {
|
|
@@ -3218,14 +3663,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3218
3663
|
} : {});
|
|
3219
3664
|
syncState = this.store.order.getOrderSyncState();
|
|
3220
3665
|
if (!(params.submitWhenPaid && syncState === 'submitting')) {
|
|
3221
|
-
|
|
3666
|
+
_context35.next = 10;
|
|
3222
3667
|
break;
|
|
3223
3668
|
}
|
|
3224
3669
|
this.queueLatestAutoPaymentSync();
|
|
3225
|
-
return
|
|
3670
|
+
return _context35.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
|
|
3226
3671
|
case 10:
|
|
3227
3672
|
payments = params.payments || [];
|
|
3228
|
-
|
|
3673
|
+
_context35.next = 13;
|
|
3229
3674
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncStart, {
|
|
3230
3675
|
payments: payments,
|
|
3231
3676
|
params: syncParams,
|
|
@@ -3233,11 +3678,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3233
3678
|
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
3234
3679
|
});
|
|
3235
3680
|
case 13:
|
|
3236
|
-
|
|
3237
|
-
|
|
3681
|
+
_context35.prev = 13;
|
|
3682
|
+
_context35.next = 16;
|
|
3238
3683
|
return this.store.order.syncPaymentsToOrder(syncParams);
|
|
3239
3684
|
case 16:
|
|
3240
|
-
syncResult =
|
|
3685
|
+
syncResult = _context35.sent;
|
|
3241
3686
|
latestPayments = this.store.order.getOrderPayments();
|
|
3242
3687
|
amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
3243
3688
|
orderSnapshot = this.store.order.getOrderSnapshot();
|
|
@@ -3255,25 +3700,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3255
3700
|
depositAmount: syncResult.depositAmount,
|
|
3256
3701
|
orderExpectedAmount: syncResult.orderExpectedAmount
|
|
3257
3702
|
};
|
|
3258
|
-
|
|
3703
|
+
_context35.next = 23;
|
|
3259
3704
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, syncPayload);
|
|
3260
3705
|
case 23:
|
|
3261
3706
|
if (!(syncResult.isDepositFullyPaid && !syncResult.isOrderFullyPaid)) {
|
|
3262
|
-
|
|
3707
|
+
_context35.next = 26;
|
|
3263
3708
|
break;
|
|
3264
3709
|
}
|
|
3265
|
-
|
|
3710
|
+
_context35.next = 26;
|
|
3266
3711
|
return this.effectsEmit(BaseSalesHookNames.onDepositPaymentSyncEnd, syncPayload);
|
|
3267
3712
|
case 26:
|
|
3268
3713
|
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
3269
|
-
return
|
|
3714
|
+
return _context35.abrupt("return", syncResult);
|
|
3270
3715
|
case 30:
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3716
|
+
_context35.prev = 30;
|
|
3717
|
+
_context35.t0 = _context35["catch"](13);
|
|
3718
|
+
_context35.next = 34;
|
|
3274
3719
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
|
|
3275
3720
|
ok: false,
|
|
3276
|
-
error:
|
|
3721
|
+
error: _context35.t0,
|
|
3277
3722
|
payments: this.store.order.getOrderPayments(),
|
|
3278
3723
|
params: syncParams,
|
|
3279
3724
|
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
@@ -3281,14 +3726,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3281
3726
|
});
|
|
3282
3727
|
case 34:
|
|
3283
3728
|
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
3284
|
-
throw
|
|
3729
|
+
throw _context35.t0;
|
|
3285
3730
|
case 36:
|
|
3286
3731
|
case "end":
|
|
3287
|
-
return
|
|
3732
|
+
return _context35.stop();
|
|
3288
3733
|
}
|
|
3289
|
-
},
|
|
3734
|
+
}, _callee35, this, [[13, 30]]);
|
|
3290
3735
|
}));
|
|
3291
|
-
function syncPaymentsToOrder(
|
|
3736
|
+
function syncPaymentsToOrder(_x29) {
|
|
3292
3737
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
3293
3738
|
}
|
|
3294
3739
|
return syncPaymentsToOrder;
|
|
@@ -3325,58 +3770,58 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3325
3770
|
}, {
|
|
3326
3771
|
key: "scheduleQueuedAutoPaymentSyncFlush",
|
|
3327
3772
|
value: function scheduleQueuedAutoPaymentSyncFlush() {
|
|
3328
|
-
var
|
|
3773
|
+
var _this15 = this;
|
|
3329
3774
|
var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;
|
|
3330
3775
|
if (!this.queuedAutoPaymentSync) return;
|
|
3331
3776
|
if (this.autoPaymentSyncTimer) return;
|
|
3332
3777
|
this.autoPaymentSyncTimer = setTimeout(function () {
|
|
3333
|
-
|
|
3334
|
-
void
|
|
3778
|
+
_this15.autoPaymentSyncTimer = null;
|
|
3779
|
+
void _this15.flushQueuedAutoPaymentSync();
|
|
3335
3780
|
}, delay);
|
|
3336
3781
|
}
|
|
3337
3782
|
}, {
|
|
3338
3783
|
key: "flushQueuedAutoPaymentSync",
|
|
3339
3784
|
value: function () {
|
|
3340
|
-
var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3785
|
+
var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {
|
|
3341
3786
|
var payments;
|
|
3342
|
-
return _regeneratorRuntime().wrap(function
|
|
3343
|
-
while (1) switch (
|
|
3787
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
3788
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
3344
3789
|
case 0:
|
|
3345
3790
|
if (this.store.order) {
|
|
3346
|
-
|
|
3791
|
+
_context36.next = 2;
|
|
3347
3792
|
break;
|
|
3348
3793
|
}
|
|
3349
|
-
return
|
|
3794
|
+
return _context36.abrupt("return");
|
|
3350
3795
|
case 2:
|
|
3351
3796
|
if (!(!this.queuedAutoPaymentSync || this.autoPaymentSyncFlushing)) {
|
|
3352
|
-
|
|
3797
|
+
_context36.next = 4;
|
|
3353
3798
|
break;
|
|
3354
3799
|
}
|
|
3355
|
-
return
|
|
3800
|
+
return _context36.abrupt("return");
|
|
3356
3801
|
case 4:
|
|
3357
3802
|
if (!(this.store.order.getOrderSyncState() === 'submitting')) {
|
|
3358
|
-
|
|
3803
|
+
_context36.next = 7;
|
|
3359
3804
|
break;
|
|
3360
3805
|
}
|
|
3361
3806
|
this.scheduleQueuedAutoPaymentSyncFlush();
|
|
3362
|
-
return
|
|
3807
|
+
return _context36.abrupt("return");
|
|
3363
3808
|
case 7:
|
|
3364
3809
|
this.autoPaymentSyncFlushing = true;
|
|
3365
|
-
|
|
3810
|
+
_context36.prev = 8;
|
|
3366
3811
|
case 9:
|
|
3367
3812
|
if (!this.queuedAutoPaymentSync) {
|
|
3368
|
-
|
|
3813
|
+
_context36.next = 18;
|
|
3369
3814
|
break;
|
|
3370
3815
|
}
|
|
3371
3816
|
this.queuedAutoPaymentSync = false;
|
|
3372
3817
|
payments = this.store.order.getOrderPayments();
|
|
3373
3818
|
if (payments.length) {
|
|
3374
|
-
|
|
3819
|
+
_context36.next = 14;
|
|
3375
3820
|
break;
|
|
3376
3821
|
}
|
|
3377
|
-
return
|
|
3822
|
+
return _context36.abrupt("continue", 9);
|
|
3378
3823
|
case 14:
|
|
3379
|
-
|
|
3824
|
+
_context36.next = 16;
|
|
3380
3825
|
return this.syncPaymentsToOrder({
|
|
3381
3826
|
payments: payments,
|
|
3382
3827
|
paymentStatus: this.getPaymentStatusForSync(payments),
|
|
@@ -3384,29 +3829,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3384
3829
|
smallTicketDataFlag: 1
|
|
3385
3830
|
});
|
|
3386
3831
|
case 16:
|
|
3387
|
-
|
|
3832
|
+
_context36.next = 9;
|
|
3388
3833
|
break;
|
|
3389
3834
|
case 18:
|
|
3390
|
-
|
|
3835
|
+
_context36.next = 23;
|
|
3391
3836
|
break;
|
|
3392
3837
|
case 20:
|
|
3393
|
-
|
|
3394
|
-
|
|
3838
|
+
_context36.prev = 20;
|
|
3839
|
+
_context36.t0 = _context36["catch"](8);
|
|
3395
3840
|
this.logError('queued auto sync payments failed', {
|
|
3396
|
-
error:
|
|
3841
|
+
error: _context36.t0 instanceof Error ? _context36.t0.message : String(_context36.t0)
|
|
3397
3842
|
});
|
|
3398
3843
|
case 23:
|
|
3399
|
-
|
|
3844
|
+
_context36.prev = 23;
|
|
3400
3845
|
this.autoPaymentSyncFlushing = false;
|
|
3401
3846
|
if (this.queuedAutoPaymentSync) {
|
|
3402
3847
|
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
3403
3848
|
}
|
|
3404
|
-
return
|
|
3849
|
+
return _context36.finish(23);
|
|
3405
3850
|
case 27:
|
|
3406
3851
|
case "end":
|
|
3407
|
-
return
|
|
3852
|
+
return _context36.stop();
|
|
3408
3853
|
}
|
|
3409
|
-
},
|
|
3854
|
+
}, _callee36, this, [[8, 20, 23, 27]]);
|
|
3410
3855
|
}));
|
|
3411
3856
|
function flushQueuedAutoPaymentSync() {
|
|
3412
3857
|
return _flushQueuedAutoPaymentSync.apply(this, arguments);
|
|
@@ -3430,35 +3875,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3430
3875
|
}, {
|
|
3431
3876
|
key: "addOrderPaymentAsync",
|
|
3432
3877
|
value: (function () {
|
|
3433
|
-
var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3878
|
+
var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(payment) {
|
|
3434
3879
|
var paymentRecord, hasPaymentNumber, devicePrefix;
|
|
3435
|
-
return _regeneratorRuntime().wrap(function
|
|
3436
|
-
while (1) switch (
|
|
3880
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
3881
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
3437
3882
|
case 0:
|
|
3438
3883
|
paymentRecord = payment;
|
|
3439
3884
|
hasPaymentNumber = String(paymentRecord.payment_number || '').trim() !== '';
|
|
3440
3885
|
if (!hasPaymentNumber) {
|
|
3441
|
-
|
|
3886
|
+
_context37.next = 6;
|
|
3442
3887
|
break;
|
|
3443
3888
|
}
|
|
3444
|
-
|
|
3445
|
-
|
|
3889
|
+
_context37.t0 = 'LOCAL';
|
|
3890
|
+
_context37.next = 9;
|
|
3446
3891
|
break;
|
|
3447
3892
|
case 6:
|
|
3448
|
-
|
|
3893
|
+
_context37.next = 8;
|
|
3449
3894
|
return this.getPaymentNumberDevicePrefixAsync();
|
|
3450
3895
|
case 8:
|
|
3451
|
-
|
|
3896
|
+
_context37.t0 = _context37.sent;
|
|
3452
3897
|
case 9:
|
|
3453
|
-
devicePrefix =
|
|
3454
|
-
return
|
|
3898
|
+
devicePrefix = _context37.t0;
|
|
3899
|
+
return _context37.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
|
|
3455
3900
|
case 11:
|
|
3456
3901
|
case "end":
|
|
3457
|
-
return
|
|
3902
|
+
return _context37.stop();
|
|
3458
3903
|
}
|
|
3459
|
-
},
|
|
3904
|
+
}, _callee37, this);
|
|
3460
3905
|
}));
|
|
3461
|
-
function addOrderPaymentAsync(
|
|
3906
|
+
function addOrderPaymentAsync(_x30) {
|
|
3462
3907
|
return _addOrderPaymentAsync.apply(this, arguments);
|
|
3463
3908
|
}
|
|
3464
3909
|
return addOrderPaymentAsync;
|
|
@@ -3469,9 +3914,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3469
3914
|
var _this$otherParams32,
|
|
3470
3915
|
_paymentRecord$paymen,
|
|
3471
3916
|
_paymentRecord$create,
|
|
3472
|
-
|
|
3917
|
+
_ref37,
|
|
3473
3918
|
_paymentRecord$origin,
|
|
3474
|
-
|
|
3919
|
+
_this16 = this;
|
|
3475
3920
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
3476
3921
|
var paymentRecord = payment;
|
|
3477
3922
|
var paymentAmount = new Decimal(paymentRecord.amount || 0);
|
|
@@ -3491,7 +3936,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3491
3936
|
var paymentTime = (_paymentRecord$paymen = paymentRecord.payment_time) !== null && _paymentRecord$paymen !== void 0 ? _paymentRecord$paymen : paymentTimestamp;
|
|
3492
3937
|
var createdAt = (_paymentRecord$create = paymentRecord.created_at) !== null && _paymentRecord$create !== void 0 ? _paymentRecord$create : paymentTimestamp;
|
|
3493
3938
|
var serviceCharge = paymentRecord.service_charge && _typeof(paymentRecord.service_charge) === 'object' ? paymentRecord.service_charge : null;
|
|
3494
|
-
var calculatedServiceFee = serviceCharge ? new Decimal((
|
|
3939
|
+
var calculatedServiceFee = serviceCharge ? new Decimal((_ref37 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref37 !== void 0 ? _ref37 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
|
|
3495
3940
|
var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({}, normalizedPaymentRecord), calculatedServiceFee !== undefined ? {
|
|
3496
3941
|
service_fee: calculatedServiceFee
|
|
3497
3942
|
} : {}), {}, {
|
|
@@ -3515,7 +3960,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3515
3960
|
submitWhenPaid: true,
|
|
3516
3961
|
smallTicketDataFlag: 1
|
|
3517
3962
|
}).catch(function (error) {
|
|
3518
|
-
|
|
3963
|
+
_this16.logError('auto sync payments failed', {
|
|
3519
3964
|
error: error instanceof Error ? error.message : String(error)
|
|
3520
3965
|
});
|
|
3521
3966
|
});
|
|
@@ -3527,7 +3972,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3527
3972
|
}, {
|
|
3528
3973
|
key: "updateOrderPayment",
|
|
3529
3974
|
value: (function () {
|
|
3530
|
-
var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3975
|
+
var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(paymentIdentity, updates) {
|
|
3531
3976
|
var _result$payment, _result$payment2;
|
|
3532
3977
|
var options,
|
|
3533
3978
|
matchMode,
|
|
@@ -3544,13 +3989,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3544
3989
|
shouldSubmit,
|
|
3545
3990
|
syncResult,
|
|
3546
3991
|
_options$smallTicketD2,
|
|
3547
|
-
|
|
3548
|
-
return _regeneratorRuntime().wrap(function
|
|
3549
|
-
while (1) switch (
|
|
3992
|
+
_args38 = arguments;
|
|
3993
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
3994
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
3550
3995
|
case 0:
|
|
3551
|
-
options =
|
|
3996
|
+
options = _args38.length > 2 && _args38[2] !== undefined ? _args38[2] : {};
|
|
3552
3997
|
if (this.store.order) {
|
|
3553
|
-
|
|
3998
|
+
_context38.next = 3;
|
|
3554
3999
|
break;
|
|
3555
4000
|
}
|
|
3556
4001
|
throw new Error('order 模块未初始化');
|
|
@@ -3559,15 +4004,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3559
4004
|
previousMatch = resolveOrderPaymentIdentity(this.store.order.getOrderPayments(), paymentIdentity, matchMode);
|
|
3560
4005
|
previousPayment = previousMatch === null || previousMatch === void 0 ? void 0 : previousMatch.payment;
|
|
3561
4006
|
if (!((previousPayment === null || previousPayment === void 0 ? void 0 : previousPayment.status) === 'paid' && !options.applyUpdatesWhenPaid)) {
|
|
3562
|
-
|
|
4007
|
+
_context38.next = 13;
|
|
3563
4008
|
break;
|
|
3564
4009
|
}
|
|
3565
4010
|
currentPayments = this.store.order.getOrderPayments();
|
|
3566
4011
|
if (!(options.submitWhenPaid && options.forceSubmitIfPaid)) {
|
|
3567
|
-
|
|
4012
|
+
_context38.next = 12;
|
|
3568
4013
|
break;
|
|
3569
4014
|
}
|
|
3570
|
-
|
|
4015
|
+
_context38.next = 11;
|
|
3571
4016
|
return this.syncPaymentsToOrder({
|
|
3572
4017
|
payments: currentPayments,
|
|
3573
4018
|
paymentStatus: this.getPaymentStatusForSync(currentPayments),
|
|
@@ -3575,9 +4020,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3575
4020
|
smallTicketDataFlag: (_options$smallTicketD = options.smallTicketDataFlag) !== null && _options$smallTicketD !== void 0 ? _options$smallTicketD : 1
|
|
3576
4021
|
});
|
|
3577
4022
|
case 11:
|
|
3578
|
-
_syncResult =
|
|
4023
|
+
_syncResult = _context38.sent;
|
|
3579
4024
|
case 12:
|
|
3580
|
-
return
|
|
4025
|
+
return _context38.abrupt("return", _objectSpread({
|
|
3581
4026
|
updated: false,
|
|
3582
4027
|
payment: previousPayment,
|
|
3583
4028
|
payments: currentPayments,
|
|
@@ -3586,44 +4031,44 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3586
4031
|
syncResult: _syncResult
|
|
3587
4032
|
} : {}));
|
|
3588
4033
|
case 13:
|
|
3589
|
-
|
|
4034
|
+
_context38.next = 15;
|
|
3590
4035
|
return this.store.order.updateOrderPayment(paymentIdentity, updates, {
|
|
3591
4036
|
matchBy: matchMode
|
|
3592
4037
|
});
|
|
3593
4038
|
case 15:
|
|
3594
|
-
result =
|
|
4039
|
+
result = _context38.sent;
|
|
3595
4040
|
if (!(options.persistDraft !== false)) {
|
|
3596
|
-
|
|
4041
|
+
_context38.next = 29;
|
|
3597
4042
|
break;
|
|
3598
4043
|
}
|
|
3599
|
-
|
|
3600
|
-
|
|
4044
|
+
_context38.prev = 17;
|
|
4045
|
+
_context38.next = 20;
|
|
3601
4046
|
return this.saveSalesOrderDraft();
|
|
3602
4047
|
case 20:
|
|
3603
|
-
draftResult =
|
|
3604
|
-
|
|
4048
|
+
draftResult = _context38.sent;
|
|
4049
|
+
_context38.next = 29;
|
|
3605
4050
|
break;
|
|
3606
4051
|
case 23:
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
draftError =
|
|
4052
|
+
_context38.prev = 23;
|
|
4053
|
+
_context38.t0 = _context38["catch"](17);
|
|
4054
|
+
draftError = _context38.t0;
|
|
3610
4055
|
this.logError('updateOrderPayment: 保存支付草稿失败', {
|
|
3611
4056
|
paymentIdentity: paymentIdentity,
|
|
3612
|
-
error:
|
|
4057
|
+
error: _context38.t0 instanceof Error ? _context38.t0.message : String(_context38.t0)
|
|
3613
4058
|
});
|
|
3614
4059
|
if (options.submitWhenPaid) {
|
|
3615
|
-
|
|
4060
|
+
_context38.next = 29;
|
|
3616
4061
|
break;
|
|
3617
4062
|
}
|
|
3618
|
-
throw
|
|
4063
|
+
throw _context38.t0;
|
|
3619
4064
|
case 29:
|
|
3620
4065
|
becamePaid = (previousPayment === null || previousPayment === void 0 ? void 0 : previousPayment.status) !== 'paid' && ((_result$payment = result.payment) === null || _result$payment === void 0 ? void 0 : _result$payment.status) === 'paid';
|
|
3621
4066
|
shouldSubmit = Boolean(options.submitWhenPaid && ((_result$payment2 = result.payment) === null || _result$payment2 === void 0 ? void 0 : _result$payment2.status) === 'paid' && (becamePaid || options.forceSubmitIfPaid));
|
|
3622
4067
|
if (!shouldSubmit) {
|
|
3623
|
-
|
|
4068
|
+
_context38.next = 35;
|
|
3624
4069
|
break;
|
|
3625
4070
|
}
|
|
3626
|
-
|
|
4071
|
+
_context38.next = 34;
|
|
3627
4072
|
return this.syncPaymentsToOrder({
|
|
3628
4073
|
payments: result.payments,
|
|
3629
4074
|
paymentStatus: this.getPaymentStatusForSync(result.payments),
|
|
@@ -3631,9 +4076,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3631
4076
|
smallTicketDataFlag: (_options$smallTicketD2 = options.smallTicketDataFlag) !== null && _options$smallTicketD2 !== void 0 ? _options$smallTicketD2 : 1
|
|
3632
4077
|
});
|
|
3633
4078
|
case 34:
|
|
3634
|
-
syncResult =
|
|
4079
|
+
syncResult = _context38.sent;
|
|
3635
4080
|
case 35:
|
|
3636
|
-
return
|
|
4081
|
+
return _context38.abrupt("return", _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, result), draftResult !== undefined ? {
|
|
3637
4082
|
draftResult: draftResult
|
|
3638
4083
|
} : {}), draftError !== undefined ? {
|
|
3639
4084
|
draftError: draftError
|
|
@@ -3642,11 +4087,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3642
4087
|
} : {}));
|
|
3643
4088
|
case 36:
|
|
3644
4089
|
case "end":
|
|
3645
|
-
return
|
|
4090
|
+
return _context38.stop();
|
|
3646
4091
|
}
|
|
3647
|
-
},
|
|
4092
|
+
}, _callee38, this, [[17, 23]]);
|
|
3648
4093
|
}));
|
|
3649
|
-
function updateOrderPayment(
|
|
4094
|
+
function updateOrderPayment(_x31, _x32) {
|
|
3650
4095
|
return _updateOrderPayment.apply(this, arguments);
|
|
3651
4096
|
}
|
|
3652
4097
|
return updateOrderPayment;
|
|
@@ -3668,24 +4113,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3668
4113
|
}, {
|
|
3669
4114
|
key: "updateVoucherOrderPaymentsAsync",
|
|
3670
4115
|
value: function () {
|
|
3671
|
-
var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3672
|
-
return _regeneratorRuntime().wrap(function
|
|
3673
|
-
while (1) switch (
|
|
4116
|
+
var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(payments, options) {
|
|
4117
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
4118
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
3674
4119
|
case 0:
|
|
3675
4120
|
if (this.store.order) {
|
|
3676
|
-
|
|
4121
|
+
_context39.next = 2;
|
|
3677
4122
|
break;
|
|
3678
4123
|
}
|
|
3679
4124
|
throw new Error('order 模块未初始化');
|
|
3680
4125
|
case 2:
|
|
3681
|
-
return
|
|
4126
|
+
return _context39.abrupt("return", this.store.order.updateVoucherOrderPaymentsAsync(payments, options));
|
|
3682
4127
|
case 3:
|
|
3683
4128
|
case "end":
|
|
3684
|
-
return
|
|
4129
|
+
return _context39.stop();
|
|
3685
4130
|
}
|
|
3686
|
-
},
|
|
4131
|
+
}, _callee39, this);
|
|
3687
4132
|
}));
|
|
3688
|
-
function updateVoucherOrderPaymentsAsync(
|
|
4133
|
+
function updateVoucherOrderPaymentsAsync(_x33, _x34) {
|
|
3689
4134
|
return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
|
|
3690
4135
|
}
|
|
3691
4136
|
return updateVoucherOrderPaymentsAsync;
|
|
@@ -3719,14 +4164,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3719
4164
|
// const products = tempOrder?.products?.filter(n => n.product_id)
|
|
3720
4165
|
|
|
3721
4166
|
var walletProducts = tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products.map(function (product) {
|
|
3722
|
-
var _product$holder_id, _product$
|
|
4167
|
+
var _product$holder_id, _product$product_vari3, _product$is_charge_ta, _metadata$main_produc, _metadata$main_produc2;
|
|
3723
4168
|
var metadata = product.metadata || {};
|
|
3724
4169
|
var rawHolderId = (_product$holder_id = product.holder_id) !== null && _product$holder_id !== void 0 ? _product$holder_id : metadata.holder_id;
|
|
3725
4170
|
var holderIdValue = Array.isArray(rawHolderId) ? rawHolderId[0] : rawHolderId;
|
|
3726
4171
|
var holder_id = Number.isInteger(Number(holderIdValue)) ? Number(holderIdValue) : undefined;
|
|
3727
4172
|
return {
|
|
3728
4173
|
product_id: product.product_id || 0,
|
|
3729
|
-
product_variant_id: String((_product$
|
|
4174
|
+
product_variant_id: String((_product$product_vari3 = product.product_variant_id) !== null && _product$product_vari3 !== void 0 ? _product$product_vari3 : ''),
|
|
3730
4175
|
quantity: product.num || 1,
|
|
3731
4176
|
is_price_include_tax: tempOrder.is_price_include_tax,
|
|
3732
4177
|
is_charge_tax: (_product$is_charge_ta = product.is_charge_tax) !== null && _product$is_charge_ta !== void 0 ? _product$is_charge_ta : 0,
|
|
@@ -3772,7 +4217,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3772
4217
|
}, {
|
|
3773
4218
|
key: "buildWalletInitBusinessData",
|
|
3774
4219
|
value: function buildWalletInitBusinessData(params) {
|
|
3775
|
-
var _this$store$order8, _params$order_wait_pa,
|
|
4220
|
+
var _this$store$order8, _params$order_wait_pa, _ref38, _tempOrder$is_price_i;
|
|
3776
4221
|
var snapshot = (_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 ? void 0 : _this$store$order8.getOrderSnapshot();
|
|
3777
4222
|
var tempOrder = snapshot === null || snapshot === void 0 ? void 0 : snapshot.tempOrder;
|
|
3778
4223
|
var amount = snapshot === null || snapshot === void 0 ? void 0 : snapshot.amount;
|
|
@@ -3788,7 +4233,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3788
4233
|
},
|
|
3789
4234
|
products: this.getWalletProductList(),
|
|
3790
4235
|
order_wait_pay_amount: (_params$order_wait_pa = params === null || params === void 0 ? void 0 : params.order_wait_pay_amount) !== null && _params$order_wait_pa !== void 0 ? _params$order_wait_pa : Number(amount.amountGap || 0),
|
|
3791
|
-
is_price_include_tax: (
|
|
4236
|
+
is_price_include_tax: (_ref38 = (_tempOrder$is_price_i = tempOrder.is_price_include_tax) !== null && _tempOrder$is_price_i !== void 0 ? _tempOrder$is_price_i : this.otherParams.is_price_include_tax) !== null && _ref38 !== void 0 ? _ref38 : 1
|
|
3792
4237
|
}, snapshot.identity.orderId ? {
|
|
3793
4238
|
payment_order_id: String(snapshot.identity.orderId)
|
|
3794
4239
|
} : {});
|
|
@@ -3796,20 +4241,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3796
4241
|
}, {
|
|
3797
4242
|
key: "initWalletData",
|
|
3798
4243
|
value: function () {
|
|
3799
|
-
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4244
|
+
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
|
|
3800
4245
|
var _snapshot$identity;
|
|
3801
4246
|
var snapshot, walletBusinessData, result;
|
|
3802
|
-
return _regeneratorRuntime().wrap(function
|
|
3803
|
-
while (1) switch (
|
|
4247
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
4248
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
3804
4249
|
case 0:
|
|
3805
4250
|
if (this.store.order) {
|
|
3806
|
-
|
|
4251
|
+
_context40.next = 2;
|
|
3807
4252
|
break;
|
|
3808
4253
|
}
|
|
3809
4254
|
throw new Error('order 模块未初始化');
|
|
3810
4255
|
case 2:
|
|
3811
4256
|
if (this.store.payment) {
|
|
3812
|
-
|
|
4257
|
+
_context40.next = 4;
|
|
3813
4258
|
break;
|
|
3814
4259
|
}
|
|
3815
4260
|
throw new Error('payment 模块未初始化');
|
|
@@ -3817,10 +4262,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3817
4262
|
snapshot = this.store.order.getOrderSnapshot();
|
|
3818
4263
|
walletBusinessData = this.buildWalletInitBusinessData(params);
|
|
3819
4264
|
if (walletBusinessData) {
|
|
3820
|
-
|
|
4265
|
+
_context40.next = 8;
|
|
3821
4266
|
break;
|
|
3822
4267
|
}
|
|
3823
|
-
return
|
|
4268
|
+
return _context40.abrupt("return", {
|
|
3824
4269
|
walletRecommendList: [],
|
|
3825
4270
|
userIdentificationCodes: [],
|
|
3826
4271
|
transformList: [],
|
|
@@ -3828,11 +4273,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3828
4273
|
products: []
|
|
3829
4274
|
});
|
|
3830
4275
|
case 8:
|
|
3831
|
-
|
|
4276
|
+
_context40.next = 10;
|
|
3832
4277
|
return this.store.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
|
|
3833
4278
|
case 10:
|
|
3834
|
-
result =
|
|
3835
|
-
|
|
4279
|
+
result = _context40.sent;
|
|
4280
|
+
_context40.next = 13;
|
|
3836
4281
|
return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
|
|
3837
4282
|
orderId: snapshot === null || snapshot === void 0 || (_snapshot$identity = snapshot.identity) === null || _snapshot$identity === void 0 ? void 0 : _snapshot$identity.orderId,
|
|
3838
4283
|
customerId: walletBusinessData.customer_id,
|
|
@@ -3844,14 +4289,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3844
4289
|
timestamp: Date.now()
|
|
3845
4290
|
});
|
|
3846
4291
|
case 13:
|
|
3847
|
-
return
|
|
4292
|
+
return _context40.abrupt("return", result);
|
|
3848
4293
|
case 14:
|
|
3849
4294
|
case "end":
|
|
3850
|
-
return
|
|
4295
|
+
return _context40.stop();
|
|
3851
4296
|
}
|
|
3852
|
-
},
|
|
4297
|
+
}, _callee40, this);
|
|
3853
4298
|
}));
|
|
3854
|
-
function initWalletData(
|
|
4299
|
+
function initWalletData(_x35) {
|
|
3855
4300
|
return _initWalletData.apply(this, arguments);
|
|
3856
4301
|
}
|
|
3857
4302
|
return initWalletData;
|
|
@@ -3878,9 +4323,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3878
4323
|
var walletPassName = fundRecord.wallet_pass_name;
|
|
3879
4324
|
var title = walletPassName && _typeof(walletPassName) === 'object' ? walletPassName.default || Object.values(walletPassName)[0] : walletPassName;
|
|
3880
4325
|
var code = String((payment === null || payment === void 0 ? void 0 : payment.code) || '').toUpperCase();
|
|
3881
|
-
var tag = ((_Object$entries$find = Object.entries(WALLET_PAYMENT_CODE_BY_TAG).find(function (
|
|
3882
|
-
var
|
|
3883
|
-
paymentCode =
|
|
4326
|
+
var tag = ((_Object$entries$find = Object.entries(WALLET_PAYMENT_CODE_BY_TAG).find(function (_ref39) {
|
|
4327
|
+
var _ref40 = _slicedToArray(_ref39, 2),
|
|
4328
|
+
paymentCode = _ref40[1];
|
|
3884
4329
|
return paymentCode === code;
|
|
3885
4330
|
})) === null || _Object$entries$find === void 0 ? void 0 : _Object$entries$find[0]) || fundRecord.tag;
|
|
3886
4331
|
return {
|
|
@@ -3902,23 +4347,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3902
4347
|
}, {
|
|
3903
4348
|
key: "publishWalletAssetsState",
|
|
3904
4349
|
value: function () {
|
|
3905
|
-
var _publishWalletAssetsState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3906
|
-
return _regeneratorRuntime().wrap(function
|
|
3907
|
-
while (1) switch (
|
|
4350
|
+
var _publishWalletAssetsState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(state) {
|
|
4351
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context41) {
|
|
4352
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
3908
4353
|
case 0:
|
|
3909
|
-
|
|
4354
|
+
_context41.next = 2;
|
|
3910
4355
|
return this.effectsEmit(BaseSalesHookNames.onWalletAssetsStateChanged, {
|
|
3911
4356
|
state: state
|
|
3912
4357
|
});
|
|
3913
4358
|
case 2:
|
|
3914
|
-
return
|
|
4359
|
+
return _context41.abrupt("return", state);
|
|
3915
4360
|
case 3:
|
|
3916
4361
|
case "end":
|
|
3917
|
-
return
|
|
4362
|
+
return _context41.stop();
|
|
3918
4363
|
}
|
|
3919
|
-
},
|
|
4364
|
+
}, _callee41, this);
|
|
3920
4365
|
}));
|
|
3921
|
-
function publishWalletAssetsState(
|
|
4366
|
+
function publishWalletAssetsState(_x36) {
|
|
3922
4367
|
return _publishWalletAssetsState.apply(this, arguments);
|
|
3923
4368
|
}
|
|
3924
4369
|
return publishWalletAssetsState;
|
|
@@ -3926,26 +4371,26 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3926
4371
|
}, {
|
|
3927
4372
|
key: "syncSelectedWalletAssets",
|
|
3928
4373
|
value: function () {
|
|
3929
|
-
var _syncSelectedWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4374
|
+
var _syncSelectedWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(state) {
|
|
3930
4375
|
var paymentMethods, methodByCode, preparePayments, selectedAssetById, voucherPayments, payments;
|
|
3931
|
-
return _regeneratorRuntime().wrap(function
|
|
3932
|
-
while (1) switch (
|
|
4376
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context42) {
|
|
4377
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
3933
4378
|
case 0:
|
|
3934
4379
|
if (!(!this.store.order || !this.store.payment)) {
|
|
3935
|
-
|
|
4380
|
+
_context42.next = 2;
|
|
3936
4381
|
break;
|
|
3937
4382
|
}
|
|
3938
4383
|
throw new Error('订单或支付模块未初始化');
|
|
3939
4384
|
case 2:
|
|
3940
4385
|
paymentMethods = this.getPaymentMethods();
|
|
3941
4386
|
if (!(!paymentMethods.length && state.selectedItems.length)) {
|
|
3942
|
-
|
|
4387
|
+
_context42.next = 7;
|
|
3943
4388
|
break;
|
|
3944
4389
|
}
|
|
3945
|
-
|
|
4390
|
+
_context42.next = 6;
|
|
3946
4391
|
return this.getPaymentMethodsAsync();
|
|
3947
4392
|
case 6:
|
|
3948
|
-
paymentMethods =
|
|
4393
|
+
paymentMethods = _context42.sent;
|
|
3949
4394
|
case 7:
|
|
3950
4395
|
methodByCode = new Map(paymentMethods.map(function (method) {
|
|
3951
4396
|
return [String(method.code || '').toUpperCase(), method];
|
|
@@ -3987,19 +4432,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3987
4432
|
payments = this.updateVoucherOrderPayments(voucherPayments, {
|
|
3988
4433
|
status: 'payment_pending'
|
|
3989
4434
|
});
|
|
3990
|
-
|
|
4435
|
+
_context42.next = 14;
|
|
3991
4436
|
return this.store.order.recalculateSummary({
|
|
3992
4437
|
createIfMissing: true
|
|
3993
4438
|
});
|
|
3994
4439
|
case 14:
|
|
3995
|
-
return
|
|
4440
|
+
return _context42.abrupt("return", payments);
|
|
3996
4441
|
case 15:
|
|
3997
4442
|
case "end":
|
|
3998
|
-
return
|
|
4443
|
+
return _context42.stop();
|
|
3999
4444
|
}
|
|
4000
|
-
},
|
|
4445
|
+
}, _callee42, this);
|
|
4001
4446
|
}));
|
|
4002
|
-
function syncSelectedWalletAssets(
|
|
4447
|
+
function syncSelectedWalletAssets(_x37) {
|
|
4003
4448
|
return _syncSelectedWalletAssets.apply(this, arguments);
|
|
4004
4449
|
}
|
|
4005
4450
|
return syncSelectedWalletAssets;
|
|
@@ -4033,29 +4478,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4033
4478
|
}, {
|
|
4034
4479
|
key: "importWalletAssetsSnapshot",
|
|
4035
4480
|
value: (function () {
|
|
4036
|
-
var _importWalletAssetsSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4481
|
+
var _importWalletAssetsSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(snapshot) {
|
|
4037
4482
|
var state;
|
|
4038
|
-
return _regeneratorRuntime().wrap(function
|
|
4039
|
-
while (1) switch (
|
|
4483
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context43) {
|
|
4484
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
4040
4485
|
case 0:
|
|
4041
4486
|
if (this.store.payment) {
|
|
4042
|
-
|
|
4487
|
+
_context43.next = 2;
|
|
4043
4488
|
break;
|
|
4044
4489
|
}
|
|
4045
4490
|
throw new Error('payment 模块未初始化');
|
|
4046
4491
|
case 2:
|
|
4047
4492
|
state = this.store.payment.wallet.importWalletAssetsSnapshot(snapshot);
|
|
4048
|
-
|
|
4493
|
+
_context43.next = 5;
|
|
4049
4494
|
return this.syncSelectedWalletAssets(state);
|
|
4050
4495
|
case 5:
|
|
4051
|
-
return
|
|
4496
|
+
return _context43.abrupt("return", this.publishWalletAssetsState(state));
|
|
4052
4497
|
case 6:
|
|
4053
4498
|
case "end":
|
|
4054
|
-
return
|
|
4499
|
+
return _context43.stop();
|
|
4055
4500
|
}
|
|
4056
|
-
},
|
|
4501
|
+
}, _callee43, this);
|
|
4057
4502
|
}));
|
|
4058
|
-
function importWalletAssetsSnapshot(
|
|
4503
|
+
function importWalletAssetsSnapshot(_x38) {
|
|
4059
4504
|
return _importWalletAssetsSnapshot.apply(this, arguments);
|
|
4060
4505
|
}
|
|
4061
4506
|
return importWalletAssetsSnapshot;
|
|
@@ -4067,20 +4512,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4067
4512
|
}, {
|
|
4068
4513
|
key: "refreshWalletAssets",
|
|
4069
4514
|
value: (function () {
|
|
4070
|
-
var _refreshWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4515
|
+
var _refreshWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(params) {
|
|
4071
4516
|
var _previousState$custom, _businessData$custome;
|
|
4072
4517
|
var refreshSequence, wallet, businessData, emptyState, previousState, hasPreviousWalletContext, customerChanged, clearedState, refreshTask, state, committed;
|
|
4073
|
-
return _regeneratorRuntime().wrap(function
|
|
4074
|
-
while (1) switch (
|
|
4518
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context44) {
|
|
4519
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
4075
4520
|
case 0:
|
|
4076
4521
|
if (this.store.order) {
|
|
4077
|
-
|
|
4522
|
+
_context44.next = 2;
|
|
4078
4523
|
break;
|
|
4079
4524
|
}
|
|
4080
4525
|
throw new Error('order 模块未初始化');
|
|
4081
4526
|
case 2:
|
|
4082
4527
|
if (this.store.payment) {
|
|
4083
|
-
|
|
4528
|
+
_context44.next = 4;
|
|
4084
4529
|
break;
|
|
4085
4530
|
}
|
|
4086
4531
|
throw new Error('payment 模块未初始化');
|
|
@@ -4089,7 +4534,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4089
4534
|
wallet = this.store.payment.wallet;
|
|
4090
4535
|
businessData = this.buildWalletInitBusinessData(params);
|
|
4091
4536
|
if (businessData) {
|
|
4092
|
-
|
|
4537
|
+
_context44.next = 12;
|
|
4093
4538
|
break;
|
|
4094
4539
|
}
|
|
4095
4540
|
wallet.clearAllCache();
|
|
@@ -4097,53 +4542,53 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4097
4542
|
this.updateVoucherOrderPayments([], {
|
|
4098
4543
|
status: 'payment_pending'
|
|
4099
4544
|
});
|
|
4100
|
-
return
|
|
4545
|
+
return _context44.abrupt("return", this.publishWalletAssetsState(emptyState));
|
|
4101
4546
|
case 12:
|
|
4102
4547
|
previousState = wallet.getWalletAssetsState();
|
|
4103
4548
|
hasPreviousWalletContext = previousState.status !== 'idle' || previousState.items.length > 0 || previousState.selectedIds.length > 0 || previousState.customerId !== undefined;
|
|
4104
4549
|
customerChanged = hasPreviousWalletContext && String((_previousState$custom = previousState.customerId) !== null && _previousState$custom !== void 0 ? _previousState$custom : '') !== String((_businessData$custome = businessData.customer_id) !== null && _businessData$custome !== void 0 ? _businessData$custome : '');
|
|
4105
4550
|
if (!customerChanged) {
|
|
4106
|
-
|
|
4551
|
+
_context44.next = 20;
|
|
4107
4552
|
break;
|
|
4108
4553
|
}
|
|
4109
4554
|
clearedState = wallet.clearWalletAssetSelection();
|
|
4110
4555
|
this.updateVoucherOrderPayments([], {
|
|
4111
4556
|
status: 'payment_pending'
|
|
4112
4557
|
});
|
|
4113
|
-
|
|
4558
|
+
_context44.next = 20;
|
|
4114
4559
|
return this.publishWalletAssetsState(clearedState);
|
|
4115
4560
|
case 20:
|
|
4116
4561
|
refreshTask = wallet.refreshWalletAssetsFromBusinessAsync(businessData, {
|
|
4117
4562
|
preserveSelection: (params === null || params === void 0 ? void 0 : params.preserveSelection) !== false && !customerChanged
|
|
4118
4563
|
});
|
|
4119
|
-
|
|
4564
|
+
_context44.next = 23;
|
|
4120
4565
|
return this.publishWalletAssetsState(wallet.getWalletAssetsState());
|
|
4121
4566
|
case 23:
|
|
4122
|
-
|
|
4567
|
+
_context44.next = 25;
|
|
4123
4568
|
return refreshTask;
|
|
4124
4569
|
case 25:
|
|
4125
|
-
state =
|
|
4570
|
+
state = _context44.sent;
|
|
4126
4571
|
if (!(refreshSequence !== this.walletAssetsRefreshSequence)) {
|
|
4127
|
-
|
|
4572
|
+
_context44.next = 28;
|
|
4128
4573
|
break;
|
|
4129
4574
|
}
|
|
4130
|
-
return
|
|
4575
|
+
return _context44.abrupt("return", wallet.getWalletAssetsState());
|
|
4131
4576
|
case 28:
|
|
4132
4577
|
if (state.status !== 'error') {
|
|
4133
4578
|
committed = this.getCommittedWalletAssets();
|
|
4134
4579
|
state = wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
4135
4580
|
}
|
|
4136
|
-
|
|
4581
|
+
_context44.next = 31;
|
|
4137
4582
|
return this.syncSelectedWalletAssets(state);
|
|
4138
4583
|
case 31:
|
|
4139
|
-
return
|
|
4584
|
+
return _context44.abrupt("return", this.publishWalletAssetsState(state));
|
|
4140
4585
|
case 32:
|
|
4141
4586
|
case "end":
|
|
4142
|
-
return
|
|
4587
|
+
return _context44.stop();
|
|
4143
4588
|
}
|
|
4144
|
-
},
|
|
4589
|
+
}, _callee44, this);
|
|
4145
4590
|
}));
|
|
4146
|
-
function refreshWalletAssets(
|
|
4591
|
+
function refreshWalletAssets(_x39) {
|
|
4147
4592
|
return _refreshWalletAssets.apply(this, arguments);
|
|
4148
4593
|
}
|
|
4149
4594
|
return refreshWalletAssets;
|
|
@@ -4151,13 +4596,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4151
4596
|
}, {
|
|
4152
4597
|
key: "selectWalletAsset",
|
|
4153
4598
|
value: (function () {
|
|
4154
|
-
var _selectWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4599
|
+
var _selectWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(params) {
|
|
4155
4600
|
var state;
|
|
4156
|
-
return _regeneratorRuntime().wrap(function
|
|
4157
|
-
while (1) switch (
|
|
4601
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context45) {
|
|
4602
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
4158
4603
|
case 0:
|
|
4159
4604
|
if (this.store.payment) {
|
|
4160
|
-
|
|
4605
|
+
_context45.next = 2;
|
|
4161
4606
|
break;
|
|
4162
4607
|
}
|
|
4163
4608
|
throw new Error('payment 模块未初始化');
|
|
@@ -4166,17 +4611,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4166
4611
|
selected: params.selected,
|
|
4167
4612
|
source: params.source
|
|
4168
4613
|
});
|
|
4169
|
-
|
|
4614
|
+
_context45.next = 5;
|
|
4170
4615
|
return this.syncSelectedWalletAssets(state);
|
|
4171
4616
|
case 5:
|
|
4172
|
-
return
|
|
4617
|
+
return _context45.abrupt("return", this.publishWalletAssetsState(state));
|
|
4173
4618
|
case 6:
|
|
4174
4619
|
case "end":
|
|
4175
|
-
return
|
|
4620
|
+
return _context45.stop();
|
|
4176
4621
|
}
|
|
4177
|
-
},
|
|
4622
|
+
}, _callee45, this);
|
|
4178
4623
|
}));
|
|
4179
|
-
function selectWalletAsset(
|
|
4624
|
+
function selectWalletAsset(_x40) {
|
|
4180
4625
|
return _selectWalletAsset.apply(this, arguments);
|
|
4181
4626
|
}
|
|
4182
4627
|
return selectWalletAsset;
|
|
@@ -4184,29 +4629,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4184
4629
|
}, {
|
|
4185
4630
|
key: "updateWalletAssetAmount",
|
|
4186
4631
|
value: (function () {
|
|
4187
|
-
var _updateWalletAssetAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4632
|
+
var _updateWalletAssetAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(params) {
|
|
4188
4633
|
var state;
|
|
4189
|
-
return _regeneratorRuntime().wrap(function
|
|
4190
|
-
while (1) switch (
|
|
4634
|
+
return _regeneratorRuntime().wrap(function _callee46$(_context46) {
|
|
4635
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
4191
4636
|
case 0:
|
|
4192
4637
|
if (this.store.payment) {
|
|
4193
|
-
|
|
4638
|
+
_context46.next = 2;
|
|
4194
4639
|
break;
|
|
4195
4640
|
}
|
|
4196
4641
|
throw new Error('payment 模块未初始化');
|
|
4197
4642
|
case 2:
|
|
4198
4643
|
state = this.store.payment.wallet.updateWalletAssetAmount(params.assetId, params.amount);
|
|
4199
|
-
|
|
4644
|
+
_context46.next = 5;
|
|
4200
4645
|
return this.syncSelectedWalletAssets(state);
|
|
4201
4646
|
case 5:
|
|
4202
|
-
return
|
|
4647
|
+
return _context46.abrupt("return", this.publishWalletAssetsState(state));
|
|
4203
4648
|
case 6:
|
|
4204
4649
|
case "end":
|
|
4205
|
-
return
|
|
4650
|
+
return _context46.stop();
|
|
4206
4651
|
}
|
|
4207
|
-
},
|
|
4652
|
+
}, _callee46, this);
|
|
4208
4653
|
}));
|
|
4209
|
-
function updateWalletAssetAmount(
|
|
4654
|
+
function updateWalletAssetAmount(_x41) {
|
|
4210
4655
|
return _updateWalletAssetAmount.apply(this, arguments);
|
|
4211
4656
|
}
|
|
4212
4657
|
return updateWalletAssetAmount;
|
|
@@ -4214,13 +4659,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4214
4659
|
}, {
|
|
4215
4660
|
key: "scanWalletAsset",
|
|
4216
4661
|
value: (function () {
|
|
4217
|
-
var _scanWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4662
|
+
var _scanWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(code) {
|
|
4218
4663
|
var wallet, businessData, result;
|
|
4219
|
-
return _regeneratorRuntime().wrap(function
|
|
4220
|
-
while (1) switch (
|
|
4664
|
+
return _regeneratorRuntime().wrap(function _callee47$(_context47) {
|
|
4665
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
4221
4666
|
case 0:
|
|
4222
4667
|
if (this.store.payment) {
|
|
4223
|
-
|
|
4668
|
+
_context47.next = 2;
|
|
4224
4669
|
break;
|
|
4225
4670
|
}
|
|
4226
4671
|
throw new Error('payment 模块未初始化');
|
|
@@ -4230,28 +4675,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4230
4675
|
if (businessData) {
|
|
4231
4676
|
wallet.generateWalletParams(businessData);
|
|
4232
4677
|
}
|
|
4233
|
-
|
|
4678
|
+
_context47.next = 7;
|
|
4234
4679
|
return wallet.scanWalletAssetAsync(code);
|
|
4235
4680
|
case 7:
|
|
4236
|
-
result =
|
|
4681
|
+
result = _context47.sent;
|
|
4237
4682
|
if (!(result.type === 'normalCode')) {
|
|
4238
|
-
|
|
4683
|
+
_context47.next = 13;
|
|
4239
4684
|
break;
|
|
4240
4685
|
}
|
|
4241
|
-
|
|
4686
|
+
_context47.next = 11;
|
|
4242
4687
|
return this.syncSelectedWalletAssets(result.state);
|
|
4243
4688
|
case 11:
|
|
4244
|
-
|
|
4689
|
+
_context47.next = 13;
|
|
4245
4690
|
return this.publishWalletAssetsState(result.state);
|
|
4246
4691
|
case 13:
|
|
4247
|
-
return
|
|
4692
|
+
return _context47.abrupt("return", result);
|
|
4248
4693
|
case 14:
|
|
4249
4694
|
case "end":
|
|
4250
|
-
return
|
|
4695
|
+
return _context47.stop();
|
|
4251
4696
|
}
|
|
4252
|
-
},
|
|
4697
|
+
}, _callee47, this);
|
|
4253
4698
|
}));
|
|
4254
|
-
function scanWalletAsset(
|
|
4699
|
+
function scanWalletAsset(_x42) {
|
|
4255
4700
|
return _scanWalletAsset.apply(this, arguments);
|
|
4256
4701
|
}
|
|
4257
4702
|
return scanWalletAsset;
|
|
@@ -4259,27 +4704,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4259
4704
|
}, {
|
|
4260
4705
|
key: "clearWalletAssetSelection",
|
|
4261
4706
|
value: (function () {
|
|
4262
|
-
var _clearWalletAssetSelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4707
|
+
var _clearWalletAssetSelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48() {
|
|
4263
4708
|
var state;
|
|
4264
|
-
return _regeneratorRuntime().wrap(function
|
|
4265
|
-
while (1) switch (
|
|
4709
|
+
return _regeneratorRuntime().wrap(function _callee48$(_context48) {
|
|
4710
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
4266
4711
|
case 0:
|
|
4267
4712
|
if (this.store.payment) {
|
|
4268
|
-
|
|
4713
|
+
_context48.next = 2;
|
|
4269
4714
|
break;
|
|
4270
4715
|
}
|
|
4271
4716
|
throw new Error('payment 模块未初始化');
|
|
4272
4717
|
case 2:
|
|
4273
4718
|
state = this.store.payment.wallet.clearWalletAssetSelection();
|
|
4274
|
-
|
|
4719
|
+
_context48.next = 5;
|
|
4275
4720
|
return this.syncSelectedWalletAssets(state);
|
|
4276
4721
|
case 5:
|
|
4277
|
-
return
|
|
4722
|
+
return _context48.abrupt("return", this.publishWalletAssetsState(state));
|
|
4278
4723
|
case 6:
|
|
4279
4724
|
case "end":
|
|
4280
|
-
return
|
|
4725
|
+
return _context48.stop();
|
|
4281
4726
|
}
|
|
4282
|
-
},
|
|
4727
|
+
}, _callee48, this);
|
|
4283
4728
|
}));
|
|
4284
4729
|
function clearWalletAssetSelection() {
|
|
4285
4730
|
return _clearWalletAssetSelection.apply(this, arguments);
|
|
@@ -4309,35 +4754,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4309
4754
|
}, {
|
|
4310
4755
|
key: "getPaymentMethodsAsync",
|
|
4311
4756
|
value: (function () {
|
|
4312
|
-
var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4757
|
+
var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49() {
|
|
4313
4758
|
var response, paymentMethods;
|
|
4314
|
-
return _regeneratorRuntime().wrap(function
|
|
4315
|
-
while (1) switch (
|
|
4759
|
+
return _regeneratorRuntime().wrap(function _callee49$(_context49) {
|
|
4760
|
+
while (1) switch (_context49.prev = _context49.next) {
|
|
4316
4761
|
case 0:
|
|
4317
|
-
|
|
4318
|
-
|
|
4762
|
+
_context49.prev = 0;
|
|
4763
|
+
_context49.next = 3;
|
|
4319
4764
|
return this.request.get('/pay/custom-payment/all', {
|
|
4320
4765
|
filterPaymentMethods: true
|
|
4321
4766
|
}, {
|
|
4322
4767
|
osServer: true
|
|
4323
4768
|
});
|
|
4324
4769
|
case 3:
|
|
4325
|
-
response =
|
|
4770
|
+
response = _context49.sent;
|
|
4326
4771
|
paymentMethods = (response === null || response === void 0 ? void 0 : response.data) || [];
|
|
4327
4772
|
this.paymentMethodsCache = Array.isArray(paymentMethods) ? _toConsumableArray(paymentMethods) : [];
|
|
4328
|
-
return
|
|
4773
|
+
return _context49.abrupt("return", this.getPaymentMethods());
|
|
4329
4774
|
case 9:
|
|
4330
|
-
|
|
4331
|
-
|
|
4775
|
+
_context49.prev = 9;
|
|
4776
|
+
_context49.t0 = _context49["catch"](0);
|
|
4332
4777
|
this.logWarning('getPaymentMethodsAsync: 获取支付方式列表失败,使用缓存列表', {
|
|
4333
|
-
error:
|
|
4778
|
+
error: _context49.t0 instanceof Error ? _context49.t0.message : String(_context49.t0)
|
|
4334
4779
|
});
|
|
4335
|
-
return
|
|
4780
|
+
return _context49.abrupt("return", this.getPaymentMethods());
|
|
4336
4781
|
case 13:
|
|
4337
4782
|
case "end":
|
|
4338
|
-
return
|
|
4783
|
+
return _context49.stop();
|
|
4339
4784
|
}
|
|
4340
|
-
},
|
|
4785
|
+
}, _callee49, this, [[0, 9]]);
|
|
4341
4786
|
}));
|
|
4342
4787
|
function getPaymentMethodsAsync() {
|
|
4343
4788
|
return _getPaymentMethodsAsync.apply(this, arguments);
|
|
@@ -4380,14 +4825,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4380
4825
|
}, {
|
|
4381
4826
|
key: "getCashPaymentConfig",
|
|
4382
4827
|
value: (function () {
|
|
4383
|
-
var _getCashPaymentConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4828
|
+
var _getCashPaymentConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50() {
|
|
4384
4829
|
var _this$store$order11, _this$store$order11$g, _this$store$order12, _this$store$order12$g, _this$otherParams33;
|
|
4385
4830
|
var paymentMethods, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, currency, recommendedAmounts;
|
|
4386
|
-
return _regeneratorRuntime().wrap(function
|
|
4387
|
-
while (1) switch (
|
|
4831
|
+
return _regeneratorRuntime().wrap(function _callee50$(_context50) {
|
|
4832
|
+
while (1) switch (_context50.prev = _context50.next) {
|
|
4388
4833
|
case 0:
|
|
4389
4834
|
if (this.store.payment) {
|
|
4390
|
-
|
|
4835
|
+
_context50.next = 2;
|
|
4391
4836
|
break;
|
|
4392
4837
|
}
|
|
4393
4838
|
throw new Error('payment 模块未初始化');
|
|
@@ -4395,13 +4840,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4395
4840
|
paymentMethods = this.getPaymentMethods();
|
|
4396
4841
|
paymentMethod = this.findCashPaymentMethod(paymentMethods);
|
|
4397
4842
|
if (paymentMethod) {
|
|
4398
|
-
|
|
4843
|
+
_context50.next = 9;
|
|
4399
4844
|
break;
|
|
4400
4845
|
}
|
|
4401
|
-
|
|
4846
|
+
_context50.next = 7;
|
|
4402
4847
|
return this.getPaymentMethodsAsync();
|
|
4403
4848
|
case 7:
|
|
4404
|
-
paymentMethods =
|
|
4849
|
+
paymentMethods = _context50.sent;
|
|
4405
4850
|
paymentMethod = this.findCashPaymentMethod(paymentMethods);
|
|
4406
4851
|
case 9:
|
|
4407
4852
|
amountSnapshot = (_this$store$order11 = this.store.order) === null || _this$store$order11 === void 0 || (_this$store$order11$g = _this$store$order11.getOrderAmountSnapshot) === null || _this$store$order11$g === void 0 ? void 0 : _this$store$order11$g.call(_this$store$order11);
|
|
@@ -4409,7 +4854,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4409
4854
|
amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0).toDecimalPlaces(2).toNumber();
|
|
4410
4855
|
currency = ((_this$store$order12 = this.store.order) === null || _this$store$order12 === void 0 || (_this$store$order12$g = _this$store$order12.getTempOrder) === null || _this$store$order12$g === void 0 || (_this$store$order12$g = _this$store$order12$g.call(_this$store$order12)) === null || _this$store$order12$g === void 0 ? void 0 : _this$store$order12$g.currency_code) || ((_this$otherParams33 = this.otherParams) === null || _this$otherParams33 === void 0 ? void 0 : _this$otherParams33.currency) || 'USD';
|
|
4411
4856
|
recommendedAmounts = amountDue > 0 ? this.store.payment.cash.getRecommendedAmount(amountDue, currency) : [];
|
|
4412
|
-
return
|
|
4857
|
+
return _context50.abrupt("return", {
|
|
4413
4858
|
available: Boolean(paymentMethod && amountDue > 0),
|
|
4414
4859
|
paymentMethod: paymentMethod,
|
|
4415
4860
|
amountDue: amountDue,
|
|
@@ -4417,9 +4862,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4417
4862
|
});
|
|
4418
4863
|
case 15:
|
|
4419
4864
|
case "end":
|
|
4420
|
-
return
|
|
4865
|
+
return _context50.stop();
|
|
4421
4866
|
}
|
|
4422
|
-
},
|
|
4867
|
+
}, _callee50, this);
|
|
4423
4868
|
}));
|
|
4424
4869
|
function getCashPaymentConfig() {
|
|
4425
4870
|
return _getCashPaymentConfig.apply(this, arguments);
|
|
@@ -4436,14 +4881,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4436
4881
|
}, {
|
|
4437
4882
|
key: "confirmWalletPayment",
|
|
4438
4883
|
value: (function () {
|
|
4439
|
-
var _confirmWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4884
|
+
var _confirmWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51() {
|
|
4440
4885
|
var _this$store$order$get3, _this$store$order13, _this$store$order$get4, _this$store$order$get5, _this$store$order14;
|
|
4441
4886
|
var beforePayments, pendingWalletAmount, amountSnapshot, effectiveAmountDue, beforePaymentStatus, submitResult, restoredTempOrder, committed, walletState, latestAmountSnapshot;
|
|
4442
|
-
return _regeneratorRuntime().wrap(function
|
|
4443
|
-
while (1) switch (
|
|
4887
|
+
return _regeneratorRuntime().wrap(function _callee51$(_context51) {
|
|
4888
|
+
while (1) switch (_context51.prev = _context51.next) {
|
|
4444
4889
|
case 0:
|
|
4445
4890
|
if (this.store.order) {
|
|
4446
|
-
|
|
4891
|
+
_context51.next = 2;
|
|
4447
4892
|
break;
|
|
4448
4893
|
}
|
|
4449
4894
|
throw new Error('order 模块未初始化');
|
|
@@ -4451,7 +4896,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4451
4896
|
beforePayments = cloneDeep(this.store.order.getOrderPayments());
|
|
4452
4897
|
pendingWalletAmount = this.getPendingWalletPaymentAmount(beforePayments);
|
|
4453
4898
|
if (!pendingWalletAmount.lte(0)) {
|
|
4454
|
-
|
|
4899
|
+
_context51.next = 6;
|
|
4455
4900
|
break;
|
|
4456
4901
|
}
|
|
4457
4902
|
throw new Error('当前订单没有待确认的 Wallet 支付');
|
|
@@ -4459,74 +4904,74 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4459
4904
|
amountSnapshot = (_this$store$order$get3 = (_this$store$order13 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get3 === void 0 ? void 0 : _this$store$order$get3.call(_this$store$order13);
|
|
4460
4905
|
effectiveAmountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
|
|
4461
4906
|
if (!effectiveAmountDue.gt(0.01)) {
|
|
4462
|
-
|
|
4907
|
+
_context51.next = 10;
|
|
4463
4908
|
break;
|
|
4464
4909
|
}
|
|
4465
4910
|
throw new Error('Wallet 支付尚未覆盖全部待支付金额');
|
|
4466
4911
|
case 10:
|
|
4467
4912
|
beforePaymentStatus = (_this$store$order$get4 = this.store.order.getTempOrder()) === null || _this$store$order$get4 === void 0 ? void 0 : _this$store$order$get4.payment_status;
|
|
4468
|
-
|
|
4469
|
-
|
|
4913
|
+
_context51.prev = 11;
|
|
4914
|
+
_context51.next = 14;
|
|
4470
4915
|
return this.submitSalesOrder({
|
|
4471
4916
|
smallTicketDataFlag: 1,
|
|
4472
4917
|
confirmPendingVoucherPayments: true
|
|
4473
4918
|
});
|
|
4474
4919
|
case 14:
|
|
4475
|
-
submitResult =
|
|
4920
|
+
submitResult = _context51.sent;
|
|
4476
4921
|
if (!isRejectedSalesSubmitResult(submitResult)) {
|
|
4477
|
-
|
|
4922
|
+
_context51.next = 17;
|
|
4478
4923
|
break;
|
|
4479
4924
|
}
|
|
4480
4925
|
throw new Error(getSalesSubmitErrorMessage(submitResult, 'Wallet 支付确认失败'));
|
|
4481
4926
|
case 17:
|
|
4482
|
-
|
|
4927
|
+
_context51.next = 27;
|
|
4483
4928
|
break;
|
|
4484
4929
|
case 19:
|
|
4485
|
-
|
|
4486
|
-
|
|
4930
|
+
_context51.prev = 19;
|
|
4931
|
+
_context51.t0 = _context51["catch"](11);
|
|
4487
4932
|
this.store.order.setOrderPayments(beforePayments);
|
|
4488
4933
|
restoredTempOrder = this.store.order.getTempOrder();
|
|
4489
4934
|
if (restoredTempOrder && beforePaymentStatus !== undefined) {
|
|
4490
4935
|
restoredTempOrder.payment_status = beforePaymentStatus;
|
|
4491
4936
|
this.store.order.persistTempOrder();
|
|
4492
4937
|
}
|
|
4493
|
-
|
|
4938
|
+
_context51.next = 26;
|
|
4494
4939
|
return this.store.order.recalculateSummary({
|
|
4495
4940
|
createIfMissing: true
|
|
4496
4941
|
});
|
|
4497
4942
|
case 26:
|
|
4498
|
-
throw
|
|
4943
|
+
throw _context51.t0;
|
|
4499
4944
|
case 27:
|
|
4500
4945
|
if (!this.store.payment) {
|
|
4501
|
-
|
|
4946
|
+
_context51.next = 38;
|
|
4502
4947
|
break;
|
|
4503
4948
|
}
|
|
4504
|
-
|
|
4949
|
+
_context51.prev = 28;
|
|
4505
4950
|
committed = this.getCommittedWalletAssets();
|
|
4506
4951
|
walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
4507
|
-
|
|
4952
|
+
_context51.next = 33;
|
|
4508
4953
|
return this.publishWalletAssetsState(walletState);
|
|
4509
4954
|
case 33:
|
|
4510
|
-
|
|
4955
|
+
_context51.next = 38;
|
|
4511
4956
|
break;
|
|
4512
4957
|
case 35:
|
|
4513
|
-
|
|
4514
|
-
|
|
4958
|
+
_context51.prev = 35;
|
|
4959
|
+
_context51.t1 = _context51["catch"](28);
|
|
4515
4960
|
this.logWarning('confirmWalletPayment: Wallet committed 状态同步失败', {
|
|
4516
|
-
error:
|
|
4961
|
+
error: _context51.t1 instanceof Error ? _context51.t1.message : String(_context51.t1)
|
|
4517
4962
|
});
|
|
4518
4963
|
case 38:
|
|
4519
4964
|
latestAmountSnapshot = (_this$store$order$get5 = (_this$store$order14 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get5 === void 0 ? void 0 : _this$store$order$get5.call(_this$store$order14);
|
|
4520
|
-
return
|
|
4965
|
+
return _context51.abrupt("return", {
|
|
4521
4966
|
submitResult: submitResult,
|
|
4522
4967
|
payments: this.store.order.getOrderPayments(),
|
|
4523
4968
|
isOrderFullyPaid: new Decimal((latestAmountSnapshot === null || latestAmountSnapshot === void 0 ? void 0 : latestAmountSnapshot.amountGap) || 0).lte(0)
|
|
4524
4969
|
});
|
|
4525
4970
|
case 40:
|
|
4526
4971
|
case "end":
|
|
4527
|
-
return
|
|
4972
|
+
return _context51.stop();
|
|
4528
4973
|
}
|
|
4529
|
-
},
|
|
4974
|
+
}, _callee51, this, [[11, 19], [28, 35]]);
|
|
4530
4975
|
}));
|
|
4531
4976
|
function confirmWalletPayment() {
|
|
4532
4977
|
return _confirmWalletPayment.apply(this, arguments);
|
|
@@ -4541,38 +4986,38 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4541
4986
|
}, {
|
|
4542
4987
|
key: "payCash",
|
|
4543
4988
|
value: (function () {
|
|
4544
|
-
var _payCash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4989
|
+
var _payCash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(params) {
|
|
4545
4990
|
var _this$store$order$get6, _params$actualPaidAmo, _this$otherParams34, _this$window, _this$window$postMess;
|
|
4546
4991
|
var amount, config, paymentMethod, roundingAmount, effectivePaymentAmount, beforePayments, beforePaymentStatus, uniquePaymentNumber, paymentTimestamp, actualPaidAmount, changeAmount, shopWalletPassId, payments, payment, syncResult, committed, walletState, restoredTempOrder;
|
|
4547
|
-
return _regeneratorRuntime().wrap(function
|
|
4548
|
-
while (1) switch (
|
|
4992
|
+
return _regeneratorRuntime().wrap(function _callee52$(_context52) {
|
|
4993
|
+
while (1) switch (_context52.prev = _context52.next) {
|
|
4549
4994
|
case 0:
|
|
4550
4995
|
if (this.store.order) {
|
|
4551
|
-
|
|
4996
|
+
_context52.next = 2;
|
|
4552
4997
|
break;
|
|
4553
4998
|
}
|
|
4554
4999
|
throw new Error('order 模块未初始化');
|
|
4555
5000
|
case 2:
|
|
4556
5001
|
amount = Number(params.amount || 0);
|
|
4557
5002
|
if (!(!Number.isFinite(amount) || amount <= 0)) {
|
|
4558
|
-
|
|
5003
|
+
_context52.next = 5;
|
|
4559
5004
|
break;
|
|
4560
5005
|
}
|
|
4561
5006
|
throw new Error('现金支付金额必须大于 0');
|
|
4562
5007
|
case 5:
|
|
4563
|
-
|
|
5008
|
+
_context52.next = 7;
|
|
4564
5009
|
return this.getCashPaymentConfig();
|
|
4565
5010
|
case 7:
|
|
4566
|
-
config =
|
|
5011
|
+
config = _context52.sent;
|
|
4567
5012
|
paymentMethod = config.paymentMethod;
|
|
4568
5013
|
if (paymentMethod) {
|
|
4569
|
-
|
|
5014
|
+
_context52.next = 11;
|
|
4570
5015
|
break;
|
|
4571
5016
|
}
|
|
4572
5017
|
throw new Error('未找到可用的 CASHMANUAL 支付方式');
|
|
4573
5018
|
case 11:
|
|
4574
5019
|
if (!(config.amountDue <= 0)) {
|
|
4575
|
-
|
|
5020
|
+
_context52.next = 13;
|
|
4576
5021
|
break;
|
|
4577
5022
|
}
|
|
4578
5023
|
throw new Error('当前订单没有待支付金额');
|
|
@@ -4580,7 +5025,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4580
5025
|
roundingAmount = Number(params.roundingAmount || 0);
|
|
4581
5026
|
effectivePaymentAmount = new Decimal(amount).minus(roundingAmount);
|
|
4582
5027
|
if (!effectivePaymentAmount.gt(new Decimal(config.amountDue).plus(0.01))) {
|
|
4583
|
-
|
|
5028
|
+
_context52.next = 17;
|
|
4584
5029
|
break;
|
|
4585
5030
|
}
|
|
4586
5031
|
throw new Error('现金支付金额超过当前待支付金额');
|
|
@@ -4593,7 +5038,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4593
5038
|
changeAmount = Number(params.changeAmount || 0);
|
|
4594
5039
|
shopWalletPassId = (_this$otherParams34 = this.otherParams) === null || _this$otherParams34 === void 0 ? void 0 : _this$otherParams34.shop_wallet_pass_id;
|
|
4595
5040
|
if (!(!Number.isFinite(actualPaidAmount) || actualPaidAmount + 0.01 < amount)) {
|
|
4596
|
-
|
|
5041
|
+
_context52.next = 26;
|
|
4597
5042
|
break;
|
|
4598
5043
|
}
|
|
4599
5044
|
throw new Error('顾客实收现金不能小于支付金额');
|
|
@@ -4628,8 +5073,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4628
5073
|
var _item$metadata2;
|
|
4629
5074
|
return (item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.unique_payment_number) === uniquePaymentNumber;
|
|
4630
5075
|
});
|
|
4631
|
-
|
|
4632
|
-
|
|
5076
|
+
_context52.prev = 29;
|
|
5077
|
+
_context52.next = 32;
|
|
4633
5078
|
return this.syncPaymentsToOrder({
|
|
4634
5079
|
payments: payments,
|
|
4635
5080
|
submitWhenPaid: true,
|
|
@@ -4637,50 +5082,50 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4637
5082
|
confirmPendingVoucherPayments: true
|
|
4638
5083
|
});
|
|
4639
5084
|
case 32:
|
|
4640
|
-
syncResult =
|
|
5085
|
+
syncResult = _context52.sent;
|
|
4641
5086
|
if (!isRejectedSalesSubmitResult(syncResult.submitResult)) {
|
|
4642
|
-
|
|
5087
|
+
_context52.next = 35;
|
|
4643
5088
|
break;
|
|
4644
5089
|
}
|
|
4645
5090
|
throw new Error(getSalesSubmitErrorMessage(syncResult.submitResult, '订单提交失败'));
|
|
4646
5091
|
case 35:
|
|
4647
5092
|
if (!this.store.payment) {
|
|
4648
|
-
|
|
5093
|
+
_context52.next = 40;
|
|
4649
5094
|
break;
|
|
4650
5095
|
}
|
|
4651
5096
|
committed = this.getCommittedWalletAssets();
|
|
4652
5097
|
walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
4653
|
-
|
|
5098
|
+
_context52.next = 40;
|
|
4654
5099
|
return this.publishWalletAssetsState(walletState);
|
|
4655
5100
|
case 40:
|
|
4656
|
-
return
|
|
5101
|
+
return _context52.abrupt("return", {
|
|
4657
5102
|
payment: payment || {},
|
|
4658
5103
|
payments: this.store.order.getOrderPayments(),
|
|
4659
5104
|
syncResult: syncResult,
|
|
4660
5105
|
isOrderFullyPaid: syncResult.isOrderFullyPaid
|
|
4661
5106
|
});
|
|
4662
5107
|
case 43:
|
|
4663
|
-
|
|
4664
|
-
|
|
5108
|
+
_context52.prev = 43;
|
|
5109
|
+
_context52.t0 = _context52["catch"](29);
|
|
4665
5110
|
this.store.order.setOrderPayments(beforePayments);
|
|
4666
5111
|
restoredTempOrder = this.store.order.getTempOrder();
|
|
4667
5112
|
if (restoredTempOrder && beforePaymentStatus !== undefined) {
|
|
4668
5113
|
restoredTempOrder.payment_status = beforePaymentStatus;
|
|
4669
5114
|
this.store.order.persistTempOrder();
|
|
4670
5115
|
}
|
|
4671
|
-
|
|
5116
|
+
_context52.next = 50;
|
|
4672
5117
|
return this.store.order.recalculateSummary({
|
|
4673
5118
|
createIfMissing: true
|
|
4674
5119
|
});
|
|
4675
5120
|
case 50:
|
|
4676
|
-
throw
|
|
5121
|
+
throw _context52.t0;
|
|
4677
5122
|
case 51:
|
|
4678
5123
|
case "end":
|
|
4679
|
-
return
|
|
5124
|
+
return _context52.stop();
|
|
4680
5125
|
}
|
|
4681
|
-
},
|
|
5126
|
+
}, _callee52, this, [[29, 43]]);
|
|
4682
5127
|
}));
|
|
4683
|
-
function payCash(
|
|
5128
|
+
function payCash(_x43) {
|
|
4684
5129
|
return _payCash.apply(this, arguments);
|
|
4685
5130
|
}
|
|
4686
5131
|
return payCash;
|
|
@@ -4696,21 +5141,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4696
5141
|
}, {
|
|
4697
5142
|
key: "commitPaymentMethodPayment",
|
|
4698
5143
|
value: (function () {
|
|
4699
|
-
var _commitPaymentMethodPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5144
|
+
var _commitPaymentMethodPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(params) {
|
|
4700
5145
|
var _this$store$order$get7, _this$store$order15, _this$store$order$get8, _params$metadata, _params$originAmount;
|
|
4701
5146
|
var amount, paymentMethods, findPaymentMethod, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, beforePayments, beforePaymentStatus, paymentTimestamp, metadata, serviceCharge, serviceFee, payments, payment, syncResult, committed, walletState, restoredTempOrder;
|
|
4702
|
-
return _regeneratorRuntime().wrap(function
|
|
4703
|
-
while (1) switch (
|
|
5147
|
+
return _regeneratorRuntime().wrap(function _callee53$(_context53) {
|
|
5148
|
+
while (1) switch (_context53.prev = _context53.next) {
|
|
4704
5149
|
case 0:
|
|
4705
5150
|
if (this.store.order) {
|
|
4706
|
-
|
|
5151
|
+
_context53.next = 2;
|
|
4707
5152
|
break;
|
|
4708
5153
|
}
|
|
4709
5154
|
throw new Error('order 模块未初始化');
|
|
4710
5155
|
case 2:
|
|
4711
5156
|
amount = Number(params.amount || 0);
|
|
4712
5157
|
if (!(!Number.isFinite(amount) || amount <= 0)) {
|
|
4713
|
-
|
|
5158
|
+
_context53.next = 5;
|
|
4714
5159
|
break;
|
|
4715
5160
|
}
|
|
4716
5161
|
throw new Error('支付金额必须大于 0');
|
|
@@ -4726,17 +5171,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4726
5171
|
};
|
|
4727
5172
|
paymentMethod = findPaymentMethod();
|
|
4728
5173
|
if (paymentMethod) {
|
|
4729
|
-
|
|
5174
|
+
_context53.next = 13;
|
|
4730
5175
|
break;
|
|
4731
5176
|
}
|
|
4732
|
-
|
|
5177
|
+
_context53.next = 11;
|
|
4733
5178
|
return this.getPaymentMethodsAsync();
|
|
4734
5179
|
case 11:
|
|
4735
|
-
paymentMethods =
|
|
5180
|
+
paymentMethods = _context53.sent;
|
|
4736
5181
|
paymentMethod = findPaymentMethod();
|
|
4737
5182
|
case 13:
|
|
4738
5183
|
if (paymentMethod) {
|
|
4739
|
-
|
|
5184
|
+
_context53.next = 15;
|
|
4740
5185
|
break;
|
|
4741
5186
|
}
|
|
4742
5187
|
throw new Error("\u672A\u627E\u5230\u53EF\u7528\u7684\u652F\u4ED8\u65B9\u5F0F\uFF1A".concat(params.paymentMethodCode || params.paymentMethodId || ''));
|
|
@@ -4745,13 +5190,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4745
5190
|
pendingWalletAmount = this.getPendingWalletPaymentAmount();
|
|
4746
5191
|
amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
|
|
4747
5192
|
if (!amountDue.lte(0)) {
|
|
4748
|
-
|
|
5193
|
+
_context53.next = 20;
|
|
4749
5194
|
break;
|
|
4750
5195
|
}
|
|
4751
5196
|
throw new Error('当前订单没有待支付金额');
|
|
4752
5197
|
case 20:
|
|
4753
5198
|
if (!new Decimal(amount).gt(amountDue.plus(0.01))) {
|
|
4754
|
-
|
|
5199
|
+
_context53.next = 22;
|
|
4755
5200
|
break;
|
|
4756
5201
|
}
|
|
4757
5202
|
throw new Error('支付金额超过当前待支付金额');
|
|
@@ -4790,8 +5235,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4790
5235
|
var _item$metadata3;
|
|
4791
5236
|
return (item === null || item === void 0 || (_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.unique_payment_number) === metadata.unique_payment_number;
|
|
4792
5237
|
});
|
|
4793
|
-
|
|
4794
|
-
|
|
5238
|
+
_context53.prev = 30;
|
|
5239
|
+
_context53.next = 33;
|
|
4795
5240
|
return this.syncPaymentsToOrder({
|
|
4796
5241
|
payments: payments,
|
|
4797
5242
|
submitWhenPaid: true,
|
|
@@ -4799,50 +5244,50 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4799
5244
|
confirmPendingVoucherPayments: true
|
|
4800
5245
|
});
|
|
4801
5246
|
case 33:
|
|
4802
|
-
syncResult =
|
|
5247
|
+
syncResult = _context53.sent;
|
|
4803
5248
|
if (!isRejectedSalesSubmitResult(syncResult.submitResult)) {
|
|
4804
|
-
|
|
5249
|
+
_context53.next = 36;
|
|
4805
5250
|
break;
|
|
4806
5251
|
}
|
|
4807
5252
|
throw new Error(getSalesSubmitErrorMessage(syncResult.submitResult, '订单提交失败'));
|
|
4808
5253
|
case 36:
|
|
4809
5254
|
if (!this.store.payment) {
|
|
4810
|
-
|
|
5255
|
+
_context53.next = 41;
|
|
4811
5256
|
break;
|
|
4812
5257
|
}
|
|
4813
5258
|
committed = this.getCommittedWalletAssets();
|
|
4814
5259
|
walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
4815
|
-
|
|
5260
|
+
_context53.next = 41;
|
|
4816
5261
|
return this.publishWalletAssetsState(walletState);
|
|
4817
5262
|
case 41:
|
|
4818
|
-
return
|
|
5263
|
+
return _context53.abrupt("return", {
|
|
4819
5264
|
payment: payment || {},
|
|
4820
5265
|
payments: this.store.order.getOrderPayments(),
|
|
4821
5266
|
syncResult: syncResult,
|
|
4822
5267
|
isOrderFullyPaid: syncResult.isOrderFullyPaid
|
|
4823
5268
|
});
|
|
4824
5269
|
case 44:
|
|
4825
|
-
|
|
4826
|
-
|
|
5270
|
+
_context53.prev = 44;
|
|
5271
|
+
_context53.t0 = _context53["catch"](30);
|
|
4827
5272
|
this.store.order.setOrderPayments(beforePayments);
|
|
4828
5273
|
restoredTempOrder = this.store.order.getTempOrder();
|
|
4829
5274
|
if (restoredTempOrder && beforePaymentStatus !== undefined) {
|
|
4830
5275
|
restoredTempOrder.payment_status = beforePaymentStatus;
|
|
4831
5276
|
this.store.order.persistTempOrder();
|
|
4832
5277
|
}
|
|
4833
|
-
|
|
5278
|
+
_context53.next = 51;
|
|
4834
5279
|
return this.store.order.recalculateSummary({
|
|
4835
5280
|
createIfMissing: true
|
|
4836
5281
|
});
|
|
4837
5282
|
case 51:
|
|
4838
|
-
throw
|
|
5283
|
+
throw _context53.t0;
|
|
4839
5284
|
case 52:
|
|
4840
5285
|
case "end":
|
|
4841
|
-
return
|
|
5286
|
+
return _context53.stop();
|
|
4842
5287
|
}
|
|
4843
|
-
},
|
|
5288
|
+
}, _callee53, this, [[30, 44]]);
|
|
4844
5289
|
}));
|
|
4845
|
-
function commitPaymentMethodPayment(
|
|
5290
|
+
function commitPaymentMethodPayment(_x44) {
|
|
4846
5291
|
return _commitPaymentMethodPayment.apply(this, arguments);
|
|
4847
5292
|
}
|
|
4848
5293
|
return commitPaymentMethodPayment;
|
|
@@ -4857,40 +5302,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4857
5302
|
}, {
|
|
4858
5303
|
key: "roundAmount",
|
|
4859
5304
|
value: (function () {
|
|
4860
|
-
var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5305
|
+
var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(params) {
|
|
4861
5306
|
var _cashManualPayment$me, _this$otherParams$ord2, _this$otherParams$ord3;
|
|
4862
5307
|
var amount, cashManualPayment;
|
|
4863
|
-
return _regeneratorRuntime().wrap(function
|
|
4864
|
-
while (1) switch (
|
|
5308
|
+
return _regeneratorRuntime().wrap(function _callee54$(_context54) {
|
|
5309
|
+
while (1) switch (_context54.prev = _context54.next) {
|
|
4865
5310
|
case 0:
|
|
4866
5311
|
amount = params.amount;
|
|
4867
5312
|
cashManualPayment = this.paymentMethodsCache.find(function (paymentMethod) {
|
|
4868
5313
|
return paymentMethod.code === 'CASHMANUAL';
|
|
4869
5314
|
});
|
|
4870
5315
|
if (cashManualPayment !== null && cashManualPayment !== void 0 && (_cashManualPayment$me = cashManualPayment.metadata) !== null && _cashManualPayment$me !== void 0 && _cashManualPayment$me.order_rounding_switch) {
|
|
4871
|
-
|
|
5316
|
+
_context54.next = 4;
|
|
4872
5317
|
break;
|
|
4873
5318
|
}
|
|
4874
|
-
return
|
|
5319
|
+
return _context54.abrupt("return", {
|
|
4875
5320
|
originalAmount: amount.toString(),
|
|
4876
5321
|
roundedAmount: amount.toString(),
|
|
4877
5322
|
roundingDifference: '0.00'
|
|
4878
5323
|
});
|
|
4879
5324
|
case 4:
|
|
4880
5325
|
if (this.payment) {
|
|
4881
|
-
|
|
5326
|
+
_context54.next = 6;
|
|
4882
5327
|
break;
|
|
4883
5328
|
}
|
|
4884
5329
|
throw new Error('payment 模块未初始化');
|
|
4885
5330
|
case 6:
|
|
4886
|
-
return
|
|
5331
|
+
return _context54.abrupt("return", this.payment.roundAmountAsync(amount, (_this$otherParams$ord2 = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord2 === void 0 ? void 0 : _this$otherParams$ord2.interval, (_this$otherParams$ord3 = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord3 === void 0 ? void 0 : _this$otherParams$ord3.type));
|
|
4887
5332
|
case 7:
|
|
4888
5333
|
case "end":
|
|
4889
|
-
return
|
|
5334
|
+
return _context54.stop();
|
|
4890
5335
|
}
|
|
4891
|
-
},
|
|
5336
|
+
}, _callee54, this);
|
|
4892
5337
|
}));
|
|
4893
|
-
function roundAmount(
|
|
5338
|
+
function roundAmount(_x45) {
|
|
4894
5339
|
return _roundAmount.apply(this, arguments);
|
|
4895
5340
|
}
|
|
4896
5341
|
return roundAmount;
|
|
@@ -4905,49 +5350,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4905
5350
|
}, {
|
|
4906
5351
|
key: "sendCustomerPayLink",
|
|
4907
5352
|
value: (function () {
|
|
4908
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4909
|
-
var orderIds,
|
|
4910
|
-
return _regeneratorRuntime().wrap(function
|
|
4911
|
-
while (1) switch (
|
|
5353
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(params) {
|
|
5354
|
+
var orderIds, _ref41, _ref42, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
|
|
5355
|
+
return _regeneratorRuntime().wrap(function _callee55$(_context55) {
|
|
5356
|
+
while (1) switch (_context55.prev = _context55.next) {
|
|
4912
5357
|
case 0:
|
|
4913
5358
|
if (this.store.order) {
|
|
4914
|
-
|
|
5359
|
+
_context55.next = 2;
|
|
4915
5360
|
break;
|
|
4916
5361
|
}
|
|
4917
5362
|
throw new Error('order 模块未初始化');
|
|
4918
5363
|
case 2:
|
|
4919
5364
|
orderIds = params.order_ids || params.orderIds || [];
|
|
4920
5365
|
if (!(!orderIds.length || params.submitBeforeSend)) {
|
|
4921
|
-
|
|
5366
|
+
_context55.next = 11;
|
|
4922
5367
|
break;
|
|
4923
5368
|
}
|
|
4924
|
-
|
|
5369
|
+
_context55.next = 6;
|
|
4925
5370
|
return this.submitSalesOrder({
|
|
4926
5371
|
smallTicketDataFlag: 1
|
|
4927
5372
|
});
|
|
4928
5373
|
case 6:
|
|
4929
|
-
submitResult =
|
|
4930
|
-
orderId = (
|
|
5374
|
+
submitResult = _context55.sent;
|
|
5375
|
+
orderId = (_ref41 = (_ref42 = (_submitResult$data$or = submitResult === null || submitResult === void 0 || (_submitResult$data = submitResult.data) === null || _submitResult$data === void 0 ? void 0 : _submitResult$data.order_id) !== null && _submitResult$data$or !== void 0 ? _submitResult$data$or : submitResult === null || submitResult === void 0 ? void 0 : submitResult.order_id) !== null && _ref42 !== void 0 ? _ref42 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref41 !== void 0 ? _ref41 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
|
|
4931
5376
|
if (orderId) {
|
|
4932
|
-
|
|
5377
|
+
_context55.next = 10;
|
|
4933
5378
|
break;
|
|
4934
5379
|
}
|
|
4935
5380
|
throw new Error('本地订单提交云端失败,无法发送支付链接');
|
|
4936
5381
|
case 10:
|
|
4937
5382
|
orderIds = [orderId];
|
|
4938
5383
|
case 11:
|
|
4939
|
-
return
|
|
5384
|
+
return _context55.abrupt("return", this.store.order.sendCustomerPayLink({
|
|
4940
5385
|
emails: params.emails,
|
|
4941
5386
|
notify_action: params.notify_action,
|
|
4942
5387
|
order_ids: orderIds
|
|
4943
5388
|
}));
|
|
4944
5389
|
case 12:
|
|
4945
5390
|
case "end":
|
|
4946
|
-
return
|
|
5391
|
+
return _context55.stop();
|
|
4947
5392
|
}
|
|
4948
|
-
},
|
|
5393
|
+
}, _callee55, this);
|
|
4949
5394
|
}));
|
|
4950
|
-
function sendCustomerPayLink(
|
|
5395
|
+
function sendCustomerPayLink(_x46) {
|
|
4951
5396
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
4952
5397
|
}
|
|
4953
5398
|
return sendCustomerPayLink;
|
|
@@ -4960,42 +5405,56 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4960
5405
|
}, {
|
|
4961
5406
|
key: "calculateProductBookingPrice",
|
|
4962
5407
|
value: function () {
|
|
4963
|
-
var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5408
|
+
var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(params) {
|
|
4964
5409
|
var _params$customer_id;
|
|
4965
|
-
var quotation, customerId, authoritativeProduct, product;
|
|
4966
|
-
return _regeneratorRuntime().wrap(function
|
|
4967
|
-
while (1) switch (
|
|
5410
|
+
var useCustomerUserPricing, quotation, customerId, channel, _yield$this$resolvePr, _yield$this$resolvePr2, authoritativeProduct, product;
|
|
5411
|
+
return _regeneratorRuntime().wrap(function _callee56$(_context56) {
|
|
5412
|
+
while (1) switch (_context56.prev = _context56.next) {
|
|
4968
5413
|
case 0:
|
|
4969
|
-
|
|
5414
|
+
useCustomerUserPricing = this.isCustomerUserPriceQuery();
|
|
5415
|
+
quotation = useCustomerUserPricing ? undefined : this.store.quotation;
|
|
4970
5416
|
customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : this.getCurrentOrderCustomerId();
|
|
4971
|
-
|
|
5417
|
+
_context56.next = 5;
|
|
4972
5418
|
return this.prepareProductPriceQueryContext(customerId);
|
|
4973
|
-
case
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
5419
|
+
case 5:
|
|
5420
|
+
channel = this.getPriceQueryChannel(params.channel);
|
|
5421
|
+
_context56.next = 8;
|
|
5422
|
+
return this.resolveProductsForPriceQuery({
|
|
5423
|
+
priceQueries: [params],
|
|
5424
|
+
schedule: this.getPriceQuerySchedule(params),
|
|
5425
|
+
customerId: customerId,
|
|
5426
|
+
channel: channel
|
|
5427
|
+
});
|
|
5428
|
+
case 8:
|
|
5429
|
+
_yield$this$resolvePr = _context56.sent;
|
|
5430
|
+
_yield$this$resolvePr2 = _slicedToArray(_yield$this$resolvePr, 1);
|
|
5431
|
+
authoritativeProduct = _yield$this$resolvePr2[0];
|
|
4978
5432
|
product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
|
|
4979
|
-
|
|
5433
|
+
if (useCustomerUserPricing) {
|
|
5434
|
+
_context56.next = 15;
|
|
5435
|
+
break;
|
|
5436
|
+
}
|
|
5437
|
+
_context56.next = 15;
|
|
4980
5438
|
return this.loadQuotationForPriceQuery({
|
|
4981
5439
|
quotation: quotation,
|
|
4982
5440
|
customer_id: customerId,
|
|
4983
|
-
channel:
|
|
5441
|
+
channel: channel
|
|
4984
5442
|
});
|
|
4985
|
-
case
|
|
4986
|
-
return
|
|
5443
|
+
case 15:
|
|
5444
|
+
return _context56.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
|
|
5445
|
+
channel: channel,
|
|
4987
5446
|
product: product,
|
|
4988
5447
|
fallback_price: authoritativeProduct ? undefined : params.fallback_price,
|
|
4989
5448
|
customer_id: customerId,
|
|
4990
5449
|
quotation: authoritativeProduct && this.preferAuthoritativeProductQueryPrice() ? undefined : quotation
|
|
4991
5450
|
})));
|
|
4992
|
-
case
|
|
5451
|
+
case 16:
|
|
4993
5452
|
case "end":
|
|
4994
|
-
return
|
|
5453
|
+
return _context56.stop();
|
|
4995
5454
|
}
|
|
4996
|
-
},
|
|
5455
|
+
}, _callee56, this);
|
|
4997
5456
|
}));
|
|
4998
|
-
function calculateProductBookingPrice(
|
|
5457
|
+
function calculateProductBookingPrice(_x47) {
|
|
4999
5458
|
return _calculateProductBookingPrice.apply(this, arguments);
|
|
5000
5459
|
}
|
|
5001
5460
|
return calculateProductBookingPrice;
|
|
@@ -5003,7 +5462,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5003
5462
|
}, {
|
|
5004
5463
|
key: "getQuotationCustomerScopeInfo",
|
|
5005
5464
|
value: function getQuotationCustomerScopeInfo() {
|
|
5006
|
-
var
|
|
5465
|
+
var _this17 = this;
|
|
5007
5466
|
var quotation = this.store.quotation;
|
|
5008
5467
|
if (quotation && typeof quotation.getQuotationCustomerScopeInfo === 'function') {
|
|
5009
5468
|
return quotation.getQuotationCustomerScopeInfo();
|
|
@@ -5015,7 +5474,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5015
5474
|
}).map(function (item) {
|
|
5016
5475
|
var localSeen = new Set();
|
|
5017
5476
|
var customers = item.customer.filter(function (customer) {
|
|
5018
|
-
var customerId =
|
|
5477
|
+
var customerId = _this17.normalizePriceContextCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
|
|
5019
5478
|
if (!customerId || localSeen.has(customerId)) return false;
|
|
5020
5479
|
localSeen.add(customerId);
|
|
5021
5480
|
if (!customerById.has(customerId)) customerById.set(customerId, customer);
|
|
@@ -5042,8 +5501,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5042
5501
|
}, {
|
|
5043
5502
|
key: "hasSmartPricingStrategies",
|
|
5044
5503
|
value: function hasSmartPricingStrategies() {
|
|
5045
|
-
var _this$
|
|
5046
|
-
var evaluator = (_this$
|
|
5504
|
+
var _this$core4;
|
|
5505
|
+
var evaluator = (_this$core4 = this.core) === null || _this$core4 === void 0 || (_this$core4 = _this$core4.context) === null || _this$core4 === void 0 ? void 0 : _this$core4.dataVariantEvaluator;
|
|
5047
5506
|
if (!evaluator || typeof evaluator.getStrategyConfigs !== 'function') {
|
|
5048
5507
|
return false;
|
|
5049
5508
|
}
|
|
@@ -5053,15 +5512,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5053
5512
|
}, {
|
|
5054
5513
|
key: "shouldRecalculateProductBookingPricesForContextChange",
|
|
5055
5514
|
value: function shouldRecalculateProductBookingPricesForContextChange(params) {
|
|
5056
|
-
var scopeInfo = this.getQuotationCustomerScopeInfo();
|
|
5057
|
-
var scopedCustomerIds = new Set(scopeInfo.customerIds.map(function (id) {
|
|
5058
|
-
return String(id);
|
|
5059
|
-
}));
|
|
5060
5515
|
var previousCustomerId = this.normalizePriceContextCustomerId(params.previousCustomerId);
|
|
5061
5516
|
var nextCustomerId = this.normalizePriceContextCustomerId(params.nextCustomerId);
|
|
5062
|
-
if (this.hasSmartPricingStrategies()) {
|
|
5517
|
+
if (this.isCustomerUserPriceQuery() || this.hasSmartPricingStrategies()) {
|
|
5063
5518
|
return previousCustomerId !== nextCustomerId;
|
|
5064
5519
|
}
|
|
5520
|
+
var scopeInfo = this.getQuotationCustomerScopeInfo();
|
|
5521
|
+
var scopedCustomerIds = new Set(scopeInfo.customerIds.map(function (id) {
|
|
5522
|
+
return String(id);
|
|
5523
|
+
}));
|
|
5065
5524
|
var previousInScope = previousCustomerId ? scopedCustomerIds.has(previousCustomerId) : false;
|
|
5066
5525
|
var nextInScope = nextCustomerId ? scopedCustomerIds.has(nextCustomerId) : false;
|
|
5067
5526
|
var shouldRecalculate = false;
|
|
@@ -5079,103 +5538,123 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5079
5538
|
}, {
|
|
5080
5539
|
key: "calculateProductBookingPrices",
|
|
5081
5540
|
value: function () {
|
|
5082
|
-
var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5083
|
-
var
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
var quotation, customerId, productMapsByGroup, groups;
|
|
5088
|
-
return _regeneratorRuntime().wrap(function _callee55$(_context55) {
|
|
5089
|
-
while (1) switch (_context55.prev = _context55.next) {
|
|
5541
|
+
var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(paramsList) {
|
|
5542
|
+
var _this18 = this;
|
|
5543
|
+
var useCustomerUserPricing, quotation, currentOrderCustomerId, resolvedChannels, authoritativeProducts, groups, quotationContexts;
|
|
5544
|
+
return _regeneratorRuntime().wrap(function _callee58$(_context58) {
|
|
5545
|
+
while (1) switch (_context58.prev = _context58.next) {
|
|
5090
5546
|
case 0:
|
|
5091
5547
|
if (paramsList.length) {
|
|
5092
|
-
|
|
5548
|
+
_context58.next = 2;
|
|
5093
5549
|
break;
|
|
5094
5550
|
}
|
|
5095
|
-
return
|
|
5551
|
+
return _context58.abrupt("return", []);
|
|
5096
5552
|
case 2:
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5553
|
+
useCustomerUserPricing = this.isCustomerUserPriceQuery();
|
|
5554
|
+
quotation = useCustomerUserPricing ? undefined : this.store.quotation;
|
|
5555
|
+
currentOrderCustomerId = this.getCurrentOrderCustomerId();
|
|
5556
|
+
resolvedChannels = paramsList.map(function (params) {
|
|
5557
|
+
return _this18.getPriceQueryChannel(params.channel);
|
|
5558
|
+
});
|
|
5559
|
+
authoritativeProducts = paramsList.map(function () {
|
|
5560
|
+
return null;
|
|
5561
|
+
});
|
|
5103
5562
|
groups = new Map();
|
|
5104
|
-
paramsList.forEach(function (params) {
|
|
5105
|
-
var
|
|
5106
|
-
var
|
|
5107
|
-
var
|
|
5108
|
-
|
|
5109
|
-
var
|
|
5110
|
-
var channel = params.channel || ((_this16$otherParams = _this16.otherParams) === null || _this16$otherParams === void 0 ? void 0 : _this16$otherParams.channel);
|
|
5111
|
-
var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || ''].join('|');
|
|
5563
|
+
paramsList.forEach(function (params, index) {
|
|
5564
|
+
var _params$customer_id2;
|
|
5565
|
+
var schedule = _this18.getPriceQuerySchedule(params);
|
|
5566
|
+
var channel = resolvedChannels[index];
|
|
5567
|
+
var customerId = (_params$customer_id2 = params.customer_id) !== null && _params$customer_id2 !== void 0 ? _params$customer_id2 : currentOrderCustomerId;
|
|
5568
|
+
var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || '', _this18.normalizePriceContextCustomerId(customerId) || ''].join('|');
|
|
5112
5569
|
var group = groups.get(groupKey) || {
|
|
5113
|
-
|
|
5570
|
+
indices: [],
|
|
5114
5571
|
schedule: schedule,
|
|
5572
|
+
customerId: customerId,
|
|
5115
5573
|
channel: channel
|
|
5116
5574
|
};
|
|
5117
|
-
group.
|
|
5575
|
+
group.indices.push(index);
|
|
5118
5576
|
groups.set(groupKey, group);
|
|
5119
5577
|
});
|
|
5120
|
-
|
|
5121
|
-
return Promise.all(Array.from(groups.
|
|
5122
|
-
var
|
|
5123
|
-
var
|
|
5124
|
-
return _regeneratorRuntime().wrap(function
|
|
5125
|
-
while (1) switch (
|
|
5578
|
+
_context58.next = 11;
|
|
5579
|
+
return Promise.all(Array.from(groups.values()).map( /*#__PURE__*/function () {
|
|
5580
|
+
var _ref43 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(group) {
|
|
5581
|
+
var priceQueries, resolvedProducts;
|
|
5582
|
+
return _regeneratorRuntime().wrap(function _callee57$(_context57) {
|
|
5583
|
+
while (1) switch (_context57.prev = _context57.next) {
|
|
5126
5584
|
case 0:
|
|
5127
|
-
|
|
5128
|
-
|
|
5129
|
-
|
|
5130
|
-
|
|
5585
|
+
_context57.next = 2;
|
|
5586
|
+
return _this18.prepareProductPriceQueryContext(group.customerId);
|
|
5587
|
+
case 2:
|
|
5588
|
+
priceQueries = group.indices.map(function (index) {
|
|
5589
|
+
return paramsList[index];
|
|
5590
|
+
});
|
|
5591
|
+
_context57.next = 5;
|
|
5592
|
+
return _this18.resolveProductsForPriceQuery({
|
|
5593
|
+
priceQueries: priceQueries,
|
|
5131
5594
|
schedule: group.schedule,
|
|
5132
|
-
customerId: customerId,
|
|
5595
|
+
customerId: group.customerId,
|
|
5133
5596
|
channel: group.channel
|
|
5134
5597
|
});
|
|
5135
|
-
case 3:
|
|
5136
|
-
productsById = _context54.sent;
|
|
5137
|
-
productMapsByGroup.set(groupKey, productsById);
|
|
5138
5598
|
case 5:
|
|
5599
|
+
resolvedProducts = _context57.sent;
|
|
5600
|
+
group.indices.forEach(function (originalIndex, groupIndex) {
|
|
5601
|
+
authoritativeProducts[originalIndex] = resolvedProducts[groupIndex] || null;
|
|
5602
|
+
});
|
|
5603
|
+
case 7:
|
|
5139
5604
|
case "end":
|
|
5140
|
-
return
|
|
5605
|
+
return _context57.stop();
|
|
5141
5606
|
}
|
|
5142
|
-
},
|
|
5607
|
+
}, _callee57);
|
|
5143
5608
|
}));
|
|
5144
|
-
return function (
|
|
5145
|
-
return
|
|
5609
|
+
return function (_x49) {
|
|
5610
|
+
return _ref43.apply(this, arguments);
|
|
5146
5611
|
};
|
|
5147
5612
|
}()));
|
|
5148
5613
|
case 11:
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
5614
|
+
if (useCustomerUserPricing) {
|
|
5615
|
+
_context58.next = 16;
|
|
5616
|
+
break;
|
|
5617
|
+
}
|
|
5618
|
+
quotationContexts = new Map();
|
|
5619
|
+
paramsList.forEach(function (params, index) {
|
|
5620
|
+
var _params$customer_id3;
|
|
5621
|
+
var channel = resolvedChannels[index];
|
|
5622
|
+
var key = channel || '';
|
|
5623
|
+
if (quotationContexts.has(key)) return;
|
|
5624
|
+
quotationContexts.set(key, {
|
|
5625
|
+
channel: channel,
|
|
5626
|
+
customer_id: (_params$customer_id3 = params.customer_id) !== null && _params$customer_id3 !== void 0 ? _params$customer_id3 : currentOrderCustomerId
|
|
5627
|
+
});
|
|
5154
5628
|
});
|
|
5155
|
-
|
|
5156
|
-
return
|
|
5157
|
-
|
|
5629
|
+
_context58.next = 16;
|
|
5630
|
+
return Promise.all(Array.from(quotationContexts.values()).map(function (context) {
|
|
5631
|
+
return _this18.loadQuotationForPriceQuery(_objectSpread({
|
|
5632
|
+
quotation: quotation
|
|
5633
|
+
}, context));
|
|
5634
|
+
}));
|
|
5635
|
+
case 16:
|
|
5636
|
+
return _context58.abrupt("return", paramsList.map(function (params, index) {
|
|
5637
|
+
var _params$customer_id4;
|
|
5158
5638
|
var productInput = params.product || {};
|
|
5159
|
-
var
|
|
5160
|
-
var
|
|
5161
|
-
var
|
|
5162
|
-
var
|
|
5163
|
-
var authoritativeProduct = productId === null ? null : ((_productMapsByGroup$g = productMapsByGroup.get(groupKey)) === null || _productMapsByGroup$g === void 0 ? void 0 : _productMapsByGroup$g.get(productId)) || null;
|
|
5164
|
-
var product = _this16.mergeProductForPriceQuery(productInput, authoritativeProduct);
|
|
5639
|
+
var authoritativeProduct = authoritativeProducts[index];
|
|
5640
|
+
var product = _this18.mergeProductForPriceQuery(productInput, authoritativeProduct);
|
|
5641
|
+
var customerId = (_params$customer_id4 = params.customer_id) !== null && _params$customer_id4 !== void 0 ? _params$customer_id4 : currentOrderCustomerId;
|
|
5642
|
+
var channel = resolvedChannels[index];
|
|
5165
5643
|
return calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
|
|
5644
|
+
channel: channel,
|
|
5166
5645
|
product: product,
|
|
5167
5646
|
fallback_price: authoritativeProduct ? undefined : params.fallback_price,
|
|
5168
5647
|
customer_id: customerId,
|
|
5169
|
-
quotation: authoritativeProduct &&
|
|
5648
|
+
quotation: authoritativeProduct && _this18.preferAuthoritativeProductQueryPrice() ? undefined : quotation
|
|
5170
5649
|
}));
|
|
5171
5650
|
}));
|
|
5172
|
-
case
|
|
5651
|
+
case 17:
|
|
5173
5652
|
case "end":
|
|
5174
|
-
return
|
|
5653
|
+
return _context58.stop();
|
|
5175
5654
|
}
|
|
5176
|
-
},
|
|
5655
|
+
}, _callee58, this);
|
|
5177
5656
|
}));
|
|
5178
|
-
function calculateProductBookingPrices(
|
|
5657
|
+
function calculateProductBookingPrices(_x48) {
|
|
5179
5658
|
return _calculateProductBookingPrices.apply(this, arguments);
|
|
5180
5659
|
}
|
|
5181
5660
|
return calculateProductBookingPrices;
|
|
@@ -5183,34 +5662,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5183
5662
|
}, {
|
|
5184
5663
|
key: "addProductToOrder",
|
|
5185
5664
|
value: function () {
|
|
5186
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5665
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(product, booking, options) {
|
|
5187
5666
|
var products;
|
|
5188
|
-
return _regeneratorRuntime().wrap(function
|
|
5189
|
-
while (1) switch (
|
|
5667
|
+
return _regeneratorRuntime().wrap(function _callee59$(_context59) {
|
|
5668
|
+
while (1) switch (_context59.prev = _context59.next) {
|
|
5190
5669
|
case 0:
|
|
5191
|
-
|
|
5670
|
+
_context59.prev = 0;
|
|
5192
5671
|
if (this.store.order) {
|
|
5193
|
-
|
|
5672
|
+
_context59.next = 3;
|
|
5194
5673
|
break;
|
|
5195
5674
|
}
|
|
5196
5675
|
throw new Error('order 模块未初始化');
|
|
5197
5676
|
case 3:
|
|
5198
|
-
|
|
5677
|
+
_context59.next = 5;
|
|
5199
5678
|
return this.store.order.addProductToOrder(product, booking, options);
|
|
5200
5679
|
case 5:
|
|
5201
|
-
products =
|
|
5202
|
-
return
|
|
5680
|
+
products = _context59.sent;
|
|
5681
|
+
return _context59.abrupt("return", products);
|
|
5203
5682
|
case 9:
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
throw
|
|
5683
|
+
_context59.prev = 9;
|
|
5684
|
+
_context59.t0 = _context59["catch"](0);
|
|
5685
|
+
throw _context59.t0;
|
|
5207
5686
|
case 12:
|
|
5208
5687
|
case "end":
|
|
5209
|
-
return
|
|
5688
|
+
return _context59.stop();
|
|
5210
5689
|
}
|
|
5211
|
-
},
|
|
5690
|
+
}, _callee59, this, [[0, 9]]);
|
|
5212
5691
|
}));
|
|
5213
|
-
function addProductToOrder(
|
|
5692
|
+
function addProductToOrder(_x50, _x51, _x52) {
|
|
5214
5693
|
return _addProductToOrder.apply(this, arguments);
|
|
5215
5694
|
}
|
|
5216
5695
|
return addProductToOrder;
|
|
@@ -5218,34 +5697,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5218
5697
|
}, {
|
|
5219
5698
|
key: "updateOrderProduct",
|
|
5220
5699
|
value: function () {
|
|
5221
|
-
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5700
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(params) {
|
|
5222
5701
|
var products;
|
|
5223
|
-
return _regeneratorRuntime().wrap(function
|
|
5224
|
-
while (1) switch (
|
|
5702
|
+
return _regeneratorRuntime().wrap(function _callee60$(_context60) {
|
|
5703
|
+
while (1) switch (_context60.prev = _context60.next) {
|
|
5225
5704
|
case 0:
|
|
5226
|
-
|
|
5705
|
+
_context60.prev = 0;
|
|
5227
5706
|
if (this.store.order) {
|
|
5228
|
-
|
|
5707
|
+
_context60.next = 3;
|
|
5229
5708
|
break;
|
|
5230
5709
|
}
|
|
5231
5710
|
throw new Error('order 模块未初始化');
|
|
5232
5711
|
case 3:
|
|
5233
|
-
|
|
5712
|
+
_context60.next = 5;
|
|
5234
5713
|
return this.store.order.updateOrderProduct(params);
|
|
5235
5714
|
case 5:
|
|
5236
|
-
products =
|
|
5237
|
-
return
|
|
5715
|
+
products = _context60.sent;
|
|
5716
|
+
return _context60.abrupt("return", products);
|
|
5238
5717
|
case 9:
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
throw
|
|
5718
|
+
_context60.prev = 9;
|
|
5719
|
+
_context60.t0 = _context60["catch"](0);
|
|
5720
|
+
throw _context60.t0;
|
|
5242
5721
|
case 12:
|
|
5243
5722
|
case "end":
|
|
5244
|
-
return
|
|
5723
|
+
return _context60.stop();
|
|
5245
5724
|
}
|
|
5246
|
-
},
|
|
5725
|
+
}, _callee60, this, [[0, 9]]);
|
|
5247
5726
|
}));
|
|
5248
|
-
function updateOrderProduct(
|
|
5727
|
+
function updateOrderProduct(_x53) {
|
|
5249
5728
|
return _updateOrderProduct.apply(this, arguments);
|
|
5250
5729
|
}
|
|
5251
5730
|
return updateOrderProduct;
|
|
@@ -5253,34 +5732,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5253
5732
|
}, {
|
|
5254
5733
|
key: "updateOrderProducts",
|
|
5255
5734
|
value: function () {
|
|
5256
|
-
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5735
|
+
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(paramsList) {
|
|
5257
5736
|
var products;
|
|
5258
|
-
return _regeneratorRuntime().wrap(function
|
|
5259
|
-
while (1) switch (
|
|
5737
|
+
return _regeneratorRuntime().wrap(function _callee61$(_context61) {
|
|
5738
|
+
while (1) switch (_context61.prev = _context61.next) {
|
|
5260
5739
|
case 0:
|
|
5261
|
-
|
|
5740
|
+
_context61.prev = 0;
|
|
5262
5741
|
if (this.store.order) {
|
|
5263
|
-
|
|
5742
|
+
_context61.next = 3;
|
|
5264
5743
|
break;
|
|
5265
5744
|
}
|
|
5266
5745
|
throw new Error('order 模块未初始化');
|
|
5267
5746
|
case 3:
|
|
5268
|
-
|
|
5747
|
+
_context61.next = 5;
|
|
5269
5748
|
return this.store.order.updateOrderProducts(paramsList);
|
|
5270
5749
|
case 5:
|
|
5271
|
-
products =
|
|
5272
|
-
return
|
|
5750
|
+
products = _context61.sent;
|
|
5751
|
+
return _context61.abrupt("return", products);
|
|
5273
5752
|
case 9:
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
throw
|
|
5753
|
+
_context61.prev = 9;
|
|
5754
|
+
_context61.t0 = _context61["catch"](0);
|
|
5755
|
+
throw _context61.t0;
|
|
5277
5756
|
case 12:
|
|
5278
5757
|
case "end":
|
|
5279
|
-
return
|
|
5758
|
+
return _context61.stop();
|
|
5280
5759
|
}
|
|
5281
|
-
},
|
|
5760
|
+
}, _callee61, this, [[0, 9]]);
|
|
5282
5761
|
}));
|
|
5283
|
-
function updateOrderProducts(
|
|
5762
|
+
function updateOrderProducts(_x54) {
|
|
5284
5763
|
return _updateOrderProducts.apply(this, arguments);
|
|
5285
5764
|
}
|
|
5286
5765
|
return updateOrderProducts;
|
|
@@ -5288,34 +5767,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5288
5767
|
}, {
|
|
5289
5768
|
key: "updateOrderProductQuantity",
|
|
5290
5769
|
value: function () {
|
|
5291
|
-
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5770
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(params) {
|
|
5292
5771
|
var products;
|
|
5293
|
-
return _regeneratorRuntime().wrap(function
|
|
5294
|
-
while (1) switch (
|
|
5772
|
+
return _regeneratorRuntime().wrap(function _callee62$(_context62) {
|
|
5773
|
+
while (1) switch (_context62.prev = _context62.next) {
|
|
5295
5774
|
case 0:
|
|
5296
|
-
|
|
5775
|
+
_context62.prev = 0;
|
|
5297
5776
|
if (this.store.order) {
|
|
5298
|
-
|
|
5777
|
+
_context62.next = 3;
|
|
5299
5778
|
break;
|
|
5300
5779
|
}
|
|
5301
5780
|
throw new Error('order 模块未初始化');
|
|
5302
5781
|
case 3:
|
|
5303
|
-
|
|
5782
|
+
_context62.next = 5;
|
|
5304
5783
|
return this.store.order.updateOrderProductQuantity(params);
|
|
5305
5784
|
case 5:
|
|
5306
|
-
products =
|
|
5307
|
-
return
|
|
5785
|
+
products = _context62.sent;
|
|
5786
|
+
return _context62.abrupt("return", products);
|
|
5308
5787
|
case 9:
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
throw
|
|
5788
|
+
_context62.prev = 9;
|
|
5789
|
+
_context62.t0 = _context62["catch"](0);
|
|
5790
|
+
throw _context62.t0;
|
|
5312
5791
|
case 12:
|
|
5313
5792
|
case "end":
|
|
5314
|
-
return
|
|
5793
|
+
return _context62.stop();
|
|
5315
5794
|
}
|
|
5316
|
-
},
|
|
5795
|
+
}, _callee62, this, [[0, 9]]);
|
|
5317
5796
|
}));
|
|
5318
|
-
function updateOrderProductQuantity(
|
|
5797
|
+
function updateOrderProductQuantity(_x55) {
|
|
5319
5798
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
5320
5799
|
}
|
|
5321
5800
|
return updateOrderProductQuantity;
|
|
@@ -5338,12 +5817,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5338
5817
|
}, {
|
|
5339
5818
|
key: "setOrderProductLineNote",
|
|
5340
5819
|
value: (function () {
|
|
5341
|
-
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5820
|
+
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(identity, note) {
|
|
5342
5821
|
var params, products;
|
|
5343
|
-
return _regeneratorRuntime().wrap(function
|
|
5344
|
-
while (1) switch (
|
|
5822
|
+
return _regeneratorRuntime().wrap(function _callee63$(_context63) {
|
|
5823
|
+
while (1) switch (_context63.prev = _context63.next) {
|
|
5345
5824
|
case 0:
|
|
5346
|
-
|
|
5825
|
+
_context63.prev = 0;
|
|
5347
5826
|
params = {
|
|
5348
5827
|
product_id: identity.product_id,
|
|
5349
5828
|
product_variant_id: identity.product_variant_id,
|
|
@@ -5358,22 +5837,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5358
5837
|
params.product_sku = identity.product_sku;
|
|
5359
5838
|
}
|
|
5360
5839
|
if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
|
|
5361
|
-
|
|
5840
|
+
_context63.next = 7;
|
|
5362
5841
|
return this.updateOrderProduct(params);
|
|
5363
5842
|
case 7:
|
|
5364
|
-
products =
|
|
5365
|
-
return
|
|
5843
|
+
products = _context63.sent;
|
|
5844
|
+
return _context63.abrupt("return", products);
|
|
5366
5845
|
case 11:
|
|
5367
|
-
|
|
5368
|
-
|
|
5369
|
-
throw
|
|
5846
|
+
_context63.prev = 11;
|
|
5847
|
+
_context63.t0 = _context63["catch"](0);
|
|
5848
|
+
throw _context63.t0;
|
|
5370
5849
|
case 14:
|
|
5371
5850
|
case "end":
|
|
5372
|
-
return
|
|
5851
|
+
return _context63.stop();
|
|
5373
5852
|
}
|
|
5374
|
-
},
|
|
5853
|
+
}, _callee63, this, [[0, 11]]);
|
|
5375
5854
|
}));
|
|
5376
|
-
function setOrderProductLineNote(
|
|
5855
|
+
function setOrderProductLineNote(_x56, _x57) {
|
|
5377
5856
|
return _setOrderProductLineNote.apply(this, arguments);
|
|
5378
5857
|
}
|
|
5379
5858
|
return setOrderProductLineNote;
|
|
@@ -5388,32 +5867,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5388
5867
|
}, {
|
|
5389
5868
|
key: "removeProductsFromOrder",
|
|
5390
5869
|
value: (function () {
|
|
5391
|
-
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5392
|
-
return _regeneratorRuntime().wrap(function
|
|
5393
|
-
while (1) switch (
|
|
5870
|
+
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(identities, options) {
|
|
5871
|
+
return _regeneratorRuntime().wrap(function _callee64$(_context64) {
|
|
5872
|
+
while (1) switch (_context64.prev = _context64.next) {
|
|
5394
5873
|
case 0:
|
|
5395
|
-
|
|
5874
|
+
_context64.prev = 0;
|
|
5396
5875
|
if (this.store.order) {
|
|
5397
|
-
|
|
5876
|
+
_context64.next = 3;
|
|
5398
5877
|
break;
|
|
5399
5878
|
}
|
|
5400
5879
|
throw new Error('order 模块未初始化');
|
|
5401
5880
|
case 3:
|
|
5402
|
-
|
|
5881
|
+
_context64.next = 5;
|
|
5403
5882
|
return this.store.order.removeProductsFromOrder(identities, options);
|
|
5404
5883
|
case 5:
|
|
5405
|
-
return
|
|
5884
|
+
return _context64.abrupt("return", _context64.sent);
|
|
5406
5885
|
case 8:
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
throw
|
|
5886
|
+
_context64.prev = 8;
|
|
5887
|
+
_context64.t0 = _context64["catch"](0);
|
|
5888
|
+
throw _context64.t0;
|
|
5410
5889
|
case 11:
|
|
5411
5890
|
case "end":
|
|
5412
|
-
return
|
|
5891
|
+
return _context64.stop();
|
|
5413
5892
|
}
|
|
5414
|
-
},
|
|
5893
|
+
}, _callee64, this, [[0, 8]]);
|
|
5415
5894
|
}));
|
|
5416
|
-
function removeProductsFromOrder(
|
|
5895
|
+
function removeProductsFromOrder(_x58, _x59) {
|
|
5417
5896
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
5418
5897
|
}
|
|
5419
5898
|
return removeProductsFromOrder;
|
|
@@ -5421,18 +5900,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5421
5900
|
}, {
|
|
5422
5901
|
key: "removeProductFromOrder",
|
|
5423
5902
|
value: function () {
|
|
5424
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5425
|
-
return _regeneratorRuntime().wrap(function
|
|
5426
|
-
while (1) switch (
|
|
5903
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(identity, options) {
|
|
5904
|
+
return _regeneratorRuntime().wrap(function _callee65$(_context65) {
|
|
5905
|
+
while (1) switch (_context65.prev = _context65.next) {
|
|
5427
5906
|
case 0:
|
|
5428
|
-
return
|
|
5907
|
+
return _context65.abrupt("return", this.removeProductsFromOrder([identity], options));
|
|
5429
5908
|
case 1:
|
|
5430
5909
|
case "end":
|
|
5431
|
-
return
|
|
5910
|
+
return _context65.stop();
|
|
5432
5911
|
}
|
|
5433
|
-
},
|
|
5912
|
+
}, _callee65, this);
|
|
5434
5913
|
}));
|
|
5435
|
-
function removeProductFromOrder(
|
|
5914
|
+
function removeProductFromOrder(_x60, _x61) {
|
|
5436
5915
|
return _removeProductFromOrder.apply(this, arguments);
|
|
5437
5916
|
}
|
|
5438
5917
|
return removeProductFromOrder;
|
|
@@ -5482,23 +5961,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5482
5961
|
}, {
|
|
5483
5962
|
key: "applyPromotion",
|
|
5484
5963
|
value: (function () {
|
|
5485
|
-
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5486
|
-
return _regeneratorRuntime().wrap(function
|
|
5487
|
-
while (1) switch (
|
|
5964
|
+
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66() {
|
|
5965
|
+
return _regeneratorRuntime().wrap(function _callee66$(_context66) {
|
|
5966
|
+
while (1) switch (_context66.prev = _context66.next) {
|
|
5488
5967
|
case 0:
|
|
5489
5968
|
if (this.store.order) {
|
|
5490
|
-
|
|
5969
|
+
_context66.next = 2;
|
|
5491
5970
|
break;
|
|
5492
5971
|
}
|
|
5493
5972
|
throw new Error('order 模块未初始化');
|
|
5494
5973
|
case 2:
|
|
5495
|
-
|
|
5974
|
+
_context66.next = 4;
|
|
5496
5975
|
return this.store.order.applyPromotion();
|
|
5497
5976
|
case 4:
|
|
5498
5977
|
case "end":
|
|
5499
|
-
return
|
|
5978
|
+
return _context66.stop();
|
|
5500
5979
|
}
|
|
5501
|
-
},
|
|
5980
|
+
}, _callee66, this);
|
|
5502
5981
|
}));
|
|
5503
5982
|
function applyPromotion() {
|
|
5504
5983
|
return _applyPromotion.apply(this, arguments);
|
|
@@ -5525,18 +6004,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5525
6004
|
}, {
|
|
5526
6005
|
key: "getProductList",
|
|
5527
6006
|
value: function () {
|
|
5528
|
-
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6007
|
+
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67() {
|
|
5529
6008
|
var _this$otherParams35;
|
|
5530
6009
|
var menu_list_ids, _this$store$products, res;
|
|
5531
|
-
return _regeneratorRuntime().wrap(function
|
|
5532
|
-
while (1) switch (
|
|
6010
|
+
return _regeneratorRuntime().wrap(function _callee67$(_context67) {
|
|
6011
|
+
while (1) switch (_context67.prev = _context67.next) {
|
|
5533
6012
|
case 0:
|
|
5534
6013
|
// 可以直接通过配置里的 menu 读取
|
|
5535
6014
|
menu_list_ids = ((_this$otherParams35 = this.otherParams) === null || _this$otherParams35 === void 0 || (_this$otherParams35 = _this$otherParams35.dineInConfig) === null || _this$otherParams35 === void 0 ? void 0 : _this$otherParams35['menu.associated_menus'].map(function (n) {
|
|
5536
6015
|
return Number(n.value);
|
|
5537
6016
|
})) || [];
|
|
5538
|
-
|
|
5539
|
-
|
|
6017
|
+
_context67.prev = 1;
|
|
6018
|
+
_context67.next = 4;
|
|
5540
6019
|
return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
|
|
5541
6020
|
menu_list_ids: menu_list_ids,
|
|
5542
6021
|
cacheId: this.cacheId,
|
|
@@ -5544,17 +6023,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5544
6023
|
schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
5545
6024
|
});
|
|
5546
6025
|
case 4:
|
|
5547
|
-
res =
|
|
5548
|
-
return
|
|
6026
|
+
res = _context67.sent;
|
|
6027
|
+
return _context67.abrupt("return", res);
|
|
5549
6028
|
case 8:
|
|
5550
|
-
|
|
5551
|
-
|
|
5552
|
-
throw
|
|
6029
|
+
_context67.prev = 8;
|
|
6030
|
+
_context67.t0 = _context67["catch"](1);
|
|
6031
|
+
throw _context67.t0;
|
|
5553
6032
|
case 11:
|
|
5554
6033
|
case "end":
|
|
5555
|
-
return
|
|
6034
|
+
return _context67.stop();
|
|
5556
6035
|
}
|
|
5557
|
-
},
|
|
6036
|
+
}, _callee67, this, [[1, 8]]);
|
|
5558
6037
|
}));
|
|
5559
6038
|
function getProductList() {
|
|
5560
6039
|
return _getProductList.apply(this, arguments);
|
|
@@ -5569,33 +6048,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5569
6048
|
}, {
|
|
5570
6049
|
key: "setOtherParams",
|
|
5571
6050
|
value: function () {
|
|
5572
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6051
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(params) {
|
|
5573
6052
|
var _this$otherParams36;
|
|
5574
|
-
var
|
|
5575
|
-
|
|
6053
|
+
var _ref44,
|
|
6054
|
+
_ref44$cover,
|
|
5576
6055
|
cover,
|
|
5577
|
-
|
|
5578
|
-
return _regeneratorRuntime().wrap(function
|
|
5579
|
-
while (1) switch (
|
|
6056
|
+
_args68 = arguments;
|
|
6057
|
+
return _regeneratorRuntime().wrap(function _callee68$(_context68) {
|
|
6058
|
+
while (1) switch (_context68.prev = _context68.next) {
|
|
5580
6059
|
case 0:
|
|
5581
|
-
|
|
6060
|
+
_ref44 = _args68.length > 1 && _args68[1] !== undefined ? _args68[1] : {}, _ref44$cover = _ref44.cover, cover = _ref44$cover === void 0 ? false : _ref44$cover;
|
|
5582
6061
|
if (cover) {
|
|
5583
6062
|
this.otherParams = _objectSpread({}, params);
|
|
5584
6063
|
} else {
|
|
5585
6064
|
this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
|
|
5586
6065
|
}
|
|
5587
6066
|
this.cacheId = (_this$otherParams36 = this.otherParams) === null || _this$otherParams36 === void 0 ? void 0 : _this$otherParams36.cacheId;
|
|
5588
|
-
|
|
6067
|
+
_context68.next = 5;
|
|
5589
6068
|
return this.syncOtherParamsToSubModules(params, {
|
|
5590
6069
|
cover: cover
|
|
5591
6070
|
});
|
|
5592
6071
|
case 5:
|
|
5593
6072
|
case "end":
|
|
5594
|
-
return
|
|
6073
|
+
return _context68.stop();
|
|
5595
6074
|
}
|
|
5596
|
-
},
|
|
6075
|
+
}, _callee68, this);
|
|
5597
6076
|
}));
|
|
5598
|
-
function setOtherParams(
|
|
6077
|
+
function setOtherParams(_x62) {
|
|
5599
6078
|
return _setOtherParams.apply(this, arguments);
|
|
5600
6079
|
}
|
|
5601
6080
|
return setOtherParams;
|