Business.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use app\common\model\BusinessModel;
  5. use think\Db;
  6. /**
  7. * 企业服务
  8. */
  9. class Business extends Api
  10. {
  11. protected $noNeedLogin = ['lists', 'banner', 'listInfo', 'gg', 'parkMessage', 'type', 'protable', 'protableInfo', 'NoticeInfo', 'GgInfo'];
  12. protected $noNeedRight = ['*'];
  13. /**
  14. * 企业服务轮播图
  15. */
  16. public function banner()
  17. {
  18. $data = Db::name('business_banner')
  19. ->order('sort desc')
  20. ->select();
  21. if ($data) {
  22. foreach ($data as &$v) {
  23. $v['image'] = config('site.httpurl') . $v['image'];
  24. }
  25. return $this->success('', $data);
  26. } else {
  27. return $this->success('暂无数据');
  28. }
  29. }
  30. /**
  31. * 企业服务分类
  32. */
  33. public function type()
  34. {
  35. $data = Db::name('business_type')
  36. ->where('switch',1)
  37. ->order('sort desc')
  38. ->select();
  39. if ($data) {
  40. foreach ($data as &$v) {
  41. $v['image'] = config('site.httpurl') . $v['image'];
  42. }
  43. return $this->success('', $data);
  44. } else {
  45. return $this->success('暂无数据');
  46. }
  47. }
  48. /**
  49. * 企业服务列表
  50. * @param string $page 页数
  51. * @param string $limit 条数
  52. * @param string $type 分类id
  53. */
  54. public function lists()
  55. {
  56. $page = $this->request->get('page');
  57. $limit = $this->request->get('limit');
  58. $type = $this->request->get('type');
  59. if (!$page) {
  60. $pages = '0,10';
  61. } else {
  62. $page = $page - 1;
  63. if ($page < 0) $page = 0;
  64. $pages = $page . ',' . $limit;
  65. }
  66. $businessModel = new BusinessModel();
  67. $data = $businessModel->where('switch', 1)
  68. ->where('type_id',$type)
  69. ->order('sort desc')
  70. ->limit($pages)
  71. ->select();
  72. if ($data) {
  73. return $this->success('', $data);
  74. } else {
  75. return $this->success('暂无数据');
  76. }
  77. }
  78. /**
  79. * 企业服务详情
  80. * @param string $id id
  81. *
  82. */
  83. public function listInfo()
  84. {
  85. $id = $this->request->get('id');
  86. if (!isset($id) || empty($id)) return $this->error('缺少参数');
  87. $businessModel = new BusinessModel();
  88. $data = $businessModel
  89. ->where('id', $id)
  90. ->where('switch', 1)
  91. ->order('sort desc')
  92. ->find();
  93. if ($data) {
  94. return $this->success('', $data);
  95. } else {
  96. return $this->success('暂无数据');
  97. }
  98. }
  99. /**
  100. * 政策入住申请
  101. * @ApiMethod (POST)
  102. * @param string $lid id
  103. * @param string $name id
  104. * @param string $mobile id
  105. * @param string $notice id
  106. *
  107. */
  108. public function declare()
  109. {
  110. $data = $this->request->post();
  111. if (!isset($data['lid']) || empty($data['lid'])) return $this->error('参数错误');
  112. if (!isset($data['name']) || empty($data['name'])) return $this->error('请输入姓名');
  113. if (!isset($data['mobile']) || empty($data['mobile'])) return $this->error('请输入手机号');
  114. if (!isset($data['notice']) || empty($data['notice'])) return $this->error('请输入具体需求');
  115. $user = $this->auth->getUser();
  116. if (!$user) return $this->error(__('Please login first'), null, 401);
  117. $data['uid'] = $user['id'];
  118. $data['create_time'] = date('Y-m-d H:i:s',time());
  119. $isert = Db::name('business_declare')->where('uid',$user['id'])->where('lid',$data['lid'])->find();
  120. if ($isert) return $this->error('您已经申请过了');
  121. $add = Db::name('business_declare')->insert($data);
  122. if ($add ) {
  123. $id = Db::name('business_declare')->getLastInsID();
  124. $data['id'] = $id;
  125. return $this->success('提交成功',$data);
  126. } else {
  127. return $this->error('提交失败');
  128. }
  129. }
  130. /**
  131. * 申报返回数据
  132. * @param string $id 注册返回的id
  133. */
  134. public function shenbaoInfo()
  135. {
  136. $data = $this->request->param();
  137. if (!isset($data['id']) || empty($data['id'])) return $this->error('参数错误');
  138. $res = Db::name('business_declare')->where('id',$data['id'])->find();
  139. return $this->success('',$res);
  140. }
  141. }