Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujun
tl_estate
Commits
e44d5506
Commit
e44d5506
authored
Dec 07, 2017
by
clone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
banner 首页统计
parent
374eddf1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
73 additions
and
166 deletions
+73
-166
Index.php
application/api/controller/Index.php
+8
-3
Basic.php
application/common/Basic.php
+0
-157
Banner.php
application/model/Banner.php
+30
-0
HouseInfos.php
application/model/HouseInfos.php
+13
-6
JournalAccounts.php
application/model/JournalAccounts.php
+22
-0
No files found.
application/api/controller/Index.php
View file @
e44d5506
...
@@ -10,6 +10,7 @@ namespace app\api\controller;
...
@@ -10,6 +10,7 @@ namespace app\api\controller;
use
app\api\extend\Basic
;
use
app\api\extend\Basic
;
use
app\model\HouseInfos
;
use
app\model\HouseInfos
;
use
app\model\JournalAccounts
;
class
Index
extends
Basic
class
Index
extends
Basic
{
{
...
@@ -22,9 +23,13 @@ class Index extends Basic
...
@@ -22,9 +23,13 @@ class Index extends Basic
*/
*/
public
function
averagePriceAndTurnover
(){
public
function
averagePriceAndTurnover
(){
$HouseInfos
=
new
HouseInfos
();
$houseInfos
=
new
HouseInfos
();
$result
=
$HouseInfos
->
getAveragePrice
();
$averagePrice
=
$houseInfos
->
getAveragePrice
();
return
$result
;
$journalAccounts
=
new
JournalAccounts
();
$turnover
=
$journalAccounts
->
getTurnover
();
$result
[
'averagePrice'
]
=
$averagePrice
;
$result
[
'turnover'
]
=
$turnover
;
return
$this
->
response
(
"request success"
,
"200"
,
$result
);
}
}
}
}
application/common/Basic.php
deleted
100644 → 0
View file @
374eddf1
<?php
namespace
app\common
;
/**
* Created by PhpStorm.
* User: zw
* Date: 2017/12/4
* Time: 9:35
* 基类
*/
use
think\Controller
;
use
think\Request
;
use
think\Response
;
class
Basic
extends
Controller
{
/**
* 访问请求对象
* @var Request
*/
public
$request
;
/**
* 当前访问身份
* @var string
*/
public
$token
;
/**
* 基础接口SDK
* @param Request|null $request
*/
public
function
__construct
(
Request
$request
=
null
)
{
// CORS 跨域 Options 检测响应
$this
->
corsOptionsHandler
();
// 输入对象
$this
->
request
=
is_null
(
$request
)
?
Request
::
instance
()
:
$request
;
}
/**
* 输出返回数据
* @param string $msg 提示消息内容
* @param string $code 业务状态码
* @param mixed $data 要返回的数据
* @param string $type 返回类型 JSON XML
* @return Response
*/
public
function
response
(
$msg
,
$code
=
'SUCCESS'
,
$data
=
[],
$type
=
'json'
)
{
$result
=
[
'msg'
=>
$msg
,
'code'
=>
$code
,
'data'
=>
$data
,
'type'
=>
strtolower
(
$type
)];
return
Response
::
create
(
$result
,
$type
);
}
/**
* 一维数据数组生成数据树
* @param array $list 数据列表
* @param string $id 父ID Key
* @param string $pid ID Key
* @param string $son 定义子数据Key
* @return array
*/
public
static
function
arr2tree
(
$list
,
$id
=
'id'
,
$pid
=
'pid'
,
$son
=
'sub'
)
{
list
(
$tree
,
$map
)
=
[[],
[]];
foreach
(
$list
as
$item
)
{
$map
[
$item
[
$id
]]
=
$item
;
}
foreach
(
$list
as
$item
)
{
if
(
isset
(
$item
[
$pid
])
&&
isset
(
$map
[
$item
[
$pid
]]))
{
$map
[
$item
[
$pid
]][
$son
][]
=
&
$map
[
$item
[
$id
]];
}
else
{
$tree
[]
=
&
$map
[
$item
[
$id
]];
}
}
unset
(
$map
);
return
$tree
;
}
/**
* 一维数据数组生成数据树
* @param array $list 数据列表
* @param string $id ID Key
* @param string $pid 父ID Key
* @param string $path
* @param string $ppath
* @return array
*/
public
static
function
arr2table
(
array
$list
,
$id
=
'id'
,
$pid
=
'pid'
,
$path
=
'path'
,
$ppath
=
''
)
{
$tree
=
[];
foreach
(
self
::
arr2tree
(
$list
,
$id
,
$pid
)
as
$attr
)
{
$attr
[
$path
]
=
"
{
$ppath
}
-
{
$attr
[
$id
]
}
"
;
$attr
[
'sub'
]
=
isset
(
$attr
[
'sub'
])
?
$attr
[
'sub'
]
:
[];
$attr
[
'spl'
]
=
str_repeat
(
" ├ "
,
substr_count
(
$ppath
,
'-'
));
$sub
=
$attr
[
'sub'
];
unset
(
$attr
[
'sub'
]);
$tree
[]
=
$attr
;
if
(
!
empty
(
$sub
))
{
$tree
=
array_merge
(
$tree
,
(
array
)
self
::
arr2table
(
$sub
,
$id
,
$pid
,
$path
,
$attr
[
$path
]));
}
}
return
$tree
;
}
/**
* 获取数据树子ID
* @param array $list 数据列表
* @param int $id 起始ID
* @param string $key 子Key
* @param string $pkey 父Key
* @return array
*/
public
static
function
getArrSubIds
(
$list
,
$id
=
0
,
$key
=
'id'
,
$pkey
=
'pid'
)
{
$ids
=
[
intval
(
$id
)];
foreach
(
$list
as
$vo
)
{
if
(
intval
(
$vo
[
$pkey
])
>
0
&&
intval
(
$vo
[
$pkey
])
===
intval
(
$id
))
{
$ids
=
array_merge
(
$ids
,
self
::
getArrSubIds
(
$list
,
intval
(
$vo
[
$key
]),
$key
,
$pkey
));
}
}
return
$ids
;
}
/**
* Cors Options 授权处理
*/
public
static
function
corsOptionsHandler
()
{
if
(
request
()
->
isOptions
())
{
header
(
'Access-Control-Allow-Origin:*'
);
header
(
'Access-Control-Allow-Headers:Accept,Referer,Host,Keep-Alive,User-Agent,X-Requested-With,Cache-Control,Content-Type,Cookie,token'
);
header
(
'Access-Control-Allow-Credentials:true'
);
header
(
'Access-Control-Allow-Methods:GET,POST,OPTIONS'
);
header
(
'Access-Control-Max-Age:1728000'
);
header
(
'Content-Type:text/plain charset=UTF-8'
);
header
(
'Content-Length: 0'
,
true
);
header
(
'status: 204'
);
header
(
'HTTP/1.0 204 No Content'
);
exit
;
}
}
/**
* Cors Request Header信息
* @return array
*/
public
static
function
corsRequestHander
()
{
return
[
'Access-Control-Allow-Origin'
=>
'*'
,
'Access-Control-Allow-Credentials'
=>
true
,
'Access-Control-Allow-Methods'
=>
'GET,POST,OPTIONS'
,
'Access-Defined-X-Support'
=>
'service@cuci.cc'
,
'Access-Defined-X-Servers'
=>
'Guangzhou Cuci Technology Co. Ltd'
,
];
}
}
application/model/Banner.php
0 → 100644
View file @
e44d5506
<?php
namespace
app\model
;
/**
* Created by PhpStorm.
* User : zw
* Date : 2017/12/7
* Time : 17:50
* Intro:
*/
use
think\Model
;
class
Banner
extends
Model
{
// 设置当前模型对应的完整数据表名称
protected
$table
=
'u_banner'
;
protected
$db
;
function
__construct
()
{
$this
->
db
=
Db
(
$this
->
table
);
}
function
add
(){
$user
=
$this
->
db
;
$user
->
data
([
'name'
=>
'thinkphp'
,
'email'
=>
'thinkphp@qq.com'
]);
$user
->
save
();
}
}
\ No newline at end of file
application/model/HouseInfos.php
View file @
e44d5506
...
@@ -2,9 +2,10 @@
...
@@ -2,9 +2,10 @@
namespace
app\model
;
namespace
app\model
;
use
think\Db
;
use
think\Model
;
use
think\Model
;
class
HouseInfos
extends
Model
class
HouseInfos
extends
Model
{
{
protected
$table
=
'houseinfos'
;
protected
$table
=
'houseinfos'
;
...
@@ -12,7 +13,7 @@ class HouseInfos extends Model
...
@@ -12,7 +13,7 @@ class HouseInfos extends Model
function
__construct
()
function
__construct
()
{
{
$this
->
dbHouseInfo
=
Db
::
table
(
$this
->
table
);
$this
->
dbHouseInfo
=
Db
(
$this
->
table
);
}
}
/**
/**
...
@@ -36,21 +37,27 @@ class HouseInfos extends Model
...
@@ -36,21 +37,27 @@ class HouseInfos extends Model
}
}
/**
* 获取月均价
* @return float
*/
function
getAveragePrice
()
function
getAveragePrice
()
{
//price
{
//price
$params
[
'rent_type'
]
=
array
(
"eq"
,
1
);
//月租金类型
$params
[
'rent_type'
]
=
array
(
"eq"
,
1
);
//月租金类型
$params
[
'room_num_left'
]
=
array
(
"<>"
,
0
);
//剩余店铺为0的不算
$params
[
'room_num_left'
]
=
array
(
"<>"
,
0
);
//剩余店铺为0的不算
$sumPrice
=
$this
->
dbHouseInfo
$sumPrice
=
$this
->
dbHouseInfo
->
where
(
$params
)
->
where
(
$params
)
->
sum
(
"price"
);
->
sum
(
"price"
);
$count_
=
$this
->
dbHouseInfo
$count_
=
$this
->
dbHouseInfo
->
field
(
"id"
)
->
field
(
"id"
)
->
where
(
$params
)
->
where
(
$params
)
->
count
(
"id"
);
->
count
(
"id"
);
$averagePrice
=
round
(
$sumPrice
/
$count_
);
$averagePrice
=
ceil
(
$sumPrice
/
$count_
);
return
$averagePrice
;
return
$averagePrice
;
}
}
}
}
application/model/JournalAccounts.php
View file @
e44d5506
...
@@ -3,9 +3,31 @@
...
@@ -3,9 +3,31 @@
namespace
app\model
;
namespace
app\model
;
use
think\Model
;
use
think\Model
;
use
think\helper\Time
;
class
JournalAccounts
extends
Model
class
JournalAccounts
extends
Model
{
{
// 设置当前模型对应的完整数据表名称
// 设置当前模型对应的完整数据表名称
protected
$table
=
'Journalaccounts'
;
protected
$table
=
'Journalaccounts'
;
protected
$db
;
function
__construct
()
{
$this
->
db
=
Db
(
$this
->
table
);
}
/**
* 获取月均价
* @return float
*/
function
getTurnover
()
{
$timeArr
=
Time
::
lastWeek
();
$signStartTime
=
date
(
"Y-m-d H:i:s"
,
$timeArr
[
0
]);
$signEndTime
=
date
(
"Y-m-d H:i:s"
,
$timeArr
[
1
]);
$where_
[
'singntime'
]
=
array
(
"between"
,
array
(
$signStartTime
,
$signEndTime
)
);
return
$this
->
db
->
where
(
$where_
)
->
count
(
"id"
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment