@pisell/pisellos 2.1.128 → 2.1.130

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 (46) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  2. package/dist/modules/Order/index.d.ts +4 -0
  3. package/dist/modules/Order/index.js +18 -1
  4. package/dist/modules/Order/types.d.ts +9 -1
  5. package/dist/modules/Order/utils.d.ts +7 -0
  6. package/dist/modules/Order/utils.js +27 -11
  7. package/dist/solution/ScanOrder/index.d.ts +27 -3
  8. package/dist/solution/ScanOrder/index.js +865 -481
  9. package/dist/solution/ScanOrder/types.d.ts +34 -24
  10. package/dist/solution/ScanOrder/types.js +5 -1
  11. package/dist/solution/ScanOrder/utils.d.ts +13 -1
  12. package/dist/solution/ScanOrder/utils.js +45 -6
  13. package/dist/solution/VenueBooking/index.d.ts +28 -5
  14. package/dist/solution/VenueBooking/index.js +463 -227
  15. package/dist/solution/VenueBooking/types.d.ts +23 -0
  16. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -1
  17. package/dist/solution/VenueBooking/utils/dateSummary.js +1 -1
  18. package/dist/solution/VenueBooking/utils/resource.d.ts +11 -1
  19. package/dist/solution/VenueBooking/utils/resource.js +57 -21
  20. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +5 -0
  21. package/dist/solution/VenueBooking/utils/slotMerge.js +33 -12
  22. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +1 -1
  23. package/dist/solution/VenueBooking/utils/timeSlot.js +259 -62
  24. package/lib/model/strategy/adapter/promotion/index.js +49 -0
  25. package/lib/modules/Order/index.d.ts +4 -0
  26. package/lib/modules/Order/index.js +14 -1
  27. package/lib/modules/Order/types.d.ts +9 -1
  28. package/lib/modules/Order/utils.d.ts +7 -0
  29. package/lib/modules/Order/utils.js +22 -12
  30. package/lib/solution/ScanOrder/index.d.ts +27 -3
  31. package/lib/solution/ScanOrder/index.js +409 -114
  32. package/lib/solution/ScanOrder/types.d.ts +34 -24
  33. package/lib/solution/ScanOrder/utils.d.ts +13 -1
  34. package/lib/solution/ScanOrder/utils.js +37 -0
  35. package/lib/solution/VenueBooking/index.d.ts +28 -5
  36. package/lib/solution/VenueBooking/index.js +203 -58
  37. package/lib/solution/VenueBooking/types.d.ts +23 -0
  38. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -1
  39. package/lib/solution/VenueBooking/utils/dateSummary.js +1 -1
  40. package/lib/solution/VenueBooking/utils/resource.d.ts +11 -1
  41. package/lib/solution/VenueBooking/utils/resource.js +15 -4
  42. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +5 -0
  43. package/lib/solution/VenueBooking/utils/slotMerge.js +29 -12
  44. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +1 -1
  45. package/lib/solution/VenueBooking/utils/timeSlot.js +182 -43
  46. package/package.json +1 -1
@@ -36,14 +36,31 @@ export interface VenueTimeSlot {
36
36
  resourceFormId: number | string;
37
37
  capacity: number | null;
38
38
  remainingCapacity: number | null;
39
+ /** per-product sub-row slot 上带的 productId;外层合并 slot 不写 */
40
+ productId?: number;
41
+ }
42
+ export interface VenueResourceSubRow {
43
+ productId: number;
44
+ productTitle: string;
45
+ price: string;
46
+ slots: VenueTimeSlot[];
47
+ }
48
+ export interface VenueResourceCombinedInfo {
49
+ resourceIds: Array<number | string>;
39
50
  }
40
51
  export interface VenueResourceRow {
41
52
  resourceId: number | string;
42
53
  resourceFormId: number | string;
43
54
  resourceName: string;
55
+ /** 单商品时取唯一 mapping.productId;多商品时取第一个 mapping(兼容字段) */
44
56
  productId: number;
45
57
  productTitle: string;
46
58
  slots: VenueTimeSlot[];
59
+ /** 多商品共享同一场地时的子行;单商品不输出 */
60
+ products?: VenueResourceSubRow[];
61
+ hasMultipleProducts?: boolean;
62
+ /** 当前资源是 combined_resource.status===1 时输出 */
63
+ combinedResource?: VenueResourceCombinedInfo;
47
64
  }
48
65
  export interface VenueTimeSlotGrid {
49
66
  date: string;
@@ -57,6 +74,10 @@ export interface VenueDateSummaryItem {
57
74
  totalSlots: number;
58
75
  availableSlots: number;
59
76
  }
77
+ export interface VenueResourceCombinedRaw {
78
+ status: number;
79
+ resource_ids: Array<number | string>;
80
+ }
60
81
  export interface VenueResourceRawData {
61
82
  resourceId: number | string;
62
83
  formId: number | string;
@@ -69,6 +90,7 @@ export interface VenueResourceRawData {
69
90
  end_at: string;
70
91
  [key: string]: any;
71
92
  }>;
93
+ combined_resource?: VenueResourceCombinedRaw;
72
94
  [key: string]: any;
73
95
  }
74
96
  export interface ResourceProductMapping {
@@ -81,6 +103,7 @@ export interface ResourceProductMapping {
81
103
  }
82
104
  export interface VenueSlotSelection {
83
105
  resourceId: number | string;
106
+ productId: number;
84
107
  startTime: string;
85
108
  endTime: string;
86
109
  price: string;
@@ -5,7 +5,7 @@ export declare function buildDateRangeSummary(params: {
5
5
  endDate: string;
6
6
  config: VenueBookingSlotConfig;
7
7
  rawResources: VenueResourceRawData[];
8
- resourceProductMap: Map<number | string, ResourceProductMapping>;
8
+ resourceProductMap: Map<number | string, ResourceProductMapping[]>;
9
9
  quotationModule?: QuotationModule;
10
10
  resolveConfig?: (date: string) => VenueBookingSlotConfig;
11
11
  }): VenueDateSummaryItem[];
@@ -16,7 +16,7 @@ export function buildDateRangeSummary(params) {
16
16
  quotationModule = params.quotationModule,
17
17
  resolveConfig = params.resolveConfig;
18
18
  var result = [];
19
- var productIds = quotationModule ? _toConsumableArray(new Set(_toConsumableArray(resourceProductMap.values()).map(function (m) {
19
+ var productIds = quotationModule ? _toConsumableArray(new Set(_toConsumableArray(resourceProductMap.values()).flat().map(function (m) {
20
20
  return m.productId;
21
21
  }))) : [];
22
22
  var cursor = dayjs(startDate);
@@ -1,4 +1,14 @@
1
1
  import type { ProductData } from '../../../modules/Product/types';
2
2
  import type { ResourceProductMapping } from '../types';
3
+ /**
4
+ * 从商品列表里抽取所有 resource_id:
5
+ * - 商品绑定的 default_resource / optional_resource
6
+ * - 以及这些资源上声明的 combined_resource.resource_ids(若可从 product_resource 读取)
7
+ * 用于一次性拉到子资源数据,判定组合资源的可用性。
8
+ */
3
9
  export declare function extractResourceIds(products: ProductData[]): number[];
4
- export declare function buildResourceProductMap(products: ProductData[]): Map<number | string, ResourceProductMapping>;
10
+ /**
11
+ * 每个 resourceId 可以被多个商品共享(同一场地关联多种运动商品)。
12
+ * Map 的 value 改为 ResourceProductMapping[],按商品出现顺序保留。
13
+ */
14
+ export declare function buildResourceProductMap(products: ProductData[]): Map<number | string, ResourceProductMapping[]>;
@@ -5,6 +5,12 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
5
5
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
6
6
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
7
7
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
8
+ /**
9
+ * 从商品列表里抽取所有 resource_id:
10
+ * - 商品绑定的 default_resource / optional_resource
11
+ * - 以及这些资源上声明的 combined_resource.resource_ids(若可从 product_resource 读取)
12
+ * 用于一次性拉到子资源数据,判定组合资源的可用性。
13
+ */
8
14
  export function extractResourceIds(products) {
9
15
  var ids = new Set();
10
16
  var _iterator = _createForOfIteratorHelper(products),
@@ -27,6 +33,21 @@ export function extractResourceIds(products) {
27
33
  var id = _arr[_i];
28
34
  if (typeof id === 'number' && id > 0) ids.add(id);
29
35
  }
36
+ var combined = resource.combined_resource;
37
+ if (combined && combined.status === 1 && Array.isArray(combined.resource_ids)) {
38
+ var _iterator3 = _createForOfIteratorHelper(combined.resource_ids),
39
+ _step3;
40
+ try {
41
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
42
+ var _id = _step3.value;
43
+ if (typeof _id === 'number' && _id > 0) ids.add(_id);
44
+ }
45
+ } catch (err) {
46
+ _iterator3.e(err);
47
+ } finally {
48
+ _iterator3.f();
49
+ }
50
+ }
30
51
  }
31
52
  } catch (err) {
32
53
  _iterator2.e(err);
@@ -41,54 +62,69 @@ export function extractResourceIds(products) {
41
62
  }
42
63
  return Array.from(ids);
43
64
  }
65
+
66
+ /**
67
+ * 每个 resourceId 可以被多个商品共享(同一场地关联多种运动商品)。
68
+ * Map 的 value 改为 ResourceProductMapping[],按商品出现顺序保留。
69
+ */
44
70
  export function buildResourceProductMap(products) {
45
71
  var map = new Map();
46
- var _iterator3 = _createForOfIteratorHelper(products),
47
- _step3;
72
+ var _iterator4 = _createForOfIteratorHelper(products),
73
+ _step4;
48
74
  try {
49
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
75
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
50
76
  var _product$product_reso2;
51
- var product = _step3.value;
77
+ var product = _step4.value;
52
78
  var resources = (_product$product_reso2 = product.product_resource) === null || _product$product_reso2 === void 0 ? void 0 : _product$product_reso2.resources;
53
79
  if (!Array.isArray(resources)) continue;
54
- var _iterator4 = _createForOfIteratorHelper(resources),
55
- _step4;
80
+ var _iterator5 = _createForOfIteratorHelper(resources),
81
+ _step5;
56
82
  try {
57
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
58
- var resource = _step4.value;
83
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
84
+ var resource = _step5.value;
59
85
  if (resource.status !== 1) continue;
60
86
  var allResourceIds = [].concat(_toConsumableArray(resource.default_resource || []), _toConsumableArray(resource.optional_resource || []));
61
- var _iterator5 = _createForOfIteratorHelper(allResourceIds),
62
- _step5;
87
+ var _iterator6 = _createForOfIteratorHelper(allResourceIds),
88
+ _step6;
63
89
  try {
64
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
65
- var resId = _step5.value;
66
- if (map.has(resId)) continue;
67
- map.set(resId, {
90
+ var _loop = function _loop() {
91
+ var resId = _step6.value;
92
+ var existing = map.get(resId);
93
+ var mapping = {
68
94
  productId: product.id,
69
95
  productTitle: product.title,
70
96
  resourceName: resource.title,
71
97
  formId: resource.id,
72
98
  price: product.price || '0.00',
73
99
  resourceType: resource.type || 'single'
74
- });
100
+ };
101
+ if (!existing) {
102
+ map.set(resId, [mapping]);
103
+ } else if (!existing.some(function (m) {
104
+ return m.productId === mapping.productId;
105
+ })) {
106
+ existing.push(mapping);
107
+ }
108
+ };
109
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
110
+ _loop();
75
111
  }
76
112
  } catch (err) {
77
- _iterator5.e(err);
113
+ _iterator6.e(err);
78
114
  } finally {
79
- _iterator5.f();
115
+ _iterator6.f();
80
116
  }
81
117
  }
82
118
  } catch (err) {
83
- _iterator4.e(err);
119
+ _iterator5.e(err);
84
120
  } finally {
85
- _iterator4.f();
121
+ _iterator5.f();
86
122
  }
87
123
  }
88
124
  } catch (err) {
89
- _iterator3.e(err);
125
+ _iterator4.e(err);
90
126
  } finally {
91
- _iterator3.f();
127
+ _iterator4.f();
92
128
  }
93
129
  return map;
94
130
  }
@@ -19,6 +19,11 @@ export interface BuildVenueBookingParams {
19
19
  rawResource: VenueResourceRawData | undefined;
20
20
  bookingUuid: string;
21
21
  productUid: string;
22
+ /**
23
+ * 若当前 resource 是组合资源(combined_resource.status === 1),传入其子资源的原始数据,
24
+ * 将作为 resources[0].children 写入 booking,结构与父 resource 保持一致。
25
+ */
26
+ childResources?: VenueResourceRawData[];
22
27
  }
23
28
  export declare function buildVenueBookingEntry(params: BuildVenueBookingParams): Record<string, any>;
24
29
  /**
@@ -96,10 +96,36 @@ export function buildVenueBookingEntry(params) {
96
96
  mapping = params.mapping,
97
97
  rawResource = params.rawResource,
98
98
  bookingUuid = params.bookingUuid,
99
- productUid = params.productUid;
99
+ productUid = params.productUid,
100
+ childResources = params.childResources;
100
101
  var startMoment = dayjs(group.startTime, 'YYYY-MM-DD HH:mm');
101
102
  var endMoment = dayjs(group.endTime, 'YYYY-MM-DD HH:mm');
102
103
  var duration = endMoment.diff(startMoment, 'minute');
104
+ var resourceEntry = {
105
+ relation_type: 'form',
106
+ like_status: 'common',
107
+ id: resourceId,
108
+ main_field: mapping.resourceName,
109
+ form_id: (_rawResource$form_id = rawResource === null || rawResource === void 0 ? void 0 : rawResource.form_id) !== null && _rawResource$form_id !== void 0 ? _rawResource$form_id : mapping.formId,
110
+ relation_id: resourceId,
111
+ capacity: 1,
112
+ metadata: {}
113
+ };
114
+ if (childResources && childResources.length) {
115
+ resourceEntry.children = childResources.map(function (child) {
116
+ var _child$form_id, _child$capacity;
117
+ return {
118
+ relation_type: 'form',
119
+ like_status: 'common',
120
+ id: child.resourceId,
121
+ main_field: child.main_field || '',
122
+ form_id: (_child$form_id = child.form_id) !== null && _child$form_id !== void 0 ? _child$form_id : child.formId,
123
+ relation_id: child.resourceId,
124
+ capacity: (_child$capacity = child.capacity) !== null && _child$capacity !== void 0 ? _child$capacity : 1,
125
+ metadata: {}
126
+ };
127
+ });
128
+ }
103
129
  return {
104
130
  schedule_event_id: null,
105
131
  appointment_status: 'new',
@@ -115,23 +141,15 @@ export function buildVenueBookingEntry(params) {
115
141
  is_all: false,
116
142
  schedule_id: 0,
117
143
  product_uid: productUid,
118
- resources: [{
119
- relation_type: 'form',
120
- like_status: 'common',
121
- id: resourceId,
122
- main_field: mapping.resourceName,
123
- form_id: (_rawResource$form_id = rawResource === null || rawResource === void 0 ? void 0 : rawResource.form_id) !== null && _rawResource$form_id !== void 0 ? _rawResource$form_id : mapping.formId,
124
- relation_id: resourceId,
125
- capacity: 1,
126
- metadata: {}
127
- }],
144
+ resources: [resourceEntry],
128
145
  relation_products: [],
129
146
  relation_forms: [],
130
147
  holder: null,
131
148
  metadata: {
132
149
  unique_identification_number: bookingUuid,
133
150
  venue_booking: true,
134
- resource_id: resourceId
151
+ resource_id: resourceId,
152
+ product_id: mapping.productId
135
153
  }
136
154
  };
137
155
  }
@@ -148,6 +166,7 @@ export function expandMergedSlotToIndividual(product, slotDurationMinutes) {
148
166
  var startTime = meta.start_time;
149
167
  var endTime = meta.end_time;
150
168
  if (!startTime || !endTime) return [];
169
+ var productId = Number(product.product_id);
151
170
  var breakdown = meta.price_breakdown;
152
171
  var result = [];
153
172
  var cursor = dayjs(startTime, 'YYYY-MM-DD HH:mm');
@@ -178,6 +197,7 @@ export function expandMergedSlotToIndividual(product, slotDurationMinutes) {
178
197
  var price = (_priceMap$get = priceMap.get(hm)) !== null && _priceMap$get !== void 0 ? _priceMap$get : 0;
179
198
  result.push({
180
199
  resourceId: resourceId,
200
+ productId: productId,
181
201
  startTime: cursor.format('YYYY-MM-DD HH:mm'),
182
202
  endTime: slotEnd.format('YYYY-MM-DD HH:mm'),
183
203
  price: new Decimal(price).toFixed(2)
@@ -192,6 +212,7 @@ export function expandMergedSlotToIndividual(product, slotDurationMinutes) {
192
212
  var _slotEnd = cursor.add(slotDurationMinutes, 'minute');
193
213
  result.push({
194
214
  resourceId: resourceId,
215
+ productId: productId,
195
216
  startTime: cursor.format('YYYY-MM-DD HH:mm'),
196
217
  endTime: _slotEnd.format('YYYY-MM-DD HH:mm'),
197
218
  price: perSlotPrice
@@ -26,7 +26,7 @@ export declare function buildTimeSlotGrid(params: {
26
26
  date: string;
27
27
  config: VenueBookingSlotConfig;
28
28
  rawResources: VenueResourceRawData[];
29
- resourceProductMap: Map<number | string, ResourceProductMapping>;
29
+ resourceProductMap: Map<number | string, ResourceProductMapping[]>;
30
30
  quotationPriceMap?: Map<string, string | null>;
31
31
  }): VenueTimeSlotGrid;
32
32
  export {};