FyGameBettingLog.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. namespace App\Models;
  3. use DB;
  4. class FyGameBettingLog extends BaseModel
  5. {
  6. protected $table = "fygame_betting_log";
  7. public $timestamps = false;
  8. protected $guarded = [];
  9. /**
  10. * 获取游戏投注记录
  11. * @param string $where
  12. * @param int $limit
  13. * @return mixed
  14. */
  15. public function getBettingList($where = '', $limit = 15, $orby = 'id', $sc = "desc"){
  16. $data = $this->orderBy('CreateAt', 'desc');
  17. if (is_array($where) && count($where)>0)
  18. {
  19. $data = $data->where($where);
  20. }
  21. $data = $data->paginate($limit);
  22. return $data->toArray();
  23. }
  24. public function getLastCreateAt()
  25. {
  26. $creatAt = $this->select('CreateAt')->orderBy('CreateAt','desc')->first();
  27. return $creatAt;
  28. }
  29. //数据插入
  30. public function addBettingInfo($orderid,$data)
  31. {
  32. return $this->updateOrCreate(['OrderID'=>$orderid],$data);
  33. }
  34. public function checkBetLog($orderId)
  35. {
  36. return $this->select('OrderID')->where('OrderID','=',$orderId)->first();
  37. }
  38. public function getTotal()
  39. {
  40. $data['count'] = $this->count(); //总条数
  41. $data['totalMoney'] = number_format($this->sum('BetAmount'),2); //总投注额
  42. $data['Money'] = number_format($this->sum('Money'),2); //总派彩(输赢)
  43. $data['effectMoney'] = number_format($this->where('Status','!=','None')->where('Status','!=','Revoke')->sum('BetAmount'),2); //总有效投注
  44. return $data;
  45. }
  46. //获取回水列表
  47. protected function getMoneyback($value = '', $type = 1, $limit = 10, $wheregame = '', $orwhere = '', $having = '')
  48. {
  49. DB::connection()->enableQueryLog();
  50. $data = $this->select('account_name','account_identity',"UserName as Accounts",DB::raw('sum("BetAmount") as betting_money'),DB::raw('sum("Money") as WinLoseAmount'),DB::raw('sum("BetAmount") as ValidAmount'),DB::raw('count("id") as bet_count'))->where('Status','!=','None')->where('Status','!=','Revoke')->groupBy('UserName','account_name','account_identity');
  51. if (!empty($having)) {
  52. foreach ($having as $v) {
  53. $data = $data->havingRaw($v);
  54. }
  55. }
  56. if (empty($value) || is_array($value)) {
  57. $where = $value;
  58. } else {
  59. $where[] = array( 'id', $value);
  60. }
  61. $where[] = array('type', 1);
  62. $data = $data->where($where);
  63. $data = $data->paginate($limit);
  64. if (!$data) {
  65. return -5030001202; //没有列表数据
  66. }
  67. return $data->toArray();
  68. }
  69. //反水更改狀
  70. protected function updateBackWater($name, $timearea)
  71. {
  72. $res = $this->where('account_name', $name)->where($timearea);
  73. $res = $res->update(['type' => '2']);
  74. if (!$res) {
  75. return -3012564406; //反水失败
  76. }
  77. return 1;
  78. }
  79. }