// c:\Users\zhu\Desktop\Practice Project\new-88live\features\mall\gateway\money.js
// 支付相关接口

import { get, post } from '@/core/http/http-client'
import { buildRestPath } from '@/core/config/api-paths'

/** 获取用户余额 */
export async function getBalance() {
	const { data } = await post(buildRestPath('pay/getBalance'))
	return data
}

/** 获取支付信息 */
export async function getPayInfo(params) {
	const { data } = await post(buildRestPath('pay/getPay'), params)
	return data
}

/** 发起支付 */
export async function postPayment(params) {
	const { data } = await post(buildRestPath('pay/payment'), params)
	return data
}

/** 获取线下支付配置 */
export async function getOfflinePaymentConfig() {
	const { data } = await get('/common/corporatepayment')
	return data
}

/** 获取PayZ支付方式列表 */
export async function getPayZData() {
	const { data } = await get('/common/getpayzdata')
	return data
}
/** 获取钻石余额 */
export async function getDiamondBalance() {
	const { data } = await get('/user/getdiamondnum')
	return data
}

/** 获取赏金余额 */
export async function getTipWallet() {
	const { data } = await get('/user/gettipwallet')
	return data
}

/** 获取提现初始化数据 */
export async function getWithdrawInit(type) {
	const { data } = await post(buildRestPath('pay/initialWithdraw'), { type })
	return data
}

/** 执行提现 */
export async function postWithdraw(params) {
	const { data } = await post(buildRestPath('pay/withdraw'), params)
	return data
}

/** 获取提现记录 */
export async function getWithdrawLog(params) {
	const { data } = await post(buildRestPath('pay/withdrawLog'), params)
	return data
}

/** 获取赏金明细列表 */
export async function getTipWalletLog(params) {
	const { data } = await post(buildRestPath('tipwalletlog/list'), params)
	return data
}

/** 获取账单明细列表 */
export async function getMoneyLog(params) {
	const { data } = await post(buildRestPath('pay/moneyLog'), params)
	return data
}

/** 获取银行卡列表 */
export async function getBankList() {
	const { data } = await post(buildRestPath('pay/getPayAccount'))
	return data
}

/** 添加银行卡 */
export async function addBankAccount(params) {
	const { data } = await post(buildRestPath('pay/addPayAccount'), params)
	return data
}

/** 删除银行卡 */
export async function deleteBankAccount(ids) {
	const { data } = await get('/wanlshop/pay/delPayAccount', { ids })
	return data
}

/** 获取钻石充值套餐列表 */
export async function getDiamondList(type) {
	const { data } = await get('/wanlshop/diamond/list', { type })
	return data
}

/** 获取钻石明细列表 */
export async function getDiamondLog(params) {
	const { data } = await post('/wanlshop/diamondlog/list', params)
	return data
}

/** 钻石充值：获取支付信息 */
export async function getDiamondRecharge(params) {
	const res = await post(buildRestPath('pay/recharge'), params)
	return res.data || {}
}

/** 钻石充值：通知服务器Google Play支付成功 */
export async function notifyGooglePayPurchase(params) {
	return post('/wanlshop/callback/ingoogalpay', params)
}

/** 钻石充值：通知服务器Apple IAP购买成功 */
export async function notifyAppleIAPPurchase(params) {
	return post('/wanlshop/callback/iniospay', params)
}

/** 获取关于/配置信息 */
export async function getAboutConfig() {
	const { data } = await get('/wanlshop/common/about')
	return data
}

/** 上报错误日志 */
export async function saveErrorLog(params) {
	return post('/index/saveerror', params)
}

/**
 * 获取Stripe支付配置
 * @returns {Promise<Object>} Stripe支付配置
*/
export async function getStripePaymentConfig() {
  const response = await get('/common/gettripepayment')
  return response.data
}