Ordini
This commit is contained in:
18
deploy_backend.sh
Executable file
18
deploy_backend.sh
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
source ./.env.production
|
||||||
|
|
||||||
|
|
||||||
|
msg="*** TUTTI I SERVER BACKEND !!! **** SEI SICURO DI INVIARE GLI AGGIORNAMENTI BACKEND (NODE.JS) - SU TUTTI SERVER ??? $SERVERDIR_WEBSITE (Y/N) ? "
|
||||||
|
|
||||||
|
if [ "$1" = "" ]; then
|
||||||
|
read -p "$msg" risposta
|
||||||
|
else
|
||||||
|
risposta=$1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $risposta == "Y" || $risposta == "y" ]]; then
|
||||||
|
cd /home/paolo/myproject/$DIRECTORY_SERVER/
|
||||||
|
./deploynodejs_on_production.sh $risposta
|
||||||
|
./deploynodejs_on_test.sh $risposta
|
||||||
|
fi
|
||||||
6
deploy_test.sh
Executable file
6
deploy_test.sh
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
source ./.env.test
|
||||||
|
|
||||||
|
cd /home/paolo/myproject/$DIRECTORY_SERVER/
|
||||||
|
./deploynodejs_on_test.sh $risposta
|
||||||
1
dist/one.template.html
vendored
Executable file
1
dist/one.template.html
vendored
Executable file
@@ -0,0 +1 @@
|
|||||||
|
<!DOCTYPE html><html><head><title>One | Email template!</title></head><body style="background: #000000; color: #5b656e; margin: 0; padding: 0;"><table class="table" cellpadding="0" cellspacing="0" style="border-collapse: collapse;"><tr><td class="red" style="background-color: #E84C50; border-collapse: collapse; color: #313a42; font-family: tahoma, geneva, sans-serif;"><h3 style="color: #313a42 !important; font-family: tahoma, geneva, sans-serif; font-size: 16px; font-weight: normal; line-height: 1.2;">Gulp & Pug is awesome</h3></td></tr><tr><td style="border-collapse: collapse; color: #313a42; font-family: tahoma, geneva, sans-serif;"><a href="/" style="color: #09c;"><img class="full-width" src="https://media.giphy.com/media/6o9Q2WehOHWI1QGO08/giphy.gif" style="border: none; text-decoration: none; width: 100%;"></a></td></tr></table></body></html>
|
||||||
394
filelog.txt
Executable file
394
filelog.txt
Executable file
@@ -0,0 +1,394 @@
|
|||||||
|
USER [Paolo Arena (n.220)]: dasdas
|
||||||
|
USER [Paolo Arena (n.220)]: djlask dlaj
|
||||||
|
USER [Paolo Arena (n.220)]: d
|
||||||
|
USER [Paolo Arena (n.220)]: ad
|
||||||
|
USER [Paolo Arena (n.220)]: asdasdas dsa
|
||||||
|
USER [Paolo Arena (n.220)]: das
|
||||||
|
USER [Paolo Arena (n.220)]: as
|
||||||
|
USER [Paolo Arena (n.220)]: as d
|
||||||
|
BOT: Entra nella Chat EMPOWER !!!
|
||||||
|
https://t.me/joinchat/C741mkx5QYXu-kyYCYvA8g 💜💝💙
|
||||||
|
USER [Paolo Arena (n.220)]: d as
|
||||||
|
USER [Paolo Arena (n.220)]: d
|
||||||
|
USER [Paolo Arena (n.220)]: as d
|
||||||
|
USER [Paolo Arena (n.220)]: dsa dsa
|
||||||
|
BOT: Entra nella Chat EMPOWER !!!
|
||||||
|
https://t.me/joinchat/C741mkx5QYXu-kyYCYvA8g 💜💝💙
|
||||||
|
USER [Paolo Arena (n.220)]: as d
|
||||||
|
USER [Paolo Arena (n.220)]: as
|
||||||
|
USER [Paolo Arena (n.220)]: das
|
||||||
|
USER [Paolo Arena (n.220)]: das
|
||||||
|
USER [Paolo Arena (n.220)]: asd
|
||||||
|
USER [Paolo Arena (n.220)]: ciao
|
||||||
|
BOT: Entra nella Chat EMPOWER !!!
|
||||||
|
https://t.me/joinchat/C741mkx5QYXu-kyYCYvA8g 💜💝💙
|
||||||
|
USER [Paolo Arena (n.220)]: mi sposi
|
||||||
|
USER [Paolo Arena (n.220)]: sei sposato
|
||||||
|
BOT: Entra nella Chat EMPOWER !!!
|
||||||
|
https://t.me/joinchat/C741mkx5QYXu-kyYCYvA8g 💜💝💙
|
||||||
|
USER [Paolo Arena (n.220)]: sei sposato
|
||||||
|
BOT: No Grazie! Sono per la Libertà a Vita! 😂
|
||||||
|
Ma se vuoi possiamo conoscerci meglio!💃🔥
|
||||||
|
USER [Paolo Arena (n.220)]: ds
|
||||||
|
USER [Paolo Arena (n.220)]: 👎 no
|
||||||
|
USER [Paolo Arena (n.220)]: s
|
||||||
|
USER [Paolo Arena (n.220)]: ds
|
||||||
|
USER [Paolo Arena (n.220)]: ds
|
||||||
|
USER [Paolo Arena (n.220)]: s
|
||||||
|
USER [Paolo Arena (n.220)]: s
|
||||||
|
USER [Paolo Arena (n.220)]: s
|
||||||
|
USER [Paolo Arena (n.220)]: ds
|
||||||
|
USER [Paolo Arena (n.220)]: ✨✨✨
|
||||||
|
USER [Paolo Arena (n.220)]: 🎁 nave 1
|
||||||
|
USER [Paolo Arena (n.220)]: 🎁 nave 2
|
||||||
|
USER [Paolo Arena (n.220)]: 🔥🌏💦💨🔥🌏💦💨
|
||||||
|
🔥 0 (undefined undefined)
|
||||||
|
USER [P2 Arena (n.2)]: s
|
||||||
|
USER [P2 Arena (n.2)]: ds
|
||||||
|
USER [P2 Arena (n.2)]: s
|
||||||
|
USER [P2 Arena (n.2)]: s
|
||||||
|
|
||||||
|
USER [P2 Arena (n.2)]: s
|
||||||
|
|
||||||
|
USER [P2 Arena (n.2)]: 📨inv e no 7 req
|
||||||
|
|
||||||
|
USER [P2 Arena (n.2)]: 👎 no
|
||||||
|
|
||||||
|
USER [P2 Arena (n.2)]: 👎 no
|
||||||
|
|
||||||
|
USER [P2 Arena (n.2)]: sendmsg
|
||||||
|
|
||||||
|
USER [P2 Arena (n.2)]: sendmsgto paoloar77
|
||||||
|
|
||||||
|
USER [P2 Arena (n.2)]: 👎 no
|
||||||
|
|
||||||
|
USER [P2 Arena (n.2)]: s
|
||||||
|
|
||||||
|
USER [P2 Arena (n.2)]: s
|
||||||
|
|
||||||
|
USER [P2 Arena (n.2)]: ds
|
||||||
|
|
||||||
|
USER [P2 Arena (n.2)]: a
|
||||||
|
|
||||||
|
USER [P2 Arena (n.2)]: s
|
||||||
|
|
||||||
|
USER [P2 Arena (n.2)]: 👎 no
|
||||||
|
|
||||||
|
USER [P2 Arena (n.2)]: 👎 no
|
||||||
|
|
||||||
|
USER [P2 Arena (n.2)]: 💥💥💥💥💥❗️❗️❗️❗️❗️❗️❗️❗️❗️
|
||||||
|
ciao, stiamo preparando le billettere che partiranno fra pochissimo.
|
||||||
|
non possiamo inserirti perchè non sei in regola con i 7 requisiti richiesti.
|
||||||
|
affrettati a farlo così non perderai il tuo numero progressivo
|
||||||
|
|
||||||
|
✨✨✨✨✨✨🔥🔥🔥🔥
|
||||||
|
hai tempo fino alle ore 24 di martedì 25/2
|
||||||
|
✨✨✨✨✨✨🔥🔥🔥🔥
|
||||||
|
|
||||||
|
accedi al sito, inserendo la tua email e password con cui ti sei registrato:
|
||||||
|
|
||||||
|
ayni.gifteconomy.app
|
||||||
|
|
||||||
|
e segui i 7 semplici passi da compiere !
|
||||||
|
ti richiederà solo 2 minuti.
|
||||||
|
✨✨✨✨✨✨✨✨✨
|
||||||
|
staff ayni
|
||||||
|
|
||||||
|
USER [P2 Arena (n.2)]: ds
|
||||||
|
|
||||||
|
USER [P2 Arena (n.2)]: ciaoo
|
||||||
|
BOT: Ciao P2!
|
||||||
|
|
||||||
|
USER [P2 Arena (n.2)]: das
|
||||||
|
|
||||||
|
USER [P2 Arena (n.2)]: prova
|
||||||
|
|
||||||
|
USER [P2 Arena (n.2)]: ds
|
||||||
|
|
||||||
|
USER [P2 Arena (n.2)]: dsa
|
||||||
|
|
||||||
|
USER [P2 Arena (n.2)]: dsds
|
||||||
|
|
||||||
|
USER [P2 Arena (n.2)]: ds
|
||||||
|
|
||||||
|
USER [P8 Arena (n.8)]: sss
|
||||||
|
|
||||||
|
USER [P8 Arena (n.8)]: 👍 si
|
||||||
|
|
||||||
|
USER [P8 Arena (n.8)]: dds
|
||||||
|
|
||||||
|
USER [P8 Arena (n.8)]: dsdas
|
||||||
|
|
||||||
|
USER [P20 Arena (n.20)]: /start
|
||||||
|
|
||||||
|
USER [P2 Arena (n.2)]: ds
|
||||||
|
|
||||||
|
USER [P2 Arena (n.2)]: dasdas
|
||||||
|
|
||||||
|
USER [P2 Arena (n.2)]: ds
|
||||||
|
|
||||||
|
USER [P2 Arena (n.2)]: cosaaaaa
|
||||||
|
|
||||||
|
USER [P2 Arena (n.2)]: dsadsadas
|
||||||
|
|
||||||
|
USER [P2 Arena (n.2)]: dasdas
|
||||||
|
|
||||||
|
USER [P20 Arena (n.20)]: cff
|
||||||
|
|
||||||
|
USER [P2 Arena (n.2)]: rfd
|
||||||
|
|
||||||
|
USER [P2 Arena (n.2)]: ddd
|
||||||
|
|
||||||
|
USER [P20 Arena (n.20)]: ddd
|
||||||
|
|
||||||
|
USER [P2 Arena (n.2)]: nave (1.1)
|
||||||
|
|
||||||
|
e1 🌈 sognatore: ayni (). (fondoayni)
|
||||||
|
|
||||||
|
a1 💦 mediatore: miriam mo. (miriam)
|
||||||
|
|
||||||
|
t1 🌏 elisa ge. (elisag.)
|
||||||
|
t2 🌏 vanessa ca. (vanessa)
|
||||||
|
|
||||||
|
a1 💨 roberta tu. (robertatc)
|
||||||
|
a2 💨 vistar fe. (vistar)
|
||||||
|
a3 💨 tiziana ca. (tizicaso)
|
||||||
|
a4 💨 raffaella ga. (duelune)
|
||||||
|
|
||||||
|
donatori:
|
||||||
|
f1 🔥 paolo ar. (paoloar77)
|
||||||
|
f2 🔥 chiara ca. (qiara2020)
|
||||||
|
f3 🔥 monica ma. (mmonica)
|
||||||
|
f4 🔥 elena li. (elenaliu)
|
||||||
|
f5 🔥 chiara de. (chiaradelmissier)
|
||||||
|
f6 🔥 riccardo ma. (riccardomantelli)
|
||||||
|
f7 🔥 sara sa. (saraester)
|
||||||
|
f8 🔥 miriam mo. (miriam)
|
||||||
|
|
||||||
|
USER [Paolo Arena (n.2)]: chi sono
|
||||||
|
BOT: Su Telegram ti chiami "Paolo Arena"
|
||||||
|
|
||||||
|
Sul sito ti sei registrato come:
|
||||||
|
|
||||||
|
[N. 2]: Paolo Arena
|
||||||
|
Username: paoloar77
|
||||||
|
Email: paolo.arena77@gmail.com
|
||||||
|
|
||||||
|
USER [Paolo Arena (n.2)]: 👎 no
|
||||||
|
|
||||||
|
USER [Paolo Arena (n.2)]: 👍 si
|
||||||
|
|
||||||
|
USER [P11 Arena (n.9)]: chi sono
|
||||||
|
BOT: Su Telegram ti chiami "Paolo A."
|
||||||
|
|
||||||
|
Sul sito ti sei registrato come:
|
||||||
|
|
||||||
|
[N. 9]: P11 Arena
|
||||||
|
Username: paoloar77b
|
||||||
|
Email: p.aoloarena77@gmail.com
|
||||||
|
Lang: it
|
||||||
|
|
||||||
|
USER [P11 Arena (n.9)]: chi sono
|
||||||
|
BOT: Su Telegram ti chiami "Paolo A."
|
||||||
|
|
||||||
|
Sul sito ti sei registrato come:
|
||||||
|
|
||||||
|
[N. 9]: P11 Arena
|
||||||
|
Username: paoloar77b
|
||||||
|
Email: p.aoloarena77@gmail.com
|
||||||
|
Lang: itNum Invitati: undefined
|
||||||
|
Num Invitati: undefined
|
||||||
|
|
||||||
|
|
||||||
|
USER [P11 Arena (n.9)]: chi sono
|
||||||
|
BOT: Su Telegram ti chiami "Paolo A."
|
||||||
|
|
||||||
|
Sul sito ti sei registrato come:
|
||||||
|
|
||||||
|
[N. 9]: P11 Arena
|
||||||
|
Username: paoloar77b
|
||||||
|
Email: p.aoloarena77@gmail.com
|
||||||
|
Lang: itNum Invitati: undefined
|
||||||
|
Num Invitati: undefined
|
||||||
|
|
||||||
|
|
||||||
|
USER [P11 Arena (n.9)]: chi sono
|
||||||
|
BOT: Su Telegram ti chiami "Paolo A."
|
||||||
|
|
||||||
|
Sul sito ti sei registrato come:
|
||||||
|
|
||||||
|
[N. 9]: P11 Arena
|
||||||
|
Username: paoloar77b
|
||||||
|
Email: p.aoloarena77@gmail.com
|
||||||
|
Lang: it
|
||||||
|
Num Invitati: undefined
|
||||||
|
Num Invitati: undefined
|
||||||
|
|
||||||
|
|
||||||
|
USER [P11 Arena (n.9)]: chi sono
|
||||||
|
BOT: Su Telegram ti chiami "Paolo A."
|
||||||
|
|
||||||
|
Sul sito ti sei registrato come:
|
||||||
|
|
||||||
|
[N. 9]: P11 Arena
|
||||||
|
Username: paoloar77b
|
||||||
|
Email: p.aoloarena77@gmail.com
|
||||||
|
Lang: it
|
||||||
|
Num Invitati: 0
|
||||||
|
Num Invitati Attivi: undefined
|
||||||
|
|
||||||
|
|
||||||
|
USER [P11 Arena (n.9)]: chi sono
|
||||||
|
BOT: Su Telegram ti chiami "Paolo A."
|
||||||
|
|
||||||
|
Sul sito ti sei registrato come:
|
||||||
|
|
||||||
|
[N. 9]: P11 Arena
|
||||||
|
Username: paoloar77b
|
||||||
|
Email: p.aoloarena77@gmail.com
|
||||||
|
Lang: it
|
||||||
|
Num Invitati: 0
|
||||||
|
Num Invitati Attivi: undefined
|
||||||
|
|
||||||
|
|
||||||
|
USER [P11 Arena (n.9)]: chi sono
|
||||||
|
BOT: Su Telegram ti chiami "Paolo A."
|
||||||
|
|
||||||
|
Sul sito ti sei registrato come:
|
||||||
|
|
||||||
|
[N. 9]: P11 Arena
|
||||||
|
Username: paoloar77b
|
||||||
|
Email: p.aoloarena77@gmail.com
|
||||||
|
Lang: it
|
||||||
|
Num Invitati: 0
|
||||||
|
Num Invitati Attivi: undefined
|
||||||
|
|
||||||
|
|
||||||
|
USER [P11 Arena (n.9)]: chi sono
|
||||||
|
BOT: Su Telegram ti chiami "Paolo A."
|
||||||
|
|
||||||
|
Sul sito ti sei registrato come:
|
||||||
|
|
||||||
|
[N. 9]: P11 Arena
|
||||||
|
Username: paoloar77b
|
||||||
|
Email: p.aoloarena77@gmail.com
|
||||||
|
Lang: it
|
||||||
|
Num Invitati: 0
|
||||||
|
Num Invitati Attivi:
|
||||||
|
|
||||||
|
|
||||||
|
USER [P11 Arena (n.9)]: chi sono
|
||||||
|
BOT: Su Telegram ti chiami "Paolo A."
|
||||||
|
|
||||||
|
Sul sito ti sei registrato come:
|
||||||
|
|
||||||
|
[N. 9]: P11 Arena
|
||||||
|
Username: paoloar77b
|
||||||
|
Email: p.aoloarena77@gmail.com
|
||||||
|
Lang: it
|
||||||
|
Num Invitati: 0
|
||||||
|
Num Invitati Attivi:
|
||||||
|
|
||||||
|
|
||||||
|
USER [U2 Ar2 (n.2)]: chi sono
|
||||||
|
BOT: Su Telegram ti chiami "Paolo A."
|
||||||
|
|
||||||
|
Sul sito ti sei registrato come:
|
||||||
|
|
||||||
|
[N. 2]: U2 Ar2
|
||||||
|
Username: Userna_U2
|
||||||
|
Email: miaemail@email.it
|
||||||
|
Lang: it
|
||||||
|
Num Invitati: 0
|
||||||
|
Num Invitati Attivi: 0
|
||||||
|
|
||||||
|
|
||||||
|
USER [U2 Ar2 (n.2)]: chi sono
|
||||||
|
BOT: Su Telegram ti chiami "Paolo A."
|
||||||
|
|
||||||
|
Sul sito ti sei registrato come:
|
||||||
|
|
||||||
|
[N. 2]: U2 Ar2
|
||||||
|
Username: Userna_U2
|
||||||
|
Email: miaemail@email.it
|
||||||
|
Lang: it
|
||||||
|
Num Invitati: 0
|
||||||
|
Num Invitati Attivi: 0
|
||||||
|
|
||||||
|
|
||||||
|
USER [U2 Ar2 (n.2)]: chi sono
|
||||||
|
BOT: Su Telegram ti chiami "Paolo A."
|
||||||
|
|
||||||
|
Sul sito ti sei registrato come:
|
||||||
|
|
||||||
|
[N. 2]: U2 Ar2
|
||||||
|
Username: Userna_U2
|
||||||
|
Email: miaemail@email.it
|
||||||
|
Lang: it
|
||||||
|
Num Invitati: 0
|
||||||
|
Num Invitati Attivi: 0
|
||||||
|
|
||||||
|
|
||||||
|
USER [Paolo Arena (n.1)]: chi sono
|
||||||
|
BOT: Su Telegram ti chiami "Paolo A."
|
||||||
|
|
||||||
|
Sul sito ti sei registrato come:
|
||||||
|
|
||||||
|
[N. 1]: Paolo Arena
|
||||||
|
Username: paoloar77
|
||||||
|
Email: paoloarena77@gmail.com
|
||||||
|
Lang: it
|
||||||
|
Num Invitati: 2
|
||||||
|
Num Invitati Attivi: 1
|
||||||
|
|
||||||
|
|
||||||
|
USER [Paolo Arena (n.-1)]: dsakad klñasdlkas djasç
|
||||||
|
|
||||||
|
USER [Paolo Arena (n.-1)]: dsadasdas das asd as
|
||||||
|
|
||||||
|
USER [Paolo Arena (n.-1)]: dasdas dadas das
|
||||||
|
|
||||||
|
USER [Paolo Arena (n.-1)]: dsa das dasd as da
|
||||||
|
|
||||||
|
USER [Paolo Arena (n.-1)]: dsa dasd als das
|
||||||
|
|
||||||
|
USER [Paolo Arena (n.-1)]: dasdasdasdas das
|
||||||
|
|
||||||
|
USER [Paolo Arena (n.-1)]: d asda da sa
|
||||||
|
|
||||||
|
USER [Paolo Arena (n.-1)]: dasd asd as das
|
||||||
|
|
||||||
|
USER [Paolo Arena (n.-1)]: <strong>ciaoo</strong>
|
||||||
|
|
||||||
|
USER [Paolo Arena (n.8)]: chiedi_se_imbarcarti
|
||||||
|
|
||||||
|
USER [Paolo Arena (n.8)]: chi sono
|
||||||
|
BOT: Su Telegram ti chiami "Paolo A."
|
||||||
|
|
||||||
|
Sul sito ti sei registrato come:
|
||||||
|
|
||||||
|
[N. 8]: Paolo Arena
|
||||||
|
Username: paoloar77
|
||||||
|
Email: pao.loarena77@gmail.com
|
||||||
|
Lang: it
|
||||||
|
Num Invitati: 9
|
||||||
|
Num Invitati Attivi: 8
|
||||||
|
|
||||||
|
|
||||||
|
2020-06-05 (Ven): USER [Paolo Arena (n.8)]: https://t.me/joinchat/nrnlqe45yuiiwli06le_ww
|
||||||
|
|
||||||
|
Mar 15/12 ORE 10:39: USER [Paolo Arena (n.8)]: https://ayni.gifteconomy.app
|
||||||
|
|
||||||
|
Mar 15/12 ORE 10:41: USER [Paolo Arena (n.8)]: https://ayni.gifteconomy.app
|
||||||
|
|
||||||
|
Mar 15/12 ORE 10:43: USER [Paolo Arena (n.8)]: https://ayni.gifteconomy.app
|
||||||
|
|
||||||
|
Mar 15/12 ORE 10:43: USER [Paolo Arena (n.8)]: https://ayni.gifteconomy.app
|
||||||
|
|
||||||
|
Mar 15/12 ORE 10:44: USER [Paolo Arena (n.8)]: https://ayni.gifteconomy.app
|
||||||
|
|
||||||
|
Mar 15/12 ORE 10:45: USER [Paolo Arena (n.8)]: https://ayni.gifteconomy.app
|
||||||
|
|
||||||
|
Mar 15/12 ORE 10:45: USER [Paolo Arena (n.8)]: https://ayni.gifteconomy.app
|
||||||
|
|
||||||
|
Mar 15/12 ORE 10:46: USER [Paolo Arena (n.8)]: https://ayni.gifteconomy.app
|
||||||
@@ -158,7 +158,7 @@ if (process.env.NODE_ENV === 'production') {
|
|||||||
portapp: '0',
|
portapp: '0',
|
||||||
dir: '/var/www/comunitanuovomondo.app',
|
dir: '/var/www/comunitanuovomondo.app',
|
||||||
email_from: 'cnmrimini@gmail.com',
|
email_from: 'cnmrimini@gmail.com',
|
||||||
email_pwd: '385e9bdfbfd8dd13505fbbc65ff6728b5fa836594054aadf9c7eb55b6b46100adUeazC8qEt2YEOkOFYWPvw==',
|
email_pwd: 'cdd333bf42a655243e9f4e97d39d7a3a9360211ecba1ce052d5b7e22630acbbfTgI3kQya6Y0NB+qnspFg9w==',
|
||||||
telegram_key:'1202788747:AAErwzIsD7k-3Yj5AX6ci3p7ELMuyASq4vA',
|
telegram_key:'1202788747:AAErwzIsD7k-3Yj5AX6ci3p7ELMuyASq4vA',
|
||||||
telegram_bot_name: 'comunitanuovomondo_bot',
|
telegram_bot_name: 'comunitanuovomondo_bot',
|
||||||
pathreg_add:'_cnm',
|
pathreg_add:'_cnm',
|
||||||
|
|||||||
21
src/server/models/cart.js
Normal file → Executable file
21
src/server/models/cart.js
Normal file → Executable file
@@ -1,6 +1,9 @@
|
|||||||
|
|
||||||
const mongoose = require('mongoose');
|
const mongoose = require('mongoose');
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
|
const shared_consts = require('../tools/shared_nodejs');
|
||||||
|
|
||||||
const Order = require('../models/order');
|
const Order = require('../models/order');
|
||||||
|
|
||||||
const CartSchema = new Schema({
|
const CartSchema = new Schema({
|
||||||
@@ -16,6 +19,9 @@ const CartSchema = new Schema({
|
|||||||
{ type: Schema.Types.ObjectId, ref: 'Order' }
|
{ type: Schema.Types.ObjectId, ref: 'Order' }
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
note: {
|
||||||
|
type: String
|
||||||
|
},
|
||||||
modify_at: {
|
modify_at: {
|
||||||
type: Date
|
type: Date
|
||||||
},
|
},
|
||||||
@@ -89,7 +95,16 @@ module.exports.updateCartByCartId = async function (cartId, newCart) {
|
|||||||
const totalQty = newCart.totalQty;
|
const totalQty = newCart.totalQty;
|
||||||
const totalPrice = newCart.totalPrice;
|
const totalPrice = newCart.totalPrice;
|
||||||
|
|
||||||
return await Cart.findOneAndUpdate({ _id: cartId }, { $set: { items, totalPrice, totalQty } }, { new: false })
|
const modify_at = new Date();
|
||||||
|
|
||||||
|
return await Cart.findOneAndUpdate({ _id: cartId }, {
|
||||||
|
$set: {
|
||||||
|
items,
|
||||||
|
totalPrice,
|
||||||
|
totalQty,
|
||||||
|
modify_at
|
||||||
|
}
|
||||||
|
}, { new: false })
|
||||||
.then((ris) => {
|
.then((ris) => {
|
||||||
return ris;
|
return ris;
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
@@ -99,6 +114,10 @@ module.exports.updateCartByCartId = async function (cartId, newCart) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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()
|
return await newCart.save()
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ mongoose.plugin(schema => {
|
|||||||
const cfgserverSchema = new Schema({
|
const cfgserverSchema = new Schema({
|
||||||
chiave: {
|
chiave: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
|
||||||
trim: true,
|
trim: true,
|
||||||
minlength: 1,
|
minlength: 1,
|
||||||
},
|
},
|
||||||
|
|||||||
179
src/server/models/orderscart.js
Executable file
179
src/server/models/orderscart.js
Executable file
@@ -0,0 +1,179 @@
|
|||||||
|
const mongoose = require('mongoose');
|
||||||
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
|
const shared_consts = require('../tools/shared_nodejs');
|
||||||
|
|
||||||
|
const Order = require('../models/order');
|
||||||
|
|
||||||
|
const { ObjectID } = require('mongodb');
|
||||||
|
|
||||||
|
const OrdersCartSchema = new Schema({
|
||||||
|
idapp: {
|
||||||
|
type: String
|
||||||
|
},
|
||||||
|
numorder: { type: Number },
|
||||||
|
userId: { type: Schema.Types.ObjectId, ref: 'User' },
|
||||||
|
totalQty: { type: Number, default: 0 },
|
||||||
|
totalPrice: { type: Number, default: 0 },
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
order:
|
||||||
|
{ type: Schema.Types.ObjectId, ref: 'Order' }
|
||||||
|
}
|
||||||
|
],
|
||||||
|
status: {
|
||||||
|
type: Number
|
||||||
|
},
|
||||||
|
note: {
|
||||||
|
type: String
|
||||||
|
},
|
||||||
|
modify_at: {
|
||||||
|
type: Date
|
||||||
|
},
|
||||||
|
created_at: {
|
||||||
|
type: Date
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
var OrdersCart = module.exports = mongoose.model('OrdersCart', OrdersCartSchema);
|
||||||
|
|
||||||
|
module.exports.findAllIdApp = async function (idapp, userId) {
|
||||||
|
const myfind = { idapp, userId };
|
||||||
|
|
||||||
|
return await OrdersCart.findOne(myfind);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
module.exports.getNewNumOrder = async function (uid, idapp) {
|
||||||
|
let query = { userId: uid, idapp }
|
||||||
|
let numorder = 1;
|
||||||
|
let numorderrec = await OrdersCart.find(query).sort({ numorder: -1 }).limit(1);
|
||||||
|
if (numorderrec.length <= 0)
|
||||||
|
numorder = 1;
|
||||||
|
else
|
||||||
|
numorder = numorderrec[0].numorder;
|
||||||
|
|
||||||
|
if (numorder) {
|
||||||
|
numorder++
|
||||||
|
} else {
|
||||||
|
numorder = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return numorder;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.getOrdersCartByUserId = async function (uid, idapp) {
|
||||||
|
let query = { userId: uid, idapp, status: { $gte: shared_consts.OrderStatus.CHECKOUT_CONFIRMED } }
|
||||||
|
const myorderscart = await OrdersCart.find(query);
|
||||||
|
|
||||||
|
for (let ind = 0; ind < myorderscart.length; ind++) {
|
||||||
|
for (const idkey in myorderscart[ind].items) {
|
||||||
|
try {
|
||||||
|
idorder = myorderscart[ind].items[idkey]._id.toString();
|
||||||
|
const myorder = myorderscart[ind].items[idkey].order;
|
||||||
|
if (!!myorder) {
|
||||||
|
idorder = myorderscart[ind].items[idkey].order._id.toString();
|
||||||
|
}
|
||||||
|
const myord = await Order.getTotalOrderById(idorder);
|
||||||
|
if (myord.length > 0) {
|
||||||
|
myorderscart[ind].items[idkey]._doc.order = myord[0];
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log('err', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 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]._doc.order = myord[0];
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log('err', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mycart;
|
||||||
|
}*/
|
||||||
|
return myorderscart
|
||||||
|
// return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.updateOrdersCartById = function (id, newOrdersCart, callback) {
|
||||||
|
let query = { id: id }
|
||||||
|
OrdersCart.find(query, function (err, c) {
|
||||||
|
if (err) throw err
|
||||||
|
|
||||||
|
//exist cart in databse
|
||||||
|
if (c.length > 0) {
|
||||||
|
OrdersCart.findOneAndUpdate(
|
||||||
|
{ _id: id },
|
||||||
|
{
|
||||||
|
$set: {
|
||||||
|
items: newOrdersCart.items,
|
||||||
|
totalQty: newOrdersCart.totalQty,
|
||||||
|
totalPrice: newOrdersCart.totalPrice,
|
||||||
|
userId: userId,
|
||||||
|
status: newOrdersCart.status,
|
||||||
|
numorder: newOrdersCart.numorder,
|
||||||
|
note: newOrdersCart.note,
|
||||||
|
modify_at: new Date(),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ new: true },
|
||||||
|
callback
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
//no cart in database
|
||||||
|
newOrdersCart.save(callback)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.createOrdersCart = async function (newOrdersCart) {
|
||||||
|
return await newOrdersCart.save()
|
||||||
|
}
|
||||||
|
|
||||||
|
OrdersCartSchema.pre('save', async function (next) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (this.isNew) {
|
||||||
|
try {
|
||||||
|
const myrec = await User.findOne({ idapp: this.idapp }).limit(1).sort({ neworder: -1 });
|
||||||
|
|
||||||
|
if (!!myrec) {
|
||||||
|
this.neworder = myrec._doc.neworder + 1;
|
||||||
|
} else {
|
||||||
|
this.neworder = 1;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
this.neworder = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (user.isModified('password')) {
|
||||||
|
bcrypt.genSalt(10, (err, salt) => {
|
||||||
|
bcrypt.hash(user.password, salt, (err, hash) => {
|
||||||
|
user.password = hash;
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
next();
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -25,6 +25,9 @@ const producerSchema = new Schema({
|
|||||||
referent: {
|
referent: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
|
username: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
region: {
|
region: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ const productSchema = new Schema({
|
|||||||
idStorehouses: [
|
idStorehouses: [
|
||||||
{ type: Schema.Types.ObjectId, ref: 'Storehouse' }
|
{ type: Schema.Types.ObjectId, ref: 'Storehouse' }
|
||||||
],
|
],
|
||||||
|
code: {
|
||||||
|
type: String,
|
||||||
|
lowercase: true
|
||||||
|
},
|
||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
@@ -50,6 +54,12 @@ const productSchema = new Schema({
|
|||||||
quantityAvailable: {
|
quantityAvailable: {
|
||||||
type: Number
|
type: Number
|
||||||
},
|
},
|
||||||
|
canBeShipped: { // è spedibile
|
||||||
|
type: Boolean
|
||||||
|
},
|
||||||
|
canBeBuyOnline: { // è acquistabile online
|
||||||
|
type: Boolean
|
||||||
|
},
|
||||||
stars: {
|
stars: {
|
||||||
type: Number
|
type: Number
|
||||||
},
|
},
|
||||||
@@ -62,6 +72,12 @@ const productSchema = new Schema({
|
|||||||
img: {
|
img: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
|
img2: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
img3: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
var Product = module.exports = mongoose.model('Product', productSchema);
|
var Product = module.exports = mongoose.model('Product', productSchema);
|
||||||
@@ -75,13 +91,17 @@ module.exports.executeQueryTable = function (idapp, params) {
|
|||||||
return tools.executeQueryTable(this, idapp, params);
|
return tools.executeQueryTable(this, idapp, params);
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.findAllIdApp = async function (idapp) {
|
module.exports.findAllIdApp = async function (idapp, code) {
|
||||||
const myfind = { idapp };
|
let myfind = { idapp };
|
||||||
|
|
||||||
|
if (code) {
|
||||||
|
myfind = { ...myfind, code }
|
||||||
|
}
|
||||||
|
|
||||||
// return await Product.find(myfind);
|
// return await Product.find(myfind);
|
||||||
|
|
||||||
const query = [
|
const query = [
|
||||||
{ $match: { idapp } },
|
{ $match: myfind },
|
||||||
{ "$addFields": { "myidProd": { "$toObjectId": "$idProducer" } } },
|
{ "$addFields": { "myidProd": { "$toObjectId": "$idProducer" } } },
|
||||||
{
|
{
|
||||||
$lookup: {
|
$lookup: {
|
||||||
@@ -125,6 +145,10 @@ module.exports.getProductByTitle = function (query, sort, callback) {
|
|||||||
Product.find(query, null, sort, callback)
|
Product.find(query, null, sort, callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports.getProductByCode = function (idapp, code) {
|
||||||
|
return Product.findOne({ idapp, code })
|
||||||
|
}
|
||||||
|
|
||||||
module.exports.filterProductByDepartment = function (department, callback) {
|
module.exports.filterProductByDepartment = function (department, callback) {
|
||||||
let regexp = new RegExp(`${department}`, 'i')
|
let regexp = new RegExp(`${department}`, 'i')
|
||||||
var query = { department: { $regex: regexp } };
|
var query = { department: { $regex: regexp } };
|
||||||
|
|||||||
49
src/server/models/sharewithus.js
Executable file
49
src/server/models/sharewithus.js
Executable file
@@ -0,0 +1,49 @@
|
|||||||
|
mongoose = require('mongoose');
|
||||||
|
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 ShareWithUsSchema = new Schema({
|
||||||
|
idapp: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
userId: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
description: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
numshared: {
|
||||||
|
type: Number,
|
||||||
|
},
|
||||||
|
rating: {
|
||||||
|
type: Number,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
var ShareWithUs = module.exports = mongoose.model('ShareWithUs', ShareWithUsSchema);
|
||||||
|
|
||||||
|
module.exports.getFieldsForSearch = function () {
|
||||||
|
return [{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 ShareWithUs.find(myfind);
|
||||||
|
};
|
||||||
|
|
||||||
@@ -257,9 +257,20 @@ const UserSchema = new mongoose.Schema({
|
|||||||
come_aiutare: {
|
come_aiutare: {
|
||||||
type: String
|
type: String
|
||||||
},
|
},
|
||||||
|
socio: {
|
||||||
|
type: Boolean,
|
||||||
|
},
|
||||||
|
socioresidente: {
|
||||||
|
type: Boolean,
|
||||||
|
},
|
||||||
|
myshares: [{
|
||||||
|
description: { type: String },
|
||||||
|
rating: { type: Number },
|
||||||
|
}]
|
||||||
},
|
},
|
||||||
|
|
||||||
});
|
})
|
||||||
|
;
|
||||||
|
|
||||||
UserSchema.methods.toJSON = function () {
|
UserSchema.methods.toJSON = function () {
|
||||||
const user = this;
|
const user = this;
|
||||||
|
|||||||
0
src/server/models/variant.js
Normal file → Executable file
0
src/server/models/variant.js
Normal file → Executable file
2
src/server/modules/Cart.js
Normal file → Executable file
2
src/server/modules/Cart.js
Normal file → Executable file
@@ -1,3 +1,4 @@
|
|||||||
|
const shared_consts = require('../tools/shared_nodejs');
|
||||||
const cartModel = require('../models/cart')
|
const cartModel = require('../models/cart')
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const { ObjectID } = require('mongodb');
|
||||||
@@ -76,6 +77,7 @@ class Cart {
|
|||||||
totalQty: this.totalQty,
|
totalQty: this.totalQty,
|
||||||
totalPrice: this.totalPrice,
|
totalPrice: this.totalPrice,
|
||||||
userId: this.userId,
|
userId: this.userId,
|
||||||
|
note: this.note,
|
||||||
modify_at: this.modify_at
|
modify_at: this.modify_at
|
||||||
})
|
})
|
||||||
return newCart
|
return newCart
|
||||||
|
|||||||
0
src/server/modules/ErrorHandler.js
Normal file → Executable file
0
src/server/modules/ErrorHandler.js
Normal file → Executable file
@@ -1,3 +1,5 @@
|
|||||||
|
const shared_consts = require('../tools/shared_nodejs');
|
||||||
|
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
@@ -29,6 +31,7 @@ const paypal = require('paypal-rest-sdk')
|
|||||||
|
|
||||||
const CartClass = require('../modules/Cart')
|
const CartClass = require('../modules/Cart')
|
||||||
const Cart = require('../models/cart');
|
const Cart = require('../models/cart');
|
||||||
|
const OrdersCart = require('../models/orderscart');
|
||||||
|
|
||||||
//GET cart
|
//GET cart
|
||||||
router.get('/:userId', authenticate, function (req, res, next) {
|
router.get('/:userId', authenticate, function (req, res, next) {
|
||||||
@@ -166,5 +169,70 @@ router.put('/:userId', authenticate, function (req, res, next) {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
//POST cart
|
||||||
|
router.post('/:userId/cartstatus', authenticate, async function (req, res, next) {
|
||||||
|
let idapp = req.body.idapp;
|
||||||
|
let userId = req.params.userId;
|
||||||
|
let cart_id = req.body.cart_id;
|
||||||
|
let status = req.body.status;
|
||||||
|
|
||||||
|
const mycart = await Cart.getCartByUserId(userId, idapp);
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (!!mycart) {
|
||||||
|
if (status === shared_consts.OrderStatus.CHECKOUT_CONFIRMED) {
|
||||||
|
// Porta tutto il Cart nell'Ordine
|
||||||
|
const newOrderCart = new OrdersCart({
|
||||||
|
idapp,
|
||||||
|
items: mycart.items,
|
||||||
|
totalQty: mycart.totalQty,
|
||||||
|
totalPrice: mycart.totalPrice,
|
||||||
|
userId,
|
||||||
|
status,
|
||||||
|
note: mycart.note,
|
||||||
|
numorder: await OrdersCart.getNewNumOrder(userId, idapp),
|
||||||
|
created_at: new Date(),
|
||||||
|
modify_at: new Date(),
|
||||||
|
})
|
||||||
|
const myorderlist = OrdersCart.updateOrdersCartById(-1, newOrderCart, function (err, ris) {
|
||||||
|
//if (err) return next(err)
|
||||||
|
if (err)
|
||||||
|
return res.send({ code: server_constants.RIS_CODE_ERR, status: 0 });
|
||||||
|
else {
|
||||||
|
const myris = ris;
|
||||||
|
// Cancella il Cart appena salvato in OrdersCart
|
||||||
|
Cart.deleteCartByCartId(mycart.id)
|
||||||
|
.then((ris) => {
|
||||||
|
const orders = OrdersCart.getOrdersCartByUserId(userId, idapp)
|
||||||
|
.then((orders) => {
|
||||||
|
return res.send({ code: server_constants.RIS_CODE_OK, status: myris.status, orders });
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// mycart.numorder = await Cart.getNewNumOrder(userId, idapp);
|
||||||
|
// mycart.status = shared_consts.OrderStatus.CHECKOUT_CONFIRMED
|
||||||
|
/* const status = await Cart.findOneAndUpdate(
|
||||||
|
{ userId },
|
||||||
|
{
|
||||||
|
$set: {
|
||||||
|
status: mycart.status, numorder: mycart.numorder
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ new: false })
|
||||||
|
.then((rec) => {
|
||||||
|
return rec.status
|
||||||
|
}) */
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
return res.send({ code: server_constants.RIS_CODE_ERR, status: 0 });
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
@@ -54,7 +54,9 @@ const { MsgTemplate } = require('../models/msg_template');
|
|||||||
const Product = require('../models/product');
|
const Product = require('../models/product');
|
||||||
const Producer = require('../models/producer');
|
const Producer = require('../models/producer');
|
||||||
const Cart = require('../models/cart');
|
const Cart = require('../models/cart');
|
||||||
|
const OrdersCart = require('../models/orderscart');
|
||||||
const Storehouse = require('../models/storehouse');
|
const Storehouse = require('../models/storehouse');
|
||||||
|
const ShareWithUs = require('../models/sharewithus');
|
||||||
const Order = require('../models/order');
|
const Order = require('../models/order');
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
@@ -200,6 +202,8 @@ function getTableByTableName(tablename) {
|
|||||||
mytable = Product;
|
mytable = Product;
|
||||||
else if (tablename === 'storehouses')
|
else if (tablename === 'storehouses')
|
||||||
mytable = Storehouse;
|
mytable = Storehouse;
|
||||||
|
else if (tablename === 'sharewithus')
|
||||||
|
mytable = ShareWithUs;
|
||||||
else if (tablename === 'orders')
|
else if (tablename === 'orders')
|
||||||
mytable = Order;
|
mytable = Order;
|
||||||
else if (tablename === 'producers')
|
else if (tablename === 'producers')
|
||||||
@@ -270,7 +274,7 @@ router.post('/settable', authenticate, (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
mytablerec = new mytable(mydata);
|
let mytablerec = new mytable(mydata);
|
||||||
console.log('mytablerec', mytablerec);
|
console.log('mytablerec', mytablerec);
|
||||||
|
|
||||||
|
|
||||||
@@ -993,7 +997,8 @@ router.delete('/delrec/:table/:id', authenticate, async (req, res) => {
|
|||||||
if (!cancellato) {
|
if (!cancellato) {
|
||||||
ris = await mytable.findByIdAndRemove(id).then((rec) => {
|
ris = await mytable.findByIdAndRemove(id).then((rec) => {
|
||||||
if (!rec) {
|
if (!rec) {
|
||||||
return res.status(404).send();
|
// res.status(404).send();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
myrec = rec;
|
myrec = rec;
|
||||||
|
|
||||||
@@ -1012,7 +1017,7 @@ router.delete('/delrec/:table/:id', authenticate, async (req, res) => {
|
|||||||
|
|
||||||
if (cancellato) {
|
if (cancellato) {
|
||||||
// Do extra things after deleted
|
// Do extra things after deleted
|
||||||
let ris2 = await actions.doOtherlasThingsAfterDeleted(tablename, myrec, notifBot, req);
|
//let ris2 = await actions.doOtherlasThingsAfterDeleted(tablename, myrec, notifBot, req);
|
||||||
if (!!ris) {
|
if (!!ris) {
|
||||||
return res.send({ code: server_constants.RIS_CODE_OK, msg: '' });
|
return res.send({ code: server_constants.RIS_CODE_OK, msg: '' });
|
||||||
}
|
}
|
||||||
@@ -1108,6 +1113,7 @@ router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) =>
|
|||||||
let producers = Producer.findAllIdApp(idapp);
|
let producers = Producer.findAllIdApp(idapp);
|
||||||
let storehouses = Storehouse.findAllIdApp(idapp);
|
let storehouses = Storehouse.findAllIdApp(idapp);
|
||||||
let cart = null;
|
let cart = null;
|
||||||
|
let orderscart = null;
|
||||||
if (sall) {
|
if (sall) {
|
||||||
newstosent = Newstosent.findAllIdApp(idapp);
|
newstosent = Newstosent.findAllIdApp(idapp);
|
||||||
}
|
}
|
||||||
@@ -1116,10 +1122,11 @@ router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) =>
|
|||||||
if (req.user) {
|
if (req.user) {
|
||||||
calcstat = User.calculateStat(idapp, req.user.username);
|
calcstat = User.calculateStat(idapp, req.user.username);
|
||||||
cart = Cart.getCartByUserId(req.user.id, idapp);
|
cart = Cart.getCartByUserId(req.user.id, idapp);
|
||||||
|
orderscart = OrdersCart.getOrdersCartByUserId(req.user.id, idapp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return Promise.all([bookedevent, eventlist, operators, wheres, contribtype, settings, permissions, disciplines, newstosent, mailinglist, mypage, gallery, paymenttype, calcstat, calzoom, producers, cart, storehouses])
|
return Promise.all([bookedevent, eventlist, operators, wheres, contribtype, settings, permissions, disciplines, newstosent, mailinglist, mypage, gallery, paymenttype, calcstat, calzoom, producers, cart, storehouses, orderscart])
|
||||||
.then((arrdata) => {
|
.then((arrdata) => {
|
||||||
// console.table(arrdata);
|
// console.table(arrdata);
|
||||||
const myuser = req.user;
|
const myuser = req.user;
|
||||||
@@ -1146,6 +1153,7 @@ router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) =>
|
|||||||
producers: arrdata[15],
|
producers: arrdata[15],
|
||||||
cart: arrdata[16],
|
cart: arrdata[16],
|
||||||
storehouses: arrdata[17],
|
storehouses: arrdata[17],
|
||||||
|
orders: arrdata[18],
|
||||||
myuser,
|
myuser,
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ const Cart = require('../models/cart');
|
|||||||
router.post('/', auth_default, async function (req, res, next) {
|
router.post('/', auth_default, async function (req, res, next) {
|
||||||
const idapp = req.body.idapp;
|
const idapp = req.body.idapp;
|
||||||
|
|
||||||
var products = await Product.findAllIdApp(idapp);
|
var products = await Product.findAllIdApp(idapp, "");
|
||||||
|
|
||||||
if (products)
|
if (products)
|
||||||
res.send({ code: server_constants.RIS_CODE_OK, products });
|
res.send({ code: server_constants.RIS_CODE_OK, products });
|
||||||
@@ -56,5 +56,16 @@ router.post('/', auth_default, async function (req, res, next) {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
router.post('/:code', auth_default, async function (req, res, next) {
|
||||||
|
const idapp = req.body.idapp;
|
||||||
|
const code = req.body.code;
|
||||||
|
|
||||||
|
var product = await Product.findAllIdApp(idapp, code);
|
||||||
|
|
||||||
|
if (product.length > 0) {
|
||||||
|
return res.send({ code: server_constants.RIS_CODE_OK, product: product[0] });
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
@@ -83,6 +83,58 @@ router.post('/', (req, res) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
async function SendMsgToAll(idapp, params) {
|
||||||
|
const arrusers = await User.find({ idapp },
|
||||||
|
{
|
||||||
|
username: 1,
|
||||||
|
name: 1,
|
||||||
|
surname: 1,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
let msgsent = 0;
|
||||||
|
|
||||||
|
for (const user of arrusers) {
|
||||||
|
await SendMsgTo(idapp, user.username, params);
|
||||||
|
msgsent++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return msgsent;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function SendMsgToParam(idapp, params) {
|
||||||
|
const arrusers = await User.find({ idapp },
|
||||||
|
{
|
||||||
|
username: 1,
|
||||||
|
name: 1,
|
||||||
|
surname: 1,
|
||||||
|
'profile.socio': 1,
|
||||||
|
'profile.socioresidente': 1,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
let msgsent = 0;
|
||||||
|
|
||||||
|
for (const user of arrusers) {
|
||||||
|
let invia = false;
|
||||||
|
if (params.typemsg === shared_consts.TypeMsg.SEND_TO_SOCI) {
|
||||||
|
invia = user.profile.socio;
|
||||||
|
}else if (params.typemsg === shared_consts.TypeMsg.SEND_TO_SOCIO_RESIDENTE) {
|
||||||
|
invia = user.profile.socioresidente;
|
||||||
|
}else if (params.typemsg === shared_consts.TypeMsg.SEND_TO_NON_SOCI) {
|
||||||
|
invia = !user.profile.socio;
|
||||||
|
} else {
|
||||||
|
invia = true;
|
||||||
|
}
|
||||||
|
if (invia) {
|
||||||
|
await SendMsgTo(idapp, user.username, params);
|
||||||
|
msgsent++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return msgsent;
|
||||||
|
}
|
||||||
|
|
||||||
async function SendMsgTo(idapp, username, params) {
|
async function SendMsgTo(idapp, username, params) {
|
||||||
|
|
||||||
return await User.find({ idapp, username }).then((arrusers) => {
|
return await User.find({ idapp, username }).then((arrusers) => {
|
||||||
@@ -105,25 +157,6 @@ async function SendMsgTo(idapp, username, params) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function SendMsgToAll(idapp, params) {
|
|
||||||
const arrusers = await User.find({ idapp },
|
|
||||||
{
|
|
||||||
username: 1,
|
|
||||||
name: 1,
|
|
||||||
surname: 1,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
let msgsent = 0;
|
|
||||||
|
|
||||||
for (const user of arrusers) {
|
|
||||||
await SendMsgTo(idapp, user.username, params);
|
|
||||||
msgsent++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return msgsent;
|
|
||||||
}
|
|
||||||
|
|
||||||
router.post('/send', authenticate, async (req, res) => {
|
router.post('/send', authenticate, async (req, res) => {
|
||||||
const idapp = req.body.idapp;
|
const idapp = req.body.idapp;
|
||||||
const params = req.body.params;
|
const params = req.body.params;
|
||||||
@@ -138,9 +171,11 @@ router.post('/send', authenticate, async (req, res) => {
|
|||||||
try {
|
try {
|
||||||
if (params.typemsg === shared_consts.TypeMsg.SEND_TO_ALL) {
|
if (params.typemsg === shared_consts.TypeMsg.SEND_TO_ALL) {
|
||||||
nummsg = await SendMsgToAll(idapp, params);
|
nummsg = await SendMsgToAll(idapp, params);
|
||||||
|
} else {
|
||||||
|
nummsg = await SendMsgToParam(idapp, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.send({ code: server_constants.RIS_CODE_OK, msg: nummsg + ' Msg Inviati !' });
|
return res.send({ code: server_constants.RIS_CODE_OK, msg: nummsg + ' Msg Inviati !', nummsg });
|
||||||
}catch (e) {
|
}catch (e) {
|
||||||
return res.send({ code: server_constants.RIS_CODE_ERR, msg: nummsg + ' Msg Inviati !' });
|
return res.send({ code: server_constants.RIS_CODE_ERR, msg: nummsg + ' Msg Inviati !' });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1628,6 +1628,9 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
ModificheConsentite(table, fieldsvalue, idrec, user) {
|
ModificheConsentite(table, fieldsvalue, idrec, user) {
|
||||||
|
if (table === 'sharewithus') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (table === 'users') {
|
if (table === 'users') {
|
||||||
if ('aportador_solidario' in fieldsvalue) {
|
if ('aportador_solidario' in fieldsvalue) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -39,7 +39,10 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
TypeMsg: {
|
TypeMsg: {
|
||||||
SEND_TO_ALL: 1
|
SEND_TO_ALL: 1,
|
||||||
|
SEND_TO_SOCI: 2,
|
||||||
|
SEND_TO_SOCIO_RESIDENTE: 3,
|
||||||
|
SEND_TO_NON_SOCI: 10
|
||||||
},
|
},
|
||||||
|
|
||||||
TypeMsg_Actions: {
|
TypeMsg_Actions: {
|
||||||
@@ -58,6 +61,17 @@ module.exports = {
|
|||||||
ZOOM_GIA_PARTECIPATO: 510
|
ZOOM_GIA_PARTECIPATO: 510
|
||||||
},
|
},
|
||||||
|
|
||||||
|
OrderStatus: {
|
||||||
|
NONE: 0,
|
||||||
|
IN_CART: 1,
|
||||||
|
CHECKOUT_CONFIRMED: 2,
|
||||||
|
PAYED: 3,
|
||||||
|
DELIVEDED: 4,
|
||||||
|
RECEIVED: 5,
|
||||||
|
CANCELED: 10,
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
fieldsUserToChange() {
|
fieldsUserToChange() {
|
||||||
return ['_id', 'index', 'username', 'email', 'name', 'surname', 'perm', 'date_reg', 'verified_email', 'ipaddr', 'lasttimeonline', 'profile', 'calcstat', 'news_on', 'aportador_solidario', 'made_gift', 'ind_order', 'old_order', 'numinvitati', 'numinvitatiattivi', 'qualified']
|
return ['_id', 'index', 'username', 'email', 'name', 'surname', 'perm', 'date_reg', 'verified_email', 'ipaddr', 'lasttimeonline', 'profile', 'calcstat', 'news_on', 'aportador_solidario', 'made_gift', 'ind_order', 'old_order', 'numinvitati', 'numinvitatiattivi', 'qualified']
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user