123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- <?php
- namespace Themes\kbgolf\pro\app\Http\Controllers\Page;
- use App\Http\Controllers\Controller;
- use App\Services\CallApiService;
- use Illuminate\Pagination\LengthAwarePaginator;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\Log;
- class SiseController extends Controller
- {
- private $callApiService;
- public function __construct(CallApiService $callApiService)
- {
- $this->callApiService = $callApiService;
- }
- public function index($siseType, $area=null, $memberbershipname=null)
- {
- // siseType별로 title 변수 생성
- switch ($siseType) {
- case 'golf':
- $title_dir = "골프";
- $title = "골프회원권 시세";
- break;
- case 'condo':
- $title_dir = "콘도";
- $title = "콘도회원권 시세";
- break;
- default:
- $title_dir = "휘트니스";
- $title = "휘트니스회원권 시세";
- }
- $query = "post_type_id = 59 and pc5='$siseType'";
- if($area){
- if($area != 'all'){
- $query .= " and pc2='$area'";
- }
- }
- if($memberbershipname){
- $query .= " and postTitle like '%$memberbershipname%'";
- }
- $limit = (int)request('limit', 10);
- $page = (int)request('page', 1);
- // api 호출 request
- $siseList = $this->callApiService->callApi([
- 'url' => 'post-page',
- 'data' => [
- 'PageVars' => [
- 'Query' => $query,
- 'Desc' => 'post_title',
- 'Limit' => $limit,
- 'Offset' => ($page - 1) * $limit
- ]
- ]
- ]);
- // dd($siseList);
- // 등락 계산
- if (isset($siseList['Page']) && !empty($siseList['Page'])) {
- foreach ($siseList['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($siseList)) {
- notify()->error($siseList['body'], 'Error', 'bottomRight');
- return redirect()->back();
- }
- // pagenation
- // $totalcnt = $siseList['PageVars']['QueryCnt'];
- // $siseItems['Page'] = new LengthAwarePaginator(
- // $siseList['Page'],
- // $totalcnt,
- // $limit,
- // $page,
- // ['path' => request()->url()]
- // );
- // dd($siseItems['Page']);
- return view('views.page.sise', compact('siseList', 'title', "title_dir", "siseType", "area"));
- }
- public function loadScrollSise(Request $request)
- {
- $today = date('ymd');
- $limit = (int) $request->query('limit', 400);
- $page = (int) $request->query('page', 1);
- $siseType = $request->query('siseType', "golf");
- $areaType = $request->query('areaType', "all");
- $siseDate = $request->query('siseDate', $today);
- $query = "post_type_id = 59 ";
- if($areaType != 'all'){
- $query .= "and pc5='$siseType' and pc2='$areaType' and pc6='$siseDate'";
- }else{
- $query .= "and pc5='$siseType' and pc6='$siseDate'";
- }
- // Log::info('More Sise List:',$siseDate );
- $moreSiseList=$this->callApiService->callApi([
- 'url' => 'post-page',
- 'data' => [
- 'PageVars' => [
- 'Query' => $query,
- 'Asc' => 'post_title',
- 'Limit' => $limit,
- 'Offset' => ($page - 1) * $limit
- ]
- ]
- ]);
- // 등락 계산
- 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;
- }
- }
|