@pisell/pisellos 2.3.94 → 2.3.95
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/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/Order/index.d.ts +18 -3
- package/dist/modules/Order/index.js +885 -485
- package/dist/modules/Order/salesNotes.d.ts +31 -0
- package/dist/modules/Order/salesNotes.js +492 -0
- package/dist/modules/Order/types.d.ts +91 -5
- package/dist/modules/Order/types.js +5 -0
- package/dist/modules/Order/utils.d.ts +12 -0
- package/dist/modules/Order/utils.js +75 -26
- 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 +6 -0
- package/dist/server/index.js +43 -3
- package/dist/solution/BaseSales/index.d.ts +9 -1
- package/dist/solution/BaseSales/index.js +894 -706
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- 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 +751 -483
- 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 +18 -3
- package/lib/modules/Order/index.js +325 -28
- package/lib/modules/Order/salesNotes.d.ts +31 -0
- package/lib/modules/Order/salesNotes.js +382 -0
- package/lib/modules/Order/types.d.ts +91 -5
- package/lib/modules/Order/types.js +4 -0
- package/lib/modules/Order/utils.d.ts +12 -0
- package/lib/modules/Order/utils.js +68 -16
- 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 +6 -0
- package/lib/server/index.js +37 -3
- package/lib/solution/BaseSales/index.d.ts +9 -1
- package/lib/solution/BaseSales/index.js +105 -1
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingTicket/utils/orderCustomer.js +2 -1
- package/lib/solution/RegisterAndLogin/config.d.ts +9 -3
- package/lib/solution/RegisterAndLogin/config.js +49 -8
- package/lib/solution/RegisterAndLogin/index.js +4 -1
- package/lib/solution/ScanOrder/index.d.ts +1 -0
- package/lib/solution/ScanOrder/index.js +5 -1
- package/lib/solution/ScanOrder/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
|
@@ -35,6 +35,7 @@ import { OrderHooks } from "./types";
|
|
|
35
35
|
import { composeLinePrice, generateDuration, getAllDiscountList, mergeRelationForms, ensureCartItemOriginHolder, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments, normalizeOrderProductDiscountList, resolveEffectivePerUnitDiscount, ensureProductSku, getProductSkuOptions, normalizeProductSkuOptions, sumOptionUnitPrice, clearTempOrderHolderAssignments, getOrderProductLineUid, indexOrderProductsByUid, calculateOrderProductsDeposit, mergeOrderProductDisplayFields, resolveIsFormSubject } from "./utils";
|
|
36
36
|
import { isNormalProduct } from "../Product/utils";
|
|
37
37
|
import dayjs from 'dayjs';
|
|
38
|
+
import { buildSalesNoteText, decodeSalesNotesSnapshot, getSalesNotePolicy } from "./salesNotes";
|
|
38
39
|
import { ensureOrderPaymentNumber, mergeOrderPaymentRecord, resolveOrderPaymentIdentity } from "./payment-utils";
|
|
39
40
|
import { resolvePaymentNumberDevicePrefix, resolvePaymentNumberDevicePrefixFromDeviceId } from "../../utils/payment-number";
|
|
40
41
|
import { processCartPromotion, appendPromotionTags as _appendPromotionTags, getOrderProductUid as getPromotionUid, PRODUCT_LINE_MERGE_DISABLED_METADATA_KEY } from "../../solution/BaseSales/utils/cartPromotion";
|
|
@@ -1373,6 +1374,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1373
1374
|
if (!this.store.tempOrder) return;
|
|
1374
1375
|
this.store.tempOrder = _objectSpread(_objectSpread({}, this.store.tempOrder), {}, {
|
|
1375
1376
|
products: _toConsumableArray(this.store.tempOrder.products),
|
|
1377
|
+
notes: _toConsumableArray(this.store.tempOrder.notes || []),
|
|
1376
1378
|
bookings: this.store.tempOrder.bookings ? _toConsumableArray(this.store.tempOrder.bookings) : []
|
|
1377
1379
|
});
|
|
1378
1380
|
this.persistTempOrder();
|
|
@@ -3208,6 +3210,277 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3208
3210
|
var _this$store$tempOrder3;
|
|
3209
3211
|
return ((_this$store$tempOrder3 = this.store.tempOrder) === null || _this$store$tempOrder3 === void 0 ? void 0 : _this$store$tempOrder3.note) || '';
|
|
3210
3212
|
}
|
|
3213
|
+
}, {
|
|
3214
|
+
key: "ensureSalesNotesRuntimeState",
|
|
3215
|
+
value: function ensureSalesNotesRuntimeState(tempOrder) {
|
|
3216
|
+
var hadNotesSnapshot = Array.isArray(tempOrder.notes);
|
|
3217
|
+
if (!Array.isArray(tempOrder.notes)) tempOrder.notes = [];
|
|
3218
|
+
if (!tempOrder._extend || _typeof(tempOrder._extend) !== 'object') {
|
|
3219
|
+
tempOrder._extend = {
|
|
3220
|
+
productsByUid: {}
|
|
3221
|
+
};
|
|
3222
|
+
}
|
|
3223
|
+
if (!tempOrder._extend.salesNotesState) {
|
|
3224
|
+
tempOrder._extend.salesNotesState = {
|
|
3225
|
+
loaded: hadNotesSnapshot,
|
|
3226
|
+
dirty: false
|
|
3227
|
+
};
|
|
3228
|
+
}
|
|
3229
|
+
return tempOrder._extend.salesNotesState;
|
|
3230
|
+
}
|
|
3231
|
+
}, {
|
|
3232
|
+
key: "ensureSalesNotesLoadedForMutation",
|
|
3233
|
+
value: function ensureSalesNotesLoadedForMutation(tempOrder) {
|
|
3234
|
+
var state = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
3235
|
+
if (state.loaded) return;
|
|
3236
|
+
if (tempOrder.order_id === null || tempOrder.order_id === undefined) {
|
|
3237
|
+
state.loaded = true;
|
|
3238
|
+
tempOrder.notes = [];
|
|
3239
|
+
return;
|
|
3240
|
+
}
|
|
3241
|
+
throw new Error('[Order Notes] 当前订单 Notes 尚未完整加载,禁止提交部分快照');
|
|
3242
|
+
}
|
|
3243
|
+
}, {
|
|
3244
|
+
key: "normalizeSalesNoteUuid",
|
|
3245
|
+
value: function normalizeSalesNoteUuid(value, field) {
|
|
3246
|
+
var uuid = String(value !== null && value !== void 0 ? value : '').trim();
|
|
3247
|
+
if (!uuid) throw new Error("[Order Notes] ".concat(field, " \u4E0D\u80FD\u4E3A\u7A7A"));
|
|
3248
|
+
if (uuid.length > 255) {
|
|
3249
|
+
throw new Error("[Order Notes] ".concat(field, " \u4E0D\u80FD\u8D85\u8FC7 255 \u4E2A\u5B57\u7B26"));
|
|
3250
|
+
}
|
|
3251
|
+
return uuid;
|
|
3252
|
+
}
|
|
3253
|
+
}, {
|
|
3254
|
+
key: "getSalesNotePrimaryRelation",
|
|
3255
|
+
value: function getSalesNotePrimaryRelation(note) {
|
|
3256
|
+
return note.note_relations.find(function (relation) {
|
|
3257
|
+
return relation.is_primary === 1;
|
|
3258
|
+
}) || null;
|
|
3259
|
+
}
|
|
3260
|
+
}, {
|
|
3261
|
+
key: "removeSalesNotesForMissingProductLines",
|
|
3262
|
+
value: function removeSalesNotesForMissingProductLines(tempOrder) {
|
|
3263
|
+
var _this19 = this;
|
|
3264
|
+
var state = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
3265
|
+
if (!state.loaded || !Array.isArray(tempOrder.notes) || tempOrder.notes.length === 0) {
|
|
3266
|
+
return;
|
|
3267
|
+
}
|
|
3268
|
+
var remainingProductUids = new Set((tempOrder.products || []).map(function (product) {
|
|
3269
|
+
var _product$metadata7;
|
|
3270
|
+
return ((_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.unique_identification_number) || product.unique_identification_number;
|
|
3271
|
+
}).filter(function (uid) {
|
|
3272
|
+
return typeof uid === 'string' && uid.length > 0;
|
|
3273
|
+
}));
|
|
3274
|
+
var nextNotes = tempOrder.notes.filter(function (note) {
|
|
3275
|
+
var primary = _this19.getSalesNotePrimaryRelation(note);
|
|
3276
|
+
if (!primary || primary.target_type !== 'order_detail') return true;
|
|
3277
|
+
return remainingProductUids.has(primary.target_uuid);
|
|
3278
|
+
});
|
|
3279
|
+
if (nextNotes.length === tempOrder.notes.length) return;
|
|
3280
|
+
tempOrder.notes = nextNotes;
|
|
3281
|
+
state.dirty = true;
|
|
3282
|
+
}
|
|
3283
|
+
}, {
|
|
3284
|
+
key: "setSalesNoteOnTempOrder",
|
|
3285
|
+
value: function setSalesNoteOnTempOrder(tempOrder, input) {
|
|
3286
|
+
var _input$target,
|
|
3287
|
+
_this20 = this,
|
|
3288
|
+
_tempOrder$shop_order;
|
|
3289
|
+
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
3290
|
+
var note_type = String(input.note_type || '').trim();
|
|
3291
|
+
var policy = getSalesNotePolicy(note_type);
|
|
3292
|
+
if (!policy) {
|
|
3293
|
+
throw new Error("[Order Notes] \u5F53\u524D\u672A\u6CE8\u518C\u5907\u6CE8\u7C7B\u578B: ".concat(note_type || '(empty)'));
|
|
3294
|
+
}
|
|
3295
|
+
if (((_input$target = input.target) === null || _input$target === void 0 ? void 0 : _input$target.target_type) !== 'order_detail') {
|
|
3296
|
+
throw new Error('[Order Notes] 本期只支持 order_detail 作为主体');
|
|
3297
|
+
}
|
|
3298
|
+
var target_uuid = this.normalizeSalesNoteUuid(input.target.target_uuid, 'target_uuid');
|
|
3299
|
+
var targetProductExists = (tempOrder.products || []).some(function (product) {
|
|
3300
|
+
var _product$metadata8;
|
|
3301
|
+
var productLineUid = ((_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.unique_identification_number) || product.unique_identification_number;
|
|
3302
|
+
return String(productLineUid !== null && productLineUid !== void 0 ? productLineUid : '') === target_uuid;
|
|
3303
|
+
});
|
|
3304
|
+
if (!targetProductExists) {
|
|
3305
|
+
throw new Error('[Order Notes] 目标商品行不存在');
|
|
3306
|
+
}
|
|
3307
|
+
var text = buildSalesNoteText(input.text);
|
|
3308
|
+
var notes = tempOrder.notes || [];
|
|
3309
|
+
// 当前 allergy policy 固定同一商品行只保留一条;业务调用方不参与去重规则。
|
|
3310
|
+
var existingIndex = policy.uniquePerPrimaryTarget ? notes.findIndex(function (note) {
|
|
3311
|
+
var primary = _this20.getSalesNotePrimaryRelation(note);
|
|
3312
|
+
return note.note_type === note_type && (primary === null || primary === void 0 ? void 0 : primary.target_type) === 'order_detail' && primary.target_uuid === target_uuid;
|
|
3313
|
+
}) : -1;
|
|
3314
|
+
var existing = existingIndex >= 0 ? notes[existingIndex] : null;
|
|
3315
|
+
var existingPrimary = existing === null || existing === void 0 ? void 0 : existing.note_relations.find(function (relation) {
|
|
3316
|
+
return relation.is_primary === 1 && relation.target_type === 'order_detail';
|
|
3317
|
+
});
|
|
3318
|
+
var existingOrderRelation = existing === null || existing === void 0 ? void 0 : existing.note_relations.find(function (relation) {
|
|
3319
|
+
return relation.is_primary === 0 && relation.target_type === 'order';
|
|
3320
|
+
});
|
|
3321
|
+
var note = {
|
|
3322
|
+
uuid: (existing === null || existing === void 0 ? void 0 : existing.uuid) || createUuidV4(),
|
|
3323
|
+
note_type: policy.note_type,
|
|
3324
|
+
content: {
|
|
3325
|
+
text: text
|
|
3326
|
+
},
|
|
3327
|
+
importance: policy.importance,
|
|
3328
|
+
note_relations: [{
|
|
3329
|
+
uuid: (existingPrimary === null || existingPrimary === void 0 ? void 0 : existingPrimary.uuid) || createUuidV4(),
|
|
3330
|
+
relation_type: policy.primary_relation_type,
|
|
3331
|
+
target_type: 'order_detail',
|
|
3332
|
+
target_uuid: target_uuid,
|
|
3333
|
+
is_primary: 1
|
|
3334
|
+
}, {
|
|
3335
|
+
uuid: (existingOrderRelation === null || existingOrderRelation === void 0 ? void 0 : existingOrderRelation.uuid) || createUuidV4(),
|
|
3336
|
+
relation_type: policy.secondary_order_relation_type,
|
|
3337
|
+
target_type: 'order',
|
|
3338
|
+
target_uuid: String((_tempOrder$shop_order = tempOrder.shop_order_number) !== null && _tempOrder$shop_order !== void 0 ? _tempOrder$shop_order : ''),
|
|
3339
|
+
is_primary: 0
|
|
3340
|
+
}]
|
|
3341
|
+
};
|
|
3342
|
+
var duplicateIndex = notes.findIndex(function (item, index) {
|
|
3343
|
+
return item.uuid === note.uuid && index !== existingIndex;
|
|
3344
|
+
});
|
|
3345
|
+
if (duplicateIndex >= 0) {
|
|
3346
|
+
throw new Error('[Order Notes] uuid 已被其他 Note 使用');
|
|
3347
|
+
}
|
|
3348
|
+
tempOrder.notes = existingIndex >= 0 ? notes.map(function (item, index) {
|
|
3349
|
+
return index === existingIndex ? note : item;
|
|
3350
|
+
}) : [].concat(_toConsumableArray(notes), [note]);
|
|
3351
|
+
var state = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
3352
|
+
state.loaded = true;
|
|
3353
|
+
state.dirty = true;
|
|
3354
|
+
return note;
|
|
3355
|
+
}
|
|
3356
|
+
}, {
|
|
3357
|
+
key: "getSalesNotes",
|
|
3358
|
+
value: function getSalesNotes() {
|
|
3359
|
+
var tempOrder = this.ensureTempOrder();
|
|
3360
|
+
this.ensureSalesNotesRuntimeState(tempOrder);
|
|
3361
|
+
return cloneDeep(tempOrder.notes || []);
|
|
3362
|
+
}
|
|
3363
|
+
}, {
|
|
3364
|
+
key: "createSalesNotesMutationSnapshot",
|
|
3365
|
+
value: function createSalesNotesMutationSnapshot() {
|
|
3366
|
+
var _tempOrder$order_id2;
|
|
3367
|
+
var tempOrder = this.ensureTempOrder();
|
|
3368
|
+
var state = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
3369
|
+
return {
|
|
3370
|
+
orderIdentity: {
|
|
3371
|
+
orderId: (_tempOrder$order_id2 = tempOrder.order_id) !== null && _tempOrder$order_id2 !== void 0 ? _tempOrder$order_id2 : null,
|
|
3372
|
+
externalSaleNumber: String(tempOrder.external_sale_number || '')
|
|
3373
|
+
},
|
|
3374
|
+
notes: cloneDeep(tempOrder.notes || []),
|
|
3375
|
+
state: cloneDeep(state)
|
|
3376
|
+
};
|
|
3377
|
+
}
|
|
3378
|
+
}, {
|
|
3379
|
+
key: "restoreSalesNotesMutationSnapshot",
|
|
3380
|
+
value: function restoreSalesNotesMutationSnapshot(snapshot) {
|
|
3381
|
+
var _snapshot$state, _snapshot$state2;
|
|
3382
|
+
if (!snapshot || !Array.isArray(snapshot.notes) || !snapshot.orderIdentity || typeof snapshot.orderIdentity.externalSaleNumber !== 'string' || typeof ((_snapshot$state = snapshot.state) === null || _snapshot$state === void 0 ? void 0 : _snapshot$state.loaded) !== 'boolean' || typeof ((_snapshot$state2 = snapshot.state) === null || _snapshot$state2 === void 0 ? void 0 : _snapshot$state2.dirty) !== 'boolean') {
|
|
3383
|
+
throw new Error('[Order Notes] 无效的 mutation snapshot');
|
|
3384
|
+
}
|
|
3385
|
+
var tempOrder = this.store.tempOrder;
|
|
3386
|
+
if (!tempOrder) throw new Error('[Order Notes] 当前订单不存在');
|
|
3387
|
+
var snapshotOrderId = snapshot.orderIdentity.orderId;
|
|
3388
|
+
var currentOrderId = tempOrder.order_id;
|
|
3389
|
+
var hasSnapshotOrderId = snapshotOrderId !== null && snapshotOrderId !== undefined && String(snapshotOrderId).trim().length > 0;
|
|
3390
|
+
var hasCurrentOrderId = currentOrderId !== null && currentOrderId !== undefined && String(currentOrderId).trim().length > 0;
|
|
3391
|
+
var isSameOrder = hasSnapshotOrderId && hasCurrentOrderId ? String(snapshotOrderId) === String(currentOrderId) : Boolean(snapshot.orderIdentity.externalSaleNumber) && snapshot.orderIdentity.externalSaleNumber === String(tempOrder.external_sale_number || '');
|
|
3392
|
+
if (!isSameOrder) {
|
|
3393
|
+
throw new Error('[Order Notes] 当前订单已切换,拒绝恢复旧订单快照');
|
|
3394
|
+
}
|
|
3395
|
+
this.ensureSalesNotesRuntimeState(tempOrder);
|
|
3396
|
+
tempOrder.notes = cloneDeep(snapshot.notes);
|
|
3397
|
+
tempOrder._extend.salesNotesState = cloneDeep(snapshot.state);
|
|
3398
|
+
this.notifyTempOrderChanged();
|
|
3399
|
+
}
|
|
3400
|
+
}, {
|
|
3401
|
+
key: "setSalesNote",
|
|
3402
|
+
value: function () {
|
|
3403
|
+
var _setSalesNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(input) {
|
|
3404
|
+
var tempOrder, note;
|
|
3405
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context17) {
|
|
3406
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
3407
|
+
case 0:
|
|
3408
|
+
tempOrder = this.ensureTempOrder();
|
|
3409
|
+
note = this.setSalesNoteOnTempOrder(tempOrder, input);
|
|
3410
|
+
this.notifyTempOrderChanged();
|
|
3411
|
+
return _context17.abrupt("return", cloneDeep(note));
|
|
3412
|
+
case 4:
|
|
3413
|
+
case "end":
|
|
3414
|
+
return _context17.stop();
|
|
3415
|
+
}
|
|
3416
|
+
}, _callee15, this);
|
|
3417
|
+
}));
|
|
3418
|
+
function setSalesNote(_x14) {
|
|
3419
|
+
return _setSalesNote.apply(this, arguments);
|
|
3420
|
+
}
|
|
3421
|
+
return setSalesNote;
|
|
3422
|
+
}()
|
|
3423
|
+
}, {
|
|
3424
|
+
key: "removeSalesNote",
|
|
3425
|
+
value: function () {
|
|
3426
|
+
var _removeSalesNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(uuid) {
|
|
3427
|
+
var tempOrder, normalizedUuid, notes, nextNotes, state;
|
|
3428
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context18) {
|
|
3429
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
3430
|
+
case 0:
|
|
3431
|
+
tempOrder = this.ensureTempOrder();
|
|
3432
|
+
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
3433
|
+
normalizedUuid = this.normalizeSalesNoteUuid(uuid, 'uuid');
|
|
3434
|
+
notes = tempOrder.notes || [];
|
|
3435
|
+
nextNotes = notes.filter(function (note) {
|
|
3436
|
+
return note.uuid !== normalizedUuid;
|
|
3437
|
+
});
|
|
3438
|
+
if (!(nextNotes.length === notes.length)) {
|
|
3439
|
+
_context18.next = 7;
|
|
3440
|
+
break;
|
|
3441
|
+
}
|
|
3442
|
+
return _context18.abrupt("return");
|
|
3443
|
+
case 7:
|
|
3444
|
+
tempOrder.notes = nextNotes;
|
|
3445
|
+
state = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
3446
|
+
state.dirty = true;
|
|
3447
|
+
this.notifyTempOrderChanged();
|
|
3448
|
+
case 11:
|
|
3449
|
+
case "end":
|
|
3450
|
+
return _context18.stop();
|
|
3451
|
+
}
|
|
3452
|
+
}, _callee16, this);
|
|
3453
|
+
}));
|
|
3454
|
+
function removeSalesNote(_x15) {
|
|
3455
|
+
return _removeSalesNote.apply(this, arguments);
|
|
3456
|
+
}
|
|
3457
|
+
return removeSalesNote;
|
|
3458
|
+
}()
|
|
3459
|
+
}, {
|
|
3460
|
+
key: "clearSalesNotes",
|
|
3461
|
+
value: function () {
|
|
3462
|
+
var _clearSalesNotes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
3463
|
+
var tempOrder, state;
|
|
3464
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context19) {
|
|
3465
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
3466
|
+
case 0:
|
|
3467
|
+
tempOrder = this.ensureTempOrder();
|
|
3468
|
+
tempOrder.notes = [];
|
|
3469
|
+
state = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
3470
|
+
state.loaded = true;
|
|
3471
|
+
state.dirty = true;
|
|
3472
|
+
this.notifyTempOrderChanged();
|
|
3473
|
+
case 6:
|
|
3474
|
+
case "end":
|
|
3475
|
+
return _context19.stop();
|
|
3476
|
+
}
|
|
3477
|
+
}, _callee17, this);
|
|
3478
|
+
}));
|
|
3479
|
+
function clearSalesNotes() {
|
|
3480
|
+
return _clearSalesNotes.apply(this, arguments);
|
|
3481
|
+
}
|
|
3482
|
+
return clearSalesNotes;
|
|
3483
|
+
}()
|
|
3211
3484
|
}, {
|
|
3212
3485
|
key: "updateTempOrderShopDiscount",
|
|
3213
3486
|
value: function updateTempOrderShopDiscount(amount) {
|
|
@@ -3249,6 +3522,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3249
3522
|
this.persistTempOrder();
|
|
3250
3523
|
return tempOrder.buzzer;
|
|
3251
3524
|
}
|
|
3525
|
+
}, {
|
|
3526
|
+
key: "updateTempOrderShopServiceData",
|
|
3527
|
+
value: function updateTempOrderShopServiceData(patch) {
|
|
3528
|
+
var tempOrder = this.ensureTempOrder();
|
|
3529
|
+
var metadata = tempOrder.metadata && _typeof(tempOrder.metadata) === 'object' && !Array.isArray(tempOrder.metadata) ? tempOrder.metadata : {};
|
|
3530
|
+
var currentShopServiceData = metadata.shop_service_data && _typeof(metadata.shop_service_data) === 'object' && !Array.isArray(metadata.shop_service_data) ? metadata.shop_service_data : {};
|
|
3531
|
+
var shopServiceData = _objectSpread(_objectSpread({}, currentShopServiceData), patch);
|
|
3532
|
+
tempOrder.metadata = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
3533
|
+
shop_service_data: shopServiceData
|
|
3534
|
+
});
|
|
3535
|
+
this.persistTempOrder();
|
|
3536
|
+
return shopServiceData;
|
|
3537
|
+
}
|
|
3538
|
+
}, {
|
|
3539
|
+
key: "updateTempOrderPickupReferenceMode",
|
|
3540
|
+
value: function updateTempOrderPickupReferenceMode(mode) {
|
|
3541
|
+
return this.updateTempOrderShopServiceData({
|
|
3542
|
+
pickup_reference_mode: mode
|
|
3543
|
+
});
|
|
3544
|
+
}
|
|
3545
|
+
}, {
|
|
3546
|
+
key: "updateTempOrderServiceType",
|
|
3547
|
+
value: function updateTempOrderServiceType(serviceType) {
|
|
3548
|
+
return this.updateTempOrderShopServiceData({
|
|
3549
|
+
service_type: serviceType
|
|
3550
|
+
});
|
|
3551
|
+
}
|
|
3252
3552
|
}, {
|
|
3253
3553
|
key: "updateTempOrderContactsInfo",
|
|
3254
3554
|
value: function updateTempOrderContactsInfo(contactsInfo) {
|
|
@@ -3290,15 +3590,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3290
3590
|
}, {
|
|
3291
3591
|
key: "productHasCustomerBoundDiscount",
|
|
3292
3592
|
value: function productHasCustomerBoundDiscount(product) {
|
|
3293
|
-
var
|
|
3593
|
+
var _this21 = this;
|
|
3294
3594
|
if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
|
|
3295
|
-
return
|
|
3595
|
+
return _this21.isCustomerBoundDiscount(discount);
|
|
3296
3596
|
})) {
|
|
3297
3597
|
return true;
|
|
3298
3598
|
}
|
|
3299
3599
|
return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
|
|
3300
3600
|
return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
|
|
3301
|
-
return
|
|
3601
|
+
return _this21.isCustomerBoundDiscount(discount);
|
|
3302
3602
|
});
|
|
3303
3603
|
});
|
|
3304
3604
|
}
|
|
@@ -3307,18 +3607,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3307
3607
|
value: function shouldSkipDiscountCalculation(tempOrder) {
|
|
3308
3608
|
var _this$store$discount18,
|
|
3309
3609
|
_this$store$discount19,
|
|
3310
|
-
|
|
3610
|
+
_this22 = this;
|
|
3311
3611
|
if (this.hasActiveCustomerBoundDiscount) return false;
|
|
3312
3612
|
var discountList = ((_this$store$discount18 = this.store.discount) === null || _this$store$discount18 === void 0 || (_this$store$discount19 = _this$store$discount18.getDiscountList) === null || _this$store$discount19 === void 0 ? void 0 : _this$store$discount19.call(_this$store$discount18)) || [];
|
|
3313
3613
|
if (discountList.length > 0) return false;
|
|
3314
3614
|
return !(tempOrder.products || []).some(function (product) {
|
|
3315
|
-
return
|
|
3615
|
+
return _this22.productHasCustomerBoundDiscount(product);
|
|
3316
3616
|
});
|
|
3317
3617
|
}
|
|
3318
3618
|
}, {
|
|
3319
3619
|
key: "clearCustomerBoundDiscounts",
|
|
3320
3620
|
value: function clearCustomerBoundDiscounts(tempOrder) {
|
|
3321
|
-
var
|
|
3621
|
+
var _this23 = this,
|
|
3322
3622
|
_discountModule$getDi,
|
|
3323
3623
|
_discountModule$getOr,
|
|
3324
3624
|
_discountModule$setDi,
|
|
@@ -3327,7 +3627,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3327
3627
|
var filterDiscountList = function filterDiscountList(discountList) {
|
|
3328
3628
|
if (!Array.isArray(discountList)) return [];
|
|
3329
3629
|
return discountList.filter(function (discount) {
|
|
3330
|
-
var shouldRemove =
|
|
3630
|
+
var shouldRemove = _this23.isCustomerBoundDiscount(discount);
|
|
3331
3631
|
if (shouldRemove) didRemoveCustomerBoundDiscount = true;
|
|
3332
3632
|
return !shouldRemove;
|
|
3333
3633
|
});
|
|
@@ -3354,12 +3654,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3354
3654
|
var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
|
|
3355
3655
|
var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
|
|
3356
3656
|
var nextDiscounts = currentDiscounts.filter(function (discount) {
|
|
3357
|
-
if (
|
|
3358
|
-
return !
|
|
3657
|
+
if (_this23.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
3658
|
+
return !_this23.isCustomerBoundDiscount(discount);
|
|
3359
3659
|
});
|
|
3360
3660
|
var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
|
|
3361
|
-
if (
|
|
3362
|
-
return !
|
|
3661
|
+
if (_this23.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
3662
|
+
return !_this23.isCustomerBoundDiscount(discount);
|
|
3363
3663
|
});
|
|
3364
3664
|
void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
|
|
3365
3665
|
void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
|
|
@@ -3520,10 +3820,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3520
3820
|
}, {
|
|
3521
3821
|
key: "setOrderPayments",
|
|
3522
3822
|
value: function setOrderPayments(payments) {
|
|
3523
|
-
var
|
|
3823
|
+
var _this24 = this;
|
|
3524
3824
|
var tempOrder = this.ensureTempOrder();
|
|
3525
3825
|
tempOrder.payments = mapPaymentItemsToOrderPayments((payments || []).map(function (payment) {
|
|
3526
|
-
return
|
|
3826
|
+
return _this24.normalizePaymentSource(payment, {
|
|
3527
3827
|
defaultPaid: false
|
|
3528
3828
|
});
|
|
3529
3829
|
}));
|
|
@@ -3543,34 +3843,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3543
3843
|
}, {
|
|
3544
3844
|
key: "addOrderPaymentAsync",
|
|
3545
3845
|
value: (function () {
|
|
3546
|
-
var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3846
|
+
var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(payment) {
|
|
3547
3847
|
var hasPaymentNumber, devicePrefix;
|
|
3548
|
-
return _regeneratorRuntime().wrap(function
|
|
3549
|
-
while (1) switch (
|
|
3848
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context20) {
|
|
3849
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
3550
3850
|
case 0:
|
|
3551
3851
|
hasPaymentNumber = String(payment.payment_number || '').trim() !== '';
|
|
3552
3852
|
if (!hasPaymentNumber) {
|
|
3553
|
-
|
|
3853
|
+
_context20.next = 5;
|
|
3554
3854
|
break;
|
|
3555
3855
|
}
|
|
3556
|
-
|
|
3557
|
-
|
|
3856
|
+
_context20.t0 = 'LOCAL';
|
|
3857
|
+
_context20.next = 8;
|
|
3558
3858
|
break;
|
|
3559
3859
|
case 5:
|
|
3560
|
-
|
|
3860
|
+
_context20.next = 7;
|
|
3561
3861
|
return this.getPaymentNumberDevicePrefixAsync();
|
|
3562
3862
|
case 7:
|
|
3563
|
-
|
|
3863
|
+
_context20.t0 = _context20.sent;
|
|
3564
3864
|
case 8:
|
|
3565
|
-
devicePrefix =
|
|
3566
|
-
return
|
|
3865
|
+
devicePrefix = _context20.t0;
|
|
3866
|
+
return _context20.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
|
|
3567
3867
|
case 10:
|
|
3568
3868
|
case "end":
|
|
3569
|
-
return
|
|
3869
|
+
return _context20.stop();
|
|
3570
3870
|
}
|
|
3571
|
-
},
|
|
3871
|
+
}, _callee18, this);
|
|
3572
3872
|
}));
|
|
3573
|
-
function addOrderPaymentAsync(
|
|
3873
|
+
function addOrderPaymentAsync(_x16) {
|
|
3574
3874
|
return _addOrderPaymentAsync.apply(this, arguments);
|
|
3575
3875
|
}
|
|
3576
3876
|
return addOrderPaymentAsync;
|
|
@@ -3578,7 +3878,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3578
3878
|
}, {
|
|
3579
3879
|
key: "addOrderPaymentWithDevicePrefix",
|
|
3580
3880
|
value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
|
|
3581
|
-
var
|
|
3881
|
+
var _this25 = this;
|
|
3582
3882
|
this.logInfo('addOrderPayment', {
|
|
3583
3883
|
payment: payment
|
|
3584
3884
|
});
|
|
@@ -3596,7 +3896,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3596
3896
|
void this.recalculateSummary({
|
|
3597
3897
|
createIfMissing: true
|
|
3598
3898
|
}).catch(function (error) {
|
|
3599
|
-
|
|
3899
|
+
_this25.logError('recalculate summary after addOrderPayment failed', {
|
|
3600
3900
|
error: error instanceof Error ? error.message : String(error)
|
|
3601
3901
|
});
|
|
3602
3902
|
});
|
|
@@ -3610,7 +3910,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3610
3910
|
}, {
|
|
3611
3911
|
key: "updateOrderPayment",
|
|
3612
3912
|
value: (function () {
|
|
3613
|
-
var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3913
|
+
var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(paymentIdentity, updates) {
|
|
3614
3914
|
var options,
|
|
3615
3915
|
tempOrder,
|
|
3616
3916
|
identity,
|
|
@@ -3619,17 +3919,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3619
3919
|
updatedPayment,
|
|
3620
3920
|
summary,
|
|
3621
3921
|
payments,
|
|
3622
|
-
|
|
3623
|
-
return _regeneratorRuntime().wrap(function
|
|
3624
|
-
while (1) switch (
|
|
3922
|
+
_args21 = arguments;
|
|
3923
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context21) {
|
|
3924
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
3625
3925
|
case 0:
|
|
3626
|
-
options =
|
|
3926
|
+
options = _args21.length > 2 && _args21[2] !== undefined ? _args21[2] : {};
|
|
3627
3927
|
tempOrder = this.ensureTempOrder();
|
|
3628
3928
|
identity = String(paymentIdentity);
|
|
3629
3929
|
matchMode = options.matchBy === 'compat' || options.matchBy === 'legacy' ? 'compat' : 'payment_number';
|
|
3630
3930
|
matchedPayment = resolveOrderPaymentIdentity(tempOrder.payments || [], identity, matchMode);
|
|
3631
3931
|
if (matchedPayment) {
|
|
3632
|
-
|
|
3932
|
+
_context21.next = 7;
|
|
3633
3933
|
break;
|
|
3634
3934
|
}
|
|
3635
3935
|
throw new Error("\u672A\u627E\u5230\u652F\u4ED8\u9879: ".concat(identity));
|
|
@@ -3644,15 +3944,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3644
3944
|
return nextPayment;
|
|
3645
3945
|
});
|
|
3646
3946
|
this.persistTempOrder();
|
|
3647
|
-
|
|
3947
|
+
_context21.next = 12;
|
|
3648
3948
|
return this.recalculateSummary({
|
|
3649
3949
|
createIfMissing: true
|
|
3650
3950
|
});
|
|
3651
3951
|
case 12:
|
|
3652
|
-
summary =
|
|
3952
|
+
summary = _context21.sent;
|
|
3653
3953
|
this.persistTempOrder();
|
|
3654
3954
|
payments = tempOrder.payments;
|
|
3655
|
-
return
|
|
3955
|
+
return _context21.abrupt("return", {
|
|
3656
3956
|
updated: true,
|
|
3657
3957
|
payment: payments[matchedPayment.index] || updatedPayment,
|
|
3658
3958
|
payments: payments,
|
|
@@ -3660,11 +3960,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3660
3960
|
});
|
|
3661
3961
|
case 16:
|
|
3662
3962
|
case "end":
|
|
3663
|
-
return
|
|
3963
|
+
return _context21.stop();
|
|
3664
3964
|
}
|
|
3665
|
-
},
|
|
3965
|
+
}, _callee19, this);
|
|
3666
3966
|
}));
|
|
3667
|
-
function updateOrderPayment(
|
|
3967
|
+
function updateOrderPayment(_x17, _x18) {
|
|
3668
3968
|
return _updateOrderPayment.apply(this, arguments);
|
|
3669
3969
|
}
|
|
3670
3970
|
return updateOrderPayment;
|
|
@@ -3709,7 +4009,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3709
4009
|
}, {
|
|
3710
4010
|
key: "applyPaymentLifecycleChange",
|
|
3711
4011
|
value: function applyPaymentLifecycleChange(tempOrder, options) {
|
|
3712
|
-
var
|
|
4012
|
+
var _this26 = this;
|
|
3713
4013
|
this.updateTempOrderPaymentStatus(tempOrder);
|
|
3714
4014
|
if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
|
|
3715
4015
|
this.persistTempOrder();
|
|
@@ -3719,7 +4019,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3719
4019
|
void this.recalculateSummary({
|
|
3720
4020
|
createIfMissing: true
|
|
3721
4021
|
}).catch(function (error) {
|
|
3722
|
-
|
|
4022
|
+
_this26.logError("recalculate summary after ".concat(logContext, " failed"), {
|
|
3723
4023
|
error: error instanceof Error ? error.message : String(error)
|
|
3724
4024
|
});
|
|
3725
4025
|
});
|
|
@@ -3763,7 +4063,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3763
4063
|
}, {
|
|
3764
4064
|
key: "updateVoucherOrderPayments",
|
|
3765
4065
|
value: function updateVoucherOrderPayments(payments, options) {
|
|
3766
|
-
var
|
|
4066
|
+
var _this27 = this;
|
|
3767
4067
|
var tempOrder = this.ensureTempOrder();
|
|
3768
4068
|
var isOrderPaymentType = function isOrderPaymentType(value) {
|
|
3769
4069
|
return value === 'normal' || value === 'deposit';
|
|
@@ -3798,7 +4098,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3798
4098
|
});
|
|
3799
4099
|
};
|
|
3800
4100
|
var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
|
|
3801
|
-
return
|
|
4101
|
+
return _this27.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
|
|
3802
4102
|
defaultPaid: false,
|
|
3803
4103
|
devicePrefix: options === null || options === void 0 ? void 0 : options.devicePrefix
|
|
3804
4104
|
});
|
|
@@ -3851,7 +4151,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3851
4151
|
void this.recalculateSummary({
|
|
3852
4152
|
createIfMissing: true
|
|
3853
4153
|
}).catch(function (error) {
|
|
3854
|
-
|
|
4154
|
+
_this27.logError('recalculate summary after updateVoucherOrderPayments failed', {
|
|
3855
4155
|
error: error instanceof Error ? error.message : String(error)
|
|
3856
4156
|
});
|
|
3857
4157
|
});
|
|
@@ -3860,38 +4160,38 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3860
4160
|
}, {
|
|
3861
4161
|
key: "updateVoucherOrderPaymentsAsync",
|
|
3862
4162
|
value: function () {
|
|
3863
|
-
var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4163
|
+
var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(payments, options) {
|
|
3864
4164
|
var needsPaymentNumber, devicePrefix;
|
|
3865
|
-
return _regeneratorRuntime().wrap(function
|
|
3866
|
-
while (1) switch (
|
|
4165
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context22) {
|
|
4166
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
3867
4167
|
case 0:
|
|
3868
4168
|
needsPaymentNumber = (payments || []).some(function (payment) {
|
|
3869
4169
|
return String(payment.payment_number || '').trim() === '';
|
|
3870
4170
|
});
|
|
3871
4171
|
if (!needsPaymentNumber) {
|
|
3872
|
-
|
|
4172
|
+
_context22.next = 7;
|
|
3873
4173
|
break;
|
|
3874
4174
|
}
|
|
3875
|
-
|
|
4175
|
+
_context22.next = 4;
|
|
3876
4176
|
return this.getPaymentNumberDevicePrefixAsync();
|
|
3877
4177
|
case 4:
|
|
3878
|
-
|
|
3879
|
-
|
|
4178
|
+
_context22.t0 = _context22.sent;
|
|
4179
|
+
_context22.next = 8;
|
|
3880
4180
|
break;
|
|
3881
4181
|
case 7:
|
|
3882
|
-
|
|
4182
|
+
_context22.t0 = 'LOCAL';
|
|
3883
4183
|
case 8:
|
|
3884
|
-
devicePrefix =
|
|
3885
|
-
return
|
|
4184
|
+
devicePrefix = _context22.t0;
|
|
4185
|
+
return _context22.abrupt("return", this.updateVoucherOrderPayments(payments, _objectSpread(_objectSpread({}, options), {}, {
|
|
3886
4186
|
devicePrefix: devicePrefix
|
|
3887
4187
|
})));
|
|
3888
4188
|
case 10:
|
|
3889
4189
|
case "end":
|
|
3890
|
-
return
|
|
4190
|
+
return _context22.stop();
|
|
3891
4191
|
}
|
|
3892
|
-
},
|
|
4192
|
+
}, _callee20, this);
|
|
3893
4193
|
}));
|
|
3894
|
-
function updateVoucherOrderPaymentsAsync(
|
|
4194
|
+
function updateVoucherOrderPaymentsAsync(_x19, _x20) {
|
|
3895
4195
|
return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
|
|
3896
4196
|
}
|
|
3897
4197
|
return updateVoucherOrderPaymentsAsync;
|
|
@@ -3909,7 +4209,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3909
4209
|
key: "shouldMergeProductToOrder",
|
|
3910
4210
|
value: function shouldMergeProductToOrder(params) {
|
|
3911
4211
|
var _this$orderHooks,
|
|
3912
|
-
|
|
4212
|
+
_this28 = this;
|
|
3913
4213
|
var onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
|
|
3914
4214
|
if (!onBeforeMergeProductToOrder) return true;
|
|
3915
4215
|
var result = onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
@@ -3917,7 +4217,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3917
4217
|
}));
|
|
3918
4218
|
if (result && _typeof(result) === 'object' && typeof result.then === 'function') {
|
|
3919
4219
|
return Promise.resolve(result).then(function (resolved) {
|
|
3920
|
-
return
|
|
4220
|
+
return _this28.normalizeShouldMergeProductResult(resolved);
|
|
3921
4221
|
});
|
|
3922
4222
|
}
|
|
3923
4223
|
return this.normalizeShouldMergeProductResult(result);
|
|
@@ -3937,8 +4237,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3937
4237
|
}, {
|
|
3938
4238
|
key: "hasLinkedBookingUid",
|
|
3939
4239
|
value: function hasLinkedBookingUid(product) {
|
|
3940
|
-
var _product$booking_uid, _product$
|
|
3941
|
-
var bookingUid = (_product$booking_uid = product === null || product === void 0 ? void 0 : product.booking_uid) !== null && _product$booking_uid !== void 0 ? _product$booking_uid : product === null || product === void 0 || (_product$
|
|
4240
|
+
var _product$booking_uid, _product$metadata9;
|
|
4241
|
+
var bookingUid = (_product$booking_uid = product === null || product === void 0 ? void 0 : product.booking_uid) !== null && _product$booking_uid !== void 0 ? _product$booking_uid : product === null || product === void 0 || (_product$metadata9 = product.metadata) === null || _product$metadata9 === void 0 ? void 0 : _product$metadata9.booking_uid;
|
|
3942
4242
|
return bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '';
|
|
3943
4243
|
}
|
|
3944
4244
|
|
|
@@ -3953,30 +4253,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3953
4253
|
}, {
|
|
3954
4254
|
key: "finalizeProductOrderMutation",
|
|
3955
4255
|
value: function () {
|
|
3956
|
-
var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3957
|
-
return _regeneratorRuntime().wrap(function
|
|
3958
|
-
while (1) switch (
|
|
4256
|
+
var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(tempOrder, options) {
|
|
4257
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context23) {
|
|
4258
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
3959
4259
|
case 0:
|
|
3960
4260
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
3961
4261
|
if (options !== null && options !== void 0 && options.skipEditDiscountConfigRefresh) {
|
|
3962
|
-
|
|
4262
|
+
_context23.next = 4;
|
|
3963
4263
|
break;
|
|
3964
4264
|
}
|
|
3965
|
-
|
|
4265
|
+
_context23.next = 4;
|
|
3966
4266
|
return this.ensureEditDiscountConfigForProductChange(tempOrder);
|
|
3967
4267
|
case 4:
|
|
3968
4268
|
if (options !== null && options !== void 0 && options.skipDiscountRecalculation) {
|
|
3969
|
-
|
|
4269
|
+
_context23.next = 7;
|
|
3970
4270
|
break;
|
|
3971
4271
|
}
|
|
3972
|
-
|
|
4272
|
+
_context23.next = 7;
|
|
3973
4273
|
return this.applyPromotion();
|
|
3974
4274
|
case 7:
|
|
3975
4275
|
if (!(options !== null && options !== void 0 && options.skipDiscountRecalculation)) {
|
|
3976
4276
|
this.applyDiscount();
|
|
3977
4277
|
}
|
|
3978
4278
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
3979
|
-
|
|
4279
|
+
_context23.next = 11;
|
|
3980
4280
|
return this.recalculateSummary({
|
|
3981
4281
|
createIfMissing: true
|
|
3982
4282
|
});
|
|
@@ -3984,11 +4284,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3984
4284
|
this.persistTempOrder();
|
|
3985
4285
|
case 12:
|
|
3986
4286
|
case "end":
|
|
3987
|
-
return
|
|
4287
|
+
return _context23.stop();
|
|
3988
4288
|
}
|
|
3989
|
-
},
|
|
4289
|
+
}, _callee21, this);
|
|
3990
4290
|
}));
|
|
3991
|
-
function finalizeProductOrderMutation(
|
|
4291
|
+
function finalizeProductOrderMutation(_x21, _x22) {
|
|
3992
4292
|
return _finalizeProductOrderMutation.apply(this, arguments);
|
|
3993
4293
|
}
|
|
3994
4294
|
return finalizeProductOrderMutation;
|
|
@@ -4014,7 +4314,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4014
4314
|
_metadata,
|
|
4015
4315
|
_productToAdd$metadat,
|
|
4016
4316
|
_origin,
|
|
4017
|
-
|
|
4317
|
+
_this29 = this;
|
|
4018
4318
|
var linked = booking ? this.createLinkedProductAndBooking({
|
|
4019
4319
|
product: product,
|
|
4020
4320
|
booking: booking
|
|
@@ -4047,8 +4347,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4047
4347
|
var shouldForceNewLine = disableMerge || !!booking || hasIncomingProductNote || hasIncomingManualProductDiscount || hasIncomingBookingUid || isIncomingCustomItem || isWeighingProduct;
|
|
4048
4348
|
var matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
4049
4349
|
var _item$metadata3;
|
|
4050
|
-
if (
|
|
4051
|
-
if (
|
|
4350
|
+
if (_this29.hasGoodPassDiscount(item)) return false;
|
|
4351
|
+
if (_this29.hasOrderProductLineNote(item)) return false;
|
|
4052
4352
|
if (isManualProductDiscountProduct(item)) return false;
|
|
4053
4353
|
if (item.order_detail_id !== undefined && item.order_detail_id !== null) return false;
|
|
4054
4354
|
if ((_item$metadata3 = item.metadata) !== null && _item$metadata3 !== void 0 && _item$metadata3.is_edit_for_runtime) return false;
|
|
@@ -4060,8 +4360,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4060
4360
|
var matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
|
|
4061
4361
|
var existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
|
|
4062
4362
|
var commitProductLine = function commitProductLine(shouldMerge) {
|
|
4363
|
+
var committedProduct;
|
|
4063
4364
|
if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
|
|
4064
|
-
|
|
4365
|
+
_this29.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
|
|
4065
4366
|
if (linked) {
|
|
4066
4367
|
normalizedIncoming.booking_uid = linked.bookingUid;
|
|
4067
4368
|
normalizedIncoming.metadata = _objectSpread(_objectSpread({}, normalizedIncoming.metadata || {}), {}, {
|
|
@@ -4074,6 +4375,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4074
4375
|
} else {
|
|
4075
4376
|
tempOrder.products = [].concat(_toConsumableArray(tempOrder.products), [normalizedIncoming]);
|
|
4076
4377
|
}
|
|
4378
|
+
committedProduct = normalizedIncoming;
|
|
4077
4379
|
} else {
|
|
4078
4380
|
var _targetProduct$metada;
|
|
4079
4381
|
var targetProduct = matchedProduct;
|
|
@@ -4101,7 +4403,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4101
4403
|
order_detail_id: targetProduct.order_detail_id,
|
|
4102
4404
|
num: nextNum
|
|
4103
4405
|
});
|
|
4104
|
-
|
|
4406
|
+
_this29.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
|
|
4407
|
+
committedProduct = tempOrder.products[matchedIndex];
|
|
4105
4408
|
if (matchedIndex !== tempOrder.products.length - 1) {
|
|
4106
4409
|
var mergedProduct = tempOrder.products[matchedIndex];
|
|
4107
4410
|
tempOrder.products = [].concat(_toConsumableArray(tempOrder.products.slice(0, matchedIndex)), _toConsumableArray(tempOrder.products.slice(matchedIndex + 1)), [mergedProduct]);
|
|
@@ -4110,10 +4413,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4110
4413
|
if (linked) {
|
|
4111
4414
|
tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
|
|
4112
4415
|
}
|
|
4416
|
+
return committedProduct;
|
|
4113
4417
|
};
|
|
4114
4418
|
if (!matchedProduct) {
|
|
4115
|
-
commitProductLine(false);
|
|
4116
|
-
return;
|
|
4419
|
+
return commitProductLine(false);
|
|
4117
4420
|
}
|
|
4118
4421
|
var shouldMerge = this.shouldMergeProductToOrder({
|
|
4119
4422
|
incomingProduct: productToAdd,
|
|
@@ -4128,7 +4431,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4128
4431
|
if (shouldMerge && _typeof(shouldMerge) === 'object' && typeof shouldMerge.then === 'function') {
|
|
4129
4432
|
return Promise.resolve(shouldMerge).then(commitProductLine);
|
|
4130
4433
|
}
|
|
4131
|
-
commitProductLine(shouldMerge);
|
|
4434
|
+
return commitProductLine(shouldMerge);
|
|
4132
4435
|
}
|
|
4133
4436
|
|
|
4134
4437
|
/**
|
|
@@ -4141,12 +4444,53 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4141
4444
|
}, {
|
|
4142
4445
|
key: "addProductToOrder",
|
|
4143
4446
|
value: (function () {
|
|
4144
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4145
|
-
var
|
|
4146
|
-
|
|
4147
|
-
|
|
4447
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(product, booking, options) {
|
|
4448
|
+
var _this30 = this;
|
|
4449
|
+
var tempOrder, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex, _ref60, _productRecord$num, productRecord, splitCount, i, singleLine, singleBooking, committedProduct, _committedProduct, _committedProduct2;
|
|
4450
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context24) {
|
|
4451
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
4148
4452
|
case 0:
|
|
4149
4453
|
tempOrder = this.ensureTempOrder();
|
|
4454
|
+
salesNoteDrafts = ((options === null || options === void 0 ? void 0 : options.salesNotes) || []).map(function (draft) {
|
|
4455
|
+
return {
|
|
4456
|
+
note_type: String(draft.note_type || '').trim(),
|
|
4457
|
+
text: {
|
|
4458
|
+
kind: 'resolved',
|
|
4459
|
+
text: buildSalesNoteText(draft.text)
|
|
4460
|
+
}
|
|
4461
|
+
};
|
|
4462
|
+
});
|
|
4463
|
+
mutationSnapshot = salesNoteDrafts.length > 0 ? {
|
|
4464
|
+
products: cloneDeep(tempOrder.products || []),
|
|
4465
|
+
bookings: cloneDeep(tempOrder.bookings || []),
|
|
4466
|
+
notes: cloneDeep(tempOrder.notes || []),
|
|
4467
|
+
extend: cloneDeep(tempOrder._extend || {})
|
|
4468
|
+
} : null;
|
|
4469
|
+
attachSalesNoteDrafts = function attachSalesNoteDrafts(orderProduct) {
|
|
4470
|
+
var _orderProduct$metadat;
|
|
4471
|
+
if (!salesNoteDrafts.length) return;
|
|
4472
|
+
var productLineUid = ((_orderProduct$metadat = orderProduct.metadata) === null || _orderProduct$metadat === void 0 ? void 0 : _orderProduct$metadat.unique_identification_number) || orderProduct.unique_identification_number;
|
|
4473
|
+
if (!productLineUid) {
|
|
4474
|
+
throw new Error('[Order Notes] 商品行缺少 unique_identification_number');
|
|
4475
|
+
}
|
|
4476
|
+
salesNoteDrafts.forEach(function (draft) {
|
|
4477
|
+
_this30.setSalesNoteOnTempOrder(tempOrder, {
|
|
4478
|
+
note_type: draft.note_type,
|
|
4479
|
+
target: {
|
|
4480
|
+
target_type: 'order_detail',
|
|
4481
|
+
target_uuid: String(productLineUid)
|
|
4482
|
+
},
|
|
4483
|
+
text: draft.text
|
|
4484
|
+
});
|
|
4485
|
+
});
|
|
4486
|
+
};
|
|
4487
|
+
rollbackProductAndNotesMutation = function rollbackProductAndNotesMutation() {
|
|
4488
|
+
if (!mutationSnapshot) return;
|
|
4489
|
+
tempOrder.products = mutationSnapshot.products;
|
|
4490
|
+
tempOrder.bookings = mutationSnapshot.bookings;
|
|
4491
|
+
tempOrder.notes = mutationSnapshot.notes;
|
|
4492
|
+
tempOrder._extend = mutationSnapshot.extend;
|
|
4493
|
+
};
|
|
4150
4494
|
insertAfterProductUid = options === null || options === void 0 ? void 0 : options.insertAfterProductUid;
|
|
4151
4495
|
anchorIndex = booking && insertAfterProductUid ? tempOrder.products.findIndex(function (line) {
|
|
4152
4496
|
var _line$metadata;
|
|
@@ -4154,73 +4498,102 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4154
4498
|
return uid !== undefined && uid !== null && String(uid) === String(insertAfterProductUid);
|
|
4155
4499
|
}) : -1;
|
|
4156
4500
|
insertAtIndex = anchorIndex >= 0 ? anchorIndex + 1 : undefined;
|
|
4501
|
+
_context24.prev = 8;
|
|
4157
4502
|
if (!booking) {
|
|
4158
|
-
|
|
4503
|
+
_context24.next = 36;
|
|
4159
4504
|
break;
|
|
4160
4505
|
}
|
|
4161
4506
|
productRecord = product;
|
|
4162
4507
|
splitCount = getSafeProductNum((_ref60 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref60 !== void 0 ? _ref60 : 1);
|
|
4163
4508
|
if (!(splitCount > 1)) {
|
|
4164
|
-
|
|
4509
|
+
_context24.next = 30;
|
|
4165
4510
|
break;
|
|
4166
4511
|
}
|
|
4167
4512
|
i = 0;
|
|
4168
|
-
case
|
|
4513
|
+
case 14:
|
|
4169
4514
|
if (!(i < splitCount)) {
|
|
4170
|
-
|
|
4515
|
+
_context24.next = 28;
|
|
4171
4516
|
break;
|
|
4172
4517
|
}
|
|
4173
4518
|
singleLine = cloneDeep(productRecord);
|
|
4519
|
+
singleBooking = cloneDeep(booking);
|
|
4174
4520
|
singleLine.num = 1;
|
|
4175
4521
|
delete singleLine.product_quantity;
|
|
4176
|
-
|
|
4522
|
+
if (i > 0) {
|
|
4523
|
+
delete singleLine.unique_identification_number;
|
|
4524
|
+
delete singleLine.identity_key;
|
|
4525
|
+
if (singleLine.metadata) {
|
|
4526
|
+
singleLine.metadata = _objectSpread({}, singleLine.metadata);
|
|
4527
|
+
delete singleLine.metadata.unique_identification_number;
|
|
4528
|
+
delete singleLine.metadata.identity_key;
|
|
4529
|
+
}
|
|
4530
|
+
delete singleBooking.booking_uid;
|
|
4531
|
+
if (singleBooking.metadata) {
|
|
4532
|
+
singleBooking.metadata = _objectSpread({}, singleBooking.metadata);
|
|
4533
|
+
delete singleBooking.metadata.unique_identification_number;
|
|
4534
|
+
}
|
|
4535
|
+
}
|
|
4536
|
+
_context24.next = 22;
|
|
4537
|
+
return this.appendProductLineToTempOrder(tempOrder, singleLine, singleBooking, {
|
|
4177
4538
|
insertAtIndex: insertAtIndex,
|
|
4178
4539
|
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge
|
|
4179
4540
|
});
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
}
|
|
4184
|
-
_context21.next = 17;
|
|
4185
|
-
return _appendResult;
|
|
4186
|
-
case 17:
|
|
4541
|
+
case 22:
|
|
4542
|
+
committedProduct = _context24.sent;
|
|
4543
|
+
attachSalesNoteDrafts(committedProduct);
|
|
4187
4544
|
if (insertAtIndex !== undefined) insertAtIndex += 1;
|
|
4188
|
-
case
|
|
4545
|
+
case 25:
|
|
4189
4546
|
i += 1;
|
|
4190
|
-
|
|
4547
|
+
_context24.next = 14;
|
|
4191
4548
|
break;
|
|
4192
|
-
case
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
case
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
appendResult = this.appendProductLineToTempOrder(tempOrder, product, booking, {
|
|
4549
|
+
case 28:
|
|
4550
|
+
_context24.next = 34;
|
|
4551
|
+
break;
|
|
4552
|
+
case 30:
|
|
4553
|
+
_context24.next = 32;
|
|
4554
|
+
return this.appendProductLineToTempOrder(tempOrder, product, cloneDeep(booking), {
|
|
4199
4555
|
insertAtIndex: insertAtIndex,
|
|
4200
4556
|
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge
|
|
4201
4557
|
});
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
case
|
|
4209
|
-
|
|
4558
|
+
case 32:
|
|
4559
|
+
_committedProduct = _context24.sent;
|
|
4560
|
+
attachSalesNoteDrafts(_committedProduct);
|
|
4561
|
+
case 34:
|
|
4562
|
+
_context24.next = 40;
|
|
4563
|
+
break;
|
|
4564
|
+
case 36:
|
|
4565
|
+
_context24.next = 38;
|
|
4566
|
+
return this.appendProductLineToTempOrder(tempOrder, product, undefined, {
|
|
4567
|
+
insertAtIndex: insertAtIndex,
|
|
4568
|
+
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge
|
|
4569
|
+
});
|
|
4570
|
+
case 38:
|
|
4571
|
+
_committedProduct2 = _context24.sent;
|
|
4572
|
+
attachSalesNoteDrafts(_committedProduct2);
|
|
4573
|
+
case 40:
|
|
4574
|
+
_context24.next = 46;
|
|
4575
|
+
break;
|
|
4576
|
+
case 42:
|
|
4577
|
+
_context24.prev = 42;
|
|
4578
|
+
_context24.t0 = _context24["catch"](8);
|
|
4579
|
+
rollbackProductAndNotesMutation();
|
|
4580
|
+
throw _context24.t0;
|
|
4581
|
+
case 46:
|
|
4582
|
+
_context24.next = 48;
|
|
4210
4583
|
return this.finalizeProductOrderMutation(tempOrder);
|
|
4211
|
-
case
|
|
4584
|
+
case 48:
|
|
4212
4585
|
this.logInfo('addProductToOrder success', {
|
|
4213
4586
|
product_id: product.product_id,
|
|
4214
4587
|
with_booking: !!booking
|
|
4215
4588
|
});
|
|
4216
|
-
return
|
|
4217
|
-
case
|
|
4589
|
+
return _context24.abrupt("return", tempOrder.products);
|
|
4590
|
+
case 50:
|
|
4218
4591
|
case "end":
|
|
4219
|
-
return
|
|
4592
|
+
return _context24.stop();
|
|
4220
4593
|
}
|
|
4221
|
-
},
|
|
4594
|
+
}, _callee22, this, [[8, 42]]);
|
|
4222
4595
|
}));
|
|
4223
|
-
function addProductToOrder(
|
|
4596
|
+
function addProductToOrder(_x23, _x24, _x25) {
|
|
4224
4597
|
return _addProductToOrder.apply(this, arguments);
|
|
4225
4598
|
}
|
|
4226
4599
|
return addProductToOrder;
|
|
@@ -4238,103 +4611,103 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4238
4611
|
}, {
|
|
4239
4612
|
key: "addProductsToOrder",
|
|
4240
4613
|
value: (function () {
|
|
4241
|
-
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4242
|
-
var tempOrder, _iterator20, _step20, item, product, booking, _ref61, _productRecord$num2, productRecord, splitCount, i, singleLine,
|
|
4243
|
-
return _regeneratorRuntime().wrap(function
|
|
4244
|
-
while (1) switch (
|
|
4614
|
+
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(items, options) {
|
|
4615
|
+
var tempOrder, _iterator20, _step20, item, product, booking, _ref61, _productRecord$num2, productRecord, splitCount, i, singleLine, _appendResult, appendResult;
|
|
4616
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context25) {
|
|
4617
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
4245
4618
|
case 0:
|
|
4246
4619
|
tempOrder = this.ensureTempOrder();
|
|
4247
4620
|
if (!(!Array.isArray(items) || items.length === 0)) {
|
|
4248
|
-
|
|
4621
|
+
_context25.next = 3;
|
|
4249
4622
|
break;
|
|
4250
4623
|
}
|
|
4251
|
-
return
|
|
4624
|
+
return _context25.abrupt("return", tempOrder.products);
|
|
4252
4625
|
case 3:
|
|
4253
4626
|
_iterator20 = _createForOfIteratorHelper(items || []);
|
|
4254
|
-
|
|
4627
|
+
_context25.prev = 4;
|
|
4255
4628
|
_iterator20.s();
|
|
4256
4629
|
case 6:
|
|
4257
4630
|
if ((_step20 = _iterator20.n()).done) {
|
|
4258
|
-
|
|
4631
|
+
_context25.next = 34;
|
|
4259
4632
|
break;
|
|
4260
4633
|
}
|
|
4261
4634
|
item = _step20.value;
|
|
4262
4635
|
product = item.product, booking = item.booking;
|
|
4263
4636
|
if (product) {
|
|
4264
|
-
|
|
4637
|
+
_context25.next = 11;
|
|
4265
4638
|
break;
|
|
4266
4639
|
}
|
|
4267
|
-
return
|
|
4640
|
+
return _context25.abrupt("continue", 32);
|
|
4268
4641
|
case 11:
|
|
4269
4642
|
if (!booking) {
|
|
4270
|
-
|
|
4643
|
+
_context25.next = 28;
|
|
4271
4644
|
break;
|
|
4272
4645
|
}
|
|
4273
4646
|
productRecord = product;
|
|
4274
4647
|
splitCount = getSafeProductNum((_ref61 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref61 !== void 0 ? _ref61 : 1);
|
|
4275
4648
|
if (!(splitCount > 1)) {
|
|
4276
|
-
|
|
4649
|
+
_context25.next = 28;
|
|
4277
4650
|
break;
|
|
4278
4651
|
}
|
|
4279
4652
|
i = 0;
|
|
4280
4653
|
case 16:
|
|
4281
4654
|
if (!(i < splitCount)) {
|
|
4282
|
-
|
|
4655
|
+
_context25.next = 27;
|
|
4283
4656
|
break;
|
|
4284
4657
|
}
|
|
4285
4658
|
singleLine = cloneDeep(productRecord);
|
|
4286
4659
|
singleLine.num = 1;
|
|
4287
4660
|
delete singleLine.product_quantity;
|
|
4288
|
-
|
|
4289
|
-
if (!
|
|
4290
|
-
|
|
4661
|
+
_appendResult = this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
|
|
4662
|
+
if (!_appendResult) {
|
|
4663
|
+
_context25.next = 24;
|
|
4291
4664
|
break;
|
|
4292
4665
|
}
|
|
4293
|
-
|
|
4294
|
-
return
|
|
4666
|
+
_context25.next = 24;
|
|
4667
|
+
return _appendResult;
|
|
4295
4668
|
case 24:
|
|
4296
4669
|
i += 1;
|
|
4297
|
-
|
|
4670
|
+
_context25.next = 16;
|
|
4298
4671
|
break;
|
|
4299
4672
|
case 27:
|
|
4300
|
-
return
|
|
4673
|
+
return _context25.abrupt("continue", 32);
|
|
4301
4674
|
case 28:
|
|
4302
4675
|
appendResult = this.appendProductLineToTempOrder(tempOrder, product, booking);
|
|
4303
4676
|
if (!appendResult) {
|
|
4304
|
-
|
|
4677
|
+
_context25.next = 32;
|
|
4305
4678
|
break;
|
|
4306
4679
|
}
|
|
4307
|
-
|
|
4680
|
+
_context25.next = 32;
|
|
4308
4681
|
return appendResult;
|
|
4309
4682
|
case 32:
|
|
4310
|
-
|
|
4683
|
+
_context25.next = 6;
|
|
4311
4684
|
break;
|
|
4312
4685
|
case 34:
|
|
4313
|
-
|
|
4686
|
+
_context25.next = 39;
|
|
4314
4687
|
break;
|
|
4315
4688
|
case 36:
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
_iterator20.e(
|
|
4689
|
+
_context25.prev = 36;
|
|
4690
|
+
_context25.t0 = _context25["catch"](4);
|
|
4691
|
+
_iterator20.e(_context25.t0);
|
|
4319
4692
|
case 39:
|
|
4320
|
-
|
|
4693
|
+
_context25.prev = 39;
|
|
4321
4694
|
_iterator20.f();
|
|
4322
|
-
return
|
|
4695
|
+
return _context25.finish(39);
|
|
4323
4696
|
case 42:
|
|
4324
|
-
|
|
4697
|
+
_context25.next = 44;
|
|
4325
4698
|
return this.finalizeProductOrderMutation(tempOrder, options);
|
|
4326
4699
|
case 44:
|
|
4327
4700
|
this.logInfo('addProductsToOrder success', {
|
|
4328
4701
|
itemsCount: items.length
|
|
4329
4702
|
});
|
|
4330
|
-
return
|
|
4703
|
+
return _context25.abrupt("return", tempOrder.products);
|
|
4331
4704
|
case 46:
|
|
4332
4705
|
case "end":
|
|
4333
|
-
return
|
|
4706
|
+
return _context25.stop();
|
|
4334
4707
|
}
|
|
4335
|
-
},
|
|
4708
|
+
}, _callee23, this, [[4, 36, 39, 42]]);
|
|
4336
4709
|
}));
|
|
4337
|
-
function addProductsToOrder(
|
|
4710
|
+
function addProductsToOrder(_x26, _x27) {
|
|
4338
4711
|
return _addProductsToOrder.apply(this, arguments);
|
|
4339
4712
|
}
|
|
4340
4713
|
return addProductsToOrder;
|
|
@@ -4368,17 +4741,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4368
4741
|
}, {
|
|
4369
4742
|
key: "preservePersistedBundlePriceFields",
|
|
4370
4743
|
value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
|
|
4371
|
-
var
|
|
4744
|
+
var _this31 = this;
|
|
4372
4745
|
if (!Array.isArray(nextBundles)) return nextBundles;
|
|
4373
4746
|
if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
|
|
4374
4747
|
var previousByIdentity = new Map();
|
|
4375
4748
|
previousBundles.forEach(function (bundle) {
|
|
4376
|
-
var identity =
|
|
4749
|
+
var identity = _this31.getBundleRuntimeIdentity(bundle);
|
|
4377
4750
|
if (identity) previousByIdentity.set(identity, bundle);
|
|
4378
4751
|
});
|
|
4379
4752
|
return nextBundles.map(function (bundle, index) {
|
|
4380
4753
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
4381
|
-
var previous = previousByIdentity.get(
|
|
4754
|
+
var previous = previousByIdentity.get(_this31.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
|
|
4382
4755
|
if (!previous || _typeof(previous) !== 'object') return bundle;
|
|
4383
4756
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
|
|
4384
4757
|
cover: previous.cover
|
|
@@ -4579,21 +4952,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4579
4952
|
}, {
|
|
4580
4953
|
key: "updateOrderProduct",
|
|
4581
4954
|
value: function () {
|
|
4582
|
-
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4955
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
|
|
4583
4956
|
var tempOrder, updatedProductUid;
|
|
4584
|
-
return _regeneratorRuntime().wrap(function
|
|
4585
|
-
while (1) switch (
|
|
4957
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context26) {
|
|
4958
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
4586
4959
|
case 0:
|
|
4587
4960
|
tempOrder = this.ensureTempOrder();
|
|
4588
4961
|
updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
4589
|
-
|
|
4962
|
+
_context26.next = 4;
|
|
4590
4963
|
return this.applyPromotion();
|
|
4591
4964
|
case 4:
|
|
4592
4965
|
this.applyDiscount({
|
|
4593
4966
|
reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
|
|
4594
4967
|
});
|
|
4595
4968
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4596
|
-
|
|
4969
|
+
_context26.next = 8;
|
|
4597
4970
|
return this.recalculateSummary({
|
|
4598
4971
|
createIfMissing: true
|
|
4599
4972
|
});
|
|
@@ -4602,14 +4975,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4602
4975
|
this.logInfo('updateOrderProduct success', {
|
|
4603
4976
|
params: params
|
|
4604
4977
|
});
|
|
4605
|
-
return
|
|
4978
|
+
return _context26.abrupt("return", tempOrder.products);
|
|
4606
4979
|
case 11:
|
|
4607
4980
|
case "end":
|
|
4608
|
-
return
|
|
4981
|
+
return _context26.stop();
|
|
4609
4982
|
}
|
|
4610
|
-
},
|
|
4983
|
+
}, _callee24, this);
|
|
4611
4984
|
}));
|
|
4612
|
-
function updateOrderProduct(
|
|
4985
|
+
function updateOrderProduct(_x28) {
|
|
4613
4986
|
return _updateOrderProduct.apply(this, arguments);
|
|
4614
4987
|
}
|
|
4615
4988
|
return updateOrderProduct;
|
|
@@ -4617,28 +4990,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4617
4990
|
}, {
|
|
4618
4991
|
key: "updateOrderProducts",
|
|
4619
4992
|
value: function () {
|
|
4620
|
-
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4621
|
-
var
|
|
4993
|
+
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(paramsList) {
|
|
4994
|
+
var _this32 = this;
|
|
4622
4995
|
var tempOrder, reapplyBookingDiscountProductUids;
|
|
4623
|
-
return _regeneratorRuntime().wrap(function
|
|
4624
|
-
while (1) switch (
|
|
4996
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context27) {
|
|
4997
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
4625
4998
|
case 0:
|
|
4626
4999
|
tempOrder = this.ensureTempOrder();
|
|
4627
5000
|
if (paramsList.length) {
|
|
4628
|
-
|
|
5001
|
+
_context27.next = 3;
|
|
4629
5002
|
break;
|
|
4630
5003
|
}
|
|
4631
|
-
return
|
|
5004
|
+
return _context27.abrupt("return", tempOrder.products);
|
|
4632
5005
|
case 3:
|
|
4633
5006
|
reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
|
|
4634
|
-
var updatedProductUid =
|
|
5007
|
+
var updatedProductUid = _this32.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
4635
5008
|
// 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
|
|
4636
5009
|
if (params.allow_booking_discount_reapply && updatedProductUid) {
|
|
4637
5010
|
acc.push(String(updatedProductUid));
|
|
4638
5011
|
}
|
|
4639
5012
|
return acc;
|
|
4640
5013
|
}, []);
|
|
4641
|
-
|
|
5014
|
+
_context27.next = 6;
|
|
4642
5015
|
return this.finalizeAfterProductsMutation(tempOrder, {
|
|
4643
5016
|
reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
|
|
4644
5017
|
});
|
|
@@ -4646,14 +5019,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4646
5019
|
this.logInfo('updateOrderProduct success', {
|
|
4647
5020
|
paramsList: paramsList
|
|
4648
5021
|
});
|
|
4649
|
-
return
|
|
5022
|
+
return _context27.abrupt("return", tempOrder.products);
|
|
4650
5023
|
case 8:
|
|
4651
5024
|
case "end":
|
|
4652
|
-
return
|
|
5025
|
+
return _context27.stop();
|
|
4653
5026
|
}
|
|
4654
|
-
},
|
|
5027
|
+
}, _callee25, this);
|
|
4655
5028
|
}));
|
|
4656
|
-
function updateOrderProducts(
|
|
5029
|
+
function updateOrderProducts(_x29) {
|
|
4657
5030
|
return _updateOrderProducts.apply(this, arguments);
|
|
4658
5031
|
}
|
|
4659
5032
|
return updateOrderProducts;
|
|
@@ -4661,11 +5034,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4661
5034
|
}, {
|
|
4662
5035
|
key: "updateOrderProductQuantity",
|
|
4663
5036
|
value: function () {
|
|
4664
|
-
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5037
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
|
|
4665
5038
|
var _targetProduct$metada17;
|
|
4666
5039
|
var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct;
|
|
4667
|
-
return _regeneratorRuntime().wrap(function
|
|
4668
|
-
while (1) switch (
|
|
5040
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context28) {
|
|
5041
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
4669
5042
|
case 0:
|
|
4670
5043
|
product_id = params.product_id, product_variant_id = params.product_variant_id, num = params.num, unique_identification_number = params.unique_identification_number, identity_key = params.identity_key, product_sku = params.product_sku, product_bundle = params.product_bundle;
|
|
4671
5044
|
tempOrder = this.ensureTempOrder();
|
|
@@ -4695,7 +5068,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4695
5068
|
productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
|
|
4696
5069
|
}
|
|
4697
5070
|
if (!(productIndex === -1)) {
|
|
4698
|
-
|
|
5071
|
+
_context28.next = 13;
|
|
4699
5072
|
break;
|
|
4700
5073
|
}
|
|
4701
5074
|
throw new Error('[Order] 目标商品不存在,无法更新数量');
|
|
@@ -4709,12 +5082,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4709
5082
|
}));
|
|
4710
5083
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
4711
5084
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
4712
|
-
|
|
5085
|
+
_context28.next = 19;
|
|
4713
5086
|
return this.applyPromotion();
|
|
4714
5087
|
case 19:
|
|
4715
5088
|
this.applyDiscount();
|
|
4716
5089
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4717
|
-
|
|
5090
|
+
_context28.next = 23;
|
|
4718
5091
|
return this.recalculateSummary({
|
|
4719
5092
|
createIfMissing: true
|
|
4720
5093
|
});
|
|
@@ -4723,14 +5096,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4723
5096
|
this.logInfo('updateOrderProductQuantity success', {
|
|
4724
5097
|
params: params
|
|
4725
5098
|
});
|
|
4726
|
-
return
|
|
5099
|
+
return _context28.abrupt("return", tempOrder.products);
|
|
4727
5100
|
case 26:
|
|
4728
5101
|
case "end":
|
|
4729
|
-
return
|
|
5102
|
+
return _context28.stop();
|
|
4730
5103
|
}
|
|
4731
|
-
},
|
|
5104
|
+
}, _callee26, this);
|
|
4732
5105
|
}));
|
|
4733
|
-
function updateOrderProductQuantity(
|
|
5106
|
+
function updateOrderProductQuantity(_x30) {
|
|
4734
5107
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
4735
5108
|
}
|
|
4736
5109
|
return updateOrderProductQuantity;
|
|
@@ -4771,19 +5144,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4771
5144
|
}, {
|
|
4772
5145
|
key: "finalizeAfterProductsMutation",
|
|
4773
5146
|
value: (function () {
|
|
4774
|
-
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4775
|
-
return _regeneratorRuntime().wrap(function
|
|
4776
|
-
while (1) switch (
|
|
5147
|
+
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(tempOrder, options) {
|
|
5148
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context29) {
|
|
5149
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
4777
5150
|
case 0:
|
|
4778
5151
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
4779
|
-
|
|
5152
|
+
_context29.next = 3;
|
|
4780
5153
|
return this.applyPromotion();
|
|
4781
5154
|
case 3:
|
|
4782
5155
|
this.applyDiscount({
|
|
4783
5156
|
reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids
|
|
4784
5157
|
});
|
|
4785
5158
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4786
|
-
|
|
5159
|
+
_context29.next = 7;
|
|
4787
5160
|
return this.recalculateSummary({
|
|
4788
5161
|
createIfMissing: true
|
|
4789
5162
|
});
|
|
@@ -4791,11 +5164,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4791
5164
|
this.persistTempOrder();
|
|
4792
5165
|
case 8:
|
|
4793
5166
|
case "end":
|
|
4794
|
-
return
|
|
5167
|
+
return _context29.stop();
|
|
4795
5168
|
}
|
|
4796
|
-
},
|
|
5169
|
+
}, _callee27, this);
|
|
4797
5170
|
}));
|
|
4798
|
-
function finalizeAfterProductsMutation(
|
|
5171
|
+
function finalizeAfterProductsMutation(_x31, _x32) {
|
|
4799
5172
|
return _finalizeAfterProductsMutation.apply(this, arguments);
|
|
4800
5173
|
}
|
|
4801
5174
|
return finalizeAfterProductsMutation;
|
|
@@ -4810,20 +5183,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4810
5183
|
}, {
|
|
4811
5184
|
key: "removeProductsFromOrder",
|
|
4812
5185
|
value: (function () {
|
|
4813
|
-
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4814
|
-
var
|
|
5186
|
+
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(identities, options) {
|
|
5187
|
+
var _this33 = this;
|
|
4815
5188
|
var tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
|
|
4816
|
-
return _regeneratorRuntime().wrap(function
|
|
4817
|
-
while (1) switch (
|
|
5189
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context31) {
|
|
5190
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
4818
5191
|
case 0:
|
|
4819
5192
|
tempOrder = this.ensureTempOrder();
|
|
4820
|
-
this.repairDuplicateProductLineIdentities(tempOrder);
|
|
4821
5193
|
if (identities.length) {
|
|
4822
|
-
|
|
5194
|
+
_context31.next = 3;
|
|
4823
5195
|
break;
|
|
4824
5196
|
}
|
|
4825
|
-
return
|
|
4826
|
-
case
|
|
5197
|
+
return _context31.abrupt("return", tempOrder.products);
|
|
5198
|
+
case 3:
|
|
5199
|
+
// 商品删除会同步删除以商品行为主关系的 Notes;快照不完整时禁止产生孤儿 Relation。
|
|
5200
|
+
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
5201
|
+
this.repairDuplicateProductLineIdentities(tempOrder);
|
|
4827
5202
|
productsBeforeRemove = tempOrder.products || [];
|
|
4828
5203
|
bookingsBeforeRemove = tempOrder.bookings || [];
|
|
4829
5204
|
preserveDisplayPosition = options === null || options === void 0 ? void 0 : options.preserveDisplayPosition;
|
|
@@ -4852,29 +5227,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4852
5227
|
}
|
|
4853
5228
|
linkedBookingUidsToRemove = new Set();
|
|
4854
5229
|
_iterator21 = _createForOfIteratorHelper(matchedProducts);
|
|
4855
|
-
|
|
5230
|
+
_context31.prev = 16;
|
|
4856
5231
|
_loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
|
|
4857
5232
|
var _metadata11, _metadata12, _metadata13, _metadata14;
|
|
4858
5233
|
var product, productUid, productBookingUid, isAddTimeProduct;
|
|
4859
|
-
return _regeneratorRuntime().wrap(function _loop3$(
|
|
4860
|
-
while (1) switch (
|
|
5234
|
+
return _regeneratorRuntime().wrap(function _loop3$(_context30) {
|
|
5235
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
4861
5236
|
case 0:
|
|
4862
5237
|
product = _step21.value;
|
|
4863
5238
|
productUid = (product === null || product === void 0 || (_metadata11 = product.metadata) === null || _metadata11 === void 0 ? void 0 : _metadata11.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
4864
5239
|
productBookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_metadata12 = product.metadata) === null || _metadata12 === void 0 ? void 0 : _metadata12.booking_uid);
|
|
4865
5240
|
isAddTimeProduct = (product === null || product === void 0 || (_metadata13 = product.metadata) === null || _metadata13 === void 0 ? void 0 : _metadata13.product_add_schedule_time) !== undefined && (product === null || product === void 0 || (_metadata14 = product.metadata) === null || _metadata14 === void 0 ? void 0 : _metadata14.product_add_schedule_time) !== null;
|
|
4866
5241
|
if (!isAddTimeProduct) {
|
|
4867
|
-
|
|
5242
|
+
_context30.next = 6;
|
|
4868
5243
|
break;
|
|
4869
5244
|
}
|
|
4870
|
-
return
|
|
5245
|
+
return _context30.abrupt("return", 1);
|
|
4871
5246
|
case 6:
|
|
4872
5247
|
if (productBookingUid !== undefined && productBookingUid !== null && productBookingUid !== '') {
|
|
4873
5248
|
linkedBookingUidsToRemove.add(String(productBookingUid));
|
|
4874
5249
|
}
|
|
4875
5250
|
if (productUid !== undefined && productUid !== null && productUid !== '') {
|
|
4876
5251
|
bookingsBeforeRemove.forEach(function (booking) {
|
|
4877
|
-
var bookingUid =
|
|
5252
|
+
var bookingUid = _this33.getBookingUniqueIdentificationNumber(booking);
|
|
4878
5253
|
if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
|
|
4879
5254
|
linkedBookingUidsToRemove.add(bookingUid);
|
|
4880
5255
|
}
|
|
@@ -4882,38 +5257,38 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4882
5257
|
}
|
|
4883
5258
|
case 8:
|
|
4884
5259
|
case "end":
|
|
4885
|
-
return
|
|
5260
|
+
return _context30.stop();
|
|
4886
5261
|
}
|
|
4887
5262
|
}, _loop3);
|
|
4888
5263
|
});
|
|
4889
5264
|
_iterator21.s();
|
|
4890
|
-
case
|
|
5265
|
+
case 19:
|
|
4891
5266
|
if ((_step21 = _iterator21.n()).done) {
|
|
4892
|
-
|
|
5267
|
+
_context31.next = 25;
|
|
4893
5268
|
break;
|
|
4894
5269
|
}
|
|
4895
|
-
return
|
|
4896
|
-
case
|
|
4897
|
-
if (!
|
|
4898
|
-
|
|
5270
|
+
return _context31.delegateYield(_loop3(), "t0", 21);
|
|
5271
|
+
case 21:
|
|
5272
|
+
if (!_context31.t0) {
|
|
5273
|
+
_context31.next = 23;
|
|
4899
5274
|
break;
|
|
4900
5275
|
}
|
|
4901
|
-
return
|
|
4902
|
-
case
|
|
4903
|
-
|
|
5276
|
+
return _context31.abrupt("continue", 23);
|
|
5277
|
+
case 23:
|
|
5278
|
+
_context31.next = 19;
|
|
4904
5279
|
break;
|
|
4905
|
-
case
|
|
4906
|
-
|
|
5280
|
+
case 25:
|
|
5281
|
+
_context31.next = 30;
|
|
4907
5282
|
break;
|
|
4908
|
-
case
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
_iterator21.e(
|
|
4912
|
-
case
|
|
4913
|
-
|
|
5283
|
+
case 27:
|
|
5284
|
+
_context31.prev = 27;
|
|
5285
|
+
_context31.t1 = _context31["catch"](16);
|
|
5286
|
+
_iterator21.e(_context31.t1);
|
|
5287
|
+
case 30:
|
|
5288
|
+
_context31.prev = 30;
|
|
4914
5289
|
_iterator21.f();
|
|
4915
|
-
return
|
|
4916
|
-
case
|
|
5290
|
+
return _context31.finish(30);
|
|
5291
|
+
case 33:
|
|
4917
5292
|
if (linkedBookingUidsToRemove.size > 0) {
|
|
4918
5293
|
// 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
|
|
4919
5294
|
tempOrder.products = (tempOrder.products || []).filter(function (line) {
|
|
@@ -4939,20 +5314,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4939
5314
|
tempOrder.products = nextProductIndex >= 0 ? [].concat(_toConsumableArray(productsWithoutRemaining.slice(0, nextProductIndex)), [remainingProduct], _toConsumableArray(productsWithoutRemaining.slice(nextProductIndex))) : [].concat(_toConsumableArray(productsWithoutRemaining), [remainingProduct]);
|
|
4940
5315
|
}
|
|
4941
5316
|
}
|
|
4942
|
-
|
|
5317
|
+
this.removeSalesNotesForMissingProductLines(tempOrder);
|
|
5318
|
+
_context31.next = 38;
|
|
4943
5319
|
return this.finalizeAfterProductsMutation(tempOrder);
|
|
4944
|
-
case
|
|
5320
|
+
case 38:
|
|
4945
5321
|
this.logInfo('removeProductsFromOrder success', {
|
|
4946
5322
|
identities: identities
|
|
4947
5323
|
});
|
|
4948
|
-
return
|
|
4949
|
-
case
|
|
5324
|
+
return _context31.abrupt("return", tempOrder.products);
|
|
5325
|
+
case 40:
|
|
4950
5326
|
case "end":
|
|
4951
|
-
return
|
|
5327
|
+
return _context31.stop();
|
|
4952
5328
|
}
|
|
4953
|
-
},
|
|
5329
|
+
}, _callee28, this, [[16, 27, 30, 33]]);
|
|
4954
5330
|
}));
|
|
4955
|
-
function removeProductsFromOrder(
|
|
5331
|
+
function removeProductsFromOrder(_x33, _x34) {
|
|
4956
5332
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
4957
5333
|
}
|
|
4958
5334
|
return removeProductsFromOrder;
|
|
@@ -4960,61 +5336,63 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4960
5336
|
}, {
|
|
4961
5337
|
key: "removeProductFromOrder",
|
|
4962
5338
|
value: function () {
|
|
4963
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4964
|
-
return _regeneratorRuntime().wrap(function
|
|
4965
|
-
while (1) switch (
|
|
5339
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(identity, options) {
|
|
5340
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context32) {
|
|
5341
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
4966
5342
|
case 0:
|
|
4967
|
-
return
|
|
5343
|
+
return _context32.abrupt("return", this.removeProductsFromOrder([identity], options));
|
|
4968
5344
|
case 1:
|
|
4969
5345
|
case "end":
|
|
4970
|
-
return
|
|
5346
|
+
return _context32.stop();
|
|
4971
5347
|
}
|
|
4972
|
-
},
|
|
5348
|
+
}, _callee29, this);
|
|
4973
5349
|
}));
|
|
4974
|
-
function removeProductFromOrder(
|
|
5350
|
+
function removeProductFromOrder(_x35, _x36) {
|
|
4975
5351
|
return _removeProductFromOrder.apply(this, arguments);
|
|
4976
5352
|
}
|
|
4977
5353
|
return removeProductFromOrder;
|
|
4978
5354
|
}()
|
|
4979
5355
|
/**
|
|
4980
5356
|
* 仅清空购物车行(products / bookings),不重置整单。
|
|
4981
|
-
*
|
|
5357
|
+
* 普通整单 note 保持不变;以商品行为主体的 Sales Notes 同步删除。
|
|
4982
5358
|
*/
|
|
4983
5359
|
}, {
|
|
4984
5360
|
key: "clearOrderCartLines",
|
|
4985
5361
|
value: (function () {
|
|
4986
|
-
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5362
|
+
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
|
|
4987
5363
|
var tempOrder;
|
|
4988
|
-
return _regeneratorRuntime().wrap(function
|
|
4989
|
-
while (1) switch (
|
|
5364
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context33) {
|
|
5365
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
4990
5366
|
case 0:
|
|
4991
5367
|
tempOrder = this.ensureTempOrder();
|
|
5368
|
+
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
4992
5369
|
tempOrder.products = [];
|
|
4993
5370
|
tempOrder.bookings = [];
|
|
5371
|
+
this.removeSalesNotesForMissingProductLines(tempOrder);
|
|
4994
5372
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
4995
5373
|
if (tempOrder._extend && _typeof(tempOrder._extend) === 'object') {
|
|
4996
5374
|
tempOrder._extend = _objectSpread(_objectSpread({}, tempOrder._extend), {}, {
|
|
4997
5375
|
productsByUid: {}
|
|
4998
5376
|
});
|
|
4999
5377
|
}
|
|
5000
|
-
|
|
5378
|
+
_context33.next = 9;
|
|
5001
5379
|
return this.applyPromotion();
|
|
5002
|
-
case
|
|
5380
|
+
case 9:
|
|
5003
5381
|
this.applyDiscount();
|
|
5004
5382
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
5005
|
-
|
|
5383
|
+
_context33.next = 13;
|
|
5006
5384
|
return this.recalculateSummary({
|
|
5007
5385
|
createIfMissing: true
|
|
5008
5386
|
});
|
|
5009
|
-
case
|
|
5387
|
+
case 13:
|
|
5010
5388
|
this.persistTempOrder();
|
|
5011
5389
|
this.logInfo('clearOrderCartLines success', {});
|
|
5012
|
-
return
|
|
5013
|
-
case
|
|
5390
|
+
return _context33.abrupt("return", tempOrder);
|
|
5391
|
+
case 16:
|
|
5014
5392
|
case "end":
|
|
5015
|
-
return
|
|
5393
|
+
return _context33.stop();
|
|
5016
5394
|
}
|
|
5017
|
-
},
|
|
5395
|
+
}, _callee30, this);
|
|
5018
5396
|
}));
|
|
5019
5397
|
function clearOrderCartLines() {
|
|
5020
5398
|
return _clearOrderCartLines.apply(this, arguments);
|
|
@@ -5037,10 +5415,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5037
5415
|
type: params === null || params === void 0 ? void 0 : params.type,
|
|
5038
5416
|
summary: this.store.summary || createEmptySummary(),
|
|
5039
5417
|
enhance: function enhance(nextPayload) {
|
|
5040
|
-
var _ref70, _tempOrder$order_numb, _ref71, _tempOrder$
|
|
5418
|
+
var _ref70, _tempOrder$order_numb, _ref71, _tempOrder$shop_order2, _ref72, _tempOrder$shop_full_;
|
|
5041
5419
|
return _objectSpread(_objectSpread({}, nextPayload), {}, {
|
|
5042
5420
|
order_number: (_ref70 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref70 !== void 0 ? _ref70 : null,
|
|
5043
|
-
shop_order_number: (_ref71 = (_tempOrder$
|
|
5421
|
+
shop_order_number: (_ref71 = (_tempOrder$shop_order2 = tempOrder.shop_order_number) !== null && _tempOrder$shop_order2 !== void 0 ? _tempOrder$shop_order2 : nextPayload.shop_order_number) !== null && _ref71 !== void 0 ? _ref71 : null,
|
|
5044
5422
|
shop_full_order_number: (_ref72 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref72 !== void 0 ? _ref72 : null,
|
|
5045
5423
|
small_ticket_data_flag: 1
|
|
5046
5424
|
});
|
|
@@ -5052,17 +5430,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5052
5430
|
}, {
|
|
5053
5431
|
key: "applyLocalPrintOrderNumbers",
|
|
5054
5432
|
value: function () {
|
|
5055
|
-
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5433
|
+
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(order) {
|
|
5056
5434
|
var tempOrder, shopOrderNumber, shopFullOrderNumber;
|
|
5057
|
-
return _regeneratorRuntime().wrap(function
|
|
5058
|
-
while (1) switch (
|
|
5435
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context34) {
|
|
5436
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
5059
5437
|
case 0:
|
|
5060
5438
|
tempOrder = this.ensureTempOrder();
|
|
5061
5439
|
if (!(!order || _typeof(order) !== 'object')) {
|
|
5062
|
-
|
|
5440
|
+
_context34.next = 3;
|
|
5063
5441
|
break;
|
|
5064
5442
|
}
|
|
5065
|
-
return
|
|
5443
|
+
return _context34.abrupt("return", tempOrder);
|
|
5066
5444
|
case 3:
|
|
5067
5445
|
shopOrderNumber = order.shop_order_number;
|
|
5068
5446
|
shopFullOrderNumber = order.shop_full_order_number;
|
|
@@ -5073,17 +5451,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5073
5451
|
tempOrder.shop_full_order_number = String(shopFullOrderNumber);
|
|
5074
5452
|
}
|
|
5075
5453
|
this.persistTempOrder();
|
|
5076
|
-
|
|
5454
|
+
_context34.next = 10;
|
|
5077
5455
|
return this.saveDraft();
|
|
5078
5456
|
case 10:
|
|
5079
|
-
return
|
|
5457
|
+
return _context34.abrupt("return", tempOrder);
|
|
5080
5458
|
case 11:
|
|
5081
5459
|
case "end":
|
|
5082
|
-
return
|
|
5460
|
+
return _context34.stop();
|
|
5083
5461
|
}
|
|
5084
|
-
},
|
|
5462
|
+
}, _callee31, this);
|
|
5085
5463
|
}));
|
|
5086
|
-
function applyLocalPrintOrderNumbers(
|
|
5464
|
+
function applyLocalPrintOrderNumbers(_x37) {
|
|
5087
5465
|
return _applyLocalPrintOrderNumbers.apply(this, arguments);
|
|
5088
5466
|
}
|
|
5089
5467
|
return applyLocalPrintOrderNumbers;
|
|
@@ -5091,35 +5469,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5091
5469
|
}, {
|
|
5092
5470
|
key: "saveTempOrderAsDraft",
|
|
5093
5471
|
value: function () {
|
|
5094
|
-
var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5472
|
+
var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
|
|
5095
5473
|
var _params$cacheId2, _this$otherParams6, _this$otherParams7, _this$otherParams8, _params$type, _this$otherParams9, _payload$products;
|
|
5096
5474
|
var tempOrder, latestSummary, payload;
|
|
5097
|
-
return _regeneratorRuntime().wrap(function
|
|
5098
|
-
while (1) switch (
|
|
5475
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context35) {
|
|
5476
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
5099
5477
|
case 0:
|
|
5100
5478
|
tempOrder = this.ensureTempOrder();
|
|
5101
5479
|
this.ensureExternalSaleNumber(tempOrder);
|
|
5102
5480
|
this.persistTempOrder();
|
|
5103
|
-
|
|
5481
|
+
_context35.next = 5;
|
|
5104
5482
|
return this.recalculateSummary({
|
|
5105
5483
|
createIfMissing: true
|
|
5106
5484
|
});
|
|
5107
5485
|
case 5:
|
|
5108
|
-
|
|
5109
|
-
if (
|
|
5110
|
-
|
|
5486
|
+
_context35.t1 = _context35.sent;
|
|
5487
|
+
if (_context35.t1) {
|
|
5488
|
+
_context35.next = 8;
|
|
5111
5489
|
break;
|
|
5112
5490
|
}
|
|
5113
|
-
|
|
5491
|
+
_context35.t1 = this.store.summary;
|
|
5114
5492
|
case 8:
|
|
5115
|
-
|
|
5116
|
-
if (
|
|
5117
|
-
|
|
5493
|
+
_context35.t0 = _context35.t1;
|
|
5494
|
+
if (_context35.t0) {
|
|
5495
|
+
_context35.next = 11;
|
|
5118
5496
|
break;
|
|
5119
5497
|
}
|
|
5120
|
-
|
|
5498
|
+
_context35.t0 = createEmptySummary();
|
|
5121
5499
|
case 11:
|
|
5122
|
-
latestSummary =
|
|
5500
|
+
latestSummary = _context35.t0;
|
|
5123
5501
|
payload = buildSubmitPayload({
|
|
5124
5502
|
tempOrder: tempOrder,
|
|
5125
5503
|
cacheId: (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId,
|
|
@@ -5140,17 +5518,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5140
5518
|
externalSaleNumber: payload.external_sale_number,
|
|
5141
5519
|
productsCount: ((_payload$products = payload.products) === null || _payload$products === void 0 ? void 0 : _payload$products.length) || 0
|
|
5142
5520
|
});
|
|
5143
|
-
return
|
|
5521
|
+
return _context35.abrupt("return", this.request.post('/order/sales/draft', payload, {
|
|
5144
5522
|
osServer: true,
|
|
5145
5523
|
customToast: function customToast() {}
|
|
5146
5524
|
}));
|
|
5147
5525
|
case 18:
|
|
5148
5526
|
case "end":
|
|
5149
|
-
return
|
|
5527
|
+
return _context35.stop();
|
|
5150
5528
|
}
|
|
5151
|
-
},
|
|
5529
|
+
}, _callee32, this);
|
|
5152
5530
|
}));
|
|
5153
|
-
function saveTempOrderAsDraft(
|
|
5531
|
+
function saveTempOrderAsDraft(_x38) {
|
|
5154
5532
|
return _saveTempOrderAsDraft.apply(this, arguments);
|
|
5155
5533
|
}
|
|
5156
5534
|
return saveTempOrderAsDraft;
|
|
@@ -5164,18 +5542,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5164
5542
|
}, {
|
|
5165
5543
|
key: "submitTempOrder",
|
|
5166
5544
|
value: (function () {
|
|
5167
|
-
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5168
|
-
return _regeneratorRuntime().wrap(function
|
|
5169
|
-
while (1) switch (
|
|
5545
|
+
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
|
|
5546
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context36) {
|
|
5547
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
5170
5548
|
case 0:
|
|
5171
|
-
return
|
|
5549
|
+
return _context36.abrupt("return", this.runSubmitTempOrder(params));
|
|
5172
5550
|
case 1:
|
|
5173
5551
|
case "end":
|
|
5174
|
-
return
|
|
5552
|
+
return _context36.stop();
|
|
5175
5553
|
}
|
|
5176
|
-
},
|
|
5554
|
+
}, _callee33, this);
|
|
5177
5555
|
}));
|
|
5178
|
-
function submitTempOrder(
|
|
5556
|
+
function submitTempOrder(_x39) {
|
|
5179
5557
|
return _submitTempOrder.apply(this, arguments);
|
|
5180
5558
|
}
|
|
5181
5559
|
return submitTempOrder;
|
|
@@ -5183,20 +5561,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5183
5561
|
}, {
|
|
5184
5562
|
key: "submitTempOrderAsync",
|
|
5185
5563
|
value: function () {
|
|
5186
|
-
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5187
|
-
return _regeneratorRuntime().wrap(function
|
|
5188
|
-
while (1) switch (
|
|
5564
|
+
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
|
|
5565
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context37) {
|
|
5566
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
5189
5567
|
case 0:
|
|
5190
|
-
return
|
|
5568
|
+
return _context37.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
5191
5569
|
syncMode: true
|
|
5192
5570
|
})));
|
|
5193
5571
|
case 1:
|
|
5194
5572
|
case "end":
|
|
5195
|
-
return
|
|
5573
|
+
return _context37.stop();
|
|
5196
5574
|
}
|
|
5197
|
-
},
|
|
5575
|
+
}, _callee34, this);
|
|
5198
5576
|
}));
|
|
5199
|
-
function submitTempOrderAsync(
|
|
5577
|
+
function submitTempOrderAsync(_x40) {
|
|
5200
5578
|
return _submitTempOrderAsync.apply(this, arguments);
|
|
5201
5579
|
}
|
|
5202
5580
|
return submitTempOrderAsync;
|
|
@@ -5204,11 +5582,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5204
5582
|
}, {
|
|
5205
5583
|
key: "runSubmitTempOrder",
|
|
5206
5584
|
value: function () {
|
|
5207
|
-
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5585
|
+
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
|
|
5208
5586
|
var _params$cacheId3, _this$otherParams10, _ref73, _ref74, _submitSnapshot$busin, _this$otherParams11, _this$otherParams12, _submitSnapshot$type;
|
|
5209
|
-
var tempOrder, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
|
|
5210
|
-
return _regeneratorRuntime().wrap(function
|
|
5211
|
-
while (1) switch (
|
|
5587
|
+
var tempOrder, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, isLocalPendingSubmit, salesNotesState, submittedOrderId, resultRecord;
|
|
5588
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context38) {
|
|
5589
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
5212
5590
|
case 0:
|
|
5213
5591
|
tempOrder = this.ensureTempOrder();
|
|
5214
5592
|
shouldConfirmPendingVoucherPayments = (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== false;
|
|
@@ -5228,26 +5606,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5228
5606
|
}
|
|
5229
5607
|
}
|
|
5230
5608
|
this.persistTempOrder();
|
|
5231
|
-
|
|
5609
|
+
_context38.next = 8;
|
|
5232
5610
|
return this.recalculateSummary({
|
|
5233
5611
|
createIfMissing: true
|
|
5234
5612
|
});
|
|
5235
5613
|
case 8:
|
|
5236
|
-
|
|
5237
|
-
if (
|
|
5238
|
-
|
|
5614
|
+
_context38.t1 = _context38.sent;
|
|
5615
|
+
if (_context38.t1) {
|
|
5616
|
+
_context38.next = 11;
|
|
5239
5617
|
break;
|
|
5240
5618
|
}
|
|
5241
|
-
|
|
5619
|
+
_context38.t1 = this.store.summary;
|
|
5242
5620
|
case 11:
|
|
5243
|
-
|
|
5244
|
-
if (
|
|
5245
|
-
|
|
5621
|
+
_context38.t0 = _context38.t1;
|
|
5622
|
+
if (_context38.t0) {
|
|
5623
|
+
_context38.next = 14;
|
|
5246
5624
|
break;
|
|
5247
5625
|
}
|
|
5248
|
-
|
|
5626
|
+
_context38.t0 = createEmptySummary();
|
|
5249
5627
|
case 14:
|
|
5250
|
-
latestSummary =
|
|
5628
|
+
latestSummary = _context38.t0;
|
|
5251
5629
|
effectiveCacheId = (_params$cacheId3 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId3 !== void 0 ? _params$cacheId3 : this.cacheId;
|
|
5252
5630
|
hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
|
|
5253
5631
|
hasSmallTicketDataFlagOverride = (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined;
|
|
@@ -5281,10 +5659,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5281
5659
|
if (!payload.created_at) {
|
|
5282
5660
|
payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
5283
5661
|
}
|
|
5284
|
-
|
|
5662
|
+
_context38.next = 25;
|
|
5285
5663
|
return this.saveDraft();
|
|
5286
5664
|
case 25:
|
|
5287
|
-
|
|
5665
|
+
_context38.prev = 25;
|
|
5288
5666
|
this.logInfo('submitTempOrder calling sales checkout', {
|
|
5289
5667
|
orderId: payload.order_id,
|
|
5290
5668
|
externalSaleNumber: payload.external_sale_number,
|
|
@@ -5294,44 +5672,49 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5294
5672
|
smallTicketDataFlag: payload.small_ticket_data_flag,
|
|
5295
5673
|
syncMode: payload.sync_mode
|
|
5296
5674
|
});
|
|
5297
|
-
|
|
5675
|
+
_context38.next = 29;
|
|
5298
5676
|
return this.submitSalesOrder({
|
|
5299
5677
|
query: payload
|
|
5300
5678
|
});
|
|
5301
5679
|
case 29:
|
|
5302
|
-
result =
|
|
5303
|
-
|
|
5680
|
+
result = _context38.sent;
|
|
5681
|
+
_context38.next = 42;
|
|
5304
5682
|
break;
|
|
5305
5683
|
case 32:
|
|
5306
|
-
|
|
5307
|
-
|
|
5308
|
-
backendErrorResponse = this.extractSubmitErrorResponse(
|
|
5684
|
+
_context38.prev = 32;
|
|
5685
|
+
_context38.t2 = _context38["catch"](25);
|
|
5686
|
+
backendErrorResponse = this.extractSubmitErrorResponse(_context38.t2);
|
|
5309
5687
|
if (!backendErrorResponse) {
|
|
5310
|
-
|
|
5688
|
+
_context38.next = 39;
|
|
5311
5689
|
break;
|
|
5312
5690
|
}
|
|
5313
5691
|
this.store.syncState = 'failed';
|
|
5314
5692
|
this.logSubmitBackendRejected(backendErrorResponse, payload);
|
|
5315
|
-
return
|
|
5693
|
+
return _context38.abrupt("return", backendErrorResponse);
|
|
5316
5694
|
case 39:
|
|
5317
5695
|
this.store.syncState = 'failed';
|
|
5318
5696
|
this.logError('submitTempOrder failed', {
|
|
5319
|
-
error:
|
|
5697
|
+
error: _context38.t2 instanceof Error ? _context38.t2.message : String(_context38.t2),
|
|
5320
5698
|
orderId: payload.order_id,
|
|
5321
5699
|
externalSaleNumber: payload.external_sale_number,
|
|
5322
5700
|
paymentStatus: payload.payment_status,
|
|
5323
5701
|
paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
|
|
5324
5702
|
});
|
|
5325
|
-
throw
|
|
5703
|
+
throw _context38.t2;
|
|
5326
5704
|
case 42:
|
|
5327
5705
|
if (!this.isSubmitResponseRejected(result)) {
|
|
5328
|
-
|
|
5706
|
+
_context38.next = 46;
|
|
5329
5707
|
break;
|
|
5330
5708
|
}
|
|
5331
5709
|
this.store.syncState = 'failed';
|
|
5332
5710
|
this.logSubmitBackendRejected(result, payload);
|
|
5333
|
-
return
|
|
5711
|
+
return _context38.abrupt("return", result);
|
|
5334
5712
|
case 46:
|
|
5713
|
+
isLocalPendingSubmit = this.isLocalPendingSubmitResult(result); // need_sync=1 仅表示已进入本地同步队列,不能视为远端已确认 Notes。
|
|
5714
|
+
if (Object.prototype.hasOwnProperty.call(payload, 'notes') && !isLocalPendingSubmit) {
|
|
5715
|
+
salesNotesState = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
5716
|
+
salesNotesState.dirty = false;
|
|
5717
|
+
}
|
|
5335
5718
|
submittedOrderId = this.extractOrderIdFromSubmitResult(result);
|
|
5336
5719
|
this.logInfo('runSubmitTempOrder: 提交成功', {
|
|
5337
5720
|
submittedOrderId: submittedOrderId,
|
|
@@ -5341,31 +5724,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5341
5724
|
})
|
|
5342
5725
|
});
|
|
5343
5726
|
if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
|
|
5344
|
-
|
|
5727
|
+
_context38.next = 55;
|
|
5345
5728
|
break;
|
|
5346
5729
|
}
|
|
5347
5730
|
tempOrder.order_id = submittedOrderId;
|
|
5348
5731
|
resultRecord = result;
|
|
5349
|
-
|
|
5732
|
+
_context38.next = 55;
|
|
5350
5733
|
return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
|
|
5351
|
-
case 53:
|
|
5352
|
-
_context35.next = 56;
|
|
5353
|
-
break;
|
|
5354
5734
|
case 55:
|
|
5355
|
-
if (
|
|
5735
|
+
if (isLocalPendingSubmit) {
|
|
5356
5736
|
this.store.syncState = 'local';
|
|
5357
|
-
} else {
|
|
5737
|
+
} else if (submittedOrderId === null || submittedOrderId === undefined) {
|
|
5358
5738
|
this.store.syncState = 'submitted';
|
|
5359
5739
|
}
|
|
5360
|
-
|
|
5361
|
-
return _context35.abrupt("return", result);
|
|
5740
|
+
return _context38.abrupt("return", result);
|
|
5362
5741
|
case 57:
|
|
5363
5742
|
case "end":
|
|
5364
|
-
return
|
|
5743
|
+
return _context38.stop();
|
|
5365
5744
|
}
|
|
5366
|
-
},
|
|
5745
|
+
}, _callee35, this, [[25, 32]]);
|
|
5367
5746
|
}));
|
|
5368
|
-
function runSubmitTempOrder(
|
|
5747
|
+
function runSubmitTempOrder(_x41) {
|
|
5369
5748
|
return _runSubmitTempOrder.apply(this, arguments);
|
|
5370
5749
|
}
|
|
5371
5750
|
return runSubmitTempOrder;
|
|
@@ -5373,10 +5752,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5373
5752
|
}, {
|
|
5374
5753
|
key: "markLocalOrderSynced",
|
|
5375
5754
|
value: function () {
|
|
5376
|
-
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5755
|
+
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(orderId, remoteOrder) {
|
|
5377
5756
|
var tempOrder;
|
|
5378
|
-
return _regeneratorRuntime().wrap(function
|
|
5379
|
-
while (1) switch (
|
|
5757
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context39) {
|
|
5758
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
5380
5759
|
case 0:
|
|
5381
5760
|
tempOrder = this.ensureTempOrder();
|
|
5382
5761
|
tempOrder.order_id = orderId;
|
|
@@ -5384,15 +5763,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5384
5763
|
this.store.lastOrderInfo = remoteOrder;
|
|
5385
5764
|
this.store.syncState = 'submitted';
|
|
5386
5765
|
this.persistTempOrder();
|
|
5387
|
-
|
|
5766
|
+
_context39.next = 8;
|
|
5388
5767
|
return this.saveDraft();
|
|
5389
5768
|
case 8:
|
|
5390
5769
|
case "end":
|
|
5391
|
-
return
|
|
5770
|
+
return _context39.stop();
|
|
5392
5771
|
}
|
|
5393
|
-
},
|
|
5772
|
+
}, _callee36, this);
|
|
5394
5773
|
}));
|
|
5395
|
-
function markLocalOrderSynced(
|
|
5774
|
+
function markLocalOrderSynced(_x42, _x43) {
|
|
5396
5775
|
return _markLocalOrderSynced.apply(this, arguments);
|
|
5397
5776
|
}
|
|
5398
5777
|
return markLocalOrderSynced;
|
|
@@ -5435,10 +5814,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5435
5814
|
value: function extractSubmitErrorResponse(error) {
|
|
5436
5815
|
var _error$response,
|
|
5437
5816
|
_error$response2,
|
|
5438
|
-
|
|
5817
|
+
_this34 = this;
|
|
5439
5818
|
var candidates = [error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data, error === null || error === void 0 ? void 0 : error.data, error === null || error === void 0 || (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.body, error === null || error === void 0 ? void 0 : error.body];
|
|
5440
5819
|
return candidates.find(function (candidate) {
|
|
5441
|
-
return
|
|
5820
|
+
return _this34.isSubmitErrorResponse(candidate);
|
|
5442
5821
|
}) || null;
|
|
5443
5822
|
}
|
|
5444
5823
|
}, {
|
|
@@ -5465,33 +5844,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5465
5844
|
}, {
|
|
5466
5845
|
key: "syncPaymentsToOrder",
|
|
5467
5846
|
value: function () {
|
|
5468
|
-
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5469
|
-
var
|
|
5847
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
|
|
5848
|
+
var _this35 = this,
|
|
5470
5849
|
_params$confirmPendin;
|
|
5471
5850
|
var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, enhancePayload, submitParams, submitResult;
|
|
5472
|
-
return _regeneratorRuntime().wrap(function
|
|
5473
|
-
while (1) switch (
|
|
5851
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context40) {
|
|
5852
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
5474
5853
|
case 0:
|
|
5475
5854
|
tempOrder = this.ensureTempOrder();
|
|
5476
5855
|
needsPaymentNumber = (params.payments || []).some(function (payment) {
|
|
5477
5856
|
return String(payment.payment_number || '').trim() === '';
|
|
5478
5857
|
});
|
|
5479
5858
|
if (!needsPaymentNumber) {
|
|
5480
|
-
|
|
5859
|
+
_context40.next = 8;
|
|
5481
5860
|
break;
|
|
5482
5861
|
}
|
|
5483
|
-
|
|
5862
|
+
_context40.next = 5;
|
|
5484
5863
|
return this.getPaymentNumberDevicePrefixAsync();
|
|
5485
5864
|
case 5:
|
|
5486
|
-
|
|
5487
|
-
|
|
5865
|
+
_context40.t0 = _context40.sent;
|
|
5866
|
+
_context40.next = 9;
|
|
5488
5867
|
break;
|
|
5489
5868
|
case 8:
|
|
5490
|
-
|
|
5869
|
+
_context40.t0 = 'LOCAL';
|
|
5491
5870
|
case 9:
|
|
5492
|
-
devicePrefix =
|
|
5871
|
+
devicePrefix = _context40.t0;
|
|
5493
5872
|
mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
|
|
5494
|
-
return
|
|
5873
|
+
return _this35.normalizePaymentSource(payment, {
|
|
5495
5874
|
defaultPaid: false,
|
|
5496
5875
|
devicePrefix: devicePrefix
|
|
5497
5876
|
});
|
|
@@ -5504,20 +5883,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5504
5883
|
tempOrder.payments = effectivePayments;
|
|
5505
5884
|
tempOrder.payment_status = paymentStatus;
|
|
5506
5885
|
this.persistTempOrder();
|
|
5507
|
-
|
|
5886
|
+
_context40.next = 21;
|
|
5508
5887
|
return this.saveDraft();
|
|
5509
5888
|
case 21:
|
|
5510
5889
|
if (params.submitWhenPaid) {
|
|
5511
|
-
|
|
5890
|
+
_context40.next = 23;
|
|
5512
5891
|
break;
|
|
5513
5892
|
}
|
|
5514
|
-
return
|
|
5893
|
+
return _context40.abrupt("return", completion);
|
|
5515
5894
|
case 23:
|
|
5516
5895
|
if (!(this.store.syncState === 'submitting')) {
|
|
5517
|
-
|
|
5896
|
+
_context40.next = 25;
|
|
5518
5897
|
break;
|
|
5519
5898
|
}
|
|
5520
|
-
return
|
|
5899
|
+
return _context40.abrupt("return", completion);
|
|
5521
5900
|
case 25:
|
|
5522
5901
|
this.store.syncState = 'submitting';
|
|
5523
5902
|
paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, effectivePayments);
|
|
@@ -5537,32 +5916,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5537
5916
|
enhancePayload: enhancePayload
|
|
5538
5917
|
};
|
|
5539
5918
|
if (!(params.checkoutSyncTaskEnabled === false)) {
|
|
5540
|
-
|
|
5919
|
+
_context40.next = 35;
|
|
5541
5920
|
break;
|
|
5542
5921
|
}
|
|
5543
|
-
|
|
5922
|
+
_context40.next = 32;
|
|
5544
5923
|
return this.submitTempOrderAsync(submitParams);
|
|
5545
5924
|
case 32:
|
|
5546
|
-
|
|
5547
|
-
|
|
5925
|
+
_context40.t1 = _context40.sent;
|
|
5926
|
+
_context40.next = 38;
|
|
5548
5927
|
break;
|
|
5549
5928
|
case 35:
|
|
5550
|
-
|
|
5929
|
+
_context40.next = 37;
|
|
5551
5930
|
return this.submitTempOrder(submitParams);
|
|
5552
5931
|
case 37:
|
|
5553
|
-
|
|
5932
|
+
_context40.t1 = _context40.sent;
|
|
5554
5933
|
case 38:
|
|
5555
|
-
submitResult =
|
|
5556
|
-
return
|
|
5934
|
+
submitResult = _context40.t1;
|
|
5935
|
+
return _context40.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
|
|
5557
5936
|
submitResult: submitResult
|
|
5558
5937
|
}));
|
|
5559
5938
|
case 40:
|
|
5560
5939
|
case "end":
|
|
5561
|
-
return
|
|
5940
|
+
return _context40.stop();
|
|
5562
5941
|
}
|
|
5563
|
-
},
|
|
5942
|
+
}, _callee37, this);
|
|
5564
5943
|
}));
|
|
5565
|
-
function syncPaymentsToOrder(
|
|
5944
|
+
function syncPaymentsToOrder(_x44) {
|
|
5566
5945
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
5567
5946
|
}
|
|
5568
5947
|
return syncPaymentsToOrder;
|
|
@@ -5570,7 +5949,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5570
5949
|
}, {
|
|
5571
5950
|
key: "createOrder",
|
|
5572
5951
|
value: function createOrder(params) {
|
|
5573
|
-
var
|
|
5952
|
+
var _this36 = this;
|
|
5574
5953
|
var order = _objectSpread({
|
|
5575
5954
|
type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
|
|
5576
5955
|
// 要从外面拿,virtual
|
|
@@ -5602,7 +5981,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5602
5981
|
|
|
5603
5982
|
// 为预约补齐 holder 信息
|
|
5604
5983
|
if (params !== null && params !== void 0 && (_params$extraData = params.extraData) !== null && _params$extraData !== void 0 && _params$extraData.is_add_holder_info) {
|
|
5605
|
-
ensureCartItemOriginHolder(item,
|
|
5984
|
+
ensureCartItemOriginHolder(item, _this36.window);
|
|
5606
5985
|
}
|
|
5607
5986
|
|
|
5608
5987
|
// 购物车是否为普通商品
|
|
@@ -5659,11 +6038,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5659
6038
|
}, {
|
|
5660
6039
|
key: "submitOrder",
|
|
5661
6040
|
value: function () {
|
|
5662
|
-
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6041
|
+
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(order) {
|
|
5663
6042
|
var _order$query$cartItem, _params$bookings, _params$relation_prod;
|
|
5664
6043
|
var url, query, fetchUrl, params;
|
|
5665
|
-
return _regeneratorRuntime().wrap(function
|
|
5666
|
-
while (1) switch (
|
|
6044
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context41) {
|
|
6045
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
5667
6046
|
case 0:
|
|
5668
6047
|
this.logInfo('submitOrder called', {
|
|
5669
6048
|
url: order.url,
|
|
@@ -5683,14 +6062,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5683
6062
|
relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
|
|
5684
6063
|
scheduleDate: params.schedule_date
|
|
5685
6064
|
});
|
|
5686
|
-
return
|
|
6065
|
+
return _context41.abrupt("return", this.request.post(fetchUrl, params));
|
|
5687
6066
|
case 6:
|
|
5688
6067
|
case "end":
|
|
5689
|
-
return
|
|
6068
|
+
return _context41.stop();
|
|
5690
6069
|
}
|
|
5691
|
-
},
|
|
6070
|
+
}, _callee38, this);
|
|
5692
6071
|
}));
|
|
5693
|
-
function submitOrder(
|
|
6072
|
+
function submitOrder(_x45) {
|
|
5694
6073
|
return _submitOrder.apply(this, arguments);
|
|
5695
6074
|
}
|
|
5696
6075
|
return submitOrder;
|
|
@@ -5698,13 +6077,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5698
6077
|
}, {
|
|
5699
6078
|
key: "cancelOrder",
|
|
5700
6079
|
value: function () {
|
|
5701
|
-
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6080
|
+
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
|
|
5702
6081
|
var payload;
|
|
5703
|
-
return _regeneratorRuntime().wrap(function
|
|
5704
|
-
while (1) switch (
|
|
6082
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context42) {
|
|
6083
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
5705
6084
|
case 0:
|
|
5706
6085
|
if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
|
|
5707
|
-
|
|
6086
|
+
_context42.next = 2;
|
|
5708
6087
|
break;
|
|
5709
6088
|
}
|
|
5710
6089
|
throw new Error('取消订单失败:order_ids 不能为空');
|
|
@@ -5720,16 +6099,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5720
6099
|
method: 'PUT',
|
|
5721
6100
|
orderIdsCount: params.order_ids.length
|
|
5722
6101
|
});
|
|
5723
|
-
return
|
|
6102
|
+
return _context42.abrupt("return", this.request.put('/order/update-status', payload, {
|
|
5724
6103
|
isShopApi: true
|
|
5725
6104
|
}));
|
|
5726
6105
|
case 5:
|
|
5727
6106
|
case "end":
|
|
5728
|
-
return
|
|
6107
|
+
return _context42.stop();
|
|
5729
6108
|
}
|
|
5730
|
-
},
|
|
6109
|
+
}, _callee39, this);
|
|
5731
6110
|
}));
|
|
5732
|
-
function cancelOrder(
|
|
6111
|
+
function cancelOrder(_x46) {
|
|
5733
6112
|
return _cancelOrder.apply(this, arguments);
|
|
5734
6113
|
}
|
|
5735
6114
|
return cancelOrder;
|
|
@@ -5737,19 +6116,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5737
6116
|
}, {
|
|
5738
6117
|
key: "changeBookingStatus",
|
|
5739
6118
|
value: function () {
|
|
5740
|
-
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6119
|
+
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
|
|
5741
6120
|
var url, payload;
|
|
5742
|
-
return _regeneratorRuntime().wrap(function
|
|
5743
|
-
while (1) switch (
|
|
6121
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context43) {
|
|
6122
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
5744
6123
|
case 0:
|
|
5745
6124
|
if (params.booking_id) {
|
|
5746
|
-
|
|
6125
|
+
_context43.next = 2;
|
|
5747
6126
|
break;
|
|
5748
6127
|
}
|
|
5749
6128
|
throw new Error('变更预约状态失败:booking_id 不能为空');
|
|
5750
6129
|
case 2:
|
|
5751
6130
|
if (params.appointment_status) {
|
|
5752
|
-
|
|
6131
|
+
_context43.next = 4;
|
|
5753
6132
|
break;
|
|
5754
6133
|
}
|
|
5755
6134
|
throw new Error('变更预约状态失败:appointment_status 不能为空');
|
|
@@ -5764,16 +6143,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5764
6143
|
bookingId: params.booking_id,
|
|
5765
6144
|
appointmentStatus: params.appointment_status
|
|
5766
6145
|
});
|
|
5767
|
-
return
|
|
6146
|
+
return _context43.abrupt("return", this.request.put(url, payload, {
|
|
5768
6147
|
isShopApi: true
|
|
5769
6148
|
}));
|
|
5770
6149
|
case 8:
|
|
5771
6150
|
case "end":
|
|
5772
|
-
return
|
|
6151
|
+
return _context43.stop();
|
|
5773
6152
|
}
|
|
5774
|
-
},
|
|
6153
|
+
}, _callee40, this);
|
|
5775
6154
|
}));
|
|
5776
|
-
function changeBookingStatus(
|
|
6155
|
+
function changeBookingStatus(_x47) {
|
|
5777
6156
|
return _changeBookingStatus.apply(this, arguments);
|
|
5778
6157
|
}
|
|
5779
6158
|
return changeBookingStatus;
|
|
@@ -5791,11 +6170,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5791
6170
|
}, {
|
|
5792
6171
|
key: "createOrderByCheckout",
|
|
5793
6172
|
value: (function () {
|
|
5794
|
-
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6173
|
+
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
|
|
5795
6174
|
var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3;
|
|
5796
6175
|
var onlineStorePaymentCodeList, _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, orderData, response;
|
|
5797
|
-
return _regeneratorRuntime().wrap(function
|
|
5798
|
-
while (1) switch (
|
|
6176
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context44) {
|
|
6177
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
5799
6178
|
case 0:
|
|
5800
6179
|
// 过滤掉由在线店铺下单的 payment 支付数据
|
|
5801
6180
|
onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
|
|
@@ -5820,7 +6199,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5820
6199
|
return p.code;
|
|
5821
6200
|
})) || []
|
|
5822
6201
|
});
|
|
5823
|
-
|
|
6202
|
+
_context44.prev = 3;
|
|
5824
6203
|
// 构建订单数据,设置默认值并允许 params 覆盖
|
|
5825
6204
|
orderData = _objectSpread({
|
|
5826
6205
|
sales_channel: 'my_pisel',
|
|
@@ -5868,32 +6247,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5868
6247
|
hasOrderId: !!orderData.order_id,
|
|
5869
6248
|
smallTicketDataFlag: orderData.small_ticket_data_flag
|
|
5870
6249
|
});
|
|
5871
|
-
|
|
6250
|
+
_context44.next = 10;
|
|
5872
6251
|
return this.request.post('/order/checkout', orderData, {
|
|
5873
6252
|
osServer: true,
|
|
5874
6253
|
customToast: function customToast() {}
|
|
5875
6254
|
});
|
|
5876
6255
|
case 10:
|
|
5877
|
-
response =
|
|
6256
|
+
response = _context44.sent;
|
|
5878
6257
|
this.logInfo('Order API called successfully', {
|
|
5879
6258
|
response: response
|
|
5880
6259
|
});
|
|
5881
|
-
return
|
|
6260
|
+
return _context44.abrupt("return", response);
|
|
5882
6261
|
case 15:
|
|
5883
|
-
|
|
5884
|
-
|
|
5885
|
-
console.error('[Order] createOrderByCheckout 创建订单失败:',
|
|
6262
|
+
_context44.prev = 15;
|
|
6263
|
+
_context44.t0 = _context44["catch"](3);
|
|
6264
|
+
console.error('[Order] createOrderByCheckout 创建订单失败:', _context44.t0);
|
|
5886
6265
|
this.logInfo('Order API called failed', {
|
|
5887
|
-
error:
|
|
6266
|
+
error: _context44.t0 instanceof Error ? _context44.t0.message : String(_context44.t0)
|
|
5888
6267
|
});
|
|
5889
|
-
throw
|
|
6268
|
+
throw _context44.t0;
|
|
5890
6269
|
case 20:
|
|
5891
6270
|
case "end":
|
|
5892
|
-
return
|
|
6271
|
+
return _context44.stop();
|
|
5893
6272
|
}
|
|
5894
|
-
},
|
|
6273
|
+
}, _callee41, this, [[3, 15]]);
|
|
5895
6274
|
}));
|
|
5896
|
-
function createOrderByCheckout(
|
|
6275
|
+
function createOrderByCheckout(_x48) {
|
|
5897
6276
|
return _createOrderByCheckout.apply(this, arguments);
|
|
5898
6277
|
}
|
|
5899
6278
|
return createOrderByCheckout;
|
|
@@ -5901,24 +6280,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5901
6280
|
}, {
|
|
5902
6281
|
key: "submitSalesOrder",
|
|
5903
6282
|
value: function () {
|
|
5904
|
-
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6283
|
+
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
|
|
5905
6284
|
var url, query, fetchUrl;
|
|
5906
|
-
return _regeneratorRuntime().wrap(function
|
|
5907
|
-
while (1) switch (
|
|
6285
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context45) {
|
|
6286
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
5908
6287
|
case 0:
|
|
5909
6288
|
url = params.url, query = params.query;
|
|
5910
6289
|
fetchUrl = url || '/order/sales/checkout';
|
|
5911
|
-
return
|
|
6290
|
+
return _context45.abrupt("return", this.request.post(fetchUrl, query, {
|
|
5912
6291
|
osServer: true,
|
|
5913
6292
|
customToast: function customToast() {}
|
|
5914
6293
|
}));
|
|
5915
6294
|
case 3:
|
|
5916
6295
|
case "end":
|
|
5917
|
-
return
|
|
6296
|
+
return _context45.stop();
|
|
5918
6297
|
}
|
|
5919
|
-
},
|
|
6298
|
+
}, _callee42, this);
|
|
5920
6299
|
}));
|
|
5921
|
-
function submitSalesOrder(
|
|
6300
|
+
function submitSalesOrder(_x49) {
|
|
5922
6301
|
return _submitSalesOrder.apply(this, arguments);
|
|
5923
6302
|
}
|
|
5924
6303
|
return submitSalesOrder;
|
|
@@ -5932,37 +6311,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5932
6311
|
}, {
|
|
5933
6312
|
key: "sendCustomerPayLink",
|
|
5934
6313
|
value: (function () {
|
|
5935
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6314
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
|
|
5936
6315
|
var _params$emails;
|
|
5937
6316
|
var orderIds;
|
|
5938
|
-
return _regeneratorRuntime().wrap(function
|
|
5939
|
-
while (1) switch (
|
|
6317
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context46) {
|
|
6318
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
5940
6319
|
case 0:
|
|
5941
6320
|
orderIds = params.order_ids || params.orderIds || [];
|
|
5942
6321
|
if (orderIds.length) {
|
|
5943
|
-
|
|
6322
|
+
_context46.next = 3;
|
|
5944
6323
|
break;
|
|
5945
6324
|
}
|
|
5946
6325
|
throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
|
|
5947
6326
|
case 3:
|
|
5948
6327
|
if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
|
|
5949
|
-
|
|
6328
|
+
_context46.next = 5;
|
|
5950
6329
|
break;
|
|
5951
6330
|
}
|
|
5952
6331
|
throw new Error('发送支付链接需要至少一个邮箱');
|
|
5953
6332
|
case 5:
|
|
5954
|
-
return
|
|
6333
|
+
return _context46.abrupt("return", this.request.post('/order/batch-email', {
|
|
5955
6334
|
order_ids: orderIds,
|
|
5956
6335
|
notify_action: params.notify_action || 'order_payment_reminder',
|
|
5957
6336
|
emails: params.emails
|
|
5958
6337
|
}));
|
|
5959
6338
|
case 6:
|
|
5960
6339
|
case "end":
|
|
5961
|
-
return
|
|
6340
|
+
return _context46.stop();
|
|
5962
6341
|
}
|
|
5963
|
-
},
|
|
6342
|
+
}, _callee43, this);
|
|
5964
6343
|
}));
|
|
5965
|
-
function sendCustomerPayLink(
|
|
6344
|
+
function sendCustomerPayLink(_x50) {
|
|
5966
6345
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
5967
6346
|
}
|
|
5968
6347
|
return sendCustomerPayLink;
|
|
@@ -5970,14 +6349,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5970
6349
|
}, {
|
|
5971
6350
|
key: "getSalesOrderByLookup",
|
|
5972
6351
|
value: function () {
|
|
5973
|
-
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6352
|
+
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(params) {
|
|
5974
6353
|
var lookup, res;
|
|
5975
|
-
return _regeneratorRuntime().wrap(function
|
|
5976
|
-
while (1) switch (
|
|
6354
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context47) {
|
|
6355
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
5977
6356
|
case 0:
|
|
5978
6357
|
lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
|
|
5979
6358
|
if (lookup) {
|
|
5980
|
-
|
|
6359
|
+
_context47.next = 3;
|
|
5981
6360
|
break;
|
|
5982
6361
|
}
|
|
5983
6362
|
throw new Error('加载销售详情需要 lookup');
|
|
@@ -5986,27 +6365,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5986
6365
|
if (lookup.startsWith('LOCAL_')) {
|
|
5987
6366
|
params.forceRemote = false;
|
|
5988
6367
|
}
|
|
5989
|
-
|
|
6368
|
+
_context47.next = 6;
|
|
5990
6369
|
return this.request.get("/order/sales/".concat(encodeURIComponent(lookup)), _objectSpread({
|
|
5991
|
-
with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info', 'refunds']
|
|
6370
|
+
with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info', 'refunds', 'notes']
|
|
5992
6371
|
}, params.forceRemote ? {
|
|
5993
6372
|
forceRemote: true
|
|
5994
6373
|
} : {}), {
|
|
5995
6374
|
osServer: true
|
|
5996
6375
|
});
|
|
5997
6376
|
case 6:
|
|
5998
|
-
res =
|
|
6377
|
+
res = _context47.sent;
|
|
5999
6378
|
if (res.code === 200) {
|
|
6000
6379
|
this.store.lastOrderInfo = res.data;
|
|
6001
6380
|
}
|
|
6002
|
-
return
|
|
6381
|
+
return _context47.abrupt("return", res);
|
|
6003
6382
|
case 9:
|
|
6004
6383
|
case "end":
|
|
6005
|
-
return
|
|
6384
|
+
return _context47.stop();
|
|
6006
6385
|
}
|
|
6007
|
-
},
|
|
6386
|
+
}, _callee44, this);
|
|
6008
6387
|
}));
|
|
6009
|
-
function getSalesOrderByLookup(
|
|
6388
|
+
function getSalesOrderByLookup(_x51) {
|
|
6010
6389
|
return _getSalesOrderByLookup.apply(this, arguments);
|
|
6011
6390
|
}
|
|
6012
6391
|
return getSalesOrderByLookup;
|
|
@@ -6020,11 +6399,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6020
6399
|
}, {
|
|
6021
6400
|
key: "hydrateTempOrderFromRecord",
|
|
6022
6401
|
value: (function () {
|
|
6023
|
-
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6402
|
+
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(record, options) {
|
|
6024
6403
|
var _sourceRaw$_extend, _this$store$discount22;
|
|
6025
6404
|
var sourceRaw, duplicateProductIdentityRepair, duplicateIdentityReadySource, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, isSessionStorageHydrate, isMergedSalesDetailHydrate, nextTempOrder, _this$store$discount20, _this$store$discount21, restoredSessionDiscounts, nextExtend, sourceLastOrderInfo, isDraftOrder, syntheticIdentityOptions, rawSummary, summarySurcharges, hadSyntheticDraftOrderId, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount23, _this$store$discount24;
|
|
6026
|
-
return _regeneratorRuntime().wrap(function
|
|
6027
|
-
while (1) switch (
|
|
6405
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context48) {
|
|
6406
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
6028
6407
|
case 0:
|
|
6029
6408
|
sourceRaw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
|
|
6030
6409
|
duplicateProductIdentityRepair = repairDuplicateOrderProductLineIdentities(Array.isArray(sourceRaw.products) ? sourceRaw.products : [], (_sourceRaw$_extend = sourceRaw._extend) === null || _sourceRaw$_extend === void 0 ? void 0 : _sourceRaw$_extend.productsByUid);
|
|
@@ -6060,11 +6439,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6060
6439
|
isMergedSalesDetailHydrate = (options === null || options === void 0 ? void 0 : options.source) === 'mergedSalesDetail';
|
|
6061
6440
|
nextTempOrder = this.normalizeTempOrderForRuntime(raw, {
|
|
6062
6441
|
// merge 前已只给远端商品补标记;这里不能把本地未提交商品一并变成 saved item。
|
|
6063
|
-
makeEditMark: !isSessionStorageHydrate && !isMergedSalesDetailHydrate
|
|
6442
|
+
makeEditMark: !isSessionStorageHydrate && !isMergedSalesDetailHydrate,
|
|
6443
|
+
allowUnresolvedSalesNotes: isSessionStorageHydrate
|
|
6064
6444
|
});
|
|
6065
6445
|
this.store.tempOrder = nextTempOrder;
|
|
6066
6446
|
if (!isSessionStorageHydrate) {
|
|
6067
|
-
|
|
6447
|
+
_context48.next = 30;
|
|
6068
6448
|
break;
|
|
6069
6449
|
}
|
|
6070
6450
|
// 会话快照是未提交购物车,不应获得编辑订单的 saved/edit 标记与服务端基线。
|
|
@@ -6080,23 +6460,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6080
6460
|
nextTempOrder.discount_list = restoredSessionDiscounts;
|
|
6081
6461
|
this.store.summary = createEmptySummary();
|
|
6082
6462
|
this.store.lastOrderInfo = undefined;
|
|
6083
|
-
|
|
6463
|
+
_context48.next = 23;
|
|
6084
6464
|
return (_this$store$discount20 = this.store.discount) === null || _this$store$discount20 === void 0 ? void 0 : _this$store$discount20.setOriginalDiscountList(cloneDeep(restoredSessionDiscounts));
|
|
6085
6465
|
case 23:
|
|
6086
|
-
|
|
6466
|
+
_context48.next = 25;
|
|
6087
6467
|
return (_this$store$discount21 = this.store.discount) === null || _this$store$discount21 === void 0 ? void 0 : _this$store$discount21.setDiscountList(cloneDeep(restoredSessionDiscounts));
|
|
6088
6468
|
case 25:
|
|
6089
6469
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
6090
|
-
|
|
6470
|
+
_context48.next = 28;
|
|
6091
6471
|
break;
|
|
6092
6472
|
}
|
|
6093
|
-
|
|
6473
|
+
_context48.next = 28;
|
|
6094
6474
|
return this.recalculateSummary({
|
|
6095
6475
|
createIfMissing: false
|
|
6096
6476
|
});
|
|
6097
6477
|
case 28:
|
|
6098
6478
|
this.persistTempOrder();
|
|
6099
|
-
return
|
|
6479
|
+
return _context48.abrupt("return", nextTempOrder);
|
|
6100
6480
|
case 30:
|
|
6101
6481
|
// Server list compatibility may synthesize order_id from external_sale_number; tempOrder must not.
|
|
6102
6482
|
sourceLastOrderInfo = sourceRaw.lastOrderInfo || sourceRaw;
|
|
@@ -6144,34 +6524,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6144
6524
|
nextDiscounts = [].concat(_toConsumableArray(hydratedEditDiscounts), _toConsumableArray(retainedScanDiscounts));
|
|
6145
6525
|
shouldSkipEmptyDiscountSync = nextDiscounts.length === 0 && currentDiscounts.length === 0;
|
|
6146
6526
|
if (shouldSkipEmptyDiscountSync) {
|
|
6147
|
-
|
|
6527
|
+
_context48.next = 53;
|
|
6148
6528
|
break;
|
|
6149
6529
|
}
|
|
6150
6530
|
OrderModule.populateSavedAmounts(nextTempOrder.products, nextDiscounts);
|
|
6151
|
-
|
|
6531
|
+
_context48.next = 51;
|
|
6152
6532
|
return (_this$store$discount23 = this.store.discount) === null || _this$store$discount23 === void 0 ? void 0 : _this$store$discount23.setOriginalDiscountList(nextDiscounts);
|
|
6153
6533
|
case 51:
|
|
6154
|
-
|
|
6534
|
+
_context48.next = 53;
|
|
6155
6535
|
return (_this$store$discount24 = this.store.discount) === null || _this$store$discount24 === void 0 ? void 0 : _this$store$discount24.setDiscountList(nextDiscounts);
|
|
6156
6536
|
case 53:
|
|
6157
6537
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
6158
|
-
|
|
6538
|
+
_context48.next = 56;
|
|
6159
6539
|
break;
|
|
6160
6540
|
}
|
|
6161
|
-
|
|
6541
|
+
_context48.next = 56;
|
|
6162
6542
|
return this.recalculateSummary({
|
|
6163
6543
|
createIfMissing: false
|
|
6164
6544
|
});
|
|
6165
6545
|
case 56:
|
|
6166
6546
|
this.persistTempOrder();
|
|
6167
|
-
return
|
|
6547
|
+
return _context48.abrupt("return", nextTempOrder);
|
|
6168
6548
|
case 58:
|
|
6169
6549
|
case "end":
|
|
6170
|
-
return
|
|
6550
|
+
return _context48.stop();
|
|
6171
6551
|
}
|
|
6172
|
-
},
|
|
6552
|
+
}, _callee45, this);
|
|
6173
6553
|
}));
|
|
6174
|
-
function hydrateTempOrderFromRecord(
|
|
6554
|
+
function hydrateTempOrderFromRecord(_x52, _x53) {
|
|
6175
6555
|
return _hydrateTempOrderFromRecord.apply(this, arguments);
|
|
6176
6556
|
}
|
|
6177
6557
|
return hydrateTempOrderFromRecord;
|
|
@@ -6224,10 +6604,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6224
6604
|
_step22;
|
|
6225
6605
|
try {
|
|
6226
6606
|
for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
|
|
6227
|
-
var _product$
|
|
6607
|
+
var _product$metadata10;
|
|
6228
6608
|
var product = _step22.value;
|
|
6229
6609
|
var productUid = getOrderCollectionUid('product', product);
|
|
6230
|
-
var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$
|
|
6610
|
+
var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata10 = product.metadata) === null || _product$metadata10 === void 0 ? void 0 : _product$metadata10.booking_uid);
|
|
6231
6611
|
if (!productUid || bookingUid === undefined || bookingUid === null || bookingUid === '') {
|
|
6232
6612
|
continue;
|
|
6233
6613
|
}
|
|
@@ -6285,7 +6665,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6285
6665
|
}, {
|
|
6286
6666
|
key: "normalizeTempOrderForRuntime",
|
|
6287
6667
|
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
6288
|
-
var
|
|
6668
|
+
var _this37 = this,
|
|
6669
|
+
_raw$_extend;
|
|
6289
6670
|
var runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
|
|
6290
6671
|
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
|
|
6291
6672
|
// ES 列表详情使用 id 表示订单主键;OS 详情态统一依赖 order_id 驱动操作按钮。
|
|
@@ -6309,12 +6690,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6309
6690
|
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
6310
6691
|
var rawProducts = Array.isArray(raw.products) ? raw.products : [];
|
|
6311
6692
|
nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
|
|
6312
|
-
return
|
|
6693
|
+
return _this37.normalizeHydratedOrderProduct(p, {
|
|
6313
6694
|
makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
|
|
6314
6695
|
});
|
|
6315
6696
|
}) : [];
|
|
6316
6697
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
6317
|
-
var booking =
|
|
6698
|
+
var booking = _this37.normalizeHydratedBookingHolder(b || {});
|
|
6318
6699
|
return _objectSpread(_objectSpread({}, booking), {}, {
|
|
6319
6700
|
is_all: normalizeBookingIsAll(booking),
|
|
6320
6701
|
sub_type: normalizeBookingSubType(booking)
|
|
@@ -6323,6 +6704,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6323
6704
|
nextTempOrder.payments = Array.isArray(raw.payments) ? raw.payments.map(function (p) {
|
|
6324
6705
|
return _objectSpread({}, p || {});
|
|
6325
6706
|
}) : [];
|
|
6707
|
+
var rawHasSalesNotes = Object.prototype.hasOwnProperty.call(raw, 'notes');
|
|
6708
|
+
var restoredSalesNotesState = (_raw$_extend = raw._extend) === null || _raw$_extend === void 0 ? void 0 : _raw$_extend.salesNotesState;
|
|
6709
|
+
var allowUnresolvedSalesNotes = (options === null || options === void 0 ? void 0 : options.allowUnresolvedSalesNotes) === true || (restoredSalesNotesState === null || restoredSalesNotesState === void 0 ? void 0 : restoredSalesNotesState.dirty) === true || Number(raw.is_draft_order || 0) === 1;
|
|
6710
|
+
var decodedSalesNotes = rawHasSalesNotes ? decodeSalesNotesSnapshot(raw.notes, {
|
|
6711
|
+
allowUnresolvedOrderTarget: allowUnresolvedSalesNotes
|
|
6712
|
+
}) : {
|
|
6713
|
+
notes: [],
|
|
6714
|
+
complete: false
|
|
6715
|
+
};
|
|
6716
|
+
var hasUnresolvedSalesNoteOrderTarget = decodedSalesNotes.notes.some(function (note) {
|
|
6717
|
+
return note.note_relations.some(function (relation) {
|
|
6718
|
+
return relation.is_primary === 0 && relation.relation_type === 'related_to' && relation.target_type === 'order' && relation.target_uuid === '';
|
|
6719
|
+
});
|
|
6720
|
+
});
|
|
6721
|
+
nextTempOrder.notes = decodedSalesNotes.notes;
|
|
6326
6722
|
nextTempOrder.surcharges = Array.isArray(raw.surcharges) ? raw.surcharges.map(function (s) {
|
|
6327
6723
|
return _objectSpread({}, s || {});
|
|
6328
6724
|
}) : [];
|
|
@@ -6339,16 +6735,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6339
6735
|
productsByUid: {}
|
|
6340
6736
|
};
|
|
6341
6737
|
var tempOrderExtend = nextTempOrder._extend;
|
|
6738
|
+
tempOrderExtend.salesNotesState = {
|
|
6739
|
+
loaded: rawHasSalesNotes ? decodedSalesNotes.complete : (restoredSalesNotesState === null || restoredSalesNotesState === void 0 ? void 0 : restoredSalesNotesState.loaded) === true,
|
|
6740
|
+
dirty: decodedSalesNotes.complete && ((restoredSalesNotesState === null || restoredSalesNotesState === void 0 ? void 0 : restoredSalesNotesState.dirty) === true || allowUnresolvedSalesNotes && hasUnresolvedSalesNoteOrderTarget)
|
|
6741
|
+
};
|
|
6342
6742
|
var productsByUid = tempOrderExtend.productsByUid || {};
|
|
6343
6743
|
var _iterator24 = _createForOfIteratorHelper(nextTempOrder.products.entries()),
|
|
6344
6744
|
_step24;
|
|
6345
6745
|
try {
|
|
6346
6746
|
for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
|
|
6347
|
-
var _product$
|
|
6747
|
+
var _product$metadata11, _ref75, _ref76, _existed$origin, _rawProduct$metadata;
|
|
6348
6748
|
var _step24$value = _slicedToArray(_step24.value, 2),
|
|
6349
6749
|
index = _step24$value[0],
|
|
6350
6750
|
product = _step24$value[1];
|
|
6351
|
-
var uid = (_product$
|
|
6751
|
+
var uid = (_product$metadata11 = product.metadata) === null || _product$metadata11 === void 0 ? void 0 : _product$metadata11.unique_identification_number;
|
|
6352
6752
|
if (!uid) continue;
|
|
6353
6753
|
var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
|
|
6354
6754
|
var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
|
|
@@ -6403,8 +6803,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6403
6803
|
var bookingUidByProductUid = new Map();
|
|
6404
6804
|
var productByUid = new Map();
|
|
6405
6805
|
(tempOrder.products || []).forEach(function (product) {
|
|
6406
|
-
var _product$
|
|
6407
|
-
var productUid = (product === null || product === void 0 || (_product$
|
|
6806
|
+
var _product$metadata12;
|
|
6807
|
+
var productUid = (product === null || product === void 0 || (_product$metadata12 = product.metadata) === null || _product$metadata12 === void 0 ? void 0 : _product$metadata12.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
6408
6808
|
if (productUid !== undefined && productUid !== null && String(productUid) !== '') {
|
|
6409
6809
|
productByUid.set(String(productUid), product);
|
|
6410
6810
|
}
|
|
@@ -6425,8 +6825,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6425
6825
|
bookingUidByProductUid.set(String(productUid), bookingUid);
|
|
6426
6826
|
});
|
|
6427
6827
|
(tempOrder.products || []).forEach(function (product) {
|
|
6428
|
-
var _product$
|
|
6429
|
-
var productUid = (product === null || product === void 0 || (_product$
|
|
6828
|
+
var _product$metadata13;
|
|
6829
|
+
var productUid = (product === null || product === void 0 || (_product$metadata13 = product.metadata) === null || _product$metadata13 === void 0 ? void 0 : _product$metadata13.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
6430
6830
|
if (productUid === undefined || productUid === null || String(productUid) === '') return;
|
|
6431
6831
|
var bookingUid = bookingUidByProductUid.get(String(productUid));
|
|
6432
6832
|
if (!bookingUid) return;
|
|
@@ -6501,7 +6901,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6501
6901
|
}, {
|
|
6502
6902
|
key: "normalizeHydratedOrderProduct",
|
|
6503
6903
|
value: function normalizeHydratedOrderProduct(product, options) {
|
|
6504
|
-
var
|
|
6904
|
+
var _this38 = this;
|
|
6505
6905
|
var row = _objectSpread({}, product || {});
|
|
6506
6906
|
if (row.num === undefined && row.product_quantity !== undefined) {
|
|
6507
6907
|
row.num = row.product_quantity;
|
|
@@ -6509,7 +6909,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6509
6909
|
var productSku = ensureProductSku(row);
|
|
6510
6910
|
row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
|
|
6511
6911
|
option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
|
|
6512
|
-
return
|
|
6912
|
+
return _this38.normalizeHydratedProductOptionItem(optionItem || {});
|
|
6513
6913
|
}))
|
|
6514
6914
|
});
|
|
6515
6915
|
delete row["product_".concat('option', "_item")];
|
|
@@ -6549,27 +6949,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6549
6949
|
}, {
|
|
6550
6950
|
key: "getOrderInfo",
|
|
6551
6951
|
value: function () {
|
|
6552
|
-
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6952
|
+
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(order_id) {
|
|
6553
6953
|
var res;
|
|
6554
|
-
return _regeneratorRuntime().wrap(function
|
|
6555
|
-
while (1) switch (
|
|
6954
|
+
return _regeneratorRuntime().wrap(function _callee46$(_context49) {
|
|
6955
|
+
while (1) switch (_context49.prev = _context49.next) {
|
|
6556
6956
|
case 0:
|
|
6557
|
-
|
|
6957
|
+
_context49.next = 2;
|
|
6558
6958
|
return this.request.get("/order/sales/".concat(order_id), {
|
|
6559
|
-
with: ['products', 'bookings']
|
|
6959
|
+
with: ['products', 'bookings', 'notes']
|
|
6560
6960
|
}, {
|
|
6561
6961
|
osServer: true
|
|
6562
6962
|
});
|
|
6563
6963
|
case 2:
|
|
6564
|
-
res =
|
|
6565
|
-
return
|
|
6964
|
+
res = _context49.sent;
|
|
6965
|
+
return _context49.abrupt("return", res);
|
|
6566
6966
|
case 4:
|
|
6567
6967
|
case "end":
|
|
6568
|
-
return
|
|
6968
|
+
return _context49.stop();
|
|
6569
6969
|
}
|
|
6570
|
-
},
|
|
6970
|
+
}, _callee46, this);
|
|
6571
6971
|
}));
|
|
6572
|
-
function getOrderInfo(
|
|
6972
|
+
function getOrderInfo(_x54) {
|
|
6573
6973
|
return _getOrderInfo.apply(this, arguments);
|
|
6574
6974
|
}
|
|
6575
6975
|
return getOrderInfo;
|