| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 | <?phpnamespace App\Http\Controllers\Web\Content;use App\Http\Controllers\Web\WebBaseController;use App\Models\Article;use App\Models\TalentHouse;use App\Models\TalentHouseApply;use App\Services\Content\ArticleService;use App\Services\Content\ArticleCategoryService;use App\Services\Content\AdService;use App\Services\Content\NavigationService;use Illuminate\Http\Request;use Illuminate\Support\Facades\Cache;use Illuminate\Support\Collection;class BuyhouseController extends WebBaseController{    private $street = [        '青阳街道', '梅岭街道', '西园街道', '罗山街道', '灵源街道', '新塘街道', '陈埭镇', '池店镇', '安海镇', '磁灶镇', '内坑镇', '紫帽镇', '东石镇', '永和镇', '英林镇', '金井镇', '龙湖镇', '深沪镇', '西滨镇',    ];    private $house_status = ['未知', '未开始', '申报中', '已结束'];    private $tag_status = ['', 'info', 'success', 'danger'];    private $apply_status = ['未知', '审核中', '已通过', '已拒绝'];    private $check_type = ['', 'warning', 'success', 'error'];    protected $articleService;    protected $articleCategoryService;    protected $adService;    protected $navigationService;    /**     * ArticleController constructor.     * @param $articleService     * @param $articleCategoryService     */    public function __construct(ArticleService $articleService, ArticleCategoryService $articleCategoryService, AdService $adService, NavigationService $navigationService)    {        $this->articleService         = $articleService;        $this->articleCategoryService = $articleCategoryService;        $this->adService              = $adService;        $this->navigationService      = $navigationService;    }    /**     * 登录     */    public function login()    {        $user_id     = auth('web-member')->id();        $return_data = ['user_id' => $user_id ?: 0, 'apply' => '[]'];        //房源        $house = TalentHouse::orderBy('updated_at', 'desc')->limit(10)->get();        foreach ($house as $v) {            $v['declare_time_text'] = date('Y-m-d', strtotime($v['declare_time']));            $v['status_text']       = $this->house_status[$v['status']];            $v['status_tag']        = $this->tag_status[$v['status']];            $v['url']               = route('buyhouse.list', ['id' => $v['id']]);        }        $return_data['house'] = $house;        //新闻        $news = Article::where('type_id', 56)->select(['id', 'title', 'updated_at'])->orderBy('updated_at', 'desc')->limit(10)->get();        foreach ($news as $v) {            $v['updated_at_text'] = date('Y-m-d', strtotime($v['updated_at']));            $v['url']             = route('news.show', ['id' => $v['id']]);        }        $return_data['news'] = $news;        //我的申报        if ($user_id > 0) {            $apply = TalentHouseApply::with('house')->select(['id', 'house_id', 'status'])->where('user_id', $user_id)->get();            foreach ($apply as $v) {                $v['status_text'] = $this->apply_status[$v['status']];                $v['status_tag']  = $this->tag_status[$v['status']];                $v['url']         = route('buyhouse.list', ['id' => $v['house_id']]);            }            $return_data['apply'] = $apply;        }        return view('app.content.buyhouse.login', $return_data);    }    /**     * 房源信息     */    public function house()    {        return view('app.content.buyhouse.house', [            'now_cate' => '房源信息',        ]);    }    /**     * 公告     */    public function news()    {        return view('app.content.buyhouse.news', [            'now_cate' => '公告',        ]);    }    /**     * 报名列表     */    public function list(Request $request)    {        /*$time         = time();        $request_post = [            'idCards' => ['350524198704156033'],            'sign'    => md5("timestr={$time}&key=rsKVyec52fqEKpk4RRD2TU8fKvPxt6ombKg0qSq1velPQtBHVi"),            'timeStr' => $time,        ];        $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']);        dd($res);*/        $login = $this->checkLogin();        if ($login) {            return $login;        }        $user_id = auth('web-member')->id();        $id      = $request->get('id');        if (empty($id)) {            $back_url = \Illuminate\Support\Facades\URL::previous();            return $this->showMessage('该房源不存在或已删除', $back_url, true, '上一页', '3');        }        //人才判断        //房源信息        $house = TalentHouse::where('id', $id)->first();        if (empty($house)) {            $back_url = \Illuminate\Support\Facades\URL::previous();            return $this->showMessage('该房源不存在或已删除', $back_url, true, '上一页', '3');        }        $house['declare_time_text'] = date('Y-m-d', strtotime($house['declare_time']));        $house['status_text']       = $this->house_status[$house['status']];        $house['status_tag']        = $this->tag_status[$house['status']];        $house['apply_time']        = date('Y-m-d', strtotime($house['apply_time_start'])) . ' - ' . date('Y-m-d', strtotime($house['apply_time_end']));        //报名信息        $apply = TalentHouseApply::where('house_id', $id)->where('user_id', $user_id)->first();        $check = [];        if ($apply) {            $apply['family']  = json_decode($apply['family'], true);            $apply['checked'] = true;            //审核状态            if ($apply['rs_check_status'] != 2) {                $check['status_text'] = '人社局' . $this->apply_status[$apply['rs_check_status']];                $check['comment']     = $apply['rs_check_comment'];                $check['type']        = $this->check_type[$apply['rs_check_status']];            } elseif ($apply['zj_check_status']) {                $check['status_text'] = '住建局' . $this->apply_status[$apply['zj_check_status']];                $check['comment']     = $apply['zj_check_comment'];                $check['type']        = $this->check_type[$apply['zj_check_status']];            } else {                $check['title']       = '';                $check['status_text'] = $this->apply_status[$apply['zj_check_status']];                $check['comment']     = '';                $check['type']        = 'success';            }        } else {            $apply = [                'family'  => [['relation' => '', 'realname' => '', 'idcard' => '']],                'checked' => true,            ];        }        $return_data = [            'check'  => $check,            'apply'  => json_encode($apply),            'house'  => json_encode($house),            'module' => ['identification'],        ];        return view('app.content.buyhouse.list', $return_data);    }    public function listPost(Request $request)    {        $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']);        $rules    = [            'certificates'       => 'required',            'marry'              => 'required',            'household_register' => 'required',            'work_prove'         => 'required',            'street'             => 'required',            'house_condition'    => 'required',            'house_policy'       => 'required',        ];        $messages = [            'certificates.required'       => '请上传证件信息',            'marry.required'              => '请选择婚姻状况',            'household_register.required' => '请上传户口本',            'work_prove.required'         => '请上传人才工作单位',            'street.required'             => '请填写所属街道',            'house_condition.required'    => '请填写家庭成员在晋江市行政区域内住房情况',            'house_policy.required'       => '请填写在晋享受政策性住房或相关优惠情况',        ];        return response()->json(['status' => 1]);    }    /**     * 登录状态     */    private function checkLogin()    {        $user_id = auth('web-member')->id();        if (empty($user_id)) {            return redirect(route('buyhouse.login'));        }        return false;    }}
 |