@pisell/pisellos 0.10.94 → 0.10.96

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.
Files changed (39) hide show
  1. package/dist/modules/OpenData/index.d.ts +13 -0
  2. package/dist/modules/OpenData/index.js +243 -93
  3. package/dist/modules/Product/index.d.ts +1 -1
  4. package/dist/modules/SalesSummary/index.d.ts +3 -0
  5. package/dist/modules/SalesSummary/index.js +104 -56
  6. package/dist/server/index.d.ts +7 -0
  7. package/dist/server/index.js +1036 -598
  8. package/dist/server/modules/order/index.d.ts +1 -0
  9. package/dist/server/modules/order/index.js +51 -51
  10. package/dist/solution/BookingByStep/index.d.ts +2 -2
  11. package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +8 -8
  12. package/dist/solution/Sales/index.d.ts +2 -1
  13. package/dist/solution/Sales/index.js +154 -48
  14. package/dist/solution/Sales/types.d.ts +12 -0
  15. package/dist/solution/Sales/types.js +2 -0
  16. package/dist/solution/UnifiedBookingSales/index.d.ts +1 -0
  17. package/dist/solution/UnifiedBookingSales/index.js +48 -49
  18. package/dist/solution/UnifiedBookingSales/sessionResourceCache.d.ts +4 -0
  19. package/dist/solution/UnifiedBookingSales/sessionResourceCache.js +91 -14
  20. package/lib/modules/OpenData/index.d.ts +13 -0
  21. package/lib/modules/OpenData/index.js +97 -18
  22. package/lib/modules/Product/index.d.ts +1 -1
  23. package/lib/modules/SalesSummary/index.d.ts +3 -0
  24. package/lib/modules/SalesSummary/index.js +36 -15
  25. package/lib/server/index.d.ts +7 -0
  26. package/lib/server/index.js +240 -18
  27. package/lib/server/modules/order/index.d.ts +1 -0
  28. package/lib/server/modules/order/index.js +4 -3
  29. package/lib/solution/BookingByStep/index.d.ts +2 -2
  30. package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +8 -8
  31. package/lib/solution/Sales/index.d.ts +2 -1
  32. package/lib/solution/Sales/index.js +53 -0
  33. package/lib/solution/Sales/types.d.ts +12 -0
  34. package/lib/solution/Sales/types.js +1 -0
  35. package/lib/solution/UnifiedBookingSales/index.d.ts +1 -0
  36. package/lib/solution/UnifiedBookingSales/index.js +11 -10
  37. package/lib/solution/UnifiedBookingSales/sessionResourceCache.d.ts +4 -0
  38. package/lib/solution/UnifiedBookingSales/sessionResourceCache.js +69 -4
  39. package/package.json +1 -1
@@ -463,6 +463,112 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
463
463
  return _printLocalOrderReceipt.apply(this, arguments);
464
464
  }
465
465
  return printLocalOrderReceipt;
466
+ }()
467
+ }, {
468
+ key: "printCloudOrderInvoice",
469
+ value: function () {
470
+ var _printCloudOrderInvoice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(input) {
471
+ var _lookup$data, _lookup$data2, _lookup$data3, _submitted$data;
472
+ var openData, orderId, channel, messageUuid, scope, event, requestOptions, lookup, accepted, rawBusinessCode, businessCode, deviceId, settings, submitted, taskUuid;
473
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
474
+ while (1) switch (_context7.prev = _context7.next) {
475
+ case 0:
476
+ openData = this.invoiceOpenDataModule;
477
+ if (openData) {
478
+ _context7.next = 3;
479
+ break;
480
+ }
481
+ throw new Error('Cloud Invoice is not initialized');
482
+ case 3:
483
+ orderId = typeof (input === null || input === void 0 ? void 0 : input.order_id) === 'string' ? input.order_id.trim() : Number.isSafeInteger(input === null || input === void 0 ? void 0 : input.order_id) ? String(input.order_id) : '';
484
+ channel = typeof (input === null || input === void 0 ? void 0 : input.channel) === 'string' ? input.channel.trim() : '';
485
+ messageUuid = typeof (input === null || input === void 0 ? void 0 : input.message_uuid) === 'string' ? input.message_uuid.trim() : '';
486
+ if (!(!/^[1-9]\d*$/.test(orderId) || !channel || !messageUuid)) {
487
+ _context7.next = 8;
488
+ break;
489
+ }
490
+ throw new Error('Cloud Invoice requires order_id, channel and message_uuid');
491
+ case 8:
492
+ scope = openData.captureCloudInvoiceScope(input.shop_id);
493
+ event = {
494
+ order_id: orderId,
495
+ channel: channel,
496
+ message_uuid: messageUuid,
497
+ shop_id: scope.shopId
498
+ };
499
+ requestOptions = {
500
+ osServer: true,
501
+ customToast: function customToast() {}
502
+ };
503
+ _context7.next = 13;
504
+ return this.request.post('/shop/local/cloud-order-invoice/lookup', event, requestOptions);
505
+ case 13:
506
+ lookup = _context7.sent;
507
+ scope.assertCurrent();
508
+ if (!((lookup === null || lookup === void 0 ? void 0 : lookup.status) !== true || lookup.code !== 200)) {
509
+ _context7.next = 17;
510
+ break;
511
+ }
512
+ throw new Error((lookup === null || lookup === void 0 ? void 0 : lookup.message) || 'Cloud Invoice order lookup failed');
513
+ case 17:
514
+ accepted = (_lookup$data = lookup.data) === null || _lookup$data === void 0 ? void 0 : _lookup$data.task_uuid;
515
+ if (!(typeof accepted === 'string' && accepted.trim())) {
516
+ _context7.next = 20;
517
+ break;
518
+ }
519
+ return _context7.abrupt("return", {
520
+ task_uuid: accepted
521
+ });
522
+ case 20:
523
+ rawBusinessCode = (_lookup$data2 = lookup.data) === null || _lookup$data2 === void 0 ? void 0 : _lookup$data2.business_code;
524
+ businessCode = typeof rawBusinessCode === 'string' ? rawBusinessCode.trim() : '';
525
+ if (businessCode) {
526
+ _context7.next = 24;
527
+ break;
528
+ }
529
+ throw new Error('Cloud Invoice order has no business_code');
530
+ case 24:
531
+ deviceId = (_lookup$data3 = lookup.data) === null || _lookup$data3 === void 0 ? void 0 : _lookup$data3.device_id;
532
+ if (!(typeof deviceId !== 'string' || !deviceId.trim())) {
533
+ _context7.next = 27;
534
+ break;
535
+ }
536
+ throw new Error('Cloud Invoice lookup has no device_id');
537
+ case 27:
538
+ _context7.next = 29;
539
+ return openData.loadCloudInvoiceTemplate("".concat(businessCode, "+").concat(channel), scope);
540
+ case 29:
541
+ settings = _context7.sent;
542
+ scope.assertCurrent();
543
+ _context7.next = 33;
544
+ return this.request.post('/shop/local/cloud-order-invoice/submit', _objectSpread(_objectSpread({}, event), {}, {
545
+ business_code: businessCode,
546
+ device_id: deviceId,
547
+ template_settings: cloneDeep(settings)
548
+ }), requestOptions);
549
+ case 33:
550
+ submitted = _context7.sent;
551
+ scope.assertCurrent();
552
+ taskUuid = submitted === null || submitted === void 0 || (_submitted$data = submitted.data) === null || _submitted$data === void 0 ? void 0 : _submitted$data.task_uuid;
553
+ if (!((submitted === null || submitted === void 0 ? void 0 : submitted.status) !== true || submitted.code !== 200 || typeof taskUuid !== 'string' || !taskUuid.trim())) {
554
+ _context7.next = 38;
555
+ break;
556
+ }
557
+ throw new Error((submitted === null || submitted === void 0 ? void 0 : submitted.message) || 'Cloud Invoice task was not accepted');
558
+ case 38:
559
+ return _context7.abrupt("return", {
560
+ task_uuid: taskUuid
561
+ });
562
+ case 39:
563
+ case "end":
564
+ return _context7.stop();
565
+ }
566
+ }, _callee7, this);
567
+ }));
568
+ function printCloudOrderInvoice(_x10) {
569
+ return _printCloudOrderInvoice.apply(this, arguments);
570
+ }
571
+ return printCloudOrderInvoice;
466
572
  }() /** 清除独立 Documents 缓存;下一次打印会按当前 target 重新获取。 */
467
573
  }, {
468
574
  key: "clearOpenDataCache",
@@ -480,38 +586,38 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
480
586
  }, {
481
587
  key: "destroy",
482
588
  value: function () {
483
- var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
589
+ var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
484
590
  var invoiceOpenDataModule;
485
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
486
- while (1) switch (_context7.prev = _context7.next) {
591
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
592
+ while (1) switch (_context8.prev = _context8.next) {
487
593
  case 0:
488
594
  this.clearOpenDataCache();
489
595
  invoiceOpenDataModule = this.invoiceOpenDataModule;
490
596
  this.invoiceOpenDataModule = null;
491
597
  if (!invoiceOpenDataModule) {
492
- _context7.next = 12;
598
+ _context8.next = 12;
493
599
  break;
494
600
  }
495
- _context7.prev = 4;
496
- _context7.next = 7;
601
+ _context8.prev = 4;
602
+ _context8.next = 7;
497
603
  return invoiceOpenDataModule.destroy();
498
604
  case 7:
499
- _context7.next = 12;
605
+ _context8.next = 12;
500
606
  break;
501
607
  case 9:
502
- _context7.prev = 9;
503
- _context7.t0 = _context7["catch"](4);
504
- console.warn('[Sales] Invoice OpenData 子模块销毁失败', _context7.t0);
608
+ _context8.prev = 9;
609
+ _context8.t0 = _context8["catch"](4);
610
+ console.warn('[Sales] Invoice OpenData 子模块销毁失败', _context8.t0);
505
611
  case 12:
506
- _context7.next = 14;
612
+ _context8.next = 14;
507
613
  return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
508
614
  case 14:
509
615
  _get(_getPrototypeOf(SalesImpl.prototype), "destroy", this).call(this);
510
616
  case 15:
511
617
  case "end":
512
- return _context7.stop();
618
+ return _context8.stop();
513
619
  }
514
- }, _callee7, this, [[4, 9]]);
620
+ }, _callee8, this, [[4, 9]]);
515
621
  }));
516
622
  function destroy() {
517
623
  return _destroy.apply(this, arguments);
@@ -1103,7 +1209,7 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
1103
1209
  }, {
1104
1210
  key: "getResourceBookingList",
1105
1211
  value: function () {
1106
- var _getResourceBookingList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(currentTime) {
1212
+ var _getResourceBookingList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(currentTime) {
1107
1213
  var _resourceResponse$dat,
1108
1214
  _resourceResponse$dat2,
1109
1215
  _this8 = this;
@@ -1117,28 +1223,28 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
1117
1223
  rawBookingMap,
1118
1224
  bookingMap,
1119
1225
  list,
1120
- _args8 = arguments;
1121
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1122
- while (1) switch (_context8.prev = _context8.next) {
1226
+ _args9 = arguments;
1227
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1228
+ while (1) switch (_context9.prev = _context9.next) {
1123
1229
  case 0:
1124
- bookingList = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : [];
1125
- deviceTime = _args8.length > 2 && _args8[2] !== undefined ? _args8[2] : currentTime;
1230
+ bookingList = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : [];
1231
+ deviceTime = _args9.length > 2 && _args9[2] !== undefined ? _args9[2] : currentTime;
1126
1232
  // currentTime 约定为完整 datetime;非法值直接返回空,避免误判
1127
1233
  current = dayjs(currentTime);
1128
1234
  if (current.isValid()) {
1129
- _context8.next = 5;
1235
+ _context9.next = 5;
1130
1236
  break;
1131
1237
  }
1132
- return _context8.abrupt("return", []);
1238
+ return _context9.abrupt("return", []);
1133
1239
  case 5:
1134
1240
  deviceCurrent = dayjs(deviceTime);
1135
1241
  if (deviceCurrent.isValid()) {
1136
- _context8.next = 8;
1242
+ _context9.next = 8;
1137
1243
  break;
1138
1244
  }
1139
- return _context8.abrupt("return", []);
1245
+ return _context9.abrupt("return", []);
1140
1246
  case 8:
1141
- _context8.next = 10;
1247
+ _context9.next = 10;
1142
1248
  return this.request.get('/shop/form/resource/page', {
1143
1249
  skip: 1,
1144
1250
  num: 999
@@ -1149,13 +1255,13 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
1149
1255
  isShopApi: true
1150
1256
  });
1151
1257
  case 10:
1152
- resourceResponse = _context8.sent;
1258
+ resourceResponse = _context9.sent;
1153
1259
  resourceList = (_resourceResponse$dat = resourceResponse === null || resourceResponse === void 0 || (_resourceResponse$dat2 = resourceResponse.data) === null || _resourceResponse$dat2 === void 0 ? void 0 : _resourceResponse$dat2.list) !== null && _resourceResponse$dat !== void 0 ? _resourceResponse$dat : [];
1154
1260
  if (!(!Array.isArray(resourceList) || resourceList.length === 0)) {
1155
- _context8.next = 14;
1261
+ _context9.next = 14;
1156
1262
  break;
1157
1263
  }
1158
- return _context8.abrupt("return", []);
1264
+ return _context9.abrupt("return", []);
1159
1265
  case 14:
1160
1266
  // 全局先做 booking 标准化 + start_time 升序,后续映射直接复用
1161
1267
  normalizedBookings = this.normalizeResourceBookings(current, deviceCurrent, bookingList); // 建立 resourceId -> bookings[] 倒排索引,加速资源匹配
@@ -1190,14 +1296,14 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
1190
1296
  list: list === null || list === void 0 ? void 0 : list.length
1191
1297
  }
1192
1298
  });
1193
- return _context8.abrupt("return", list);
1299
+ return _context9.abrupt("return", list);
1194
1300
  case 20:
1195
1301
  case "end":
1196
- return _context8.stop();
1302
+ return _context9.stop();
1197
1303
  }
1198
- }, _callee8, this);
1304
+ }, _callee9, this);
1199
1305
  }));
1200
- function getResourceBookingList(_x10) {
1306
+ function getResourceBookingList(_x11) {
1201
1307
  return _getResourceBookingList.apply(this, arguments);
1202
1308
  }
1203
1309
  return getResourceBookingList;
@@ -1205,30 +1311,30 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
1205
1311
  }, {
1206
1312
  key: "getResourceBookingItem",
1207
1313
  value: function () {
1208
- var _getResourceBookingItem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
1314
+ var _getResourceBookingItem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
1209
1315
  var _resourceResponse$dat3,
1210
1316
  _resourceResponse$dat4,
1211
1317
  _this9 = this,
1212
1318
  _params$bookingList;
1213
1319
  var current, deviceCurrent, resourceResponse, resourceList, targetResource, resourceId, matchedBookingList, statsBookingList, completedBookingList, unpaidBookingList, bookings, completedBookings, unpaidBookings, orderCount, bookingCount, compeleteBookingCount;
1214
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1215
- while (1) switch (_context9.prev = _context9.next) {
1320
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1321
+ while (1) switch (_context10.prev = _context10.next) {
1216
1322
  case 0:
1217
1323
  current = dayjs(params.currentTime);
1218
1324
  if (current.isValid()) {
1219
- _context9.next = 3;
1325
+ _context10.next = 3;
1220
1326
  break;
1221
1327
  }
1222
- return _context9.abrupt("return", null);
1328
+ return _context10.abrupt("return", null);
1223
1329
  case 3:
1224
1330
  deviceCurrent = dayjs(params.deviceTime || params.currentTime);
1225
1331
  if (deviceCurrent.isValid()) {
1226
- _context9.next = 6;
1332
+ _context10.next = 6;
1227
1333
  break;
1228
1334
  }
1229
- return _context9.abrupt("return", null);
1335
+ return _context10.abrupt("return", null);
1230
1336
  case 6:
1231
- _context9.next = 8;
1337
+ _context10.next = 8;
1232
1338
  return this.request.get('/shop/form/resource/page', {
1233
1339
  skip: 1,
1234
1340
  num: 999
@@ -1239,22 +1345,22 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
1239
1345
  isShopApi: true
1240
1346
  });
1241
1347
  case 8:
1242
- resourceResponse = _context9.sent;
1348
+ resourceResponse = _context10.sent;
1243
1349
  resourceList = (_resourceResponse$dat3 = resourceResponse === null || resourceResponse === void 0 || (_resourceResponse$dat4 = resourceResponse.data) === null || _resourceResponse$dat4 === void 0 ? void 0 : _resourceResponse$dat4.list) !== null && _resourceResponse$dat3 !== void 0 ? _resourceResponse$dat3 : [];
1244
1350
  if (!(!Array.isArray(resourceList) || resourceList.length === 0)) {
1245
- _context9.next = 12;
1351
+ _context10.next = 12;
1246
1352
  break;
1247
1353
  }
1248
- return _context9.abrupt("return", null);
1354
+ return _context10.abrupt("return", null);
1249
1355
  case 12:
1250
1356
  targetResource = resourceList.find(function (resource) {
1251
1357
  return String(_this9.getResourceId(resource)) === String(params.resourceId);
1252
1358
  });
1253
1359
  if (targetResource) {
1254
- _context9.next = 15;
1360
+ _context10.next = 15;
1255
1361
  break;
1256
1362
  }
1257
- return _context9.abrupt("return", null);
1363
+ return _context10.abrupt("return", null);
1258
1364
  case 15:
1259
1365
  resourceId = this.getResourceId(targetResource);
1260
1366
  matchedBookingList = params.bookingList.filter(function (booking) {
@@ -1305,7 +1411,7 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
1305
1411
  compeleteBookingCount: compeleteBookingCount
1306
1412
  }
1307
1413
  });
1308
- return _context9.abrupt("return", _objectSpread(_objectSpread({}, targetResource), {}, {
1414
+ return _context10.abrupt("return", _objectSpread(_objectSpread({}, targetResource), {}, {
1309
1415
  resource_id: resourceId,
1310
1416
  orderCount: orderCount,
1311
1417
  bookingCount: bookingCount,
@@ -1316,11 +1422,11 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
1316
1422
  }));
1317
1423
  case 28:
1318
1424
  case "end":
1319
- return _context9.stop();
1425
+ return _context10.stop();
1320
1426
  }
1321
- }, _callee9, this);
1427
+ }, _callee10, this);
1322
1428
  }));
1323
- function getResourceBookingItem(_x11) {
1429
+ function getResourceBookingItem(_x12) {
1324
1430
  return _getResourceBookingItem.apply(this, arguments);
1325
1431
  }
1326
1432
  return getResourceBookingItem;
@@ -56,6 +56,17 @@ export interface SalesPrintLocalOrderReceiptOptions {
56
56
  /** 当前销售入口;缺失或为 system 时按 pos 处理。 */
57
57
  channel?: string;
58
58
  }
59
+ /** Order and delivery identity supplied by the native cloud-print listener. */
60
+ export interface CloudOrderInvoiceRequest {
61
+ shop_id: string | number;
62
+ order_id: string | number;
63
+ message_uuid: string;
64
+ channel: string;
65
+ }
66
+ export interface CloudOrderInvoiceResult {
67
+ /** DeviceTask accepted for this message on the current device. */
68
+ task_uuid: string;
69
+ }
59
70
  /**
60
71
  * Sales 解决方案状态
61
72
  *
@@ -90,6 +101,7 @@ export interface SalesModuleAPI {
90
101
  changeBookingStatus: (params: ChangeBookingStatusParams) => Promise<any>;
91
102
  /** 按本地订单标识打印小票;本地未命中时由 OS Server 负责远端兜底。 */
92
103
  printLocalOrderReceipt: <T = any>(lookup: string | number, options: SalesPrintLocalOrderReceiptOptions) => Promise<T>;
104
+ printCloudOrderInvoice: (request: CloudOrderInvoiceRequest) => Promise<CloudOrderInvoiceResult>;
93
105
  /** 清除 Legacy Sales 独立维护的 Documents OpenData 缓存。 */
94
106
  clearOpenDataCache: () => void;
95
107
  /** 获取资源维度的预约占用列表 */
@@ -14,6 +14,8 @@ export var SalesHooks = /*#__PURE__*/function (SalesHooks) {
14
14
  * 当前不要直接把 OrderData 当作最终 UI 数据结构。
15
15
  */
16
16
 
17
+ /** Order and delivery identity supplied by the native cloud-print listener. */
18
+
17
19
  /**
18
20
  * Sales 解决方案状态
19
21
  *
@@ -91,6 +91,7 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
91
91
  private availabilityProjectionRefreshInFlight;
92
92
  private availabilityRemoteOccupancyCache;
93
93
  private availabilitySessionResourceCache;
94
+ private readonly fetchAvailabilitySessionResources;
94
95
  private availabilityRemoteResourceQueryInFlight;
95
96
  private availabilityRemoteResourceQuerySequence;
96
97
  private availabilityRemoteResourceEpoch;