You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

259 lines
9.8 KiB
PHTML

5 years ago
<?php
namespace Admin\Controller;
use User\Api\UserApi as UserApi;
/**
* 后台首页控制器
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
class DepositController extends ThinkController {
const model_name = 'Deposit';
public function lists(){
if(isset($_REQUEST['user_account'])){
$map['user_account']=array('like','%'.trim($_REQUEST['user_account']).'%');
unset($_REQUEST['user_account']);
}
if(isset($_REQUEST['pay_order_number'])){
$map['pay_order_number']=array('like','%'.trim($_REQUEST['pay_order_number']).'%');
unset($_REQUEST['pay_order_number']);
}
if(isset($_REQUEST['pay_ip'])){
$map['pay_ip']=array('like','%'.trim($_REQUEST['pay_ip']).'%');
unset($_REQUEST['pay_ip']);
}
$promoteRoot = getPowerPromoteIds();
if ($promoteRoot) {
$map['promote_id'] =array('in',$promoteRoot);
}
5 years ago
if(!isset($_REQUEST['promote_id'])){
}else if(isset($_REQUEST['promote_id']) && $_REQUEST['promote_id']==0){
$map['promote_id']=array('elt',0);
unset($_REQUEST['promote_id']);
unset($_REQUEST['promote_name']);
}elseif(isset($_REQUEST['promote_name'])&&$_REQUEST['promote_id']==-1){
$map['promote_id']=get_promote_id($_REQUEST['promote_name']);
unset($_REQUEST['promote_id']);
unset($_REQUEST['promote_name']);
}else{
$map['promote_id']=$_REQUEST['promote_id'];
unset($_REQUEST['promote_id']);
unset($_REQUEST['promote_name']);
}
if(isset($_REQUEST['time-start'])&&isset($_REQUEST['time-end'])){
$map['create_time'] =array('BETWEEN',array(strtotime($_REQUEST['time-start']),strtotime($_REQUEST['time-end'])+24*60*60-1));
unset($_REQUEST['time-start']);unset($_REQUEST['time-end']);
}elseif(isset($_REQUEST['time-start'])){
$map['create_time'] = ['GT',strtotime(I('time-start'))];
unset($_REQUEST['time-start']);
}elseif(isset($_REQUEST['time-end'])){
$map['create_time'] = ['LT',strtotime(I('time-end'))+86399];
unset($_REQUEST['time-end']);
}
if(isset($_REQUEST['start'])&&isset($_REQUEST['end'])){
$map['create_time'] =array('BETWEEN',array(strtotime($_REQUEST['start']),strtotime($_REQUEST['end'])+24*60*60-1));
unset($_REQUEST['start']);unset($_REQUEST['end']);
}elseif(isset($_REQUEST['start'])){
$map['create_time'] = ['GT',strtotime(I('start'))];
unset($_REQUEST['start']);
}elseif(isset($_REQUEST['end'])){
$map['create_time'] = ['LT',strtotime(I('end'))+86399];
unset($_REQUEST['end']);
}
if(isset($_REQUEST['pay_way'])) {
if ($_REQUEST['pay_way'] == "2") {
$map['pay_way'] = ['in', '2,3,4'];
} else {
$map['pay_way'] = $_REQUEST['pay_way'];
}
unset($_REQUEST['pay_way']);
}
5 years ago
if(isset($_REQUEST['pay_status'])){
$map['pay_status']=$_REQUEST['pay_status'];
unset($_REQUEST['pay_status']);
}
if($_REQUEST['data_order']!=''){
$data_order=reset(explode(',',$_REQUEST['data_order']));
$data_order_type=end(explode(',',$_REQUEST['data_order']));
$this->assign('userarpu_order',$data_order);
$this->assign('userarpu_order_type',$data_order_type);
$sort = $data_order==3?'desc':'asc';
$map['order'] = $data_order_type.' '.$sort;
}
$map1=$map;
$map1['pay_status']=1;
$total=null_to_0(D(self::model_name)->where($map1)->sum('pay_amount'));
$ttotal=null_to_0(D(self::model_name)->where('create_time'.total(1))->where(array('pay_status'=>1))->sum('pay_amount'));
$ytotal=null_to_0(D(self::model_name)->where('create_time'.total(5))->where(array('pay_status'=>1))->sum('pay_amount'));
$this->assign('total',$total);
$this->assign('ttotal',$ttotal);
$this->assign('ytotal',$ytotal);
$this->m_title = '平台币充值';
$this->assign('commonset',M('Kuaijieicon')->where(['url'=>'Deposit/lists','status'=>1])->find());
parent::lists(self::model_name,$_GET["p"],$map);
}
public function send_lists(){
if(IS_POST){
$type = $_REQUEST['type'];
$firstpay = A('Send','Event');
\Think\Log::actionLog('Deposit/send_lists','Deposit',1);
switch ($type) {
case 1:
$firstpay->add1();
break;
case 2:
$firstpay->add2();
break;
case 3:
$firstpay->add3();
break;
}
}
else{
$this->meta_title ="后台发放(玩家)";
$this->m_title = '平台币发放(玩家)';
$this->assign('commonset',M('Kuaijieicon')->where(['url'=>'Deposit/send_lists','status'=>1])->find());
$this->display();
}
}
/**
* 后台充值平台币(玩家)
*/
public function lists_sen(){
5 years ago
if(isset($_REQUEST['user_account'])){
$map['user_account']=array('like','%'.trim($_REQUEST['user_account']).'%');
unset($_REQUEST['user_account']);
}
if(isset($_REQUEST['time-start'])&&isset($_REQUEST['time-end'])){
$map['create_time'] =array('BETWEEN',array(strtotime($_REQUEST['time-start']),strtotime($_REQUEST['time-end'])+24*60*60-1));
unset($_REQUEST['time-start']);unset($_REQUEST['time-end']);
}elseif(isset($_REQUEST['time-start'])){
$map['create_time'] = ['GT',strtotime(I('time-start'))];
unset($_REQUEST['time-start']);
}elseif(isset($_REQUEST['time-end'])){
$map['create_time'] = ['LT',strtotime(I('time-end'))+86399];
unset($_REQUEST['time-end']);
}
if(isset($_REQUEST['start'])&&isset($_REQUEST['end'])){
$map['create_time'] =array('BETWEEN',array(strtotime($_REQUEST['start']),strtotime($_REQUEST['end'])+24*60*60-1));
unset($_REQUEST['start']);unset($_REQUEST['end']);
}elseif(isset($_REQUEST['start'])){
$map['create_time'] = ['GT',strtotime(I('start'))];
unset($_REQUEST['start']);
}elseif(isset($_REQUEST['end'])){
$map['create_time'] = ['LT',strtotime(I('end'))+86399];
unset($_REQUEST['end']);
}
$map['op_account']=session('user_auth')['username'];
5 years ago
if(isset($_REQUEST['op_account'])){
if($_REQUEST['op_account']=='全部'){
unset($_REQUEST['op_account']);
}else{
$map['op_account']=$_REQUEST['op_account'];
unset($_REQUEST['op_account']);
}
}
if(isset($_REQUEST['op_id'])){
$map['op_id']=$_REQUEST['op_id'];
unset($_REQUEST['op_id']);
}
if(is_numeric($_REQUEST['status']) && ($_REQUEST['status']==0 || $_REQUEST['status']==1)) {
$map['status'] = $_REQUEST['status'];
unset($_REQUEST['status']);
}
$map1=$map;
$map1['status']=1;
$total=null_to_0(M('provide_user','tab_')->where($map1)->sum('amount'));
$ttotal=null_to_0(M('provide_user','tab_')->where('create_time'.total(1))->where(array('status'=>1))->sum('amount'));
$ytotal=null_to_0(M('provide_user','tab_')->where('create_time'.total(5))->where(array('status'=>1))->sum('amount'));
// $this->assign('dtotal',$dtotal);
$this->assign('total',$total);
$this->assign('ttotal',$ttotal);
$this->assign('ytotal',$ytotal);
$model = array(
'm_name' => 'provide_user',
'map' => $map,
'fields' => 'tab_provide_user.*,u.puid',
'title' => "后台发放(玩家)",
'join' => 'left join tab_user as u on u.id = tab_provide_user.user_id',
'template_list' =>'lists_sen',
'order'=>'tab_provide_user.id desc',
);
$user = A('User','Event');
$this->m_title = '平台币发放(玩家)';
$this->assign('commonset',M('Kuaijieicon')->where(['url'=>'Deposit/send_lists','status'=>1])->find());
$user->user_join_($model,$_GET['p']);
}
/**
* 批量充值
* @param $ids
*/
public function batch($ids=''){
if ( empty($ids) ) {
$this->error('请选择要操作的数据!');
}
$list=M("provide_user","tab_");
$map['id']=array("in",$ids);
$map['status']=0;
$pro=$list->where($map)->select();
$userModel = M("User","tab_");
for ($i=0; $i <count($pro) ; $i++) {
$maps['id']=$pro[$i]['user_id'];
$puid = $userModel->field('puid')->where($maps)->find();
if(!empty($puid) && $puid['puid']>0) {
$maps['id']=$puid['puid'];
}
$user=$userModel->where($maps)->setInc("balance",$pro[$i]['amount']);
$list->where($map)->setField("status",1);
}
\Think\Log::actionLog('Deposit/batch','Deposit',1);
$this->success("充值成功",U("lists_sen",array('type'=>2)));
}
public function delprovide($ids=null){
if ( empty($ids) ) {
$this->error('请选择要操作的数据!');
}
$list=M("provide_user","tab_");
$map['id']=array("in",$ids);
$map['status']=0;
$delete=$list->where($map)->delete();
if($delete){
\Think\Log::actionLog('Deposit/batch','Deposit',1);
$this->success("批量删除成功!",U("lists_sen",array('type'=>2)));
}else{
$this->error("批量删除失败!",U("lists_sen",array('type'=>2)));
}
}
}