コード例 #1
0
ファイル: views.py プロジェクト: RaynorZhong/web91act
def check_phone(request, phone, check):
    p = option()
    if p['gift'] != '0':
        ret = {'result': 6}
        ret = json.dumps(ret, ensure_ascii=False)
        return HttpResponse(ret, content_type='application/json')
    appointment = Appointment.objects.filter(pk=phone)
    check = check.upper()
    if len(appointment) > 0:
        appointment = appointment[0]
        if appointment.status == 1:
            ret = {'result': 3}
            ret = json.dumps(ret, ensure_ascii=False)
            return HttpResponse(ret, content_type='application/json')
        if check == appointment.check:
            wl = WinnerLook('CDGD', 'CDGD123')
            gift_label = appointment.gift.label
            ret_msg = wl.send_msg(1, str(phone), gift_label)
            appointment.ret_msg = ret_msg
            appointment.pub_date = timezone.now()
            appointment.status = 1
            appointment.save()
            if ret_msg < 0:
                ret = {'result': 1}
            else:
                ret = {'result': 0, 'gift': str(appointment.gift)}
        else:
            ret = {'result': 2}
    else:
        ret = {'result': 4}
    ret = json.dumps(ret, ensure_ascii=False)
    return HttpResponse(ret, content_type='application/json')
コード例 #2
0
ファイル: views.py プロジェクト: RaynorZhong/web91act
def appointment(request, phone):
    p = option()
    if p['gift'] != '0':
        ret = {'result': 6}
        ret = json.dumps(ret, ensure_ascii=False)
        return HttpResponse(ret, content_type='application/json')
    appointment = Appointment.objects.filter(pk=phone)
    wl = WinnerLook('CDGD', 'CDGD123')
    platform = request.GET.get('platform', 'unknow')
    if len(appointment) > 0:
        appointment = appointment[0]
        tmp = timezone.timedelta(seconds=120)
        if appointment.status == 1:
            ret = {'result': 3}
            ret = json.dumps(ret, ensure_ascii=False)
            return HttpResponse(ret, content_type='application/json')
        if timezone.now() - appointment.pub_date < tmp:
            ret = {'result': 2}
            ret = json.dumps(ret, ensure_ascii=False)
            return HttpResponse(ret, content_type='application/json')
        check = appointment.check
        gift = appointment.gift
        ret_msg = wl.send_msg(0, str(phone), check)
        appointment.pub_date = timezone.now()
        appointment.ret = ret_msg
        appointment.platform = platform
        appointment.save()
    else:
        check = wl.clac_check_no(str(phone))
        ret_msg = wl.send_msg(0, str(phone), check)
        if not save_appointment(phone, check, ret_msg, platform):
            ret = {'result': 5}
            ret = json.dumps(ret, ensure_ascii=False)
            return HttpResponse(ret, content_type='application/json')
    if ret_msg < 0:
        ret = {'result': 1}
    else:
        ret = {'result': 0}
    ret = json.dumps(ret, ensure_ascii=False)
    return HttpResponse(ret, content_type='application/json')