本文整理汇总了Python中models.Order.find_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Order.find_by_id方法的具体用法?Python Order.find_by_id怎么用?Python Order.find_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Order
的用法示例。
在下文中一共展示了Order.find_by_id方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: order_refund_by_admin
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import find_by_id [as 别名]
def order_refund_by_admin(order_id):
order = Order.find_by_id(order_id)
if not order:
return render.not_found()
reason = json.loads(request.data).get('reason', CANCEL_REASON_ADMIN)
refund_money = json.loads(request.data).get('money')
if refund_money is None:
return render.error('missing argument: money')
refund_money = int_money(refund_money)
if refund_money == 0:
return render.error('Refund money can not be 0')
remained_money = order.cash_amount - Refund.order_refund_total(order.id)
if refund_money > remained_money:
return render.error('not enough money to refund')
# refund
if not refund_order(order, refund_money, reason, [], charge):
return render.error('refund error')
return render.ok('refund successfully')
示例2: order_confirm_by_admin
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import find_by_id [as 别名]
def order_confirm_by_admin(order_id):
order = Order.find_by_id(order_id)
if not order:
return render.not_found()
order.confirm()
return render.ok('CONFIRMED')
示例3: order_start_deliver
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import find_by_id [as 别名]
def order_start_deliver(order_id):
order = Order.find_by_id(order_id)
if not order:
return render.not_found()
try:
order.depart()
except:
return render.error("not able to depart")
return render.ok('IN_DELIVERY')
示例4: order_cancel_by_admin
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import find_by_id [as 别名]
def order_cancel_by_admin(order_id):
order = Order.find_by_id(order_id)
if not order:
return render.not_found()
reason = json.loads(request.data).get('reason', CANCEL_REASON_ADMIN)
cancel_order(order, charge, reason)
return render.ok()
示例5: order_receive_express
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import find_by_id [as 别名]
def order_receive_express(order_id):
order = Order.find_by_id(order_id)
if not order:
return render.not_found()
# code = json.loads(request.data).get('code', None)
# TODO: when need authorize order.code, change it.
# if code == order.code:
if True:
order.delivered()
return render.ok('DELIVERED')
else:
return render.error('wrong code')
示例6: order_show
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import find_by_id [as 别名]
def order_show(order_id):
order = Order.find_by_id(order_id)
return render.ok(order.details())