コード例 #1
0
def top_dollar():
    if request.method == 'POST':
        '''
        1:校验前端数据是否正确
        2:查看实时汇率有没有变动
        3:核实客户是否存在
        '''
        data = json.loads(request.form.get('data'))
        sum_money = data.get('sum_money')
        top_money = data.get('top_money')
        cus_name = data.get('cus_name')
        cus_account = data.get('cus_account')
        phone = data.get('phone')
        res = SqlData().search_user_check(cus_name, cus_account)
        if not res:
            return jsonify({'code': RET.SERVERERROR, 'msg': '没有该用户!请核实后重试!'})
        if phone:
            ret = re.match(r"^1[35789]\d{9}$", phone)
            if not ret:
                results = dict()
                results['code'] = RET.SERVERERROR
                results['msg'] = '请输入符合规范的电话号码!'
                return jsonify(results)
        dollar = SqlData().search_admin_field('dollar_hand')
        _money_self = float(top_money) * (dollar + 1)
        money_self = round(_money_self, 10)
        sum_money = round(float(sum_money), 10)
        if money_self == sum_money:
            return jsonify({'code': RET.OK, 'msg': MSG.OK})
        else:
            return jsonify({
                'code': RET.SERVERERROR,
                'msg': '手续费已变动!请刷新界面后重试!'
            })
コード例 #2
0
def make_up():
    '''
    补全卡信息接口(卡列表头部工具栏最右边那个笑脸)
    :return:
    '''
    try:
        user_id = g.user_id
        sql = "WHERE cvv='' OR expire='' AND account_id={}".format(str(user_id))
        info = SqlData().search_card_info_admin(sql)
        if not info:
            return jsonify({'code': RET.OK, 'msg': '无卡缺失信息!'})
        for i in info:
            card_no = i.get('card_no')
            card_no = card_no.strip()
            resp_card_info = QuanQiuFu().query_card_info(card_no)
            if resp_card_info.get('resp_code') != '0000':
                expire_date = ''
                card_verify_code = ''
            else:
                re_de = resp_card_info.get('response_detail')
                expire_date = re_de.get('expire_date')
                card_verify_code = re_de.get('card_verify_code')
            SqlData().update_card_info_card_no('cvv', card_verify_code, card_no)
            SqlData().update_card_info_card_no('expire', expire_date, card_no)
        return jsonify({'code': RET.OK, 'msg': MSG.OK})
    except Exception as e:
        logging.error(str(e))
        return jsonify({'code': RET.OK, 'msg': MSG.SERVERERROR})
コード例 #3
0
ファイル: user.py プロジェクト: HelenLiu97/huihui
def line_chart():
    # 展示近三十天开卡数量
    day_num = 30
    day_list = get_nday_list(day_num)
    user_id = g.user_id
    sum_day_money = list()
    sum_day_card = list()
    for d in day_list:
        start_t = d + " 00:00:00"
        end_t = d + " 23:59:59"
        day_money = SqlData.search_trans_money(
            start_t, end_t, user_sql='AND user_id={}'.format(user_id))
        if not day_money:
            day_money = 0
        sum_day_money.append(day_money)
        sql = "WHERE do_type='开卡' AND do_date BETWEEN '{}' AND '{}' AND user_id={}".format(
            start_t, end_t, user_id)
        card_num = SqlData.search_value_count('user_trans', sql=sql)
        sum_day_card.append(card_num)
    money_dict = {
        'name': '充值金额',
        'type': 'column',
        'yAxis': 1,
        'data': sum_day_money,
        'tooltip': {
            'valueSuffix': ' $'
        }
    }
    card_dict = {
        'name': '开卡数量',
        'type': 'spline',
        'data': sum_day_card,
        'tooltip': {
            'valueSuffix': ' 张'
        }
    }
    # 以下是数据结构
    '''
    [{
            name: '充值金额',
            type: 'column',
            yAxis: 1,
            data: [49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4,980,98,98],
            tooltip: {
                valueSuffix: ' $'
            }
        }, {
            name: '开卡数量',
            type: 'spline',
            data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6],
            tooltip: {
                valueSuffix: ' 张'
            }
        }]'''
    results = dict()
    results['code'] = RET.OK
    results['msg'] = MSG.OK
    results['data'] = [money_dict, card_dict]
    results['xAx'] = day_list
    return jsonify(results)
コード例 #4
0
def del_account():
    user_name = g.user_name
    user_id = g.user_id
    results = {'code': RET.OK, 'msg': MSG.OK}
    if request.method == "GET":
        account = request.args.get('account')
        try:
            SqlData().del_account(account, user_id)
            logging.warning(user_name + '删除' + account)
            return jsonify(results)
        except Exception as e:
            logging.error(str(e))
            results['code'] = RET.SERVERERROR
            results['msg'] = MSG.DATAERROR
            return jsonify(results)
    elif request.method == 'POST':
        data = json.loads(request.form.get('data'))
        try:
            for i in data:
                account = i.get('account')
                SqlData().del_account(account, user_id)
                logging.warning(user_name + '删除' + account)
            return jsonify(results)
        except Exception as e:
            logging.error(str(e))
            results['code'] = RET.SERVERERROR
            results['msg'] = MSG.DATAERROR
            return jsonify(results)
コード例 #5
0
def change_pass():
    '''
    更换用户密码
    :return:
    '''
    data = json.loads(request.form.get('data'))
    old_pass = data.get('old_pass')
    new_pass_one = data.get('new_pass_one')
    new_pass_two = data.get('new_pass_two')
    user_id = g.user_id
    pass_word = SqlData().search_user_field('password', user_id)
    results = {'code': RET.OK, 'msg': MSG.OK}
    if not (old_pass == pass_word):
        results['code'] = RET.SERVERERROR
        results['msg'] = MSG.PSWDERROR
        return jsonify(results)
    if not (new_pass_one == new_pass_two):
        results['code'] = RET.SERVERERROR
        results['msg'] = MSG.PSWDERROR
        return jsonify(results)
    if len(new_pass_one) < 6:
        results['code'] = RET.SERVERERROR

        results['msg'] = MSG.PSWDLEN
        return jsonify(results)
    try:
        SqlData().update_user_field('password', new_pass_one, g.user_id)
        return jsonify(results)
    except Exception as e:
        logging.error(e)
        results['code'] = RET.SERVERERROR
        results['msg'] = MSG.SERVERERROR
        return jsonify(results)
コード例 #6
0
ファイル: user.py プロジェクト: HelenLiu97/huihui
def one_detail():
    try:
        context = dict()
        card_number = request.args.get('card_number')
        card_status = SqlData.search_one_card_status(card_number)
        if card_status:
            card_id = SqlData.search_card_field('card_id', card_number)
            card_detail = svb.card_detail(card_id)
            available_balance = card_detail.get('data').get(
                'available_balance')
            context['available_balance'] = available_balance / 100
            context['card_status'] = "正常"
        else:
            context['available_balance'] = 0
            context['card_status'] = "已注销"
        # for td in []:
        #     info_list.append({
        #         "status": td.get("status"),
        #         "amount": td.get("amount"),
        #         "description": td.get("description"),
        #         "date": td.get("date"),
        #         "cardTransactionId": td.get("cardTransactionId"),
        #         "lastFour": td.get("lastFour"),
        #         "alias": td.get("alias"),
        #         "originalCurrency": td.get("originalCurrency"),
        #     })
        # context['pay_list'] = info_list
        return render_template('user/card_detail.html', **context)
    except Exception as e:
        logging.error((str(e)))
        return render_template('user/404.html')
コード例 #7
0
def account_info():
    page = request.args.get('page')
    limit = request.args.get('limit')
    customer = request.args.get('customer')
    results = {"code": RET.OK, "msg": MSG.OK, "count": 0, "data": ""}
    if customer:
        sql = "WHERE name LIKE '%" + customer + "%'"
    else:
        start_index = (int(page) - 1) * int(limit)
        sql = 'limit ' + str(start_index) + ", " + limit + ';'
    task_one = SqlData().search_account_info(sql)
    if len(task_one) == 0:
        results['MSG'] = MSG.NODATA
        return jsonify(results)
    task_info = list()
    for u in task_one:
        u_id = u.get('u_id')
        card_count = SqlData().search_card_count(u_id, '')
        out_money = SqlData().search_trans_sum(u_id)
        u['card_num'] = card_count
        u['out_money'] = out_money
        task_info.append(u)
    task_info = list(reversed(task_info))
    results['data'] = task_info
    results['count'] = SqlData().search_table_count('account')
    return jsonify(results)
コード例 #8
0
ファイル: task.py プロジェクト: HackerLiu2008/buysys
def insert_task():
    user_id = g.user_id
    data = json.loads(request.form.get('data'))
    country = data.get('country')
    sum_time = data.get('sum_time')
    asin = data.get('asin')
    store_name = data.get('store_name')
    key_word = data.get('key_word')
    kw_location = data.get('kw_location')
    good_name = data.get('good_name')
    good_money = data.get('good_money')
    good_link = data.get('good_link')
    pay_method = data.get('pay_method')
    serve_class = data.get('serve_class')
    mail_method = data.get('mail_method')
    note = data.get('note')
    review_title = data.get('review_title')
    review_info = data.get('review_info')
    feedback_info = data.get('feedback_info')
    try:
        sum_order_code = sum_code()
        parent_id = SqlData().insert_task_parent(user_id, sum_order_code)
        task_code = sum_order_code + '-' + '1'
        SqlData().insert_task_detail(parent_id, task_code, country, asin,
                                     key_word, kw_location, store_name,
                                     good_name, good_money, good_link,
                                     pay_method, sum_time, serve_class,
                                     mail_method, note, review_title,
                                     review_info, feedback_info, user_id)
        return jsonify({'code': RET.OK, 'msg': RET.OK})
    except Exception as e:
        logging.error(str(e))
        return jsonify({'code': RET.SERVERERROR, 'msg': MSG.SERVERERROR})
コード例 #9
0
def card_info_all():
    try:
        limit = request.args.get('limit')
        page = request.args.get('page')
        field = request.args.get('field')
        value = request.args.get('value')

        if field == "card_cus":
            account_id = SqlData().search_user_field_name('id', value)
            sql = "WHERE account_id=" + str(account_id)
        elif field:
            sql = "WHERE " + field + " LIKE '%" + value + "%'"
        else:
            # 如果没有搜索条件,则分页查询MYSQL,加快速度
            start_index = (int(page) - 1) * int(limit)
            sql = 'limit ' + str(start_index) + ", " + limit + ';'

        results = dict()
        results['code'] = RET.OK
        results['msg'] = MSG.OK
        info_list = SqlData().search_card_info_admin(sql)
        if not info_list:
            results['code'] = RET.OK
            results['msg'] = MSG.NODATA
            return jsonify(results)

        results['data'] = info_list
        results['count'] = SqlData().search_table_count('card_info')
        return jsonify(results)
    except Exception as e:
        logging.error(str(e))
        return jsonify({'code': RET.SERVERERROR, 'msg': MSG.SERVERERROR})
コード例 #10
0
def add_middle():
    results = {"code": RET.OK, "msg": MSG.OK}
    try:
        data = json.loads(request.form.get('data'))
        name = data.get('name')
        account = data.get('account')
        password = data.get('password')
        phone_num = data.get('phone_num')
        create_price = float(data.get('create_price'))
        note = data.get('note1')
        ret = SqlData().search_middle_ed(name)
        if ret:
            results['code'] = RET.SERVERERROR
            results['msg'] = '该中介名已存在!'
            return jsonify(results)
        '''
        ret = re.match(r"^1[35789]\d{9}$", phone_num)
        if not ret:
            results['code'] = RET.SERVERERROR
            results['msg'] = '请输入符合规范的电话号码!'
            return jsonify(results)
        '''
        SqlData().insert_middle(account, password, name, phone_num, create_price, note)
        return jsonify(results)
    except Exception as e:
        logging.error(e)
        results['code'] = RET.SERVERERROR
        results['msg'] = RET.SERVERERROR
        return jsonify(results)
コード例 #11
0
ファイル: user.py プロジェクト: HelenLiu97/huihui
def change_card_name():
    '''
    更改卡姓名和标签信息
    :return:
    '''
    # 判断是否是子账号用户
    vice_id = g.vice_id
    if vice_id:
        auth_dict = RedisTool.hash_get('svb_vice_auth', vice_id)
        if auth_dict is None:
            return render_template('user/no_auth.html')
        c_card = auth_dict.get('refund')
        if c_card == 'F':
            return render_template('user/no_auth.html')

    if request.method == 'GET':
        card_number = request.args.get('card_number')
        context = dict()
        context['card_number'] = card_number
        return render_template('user/card_label.html', **context)
    if request.method == 'POST':
        try:
            data = json.loads(request.form.get('data'))
            card_number = data.get('card_number')
            card_label = data.get('card_label')
            card_number = card_number.strip()
            if card_label:
                SqlData.update_card_info_card_no('label', card_label,
                                                 card_number)
            return jsonify({'code': RET.OK, 'msg': MSG.OK})
        except Exception as e:
            logging.error(str(e))
            return jsonify({'code': RET.SERVERERROR, 'msg': MSG.SERVERERROR})
コード例 #12
0
def batch_change():
    if request.method == 'GET':
        return render_template('account/batch_account.html')
    elif request.method == 'POST':
        user_id = g.user_id
        data = json.loads(request.form.get('data'))
        batch_list = json.loads(data.get('batch_data'))
        label = data.get('label')
        member_state = data.get('member_state')
        try:
            if not label and not member_state:
                return jsonify({'code': RET.SERVERERROR, 'msg': '请填写参数!'})
            if label:
                for i in batch_list:
                    account = i.get('account')
                    SqlData().update_account_one('label', label, account,
                                                 user_id)
            if member_state:
                for i in batch_list:
                    account = i.get('account')
                    SqlData().update_account_one('member_state', member_state,
                                                 account, user_id)

            return jsonify({'code': RET.OK, 'msg': MSG.OK})
        except Exception as e:
            logging.error(str(e))
            return jsonify({'code': RET.SERVERERROR, 'msg': MSG.SERVERERROR})
コード例 #13
0
def index():
    '''
    查询主页面信息
    :return:
    '''
    admin_name = g.admin_name
    if admin_name != 'Juno':
        return '没有权限访问!'
    spent = SqlData().search_trans_sum_admin()
    balance, sum_balance = SqlData().search_user_sum_balance()
    card_remain = SqlData().search_card_remain_admin()
    out_money = SqlData().search_trans_sum_admin()
    card_use = SqlData().search_card_status("WHERE account_id != ''")
    card_no = SqlData().search_card_status("WHERE account_id is null AND activation != ''")
    ex_change = SqlData().search_admin_field('ex_change')
    ex_range = SqlData().search_admin_field('ex_range')
    hand = SqlData().search_admin_field('hand')
    dollar_hand = SqlData().search_admin_field('dollar_hand')
    context = dict()
    context['admin_name'] = admin_name
    context['spent'] = spent
    context['sum_balance'] = sum_balance
    context['card_use'] = card_use
    context['card_no'] = card_no
    context['ex_change'] = ex_change
    context['ex_range'] = ex_range
    context['hand'] = hand
    context['dollar_hand'] = dollar_hand
    context['balance'] = balance
    context['card_remain'] = card_remain
    context['out_money'] = out_money
    return render_template('admin/index.html', **context)
コード例 #14
0
def pay_log():
    results = dict()
    results['code'] = RET.OK
    results['msg'] = MSG.OK
    limit = request.args.get('limit')
    page = request.args.get('page')
    status = request.args.get('status')
    data = SqlData.search_pay_log(status)
    if not data:
        results['msg'] = MSG.NODATA
        return jsonify(results)
    info = list(reversed(data))
    page_list = list()
    for i in range(0, len(info), int(limit)):
        page_list.append(info[i:i + int(limit)])
    info_list = page_list[int(page) - 1]

    # 查询当次充值时的账号总充值金额
    new_list = list()
    for o in info_list:
        x_time = o.get('ver_time')
        user_id = o.get('cus_id')
        sum_money = SqlData.search_time_sum_money(x_time, user_id)
        o['sum_balance'] = round(sum_money, 2)
        new_list.append(o)

    results['data'] = new_list
    results['count'] = len(data)
    return jsonify(results)
コード例 #15
0
def task_list():
    if request.method == 'GET':
        try:
            middle_id = g.middle_id
            limit = request.args.get('limit')
            page = request.args.get('page')
            account_list = SqlData.search_user_middle_info(middle_id)
            if not account_list:
                return jsonify({'code': RET.OK, 'msg': MSG.NODATA})
            info_list = list()
            for u in account_list:
                u_id = u.get('id')
                card_count = SqlData.search_card_count(u_id, '')
                u['card_num'] = card_count
                info_list.append(u)
            page_list = list()
            results = dict()
            results['code'] = RET.OK
            results['msg'] = MSG.OK
            info_list = list(reversed(info_list))
            for i in range(0, len(info_list), int(limit)):
                page_list.append(info_list[i:i + int(limit)])
            results['data'] = page_list[int(page) - 1]
            results['count'] = len(info_list)
            return jsonify(results)
        except Exception as e:
            logging.error(str(e))
            return jsonify({'code': RET.SERVERERROR, 'msg': MSG.SERVERERROR})
コード例 #16
0
ファイル: admin.py プロジェクト: HelenLiu97/huihui
def change_pass():
    if request.method == 'GET':
        admin_name = g.admin_name
        context = dict()
        context['admin_name'] = admin_name
        return render_template('admin/changePwd.html', **context)
    if request.method == 'POST':
        results = {"code": RET.OK, "msg": MSG.OK}
        data = json.loads(request.form.get('data'))
        old_pass = data.get('old_pass')
        new_pass_one = data.get('new_pass_one')
        new_pass_two = data.get('new_pass_two')
        if new_pass_two != new_pass_one:
            results['code'] = RET.SERVERERROR
            results['msg'] = '两次输入密码不一致!'
            return jsonify(results)
        res = re.match(
            '(?!.*\s)(?!^[\u4e00-\u9fa5]+$)(?!^[0-9]+$)(?!^[A-z]+$)(?!^[^A-z0-9]+$)^.{8,16}$',
            new_pass_one)
        if not res:
            results['code'] = RET.SERVERERROR
            results['msg'] = '密码不符合要求!'
            return jsonify(results)
        password = SqlData.search_admin_field('password')
        if old_pass != password:
            results['code'] = RET.SERVERERROR
            results['msg'] = '密码错误!'
            return jsonify(results)
        SqlData.update_admin_field('password', new_pass_one)
        session.pop('admin_id')
        session.pop('admin_name')
        return jsonify(results)
コード例 #17
0
ファイル: admin.py プロジェクト: HelenLiu97/huihui
def middle_info_html():
    user_id = request.args.get('user_id')
    middle_user_id = SqlData.middle_user_id(name=user_id)
    middle_data = SqlData.middle_user_data(middle_id=middle_user_id)
    context = dict()
    context['pay_list'] = middle_data
    return render_template('admin/middle_info.html', **context)
コード例 #18
0
ファイル: admin.py プロジェクト: HelenLiu97/huihui
def lock_bank():
    bank_number = request.args.get('bank_number')
    status = SqlData.search_bank_status(bank_number)
    if status == 0:
        SqlData.update_bank_status(bank_number, 1)
    else:
        SqlData.update_bank_status(bank_number, 0)
    return jsonify({'code': RET.OK, 'msg': MSG.OK})
コード例 #19
0
def bento_refund():
    page = request.args.get('page')
    limit = request.args.get('limit')
    acc_name = request.args.get('acc_name')
    order_num = request.args.get('order_num')
    time_range = request.args.get('time_range')

    name_sql = ""
    order_sql = ""
    time_sql = ""

    if acc_name:
        name_sql = "account.name='{}'".format(acc_name)
    if order_num:
        order_sql = "account_trans.card_no='{}'".format(order_num)
    if time_range:
        min_time = time_range.split(' - ')[0] + ' 00:00:00'
        max_time = time_range.split(' - ')[1] + ' 23:59:59'
        time_sql = "account_trans.do_date BETWEEN '{}' and '{}'".format(min_time, max_time)

    if name_sql and time_sql and order_sql:
        sql_all = "AND " + name_sql + " AND " + order_sql + " AND " + time_sql
    elif name_sql and order_sql:
        sql_all = "AND " + name_sql + " AND " + order_sql
    elif time_sql and order_sql:
        sql_all = "AND " + time_sql + " AND " + order_sql
    elif name_sql and time_sql:
        sql_all = "AND " + name_sql + " AND " + time_sql
    elif name_sql:
        sql_all = "AND " + name_sql
    elif order_sql:
        sql_all = "AND " + order_sql
    elif time_range:
        sql_all = "AND " + time_sql
    else:
        sql_all = ""
    results = {"code": RET.OK, "msg": MSG.OK, "count": 0, "data": ""}
    task_info = SqlData.bento_refund_data(sql_all)
    if len(task_info) == 0:
        results['MSG'] = MSG.NODATA
        return jsonify(results)
    page_list = list()
    task_info = sorted(task_info, key=operator.itemgetter('time'))
    task_info = list(reversed(task_info))
    for i in range(0, len(task_info), int(limit)):
        page_list.append(task_info[i:i + int(limit)])
    data = page_list[int(page) - 1]

    for o in data:
        x_time = o.get("time")
        user_id = o.get("user_id")
        sum_money = SqlData.search_bento_sum_money(user_id=user_id, x_time=x_time)
        sum_refund = SqlData.search_bento_sum_refund(user_id=user_id, x_time=x_time)
        o["sum_balance"] = round(sum_money, 2)
        o["sum_refund"] = round(sum_refund, 2)
    results['data'] = data
    results['count'] = len(task_info)
    return jsonify(results)
コード例 #20
0
ファイル: user.py プロジェクト: HelenLiu97/huihui
def user_password():
    user_id = g.user_id
    vice_id = g.vice_id
    if user_id and not vice_id:
        password = SqlData.search_user_field('password', user_id)
        return jsonify({'code': RET.OK, 'msg': password})
    else:
        password = SqlData.search_one_acc_vice(vice_id).get('v_password')
        return jsonify({'code': RET.OK, 'msg': password})
コード例 #21
0
def push_log():

    '''
    卡交易记录接口
    '''

    try:
        user_id = g.user_id
        page = request.args.get('page')
        limit = request.args.get('limit')
        range_time = request.args.get('range_time')
        card_no = request.args.get('card_no')
        trans_type = request.args.get('trans_type')
        if range_time:
            start_time = range_time.split(" - ")[0]
            end_time = range_time.split(" - ")[1] + ' 23:59:59'
            time_sql = " AND timestamp BETWEEN '" + start_time + "' AND '" + end_time + "'"

            card_sql = ""
            if card_no:
                card_sql = " AND card_no LIKE '%" + card_no + "%'"

            trans_sql = ""
            if trans_type:
                trans_sql = " AND trans_type ='" + trans_type + "'"

            sql = time_sql + card_sql + trans_sql
        else:
            start_index = (int(page) - 1) * int(limit)
            sql = ' ORDER BY push_log.id desc limit ' + str(start_index) + ", " + limit + ';'

        results = dict()
        results['msg'] = MSG.OK
        results['code'] = RET.OK
        info = SqlData().search_user_push(user_id, sql)
        if not info:
            results['msg'] = MSG.NODATA
            return jsonify(results)
        task_info = info
        page_list = list()

        if 'limit' in sql:
            s = 'push_log WHERE account_id={}'.format(user_id)
            results['data'] = task_info
        else:
            # 分页显示
            task_info = list(reversed(task_info))
            for i in range(0, len(task_info), int(limit)):
                page_list.append(task_info[i:i + int(limit)])
            results['data'] = page_list[int(page) - 1]
            s = 'push_log WHERE account_id={}'.format(user_id) + sql
        results['count'] = SqlData().search_table_count(s)
        return jsonify(results)
    except Exception as e:
        logging.error('查询卡交易推送失败:' + str(e))
        return jsonify({'code': RET.SERVERERROR, 'msg': MSG.SERVERERROR})
コード例 #22
0
def account_detail():
    user_id = g.user_id
    page = request.args.get('page')
    limit = request.args.get('limit')
    buy_state = request.args.get('buy_state')
    account = request.args.get('account')
    label = request.args.get('label')
    terrace = request.args.get('terrace')
    # print(page, limit, account, label, terrace)
    results = {"code": RET.OK, "msg": MSG.OK, "count": 0, "data": ""}
    page_list = list()
    if not account and not label and not terrace:
        try:
            if buy_state == "使用中":
                data = SqlData().search_account_ing("buy_state", buy_state,
                                                    user_id)
                data = list(reversed(data))
                for i in range(0, len(data), int(limit)):
                    page_list.append(data[i:i + int(limit)])
                results['data'] = page_list[int(page) - 1]
                results['count'] = len(data)
            elif buy_state == '未分配':
                buy_state = ""
                data = SqlData().search_account_ing("buy_state", buy_state,
                                                    user_id)
                data = list(reversed(data))
                for i in range(0, len(data), int(limit)):
                    page_list.append(data[i:i + int(limit)])
                results['data'] = page_list[int(page) - 1]
                results['count'] = len(data)
            else:
                data = SqlData().search_account(user_id)
                data = list(reversed(data))
                for i in range(0, len(data), int(limit)):
                    page_list.append(data[i:i + int(limit)])
                results['data'] = page_list[int(page) - 1]
                results['count'] = len(data)
        except Exception as e:
            logging.error(str(e))
            results['code'] = RET.SERVERERROR
            results['msg'] = MSG.NODATA
    else:
        sql_label = ''
        sql_account = ''
        sql_terrace = ''
        if label:
            sql_label = "AND label='" + label + "'"
        if account:
            sql_account = "AND account LIKE '%" + account + "%'"
        if terrace:
            sql_terrace = "AND terrace='" + terrace + "'"
        sql = sql_label + sql_account + sql_terrace
        data = SqlData().search_account_sql(sql, user_id)
        results['count'] = len(data)
        results['data'] = data
    return results
コード例 #23
0
def transation():
    if request.method == 'POST':
        data = request.form
        # 易票联支付平台交易号
        trade_no = data.get('trade_no')

        # 交易金额
        trans_amount = data.get('trans_amount')

        # 交易币种
        trans_currency_type = data.get('trans_currency_type')

        # 商户名称
        local_merchant_name = data.get('local_merchant_name')

        # 卡号
        card_no = data.get('card_no')

        # 结算金额
        settle_amount = data.get('settle_amount')

        # 结算币种
        settle_currency_type = data.get('settle_currency_type')

        # 交易状态
        trans_status = data.get('trans_status')

        # 交易类型
        trans_type = data.get('trans_type')

        # 推送时间戳
        timestamp = data.get('timestamp')

        # 将交易类型码和交易状态转换位对应的文字信息,存储到数据库
        trans_type_cn = TRANS_TYPE_LOG.get(trans_type)
        if trans_type_cn is None:
            trans_type_cn = trans_type

        trans_status_cn = TRANS_STATUS.get(trans_status)
        if trans_type_cn is None:
            trans_status_cn = trans_status

        # 有出现商户名称为none的情况
        if local_merchant_name is None:
            local_merchant_name = ""
        elif local_merchant_name == '香港龙日实业有限公司':
            local_merchant_name = '全球付'

        account_id = SqlData().search_card_field('account_id', card_no)

        if account_id:

            SqlData().insert_push_log(trade_no, card_no, trans_type_cn, timestamp, local_merchant_name, trans_amount,
                                      trans_currency_type, settle_amount, settle_currency_type, trans_status_cn, account_id)

        return 'success'
コード例 #24
0
def del_account():
    try:
        data = json.loads(request.form.get('data'))
        user_name = data.get('user_name')
        user_id = SqlData().search_user_field_name('id', user_name)
        SqlData().del_account_info(user_id)
        return jsonify({"code": RET.OK, "msg": MSG.OK})
    except Exception as e:
        logging.error(str(e))
        return jsonify({"code": RET.SERVERERROR, "msg": MSG.SERVERERROR})
コード例 #25
0
def index_pay():
    ex_change = SqlData.search_admin_field('ex_change')
    ex_range = SqlData.search_admin_field('ex_range')
    hand = SqlData.search_admin_field('hand')
    dollar_hand = SqlData.search_admin_field('dollar_hand')
    context = dict()
    context['ex_change'] = ex_change
    context['ex_range'] = ex_range
    context['hand'] = hand
    context['dollar_hand'] = dollar_hand
    return render_template('pay/index.html', **context)
コード例 #26
0
def package():
    '''
    查询不同套餐的对应的价格
    :return:
    '''
    key = request.args.get('key')
    data = SqlData().search_reg_money(key)
    money = data.get('money')
    days = data.get('days')
    price = data.get('price')
    return jsonify({'code': RET.OK, 'money': money, 'days': days, 'price': price})
コード例 #27
0
def notice():
    if request.method == 'GET':
        note = SqlData().search_admin_field('notice')
        context = dict()
        context['note'] = note
        return render_template('admin/notice.html', **context)
    if request.method == 'POST':
        data = json.loads(request.form.get('data'))
        note = data.get('note')
        SqlData().update_admin_field('notice', note)
        return jsonify({"code": RET.OK, "msg": MSG.OK})
コード例 #28
0
ファイル: admin.py プロジェクト: HelenLiu97/huihui
def push_log():
    '''
    卡交易推送接口
    :return:
    待解决搜索条件sql组合
    '''
    try:
        page = request.args.get('page')
        limit = request.args.get('limit')

        range_time = request.args.get('range_time')
        card_no = request.args.get('card_no')
        if range_time or card_no:
            start_time = range_time.split(" - ")[0]
            end_time = range_time.split(" - ")[1] + ' 23:59:59'
            time_sql = " timestamp BETWEEN '" + start_time + "' AND '" + end_time + "'"

            card_sql = ""
            if card_no:
                card_sql = " card_no LIKE '%" + card_no + "%'"

            sql = "WHERE" + time_sql + card_sql
        else:
            start_index = (int(page) - 1) * int(limit)
            sql = 'ORDER BY push_log.id desc limit ' + str(
                start_index) + ", " + limit + ';'

        results = dict()
        results['msg'] = MSG.OK
        results['code'] = RET.OK
        info = SqlData.search_push(sql)
        if not info:
            results['msg'] = MSG.NODATA
            return jsonify(results)
        task_info = info
        page_list = list()

        if 'limit' in sql:
            s = 'push_log'
            results['data'] = task_info
        else:
            # 分页显示
            for i in range(0, len(task_info), int(limit)):
                page_list.append(task_info[i:i + int(limit)])
            results['data'] = page_list[int(page) - 1]
            s = 'push_log ' + sql
        results['count'] = SqlData.search_table_count(s)
        return jsonify(results)
    except Exception as e:
        print(e)
        logging.error('查询卡交易推送失败:' + str(e))
        return jsonify({'code': RET.SERVERERROR, 'msg': MSG.SERVERERROR})
コード例 #29
0
def make_name(n):
    name_dict = SqlData().search_name_info()
    last_name = name_dict.get('last_name')
    female = name_dict.get('female')
    female_len = len(female)
    last_len = len(last_name)
    name_list = list()
    for i in range(n):
        name = female[random.randint(
            0, female_len - 1)] + " " + last_name[random.randint(
                0, last_len - 1)]
        name_list.append(name)
    return name_list
コード例 #30
0
def change_phone():
    middle_id = g.middle_id
    phone_num = request.args.get('phone_num')
    results = dict()
    try:
        SqlData.update_middle_field('phone_num', phone_num, middle_id)
        results['code'] = RET.OK
        results['msg'] = MSG.OK
        return jsonify(results)
    except Exception as e:
        logging.error(str(e))
        results['code'] = RET.SERVERERROR
        results['msg'] = MSG.SERVERERROR
        return jsonify(results)