jh-admin/addon/saas/api/controller/Withdraw.php

103 lines
3.6 KiB
PHP

<?php
namespace addon\saas\api\controller;
use addon\saas\model\ManageWithdraw;
use app\api\controller\BaseApi;
use app\model\member\Member;
class Withdraw extends BaseApi
{
/**
* 提现记录分页
* @return false|string
*/
public function page()
{
$token = $this->checkToken();
if ($token['code'] < 0) return $this->response($token);
$page = isset($this->params['page']) ? $this->params['page'] : 1;
$page_size = isset($this->params['page_size']) ? $this->params['page_size'] : PAGE_LIST_ROWS;
$status = isset($this->params['status']) ? $this->params['status'] : 0;// 当前状态 1待审核 2待转账 3已转账 -1 已拒绝
$condition = [
['member_id', '=', $this->member_id]
];
if (!empty($status)) {
$condition[] = ['status', '=', $status];
}
$order = 'id desc';
$withdraw_model = new ManageWithdraw();
$list = $withdraw_model->getWithdrawPageList($condition, $page, $page_size, $order);
foreach ($list['data']['list'] as $k => $v) {
$list['data']['list'][$k] = $withdraw_model->tran($v);
}
return $this->response($list);
}
/**
* 获取转账方式
* @return false|string
*/
public function transferType()
{
$token = $this->checkToken();
if ($token['code'] < 0) return $this->response($token);
$member_model = new Member();
$member_info = $member_model->getMemberInfo([['member_id', '=', $token['data']['member_id']]], 'site_id,wx_openid,weapp_openid');
$withdraw_config_model = new \addon\saas\model\Config();
$transfer_type_list = $withdraw_config_model->getTransferType($member_info['data']['site_id'], 'shop');
if (empty($member_info['data']['wx_openid']) && empty($member_info['data']['weapp_openid'])) {
unset($transfer_type_list['wechatpay']);
}
return $this->response($this->success($transfer_type_list));
}
/**
* 申请提现
* @return mixed
*/
public function apply()
{
$token = $this->checkToken();
if ($token['code'] < 0) return $this->response($token);
$apply_money = $this->params['apply_money'] ?? 0;
$transfer_type = $this->params['transfer_type'] ?? '';//提现方式
$realname = $this->params['realname'] ?? '';//真实姓名
$bank_name = $this->params['bank_name'] ?? '';//银行名称
$account_number = $this->params['account_number'] ?? '';//账号名称
$mobile = $this->params['mobile'] ?? '';//手机号
$app_type = $this->params['app_type'];
$withdraw_model = new ManageWithdraw();
$data = array(
'member_id' => $this->member_id,
'transfer_type' => $transfer_type,
'realname' => $realname,
'bank_name' => $bank_name,
'account_number' => $account_number,
'apply_money' => abs($apply_money),
'mobile' => $mobile,
'app_type' => $app_type
);
$result = $withdraw_model->apply($data, $this->site_id, 'shop');
return $this->response($result);
}
/**
* 提现详情
* @return mixed
*/
public function detail()
{
$token = $this->checkToken();
if ($token['code'] < 0) return $this->response($token);
$id = $this->params['id'] ?? 0;
$fenxiao_withdraw_model = new ManageWithdraw();
$params = array(
'id' => $id,
'site_id' => $this->site_id
);
$result = $fenxiao_withdraw_model->getWithdrawDetail($params);
return $this->response($result);
}
}