Ejemplo n.º 1
0
	def edit_order(order):
		o = OrderBiz.get_order_by_id(order.id).first()
		user = UserBiz.get_user_by_id(order.user_id)

		if o is None:
			raise DaixieError(ORDER_NOT_EXIST)

		if o.status >= '1' and order.actual_order_price != 0:
			try:
				amount = float(o.expect_order_price)-float(order.actual_order_price)
				if amount>0:
					UserBiz.refund(o.user_id, abs(amount), type=Transaction.TYPE.REFUND, description=u'订单最终价格调整')
				else:
					if user.account < abs(amount):
						raise DaixieError(u'用户的余额不足,无法填写订单实际价格,修改失败')
					UserBiz.recharge(o.user_id, abs(amount), type=Transaction.TYPE.PAY, description=u'订单最终价格调整')
			except DaixieError as e:
				raise e

		try:
			db_session.add(order)
			db_session.commit()
		except:
			raise DaixieError(EDIT_ORDER_FAIL)
		return EDIT_ORDER_OK
Ejemplo n.º 2
0
    def register(user):
        if UserBiz.get_user_by_email(user.email):
            raise DaixieError(USER_DUPLICATE)
        db_session.add(user)
        db_session.commit()

        return USER_REGISTER_OK
Ejemplo n.º 3
0
 def register(user):
     if UserBiz.get_user_by_email(user.email):
         raise DaixieError(USER_DUPLICATE)
     db_session.add(user)
     db_session.commit()
     
     return USER_REGISTER_OK
Ejemplo n.º 4
0
 def add_solver(solver):
     if AdminBiz.get_admin_by_email(solver.email):
         raise DaixieError(USER_DUPLICATE)
     solver.type = Admin.ADMIN_TYPE.SOLVER
     db_session.add(solver)
     db_session.commit()
     return CS_ADD_OK
Ejemplo n.º 5
0
 def add_solver(solver):
     if AdminBiz.get_admin_by_email(solver.email):
         raise DaixieError(USER_DUPLICATE)
     solver.type = Admin.ADMIN_TYPE.SOLVER
     db_session.add(solver)
     db_session.commit()
     return CS_ADD_OK
Ejemplo n.º 6
0
 def edit_user_profile(user):
     try:
         db_session.add(user)
         db_session.commit()
         login_user(user, remember=True)
     except:
         raise DaixieError(EDIT_USER_PROFILE_FAIL)
     return EDIT_USER_PROFILE_OK
Ejemplo n.º 7
0
 def edit_user_profile(user):
     try:
         db_session.add(user)
         db_session.commit()
         login_user(user, remember=True)
     except:
         raise DaixieError(EDIT_USER_PROFILE_FAIL)
     return EDIT_USER_PROFILE_OK
Ejemplo n.º 8
0
	def create_order(order):
		try:
			db_session.add(order)
			db_session.commit()	
			order.id += 17394000
			db_session.add(order)
			db_session.commit()	 	
		except:
			raise DaixieError(CREATE_ORDER_FAIL)
		return CREATE_ORDER_OK
Ejemplo n.º 9
0
 def create(user_id, amount, account, type, description):
     try:
         transaction = Transaction(user_id, amount, account, type, description)
         db_session.add(transaction)
         db_session.commit()
         transaction.id += 23714000
         db_session.add(transaction)
         db_session.commit()
     except:
         raise DaixieError(u'生成交易记录失败')
Ejemplo n.º 10
0
 def create(user_id, amount, account, type, description):
     try:
         transaction = Transaction(user_id, amount, account, type,
                                   description)
         db_session.add(transaction)
         db_session.commit()
         transaction.id += 23714000
         db_session.add(transaction)
         db_session.commit()
     except:
         raise DaixieError(u'生成交易记录失败')
Ejemplo n.º 11
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 -= float(amount)
         db_session.add(user)
         db_session.commit()
         TransactionBiz.create(id, amount, user.account, type, description)
     except:
         raise DaixieError(REFUND_FAIL)
     return RECHARGE_SUCCESS
Ejemplo n.º 12
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 -= float(amount)
         db_session.add(user)
         db_session.commit()
         TransactionBiz.create(id, amount, user.account, type, description)
     except:
         raise DaixieError(REFUND_FAIL)
     return RECHARGE_SUCCESS
Ejemplo n.º 13
0
 def add_solver(user):
     if UserBiz.get_user_by_email(user.email):
         raise DaixieError(USER_DUPLICATE)
     db_session.add(user)
     db_session.commit()
     return SOLVER_ADD_OK
Ejemplo n.º 14
0
 def add_CS(cs):
     if AdminBiz.get_admin_by_email(cs.email):
         raise DaixieError(USER_DUPLICATE)
     db_session.add(cs)
     db_session.commit()
     return CS_ADD_OK
Ejemplo n.º 15
0
 def add_solver(user):
     if UserBiz.get_user_by_email(user.email):
         raise DaixieError(USER_DUPLICATE)
     db_session.add(user)
     db_session.commit()
     return SOLVER_ADD_OK
Ejemplo n.º 16
0
 def add_CS(cs):
     if AdminBiz.get_admin_by_email(cs.email):
         raise DaixieError(USER_DUPLICATE)
     db_session.add(cs)
     db_session.commit()
     return CS_ADD_OK