@pisell/pisellos 2.2.221 → 2.2.223
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/Customer/index.d.ts +7 -0
- package/dist/modules/Customer/index.js +27 -0
- package/dist/modules/OpenData/index.js +1 -1
- package/dist/modules/Order/index.js +17 -11
- package/dist/modules/Order/types.d.ts +3 -0
- package/dist/modules/Order/utils.js +6 -5
- package/dist/modules/Payment/types.d.ts +2 -0
- package/dist/modules/SalesSummary/index.js +3 -3
- package/dist/modules/Schedule/index.js +3 -1
- package/dist/modules/Summary/index.js +4 -3
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.js +48 -18
- package/dist/server/modules/order/index.js +3 -2
- package/dist/server/modules/order/types.d.ts +1 -1
- package/dist/server/modules/order/utils/filterBookings.js +1 -1
- package/dist/server/modules/schedule/index.d.ts +4 -4
- package/dist/server/modules/schedule/index.js +99 -83
- package/dist/server/utils/small-ticket.d.ts +3 -1
- package/dist/server/utils/small-ticket.js +106 -18
- package/dist/solution/BaseSales/index.js +7 -2
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +3 -1
- package/dist/solution/BookingTicket/index.js +12 -8
- package/lib/modules/Customer/index.d.ts +7 -0
- package/lib/modules/Customer/index.js +26 -0
- package/lib/modules/OpenData/index.js +1 -1
- package/lib/modules/Order/index.js +7 -3
- package/lib/modules/Order/types.d.ts +3 -0
- package/lib/modules/Order/utils.js +2 -1
- package/lib/modules/Payment/types.d.ts +2 -0
- package/lib/modules/SalesSummary/index.js +2 -1
- package/lib/modules/Schedule/index.js +3 -1
- package/lib/modules/Summary/index.js +5 -4
- package/lib/server/index.d.ts +2 -0
- package/lib/server/index.js +37 -7
- package/lib/server/modules/order/index.js +1 -0
- package/lib/server/modules/order/types.d.ts +1 -1
- package/lib/server/modules/order/utils/filterBookings.js +7 -3
- package/lib/server/modules/schedule/index.d.ts +4 -4
- package/lib/server/modules/schedule/index.js +45 -39
- package/lib/server/utils/small-ticket.d.ts +3 -1
- package/lib/server/utils/small-ticket.js +85 -11
- package/lib/solution/BaseSales/index.js +6 -2
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +3 -1
- package/lib/solution/BookingTicket/index.js +3 -3
- package/package.json +1 -1
|
@@ -32,9 +32,9 @@ dayjs.extend(isSameOrBefore);
|
|
|
32
32
|
dayjs.extend(isSameOrAfter);
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
35
|
+
* SQLite 存储名称
|
|
36
36
|
*/
|
|
37
|
-
var
|
|
37
|
+
var SCHEDULE_STORE_NAME = 'schedule';
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* Schedule 模块(扩展版本)
|
|
@@ -54,7 +54,7 @@ export var ScheduleModuleEx = /*#__PURE__*/function (_BaseModule) {
|
|
|
54
54
|
_defineProperty(_assertThisInitialized(_this), "request", void 0);
|
|
55
55
|
_defineProperty(_assertThisInitialized(_this), "store", {});
|
|
56
56
|
_defineProperty(_assertThisInitialized(_this), "dbManager", void 0);
|
|
57
|
-
//
|
|
57
|
+
// SQLiteAdapter 实例
|
|
58
58
|
_defineProperty(_assertThisInitialized(_this), "logger", void 0);
|
|
59
59
|
return _this;
|
|
60
60
|
}
|
|
@@ -149,16 +149,16 @@ export var ScheduleModuleEx = /*#__PURE__*/function (_BaseModule) {
|
|
|
149
149
|
this.store.map = new Map();
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
// 获取并存储
|
|
152
|
+
// 获取并存储 SQLite 和 logger
|
|
153
153
|
appPlugin = core.getPlugin('app');
|
|
154
154
|
if (appPlugin) {
|
|
155
155
|
app = appPlugin.getApp();
|
|
156
|
-
this.dbManager = app.
|
|
156
|
+
this.dbManager = app.sqlite;
|
|
157
157
|
this.logger = app.logger;
|
|
158
158
|
if (this.dbManager) {
|
|
159
|
-
console.log('[Schedule]
|
|
159
|
+
console.log('[Schedule] SQLite 已初始化');
|
|
160
160
|
} else {
|
|
161
|
-
console.warn('[Schedule]
|
|
161
|
+
console.warn('[Schedule] SQLite 未找到');
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
this.logInfo('模块初始化完成', {
|
|
@@ -206,9 +206,9 @@ export var ScheduleModuleEx = /*#__PURE__*/function (_BaseModule) {
|
|
|
206
206
|
duration: "".concat(duration, "ms")
|
|
207
207
|
});
|
|
208
208
|
|
|
209
|
-
// 保存到
|
|
209
|
+
// 保存到 SQLite
|
|
210
210
|
_context2.next = 11;
|
|
211
|
-
return this.
|
|
211
|
+
return this.saveScheduleToSQLite(list);
|
|
212
212
|
case 11:
|
|
213
213
|
this.setScheduleList(list);
|
|
214
214
|
return _context2.abrupt("return", list);
|
|
@@ -334,25 +334,25 @@ export var ScheduleModuleEx = /*#__PURE__*/function (_BaseModule) {
|
|
|
334
334
|
});
|
|
335
335
|
this.store.scheduleList = [];
|
|
336
336
|
this.store.map.clear();
|
|
337
|
-
// 同时清空
|
|
337
|
+
// 同时清空 SQLite 中的数据
|
|
338
338
|
if (!this.dbManager) {
|
|
339
339
|
_context3.next = 16;
|
|
340
340
|
break;
|
|
341
341
|
}
|
|
342
342
|
_context3.prev = 4;
|
|
343
343
|
_context3.next = 7;
|
|
344
|
-
return this.dbManager.clear(
|
|
344
|
+
return this.dbManager.clear(SCHEDULE_STORE_NAME);
|
|
345
345
|
case 7:
|
|
346
|
-
console.log('[Schedule]
|
|
347
|
-
this.logInfo('
|
|
346
|
+
console.log('[Schedule] SQLite 缓存已清空');
|
|
347
|
+
this.logInfo('SQLite 缓存已清空');
|
|
348
348
|
_context3.next = 16;
|
|
349
349
|
break;
|
|
350
350
|
case 11:
|
|
351
351
|
_context3.prev = 11;
|
|
352
352
|
_context3.t0 = _context3["catch"](4);
|
|
353
353
|
errorMessage = _context3.t0 instanceof Error ? _context3.t0.message : String(_context3.t0);
|
|
354
|
-
console.error('[Schedule] 清空
|
|
355
|
-
this.logError('清空
|
|
354
|
+
console.error('[Schedule] 清空 SQLite 缓存失败:', _context3.t0);
|
|
355
|
+
this.logError('清空 SQLite 缓存失败', {
|
|
356
356
|
error: errorMessage
|
|
357
357
|
});
|
|
358
358
|
case 16:
|
|
@@ -397,13 +397,13 @@ export var ScheduleModuleEx = /*#__PURE__*/function (_BaseModule) {
|
|
|
397
397
|
}
|
|
398
398
|
|
|
399
399
|
/**
|
|
400
|
-
* 从
|
|
400
|
+
* 从 SQLite 加载日程数据
|
|
401
401
|
* @private
|
|
402
402
|
*/
|
|
403
403
|
}, {
|
|
404
|
-
key: "
|
|
404
|
+
key: "loadScheduleFromSQLite",
|
|
405
405
|
value: (function () {
|
|
406
|
-
var
|
|
406
|
+
var _loadScheduleFromSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
407
407
|
var _scheduleList$length, scheduleList, errorMessage;
|
|
408
408
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
409
409
|
while (1) switch (_context4.prev = _context4.next) {
|
|
@@ -412,15 +412,15 @@ export var ScheduleModuleEx = /*#__PURE__*/function (_BaseModule) {
|
|
|
412
412
|
_context4.next = 3;
|
|
413
413
|
break;
|
|
414
414
|
}
|
|
415
|
-
this.logWarning('
|
|
415
|
+
this.logWarning('loadScheduleFromSQLite: SQLite 不可用');
|
|
416
416
|
return _context4.abrupt("return", []);
|
|
417
417
|
case 3:
|
|
418
418
|
_context4.prev = 3;
|
|
419
419
|
_context4.next = 6;
|
|
420
|
-
return this.dbManager.getAll(
|
|
420
|
+
return this.dbManager.getAll(SCHEDULE_STORE_NAME);
|
|
421
421
|
case 6:
|
|
422
422
|
scheduleList = _context4.sent;
|
|
423
|
-
this.logInfo('从
|
|
423
|
+
this.logInfo('从 SQLite 加载日程数据', {
|
|
424
424
|
scheduleCount: (_scheduleList$length = scheduleList === null || scheduleList === void 0 ? void 0 : scheduleList.length) !== null && _scheduleList$length !== void 0 ? _scheduleList$length : 0
|
|
425
425
|
});
|
|
426
426
|
return _context4.abrupt("return", scheduleList || []);
|
|
@@ -428,8 +428,8 @@ export var ScheduleModuleEx = /*#__PURE__*/function (_BaseModule) {
|
|
|
428
428
|
_context4.prev = 11;
|
|
429
429
|
_context4.t0 = _context4["catch"](3);
|
|
430
430
|
errorMessage = _context4.t0 instanceof Error ? _context4.t0.message : String(_context4.t0);
|
|
431
|
-
console.error('[Schedule] 从
|
|
432
|
-
this.logError('从
|
|
431
|
+
console.error('[Schedule] 从 SQLite 读取数据失败:', _context4.t0);
|
|
432
|
+
this.logError('从 SQLite 读取数据失败', {
|
|
433
433
|
error: errorMessage
|
|
434
434
|
});
|
|
435
435
|
return _context4.abrupt("return", []);
|
|
@@ -439,22 +439,22 @@ export var ScheduleModuleEx = /*#__PURE__*/function (_BaseModule) {
|
|
|
439
439
|
}
|
|
440
440
|
}, _callee4, this, [[3, 11]]);
|
|
441
441
|
}));
|
|
442
|
-
function
|
|
443
|
-
return
|
|
442
|
+
function loadScheduleFromSQLite() {
|
|
443
|
+
return _loadScheduleFromSQLite.apply(this, arguments);
|
|
444
444
|
}
|
|
445
|
-
return
|
|
445
|
+
return loadScheduleFromSQLite;
|
|
446
446
|
}()
|
|
447
447
|
/**
|
|
448
|
-
* 保存日程数据到
|
|
448
|
+
* 保存日程数据到 SQLite
|
|
449
449
|
* @private
|
|
450
450
|
*/
|
|
451
451
|
)
|
|
452
452
|
}, {
|
|
453
|
-
key: "
|
|
453
|
+
key: "saveScheduleToSQLite",
|
|
454
454
|
value: (function () {
|
|
455
|
-
var
|
|
455
|
+
var _saveScheduleToSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(scheduleList) {
|
|
456
456
|
var _this4 = this;
|
|
457
|
-
var
|
|
457
|
+
var errorMessage;
|
|
458
458
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
459
459
|
while (1) switch (_context5.prev = _context5.next) {
|
|
460
460
|
case 0:
|
|
@@ -462,48 +462,70 @@ export var ScheduleModuleEx = /*#__PURE__*/function (_BaseModule) {
|
|
|
462
462
|
_context5.next = 3;
|
|
463
463
|
break;
|
|
464
464
|
}
|
|
465
|
-
this.logWarning('
|
|
465
|
+
this.logWarning('saveScheduleToSQLite: SQLite 不可用');
|
|
466
466
|
return _context5.abrupt("return");
|
|
467
467
|
case 3:
|
|
468
|
-
this.logInfo('开始保存日程数据到
|
|
468
|
+
this.logInfo('开始保存日程数据到 SQLite', {
|
|
469
469
|
scheduleCount: scheduleList.length
|
|
470
470
|
});
|
|
471
471
|
_context5.prev = 4;
|
|
472
472
|
_context5.next = 7;
|
|
473
|
-
return this.dbManager.clear(
|
|
473
|
+
return this.dbManager.clear(SCHEDULE_STORE_NAME);
|
|
474
474
|
case 7:
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
475
|
+
if (!(scheduleList.length > 0)) {
|
|
476
|
+
_context5.next = 20;
|
|
477
|
+
break;
|
|
478
|
+
}
|
|
479
|
+
if (!(typeof this.dbManager.bulkAdd === 'function')) {
|
|
480
|
+
_context5.next = 13;
|
|
481
|
+
break;
|
|
482
|
+
}
|
|
483
|
+
_context5.next = 11;
|
|
484
|
+
return this.dbManager.bulkAdd(SCHEDULE_STORE_NAME, scheduleList);
|
|
485
|
+
case 11:
|
|
486
|
+
_context5.next = 20;
|
|
487
|
+
break;
|
|
488
|
+
case 13:
|
|
489
|
+
if (!(typeof this.dbManager.bulkUpdate === 'function')) {
|
|
490
|
+
_context5.next = 18;
|
|
491
|
+
break;
|
|
492
|
+
}
|
|
493
|
+
_context5.next = 16;
|
|
494
|
+
return this.dbManager.bulkUpdate(SCHEDULE_STORE_NAME, scheduleList);
|
|
495
|
+
case 16:
|
|
496
|
+
_context5.next = 20;
|
|
497
|
+
break;
|
|
498
|
+
case 18:
|
|
499
|
+
_context5.next = 20;
|
|
500
|
+
return Promise.all(scheduleList.map(function (schedule) {
|
|
501
|
+
return _this4.dbManager.add(SCHEDULE_STORE_NAME, schedule);
|
|
502
|
+
}));
|
|
503
|
+
case 20:
|
|
504
|
+
console.log("[Schedule] \u5DF2\u5C06 ".concat(scheduleList.length, " \u6761\u65E5\u7A0B\u6570\u636E\u4FDD\u5B58\u5230 SQLite"));
|
|
505
|
+
this.logInfo('日程数据已保存到 SQLite', {
|
|
484
506
|
scheduleCount: scheduleList.length
|
|
485
507
|
});
|
|
486
|
-
_context5.next =
|
|
508
|
+
_context5.next = 29;
|
|
487
509
|
break;
|
|
488
|
-
case
|
|
489
|
-
_context5.prev =
|
|
510
|
+
case 24:
|
|
511
|
+
_context5.prev = 24;
|
|
490
512
|
_context5.t0 = _context5["catch"](4);
|
|
491
513
|
errorMessage = _context5.t0 instanceof Error ? _context5.t0.message : String(_context5.t0);
|
|
492
|
-
console.error('[Schedule] 保存数据到
|
|
493
|
-
this.logError('保存数据到
|
|
514
|
+
console.error('[Schedule] 保存数据到 SQLite 失败:', _context5.t0);
|
|
515
|
+
this.logError('保存数据到 SQLite 失败', {
|
|
494
516
|
scheduleCount: scheduleList.length,
|
|
495
517
|
error: errorMessage
|
|
496
518
|
});
|
|
497
|
-
case
|
|
519
|
+
case 29:
|
|
498
520
|
case "end":
|
|
499
521
|
return _context5.stop();
|
|
500
522
|
}
|
|
501
|
-
}, _callee5, this, [[4,
|
|
523
|
+
}, _callee5, this, [[4, 24]]);
|
|
502
524
|
}));
|
|
503
|
-
function
|
|
504
|
-
return
|
|
525
|
+
function saveScheduleToSQLite(_x3) {
|
|
526
|
+
return _saveScheduleToSQLite.apply(this, arguments);
|
|
505
527
|
}
|
|
506
|
-
return
|
|
528
|
+
return saveScheduleToSQLite;
|
|
507
529
|
}()
|
|
508
530
|
/**
|
|
509
531
|
* 预加载模块数据(统一接口)
|
|
@@ -523,36 +545,36 @@ export var ScheduleModuleEx = /*#__PURE__*/function (_BaseModule) {
|
|
|
523
545
|
this.logInfo('开始预加载数据');
|
|
524
546
|
_context6.prev = 3;
|
|
525
547
|
_context6.next = 6;
|
|
526
|
-
return this.
|
|
548
|
+
return this.loadScheduleFromSQLite();
|
|
527
549
|
case 6:
|
|
528
550
|
cachedData = _context6.sent;
|
|
529
551
|
if (!(cachedData && cachedData.length > 0)) {
|
|
530
552
|
_context6.next = 14;
|
|
531
553
|
break;
|
|
532
554
|
}
|
|
533
|
-
console.log("[Schedule] \u4ECE
|
|
555
|
+
console.log("[Schedule] \u4ECE SQLite \u52A0\u8F7D\u4E86 ".concat(cachedData.length, " \u6761\u65E5\u7A0B\u6570\u636E"));
|
|
534
556
|
// 将缓存数据放入 store
|
|
535
557
|
this.store.scheduleList = cloneDeep(cachedData);
|
|
536
558
|
// 同步更新 Map 缓存
|
|
537
559
|
this.syncScheduleMap();
|
|
538
560
|
duration = Date.now() - startTime;
|
|
539
|
-
this.logInfo('预加载完成(从
|
|
561
|
+
this.logInfo('预加载完成(从 SQLite)', {
|
|
540
562
|
scheduleCount: cachedData.length,
|
|
541
563
|
duration: "".concat(duration, "ms"),
|
|
542
|
-
source: '
|
|
564
|
+
source: 'SQLite'
|
|
543
565
|
});
|
|
544
566
|
return _context6.abrupt("return");
|
|
545
567
|
case 14:
|
|
546
|
-
console.log('[Schedule]
|
|
547
|
-
this.logInfo('
|
|
568
|
+
console.log('[Schedule] SQLite 中没有缓存数据,从服务器加载...');
|
|
569
|
+
this.logInfo('SQLite 中没有缓存数据,准备从服务器加载');
|
|
548
570
|
_context6.next = 23;
|
|
549
571
|
break;
|
|
550
572
|
case 18:
|
|
551
573
|
_context6.prev = 18;
|
|
552
574
|
_context6.t0 = _context6["catch"](3);
|
|
553
575
|
errorMessage = _context6.t0 instanceof Error ? _context6.t0.message : String(_context6.t0);
|
|
554
|
-
console.warn('[Schedule] 从
|
|
555
|
-
this.logWarning('从
|
|
576
|
+
console.warn('[Schedule] 从 SQLite 加载数据失败:', _context6.t0);
|
|
577
|
+
this.logWarning('从 SQLite 加载数据失败,准备从服务器加载', {
|
|
556
578
|
error: errorMessage
|
|
557
579
|
});
|
|
558
580
|
case 23:
|
|
@@ -560,30 +582,24 @@ export var ScheduleModuleEx = /*#__PURE__*/function (_BaseModule) {
|
|
|
560
582
|
return this.loadAllSchedule();
|
|
561
583
|
case 25:
|
|
562
584
|
scheduleList = _context6.sent;
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
585
|
+
// 3. 将服务器数据放入 store
|
|
586
|
+
if (scheduleList && scheduleList.length > 0) {
|
|
587
|
+
this.store.scheduleList = cloneDeep(scheduleList);
|
|
588
|
+
// 同步更新 Map 缓存
|
|
589
|
+
this.syncScheduleMap();
|
|
590
|
+
_duration2 = Date.now() - startTime;
|
|
591
|
+
this.logInfo('预加载完成(从服务器)', {
|
|
592
|
+
scheduleCount: scheduleList.length,
|
|
593
|
+
duration: "".concat(_duration2, "ms"),
|
|
594
|
+
source: 'Server'
|
|
595
|
+
});
|
|
596
|
+
} else {
|
|
597
|
+
_duration3 = Date.now() - startTime;
|
|
598
|
+
this.logWarning('预加载完成但未获取到数据', {
|
|
599
|
+
duration: "".concat(_duration3, "ms")
|
|
600
|
+
});
|
|
566
601
|
}
|
|
567
|
-
|
|
568
|
-
return this.saveScheduleToIndexDB(scheduleList);
|
|
569
|
-
case 29:
|
|
570
|
-
this.store.scheduleList = cloneDeep(scheduleList);
|
|
571
|
-
// 同步更新 Map 缓存
|
|
572
|
-
this.syncScheduleMap();
|
|
573
|
-
_duration2 = Date.now() - startTime;
|
|
574
|
-
this.logInfo('预加载完成(从服务器)', {
|
|
575
|
-
scheduleCount: scheduleList.length,
|
|
576
|
-
duration: "".concat(_duration2, "ms"),
|
|
577
|
-
source: 'Server'
|
|
578
|
-
});
|
|
579
|
-
_context6.next = 37;
|
|
580
|
-
break;
|
|
581
|
-
case 35:
|
|
582
|
-
_duration3 = Date.now() - startTime;
|
|
583
|
-
this.logWarning('预加载完成但未获取到数据', {
|
|
584
|
-
duration: "".concat(_duration3, "ms")
|
|
585
|
-
});
|
|
586
|
-
case 37:
|
|
602
|
+
case 27:
|
|
587
603
|
case "end":
|
|
588
604
|
return _context6.stop();
|
|
589
605
|
}
|
|
@@ -145,7 +145,7 @@ function buildBaseData(params) {
|
|
|
145
145
|
var order = params.order,
|
|
146
146
|
shopInfo = params.shopInfo,
|
|
147
147
|
locale = params.locale;
|
|
148
|
-
var orderNumber = stringify(order.
|
|
148
|
+
var orderNumber = stringify(order.buzzer || order.shop_full_order_number);
|
|
149
149
|
return {
|
|
150
150
|
shop_name: stringify(shopInfo.name || order.shop_name),
|
|
151
151
|
note: stringify(order.note),
|
|
@@ -173,24 +173,33 @@ function buildProducts(order, locale, productMap) {
|
|
|
173
173
|
productMap: productMap,
|
|
174
174
|
locale: locale
|
|
175
175
|
});
|
|
176
|
+
var currencySymbol = getCurrencySymbol(order, null);
|
|
177
|
+
var options = normalizeProductOptions({
|
|
178
|
+
product: product,
|
|
179
|
+
locale: locale,
|
|
180
|
+
currencySymbol: currencySymbol
|
|
181
|
+
});
|
|
182
|
+
var combinations = normalizeProductCombinations({
|
|
183
|
+
product: product,
|
|
184
|
+
productMap: productMap,
|
|
185
|
+
locale: locale,
|
|
186
|
+
currencySymbol: currencySymbol
|
|
187
|
+
});
|
|
176
188
|
return _objectSpread(_objectSpread(_objectSpread({
|
|
177
189
|
product_title: productTitle,
|
|
178
190
|
product_quantity: quantity,
|
|
179
|
-
selling_price: formatMoney(sellingPrice,
|
|
180
|
-
original_price: formatMoney(originalPrice,
|
|
181
|
-
total_original_price: formatMoney(new Decimal(toMoneyNumber(originalPrice)).mul(quantity),
|
|
191
|
+
selling_price: formatMoney(sellingPrice, currencySymbol),
|
|
192
|
+
original_price: formatMoney(originalPrice, currencySymbol),
|
|
193
|
+
total_original_price: formatMoney(new Decimal(toMoneyNumber(originalPrice)).mul(quantity), currencySymbol),
|
|
182
194
|
extension_list: Array.isArray(product.extension_list) ? product.extension_list : []
|
|
183
|
-
},
|
|
184
|
-
options:
|
|
185
|
-
return {
|
|
186
|
-
name: getLocalizedValue(option.name || option.title, locale),
|
|
187
|
-
value: getLocalizedValue(option.value || option.option || option.item, locale)
|
|
188
|
-
};
|
|
189
|
-
})
|
|
195
|
+
}, options.length ? {
|
|
196
|
+
options: options
|
|
190
197
|
} : {}), product.variant ? {
|
|
191
198
|
variant: getLocalizedValue(product.variant, locale)
|
|
192
199
|
} : {}), Array.isArray(product.combinations) ? {
|
|
193
200
|
combinations: product.combinations
|
|
201
|
+
} : combinations.length ? {
|
|
202
|
+
combinations: combinations
|
|
194
203
|
} : {});
|
|
195
204
|
});
|
|
196
205
|
}
|
|
@@ -206,6 +215,85 @@ function resolveProductTitle(params) {
|
|
|
206
215
|
if (!fallbackProduct) return '';
|
|
207
216
|
return getLocalizedValue(fallbackProduct.product_title || fallbackProduct.title || fallbackProduct.name || fallbackProduct.format_title || ((_fallbackProduct$prod = fallbackProduct.product) === null || _fallbackProduct$prod === void 0 ? void 0 : _fallbackProduct$prod.title), locale);
|
|
208
217
|
}
|
|
218
|
+
function normalizeProductOptions(params) {
|
|
219
|
+
var _product$product_sku;
|
|
220
|
+
var product = params.product,
|
|
221
|
+
locale = params.locale,
|
|
222
|
+
currencySymbol = params.currencySymbol;
|
|
223
|
+
var rawOptions = Array.isArray(params.options) ? params.options : Array.isArray(product.options) ? product.options : Array.isArray((_product$product_sku = product.product_sku) === null || _product$product_sku === void 0 ? void 0 : _product$product_sku.option) ? product.product_sku.option : [];
|
|
224
|
+
return rawOptions.map(function (option) {
|
|
225
|
+
var _ref8, _option$original_pric, _ref9, _option$value, _option$num;
|
|
226
|
+
var price = (_ref8 = (_option$original_pric = option.original_price) !== null && _option$original_pric !== void 0 ? _option$original_pric : option.add_price) !== null && _ref8 !== void 0 ? _ref8 : option.price;
|
|
227
|
+
var value = (_ref9 = (_option$value = option.value) !== null && _option$value !== void 0 ? _option$value : option.option) !== null && _ref9 !== void 0 ? _ref9 : option.item;
|
|
228
|
+
return _objectSpread(_objectSpread(_objectSpread({
|
|
229
|
+
name: getLocalizedValue(option.name || option.title, locale)
|
|
230
|
+
}, option.num !== undefined || option.quantity !== undefined ? {
|
|
231
|
+
num: toNumber((_option$num = option.num) !== null && _option$num !== void 0 ? _option$num : option.quantity, 1)
|
|
232
|
+
} : {}), price !== undefined && price !== null && price !== '' ? {
|
|
233
|
+
price: formatMoney(price, currencySymbol)
|
|
234
|
+
} : {}), value !== undefined && value !== null && value !== '' ? {
|
|
235
|
+
value: getLocalizedValue(value, locale)
|
|
236
|
+
} : {});
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
function normalizeProductCombinations(params) {
|
|
240
|
+
var product = params.product,
|
|
241
|
+
productMap = params.productMap,
|
|
242
|
+
locale = params.locale,
|
|
243
|
+
currencySymbol = params.currencySymbol;
|
|
244
|
+
var bundles = Array.isArray(product.product_bundle) ? product.product_bundle : [];
|
|
245
|
+
return bundles.map(function (bundle) {
|
|
246
|
+
var _ref10, _bundle$num;
|
|
247
|
+
var combinationsOptions = normalizeProductOptions({
|
|
248
|
+
product: {},
|
|
249
|
+
locale: locale,
|
|
250
|
+
currencySymbol: currencySymbol,
|
|
251
|
+
options: Array.isArray(bundle.option) ? bundle.option : []
|
|
252
|
+
});
|
|
253
|
+
var baseTitle = resolveBundleProductTitle({
|
|
254
|
+
bundle: bundle,
|
|
255
|
+
productMap: productMap,
|
|
256
|
+
locale: locale
|
|
257
|
+
});
|
|
258
|
+
var optionTitle = buildOptionTitleSuffix(combinationsOptions);
|
|
259
|
+
return {
|
|
260
|
+
product_title: "".concat(baseTitle).concat(optionTitle),
|
|
261
|
+
product_quantity: toNumber((_ref10 = (_bundle$num = bundle.num) !== null && _bundle$num !== void 0 ? _bundle$num : bundle.quantity) !== null && _ref10 !== void 0 ? _ref10 : 1, 1),
|
|
262
|
+
price: formatBundlePrice(bundle, currencySymbol),
|
|
263
|
+
combinations_options: combinationsOptions
|
|
264
|
+
};
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
function resolveBundleProductTitle(params) {
|
|
268
|
+
var _bundle$product, _ref11, _ref12, _bundle$bundle_produc, _fallbackProduct$prod2;
|
|
269
|
+
var bundle = params.bundle,
|
|
270
|
+
productMap = params.productMap,
|
|
271
|
+
locale = params.locale;
|
|
272
|
+
var ownTitle = getLocalizedValue(bundle.product_title || bundle.title || bundle.name || ((_bundle$product = bundle.product) === null || _bundle$product === void 0 ? void 0 : _bundle$product.title), locale);
|
|
273
|
+
if (ownTitle) return ownTitle;
|
|
274
|
+
var productId = (_ref11 = (_ref12 = (_bundle$bundle_produc = bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle._bundle_product_id) !== null && _ref12 !== void 0 ? _ref12 : bundle.product_id) !== null && _ref11 !== void 0 ? _ref11 : bundle.id;
|
|
275
|
+
var fallbackProduct = productId !== undefined && productId !== null ? productMap[productId] || productMap[String(productId)] : null;
|
|
276
|
+
if (!fallbackProduct) return '';
|
|
277
|
+
return getLocalizedValue(fallbackProduct.product_title || fallbackProduct.title || fallbackProduct.name || fallbackProduct.format_title || ((_fallbackProduct$prod2 = fallbackProduct.product) === null || _fallbackProduct$prod2 === void 0 ? void 0 : _fallbackProduct$prod2.title), locale);
|
|
278
|
+
}
|
|
279
|
+
function buildOptionTitleSuffix(options) {
|
|
280
|
+
var text = options.map(function (option) {
|
|
281
|
+
var _option$num2;
|
|
282
|
+
var name = stringify(option.name).trim();
|
|
283
|
+
if (!name) return '';
|
|
284
|
+
var quantity = (_option$num2 = option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1;
|
|
285
|
+
return "".concat(name, " x ").concat(quantity);
|
|
286
|
+
}).filter(Boolean).join(', ');
|
|
287
|
+
return text ? "(".concat(text, ")") : '';
|
|
288
|
+
}
|
|
289
|
+
function formatBundlePrice(bundle, currencySymbol) {
|
|
290
|
+
var _ref13, _ref14, _bundle$bundle_sellin;
|
|
291
|
+
var value = (_ref13 = (_ref14 = (_bundle$bundle_sellin = bundle.bundle_selling_price) !== null && _bundle$bundle_sellin !== void 0 ? _bundle$bundle_sellin : bundle.bundle_sum_price) !== null && _ref14 !== void 0 ? _ref14 : bundle.price) !== null && _ref13 !== void 0 ? _ref13 : 0;
|
|
292
|
+
var amount = new Decimal(toMoneyNumber(value));
|
|
293
|
+
var isNegative = bundle.price_type === 'markdown' || bundle.price_type === 'markup' && bundle.price_type_ext === 'product_price';
|
|
294
|
+
if (isNegative) return "-".concat(currencySymbol).concat(amount.abs().toFixed(2));
|
|
295
|
+
return formatMoney(amount, currencySymbol);
|
|
296
|
+
}
|
|
209
297
|
function buildFees(params) {
|
|
210
298
|
var order = params.order,
|
|
211
299
|
shopInfo = params.shopInfo,
|
|
@@ -215,9 +303,9 @@ function buildFees(params) {
|
|
|
215
303
|
currencySymbol = params.currencySymbol;
|
|
216
304
|
var fees = [];
|
|
217
305
|
for (var _i = 0, _normalizeArray = normalizeArray(order.surcharges || summary.surcharges); _i < _normalizeArray.length; _i++) {
|
|
218
|
-
var
|
|
306
|
+
var _ref15, _surcharge$amount;
|
|
219
307
|
var surcharge = _normalizeArray[_i];
|
|
220
|
-
var value = (
|
|
308
|
+
var value = (_ref15 = (_surcharge$amount = surcharge.amount) !== null && _surcharge$amount !== void 0 ? _surcharge$amount : surcharge.value) !== null && _ref15 !== void 0 ? _ref15 : surcharge.total_amount;
|
|
221
309
|
if (!isNonZero(value)) continue;
|
|
222
310
|
fees.push({
|
|
223
311
|
item: getLocalizedValue(surcharge.name || surcharge.title || surcharge.item, locale),
|
|
@@ -352,8 +440,8 @@ function buildPaymentData(params) {
|
|
|
352
440
|
currencySymbol: params.currencySymbol
|
|
353
441
|
})));
|
|
354
442
|
} else {
|
|
355
|
-
var
|
|
356
|
-
var remainingAmount = (
|
|
443
|
+
var _ref16, _payment$remaining_am, _payment$metadata;
|
|
444
|
+
var remainingAmount = (_ref16 = (_payment$remaining_am = payment.remaining_amount) !== null && _payment$remaining_am !== void 0 ? _payment$remaining_am : payment.balance) !== null && _ref16 !== void 0 ? _ref16 : (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.remaining_amount;
|
|
357
445
|
if (remainingAmount !== undefined && remainingAmount !== null) {
|
|
358
446
|
items.push({
|
|
359
447
|
item: label(params.locale, 'remainingAmount'),
|
|
@@ -461,13 +549,13 @@ function label(locale, key) {
|
|
|
461
549
|
return ((_LABELS$locale = LABELS[locale]) === null || _LABELS$locale === void 0 ? void 0 : _LABELS$locale[key]) || LABELS.en[key] || key;
|
|
462
550
|
}
|
|
463
551
|
function getLocalizedValue(value, locale) {
|
|
464
|
-
var
|
|
552
|
+
var _ref17, _ref18, _ref19, _ref20, _ref21, _ref22, _value$locale;
|
|
465
553
|
if (value === undefined || value === null) return '';
|
|
466
554
|
if (_typeof(value) !== 'object') return stringify(value);
|
|
467
555
|
var dashedLocale = locale.replace('_', '-');
|
|
468
|
-
return stringify((
|
|
556
|
+
return stringify((_ref17 = (_ref18 = (_ref19 = (_ref20 = (_ref21 = (_ref22 = (_value$locale = value[locale]) !== null && _value$locale !== void 0 ? _value$locale : value[dashedLocale]) !== null && _ref22 !== void 0 ? _ref22 : value.default) !== null && _ref21 !== void 0 ? _ref21 : value.en) !== null && _ref20 !== void 0 ? _ref20 : value.zh_CN) !== null && _ref19 !== void 0 ? _ref19 : value['zh-CN']) !== null && _ref18 !== void 0 ? _ref18 : Object.values(value).find(function (item) {
|
|
469
557
|
return typeof item === 'string' || typeof item === 'number';
|
|
470
|
-
})) !== null &&
|
|
558
|
+
})) !== null && _ref17 !== void 0 ? _ref17 : '');
|
|
471
559
|
}
|
|
472
560
|
function serviceTypeToLabelKey(serviceType) {
|
|
473
561
|
var normalized = serviceType.toLowerCase();
|
|
@@ -98,7 +98,7 @@ function mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey) {
|
|
|
98
98
|
}
|
|
99
99
|
function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord) {
|
|
100
100
|
if (!currentTempOrder) return loadedRecord;
|
|
101
|
-
|
|
101
|
+
var mergedRecord = mergeWith(cloneDeep(currentTempOrder), cloneDeep(loadedRecord || {}), function (currentValue, loadedValue, key) {
|
|
102
102
|
if (Array.isArray(currentValue) && Array.isArray(loadedValue)) {
|
|
103
103
|
var metadataKey = getBaseSalesUniqueArrayMetadataKey(key);
|
|
104
104
|
if (metadataKey) {
|
|
@@ -112,6 +112,8 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord) {
|
|
|
112
112
|
}
|
|
113
113
|
return undefined;
|
|
114
114
|
});
|
|
115
|
+
delete mergedRecord.request_unique_idempotency_token;
|
|
116
|
+
return mergedRecord;
|
|
115
117
|
}
|
|
116
118
|
export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
117
119
|
_inherits(BaseSalesImpl, _BaseModule);
|
|
@@ -2114,6 +2116,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2114
2116
|
key: "addOrderPayment",
|
|
2115
2117
|
value: function addOrderPayment(payment) {
|
|
2116
2118
|
var _this$otherParams16,
|
|
2119
|
+
_paymentRecord$paymen,
|
|
2117
2120
|
_this7 = this;
|
|
2118
2121
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
2119
2122
|
var paymentRecord = payment;
|
|
@@ -2132,8 +2135,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2132
2135
|
if (!metadata.unique_payment_number) {
|
|
2133
2136
|
metadata.unique_payment_number = createUuidV4();
|
|
2134
2137
|
}
|
|
2138
|
+
var paymentTime = (_paymentRecord$paymen = paymentRecord.payment_time) !== null && _paymentRecord$paymen !== void 0 ? _paymentRecord$paymen : dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
2135
2139
|
var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread({}, paymentRecord), {}, {
|
|
2136
|
-
metadata: metadata
|
|
2140
|
+
metadata: metadata,
|
|
2141
|
+
payment_time: paymentTime
|
|
2137
2142
|
}));
|
|
2138
2143
|
var amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
2139
2144
|
var syncState = this.store.order.getOrderSyncState();
|
|
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
311
|
date: string;
|
|
312
312
|
status: string;
|
|
313
313
|
week: string;
|
|
314
|
-
weekNum: 0 |
|
|
314
|
+
weekNum: 0 | 1 | 2 | 3 | 5 | 4 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -109,7 +109,9 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
109
109
|
*
|
|
110
110
|
* @returns loadSalesDetail 的返回值
|
|
111
111
|
*/
|
|
112
|
-
refreshSalesDetail(
|
|
112
|
+
refreshSalesDetail(params?: {
|
|
113
|
+
forceRemote?: boolean;
|
|
114
|
+
}): Promise<ISalesDetail>;
|
|
113
115
|
/**
|
|
114
116
|
* 获取商品列表
|
|
115
117
|
* @param params 包含 schedule_date 的参数
|
|
@@ -786,30 +786,34 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
786
786
|
value: (function () {
|
|
787
787
|
var _refreshSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
788
788
|
var _this$store$order3, _this$store$order3$ge;
|
|
789
|
-
var
|
|
789
|
+
var params,
|
|
790
|
+
tempOrder,
|
|
791
|
+
orderId,
|
|
792
|
+
_args11 = arguments;
|
|
790
793
|
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
791
794
|
while (1) switch (_context11.prev = _context11.next) {
|
|
792
795
|
case 0:
|
|
796
|
+
params = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : {};
|
|
793
797
|
tempOrder = (_this$store$order3 = this.store.order) === null || _this$store$order3 === void 0 || (_this$store$order3$ge = _this$store$order3.getTempOrder) === null || _this$store$order3$ge === void 0 ? void 0 : _this$store$order3$ge.call(_this$store$order3);
|
|
794
798
|
if (tempOrder) {
|
|
795
|
-
_context11.next =
|
|
799
|
+
_context11.next = 4;
|
|
796
800
|
break;
|
|
797
801
|
}
|
|
798
802
|
throw new Error('refreshSalesDetail: tempOrder 未加载');
|
|
799
|
-
case
|
|
803
|
+
case 4:
|
|
800
804
|
orderId = tempOrder.order_id;
|
|
801
805
|
if (!(orderId === undefined || orderId === null)) {
|
|
802
|
-
_context11.next =
|
|
806
|
+
_context11.next = 7;
|
|
803
807
|
break;
|
|
804
808
|
}
|
|
805
809
|
return _context11.abrupt("return", {});
|
|
806
|
-
case
|
|
810
|
+
case 7:
|
|
807
811
|
return _context11.abrupt("return", this.loadSalesDetail({
|
|
808
812
|
orderId: Number(orderId),
|
|
809
|
-
merge: true
|
|
810
|
-
|
|
813
|
+
// merge: true
|
|
814
|
+
forceRemote: params.forceRemote
|
|
811
815
|
}));
|
|
812
|
-
case
|
|
816
|
+
case 8:
|
|
813
817
|
case "end":
|
|
814
818
|
return _context11.stop();
|
|
815
819
|
}
|
|
@@ -7,6 +7,13 @@ export declare class CustomerModule extends BaseModule implements Module, Custom
|
|
|
7
7
|
private store;
|
|
8
8
|
private request;
|
|
9
9
|
private cacheId;
|
|
10
|
+
/**
|
|
11
|
+
* 判断两份选中客户的核心展示字段是否一致,用于避免重复 clone / emit。
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* this.isSameSelectedCustomer(currentCustomer, nextCustomer);
|
|
15
|
+
*/
|
|
16
|
+
private isSameSelectedCustomer;
|
|
10
17
|
private openCache;
|
|
11
18
|
private fatherModule;
|
|
12
19
|
private otherParams;
|