| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- <?php
- /**
- * Created by PhpStorm.
- * User: ikeke
- * Date: 2018/12/4
- * Time: 18:24
- */
- namespace App\Models;
- class Oggame_transfer_record extends BaseModel
- {
- protected $table = "oggame_transfer_record";
- public $timestamps = false;
- /**
- * 获取所有游戏记录
- * @param string $where
- * @param int $limit
- * @return mixed
- */
- public function recordlist($where='',$limit=15)
- {
- $data = $this->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;
- }
- }
|