Beispiel #1
0
def send_staff_unread(request): 
    unread_mentors = unread_mentor()
    unread_waiters = unread_waiter()
    if not unread_mentors and not unread_mentors:
        return HttpResponse('')
    
    staffs = RelevantStaff.objects.exclude(send_mentor=False,send_waiter=False)
    
    for s in staffs:
        #发送短信,已有队列
        if s.send_mentor and unread_mentors and s.mobile:
            msg = "<" + SITE_INFO.name + ">导师留言后台有" + str(unread_mentors) + "条新客户留言. 请及时登录回复. 登录地址: " + SITE_INFO.domain + reverse('aq')
            helpers.send_staff_mobile(s.mobile,msg)
        if s.send_waiter and unread_waiters and s.mobile:
            msg = "<" + SITE_INFO.name + ">客服后台有" + str(unread_waiters) + "条新客服留言. 请及时登录回复. 登录地址: " + SITE_INFO.domain + reverse('waiter')
            helpers.send_staff_mobile(s.mobile,msg)
    
    for s in staffs:
        #发送邮件队列
        data = {"staff_id":s.id,"unread_mentors":unread_mentors,"unread_waiters":unread_waiters}
        payload = urllib.urlencode(data)
        #执行转换
        try:
            queue = TaskQueue('notice2staff')
            queue.add(Task("/backend/taskqueue/notice2staff",payload))
        except:
            st = helpers.StaffTrans()
            st.kinger_notice_to_staff(s.id,unread_mentors,unread_waiters)
  
    return HttpResponse('')
Beispiel #2
0
def send_staff_unread(): 
    
    time_limit = datetime.datetime.now() + datetime.timedelta(seconds = -1800)
    has_send = Sms.objects.filter(type_id=99,send_time__gt=time_limit).count()
    if has_send:
        print '30分钟内已发送过短信'
        return '30分钟内已发送过短信'
    unread_mentors = unread_mentor()
    unread_waiters = unread_waiter()
    print unread_mentors,unread_waiters,'unread_mentors,unread_waiters---------'
    if not unread_mentors and not unread_waiters:
        return HttpResponse("")
    
    staffs = RelevantStaff.objects.exclude(send_mentor=False,send_waiter=False)
    
    for s in staffs:
        #发送短信,已有队列
        if s.send_mentor and unread_mentors and s.mobile:
            print 'send_mentor-----------------------------'
            msg = "<" + SITE_INFO.name + ">导师留言后台有" + str(unread_mentors) + "条新客户留言. 请及时登录回复. 登录地址: " + SITE_INFO.domain + reverse('aq')
            helpers.send_staff_mobile(s.mobile,msg)
        if s.send_waiter and unread_waiters and s.mobile:
            print 'send_waiter------------------------------'
            msg = "<" + SITE_INFO.name + ">客服后台有" + str(unread_waiters) + "条新客服留言. 请及时登录回复. 登录地址: " + SITE_INFO.domain + reverse('waiter')
            helpers.send_staff_mobile(s.mobile,msg)
             
    for s in staffs: 
        #发送邮件队列   
        data = {"staff_id":s.id,"unread_mentors":unread_mentors,"unread_waiters":unread_waiters}
        #执行转换
        try:
            res = URL('http://' + SITE_INFO.domain + reverse('cron_push_notice_staff')).post_async(staff_id=s.id,unread_mentors=unread_mentors,unread_waiters=unread_waiters)
#            queue.notice2staff.delay(data)
        except:
            st = helpers.StaffTrans()
            st.kinger_notice_to_staff(s.id,unread_mentors,unread_waiters)
    return ''
Beispiel #3
0
 def render(self, context):  
     return unread_waiter()