Exemple #1
0
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')
Exemple #2
0
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')
Exemple #3
0
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')