orderBy('id','desc'); if(is_array($where)&&count($where)>0){ $data = $data->where($where); } $data=$data->paginate($limit); return $data->toArray(); } /** * 插入数据 * @param $data * @return int */ public function insertRec($data) { $res = $this->insert($data); if(!$res) { return -1; } return 1; } /** * 更新转账状态 */ public function setTransferCredit($where='',$d) { $res = $this->where($where)->update($d); if(!$res) { return -1; } else { return 1; } } /** * 转账记录统计 * @param $where * @return array */ public function getSum($where) { $arr = array(); if(is_array($where)&&count($where)>0) { //查询总投注金额 $sum = $this->where($where)->sum('transfer_money'); //查询转账数 $count = $this->where($where)->count(); //查询转账人数 $person = $this->where($where)->select('local_user')->distinct()->get()->toArray(); //查询余额转入到游戏总金额 $in = $this->where($where)->where('transfer_type', 1)->sum('transfer_money'); //查询游戏转出到余额总金额 $out = $this->where($where)->where('transfer_type', 2)->sum('transfer_money'); } $arr['total'] = $sum; $arr['count'] = $count; $arr['person'] = count($person); $arr['in'] = $in; $arr['out'] = $out; return $arr; } /** * 转账成功记录统计 * @param $where * @return array */ public function getSuccessSum($where, $gametype) { $arr = array(); if(is_array($where)&&count($where)>0) { //成功转入笔数 $arr['suc_in_sum'] = $this->where($where)->where('transfer_type', 1)->where('type', 1)->where('game_type', $gametype)->count(); //成功转入总金额 $arr['suc_in_money'] = $this->where($where)->where('transfer_type', 1)->where('type', 1)->where('game_type', $gametype)->sum('transfer_money'); //成功转出笔数 $arr['suc_out_sum'] = $this->where($where)->where('transfer_type', 2)->where('type', 1)->where('game_type', $gametype)->count(); //成功转出总金额 $arr['suc_out_money'] = $this->where($where)->where('transfer_type', 2)->where('type', 1)->where('game_type', $gametype)->sum('transfer_money'); //成功总笔数 $arr['suc_sum'] = $this->where($where)->where('type', 1)->where('game_type', $gametype)->count(); //盈利金额 $arr['profit_money'] = $arr['suc_in_money'] - $arr['suc_out_money']; } return $arr; } }