@pisell/pisellos 2.3.10 → 2.3.12

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.
@@ -1,9 +0,0 @@
1
- // 导出评估器
2
- export { PromotionEvaluator } from "./evaluator";
3
-
4
- // 导出适配器
5
- export { PromotionAdapter } from "./adapter";
6
- export { default } from "./adapter";
7
-
8
- // 导出策略配置示例常量
9
- export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY } from "./examples";
@@ -4640,7 +4640,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4640
4640
  this.logInfo('runSubmitTempOrder: 提交成功', {
4641
4641
  submittedOrderId: submittedOrderId,
4642
4642
  result: result,
4643
- tempOrder: tempOrder
4643
+ tempOrder: _objectSpread(_objectSpread({}, tempOrder), {}, {
4644
+ _extend: undefined
4645
+ })
4644
4646
  });
4645
4647
  if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
4646
4648
  _context32.next = 56;
@@ -1029,7 +1029,8 @@ var Server = /*#__PURE__*/function () {
1029
1029
  checkoutData: checkoutData,
1030
1030
  order: printableOrder,
1031
1031
  response: null,
1032
- requireFullyPaid: false
1032
+ requireFullyPaid: false,
1033
+ isManualPrint: true
1033
1034
  });
1034
1035
  case 27:
1035
1036
  printResult = _context16.sent;
@@ -4235,10 +4236,12 @@ var Server = /*#__PURE__*/function () {
4235
4236
  action: 'print_all',
4236
4237
  device_id: (_params$deviceId = params.deviceId) !== null && _params$deviceId !== void 0 ? _params$deviceId : deviceId,
4237
4238
  payload: {
4238
- type: params.receiptOnly ? '0' : '99',
4239
+ type: params.isManualPrint ? '0' : '99',
4239
4240
  data: params.receiptOnly ? {
4240
4241
  order_id: printIdentity,
4241
- small_ticket_data: (_params$syncedOrder = params.syncedOrder) === null || _params$syncedOrder === void 0 || (_params$syncedOrder = _params$syncedOrder.payment_info) === null || _params$syncedOrder === void 0 ? void 0 : _params$syncedOrder.small_ticket_data
4242
+ small_ticket_data: (_params$syncedOrder = params.syncedOrder) === null || _params$syncedOrder === void 0 || (_params$syncedOrder = _params$syncedOrder.payment_info) === null || _params$syncedOrder === void 0 ? void 0 : _params$syncedOrder.small_ticket_data,
4243
+ skip_wristband: true,
4244
+ skip_voucher: true
4242
4245
  } : {
4243
4246
  order_id: printIdentity,
4244
4247
  machine_code_print_info: (_params$syncedOrder2 = params.syncedOrder) === null || _params$syncedOrder2 === void 0 || (_params$syncedOrder2 = _params$syncedOrder2.payment_info) === null || _params$syncedOrder2 === void 0 ? void 0 : _params$syncedOrder2.machine_code_print_info,
@@ -4249,7 +4252,7 @@ var Server = /*#__PURE__*/function () {
4249
4252
  idempotency_key: this.buildPrintOtherReceiptIdempotencyKey(params.syncedOrder, {
4250
4253
  receiptOnly: params.receiptOnly
4251
4254
  }),
4252
- name: '打印转发',
4255
+ name: 'PRINT_V1',
4253
4256
  source: 'server',
4254
4257
  source_type: 'order',
4255
4258
  source_id: printIdentity
@@ -4329,7 +4332,8 @@ var Server = /*#__PURE__*/function () {
4329
4332
  checkoutData: params.checkoutData,
4330
4333
  syncedOrder: printableOrder,
4331
4334
  response: params.response,
4332
- receiptOnly: true
4335
+ receiptOnly: true,
4336
+ isManualPrint: params.isManualPrint
4333
4337
  });
4334
4338
  case 10:
4335
4339
  return _context46.abrupt("return", {
@@ -30,7 +30,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
30
30
  protected defaultVersion: string;
31
31
  isSolution: boolean;
32
32
  protected initializeOptions: ModuleOptions;
33
- private logger;
33
+ protected logger: any;
34
34
  protected appPlugin: AppPlugin;
35
35
  protected store: BaseSalesState;
36
36
  protected otherParams: Record<string, any>;
@@ -322,7 +322,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
322
322
  * 获取当前的客户搜索条件
323
323
  * @returns 当前搜索条件
324
324
  */
325
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
325
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
326
326
  /**
327
327
  * 获取客户列表状态(包含滚动加载相关状态)
328
328
  * @returns 客户状态
@@ -551,6 +551,13 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
551
551
  setOtherParams(params: Record<string, any>, { cover }?: {
552
552
  cover?: boolean;
553
553
  }): Promise<void>;
554
+ private getDeviceTaskPlugin;
555
+ handlePrintWristband(params: {
556
+ voucher_ids: number[];
557
+ }): Promise<void>;
558
+ handleCheckIn(params: {
559
+ voucher_ids: number[];
560
+ }): Promise<void>;
554
561
  /**
555
562
  * 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
556
563
  * 再清理 BookingTicket 自有资源(scan 监听 + scan 内存缓存)。
@@ -49,6 +49,7 @@ import { buildNormalProductCacheItemFromOrderLine as buildNormalProductCacheItem
49
49
  import { buildProductOptionStringFromOrderLine } from "../../modules/BookingContext/utils/orderLineDisplay";
50
50
  import { applyBookingsStatus, applyChildBookingStatus, resolveScheduleId, resolveStatusAfterTransition, restoreBookingsStatus, restoreChildBookingStatus } from "./utils/bookingStatus";
51
51
  import { resolveBestAddTimePlan as _resolveBestAddTimePlan } from "./utils/resolveBestAddTimePlan";
52
+ import { createUuidV4 } from "../../modules/Order/utils";
52
53
  var OPEN_DATA_SECTION_CODES = ['sale', 'reservation', 'fulfillment', 'menu', 'workflow'];
53
54
  var OPEN_DATA_CACHE_TTL = 5 * 60 * 1000;
54
55
 
@@ -2586,6 +2587,92 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2586
2587
  }
2587
2588
  return setOtherParams;
2588
2589
  }()
2590
+ }, {
2591
+ key: "getDeviceTaskPlugin",
2592
+ value: function getDeviceTaskPlugin() {
2593
+ var _app$getApp;
2594
+ var app = this.core.getPlugin('app');
2595
+ return (app === null || app === void 0 || (_app$getApp = app.getApp()) === null || _app$getApp === void 0 ? void 0 : _app$getApp.getPlugin('deviceTask')) || null;
2596
+ }
2597
+
2598
+ // 打印手环,单个或批量都可以
2599
+ }, {
2600
+ key: "handlePrintWristband",
2601
+ value: function () {
2602
+ var _handlePrintWristband = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
2603
+ var deviceTask, deviceId, idempotencyKey;
2604
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2605
+ while (1) switch (_context32.prev = _context32.next) {
2606
+ case 0:
2607
+ deviceTask = this.getDeviceTaskPlugin();
2608
+ if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
2609
+ _context32.next = 4;
2610
+ break;
2611
+ }
2612
+ this.logger.addLog({
2613
+ type: 'info',
2614
+ title: '[BookingTicket] handlePrintWristband: deviceTask.dispatch 不可用',
2615
+ metadata: {
2616
+ voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids]
2617
+ }
2618
+ });
2619
+ return _context32.abrupt("return");
2620
+ case 4:
2621
+ _context32.next = 6;
2622
+ return this.getShortNumberOrDeviceId();
2623
+ case 6:
2624
+ deviceId = _context32.sent;
2625
+ idempotencyKey = createUuidV4();
2626
+ deviceTask.dispatch({
2627
+ action: 'print_all',
2628
+ device_id: deviceId,
2629
+ payload: {
2630
+ type: 'WRISTBAND',
2631
+ data: {
2632
+ order_id: this.getOrderIdentity(),
2633
+ voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids]
2634
+ }
2635
+ },
2636
+ idempotency_key: idempotencyKey,
2637
+ name: 'PRINT_V1',
2638
+ source: 'bookingTicket',
2639
+ source_type: 'handlePrintWristband',
2640
+ source_id: idempotencyKey
2641
+ });
2642
+ case 9:
2643
+ case "end":
2644
+ return _context32.stop();
2645
+ }
2646
+ }, _callee32, this);
2647
+ }));
2648
+ function handlePrintWristband(_x23) {
2649
+ return _handlePrintWristband.apply(this, arguments);
2650
+ }
2651
+ return handlePrintWristband;
2652
+ }() // 触发 checkIn
2653
+ }, {
2654
+ key: "handleCheckIn",
2655
+ value: function () {
2656
+ var _handleCheckIn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
2657
+ return _regeneratorRuntime().wrap(function _callee33$(_context33) {
2658
+ while (1) switch (_context33.prev = _context33.next) {
2659
+ case 0:
2660
+ // 优先修改 tempOrder 中 vouchers 的是否 checkIn 字段(需要同步数据库)
2661
+ // 然后触发 checkIn 接口
2662
+ this.request.post('/shop/machinecode/batch-metadata', {
2663
+ voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids]
2664
+ });
2665
+ case 1:
2666
+ case "end":
2667
+ return _context33.stop();
2668
+ }
2669
+ }, _callee33, this);
2670
+ }));
2671
+ function handleCheckIn(_x24) {
2672
+ return _handleCheckIn.apply(this, arguments);
2673
+ }
2674
+ return handleCheckIn;
2675
+ }()
2589
2676
  /**
2590
2677
  * 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
2591
2678
  * 再清理 BookingTicket 自有资源(scan 监听 + scan 内存缓存)。
@@ -2593,12 +2680,12 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2593
2680
  }, {
2594
2681
  key: "destroy",
2595
2682
  value: (function () {
2596
- var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
2683
+ var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
2597
2684
  var _this$scan;
2598
- return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2599
- while (1) switch (_context32.prev = _context32.next) {
2685
+ return _regeneratorRuntime().wrap(function _callee34$(_context34) {
2686
+ while (1) switch (_context34.prev = _context34.next) {
2600
2687
  case 0:
2601
- _context32.next = 2;
2688
+ _context34.next = 2;
2602
2689
  return _get(_getPrototypeOf(BookingTicketImpl.prototype), "destroy", this).call(this);
2603
2690
  case 2:
2604
2691
  try {
@@ -2609,9 +2696,9 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2609
2696
  scanCache.clear();
2610
2697
  case 4:
2611
2698
  case "end":
2612
- return _context32.stop();
2699
+ return _context34.stop();
2613
2700
  }
2614
- }, _callee32, this);
2701
+ }, _callee34, this);
2615
2702
  }));
2616
2703
  function destroy() {
2617
2704
  return _destroy.apply(this, arguments);
@@ -896,7 +896,6 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
896
896
  completedBookingList = matchedBookingList.filter(function (booking) {
897
897
  return _this7.getBookingAppointmentStatus(booking) === 'completed';
898
898
  });
899
- debugger;
900
899
  unpaidBookingList = matchedBookingList.filter(function (booking) {
901
900
  return _this7.getBookingOrderPaymentStatus(booking) === 'unpaid' || _this7.getBookingOrderPaymentStatus(booking) === 'payment_processing';
902
901
  });
@@ -941,7 +940,7 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
941
940
  completedBookings: completedBookings,
942
941
  unpaidBookings: unpaidBookings
943
942
  }));
944
- case 29:
943
+ case 28:
945
944
  case "end":
946
945
  return _context6.stop();
947
946
  }
@@ -3454,7 +3454,10 @@ var OrderModule = class extends import_BaseModule.BaseModule {
3454
3454
  this.logInfo("runSubmitTempOrder: 提交成功", {
3455
3455
  submittedOrderId,
3456
3456
  result,
3457
- tempOrder
3457
+ tempOrder: {
3458
+ ...tempOrder,
3459
+ _extend: void 0
3460
+ }
3458
3461
  });
3459
3462
  if (submittedOrderId !== null && submittedOrderId !== void 0) {
3460
3463
  tempOrder.order_id = submittedOrderId;
@@ -639,7 +639,8 @@ var Server = class {
639
639
  checkoutData,
640
640
  order: printableOrder,
641
641
  response: null,
642
- requireFullyPaid: false
642
+ requireFullyPaid: false,
643
+ isManualPrint: true
643
644
  });
644
645
  return {
645
646
  code: 200,
@@ -2656,10 +2657,12 @@ var Server = class {
2656
2657
  action: "print_all",
2657
2658
  device_id: params.deviceId ?? deviceId,
2658
2659
  payload: {
2659
- type: params.receiptOnly ? "0" : "99",
2660
+ type: params.isManualPrint ? "0" : "99",
2660
2661
  data: params.receiptOnly ? {
2661
2662
  order_id: printIdentity,
2662
- small_ticket_data: (_b = (_a = params.syncedOrder) == null ? void 0 : _a.payment_info) == null ? void 0 : _b.small_ticket_data
2663
+ small_ticket_data: (_b = (_a = params.syncedOrder) == null ? void 0 : _a.payment_info) == null ? void 0 : _b.small_ticket_data,
2664
+ skip_wristband: true,
2665
+ skip_voucher: true
2663
2666
  } : {
2664
2667
  order_id: printIdentity,
2665
2668
  machine_code_print_info: (_d = (_c = params.syncedOrder) == null ? void 0 : _c.payment_info) == null ? void 0 : _d.machine_code_print_info,
@@ -2670,7 +2673,7 @@ var Server = class {
2670
2673
  idempotency_key: this.buildPrintOtherReceiptIdempotencyKey(params.syncedOrder, {
2671
2674
  receiptOnly: params.receiptOnly
2672
2675
  }),
2673
- name: "打印转发",
2676
+ name: "PRINT_V1",
2674
2677
  source: "server",
2675
2678
  source_type: "order",
2676
2679
  source_id: printIdentity
@@ -2710,7 +2713,8 @@ var Server = class {
2710
2713
  checkoutData: params.checkoutData,
2711
2714
  syncedOrder: printableOrder,
2712
2715
  response: params.response,
2713
- receiptOnly: true
2716
+ receiptOnly: true,
2717
+ isManualPrint: params.isManualPrint
2714
2718
  });
2715
2719
  return { printed: true, order: printableOrder };
2716
2720
  }
@@ -30,7 +30,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
30
30
  protected defaultVersion: string;
31
31
  isSolution: boolean;
32
32
  protected initializeOptions: ModuleOptions;
33
- private logger;
33
+ protected logger: any;
34
34
  protected appPlugin: AppPlugin;
35
35
  protected store: BaseSalesState;
36
36
  protected otherParams: Record<string, any>;
@@ -322,7 +322,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
322
322
  * 获取当前的客户搜索条件
323
323
  * @returns 当前搜索条件
324
324
  */
325
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
325
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
326
326
  /**
327
327
  * 获取客户列表状态(包含滚动加载相关状态)
328
328
  * @returns 客户状态
@@ -551,6 +551,13 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
551
551
  setOtherParams(params: Record<string, any>, { cover }?: {
552
552
  cover?: boolean;
553
553
  }): Promise<void>;
554
+ private getDeviceTaskPlugin;
555
+ handlePrintWristband(params: {
556
+ voucher_ids: number[];
557
+ }): Promise<void>;
558
+ handleCheckIn(params: {
559
+ voucher_ids: number[];
560
+ }): Promise<void>;
554
561
  /**
555
562
  * 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
556
563
  * 再清理 BookingTicket 自有资源(scan 监听 + scan 内存缓存)。
@@ -52,6 +52,7 @@ var import_buildNormalProductCacheItemFromOrderLine = require("../../modules/Boo
52
52
  var import_orderLineDisplay = require("../../modules/BookingContext/utils/orderLineDisplay");
53
53
  var import_bookingStatus = require("./utils/bookingStatus");
54
54
  var import_resolveBestAddTimePlan = require("./utils/resolveBestAddTimePlan");
55
+ var import_utils = require("../../modules/Order/utils");
55
56
  __reExport(BookingTicket_exports, require("./types"), module.exports);
56
57
  var OPEN_DATA_SECTION_CODES = ["sale", "reservation", "fulfillment", "menu", "workflow"];
57
58
  var OPEN_DATA_CACHE_TTL = 5 * 60 * 1e3;
@@ -1505,6 +1506,49 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
1505
1506
  await this.configureIdGeneratorFromOpenData();
1506
1507
  }
1507
1508
  }
1509
+ getDeviceTaskPlugin() {
1510
+ var _a;
1511
+ const app = this.core.getPlugin("app");
1512
+ return ((_a = app == null ? void 0 : app.getApp()) == null ? void 0 : _a.getPlugin("deviceTask")) || null;
1513
+ }
1514
+ // 打印手环,单个或批量都可以
1515
+ async handlePrintWristband(params) {
1516
+ const deviceTask = this.getDeviceTaskPlugin();
1517
+ if (!(deviceTask == null ? void 0 : deviceTask.dispatch)) {
1518
+ this.logger.addLog({
1519
+ type: "info",
1520
+ title: "[BookingTicket] handlePrintWristband: deviceTask.dispatch 不可用",
1521
+ metadata: {
1522
+ voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids]
1523
+ }
1524
+ });
1525
+ return;
1526
+ }
1527
+ const deviceId = await this.getShortNumberOrDeviceId();
1528
+ const idempotencyKey = (0, import_utils.createUuidV4)();
1529
+ deviceTask.dispatch({
1530
+ action: "print_all",
1531
+ device_id: deviceId,
1532
+ payload: {
1533
+ type: "WRISTBAND",
1534
+ data: {
1535
+ order_id: this.getOrderIdentity(),
1536
+ voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids]
1537
+ }
1538
+ },
1539
+ idempotency_key: idempotencyKey,
1540
+ name: "PRINT_V1",
1541
+ source: "bookingTicket",
1542
+ source_type: "handlePrintWristband",
1543
+ source_id: idempotencyKey
1544
+ });
1545
+ }
1546
+ // 触发 checkIn
1547
+ async handleCheckIn(params) {
1548
+ this.request.post("/shop/machinecode/batch-metadata", {
1549
+ voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids]
1550
+ });
1551
+ }
1508
1552
  /**
1509
1553
  * 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
1510
1554
  * 再清理 BookingTicket 自有资源(scan 监听 + scan 内存缓存)。
@@ -631,7 +631,6 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
631
631
  const completedBookingList = matchedBookingList.filter(
632
632
  (booking) => this.getBookingAppointmentStatus(booking) === "completed"
633
633
  );
634
- debugger;
635
634
  const unpaidBookingList = matchedBookingList.filter(
636
635
  (booking) => this.getBookingOrderPaymentStatus(booking) === "unpaid" || this.getBookingOrderPaymentStatus(booking) === "payment_processing"
637
636
  );
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.10",
4
+ "version": "2.3.12",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",