159 lines
3.5 KiB
PHP
159 lines
3.5 KiB
PHP
![]() |
<?php
|
||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||
|
|
||
|
class Ad_model extends CI_Model {
|
||
|
|
||
|
public function __construct()
|
||
|
{
|
||
|
parent::__construct();
|
||
|
$this->load->database();
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
解析广告牌信息
|
||
|
*/
|
||
|
public function setAdMsg($row)
|
||
|
{
|
||
|
$where = array('id' => $row->cityid);
|
||
|
$cityinfor = $this->Db_model->getSpecificData("city",$where);
|
||
|
$city = "";
|
||
|
if (count($cityinfor) > 0)
|
||
|
$city = $cityinfor[0]->name;
|
||
|
|
||
|
$where = array('id' => $row->areaid);
|
||
|
$areainfor = $this->Db_model->getSpecificData("area",$where);
|
||
|
$area = "";
|
||
|
if (count($areainfor) > 0)
|
||
|
$area = $areainfor[0]->name;
|
||
|
|
||
|
$where = array('id' => $row->communityid);
|
||
|
$communityinfor = $this->Db_model->getSpecificData("community",$where);
|
||
|
$community = "";
|
||
|
if (count($communityinfor) > 0)
|
||
|
$community = $communityinfor[0]->name;
|
||
|
$data=array(
|
||
|
'id' => $row->id,
|
||
|
'number' => $row->number,
|
||
|
'free' => $row->free,
|
||
|
'size' => $row->size,
|
||
|
'cityid' => $row->cityid,
|
||
|
'city' => $city,
|
||
|
'areaid' => $row->areaid,
|
||
|
'area' => $area,
|
||
|
'communityid' => $row->communityid,
|
||
|
'community' => $community,
|
||
|
'photo' => $row->photo,
|
||
|
'img' => $row->img,
|
||
|
'addtime' => $row->addtime,
|
||
|
'citydess'=> $row->citydess
|
||
|
);
|
||
|
|
||
|
return $data;
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
接收广告牌信息
|
||
|
*/
|
||
|
public function receiveAdMsg()
|
||
|
{
|
||
|
date_default_timezone_set("Asia/Shanghai");
|
||
|
$number = isset($_POST['number'])?$_POST['number']:"";
|
||
|
$vacancy = isset($_POST['vacancy'])?$_POST['vacancy']:0;
|
||
|
$size = isset($_POST['size'])?$_POST['size']:"";
|
||
|
$cityid = isset($_POST['cityid'])?$_POST['cityid']:"";
|
||
|
$areaid = isset($_POST['areaid'])?$_POST['areaid']:"";
|
||
|
$citydess= isset($_POST['citydess'])?$_POST['citydess']:"";
|
||
|
$communityid = isset($_POST['communityid'])?$_POST['communityid']:"";
|
||
|
|
||
|
$data = array(
|
||
|
'number' => $number,
|
||
|
'free' => $vacancy,
|
||
|
'size' => $size,
|
||
|
'cityid' => $cityid,
|
||
|
'areaid' => $areaid,
|
||
|
'communityid' => $communityid,
|
||
|
'citydess' => $citydess,
|
||
|
'img' => '',
|
||
|
'addtime' => date("m/d/Y")
|
||
|
);
|
||
|
return $data;
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
获得广告牌
|
||
|
*/
|
||
|
public function getAd()
|
||
|
{
|
||
|
$infor = $this->Db_model->getAllData("advertisement");
|
||
|
$data=array();
|
||
|
foreach($infor as $v){
|
||
|
$data[] = $this->setAdMsg($v);
|
||
|
}
|
||
|
return $data;
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
广告牌实拍图
|
||
|
*/
|
||
|
public function getPhoto($id)
|
||
|
{
|
||
|
$where = array('id' => $id);
|
||
|
$infor = $this->Db_model->getSpecificData("advertisement",$where);
|
||
|
$img = "";
|
||
|
|
||
|
if (count($infor) <= 0)
|
||
|
{
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
$imgarr = explode('|', $infor[0]->photo);
|
||
|
return $imgarr;
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
广告位空位
|
||
|
*/
|
||
|
public function setFree($id, $number = 1)
|
||
|
{
|
||
|
$where = array('id' => $id);
|
||
|
$infor = $this->Db_model->getSpecificData("advertisement",$where);
|
||
|
|
||
|
if (count($infor) <= 0)
|
||
|
{
|
||
|
return 0;
|
||
|
}else
|
||
|
{
|
||
|
$num = (int)$infor[0]->free;
|
||
|
$data['free'] = $num + $number;
|
||
|
$this->Db_model->updateData("advertisement",$data,$where);
|
||
|
}
|
||
|
}
|
||
|
/*
|
||
|
广告位空位减少
|
||
|
*/
|
||
|
public function setFreeState($id, $number = 1)
|
||
|
{
|
||
|
$where = array('id' => $id);
|
||
|
$infor = $this->Db_model->getSpecificData("advertisement",$where);
|
||
|
|
||
|
if (count($infor) <= 0)
|
||
|
{
|
||
|
return 0;
|
||
|
}else
|
||
|
{
|
||
|
$num = (int)$infor[0]->free;
|
||
|
$data['free'] = $num - $number;
|
||
|
$this->Db_model->updateData("advertisement",$data,$where);
|
||
|
}
|
||
|
}
|
||
|
/*
|
||
|
设置具体小区信息状态
|
||
|
*/
|
||
|
public function setVacancyState($id,$state = 1)
|
||
|
{
|
||
|
$where = array('id' => $id);
|
||
|
$data = array('state' => $state);
|
||
|
$this->Db_model->updateData("vacancy",$data,$where);
|
||
|
}
|
||
|
}
|