@pisell/pisellos 2.3.10 → 2.3.11

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;
@@ -4235,10 +4235,12 @@ var Server = /*#__PURE__*/function () {
4235
4235
  action: 'print_all',
4236
4236
  device_id: (_params$deviceId = params.deviceId) !== null && _params$deviceId !== void 0 ? _params$deviceId : deviceId,
4237
4237
  payload: {
4238
- type: params.receiptOnly ? '0' : '99',
4238
+ type: '99',
4239
4239
  data: params.receiptOnly ? {
4240
4240
  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
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
+ skip_wristband: true,
4243
+ skip_voucher: true
4242
4244
  } : {
4243
4245
  order_id: printIdentity,
4244
4246
  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 +4251,7 @@ var Server = /*#__PURE__*/function () {
4249
4251
  idempotency_key: this.buildPrintOtherReceiptIdempotencyKey(params.syncedOrder, {
4250
4252
  receiptOnly: params.receiptOnly
4251
4253
  }),
4252
- name: '打印转发',
4254
+ name: 'PRINT_V1',
4253
4255
  source: 'server',
4254
4256
  source_type: 'order',
4255
4257
  source_id: printIdentity
@@ -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>;
@@ -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,85 @@ 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;
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
+ deviceTask.dispatch({
2626
+ action: 'print_v1',
2627
+ device_id: deviceId,
2628
+ payload: {
2629
+ type: 'WRISTBAND',
2630
+ data: {
2631
+ order_id: this.getOrderIdentity(),
2632
+ voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids]
2633
+ }
2634
+ },
2635
+ idempotency_key: createUuidV4(),
2636
+ name: 'PRINT_V1',
2637
+ source: 'server',
2638
+ source_type: 'order',
2639
+ source_id: createUuidV4()
2640
+ });
2641
+ case 8:
2642
+ case "end":
2643
+ return _context32.stop();
2644
+ }
2645
+ }, _callee32, this);
2646
+ }));
2647
+ function handlePrintWristband(_x23) {
2648
+ return _handlePrintWristband.apply(this, arguments);
2649
+ }
2650
+ return handlePrintWristband;
2651
+ }() // 触发 checkIn
2652
+ }, {
2653
+ key: "handleCheckIn",
2654
+ value: function () {
2655
+ var _handleCheckIn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
2656
+ return _regeneratorRuntime().wrap(function _callee33$(_context33) {
2657
+ while (1) switch (_context33.prev = _context33.next) {
2658
+ case 0:
2659
+ case "end":
2660
+ return _context33.stop();
2661
+ }
2662
+ }, _callee33);
2663
+ }));
2664
+ function handleCheckIn(_x24) {
2665
+ return _handleCheckIn.apply(this, arguments);
2666
+ }
2667
+ return handleCheckIn;
2668
+ }()
2589
2669
  /**
2590
2670
  * 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
2591
2671
  * 再清理 BookingTicket 自有资源(scan 监听 + scan 内存缓存)。
@@ -2593,12 +2673,12 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2593
2673
  }, {
2594
2674
  key: "destroy",
2595
2675
  value: (function () {
2596
- var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
2676
+ var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
2597
2677
  var _this$scan;
2598
- return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2599
- while (1) switch (_context32.prev = _context32.next) {
2678
+ return _regeneratorRuntime().wrap(function _callee34$(_context34) {
2679
+ while (1) switch (_context34.prev = _context34.next) {
2600
2680
  case 0:
2601
- _context32.next = 2;
2681
+ _context34.next = 2;
2602
2682
  return _get(_getPrototypeOf(BookingTicketImpl.prototype), "destroy", this).call(this);
2603
2683
  case 2:
2604
2684
  try {
@@ -2609,9 +2689,9 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2609
2689
  scanCache.clear();
2610
2690
  case 4:
2611
2691
  case "end":
2612
- return _context32.stop();
2692
+ return _context34.stop();
2613
2693
  }
2614
- }, _callee32, this);
2694
+ }, _callee34, this);
2615
2695
  }));
2616
2696
  function destroy() {
2617
2697
  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
  }
@@ -1,49 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/model/strategy/adapter/promotion/index.ts
30
- var promotion_exports = {};
31
- __export(promotion_exports, {
32
- BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
33
- PromotionAdapter: () => import_adapter.PromotionAdapter,
34
- PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
35
- X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
36
- default: () => import_adapter2.default
37
- });
38
- module.exports = __toCommonJS(promotion_exports);
39
- var import_evaluator = require("./evaluator");
40
- var import_adapter = require("./adapter");
41
- var import_adapter2 = __toESM(require("./adapter"));
42
- var import_examples = require("./examples");
43
- // Annotate the CommonJS export names for ESM import in node:
44
- 0 && (module.exports = {
45
- BUY_X_GET_Y_FREE_STRATEGY,
46
- PromotionAdapter,
47
- PromotionEvaluator,
48
- X_ITEMS_FOR_Y_PRICE_STRATEGY
49
- });
@@ -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;
@@ -2656,10 +2656,12 @@ var Server = class {
2656
2656
  action: "print_all",
2657
2657
  device_id: params.deviceId ?? deviceId,
2658
2658
  payload: {
2659
- type: params.receiptOnly ? "0" : "99",
2659
+ type: "99",
2660
2660
  data: params.receiptOnly ? {
2661
2661
  order_id: printIdentity,
2662
- small_ticket_data: (_b = (_a = params.syncedOrder) == null ? void 0 : _a.payment_info) == null ? void 0 : _b.small_ticket_data
2662
+ small_ticket_data: (_b = (_a = params.syncedOrder) == null ? void 0 : _a.payment_info) == null ? void 0 : _b.small_ticket_data,
2663
+ skip_wristband: true,
2664
+ skip_voucher: true
2663
2665
  } : {
2664
2666
  order_id: printIdentity,
2665
2667
  machine_code_print_info: (_d = (_c = params.syncedOrder) == null ? void 0 : _c.payment_info) == null ? void 0 : _d.machine_code_print_info,
@@ -2670,7 +2672,7 @@ var Server = class {
2670
2672
  idempotency_key: this.buildPrintOtherReceiptIdempotencyKey(params.syncedOrder, {
2671
2673
  receiptOnly: params.receiptOnly
2672
2674
  }),
2673
- name: "打印转发",
2675
+ name: "PRINT_V1",
2674
2676
  source: "server",
2675
2677
  source_type: "order",
2676
2678
  source_id: printIdentity
@@ -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>;
@@ -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,45 @@ 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
+ deviceTask.dispatch({
1529
+ action: "print_v1",
1530
+ device_id: deviceId,
1531
+ payload: {
1532
+ type: "WRISTBAND",
1533
+ data: {
1534
+ order_id: this.getOrderIdentity(),
1535
+ voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids]
1536
+ }
1537
+ },
1538
+ idempotency_key: (0, import_utils.createUuidV4)(),
1539
+ name: "PRINT_V1",
1540
+ source: "server",
1541
+ source_type: "order",
1542
+ source_id: (0, import_utils.createUuidV4)()
1543
+ });
1544
+ }
1545
+ // 触发 checkIn
1546
+ async handleCheckIn(params) {
1547
+ }
1508
1548
  /**
1509
1549
  * 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
1510
1550
  * 再清理 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.11",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",