Egame_buy.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace App\Models;
  3. use DB;
  4. class Egame_buy extends BaseModel {
  5. protected $table = "egame_buy";
  6. public $timestamps = false;
  7. function EgameBuyInfo($game, $list = 10, $fild = 'money_time', $order = 'desc', $where = '',$page=1){
  8. $model = $this->select($this->table . '.id', 'account_name', 'order_id', $this->table .'.game_name','info_name', 'info_no','sub_title', 'money_time', 'money', 'prize_money', 'get_money',$this->table . '.codes', $this->table . '.buy_status', $this->table.'.status', 'game_egame.codes as prize_code')
  9. ->leftjoin('game_egame', 'game_egame.identity', 'game_identity')
  10. ->where($this->table .'.game_name', $game)
  11. ->where($where)
  12. ->orderBy('money_time', $order);
  13. $model=$model->paginate($list);
  14. if (!$model) {
  15. return -5030000122; //没有数据
  16. }
  17. return $model->toArray();
  18. }
  19. //总投注
  20. function totalBet($where) {
  21. if (count($where)>0) {
  22. return $this->where($where)->sum('money');
  23. } else {
  24. return $this->sum('money');
  25. }
  26. }
  27. //总赢取
  28. function totalGetMoney($where) {
  29. if (count($where)>0) {
  30. $res = $this->where($where)->sum('get_money');
  31. } else {
  32. $res = $this->sum('money');
  33. }
  34. return -$res;
  35. }
  36. //获取投注信息
  37. function getInfoByID($id){
  38. $data=$this->where('id',$id)->first();
  39. if(!$data){
  40. return -5030000122; //没有数据
  41. }
  42. return $data->toArray();
  43. }
  44. }