import { cashOut } from "@/api";

/**分成收益模型 */
export class CashOutModel {
  private api = cashOut;

  /**查询收益列表 */
  async extensionIncomeList() {
    const res = await this.api.extensionIncomeList();
    return {
      rows: res.data.rows.map((item) => {
        item.profitPrice /= 100;
        return {
          ...item,
          profitPrice: item.profitPrice.toFixed(2),
        };
      }),
      total: res.data.total,
    };
  }

  /**查询收益金额（总金额、已提现金额、未提现金额） */
  async extensionIncomePrice() {
    const {
      data: { data },
    } = await this.api.extensionIncomePrice();

    data.extractPrice /= 100;
    data.remainderPrice /= 100;
    data.totalPrice /= 100;
    return {
      ...data,
      extractPrice: data.extractPrice.toFixed(2),
      remainderPrice: data.remainderPrice.toFixed(2),
      totalPrice: data.totalPrice.toFixed(2),
    };
  }
}
