@ozdao/prometheus-framework 0.2.40 → 0.2.41
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/main.css +1 -1
- package/dist/prometheus-framework.cjs.js +19 -19
- package/dist/prometheus-framework.es.js +501 -515
- package/package.json +1 -1
- package/src/components/Countdown/Countdown.vue +4 -3
- package/src/components/Header/Header.vue +2 -0
- package/src/modules/community/components/layouts/Community.vue +2 -2
- package/src/modules/community/components/pages/CreateBlogPost.vue +1 -0
- package/src/modules/constructor/components/sections/Constructor.vue +1 -1
- package/src/modules/events/components/pages/EditEvent.vue +48 -3
- package/src/modules/events/components/pages/Event.vue +16 -8
- package/src/modules/events/components/sections/HeroEvent.vue +32 -28
- package/src/modules/events/components/sections/SectionMainGuest.vue +3 -2
- package/src/modules/events/components/sections/SectionPreviousEvents.vue +22 -15
- package/src/modules/events/models/event.model.js +9 -0
- package/src/modules/files/middlewares/server/middlewareBusboy.js +13 -2
- package/src/modules/marketplace/components/layouts/Marketplace.vue +1 -1
- package/src/modules/orders/store/shopcart.js +21 -5
- package/src/modules/payments/controller/payments.controller.js +54 -200
- package/src/modules/payments/controller/payments.tinkoff.controller.js +242 -0
- package/src/modules/payments/models/payment.model.js +22 -0
- package/src/modules/payments/routes/payments.routes.js +4 -25
- package/src/modules/payments/routes/payments.tinkoff.routes.js +58 -0
- package/src/modules/products/components/pages/Product.vue +3 -1
- package/src/modules/products/components/sections/SectionProduct.vue +3 -0
- package/src/modules/products/controllers/products.controller.js +188 -109
- package/src/modules/products/models/product.model.js +1 -0
- package/src/modules/wallet/components/pages/Wallet.vue +73 -88
- package/src/modules/wallet/controllers/crypto.controller.js +79 -0
- package/src/modules/wallet/models/wallet.model.js +27 -0
- /package/src/modules/{orders/models/payment.model.js → payments/models/payment.tinkoff.model.js} +0 -0
@@ -167,77 +167,142 @@ const controllerFactory = (db) => {
|
|
167
167
|
|
168
168
|
const getProducts = (req, res) => {
|
169
169
|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
170
|
+
// {
|
171
|
+
// $lookup: {
|
172
|
+
// from: "modifications",
|
173
|
+
// let: { "productId": "$_id" },
|
174
|
+
// pipeline: [{
|
175
|
+
// $match: {
|
176
|
+
// "$expr": {
|
177
|
+
// "$eq": ["$product", "$$productId"]
|
178
|
+
// }
|
179
|
+
// }
|
180
|
+
// },{
|
181
|
+
// $lookup: {
|
182
|
+
// from: "leftovers",
|
183
|
+
// let: { "productId": "$_id" },
|
184
|
+
// pipeline: [{
|
185
|
+
// $unwind: "$positions"
|
186
|
+
// },{
|
187
|
+
// "$match": { "$expr": { "$eq": ["$positions._id", "$$productId"] }}
|
188
|
+
// },{
|
189
|
+
// "$project": {
|
190
|
+
// _id: "$positions._id",
|
191
|
+
// quantity: "$positions.quantity",
|
192
|
+
// name: "$positions.name",
|
193
|
+
// }
|
194
|
+
// }],
|
195
|
+
// as: "variantsMods"
|
196
|
+
// },
|
197
|
+
// },{
|
198
|
+
// $set: {
|
199
|
+
// quantity:{
|
200
|
+
// $sum:["$quantity",{$sum:"$variantsMods.quantity"}]
|
201
|
+
// }
|
202
|
+
// }
|
203
|
+
// },{
|
204
|
+
// $unset: "variants"
|
205
|
+
// }],
|
206
|
+
// as: "modifications"
|
207
|
+
// },
|
208
|
+
// }
|
209
|
+
|
210
|
+
Product.aggregate([
|
211
|
+
{
|
212
|
+
$facet: {
|
213
|
+
"withIngredients": [
|
214
|
+
{
|
215
|
+
$match: {
|
216
|
+
ingridients: { $exists: true, $not: {$size: 0} } // Продукты с ингредиентами
|
179
217
|
}
|
180
|
-
},
|
218
|
+
},
|
219
|
+
{
|
220
|
+
$lookup: {
|
221
|
+
from: "products",
|
222
|
+
localField: "ingridients",
|
223
|
+
foreignField: "_id",
|
224
|
+
as: "ingredientDetails"
|
225
|
+
}
|
226
|
+
},
|
227
|
+
{ $unwind: "$ingredientDetails" },
|
228
|
+
{
|
229
|
+
$lookup: {
|
230
|
+
from: "leftovers",
|
231
|
+
let: { "ingredientId": "$ingredientDetails._id" },
|
232
|
+
pipeline: [
|
233
|
+
{ $unwind: "$positions" },
|
234
|
+
{
|
235
|
+
$match: {
|
236
|
+
$expr: {
|
237
|
+
$eq: ["$positions._id", "$$ingredientId"]
|
238
|
+
}
|
239
|
+
}
|
240
|
+
},
|
241
|
+
{
|
242
|
+
$project: {
|
243
|
+
quantity: "$positions.quantity"
|
244
|
+
}
|
245
|
+
}
|
246
|
+
],
|
247
|
+
as: "ingredientLeftovers"
|
248
|
+
}
|
249
|
+
},
|
250
|
+
{
|
251
|
+
$group: {
|
252
|
+
_id: "$_id",
|
253
|
+
name: { $first: "$name" },
|
254
|
+
minQuantity: { $min: "$ingredientLeftovers.quantity" }
|
255
|
+
}
|
256
|
+
}
|
257
|
+
],
|
258
|
+
"withoutIngredients": [
|
259
|
+
{
|
260
|
+
$match: {
|
261
|
+
$or: [
|
262
|
+
{ ingridients: { $exists: false } }, // Продукты без ингредиентов
|
263
|
+
{ ingridients: { $size: 0 } }
|
264
|
+
]
|
265
|
+
}
|
266
|
+
},
|
267
|
+
{
|
181
268
|
$lookup: {
|
182
269
|
from: "leftovers",
|
183
270
|
let: { "productId": "$_id" },
|
184
|
-
pipeline: [
|
185
|
-
$unwind: "$positions"
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
271
|
+
pipeline: [
|
272
|
+
{ $unwind: "$positions" },
|
273
|
+
{
|
274
|
+
$match: {
|
275
|
+
$expr: {
|
276
|
+
$eq: ["$positions._id", "$$productId"]
|
277
|
+
}
|
278
|
+
}
|
279
|
+
},
|
280
|
+
{
|
281
|
+
$project: {
|
282
|
+
quantity: "$positions.quantity"
|
283
|
+
}
|
193
284
|
}
|
194
|
-
|
195
|
-
as: "
|
196
|
-
},
|
197
|
-
},{
|
198
|
-
$set: {
|
199
|
-
quantity:{
|
200
|
-
$sum:["$quantity",{$sum:"$variantsMods.quantity"}]
|
201
|
-
}
|
285
|
+
],
|
286
|
+
as: "productLeftovers"
|
202
287
|
}
|
203
|
-
},
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
},
|
208
|
-
},
|
209
|
-
{
|
210
|
-
$lookup: {
|
211
|
-
from: "leftovers",
|
212
|
-
let: { "productId": "$_id" },
|
213
|
-
pipeline: [
|
214
|
-
{
|
215
|
-
$unwind: "$positions"
|
216
|
-
},
|
217
|
-
|
218
|
-
{
|
219
|
-
"$match": { "$expr": { "$eq": ["$positions._id", "$$productId"] }}
|
220
|
-
},
|
221
|
-
{
|
222
|
-
"$project": {
|
223
|
-
_id: "$positions._id",
|
224
|
-
quantity: "$positions.quantity",
|
225
|
-
name: "$positions.name",
|
288
|
+
},
|
289
|
+
{
|
290
|
+
$set: {
|
291
|
+
minQuantity: { $sum: "$productLeftovers.quantity" }
|
226
292
|
}
|
227
293
|
}
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
{
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
])
|
294
|
+
]
|
295
|
+
}
|
296
|
+
},
|
297
|
+
{
|
298
|
+
$project: {
|
299
|
+
products: { $setUnion: ["$withIngredients", "$withoutIngredients"] }
|
300
|
+
}
|
301
|
+
},
|
302
|
+
{ $unwind: "$products" },
|
303
|
+
{ $replaceRoot: { newRoot: "$products" } }
|
304
|
+
])
|
305
|
+
|
241
306
|
.exec((err, products) => {
|
242
307
|
// If error
|
243
308
|
if (err) {return res.status(500).send({ message: err }); }
|
@@ -338,58 +403,72 @@ const controllerFactory = (db) => {
|
|
338
403
|
// Get product
|
339
404
|
const getProduct = async (req, res) => {
|
340
405
|
try {
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
{
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
406
|
+
const product = await Product.aggregate([
|
407
|
+
{
|
408
|
+
$match: { "_id": new ObjectId(req.params._id) }
|
409
|
+
},
|
410
|
+
{
|
411
|
+
$lookup: {
|
412
|
+
from: "leftovers",
|
413
|
+
let: { productId: "$_id", ingredients: { $ifNull: ["$ingredients", []] } },
|
414
|
+
pipeline: [
|
415
|
+
{
|
416
|
+
$unwind: "$positions"
|
417
|
+
},
|
418
|
+
{
|
419
|
+
"$match": { "$expr": { "$eq": ["$positions._id", "$$productId"] }}
|
420
|
+
},
|
421
|
+
{
|
422
|
+
"$addFields": {
|
423
|
+
"positions.quantity": {
|
424
|
+
$cond: {
|
425
|
+
if: { $eq: ["$type", "stock-in"] },
|
426
|
+
then: "$positions.quantity",
|
427
|
+
else: { $multiply: ["$positions.quantity", -1] }
|
428
|
+
}
|
429
|
+
}
|
430
|
+
}
|
431
|
+
},
|
432
|
+
{
|
433
|
+
"$project": {
|
434
|
+
_id: "$positions._id",
|
435
|
+
quantity: "$positions.quantity",
|
436
|
+
name: "$positions.name",
|
437
|
+
}
|
360
438
|
}
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
}
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
439
|
+
],
|
440
|
+
as: "variants"
|
441
|
+
}
|
442
|
+
},
|
443
|
+
{
|
444
|
+
$set: {
|
445
|
+
quantity: {
|
446
|
+
$sum: ["$quantity", {$sum: "$variants.quantity"}]
|
447
|
+
}
|
369
448
|
}
|
370
|
-
}
|
371
|
-
},
|
372
|
-
{ $unset: "variants" }
|
373
|
-
])
|
449
|
+
},
|
374
450
|
|
375
|
-
|
376
|
-
|
377
|
-
}
|
451
|
+
{ $unset: "variants" }
|
452
|
+
]);
|
378
453
|
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
{ new: true }
|
383
|
-
);
|
454
|
+
if (!product || product.length < 1) {
|
455
|
+
return res.status(404).send({ message: "Product not found." });
|
456
|
+
}
|
384
457
|
|
385
|
-
|
458
|
+
const updatedProduct = await Product.findOneAndUpdate(
|
459
|
+
{ _id: req.params._id },
|
460
|
+
{ $inc: { popularity: 1 } },
|
461
|
+
{ new: true }
|
462
|
+
);
|
386
463
|
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
464
|
+
console.log('Popularity updated:', updatedProduct);
|
465
|
+
|
466
|
+
res.status(200).send(product);
|
467
|
+
} catch (err) {
|
468
|
+
console.error('Error:', err);
|
469
|
+
res.status(500).send({ message: err });
|
470
|
+
}
|
471
|
+
};
|
393
472
|
|
394
473
|
return {
|
395
474
|
Create,
|
@@ -1,117 +1,102 @@
|
|
1
1
|
<template>
|
2
|
-
<section class="pd-
|
3
|
-
<h1 class="mn-b-small">Your Wallet</h1>
|
2
|
+
<section class="pd-thin">
|
4
3
|
|
5
|
-
<
|
6
|
-
|
7
|
-
</p>
|
4
|
+
<section class="bg-black t-white mn-b-thin radius-big pd-big">
|
5
|
+
<h1 class="mn-b-medium ">Your Wallet</h1>
|
8
6
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
class="w-100 pd-medium radius-medium t-center bg-grey"
|
13
|
-
>
|
14
|
-
<h3 class="mn-b-small">Make first order and start earning Weeder Token</h3>
|
15
|
-
<button class="mn-l-auto mn-r-auto bg-main button">Explore marketplace</button>
|
16
|
-
</div>
|
7
|
+
<p class="mn-b-semi t-transp p-big">
|
8
|
+
Earn Weeder Tokens by purchasing our weed or contributing to the community.
|
9
|
+
</p>
|
17
10
|
|
18
|
-
<div
|
11
|
+
<div
|
19
12
|
v-if="state.account"
|
20
|
-
class="
|
13
|
+
class="gap-thin flex-nowrap bg-black radius-extra t-white br-solid br-white-transp-10 br-1px flex-v-center flex pd-medium"
|
21
14
|
>
|
22
|
-
<
|
23
|
-
|
24
|
-
|
25
|
-
</div>
|
26
|
-
|
27
|
-
<div class="w-100 bg-black radius-semi pd-medium t-white">
|
28
|
-
<p class="h4 mn-b-thin">Your Metamask</p>
|
29
|
-
|
30
|
-
<div
|
31
|
-
v-if="state.account"
|
32
|
-
class="mn-b-small pd-small br-solid br-1px br-white-transp-10 radius-small"
|
33
|
-
>
|
34
|
-
{{state.account}}
|
15
|
+
<div class="flex-v-center flex-nowrap flex mn-r-auto">
|
16
|
+
<img src="/logo/wdt.svg" class="mn-r-thin i-big">
|
17
|
+
<h2>{{state.tokenBalance}} WDT</h2>
|
35
18
|
</div>
|
36
19
|
|
37
|
-
<
|
38
|
-
|
39
|
-
class="p-medium t-transp mn-b-small"
|
40
|
-
>
|
41
|
-
Connect Metamask to withdrawal your earnings.
|
42
|
-
</p>
|
43
|
-
|
44
|
-
<button
|
45
|
-
v-if="!state.account"
|
46
|
-
@click="actions.connectWallet"
|
47
|
-
class="w-100 br-solid br-2px br-white t-white button"
|
48
|
-
>
|
49
|
-
Connect Wallet
|
50
|
-
</button>
|
51
|
-
|
52
|
-
<button
|
53
|
-
v-if="state.account"
|
54
|
-
@click="actions.disconnectWallet"
|
55
|
-
class="w-100 bg-red button"
|
56
|
-
>
|
57
|
-
Disconnect Wallet
|
58
|
-
</button>
|
20
|
+
<button class="w-max bg-main t-medium button">Get More</button>
|
21
|
+
<button class="w-max bg-white t-black t-medium button" @click="actions.collectRewards">Withdraw</button>
|
59
22
|
</div>
|
60
|
-
</div>
|
61
23
|
|
62
|
-
|
63
|
-
v-if="state.account"
|
64
|
-
class="w-100 pd-medium radius-medium bg-grey"
|
65
|
-
>
|
66
|
-
<p class="h4 mn-b-thin">You earn:</p>
|
67
|
-
<h3 class="mn-b-small">{{state.tokenBalance}} WDT</h3>
|
68
|
-
<button class="w-100 bg-main button" @click="actions.collectRewards">Withdraw</button>
|
69
|
-
</div>
|
70
|
-
|
71
|
-
|
72
|
-
<h3 class="mn-b-small" v-if="state.rewards.length > 0">Latest Rewards </h3>
|
24
|
+
</section>
|
73
25
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
<div class="pd-medium">
|
82
|
-
<span class="w-max mn-b-small d-block pd-t-nano pd-b-nano pd-l-thin pd-r-thin bg-main radius-extra t-semi p-small">{{income.type === 'blogpost' ? 'Community Reward' : income.type}}</span>
|
83
|
-
<h4 class="mn-b-thin">{{income.name}}</h4>
|
84
|
-
<p class="mn-b-small p-small">{{income.content[0].content}}</p>
|
26
|
+
<div v-if="!state.account" class="mn-b-semi cols-2 gap-thin">
|
27
|
+
<div
|
28
|
+
class="w-100 pd-medium radius-medium t-center bg-grey"
|
29
|
+
>
|
30
|
+
<h3 class="mn-b-small">Make first order and start earning Weeder Token</h3>
|
31
|
+
<button class="mn-l-auto mn-r-auto bg-main button">Explore marketplace</button>
|
32
|
+
</div>
|
85
33
|
|
86
|
-
<div
|
87
|
-
|
88
|
-
|
34
|
+
<div
|
35
|
+
class="w-100 pd-medium flex-center flex flex-column radius-medium t-center bg-grey"
|
36
|
+
>
|
37
|
+
<h3
|
38
|
+
v-if="!state.account"
|
39
|
+
class="mn-b-small"
|
40
|
+
>
|
41
|
+
Connect Metamask to withdrawal your earnings.
|
42
|
+
</h3>
|
43
|
+
|
44
|
+
<button
|
45
|
+
v-if="!state.account"
|
46
|
+
@click="actions.connectWallet"
|
47
|
+
class="br-solid br-2px br-black-transp-10 t-black button"
|
48
|
+
>
|
49
|
+
Connect Wallet
|
50
|
+
</button>
|
89
51
|
</div>
|
90
52
|
</div>
|
91
|
-
|
92
|
-
|
93
|
-
<!-- <CardBlogpost
|
94
|
-
:key="income._id"
|
95
|
-
:blogpost="income"
|
96
|
-
class=""
|
97
|
-
/> -->
|
98
53
|
|
99
|
-
|
54
|
+
<div
|
55
|
+
v-if="state.account"
|
56
|
+
class="w-100 mn-b-semi flex-column flex pd-big radius-big bg-main t-black"
|
57
|
+
>
|
58
|
+
<p class="t-transp t-medium mn-b-thin">You own:</p>
|
59
|
+
<p class="h1 mn-b-small">{{state.share}}%</p>
|
60
|
+
<p class="t-white p-big t-medium mn-b-semi">of all shares</p>
|
61
|
+
|
62
|
+
<div
|
63
|
+
class="flex-v-center mn-b-small flex-nowrap flex pd-small bg-black-transp-5 radius-extra"
|
64
|
+
>
|
65
|
+
<img src="@/assets/icons/metamask.svg" class="mn-r-small i-big" >
|
66
|
+
|
67
|
+
<p v-if="state.account" class="t-transp t-medium ">
|
68
|
+
<span class="uppercase p-small t-medium t-transp">Connected Metamask</span><br>
|
69
|
+
<span>{{state.account}}</span>
|
70
|
+
</p>
|
71
|
+
|
72
|
+
<button
|
73
|
+
v-if="state.account"
|
74
|
+
@click="actions.disconnectWallet"
|
75
|
+
class="mn-l-auto bg-red button"
|
76
|
+
>
|
77
|
+
Disconnect Wallet
|
78
|
+
</button>
|
79
|
+
</div>
|
80
|
+
|
81
|
+
|
82
|
+
</div>
|
83
|
+
<h2 class="mn-b-small" v-if="state.rewards.length > 0">Latest Rewards </h2>
|
100
84
|
|
85
|
+
<section class="cols-3 gap-thin">
|
101
86
|
<div
|
102
87
|
class="radius-medium bg-grey"
|
103
88
|
v-for="income in state.rewards"
|
104
89
|
>
|
105
|
-
<div class="flex-nowrap
|
106
|
-
|
90
|
+
<div class="flex-nowrap br-b br-black-transp-10 br-solid flex pd-medium">
|
91
|
+
<img src="/logo/wdt-plus.svg" class="mn-r-thin i-semi">
|
107
92
|
<p class="t-semi mn-r-auto">{{income.amount}} WDT</p>
|
108
93
|
|
109
94
|
<span class="pd-t-nano pd-b-nano pd-l-thin pd-r-thin bg-main flex flex-center radius-extra t-semi p-small">{{income.type === 'blogpost' ? 'Community Reward' : income.type}}</span>
|
110
95
|
</div>
|
111
96
|
|
112
97
|
<div class="pd-medium">
|
113
|
-
<h4 class="mn-b-thin">{{income.name}}</h4>
|
114
|
-
<p class="p-small">{{income.content[0].content}}</p>
|
98
|
+
<h4 class="t-regular mn-b-thin">{{income.name}}</h4>
|
99
|
+
<!-- <p class="p-small">{{income.content[0].content}}</p> -->
|
115
100
|
</div>
|
116
101
|
|
117
102
|
</div>
|
@@ -26,6 +26,85 @@ const cryptoControllerFactory = (db, wdmClient) => {
|
|
26
26
|
const Comment = db.comment;
|
27
27
|
const Reward = db.reward;
|
28
28
|
|
29
|
+
// const listRewards = async (req, res) => {
|
30
|
+
// try {
|
31
|
+
// const rewards = await Blogpost.aggregate([
|
32
|
+
// // Шаг 1: Фильтрация блогпостов по создателю
|
33
|
+
// { $match: { "creator.target": req.userId } },
|
34
|
+
// // Шаг 2: Соединение с Reaction для подсчета реакций
|
35
|
+
// {
|
36
|
+
// $lookup: {
|
37
|
+
// from: "reactions",
|
38
|
+
// localField: "_id",
|
39
|
+
// foreignField: "target",
|
40
|
+
// as: "reactions"
|
41
|
+
// }
|
42
|
+
// },
|
43
|
+
// // Шаг 3: Соединение с Comment для подсчета комментариев
|
44
|
+
// {
|
45
|
+
// $lookup: {
|
46
|
+
// from: "comments",
|
47
|
+
// localField: "_id",
|
48
|
+
// foreignField: "target",
|
49
|
+
// as: "comments"
|
50
|
+
// }
|
51
|
+
// },
|
52
|
+
// // Шаг 4: Соединение с Reward для получения предыдущих наград
|
53
|
+
// {
|
54
|
+
// $lookup: {
|
55
|
+
// from: "rewards",
|
56
|
+
// let: { blogId: "$_id", userId: req.userId },
|
57
|
+
// pipeline: [
|
58
|
+
// { $match: {
|
59
|
+
// $expr: {
|
60
|
+
// $and: [
|
61
|
+
// { $eq: ["$user", "$$userId"] },
|
62
|
+
// { $eq: ["$type", "blogpost"] },
|
63
|
+
// { $eq: ["$target", "$$blogId"] }
|
64
|
+
// ]
|
65
|
+
// }
|
66
|
+
// }
|
67
|
+
// },
|
68
|
+
// { $sort: { createdAt: -1 } },
|
69
|
+
// { $limit: 1 }
|
70
|
+
// ],
|
71
|
+
// as: "previousReward"
|
72
|
+
// }
|
73
|
+
// },
|
74
|
+
// // Шаг 5: Проецирование результата и преобразование массивов в счетчики
|
75
|
+
// {
|
76
|
+
// $project: {
|
77
|
+
// user: req.userId,
|
78
|
+
// type: 'blogpost',
|
79
|
+
// name: "$name",
|
80
|
+
// content: "$content",
|
81
|
+
// url: "$url",
|
82
|
+
// views: "$views",
|
83
|
+
// reactionsCount: { $size: "$reactions" },
|
84
|
+
// commentsCount: { $size: "$comments" },
|
85
|
+
// previousRewardSnapshot: { $arrayElemAt: ["$previousReward.snapshot", 0] },
|
86
|
+
// }
|
87
|
+
// }
|
88
|
+
// ]).exec();
|
89
|
+
|
90
|
+
// // Пересчет наград на основе полученных данных
|
91
|
+
// const calculatedRewards = rewards.map(reward => ({
|
92
|
+
// ...reward,
|
93
|
+
// amount: calculateRewardForPost(
|
94
|
+
// reward.previousRewardSnapshot,
|
95
|
+
// reward.views,
|
96
|
+
// reward.reactionsCount,
|
97
|
+
// reward.commentsCount
|
98
|
+
// ).toString(),
|
99
|
+
// }));
|
100
|
+
|
101
|
+
// res.status(200).send(calculatedRewards);
|
102
|
+
// } catch (error) {
|
103
|
+
// console.error("Error listing rewards:", error);
|
104
|
+
// res.status(500).send({ message: "Internal server error" });
|
105
|
+
// }
|
106
|
+
// };
|
107
|
+
|
29
108
|
const listRewards = async (req, res) => {
|
30
109
|
const blogs = await Blogpost.find({ "creator.target": req.userId }).exec();
|
31
110
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module.exports = (mongoose) => {
|
2
|
+
const WalletSchema = new mongoose.Schema(
|
3
|
+
{
|
4
|
+
owner: {
|
5
|
+
type: mongoose.Schema.Types.ObjectId,
|
6
|
+
ref: () => {
|
7
|
+
if (this.owner.type === 'user') return 'User';
|
8
|
+
if (this.owner.type === 'organization') return 'Organization';
|
9
|
+
},
|
10
|
+
required: true,
|
11
|
+
},
|
12
|
+
amount: {
|
13
|
+
type: Number,
|
14
|
+
required: true,
|
15
|
+
default: 0
|
16
|
+
},
|
17
|
+
},
|
18
|
+
{
|
19
|
+
timestamps: {
|
20
|
+
currentTime: () => Date.now(),
|
21
|
+
},
|
22
|
+
},
|
23
|
+
{ strict: false },
|
24
|
+
);
|
25
|
+
|
26
|
+
return mongoose.model("Wallet", WalletSchema);
|
27
|
+
};
|
/package/src/modules/{orders/models/payment.model.js → payments/models/payment.tinkoff.model.js}
RENAMED
File without changes
|