import request from '@/utils/request'

// 查询优惠券类型列表
export function listType(query) {
    return request({
        url: '/mapi/coupon/type/list',
        method: 'get',
        params: query
    })
}

export function allList(sendWay) {
    return request({
        url: '/mapi/coupon/type/all',
        method: 'get',
        params: {
            sendWay: sendWay
        }
    })
}
// 查询所有有效优惠券类型列表
export function allValidList(orgId) {
    return request({
        url: '/mapi/coupon/type/allValidByStoreId',
        method: 'get',
        params: {
            orgId: orgId
        }
    })
}

// 查询优惠券类型详细
export function getType(id) {
    return request({
        url: '/mapi/coupon/type/getInfo',
        method: 'get',
        params: { id: id }
    })
}

// 新增优惠券类型
export function addType(data) {
    return request({
        url: '/mapi/coupon/type',
        method: 'post',
        data: data
    })
}

// 修改优惠券类型
export function updateType(data) {
    return request({
        url: '/mapi/coupon/type',
        method: 'put',
        data: data
    })
}

// 删除优惠券类型
export function delType(id) {
    return request({
        url: '/mapi/coupon/type/' + id,
        method: 'delete'
    })
}

// 修改优惠券类型状态
export function updateTypeStatus(id, status) {
    const data = {
        id,
        status
    }
    return request({
        url: '/mapi/coupon/type/updateStatus',
        method: 'post',
        data: data
    })
}

// 查询优惠券类型列表
export function getCouponTypeList(query) {
    return request({
        url: '/mapi/coupon/type/list',
        method: 'get',
        params: query
    })
}
