import http from './http.js'
const request = http.request

/**
 * 查询订单
 * @param {*} data
 * @returns
 */
export function tbOrderInfoData(data) {
	return request({
		url: "/order/admin/order",
		method: "get",
		data: {
			shopId: uni.getStorageSync('shopId'),
			...data
		}
	});
}

/**
 * 导出数据
 * @param {*} data
 * @returns
 */
export function tbOrderInfoDownload(data) {
	return request({
		url: "/api/tbOrderInfo/download",
		method: "post",
		data: {
			shopId: uni.getStorageSync('shopId'),
			...data
		},
		responseType: "blob"
	});
}
export function createOrder(data, urlType = 'order') {
	return request({
		url: `/${urlType}/admin/order/createOrder`,
		method: "POST",
		data: {
			...data
		}
	})
}
/**
 * 通过Id查询订单
 * @param {*} id
 * @returns
 */
export function tbOrderInfoDetail(id) {
	return request({
		url: `/api/tbOrderInfo/${id}`,
		method: "get"
	});
}

/**
 * 通过Id查询订单
 * @param {*} createdAt
 * @returns
 */
export function payCount(createdAt) {
	console.log(createdAt);
	return request({
		url: `/api/tbOrderInfo/payCount`,
		method: "post",
		data: {
			shopId: uni.getStorageSync('shopId'),
			createdAt: createdAt
		}
	});
}

/**
 * 订单列表
 * @param {*} createdAt
 * @returns
 */
export function tbGroupOrderInfo(params) {
	return request({
		url: `/api/tbGroupOrderInfo`,
		method: "post",
		data: {
			shopId: uni.getStorageSync('shopId'),
			...params
		}
	});
}

/**
 * 退单
 * @param {*} data
 * @returns
 */
export function returnGpOrder(data) {
	return request({
		url: `/api/tbGroupOrderInfo/returnGpOrder`,
		method: "post",
		data
	});
}


/**
 * 店铺订单支付获取链接
 */
export function $getOrderPayUrl(data) {
	return request({
		url: `/api/shopPayApi/getOrderPayUrl`,
		method: "get",
		data: {
			shopId: uni.getStorageSync('shopId'),
			...data
		}
	});
}