def lists_get(page=1): """ 提现申请列表 """ user_id = current_user.id # 判断基本信息和银行信息是否完整 if not user_profile_is_complete(user_id): flash(u'请先完善基本信息', 'warning') return redirect(url_for('user.profile')) if not user_profile_is_complete(user_id): flash(u'请先完善银行信息', 'warning') return redirect(url_for('user.bank')) # 判断是否激活 if current_user.status_active == int(STATUS_ACTIVE_NO): flash(u'请先激活当前账号', 'warning') return redirect(url_for('user.profile')) condition = [ ApplyGet.user_id == user_id, ApplyGet.status_delete == int(STATUS_DEL_NO) ] # 订单状态 status_order = request.args.get('status_order', 0, type=int) if status_order == int(STATUS_ORDER_COMPLETED): condition.append(ApplyGet.status_order == int(STATUS_ORDER_COMPLETED)) else: condition.append(ApplyGet.status_order < int(STATUS_ORDER_COMPLETED)) pagination = get_apply_get_rows(page, PER_PAGE_FRONTEND, *condition) return render_template('apply/get_list.html', title='apply_get_list', pagination=pagination)
def add_get(): """ 创建提现申请 :return: """ user_id = current_user.id # 判断基本信息和银行信息是否完整 if not user_profile_is_complete(user_id): flash(u'请先完善基本信息', 'warning') return redirect(url_for('user.profile')) if not user_profile_is_complete(user_id): flash(u'请先完善银行信息', 'warning') return redirect(url_for('user.bank')) # 判断是否激活 if current_user.status_active == int(STATUS_ACTIVE_NO): flash(u'请先激活当前账号', 'warning') return redirect(url_for('user.profile')) # 获取团队成员三级树形结构 team_tree = get_team_tree(current_user.id) # 单次提现金额范围 APPLY_GET_MIN_EACH = Decimal(get_conf('APPLY_GET_MIN_EACH')) # 最小值 APPLY_GET_MAX_EACH = Decimal(get_conf('APPLY_GET_MAX_EACH')) # 最大值 APPLY_GET_STEP = Decimal(get_conf('APPLY_GET_STEP')) # 投资金额步长(基数) form = ApplyGetAddForm(request.form) if request.method == 'POST': if form.validate_on_submit(): type_pay = form.type_pay.data type_withdraw = form.type_withdraw.data money_apply = form.money_apply.data try: result = user_apply_get(user_id, type_pay, type_withdraw, money_apply) if result: flash(u'申请成功', 'success') return redirect(url_for('apply.lists_get')) except Exception as e: flash(u'申请失败, 原因:%s' % e.message, 'warning') return render_template('apply/get_add.html', title='apply_get_add', form=form, APPLY_GET_MIN_EACH=str(APPLY_GET_MIN_EACH), APPLY_GET_MAX_EACH=str(APPLY_GET_MAX_EACH), APPLY_GET_STEP=str(APPLY_GET_STEP), team_tree=team_tree)
def lists_put(page=1): """ 投资订单列表 """ user_id = current_user.id # 判断基本信息和银行信息是否完整 if not user_profile_is_complete(user_id): flash(u'请先完善基本信息', 'warning') return redirect(url_for('user.profile')) if not user_bank_is_complete(user_id): flash(u'请先完善银行信息', 'warning') return redirect(url_for('user.bank')) # 判断是否激活 if current_user.status_active == int(STATUS_ACTIVE_NO): flash(u'请先激活当前账号', 'warning') return redirect(url_for('user.profile')) # 支付状态(默认未处理) status_pay = request.args.get('status_pay', 0, type=int) search_condition_order = [ Order.apply_put_uid == user_id, Order.status_delete == STATUS_DEL_NO, # 默认未删除 ] if status_pay in STATUS_PAY_DICT: search_condition_order.append(Order.status_pay == status_pay) try: pagination = Order.query. \ filter(*search_condition_order). \ outerjoin(UserProfile, Order.apply_get_uid == UserProfile.user_id). \ add_entity(UserProfile). \ order_by(Order.id.desc()). \ paginate(page, PER_PAGE_FRONTEND, False) db.session.commit() return render_template('order/put_list.html', title='order_put_list', pagination=pagination) except Exception as e: db.session.rollback() flash(e.message, category='warning') return redirect(url_for('index'))
def add_put(): """ 创建投资申请 :return: """ user_id = current_user.id # 判断基本信息和银行信息是否完整 if not user_profile_is_complete(user_id): flash(u'请先完善基本信息', 'warning') return redirect(url_for('user.profile')) if not user_profile_is_complete(user_id): flash(u'请先完善银行信息', 'warning') return redirect(url_for('user.bank')) # 判断是否激活 if current_user.status_active == int(STATUS_ACTIVE_NO): flash(u'请先激活当前账号', 'warning') return redirect(url_for('user.profile')) # 获取团队成员三级树形结构 team_tree = get_team_tree(current_user.id) # 单次投资金额范围 APPLY_PUT_MIN_EACH = Decimal(get_conf('APPLY_PUT_MIN_EACH')) # 最小值 APPLY_PUT_MAX_EACH = Decimal(get_conf('APPLY_PUT_MAX_EACH')) # 最大值 APPLY_PUT_STEP = Decimal(get_conf('APPLY_PUT_STEP')) # 投资金额步长(基数) form = ApplyPutAddForm(request.form) if request.method == 'POST': if form.validate_on_submit(): current_time = datetime.utcnow() # 新增投资申请明细 apply_put_info = { 'user_id': user_id, 'type_apply': TYPE_APPLY_USER, 'type_pay': form.type_pay.data, 'money_apply': form.money_apply.data, 'status_apply': STATUS_APPLY_SUCCESS, 'status_order': STATUS_ORDER_HANDING, 'status_delete': STATUS_DEL_NO, 'create_time': current_time, 'update_time': current_time, } apply_put_id = add_apply_put(apply_put_info) # 消耗排单币 scheduling_cost = form.money_apply.data / 100 # 扣除排单币总表数量 scheduling_info = get_scheduling_row_by_id(user_id) amount = scheduling_info.amount if scheduling_info else 0 scheduling_data = { 'amount': amount - scheduling_cost, 'create_time': current_time, 'update_time': current_time } edit_scheduling(user_id, scheduling_data) # 新增排单币明细 scheduling_item_data = { 'user_id': user_id, 'type': user_id, 'amount': scheduling_cost, 'sc_id': user_id, 'note': u'投资申请编号:%s' % apply_put_id, 'status_audit': STATUS_AUDIT_SUCCESS, 'audit_time': current_time, 'create_time': current_time, 'update_time': current_time } add_scheduling_item(scheduling_item_data) if apply_put_id: # 加入投资申请本息回收队列 q = RabbitDelayQueue( exchange=EXCHANGE_NAME, queue_name='apply_put_interest_on_principal', ttl=APPLY_PUT_INTEREST_ON_PRINCIPAL_TTL) msg = { 'user_id': user_id, 'apply_put_id': apply_put_id, 'apply_time': current_time.strftime('%Y-%m-%d %H:%M:%S') } q.put(msg) q.close_conn() flash(u'申请成功', 'success') else: flash(u'申请失败', 'warning') return redirect(url_for('apply.lists_put')) return render_template('apply/put_add.html', title='apply_put_add', form=form, APPLY_PUT_MIN_EACH=str(APPLY_PUT_MIN_EACH), APPLY_PUT_MAX_EACH=str(APPLY_PUT_MAX_EACH), APPLY_PUT_STEP=str(APPLY_PUT_STEP), team_tree=team_tree)