Compare commits
175 Commits
1.2.62
...
Ver_1.0.24
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0c2a8ecef5 | ||
|
|
aeabf96efe | ||
|
|
e4504bcf9e | ||
|
|
dbcdbd689b | ||
|
|
f6a0876178 | ||
|
|
1ef3103a9d | ||
|
|
d7122af70e | ||
|
|
3d1a330fa2 | ||
|
|
a2c9dcb38c | ||
|
|
d22e808626 | ||
|
|
9265e9bfb3 | ||
|
|
504e9fd88c | ||
|
|
4b9fe4d267 | ||
|
|
d81f533ecb | ||
|
|
65d75cb2c5 | ||
|
|
212f895650 | ||
|
|
3183825137 | ||
|
|
79ca364e84 | ||
|
|
7bf549569d | ||
|
|
c63e345285 | ||
|
|
9b4a9dbf28 | ||
|
|
a71c487697 | ||
|
|
3dfb990620 | ||
|
|
4cdc4f7de1 | ||
|
|
7ea6c2a76b | ||
|
|
db81980046 | ||
|
|
fb16a1729e | ||
|
|
d7ae8baec4 | ||
|
|
b754492b41 | ||
|
|
0aaa331b3f | ||
|
|
66e4c577c7 | ||
|
|
75ef581635 | ||
|
|
4e0c18f47c | ||
|
|
3fb78ff39a | ||
|
|
6313476d54 | ||
|
|
b6204c7612 | ||
|
|
ade9c149c5 | ||
|
|
633b9a2d8c | ||
|
|
3d1dddba39 | ||
|
|
db7724cca4 | ||
|
|
5afe9dd1e2 | ||
|
|
c001587702 | ||
|
|
ca6d29414a | ||
|
|
f23047bcd5 | ||
|
|
15d831eecc | ||
|
|
f0495d93b3 | ||
|
|
0eb287db06 | ||
|
|
322bfb9738 | ||
|
|
428a5ca0e9 | ||
|
|
000e900f48 | ||
|
|
2ab4bd4e2a | ||
|
|
7af909d2be | ||
|
|
0e1fc359a0 | ||
|
|
d00c7eccc8 | ||
|
|
7e7d7ca6b4 | ||
|
|
a3913a4575 | ||
|
|
7628fb97fc | ||
|
|
56b5bac5f0 | ||
|
|
e7021e1f14 | ||
|
|
139d7ea33c | ||
|
|
50d610b1b1 | ||
|
|
c71f4af370 | ||
|
|
4290895a97 | ||
|
|
ab3a31d4fb | ||
|
|
1ca72118f1 | ||
|
|
4d9eccd1ae | ||
|
|
05ec283882 | ||
|
|
ea2b7095c9 | ||
|
|
d0bf7e1b6a | ||
|
|
fcdd826c54 | ||
|
|
a2bd4f6e97 | ||
|
|
5f3c8a65ea | ||
|
|
caadbaae5f | ||
|
|
296b7b4fb8 | ||
|
|
ff81ab7be3 | ||
|
|
8ce4f66c55 | ||
|
|
daacde7455 | ||
|
|
023ba26003 | ||
|
|
502ed32c42 | ||
|
|
74c4a829b0 | ||
|
|
f7bcb0c361 | ||
|
|
72a7e3fa37 | ||
|
|
4871c2d868 | ||
|
|
d5bc76335f | ||
|
|
6edba03eff | ||
|
|
8e42baf79e | ||
|
|
e3ed2934ee | ||
|
|
e895e7dae2 | ||
|
|
4a408b4ebd | ||
|
|
0e3ba5ff87 | ||
|
|
a66cd610dd | ||
|
|
5aa6accfc5 | ||
|
|
35178684af | ||
|
|
bba0df4302 | ||
|
|
f1954d98d6 | ||
|
|
34b00bdf98 | ||
|
|
0cfabed233 | ||
|
|
c92dc8f216 | ||
|
|
7b14c09fd5 | ||
|
|
2258e8e7e1 | ||
|
|
e8c961f500 | ||
|
|
b395d1a30a | ||
|
|
341af6a3b2 | ||
|
|
3d876687b6 | ||
|
|
560a532a85 | ||
|
|
aac8ce0a4c | ||
|
|
d434374ed9 | ||
|
|
045057082c | ||
|
|
18c5630a45 | ||
|
|
7f1bd15bcf | ||
|
|
c1a9a9a555 | ||
|
|
536fbd1752 | ||
|
|
d6303f5880 | ||
|
|
b6579832b6 | ||
|
|
04c8e929ee | ||
|
|
142dcadca9 | ||
|
|
ad6b4c2bfa | ||
|
|
ba81a33c88 | ||
|
|
baf56b59d0 | ||
|
|
3393af36aa | ||
|
|
95a812f002 | ||
|
|
aff50b03d4 | ||
|
|
e28cd5f043 | ||
|
|
9e499b8f43 | ||
|
|
84328e7bcd | ||
|
|
a79e79a85e | ||
|
|
0945f1af08 | ||
|
|
eea6e63c58 | ||
|
|
cda0bff21f | ||
|
|
cada7aa0b6 | ||
|
|
f13786fca1 | ||
|
|
5bb6611384 | ||
|
|
0d5bff5849 | ||
|
|
198b5914bc | ||
|
|
94ef2c4c85 | ||
|
|
8a77dabc22 | ||
|
|
6d1ad4132f | ||
|
|
e92edcbe78 | ||
|
|
561bab57a8 | ||
|
|
00e9aafd4c | ||
|
|
5993112a8e | ||
|
|
7482b65743 | ||
|
|
e705594294 | ||
|
|
6a4c270c91 | ||
|
|
39cc9b66d6 | ||
|
|
4effda98ec | ||
|
|
84ceed500d | ||
|
|
0076adac76 | ||
|
|
874114942a | ||
|
|
a81300e13d | ||
|
|
81d7d32b85 | ||
|
|
402a9c373e | ||
|
|
6e7eb31d38 | ||
|
|
022ad11747 | ||
|
|
7bf6f91a97 | ||
|
|
2d213b7020 | ||
|
|
aa9d27c8fd | ||
|
|
9a0f0a0cc6 | ||
|
|
5f3ce44a68 | ||
|
|
73aa780733 | ||
|
|
b9e4dbbaec | ||
|
|
8e7b9fb5bd | ||
|
|
f7d05eb856 | ||
|
|
e13fe84709 | ||
|
|
dd51982795 | ||
|
|
a4b42a1fc3 | ||
|
|
331c2e6780 | ||
|
|
399153f477 | ||
|
|
d1135f1151 | ||
|
|
d183a07bad | ||
|
|
f42a39d231 | ||
|
|
dd1c9d573f | ||
|
|
18b827f5f4 | ||
|
|
7a41e6a1d4 | ||
|
|
7e1407cbb1 |
4
.dockerignore
Normal file
4
.dockerignore
Normal file
@@ -0,0 +1,4 @@
|
||||
./node_modules
|
||||
Dockerfile
|
||||
.dockerignore
|
||||
docker-compose.yml
|
||||
38
.env.dev.pcb
Normal file
38
.env.dev.pcb
Normal file
@@ -0,0 +1,38 @@
|
||||
DATABASE=test_PiuCheBuono
|
||||
UDB=paofreeplanet
|
||||
PDB=mypassword@1A
|
||||
SEND_EMAIL=0
|
||||
SEND_EMAIL_ORDERS=1
|
||||
PORT=3000
|
||||
appTelegram_TEST=["1","13"]
|
||||
appTelegram=["1","13"]
|
||||
DOMAIN=mongodb://localhost:27017/
|
||||
AUTH_MONGODB=true
|
||||
MONGODB_USER=admin
|
||||
MONGODB_PWD=mypwadmin@1A
|
||||
ENABLE_PUSHNOTIFICATION=1
|
||||
URLBASE_APP1=https://localhost
|
||||
PORT_APP1=8080
|
||||
SIGNCODE=SU2134hncaskjdbo231oihJSDNHEI$1@AB
|
||||
HTTPS_LOCALHOST=true
|
||||
DEBUG=0
|
||||
DEBUG=0
|
||||
TESTING_ON=1
|
||||
LOCALE=1
|
||||
DELAY_SENDEMAIL=2000
|
||||
VAPI_KEY_SUBJECT=mailto:paolo@freeplanet.app
|
||||
PUBLIC_VAPI_KEY=BDncvMiUZmjaCG2Kr1V9N0_33hOG-AuNSbHSvL24y2dzBiUjAxKm02emx5SeJvz2IGmtRf6YqCgopeQwCwUmZw8
|
||||
PRIVATE_VAPI_KEY=uB2-jQkrbysyDtqN3ziMBDsVn0wdEaDsksX81zoOGQo
|
||||
PATH_CERT_KEY=localhost.key
|
||||
PATH_SERVER_CRT=localhost.crt
|
||||
PATH_SSL_ROOT_PEM=root.pem
|
||||
PATH_SSL_CHAIN_PEM=chain.pem
|
||||
GCM_API_KEY=""
|
||||
PROD=0
|
||||
PROJECT_DESCR_MAIN='__PROJECTS'
|
||||
SECRK=Askb38v23jjDFaoskBOWj92axXCQ
|
||||
FTPSERVER_HOST=139.162.166.31
|
||||
FTPSERVER_PORT=21
|
||||
FTPSERVER_USER=ftpusrsrv_
|
||||
FTPSERVER_PWD=ftpmypwd@1A_
|
||||
AUTH_NEW_SITES=123123123
|
||||
38
.env.dev.riso
Normal file
38
.env.dev.riso
Normal file
@@ -0,0 +1,38 @@
|
||||
DATABASE=test_FreePlanet
|
||||
UDB=paofreeplanet
|
||||
PDB=mypassword@1A
|
||||
SEND_EMAIL=0
|
||||
SEND_EMAIL_ORDERS=1
|
||||
PORT=3000
|
||||
appTelegram_TEST=["1","13"]
|
||||
appTelegram=["1","13"]
|
||||
DOMAIN=mongodb://localhost:27017/
|
||||
AUTH_MONGODB=true
|
||||
MONGODB_USER=admin
|
||||
MONGODB_PWD=mypwadmin@1A
|
||||
ENABLE_PUSHNOTIFICATION=1
|
||||
URLBASE_APP1=https://localhost
|
||||
PORT_APP1=8080
|
||||
SIGNCODE=SU2134hncaskjdbo231oihJSDNHEI$1@AB
|
||||
HTTPS_LOCALHOST=true
|
||||
DEBUG=0
|
||||
DEBUG=0
|
||||
TESTING_ON=1
|
||||
LOCALE=1
|
||||
DELAY_SENDEMAIL=2000
|
||||
VAPI_KEY_SUBJECT=mailto:paolo@freeplanet.app
|
||||
PUBLIC_VAPI_KEY=BDncvMiUZmjaCG2Kr1V9N0_33hOG-AuNSbHSvL24y2dzBiUjAxKm02emx5SeJvz2IGmtRf6YqCgopeQwCwUmZw8
|
||||
PRIVATE_VAPI_KEY=uB2-jQkrbysyDtqN3ziMBDsVn0wdEaDsksX81zoOGQo
|
||||
PATH_CERT_KEY=localhost.key
|
||||
PATH_SERVER_CRT=localhost.crt
|
||||
PATH_SSL_ROOT_PEM=root.pem
|
||||
PATH_SSL_CHAIN_PEM=chain.pem
|
||||
GCM_API_KEY=""
|
||||
PROD=0
|
||||
PROJECT_DESCR_MAIN='__PROJECTS'
|
||||
SECRK=Askb38v23jjDFaoskBOWj92axXCQ
|
||||
FTPSERVER_HOST=139.162.166.31
|
||||
FTPSERVER_PORT=21
|
||||
FTPSERVER_USER=ftpusrsrv_
|
||||
FTPSERVER_PWD=ftpmypwd@1A_
|
||||
AUTH_NEW_SITES=123123123
|
||||
38
.env.development
Normal file
38
.env.development
Normal file
@@ -0,0 +1,38 @@
|
||||
DATABASE=test_FreePlanet
|
||||
UDB=paofreeplanet
|
||||
PDB=mypassword@1A
|
||||
SEND_EMAIL=0
|
||||
SEND_EMAIL_ORDERS=1
|
||||
PORT=3000
|
||||
appTelegram_TEST=["1","13"]
|
||||
appTelegram=["1","13"]
|
||||
DOMAIN=mongodb://localhost:27017/
|
||||
AUTH_MONGODB=true
|
||||
MONGODB_USER=admin
|
||||
MONGODB_PWD=mypwadmin@1A
|
||||
ENABLE_PUSHNOTIFICATION=1
|
||||
URLBASE_APP1=https://localhost
|
||||
PORT_APP1=8080
|
||||
SIGNCODE=SU2134hncaskjdbo231oihJSDNHEI$1@AB
|
||||
HTTPS_LOCALHOST=true
|
||||
DEBUG=0
|
||||
DEBUG=0
|
||||
TESTING_ON=1
|
||||
LOCALE=1
|
||||
DELAY_SENDEMAIL=2000
|
||||
VAPI_KEY_SUBJECT=mailto:paolo@freeplanet.app
|
||||
PUBLIC_VAPI_KEY=BDncvMiUZmjaCG2Kr1V9N0_33hOG-AuNSbHSvL24y2dzBiUjAxKm02emx5SeJvz2IGmtRf6YqCgopeQwCwUmZw8
|
||||
PRIVATE_VAPI_KEY=uB2-jQkrbysyDtqN3ziMBDsVn0wdEaDsksX81zoOGQo
|
||||
PATH_CERT_KEY=localhost.key
|
||||
PATH_SERVER_CRT=localhost.crt
|
||||
PATH_SSL_ROOT_PEM=root.pem
|
||||
PATH_SSL_CHAIN_PEM=chain.pem
|
||||
GCM_API_KEY=""
|
||||
PROD=0
|
||||
PROJECT_DESCR_MAIN='__PROJECTS'
|
||||
SECRK=Askb38v23jjDFaoskBOWj92axXCQ
|
||||
FTPSERVER_HOST=139.162.166.31
|
||||
FTPSERVER_PORT=21
|
||||
FTPSERVER_USER=ftpusrsrv_
|
||||
FTPSERVER_PWD=ftpmypwd@1A_
|
||||
AUTH_NEW_SITES=123123123
|
||||
32
.env.prod.pcb
Normal file
32
.env.prod.pcb
Normal file
@@ -0,0 +1,32 @@
|
||||
DATABASE=PiuCheBuono
|
||||
UDB=paofreeplanet
|
||||
PDB=suerteFreePlanet@1A
|
||||
SEND_EMAIL=1
|
||||
SEND_EMAIL_ORDERS=1
|
||||
PORT=3000
|
||||
appTelegram_TEST=["17"]
|
||||
appTelegram=["17"]
|
||||
ENABLE_PUSHNOTIFICATION=1
|
||||
DIRECTORY_SERVER=freeplanet_serverside
|
||||
SERVERDIR_WEBSITE=www.freeplanet_server
|
||||
PORT_APP1="0"
|
||||
DOMAIN=mongodb://localhost:32001/
|
||||
AUTH_MONGODB=1
|
||||
MONGODB_USER=admin
|
||||
MONGODB_PWD=mypwadminREAL@1A
|
||||
SIGNCODE=SU2134hncaskjdbo231oihJSDNHEI$1@AB
|
||||
DEBUG=0
|
||||
LOCALE=0
|
||||
DELAY_SENDEMAIL=1000
|
||||
VAPI_KEY_SUBJECT="mailto:surya@riso.app"
|
||||
PUBLIC_VAPI_KEY="BJgo8XR_upbnbMLWgCAUELo6DK7dRXffYAnFOxbaMMz5favBgcQBKT-eISqouO-jRad4Sw8l5nd2wCF6KorGiTc"
|
||||
PRIVATE_VAPI_KEY="LVpFDJuKscdHuQr5pe20dFuYuWX1-ZRb6x72PP-Pp4I"
|
||||
GCM_API_KEY="AIzaSyD7w1jztfVV05mX1iyxoI-r1pZWxuxdUK8"
|
||||
PATH_CERT_KEY=key.pem
|
||||
PATH_SERVER_CRT=cert.pem
|
||||
PATH_SSL_ROOT_PEM=root.pem
|
||||
PATH_SSL_CHAIN_PEM=chain.pem
|
||||
PROD=0
|
||||
PROJECT_DESCR_MAIN='__PROJECTS'
|
||||
SECRK=iUUb38v23jjDFaosWj92axkBOXCQ
|
||||
AUTH_NEW_SITES=B234HDSAOJ734ndcsdKWNVZZ
|
||||
32
.env.test.pcb
Normal file
32
.env.test.pcb
Normal file
@@ -0,0 +1,32 @@
|
||||
DATABASE=test_PiuCheBuono
|
||||
UDB=paofreeplanet
|
||||
PDB=suerteFreePlanet@1A
|
||||
SEND_EMAIL=1
|
||||
SEND_EMAIL_ORDERS=1
|
||||
PORT=3001
|
||||
appTelegram_TEST=["17"]
|
||||
appTelegram=["17"]
|
||||
ENABLE_PUSHNOTIFICATION=1
|
||||
DIRECTORY_SERVER=freeplanet_serverside
|
||||
SERVERDIR_WEBSITE=test.freeplanet_server
|
||||
PORT_APP1="0"
|
||||
DOMAIN=mongodb://localhost:32002/
|
||||
AUTH_MONGODB=1
|
||||
MONGODB_USER=admin
|
||||
MONGODB_PWD=mypwadmin@1A
|
||||
SIGNCODE=SU2134hncaskjdbo231oihJSDNHEI$1@AB
|
||||
DEBUG=0
|
||||
LOCALE=0
|
||||
DELAY_SENDEMAIL=1000
|
||||
VAPI_KEY_SUBJECT="mailto:surya@riso.app"
|
||||
PUBLIC_VAPI_KEY="BJgo8XR_upbnbMLWgCAUELo6DK7dRXffYAnFOxbaMMz5favBgcQBKT-eISqouO-jRad4Sw8l5nd2wCF6KorGiTc"
|
||||
PRIVATE_VAPI_KEY="LVpFDJuKscdHuQr5pe20dFuYuWX1-ZRb6x72PP-Pp4I"
|
||||
GCM_API_KEY="AIzaSyD7w1jztfVV05mX1iyxoI-r1pZWxuxdUK8"
|
||||
PATH_CERT_KEY=key.pem
|
||||
PATH_SERVER_CRT=cert.pem
|
||||
PATH_SSL_ROOT_PEM=root.pem
|
||||
PATH_SSL_CHAIN_PEM=chain.pem
|
||||
PROD=0
|
||||
PROJECT_DESCR_MAIN='__PROJECTS'
|
||||
SECRK=iUUb38v23jjDFaosWj92axkBOXCQ
|
||||
AUTH_NEW_SITES=B234HDSAOJ734ndcsdKWNV
|
||||
29
.env.test.risosrv
Normal file
29
.env.test.risosrv
Normal file
@@ -0,0 +1,29 @@
|
||||
DATABASE=test_FreePlanet
|
||||
UDB=paofreeplanet
|
||||
PDB=suerteFreePlanet@1A
|
||||
SEND_EMAIL=1
|
||||
PORT=3001
|
||||
ENABLE_PUSHNOTIFICATION=1
|
||||
DIRECTORY_SERVER=freeplanet_serverside
|
||||
SERVERDIR_WEBSITE=test.freeplanet_server
|
||||
PORT_APP1="0"
|
||||
DOMAIN=mongodb://localhost:27018/
|
||||
AUTH_MONGODB=1
|
||||
MONGODB_USER=admin
|
||||
MONGODB_PWD=mypwadmin@1A
|
||||
SIGNCODE=SU2134hncaskjdbo231oihJSDNHEI$1@AB
|
||||
DEBUG=0
|
||||
LOCALE=0
|
||||
DELAY_SENDEMAIL=1000
|
||||
VAPI_KEY_SUBJECT="mailto:surya@riso.app"
|
||||
PUBLIC_VAPI_KEY="BGXRf1TgcqocqD6J7qnRgCG7AvM2lxAoW7peb7UEzB4SxBb6DxGRdJ0UvD9ewnrB9KrSrh0-aDCODXBm7sZ1DDs"
|
||||
PRIVATE_VAPI_KEY="St9UMzcS76Q9yKG6RInAuYydYjFRliqwHTJY3A5wjO0"
|
||||
GCM_API_KEY="AIzaSyD7w1jztfVV05mX1iyxoI-r1pZWxuxdUK8"
|
||||
PATH_CERT_KEY=key.pem
|
||||
PATH_SERVER_CRT=cert.pem
|
||||
PATH_SSL_ROOT_PEM=root.pem
|
||||
PATH_SSL_CHAIN_PEM=chain.pem
|
||||
PROD=0
|
||||
PROJECT_DESCR_MAIN='__PROJECTS'
|
||||
SECRK=iUUb38v23jjDFaosWj92axkBOXCQ
|
||||
AUTH_NEW_SITES=B234HDSAOJ734ndcsdKWNV
|
||||
6
.gitignore
vendored
6
.gitignore
vendored
@@ -1,6 +1,5 @@
|
||||
node_modules/
|
||||
.env.test
|
||||
.env.development
|
||||
.env.production
|
||||
.env.production.bak
|
||||
ESEMPI/
|
||||
@@ -25,3 +24,8 @@ src/.DS_Store
|
||||
.gitignore
|
||||
src/server/router/.DS_Store
|
||||
src/server/.DS_Store
|
||||
emails/.DS_Store
|
||||
.DS_Store
|
||||
.DS_Store
|
||||
.DS_Store
|
||||
logtrans.txt
|
||||
|
||||
51
.vscode/launch.json
vendored
51
.vscode/launch.json
vendored
@@ -2,17 +2,50 @@
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Server Debug",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Launch via Nodemon",
|
||||
"program": "${workspaceFolder}/node_modules/nodemon/bin/nodemon.js",
|
||||
"restart": true,
|
||||
"runtimeExecutable": "node",
|
||||
"runtimeArgs": [
|
||||
"run-script",
|
||||
"start"
|
||||
"--inspect=9229" // Use "--inspect=0.0.0.0:9229" for remote debugging
|
||||
],
|
||||
"runtimeExecutable": "npm",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
"args": [
|
||||
"${workspaceFolder}/src/server/server.js"
|
||||
], // Replace with your entry file
|
||||
"cwd": "${workspaceFolder}",
|
||||
"autoAttachChildProcesses": true,
|
||||
"console": "integratedTerminal",
|
||||
"internalConsoleOptions": "neverOpen",
|
||||
"sourceMaps": true,
|
||||
"env": {
|
||||
"NODE_ENV": "development",
|
||||
"TESTING_ON": "1"
|
||||
},
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Launch Trace Warning",
|
||||
"program": "${workspaceFolder}/node_modules/nodemon/bin/nodemon.js",
|
||||
"restart": true,
|
||||
"runtimeExecutable": "node",
|
||||
"runtimeArgs": [
|
||||
"--trace-warnings" // Use "--inspect=0.0.0.0:9229" for remote debugging
|
||||
],
|
||||
"type": "node"
|
||||
"args": [
|
||||
"${workspaceFolder}/src/server/server.js"
|
||||
], // Replace with your entry file
|
||||
"cwd": "${workspaceFolder}",
|
||||
"autoAttachChildProcesses": true,
|
||||
"console": "integratedTerminal",
|
||||
"internalConsoleOptions": "neverOpen",
|
||||
"sourceMaps": true,
|
||||
"env": {
|
||||
"NODE_ENV": "development",
|
||||
"TESTING_ON": "1"
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "ServerSide",
|
||||
@@ -23,8 +56,8 @@
|
||||
],
|
||||
"type": "node",
|
||||
"env": {
|
||||
"NODE_ENV":"development",
|
||||
"TESTING_ON":"1"
|
||||
"NODE_ENV": "development",
|
||||
"TESTING_ON": "1"
|
||||
}
|
||||
},
|
||||
]
|
||||
|
||||
7
.vscode/settings.json
vendored
Normal file
7
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"search.useIgnoreFiles": false,
|
||||
"files.watcherExclude": {
|
||||
"**/.git/objects/**": true,
|
||||
"**/node_modules/**": true
|
||||
},
|
||||
}
|
||||
7
Dockerfile
Normal file
7
Dockerfile
Normal file
@@ -0,0 +1,7 @@
|
||||
FROM node:alpine
|
||||
WORKDIR /Users/suryapaolo/myproject/freeplanet_serverside
|
||||
COPY package*.json .
|
||||
RUN npm ci
|
||||
COPY . .
|
||||
#CMD ["npm", "start"]
|
||||
CMD ["npm", "run", "dev"]
|
||||
18
deploy_solo1.sh
Executable file
18
deploy_solo1.sh
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
source ./.env.production
|
||||
|
||||
msg="*** SERVER DI PRODUZIONE **** SEI SICURO DI INVIARE IL SINGOLO FILE GENERAL.JS - SUL SERVER DI PRODUZIONE ?? $SERVERDIR_WEBSITE (Y/N) ? "
|
||||
|
||||
if [ "$1" = "" ]; then
|
||||
read -p "$msg" risposta
|
||||
else
|
||||
echo $msg
|
||||
risposta=$1
|
||||
fi
|
||||
|
||||
if [[ $risposta == "Y" || $risposta == "y" ]]; then
|
||||
echo "Sincronizzazione di 1 FILE in corso..."
|
||||
rsync -avz -e 'ssh -p 8855' src/server/tools/general.js suryapaolo@servereng:/var/www/$SERVERDIR_WEBSITE/src/server/tools/general.js
|
||||
echo "Sincronizzazione TERMINATA - SERVER PRODUZIONE!"
|
||||
fi
|
||||
18
deploynode_on_prod_pcb.sh
Executable file
18
deploynode_on_prod_pcb.sh
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
source ./.env.prod.pcb
|
||||
|
||||
echo "Sincronizzazione in corso PCB PRODUZIONE ... /var/www/$SERVERDIR_WEBSITE/"
|
||||
echo ""
|
||||
|
||||
rsync -avz -e 'ssh -p 8822' css pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 8822' docs pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 8822' emails pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 8822' images pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 8822' plugins pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 8822' sass pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 8822' src pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 8822' .env.prod.pcb pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/.env.production
|
||||
rsync -avz -e 'ssh -p 8822' package.json pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/package.json
|
||||
|
||||
echo "Sincronizzazione TERMINATA! - SERVER PCB!"
|
||||
19
deploynode_on_test_pcb.sh
Executable file
19
deploynode_on_test_pcb.sh
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
source ./.env.test.pcb
|
||||
|
||||
echo "Sincronizzazione in corso PCB TEST ... /var/www/$SERVERDIR_WEBSITE/"
|
||||
echo ""
|
||||
|
||||
rsync -avz -e 'ssh -p 8822' css pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 8822' docs pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 8822' emails pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 8822' images pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 8822' plugins pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 8822' sass pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 8822' src pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 8822' .env.test.pcb pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/.env.test
|
||||
rsync -avz -e 'ssh -p 8822' .env.test.pcb pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 8822' package.json pcbuser@pcb:/var/www/$SERVERDIR_WEBSITE/package.json
|
||||
|
||||
echo "Sincronizzazione TERMINATA! - SERVER PCB!"
|
||||
16
deploynodejs_on_risosrv_test.sh
Executable file
16
deploynodejs_on_risosrv_test.sh
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
source ./.env.test.risosrv
|
||||
|
||||
echo "Sincronizzazione in corso..."
|
||||
rsync -avz -e 'ssh -p 5522' css root@risosrv:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 5522' docs root@risosrv:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 5522' emails root@risosrv:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 5522' images root@risosrv:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 5522' plugins root@risosrv:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 5522' sass root@risosrv:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 5522' src root@risosrv:/var/www/$SERVERDIR_WEBSITE/
|
||||
rsync -avz -e 'ssh -p 5522' .env.test.risosrv root@risosrv:/var/www/$SERVERDIR_WEBSITE/.env.test
|
||||
rsync -avz -e 'ssh -p 5522' package.json root@risosrv:/var/www/$SERVERDIR_WEBSITE/package.json
|
||||
|
||||
echo "Sincronizzazione TERMINATA! - SERVER TEST!"
|
||||
30
docker-compose.yml
Normal file
30
docker-compose.yml
Normal file
@@ -0,0 +1,30 @@
|
||||
version: '3.9'
|
||||
|
||||
services:
|
||||
# mongoDB service
|
||||
mongo_db:
|
||||
container_name: db_container
|
||||
image: mongo:4.4
|
||||
restart: always
|
||||
ports:
|
||||
- 2717:27017
|
||||
volumes:
|
||||
- mongo_db:/data/db
|
||||
|
||||
# Node API service
|
||||
api:
|
||||
build: .
|
||||
ports:
|
||||
- 4000:3000
|
||||
volumes:
|
||||
- .:/Users/suryapaolo/myproject/freeplanet_serverside
|
||||
environment:
|
||||
PORT: 3000
|
||||
DOMAIN: mongodb://mongo_db:27017/
|
||||
DATABASE: test_FreePlanet
|
||||
UDB: paofreeplanet
|
||||
depends_on:
|
||||
- mongo_db
|
||||
|
||||
volumes:
|
||||
mongo_db: {}
|
||||
0
docs/prova.txt
Normal file
0
docs/prova.txt
Normal file
@@ -4,7 +4,10 @@ module.exports = {
|
||||
name: "FreePlanetServerSide",
|
||||
script: "./src/server/server.js",
|
||||
ignore_watch : ["node_modules"],
|
||||
interpreter: "/root/.nvm/versions/node/v16.19.0/bin/node",
|
||||
watch: false,
|
||||
//autorestart: true,
|
||||
instances: 1,
|
||||
env: {
|
||||
"PORT": 3000,
|
||||
"NODE_ENV": "development",
|
||||
@@ -17,9 +20,9 @@ module.exports = {
|
||||
"PORT": 3000,
|
||||
"NODE_ENV": "production",
|
||||
},
|
||||
log_file: "combined.outerr.log",
|
||||
error_file: "err.log",
|
||||
out_file: "out.log",
|
||||
log_file: "logs/combined.outerr.log",
|
||||
error_file: "logs/err.log",
|
||||
out_file: "logs/out.log",
|
||||
merge_logs: true,
|
||||
log_date_format: "YYYY-MM-DD HH:mm:ss.SSSS Z"
|
||||
}
|
||||
|
||||
BIN
emails/.DS_Store
vendored
Normal file
BIN
emails/.DS_Store
vendored
Normal file
Binary file not shown.
@@ -1,5 +1,6 @@
|
||||
p Ciao,
|
||||
p Ti avvisiamo che #{username} (#{name} #{surname}) ha appena cancellato la prenotazione per l'evento #{event}:
|
||||
span #{msgbooking}
|
||||
span #{participants}
|
||||
span #{participantsLunch}
|
||||
span #{participantsDinner}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
p Ciao,
|
||||
p Ti confermiamo che #{username} (#{name} #{surname}) ha appena inviato una richiesta di prenotazione per l'evento #{event}
|
||||
p #{msgbooking}
|
||||
p #{participants}
|
||||
p #{participantsLunch}
|
||||
p #{participantsDinner}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
p Ciao,
|
||||
p Ti confermiamo che #{username} (#{name} #{surname}) ha appena Modificato la sua prenotazione per l'evento #{event}
|
||||
p #{msgbooking}
|
||||
p #{participants}
|
||||
p #{participantsLunch}
|
||||
p #{participantsDinner}
|
||||
|
||||
BIN
emails/admin/registration/.DS_Store
vendored
Normal file
BIN
emails/admin/registration/.DS_Store
vendored
Normal file
Binary file not shown.
@@ -1,5 +1,6 @@
|
||||
p Ciao #{name},
|
||||
p Ti confermiamo che la prenotazione per l'evento "#{event}" è stata cancellata.
|
||||
p #{msgbooking}
|
||||
p #{participants}
|
||||
p #{participantsLunch}
|
||||
p #{participantsDinner}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
p Ciao #{name},
|
||||
p Ti confermiamo che hai appena inviato una richiesta di prenotazione per l'evento #{event}
|
||||
p #{msgbooking}
|
||||
p #{participants}
|
||||
p #{participantsLunch}
|
||||
p #{participantsDinner}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
p Ciao #{name},
|
||||
p Ti confermiamo che hai modificato la prenotazione per l'evento #{event}
|
||||
p #{msgbooking}
|
||||
p #{participants}
|
||||
p #{participantsLunch}
|
||||
p #{participantsDinner}
|
||||
|
||||
@@ -19,66 +19,112 @@ html
|
||||
}
|
||||
|
||||
body(yahoofix, style="background: #ffffff")
|
||||
- var baseimg = baseurl + '/statics/'
|
||||
- var baseimg = baseurl + '/'
|
||||
span(id='body_style', style='display:block')
|
||||
table(cellpadding="10", cellspacing="0", width="600", align="center")
|
||||
tr
|
||||
td(class="whitespace", height="10")
|
||||
p
|
||||
if (orders.items && orders.items.length > 0)
|
||||
- var mystorehouse = orders.items[0].order.storehouse
|
||||
else
|
||||
- var mystorehouse = null
|
||||
|
||||
tr
|
||||
td(class="emailContainer", valign="top")
|
||||
- var mioheader = mystorehouse.email_html_header
|
||||
if (mioheader)
|
||||
p!= mioheader
|
||||
|
||||
p Ciao #{username},
|
||||
p Ti confermiamo che hai appena inviato un'ordine di prenotazione dei seguenti prodotti:
|
||||
- var mioname = name
|
||||
if (!mioname)
|
||||
- var mioname = user.username
|
||||
|
||||
tr
|
||||
td(class="whitespace", height="10")
|
||||
p
|
||||
p Ciao #{mioname},
|
||||
|
||||
- var totalPrice = orders.totalPrice
|
||||
- var note = orders.note
|
||||
- var index = 0
|
||||
if (orders.items[0].order.quantitypreordered > 0)
|
||||
- var miomakeorder = mystorehouse.email_html_GAS_makeorder
|
||||
else
|
||||
- var miomakeorder = mystorehouse.email_html_makeorder
|
||||
|
||||
each product in orders.items
|
||||
- var descr = product.order.product.name
|
||||
- var img = product.order.product.img
|
||||
- var price = product.order.price
|
||||
- var after_price = product.order.after_price
|
||||
- var qty = product.order.quantity
|
||||
- index = index + 1
|
||||
if (miomakeorder)
|
||||
p!= miomakeorder
|
||||
else
|
||||
p Ti arriverà una email quando i prodotti saranno disponibili per poterli venire a ritirare.
|
||||
p Il pagamento, se non diversamente comunicato, potrai farlo direttamente in sede.
|
||||
|
||||
table(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")
|
||||
tr
|
||||
td(class="column", valign="center" width="40")
|
||||
p.boldhigh #{index}.
|
||||
|
||||
td(class="column sectionArticleImage", valign="top" width="150")
|
||||
table(cellpadding="0", cellspacing="0", summary="", border="0")
|
||||
tr
|
||||
td
|
||||
img(src=baseimg + img, alt="", width="150" height="150")
|
||||
td(class="column", valign="top")
|
||||
tr
|
||||
td(class="whitespace", height="10")
|
||||
p
|
||||
|
||||
table(cellpadding="0", cellspacing="0", summary="", border="0")
|
||||
tr
|
||||
td(class="sectionContentTitle boldhigh", valign="top")
|
||||
p #{descr}
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Prezzo: #{price} € #{after_price}
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Quantità: #{qty}
|
||||
- var totalPrice = orders.totalPrice
|
||||
- var note = orders.note
|
||||
- var index = 0
|
||||
|
||||
p Note Aggiuntive: #{note}
|
||||
each rec in orders.items
|
||||
- var descr = rec.order.product.productInfo.name
|
||||
- var img = rec.order.product.productInfo.img
|
||||
- var price = rec.order.price
|
||||
- var after_price = rec.order.after_price
|
||||
- var TotalPriceProduct = rec.order.TotalPriceProduct
|
||||
if (rec.order.gasordine)
|
||||
- var gasordine = rec.order.gasordine.name
|
||||
else
|
||||
- var gasordine = ''
|
||||
|
||||
p.sectionContentTitle.boldhigh.sectionTotal Totale Ordine: #{totalPrice} €
|
||||
- var qty = rec.order.quantity
|
||||
- var qtypreordered = rec.order.quantitypreordered
|
||||
- index = index + 1
|
||||
|
||||
table(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")
|
||||
tr
|
||||
td(class="column", valign="center" width="40")
|
||||
p.boldhigh #{index}.
|
||||
|
||||
td(class="column sectionArticleImage", valign="top" width="150")
|
||||
table(cellpadding="0", cellspacing="0", summary="", border="0")
|
||||
tr
|
||||
td
|
||||
img(src=baseimg + img, alt="", width="150" height="150")
|
||||
td(class="column", valign="top")
|
||||
|
||||
table(cellpadding="0", cellspacing="0", summary="", border="0")
|
||||
if (qtypreordered > 0)
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Gas Ordine: #{gasordine}
|
||||
p
|
||||
tr
|
||||
td(class="sectionContentTitle boldhigh", valign="top")
|
||||
p #{descr}
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Prezzo: #{price} € #{after_price}
|
||||
if (qty > 0)
|
||||
td(class="sectionContent", valign="top")
|
||||
p Quantità: #{qty}
|
||||
if (qtypreordered > 0)
|
||||
td(class="sectionContent", valign="top")
|
||||
p Quantità Prenotata: #{qtypreordered}
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Totale: #{TotalPriceProduct} €
|
||||
|
||||
if (note)
|
||||
p Note Aggiuntive: #{note}
|
||||
|
||||
p.sectionContentTitle.boldhigh.sectionTotal Totale Ordine: #{totalPrice} €
|
||||
tr
|
||||
td(class="whitespace", height="10")
|
||||
|
||||
p Ti arriverà una email quando i prodotti saranno disponibili per poterli venire a ritirare.
|
||||
p Il pagamento potrai farlo direttamente in sede.
|
||||
p Grazie Mille
|
||||
tr
|
||||
td
|
||||
- var miofooter = mystorehouse.email_html_footer
|
||||
if (miofooter)
|
||||
p!= miofooter
|
||||
else
|
||||
p Grazie Mille
|
||||
|
||||
table.footer(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")
|
||||
tr
|
||||
|
||||
@@ -28,7 +28,12 @@ html
|
||||
tr
|
||||
td(class="emailContainer", valign="top")
|
||||
|
||||
p Ciao #{name},
|
||||
- var mioname = name
|
||||
if (!mioname)
|
||||
- var mioname = user.username
|
||||
|
||||
p Ciao #{mioname},
|
||||
|
||||
p L'ordine è stato Cancellato.
|
||||
p Se è stato un errore, procedi a ripetere l'Ordine, ripartendo dalla lista prodotti.
|
||||
p Grazie Mille
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
doctype html
|
||||
html
|
||||
head
|
||||
title Ordine Completato
|
||||
|
||||
//- import css/scss stylesheets
|
||||
//- these file names will be replace by gulp with proper css file paths
|
||||
link(rel="stylesheet", href="../sass/basic.scss")
|
||||
link(rel="stylesheet", href="../sass/one/styles.scss")
|
||||
|
||||
//- embdedded css allowed, but not sass
|
||||
style.
|
||||
.red {
|
||||
background-color: #E84C50;
|
||||
}
|
||||
|
||||
.full-width {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
body(yahoofix, style="background: #ffffff")
|
||||
- var baseimg = baseurl + '/statics/'
|
||||
span(id='body_style', style='display:block')
|
||||
table(cellpadding="10", cellspacing="0", width="600", align="center")
|
||||
tr
|
||||
td(class="whitespace", height="10")
|
||||
p
|
||||
tr
|
||||
td(class="emailContainer", valign="top")
|
||||
|
||||
p Ciao #{name},
|
||||
p L'ordine n. #{ordernumber} è stato Completato correttamente !
|
||||
p Grazie Mille per aver contribuito a far crescere la Comunità
|
||||
|
||||
table.footer(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")
|
||||
tr
|
||||
td(class="whitespace", height="10")
|
||||
p
|
||||
tr
|
||||
td.firma
|
||||
p!= dataemail.firma
|
||||
|
||||
tr
|
||||
td.disclaimer
|
||||
p!= dataemail.disclaimer_out
|
||||
|
||||
tr
|
||||
td.bottom
|
||||
p!= dataemail.disc_bottom_out
|
||||
|
||||
tr
|
||||
td(class="whitespace", height="10")
|
||||
p
|
||||
|
||||
style(type="text/css").
|
||||
html, body {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.divbtn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.btn-lg {
|
||||
padding: 5px;
|
||||
margin: 5px;
|
||||
font-size: 26px;
|
||||
cursor: pointer;
|
||||
color: white;
|
||||
background: #027be3 !important;
|
||||
border-radius: 28px;
|
||||
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
=`Ordine n. ${ordernumber} Completato`
|
||||
168
emails/ecommerce/order_confirmed/it/html consegnato.pug
Executable file
168
emails/ecommerce/order_confirmed/it/html consegnato.pug
Executable file
@@ -0,0 +1,168 @@
|
||||
doctype html
|
||||
html
|
||||
head
|
||||
title Ordine n. #{ordernumber} Consegnato
|
||||
|
||||
//- import css/scss stylesheets
|
||||
//- these file names will be replace by gulp with proper css file paths
|
||||
link(rel="stylesheet", href="../sass/basic.scss")
|
||||
link(rel="stylesheet", href="../sass/one/styles.scss")
|
||||
|
||||
//- embdedded css allowed, but not sass
|
||||
style.
|
||||
.red {
|
||||
background-color: #E84C50;
|
||||
}
|
||||
|
||||
.full-width {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
body(yahoofix, style="background: #ffffff")
|
||||
- var baseimg = baseurl + '/';
|
||||
span(id='body_style', style='display:block')
|
||||
table(cellpadding="10", cellspacing="0", width="600", align="center")
|
||||
tr
|
||||
td(class="whitespace", height="10")
|
||||
p
|
||||
|
||||
if (orders.items && orders.items.length > 0)
|
||||
- var mystorehouse = orders.items[0].order.storehouse
|
||||
else
|
||||
- var mystorehouse = null
|
||||
|
||||
tr
|
||||
td(class="emailContainer", valign="top")
|
||||
|
||||
- var mioheader = mystorehouse.email_html_header
|
||||
if (mioheader)
|
||||
p!= mioheader
|
||||
else
|
||||
p Ciao #{name},
|
||||
|
||||
p L'ordine n. #{ordernumber} è stato Consegnato correttamente !
|
||||
|
||||
if (orders.items[0].order.quantitypreordered > 0)
|
||||
- var miomakeorder = mystorehouse.email_html_GAS_order_consegnato
|
||||
else
|
||||
- var miomakeorder = mystorehouse.email_html_order_consegnato
|
||||
|
||||
if (miomakeorder)
|
||||
p!= miomakeorder
|
||||
|
||||
- var totalPrice = orders.totalPrice
|
||||
- var note = orders.note
|
||||
- var index = 0
|
||||
|
||||
each rec in orders.items
|
||||
- var descr = rec.order.product.productInfo.name
|
||||
- var img = rec.order.product.productInfo.img
|
||||
- var price = rec.order.product.price
|
||||
- var after_price = rec.order.product.after_price
|
||||
if (rec.order.gasordine)
|
||||
- var gasordine = rec.order.gasordine.name
|
||||
else
|
||||
- var gasordine = ''
|
||||
- var qty = rec.order.product.quantity
|
||||
- var qtypreordered = rec.order.quantitypreordered
|
||||
- var TotalPriceProduct = rec.order.TotalPriceProduct
|
||||
- index = index + 1
|
||||
|
||||
table(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")
|
||||
tr
|
||||
td(class="column", valign="center" width="40")
|
||||
p.boldhigh #{index}.
|
||||
|
||||
td(class="column sectionArticleImage", valign="top" width="150")
|
||||
table(cellpadding="0", cellspacing="0", summary="", border="0")
|
||||
tr
|
||||
td
|
||||
img(src=baseimg + img, alt="", width="150" height="150")
|
||||
td(class="column", valign="top")
|
||||
|
||||
table(cellpadding="0", cellspacing="0", summary="", border="0")
|
||||
if (qtypreordered > 0)
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Gas Ordine: #{gasordine}
|
||||
p
|
||||
tr
|
||||
td(class="sectionContentTitle boldhigh", valign="top")
|
||||
p #{descr}
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Prezzo: #{price} € #{after_price}
|
||||
if (qty > 0)
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Quantità: #{qty}
|
||||
if (qtypreordered > 0)
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Quantità Prenotata: #{qtypreordered}
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Totale: #{TotalPriceProduct} €
|
||||
|
||||
if (note)
|
||||
p Note Aggiuntive: #{note}
|
||||
|
||||
p.sectionContentTitle.boldhigh.sectionTotal Totale Ordine: #{totalPrice} €
|
||||
tr
|
||||
td(class="whitespace", height="10")
|
||||
|
||||
tr
|
||||
td
|
||||
- var miofooter = mystorehouse.email_html_footer
|
||||
if (miofooter)
|
||||
p!= miofooter
|
||||
else
|
||||
p Grazie Mille
|
||||
|
||||
table.footer(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")
|
||||
tr
|
||||
td(class="whitespace", height="10")
|
||||
p
|
||||
tr
|
||||
td.firma
|
||||
p!= dataemail.firma
|
||||
|
||||
tr
|
||||
td.disclaimer
|
||||
p!= dataemail.disclaimer_out
|
||||
|
||||
tr
|
||||
td.bottom
|
||||
p!= dataemail.disc_bottom_out
|
||||
|
||||
tr
|
||||
td(class="whitespace", height="10")
|
||||
p
|
||||
|
||||
style(type="text/css").
|
||||
html, body {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
|
||||
.divbtn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.btn-lg {
|
||||
padding: 5px;
|
||||
margin: 5px;
|
||||
font-size: 26px;
|
||||
cursor: pointer;
|
||||
color: white;
|
||||
background: #027be3 !important;
|
||||
border-radius: 28px;
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
doctype html
|
||||
html
|
||||
head
|
||||
title Ordine Confermato
|
||||
title Ordine n. #{ordernumber} Confermato
|
||||
|
||||
//- import css/scss stylesheets
|
||||
//- these file names will be replace by gulp with proper css file paths
|
||||
@@ -19,32 +19,59 @@ html
|
||||
}
|
||||
|
||||
body(yahoofix, style="background: #ffffff")
|
||||
- var baseimg = baseurl + '/statics/'
|
||||
- var baseimg = baseurl + '/';
|
||||
span(id='body_style', style='display:block')
|
||||
table(cellpadding="10", cellspacing="0", width="600", align="center")
|
||||
tr
|
||||
td(class="whitespace", height="10")
|
||||
p
|
||||
|
||||
if (orders.items && orders.items.length > 0)
|
||||
- var mystorehouse = orders.items[0].order.storehouse
|
||||
else
|
||||
- var mystorehouse = null
|
||||
|
||||
tr
|
||||
td(class="emailContainer", valign="top")
|
||||
|
||||
p Ciao #{name},
|
||||
p L'ordine dei seguenti prodotti è stato Confermato:
|
||||
- var mioheader = mystorehouse.email_html_header
|
||||
if (mioheader)
|
||||
p!= mioheader
|
||||
|
||||
- var mioname = name
|
||||
if (!mioname)
|
||||
- var mioname = user.username
|
||||
|
||||
p Ciao #{mioname},
|
||||
|
||||
if (orders.items[0].order.quantitypreordered > 0)
|
||||
- var miordconfirmed = mystorehouse.email_html_GAS_order_confirmed
|
||||
else
|
||||
- var miordconfirmed = mystorehouse.email_html_order_confirmed
|
||||
|
||||
if (miordconfirmed)
|
||||
p!= miordconfirmed
|
||||
else
|
||||
p Puoi pertanto venire a ritirarli direttamente in sede, negli orari che ti sono stati indicati.
|
||||
|
||||
tr
|
||||
td(class="whitespace", height="10")
|
||||
p
|
||||
|
||||
- var totalPrice = orders.totalPrice
|
||||
- var note = orders.note
|
||||
- var index = 0
|
||||
|
||||
each product in orders.items
|
||||
- var descr = product.order.product.name
|
||||
- var img = product.order.product.img
|
||||
- var price = product.order.price
|
||||
- var after_price = product.order.after_price
|
||||
- var qty = product.order.quantity
|
||||
each rec in orders.items
|
||||
- var descr = rec.order.product.productInfo.name
|
||||
- var img = rec.order.product.productInfo.img
|
||||
- var price = rec.order.product.price
|
||||
- var after_price = rec.order.product.after_price
|
||||
if (rec.order.gasordine)
|
||||
- var gasordine = rec.order.gasordine.name
|
||||
else
|
||||
- var gasordine = ''
|
||||
- var qty = rec.order.product.quantity
|
||||
- var qtypreordered = rec.order.quantitypreordered
|
||||
- var TotalPriceProduct = rec.order.TotalPriceProduct
|
||||
- index = index + 1
|
||||
|
||||
table(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")
|
||||
@@ -60,24 +87,43 @@ html
|
||||
td(class="column", valign="top")
|
||||
|
||||
table(cellpadding="0", cellspacing="0", summary="", border="0")
|
||||
if (qtypreordered > 0)
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Gas Ordine: #{gasordine}
|
||||
p
|
||||
tr
|
||||
td(class="sectionContentTitle boldhigh", valign="top")
|
||||
p #{descr}
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Prezzo: #{price} € #{after_price}
|
||||
if (qty > 0)
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Quantità: #{qty}
|
||||
if (qtypreordered > 0)
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Quantità Prenotata: #{qtypreordered}
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Quantità: #{qty}
|
||||
p Totale: #{TotalPriceProduct} €
|
||||
|
||||
p Note Aggiuntive: #{note}
|
||||
if (note)
|
||||
p Note Aggiuntive: #{note}
|
||||
|
||||
p.sectionContentTitle.boldhigh.sectionTotal Totale Ordine: #{totalPrice} €
|
||||
tr
|
||||
td(class="whitespace", height="10")
|
||||
|
||||
p Puoi pertanto venire a ritirarli direttamente in sede.
|
||||
p Grazie Mille
|
||||
tr
|
||||
td
|
||||
- var miofooter = mystorehouse.email_html_footer
|
||||
if (miofooter)
|
||||
p!= miofooter
|
||||
else
|
||||
p Grazie Mille
|
||||
|
||||
table.footer(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")
|
||||
tr
|
||||
|
||||
173
emails/ecommerce/order_consegnato/it/html.pug
Executable file
173
emails/ecommerce/order_consegnato/it/html.pug
Executable file
@@ -0,0 +1,173 @@
|
||||
doctype html
|
||||
html
|
||||
head
|
||||
title Ordine n. #{ordernumber} Consegnato
|
||||
|
||||
//- import css/scss stylesheets
|
||||
//- these file names will be replace by gulp with proper css file paths
|
||||
link(rel="stylesheet", href="../sass/basic.scss")
|
||||
link(rel="stylesheet", href="../sass/one/styles.scss")
|
||||
|
||||
//- embdedded css allowed, but not sass
|
||||
style.
|
||||
.red {
|
||||
background-color: #E84C50;
|
||||
}
|
||||
|
||||
.full-width {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
body(yahoofix, style="background: #ffffff")
|
||||
- var baseimg = baseurl + '/';
|
||||
span(id='body_style', style='display:block')
|
||||
table(cellpadding="10", cellspacing="0", width="600", align="center")
|
||||
tr
|
||||
td(class="whitespace", height="10")
|
||||
p
|
||||
|
||||
if (orders.items && orders.items.length > 0)
|
||||
- var mystorehouse = orders.items[0].order.storehouse
|
||||
else
|
||||
- var mystorehouse = null
|
||||
|
||||
tr
|
||||
td(class="emailContainer", valign="top")
|
||||
|
||||
- var mioheader = mystorehouse.email_html_header
|
||||
if (mioheader)
|
||||
p!= mioheader
|
||||
|
||||
- var mioname = name
|
||||
if (!mioname)
|
||||
- var mioname = user.username
|
||||
|
||||
p Ciao #{mioname},
|
||||
p L'ordine n. #{ordernumber} è stato Consegnato correttamente 📦 !
|
||||
p Grazie per averci scelto 🙏🏻 e alla prossima !
|
||||
p
|
||||
|
||||
if (orders.items[0].order.quantitypreordered > 0)
|
||||
- var miomakeorder = mystorehouse.email_html_GAS_order_consegnato
|
||||
else
|
||||
- var miomakeorder = mystorehouse.email_html_order_consegnato
|
||||
|
||||
if (miomakeorder)
|
||||
p!= miomakeorder
|
||||
|
||||
- var totalPrice = orders.totalPrice
|
||||
- var note = orders.note
|
||||
- var index = 0
|
||||
|
||||
each rec in orders.items
|
||||
- var descr = rec.order.product.productInfo.name
|
||||
- var img = rec.order.product.productInfo.img
|
||||
- var price = rec.order.product.price
|
||||
- var after_price = rec.order.product.after_price
|
||||
if (rec.order.gasordine)
|
||||
- var gasordine = rec.order.gasordine.name
|
||||
else
|
||||
- var gasordine = ''
|
||||
- var qty = rec.order.product.quantity
|
||||
- var qtypreordered = rec.order.quantitypreordered
|
||||
- var TotalPriceProduct = rec.order.TotalPriceProduct
|
||||
- index = index + 1
|
||||
|
||||
table(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")
|
||||
tr
|
||||
td(class="column", valign="center" width="40")
|
||||
p.boldhigh #{index}.
|
||||
|
||||
td(class="column sectionArticleImage", valign="top" width="150")
|
||||
table(cellpadding="0", cellspacing="0", summary="", border="0")
|
||||
tr
|
||||
td
|
||||
img(src=baseimg + img, alt="", width="150" height="150")
|
||||
td(class="column", valign="top")
|
||||
|
||||
table(cellpadding="0", cellspacing="0", summary="", border="0")
|
||||
if (qtypreordered > 0)
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Gas Ordine: #{gasordine}
|
||||
p
|
||||
tr
|
||||
td(class="sectionContentTitle boldhigh", valign="top")
|
||||
p #{descr}
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Prezzo: #{price} € #{after_price}
|
||||
if (qty > 0)
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Quantità: #{qty}
|
||||
if (qtypreordered > 0)
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Quantità Prenotata: #{qtypreordered}
|
||||
tr
|
||||
td(class="sectionContent", valign="top")
|
||||
p Totale: #{TotalPriceProduct} €
|
||||
|
||||
if (note)
|
||||
p Note Aggiuntive: #{note}
|
||||
|
||||
p.sectionContentTitle.boldhigh.sectionTotal Totale Ordine: #{totalPrice} €
|
||||
tr
|
||||
td(class="whitespace", height="10")
|
||||
|
||||
tr
|
||||
td
|
||||
- var miofooter = mystorehouse.email_html_footer
|
||||
if (miofooter)
|
||||
p!= miofooter
|
||||
else
|
||||
p Grazie Mille
|
||||
|
||||
table.footer(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")
|
||||
tr
|
||||
td(class="whitespace", height="10")
|
||||
p
|
||||
tr
|
||||
td.firma
|
||||
p!= dataemail.firma
|
||||
|
||||
tr
|
||||
td.disclaimer
|
||||
p!= dataemail.disclaimer_out
|
||||
|
||||
tr
|
||||
td.bottom
|
||||
p!= dataemail.disc_bottom_out
|
||||
|
||||
tr
|
||||
td(class="whitespace", height="10")
|
||||
p
|
||||
|
||||
style(type="text/css").
|
||||
html, body {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
|
||||
.divbtn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.btn-lg {
|
||||
padding: 5px;
|
||||
margin: 5px;
|
||||
font-size: 26px;
|
||||
cursor: pointer;
|
||||
color: white;
|
||||
background: #027be3 !important;
|
||||
border-radius: 28px;
|
||||
|
||||
}
|
||||
1
emails/ecommerce/order_consegnato/it/subject.pug
Executable file
1
emails/ecommerce/order_consegnato/it/subject.pug
Executable file
@@ -0,0 +1 @@
|
||||
=`Ordine n. ${ordernumber} Consegnato`
|
||||
@@ -11,46 +11,42 @@
|
||||
-}
|
||||
|
||||
- var urlcal = baseurl + '/calendario-eventi/'
|
||||
- var imginstagram = baseurl + '/statics/images/images/footer-instagram-icon.png'
|
||||
- var imgtwitter = baseurl + '/statics/images/images/footer-twitter-icon.png'
|
||||
- var imgyoutube = baseurl + '/statics/images/images/footer-youtube-icon.png'
|
||||
- var imgfb = baseurl + '/statics/images/images/footer-facebook-icon.png'
|
||||
- var baseimg = baseurl + '/statics/'
|
||||
- var imginstagram = baseurl + '/images/images/footer-instagram-icon.png'
|
||||
- var imgtwitter = baseurl + '/images/images/footer-twitter-icon.png'
|
||||
- var imgyoutube = baseurl + '/images/images/footer-youtube-icon.png'
|
||||
- var imgfb = baseurl + '/images/images/footer-facebook-icon.png'
|
||||
- var baseimg = baseurl + '/'
|
||||
doctype html
|
||||
html
|
||||
head
|
||||
title Calendario Eventi
|
||||
- if (dataemail.title)
|
||||
head
|
||||
title dataemail.subject
|
||||
|
||||
//- import css/scss stylesheets
|
||||
//- these file names will be replace by gulp with proper css file paths
|
||||
link(rel="stylesheet", href="../sass/basic.scss")
|
||||
link(rel="stylesheet", href="../sass/one/styles.scss")
|
||||
//- import css/scss stylesheets
|
||||
//- these file names will be replace by gulp with proper css file paths
|
||||
link(rel="stylesheet", href="../sass/basic.scss")
|
||||
link(rel="stylesheet", href="../sass/one/styles.scss")
|
||||
|
||||
//- embdedded css allowed, but not sass
|
||||
style.
|
||||
.red {
|
||||
background-color: #E84C50;
|
||||
}
|
||||
//- embdedded css allowed, but not sass
|
||||
style.
|
||||
.red {
|
||||
background-color: #E84C50;
|
||||
}
|
||||
|
||||
.full-width {
|
||||
width: 100%;
|
||||
}
|
||||
.full-width {
|
||||
width: 100%;
|
||||
}
|
||||
body(yahoofix)
|
||||
span(id='body_style', style='display:block')
|
||||
table(class="preheader", cellpadding="0", cellspacing="0", width="100%")
|
||||
tr
|
||||
td.webversion
|
||||
p non vedi le immagini?
|
||||
a(href=urlcal) Apri il Calendario
|
||||
|
||||
table(class="topHeader", cellpadding="0", cellspacing="0", width="100%")
|
||||
tr
|
||||
td
|
||||
table(cellpadding="0", cellspacing="0", align="center", summary="")
|
||||
tr
|
||||
td.logoContainer
|
||||
a(href=baseurl, title='logo')
|
||||
img.logo(src=baseurl+"/statics/images/logo.png", height=dataemail.height_logo)
|
||||
- if (dataemail.height_logo)
|
||||
tr
|
||||
td
|
||||
table(cellpadding="0", cellspacing="0", align="center", summary="")
|
||||
tr
|
||||
td.logoContainer
|
||||
a(href=baseurl, title='logo')
|
||||
img.logo(src=baseurl+"/images/logo.png", height=dataemail.height_logo)
|
||||
|
||||
tr
|
||||
td.testomail
|
||||
@@ -61,17 +57,17 @@ html
|
||||
td.clpromo
|
||||
p!= dataemail.textpromo
|
||||
|
||||
- if (dataemail.templ.content)
|
||||
table(cellpadding="0", cellspacing="0", width="95%", align="center")
|
||||
tr
|
||||
td(class="textIniContainer", valign="top")
|
||||
p!=dataemail.templ.content
|
||||
- if (dataemail.templ.img)
|
||||
img(src=baseimg + dataemail.templ.img, alt="", class="myimg")
|
||||
- if (dataemail.templ.content2)
|
||||
p!=dataemail.templ.content2
|
||||
- if (dataemail.templ.img2)
|
||||
img(src=baseimg + dataemail.templ.img2, alt="", class="myimg")
|
||||
- if (dataemail.templ.content)
|
||||
table(cellpadding="0", cellspacing="0", width="95%", align="center")
|
||||
tr
|
||||
td(class="textIniContainer", valign="top")
|
||||
p!=dataemail.templ.content
|
||||
- if (dataemail.templ.img)
|
||||
img(src=baseimg + dataemail.templ.img, alt="", class="myimg")
|
||||
- if (dataemail.templ.content2)
|
||||
p!=dataemail.templ.content2
|
||||
- if (dataemail.templ.img2)
|
||||
img(src=baseimg + dataemail.templ.img2, alt="", class="myimg")
|
||||
|
||||
table(cellpadding="0", cellspacing="0", width="640", align="center")
|
||||
- if (dataemail.templ.options.includes('SHOW_EVENTS'))
|
||||
@@ -201,10 +197,6 @@ html
|
||||
td(class="whitespace", height="20")
|
||||
p
|
||||
|
||||
tr
|
||||
td(class="whitespace", height="20")
|
||||
p
|
||||
|
||||
// Social Media
|
||||
table.socialMedia(cellpadding="0", cellspacing="0", width="100%", summary="", border="0", align="center")
|
||||
tr
|
||||
|
||||
115
filelog.txt
115
filelog.txt
@@ -19,3 +19,118 @@ entrando sul bot riso premi su avvia (o start) e segui le istruzioni
|
||||
|
||||
3️⃣ condividi il progetto ai tuoi amici ed aiuta così a far crescere questa rete e crescere insieme 💚 partecipa al cambiamento. riso sei anche tu.
|
||||
se hai bisogno di aiuto chiedi in questa chat: 👉🏻 chat riso help
|
||||
|
||||
Gio 05/01 ORE 19:28: USER [paoloar77]: vai al sito
|
||||
|
||||
Gio 05/01 ORE 19:28: USER [paoloar77]: link da condividere
|
||||
|
||||
Gio 16/02 ORE 18:14: USER [paoloar77]: vai al sito
|
||||
|
||||
Mar 06/06 ORE 19:39: USER [paoloar77]: ciaooooooooooooooooo
|
||||
|
||||
Mar 06/06 ORE 19:54: USER [paoloar77]: dasjdalksjdasdklasjkldasjlkdjasl
|
||||
|
||||
Sab 17/06 ORE 20:03: USER [paoloar77]: pro v adsasdasdaksdas
|
||||
|
||||
Dom 18/06 ORE 19:22: USER [paoloar77]: /start inv
|
||||
|
||||
Dom 18/06 ORE 19:42: USER [paoloar77]: /start inv
|
||||
|
||||
Dom 18/06 ORE 19:58: USER [paoloar77]: /start inv
|
||||
|
||||
Dom 18/06 ORE 19:59: USER [paoloar77]: /start inv
|
||||
|
||||
Dom 18/06 ORE 19:59: USER [paoloar77]: /start inv
|
||||
|
||||
Ven 23/06 ORE 14:08: USER [paoloar77]: link da condividere
|
||||
|
||||
Sab 30/09 ORE 00:21: USER [SuryaArena]: vai al sito
|
||||
|
||||
Sab 30/09 ORE 00:32: USER [SuryaArena]: vai al sito
|
||||
|
||||
Gio 12/10 ORE 11:11: USER [paoloar77]: prova
|
||||
|
||||
Gio 12/10 ORE 11:48: USER [paoloar77]: prova
|
||||
|
||||
Gio 12/10 ORE 12:07: USER [SuryaArena]: prova
|
||||
|
||||
Gio 12/10 ORE 12:07: USER [SuryaArena]: prova
|
||||
|
||||
Gio 12/10 ORE 12:09: USER [SuryaArena]: prova
|
||||
|
||||
Gio 12/10 ORE 12:10: USER [SuryaArena]: prova
|
||||
|
||||
Gio 12/10 ORE 12:10: USER [SuryaArena]: prova
|
||||
|
||||
Gio 12/10 ORE 12:13: USER [SuryaArena]: prova
|
||||
|
||||
Gio 12/10 ORE 12:14: USER [SuryaArena]: prova
|
||||
|
||||
Gio 12/10 ORE 12:16: USER [SuryaArena]: prova
|
||||
|
||||
Gio 12/10 ORE 12:21: USER [SuryaArena]: prova
|
||||
|
||||
Gio 12/10 ORE 12:33: USER [paoloar77]: prova
|
||||
|
||||
Gio 12/10 ORE 12:33: USER [SuryaArena]: ciao
|
||||
|
||||
Gio 12/10 ORE 12:33: USER [SuryaArena]: prova
|
||||
|
||||
Gio 12/10 ORE 12:45: USER [SuryaArena]: bottone
|
||||
|
||||
Gio 12/10 ORE 14:49: USER [paoloar77]: bottone
|
||||
|
||||
Gio 12/10 ORE 14:49: USER [paoloar77]: bottone
|
||||
|
||||
Gio 12/10 ORE 14:49: USER [paoloar77]: bottone
|
||||
|
||||
Gio 12/10 ORE 14:52: USER [paoloar77]: bottone
|
||||
|
||||
Gio 12/10 ORE 14:57: USER [paoloar77]: bottone
|
||||
|
||||
Gio 12/10 ORE 15:06: USER [paoloar77]: bottone
|
||||
|
||||
Ven 13/10 ORE 11:05: USER [SuryaArena]: bottone
|
||||
|
||||
Ven 13/10 ORE 11:40: USER [SuryaArena]: bottone
|
||||
|
||||
Dom 17/12 ORE 15:38: USER [admin]: prova
|
||||
|
||||
Dom 17/12 ORE 16:18: USER [admin]: vai al sito
|
||||
|
||||
Dom 17/12 ORE 16:19: USER [admin]: vai al sito
|
||||
|
||||
Dom 17/12 ORE 16:19: USER [admin]: il mio profilo
|
||||
|
||||
Dom 17/12 ORE 16:19: USER [admin]: prova
|
||||
|
||||
Dom 17/12 ORE 16:19: USER [admin]: link da condividere
|
||||
|
||||
Sab 30/12 ORE 20:06: USER [admin]: gruppo di acquisto per le arance:
|
||||
|
||||
produttore:
|
||||
🍊sicilia frutta express (catania)
|
||||
|
||||
la piccola azienda a conduzione familiare di giovanni si trova in provincia di catania (sicilia), i frutti vengono prodotti rispettando i principi della biodinamica infatti non viene utilizzato nulla di chimico (niente irrorazioni) e la concimazione avviene tramite concimi naturali (letame).
|
||||
|
||||
⚠️ offerta sconto valida solo fino al 3 gennaio 2024, raggiungendo 100 kg totali di ordini di arance:
|
||||
i prezzi sono compresi di spese di spedizione e di gestione.
|
||||
|
||||
🍊 arance tarocco spremuta: 1,20 € / kg
|
||||
|
||||
🥑 avocado: 7,80 € / kg
|
||||
|
||||
🍋 limoni: 2,40 € / kg
|
||||
|
||||
👉🏻 entra sul gruppo telegram piu che buono
|
||||
|
||||
per le prenotazioni potete registratevi sul nuovo sito:
|
||||
👉🏻 piu che buono - gas e bottega (piuchebuono.app)
|
||||
|
||||
come funziona:
|
||||
- registratevi su piuchebuono.app, verificate la email.
|
||||
- accedete e poi cliccate su "gruppo di acquisto".
|
||||
- cliccate sul carrello verde 🛒 per aggiungere i kg che desiderate.
|
||||
- per finire: cliccare su "procedi all'ordine" e confermate.
|
||||
|
||||
Dom 21/01 ORE 19:00: USER [paoloar77]: 👉🏻 indietro
|
||||
|
||||
31
logevents.txt
Normal file
31
logevents.txt
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
Mar 06/06 ORE 19:06: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
||||
✅ SuryaArena2 è stato Abilitato correttamente (da paoloar77)!
|
||||
Mar 06/06 ORE 19:07: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
||||
✅ SuryaArena2 è stato Abilitato correttamente (da paoloar77)!
|
||||
Mar 06/06 ORE 19:38: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
||||
✅ SuryaArena2 è stato Abilitato correttamente (da paoloar77)!
|
||||
Mar 06/06 ORE 19:39: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
||||
ciaooooooooooooooooo
|
||||
Mar 06/06 ORE 19:49: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
||||
✅ SuryaArena2 è stato Abilitato correttamente (da paoloar77)!
|
||||
Mar 06/06 ORE 19:54: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
||||
dasjdalksjdasdklasjkldasjlkdjasl
|
||||
Sab 17/06 ORE 20:03: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
||||
pro v adsasdasdaksdas
|
||||
Dom 18/06 ORE 19:22: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
||||
/start inv
|
||||
Ven 23/06 ORE 14:13: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
||||
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!
|
||||
Dom 25/06 ORE 16:11: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
||||
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!
|
||||
Ven 29/09 ORE 23:18: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
||||
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!
|
||||
Mar 03/10 ORE 22:49: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
||||
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!
|
||||
Sab 04/11 ORE 15:17: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
||||
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!
|
||||
Sab 02/12 ORE 14:15: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
||||
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!
|
||||
Dom 21/01 ORE 19:00: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
||||
👉🏻 indietro
|
||||
131
logtrans.txt
Normal file
131
logtrans.txt
Normal file
@@ -0,0 +1,131 @@
|
||||
|
||||
Lun 06/02 ORE 23:13: Inviate Monete da paoloar77 a surya1977 1 RISTEST [] [Saldo 1: -50] [Saldo 2: 5]
|
||||
Lun 06/02 ORE 23:15: Inviate Monete da paoloar77 a surya1977 1 RISTEST [causale: ] [Saldo 1: -51 RISTEST] [Saldo 2: 6 RISTEST ]
|
||||
Lun 06/02 ORE 23:17: Inviate Monete da paoloar77 a surya1977 1 RISTEST [causale: ] [Saldo paoloar77: -52 RISTEST] [Saldo surya1977: 7 RISTEST]
|
||||
Dom 12/03 ORE 13:35: Inviate Monete da paoloar77 a 1 RIS [causale: ] [Saldo paoloar77: 3 RIS] [Saldo : 2 RIS]
|
||||
Mer 15/03 ORE 22:15: Inviate Monete da pontiUmani (paoloar77) a paoloar77 1 RIS [causale: ] [Saldo pontiUmani (paoloar77): 1 RIS] [Saldo paoloar77: 4 RIS]
|
||||
Mer 15/03 ORE 22:37: Inviate Monete da pontiUmani (paoloar77) a surya1977 1 RIS [causale: ] [Saldo pontiUmani (paoloar77): 0 RIS] [Saldo surya1977: 1 RIS]
|
||||
Ven 28/04 ORE 01:33: Inviate Monete da surya1977 a risotest 1 RISTEST [causale: ] [Saldo surya1977: 0 RISTEST] [Saldo risotest: 9.5 RISTEST]
|
||||
Gio 01/06 ORE 12:22: Inviate Monete da paoloar77 a surya1977 1 RIS [causale: ] [Saldo paoloar77: -2 RIS] [Saldo surya1977: 1 RIS]
|
||||
Gio 01/06 ORE 12:25: Inviate Monete da paoloar77 a surya1977 2 RIS [causale: ] [Saldo paoloar77: -4 RIS] [Saldo surya1977: 3 RIS]
|
||||
Gio 01/06 ORE 12:31: Inviate Monete da paoloar77 a surya1977 4 RIS [causale: ] [Saldo paoloar77: -8 RIS] [Saldo surya1977: 7 RIS]
|
||||
Gio 01/06 ORE 17:26: Inviate Monete da paoloar77 a surya1977 1 RIS [causale: ] [Saldo paoloar77: -9 RIS] [Saldo surya1977: 8 RIS]
|
||||
Gio 01/06 ORE 17:41: Inviate Monete da paoloar77 a surya1977 1 RIS [causale: ] [Saldo paoloar77: -10 RIS] [Saldo surya1977: 9 RIS]
|
||||
Ven 02/06 ORE 19:29: Inviate Monete da paoloar77 a 2 RIS [causale: ] [Saldo paoloar77: 8 RIS] [Saldo : -261 RIS]
|
||||
Ven 02/06 ORE 19:31: Inviate Monete da paoloar77 a pontiUmani 4 RIS [causale: ] [Saldo paoloar77: 0 RIS] [Saldo pontiUmani: -253 RIS]
|
||||
Lun 26/06 ORE 23:23: [<b>Circuito RIS Ragusa</b>]: Inviate Monete da risragusa (paoloar77) a paogruppo2 300 RIS [causale: aaa]
|
||||
Saldi:
|
||||
risragusa (paoloar77): -300 RIS]
|
||||
paogruppo2: 300 RIS]
|
||||
Lun 26/06 ORE 23:27: [<b>Circuito RIS Ragusa</b>]: Inviate Monete da paoloar77 a paogruppo2 20 RIS [causale: ]
|
||||
Saldi:
|
||||
paoloar77: -20 RIS]
|
||||
paogruppo2: 320 RIS]
|
||||
Sab 30/09 ORE 13:32: [<b>Circuito RIS Bologna</b>]: Inviate Monete da SuryaArena a paoloar77 1 RIS [causale: aaa]
|
||||
Saldi:
|
||||
SuryaArena: -1 RIS]
|
||||
paoloar77: 11 RIS]
|
||||
Lun 09/10 ORE 09:04: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a SuryaArena2 1 RIS [causale: ]
|
||||
Saldi:
|
||||
paoloar77: -2 RIS]
|
||||
SuryaArena2: 1 RIS]
|
||||
Lun 09/10 ORE 09:21: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a SuryaArena2 1 RIS [causale: ]
|
||||
Saldi:
|
||||
paoloar77: -3 RIS]
|
||||
SuryaArena2: 2 RIS]
|
||||
Lun 09/10 ORE 10:25: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a SuryaArena2 1 RIS [causale: ]
|
||||
Saldi:
|
||||
paoloar77: -4 RIS]
|
||||
SuryaArena2: 3 RIS]
|
||||
Lun 09/10 ORE 10:26: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a SuryaArena2 1 RIS [causale: ]
|
||||
Saldi:
|
||||
paoloar77: -5 RIS]
|
||||
SuryaArena2: 4 RIS]
|
||||
Lun 09/10 ORE 23:26: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a SuryaArena2 1 RIS [causale: ]
|
||||
Saldi:
|
||||
paoloar77: -2 RIS]
|
||||
SuryaArena2: 1 RIS]
|
||||
Lun 09/10 ORE 23:36: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a SuryaArena2 1 RIS [causale: ]
|
||||
Saldi:
|
||||
paoloar77: -3 RIS]
|
||||
SuryaArena2: 2 RIS]
|
||||
Lun 09/10 ORE 23:36: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a SuryaArena2 1 RIS [causale: ]
|
||||
Saldi:
|
||||
paoloar77: -4 RIS]
|
||||
SuryaArena2: 3 RIS]
|
||||
Mar 10/10 ORE 00:04: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a SuryaArena2 1 RIS [causale: ]
|
||||
Saldi:
|
||||
paoloar77: -5 RIS]
|
||||
SuryaArena2: 4 RIS]
|
||||
Mar 10/10 ORE 00:21: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a SuryaArena2 1 RIS [causale: ]
|
||||
Saldi:
|
||||
paoloar77: -6 RIS]
|
||||
SuryaArena2: 5 RIS]
|
||||
Mar 10/10 ORE 00:34: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a SuryaArena2 1 RIS [causale: ]
|
||||
Saldi:
|
||||
paoloar77: -7 RIS]
|
||||
SuryaArena2: 6 RIS]
|
||||
Mar 10/10 ORE 22:47: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a PaoTEST1 1 RIS [causale: ]
|
||||
Saldi:
|
||||
paoloar77: -8 RIS]
|
||||
PaoTEST1: 1 RIS]
|
||||
Mar 10/10 ORE 22:49: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a PaoTEST1 1 RIS [causale: ]
|
||||
Saldi:
|
||||
paoloar77: -9 RIS]
|
||||
PaoTEST1: 2 RIS]
|
||||
Mar 10/10 ORE 23:08: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a PaoTEST1 2 RIS [causale: ]
|
||||
Saldi:
|
||||
paoloar77: -11 RIS]
|
||||
PaoTEST1: 4 RIS]
|
||||
Mar 10/10 ORE 23:13: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a PaoTEST1 3 RIS [causale: ]
|
||||
Saldi:
|
||||
paoloar77: -14 RIS]
|
||||
PaoTEST1: 7 RIS]
|
||||
Mar 10/10 ORE 23:22: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a PaoTEST1 1 RIS [causale: ]
|
||||
Saldi:
|
||||
paoloar77: -15 RIS]
|
||||
PaoTEST1: 8 RIS]
|
||||
Mer 11/10 ORE 22:33: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a PaoTEST1 1 RIS [causale: ]
|
||||
Saldi:
|
||||
paoloar77: -16 RIS]
|
||||
PaoTEST1: 9 RIS]
|
||||
Gio 12/10 ORE 08:05: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a PaoTEST1 1 RIS [causale: ]
|
||||
Saldi:
|
||||
paoloar77: -17 RIS]
|
||||
PaoTEST1: 10 RIS]
|
||||
Gio 12/10 ORE 08:06: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a SuryaArena2 1 RIS [causale: ]
|
||||
Saldi:
|
||||
paoloar77: -18 RIS]
|
||||
SuryaArena2: 7 RIS]
|
||||
Mer 29/11 ORE 16:35: [<b>Circuito RIS Italia</b>]: Inviate Monete da SuryaArena a paoloar77 5 RIS [causale: Seconda]
|
||||
Saldi:
|
||||
SuryaArena: -5 RIS]
|
||||
paoloar77: 5 RIS]
|
||||
Mer 29/11 ORE 16:44: [<b>Circuito RIS Italia</b>]: Inviate Monete da SuryaArena a paoloar77 3 RIS [causale: Eccolo]
|
||||
Saldi:
|
||||
SuryaArena: -8 RIS]
|
||||
paoloar77: 8 RIS]
|
||||
Mer 29/11 ORE 16:50: [<b>Circuito RIS Italia</b>]: Inviate Monete da SuryaArena a paoloar77 3 RIS [causale: Ricevuto un bel massaggio]
|
||||
Saldi:
|
||||
SuryaArena: -11 RIS]
|
||||
paoloar77: 11 RIS]
|
||||
Mer 29/11 ORE 16:52: [<b>Circuito RIS Bologna</b>]: Inviate Monete da SuryaArena a paoloar77 4 RIS [causale: Un bel massaggio con olio caldo]
|
||||
Saldi:
|
||||
SuryaArena: -4 RIS]
|
||||
paoloar77: 14 RIS]
|
||||
Mer 29/11 ORE 17:14: [<b>Circuito RIS Italia</b>]: Inviate Monete da SuryaArena a paoloar77 2 RIS [causale: Massaggio !]
|
||||
Saldi:
|
||||
SuryaArena: -13 RIS]
|
||||
paoloar77: 13 RIS]
|
||||
Gio 04/01 ORE 14:00: [<b>Euro</b>]: Inviate Monete da PaoloRiso a piuchebuono 44.4 € [causale: Pagato Ordine n.101]
|
||||
Saldi:
|
||||
PaoloRiso: -44.4 €]
|
||||
piuchebuono: 44.4 €]
|
||||
Dom 07/01 ORE 16:22: [<b>Euro</b>]: Inviate Monete da PaoloRiso a 44.4 € [causale: Pagato Ordine n.101]
|
||||
Saldi:
|
||||
PaoloRiso: -44.4 €]
|
||||
: 44.4 €]
|
||||
Dom 07/01 ORE 16:24: [<b>Euro</b>]: Inviate Monete da PaoloRiso a 44.4 € [causale: Pagato Ordine n.101]
|
||||
Saldi:
|
||||
PaoloRiso: -88.8 €]
|
||||
: 88.8 €]
|
||||
@@ -10,91 +10,345 @@ let aggregation = [
|
||||
{
|
||||
$match: {
|
||||
idapp: "13",
|
||||
},
|
||||
},
|
||||
{
|
||||
$sort: {
|
||||
date_updated: -1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$addFields: {
|
||||
myId1: {
|
||||
$toObjectId: "$userId",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "users",
|
||||
localField: "myId1",
|
||||
foreignField: "_id",
|
||||
as: "user",
|
||||
},
|
||||
},
|
||||
{
|
||||
$replaceRoot: {
|
||||
newRoot: {
|
||||
$mergeObjects: [
|
||||
{
|
||||
$arrayElemAt: [
|
||||
"$user",
|
||||
0,
|
||||
],
|
||||
},
|
||||
"$$ROOT",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
recGood: 1,
|
||||
sectorGood: 1,
|
||||
idSectorGood: 1,
|
||||
idGood: 1,
|
||||
mygood: 1,
|
||||
idStatusSkill: 1,
|
||||
idContribType: 1,
|
||||
"profile.username_telegram": 1,
|
||||
"profile.favorite": 1,
|
||||
"profile.bookmark": 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
numLevel: 1,
|
||||
adType: 1,
|
||||
photos: 1,
|
||||
note: 1,
|
||||
website: 1,
|
||||
descr: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
userId: 1,
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
comune: 1,
|
||||
mycities: 1,
|
||||
"profile.img": 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.qualifica": 1,
|
||||
"profile.resid_province": 1,
|
||||
"profile.resid_card": 1,
|
||||
reported: 1,
|
||||
date_report: 1,
|
||||
username_who_report: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "goods",
|
||||
localField: "idGood",
|
||||
foreignField: "_id",
|
||||
as: "recGood",
|
||||
},
|
||||
},
|
||||
{
|
||||
$replaceRoot: {
|
||||
newRoot: {
|
||||
$mergeObjects: [
|
||||
{
|
||||
$arrayElemAt: [
|
||||
"$recGood",
|
||||
0,
|
||||
],
|
||||
},
|
||||
"$$ROOT",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
recGood: 1,
|
||||
sectorGood: 1,
|
||||
idSectorGood: 1,
|
||||
idGood: 1,
|
||||
mygood: 1,
|
||||
idStatusSkill: 1,
|
||||
idContribType: 1,
|
||||
"profile.username_telegram": 1,
|
||||
"profile.favorite": 1,
|
||||
"profile.bookmark": 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
numLevel: 1,
|
||||
adType: 1,
|
||||
photos: 1,
|
||||
note: 1,
|
||||
website: 1,
|
||||
descr: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
userId: 1,
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
comune: 1,
|
||||
mycities: 1,
|
||||
"profile.img": 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.qualifica": 1,
|
||||
"profile.resid_province": 1,
|
||||
"profile.resid_card": 1,
|
||||
reported: 1,
|
||||
date_report: 1,
|
||||
username_who_report: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "sectorgoods",
|
||||
localField: "idSectorGood",
|
||||
foreignField: "_id",
|
||||
as: "sectorGood",
|
||||
},
|
||||
},
|
||||
{
|
||||
$replaceRoot: {
|
||||
newRoot: {
|
||||
$mergeObjects: [
|
||||
{
|
||||
$arrayElemAt: [
|
||||
"$sectorGood",
|
||||
0,
|
||||
],
|
||||
},
|
||||
"$$ROOT",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
recGood: 1,
|
||||
sectorGood: 1,
|
||||
idSectorGood: 1,
|
||||
idGood: 1,
|
||||
mygood: 1,
|
||||
idStatusSkill: 1,
|
||||
idContribType: 1,
|
||||
"profile.username_telegram": 1,
|
||||
"profile.favorite": 1,
|
||||
"profile.bookmark": 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
numLevel: 1,
|
||||
adType: 1,
|
||||
photos: 1,
|
||||
note: 1,
|
||||
website: 1,
|
||||
descr: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
userId: 1,
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
comune: 1,
|
||||
mycities: 1,
|
||||
"profile.img": 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.qualifica": 1,
|
||||
"profile.resid_province": 1,
|
||||
reported: 1,
|
||||
date_report: 1,
|
||||
username_who_report: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "cities",
|
||||
localField: "idCity",
|
||||
foreignField: "_id",
|
||||
as: "mycities",
|
||||
},
|
||||
},
|
||||
{
|
||||
$replaceRoot: {
|
||||
newRoot: {
|
||||
$mergeObjects: [
|
||||
{
|
||||
$arrayElemAt: [
|
||||
"$mycities",
|
||||
0,
|
||||
],
|
||||
},
|
||||
"$$ROOT",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
recGood: 1,
|
||||
sectorGood: 1,
|
||||
idSectorGood: 1,
|
||||
idGood: 1,
|
||||
mygood: 1,
|
||||
idStatusSkill: 1,
|
||||
idContribType: 1,
|
||||
"profile.username_telegram": 1,
|
||||
"profile.favorite": 1,
|
||||
"profile.bookmark": 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
numLevel: 1,
|
||||
adType: 1,
|
||||
photos: 1,
|
||||
note: 1,
|
||||
website: 1,
|
||||
descr: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
userId: 1,
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
comune: 1,
|
||||
mycities: 1,
|
||||
"profile.img": 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.qualifica": 1,
|
||||
"profile.resid_province": 1,
|
||||
reported: 1,
|
||||
date_report: 1,
|
||||
username_who_report: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
$or: [
|
||||
{
|
||||
deleted: {
|
||||
$exists: false,
|
||||
},
|
||||
$and: [
|
||||
{
|
||||
"profile.mygroups": {
|
||||
$elemMatch: {
|
||||
groupname: {
|
||||
$in: [
|
||||
"000017",
|
||||
"risoprova",
|
||||
"VillaggiamoItalia",
|
||||
"Terraw",
|
||||
"RisoBenevento",
|
||||
"111",
|
||||
"gruppodefaultriso",
|
||||
"pontiUmani",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
pub_to_share: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
deleted: {
|
||||
$exists: true,
|
||||
$eq: false,
|
||||
},
|
||||
$or: [
|
||||
{
|
||||
pub_to_share: {
|
||||
$exists: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
pub_to_share: {
|
||||
$exists: true,
|
||||
$eq: 0,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
$and: [
|
||||
{
|
||||
"mycities.reg": "EMR",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
$group: {
|
||||
_id: "$aportador_solidario",
|
||||
_id: null,
|
||||
count: {
|
||||
$sum: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$match: { "count": { $gte: 2 } }
|
||||
},
|
||||
{
|
||||
$sort: {
|
||||
count: -1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "users",
|
||||
let: {
|
||||
username: "$_id",
|
||||
idapp: "13",
|
||||
},
|
||||
pipeline: [
|
||||
{
|
||||
$match: {
|
||||
$expr: {
|
||||
$and: [
|
||||
{
|
||||
$eq: [
|
||||
"$$username",
|
||||
"$username",
|
||||
],
|
||||
},
|
||||
{
|
||||
$eq: [
|
||||
"$$idapp",
|
||||
"$idapp",
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: "user",
|
||||
},
|
||||
},
|
||||
{ $unwind: "$user" },
|
||||
{
|
||||
$replaceRoot: {
|
||||
newRoot: {
|
||||
$mergeObjects: [ "$user", "$$ROOT" ],
|
||||
results: {
|
||||
$push: "$$ROOT",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
_id: 0,
|
||||
count: 1,
|
||||
aportador_solidario: 1,
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
idapp: 1,
|
||||
"profile.img": 1,
|
||||
rows: {
|
||||
$slice: [
|
||||
"$results",
|
||||
0,
|
||||
10,
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
db.users.aggregate(aggregation);
|
||||
db.myskills.aggregate(aggregation);
|
||||
|
||||
|
||||
432
mongodb/Favorite.mongodb
Normal file
432
mongodb/Favorite.mongodb
Normal file
@@ -0,0 +1,432 @@
|
||||
use('test_FreePlanet');
|
||||
|
||||
let aggregation = [
|
||||
{
|
||||
$match: {
|
||||
idapp: "13",
|
||||
},
|
||||
},
|
||||
{
|
||||
$sort: {
|
||||
date_updated: -1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "users",
|
||||
let: {
|
||||
tab: 1,
|
||||
id: "$_id",
|
||||
},
|
||||
pipeline: [
|
||||
{
|
||||
$unwind: "$profile.favorite",
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
$expr: {
|
||||
$and: [
|
||||
{
|
||||
$eq: [
|
||||
"$profile.favorite.id",
|
||||
"$$id",
|
||||
],
|
||||
},
|
||||
{
|
||||
$eq: [
|
||||
"$profile.favorite.tab",
|
||||
"$$tab",
|
||||
],
|
||||
},
|
||||
{
|
||||
$eq: [
|
||||
"$idapp",
|
||||
"13",
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{ $project: { username: 1, _id: 0 } },
|
||||
],
|
||||
as: "myfav",
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "users",
|
||||
let: {
|
||||
tab: 1,
|
||||
id: "$_id",
|
||||
},
|
||||
pipeline: [
|
||||
{
|
||||
$unwind: "$profile.bookmark",
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
$expr: {
|
||||
$and: [
|
||||
{
|
||||
$eq: [
|
||||
"$profile.bookmark.id",
|
||||
"$$id",
|
||||
],
|
||||
},
|
||||
{
|
||||
$eq: [
|
||||
"$profile.bookmark.tab",
|
||||
"$$tab",
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: "mybook",
|
||||
},
|
||||
},
|
||||
{
|
||||
$addFields: {
|
||||
myId1: {
|
||||
$toObjectId: "$userId",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "users",
|
||||
localField: "myId1",
|
||||
foreignField: "_id",
|
||||
as: "user",
|
||||
},
|
||||
},
|
||||
{
|
||||
$replaceRoot: {
|
||||
newRoot: {
|
||||
$mergeObjects: [
|
||||
{
|
||||
$arrayElemAt: [
|
||||
"$user",
|
||||
0,
|
||||
],
|
||||
},
|
||||
"$$ROOT",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
recSkill: 1,
|
||||
sector: 1,
|
||||
idSector: 1,
|
||||
idSkill: 1,
|
||||
myskill: 1,
|
||||
idStatusSkill: 1,
|
||||
idContribType: 1,
|
||||
"profile.username_telegram": 1,
|
||||
"profile.favorite": 1,
|
||||
"profile.bookmark": 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
numLevel: 1,
|
||||
adType: 1,
|
||||
photos: 1,
|
||||
note: 1,
|
||||
website: 1,
|
||||
descr: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
userId: 1,
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
comune: 1,
|
||||
mycities: 1,
|
||||
"profile.img": 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.qualifica": 1,
|
||||
"profile.resid_province": 1,
|
||||
reported: 1,
|
||||
date_report: 1,
|
||||
username_who_report: 1,
|
||||
myfav: 1,
|
||||
mybook: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "skills",
|
||||
localField: "idSkill",
|
||||
foreignField: "_id",
|
||||
as: "recSkill",
|
||||
},
|
||||
},
|
||||
{
|
||||
$replaceRoot: {
|
||||
newRoot: {
|
||||
$mergeObjects: [
|
||||
{
|
||||
$arrayElemAt: [
|
||||
"$recSkill",
|
||||
0,
|
||||
],
|
||||
},
|
||||
"$$ROOT",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
recSkill: 1,
|
||||
sector: 1,
|
||||
idSector: 1,
|
||||
idSkill: 1,
|
||||
myskill: 1,
|
||||
idStatusSkill: 1,
|
||||
idContribType: 1,
|
||||
"profile.username_telegram": 1,
|
||||
"profile.favorite": 1,
|
||||
"profile.bookmark": 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
numLevel: 1,
|
||||
adType: 1,
|
||||
photos: 1,
|
||||
note: 1,
|
||||
website: 1,
|
||||
descr: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
userId: 1,
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
comune: 1,
|
||||
mycities: 1,
|
||||
"profile.img": 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.qualifica": 1,
|
||||
"profile.resid_province": 1,
|
||||
reported: 1,
|
||||
date_report: 1,
|
||||
username_who_report: 1,
|
||||
myfav: 1,
|
||||
mybook: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "sectors",
|
||||
localField: "idSector",
|
||||
foreignField: "_id",
|
||||
as: "sector",
|
||||
},
|
||||
},
|
||||
{
|
||||
$replaceRoot: {
|
||||
newRoot: {
|
||||
$mergeObjects: [
|
||||
{
|
||||
$arrayElemAt: [
|
||||
"$sector",
|
||||
0,
|
||||
],
|
||||
},
|
||||
"$$ROOT",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
recSkill: 1,
|
||||
sector: 1,
|
||||
idSector: 1,
|
||||
idSkill: 1,
|
||||
myskill: 1,
|
||||
idStatusSkill: 1,
|
||||
idContribType: 1,
|
||||
"profile.username_telegram": 1,
|
||||
"profile.favorite": 1,
|
||||
"profile.bookmark": 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
numLevel: 1,
|
||||
adType: 1,
|
||||
photos: 1,
|
||||
note: 1,
|
||||
website: 1,
|
||||
descr: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
userId: 1,
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
comune: 1,
|
||||
mycities: 1,
|
||||
"profile.img": 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.qualifica": 1,
|
||||
"profile.resid_province": 1,
|
||||
reported: 1,
|
||||
date_report: 1,
|
||||
username_who_report: 1,
|
||||
myfav: 1,
|
||||
mybook: 1,
|
||||
myseen: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "cities",
|
||||
localField: "idCity",
|
||||
foreignField: "_id",
|
||||
as: "mycities",
|
||||
},
|
||||
},
|
||||
{
|
||||
$replaceRoot: {
|
||||
newRoot: {
|
||||
$mergeObjects: [
|
||||
{
|
||||
$arrayElemAt: [
|
||||
"$mycities",
|
||||
0,
|
||||
],
|
||||
},
|
||||
"$$ROOT",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
recSkill: 1,
|
||||
sector: 1,
|
||||
idSector: 1,
|
||||
idSkill: 1,
|
||||
myskill: 1,
|
||||
idStatusSkill: 1,
|
||||
idContribType: 1,
|
||||
"profile.username_telegram": 1,
|
||||
"profile.favorite": 1,
|
||||
"profile.bookmark": 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
numLevel: 1,
|
||||
adType: 1,
|
||||
photos: 1,
|
||||
note: 1,
|
||||
website: 1,
|
||||
descr: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
userId: 1,
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
comune: 1,
|
||||
mycities: 1,
|
||||
"profile.img": 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.qualifica": 1,
|
||||
"profile.resid_province": 1,
|
||||
reported: 1,
|
||||
date_report: 1,
|
||||
username_who_report: 1,
|
||||
myfav: 1,
|
||||
mybook: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
$or: [
|
||||
{
|
||||
$and: [
|
||||
{
|
||||
"profile.mygroups": {
|
||||
$elemMatch: {
|
||||
groupname: {
|
||||
$in: [
|
||||
"000017",
|
||||
"risoprova",
|
||||
"VillaggiamoItalia",
|
||||
"Terraw",
|
||||
"RisoBenevento",
|
||||
"111",
|
||||
"gruppodefaultriso",
|
||||
"pontiUmani",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
pub_to_share: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
$or: [
|
||||
{
|
||||
pub_to_share: {
|
||||
$exists: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
pub_to_share: {
|
||||
$exists: true,
|
||||
$eq: 0,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
$and: [
|
||||
{
|
||||
"mycities.reg": "EMR",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
$group: {
|
||||
_id: null,
|
||||
count: {
|
||||
$sum: 1,
|
||||
},
|
||||
results: {
|
||||
$push: "$$ROOT",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
count: 1,
|
||||
rows: {
|
||||
$slice: [
|
||||
"$results",
|
||||
0,
|
||||
10,
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
db.myskills.aggregate(aggregation);
|
||||
|
||||
203
mongodb/Members.mongodb
Normal file
203
mongodb/Members.mongodb
Normal file
@@ -0,0 +1,203 @@
|
||||
use('test_FreePlanet');
|
||||
|
||||
let aggregation = [
|
||||
{
|
||||
$match: {
|
||||
idapp: "13",
|
||||
"profile.mycircuits": {
|
||||
$elemMatch: {
|
||||
circuitname: {
|
||||
$eq: "Circuito RIS Bologna",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "circuits",
|
||||
as: "circuit",
|
||||
let: {
|
||||
circuitname: "Circuito RIS Bologna",
|
||||
idapp: "$idapp",
|
||||
},
|
||||
pipeline: [
|
||||
{
|
||||
$match: {
|
||||
$expr: {
|
||||
$and: [
|
||||
{
|
||||
$eq: [
|
||||
"$name",
|
||||
"$$circuitname",
|
||||
],
|
||||
},
|
||||
{
|
||||
$eq: [
|
||||
"$idapp",
|
||||
"$$idapp",
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: "$circuit",
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
date_reg: 1,
|
||||
profile: 1,
|
||||
idapp: 1,
|
||||
"circuit.name": 1,
|
||||
"circuit._id": 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "accounts",
|
||||
as: "account",
|
||||
let: {
|
||||
username: "$username",
|
||||
idapp: "$idapp",
|
||||
circuitId: "$circuit._id",
|
||||
},
|
||||
pipeline: [
|
||||
{
|
||||
$match: {
|
||||
$expr: {
|
||||
$and: [
|
||||
{
|
||||
$eq: [
|
||||
"$$username",
|
||||
"$username",
|
||||
],
|
||||
},
|
||||
{
|
||||
$eq: [
|
||||
"$$idapp",
|
||||
"$idapp",
|
||||
],
|
||||
},
|
||||
{
|
||||
$eq: [
|
||||
"$$circuitId",
|
||||
"$circuitId",
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: "$account",
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
idapp: "13",
|
||||
},
|
||||
},
|
||||
{
|
||||
$addFields: {
|
||||
myId1: {
|
||||
$toObjectId: "$userId",
|
||||
},
|
||||
namecomplete: {
|
||||
$concat: [
|
||||
{
|
||||
$toLower: "$name",
|
||||
},
|
||||
{
|
||||
$toLower: "$surname",
|
||||
},
|
||||
{ $toLower: "$username" },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "users",
|
||||
localField: "myId1",
|
||||
foreignField: "_id",
|
||||
as: "user",
|
||||
},
|
||||
},
|
||||
{
|
||||
$replaceRoot: {
|
||||
newRoot: {
|
||||
$mergeObjects: [
|
||||
{
|
||||
$arrayElemAt: [
|
||||
"$user",
|
||||
0,
|
||||
],
|
||||
},
|
||||
"$$ROOT",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
"profile.img": 1,
|
||||
"profile.mycircuits": 1,
|
||||
"profile.qualifica": 1,
|
||||
"profile.resid_province": 1,
|
||||
"account._id": 1,
|
||||
"account.saldo": 1,
|
||||
"account.fidoConcesso": 1,
|
||||
"account.qta_maxConcessa": 1,
|
||||
"account.totTransato": 1,
|
||||
reported: 1,
|
||||
date_report: 1,
|
||||
username_who_report: 1,
|
||||
namecomplete: 1,
|
||||
date_reg: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$sort: {
|
||||
date_reg: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$group: {
|
||||
_id: null,
|
||||
count: {
|
||||
$sum: 1,
|
||||
},
|
||||
results: {
|
||||
$push: "$$ROOT",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
count: 1,
|
||||
rows: {
|
||||
$slice: [
|
||||
"$results",
|
||||
1,
|
||||
15,
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
db.users.aggregate(aggregation);
|
||||
|
||||
352
mongodb/MySkills.mongodb
Normal file
352
mongodb/MySkills.mongodb
Normal file
@@ -0,0 +1,352 @@
|
||||
// MongoDB Playground
|
||||
// To disable this template go to Settings | MongoDB | Use Default Template For Playground.
|
||||
// Make sure you are connected to enable completions and to be able to run a playground.
|
||||
// Use Ctrl+Space inside a snippet or a string literal to trigger completions.
|
||||
|
||||
// Select the database to use.
|
||||
use('test_FreePlanet');
|
||||
|
||||
let aggregation = [
|
||||
{
|
||||
$match: {
|
||||
idapp: "13",
|
||||
},
|
||||
},
|
||||
{
|
||||
$sort: {
|
||||
date_updated: -1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$addFields: {
|
||||
myId1: {
|
||||
$toObjectId: "$userId",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "users",
|
||||
localField: "myId1",
|
||||
foreignField: "_id",
|
||||
as: "user",
|
||||
},
|
||||
},
|
||||
{
|
||||
$replaceRoot: {
|
||||
newRoot: {
|
||||
$mergeObjects: [
|
||||
{
|
||||
$arrayElemAt: [
|
||||
"$user",
|
||||
0,
|
||||
],
|
||||
},
|
||||
"$$ROOT",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
recGood: 1,
|
||||
sectorGood: 1,
|
||||
idSectorGood: 1,
|
||||
idGood: 1,
|
||||
mygood: 1,
|
||||
idStatusSkill: 1,
|
||||
idContribType: 1,
|
||||
"profile.username_telegram": 1,
|
||||
"profile.favorite": 1,
|
||||
"profile.bookmark": 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
numLevel: 1,
|
||||
adType: 1,
|
||||
photos: 1,
|
||||
note: 1,
|
||||
website: 1,
|
||||
descr: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
userId: 1,
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
comune: 1,
|
||||
mycities: 1,
|
||||
"profile.img": 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.qualifica": 1,
|
||||
"profile.resid_province": 1,
|
||||
reported: 1,
|
||||
date_report: 1,
|
||||
username_who_report: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "goods",
|
||||
localField: "idGood",
|
||||
foreignField: "_id",
|
||||
as: "recGood",
|
||||
},
|
||||
},
|
||||
{
|
||||
$replaceRoot: {
|
||||
newRoot: {
|
||||
$mergeObjects: [
|
||||
{
|
||||
$arrayElemAt: [
|
||||
"$recGood",
|
||||
0,
|
||||
],
|
||||
},
|
||||
"$$ROOT",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
recGood: 1,
|
||||
sectorGood: 1,
|
||||
idSectorGood: 1,
|
||||
idGood: 1,
|
||||
mygood: 1,
|
||||
idStatusSkill: 1,
|
||||
idContribType: 1,
|
||||
"profile.username_telegram": 1,
|
||||
"profile.favorite": 1,
|
||||
"profile.bookmark": 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
numLevel: 1,
|
||||
adType: 1,
|
||||
photos: 1,
|
||||
note: 1,
|
||||
website: 1,
|
||||
descr: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
userId: 1,
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
comune: 1,
|
||||
mycities: 1,
|
||||
"profile.img": 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.qualifica": 1,
|
||||
"profile.resid_province": 1,
|
||||
reported: 1,
|
||||
date_report: 1,
|
||||
username_who_report: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "sectorgoods",
|
||||
localField: "idSectorGood",
|
||||
foreignField: "_id",
|
||||
as: "sectorGood",
|
||||
},
|
||||
},
|
||||
{
|
||||
$replaceRoot: {
|
||||
newRoot: {
|
||||
$mergeObjects: [
|
||||
{
|
||||
$arrayElemAt: [
|
||||
"$sectorGood",
|
||||
0,
|
||||
],
|
||||
},
|
||||
"$$ROOT",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
recGood: 1,
|
||||
sectorGood: 1,
|
||||
idSectorGood: 1,
|
||||
idGood: 1,
|
||||
mygood: 1,
|
||||
idStatusSkill: 1,
|
||||
idContribType: 1,
|
||||
"profile.username_telegram": 1,
|
||||
"profile.favorite": 1,
|
||||
"profile.bookmark": 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
numLevel: 1,
|
||||
adType: 1,
|
||||
photos: 1,
|
||||
note: 1,
|
||||
website: 1,
|
||||
descr: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
userId: 1,
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
comune: 1,
|
||||
mycities: 1,
|
||||
"profile.img": 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.qualifica": 1,
|
||||
"profile.resid_province": 1,
|
||||
reported: 1,
|
||||
date_report: 1,
|
||||
username_who_report: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "cities",
|
||||
localField: "idCity",
|
||||
foreignField: "_id",
|
||||
as: "mycities",
|
||||
},
|
||||
},
|
||||
{
|
||||
$replaceRoot: {
|
||||
newRoot: {
|
||||
$mergeObjects: [
|
||||
{
|
||||
$arrayElemAt: [
|
||||
"$mycities",
|
||||
0,
|
||||
],
|
||||
},
|
||||
"$$ROOT",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
recGood: 1,
|
||||
sectorGood: 1,
|
||||
idSectorGood: 1,
|
||||
idGood: 1,
|
||||
mygood: 1,
|
||||
idStatusSkill: 1,
|
||||
idContribType: 1,
|
||||
"profile.username_telegram": 1,
|
||||
"profile.favorite": 1,
|
||||
"profile.bookmark": 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
numLevel: 1,
|
||||
adType: 1,
|
||||
photos: 1,
|
||||
note: 1,
|
||||
website: 1,
|
||||
descr: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
userId: 1,
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
comune: 1,
|
||||
mycities: 1,
|
||||
"profile.img": 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.qualifica": 1,
|
||||
"profile.resid_province": 1,
|
||||
reported: 1,
|
||||
date_report: 1,
|
||||
username_who_report: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
$or: [
|
||||
{
|
||||
$and: [
|
||||
{
|
||||
"profile.mygroups": {
|
||||
$elemMatch: {
|
||||
groupname: {
|
||||
$in: [
|
||||
"000017",
|
||||
"risoprova",
|
||||
"VillaggiamoItalia",
|
||||
"Terraw",
|
||||
"RisoBenevento",
|
||||
"111",
|
||||
"gruppodefaultriso",
|
||||
"pontiUmani",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
pub_to_share: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
$or: [
|
||||
{
|
||||
pub_to_share: {
|
||||
$exists: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
pub_to_share: {
|
||||
$exists: true,
|
||||
$eq: 0,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
$and: [
|
||||
{
|
||||
"mycities.reg": "EMR",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
$group: {
|
||||
_id: null,
|
||||
count: {
|
||||
$sum: 1,
|
||||
},
|
||||
results: {
|
||||
$push: "$$ROOT",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
count: 1,
|
||||
rows: {
|
||||
$slice: [
|
||||
"$results",
|
||||
0,
|
||||
10,
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
db.myskills.aggregate(aggregation);
|
||||
|
||||
@@ -278,3 +278,11 @@ if (test) {
|
||||
// Use toArray() to exhaust the cursor to return the whole result set.
|
||||
// You can use hasNext()/next() to iterate through the cursor page by page.
|
||||
db.users.aggregate(aggregation);
|
||||
|
||||
|
||||
|
||||
db.getCollection('myskills').deleteMany({ '_id': { $lte: 10000 }})
|
||||
db.getCollection('mygoods').deleteMany({ '_id': { $lte: 10000 }})
|
||||
db.getCollection('mybachecas').deleteMany({ '_id': { $lte: 10000 }})
|
||||
db.getCollection('myhosps').deleteMany({ '_id': { $lte: 10000 }})
|
||||
db.getCollection('mygroups').deleteMany({ '_id': { $lte: 10000 }})
|
||||
23
mongodb/favorite.mongodb.js
Normal file
23
mongodb/favorite.mongodb.js
Normal file
@@ -0,0 +1,23 @@
|
||||
use('test_FreePlanet');
|
||||
|
||||
let aggregation = [
|
||||
{
|
||||
$match: {
|
||||
idapp: "13",
|
||||
"profile.favorite": {
|
||||
$elemMatch:
|
||||
{ id: '10256', tab: 4 }
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
$group:
|
||||
{
|
||||
_id: null,
|
||||
count: { $sum: 1 },
|
||||
}
|
||||
},
|
||||
{ $project: { _id: 0 } }
|
||||
];
|
||||
|
||||
db.users.aggregate(aggregation);
|
||||
19
package.json
19
package.json
@@ -4,15 +4,17 @@
|
||||
"description": "freeplanet serverside",
|
||||
"main": "server/server.js",
|
||||
"scripts": {
|
||||
"start": "NODE_ENV=development nodemon src/server/server.js",
|
||||
"start": "node src/server/server.js",
|
||||
"dev": "NODE_ENV=development nodemon src/server/server.js",
|
||||
"build": "gulp build",
|
||||
"watch": "gulp watch",
|
||||
"test": "export NODE_ENV=development || SET NODE_ENV=development && mocha src/server/**/*.test.js",
|
||||
"start:prod": "NODE_ENV=production node src/server/server.js",
|
||||
"starttest": "NODE_ENV=test node src/server/server.js",
|
||||
"test-watch": "nodemon --exec 'npm test'"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^16.14.0"
|
||||
"node": "^18.19.0"
|
||||
},
|
||||
"author": "Paolo Arena",
|
||||
"license": "MIT",
|
||||
@@ -34,8 +36,8 @@
|
||||
"i18n": "^0.15.0",
|
||||
"image-downloader": "^4.3.0",
|
||||
"internet-available": "^1.0.0",
|
||||
"jade": "^1.11.0",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
"jade": "^1.9.2",
|
||||
"jsonwebtoken": "^9.0.1",
|
||||
"lodash": "^4.17.21",
|
||||
"mongodb": "^4.4.1",
|
||||
"mongoose": "^5.13.15",
|
||||
@@ -47,11 +49,12 @@
|
||||
"node-telegram-bot-api": "^0.59.0",
|
||||
"nodemailer": "^6.7.8",
|
||||
"npm-check-updates": "^16.1.0",
|
||||
"pem": "^1.14.6",
|
||||
"preview-email": "^3.0.7",
|
||||
"pug": "^3.0.2",
|
||||
"rate-limiter-flexible": "^2.3.9",
|
||||
"save": "^2.5.0",
|
||||
"sharp": "0.30.0",
|
||||
"sharp": "^0.30.7",
|
||||
"superagent": "^8.0.0",
|
||||
"url-parse": "^1.5.10",
|
||||
"validator": "^13.7.0",
|
||||
@@ -61,15 +64,15 @@
|
||||
"devDependencies": {
|
||||
"browser-sync": "^2.27.10",
|
||||
"expect": "^29.0.2",
|
||||
"gulp": "^4.0.2",
|
||||
"gulp-inline-css": "^4.0.0",
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-inline-css": "^2.0.0",
|
||||
"gulp-pug": "^5.0.0",
|
||||
"gulp-rename": "^2.0.0",
|
||||
"gulp-replace": "^1.1.3",
|
||||
"gulp-sass": "^5.1.0",
|
||||
"jest": "^29.0.2",
|
||||
"mocha": "^10.0.0",
|
||||
"nodemon": "^2.0.19",
|
||||
"nodemon": "^3.0.1",
|
||||
"supertest": "^6.2.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
body, #body_style {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background: #E9F2F9;
|
||||
background: #E9F2F9 !important;
|
||||
color: #5b656e;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,16 @@
|
||||
},
|
||||
{
|
||||
"path": "../../../newfreeplanet"
|
||||
},
|
||||
{
|
||||
"path": "../../../cnm"
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
"search.useIgnoreFiles": true,
|
||||
"search.useParentIgnoreFiles": true
|
||||
"search.useIgnoreFiles": false,
|
||||
"search.useParentIgnoreFiles": false,
|
||||
"files.exclude": {
|
||||
"": true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,15 @@ const tools = require('../tools/general');
|
||||
|
||||
// still in app.js
|
||||
const node_env = process.env.NODE_ENV || 'production';
|
||||
console.log('node_env=', node_env);
|
||||
|
||||
var file = `.env.${node_env}`;
|
||||
|
||||
|
||||
// GLOBALI (Uguali per TUTTI)
|
||||
process.env.LINKVERIF_REG = '/vreg';
|
||||
process.env.LINK_REQUEST_NEWPASSWORD = '/requestnewpwd';
|
||||
process.env.ADD_NEW_SITE = '/addNewSite';
|
||||
process.env.LINK_UPDATE_PASSWORD = '/updatepassword';
|
||||
process.env.LINK_UPDATE_PWD = '/updatepwd';
|
||||
process.env.LINK_CHECK_UPDATES = '/checkupdates';
|
||||
@@ -18,7 +21,10 @@ require('dotenv').config({ path: file });
|
||||
|
||||
process.env.DATABASE = process.env.DATABASE || 'FreePlanet';
|
||||
|
||||
console.log('process.env.DOMAIN:', process.env.DOMAIN);
|
||||
process.env.MONGODB_URI = process.env.DOMAIN + process.env.DATABASE;
|
||||
console.log('process.env.MONGODB_URI:', process.env.MONGODB_URI);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@@ -11,7 +11,7 @@ mongoose.plugin(schema => {
|
||||
|
||||
mongoose.set('debug', false);
|
||||
|
||||
const options = {
|
||||
let options = {
|
||||
// user: process.env.UDB,
|
||||
// pass: process.env.PDB,
|
||||
// useMongoClient: true,
|
||||
@@ -38,19 +38,36 @@ const options = {
|
||||
// keepAliveInitialDelay: 300000 // keepAliveInitialDelay is the number of milliseconds to wait before initiating keepAlive on the socket.
|
||||
};
|
||||
|
||||
if (process.env.AUTH_MONGODB === '1') {
|
||||
options.auth = {
|
||||
authSource: "admin",
|
||||
poolSize: 10,
|
||||
user: process.env.MONGODB_USER,
|
||||
password: process.env.MONGODB_PWD,
|
||||
};
|
||||
}
|
||||
|
||||
if (options.auth && options.auth.user) {
|
||||
console.log('MongoDb con Authenticazione:', options.auth.user, '******');
|
||||
} else {
|
||||
console.log('### MongoDb SENZA Authenticazione !!! ');
|
||||
}
|
||||
|
||||
const db = mongoose.connection;
|
||||
|
||||
console.log('Node Version ' + process.version);
|
||||
console.log('Mongoose Version ' + mongoose.version);
|
||||
|
||||
// mongoose.connect(process.env.MONGODB_URI + '?authSource=admin', { options })
|
||||
// console.log(' -> PASSAGGIO PARAMETRI MONGOOSE')
|
||||
mongoose.connect(process.env.MONGODB_URI, options);
|
||||
connectionUrl = process.env.MONGODB_URI;
|
||||
|
||||
console.log('Connessione a ' + connectionUrl + ' in corso...');
|
||||
mongoose.connect(connectionUrl, options);
|
||||
|
||||
db.on('error', console.error.bind(console, 'connection error:'));
|
||||
db.once('open', function() {
|
||||
db.once('open', function () {
|
||||
// we're connected!
|
||||
console.log('*** CONNESSIONE EFFETTUATA ! ' + process.env.MONGODB_URI + ' db: ' + process.env.DATABASE)
|
||||
console.log('*** CONNESSIONE EFFETTUATA ! ' + connectionUrl + ' db: ' + process.env.DATABASE)
|
||||
|
||||
});
|
||||
|
||||
module.exports = {mongoose};
|
||||
module.exports = { mongoose };
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"L'Email è già stata Verificata": "L'Email è già stata Verificata"
|
||||
"L'Email è già stata Verificata": "L'Email è già stata Verificata",
|
||||
"Email Verificata!": "Email Verificada! Cierre esta ventana y regrese a la otra.",
|
||||
"Nuova Registrazione": "Nuevo Registro",
|
||||
"Effettuata una Nuova Registrazione": "Se ha realizado un nuevo registro",
|
||||
|
||||
@@ -3,15 +3,25 @@
|
||||
"Hello %s": "Ciao %s",
|
||||
"Good: %s": "Bene: %s",
|
||||
"Service: %s": "Servizio: %s",
|
||||
"<strong>%s</strong> new Good: %s": "<strong>%s</strong> nuovo Bene: %s",
|
||||
"<strong>%s</strong> new Service: %s": "<strong>%s</strong> nuovo Servizio: %s",
|
||||
"NEW_GOOD": "❇️ <strong>%s</strong> ha aggiunto un nuovo Bene: \n<strong>%s</strong>",
|
||||
"NEW_SERVICE": "❇️ <strong>%s</strong> ha aggiunto un nuovo Servizio: \n<strong>%s</strong>",
|
||||
"NEW_HOSP": "❇️ <strong>%s</strong> ha aggiunto una nuova Ospitalità: \n<strong>%s</strong>",
|
||||
"NEW_EVENT": "❇️ <strong>%s</strong> ha aggiunto un nuovo Evento: \n%s\n<strong>%s</strong>\n%s",
|
||||
"NEW_EVENT_TELEGRAM": "%s\n\n❇️ <strong>%s</strong>\n\n%s\n\n%s",
|
||||
"ADDED_FROM": "\n\n<i>(Evento aggiunto da <strong>%s</strong>)</i>",
|
||||
"CONTRIB": "\n💠 Contributo richiesto: %s",
|
||||
"ORGANIZED_BY": "\n<i>Organizzato da <strong>%s</strong></i>",
|
||||
"SHOW_POST": "👉🏻 vedi post su RISO",
|
||||
"OPEN PAGE": "<em>APRI la APP RISO oppure visita riso.app</em>",
|
||||
"<strong>%s</strong> asked you for Friendship": "<strong>%s</strong> ti ha chiesto l'Amicizia",
|
||||
"<strong>%s</strong> accepted your Friendship": "<strong>%s</strong> ha accettato l'Amicizia",
|
||||
"<strong>%s</strong> refused your Friendship": "<strong>%s</strong> ha rifiutato l'Amicizia",
|
||||
"✅ %s accepted your Friendship request !": "✅ %s ha accettato la tua richiesta di Amicizia !",
|
||||
"✅ You have accepted %s' Friendship request!": "✅ Hai accettato la richiesta di Amicizia di %s !",
|
||||
"GROUPS_ACCEPTED": "✅ Sei stato accettato da %s a far parte del Gruppo %s (da parte di %s)",
|
||||
"HANDSHAKE_SET": "<strong>%s</strong> ha comunicato che ti conosce personalmente e ha Fiducia in te (Stretta di mano).",
|
||||
"HANDSHAKE_CONFIRMED": "🤝 Hai contraccambiato la stretta di mano di <strong>%s</strong>!",
|
||||
"HANDSHAKE_ACCEPTED": "🤝 <strong>%s</strong> ha contraccambiato la tua stretta di mano !",
|
||||
"GROUPS_ACCEPTED": "✅ Sei stato accettato a far parte del Gruppo %s (da parte di %s)",
|
||||
"GROUPS_REFUSED": "❌ Ti è stato rifiutato l'accesso da %s a far parte del Gruppo %s. Se pensi sia un'errore, contatta l'amministratore del Gruppo.",
|
||||
"GROUPS_REMOVED": "❌ l'utente %s è stato rimosso del Gruppo %s (da parte di %s)",
|
||||
"GROUPS_EXIT_USER": "❌ l'utente %s è uscito dal Gruppo %s",
|
||||
@@ -33,36 +43,75 @@
|
||||
"FRIEND_UNBLOCKED_TO_ME": "Sei stato riattivato da %s",
|
||||
"FRIEND_UNBLOCKED": "E' stato riattivato %s da %s.",
|
||||
"FRIEND_UNBLOCKED_YOU": "Hai riattivato %s.",
|
||||
"CIRCUIT_ACCEPT_NEWENTRY": "❇️👥 🧍♂️ Accetta Ingresso nel Circuito %s:",
|
||||
"CIRCUIT_REQUEST_TO_ENTER": "%s ha chiesto di entrare nel circuito %s",
|
||||
"CIRCUIT_ACCEPT_NEWENTRY": "❇️👥 🧍♂️ Abilita Fiducia a %s nel '%s':",
|
||||
"CIRCUIT_ACCEPT_NEWENTRY_BYGROUP": "❇️👥 🧍♂️ Abilita Fiducia nel Circuito al gruppo %s:",
|
||||
"CIRCUIT_OPEN_RISITALIA": "Apri il Circuito RIS Italia e chiedi di entrare",
|
||||
"CIRCUIT_REQUEST_TO_ENTER": "%s è entrato nel %s (con %s iscritti) ed è in attesa di essere abilitato alla Fiducia\n🙎🏻♂️ Invitato da %s",
|
||||
"CIRCUIT_ADMINS": "Gli amministratori del circuito sono %s:\n%s",
|
||||
"CIRCUIT_WHERE_IS_PRESENT": "\nAttualmente è presente in: %s",
|
||||
"CIRCUIT_REQUEST_TO_ENTER_WITH_GROUP": "il gruppo %s ha chiesto di entrare nel %s (con %s iscritti)",
|
||||
"CIRCUIT_CREATED": "✅ %s ha creato un nuovo Circuito chiamato %s",
|
||||
"CIRCUIT_REQUEST": "Richiesta di entrare nel Circuito %s da parte di %s",
|
||||
"CIRCUIT_ADDED_ADMIN": "E' stato aggiunto %s come Amministratore del circuito %s da parte di %s",
|
||||
"CIRCUIT_ADDED_ADMIN_YOU": "Sei stato aggiunto come Amministratore del circuito %s da parte di %s",
|
||||
"CIRCUIT_REMOVED_ADMIN": "E' stato rimosso l'incarico di Amministratore a %s del circuito %s da parte di %s",
|
||||
"CIRCUIT_REMOVED_ADMIN_YOU": "Ti è stato rimosso l'incarico di Amministratore del circuito %s da parte di %s",
|
||||
"RICHIESTA_BLOCCO_CIRCUIT": "Richiesta di bloccare il Circuito %s da parte di %s",
|
||||
"CIRCUIT_ELIMINATO": "Il circuito %s è stato eliminato da parte di %s",
|
||||
"ACCETTATO_NOTIFICA_ADMINS_CIRCUIT": "✅ l'utente %s è stato accettato a far parte del Circuito %s (da parte di %s)",
|
||||
"CIRCUIT_ACCEPTED": "✅ Sei stato accettato da %s a far parte del Circuito %s.\nApri la APP e clicca in alto a destra sull'icona delle monete, oppure clicca qui: %s",
|
||||
"CIRCUIT_ACCEPTED_YOU": "✅ Hai accettato %s a far parte del Circuito %s",
|
||||
"CIRCUIT_REFUSED": "❌ Ti è stato rifiutato l'accesso da %s a far parte del Circuito %s. Se pensi sia un'errore, contatta l'amministratore del Circuito.",
|
||||
"CIRCUIT_REMOVED": "❌ l'utente %s è stato rimosso del Circuito %s (da parte di %s)",
|
||||
"CIRCUIT_REFUSED_TO_ME": "All'utente %s gli è stato rifiutato l'accesso a far parte del Circuito %s (da parte di %s).",
|
||||
"CIRCUIT_EXIT_USER": "❌ l'utente %s è uscito dal Circuito %s",
|
||||
"CIRCUIT_EXIT_USER_TO_ME": "❌ Sei uscito dal Circuito %s",
|
||||
"CIRCUIT_REMOVED_TO_ME": "❌ Sei stato rimosso dal Circuito %s (da parte di %s)",
|
||||
"CIRCUIT_SENDCOINSREQ": "%s ti sta inviando <strong>%s %s</strong>.",
|
||||
"CIRCUIT_SENDCOINSREQ_TO_ME": "Stai inviando <strong>%s %s</strong> a %s. \nIl destinatario deve accettare la transazione.",
|
||||
"ID_CIRCUIT_COINS_ACCEPTED": "<strong>%s %s</strong> accettati da %s.",
|
||||
"SALDO_UPDATE": "[Saldo <strong>%s %s</strong>]",
|
||||
"ID_CIRCUIT_COINS_ACCEPTED_TO_ME": "<strong>%s %s</strong> sono stati accettati da %s.",
|
||||
"ID_CIRCUIT_COINS_REFUSED": "%s %s rifiutati da %s.",
|
||||
"ID_CIRCUIT_COINS_REFUSED_TO_ME": "%s %s rifiutati da %s.",
|
||||
"CIRCUIT_REQUEST": "Richiesta di entrare nel %s da parte di %s",
|
||||
"CIRCUIT_ADDED_ADMIN": "E' stato aggiunto %s come Amministratore del %s da parte di %s",
|
||||
"CIRCUIT_ADDED_ADMIN_YOU": "%s sei stato aggiunto come Amministratore del %s da parte di %s",
|
||||
"CIRCUIT_REMOVED_ADMIN": "E' stato rimosso l'incarico di Amministratore a %s del %s da parte di %s",
|
||||
"CIRCUIT_REMOVED_ADMIN_YOU": "%s ti è stato rimosso l'incarico di Amministratore del %s da parte di %s",
|
||||
"RICHIESTA_BLOCCO_CIRCUIT": "Richiesta di bloccare il %s da parte di %s",
|
||||
"CIRCUIT_ELIMINATO": "Il %s è stato eliminato da parte di %s",
|
||||
"FIDO_IMPOSTATO_ADMINS_CIRCUIT": "✅ l'utente %s è stato abilitato alla Fiducia (%s RIS) sul '%s' (da parte di %s)",
|
||||
"FIDO_IMPOSTATO_ADMINS_CIRCUIT_MYGROUP": "✅ il Conto di Gruppo %s è stato abilitato alla Fiducia fino a -%s sul '%s' (da parte di %s)",
|
||||
"ACCETTATO_NOTIFICA_ADMINS_CIRCUIT": "✅ l'utente %s è stato accettato a far parte del '%s' (da parte di %s)",
|
||||
"ACCETTATO_NOTIFICA_ADMINS_CIRCUIT_MYGROUP": "✅ il Conto di Gruppo %s è stato accettato a far parte del '%s' (da parte di %s)",
|
||||
"CIRCUIT_ACCEPTED": "✅ Sei stato accettato da %s a far parte del %s.\nApri la APP e clicca in alto a destra sull'icona delle monete, oppure clicca qui: %s",
|
||||
"FIDO_IMPOSTATO": "✅ Ti è stata attivata la possibilità di utilizzare la Fiducia Concessa fino a %s RIS da %s sul '%s'.",
|
||||
"CIRCUIT_ACCEPTED_YOU": "✅ Hai accettato %s a far parte del '%s'",
|
||||
"CIRCUIT_REFUSED": "❌ Ti è stato rifiutato l'accesso da %s a far parte del '%s'. Se pensi sia un'errore, contatta l'amministratore del Circuito.",
|
||||
"CIRCUIT_REMOVED": "❌ l'utente %s è stato rimosso del %s (da parte di %s)",
|
||||
"CIRCUIT_REFUSED_TO_ME": "All'utente %s gli è stato rifiutato l'accesso a far parte del '%s' (da parte di %s).",
|
||||
"CIRCUIT_REFUSED_TO_MYGROUP": "Al Conto Collettivo %s gli è stato rifiutato l'accesso a far parte del '%s' (da parte di %s).",
|
||||
"CIRCUIT_EXIT_USER": "❌ l'utente %s è uscito dal '%s'",
|
||||
"CIRCUIT_EXIT_USER_TO_ME": "❌ Sei uscito dal '%s'",
|
||||
"CIRCUIT_REMOVED_TO_ME": "❌ Sei stato rimosso dal '%s' (da parte di %s)",
|
||||
"CIRCUIT_SENDCOINSREQ": "%s ti sta inviando <strong>%s %s</strong> sul <strong>'%s'</strong>",
|
||||
"COMUNITARIO": "Comunitario",
|
||||
"COLLETTIVO": "Gruppo",
|
||||
"CIRCUIT_SENDCOINSREQ_GROUP": "%s sta inviando <strong>%s %s</strong> al Conto %s '%s' sul '%s'.",
|
||||
"CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_USER": "il conto %s '%s' (%s) sta inviando <strong>%s %s</strong> a %s sul '%s'.",
|
||||
"CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_YOU": "il conto %s '%s' (%s) ti sta inviando <strong>%s %s</strong> sul '%s'",
|
||||
"CIRCUIT_SENDCOINSREQ_FROM_GROUP_TO_GROUP": "il conto %s '%s' (%s) sta inviando <strong>%s %s</strong> al conto %s '%s' sul '%s'.",
|
||||
"CIRCUIT_SENDCOINSREQ_TO_ME": "Stai inviando <strong>%s %s</strong> a %s sul '%s'. \nIl destinatario deve accettare la transazione.",
|
||||
"CIRCUIT_SENDCOINSREQ_TO_GROUP": "Stai inviando <strong>%s %s</strong> al Conto %s '%s' sul '%s'. \nIl destinatario deve accettare la transazione.",
|
||||
"ID_CIRCUIT_COINS_ACCEPTED_FROM_GROUP_TO_YOU": "<strong>%s %s</strong> accettati dal Conto %s '%s' sul '%s' (%s) .",
|
||||
"ID_CIRCUIT_COINS_ACCEPTED_FROM_GROUP_TO_GROUP": "il conto %s '%s' (%s) ha accettato <strong>%s %s</strong> dal conto %s '%s' sul '%s' (%s).",
|
||||
"ID_CIRCUIT_COINS_ACCEPTED_FROM_ME_TO_GROUP": "il conto %s '%s' (%s) ha accettato <strong>%s %s</strong> da %s sul '%s'.",
|
||||
"ID_CIRCUIT_COINS_ACCEPTED_FROM_ME_TO_YOU": "<strong>%s %s</strong> accettati da %s sul '%s'.",
|
||||
"ID_CIRCUIT_COINS_ACCEPTED": "<strong>%s %s</strong> accettati da %s sul '%s'.",
|
||||
"SALDO_UPDATE": "[Saldo <strong>%s %s</strong> sul '%s']",
|
||||
"SALDO_UPDATE_WHO": "[Saldo %s <strong>%s %s</strong> sul '%s']",
|
||||
"ID_CIRCUIT_COINS_ACCEPTED_TO_ME": "<strong>%s %s</strong> sono stati accettati da %s sul '%s'.",
|
||||
"ID_CIRCUIT_COINS_REFUSED": "%s %s rifiutati da %s sul '%s'.",
|
||||
"ID_CIRCUIT_COINS_REFUSED_TO_ME": "%s %s rifiutati da %s sul '%s'.",
|
||||
"CIRCUIT_AMOUNT_EXCEED_FIDO": "L'importo supera la quantità massima concessa per %s",
|
||||
"CIRCUIT_AMOUNT_EXCEED_QTAMAX": "L'importo supera la quantità massima che il destinatario (%s) può accumulare",
|
||||
"CIRCUIT_COINS_ALREADY_PROCESSED": "La richiesta è stata già processata. Stato %s",
|
||||
"STATUS_SENT": "Inviato",
|
||||
"STATUS_REFUSED": "Rifiutato",
|
||||
"CLICCA_QUI": "CLICCA QUI"
|
||||
"SALDO_VARIATO": "[%s] l'utente %s ha variato il Saldo di %s da %s a %s %s",
|
||||
"FIDOCONCESSO_VARIATO": "[%s] l'utente %s ha variato la Fiducia Concessa di %s da %s a %s %s",
|
||||
"QTAMAX_VARIATO": "[%s] l'utente %s ha variato la quantità massima concessa di %s da %s a %s %s",
|
||||
"SET_FAVORITE": "%s ha messo 'Mi Piace' al tuo post: %s",
|
||||
"SET_FAVORITE_OTHERS": "%s e altre %s persone hanno messo 'Mi Piace' al tuo post: %s",
|
||||
"EVENT_SEND_MSG": "%s ha mandato un messaggio sull'evento %s: \n%s",
|
||||
"SET_ATTEND": "%s ha detto che Parteciperà all'evento: %s",
|
||||
"SET_ATTEND_OTHERS": "%s e altre %s persone hanno detto che Parteciperanno all'evento: %s",
|
||||
"DATEDAYONLY": "%s dalle %s alle %s",
|
||||
"DATE_2DAYS": "%s dalle %s fino a %s alle %s",
|
||||
"SENDMSG_ENTRA_IN_RISO_ITALIA": "Ciao %s!<br>%s che appartiene al <em>%s</em> vuole inviarti dei RIS. Per poterli ricevere dovete entrambi utilizzare il <strong>Circuito RIS Italia</strong>.",
|
||||
"CLICCA_QUI": "CLICCA QUI",
|
||||
"✅ %s è stato Abilitato correttamente (da %s)!": "✅ %s è stato Abilitato correttamente (da %s)!",
|
||||
"✅ Sei stato Abilitato correttamente da %s!": "✅ Sei stato Abilitato correttamente da %s!",
|
||||
"🚫 Hai rifiutato l'accesso alla App di RISO da parte di %s!": "🚫 Hai rifiutato l'accesso alla App di RISO da parte di %s!",
|
||||
"🚫 Ti è stato rifiutato l'accesso. Probabilmente l'username con cui ti sei registrato non ti conosce. (%s) !<br>Contatta l'Assistenza Tecnica.": "🚫 Ti è stato rifiutato l'accesso. Probabilmente l'username con cui ti sei registrato non ti conosce. (%s) !<br>Contatta l'Assistenza Tecnica.",
|
||||
"🚫 %s ha rifiutato l'accesso alla App a %s !": "🚫 %s ha rifiutato l'accesso alla App a %s !",
|
||||
"✅ Hai Abilitato l'accesso alla App a %s !": "✅ Hai Abilitato l'accesso alla App a %s !"
|
||||
}
|
||||
@@ -16,6 +16,17 @@ const authenticate = (req, res, next) => {
|
||||
|
||||
// console.log('authenticate... ');
|
||||
|
||||
let noaut = false;
|
||||
|
||||
if (req.body.hasOwnProperty('noaut')) {
|
||||
noaut = req.body.noaut;
|
||||
}
|
||||
|
||||
if (noaut) {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
|
||||
const access = 'auth';
|
||||
|
||||
User.findByToken(token, access).then((user) => {
|
||||
|
||||
@@ -30,9 +30,18 @@ const AccountSchema = new Schema({
|
||||
idapp: {
|
||||
type: String,
|
||||
},
|
||||
numtransactions: {
|
||||
type: Number,
|
||||
},
|
||||
username: {
|
||||
type: String,
|
||||
},
|
||||
groupname: { // For the Groups
|
||||
type: String,
|
||||
},
|
||||
contocom: { // For the Conto Comunitario dei Circuiti
|
||||
type: String,
|
||||
},
|
||||
circuitId: { // ----- REF TO Circuit
|
||||
type: String,
|
||||
},
|
||||
@@ -50,12 +59,23 @@ const AccountSchema = new Schema({
|
||||
},
|
||||
importo_iniziale: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
saldo: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
totTransato: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
saldo_pend: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
totTransato_pend: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
regulation_ok: {
|
||||
type: Boolean,
|
||||
@@ -94,6 +114,9 @@ AccountSchema.pre('save', async function (next) {
|
||||
AccountSchema.statics.getFieldsForSearch = function () {
|
||||
return [
|
||||
{ field: 'name', type: tools.FieldType.string },
|
||||
{ field: 'username', type: tools.FieldType.string },
|
||||
{ field: 'groupname', type: tools.FieldType.string },
|
||||
{ field: 'contocom', type: tools.FieldType.string },
|
||||
];
|
||||
|
||||
};
|
||||
@@ -129,7 +152,7 @@ AccountSchema.statics.calcTotCircolante = async function (idapp, circuitId) {
|
||||
{ $group: { _id: null, count: { $sum: '$saldo' } } }
|
||||
];
|
||||
|
||||
ris = await Account.aggregate(aggr1);
|
||||
const ris = await Account.aggregate(aggr1);
|
||||
|
||||
return ris ? ris[0].count : 0;
|
||||
|
||||
@@ -138,23 +161,69 @@ AccountSchema.statics.calcTotCircolante = async function (idapp, circuitId) {
|
||||
}
|
||||
|
||||
};
|
||||
AccountSchema.methods.addtoSaldoSave = async function (amount) {
|
||||
const account = this;
|
||||
AccountSchema.methods.calcPending = async function (mittente) {
|
||||
try {
|
||||
const account = this;
|
||||
|
||||
if (account) {
|
||||
account.saldo = account.saldo + amount;
|
||||
if (!account.totTransato) {
|
||||
account.totTransato = 0;
|
||||
const { SendNotif } = require('../models/sendnotif');
|
||||
const { Circuit } = require('../models/circuit');
|
||||
|
||||
// *** Calc Pending Transactions ***
|
||||
|
||||
const circuit = await Circuit.getCircuitById(account.circuitId);
|
||||
if (circuit) {
|
||||
let prec_saldo_pend = account.saldo_pend;
|
||||
let prec_totTransato_pend = account.totTransato_pend;
|
||||
let transatopending = 0;
|
||||
|
||||
if (mittente) {
|
||||
let pendingtransactionsMittente = await SendNotif.getSumPendingTransactionsMittente(account.idapp, account.username, circuit.name, account.groupname);
|
||||
let saldopendingMitt = pendingtransactionsMittente.reduce((sum, rec) => sum + rec.extrarec.qty, 0);
|
||||
transatopending = pendingtransactionsMittente.reduce((sum, rec) => sum + Math.abs(rec.extrarec.qty), 0);
|
||||
|
||||
account.saldo_pend = account.saldo - saldopendingMitt;
|
||||
} else {
|
||||
// let pendingtransactionsDest = await SendNotif.getSumPendingTransactionsMittente(account.idapp, account.username, circuit.name, account.groupname);
|
||||
|
||||
// let saldopendingDest = pendingtransactionsDest.reduce((sum, rec) => sum + rec.extrarec.qty, 0);
|
||||
// transatopending = pendingtransactionsDest.reduce((sum, rec) => sum + Math.abs(rec.extrarec.qty), 0);
|
||||
|
||||
// account.saldo_pend = account.saldo + saldopendingDest;
|
||||
account.saldo_pend = account.saldo;
|
||||
}
|
||||
account.totTransato_pend = account.totTransato + transatopending;
|
||||
|
||||
if (prec_saldo_pend !== account.saldo_pend || prec_totTransato_pend !== account.totTransato_pend) {
|
||||
|
||||
const myaccountupdate = {
|
||||
saldo_pend: account.saldo_pend,
|
||||
totTransato_pend: account.totTransato_pend,
|
||||
};
|
||||
|
||||
// Update Record
|
||||
return await Account.findByIdAndUpdate(account.id,
|
||||
{
|
||||
$set: myaccountupdate
|
||||
}).then((ris) => {
|
||||
console.log('calcPending', ris);
|
||||
}).catch((err) => {
|
||||
console.error('calcPending', err);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
account.totTransato += Math.abs(amount);
|
||||
account.date_updated = new Date();
|
||||
return await account.save();
|
||||
|
||||
|
||||
// -----
|
||||
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
AccountSchema.statics.addtoSaldo = async function (myaccount, amount) {
|
||||
AccountSchema.statics.addtoSaldo = async function (myaccount, amount, mitt) {
|
||||
const Account = this;
|
||||
|
||||
try {
|
||||
@@ -166,16 +235,27 @@ AccountSchema.statics.addtoSaldo = async function (myaccount, amount) {
|
||||
myaccount.totTransato = 0;
|
||||
}
|
||||
myaccount.totTransato += Math.abs(amount);
|
||||
|
||||
if (!myaccount.numtransactions)
|
||||
myaccount.numtransactions = 0;
|
||||
myaccount.numtransactions++;
|
||||
|
||||
myaccount.date_updated = new Date();
|
||||
|
||||
myaccountupdate.saldo = myaccount.saldo;
|
||||
myaccountupdate.totTransato = myaccount.totTransato;
|
||||
myaccountupdate.date_updated = myaccount.date_updated;
|
||||
|
||||
return await Account.updateOne({ _id: myaccount.id },
|
||||
const ris = await Account.updateOne({ _id: myaccount.id },
|
||||
{
|
||||
$set: myaccountupdate
|
||||
});
|
||||
|
||||
|
||||
await myaccount.calcPending(mitt);
|
||||
|
||||
return ris;
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('error', e);
|
||||
@@ -186,28 +266,36 @@ AccountSchema.statics.addtoSaldo = async function (myaccount, amount) {
|
||||
|
||||
AccountSchema.pre('save', async function (next) {
|
||||
if (this.isNew) {
|
||||
this.date_created = new Date();
|
||||
if (!this.date_created)
|
||||
this.date_created = new Date();
|
||||
}
|
||||
|
||||
next();
|
||||
});
|
||||
|
||||
AccountSchema.statics.getAccountByUsernameAndCircuitId = async function (idapp, username, circuitId, createifnotexist) {
|
||||
AccountSchema.statics.getAccountByUsernameAndCircuitId = async function (idapp, username, circuitId, createifnotexist, confido, groupname = '', contocom = "") {
|
||||
const Account = this;
|
||||
|
||||
try {
|
||||
|
||||
const { Circuit } = require('../models/circuit');
|
||||
|
||||
if (username === undefined)
|
||||
return false;
|
||||
// if (username === undefined)
|
||||
// return false;
|
||||
|
||||
let myquery = {
|
||||
'idapp': idapp,
|
||||
'username': username,
|
||||
idapp,
|
||||
circuitId,
|
||||
};
|
||||
|
||||
if (groupname) {
|
||||
myquery.groupname = groupname;
|
||||
} else if (contocom) {
|
||||
myquery.contocom = contocom;
|
||||
} else {
|
||||
myquery.username = username;
|
||||
}
|
||||
|
||||
let mycircuit = await Circuit.getCircuitById(circuitId);
|
||||
|
||||
if (mycircuit) {
|
||||
@@ -217,15 +305,43 @@ AccountSchema.statics.getAccountByUsernameAndCircuitId = async function (idapp,
|
||||
myaccount = new Account({
|
||||
_id: new ObjectID().toString(),
|
||||
idapp,
|
||||
username,
|
||||
username: (!groupname && !contocom) ? username : '',
|
||||
groupname,
|
||||
contocom,
|
||||
circuitId: mycircuit._id,
|
||||
deperibile: false,
|
||||
fidoConcesso: mycircuit.fido_scoperto_default,
|
||||
qta_maxConcessa: mycircuit.qta_max_default,
|
||||
importo_iniziale: 0,
|
||||
saldo: 0,
|
||||
saldo_pend: 0,
|
||||
fidoConcesso: 0,
|
||||
qta_maxConcessa: 0,
|
||||
totTransato: 0,
|
||||
numtransactions: 0,
|
||||
totTransato_pend: 0,
|
||||
});
|
||||
|
||||
if (contocom) {
|
||||
myaccount.fidoConcesso = shared_consts.CIRCUIT_PARAMS.SCOPERTO_MIN_CONTO_COMUNITARIO;
|
||||
myaccount.qta_maxConcessa = shared_consts.CIRCUIT_PARAMS.SCOPERTO_MAX_CONTO_COMUNITARIO;
|
||||
} else {
|
||||
if (!mycircuit.fido_scoperto_default_grp)
|
||||
mycircuit.fido_scoperto_default_grp = shared_consts.CIRCUIT_PARAMS.SCOPERTO_MIN_GRP;
|
||||
if (!mycircuit.qta_max_default_grp)
|
||||
mycircuit.qta_max_default_grp = shared_consts.CIRCUIT_PARAMS.SCOPERTO_MAX_GRP;
|
||||
|
||||
if (groupname) {
|
||||
myaccount.fidoConcesso = mycircuit.fido_scoperto_default_grp;
|
||||
myaccount.qta_maxConcessa = mycircuit.qta_max_default_grp;
|
||||
} else {
|
||||
myaccount.fidoConcesso = mycircuit.fido_scoperto_default;
|
||||
myaccount.qta_maxConcessa = mycircuit.qta_max_default;
|
||||
}
|
||||
}
|
||||
|
||||
if (!confido) {
|
||||
myaccount.fidoConcesso = 0;
|
||||
}
|
||||
|
||||
return await myaccount.save();
|
||||
}
|
||||
|
||||
@@ -239,14 +355,52 @@ AccountSchema.statics.getAccountByUsernameAndCircuitId = async function (idapp,
|
||||
|
||||
};
|
||||
|
||||
AccountSchema.statics.createAccount = async function (idapp, username, circuitName) {
|
||||
AccountSchema.statics.isExistAccountByUsernameAndCircuitId = async function (idapp, username, circuitId, groupname = '', contocom = "") {
|
||||
const Account = this;
|
||||
|
||||
try {
|
||||
|
||||
const { Circuit } = require('../models/circuit');
|
||||
|
||||
if (username === undefined)
|
||||
return false;
|
||||
|
||||
let myquery = {
|
||||
idapp,
|
||||
circuitId,
|
||||
};
|
||||
|
||||
if (groupname) {
|
||||
myquery.groupname = groupname;
|
||||
} else if (contocom) {
|
||||
myquery.contocom = contocom;
|
||||
} else {
|
||||
myquery.username = username;
|
||||
}
|
||||
|
||||
let mycircuit = await Circuit.getCircuitById(circuitId);
|
||||
|
||||
if (mycircuit) {
|
||||
let myaccount = await Account.findOne(myquery);
|
||||
return !!myaccount
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
} catch (e) {
|
||||
console.error('error', e);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
AccountSchema.statics.createAccount = async function (idapp, username, circuitName, confido, groupname = '', contocom = '') {
|
||||
|
||||
const { Circuit } = require('../models/circuit');
|
||||
|
||||
try {
|
||||
mycircuit = await Circuit.findOne({ name: circuitName }, {_id: 1});
|
||||
mycircuit = await Circuit.findOne({ name: circuitName }, { _id: 1 });
|
||||
if (mycircuit) {
|
||||
return await Account.getAccountByUsernameAndCircuitId(idapp, username, mycircuit._id, true);
|
||||
return await Account.getAccountByUsernameAndCircuitId(idapp, username, mycircuit._id, true, confido, groupname, contocom);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@@ -258,6 +412,7 @@ AccountSchema.statics.createAccount = async function (idapp, username, circuitNa
|
||||
};
|
||||
|
||||
AccountSchema.statics.getUserAccounts = async function (idapp, username) {
|
||||
const { SendNotif } = require('../models/sendnotif');
|
||||
|
||||
try {
|
||||
let aggr1 = [
|
||||
@@ -289,32 +444,114 @@ AccountSchema.statics.getUserAccounts = async function (idapp, username) {
|
||||
$match: {
|
||||
$expr: {
|
||||
$and: [
|
||||
{ $eq: ['$idapp', '$$idapp'] },
|
||||
{ $eq: ['$typedir', '$$typedir'] },
|
||||
{ $eq: ['$typeid', '$$typeid'] },
|
||||
{ $eq: ['$status', 0] },
|
||||
{ $eq: ['$sender', '$$username'] },
|
||||
{ $eq: ['$extrarec.circuitname', '$$circuitname'] },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$group:
|
||||
{ _id: "$extrarec.notifIdToUpdate", result: { $first: "$$ROOT" } }
|
||||
},
|
||||
|
||||
],
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const ris = await this.aggregate(aggr1);
|
||||
|
||||
// console.log('1 - INIZIA getUserAccounts ')
|
||||
// console.log(aggr1);
|
||||
|
||||
/* if (ris) {
|
||||
for (const account of ris) {
|
||||
try {
|
||||
//++OTTIMIZZARE QUESTA PARTE ! (CON UNA QUERY...)
|
||||
// console.log(' 1B - PENDIND... ')
|
||||
|
||||
let pendingtransactions = await SendNotif.getSumPendingTransactions(idapp, username, account.circuit.name);
|
||||
let saldopending = pendingtransactions.reduce((sum, rec) => sum + rec.extrarec.qty, 0);
|
||||
if (saldopending !== 0) {
|
||||
account.saldo -= saldopending;
|
||||
account.totTransato = account.totTransato || 0;
|
||||
}
|
||||
|
||||
|
||||
} catch (e) {
|
||||
console.error('getUserAccounts 1) ', e);
|
||||
}
|
||||
|
||||
}
|
||||
} */
|
||||
|
||||
return ris;
|
||||
} catch (e) {
|
||||
console.error('getUserAccounts', e);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
AccountSchema.statics.getGroupAccounts = async function (idapp, groupname) {
|
||||
|
||||
if (!groupname) {
|
||||
return [];
|
||||
}
|
||||
try {
|
||||
let aggr1 = [
|
||||
{
|
||||
$match: { idapp, groupname },
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'circuits',
|
||||
localField: 'circuitId',
|
||||
foreignField: '_id',
|
||||
as: 'circuit',
|
||||
},
|
||||
},
|
||||
{ $unwind: '$circuit' },
|
||||
{
|
||||
$lookup: {
|
||||
from: 'sendnotifs',
|
||||
as: 'notifspending',
|
||||
let: {
|
||||
circuitname: '$circuit.name',
|
||||
groupname: '$groupname',
|
||||
idapp: '$idapp',
|
||||
typedir: shared_consts.TypeNotifs.TYPEDIR_CIRCUITS,
|
||||
typeid: shared_consts.TypeNotifs.ID_CIRCUIT_SENDCOINSREQ,
|
||||
},
|
||||
pipeline: [
|
||||
{
|
||||
$match: {
|
||||
$expr: {
|
||||
$and: [
|
||||
{ $eq: ['$typedir', '$$typedir'] },
|
||||
{ $eq: ['$typeid', '$$typeid'] },
|
||||
{ $eq: ['$status', 0] },
|
||||
{ $eq: ['$sendergroup', '$$groupname'] },
|
||||
{ $eq: ['$idapp', '$$idapp'] },
|
||||
{ $eq: ['$extrarec.circuitname', '$$circuitname'] },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$group:
|
||||
{ _id: "$extrarec.notifIdToUpdate", result: { $first: "$$ROOT" } }
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
ris = await this.aggregate(aggr1);
|
||||
|
||||
const { SendNotif } = require('../models/sendnotif');
|
||||
|
||||
if (ris) {
|
||||
for (const account of ris) {
|
||||
const pendingtransactions = await SendNotif.getSumPendingTransactions(idapp, username, account.circuit.name);
|
||||
const saldopending = pendingtransactions.reduce((sum, rec) => sum + rec.extrarec.qty, 0);
|
||||
account.saldo -= saldopending;
|
||||
}
|
||||
}
|
||||
const ris = await this.aggregate(aggr1);
|
||||
|
||||
return ris;
|
||||
} catch (e) {
|
||||
@@ -323,6 +560,198 @@ AccountSchema.statics.getUserAccounts = async function (idapp, username) {
|
||||
|
||||
};
|
||||
|
||||
// Imposta a tutti i Conti Collettivi, i seguenti minimi e massimi
|
||||
AccountSchema.statics.SetMinMaxCollettivi = async function (idapp, valmin, valmax) {
|
||||
const Account = this;
|
||||
|
||||
const ris = await Account.updateMany({ idapp, groupname: { "$nin": [null, ""] } },
|
||||
{
|
||||
$set:
|
||||
{
|
||||
fidoConcesso: valmin,
|
||||
qta_maxConcessa: valmax,
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
// Imposta a tutti i Conti Comunitari, i seguenti minimi e massimi
|
||||
AccountSchema.statics.SetMinMaxComunitari = async function (idapp, valmin, valmax) {
|
||||
const Account = this;
|
||||
|
||||
const ris = await Account.updateMany({ idapp, contocom: { "$nin": [null, ""] } },
|
||||
{
|
||||
$set:
|
||||
{
|
||||
fidoConcesso: valmin,
|
||||
qta_maxConcessa: valmax,
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
// Imposta a tutti i Conti Personali, i seguenti minimi e massimi
|
||||
AccountSchema.statics.SetMinMaxPersonali = async function (idapp, fidoConcesso, qta_maxConcessa, circuitId) {
|
||||
const Account = this;
|
||||
|
||||
if (circuitId) {
|
||||
const ris = await Account.updateMany({ idapp, circuitId, fidoConcesso: { $gt: 0 }, username: { "$nin": [null, ""] } },
|
||||
{
|
||||
$set:
|
||||
{
|
||||
fidoConcesso,
|
||||
qta_maxConcessa,
|
||||
}
|
||||
});
|
||||
|
||||
// Se aggiorno questi dati, allora devo aggiornare anche gli account del RIS Nazionale
|
||||
await Account.updateAccountCircuitoNazionaleByLimiti(idapp, circuitId, fidoConcesso, qta_maxConcessa);
|
||||
|
||||
} else {
|
||||
const ris = await Account.updateMany({ idapp, fidoConcesso: { $gt: 0 }, username: { "$nin": [null, ""] } },
|
||||
{
|
||||
$set:
|
||||
{
|
||||
fidoConcesso,
|
||||
qta_maxConcessa,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
AccountSchema.statics.updateFido = async function (idapp, username, groupname, circuitId, fido) {
|
||||
|
||||
let paramstoupdate = {
|
||||
fidoConcesso: fido,
|
||||
};
|
||||
let risult = null;
|
||||
if (groupname)
|
||||
risult = await Account.updateOne({ idapp, circuitId, groupname }, { $set: paramstoupdate });
|
||||
else
|
||||
risult = await Account.updateOne({ idapp, username, circuitId }, { $set: paramstoupdate });
|
||||
|
||||
return risult;
|
||||
};
|
||||
|
||||
AccountSchema.statics.updateQtaMax = async function (idapp, username, groupname, circuitId, qtamax) {
|
||||
|
||||
let paramstoupdate = {
|
||||
qta_maxConcessa: qtamax,
|
||||
};
|
||||
let risult = null;
|
||||
if (groupname)
|
||||
risult = await Account.updateOne({ idapp, circuitId, groupname }, { $set: paramstoupdate });
|
||||
else
|
||||
risult = await Account.updateOne({ idapp, username, circuitId }, { $set: paramstoupdate });
|
||||
|
||||
return risult && risult.nModified > 0;
|
||||
};
|
||||
|
||||
AccountSchema.statics.getAccountsCircuitiNazionali = async function (idapp) {
|
||||
const { Circuit } = require('../models/circuit');
|
||||
|
||||
const circuit = await Circuit.find({ idapp, showAlways: true });
|
||||
|
||||
return Account.find({ idapp, circuitId: circuit.id });
|
||||
};
|
||||
|
||||
AccountSchema.statics.updateAccountCircuitoNazionaleByLimiti = async function (idapp, circuitId, fidoConcesso, qta_maxConcessa) {
|
||||
const { Circuit } = require('../models/circuit');
|
||||
|
||||
try {
|
||||
const accounts = await this.getAccountsCircuitiNazionali(idapp);
|
||||
|
||||
for (const account of accounts) {
|
||||
const circuitId = account.circuitId;
|
||||
const circuit = await Circuit.findOne({ _id: circuitId });
|
||||
if (circuit) {
|
||||
let fido = 0;
|
||||
let qtamax = 0;
|
||||
|
||||
if (account.groupname) {
|
||||
fido = circuit.fido_scoperto_default_grp * shared_consts.CIRCUIT_CFG.MULT_FIDO_GROUP;
|
||||
qtamax = circuit.qta_max_default_grp * shared_consts.CIRCUIT_CFG.MULT_FIDO_GROUP;
|
||||
} else {
|
||||
fido = circuit.fido_scoperto_default * shared_consts.CIRCUIT_CFG.MULT_FIDO_USER;
|
||||
qtamax = circuit.qta_max_default * shared_consts.CIRCUIT_CFG.MULT_FIDO_USER;
|
||||
}
|
||||
|
||||
let paramstoupdate = {
|
||||
fidoConcesso: fido,
|
||||
qta_maxConcessa: qtamax,
|
||||
};
|
||||
|
||||
risult = await Account.updateOne({ _id: account.id }, { $set: paramstoupdate });
|
||||
}
|
||||
}
|
||||
return risult;
|
||||
} catch (e) {
|
||||
console.error('updateAccountCircuitoNazionaleByLimiti', e);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
};
|
||||
|
||||
AccountSchema.statics.canEditAccountAdmins = async function (username, id) {
|
||||
const account = await Account.findOne({ _id: id }).lean();
|
||||
|
||||
const { Circuit } = require('../models/circuit');
|
||||
|
||||
if (account) {
|
||||
const circuit = await Circuit.findOne({ _id: account.circuitId }).lean();
|
||||
if (circuit) {
|
||||
return circuit.admins.findIndex((admin) => admin.username === username) >= 0;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
AccountSchema.statics.addToPeopleOfMyAccount = async function (idapp, username, circuitId, person_username, perm) {
|
||||
|
||||
return await Account.updateOne({ idapp, username, circuitId },
|
||||
{
|
||||
$push:
|
||||
{
|
||||
people: {
|
||||
username: person_username,
|
||||
perm,
|
||||
date: new Date(),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
// Rimuovi dagli Admin del Account
|
||||
AccountSchema.statics.removeAdminOfAccount = async function (idapp, username, circuitId, person_username, perm) {
|
||||
const { Circuit } = require('../models/circuit');
|
||||
|
||||
return await Circuit.updateOne({ idapp, username, circuitId },
|
||||
{ $pull: { people: { username: { $in: [person_username] } } } });
|
||||
};
|
||||
|
||||
// Rimuovi l'account
|
||||
AccountSchema.statics.removeAccount = async function (accountId) {
|
||||
|
||||
return await Account.deleteOne({ _id: accountId});
|
||||
};
|
||||
|
||||
AccountSchema.statics.updateSaldoAndTransato_AllAccounts = async function (idapp) {
|
||||
|
||||
const recaccounts = await Account.find({ idapp });
|
||||
|
||||
for (const account of recaccounts) {
|
||||
await account.calcPending();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
const Account = mongoose.model('Account', AccountSchema);
|
||||
|
||||
Account.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = { Account };
|
||||
|
||||
@@ -64,4 +64,8 @@ AdTypeSchema.statics.executeQueryTable = function(idapp, params) {
|
||||
|
||||
const AdType = mongoose.model('AdType', AdTypeSchema);
|
||||
|
||||
AdType.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = {AdType};
|
||||
|
||||
@@ -64,4 +64,8 @@ AdTypeGoodSchema.statics.executeQueryTable = function(idapp, params) {
|
||||
|
||||
const AdTypeGood = mongoose.model('AdTypeGood', AdTypeGoodSchema);
|
||||
|
||||
AdTypeGood.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = {AdTypeGood};
|
||||
|
||||
@@ -20,6 +20,12 @@ const bookingSchema = new Schema({
|
||||
userId: {
|
||||
type: String,
|
||||
},
|
||||
username: {
|
||||
type: String,
|
||||
},
|
||||
tableType: {
|
||||
type: Number,
|
||||
},
|
||||
id_bookedevent: {
|
||||
type: String,
|
||||
},
|
||||
@@ -116,4 +122,8 @@ bookingSchema.statics.findAllDistinctByBooking = function (idapp) {
|
||||
|
||||
const Booking = mongoose.model('Booking', bookingSchema);
|
||||
|
||||
Booking.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = { Booking };
|
||||
|
||||
@@ -50,11 +50,11 @@ const BotSchema = new Schema({
|
||||
},
|
||||
});
|
||||
|
||||
BotSchema.statics.getFieldsForSearch = function() {
|
||||
BotSchema.statics.getFieldsForSearch = function () {
|
||||
return [{ field: 'label', type: tools.FieldType.string }]
|
||||
};
|
||||
|
||||
BotSchema.statics.executeQueryTable = function(idapp, params) {
|
||||
BotSchema.statics.executeQueryTable = function (idapp, params) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
return tools.executeQueryTable(this, idapp, params);
|
||||
};
|
||||
@@ -66,14 +66,147 @@ BotSchema.statics.DuplicateAllRecords = async function (idapporig, idappdest) {
|
||||
};
|
||||
|
||||
|
||||
BotSchema.statics.findAllIdApp = async function(idapp) {
|
||||
BotSchema.statics.generateBotMenuRecords = async function (idapp) {
|
||||
|
||||
try {
|
||||
let arrrec = [
|
||||
{
|
||||
"page": 1,
|
||||
"index": 1,
|
||||
"riga": 1,
|
||||
"active": true,
|
||||
"label": "Vai al Sito",
|
||||
"type": 3,
|
||||
"value": "{host}",
|
||||
"visibility": 0,
|
||||
idapp,
|
||||
"lang": "it",
|
||||
"main": true
|
||||
},
|
||||
{
|
||||
"page": 1,
|
||||
"index": 1,
|
||||
"riga": 2,
|
||||
"active": true,
|
||||
"label": "Il mio Profilo",
|
||||
"type": 3,
|
||||
"value": "{host}/my/{username}",
|
||||
"visibility": 1,
|
||||
idapp,
|
||||
"lang": "it",
|
||||
"main": true
|
||||
},
|
||||
{
|
||||
"page": 1,
|
||||
"index": 1,
|
||||
"riga": 3,
|
||||
"active": true,
|
||||
"label": "Link da Condividere",
|
||||
"type": 2,
|
||||
"value": "{host}/registrati/{username}",
|
||||
"visibility": 1,
|
||||
idapp,
|
||||
"lang": "it",
|
||||
"main": true,
|
||||
},
|
||||
{
|
||||
"page": 1,
|
||||
"index": 2,
|
||||
"riga": 1,
|
||||
"active": true,
|
||||
"label": "🔮 Help",
|
||||
"type": 4,
|
||||
"value": "",
|
||||
"visibility": 0,
|
||||
idapp,
|
||||
"lang": "it",
|
||||
"main": true,
|
||||
},
|
||||
{
|
||||
"page": 1,
|
||||
"index": 1,
|
||||
"riga": 3,
|
||||
"active": true,
|
||||
"label": "💁♀️ Admin",
|
||||
"type": 4,
|
||||
"value": "",
|
||||
"visibility": 5,
|
||||
idapp,
|
||||
"lang": "it",
|
||||
"main": true
|
||||
},
|
||||
{
|
||||
"page": 1,
|
||||
"index": 2,
|
||||
"riga": 2,
|
||||
"active": true,
|
||||
"label": "Imposta Foto Profilo",
|
||||
"type": 4,
|
||||
"value": "🖼 SetPicProfile",
|
||||
"visibility": 1,
|
||||
idapp,
|
||||
"lang": "it",
|
||||
"main": true
|
||||
},
|
||||
{
|
||||
"page": 1,
|
||||
"index": 2,
|
||||
"riga": 3,
|
||||
"active": true,
|
||||
"label": "🛠 Strumenti",
|
||||
"type": 1,
|
||||
"value": "2",
|
||||
"visibility": 1,
|
||||
idapp,
|
||||
"lang": "it",
|
||||
"main": true,
|
||||
},
|
||||
{
|
||||
"page": 2,
|
||||
"index": 1,
|
||||
"riga": 1,
|
||||
"active": true,
|
||||
"label": "🔑 Cambio Password",
|
||||
"type": 4,
|
||||
"value": "🔑 SetResetPwd",
|
||||
"visibility": 1,
|
||||
idapp,
|
||||
"lang": "it",
|
||||
},
|
||||
{
|
||||
"page": 2,
|
||||
"index": 1,
|
||||
"riga": 2,
|
||||
"active": true,
|
||||
"label": "👉🏻 Indietro",
|
||||
"type": 1,
|
||||
"value": "1",
|
||||
"visibility": 1,
|
||||
idapp,
|
||||
"lang": "it",
|
||||
}];
|
||||
|
||||
const ris = await MyBot.insertMany(arrrec);
|
||||
|
||||
return ris;
|
||||
|
||||
} catch (e) {
|
||||
console.error('Err:', e);
|
||||
}
|
||||
|
||||
}
|
||||
BotSchema.statics.findAllIdApp = async function (idapp) {
|
||||
const Bot = this;
|
||||
|
||||
const myfind = {idapp};
|
||||
const myfind = { idapp };
|
||||
|
||||
return await Bot.find(myfind).sort({page: 1, lang: 1, riga: 1, index: 1}).lean();
|
||||
return await Bot.find(myfind).sort({ page: 1, lang: 1, riga: 1, index: 1 }).lean();
|
||||
};
|
||||
|
||||
const MyBot = mongoose.model('Bot', BotSchema);
|
||||
|
||||
module.exports = {MyBot};
|
||||
MyBot.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = { MyBot };
|
||||
|
||||
@@ -76,4 +76,8 @@ CalZoomSchema.statics.getNextZoom = async function (idapp) {
|
||||
|
||||
const CalZoom = mongoose.model('CalZoom', CalZoomSchema);
|
||||
|
||||
CalZoom.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = { CalZoom };
|
||||
|
||||
@@ -1,24 +1,30 @@
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
mongoose.Promise = global.Promise;
|
||||
mongoose.level = "F";
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
schema.options.usePushEach = true
|
||||
});
|
||||
|
||||
const Order = require('../models/order');
|
||||
|
||||
const CartSchema = new Schema({
|
||||
idapp: {
|
||||
type: String,
|
||||
},
|
||||
userId: {type: Schema.Types.ObjectId, ref: 'User'},
|
||||
totalQty: {type: Number, default: 0},
|
||||
totalPrice: {type: Number, default: 0},
|
||||
userId: { type: Schema.Types.ObjectId, ref: 'User' },
|
||||
totalQty: { type: Number, default: 0 },
|
||||
totalPrice: { type: Number, default: 0 },
|
||||
totalPriceCalc: { type: Number, default: 0 },
|
||||
department: {
|
||||
type: String, ref: 'Department',
|
||||
},
|
||||
items: [
|
||||
{
|
||||
order:
|
||||
{type: Schema.Types.ObjectId, ref: 'Order'},
|
||||
{ type: Schema.Types.ObjectId, ref: 'Order' },
|
||||
},
|
||||
],
|
||||
note: {
|
||||
@@ -31,57 +37,64 @@ const CartSchema = new Schema({
|
||||
|
||||
var Cart = module.exports = mongoose.model('Cart', CartSchema);
|
||||
|
||||
module.exports.findAllIdApp = async function(idapp, userId) {
|
||||
const myfind = {idapp, userId};
|
||||
module.exports.findAllIdApp = async function (idapp, userId) {
|
||||
const myfind = { idapp, userId };
|
||||
|
||||
return await Cart.findOne(myfind).lean();
|
||||
};
|
||||
|
||||
module.exports.getCartByUserId = async function(uid, idapp) {
|
||||
let query = {userId: uid, idapp};
|
||||
const mycart = await Cart.findOne(query).lean();
|
||||
module.exports.getCartByUserId = async function (uid, idapp) {
|
||||
try {
|
||||
const Order = require('../models/order');
|
||||
|
||||
if (!!mycart) {
|
||||
for (const idkey in mycart.items) {
|
||||
try {
|
||||
idorder = mycart.items[idkey]._id.toString();
|
||||
const myorder = mycart.items[idkey].order;
|
||||
if (!!myorder) {
|
||||
idorder = mycart.items[idkey].order._id.toString();
|
||||
let query = { userId: uid, idapp };
|
||||
const mycart = await Cart.findOne(query).lean();
|
||||
|
||||
if (!!mycart) {
|
||||
for (const idkey in mycart.items) {
|
||||
try {
|
||||
idorder = mycart.items[idkey]._id.toString();
|
||||
const myorder = mycart.items[idkey].order;
|
||||
if (!!myorder) {
|
||||
idorder = mycart.items[idkey].order._id.toString();
|
||||
}
|
||||
const myord = await Order.getTotalOrderById(idorder);
|
||||
if (myord.length > 0) {
|
||||
mycart.items[idkey].order = myord[0];
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('err', e);
|
||||
}
|
||||
const myord = await Order.getTotalOrderById(idorder);
|
||||
if (myord.length > 0) {
|
||||
mycart.items[idkey].order = myord[0];
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('err', e);
|
||||
}
|
||||
return mycart;
|
||||
}
|
||||
return mycart;
|
||||
return null;
|
||||
} catch (e) {
|
||||
console.log('getCartByUserId err', e);
|
||||
}
|
||||
return null;
|
||||
|
||||
};
|
||||
|
||||
module.exports.updateCartByUserId = function(userId, newCart, callback) {
|
||||
let query = {userId: userId};
|
||||
Cart.find(query, function(err, c) {
|
||||
module.exports.updateCartByUserId = function (userId, newCart, callback) {
|
||||
let query = { userId: userId };
|
||||
Cart.find(query, function (err, c) {
|
||||
if (err) throw err;
|
||||
|
||||
//exist cart in databse
|
||||
if (c.length > 0) {
|
||||
Cart.findOneAndUpdate(
|
||||
{userId: userId},
|
||||
{
|
||||
$set: {
|
||||
items: newCart.items,
|
||||
totalQty: newCart.totalQty,
|
||||
totalPrice: newCart.totalPrice,
|
||||
userId: userId,
|
||||
},
|
||||
{ userId: userId },
|
||||
{
|
||||
$set: {
|
||||
items: newCart.items,
|
||||
totalQty: newCart.totalQty,
|
||||
totalPrice: newCart.totalPrice,
|
||||
totalPriceCalc: newCart.totalPriceCalc,
|
||||
userId: userId,
|
||||
},
|
||||
{new: true},
|
||||
callback,
|
||||
},
|
||||
{ new: true },
|
||||
callback,
|
||||
);
|
||||
} else {
|
||||
//no cart in database
|
||||
@@ -90,22 +103,26 @@ module.exports.updateCartByUserId = function(userId, newCart, callback) {
|
||||
});
|
||||
};
|
||||
|
||||
module.exports.updateCartByCartId = async function(cartId, newCart) {
|
||||
module.exports.updateCartByCartId = async function (cartId, newCart) {
|
||||
// delete newCart._doc._id;
|
||||
const items = newCart.items;
|
||||
const totalQty = newCart.totalQty;
|
||||
const totalPrice = newCart.totalPrice;
|
||||
const totalPriceCalc = newCart.totalPriceCalc;
|
||||
const note = newCart.note;
|
||||
|
||||
const modify_at = new Date();
|
||||
|
||||
return await Cart.findOneAndUpdate({_id: cartId}, {
|
||||
return await Cart.findOneAndUpdate({ _id: cartId }, {
|
||||
$set: {
|
||||
items,
|
||||
totalPrice,
|
||||
totalPriceCalc,
|
||||
totalQty,
|
||||
modify_at,
|
||||
note,
|
||||
modify_at: new Date(),
|
||||
},
|
||||
}, {new: false}).lean().then((ris) => {
|
||||
}, { new: false }).lean().then((ris) => {
|
||||
return ris;
|
||||
}).catch(err => {
|
||||
console.log('err', err);
|
||||
@@ -114,11 +131,15 @@ module.exports.updateCartByCartId = async function(cartId, newCart) {
|
||||
|
||||
};
|
||||
|
||||
module.exports.deleteCartByCartId = async function(cartId) {
|
||||
return await Cart.remove({_id: cartId});
|
||||
module.exports.deleteCartByCartId = async function (cartId) {
|
||||
return await Cart.remove({ _id: cartId });
|
||||
};
|
||||
|
||||
module.exports.createCart = async function(newCart) {
|
||||
module.exports.createCart = async function (newCart) {
|
||||
return await newCart.save();
|
||||
};
|
||||
|
||||
|
||||
Cart.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
@@ -1,127 +0,0 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
mongoose.level = "F";
|
||||
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
schema.options.usePushEach = true
|
||||
});
|
||||
|
||||
const CashSchema = new Schema({
|
||||
idapp: {
|
||||
type: String,
|
||||
},
|
||||
creatorUserId: {
|
||||
type: String,
|
||||
},
|
||||
idCashCategory: {
|
||||
type: String
|
||||
},
|
||||
idSubCashCategory: {
|
||||
type: String
|
||||
},
|
||||
type: { // CashType: TYPE_IN, TYPE_OUT
|
||||
type: Number
|
||||
},
|
||||
date_created: {
|
||||
type: Date
|
||||
},
|
||||
date_payment: {
|
||||
type: Date
|
||||
},
|
||||
descr: {
|
||||
type: String,
|
||||
},
|
||||
price: {
|
||||
type: Number
|
||||
},
|
||||
quantity: {
|
||||
type: Number
|
||||
},
|
||||
total: {
|
||||
type: Number
|
||||
},
|
||||
fromWalletUserId: { // walletCommonCash or any Member
|
||||
type: String,
|
||||
},
|
||||
toWalletUserId: { // walletCommonCash or any Member
|
||||
type: String,
|
||||
},
|
||||
walletStatus: { // WalletFinalStatusType: None: 0, InCommonCash: 1, InMyWallet : 2
|
||||
type: Number,
|
||||
},
|
||||
walletTemporaryToUserId: { // WalletCommonCash
|
||||
type: String,
|
||||
},
|
||||
walletCashId: {
|
||||
type: String,
|
||||
},
|
||||
internal: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
extra: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
notes: {
|
||||
type: String
|
||||
},
|
||||
confirmed: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
});
|
||||
|
||||
var Cash = module.exports = mongoose.model('Cash', CashSchema);
|
||||
|
||||
module.exports.getFieldsForSearch = function () {
|
||||
return []
|
||||
};
|
||||
|
||||
module.exports.executeQueryTable = function (idapp, params) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
return tools.executeQueryTable(this, idapp, params);
|
||||
};
|
||||
|
||||
module.exports.findAllIdApp = async function (idapp) {
|
||||
const myfind = { idapp };
|
||||
|
||||
return await Cash.find(myfind);
|
||||
};
|
||||
|
||||
module.exports.getAllCash = function (query, sort, callback) {
|
||||
Cash.find(query, null, sort, callback)
|
||||
}
|
||||
|
||||
module.exports.getCashByUserId = function (userId, sort, callback) {
|
||||
Cash.find({ userId }, null, sort, callback)
|
||||
}
|
||||
|
||||
|
||||
module.exports.getCashByID = function (id, callback) {
|
||||
Cash.findById(id, callback);
|
||||
}
|
||||
|
||||
module.exports.createCash = async function (Cash) {
|
||||
const CashModel = new Cash(Cash);
|
||||
|
||||
return await CashModel.save(Cash)
|
||||
.then((ris) => {
|
||||
if (!!ris)
|
||||
return ris._id;
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// const Cash = mongoose.model('Cash', CashSchema);
|
||||
|
||||
// module.exports = { Cash };
|
||||
@@ -28,6 +28,10 @@ const CashCategorySchema = new Schema({
|
||||
|
||||
var CashCategory = module.exports = mongoose.model('CashCategory', CashCategorySchema);
|
||||
|
||||
CashCategory.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports.getFieldsForSearch = function () {
|
||||
return []
|
||||
};
|
||||
@@ -66,3 +70,4 @@ module.exports.createCashCategory = async function (CashCategory) {
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -69,3 +69,7 @@ module.exports.createCashSubCategory = async function (CashSubCategory) {
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
module.exports.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
61
src/server/models/catai.js
Executable file
61
src/server/models/catai.js
Executable file
@@ -0,0 +1,61 @@
|
||||
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
mongoose.level = "F";
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
schema.options.usePushEach = true
|
||||
});
|
||||
|
||||
const CatAISchema = new Schema({
|
||||
_id: {
|
||||
type: Number,
|
||||
},
|
||||
name: {
|
||||
type: String,
|
||||
},
|
||||
img: {
|
||||
type: String,
|
||||
},
|
||||
icon: {
|
||||
type: String,
|
||||
},
|
||||
color: {
|
||||
type: String,
|
||||
},
|
||||
});
|
||||
|
||||
CatAISchema.statics.getAllCategories = function (callback) {
|
||||
CatAI.find(callback)
|
||||
}
|
||||
|
||||
CatAISchema.statics.getCatAIById = function (id, callback) {
|
||||
CatAI.findById(id, callback);
|
||||
}
|
||||
|
||||
CatAISchema.statics.getFieldsForSearch = function () {
|
||||
return [{ field: 'name', type: tools.FieldType.string }]
|
||||
};
|
||||
|
||||
CatAISchema.statics.executeQueryTable = function (idapp, params) {
|
||||
return tools.executeQueryTable(this, idapp, params);
|
||||
};
|
||||
|
||||
CatAISchema.statics.findAllIdApp = async function (idapp) {
|
||||
const myfind = {};
|
||||
|
||||
return await CatAI.find(myfind).sort({ name: 1 });
|
||||
};
|
||||
|
||||
const CatAI = mongoose.model('CatAI', CatAISchema);
|
||||
|
||||
CatAI.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = CatAI;
|
||||
@@ -1,9 +1,11 @@
|
||||
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
mongoose.level = "F";
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
@@ -11,20 +13,46 @@ mongoose.plugin(schema => {
|
||||
});
|
||||
|
||||
const CategorySchema = new Schema({
|
||||
idapp: {
|
||||
type: String,
|
||||
},
|
||||
name: {
|
||||
type: String,
|
||||
unique: true,
|
||||
index: true,
|
||||
lowercase: true
|
||||
}
|
||||
},
|
||||
img: {
|
||||
type: String,
|
||||
},
|
||||
});
|
||||
|
||||
module.exports.getAllCategories = function (callback) {
|
||||
CategorySchema.statics.getAllCategories = function (callback) {
|
||||
Category.find(callback)
|
||||
}
|
||||
|
||||
module.exports.getCategoryById = function (id, callback) {
|
||||
CategorySchema.statics.getCategoryById = function (id, callback) {
|
||||
Category.findById(id, callback);
|
||||
}
|
||||
|
||||
module.exports = mongoose.model('Category', CategorySchema);
|
||||
CategorySchema.statics.getFieldsForSearch = function () {
|
||||
return [{ field: 'name', type: tools.FieldType.string }]
|
||||
};
|
||||
|
||||
CategorySchema.statics.executeQueryTable = function (idapp, params) {
|
||||
return tools.executeQueryTable(this, idapp, params);
|
||||
};
|
||||
|
||||
CategorySchema.statics.findAllIdApp = async function (idapp) {
|
||||
const myfind = { idapp };
|
||||
|
||||
return await Category.find(myfind);
|
||||
};
|
||||
|
||||
const Category = mongoose.model('Category', CategorySchema);
|
||||
|
||||
Category.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
|
||||
module.exports = { Category };
|
||||
|
||||
@@ -80,4 +80,8 @@ CatGrpSchema.statics.executeQueryTable = function (idapp, params) {
|
||||
|
||||
const CatGrp = mongoose.model('CatGrp', CatGrpSchema);
|
||||
|
||||
CatGrp.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = { CatGrp };
|
||||
|
||||
62
src/server/models/catprod.js
Executable file
62
src/server/models/catprod.js
Executable file
@@ -0,0 +1,62 @@
|
||||
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
mongoose.level = "F";
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
schema.options.usePushEach = true
|
||||
});
|
||||
|
||||
const CatProdSchema = new Schema({
|
||||
idapp: {
|
||||
type: String,
|
||||
},
|
||||
name: {
|
||||
type: String,
|
||||
},
|
||||
img: {
|
||||
type: String,
|
||||
},
|
||||
icon: {
|
||||
type: String,
|
||||
},
|
||||
color: {
|
||||
type: String,
|
||||
},
|
||||
});
|
||||
|
||||
CatProdSchema.statics.getAllCategories = function (callback) {
|
||||
CatProd.find(callback)
|
||||
}
|
||||
|
||||
CatProdSchema.statics.getCatProdById = function (id, callback) {
|
||||
CatProd.findById(id, callback);
|
||||
}
|
||||
|
||||
CatProdSchema.statics.getFieldsForSearch = function () {
|
||||
return [{ field: 'name', type: tools.FieldType.string }]
|
||||
};
|
||||
|
||||
CatProdSchema.statics.executeQueryTable = function (idapp, params) {
|
||||
return tools.executeQueryTable(this, idapp, params);
|
||||
};
|
||||
|
||||
CatProdSchema.statics.findAllIdApp = async function (idapp) {
|
||||
const myfind = { idapp };
|
||||
|
||||
return await CatProd.find(myfind).sort({ name: 1 });
|
||||
};
|
||||
|
||||
const CatProd = mongoose.model('CatProd', CatProdSchema);
|
||||
|
||||
CatProd.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
|
||||
module.exports = CatProd;
|
||||
@@ -43,5 +43,9 @@ CfgServerSchema.statics.findAllIdApp = async function(idapp) {
|
||||
|
||||
const CfgServer = mongoose.model('CfgServer', CfgServerSchema);
|
||||
|
||||
CfgServer.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = {CfgServer};
|
||||
|
||||
|
||||
@@ -11,6 +11,9 @@ const { ObjectID } = require('mongodb');
|
||||
const { Movement } = require('../models/movement');
|
||||
const { Account } = require('../models/account');
|
||||
|
||||
const { Province } = require('../models/province');
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
|
||||
const i18n = require('i18n');
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
@@ -40,6 +43,9 @@ const CircuitSchema = new Schema({
|
||||
type: String,
|
||||
unique: true,
|
||||
},
|
||||
link_group: {
|
||||
type: String,
|
||||
},
|
||||
subname: {
|
||||
type: String,
|
||||
},
|
||||
@@ -47,6 +53,14 @@ const CircuitSchema = new Schema({
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
strProv:
|
||||
{
|
||||
type: String,
|
||||
},
|
||||
card: // Punti cardinali
|
||||
{
|
||||
type: String,
|
||||
},
|
||||
pub_to_share: {
|
||||
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW
|
||||
},
|
||||
@@ -106,6 +120,12 @@ const CircuitSchema = new Schema({
|
||||
qta_max_default: {
|
||||
type: Number,
|
||||
},
|
||||
fido_scoperto_default_grp: {
|
||||
type: Number,
|
||||
},
|
||||
qta_max_default_grp: {
|
||||
type: Number,
|
||||
},
|
||||
data_costituz: {
|
||||
type: Date,
|
||||
},
|
||||
@@ -173,6 +193,18 @@ const CircuitSchema = new Schema({
|
||||
username: { type: String },
|
||||
date: { type: Date },
|
||||
}], // username
|
||||
req_groups: [
|
||||
{
|
||||
_id: false,
|
||||
groupname: { type: String },
|
||||
date: { type: Date },
|
||||
}], // username
|
||||
refused_groups: [
|
||||
{
|
||||
_id: false,
|
||||
groupname: { type: String },
|
||||
date: { type: Date },
|
||||
}], // username
|
||||
deleted: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
@@ -184,10 +216,18 @@ const CircuitSchema = new Schema({
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
showAlways: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
status: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
ignoreLimits: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
});
|
||||
|
||||
CircuitSchema.pre('save', async function (next) {
|
||||
@@ -207,15 +247,14 @@ CircuitSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
const whatToShow = this.getWhatToShow(idapp, '');
|
||||
|
||||
return await Circuit.find(myfind, whatToShow, (err, arrrec) => {
|
||||
return arrrec;
|
||||
});
|
||||
return await Circuit.find(myfind, whatToShow).sort({ status: -1, numMembers: -1, name: 1 });
|
||||
};
|
||||
|
||||
CircuitSchema.statics.getFieldsForSearch = function () {
|
||||
return [
|
||||
{ field: 'nome_circuito', type: tools.FieldType.string },
|
||||
{ field: 'sotto_nome', type: tools.FieldType.string },
|
||||
{ field: 'name', type: tools.FieldType.string },
|
||||
{ field: 'subname', type: tools.FieldType.string },
|
||||
{ field: 'path', type: tools.FieldType.string },
|
||||
{ field: 'nome_valuta', type: tools.FieldType.string },
|
||||
{ field: 'descr', type: tools.FieldType.string },
|
||||
];
|
||||
@@ -245,13 +284,19 @@ CircuitSchema.statics.getWhatToShow = function (idapp, username) {
|
||||
date_updated: 1,
|
||||
nome_valuta: 1,
|
||||
fido_scoperto_default: 1,
|
||||
qta_max_default: 1,
|
||||
fido_scoperto_default_grp: 1,
|
||||
qta_max_default_grp: 1,
|
||||
deperimento: 1,
|
||||
showAlways: 1,
|
||||
transactionsEnabled: 1,
|
||||
status: 1,
|
||||
qta_max_default: 1,
|
||||
valuta_per_euro: 1,
|
||||
symbol: 1,
|
||||
idCity: 1,
|
||||
strProv: 1,
|
||||
card: 1,
|
||||
link_group: 1,
|
||||
pub_to_share: 1,
|
||||
visibility: 1,
|
||||
color: 1,
|
||||
@@ -261,6 +306,8 @@ CircuitSchema.statics.getWhatToShow = function (idapp, username) {
|
||||
admins: 1,
|
||||
req_users: 1,
|
||||
refused_users: 1,
|
||||
req_groups: 1,
|
||||
refused_groups: 1,
|
||||
'mycities': 1,
|
||||
};
|
||||
|
||||
@@ -298,17 +345,23 @@ CircuitSchema.statics.getWhatToShow_Unknown = function (idapp, username) {
|
||||
longdescr: 1,
|
||||
regulation: 1,
|
||||
numMembers: 1,
|
||||
showAlways: 1,
|
||||
systemUserId: 1,
|
||||
founderUserId: 1,
|
||||
nome_valuta: 1,
|
||||
totCircolante: 1,
|
||||
totTransato: 1,
|
||||
fido_scoperto_default: 1,
|
||||
fido_scoperto_default_grp: 1,
|
||||
qta_max_default_grp: 1,
|
||||
qta_max_default: 1,
|
||||
valuta_per_euro: 1,
|
||||
symbol: 1,
|
||||
color: 1,
|
||||
idCity: 1,
|
||||
strProv: 1,
|
||||
card: 1,
|
||||
link_group: 1,
|
||||
pub_to_share: 1,
|
||||
visibility: 1,
|
||||
abbrev: 1,
|
||||
@@ -320,6 +373,8 @@ CircuitSchema.statics.getWhatToShow_Unknown = function (idapp, username) {
|
||||
date_updated: 1,
|
||||
req_users: 1,
|
||||
refused_users: 1,
|
||||
req_groups: 1,
|
||||
refused_groups: 1,
|
||||
transactionsEnabled: 1,
|
||||
status: 1,
|
||||
'mycities': 1,
|
||||
@@ -345,14 +400,14 @@ CircuitSchema.statics.getCircuitsByUsername = async function (idapp, username, u
|
||||
$or: [
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}).lean();
|
||||
}).sort({ status: -1, numMembers: -1, name: 1 }).lean();
|
||||
|
||||
let listcircuits = await Circuit.find({
|
||||
idapp,
|
||||
$or: [
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}, whatToShow_Unknown).lean();
|
||||
}, whatToShow_Unknown).sort({ status: -1, numMembers: -1, name: 1 }).lean();
|
||||
|
||||
let asked_circuits = await Circuit.find({
|
||||
idapp,
|
||||
@@ -362,7 +417,7 @@ CircuitSchema.statics.getCircuitsByUsername = async function (idapp, username, u
|
||||
$or: [
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}, whatToShow_Unknown).lean();
|
||||
}, whatToShow_Unknown).sort({ status: -1 }).lean();
|
||||
|
||||
let refused_circuits = await Circuit.find({
|
||||
idapp,
|
||||
@@ -372,7 +427,7 @@ CircuitSchema.statics.getCircuitsByUsername = async function (idapp, username, u
|
||||
$or: [
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}, whatToShow_Unknown).lean();
|
||||
}, whatToShow_Unknown).sort({ status: -1 }).lean();
|
||||
|
||||
return {
|
||||
listcircuits,
|
||||
@@ -430,6 +485,49 @@ CircuitSchema.statics.getCircuitByName = async function (idapp, name) {
|
||||
|
||||
};
|
||||
|
||||
CircuitSchema.statics.getCircuitIdByName = async function (idapp, name) {
|
||||
|
||||
const myfind = {
|
||||
idapp,
|
||||
name,
|
||||
};
|
||||
|
||||
try {
|
||||
const circuit = await Circuit.findOne(myfind);
|
||||
return (!!circuit ? circuit._id : 0);
|
||||
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CircuitSchema.statics.getCircuitByProvinceAndCard = async function (idapp, strProv, card) {
|
||||
|
||||
let myfind = {};
|
||||
|
||||
if (card) {
|
||||
myfind = {
|
||||
idapp,
|
||||
strProv,
|
||||
card
|
||||
};
|
||||
} else {
|
||||
myfind = {
|
||||
idapp,
|
||||
strProv,
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
return await Circuit.findOne(myfind);
|
||||
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CircuitSchema.statics.getCircuitById = async function (circuitId) {
|
||||
|
||||
const myfind = {
|
||||
@@ -450,59 +548,6 @@ CircuitSchema.statics.deleteCircuit = async function (idapp, usernameOrig, name)
|
||||
return await Circuit.findOneAndRemove({ idapp, name });
|
||||
};
|
||||
|
||||
CircuitSchema.statics.getUserCircuits = async function (idapp, username) {
|
||||
|
||||
try {
|
||||
let aggr1 = [
|
||||
{
|
||||
$match: {
|
||||
idapp, username,
|
||||
$or: [
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'circuits',
|
||||
localField: 'circuitId',
|
||||
foreignField: '_id',
|
||||
as: 'circuit',
|
||||
},
|
||||
},
|
||||
{
|
||||
'$replaceRoot': {
|
||||
'newRoot': {
|
||||
'$mergeObjects': [
|
||||
{
|
||||
'$arrayElemAt': [
|
||||
'$circuit',
|
||||
0,
|
||||
],
|
||||
},
|
||||
'$$ROOT',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
/*
|
||||
{
|
||||
$project: {
|
||||
"circuit.name": 1,
|
||||
},
|
||||
},
|
||||
|
||||
*/
|
||||
];
|
||||
|
||||
ris = await this.aggregate(aggr1);
|
||||
|
||||
return ris;
|
||||
} catch (e) {
|
||||
console.error('e', e);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CircuitSchema.statics.getUsersSingleCircuit = async function (idapp, username, circuitname, circuitId) {
|
||||
|
||||
@@ -550,7 +595,8 @@ CircuitSchema.statics.getUsersSingleCircuit = async function (idapp, username, c
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
profile: 1, idapp: 1 /*, 'circuit.name': 1, 'circuit._id': 1*/
|
||||
profile: 1,
|
||||
idapp: 1 /*, 'circuit.name': 1, 'circuit._id': 1*/
|
||||
},
|
||||
|
||||
},
|
||||
@@ -602,6 +648,8 @@ CircuitSchema.statics.getCircolanteSingolaTransaz = function (accountorigTable,
|
||||
|
||||
CircuitSchema.statics.sendCoins = async function (onlycheck, idapp, usernameOrig, extrarec) {
|
||||
|
||||
const { User } = require('../models/user');
|
||||
|
||||
let ris = {
|
||||
result: false,
|
||||
cansend: true,
|
||||
@@ -620,26 +668,51 @@ CircuitSchema.statics.sendCoins = async function (onlycheck, idapp, usernameOrig
|
||||
if (circuittable) {
|
||||
const myqty = Math.abs(extrarec.qty);
|
||||
|
||||
const accountdestTable = await Account.getAccountByUsernameAndCircuitId(idapp, extrarec.dest, circuittable._id, true);
|
||||
const accountorigTable = await Account.getAccountByUsernameAndCircuitId(idapp, usernameOrig, circuittable._id, true);
|
||||
const esisteDest = await Account.isExistAccountByUsernameAndCircuitId(idapp, extrarec.dest, circuittable._id, extrarec.groupdest, extrarec.contoComDest);
|
||||
|
||||
|
||||
if (!esisteDest) {
|
||||
// Fallo entrare anche sul Circuito (oltre ad aver creato l'Account).
|
||||
await User.addCircuitToUser(idapp, usernameOrig, extrarec.circuitname, false, extrarec.groupdest, extrarec.contoComDest);
|
||||
}
|
||||
if (extrarec.dest) {
|
||||
const foundIfAlreadyCircuit = await User.ifAlreadyInCircuit(idapp, extrarec.dest, extrarec.circuitname);
|
||||
if (!foundIfAlreadyCircuit) {
|
||||
update = {
|
||||
$push: {
|
||||
'profile.mycircuits': {
|
||||
circuitname: extrarec.circuitname,
|
||||
date: new Date(),
|
||||
},
|
||||
},
|
||||
};
|
||||
const ris = await User.updateOne({ idapp, username: extrarec.dest }, update);
|
||||
}
|
||||
}
|
||||
|
||||
const accountdestTable = await Account.getAccountByUsernameAndCircuitId(idapp, extrarec.dest, circuittable._id, true, false, extrarec.groupdest, extrarec.contoComDest);
|
||||
const accountorigTable = await Account.getAccountByUsernameAndCircuitId(idapp, usernameOrig, circuittable._id, true, true, extrarec.grouporig, extrarec.contoComOrig);
|
||||
|
||||
|
||||
const circolantePrec = this.getCircolanteSingolaTransaz(accountorigTable, accountdestTable);
|
||||
|
||||
// Check if Sender has enough money
|
||||
if (accountorigTable.saldo - myqty < -accountorigTable.fidoConcesso) {
|
||||
ris.cansend = false;
|
||||
ris.errormsg = i18n.__('CIRCUIT_AMOUNT_EXCEED_FIDO', usernameOrig);
|
||||
}
|
||||
if (!circuittable.ignoreLimits) {
|
||||
// Check if Sender has enough money
|
||||
if (accountorigTable.saldo - myqty < -accountorigTable.fidoConcesso) {
|
||||
ris.cansend = false;
|
||||
ris.errormsg = i18n.__('CIRCUIT_AMOUNT_EXCEED_FIDO', usernameOrig);
|
||||
}
|
||||
|
||||
if (accountdestTable.saldo + myqty > accountorigTable.qta_maxConcessa) {
|
||||
ris.cansend = false;
|
||||
ris.errormsg = i18n.__('CIRCUIT_AMOUNT_EXCEED_QTAMAX', extrarec.dest);
|
||||
if (accountdestTable.saldo + myqty > accountdestTable.qta_maxConcessa) {
|
||||
ris.cansend = false;
|
||||
ris.errormsg = i18n.__('CIRCUIT_AMOUNT_EXCEED_QTAMAX', extrarec.dest);
|
||||
}
|
||||
}
|
||||
|
||||
if (!onlycheck) {
|
||||
// Add a Transaction !
|
||||
if (ris.cansend) {
|
||||
ris.rec = await Movement.addMov(idapp, accountorigTable, accountdestTable, myqty, extrarec.causal, extrarec.notifId);
|
||||
ris.rec = await Movement.addMov(idapp, accountorigTable, accountdestTable, myqty, extrarec.causal, extrarec.notifId, extrarec.idOrdersCart);
|
||||
}
|
||||
|
||||
if (ris.cansend && ris.rec) {
|
||||
@@ -657,16 +730,31 @@ CircuitSchema.statics.sendCoins = async function (onlycheck, idapp, usernameOrig
|
||||
};
|
||||
await Circuit.updateOne({ _id: circuittable }, { $set: paramstoupdate });
|
||||
|
||||
ris.result = true;
|
||||
console.log('Inviate Monete da', usernameOrig, extrarec.dest, myqty, extrarec.causal);
|
||||
|
||||
ris.useraccounts = await Account.getUserAccounts(idapp, usernameOrig);
|
||||
|
||||
extrarec.saldoOrig = accountorigTable.saldo;
|
||||
extrarec.saldoDest = accountdestTable.saldo;
|
||||
|
||||
let orig = usernameOrig;
|
||||
if (extrarec.grouporig) {
|
||||
orig = extrarec.grouporig + ' (' + usernameOrig + ')'
|
||||
}
|
||||
if (extrarec.contoComOrig) {
|
||||
orig = extrarec.contoComOrig + ' (' + usernameOrig + ')'
|
||||
}
|
||||
let dest = (extrarec.dest ? extrarec.dest : '') + (extrarec.groupdest ? extrarec.groupdest : '') + (extrarec.contoComDest ? extrarec.contoComDest : '');
|
||||
|
||||
ris.result = true;
|
||||
let msg = '[<b>' + circuittable.name + '</b>]: Inviate Monete da ' + orig + ' a ' + dest + ' ' + myqty + ' ' + circuittable.symbol + ' [causale: ' + extrarec.causal +
|
||||
`]\nSaldi:\n${orig}: ` + extrarec.saldoOrig + ' ' + circuittable.symbol + '] ' + `\n${dest}: ` + extrarec.saldoDest + ' ' + circuittable.symbol + ']';
|
||||
console.log(msg);
|
||||
|
||||
ris.useraccounts = await Account.getUserAccounts(idapp, usernameOrig);
|
||||
|
||||
tools.writeTransactionLog(msg);
|
||||
|
||||
tools.sendMsgTelegramToAdmin(idapp, msg);
|
||||
|
||||
} else {
|
||||
console.log('NON Inviate Monete da', usernameOrig, extrarec.dest, myqty, extrarec.causal);
|
||||
// console.log('NON Inviate Monete da', usernameOrig, extrarec.grouporig, extrarec.dest, extrarec.groupdest, myqty, extrarec.causal);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -688,6 +776,13 @@ CircuitSchema.statics.removeReqCircuit = async function (idapp, username, name)
|
||||
{ $pull: { req_users: { username: { $in: [username] } } } });
|
||||
};
|
||||
|
||||
// Rimuovo la Richiesta del Gruppo sul Circuito
|
||||
CircuitSchema.statics.removeReqGroupCircuit = async function (idapp, groupname, name) {
|
||||
|
||||
return await Circuit.updateOne({ idapp, name },
|
||||
{ $pull: { req_groups: { groupname: { $in: [groupname] } } } });
|
||||
};
|
||||
|
||||
// Aggiungi agli utenti Rifiutati del Circuito
|
||||
|
||||
CircuitSchema.statics.refuseReqCircuit = async function (idapp, username, name) {
|
||||
@@ -705,6 +800,21 @@ CircuitSchema.statics.refuseReqCircuit = async function (idapp, username, name)
|
||||
|
||||
};
|
||||
|
||||
CircuitSchema.statics.refuseReqGroupCircuit = async function (idapp, groupname, name) {
|
||||
|
||||
return await Circuit.updateOne({ idapp, name },
|
||||
{
|
||||
$push:
|
||||
{
|
||||
refused_groups: {
|
||||
groupname,
|
||||
date: new Date(),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
CircuitSchema.statics.updateData = async function (idapp, circuitname) {
|
||||
|
||||
try {
|
||||
@@ -725,7 +835,13 @@ CircuitSchema.statics.updateData = async function (idapp, circuitname) {
|
||||
|
||||
const ris = await User.aggregate(aggr1);
|
||||
|
||||
let numMembers = ris ? ris[0].count : 0;
|
||||
let numMembers = 0;
|
||||
try {
|
||||
numMembers = ris && tools.isArray(ris) ? ris[0].count : 0;
|
||||
} catch (e) {
|
||||
|
||||
};
|
||||
|
||||
|
||||
let paramstoupdate = {
|
||||
numMembers: numMembers,
|
||||
@@ -747,6 +863,398 @@ CircuitSchema.statics.setDeperimentoOff = async function () {
|
||||
|
||||
};
|
||||
|
||||
CircuitSchema.statics.getNameByCircuitId = async function (circuitId) {
|
||||
|
||||
let circuit = await Circuit.findOne({ _id: circuitId });
|
||||
if (circuit)
|
||||
return circuit.name;
|
||||
|
||||
return '';
|
||||
|
||||
};
|
||||
|
||||
CircuitSchema.statics.getCircuitByCircuitId = async function (circuitId) {
|
||||
|
||||
return await Circuit.findOne({ _id: circuitId });
|
||||
|
||||
};
|
||||
|
||||
CircuitSchema.statics.getListAdminsByCircuitPath = async function (idapp, circuitPath) {
|
||||
|
||||
let arr = await Circuit.findOne({
|
||||
idapp,
|
||||
path: circuitPath,
|
||||
$or: [
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}, { admins: 1 }).lean();
|
||||
|
||||
return arr && arr.admins ? arr.admins : [];
|
||||
|
||||
};
|
||||
|
||||
|
||||
// Imposta a tutti i Conti Collettivi, i seguenti minimi e massimi
|
||||
CircuitSchema.statics.setstrProvByIdCityCircuits = async function (idapp) {
|
||||
const { City } = require('../models/city');
|
||||
|
||||
const arrcircuits = await Circuit.find({ idapp }).lean();
|
||||
try {
|
||||
for (const rec of arrcircuits) {
|
||||
let recstrProv = await City.findOne({ _id: rec.idCity[0] });
|
||||
if (recstrProv) {
|
||||
let objProv = {}
|
||||
objProv['strProv'] = recstrProv.prov;
|
||||
await Circuit.updateOne({ _id: rec._id }, { $set: objProv });
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
CircuitSchema.statics.AbilitaTuttiCircuiti = async function (idapp) {
|
||||
|
||||
const ris = await Circuit.updateMany({ idapp },
|
||||
{
|
||||
$set:
|
||||
{
|
||||
transactionsEnabled: true
|
||||
}
|
||||
});
|
||||
|
||||
return ris;
|
||||
};
|
||||
|
||||
CircuitSchema.statics.AzzeraRegolamentiTuttiCircuiti = async function (idapp) {
|
||||
|
||||
const ris = await Circuit.updateMany({ idapp },
|
||||
{
|
||||
$set:
|
||||
{
|
||||
regulation: '',
|
||||
}
|
||||
});
|
||||
|
||||
return ris;
|
||||
};
|
||||
|
||||
// Imposta a tutti i Conti Personali, i seguenti minimi e massimi
|
||||
CircuitSchema.statics.SetDefMinMaxPersonali = async function (idapp, valmin, valmax, circuitId) {
|
||||
|
||||
if (circuitId) {
|
||||
const ris = await Circuit.updateOne({ _id: circuitId },
|
||||
{
|
||||
$set:
|
||||
{
|
||||
fido_scoperto_default: valmin,
|
||||
qta_max_default: valmax,
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
||||
const ris = await Circuit.updateMany({ idapp },
|
||||
{
|
||||
$set:
|
||||
{
|
||||
fido_scoperto_default: valmin,
|
||||
qta_max_default: valmax,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Imposta a tutti i Conti Collettivi, i seguenti minimi e massimi
|
||||
CircuitSchema.statics.getCircuitMyProvince = async function (idapp, username) {
|
||||
const { User } = require('../models/user');
|
||||
|
||||
const myuser = await User.getUserByUsername(idapp, username);
|
||||
|
||||
try {
|
||||
const circuit = await this.getCircuitByProvinceAndCard(idapp, myuser.profile.resid_province, myuser.profile.resid_card);
|
||||
|
||||
if (circuit) {
|
||||
if (await User.ifAlreadyInCircuit(idapp, username, circuit.name)) {
|
||||
return circuit.name;
|
||||
}
|
||||
}
|
||||
|
||||
return '[nessun Circuito]';
|
||||
|
||||
} catch (e) {
|
||||
console.error('Error', e);
|
||||
}
|
||||
};
|
||||
|
||||
// Imposta a tutti i Conti Collettivi, i seguenti minimi e massimi
|
||||
CircuitSchema.statics.createCircuitIfNotExist = async function (req, idapp, province, card) {
|
||||
const { User } = require('../models/user');
|
||||
|
||||
const useradmin = tools.USER_ADMIN_CIRCUITS;
|
||||
|
||||
let myrec = null;
|
||||
try {
|
||||
const circuit = await this.getCircuitByProvinceAndCard(idapp, province, card);
|
||||
|
||||
const nomeprovincia = await Province.getStrProvinceByProv(province);
|
||||
|
||||
if (!circuit && nomeprovincia) {
|
||||
const circ = new Circuit({
|
||||
idapp,
|
||||
name: 'Circuito RIS ' + nomeprovincia,
|
||||
path: 'ris' + tools.convertSpaces_ToUScore(nomeprovincia.toLowerCase()),
|
||||
strProv: province,
|
||||
card,
|
||||
photos: [],
|
||||
color: '#ff5500',
|
||||
deperimento: false,
|
||||
showAlways: false,
|
||||
transactionsEnabled: true, // Abilita cmq il circuito dall'inizio
|
||||
status: shared_consts.CIRCUIT_STATUS.FASE1_CREAZIONE_GRUPPO,
|
||||
symbol: 'RIS',
|
||||
fido_scoperto_default: 100,
|
||||
qta_max_default: 200,
|
||||
fido_scoperto_default_grp: shared_consts.CIRCUIT_PARAMS.SCOPERTO_MIN_GRP,
|
||||
qta_max_default_grp: shared_consts.CIRCUIT_PARAMS.SCOPERTO_MAX_GRP,
|
||||
valuta_per_euro: 1,
|
||||
totTransato: 0,
|
||||
totCircolante: 0,
|
||||
date_created: new Date(),
|
||||
admins: [{ username: useradmin }],
|
||||
});
|
||||
|
||||
myrec = await circ.save();
|
||||
|
||||
if (myrec) {
|
||||
|
||||
// nuovo Circuito:
|
||||
await User.setCircuitCmd(idapp, useradmin, myrec.name,
|
||||
shared_consts.CIRCUITCMD.CREATE, true, useradmin, myrec).then((ris) => {
|
||||
|
||||
});
|
||||
|
||||
// aggiungi il creatore al Circuito stesso
|
||||
await User.setCircuitCmd(idapp, useradmin, myrec.name,
|
||||
shared_consts.CIRCUITCMD.SET, true, useradmin, myrec).then((ris) => {
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
msg = 'Nuovo Circuito Creato in Automatico: ' + myrec.name + ' (da ' + req.user.username + ')';
|
||||
tools.sendMsgTelegramToAdmin(idapp, msg);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error', e);
|
||||
}
|
||||
|
||||
return myrec;
|
||||
|
||||
};
|
||||
|
||||
CircuitSchema.statics.getListAdmins = async function (idapp, circuitname) {
|
||||
|
||||
let arr = await Circuit.findOne({
|
||||
idapp,
|
||||
name: circuitname,
|
||||
$or: [
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}, { admins: 1 }).lean();
|
||||
|
||||
let mystr = '';
|
||||
|
||||
if (arr) {
|
||||
for (const admin of arr.admins) {
|
||||
mystr += await tools.getAhref(admin.username, await tools.getLinkUserTelegram(idapp, admin.username)) + ', ';
|
||||
}
|
||||
}
|
||||
|
||||
return { str: mystr, num: arr ? arr.admins.length : 0 };
|
||||
|
||||
};
|
||||
|
||||
CircuitSchema.statics.isAdminCircuit = async function (idapp, circuitname, username) {
|
||||
|
||||
let arr = await Circuit.findOne({
|
||||
idapp,
|
||||
name: circuitname,
|
||||
$or: [
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}, { admins: 1 }).lean();
|
||||
|
||||
if (arr) {
|
||||
for (const admin of arr.admins) {
|
||||
if (admin.username === username)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
};
|
||||
|
||||
CircuitSchema.statics.getListCircuitsByUsername = async function (idapp, username, groupname) {
|
||||
|
||||
let mystr = '';
|
||||
const { User } = require('../models/user');
|
||||
const myuser = await User.getUserByUsername(idapp, username);
|
||||
|
||||
const useraccounts = await Account.getUserAccounts(idapp, username);
|
||||
const groupsaccounts = await Account.getGroupAccounts(idapp, groupname);
|
||||
|
||||
|
||||
|
||||
for (let account of useraccounts) {
|
||||
if (myuser.profile.mycircuits.find((rec) => (rec.circuitname === account.circuit.name))) {
|
||||
if (account.groupname === '') {
|
||||
mystr += '\n👉🏻 ' + account.circuit.name + '\n';
|
||||
mystr += ' [Saldo: ' + account.saldo + ' RIS, ';
|
||||
mystr += ' Fiducia: ' + account.fidoConcesso + ' RIS, ';
|
||||
mystr += ' Transato: ' + account.totTransato + ' RIS]';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (let account of groupsaccounts) {
|
||||
if (myuser.profile.mycircuits.find((rec) => (rec.circuitname === account.circuit.name))) {
|
||||
mystr += '\n GRUPPO: 👉🏻 <b>' + account.groupname + '</b> in ' + account.circuit.name + '\n';
|
||||
mystr += ' [Saldo: ' + account.saldo + ' RIS, ';
|
||||
mystr += ' Fiducia: ' + account.fidoConcesso + ' RIS, ';
|
||||
mystr += ' Transato: ' + account.totTransato + ' RIS]';
|
||||
}
|
||||
}
|
||||
|
||||
if (!mystr) {
|
||||
mystr = '[Nessun Circuito]';
|
||||
}
|
||||
|
||||
return mystr;
|
||||
|
||||
};
|
||||
|
||||
CircuitSchema.statics.SetDefMinMaxCollettivi = async function (idapp, valmin, valmax, circuitId) {
|
||||
|
||||
if (circuitId) {
|
||||
const ris = await Circuit.updateOne({ _id: circuitId },
|
||||
{
|
||||
$set:
|
||||
{
|
||||
fido_scoperto_default_grp: valmin,
|
||||
qta_max_default_grp: valmax,
|
||||
}
|
||||
});
|
||||
} else {
|
||||
const ris = await Circuit.updateMany({ idapp },
|
||||
{
|
||||
$set:
|
||||
{
|
||||
fido_scoperto_default_grp: valmin,
|
||||
qta_max_default_grp: valmax,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
CircuitSchema.statics.setFido = async function (idapp, username, circuitName, groupname) {
|
||||
|
||||
try {
|
||||
mycircuit = await Circuit.findOne({ idapp, name: circuitName }).lean();
|
||||
if (mycircuit) {
|
||||
const circuitId = mycircuit._id;
|
||||
let account = null;
|
||||
let fido = 0;
|
||||
let qtamax = 0;
|
||||
let variato = false;
|
||||
let variato2 = false;
|
||||
|
||||
if (mycircuit.showAlways) {
|
||||
|
||||
const { User } = require('../models/user');
|
||||
|
||||
const myuser = await User.getUserByUsername(idapp, username);
|
||||
|
||||
// Se è il circuito Nazionale, allora prende i valori dal proprio Circuito Locale:
|
||||
const accountsuser = await Account.getUserAccounts(idapp, username);
|
||||
if (accountsuser) {
|
||||
// Se lo trovo della mia provincia, prendo quello
|
||||
account = accountsuser.find((account) => account.circuit.strProv === myuser.profile.resid_province && ((account.circuit.card === myuser.profile.resid_card) || !myuser.profile.resid_card))
|
||||
if (!account && accountsuser.length > 0) {
|
||||
// Se non lo trovo, prendo il primo in cui sono entrato !
|
||||
account = accountsuser[0];
|
||||
}
|
||||
if (account && account.circuit) {
|
||||
if (groupname) {
|
||||
qtamax = account.circuit.qta_max_default_grp * shared_consts.CIRCUIT_CFG.MULT_FIDO_GROUP;
|
||||
fido = account.circuit.fido_scoperto_default_grp * shared_consts.CIRCUIT_CFG.MULT_FIDO_GROUP;
|
||||
} else {
|
||||
qtamax = account.circuit.qta_max_default * shared_consts.CIRCUIT_CFG.MULT_FIDO_USER;
|
||||
fido = account.circuit.fido_scoperto_default * shared_consts.CIRCUIT_CFG.MULT_FIDO_USER;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Se non ho Circuiti locali, non applico il Fido !
|
||||
return null;
|
||||
}
|
||||
|
||||
} else {
|
||||
account = await Account.getAccountByUsernameAndCircuitId(idapp, username, circuitId, true, true, groupname, '');
|
||||
if (groupname)
|
||||
fido = mycircuit.fido_scoperto_default_grp;
|
||||
else
|
||||
fido = mycircuit.fido_scoperto_default;
|
||||
}
|
||||
|
||||
if (account) {
|
||||
if (qtamax > 0) {
|
||||
variato = await Account.updateQtaMax(idapp, username, groupname, circuitId, qtamax);
|
||||
}
|
||||
|
||||
const ris = await Account.updateFido(idapp, username, groupname, circuitId, fido);
|
||||
if (ris) {
|
||||
return { qta_maxConcessa: qtamax, fidoConcesso: fido, changed: variato || (ris && ris.nModified > 0) };
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Err:', e);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
CircuitSchema.statics.addMovementByOrdersCart = async function (ordersCart, usernameDest, groupDest) {
|
||||
|
||||
const { User } = require('../models/user');
|
||||
|
||||
const idapp = ordersCart.idapp;
|
||||
|
||||
let extrarec = {
|
||||
causal: 'Pagato Ordine n.' + ordersCart.numorder,
|
||||
circuitname: 'Euro',
|
||||
idOrdersCart: ordersCart._id,
|
||||
qty: ordersCart.totalPrice,
|
||||
dest: usernameDest,
|
||||
groupdest: groupDest,
|
||||
contoComDest: '',
|
||||
};
|
||||
|
||||
const usernameOrig = await User.getUsernameById(idapp, ordersCart.userId);
|
||||
|
||||
return this.sendCoins(false, idapp, usernameOrig, extrarec);
|
||||
|
||||
};
|
||||
|
||||
const Circuit = mongoose.model('Circuit', CircuitSchema);
|
||||
|
||||
Circuit.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = { Circuit };
|
||||
|
||||
@@ -77,6 +77,17 @@ CitySchema.statics.getProvinceByIdCity = async function(idcity) {
|
||||
return '';
|
||||
}
|
||||
|
||||
CitySchema.statics.getCircuitNameBystrProv = async function(strProv) {
|
||||
const { Circuit } = require('../models/circuit');
|
||||
|
||||
const myrec = await Circuit.findOne({strProv}).lean();
|
||||
if (myrec) {
|
||||
return myrec.name;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
CitySchema.statics.getRegionByIdCity = async function(idcity) {
|
||||
const myrec = await City.findOne({_id: idcity}).lean();
|
||||
if (myrec) {
|
||||
@@ -190,4 +201,8 @@ CitySchema.statics.findAllIdApp = async function(idapp) {
|
||||
|
||||
const City = mongoose.model('City', CitySchema);
|
||||
|
||||
City.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = {City};
|
||||
|
||||
@@ -52,4 +52,8 @@ ContribtypeSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
const Contribtype = mongoose.model('Contribtype', ContribtypeSchema);
|
||||
|
||||
Contribtype.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = { Contribtype };
|
||||
|
||||
@@ -26,6 +26,10 @@ const departmentSchema = new Schema({
|
||||
|
||||
var Department = module.exports = mongoose.model('Department', departmentSchema);
|
||||
|
||||
module.exports.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports.getFieldsForSearch = function () {
|
||||
return [{ field: 'name', type: tools.FieldType.string },
|
||||
{ field: 'username', type: tools.FieldType.string }
|
||||
|
||||
@@ -106,4 +106,8 @@ DisciplineSchema.statics.DuplicateAllRecords = async function (idapporig, idappd
|
||||
|
||||
const Discipline = mongoose.model('Discipline', DisciplineSchema);
|
||||
|
||||
Discipline.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = { Discipline };
|
||||
|
||||
@@ -114,7 +114,7 @@ ExtraListSchema.statics.getTotInLista = async function (idapp) {
|
||||
|
||||
const myfind = { idapp };
|
||||
|
||||
return await ExtraList.count(myfind);
|
||||
return await ExtraList.countDocuments(myfind);
|
||||
};
|
||||
|
||||
ExtraListSchema.statics.getRegDellaLista = async function (idapp) {
|
||||
@@ -122,7 +122,7 @@ ExtraListSchema.statics.getRegDellaLista = async function (idapp) {
|
||||
|
||||
const myfind = { idapp, registered: true };
|
||||
|
||||
return await ExtraList.count(myfind);
|
||||
return await ExtraList.countDocuments(myfind);
|
||||
};
|
||||
|
||||
ExtraListSchema.statics.getLastUser = function (idapp) {
|
||||
@@ -332,6 +332,9 @@ ExtraListSchema.statics.ImportData = async function (locale, idapp, strdata) {
|
||||
|
||||
const ExtraList = mongoose.model('ExtraList', ExtraListSchema);
|
||||
|
||||
ExtraList.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = { ExtraList };
|
||||
|
||||
|
||||
@@ -64,4 +64,8 @@ GallerySchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
const Gallery = mongoose.model('Gallery', GallerySchema);
|
||||
|
||||
Gallery.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = { Gallery };
|
||||
|
||||
80
src/server/models/gasordine.js
Executable file
80
src/server/models/gasordine.js
Executable file
@@ -0,0 +1,80 @@
|
||||
mongoose = require('mongoose').set('debug', false)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
mongoose.level = "F";
|
||||
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
schema.options.usePushEach = true
|
||||
});
|
||||
|
||||
const gasordineSchema = new Schema({
|
||||
active: {
|
||||
type: Boolean,
|
||||
},
|
||||
idapp: {
|
||||
type: String,
|
||||
},
|
||||
name: {
|
||||
type: String,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
},
|
||||
referente: {
|
||||
type: String,
|
||||
},
|
||||
city: {
|
||||
type: String,
|
||||
},
|
||||
img: {
|
||||
type: String,
|
||||
},
|
||||
|
||||
dataora_chiusura_ordini: {
|
||||
type: Date,
|
||||
},
|
||||
data_arrivo_merce: {
|
||||
type: Date,
|
||||
},
|
||||
dataora_ritiro: {
|
||||
type: Date,
|
||||
},
|
||||
dataora_termine_pagamento: {
|
||||
type: Date,
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
var Gasordine = module.exports = mongoose.model('Gasordine', gasordineSchema);
|
||||
|
||||
module.exports.getFieldsForSearch = function () {
|
||||
return [
|
||||
{field: 'name', type: tools.FieldType.string},
|
||||
{field: 'description', type: tools.FieldType.string},
|
||||
]
|
||||
};
|
||||
|
||||
module.exports.executeQueryTable = function (idapp, params) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
return tools.executeQueryTable(this, idapp, params);
|
||||
};
|
||||
|
||||
module.exports.findAllIdApp = async function (idapp) {
|
||||
const myfind = { idapp };
|
||||
|
||||
return await Gasordine.find(myfind);
|
||||
};
|
||||
|
||||
|
||||
module.exports.getGasordineByID = function (id, callback) {
|
||||
Gasordine.findById(id, callback);
|
||||
}
|
||||
|
||||
module.exports.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
@@ -80,4 +80,8 @@ GoodSchema.statics.executeQueryTable = function (idapp, params) {
|
||||
|
||||
const Good = mongoose.model('Good', GoodSchema);
|
||||
|
||||
Good.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = { Good };
|
||||
|
||||
@@ -138,7 +138,7 @@ GraduatoriaSchema.statics.findByAllRecByUsername = function (idapp, username) {
|
||||
GraduatoriaSchema.statics.getNumDaImbarcare = async function (idapp) {
|
||||
const Graduatoria = this;
|
||||
|
||||
return await Graduatoria.count({ idapp })
|
||||
return await Graduatoria. countDocuments({ idapp })
|
||||
|
||||
};
|
||||
|
||||
@@ -415,4 +415,8 @@ GraduatoriaSchema.statics.getPosizioneInGraduatoria = async function (idapp, ind
|
||||
|
||||
const Graduatoria = mongoose.model('Graduatoria', GraduatoriaSchema);
|
||||
|
||||
Graduatoria.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = { Graduatoria };
|
||||
|
||||
@@ -47,3 +47,6 @@ module.exports.findAllIdApp = async function (idapp) {
|
||||
return await Group.find(myfind);
|
||||
};
|
||||
|
||||
module.exports.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
@@ -228,3 +228,6 @@ module.exports.calculateHoursTodo = async function (idtodo) {
|
||||
|
||||
};
|
||||
|
||||
module.exports.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
59
src/server/models/inventariogm.js
Executable file
59
src/server/models/inventariogm.js
Executable file
@@ -0,0 +1,59 @@
|
||||
mongoose = require('mongoose').set('debug', false)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
mongoose.level = "F";
|
||||
|
||||
// A1P
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
schema.options.usePushEach = true
|
||||
});
|
||||
|
||||
const inventariogmSchema = new Schema({
|
||||
idapp: {
|
||||
type: String,
|
||||
},
|
||||
});
|
||||
|
||||
var Inventariogm = module.exports = mongoose.model('Inventariogm', inventariogmSchema);
|
||||
|
||||
inventariogmSchema.index({ idapp: 1 });
|
||||
|
||||
module.exports.getFieldsForSearch = function () {
|
||||
return [
|
||||
{ field: 'name', type: tools.FieldType.string },
|
||||
{ field: 'description', type: tools.FieldType.string },
|
||||
]
|
||||
};
|
||||
|
||||
module.exports.executeQueryTable = function (idapp, params) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
return tools.executeQueryTable(this, idapp, params);
|
||||
};
|
||||
|
||||
module.exports.getInventariogmByCode = function (idapp, code) {
|
||||
return Inventariogm.findAllIdApp(idapp, code);
|
||||
}
|
||||
|
||||
module.exports.getInventariogmById = async function (id) {
|
||||
const arrris = await Inventariogm.findAllIdApp('', '', id);
|
||||
return arrris && arrris.length > 0 ? arrris[0] : null
|
||||
}
|
||||
|
||||
module.exports.findAllIdApp = async function (idapp) {
|
||||
const Inventariogm = this;
|
||||
|
||||
const myfind = { idapp, deleted: false };
|
||||
|
||||
return await Inventariogm.find(myfind, (err, arrrec) => {
|
||||
return arrrec;
|
||||
});
|
||||
};
|
||||
@@ -196,3 +196,7 @@ module.exports.findAllIdApp = async function(idapp) {
|
||||
return arrrec;
|
||||
});
|
||||
};
|
||||
|
||||
module.exports.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
@@ -196,3 +196,7 @@ module.exports.findAllIdApp = async function (idapp) {
|
||||
return arrrec
|
||||
});
|
||||
};
|
||||
|
||||
module.exports.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
@@ -73,4 +73,8 @@ LevelSchema.statics.executeQueryTable = function(idapp, params) {
|
||||
|
||||
const Level = mongoose.model('Level', LevelSchema);
|
||||
|
||||
Level.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = {Level};
|
||||
|
||||
@@ -74,7 +74,7 @@ MailingListSchema.statics.getnumSent = async function (idapp, idmailinglist) {
|
||||
|
||||
// Extract only the Teacher where in the users table the field permissions is set 'Teacher' bit.
|
||||
|
||||
return await MailingList.count(myfind);
|
||||
return await MailingList.countDocuments(myfind);
|
||||
};
|
||||
|
||||
MailingListSchema.statics.isOk = async function (idapp, iduser, idmailinglist) {
|
||||
@@ -84,7 +84,7 @@ MailingListSchema.statics.isOk = async function (idapp, iduser, idmailinglist) {
|
||||
|
||||
// Extract only the Teacher where in the users table the field permissions is set 'Teacher' bit.
|
||||
|
||||
return await MailingList.count(myfind) > 0;
|
||||
return await MailingList.countDocuments(myfind) > 0;
|
||||
};
|
||||
|
||||
MailingListSchema.statics.findAllIdApp = async function (idapp) {
|
||||
@@ -121,4 +121,8 @@ MailingListSchema.statics.findByHash = function (idapp, hash) {
|
||||
|
||||
const MailingList = mongoose.model('MailingList', MailingListSchema);
|
||||
|
||||
MailingList.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = { MailingList };
|
||||
|
||||
@@ -6,8 +6,8 @@ mongoose.level = 'F';
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
const {ObjectID} = require('mongodb');
|
||||
const {Account} = require('../models/account');
|
||||
const { ObjectID } = require('mongodb');
|
||||
const { Account } = require('../models/account');
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
@@ -17,7 +17,7 @@ mongoose.plugin(schema => {
|
||||
const MovementSchema = new Schema({
|
||||
_id: {
|
||||
type: String,
|
||||
default: function() {
|
||||
default: function () {
|
||||
return new ObjectID().toString();
|
||||
},
|
||||
},
|
||||
@@ -36,6 +36,7 @@ const MovementSchema = new Schema({
|
||||
accountToId: {
|
||||
type: String,
|
||||
},
|
||||
idOrdersCart: { type: Schema.Types.ObjectId, ref: 'OrdersCart' },
|
||||
causal_table: {
|
||||
type: String,
|
||||
},
|
||||
@@ -47,26 +48,32 @@ const MovementSchema = new Schema({
|
||||
},
|
||||
causal: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
residual: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
expiringDate: {
|
||||
type: Date,
|
||||
},
|
||||
confirmed: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
});
|
||||
|
||||
MovementSchema.statics.findAllIdApp = async function(idapp) {
|
||||
MovementSchema.statics.findAllIdApp = async function (idapp) {
|
||||
const MyMovement = this;
|
||||
|
||||
const myfind = {idapp};
|
||||
const myfind = { idapp };
|
||||
|
||||
return await MyMovement.find(myfind, (err, arrrec) => {
|
||||
return arrrec;
|
||||
});
|
||||
};
|
||||
|
||||
MovementSchema.pre('save', async function(next) {
|
||||
MovementSchema.pre('save', async function (next) {
|
||||
if (this.isNew) {
|
||||
|
||||
this.transactionDate = new Date();
|
||||
@@ -75,45 +82,45 @@ MovementSchema.pre('save', async function(next) {
|
||||
next();
|
||||
});
|
||||
|
||||
MovementSchema.statics.getFieldsForSearch = function() {
|
||||
MovementSchema.statics.getFieldsForSearch = function () {
|
||||
return [
|
||||
{field: 'causal', type: tools.FieldType.string},
|
||||
{field: 'amount', type: tools.FieldType.number},
|
||||
{ field: 'causal', type: tools.FieldType.string },
|
||||
{ field: 'amount', type: tools.FieldType.number },
|
||||
];
|
||||
|
||||
};
|
||||
|
||||
MovementSchema.statics.executeQueryTable = function(idapp, params) {
|
||||
MovementSchema.statics.executeQueryTable = function (idapp, params) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
return tools.executeQueryTable(this, 0, params);
|
||||
};
|
||||
|
||||
MovementSchema.statics.addMov = async function(idapp, accountFromIdTable, accountToIdTable, amount, causal, notifId) {
|
||||
MovementSchema.statics.addMov = async function (idapp, accountFromIdTable, accountToIdTable, amount, causal, notifId, idOrdersCart) {
|
||||
|
||||
try {
|
||||
// Only positive values
|
||||
amount = Math.abs(amount);
|
||||
|
||||
let mymov = await Movement.create(
|
||||
{
|
||||
_id: new ObjectID().toString(),
|
||||
idapp,
|
||||
transactionDate: new Date(),
|
||||
accountFromId: accountFromIdTable._id,
|
||||
accountToId: accountToIdTable._id,
|
||||
amount,
|
||||
causal,
|
||||
residual: 0,
|
||||
notifId,
|
||||
// expiringDate:
|
||||
},
|
||||
{
|
||||
idapp,
|
||||
transactionDate: new Date(),
|
||||
accountFromId: accountFromIdTable._id,
|
||||
accountToId: accountToIdTable._id,
|
||||
idOrdersCart,
|
||||
amount,
|
||||
causal,
|
||||
residual: 0,
|
||||
notifId,
|
||||
// expiringDate:
|
||||
},
|
||||
);
|
||||
|
||||
if (mymov) {
|
||||
// Update saldo dell'Account
|
||||
await Account.addtoSaldo(accountToIdTable, amount);
|
||||
await Account.addtoSaldo(accountToIdTable, amount, true);
|
||||
|
||||
await Account.addtoSaldo(accountFromIdTable, -amount);
|
||||
await Account.addtoSaldo(accountFromIdTable, -amount, false);
|
||||
|
||||
return mymov;
|
||||
}
|
||||
@@ -122,13 +129,13 @@ MovementSchema.statics.addMov = async function(idapp, accountFromIdTable, accoun
|
||||
}
|
||||
};
|
||||
|
||||
MovementSchema.statics.getQueryMovsByCircuitId = async function(idapp, username, circuitId) {
|
||||
MovementSchema.statics.getQueryMovsByCircuitId = async function (idapp, username, groupname, contocom, circuitId) {
|
||||
|
||||
try {
|
||||
if (!circuitId) {
|
||||
return [];
|
||||
}
|
||||
const myaccount = await Account.getAccountByUsernameAndCircuitId(idapp, username, circuitId, false);
|
||||
const myaccount = await Account.getAccountByUsernameAndCircuitId(idapp, username, circuitId, false, true, groupname, contocom);
|
||||
|
||||
if (myaccount) {
|
||||
|
||||
@@ -137,8 +144,8 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function(idapp, username,
|
||||
$match: {
|
||||
idapp,
|
||||
$or: [
|
||||
{accountFromId: myaccount._id},
|
||||
{accountToId: myaccount._id}],
|
||||
{ accountFromId: myaccount._id },
|
||||
{ accountToId: myaccount._id }],
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -149,30 +156,92 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function(idapp, username,
|
||||
as: 'accfrom',
|
||||
},
|
||||
},
|
||||
{$unwind: '$accfrom'},
|
||||
{ $unwind: '$accfrom' },
|
||||
{
|
||||
$lookup: {
|
||||
from: 'users',
|
||||
let: {username: '$accfrom.username', idapp: '$accfrom.idapp'},
|
||||
let: { username: '$accfrom.username', idapp: '$accfrom.idapp' },
|
||||
pipeline: [
|
||||
{
|
||||
$match:
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{$eq: ['$$username', '$username']},
|
||||
{$eq: ['$$idapp', '$idapp']},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{ $eq: ['$$username', '$username'] },
|
||||
{ $eq: ['$$idapp', '$idapp'] },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: 'userfrom',
|
||||
},
|
||||
},
|
||||
{$unwind: '$userfrom'},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$userfrom',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'mygroups',
|
||||
let: { groupname: '$accfrom.groupname', idapp: '$accfrom.idapp' },
|
||||
pipeline: [
|
||||
{
|
||||
$match:
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{ $eq: ['$$groupname', '$groupname'] },
|
||||
{ $eq: ['$$idapp', '$idapp'] },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: 'groupfrom',
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$groupfrom',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
$lookup: {
|
||||
from: 'circuits',
|
||||
let: { contocom: '$accfrom.contocom', idapp: '$accfrom.idapp' },
|
||||
pipeline: [
|
||||
{
|
||||
$match:
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{ $eq: ['$$contocom', '$path'] },
|
||||
{ $eq: ['$$idapp', '$idapp'] },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: 'contocomfrom',
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$contocomfrom',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'accounts',
|
||||
@@ -181,66 +250,137 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function(idapp, username,
|
||||
as: 'accto',
|
||||
},
|
||||
},
|
||||
{$unwind: '$accto'},
|
||||
{ $unwind: '$accto' },
|
||||
{
|
||||
'$lookup': {
|
||||
'from': 'circuits',
|
||||
'localField': 'accfrom.circuitId',
|
||||
'foreignField': '_id',
|
||||
'as': 'circuitfrom',
|
||||
$lookup: {
|
||||
from: 'circuits',
|
||||
localField: 'accfrom.circuitId',
|
||||
foreignField: '_id',
|
||||
as: 'circuitfrom',
|
||||
},
|
||||
},
|
||||
{
|
||||
'$unwind': '$circuitfrom',
|
||||
$unwind: '$circuitfrom',
|
||||
},
|
||||
{
|
||||
'$lookup': {
|
||||
'from': 'circuits',
|
||||
'localField': 'accto.circuitId',
|
||||
'foreignField': '_id',
|
||||
'as': 'circuitto',
|
||||
$lookup: {
|
||||
from: 'circuits',
|
||||
localField: 'accto.circuitId',
|
||||
foreignField: '_id',
|
||||
as: 'circuitto',
|
||||
},
|
||||
},
|
||||
{
|
||||
'$unwind': '$circuitto',
|
||||
$unwind: '$circuitto',
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'users',
|
||||
let: {username: '$accto.username', idapp: '$accto.idapp'},
|
||||
let: { username: '$accto.username', idapp: '$accto.idapp' },
|
||||
pipeline: [
|
||||
{
|
||||
$match:
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{$eq: ['$$username', '$username']},
|
||||
{$eq: ['$$idapp', '$idapp']},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{ $eq: ['$$username', '$username'] },
|
||||
{ $eq: ['$$idapp', '$idapp'] },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: 'userto',
|
||||
},
|
||||
},
|
||||
{$unwind: '$userto'},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$userto',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'mygroups',
|
||||
let: { groupname: '$accto.groupname', idapp: '$accto.idapp' },
|
||||
pipeline: [
|
||||
{
|
||||
$match:
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{ $eq: ['$$groupname', '$groupname'] },
|
||||
{ $eq: ['$$idapp', '$idapp'] },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: 'groupto',
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$groupto',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'circuits',
|
||||
let: { contocom: '$accto.contocom', idapp: '$accto.idapp' },
|
||||
pipeline: [
|
||||
{
|
||||
$match:
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{ $eq: ['$$contocom', '$path'] },
|
||||
{ $eq: ['$$idapp', '$idapp'] },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: 'contocomto',
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$contocomto',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$project:
|
||||
{
|
||||
transactionDate: 1,
|
||||
amount: 1,
|
||||
causal: 1,
|
||||
notifId: 1,
|
||||
'circuitfrom.symbol': 1,
|
||||
'circuitto.symbol': 1,
|
||||
'userfrom.username': 1,
|
||||
'userfrom.profile.img': 1,
|
||||
'userto.username': 1,
|
||||
'userto.profile.img': 1,
|
||||
},
|
||||
{
|
||||
transactionDate: 1,
|
||||
amount: 1,
|
||||
causal: 1,
|
||||
notifId: 1,
|
||||
'circuitfrom.symbol': 1,
|
||||
'circuitto.symbol': 1,
|
||||
'userfrom.username': 1,
|
||||
'userfrom.profile.img': 1,
|
||||
'userto.username': 1,
|
||||
'userto.profile.img': 1,
|
||||
'groupfrom.groupname': 1,
|
||||
'groupfrom.title': 1,
|
||||
'groupfrom.photos': 1,
|
||||
'groupto.groupname': 1,
|
||||
'groupto.title': 1,
|
||||
'groupto.photos': 1,
|
||||
'contocomfrom.path': 1,
|
||||
'contocomfrom.name': 1,
|
||||
'contocomto.path': 1,
|
||||
'contocomto.name': 1,
|
||||
},
|
||||
},
|
||||
|
||||
];
|
||||
@@ -255,7 +395,8 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function(idapp, username,
|
||||
return [];
|
||||
};
|
||||
|
||||
MovementSchema.statics.getQueryAllUsersMovsByCircuitId = async function(idapp, circuitId) {
|
||||
|
||||
MovementSchema.statics.getQueryAllUsersMovsByCircuitId = async function (idapp, circuitId) {
|
||||
|
||||
try {
|
||||
if (!circuitId) {
|
||||
@@ -275,24 +416,24 @@ MovementSchema.statics.getQueryAllUsersMovsByCircuitId = async function(idapp, c
|
||||
as: 'accfrom',
|
||||
},
|
||||
},
|
||||
{$unwind: '$accfrom'},
|
||||
{ $unwind: '$accfrom' },
|
||||
{
|
||||
$lookup: {
|
||||
from: 'users',
|
||||
let: {username: '$accfrom.username', idapp: '$accfrom.idapp'},
|
||||
let: { username: '$accfrom.username', idapp: '$accfrom.idapp' },
|
||||
pipeline: [
|
||||
{
|
||||
$match:
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{$eq: ['$$username', '$username']},
|
||||
{$eq: ['$$idapp', '$idapp']},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{ $eq: ['$$username', '$username'] },
|
||||
{ $eq: ['$$idapp', '$idapp'] },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: 'userfrom',
|
||||
@@ -304,6 +445,62 @@ MovementSchema.statics.getQueryAllUsersMovsByCircuitId = async function(idapp, c
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'mygroups',
|
||||
let: { groupname: '$accfrom.groupname', idapp: '$accfrom.idapp' },
|
||||
pipeline: [
|
||||
{
|
||||
$match:
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{ $eq: ['$$groupname', '$groupname'] },
|
||||
{ $eq: ['$$idapp', '$idapp'] },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: 'groupfrom',
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$groupfrom',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'circuits',
|
||||
let: { contocom: '$accfrom.contocom', idapp: '$accfrom.idapp' },
|
||||
pipeline: [
|
||||
{
|
||||
$match:
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{ $eq: ['$$contocom', '$path'] },
|
||||
{ $eq: ['$$idapp', '$idapp'] },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: 'contocomfrom',
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$contocomfrom',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'accounts',
|
||||
@@ -319,7 +516,7 @@ MovementSchema.statics.getQueryAllUsersMovsByCircuitId = async function(idapp, c
|
||||
},
|
||||
},
|
||||
{
|
||||
$match: {'accto.circuitId': circuitId},
|
||||
$match: { 'accto.circuitId': circuitId },
|
||||
},
|
||||
{
|
||||
'$lookup': {
|
||||
@@ -352,20 +549,20 @@ MovementSchema.statics.getQueryAllUsersMovsByCircuitId = async function(idapp, c
|
||||
{
|
||||
$lookup: {
|
||||
from: 'users',
|
||||
let: {username: '$accto.username', idapp: '$accto.idapp'},
|
||||
let: { username: '$accto.username', idapp: '$accto.idapp' },
|
||||
pipeline: [
|
||||
{
|
||||
$match:
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{$eq: ['$$username', '$username']},
|
||||
{$eq: ['$$idapp', '$idapp']},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{ $eq: ['$$username', '$username'] },
|
||||
{ $eq: ['$$idapp', '$idapp'] },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: 'userto',
|
||||
@@ -378,19 +575,85 @@ MovementSchema.statics.getQueryAllUsersMovsByCircuitId = async function(idapp, c
|
||||
},
|
||||
},
|
||||
{
|
||||
$project:
|
||||
$lookup: {
|
||||
from: 'mygroups',
|
||||
let: { groupname: '$accto.groupname', idapp: '$accto.idapp' },
|
||||
pipeline: [
|
||||
{
|
||||
transactionDate: 1,
|
||||
amount: 1,
|
||||
causal: 1,
|
||||
notifId: 1,
|
||||
'circuitfrom.symbol': 1,
|
||||
'circuitto.symbol': 1,
|
||||
'userfrom.username': 1,
|
||||
'userfrom.profile.img': 1,
|
||||
'userto.username': 1,
|
||||
'userto.profile.img': 1,
|
||||
$match:
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{ $eq: ['$$groupname', '$groupname'] },
|
||||
{ $eq: ['$$idapp', '$idapp'] },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: 'groupto',
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$groupto',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'circuits',
|
||||
let: { contocom: '$accto.contocom', idapp: '$accto.idapp' },
|
||||
pipeline: [
|
||||
{
|
||||
$match:
|
||||
{
|
||||
$expr:
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{ $eq: ['$$contocom', '$path'] },
|
||||
{ $eq: ['$$idapp', '$idapp'] },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: 'contocomto',
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$contocomto',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$project:
|
||||
{
|
||||
transactionDate: 1,
|
||||
amount: 1,
|
||||
causal: 1,
|
||||
notifId: 1,
|
||||
'circuitfrom.symbol': 1,
|
||||
'circuitto.symbol': 1,
|
||||
'userfrom.username': 1,
|
||||
'userfrom.profile.img': 1,
|
||||
'userto.username': 1,
|
||||
'userto.profile.img': 1,
|
||||
'groupfrom.groupname': 1,
|
||||
'groupfrom.title': 1,
|
||||
'groupto.groupname': 1,
|
||||
'groupto.title': 1,
|
||||
'contocomfrom.path': 1,
|
||||
'contocomfrom.name': 1,
|
||||
'contocomfrom.title': 1,
|
||||
'contocomto.path': 1,
|
||||
'contocomto.name': 1,
|
||||
'contocomto.title': 1,
|
||||
},
|
||||
},
|
||||
|
||||
];
|
||||
@@ -404,10 +667,10 @@ MovementSchema.statics.getQueryAllUsersMovsByCircuitId = async function(idapp, c
|
||||
return [];
|
||||
};
|
||||
|
||||
MovementSchema.statics.getMovsByCircuitId = async function(idapp, username, circuitId) {
|
||||
MovementSchema.statics.getMovsByCircuitId = async function (idapp, username, circuitId) {
|
||||
const MyMovement = this;
|
||||
|
||||
const myquery = await MyMovement.getQueryMovsByCircuitId(idapp, username, circuitId);
|
||||
const myquery = await MyMovement.getQueryMovsByCircuitId(idapp, username, '', '', circuitId);
|
||||
|
||||
if (myquery && myquery.length > 0) {
|
||||
ris = await MyMovement.aggregate(myquery);
|
||||
@@ -418,12 +681,11 @@ MovementSchema.statics.getMovsByCircuitId = async function(idapp, username, circ
|
||||
return [];
|
||||
};
|
||||
|
||||
MovementSchema.statics.checkIfCoinsAlreadySent = async function(notifId) {
|
||||
MovementSchema.statics.checkIfCoinsAlreadySent = async function (notifId) {
|
||||
const MyMovement = this;
|
||||
|
||||
try {
|
||||
const rec = await MyMovement.findOne({notifId}, {_id: 1});
|
||||
|
||||
const rec = await MyMovement.findOne({ notifId }, { _id: 1 });
|
||||
return !!rec;
|
||||
|
||||
} catch (e) {
|
||||
@@ -436,4 +698,8 @@ MovementSchema.statics.checkIfCoinsAlreadySent = async function(notifId) {
|
||||
|
||||
const Movement = mongoose.model('Movement', MovementSchema);
|
||||
|
||||
module.exports = {Movement};
|
||||
Movement.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = { Movement };
|
||||
|
||||
@@ -125,4 +125,8 @@ MsgTemplateSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
const MsgTemplate = mongoose.model('MsgTemplate', MsgTemplateSchema);
|
||||
|
||||
MsgTemplate.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = { MsgTemplate };
|
||||
|
||||
@@ -7,6 +7,11 @@ mongoose.level = 'F';
|
||||
const tools = require('../tools/general');
|
||||
|
||||
const { ObjectID } = require('mongodb');
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
|
||||
const { Reaction } = require('./reaction');
|
||||
|
||||
const tableModel = shared_consts.TABLES_MYBACHECAS;
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
@@ -14,92 +19,112 @@ mongoose.plugin(schema => {
|
||||
});
|
||||
|
||||
const MyBachecaSchema = new Schema({
|
||||
_id: {
|
||||
type: Number,
|
||||
},
|
||||
idapp: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
userId: { type: Schema.Types.ObjectId, ref: 'User' },
|
||||
idSector: {
|
||||
type: Number,
|
||||
},
|
||||
idSkill: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
idStatusSkill: [
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
idContribType: [
|
||||
{
|
||||
...{
|
||||
_id: {
|
||||
type: String,
|
||||
}],
|
||||
idCity: [
|
||||
{
|
||||
default: function () {
|
||||
return new ObjectID().toString();
|
||||
},
|
||||
},
|
||||
idapp: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
userId: { type: Schema.Types.ObjectId, ref: 'User' },
|
||||
groupname: { type: String },
|
||||
idSector: {
|
||||
type: Number,
|
||||
}],
|
||||
dateTimeStart: {
|
||||
type: Date,
|
||||
},
|
||||
dateTimeEnd: {
|
||||
type: Date,
|
||||
},
|
||||
numLevel: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
adType: {
|
||||
type: Number,
|
||||
},
|
||||
photos: [
|
||||
{
|
||||
imagefile: {
|
||||
},
|
||||
idSkill: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
idStatusSkill: [
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
idContribType: [
|
||||
{
|
||||
type: String,
|
||||
},
|
||||
alt: {
|
||||
type: String,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
},
|
||||
}],
|
||||
note: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
descr: {
|
||||
type: String,
|
||||
},
|
||||
//**ADDFIELD_MYBACHECAS
|
||||
website: {
|
||||
type: String,
|
||||
},
|
||||
date_created: {
|
||||
type: Date,
|
||||
default: Date.now,
|
||||
},
|
||||
date_updated: {
|
||||
type: Date,
|
||||
}],
|
||||
idCity: [
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
dateTimeStart: {
|
||||
type: Date,
|
||||
},
|
||||
dateTimeEnd: {
|
||||
type: Date,
|
||||
},
|
||||
organisedBy: {
|
||||
type: String
|
||||
},
|
||||
contact_phone: {
|
||||
type: String
|
||||
},
|
||||
contact_telegram: {
|
||||
type: String
|
||||
},
|
||||
address: {
|
||||
type: String,
|
||||
},
|
||||
min_partecip: {
|
||||
type: Number,
|
||||
},
|
||||
max_partecip: {
|
||||
type: Number,
|
||||
},
|
||||
link_maplocation: {
|
||||
type: String,
|
||||
},
|
||||
contribstr: {
|
||||
type: String,
|
||||
},
|
||||
numLevel: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
adType: {
|
||||
type: Number,
|
||||
},
|
||||
photos: [
|
||||
{
|
||||
imagefile: {
|
||||
type: String,
|
||||
},
|
||||
alt: {
|
||||
type: String,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
},
|
||||
}],
|
||||
note: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
descr: {
|
||||
type: String,
|
||||
},
|
||||
//**ADDFIELD_MYBACHECAS
|
||||
website: {
|
||||
type: String,
|
||||
},
|
||||
date_created: {
|
||||
type: Date,
|
||||
},
|
||||
date_updated: {
|
||||
type: Date,
|
||||
},
|
||||
},
|
||||
...Reaction.getFieldsForReactions()
|
||||
});
|
||||
|
||||
MyBachecaSchema.pre('save', async function (next) {
|
||||
if (this.isNew) {
|
||||
const myrec = await MyBacheca.findOne().limit(1).sort({ _id: -1 });
|
||||
if (!!myrec) {
|
||||
if (myrec._doc._id === 0)
|
||||
this._id = 1;
|
||||
else
|
||||
this._id = myrec._doc._id + 1;
|
||||
|
||||
} else {
|
||||
this._id = 1;
|
||||
}
|
||||
|
||||
this.date_created = new Date();
|
||||
if (!this.date_created)
|
||||
this.date_created = new Date();
|
||||
}
|
||||
|
||||
next();
|
||||
@@ -144,37 +169,7 @@ MyBachecaSchema.statics.executeQueryTable = function (idapp, params, user) {
|
||||
lk_FF: '_id',
|
||||
lk_as: 'user',
|
||||
af_objId_tab: 'myId',
|
||||
lk_proj: {
|
||||
idSkill: 1,
|
||||
idSubSkill: 1,
|
||||
MyBacheca: 1,
|
||||
idStatusSkill: 1,
|
||||
idContribType: 1,
|
||||
dateTimeStart: 1,
|
||||
dateTimeEnd: 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
numLevel: 1,
|
||||
adType: 1,
|
||||
photos: 1,
|
||||
note: 1,
|
||||
//**ADDFIELD_MYBACHECAS
|
||||
website: 1,
|
||||
descr: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
userId: 1,
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
date_report: 1,
|
||||
username_who_report: 1,
|
||||
},
|
||||
lk_proj: shared_consts.getProjectForAll({}, tableModel),
|
||||
},
|
||||
};
|
||||
|
||||
@@ -186,28 +181,24 @@ MyBachecaSchema.statics.executeQueryTable = function (idapp, params, user) {
|
||||
MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
|
||||
const MyBacheca = this;
|
||||
|
||||
const query = [
|
||||
|
||||
let myparsid = {
|
||||
'_id': id,
|
||||
idapp,
|
||||
};
|
||||
|
||||
let query = [
|
||||
{
|
||||
'$match': {
|
||||
'$and': [
|
||||
{
|
||||
'_id': parseInt(id),
|
||||
},
|
||||
],
|
||||
$match:
|
||||
myparsid,
|
||||
},
|
||||
{
|
||||
$sort: {
|
||||
desc: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
'$match': {
|
||||
'idapp': idapp,
|
||||
},
|
||||
},
|
||||
{
|
||||
'$sort': {
|
||||
'desc': 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
'$addFields': {
|
||||
$addFields: {
|
||||
'myId1': {
|
||||
'$toObjectId': '$userId',
|
||||
},
|
||||
@@ -237,39 +228,7 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
|
||||
},
|
||||
},
|
||||
{
|
||||
'$project': {
|
||||
'recSkill': 1,
|
||||
'sector': 1,
|
||||
'idSector': 1,
|
||||
'idSkill': 1,
|
||||
'idSubSkill': 1,
|
||||
'idStatusSkill': 1,
|
||||
'idContribType': 1,
|
||||
dateTimeStart: 1,
|
||||
dateTimeEnd: 1,
|
||||
'idCity': 1,
|
||||
pub_to_share: 1,
|
||||
'numLevel': 1,
|
||||
adType: 1,
|
||||
'photos': 1,
|
||||
'note': 1,
|
||||
website: 1,
|
||||
//**ADDFIELD_MYBACHECAS
|
||||
'descr': 1,
|
||||
'date_created': 1,
|
||||
'date_updated': 1,
|
||||
'userId': 1,
|
||||
'username': 1,
|
||||
'name': 1,
|
||||
'surname': 1,
|
||||
'comune': 1,
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
'$project': shared_consts.getProjectForAll({}, tableModel),
|
||||
},
|
||||
{
|
||||
'$lookup': {
|
||||
@@ -295,39 +254,7 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
|
||||
},
|
||||
},
|
||||
{
|
||||
'$project': {
|
||||
'recSkill': 1,
|
||||
'sector': 1,
|
||||
'idSector': 1,
|
||||
'idSkill': 1,
|
||||
'idSubSkill': 1,
|
||||
'idStatusSkill': 1,
|
||||
'idContribType': 1,
|
||||
dateTimeStart: 1,
|
||||
dateTimeEnd: 1,
|
||||
'idCity': 1,
|
||||
pub_to_share: 1,
|
||||
'numLevel': 1,
|
||||
adType: 1,
|
||||
'photos': 1,
|
||||
'note': 1,
|
||||
website: 1,
|
||||
//**ADDFIELD_MYBACHECAS
|
||||
'descr': 1,
|
||||
'date_created': 1,
|
||||
'date_updated': 1,
|
||||
'userId': 1,
|
||||
'username': 1,
|
||||
'name': 1,
|
||||
'surname': 1,
|
||||
'comune': 1,
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
'$project': shared_consts.getProjectForAll({}, tableModel),
|
||||
},
|
||||
{
|
||||
'$lookup': {
|
||||
@@ -353,40 +280,22 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
|
||||
},
|
||||
},
|
||||
{
|
||||
'$project': {
|
||||
'recSkill': 1,
|
||||
'sector': 1,
|
||||
'idSector': 1,
|
||||
'idSkill': 1,
|
||||
'idSubSkill': 1,
|
||||
'idStatusSkill': 1,
|
||||
'idContribType': 1,
|
||||
dateTimeStart: 1,
|
||||
dateTimeEnd: 1,
|
||||
'idCity': 1,
|
||||
pub_to_share: 1,
|
||||
'numLevel': 1,
|
||||
adType: 1,
|
||||
'photos': 1,
|
||||
'note': 1,
|
||||
website: 1,
|
||||
//**ADDFIELD_MYBACHECAS
|
||||
'descr': 1,
|
||||
'date_created': 1,
|
||||
'date_updated': 1,
|
||||
'userId': 1,
|
||||
'username': 1,
|
||||
'name': 1,
|
||||
'surname': 1,
|
||||
'comune': 1,
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
$lookup: {
|
||||
'from': 'mygroups',
|
||||
'localField': 'groupname',
|
||||
'foreignField': 'groupname',
|
||||
'as': 'mygrp',
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$mygrp',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
'$project': shared_consts.getProjectForAll({}, tableModel),
|
||||
},
|
||||
/*{
|
||||
'$lookup': {
|
||||
'from': 'subskills',
|
||||
@@ -411,39 +320,7 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
|
||||
},
|
||||
},
|
||||
{
|
||||
'$project': {
|
||||
'recSkill': 1,
|
||||
'sector': 1,
|
||||
'idSector': 1,
|
||||
'idSkill': 1,
|
||||
// 'idSubSkill': 1,
|
||||
'idStatusSkill': 1,
|
||||
'idContribType': 1,
|
||||
dateTimeStart: 1,
|
||||
dateTimeEnd: 1,
|
||||
'idCity': 1,
|
||||
pub_to_share: 1,
|
||||
'numLevel': 1,
|
||||
adType: 1,
|
||||
'photos': 1,
|
||||
'note': 1,
|
||||
website: 1,
|
||||
//**ADDFIELD_MYBACHECAS
|
||||
'descr': 1,
|
||||
'date_created': 1,
|
||||
'date_updated': 1,
|
||||
'userId': 1,
|
||||
'username': 1,
|
||||
'name': 1,
|
||||
'surname': 1,
|
||||
'comune': 1,
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
'$project': shared_consts.getProjectForAll({}, tableModel),
|
||||
},
|
||||
{
|
||||
'$lookup': {
|
||||
@@ -468,48 +345,29 @@ MyBachecaSchema.statics.getMyRecById = function (idapp, id) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
'$project': {
|
||||
'recSkill': 1,
|
||||
'sector': 1,
|
||||
'idSector': 1,
|
||||
'idSkill': 1,
|
||||
// 'idSubSkill': 1,
|
||||
'idStatusSkill': 1,
|
||||
'idContribType': 1,
|
||||
dateTimeStart: 1,
|
||||
dateTimeEnd: 1,
|
||||
'idCity': 1,
|
||||
pub_to_share: 1,
|
||||
'numLevel': 1,
|
||||
adType: 1,
|
||||
'photos': 1,
|
||||
'note': 1,
|
||||
website: 1,
|
||||
//**ADDFIELD_MYBACHECAS
|
||||
'descr': 1,
|
||||
'date_created': 1,
|
||||
'date_updated': 1,
|
||||
'userId': 1,
|
||||
'username': 1,
|
||||
'name': 1,
|
||||
'surname': 1,
|
||||
'comune': 1,
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
try {
|
||||
let numtab = tools.getNumTabByTable(shared_consts.TABLES_MYBACHECAS);
|
||||
|
||||
let objadd = tools.addNumFavoriteAndBookmarkToQuery(idapp, numtab);
|
||||
query = [...query, ...objadd.query];
|
||||
|
||||
const toadd = {
|
||||
$project: shared_consts.getProjectForAll(objadd.proj, tableModel),
|
||||
};
|
||||
|
||||
query = [...query, { ...toadd }];
|
||||
} catch (e) {
|
||||
console.error('e', e);
|
||||
}
|
||||
|
||||
return MyBacheca.aggregate(query).then((rec) => {
|
||||
return rec ? rec[0] : null;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
MyBachecaSchema.statics.getCompleteRecord = function (idapp, id) {
|
||||
const MyBacheca = this;
|
||||
|
||||
@@ -520,4 +378,8 @@ MyBachecaSchema.statics.getCompleteRecord = function (idapp, id) {
|
||||
|
||||
const MyBacheca = mongoose.model('MyBacheca', MyBachecaSchema);
|
||||
|
||||
MyBacheca.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = { MyBacheca };
|
||||
|
||||
@@ -143,6 +143,7 @@ const MyElemSchema = new Schema({
|
||||
anim: animation,
|
||||
active: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
class: {
|
||||
type: String,
|
||||
@@ -209,4 +210,8 @@ MyElemSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
const MyElem = mongoose.model('MyElem', MyElemSchema);
|
||||
|
||||
MyElem.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = { MyElem };
|
||||
|
||||
@@ -276,4 +276,8 @@ if (tools.INITDB_FIRSTIME) {
|
||||
|
||||
const MyEvent = mongoose.model('MyEvent', MyEventSchema);
|
||||
|
||||
MyEvent.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = {MyEvent};
|
||||
|
||||
@@ -6,7 +6,11 @@ mongoose.level = 'F';
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
const {ObjectID} = require('mongodb');
|
||||
const { Reaction } = require('./reaction');
|
||||
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
@@ -14,104 +18,96 @@ mongoose.plugin(schema => {
|
||||
});
|
||||
|
||||
const MyGoodSchema = new Schema({
|
||||
_id: {
|
||||
type: Number,
|
||||
},
|
||||
idapp: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
userId: {type: Schema.Types.ObjectId, ref: 'User'},
|
||||
idSectorGood: {
|
||||
type: Number,
|
||||
},
|
||||
idGood: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
idShipping: [
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
|
||||
idContribType: [
|
||||
{
|
||||
...{
|
||||
_id: {
|
||||
type: String,
|
||||
}],
|
||||
idCity: [
|
||||
{
|
||||
},
|
||||
idapp: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
userId: { type: Schema.Types.ObjectId, ref: 'User' },
|
||||
idSectorGood: {
|
||||
type: Number,
|
||||
},
|
||||
idGood: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
idShipping: [
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
|
||||
idContribType: [
|
||||
{
|
||||
type: String,
|
||||
}],
|
||||
idCity: [
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
pub_to_share: {
|
||||
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW
|
||||
},
|
||||
numLevel: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
adType: {
|
||||
type: Number,
|
||||
},
|
||||
otherfilters: [{
|
||||
type: Number,
|
||||
}],
|
||||
pub_to_share: {
|
||||
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW
|
||||
},
|
||||
numLevel: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
adType: {
|
||||
type: Number,
|
||||
},
|
||||
otherfilters: [{
|
||||
type: Number,
|
||||
}],
|
||||
photos: [
|
||||
{
|
||||
imagefile: {
|
||||
type: String,
|
||||
},
|
||||
alt: {
|
||||
type: String,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
},
|
||||
}],
|
||||
note: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
descr: {
|
||||
type: String,
|
||||
},
|
||||
//**ADDFIELD_MyGood
|
||||
website: {
|
||||
type: String,
|
||||
},
|
||||
date_created: {
|
||||
type: Date,
|
||||
default: Date.now,
|
||||
},
|
||||
date_updated: {
|
||||
type: Date,
|
||||
photos: [
|
||||
{
|
||||
imagefile: {
|
||||
type: String,
|
||||
},
|
||||
alt: {
|
||||
type: String,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
},
|
||||
}],
|
||||
note: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
descr: {
|
||||
type: String,
|
||||
},
|
||||
//**ADDFIELD_MyGood
|
||||
website: {
|
||||
type: String,
|
||||
},
|
||||
date_created: {
|
||||
type: Date,
|
||||
},
|
||||
date_updated: {
|
||||
type: Date,
|
||||
},
|
||||
},
|
||||
...Reaction.getFieldsForReactions()
|
||||
});
|
||||
|
||||
MyGoodSchema.pre('save', async function(next) {
|
||||
MyGoodSchema.pre('save', async function (next) {
|
||||
if (this.isNew) {
|
||||
const myrec = await MyGood.findOne().limit(1).sort({_id: -1});
|
||||
if (!!myrec) {
|
||||
if (myrec._doc._id === 0)
|
||||
this._id = 1;
|
||||
else
|
||||
this._id = myrec._doc._id + 1;
|
||||
|
||||
} else {
|
||||
this._id = 1;
|
||||
}
|
||||
|
||||
this.date_created = new Date();
|
||||
if (!this.date_created)
|
||||
this.date_created = new Date();
|
||||
}
|
||||
|
||||
next();
|
||||
});
|
||||
|
||||
MyGoodSchema.statics.findAllIdApp = async function(idapp) {
|
||||
MyGoodSchema.statics.findAllIdApp = async function (idapp) {
|
||||
const MyGood = this;
|
||||
|
||||
const query = [
|
||||
{$match: {idapp}},
|
||||
{$sort: {descr: 1}},
|
||||
{ $match: { idapp } },
|
||||
{ $sort: { descr: 1 } },
|
||||
];
|
||||
|
||||
return await MyGood.aggregate(query).then((arrrec) => {
|
||||
@@ -120,21 +116,21 @@ MyGoodSchema.statics.findAllIdApp = async function(idapp) {
|
||||
|
||||
};
|
||||
|
||||
MyGoodSchema.statics.getFieldsForSearch = function() {
|
||||
MyGoodSchema.statics.getFieldsForSearch = function () {
|
||||
return [];
|
||||
};
|
||||
|
||||
MyGoodSchema.statics.getFieldsLastForSearch = function() {
|
||||
MyGoodSchema.statics.getFieldsLastForSearch = function () {
|
||||
return [
|
||||
{field: 'note', type: tools.FieldType.string},
|
||||
{field: 'descr', type: tools.FieldType.string},
|
||||
{field: 'recGood.descr', type: tools.FieldType.string},
|
||||
{field: 'MyGood.descr', type: tools.FieldType.string},
|
||||
{ field: 'note', type: tools.FieldType.string },
|
||||
{ field: 'descr', type: tools.FieldType.string },
|
||||
{ field: 'recGood.descr', type: tools.FieldType.string },
|
||||
{ field: 'MyGood.descr', type: tools.FieldType.string },
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
MyGoodSchema.statics.executeQueryTable = function(idapp, params, user) {
|
||||
MyGoodSchema.statics.executeQueryTable = function (idapp, params, user) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
params.fieldsearch_last = this.getFieldsLastForSearch();
|
||||
|
||||
@@ -145,60 +141,27 @@ MyGoodSchema.statics.executeQueryTable = function(idapp, params, user) {
|
||||
lk_FF: '_id',
|
||||
lk_as: 'user',
|
||||
af_objId_tab: 'myId',
|
||||
lk_proj: {
|
||||
idGood: 1,
|
||||
idShipping: 1,
|
||||
MyGood: 1,
|
||||
idStatusGood: 1,
|
||||
idContribType: 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
numLevel: 1,
|
||||
adType: 1,
|
||||
otherfilters: 1,
|
||||
photos: 1,
|
||||
note: 1,
|
||||
website: 1,
|
||||
//**ADDFIELD_MyGood
|
||||
descr: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
userId: 1,
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
lk_proj: this.getProject(),
|
||||
},
|
||||
};
|
||||
|
||||
params = {...params, ...otherparams};
|
||||
params = { ...params, ...otherparams };
|
||||
|
||||
return tools.executeQueryTable(this, idapp, params, user);
|
||||
};
|
||||
|
||||
MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
|
||||
MyGoodSchema.statics.getMyRecById = function (idapp, idGood) {
|
||||
const MyGood = this;
|
||||
|
||||
const query = [
|
||||
let myparsid = {
|
||||
'_id': idGood,
|
||||
idapp,
|
||||
};
|
||||
|
||||
let query = [
|
||||
{
|
||||
'$match': {
|
||||
'$and': [
|
||||
{
|
||||
'_id': parseInt(idGood),
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
'$match': {
|
||||
'idapp': idapp,
|
||||
},
|
||||
'$match':
|
||||
myparsid,
|
||||
},
|
||||
{
|
||||
'$sort': {
|
||||
@@ -236,38 +199,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
|
||||
},
|
||||
},
|
||||
{
|
||||
'$project': {
|
||||
'recGood': 1,
|
||||
'sectorGood': 1,
|
||||
'idSectorGood': 1,
|
||||
'idGood': 1,
|
||||
'idShipping': 1,
|
||||
'idStatusGood': 1,
|
||||
'idContribType': 1,
|
||||
'idCity': 1,
|
||||
pub_to_share: 1,
|
||||
'numLevel': 1,
|
||||
adType: 1,
|
||||
otherfilters: 1,
|
||||
'photos': 1,
|
||||
note: 1,
|
||||
website: 1,
|
||||
//**ADDFIELD_MyGood
|
||||
'descr': 1,
|
||||
'date_created': 1,
|
||||
'date_updated': 1,
|
||||
'userId': 1,
|
||||
'username': 1,
|
||||
'name': 1,
|
||||
'surname': 1,
|
||||
'comune': 1,
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
$project: this.getProject(),
|
||||
},
|
||||
{
|
||||
'$lookup': {
|
||||
@@ -293,38 +225,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
|
||||
},
|
||||
},
|
||||
{
|
||||
'$project': {
|
||||
'recGood': 1,
|
||||
'sectorGood': 1,
|
||||
'idSectorGood': 1,
|
||||
'idGood': 1,
|
||||
'idShipping': 1,
|
||||
'idStatusGood': 1,
|
||||
'idContribType': 1,
|
||||
'idCity': 1,
|
||||
pub_to_share: 1,
|
||||
'numLevel': 1,
|
||||
adType: 1,
|
||||
otherfilters: 1,
|
||||
'photos': 1,
|
||||
'note': 1,
|
||||
website: 1,
|
||||
//**ADDFIELD_MyGood
|
||||
'descr': 1,
|
||||
'date_created': 1,
|
||||
'date_updated': 1,
|
||||
'userId': 1,
|
||||
'username': 1,
|
||||
'name': 1,
|
||||
'surname': 1,
|
||||
'comune': 1,
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
$project: this.getProject(),
|
||||
},
|
||||
{
|
||||
'$lookup': {
|
||||
@@ -351,38 +252,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
|
||||
},
|
||||
},
|
||||
{
|
||||
'$project': {
|
||||
'recGood': 1,
|
||||
'sectorGood': 1,
|
||||
'idSectorGood': 1,
|
||||
'idGood': 1,
|
||||
'idShipping': 1,
|
||||
'idStatusGood': 1,
|
||||
'idContribType': 1,
|
||||
'idCity': 1,
|
||||
pub_to_share: 1,
|
||||
'numLevel': 1,
|
||||
adType: 1,
|
||||
otherfilters: 1,
|
||||
'photos': 1,
|
||||
'note': 1,
|
||||
website: 1,
|
||||
//**ADDFIELD_MyGood
|
||||
'descr': 1,
|
||||
'date_created': 1,
|
||||
'date_updated': 1,
|
||||
'userId': 1,
|
||||
'username': 1,
|
||||
'name': 1,
|
||||
'surname': 1,
|
||||
'comune': 1,
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
$project: this.getProject(),
|
||||
},
|
||||
{
|
||||
'$lookup': {
|
||||
@@ -408,38 +278,7 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
|
||||
},
|
||||
},
|
||||
{
|
||||
'$project': {
|
||||
'recGood': 1,
|
||||
'sectorGood': 1,
|
||||
'idSectorGood': 1,
|
||||
'idGood': 1,
|
||||
'idShipping': 1,
|
||||
'idStatusGood': 1,
|
||||
'idContribType': 1,
|
||||
'idCity': 1,
|
||||
pub_to_share: 1,
|
||||
'numLevel': 1,
|
||||
adType: 1,
|
||||
otherfilters: 1,
|
||||
'photos': 1,
|
||||
'note': 1,
|
||||
website: 1,
|
||||
//**ADDFIELD_MyGood
|
||||
'descr': 1,
|
||||
'date_created': 1,
|
||||
'date_updated': 1,
|
||||
'userId': 1,
|
||||
'username': 1,
|
||||
'name': 1,
|
||||
'surname': 1,
|
||||
'comune': 1,
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
$project: this.getProject(),
|
||||
},
|
||||
{
|
||||
'$lookup': {
|
||||
@@ -464,55 +303,53 @@ MyGoodSchema.statics.getMyRecById = function(idapp, idGood) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
'$project': {
|
||||
'recGood': 1,
|
||||
'sectorGood': 1,
|
||||
'idSectorGood': 1,
|
||||
'idGood': 1,
|
||||
'idShipping': 1,
|
||||
'idStatusGood': 1,
|
||||
'idContribType': 1,
|
||||
'idCity': 1,
|
||||
pub_to_share: 1,
|
||||
'numLevel': 1,
|
||||
adType: 1,
|
||||
otherfilters: 1,
|
||||
'photos': 1,
|
||||
'note': 1,
|
||||
website: 1,
|
||||
//**ADDFIELD_MyGood
|
||||
'descr': 1,
|
||||
'date_created': 1,
|
||||
'date_updated': 1,
|
||||
'userId': 1,
|
||||
'username': 1,
|
||||
'name': 1,
|
||||
'surname': 1,
|
||||
'comune': 1,
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
let numtab = tools.getNumTabByTable(shared_consts.TABLES_MYGOODS);
|
||||
|
||||
const objadd = tools.addNumFavoriteAndBookmarkToQuery(idapp, numtab);
|
||||
query = [...query, ...objadd.query];
|
||||
|
||||
const toadd = {
|
||||
$project: this.getProject(objadd.proj),
|
||||
};
|
||||
|
||||
query = [...query, { ...toadd }];
|
||||
|
||||
return MyGood.aggregate(query).then((rec) => {
|
||||
return rec ? rec[0] : null;
|
||||
});
|
||||
};
|
||||
|
||||
MyGoodSchema.statics.getCompleteRecord = function(idapp, id) {
|
||||
MyGoodSchema.statics.getCompleteRecord = function (idapp, id) {
|
||||
const MyGood = this;
|
||||
|
||||
return MyGood.getMyRecById(idapp, id);
|
||||
|
||||
};
|
||||
|
||||
MyGoodSchema.statics.getProject = function () {
|
||||
let proj = {
|
||||
'recGood': 1,
|
||||
'sectorGood': 1,
|
||||
'idSectorGood': 1,
|
||||
'idGood': 1,
|
||||
'idShipping': 1,
|
||||
'idStatusGood': 1,
|
||||
//**ADDFIELD_MYGOOD
|
||||
|
||||
};
|
||||
|
||||
const proj_add = shared_consts.getProjectForAll()
|
||||
|
||||
return Object.assign({}, proj, proj_add);
|
||||
|
||||
}
|
||||
|
||||
const MyGood = mongoose.model('MyGood', MyGoodSchema);
|
||||
|
||||
module.exports = {MyGood};
|
||||
MyGood.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = { MyGood };
|
||||
|
||||
@@ -15,7 +15,10 @@ mongoose.plugin(schema => {
|
||||
|
||||
const MyGroupSchema = new Schema({
|
||||
_id: {
|
||||
type: Number,
|
||||
type: String,
|
||||
default: function () {
|
||||
return new ObjectID().toString();
|
||||
},
|
||||
},
|
||||
idapp: {
|
||||
type: String,
|
||||
@@ -75,8 +78,9 @@ const MyGroupSchema = new Schema({
|
||||
},
|
||||
admins: [
|
||||
{
|
||||
username: {type: String},
|
||||
date: {type: Date},
|
||||
username: { type: String },
|
||||
perm: { type: Number },
|
||||
date: { type: Date },
|
||||
},
|
||||
],
|
||||
blocked: {
|
||||
@@ -97,34 +101,38 @@ const MyGroupSchema = new Schema({
|
||||
req_users: [
|
||||
{
|
||||
_id: false,
|
||||
username: {type: String},
|
||||
date: {type: Date},
|
||||
username: { type: String },
|
||||
date: { type: Date },
|
||||
}], // username
|
||||
refused_users: [
|
||||
{
|
||||
_id: false,
|
||||
username: {type: String},
|
||||
date: {type: Date},
|
||||
username: { type: String },
|
||||
date: { type: Date },
|
||||
}], // username
|
||||
deleted: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
circuits_list: [
|
||||
mycircuits: [
|
||||
{
|
||||
Num: { type: Number },
|
||||
inscription_date: {type: Date},
|
||||
_id: false,
|
||||
circuitname: { type: String },
|
||||
date: { type: Date },
|
||||
}],
|
||||
lastdate_reqRisGroup: {
|
||||
type: Date,
|
||||
},
|
||||
});
|
||||
|
||||
MyGroupSchema.statics.getFieldsForSearch = function() {
|
||||
return [{field: 'descr', type: tools.FieldType.string}];
|
||||
MyGroupSchema.statics.getFieldsForSearch = function () {
|
||||
return [{ field: 'descr', type: tools.FieldType.string }];
|
||||
};
|
||||
|
||||
MyGroupSchema.statics.executeQueryTable = function(idapp, params, user) {
|
||||
MyGroupSchema.statics.executeQueryTable = function (idapp, params, user) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
|
||||
const {User} = require('./user');
|
||||
const { User } = require('./user');
|
||||
|
||||
if (params.options) {
|
||||
if (tools.isBitActive(params.options, shared_consts.OPTIONS_SEARCH_USER_ONLY_FULL_WORDS)) {
|
||||
@@ -137,90 +145,94 @@ MyGroupSchema.statics.executeQueryTable = function(idapp, params, user) {
|
||||
return tools.executeQueryTable(this, idapp, params, user);
|
||||
};
|
||||
|
||||
MyGroupSchema.pre('save', async function(next) {
|
||||
MyGroupSchema.pre('save', async function (next) {
|
||||
if (this.isNew) {
|
||||
const myrec = await MyGroup.findOne().limit(1).sort({_id: -1});
|
||||
if (!!myrec) {
|
||||
if (myrec._doc._id === 0)
|
||||
this._id = 1;
|
||||
else
|
||||
this._id = myrec._doc._id + 1;
|
||||
|
||||
} else {
|
||||
this._id = 1;
|
||||
}
|
||||
|
||||
this.date_created = new Date();
|
||||
if (!this.date_created)
|
||||
this.date_created = new Date();
|
||||
}
|
||||
|
||||
next();
|
||||
});
|
||||
|
||||
MyGroupSchema.statics.findAllIdApp = async function(idapp) {
|
||||
const myfind = {idapp};
|
||||
MyGroupSchema.statics.findAllIdApp = async function (idapp) {
|
||||
const myfind = { idapp };
|
||||
|
||||
return await MyGroup.find(myfind);
|
||||
};
|
||||
|
||||
MyGroupSchema.statics.findAllGroups = async function(idapp) {
|
||||
MyGroupSchema.statics.findAllGroups = async function (idapp) {
|
||||
|
||||
const whatToShow = this.getWhatToShow(idapp, '');
|
||||
|
||||
return await MyGroup.find({
|
||||
idapp,
|
||||
$or: [
|
||||
{deleted: {$exists: false}},
|
||||
{deleted: {$exists: true, $eq: false}}],
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}, whatToShow);
|
||||
};
|
||||
|
||||
// Rimuovo la Richiesta del Gruppo
|
||||
MyGroupSchema.statics.removeReqGroup = async function(idapp, username, groupnameDest) {
|
||||
MyGroupSchema.statics.removeReqGroup = async function (idapp, username, groupnameDest) {
|
||||
|
||||
return await MyGroup.updateOne({idapp, groupname: groupnameDest},
|
||||
{$pull: {req_users: {username: {$in: [username]}}}});
|
||||
return await MyGroup.updateOne({ idapp, groupname: groupnameDest },
|
||||
{ $pull: { req_users: { username: { $in: [username] } } } });
|
||||
};
|
||||
|
||||
// Aggiungi agli utenti Rifiutati del Gruppo
|
||||
MyGroupSchema.statics.refuseReqGroup = async function(idapp, username, groupnameDest) {
|
||||
MyGroupSchema.statics.refuseReqGroup = async function (idapp, username, groupnameDest) {
|
||||
|
||||
return await MyGroup.updateOne({idapp, groupname: groupnameDest},
|
||||
return await MyGroup.updateOne({ idapp, groupname: groupnameDest },
|
||||
{
|
||||
$push:
|
||||
{
|
||||
$push:
|
||||
{
|
||||
refused_users: {
|
||||
username,
|
||||
date: new Date(),
|
||||
},
|
||||
},
|
||||
});
|
||||
refused_users: {
|
||||
username,
|
||||
date: new Date(),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
// Aggiungi agli Admin del Gruppo
|
||||
MyGroupSchema.statics.addToAdminOfMyGroup = async function(idapp, username, groupnameDest) {
|
||||
MyGroupSchema.statics.addToAdminOfMyGroup = async function (idapp, username, groupnameDest) {
|
||||
|
||||
return await MyGroup.updateOne({idapp, groupname: groupnameDest},
|
||||
return await MyGroup.updateOne({ idapp, groupname: groupnameDest },
|
||||
{
|
||||
$push:
|
||||
{
|
||||
$push:
|
||||
{
|
||||
admins: {
|
||||
username,
|
||||
date: new Date(),
|
||||
},
|
||||
},
|
||||
});
|
||||
admins: {
|
||||
username,
|
||||
date: new Date(),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
// Rimuovi dagli Admin del Gruppo
|
||||
MyGroupSchema.statics.removeAdminOfMyGroup = async function(idapp, username, groupnameDest) {
|
||||
MyGroupSchema.statics.removeAdminOfMyGroup = async function (idapp, username, groupnameDest) {
|
||||
|
||||
return await MyGroup.updateOne({idapp, groupname: groupnameDest},
|
||||
{$pull: {admins: {username: {$in: [username]}}}});
|
||||
return await MyGroup.updateOne({ idapp, groupname: groupnameDest },
|
||||
{ $pull: { admins: { username: { $in: [username] } } } });
|
||||
};
|
||||
|
||||
MyGroupSchema.statics.getWhatToShow = function(idapp, username) {
|
||||
MyGroupSchema.statics.getListAdminsByGroupName = async function (idapp, groupname) {
|
||||
|
||||
let arr = await MyGroup.findOne({
|
||||
idapp,
|
||||
groupname,
|
||||
$or: [
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}, { admins: 1 }).lean();
|
||||
|
||||
return arr && arr.admins ? arr.admins : [];
|
||||
|
||||
};
|
||||
|
||||
MyGroupSchema.statics.getWhatToShow = function (idapp, username) {
|
||||
// FOR ME, PERMIT ALL
|
||||
return {
|
||||
groupname: 1,
|
||||
@@ -242,12 +254,13 @@ MyGroupSchema.statics.getWhatToShow = function(idapp, username) {
|
||||
createdBy: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
circuits_list: 1,
|
||||
mycircuits: 1,
|
||||
lastdate_reqRisGroup: 1,
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
MyGroupSchema.statics.getWhatToShow_Unknown = function(idapp, username) {
|
||||
MyGroupSchema.statics.getWhatToShow_Unknown = function (idapp, username) {
|
||||
return {
|
||||
groupname: 1,
|
||||
title: 1,
|
||||
@@ -259,14 +272,15 @@ MyGroupSchema.statics.getWhatToShow_Unknown = function(idapp, username) {
|
||||
note: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
circuits_list: 1,
|
||||
mycircuits: 1,
|
||||
lastdate_reqRisGroup: 1,
|
||||
};
|
||||
};
|
||||
|
||||
MyGroupSchema.statics.getArrUsernameFromFieldByGroupname = async function(
|
||||
idapp, groupname, field) {
|
||||
MyGroupSchema.statics.getArrUsernameFromFieldByGroupname = async function (
|
||||
idapp, groupname, field) {
|
||||
|
||||
const {User} = require('../models/user');
|
||||
const { User } = require('../models/user');
|
||||
|
||||
const myobj = {};
|
||||
myobj[field + '.' + subfield] = 1;
|
||||
@@ -274,7 +288,7 @@ MyGroupSchema.statics.getArrUsernameFromFieldByGroupname = async function(
|
||||
let arrrec = await User.findOne({
|
||||
idapp,
|
||||
groupname,
|
||||
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
|
||||
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
|
||||
}, myobj).then((ris) => ris ? ris._doc[field] : []);
|
||||
|
||||
if (arrrec.length > 0) {
|
||||
@@ -284,7 +298,7 @@ MyGroupSchema.statics.getArrUsernameFromFieldByGroupname = async function(
|
||||
|
||||
};
|
||||
|
||||
MyGroupSchema.statics.getInfoGroupByGroupname = async function(idapp, groupname) {
|
||||
MyGroupSchema.statics.getInfoGroupByGroupname = async function (idapp, groupname) {
|
||||
|
||||
const whatToShow = this.getWhatToShow(idapp, groupname);
|
||||
|
||||
@@ -294,13 +308,13 @@ MyGroupSchema.statics.getInfoGroupByGroupname = async function(idapp, groupname)
|
||||
};
|
||||
|
||||
const query = [
|
||||
{$match: myfind},
|
||||
{ $unwind: '$circuits_list' },
|
||||
{ $match: myfind },
|
||||
{ $unwind: '$mycircuits' },
|
||||
{
|
||||
$lookup: {
|
||||
from: 'circuits',
|
||||
localField: 'circuits_list.Num',
|
||||
foreignField: 'Num',
|
||||
localField: 'mycircuits.circuitname',
|
||||
foreignField: 'name',
|
||||
as: 'mycircuits',
|
||||
},
|
||||
},
|
||||
@@ -319,7 +333,7 @@ MyGroupSchema.statics.getInfoGroupByGroupname = async function(idapp, groupname)
|
||||
},
|
||||
},
|
||||
},
|
||||
{$project: whatToShow},
|
||||
{ $project: whatToShow },
|
||||
|
||||
];
|
||||
|
||||
@@ -332,19 +346,19 @@ MyGroupSchema.statics.getInfoGroupByGroupname = async function(idapp, groupname)
|
||||
return null;
|
||||
}
|
||||
|
||||
return ris;
|
||||
return null;
|
||||
|
||||
};
|
||||
|
||||
MyGroupSchema.statics.deleteGroup = async function(idapp, usernameOrig, groupname) {
|
||||
MyGroupSchema.statics.deleteGroup = async function (idapp, usernameOrig, groupname) {
|
||||
console.log('Gruppo ' + groupname + ' rimosso da ' + usernameOrig);
|
||||
return await MyGroup.findOneAndRemove({idapp, groupname});
|
||||
return await MyGroup.findOneAndRemove({ idapp, groupname });
|
||||
};
|
||||
|
||||
MyGroupSchema.statics.getGroupsByUsername = async function(idapp, username, req) {
|
||||
MyGroupSchema.statics.getGroupsByUsername = async function (idapp, username, req) {
|
||||
|
||||
try {
|
||||
const {User} = require('../models/user');
|
||||
const { User } = require('../models/user');
|
||||
|
||||
const whatToShow = this.getWhatToShow(idapp, username);
|
||||
const whatToShow_Unknown = this.getWhatToShow_Unknown(idapp, username);
|
||||
@@ -353,17 +367,17 @@ MyGroupSchema.statics.getGroupsByUsername = async function(idapp, username, req)
|
||||
|
||||
let listUsersGroup = await User.find({
|
||||
idapp,
|
||||
username: {$in: arrUsernameGroups},
|
||||
username: { $in: arrUsernameGroups },
|
||||
$or: [
|
||||
{deleted: {$exists: false}},
|
||||
{deleted: {$exists: true, $eq: false}}],
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}, whatToShow);
|
||||
|
||||
let listgroups = await MyGroup.find({
|
||||
idapp,
|
||||
$or: [
|
||||
{deleted: {$exists: false}},
|
||||
{deleted: {$exists: true, $eq: false}}],
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}, whatToShow_Unknown);
|
||||
|
||||
/*let listRequestUsersGroup = await User.find({
|
||||
@@ -379,21 +393,21 @@ MyGroupSchema.statics.getGroupsByUsername = async function(idapp, username, req)
|
||||
let listSentRequestGroups = await MyGroup.find({
|
||||
idapp,
|
||||
'req_users': {
|
||||
$elemMatch: {username: {$eq: username}},
|
||||
$elemMatch: { username: { $eq: username } },
|
||||
},
|
||||
$or: [
|
||||
{deleted: {$exists: false}},
|
||||
{deleted: {$exists: true, $eq: false}}],
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}, whatToShow_Unknown);
|
||||
|
||||
let listRefusedGroups = await MyGroup.find({
|
||||
idapp,
|
||||
'refused_users': {
|
||||
$elemMatch: {username: {$eq: username}},
|
||||
$elemMatch: { username: { $eq: username } },
|
||||
},
|
||||
$or: [
|
||||
{deleted: {$exists: false}},
|
||||
{deleted: {$exists: true, $eq: false}}],
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}, whatToShow_Unknown);
|
||||
|
||||
return {
|
||||
@@ -418,12 +432,12 @@ MyGroupSchema.statics.getGroupsByUsername = async function(idapp, username, req)
|
||||
};
|
||||
};
|
||||
|
||||
MyGroupSchema.statics.extractCitiesName = async function(idapp, id) {
|
||||
MyGroupSchema.statics.extractCitiesName = async function (idapp, id) {
|
||||
|
||||
try {
|
||||
let aggr1 = [
|
||||
{
|
||||
$match: {idapp, _id: id},
|
||||
$match: { idapp, _id: id },
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
@@ -459,13 +473,178 @@ MyGroupSchema.statics.extractCitiesName = async function(idapp, id) {
|
||||
ris = await this.aggregate(aggr1);
|
||||
|
||||
return ris;
|
||||
}catch (e) {
|
||||
} catch (e) {
|
||||
console.error('e', e);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
MyGroupSchema.statics.ifCircuitAlreadyInGroup = async function (idapp, groupname, circuitname) {
|
||||
|
||||
// Controllo se è stato già inserito il circuito sul gruppo
|
||||
return await this.findOne({
|
||||
idapp,
|
||||
groupname,
|
||||
'mycircuits': {
|
||||
$elemMatch: { circuitname: { $eq: circuitname } },
|
||||
},
|
||||
}).lean();
|
||||
};
|
||||
|
||||
// aggiungo il Circuito all'interno del Gruppo
|
||||
MyGroupSchema.statics.addCircuitFromGroup = async function (idapp, groupname, circuitname) {
|
||||
return await this.updateOne({ idapp, groupname },
|
||||
{
|
||||
$push: {
|
||||
'mycircuits': {
|
||||
circuitname,
|
||||
date: new Date(),
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
// Rimuovo il Circuito all'interno del Gruppo
|
||||
MyGroupSchema.statics.removeCircuitFromGroup = async function (idapp, groupname, circuitname) {
|
||||
|
||||
|
||||
const ris = await this.updateOne({ idapp, groupname },
|
||||
{ $pull: { 'mycircuits': { circuitname: { $in: [circuitname] } } } });
|
||||
|
||||
const circuitId = await Circuit.getCircuitIdByName(idapp, circuitname);
|
||||
let remove = false;
|
||||
|
||||
// Se il mio account non è stato utilizzato, allora lo cancello anche questo
|
||||
const myaccount = await Account.getAccountByUsernameAndCircuitId(idapp, username, circuitId, false, false, groupname, '');
|
||||
if (myaccount && myaccount.totTransato === 0) {
|
||||
remove = true;
|
||||
} else {
|
||||
remove = true;
|
||||
}
|
||||
|
||||
if (remove) {
|
||||
await Account.removeAccount(myaccount._id);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
MyGroupSchema.statics.getQueryReceiveRISGroups = function (idapp, hours) {
|
||||
|
||||
const query = [
|
||||
{
|
||||
$match: {
|
||||
idapp,
|
||||
'lastdate_reqRisGroup': { $gte: tools.IncDateNow(-(1000 * 60 * 60 * hours)) },
|
||||
$or: [
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
},
|
||||
},
|
||||
{
|
||||
$group:
|
||||
{
|
||||
_id: "$groupname",
|
||||
count: {
|
||||
$sum: 1,
|
||||
},
|
||||
}
|
||||
},
|
||||
{ $sort: { 'lastdate_reqRisGroup': -1 } },
|
||||
{ $limit: 30 },
|
||||
{
|
||||
$lookup: {
|
||||
from: "mygroups",
|
||||
let: {
|
||||
groupname: "$_id",
|
||||
idapp,
|
||||
},
|
||||
pipeline: [
|
||||
{
|
||||
$match: {
|
||||
$expr: {
|
||||
$and: [
|
||||
{
|
||||
$eq: [
|
||||
"$$groupname",
|
||||
"$groupname",
|
||||
],
|
||||
},
|
||||
{
|
||||
$eq: [
|
||||
"$$idapp",
|
||||
"$idapp",
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: "mygroup",
|
||||
},
|
||||
},
|
||||
{ $unwind: "$mygroup" },
|
||||
{
|
||||
$replaceRoot: {
|
||||
newRoot: {
|
||||
$mergeObjects: ["$mygroup", "$$ROOT"],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
_id: 0,
|
||||
groupname: 1,
|
||||
title: 1,
|
||||
descr: 1,
|
||||
visibility: 1,
|
||||
idCatGrp: 1,
|
||||
userId: 1,
|
||||
photos: 1,
|
||||
idCity: 1,
|
||||
website: 1,
|
||||
link_telegram: 1,
|
||||
note: 1,
|
||||
admins: 1,
|
||||
blocked: 1,
|
||||
req_users: 1,
|
||||
createdBy: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
lastdate_reqRisGroup: 1,
|
||||
},
|
||||
},
|
||||
];
|
||||
return query;
|
||||
};
|
||||
|
||||
|
||||
MyGroupSchema.statics.getReceiveRISGroups = async function (idapp) {
|
||||
|
||||
return await this.aggregate(this.getQueryReceiveRISGroups(idapp, 8)).then(ris => {
|
||||
return ris;
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
MyGroupSchema.statics.setReceiveRisGroup = async function (idapp, groupname) {
|
||||
|
||||
return await this.findOneAndUpdate({
|
||||
idapp, groupname,
|
||||
},
|
||||
{ $set: { 'lastdate_reqRisGroup': new Date() } }, { new: false }).lean().then((record) => {
|
||||
return !!record;
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
const MyGroup = mongoose.model('MyGroup', MyGroupSchema);
|
||||
|
||||
module.exports = {MyGroup};
|
||||
MyGroup.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = { MyGroup };
|
||||
|
||||
@@ -6,7 +6,10 @@ mongoose.level = 'F';
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
const {ObjectID} = require('mongodb');
|
||||
const { Reaction } = require('./reaction');
|
||||
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
@@ -14,109 +17,101 @@ mongoose.plugin(schema => {
|
||||
});
|
||||
|
||||
const MyHospSchema = new Schema({
|
||||
_id: {
|
||||
type: Number,
|
||||
},
|
||||
idapp: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
userId: {type: Schema.Types.ObjectId, ref: 'User'},
|
||||
visibile: {
|
||||
type: Boolean
|
||||
},
|
||||
typeHosp: { // scambio casa / ospitalità
|
||||
type: Number,
|
||||
},
|
||||
numMaxPeopleHosp: {
|
||||
type: Number,
|
||||
},
|
||||
accomodation: [
|
||||
{
|
||||
type: { // Letto matrimoniale / letto singolo / divano-letto / almaca / a terra sul tappeto (per sacco a pelo) / culla
|
||||
type: Number,
|
||||
},
|
||||
location: { // in camera privata / in camera condivisa / in soggiorno / in camper / in tenda / in giardino / all'aperto
|
||||
type: Number,
|
||||
},
|
||||
num: {
|
||||
type: Number,
|
||||
},
|
||||
}],
|
||||
preferences: [ // Accetto bambini, Accetto cani, Accetto gatti, E' consentito fumare in casa, Accessibile con sedia a rotelle
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
photos: [
|
||||
{
|
||||
imagefile: {
|
||||
type: String,
|
||||
},
|
||||
alt: {
|
||||
type: String,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
},
|
||||
}],
|
||||
idContribType: [
|
||||
{
|
||||
...{
|
||||
_id: {
|
||||
type: String,
|
||||
}],
|
||||
idCity: [
|
||||
{
|
||||
},
|
||||
idapp: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
userId: { type: Schema.Types.ObjectId, ref: 'User' },
|
||||
visibile: {
|
||||
type: Boolean
|
||||
},
|
||||
typeHosp: { // scambio casa / ospitalità
|
||||
type: Number,
|
||||
}],
|
||||
pub_to_share: {
|
||||
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW
|
||||
},
|
||||
descr: {
|
||||
type: String,
|
||||
},
|
||||
note: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
website: {
|
||||
type: String,
|
||||
},
|
||||
link_maplocation: {
|
||||
type: String,
|
||||
},
|
||||
date_created: {
|
||||
type: Date,
|
||||
default: Date.now,
|
||||
},
|
||||
date_updated: {
|
||||
type: Date,
|
||||
},
|
||||
numMaxPeopleHosp: {
|
||||
type: Number,
|
||||
},
|
||||
accomodation: [
|
||||
{
|
||||
type: { // Letto matrimoniale / letto singolo / divano-letto / almaca / a terra sul tappeto (per sacco a pelo) / culla
|
||||
type: Number,
|
||||
},
|
||||
location: { // in camera privata / in camera condivisa / in soggiorno / in camper / in tenda / in giardino / all'aperto
|
||||
type: Number,
|
||||
},
|
||||
num: {
|
||||
type: Number,
|
||||
},
|
||||
}],
|
||||
preferences: [ // Accetto bambini, Accetto cani, Accetto gatti, E' consentito fumare in casa, Accessibile con sedia a rotelle
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
photos: [
|
||||
{
|
||||
imagefile: {
|
||||
type: String,
|
||||
},
|
||||
alt: {
|
||||
type: String,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
},
|
||||
}],
|
||||
idContribType: [
|
||||
{
|
||||
type: String,
|
||||
}],
|
||||
idCity: [
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
pub_to_share: {
|
||||
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW
|
||||
},
|
||||
descr: {
|
||||
type: String,
|
||||
},
|
||||
note: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
website: {
|
||||
type: String,
|
||||
},
|
||||
link_maplocation: {
|
||||
type: String,
|
||||
},
|
||||
date_created: {
|
||||
type: Date,
|
||||
},
|
||||
date_updated: {
|
||||
type: Date,
|
||||
},
|
||||
},
|
||||
...Reaction.getFieldsForReactions()
|
||||
});
|
||||
|
||||
MyHospSchema.pre('save', async function(next) {
|
||||
MyHospSchema.pre('save', async function (next) {
|
||||
if (this.isNew) {
|
||||
const myrec = await MyHosp.findOne().limit(1).sort({_id: -1});
|
||||
if (!!myrec) {
|
||||
if (myrec._doc._id === 0)
|
||||
this._id = 1;
|
||||
else
|
||||
this._id = myrec._doc._id + 1;
|
||||
|
||||
} else {
|
||||
this._id = 1;
|
||||
}
|
||||
|
||||
this.date_created = new Date();
|
||||
if (!this.date_created)
|
||||
this.date_created = new Date();
|
||||
}
|
||||
|
||||
next();
|
||||
});
|
||||
|
||||
MyHospSchema.statics.findAllIdApp = async function(idapp) {
|
||||
MyHospSchema.statics.findAllIdApp = async function (idapp) {
|
||||
const MyHosp = this;
|
||||
|
||||
const query = [
|
||||
{$match: {idapp}},
|
||||
{$sort: {descr: 1}},
|
||||
{ $match: { idapp } },
|
||||
{ $sort: { descr: 1 } },
|
||||
];
|
||||
|
||||
return await MyHosp.aggregate(query).then((arrrec) => {
|
||||
@@ -125,18 +120,18 @@ MyHospSchema.statics.findAllIdApp = async function(idapp) {
|
||||
|
||||
};
|
||||
|
||||
MyHospSchema.statics.getFieldsForSearch = function() {
|
||||
MyHospSchema.statics.getFieldsForSearch = function () {
|
||||
return [];
|
||||
};
|
||||
|
||||
MyHospSchema.statics.getFieldsLastForSearch = function() {
|
||||
MyHospSchema.statics.getFieldsLastForSearch = function () {
|
||||
return [
|
||||
{field: 'descr', type: tools.FieldType.string},
|
||||
{field: 'note', type: tools.FieldType.string},
|
||||
{ field: 'descr', type: tools.FieldType.string },
|
||||
{ field: 'note', type: tools.FieldType.string },
|
||||
];
|
||||
};
|
||||
|
||||
MyHospSchema.statics.executeQueryTable = function(idapp, params, user) {
|
||||
MyHospSchema.statics.executeQueryTable = function (idapp, params, user) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
params.fieldsearch_last = this.getFieldsLastForSearch();
|
||||
|
||||
@@ -147,59 +142,24 @@ MyHospSchema.statics.executeQueryTable = function(idapp, params, user) {
|
||||
lk_FF: '_id',
|
||||
lk_as: 'user',
|
||||
af_objId_tab: 'myId',
|
||||
lk_proj: {
|
||||
visibile: 1,
|
||||
typeHosp: 1,
|
||||
numMaxPeopleHosp: 1,
|
||||
accomodation: 1,
|
||||
preferences: 1,
|
||||
photos: 1,
|
||||
idContribType: 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
note: 1,
|
||||
website: 1,
|
||||
link_maplocation: 1,
|
||||
descr: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
userId: 1,
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
'mycities': 1,
|
||||
reported: 1,
|
||||
},
|
||||
lk_proj: this.getProject(),
|
||||
},
|
||||
};
|
||||
|
||||
params = {...params, ...otherparams};
|
||||
params = { ...params, ...otherparams };
|
||||
|
||||
return tools.executeQueryTable(this, idapp, params, user);
|
||||
};
|
||||
|
||||
MyHospSchema.statics.getMyRecById = function(idapp, id) {
|
||||
MyHospSchema.statics.getMyRecById = function (idapp, id) {
|
||||
const MyHosp = this;
|
||||
|
||||
const query = [
|
||||
const myparsid = { '_id': id, idapp };
|
||||
|
||||
let query = [
|
||||
{
|
||||
'$match': {
|
||||
'$and': [
|
||||
{
|
||||
'_id': parseInt(id),
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
'$match': {
|
||||
'idapp': idapp,
|
||||
},
|
||||
'$match':
|
||||
myparsid,
|
||||
},
|
||||
{
|
||||
'$sort': {
|
||||
@@ -237,34 +197,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
|
||||
},
|
||||
},
|
||||
{
|
||||
'$project': {
|
||||
visibile: 1,
|
||||
typeHosp: 1,
|
||||
numMaxPeopleHosp: 1,
|
||||
accomodation: 1,
|
||||
preferences: 1,
|
||||
photos: 1,
|
||||
idContribType: 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
note: 1,
|
||||
website: 1,
|
||||
link_maplocation: 1,
|
||||
descr: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
'userId': 1,
|
||||
'username': 1,
|
||||
'name': 1,
|
||||
'surname': 1,
|
||||
'comune': 1,
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
$project: this.getProject(),
|
||||
},
|
||||
{
|
||||
'$lookup': {
|
||||
@@ -290,34 +223,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
|
||||
},
|
||||
},
|
||||
{
|
||||
'$project': {
|
||||
visibile: 1,
|
||||
typeHosp: 1,
|
||||
numMaxPeopleHosp: 1,
|
||||
accomodation: 1,
|
||||
preferences: 1,
|
||||
photos: 1,
|
||||
idContribType: 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
note: 1,
|
||||
website: 1,
|
||||
link_maplocation: 1,
|
||||
descr: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
'userId': 1,
|
||||
'username': 1,
|
||||
'name': 1,
|
||||
'surname': 1,
|
||||
'comune': 1,
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
$project: this.getProject(),
|
||||
},
|
||||
{
|
||||
'$lookup': {
|
||||
@@ -343,34 +249,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
|
||||
},
|
||||
},
|
||||
{
|
||||
'$project': {
|
||||
visibile: 1,
|
||||
typeHosp: 1,
|
||||
numMaxPeopleHosp: 1,
|
||||
accomodation: 1,
|
||||
preferences: 1,
|
||||
photos: 1,
|
||||
idContribType: 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
note: 1,
|
||||
website: 1,
|
||||
link_maplocation: 1,
|
||||
descr: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
'userId': 1,
|
||||
'username': 1,
|
||||
'name': 1,
|
||||
'surname': 1,
|
||||
'comune': 1,
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
$project: this.getProject(),
|
||||
},
|
||||
/*{
|
||||
'$lookup': {
|
||||
@@ -396,34 +275,7 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
|
||||
},
|
||||
},
|
||||
{
|
||||
'$project': {
|
||||
visibile: 1,
|
||||
typeHosp: 1,
|
||||
numMaxPeopleHosp: 1,
|
||||
accomodation: 1,
|
||||
preferences: 1,
|
||||
photos: 1,
|
||||
idContribType: 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
note: 1,
|
||||
website: 1,
|
||||
link_maplocation: 1,
|
||||
descr: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
'userId': 1,
|
||||
'username': 1,
|
||||
'name': 1,
|
||||
'surname': 1,
|
||||
'comune': 1,
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
$project: this.getProject(),
|
||||
},
|
||||
{
|
||||
'$lookup': {
|
||||
@@ -448,50 +300,56 @@ MyHospSchema.statics.getMyRecById = function(idapp, id) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
'$project': {
|
||||
visibile: 1,
|
||||
typeHosp: 1,
|
||||
numMaxPeopleHosp: 1,
|
||||
accomodation: 1,
|
||||
preferences: 1,
|
||||
photos: 1,
|
||||
idContribType: 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
note: 1,
|
||||
website: 1,
|
||||
link_maplocation: 1,
|
||||
descr: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
'userId': 1,
|
||||
'username': 1,
|
||||
'name': 1,
|
||||
'surname': 1,
|
||||
'comune': 1,
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
let numtab = tools.getNumTabByTable(shared_consts.TABLES_MYHOSPS);
|
||||
|
||||
const objadd = tools.addNumFavoriteAndBookmarkToQuery(idapp, numtab);
|
||||
query = [...query, ...objadd.query];
|
||||
|
||||
const toadd = {
|
||||
$project: this.getProject(objadd.proj),
|
||||
};
|
||||
|
||||
query = [...query, { ...toadd }];
|
||||
|
||||
return MyHosp.aggregate(query).then((rec) => {
|
||||
return rec ? rec[0] : null;
|
||||
});
|
||||
};
|
||||
|
||||
MyHospSchema.statics.getCompleteRecord = function(idapp, id) {
|
||||
MyHospSchema.statics.getCompleteRecord = function (idapp, id) {
|
||||
const MyHosp = this;
|
||||
|
||||
return MyHosp.getMyRecById(idapp, id);
|
||||
|
||||
};
|
||||
|
||||
MyHospSchema.statics.getProject = function () {
|
||||
let proj = {
|
||||
visibile: 1,
|
||||
typeHosp: 1,
|
||||
numMaxPeopleHosp: 1,
|
||||
accomodation: 1,
|
||||
preferences: 1,
|
||||
photos: 1,
|
||||
website: 1,
|
||||
link_maplocation: 1,
|
||||
//**ADDFIELD_MYHOSP
|
||||
|
||||
};
|
||||
|
||||
const proj_add = shared_consts.getProjectForAll()
|
||||
|
||||
return Object.assign({}, proj, proj_add);
|
||||
|
||||
}
|
||||
|
||||
|
||||
const MyHosp = mongoose.model('MyHosp', MyHospSchema);
|
||||
|
||||
module.exports = {MyHosp};
|
||||
MyHosp.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = { MyHosp };
|
||||
|
||||
@@ -135,6 +135,7 @@ const MyPageSchema = new Schema({
|
||||
|
||||
MyPageSchema.statics.getFieldsForSearch = function () {
|
||||
return [{ field: 'title', type: tools.FieldType.string },
|
||||
{ field: 'path', type: tools.FieldType.string },
|
||||
{ field: 'keywords', type: tools.FieldType.string },
|
||||
{ field: 'description', type: tools.FieldType.string },
|
||||
{ field: 'content', type: tools.FieldType.string }]
|
||||
@@ -217,4 +218,8 @@ MyPageSchema.statics.findInternalPages = async function (idapp) {
|
||||
|
||||
const MyPage = mongoose.model('MyPage', MyPageSchema);
|
||||
|
||||
MyPage.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = { MyPage };
|
||||
|
||||
@@ -6,115 +6,118 @@ mongoose.level = 'F';
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
const {ObjectID} = require('mongodb');
|
||||
const { Reaction } = require('./reaction');
|
||||
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
schema.options.usePushEach = true;
|
||||
});
|
||||
|
||||
const MySkillSchema = new Schema({
|
||||
_id: {
|
||||
type: Number,
|
||||
},
|
||||
idapp: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
userId: {type: Schema.Types.ObjectId, ref: 'User'},
|
||||
idSector: {
|
||||
type: Number,
|
||||
},
|
||||
idSkill: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
/*idSubSkill: [
|
||||
{
|
||||
type: Number,
|
||||
default: 0,
|
||||
}],
|
||||
const MySkillSchema = new Schema(
|
||||
{
|
||||
...{
|
||||
_id: {
|
||||
type: String,
|
||||
default: function () {
|
||||
return new ObjectID().toString();
|
||||
},
|
||||
},
|
||||
idapp: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
userId: { type: Schema.Types.ObjectId, ref: 'User' },
|
||||
idSector: {
|
||||
type: Number,
|
||||
},
|
||||
idSkill: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
/*idSubSkill: [
|
||||
{
|
||||
type: Number,
|
||||
default: 0,
|
||||
}],
|
||||
|
||||
*/
|
||||
idStatusSkill: [
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
idContribType: [
|
||||
{
|
||||
type: String,
|
||||
}],
|
||||
idCity: [
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
pub_to_share: {
|
||||
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW
|
||||
},
|
||||
numLevel: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
adType: {
|
||||
type: Number,
|
||||
},
|
||||
photos: [
|
||||
{
|
||||
imagefile: {
|
||||
*/
|
||||
idStatusSkill: [
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
idContribType: [
|
||||
{
|
||||
type: String,
|
||||
}],
|
||||
idCity: [
|
||||
{
|
||||
type: Number,
|
||||
}],
|
||||
pub_to_share: {
|
||||
type: Number, // PUB_TO_SHARE_ALL, PUB_TO_SHARE_ONLY_TABLE_FOLLOW
|
||||
},
|
||||
numLevel: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
adType: {
|
||||
type: Number,
|
||||
},
|
||||
photos: [
|
||||
{
|
||||
imagefile: {
|
||||
type: String,
|
||||
},
|
||||
alt: {
|
||||
type: String,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
},
|
||||
}],
|
||||
note: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
descr: {
|
||||
type: String,
|
||||
},
|
||||
alt: {
|
||||
//**ADDFIELD_MYSKILL
|
||||
website: {
|
||||
type: String,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
date_created: {
|
||||
type: Date,
|
||||
},
|
||||
}],
|
||||
note: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
descr: {
|
||||
type: String,
|
||||
},
|
||||
//**ADDFIELD_MYSKILL
|
||||
website: {
|
||||
type: String,
|
||||
},
|
||||
date_created: {
|
||||
type: Date,
|
||||
default: Date.now,
|
||||
},
|
||||
date_updated: {
|
||||
type: Date,
|
||||
},
|
||||
});
|
||||
date_updated: {
|
||||
type: Date,
|
||||
},
|
||||
},
|
||||
...Reaction.getFieldsForReactions()
|
||||
}, { strict: false });
|
||||
|
||||
MySkillSchema.pre('save', async function(next) {
|
||||
MySkillSchema.index({ 'idapp': 1 });
|
||||
|
||||
|
||||
MySkillSchema.pre('save', async function (next) {
|
||||
if (this.isNew) {
|
||||
const myrec = await MySkill.findOne().limit(1).sort({_id: -1});
|
||||
if (!!myrec) {
|
||||
if (myrec._doc._id === 0)
|
||||
this._id = 1;
|
||||
else
|
||||
this._id = myrec._doc._id + 1;
|
||||
|
||||
} else {
|
||||
this._id = 1;
|
||||
}
|
||||
|
||||
this.date_created = new Date();
|
||||
if (!this.date_created)
|
||||
this.date_created = new Date();
|
||||
}
|
||||
|
||||
next();
|
||||
});
|
||||
|
||||
MySkillSchema.statics.findAllIdApp = async function(idapp) {
|
||||
MySkillSchema.statics.findAllIdApp = async function (idapp) {
|
||||
const MySkill = this;
|
||||
|
||||
const query = [
|
||||
{$match: {idapp}},
|
||||
{$sort: {descr: 1}},
|
||||
{ $match: { idapp } },
|
||||
{ $sort: { descr: 1 } },
|
||||
];
|
||||
|
||||
return await MySkill.aggregate(query).then((arrrec) => {
|
||||
@@ -123,20 +126,20 @@ MySkillSchema.statics.findAllIdApp = async function(idapp) {
|
||||
|
||||
};
|
||||
|
||||
MySkillSchema.statics.getFieldsForSearch = function() {
|
||||
MySkillSchema.statics.getFieldsForSearch = function () {
|
||||
return [];
|
||||
};
|
||||
|
||||
MySkillSchema.statics.getFieldsLastForSearch = function() {
|
||||
MySkillSchema.statics.getFieldsLastForSearch = function () {
|
||||
return [
|
||||
{field: 'note', type: tools.FieldType.string},
|
||||
{field: 'descr', type: tools.FieldType.string},
|
||||
{field: 'recSkill.descr', type: tools.FieldType.string},
|
||||
{field: 'myskill.descr', type: tools.FieldType.string},
|
||||
{ field: 'note', type: tools.FieldType.string },
|
||||
{ field: 'descr', type: tools.FieldType.string },
|
||||
{ field: 'recSkill.descr', type: tools.FieldType.string },
|
||||
{ field: 'myskill.descr', type: tools.FieldType.string },
|
||||
];
|
||||
};
|
||||
|
||||
MySkillSchema.statics.executeQueryTable = function(idapp, params, user) {
|
||||
MySkillSchema.statics.executeQueryTable = function (idapp, params, user) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
params.fieldsearch_last = this.getFieldsLastForSearch();
|
||||
|
||||
@@ -147,58 +150,22 @@ MySkillSchema.statics.executeQueryTable = function(idapp, params, user) {
|
||||
lk_FF: '_id',
|
||||
lk_as: 'user',
|
||||
af_objId_tab: 'myId',
|
||||
lk_proj: {
|
||||
idSkill: 1,
|
||||
// idSubSkill: 1,
|
||||
myskill: 1,
|
||||
idStatusSkill: 1,
|
||||
idContribType: 1,
|
||||
idCity: 1,
|
||||
pub_to_share: 1,
|
||||
numLevel: 1,
|
||||
adType: 1,
|
||||
photos: 1,
|
||||
note: 1,
|
||||
website: 1,
|
||||
//**ADDFIELD_MYSKILL
|
||||
descr: 1,
|
||||
date_created: 1,
|
||||
date_updated: 1,
|
||||
userId: 1,
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
lk_proj: this.getProject(),
|
||||
},
|
||||
};
|
||||
|
||||
params = {...params, ...otherparams};
|
||||
params = { ...params, ...otherparams };
|
||||
|
||||
return tools.executeQueryTable(this, idapp, params, user);
|
||||
};
|
||||
|
||||
MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
|
||||
MySkillSchema.statics.getMyRecById = function (idapp, idSkill) {
|
||||
const MySkill = this;
|
||||
|
||||
const query = [
|
||||
let query = [
|
||||
{
|
||||
'$match': {
|
||||
'$and': [
|
||||
{
|
||||
'_id': parseInt(idSkill),
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
'$match': {
|
||||
'idapp': idapp,
|
||||
'_id': idSkill, idapp
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -237,37 +204,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
|
||||
},
|
||||
},
|
||||
{
|
||||
'$project': {
|
||||
'recSkill': 1,
|
||||
'sector': 1,
|
||||
'idSector': 1,
|
||||
'idSkill': 1,
|
||||
// 'idSubSkill': 1,
|
||||
'idStatusSkill': 1,
|
||||
'idContribType': 1,
|
||||
'idCity': 1,
|
||||
pub_to_share: 1,
|
||||
'numLevel': 1,
|
||||
adType: 1,
|
||||
'photos': 1,
|
||||
note: 1,
|
||||
website: 1,
|
||||
//**ADDFIELD_MYSKILL
|
||||
'descr': 1,
|
||||
'date_created': 1,
|
||||
'date_updated': 1,
|
||||
'userId': 1,
|
||||
'username': 1,
|
||||
'name': 1,
|
||||
'surname': 1,
|
||||
'comune': 1,
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
$project: this.getProject(),
|
||||
},
|
||||
{
|
||||
'$lookup': {
|
||||
@@ -293,37 +230,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
|
||||
},
|
||||
},
|
||||
{
|
||||
'$project': {
|
||||
'recSkill': 1,
|
||||
'sector': 1,
|
||||
'idSector': 1,
|
||||
'idSkill': 1,
|
||||
// 'idSubSkill': 1,
|
||||
'idStatusSkill': 1,
|
||||
'idContribType': 1,
|
||||
'idCity': 1,
|
||||
pub_to_share: 1,
|
||||
'numLevel': 1,
|
||||
adType: 1,
|
||||
'photos': 1,
|
||||
'note': 1,
|
||||
website: 1,
|
||||
//**ADDFIELD_MYSKILL
|
||||
'descr': 1,
|
||||
'date_created': 1,
|
||||
'date_updated': 1,
|
||||
'userId': 1,
|
||||
'username': 1,
|
||||
'name': 1,
|
||||
'surname': 1,
|
||||
'comune': 1,
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
$project: this.getProject(),
|
||||
},
|
||||
{
|
||||
'$lookup': {
|
||||
@@ -349,37 +256,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
|
||||
},
|
||||
},
|
||||
{
|
||||
'$project': {
|
||||
'recSkill': 1,
|
||||
'sector': 1,
|
||||
'idSector': 1,
|
||||
'idSkill': 1,
|
||||
//'idSubSkill': 1,
|
||||
'idStatusSkill': 1,
|
||||
'idContribType': 1,
|
||||
'idCity': 1,
|
||||
pub_to_share: 1,
|
||||
'numLevel': 1,
|
||||
adType: 1,
|
||||
'photos': 1,
|
||||
'note': 1,
|
||||
website: 1,
|
||||
//**ADDFIELD_MYSKILL
|
||||
'descr': 1,
|
||||
'date_created': 1,
|
||||
'date_updated': 1,
|
||||
'userId': 1,
|
||||
'username': 1,
|
||||
'name': 1,
|
||||
'surname': 1,
|
||||
'comune': 1,
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
$project: this.getProject(),
|
||||
},
|
||||
/*{
|
||||
'$lookup': {
|
||||
@@ -407,37 +284,7 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
|
||||
},
|
||||
},
|
||||
{
|
||||
'$project': {
|
||||
'recSkill': 1,
|
||||
'sector': 1,
|
||||
'idSector': 1,
|
||||
'idSkill': 1,
|
||||
// 'idSubSkill': 1,
|
||||
'idStatusSkill': 1,
|
||||
'idContribType': 1,
|
||||
'idCity': 1,
|
||||
pub_to_share: 1,
|
||||
'numLevel': 1,
|
||||
adType: 1,
|
||||
'photos': 1,
|
||||
'note': 1,
|
||||
website: 1,
|
||||
//**ADDFIELD_MYSKILL
|
||||
'descr': 1,
|
||||
'date_created': 1,
|
||||
'date_updated': 1,
|
||||
'userId': 1,
|
||||
'username': 1,
|
||||
'name': 1,
|
||||
'surname': 1,
|
||||
'comune': 1,
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
$project: this.getProject(),
|
||||
},
|
||||
{
|
||||
'$lookup': {
|
||||
@@ -462,47 +309,43 @@ MySkillSchema.statics.getMyRecById = function(idapp, idSkill) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
'$project': {
|
||||
'recSkill': 1,
|
||||
'sector': 1,
|
||||
'idSector': 1,
|
||||
'idSkill': 1,
|
||||
// 'idSubSkill': 1,
|
||||
'idStatusSkill': 1,
|
||||
'idContribType': 1,
|
||||
'idCity': 1,
|
||||
pub_to_share: 1,
|
||||
'numLevel': 1,
|
||||
adType: 1,
|
||||
'photos': 1,
|
||||
'note': 1,
|
||||
website: 1,
|
||||
//**ADDFIELD_MYSKILL
|
||||
'descr': 1,
|
||||
'date_created': 1,
|
||||
'date_updated': 1,
|
||||
'userId': 1,
|
||||
'username': 1,
|
||||
'name': 1,
|
||||
'surname': 1,
|
||||
'comune': 1,
|
||||
'mycities': 1,
|
||||
'profile.img': 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.mycircuits": 1,
|
||||
'profile.qualifica': 1,
|
||||
reported: 1,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
let numtab = tools.getNumTabByTable(shared_consts.TABLES_MYSKILLS);
|
||||
|
||||
const objadd = tools.addNumFavoriteAndBookmarkToQuery(idapp, numtab);
|
||||
query = [...query, ...objadd.query];
|
||||
|
||||
const toadd = {
|
||||
$project: this.getProject(objadd.proj),
|
||||
};
|
||||
|
||||
query = [...query, { ...toadd }];
|
||||
|
||||
return MySkill.aggregate(query).then((rec) => {
|
||||
return rec ? rec[0] : null;
|
||||
});
|
||||
};
|
||||
|
||||
MySkillSchema.statics.getCompleteRecord = function(idapp, id) {
|
||||
MySkillSchema.statics.getProject = function (proj_add2) {
|
||||
let proj = {
|
||||
recSkill: 1,
|
||||
sector: 1,
|
||||
idSector: 1,
|
||||
idSkill: 1,
|
||||
idStatusSkill: 1,
|
||||
website: 1,
|
||||
'numLevel': 1,
|
||||
//**ADDFIELD_MYSKILL
|
||||
};
|
||||
|
||||
const proj_add = shared_consts.getProjectForAll(proj_add2)
|
||||
|
||||
return Object.assign({}, proj, proj_add);
|
||||
|
||||
}
|
||||
|
||||
MySkillSchema.statics.getCompleteRecord = function (idapp, id) {
|
||||
const MySkill = this;
|
||||
|
||||
return MySkill.getMyRecById(idapp, id);
|
||||
@@ -511,4 +354,8 @@ MySkillSchema.statics.getCompleteRecord = function(idapp, id) {
|
||||
|
||||
const MySkill = mongoose.model('MySkill', MySkillSchema);
|
||||
|
||||
module.exports = {MySkill};
|
||||
MySkill.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = { MySkill };
|
||||
|
||||
@@ -170,4 +170,8 @@ NewstosentSchema.statics.isActivated = async function (_id) {
|
||||
|
||||
const Newstosent = mongoose.model('Newstosent', NewstosentSchema);
|
||||
|
||||
Newstosent.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = { Newstosent };
|
||||
|
||||
@@ -118,4 +118,8 @@ OperatorSchema.statics.findAllIdApp = function (idapp) {
|
||||
|
||||
const Operator = mongoose.model('Operator', OperatorSchema);
|
||||
|
||||
Operator.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = { Operator };
|
||||
|
||||
@@ -43,4 +43,8 @@ OpzEmailSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
const OpzEmail = mongoose.model('OpzEmail', OpzEmailSchema);
|
||||
|
||||
OpzEmail.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports = { OpzEmail };
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
const shared_consts = require('../tools/shared_nodejs');
|
||||
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
@@ -18,23 +19,19 @@ const orderSchema = new Schema({
|
||||
idapp: {
|
||||
type: String,
|
||||
},
|
||||
userId: {
|
||||
type: String,
|
||||
},
|
||||
userId: { type: Schema.Types.ObjectId, ref: 'User' },
|
||||
status: {
|
||||
type: Number,
|
||||
},
|
||||
idProduct: {
|
||||
type: String
|
||||
},
|
||||
idProducer: {
|
||||
type: String
|
||||
},
|
||||
idStorehouse: {
|
||||
type: String
|
||||
},
|
||||
idProduct: { type: Schema.Types.ObjectId, ref: 'Product' },
|
||||
idProducer: { type: Schema.Types.ObjectId, ref: 'Producer' },
|
||||
idStorehouse: { type: Schema.Types.ObjectId, ref: 'StoreHouse' },
|
||||
idScontisticas: [{ type: Schema.Types.ObjectId, ref: 'Scontistica' }],
|
||||
idProvider: { type: Schema.Types.ObjectId, ref: 'Provider' },
|
||||
idGasordine: { type: Schema.Types.ObjectId, ref: 'Gasordine' },
|
||||
price: {
|
||||
type: Number
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
after_price: {
|
||||
type: String
|
||||
@@ -46,11 +43,62 @@ const orderSchema = new Schema({
|
||||
type: String
|
||||
},
|
||||
quantity: {
|
||||
type: Number
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
quantitypreordered: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
TotalPriceProduct: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
TotalPriceProductCalc: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
confermato: { // e quindi è stato tolto dal magazzino (aggiornando il campo stockQty)
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
date_confermato: {
|
||||
type: Date
|
||||
},
|
||||
pagato: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
date_pagato: {
|
||||
type: Date
|
||||
},
|
||||
consegnato: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
date_consegnato: {
|
||||
type: Date
|
||||
},
|
||||
spedito: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
date_spedito: {
|
||||
type: Date
|
||||
},
|
||||
ricevuto: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
date_ricevuto: {
|
||||
type: Date
|
||||
},
|
||||
weight: {
|
||||
type: Number
|
||||
},
|
||||
unit: {
|
||||
type: Number
|
||||
},
|
||||
stars: {
|
||||
type: Number
|
||||
},
|
||||
@@ -69,18 +117,27 @@ const orderSchema = new Schema({
|
||||
date_delivered: {
|
||||
type: Date
|
||||
},
|
||||
notes: {
|
||||
note: {
|
||||
type: String
|
||||
}
|
||||
},
|
||||
modify_at: {
|
||||
type: Date
|
||||
},
|
||||
});
|
||||
|
||||
var Order = module.exports = mongoose.model('Order', orderSchema);
|
||||
|
||||
module.exports.createIndexes((err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
module.exports.getFieldsForSearch = function () {
|
||||
return []
|
||||
};
|
||||
|
||||
module.exports.executeQueryTable = function (idapp, params) {
|
||||
const tools = require('../tools/general');
|
||||
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
return tools.executeQueryTable(this, idapp, params);
|
||||
};
|
||||
@@ -89,26 +146,93 @@ module.exports.findAllIdApp = async function (idapp) {
|
||||
|
||||
const query = [
|
||||
{ $match: { idapp } },
|
||||
{ "$addFields": { "myidProd": { "$toObjectId": "$idProduct" } } },
|
||||
{ "$addFields": { "myidProducer": { "$toObjectId": "$idProducer" } } },
|
||||
{
|
||||
$lookup: {
|
||||
from: 'products',
|
||||
localField: 'myidProd',
|
||||
localField: 'idProduct',
|
||||
foreignField: '_id',
|
||||
as: 'product'
|
||||
}
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'productinfos',
|
||||
localField: 'product.idProduct',
|
||||
foreignField: '_id',
|
||||
as: 'product.productInfo'
|
||||
}
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$product.productInfo',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'producers',
|
||||
localField: 'myidProducer',
|
||||
localField: 'product.idProducer',
|
||||
foreignField: '_id',
|
||||
as: 'producer'
|
||||
}
|
||||
},
|
||||
{ $unwind: '$product' },
|
||||
{ $unwind: '$producer' },
|
||||
{
|
||||
$lookup: {
|
||||
from: 'providers',
|
||||
localField: 'product.idProvider',
|
||||
foreignField: '_id',
|
||||
as: 'provider'
|
||||
}
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'gasordines',
|
||||
localField: 'idGasordine',
|
||||
foreignField: '_id',
|
||||
as: 'gasordine'
|
||||
}
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$gasordine',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
$or: [
|
||||
{ 'gasordine': { $exists: false } },
|
||||
{ 'gasordine.active': true }
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'scontisticas',
|
||||
localField: 'product.idScontisticas',
|
||||
foreignField: '_id',
|
||||
as: 'scontistica'
|
||||
}
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$product',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$producer',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$provider',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
|
||||
];
|
||||
|
||||
return await Order.aggregate(query)
|
||||
@@ -129,34 +253,158 @@ module.exports.getOrderByID = function (id, callback) {
|
||||
}
|
||||
|
||||
module.exports.createOrder = async function (order) {
|
||||
const orderModel = new Order(order);
|
||||
|
||||
return await orderModel.save(order)
|
||||
.then((ris) => {
|
||||
if (!!ris)
|
||||
return ris._id;
|
||||
return null;
|
||||
});
|
||||
try {
|
||||
if (order.idGasordine === '') {
|
||||
order.idGasordine = undefined;
|
||||
}
|
||||
Order.updateTotals(order);
|
||||
return await Order.create(order)
|
||||
.then((ris) => {
|
||||
if (!!ris)
|
||||
return ris._id;
|
||||
return null;
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('err', e);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.updateStatusOrders = async function (arrOrders, status) {
|
||||
|
||||
for (const order of arrOrders) {
|
||||
let ret = await Order.updateOne({ _id: order.order._id }, { $set: { status } });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports.updateStatusOrdersElements = async function (arrOrders, myelements) {
|
||||
|
||||
for (const order of arrOrders) {
|
||||
const ret = await Order.findOneAndUpdate({ _id: order.order._id }, { $set: myelements });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports.updateOrderByParams = async function (idOrder, paramstoupdate) {
|
||||
|
||||
const ris = await Order.findOneAndUpdate({ _id: idOrder }, { $set: paramstoupdate });
|
||||
|
||||
let myorder = await Order.findOne({ _id: idOrder }).lean();
|
||||
|
||||
if (paramstoupdate && !paramstoupdate.hasOwnProperty('TotalPriceProduct')) {
|
||||
this.updateTotals(myorder);
|
||||
|
||||
await Order.findOneAndUpdate({ _id: idOrder }, { $set: myorder });
|
||||
}
|
||||
|
||||
return myorder;
|
||||
}
|
||||
|
||||
module.exports.updateTotals = function (order) {
|
||||
|
||||
try {
|
||||
if (!order) {
|
||||
return;
|
||||
}
|
||||
|
||||
let mypricecalc = 0;
|
||||
order.TotalPriceProduct = 0;
|
||||
order.TotalPriceProductCalc = 0;
|
||||
order.modify_at = new Date();
|
||||
|
||||
// Calcolo Sconto
|
||||
let sconti_da_applicare = [];
|
||||
if (order.scontisticas) {
|
||||
|
||||
let qtadascontare = order.quantity + order.quantitypreordered
|
||||
let qtanonscontata = 0
|
||||
|
||||
while (qtadascontare > 0) {
|
||||
let scontoapplicato = null
|
||||
for (const sconto of order.scontisticas.filter((rec) => !rec.cumulativo)) {
|
||||
if (qtadascontare >= sconto.qta) {
|
||||
scontoapplicato = sconto
|
||||
scontoapplicato.qtadascontare = sconto.qta
|
||||
}
|
||||
}
|
||||
if (scontoapplicato && scontoapplicato.qtadascontare > 0) {
|
||||
sconti_da_applicare.push(scontoapplicato)
|
||||
qtadascontare -= scontoapplicato.qtadascontare
|
||||
} else {
|
||||
qtanonscontata = qtadascontare
|
||||
qtadascontare = 0
|
||||
}
|
||||
}
|
||||
|
||||
/*for (const sconto of order.scontisticas.filter((rec) => rec.cumulativo)) {
|
||||
if ((sconto.qta % order.quantity) === 0) {
|
||||
sconti_da_applicare.push(sconto)
|
||||
}
|
||||
}*/
|
||||
|
||||
if (sconti_da_applicare.length > 0) {
|
||||
for (const sconto of sconti_da_applicare) {
|
||||
if (sconto.perc_sconto > 0) {
|
||||
mypricecalc += (sconto.qtadascontare * order.price) * (1 - (sconto.perc_sconto / 100))
|
||||
} else {
|
||||
mypricecalc += sconto.price
|
||||
}
|
||||
}
|
||||
}
|
||||
if (qtanonscontata > 0) {
|
||||
mypricecalc += order.price * qtanonscontata;
|
||||
}
|
||||
|
||||
} else {
|
||||
mypricecalc = (order.price * order.quantity) + (order.price * order.quantitypreordered);
|
||||
}
|
||||
|
||||
order.TotalPriceProductCalc += mypricecalc;
|
||||
order.TotalPriceProduct += mypricecalc;
|
||||
|
||||
return order;
|
||||
|
||||
} catch (e) {
|
||||
console.error('Err:', e);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.getTotalOrderById = async function (id) {
|
||||
const query = [
|
||||
{ $match: { _id: ObjectID(id) } },
|
||||
{ "$addFields": { "myidProd": { "$toObjectId": "$idProduct" } } },
|
||||
{ "$addFields": { "myidProducer": { "$toObjectId": "$idProducer" } } },
|
||||
{ "$addFields": { "myidStore": { "$toObjectId": "$idStorehouse" } } },
|
||||
{
|
||||
$lookup: {
|
||||
from: 'products',
|
||||
localField: 'myidProd',
|
||||
localField: 'idProduct',
|
||||
foreignField: '_id',
|
||||
as: 'product'
|
||||
}
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$product',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'productinfos',
|
||||
localField: 'product.idProductInfo',
|
||||
foreignField: '_id',
|
||||
as: 'product.productInfo'
|
||||
}
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$product.productInfo',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'producers',
|
||||
localField: 'myidProducer',
|
||||
localField: 'product.idProducer',
|
||||
foreignField: '_id',
|
||||
as: 'producer'
|
||||
}
|
||||
@@ -164,14 +412,192 @@ module.exports.getTotalOrderById = async function (id) {
|
||||
{
|
||||
$lookup: {
|
||||
from: 'storehouses',
|
||||
localField: 'myidStore',
|
||||
localField: 'idStorehouse',
|
||||
foreignField: '_id',
|
||||
as: 'storehouse'
|
||||
}
|
||||
},
|
||||
{ $unwind: '$product' },
|
||||
{ $unwind: '$producer' },
|
||||
{ $unwind: '$storehouse' },
|
||||
{
|
||||
$lookup: {
|
||||
from: 'providers',
|
||||
localField: 'product.idProvider',
|
||||
foreignField: '_id',
|
||||
as: 'provider'
|
||||
}
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'gasordines',
|
||||
localField: 'idGasordine',
|
||||
foreignField: '_id',
|
||||
as: 'gasordine'
|
||||
}
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$gasordine',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
$or: [
|
||||
{ 'gasordine': { $exists: false } },
|
||||
{ 'gasordine.active': true }
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'scontisticas',
|
||||
localField: 'product.idScontisticas',
|
||||
foreignField: '_id',
|
||||
as: 'scontisticas'
|
||||
}
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$producer',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$storehouse',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$provider',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'orders',
|
||||
let: { productId: '$product._id' },
|
||||
pipeline: [
|
||||
{
|
||||
$match: {
|
||||
$expr: {
|
||||
$and: [
|
||||
{ $eq: ['$idProduct', '$$productId'] },
|
||||
{
|
||||
$or: [
|
||||
{
|
||||
$eq: ['$status', shared_consts.OrderStatus.CHECKOUT_SENT]
|
||||
},
|
||||
{
|
||||
$and: [{ $lt: ['$status', shared_consts.OrderStatus.CHECKOUT_SENT] },
|
||||
{
|
||||
$gt: [
|
||||
'$modify_at',
|
||||
{ $subtract: [new Date(), 60 * 60 * 1000] } // 1 hour in milliseconds 60 * 60
|
||||
]
|
||||
}]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
$group: {
|
||||
_id: null,
|
||||
totalQty: { $sum: '$quantity' },
|
||||
}
|
||||
}
|
||||
],
|
||||
as: 'productOrders'
|
||||
}
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'orders',
|
||||
let: { productId: '$product._id' },
|
||||
pipeline: [
|
||||
{
|
||||
$match: {
|
||||
$expr: {
|
||||
$and: [
|
||||
{ $eq: ['$idProduct', '$$productId'] },
|
||||
{
|
||||
$or: [
|
||||
{
|
||||
$eq: ['$status', shared_consts.OrderStatus.CHECKOUT_SENT]
|
||||
},
|
||||
{
|
||||
$and: [{ $lt: ['$status', shared_consts.OrderStatus.CHECKOUT_SENT] },
|
||||
{
|
||||
$gt: [
|
||||
'$modify_at',
|
||||
{ $subtract: [new Date(), 60 * 60 * 1000] } // 1 hour in milliseconds 60 * 60
|
||||
]
|
||||
}]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
$group: {
|
||||
_id: null,
|
||||
totalQtyPreordered: { $sum: '$quantitypreordered' }
|
||||
}
|
||||
}
|
||||
],
|
||||
as: 'productPreOrders'
|
||||
}
|
||||
},
|
||||
{
|
||||
$addFields: {
|
||||
'product.QuantitaOrdinateInAttesa': {
|
||||
$ifNull: [
|
||||
{
|
||||
$cond: {
|
||||
if: { $isArray: '$productOrders' },
|
||||
then: { $arrayElemAt: ['$productOrders.totalQty', 0] },
|
||||
else: 0
|
||||
}
|
||||
},
|
||||
0
|
||||
]
|
||||
},
|
||||
'product.QuantitaPrenotateInAttesa': {
|
||||
$ifNull: [
|
||||
{
|
||||
$cond: {
|
||||
if: { $isArray: '$productPreOrders' },
|
||||
then: { $arrayElemAt: ['$productPreOrders.totalQtyPreordered', 0] },
|
||||
else: 0
|
||||
}
|
||||
},
|
||||
0
|
||||
]
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$addFields: {
|
||||
'product.quantityAvailable': {
|
||||
$subtract: ["$product.stockQty", "$product.QuantitaOrdinateInAttesa"],
|
||||
},
|
||||
'product.bookableAvailableQty': {
|
||||
$subtract: ["$product.maxbookableGASQty", "$product.QuantitaPrenotateInAttesa"],
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
$unset: 'productOrders'
|
||||
},
|
||||
{
|
||||
$unset: 'productPreOrders'
|
||||
},
|
||||
|
||||
];
|
||||
|
||||
return await Order.aggregate(query);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user