Exemplo n.º 1
0
def saveConsult(request, eventId, eventName):
    try:
        if request.method == 'POST':
            cds = request.POST
            if cds.get('name', False) and (cds.get('email', False) or cds.get(
                    'phone', False)) and cds.get('content', False):
                timeNow = time.time()
                NewOrderMessage.objects.create(event_id=eventId,
                                               event_name=eventName,
                                               msg_name=cds.get('name', ''),
                                               msg_tel=cds.get('phone', ''),
                                               msg_email=cds.get('email', ''),
                                               msg_content=cds.get(
                                                   'content', ''),
                                               msg_addtime=timeNow)
                subject = '活动家-留言咨询,活动名:%s,客户:%s' % (eventName.encode(
                    'utf-8'), cds.get('name', '').encode('utf-8'))
                content = '活动id:%s\n活动名:%s\n' % (
                    eventId, eventName.encode('utf-8')) + dic2text(
                        cds) + '留言时间:%s' % time.strftime(
                            "%Y-%m-%d %H:%M:%S", time.localtime(timeNow))
                sendMail(subject, content)
                return True
            else:
                return False
        else:
            return False
    except:
        return False
Exemplo n.º 2
0
def send_mail_from(request, event_id, event_name, mail=''):
    try:
        content = '询问如何参加%s,请问该活动的费用是多少,如何报名,有官方网站或相关资料吗?谢谢' % event_name
        subject = u'信息求助'
        sendMail(subject, content, to_list=[mail])

    except:
        p = []
    response = json.dumps(p)
Exemplo n.º 3
0
def send_mail_from(request,event_id,event_name,mail=''):
    try:
        content='询问如何参加%s,请问该活动的费用是多少,如何报名,有官方网站或相关资料吗?谢谢' % event_name
        subject = u'信息求助'  
        sendMail(subject,content,to_list=[mail])
        
    except:
        p=[]
    response = json.dumps(p)
Exemplo n.º 4
0
def CustomMessage(request):
    p = {}
    p['code'] = 0
    if request.method != 'POST':
        p['msg'] = 'Only POSTs are allowed'
        return HttpResponse(json.dumps(p), content_type="application/json")
    if not ip_Filter(request, 10):
        p['msg'] = 'The request is limited'
        return HttpResponse(json.dumps(p), content_type="application/json")
    eventId = request.POST.get('event_id', None)
    eventName = request.POST.get('event_name', None)
    name = request.POST.get('name', None)
    phone = request.POST.get('phone', None)
    email = request.POST.get('email', None)
    content = request.POST.get('content', None)
    if not phone and not email and not content:
        p['msg'] = 'Incomplete information'
        return HttpResponse(json.dumps(p), content_type="application/json")
    try:
        timeNow = time.time()
        NewOrderMessage.objects.create(
            event_id=eventId,
            event_name=eventName,
            msg_name=name,
            msg_tel=phone,
            msg_email=email,
            msg_content=content,
            msg_addtime=timeNow,
            type=1,
        )
    except:
        p['msg'] = 'Incomplete information'
        return HttpResponse(json.dumps(p), content_type="application/json")
    p['msg'] = 'Request is successful'
    p['code'] = 1
    subject = u'活动家留言,邮件提醒  %s %s' % (phone, email)
    cont = u'活动家留言\r\n'
    cont += u'活动:<a href="http://www.huodongjia.com/event-%s.html">%s</a>\r\n' % (
        eventId, eventName)
    cont += u'姓名:%s\r\n' % name
    cont += u'手机:%s\r\n' % phone
    cont += u'邮箱:%s\r\n' % email
    cont += u'内容:%s\r\n' % content
    #log.debug(cont)
    sendMail(subject.encode('utf-8'), cont.encode('utf-8'),
             ['*****@*****.**', '*****@*****.**'])

    return HttpResponse(json.dumps(p))
Exemplo n.º 5
0
def send_email(request,email=None,content=None,subject=None):
    if not email:
        email=request.POST.get('email',None)        
    if not content:
        content=request.POST.get('content',None)
    if not subject:        
        subject=request.POST.get('subject',None)

    p={}
    p['flag']=False    
    if   email and content and  subject:
        p['email']=email
        p['content']=content
        p['subject']=subject
        
        mailre=re.compile(r"([0-9a-zA-Z_.]+@[0-9a-zA-Z_.]+)")
        mail=mailre.findall(email)
        
        for i in range(len(mail)):
            mail[i]=mail[i].lower()
            
        
    
        if len(mail)>0:
            p['mail']=mail
            if sendMail(subject.encode('utf-8'),content.encode('utf-8'),mail):
                p['flag']=True
     
        
    response = json.dumps(p)
    return HttpResponse(response, mimetype="application/json")       
Exemplo n.º 6
0
def send_email(request, email=None, content=None, subject=None):
    if not email:
        email = request.POST.get('email', None)
    if not content:
        content = request.POST.get('content', None)
    if not subject:
        subject = request.POST.get('subject', None)

    p = {}
    p['flag'] = False
    if email and content and subject:
        p['email'] = email
        p['content'] = content
        p['subject'] = subject

        mailre = re.compile(r"([0-9a-zA-Z_.]+@[0-9a-zA-Z_.]+)")
        mail = mailre.findall(email)

        for i in range(len(mail)):
            mail[i] = mail[i].lower()

        if len(mail) > 0:
            p['mail'] = mail
            if sendMail(subject.encode('utf-8'), content.encode('utf-8'),
                        mail):
                p['flag'] = True

    response = json.dumps(p)
    return HttpResponse(response, mimetype="application/json")
Exemplo n.º 7
0
def CustomMessage(request):
    p={}
    p['code']=0
    if request.method != 'POST':
        p['msg']='Only POSTs are allowed'   
        return HttpResponse(json.dumps(p), content_type="application/json")
    if not ip_Filter(request,10):
        p['msg']='The request is limited'   
        return HttpResponse(json.dumps(p), content_type="application/json")
    eventId = request.POST.get('event_id',None)
    eventName = request.POST.get('event_name',None)
    name = request.POST.get('name',None)
    phone = request.POST.get('phone',None)
    email = request.POST.get('email',None)   
    content=request.POST.get('content',None) 
    if not phone and not email and not content:
        p['msg']='Incomplete information'
        return HttpResponse(json.dumps(p), content_type="application/json")
    try:
        timeNow = time.time()
        NewOrderMessage.objects.create(event_id = eventId,
                                       event_name = eventName,
                                       msg_name = name,
                                       msg_tel = phone,
                                       msg_email = email,
                                       msg_content = content,
                                       msg_addtime = timeNow,
                                       type=1,
                                       )
    except:
        p['msg']='Incomplete information'
        return HttpResponse(json.dumps(p), content_type="application/json")        
    p['msg']='Request is successful'
    p['code']=1
    subject=u'活动家留言,邮件提醒  %s %s' % (phone,email)
    cont=u'活动家留言\r\n'
    cont+=u'活动:<a href="http://www.huodongjia.com/event-%s.html">%s</a>\r\n' % (eventId,eventName)
    cont+=u'姓名:%s\r\n' % name
    cont+=u'手机:%s\r\n' % phone
    cont+=u'邮箱:%s\r\n' % email
    cont+=u'内容:%s\r\n' % content
    #log.debug(cont)
    sendMail(subject.encode('utf-8'),cont.encode('utf-8'),['*****@*****.**','*****@*****.**'])
    
    return HttpResponse(json.dumps(p))
Exemplo n.º 8
0
def saveSuggestion(request, eventId, eventName):
    try:
        if request.method == 'POST':
            cds = request.POST
            if cds.get('msg_type') != 'suggestion':
                return False
            if cds.get('name', False) and cds.get('email', False) and cds.get(
                    'where', False):
                timeNow = time.time()
                msg_content = cds.get('where', '') + '\n' + cds.get(
                    'suggestion', '')
                NewOrderMessage.objects.create(
                    event_id=eventId,
                    event_name=eventName,
                    msg_name=cds.get('name', ''),
                    msg_tel=cds.get('phone', ''),
                    msg_email=cds.get('email', ''),
                    msg_content=msg_content,
                    msg_addtime=timeNow,
                    type=1,
                )
                subject = '活动家-新的纠错,活动名:%s' % eventName.encode('utf-8')
                content = '客户姓名:%s\n联系邮箱:%s\n联系电话:%s\n活动id:%s\n活动名:%s\n活动链接:%s\n纠错内容:%s\n纠错时间:%s' % (
                    cds.get('name', '').encode('utf-8'), cds.get(
                        'email', '').encode('utf-8'), cds.get(
                            'phone', '').encode('utf-8'), eventId,
                    eventName.encode('utf-8'),
                    'http://www.huodongjia.com/event-%s.html' % eventId,
                    msg_content.encode('utf-8'),
                    time.strftime("%Y-%m-%d %H:%M:%S",
                                  time.localtime(timeNow)))
                sendMail(subject, content)
                return True
            else:
                return False
        else:
            return False
    except Exception, e:
        print e
        return False
Exemplo n.º 9
0
def msg(request):
    title = request.COOKIES.get('city_py',False)
    city_name = request.COOKIES.get('city',False)
    if request.method == 'POST':
        cds = request.POST
        eventId=cds.get('eventId')
        eventName=cds.get('eventName',None)
        if not eventId:
            
            return redirect('/msg/')
        if not eventName:
            try:
                eventName=NewEventTable.objects.get(old_event_id=eventId).name
            except:
                return redirect('/msg/')
        if cds.get('eventId',False) and cds.get('name',False) and (cds.get('email',False) or cds.get('phone',False)) and cds.get('content',False):
            timeNow = time.time()

            try:
                NewOrderMessage.objects.create(event_id = eventId,
                                               event_name = eventName,
                                               msg_name = cds.get('name',''),
                                               msg_tel = cds.get('phone',''),
                                               msg_email = cds.get('email',''),
                                               msg_content = cds.get('content',''),
                                               msg_addtime = timeNow
                                               ) 
            
                
                subject ='活动家-留言咨询,活动名:%s,客户:%s'%(eventName.encode('utf-8'),cds.get('name','').encode('utf-8'))
                content = '活动id:%s\n活动名:%s\n'%(eventId,eventName.encode('utf-8'))+dic2text(cds)+'留言时间:%s'%time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(timeNow)) 
                sendMail(subject,content)
            except Exception,e:
                log.debug(e)
            return redirect('/event-%s.html' % eventId)
        else:
            return redirect('/msg/')
Exemplo n.º 10
0
def saveSuggestion(request,eventId,eventName):
    try:
        if request.method == 'POST':
            cds = request.POST
            if cds.get('msg_type') != 'suggestion':
                return False
            if cds.get('name',False) and cds.get('email',False) and cds.get('where',False):
                timeNow = time.time()
                msg_content = cds.get('where','')+'\n'+cds.get('suggestion','')
                NewOrderMessage.objects.create(event_id = eventId,
                                               event_name = eventName,
                                               msg_name = cds.get('name',''),
                                               msg_tel = cds.get('phone',''),
                                               msg_email = cds.get('email',''),
                                               msg_content = msg_content,
                                               msg_addtime = timeNow,
                                               type=1,
                                               ) 
                subject ='活动家-新的纠错,活动名:%s'%eventName.encode('utf-8')
                content = '客户姓名:%s\n联系邮箱:%s\n联系电话:%s\n活动id:%s\n活动名:%s\n活动链接:%s\n纠错内容:%s\n纠错时间:%s'%(cds.get('name','').encode('utf-8'),
                                                                                                   cds.get('email','').encode('utf-8'),
                                                                                                   cds.get('phone','').encode('utf-8'),
                                                                                                   eventId,
                                                                                                   eventName.encode('utf-8'),
                                                                                                   'http://www.huodongjia.com/event-%s.html'%eventId,
                                                                                                   msg_content.encode('utf-8'),
                                                                                                   time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(timeNow))
                                                                                                   ) 
                sendMail(subject,content)
                return True
            else:
                return False
        else:
            return False
    except Exception,e:
        print e
        return False
Exemplo n.º 11
0
def saveConsult(request,eventId,eventName):
    try:
        if request.method == 'POST':
            cds = request.POST
            if cds.get('name',False) and (cds.get('email',False) or cds.get('phone',False)) and cds.get('content',False):
                timeNow = time.time()
                NewOrderMessage.objects.create(event_id = eventId,
                                               event_name = eventName,
                                               msg_name = cds.get('name',''),
                                               msg_tel = cds.get('phone',''),
                                               msg_email = cds.get('email',''),
                                               msg_content = cds.get('content',''),
                                               msg_addtime = timeNow
                                               ) 
                subject ='活动家-留言咨询,活动名:%s,客户:%s'%(eventName.encode('utf-8'),cds.get('name','').encode('utf-8'))
                content = '活动id:%s\n活动名:%s\n'%(eventId,eventName.encode('utf-8'))+dic2text(cds)+'留言时间:%s'%time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(timeNow)) 
                sendMail(subject,content)
                return True
            else:
                return False
        else:
            return False
    except:
        return False
Exemplo n.º 12
0
def submitOrder_weixin(request):
    title = request.COOKIES.get('city_py',False)
    city_name = request.COOKIES.get('city',False)
    if request.method == 'POST':
        cds = request.POST
        error = False
        if not cds.get('name',''):
            
            error = True
        if not cds.get('mobilphone',''):
             
            error = True
        if not cds.get('address',''):
      
            error = True
        eventId = int(cds.get('event_id','0')) 
        if not eventId:             
            error = True
        else:
            try:
                pn=NewEventTable.objects.get(old_event_id=eventId,isshow_id__in=(1,8))
                
                event = NewformatEvent(pn)
                #return HttpResponse(json.dumps({'flag':event}))
                #event = NewEventTable.objects.get(Q(event_isshow=1)|Q(event_isshow=8),id=eventId)
                if event['event_price_model'] != 2:
                    if event['event_price_model'] == 1:
                        priceString = event['event_discount_price']
                    else:        
                        priceString = event['event_price']
                    priceList = priceString.split('/')
                    #return HttpResponse(json.dumps({'flag':priceList})) 
                    #currencyDic = [1,1,1.24,4.84,0.16,0.12,0.095,16.33,5.23,164.46,0.2,3388.90,0.52]
                    for i in range(len(priceList)):
                        if priceList[i].replace('.','').isdigit():
                            ra=pn.Price.Currency.rate if pn.Price.Currency else 1
                            priceList[i] = '%.2f'% (float(priceList[i])/float(ra) )
                    if '%.2f'%float(cds.get('price')) not in priceList:
                        return HttpResponse(json.dumps({'flag':priceString}))
                        error = True
            except:
                return HttpResponse(json.dumps({'flag':1})) 
                error = True
        if not error:
            city_name =event['district_name']
            number = '%s%s'%(int(time.time()),random.randint(100,1000))
            totalpay = float(cds['price'])*int(cds['number']) 
            #print cds['payMode']
 
            if request.META.has_key('HTTP_X_FORWARDED_FOR'):
                ip =  request.META['HTTP_X_FORWARDED_FOR']
            else:
                ip = request.META['REMOTE_ADDR']
            
            NewOrder.objects.create(
                                    order_number=number,
                                    order_user_name=cds.get('name',''),
                                    order_tel = cds.get('mobilphone',''),
                                    order_email = cds.get('email',''), 
                                    order_totalpay = totalpay,
                                    order_price = cds.get('price',''),
                                    order_amount = cds.get('number',''),
                                    order_address = cds.get('address',''),
                                    order_payment = 'weixin',
                                    order_telphone = cds.get('phone',''),
                                    order_pay_status = 0,
                                    order_status = 0,
                                    event_id = event['event_id'],
                                    event_name = cds.get('event_name',''),
                                    city_title = city_name,
                                    order_reg_fields = 0,
                                    order_userid = 0,
                                    order_addtime = time.time(),
                                    order_addip = ip,
                                    order_text = cds.get('remark',''),
                                    event_to=3,
                                    )
            
            subject = '活动家 -来自微信的订单通知.客户:%s,电话:%s'%(cds.get('name','').encode('utf-8'),cds.get('mobilphone','').encode('utf-8'))
            content = '点单号:%s\n总价:%s\n'%(number,totalpay)
            content += dic2text(cds)
            sendMail(subject,content)
            #msgs= u'您好,您预定的《%s》项目还未付款,请继续安排支付,支付成功后将有短信或电邮通知,请注意查收。【活动家】' % (re.sub(ur"[^\u4e00-\u9fa5\w]", " ", cds.get('event_name','')))
            #msgs= u'您好,你在活动家(huodongjia.com)预订了%s活动,还未支付,请你尽快支付,我们好为你出票。你可以在huodongjia.com上查询订单号%s支付即可。谢谢!【活动家】'\
            # % (re.sub(ur"[^\u4e00-\u9fa5\w]", " ", cds.get('event_name','')),number)
            #print type(msgs)
            
            
            #SendOrderMsg(cds.get('mobilphone',''),msgs)
            url_log=request.COOKIES.get('urllogorder',None)
            if url_log:
                cache.set('order_%s' % number,[json.loads(url_log),ip],86400*30)
            '''
            msg = u'活动家新的订单通知,活动名称:%s,客户:%s,电话:%s,单号:%s,总价:%s,'%( cds.get('event_name',''),cds.get('name',''),cds.get('mobilphone',''),number,totalpay)
            msg = re.sub(ur"[^\u4e00-\u9fa5\w]", ",", msg)
            try:
                SendOrderMsg('18628175526','%s【活动家】' % msg)
            except Exception,e:
                log.debug('order_c')
                log.debug(e)
            '''
            return HttpResponseRedirect('/weixin/js_api_call.php?order_number=%s' % number)
            #return render_to_response('m_orderDetails.html',{'city':city_name,'city_py':title,'order_info':cds,'order_number':number,'total_price':totalpay},context_instance=RequestContext(request))
        else:
            return render_to_response('m_base_error.html',{'city':city_name,'city_py':title,'error_msg':u'下订单时遇到错误,请重新下单2'},context_instance=RequestContext(request))
            
            
    return render_to_response('m_base_error.html',{'city':city_name,'city_py':title,'error_msg':u'下订单时遇到错误,请重新下单1'},context_instance=RequestContext(request))
Exemplo n.º 13
0
def submitOrder(request):
    title = request.COOKIES.get('city_py',False)
    city_name = request.COOKIES.get('city',False)
    if request.method == 'POST':
        cds = request.POST
        error = False
        if not cds.get('name',''):
            
            error = True
        if not cds.get('mobilphone',''):
             
            error = True
        if not cds.get('address',''):
      
            error = True
        eventId = int(cds.get('event_id','0')) 
        if not eventId:             
            error = True
        else:
            try:
                pn=NewEventTable.objects.get(old_event_id=eventId,isshow_id__in=(1,8))
                
                event = NewformatEvent(pn)
                #return HttpResponse(json.dumps({'flag':event}))
                #event = NewEventTable.objects.get(Q(event_isshow=1)|Q(event_isshow=8),id=eventId)
                if event['event_price_model'] != 2:
                    if event['event_price_model'] == 1:
                        priceString = event['event_discount_price']
                    else:        
                        priceString = event['event_price']
                    priceList = priceString.split('/')
                    #return HttpResponse(json.dumps({'flag':priceList})) 
                    #currencyDic = [1,1,1.24,4.84,0.16,0.12,0.095,16.33,5.23,164.46,0.2,3388.90,0.52]
                    for i in range(len(priceList)):
                        if priceList[i].replace('.','').isdigit():
                            ra=pn.Price.Currency.rate if pn.Price.Currency else 1
                            priceList[i] = '%.2f'% (float(priceList[i])/float(ra) )
                    if '%.2f'%float(cds.get('price')) not in priceList:
                        return HttpResponse(json.dumps({'flag':priceString}))
                        error = True
            except:
                return HttpResponse(json.dumps({'flag':1})) 
                error = True
        if not error:
            city_name =event['district_name']
            number = '%s%s'%(int(time.time()),random.randint(100,1000))
            totalpay = float(cds['price'])*int(cds['number']) 
            #print cds['payMode']
 
            if request.META.has_key('HTTP_X_FORWARDED_FOR'):
                ip =  request.META['HTTP_X_FORWARDED_FOR']
            else:
                ip = request.META['REMOTE_ADDR']
            
            NewOrder.objects.create(
                                    order_number=number,
                                    order_user_name=cds.get('name',''),
                                    order_tel = cds.get('mobilphone',''),
                                    order_email = cds.get('email',''), 
                                    order_totalpay = totalpay,
                                    order_price = cds.get('price',''),
                                    order_amount = cds.get('number',''),
                                    order_address = cds.get('address',''),
                                    order_payment = cds.get('payMode',''),
                                    order_telphone = cds.get('phone',''),
                                    order_pay_status = 0,
                                    order_status = 0,
                                    event_id = event['event_id'],
                                    event_name = cds.get('event_name',''),
                                    city_title = city_name,
                                    order_reg_fields = 0,
                                    order_userid = 0,
                                    order_addtime = time.time(),
                                    order_addip = ip,
                                    order_text = cds.get('remark',''),
                                    event_to=0,
                                    )
            
            subject = '活动家 -新的订单通知.客户:%s,电话:%s'%(cds.get('name','').encode('utf-8'),cds.get('mobilphone','').encode('utf-8'))
            content = '点单号:%s\n总价:%s\n'%(number,totalpay)
            content += dic2text(cds)
            sendMail(subject,content)
            msgs= u'您好,您预定的《%s》项目还未付款,请继续安排支付,支付成功后将有短信或电邮通知,请注意查收。【活动家】' % (re.sub(ur"[^\u4e00-\u9fa5\w]", " ", cds.get('event_name','')))
            #msgs= u'您好,你在活动家(huodongjia.com)预订了%s活动,还未支付,请你尽快支付,我们好为你出票。你可以在huodongjia.com上查询订单号%s支付即可。谢谢!【活动家】'\
            # % (re.sub(ur"[^\u4e00-\u9fa5\w]", " ", cds.get('event_name','')),number)
            #print type(msgs)
            
            
            SendOrderMsg(cds.get('mobilphone',''),msgs)
            '''
            msg = u'活动家新的订单通知,活动名称:%s,客户:%s,电话:%s,单号:%s,总价:%s,'%( cds.get('event_name',''),cds.get('name',''),cds.get('mobilphone',''),number,totalpay)
            msg = re.sub(ur"[^\u4e00-\u9fa5\w]", ",", msg)
            try:
                SendOrderMsg('18628175526','%s【活动家】' % msg)
            except Exception,e:
                log.debug('order_c')
                log.debug(e)
            '''
            return render_to_response('orderDetails.html',{'city':city_name,'city_py':title,'order_info':cds,'order_number':number,'total_price':totalpay},context_instance=RequestContext(request))
        else:
            return render_to_response('base_error.html',{'city':city_name,'city_py':title,'error_msg':u'下订单时遇到错误,请重新下单2'},context_instance=RequestContext(request))
            
            
    return render_to_response('base_error.html',{'city':city_name,'city_py':title,'error_msg':u'下订单时遇到错误,请重新下单1'},context_instance=RequestContext(request))