125 lines
4.6 KiB
PHP
125 lines
4.6 KiB
PHP
<?php
|
|
namespace app\agent\controller;
|
|
use \think\Controller;
|
|
use \think\Session;
|
|
use \think\Request;
|
|
use \think\Db;
|
|
use \think\paginator\driver\Bootstrap;
|
|
class Withdraw Extends Common{
|
|
// 提现查询
|
|
public function withdraw(){
|
|
// 登录用户信息
|
|
$user_info = Session::get('user_info');
|
|
$account_type = $user_info['account_type'];
|
|
$user_info = Db::connect('DB2')->name('user')->where('id',$user_info['id'])->find();
|
|
$user_info['account_type'] = $account_type;
|
|
if($user_info['account_type'] == 1){
|
|
return '非法请求';
|
|
}
|
|
|
|
|
|
// 用于分页和搜索查询的数据
|
|
$get = Request::instance()->get();
|
|
$query = http_build_query($get);
|
|
$this->assign('get',$get);
|
|
$this->assign('query',$query);
|
|
|
|
// 接收参数
|
|
$startDate = Request::instance()->get('startDate');
|
|
$endDate = Request::instance()->get('endDate');
|
|
$username = Request::instance()->get('username');
|
|
|
|
// 转换日期时间
|
|
if($startDate){
|
|
$startTime = strtotime($startDate);
|
|
}else{
|
|
$startTime = 0;
|
|
}
|
|
if($endDate){
|
|
$endTime = strtotime($endDate);
|
|
}else{
|
|
$endTime = time();
|
|
}
|
|
|
|
// 拼装搜索条件
|
|
$where = array();
|
|
$where['create_time'] = array('between',[$startTime,$endTime]);
|
|
if($username){
|
|
$user = Db::name('user')->where(['username'=>$username,'is_delete'=>0])->find();
|
|
if($user){
|
|
$where['user_id'] = $user['id'];
|
|
}else{
|
|
$where['user_id'] = 0;
|
|
}
|
|
}
|
|
if($user_info['agent_parent_id'] > 0){
|
|
$list = Db::name('user_withdraw')
|
|
->alias('r')
|
|
->field('r.*,u.username,u.nickname')
|
|
->join('cg_user u','r.user_id=u.id and (u.agent_parent_id_path like "%,'.$user_info['id'].',%" or r.user_id='.$user_info['id'].')')
|
|
->where($where)
|
|
->order('r.id desc')
|
|
->paginate(20,false,array('query'=>$get));
|
|
}else{
|
|
$list = Db::name('user_withdraw')
|
|
->alias('r')
|
|
->field('r.*,u.username,u.nickname')
|
|
->join('cg_user u','r.user_id=u.id and (u.agent_parent_id_path like "'.$user_info['id'].',%" or r.user_id='.$user_info['id'].')')
|
|
->where($where)
|
|
->order('r.id desc')
|
|
->paginate(20,false,array('query'=>$get));
|
|
}
|
|
|
|
// 提现状态
|
|
$status = [
|
|
'SUCCESS' => "提现成功",
|
|
'FAIL' => "提现失败",
|
|
'WAIT' => "等待审核",
|
|
'AGREE' => "已同意",
|
|
'DISAGREE' => "已拒绝",
|
|
'CANCEL' => "已取消",
|
|
];
|
|
foreach($list as $k => $v){
|
|
// 信息组装
|
|
$v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
|
|
// 提现状态
|
|
$v['status_msg'] = $status[$v['status']];
|
|
|
|
// 操作类型
|
|
if($v['operator_source'] == 1){
|
|
$v['operator_source_msg'] = '总台操作';
|
|
}else if($v['operator_source'] == 2){
|
|
$v['operator_source_msg'] = '代理操作';
|
|
}else{
|
|
$v['operator_source_msg'] = '';
|
|
}
|
|
// 数据格式转换
|
|
$v['amount'] = round($v['amount'],2);
|
|
$v['old_money'] = round($v['old_money'],2);
|
|
$v['new_money'] = round($v['new_money'],2);
|
|
$list[$k] = $v;
|
|
}
|
|
// pre($list);
|
|
// 汇总金额
|
|
if($user_info['agent_parent_id'] > 0){
|
|
$total = Db::name('user_withdraw')
|
|
->alias('r')
|
|
->field('sum(r.amount) as amount, sum(r.service_fee) as service_fee, sum(r.money) as money')
|
|
->join('cg_user u','r.user_id=u.id and (u.agent_parent_id_path like "%,'.$user_info['id'].',%" or r.user_id='.$user_info['id'].')')
|
|
->where($where)->find();
|
|
}else{
|
|
$total = Db::name('user_withdraw')
|
|
->alias('r')
|
|
->field('sum(r.amount) as amount, sum(r.service_fee) as service_fee, sum(r.money) as money')
|
|
->join('cg_user u','r.user_id=u.id and (u.agent_parent_id_path like "'.$user_info['id'].',%" or r.user_id='.$user_info['id'].')')
|
|
->where($where)
|
|
->find();
|
|
}
|
|
|
|
// 渲染参数和模板
|
|
$this->assign('list',$list);
|
|
$this->assign('user_info',$user_info);
|
|
$this->assign('total',$total);
|
|
return $this->fetch();
|
|
}
|
|
} |