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.
82 lines
2.9 KiB
PHTML
82 lines
2.9 KiB
PHTML
2 years ago
|
<?php
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | OneThink [ WE CAN DO IT JUST THINK IT ]
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
|
||
|
// +----------------------------------------------------------------------
|
||
|
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
|
||
|
// +----------------------------------------------------------------------
|
||
|
|
||
|
namespace Home\Model;
|
||
|
use Think\Model;
|
||
|
|
||
|
/**
|
||
|
* 分类模型
|
||
|
*/
|
||
|
class TestResourceModel extends Model{
|
||
|
/**
|
||
|
* 构造函数
|
||
|
* @param string $name 模型名称
|
||
|
* @param string $tablePrefix 表前缀
|
||
|
* @param mixed $connection 数据库连接信息
|
||
|
*/
|
||
|
public function __construct($name = '', $tablePrefix = '', $connection = '') {
|
||
|
/* 设置默认的表前缀 */
|
||
|
$this->tablePrefix ='tab_';
|
||
|
/* 执行构造方法 */
|
||
|
parent::__construct($name, $tablePrefix, $connection);
|
||
|
}
|
||
|
/**
|
||
|
* 获取统计 $map,$page,$row
|
||
|
*/
|
||
|
public function getResourceCout($map,$page,$row) {
|
||
|
$promote_id=session("promote_auth.pid");
|
||
|
//获取基本信息
|
||
|
|
||
|
$res = $this
|
||
|
->table("tab_test_resource as test")
|
||
|
->field("test.*,user.check_status")
|
||
|
->join('tab_user user on test.user_id=user.id','left')
|
||
|
->page($page,$row)
|
||
|
->order("create_time desc")
|
||
|
->where($map)
|
||
|
->group("user_id,game_id,server_id")
|
||
|
->select();
|
||
|
//获取统计
|
||
|
|
||
|
if(empty($res)){
|
||
|
return $res;
|
||
|
}
|
||
|
$rescount = $this->table("tab_test_resource as test")
|
||
|
->where($map)
|
||
|
->group("user_id,game_id,server_id")
|
||
|
->buildSql();
|
||
|
$rescount = $this->table($rescount.' a')->count();
|
||
|
//生成idstr
|
||
|
foreach ($res as $key => $value) {
|
||
|
$value['create_time'] = date("Y-m-d H:i:s", $value['create_time']);
|
||
|
//获取累计发放
|
||
|
$where = array(
|
||
|
"user_id"=>$value['user_id'],
|
||
|
"game_id"=>$value['game_id'],
|
||
|
"server_id"=>$value['server_id']
|
||
|
);
|
||
|
$where1 = array(
|
||
|
"apply_status"=>2,
|
||
|
);
|
||
|
//获取累计
|
||
|
$verify_resource = $this->field("IFNULL(sum(verify_resource),0) verify_resource_count,count(*) verify_count")->where(array_merge($where,$where1))->find();
|
||
|
//获取申请
|
||
|
$where2 = array(
|
||
|
"apply_status"=>0,
|
||
|
);
|
||
|
$apply_resource = $this->field("IFNULL(sum(apply_resource),0) apply_resource_count")->where(array_merge($where,$where2))->find();
|
||
|
$res[$key] = array_merge($value,$verify_resource,$apply_resource);
|
||
|
}
|
||
|
return array("list"=>$res,"count"=>$rescount);
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
}
|