forked from github/server
vin skripte verfeinert
This commit is contained in:
parent
5663209167
commit
86912c69de
|
@ -1,6 +1,6 @@
|
||||||
select distinct u.id ID, s.faction Partei, left(concat(firstname,' ',lastname, ' <',email,'>'),43) Name, sum(t.balance) Kontostand
|
select distinct u.id ID, concat(s.game, '/', s.faction) Partei, left(concat(firstname,' ',lastname, ' <',email,'>'),43) Name, sum(t.balance) Kontostand
|
||||||
from users u, transactions t, subscriptions s
|
from users u, transactions t, subscriptions s
|
||||||
where u.id=t.user and u.id=s.user
|
where u.id=t.user and u.id=s.user
|
||||||
and s.status='ACTIVE'
|
and s.status='ACTIVE'
|
||||||
GROUP BY s.faction
|
GROUP BY s.faction
|
||||||
HAVING Kontostand<2.5;
|
HAVING Kontostand<5;
|
||||||
|
|
|
@ -9,7 +9,8 @@ dryrun=0
|
||||||
if len(sys.argv)>2:
|
if len(sys.argv)>2:
|
||||||
dryrun=1
|
dryrun=1
|
||||||
price=1.25
|
price=1.25
|
||||||
warnahead=2
|
warnahead=4
|
||||||
|
cancelafter=1
|
||||||
db=MySQLdb.connect(db=dbname)
|
db=MySQLdb.connect(db=dbname)
|
||||||
cursor=db.cursor()
|
cursor=db.cursor()
|
||||||
|
|
||||||
|
@ -18,28 +19,41 @@ server=smtplib.SMTP('localhost')
|
||||||
while users > 0:
|
while users > 0:
|
||||||
users=users-1
|
users=users-1
|
||||||
email, uid, games = cursor.fetchone()
|
email, uid, games = cursor.fetchone()
|
||||||
|
if games==0:
|
||||||
|
continue
|
||||||
c2 = db.cursor()
|
c2 = db.cursor()
|
||||||
t = c2.execute("select sum(balance) from transactions where user="+str(int(uid)))
|
t = c2.execute("select sum(balance) from transactions where user="+str(int(uid)))
|
||||||
if t==0:
|
if t==0:
|
||||||
balance=0.0
|
balance=0.0
|
||||||
else:
|
else:
|
||||||
balance = c2.fetchone()[0]
|
balance = c2.fetchone()[0]
|
||||||
if balance < games*warnahead*price:
|
Msg=None
|
||||||
print "Warning "+email+", uid="+str(int(uid))+", balance="+str(balance)+", games="+str(int(games))
|
if balance <= games*warnahead*price:
|
||||||
Msg = ("From: Vinyambar Buchhaltung <"+From+">\nTo: "+email+"\nSubject: Vinyambar Kontostand, Warnung.\n\n"+
|
Msg = ("From: Vinyambar Buchhaltung <"+From+">\nTo: "+email+"\n")
|
||||||
"Dein Vinyambar Kontostand reicht nicht mehr aus, um die kommenden "+str(warnahead)+"\n"+
|
if balance <= -games*cancelafter*price:
|
||||||
"Wochen zu bezahlen. Bitte mache baldmöglichst eine neue Überweisung\n"
|
Msg=Msg+"Subject: Vinyambar Abmeldung Kunde "+str(int(uid))+".\n\n"
|
||||||
"auf das Vinyambar-Konto.\n\n"+
|
Msg = Msg+("Nachdem Dein Konto bei uns im Minus ist, haben wir deine\n"+
|
||||||
"Kundennummer: "+str(uid)+"\n"+
|
"Anmeldung bei Vinyambar gekündigt, und die Partei(en) der Parteibörse\n"+
|
||||||
"Kontostand: "+str(balance)+" EUR\n"+
|
"zugeführt.\n")
|
||||||
"\n"+
|
print "CANCEL: "+email+", uid="+str(int(uid))+", balance="+str(balance)+", games="+str(int(games))
|
||||||
"Unser Konto: Katja Zedel\n"+
|
|
||||||
"Kontonummer 1251 886 106\n"+
|
|
||||||
"BLZ 500 502 01 (Frankfurter Sparkasse)\n")
|
|
||||||
try:
|
|
||||||
# print Msg
|
|
||||||
if dryrun==0:
|
if dryrun==0:
|
||||||
server.sendmail(From, email, Msg)
|
c2.execute("UPDATE subscriptions set user=0, status='CANCELLED' where user="+str(int(uid)))
|
||||||
|
else:
|
||||||
|
print "WARNING: "+email+", uid="+str(int(uid))+", balance="+str(balance)+", games="+str(int(games))
|
||||||
|
Msg = Msg+"Subject: WARNUNG - Vinyambar Kontostand Kunde "+str(int(uid))+"\n\n"
|
||||||
|
Msg = Msg+("Dein Vinyambar Kontostand reicht nicht mehr aus, um die kommenden "+str(warnahead)+"\n"+
|
||||||
|
"Wochen zu bezahlen. Bitte mache baldmöglichst eine neue Überweisung\n"
|
||||||
|
"auf das Vinyambar-Konto.\n\n"+
|
||||||
|
"Kundennummer: "+str(uid)+"\n"+
|
||||||
|
"Kontostand: "+str(balance)+" EUR\n"+
|
||||||
|
"\n"+
|
||||||
|
"Unser Konto: Katja Zedel\n"+
|
||||||
|
"Kontonummer 1251 886 106\n"+
|
||||||
|
"BLZ 500 502 01 (Frankfurter Sparkasse)\n")
|
||||||
|
|
||||||
|
if (Msg!=None) and dryrun==0:
|
||||||
|
try:
|
||||||
|
server.sendmail(From, email, Msg)
|
||||||
except:
|
except:
|
||||||
print "Could not send confirmation to "+email
|
print "Could not send confirmation to "+email
|
||||||
print "Exception is:", sys.exc_type, ":", sys.exc_value
|
print "Exception is:", sys.exc_type, ":", sys.exc_value
|
||||||
|
|
|
@ -36,7 +36,7 @@ print "Removing "+str(int(k))+" transfered subscriptions."
|
||||||
k = cursor.execute("UPDATE subscriptions SET user=0 where game="+str(int(game))+" and status='CANCELLED' and updated<'"+date+"'")
|
k = cursor.execute("UPDATE subscriptions SET user=0 where game="+str(int(game))+" and status='CANCELLED' and updated<'"+date+"'")
|
||||||
print "Removing "+str(int(k))+" cancelled subscriptions."
|
print "Removing "+str(int(k))+" cancelled subscriptions."
|
||||||
|
|
||||||
k = cursor.execute("UPDATE subscriptions SET user=0 where game="+str(int(game))+" and status='DEAD' and updated<'"+date+"'")
|
k = cursor.execute("UPDATE subscriptions SET user=0 where game="+str(int(game))+" and status='DEAD'")
|
||||||
print "Removing "+str(int(k))+" dead subscriptions."
|
print "Removing "+str(int(k))+" dead subscriptions."
|
||||||
|
|
||||||
k = cursor.execute("UPDATE subscriptions SET status='CANCELLED' where game="+str(int(game))+" and status='ACTIVE' and lastturn+3<="+str(lastturn))
|
k = cursor.execute("UPDATE subscriptions SET status='CANCELLED' where game="+str(int(game))+" and status='ACTIVE' and lastturn+3<="+str(lastturn))
|
||||||
|
|
Loading…
Reference in New Issue