Relational.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * 游戏包关联查询
  4. * Created by PhpStorm.
  5. * User: hhhhh
  6. * Date: 2019/1/8
  7. * Time: 18:02
  8. */
  9. namespace app\admin\controller;
  10. use app\common\model\PromotionShortLink;
  11. class Relational extends Admin
  12. {
  13. protected function _initialize()
  14. {
  15. parent::_initialize(); // TODO: Change the autogenerated stub
  16. $this->packageModel = model('SdkGameList');
  17. }
  18. /**
  19. *关联查询
  20. */
  21. public function index(){
  22. $condition = [];
  23. $url_type = input('url_type',0,'intval');
  24. $filename = input('filename');
  25. $result = $this->validate(['filename'=>$filename], [
  26. ['filename', 'url', '链接地址格式不正确']
  27. ]);
  28. if (true !== $result) {
  29. $this->error($result);
  30. }
  31. if (!empty($filename)){
  32. //推广页链接
  33. if($url_type==1){
  34. $shortLinkModel = new PromotionShortLink;
  35. $short_link = pathinfo($filename)['filename'];
  36. $list = $shortLinkModel->field('game_id as gameid,package_type,channel_id,create_time as update_time')->where(['short_link'=>$short_link])->order('id desc')->paginate(10, false, ['query' => input('get.')]);
  37. }
  38. //游戏包链接
  39. else{
  40. if (!empty($filename)){
  41. if (preg_match('/^(http|https|ftp):\/\/[\w.]+[\w\/]*[\w.]*\??[\w=&\+\%]*/is', $filename)) {
  42. $filename =explode('/',$filename);
  43. $filename = end($filename);
  44. $condition['filename'] = $filename;
  45. } else {
  46. $this->error('请输入正确的网址');
  47. }
  48. }
  49. $list = $this->packageModel
  50. ->where($condition)
  51. ->order('id desc')
  52. ->paginate(10, false, ['query' => input('get.')]);
  53. }
  54. $total = $list->total();
  55. $page = $list->render();
  56. }
  57. else{
  58. $list = [];
  59. $total = 0;
  60. $page = 0;
  61. }
  62. $this->assign('list', $list);
  63. $this->assign('total', $total);
  64. $this->assign('page',$page);
  65. return $this->fetch('index');
  66. }
  67. }