Exemplo n.º 1
0
 def get(self, *args, **kwargs):
     sign = self.get_argument('sign')
     time = self.get_argument('time')
     page = int(self.get_argument('page'))
     size = int(self.get_argument('size'))
     userId = self.get_argument('openId')
     type = self.get_argument('type')
     receiveFlg = int(self.get_argument('receiveFlg'))
     orderStatus = self.get_argument('orderStatus')
     md5Util = MD5Util()
     baseResponse = BaseResponse()
     if sign == md5Util.md5Signature(time):
         getOrder = GetOrder()
         netOrderList = getOrder.getMyOrderList(userId, orderStatus, page,
                                                size)
         if netOrderList:
             baseResponse.code = ResponseCode.op_success
             baseResponse.desc = ResponseCode.op_success_desc
             orderCount = getOrder.getMyOrderSizeByStatus(
                 user_id=userId, order_status=orderStatus)
             page_total = (orderCount /
                           size) + (1 if orderCount % size > 0 else 0)
             baseResponse.pageNum = page
             baseResponse.pageSize = size
             baseResponse.page_total = page_total
             baseResponse.totalCount = orderCount
             baseResponse.data = netOrderList
         else:
             baseResponse.code = ResponseCode.op_fail
             baseResponse.desc = ResponseCode.op_fail_desc
     else:
         baseResponse.code = ResponseCode.fail_check_api_md5
         baseResponse.desc = ResponseCode.fail_check_api_md5_desc
     json_str = json.dumps(baseResponse, cls=OrderEncoder)
     self.write(json_str)
 def get(self, *args, **kwargs):
     sign = self.get_argument('sign')
     time = self.get_argument('time')
     page = int(self.get_argument('page'))
     size = int(self.get_argument('size'))
     cateCode = self.get_argument('cateCode')
     sort = int(self.get_argument('sort'))
     skuval = self.get_argument('skuval')
     md5Util = MD5Util()
     baseResponse = BaseResponse()
     if sign == md5Util.md5Signature(time):
         getGoods = GetGoods()
         netHostGoods = getGoods.getHostGoods(cateCode, skuval, page, size,
                                              sort)
         if netHostGoods:
             baseResponse.code = ResponseCode.op_success
             baseResponse.desc = ResponseCode.op_success_desc
             hostGoodsCount = getGoods.getGoodsCountByCate(cateCode, skuval)
             page_total = (hostGoodsCount /
                           size) + (1 if hostGoodsCount % size > 0 else 0)
             baseResponse.pageNum = page
             baseResponse.pageSize = size
             baseResponse.page_total = page_total
             baseResponse.totalCount = hostGoodsCount
             baseResponse.data = netHostGoods
         else:
             baseResponse.code = ResponseCode.op_fail
             baseResponse.desc = ResponseCode.op_fail_desc
     else:
         baseResponse.code = ResponseCode.fail_check_api_md5
         baseResponse.desc = ResponseCode.fail_check_api_md5_desc
     json_str = json.dumps(baseResponse, cls=HostGoodsEncoder)
     self.write(json_str)
Exemplo n.º 3
0
 def get(self, *args, **kwargs):
     page = int(self.get_argument('page'))
     size = int(self.get_argument('size'))
     sign = self.get_argument('sign')
     time = self.get_argument('time')
     logging = LogUtil().getLogging()
     baseResponse = BaseResponse()
     md5Util = MD5Util()
     if sign == md5Util.md5Signature(time):
         getCategory = GetCategory()
         homeDiscoverList = getCategory.getHomeDiscoverList(page_num=page, page_size=size)
         baseResponse.code = ResponseCode.op_success
         baseResponse.desc = ResponseCode.op_success_desc
         homeDiscoverCount = getCategory.getHomeDiscoverCount().get('count')
         logging.info('---> homeDiscoverCount: ' + str(homeDiscoverCount))
         page_total = (homeDiscoverCount / size) + (1 if homeDiscoverCount % size > 0 else 0)
         baseResponse.pageNum = page
         baseResponse.pageSize = size
         baseResponse.page_total = page_total
         baseResponse.totalCount = homeDiscoverCount
         if homeDiscoverList:
             for homeDiscover in homeDiscoverList:
                 baseResponse.append(homeDiscover)
     else:
         baseResponse.code = ResponseCode.fail_check_api_md5
         baseResponse.desc = ResponseCode.fail_check_api_md5_desc
     json_str = json.dumps(baseResponse, cls=HomeDiscoverEncoder)
     self.write(json_str)
 def get(self, *args, **kwargs):
     jsCode = self.get_argument('jsCode')
     nickName = self.get_argument('nickName')
     sign = self.get_argument('sign')
     time = self.get_argument('time')
     md5Util = MD5Util()
     if sign == md5Util.md5Signature(time):
         logging = LogUtil().getLogging()
         # logging.info('----> jsCode: ' + jsCode)
         # logging.info('----> nickName: ' + nickName)
         # logging.info('----> sign: ' + sign)
         # logging.info('----> time: ' + time)
         httpUrl = 'https://api.weixin.qq.com/sns/jscode2session'
         param = {
             "appid": WxToken.APP_ID,
             "secret": WxToken.APP_SECRET,
             "js_code": str(jsCode),
             "grant_type": 'authorization_code'
         }
         body = HttpUtil.http_get(httpUrl, params=param)
         jsonBody = json.loads(body, "utf8")
         if isinstance(jsonBody, dict):
             if jsonBody.has_key('openid'):
                 jsonBody['result'] = True
             else:
                 jsonBody['result'] = False
         # logging.info(type(jsonBody))
         logging.info('--->session json: ' + str(jsonBody))
     else:
         jsonBody = json.loads(u'校验失败', "utf8")
     self.write(jsonBody)
Exemplo n.º 5
0
 def get(self, *args, **kwargs):
     sign = self.get_argument('sign')
     time = self.get_argument('time')
     userId = self.get_argument('openId')
     md5Util = MD5Util()
     baseResponse = BaseResponse()
     if sign == md5Util.md5Signature(time):
         getOrder = GetOrder()
         orderSize = getOrder.getMyOrderSize(userId)
         baseResponse.code = ResponseCode.op_success
         baseResponse.desc = ResponseCode.op_success_desc
         baseResponse.data = orderSize
     else:
         baseResponse.code = ResponseCode.fail_check_api_md5
         baseResponse.desc = ResponseCode.fail_check_api_md5_desc
     json_str = json.dumps(baseResponse, cls=StrEncoder)
     self.write(json_str)
Exemplo n.º 6
0
 def get(self, *args, **kwargs):
     sign = self.get_argument('sign')
     time = self.get_argument('time')
     goods_id = self.get_argument('id')
     baseResponse = BaseResponse()
     md5Util = MD5Util()
     if sign == md5Util.md5Signature(time):
         getGoods = GetGoods()
         netGoodsDetail = getGoods.getGoodsById(goods_id)
         baseResponse.code = ResponseCode.op_success
         baseResponse.desc = ResponseCode.op_success_desc
         baseResponse.data = netGoodsDetail
     else:
         baseResponse.code = ResponseCode.fail_check_api_md5
         baseResponse.desc = ResponseCode.fail_check_api_md5_desc
     json_str = json.dumps(baseResponse, cls=GoodsDetailEncoder)
     self.write(json_str)
Exemplo n.º 7
0
 def get(self, *args, **kwargs):
     sign = self.get_argument('sign')
     time = self.get_argument('time')
     logging = LogUtil().getLogging()
     baseResponse = BaseResponse()
     md5Util = MD5Util()
     if sign == md5Util.md5Signature(time):
         getAdverts = GetAdverts()
         netAdvertsList = getAdverts.getLastAdverts(6)
         logging.info("---> netAdvertsList: " + str(netAdvertsList))
         baseResponse.code = ResponseCode.op_success
         baseResponse.desc = ResponseCode.op_success_desc
         baseResponse.data = netAdvertsList
     else:
         baseResponse.code = ResponseCode.fail_check_api_md5
         baseResponse.desc = ResponseCode.fail_check_api_md5_desc
     json_str = json.dumps(baseResponse, cls=AdvertsEncoder)
     self.write(json_str)
Exemplo n.º 8
0
 def checkAdminPermissionWithLoginStatus(self, sign, time, admin_tel,
                                         sms_pwd):
     baseResponse = BaseResponse()
     if sign is None or time is None or admin_tel is None or sms_pwd is None:
         baseResponse.code = ResponseCode.fail_api_args
         baseResponse.desc = ResponseCode.fail_api_args_desc
     else:
         md5Util = MD5Util(ADMIN_SECRET_KEY)
         adminMgr = AdminManager()
         if sign == md5Util.md5Signature(time):
             login_status = adminMgr.checkLoginState(admin_tel, sms_pwd)
             if login_status == LoginStatus.STATUS_LOGIN_SUCCESS:
                 baseResponse.code = ResponseCode.success_check_admin_permission
                 baseResponse.desc = ResponseCode.success_check_admin_permission_desc
             elif login_status == LoginStatus.STATUS_LOGIN_OUT_OF_DATE:
                 baseResponse.code = ResponseCode.fail_admin_out_of_date
                 baseResponse.desc = ResponseCode.fail_admin_out_of_date_desc
             else:
                 baseResponse.code = ResponseCode.fail_admin_login
                 baseResponse.desc = ResponseCode.fail_admin_login_desc
         else:
             baseResponse.code = ResponseCode.illegal_md5_client
             baseResponse.desc = ResponseCode.illegal_md5_client_desc
     return baseResponse