예제 #1
0
파일: cook_order.py 프로젝트: tillmans/pack
def cookGetOrderSkuList(request):
    logger = logging.getLogger('Pack.app')
    response = {}
    response['data'] = {}
    response['errorMsg'] = ""
    _cookId = request.session.get('cookId')
    if not _cookId:
        response['code'] = 1
        response['errorMsg'] = '请先登录'
        return HttpResponse(json.dumps(response),content_type="application/json")
    ##################JUDGE############
    _lastLoginTime = request.session.get('lastLoginTime')
    if not _lastLoginTime:
        response['code'] = 1
        response['errorMsg'] = '请先登录'
        return HttpResponse(json.dumps(response),content_type="application/json")
    try:
        cook = Cook.select_related().objects.get(id = _cookId)
    except ObjectDoesNotExist:
        response['code'] = 1
        response['errorMsg'] = '请先登录'
        return HttpResponse(json.dumps(response,ensure_ascii=False),content_type="application/json")
    if _lastLoginTime != cook.lastLoginTime:
        response['code'] = 1
        response['errorMsg'] = '上次登录失效,请重新登录'
        return HttpResponse(json.dumps(response),content_type="application/json")
    ####################END#################

    _orderSkuId = request.REQUEST.get('0rderSkuId')
    _limit = request.REQUEST.get('limit',20)
    _limit = int(_limit)

    if _orderSkuId == None:
        response['code'] = -1
        response['errorMsg'] = '请输入订单id'
        return HttpResponse(json.dumps(response),content_type="application/json")
    _orderSkuId = int (_orderSkuId)
    if _orderSkuId == 0:
        orderSkuQuery = OrderSku.objects.select_related().filter(cookId = _cookId).filter(status = '0').order_by('id')
        orderSkus = orderSkuQuery.reverse()[0:0+_limit]
    else:
        orderSkuQuery = OrderSku.objects.select_related().filter(cookId = _cookId).filter(status = '0').filter(id__lt =
            _orderSkuId).order_by('id')
        orderSkus = orderSkuQuery.reverse()[0:0+_limit]
    orderSkuList = []
    for orderSku in orderSkus:
        _orderSku = {}
        _orderSku['skuId'] = orderSku.skuId
        _orderSku['skuName'] = orderSku.skuName
        _orderSku['skuPrice'] = orderSku.skuPrice
        _orderSku['skuSizeName'] = orderSku.skuSizeName
        _orderSku['skuQuantity'] = orderSku.skuQuantity
        orderSkuList.append(_orderSku)
    response['code'] = 0
    response['data'] = orderSkuList
    return HttpResponse(json.dumps(response),content_type="application/json")
예제 #2
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")
예제 #3
0
def verifyCook(request):
    response = {}
    response['data'] = {}
    response['errorMsg'] = ""
    _shopId = request.session.get('shopId')
    if not _shopId:
        response['code'] = 1
        response['errorMsg'] = '请先登录'
        return HttpResponse(json.dumps(response),content_type="application/json")
    ##################JUDGE############
    _lastLoginTime = request.session.get('lastLoginTime')
    if not _lastLoginTime:
        response['code'] = 1
        response['errorMsg'] = '请先登录'
        return HttpResponse(json.dumps(response),content_type="application/json")
    try:
        shop = Shop.objects.get(id = _shopId)
    except ObjectDoesNotExist:
        response['code'] = 1
        response['errorMsg'] = '请先登录'
        return HttpResponse(json.dumps(response,ensure_ascii=False),content_type="application/json")
    if _lastLoginTime != shop.lastLoginTime:
        response['code'] = 1
        response['errorMsg'] = '上次登录失效,请重新登录'
        return HttpResponse(json.dumps(response),content_type="application/json")
    ####################END#################

    _telephone = request.REQUEST.get('telephone',18201637776)
    _verify_code = request.REQUEST.get('verifyCode',8888)
    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")

    _telephone = str(_telephone)
    _verify_code = str(_verify_code)
    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")
    CM_prog = re.compile(r"^1(34[0-8]|(3[5-9]|5[017-9]|8[278])\d)\d{7}$")
    CU_prog = re.compile(r"^1(3[0-2]|5[256]|8[56])\d{8}$")
    CT_prog = re.compile(r"^1((33|53|8[09])[0-9]|349)\d{7}$")
    telephone_match_CM = CM_prog.match(_telephone)
    telephone_match_CU = CU_prog.match(_telephone)
    telephone_match_CT = CT_prog.match(_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(_telephone)
    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")
    query_cook = Cook.objects.filter(telephone = _telephone)
    if not query_cook.exists():
        _name = '****'+_telephone[7:11]
        _headImage = 'http://meiyue.b0.upaiyun.com/head/1_head.jpg'
        cook = Cook(telephone = _telephone, name = _name, headImage = _headImage,shop = shop)
        cook.save()
        response['code'] = 0
        response_data = {}
        response_data['waiterOrderId'] = cook.id
        response_data['waiterOrderName'] = cook.name
        response_data['waiterOrderTelepohone'] = cook.telephone
        response['data'] = response_data
        return HttpResponse(json.dumps(response,ensure_ascii=False),content_type="application/json")
    cook = query_cook[0]
    cook.shop = shop
    cook.save()
    response['code'] = 0
    response_data = {}
    response_data['waiterOrderId'] = cook.id
    response_data['waiterOrderName'] = cook.name
    response_data['waiterOrderTelepohone'] = cook.telephone
    response['data'] = response_data
    return HttpResponse(json.dumps(response,ensure_ascii=False),content_type="application/json")
예제 #4
0
파일: cook_order.py 프로젝트: tillmans/pack
def cookFinishOrderSku(request):
    logger = logging.getLogger('Pack.app')
    response = {}
    response['data'] = {}
    response['errorMsg'] = ""
    _cookId = request.session.get('cookId')
    if not _cookId:
        response['code'] = 1
        response['errorMsg'] = '请先登录'
        return HttpResponse(json.dumps(response),content_type="application/json")
    ##################JUDGE############
    _lastLoginTime = request.session.get('lastLoginTime')
    if not _lastLoginTime:
        response['code'] = 1
        response['errorMsg'] = '请先登录'
        return HttpResponse(json.dumps(response),content_type="application/json")
    try:
        cook = Cook.select_related().objects.get(id = _cookId)
    except ObjectDoesNotExist:
        response['code'] = 1
        response['errorMsg'] = '请先登录'
        return HttpResponse(json.dumps(response,ensure_ascii=False),content_type="application/json")
    if _lastLoginTime != cook.lastLoginTime:
        response['code'] = 1
        response['errorMsg'] = '上次登录失效,请重新登录'
        return HttpResponse(json.dumps(response),content_type="application/json")
    ####################END#################

    _orderSkuId = request.REQUEST.get('0rderSkuId')

    if _orderSkuId == None or _orderSkuId == '':
        response['code'] = -1
        response['errorMsg'] = '请输入订单id'
        return HttpResponse(json.dumps(response),content_type="application/json")
    try:
        orderSku = OrderSku.objects.get(id = str(_orderSkuId))
    except ObjectDoesNotExist:
        response['code'] = -1
        response['errorMsg'] = '查询orderSku失败'
        return HttpResponse(json.dumps(response),content_type="application/json")
    if orderSku.status == '0':
        orderSku.status = '1'
        orderSku.save()
        try:
            waiterServe = WaiterServe.objects.get(id = str(orderSku.waiterServeId))
        except ObjectDoesNotExist:
            response['code'] = -1
            response['errorMsg'] = '查询waiterServe失败'
            return HttpResponse(json.dumps(response,ensure_ascii=False),content_type="application/json")
        _deviceInfo = waiterServe.deviceInfo
        if(len(_deviceInfo and 'iOS') == 3):
            pass
            # pushRst = pushAPN(waiterServe.deviceToken, '1001',str(order.id))
            # logger.info(pushRst)
        elif(len(_deviceInfo and 'Android') == 7):
            pass
            # pushRst = pushMessageToSingle(waiterServe.clientID,'1001',str(order.id))
    elif orderSku.status == '1':
        response['code'] = 0
        return HttpResponse(json.dumps(response),content_type="application/json")
    else:
        response['code'] = -1
        response['errorMsg'] = 'orderSku状态错误'
        return HttpResponse(json.dumps(response),content_type="application/json")
예제 #5
0
파일: cook_order.py 프로젝트: tillmans/pack
def getShopOrderDetailWithTable(request):
    logger = logging.getLogger('Pack.app')
    response = {}
    response['data'] = {}
    response['errorMsg'] = ""
    _cookId = request.session.get('cookId')
    if not _cookId:
        response['code'] = 1
        response['errorMsg'] = '请先登录'
        return HttpResponse(json.dumps(response),content_type="application/json")
    ##################JUDGE############
    _lastLoginTime = request.session.get('lastLoginTime')
    if not _lastLoginTime:
        response['code'] = 1
        response['errorMsg'] = '请先登录'
        return HttpResponse(json.dumps(response),content_type="application/json")
    try:
        cook = Cook.select_related().objects.get(id = _cookId)
    except ObjectDoesNotExist:
        response['code'] = 1
        response['errorMsg'] = '请先登录'
        return HttpResponse(json.dumps(response,ensure_ascii=False),content_type="application/json")
    if _lastLoginTime != cook.lastLoginTime:
        response['code'] = 1
        response['errorMsg'] = '上次登录失效,请重新登录'
        return HttpResponse(json.dumps(response),content_type="application/json")
    ####################END#################

    _tableId = request.REQUEST.get('tableId')
    if _tableId == None or _tableId == '':
        response['code'] = -1
        response['errorMsg'] = '获取tableId失败'
        return HttpResponse(json.dumps(response),content_type="application/json")
    _tableId = str(_tableId)
    try:
        order = Order.objects.filter(table__id =_tableId).filter(Q(status = '0') | Q (status = '2')).last()
    except IndexError:
        response['code'] = -1
        response['errorMsg'] = '获取订单失败'
        return HttpResponse(json.dumps(response),content_type="application/json")
    _order = {}
    _order['orderId'] = str(order.id)
    _order['tableId'] = str(order.tableId)
    _order['tableNumber'] = str(order.tableNumber)
    _order['priceTotal'] = float(order.priceTotal)
    _order['status'] = order.status
    shanghai_tz = pytz.timezone('Asia/Shanghai')
    _order['dateTime'] = order.date.astimezone(shanghai_tz).strftime('%Y/%m/%d %H:%M:%S')

    if order.userId =='':
        _order['userInfo'] = ''
    else:
        try:
            user = User.objects.get(id = order.userId)
        except ObjectDoesNotExist:
            response['code'] = -1
            response['errorMsg'] = '获取用户消息失败'
            return HttpResponse(json.dumps(response),content_type="application/json")
        _userInfo = {}
        _userInfo['userId'] = str(user.id)
        _userInfo['userName'] = user.name
        _userInfo['userHeadImage'] = user.headImage
        _userInfo['userTelephone'] = user.telephone
        _order['userInfo'] = _userInfo
    _skuList = []
    orderSkuQuery = OrderSku.objects.filter(order__id = order.id)
    for orderSku in orderSkuQuery:
        _sku = {}
        _sku['orderSkuId'] = orderSku.id
        _sku['skuId'] = orderSku.skuId
        _sku['skuName'] = orderSku.name.encode('utf-8')
        _sku['skuPrice'] = float(orderSku.skuPrice)
        _sku['skuSizeName'] = str(orderSku.skuSizeName)
        _sku['skuQuantity'] = float(orderSku.skuQuantity)
        _sku['skuStatus'] = orderSku.status
        _skuList.append(_sku)
    _order['skuList'] = _skuList
    response['data'] = _order
    response['code'] = 0
    return HttpResponse(json.dumps(response),content_type = "application/json")
예제 #6
0
파일: cook.py 프로젝트: tillmans/pack
def cookInfo(request):
    logger = logging.getLogger('Pack.app')
    response = {}
    response['data'] = {}
    response['errorMsg'] = ""
    _cookId = request.session.get('cookId')
    if not _cookId:
        response['code'] = 1
        response['errorMsg'] = '请先登录'
        return HttpResponse(json.dumps(response),content_type="application/json")
    ##################JUDGE############
    _lastLoginTime = request.session.get('lastLoginTime')
    if not _lastLoginTime:
        response['code'] = 1
        response['errorMsg'] = '请先登录'
        return HttpResponse(json.dumps(response),content_type="application/json")
    try:
        cook = Cook.select_related().objects.get(id = _cookId)
    except ObjectDoesNotExist:
        response['code'] = 1
        response['errorMsg'] = '请先登录'
        return HttpResponse(json.dumps(response,ensure_ascii=False),content_type="application/json")
    if _lastLoginTime != cook.lastLoginTime:
        response['code'] = 1
        response['errorMsg'] = '上次登录失效,请重新登录'
        return HttpResponse(json.dumps(response),content_type="application/json")
    ####################END#################


    _method = request.REQUEST.get('method')
    if _method == None or _method == '':
        response['code'] = -1
        response['errorMsg'] = '获取method失败'
        return HttpResponse(json.dumps(response,ensure_ascii=False),content_type="application/json")
    _method = str(_method)

    #if method = 1,update; method = 2, query
    if _method == '1':
        _name = request.REQUEST.get('name')
        _headImage = request.REQUEST.get('headImage')


        if _name == None or _name == '':
            response['code'] = -1
            response['errorMsg'] = '请输入店铺名字'
            return HttpResponse(json.dumps(response,ensure_ascii=False),content_type="application/json")
        if _headImage == None or _headImage == '':
            _headImage = 'http://meiyue.b0.upaiyun.com/head/1_head.jpg'


        cook.name = _name
        cook.headImage = _headImage
        cook.save()

        response['code'] = 0
        response_data = {}
        response_data['name'] = cook.name.encode('utf-8')
        response_data['telephone'] = cook.telephone
        response_data['headImage'] = cook.headImage
        if cook.saler == None:
            response_salerInfo = {}
            response_salerInfo['salerId'] = ''
            response_salerInfo['salerName'] = ''
            response_salerInfo['salertelephone'] = ''
            response_data['salerInfo'] = response_salerInfo
            response['data'] = response_data
            return HttpResponse(json.dumps(response),content_type="application/json")

        else:
            response_salerInfo = {}
            response_salerInfo['salerId'] = str(cook.saler.id)
            response_salerInfo['salerName'] = str(cook.saler.name)
            response_salerInfo['salertelephone'] = str(cook.saler.telephone)
            response_data['salerInfo'] = response_salerInfo
            response['data'] = response_data
            return HttpResponse(json.dumps(response),content_type="application/json")
    else:
        response['code'] = 0
        response_data = {}
        response_data['name'] = cook.name.encode('utf-8')
        response_data['telephone'] = cook.telephone
        response_data['headImage'] = cook.headImage
        if cook.saler == None:
            response_salerInfo = {}
            response_salerInfo['salerId'] = ''
            response_salerInfo['salerName'] = ''
            response_salerInfo['salertelephone'] = ''
            response_data['salerInfo'] = response_salerInfo
            response['data'] = response_data
            return HttpResponse(json.dumps(response),content_type="application/json")

        else:
            response_salerInfo = {}
            response_salerInfo['salerId'] = str(cook.saler.id)
            response_salerInfo['salerName'] = str(cook.saler.name)
            response_salerInfo['salertelephone'] = str(cook.saler.telephone)
            response_data['salerInfo'] = response_salerInfo
            response['data'] = response_data
            return HttpResponse(json.dumps(response),content_type="application/json")