import { AxiosPromise } from "axios";
import request from "../request";

class Branch {
	/**
	 * 查询一二级绑定用户
	 * @returns
	 */
	spreadRelationList(): AxiosPromise<BranchType.spreadRelationListRes> {
		return request("/student/spread/relation/spreadRelationList");
	}

	/**下级用户积分列表 */
	integralList(): AxiosPromise<BranchTypeTest.IntegralRes> {
		return request("/student/extension/income/extensionPoints");
	}

	/**积分结算 */
	integralSettlement(params: BranchTypeTest.IntegralSettlementParams): AxiosPromise<BranchTypeTest.IntegralSettlementRes> {
		return request("/student/extension/income/extensionIncomePrice", {
			params,
		});
	}
}

export const branch = new Branch();

export declare namespace BranchTypeTest {
	type Integral = {
		openid: string;
		nickName: string;
		headImage: string;
		achievement: number;
		achievementSettled: number;
	};

	interface IntegralRes extends Common.Res {
		data: Integral[];
	}

	type IntegralSettlementParams = {
		openid: string;
		settlePoints: number;
	};

	interface IntegralSettlementRes extends Common.Res {
		data: {};
	}
}
