SportsNoteList.php 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Jonlin
  5. * Date: 2019/4/9
  6. * Time: 9:18
  7. */
  8. namespace App\Models;
  9. use Illuminate\Support\Facades\DB;
  10. use App\Models\MoneyBuyMatch;
  11. class SportsNoteList extends BaseModel
  12. {
  13. protected $table = "money_buy_simplex";
  14. public $timestamps = false;
  15. public function matchdatas()
  16. {
  17. return $this->hasMany(MoneyBuyMatch::class, 'order_id', 'order_id');
  18. }
  19. function getinfo($list = 10, $page, $where = '', $type)
  20. {
  21. $data = $this
  22. ->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')
  23. ->join('st_' . $type . '_competition', 'st_' . $type . '_competition.id', '=', 'money_buy_simplex.match_id')
  24. //->join('money_buy_match','money_buy_match.order_id','=','money_buy_simplex.order_id')
  25. ->join('st_' . $type . '_league', 'money_buy_simplex.lg_id', '=', 'st_' . $type . '_league.id')
  26. ->select('money_buy_simplex.id', 'money_buy_simplex.account_name', 'money_buy_simplex.is_champion', 'money_buy_simplex.account_identity', 'money_buy_simplex.order_id', 'money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.status', 'money_buy_simplex.money_time', 'money_buy_simplex.settle_status', 'money_buy_simplex.gain_money', 'money_buy_simplex.game_code', 'money_buy_simplex.match_id', 'money_buy_simplex.game_status', 'st_' . $type . '_competition.home_team', 'st_' . $type . '_competition.guest_team', 'st_' . $type . '_competition.match_date', 'st_' . $type . '_competition.match_time', 'st_' . $type . '_competition.lg_id', 'st_' . $type . '_competition.status as match_status', 'money_details.money_cash', 'money_buy_simplex.batch_id', 'st_' . $type . '_league.name_chinese', 'st_' . $type . '_league.last_time')
  27. ->whereIn('money_buy_simplex.roll_ratify',array(0,1))
  28. ->where($where)
  29. //->distinct('money_buy_match.order_id')
  30. ->orderby('money_buy_simplex.money_time', 'desc')
  31. ->paginate($list);
  32. if (!$data < 0) {
  33. return -2021052003; //
  34. }
  35. //反水
  36. $water_return_money = \App\Models\Money_details::where('trade_type', '7')->get();
  37. //注单作废
  38. $invalid_money = \App\Models\Money_details::where('trade_type', '3')->get();
  39. //订单投注的玩法
  40. $content = \App\Models\MoneyBuyMatch::where('bet_type', '1')->get();
  41. for ($d = 0; $d < count($content); $d++) {
  42. if ($content[$d]->result == 0) {
  43. $content[$d]->result = '未处理';
  44. }
  45. if ($content[$d]->result == 1) {
  46. $content[$d]->result = '赢';
  47. }
  48. if ($content[$d]->result == -1) {
  49. $content[$d]->result = '输';
  50. }
  51. if ($content[$d]->result == 2) {
  52. $content[$d]->result = '平';
  53. }
  54. if ($content[$d]->result == 3) {
  55. $content[$d]->result = '赢半平半';
  56. }
  57. if ($content[$d]->result == 4) {
  58. $content[$d]->result = '输半平半';
  59. }
  60. }
  61. //玩法
  62. $result = \App\Models\Matchcode::where('game_code', $type)->get();
  63. //$result = \App\Model\Matchcode::get();
  64. for ($i = 0; $i < count($data); $i++) {
  65. // if($data[$i]->status==1 && $data[$i]->game_status==0){
  66. // $data[$i]->order_status = '投注'.'<br>;<a class="layui-btn layui-btn-sm invalid" lay-event="detail" pid="id" uri="/admin/SoccerNoteList/invalid/?id=" href="javascript:invalid(\'/admin/SoccerNoteList/invalid/?id='.$data[$i]->id.'\');"> 作废 </a>';
  67. // }else
  68. if ($data[$i]->status == 1 && $data[$i]->game_status == 0) {
  69. $data[$i]->order_status = '投注';
  70. } else if ($data[$i]->status == 2) {
  71. $data[$i]->order_status = '作废';//.'<br><a class="layui-btn layui-btn-sm audit" lay-event="detail" pid="id" uri="" href="javascript:void(0)" style="background-color: grey;"> 已作废 </a>';
  72. } else if ($data[$i]->status == 3) {
  73. $data[$i]->order_status = '撤单';//.'<br><a class="layui-btn layui-btn-sm audit" lay-event="detail" pid="id" uri="" href="javascript:void(0)" style="background-color: grey;"> 已撤单 </a>';
  74. }
  75. if ($data[$i]->settle_status == 1) {
  76. $data[$i]->settle_status = '未结算';
  77. } else if ($data[$i]->settle_status == 2) {
  78. $data[$i]->settle_status = '已结算';
  79. }
  80. if ($data[$i]->game_status == 0) {
  81. $data[$i]->game_status = '未处理';
  82. } else {
  83. $data[$i]->game_status = '已处理';
  84. }
  85. $data[$i]->league = $data[$i]->name_chinese;
  86. if ($data[$i]->is_champion == 0) {
  87. if ($data[$i]->game_code == 'zq') {
  88. $data[$i]->match_id_order = '<a href="/admin/sportsfoot/outcome?home_team=' . $data[$i]->match_id . '">' . $data[$i]->match_id . '</a> (<span>' . $data[$i]->account_name . '</span>)<br>' . $data[$i]->order_id;
  89. }
  90. if ($data[$i]->game_code == 'lq') {
  91. $data[$i]->match_id_order = '<a href="/admin/Sportsbk/outcome?home_team=' . $data[$i]->match_id . '">' . $data[$i]->match_id . '</a> (<span>' . $data[$i]->account_name . '</span>)<br>' . $data[$i]->order_id;
  92. }
  93. if ($data[$i]->game_code == 'wq') {
  94. $data[$i]->match_id_order = '<a href="/admin/Sportswq/outcome?home_team=' . $data[$i]->match_id . '">' . $data[$i]->match_id . '</a> (<span>' . $data[$i]->account_name . '</span>)<br>' . $data[$i]->order_id;
  95. }
  96. if ($data[$i]->game_code == 'bq') {
  97. $data[$i]->match_id_order = '<a href="/admin/Sportsbq/outcome?home_team=' . $data[$i]->match_id . '">' . $data[$i]->match_id . '</a> (<span>' . $data[$i]->account_name . '</span>)<br>' . $data[$i]->order_id;
  98. }
  99. $data[$i]->home_guest = $data[$i]->home_team . ' VS ' . $data[$i]->guest_team;
  100. $data[$i]->time = '开赛:' . $data[$i]->match_date . ' ' . $data[$i]->match_time;
  101. } else {
  102. $data[$i]->lg_id_order = $data[$i]->match_id . '(<span>' . $data[$i]->account_name . '</span>)<br>' . $data[$i]->order_id;
  103. $data[$i]->home_guest = '冠军联赛投注';
  104. $data[$i]->time = '结束:' . $data[$i]->last_time;
  105. }
  106. $data[$i]->money_match_time = '下注:' . $data[$i]->money_time . $data[$i]->time;
  107. //反水
  108. $data[$i]->water_return = -1;
  109. for ($a = 0; $a < count($water_return_money); $a++) {
  110. if ($data[$i]->order_id == $water_return_money[$a]->trade_id) {
  111. if ($data[$i]->status == 2 || $data[$i]->status == 3) {
  112. $data[$i]->water_return = 0;
  113. } else {
  114. $data[$i]->water_return = $water_return_money[$a]->money;
  115. }
  116. //用户投注后账户金额
  117. $data[$i]->frozen_cash = $water_return_money[$a]->money_cash;
  118. }
  119. }
  120. if ($data[$i]->water_return == -1) {
  121. $data[$i]->water_return = 0;
  122. //用户投注后账户金额
  123. $data[$i]->frozen_cash = $data[$i]->money_cash;
  124. }
  125. //此时结果金额
  126. $data[$i]->result = $data[$i]->water_return + $data[$i]->gain_money;
  127. //用户投注前账户金额
  128. $data[$i]->available_cash = $data[$i]->money_cash + $data[$i]->money;
  129. //投注前后账户金额
  130. $data[$i]->account_money = $data[$i]->available_cash . '<br><span>' . $data[$i]->money . '</span><br>' . $data[$i]->frozen_cash;
  131. if ($data[$i]->status == 2 || $data[$i]->status == 3) {
  132. for ($b = 0; $b < count($invalid_money); $b++) {
  133. if ($data[$i]->order_id == $invalid_money[$b]->trade_id) {
  134. $data[$i]->available_cash = $invalid_money[$b]->money_cash;
  135. $data[$i]->account_money = $data[$i]->available_cash;
  136. }
  137. }
  138. }
  139. $data[$i]->str = 0;
  140. for ($b = 0; $b < count($content); $b++) {
  141. $data[$i]->str1 = 0;
  142. $data[$i]->team = '';
  143. if (!empty($content[$b]->odds_code)) {
  144. if (!empty(stristr($content[$b]->odds_code, 'home'))) {
  145. $data[$i]->team = $data[$i]->home_team;
  146. }
  147. if (!empty(stristr($content[$b]->odds_code, 'guest'))) {
  148. $data[$i]->team = $data[$i]->guest_team;
  149. }
  150. if ($content[$b]->p_code == 'half_full') {
  151. $string = str_replace('home', $data[$i]->home_team, $content[$b]->odds_code);
  152. $string = str_replace('guest', $data[$i]->guest_team, $string);
  153. $string = str_replace('dogfall', '和局', $string);
  154. $string = explode('_', $string);
  155. $data[$i]->team = $string['2'] . '/' . $string['3'];
  156. }
  157. }
  158. //处理普通赛事玩法详情
  159. if ($data[$i]->match_id == $content[$b]->match_id && $data[$i]->batch_id == $content[$b]->batch_id && $data[$i]->is_champion == 0) {
  160. if ($content[$b]->p_code == 'first_last_ball' || $content[$b]->p_code == 'half_full' || $content[$b]->p_code == 'capot' || $content[$b]->p_code == 'two_sides' || $content[$b]->p_code == 'total_goal') {
  161. $content[$b]->condition = '';
  162. }
  163. $data[$i]->game_status = $data[$i]->game_status;
  164. //投注详情
  165. if (!empty($data[$i]->match_time)) {
  166. $data[$i]->content1 = '[' . $data[$i]->match_time . ']';
  167. //$data[$i]->match_time = $data[$i]->match_time;
  168. } else {
  169. if (!empty($data[$i]->last_time)) {
  170. $datetime = explode(' ', $data[$i]->last_time);
  171. //$data[$i]->match_time = $datetime[1];
  172. $data[$i]->content1 = '[' . $datetime[1] . ']';
  173. }
  174. }
  175. for ($c = 0; $c < count($result); $c++) {
  176. if ($content[$b]->odds_code == $result[$c]->odds_code) {
  177. $data[$i]->str1 = 1;
  178. if ($content[$b]->result == '未处理') {
  179. $data[$i]->content = $data[$i]->content . $result[$c]->odds_name . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br>';
  180. } else {
  181. $data[$i]->content = $data[$i]->content . $result[$c]->odds_name . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br><span>' . $content[$b]->result . '</span>(' . $content[$b]->matchresult . ')<br>';
  182. }
  183. }
  184. }
  185. if ($data[$i]->str1 == 0) {
  186. if ($content[$b]->result == '未处理') {
  187. $data[$i]->content = $data[$i]->content . $content[$b]->odds_code . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br>';
  188. } else {
  189. $data[$i]->content = $data[$i]->content . $content[$b]->odds_code . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br><span>' . $content[$b]->result . '</span>(' . $content[$b]->matchresult . ')<br>';
  190. }
  191. }
  192. }
  193. //处理冠军联赛玩法详情
  194. if ($data[$i]->match_id == $content[$b]->lg_id && $data[$i]->batch_id == $content[$b]->batch_id && $data[$i]->is_champion == 1) {
  195. $content[$b]->condition = '';
  196. if ($content[$b]->p_code == 'first_last_ball' || $content[$b]->p_code == 'half_full' || $content[$b]->p_code == 'capot' || $content[$b]->p_code == 'two_sides' || $content[$b]->p_code == 'total_goal') {
  197. $content[$b]->condition = '';
  198. }
  199. $data[$i]->game_status = $data[$i]->game_status;
  200. /*
  201. //投注详情
  202. if(!empty($data[$i]->match_time)){
  203. $data[$i]->content1 = '['.$data[$i]->match_time.']';
  204. //$data[$i]->match_time = $data[$i]->match_time;
  205. }
  206. else{
  207. if(!empty($data[$i]->last_time)){
  208. $datetime = explode(' ',$data[$i]->last_time);
  209. //$data[$i]->match_time = $datetime[1];
  210. $data[$i]->content1 = '['.$datetime[1].']';
  211. }
  212. }
  213. */
  214. /*
  215. for($c=0;$c<count($result);$c++){
  216. if($content[$b]->odds_code == $result[$c]->odds_code){
  217. $data[$i]->str1 = 1;
  218. if($content[$b]->result=='未处理'){
  219. $data[$i]->content = $content[$b]->home_team.'<br>'.$data[$i]->content.$result[$c]->odds_name.'<br>'.$content[$b]->condition.' '.$data[$i]->team.'@'.$content[$b]->odds.' ¥'.$content[$b]->bet_money.'<br>';
  220. }else{
  221. $data[$i]->content = $content[$b]->home_team.'<br>'.$data[$i]->content.$result[$c]->odds_name.'<br>'.$content[$b]->condition.' '.$data[$i]->team.'@'.$content[$b]->odds.' ¥'.$content[$b]->bet_money.'<br><span>'.$content[$b]->result.'</span>('.$content[$b]->matchresult.')<br>';
  222. }
  223. }
  224. }
  225. */
  226. if ($data[$i]->str1 == 0) {
  227. if ($content[$b]->result == '未处理') {
  228. $data[$i]->content = $content[$b]->home_team . '<br>' . $data[$i]->content . $content[$b]->odds_code . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br>';
  229. } else {
  230. $data[$i]->content = $content[$b]->home_team . '<br>' . $data[$i]->content . $content[$b]->odds_code . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br><span>' . $content[$b]->result . '</span>(' . $content[$b]->matchresult . ')<br>';
  231. }
  232. }
  233. }
  234. }
  235. // if($data[$i]->status == 1){
  236. // if($data[$i]->match_status == 0 || $data[$i]->match_status == 1){
  237. // $data[$i]->game_status = $data[$i]->settle_status.'<br><a class="layui-btn layui-btn-sm audit" lay-event="detail" pid="id" uri="" href="javascript:void(0)" style="background-color: grey;"> 结算 </a>';
  238. // }
  239. // if($data[$i]->match_status == 2 || $data[$i]->match_status == 3 || $data[$i]->match_status == 5){
  240. // if($data[$i]->settle_status == '已结算'){
  241. // $data[$i]->game_status = $data[$i]->settle_status.'<br><a class="layui-btn layui-btn-sm resettlement" lay-event="detail" pid="id" uri="/admin/SoccerNoteList/resettlement/?id=" href="javascript:resettlement(\'/admin/SoccerNoteList/resettlement/?id='.$data[$i]->id.'\');"> 重新结算 </a>';
  242. // }else{
  243. // $data[$i]->game_status = $data[$i]->settle_status.'<br><a class="layui-btn layui-btn-sm settlement" lay-event="detail" pid="id" uri="/admin/SoccerNoteList/settlement/?id=" href="javascript:settlement(\'/admin/SoccerNoteList/settlement/?id='.$data[$i]->id.'\');"> 结算 </a>';
  244. // }
  245. // }
  246. // }else{
  247. // $data[$i]->game_status = $data[$i]->settle_status.'<br><a class="layui-btn layui-btn-sm audit" lay-event="detail" pid="id" uri="" href="javascript:void(0)" style="background-color: grey;"> 结2算 </a>';
  248. // }
  249. $data[$i]->content = $data[$i]->content1 . $data[$i]->content;
  250. }
  251. return $data->toArray();
  252. }
  253. //投注金额汇总统计
  254. function MoneyCount($where = '', $type)
  255. {
  256. $data = array();
  257. // $data['all_money'] = $this->sum('money');
  258. // $data['all_prize_money'] = $this->sum('prize_money');
  259. // $data['alraedy_prize_money'] = $this->where('settle_status','2')->sum('gain_money');
  260. $data['all_money'] = 0;
  261. $data['all_prize_money'] = 0;
  262. $data['alraedy_prize_money'] = 0;
  263. $all_money = $this->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')->join('st_' . $type . '_competition', 'st_' . $type . '_competition.id', '=', 'money_buy_simplex.match_id')->join('st_' . $type . '_league', 'st_' . $type . '_competition.lg_id', '=', 'st_' . $type . '_league.id')->select('money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.gain_money')->whereIn('money_buy_simplex.roll_ratify',array(0,1))->where('money_buy_simplex.status', '1')->get();
  264. for ($a = 0; $a < count($all_money); $a++) {
  265. $data['all_money'] = $data['all_money'] + $all_money[$a]->money;
  266. }
  267. $all_prize_money = $this->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')->join('st_' . $type . '_competition', 'st_' . $type . '_competition.id', '=', 'money_buy_simplex.match_id')->join('st_' . $type . '_league', 'st_' . $type . '_competition.lg_id', '=', 'st_' . $type . '_league.id')->select('money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.gain_money')->whereIn('money_buy_simplex.roll_ratify',array(0,1))->where('money_buy_simplex.status', '1')->get();
  268. for ($a = 0; $a < count($all_prize_money); $a++) {
  269. $data['all_prize_money'] = $data['all_money'] + $all_prize_money[$a]->prize_money;
  270. }
  271. $alraedy_prize_money = $this->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')->join('st_' . $type . '_competition', 'st_' . $type . '_competition.id', '=', 'money_buy_simplex.match_id')->join('st_' . $type . '_league', 'st_' . $type . '_competition.lg_id', '=', 'st_' . $type . '_league.id')->select('money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.gain_money')->where('money_buy_simplex.settle_status', '2')->whereIn('money_buy_simplex.roll_ratify',array(0,1))->where('money_buy_simplex.status', '1')->get();
  272. for ($a = 0; $a < count($alraedy_prize_money); $a++) {
  273. $data['alraedy_prize_money'] = $data['all_money'] + $alraedy_prize_money[$a]->gain_money;
  274. }
  275. if (!empty($where) && is_array($where)) {
  276. $data['all_money'] = 0;
  277. $data['all_prize_money'] = 0;
  278. $data['alraedy_prize_money'] = 0;
  279. //$data['all_money'] = $this->where($where)->sum('money');
  280. // $data['all_prize_money'] = $this->where($where)->sum('prize_money');
  281. // $data['alraedy_prize_money'] = $this->where($where)->where('settle_status','2')->sum('gain_money');
  282. $all_money = $this->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')->join('st_zq_competition', 'st_zq_competition.id', '=', 'money_buy_simplex.match_id')->join('st_zq_league', 'st_zq_competition.lg_id', '=', 'st_zq_league.id')->select('money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.gain_money')->whereIn('money_buy_simplex.roll_ratify',array(0,1))->where($where)->where('money_buy_simplex.status', '1')->get();
  283. for ($a = 0; $a < count($all_money); $a++) {
  284. $data['all_money'] = $data['all_money'] + $all_money[$a]->money;
  285. }
  286. $all_prize_money = $this->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')->join('st_' . $type . '_competition', 'st_' . $type . '_competition.id', '=', 'money_buy_simplex.match_id')->join('st_' . $type . '_league', 'st_' . $type . '_competition.lg_id', '=', 'st_' . $type . '_league.id')->select('money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.gain_money')->whereIn('money_buy_simplex.roll_ratify',array(0,1))->where($where)->where('money_buy_simplex.status', '1')->get();
  287. for ($a = 0; $a < count($all_prize_money); $a++) {
  288. $data['all_prize_money'] = $data['all_prize_money'] + $all_prize_money[$a]->prize_money;
  289. }
  290. $alraedy_prize_money = $this->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')->join('st_' . $type . '_competition', 'st_' . $type . '_competition.id', '=', 'money_buy_simplex.match_id')->join('st_' . $type . '_league', 'st_' . $type . '_competition.lg_id', '=', 'st_' . $type . '_league.id')->select('money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.gain_money')->whereIn('money_buy_simplex.roll_ratify',array(0,1))->where('money_buy_simplex.settle_status', '2')->where($where)->where('money_buy_simplex.status', '1')->get();
  291. for ($a = 0; $a < count($alraedy_prize_money); $a++) {
  292. $data['alraedy_prize_money'] = $data['alraedy_prize_money'] + $alraedy_prize_money[$a]->gain_money;
  293. }
  294. }
  295. return $data;
  296. }
  297. //修改赛事下的所有单式下注 3199308
  298. function updatesimplex($ssid, $code)
  299. {
  300. $newapp = new \App\Models\MoneyBuyMatch();
  301. $data = $newapp->allsimplexorder($ssid, $code);
  302. if ($data) {
  303. for ($i = 0; $i < count($data); $i++) {
  304. $the = array(
  305. 'status' => 2,
  306. 'game_status' => 3,
  307. 'game_code' => $code,
  308. );
  309. $res = $this->where('order_id', $data[$i]['order_id'])->update($the);
  310. }
  311. if ($res < 0) {
  312. return -7012000302; //操作失败
  313. }
  314. return $res;
  315. } else {
  316. return -111;
  317. }
  318. }
  319. function info($list = 10, $page, $where = '', $type)
  320. {
  321. $data = $this
  322. ->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')
  323. ->join('st_' . $type . '_competition', 'st_' . $type . '_competition.id', '=', 'money_buy_simplex.match_id')
  324. // ->join('st_'.$type.'_league','st_'.$type.'_competition.lg_id','=','st_'.$type.'_league.id')
  325. ->join('st_' . $type . '_league', 'money_buy_simplex.lg_id', '=', 'st_' . $type . '_league.id')
  326. ->select('money_buy_simplex.id', 'money_buy_simplex.account_name', 'money_buy_simplex.is_champion', 'money_buy_simplex.account_identity', 'money_buy_simplex.order_id', 'money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.status', 'money_buy_simplex.money_time', 'money_buy_simplex.settle_status', 'money_buy_simplex.gain_money', 'money_buy_simplex.game_code', 'money_buy_simplex.match_id', 'money_buy_simplex.game_status', 'st_' . $type . '_competition.home_team', 'st_' . $type . '_competition.guest_team', 'st_' . $type . '_competition.match_date', 'st_' . $type . '_competition.match_time', 'st_' . $type . '_competition.lg_id', 'st_' . $type . '_competition.status as match_status', 'money_details.money_cash', 'money_buy_simplex.batch_id', 'st_' . $type . '_league.name_chinese', 'st_' . $type . '_league.last_time')
  327. ->whereIn('money_buy_simplex.roll_ratify',array(0,1))
  328. ->where($where)
  329. ->orderby('money_buy_simplex.money_time', 'desc')
  330. ->paginate($list);
  331. if (!$data < 0) {
  332. return -2021052003; //
  333. }
  334. //反水
  335. $water_return_money = \App\Models\Money_details::where('trade_type', '7')->get();
  336. //注单作废
  337. $invalid_money = \App\Models\Money_details::where('trade_type', '3')->get();
  338. //订单投注的玩法
  339. $content = \App\Models\MoneyBuyMatch::where('bet_type', '1')->get();
  340. for ($d = 0; $d < count($content); $d++) {
  341. if ($content[$d]->result == 0) {
  342. $content[$d]->result = '未处理';
  343. }
  344. if ($content[$d]->result == 1) {
  345. $content[$d]->result = '赢';
  346. }
  347. if ($content[$d]->result == -1) {
  348. $content[$d]->result = '输';
  349. }
  350. if ($content[$d]->result == 2) {
  351. $content[$d]->result = '平';
  352. }
  353. if ($content[$d]->result == 3) {
  354. $content[$d]->result = '赢半平半';
  355. }
  356. if ($content[$d]->result == 4) {
  357. $content[$d]->result = '输半平半';
  358. }
  359. }
  360. //玩法
  361. $result = \App\Models\Matchcode::where('game_code', $type)->get();
  362. //$result = \App\Model\Matchcode::get();
  363. for ($i = 0; $i < count($data); $i++) {
  364. if ($data[$i]->status == 1 && $data[$i]->game_status == 0) {
  365. $data[$i]->order_status = '投注' . '<br><a class="layui-btn layui-btn-sm invalid" lay-event="detail" pid="id" uri="/admin/SoccerNoteList/invalid/?id=" href="javascript:invalid(\'/admin/SoccerNoteList/invalid/?id=' . $data[$i]->id . '\');"> 作废 </a>';
  366. } else if ($data[$i]->status == 1 && $data[$i]->game_status != 0) {
  367. $data[$i]->order_status = '投注';
  368. } else if ($data[$i]->status == 2) {
  369. $data[$i]->order_status = '作废';
  370. } else if ($data[$i]->status == 3) {
  371. $data[$i]->order_status = '撤单';
  372. }
  373. // if($data[$i]->settle_status==1){
  374. // $data[$i]->settle_status = '未结算';
  375. // }else if($data[$i]->settle_status==2){
  376. // $data[$i]->settle_status = '已结算';
  377. // }
  378. if ($data[$i]->game_status == 0) {
  379. $data[$i]->game_status = '未处理';
  380. } else {
  381. $data[$i]->game_status = '已处理';
  382. }
  383. $data[$i]->league = $data[$i]->name_chinese;
  384. if ($data[$i]->is_champion == 0) {
  385. if ($data[$i]->game_code == 'zq') {
  386. $data[$i]->match_id_order = '<a href="/admin/sportsfoot/outcome?home_team=' . $data[$i]->match_id . '">' . $data[$i]->match_id . '</a> (<span>' . $data[$i]->account_name . '</span>)<br>' . $data[$i]->order_id;
  387. }
  388. if ($data[$i]->game_code == 'lq') {
  389. $data[$i]->match_id_order = '<a href="/admin/Sportsbk/outcome?home_team=' . $data[$i]->match_id . '">' . $data[$i]->match_id . '</a> (<span>' . $data[$i]->account_name . '</span>)<br>' . $data[$i]->order_id;
  390. }
  391. if ($data[$i]->game_code == 'wq') {
  392. $data[$i]->match_id_order = '<a href="/admin/Sportswq/outcome?home_team=' . $data[$i]->match_id . '">' . $data[$i]->match_id . '</a> (<span>' . $data[$i]->account_name . '</span>)<br>' . $data[$i]->order_id;
  393. }
  394. if ($data[$i]->game_code == 'bq') {
  395. $data[$i]->match_id_order = '<a href="/admin/Sportsbq/outcome?home_team=' . $data[$i]->match_id . '">' . $data[$i]->match_id . '</a> (<span>' . $data[$i]->account_name . '</span>)<br>' . $data[$i]->order_id;
  396. }
  397. $data[$i]->home_guest = $data[$i]->home_team . ' VS ' . $data[$i]->guest_team;
  398. $data[$i]->time = '开赛:' . $data[$i]->match_date . ' ' . $data[$i]->match_time;
  399. } else {
  400. $data[$i]->lg_id_order = $data[$i]->match_id . '(<span>' . $data[$i]->account_name . '</span>)<br>' . $data[$i]->order_id;
  401. $data[$i]->home_guest = '冠军联赛投注';
  402. $data[$i]->time = '结束:' . $data[$i]->last_time;
  403. }
  404. $data[$i]->money_match_time = '下注:' . $data[$i]->money_time . $data[$i]->time;
  405. /*
  406. $data[$i]->home_guest = $data[$i]->home_team.' VS '.$data[$i]->guest_team;
  407. $data[$i]->time = '开赛:'.$data[$i]->match_date.' '.$data[$i]->match_time;
  408. $data[$i]->money_match_time = '下注:'.$data[$i]->money_time.'<br>'.$data[$i]->time;
  409. */
  410. //反水
  411. $data[$i]->water_return = -1;
  412. for ($a = 0; $a < count($water_return_money); $a++) {
  413. if ($data[$i]->order_id == $water_return_money[$a]->trade_id) {
  414. if ($data[$i]->status == 2 || $data[$i]->status == 3) {
  415. $data[$i]->water_return = 0;
  416. } else {
  417. $data[$i]->water_return = $water_return_money[$a]->money;
  418. }
  419. //用户投注后账户金额
  420. $data[$i]->frozen_cash = $water_return_money[$a]->money_cash;
  421. }
  422. }
  423. if ($data[$i]->water_return == -1) {
  424. $data[$i]->water_return = 0;
  425. //用户投注后账户金额
  426. $data[$i]->frozen_cash = $data[$i]->money_cash;
  427. }
  428. //此时结果金额
  429. $data[$i]->result = $data[$i]->water_return + $data[$i]->gain_money;
  430. //用户投注前账户金额
  431. $data[$i]->available_cash = $data[$i]->money_cash + $data[$i]->money;
  432. //投注前后账户金额
  433. $data[$i]->account_money = $data[$i]->available_cash . '<br><span>' . $data[$i]->money . '</span><br>' . $data[$i]->frozen_cash;
  434. if ($data[$i]->status == 2 || $data[$i]->status == 3) {
  435. for ($b = 0; $b < count($invalid_money); $b++) {
  436. if ($data[$i]->order_id == $invalid_money[$b]->trade_id) {
  437. $data[$i]->available_cash = $invalid_money[$b]->money_cash;
  438. $data[$i]->account_money = $data[$i]->available_cash;
  439. }
  440. }
  441. }
  442. $data[$i]->str = 0;
  443. for ($b = 0; $b < count($content); $b++) {
  444. $data[$i]->str1 = 0;
  445. $data[$i]->team = '';
  446. if (!empty($content[$b]->odds_code)) {
  447. if (!empty(stristr($content[$b]->odds_code, 'home'))) {
  448. $data[$i]->team = $data[$i]->home_team;
  449. }
  450. if (!empty(stristr($content[$b]->odds_code, 'guest'))) {
  451. $data[$i]->team = $data[$i]->guest_team;
  452. }
  453. if ($content[$b]->p_code == 'half_full') {
  454. $string = str_replace('home', $data[$i]->home_team, $content[$b]->odds_code);
  455. $string = str_replace('guest', $data[$i]->guest_team, $string);
  456. $string = str_replace('dogfall', '和局', $string);
  457. $string = explode('_', $string);
  458. $data[$i]->team = $string['2'] . '/' . $string['3'];
  459. }
  460. }
  461. //处理普通赛事
  462. if ($data[$i]->match_id == $content[$b]->match_id && $data[$i]->batch_id == $content[$b]->batch_id && $data[$i]->is_champion == 0) {
  463. if ($content[$b]->p_code == 'first_last_ball' || $content[$b]->p_code == 'half_full' || $content[$b]->p_code == 'capot' || $content[$b]->p_code == 'two_sides' || $content[$b]->p_code == 'total_goal') {
  464. $content[$b]->condition = '';
  465. }
  466. $data[$i]->game_status = $data[$i]->game_status;
  467. //投注详情
  468. if (!empty($data[$i]->match_time)) {
  469. $data[$i]->content1 = '[' . $data[$i]->match_time . ']';
  470. //$data[$i]->match_time = $data[$i]->match_time;
  471. } else {
  472. if (!empty($data[$i]->last_time)) {
  473. $datetime = explode(' ', $data[$i]->last_time);
  474. //$data[$i]->match_time = $datetime[1];
  475. $data[$i]->content1 = '[' . $datetime[1] . ']';
  476. }
  477. }
  478. for ($c = 0; $c < count($result); $c++) {
  479. if ($content[$b]->odds_code == $result[$c]->odds_code) {
  480. $data[$i]->str1 = 1;
  481. if ($content[$b]->result == '未处理') {
  482. $data[$i]->content = $data[$i]->content . $result[$c]->odds_name . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br>';
  483. } else {
  484. $data[$i]->content = $data[$i]->content . $result[$c]->odds_name . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br><span>' . $content[$b]->result . '</span>(' . $content[$b]->matchresult . ')<br>';
  485. }
  486. }
  487. }
  488. if ($data[$i]->str1 == 0) {
  489. if ($content[$b]->result == '未处理') {
  490. $data[$i]->content = $data[$i]->content . $content[$b]->odds_code . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br>';
  491. } else {
  492. $data[$i]->content = $data[$i]->content . $content[$b]->odds_code . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br><span>' . $content[$b]->result . '</span>(' . $content[$b]->matchresult . ')<br>';
  493. }
  494. }
  495. }
  496. //处理冠军联赛玩法详情
  497. if ($data[$i]->match_id == $content[$b]->lg_id && $data[$i]->batch_id == $content[$b]->batch_id && $data[$i]->is_champion == 1) {
  498. $content[$b]->condition = '';
  499. if ($content[$b]->p_code == 'first_last_ball' || $content[$b]->p_code == 'half_full' || $content[$b]->p_code == 'capot' || $content[$b]->p_code == 'two_sides' || $content[$b]->p_code == 'total_goal') {
  500. $content[$b]->condition = '';
  501. }
  502. $data[$i]->game_status = $data[$i]->game_status;
  503. /*
  504. //投注详情
  505. if(!empty($data[$i]->match_time)){
  506. $data[$i]->content1 = '['.$data[$i]->match_time.']';
  507. //$data[$i]->match_time = $data[$i]->match_time;
  508. }
  509. else{
  510. if(!empty($data[$i]->last_time)){
  511. $datetime = explode(' ',$data[$i]->last_time);
  512. //$data[$i]->match_time = $datetime[1];
  513. $data[$i]->content1 = '['.$datetime[1].']';
  514. }
  515. }
  516. */
  517. /*
  518. for($c=0;$c<count($result);$c++){
  519. if($content[$b]->odds_code == $result[$c]->odds_code){
  520. $data[$i]->str1 = 1;
  521. if($content[$b]->result=='未处理'){
  522. $data[$i]->content = $data[$i]->content.$result[$c]->odds_name.'<br>'.$content[$b]->condition.' '.$data[$i]->team.'@'.$content[$b]->odds.' ¥'.$content[$b]->bet_money.'<br>';
  523. }else{
  524. $data[$i]->content = $data[$i]->content.$result[$c]->odds_name.'<br>'.$content[$b]->condition.' '.$data[$i]->team.'@'.$content[$b]->odds.' ¥'.$content[$b]->bet_money.'<br><span>'.$content[$b]->result.'</span>('.$content[$b]->matchresult.')<br>';
  525. }
  526. }
  527. }
  528. */
  529. if ($data[$i]->str1 == 0) {
  530. if ($content[$b]->result == '未处理') {
  531. $data[$i]->content = $content[$b]->home_team . '<br>' . $data[$i]->content . $content[$b]->odds_code . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br>';
  532. } else {
  533. $data[$i]->content = $content[$b]->home_team . '<br>' . $data[$i]->content . $content[$b]->odds_code . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br><span>' . $content[$b]->result . '</span>(' . $content[$b]->matchresult . ')<br>';
  534. }
  535. }
  536. }
  537. }
  538. $data[$i]->game_status = $data[$i]->settle_status;
  539. $data[$i]->content = $data[$i]->content1 . $data[$i]->content;
  540. }
  541. return $data->toArray();
  542. }
  543. //查询单订单是否存在
  544. function onlyorder($orderid)
  545. {
  546. $order = $this->where('order_id', $orderid)->count();
  547. return $order;
  548. }
  549. //查询单订单是否存在
  550. function getorder($orderid)
  551. {
  552. $order = $this->with("matchdatas")->where('order_id', $orderid)->first();
  553. return $order;
  554. }
  555. function checkinfo($list = 10, $page, $where = '', $type)
  556. {
  557. $data = $this
  558. ->join('money_details', 'money_details.info_identity', '=', 'money_buy_simplex.info_identity')
  559. ->join('st_' . $type . '_competition', 'st_' . $type . '_competition.id', '=', 'money_buy_simplex.match_id')
  560. //->join('money_buy_match','money_buy_match.order_id','=','money_buy_simplex.order_id')
  561. ->join('st_' . $type . '_league', 'money_buy_simplex.lg_id', '=', 'st_' . $type . '_league.id')
  562. ->select('money_buy_simplex.id', 'money_buy_simplex.account_name', 'money_buy_simplex.is_champion', 'money_buy_simplex.account_identity', 'money_buy_simplex.order_id', 'money_buy_simplex.money', 'money_buy_simplex.prize_money', 'money_buy_simplex.status', 'money_buy_simplex.money_time', 'money_buy_simplex.settle_status', 'money_buy_simplex.gain_money', 'money_buy_simplex.game_code', 'money_buy_simplex.match_id', 'money_buy_simplex.game_status', 'money_buy_simplex.roll_ratify', 'st_' . $type . '_competition.home_team', 'st_' . $type . '_competition.guest_team', 'st_' . $type . '_competition.match_date', 'st_' . $type . '_competition.match_time', 'st_' . $type . '_competition.lg_id', 'st_' . $type . '_competition.status as match_status', 'money_details.money_cash', 'money_buy_simplex.batch_id', 'st_' . $type . '_league.name_chinese', 'st_' . $type . '_league.last_time')
  563. ->where($where)
  564. //->distinct('money_buy_match.order_id')
  565. ->orderby('money_buy_simplex.money_time', 'desc')
  566. ->paginate($list);
  567. if (!$data < 0) {
  568. return -2021052003; //
  569. }
  570. //反水
  571. $water_return_money = \App\Models\Money_details::where('trade_type', '7')->get();
  572. //注单作废
  573. $invalid_money = \App\Models\Money_details::where('trade_type', '3')->get();
  574. //订单投注的玩法
  575. $content = \App\Models\MoneyBuyMatch::where('bet_type', '1')->get();
  576. for ($d = 0; $d < count($content); $d++) {
  577. if ($content[$d]->result == 0) {
  578. $content[$d]->result = '未处理';
  579. }
  580. if ($content[$d]->result == 1) {
  581. $content[$d]->result = '赢';
  582. }
  583. if ($content[$d]->result == -1) {
  584. $content[$d]->result = '输';
  585. }
  586. if ($content[$d]->result == 2) {
  587. $content[$d]->result = '平';
  588. }
  589. if ($content[$d]->result == 3) {
  590. $content[$d]->result = '赢半平半';
  591. }
  592. if ($content[$d]->result == 4) {
  593. $content[$d]->result = '输半平半';
  594. }
  595. }
  596. //玩法
  597. $result = \App\Models\Matchcode::where('game_code', $type)->get();
  598. //$result = \App\Model\Matchcode::get();
  599. for ($i = 0; $i < count($data); $i++) {
  600. // if($data[$i]->status==1 && $data[$i]->game_status==0){
  601. // $data[$i]->order_status = '投注'.'<br>;<a class="layui-btn layui-btn-sm invalid" lay-event="detail" pid="id" uri="/admin/SoccerNoteList/invalid/?id=" href="javascript:invalid(\'/admin/SoccerNoteList/invalid/?id='.$data[$i]->id.'\');"> 作废 </a>';
  602. // }else
  603. if ($data[$i]->status == 1 && $data[$i]->game_status == 0) {
  604. $data[$i]->order_status = '投注';
  605. } else if ($data[$i]->status == 2) {
  606. $data[$i]->order_status = '作废';//.'<br><a class="layui-btn layui-btn-sm audit" lay-event="detail" pid="id" uri="" href="javascript:void(0)" style="background-color: grey;"> 已作废 </a>';
  607. } else if ($data[$i]->status == 3) {
  608. $data[$i]->order_status = '撤单';//.'<br><a class="layui-btn layui-btn-sm audit" lay-event="detail" pid="id" uri="" href="javascript:void(0)" style="background-color: grey;"> 已撤单 </a>';
  609. }
  610. if ($data[$i]->settle_status == 1) {
  611. $data[$i]->settle_status = '未结算';
  612. } else if ($data[$i]->settle_status == 2) {
  613. $data[$i]->settle_status = '已结算';
  614. }
  615. if ($data[$i]->game_status == 0) {
  616. $data[$i]->game_status = '未处理';
  617. } else {
  618. $data[$i]->game_status = '已处理';
  619. }
  620. if ($data[$i]->roll_ratify == 2) {
  621. $data[$i]->roll_ratify = '<a class="layui-btn layui-btn-sm lay-btn-diy" lay-event="detail" pid="id" uri="/admin/CheckRolling/check/?id=" href="javascript:check(\'/admin/CheckRolling/check/?id=' . $data[$i]->id . '\');"> 通过 </a><br><a class="layui-btn layui-btn-sm invalid" lay-event="detail" pid="id" style="margin-top:5px;" uri="/admin/CheckRolling/nocheck/?id=" href="javascript:nocheck(\'/admin/CheckRolling/nocheck/?id=' . $data[$i]->id . '\');"> 拒绝 </a>';
  622. }
  623. if ($data[$i]->game_code == 'zq') {
  624. $data[$i]->match_id_order = '<a href="/admin/sportsfoot/outcome?home_team=' . $data[$i]->match_id . '">' . $data[$i]->match_id . '</a> (<span>' . $data[$i]->account_name . '</span>)<br>' . $data[$i]->order_id;
  625. }
  626. if ($data[$i]->game_code == 'lq') {
  627. $data[$i]->match_id_order = '<a href="/admin/Sportsbk/outcome?home_team=' . $data[$i]->match_id . '">' . $data[$i]->match_id . '</a> (<span>' . $data[$i]->account_name . '</span>)<br>' . $data[$i]->order_id;
  628. }
  629. if ($data[$i]->game_code == 'wq') {
  630. $data[$i]->match_id_order = '<a href="/admin/Sportswq/outcome?home_team=' . $data[$i]->match_id . '">' . $data[$i]->match_id . '</a> (<span>' . $data[$i]->account_name . '</span>)<br>' . $data[$i]->order_id;
  631. }
  632. if ($data[$i]->game_code == 'bq') {
  633. $data[$i]->match_id_order = '<a href="/admin/Sportsbq/outcome?home_team=' . $data[$i]->match_id . '">' . $data[$i]->match_id . '</a> (<span>' . $data[$i]->account_name . '</span>)<br>' . $data[$i]->order_id;
  634. }
  635. $data[$i]->league = $data[$i]->name_chinese;
  636. if ($data[$i]->is_champion == 0) {
  637. $data[$i]->home_guest = $data[$i]->home_team . ' VS ' . $data[$i]->guest_team;
  638. $data[$i]->time = '开赛:' . $data[$i]->match_date . ' ' . $data[$i]->match_time;
  639. } else {
  640. $data[$i]->home_guest = '冠军联赛投注';
  641. $data[$i]->time = '结束:' . $data[$i]->last_time;
  642. }
  643. $data[$i]->money_match_time = '下注:' . $data[$i]->money_time . $data[$i]->time;
  644. //反水
  645. $data[$i]->water_return = -1;
  646. for ($a = 0; $a < count($water_return_money); $a++) {
  647. if ($data[$i]->order_id == $water_return_money[$a]->trade_id) {
  648. if ($data[$i]->status == 2 || $data[$i]->status == 3) {
  649. $data[$i]->water_return = 0;
  650. } else {
  651. $data[$i]->water_return = $water_return_money[$a]->money;
  652. }
  653. //用户投注后账户金额
  654. $data[$i]->frozen_cash = $water_return_money[$a]->money_cash;
  655. }
  656. }
  657. if ($data[$i]->water_return == -1) {
  658. $data[$i]->water_return = 0;
  659. //用户投注后账户金额
  660. $data[$i]->frozen_cash = $data[$i]->money_cash;
  661. }
  662. //此时结果金额
  663. $data[$i]->result = $data[$i]->water_return + $data[$i]->gain_money;
  664. //用户投注前账户金额
  665. $data[$i]->available_cash = $data[$i]->money_cash + $data[$i]->money;
  666. //投注前后账户金额
  667. $data[$i]->account_money = $data[$i]->available_cash . '<br><span>' . $data[$i]->money . '</span><br>' . $data[$i]->frozen_cash;
  668. if ($data[$i]->status == 2 || $data[$i]->status == 3) {
  669. for ($b = 0; $b < count($invalid_money); $b++) {
  670. if ($data[$i]->order_id == $invalid_money[$b]->trade_id) {
  671. $data[$i]->available_cash = $invalid_money[$b]->money_cash;
  672. $data[$i]->account_money = $data[$i]->available_cash;
  673. }
  674. }
  675. }
  676. $data[$i]->str = 0;
  677. for ($b = 0; $b < count($content); $b++) {
  678. $data[$i]->str1 = 0;
  679. $data[$i]->team = '';
  680. if (!empty($content[$b]->odds_code)) {
  681. if (!empty(stristr($content[$b]->odds_code, 'home'))) {
  682. $data[$i]->team = $data[$i]->home_team;
  683. }
  684. if (!empty(stristr($content[$b]->odds_code, 'guest'))) {
  685. $data[$i]->team = $data[$i]->guest_team;
  686. }
  687. if ($content[$b]->p_code == 'half_full') {
  688. $string = str_replace('home', $data[$i]->home_team, $content[$b]->odds_code);
  689. $string = str_replace('guest', $data[$i]->guest_team, $string);
  690. $string = str_replace('dogfall', '和局', $string);
  691. $string = explode('_', $string);
  692. $data[$i]->team = $string['2'] . '/' . $string['3'];
  693. }
  694. }
  695. //处理普通赛事玩法详情
  696. if ($data[$i]->match_id == $content[$b]->match_id && $data[$i]->batch_id == $content[$b]->batch_id && $data[$i]->is_champion == 0) {
  697. if ($content[$b]->p_code == 'first_last_ball' || $content[$b]->p_code == 'half_full' || $content[$b]->p_code == 'capot' || $content[$b]->p_code == 'two_sides' || $content[$b]->p_code == 'total_goal') {
  698. $content[$b]->condition = '';
  699. }
  700. $data[$i]->game_status = $data[$i]->game_status;
  701. //投注详情
  702. if (!empty($data[$i]->match_time)) {
  703. $data[$i]->content1 = '[' . $data[$i]->match_time . ']';
  704. //$data[$i]->match_time = $data[$i]->match_time;
  705. } else {
  706. if (!empty($data[$i]->last_time)) {
  707. $datetime = explode(' ', $data[$i]->last_time);
  708. //$data[$i]->match_time = $datetime[1];
  709. $data[$i]->content1 = '[' . $datetime[1] . ']';
  710. }
  711. }
  712. for ($c = 0; $c < count($result); $c++) {
  713. if ($content[$b]->odds_code == $result[$c]->odds_code) {
  714. $data[$i]->str1 = 1;
  715. if ($content[$b]->result == '未处理') {
  716. $data[$i]->content = $data[$i]->content . $result[$c]->odds_name . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br>';
  717. } else {
  718. $data[$i]->content = $data[$i]->content . $result[$c]->odds_name . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br><span>' . $content[$b]->result . '</span>(' . $content[$b]->matchresult . ')<br>';
  719. }
  720. }
  721. }
  722. if ($data[$i]->str1 == 0) {
  723. if ($content[$b]->result == '未处理') {
  724. $data[$i]->content = $data[$i]->content . $content[$b]->odds_code . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br>';
  725. } else {
  726. $data[$i]->content = $data[$i]->content . $content[$b]->odds_code . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br><span>' . $content[$b]->result . '</span>(' . $content[$b]->matchresult . ')<br>';
  727. }
  728. }
  729. }
  730. //处理冠军联赛玩法详情
  731. if ($data[$i]->match_id == $content[$b]->lg_id && $data[$i]->batch_id == $content[$b]->batch_id && $data[$i]->is_champion == 1) {
  732. $content[$b]->condition = '';
  733. if ($content[$b]->p_code == 'first_last_ball' || $content[$b]->p_code == 'half_full' || $content[$b]->p_code == 'capot' || $content[$b]->p_code == 'two_sides' || $content[$b]->p_code == 'total_goal') {
  734. $content[$b]->condition = '';
  735. }
  736. $data[$i]->game_status = $data[$i]->game_status;
  737. /*
  738. //投注详情
  739. if(!empty($data[$i]->match_time)){
  740. $data[$i]->content1 = '['.$data[$i]->match_time.']';
  741. //$data[$i]->match_time = $data[$i]->match_time;
  742. }
  743. else{
  744. if(!empty($data[$i]->last_time)){
  745. $datetime = explode(' ',$data[$i]->last_time);
  746. //$data[$i]->match_time = $datetime[1];
  747. $data[$i]->content1 = '['.$datetime[1].']';
  748. }
  749. }
  750. */
  751. /*
  752. for($c=0;$c<count($result);$c++){
  753. if($content[$b]->odds_code == $result[$c]->odds_code){
  754. $data[$i]->str1 = 1;
  755. if($content[$b]->result=='未处理'){
  756. $data[$i]->content = $content[$b]->home_team.'<br>'.$data[$i]->content.$result[$c]->odds_name.'<br>'.$content[$b]->condition.' '.$data[$i]->team.'@'.$content[$b]->odds.' ¥'.$content[$b]->bet_money.'<br>';
  757. }else{
  758. $data[$i]->content = $content[$b]->home_team.'<br>'.$data[$i]->content.$result[$c]->odds_name.'<br>'.$content[$b]->condition.' '.$data[$i]->team.'@'.$content[$b]->odds.' ¥'.$content[$b]->bet_money.'<br><span>'.$content[$b]->result.'</span>('.$content[$b]->matchresult.')<br>';
  759. }
  760. }
  761. }
  762. */
  763. if ($data[$i]->str1 == 0) {
  764. if ($content[$b]->result == '未处理') {
  765. $data[$i]->content = $content[$b]->home_team . '<br>' . $data[$i]->content . $content[$b]->odds_code . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br>';
  766. } else {
  767. $data[$i]->content = $content[$b]->home_team . '<br>' . $data[$i]->content . $content[$b]->odds_code . '<br>' . $content[$b]->condition . ' ' . $data[$i]->team . '@' . $content[$b]->odds . ' ¥' . $content[$b]->bet_money . '<br><span>' . $content[$b]->result . '</span>(' . $content[$b]->matchresult . ')<br>';
  768. }
  769. }
  770. }
  771. }
  772. // if($data[$i]->status == 1){
  773. // if($data[$i]->match_status == 0 || $data[$i]->match_status == 1){
  774. // $data[$i]->game_status = $data[$i]->settle_status.'<br><a class="layui-btn layui-btn-sm audit" lay-event="detail" pid="id" uri="" href="javascript:void(0)" style="background-color: grey;"> 结算 </a>';
  775. // }
  776. // if($data[$i]->match_status == 2 || $data[$i]->match_status == 3 || $data[$i]->match_status == 5){
  777. // if($data[$i]->settle_status == '已结算'){
  778. // $data[$i]->game_status = $data[$i]->settle_status.'<br><a class="layui-btn layui-btn-sm resettlement" lay-event="detail" pid="id" uri="/admin/SoccerNoteList/resettlement/?id=" href="javascript:resettlement(\'/admin/SoccerNoteList/resettlement/?id='.$data[$i]->id.'\');"> 重新结算 </a>';
  779. // }else{
  780. // $data[$i]->game_status = $data[$i]->settle_status.'<br><a class="layui-btn layui-btn-sm settlement" lay-event="detail" pid="id" uri="/admin/SoccerNoteList/settlement/?id=" href="javascript:settlement(\'/admin/SoccerNoteList/settlement/?id='.$data[$i]->id.'\');"> 结算 </a>';
  781. // }
  782. // }
  783. // }else{
  784. // $data[$i]->game_status = $data[$i]->settle_status.'<br><a class="layui-btn layui-btn-sm audit" lay-event="detail" pid="id" uri="" href="javascript:void(0)" style="background-color: grey;"> 结2算 </a>';
  785. // }
  786. $data[$i]->content = $data[$i]->content1 . $data[$i]->content;
  787. }
  788. return $data->toArray();
  789. }
  790. }