123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248 |
- <?php
- namespace Themes\kbgolf\pro\app\Http\Controllers;
- use App\Facades\ProApiCacheFacade;
- use App\Helpers\ResponseConverter;
- use App\Helpers\Utils;
- use App\Http\Controllers\Controller;
- use App\Services\CallApiService;
- use Illuminate\Http\Request;
- // use Illuminate\Support\Facades\Request;
- class IndexController extends Controller
- {
- private $callApiService;
- public function __construct(CallApiService $callApiService)
- {
- $this->callApiService = $callApiService;
- }
- public function index()
- {
- // [$oauth2InfoList, $develLoginInfo] = setupSsoClientOrLoginInfo('member');
- // dump($oauth2InfoList);
- $connectionDevice = session()->get('ConnectionDevice');
- $response = ProApiCacheFacade::getCachedResponse('list-type1-book', 'list-type1/home-book');
- if ($this->callApiService->verifyApiError($response)) {
- notify()->error($response['body'], 'Error', 'bottomRight');
- return redirect()->back();
- }
- $widgetTaxo = $response['Book'][0]['Page'];
- $maMainSlider = ProApiCacheFacade::filterWidgetTaxo($widgetTaxo, 'ma-main-slider', $connectionDevice);
- // dd($maMainSlider);
- $seoHtml = Utils::getSeoHtml('main');
- $query = "post_type_id = 59";
- $limit = (int)request('limit', 150);
- $page = (int)request('page', 1);
- // 시세
- $mainSiseList = $this->callApiService->callApi([
- 'url' => 'post-page',
- 'data' => [
- 'PageVars' => [
- 'Query' => $query,
- 'Desc' => 'created_on',
- 'Limit' => $limit,
- 'Offset' => ($page - 1) * $limit
- ]
- ]
- ]);
- // dd($mainSiseList);
- // 유튜브
- $query = "(post_type_id = 40 or post_type_id = 43 or post_type_id = 46) and status ='1' and pt1 !=''";
- $limit = (int)request('limit', 12);
- $page = (int)request('page', 1);
- $mainYoutubeList = $this->callApiService->callApi([
- 'url' => 'post-page',
- 'data' => [
- 'PageVars' => [
- 'Query' => $query,
- 'Desc' => 'created_on',
- 'Limit' => $limit,
- 'Offset' => ($page - 1) * $limit
- ]
- ]
- ]);
- // dd($mainYoutubeList);
- // 블로그
- $query = "(post_type_id = 41 or post_type_id = 44 or post_type_id = 50) and status ='1'";
- $limit = (int)request('limit', 12);
- $page = (int)request('page', 1);
- $mainBlogList = $this->callApiService->callApi([
- 'url' => 'post-page',
- 'data' => [
- 'PageVars' => [
- 'Query' => $query,
- 'Desc' => 'created_on',
- 'Limit' => $limit,
- 'Offset' => ($page - 1) * $limit
- ]
- ]
- ]);
- // dd($mainBlogList);
- // 시세 등락 계산
- if (isset($mainSiseList['Page']) && !empty($mainSiseList['Page'])) {
- foreach ($mainSiseList['Page'] as &$sise) {
- if (isset($sise['Pc3'], $sise['Pc4'])) {
- $sise['fluctuation'] = (float)$sise['Pc3'] - (float)$sise['Pc4'];
- } else {
- $sise['fluctuation'] = 0;
- }
- }
- }
- // 블로그 post_code 만들기
- if (isset($mainBlogList['Page']) && !empty($mainBlogList['Page'])) {
- foreach ($mainBlogList['Page'] as &$mainBlog) {
- if (isset($mainBlog['PostTypeId'])) {
- switch ($mainBlog['PostTypeId']) {
- case 41:
- $mainBlog['PostCode'] = 'golf-blog';
- break;
- case 44:
- $mainBlog['PostCode'] = 'condo-blog';
- break;
- default:
- $mainBlog['PostCode'] = 'fitness-blog';
- }
- }
- }
- }
- if ($this->callApiService->verifyApiError($mainSiseList)) {
- notify()->error($mainSiseList['body'], 'Error', 'bottomRight');
- return redirect()->back();
- }
- if ($this->callApiService->verifyApiError($mainYoutubeList)) {
- notify()->error($mainYoutubeList['body'], 'Error', 'bottomRight');
- return redirect()->back();
- }
- if ($this->callApiService->verifyApiError($mainBlogList)) {
- notify()->error($mainBlogList['body'], 'Error', 'bottomRight');
- return redirect()->back();
- }
- return view('views.index', compact('seoHtml', 'maMainSlider', 'mainSiseList', 'mainYoutubeList' ,'mainBlogList'));
- }
- // 시세 더보기
- public function loadMoreSise(Request $request)
- {
- $query = "post_type_id = 59";
- $offset = (int) $request->query('offset', 0);
- $limit = (int) $request->query('limit', 5);
- $siseType = $request->query('siseType', 'golf');
- if($siseType){
- $query .= " and pc1='$siseType'";
- }
- $moreSiseList=$this->callApiService->callApi([
- 'url' => 'post-page',
- 'data' => [
- 'PageVars' => [
- 'Query' => $query,
- 'Desc' => 'created_on',
- 'Limit' => $limit,
- 'Offset' => $offset
- ]
- ]
- ]);
- // 등락 계산
- if (isset($moreSiseList['Page']) && !empty($moreSiseList['Page'])) {
- foreach ($moreSiseList['Page'] as &$sise) {
- if (isset($sise['Pc3'], $sise['Pc4'])) {
- $sise['fluctuation'] = (float)$sise['Pc3'] - (float)$sise['Pc4'];
- } else {
- $sise['fluctuation'] = 0;
- }
- }
- }
- if ($this->callApiService->verifyApiError($moreSiseList)) {
- notify()->error($moreSiseList['body'], 'Error', 'bottomRight');
- return redirect()->back();
- }
- return $moreSiseList;
- }
- // 유튜브 더보기
- public function loadMoreYoutube(Request $request)
- {
- $query = "(post_type_id = 40 or post_type_id = 43 or post_type_id = 46) and status ='1' and pt!=''";
- $offset = (int) $request->query('offset', 0);
- $limit = (int) $request->query('limit', 12);
- $mainYoutubeList=$this->callApiService->callApi([
- 'url' => 'post-page',
- 'data' => [
- 'PageVars' => [
- 'Query' => $query,
- 'Desc' => 'created_on',
- 'Limit' => $limit,
- 'Offset' => $offset
- ]
- ]
- ]);
- if ($this->callApiService->verifyApiError($mainYoutubeList)) {
- notify()->error($mainYoutubeList['body'], 'Error', 'bottomRight');
- return redirect()->back();
- }
- return $mainYoutubeList;
- }
- // 블로그 더보기
- public function loadMoreBlog(Request $request)
- {
- $query = "(post_type_id = 41 or post_type_id = 44 or post_type_id = 50) and status ='1'";
- $offset = (int) $request->query('offset', 0);
- $limit = (int) $request->query('limit', 12);
- $moreBlogList=$this->callApiService->callApi([
- 'url' => 'post-page',
- 'data' => [
- 'PageVars' => [
- 'Query' => $query,
- 'Desc' => 'created_on',
- 'Limit' => $limit,
- 'Offset' => $offset
- ]
- ]
- ]);
- // post_code 만들기
- if (isset($moreBlogList['Page']) && !empty($moreBlogList['Page'])) {
- foreach ($moreBlogList['Page'] as &$mainBlog) {
- if (isset($mainBlog['PostTypeId'])) {
- switch ($mainBlog['PostTypeId']) {
- case 41:
- $mainBlog['PostCode'] = 'golf-blog';
- break;
- case 44:
- $mainBlog['PostCode'] = 'condo-blog';
- break;
- default:
- $mainBlog['PostCode'] = 'fitness-blog';
- }
- }
- }
- }
- if ($this->callApiService->verifyApiError($moreBlogList)) {
- notify()->error($moreBlogList['body'], 'Error', 'bottomRight');
- return redirect()->back();
- }
- return $moreBlogList;
- }
- }
|