@ozdao/martyrs 0.2.561 → 0.2.562

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 (179) hide show
  1. package/dist/{main-DQtUY5ma.js → main-TV4u6Jux.js} +2915 -2626
  2. package/dist/martyrs/src/components/Button/Button.vue.js +2 -2
  3. package/dist/martyrs/src/components/Button/Button.vue.js.map +1 -1
  4. package/dist/martyrs/src/components/Checkbox/Checkbox.vue.js +1 -1
  5. package/dist/martyrs/src/components/Checkbox/Checkbox.vue.js.map +1 -1
  6. package/dist/martyrs/src/components/EditImages/{EditImages.vue.js → EditImages.vue2.js} +2 -2
  7. package/dist/martyrs/src/components/EditImages/EditImages.vue2.js.map +1 -0
  8. package/dist/martyrs/src/components/Feed/Carousel.vue.js +1 -1
  9. package/dist/martyrs/src/components/Feed/Feed.vue.js +2 -2
  10. package/dist/martyrs/src/components/Field/{Field.vue.js → Field.vue2.js} +2 -2
  11. package/dist/martyrs/src/components/Field/Field.vue2.js.map +1 -0
  12. package/dist/martyrs/src/components/FieldBig/FieldBig.vue.js +1 -1
  13. package/dist/martyrs/src/components/Loader/{Loader.vue.js → Loader.vue2.js} +2 -2
  14. package/dist/martyrs/src/components/Loader/Loader.vue2.js.map +1 -0
  15. package/dist/martyrs/src/components/LocationMarker/LocationMarker.vue.js +1 -1
  16. package/dist/martyrs/src/components/Media/Media.vue.js +1 -1
  17. package/dist/martyrs/src/components/Menu/{Menu.vue2.js → Menu.vue.js} +2 -2
  18. package/dist/martyrs/src/components/Menu/Menu.vue.js.map +1 -0
  19. package/dist/martyrs/src/components/SelectMulti/{SelectMulti.vue2.js → SelectMulti.vue.js} +2 -2
  20. package/dist/martyrs/src/components/SelectMulti/SelectMulti.vue.js.map +1 -0
  21. package/dist/martyrs/src/components/Spoiler/{Spoiler.vue.js → Spoiler.vue2.js} +2 -2
  22. package/dist/martyrs/src/components/Spoiler/Spoiler.vue2.js.map +1 -0
  23. package/dist/martyrs/src/components/Tab/{Tab.vue.js → Tab.vue2.js} +2 -2
  24. package/dist/martyrs/src/components/Tab/Tab.vue2.js.map +1 -0
  25. package/dist/martyrs/src/components/UploadImage/UploadImage.vue.js +1 -1
  26. package/dist/martyrs/src/components/UploadImageMultiple/UploadImageMultiple.vue.js +1 -1
  27. package/dist/martyrs/src/modules/auth/views/components/pages/EnterCode.vue.js +1 -1
  28. package/dist/martyrs/src/modules/auth/views/components/pages/EnterPassword.vue.js +2 -2
  29. package/dist/martyrs/src/modules/auth/views/components/pages/Invite.vue.js +2 -2
  30. package/dist/martyrs/src/modules/auth/views/components/pages/Profile.vue.js +3 -3
  31. package/dist/martyrs/src/modules/auth/views/components/pages/ProfileBlogposts.vue.js +1 -1
  32. package/dist/martyrs/src/modules/auth/views/components/pages/ProfileEdit.vue.js +1 -1
  33. package/dist/martyrs/src/modules/auth/views/components/pages/ProfileEditProfile.vue.js +1 -1
  34. package/dist/martyrs/src/modules/auth/views/components/pages/ResetPassword.vue.js +2 -2
  35. package/dist/martyrs/src/modules/auth/views/components/pages/SignIn.vue.js +2 -2
  36. package/dist/martyrs/src/modules/auth/views/components/pages/SignUp.vue.js +2 -2
  37. package/dist/martyrs/src/modules/auth/views/components/sections/ProfileEditCredentials.vue.js +1 -1
  38. package/dist/martyrs/src/modules/backoffice/components/partials/Sidebar.vue.js +1 -1
  39. package/dist/martyrs/src/modules/community/components/pages/BlogPost.vue.js +1 -1
  40. package/dist/martyrs/src/modules/community/components/pages/CreateBlogPost.vue.js +1 -1
  41. package/dist/martyrs/src/modules/constructor/components/elements/Card.vue.js +1 -1
  42. package/dist/martyrs/src/modules/constructor/components/elements/Embed.vue.js +1 -1
  43. package/dist/martyrs/src/modules/core/views/components/blocks/BlockSearch.vue.js +1 -1
  44. package/dist/martyrs/src/modules/core/views/components/blocks/CardHeader.vue.js +1 -1
  45. package/dist/martyrs/src/modules/core/views/components/blocks/PopupDateSelector.vue.js +1 -1
  46. package/dist/martyrs/src/modules/core/views/components/layouts/Client.vue.js +3 -6
  47. package/dist/martyrs/src/modules/core/views/components/layouts/Client.vue.js.map +1 -1
  48. package/dist/martyrs/src/modules/core/views/components/partials/Header.vue.js +1 -1
  49. package/dist/martyrs/src/modules/core/views/components/partials/Header.vue.js.map +1 -1
  50. package/dist/martyrs/src/modules/core/views/components/partials/Navigation.vue.js +1 -1
  51. package/dist/martyrs/src/modules/core/views/components/sections/{Filters.vue.js → Filters.vue2.js} +60 -172
  52. package/dist/martyrs/src/modules/core/views/components/sections/Filters.vue2.js.map +1 -0
  53. package/dist/martyrs/src/modules/core/views/components/sections/SectionPageTitle.vue.js +1 -1
  54. package/dist/martyrs/src/modules/core/views/components/sections/filters/FilterCheckbox.vue2.js +64 -0
  55. package/dist/martyrs/src/modules/core/views/components/sections/filters/FilterCheckbox.vue2.js.map +1 -0
  56. package/dist/martyrs/src/modules/core/views/components/sections/filters/FilterDateRange.vue2.js +160 -0
  57. package/dist/martyrs/src/modules/core/views/components/sections/filters/FilterDateRange.vue2.js.map +1 -0
  58. package/dist/martyrs/src/modules/core/views/components/sections/filters/FilterOptions.vue.js +46 -0
  59. package/dist/martyrs/src/modules/core/views/components/sections/filters/FilterOptions.vue.js.map +1 -0
  60. package/dist/martyrs/src/modules/core/views/components/sections/filters/FilterRange.vue.js +105 -0
  61. package/dist/martyrs/src/modules/core/views/components/sections/filters/FilterRange.vue.js.map +1 -0
  62. package/dist/martyrs/src/modules/core/views/components/sections/filters/FiltersGroup.vue.js +168 -0
  63. package/dist/martyrs/src/modules/core/views/components/sections/filters/FiltersGroup.vue.js.map +1 -0
  64. package/dist/martyrs/src/modules/core/views/utils/vue-app-renderer.js +4 -0
  65. package/dist/martyrs/src/modules/core/views/utils/vue-app-renderer.js.map +1 -1
  66. package/dist/martyrs/src/modules/events/components/pages/EditEvent.vue.js +4 -4
  67. package/dist/martyrs/src/modules/events/components/pages/EditEventTickets.vue.js +1 -1
  68. package/dist/martyrs/src/modules/events/components/pages/Event.vue.js +5 -3
  69. package/dist/martyrs/src/modules/events/components/pages/Event.vue.js.map +1 -1
  70. package/dist/martyrs/src/modules/events/components/pages/EventsBackoffice.vue.js +1 -1
  71. package/dist/martyrs/src/modules/events/components/sections/EditTickets.vue.js +1 -1
  72. package/dist/martyrs/src/modules/events/components/sections/Feed.vue.js +1 -1
  73. package/dist/martyrs/src/modules/events/components/sections/List.vue.js +1 -1
  74. package/dist/martyrs/src/modules/gallery/components/sections/BackofficeGallery.vue.js +3 -3
  75. package/dist/martyrs/src/modules/inventory/components/forms/AdjustmentForm.vue.js +1 -1
  76. package/dist/martyrs/src/modules/inventory/components/forms/StockAlertsForm.vue.js +1 -1
  77. package/dist/martyrs/src/modules/inventory/components/pages/InventoryEdit.vue.js +1 -1
  78. package/dist/martyrs/src/modules/landing/components/sections/SectionGuide.vue.js +1 -1
  79. package/dist/martyrs/src/modules/marketplace/views/components/layouts/Marketplace.vue.js +159 -239
  80. package/dist/martyrs/src/modules/marketplace/views/components/layouts/Marketplace.vue.js.map +1 -1
  81. package/dist/martyrs/src/modules/marketplace/views/components/pages/Catalog.vue.js +5 -6
  82. package/dist/martyrs/src/modules/marketplace/views/components/pages/Catalog.vue.js.map +1 -1
  83. package/dist/martyrs/src/modules/marketplace/views/components/sections/SectionMenu.vue.js +1 -1
  84. package/dist/martyrs/src/modules/marketplace/views/store/marketplace.js +65 -2
  85. package/dist/martyrs/src/modules/marketplace/views/store/marketplace.js.map +1 -1
  86. package/dist/martyrs/src/modules/music/components/forms/AlbumForm.vue.js +1 -1
  87. package/dist/martyrs/src/modules/music/components/forms/ArtistForm.vue.js +2 -2
  88. package/dist/martyrs/src/modules/music/components/forms/PlaylistForm.vue.js +1 -1
  89. package/dist/martyrs/src/modules/music/components/forms/TrackForm.vue.js +1 -1
  90. package/dist/martyrs/src/modules/music/components/pages/Album.vue.js +1 -1
  91. package/dist/martyrs/src/modules/music/components/pages/Artist.vue.js +1 -1
  92. package/dist/martyrs/src/modules/music/components/pages/Playlist.vue.js +1 -1
  93. package/dist/martyrs/src/modules/music/components/pages/SearchResults.vue.js +1 -1
  94. package/dist/martyrs/src/modules/music/components/pages/Track.vue.js +1 -1
  95. package/dist/martyrs/src/modules/music/components/pages/TrackCreate.vue.js +1 -1
  96. package/dist/martyrs/src/modules/notifications/components/pages/Notifications.vue.js +1 -1
  97. package/dist/martyrs/src/modules/orders/components/forms/FormApplicationDetails.vue.js +1 -1
  98. package/dist/martyrs/src/modules/orders/components/forms/FormCustomerDetails.vue.js +1 -1
  99. package/dist/martyrs/src/modules/orders/components/forms/FormSelectCustomer.vue.js +1 -1
  100. package/dist/martyrs/src/modules/orders/components/pages/OrderCreateBackoffice.vue.js +2 -2
  101. package/dist/martyrs/src/modules/orders/components/pages/Orders.vue.js +1 -1
  102. package/dist/martyrs/src/modules/orders/components/sections/FormDelivery.vue.js +5 -3
  103. package/dist/martyrs/src/modules/orders/components/sections/FormDelivery.vue.js.map +1 -1
  104. package/dist/martyrs/src/modules/organizations/components/blocks/CardDepartment.vue.js +1 -1
  105. package/dist/martyrs/src/modules/organizations/components/blocks/CardOrganization.vue.js +4 -4
  106. package/dist/martyrs/src/modules/organizations/components/blocks/CardOrganization.vue.js.map +1 -1
  107. package/dist/martyrs/src/modules/organizations/components/forms/DepartmentForm.vue.js +2 -2
  108. package/dist/martyrs/src/modules/organizations/components/forms/InviteForm.vue.js +1 -1
  109. package/dist/martyrs/src/modules/organizations/components/pages/Department.vue.js +1 -1
  110. package/dist/martyrs/src/modules/organizations/components/pages/Organization.vue.js +1 -1
  111. package/dist/martyrs/src/modules/organizations/components/pages/OrganizationBackoffice.vue.js +2 -2
  112. package/dist/martyrs/src/modules/organizations/components/pages/OrganizationEdit.vue.js +3 -3
  113. package/dist/martyrs/src/modules/organizations/components/pages/Organizations.vue.js +1 -1
  114. package/dist/martyrs/src/modules/organizations/components/sections/Documents.vue.js +2 -2
  115. package/dist/martyrs/src/modules/organizations/components/sections/MembersAdd.vue.js +1 -1
  116. package/dist/martyrs/src/modules/organizations/components/sections/Organizations.vue.js +3 -3
  117. package/dist/martyrs/src/modules/pages/views/components/blocks/CardPage.vue.js +2 -2
  118. package/dist/martyrs/src/modules/pages/views/components/pages/PageEdit.vue.js +1 -1
  119. package/dist/martyrs/src/modules/products/components/elements/Image360.vue.js +1 -1
  120. package/dist/martyrs/src/modules/products/components/pages/Categories.vue.js +1 -1
  121. package/dist/martyrs/src/modules/products/components/pages/CategoryEdit.vue.js +5 -3
  122. package/dist/martyrs/src/modules/products/components/pages/CategoryEdit.vue.js.map +1 -1
  123. package/dist/martyrs/src/modules/products/components/pages/Product.vue.js +2 -2
  124. package/dist/martyrs/src/modules/products/components/pages/ProductEdit.vue.js +4 -4
  125. package/dist/martyrs/src/modules/products/components/pages/ProductRecommmendation.vue.js +1 -1
  126. package/dist/martyrs/src/modules/products/components/pages/Products.vue.js +4 -4
  127. package/dist/martyrs/src/modules/products/components/sections/EditAttributes.vue.js +1 -1
  128. package/dist/martyrs/src/modules/products/components/sections/EditDiscounts.vue.js +1 -1
  129. package/dist/martyrs/src/modules/products/components/sections/EditVariants.vue.js +2 -2
  130. package/dist/martyrs/src/modules/products/components/sections/FilterProducts.vue.js +1 -1
  131. package/dist/martyrs/src/modules/products/components/sections/SectionProduct.vue.js +1 -1
  132. package/dist/martyrs/src/modules/rents/views/components/pages/Gant/GanttToolbar.vue.js +1 -1
  133. package/dist/martyrs/src/modules/rents/views/components/pages/Rents.vue.js +1 -1
  134. package/dist/martyrs/src/modules/rents/views/components/pages/RentsEdit.vue.js +1 -1
  135. package/dist/martyrs/src/modules/spots/components/blocks/SpotMemberModify.vue.js +1 -1
  136. package/dist/martyrs/src/modules/spots/components/layouts/Spots.vue.js +2 -2
  137. package/dist/martyrs/src/modules/spots/components/pages/Spot.vue.js +1 -1
  138. package/dist/martyrs/src/modules/spots/components/pages/SpotEdit.vue.js +2 -2
  139. package/dist/martyrs/src/modules/spots/components/sections/WorktimeEdit.vue.js +1 -1
  140. package/dist/martyrs/src/modules/wallet/views/components/blocks/CardDeposit.vue.js +1 -1
  141. package/dist/martyrs/src/modules/wallet/views/components/blocks/CryptoDeposit.vue.js +1 -1
  142. package/dist/martyrs.css +1 -1
  143. package/dist/martyrs.es.js +1 -1
  144. package/dist/organizations.server.js +7 -2
  145. package/dist/style.css +10 -1
  146. package/dist/{web-Cyc6i_pv.js → web-Cq5tyhkl.js} +1 -1
  147. package/package.json +1 -1
  148. package/src/components/Button/Button.vue +1 -1
  149. package/src/components/Checkbox/Checkbox.vue +1 -1
  150. package/src/modules/core/views/components/layouts/Client.vue +7 -11
  151. package/src/modules/core/views/components/partials/Header.vue +1 -1
  152. package/src/modules/core/views/components/sections/Filters.vue +47 -161
  153. package/src/modules/core/views/components/sections/filters/FilterCheckbox.vue +12 -31
  154. package/src/modules/core/views/components/sections/filters/FilterDateRange.vue +15 -15
  155. package/src/modules/core/views/components/sections/filters/FilterOptions.vue +12 -43
  156. package/src/modules/core/views/components/sections/filters/FilterRange.vue +59 -36
  157. package/src/modules/core/views/components/sections/filters/FiltersGroup.vue +178 -0
  158. package/src/modules/core/views/utils/vue-app-renderer.js +12 -0
  159. package/src/modules/marketplace/controllers/marketplace.controller.js +123 -0
  160. package/src/modules/marketplace/controllers/utils/lookupConfigs.js +130 -0
  161. package/src/modules/marketplace/controllers/utils/queryProcessorMarketplace.js +211 -0
  162. package/src/modules/marketplace/marketplace.server.js +22 -0
  163. package/src/modules/marketplace/routes/marketplace.routes.js +34 -0
  164. package/src/modules/marketplace/views/components/layouts/Marketplace.vue +194 -275
  165. package/src/modules/marketplace/views/components/pages/Catalog.vue +6 -5
  166. package/src/modules/marketplace/views/router/marketplace.router.js +43 -28
  167. package/src/modules/marketplace/views/store/marketplace.js +74 -3
  168. package/src/modules/organizations/components/blocks/CardOrganization.vue +8 -8
  169. package/src/modules/organizations/controllers/organizations.controller.js +1 -1
  170. package/src/modules/organizations/controllers/utils/queryProcessorOrganizations.js +8 -1
  171. package/dist/martyrs/src/components/EditImages/EditImages.vue.js.map +0 -1
  172. package/dist/martyrs/src/components/Field/Field.vue.js.map +0 -1
  173. package/dist/martyrs/src/components/Loader/Loader.vue.js.map +0 -1
  174. package/dist/martyrs/src/components/Menu/Menu.vue2.js.map +0 -1
  175. package/dist/martyrs/src/components/SelectMulti/SelectMulti.vue2.js.map +0 -1
  176. package/dist/martyrs/src/components/Spoiler/Spoiler.vue.js.map +0 -1
  177. package/dist/martyrs/src/components/Tab/Tab.vue.js.map +0 -1
  178. package/dist/martyrs/src/modules/core/views/components/sections/Filters.vue.js.map +0 -1
  179. package/src/modules/core/views/components/sections/filters/FilterPrice.vue +0 -81
@@ -0,0 +1,211 @@
1
+ import { Types } from 'mongoose';
2
+ import * as googleMapsServicesJs from '@googlemaps/google-maps-services-js';
3
+
4
+ const ObjectId = Types.ObjectId;
5
+ const { Client } = googleMapsServicesJs;
6
+ const client = new Client({});
7
+
8
+ /**
9
+ * Get basic match conditions for spots (delivery, payment)
10
+ */
11
+ const getBasicMatchConditions = query => {
12
+ const conditions = [];
13
+
14
+ if (query.delivery) {
15
+ // Нормализуем в массив и фильтруем пустые значения
16
+ let deliveryMethods = Array.isArray(query.delivery)
17
+ ? query.delivery
18
+ : typeof query.delivery === 'string'
19
+ ? query.delivery.split(',')
20
+ : [];
21
+
22
+ deliveryMethods = deliveryMethods.filter(Boolean).map(m => m.trim());
23
+
24
+ if (deliveryMethods.length > 0) {
25
+ // $in = spots которые поддерживают ХОТЯ БЫ ОДИН метод
26
+ conditions.push({ delivery: { $in: deliveryMethods } });
27
+ }
28
+ }
29
+
30
+ if (query.payment) {
31
+ // Нормализуем в массив и фильтруем пустые значения
32
+ let paymentMethods = Array.isArray(query.payment)
33
+ ? query.payment
34
+ : typeof query.payment === 'string'
35
+ ? query.payment.split(',')
36
+ : [];
37
+
38
+ paymentMethods = paymentMethods.filter(Boolean).map(m => m.trim());
39
+
40
+ if (paymentMethods.length > 0) {
41
+ // $in = spots которые поддерживают ХОТЯ БЫ ОДИН метод
42
+ conditions.push({ payment: { $in: paymentMethods } });
43
+ }
44
+ }
45
+
46
+ return conditions;
47
+ };
48
+
49
+ /**
50
+ * Get price filter conditions for variants
51
+ */
52
+ const getPriceConditions = (priceMin, priceMax) => {
53
+ if (!priceMin && !priceMax) return [];
54
+
55
+ const conditions = {};
56
+
57
+ if (priceMin !== undefined && priceMin !== null && priceMin !== '') {
58
+ conditions['products.variants.price'] = { $gte: parseFloat(priceMin) };
59
+ }
60
+
61
+ if (priceMax !== undefined && priceMax !== null && priceMax !== '') {
62
+ if (conditions['products.variants.price']) {
63
+ conditions['products.variants.price'].$lte = parseFloat(priceMax);
64
+ } else {
65
+ conditions['products.variants.price'] = { $lte: parseFloat(priceMax) };
66
+ }
67
+ }
68
+
69
+ return Object.keys(conditions).length > 0 ? [{ $match: conditions }] : [];
70
+ };
71
+
72
+ /**
73
+ * Get category filter conditions for products
74
+ */
75
+ const getCategoryConditions = categories => {
76
+ if (!categories || categories.length === 0) return [];
77
+
78
+ const categoriesArray = Array.isArray(categories) ? categories : categories.split(',');
79
+
80
+ return [
81
+ {
82
+ $match: {
83
+ 'products.category': { $in: categoriesArray.map(id => new ObjectId(id)) },
84
+ },
85
+ },
86
+ ];
87
+ };
88
+
89
+ /**
90
+ * Get contain conditions (spots must have availability, products, etc)
91
+ */
92
+ const getContainConditions = contain => {
93
+ if (!contain) return [];
94
+
95
+ const conditions = contain.map(property => ({
96
+ [property]: { $exists: true, $not: { $size: 0 } },
97
+ }));
98
+
99
+ return conditions.length > 0 ? [{ $match: { $and: conditions } }] : [];
100
+ };
101
+
102
+ /**
103
+ * Геофильтрация для Spots (адаптировано из organizations)
104
+ */
105
+ const hasLocationParams = query => query.location || query.address || query.city || query.state || query.country;
106
+
107
+ const resolveLocation = async query => {
108
+ if (query.location) {
109
+ const parsedLocation = typeof query.location === 'string' ? JSON.parse(query.location) : query.location;
110
+ const coordinates = parsedLocation.lng ? [parsedLocation.lng, parsedLocation.lat] : parsedLocation.coordinates;
111
+ return { coordinates: coordinates.map(coord => parseFloat(coord)) };
112
+ }
113
+ const searchString = [query.address, query.city, query.state, query.country].filter(Boolean).join(', ');
114
+ try {
115
+ const geoResponse = await client.geocode({
116
+ params: {
117
+ address: searchString,
118
+ key: process.env.GOOGLE_MAPS_API_KEY,
119
+ },
120
+ });
121
+ if (!geoResponse.data.results?.length) {
122
+ throw new Error('Unable to geocode the provided location.');
123
+ }
124
+ const { lng, lat } = geoResponse.data.results[0].geometry.location;
125
+ return { coordinates: [lng, lat] };
126
+ } catch (err) {
127
+ throw new Error('Error occurred while geocoding.');
128
+ }
129
+ };
130
+
131
+ const getRadius = query => {
132
+ if (query.locationRadius) return parseFloat(query.locationRadius) / 6378.1;
133
+ if (query.city) return 25 / 6378.1;
134
+ if (query.state) return 50 / 6378.1;
135
+ return null;
136
+ };
137
+
138
+ const getDistanceStages = location => [
139
+ {
140
+ $addFields: {
141
+ distance: {
142
+ $function: {
143
+ body: `function(spotCoords, userCoords, isMiles) {
144
+ function toRad(x) {
145
+ return x * Math.PI / 180;
146
+ }
147
+ var lon1 = spotCoords[0];
148
+ var lat1 = spotCoords[1];
149
+ var lon2 = userCoords[0];
150
+ var lat2 = userCoords[1];
151
+ var R = 6371;
152
+ if (isMiles) R = 3959;
153
+ var x1 = lat2 - lat1;
154
+ var dLat = toRad(x1);
155
+ var x2 = lon2 - lon1;
156
+ var dLon = toRad(x2);
157
+ var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
158
+ Math.cos(toRad(lat1)) * Math.cos(toRad(lat2)) *
159
+ Math.sin(dLon / 2) * Math.sin(dLon / 2);
160
+ var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
161
+ var d = R * c;
162
+ return d;
163
+ }`,
164
+ args: ['$location.coordinates', location.coordinates, false],
165
+ lang: 'js',
166
+ },
167
+ },
168
+ },
169
+ },
170
+ ];
171
+
172
+ const getSpotsLocationStages = async query => {
173
+ if (!hasLocationParams(query)) {
174
+ return { stages: [], userLocation: null };
175
+ }
176
+ const location = await resolveLocation(query);
177
+ const radius = getRadius(query);
178
+ const geoStages = radius
179
+ ? [
180
+ {
181
+ $match: {
182
+ 'location.coordinates': {
183
+ $geoWithin: {
184
+ $centerSphere: [[location.coordinates[0], location.coordinates[1]], radius],
185
+ },
186
+ },
187
+ },
188
+ },
189
+ ]
190
+ : [];
191
+ return {
192
+ stages: [...geoStages, ...getDistanceStages(location)],
193
+ userLocation: location,
194
+ };
195
+ };
196
+
197
+ export {
198
+ getBasicMatchConditions,
199
+ getPriceConditions,
200
+ getCategoryConditions,
201
+ getContainConditions,
202
+ getSpotsLocationStages,
203
+ };
204
+
205
+ export default {
206
+ getBasicMatchConditions,
207
+ getPriceConditions,
208
+ getCategoryConditions,
209
+ getContainConditions,
210
+ getSpotsLocationStages,
211
+ };
@@ -0,0 +1,22 @@
1
+ import marketplaceRoutes from './routes/marketplace.routes.js';
2
+
3
+ function initializeMarketplace(app, db, origins, publicPath) {
4
+ // Marketplace использует существующие модели (Spot, StockAvailability, Variant, Product, Organization)
5
+ // Модели уже зарегистрированы в spots, inventory, products, organizations модулях
6
+
7
+ // Настраиваем маршруты
8
+ if (app) {
9
+ marketplaceRoutes(app, db, origins, publicPath);
10
+ }
11
+ }
12
+
13
+ export const routes = {
14
+ marketplaceRoutes,
15
+ };
16
+
17
+ export const initialize = initializeMarketplace;
18
+
19
+ export default {
20
+ initialize: initializeMarketplace,
21
+ routes,
22
+ };
@@ -0,0 +1,34 @@
1
+ import middlewareFactoryAuth from '@martyrs/src/modules/auth/controllers/middlewares/index.js';
2
+ import controllerFactory from '../controllers/marketplace.controller.js';
3
+
4
+ export default (function (app, db) {
5
+ const controller = controllerFactory(db);
6
+ const { authJwt } = middlewareFactoryAuth(db);
7
+
8
+ /**
9
+ * GET /api/marketplace/catalog
10
+ * Public endpoint for marketplace catalog
11
+ * Returns organizations with available products at nearby spots
12
+ *
13
+ * Query params:
14
+ * - location: { coordinates: [lng, lat] } or JSON string
15
+ * - locationRadius: number (km)
16
+ * - address/city/state/country: for geocoding
17
+ * - priceMin/priceMax: number
18
+ * - delivery: comma-separated string or array
19
+ * - payment: comma-separated string or array
20
+ * - categories: comma-separated string or array
21
+ * - isOpenNow: boolean
22
+ * - sortParam: 'distance' | 'rating' | 'views' (default: 'distance')
23
+ * - sortOrder: 'asc' | 'desc' (default: 'asc')
24
+ * - skip: number (default: 0)
25
+ * - limit: number (default: 18)
26
+ */
27
+ app.get(
28
+ '/api/marketplace/catalog',
29
+ [
30
+ authJwt.verifyToken(true), // Optional authentication
31
+ ],
32
+ controller.readCatalog
33
+ );
34
+ });