Ejemplo n.º 1
0
def order():
    setting_form = OrderSettingForm()
    if request.method == 'POST':
        print setting_form.data
        if setting_form.validate():
            params = setting_form.data

            params['order_sell_rate'] = str(
                params['order_sell_rate'] if params['order_sell_rate'] else 0)
            params['order_amount_min'] = str(params['order_amount_min'] if
                                             params['order_amount_min'] else 0)
            params['order_amount_max'] = str(params['order_amount_max'] if
                                             params['order_amount_max'] else 0)
            params['order_fee_rate'] = str(
                params['order_fee_rate'] if params['order_fee_rate'] else 0)
            params['order_price_min'] = str(
                params['order_price_min'] if params['order_price_min'] else 0)
            params['order_price_max'] = str(
                params['order_price_max'] if params['order_price_max'] else 0)

            print params
            return jsonify(Api.put('/admin/setting/sys', params))
        else:
            raise AppError.invalid_request(setting_form.errors)
    else:
        data = Api.get('/admin/setting/sys')['value']

        setting_form.process(data=data)
        return render_template('setting/order.html', setting_form=setting_form)
Ejemplo n.º 2
0
def ajax_add_user():
    add_user_form = AddUserForm()
    if add_user_form.data['id']:
        add_user_form.password.validators = []
        add_user_form.confirm_password.validators = []
    if add_user_form.validate():
        permission = {}
        for item in add_user_form.permission.data:
            permission[item] = api_permission[item]
        if add_user_form.data['id']:
            data = Api.put(
                '/admin/user/' + urllib2.quote(add_user_form.id.data), {
                    'uid': add_user_form.uid.data,
                    'password': add_user_form.password.data,
                    'permission': permission
                })
        else:
            data = Api.post(
                '/admin/user', {
                    'uid': add_user_form.uid.data,
                    'password': add_user_form.password.data,
                    'permission': permission
                })
        return jsonify(data)
    else:
        raise ApiError(AppError.INVALID_REQUEST, add_user_form.errors)
Ejemplo n.º 3
0
def details(member_id):
    deposit_form = DepositForm()
    change_password_form = ChangePasswordForm()
    change_security_form = ChangeSecurityForm()
    change_profile_form = ChangeProfileForm()
    payment_form = PaymentForm()
    data = Api.get('/admin/member/detail/' + urllib2.quote(member_id))
    change_security_form.security_id.data = data['id']
    change_password_form.password_id.data = data['id']
    change_profile_form.id.data = data['id']
    deposit_form.id.data = data['assets']['id']
    payment_form.user_id.data = data['id']
    change_profile_form.mobile.data = data['mobile']
    change_profile_form.name.data = data['name']
    change_profile_form.wechat.data = data['wechat']
    payment_list = Api.get('/admin/payment/list',
                           {'user_id': data['id']})['objects']

    payment_dic = {}
    payment_flag = [
        'bank_payment', 'wechat_payment', 'alipay_payment', 'usdt_payment'
    ]
    for item in payment_list:
        payment_dic[payment_flag[item['type']]] = item

    return render_template('member/details.html',
                           data=data,
                           payment_dic=payment_dic,
                           payment_form=payment_form,
                           change_password_form=change_password_form,
                           change_profile_form=change_profile_form,
                           change_security_form=change_security_form,
                           deposit_form=deposit_form)
Ejemplo n.º 4
0
def details(id):
    change_status_form = ChangeStatusForm()
    data = Api.get('/admin/mall/order/' + urllib2.quote(id))
    change_status_form.id.data = data['id']
    change_status_form.status.data = data['status']
    product = Api.get('/admin/mall/' + urllib2.quote(data['product_id']))
    return render_template('order/details.html',
                           data=data,
                           product=product,
                           change_status_form=change_status_form)
Ejemplo n.º 5
0
def ajax_product_modify():
    product_form = ResellerForm()
    if product_form.validate():
        params = product_form.data
        if product_form.id.data:
            data = Api.put('/admin/reseller/' + urllib2.quote(product_form.id.data), params)
        else:
            data = Api.post('/admin/reseller', params)
        return jsonify(data)
    else:
        raise ApiError(AppError.INVALID_REQUEST, product_form.errors)
Ejemplo n.º 6
0
def ajax_register_member():
    form = RegisterForm()
    if form.validate():
        data = form.data
        return jsonify(Api.post('/admin/member', data))
    else:
        raise ApiError(AppError.INVALID_REQUEST, form.errors)
Ejemplo n.º 7
0
def ajax_match_task():
    match_form = MatchOrderForm()
    if match_form.validate():
        data = Api.post('/admin/order/start_match', match_form.data)
        return jsonify(data)
    else:
        raise ApiError(AppError.INVALID_REQUEST, match_form.errors)
Ejemplo n.º 8
0
Archivo: home.py Proyecto: q25979/tdb99
def login():
    login_form = LoginForm()
    error = None
    if request.method == 'POST' and login_form.validate():
        try:
            data = Api.post(
                '/admin/user/login', {
                    'uid': login_form.uid.data,
                    'password': login_form.password.data,
                    'uuid': login_form.uuid.data,
                    'pin_code': login_form.captcha.data
                })
            session['uid'] = login_form.uid.data
            session['token'] = data['token']
            session['role'] = data['role']
            session['permission'] = data['permission']

            return redirect(url_for('home.index'))
        except ApiError as e:
            if 'id' in e.message or 'password' in e.message:
                error = u'用户名或密码错误'
            elif 'uuid' in e.message or 'pin_code' in e.message:
                error = u'验证码错误'
            elif 'locked' in e.message:
                error = u'账号已被锁定'
            elif 'uid' in e.message:

                error = u'账号不存在'
            else:
                error = u'登录错误'
    login_form.captcha.data = None
    return render_template('login.html', form=login_form, login_error=error)
Ejemplo n.º 9
0
def withdraw_download():
    params = {}
    for key, value in request.args.items():
        if value != '':
            params[key] = value

    params['per_page'] = 10000
    if params.get('created_begin_timestamp'):
        params['created_begin_timestamp'] = int(
            time.mktime(
                time.strptime(params['created_begin_timestamp'],
                              u"%Y年%m月%d日")))
    if params.get('created_end_timestamp'):
        params['created_end_timestamp'] = int(
            time.mktime(
                time.strptime(params['created_end_timestamp'] + u' 23:59:59',
                              u"%Y年%m月%d日 %H:%M:%S")))

    params['per_page'] = 10000
    member_data = Api.get('/admin/withdraw', params)
    status = dict(STATUS_FLAG)
    fields = [[u'时间', u'用户编号', u'提现数量', u'手续费', u'提现地址', u'交易哈希', u'状态']]

    data = [[
        timestamp_to_str(y['created_timestamp']), y['user']['uid'],
        format_currency(y['amount']),
        format_currency(y['fee']), y['address'], y['txid'], status[y['status']]
    ] for y in member_data['items']]

    return excel.make_response_from_array(fields + data, "xls", file_name='提现')
Ejemplo n.º 10
0
def ajax_deposit():
    deposit_form = DepositForm()
    if deposit_form.validate():
        data = Api.post('/admin/assets/recharge', deposit_form.data)
        return jsonify(data)
    else:
        raise ApiError(AppError.INVALID_REQUEST, deposit_form.errors)
Ejemplo n.º 11
0
Archivo: news.py Proyecto: q25979/tdb99
def ajax_save():
    form = NewsForm()
    if form.validate():
        data = form.data
        news_id = data.pop('id')
        # detail_data = data['details']
        # details_hash = utils.md5hex(detail_data)
        # data['details'] = upload.put_oss('news/%s.html' % details_hash, detail_data)
        if news_id:
            result = Api.put('/admin/news/details/' + urllib2.quote(news_id),
                             data)
        else:
            result = Api.post('/admin/news', data)
        return jsonify(result)
    else:
        raise ApiError(AppError.INVALID_REQUEST, form.errors)
Ejemplo n.º 12
0
def ajax_add_payment():
    payment_form = PaymentForm()
    if payment_form.validate():
        data = Api.post('/admin/payment/list', payment_form.data)
        return jsonify(data)
    else:
        raise ApiError(AppError.INVALID_REQUEST, payment_form.errors)
Ejemplo n.º 13
0
def details(reseller_id=None):
    reseller_form = ResellerForm()
    if reseller_id:
        data = Api.get('/admin/reseller/' + urllib2.quote(reseller_id))
        reseller_form.process(data=data)
        reseller_form.user_uid.data = data['user']['uid']
    return render_template('reseller/details.html', reseller_form=reseller_form)
Ejemplo n.º 14
0
def record_download():
    params = {}
    for key, value in request.args.items():
        if value != '':
            params[key] = value

    params['per_page'] = 10000
    if params.get('created_begin_timestamp'):
        params['created_begin_timestamp'] = int(
            time.mktime(
                time.strptime(params['created_begin_timestamp'],
                              u"%Y年%m月%d日")))
    if params.get('created_end_timestamp'):
        params['created_end_timestamp'] = int(
            time.mktime(
                time.strptime(params['created_end_timestamp'] + u' 23:59:59',
                              u"%Y年%m月%d日 %H:%M:%S")))

    params['per_page'] = 10000
    member_data = Api.get('/admin/wallet/record', params)
    wallet_type = dict(WALLET_TYPE_FLAG)
    type_flag = dict(TYPE_FLAG)

    fields = [[u'创建时间', u'用户编号', u'变化后余额', u'变化量', u'钱包类型', u'来源', u'详情信息']]

    data = [[
        timestamp_to_str(y['created_timestamp']), y['user']['uid'],
        format_currency(y['current_amount']),
        format_currency(y['delta_amount']), wallet_type[y['wallet_type']],
        type_flag[y['type']], y['details']['message']
    ] for y in member_data['items']]

    return excel.make_response_from_array(fields + data,
                                          "xls",
                                          file_name='钱包记录')
Ejemplo n.º 15
0
def details(message_id=None):
    form = MessageForm()
    message_detail = Api.get('/admin/message/detail/' +
                             urllib2.quote(message_id))
    form.process(data=message_detail)
    return render_template('message/detail.html',
                           message_detail=message_detail,
                           form=form)
Ejemplo n.º 16
0
def ajax_change_password():
    change_password_form = ChangePasswordForm()
    if change_password_form.validate():
        data = Api.put(
            '/admin/user/' + urllib2.quote(change_password_form.id.data),
            {'password': change_password_form.password.data})
        return jsonify(data)
    else:
        raise ApiError(AppError.INVALID_REQUEST, change_password_form.errors)
Ejemplo n.º 17
0
def ajax_change_role():
    change_role_form = ChangeRoleForm()
    if change_role_form.validate():
        data = Api.put(
            '/admin/user/' + urllib2.quote(change_role_form.user_id.data),
            {'role': change_role_form.role.data})
        return jsonify(data)
    else:
        raise ApiError(AppError.INVALID_REQUEST, change_role_form.errors)
Ejemplo n.º 18
0
def analyze():
    filter_form = FilterForm()
    params = filter_params(filter_form)
    analysis_data = Api.get('/admin/wallet/day/statistics', params)

    data = [[
        k,
        format_currency(v.get('recharge', '0')),
        format_currency(v.get('deduction', '0')),
        format_currency(v.get('static_profit', '0')),
        format_currency(v.get('dynamic_profit', '0')),
        format_currency(v.get('node_profit', '0')),
        format_currency(v.get('free_coin', '0')),
        format_currency(v.get('transfer', '0')),
        format_currency(v.get('withdraw', '0')),
        format_currency(v.get('block_recharge', '0')),
        format_currency(v.get('buy_product', '0')),
        format_currency(v.get('reinvestment', '0')),
        format_currency(v.get('buy_order', '0')),
        format_currency(v.get('sell_order', '0')),
    ] for k, v in analysis_data.items()]
    day_data = sorted(data, key=lambda x: x[0])

    recharge = sum([decimal.Decimal(x[1]) for x in data])
    deduction = sum([decimal.Decimal(x[2]) for x in data])
    static_profit = sum([decimal.Decimal(x[3]) for x in data])
    dynamic_profit = sum([decimal.Decimal(x[4]) for x in data])
    node_profit = sum([decimal.Decimal(x[5]) for x in data])
    free_coin = sum([decimal.Decimal(x[6]) for x in data])
    transfer = sum([decimal.Decimal(x[7]) for x in data])
    withdraw = sum([decimal.Decimal(x[8]) for x in data])
    block_recharge = sum([decimal.Decimal(x[9]) for x in data])
    buy_product = sum([decimal.Decimal(x[10]) for x in data])
    reinvestment = sum([decimal.Decimal(x[11]) for x in data])
    buy_order = sum([decimal.Decimal(x[12]) for x in data])
    sell_order = sum([decimal.Decimal(x[13]) for x in data])

    data = {
        'recharge': format_currency(recharge),
        'deduction': format_currency(deduction),
        'static_profit': format_currency(static_profit),
        'dynamic_profit': format_currency(dynamic_profit),
        'node_profit': format_currency(node_profit),
        'free_coin': format_currency(free_coin),
        'transfer': format_currency(transfer),
        'withdraw': format_currency(withdraw),
        'block_recharge': format_currency(block_recharge),
        'buy_product': format_currency(buy_product),
        'reinvestment': format_currency(reinvestment),
        'buy_order': format_currency(buy_order),
        'sell_order': format_currency(sell_order),
    }

    return render_template('wallet/analyze.html',
                           filter_form=filter_form,
                           day_data=day_data,
                           data=data)
Ejemplo n.º 19
0
def ajax_save():
    form = MessageForm()
    if form.validate():
        data = form.data
        message_id = data.pop('id')
        result = Api.put('/admin/message/detail/' + urllib2.quote(message_id),
                         data)
        return jsonify(result)
    else:
        raise ApiError(AppError.INVALID_REQUEST, form.errors)
Ejemplo n.º 20
0
def ajax_change_profile():
    change_profile_form = ChangeProfileForm()
    if change_profile_form.validate():
        data = Api.put(
            '/admin/member/detail/' +
            urllib2.quote(change_profile_form.id.data),
            change_profile_form.data)
        return jsonify(data)
    else:
        raise ApiError(AppError.INVALID_REQUEST, change_profile_form.errors)
Ejemplo n.º 21
0
def ajax_change_security():
    change_security_form = ChangeSecurityForm()
    if change_security_form.validate():
        data = Api.put(
            '/admin/member/detail/' +
            urllib2.quote(change_security_form.security_id.data),
            {'security_password': change_security_form.security_password.data})
        return jsonify(data)
    else:
        raise ApiError(AppError.INVALID_REQUEST, change_security_form.errors)
Ejemplo n.º 22
0
Archivo: home.py Proyecto: q25979/tdb99
def captcha():
    if request.args.get('uuid', None):
        pin_code_uuid = request.args.get('uuid')
    else:
        pin_code_uuid = str(uuid.uuid4())
    data = Api.get('/captcha_pin_code', {'uuid': pin_code_uuid},
                   response_type='binary')
    session['login_captcha_uuid'] = pin_code_uuid
    response = make_response(data)
    response.headers['Content-Type'] = 'image/jpeg'
    return response
Ejemplo n.º 23
0
def ajax_list():
    params = request.get_json()
    data = Api.get('/admin/user', params['query'])
    total_records = data['total_count']
    return_dict = {
        'draw': params['draw'],
        'recordsTotal': total_records,
        'recordsFiltered': total_records,
        'data': data['objects']
    }
    return jsonify(return_dict)
Ejemplo n.º 24
0
def add_user(user_id=None):
    add_user_form = AddUserForm()
    if user_id:
        user = Api.get('/admin/user/' + urllib2.quote(user_id))
        add_user_form.process(data=user)
        permission_list = []
        for key, value in user['permission'].items():
            permission_list.append(key)
        add_user_form.permission.data = permission_list

    return render_template('admin/add_user.html', add_user_form=add_user_form)
Ejemplo n.º 25
0
Archivo: news.py Proyecto: q25979/tdb99
def details(news_id=None):
    form = NewsForm()
    if news_id:
        news_detail = Api.get('/admin/news/details/' + urllib2.quote(news_id))
        # if news_detail['details']:
        #     detail_url = news_detail['details']
        #     response = requests.get(utils.build_oss_url(detail_url, 'http'), timeout=(9, 9))
        #     response.encoding = 'utf-8'
        #     news_detail['details'] = response.text
        form.process(data=news_detail)
    return render_template('news/detail.html', form=form)
Ejemplo n.º 26
0
def ajax_change_status():
    change_status_form = ChangeStatusForm()
    if change_status_form.validate():
        data = Api.put(
            '/admin/mall/order/' + urllib2.quote(change_status_form.id.data), {
                'express_company': change_status_form.express_company.data,
                'express_code': change_status_form.express_code.data,
                'status': change_status_form.status.data
            })
        return jsonify(data)
    else:
        raise ApiError(AppError.INVALID_REQUEST, change_status_form.errors)
Ejemplo n.º 27
0
Archivo: home.py Proyecto: q25979/tdb99
def change_password():
    change_password_form = ChangePasswordForm()
    if request.method == 'POST':
        if change_password_form.validate():
            params = change_password_form.data
            params.pop('confirm_new_password')
            return jsonify(Api.post('/admin/user/reset_password', params))
        else:
            raise AppError.invalid_request(change_password_form.errors)
    else:
        return render_template('change_password.html',
                               change_password_form=change_password_form)
Ejemplo n.º 28
0
def ajax_product_modify():
    product_form = ProductForm()
    if product_form.validate():
        params = {
            'name': product_form.name.data,
            'front_cover': product_form.front_cover.data,
            'category': product_form.category.data,
            'detail_cover_0': product_form.detail_cover_0.data,
            'detail_cover_1': product_form.detail_cover_1.data,
            'detail_cover_2': product_form.detail_cover_2.data,
            'description': product_form.description.data,
            'price': product_form.price.data,
            'sequence': product_form.sequence.data,
            'status': product_form.status.data
        }
        if product_form.id.data:
            data = Api.put(
                '/admin/mall/' + urllib2.quote(product_form.id.data), params)
        else:
            data = Api.post('/admin/mall/product_add', params)
        return jsonify(data)
    else:
        raise ApiError(AppError.INVALID_REQUEST, product_form.errors)
Ejemplo n.º 29
0
def details(id):
    data = Api.get('/admin/order/sell/detail/' + urllib2.quote(id))
    sell_user = data['user']
    buy_user = data['match_order']['buy_user']
    payment_dic = {}
    payment_flag = [
        'bank_payment', 'wechat_payment', 'alipay_payment', 'usdt_payment'
    ]
    for item in data['all_payment']:
        payment_dic[payment_flag[item['type']]] = item
    return render_template('p2p_order/details.html',
                           data=data,
                           payment_dic=payment_dic,
                           sell_user=sell_user,
                           buy_user=buy_user,
                           ORDER_STATUS_FLAG=dict(ORDER_STATUS_FLAG))
Ejemplo n.º 30
0
def ajax_sponsor_downline():
    params = request.json
    res = Api.get('/admin/team/sponsor_downline',
                  {'unique_id': params['unique_id']})
    children = []
    for item in res['objects']:
        obj = {
            'id': item['mobile'],
            'text': u'{} {}'.format(item['name'], item['mobile']),
            'children': True,
            'icon': 'fa fa-user'
        }
        children.append(obj)
    result = {
        'id': params['unique_id'],
        'text': params['text'],
        'icon': 'fa fa-user',
        'children': children
    }
    return jsonify(result)