ZqRule.php 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2019/4/25
  6. * Time: 14:10
  7. */
  8. namespace App\Lib\Settlement\Adapter;
  9. use Illuminate\Support\Facades\DB;
  10. class ZqRule
  11. {
  12. use RulePlus;
  13. /**
  14. * 全场|主队|让球
  15. * @param mixed $model 注单表数据
  16. * @param mixed $resultModel 结果表数据
  17. * @param mixed $resultRecords 结果记录表数据
  18. * @return string 1:赢 -1:输 2:平 3:赢半平半 4:输半平半
  19. */
  20. public function concede_home($model, $resultModels, $resultRecords)
  21. {
  22. $resultModel = $resultModels['0'];
  23. $home = intval($resultModel->home_score);
  24. $guest = intval($resultModel->guest_score);
  25. $word = $home . '-' . $guest . '(全场)';
  26. $ret = $this->zq_letball($home - $guest, $model->condition, $word);
  27. return $ret;
  28. }
  29. /**
  30. * 全场|客队|让球
  31. * @param mixed $model 注单表数据
  32. * @param mixed $resultModel 结果表数据
  33. * @param mixed $resultRecords 结果记录表数据
  34. * @return string 1:赢 -1:输 2:平 3:赢半平半 4:输半平半
  35. */
  36. public function concede_guest($model, $resultModels, $resultRecords)
  37. {
  38. $resultModel = $resultModels['0'];
  39. $home = intval($resultModel->home_score);
  40. $guest = intval($resultModel->guest_score);
  41. $word = $home . '-' . $guest . '(全场)';
  42. $ret = $this->zq_letball($guest - $home, $model->condition, $word);
  43. return $ret;
  44. }
  45. /**
  46. * 上半场|主队|让球
  47. * @param mixed $model 注单表数据
  48. * @param mixed $resultModel 结果表数据
  49. * @param mixed $resultRecords 结果记录表数据
  50. * @return string 1:赢 -1:输 2:平 3:赢半平半 4:输半平半
  51. */
  52. public function half_concede_home($model, $resultModels, $resultRecords)
  53. {
  54. $resultModel = $resultModels['0'];
  55. $home = intval($resultModel->u_home_score);
  56. $guest = intval($resultModel->u_guest_score);
  57. $word = $home . '-' . $guest . '(上半场)';
  58. $ret = $this->zq_letball($home - $guest, $model->condition, $word);
  59. return $ret;
  60. }
  61. /**
  62. * 上半场|客队|让球
  63. * @param mixed $model 注单表数据
  64. * @param mixed $resultModel 结果表数据
  65. * @param mixed $resultRecords 结果记录表数据
  66. * @return string 1:赢 -1:输 2:平 3:赢半平半 4:输半平半
  67. */
  68. public function half_concede_guest($model, $resultModels, $resultRecords)
  69. {
  70. $resultModel = $resultModels['0'];
  71. $home = intval($resultModel->u_home_score);
  72. $guest = intval($resultModel->u_guest_score);
  73. $word = $home . '-' . $guest . '(上半场)';
  74. $ret = $this->zq_letball($guest - $home, $model->condition, $word);
  75. return $ret;
  76. }
  77. /**
  78. * 进球|全场|大
  79. * @param mixed $model 注单表数据
  80. * @param mixed $resultModel 结果表数据
  81. * @param mixed $resultMgoal_size_smallodel 结果表数据
  82. * @param mixed $resultRecords 结果记录表数据
  83. * @return string 1:赢 -1:输 2:平 3:赢半平半 4:输半平半
  84. */
  85. public function goal_size_home($model, $resultModels, $resultRecords)
  86. {
  87. $resultModel = $resultModels['0'];
  88. $home = intval($resultModel->u_home_score);
  89. $guest = intval($resultModel->u_guest_score);
  90. $total = $home + $guest;
  91. $word = $home . '-' . $guest . '(全场)';
  92. $ret = $this->zq_inball_bigsmall($total, $model->condition, 2, $word);
  93. return $ret;
  94. }
  95. /**
  96. * 进球|全场|小
  97. * @param mixed $model 注单表数据
  98. * @param mixed $resultModel 结果表数据
  99. * @param mixed $resultRecords 结果记录表数据
  100. * @return string 1:赢 -1:输 2:平 3:赢半平半 4:输半平半
  101. */
  102. public function goal_size_guest($model, $resultModels, $resultRecords)
  103. {
  104. $resultModel = $resultModels['0'];
  105. $home = intval($resultModel->u_home_score);
  106. $guest = intval($resultModel->u_guest_score);
  107. $total = $home + $guest;
  108. $word = $home . '-' . $guest . '(全场)';
  109. $ret = $this->zq_inball_bigsmall($total, $model->condition, 1, $word);
  110. return $ret;
  111. }
  112. //全场|进球|大
  113. public function goal_size_big($model, $resultModels, $resultRecords)
  114. {
  115. $resultModel = $resultModels['0'];
  116. $allscore = intval($resultModel->home_score) + intval($resultModel->guest_score);
  117. $word = $resultModel->home_score . '-' . $resultModel->guest_score . "(全场)";
  118. $returnDatas = $this->zq_inball_bigsmall($allscore, $model->condition, 2, $word);
  119. return $returnDatas;
  120. }
  121. //全场|进球|小
  122. public function goal_size_small($model, $resultModels, $resultRecords)
  123. {
  124. $resultModel = $resultModels['0'];
  125. $allscore = intval($resultModel->home_score) + intval($resultModel->guest_score);
  126. $word = $resultModel->home_score . '-' . $resultModel->guest_score . "(全场)";
  127. $returnDatas = $this->zq_inball_bigsmall($allscore, $model->condition, 1, $word);
  128. return $returnDatas;
  129. }
  130. /**
  131. * 进球|上半场|大
  132. * @param mixed $model 注单表数据
  133. * @param mixed $resultModel 结果表数据
  134. * @param mixed $resultRecords 结果记录表数据
  135. * @return string 1:赢 -1:输 2:平 3:赢半平半 4:输半平半
  136. */
  137. public function half_goal_size_big($model, $resultModels, $resultRecords)
  138. {
  139. $resultModel = $resultModels['0'];
  140. $score = intval($resultModel->u_home_score) + intval($resultModel->u_guest_score);
  141. return $this->zq_inball_bigsmall($score, $model->condition, 2, $resultModel->u_home_score . '-' . $resultModel->u_guest_score . '(上半场)');
  142. }
  143. /**
  144. * 进球|上半场|小
  145. * @param mixed $model 注单表数据
  146. * @param mixed $resultModel 结果表数据
  147. * @param mixed $resultRecords 结果记录表数据
  148. * @return string 1:赢 -1:输 2:平 3:赢半平半 4:输半平半
  149. */
  150. public function half_goal_size_small($model, $resultModels, $resultRecords)
  151. {
  152. $resultModel = $resultModels['0'];
  153. $score = intval($resultModel->u_home_score) + intval($resultModel->u_guest_score);
  154. return $this->zq_inball_bigsmall($score, $model->condition, 1, $resultModel->u_home_score . '-' . $resultModel->u_guest_score . '(上半场)');
  155. }
  156. /**
  157. * 全场|主队|独赢
  158. * @param mixed $model 注单表数据
  159. * @param mixed $resultModel 结果表数据
  160. * @param mixed $resultRecords 结果记录表数据
  161. * @return string 1:赢 -1:输
  162. */
  163. public function capot_home($model, $resultModels, $resultRecords)
  164. {
  165. $resultModel = $resultModels['0'];
  166. $home = intval($resultModel->home_score);
  167. $guest = intval($resultModel->guest_score);
  168. $word = $home . '-' . $guest . '(全场)';
  169. $ret = $this->zq_duyingv2(1, 4, $resultModel, $word);
  170. return $ret;
  171. }
  172. /**
  173. * 全场|客队|独赢
  174. * @param mixed $model 注单表数据
  175. * @param mixed $resultModel 结果表数据
  176. * @param mixed $resultRecords 结果记录表数据
  177. * @return string 1:赢 -1:输
  178. */
  179. public function capot_guest($model, $resultModels, $resultRecords)
  180. {
  181. $resultModel = $resultModels['0'];
  182. $home = intval($resultModel->home_score);
  183. $guest = intval($resultModel->guest_score);
  184. $word = $home . '-' . $guest . '(全场)';
  185. $ret = $this->zq_duyingv2(2, 4, $resultModel, $word);
  186. return $ret;
  187. }
  188. /**
  189. * 全场|主客平|独赢
  190. * @param mixed $model 注单表数据
  191. * @param mixed $resultModel 结果表数据
  192. * @param mixed $resultRecords 结果记录表数据
  193. * @return string 1:赢 -1:输
  194. */
  195. public function capot_dogfall($model, $resultModels, $resultRecords)
  196. {
  197. $resultModel = $resultModels['0'];
  198. $home = intval($resultModel->home_score);
  199. $guest = intval($resultModel->guest_score);
  200. $word = $home . '-' . $guest . '(全场)';
  201. if ($home == $guest) {
  202. $return['result'] = 1;
  203. } else {
  204. $return['result'] = -1;
  205. }
  206. $return['matchResult'] = $word;
  207. return $return;
  208. }
  209. /**
  210. * 上半场|主队|独赢
  211. * @param mixed $model 注单表数据
  212. * @param mixed $resultModel 结果表数据
  213. * @param mixed $resultRecords 结果记录表数据
  214. * @return string 1:赢 -1:输
  215. */
  216. public function half_capot_home($model, $resultModels, $resultRecords)
  217. {
  218. $resultModel = $resultModels['0'];
  219. $word = $resultModel->u_home_score . '-' . $resultModel->u_guest_score . '(上半场)';
  220. return $this->zq_duyingv2(1, 1, $resultModel, $word);
  221. }
  222. /**
  223. * 上半场|客队|独赢
  224. * @param mixed $model 注单表数据
  225. * @param mixed $resultModel 结果表数据
  226. * @param mixed $resultRecords 结果记录表数据
  227. * @return string 1:赢 -1:输
  228. */
  229. public function half_capot_guest($model, $resultModels, $resultRecords)
  230. {
  231. $resultModel = $resultModels['0'];
  232. $word = $resultModel->u_home_score . '-' . $resultModel->u_guest_score . '(上半场)';
  233. return $this->zq_duyingv2(2, 1, $resultModel, $word);
  234. }
  235. /**
  236. * 上半场|主客平|独赢
  237. * @param mixed $model 注单表数据
  238. * @param mixed $resultModel 结果表数据
  239. * @param mixed $resultRecords 结果记录表数据
  240. * @return string 1:赢 -1:输
  241. */
  242. public function half_capot_dogfall($model, $resultModels, $resultRecords)
  243. {
  244. $resultModel = $resultModels['0'];
  245. $word = $resultModel->u_home_score . '-' . $resultModel->u_guest_score . '(上半场)';
  246. if ($resultModel->u_home_score == $resultModel->u_guest_score) {
  247. $result = 1;
  248. } else {
  249. $result = -1;
  250. }
  251. return ['result' => $result, 'matchResult' => $word];
  252. }
  253. // first_last_ball最先/最后进球 开始-----------------------
  254. //主队|最先进球
  255. public function first_ball_home($model, $resultModel, $resultRecords)
  256. {
  257. $resultModel = $resultModel['0'];
  258. $word = ($resultModel->first_score != '') ? (($resultModel->first_score == $model->home_team) ? '1:0' : '0:1') : '0:0';
  259. $word .= '(主客)';
  260. if (trim($resultModel->first_score) == trim($resultModel->home_team)) {
  261. return ['result' => 1, 'matchResult' => $word];
  262. } else {
  263. return ['result' => -1, 'matchResult' => $word];
  264. }
  265. }
  266. //客队|最先进球
  267. public function first_ball_guest($model, $resultModel, $resultRecords)
  268. {
  269. $resultModel = $resultModel['0'];
  270. $word = ($resultModel->first_score != '') ? (($resultModel->first_score == $model->guest_team) ? '0:1' : '1:0') : '0:0';
  271. $word .= '(主客)';
  272. if (trim($resultModel->first_score) == trim($resultModel->guest_team)) {
  273. return ['result' => 1, 'matchResult' => $word];
  274. } else {
  275. return ['result' => -1, 'matchResult' => $word];
  276. }
  277. }
  278. //主队|最后进球
  279. public function last_ball_home($model, $resultModel, $resultRecords)
  280. {
  281. $resultModel = $resultModel['0'];
  282. $word = ($resultModel->last_score != '') ? (($resultModel->last_score == $model->home_team) ? '1:0' : '0:1') : '0:0';
  283. $word .= '(主客)';
  284. if (trim($resultModel->last_score) == trim($resultModel->home_team)) {
  285. return ['result' => 1, 'matchResult' => $word];
  286. } else {
  287. return ['result' => -1, 'matchResult' => $word];
  288. }
  289. }
  290. //客队|最后进球
  291. public function last_ball_guest($model, $resultModel, $resultRecords)
  292. {
  293. $resultModel = $resultModel['0'];
  294. $word = ($resultModel->last_score != '') ? (($resultModel->last_score == $model->guest_team) ? '0:1' : '1:0') : '0:0';
  295. $word .= '(主客)';
  296. if (trim($resultModel->last_score) == trim($resultModel->guest_team)) {
  297. return ['result' => 1, 'matchResult' => $word];
  298. } else {
  299. return ['result' => -1, 'matchResult' => $word];
  300. }
  301. }
  302. //没有进球
  303. public function not_ball($model, $resultModel, $resultRecords)
  304. {
  305. $resultModel = $resultModel['0'];
  306. $home = intval($resultModel->home_score);
  307. $guest = intval($resultModel->guest_score);
  308. $all_score = $home + $guest;
  309. $word = ($home > 0 ? 1 : 0) . '-' . ($guest > 0 ? 1 : 0) . '(主客)';
  310. if ($all_score <= 0) {
  311. return ['result' => 1, 'matchResult' => $word];
  312. } else {
  313. return ['result' => -1, 'matchResult' => $word];
  314. }
  315. }
  316. ////////// first_last_ball最先/最后进球 结束-----------------------
  317. /**
  318. * 足球波胆 规则
  319. * @param $bet_match 投注赛事数据
  320. * @param $result_match 最终结果
  321. * @param $result_match_r 结果记录
  322. */
  323. public function bodan($bet_match, $result_match, $result_match_r)
  324. {
  325. // $bet_match = DB::table('money_buy_match')->where(['match_id'=> 3219925,'p_code'=>'bodan'])->first();
  326. // $result_match = DB::table('st_zq_result')->where('match_id', 3224833)->limit(10)->get();
  327. // select * from st_zq_result where id=1317823 order by id desc limit 10 ;
  328. // $result_match_r = DB::table('st_zq_result_record')->where('match_id', 3150765)->get()->toArray();
  329. //获取父/子级赔率代码
  330. $p_code = $bet_match->p_code;
  331. $odds_code = $bet_match->odds_code;
  332. //获取主客队投注比分
  333. $bet_score = explode('-', $bet_match->condition);
  334. $bet_home_score = (int)$bet_score[0];
  335. $bet_guest_score = isset($bet_score[1]) ? intval($bet_score[1]) : 0;
  336. if ($p_code != 'bodan') return false;
  337. //获取赛事最终结果数据
  338. $result_match = $this->getHalfData($result_match);
  339. if (strstr($odds_code, "half")) {//上半场
  340. //获取主客队上半场得分
  341. $home_score = $result_match->u_home_score;
  342. $guest_score = $result_match->u_guest_score;
  343. //返回结果
  344. $data = [
  345. 'result' => 1,
  346. 'matchResult' => "$home_score-$guest_score(上半场)"
  347. ];
  348. if (strstr($bet_match->condition, "其他")) {
  349. if (($home_score > 3) || ($guest_score > 3)) {
  350. return $data;
  351. }
  352. }
  353. //判断结果
  354. if ($bet_home_score == $home_score and $bet_guest_score == $guest_score) {
  355. return $data;
  356. }
  357. $data['result'] = -1;
  358. return $data;
  359. } else {//全场
  360. //获取主客队全场得分
  361. $home_score = $result_match->home_score;
  362. $guest_score = $result_match->guest_score;
  363. //返回结果
  364. $data = [
  365. 'result' => 1,
  366. 'matchResult' => "$home_score-$guest_score(全场)"
  367. ];
  368. if (strstr($bet_match->condition, "其他")) {
  369. if (($home_score > 4) || ($guest_score > 4)) {
  370. return $data;
  371. }
  372. }
  373. //判断结果
  374. if ($bet_home_score == $home_score and $bet_guest_score == $guest_score) {
  375. return $data;
  376. }
  377. $data['result'] = -1;
  378. return $data;
  379. }
  380. }
  381. //结果单/双 home_score 主队进球数 guest_score 客队进球数 home_rate 主队让球 guest_rate 客队让球 u_home_score 上半场主队进球 u_guest_score 上半场-客队进球数 two_sides_single 全场单 two_sides_double 全场双 half_two_sides_single 上半场单 half_two_sides_double 上半场双
  382. public function two_sides($model, $resultModels, $resultRecords)
  383. {
  384. $resultModel = $resultModels['0'];
  385. $resulttod = intval($resultModel->home_score) + intval($resultModel->guest_score);//全场
  386. $score_home = intval($resultModel->home_score);
  387. $guest_home = intval($resultModel->guest_score);
  388. $word_all = $score_home . '-' . $guest_home . '(全场)';
  389. $score_home_half = intval($resultModel->u_home_score);
  390. $guest_home_half = intval($resultModel->u_guest_score);
  391. $word_all_half = $score_home_half . '-' . $guest_home_half . '(半场)';
  392. if ($resulttod % 2 == 0) {
  393. $text = '双';
  394. } else {
  395. $text = '单';
  396. }
  397. if ($model->odds_code == "two_sides_single" || $model->odds_code == 'two_sides_double') {
  398. if ($text == $model->condition) {
  399. $dsresult = 1;
  400. } else {
  401. $dsresult = -1;
  402. }
  403. return ['result' => $dsresult, 'matchResult' => $word_all];
  404. } elseif ($model->odds_code == 'half_two_sides_single' || $model->odds_code == 'half_two_sides_double') {
  405. $hafs = intval($resultModel->u_home_score) + intval($resultModel->u_guest_score);
  406. $text = ($hafs % 2 == 0) ? '双' : '单';
  407. $dsresult = ($text == $model->condition) ? 1 : -1;
  408. return ['result' => $dsresult, 'matchResult' => $word_all_half];
  409. } else {
  410. $data = [
  411. 'result' => 100,
  412. 'matchResult' => "参数不存在",
  413. ];
  414. return $data;
  415. }
  416. }
  417. //结果总数 home_score 主队进球数 guest_score 客队进球数 home_rate 主队让球 guest_rate 客队让球 u_home_score 上半场-主队进球数 u_guest_score 上半场-客队进球数
  418. public function total_goal($model, $resultModels, $resultRecords)
  419. {
  420. $resultModel = $resultModels['0'];
  421. //全场总进球数
  422. $resulttod = intval($resultModel->home_score) + intval($resultModel->guest_score);
  423. $score_home = intval($resultModel->home_score);
  424. $guest_home = intval($resultModel->guest_score);
  425. $word_all = $score_home . '-' . $guest_home . '(全场)';
  426. $score_home_half = intval($resultModel->u_home_score);
  427. $guest_home_half = intval($resultModel->u_guest_score);
  428. $word_all_half = $score_home_half . '-' . $guest_home_half . '(半场)';
  429. //上半场总进球数
  430. $firsthalftod = intval($resultModel->u_home_score) + intval($resultModel->u_guest_score);
  431. $results = 0;
  432. $resultb = 0;
  433. if ($model->odds_code == "total_goal_four") {
  434. if (4 <= $resulttod and $resulttod <= 6) {
  435. $results = 1;
  436. } else {
  437. $results = -1;
  438. }
  439. }
  440. if ($model->odds_code == "total_goal_zero") {
  441. if (0 <= $resulttod and $resulttod <= 1) {
  442. $results = 1;
  443. } else {
  444. $results = -1;
  445. }
  446. }
  447. if ($model->odds_code == "total_goal_two") {
  448. if (2 <= $resulttod and $resulttod <= 3) {
  449. $results = 1;
  450. } else {
  451. $results = -1;
  452. }
  453. }
  454. if ($model->odds_code == "total_goal_seven") {
  455. if (7 <= $resulttod) {
  456. $results = 1;
  457. } else {
  458. $results = -1;
  459. }
  460. }
  461. if ($model->odds_code == "half_total_goal_zero") {
  462. if ($firsthalftod == 0) {
  463. $resultb = 1;
  464. } else {
  465. $resultb = -1;
  466. }
  467. }
  468. if ($model->odds_code == "half_total_goal_one") {
  469. if ($firsthalftod == 1) {
  470. $resultb = 1;
  471. } else {
  472. $resultb = -1;
  473. }
  474. }
  475. if ($model->odds_code == "half_total_goal_two") {
  476. if ($firsthalftod == 2) {
  477. $resultb = 1;
  478. } else {
  479. $resultb = -1;
  480. }
  481. }
  482. if ($model->odds_code == "half_total_goal_three") {
  483. if ($firsthalftod == 3) {
  484. $resultb = 1;
  485. } else {
  486. $resultb = -1;
  487. }
  488. }
  489. if ($results == 1) {
  490. $data = [
  491. 'result' => 1,
  492. 'matchResult' => $word_all,
  493. ];
  494. }
  495. if ($results == -1) {
  496. $data = [
  497. 'result' => -1,
  498. 'matchResult' => $word_all,
  499. ];
  500. }
  501. if ($resultb == 1) {
  502. $data = [
  503. 'result' => 1,
  504. 'matchResult' => $word_all_half,
  505. ];
  506. }
  507. if ($resultb == -1) {
  508. $data = [
  509. 'result' => -1,
  510. 'matchResult' => $word_all_half,
  511. ];
  512. }
  513. return $data;
  514. }
  515. //球队进球数:大/小
  516. //condition 0.5 或 0.5/1 这种
  517. public function tema_ball($model, $resultModels, $result_match_r = [])
  518. {
  519. $resultModel = $resultModels['0'];
  520. $odds_code = trim($model->odds_code);
  521. $score_home = intval($resultModel->home_score);
  522. $score_guest = intval($resultModel->guest_score);
  523. $score_home_uhalf = intval($resultModel->u_home_score);
  524. $score_guest_uhalf = intval($resultModel->u_guest_score);
  525. switch ($odds_code) {
  526. case 'home_tema_ball_big':
  527. $returnDatas['matchResult'] = $score_home . '-' . $score_guest . '(全场)';
  528. $returnDatas = $this->zq_inball_bigsmall($score_home, $model->condition, 2, $returnDatas['matchResult']);
  529. break;
  530. case 'home_tema_ball_small':
  531. $returnDatas['matchResult'] = $score_home . '-' . $score_guest . '(全场)';
  532. $returnDatas = $this->zq_inball_bigsmall($score_home, $model->condition, 1, $returnDatas['matchResult']);
  533. break;
  534. case 'guest_tema_ball_big':
  535. $returnDatas['matchResult'] = $score_home . '-' . $score_guest . '(全场)';
  536. $returnDatas = $this->zq_inball_bigsmall($score_guest, $model->condition, 2, $returnDatas['matchResult']);
  537. break;
  538. case 'guest_tema_ball_small':
  539. $returnDatas['matchResult'] = $score_home . '-' . $score_guest . '(全场)';
  540. $returnDatas = $this->zq_inball_bigsmall($score_guest, $model->condition, 1, $returnDatas['matchResult']);
  541. break;
  542. case 'half_home_tema_ball_big':
  543. $returnDatas['matchResult'] = $score_home_uhalf . '-' . $score_guest_uhalf . '(上半场)';
  544. $returnDatas = $this->zq_inball_bigsmall($score_home_uhalf, $model->condition, 2, $returnDatas['matchResult']);
  545. break;
  546. case 'half_home_tema_ball_small':
  547. $returnDatas['matchResult'] = $score_home_uhalf . '-' . $score_guest_uhalf . '(上半场)';
  548. $returnDatas = $this->zq_inball_bigsmall($score_home_uhalf, $model->condition, 1, $returnDatas['matchResult']);
  549. break;
  550. case 'half_guest_tema_ball_big':
  551. $returnDatas['matchResult'] = $score_home_uhalf . '-' . $score_guest_uhalf . '(上半场)';
  552. $returnDatas = $this->zq_inball_bigsmall($score_guest_uhalf, $model->condition, 2, $returnDatas['matchResult']);
  553. break;
  554. case 'half_guest_tema_ball_small':
  555. $returnDatas['matchResult'] = $score_home_uhalf . '-' . $score_guest_uhalf . '(上半场)';
  556. $returnDatas = $this->zq_inball_bigsmall($score_guest_uhalf, $model->condition, 1, $returnDatas['matchResult']);
  557. break;
  558. }
  559. return $returnDatas;
  560. }
  561. /**
  562. * 半场/全场 投注规则
  563. */
  564. public function half_full($bet_match, $result_match, $result_match_r)
  565. {
  566. // $bet_match = DB::table('money_buy_match')->where('match_id', 3210851)->first();
  567. // $result_match = DB::table('st_zq_result')->where('match_id', 3210851)->first();
  568. // $result_match_r = DB::table('st_zq_result_record')->where('match_id', 3210851)->get()->toArray();
  569. if (empty($bet_match) || empty($result_match)) return false;
  570. //获取父/子级赔率代码
  571. $p_code = $bet_match->p_code;
  572. $odds_code = $bet_match->odds_code;
  573. //获取最终赛事数据
  574. $result_match = $this->getHalfData($result_match);
  575. //获取主客队上半场得分
  576. $half_home_score = $result_match->u_home_score;
  577. $half_guest_score = $result_match->u_guest_score;
  578. //获取主客队全场得分
  579. $full_home_score = $result_match->home_score;
  580. $full_guest_score = $result_match->guest_score;
  581. //半场/全场盘口
  582. if ($p_code != 'half_full') return false;
  583. //返回结果
  584. $data = [
  585. 'result' => 1,
  586. 'matchResult' => "$half_home_score-$half_guest_score(上半场);$full_home_score-$full_guest_score(全场)"
  587. ];
  588. switch ($odds_code) {
  589. case 'half_full_home_home':// 主-主
  590. if ($half_home_score > $half_guest_score and $full_home_score > $full_guest_score) return $data;
  591. break;
  592. case 'half_full_home_dogfall':// 主-和
  593. if ($half_home_score > $half_guest_score and $full_home_score == $full_guest_score) return $data;
  594. break;
  595. case 'half_full_home_guest':// 主-客
  596. if ($half_home_score > $half_guest_score and $full_home_score < $full_guest_score) return $data;
  597. break;
  598. case 'half_full_dogfall_home':// 和-主
  599. if ($half_home_score == $half_guest_score and $full_home_score > $full_guest_score) return $data;
  600. break;
  601. case 'half_full_dogfall_dogfall':// 和-和
  602. if ($half_home_score == $half_guest_score and $full_home_score == $full_guest_score) return $data;
  603. break;
  604. case 'half_full_dogfall_guest':// 和-客
  605. if ($half_home_score == $half_guest_score and $full_home_score < $full_guest_score) return $data;
  606. break;
  607. case 'half_full_guest_home':// 客-主
  608. if ($half_home_score < $half_guest_score and $full_home_score > $full_guest_score) return $data;
  609. break;
  610. case 'half_full_guest_dogfall':// 客-和
  611. if ($half_home_score < $half_guest_score and $full_home_score == $full_guest_score) return $data;
  612. break;
  613. case 'half_full_guest_guest':// 客-客
  614. if ($half_home_score < $half_guest_score and $full_home_score < $full_guest_score) return $data;
  615. break;
  616. default:
  617. return false;
  618. }
  619. $data['result'] = -1;
  620. return $data;
  621. }
  622. /**
  623. * @param $result_match_r 赛事结果记录
  624. * @return mixed 返回最新一条上半场结果数据
  625. */
  626. public function getHalfData($result_match_r = [])
  627. {
  628. return $result_match_r['0'];
  629. if (empty($result_match_r)) return false;
  630. if (is_array($result_match_r)) {
  631. foreach ($result_match_r as $k => $v) {
  632. return $v;
  633. }
  634. }
  635. }
  636. /**bo
  637. * 冠军盘口投注
  638. * $bet_match 投注赛事数据
  639. * $result_match 联赛结果 数据 根据玩法代码查询一条
  640. * $result_match_r 无用参数
  641. */
  642. public function gj($bet_match, $result_match, $result_match_r)
  643. {
  644. // $bet_match = DB::table('money_buy_match')->where('match_id', 127317)->first();
  645. // $bet_match->odds_code = '巴西小组赛积分成绩';
  646. // $result_match = DB::table('st_zq_league_result')->where(['lg_id'=>27317,'game_name'=>$bet_match->odds_code])->first();
  647. //获取 赛事最终数据
  648. $result_match = $this->getHalfData($result_match);
  649. if (empty($bet_match) || empty($result_match)) return false;
  650. if ($bet_match->p_code != 'gj') return false;//冠军玩法
  651. if ($bet_match->odds_code == $result_match->game_name) {
  652. $condition = $bet_match->condition;
  653. //进球数判断
  654. if (strpos($bet_match->odds_code, '进球数') !== false) {
  655. //返回结果
  656. $data = [
  657. 'result' => 1,
  658. 'matchResult' => "$result_match->result(球队进球数)"
  659. ];
  660. //获取数值
  661. $bet = $this->findNum($condition);
  662. //以上/以下判断
  663. if (strpos($condition, '上') !== false) {
  664. if ($bet < $result_match->result) {
  665. return $data;
  666. }
  667. $data['result'] = -1;
  668. return $data;
  669. }
  670. if (strpos($condition, '下') !== false) {
  671. if ($bet > $result_match->result) {
  672. return $data;
  673. }
  674. $data['result'] = -1;
  675. return $data;
  676. }
  677. //大/小判断
  678. if (strpos($condition, '大') !== false) {
  679. if ($bet < $result_match->result) {
  680. return $data;
  681. }
  682. $data['result'] = -1;
  683. return $data;
  684. }
  685. if (strpos($condition, '小') !== false) {
  686. if ($bet > $result_match->result) {
  687. return $data;
  688. }
  689. $data['result'] = -1;
  690. return $data;
  691. }
  692. }
  693. //积分成绩判断
  694. if (strpos($bet_match->odds_code, '积分') !== false) {
  695. //返回结果
  696. $data = [
  697. 'result' => 1,
  698. 'matchResult' => "$result_match->result(球队积分)"
  699. ];
  700. $condition = $bet_match->condition;
  701. //获取数值
  702. $bet = $this->findNum($condition);
  703. if ($bet == $result_match->result) {
  704. return $data;
  705. }
  706. $data['result'] = -1;
  707. return $data;
  708. }
  709. //如果条件中没有数字,则获取球队/球员结果
  710. if ((preg_match('/\d+/', $condition)) == 0) {
  711. //返回结果
  712. $data = [
  713. 'result' => 1,
  714. 'matchResult' => "$result_match->result(晋级球队)"
  715. ];
  716. $result = $this->teamJudge($condition, $result_match->result);
  717. if ($result) {
  718. return $data;
  719. }
  720. $data['result'] = -1;
  721. return $data;
  722. };
  723. return false;
  724. }
  725. return false;
  726. }
  727. /**
  728. * 冠军盘口 球队/球员结果判断
  729. */
  730. public function teamJudge($condition, $result)
  731. {
  732. //返回结果数组中是否包含该球队
  733. $result = in_array($condition, json_decode($result, true));
  734. return $result;
  735. }
  736. /**
  737. * @param string $str
  738. * @return string
  739. * 处理字符串中的数字
  740. */
  741. public function findNum($str = '')
  742. {
  743. $str = trim($str);
  744. if (empty($str)) {
  745. return '';
  746. }
  747. $result = '';
  748. for ($i = 0; $i < strlen($str); $i++) {
  749. if (is_numeric($str[$i]) || $str[$i] == '.') {
  750. $result .= $str[$i];
  751. }
  752. }
  753. //如果有小数点,返回浮点数
  754. if (strpos($result, '.')) return floatval($result);
  755. //返回整数
  756. return (int)$result;
  757. }
  758. /**
  759. * 角球相关--------->开始
  760. */
  761. public function corner_ball($model, $resultModels, $result_match_r)
  762. {
  763. $odds_code = $model->odds_code;
  764. $isHalf = strpos(strtolower($odds_code), 'half');
  765. if ($isHalf) {
  766. return $this->corner_ball_half($model, $resultModels, $result_match_r);
  767. } else {
  768. return $this->corner_ball_all($model, $resultModels, $result_match_r);
  769. }
  770. }
  771. public function corner_ball_all($model, $resultModels, $result_match_r)
  772. {
  773. $resultModel = $resultModels['0'];
  774. if ($resultModel->corner_ball == '') {
  775. $game_ret = json_decode(json_encode(['home' => 0, 'guest' => 0, 'home_half' => 0, 'guest_half' => 0]));
  776. } else {
  777. $game_ret = json_decode($resultModel->corner_ball);
  778. }
  779. $word = $game_ret->home . '-' . $game_ret->guest . "(全场)";
  780. $returnDatas = ['result' => -1, 'matchResult' => $word];
  781. $odds_code = $model->odds_code;
  782. switch ($odds_code) {
  783. case "corner_concede_home":
  784. $returnDatas = $this->zq_letball($game_ret->home - $game_ret->guest, $model->condition, $word);
  785. break;
  786. case "corner_concede_guest":
  787. $returnDatas = $this->zq_letball($game_ret->guest - $game_ret->home, $model->condition, $word);
  788. break;
  789. case "corner_goal_size_home":
  790. $returnDatas = $this->zq_inball_bigsmall($game_ret->home - $game_ret->guest, $model->condition, 2, $word);
  791. break;
  792. case "corner_goal_size_guest":
  793. $returnDatas = $this->zq_inball_bigsmall($game_ret->guest - $game_ret->home, $model->condition, 1, $word);
  794. break;
  795. case "corner_capot_home":
  796. $returnDatas = $this->zq_duyingv2(1, 4, $resultModel, $word);
  797. break;
  798. case "corner_capot_guest":
  799. $returnDatas = $this->zq_duyingv2(2, 4, $resultModel, $word);
  800. break;
  801. case "corner_capot_dogfall":
  802. $returnDatas['result'] = ($game_ret->home == $game_ret->guest) ? 1 : -1;
  803. break;
  804. case "corner_two_sides_single":
  805. $returnDatas = $this->zq_doublesing($game_ret->home + $game_ret->guest, $model->condition, $word);
  806. break;
  807. case "corner_two_sides_double":
  808. $returnDatas = $this->zq_doublesing($game_ret->home + $game_ret->guest, $model->condition, $word);
  809. break;
  810. default:
  811. $returnDatas = ['result' => 2, 'matchResult' => '(玩法无规则异常)-' . $odds_code];
  812. }
  813. return $returnDatas;
  814. }
  815. public function corner_ball_half($model, $resultModels, $result_match_r)
  816. {
  817. $resultModel = $resultModels['0'];
  818. if ($resultModel->corner_ball == '') {
  819. $game_ret = json_decode(json_encode(['home' => 0, 'guest' => 0, 'home_half' => 0, 'guest_half' => 0]));
  820. } else {
  821. $game_ret = json_decode($resultModel->corner_ball);
  822. }
  823. $word = $game_ret->home_half . '-' . $game_ret->guest_half . "(上半场)";
  824. $returnDatas = ['result' => -1, 'matchResult' => $word];
  825. $odds_code = $model->odds_code;
  826. switch ($odds_code) {
  827. case "corner_half_concede_home":
  828. $returnDatas = $this->zq_letball($game_ret->home_half - $game_ret->guest_half, $model->condition, $word);
  829. break;
  830. case "corner_half_concede_guest":
  831. $returnDatas = $this->zq_letball($game_ret->guest_half - $game_ret->home_half, $model->condition, $word);
  832. break;
  833. case "corner_half_goal_size_home":
  834. $returnDatas = $this->zq_inball_bigsmall($game_ret->home_half - $game_ret->guest_half, $model->condition, 2, $word);
  835. break;
  836. case "corner_half_goal_size_guest":
  837. $returnDatas = $this->zq_inball_bigsmall($game_ret->guest_half - $game_ret->home_half, $model->condition, 1, $word);
  838. break;
  839. case "corner_half_capot_home":
  840. $returnDatas = $this->zq_duyingv2(1, 1, $resultModel, $word);
  841. break;
  842. case "corner_half_capot_guest":
  843. $returnDatas = $this->zq_duyingv2(2, 1, $resultModel, $word);
  844. break;
  845. case "corner_half_capot_dogfall":
  846. $returnDatas['result'] = ($game_ret->home_half == $game_ret->guest_half) ? 1 : -1;
  847. break;
  848. case "corner_half_two_sides_single":
  849. $returnDatas = $this->zq_doublesing($game_ret->home_half + $game_ret->guest_half, $model->condition, $word);
  850. break;
  851. case "corner_half_two_sides_double":
  852. $returnDatas = $this->zq_doublesing($game_ret->home_half + $game_ret->guest_half, $model->condition, $word);
  853. break;
  854. default:
  855. $returnDatas = ['result' => 2, 'matchResult' => '(玩法无规则异常)-' . $odds_code];
  856. }
  857. return $returnDatas;
  858. }
  859. /**
  860. * 角球相关--------->结束
  861. */
  862. //净胜球相关
  863. public function sw_WM($model, $resultModels, $result_match_r)
  864. {
  865. $resultModel = $resultModels['0'];
  866. $home = intval($resultModel->home_score);
  867. $guest = intval($resultModel->guest_score);
  868. $word = $home . '-' . $guest . '(全场)';
  869. $game_odds = $model->odde_code;
  870. switch ($game_odds) {
  871. case 'ior_WMH1':
  872. $ret = $this->zq_jingshengqiu($home, $guest, 1, $word);
  873. break;
  874. case 'ior_WMH2':
  875. $ret = $this->zq_jingshengqiu($home, $guest, 2, $word);
  876. break;
  877. case 'ior_WMH3':
  878. $ret = $this->zq_jingshengqiu($home, $guest, 3, $word);
  879. break;
  880. case 'ior_WMHOV':
  881. $ret = $this->zq_jingshengqiu($home, $guest, 4, $word);
  882. break;
  883. case 'ior_WMC1':
  884. $ret = $this->zq_jingshengqiu($guest, $home, 1, $word);
  885. break;
  886. case 'ior_WMC2':
  887. $ret = $this->zq_jingshengqiu($guest, $home, 2, $word);
  888. break;
  889. case 'ior_WMC3':
  890. $ret = $this->zq_jingshengqiu($guest, $home, 3, $word);
  891. break;
  892. case 'ior_WMCOV':
  893. $ret = $this->zq_jingshengqiu($guest, $home, 4, $word);
  894. break;
  895. case 'ior_WM0':
  896. $ret = $this->zq_jingshengqiu($home, $guest, 0, $word);
  897. break;
  898. case 'ior_WMN':
  899. $ret = $this->zq_jingshengqiu($guest, $home, 99, $word);
  900. break;
  901. default:
  902. $ret = $this->return_error;
  903. break;
  904. }
  905. return $ret;
  906. }
  907. //足球净胜球胜负判断
  908. private function zq_jingshengqiu($winScore, $loseScore, $condNum, $word)
  909. {
  910. if (in_array($condNum, [1, 2, 3])) {
  911. if ($winScore - $loseScore = $condNum) {
  912. return ['result' => 1, 'matchResult' => $word];
  913. } else {
  914. return ['result' => -1, 'matchResult' => $word];
  915. }
  916. }
  917. if ($condNum == 4) {
  918. if ($winScore - $loseScore >= 4) {
  919. return ['result' => 1, 'matchResult' => $word];
  920. } else {
  921. return ['result' => -1, 'matchResult' => $word];
  922. }
  923. }
  924. if ($condNum == 0) {
  925. if ($winScore == 0 && $loseScore == 0) {
  926. return ['result' => 1, 'matchResult' => $word];
  927. } else {
  928. return ['result' => -1, 'matchResult' => $word];
  929. }
  930. }
  931. if ($condNum == 99) {
  932. if ($winScore > 0 && $winScore == $loseScore) {
  933. return ['result' => 1, 'matchResult' => $word];
  934. } else {
  935. return ['result' => -1, 'matchResult' => $word];
  936. }
  937. }
  938. return $this->return_error;
  939. }
  940. /**
  941. * 罚球相关 开始
  942. */
  943. public function penalty_card($model, $resultModels, $result_match_r)
  944. {
  945. $odde_code = $model->odde_code;
  946. $isHalf = strpos(strtolower($odde_code), 'half');
  947. if ($isHalf) {
  948. return $this->penalty_card_half($model, $resultModels, $result_match_r);
  949. } else {
  950. return $this->penalty_card_all($model, $resultModels, $result_match_r);
  951. }
  952. }
  953. public function penalty_card_half($model, $resultModels, $result_match_r)
  954. {
  955. $resultModel = $resultModels['0'];
  956. if ($resultModel->conner_ball == '') {
  957. $game_ret = json_decode(json_encode(['home' => 0, 'guest' => 0, 'home_half' => 0, 'guest_half' => 0]));
  958. } else {
  959. $game_ret = json_decode($resultModel->penalty_card);
  960. }
  961. $word = $game_ret->home_half . '-' . $game_ret->guest_half . "(上半场)";
  962. $returnDatas = ['result' => -1, 'matchResult' => $word];
  963. $odds_code = $model->odds_code;
  964. switch ($odds_code) {
  965. case "penalty_half_concede_home":
  966. $returnDatas = $this->zq_letball($game_ret->home_half - $game_ret->guest_half, $model->condition, $word);
  967. break;
  968. case "penalty_half_concede_guest":
  969. $returnDatas = $this->zq_letball($game_ret->guest_half - $game_ret->home_half, $model->condition, $word);
  970. break;
  971. case "penalty_half_goal_size_home":
  972. $returnDatas = $this->zq_inball_bigsmall($game_ret->home_half - $game_ret->guest_half, $model->condition, 2, $word);
  973. break;
  974. case "penalty_half_goal_size_guest":
  975. $returnDatas = $this->zq_inball_bigsmall($game_ret->guest_half - $game_ret->home_half, $model->condition, 1, $word);
  976. break;
  977. case "penalty_half_capot_home":
  978. $returnDatas = $this->zq_duyingv2(1, 1, $resultModel, $word);
  979. break;
  980. case "penalty_half_capot_guest":
  981. $returnDatas = $this->zq_duyingv2(2, 1, $resultModel, $word);
  982. break;
  983. case "penalty_half_capot_dogfall":
  984. $returnDatas['result'] = ($game_ret->home_half == $game_ret->guest_half) ? 1 : -1;
  985. break;
  986. case "penalty_half_two_sides_single":
  987. $returnDatas = $this->zq_doublesing($game_ret->home_half + $game_ret->guest_half, $model->condition, $word);
  988. break;
  989. case "penalty_half_two_sides_double":
  990. $returnDatas = $this->zq_doublesing($game_ret->home_half + $game_ret->guest_half, $model->condition, $word);
  991. break;
  992. default:
  993. $returnDatas = ['result' => 2, 'matchResult' => '(玩法无规则异常)-' . $odds_code];
  994. }
  995. return $returnDatas;
  996. }
  997. public function penalty_card_all($model, $resultModels, $result_match_r)
  998. {
  999. $resultModel = $resultModels['0'];
  1000. if ($resultModel->conner_ball == '') {
  1001. $game_ret = json_decode(json_encode(['home' => 0, 'guest' => 0, 'home_half' => 0, 'guest_half' => 0]));
  1002. } else {
  1003. $game_ret = json_decode($resultModel->penalty_card);
  1004. }
  1005. $word = $game_ret->home . '-' . $game_ret->guest . "(全场)";
  1006. $returnDatas = ['result' => -1, 'matchResult' => $word];
  1007. $odds_code = $model->odds_code;
  1008. switch ($odds_code) {
  1009. case "penalty_concede_home":
  1010. $returnDatas = $this->zq_letball($game_ret->home - $game_ret->guest, $model->condition, $word);
  1011. break;
  1012. case "penalty_concede_guest":
  1013. $returnDatas = $this->zq_letball($game_ret->guest - $game_ret->home, $model->condition, $word);
  1014. break;
  1015. case "penalty_goal_size_home":
  1016. $returnDatas = $this->zq_inball_bigsmall($game_ret->home - $game_ret->guest, $model->condition, 2, $word);
  1017. break;
  1018. case "penalty_goal_size_guest":
  1019. $returnDatas = $this->zq_inball_bigsmall($game_ret->guest - $game_ret->home, $model->condition, 1, $word);
  1020. break;
  1021. case "penalty_capot_home":
  1022. $returnDatas = $this->zq_duyingv2(1, 4, $resultModel, $word);
  1023. break;
  1024. case "penalty_capot_guest":
  1025. $returnDatas = $this->zq_duyingv2(2, 4, $resultModel, $word);
  1026. break;
  1027. case "penalty_capot_dogfall":
  1028. $returnDatas['result'] = ($game_ret->home == $game_ret->guest) ? 1 : -1;
  1029. break;
  1030. case "penalty_two_sides_single":
  1031. $returnDatas = $this->zq_doublesing($game_ret->home + $game_ret->guest, $model->condition, $word);
  1032. break;
  1033. case "penalty_two_sides_double":
  1034. $returnDatas = $this->zq_doublesing($game_ret->home + $game_ret->guest, $model->condition, $word);
  1035. break;
  1036. default:
  1037. $returnDatas = ['result' => 2, 'matchResult' => '(玩法无规则异常)-' . $odds_code];
  1038. }
  1039. return $returnDatas;
  1040. }
  1041. /**
  1042. * 发球相关 结束
  1043. */
  1044. }