import { ResponseDataEntity, baseFetch, customerFetch } from './index';
import { number } from 'prop-types';

export type PayConfigParams = {
  areaId: number;
  customerId: number;
};

export type PayTypeVo = {
  /** id */
  id: number;

  /** name */
  name: string;
};

export type PayConfig = {
  id: number;
  giveId: number; //赠送服务id
  giveMoney: number; // 赠送金额
  giveName: string; // 赠送服务名称
  rechargeMoney: number; // 充值金额
};

type PayConfigResponse = {
  isFirstRecharge: number;
  listPayList: PayTypeVo[];
  listRechargeConfDetail: PayConfig[];
};

export const fetchPayConfig = (
  params: PayConfigParams,
): Promise<ResponseDataEntity<PayConfigResponse>> =>
  baseFetch({
    url: '/dcxy/api/paymentAndActiveConf/getRechargeConf',
    data: params,
  });

type RechargeOrderParams = {
  customerId: number;
  id: number;
  isFirstRecharge: number;
  rechargeType: string;
};

export const rechargeOrder = (
  params: RechargeOrderParams,
): Promise<{
  canCall: number;
  code: number;
  msg: string;
  outTradeNo: string;
  payStr: string;
}> =>
  customerFetch({
    url: '/dcxy/app/rechargeOrder/rechargeOrder/smallProPay',
    method: 'POST',
    data: params,
  });

type CreditInfo = {
  amount: number;
  areaId: number;
  operateId: number;
  showType: string;
};

export const fetchCreditDeposites = (params: {
  areaId: number;
}): Promise<ResponseDataEntity<CreditInfo>> =>
  baseFetch({
    url: '/dcxy/api/creditDeposits',
    data: params,
  });
