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.

64 lines
1.6 KiB
PHP

<?php
namespace Mobile\Model;
use Think\Model;
/**
* 消费模型
* @author 鹿文学
*/
class SpendModel extends Model{
/* 自动验证规则 */
protected $_validate = array(
);
/* 自动完成规则 */
protected $_auto = array(
array('create_time', 'getCreateTime', self::MODEL_BOTH,'callback'),
);
/**
* 构造函数
* @param string $name 模型名称
* @param string $tablePrefix 表前缀
* @param mixed $connection 数据库连接信息
*/
public function __construct($name = '', $tablePrefix = '', $connection = '') {
/* 设置默认的表前缀 */
$this->tablePrefix ='tab_';
/* 执行构造方法 */
parent::__construct($name, $tablePrefix, $connection);
}
/**
* 消费列表
* @author 鹿文学
*/
public function lists($p=1) {
}
/**
* 获取小号列表通过游戏
* @param integer $game_id 游戏编号
* @return array
* @author 鹿文学
*/
public function get_small_list_by_game($game_id=0) {
if(is_numeric($game_id) && $game_id > 0) {
$user = D('User')->getLoginInfo();
$lists = $this->alias('s')->field('s.small_id,s.small_account,u.cumulative,sum(pay_amount) as pay_amount')
->join('tab_user as u on(u.id=s.small_id and u.lock_status=1 and puid='.$user['user_id'].') ')
->where(['s.game_id'=>$game_id,'s.pay_status'=>1])->group('s.small_id')->select();
file_put_contents(dirname(__FILE__) .'/spend_sql.txt',json_encode([$this->getLastSql()]));
return $lists;
} else {
return '';
}
}
}