Пример #1
0
def doSubmitOrder(request,cds, eventId, orderFrom):
    try:
        orderFromDict = {0:'网站',1:'app',2:'手机站',3:'微信'}
        #pn=NewEventTable.objects.get(old_event_id=eventId,isshow_id__in=(1,8))
        event = NewformatEvent(None,eventId)
        city_name =event['district_name']
        number = '%s%s'%(int(time.time()),random.randint(100,1000))
        totalpay = float(cds['price'])*int(cds['number']) 
        if int(totalpay) == 0:
            return (False,None,None)
        #if request.META.has_key('HTTP_X_FORWARDED_FOR'):
        #    ip =  request.META['HTTP_X_FORWARDED_FOR']
        #else:
        #    ip = request.META['REMOTE_ADDR']

        ip = request.META['REMOTE_ADDR']

        if cds.get('fapiao'):
            invoice = u'  ' + u'  '.join([u'发票抬头:%s' %cds.get('Invoice'),
                                        u'邮寄地址:%s' %cds.get('mail_address')])
        else:
            invoice = u'  无需发票'

        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_reg_fields=cds.get('reg_fields',0),
                                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','') + invoice,
                                event_to=orderFrom,
                                )
        subject = '活动家 来自%s订单通知.客户:%s,电话:%s'%(orderFromDict[orderFrom],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','')))
        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)
    
    except Exception,e:
        log.debug(e)
        return (False,None,None)
Пример #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)
Пример #3
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")

    phone = request.POST.get('phone', '')
    email = request.POST.get('email', '')
    content = request.POST.get('content', '')
    con = {
        'content': content,
        'work': request.POST.get('work', ''),
        'need': request.POST.get('need', ''),
        'price': request.POST.get('price', ''),
        'other': request.POST.get('other', ''),
        'username': request.POST.get('username', ''),
        'usersex': request.POST.get('usersex', ''),
        'userage': request.POST.get('userage', ''),
        'city': request.POST.get('city', ''),
    }
    con_str = ''
    for k, v in con.items():
        con_str += '%s:%s\r\n' % (k, v)
    if not phone and not email:
        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'手机:%s\r\n' % phone
    cont += u'邮箱:%s\r\n' % email
    cont += u'内容:%s\r\n' % con_str
    log.debug(cont)

    NewOrderMessage.objects.create(msg_content=cont,
                                   msg_tel=phone,
                                   msg_email=email)
    sendMail(subject.encode('utf-8'), cont.encode('utf-8'), [
        '*****@*****.**', '*****@*****.**', '*****@*****.**',
        '*****@*****.**'
    ])

    return HttpResponse(json.dumps(p), content_type="application/json")
Пример #4
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,host=2):
                p['flag']=True
     
        
    response = json.dumps(p)
    return HttpResponse(response, mimetype="application/json")       
Пример #5
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))
Пример #6
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")
    
    phone = request.POST.get('phone','')
    email = request.POST.get('email','')   
    content=request.POST.get('content','') 
    con={
    'content':content,
    'work':request.POST.get('work','') ,
    'need':request.POST.get('need','') ,
    'price':request.POST.get('price','') ,
    'other':request.POST.get('other','') ,
    'username':request.POST.get('username','') ,
    'usersex':request.POST.get('usersex','') ,
    'userage':request.POST.get('userage','') ,
    'city':request.POST.get('city','') ,
    }
    con_str=''
    for k,v in con.items():
        con_str+='%s:%s' % (k,v)
    if not phone and not email :
        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'手机:%s\r\n' % phone
    cont+=u'邮箱:%s\r\n' % email
    cont+=u'内容:%s\r\n' % con_str
    log.debug(cont)
    sendMail(subject.encode('utf-8'),cont.encode('utf-8'),['*****@*****.**','*****@*****.**','*****@*****.**'])
    
    return HttpResponse(json.dumps(p), content_type="application/json")
Пример #7
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/')
Пример #8
0
def submitOrder_with_coupon(request, coupon_record):
    if request.method != 'GET':
        return HttpResponse(json.dumps({"code":0,"msg":"Only GETs are allowed","list":[]}), content_type="application/json")

    cds = request.GET
    price =cds['price']
    price = round( float(price),2)
    eventId = int(cds['eventid'])
    event=NewAppEvent(None,eventId)
    '''
    pr_ok=False
    for i in range(len(event['price_unit_info'])):
        pr1=round(float(event['price_unit_info'][i]['price'])*float(event['price_unit_info'][i]['discount']),1)
        if price  is pr1:
            pr_ok=True
            break
    if not pr_ok:
        return HttpResponse(json.dumps({"code":0,"msg":"price is wrong %s,%s" % (price,pr1),"list":[]}), content_type="application/json")

    '''

    import random
    number = '%s%s'%(int(time.time()),random.randint(100,1000))
    if int(cds['amount']) < 1:
        return HttpResponse(json.dumps({"code":0,"msg":"amount must be bigger than 1","list":[]}), content_type="application/json")
    totalpay = float(price)*int(cds['amount'])
    #print cds['payMode']

    # 使用了优惠券
    totalpay = coupon_record.cost

    if request.META.has_key('HTTP_X_FORWARDED_FOR'):
        ip =  request.META['HTTP_X_FORWARDED_FOR']
    else:
        ip = request.META['REMOTE_ADDR']
    userid = cds.get('userid')
    if not userid:
        userid = 0
    else:
        userid = int(userid)
    try:
        NewOrder.objects.create(
                                order_number=number,
                                order_user_name=cds.get('name',''),
                                order_tel = cds.get('phone',''),
                                order_email = cds.get('email',''),
                                order_totalpay = totalpay,
                                order_price = float(price),
                                order_amount = cds['amount'],
                                order_address = cds.get('address',''),
                                order_payment = 'alipay',
                                order_telphone = cds.get('phone',''),
                                order_pay_status = 0,
                                order_status = 0,
                                event_id = eventId,
                                event_name = event['title'],
                                city_title = event['district_name'],
                                order_reg_fields = 0,
                                order_addtime = time.time(),
                                order_addip = ip,
                                order_text = cds.get('message',''),
                                order_userid = userid,
                                event_to=4,
                                )
    except:
        return HttpResponse(json.dumps({"code":0,"msg":"err","list":[]}), content_type="application/json")

    subject = '来自闲时app的订单通知.客户:%s,电话:%s'%(cds.get('name','').encode('utf-8'),cds.get('mobilphone','').encode('utf-8'))
    content = '点单号:%s\n总价:%s\n活动链接:http://www.huodongjia.com/event-%s.html'%(number,totalpay,eventId)
    content += dic2text(cds)
    sendMail(subject,content)
    order = {
    'price':price,
    'order_id':number,
    'user_id':cds.get('userid',''),
    'addtime':int(time.time()),
    'name':cds.get('name',u'匿名'),
    'phone':cds['phone'],
    'address':cds.get('address',''),
    'message':cds.get('message',''),
    "total":totalpay,
    "amount":cds['amount'],
    "order_pay_status":u"未付款",
    "order_status":u"未处理",
    }

    # 记录order_number
    coupon_record.order_id = number
    coupon_record.save()

    eventdic = getevent(eventId)
    return HttpResponse(json.dumps({"code":1,"msg":u"下单成功","data":{'order':order,'event':eventdic}}), content_type="application/json")
Пример #9
0
def submitOrder_weixin(request):
    title = request.COOKIES.get('city_py',False)
    city_name = request.COOKIES.get('city',False)
    if request.method == 'GET':
        cds = request.GET
        error = False
        if not cds.get('name',''):
            return render_to_response('m_base_error.html',{'city':city_name,'city_py':title,'error_msg':u'用户名未填写'},context_instance=RequestContext(request))
            error = True
        if not cds.get('mobilphone',''):
            return render_to_response('m_base_error.html',{'city':city_name,'city_py':title,'error_msg':u'电话提交错误'},context_instance=RequestContext(request))
            error = True
        if not cds.get('address',''):
            return render_to_response('m_base_error.html',{'city':city_name,'city_py':title,'error_msg':u'地址提交错误'},context_instance=RequestContext(request))
            error = True
        eventId = int(cds.get('event_id','0')) 
        if not eventId:   
            return render_to_response('m_base_error.html',{'city':city_name,'city_py':title,'error_msg':u'event id 提交错误'},context_instance=RequestContext(request))          
            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))
Пример #10
0
def doSubmitOrder(request, cds, eventId, orderFrom):
    try:
        orderFromDict = {0: '网站', 1: 'app', 2: '手机站', 3: '微信'}
        #pn=NewEventTable.objects.get(old_event_id=eventId,isshow_id__in=(1,8))
        event = NewformatEvent(None, eventId)
        city_name = event['district_name']
        number = '%s%s' % (int(time.time()), random.randint(100, 1000))
        totalpay = float(cds['price']) * int(cds['number'])
        if int(totalpay) == 0:
            return (False, None, None)
        #if request.META.has_key('HTTP_X_FORWARDED_FOR'):
        #    ip =  request.META['HTTP_X_FORWARDED_FOR']
        #else:
        #    ip = request.META['REMOTE_ADDR']

        ip = request.META['REMOTE_ADDR']

        if cds.get('fapiao'):
            invoice = u'  ' + u'  '.join([
                u'发票抬头:%s' % cds.get('Invoice'),
                u'邮寄地址:%s' % cds.get('mail_address')
            ])
        else:
            invoice = u'  无需发票'

        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_reg_fields=cds.get('reg_fields', 0),
            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', '') + invoice,
            event_to=orderFrom,
        )
        subject = '活动家 来自%s订单通知.客户:%s,电话:%s' % (
            orderFromDict[orderFrom], 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', '')))
        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)

    except Exception, e:
        log.debug(e)
        return (False, None, None)