Ejemplo n.º 1
0
from app.api import AddResource, pagination_query
from app.api.admin import admin_sys_login_required
from app.model import Datetime2Timestamp, DecimalToString, timestamp_to_datetime
from app.model.order import Order, g_order_status, g_order_side
from app.model.match_order import MatchOrder
from app.model.match_order import MatchOrderTask, g_match_order_task_status
from app.model.sell_order import SellOrder, g_sell_order_status
from app.model.buy_order import BuyOrder, g_buy_order_status
from app.model.user import User
from app.model.payment import Payment
from app.model.setting import Setting
from app.model.currency import Currency
from app.model.assets import Assets, g_assets_record_type, AssetsBalanceRecord

order_bp = Blueprint('admin_order_bp', __name__)
order_api = AddResource(Api(order_bp))

admin_member_user_fields = {
    'id': fields.String,
    'uid': fields.String,
    'mobile': fields.String,
    'email': fields.String,
    'order_mobile': fields.String,
    'avatar': fields.String,
    'name': fields.String,
    'nickname': fields.String,
    'gender': fields.Integer,
    'wechat': fields.String,
    'transaction_level': fields.Integer
}
Ejemplo n.º 2
0
from flask import Blueprint
from flask_restful import Api, Resource, marshal_with, abort
from flask_restful import fields
from flask_restful import reqparse
from werkzeug.http import dump_cookie

from app import db
from app.api import AddResource, pagination_query
from app.api.admin import admin_sys_login_required, member_user_fields
from app.model import timestamp_to_datetime, DecimalToString
from app.model.assets import AssetsBalanceRecord
from app.model.order import Order
from app.model.user import User, g_user_state_type, g_user_transaction_level

member_bp = Blueprint('admin_member_bp', __name__)
member_api = AddResource(Api(member_bp))


def cal_community_balance(x):
    balance = x.community_balance + x.community_today_balance
    return '{0:.8f}'.format(decimal.Decimal(balance))


admin_member_fields = {
    'id':
    fields.String,
    'uid':
    fields.String,
    'created_timestamp':
    fields.Integer,
    'mobile':
Ejemplo n.º 3
0
# -*- coding: utf-8 -*-
import datetime
import uuid
from flask import Blueprint, g, request, url_for
from flask_restful import Api, abort, fields, marshal_with, Resource

from app.api import pagination_query, restful_api, CustomRequestParser, UrlNormalize, AddResource
from app.api.member import member_login_required
from app.model import db, Datetime2Timestamp, DecimalToString
from app.model.payment import Payment, g_payment_type

payment_bp = Blueprint('member_payment_bp', __name__)
payment_api = AddResource(Api(payment_bp))

member_payment_user_fields = {
    'id': fields.String,
    'uid': fields.String,
    'name': fields.String
}

member_payment_fields = {
    'id': fields.String,
    'user': fields.Nested(member_payment_user_fields),
    'type': fields.Integer,
    'name': fields.String,
    'bank': fields.String,
    'card_number': fields.String,
    'wechat': fields.String,
    'wechat_image': fields.String,
    'alipay': fields.String,
    'alipay_image': fields.String,
Ejemplo n.º 4
0
# -*- coding: utf-8 -*-
from flask import Blueprint, g
from flask_restful import abort, fields, marshal_with, Resource, Api, reqparse

from app.api import AddResource
from app.api.member import member_login_required
from app.model import DecimalToString, Datetime2Timestamp
from app.model.user import User

team_bp = Blueprint('member_team_bp', __name__)
team_api = AddResource(Api(team_bp))

member_downline_fields = {
    'id': fields.String,
    'nickname': fields.String,
    'name': fields.String,
    'mobile': fields.String,
    'uid': fields.String,
    'created_at': Datetime2Timestamp
}


# 推荐网络图
@team_api.add_resource('/sponsor_downline')
class MemberSponsorDownlineApi(Resource):
    decorators = [member_login_required]

    @marshal_with(member_downline_fields, envelope='objects')
    def get(self):
        parser = reqparse.RequestParser()
        parser.add_argument('depth', type=int, default=1, location='args')
Ejemplo n.º 5
0
import decimal
import json
import datetime

from flask import Blueprint, g
from flask_restful import Api, fields, Resource, marshal_with, abort

from app.api import AddResource, CustomRequestParser, pagination_query
from app.api.member import member_login_required
from app.model import db, Datetime2Timestamp, timestamp_to_datetime, DecimalToString
from app.model.assets import Assets, AssetsBalanceRecord, g_assets_record_type, g_assets_type
from app.model.setting import Setting
from app.model.user import User

assets_bp = Blueprint('member_assets_bp', __name__)
assets_api = AddResource(Api(assets_bp))

member_assets_user_fields = {
    'id': fields.String,
    'uid': fields.String,
    'name': fields.String,
    'email': fields.String
}


def cal_community_balance(x):
    balance = x.community_balance + x.community_today_balance
    return '{0:.8f}'.format(decimal.Decimal(balance))


member_assets_fields = {
Ejemplo n.º 6
0
# -*- coding: utf-8 -*-
from flask import Blueprint
from flask_restful import abort, fields, marshal_with, Resource, Api
from app.api import AddResource, CustomRequestParser, pagination_query

from app.model import DecimalToString, timestamp_to_datetime
from app.model.currency import Currency, CurrencyPriceRecord

currency_bp = Blueprint('admin_currency_bp', __name__)
currency_api = AddResource(Api(currency_bp))

admin_currency_fields = {
    'usd_price': DecimalToString,
    'transaction_cnt': fields.Integer,
    'today_transaction_amount': fields.Integer
}


@currency_api.add_resource('/usd_price')
class AdminCurrencyApi(Resource):
    @marshal_with(admin_currency_fields)
    def get(self):
        currency = Currency.get_currency()
        if currency is None:
            abort(400,
                  code=1001,
                  message={'currency': 'currency does not exist'})
        return currency


admin_currency_price_record_fields = {
Ejemplo n.º 7
0
# -*- coding: utf-8 -*-
import json

from flask import Blueprint, g
from flask_restful import Api, Resource, marshal_with, fields, reqparse, abort

from app.api import AddResource, pagination_query
from app.api.admin import admin_login_required
from app.model.admin_user import AdminUser
from app.model.pin_code import CaptchaPinCode

user_bp = Blueprint('admin_user', __name__)
restful_api = Api(user_bp)
user = AddResource(restful_api)


class AccessFunction(fields.Raw):
    def format(self, value):
        return value


admin_login_fields = {
    'id':
    fields.String,
    'uid':
    fields.String,
    'role':
    fields.Integer,
    'token':
    fields.String,
    'permission':
Ejemplo n.º 8
0
from io import BytesIO

from captcha.image import ImageCaptcha
from flask import Blueprint, make_response
from flask_restful import Api, Resource, reqparse, abort
from yunpian_python_sdk.model import constant as YC
from yunpian_python_sdk.ypclient import YunpianClient

from app.api import AddResource
from app.api.utils import get_random_str
from app.model.pin_code import CaptchaPinCode, SmsPinCode
from app.model.user import User

pin_code_bp = Blueprint('pin_code', __name__)
pin_code_api = Api(pin_code_bp)
pin_code = AddResource(pin_code_api)


@pin_code.add_resource('/captcha_pin_code')
class PinCodeCaptcha(Resource):
    def get(self):
        parser = reqparse.RequestParser()
        parser.add_argument('uuid',
                            type=str,
                            required=True,
                            location='args',
                            help="uuid cannot be blank!")
        parser_args = parser.parse_args()
        code = get_random_str()
        image = ImageCaptcha()
        data = image.generate_image(code)
Ejemplo n.º 9
0
# -*- coding: utf-8 -*-
import os
import uuid

from flask import Blueprint
from flask import current_app
from flask_restful import Api, Resource, abort
from flask_restful import reqparse
from werkzeug.datastructures import FileStorage

from app.api import AddResource, oss_proof_img_key, oss_bucket
from app.api.member import member_login_required

upload_bp = Blueprint('upload_bp', __name__)
upload_api = AddResource(Api(upload_bp))


@upload_api.add_resource('/image')
class MemberUploadProofImgApi(Resource):
    # decorators = [member_login_required]

    def post(self):
        parser = reqparse.RequestParser()
        parser.add_argument('attachment',
                            type=FileStorage,
                            required=True,
                            nullable=False,
                            location='files')
        parsed_args = parser.parse_args()
        attachment = parsed_args['attachment']
        if not attachment.content_type.startswith('image'):
Ejemplo n.º 10
0
Archivo: news.py Proyecto: q25979/tdb99
# -*- coding: utf-8 -*-
import requests
from flask_restful import fields, Resource, marshal_with, abort, reqparse, Api

from app.model.news import News
from app.api import pagination_query, AddResource
from flask.blueprints import Blueprint
from app.model import Datetime2Timestamp

news_bp = Blueprint('news_bp', __name__)
news_api = AddResource(Api(news_bp))

news_fields = {
    'id': fields.String,
    'created_at': Datetime2Timestamp,
    'title': fields.String,
    'details': fields.String,
}

news_list_fields = {
    'total_pages': fields.Integer,
    'page': fields.Integer,
    'per_page': fields.Integer,
    'total_count': fields.Integer,
    'objects': fields.List(fields.Nested(news_fields))
}

# 新闻为公告,可以不用户认证。


@news_api.add_resource()
Ejemplo n.º 11
0
Archivo: user.py Proyecto: q25979/tdb99
# -*- coding: utf-8 -*-
import datetime
import uuid
from flask import Blueprint, g, request, url_for
from flask_restful import Api, abort, fields, marshal_with, Resource

from app.api import pagination_query, restful_api, CustomRequestParser, UrlNormalize, AddResource
from app.api.member import member_login_required
from app.model import db, Datetime2Timestamp, DecimalToString
from app.model.user import LoginInfo, User, g_user_state_type
from app.model.pin_code import CaptchaPinCode, SmsPinCode
from app.model.payment import Payment
from werkzeug.http import dump_cookie

user_bp = Blueprint('member_user_bp', __name__)
user_api = AddResource(Api(user_bp))


def member_user_mobile_exists(mobile):
    user = User.query.filter(User.mobile == mobile).first()
    return user


member_user_login_fields = {
    'id': fields.String,
    'uid': fields.String,
    'mobile': fields.String,
    'token': fields.String,
}

Ejemplo n.º 12
0
# -*- coding: utf-8 -*-
import json

from flask import Blueprint
from flask_restful import Resource, fields, marshal_with, Api, reqparse, abort

from app.api import AddResource
from app.api.admin import admin_sys_login_required
from app.model import db
from app.model.setting import Setting

setting_bp = Blueprint('admin_setting_bp', __name__)
setting_api = AddResource(Api(setting_bp))

admin_setting_fields = {
    "name": fields.String,
    "title": fields.String,
    "value": fields.Raw(attribute=lambda x: json.loads(x.value)),
    "description": fields.Raw(attribute=lambda x: json.loads(x.description))
}


@setting_api.add_resource('/general_option')
class AdminSettingGeneralOptionApi(Resource):
    decorators = [admin_sys_login_required]

    @marshal_with(admin_setting_fields)
    def get(self):
        return Setting.query.get('general_option')

    def put(self):
Ejemplo n.º 13
0
# -*- coding: utf-8 -*-
import io
import qrcode
from flask import send_file, Blueprint
from flask_restful import Resource
from flask_restful import Api, Resource, reqparse, abort
from app.api import restful_api, AddResource


qr_code_bp = Blueprint('qr_code', __name__)
qr_code_api = Api(qr_code_bp)
qr_code = AddResource(qr_code_api)


# 二维码
@qr_code.add_resource('/address_qr_code/<string:address>')
class AddressQrCodeApi(Resource):
    def get(self, address):
        qr = qrcode.QRCode(
            version=2,
            error_correction=qrcode.constants.ERROR_CORRECT_L,
            box_size=10,
            border=1)

        url = address
        qr.add_data(url)
        qr.make(fit=True)
        qr_img = qr.make_image()

        byte_io = io.BytesIO()
        qr_img.save(byte_io, 'PNG')