BuyhouseController.php 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <?php
  2. namespace App\Http\Controllers\Web\Content;
  3. use App\Http\Controllers\Web\WebBaseController;
  4. use App\Models\Article;
  5. use App\Models\TalentHouse;
  6. use App\Models\TalentHouseApply;
  7. use App\Services\Content\ArticleService;
  8. use App\Services\Content\ArticleCategoryService;
  9. use App\Services\Content\AdService;
  10. use App\Services\Content\NavigationService;
  11. use Illuminate\Http\Request;
  12. use Illuminate\Support\Facades\Cache;
  13. use Illuminate\Support\Collection;
  14. class BuyhouseController extends WebBaseController
  15. {
  16. private $street = [
  17. '青阳街道', '梅岭街道', '西园街道', '罗山街道', '灵源街道', '新塘街道', '陈埭镇', '池店镇', '安海镇', '磁灶镇', '内坑镇', '紫帽镇', '东石镇', '永和镇', '英林镇', '金井镇', '龙湖镇', '深沪镇', '西滨镇',
  18. ];
  19. private $house_status = ['未知', '未开始', '申报中', '已结束'];
  20. private $tag_status = ['', 'info', 'success', 'danger'];
  21. private $apply_status = ['未知', '审核中', '已通过', '已拒绝'];
  22. private $check_type = ['', 'warning', 'success', 'error'];
  23. protected $articleService;
  24. protected $articleCategoryService;
  25. protected $adService;
  26. protected $navigationService;
  27. /**
  28. * ArticleController constructor.
  29. * @param $articleService
  30. * @param $articleCategoryService
  31. */
  32. public function __construct(ArticleService $articleService, ArticleCategoryService $articleCategoryService, AdService $adService, NavigationService $navigationService)
  33. {
  34. $this->articleService = $articleService;
  35. $this->articleCategoryService = $articleCategoryService;
  36. $this->adService = $adService;
  37. $this->navigationService = $navigationService;
  38. }
  39. /**
  40. * 登录
  41. */
  42. public function login()
  43. {
  44. $user_id = auth('web-member')->id();
  45. $return_data = ['user_id' => $user_id ?: 0, 'apply' => '[]'];
  46. //房源
  47. $house = TalentHouse::orderBy('updated_at', 'desc')->limit(10)->get();
  48. foreach ($house as $v) {
  49. $v['declare_time_text'] = date('Y-m-d', strtotime($v['declare_time']));
  50. $v['status_text'] = $this->house_status[$v['status']];
  51. $v['status_tag'] = $this->tag_status[$v['status']];
  52. $v['url'] = route('buyhouse.list', ['id' => $v['id']]);
  53. }
  54. $return_data['house'] = $house;
  55. //新闻
  56. $news = Article::where('type_id', 56)->select(['id', 'title', 'updated_at'])->orderBy('updated_at', 'desc')->limit(10)->get();
  57. foreach ($news as $v) {
  58. $v['updated_at_text'] = date('Y-m-d', strtotime($v['updated_at']));
  59. $v['url'] = route('news.show', ['id' => $v['id']]);
  60. }
  61. $return_data['news'] = $news;
  62. //我的申报
  63. if ($user_id > 0) {
  64. $apply = TalentHouseApply::with('house')->select(['id', 'house_id', 'status'])->where('user_id', $user_id)->get();
  65. foreach ($apply as $v) {
  66. $v['status_text'] = $this->apply_status[$v['status']];
  67. $v['status_tag'] = $this->tag_status[$v['status']];
  68. $v['url'] = route('buyhouse.list', ['id' => $v['house_id']]);
  69. }
  70. $return_data['apply'] = $apply;
  71. }
  72. return view('app.content.buyhouse.login', $return_data);
  73. }
  74. /**
  75. * 房源信息
  76. */
  77. public function house()
  78. {
  79. return view('app.content.buyhouse.house', [
  80. 'now_cate' => '房源信息',
  81. ]);
  82. }
  83. /**
  84. * 公告
  85. */
  86. public function news()
  87. {
  88. return view('app.content.buyhouse.news', [
  89. 'now_cate' => '公告',
  90. ]);
  91. }
  92. /**
  93. * 报名列表
  94. */
  95. public function list(Request $request)
  96. {
  97. /*$time = time();
  98. $request_post = [
  99. 'idCards' => ['350524198704156033'],
  100. 'sign' => md5("timestr={$time}&key=rsKVyec52fqEKpk4RRD2TU8fKvPxt6ombKg0qSq1velPQtBHVi"),
  101. 'timeStr' => $time,
  102. ];
  103. $res = https_request('http://rc.jucai.gov.cn/api/dataInterface/findTalentInfoByIdCards', json_encode($request_post), ['Accept:application/json', 'Content-Type:application/json;charset=utf-8']);
  104. dd($res);*/
  105. $login = $this->checkLogin();
  106. if ($login) {
  107. return $login;
  108. }
  109. $user_id = auth('web-member')->id();
  110. $id = $request->get('id');
  111. if (empty($id)) {
  112. $back_url = \Illuminate\Support\Facades\URL::previous();
  113. return $this->showMessage('该房源不存在或已删除', $back_url, true, '上一页', '3');
  114. }
  115. //人才判断
  116. //房源信息
  117. $house = TalentHouse::where('id', $id)->first();
  118. if (empty($house)) {
  119. $back_url = \Illuminate\Support\Facades\URL::previous();
  120. return $this->showMessage('该房源不存在或已删除', $back_url, true, '上一页', '3');
  121. }
  122. $house['declare_time_text'] = date('Y-m-d', strtotime($house['declare_time']));
  123. $house['status_text'] = $this->house_status[$house['status']];
  124. $house['status_tag'] = $this->tag_status[$house['status']];
  125. $house['apply_time'] = date('Y-m-d', strtotime($house['apply_time_start'])) . ' - ' . date('Y-m-d', strtotime($house['apply_time_end']));
  126. //报名信息
  127. $apply = TalentHouseApply::where('house_id', $id)->where('user_id', $user_id)->first();
  128. $check = [];
  129. if ($apply) {
  130. $apply['family'] = json_decode($apply['family'], true);
  131. $apply['checked'] = true;
  132. //审核状态
  133. if ($apply['rs_check_status'] != 2) {
  134. $check['status_text'] = '人社局' . $this->apply_status[$apply['rs_check_status']];
  135. $check['comment'] = $apply['rs_check_comment'];
  136. $check['type'] = $this->check_type[$apply['rs_check_status']];
  137. } elseif ($apply['zj_check_status']) {
  138. $check['status_text'] = '住建局' . $this->apply_status[$apply['zj_check_status']];
  139. $check['comment'] = $apply['zj_check_comment'];
  140. $check['type'] = $this->check_type[$apply['zj_check_status']];
  141. } else {
  142. $check['title'] = '';
  143. $check['status_text'] = $this->apply_status[$apply['zj_check_status']];
  144. $check['comment'] = '';
  145. $check['type'] = 'success';
  146. }
  147. } else {
  148. $apply = [
  149. 'family' => [['relation' => '', 'realname' => '', 'idcard' => '']],
  150. 'checked' => true,
  151. ];
  152. }
  153. $return_data = [
  154. 'check' => $check,
  155. 'apply' => json_encode($apply),
  156. 'house' => json_encode($house),
  157. 'module' => ['identification'],
  158. ];
  159. return view('app.content.buyhouse.list', $return_data);
  160. }
  161. public function listPost(Request $request)
  162. {
  163. $data = $request->only(['id', 'house_id', 'name', 'mobile', 'native', 'email', 'talent_level', 'talent_card_validity', 'talent_tags', 'talent_condition', 'certificates', 'marry', 'marry_prove', 'household_register', 'family', 'work_prove', 'street', 'house_condition', 'house_policy']);
  164. $rules = [
  165. 'certificates' => 'required',
  166. 'marry' => 'required',
  167. 'household_register' => 'required',
  168. 'work_prove' => 'required',
  169. 'street' => 'required',
  170. 'house_condition' => 'required',
  171. 'house_policy' => 'required',
  172. ];
  173. $messages = [
  174. 'certificates.required' => '请上传证件信息',
  175. 'marry.required' => '请选择婚姻状况',
  176. 'household_register.required' => '请上传户口本',
  177. 'work_prove.required' => '请上传人才工作单位',
  178. 'street.required' => '请填写所属街道',
  179. 'house_condition.required' => '请填写家庭成员在晋江市行政区域内住房情况',
  180. 'house_policy.required' => '请填写在晋享受政策性住房或相关优惠情况',
  181. ];
  182. return response()->json(['status' => 1]);
  183. }
  184. /**
  185. * 登录状态
  186. */
  187. private function checkLogin()
  188. {
  189. $user_id = auth('web-member')->id();
  190. if (empty($user_id)) {
  191. return redirect(route('buyhouse.login'));
  192. }
  193. return false;
  194. }
  195. }