Kygame_transfer_record.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: ikeke
  5. * Date: 2018/12/4
  6. * Time: 18:24
  7. */
  8. namespace App\Models;
  9. class Kygame_transfer_record extends BaseModel
  10. {
  11. protected $table = "kygame_transfer_record";
  12. public $timestamps = false;
  13. /**
  14. * 获取所有游戏记录
  15. * @param string $where
  16. * @param int $limit
  17. * @return mixed
  18. */
  19. public function recordlist($where='',$limit=15)
  20. {
  21. $data = $this->orderBy('id','desc');
  22. if(is_array($where)&&count($where)>0){
  23. $data = $data->where($where);
  24. }
  25. $data=$data->paginate($limit);
  26. return $data->toArray();
  27. }
  28. /**
  29. * 更新转账状态
  30. */
  31. public function setTransferCredit($where='',$d)
  32. {
  33. $res = $this->where($where)->update($d);
  34. if(!$res)
  35. {
  36. return -1;
  37. }
  38. else
  39. {
  40. return 1;
  41. }
  42. }
  43. /**
  44. * 转账记录统计
  45. * @param $where
  46. * @return array
  47. */
  48. public function getSum($where)
  49. {
  50. $arr = array();
  51. if(is_array($where)&&count($where)>0)
  52. {
  53. //查询总投注金额
  54. $sum = $this->where($where)->sum('transfer_money');
  55. //查询转账数
  56. $count = $this->where($where)->count();
  57. //查询转账人数
  58. $person = $this->where($where)->select('local_user')->distinct()->get()->toArray();
  59. //查询余额转入到游戏总金额
  60. $in = $this->where($where)->where('transfer_type', 1)->sum('transfer_money');
  61. //查询游戏转出到余额总金额
  62. $out = $this->where($where)->where('transfer_type', 2)->sum('transfer_money');
  63. }
  64. $arr['total'] = $sum;
  65. $arr['count'] = $count;
  66. $arr['person'] = count($person);
  67. $arr['in'] = $in;
  68. $arr['out'] = $out;
  69. return $arr;
  70. }
  71. }