Esempio n. 1
0
 def refund(id, amount, type, description):
     user = UserBiz.get_user_by_id(id)
     if not user:
         raise DaixieError(USER_NOT_EXIST)
     try:
         user.account -= int(amount)
         db_session.add(user)
         db_session.commit()
         TransactionBiz.create(id, amount, user.account, type, description)
     except:
         raise DaixieError(REFUND_FAIL)
     return REFUND_SUCCESS
Esempio n. 2
0
 def recharge(id, amount, type, description):
     user = UserBiz.get_user_by_id(id)
     if not user:
         raise DaixieError(USER_NOT_EXIST)
     try:
         user.account += int(amount)
         db_session.add(user)
         db_session.commit()
     except:
         raise DaixieError(RECHARGE_FAIL)
     else:
         TransactionBiz.create(id, amount, user.account, type, description)
     return RECHARGE_SUCCESS
Esempio n. 3
0
 def pay(id, amount, type, description):
     user = UserBiz.get_user_by_id(id)
     if not user:
         raise DaixieError(USER_NOT_EXIST)
     try:
         print amount
         user.account = user.account - amount
         print user.account
         db_session.add(user)
         print "committing user"
         db_session.commit()
         TransactionBiz.create(id, amount, user.account, type, description)
     except:
         raise DaixieError(REFUND_FAIL)
     return REFUND_SUCCESS