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
def delete_solver(id): ''' delete cs ''' if not current_user.is_authenticated(): return redirect(url_for('general.index')) solver = UserBiz.get_user_by_id(id) try: ret = UserBiz.delete_solver(solver) success(ret) except DaixieError as e: fail(e) return redirect(url_for('.cs_list'))
def update_solver(id): ''' update solver ''' if not current_user.is_authenticated(): return redirect(url_for('general.index')) solver=UserBiz.get_user_by_id(id); form = AccountForm(); if not form.validate_on_submit(): return render_template('admin/update.html', form=form, id=id, type="SOLVER", nav_user_manage='active') try: solver.passwd = form.passwd.data ret = UserBiz.solver_commit_update(solver=solver) except DaixieError as e: fail(e) return redirect(url_for('.cs_list')) success(ret) return redirect(url_for('.cs_list'))
def update_solver(id): ''' update solver ''' if not current_user.is_authenticated(): return redirect(url_for('general.index')) solver = UserBiz.get_user_by_id(id) form = AccountForm() if not form.validate_on_submit(): return render_template('admin/update.html', form=form, id=id, type="SOLVER", nav_user_manage='active') try: solver.passwd = form.passwd.data ret = UserBiz.solver_commit_update(solver=solver) except DaixieError as e: fail(e) return redirect(url_for('.cs_list')) success(ret) return redirect(url_for('.cs_list'))
def user_email(self): from daixieadmin.biz.user import UserBiz user = UserBiz.get_user_by_id(self.user_id) return user.email