import request from '/@/utils/request';

// ==================== 商户用户相关 API ====================

export function fetchList(query?: Object) {
	return request({
		url: 'admin/merchantUser/page',
		method: 'get',
		params: query,
	});
}

export function addObj(obj?: Object) {
	return request({
		url: 'admin/merchantUser/save',
		method: 'post',
		data: obj,
	});
}

export function getObj(id?: string) {
	return request({
		url: `admin/merchantUser/info/${id}`,
		method: 'get',
	});
}

export function putObj(id: string, obj?: Object) {
	return request({
		url: `admin/merchantUser/edit/${id}`,
		method: 'patch',
		data: obj,
	});
}

export function changeStatus(id: string) {
	return request({
		url: `/admin/merchantUser/changeStatus/${id}`,
		method: 'patch',
	});
}

export function changePwd(id: string, data?: Object) {
	return request({
		url: `/admin/merchantUser/changePwd/${id}`,
		method: 'patch',
		data: data,
	});
}

export function getAgentList(id: string) {
	return request({
		url: `/admin/merchantUser/agentList/${id}`,
		method: 'get',
	});
}

export function resetMd5Key(id: string) {
	return request({
		url: `/admin/merchantUser/resetMd5/${id}`,
		method: 'patch',
	});
}

// ==================== 商户支付通道相关 API ====================

export function fetchMerchantPaymentTypeList(merchantUserId: string, paymentType: 'PAY' | 'HARVEST') {
	return request({
		url: 'admin/merchantPaymentType/list',
		method: 'get',
		params: {
			merchantUserId,
			paymentType,
		},
	});
}

export function editMerchantPaymentType(obj?: Object) {
	return request({
		url: 'admin/merchantPaymentType/edit',
		method: 'post',
		data: obj,
	});
}
