Ejemplo n.º 1
0
def get_card_create(request):
    """
    显示创建卡规则
    """
    user_ids = [
        user.id for user in User.objects.filter(
            username__in=WEIZOOM_CARD_BELONG_TO_OWNER)
    ]
    user_id2mpuser_name = []
    userprofiles = UserProfile.objects.filter(user_id__in=user_ids)
    for profile in userprofiles:
        if profile.store_name:
            user_id2mpuser_name.append({
                'user_id': profile.user_id,
                'mpuser_name': profile.store_name
            })

    c = RequestContext(
        request, {
            'first_nav_name': export.MALL_CARD_FIRST_NAV,
            'second_navs': export.get_card_second_navs(request),
            'second_nav_name': export.MALL_CARD_MANAGER_NAV,
            'belong_to_owner': user_id2mpuser_name
        })
    return render_to_response('card/editor/edit_weizoom_card_rule.html', c)
Ejemplo n.º 2
0
def get_card_detail(request):
    """
    显示某一规则下的卡列表
    """
    weizoomcardpermission = WeiZoomCardPermission.objects.filter(
        user_id=request.user.id)
    can_batch_active_card = can_batch_stop_card = can_add_card = can_export_batch_card = 0
    if weizoomcardpermission:
        can_batch_active_card = weizoomcardpermission[0].can_batch_active_card
        can_batch_stop_card = weizoomcardpermission[0].can_batch_stop_card
        can_add_card = weizoomcardpermission[0].can_add_card
        can_export_batch_card = weizoomcardpermission[0].can_export_batch_card
    rule_id = request.GET.get('id', '')
    if rule_id:
        rule = WeizoomCardRule.objects.get(id=rule_id)
        c = RequestContext(
            request, {
                'first_nav_name': export.MALL_CARD_FIRST_NAV,
                'second_navs': export.get_card_second_navs(request),
                'second_nav_name': export.MALL_CARD_MANAGER_NAV,
                'weizoom_card_rule': rule,
                'can_batch_active_card': can_batch_active_card,
                'can_batch_stop_card': can_batch_stop_card,
                'can_add_card': can_add_card,
                'can_export_batch_card': can_export_batch_card
            })
        return render_to_response('card/editor/list_weizoom_card_detail.html',
                                  c)
Ejemplo n.º 3
0
def edit_weizoom_card_account_permission(request):
    is_manage = 'manage' in request.GET
    c = RequestContext(request, {
        'first_nav_name': export.MALL_CARD_FIRST_NAV,
        'second_navs': export.get_card_second_navs(request),
        'second_nav_name': export.MALL_CARD_PERMISSIONS_NAV,
        'is_manage': is_manage
    })
    return render_to_response('card/editor/list_weizoom_card_manager.html', c)
Ejemplo n.º 4
0
def get_overview_data(request):
    c = RequestContext(
        request, {
            'first_nav_name': export.MALL_CARD_FIRST_NAV,
            'second_navs': export.get_card_second_navs(request),
            'second_nav_name': export.MALL_CARD_CENSUS_NAV,
            'third_nav_name': export.MALL_CARD_TOTAL_CENSUS_NAV,
        })
    return render_to_response('card/editor/overview.html', c)
Ejemplo n.º 5
0
def get_card_channel_details(request):
    """
    微众卡明细页面
    """
    owner_id = request.GET.get('owner_id', '')
    start_date = request.GET.get('start_date', '')
    end_date = request.GET.get('end_date', '')
    channel = User.objects.get(id=owner_id)
    if not start_date:
        total_days, start_date, cur_date, end_date = dateutil.get_date_range(
            dateutil.get_today(), "6", 0)
        start_date = str(start_date) + ' 00:00:00'
        end_date = str(end_date) + ' 23:59:59'
    webapp = WebApp.objects.get(owner_id=owner_id)
    orders = Order.by_webapp_id(
        webapp.appid).filter(created_at__gte=start_date,
                             created_at__lte=end_date).order_by('-created_at')
    id2order_ids = {}
    for r in orders:
        id2order_ids[r.order_id] = r.id
    order_ids = id2order_ids.keys()
    card_orders = WeizoomCardHasOrder.objects.filter(
        order_id__in=order_ids).order_by('-created_at')
    # orders = WeizoomCardHasOrder.objects.filter(owner_id=owner_id,created_at__gte=start_date,created_at__lte=end_date).exclude(order_id=-1)
    use_money = 0
    refund = 0
    card_ids = set()
    order_ids = set()
    for order in card_orders:
        if order.event_type == "使用":
            use_money += order.money
        else:
            refund += order.money
        card_ids.add(order.card_id)
        order_ids.add(order.order_id)
    channel.use_money = '%.2f' % use_money
    channel.refund = '%.2f' % -refund
    channel.order_count = len(order_ids)
    channel.use_count = len(card_ids)
    channel.start_date = start_date
    channel.end_date = end_date

    c = RequestContext(
        request, {
            'first_nav_name': export.MALL_CARD_FIRST_NAV,
            'second_navs': export.get_card_second_navs(request),
            'second_nav_name': export.MALL_CARD_CENSUS_NAV,
            'third_nav_name': export.MALL_CARD_BY_CHANNEL_NAV,
            'channel': channel,
            'has_order': orders.count() > 0,
            'owner_id': owner_id
        })
    return render_to_response('card/editor/weizoom_channel_card_detail.html',
                              c)
Ejemplo n.º 6
0
def edit_weizoom_card_account_permission(request):
    weizoomcardpermission=WeiZoomCardPermission.objects.filter(user_id=request.user.id)
    can_change_shop_config=0
    if weizoomcardpermission:
        can_change_shop_config=weizoomcardpermission[0].can_change_shop_config
    c = RequestContext(request, {
        'first_nav_name': export.MALL_CARD_FIRST_NAV,
        'second_navs': export.get_card_second_navs(request),
        'second_nav_name': export.MALL_CARD_MANAGER_NAV,
        'can_change_shop_config': can_change_shop_config,
    })
    return render_to_response('card/editor/edit_account_has_permissions.html',c )
Ejemplo n.º 7
0
def get_cards(request):
    """
    显示卡充值明细表
    """
    c = RequestContext(
        request, {
            'first_nav_name': export.MALL_CARD_FIRST_NAV,
            'second_navs': export.get_card_second_navs(request),
            'second_nav_name': export.MALL_CARD_MANAGER_NAV,
            'third_nav_name': export.MONEY_CARD_MANAGER_RECHARGE_NAV,
        })

    return render_to_response('card/editor/card_recharge_detail.html', c)
Ejemplo n.º 8
0
def get_cards_num_census(request):
    """
    微众卡列表页面
    """
    has_cards = (WeizoomCard.objects.filter().count() > 0)
    c = RequestContext(
        request, {
            'first_nav_name': export.MALL_CARD_FIRST_NAV,
            'second_navs': export.get_card_second_navs(request),
            'second_nav_name': export.MALL_CARD_CENSUS_NAV,
            'third_nav_name': export.MALL_CARD_BY_CARD_NAV,
            'has_cards': has_cards,
        })
    return render_to_response('card/editor/list_weizoom_num_card.html', c)
Ejemplo n.º 9
0
def get_cards(request):
    """
    显示卡规则列表
    """
    weizoomcardpermission = WeiZoomCardPermission.objects.filter(
        user_id=request.user.id)
    can_create_card = 0
    if weizoomcardpermission:
        can_create_card = weizoomcardpermission[0].can_create_card
    c = RequestContext(
        request, {
            'first_nav_name': export.MALL_CARD_FIRST_NAV,
            'second_navs': export.get_card_second_navs(request),
            'second_nav_name': export.MALL_CARD_MANAGER_NAV,
            'third_nav_name': export.MONEY_CARD_MANAGER_CREATE_NAV,
            'can_create_card': can_create_card,
        })

    return render_to_response('card/editor/list_weizoom_card.html', c)
Ejemplo n.º 10
0
def get_chan_channel_census(request):
    """
    微众卡列表页面
    """
    total_days, start_date, cur_date, end_date = dateutil.get_date_range(
        dateutil.get_today(), "6", 0)
    start_date = str(start_date)
    end_date = str(end_date)
    has_cards = (WeizoomCard.objects.filter().count() > 0)
    c = RequestContext(
        request, {
            'first_nav_name': export.MALL_CARD_FIRST_NAV,
            'second_navs': export.get_card_second_navs(request),
            'second_nav_name': export.MALL_CARD_CENSUS_NAV,
            'third_nav_name': export.MALL_CARD_BY_CHANNEL_NAV,
            'has_cards': has_cards,
            'start_date': start_date,
            'end_date': end_date
        })
    return render_to_response('card/editor/list_weizoom_channel_card.html', c)
Ejemplo n.º 11
0
def get_card_num_details(request):
    """
    微众卡明细页面
    """
    card_id = request.GET.get('card_id', '')
    start_date = request.GET.get('start_date', '')
    end_date = request.GET.get('end_date', '')
    card = WeizoomCard.objects.get(weizoom_card_id=card_id)
    active_card_user_id = card.active_card_user_id
    IS_CARD_RULE = request.GET.get('IS_CARD_RULE', '')

    # if not start_date:
    #     total_days, start_date, cur_date, end_date = dateutil.get_date_range(dateutil.get_today(), "6", 0)
    #     start_date = str(start_date) + ' 00:00:00'
    #     end_date = str(end_date) + ' 23:59:59'
    if card:
        status_str = u''
        password_is_show = False
        if card.is_expired:
            status_str = u'己过期'
            if active_card_user_id == request.user.id:
                password_is_show = True
        else:
            if card.status == WEIZOOM_CARD_STATUS_UNUSED:
                status_str = u'未使用'
                if active_card_user_id == request.user.id:
                    password_is_show = True
            if card.status == WEIZOOM_CARD_STATUS_USED:
                status_str = u'使用中'
                if active_card_user_id == request.user.id:
                    password_is_show = True
            if card.status == WEIZOOM_CARD_STATUS_INACTIVE:
                status_str = u'未激活'
            if card.status == WEIZOOM_CARD_STATUS_EMPTY:
                status_str = u'己用完'
                if active_card_user_id == request.user.id:
                    password_is_show = True

        card.status_str = status_str
        card_rule = WeizoomCardRule.objects.get(id=card.weizoom_card_rule_id)
        card.rule_name = card_rule.name
        card.rule_money = card_rule.money
        card_rule_name = card.rule_name
        weizoom_card_rule_id = card_rule.id
        card_type = u''
        if card_rule.card_type == WEIZOOM_CARD_EXTERNAL_USER:
            card_type = u'外部卡'
        if card_rule.card_type == WEIZOOM_CARD_INTERNAL_USER:
            card_type = u'内部卡'
        if card_rule.card_type == WEIZOOM_CARD_GIFT_USER:
            card_type = u'赠品卡'
        card.type = card_type
        card_orders = WeizoomCardHasOrder.objects.filter(card_id=card.id)
        card_operations = WeizoomCardOperationLog.objects.filter(
            card_id=card.id)
        card.start_date = start_date
        card.end_date = end_date

        if IS_CARD_RULE == 'TRUE':
            c = RequestContext(
                request, {
                    'first_nav_name': export.MALL_CARD_FIRST_NAV,
                    'second_navs': export.get_card_second_navs(request),
                    'second_nav_name': export.MALL_CARD_MANAGER_NAV,
                    'card_rule_name': card_rule_name,
                    'weizoom_card_rule_id': weizoom_card_rule_id,
                    'card': card,
                    'card_orders': card_orders,
                    'card_operations': card_operations,
                    'IS_CARD_RULE': True,
                    'password_is_show': password_is_show
                })
        else:
            c = RequestContext(
                request, {
                    'first_nav_name': export.MALL_CARD_FIRST_NAV,
                    'second_navs': export.get_card_second_navs(request),
                    'second_nav_name': export.MALL_CARD_CENSUS_NAV,
                    'third_nav_name': export.MALL_CARD_BY_CARD_NAV,
                    'card': card,
                    'card_orders': card_orders,
                    'card_operations': card_operations,
                    'IS_CARD_RULE': False
                })

    return render_to_response('card/editor/weizoom_num_card_detail.html', c)