vin skripte verfeinert

This commit is contained in:
Enno Rehling 2002-03-31 17:12:17 +00:00
parent 5663209167
commit 86912c69de
3 changed files with 33 additions and 19 deletions

View File

@ -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
where u.id=t.user and u.id=s.user
and s.status='ACTIVE'
GROUP BY s.faction
HAVING Kontostand<2.5;
HAVING Kontostand<5;

View File

@ -9,7 +9,8 @@ dryrun=0
if len(sys.argv)>2:
dryrun=1
price=1.25
warnahead=2
warnahead=4
cancelafter=1
db=MySQLdb.connect(db=dbname)
cursor=db.cursor()
@ -18,28 +19,41 @@ server=smtplib.SMTP('localhost')
while users > 0:
users=users-1
email, uid, games = cursor.fetchone()
if games==0:
continue
c2 = db.cursor()
t = c2.execute("select sum(balance) from transactions where user="+str(int(uid)))
if t==0:
balance=0.0
else:
balance = c2.fetchone()[0]
if balance < games*warnahead*price:
print "Warning "+email+", uid="+str(int(uid))+", balance="+str(balance)+", games="+str(int(games))
Msg = ("From: Vinyambar Buchhaltung <"+From+">\nTo: "+email+"\nSubject: Vinyambar Kontostand, Warnung.\n\n"+
"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")
try:
# print Msg
Msg=None
if balance <= games*warnahead*price:
Msg = ("From: Vinyambar Buchhaltung <"+From+">\nTo: "+email+"\n")
if balance <= -games*cancelafter*price:
Msg=Msg+"Subject: Vinyambar Abmeldung Kunde "+str(int(uid))+".\n\n"
Msg = Msg+("Nachdem Dein Konto bei uns im Minus ist, haben wir deine\n"+
"Anmeldung bei Vinyambar gekündigt, und die Partei(en) der Parteibörse\n"+
"zugeführt.\n")
print "CANCEL: "+email+", uid="+str(int(uid))+", balance="+str(balance)+", games="+str(int(games))
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:
print "Could not send confirmation to "+email
print "Exception is:", sys.exc_type, ":", sys.exc_value

View File

@ -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+"'")
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."
k = cursor.execute("UPDATE subscriptions SET status='CANCELLED' where game="+str(int(game))+" and status='ACTIVE' and lastturn+3<="+str(lastturn))