RuleMatch.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace App\Sports\Controller;
  3. use BaseController\Controller;
  4. use Biz\Match\GetmatchData;
  5. use Biz\Match\GetOddsData;
  6. /**
  7. * 前台赛事规则数据接口
  8. * User: tank
  9. * Date: 2019/10/11
  10. */
  11. class RuleMatch extends Controller{
  12. public function init() {
  13. $this->commonFunction = C()->get('commonFunction');
  14. $this->getTypeData = new GetmatchData();
  15. $this->getOddsData = new GetOddsData();
  16. }
  17. /**
  18. * 获取各球类玩法规则数据
  19. */
  20. public function getMatchRule(){
  21. //请求模块名称
  22. $modular = $_REQUEST['modular']?:'体育';
  23. //请求规则组名称
  24. $group = $_REQUEST['group']?:'一般体育说明';
  25. try {
  26. if(empty($modular) || empty($group)){
  27. throw new \Exception(Render([], '10001', lang('Tips','Sports')->get('PARAM_ERROR')));
  28. }
  29. //拼装查询条件
  30. $where = [
  31. ['modular_name','=',$modular],
  32. ['group_name','=',$group],
  33. ];
  34. //获取各球类规则
  35. $match_rule = lm('st_match_rule',"Sports")
  36. ->select('modular_name','group_name','author','atime','utime','status','content')
  37. ->where($where)
  38. ->first()
  39. ->toArray();
  40. //获取所有模块/分组
  41. $rule_menu = lm('st_match_rule_group',"Sports")
  42. ->select('modular_id','modular_name','id as group_id','group_name')
  43. ->get()
  44. ->toArray();
  45. //获取模块
  46. $modular_data = $this->commonFunction->array_unset_tt($rule_menu,'modular_name');
  47. $rule_menu_data = [];
  48. foreach($modular_data as $k=>$v){
  49. $dd['modular_id'] = $v['modular_id'];
  50. $dd['modular_name'] = $v['modular_name'];
  51. foreach($rule_menu as $kk=>$vv){
  52. $ddd['group_id'] = $vv['group_id'];
  53. $ddd['group_name'] = $vv['group_name'];
  54. if($vv['modular_name'] == $k){
  55. $dd['group'][] = $ddd;
  56. }
  57. }
  58. $rule_menu_data[] = $dd;
  59. }
  60. $data = [
  61. 'rule_menu' =>$rule_menu_data,
  62. 'match_rule'=>$match_rule
  63. ];
  64. Render($data, '1', lang('Tips','Sports')->get('success'));
  65. } catch (\Exception $e) {
  66. echo $e->getMessage();
  67. }
  68. }
  69. }