Beispiel #1
0
def update_appraise_record(shop_id):
    """更新有用的好评记录的积分状态"""
    # 获取用户点击好评有礼的记录并对比更新
    appraise_list = list(pa_coll.find({'shop_id': shop_id, 'type':'appraise'}).sort("create_time", -1))
    # 取最新一条好评有礼记录
    if appraise_list:
        appraise = appraise_list[0]
        # 如果未解冻,则需判断时间是否在30天之前,若在30天之前,则不解冻
        if appraise['is_freeze']:
            last_create_time = appraise['create_time']
            # 如果在30天内,则需要判断在这段时间内是否有好评开车精灵,有则解冻
            if (last_create_time + datetime.timedelta(days = 30)) > datetime.datetime.today():
                comment_list = AppComment.objects.filter(user_nick = appraise['nick'], service_code = 'ts-25811', gmt_create__gte = appraise['create_time']).order_by('-id')
                if comment_list:
                    pa_coll.update({'_id':appraise['_id']}, {'$set':{'is_freeze':0, 'create_time':comment_list[0].gmt_create}})
                    # 解冻后需要刷新用户积分
                    PointManager.refresh_points_4nick(appraise['nick'])
Beispiel #2
0
    def bind_point(self):
        """【积分相关】积分数量"""

        point = 0
        try:
            point = CacheAdpter.get(CacheKey.WEB_JLB_COUNT % self.shop_id, 'web', 'no_cache')
            if point == 'no_cache':
                from apps.web.point import PointManager
                point = PointManager.refresh_points_4shop(shop_id = self.shop_id)
        except Exception, e:
            log.error('bind_point error,e=%s, shop_id=%s' % (e, self.shop_id))
Beispiel #3
0
def vip_home(request):
    from apps.web.point import PointManager, Sign
    from apps.web.utils import get_isneed_phone

    shop_id = request.user.shop_id
    customer = request.user.customer

    tapi = get_tapi(shop_id=shop_id)
    request.user.shop.sync_from_top(tapi)

    # 判断是否激活
    is_need_phone = get_isneed_phone(request.user)

    # 获取积分
    point_count = CacheAdpter.get(CacheKey.WEB_JLB_COUNT % shop_id, 'web',
                                  'no_cache')
    if point_count == 'no_cache':
        point_count = PointManager.refresh_points_4shop(
            shop_id=request.user.shop_id)

    # 区分积分等级
    grade, next_grade, parcent = Account.get_grade_display(shop_id=shop_id)

    # 历史最高积分
    history_highest_point = Account.get_history_highest_point(shop_id=shop_id)

    # 判断今天是否签到
    is_sign_today = Sign.is_sign_today(shop_id=shop_id)
    get_attendance_day = Sign.get_attendance_day(shop_id=shop_id)

    # 判断并获取用户收货信息
    info_dict = customer.perfect_info if customer else {}

    # 改代码新版并没有用到,需要注销掉
    # 获取兑换话费的人数
    #     phone_cost20_num = PointManager.get_exchange_gift_count(gift_type = 'phone_cost20') + 500 # 这里直接加了500
    #     discount_num = PointManager.get_exchange_gift_count(type = 'discount')

    data = {
        'point_count': point_count,
        'grade': grade,
        'parcent': parcent,
        'next_grade': next_grade,
        'is_sign_today': is_sign_today,
        'get_attendance_day': get_attendance_day,
        'info_dict': info_dict,
        #         'phone_cost20_num': phone_cost20_num,
        #         'discount_num': discount_num,
        'is_need_phone': is_need_phone,
        'history_highest_point': history_highest_point
    }
    return render_to_response('vip_home.html', {'data': data},
                              context_instance=RequestContext(request))
Beispiel #4
0
 def get_jlb_count(shop_id):
     """获取精灵币个数"""
     try:
         jlb_count = CacheAdpter.get(CacheKey.WEB_JLB_COUNT % shop_id,
                                     'web', 'no_cache')
         if jlb_count == 'no_cache':
             from apps.web.point import PointManager
             jlb_count = PointManager.refresh_points_4shop(
                 shop_id=request.user.shop_id)
         return jlb_count
     except Exception, e:
         log.error('get_jlb_count error,e=%s, shop_id=%s' % (e, shop_id))
         return 0
Beispiel #5
0
def invite_friend(request, template="invite_friend.html"):
    from apps.web.point import PointManager, Promotion4Shop

    shop_id = request.user.shop_id
    usable_point = PointManager.get_point(shop_id=shop_id)
    used_point = PointManager.get_used_point(shop_id=shop_id)

    # 用户推荐 方式2的记录
    #     promotion_list = Promotion4Shop.get_promotion_4shop(shop_id = shop_id)

    # 用户推荐方式2
    promotion_list = list(
        pa_coll.find({
            'shop_id': int(request.user.shop_id),
            'type': 'promotion'
        }).sort("create_time", -1))
    data = {
        'usable_point': usable_point,
        'used_point': used_point,
        'promotion_list': promotion_list
    }
    return render_to_response(template,
                              data,
                              context_instance=RequestContext(request))
Beispiel #6
0
def point_praise(request):
    """好评送积分"""
    from apps.web.point import PointManager

    shop_id = request.user.shop_id
    # 获取积分
    point_count = CacheAdpter.get(CacheKey.WEB_JLB_COUNT % shop_id, 'web',
                                  'no_cache')
    if point_count == 'no_cache':
        point_count = PointManager.refresh_points_4shop(
            shop_id=request.user.shop_id)

    # 获取随机好评
    # appraises = Appraise.objects.filter().order_by('?')
    # appraises = appraises[:5]
    # return render_to_response('point_praise.html', {'point_count':point_count, 'appraises':appraises}, context_instance = RequestContext(request))
    return render_to_response('point_praise.html',
                              {'point_count': point_count},
                              context_instance=RequestContext(request))
Beispiel #7
0
def point_mall(request):
    """积分商城"""
    from apps.web.point import PointManager

    shop_id = request.user.shop_id
    customer = request.user.customer
    is_perfect_info = customer.is_perfect_info if customer else False
    # 获取积分
    point_count = CacheAdpter.get(CacheKey.WEB_JLB_COUNT % shop_id, 'web',
                                  'no_cache')
    if point_count == 'no_cache':
        point_count = PointManager.refresh_points_4shop(
            shop_id=request.user.shop_id)

    shop_items = MemberStore.query_present_templates()
    return render_to_response('point_mall.html', {
        'is_perfect_info': is_perfect_info,
        "shop_items": shop_items,
        'point_count': point_count
    },
                              context_instance=RequestContext(request))
Beispiel #8
0
def update_appraise_record(vaild_list):
    """跟新有用的记录"""
    for v in vaild_list:
        pa_coll.update({'_id':v['_id']}, {'$set':{'is_freeze':0, 'gmt_create':v['gmt_create']}})
        PointManager.refresh_points_4nick(v['nick'])