BuyhouseController.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  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\MemberInfo;
  6. use App\Models\SmsTemplate;
  7. use App\Models\TalentHouse;
  8. use App\Models\TalentHouseApply;
  9. use App\Models\TalentHousePeople;
  10. use App\Services\Content\ArticleService;
  11. use Illuminate\Http\Request;
  12. use Illuminate\Support\Facades\DB;
  13. use Illuminate\Support\Facades\Storage;
  14. use Illuminate\Support\Facades\Validator;
  15. class BuyhouseController extends WebBaseController
  16. {
  17. private $street = [
  18. '青阳街道', '梅岭街道', '西园街道', '罗山街道', '灵源街道', '新塘街道', '陈埭镇', '池店镇', '安海镇', '磁灶镇', '内坑镇', '紫帽镇', '东石镇', '永和镇', '英林镇', '金井镇', '龙湖镇', '深沪镇', '西滨镇',
  19. ];
  20. private $house_status = ['未知', '未开始', '申报中', '已结束'];
  21. private $tag_status = ['', 'info', 'success', 'danger', 'danger'];
  22. private $apply_status = ['未知', '审核中', '审核通过', '审核驳回', '审核不通过'];
  23. private $check_type = ['', 'warning', 'success', 'error', 'error'];
  24. private $talent_level = ['不是人才', '第一层次', '第二层次', '第三层次', '第四层次', '第五层次', '第六层次', '第七层次'];
  25. protected $articleService;
  26. /**
  27. * ArticleController constructor.
  28. * @param $articleService
  29. * @param $articleCategoryService
  30. */
  31. public function __construct(ArticleService $articleService)
  32. {
  33. $this->articleService = $articleService;
  34. }
  35. /**
  36. * 登录
  37. */
  38. public function login()
  39. {
  40. $user_id = auth('web-member')->id();
  41. $return_data = ['user_id' => $user_id ?: 0, 'apply' => '[]'];
  42. //房源
  43. $house = TalentHouse::orderBy('apply_time_start', 'desc')->limit(8)->get();
  44. foreach ($house as $v) {
  45. $v['status'] = $this->_get_status($v);
  46. $v['apply_time_start'] = date('Y-m-d', strtotime($v['apply_time_start']));
  47. $v['apply_time_end'] = date('Y-m-d', strtotime($v['apply_time_end']));
  48. $v['status_text'] = $this->house_status[$v['status']];
  49. $v['status_tag'] = $this->tag_status[$v['status']];
  50. $v['url'] = route('buyhouse.detail', ['id' => $v['id']]);
  51. }
  52. $return_data['house'] = $house;
  53. //新闻
  54. $news = Article::where('type_id', 56)
  55. ->where('is_display', 1)
  56. ->select(['id', 'title', 'updated_at', 'created_at'])
  57. ->orderByRaw('list_order desc,created_at desc')
  58. ->limit(6)
  59. ->get();
  60. foreach ($news as $v) {
  61. $v['created_at_text'] = date('Y-m-d', strtotime($v['created_at']));
  62. $v['updated_at_text'] = date('Y-m-d', strtotime($v['updated_at']));
  63. $v['url'] = route('news.show', ['id' => $v['id']]);
  64. }
  65. $return_data['news'] = $news;
  66. //我的申报
  67. if ($user_id > 0) {
  68. $apply = TalentHouseApply::with('house')
  69. ->select(['id', 'house_id', 'status'])
  70. ->where('is_draft', 2)
  71. ->where('is_back', 2)
  72. ->where('user_id', $user_id)
  73. ->get();
  74. foreach ($apply as $v) {
  75. $v['status_text'] = $this->apply_status[$v['status']];
  76. $v['status_tag'] = $this->tag_status[$v['status']];
  77. $v['url'] = route('buyhouse.list', ['id' => $v['house_id']]);
  78. }
  79. $return_data['apply'] = $apply;
  80. //用户信息
  81. $memberInfo = MemberInfo::where('uid', $user_id)->first();
  82. $return_data['member_info'] = $memberInfo;
  83. }
  84. return view('app.content.buyhouse.login', $return_data);
  85. }
  86. /**
  87. * 完善信息
  88. */
  89. public function perfect(Request $request)
  90. {
  91. $user_id = auth('web-member')->id();
  92. if (empty($user_id)) {
  93. return response()->json(['status' => 0, 'msg' => '请先登录']);
  94. }
  95. $data = $request->only(['realname', 'card_t_cn', 'id_card']);
  96. MemberInfo::where('uid', $user_id)->update($data);
  97. return response()->json(['status' => 1, 'msg' => '修改成功']);
  98. }
  99. /**
  100. * 房源信息
  101. */
  102. public function house()
  103. {
  104. $lists = TalentHouse::orderBy('apply_time_start', 'desc')->paginate(10);
  105. foreach ($lists as $v) {
  106. $v['status'] = $this->_get_status($v);
  107. $v['apply_time_start'] = date('Y-m-d', strtotime($v['apply_time_start']));
  108. $v['apply_time_end'] = date('Y-m-d', strtotime($v['apply_time_end']));
  109. $v['status_text'] = $this->house_status[$v['status']];
  110. $v['status_tag'] = $this->tag_status[$v['status']];
  111. }
  112. $return_data = [
  113. 'articles' => $lists,
  114. 'now_cate' => '房源信息',
  115. ];
  116. return view('app.content.buyhouse.house', $return_data);
  117. }
  118. /**
  119. * 公告
  120. */
  121. public function news()
  122. {
  123. $lists = $this->articleService->list('', 56, '10');
  124. $return_data = [
  125. 'articles' => $lists,
  126. 'now_cate' => '公告',
  127. ];
  128. return view('app.content.buyhouse.news', $return_data);
  129. }
  130. public function detail(Request $request)
  131. {
  132. $id = $request->get('id');
  133. if (empty($id)) {
  134. $back_url = \Illuminate\Support\Facades\URL::previous();
  135. return $this->showMessage('该房源不存在或已删除', $back_url, true, '上一页', '3');
  136. }
  137. //房源信息
  138. $house = TalentHouse::where('id', $id)->first();
  139. if (empty($house)) {
  140. $back_url = \Illuminate\Support\Facades\URL::previous();
  141. return $this->showMessage('该房源不存在或已删除', $back_url, true, '上一页', '3');
  142. }
  143. $house['status'] = $this->_get_status($house);
  144. $house['status_text'] = $this->house_status[$house['status']];
  145. $house['status_tag'] = $this->tag_status[$house['status']];
  146. $house['url'] = route('buyhouse.list', ['id' => $house['id']]);
  147. $house['apply_time'] = date('Y-m-d', strtotime($house['apply_time_start'])) . ' - ' . date('Y-m-d', strtotime($house['apply_time_end']));
  148. $return_data = [
  149. 'info' => $house,
  150. ];
  151. return view('app.content.buyhouse.detail', $return_data);
  152. }
  153. /**
  154. * 报名列表
  155. */
  156. public function list(Request $request)
  157. {
  158. $login = $this->checkLogin();
  159. if ($login) {
  160. return $login;
  161. }
  162. $user_id = auth('web-member')->id();
  163. if (empty($user_id)) {
  164. $back_url = route('buyhouse.login');
  165. return $this->showMessage('登录过期,请先登录', $back_url, true, '上一页', '3');
  166. }
  167. //拉黑
  168. $people = TalentHousePeople::where('user_id', $user_id)->first();
  169. if (!empty($people) && $people['status'] == 2) {
  170. $back_url = \Illuminate\Support\Facades\URL::previous();
  171. return $this->showMessage('无法进入申报系统,请联系相关单位', $back_url, true, '上一页', '3');
  172. }
  173. $id = $request->get('id');
  174. if (empty($id)) {
  175. $back_url = \Illuminate\Support\Facades\URL::previous();
  176. return $this->showMessage('该房源不存在或已删除', $back_url, true, '上一页', '3');
  177. }
  178. //是否报名其他
  179. $sock = TalentHouseApply::where('user_id', $user_id)->where('house_id', '<>', $id)->where('is_sock', 1)->where('is_draft', 2)->first();
  180. if (!empty($sock)) {
  181. $back_url = \Illuminate\Support\Facades\URL::previous();
  182. return $this->showMessage('不可以同时申报多个房源', $back_url, true, '上一页', '3');
  183. }
  184. //房源信息
  185. $house = TalentHouse::where('id', $id)->first();
  186. if (empty($house)) {
  187. $back_url = \Illuminate\Support\Facades\URL::previous();
  188. return $this->showMessage('该房源不存在或已删除', $back_url, true, '上一页', '3');
  189. }
  190. $house['declare_time_text'] = date('Y-m-d', strtotime($house['declare_time']));
  191. $house['status'] = $this->_get_status($house);
  192. $house['status_text'] = $this->house_status[$house['status']];
  193. $house['status_tag'] = $this->tag_status[$house['status']];
  194. $house['apply_time'] = date('Y-m-d', strtotime($house['apply_time_start'])) . ' - ' . date('Y-m-d', strtotime($house['apply_time_end']));
  195. //报名信息
  196. $apply = TalentHouseApply::where('house_id', $id)->where('is_back', 2)->where('user_id', $user_id)->first();
  197. $check = [];
  198. $time = time();
  199. if ($apply) {
  200. if ($house['status'] != 2 && $apply['is_draft'] == 1) {
  201. $back_url = \Illuminate\Support\Facades\URL::previous();
  202. return $this->showMessage('该房源未在申报时间', $back_url, true, '上一页', '3');
  203. }
  204. //审核状态
  205. if ($apply['is_draft'] == 2) {
  206. if ($apply['rs_check_status'] != 2) {
  207. if ($apply['type'] == 1) {
  208. $check['status_text'] = '人社局' . $this->apply_status[$apply['rs_check_status']];
  209. } else {
  210. $check['status_text'] = '集成电路' . $this->apply_status[$apply['rs_check_status']];
  211. }
  212. $check['comment'] = $apply['rs_check_status'] == 1 ? '' : $apply['rs_check_comment'];
  213. $check['type'] = $this->check_type[$apply['rs_check_status']];
  214. } elseif ($apply['zj_check_status'] != 2 || $apply['zr_check_status'] != 2) {
  215. $check['status_text'] = '住建局' . $this->apply_status[$apply['zj_check_status']] . '<br/>' . '自然资源局' . $this->apply_status[$apply['zr_check_status']];
  216. $comment = [];
  217. if ($apply['zj_check_status'] != 1 && !empty($apply['zj_check_comment'])) {
  218. $comment[] = '住建局:' . $apply['zj_check_comment'];
  219. }
  220. if ($apply['zr_check_status'] != 1 && !empty($apply['zr_check_comment'])) {
  221. $comment[] = '自然资源局:' . $apply['zr_check_comment'];
  222. }
  223. $check['comment'] = implode(';', $comment);
  224. $check_status = $apply['zj_check_status'] > $apply['zr_check_status'] ? $apply['zj_check_status'] : $apply['zr_check_status'];
  225. $check['type'] = $this->check_type[$check_status];
  226. } else {
  227. $check['title'] = '';
  228. $check['status_text'] = '审核通过';
  229. $check['comment'] = '';
  230. $check['type'] = 'success';
  231. }
  232. }
  233. } else {
  234. if ($house['status'] != 2) {
  235. $back_url = \Illuminate\Support\Facades\URL::previous();
  236. return $this->showMessage('该房源未在申报时间', $back_url, true, '上一页', '3');
  237. }
  238. $infos = MemberInfo::where('uid', $user_id)->first();
  239. if (empty($infos['id_card'])) {
  240. $back_url = route('person.resume');
  241. return $this->showMessage('请先填写身份证号', $back_url, true, '上一页', '3');
  242. }
  243. $request_post = [
  244. 'idCards' => [$infos['id_card']],
  245. 'sign' => mb_strtoupper(md5("timestr={$time}&key=rsKVyec52fqEKpk4RRD2TU8fKvPxt6ombKg0qSq1velPQtBHVi")),
  246. 'timeStr' => (string)$time,
  247. ];
  248. $res = https_request('https://rc.jucai.gov.cn/api/dataInterface/findTalentInfoByIdCards', json_encode($request_post), ['Content-Type:application/json']);
  249. $talent = json_decode($res, true);
  250. if (empty($talent['obj'])) {
  251. $back_url = \Illuminate\Support\Facades\URL::previous();
  252. return $this->showMessage('您还未认定人才,暂无申报资格', $back_url, true, '上一页', '3');
  253. }
  254. $talent = $talent['obj'][0];
  255. if ($talent['talentArrange'] > 5) {
  256. $back_url = \Illuminate\Support\Facades\URL::previous();
  257. return $this->showMessage('目前仅支持一到五层次人才申报', $back_url, true, '上一页', '3');
  258. }
  259. if ($talent['type'] > 2) {
  260. $back_url = \Illuminate\Support\Facades\URL::previous();
  261. return $this->showMessage('其他人才暂不支持', $back_url, true, '上一页', '3');
  262. }
  263. if (!empty($talent['activeDate']) && strtotime($talent['activeDate']) < time()) {
  264. $back_url = \Illuminate\Support\Facades\URL::previous();
  265. return $this->showMessage('人才证有效期为' . $talent['activeDate'] . ',人才证已过期,请重新认证', $back_url, true, '上一页', '3');
  266. }
  267. $add = [
  268. 'user_id' => $user_id,
  269. 'house_id' => $id,
  270. 'type' => $talent['type'],
  271. 'name' => $talent['name'],
  272. 'mobile' => $talent['phone'],
  273. 'native' => $talent['nativePlace'],
  274. 'email' => $talent['email'],
  275. 'talent_level' => $this->talent_level[$talent['talentArrange']],
  276. 'talent_card_validity' => $talent['activeDate'],
  277. 'talent_tags' => $talent['talentType'],
  278. 'talent_condition' => $talent['identifyCondition'],
  279. 'company' => $talent['company'],
  280. 'street' => $talent['street'],
  281. 'family' => json_encode([['relation' => '配偶', 'realname' => '', 'idcard' => '']]),
  282. 'certificates' => '[]',
  283. 'marry_prove' => '[]',
  284. 'household_register' => '[]',
  285. 'work_prove' => '[]',
  286. 'created_at' => date('Y-m-d H:i:s'),
  287. 'updated_at' => date('Y-m-d H:i:s'),
  288. ];
  289. $id = TalentHouseApply::insertGetId($add);
  290. $apply = TalentHouseApply::find($id);
  291. //报名人员列表
  292. $memberInfo = MemberInfo::where('uid', $user_id)->first();
  293. if (empty($people)) {
  294. TalentHousePeople::insert([
  295. 'user_id' => $user_id,
  296. 'realname' => $memberInfo['realname'] ?: '',
  297. 'mobile' => $memberInfo['phone'] ?: '',
  298. 'email' => $memberInfo['email'] ?: '',
  299. 'card_t_cn' => $memberInfo['card_t_cn'] ?: 306,
  300. 'id_card' => $memberInfo['id_card'] ?: '',
  301. 'created_at' => date('Y-m-d H:i:s'),
  302. 'updated_at' => date('Y-m-d H:i:s'),
  303. ]);
  304. } else {
  305. TalentHousePeople::where('user_id', $user_id)->update([
  306. 'realname' => $memberInfo['realname'] ?: '',
  307. 'mobile' => $memberInfo['mobile'] ?: '',
  308. 'email' => $memberInfo['email'] ?: '',
  309. 'card_t_cn' => $memberInfo['card_t_cn'] ?: 306,
  310. 'id_card' => $memberInfo['id_card'] ?: '',
  311. 'updated_at' => date('Y-m-d H:i:s'),
  312. ]);
  313. }
  314. }
  315. $apply['family'] = json_decode($apply['family'], true);
  316. $apply['certificates'] = json_decode($apply['certificates'], true);
  317. $apply['marry_prove'] = json_decode($apply['marry_prove'], true);
  318. $apply['household_register'] = json_decode($apply['household_register'], true);
  319. $apply['work_prove'] = json_decode($apply['work_prove'], true);
  320. $apply['checked'] = true;
  321. //是否可填表格
  322. $formDisable = 'true';
  323. if ($apply['is_draft'] == 1) {
  324. //草稿
  325. $formDisable = 'false';
  326. } else {
  327. if ($time < strtotime($house['apply_time_end']) && $apply['status'] == 3) {
  328. $formDisable = 'false';
  329. } else {
  330. if ($time < strtotime($house['supply_time']) && ($apply['rs_check_status'] == 3 || $apply['zj_check_status'] == 3)) {
  331. $formDisable = 'false';
  332. }
  333. }
  334. }
  335. $return_data = [
  336. 'formDisable' => $formDisable,
  337. 'check' => $check,
  338. 'apply' => json_encode($apply),
  339. 'house' => json_encode($house),
  340. 'module' => ['identification'],
  341. ];
  342. return view('app.content.buyhouse.list', $return_data);
  343. }
  344. /**
  345. * 申报提交
  346. */
  347. public function listPost(Request $request)
  348. {
  349. //数据校验
  350. $data = $request->only(['id', 'certificates', 'marry', 'child_num', 'marry_prove', 'household_register', 'family', 'work_prove', 'company', 'street', 'house_condition', 'house_policy']);
  351. $rules = [
  352. 'certificates' => 'required',
  353. 'marry' => 'required',
  354. 'household_register' => 'required',
  355. 'work_prove' => 'required',
  356. 'house_condition' => 'required',
  357. 'house_policy' => 'required',
  358. ];
  359. $messages = [
  360. 'certificates.required' => '请上传证件信息',
  361. 'marry.required' => '请选择婚姻状况',
  362. 'household_register.required' => '请上传户口本',
  363. 'work_prove.required' => '请上传工作证明',
  364. 'house_condition.required' => '请填写家庭成员在晋江市行政区域内住房情况',
  365. 'house_policy.required' => '请填写在晋享受政策性住房或相关优惠情况',
  366. ];
  367. $validator = Validator::make($data, $rules, $messages);
  368. if ($validator->fails()) {
  369. $msg = $validator->errors()->all();
  370. return response()->json(['status' => 0, 'msg' => $msg[0]]);
  371. }
  372. if ($data['marry'] > 1 && empty($data['marry_prove'])) {
  373. return response()->json(['status' => 0, 'msg' => '请上传婚姻证明']);
  374. }
  375. //报名信息
  376. $info = TalentHouseApply::find($data['id']);
  377. if (empty($info)) {
  378. return response()->json(['status' => 0, 'msg' => '提交格式有误']);
  379. }
  380. //房源消息
  381. $house = TalentHouse::find($info['house_id']);
  382. $house['status'] = $this->_get_status($house);
  383. $time = time();
  384. if (strtotime($house['apply_time_start']) > $time) {
  385. return response()->json(['status' => 0, 'msg' => '申报未开始,无法修改']);
  386. }
  387. if ($time > strtotime($house['supply_time'])) {
  388. return response()->json(['status' => 0, 'msg' => '已超过补件时间,无法修改']);
  389. }
  390. //日志
  391. $log = [
  392. 'house_name' => $house['name'],
  393. 'user_name' => $info['name'],
  394. 'old' => $info['is_draft'] == 1 ? '' : json_encode($info),
  395. 'created_at' => date('Y-m-d H:i:s'),
  396. ];
  397. //图片
  398. $images = ['certificates', 'household_register', 'marry_prove', 'work_prove'];
  399. foreach ($images as $image) {
  400. if (!empty($data[$image]) && is_array($data[$image])) {
  401. //删除掉没有成功返回路径的图片
  402. foreach ($data[$image] as $k => $v) {
  403. if (!array_key_exists('response', $v)) {
  404. unset($data[$image][$k]);
  405. }
  406. }
  407. $data[$image] = array_values($data[$image]);
  408. }
  409. }
  410. //更新数据
  411. $info->certificates = json_encode($data['certificates']);
  412. $info->marry = $data['marry'];
  413. if ($data['marry'] > 1) {
  414. $info->marry_prove = json_encode($data['marry_prove']);
  415. }
  416. $info->household_register = json_encode($data['household_register']);
  417. $info->family = json_encode($data['family']);
  418. $info->work_prove = json_encode($data['work_prove']);
  419. $info->street = $data['street'];
  420. $info->child_num = $data['child_num'];
  421. $info->company = $data['company'];
  422. $info->house_condition = $data['house_condition'];
  423. $info->house_policy = $data['house_policy'];
  424. $info->status = 1;
  425. //审核状态
  426. if ($info->rs_check_status == 1 && $info->type == 1) {
  427. SmsTemplate::buyHouseCheck('rs');
  428. }
  429. if ($info->rs_check_status == 3) {
  430. $info->rs_check_status = 1;
  431. if ($info->type == 1) {
  432. SmsTemplate::buyHouseCheck('rs');
  433. }
  434. }
  435. if ($info->zj_check_status == 3) {
  436. $info->zj_check_status = 1;
  437. SmsTemplate::buyHouseCheck('zj');
  438. }
  439. if ($info->zr_check_status == 3) {
  440. $info->zr_check_status = 1;
  441. SmsTemplate::buyHouseCheck('zr');
  442. }
  443. if ($info->is_draft == 1) {
  444. $info->is_draft = 2;
  445. }
  446. if ($info->is_sock == 2) {
  447. $info->is_sock = 1;
  448. }
  449. $info->save();
  450. //日志
  451. $log['new'] = json_encode($info);
  452. DB::table('talent_house_log')->insert($log);
  453. return response()->json(['status' => 1]);
  454. }
  455. /**
  456. * 撤消
  457. */
  458. public function back(Request $request)
  459. {
  460. $id = $request->get('id');
  461. if (empty($id)) {
  462. return response()->json(['status' => 1]);
  463. }
  464. $apply = TalentHouseApply::find($id);
  465. if (empty($apply) || $apply['user_id'] != auth('web-member')->id() || $apply['is_back'] == 1) {
  466. return response()->json(['status' => 1]);
  467. }
  468. if ($apply['status'] == 2) {
  469. return response()->json(['status' => 0, 'msg' => '已通过审核的申报无法撤消']);
  470. }
  471. if ($apply['status'] == 4) {
  472. return response()->json(['status' => 0, 'msg' => '审核不通过的申报无法撤消']);
  473. }
  474. $house = TalentHouse::find($apply['house_id']);
  475. if (strtotime($house['supply_time']) < time()) {
  476. return response()->json(['status' => 0, 'msg' => '已过补件时间,申报无法撤消']);
  477. }
  478. $apply->is_back = 1;
  479. $apply->is_sock = 2;
  480. $apply->save();
  481. return response()->json(['status' => 1]);
  482. }
  483. /**
  484. * 图片上传
  485. */
  486. public function upload(Request $request)
  487. {
  488. header('Access-Control-Allow-Origin:*');
  489. header('Access-Control-Allow-Methods:GET,POST,PUT,DELETE');
  490. header('Access-Control-Allow-Headers:Origin, Content-Type, Cookie, Accept, X-CSRF-TOKEN');
  491. header('Access-Control-Allow-Credentials:true');
  492. $file = $request->file('file');
  493. if ($file->isValid()) { //判断文件是否存在
  494. //获取文件的扩展名
  495. $ext = $file->getClientOriginalExtension();
  496. if (!in_array(strtolower($ext), ['jpg', 'jpeg', 'png', 'doc', 'docx', 'pdf'])) {
  497. $res['status'] = 0;
  498. $res['msg'] = '文件格式不正确';
  499. } else {
  500. //获取文件的绝对路径
  501. $path = $file->getRealPath();
  502. $oldname = $file->getClientOriginalName();
  503. //定义文件名
  504. $filename = 'storage/buyhouse/' . uniqid() . mt_rand(10000, 99999) . '.' . $ext;
  505. //存储文件。disk里面的public。总的来说,就是调用disk模块里的public配置
  506. Storage::disk('public')->put($filename, file_get_contents($path));
  507. $res['status'] = 1;
  508. $res['filename'] = $oldname;
  509. $res['path'] = "/storage/" . $filename;
  510. $res['msg'] = '上传成功';
  511. }
  512. } else {
  513. $res['status'] = 0;
  514. $res['msg'] = '上传失败';
  515. }
  516. return response()->json($res);
  517. }
  518. /**
  519. * 登录状态
  520. */
  521. private function checkLogin()
  522. {
  523. $user_id = auth('web-member')->id();
  524. if (empty($user_id)) {
  525. return redirect(route('buyhouse.login'));
  526. }
  527. return false;
  528. }
  529. /**
  530. * 状态
  531. */
  532. private function _get_status($row)
  533. {
  534. $time = time();
  535. if (strtotime($row['apply_time_start']) > $time) {
  536. return 1;
  537. } elseif (strtotime($row['apply_time_end']) < $time) {
  538. return 3;
  539. } else {
  540. return 2;
  541. }
  542. }
  543. }