You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
368 lines
14 KiB
368 lines
14 KiB
10 months ago
|
<?php
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | 天诚科技 [ 刘海东 17600099397赋能开发者,助力企业发展 ]
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | Copyright (c) 2016~2020 https://www.tczxkj.com All rights reserved.
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | Licensed 该系统并不是自由软件,未经许可不能去掉相关版权
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | Author:甘肃天诚志信电子商务有限公司 刘海东 联系电话维系17600099397
|
||
|
// +----------------------------------------------------------------------
|
||
|
|
||
|
|
||
|
namespace app\admin\controller\finance;
|
||
|
|
||
|
use app\admin\controller\AuthController;
|
||
|
use service\FormBuilder as Form;
|
||
|
use app\admin\model\user\UserExtract as UserExtractModel;
|
||
|
use app\admin\model\special\UserWithdrawal as UserWithdrawalModel;
|
||
|
use service\JsonService;
|
||
|
use think\Request;
|
||
|
use think\Url;
|
||
|
use service\AlipayTradeWapService;
|
||
|
|
||
|
/**
|
||
|
* 用户提现管理
|
||
|
* Class UserExtract
|
||
|
*/
|
||
|
class UserExtract extends AuthController
|
||
|
{
|
||
|
/**用户提现
|
||
|
* @return mixed
|
||
|
*/
|
||
|
public function index()
|
||
|
{
|
||
|
return $this->fetch();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 用户提现记录
|
||
|
*/
|
||
|
public function get_user_extract()
|
||
|
{
|
||
|
$where = parent::getMore([
|
||
|
['start_time', ''],
|
||
|
['end_time', ''],
|
||
|
['status', ''],
|
||
|
['extract_type', ''],
|
||
|
['nireid', ''],
|
||
|
['page', 1],
|
||
|
['limit', 20],
|
||
|
], $this->request);
|
||
|
return JsonService::successlayui(UserExtractModel::get_user_extract_list($where));
|
||
|
}
|
||
|
/**讲师提现
|
||
|
* @return mixed
|
||
|
*/
|
||
|
public function merIndex()
|
||
|
{
|
||
|
return $this->fetch();
|
||
|
}
|
||
|
|
||
|
/**代理提现
|
||
|
* @return mixed
|
||
|
*/
|
||
|
public function ageindex()
|
||
|
{
|
||
|
return $this->fetch();
|
||
|
}
|
||
|
/**机构提现
|
||
|
* @return mixed
|
||
|
*/
|
||
|
public function insindex()
|
||
|
{
|
||
|
return $this->fetch();
|
||
|
}
|
||
|
public function get_mer_user_extract()
|
||
|
{
|
||
|
$where = parent::getMore([
|
||
|
['start_time', ''],
|
||
|
['end_time', ''],
|
||
|
['mer_id', 1],
|
||
|
['institution_type', 0],
|
||
|
['status', ''],
|
||
|
['extract_type', ''],
|
||
|
['nireid', ''],
|
||
|
['page', 1],
|
||
|
['limit', 20],
|
||
|
], $this->request);
|
||
|
return JsonService::successlayui(UserExtractModel::get_mer_user_extract_list($where));
|
||
|
}
|
||
|
public function get_ins_user_extract()
|
||
|
{
|
||
|
$where = parent::getMore([
|
||
|
['start_time', ''],
|
||
|
['end_time', ''],
|
||
|
['mer_id', 1],
|
||
|
['institution_type', 1],
|
||
|
['status', ''],
|
||
|
['extract_type', ''],
|
||
|
['nireid', ''],
|
||
|
['page', 1],
|
||
|
['limit', 20],
|
||
|
], $this->request);
|
||
|
return JsonService::successlayui(UserExtractModel::get_mer_user_extract_list($where));
|
||
|
}
|
||
|
public function get_agent_user_extract()
|
||
|
{
|
||
|
$where = parent::getMore([
|
||
|
['start_time', ''],
|
||
|
['end_time', ''],
|
||
|
['agent_id', 1],
|
||
|
['status', ''],
|
||
|
['extract_type', ''],
|
||
|
['nireid', ''],
|
||
|
['page', 1],
|
||
|
['limit', 20],
|
||
|
], $this->request);
|
||
|
return JsonService::successlayui(UserExtractModel::get_agent_user_extract_list($where));
|
||
|
}
|
||
|
|
||
|
public function edit($id)
|
||
|
{
|
||
|
if (!$id) return $this->failed('数据不存在');
|
||
|
$UserExtract = UserExtractModel::get($id);
|
||
|
if (!$UserExtract) return JsonService::fail('数据不存在!');
|
||
|
$f = array();
|
||
|
if ($UserExtract['extract_type'] == 'alipay') {
|
||
|
$f[] = Form::input('real_name', '姓名', $UserExtract['real_name']);
|
||
|
$f[] = Form::input('alipay_code', '支付宝账号', $UserExtract['alipay_code']);
|
||
|
} else if ($UserExtract['extract_type'] == 'bank') {
|
||
|
$f[] = Form::input('real_name', '姓名', $UserExtract['real_name']);
|
||
|
$f[] = Form::input('bank_code', '银行卡号', $UserExtract['bank_code']);
|
||
|
$f[] = Form::input('bank_address', '开户行', $UserExtract['bank_address']);
|
||
|
} else if ($UserExtract['extract_type'] == 'weixin') {
|
||
|
$f[] = Form::input('real_name', '姓名', $UserExtract['real_name']);
|
||
|
$f[] = Form::input('wechat', '微信号', $UserExtract['wechat']);
|
||
|
}
|
||
|
$f[] = Form::number('extract_price', '提现金额', $UserExtract['extract_price'])->precision(2);
|
||
|
$f[] = Form::input('mark', '备注', $UserExtract['mark'])->type('textarea');
|
||
|
$form = Form::make_post_form('编辑', $f, Url::build('update', array('id' => $id)), 2);
|
||
|
$this->assign(compact('form'));
|
||
|
return $this->fetch('public/form-builder');
|
||
|
|
||
|
}
|
||
|
|
||
|
public function update(Request $request, $id)
|
||
|
{
|
||
|
$UserExtract = UserExtractModel::get($id);
|
||
|
if (!$UserExtract) return JsonService::fail('数据不存在!');
|
||
|
if ($UserExtract['extract_type'] == 'alipay') {
|
||
|
$data = parent::postMore([
|
||
|
'real_name',
|
||
|
'mark',
|
||
|
'extract_price',
|
||
|
'alipay_code',
|
||
|
], $request);
|
||
|
if (!$data['real_name']) return JsonService::fail('请输入姓名');
|
||
|
if ($data['extract_price'] <= -1) return JsonService::fail('请输入提现金额');
|
||
|
if (!$data['alipay_code']) return JsonService::fail('请输入支付宝账号');
|
||
|
} else if ($UserExtract['extract_type'] == 'weixin') {
|
||
|
$data = parent::postMore([
|
||
|
'real_name',
|
||
|
'mark',
|
||
|
'extract_price',
|
||
|
'wechat',
|
||
|
], $request);
|
||
|
if (!$data['real_name']) return JsonService::fail('请输入姓名');
|
||
|
if ($data['extract_price'] <= -1) return JsonService::fail('请输入提现金额');
|
||
|
if (!$data['wechat']) return JsonService::fail('请输入wechat');
|
||
|
} else if ($UserExtract['extract_type'] == 'bank') {
|
||
|
$data = parent::postMore([
|
||
|
'real_name',
|
||
|
'extract_price',
|
||
|
'mark',
|
||
|
'bank_code',
|
||
|
'bank_address',
|
||
|
], $request);
|
||
|
if (!$data['real_name']) return JsonService::fail('请输入姓名');
|
||
|
if ($data['extract_price'] <= -1) return JsonService::fail('请输入提现金额');
|
||
|
if (!$data['bank_code']) return JsonService::fail('请输入银行卡号');
|
||
|
if (!$data['bank_address']) return JsonService::fail('请输入开户行');
|
||
|
} else if ($UserExtract['extract_type'] == 'yue') {
|
||
|
$data = parent::postMore([
|
||
|
'extract_price',
|
||
|
'mark',
|
||
|
], $request);
|
||
|
if ($data['extract_price'] <= -1) return JsonService::fail('请输入提现金额');
|
||
|
}
|
||
|
if (!UserExtractModel::edit($data, $id))
|
||
|
return JsonService::fail(UserExtractModel::getErrorInfo('修改失败'));
|
||
|
else
|
||
|
return JsonService::successful('修改成功!');
|
||
|
}
|
||
|
|
||
|
/**提现回退
|
||
|
* @param Request $request
|
||
|
* @param $id
|
||
|
* @throws \think\exception\DbException
|
||
|
*/
|
||
|
public function fail($id)
|
||
|
{
|
||
|
$fail_msg = parent::postMore([
|
||
|
['message', ''],
|
||
|
]);
|
||
|
if (!UserExtractModel::be(['id' => $id, 'status' => 0])) return JsonService::fail('操作记录不存在或状态错误!');
|
||
|
$extract = UserExtractModel::get($id);
|
||
|
if (!$extract) return JsonService::fail('操作记录不存!');
|
||
|
if ($extract->status == 1) return JsonService::fail('已经提现,错误操作');
|
||
|
if ($extract->status == -1) return JsonService::fail('您的提现申请已被拒绝,请勿重复操作!');
|
||
|
UserExtractModel::beginTrans();
|
||
|
$res = UserExtractModel::changeFail($id, $fail_msg['message'], $extract);
|
||
|
if ($res) {
|
||
|
UserExtractModel::commitTrans();
|
||
|
return JsonService::successful('操作成功!');
|
||
|
} else {
|
||
|
UserExtractModel::rollbackTrans();
|
||
|
return JsonService::fail('操作失败!');
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/**提现通过
|
||
|
* @param $id
|
||
|
* @throws \think\exception\DbException
|
||
|
*/
|
||
|
public function succ($id)
|
||
|
{
|
||
|
if (!UserExtractModel::be(['id' => $id, 'status' => 0])) return JsonService::fail('操作记录不存在或状态错误!');
|
||
|
$extract = UserExtractModel::get($id);
|
||
|
if (!$extract) return JsonService::fail('操作记录不存!');
|
||
|
if ($extract->status == 1) return JsonService::fail('您已提现,请勿重复提现!');
|
||
|
if ($extract->status == -1) return JsonService::fail('您的提现申请已被拒绝!');
|
||
|
// 支付宝自动提现
|
||
|
if($extract['extract_type'] == "alipay"){
|
||
|
$Withdrawal = AlipayTradeWapService::init()->WithdrawalQuery($extract);
|
||
|
if($Withdrawal['code'] == 10000){
|
||
|
UserExtractModel::beginTrans();
|
||
|
$res = UserExtractModel::changeMerSuccess($id, $extract);
|
||
|
UserWithdrawalModel::insert([
|
||
|
'order_id' => $Withdrawal['order_id'],
|
||
|
'out_biz_no' => $Withdrawal['out_biz_no'],
|
||
|
'pay_fund_order_id' => $Withdrawal['pay_fund_order_id'],
|
||
|
'trans_date' => $Withdrawal['trans_date'],
|
||
|
'status' => $Withdrawal['status'],
|
||
|
'e_id' => $extract['id']
|
||
|
]);
|
||
|
if ($res) {
|
||
|
UserExtractModel::commitTrans();
|
||
|
return JsonService::successful('操作成功!');
|
||
|
} else {
|
||
|
UserExtractModel::rollbackTrans();
|
||
|
return JsonService::fail('操作失败!');
|
||
|
}
|
||
|
}else{
|
||
|
return JsonService::fail($Withdrawal['sub_msg']);
|
||
|
}
|
||
|
}else{
|
||
|
UserExtractModel::beginTrans();
|
||
|
$res = UserExtractModel::changeMerSuccess($id, $extract);
|
||
|
if ($res) {
|
||
|
UserExtractModel::commitTrans();
|
||
|
return JsonService::successful('操作成功!');
|
||
|
} else {
|
||
|
UserExtractModel::rollbackTrans();
|
||
|
return JsonService::fail('操作失败!');
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
/**提现回退
|
||
|
* @param Request $request
|
||
|
* @param $id
|
||
|
* @throws \think\exception\DbException
|
||
|
*/
|
||
|
public function merFail($id)
|
||
|
{
|
||
|
$fail_msg = parent::postMore([
|
||
|
['message', ''],
|
||
|
]);
|
||
|
if (!UserExtractModel::be(['id' => $id, 'status' => 0])) return JsonService::fail('操作记录不存在或状态错误!');
|
||
|
$extract = UserExtractModel::get($id);
|
||
|
if (!$extract) return JsonService::fail('操作记录不存!');
|
||
|
if ($extract->status == 1) return JsonService::fail('已经提现,错误操作');
|
||
|
if ($extract->status == -1) return JsonService::fail('您的提现申请已被拒绝,请勿重复操作!');
|
||
|
UserExtractModel::beginTrans();
|
||
|
$res = UserExtractModel::changeMerFail($id, $fail_msg['message'], $extract);
|
||
|
if ($res) {
|
||
|
UserExtractModel::commitTrans();
|
||
|
return JsonService::successful('操作成功!');
|
||
|
} else {
|
||
|
UserExtractModel::rollbackTrans();
|
||
|
return JsonService::fail('操作失败!');
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/**提现通过
|
||
|
* @param $id
|
||
|
* @throws \think\exception\DbException
|
||
|
*/
|
||
|
public function merSucc($id)
|
||
|
{
|
||
|
if (!UserExtractModel::be(['id' => $id, 'status' => 0])) return JsonService::fail('操作记录不存在或状态错误!');
|
||
|
$extract = UserExtractModel::get($id);
|
||
|
if (!$extract) return JsonService::fail('操作记录不存!');
|
||
|
if ($extract->status == 1) return JsonService::fail('您已提现,请勿重复提现!');
|
||
|
if ($extract->status == -1) return JsonService::fail('您的提现申请已被拒绝!');
|
||
|
// 支付宝自动提现
|
||
|
if($extract['extract_type'] == "alipay"){
|
||
|
$Withdrawal = AlipayTradeWapService::init()->WithdrawalQuery($extract);
|
||
|
if($Withdrawal['code'] == 10000){
|
||
|
UserExtractModel::beginTrans();
|
||
|
$res = UserExtractModel::changeMerSuccess($id, $extract);
|
||
|
UserWithdrawalModel::insert([
|
||
|
'order_id' => $Withdrawal['order_id'],
|
||
|
'out_biz_no' => $Withdrawal['out_biz_no'],
|
||
|
'pay_fund_order_id' => $Withdrawal['pay_fund_order_id'],
|
||
|
'trans_date' => $Withdrawal['trans_date'],
|
||
|
'status' => $Withdrawal['status'],
|
||
|
'e_id' => $extract['id']
|
||
|
]);
|
||
|
if ($res) {
|
||
|
UserExtractModel::commitTrans();
|
||
|
return JsonService::successful('操作成功!');
|
||
|
} else {
|
||
|
UserExtractModel::rollbackTrans();
|
||
|
return JsonService::fail('操作失败!');
|
||
|
}
|
||
|
}else{
|
||
|
return JsonService::fail($Withdrawal['sub_msg']);
|
||
|
}
|
||
|
}else{
|
||
|
UserExtractModel::beginTrans();
|
||
|
$res = UserExtractModel::changeMerSuccess($id, $extract);
|
||
|
if ($res) {
|
||
|
UserExtractModel::commitTrans();
|
||
|
return JsonService::successful('操作成功!');
|
||
|
} else {
|
||
|
UserExtractModel::rollbackTrans();
|
||
|
return JsonService::fail('操作失败!');
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
/**提现备注
|
||
|
* @param $id
|
||
|
* @throws \think\exception\DbException
|
||
|
*/
|
||
|
public function remarks($id)
|
||
|
{
|
||
|
$fail_msg = parent::postMore([
|
||
|
['message', ''],
|
||
|
]);
|
||
|
$extract = UserExtractModel::get($id);
|
||
|
if (!$extract) return JsonService::fail('操作记录不存!');
|
||
|
$res = UserExtractModel::where('id', $id)->update(['mark' => $fail_msg['message']]);
|
||
|
if ($res) {
|
||
|
return JsonService::successful('操作成功!');
|
||
|
} else {
|
||
|
return JsonService::fail('操作失败!');
|
||
|
}
|
||
|
}
|
||
|
}
|