Beispiel #1
0
def home_capital_recharge(r):
    user, last_notice = _home_init(r)
    recharges = Recharge.objects.filter(user_id=user.id)[0:5]
    for re in recharges:
        re.create_time_str = get_datetime_by_stamp(re.create_time)
        re.verify_time_str = get_datetime_by_stamp(
            re.verify_time) if re.verify_time else ''
    return render(r, 'home/home_capital_recharge.html', locals())
Beispiel #2
0
def task_order_detail(r):
    user = User.objects.get_user_from_session(r)
    order = Order.objects.get(pk=r.REQUEST['order_id'])
    task = order.task
    bankcard = order.bankcard
    appeal_types = AppealType.objects.filter(
        type=Const['model.notice.type.seller'])
    progress_appeal = Appeal.objects.filter(
        order=order, status=Const['model.appeal.status.in_progress'])
    task_type = task.task_type
    if bankcard:
        account = bankcard.account_id
        account_str = ' '.join(
            [account[i:i + 4] for i in range(0, len(account), 4)])
    is_comment_order = True if order.order_type in (
        Const['model.order.type.normal'],
        Const['model.order.type.keyword'],
        Const['model.order.type.image'],
    ) else False
    if order.receive_time:
        order.receive_time_str = get_datetime_by_stamp(order.receive_time)
    order.check_upgrade()
    # 借用flags用来存储是否被拉黑的状态
    buyer = order.tb.user
    order.flags = 0
    if Blacklist.objects.filter(seller=user, buyer=buyer):
        order.flags = 1

    steps = []
    for key in order.get_steps():
        order.get_steps()[key]['time_str'] = get_datetime_by_stamp(
            order.get_steps()[key]['create_time'])
        steps.append(order.get_steps()[key])

    #_steps=json.loads(order.step_detail)

    # logger.info(steps)
    # for key in steps:
    #    steps[key]['time_str']=get_datetime_by_stamp(steps[key]['create_time'])

    return render(r, 'task/order_detail.html', locals())
Beispiel #3
0
def task_flow_detail(r):
    user = User.objects.get_user_from_session(r)
    task = Task.objects.get(pk=r.REQUEST['task_id'])
    task.create_time_str = get_datetime_by_stamp(task.create_time)
    orders = Order.objects.filter(task_id=r.REQUEST['task_id']) \
             .filter(order_type__in=[Const['model.order.type.flow'], Const['model.order.type.collect']])
    total_orders = orders.count()
    receive_orders = 0
    commodities = json.loads(task.commodities)
    search_entries = json.loads(task.search_entries)
    order_types = json.loads(task.order_types)
    store = task.store
    if task.status == Const['model.task.status.need_payment']:
        status = 0
    elif task.verify_status == Const['model.verify.need_check']:
        status = 1
    elif task.status == Const['model.task.status.in_progress']:
        status = 2
    elif task.status == Const['model.task.status.closed']:
        status = 3
    for order in orders:
        if order.status != Const['model.order.status.init']:
            receive_orders = receive_orders + 1
    return render(r, 'task/flow_task_detail.html', locals())
Beispiel #4
0
def notice(r, nid):
    notice = Notice.objects.get(pk=nid)
    notice.update_time = get_datetime_by_stamp(notice.update_time)
    return render(r, 'mobile/notice.html', {'notice': notice})
Beispiel #5
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())
Beispiel #6
0
def task_return_manage(r):
    user = User.objects.get_user_from_session(r)
    user.notice_set(Const['model.remind.no_money'], False)
    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

    q_not_return = Q(status=Const['model.order.status.step3'])
    q_returned = Q(status__in=[
        Const['model.order.status.completed'],
        Const['model.order.status.comment'],
        Const['model.order.status.returnmoney'],
        Const['model.order.status.deliver'], Const['model.order.status.affirm']
    ])
    q_all = Q(status__in=[
        Const['model.order.status.step3'],
        Const['model.order.status.completed'],
        Const['model.order.status.comment'],
        Const['model.order.status.returnmoney'],
        Const['model.order.status.deliver'], Const['model.order.status.affirm']
    ])

    query_condition=[Q(order_type__in=[Const['model.order.type.normal'],
                                       Const['model.order.type.keyword'],
                                       Const['model.order.type.image'],
                                       Const['model.order.type.advance'],
                                      ]),\
                     Q(task__store__user_id=user.id)\
                    ]
    if 'store_id' in params:
        query_condition.append(Q(task__store_id=params['store_id']))
    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 'buyer_id' in params:
        query_condition.append(Q(tb__user_id=params['buyer_id']))
    if 'return_status' in params:
        if params['return_status'] == '1':
            query_condition.append(q_returned)
        else:
            query_condition.append(q_not_return)
    else:
        query_condition.append(q_not_return)
    if 'buyer_wangwang' in params:
        query_condition.append(Q(tb__wangwang=params['buyer_wangwang']))
    orders = Order.objects.filter(*query_condition)[start:start + num]
    logger.debug(orders.query)
    for order in orders:
        order.buy_time_str = get_datetime_by_stamp(
            order.get_step_item(2, 'create_time'))
        if order.task.task_type == Const['model.task.type.special'] or \
        order.order_type == Const['model.order.type.flow'] or \
        order.order_type == Const['model.order.type.collect']:
            order.buy_pic1 = order.get_step_item(0, 'pic_path')[0]
            order.buy_pic2 = order.get_step_item(0, 'pic_path')[1]
        elif order.order_type == Const['model.order.type.advance']:
            order.buy_pic1 = order.get_step_item(0, 'pic_path')[0]
            order.buy_pic2 = order.get_step_item(0, 'pic_path')[1]
        else:
            order.buy_pic1 = order.get_step_item(2, 'pic_path')[0]
            order.buy_pic2 = order.get_step_item(2, 'pic_path')[1]
        # logger.info('task_return_manage order_type is %d'%order.order_type)
    pagebar = {
        'record_total': Order.objects.filter(*query_condition).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/return_manage.html', locals())
Beispiel #7
0
def home_blicklist(r):
    user, last_notice = _home_init(r)
    blacklists = Blacklist.objects.filter(seller=user)
    for b in blacklists:
        b.time_str = get_datetime_by_stamp(b.create_time)
    return render(r, 'home/home_blacklist.html', locals())
Beispiel #8
0
def home_task_flows(r):
    user, last_notice = _home_init(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(store__user_id=user.id),
    ]
    if 'store_id' in params:
        query_condition.append(Q(store_id=params['store_id']))
    if 'task_id' in params:
        query_condition.append(Q(id=params['task_id']))
    if 'publish_start' in params:
        query_condition.append(
            Q(publish_start_date__gte=params['publish_start']))
    if 'publish_end' in params:
        query_condition.append(
            Q(publish_start_date__lte=params['publish_end']))
    if 'task_status' in params:
        task_status = int(params['task_status'])
        if task_status == 0:
            query_condition.append(
                Q(verify_status=Const['model.verify.need_check']))
        elif task_status == 1:
            query_condition.append(
                Q(verify_status=Const['model.verify.check_pass']))
        elif task_status == 2:
            query_condition.append(Q(status=Const['model.task.status.closed']))
        elif task_status == 3:
            query_condition.append(
                Q(verify_status=Const['model.verify.check_deny']))
    if 'task_type' in params:
        task_type = int(params['task_type'])
        if task_type == 0:
            query_condition.append(
                Q(task_type=Const['model.task.type.mobile_taobao']))
    if 'keywords' in params:
        query_condition.append(
            Q(commodities_contains=params['keywords'])
            | Q(search_entries=params['keywords']))
    timestamp = before15(30)
    tasks = Task.objects.filter(*query_condition).filter(
        create_time__gte=timestamp).filter(flow=True)[start:start + num]
    logger.debug(tasks.query)
    odd = True
    for task in tasks:
        orders = Order.objects.filter(task_id=task.id) \
        .filter(order_type__in=[Const['model.order.type.flow'], Const['model.order.type.collect']])
        # orders=task.order_set.filter()
        task.total_orders = orders.count()
        logger.debug(task.id)
        task.odd = odd
        odd = not odd
        task.jsearch_entries = json.loads(task.search_entries)
        task.mobile = True if task.task_type in (
            Const['model.task.type.mobile_taobao'], ) else False
        task.jcommodities = json.loads(task.commodities)
        task.create_time_str = get_datetime_by_stamp(task.create_time)
        if task.status == Const['model.task.status.need_payment']:
            task.status_str = '待支付'
        elif task.status == Const['model.task.status.cancel']:
            task.status_str = '已取消'
        elif task.verify_status == Const['model.verify.check_deny']:
            task.status_str = '审核不通过'
        elif task.verify_status == Const['model.verify.need_check']:
            task.status_str = '待审核'
        elif task.status == Const['model.task.status.in_progress']:
            task.status_str = '进行中'
        elif task.status == Const['model.task.status.closed']:
            task.status_str = '已完成'
        elif task.status == Const['model.task.status.frozen']:
            task.status_str = '已冻结'
        task.order_1 = task.order_2 = task.order_5 = task.order_6 = 0
        for o in orders:
            if o.status == Const['model.order.status.init']:
                task.order_1 = task.order_1 + 1
            elif o.status == Const['model.order.status.comment']:
                task.order_5 = task.order_5 + 1
            elif o.status == Const['model.order.status.completed']:
                task.order_6 = task.order_6 + 1
            elif o.status in (
                    Const['model.order.status.received'],
                    Const['model.order.status.step1'],
                    Const['model.order.status.step2'],
            ):
                task.order_2 = task.order_2 + 1
    pagebar={
             'record_total': Task.objects.filter(*query_condition).filter(create_time__gte=timestamp) \
                                .filter(Q(flow=True) | Q(task_type=Const['model.task.type.flow'])).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, 'home/home_task_flow.html', locals())
Beispiel #9
0
def task_order_appeal(request, oid):
    user = User.objects.get_user_from_session(request)
    order = Order.objects.get(pk=oid)
    if order.receive_time:
        order.receive_time_str = get_datetime_by_stamp(order.receive_time)
    return render(request, 'task/order_appeal.html', locals())