예제 #1
0
파일: shop.py 프로젝트: tillmans/pack
def shopVerifyTelephone(request):
    logger = logging.getLogger('Pack.app')
    response = {}
    response['data'] = {}
    response['errorMsg'] = ""
    _telephone = request.REQUEST.get('telephone',18201637776)
    _verify_code = request.REQUEST.get('verifyCode',8888)
    _method = request.REQUEST.get('method')
    _deviceInfo = request.REQUEST.get('deviceInfo')
    _clientID = request.REQUEST.get('clientID','0')
    _deviceToken = request.REQUEST.get('deviceToken','0')

    cache.set(str(_telephone),str(_verify_code),1800)
    if _telephone == None or _telephone == '':
        response['code'] = -1
        response['errorMsg'] = u'请输入手机号'
        return HttpResponse(json.dumps(response,ensure_ascii=False),content_type="application/json")
    if  _verify_code == None or _verify_code == '':
        response['code'] = -1
        response['errorMsg'] = u'请输入验证码'
        return HttpResponse(json.dumps(response,ensure_ascii=False),content_type="application/json")
    if _deviceInfo == None or _deviceInfo == '':
        response['code'] = -1
        response['errorMsg'] = u'请输入设备信息'
        return HttpResponse(json.dumps(response,ensure_ascii=False),content_type="application/json")
    if _clientID == None or _clientID == '':
        response['code'] = -1
        response['errorMsg'] = u'请输入clientID'
        return HttpResponse(json.dumps(response,ensure_ascii=False),content_type="application/json")
    if _deviceToken == None or _deviceToken == '':
        response['code'] = -1
        response['errorMsg'] = u'请输入deviceToken'
        return HttpResponse(json.dumps(response,ensure_ascii=False),content_type="application/json")
    if _method == None or _method == '':
        response['code'] = -1
        response['errorMsg'] = u'请输入method'
        return HttpResponse(json.dumps(response,ensure_ascii=False),content_type="application/json")


    _telephone = str(_telephone)
    _verify_code = str(_verify_code)
    _clientID = str(_clientID)
    _deviceToken = str(_deviceToken)
    _method = str(_method)

    if len(_telephone) != 11:
        response['code'] = -1
        response['errorMsg'] = '请输入11位手机号'
        return HttpResponse(json.dumps(response,ensure_ascii=False),content_type="application/json")
    if _telephone.isdigit() == False:
        response['code'] = -1
        response['errorMsg'] = '请输入有效的手机号'
        return HttpResponse(json.dumps(response,ensure_ascii=False),content_type="application/json")
    #中国移动:China Mobile
    # 134[0-8],135,136,137,138,139,150,151,157,158,159,182,187,188
    CM_prog = re.compile(r"^1(34[0-8]|(3[5-9]|5[017-9]|8[278])\d)\d{7}$")
    #CM = r"^1(34[0-8]|(3[5-9]|5[017-9]|8[278])\\d)\\d{7}$"
    #中国联通:China Unicom
    # 130,131,132,152,155,156,185,186
    CU_prog = re.compile(r"^1(3[0-2]|5[256]|8[56])\d{8}$")
    #CU = r"^1(3[0-2]|5[256]|8[56])\\d{8}$"
    # 中国电信:China Telecom
    # 133,1349,153,180,189
    CT_prog = re.compile(r"^1((33|53|8[09])[0-9]|349)\d{7}$")
    #CT = r"^1((33|53|8[09])[0-9]|349)\\d{7}$"
    telephone_match_CM = CM_prog.match(str(_telephone))
    telephone_match_CU = CU_prog.match(str(_telephone))
    telephone_match_CT = CT_prog.match(str(_telephone))

    if not telephone_match_CM and not telephone_match_CT and not telephone_match_CU:
        response['code'] =  -1
        response['errorMsg'] = '请输入有效的手机号'
        return HttpResponse(json.dumps(response,ensure_ascii=False),content_type="application/json")
    saved_verify_code = cache.get(str(_telephone))
    #print('saved_verify_code:'+str(saved_verify_code))
    if not saved_verify_code:
        response['code'] = -1
        response['errorMsg'] = '请重新发送验证码'
        return HttpResponse(json.dumps(response,ensure_ascii=False),content_type="application/json")
    if saved_verify_code != _verify_code:
        response['code'] = -1
        response['errorMsg'] = '验证码错误,请重新输入'
        return HttpResponse(json.dumps(response,ensure_ascii=False),content_type="application/json")
    if _method == '0':
        query_telephone = WaiterOrder.objects.filter(telephone = str(_telephone))
        if not query_telephone.exists():
            _name = '****'+_telephone[7:11]
            _headImage = 'http://meiyue.b0.upaiyun.com/head/1_head.jpg'
            currentTime = time.time()
            currentTime = int(currentTime)
            currentTime = str(currentTime)
            new_waiterOrder = WaiterOrder(telephone=str(_telephone),name = _name, headImage = _headImage,lastLoginTime =
            currentTime,deviceToken = _deviceToken,clientID = _clientID,deviceInfo = _deviceInfo)
            new_waiterOrder.save()
            response['code'] = 0
            response_data = {'waiterOrderId':new_waiterOrder.id,'setShopStatus':'0','shopId':'0'}
            request.session['waiterOrderId'] = new_waiterOrder.id   #new_shop.save()之后,才能在session中设置shopid,未保存之前不知道是多少
            request.session['lastLoginTime'] = currentTime
            response['data'] = response_data
            return HttpResponse(json.dumps(response),content_type="application/json")

        response_data = {}
        response_data['waiterOrderId'] = query_telephone[0].id
        if query_telephone[0].shop == None:
            response_data['setShopStatus'] = '0'
            response_data['shopId'] = '0'
        else:
            response_data['setShopStatus'] = '1'
            response_data['shopId'] = query_telephone[0].shop.id
            request.session['shopId'] = str(query_telephone[0].shop.id)
        request.session['waiterOrderId'] = query_telephone[0].id
        currentTime = time.time()*1000
        currentTime = int(currentTime)
        currentTime = str(currentTime)
        query_telephone.update(clientID = _clientID, deviceToken = _deviceToken,deviceInfo = _deviceInfo,lastLoginTime = currentTime)
        request.session['lastLoginTime'] = currentTime
        response['code'] = 0
        response['data'] = response_data
        return HttpResponse(json.dumps(response),content_type="application/json")

    elif _method == '1':
        query_telephone = Cook.objects.filter(telephone = str(_telephone))
        if not query_telephone.exists():
            _name = '****'+_telephone[7:11]
            _headImage = 'http://meiyue.b0.upaiyun.com/head/1_head.jpg'
            currentTime = time.time()
            currentTime = int(currentTime)
            currentTime = str(currentTime)
            new_cook = Cook(telephone=str(_telephone),name = _name, headImage = _headImage,lastLoginTime =
            currentTime,deviceToken = _deviceToken,clientID = _clientID,deviceInfo = _deviceInfo)
            new_cook.save()
            response['code'] = 0
            response_data = {'cookId':new_cook.id,'setShopStatus':'0','shopId':'0'}
            request.session['cookId'] = new_cook.id   #new_shop.save()之后,才能在session中设置shopid,未保存之前不知道是多少
            request.session['lastLoginTime'] = currentTime
            response['data'] = response_data
            return HttpResponse(json.dumps(response),content_type="application/json")

        response_data = {}
        response_data['cookId'] = query_telephone[0].id
        if query_telephone[0].shop == None:
            response_data['setShopStatus'] = '0'
            response_data['shopId'] = '0'
        else:
            response_data['setShopStatus'] = '1'
            response_data['shopId'] = query_telephone[0].shop.id
        request.session['cookId'] = query_telephone[0].id
        currentTime = time.time()*1000
        currentTime = int(currentTime)
        currentTime = str(currentTime)
        query_telephone.update(clientID = _clientID, deviceToken = _deviceToken,deviceInfo = _deviceInfo,lastLoginTime = currentTime)
        request.session['lastLoginTime'] = currentTime
        response['code'] = 0
        response['data'] = response_data
        return HttpResponse(json.dumps(response),content_type="application/json")

    elif _method == '2':
        query_telephone = WaiterServe.objects.filter(telephone = str(_telephone))
        if not query_telephone.exists():
            _name = '****'+_telephone[7:11]
            _headImage = 'http://meiyue.b0.upaiyun.com/head/1_head.jpg'
            currentTime = time.time()
            currentTime = int(currentTime)
            currentTime = str(currentTime)
            new_waiterServe = WaiterServe(telephone=str(_telephone),name = _name, headImage = _headImage,lastLoginTime =
            currentTime,deviceToken = _deviceToken,clientID = _clientID,deviceInfo = _deviceInfo)
            new_waiterServe.save()
            response['code'] = 0
            response_data = {'waiterServeId':new_waiterServe.id,'setShopStatus':0,'shopId':'0'}
            request.session['waiterServeId'] = new_waiterServe.id   #new_shop.save()之后,才能在session中设置shopid,未保存之前不知道是多少
            request.session['lastLoginTime'] = currentTime
            response['data'] = response_data
            return HttpResponse(json.dumps(response),content_type="application/json")

        response_data = {}
        response_data['waiterServeId'] = query_telephone[0].id
        if query_telephone[0].shop == None:
            response_data['setShopStatus'] = '0'
            response_data['shopId'] = '0'
        else:
            response_data['setShopStatus'] = '1'
            response_data['shopId'] = query_telephone[0].shop.id
        request.session['waiterServeId'] = query_telephone[0].id
        currentTime = time.time()*1000
        currentTime = int(currentTime)
        currentTime = str(currentTime)
        query_telephone.update(clientID = _clientID, deviceToken = _deviceToken,deviceInfo = _deviceInfo,lastLoginTime = currentTime)
        request.session['lastLoginTime'] = currentTime
        response['code'] = 0
        response['data'] = response_data
        return HttpResponse(json.dumps(response),content_type="application/json")

    elif _method == '3':
        query_telephone = Shop.objects.filter(telephone = str(_telephone))
        if not query_telephone.exists():
            currentTime = time.time()
            currentTime = int(currentTime)
            currentTime = str(currentTime)
            new_shop = Shop(telephone=str(_telephone),setInfoStatus = '0',lastLoginTime = currentTime,deviceToken
            = _deviceToken,clientID = _clientID,deviceInfo = _deviceInfo)
            new_shop.save()
            response['code'] = 0
            response_data = {'shopId':new_shop.id,'setInfoStatus':0}
            request.session['shopId'] = new_shop.id   #new_shop.save()之后,才能在session中设置shopid,未保存之前不知道是多少
            request.session['lastLoginTime'] = currentTime
            response['data'] = response_data
            return HttpResponse(json.dumps(response),content_type="application/json")

        response_data = {'setInfoStatus':query_telephone[0].setInfoStatus,'shopId':query_telephone[0].id}
        request.session['shopId'] = query_telephone[0].id
        currentTime = time.time()*1000
        currentTime = int(currentTime)
        currentTime = str(currentTime)
        query_telephone.update(lastLoginTime = currentTime,clientID = _clientID, deviceToken = _deviceToken,deviceInfo = _deviceInfo)
        request.session['lastLoginTime'] = currentTime
        response['code'] = 0
        response['data'] = response_data
        return HttpResponse(json.dumps(response),content_type="application/json")
예제 #2
0
파일: shop.py 프로젝트: yeepom/Packing
def shopVerifyTelephone(request):
    logger = logging.getLogger('Pack.app')
    response = {}
    response['data'] = {}
    response['errorMsg'] = ""
    _telephone = request.REQUEST.get('telephone',18201637776)
    _verify_code = request.REQUEST.get('verifyCode',8888)
    _method = request.REQUEST.get('method')
    _deviceInfo = request.REQUEST.get('deviceInfo')
    _clientID = request.REQUEST.get('clientID','0')
    _deviceToken = request.REQUEST.get('deviceToken','0')

    # cache.set(str(_telephone),str(_verify_code),1800)
    if _telephone == None or _telephone == '':
        response['code'] = -1
        response['errorMsg'] = u'请输入手机号'
        return HttpResponse(json.dumps(response,ensure_ascii=False),content_type="application/json")
    if  _verify_code == None or _verify_code == '':
        response['code'] = -1
        response['errorMsg'] = u'请输入验证码'
        return HttpResponse(json.dumps(response,ensure_ascii=False),content_type="application/json")
    if _deviceInfo == None or _deviceInfo == '':
        response['code'] = -1
        response['errorMsg'] = u'请输入设备信息'
        return HttpResponse(json.dumps(response,ensure_ascii=False),content_type="application/json")
    if _clientID == None or _clientID == '':
        response['code'] = -1
        response['errorMsg'] = u'请输入clientID'
        return HttpResponse(json.dumps(response,ensure_ascii=False),content_type="application/json")
    if _deviceToken == None or _deviceToken == '':
        response['code'] = -1
        response['errorMsg'] = u'请输入deviceToken'
        return HttpResponse(json.dumps(response,ensure_ascii=False),content_type="application/json")
    if _method == None or _method == '':
        response['code'] = -1
        response['errorMsg'] = u'请输入method'
        return HttpResponse(json.dumps(response,ensure_ascii=False),content_type="application/json")


    _telephone = str(_telephone)
    _verify_code = str(_verify_code)
    _clientID = str(_clientID)
    _deviceToken = str(_deviceToken)
    _method = str(_method)

    if _verify_code == '8888':
        cache.set(str(_telephone),str(_verify_code),5*60)

    if len(_telephone) != 11:
        response['code'] = -1
        response['errorMsg'] = '请输入11位手机号'
        return HttpResponse(json.dumps(response,ensure_ascii=False),content_type="application/json")
    if _telephone.isdigit() == False:
        response['code'] = -1
        response['errorMsg'] = '请输入有效的手机号'
        return HttpResponse(json.dumps(response,ensure_ascii=False),content_type="application/json")


     # 手机号码:
     # 13[0-9], 14[5,7], 15[0, 1, 2, 3, 5, 6, 7, 8, 9], 17[6, 7, 8], 18[0-9], 170[0-9]
     # 移动号段: 134,135,136,137,138,139,150,151,152,157,158,159,182,183,184,187,188,147,178,1705
     # 联通号段: 130,131,132,155,156,185,186,145,176,1709
     # 电信号段: 133,153,180,181,189,177,1700


    #手机号判断
    MOBILE_PROG = re.compile(r"^1(3[0-9]|4[57]|5[0-35-9]|8[0-9]|70)\d{8}$")

    #中国移动:China Mobile
    # 134,135,136,137,138,139,150,151,152,157,158,159,182,183,184,187,188,147,178,1705
    CM_prog = re.compile(r"(^1(3[4-9]|4[7]|5[0-27-9]|7[8]|8[2-478])\d{8}$)|(^1705\d{7}$)")

    #中国联通:China Unicom
    # 130,131,132,155,156,185,186,145,176,1709
    CU_prog = re.compile(r"(^1(3[0-2]|4[5]|5[56]|7[6]|8[56])\d{8}$)|(^1709\d{7}$)")

    # 中国电信:China Telecom
    # 133,153,180,181,189,177,1700
    CT_prog = re.compile(r"(^1(33|53|77|8[019])\d{8}$)|(^1700\d{7}$)")

    telephone_match_MOBILE = MOBILE_PROG.match(str(_telephone))
    telephone_match_CM = CM_prog.match(str(_telephone))
    telephone_match_CU = CU_prog.match(str(_telephone))
    telephone_match_CT = CT_prog.match(str(_telephone))


    if not telephone_match_MOBILE:
        response['code'] =  -1
        response['errorMsg'] = '请输入有效的手机号'
        return HttpResponse(json.dumps(response,ensure_ascii=False),content_type="application/json")

    if not telephone_match_CM and not telephone_match_CT and not telephone_match_CU:
        response['code'] =  -1
        response['errorMsg'] = '请输入有效的手机号'
        return HttpResponse(json.dumps(response,ensure_ascii=False),content_type="application/json")
    saved_verify_code = cache.get(str(_telephone))
    #print('saved_verify_code:'+str(saved_verify_code))
    if not saved_verify_code:
        response['code'] = -1
        response['errorMsg'] = '请重新发送验证码'
        return HttpResponse(json.dumps(response,ensure_ascii=False),content_type="application/json")
    if saved_verify_code != _verify_code:
        response['code'] = -1
        response['errorMsg'] = '验证码错误,请重新输入'
        return HttpResponse(json.dumps(response,ensure_ascii=False),content_type="application/json")
    if _method == '0':
        query_telephone = Shop.objects.filter(telephone = str(_telephone))
        if not query_telephone.exists():
            currentTime = time.time()
            currentTime = int(currentTime)
            currentTime = str(currentTime)
            new_shop = Shop(telephone=str(_telephone),lastLoginTime = currentTime,deviceToken  = _deviceToken,
                            clientID = _clientID,deviceInfo = _deviceInfo)
            new_shop.save()
            response['code'] = 0
            response_data = {'type':'0','shopId':str(new_shop.id),'everSetInfo':'0'}
            request.session['shopId'] = new_shop.id   #new_shop.save()之后,才能在session中设置shopid,未保存之前不知道是多少
            request.session['lastLoginTime'] = currentTime
            response['data'] = response_data
            return HttpResponse(json.dumps(response),content_type="application/json")

        response_data = {'type':'0','shopId':str(query_telephone[0].id)}
        response_data['everSetInfo'] = '1' if query_telephone[0].everSetInfo == True else '0'
        currentTime = time.time()*1000
        currentTime = int(currentTime)
        currentTime = str(currentTime)
        query_telephone.update(lastLoginTime = currentTime,clientID = _clientID, deviceToken = _deviceToken,deviceInfo = _deviceInfo)
        request.session['shopId'] = query_telephone[0].id
        request.session['lastLoginTime'] = currentTime
        response['code'] = 0
        response['data'] = response_data
        return HttpResponse(json.dumps(response),content_type="application/json")

    elif _method == '1':
        query_telephone = Waiter.objects.filter(telephone = str(_telephone))
        if not query_telephone.exists():
            _name = '****'+_telephone[7:11]
            _headImage = 'http://meiyue.b0.upaiyun.com/head/1_head.jpg'
            currentTime = time.time()
            currentTime = int(currentTime)
            currentTime = str(currentTime)
            new_waiter = Waiter(telephone=str(_telephone),name = _name, headImage = _headImage,lastLoginTime =
            currentTime,deviceToken = _deviceToken,clientID = _clientID,deviceInfo = _deviceInfo)
            new_waiter.save()
            response['code'] = 0
            response_data = {'type':'1','waiterId':str(new_waiter.id),'everSetInfo':'0'}
            request.session['waiterId'] = new_waiter.id   #new_shop.save()之后,才能在session中设置shopid,未保存之前不知道是多少
            request.session['lastLoginTime'] = currentTime
            response['data'] = response_data
            return HttpResponse(json.dumps(response),content_type="application/json")

        response_data = {}
        response_data['waiterId'] = str(query_telephone[0].id)
        response_data['type'] = '1'
        response_data['everSetInfo'] = '1' if query_telephone[0].everSetInfo == True else '0'
        currentTime = time.time()*1000
        currentTime = int(currentTime)
        currentTime = str(currentTime)
        query_telephone.update(clientID = _clientID, deviceToken = _deviceToken,deviceInfo = _deviceInfo,lastLoginTime = currentTime)
        request.session['waiterId'] = query_telephone[0].id
        request.session['lastLoginTime'] = currentTime
        response['code'] = 0
        response['data'] = response_data
        return HttpResponse(json.dumps(response),content_type="application/json")

    elif _method == '2':
        query_telephone = OrderSeparate.objects.filter(telephone = str(_telephone))
        if not query_telephone.exists():
            _name = '****'+_telephone[7:11]
            _headImage = 'http://meiyue.b0.upaiyun.com/head/1_head.jpg'
            currentTime = time.time()
            currentTime = int(currentTime)
            currentTime = str(currentTime)
            new_orderSeparate = OrderSeparate(telephone=str(_telephone),name = _name, headImage = _headImage,
                                           lastLoginTime =
            currentTime,deviceToken = _deviceToken,clientID = _clientID,deviceInfo = _deviceInfo)
            new_orderSeparate.save()
            response['code'] = 0
            response_data = {'type':'2','orderSeparateId':str(new_orderSeparate.id),'everSetInfo':'0'}
            request.session['orderSeparateId'] = new_orderSeparate.id   #new_shop.save()之后,才能在session中设置shopid,未保存之前不知道是多少
            request.session['lastLoginTime'] = currentTime
            response['data'] = response_data
            return HttpResponse(json.dumps(response),content_type="application/json")

        response_data = {}
        response_data['orderSeparateId'] = str(query_telephone[0].id)
        response_data['type'] = '2'
        response_data['everSetInfo'] = '1' if query_telephone[0].everSetInfo == True else '0'
        currentTime = time.time()*1000
        currentTime = int(currentTime)
        currentTime = str(currentTime)
        query_telephone.update(clientID = _clientID, deviceToken = _deviceToken,deviceInfo = _deviceInfo,lastLoginTime = currentTime)
        request.session['orderSeparateId'] = query_telephone[0].id
        request.session['lastLoginTime'] = currentTime
        response['code'] = 0
        response['data'] = response_data
        return HttpResponse(json.dumps(response),content_type="application/json")


    elif _method == '3':
        query_telephone = BeforeCook.objects.filter(telephone = str(_telephone))
        if not query_telephone.exists():
            _name = '****'+_telephone[7:11]
            _headImage = 'http://meiyue.b0.upaiyun.com/head/1_head.jpg'
            currentTime = time.time()
            currentTime = int(currentTime)
            currentTime = str(currentTime)
            new_beforeCook = BeforeCook(telephone=str(_telephone),name = _name, headImage = _headImage,lastLoginTime =
            currentTime,deviceToken = _deviceToken,clientID = _clientID,deviceInfo = _deviceInfo)
            new_beforeCook.save()
            response['code'] = 0
            response_data = {'type':'3','beforeCookId':str(new_beforeCook.id),'everSetInfo':'0'}
            request.session['beforeCookId'] = new_beforeCook.id   #new_shop.save()之后,才能在session中设置shopid,未保存之前不知道是多少
            request.session['lastLoginTime'] = currentTime
            response['data'] = response_data
            return HttpResponse(json.dumps(response),content_type="application/json")

        response_data = {}
        response_data['beforeCookId'] = str(query_telephone[0].id)
        response_data['type'] = '3'
        response_data['everSetInfo'] = '1' if query_telephone[0].everSetInfo == True else '0'
        currentTime = time.time()*1000
        currentTime = int(currentTime)
        currentTime = str(currentTime)
        query_telephone.update(clientID = _clientID, deviceToken = _deviceToken,deviceInfo = _deviceInfo,lastLoginTime = currentTime)
        request.session['beforeCookId'] = query_telephone[0].id
        request.session['lastLoginTime'] = currentTime
        response['code'] = 0
        response['data'] = response_data
        return HttpResponse(json.dumps(response),content_type="application/json")


    elif _method == '4':
        query_telephone = AfterCook.objects.filter(telephone = str(_telephone))
        if not query_telephone.exists():
            _name = '****'+_telephone[7:11]
            _headImage = 'http://meiyue.b0.upaiyun.com/head/1_head.jpg'
            currentTime = time.time()
            currentTime = int(currentTime)
            currentTime = str(currentTime)
            new_afterCook = AfterCook(telephone=str(_telephone),name = _name, headImage = _headImage,
                lastLoginTime =currentTime,deviceToken = _deviceToken,clientID = _clientID,deviceInfo = _deviceInfo)
            new_afterCook.save()
            response['code'] = 0
            response_data = {'type':'4','afterCookId':str(new_afterCook.id),'everSetInfo':'0'}
            request.session['afterCookId'] = new_afterCook.id   #new_shop.save()之后,才能在session中设置shopid,未保存之前不知道是多少
            request.session['lastLoginTime'] = currentTime
            response['data'] = response_data
            return HttpResponse(json.dumps(response),content_type="application/json")

        response_data = {}
        response_data['afterCookId'] = str(query_telephone[0].id)
        response_data['type'] = '4'
        response_data['everSetInfo'] = '1' if query_telephone[0].everSetInfo == True else '0'
        currentTime = time.time()*1000
        currentTime = int(currentTime)
        currentTime = str(currentTime)
        query_telephone.update(clientID = _clientID, deviceToken = _deviceToken,deviceInfo = _deviceInfo,lastLoginTime = currentTime)
        request.session['afterCookId'] = query_telephone[0].id
        request.session['lastLoginTime'] = currentTime
        response['code'] = 0
        response['data'] = response_data
        return HttpResponse(json.dumps(response),content_type="application/json")


    elif _method == '5':
        query_telephone = Serve.objects.filter(telephone = str(_telephone))
        if not query_telephone.exists():
            _name = '****'+_telephone[7:11]
            _headImage = 'http://meiyue.b0.upaiyun.com/head/1_head.jpg'
            currentTime = time.time()
            currentTime = int(currentTime)
            currentTime = str(currentTime)
            new_serve = Serve(telephone=str(_telephone),name = _name, headImage = _headImage,lastLoginTime =
            currentTime,deviceToken = _deviceToken,clientID = _clientID,deviceInfo = _deviceInfo)
            new_serve.save()
            response['code'] = 0
            response_data = {'type':'5','serveId':str(new_serve.id),'everSetInfo':'0'}
            request.session['serveId'] = new_serve.id   #new_shop.save()之后,才能在session中设置shopid,未保存之前不知道是多少
            request.session['lastLoginTime'] = currentTime
            response['data'] = response_data
            return HttpResponse(json.dumps(response),content_type="application/json")

        response_data = {}
        response_data['serveId'] = str(query_telephone[0].id)
        response_data['type'] = '5'
        response_data['everSetInfo'] = '1' if query_telephone[0].everSetInfo == True else '0'
        currentTime = time.time()*1000
        currentTime = int(currentTime)
        currentTime = str(currentTime)
        query_telephone.update(clientID = _clientID, deviceToken = _deviceToken,deviceInfo = _deviceInfo,lastLoginTime = currentTime)
        request.session['serveId'] = query_telephone[0].id
        request.session['lastLoginTime'] = currentTime
        response['code'] = 0
        response['data'] = response_data
        return HttpResponse(json.dumps(response),content_type="application/json")