コード例 #1
0
def withdraw_list(r):
    start, num = get_paginator(r)
    params = r.REQUEST
    condition = make_conditions(r, type='type', bankcard_id='bankcard_id', verify_status='verify_status')
    if 'create_time_start' in params:
        condition['create_time__gte'] = get_stamp_by_date(params['create_time_start'])
    if 'create_time_end' in params:
        condition['create_time__lte'] = get_stamp_by_date(params['create_time_end'])
    if 'user_id' in r.REQUEST:
        condition['bankcard__user_id'] = r.REQUEST['user_id']
    withdraws = Withdraw.objects.filter(**condition)[start:start + num]
    total = Withdraw.objects.filter(**condition).count()
    data = []
    for wit in withdraws:
        d = wit.to_dict()
        if wit.reward == 0:
            d['reward'] = wit.amount
        d['bank_name'] = wit.bankcard.bank_name
        d['bank_city'] = wit.bankcard.bank_city
        d['owner_name'] = wit.bankcard.owner_name
        d['account_id'] = wit.bankcard.account_id
        d['account_name'] = wit.bankcard.account_name
        d['user_id'] = wit.bankcard.user_id
        d['user_qq'] = wit.bankcard.user.qq
        d['user_name'] = wit.bankcard.user.idc_name
        d['user_phone'] = wit.bankcard.user.phone
        d['create_time'] = wit.create_time
        data.append(d)

    return JsonResponse(code=Const['code.success'],
                        data={'total': total, 'withdraws': data})
コード例 #2
0
def home_capital(request):
    user, last_notice = _home_init(request)
    user.notice_set(Const['model.remind.principal'], False)
    params = request.REQUEST
    page = int(params['page']) if 'page' in params else 1
    num = int(params['num']) if 'num' in params else 10
    start = (page - 1) * num
    timestamp = before15(30)
    conditions = make_conditions(request)
    conditions['user_id'] = user.id
    if 'create_time_start' in params or 'create_time_end' in params:
        if 'create_time_start' in params:
            conditions['create_time__gte'] = get_stamp_by_date(
                params['create_time_start'])
        if 'create_time_end' in params:
            conditions['create_time__lte'] = get_stamp_by_date(
                params['create_time_end'])
    else:
        conditions['create_time__gte'] = 0

    if 'capital_type' in params:
        if int(params['capital_type']) == 0:
            conditions['amount__lte'] = 0.0
        elif int(params['capital_type']) == 1:
            conditions['amount__gte'] = 0.0
    query = Record.objects.filter(**conditions)

    pagebar = _pagebar_obj(query.count(), page, num)
    records = query[start:start + num]
    return render(request, 'home/home_capital.html', locals())
コード例 #3
0
def rebate_export(r):
    start, num = get_paginator(r)
    params = r.REQUEST
    condition = make_conditions(r, type='type', bankcard_id='bankcard_id', verify_status='verify_status')
    if 'create_time_start' in params:
        condition['create_time__gte'] = get_stamp_by_date(params['create_time_start'])
    if 'create_time_end' in params:
        condition['create_time__lte'] = get_stamp_by_date(params['create_time_end'])
    if 'user_id' in r.REQUEST:
        condition['bankcard__user_id'] = r.REQUEST['user_id']
    withdraws = Withdraw.objects.filter(**condition)
    data = []
    for wit in withdraws:
        d = {}
        d['account_id'] = wit.bankcard.account_id
        d['owner_name'] = wit.bankcard.owner_name
        if wit.type == Const['model.withdraw.type.principal']:
            d['amount'] = wit.amount
        else:
            d['amount'] = wit.reward
        d['bank_name'] = wit.bankcard.bank_name
        d['account_name'] = wit.bankcard.account_name
        d['bank_city'] = wit.bankcard.bank_city
        data.append(d)
    metas = {
        'account_id': u'收款卡号',
        'owner_name': u'收款用户',
        'amount': u'返款金额',
        'bank_name': u'收款银行',
        'account_name': u'收款支行',
        'bank_city': u'归属',
    }
    return CsvResponse(metas, data)
コード例 #4
0
def user_capitalrecordexport(r, uid):
    conditions = make_conditions(r)
    conditions['user_id'] = uid
    params = r.REQUEST
    if 'create_time_start' in params or 'create_time_end' in params:
        if 'create_time_start' in params:
            conditions['create_time__gte'] = get_stamp_by_date(
                params['create_time_start'])
        if 'create_time_end' in params:
            conditions['create_time__lte'] = get_stamp_by_date(
                params['create_time_end'])
    else:
        conditions['create_time__gte'] = 0

    if 'capital_type' in params:
        if int(params['capital_type']) == 0:
            conditions['amount__lte'] = 0.0
        elif int(params['capital_type']) == 1:
            conditions['amount__gte'] = 0.0
    query = Record.objects.filter(**conditions)
    data = []
    for o in query:
        data.append({
            'time': get_datetime_by_stamp(o.create_time),
            'type': u'收入' if o.is_income() else u'支出',
            'content': o.description,
            'amount': o.amount,
        })
    return CsvResponse(
        {
            'time': u'时间',
            'type': u'收支类型',
            'content': u'描述',
            'amount': u'金额',
        }, data)
コード例 #5
0
def notice_list(r):
    start, num = get_paginator(r)
    conditions = {}
    params = r.REQUEST
    if 'type' in params:
        conditions['type'] = params['type']
    if 'publish_start_date' in params:
        conditions['create_time__gte'] = get_stamp_by_date(params['publish_start_date'])
    if 'publish_end_date' in params:
        conditions['create_time__lte'] = get_stamp_by_date(params['publish_end_date'])
    if 'keyword' in params:
        conditions['title__contains'] = params['keyword']
    total = Notice.objects.filter(**conditions).count()
    notices = Notice.objects.filter(**conditions)[start:start + num]
    return JsonResponse(code=Const['code.success'],
                        data={'total': total, 'notices': [n.to_dict() for n in notices]})
コード例 #6
0
def user_listidc(r):
    start, num = get_paginator(r)
    condition = make_conditions(r, id='user_id', verify_status='verify_status')
    if 'register_start_time' in r.REQUEST:
        condition['register_time__gte'] = get_stamp_by_date(
            r.REQUEST['register_start_time'])
    users = User.objects.exclude(idc_name='').filter(**condition)[start:start +
                                                                  num]
    logger.debug(users.query)
    total = User.objects.exclude(idc_name='').filter(**condition).count()
    data = []
    for u in users:
        try:
            idcphotos = json.loads(u.idc_photo)
        except Exception:
            idcphotos = [None, None]
        data.append({
            'user_id': u.id,
            'register_time': u.register_time,
            'user_name': u.idc_name,
            'idc_photo1': idcphotos[0],
            'idc_photo2': idcphotos[1],
            'verify_status': u.verify_status,
        })
    return JsonResponse(code=Const['code.success'],
                        data={
                            'total': total,
                            'users': data
                        })
コード例 #7
0
def tbaccount_list(r):
    start, num = get_paginator(r)
    condition = make_conditions(r, user_id='user_id', status='verify_status')
    if 'register_start_time' in r.REQUEST:
        condition['user__register_time__gte'] = get_stamp_by_date(
            r.REQUEST['register_start_time'])
    tbs = TBAccount.objects.filter(**condition)[start:start + num]
    total = TBAccount.objects.filter(**condition).count()
    data = []
    for t in tbs:

        d = t.to_dict()
        try:
            pics = json.loads(t.pic_paths)
        except Exception:
            pics = [None, None]
        if not isinstance(pics, list):
            pics = [None, None]

        # 获取user的身份证姓名信息,如果没有提交,那么使用旺旺号码
        idc_name = t.user.idc_name
        if (idc_name):
            d['name'] = idc_name
        else:
            d['name'] = u'未绑定身份证--' + d['name']
        d['pic1'] = pics[0]
        d['pic2'] = pics[1]
        d['register_time'] = t.user.register_time
        d['tb_register_time'] = t.register_time  # 旺旺注册时间
        data.append(d)
    return JsonResponse(code='code.success',
                        data={
                            'total': total,
                            'tbaccounts': data
                        })
コード例 #8
0
def record_list(r):
    start, num = get_paginator(r)
    condition = make_conditions(r,
                                user_id='user_id',
                                start_time='start_time',
                                end_time='end_time')
    if 'start_time' in condition:
        condition['create_time__gte'] = get_stamp_by_date(
            condition['start_time'])
    if 'end_time' in condition:
        condition['create_time__lte'] = get_stamp_by_date(
            condition['end_time'])
    total = Record.objects.filter(**sub_dict(
        condition, 'user_id', 'create_time__lte', 'create_time__gte')).count()
    records = Record.objects.filter(
        **sub_dict(condition, 'user_id', 'create_time__lte',
                   'create_time__gte'))[start:start + num]
    return JsonResponse(code=Const['code.success'],
                        data={
                            'total': total,
                            'records': [re.to_dict() for re in records]
                        })
コード例 #9
0
def bankcard_list(r):
    start, num = get_paginator(r)
    condition = make_conditions(r,
                                user_id='user_id',
                                verify_status='verify_status')
    if 'register_start_time' in r.REQUEST:
        condition['user__register_time__gte'] = get_stamp_by_date(
            r.REQUEST['register_start_time'])
    bankcards = Bankcard.objects.filter(**condition)[start:start + num]
    total = Bankcard.objects.filter(**condition).count()
    data = []
    for b in bankcards:
        d = b.to_dict()
        d['register_time'] = b.user.register_time
        data.append(d)
    return JsonResponse(code='code.success',
                        data={
                            'total': total,
                            'bankcards': data
                        })
コード例 #10
0
def user_list(r):
    start, num = get_paginator(r)
    conditions = make_conditions(r,
                                 pk='user_id',
                                 phone='phone',
                                 qq='qq',
                                 buyer_level='buyer_level',
                                 register_time='register_time')
    if 'register_time' in conditions:
        conditions['register_time'] = get_stamp_by_date(
            conditions['register_time'])
    total = User.objects.filter(**conditions).count()
    users = User.objects.filter(**conditions)[start:start + num]
    data = []
    for u in users:
        try:
            idcphotos = json.loads(u.idc_photo)
        except Exception:
            idcphotos = [None, None]
        data.append({
            'id': u.id,
            'register_time': u.register_time,
            'user_name': u.idc_name,
            'phone': u.phone,
            'qq': u.qq,
            'buyer_level': u.buyer_level,
            'seller_level': u.seller_level,
            'idc_photo1': idcphotos[0],
            'idc_photo2': idcphotos[1],
            'verify_status': u.verify_status,
            'principal': u.principal,
            'commission': u.commission,
            'flags': u.flag_dump(),
        })
    return JsonResponse(code=Const['code.success'],
                        data={
                            'total': total,
                            'users': data
                        })
コード例 #11
0
def task_flow_manage(r):
    user = User.objects.get_user_from_session(r)
    stores = user.store_set.filter(
        verify_status=Const['model.verify.check_pass'])
    params = r.REQUEST
    page = int(params['page']) if 'page' in params else 1
    num = int(params['num']) if 'num' in params else 10
    start = (page - 1) * num
    query_condition = [
        Q(task__store__user_id=user.id),
    ]
    be15 = before15(15)
    if 'store_id' in params:
        query_condition.append(Q(task__store_id=params['store_id']))
    if 'buyer_id' in params:
        query_condition.append(Q(tb__user_id=params['buyer_id']))
    if 'buyer_wangwang' in params:
        query_condition.append(Q(tb__wangwang=params['buyer_wangwang']))
    if 'task_id' in params:
        query_condition.append(Q(task_id=params['task_id']))
    if 'order_id' in params:
        query_condition.append(Q(pk=params['order_id']))
    #    if 'order_type' in params:
    #        ordertype = int(params['order_type'])
    #        if ordertype <= Const['model.order.type.max']:
    #            query_condition.append(Q(order_type=ordertype))
    if 'order_status' in params:
        if params['order_status'] == '1':
            query_condition.append(
                Q(status__in=[
                    Const['model.order.status.received'],
                    Const['model.order.status.step1'],
                    Const['model.order.status.step2'],
                ]))
        elif params['order_status'] == '4':
            query_condition.append(
                Q(status=Const['model.order.status.comment']))
        elif params['order_status'] == '5':
            query_condition.append(
                Q(status=Const['model.order.status.completed']))
    if 'receive_start' in params:
        query_condition.append(
            Q(receive_time__gte=get_stamp_by_date(params['receive_start'])))
    if 'receive_end' in params:
        query_condition.append(
            Q(receive_time__lte=get_stamp_by_date(params['receive_end'])))
    q = Order.objects.exclude(status__in=[Const['model.order.status.init'],
                                          Const['model.order.status.cancel']]).filter(*query_condition) \
        .filter(order_type__in=[Const['model.order.type.flow'], Const['model.order.type.collect']]) \
        .filter((Q(status=Const['model.order.status.completed']) & Q(update_time__gte=be15)) | \
                ~Q(status=Const['model.order.status.completed']))
    orders = q[start:start + num]
    logger.debug(orders.query)
    for o in orders:
        if o.receive_time:
            o.receive_time_str = get_datetime_by_stamp(o.receive_time)
    pagebar = {
        'record_total': q.count(),
        'record_per_page': num,
        'current_page': page,
    }
    pagebar['page_total'] = int(math.ceil(1.0 * pagebar['record_total'] / num))
    pagebar['page_total_list'] = range(1, pagebar['page_total'] + 1)
    return render(r, 'task/flow_manage.html', locals())
コード例 #12
0
def user_exportorders(r, uid):
    conditions = make_conditions(r,
                                 task__store_id='store_id',
                                 tb__wangwang='buyer_wangwang',
                                 task_id='task_id',
                                 tb__user_id='buyer_id',
                                 order_type='order_type')
    params = r.REQUEST
    conditions['task__store__user_id'] = uid
    if 'receive_start' in params:
        conditions['receive_time__gte'] = get_stamp_by_date(
            params['receive_start'])
    if 'receive_end' in params:
        conditions['receive_time__lte'] = get_stamp_by_date(
            params['receive_end'])
    if 'order_status' in params:
        if params['order_status'] == '1':
            conditions['status__in'] = [
                Const['model.order.status.received'],
                Const['model.order.status.step1'],
                Const['model.order.status.step2'],
                Const['model.order.status.step9']
            ]
        elif params['order_status'] == '2':
            conditions['status__in'] = [
                Const['model.order.status.step3'],
                Const['model.order.status.returnmoney']
            ]
        elif params['order_status'] == '3':
            conditions['status'] = Const['model.order.status.deliver']
        elif params['order_status'] == '4':
            conditions['status'] = Const['model.order.status.comment']
        elif params['order_status'] == '5':
            conditions['status'] = Const['model.order.status.completed']

    if 'o_type' in params:
        if params['o_type'] == 'flow':
            conditions['order_type__in'] = [
                Const['model.order.type.flow'],
                Const['model.order.type.collect']
            ]
        elif params['o_type'] == 'buy_order':
            conditions['order_type__in'] = [0, 1, 2, 5, 6]

    orders = Order.objects.exclude(status__in=[
        Const['model.order.status.init'], Const['model.order.status.cancel']
    ]).filter(**conditions)
    logger.debug(orders.query)
    data = []
    for o in orders:
        t = o.task
        bk = o.bankcard
        commodities = json.loads(t.commodities)
        search_entry = json.loads(t.search_entries)[
            o.search_entry_index] if o.search_entry_index >= 0 else None
        bc = o.get_buyer_commit()
        sc = o.get_seller_commit()
        data.append({
            'order_id':
            o.id,
            'receive_time':
            get_datetime_by_stamp(o.receive_time),
            'buyer_id':
            o.tb.user_id,
            'buyer_wangwang':
            o.tb.wangwang,
            'task_type':
            o.get_display_type(),
            'order_status':
            o.get_display_status(),
            'total_price':
            t.total_price,
            'buyer_commit':
            bc if bc else '',
            'seller_commit':
            sc if sc else '',
            'store_name':
            t.store.name,
            'commodity_name':
            commodities[0]['name'],
            'search_keyword':
            search_entry['keyword'] if search_entry else '',
            'bk_name':
            bk.owner_name if bk else '',
            'bk_bank':
            bk.bank_name if bk else '',
            'bk_account':
            bk.account_id if bk else '',
            'bk_city':
            bk.bank_city if bk else '',
            'bk_zh':
            bk.account_name if bk else '',
            'order_all_pay':
            o.seller_payment,
        })
    return CsvResponse(
        {
            'order_id': u'订单ID',
            'receive_time': u'接单时间',
            'buyer_id': u'买手ID',
            'buyer_wangwang': u'买手旺旺',
            'task_type': u'订单类型',
            'order_status': u'订单状态',
            'total_price': u'商家要求垫付金额',
            'buyer_commit': u'买手实际垫付金额',
            'seller_commit': u'商家实际返款金额',
            'store_name': u'店铺名',
            'commodity_name': u'商品名',
            'search_keyword': u'搜索关键词',
            'bk_name': u'返款人姓名',
            'bk_bank': u'返款银行名',
            'bk_account': u'返款账户',
            'bk_city': u'返款银行所在地',
            'bk_zh': u'返款银行支行',
            'order_all_pay': u'商家支付总额(包括佣金)',
        }, data)