|
|
<?php
|
|
|
|
|
|
namespace fubei\account;
|
|
|
|
|
|
|
|
|
use fubei\Base;
|
|
|
|
|
|
class Fixed extends Base
|
|
|
{
|
|
|
|
|
|
/**
|
|
|
* 按固定金额分账
|
|
|
* @param float $money 分账总金额,单位为元,精确到0.01 ~ 10000000
|
|
|
* @param string $order_number 外部系统订单号(确保唯一,前后不允许带空格)
|
|
|
* @param array $data_list 分账列表,account_id--分账接收方id share_amount--分账金额(元),精确到0.01,范围:0.01 ~ 1000000
|
|
|
* @param string $notify_url 支付回调地址
|
|
|
* @date 2022-03-17
|
|
|
*/
|
|
|
public function fixedAmount($money, $order_number, $data_list = [], $notify_url = '')
|
|
|
{
|
|
|
//公共参数
|
|
|
$common_data = [
|
|
|
'method' => 'openapi.agent.account.fixed.amount',
|
|
|
];
|
|
|
//业务参数
|
|
|
$biz_content = [
|
|
|
'merchant_order_sn' => $order_number,//32 外部系统订单号(请求流水号)
|
|
|
'total_share_amount' => (string)$money, //分账总金额(元),精确到0.01,范围:0.01 ~ 1000000 强行转成字符串来保证精度
|
|
|
'data_list' => $data_list, //分账列表,具体字段见下方
|
|
|
'notify_url' => $notify_url
|
|
|
];
|
|
|
if (!empty($notify_url)) { //回调地址,非必传
|
|
|
$biz_content['notify_url'] = $notify_url;
|
|
|
}
|
|
|
|
|
|
$result = $this->actionApi($common_data, $biz_content);
|
|
|
|
|
|
// 记录日志
|
|
|
$uid = defined('UID') ? UID : '';
|
|
|
platformLog([
|
|
|
'common_data' => $common_data,
|
|
|
'biz_content' => $biz_content,
|
|
|
], $result, 'fubei_fixed_amount_uid_' . $uid);
|
|
|
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 提现接口
|
|
|
* @param string $order_number 外部系统订单号(请求流水号)
|
|
|
* @param float $money 提现金额(元),精确到0.01,范围:0.01 ~ 10000000 type 为2秒到提现情况下,最低提现金额为1元
|
|
|
* @param string $account_id 分账接收方id,与付呗商户号二选一 不传默认查商户入账户资金
|
|
|
* @param string $notify_url 回调地址
|
|
|
* @date 2022-03-18
|
|
|
*/
|
|
|
public function fixedAmountWithdraw($order_number, $money, $account_id = '', $notify_url = '')
|
|
|
{
|
|
|
//公共参数
|
|
|
$common_data = [
|
|
|
'method' => 'openapi.agent.account.withdraw',
|
|
|
];
|
|
|
|
|
|
//业务参数
|
|
|
$biz_content = [
|
|
|
'merchant_order_sn' => $order_number,
|
|
|
'amount' => (string)$money, //强行转成字符串来保证精度
|
|
|
'type' => 1 //提现方式:1--已结算金额提现,默认值为1,默认提现方式一天有3个打款窗口期 2--D0快速提现,每日10次
|
|
|
];
|
|
|
if (!empty($account_id)) {
|
|
|
$biz_content['account_id'] = $account_id;
|
|
|
} else {
|
|
|
$biz_content['merchant_id'] = $this->config['merchant_id'];
|
|
|
}
|
|
|
if (!empty($notify_url)) { //回调地址,非必传
|
|
|
$biz_content['notify_url'] = $notify_url;
|
|
|
}
|
|
|
|
|
|
$result = $this->actionApi($common_data, $biz_content);
|
|
|
|
|
|
// 记录日志
|
|
|
$uid = defined('UID') ? UID : '';
|
|
|
platformLog([
|
|
|
'common_data' => $common_data,
|
|
|
'biz_content' => $biz_content,
|
|
|
], $result, 'fubei_fixed_amount_withdraw_uid_' . $uid);
|
|
|
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 账户余额查询
|
|
|
* @param string $account_id 分账接收方id,与merchant_id二选一,以商户级接入时,需要使用该字段进行查询时传入 不传默认查商户余额
|
|
|
* @remark 服务商接入时merchant_id与account_id不能同时传,否则报错
|
|
|
* @date 2022-03-18
|
|
|
*/
|
|
|
public function getAccountMoney($account_id = '')
|
|
|
{
|
|
|
//公共参数
|
|
|
$common_data = [
|
|
|
'method' => 'openapi.agent.account.balance.query',
|
|
|
];
|
|
|
//业务参数
|
|
|
if (!empty($account_id)) {
|
|
|
$biz_content['account_id'] = $account_id;
|
|
|
} else {
|
|
|
$biz_content['merchant_id'] = $this->config['merchant_id'];
|
|
|
}
|
|
|
|
|
|
$result = $this->actionApi($common_data, $biz_content);
|
|
|
|
|
|
// 记录日志
|
|
|
$uid = defined('UID') ? UID : '';
|
|
|
platformLog([
|
|
|
'common_data' => $common_data,
|
|
|
'biz_content' => $biz_content,
|
|
|
], $result, 'fubei_get_account_money_uid_' . $uid);
|
|
|
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 入账户资金汇总查询
|
|
|
* @param string $account_id 20 分账接收方id,与付呗商户号二选一 不传默认查商户入账户资金
|
|
|
* @date 2022-03-18
|
|
|
*/
|
|
|
public function getAccountEntryMoney($account_id = '')
|
|
|
{
|
|
|
//公共参数
|
|
|
$common_data = [
|
|
|
'method' => 'openapi.agent.account.balance.entry',
|
|
|
];
|
|
|
//业务参数
|
|
|
if (!empty($account_id)) {
|
|
|
$biz_content['account_id'] = $account_id;
|
|
|
} else {
|
|
|
$biz_content['merchant_id'] = $this->config['merchant_id'];
|
|
|
}
|
|
|
|
|
|
$result = $this->actionApi($common_data, $biz_content);
|
|
|
|
|
|
// 记录日志
|
|
|
$uid = defined('UID') ? UID : '';
|
|
|
platformLog([
|
|
|
'common_data' => $common_data,
|
|
|
'biz_content' => $biz_content,
|
|
|
], $result, 'fubei_get_account_entry_money_uid_' . $uid);
|
|
|
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 提现记录查询
|
|
|
* @param string $account_id 20 分账接收方id,与付呗商户号二选一 不传默认查商户提现记录
|
|
|
* @date 2022-03-18
|
|
|
*/
|
|
|
public function getAccountWithdrawRecord($account_id = '')
|
|
|
{
|
|
|
//公共参数
|
|
|
$common_data = [
|
|
|
'method' => 'openapi.agent.account.withdraw.record',
|
|
|
];
|
|
|
//业务参数
|
|
|
if (!empty($account_id)) {
|
|
|
$biz_content['account_id'] = $account_id;
|
|
|
} else {
|
|
|
$biz_content['merchant_id'] = $this->config['merchant_id'];
|
|
|
}
|
|
|
|
|
|
$result = $this->actionApi($common_data, $biz_content);
|
|
|
|
|
|
// 记录日志
|
|
|
$uid = defined('UID') ? UID : '';
|
|
|
platformLog([
|
|
|
'common_data' => $common_data,
|
|
|
'biz_content' => $biz_content,
|
|
|
], $result, 'fubei_get_account_withdraw_record_uid_' . $uid);
|
|
|
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
} |