@pisell/pisellos 2.2.152 → 2.2.154

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 (92) hide show
  1. package/dist/core/index.js +1 -0
  2. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  3. package/dist/modules/Cart/utils/cartProduct.js +1 -1
  4. package/dist/modules/Discount/index.d.ts +6 -2
  5. package/dist/modules/Discount/index.js +14 -8
  6. package/dist/modules/Order/index.d.ts +2 -0
  7. package/dist/modules/Order/index.js +234 -161
  8. package/dist/modules/Order/types.d.ts +19 -0
  9. package/dist/modules/Order/utils.js +7 -6
  10. package/dist/modules/Payment/index.d.ts +4 -0
  11. package/dist/modules/Payment/index.js +567 -505
  12. package/dist/modules/Payment/types.d.ts +29 -9
  13. package/dist/modules/SalesSummary/index.d.ts +7 -5
  14. package/dist/modules/SalesSummary/index.js +35 -11
  15. package/dist/plugins/app.d.ts +2 -0
  16. package/dist/server/index.d.ts +2 -5
  17. package/dist/server/index.js +58 -66
  18. package/dist/server/modules/index.d.ts +1 -1
  19. package/dist/server/modules/products/index.d.ts +12 -1
  20. package/dist/server/modules/products/index.js +169 -78
  21. package/dist/server/modules/products/types.d.ts +11 -0
  22. package/dist/server/modules/products/types.js +4 -0
  23. package/dist/server/utils/product.js +2 -2
  24. package/dist/solution/BaseSales/index.d.ts +26 -2
  25. package/dist/solution/BaseSales/index.js +342 -112
  26. package/dist/solution/BaseSales/types.d.ts +4 -4
  27. package/dist/solution/BaseSales/types.js +4 -4
  28. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +62 -0
  29. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +116 -0
  30. package/dist/solution/BaseSales/utils.js +3 -3
  31. package/dist/solution/BookingByStep/index.d.ts +1 -1
  32. package/dist/solution/BookingTicket/index.d.ts +11 -13
  33. package/dist/solution/BookingTicket/index.js +23 -37
  34. package/dist/solution/BookingTicket/types.d.ts +9 -6
  35. package/dist/solution/BookingTicket/types.js +6 -3
  36. package/dist/solution/BookingTicket/utils/cartView.d.ts +7 -12
  37. package/dist/solution/BookingTicket/utils/cartView.js +52 -14
  38. package/dist/solution/BookingTicket/utils/orderCustomer.d.ts +4 -0
  39. package/dist/solution/BookingTicket/utils/orderCustomer.js +31 -0
  40. package/dist/solution/Sales/index.d.ts +3 -0
  41. package/dist/solution/Sales/index.js +85 -43
  42. package/dist/solution/Sales/types.d.ts +3 -0
  43. package/dist/solution/ScanOrder/types.d.ts +4 -4
  44. package/dist/solution/ScanOrder/types.js +4 -4
  45. package/dist/solution/ScanOrder/utils.js +3 -3
  46. package/dist/solution/ShopDiscount/index.d.ts +2 -1
  47. package/dist/solution/ShopDiscount/index.js +32 -20
  48. package/dist/solution/ShopDiscount/types.d.ts +1 -0
  49. package/lib/core/index.js +1 -0
  50. package/lib/modules/Cart/utils/cartProduct.js +1 -1
  51. package/lib/modules/Discount/index.d.ts +6 -2
  52. package/lib/modules/Discount/index.js +3 -1
  53. package/lib/modules/Order/index.d.ts +2 -0
  54. package/lib/modules/Order/index.js +40 -8
  55. package/lib/modules/Order/types.d.ts +19 -0
  56. package/lib/modules/Order/utils.js +4 -2
  57. package/lib/modules/Payment/index.d.ts +4 -0
  58. package/lib/modules/Payment/index.js +26 -2
  59. package/lib/modules/Payment/types.d.ts +29 -9
  60. package/lib/modules/SalesSummary/index.d.ts +7 -5
  61. package/lib/modules/SalesSummary/index.js +29 -9
  62. package/lib/plugins/app.d.ts +2 -0
  63. package/lib/server/index.d.ts +2 -5
  64. package/lib/server/index.js +38 -58
  65. package/lib/server/modules/index.d.ts +1 -1
  66. package/lib/server/modules/products/index.d.ts +12 -1
  67. package/lib/server/modules/products/index.js +69 -9
  68. package/lib/server/modules/products/types.d.ts +11 -0
  69. package/lib/server/utils/product.js +2 -2
  70. package/lib/solution/BaseSales/index.d.ts +26 -2
  71. package/lib/solution/BaseSales/index.js +169 -3
  72. package/lib/solution/BaseSales/types.d.ts +4 -4
  73. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +62 -0
  74. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +155 -0
  75. package/lib/solution/BaseSales/utils.js +3 -3
  76. package/lib/solution/BookingByStep/index.d.ts +1 -1
  77. package/lib/solution/BookingTicket/index.d.ts +11 -13
  78. package/lib/solution/BookingTicket/index.js +17 -27
  79. package/lib/solution/BookingTicket/types.d.ts +9 -6
  80. package/lib/solution/BookingTicket/utils/cartView.d.ts +7 -12
  81. package/lib/solution/BookingTicket/utils/cartView.js +44 -18
  82. package/lib/solution/BookingTicket/utils/orderCustomer.d.ts +4 -0
  83. package/lib/solution/BookingTicket/utils/orderCustomer.js +58 -0
  84. package/lib/solution/Sales/index.d.ts +3 -0
  85. package/lib/solution/Sales/index.js +50 -15
  86. package/lib/solution/Sales/types.d.ts +3 -0
  87. package/lib/solution/ScanOrder/types.d.ts +4 -4
  88. package/lib/solution/ScanOrder/utils.js +3 -3
  89. package/lib/solution/ShopDiscount/index.d.ts +2 -1
  90. package/lib/solution/ShopDiscount/index.js +10 -4
  91. package/lib/solution/ShopDiscount/types.d.ts +1 -0
  92. package/package.json +1 -1
@@ -254,6 +254,37 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
254
254
  var _a;
255
255
  return String(((_a = booking.order) == null ? void 0 : _a.payment_status) ?? "");
256
256
  }
257
+ countBookingOrders(bookings) {
258
+ const orderIds = /* @__PURE__ */ new Set();
259
+ bookings.forEach((booking) => {
260
+ var _a;
261
+ const orderId = booking.order_id ?? ((_a = booking.order) == null ? void 0 : _a.order_id);
262
+ if (orderId === void 0 || orderId === null)
263
+ return;
264
+ orderIds.add(String(orderId));
265
+ });
266
+ return orderIds.size;
267
+ }
268
+ countCompletedBookings(bookings) {
269
+ return bookings.filter((booking) => this.getBookingAppointmentStatus(booking) === "completed").length;
270
+ }
271
+ groupBookingsByResource(bookingList) {
272
+ const bookingMap = /* @__PURE__ */ new Map();
273
+ bookingList.forEach((booking) => {
274
+ if (!Array.isArray(booking.resources))
275
+ return;
276
+ booking.resources.forEach((resource) => {
277
+ const relationId = resource == null ? void 0 : resource.relation_id;
278
+ if (relationId === void 0 || relationId === null)
279
+ return;
280
+ const key = String(relationId);
281
+ const list = bookingMap.get(key) || [];
282
+ list.push(booking);
283
+ bookingMap.set(key, list);
284
+ });
285
+ });
286
+ return bookingMap;
287
+ }
257
288
  isBookingMatchedResource(booking, resourceId) {
258
289
  if (!Array.isArray(booking.resources))
259
290
  return false;
@@ -534,27 +565,22 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
534
565
  if (!Array.isArray(resourceList) || resourceList.length === 0)
535
566
  return [];
536
567
  const normalizedBookings = this.normalizeResourceBookings(current, deviceCurrent, bookingList);
537
- const bookingMap = /* @__PURE__ */ new Map();
538
- normalizedBookings.forEach((booking) => {
539
- if (!Array.isArray(booking.resources))
540
- return;
541
- booking.resources.forEach((resource) => {
542
- const relationId = resource == null ? void 0 : resource.relation_id;
543
- if (relationId === void 0 || relationId === null)
544
- return;
545
- const key = String(relationId);
546
- const list2 = bookingMap.get(key) || [];
547
- list2.push(booking);
548
- bookingMap.set(key, list2);
549
- });
550
- });
568
+ const rawBookingMap = this.groupBookingsByResource(bookingList);
569
+ const bookingMap = this.groupBookingsByResource(normalizedBookings);
551
570
  const list = resourceList.map((resource) => {
552
571
  const resourceId = this.getResourceId(resource);
572
+ const rawMatchedBookings = rawBookingMap.get(String(resourceId)) || [];
553
573
  const matchedBookings = bookingMap.get(String(resourceId)) || [];
574
+ const orderCount = this.countBookingOrders(rawMatchedBookings);
575
+ const bookingCount = rawMatchedBookings.length;
576
+ const compeleteBookingCount = this.countCompletedBookings(rawMatchedBookings);
554
577
  const bookings = this.pickBookingsForCurrentPoint(current, matchedBookings);
555
578
  return {
556
579
  ...resource,
557
580
  resource_id: resourceId,
581
+ orderCount,
582
+ bookingCount,
583
+ compeleteBookingCount,
558
584
  bookings
559
585
  };
560
586
  });
@@ -616,6 +642,9 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
616
642
  current,
617
643
  this.normalizeResourceBookings(current, deviceCurrent, unpaidBookingList)
618
644
  );
645
+ const orderCount = this.countBookingOrders(matchedBookingList);
646
+ const bookingCount = matchedBookingList.length;
647
+ const compeleteBookingCount = completedBookingList.length;
619
648
  this.logger.addLog({
620
649
  type: "info",
621
650
  title: "getResourceBookingItem",
@@ -626,12 +655,18 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
626
655
  bookingList: (_b = params.bookingList) == null ? void 0 : _b.length,
627
656
  bookings: bookings.length,
628
657
  completedBookings: completedBookings.length,
629
- unpaidBookings: unpaidBookings.length
658
+ unpaidBookings: unpaidBookings.length,
659
+ orderCount,
660
+ bookingCount,
661
+ compeleteBookingCount
630
662
  }
631
663
  });
632
664
  return {
633
665
  ...targetResource,
634
666
  resource_id: resourceId,
667
+ orderCount,
668
+ bookingCount,
669
+ compeleteBookingCount,
635
670
  bookings,
636
671
  completedBookings,
637
672
  unpaidBookings
@@ -30,6 +30,9 @@ export interface SalesResourceMatchedBooking extends Omit<BookingData, 'status'>
30
30
  }
31
31
  export interface SalesResourceBookingItem extends Omit<ResourceData, 'bookings'> {
32
32
  resource_id: ResourceId;
33
+ orderCount: number;
34
+ bookingCount: number;
35
+ compeleteBookingCount: number;
33
36
  bookings: SalesResourceMatchedBooking[];
34
37
  }
35
38
  export interface SalesResourceBookingItemWithGroups extends SalesResourceBookingItem {
@@ -85,13 +85,13 @@ export interface ScanOrderOrderProduct extends ScanOrderOrderProductIdentity {
85
85
  * 出站 payload 版本的商品行。
86
86
  *
87
87
  * 与 tempOrder 内部 `ScanOrderOrderProduct` 的字段差异:
88
- * - `product_option_item[*]`:内部为 `{ product_option_item_id, option_group_id, num, price, ... }`,
89
- * 出站由 `normalizeSubmitProduct` 重命名为 `{ option_group_item_id, option_group_id, num }`
88
+ * - `product_option_item[*]`:内部为 `{ option_group_item_id, option_group_id, num, price, ... }`,
89
+ * 出站保留 `{ option_group_item_id, option_group_id, num }`
90
90
  * (后端 checkout 协议;丢弃 `price` 等运行时辅助字段)。
91
91
  * - `product_bundle[*].option[*]`:同上重命名规则。
92
92
  *
93
- * 运行时(UI 显示、加购合并、指纹、持久化)全部消费内部字段名 `product_option_item_id`,
94
- * 仅在 SDK 提交边界做一次出站映射,不影响 opaque identity 契约。
93
+ * 运行时(UI 显示、加购合并、指纹、持久化)与提交边界统一消费字段名
94
+ * `option_group_item_id`,保持 tempOrder 与后端协议一致。
95
95
  */
96
96
  export interface ScanOrderSubmitProduct extends Omit<ScanOrderOrderProduct, '_origin' | 'identity_key'> {
97
97
  /**
@@ -349,13 +349,13 @@ function attachItemRuleLimitsToTopLevelProducts(productList, limits) {
349
349
  function buildProductLineFingerprint(productOptionItem, productBundle) {
350
350
  const optArr = Array.isArray(productOptionItem) ? productOptionItem : [];
351
351
  const normalizedOpts = optArr.map((item) => ({
352
- product_option_item_id: Number(item == null ? void 0 : item.product_option_item_id) || 0,
352
+ option_group_item_id: Number(item == null ? void 0 : item.option_group_item_id) || 0,
353
353
  option_group_id: Number(item == null ? void 0 : item.option_group_id) || 0,
354
354
  num: typeof (item == null ? void 0 : item.num) === "number" && !Number.isNaN(item.num) ? Math.max(1, Math.floor(item.num)) : 1,
355
355
  price: String((item == null ? void 0 : item.price) ?? "")
356
356
  })).sort((p, q) => {
357
- if (p.product_option_item_id !== q.product_option_item_id) {
358
- return p.product_option_item_id - q.product_option_item_id;
357
+ if (p.option_group_item_id !== q.option_group_item_id) {
358
+ return p.option_group_item_id - q.option_group_item_id;
359
359
  }
360
360
  if (p.option_group_id !== q.option_group_id)
361
361
  return p.option_group_id - q.option_group_id;
@@ -30,6 +30,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
30
30
  type?: 'form' | 'customer';
31
31
  [key: string]: any;
32
32
  }): void;
33
+ setOrderId(id?: number): void;
33
34
  calcDiscount(productList: Record<string, any>[], options?: SetDiscountSelectedParams): {
34
35
  productList: Record<string, any>[];
35
36
  discountList: Discount[];
@@ -56,7 +57,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
56
57
  private bestDiscount;
57
58
  loadPrepareConfig(params: {
58
59
  customerId: number;
59
- action?: 'create' | 'update';
60
+ action?: 'create' | 'edit';
60
61
  with_good_pass?: 0 | 1;
61
62
  with_discount_card?: 0 | 1;
62
63
  }): Promise<void>;
@@ -57,7 +57,8 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
57
57
  currentBookingTime: "",
58
58
  filteredDiscountList: [],
59
59
  bookingSubject: void 0,
60
- orderTotalAmount: 0
60
+ orderTotalAmount: 0,
61
+ orderId: void 0
61
62
  };
62
63
  }
63
64
  // =========== 生命周期方法 ===========
@@ -205,6 +206,9 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
205
206
  setBookingSubject(bookingSubject) {
206
207
  this.store.bookingSubject = bookingSubject;
207
208
  }
209
+ setOrderId(id) {
210
+ this.store.orderId = id;
211
+ }
208
212
  // 计算优惠券
209
213
  calcDiscount(productList, options) {
210
214
  var _a;
@@ -270,7 +274,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
270
274
  async scanCode(code, customerId) {
271
275
  var _a, _b, _c;
272
276
  try {
273
- const resultDiscountList = await ((_a = this.store.discount) == null ? void 0 : _a.batchSearch(code, customerId)) || [];
277
+ const resultDiscountList = await ((_a = this.store.discount) == null ? void 0 : _a.batchSearch(code, { customerId, orderId: this.store.orderId })) || [];
274
278
  const rulesModule = this.store.rules;
275
279
  if (!rulesModule) {
276
280
  return {
@@ -497,14 +501,16 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
497
501
  async loadPrepareConfig(params) {
498
502
  var _a, _b, _c, _d, _e;
499
503
  try {
504
+ const orderId = this.store.orderId;
500
505
  const customerId = params.customerId || ((_a = this.getCustomer()) == null ? void 0 : _a.id);
501
506
  const goodPassList = await ((_b = this.store.discount) == null ? void 0 : _b.loadPrepareConfig({
502
507
  customer_id: customerId,
503
- action: "create",
508
+ action: orderId ? "edit" : "create",
504
509
  with_good_pass: 1,
505
510
  with_discount_card: 1,
506
511
  with_wallet_pass_holder: 1,
507
- request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
512
+ request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
513
+ ...orderId ? { order_id: orderId } : {}
508
514
  }));
509
515
  const scanDiscount = (_c = this.getDiscountList()) == null ? void 0 : _c.filter(
510
516
  (item) => item.isScan
@@ -36,6 +36,7 @@ export interface ShopDiscountState {
36
36
  type?: 'form' | 'customer';
37
37
  [key: string]: any;
38
38
  };
39
+ orderId?: number;
39
40
  }
40
41
  export interface SetDiscountSelectedParams {
41
42
  discountId: number;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.152",
4
+ "version": "2.2.154",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",