wupengfei
2025-02-21 64b52fa928e11640e8d6aad49bd39cd27c896543
packages/components/src/utils/lifeRechargeServices.ts
@@ -1,12 +1,6 @@
import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
import { IRequest, BlLifeRechargeServicesOptions } from './types';
export interface PhoneMesssageCodeLoginInput {
  /** 手机号 */
  phoneNumber: string;
  /** 验证码 */
  code: string;
}
import { LifeRechargeConstants } from './lifeRechargeConstants';
export interface RequestConfig {}
@@ -26,4 +20,193 @@
      ...(options || {}),
    });
  }
  /** 获取折扣 GET /api/LifePay/GetRate */
  async getRate(options?: RequestConfig) {
    return this.request<LifePayRateListOutput[]>('/api/LifePay/GetRate', {
      method: 'GET',
      ...(options || {}),
    });
  }
  /** 获取电费面值 GET /api/LifePay/GetElectricParValue */
  async getElectricParValue(options?: RequestConfig) {
    return this.request<ElectricParValueResponse>('/api/LifePay/GetElectricParValue', {
      method: 'GET',
      ...(options || {}),
    });
  }
  /** 获取话费面值 GET /api/LifePay/GetPhoneParValue */
  async getPhoneParValue(options?: RequestConfig) {
    return this.request<PhoneParValueResponse>('/api/LifePay/GetPhoneParValue', {
      method: 'GET',
      ...(options || {}),
    });
  }
  /** 创建生活缴费话费订单 POST /api/LifePay/CreateLifePayPhoneOrder */
  async createLifePayPhoneOrder(
    body: LifePhoneDataCreateLifePayOrderInput,
    options?: RequestConfig
  ) {
    return this.request<CreateLifePayOrderOutput>('/api/LifePay/CreateLifePayPhoneOrder', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      data: body,
      ...(options || {}),
    });
  }
  /** 创建生活缴费电费订单 POST /api/LifePay/CreateLifePayElectricOrder */
  async createLifePayElectricOrder(
    body: LifeElectricDataCreateLifePayOrderInput,
    options?: RequestConfig
  ) {
    return this.request<CreateLifePayOrderOutput>('/api/LifePay/CreateLifePayElectricOrder', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      data: body,
      ...(options || {}),
    });
  }
  /** 根据订单号获取支付状态 GET /api/LifePay/GetPayStatusByOrderNo */
  async getPayStatusByOrderNo(params: APIgetPayStatusByOrderNoParams, options?: RequestConfig) {
    return this.request<LifeRechargeConstants.LifePayStatusEnum>(
      '/api/LifePay/GetPayStatusByOrderNo',
      {
        method: 'GET',
        params: {
          ...params,
        },
        ...(options || {}),
      }
    );
  }
  async setLifePayOrderPayType(body: SetLifePayOrderPayTypeInput, options?: RequestConfig) {
    return this.request<string>('/api/LifePay/SetLifePayOrderPayType', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      data: body,
      ...(options || {}),
    });
  }
}
export interface PhoneMesssageCodeLoginInput {
  /** 手机号 */
  phoneNumber: string;
  /** 验证码 */
  code: string;
}
export interface LifePayRateListOutput {
  rateType?: LifeRechargeConstants.LifePayRateTypeEnum;
  rate?: number;
}
export interface ElectricParValueResponse {
  success?: string;
  requestNo?: string;
  partnerId?: string;
  service?: string;
  version?: string;
  protocol?: string;
  context?: string;
  ext?: string;
  code?: string;
  message?: string;
  detail?: string;
  electricParValue?: ElectricParValueOutput[];
}
export interface ElectricParValueOutput {
  electricType?: string;
  areaName?: string;
  parValue?: string;
  rate?: number;
  comments?: string;
}
export interface PhoneParValueResponse {
  success?: string;
  requestNo?: string;
  partnerId?: string;
  service?: string;
  version?: string;
  protocol?: string;
  context?: string;
  ext?: string;
  code?: string;
  message?: string;
  detail?: string;
  phoneParValue?: PhoneParValueOutput[];
}
export interface PhoneParValueOutput {
  ispCode?: string;
  ispName?: string;
  parValue?: string;
  rate?: number;
  phoneSection?: string;
  comments?: string;
}
export interface LifePhoneDataCreateLifePayOrderInput {
  userId?: string;
  productData?: LifePhoneData;
}
export interface LifePhoneData {
  /** 运营商编码,例如:"yidong", "dianxin", "liantong"。 */
  ispCode: string;
  /** 充值面额,单位为元。测试账户:parValue=100:缴费成功,parValue>100:缴费失败。 */
  parValue: number;
  /** 手机号。 */
  phone: string;
  /** 机主名称(电信手机号必填) */
  name?: string;
}
export interface CreateLifePayOrderOutput {
  orderNo?: string;
}
export interface LifeElectricDataCreateLifePayOrderInput {
  userId?: string;
  productData?: LifeElectricData;
}
export interface LifeElectricData {
  /** 充值面额,单位为元。 */
  parValue: number;
  /** 电网类型,例如:"guowang"代表国家电网,"nanwang"代表南方电网。 */
  electricType: string;
  /** 电费类型,国网必传:住宅、企事业、店铺三个选项。 */
  electricAccountType: string;
  /** 电费户号。 */
  electricAccount: string;
  /** 省份。 */
  province: string;
  /** 城市。 */
  city: string;
  /** 客户身份证后6位,南网必传。 */
  sixID?: string;
}
export interface APIgetPayStatusByOrderNoParams {
  orderNo?: string;
}
export interface SetLifePayOrderPayTypeInput {
  orderNo: string;
  lifePayType?: LifeRechargeConstants.LifePayTypeEnum;
}