<file_sep># -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations


class Migration(migrations.Migration):

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='ShopOwner',
            fields=[
                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
                ('phoneIp', models.CharField(max_length=50, verbose_name=b'\xe6\x89\x8b\xe6\x9c\xbaIP')),
                ('phoneMac', models.CharField(max_length=50, verbose_name=b'\xe6\x89\x8b\xe6\x9c\xbaMac')),
                ('wifiSsid', models.CharField(max_length=50, verbose_name=b'wifiSSID')),
                ('wifiMac', models.CharField(max_length=50, verbose_name=b'wifiMac')),
                ('register_time', models.DateTimeField(verbose_name=b'\xe7\xad\xbe\xe5\x88\xb0\xe6\x97\xb6\xe9\x97\xb4')),
            ],
        ),
    ]
<file_sep>from django.shortcuts import render
import json
from django.http import HttpResponse
# Create your views here.

def bdWifi(request):
    username = request.GET.get('username', False)
    password = request.GET.get('password', False)
    if username=='sdy' and password=='<PASSWORD>':
        serverMsg="login success"
        jStr = {'serverMsg': serverMsg,'flag':'True'}
    else:
        serverMsg="login defied"
        jStr = {'serverMsg': serverMsg,'flag':'True'}

    return HttpResponse(json.JSONEncoder().encode(jStr))

<file_sep># -*- coding:utf-8 -*-
from django.shortcuts import render
# from urllib import urlencode
import json
from django.http import HttpResponse
# import logging
# from freeradius.models import Radcheck, AuthUser, SystemConfig
# from django.utils import timezone
# from accounting.models import *
from wifiSign.models import *
import time
from datetime import datetime,timedelta
# from datetime import datetime

# Create your views here.
def wifiSign(request):
    netName = request.GET.get('netName', False)
    netMac = request.GET.get('netMac', False)
    localMac = request.GET.get('localMac', False)
    localIp = request.GET.get('localIp', False)
    curDate = request.GET.get('curDate', False)

    # from datetime import datetime,timedelta
    # now = datetime.now()
    # yestoday = now - timedelta(days=1)
    # tommorow = now + timedelta(days=1)
    # or netMac != 'xxx'MERCURY_701  netName != 'SuccessfulTeam' or
    # /wifi_sign?netName="SuccessfulTeam"&netMac=ca:3a:35:4b:03:69&localMac=9c:99:a0:22:11:cb&localIp=192.168.0.111
    # /wifi_sign?netName="SuccessfulTeam"&netMac=ca:3a:35:4b:03:69&localMac=08:57:00:c0:1c:c5&localIp=192.168.0.100
    if ( netMac == 'ca:3a:35:4b:03:69' or netMac =='c8:3a:35:4b:03:68'):

        dateNow = datetime.now()
        print(dateNow)
        startTime=dateNow.date()
        # startDate=datetime.datetime.strptime(time.gmtime(time.time()),'%Y-%m-%d')
        endTime = startTime + timedelta(days=1)
        print(endTime)
        signHistory = SignHistory.objects.filter(phoneMac=localMac, register_time__lte=endTime,
                                                 register_time__gte=startTime)
        if signHistory.count()>=1:
            serverMsg="今天已经签到,不用重复签到"
            jstr = {'serverMsg': serverMsg}
            return HttpResponse(json.JSONEncoder().encode(jstr))
        if signHistory.count()==0:
            newSignHistory=SignHistory()
            newSignHistory.phoneMac=localMac
            newSignHistory.phoneIp=localIp
            newSignHistory.wifiMac=netMac
            newSignHistory.wifiSsid=netName
            newSignHistory.register_time=dateNow
            newSignHistory.save()
            serverMsg="本次签到成功"
            jstr = {'serverMsg': serverMsg}
            return HttpResponse(json.JSONEncoder().encode(jstr))
    else:
        serverMsg = "请链接公司wifi"
        jstr = {'serverMsg': serverMsg}
        return HttpResponse(json.JSONEncoder().encode(jstr))

<file_sep># -*- coding:utf-8 -*-
from django.db import models

# Create your models here.
class SignHistory(models.Model):
	phoneIp = models.CharField('手机IP',max_length=50)
	phoneMac = models.CharField('手机Mac',max_length=50,blank=False, null = False)
	wifiSsid = models.CharField('wifiSSID',max_length=50)
	wifiMac = models.CharField('wifiMac',max_length=50)
	register_time = models.DateTimeField('签到时间')
	# employee_name=models.CharField('employee_name',max_length=50)
	# employee_id=models.CharField('employee_id',max_length=20)
	# class Meta:
	# 	verbose_name='手机MAC'

	def __str__(self):
		return  self.phoneMac

	def __unicode__(self):
		return self.phoneMac