123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664 |
- <?php
- namespace App\Http\Controllers\Mobile\Active;
- use App\Http\Controllers\Mobile\MobileBaseController;
- use App\Models\LotteryLog;
- use App\Models\LotteryPrize;
- use App\Models\LotteryWin;
- use App\Models\Thirdlogin;
- use App\Services\Common\CategoryService;
- use App\Services\Common\WechatService;
- use App\Services\Auth\AuthService;
- use App\Services\HomeService;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\Cache;
- use Illuminate\Support\Facades\DB;
- use Illuminate\Support\Facades\Session;
- class SpringController extends MobileBaseController
- {
- private $wechatService;
- protected $categoryService;
- protected $authService;
- protected $homeService;
- public function __construct(WechatService $wechatService, CategoryService $categoryService, authService $authService, HomeService $homeService)
- {
- $this->wechatService = $wechatService;
- $this->categoryService = $categoryService;
- $this->authService = $authService;
- $this->homeService = $homeService;
- }
- /**
- * 专题页
- */
- public function index(Request $request)
- {
- //是否登录
- $user = auth('web-member')->user();
- if (empty($user)) {
- $open_id = Session::get('open_id');
- if (empty($open_id)) {
- return redirect(route('mobile.lottery.login'));
- }
- } else {
- $third = Thirdlogin::where('uid', $user->id)->first();
- $open_id = $third['openid'];
- }
- // $open_id = '11';
- //抽奖次数
- $type = $request->input('type', 1);
- $date = date('Y-m-d');
- $log = LotteryLog::where([
- ['create_time', '=', $date],
- ['type', '=', $type],
- ['open_id', '=', $open_id],
- ])->first();
- $number = 1;
- if (!empty($log)) {
- $number = 0;
- }
- //奖品列表
- $prize = LotteryPrize::all();
- $ids = [];
- $restaraunts = [];
- $colors = [];
- $images = [];
- foreach ($prize as $v) {
- $ids[] = $v->id;
- $restaraunts[] = $v->prize_name;
- $colors[] = $v->prize_bg;
- $images[] = upload_asset($v->prize_image);
- }
- //中奖记录
- $win = [];
- $user = auth('web-member')->user();
- if (!empty($user)) {
- $win = LotteryWin::with('prize')->where('member_id', $user->id)->orderBy('status', 'asc')->orderBy('created_at', 'desc')->limit(8)->get();
- }
- $return_data = [
- 'open_id' => $open_id,
- 'current_url' => \Illuminate\Support\Facades\Request::getRequestUri(),
- 'user' => $user,
- 'number' => $number,
- 'type' => $type,
- 'prize' => $prize,
- 'win' => $win,
- 'ids' => $ids,
- 'restaraunts' => $restaraunts,
- 'colors' => $colors,
- 'images' => $images,
- 'wap_title' => '抽奖',
- 'share_title' => '【福利通知】免费找工作,抽大奖拿好礼',
- 'share_desc' => '晋江好福利!免费找工作、找人才,还能抽奖,100%中奖,万份好礼免费拿!',
- 'share_link' => route('mobile.lottery.login'),
- 'share_image_url' => theme_asset('mobile/images/online2021/share_logo.jpg'),
- 'live_list' => $this->homeService->getSpringLive(),
- ];
- return view('mobile.app.active.spring', $return_data);
- }
- /**
- * 专区页
- */
- public function special(Request $request)
- {
- $offset = isset($request->page) ? $request->page : 0;
- $limit = 8;
- $citycategory = $request->input('citycategory', '');
- $trade = $request->input('trade', '');
- $param_array = ['citycategory', 'trade', 'nature'];
- $params = [];
- if ($request->all()) {
- foreach ($request->all() as $k => $v) {
- if (in_array($k, $param_array) && $v) {
- $params[$k] = $v;
- }
- }
- }
- $filter_where = [
- 'AIX_trade' => 100,
- 'AIX_company_type' => 100,
- ];
- $categories = $this->categoryService->getCategories($filter_where);
- $subsites = Cache::get('subsites_list');
- if ($subsites) {
- if (!array_has($params, 'citycategory')) {
- if (get_subsite_id() > 0) {
- $citycategory = $subsites[get_subsite_id()]['district'];
- }
- }
- }
- $title = '晋江市新春招聘会';
- $citys = $this->categoryService->getCitys($citycategory);
- if (empty($citycategory)) {
- $district_str = "(district like ? or district like ?)";
- $district_arr = ["%.623%", "%623.%"];
- } else {
- $select_id = $citys['select']['id'];
- $district_str = "(district like ? or district like ?)";
- $district_arr = ["%.{$select_id}%", "%{$select_id}.%"];
- $title = $citys['select']['name'] . '专区';
- }
- $whereRaw = "jobs.updated_at > '2022-01-01 00:00:00' and jobs.deleted_at is null and jobs.valid = 1 and jobs.audit = 1 and jobs.display = 1";
- $companys = DB::table('jobs')->join('companys', 'jobs.company_id', '=', 'companys.id')->whereRaw($whereRaw)->groupBy('jobs.company_id')->select('jobs.company_id')->pluck('company_id')->toArray();
- $where = [];
- $where[] = ['user_status', '=', 1];
- $where[] = ['audit', '=', 1];
- $where[] = ['deleted_at', '=', null];
- if (!empty($trade)) {
- $where[] = ['trade', '=', $trade];
- }
- $list = DB::table('companys')->where($where)->whereRaw($district_str, $district_arr)->whereIn('id', $companys)->orderBy('sort_index', 'desc')->orderBy('id', 'desc')->offset($limit * $offset)->limit($limit)->get();
- $more = count($list) >= $limit ? true : false;
- $res = [];
- foreach ($list as $val) {
- $item = [
- 'id' => $val->id,
- 'companyname' => $val->companyname,
- 'jobs' => [],
- 'tag_arr' => [],
- ];
- //在招职位
- $jobs_where = [
- ['company_id', '=', $val->id],
- ['valid', '=', 1],
- ['display', '=', 1],
- ['audit', '=', 1],
- ['deleted_at', '=', null],
- ];
- $jobs = DB::table('jobs')->where($jobs_where)->get();
- if (!$jobs->isEmpty()) {
- foreach ($jobs as $value) {
- $job = [
- 'id' => $value->id,
- 'jobs_name' => $value->jobs_name,
- 'amount' => $value->amount,
- 'wage' => $value->wage,
- 'wage_min' => $value->wage_min,
- 'wage_max' => $value->wage_max,
- ];
- array_push($item['jobs'], $job);
- }
- }
- //企业福利
- if (!empty($val->tag)) {
- $tags = explode(',', $val->tag);
- $tag_arr = DB::table('categorys')->whereIn('id', $tags)->limit(3)->get(['demand'])->toArray();
- $item['tag_arr'] = $tag_arr;
- }
- array_push($res, $item);
- }
- if ($request->ajax()) {
- if (count($res)) {
- return response()->json(['status' => 1, 'data' => view('mobile.app.active.ajax.ajax_spring_special_com', [
- 'res' => $res,
- 'city' => $citys,
- 'params' => $params,
- 'categories' => $categories,
- 'more' => $more,
- ])->render()]);
- }
- return response()->json(['status' => 0]);
- }
- return view('mobile.app.active.spring_special', [
- 'title' => $title,
- 'res' => $res,
- 'city' => $citys,
- 'params' => $params,
- 'categories' => $categories,
- 'more' => $more,
- 'share_title' => "【{$title}】免费找工作",
- 'share_desc' => '晋江好福利!免费找工作、找人才,还能抽奖,100%中奖,万份好礼免费拿!',
- 'share_image_url' => theme_asset('mobile/images/online2021/share_logo.jpg'),
- 'share_link' => route('mobile.active.spring_special') . '?citycategory=' . $citycategory,
- ]);
- }
- /**
- * 经开区专区页
- */
- public function special_jkq(Request $request)
- {
- $source = $request->input('source', 0);
- $type = $request->input('type', 1);
- if (!$request->ajax()) {
- //是否登录
- $user = auth('web-member')->user();
- if (empty($user)) {
- $open_id = Session::get('open_id');
- if (empty($open_id)) {
- return redirect(route('mobile.active.spring_jkq_login', ['type' => $type, 'source' => $source]));
- }
- } else {
- $third = Thirdlogin::where('uid', $user->id)->first();
- $open_id = $third['openid'];
- }
- // $open_id = '11';
- //抽奖次数
- $date = date('Y-m-d');
- $log = LotteryLog::where([
- ['create_time', '=', $date],
- ['type', '=', $type],
- ['open_id', '=', $open_id],
- ])->first();
- $number = 1;
- if (!empty($log)) {
- $number = 0;
- }
- //奖品列表
- $prize = LotteryPrize::all();
- $ids = [];
- $restaraunts = [];
- $colors = [];
- $images = [];
- foreach ($prize as $v) {
- $ids[] = $v->id;
- $restaraunts[] = $v->prize_name;
- $colors[] = $v->prize_bg;
- $images[] = upload_asset($v->prize_image);
- }
- //中奖记录
- $win = [];
- $user = auth('web-member')->user();
- if (!empty($user)) {
- $win = LotteryWin::with('prize')->where('member_id', $user->id)->orderBy('status', 'asc')->orderBy('created_at', 'desc')->limit(8)->get();
- }
- }
- $offset = isset($request->page) ? $request->page : 0;
- $limit = 8;
- $citycategory = 'jjkfq';
- $whereRaw = "jobs.updated_at > '2022-01-01 00:00:00' and jobs.deleted_at is null and jobs.valid = 1 and jobs.audit = 1 and jobs.display = 1";
- $companys = DB::table('jobs')->join('companys', 'jobs.company_id', '=', 'companys.id')->whereRaw($whereRaw)->groupBy('jobs.company_id')->select('jobs.company_id')->pluck('company_id')->toArray();
- $citys = $this->categoryService->getCitys($citycategory);
- $select_id = $citys['select']['id'];
- $district_str = "(district like ? or district like ?)";
- $district_arr = ["%.{$select_id}%", "%{$select_id}.%"];
- $where = [];
- $where[] = ['user_status', '=', 1];
- $where[] = ['audit', '=', 1];
- $where[] = ['deleted_at', '=', null];
- $list = DB::table('companys')->where($where)->whereRaw($district_str, $district_arr)->whereIn('id', $companys)->orderBy('sort_index', 'desc')->orderBy('id', 'desc')->offset($limit * $offset)->limit($limit)->get();
- $more = count($list) >= $limit ? true : false;
- $res = [];
- foreach ($list as $val) {
- $item = [
- 'id' => $val->id,
- 'companyname' => $val->companyname,
- 'jobs' => [],
- 'tag_arr' => [],
- ];
- //在招职位
- $jobs_where = [
- ['company_id', '=', $val->id],
- ['valid', '=', 1],
- ['display', '=', 1],
- ['audit', '=', 1],
- ['deleted_at', '=', null],
- ];
- $jobs = DB::table('jobs')->where($jobs_where)->get();
- if (!$jobs->isEmpty()) {
- foreach ($jobs as $value) {
- $job = [
- 'id' => $value->id,
- 'jobs_name' => $value->jobs_name,
- 'amount' => $value->amount,
- 'wage' => $value->wage,
- 'wage_min' => $value->wage_min,
- 'wage_max' => $value->wage_max,
- 'wage_str' => $value->wage_str,
- ];
- array_push($item['jobs'], $job);
- }
- }
- //企业福利
- if (!empty($val->tag)) {
- $tags = explode(',', $val->tag);
- $tag_arr = DB::table('categorys')->whereIn('id', $tags)->limit(3)->get(['demand'])->toArray();
- $item['tag_arr'] = $tag_arr;
- }
- array_push($res, $item);
- }
- if ($request->ajax()) {
- if (count($res)) {
- return response()->json(['status' => 1, 'data' => view('mobile.app.active.ajax.ajax_spring_special_com', [
- 'res' => $res,
- 'more' => $more,
- ])->render()]);
- }
- return response()->json(['status' => 0]);
- }
- return view('mobile.app.active.spring_special_jkq', [
- 'source' => $source,
- 'params' => ['citycategory' => 'jjkfq'],
- 'open_id' => $open_id,
- 'current_url' => \Illuminate\Support\Facades\Request::getRequestUri(),
- 'user' => $user,
- 'number' => $number,
- 'type' => $type,
- 'prize' => $prize,
- 'win' => $win,
- 'ids' => $ids,
- 'restaraunts' => $restaraunts,
- 'colors' => $colors,
- 'images' => $images,
- 'res' => $res,
- 'more' => $more,
- 'share_title' => '【福利通知】免费找工作,抽大奖拿好礼',
- 'share_desc' => '晋江好福利!免费找工作、找人才,还能抽奖,100%中奖,万份好礼免费拿!',
- 'share_image_url' => theme_asset('mobile/images/online2021/share_logo.jpg'),
- 'live_list' => $this->homeService->getSpringLive(),
- ]);
- }
- /**
- * 微信登录
- */
- public function jkq_login(Request $request)
- {
- //type:web-电脑端,mobile-手机端,
- $app_id = subsite_config('aix.system.oauth.wechat_official.app_id');
- $redirect_uri = urlencode(route('mobile.active.spring_jkq_wechat_back'));
- $type = $request->input('type', 1);
- $source = $request->input('source', 0);
- $wechat_url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={$app_id}&redirect_uri={$redirect_uri}&response_type=code&scope=snsapi_userinfo&state={$type}_{$source}#wechat_redirect";
- return redirect($wechat_url);
- }
- /**
- * 微信回调
- */
- public function jkq_wechat_back(Request $request)
- {
- //微信登录
- $officialAccount = $this->wechatService->getOfficialAccount();
- $wechatUser = $officialAccount->oauth->user()->getOriginal();
- $thirdlogin = Thirdlogin::where('openid', $wechatUser['openid'])->first();
- if (!$thirdlogin && $wechatUser['unionid']) {
- $thirdlogin = Thirdlogin::where('unionid', $wechatUser['unionid'])->first();
- }
- if ($thirdlogin) {
- $member = $thirdlogin->member()->withTrashed()->first();
- $this->authService->login($member, 1);
- } else {
- Session::put('open_id', $wechatUser['openid']);
- Session::put('union_id', $wechatUser['unionid'] ?: '');
- Session::save();
- }
- $state = $request->input('state', '');
- $state = explode('_', $state);
- $url = route('mobile.active.spring_special_jkq', ['type' => $state[0], 'source' => $state[1]]);
- return redirect($url);
- }
- /**
- * 直播专用页
- */
- public function special_live(Request $request)
- {
- if (!$request->ajax()) {
- //奖品列表
- $prize = LotteryPrize::all();
- }
- $offset = isset($request->page) ? $request->page : 0;
- $limit = 8;
- $citycategory = 'jjkfq';
- $whereRaw = "jobs.updated_at > '2022-01-01 00:00:00' and jobs.deleted_at is null and jobs.valid = 1 and jobs.audit = 1 and jobs.display = 1";
- $companys = DB::table('jobs')->join('companys', 'jobs.company_id', '=', 'companys.id')->whereRaw($whereRaw)->groupBy('jobs.company_id')->select('jobs.company_id')->pluck('company_id')->toArray();
- $citys = $this->categoryService->getCitys($citycategory);
- $select_id = $citys['select']['id'];
- $district_str = "(district like ? or district like ?)";
- $district_arr = ["%.{$select_id}%", "%{$select_id}.%"];
- $where = [];
- $where[] = ['user_status', '=', 1];
- $where[] = ['audit', '=', 1];
- $where[] = ['deleted_at', '=', null];
- $list = DB::table('companys')->where($where)->whereRaw($district_str, $district_arr)->whereIn('id', $companys)->orderBy('sort_index', 'desc')->orderBy('id', 'desc')->offset($limit * $offset)->limit($limit)->get();
- $more = count($list) >= $limit ? true : false;
- $res = [];
- foreach ($list as $val) {
- $item = [
- 'id' => $val->id,
- 'companyname' => $val->companyname,
- 'jobs' => [],
- 'tag_arr' => [],
- ];
- //在招职位
- $jobs_where = [
- ['company_id', '=', $val->id],
- ['valid', '=', 1],
- ['display', '=', 1],
- ['audit', '=', 1],
- ['deleted_at', '=', null],
- ];
- $jobs = DB::table('jobs')->where($jobs_where)->get();
- if (!$jobs->isEmpty()) {
- foreach ($jobs as $value) {
- $job = [
- 'id' => $value->id,
- 'jobs_name' => $value->jobs_name,
- 'amount' => $value->amount,
- 'wage' => $value->wage,
- 'wage_min' => $value->wage_min,
- 'wage_max' => $value->wage_max,
- 'wage_str' => $value->wage_str,
- ];
- array_push($item['jobs'], $job);
- }
- }
- //企业福利
- if (!empty($val->tag)) {
- $tags = explode(',', $val->tag);
- $tag_arr = DB::table('categorys')->whereIn('id', $tags)->limit(3)->get(['demand'])->toArray();
- $item['tag_arr'] = $tag_arr;
- }
- array_push($res, $item);
- }
- if ($request->ajax()) {
- if (count($res)) {
- return response()->json(['status' => 1, 'data' => view('mobile.app.active.ajax.ajax_spring_special_com', [
- 'res' => $res,
- 'more' => $more,
- ])->render()]);
- }
- return response()->json(['status' => 0]);
- }
- return view('mobile.app.active.spring_special_live', [
- 'params' => ['citycategory' => 'jjkfq'],
- 'current_url' => \Illuminate\Support\Facades\Request::getRequestUri(),
- 'res' => $res,
- 'more' => $more,
- 'prize' => $prize,
- 'share_title' => '【福利通知】免费找工作,抽大奖拿好礼',
- 'share_desc' => '晋江好福利!免费找工作、找人才,还能抽奖,100%中奖,万份好礼免费拿!',
- 'share_image_url' => theme_asset('mobile/images/online2021/share_logo.jpg'),
- 'live_list' => $this->homeService->getSpringLive(),
- ]);
- }
- /**
- * 线上招聘
- */
- public function recruit(Request $request)
- {
- $offset = isset($request->page) ? $request->page : 0;
- $limit = 8;
- $citycategory = $request->input('citycategory', '');
- $trade = $request->input('trade', '');
- $param_array = ['citycategory', 'trade', 'nature'];
- $params = [];
- if ($request->all()) {
- foreach ($request->all() as $k => $v) {
- if (in_array($k, $param_array) && $v) {
- $params[$k] = $v;
- }
- }
- }
- $filter_where = [
- 'AIX_trade' => 100,
- 'AIX_company_type' => 100,
- ];
- $categories = $this->categoryService->getCategories($filter_where);
- $subsites = Cache::get('subsites_list');
- if ($subsites) {
- if (!array_has($params, 'citycategory')) {
- if (get_subsite_id() > 0) {
- $citycategory = $subsites[get_subsite_id()]['district'];
- }
- }
- }
- $title = '晋江市新春招聘会';
- $citys = $this->categoryService->getCitys($citycategory);
- if (empty($citycategory)) {
- $district_str = "(district like ? or district like ?)";
- $district_arr = ["%.623%", "%623.%"];
- } else {
- $select_id = $citys['select']['id'];
- $district_str = "(district like ? or district like ?)";
- $district_arr = ["%.{$select_id}%", "%{$select_id}.%"];
- $title = $citys['select']['name'] . '专区';
- }
- $whereRaw = "jobs.updated_at > '2022-01-01 00:00:00' and jobs.deleted_at is null and jobs.valid = 1 and jobs.audit = 1 and jobs.display = 1";
- $companys = DB::table('jobs')->join('companys', 'jobs.company_id', '=', 'companys.id')->whereRaw($whereRaw)->groupBy('jobs.company_id')->select('jobs.company_id')->pluck('company_id')->toArray();
- $where = [];
- $where[] = ['user_status', '=', 1];
- $where[] = ['audit', '=', 1];
- $where[] = ['deleted_at', '=', null];
- if (!empty($trade)) {
- $where[] = ['trade', '=', $trade];
- }
- $list = DB::table('companys')->where($where)->whereRaw($district_str, $district_arr)->whereIn('id', $companys)->orderBy('sort_index', 'desc')->orderBy('id', 'desc')->offset($limit * $offset)->limit($limit)->get();
- $more = count($list) >= $limit ? true : false;
- $res = [];
- foreach ($list as $val) {
- $item = [
- 'id' => $val->id,
- 'companyname' => $val->companyname,
- 'jobs' => [],
- 'tag_arr' => [],
- ];
- //在招职位
- $jobs_where = [
- ['company_id', '=', $val->id],
- ['valid', '=', 1],
- ['display', '=', 1],
- ['audit', '=', 1],
- ['deleted_at', '=', null],
- ];
- $jobs = DB::table('jobs')->where($jobs_where)->get();
- if (!$jobs->isEmpty()) {
- foreach ($jobs as $value) {
- $job = [
- 'id' => $value->id,
- 'jobs_name' => $value->jobs_name,
- 'amount' => $value->amount,
- 'wage' => $value->wage,
- 'wage_min' => $value->wage_min,
- 'wage_max' => $value->wage_max,
- ];
- array_push($item['jobs'], $job);
- }
- }
- //企业福利
- if (!empty($val->tag)) {
- $tags = explode(',', $val->tag);
- $tag_arr = DB::table('categorys')->whereIn('id', $tags)->limit(3)->get(['demand'])->toArray();
- $item['tag_arr'] = $tag_arr;
- }
- array_push($res, $item);
- }
- if ($request->ajax()) {
- if (count($res)) {
- return response()->json(['status' => 1, 'data' => view('mobile.app.active.ajax.ajax_spring_special_com', [
- 'res' => $res,
- 'city' => $citys,
- 'params' => $params,
- 'categories' => $categories,
- 'more' => $more,
- ])->render()]);
- }
- return response()->json(['status' => 0]);
- }
- return view('mobile.app.active.spring_special', [
- 'title' => $title,
- 'res' => $res,
- 'city' => $citys,
- 'params' => $params,
- 'categories' => $categories,
- 'more' => $more,
- 'share_title' => "【{$title}】免费找工作",
- 'share_desc' => '晋江好福利!免费找工作、找人才,还能抽奖,100%中奖,万份好礼免费拿!',
- 'share_image_url' => theme_asset('mobile/images/online2021/share_logo.jpg'),
- 'share_link' => route('mobile.active.spring_special') . '?citycategory=' . $citycategory,
- ]);
- }
- }
|