Exemplo n.º 1
0
def get_app_manage(account_id, appid, app_type, valid, name, page, size):

    limit = _DEFAULT_PAGE_SIZE if not size or size > _DEFAULT_PAGE_SIZE else size
    if not page or page < 1:
        page = 1
    offset = 0 if not page else (page - 1) * limit

    apps, counts = query_app_manage(account_id,
                                    appid=appid,
                                    app_type=app_type,
                                    valid=valid,
                                    appname=name,
                                    limit=limit,
                                    offset=offset)
    pages = int(counts / float(limit)) + 1
    resp = []
    for app in apps:
        data = {
            'name': app.appname,
            'appid': app.appid,
            'appkey': get_appkey(app.appid),
            'app_type': app.app_type,
            'pay_type': json.loads(app.pay_type),
            'status': app.valid,
            'created_at': utc_to_local_str(app.created_at),
        }
        resp.append(data)

    resp_wrap = {'pages': pages, 'resp': resp}  # 需有加个分页
    return resp_wrap
Exemplo n.º 2
0
def get_merchants(accountid, mch_name, appid, page, size):
    limit = _DEFAULT_PAGE_SIZE if not size or size > _DEFAULT_PAGE_SIZE else size
    if not page or page < 1:
        page = 1
    offset = 0 if not page else (page - 1) * limit
    apps, counts = db.query_app_manage(accountid,
                                       mch_name=mch_name,
                                       appid=appid,
                                       limit=limit,
                                       offset=offset)
    resp = []
    if apps:
        for app in apps:
            user = db.get_user(app.accountid)
            appid_detail = db.get_appid_detail(app.appid)
            real_pay = REAL_PAY.get_label(appid_detail.real_pay) if appid_detail else None
            extend = None
            if app.extend:
                extend = json.loads(app.extend).get('extend', '')
            resp.append({"real_pay": real_pay,
                         "mch_name": app.mch_name,
                         "phone": user.phone if user else None,
                         "appid": app.appid,
                         "extend": extend,
                         "appkey": db.get_appkey(app.appid),
                         "updated_at": tz.utc_to_local_str(app.updated_at),
                         "mch_number": app.id})

    pages = int(counts / float(limit)) + 1
    return {"pages": pages, "resp": resp}
Exemplo n.º 3
0
def get_app_manage(mchid, page, size, appid, app_type, valid, status,
                   bank_name, begin_at, end_at, mch_name, mch_short_name,
                   appname, paymenttype):
    limit = _DEFAULT_PAGE_SIZE if not size or size > _DEFAULT_PAGE_SIZE else size
    if not page or page < 1:
        page = 1
    offset = 0 if not page else (page - 1) * limit
    apps, count = db.query_app_manage(mchid, appid=appid, app_type=app_type,
                                      valid=valid, appname=appname, limit=limit,
                                      offset=offset, begin_at=begin_at,
                                      end_at=end_at, mch_name=mch_name,
                                      mch_short_name=mch_short_name,
                                      paymenttype=paymenttype)

    return {"total": count,
            "jinjians": [
                {
                 "id": app.id,
                 "status": app.valid,
                 "appname": app.appname,
                 "app_type": app.app_type,
                 "appid": app.appid,
                 "appkey": db.get_appkey(app.appid),
                 "mch_name": app.mch_name,
                 "mch_short_name": app.mch_short_name,
                 "updated_at": tz.utc_to_local_str(app.updated_at),
                 "bank_name": _convert_paymenttype_to_banklinkname(app.paymenttype)
                } for app in apps
            ] if apps else []
            }
Exemplo n.º 4
0
def get_withdraw_info(account_id, appid, app_type, valid, name, page, size):
    limit = _DEFAULT_PAGE_SIZE if not size or size > _DEFAULT_PAGE_SIZE else size
    if not page or page < 1:
        page = 1
    offset = 0 if not page else (page - 1) * limit

    apps, counts = query_app_manage(account_id, appid, app_type, valid, name,
                                    limit, offset)
    pages = int(counts / float(limit)) + 1
    resp = []
    for app in apps:
        data = {
            'mch_name': app.mch_name,
            'app_name': app.appname,
            'appid': app.appid,
            'bank_name': app.card_name,
            'balance': get_appid_balance(app.appid),
            'card_number': app.card_number,
        }
        resp.append(data)
    succeed, succeed_fee, dealing, dealing_fee = get_withdraw_data(account_id)

    resp_wrap = {
        'pages': pages,
        'list': resp,
        'succeed': succeed,
        'succeed_fee': succeed_fee,
        'dealing': dealing,
        'dealing_fee': dealing_fee
    }
    return resp_wrap
Exemplo n.º 5
0
def get_withdraw_account(account_id, bank_name, balance_type, mch_type,
                         bank_number, balance_name, mch_number, mch_name, page,
                         size):
    limit = _DEFAULT_PAGE_SIZE if not size or size > _DEFAULT_PAGE_SIZE else size
    if not page or page < 1:
        page = 1
    offset = 0 if not page else (page - 1) * limit
    apps, counts = query_app_manage(account_id,
                                    bank_name=bank_name,
                                    balance_type=balance_type,
                                    industry_no=mch_type,
                                    card_number=bank_number,
                                    balance_name=balance_name,
                                    mch_number=mch_number,
                                    mch_name=mch_name,
                                    offset=offset,
                                    limit=limit)

    resp = []
    for app in apps:
        resp.append({
            "mch_number":
            app.id,
            "mch_name":
            app.mch_name,
            "mch_type":
            MCH_TYPE.get_label(app.industry_no),
            "balance_type":
            BALANCE_TYPE.get_label(app.balance_type),
            "balance_name":
            app.balance_name,
            "card_number":
            app.card_number,
            "bank_no":
            app.bank_no,
            "bank_name":
            app.bank_name,
            "updated_at":
            tz.utc_to_local(app.updated_at).strftime("%Y-%m-%d %H:%M:%S")
        })
    pages = int(counts / float(limit)) + 1
    return {"pages": pages, "list": resp}