Пример #1
0
from app.extensions.ext_api import api_cashier as api
from flask_restplus import Resource

from app.forms.deposit_form import CreateOrderForm, AmountInputForm
from app.forms.domain_form import DomainForm
from app.libs.error_code import InvalidDepositPaymentTypeError, PreOrderCreateError, UserPermissionDeniedError
from app.libs.doc_response import ResponseDoc
from app.logics.channel.chanel_cache import ChannelLimitCacheCtl
from app.logics.channel.channel_list import ChannelListHelper
from app.logics.payment.deposit_helper import DepositHelper
from app.logics.token.cashier_token import cashier_decorators
from flask import g, current_app
from app.docs.doc_cashier.deposit_withdraw import ResponseDepositLimitConfig, ResponsePaymentType, \
    DepositRequest, ResponseRedirectUrl, PaymentTypeListRequestDoc

ns = api.namespace('deposit', description='用户充值')


@ns.route('/limit/config/get', endpoint='get_limit')
@ResponseDoc.response(ns, api)
class ResetPassword(Resource):
    method_decorators = cashier_decorators

    # 相应数据格式
    @ns.marshal_with(ResponseDepositLimitConfig.gen_doc(api))
    def post(self):
        """
        获取单笔交易最低最高限额
        """
        form, error = DomainForm().request_validate()
        if error:
Пример #2
0
from app.forms.deposit_form import CreateWithdrawOrderForm
from app.forms.domain_form import DomainForm
from app.libs.balance_kit import BalanceKit
from app.libs.doc_response import ResponseDoc
from app.logics.channel.chanel_cache import ChannelLimitCacheCtl
from app.logics.channel.channel_list import ChannelListHelper
from app.logics.token.cashier_token import cashier_decorators
from app.logics.transaction.withdraw_ctl import WithdrawTransactionCtl
from app.libs.error_code import ResponseSuccess, PaymentPasswordError, UserPermissionDeniedError
from flask import g
from app.docs.doc_cashier.deposit_withdraw import ResponseWithdrawLimitConfig, ResponseBankWithdraw, WithdrawRequestDoc
from app.models.balance import UserBalance
from app.models.user import User

ns = api.namespace('withdraw', description='用户提现')


@ns.route('/limit/config/get', endpoint='withdraw_get_limit')
@ResponseDoc.response(ns, api)
class ResetPassword(Resource):
    method_decorators = cashier_decorators

    # 相应数据格式
    @ns.marshal_with(ResponseWithdrawLimitConfig.gen_doc(api))
    def post(self):
        """
        获取单笔交易最低最高限额
        """
        form, error = DomainForm().request_validate()
        if error:
Пример #3
0
    PasswordTrueForm, AuthCodeTrueForm, ResetWordForm, ResetWordVerify
from app.forms.client_auth import LoginForm
from app.libs.doc_response import ResponseDoc
from app.libs.error_code import AuthCodeError, ResponseSuccess, \
    AccountAlreadyExitError, AccountNotExistError, LoginPasswordError, AuthCodeTimesLimitError, \
    RePasswordError, NoSourceError, PasswordError, AuthCodeExpiredError, OriPasswordError, DisableUserError, \
    MerchantConfigDepositError, MerchantConfigWithdrawError
from app.libs.string_kit import PhoneNumberParser
from app.logics.token.cashier_token import UserLoginToken, cashier_decorators
from app.logics.mobile.auth_code import AuthCodeGenerator, AuthCodeLimiter
from app.models.merchant import MerchantFeeConfig
from app.models.user import User, UserBindInfo
from app.extensions.ext_api import api_cashier as api
from app.caches.user_password import UserPasswordLimitCache

ns = api.namespace('auth', description='用户注册登录')


@ns.route('/mobile/check', endpoint="mobile_number_check")
@ResponseDoc.response(ns, api, [AccountAlreadyExitError], login=False)
class AuthUsername(Resource):
    method_decorators = [
        limiter.limit("1/second"),
    ]

    @ns.expect(MobileNumber)
    @ns.marshal_with(ResponseSuccess.gen_doc(api))
    def post(self):
        """
            检查手机号是否已经注册
        """
Пример #4
0
from app.extensions.ext_api import api_cashier as api
from flask_restplus import Resource
from app.libs.doc_response import ResponseDoc
from app.libs.string_kit import PhoneNumberParser
from app.logics.token.cashier_token import cashier_decorators
from app.libs.error_code import ResponseSuccess, PaymentPwdNotExistError, NoSourceError, PaymentPasswordError, \
    PaymentPasswordLimitedError, AccountNotExistError, AccountBalanceInsufficientError, TransferToMeError, \
    UserPermissionDeniedError
from app.forms.auth_code import TransferForm, TransferAccountQueryForm
from app.docs.doc_cashier.auth_code import TransferParam, TransferAccountQueryDoc
from app.caches.user_payment_password import UserPaymentPasswordLimitCache
from app.models.user import User, UserBindInfo
from app.models.balance import UserBalance, UserBalanceEvent
from app.libs.balance_kit import BalanceKit

ns = api.namespace('transfer', description='转账')


@ns.route('/account/query')
@ResponseDoc.response(ns, api, [AccountNotExistError])
class QueryTransferAccount(Resource):
    method_decorators = cashier_decorators

    @ns.expect(TransferAccountQueryDoc)
    @ns.marshal_with(ResponseTransferUserQueryResult.gen_doc(api))
    def post(self):
        form, error = TransferAccountQueryForm().request_validate()
        if error:
            return error.as_response()

        bind_user = UserBindInfo.query_bind(form.merchant.data,
Пример #5
0
    BankCardNumLimitedError, BankCardAccountNameError, BankCardExistError, UserPermissionDeniedError
from app.forms.auth_code import SetPaymentPassword, ResetPaymentPasswordForm, \
    SetForgetPaymentPasswordForm, BankCardForm, CreateBankCardForm, \
    DeleteBankCardForm
from app.docs.doc_cashier.auth_code import PaymentPassword, ResetPaymentPassword, SetForgetPaymentPassword, \
    ResponsePaymentPasswordRemaintimes, \
    ResponseBanks, BankCardId, ResponseBankLocation, BankCardParams, ResponseBankCards, BankCardDeleteParams
from app.models.user import User
from app.caches.user_payment_password import UserPaymentPasswordLimitCache
from app.logics.mobile.auth_code import AuthCodeGenerator
from app.constants.trade import USER_BANK_CARD_NUM_LIMIT
from app.models.bank import Bank
from app.models.bankcard import BankCard
from app.libs.yonyou.bank import BankToolKit

ns = api.namespace('setting', description='用户设置')


@ns.route('/payment/password/set', endpoint='set_payment_password')
@ResponseDoc.response(ns, api, [PaymentPwdNotExistError, NoSourceError])
class PaymentPasswordSet(Resource):
    method_decorators = cashier_decorators

    # 期待客户端请求数据模型, 用response 来装饰
    @ns.expect(PaymentPassword)
    # 相应数据格式
    @ns.marshal_with(ResponseSuccess.gen_doc(api))
    def post(self):
        """
        设置支付密码
        """
Пример #6
0
from flask import current_app
from flask_restplus import Resource

from app.extensions import limiter
from app.docs.doc_cashier.auth_code import MobileAuthCode, MobileNumber
from app.libs.error_code import ResponseSuccess, AccountAlreadyExitError, AuthCodeTimesLimitError, AuthCodeError, \
    AuthCodeExpiredError
from app.logics.mobile.auth_code import AuthCodeGenerator, AuthCodeLimiter
from app.libs.doc_response import ResponseDoc
from app.forms.auth_code import MobileRegisterCheckForm, AuthCodeForm
from app.extensions.ext_api import api_cashier as api

# 定义文档模型的名字空间
# 文档模型只是用来描述API,如API的请求/响应的数据格式
ns = api.namespace('sms', description='短信动态验证码API')


@ns.route('/get', endpoint='sms_get_code')
# 非200类型的响应模型,用response来装饰,可以装饰多个
@ResponseDoc.response(ns, api, [
    AuthCodeTimesLimitError, AccountAlreadyExitError
], login=False)
class SMSCodeGenerator(Resource):
    # 验证码的发送要限速
    method_decorators = [limiter.limit("1/10")]

    # 期待客户端请求的数据模型,使用expect来装饰
    @ns.expect(MobileNumber)
    # 给客户端返回的的响应数据模型,使用marshal_with来装饰
    @ns.marshal_with(ResponseSuccess.gen_doc(api))
Пример #7
0
# -*-coding:utf8-*-
from flask import g
from flask_restplus import Resource

from app.docs.doc_cashier.deposit_withdraw import ResponseUserBalance
from app.libs.balance_kit import BalanceKit
from app.libs.doc_response import ResponseDoc
from app.extensions.ext_api import api_cashier as api
from app.logics.token.cashier_token import cashier_decorators
from app.models.balance import UserBalance

ns = api.namespace('user', description='用户操作')


@ns.route('/balance/get', endpoint='get_user_balance')
@ResponseDoc.response(ns, api)
class BalanceGetView(Resource):
    method_decorators = cashier_decorators

    # 相应数据格式
    @ns.marshal_with(ResponseUserBalance.gen_doc(api))
    def post(self):
        """
        获取用户余额
        """
        # uid = g.user.uid
        # merchant = g.user.merchant
        # account = g.user.account
        # is_active = g.user.is_active
        # state = g.user.state
        # ac_type = g.user.ac_type