Exemplo n.º 1
0
 def get(self):
     """this method to get user how much used one day"""
     user_id = self.context.get("user_id")
     ret = orders_api.expr_order_kinds_used(user_id)
     if ret == 0:
         self.json_response(1, result=ret)
     else:
         self.json_response(0, result=ret)
Exemplo n.º 2
0
    def get(self):
        # 检查用户是否是admin用户
        if not self.context.get("user").get("admin"):
            self.set_status(401)
            return
        resource_id = self.get_argument('resource_id', "")

        result = orders_api.get_order_by_resource_id(resource_id=resource_id)
        self.set_status(result)
Exemplo n.º 3
0
 def put(self, **kwargs):
     try:
         data = json.loads(self.request.body)
         resource_id = str(self.path_kwargs.get('rid', "")).strip()
         ret = orders_api.update_order(data=data,
                                       resource_id=resource_id)
         if ret.get("code") != 0:
             self.set_status(500)
             self.write({"code": 1, "message": "变更订单失败"})
         else:
             self.write({"code": 0, "message": ""})
     except Exception as e:
         self.set_status(500)
         self.write({"code": 1, "message": "变更订单失败. <{0}>".format(e)})
Exemplo n.º 4
0
 def delete(self, **kwargs):
     try:
         resource_id = str(self.path_kwargs.get('rid', "")).strip()
         ret = orders_api.delete_order(resource_id=resource_id,
                                       end_time=int(time.time())
                                       )
         if ret.get("code") != 0:
             self.set_status(500)
             self.write({"code": 1, "message": "结束订单失败"})
         else:
             self.write({"code": 0, "message": ""})
     except Exception as e:
         self.set_status(500)
         self.write({"code": 1, "message": "结束订单失败. {0}".format(e)})
Exemplo n.º 5
0
 def get(self):
     try:
         user_id = self.context.get("user_id")
         status = self.get_argument('status', '')
         if status != "Settlemented" or not status:
             status = None
         ret = orders_api.get_user_orders(user_id, status)
         if ret == 0:
             self.set_status(500)
             self.json_response(1, result=ret)
         else:
             self.json_response(0, result=ret)
     except Exception as e:
         self.set_status(500)
         self.write({"code": 1, "message": "获取订单失败. <{0}>".format(e)})
Exemplo n.º 6
0
 def post(self):
     try:
         data = json.loads(self.request.body)
         if not data:
             em = "ValueError: no data found"
             self.write({"code": 1, "message": em})
         # add user
         data["user_id"] = data.get("user_id")
         users_api.add_user(data)
         ret = orders_api.add_order(data)
         if ret.get("code") != 0:
             self.set_status(500)
             self.write(ret)
         else:
             self.write(ret)
     except Exception as e:
         self.set_status(500)
         self.write({"code": 1, "message": "添加订单失败. {0}".format(e)})
Exemplo n.º 7
0
 def put(self):
     if not self.context.get("user").get("admin"):
         self.set_status(401)
     orders_api.sync_user_et()
Exemplo n.º 8
0
def test_get_user_day_used(user_id):
    return OrderAbout.get_user_day_used(user_id=user_id)