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())
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())
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())