BuyhouseController.php 24 KB

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