Exemplo n.º 1
0
def auth_admin_model(role, email, status):
    """
    更改管理员权限
    :param role: 管理员角色
    :param email:  管理员登录邮箱
    :param status:  提交前的状态
    :return:  更过后的状态或结果
    """
    if status == 'on' and role in ADMIN_ROLE:  # status为授权状态‘on’,其操作是撤销权限
        query = {'$pull': {'auth': role}}
        status = 'off'
    elif status == 'off' and role in ADMIN_ROLE:    # status为'off'无权限,接下来将授予权限
        query = {'$push': {'auth': role}}
        status = 'on'
    else:
        return False
    my_db = ToMongo()
    my_db.update('admin', {'email': email}, query)
    result = {'status': status}
    return result
Exemplo n.º 2
0
def handle_refund(order_no, status, msg):
    """退款"""
    conn = ToMongo()
    # 还原库存
    query = {'order_no': order_no}
    restore_stock(query, conn)
    # 更新订单状态
    result = conn.update('order', {
        'order_no': order_no,
        'orders_status': status
    }, {"$set": {
        'orders_status': 5
    }})
    if result.modified_count:
        pass
    else:
        msg.update({'error': '更新失败'})
    conn.close_conn()
Exemplo n.º 3
0
def uptate_status_inc(order_no, status, msg):
    conn = ToMongo()
    new = {"$inc": {'orders_status': 1}}
    if status == 0:
        new = {
            "$inc": {
                'orders_status': 1
            },
            "$addToSet": {
                'logistics': {
                    'create_time': get_now(),
                    'info': '商品已经下单'
                }
            }
        }
    elif status == 1:
        new = {
            "$inc": {
                'orders_status': 1
            },
            "$addToSet": {
                'logistics': {
                    'create_time': get_now(),
                    'info': '包裹正在等待揽收'
                }
            }
        }
    result = conn.update('order', {
        'order_no': order_no,
        'orders_status': status
    },
                         new,
                         is_one=False)
    if result.modified_count:
        pass
    else:
        msg.update({'error': '更新失败'})
    conn.close_conn()