Aggame_betting_ogrbv.php 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: ikeke
  5. * Date: 2018/12/6
  6. * Time: 19:38
  7. */
  8. namespace App\Models;
  9. use DB;
  10. class Aggame_betting_ogrbv extends BaseModel
  11. {
  12. protected $table = "aggame_betting_ogrbv";
  13. public $timestamps = false;
  14. /**
  15. * 获取所有游戏记录
  16. * @param string $where
  17. * @param int $limit
  18. * @return mixed
  19. */
  20. public function getlist($where='',$limit=15)
  21. {
  22. $data = $this->orderBy('id','desc');
  23. if(is_array($where)&&count($where)>0){
  24. $data = $data->where($where);
  25. }
  26. $data=$data->paginate($limit);
  27. return $data->toArray();
  28. }
  29. /**
  30. * 获取指定数据
  31. * @param string $where
  32. * @return mixed
  33. */
  34. public function getOneData($where='')
  35. {
  36. $data = $this->where('billNo', $where)->first();
  37. if (empty($data)&&count($data)<=0) {
  38. return -20000;
  39. }else{
  40. return $data->toArray();
  41. }
  42. }
  43. /**
  44. * 获取指定数据
  45. * @param string $where
  46. * @return mixed
  47. */
  48. public function getTradeNo($where='')
  49. {
  50. $data = $this->where('tradeNo', $where)->first();
  51. if (empty($data)&&count($data)<=0) {
  52. return -20000;
  53. }else{
  54. return $data->toArray();
  55. }
  56. }
  57. /**
  58. * 获取最新一条数据
  59. */
  60. public function getLastData()
  61. {
  62. $res = $this->orderBy('tradeNo','desc')->limit(1)->first()->toArray();
  63. return $res;
  64. }
  65. public function agInsertData($data)
  66. {
  67. if(isset($data['betTime']) && isset($data['recalcuTime']))
  68. {
  69. $bettime = str_replace('/','-', $data['betTime']);
  70. $recalcuTime = strtotime(str_replace('/','-', $data['recalcuTime']));
  71. $data['betTime'] = strtotime("$bettime + 12hour");
  72. $data['recalcuTime'] = strtotime("$recalcuTime + 12hour");
  73. $data['recalcurawTime'] = $recalcuTime; //美东时间
  74. $data['rawTime'] = strtotime($bettime); //美东时间
  75. }
  76. else if(isset($data['SceneStartTime']) && isset($data['SceneEndTime']))
  77. {
  78. $bettime = str_replace('/','-', $data['SceneStartTime']);
  79. $recalcuTime = strtotime(str_replace('/','-', $data['SceneEndTime']));
  80. $data['betAmount'] = $data['Cost'];
  81. $data['validBetAmount'] = $data['Cost'];
  82. $data['netAmount'] = $data['transferAmount'];
  83. $data['netAmountBase'] = $data['Earn'];
  84. $data['netAmountBonus'] = $data['Jackpotcomm'];
  85. $data['gameCode'] = $data['Roomid'].'-'.$data['Roombet'];
  86. $data['beforeCredit'] = $data['previousAmount'];
  87. $data['loginIP'] = $data['IP'];
  88. $data['gameType'] = 'HUNTER';
  89. unset($data['SceneStartTime']);
  90. unset($data['SceneEndTime']);
  91. unset($data['ID']);
  92. unset($data['creationTime']);
  93. unset($data['Cost']);
  94. unset($data['Earn']);
  95. unset($data['Jackpotcomm']);
  96. unset($data['type']);
  97. unset($data['sceneId']);
  98. unset($data['Roomid']);
  99. unset($data['Roombet']);
  100. unset($data['exchangeRate']);
  101. unset($data['previousAmount']);
  102. unset($data['transferAmount']);
  103. unset($data['currentAmount']);
  104. unset($data['IP']);
  105. $data['betTime'] = strtotime("$bettime + 12hour");
  106. $data['recalcuTime'] = strtotime("$recalcuTime + 12hour");
  107. $data['recalcurawTime'] = $recalcuTime; //美东时间
  108. $data['rawTime'] = strtotime($bettime); //美东时间
  109. }
  110. $res = $this->insert($data);
  111. if(!$res){
  112. return -3020011322;
  113. }
  114. return $res;
  115. }
  116. //获取回水列表
  117. protected function getMoneyback($value = '', $type = 1, $limit = 10, $wheregame = '', $orwhere = '', $having = '')
  118. {
  119. DB::connection()->enableQueryLog();
  120. $key = $this->getFeild($type);
  121. $data = $this->join ('account_detailed', 'aggame_betting_ogrbv.account_identity', '=', 'account_detailed.account_identity')->select('account_name','group_name','group_code','aggame_betting_ogrbv.account_identity','playerName',DB::raw('sum("betAmount") as betting_money'),DB::raw('sum("validBetAmount") as ValidAmount'),DB::raw('sum("netAmount") as WinLoseAmount'),DB::raw('count("billNo") as bet_count'))->where('type',1)->groupBy('playerName','account_name','group_name','group_code','aggame_betting_ogrbv.account_identity');
  122. if (!empty($having)) {
  123. foreach ($having as $v) {
  124. $data = $data->havingRaw($v);
  125. }
  126. }
  127. if (!empty($wheregame)) {
  128. $data->whereIn('Accounts', $wheregame);
  129. }
  130. if (empty($value) || is_array($value)) {
  131. $where = $value;
  132. } else {
  133. $where[] = array($key, '=', $value);
  134. }
  135. // $where[] = array('water_status', '=', 1);
  136. $where[] = array('type', '=', 1);
  137. // $where[] = array('ResultType', '!=', 4);
  138. $data = $data->where($where);
  139. $data = $data->paginate($limit);
  140. if (!$data) {
  141. return -5030001202; //没有列表数据
  142. }
  143. return $data->toArray();
  144. }
  145. //字段对应值
  146. private function getFeild($num)
  147. {
  148. $data = array(
  149. '1' => 'id',
  150. '2' => 'dataType',
  151. '3' => 'billNo',
  152. '4' => 'playerName',
  153. '5' => 'agentCode',
  154. '6' => 'gameCode',
  155. '7' => 'netAmount',
  156. '8' => 'betTime',
  157. '9' => 'gameType',
  158. '10' => 'betAmount',
  159. '11' => 'validBetAmount',
  160. '12' => 'flag',
  161. '13' => 'playType',
  162. '14' => 'currency',
  163. '15' => 'tableCode',
  164. '16' => 'loginIP',
  165. '17' => 'recalcuTime',
  166. '18' => 'platformType',
  167. '19' => 'remark',
  168. '20' => 'round',
  169. '21' => 'result',
  170. '22' => 'beforeCredit',
  171. '23' => 'deviceType',
  172. '24' => 'type',
  173. '25' => 'account_identity',
  174. '26' => 'account_name',
  175. '27' => 'count_status',
  176. );
  177. return $data[$num];
  178. }
  179. //反水更改狀
  180. protected function updateBackWater($name, $timearea)
  181. {
  182. $res = $this->where('account_name', $name)->where($timearea);
  183. $res = $res->update(['type' => '2']);
  184. if (!$res) {
  185. return -3012564406; //反水失败
  186. }
  187. return 1;
  188. }
  189. public function getSum($where)
  190. {
  191. $arr = array();
  192. $ba = 0;
  193. $wa= 0;
  194. $va = 0;
  195. $co = 0;
  196. if(is_array($where) && count($where)>0)
  197. {
  198. //查询总投注金额
  199. $ba = $this->where($where)->sum('betAmount');
  200. //查询总派彩金额
  201. $wa = $this->where($where)->sum('netAmount');
  202. //查询总有效投注金额
  203. $va = $this->where($where)->sum('validBetAmount');
  204. // $va = $this->where($where)->sum('Revenue');
  205. //查询总条数
  206. $co = $this->where($where)->count();
  207. }
  208. $arr['betAmount'] = ceil($ba) == $ba ? $ba.'.00' : round($ba ,2);
  209. $arr['netAmount'] = ceil($wa) == $wa ? $wa.'.00' : round($wa ,2);
  210. $arr['validBetAmount'] = ceil($va) == $va ? $va.'.00' : round($va ,2);
  211. //$arr['revenue'] = ceil($va) == $va ? $va.'.00' : round($va ,2);
  212. $arr['co'] = $co;
  213. return $arr;
  214. }
  215. }