@pisell/pisellos 0.10.43 → 0.10.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/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/modules/Order/index.d.ts +41 -9
- package/dist/modules/Order/index.js +1438 -878
- package/dist/modules/Order/salesNotes.d.ts +31 -0
- package/dist/modules/Order/salesNotes.js +492 -0
- package/dist/modules/Order/types.d.ts +105 -8
- package/dist/modules/Order/types.js +6 -1
- package/dist/modules/Order/utils.d.ts +3 -1
- package/dist/modules/Order/utils.js +191 -71
- package/dist/modules/Payment/cashRecommendationAlgorithm.d.ts +4 -5
- package/dist/modules/Payment/cashRecommendationAlgorithm.js +17 -367
- package/dist/modules/ProductList/index.d.ts +2 -1
- package/dist/modules/ProductList/index.js +100 -20
- package/dist/modules/ProductList/types.d.ts +10 -0
- package/dist/server/index.d.ts +7 -0
- package/dist/server/index.js +45 -3
- package/dist/server/modules/order/index.js +6 -0
- package/dist/server/modules/order/types.d.ts +9 -0
- package/dist/server/utils/small-ticket.d.ts +1 -0
- package/dist/server/utils/small-ticket.js +142 -14
- package/dist/solution/BaseSales/index.d.ts +15 -1
- package/dist/solution/BaseSales/index.js +1240 -877
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -0
- package/dist/solution/BookingTicket/index.js +37 -16
- 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/utils.d.ts +1 -0
- package/dist/solution/ScanOrder/utils.js +2 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +15 -2
- package/dist/solution/UnifiedBookingSales/index.js +777 -510
- package/dist/solution/UnifiedBookingSales/types.d.ts +14 -1
- package/dist/solution/VenueBooking/index.d.ts +1 -0
- package/dist/solution/VenueBooking/index.js +8 -4
- 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/Order/index.d.ts +41 -9
- package/lib/modules/Order/index.js +434 -61
- package/lib/modules/Order/salesNotes.d.ts +31 -0
- package/lib/modules/Order/salesNotes.js +382 -0
- package/lib/modules/Order/types.d.ts +105 -8
- package/lib/modules/Order/types.js +5 -1
- package/lib/modules/Order/utils.d.ts +3 -1
- package/lib/modules/Order/utils.js +114 -1
- package/lib/modules/Payment/cashRecommendationAlgorithm.d.ts +4 -5
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +9 -354
- package/lib/modules/ProductList/index.d.ts +2 -1
- package/lib/modules/ProductList/index.js +47 -2
- package/lib/modules/ProductList/types.d.ts +10 -0
- package/lib/server/index.d.ts +7 -0
- package/lib/server/index.js +39 -3
- package/lib/server/modules/order/index.js +6 -0
- package/lib/server/modules/order/types.d.ts +9 -0
- package/lib/server/utils/small-ticket.d.ts +1 -0
- package/lib/server/utils/small-ticket.js +136 -12
- package/lib/solution/BaseSales/index.d.ts +15 -1
- package/lib/solution/BaseSales/index.js +192 -22
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -0
- package/lib/solution/BookingTicket/index.js +23 -5
- 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/utils.d.ts +1 -0
- package/lib/solution/ScanOrder/utils.js +1 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +15 -2
- package/lib/solution/UnifiedBookingSales/index.js +125 -1
- package/lib/solution/UnifiedBookingSales/types.d.ts +14 -1
- package/lib/solution/VenueBooking/index.d.ts +1 -0
- package/lib/solution/VenueBooking/index.js +5 -1
- 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 { buildCurrencyDisplaySnapshot, getTempOrderSettlementSnapshot, isVirtualSettlementOrder } from "../../modules/Order/utils/virtualSettlement";
|
|
@@ -341,7 +341,67 @@ function mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey) {
|
|
|
341
341
|
loadedValue.forEach(appendOrReplaceByUid);
|
|
342
342
|
return result;
|
|
343
343
|
}
|
|
344
|
+
|
|
345
|
+
// checkout / realtime snapshots may reorder protocol arrays or append persistence fields.
|
|
346
|
+
// Compare only the Sales Note protocol fields so a matching remote echo can acknowledge dirty state.
|
|
347
|
+
function normalizeBaseSalesNotesForComparison(value, options) {
|
|
348
|
+
var _options$unresolvedOr;
|
|
349
|
+
if (!Array.isArray(value)) return null;
|
|
350
|
+
var unresolvedOrderTargetUuid = String((_options$unresolvedOr = options === null || options === void 0 ? void 0 : options.unresolvedOrderTargetUuid) !== null && _options$unresolvedOr !== void 0 ? _options$unresolvedOr : '').trim();
|
|
351
|
+
return value.map(function (note) {
|
|
352
|
+
var _noteRecord$content;
|
|
353
|
+
if (!note || _typeof(note) !== 'object' || Array.isArray(note)) {
|
|
354
|
+
return cloneDeep(note);
|
|
355
|
+
}
|
|
356
|
+
var noteRecord = note;
|
|
357
|
+
var relations = Array.isArray(noteRecord.note_relations) ? noteRecord.note_relations.map(function (relation) {
|
|
358
|
+
var _relation$target_uuid;
|
|
359
|
+
if (!relation || _typeof(relation) !== 'object' || Array.isArray(relation)) {
|
|
360
|
+
return cloneDeep(relation);
|
|
361
|
+
}
|
|
362
|
+
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;
|
|
363
|
+
return {
|
|
364
|
+
uuid: relation.uuid,
|
|
365
|
+
relation_type: relation.relation_type,
|
|
366
|
+
target_type: relation.target_type,
|
|
367
|
+
target_uuid: shouldResolveOrderTarget ? unresolvedOrderTargetUuid : relation.target_uuid,
|
|
368
|
+
is_primary: relation.is_primary
|
|
369
|
+
};
|
|
370
|
+
}).sort(function (left, right) {
|
|
371
|
+
var _left$uuid, _right$uuid;
|
|
372
|
+
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 : ''));
|
|
373
|
+
}) : cloneDeep(noteRecord.note_relations);
|
|
374
|
+
return {
|
|
375
|
+
uuid: noteRecord.uuid,
|
|
376
|
+
note_type: noteRecord.note_type,
|
|
377
|
+
content: {
|
|
378
|
+
text: cloneDeep((_noteRecord$content = noteRecord.content) === null || _noteRecord$content === void 0 ? void 0 : _noteRecord$content.text)
|
|
379
|
+
},
|
|
380
|
+
importance: noteRecord.importance,
|
|
381
|
+
note_relations: relations
|
|
382
|
+
};
|
|
383
|
+
}).sort(function (left, right) {
|
|
384
|
+
var _left$uuid2, _right$uuid2;
|
|
385
|
+
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 : ''));
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
function areBaseSalesNotesEquivalent(currentValue, loadedValue, options) {
|
|
389
|
+
var currentNotes = normalizeBaseSalesNotesForComparison(currentValue, {
|
|
390
|
+
unresolvedOrderTargetUuid: options === null || options === void 0 ? void 0 : options.currentOrderTargetUuid
|
|
391
|
+
});
|
|
392
|
+
var loadedNotes = normalizeBaseSalesNotesForComparison(loadedValue);
|
|
393
|
+
return currentNotes !== null && loadedNotes !== null && isEqual(currentNotes, loadedNotes);
|
|
394
|
+
}
|
|
344
395
|
function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, strategy) {
|
|
396
|
+
var _currentTempOrder$_ex, _normalizedLoadedReco;
|
|
397
|
+
var loadedHasOrderMetaList = Object.prototype.hasOwnProperty.call(loadedRecord || {}, 'order_meta_list');
|
|
398
|
+
var loadedHasSalesNotes = Object.prototype.hasOwnProperty.call(loadedRecord || {}, 'notes');
|
|
399
|
+
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;
|
|
400
|
+
var incomingSalesNotesMatchLocal = loadedHasSalesNotes && areBaseSalesNotesEquivalent(currentTempOrder === null || currentTempOrder === void 0 ? void 0 : currentTempOrder.notes, loadedRecord.notes, {
|
|
401
|
+
currentOrderTargetUuid: (loadedRecord === null || loadedRecord === void 0 ? void 0 : loadedRecord.shop_order_number) || (currentTempOrder === null || currentTempOrder === void 0 ? void 0 : currentTempOrder.shop_order_number)
|
|
402
|
+
});
|
|
403
|
+
var shouldAwaitAuthoritativeSalesNotes = strategy === 'authoritative-incoming' && hasDirtyLocalSalesNotes && (Number(loadedRecord === null || loadedRecord === void 0 ? void 0 : loadedRecord.need_sync) === 1 || !incomingSalesNotesMatchLocal);
|
|
404
|
+
var preserveDirtyLocalSalesNotes = hasDirtyLocalSalesNotes && (strategy === 'preserve-local' || shouldAwaitAuthoritativeSalesNotes);
|
|
345
405
|
var normalizedLoadedRecord = normalizeBaseSalesRecordCollections(loadedRecord || {}, {
|
|
346
406
|
ensureUid: false
|
|
347
407
|
});
|
|
@@ -353,6 +413,18 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, str
|
|
|
353
413
|
});
|
|
354
414
|
var uidRemaps = [];
|
|
355
415
|
var mergedRecord = mergeWith(normalizedCurrentTempOrder, normalizedLoadedRecord, function (currentValue, loadedValue, key) {
|
|
416
|
+
// order_meta_list 是服务端/本地订单携带的完整业务快照。若 incoming
|
|
417
|
+
// 明确提供它,必须整体替换;若省略,则保留当前值,避免 snapshot
|
|
418
|
+
// 数组递归拼接后出现同 ID 的旧数据。
|
|
419
|
+
if (key === 'order_meta_list') {
|
|
420
|
+
return cloneDeep(loadedHasOrderMetaList ? loadedValue : currentValue);
|
|
421
|
+
}
|
|
422
|
+
if (key === 'notes') {
|
|
423
|
+
if (preserveDirtyLocalSalesNotes && Array.isArray(currentValue)) {
|
|
424
|
+
return cloneDeep(currentValue);
|
|
425
|
+
}
|
|
426
|
+
if (Array.isArray(loadedValue)) return cloneDeep(loadedValue);
|
|
427
|
+
}
|
|
356
428
|
// small_ticket_data 是由 Server 一次性生成的完整展示快照,不能递归进入
|
|
357
429
|
// locale 内部继续套用订单集合或普通数组的合并规则。
|
|
358
430
|
if (key === 'small_ticket_data') {
|
|
@@ -381,7 +453,23 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, str
|
|
|
381
453
|
return undefined;
|
|
382
454
|
});
|
|
383
455
|
delete mergedRecord.request_unique_idempotency_token;
|
|
384
|
-
|
|
456
|
+
var normalizedMergedRecord = normalizeBaseSalesRecordCollections(applyOrderCollectionUidRemaps(mergedRecord, uidRemaps));
|
|
457
|
+
normalizedMergedRecord._extend = _objectSpread(_objectSpread({}, normalizedMergedRecord._extend || {}), {}, {
|
|
458
|
+
salesNotesState: preserveDirtyLocalSalesNotes ? {
|
|
459
|
+
loaded: true,
|
|
460
|
+
dirty: true
|
|
461
|
+
} : loadedHasSalesNotes ? {
|
|
462
|
+
loaded: true,
|
|
463
|
+
dirty: ((_normalizedLoadedReco = normalizedLoadedRecord._extend) === null || _normalizedLoadedReco === void 0 || (_normalizedLoadedReco = _normalizedLoadedReco.salesNotesState) === null || _normalizedLoadedReco === void 0 ? void 0 : _normalizedLoadedReco.dirty) === true
|
|
464
|
+
} : {
|
|
465
|
+
loaded: false,
|
|
466
|
+
dirty: false
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
if (!loadedHasSalesNotes && !preserveDirtyLocalSalesNotes) {
|
|
470
|
+
delete normalizedMergedRecord.notes;
|
|
471
|
+
}
|
|
472
|
+
return normalizedMergedRecord;
|
|
385
473
|
}
|
|
386
474
|
function filterPendingPaymentsFromLoadedSalesDetail(sourceRecord) {
|
|
387
475
|
if (!sourceRecord || _typeof(sourceRecord) !== 'object') return sourceRecord;
|
|
@@ -2192,6 +2280,101 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2192
2280
|
if (!this.store.order) return '';
|
|
2193
2281
|
return this.store.order.getTempOrderNote();
|
|
2194
2282
|
}
|
|
2283
|
+
}, {
|
|
2284
|
+
key: "getSalesNotes",
|
|
2285
|
+
value: function getSalesNotes() {
|
|
2286
|
+
if (!this.store.order) return [];
|
|
2287
|
+
return this.store.order.getSalesNotes();
|
|
2288
|
+
}
|
|
2289
|
+
}, {
|
|
2290
|
+
key: "createSalesNotesMutationSnapshot",
|
|
2291
|
+
value: function createSalesNotesMutationSnapshot() {
|
|
2292
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
2293
|
+
return this.store.order.createSalesNotesMutationSnapshot();
|
|
2294
|
+
}
|
|
2295
|
+
}, {
|
|
2296
|
+
key: "restoreSalesNotesMutationSnapshot",
|
|
2297
|
+
value: function restoreSalesNotesMutationSnapshot(snapshot) {
|
|
2298
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
2299
|
+
this.store.order.restoreSalesNotesMutationSnapshot(snapshot);
|
|
2300
|
+
}
|
|
2301
|
+
}, {
|
|
2302
|
+
key: "setSalesNote",
|
|
2303
|
+
value: function () {
|
|
2304
|
+
var _setSalesNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(input) {
|
|
2305
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
2306
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
2307
|
+
case 0:
|
|
2308
|
+
if (this.store.order) {
|
|
2309
|
+
_context16.next = 2;
|
|
2310
|
+
break;
|
|
2311
|
+
}
|
|
2312
|
+
throw new Error('order 模块未初始化');
|
|
2313
|
+
case 2:
|
|
2314
|
+
return _context16.abrupt("return", this.store.order.setSalesNote(input));
|
|
2315
|
+
case 3:
|
|
2316
|
+
case "end":
|
|
2317
|
+
return _context16.stop();
|
|
2318
|
+
}
|
|
2319
|
+
}, _callee16, this);
|
|
2320
|
+
}));
|
|
2321
|
+
function setSalesNote(_x15) {
|
|
2322
|
+
return _setSalesNote.apply(this, arguments);
|
|
2323
|
+
}
|
|
2324
|
+
return setSalesNote;
|
|
2325
|
+
}()
|
|
2326
|
+
}, {
|
|
2327
|
+
key: "removeSalesNote",
|
|
2328
|
+
value: function () {
|
|
2329
|
+
var _removeSalesNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(uuid) {
|
|
2330
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
2331
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
2332
|
+
case 0:
|
|
2333
|
+
if (this.store.order) {
|
|
2334
|
+
_context17.next = 2;
|
|
2335
|
+
break;
|
|
2336
|
+
}
|
|
2337
|
+
throw new Error('order 模块未初始化');
|
|
2338
|
+
case 2:
|
|
2339
|
+
_context17.next = 4;
|
|
2340
|
+
return this.store.order.removeSalesNote(uuid);
|
|
2341
|
+
case 4:
|
|
2342
|
+
case "end":
|
|
2343
|
+
return _context17.stop();
|
|
2344
|
+
}
|
|
2345
|
+
}, _callee17, this);
|
|
2346
|
+
}));
|
|
2347
|
+
function removeSalesNote(_x16) {
|
|
2348
|
+
return _removeSalesNote.apply(this, arguments);
|
|
2349
|
+
}
|
|
2350
|
+
return removeSalesNote;
|
|
2351
|
+
}()
|
|
2352
|
+
}, {
|
|
2353
|
+
key: "clearSalesNotes",
|
|
2354
|
+
value: function () {
|
|
2355
|
+
var _clearSalesNotes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
2356
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
2357
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
2358
|
+
case 0:
|
|
2359
|
+
if (this.store.order) {
|
|
2360
|
+
_context18.next = 2;
|
|
2361
|
+
break;
|
|
2362
|
+
}
|
|
2363
|
+
throw new Error('order 模块未初始化');
|
|
2364
|
+
case 2:
|
|
2365
|
+
_context18.next = 4;
|
|
2366
|
+
return this.store.order.clearSalesNotes();
|
|
2367
|
+
case 4:
|
|
2368
|
+
case "end":
|
|
2369
|
+
return _context18.stop();
|
|
2370
|
+
}
|
|
2371
|
+
}, _callee18, this);
|
|
2372
|
+
}));
|
|
2373
|
+
function clearSalesNotes() {
|
|
2374
|
+
return _clearSalesNotes.apply(this, arguments);
|
|
2375
|
+
}
|
|
2376
|
+
return clearSalesNotes;
|
|
2377
|
+
}()
|
|
2195
2378
|
}, {
|
|
2196
2379
|
key: "updateTempOrderNote",
|
|
2197
2380
|
value: function updateTempOrderNote(note) {
|
|
@@ -2230,6 +2413,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2230
2413
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
2231
2414
|
return this.store.order.updateTempOrderDepositAmount(amount);
|
|
2232
2415
|
}
|
|
2416
|
+
}, {
|
|
2417
|
+
key: "setPickupReferenceMode",
|
|
2418
|
+
value: function setPickupReferenceMode(mode) {
|
|
2419
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
2420
|
+
return this.store.order.updateTempOrderPickupReferenceMode(mode);
|
|
2421
|
+
}
|
|
2422
|
+
}, {
|
|
2423
|
+
key: "setServiceType",
|
|
2424
|
+
value: function setServiceType(serviceType) {
|
|
2425
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
2426
|
+
return this.store.order.updateTempOrderServiceType(serviceType);
|
|
2427
|
+
}
|
|
2233
2428
|
}, {
|
|
2234
2429
|
key: "updateTempOrderContactsInfo",
|
|
2235
2430
|
value: function updateTempOrderContactsInfo(contactsInfo) {
|
|
@@ -2263,40 +2458,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2263
2458
|
}, {
|
|
2264
2459
|
key: "addNewOrder",
|
|
2265
2460
|
value: function () {
|
|
2266
|
-
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2461
|
+
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
|
|
2267
2462
|
var tempOrder;
|
|
2268
|
-
return _regeneratorRuntime().wrap(function
|
|
2269
|
-
while (1) switch (
|
|
2463
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
2464
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
2270
2465
|
case 0:
|
|
2271
|
-
|
|
2466
|
+
_context19.prev = 0;
|
|
2272
2467
|
if (this.store.order) {
|
|
2273
|
-
|
|
2468
|
+
_context19.next = 3;
|
|
2274
2469
|
break;
|
|
2275
2470
|
}
|
|
2276
2471
|
throw new Error('order 模块未初始化');
|
|
2277
2472
|
case 3:
|
|
2278
|
-
|
|
2473
|
+
_context19.next = 5;
|
|
2279
2474
|
return this.store.order.addNewOrder();
|
|
2280
2475
|
case 5:
|
|
2281
|
-
tempOrder =
|
|
2476
|
+
tempOrder = _context19.sent;
|
|
2282
2477
|
if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
|
|
2283
|
-
|
|
2478
|
+
_context19.next = 10;
|
|
2284
2479
|
break;
|
|
2285
2480
|
}
|
|
2286
2481
|
this.store.order.persistTempOrder();
|
|
2287
|
-
|
|
2482
|
+
_context19.next = 10;
|
|
2288
2483
|
return this.store.order.saveDraft();
|
|
2289
2484
|
case 10:
|
|
2290
|
-
return
|
|
2485
|
+
return _context19.abrupt("return", tempOrder);
|
|
2291
2486
|
case 13:
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
throw
|
|
2487
|
+
_context19.prev = 13;
|
|
2488
|
+
_context19.t0 = _context19["catch"](0);
|
|
2489
|
+
throw _context19.t0;
|
|
2295
2490
|
case 16:
|
|
2296
2491
|
case "end":
|
|
2297
|
-
return
|
|
2492
|
+
return _context19.stop();
|
|
2298
2493
|
}
|
|
2299
|
-
},
|
|
2494
|
+
}, _callee19, this, [[0, 13]]);
|
|
2300
2495
|
}));
|
|
2301
2496
|
function addNewOrder() {
|
|
2302
2497
|
return _addNewOrder.apply(this, arguments);
|
|
@@ -2306,22 +2501,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2306
2501
|
}, {
|
|
2307
2502
|
key: "saveDraft",
|
|
2308
2503
|
value: function () {
|
|
2309
|
-
var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2310
|
-
return _regeneratorRuntime().wrap(function
|
|
2311
|
-
while (1) switch (
|
|
2504
|
+
var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
2505
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
2506
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
2312
2507
|
case 0:
|
|
2313
2508
|
if (this.store.order) {
|
|
2314
|
-
|
|
2509
|
+
_context20.next = 2;
|
|
2315
2510
|
break;
|
|
2316
2511
|
}
|
|
2317
2512
|
throw new Error('order 模块未初始化');
|
|
2318
2513
|
case 2:
|
|
2319
|
-
return
|
|
2514
|
+
return _context20.abrupt("return", this.store.order.saveDraft());
|
|
2320
2515
|
case 3:
|
|
2321
2516
|
case "end":
|
|
2322
|
-
return
|
|
2517
|
+
return _context20.stop();
|
|
2323
2518
|
}
|
|
2324
|
-
},
|
|
2519
|
+
}, _callee20, this);
|
|
2325
2520
|
}));
|
|
2326
2521
|
function saveDraft() {
|
|
2327
2522
|
return _saveDraft.apply(this, arguments);
|
|
@@ -2332,14 +2527,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2332
2527
|
}, {
|
|
2333
2528
|
key: "restoreOrder",
|
|
2334
2529
|
value: function () {
|
|
2335
|
-
var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2530
|
+
var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
2336
2531
|
var _this$store$payment, tempOrder, appDataChanged, wallet;
|
|
2337
|
-
return _regeneratorRuntime().wrap(function
|
|
2338
|
-
while (1) switch (
|
|
2532
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
2533
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
2339
2534
|
case 0:
|
|
2340
|
-
|
|
2535
|
+
_context21.prev = 0;
|
|
2341
2536
|
if (this.store.order) {
|
|
2342
|
-
|
|
2537
|
+
_context21.next = 3;
|
|
2343
2538
|
break;
|
|
2344
2539
|
}
|
|
2345
2540
|
throw new Error('scanOrder 解决方案需要 order 模块支持');
|
|
@@ -2352,37 +2547,37 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2352
2547
|
this.hasManualDiscountSelection = false;
|
|
2353
2548
|
wallet = (_this$store$payment = this.store.payment) === null || _this$store$payment === void 0 ? void 0 : _this$store$payment.wallet;
|
|
2354
2549
|
if (!wallet) {
|
|
2355
|
-
|
|
2550
|
+
_context21.next = 14;
|
|
2356
2551
|
break;
|
|
2357
2552
|
}
|
|
2358
2553
|
this.walletAssetsRefreshSequence += 1;
|
|
2359
2554
|
wallet.clearAllCache();
|
|
2360
|
-
|
|
2555
|
+
_context21.next = 14;
|
|
2361
2556
|
return this.publishWalletAssetsState(wallet.getWalletAssetsState());
|
|
2362
2557
|
case 14:
|
|
2363
|
-
|
|
2558
|
+
_context21.next = 16;
|
|
2364
2559
|
return this.effectsEmit('onTempOrderReplaced', {
|
|
2365
2560
|
tempOrder: tempOrder
|
|
2366
2561
|
});
|
|
2367
2562
|
case 16:
|
|
2368
2563
|
if (!(appDataChanged && this.isTempOrderPersistEnabled())) {
|
|
2369
|
-
|
|
2564
|
+
_context21.next = 20;
|
|
2370
2565
|
break;
|
|
2371
2566
|
}
|
|
2372
2567
|
this.store.order.persistTempOrder();
|
|
2373
|
-
|
|
2568
|
+
_context21.next = 20;
|
|
2374
2569
|
return this.store.order.saveDraft();
|
|
2375
2570
|
case 20:
|
|
2376
|
-
return
|
|
2571
|
+
return _context21.abrupt("return", tempOrder);
|
|
2377
2572
|
case 23:
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
throw
|
|
2573
|
+
_context21.prev = 23;
|
|
2574
|
+
_context21.t0 = _context21["catch"](0);
|
|
2575
|
+
throw _context21.t0;
|
|
2381
2576
|
case 26:
|
|
2382
2577
|
case "end":
|
|
2383
|
-
return
|
|
2578
|
+
return _context21.stop();
|
|
2384
2579
|
}
|
|
2385
|
-
},
|
|
2580
|
+
}, _callee21, this, [[0, 23]]);
|
|
2386
2581
|
}));
|
|
2387
2582
|
function restoreOrder() {
|
|
2388
2583
|
return _restoreOrder.apply(this, arguments);
|
|
@@ -2396,22 +2591,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2396
2591
|
}, {
|
|
2397
2592
|
key: "clearOrderCartLines",
|
|
2398
2593
|
value: (function () {
|
|
2399
|
-
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2594
|
+
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
|
|
2400
2595
|
var tempOrder;
|
|
2401
|
-
return _regeneratorRuntime().wrap(function
|
|
2402
|
-
while (1) switch (
|
|
2596
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
2597
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
2403
2598
|
case 0:
|
|
2404
|
-
|
|
2599
|
+
_context22.prev = 0;
|
|
2405
2600
|
if (this.store.order) {
|
|
2406
|
-
|
|
2601
|
+
_context22.next = 3;
|
|
2407
2602
|
break;
|
|
2408
2603
|
}
|
|
2409
2604
|
throw new Error('order 模块未初始化');
|
|
2410
2605
|
case 3:
|
|
2411
|
-
|
|
2606
|
+
_context22.next = 5;
|
|
2412
2607
|
return this.store.order.clearOrderCartLines();
|
|
2413
2608
|
case 5:
|
|
2414
|
-
tempOrder =
|
|
2609
|
+
tempOrder = _context22.sent;
|
|
2415
2610
|
if (this.currentSalesDetail) {
|
|
2416
2611
|
this.currentSalesDetail = _objectSpread(_objectSpread({}, this.currentSalesDetail), {}, {
|
|
2417
2612
|
products: [],
|
|
@@ -2421,29 +2616,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2421
2616
|
discount_list: []
|
|
2422
2617
|
});
|
|
2423
2618
|
}
|
|
2424
|
-
|
|
2619
|
+
_context22.next = 9;
|
|
2425
2620
|
return this.effectsEmit('onTempOrderReplaced', {
|
|
2426
2621
|
tempOrder: tempOrder
|
|
2427
2622
|
});
|
|
2428
2623
|
case 9:
|
|
2429
2624
|
if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
|
|
2430
|
-
|
|
2625
|
+
_context22.next = 13;
|
|
2431
2626
|
break;
|
|
2432
2627
|
}
|
|
2433
2628
|
this.store.order.persistTempOrder();
|
|
2434
|
-
|
|
2629
|
+
_context22.next = 13;
|
|
2435
2630
|
return this.store.order.saveDraft();
|
|
2436
2631
|
case 13:
|
|
2437
|
-
return
|
|
2632
|
+
return _context22.abrupt("return", tempOrder);
|
|
2438
2633
|
case 16:
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
throw
|
|
2634
|
+
_context22.prev = 16;
|
|
2635
|
+
_context22.t0 = _context22["catch"](0);
|
|
2636
|
+
throw _context22.t0;
|
|
2442
2637
|
case 19:
|
|
2443
2638
|
case "end":
|
|
2444
|
-
return
|
|
2639
|
+
return _context22.stop();
|
|
2445
2640
|
}
|
|
2446
|
-
},
|
|
2641
|
+
}, _callee22, this, [[0, 16]]);
|
|
2447
2642
|
}));
|
|
2448
2643
|
function clearOrderCartLines() {
|
|
2449
2644
|
return _clearOrderCartLines.apply(this, arguments);
|
|
@@ -2453,21 +2648,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2453
2648
|
}, {
|
|
2454
2649
|
key: "clearOrderForSettlementSwitch",
|
|
2455
2650
|
value: (function () {
|
|
2456
|
-
var _clearOrderForSettlementSwitch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2651
|
+
var _clearOrderForSettlementSwitch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
2457
2652
|
var tempOrder;
|
|
2458
|
-
return _regeneratorRuntime().wrap(function
|
|
2459
|
-
while (1) switch (
|
|
2653
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
2654
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
2460
2655
|
case 0:
|
|
2461
2656
|
if (this.store.order) {
|
|
2462
|
-
|
|
2657
|
+
_context23.next = 2;
|
|
2463
2658
|
break;
|
|
2464
2659
|
}
|
|
2465
2660
|
throw new Error('order 模块未初始化');
|
|
2466
2661
|
case 2:
|
|
2467
|
-
|
|
2662
|
+
_context23.next = 4;
|
|
2468
2663
|
return this.store.order.clearOrderForSettlementSwitch();
|
|
2469
2664
|
case 4:
|
|
2470
|
-
tempOrder =
|
|
2665
|
+
tempOrder = _context23.sent;
|
|
2471
2666
|
if (this.currentSalesDetail) {
|
|
2472
2667
|
this.currentSalesDetail = _objectSpread(_objectSpread({}, this.currentSalesDetail), {}, {
|
|
2473
2668
|
products: [],
|
|
@@ -2478,12 +2673,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2478
2673
|
payments: []
|
|
2479
2674
|
});
|
|
2480
2675
|
}
|
|
2481
|
-
return
|
|
2676
|
+
return _context23.abrupt("return", tempOrder);
|
|
2482
2677
|
case 7:
|
|
2483
2678
|
case "end":
|
|
2484
|
-
return
|
|
2679
|
+
return _context23.stop();
|
|
2485
2680
|
}
|
|
2486
|
-
},
|
|
2681
|
+
}, _callee23, this);
|
|
2487
2682
|
}));
|
|
2488
2683
|
function clearOrderForSettlementSwitch() {
|
|
2489
2684
|
return _clearOrderForSettlementSwitch.apply(this, arguments);
|
|
@@ -2500,32 +2695,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2500
2695
|
}, {
|
|
2501
2696
|
key: "getSummary",
|
|
2502
2697
|
value: function () {
|
|
2503
|
-
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2698
|
+
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
2504
2699
|
var summary;
|
|
2505
|
-
return _regeneratorRuntime().wrap(function
|
|
2506
|
-
while (1) switch (
|
|
2700
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
2701
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
2507
2702
|
case 0:
|
|
2508
|
-
|
|
2703
|
+
_context24.prev = 0;
|
|
2509
2704
|
if (this.store.order) {
|
|
2510
|
-
|
|
2705
|
+
_context24.next = 3;
|
|
2511
2706
|
break;
|
|
2512
2707
|
}
|
|
2513
2708
|
throw new Error('order 模块未初始化');
|
|
2514
2709
|
case 3:
|
|
2515
|
-
|
|
2710
|
+
_context24.next = 5;
|
|
2516
2711
|
return this.store.order.getOrderSummary();
|
|
2517
2712
|
case 5:
|
|
2518
|
-
summary =
|
|
2519
|
-
return
|
|
2713
|
+
summary = _context24.sent;
|
|
2714
|
+
return _context24.abrupt("return", summary);
|
|
2520
2715
|
case 9:
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
throw
|
|
2716
|
+
_context24.prev = 9;
|
|
2717
|
+
_context24.t0 = _context24["catch"](0);
|
|
2718
|
+
throw _context24.t0;
|
|
2524
2719
|
case 12:
|
|
2525
2720
|
case "end":
|
|
2526
|
-
return
|
|
2721
|
+
return _context24.stop();
|
|
2527
2722
|
}
|
|
2528
|
-
},
|
|
2723
|
+
}, _callee24, this, [[0, 9]]);
|
|
2529
2724
|
}));
|
|
2530
2725
|
function getSummary() {
|
|
2531
2726
|
return _getSummary.apply(this, arguments);
|
|
@@ -2650,17 +2845,45 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2650
2845
|
return discount;
|
|
2651
2846
|
});
|
|
2652
2847
|
}
|
|
2848
|
+
}, {
|
|
2849
|
+
key: "resolveDiscountConfigCustomerId",
|
|
2850
|
+
value: function resolveDiscountConfigCustomerId(tempOrder) {
|
|
2851
|
+
var _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2;
|
|
2852
|
+
return Number((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.customer_id) || (tempOrder === null || tempOrder === void 0 || (_tempOrder$customer = tempOrder.customer) === null || _tempOrder$customer === void 0 ? void 0 : _tempOrder$customer.id) || (tempOrder === null || tempOrder === void 0 || (_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 || (_tempOrder$_extend = _tempOrder$_extend.customerSnapshot) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend.id) || (tempOrder === null || tempOrder === void 0 || (_tempOrder$_extend2 = tempOrder._extend) === null || _tempOrder$_extend2 === void 0 || (_tempOrder$_extend2 = _tempOrder$_extend2.customerSnapshot) === null || _tempOrder$_extend2 === void 0 ? void 0 : _tempOrder$_extend2.customer_id) || 0);
|
|
2853
|
+
}
|
|
2854
|
+
|
|
2855
|
+
/**
|
|
2856
|
+
* Stable across notifyTempOrderChanged's immutable object replacement, while
|
|
2857
|
+
* still distinguishing two local orders for the same customer.
|
|
2858
|
+
*/
|
|
2859
|
+
}, {
|
|
2860
|
+
key: "getDiscountConfigOrderIdentityKey",
|
|
2861
|
+
value: function getDiscountConfigOrderIdentityKey(tempOrder) {
|
|
2862
|
+
var _this$store$order4, _this$store$order4$ge, _ref42, _identity$orderId, _tempOrder$request_un, _ref43, _identity$externalSal, _ref44, _ref45, _identity$localId, _tempOrder$_extend3;
|
|
2863
|
+
var identity = (_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 || (_this$store$order4$ge = _this$store$order4.getOrderIdentity) === null || _this$store$order4$ge === void 0 ? void 0 : _this$store$order4$ge.call(_this$store$order4);
|
|
2864
|
+
return JSON.stringify([(_ref42 = (_identity$orderId = identity === null || identity === void 0 ? void 0 : identity.orderId) !== null && _identity$orderId !== void 0 ? _identity$orderId : tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.order_id) !== null && _ref42 !== void 0 ? _ref42 : '', (_tempOrder$request_un = tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.request_unique_idempotency_token) !== null && _tempOrder$request_un !== void 0 ? _tempOrder$request_un : '', (_ref43 = (_identity$externalSal = identity === null || identity === void 0 ? void 0 : identity.externalSaleNumber) !== null && _identity$externalSal !== void 0 ? _identity$externalSal : tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.external_sale_number) !== null && _ref43 !== void 0 ? _ref43 : '', (_ref44 = (_ref45 = (_identity$localId = identity === null || identity === void 0 ? void 0 : identity.localId) !== null && _identity$localId !== void 0 ? _identity$localId : tempOrder === null || tempOrder === void 0 || (_tempOrder$_extend3 = tempOrder._extend) === null || _tempOrder$_extend3 === void 0 ? void 0 : _tempOrder$_extend3.localId) !== null && _ref45 !== void 0 ? _ref45 : this.cacheId) !== null && _ref44 !== void 0 ? _ref44 : '']);
|
|
2865
|
+
}
|
|
2653
2866
|
}, {
|
|
2654
2867
|
key: "loadDiscountConfig",
|
|
2655
2868
|
value: function () {
|
|
2656
|
-
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2657
|
-
var _this$
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2869
|
+
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
|
|
2870
|
+
var _this$store$order$get2,
|
|
2871
|
+
_this$store$order5,
|
|
2872
|
+
_tempOrder$customer2,
|
|
2873
|
+
_tempOrder$_extend4,
|
|
2874
|
+
_tempOrder$_extend5,
|
|
2875
|
+
_discountModule$getDi,
|
|
2876
|
+
_discountModule$getOr,
|
|
2877
|
+
_this$store$order$get3,
|
|
2878
|
+
_this$store$order6,
|
|
2879
|
+
_this15 = this,
|
|
2880
|
+
_discountModule$getDi3;
|
|
2881
|
+
var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, requestOrderIdentityKey, discountConfigCacheKey, requestEpoch, isCurrentRequest, getCurrentResult, searchedDiscountList, searchedDiscountIds, preparedDiscountList, _this$store$order$get4, _this$store$order7, _discountModule$setOr, prepareConfigPromise, _discountModule$setOr2, _discountModule$setDi, nextDiscountList, shouldSkipAutoApplyFetchedDiscounts, _orderStore$summary, orderTotalAmount, result, _iterator3, _step3, _product$metadata5, _tempOrder$_extend6, _product$metadata$sou, _product$metadata6, _product$metadata7, _product$original_pri, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
|
|
2882
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
2883
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
2661
2884
|
case 0:
|
|
2662
2885
|
if (this.store.order) {
|
|
2663
|
-
|
|
2886
|
+
_context25.next = 2;
|
|
2664
2887
|
break;
|
|
2665
2888
|
}
|
|
2666
2889
|
throw new Error('order 模块未初始化');
|
|
@@ -2669,76 +2892,147 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2669
2892
|
orderStore = this.store.order.store || {};
|
|
2670
2893
|
discountModule = orderStore.discount;
|
|
2671
2894
|
rulesModule = orderStore.rules;
|
|
2672
|
-
orderId = tempOrder.order_id || ((_this$
|
|
2673
|
-
customerId = Number((params === null || params === void 0 ? void 0 : params.customerId) || tempOrder.customer_id || ((_tempOrder$
|
|
2895
|
+
orderId = tempOrder.order_id || ((_this$store$order$get2 = (_this$store$order5 = this.store.order).getOrderIdentity) === null || _this$store$order$get2 === void 0 || (_this$store$order$get2 = _this$store$order$get2.call(_this$store$order5)) === null || _this$store$order$get2 === void 0 ? void 0 : _this$store$order$get2.orderId);
|
|
2896
|
+
customerId = Number((params === null || params === void 0 ? void 0 : params.customerId) || tempOrder.customer_id || ((_tempOrder$customer2 = tempOrder.customer) === null || _tempOrder$customer2 === void 0 ? void 0 : _tempOrder$customer2.id) || ((_tempOrder$_extend4 = tempOrder._extend) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4.customerSnapshot) === null || _tempOrder$_extend4 === void 0 ? void 0 : _tempOrder$_extend4.id) || ((_tempOrder$_extend5 = tempOrder._extend) === null || _tempOrder$_extend5 === void 0 || (_tempOrder$_extend5 = _tempOrder$_extend5.customerSnapshot) === null || _tempOrder$_extend5 === void 0 ? void 0 : _tempOrder$_extend5.customer_id) || 0);
|
|
2674
2897
|
currentDiscountList = (discountModule === null || discountModule === void 0 || (_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
|
|
2675
2898
|
originalDiscountList = (discountModule === null || discountModule === void 0 || (_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
|
|
2676
2899
|
hasManualDiscountSelection = this.hasManualDiscountSelection || currentDiscountList.some(function (discount) {
|
|
2677
2900
|
return discount.isManualSelect;
|
|
2678
2901
|
});
|
|
2679
2902
|
discountAction = (params === null || params === void 0 ? void 0 : params.action) || (orderId ? 'edit' : 'create');
|
|
2680
|
-
|
|
2681
|
-
|
|
2903
|
+
requestOrderIdentityKey = this.getDiscountConfigOrderIdentityKey(tempOrder);
|
|
2904
|
+
discountConfigCacheKey = JSON.stringify([customerId, discountAction, Number(orderId) || 0, requestOrderIdentityKey]);
|
|
2905
|
+
requestEpoch = (_this$store$order$get3 = (_this$store$order6 = this.store.order).getCustomerWalletPrepareConfigEpoch) === null || _this$store$order$get3 === void 0 ? void 0 : _this$store$order$get3.call(_this$store$order6);
|
|
2906
|
+
isCurrentRequest = function isCurrentRequest() {
|
|
2907
|
+
var _this15$store$order, _this15$store$order$g, _this15$store$order2, _this15$store$order2$;
|
|
2908
|
+
var currentTempOrder = (_this15$store$order = _this15.store.order) === null || _this15$store$order === void 0 || (_this15$store$order$g = _this15$store$order.getTempOrder) === null || _this15$store$order$g === void 0 ? void 0 : _this15$store$order$g.call(_this15$store$order);
|
|
2909
|
+
return Boolean(currentTempOrder && (requestEpoch === undefined || ((_this15$store$order2 = _this15.store.order) === null || _this15$store$order2 === void 0 || (_this15$store$order2$ = _this15$store$order2.getCustomerWalletPrepareConfigEpoch) === null || _this15$store$order2$ === void 0 ? void 0 : _this15$store$order2$.call(_this15$store$order2)) === requestEpoch) && _this15.resolveDiscountConfigCustomerId(currentTempOrder) === customerId && _this15.getDiscountConfigOrderIdentityKey(currentTempOrder) === requestOrderIdentityKey);
|
|
2910
|
+
};
|
|
2911
|
+
getCurrentResult = function getCurrentResult() {
|
|
2912
|
+
var _this15$store$order3, _this15$store$order3$, _discountModule$getDi2;
|
|
2913
|
+
var currentTempOrder = (_this15$store$order3 = _this15.store.order) === null || _this15$store$order3 === void 0 || (_this15$store$order3$ = _this15$store$order3.getTempOrder) === null || _this15$store$order3$ === void 0 ? void 0 : _this15$store$order3$.call(_this15$store$order3);
|
|
2914
|
+
return {
|
|
2915
|
+
productList: (currentTempOrder === null || currentTempOrder === void 0 ? void 0 : currentTempOrder.products) || [],
|
|
2916
|
+
discountList: (discountModule === null || discountModule === void 0 || (_discountModule$getDi2 = discountModule.getDiscountList) === null || _discountModule$getDi2 === void 0 ? void 0 : _discountModule$getDi2.call(discountModule)) || [],
|
|
2917
|
+
availableWalletIds: _this15.getAvailableWalletIds(),
|
|
2918
|
+
virtualCurrencyList: _this15.getVirtualCurrencyList()
|
|
2919
|
+
};
|
|
2920
|
+
}; // Walk-In 不请求 prepare config;当前搜索/扫码券必须继续参与本次重算。
|
|
2921
|
+
// current 优先于 original,保留搜索后的最新选择与可用状态。
|
|
2922
|
+
searchedDiscountList = currentDiscountList.filter(function (discount) {
|
|
2923
|
+
return discount.isScan;
|
|
2924
|
+
});
|
|
2925
|
+
searchedDiscountIds = new Set(searchedDiscountList.map(function (discount) {
|
|
2926
|
+
return String(discount.id);
|
|
2927
|
+
}));
|
|
2928
|
+
preparedDiscountList = [].concat(_toConsumableArray(searchedDiscountList), _toConsumableArray(originalDiscountList.filter(function (discount) {
|
|
2929
|
+
return !searchedDiscountIds.has(String(discount.id));
|
|
2930
|
+
})));
|
|
2682
2931
|
if (!(customerId && customerId !== 1)) {
|
|
2683
|
-
|
|
2932
|
+
_context25.next = 37;
|
|
2684
2933
|
break;
|
|
2685
2934
|
}
|
|
2686
2935
|
if (!(!(params !== null && params !== void 0 && params.force) && this.discountConfigCacheKey === discountConfigCacheKey)) {
|
|
2687
|
-
|
|
2936
|
+
_context25.next = 25;
|
|
2688
2937
|
break;
|
|
2689
2938
|
}
|
|
2690
2939
|
preparedDiscountList = originalDiscountList;
|
|
2691
|
-
|
|
2940
|
+
_context25.next = 37;
|
|
2692
2941
|
break;
|
|
2693
|
-
case
|
|
2694
|
-
|
|
2695
|
-
return this.store.order.loadDiscountConfig({
|
|
2942
|
+
case 25:
|
|
2943
|
+
prepareConfigPromise = this.store.order.loadDiscountConfig({
|
|
2696
2944
|
customerId: customerId,
|
|
2697
2945
|
action: discountAction,
|
|
2698
2946
|
orderId: Number(orderId) || undefined,
|
|
2699
2947
|
apply: false
|
|
2700
|
-
});
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2948
|
+
}); // OrderModule increments this epoch synchronously before its first await.
|
|
2949
|
+
requestEpoch = (_this$store$order$get4 = (_this$store$order7 = this.store.order).getCustomerWalletPrepareConfigEpoch) === null || _this$store$order$get4 === void 0 ? void 0 : _this$store$order$get4.call(_this$store$order7);
|
|
2950
|
+
_context25.next = 29;
|
|
2951
|
+
return prepareConfigPromise;
|
|
2952
|
+
case 29:
|
|
2953
|
+
preparedDiscountList = _context25.sent;
|
|
2954
|
+
if (isCurrentRequest()) {
|
|
2955
|
+
_context25.next = 32;
|
|
2956
|
+
break;
|
|
2957
|
+
}
|
|
2958
|
+
return _context25.abrupt("return", getCurrentResult());
|
|
2959
|
+
case 32:
|
|
2960
|
+
_context25.next = 34;
|
|
2705
2961
|
return discountModule === null || discountModule === void 0 || (_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, preparedDiscountList);
|
|
2706
|
-
case
|
|
2962
|
+
case 34:
|
|
2963
|
+
if (isCurrentRequest()) {
|
|
2964
|
+
_context25.next = 36;
|
|
2965
|
+
break;
|
|
2966
|
+
}
|
|
2967
|
+
return _context25.abrupt("return", getCurrentResult());
|
|
2968
|
+
case 36:
|
|
2969
|
+
this.discountConfigCacheKey = discountConfigCacheKey;
|
|
2970
|
+
case 37:
|
|
2707
2971
|
if (!this.isActiveVirtualSettlementOrder(tempOrder)) {
|
|
2708
|
-
|
|
2972
|
+
_context25.next = 51;
|
|
2973
|
+
break;
|
|
2974
|
+
}
|
|
2975
|
+
if (isCurrentRequest()) {
|
|
2976
|
+
_context25.next = 40;
|
|
2709
2977
|
break;
|
|
2710
2978
|
}
|
|
2711
|
-
|
|
2979
|
+
return _context25.abrupt("return", getCurrentResult());
|
|
2980
|
+
case 40:
|
|
2981
|
+
_context25.next = 42;
|
|
2712
2982
|
return discountModule === null || discountModule === void 0 || (_discountModule$setOr2 = discountModule.setOriginalDiscountList) === null || _discountModule$setOr2 === void 0 ? void 0 : _discountModule$setOr2.call(discountModule, []);
|
|
2713
|
-
case
|
|
2714
|
-
|
|
2983
|
+
case 42:
|
|
2984
|
+
if (isCurrentRequest()) {
|
|
2985
|
+
_context25.next = 44;
|
|
2986
|
+
break;
|
|
2987
|
+
}
|
|
2988
|
+
return _context25.abrupt("return", getCurrentResult());
|
|
2989
|
+
case 44:
|
|
2990
|
+
_context25.next = 46;
|
|
2715
2991
|
return discountModule === null || discountModule === void 0 || (_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, []);
|
|
2716
|
-
case
|
|
2992
|
+
case 46:
|
|
2993
|
+
if (isCurrentRequest()) {
|
|
2994
|
+
_context25.next = 48;
|
|
2995
|
+
break;
|
|
2996
|
+
}
|
|
2997
|
+
return _context25.abrupt("return", getCurrentResult());
|
|
2998
|
+
case 48:
|
|
2717
2999
|
tempOrder.discount_list = [];
|
|
2718
3000
|
tempOrder.shop_discount = '0.00';
|
|
2719
|
-
return
|
|
3001
|
+
return _context25.abrupt("return", {
|
|
2720
3002
|
productList: tempOrder.products || [],
|
|
2721
3003
|
discountList: [],
|
|
2722
3004
|
availableWalletIds: this.getAvailableWalletIds(),
|
|
2723
|
-
virtualCurrencyList: this.
|
|
3005
|
+
virtualCurrencyList: this.getVirtualCurrencyList()
|
|
2724
3006
|
});
|
|
2725
|
-
case
|
|
3007
|
+
case 51:
|
|
2726
3008
|
if (!(hasManualDiscountSelection && currentDiscountList.length)) {
|
|
2727
|
-
|
|
3009
|
+
_context25.next = 53;
|
|
2728
3010
|
break;
|
|
2729
3011
|
}
|
|
2730
|
-
return
|
|
3012
|
+
return _context25.abrupt("return", {
|
|
2731
3013
|
productList: tempOrder.products || [],
|
|
2732
3014
|
discountList: currentDiscountList,
|
|
2733
3015
|
availableWalletIds: this.getAvailableWalletIds(),
|
|
2734
|
-
virtualCurrencyList: this.
|
|
3016
|
+
virtualCurrencyList: this.getVirtualCurrencyList()
|
|
2735
3017
|
});
|
|
2736
|
-
case
|
|
2737
|
-
nextDiscountList = this.mergeHistoricalDiscountList(preparedDiscountList || (discountModule === null || discountModule === void 0 || (_discountModule$
|
|
3018
|
+
case 53:
|
|
3019
|
+
nextDiscountList = this.mergeHistoricalDiscountList(preparedDiscountList || (discountModule === null || discountModule === void 0 || (_discountModule$getDi3 = discountModule.getDiscountList) === null || _discountModule$getDi3 === void 0 ? void 0 : _discountModule$getDi3.call(discountModule)) || [], tempOrder.products || []);
|
|
2738
3020
|
nextDiscountList = this.mergeCurrentDiscountSelectionState(nextDiscountList, currentDiscountList);
|
|
2739
|
-
|
|
3021
|
+
if (isCurrentRequest()) {
|
|
3022
|
+
_context25.next = 57;
|
|
3023
|
+
break;
|
|
3024
|
+
}
|
|
3025
|
+
return _context25.abrupt("return", getCurrentResult());
|
|
3026
|
+
case 57:
|
|
3027
|
+
_context25.next = 59;
|
|
2740
3028
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
2741
|
-
case
|
|
3029
|
+
case 59:
|
|
3030
|
+
if (isCurrentRequest()) {
|
|
3031
|
+
_context25.next = 61;
|
|
3032
|
+
break;
|
|
3033
|
+
}
|
|
3034
|
+
return _context25.abrupt("return", getCurrentResult());
|
|
3035
|
+
case 61:
|
|
2742
3036
|
shouldSkipAutoApplyFetchedDiscounts = this.shouldSkipAutoApplyFetchedDiscountsInEditMode({
|
|
2743
3037
|
discountAction: discountAction,
|
|
2744
3038
|
products: tempOrder.products || [],
|
|
@@ -2746,35 +3040,58 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2746
3040
|
nextDiscountList: nextDiscountList
|
|
2747
3041
|
});
|
|
2748
3042
|
if (!shouldSkipAutoApplyFetchedDiscounts) {
|
|
2749
|
-
|
|
3043
|
+
_context25.next = 75;
|
|
2750
3044
|
break;
|
|
2751
3045
|
}
|
|
2752
|
-
|
|
3046
|
+
_context25.next = 65;
|
|
2753
3047
|
return this.store.order.recalculateSummary({
|
|
2754
3048
|
createIfMissing: true
|
|
2755
3049
|
});
|
|
2756
|
-
case
|
|
2757
|
-
|
|
3050
|
+
case 65:
|
|
3051
|
+
if (isCurrentRequest()) {
|
|
3052
|
+
_context25.next = 67;
|
|
3053
|
+
break;
|
|
3054
|
+
}
|
|
3055
|
+
return _context25.abrupt("return", getCurrentResult());
|
|
3056
|
+
case 67:
|
|
2758
3057
|
this.store.order.persistTempOrder();
|
|
2759
|
-
|
|
3058
|
+
if (isCurrentRequest()) {
|
|
3059
|
+
_context25.next = 70;
|
|
3060
|
+
break;
|
|
3061
|
+
}
|
|
3062
|
+
return _context25.abrupt("return", getCurrentResult());
|
|
3063
|
+
case 70:
|
|
3064
|
+
_context25.next = 72;
|
|
2760
3065
|
return this.effectsEmit('onDiscountApplied', {
|
|
2761
3066
|
productList: tempOrder.products || [],
|
|
2762
3067
|
discountList: nextDiscountList,
|
|
2763
3068
|
selectedDiscountList: tempOrder.discount_list || [],
|
|
2764
3069
|
tempOrder: tempOrder
|
|
2765
3070
|
});
|
|
2766
|
-
case
|
|
2767
|
-
|
|
3071
|
+
case 72:
|
|
3072
|
+
if (isCurrentRequest()) {
|
|
3073
|
+
_context25.next = 74;
|
|
3074
|
+
break;
|
|
3075
|
+
}
|
|
3076
|
+
return _context25.abrupt("return", getCurrentResult());
|
|
3077
|
+
case 74:
|
|
3078
|
+
return _context25.abrupt("return", {
|
|
2768
3079
|
productList: tempOrder.products || [],
|
|
2769
3080
|
discountList: nextDiscountList,
|
|
2770
3081
|
availableWalletIds: this.getAvailableWalletIds(),
|
|
2771
|
-
virtualCurrencyList: this.
|
|
3082
|
+
virtualCurrencyList: this.getVirtualCurrencyList()
|
|
2772
3083
|
});
|
|
2773
|
-
case
|
|
3084
|
+
case 75:
|
|
2774
3085
|
if (!rulesModule) {
|
|
2775
|
-
|
|
3086
|
+
_context25.next = 117;
|
|
2776
3087
|
break;
|
|
2777
3088
|
}
|
|
3089
|
+
if (isCurrentRequest()) {
|
|
3090
|
+
_context25.next = 78;
|
|
3091
|
+
break;
|
|
3092
|
+
}
|
|
3093
|
+
return _context25.abrupt("return", getCurrentResult());
|
|
3094
|
+
case 78:
|
|
2778
3095
|
orderTotalAmount = Number(((_orderStore$summary = orderStore.summary) === null || _orderStore$summary === void 0 ? void 0 : _orderStore$summary.total_amount) || 0);
|
|
2779
3096
|
result = rulesModule.calcDiscount({
|
|
2780
3097
|
productList: tempOrder.products,
|
|
@@ -2792,22 +3109,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2792
3109
|
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
2793
3110
|
}
|
|
2794
3111
|
_iterator3 = _createForOfIteratorHelper(tempOrder.products || []);
|
|
2795
|
-
|
|
3112
|
+
_context25.prev = 82;
|
|
2796
3113
|
_iterator3.s();
|
|
2797
|
-
case
|
|
3114
|
+
case 84:
|
|
2798
3115
|
if ((_step3 = _iterator3.n()).done) {
|
|
2799
|
-
|
|
3116
|
+
_context25.next = 99;
|
|
2800
3117
|
break;
|
|
2801
3118
|
}
|
|
2802
3119
|
product = _step3.value;
|
|
2803
3120
|
productUid = (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number;
|
|
2804
|
-
runtimeOrigin = productUid ? (_tempOrder$
|
|
3121
|
+
runtimeOrigin = productUid ? (_tempOrder$_extend6 = tempOrder._extend) === null || _tempOrder$_extend6 === void 0 || (_tempOrder$_extend6 = _tempOrder$_extend6.productsByUid) === null || _tempOrder$_extend6 === void 0 || (_tempOrder$_extend6 = _tempOrder$_extend6[productUid]) === null || _tempOrder$_extend6 === void 0 ? void 0 : _tempOrder$_extend6.origin : undefined;
|
|
2805
3122
|
if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
|
|
2806
|
-
|
|
3123
|
+
_context25.next = 90;
|
|
2807
3124
|
break;
|
|
2808
3125
|
}
|
|
2809
|
-
return
|
|
2810
|
-
case
|
|
3126
|
+
return _context25.abrupt("continue", 97);
|
|
3127
|
+
case 90:
|
|
2811
3128
|
totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
|
|
2812
3129
|
return sum + Number(pd.amount || 0);
|
|
2813
3130
|
}, 0);
|
|
@@ -2823,62 +3140,97 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2823
3140
|
mainPrice: newMainSellingPrice,
|
|
2824
3141
|
bundle: product.product_bundle
|
|
2825
3142
|
});
|
|
2826
|
-
case
|
|
2827
|
-
|
|
3143
|
+
case 97:
|
|
3144
|
+
_context25.next = 84;
|
|
2828
3145
|
break;
|
|
2829
|
-
case
|
|
2830
|
-
|
|
3146
|
+
case 99:
|
|
3147
|
+
_context25.next = 104;
|
|
2831
3148
|
break;
|
|
2832
|
-
case
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
_iterator3.e(
|
|
2836
|
-
case
|
|
2837
|
-
|
|
3149
|
+
case 101:
|
|
3150
|
+
_context25.prev = 101;
|
|
3151
|
+
_context25.t0 = _context25["catch"](82);
|
|
3152
|
+
_iterator3.e(_context25.t0);
|
|
3153
|
+
case 104:
|
|
3154
|
+
_context25.prev = 104;
|
|
2838
3155
|
_iterator3.f();
|
|
2839
|
-
return
|
|
2840
|
-
case
|
|
3156
|
+
return _context25.finish(104);
|
|
3157
|
+
case 107:
|
|
2841
3158
|
if (!result.discountList) {
|
|
2842
|
-
|
|
3159
|
+
_context25.next = 117;
|
|
2843
3160
|
break;
|
|
2844
3161
|
}
|
|
2845
3162
|
nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
|
|
2846
3163
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
2847
|
-
|
|
3164
|
+
if (isCurrentRequest()) {
|
|
3165
|
+
_context25.next = 112;
|
|
3166
|
+
break;
|
|
3167
|
+
}
|
|
3168
|
+
return _context25.abrupt("return", getCurrentResult());
|
|
3169
|
+
case 112:
|
|
3170
|
+
_context25.next = 114;
|
|
2848
3171
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
2849
|
-
case
|
|
3172
|
+
case 114:
|
|
3173
|
+
if (isCurrentRequest()) {
|
|
3174
|
+
_context25.next = 116;
|
|
3175
|
+
break;
|
|
3176
|
+
}
|
|
3177
|
+
return _context25.abrupt("return", getCurrentResult());
|
|
3178
|
+
case 116:
|
|
2850
3179
|
tempOrder.discount_list = nextDiscountList.filter(function (discount) {
|
|
2851
3180
|
return discount.isSelected;
|
|
2852
3181
|
});
|
|
2853
|
-
case
|
|
2854
|
-
|
|
3182
|
+
case 117:
|
|
3183
|
+
if (isCurrentRequest()) {
|
|
3184
|
+
_context25.next = 119;
|
|
3185
|
+
break;
|
|
3186
|
+
}
|
|
3187
|
+
return _context25.abrupt("return", getCurrentResult());
|
|
3188
|
+
case 119:
|
|
3189
|
+
_context25.next = 121;
|
|
2855
3190
|
return this.store.order.recalculateSummary({
|
|
2856
3191
|
createIfMissing: true
|
|
2857
3192
|
});
|
|
2858
|
-
case
|
|
2859
|
-
|
|
3193
|
+
case 121:
|
|
3194
|
+
if (isCurrentRequest()) {
|
|
3195
|
+
_context25.next = 123;
|
|
3196
|
+
break;
|
|
3197
|
+
}
|
|
3198
|
+
return _context25.abrupt("return", getCurrentResult());
|
|
3199
|
+
case 123:
|
|
2860
3200
|
this.store.order.persistTempOrder();
|
|
2861
|
-
|
|
3201
|
+
if (isCurrentRequest()) {
|
|
3202
|
+
_context25.next = 126;
|
|
3203
|
+
break;
|
|
3204
|
+
}
|
|
3205
|
+
return _context25.abrupt("return", getCurrentResult());
|
|
3206
|
+
case 126:
|
|
3207
|
+
_context25.next = 128;
|
|
2862
3208
|
return this.effectsEmit('onDiscountApplied', {
|
|
2863
3209
|
productList: tempOrder.products || [],
|
|
2864
3210
|
discountList: nextDiscountList,
|
|
2865
3211
|
selectedDiscountList: tempOrder.discount_list || [],
|
|
2866
3212
|
tempOrder: tempOrder
|
|
2867
3213
|
});
|
|
2868
|
-
case
|
|
2869
|
-
|
|
3214
|
+
case 128:
|
|
3215
|
+
if (isCurrentRequest()) {
|
|
3216
|
+
_context25.next = 130;
|
|
3217
|
+
break;
|
|
3218
|
+
}
|
|
3219
|
+
return _context25.abrupt("return", getCurrentResult());
|
|
3220
|
+
case 130:
|
|
3221
|
+
return _context25.abrupt("return", {
|
|
2870
3222
|
productList: tempOrder.products || [],
|
|
2871
3223
|
discountList: nextDiscountList,
|
|
2872
3224
|
availableWalletIds: this.getAvailableWalletIds(),
|
|
2873
|
-
virtualCurrencyList: this.
|
|
3225
|
+
virtualCurrencyList: this.getVirtualCurrencyList()
|
|
2874
3226
|
});
|
|
2875
|
-
case
|
|
3227
|
+
case 131:
|
|
2876
3228
|
case "end":
|
|
2877
|
-
return
|
|
3229
|
+
return _context25.stop();
|
|
2878
3230
|
}
|
|
2879
|
-
},
|
|
3231
|
+
}, _callee25, this, [[82, 101, 104, 107]]);
|
|
2880
3232
|
}));
|
|
2881
|
-
function loadDiscountConfig(
|
|
3233
|
+
function loadDiscountConfig(_x17) {
|
|
2882
3234
|
return _loadDiscountConfig.apply(this, arguments);
|
|
2883
3235
|
}
|
|
2884
3236
|
return loadDiscountConfig;
|
|
@@ -2886,35 +3238,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2886
3238
|
}, {
|
|
2887
3239
|
key: "getAvailableWalletIds",
|
|
2888
3240
|
value: function getAvailableWalletIds() {
|
|
2889
|
-
var _this$store$
|
|
2890
|
-
if (!((_this$store$
|
|
3241
|
+
var _this$store$order8;
|
|
3242
|
+
if (!((_this$store$order8 = this.store.order) !== null && _this$store$order8 !== void 0 && _this$store$order8.getAvailableWalletIds)) return [];
|
|
2891
3243
|
return this.store.order.getAvailableWalletIds();
|
|
2892
3244
|
}
|
|
2893
3245
|
}, {
|
|
2894
3246
|
key: "getVirtualCurrencyList",
|
|
2895
3247
|
value: function getVirtualCurrencyList() {
|
|
2896
|
-
var _this$store$
|
|
2897
|
-
if (!((_this$store$
|
|
3248
|
+
var _this$store$order9;
|
|
3249
|
+
if (!((_this$store$order9 = this.store.order) !== null && _this$store$order9 !== void 0 && _this$store$order9.getVirtualCurrencyList)) return [];
|
|
2898
3250
|
return this.store.order.getVirtualCurrencyList();
|
|
2899
3251
|
}
|
|
2900
3252
|
}, {
|
|
2901
3253
|
key: "bestDiscount",
|
|
2902
3254
|
value: function () {
|
|
2903
|
-
var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2904
|
-
var _discountModule$getOr2, _discountModule$
|
|
3255
|
+
var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(cb) {
|
|
3256
|
+
var _discountModule$getOr2, _discountModule$getDi4;
|
|
2905
3257
|
var tempOrder, _result2, orderStore, discountModule, rulesModule, originalDiscountList, currentDiscountList, nextDiscountList, result, _orderStore$summary2, orderTotalAmount;
|
|
2906
|
-
return _regeneratorRuntime().wrap(function
|
|
2907
|
-
while (1) switch (
|
|
3258
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
3259
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
2908
3260
|
case 0:
|
|
2909
3261
|
if (this.store.order) {
|
|
2910
|
-
|
|
3262
|
+
_context26.next = 2;
|
|
2911
3263
|
break;
|
|
2912
3264
|
}
|
|
2913
3265
|
throw new Error('order 模块未初始化');
|
|
2914
3266
|
case 2:
|
|
2915
3267
|
tempOrder = this.store.order.ensureTempOrder();
|
|
2916
3268
|
if (!this.isActiveVirtualSettlementOrder(tempOrder)) {
|
|
2917
|
-
|
|
3269
|
+
_context26.next = 7;
|
|
2918
3270
|
break;
|
|
2919
3271
|
}
|
|
2920
3272
|
_result2 = {
|
|
@@ -2922,23 +3274,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2922
3274
|
discountList: []
|
|
2923
3275
|
};
|
|
2924
3276
|
cb === null || cb === void 0 || cb(_result2);
|
|
2925
|
-
return
|
|
3277
|
+
return _context26.abrupt("return", _result2);
|
|
2926
3278
|
case 7:
|
|
2927
3279
|
orderStore = this.store.order.store || {};
|
|
2928
3280
|
discountModule = orderStore.discount;
|
|
2929
3281
|
rulesModule = orderStore.rules;
|
|
2930
3282
|
originalDiscountList = (discountModule === null || discountModule === void 0 || (_discountModule$getOr2 = discountModule.getOriginalDiscountList) === null || _discountModule$getOr2 === void 0 ? void 0 : _discountModule$getOr2.call(discountModule)) || this.getDiscountList();
|
|
2931
|
-
currentDiscountList = (discountModule === null || discountModule === void 0 || (_discountModule$
|
|
3283
|
+
currentDiscountList = (discountModule === null || discountModule === void 0 || (_discountModule$getDi4 = discountModule.getDiscountList) === null || _discountModule$getDi4 === void 0 ? void 0 : _discountModule$getDi4.call(discountModule)) || [];
|
|
2932
3284
|
nextDiscountList = this.mergeHistoricalDiscountList(originalDiscountList || [], tempOrder.products || []);
|
|
2933
3285
|
result = {
|
|
2934
3286
|
productList: tempOrder.products || [],
|
|
2935
3287
|
discountList: nextDiscountList
|
|
2936
3288
|
};
|
|
2937
|
-
|
|
3289
|
+
_context26.next = 16;
|
|
2938
3290
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
2939
3291
|
case 16:
|
|
2940
3292
|
if (!rulesModule) {
|
|
2941
|
-
|
|
3293
|
+
_context26.next = 27;
|
|
2942
3294
|
break;
|
|
2943
3295
|
}
|
|
2944
3296
|
orderTotalAmount = Number(((_orderStore$summary2 = orderStore.summary) === null || _orderStore$summary2 === void 0 ? void 0 : _orderStore$summary2.total_amount) || 0);
|
|
@@ -2955,12 +3307,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2955
3307
|
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
2956
3308
|
}
|
|
2957
3309
|
if (!result.discountList) {
|
|
2958
|
-
|
|
3310
|
+
_context26.next = 27;
|
|
2959
3311
|
break;
|
|
2960
3312
|
}
|
|
2961
3313
|
nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
|
|
2962
3314
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
2963
|
-
|
|
3315
|
+
_context26.next = 25;
|
|
2964
3316
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
2965
3317
|
case 25:
|
|
2966
3318
|
tempOrder.discount_list = nextDiscountList.filter(function (discount) {
|
|
@@ -2971,13 +3323,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2971
3323
|
discountList: nextDiscountList
|
|
2972
3324
|
};
|
|
2973
3325
|
case 27:
|
|
2974
|
-
|
|
3326
|
+
_context26.next = 29;
|
|
2975
3327
|
return this.store.order.recalculateSummary({
|
|
2976
3328
|
createIfMissing: true
|
|
2977
3329
|
});
|
|
2978
3330
|
case 29:
|
|
2979
3331
|
this.store.order.persistTempOrder();
|
|
2980
|
-
|
|
3332
|
+
_context26.next = 32;
|
|
2981
3333
|
return this.effectsEmit('onDiscountApplied', {
|
|
2982
3334
|
productList: tempOrder.products || [],
|
|
2983
3335
|
discountList: nextDiscountList,
|
|
@@ -2986,14 +3338,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2986
3338
|
});
|
|
2987
3339
|
case 32:
|
|
2988
3340
|
cb === null || cb === void 0 || cb(result);
|
|
2989
|
-
return
|
|
3341
|
+
return _context26.abrupt("return", result);
|
|
2990
3342
|
case 34:
|
|
2991
3343
|
case "end":
|
|
2992
|
-
return
|
|
3344
|
+
return _context26.stop();
|
|
2993
3345
|
}
|
|
2994
|
-
},
|
|
3346
|
+
}, _callee26, this);
|
|
2995
3347
|
}));
|
|
2996
|
-
function bestDiscount(
|
|
3348
|
+
function bestDiscount(_x18) {
|
|
2997
3349
|
return _bestDiscount.apply(this, arguments);
|
|
2998
3350
|
}
|
|
2999
3351
|
return bestDiscount;
|
|
@@ -3022,41 +3374,41 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3022
3374
|
}, {
|
|
3023
3375
|
key: "replaceDiscountStoreLists",
|
|
3024
3376
|
value: (function () {
|
|
3025
|
-
var _replaceDiscountStoreLists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3377
|
+
var _replaceDiscountStoreLists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
|
|
3026
3378
|
var _store2;
|
|
3027
3379
|
var discountModule;
|
|
3028
|
-
return _regeneratorRuntime().wrap(function
|
|
3029
|
-
while (1) switch (
|
|
3380
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
3381
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
3030
3382
|
case 0:
|
|
3031
3383
|
if (this.store.order) {
|
|
3032
|
-
|
|
3384
|
+
_context27.next = 2;
|
|
3033
3385
|
break;
|
|
3034
3386
|
}
|
|
3035
3387
|
throw new Error('order 模块未初始化');
|
|
3036
3388
|
case 2:
|
|
3037
3389
|
discountModule = (_store2 = this.store.order.store) === null || _store2 === void 0 ? void 0 : _store2.discount;
|
|
3038
3390
|
if (discountModule) {
|
|
3039
|
-
|
|
3391
|
+
_context27.next = 5;
|
|
3040
3392
|
break;
|
|
3041
3393
|
}
|
|
3042
|
-
return
|
|
3394
|
+
return _context27.abrupt("return");
|
|
3043
3395
|
case 5:
|
|
3044
3396
|
if (!params.originalDiscountList) {
|
|
3045
|
-
|
|
3397
|
+
_context27.next = 8;
|
|
3046
3398
|
break;
|
|
3047
3399
|
}
|
|
3048
|
-
|
|
3400
|
+
_context27.next = 8;
|
|
3049
3401
|
return discountModule.setOriginalDiscountList(params.originalDiscountList);
|
|
3050
3402
|
case 8:
|
|
3051
|
-
|
|
3403
|
+
_context27.next = 10;
|
|
3052
3404
|
return discountModule.setDiscountList(params.discountList);
|
|
3053
3405
|
case 10:
|
|
3054
3406
|
case "end":
|
|
3055
|
-
return
|
|
3407
|
+
return _context27.stop();
|
|
3056
3408
|
}
|
|
3057
|
-
},
|
|
3409
|
+
}, _callee27, this);
|
|
3058
3410
|
}));
|
|
3059
|
-
function replaceDiscountStoreLists(
|
|
3411
|
+
function replaceDiscountStoreLists(_x19) {
|
|
3060
3412
|
return _replaceDiscountStoreLists.apply(this, arguments);
|
|
3061
3413
|
}
|
|
3062
3414
|
return replaceDiscountStoreLists;
|
|
@@ -3064,34 +3416,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3064
3416
|
}, {
|
|
3065
3417
|
key: "scanPromotionCode",
|
|
3066
3418
|
value: function () {
|
|
3067
|
-
var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3419
|
+
var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(code, customerId) {
|
|
3068
3420
|
var raw, tempOrder;
|
|
3069
|
-
return _regeneratorRuntime().wrap(function
|
|
3070
|
-
while (1) switch (
|
|
3421
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
3422
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
3071
3423
|
case 0:
|
|
3072
|
-
|
|
3424
|
+
_context28.prev = 0;
|
|
3073
3425
|
if (this.store.order) {
|
|
3074
|
-
|
|
3426
|
+
_context28.next = 3;
|
|
3075
3427
|
break;
|
|
3076
3428
|
}
|
|
3077
3429
|
throw new Error('order 模块未初始化');
|
|
3078
3430
|
case 3:
|
|
3079
|
-
|
|
3431
|
+
_context28.next = 5;
|
|
3080
3432
|
return this.store.order.scanCode(code, customerId);
|
|
3081
3433
|
case 5:
|
|
3082
|
-
raw =
|
|
3434
|
+
raw = _context28.sent;
|
|
3083
3435
|
if (!raw.isAvailable) {
|
|
3084
|
-
|
|
3436
|
+
_context28.next = 13;
|
|
3085
3437
|
break;
|
|
3086
3438
|
}
|
|
3087
|
-
|
|
3439
|
+
_context28.next = 9;
|
|
3088
3440
|
return this.store.order.recalculateSummary({
|
|
3089
3441
|
createIfMissing: true
|
|
3090
3442
|
});
|
|
3091
3443
|
case 9:
|
|
3092
3444
|
this.store.order.persistTempOrder();
|
|
3093
3445
|
tempOrder = this.store.order.ensureTempOrder();
|
|
3094
|
-
|
|
3446
|
+
_context28.next = 13;
|
|
3095
3447
|
return this.effectsEmit('onDiscountApplied', {
|
|
3096
3448
|
productList: tempOrder.products || [],
|
|
3097
3449
|
discountList: this.store.order.getDiscountList(),
|
|
@@ -3099,7 +3451,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3099
3451
|
tempOrder: tempOrder
|
|
3100
3452
|
});
|
|
3101
3453
|
case 13:
|
|
3102
|
-
return
|
|
3454
|
+
return _context28.abrupt("return", _objectSpread(_objectSpread({
|
|
3103
3455
|
isAvailable: raw.isAvailable
|
|
3104
3456
|
}, raw.isAccepted !== undefined ? {
|
|
3105
3457
|
isAccepted: raw.isAccepted
|
|
@@ -3109,16 +3461,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3109
3461
|
scannedDiscountList: raw.scannedDiscountList
|
|
3110
3462
|
}));
|
|
3111
3463
|
case 16:
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
throw
|
|
3464
|
+
_context28.prev = 16;
|
|
3465
|
+
_context28.t0 = _context28["catch"](0);
|
|
3466
|
+
throw _context28.t0;
|
|
3115
3467
|
case 19:
|
|
3116
3468
|
case "end":
|
|
3117
|
-
return
|
|
3469
|
+
return _context28.stop();
|
|
3118
3470
|
}
|
|
3119
|
-
},
|
|
3471
|
+
}, _callee28, this, [[0, 16]]);
|
|
3120
3472
|
}));
|
|
3121
|
-
function scanPromotionCode(
|
|
3473
|
+
function scanPromotionCode(_x20, _x21) {
|
|
3122
3474
|
return _scanPromotionCode.apply(this, arguments);
|
|
3123
3475
|
}
|
|
3124
3476
|
return scanPromotionCode;
|
|
@@ -3126,35 +3478,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3126
3478
|
}, {
|
|
3127
3479
|
key: "setDiscountSelected",
|
|
3128
3480
|
value: function () {
|
|
3129
|
-
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3130
|
-
var currentOrder, _store3, _store3$setDiscountLi, list, updated, tempOrder, orderStore,
|
|
3131
|
-
return _regeneratorRuntime().wrap(function
|
|
3132
|
-
while (1) switch (
|
|
3481
|
+
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
|
|
3482
|
+
var currentOrder, _store3, _store3$setDiscountLi, list, updated, tempOrder, orderStore, _discountModule, rulesModule, nextDiscountList, _orderStore$summary3, orderTotalAmount, result, beforeSelectedIds, _iterator4, _step4, d, selectedResourceIds, filterSelectedDiscountDetails, _iterator5, _step5, _product$metadata8, _tempOrder$_extend7, _product$metadata$sou2, _product$metadata9, _product$metadata10, _product$original_pri2, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
|
|
3483
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
3484
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
3133
3485
|
case 0:
|
|
3134
|
-
|
|
3486
|
+
_context29.prev = 0;
|
|
3135
3487
|
if (this.store.order) {
|
|
3136
|
-
|
|
3488
|
+
_context29.next = 3;
|
|
3137
3489
|
break;
|
|
3138
3490
|
}
|
|
3139
3491
|
throw new Error('order 模块未初始化');
|
|
3140
3492
|
case 3:
|
|
3141
3493
|
currentOrder = this.store.order.ensureTempOrder();
|
|
3142
3494
|
if (!this.isActiveVirtualSettlementOrder(currentOrder)) {
|
|
3143
|
-
|
|
3495
|
+
_context29.next = 13;
|
|
3144
3496
|
break;
|
|
3145
3497
|
}
|
|
3146
3498
|
currentOrder.discount_list = [];
|
|
3147
3499
|
currentOrder.shop_discount = '0.00';
|
|
3148
|
-
|
|
3500
|
+
_context29.next = 9;
|
|
3149
3501
|
return (_store3 = this.store.order.store) === null || _store3 === void 0 || (_store3 = _store3.discount) === null || _store3 === void 0 || (_store3$setDiscountLi = _store3.setDiscountList) === null || _store3$setDiscountLi === void 0 ? void 0 : _store3$setDiscountLi.call(_store3, []);
|
|
3150
3502
|
case 9:
|
|
3151
|
-
|
|
3503
|
+
_context29.next = 11;
|
|
3152
3504
|
return this.store.order.recalculateSummary({
|
|
3153
3505
|
createIfMissing: true
|
|
3154
3506
|
});
|
|
3155
3507
|
case 11:
|
|
3156
3508
|
this.store.order.persistTempOrder();
|
|
3157
|
-
return
|
|
3509
|
+
return _context29.abrupt("return");
|
|
3158
3510
|
case 13:
|
|
3159
3511
|
list = this.store.order.getDiscountList();
|
|
3160
3512
|
updated = list.map(function (d) {
|
|
@@ -3166,11 +3518,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3166
3518
|
this.hasManualDiscountSelection = true;
|
|
3167
3519
|
tempOrder = this.store.order.ensureTempOrder();
|
|
3168
3520
|
orderStore = this.store.order.store || {};
|
|
3169
|
-
|
|
3521
|
+
_discountModule = orderStore.discount;
|
|
3170
3522
|
rulesModule = orderStore.rules;
|
|
3171
3523
|
nextDiscountList = updated;
|
|
3172
|
-
|
|
3173
|
-
return
|
|
3524
|
+
_context29.next = 23;
|
|
3525
|
+
return _discountModule === null || _discountModule === void 0 ? void 0 : _discountModule.setDiscountList(updated);
|
|
3174
3526
|
case 23:
|
|
3175
3527
|
if (rulesModule) {
|
|
3176
3528
|
orderTotalAmount = Number(((_orderStore$summary3 = orderStore.summary) === null || _orderStore$summary3 === void 0 ? void 0 : _orderStore$summary3.total_amount) || 0);
|
|
@@ -3231,29 +3583,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3231
3583
|
});
|
|
3232
3584
|
};
|
|
3233
3585
|
_iterator5 = _createForOfIteratorHelper(tempOrder.products);
|
|
3234
|
-
|
|
3586
|
+
_context29.prev = 27;
|
|
3235
3587
|
_iterator5.s();
|
|
3236
3588
|
case 29:
|
|
3237
3589
|
if ((_step5 = _iterator5.n()).done) {
|
|
3238
|
-
|
|
3590
|
+
_context29.next = 46;
|
|
3239
3591
|
break;
|
|
3240
3592
|
}
|
|
3241
3593
|
product = _step5.value;
|
|
3242
3594
|
productUid = (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.unique_identification_number;
|
|
3243
|
-
runtimeOrigin = productUid ? (_tempOrder$
|
|
3595
|
+
runtimeOrigin = productUid ? (_tempOrder$_extend7 = tempOrder._extend) === null || _tempOrder$_extend7 === void 0 || (_tempOrder$_extend7 = _tempOrder$_extend7.productsByUid) === null || _tempOrder$_extend7 === void 0 || (_tempOrder$_extend7 = _tempOrder$_extend7[productUid]) === null || _tempOrder$_extend7 === void 0 ? void 0 : _tempOrder$_extend7.origin : undefined;
|
|
3244
3596
|
if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
|
|
3245
|
-
|
|
3597
|
+
_context29.next = 35;
|
|
3246
3598
|
break;
|
|
3247
3599
|
}
|
|
3248
|
-
return
|
|
3600
|
+
return _context29.abrupt("continue", 44);
|
|
3249
3601
|
case 35:
|
|
3250
3602
|
product.discount_list = filterSelectedDiscountDetails(product.discount_list);
|
|
3251
3603
|
if (Array.isArray(product.product_bundle)) {
|
|
3252
3604
|
product.product_bundle = product.product_bundle.map(function (bundle) {
|
|
3253
|
-
var
|
|
3605
|
+
var _ref46, _bundle$original_pric;
|
|
3254
3606
|
var nextBundleDiscountList = filterSelectedDiscountDetails(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list);
|
|
3255
3607
|
var shouldRestoreBundlePrice = nextBundleDiscountList.length === 0;
|
|
3256
|
-
var restoredBundlePrice = (
|
|
3608
|
+
var restoredBundlePrice = (_ref46 = (_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 && _ref46 !== void 0 ? _ref46 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
|
|
3257
3609
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), shouldRestoreBundlePrice ? {
|
|
3258
3610
|
price: restoredBundlePrice,
|
|
3259
3611
|
bundle_selling_price: restoredBundlePrice
|
|
@@ -3281,28 +3633,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3281
3633
|
bundle: product.product_bundle
|
|
3282
3634
|
});
|
|
3283
3635
|
case 44:
|
|
3284
|
-
|
|
3636
|
+
_context29.next = 29;
|
|
3285
3637
|
break;
|
|
3286
3638
|
case 46:
|
|
3287
|
-
|
|
3639
|
+
_context29.next = 51;
|
|
3288
3640
|
break;
|
|
3289
3641
|
case 48:
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
_iterator5.e(
|
|
3642
|
+
_context29.prev = 48;
|
|
3643
|
+
_context29.t0 = _context29["catch"](27);
|
|
3644
|
+
_iterator5.e(_context29.t0);
|
|
3293
3645
|
case 51:
|
|
3294
|
-
|
|
3646
|
+
_context29.prev = 51;
|
|
3295
3647
|
_iterator5.f();
|
|
3296
|
-
return
|
|
3648
|
+
return _context29.finish(51);
|
|
3297
3649
|
case 54:
|
|
3298
3650
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
3299
|
-
|
|
3300
|
-
return
|
|
3651
|
+
_context29.next = 57;
|
|
3652
|
+
return _discountModule === null || _discountModule === void 0 ? void 0 : _discountModule.setDiscountList(nextDiscountList);
|
|
3301
3653
|
case 57:
|
|
3302
3654
|
tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
|
|
3303
3655
|
return d.isSelected;
|
|
3304
3656
|
});
|
|
3305
|
-
|
|
3657
|
+
_context29.next = 60;
|
|
3306
3658
|
return this.store.order.recalculateSummary({
|
|
3307
3659
|
createIfMissing: true
|
|
3308
3660
|
});
|
|
@@ -3314,19 +3666,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3314
3666
|
selectedDiscountList: tempOrder.discount_list,
|
|
3315
3667
|
tempOrder: tempOrder
|
|
3316
3668
|
});
|
|
3317
|
-
|
|
3669
|
+
_context29.next = 67;
|
|
3318
3670
|
break;
|
|
3319
3671
|
case 64:
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
throw
|
|
3672
|
+
_context29.prev = 64;
|
|
3673
|
+
_context29.t1 = _context29["catch"](0);
|
|
3674
|
+
throw _context29.t1;
|
|
3323
3675
|
case 67:
|
|
3324
3676
|
case "end":
|
|
3325
|
-
return
|
|
3677
|
+
return _context29.stop();
|
|
3326
3678
|
}
|
|
3327
|
-
},
|
|
3679
|
+
}, _callee29, this, [[0, 64], [27, 48, 51, 54]]);
|
|
3328
3680
|
}));
|
|
3329
|
-
function setDiscountSelected(
|
|
3681
|
+
function setDiscountSelected(_x22) {
|
|
3330
3682
|
return _setDiscountSelected.apply(this, arguments);
|
|
3331
3683
|
}
|
|
3332
3684
|
return setDiscountSelected;
|
|
@@ -3334,49 +3686,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3334
3686
|
}, {
|
|
3335
3687
|
key: "applyDiscountCalculationResult",
|
|
3336
3688
|
value: function () {
|
|
3337
|
-
var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3338
|
-
var tempOrder, orderStore,
|
|
3339
|
-
return _regeneratorRuntime().wrap(function
|
|
3340
|
-
while (1) switch (
|
|
3689
|
+
var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(result) {
|
|
3690
|
+
var tempOrder, orderStore, _discountModule2;
|
|
3691
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
3692
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
3341
3693
|
case 0:
|
|
3342
|
-
|
|
3694
|
+
_context30.prev = 0;
|
|
3343
3695
|
if (this.store.order) {
|
|
3344
|
-
|
|
3696
|
+
_context30.next = 3;
|
|
3345
3697
|
break;
|
|
3346
3698
|
}
|
|
3347
3699
|
throw new Error('order 模块未初始化');
|
|
3348
3700
|
case 3:
|
|
3349
3701
|
if (result) {
|
|
3350
|
-
|
|
3702
|
+
_context30.next = 5;
|
|
3351
3703
|
break;
|
|
3352
3704
|
}
|
|
3353
|
-
return
|
|
3705
|
+
return _context30.abrupt("return");
|
|
3354
3706
|
case 5:
|
|
3355
3707
|
tempOrder = this.store.order.ensureTempOrder();
|
|
3356
3708
|
orderStore = this.store.order.store || {};
|
|
3357
|
-
|
|
3709
|
+
_discountModule2 = orderStore.discount;
|
|
3358
3710
|
if (result.productList) {
|
|
3359
3711
|
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
3360
3712
|
}
|
|
3361
3713
|
if (!result.discountList) {
|
|
3362
|
-
|
|
3714
|
+
_context30.next = 14;
|
|
3363
3715
|
break;
|
|
3364
3716
|
}
|
|
3365
3717
|
OrderModule.populateSavedAmounts(tempOrder.products, result.discountList);
|
|
3366
|
-
|
|
3367
|
-
return
|
|
3718
|
+
_context30.next = 13;
|
|
3719
|
+
return _discountModule2 === null || _discountModule2 === void 0 ? void 0 : _discountModule2.setDiscountList(result.discountList);
|
|
3368
3720
|
case 13:
|
|
3369
3721
|
tempOrder.discount_list = result.discountList.filter(function (discount) {
|
|
3370
3722
|
return discount.isSelected;
|
|
3371
3723
|
});
|
|
3372
3724
|
case 14:
|
|
3373
|
-
|
|
3725
|
+
_context30.next = 16;
|
|
3374
3726
|
return this.store.order.recalculateSummary({
|
|
3375
3727
|
createIfMissing: true
|
|
3376
3728
|
});
|
|
3377
3729
|
case 16:
|
|
3378
3730
|
this.store.order.persistTempOrder();
|
|
3379
|
-
|
|
3731
|
+
_context30.next = 19;
|
|
3380
3732
|
return this.effectsEmit('onDiscountApplied', {
|
|
3381
3733
|
productList: tempOrder.products || [],
|
|
3382
3734
|
discountList: result.discountList || [],
|
|
@@ -3384,19 +3736,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3384
3736
|
tempOrder: tempOrder
|
|
3385
3737
|
});
|
|
3386
3738
|
case 19:
|
|
3387
|
-
|
|
3739
|
+
_context30.next = 24;
|
|
3388
3740
|
break;
|
|
3389
3741
|
case 21:
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
throw
|
|
3742
|
+
_context30.prev = 21;
|
|
3743
|
+
_context30.t0 = _context30["catch"](0);
|
|
3744
|
+
throw _context30.t0;
|
|
3393
3745
|
case 24:
|
|
3394
3746
|
case "end":
|
|
3395
|
-
return
|
|
3747
|
+
return _context30.stop();
|
|
3396
3748
|
}
|
|
3397
|
-
},
|
|
3749
|
+
}, _callee30, this, [[0, 21]]);
|
|
3398
3750
|
}));
|
|
3399
|
-
function applyDiscountCalculationResult(
|
|
3751
|
+
function applyDiscountCalculationResult(_x23) {
|
|
3400
3752
|
return _applyDiscountCalculationResult.apply(this, arguments);
|
|
3401
3753
|
}
|
|
3402
3754
|
return applyDiscountCalculationResult;
|
|
@@ -3404,18 +3756,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3404
3756
|
}, {
|
|
3405
3757
|
key: "submitScanOrder",
|
|
3406
3758
|
value: function () {
|
|
3407
|
-
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3408
|
-
return _regeneratorRuntime().wrap(function
|
|
3409
|
-
while (1) switch (
|
|
3759
|
+
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
|
|
3760
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
3761
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
3410
3762
|
case 0:
|
|
3411
|
-
return
|
|
3763
|
+
return _context31.abrupt("return", this.submitSalesOrder(params));
|
|
3412
3764
|
case 1:
|
|
3413
3765
|
case "end":
|
|
3414
|
-
return
|
|
3766
|
+
return _context31.stop();
|
|
3415
3767
|
}
|
|
3416
|
-
},
|
|
3768
|
+
}, _callee31, this);
|
|
3417
3769
|
}));
|
|
3418
|
-
function submitScanOrder(
|
|
3770
|
+
function submitScanOrder(_x24) {
|
|
3419
3771
|
return _submitScanOrder.apply(this, arguments);
|
|
3420
3772
|
}
|
|
3421
3773
|
return submitScanOrder;
|
|
@@ -3423,46 +3775,46 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3423
3775
|
}, {
|
|
3424
3776
|
key: "buildVirtualSettlementSubmitData",
|
|
3425
3777
|
value: function () {
|
|
3426
|
-
var _buildVirtualSettlementSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3778
|
+
var _buildVirtualSettlementSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
|
|
3427
3779
|
var _tempOrder$metadata$c, _tempOrder$metadata2;
|
|
3428
3780
|
var tempOrder, snapshot, currencyProductId, summary, amount, customerId, asset, currencyCode, currencySymbol, currencyFormat, balance, amountText, paymentNumber, payment, _paymentMethod$custom, paymentMethods, paymentMethod;
|
|
3429
|
-
return _regeneratorRuntime().wrap(function
|
|
3430
|
-
while (1) switch (
|
|
3781
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
3782
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
3431
3783
|
case 0:
|
|
3432
3784
|
if (this.store.order) {
|
|
3433
|
-
|
|
3785
|
+
_context32.next = 2;
|
|
3434
3786
|
break;
|
|
3435
3787
|
}
|
|
3436
|
-
return
|
|
3788
|
+
return _context32.abrupt("return", null);
|
|
3437
3789
|
case 2:
|
|
3438
3790
|
tempOrder = this.store.order.getTempOrder();
|
|
3439
3791
|
if (this.isActiveVirtualSettlementOrder(tempOrder)) {
|
|
3440
|
-
|
|
3792
|
+
_context32.next = 5;
|
|
3441
3793
|
break;
|
|
3442
3794
|
}
|
|
3443
|
-
return
|
|
3795
|
+
return _context32.abrupt("return", null);
|
|
3444
3796
|
case 5:
|
|
3445
3797
|
snapshot = getTempOrderSettlementSnapshot(tempOrder);
|
|
3446
3798
|
currencyProductId = Number((_tempOrder$metadata$c = tempOrder === null || tempOrder === void 0 || (_tempOrder$metadata2 = tempOrder.metadata) === null || _tempOrder$metadata2 === void 0 || (_tempOrder$metadata2 = _tempOrder$metadata2.currency_settlement_config) === null || _tempOrder$metadata2 === void 0 || (_tempOrder$metadata2 = _tempOrder$metadata2.settlement_ids) === null || _tempOrder$metadata2 === void 0 ? void 0 : _tempOrder$metadata2[0]) !== null && _tempOrder$metadata$c !== void 0 ? _tempOrder$metadata$c : snapshot === null || snapshot === void 0 ? void 0 : snapshot.currency_product_id);
|
|
3447
3799
|
if (!(!snapshot || !Number.isFinite(currencyProductId) || currencyProductId <= 0)) {
|
|
3448
|
-
|
|
3800
|
+
_context32.next = 9;
|
|
3449
3801
|
break;
|
|
3450
3802
|
}
|
|
3451
3803
|
throw new Error('Virtual currency settlement configuration is invalid.');
|
|
3452
3804
|
case 9:
|
|
3453
|
-
|
|
3805
|
+
_context32.next = 11;
|
|
3454
3806
|
return this.store.order.recalculateSummary({
|
|
3455
3807
|
createIfMissing: true
|
|
3456
3808
|
});
|
|
3457
3809
|
case 11:
|
|
3458
|
-
summary =
|
|
3810
|
+
summary = _context32.sent;
|
|
3459
3811
|
amount = new Decimal((summary === null || summary === void 0 ? void 0 : summary.total_amount) || 0).toDecimalPlaces(2);
|
|
3460
3812
|
customerId = Number((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.customer_id) || 0);
|
|
3461
3813
|
if (!(amount.gt(0) && customerId > 0 && customerId !== 1)) {
|
|
3462
|
-
|
|
3814
|
+
_context32.next = 17;
|
|
3463
3815
|
break;
|
|
3464
3816
|
}
|
|
3465
|
-
|
|
3817
|
+
_context32.next = 17;
|
|
3466
3818
|
return this.store.order.loadDiscountConfig({
|
|
3467
3819
|
customerId: customerId,
|
|
3468
3820
|
action: tempOrder !== null && tempOrder !== void 0 && tempOrder.order_id ? 'edit' : 'create',
|
|
@@ -3477,10 +3829,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3477
3829
|
currencySymbol = String((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.currency_symbol) || '');
|
|
3478
3830
|
currencyFormat = String((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.currency_format) || 'symbol_first');
|
|
3479
3831
|
if (!amount.lte(0)) {
|
|
3480
|
-
|
|
3832
|
+
_context32.next = 23;
|
|
3481
3833
|
break;
|
|
3482
3834
|
}
|
|
3483
|
-
return
|
|
3835
|
+
return _context32.abrupt("return", {
|
|
3484
3836
|
payments: [],
|
|
3485
3837
|
snapshot: snapshot,
|
|
3486
3838
|
currencyProductId: currencyProductId,
|
|
@@ -3490,14 +3842,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3490
3842
|
});
|
|
3491
3843
|
case 23:
|
|
3492
3844
|
if (asset) {
|
|
3493
|
-
|
|
3845
|
+
_context32.next = 25;
|
|
3494
3846
|
break;
|
|
3495
3847
|
}
|
|
3496
3848
|
throw new Error('No matching virtual currency card is available.');
|
|
3497
3849
|
case 25:
|
|
3498
3850
|
balance = new Decimal(asset.balance || 0);
|
|
3499
3851
|
if (!balance.lt(amount)) {
|
|
3500
|
-
|
|
3852
|
+
_context32.next = 28;
|
|
3501
3853
|
break;
|
|
3502
3854
|
}
|
|
3503
3855
|
throw new Error('Insufficient virtual currency balance.');
|
|
@@ -3505,7 +3857,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3505
3857
|
amountText = amount.toFixed(2);
|
|
3506
3858
|
paymentNumber = "LOCAL_".concat(createUuidV4());
|
|
3507
3859
|
if (!this.store.order.isOnlineStorePlatform()) {
|
|
3508
|
-
|
|
3860
|
+
_context32.next = 34;
|
|
3509
3861
|
break;
|
|
3510
3862
|
}
|
|
3511
3863
|
payment = {
|
|
@@ -3522,18 +3874,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3522
3874
|
},
|
|
3523
3875
|
wallet_pass_use_value: amountText
|
|
3524
3876
|
};
|
|
3525
|
-
|
|
3877
|
+
_context32.next = 41;
|
|
3526
3878
|
break;
|
|
3527
3879
|
case 34:
|
|
3528
|
-
|
|
3880
|
+
_context32.next = 36;
|
|
3529
3881
|
return this.getPaymentMethodsAsync();
|
|
3530
3882
|
case 36:
|
|
3531
|
-
paymentMethods =
|
|
3883
|
+
paymentMethods = _context32.sent;
|
|
3532
3884
|
paymentMethod = paymentMethods.find(function (method) {
|
|
3533
3885
|
return String(method.code || '').toUpperCase() === 'PRODUCTVOUCHER';
|
|
3534
3886
|
});
|
|
3535
3887
|
if (paymentMethod) {
|
|
3536
|
-
|
|
3888
|
+
_context32.next = 40;
|
|
3537
3889
|
break;
|
|
3538
3890
|
}
|
|
3539
3891
|
throw new Error('PRODUCTVOUCHER payment method is unavailable.');
|
|
@@ -3557,7 +3909,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3557
3909
|
metadata: {}
|
|
3558
3910
|
};
|
|
3559
3911
|
case 41:
|
|
3560
|
-
return
|
|
3912
|
+
return _context32.abrupt("return", {
|
|
3561
3913
|
payments: [payment],
|
|
3562
3914
|
snapshot: snapshot,
|
|
3563
3915
|
currencyProductId: currencyProductId,
|
|
@@ -3567,9 +3919,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3567
3919
|
});
|
|
3568
3920
|
case 42:
|
|
3569
3921
|
case "end":
|
|
3570
|
-
return
|
|
3922
|
+
return _context32.stop();
|
|
3571
3923
|
}
|
|
3572
|
-
},
|
|
3924
|
+
}, _callee32, this);
|
|
3573
3925
|
}));
|
|
3574
3926
|
function buildVirtualSettlementSubmitData() {
|
|
3575
3927
|
return _buildVirtualSettlementSubmitData.apply(this, arguments);
|
|
@@ -3585,22 +3937,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3585
3937
|
}, {
|
|
3586
3938
|
key: "submitSalesOrder",
|
|
3587
3939
|
value: (function () {
|
|
3588
|
-
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3940
|
+
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
|
|
3589
3941
|
var _params$smallTicketDa, _this$otherParams14, _this$otherParams15, _this$otherParams16, _this$otherParams17;
|
|
3590
3942
|
var virtualSettlement, inferredPaymentStatus, smallTicketDataFlag, virtualSettlementEnhancePayload, enhancePayload, submitParams;
|
|
3591
|
-
return _regeneratorRuntime().wrap(function
|
|
3592
|
-
while (1) switch (
|
|
3943
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
3944
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
3593
3945
|
case 0:
|
|
3594
3946
|
if (this.store.order) {
|
|
3595
|
-
|
|
3947
|
+
_context33.next = 2;
|
|
3596
3948
|
break;
|
|
3597
3949
|
}
|
|
3598
3950
|
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
3599
3951
|
case 2:
|
|
3600
|
-
|
|
3952
|
+
_context33.next = 4;
|
|
3601
3953
|
return this.buildVirtualSettlementSubmitData();
|
|
3602
3954
|
case 4:
|
|
3603
|
-
virtualSettlement =
|
|
3955
|
+
virtualSettlement = _context33.sent;
|
|
3604
3956
|
// this.store.order.persistTempOrder();
|
|
3605
3957
|
inferredPaymentStatus = this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
|
|
3606
3958
|
smallTicketDataFlag = (_params$smallTicketDa = params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== null && _params$smallTicketDa !== void 0 ? _params$smallTicketDa : this.getDefaultCheckoutSmallTicketDataFlag();
|
|
@@ -3644,14 +3996,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3644
3996
|
} : {}), enhancePayload !== undefined ? {
|
|
3645
3997
|
enhancePayload: enhancePayload
|
|
3646
3998
|
} : {});
|
|
3647
|
-
return
|
|
3999
|
+
return _context33.abrupt("return", this.shouldUseCheckoutSyncTask() ? this.store.order.submitTempOrder(submitParams) : this.store.order.submitTempOrderAsync(submitParams));
|
|
3648
4000
|
case 11:
|
|
3649
4001
|
case "end":
|
|
3650
|
-
return
|
|
4002
|
+
return _context33.stop();
|
|
3651
4003
|
}
|
|
3652
|
-
},
|
|
4004
|
+
}, _callee33, this);
|
|
3653
4005
|
}));
|
|
3654
|
-
function submitSalesOrder(
|
|
4006
|
+
function submitSalesOrder(_x25) {
|
|
3655
4007
|
return _submitSalesOrder.apply(this, arguments);
|
|
3656
4008
|
}
|
|
3657
4009
|
return submitSalesOrder;
|
|
@@ -3659,18 +4011,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3659
4011
|
}, {
|
|
3660
4012
|
key: "saveSalesOrderDraft",
|
|
3661
4013
|
value: function () {
|
|
3662
|
-
var _saveSalesOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4014
|
+
var _saveSalesOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
|
|
3663
4015
|
var _params$platform, _this$otherParams18, _this$otherParams19, _this$otherParams20, _params$channel, _params$type, _this$otherParams21;
|
|
3664
|
-
return _regeneratorRuntime().wrap(function
|
|
3665
|
-
while (1) switch (
|
|
4016
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
4017
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
3666
4018
|
case 0:
|
|
3667
4019
|
if (this.store.order) {
|
|
3668
|
-
|
|
4020
|
+
_context34.next = 2;
|
|
3669
4021
|
break;
|
|
3670
4022
|
}
|
|
3671
4023
|
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
3672
4024
|
case 2:
|
|
3673
|
-
return
|
|
4025
|
+
return _context34.abrupt("return", this.store.order.saveTempOrderAsDraft(_objectSpread({
|
|
3674
4026
|
cacheId: this.cacheId,
|
|
3675
4027
|
platform: (_params$platform = params === null || params === void 0 ? void 0 : params.platform) !== null && _params$platform !== void 0 ? _params$platform : (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.platform,
|
|
3676
4028
|
businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.businessCode) || ((_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.business_code),
|
|
@@ -3681,11 +4033,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3681
4033
|
} : {})));
|
|
3682
4034
|
case 3:
|
|
3683
4035
|
case "end":
|
|
3684
|
-
return
|
|
4036
|
+
return _context34.stop();
|
|
3685
4037
|
}
|
|
3686
|
-
},
|
|
4038
|
+
}, _callee34, this);
|
|
3687
4039
|
}));
|
|
3688
|
-
function saveSalesOrderDraft(
|
|
4040
|
+
function saveSalesOrderDraft(_x26) {
|
|
3689
4041
|
return _saveSalesOrderDraft.apply(this, arguments);
|
|
3690
4042
|
}
|
|
3691
4043
|
return saveSalesOrderDraft;
|
|
@@ -3693,14 +4045,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3693
4045
|
}, {
|
|
3694
4046
|
key: "submitTempOrderAsync",
|
|
3695
4047
|
value: function () {
|
|
3696
|
-
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4048
|
+
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
|
|
3697
4049
|
var _params$smallTicketDa2, _this$otherParams22, _this$otherParams23, _this$otherParams24, _this$otherParams25;
|
|
3698
4050
|
var inferredPaymentStatus, smallTicketDataFlag, enhancePayload, submitParams;
|
|
3699
|
-
return _regeneratorRuntime().wrap(function
|
|
3700
|
-
while (1) switch (
|
|
4051
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
4052
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
3701
4053
|
case 0:
|
|
3702
4054
|
if (this.store.order) {
|
|
3703
|
-
|
|
4055
|
+
_context35.next = 2;
|
|
3704
4056
|
break;
|
|
3705
4057
|
}
|
|
3706
4058
|
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
@@ -3726,14 +4078,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3726
4078
|
} : {}), enhancePayload !== undefined ? {
|
|
3727
4079
|
enhancePayload: enhancePayload
|
|
3728
4080
|
} : {});
|
|
3729
|
-
return
|
|
4081
|
+
return _context35.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
|
|
3730
4082
|
case 7:
|
|
3731
4083
|
case "end":
|
|
3732
|
-
return
|
|
4084
|
+
return _context35.stop();
|
|
3733
4085
|
}
|
|
3734
|
-
},
|
|
4086
|
+
}, _callee35, this);
|
|
3735
4087
|
}));
|
|
3736
|
-
function submitTempOrderAsync(
|
|
4088
|
+
function submitTempOrderAsync(_x27) {
|
|
3737
4089
|
return _submitTempOrderAsync.apply(this, arguments);
|
|
3738
4090
|
}
|
|
3739
4091
|
return submitTempOrderAsync;
|
|
@@ -3759,14 +4111,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3759
4111
|
}, {
|
|
3760
4112
|
key: "printLocalOrderReceipt",
|
|
3761
4113
|
value: function () {
|
|
3762
|
-
var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4114
|
+
var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(lookup) {
|
|
3763
4115
|
var _this$otherParams27, _this$otherParams28, _this$otherParams29, _this$otherParams30;
|
|
3764
|
-
var hasLookup, lookupPayload, context, payload, invoiceLayoutConfig, invoiceTemplateSettings, printPayload, response, _this$store$order$app, _this$store$
|
|
3765
|
-
return _regeneratorRuntime().wrap(function
|
|
3766
|
-
while (1) switch (
|
|
4116
|
+
var hasLookup, lookupPayload, context, payload, invoiceLayoutConfig, invoiceTemplateSettings, printPayload, response, _this$store$order$app, _this$store$order10, _data;
|
|
4117
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
4118
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
3767
4119
|
case 0:
|
|
3768
4120
|
if (this.store.order) {
|
|
3769
|
-
|
|
4121
|
+
_context36.next = 2;
|
|
3770
4122
|
break;
|
|
3771
4123
|
}
|
|
3772
4124
|
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
@@ -3804,28 +4156,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3804
4156
|
} : {}), invoiceTemplateSettings ? {
|
|
3805
4157
|
template_settings: cloneDeep(invoiceTemplateSettings)
|
|
3806
4158
|
} : {});
|
|
3807
|
-
|
|
4159
|
+
_context36.next = 11;
|
|
3808
4160
|
return this.request.post('/local/print-order', printPayload, {
|
|
3809
4161
|
osServer: true,
|
|
3810
4162
|
customToast: function customToast() {}
|
|
3811
4163
|
});
|
|
3812
4164
|
case 11:
|
|
3813
|
-
response =
|
|
4165
|
+
response = _context36.sent;
|
|
3814
4166
|
if (hasLookup) {
|
|
3815
|
-
|
|
4167
|
+
_context36.next = 15;
|
|
3816
4168
|
break;
|
|
3817
4169
|
}
|
|
3818
|
-
|
|
3819
|
-
return (_this$store$order$app = (_this$store$
|
|
4170
|
+
_context36.next = 15;
|
|
4171
|
+
return (_this$store$order$app = (_this$store$order10 = this.store.order).applyLocalPrintOrderNumbers) === null || _this$store$order$app === void 0 ? void 0 : _this$store$order$app.call(_this$store$order10, response === null || response === void 0 || (_data = response.data) === null || _data === void 0 ? void 0 : _data.order);
|
|
3820
4172
|
case 15:
|
|
3821
|
-
return
|
|
4173
|
+
return _context36.abrupt("return", response);
|
|
3822
4174
|
case 16:
|
|
3823
4175
|
case "end":
|
|
3824
|
-
return
|
|
4176
|
+
return _context36.stop();
|
|
3825
4177
|
}
|
|
3826
|
-
},
|
|
4178
|
+
}, _callee36, this);
|
|
3827
4179
|
}));
|
|
3828
|
-
function printLocalOrderReceipt(
|
|
4180
|
+
function printLocalOrderReceipt(_x28) {
|
|
3829
4181
|
return _printLocalOrderReceipt.apply(this, arguments);
|
|
3830
4182
|
}
|
|
3831
4183
|
return printLocalOrderReceipt;
|
|
@@ -3833,9 +4185,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3833
4185
|
}, {
|
|
3834
4186
|
key: "getSubmitPaymentStatus",
|
|
3835
4187
|
value: function getSubmitPaymentStatus(paymentStatus) {
|
|
3836
|
-
var _this$store$
|
|
4188
|
+
var _this$store$order11, _this$store$order11$g;
|
|
3837
4189
|
if (paymentStatus !== undefined) return paymentStatus;
|
|
3838
|
-
var amountSnapshot = (_this$store$
|
|
4190
|
+
var 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);
|
|
3839
4191
|
if (!amountSnapshot) return undefined;
|
|
3840
4192
|
try {
|
|
3841
4193
|
return new Decimal(amountSnapshot.amountGap || 0).lte(0) ? 'paid' : undefined;
|
|
@@ -3846,19 +4198,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3846
4198
|
}, {
|
|
3847
4199
|
key: "syncPaymentsToOrder",
|
|
3848
4200
|
value: function () {
|
|
3849
|
-
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3850
|
-
var
|
|
4201
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
|
|
4202
|
+
var _ref47, _params$businessCode, _this$otherParams31, _this$otherParams32, _params$channel2;
|
|
3851
4203
|
var businessCode, channel, enhancePayload, syncParams, syncState, payments, syncResult, latestPayments, amountSnapshot, orderSnapshot, syncPayload;
|
|
3852
|
-
return _regeneratorRuntime().wrap(function
|
|
3853
|
-
while (1) switch (
|
|
4204
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
4205
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
3854
4206
|
case 0:
|
|
3855
4207
|
if (this.store.order) {
|
|
3856
|
-
|
|
4208
|
+
_context37.next = 2;
|
|
3857
4209
|
break;
|
|
3858
4210
|
}
|
|
3859
4211
|
throw new Error('order 模块未初始化');
|
|
3860
4212
|
case 2:
|
|
3861
|
-
businessCode = (
|
|
4213
|
+
businessCode = (_ref47 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams31 = this.otherParams) === null || _this$otherParams31 === void 0 ? void 0 : _this$otherParams31.businessCode) !== null && _ref47 !== void 0 ? _ref47 : (_this$otherParams32 = this.otherParams) === null || _this$otherParams32 === void 0 ? void 0 : _this$otherParams32.business_code;
|
|
3862
4214
|
channel = (_params$channel2 = params.channel) !== null && _params$channel2 !== void 0 ? _params$channel2 : this.getSubmitOrderSalesChannel();
|
|
3863
4215
|
enhancePayload = this.buildSubmitPayloadEnhancerWithOpenDataConfig(params.enhancePayload);
|
|
3864
4216
|
syncParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, params), {}, {
|
|
@@ -3872,14 +4224,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3872
4224
|
} : {});
|
|
3873
4225
|
syncState = this.store.order.getOrderSyncState();
|
|
3874
4226
|
if (!(params.submitWhenPaid && syncState === 'submitting')) {
|
|
3875
|
-
|
|
4227
|
+
_context37.next = 10;
|
|
3876
4228
|
break;
|
|
3877
4229
|
}
|
|
3878
4230
|
this.queueLatestAutoPaymentSync();
|
|
3879
|
-
return
|
|
4231
|
+
return _context37.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
|
|
3880
4232
|
case 10:
|
|
3881
4233
|
payments = params.payments || [];
|
|
3882
|
-
|
|
4234
|
+
_context37.next = 13;
|
|
3883
4235
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncStart, {
|
|
3884
4236
|
payments: payments,
|
|
3885
4237
|
params: syncParams,
|
|
@@ -3887,11 +4239,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3887
4239
|
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
3888
4240
|
});
|
|
3889
4241
|
case 13:
|
|
3890
|
-
|
|
3891
|
-
|
|
4242
|
+
_context37.prev = 13;
|
|
4243
|
+
_context37.next = 16;
|
|
3892
4244
|
return this.store.order.syncPaymentsToOrder(syncParams);
|
|
3893
4245
|
case 16:
|
|
3894
|
-
syncResult =
|
|
4246
|
+
syncResult = _context37.sent;
|
|
3895
4247
|
latestPayments = this.store.order.getOrderPayments();
|
|
3896
4248
|
amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
3897
4249
|
orderSnapshot = this.store.order.getOrderSnapshot();
|
|
@@ -3909,25 +4261,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3909
4261
|
depositAmount: syncResult.depositAmount,
|
|
3910
4262
|
orderExpectedAmount: syncResult.orderExpectedAmount
|
|
3911
4263
|
};
|
|
3912
|
-
|
|
4264
|
+
_context37.next = 23;
|
|
3913
4265
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, syncPayload);
|
|
3914
4266
|
case 23:
|
|
3915
4267
|
if (!(syncResult.isDepositFullyPaid && !syncResult.isOrderFullyPaid)) {
|
|
3916
|
-
|
|
4268
|
+
_context37.next = 26;
|
|
3917
4269
|
break;
|
|
3918
4270
|
}
|
|
3919
|
-
|
|
4271
|
+
_context37.next = 26;
|
|
3920
4272
|
return this.effectsEmit(BaseSalesHookNames.onDepositPaymentSyncEnd, syncPayload);
|
|
3921
4273
|
case 26:
|
|
3922
4274
|
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
3923
|
-
return
|
|
4275
|
+
return _context37.abrupt("return", syncResult);
|
|
3924
4276
|
case 30:
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
4277
|
+
_context37.prev = 30;
|
|
4278
|
+
_context37.t0 = _context37["catch"](13);
|
|
4279
|
+
_context37.next = 34;
|
|
3928
4280
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
|
|
3929
4281
|
ok: false,
|
|
3930
|
-
error:
|
|
4282
|
+
error: _context37.t0,
|
|
3931
4283
|
payments: this.store.order.getOrderPayments(),
|
|
3932
4284
|
params: syncParams,
|
|
3933
4285
|
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
@@ -3935,14 +4287,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3935
4287
|
});
|
|
3936
4288
|
case 34:
|
|
3937
4289
|
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
3938
|
-
throw
|
|
4290
|
+
throw _context37.t0;
|
|
3939
4291
|
case 36:
|
|
3940
4292
|
case "end":
|
|
3941
|
-
return
|
|
4293
|
+
return _context37.stop();
|
|
3942
4294
|
}
|
|
3943
|
-
},
|
|
4295
|
+
}, _callee37, this, [[13, 30]]);
|
|
3944
4296
|
}));
|
|
3945
|
-
function syncPaymentsToOrder(
|
|
4297
|
+
function syncPaymentsToOrder(_x29) {
|
|
3946
4298
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
3947
4299
|
}
|
|
3948
4300
|
return syncPaymentsToOrder;
|
|
@@ -3979,58 +4331,58 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3979
4331
|
}, {
|
|
3980
4332
|
key: "scheduleQueuedAutoPaymentSyncFlush",
|
|
3981
4333
|
value: function scheduleQueuedAutoPaymentSyncFlush() {
|
|
3982
|
-
var
|
|
4334
|
+
var _this16 = this;
|
|
3983
4335
|
var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;
|
|
3984
4336
|
if (!this.queuedAutoPaymentSync) return;
|
|
3985
4337
|
if (this.autoPaymentSyncTimer) return;
|
|
3986
4338
|
this.autoPaymentSyncTimer = setTimeout(function () {
|
|
3987
|
-
|
|
3988
|
-
void
|
|
4339
|
+
_this16.autoPaymentSyncTimer = null;
|
|
4340
|
+
void _this16.flushQueuedAutoPaymentSync();
|
|
3989
4341
|
}, delay);
|
|
3990
4342
|
}
|
|
3991
4343
|
}, {
|
|
3992
4344
|
key: "flushQueuedAutoPaymentSync",
|
|
3993
4345
|
value: function () {
|
|
3994
|
-
var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4346
|
+
var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
|
|
3995
4347
|
var payments;
|
|
3996
|
-
return _regeneratorRuntime().wrap(function
|
|
3997
|
-
while (1) switch (
|
|
4348
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
4349
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
3998
4350
|
case 0:
|
|
3999
4351
|
if (this.store.order) {
|
|
4000
|
-
|
|
4352
|
+
_context38.next = 2;
|
|
4001
4353
|
break;
|
|
4002
4354
|
}
|
|
4003
|
-
return
|
|
4355
|
+
return _context38.abrupt("return");
|
|
4004
4356
|
case 2:
|
|
4005
4357
|
if (!(!this.queuedAutoPaymentSync || this.autoPaymentSyncFlushing)) {
|
|
4006
|
-
|
|
4358
|
+
_context38.next = 4;
|
|
4007
4359
|
break;
|
|
4008
4360
|
}
|
|
4009
|
-
return
|
|
4361
|
+
return _context38.abrupt("return");
|
|
4010
4362
|
case 4:
|
|
4011
4363
|
if (!(this.store.order.getOrderSyncState() === 'submitting')) {
|
|
4012
|
-
|
|
4364
|
+
_context38.next = 7;
|
|
4013
4365
|
break;
|
|
4014
4366
|
}
|
|
4015
4367
|
this.scheduleQueuedAutoPaymentSyncFlush();
|
|
4016
|
-
return
|
|
4368
|
+
return _context38.abrupt("return");
|
|
4017
4369
|
case 7:
|
|
4018
4370
|
this.autoPaymentSyncFlushing = true;
|
|
4019
|
-
|
|
4371
|
+
_context38.prev = 8;
|
|
4020
4372
|
case 9:
|
|
4021
4373
|
if (!this.queuedAutoPaymentSync) {
|
|
4022
|
-
|
|
4374
|
+
_context38.next = 18;
|
|
4023
4375
|
break;
|
|
4024
4376
|
}
|
|
4025
4377
|
this.queuedAutoPaymentSync = false;
|
|
4026
4378
|
payments = this.store.order.getOrderPayments();
|
|
4027
4379
|
if (payments.length) {
|
|
4028
|
-
|
|
4380
|
+
_context38.next = 14;
|
|
4029
4381
|
break;
|
|
4030
4382
|
}
|
|
4031
|
-
return
|
|
4383
|
+
return _context38.abrupt("continue", 9);
|
|
4032
4384
|
case 14:
|
|
4033
|
-
|
|
4385
|
+
_context38.next = 16;
|
|
4034
4386
|
return this.syncPaymentsToOrder({
|
|
4035
4387
|
payments: payments,
|
|
4036
4388
|
paymentStatus: this.getPaymentStatusForSync(payments),
|
|
@@ -4038,29 +4390,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4038
4390
|
smallTicketDataFlag: 1
|
|
4039
4391
|
});
|
|
4040
4392
|
case 16:
|
|
4041
|
-
|
|
4393
|
+
_context38.next = 9;
|
|
4042
4394
|
break;
|
|
4043
4395
|
case 18:
|
|
4044
|
-
|
|
4396
|
+
_context38.next = 23;
|
|
4045
4397
|
break;
|
|
4046
4398
|
case 20:
|
|
4047
|
-
|
|
4048
|
-
|
|
4399
|
+
_context38.prev = 20;
|
|
4400
|
+
_context38.t0 = _context38["catch"](8);
|
|
4049
4401
|
this.logError('queued auto sync payments failed', {
|
|
4050
|
-
error:
|
|
4402
|
+
error: _context38.t0 instanceof Error ? _context38.t0.message : String(_context38.t0)
|
|
4051
4403
|
});
|
|
4052
4404
|
case 23:
|
|
4053
|
-
|
|
4405
|
+
_context38.prev = 23;
|
|
4054
4406
|
this.autoPaymentSyncFlushing = false;
|
|
4055
4407
|
if (this.queuedAutoPaymentSync) {
|
|
4056
4408
|
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
4057
4409
|
}
|
|
4058
|
-
return
|
|
4410
|
+
return _context38.finish(23);
|
|
4059
4411
|
case 27:
|
|
4060
4412
|
case "end":
|
|
4061
|
-
return
|
|
4413
|
+
return _context38.stop();
|
|
4062
4414
|
}
|
|
4063
|
-
},
|
|
4415
|
+
}, _callee38, this, [[8, 20, 23, 27]]);
|
|
4064
4416
|
}));
|
|
4065
4417
|
function flushQueuedAutoPaymentSync() {
|
|
4066
4418
|
return _flushQueuedAutoPaymentSync.apply(this, arguments);
|
|
@@ -4084,35 +4436,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4084
4436
|
}, {
|
|
4085
4437
|
key: "addOrderPaymentAsync",
|
|
4086
4438
|
value: (function () {
|
|
4087
|
-
var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4439
|
+
var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(payment) {
|
|
4088
4440
|
var paymentRecord, hasPaymentNumber, devicePrefix;
|
|
4089
|
-
return _regeneratorRuntime().wrap(function
|
|
4090
|
-
while (1) switch (
|
|
4441
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
4442
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
4091
4443
|
case 0:
|
|
4092
4444
|
paymentRecord = payment;
|
|
4093
4445
|
hasPaymentNumber = String(paymentRecord.payment_number || '').trim() !== '';
|
|
4094
4446
|
if (!hasPaymentNumber) {
|
|
4095
|
-
|
|
4447
|
+
_context39.next = 6;
|
|
4096
4448
|
break;
|
|
4097
4449
|
}
|
|
4098
|
-
|
|
4099
|
-
|
|
4450
|
+
_context39.t0 = 'LOCAL';
|
|
4451
|
+
_context39.next = 9;
|
|
4100
4452
|
break;
|
|
4101
4453
|
case 6:
|
|
4102
|
-
|
|
4454
|
+
_context39.next = 8;
|
|
4103
4455
|
return this.getPaymentNumberDevicePrefixAsync();
|
|
4104
4456
|
case 8:
|
|
4105
|
-
|
|
4457
|
+
_context39.t0 = _context39.sent;
|
|
4106
4458
|
case 9:
|
|
4107
|
-
devicePrefix =
|
|
4108
|
-
return
|
|
4459
|
+
devicePrefix = _context39.t0;
|
|
4460
|
+
return _context39.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
|
|
4109
4461
|
case 11:
|
|
4110
4462
|
case "end":
|
|
4111
|
-
return
|
|
4463
|
+
return _context39.stop();
|
|
4112
4464
|
}
|
|
4113
|
-
},
|
|
4465
|
+
}, _callee39, this);
|
|
4114
4466
|
}));
|
|
4115
|
-
function addOrderPaymentAsync(
|
|
4467
|
+
function addOrderPaymentAsync(_x30) {
|
|
4116
4468
|
return _addOrderPaymentAsync.apply(this, arguments);
|
|
4117
4469
|
}
|
|
4118
4470
|
return addOrderPaymentAsync;
|
|
@@ -4123,9 +4475,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4123
4475
|
var _this$otherParams33,
|
|
4124
4476
|
_paymentRecord$paymen,
|
|
4125
4477
|
_paymentRecord$create,
|
|
4126
|
-
|
|
4478
|
+
_ref48,
|
|
4127
4479
|
_paymentRecord$origin,
|
|
4128
|
-
|
|
4480
|
+
_this17 = this;
|
|
4129
4481
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
4130
4482
|
var paymentRecord = payment;
|
|
4131
4483
|
var paymentAmount = new Decimal(paymentRecord.amount || 0);
|
|
@@ -4145,7 +4497,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4145
4497
|
var paymentTime = (_paymentRecord$paymen = paymentRecord.payment_time) !== null && _paymentRecord$paymen !== void 0 ? _paymentRecord$paymen : paymentTimestamp;
|
|
4146
4498
|
var createdAt = (_paymentRecord$create = paymentRecord.created_at) !== null && _paymentRecord$create !== void 0 ? _paymentRecord$create : paymentTimestamp;
|
|
4147
4499
|
var serviceCharge = paymentRecord.service_charge && _typeof(paymentRecord.service_charge) === 'object' ? paymentRecord.service_charge : null;
|
|
4148
|
-
var calculatedServiceFee = serviceCharge ? new Decimal((
|
|
4500
|
+
var calculatedServiceFee = serviceCharge ? new Decimal((_ref48 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref48 !== void 0 ? _ref48 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
|
|
4149
4501
|
var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({}, normalizedPaymentRecord), calculatedServiceFee !== undefined ? {
|
|
4150
4502
|
service_fee: calculatedServiceFee
|
|
4151
4503
|
} : {}), {}, {
|
|
@@ -4169,7 +4521,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4169
4521
|
submitWhenPaid: true,
|
|
4170
4522
|
smallTicketDataFlag: 1
|
|
4171
4523
|
}).catch(function (error) {
|
|
4172
|
-
|
|
4524
|
+
_this17.logError('auto sync payments failed', {
|
|
4173
4525
|
error: error instanceof Error ? error.message : String(error)
|
|
4174
4526
|
});
|
|
4175
4527
|
});
|
|
@@ -4181,13 +4533,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4181
4533
|
}, {
|
|
4182
4534
|
key: "updateOrderPayment",
|
|
4183
4535
|
value: (function () {
|
|
4184
|
-
var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4536
|
+
var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(paymentIdentity, updates) {
|
|
4185
4537
|
var _result$payment, _result$payment2;
|
|
4186
4538
|
var options,
|
|
4187
4539
|
matchMode,
|
|
4188
4540
|
previousMatch,
|
|
4189
4541
|
previousPayment,
|
|
4190
|
-
_this$store$order$
|
|
4542
|
+
_this$store$order$get5,
|
|
4191
4543
|
currentPayments,
|
|
4192
4544
|
_syncResult,
|
|
4193
4545
|
_options$smallTicketD,
|
|
@@ -4198,13 +4550,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4198
4550
|
shouldSubmit,
|
|
4199
4551
|
syncResult,
|
|
4200
4552
|
_options$smallTicketD2,
|
|
4201
|
-
|
|
4202
|
-
return _regeneratorRuntime().wrap(function
|
|
4203
|
-
while (1) switch (
|
|
4553
|
+
_args40 = arguments;
|
|
4554
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
4555
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
4204
4556
|
case 0:
|
|
4205
|
-
options =
|
|
4557
|
+
options = _args40.length > 2 && _args40[2] !== undefined ? _args40[2] : {};
|
|
4206
4558
|
if (this.store.order) {
|
|
4207
|
-
|
|
4559
|
+
_context40.next = 3;
|
|
4208
4560
|
break;
|
|
4209
4561
|
}
|
|
4210
4562
|
throw new Error('order 模块未初始化');
|
|
@@ -4213,15 +4565,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4213
4565
|
previousMatch = resolveOrderPaymentIdentity(this.store.order.getOrderPayments(), paymentIdentity, matchMode);
|
|
4214
4566
|
previousPayment = previousMatch === null || previousMatch === void 0 ? void 0 : previousMatch.payment;
|
|
4215
4567
|
if (!((previousPayment === null || previousPayment === void 0 ? void 0 : previousPayment.status) === 'paid' && !options.applyUpdatesWhenPaid)) {
|
|
4216
|
-
|
|
4568
|
+
_context40.next = 13;
|
|
4217
4569
|
break;
|
|
4218
4570
|
}
|
|
4219
4571
|
currentPayments = this.store.order.getOrderPayments();
|
|
4220
4572
|
if (!(options.submitWhenPaid && options.forceSubmitIfPaid)) {
|
|
4221
|
-
|
|
4573
|
+
_context40.next = 12;
|
|
4222
4574
|
break;
|
|
4223
4575
|
}
|
|
4224
|
-
|
|
4576
|
+
_context40.next = 11;
|
|
4225
4577
|
return this.syncPaymentsToOrder({
|
|
4226
4578
|
payments: currentPayments,
|
|
4227
4579
|
paymentStatus: this.getPaymentStatusForSync(currentPayments),
|
|
@@ -4229,55 +4581,55 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4229
4581
|
smallTicketDataFlag: (_options$smallTicketD = options.smallTicketDataFlag) !== null && _options$smallTicketD !== void 0 ? _options$smallTicketD : 1
|
|
4230
4582
|
});
|
|
4231
4583
|
case 11:
|
|
4232
|
-
_syncResult =
|
|
4584
|
+
_syncResult = _context40.sent;
|
|
4233
4585
|
case 12:
|
|
4234
|
-
return
|
|
4586
|
+
return _context40.abrupt("return", _objectSpread({
|
|
4235
4587
|
updated: false,
|
|
4236
4588
|
payment: previousPayment,
|
|
4237
4589
|
payments: currentPayments,
|
|
4238
|
-
summary: ((_this$store$order$
|
|
4590
|
+
summary: ((_this$store$order$get5 = this.store.order.getOrderAmountSnapshot()) === null || _this$store$order$get5 === void 0 ? void 0 : _this$store$order$get5.summary) || null
|
|
4239
4591
|
}, _syncResult !== undefined ? {
|
|
4240
4592
|
syncResult: _syncResult
|
|
4241
4593
|
} : {}));
|
|
4242
4594
|
case 13:
|
|
4243
|
-
|
|
4595
|
+
_context40.next = 15;
|
|
4244
4596
|
return this.store.order.updateOrderPayment(paymentIdentity, updates, {
|
|
4245
4597
|
matchBy: matchMode
|
|
4246
4598
|
});
|
|
4247
4599
|
case 15:
|
|
4248
|
-
result =
|
|
4600
|
+
result = _context40.sent;
|
|
4249
4601
|
if (!(options.persistDraft !== false)) {
|
|
4250
|
-
|
|
4602
|
+
_context40.next = 29;
|
|
4251
4603
|
break;
|
|
4252
4604
|
}
|
|
4253
|
-
|
|
4254
|
-
|
|
4605
|
+
_context40.prev = 17;
|
|
4606
|
+
_context40.next = 20;
|
|
4255
4607
|
return this.saveSalesOrderDraft();
|
|
4256
4608
|
case 20:
|
|
4257
|
-
draftResult =
|
|
4258
|
-
|
|
4609
|
+
draftResult = _context40.sent;
|
|
4610
|
+
_context40.next = 29;
|
|
4259
4611
|
break;
|
|
4260
4612
|
case 23:
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
draftError =
|
|
4613
|
+
_context40.prev = 23;
|
|
4614
|
+
_context40.t0 = _context40["catch"](17);
|
|
4615
|
+
draftError = _context40.t0;
|
|
4264
4616
|
this.logError('updateOrderPayment: 保存支付草稿失败', {
|
|
4265
4617
|
paymentIdentity: paymentIdentity,
|
|
4266
|
-
error:
|
|
4618
|
+
error: _context40.t0 instanceof Error ? _context40.t0.message : String(_context40.t0)
|
|
4267
4619
|
});
|
|
4268
4620
|
if (options.submitWhenPaid) {
|
|
4269
|
-
|
|
4621
|
+
_context40.next = 29;
|
|
4270
4622
|
break;
|
|
4271
4623
|
}
|
|
4272
|
-
throw
|
|
4624
|
+
throw _context40.t0;
|
|
4273
4625
|
case 29:
|
|
4274
4626
|
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';
|
|
4275
4627
|
shouldSubmit = Boolean(options.submitWhenPaid && ((_result$payment2 = result.payment) === null || _result$payment2 === void 0 ? void 0 : _result$payment2.status) === 'paid' && (becamePaid || options.forceSubmitIfPaid));
|
|
4276
4628
|
if (!shouldSubmit) {
|
|
4277
|
-
|
|
4629
|
+
_context40.next = 35;
|
|
4278
4630
|
break;
|
|
4279
4631
|
}
|
|
4280
|
-
|
|
4632
|
+
_context40.next = 34;
|
|
4281
4633
|
return this.syncPaymentsToOrder({
|
|
4282
4634
|
payments: result.payments,
|
|
4283
4635
|
paymentStatus: this.getPaymentStatusForSync(result.payments),
|
|
@@ -4285,9 +4637,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4285
4637
|
smallTicketDataFlag: (_options$smallTicketD2 = options.smallTicketDataFlag) !== null && _options$smallTicketD2 !== void 0 ? _options$smallTicketD2 : 1
|
|
4286
4638
|
});
|
|
4287
4639
|
case 34:
|
|
4288
|
-
syncResult =
|
|
4640
|
+
syncResult = _context40.sent;
|
|
4289
4641
|
case 35:
|
|
4290
|
-
return
|
|
4642
|
+
return _context40.abrupt("return", _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, result), draftResult !== undefined ? {
|
|
4291
4643
|
draftResult: draftResult
|
|
4292
4644
|
} : {}), draftError !== undefined ? {
|
|
4293
4645
|
draftError: draftError
|
|
@@ -4296,11 +4648,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4296
4648
|
} : {}));
|
|
4297
4649
|
case 36:
|
|
4298
4650
|
case "end":
|
|
4299
|
-
return
|
|
4651
|
+
return _context40.stop();
|
|
4300
4652
|
}
|
|
4301
|
-
},
|
|
4653
|
+
}, _callee40, this, [[17, 23]]);
|
|
4302
4654
|
}));
|
|
4303
|
-
function updateOrderPayment(
|
|
4655
|
+
function updateOrderPayment(_x31, _x32) {
|
|
4304
4656
|
return _updateOrderPayment.apply(this, arguments);
|
|
4305
4657
|
}
|
|
4306
4658
|
return updateOrderPayment;
|
|
@@ -4322,24 +4674,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4322
4674
|
}, {
|
|
4323
4675
|
key: "updateVoucherOrderPaymentsAsync",
|
|
4324
4676
|
value: function () {
|
|
4325
|
-
var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4326
|
-
return _regeneratorRuntime().wrap(function
|
|
4327
|
-
while (1) switch (
|
|
4677
|
+
var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(payments, options) {
|
|
4678
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context41) {
|
|
4679
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
4328
4680
|
case 0:
|
|
4329
4681
|
if (this.store.order) {
|
|
4330
|
-
|
|
4682
|
+
_context41.next = 2;
|
|
4331
4683
|
break;
|
|
4332
4684
|
}
|
|
4333
4685
|
throw new Error('order 模块未初始化');
|
|
4334
4686
|
case 2:
|
|
4335
|
-
return
|
|
4687
|
+
return _context41.abrupt("return", this.store.order.updateVoucherOrderPaymentsAsync(payments, options));
|
|
4336
4688
|
case 3:
|
|
4337
4689
|
case "end":
|
|
4338
|
-
return
|
|
4690
|
+
return _context41.stop();
|
|
4339
4691
|
}
|
|
4340
|
-
},
|
|
4692
|
+
}, _callee41, this);
|
|
4341
4693
|
}));
|
|
4342
|
-
function updateVoucherOrderPaymentsAsync(
|
|
4694
|
+
function updateVoucherOrderPaymentsAsync(_x33, _x34) {
|
|
4343
4695
|
return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
|
|
4344
4696
|
}
|
|
4345
4697
|
return updateVoucherOrderPaymentsAsync;
|
|
@@ -4352,7 +4704,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4352
4704
|
if (this.store.payment) {
|
|
4353
4705
|
var committed = this.getCommittedWalletAssets();
|
|
4354
4706
|
var state = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
4355
|
-
void this.publishWalletAssetsState(state);
|
|
4707
|
+
void this.publishWalletAssetsState(state, 'local');
|
|
4356
4708
|
}
|
|
4357
4709
|
return payments;
|
|
4358
4710
|
}
|
|
@@ -4365,8 +4717,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4365
4717
|
}, {
|
|
4366
4718
|
key: "getWalletProductList",
|
|
4367
4719
|
value: function getWalletProductList() {
|
|
4368
|
-
var _this$store$
|
|
4369
|
-
var tempOrder = (_this$store$
|
|
4720
|
+
var _this$store$order12, _tempOrder$products;
|
|
4721
|
+
var tempOrder = (_this$store$order12 = this.store.order) === null || _this$store$order12 === void 0 ? void 0 : _this$store$order12.getTempOrder();
|
|
4370
4722
|
if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$products = tempOrder.products) !== null && _tempOrder$products !== void 0 && _tempOrder$products.length)) return [];
|
|
4371
4723
|
// 过滤出有 product_id的商品来,如果没有代表他是自定义商品,不需要参与 wallet
|
|
4372
4724
|
// debugger
|
|
@@ -4426,8 +4778,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4426
4778
|
}, {
|
|
4427
4779
|
key: "buildWalletInitBusinessData",
|
|
4428
4780
|
value: function buildWalletInitBusinessData(params) {
|
|
4429
|
-
var _this$store$
|
|
4430
|
-
var snapshot = (_this$store$
|
|
4781
|
+
var _this$store$order13, _params$order_wait_pa, _ref49, _tempOrder$is_price_i;
|
|
4782
|
+
var snapshot = (_this$store$order13 = this.store.order) === null || _this$store$order13 === void 0 ? void 0 : _this$store$order13.getOrderSnapshot();
|
|
4431
4783
|
var tempOrder = snapshot === null || snapshot === void 0 ? void 0 : snapshot.tempOrder;
|
|
4432
4784
|
var amount = snapshot === null || snapshot === void 0 ? void 0 : snapshot.amount;
|
|
4433
4785
|
if (!tempOrder || !amount) return null;
|
|
@@ -4442,7 +4794,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4442
4794
|
},
|
|
4443
4795
|
products: this.getWalletProductList(),
|
|
4444
4796
|
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),
|
|
4445
|
-
is_price_include_tax: (
|
|
4797
|
+
is_price_include_tax: (_ref49 = (_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 && _ref49 !== void 0 ? _ref49 : 1
|
|
4446
4798
|
}, snapshot.identity.orderId ? {
|
|
4447
4799
|
payment_order_id: String(snapshot.identity.orderId)
|
|
4448
4800
|
} : {});
|
|
@@ -4450,20 +4802,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4450
4802
|
}, {
|
|
4451
4803
|
key: "initWalletData",
|
|
4452
4804
|
value: function () {
|
|
4453
|
-
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4805
|
+
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
|
|
4454
4806
|
var _snapshot$identity;
|
|
4455
4807
|
var snapshot, walletBusinessData, result;
|
|
4456
|
-
return _regeneratorRuntime().wrap(function
|
|
4457
|
-
while (1) switch (
|
|
4808
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context42) {
|
|
4809
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
4458
4810
|
case 0:
|
|
4459
4811
|
if (this.store.order) {
|
|
4460
|
-
|
|
4812
|
+
_context42.next = 2;
|
|
4461
4813
|
break;
|
|
4462
4814
|
}
|
|
4463
4815
|
throw new Error('order 模块未初始化');
|
|
4464
4816
|
case 2:
|
|
4465
4817
|
if (this.store.payment) {
|
|
4466
|
-
|
|
4818
|
+
_context42.next = 4;
|
|
4467
4819
|
break;
|
|
4468
4820
|
}
|
|
4469
4821
|
throw new Error('payment 模块未初始化');
|
|
@@ -4471,10 +4823,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4471
4823
|
snapshot = this.store.order.getOrderSnapshot();
|
|
4472
4824
|
walletBusinessData = this.buildWalletInitBusinessData(params);
|
|
4473
4825
|
if (walletBusinessData) {
|
|
4474
|
-
|
|
4826
|
+
_context42.next = 8;
|
|
4475
4827
|
break;
|
|
4476
4828
|
}
|
|
4477
|
-
return
|
|
4829
|
+
return _context42.abrupt("return", {
|
|
4478
4830
|
walletRecommendList: [],
|
|
4479
4831
|
userIdentificationCodes: [],
|
|
4480
4832
|
transformList: [],
|
|
@@ -4482,11 +4834,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4482
4834
|
products: []
|
|
4483
4835
|
});
|
|
4484
4836
|
case 8:
|
|
4485
|
-
|
|
4837
|
+
_context42.next = 10;
|
|
4486
4838
|
return this.store.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
|
|
4487
4839
|
case 10:
|
|
4488
|
-
result =
|
|
4489
|
-
|
|
4840
|
+
result = _context42.sent;
|
|
4841
|
+
_context42.next = 13;
|
|
4490
4842
|
return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
|
|
4491
4843
|
orderId: snapshot === null || snapshot === void 0 || (_snapshot$identity = snapshot.identity) === null || _snapshot$identity === void 0 ? void 0 : _snapshot$identity.orderId,
|
|
4492
4844
|
customerId: walletBusinessData.customer_id,
|
|
@@ -4498,14 +4850,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4498
4850
|
timestamp: Date.now()
|
|
4499
4851
|
});
|
|
4500
4852
|
case 13:
|
|
4501
|
-
return
|
|
4853
|
+
return _context42.abrupt("return", result);
|
|
4502
4854
|
case 14:
|
|
4503
4855
|
case "end":
|
|
4504
|
-
return
|
|
4856
|
+
return _context42.stop();
|
|
4505
4857
|
}
|
|
4506
|
-
},
|
|
4858
|
+
}, _callee42, this);
|
|
4507
4859
|
}));
|
|
4508
|
-
function initWalletData(
|
|
4860
|
+
function initWalletData(_x35) {
|
|
4509
4861
|
return _initWalletData.apply(this, arguments);
|
|
4510
4862
|
}
|
|
4511
4863
|
return initWalletData;
|
|
@@ -4513,8 +4865,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4513
4865
|
}, {
|
|
4514
4866
|
key: "getCommittedWalletAssets",
|
|
4515
4867
|
value: function getCommittedWalletAssets() {
|
|
4516
|
-
var _this$store$
|
|
4517
|
-
var payments = ((_this$store$
|
|
4868
|
+
var _this$store$order14, _this$store$order14$g;
|
|
4869
|
+
var payments = ((_this$store$order14 = this.store.order) === null || _this$store$order14 === void 0 || (_this$store$order14$g = _this$store$order14.getOrderPayments) === null || _this$store$order14$g === void 0 ? void 0 : _this$store$order14$g.call(_this$store$order14)) || [];
|
|
4518
4870
|
var committed = payments.filter(function (payment) {
|
|
4519
4871
|
var voucherId = payment === null || payment === void 0 ? void 0 : payment.voucher_id;
|
|
4520
4872
|
if (voucherId === undefined || voucherId === null || voucherId === 0) {
|
|
@@ -4532,9 +4884,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4532
4884
|
var walletPassName = fundRecord.wallet_pass_name;
|
|
4533
4885
|
var title = walletPassName && _typeof(walletPassName) === 'object' ? walletPassName.default || Object.values(walletPassName)[0] : walletPassName;
|
|
4534
4886
|
var code = String((payment === null || payment === void 0 ? void 0 : payment.code) || '').toUpperCase();
|
|
4535
|
-
var tag = ((_Object$entries$find = Object.entries(WALLET_PAYMENT_CODE_BY_TAG).find(function (
|
|
4536
|
-
var
|
|
4537
|
-
paymentCode =
|
|
4887
|
+
var tag = ((_Object$entries$find = Object.entries(WALLET_PAYMENT_CODE_BY_TAG).find(function (_ref50) {
|
|
4888
|
+
var _ref51 = _slicedToArray(_ref50, 2),
|
|
4889
|
+
paymentCode = _ref51[1];
|
|
4538
4890
|
return paymentCode === code;
|
|
4539
4891
|
})) === null || _Object$entries$find === void 0 ? void 0 : _Object$entries$find[0]) || fundRecord.tag;
|
|
4540
4892
|
return {
|
|
@@ -4556,23 +4908,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4556
4908
|
}, {
|
|
4557
4909
|
key: "publishWalletAssetsState",
|
|
4558
4910
|
value: function () {
|
|
4559
|
-
var _publishWalletAssetsState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4560
|
-
|
|
4561
|
-
|
|
4911
|
+
var _publishWalletAssetsState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(state) {
|
|
4912
|
+
var changeSource,
|
|
4913
|
+
_args43 = arguments;
|
|
4914
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context43) {
|
|
4915
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
4562
4916
|
case 0:
|
|
4563
|
-
|
|
4917
|
+
changeSource = _args43.length > 1 && _args43[1] !== undefined ? _args43[1] : 'derived';
|
|
4918
|
+
_context43.next = 3;
|
|
4564
4919
|
return this.effectsEmit(BaseSalesHookNames.onWalletAssetsStateChanged, {
|
|
4565
|
-
state: state
|
|
4920
|
+
state: state,
|
|
4921
|
+
changeSource: changeSource
|
|
4566
4922
|
});
|
|
4567
|
-
case 2:
|
|
4568
|
-
return _context40.abrupt("return", state);
|
|
4569
4923
|
case 3:
|
|
4924
|
+
return _context43.abrupt("return", state);
|
|
4925
|
+
case 4:
|
|
4570
4926
|
case "end":
|
|
4571
|
-
return
|
|
4927
|
+
return _context43.stop();
|
|
4572
4928
|
}
|
|
4573
|
-
},
|
|
4929
|
+
}, _callee43, this);
|
|
4574
4930
|
}));
|
|
4575
|
-
function publishWalletAssetsState(
|
|
4931
|
+
function publishWalletAssetsState(_x36) {
|
|
4576
4932
|
return _publishWalletAssetsState.apply(this, arguments);
|
|
4577
4933
|
}
|
|
4578
4934
|
return publishWalletAssetsState;
|
|
@@ -4580,26 +4936,26 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4580
4936
|
}, {
|
|
4581
4937
|
key: "syncSelectedWalletAssets",
|
|
4582
4938
|
value: function () {
|
|
4583
|
-
var _syncSelectedWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4939
|
+
var _syncSelectedWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(state) {
|
|
4584
4940
|
var paymentMethods, methodByCode, preparePayments, selectedAssetById, voucherPayments, payments;
|
|
4585
|
-
return _regeneratorRuntime().wrap(function
|
|
4586
|
-
while (1) switch (
|
|
4941
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context44) {
|
|
4942
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
4587
4943
|
case 0:
|
|
4588
4944
|
if (!(!this.store.order || !this.store.payment)) {
|
|
4589
|
-
|
|
4945
|
+
_context44.next = 2;
|
|
4590
4946
|
break;
|
|
4591
4947
|
}
|
|
4592
4948
|
throw new Error('订单或支付模块未初始化');
|
|
4593
4949
|
case 2:
|
|
4594
4950
|
paymentMethods = this.getPaymentMethods();
|
|
4595
4951
|
if (!(!paymentMethods.length && state.selectedItems.length)) {
|
|
4596
|
-
|
|
4952
|
+
_context44.next = 7;
|
|
4597
4953
|
break;
|
|
4598
4954
|
}
|
|
4599
|
-
|
|
4955
|
+
_context44.next = 6;
|
|
4600
4956
|
return this.getPaymentMethodsAsync();
|
|
4601
4957
|
case 6:
|
|
4602
|
-
paymentMethods =
|
|
4958
|
+
paymentMethods = _context44.sent;
|
|
4603
4959
|
case 7:
|
|
4604
4960
|
methodByCode = new Map(paymentMethods.map(function (method) {
|
|
4605
4961
|
return [String(method.code || '').toUpperCase(), method];
|
|
@@ -4641,19 +4997,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4641
4997
|
payments = this.updateVoucherOrderPayments(voucherPayments, {
|
|
4642
4998
|
status: 'payment_pending'
|
|
4643
4999
|
});
|
|
4644
|
-
|
|
5000
|
+
_context44.next = 14;
|
|
4645
5001
|
return this.store.order.recalculateSummary({
|
|
4646
5002
|
createIfMissing: true
|
|
4647
5003
|
});
|
|
4648
5004
|
case 14:
|
|
4649
|
-
return
|
|
5005
|
+
return _context44.abrupt("return", payments);
|
|
4650
5006
|
case 15:
|
|
4651
5007
|
case "end":
|
|
4652
|
-
return
|
|
5008
|
+
return _context44.stop();
|
|
4653
5009
|
}
|
|
4654
|
-
},
|
|
5010
|
+
}, _callee44, this);
|
|
4655
5011
|
}));
|
|
4656
|
-
function syncSelectedWalletAssets(
|
|
5012
|
+
function syncSelectedWalletAssets(_x37) {
|
|
4657
5013
|
return _syncSelectedWalletAssets.apply(this, arguments);
|
|
4658
5014
|
}
|
|
4659
5015
|
return syncSelectedWalletAssets;
|
|
@@ -4687,29 +5043,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4687
5043
|
}, {
|
|
4688
5044
|
key: "importWalletAssetsSnapshot",
|
|
4689
5045
|
value: (function () {
|
|
4690
|
-
var _importWalletAssetsSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5046
|
+
var _importWalletAssetsSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(snapshot) {
|
|
4691
5047
|
var state;
|
|
4692
|
-
return _regeneratorRuntime().wrap(function
|
|
4693
|
-
while (1) switch (
|
|
5048
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context45) {
|
|
5049
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
4694
5050
|
case 0:
|
|
4695
5051
|
if (this.store.payment) {
|
|
4696
|
-
|
|
5052
|
+
_context45.next = 2;
|
|
4697
5053
|
break;
|
|
4698
5054
|
}
|
|
4699
5055
|
throw new Error('payment 模块未初始化');
|
|
4700
5056
|
case 2:
|
|
4701
5057
|
state = this.store.payment.wallet.importWalletAssetsSnapshot(snapshot);
|
|
4702
|
-
|
|
5058
|
+
_context45.next = 5;
|
|
4703
5059
|
return this.syncSelectedWalletAssets(state);
|
|
4704
5060
|
case 5:
|
|
4705
|
-
return
|
|
5061
|
+
return _context45.abrupt("return", this.publishWalletAssetsState(state));
|
|
4706
5062
|
case 6:
|
|
4707
5063
|
case "end":
|
|
4708
|
-
return
|
|
5064
|
+
return _context45.stop();
|
|
4709
5065
|
}
|
|
4710
|
-
},
|
|
5066
|
+
}, _callee45, this);
|
|
4711
5067
|
}));
|
|
4712
|
-
function importWalletAssetsSnapshot(
|
|
5068
|
+
function importWalletAssetsSnapshot(_x38) {
|
|
4713
5069
|
return _importWalletAssetsSnapshot.apply(this, arguments);
|
|
4714
5070
|
}
|
|
4715
5071
|
return importWalletAssetsSnapshot;
|
|
@@ -4721,20 +5077,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4721
5077
|
}, {
|
|
4722
5078
|
key: "refreshWalletAssets",
|
|
4723
5079
|
value: (function () {
|
|
4724
|
-
var _refreshWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5080
|
+
var _refreshWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(params) {
|
|
4725
5081
|
var _previousState$custom, _businessData$custome;
|
|
4726
5082
|
var refreshSequence, wallet, businessData, emptyState, previousState, hasPreviousWalletContext, customerChanged, clearedState, refreshTask, state, committed;
|
|
4727
|
-
return _regeneratorRuntime().wrap(function
|
|
4728
|
-
while (1) switch (
|
|
5083
|
+
return _regeneratorRuntime().wrap(function _callee46$(_context46) {
|
|
5084
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
4729
5085
|
case 0:
|
|
4730
5086
|
if (this.store.order) {
|
|
4731
|
-
|
|
5087
|
+
_context46.next = 2;
|
|
4732
5088
|
break;
|
|
4733
5089
|
}
|
|
4734
5090
|
throw new Error('order 模块未初始化');
|
|
4735
5091
|
case 2:
|
|
4736
5092
|
if (this.store.payment) {
|
|
4737
|
-
|
|
5093
|
+
_context46.next = 4;
|
|
4738
5094
|
break;
|
|
4739
5095
|
}
|
|
4740
5096
|
throw new Error('payment 模块未初始化');
|
|
@@ -4743,7 +5099,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4743
5099
|
wallet = this.store.payment.wallet;
|
|
4744
5100
|
businessData = this.buildWalletInitBusinessData(params);
|
|
4745
5101
|
if (businessData) {
|
|
4746
|
-
|
|
5102
|
+
_context46.next = 12;
|
|
4747
5103
|
break;
|
|
4748
5104
|
}
|
|
4749
5105
|
wallet.clearAllCache();
|
|
@@ -4751,54 +5107,54 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4751
5107
|
this.updateVoucherOrderPayments([], {
|
|
4752
5108
|
status: 'payment_pending'
|
|
4753
5109
|
});
|
|
4754
|
-
return
|
|
5110
|
+
return _context46.abrupt("return", this.publishWalletAssetsState(emptyState));
|
|
4755
5111
|
case 12:
|
|
4756
5112
|
previousState = wallet.getWalletAssetsState();
|
|
4757
5113
|
hasPreviousWalletContext = previousState.status !== 'idle' || previousState.items.length > 0 || previousState.selectedIds.length > 0 || previousState.customerId !== undefined;
|
|
4758
5114
|
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 : '');
|
|
4759
5115
|
if (!customerChanged) {
|
|
4760
|
-
|
|
5116
|
+
_context46.next = 20;
|
|
4761
5117
|
break;
|
|
4762
5118
|
}
|
|
4763
5119
|
clearedState = wallet.clearWalletAssetSelection();
|
|
4764
5120
|
this.updateVoucherOrderPayments([], {
|
|
4765
5121
|
status: 'payment_pending'
|
|
4766
5122
|
});
|
|
4767
|
-
|
|
5123
|
+
_context46.next = 20;
|
|
4768
5124
|
return this.publishWalletAssetsState(clearedState);
|
|
4769
5125
|
case 20:
|
|
4770
5126
|
refreshTask = wallet.refreshWalletAssetsFromBusinessAsync(businessData, {
|
|
4771
5127
|
preserveSelection: (params === null || params === void 0 ? void 0 : params.preserveSelection) !== false && !customerChanged,
|
|
4772
5128
|
retainSearchResultCodes: params === null || params === void 0 ? void 0 : params.retainSearchResultCodes
|
|
4773
5129
|
});
|
|
4774
|
-
|
|
5130
|
+
_context46.next = 23;
|
|
4775
5131
|
return this.publishWalletAssetsState(wallet.getWalletAssetsState());
|
|
4776
5132
|
case 23:
|
|
4777
|
-
|
|
5133
|
+
_context46.next = 25;
|
|
4778
5134
|
return refreshTask;
|
|
4779
5135
|
case 25:
|
|
4780
|
-
state =
|
|
5136
|
+
state = _context46.sent;
|
|
4781
5137
|
if (!(refreshSequence !== this.walletAssetsRefreshSequence)) {
|
|
4782
|
-
|
|
5138
|
+
_context46.next = 28;
|
|
4783
5139
|
break;
|
|
4784
5140
|
}
|
|
4785
|
-
return
|
|
5141
|
+
return _context46.abrupt("return", wallet.getWalletAssetsState());
|
|
4786
5142
|
case 28:
|
|
4787
5143
|
if (state.status !== 'error') {
|
|
4788
5144
|
committed = this.getCommittedWalletAssets();
|
|
4789
5145
|
state = wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
4790
5146
|
}
|
|
4791
|
-
|
|
5147
|
+
_context46.next = 31;
|
|
4792
5148
|
return this.syncSelectedWalletAssets(state);
|
|
4793
5149
|
case 31:
|
|
4794
|
-
return
|
|
5150
|
+
return _context46.abrupt("return", this.publishWalletAssetsState(state));
|
|
4795
5151
|
case 32:
|
|
4796
5152
|
case "end":
|
|
4797
|
-
return
|
|
5153
|
+
return _context46.stop();
|
|
4798
5154
|
}
|
|
4799
|
-
},
|
|
5155
|
+
}, _callee46, this);
|
|
4800
5156
|
}));
|
|
4801
|
-
function refreshWalletAssets(
|
|
5157
|
+
function refreshWalletAssets(_x39) {
|
|
4802
5158
|
return _refreshWalletAssets.apply(this, arguments);
|
|
4803
5159
|
}
|
|
4804
5160
|
return refreshWalletAssets;
|
|
@@ -4806,13 +5162,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4806
5162
|
}, {
|
|
4807
5163
|
key: "selectWalletAsset",
|
|
4808
5164
|
value: (function () {
|
|
4809
|
-
var _selectWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5165
|
+
var _selectWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
|
|
4810
5166
|
var state;
|
|
4811
|
-
return _regeneratorRuntime().wrap(function
|
|
4812
|
-
while (1) switch (
|
|
5167
|
+
return _regeneratorRuntime().wrap(function _callee47$(_context47) {
|
|
5168
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
4813
5169
|
case 0:
|
|
4814
5170
|
if (this.store.payment) {
|
|
4815
|
-
|
|
5171
|
+
_context47.next = 2;
|
|
4816
5172
|
break;
|
|
4817
5173
|
}
|
|
4818
5174
|
throw new Error('payment 模块未初始化');
|
|
@@ -4821,17 +5177,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4821
5177
|
selected: params.selected,
|
|
4822
5178
|
source: params.source
|
|
4823
5179
|
});
|
|
4824
|
-
|
|
5180
|
+
_context47.next = 5;
|
|
4825
5181
|
return this.syncSelectedWalletAssets(state);
|
|
4826
5182
|
case 5:
|
|
4827
|
-
return
|
|
5183
|
+
return _context47.abrupt("return", this.publishWalletAssetsState(state, 'local'));
|
|
4828
5184
|
case 6:
|
|
4829
5185
|
case "end":
|
|
4830
|
-
return
|
|
5186
|
+
return _context47.stop();
|
|
4831
5187
|
}
|
|
4832
|
-
},
|
|
5188
|
+
}, _callee47, this);
|
|
4833
5189
|
}));
|
|
4834
|
-
function selectWalletAsset(
|
|
5190
|
+
function selectWalletAsset(_x40) {
|
|
4835
5191
|
return _selectWalletAsset.apply(this, arguments);
|
|
4836
5192
|
}
|
|
4837
5193
|
return selectWalletAsset;
|
|
@@ -4839,29 +5195,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4839
5195
|
}, {
|
|
4840
5196
|
key: "updateWalletAssetAmount",
|
|
4841
5197
|
value: (function () {
|
|
4842
|
-
var _updateWalletAssetAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5198
|
+
var _updateWalletAssetAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(params) {
|
|
4843
5199
|
var state;
|
|
4844
|
-
return _regeneratorRuntime().wrap(function
|
|
4845
|
-
while (1) switch (
|
|
5200
|
+
return _regeneratorRuntime().wrap(function _callee48$(_context48) {
|
|
5201
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
4846
5202
|
case 0:
|
|
4847
5203
|
if (this.store.payment) {
|
|
4848
|
-
|
|
5204
|
+
_context48.next = 2;
|
|
4849
5205
|
break;
|
|
4850
5206
|
}
|
|
4851
5207
|
throw new Error('payment 模块未初始化');
|
|
4852
5208
|
case 2:
|
|
4853
5209
|
state = this.store.payment.wallet.updateWalletAssetAmount(params.assetId, params.amount);
|
|
4854
|
-
|
|
5210
|
+
_context48.next = 5;
|
|
4855
5211
|
return this.syncSelectedWalletAssets(state);
|
|
4856
5212
|
case 5:
|
|
4857
|
-
return
|
|
5213
|
+
return _context48.abrupt("return", this.publishWalletAssetsState(state, 'local'));
|
|
4858
5214
|
case 6:
|
|
4859
5215
|
case "end":
|
|
4860
|
-
return
|
|
5216
|
+
return _context48.stop();
|
|
4861
5217
|
}
|
|
4862
|
-
},
|
|
5218
|
+
}, _callee48, this);
|
|
4863
5219
|
}));
|
|
4864
|
-
function updateWalletAssetAmount(
|
|
5220
|
+
function updateWalletAssetAmount(_x41) {
|
|
4865
5221
|
return _updateWalletAssetAmount.apply(this, arguments);
|
|
4866
5222
|
}
|
|
4867
5223
|
return updateWalletAssetAmount;
|
|
@@ -4869,13 +5225,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4869
5225
|
}, {
|
|
4870
5226
|
key: "scanWalletAsset",
|
|
4871
5227
|
value: (function () {
|
|
4872
|
-
var _scanWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5228
|
+
var _scanWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(code) {
|
|
4873
5229
|
var wallet, businessData, result;
|
|
4874
|
-
return _regeneratorRuntime().wrap(function
|
|
4875
|
-
while (1) switch (
|
|
5230
|
+
return _regeneratorRuntime().wrap(function _callee49$(_context49) {
|
|
5231
|
+
while (1) switch (_context49.prev = _context49.next) {
|
|
4876
5232
|
case 0:
|
|
4877
5233
|
if (this.store.payment) {
|
|
4878
|
-
|
|
5234
|
+
_context49.next = 2;
|
|
4879
5235
|
break;
|
|
4880
5236
|
}
|
|
4881
5237
|
throw new Error('payment 模块未初始化');
|
|
@@ -4885,28 +5241,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4885
5241
|
if (businessData) {
|
|
4886
5242
|
wallet.generateWalletParams(businessData);
|
|
4887
5243
|
}
|
|
4888
|
-
|
|
5244
|
+
_context49.next = 7;
|
|
4889
5245
|
return wallet.scanWalletAssetAsync(code);
|
|
4890
5246
|
case 7:
|
|
4891
|
-
result =
|
|
5247
|
+
result = _context49.sent;
|
|
4892
5248
|
if (!(result.type === 'normalCode')) {
|
|
4893
|
-
|
|
5249
|
+
_context49.next = 13;
|
|
4894
5250
|
break;
|
|
4895
5251
|
}
|
|
4896
|
-
|
|
5252
|
+
_context49.next = 11;
|
|
4897
5253
|
return this.syncSelectedWalletAssets(result.state);
|
|
4898
5254
|
case 11:
|
|
4899
|
-
|
|
4900
|
-
return this.publishWalletAssetsState(result.state);
|
|
5255
|
+
_context49.next = 13;
|
|
5256
|
+
return this.publishWalletAssetsState(result.state, 'local');
|
|
4901
5257
|
case 13:
|
|
4902
|
-
return
|
|
5258
|
+
return _context49.abrupt("return", result);
|
|
4903
5259
|
case 14:
|
|
4904
5260
|
case "end":
|
|
4905
|
-
return
|
|
5261
|
+
return _context49.stop();
|
|
4906
5262
|
}
|
|
4907
|
-
},
|
|
5263
|
+
}, _callee49, this);
|
|
4908
5264
|
}));
|
|
4909
|
-
function scanWalletAsset(
|
|
5265
|
+
function scanWalletAsset(_x42) {
|
|
4910
5266
|
return _scanWalletAsset.apply(this, arguments);
|
|
4911
5267
|
}
|
|
4912
5268
|
return scanWalletAsset;
|
|
@@ -4914,27 +5270,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4914
5270
|
}, {
|
|
4915
5271
|
key: "clearWalletAssetSelection",
|
|
4916
5272
|
value: (function () {
|
|
4917
|
-
var _clearWalletAssetSelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5273
|
+
var _clearWalletAssetSelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50() {
|
|
4918
5274
|
var state;
|
|
4919
|
-
return _regeneratorRuntime().wrap(function
|
|
4920
|
-
while (1) switch (
|
|
5275
|
+
return _regeneratorRuntime().wrap(function _callee50$(_context50) {
|
|
5276
|
+
while (1) switch (_context50.prev = _context50.next) {
|
|
4921
5277
|
case 0:
|
|
4922
5278
|
if (this.store.payment) {
|
|
4923
|
-
|
|
5279
|
+
_context50.next = 2;
|
|
4924
5280
|
break;
|
|
4925
5281
|
}
|
|
4926
5282
|
throw new Error('payment 模块未初始化');
|
|
4927
5283
|
case 2:
|
|
4928
5284
|
state = this.store.payment.wallet.clearWalletAssetSelection();
|
|
4929
|
-
|
|
5285
|
+
_context50.next = 5;
|
|
4930
5286
|
return this.syncSelectedWalletAssets(state);
|
|
4931
5287
|
case 5:
|
|
4932
|
-
return
|
|
5288
|
+
return _context50.abrupt("return", this.publishWalletAssetsState(state, 'local'));
|
|
4933
5289
|
case 6:
|
|
4934
5290
|
case "end":
|
|
4935
|
-
return
|
|
5291
|
+
return _context50.stop();
|
|
4936
5292
|
}
|
|
4937
|
-
},
|
|
5293
|
+
}, _callee50, this);
|
|
4938
5294
|
}));
|
|
4939
5295
|
function clearWalletAssetSelection() {
|
|
4940
5296
|
return _clearWalletAssetSelection.apply(this, arguments);
|
|
@@ -4951,8 +5307,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4951
5307
|
}, {
|
|
4952
5308
|
key: "updateOrderCustomer",
|
|
4953
5309
|
value: function updateOrderCustomer(customer) {
|
|
5310
|
+
var _this$store$order$get6, _this$store$order15, _this$store$order$get7, _this$store$order16;
|
|
4954
5311
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
5312
|
+
var previousCustomerId = this.resolveDiscountConfigCustomerId((_this$store$order$get6 = (_this$store$order15 = this.store.order).getTempOrder) === null || _this$store$order$get6 === void 0 ? void 0 : _this$store$order$get6.call(_this$store$order15));
|
|
4955
5313
|
var result = this.store.order.updateTempOrderCustomer(customer);
|
|
5314
|
+
var nextCustomerId = this.resolveDiscountConfigCustomerId((_this$store$order$get7 = (_this$store$order16 = this.store.order).getTempOrder) === null || _this$store$order$get7 === void 0 ? void 0 : _this$store$order$get7.call(_this$store$order16));
|
|
5315
|
+
if (String(previousCustomerId) !== String(nextCustomerId)) {
|
|
5316
|
+
this.discountConfigCacheKey = null;
|
|
5317
|
+
this.hasManualDiscountSelection = false;
|
|
5318
|
+
}
|
|
4956
5319
|
this.store.order.recalculateSummary({
|
|
4957
5320
|
createIfMissing: true
|
|
4958
5321
|
});
|
|
@@ -4964,35 +5327,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4964
5327
|
}, {
|
|
4965
5328
|
key: "getPaymentMethodsAsync",
|
|
4966
5329
|
value: (function () {
|
|
4967
|
-
var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5330
|
+
var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51() {
|
|
4968
5331
|
var response, paymentMethods;
|
|
4969
|
-
return _regeneratorRuntime().wrap(function
|
|
4970
|
-
while (1) switch (
|
|
5332
|
+
return _regeneratorRuntime().wrap(function _callee51$(_context51) {
|
|
5333
|
+
while (1) switch (_context51.prev = _context51.next) {
|
|
4971
5334
|
case 0:
|
|
4972
|
-
|
|
4973
|
-
|
|
5335
|
+
_context51.prev = 0;
|
|
5336
|
+
_context51.next = 3;
|
|
4974
5337
|
return this.request.get('/pay/custom-payment/all', {
|
|
4975
5338
|
filterPaymentMethods: true
|
|
4976
5339
|
}, {
|
|
4977
5340
|
osServer: true
|
|
4978
5341
|
});
|
|
4979
5342
|
case 3:
|
|
4980
|
-
response =
|
|
5343
|
+
response = _context51.sent;
|
|
4981
5344
|
paymentMethods = (response === null || response === void 0 ? void 0 : response.data) || [];
|
|
4982
5345
|
this.paymentMethodsCache = Array.isArray(paymentMethods) ? _toConsumableArray(paymentMethods) : [];
|
|
4983
|
-
return
|
|
5346
|
+
return _context51.abrupt("return", this.getPaymentMethods());
|
|
4984
5347
|
case 9:
|
|
4985
|
-
|
|
4986
|
-
|
|
5348
|
+
_context51.prev = 9;
|
|
5349
|
+
_context51.t0 = _context51["catch"](0);
|
|
4987
5350
|
this.logWarning('getPaymentMethodsAsync: 获取支付方式列表失败,使用缓存列表', {
|
|
4988
|
-
error:
|
|
5351
|
+
error: _context51.t0 instanceof Error ? _context51.t0.message : String(_context51.t0)
|
|
4989
5352
|
});
|
|
4990
|
-
return
|
|
5353
|
+
return _context51.abrupt("return", this.getPaymentMethods());
|
|
4991
5354
|
case 13:
|
|
4992
5355
|
case "end":
|
|
4993
|
-
return
|
|
5356
|
+
return _context51.stop();
|
|
4994
5357
|
}
|
|
4995
|
-
},
|
|
5358
|
+
}, _callee51, this, [[0, 9]]);
|
|
4996
5359
|
}));
|
|
4997
5360
|
function getPaymentMethodsAsync() {
|
|
4998
5361
|
return _getPaymentMethodsAsync.apply(this, arguments);
|
|
@@ -5017,8 +5380,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5017
5380
|
}, {
|
|
5018
5381
|
key: "getPendingWalletPaymentAmount",
|
|
5019
5382
|
value: function getPendingWalletPaymentAmount() {
|
|
5020
|
-
var _this$store$
|
|
5021
|
-
var payments = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ((_this$store$
|
|
5383
|
+
var _this$store$order17, _this$store$order17$g;
|
|
5384
|
+
var payments = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ((_this$store$order17 = this.store.order) === null || _this$store$order17 === void 0 || (_this$store$order17$g = _this$store$order17.getOrderPayments) === null || _this$store$order17$g === void 0 ? void 0 : _this$store$order17$g.call(_this$store$order17)) || [];
|
|
5022
5385
|
return payments.reduce(function (total, payment) {
|
|
5023
5386
|
if ((payment === null || payment === void 0 ? void 0 : payment.status) !== 'payment_pending' || (payment === null || payment === void 0 ? void 0 : payment.voucher_id) === undefined || Number(payment.voucher_id) === 0) {
|
|
5024
5387
|
return total;
|
|
@@ -5035,14 +5398,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5035
5398
|
}, {
|
|
5036
5399
|
key: "getCashPaymentConfig",
|
|
5037
5400
|
value: (function () {
|
|
5038
|
-
var _getCashPaymentConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5039
|
-
var _this$store$
|
|
5401
|
+
var _getCashPaymentConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52() {
|
|
5402
|
+
var _this$store$order18, _this$store$order18$g, _this$store$order19, _this$store$order19$g, _this$otherParams34;
|
|
5040
5403
|
var paymentMethods, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, currency, recommendedAmounts;
|
|
5041
|
-
return _regeneratorRuntime().wrap(function
|
|
5042
|
-
while (1) switch (
|
|
5404
|
+
return _regeneratorRuntime().wrap(function _callee52$(_context52) {
|
|
5405
|
+
while (1) switch (_context52.prev = _context52.next) {
|
|
5043
5406
|
case 0:
|
|
5044
5407
|
if (this.store.payment) {
|
|
5045
|
-
|
|
5408
|
+
_context52.next = 2;
|
|
5046
5409
|
break;
|
|
5047
5410
|
}
|
|
5048
5411
|
throw new Error('payment 模块未初始化');
|
|
@@ -5050,21 +5413,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5050
5413
|
paymentMethods = this.getPaymentMethods();
|
|
5051
5414
|
paymentMethod = this.findCashPaymentMethod(paymentMethods);
|
|
5052
5415
|
if (paymentMethod) {
|
|
5053
|
-
|
|
5416
|
+
_context52.next = 9;
|
|
5054
5417
|
break;
|
|
5055
5418
|
}
|
|
5056
|
-
|
|
5419
|
+
_context52.next = 7;
|
|
5057
5420
|
return this.getPaymentMethodsAsync();
|
|
5058
5421
|
case 7:
|
|
5059
|
-
paymentMethods =
|
|
5422
|
+
paymentMethods = _context52.sent;
|
|
5060
5423
|
paymentMethod = this.findCashPaymentMethod(paymentMethods);
|
|
5061
5424
|
case 9:
|
|
5062
|
-
amountSnapshot = (_this$store$
|
|
5425
|
+
amountSnapshot = (_this$store$order18 = this.store.order) === null || _this$store$order18 === void 0 || (_this$store$order18$g = _this$store$order18.getOrderAmountSnapshot) === null || _this$store$order18$g === void 0 ? void 0 : _this$store$order18$g.call(_this$store$order18);
|
|
5063
5426
|
pendingWalletAmount = this.getPendingWalletPaymentAmount();
|
|
5064
5427
|
amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0).toDecimalPlaces(2).toNumber();
|
|
5065
|
-
currency = ((_this$store$
|
|
5428
|
+
currency = ((_this$store$order19 = this.store.order) === null || _this$store$order19 === void 0 || (_this$store$order19$g = _this$store$order19.getTempOrder) === null || _this$store$order19$g === void 0 || (_this$store$order19$g = _this$store$order19$g.call(_this$store$order19)) === null || _this$store$order19$g === void 0 ? void 0 : _this$store$order19$g.currency_code) || ((_this$otherParams34 = this.otherParams) === null || _this$otherParams34 === void 0 ? void 0 : _this$otherParams34.currency) || 'USD';
|
|
5066
5429
|
recommendedAmounts = amountDue > 0 ? this.store.payment.cash.getRecommendedAmount(amountDue, currency) : [];
|
|
5067
|
-
return
|
|
5430
|
+
return _context52.abrupt("return", {
|
|
5068
5431
|
available: Boolean(paymentMethod && amountDue > 0),
|
|
5069
5432
|
paymentMethod: paymentMethod,
|
|
5070
5433
|
amountDue: amountDue,
|
|
@@ -5072,9 +5435,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5072
5435
|
});
|
|
5073
5436
|
case 15:
|
|
5074
5437
|
case "end":
|
|
5075
|
-
return
|
|
5438
|
+
return _context52.stop();
|
|
5076
5439
|
}
|
|
5077
|
-
},
|
|
5440
|
+
}, _callee52, this);
|
|
5078
5441
|
}));
|
|
5079
5442
|
function getCashPaymentConfig() {
|
|
5080
5443
|
return _getCashPaymentConfig.apply(this, arguments);
|
|
@@ -5091,42 +5454,42 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5091
5454
|
}, {
|
|
5092
5455
|
key: "confirmWalletPayment",
|
|
5093
5456
|
value: (function () {
|
|
5094
|
-
var _confirmWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5095
|
-
var _this$store$order$
|
|
5096
|
-
var beforePayments, pendingWalletAmount, amountSnapshot, _this$store$order$
|
|
5097
|
-
return _regeneratorRuntime().wrap(function
|
|
5098
|
-
while (1) switch (
|
|
5457
|
+
var _confirmWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53() {
|
|
5458
|
+
var _this$store$order$get8, _this$store$order20, _this$store$order$get10, _this$store$order$get11, _this$store$order22;
|
|
5459
|
+
var beforePayments, pendingWalletAmount, amountSnapshot, _this$store$order$get9, _this$store$order21, _submitResult, _latestAmountSnapshot, effectiveAmountDue, beforePaymentStatus, submitResult, restoredTempOrder, committed, walletState, latestAmountSnapshot;
|
|
5460
|
+
return _regeneratorRuntime().wrap(function _callee53$(_context53) {
|
|
5461
|
+
while (1) switch (_context53.prev = _context53.next) {
|
|
5099
5462
|
case 0:
|
|
5100
5463
|
if (this.store.order) {
|
|
5101
|
-
|
|
5464
|
+
_context53.next = 2;
|
|
5102
5465
|
break;
|
|
5103
5466
|
}
|
|
5104
5467
|
throw new Error('order 模块未初始化');
|
|
5105
5468
|
case 2:
|
|
5106
5469
|
beforePayments = cloneDeep(this.store.order.getOrderPayments());
|
|
5107
5470
|
pendingWalletAmount = this.getPendingWalletPaymentAmount(beforePayments);
|
|
5108
|
-
amountSnapshot = (_this$store$order$
|
|
5471
|
+
amountSnapshot = (_this$store$order$get8 = (_this$store$order20 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get8 === void 0 ? void 0 : _this$store$order$get8.call(_this$store$order20);
|
|
5109
5472
|
if (!pendingWalletAmount.lte(0)) {
|
|
5110
|
-
|
|
5473
|
+
_context53.next = 14;
|
|
5111
5474
|
break;
|
|
5112
5475
|
}
|
|
5113
5476
|
this.logWarning('confirmWalletPayment: 未发现待确认 Wallet 支付,跳过 Wallet 确认并按普通订单提交', {
|
|
5114
5477
|
amountGap: amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap
|
|
5115
5478
|
});
|
|
5116
|
-
|
|
5479
|
+
_context53.next = 9;
|
|
5117
5480
|
return this.submitSalesOrder({
|
|
5118
5481
|
smallTicketDataFlag: 1
|
|
5119
5482
|
});
|
|
5120
5483
|
case 9:
|
|
5121
|
-
_submitResult =
|
|
5484
|
+
_submitResult = _context53.sent;
|
|
5122
5485
|
if (!isRejectedSalesSubmitResult(_submitResult)) {
|
|
5123
|
-
|
|
5486
|
+
_context53.next = 12;
|
|
5124
5487
|
break;
|
|
5125
5488
|
}
|
|
5126
5489
|
throw new Error(getSalesSubmitErrorMessage(_submitResult, '订单提交失败'));
|
|
5127
5490
|
case 12:
|
|
5128
|
-
_latestAmountSnapshot = (_this$store$order$
|
|
5129
|
-
return
|
|
5491
|
+
_latestAmountSnapshot = (_this$store$order$get9 = (_this$store$order21 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get9 === void 0 ? void 0 : _this$store$order$get9.call(_this$store$order21);
|
|
5492
|
+
return _context53.abrupt("return", {
|
|
5130
5493
|
submitResult: _submitResult,
|
|
5131
5494
|
payments: this.store.order.getOrderPayments(),
|
|
5132
5495
|
isOrderFullyPaid: new Decimal((_latestAmountSnapshot === null || _latestAmountSnapshot === void 0 ? void 0 : _latestAmountSnapshot.amountGap) || 0).lte(0)
|
|
@@ -5134,74 +5497,74 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5134
5497
|
case 14:
|
|
5135
5498
|
effectiveAmountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
|
|
5136
5499
|
if (!effectiveAmountDue.gt(0.01)) {
|
|
5137
|
-
|
|
5500
|
+
_context53.next = 17;
|
|
5138
5501
|
break;
|
|
5139
5502
|
}
|
|
5140
5503
|
throw new Error('Wallet 支付尚未覆盖全部待支付金额');
|
|
5141
5504
|
case 17:
|
|
5142
|
-
beforePaymentStatus = (_this$store$order$
|
|
5143
|
-
|
|
5144
|
-
|
|
5505
|
+
beforePaymentStatus = (_this$store$order$get10 = this.store.order.getTempOrder()) === null || _this$store$order$get10 === void 0 ? void 0 : _this$store$order$get10.payment_status;
|
|
5506
|
+
_context53.prev = 18;
|
|
5507
|
+
_context53.next = 21;
|
|
5145
5508
|
return this.submitSalesOrder({
|
|
5146
5509
|
smallTicketDataFlag: 1,
|
|
5147
5510
|
confirmPendingVoucherPayments: true
|
|
5148
5511
|
});
|
|
5149
5512
|
case 21:
|
|
5150
|
-
submitResult =
|
|
5513
|
+
submitResult = _context53.sent;
|
|
5151
5514
|
if (!isRejectedSalesSubmitResult(submitResult)) {
|
|
5152
|
-
|
|
5515
|
+
_context53.next = 24;
|
|
5153
5516
|
break;
|
|
5154
5517
|
}
|
|
5155
5518
|
throw new Error(getSalesSubmitErrorMessage(submitResult, 'Wallet 支付确认失败'));
|
|
5156
5519
|
case 24:
|
|
5157
|
-
|
|
5520
|
+
_context53.next = 34;
|
|
5158
5521
|
break;
|
|
5159
5522
|
case 26:
|
|
5160
|
-
|
|
5161
|
-
|
|
5523
|
+
_context53.prev = 26;
|
|
5524
|
+
_context53.t0 = _context53["catch"](18);
|
|
5162
5525
|
this.store.order.setOrderPayments(beforePayments);
|
|
5163
5526
|
restoredTempOrder = this.store.order.getTempOrder();
|
|
5164
5527
|
if (restoredTempOrder && beforePaymentStatus !== undefined) {
|
|
5165
5528
|
restoredTempOrder.payment_status = beforePaymentStatus;
|
|
5166
5529
|
this.store.order.persistTempOrder();
|
|
5167
5530
|
}
|
|
5168
|
-
|
|
5531
|
+
_context53.next = 33;
|
|
5169
5532
|
return this.store.order.recalculateSummary({
|
|
5170
5533
|
createIfMissing: true
|
|
5171
5534
|
});
|
|
5172
5535
|
case 33:
|
|
5173
|
-
throw
|
|
5536
|
+
throw _context53.t0;
|
|
5174
5537
|
case 34:
|
|
5175
5538
|
if (!this.store.payment) {
|
|
5176
|
-
|
|
5539
|
+
_context53.next = 45;
|
|
5177
5540
|
break;
|
|
5178
5541
|
}
|
|
5179
|
-
|
|
5542
|
+
_context53.prev = 35;
|
|
5180
5543
|
committed = this.getCommittedWalletAssets();
|
|
5181
5544
|
walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
5182
|
-
|
|
5183
|
-
return this.publishWalletAssetsState(walletState);
|
|
5545
|
+
_context53.next = 40;
|
|
5546
|
+
return this.publishWalletAssetsState(walletState, 'local');
|
|
5184
5547
|
case 40:
|
|
5185
|
-
|
|
5548
|
+
_context53.next = 45;
|
|
5186
5549
|
break;
|
|
5187
5550
|
case 42:
|
|
5188
|
-
|
|
5189
|
-
|
|
5551
|
+
_context53.prev = 42;
|
|
5552
|
+
_context53.t1 = _context53["catch"](35);
|
|
5190
5553
|
this.logWarning('confirmWalletPayment: Wallet committed 状态同步失败', {
|
|
5191
|
-
error:
|
|
5554
|
+
error: _context53.t1 instanceof Error ? _context53.t1.message : String(_context53.t1)
|
|
5192
5555
|
});
|
|
5193
5556
|
case 45:
|
|
5194
|
-
latestAmountSnapshot = (_this$store$order$
|
|
5195
|
-
return
|
|
5557
|
+
latestAmountSnapshot = (_this$store$order$get11 = (_this$store$order22 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get11 === void 0 ? void 0 : _this$store$order$get11.call(_this$store$order22);
|
|
5558
|
+
return _context53.abrupt("return", {
|
|
5196
5559
|
submitResult: submitResult,
|
|
5197
5560
|
payments: this.store.order.getOrderPayments(),
|
|
5198
5561
|
isOrderFullyPaid: new Decimal((latestAmountSnapshot === null || latestAmountSnapshot === void 0 ? void 0 : latestAmountSnapshot.amountGap) || 0).lte(0)
|
|
5199
5562
|
});
|
|
5200
5563
|
case 47:
|
|
5201
5564
|
case "end":
|
|
5202
|
-
return
|
|
5565
|
+
return _context53.stop();
|
|
5203
5566
|
}
|
|
5204
|
-
},
|
|
5567
|
+
}, _callee53, this, [[18, 26], [35, 42]]);
|
|
5205
5568
|
}));
|
|
5206
5569
|
function confirmWalletPayment() {
|
|
5207
5570
|
return _confirmWalletPayment.apply(this, arguments);
|
|
@@ -5216,38 +5579,38 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5216
5579
|
}, {
|
|
5217
5580
|
key: "payCash",
|
|
5218
5581
|
value: (function () {
|
|
5219
|
-
var _payCash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5220
|
-
var _this$store$order$
|
|
5582
|
+
var _payCash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(params) {
|
|
5583
|
+
var _this$store$order$get12, _params$actualPaidAmo, _this$otherParams35, _this$window, _this$window$postMess;
|
|
5221
5584
|
var amount, config, paymentMethod, roundingAmount, effectivePaymentAmount, beforePayments, beforePaymentStatus, uniquePaymentNumber, paymentTimestamp, actualPaidAmount, changeAmount, shopWalletPassId, payments, payment, syncResult, committed, walletState, restoredTempOrder;
|
|
5222
|
-
return _regeneratorRuntime().wrap(function
|
|
5223
|
-
while (1) switch (
|
|
5585
|
+
return _regeneratorRuntime().wrap(function _callee54$(_context54) {
|
|
5586
|
+
while (1) switch (_context54.prev = _context54.next) {
|
|
5224
5587
|
case 0:
|
|
5225
5588
|
if (this.store.order) {
|
|
5226
|
-
|
|
5589
|
+
_context54.next = 2;
|
|
5227
5590
|
break;
|
|
5228
5591
|
}
|
|
5229
5592
|
throw new Error('order 模块未初始化');
|
|
5230
5593
|
case 2:
|
|
5231
5594
|
amount = Number(params.amount || 0);
|
|
5232
5595
|
if (!(!Number.isFinite(amount) || amount <= 0)) {
|
|
5233
|
-
|
|
5596
|
+
_context54.next = 5;
|
|
5234
5597
|
break;
|
|
5235
5598
|
}
|
|
5236
5599
|
throw new Error('现金支付金额必须大于 0');
|
|
5237
5600
|
case 5:
|
|
5238
|
-
|
|
5601
|
+
_context54.next = 7;
|
|
5239
5602
|
return this.getCashPaymentConfig();
|
|
5240
5603
|
case 7:
|
|
5241
|
-
config =
|
|
5604
|
+
config = _context54.sent;
|
|
5242
5605
|
paymentMethod = config.paymentMethod;
|
|
5243
5606
|
if (paymentMethod) {
|
|
5244
|
-
|
|
5607
|
+
_context54.next = 11;
|
|
5245
5608
|
break;
|
|
5246
5609
|
}
|
|
5247
5610
|
throw new Error('未找到可用的 CASHMANUAL 支付方式');
|
|
5248
5611
|
case 11:
|
|
5249
5612
|
if (!(config.amountDue <= 0)) {
|
|
5250
|
-
|
|
5613
|
+
_context54.next = 13;
|
|
5251
5614
|
break;
|
|
5252
5615
|
}
|
|
5253
5616
|
throw new Error('当前订单没有待支付金额');
|
|
@@ -5255,20 +5618,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5255
5618
|
roundingAmount = Number(params.roundingAmount || 0);
|
|
5256
5619
|
effectivePaymentAmount = new Decimal(amount).minus(roundingAmount);
|
|
5257
5620
|
if (!effectivePaymentAmount.gt(new Decimal(config.amountDue).plus(0.01))) {
|
|
5258
|
-
|
|
5621
|
+
_context54.next = 17;
|
|
5259
5622
|
break;
|
|
5260
5623
|
}
|
|
5261
5624
|
throw new Error('现金支付金额超过当前待支付金额');
|
|
5262
5625
|
case 17:
|
|
5263
5626
|
beforePayments = cloneDeep(this.store.order.getOrderPayments());
|
|
5264
|
-
beforePaymentStatus = (_this$store$order$
|
|
5627
|
+
beforePaymentStatus = (_this$store$order$get12 = this.store.order.getTempOrder()) === null || _this$store$order$get12 === void 0 ? void 0 : _this$store$order$get12.payment_status;
|
|
5265
5628
|
uniquePaymentNumber = createUuidV4();
|
|
5266
5629
|
paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
5267
5630
|
actualPaidAmount = Number((_params$actualPaidAmo = params.actualPaidAmount) !== null && _params$actualPaidAmo !== void 0 ? _params$actualPaidAmo : amount);
|
|
5268
5631
|
changeAmount = Number(params.changeAmount || 0);
|
|
5269
5632
|
shopWalletPassId = (_this$otherParams35 = this.otherParams) === null || _this$otherParams35 === void 0 ? void 0 : _this$otherParams35.shop_wallet_pass_id;
|
|
5270
5633
|
if (!(!Number.isFinite(actualPaidAmount) || actualPaidAmount + 0.01 < amount)) {
|
|
5271
|
-
|
|
5634
|
+
_context54.next = 26;
|
|
5272
5635
|
break;
|
|
5273
5636
|
}
|
|
5274
5637
|
throw new Error('顾客实收现金不能小于支付金额');
|
|
@@ -5303,8 +5666,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5303
5666
|
var _item$metadata2;
|
|
5304
5667
|
return (item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.unique_payment_number) === uniquePaymentNumber;
|
|
5305
5668
|
});
|
|
5306
|
-
|
|
5307
|
-
|
|
5669
|
+
_context54.prev = 29;
|
|
5670
|
+
_context54.next = 32;
|
|
5308
5671
|
return this.syncPaymentsToOrder({
|
|
5309
5672
|
payments: payments,
|
|
5310
5673
|
submitWhenPaid: true,
|
|
@@ -5312,50 +5675,50 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5312
5675
|
confirmPendingVoucherPayments: true
|
|
5313
5676
|
});
|
|
5314
5677
|
case 32:
|
|
5315
|
-
syncResult =
|
|
5678
|
+
syncResult = _context54.sent;
|
|
5316
5679
|
if (!isRejectedSalesSubmitResult(syncResult.submitResult)) {
|
|
5317
|
-
|
|
5680
|
+
_context54.next = 35;
|
|
5318
5681
|
break;
|
|
5319
5682
|
}
|
|
5320
5683
|
throw new Error(getSalesSubmitErrorMessage(syncResult.submitResult, '订单提交失败'));
|
|
5321
5684
|
case 35:
|
|
5322
5685
|
if (!this.store.payment) {
|
|
5323
|
-
|
|
5686
|
+
_context54.next = 40;
|
|
5324
5687
|
break;
|
|
5325
5688
|
}
|
|
5326
5689
|
committed = this.getCommittedWalletAssets();
|
|
5327
5690
|
walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
5328
|
-
|
|
5329
|
-
return this.publishWalletAssetsState(walletState);
|
|
5691
|
+
_context54.next = 40;
|
|
5692
|
+
return this.publishWalletAssetsState(walletState, 'local');
|
|
5330
5693
|
case 40:
|
|
5331
|
-
return
|
|
5694
|
+
return _context54.abrupt("return", {
|
|
5332
5695
|
payment: payment || {},
|
|
5333
5696
|
payments: this.store.order.getOrderPayments(),
|
|
5334
5697
|
syncResult: syncResult,
|
|
5335
5698
|
isOrderFullyPaid: syncResult.isOrderFullyPaid
|
|
5336
5699
|
});
|
|
5337
5700
|
case 43:
|
|
5338
|
-
|
|
5339
|
-
|
|
5701
|
+
_context54.prev = 43;
|
|
5702
|
+
_context54.t0 = _context54["catch"](29);
|
|
5340
5703
|
this.store.order.setOrderPayments(beforePayments);
|
|
5341
5704
|
restoredTempOrder = this.store.order.getTempOrder();
|
|
5342
5705
|
if (restoredTempOrder && beforePaymentStatus !== undefined) {
|
|
5343
5706
|
restoredTempOrder.payment_status = beforePaymentStatus;
|
|
5344
5707
|
this.store.order.persistTempOrder();
|
|
5345
5708
|
}
|
|
5346
|
-
|
|
5709
|
+
_context54.next = 50;
|
|
5347
5710
|
return this.store.order.recalculateSummary({
|
|
5348
5711
|
createIfMissing: true
|
|
5349
5712
|
});
|
|
5350
5713
|
case 50:
|
|
5351
|
-
throw
|
|
5714
|
+
throw _context54.t0;
|
|
5352
5715
|
case 51:
|
|
5353
5716
|
case "end":
|
|
5354
|
-
return
|
|
5717
|
+
return _context54.stop();
|
|
5355
5718
|
}
|
|
5356
|
-
},
|
|
5719
|
+
}, _callee54, this, [[29, 43]]);
|
|
5357
5720
|
}));
|
|
5358
|
-
function payCash(
|
|
5721
|
+
function payCash(_x43) {
|
|
5359
5722
|
return _payCash.apply(this, arguments);
|
|
5360
5723
|
}
|
|
5361
5724
|
return payCash;
|
|
@@ -5371,21 +5734,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5371
5734
|
}, {
|
|
5372
5735
|
key: "commitPaymentMethodPayment",
|
|
5373
5736
|
value: (function () {
|
|
5374
|
-
var _commitPaymentMethodPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5375
|
-
var _this$store$order$
|
|
5737
|
+
var _commitPaymentMethodPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(params) {
|
|
5738
|
+
var _this$store$order$get13, _this$store$order23, _this$store$order$get14, _params$metadata, _params$originAmount;
|
|
5376
5739
|
var amount, paymentMethods, findPaymentMethod, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, beforePayments, beforePaymentStatus, paymentTimestamp, metadata, serviceCharge, serviceFee, payments, payment, syncResult, committed, walletState, restoredTempOrder;
|
|
5377
|
-
return _regeneratorRuntime().wrap(function
|
|
5378
|
-
while (1) switch (
|
|
5740
|
+
return _regeneratorRuntime().wrap(function _callee55$(_context55) {
|
|
5741
|
+
while (1) switch (_context55.prev = _context55.next) {
|
|
5379
5742
|
case 0:
|
|
5380
5743
|
if (this.store.order) {
|
|
5381
|
-
|
|
5744
|
+
_context55.next = 2;
|
|
5382
5745
|
break;
|
|
5383
5746
|
}
|
|
5384
5747
|
throw new Error('order 模块未初始化');
|
|
5385
5748
|
case 2:
|
|
5386
5749
|
amount = Number(params.amount || 0);
|
|
5387
5750
|
if (!(!Number.isFinite(amount) || amount <= 0)) {
|
|
5388
|
-
|
|
5751
|
+
_context55.next = 5;
|
|
5389
5752
|
break;
|
|
5390
5753
|
}
|
|
5391
5754
|
throw new Error('支付金额必须大于 0');
|
|
@@ -5401,38 +5764,38 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5401
5764
|
};
|
|
5402
5765
|
paymentMethod = findPaymentMethod();
|
|
5403
5766
|
if (paymentMethod) {
|
|
5404
|
-
|
|
5767
|
+
_context55.next = 13;
|
|
5405
5768
|
break;
|
|
5406
5769
|
}
|
|
5407
|
-
|
|
5770
|
+
_context55.next = 11;
|
|
5408
5771
|
return this.getPaymentMethodsAsync();
|
|
5409
5772
|
case 11:
|
|
5410
|
-
paymentMethods =
|
|
5773
|
+
paymentMethods = _context55.sent;
|
|
5411
5774
|
paymentMethod = findPaymentMethod();
|
|
5412
5775
|
case 13:
|
|
5413
5776
|
if (paymentMethod) {
|
|
5414
|
-
|
|
5777
|
+
_context55.next = 15;
|
|
5415
5778
|
break;
|
|
5416
5779
|
}
|
|
5417
5780
|
throw new Error("\u672A\u627E\u5230\u53EF\u7528\u7684\u652F\u4ED8\u65B9\u5F0F\uFF1A".concat(params.paymentMethodCode || params.paymentMethodId || ''));
|
|
5418
5781
|
case 15:
|
|
5419
|
-
amountSnapshot = (_this$store$order$
|
|
5782
|
+
amountSnapshot = (_this$store$order$get13 = (_this$store$order23 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get13 === void 0 ? void 0 : _this$store$order$get13.call(_this$store$order23);
|
|
5420
5783
|
pendingWalletAmount = this.getPendingWalletPaymentAmount();
|
|
5421
5784
|
amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
|
|
5422
5785
|
if (!amountDue.lte(0)) {
|
|
5423
|
-
|
|
5786
|
+
_context55.next = 20;
|
|
5424
5787
|
break;
|
|
5425
5788
|
}
|
|
5426
5789
|
throw new Error('当前订单没有待支付金额');
|
|
5427
5790
|
case 20:
|
|
5428
5791
|
if (!new Decimal(amount).gt(amountDue.plus(0.01))) {
|
|
5429
|
-
|
|
5792
|
+
_context55.next = 22;
|
|
5430
5793
|
break;
|
|
5431
5794
|
}
|
|
5432
5795
|
throw new Error('支付金额超过当前待支付金额');
|
|
5433
5796
|
case 22:
|
|
5434
5797
|
beforePayments = cloneDeep(this.store.order.getOrderPayments());
|
|
5435
|
-
beforePaymentStatus = (_this$store$order$
|
|
5798
|
+
beforePaymentStatus = (_this$store$order$get14 = this.store.order.getTempOrder()) === null || _this$store$order$get14 === void 0 ? void 0 : _this$store$order$get14.payment_status;
|
|
5436
5799
|
paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
5437
5800
|
metadata = _objectSpread(_objectSpread({}, params.metadata || {}), {}, {
|
|
5438
5801
|
unique_payment_number: ((_params$metadata = params.metadata) === null || _params$metadata === void 0 ? void 0 : _params$metadata.unique_payment_number) || createUuidV4()
|
|
@@ -5465,8 +5828,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5465
5828
|
var _item$metadata3;
|
|
5466
5829
|
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;
|
|
5467
5830
|
});
|
|
5468
|
-
|
|
5469
|
-
|
|
5831
|
+
_context55.prev = 30;
|
|
5832
|
+
_context55.next = 33;
|
|
5470
5833
|
return this.syncPaymentsToOrder({
|
|
5471
5834
|
payments: payments,
|
|
5472
5835
|
submitWhenPaid: true,
|
|
@@ -5474,50 +5837,50 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5474
5837
|
confirmPendingVoucherPayments: true
|
|
5475
5838
|
});
|
|
5476
5839
|
case 33:
|
|
5477
|
-
syncResult =
|
|
5840
|
+
syncResult = _context55.sent;
|
|
5478
5841
|
if (!isRejectedSalesSubmitResult(syncResult.submitResult)) {
|
|
5479
|
-
|
|
5842
|
+
_context55.next = 36;
|
|
5480
5843
|
break;
|
|
5481
5844
|
}
|
|
5482
5845
|
throw new Error(getSalesSubmitErrorMessage(syncResult.submitResult, '订单提交失败'));
|
|
5483
5846
|
case 36:
|
|
5484
5847
|
if (!this.store.payment) {
|
|
5485
|
-
|
|
5848
|
+
_context55.next = 41;
|
|
5486
5849
|
break;
|
|
5487
5850
|
}
|
|
5488
5851
|
committed = this.getCommittedWalletAssets();
|
|
5489
5852
|
walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
5490
|
-
|
|
5491
|
-
return this.publishWalletAssetsState(walletState);
|
|
5853
|
+
_context55.next = 41;
|
|
5854
|
+
return this.publishWalletAssetsState(walletState, 'local');
|
|
5492
5855
|
case 41:
|
|
5493
|
-
return
|
|
5856
|
+
return _context55.abrupt("return", {
|
|
5494
5857
|
payment: payment || {},
|
|
5495
5858
|
payments: this.store.order.getOrderPayments(),
|
|
5496
5859
|
syncResult: syncResult,
|
|
5497
5860
|
isOrderFullyPaid: syncResult.isOrderFullyPaid
|
|
5498
5861
|
});
|
|
5499
5862
|
case 44:
|
|
5500
|
-
|
|
5501
|
-
|
|
5863
|
+
_context55.prev = 44;
|
|
5864
|
+
_context55.t0 = _context55["catch"](30);
|
|
5502
5865
|
this.store.order.setOrderPayments(beforePayments);
|
|
5503
5866
|
restoredTempOrder = this.store.order.getTempOrder();
|
|
5504
5867
|
if (restoredTempOrder && beforePaymentStatus !== undefined) {
|
|
5505
5868
|
restoredTempOrder.payment_status = beforePaymentStatus;
|
|
5506
5869
|
this.store.order.persistTempOrder();
|
|
5507
5870
|
}
|
|
5508
|
-
|
|
5871
|
+
_context55.next = 51;
|
|
5509
5872
|
return this.store.order.recalculateSummary({
|
|
5510
5873
|
createIfMissing: true
|
|
5511
5874
|
});
|
|
5512
5875
|
case 51:
|
|
5513
|
-
throw
|
|
5876
|
+
throw _context55.t0;
|
|
5514
5877
|
case 52:
|
|
5515
5878
|
case "end":
|
|
5516
|
-
return
|
|
5879
|
+
return _context55.stop();
|
|
5517
5880
|
}
|
|
5518
|
-
},
|
|
5881
|
+
}, _callee55, this, [[30, 44]]);
|
|
5519
5882
|
}));
|
|
5520
|
-
function commitPaymentMethodPayment(
|
|
5883
|
+
function commitPaymentMethodPayment(_x44) {
|
|
5521
5884
|
return _commitPaymentMethodPayment.apply(this, arguments);
|
|
5522
5885
|
}
|
|
5523
5886
|
return commitPaymentMethodPayment;
|
|
@@ -5532,40 +5895,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5532
5895
|
}, {
|
|
5533
5896
|
key: "roundAmount",
|
|
5534
5897
|
value: (function () {
|
|
5535
|
-
var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5898
|
+
var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(params) {
|
|
5536
5899
|
var _cashManualPayment$me, _this$otherParams$ord2, _this$otherParams$ord3;
|
|
5537
5900
|
var amount, cashManualPayment;
|
|
5538
|
-
return _regeneratorRuntime().wrap(function
|
|
5539
|
-
while (1) switch (
|
|
5901
|
+
return _regeneratorRuntime().wrap(function _callee56$(_context56) {
|
|
5902
|
+
while (1) switch (_context56.prev = _context56.next) {
|
|
5540
5903
|
case 0:
|
|
5541
5904
|
amount = params.amount;
|
|
5542
5905
|
cashManualPayment = this.paymentMethodsCache.find(function (paymentMethod) {
|
|
5543
5906
|
return paymentMethod.code === 'CASHMANUAL';
|
|
5544
5907
|
});
|
|
5545
5908
|
if (cashManualPayment !== null && cashManualPayment !== void 0 && (_cashManualPayment$me = cashManualPayment.metadata) !== null && _cashManualPayment$me !== void 0 && _cashManualPayment$me.order_rounding_switch) {
|
|
5546
|
-
|
|
5909
|
+
_context56.next = 4;
|
|
5547
5910
|
break;
|
|
5548
5911
|
}
|
|
5549
|
-
return
|
|
5912
|
+
return _context56.abrupt("return", {
|
|
5550
5913
|
originalAmount: amount.toString(),
|
|
5551
5914
|
roundedAmount: amount.toString(),
|
|
5552
5915
|
roundingDifference: '0.00'
|
|
5553
5916
|
});
|
|
5554
5917
|
case 4:
|
|
5555
5918
|
if (this.payment) {
|
|
5556
|
-
|
|
5919
|
+
_context56.next = 6;
|
|
5557
5920
|
break;
|
|
5558
5921
|
}
|
|
5559
5922
|
throw new Error('payment 模块未初始化');
|
|
5560
5923
|
case 6:
|
|
5561
|
-
return
|
|
5924
|
+
return _context56.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));
|
|
5562
5925
|
case 7:
|
|
5563
5926
|
case "end":
|
|
5564
|
-
return
|
|
5927
|
+
return _context56.stop();
|
|
5565
5928
|
}
|
|
5566
|
-
},
|
|
5929
|
+
}, _callee56, this);
|
|
5567
5930
|
}));
|
|
5568
|
-
function roundAmount(
|
|
5931
|
+
function roundAmount(_x45) {
|
|
5569
5932
|
return _roundAmount.apply(this, arguments);
|
|
5570
5933
|
}
|
|
5571
5934
|
return roundAmount;
|
|
@@ -5580,49 +5943,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5580
5943
|
}, {
|
|
5581
5944
|
key: "sendCustomerPayLink",
|
|
5582
5945
|
value: (function () {
|
|
5583
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5584
|
-
var orderIds,
|
|
5585
|
-
return _regeneratorRuntime().wrap(function
|
|
5586
|
-
while (1) switch (
|
|
5946
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
|
|
5947
|
+
var orderIds, _ref52, _ref53, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
|
|
5948
|
+
return _regeneratorRuntime().wrap(function _callee57$(_context57) {
|
|
5949
|
+
while (1) switch (_context57.prev = _context57.next) {
|
|
5587
5950
|
case 0:
|
|
5588
5951
|
if (this.store.order) {
|
|
5589
|
-
|
|
5952
|
+
_context57.next = 2;
|
|
5590
5953
|
break;
|
|
5591
5954
|
}
|
|
5592
5955
|
throw new Error('order 模块未初始化');
|
|
5593
5956
|
case 2:
|
|
5594
5957
|
orderIds = params.order_ids || params.orderIds || [];
|
|
5595
5958
|
if (!(!orderIds.length || params.submitBeforeSend)) {
|
|
5596
|
-
|
|
5959
|
+
_context57.next = 11;
|
|
5597
5960
|
break;
|
|
5598
5961
|
}
|
|
5599
|
-
|
|
5962
|
+
_context57.next = 6;
|
|
5600
5963
|
return this.submitSalesOrder({
|
|
5601
5964
|
smallTicketDataFlag: 1
|
|
5602
5965
|
});
|
|
5603
5966
|
case 6:
|
|
5604
|
-
submitResult =
|
|
5605
|
-
orderId = (
|
|
5967
|
+
submitResult = _context57.sent;
|
|
5968
|
+
orderId = (_ref52 = (_ref53 = (_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 && _ref53 !== void 0 ? _ref53 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref52 !== void 0 ? _ref52 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
|
|
5606
5969
|
if (orderId) {
|
|
5607
|
-
|
|
5970
|
+
_context57.next = 10;
|
|
5608
5971
|
break;
|
|
5609
5972
|
}
|
|
5610
5973
|
throw new Error('本地订单提交云端失败,无法发送支付链接');
|
|
5611
5974
|
case 10:
|
|
5612
5975
|
orderIds = [orderId];
|
|
5613
5976
|
case 11:
|
|
5614
|
-
return
|
|
5977
|
+
return _context57.abrupt("return", this.store.order.sendCustomerPayLink({
|
|
5615
5978
|
emails: params.emails,
|
|
5616
5979
|
notify_action: params.notify_action,
|
|
5617
5980
|
order_ids: orderIds
|
|
5618
5981
|
}));
|
|
5619
5982
|
case 12:
|
|
5620
5983
|
case "end":
|
|
5621
|
-
return
|
|
5984
|
+
return _context57.stop();
|
|
5622
5985
|
}
|
|
5623
|
-
},
|
|
5986
|
+
}, _callee57, this);
|
|
5624
5987
|
}));
|
|
5625
|
-
function sendCustomerPayLink(
|
|
5988
|
+
function sendCustomerPayLink(_x46) {
|
|
5626
5989
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
5627
5990
|
}
|
|
5628
5991
|
return sendCustomerPayLink;
|
|
@@ -5635,20 +5998,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5635
5998
|
}, {
|
|
5636
5999
|
key: "calculateProductBookingPrice",
|
|
5637
6000
|
value: function () {
|
|
5638
|
-
var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6001
|
+
var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(params) {
|
|
5639
6002
|
var _params$customer_id;
|
|
5640
6003
|
var useCustomerUserPricing, quotation, customerId, channel, _yield$this$resolvePr, _yield$this$resolvePr2, authoritativeProduct, product;
|
|
5641
|
-
return _regeneratorRuntime().wrap(function
|
|
5642
|
-
while (1) switch (
|
|
6004
|
+
return _regeneratorRuntime().wrap(function _callee58$(_context58) {
|
|
6005
|
+
while (1) switch (_context58.prev = _context58.next) {
|
|
5643
6006
|
case 0:
|
|
5644
6007
|
useCustomerUserPricing = this.isCustomerUserPriceQuery();
|
|
5645
6008
|
quotation = useCustomerUserPricing ? undefined : this.store.quotation;
|
|
5646
6009
|
customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : this.getCurrentOrderCustomerId();
|
|
5647
|
-
|
|
6010
|
+
_context58.next = 5;
|
|
5648
6011
|
return this.prepareProductPriceQueryContext(customerId);
|
|
5649
6012
|
case 5:
|
|
5650
6013
|
channel = this.getPriceQueryChannel(params.channel);
|
|
5651
|
-
|
|
6014
|
+
_context58.next = 8;
|
|
5652
6015
|
return this.resolveProductsForPriceQuery({
|
|
5653
6016
|
priceQueries: [params],
|
|
5654
6017
|
schedule: this.getPriceQuerySchedule(params),
|
|
@@ -5656,22 +6019,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5656
6019
|
channel: channel
|
|
5657
6020
|
});
|
|
5658
6021
|
case 8:
|
|
5659
|
-
_yield$this$resolvePr =
|
|
6022
|
+
_yield$this$resolvePr = _context58.sent;
|
|
5660
6023
|
_yield$this$resolvePr2 = _slicedToArray(_yield$this$resolvePr, 1);
|
|
5661
6024
|
authoritativeProduct = _yield$this$resolvePr2[0];
|
|
5662
6025
|
product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
|
|
5663
6026
|
if (useCustomerUserPricing) {
|
|
5664
|
-
|
|
6027
|
+
_context58.next = 15;
|
|
5665
6028
|
break;
|
|
5666
6029
|
}
|
|
5667
|
-
|
|
6030
|
+
_context58.next = 15;
|
|
5668
6031
|
return this.loadQuotationForPriceQuery({
|
|
5669
6032
|
quotation: quotation,
|
|
5670
6033
|
customer_id: customerId,
|
|
5671
6034
|
channel: channel
|
|
5672
6035
|
});
|
|
5673
6036
|
case 15:
|
|
5674
|
-
return
|
|
6037
|
+
return _context58.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
|
|
5675
6038
|
channel: channel,
|
|
5676
6039
|
product: product,
|
|
5677
6040
|
fallback_price: authoritativeProduct ? undefined : params.fallback_price,
|
|
@@ -5680,11 +6043,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5680
6043
|
})));
|
|
5681
6044
|
case 16:
|
|
5682
6045
|
case "end":
|
|
5683
|
-
return
|
|
6046
|
+
return _context58.stop();
|
|
5684
6047
|
}
|
|
5685
|
-
},
|
|
6048
|
+
}, _callee58, this);
|
|
5686
6049
|
}));
|
|
5687
|
-
function calculateProductBookingPrice(
|
|
6050
|
+
function calculateProductBookingPrice(_x47) {
|
|
5688
6051
|
return _calculateProductBookingPrice.apply(this, arguments);
|
|
5689
6052
|
}
|
|
5690
6053
|
return calculateProductBookingPrice;
|
|
@@ -5692,7 +6055,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5692
6055
|
}, {
|
|
5693
6056
|
key: "getQuotationCustomerScopeInfo",
|
|
5694
6057
|
value: function getQuotationCustomerScopeInfo() {
|
|
5695
|
-
var
|
|
6058
|
+
var _this18 = this;
|
|
5696
6059
|
var quotation = this.store.quotation;
|
|
5697
6060
|
if (quotation && typeof quotation.getQuotationCustomerScopeInfo === 'function') {
|
|
5698
6061
|
return quotation.getQuotationCustomerScopeInfo();
|
|
@@ -5704,7 +6067,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5704
6067
|
}).map(function (item) {
|
|
5705
6068
|
var localSeen = new Set();
|
|
5706
6069
|
var customers = item.customer.filter(function (customer) {
|
|
5707
|
-
var customerId =
|
|
6070
|
+
var customerId = _this18.normalizePriceContextCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
|
|
5708
6071
|
if (!customerId || localSeen.has(customerId)) return false;
|
|
5709
6072
|
localSeen.add(customerId);
|
|
5710
6073
|
if (!customerById.has(customerId)) customerById.set(customerId, customer);
|
|
@@ -5768,23 +6131,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5768
6131
|
}, {
|
|
5769
6132
|
key: "calculateProductBookingPrices",
|
|
5770
6133
|
value: function () {
|
|
5771
|
-
var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5772
|
-
var
|
|
6134
|
+
var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(paramsList) {
|
|
6135
|
+
var _this19 = this;
|
|
5773
6136
|
var useCustomerUserPricing, quotation, currentOrderCustomerId, resolvedChannels, authoritativeProducts, groups, quotationContexts;
|
|
5774
|
-
return _regeneratorRuntime().wrap(function
|
|
5775
|
-
while (1) switch (
|
|
6137
|
+
return _regeneratorRuntime().wrap(function _callee60$(_context60) {
|
|
6138
|
+
while (1) switch (_context60.prev = _context60.next) {
|
|
5776
6139
|
case 0:
|
|
5777
6140
|
if (paramsList.length) {
|
|
5778
|
-
|
|
6141
|
+
_context60.next = 2;
|
|
5779
6142
|
break;
|
|
5780
6143
|
}
|
|
5781
|
-
return
|
|
6144
|
+
return _context60.abrupt("return", []);
|
|
5782
6145
|
case 2:
|
|
5783
6146
|
useCustomerUserPricing = this.isCustomerUserPriceQuery();
|
|
5784
6147
|
quotation = useCustomerUserPricing ? undefined : this.store.quotation;
|
|
5785
6148
|
currentOrderCustomerId = this.getCurrentOrderCustomerId();
|
|
5786
6149
|
resolvedChannels = paramsList.map(function (params) {
|
|
5787
|
-
return
|
|
6150
|
+
return _this19.getPriceQueryChannel(params.channel);
|
|
5788
6151
|
});
|
|
5789
6152
|
authoritativeProducts = paramsList.map(function () {
|
|
5790
6153
|
return null;
|
|
@@ -5792,10 +6155,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5792
6155
|
groups = new Map();
|
|
5793
6156
|
paramsList.forEach(function (params, index) {
|
|
5794
6157
|
var _params$customer_id2;
|
|
5795
|
-
var schedule =
|
|
6158
|
+
var schedule = _this19.getPriceQuerySchedule(params);
|
|
5796
6159
|
var channel = resolvedChannels[index];
|
|
5797
6160
|
var customerId = (_params$customer_id2 = params.customer_id) !== null && _params$customer_id2 !== void 0 ? _params$customer_id2 : currentOrderCustomerId;
|
|
5798
|
-
var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || '',
|
|
6161
|
+
var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || '', _this19.normalizePriceContextCustomerId(customerId) || ''].join('|');
|
|
5799
6162
|
var group = groups.get(groupKey) || {
|
|
5800
6163
|
indices: [],
|
|
5801
6164
|
schedule: schedule,
|
|
@@ -5805,44 +6168,44 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5805
6168
|
group.indices.push(index);
|
|
5806
6169
|
groups.set(groupKey, group);
|
|
5807
6170
|
});
|
|
5808
|
-
|
|
6171
|
+
_context60.next = 11;
|
|
5809
6172
|
return Promise.all(Array.from(groups.values()).map( /*#__PURE__*/function () {
|
|
5810
|
-
var
|
|
6173
|
+
var _ref54 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(group) {
|
|
5811
6174
|
var priceQueries, resolvedProducts;
|
|
5812
|
-
return _regeneratorRuntime().wrap(function
|
|
5813
|
-
while (1) switch (
|
|
6175
|
+
return _regeneratorRuntime().wrap(function _callee59$(_context59) {
|
|
6176
|
+
while (1) switch (_context59.prev = _context59.next) {
|
|
5814
6177
|
case 0:
|
|
5815
|
-
|
|
5816
|
-
return
|
|
6178
|
+
_context59.next = 2;
|
|
6179
|
+
return _this19.prepareProductPriceQueryContext(group.customerId);
|
|
5817
6180
|
case 2:
|
|
5818
6181
|
priceQueries = group.indices.map(function (index) {
|
|
5819
6182
|
return paramsList[index];
|
|
5820
6183
|
});
|
|
5821
|
-
|
|
5822
|
-
return
|
|
6184
|
+
_context59.next = 5;
|
|
6185
|
+
return _this19.resolveProductsForPriceQuery({
|
|
5823
6186
|
priceQueries: priceQueries,
|
|
5824
6187
|
schedule: group.schedule,
|
|
5825
6188
|
customerId: group.customerId,
|
|
5826
6189
|
channel: group.channel
|
|
5827
6190
|
});
|
|
5828
6191
|
case 5:
|
|
5829
|
-
resolvedProducts =
|
|
6192
|
+
resolvedProducts = _context59.sent;
|
|
5830
6193
|
group.indices.forEach(function (originalIndex, groupIndex) {
|
|
5831
6194
|
authoritativeProducts[originalIndex] = resolvedProducts[groupIndex] || null;
|
|
5832
6195
|
});
|
|
5833
6196
|
case 7:
|
|
5834
6197
|
case "end":
|
|
5835
|
-
return
|
|
6198
|
+
return _context59.stop();
|
|
5836
6199
|
}
|
|
5837
|
-
},
|
|
6200
|
+
}, _callee59);
|
|
5838
6201
|
}));
|
|
5839
|
-
return function (
|
|
5840
|
-
return
|
|
6202
|
+
return function (_x49) {
|
|
6203
|
+
return _ref54.apply(this, arguments);
|
|
5841
6204
|
};
|
|
5842
6205
|
}()));
|
|
5843
6206
|
case 11:
|
|
5844
6207
|
if (useCustomerUserPricing) {
|
|
5845
|
-
|
|
6208
|
+
_context60.next = 16;
|
|
5846
6209
|
break;
|
|
5847
6210
|
}
|
|
5848
6211
|
quotationContexts = new Map();
|
|
@@ -5856,18 +6219,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5856
6219
|
customer_id: (_params$customer_id3 = params.customer_id) !== null && _params$customer_id3 !== void 0 ? _params$customer_id3 : currentOrderCustomerId
|
|
5857
6220
|
});
|
|
5858
6221
|
});
|
|
5859
|
-
|
|
6222
|
+
_context60.next = 16;
|
|
5860
6223
|
return Promise.all(Array.from(quotationContexts.values()).map(function (context) {
|
|
5861
|
-
return
|
|
6224
|
+
return _this19.loadQuotationForPriceQuery(_objectSpread({
|
|
5862
6225
|
quotation: quotation
|
|
5863
6226
|
}, context));
|
|
5864
6227
|
}));
|
|
5865
6228
|
case 16:
|
|
5866
|
-
return
|
|
6229
|
+
return _context60.abrupt("return", paramsList.map(function (params, index) {
|
|
5867
6230
|
var _params$customer_id4;
|
|
5868
6231
|
var productInput = params.product || {};
|
|
5869
6232
|
var authoritativeProduct = authoritativeProducts[index];
|
|
5870
|
-
var product =
|
|
6233
|
+
var product = _this19.mergeProductForPriceQuery(productInput, authoritativeProduct);
|
|
5871
6234
|
var customerId = (_params$customer_id4 = params.customer_id) !== null && _params$customer_id4 !== void 0 ? _params$customer_id4 : currentOrderCustomerId;
|
|
5872
6235
|
var channel = resolvedChannels[index];
|
|
5873
6236
|
return calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
|
|
@@ -5875,16 +6238,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5875
6238
|
product: product,
|
|
5876
6239
|
fallback_price: authoritativeProduct ? undefined : params.fallback_price,
|
|
5877
6240
|
customer_id: customerId,
|
|
5878
|
-
quotation: authoritativeProduct &&
|
|
6241
|
+
quotation: authoritativeProduct && _this19.preferAuthoritativeProductQueryPrice() ? undefined : quotation
|
|
5879
6242
|
}));
|
|
5880
6243
|
}));
|
|
5881
6244
|
case 17:
|
|
5882
6245
|
case "end":
|
|
5883
|
-
return
|
|
6246
|
+
return _context60.stop();
|
|
5884
6247
|
}
|
|
5885
|
-
},
|
|
6248
|
+
}, _callee60, this);
|
|
5886
6249
|
}));
|
|
5887
|
-
function calculateProductBookingPrices(
|
|
6250
|
+
function calculateProductBookingPrices(_x48) {
|
|
5888
6251
|
return _calculateProductBookingPrices.apply(this, arguments);
|
|
5889
6252
|
}
|
|
5890
6253
|
return calculateProductBookingPrices;
|
|
@@ -5892,34 +6255,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5892
6255
|
}, {
|
|
5893
6256
|
key: "addProductToOrder",
|
|
5894
6257
|
value: function () {
|
|
5895
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6258
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(product, booking, options) {
|
|
5896
6259
|
var products;
|
|
5897
|
-
return _regeneratorRuntime().wrap(function
|
|
5898
|
-
while (1) switch (
|
|
6260
|
+
return _regeneratorRuntime().wrap(function _callee61$(_context61) {
|
|
6261
|
+
while (1) switch (_context61.prev = _context61.next) {
|
|
5899
6262
|
case 0:
|
|
5900
|
-
|
|
6263
|
+
_context61.prev = 0;
|
|
5901
6264
|
if (this.store.order) {
|
|
5902
|
-
|
|
6265
|
+
_context61.next = 3;
|
|
5903
6266
|
break;
|
|
5904
6267
|
}
|
|
5905
6268
|
throw new Error('order 模块未初始化');
|
|
5906
6269
|
case 3:
|
|
5907
|
-
|
|
6270
|
+
_context61.next = 5;
|
|
5908
6271
|
return this.store.order.addProductToOrder(product, booking, options);
|
|
5909
6272
|
case 5:
|
|
5910
|
-
products =
|
|
5911
|
-
return
|
|
6273
|
+
products = _context61.sent;
|
|
6274
|
+
return _context61.abrupt("return", products);
|
|
5912
6275
|
case 9:
|
|
5913
|
-
|
|
5914
|
-
|
|
5915
|
-
throw
|
|
6276
|
+
_context61.prev = 9;
|
|
6277
|
+
_context61.t0 = _context61["catch"](0);
|
|
6278
|
+
throw _context61.t0;
|
|
5916
6279
|
case 12:
|
|
5917
6280
|
case "end":
|
|
5918
|
-
return
|
|
6281
|
+
return _context61.stop();
|
|
5919
6282
|
}
|
|
5920
|
-
},
|
|
6283
|
+
}, _callee61, this, [[0, 9]]);
|
|
5921
6284
|
}));
|
|
5922
|
-
function addProductToOrder(
|
|
6285
|
+
function addProductToOrder(_x50, _x51, _x52) {
|
|
5923
6286
|
return _addProductToOrder.apply(this, arguments);
|
|
5924
6287
|
}
|
|
5925
6288
|
return addProductToOrder;
|
|
@@ -5927,34 +6290,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5927
6290
|
}, {
|
|
5928
6291
|
key: "updateOrderProduct",
|
|
5929
6292
|
value: function () {
|
|
5930
|
-
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6293
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(params) {
|
|
5931
6294
|
var products;
|
|
5932
|
-
return _regeneratorRuntime().wrap(function
|
|
5933
|
-
while (1) switch (
|
|
6295
|
+
return _regeneratorRuntime().wrap(function _callee62$(_context62) {
|
|
6296
|
+
while (1) switch (_context62.prev = _context62.next) {
|
|
5934
6297
|
case 0:
|
|
5935
|
-
|
|
6298
|
+
_context62.prev = 0;
|
|
5936
6299
|
if (this.store.order) {
|
|
5937
|
-
|
|
6300
|
+
_context62.next = 3;
|
|
5938
6301
|
break;
|
|
5939
6302
|
}
|
|
5940
6303
|
throw new Error('order 模块未初始化');
|
|
5941
6304
|
case 3:
|
|
5942
|
-
|
|
6305
|
+
_context62.next = 5;
|
|
5943
6306
|
return this.store.order.updateOrderProduct(params);
|
|
5944
6307
|
case 5:
|
|
5945
|
-
products =
|
|
5946
|
-
return
|
|
6308
|
+
products = _context62.sent;
|
|
6309
|
+
return _context62.abrupt("return", products);
|
|
5947
6310
|
case 9:
|
|
5948
|
-
|
|
5949
|
-
|
|
5950
|
-
throw
|
|
6311
|
+
_context62.prev = 9;
|
|
6312
|
+
_context62.t0 = _context62["catch"](0);
|
|
6313
|
+
throw _context62.t0;
|
|
5951
6314
|
case 12:
|
|
5952
6315
|
case "end":
|
|
5953
|
-
return
|
|
6316
|
+
return _context62.stop();
|
|
5954
6317
|
}
|
|
5955
|
-
},
|
|
6318
|
+
}, _callee62, this, [[0, 9]]);
|
|
5956
6319
|
}));
|
|
5957
|
-
function updateOrderProduct(
|
|
6320
|
+
function updateOrderProduct(_x53) {
|
|
5958
6321
|
return _updateOrderProduct.apply(this, arguments);
|
|
5959
6322
|
}
|
|
5960
6323
|
return updateOrderProduct;
|
|
@@ -5962,34 +6325,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5962
6325
|
}, {
|
|
5963
6326
|
key: "updateOrderProducts",
|
|
5964
6327
|
value: function () {
|
|
5965
|
-
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6328
|
+
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(paramsList) {
|
|
5966
6329
|
var products;
|
|
5967
|
-
return _regeneratorRuntime().wrap(function
|
|
5968
|
-
while (1) switch (
|
|
6330
|
+
return _regeneratorRuntime().wrap(function _callee63$(_context63) {
|
|
6331
|
+
while (1) switch (_context63.prev = _context63.next) {
|
|
5969
6332
|
case 0:
|
|
5970
|
-
|
|
6333
|
+
_context63.prev = 0;
|
|
5971
6334
|
if (this.store.order) {
|
|
5972
|
-
|
|
6335
|
+
_context63.next = 3;
|
|
5973
6336
|
break;
|
|
5974
6337
|
}
|
|
5975
6338
|
throw new Error('order 模块未初始化');
|
|
5976
6339
|
case 3:
|
|
5977
|
-
|
|
6340
|
+
_context63.next = 5;
|
|
5978
6341
|
return this.store.order.updateOrderProducts(paramsList);
|
|
5979
6342
|
case 5:
|
|
5980
|
-
products =
|
|
5981
|
-
return
|
|
6343
|
+
products = _context63.sent;
|
|
6344
|
+
return _context63.abrupt("return", products);
|
|
5982
6345
|
case 9:
|
|
5983
|
-
|
|
5984
|
-
|
|
5985
|
-
throw
|
|
6346
|
+
_context63.prev = 9;
|
|
6347
|
+
_context63.t0 = _context63["catch"](0);
|
|
6348
|
+
throw _context63.t0;
|
|
5986
6349
|
case 12:
|
|
5987
6350
|
case "end":
|
|
5988
|
-
return
|
|
6351
|
+
return _context63.stop();
|
|
5989
6352
|
}
|
|
5990
|
-
},
|
|
6353
|
+
}, _callee63, this, [[0, 9]]);
|
|
5991
6354
|
}));
|
|
5992
|
-
function updateOrderProducts(
|
|
6355
|
+
function updateOrderProducts(_x54) {
|
|
5993
6356
|
return _updateOrderProducts.apply(this, arguments);
|
|
5994
6357
|
}
|
|
5995
6358
|
return updateOrderProducts;
|
|
@@ -5997,34 +6360,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5997
6360
|
}, {
|
|
5998
6361
|
key: "updateOrderProductQuantity",
|
|
5999
6362
|
value: function () {
|
|
6000
|
-
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6363
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(params) {
|
|
6001
6364
|
var products;
|
|
6002
|
-
return _regeneratorRuntime().wrap(function
|
|
6003
|
-
while (1) switch (
|
|
6365
|
+
return _regeneratorRuntime().wrap(function _callee64$(_context64) {
|
|
6366
|
+
while (1) switch (_context64.prev = _context64.next) {
|
|
6004
6367
|
case 0:
|
|
6005
|
-
|
|
6368
|
+
_context64.prev = 0;
|
|
6006
6369
|
if (this.store.order) {
|
|
6007
|
-
|
|
6370
|
+
_context64.next = 3;
|
|
6008
6371
|
break;
|
|
6009
6372
|
}
|
|
6010
6373
|
throw new Error('order 模块未初始化');
|
|
6011
6374
|
case 3:
|
|
6012
|
-
|
|
6375
|
+
_context64.next = 5;
|
|
6013
6376
|
return this.store.order.updateOrderProductQuantity(params);
|
|
6014
6377
|
case 5:
|
|
6015
|
-
products =
|
|
6016
|
-
return
|
|
6378
|
+
products = _context64.sent;
|
|
6379
|
+
return _context64.abrupt("return", products);
|
|
6017
6380
|
case 9:
|
|
6018
|
-
|
|
6019
|
-
|
|
6020
|
-
throw
|
|
6381
|
+
_context64.prev = 9;
|
|
6382
|
+
_context64.t0 = _context64["catch"](0);
|
|
6383
|
+
throw _context64.t0;
|
|
6021
6384
|
case 12:
|
|
6022
6385
|
case "end":
|
|
6023
|
-
return
|
|
6386
|
+
return _context64.stop();
|
|
6024
6387
|
}
|
|
6025
|
-
},
|
|
6388
|
+
}, _callee64, this, [[0, 9]]);
|
|
6026
6389
|
}));
|
|
6027
|
-
function updateOrderProductQuantity(
|
|
6390
|
+
function updateOrderProductQuantity(_x55) {
|
|
6028
6391
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
6029
6392
|
}
|
|
6030
6393
|
return updateOrderProductQuantity;
|
|
@@ -6047,12 +6410,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6047
6410
|
}, {
|
|
6048
6411
|
key: "setOrderProductLineNote",
|
|
6049
6412
|
value: (function () {
|
|
6050
|
-
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6413
|
+
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(identity, note) {
|
|
6051
6414
|
var params, products;
|
|
6052
|
-
return _regeneratorRuntime().wrap(function
|
|
6053
|
-
while (1) switch (
|
|
6415
|
+
return _regeneratorRuntime().wrap(function _callee65$(_context65) {
|
|
6416
|
+
while (1) switch (_context65.prev = _context65.next) {
|
|
6054
6417
|
case 0:
|
|
6055
|
-
|
|
6418
|
+
_context65.prev = 0;
|
|
6056
6419
|
params = {
|
|
6057
6420
|
product_id: identity.product_id,
|
|
6058
6421
|
product_variant_id: identity.product_variant_id,
|
|
@@ -6067,22 +6430,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6067
6430
|
params.product_sku = identity.product_sku;
|
|
6068
6431
|
}
|
|
6069
6432
|
if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
|
|
6070
|
-
|
|
6433
|
+
_context65.next = 7;
|
|
6071
6434
|
return this.updateOrderProduct(params);
|
|
6072
6435
|
case 7:
|
|
6073
|
-
products =
|
|
6074
|
-
return
|
|
6436
|
+
products = _context65.sent;
|
|
6437
|
+
return _context65.abrupt("return", products);
|
|
6075
6438
|
case 11:
|
|
6076
|
-
|
|
6077
|
-
|
|
6078
|
-
throw
|
|
6439
|
+
_context65.prev = 11;
|
|
6440
|
+
_context65.t0 = _context65["catch"](0);
|
|
6441
|
+
throw _context65.t0;
|
|
6079
6442
|
case 14:
|
|
6080
6443
|
case "end":
|
|
6081
|
-
return
|
|
6444
|
+
return _context65.stop();
|
|
6082
6445
|
}
|
|
6083
|
-
},
|
|
6446
|
+
}, _callee65, this, [[0, 11]]);
|
|
6084
6447
|
}));
|
|
6085
|
-
function setOrderProductLineNote(
|
|
6448
|
+
function setOrderProductLineNote(_x56, _x57) {
|
|
6086
6449
|
return _setOrderProductLineNote.apply(this, arguments);
|
|
6087
6450
|
}
|
|
6088
6451
|
return setOrderProductLineNote;
|
|
@@ -6097,32 +6460,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6097
6460
|
}, {
|
|
6098
6461
|
key: "removeProductsFromOrder",
|
|
6099
6462
|
value: (function () {
|
|
6100
|
-
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6101
|
-
return _regeneratorRuntime().wrap(function
|
|
6102
|
-
while (1) switch (
|
|
6463
|
+
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(identities, options) {
|
|
6464
|
+
return _regeneratorRuntime().wrap(function _callee66$(_context66) {
|
|
6465
|
+
while (1) switch (_context66.prev = _context66.next) {
|
|
6103
6466
|
case 0:
|
|
6104
|
-
|
|
6467
|
+
_context66.prev = 0;
|
|
6105
6468
|
if (this.store.order) {
|
|
6106
|
-
|
|
6469
|
+
_context66.next = 3;
|
|
6107
6470
|
break;
|
|
6108
6471
|
}
|
|
6109
6472
|
throw new Error('order 模块未初始化');
|
|
6110
6473
|
case 3:
|
|
6111
|
-
|
|
6474
|
+
_context66.next = 5;
|
|
6112
6475
|
return this.store.order.removeProductsFromOrder(identities, options);
|
|
6113
6476
|
case 5:
|
|
6114
|
-
return
|
|
6477
|
+
return _context66.abrupt("return", _context66.sent);
|
|
6115
6478
|
case 8:
|
|
6116
|
-
|
|
6117
|
-
|
|
6118
|
-
throw
|
|
6479
|
+
_context66.prev = 8;
|
|
6480
|
+
_context66.t0 = _context66["catch"](0);
|
|
6481
|
+
throw _context66.t0;
|
|
6119
6482
|
case 11:
|
|
6120
6483
|
case "end":
|
|
6121
|
-
return
|
|
6484
|
+
return _context66.stop();
|
|
6122
6485
|
}
|
|
6123
|
-
},
|
|
6486
|
+
}, _callee66, this, [[0, 8]]);
|
|
6124
6487
|
}));
|
|
6125
|
-
function removeProductsFromOrder(
|
|
6488
|
+
function removeProductsFromOrder(_x58, _x59) {
|
|
6126
6489
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
6127
6490
|
}
|
|
6128
6491
|
return removeProductsFromOrder;
|
|
@@ -6130,18 +6493,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6130
6493
|
}, {
|
|
6131
6494
|
key: "removeProductFromOrder",
|
|
6132
6495
|
value: function () {
|
|
6133
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6134
|
-
return _regeneratorRuntime().wrap(function
|
|
6135
|
-
while (1) switch (
|
|
6496
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(identity, options) {
|
|
6497
|
+
return _regeneratorRuntime().wrap(function _callee67$(_context67) {
|
|
6498
|
+
while (1) switch (_context67.prev = _context67.next) {
|
|
6136
6499
|
case 0:
|
|
6137
|
-
return
|
|
6500
|
+
return _context67.abrupt("return", this.removeProductsFromOrder([identity], options));
|
|
6138
6501
|
case 1:
|
|
6139
6502
|
case "end":
|
|
6140
|
-
return
|
|
6503
|
+
return _context67.stop();
|
|
6141
6504
|
}
|
|
6142
|
-
},
|
|
6505
|
+
}, _callee67, this);
|
|
6143
6506
|
}));
|
|
6144
|
-
function removeProductFromOrder(
|
|
6507
|
+
function removeProductFromOrder(_x60, _x61) {
|
|
6145
6508
|
return _removeProductFromOrder.apply(this, arguments);
|
|
6146
6509
|
}
|
|
6147
6510
|
return removeProductFromOrder;
|
|
@@ -6191,23 +6554,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6191
6554
|
}, {
|
|
6192
6555
|
key: "applyPromotion",
|
|
6193
6556
|
value: (function () {
|
|
6194
|
-
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6195
|
-
return _regeneratorRuntime().wrap(function
|
|
6196
|
-
while (1) switch (
|
|
6557
|
+
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68() {
|
|
6558
|
+
return _regeneratorRuntime().wrap(function _callee68$(_context68) {
|
|
6559
|
+
while (1) switch (_context68.prev = _context68.next) {
|
|
6197
6560
|
case 0:
|
|
6198
6561
|
if (this.store.order) {
|
|
6199
|
-
|
|
6562
|
+
_context68.next = 2;
|
|
6200
6563
|
break;
|
|
6201
6564
|
}
|
|
6202
6565
|
throw new Error('order 模块未初始化');
|
|
6203
6566
|
case 2:
|
|
6204
|
-
|
|
6567
|
+
_context68.next = 4;
|
|
6205
6568
|
return this.store.order.applyPromotion();
|
|
6206
6569
|
case 4:
|
|
6207
6570
|
case "end":
|
|
6208
|
-
return
|
|
6571
|
+
return _context68.stop();
|
|
6209
6572
|
}
|
|
6210
|
-
},
|
|
6573
|
+
}, _callee68, this);
|
|
6211
6574
|
}));
|
|
6212
6575
|
function applyPromotion() {
|
|
6213
6576
|
return _applyPromotion.apply(this, arguments);
|
|
@@ -6217,16 +6580,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6217
6580
|
}, {
|
|
6218
6581
|
key: "getUnfulfilledPromotions",
|
|
6219
6582
|
value: function getUnfulfilledPromotions() {
|
|
6220
|
-
var _this$store$
|
|
6221
|
-
return ((_this$store$
|
|
6583
|
+
var _this$store$order24;
|
|
6584
|
+
return ((_this$store$order24 = this.store.order) === null || _this$store$order24 === void 0 ? void 0 : _this$store$order24.getUnfulfilledPromotions()) || [];
|
|
6222
6585
|
}
|
|
6223
6586
|
|
|
6224
6587
|
/** 最近一次促销计算输出的赠品操作 diff。 */
|
|
6225
6588
|
}, {
|
|
6226
6589
|
key: "getLastGiftActions",
|
|
6227
6590
|
value: function getLastGiftActions() {
|
|
6228
|
-
var _this$store$
|
|
6229
|
-
return ((_this$store$
|
|
6591
|
+
var _this$store$order25;
|
|
6592
|
+
return ((_this$store$order25 = this.store.order) === null || _this$store$order25 === void 0 ? void 0 : _this$store$order25.getLastGiftActions()) || null;
|
|
6230
6593
|
}
|
|
6231
6594
|
|
|
6232
6595
|
// 获取商品列表
|
|
@@ -6234,18 +6597,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6234
6597
|
}, {
|
|
6235
6598
|
key: "getProductList",
|
|
6236
6599
|
value: function () {
|
|
6237
|
-
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6600
|
+
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69() {
|
|
6238
6601
|
var _this$otherParams36;
|
|
6239
6602
|
var menu_list_ids, _this$store$products, res;
|
|
6240
|
-
return _regeneratorRuntime().wrap(function
|
|
6241
|
-
while (1) switch (
|
|
6603
|
+
return _regeneratorRuntime().wrap(function _callee69$(_context69) {
|
|
6604
|
+
while (1) switch (_context69.prev = _context69.next) {
|
|
6242
6605
|
case 0:
|
|
6243
6606
|
// 可以直接通过配置里的 menu 读取
|
|
6244
6607
|
menu_list_ids = ((_this$otherParams36 = this.otherParams) === null || _this$otherParams36 === void 0 || (_this$otherParams36 = _this$otherParams36.dineInConfig) === null || _this$otherParams36 === void 0 ? void 0 : _this$otherParams36['menu.associated_menus'].map(function (n) {
|
|
6245
6608
|
return Number(n.value);
|
|
6246
6609
|
})) || [];
|
|
6247
|
-
|
|
6248
|
-
|
|
6610
|
+
_context69.prev = 1;
|
|
6611
|
+
_context69.next = 4;
|
|
6249
6612
|
return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
|
|
6250
6613
|
menu_list_ids: menu_list_ids,
|
|
6251
6614
|
cacheId: this.cacheId,
|
|
@@ -6253,17 +6616,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6253
6616
|
schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
6254
6617
|
});
|
|
6255
6618
|
case 4:
|
|
6256
|
-
res =
|
|
6257
|
-
return
|
|
6619
|
+
res = _context69.sent;
|
|
6620
|
+
return _context69.abrupt("return", res);
|
|
6258
6621
|
case 8:
|
|
6259
|
-
|
|
6260
|
-
|
|
6261
|
-
throw
|
|
6622
|
+
_context69.prev = 8;
|
|
6623
|
+
_context69.t0 = _context69["catch"](1);
|
|
6624
|
+
throw _context69.t0;
|
|
6262
6625
|
case 11:
|
|
6263
6626
|
case "end":
|
|
6264
|
-
return
|
|
6627
|
+
return _context69.stop();
|
|
6265
6628
|
}
|
|
6266
|
-
},
|
|
6629
|
+
}, _callee69, this, [[1, 8]]);
|
|
6267
6630
|
}));
|
|
6268
6631
|
function getProductList() {
|
|
6269
6632
|
return _getProductList.apply(this, arguments);
|
|
@@ -6278,33 +6641,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6278
6641
|
}, {
|
|
6279
6642
|
key: "setOtherParams",
|
|
6280
6643
|
value: function () {
|
|
6281
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6644
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(params) {
|
|
6282
6645
|
var _this$otherParams37;
|
|
6283
|
-
var
|
|
6284
|
-
|
|
6646
|
+
var _ref55,
|
|
6647
|
+
_ref55$cover,
|
|
6285
6648
|
cover,
|
|
6286
|
-
|
|
6287
|
-
return _regeneratorRuntime().wrap(function
|
|
6288
|
-
while (1) switch (
|
|
6649
|
+
_args70 = arguments;
|
|
6650
|
+
return _regeneratorRuntime().wrap(function _callee70$(_context70) {
|
|
6651
|
+
while (1) switch (_context70.prev = _context70.next) {
|
|
6289
6652
|
case 0:
|
|
6290
|
-
|
|
6653
|
+
_ref55 = _args70.length > 1 && _args70[1] !== undefined ? _args70[1] : {}, _ref55$cover = _ref55.cover, cover = _ref55$cover === void 0 ? false : _ref55$cover;
|
|
6291
6654
|
if (cover) {
|
|
6292
6655
|
this.otherParams = _objectSpread({}, params);
|
|
6293
6656
|
} else {
|
|
6294
6657
|
this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
|
|
6295
6658
|
}
|
|
6296
6659
|
this.cacheId = (_this$otherParams37 = this.otherParams) === null || _this$otherParams37 === void 0 ? void 0 : _this$otherParams37.cacheId;
|
|
6297
|
-
|
|
6660
|
+
_context70.next = 5;
|
|
6298
6661
|
return this.syncOtherParamsToSubModules(params, {
|
|
6299
6662
|
cover: cover
|
|
6300
6663
|
});
|
|
6301
6664
|
case 5:
|
|
6302
6665
|
case "end":
|
|
6303
|
-
return
|
|
6666
|
+
return _context70.stop();
|
|
6304
6667
|
}
|
|
6305
|
-
},
|
|
6668
|
+
}, _callee70, this);
|
|
6306
6669
|
}));
|
|
6307
|
-
function setOtherParams(
|
|
6670
|
+
function setOtherParams(_x62) {
|
|
6308
6671
|
return _setOtherParams.apply(this, arguments);
|
|
6309
6672
|
}
|
|
6310
6673
|
return setOtherParams;
|