Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
施宇
/
icsales
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ca374dea
authored
Aug 15, 2019
by
朱继来
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
调整cms,若缓存不存在,则读取数据库
parent
83112cc0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
180 additions
and
5 deletions
Application/Common/Conf/config_db.php
Application/Home/Controller/CmsController.class.php
Application/Home/Model/CmsModel.class.php
Application/Home/Model/ScmsModel.class.php
Application/Common/Conf/config_db.php
View file @
ca374dea
...
@@ -18,11 +18,11 @@ return array(
...
@@ -18,11 +18,11 @@ return array(
'DB_OTHER'
=>
array
(
'DB_OTHER'
=>
array
(
'CMS'
=>
array
(
'CMS'
=>
array
(
'db_type'
=>
'mysql'
,
'db_type'
=>
'mysql'
,
'db_user'
=>
'
ichuntcm
s'
,
'db_user'
=>
'
liexin_icsale
s'
,
'db_pwd'
=>
'
ichuntcm
s#zsyM'
,
'db_pwd'
=>
'
liexin_icsale
s#zsyM'
,
'db_host'
=>
'192.168.2.232'
,
'db_host'
=>
'192.168.2.232'
,
'db_port'
=>
'3306'
,
'db_port'
=>
'3306'
,
'db_name'
=>
'
ichuntcm
s'
,
'db_name'
=>
'
liexin_icsale
s'
,
'db_charset'
=>
'utf8'
,
'db_charset'
=>
'utf8'
,
),
),
'FS'
=>
array
(
'FS'
=>
array
(
...
...
Application/Home/Controller/CmsController.class.php
View file @
ca374dea
...
@@ -8,7 +8,8 @@ class CmsController extends BaseController
...
@@ -8,7 +8,8 @@ class CmsController extends BaseController
// 获取热门商品
// 获取热门商品
public
function
getHotGoods
()
public
function
getHotGoods
()
{
{
$res
=
$this
->
checkApi
();
// 接口校验
$request
=
I
(
'request.'
);
$res
=
$this
->
checkApi
(
$request
);
// 接口校验
if
(
$res
===
false
)
return
$this
->
jsonReturn
(
11001
,
'接口校验失败'
);
if
(
$res
===
false
)
return
$this
->
jsonReturn
(
11001
,
'接口校验失败'
);
...
...
Application/Home/Model/CmsModel.class.php
0 → 100644
View file @
ca374dea
<?php
namespace
Home\Model
;
use
Think\Model
;
/**
* 配置系统模型
* @authors yc ()
* @date 2017-08-02 11:15:25
* @version $Id$
*/
class
CmsModel
extends
Model
{
protected
$autoCheckFields
=
false
;
public
function
_initialize
()
{
parent
::
_initialize
();
$this
->
ScmsModel
=
D
(
'Home/Scms'
);
$this
->
connection
=
C
(
'DB_OTHER.CMS'
);
}
public
function
getModel
(
$key
=
''
,
$field
=
'model_id'
)
{
static
$model_key
;
if
(
!
isset
(
$model_key
[
$key
]))
{
$this
->
ScmsModel
=
D
(
'Home/Scms'
);
$model_key
[
$key
]
=
$this
->
ScmsModel
->
getModel
(
$key
);
if
(
empty
(
$model_key
[
$key
]))
{
$map
=
array
(
'model_key'
=>
$key
,
);
$model_key
[
$key
]
=
$this
->
table
(
'lie_model'
)
->
where
(
$map
)
->
field
(
'model_id, model_name'
)
->
find
();
}
}
return
$model_key
[
$key
][
$field
];
}
private
function
formatwhere
(
$map
,
$where
)
{
if
(
is_string
(
$where
))
{
if
(
!
empty
(
$where
))
{
$where
=
array
(
'_string'
=>
$where
);
}
else
{
$where
=
array
();
}
}
$map
=
array_merge
(
$map
,
$where
);
return
$map
;
}
/**
* 获取基本配置
* @return [type] [description]
*/
public
function
getSetting
()
{
$data
=
$this
->
table
(
'lie_setting'
)
->
getField
(
'set_key,set_val'
);
return
$data
;
}
/**
* 获取底部链接分类
* @param [type] $fcat_key [description]
* @return [type] [description]
*/
public
function
getFooterLinkCat
(
$fcat_key
)
{
$this
->
ScmsModel
=
D
(
'Home/Scms'
);
$datas
=
$this
->
ScmsModel
->
getFooterLinkCat
(
$fcat_key
,
'fcat_id'
);
if
(
!
empty
(
$datas
))
{
return
$datas
;
}
$map
=
array
(
'fcat_key'
=>
$fcat_key
,
);
$datas
=
$this
->
table
(
'lie_footer_link_cat'
)
->
where
(
$map
)
->
limit
(
$limit
)
->
getField
(
'fcat_id'
);
return
$datas
;
}
/**
* 获取底部链接分类列表
* @param string $where [description]
* @param string $limit [description]
* @return [type] [description]
*/
public
function
getFooterLinkCatList
(
$where
=
''
,
$limit
=
''
)
{
$this
->
ScmsModel
=
D
(
'Home/Scms'
);
$parent_id
=
isset
(
$where
[
'parent_id'
])
?
$where
[
'parent_id'
]
:
0
;
$datas
=
$this
->
ScmsModel
->
getFooterLinkCat
(
''
,
''
,
$parent_id
);
if
(
!
empty
(
$datas
))
{
$datas
=
array_slice
(
$datas
,
0
,
$limit
);
return
$datas
;
}
$datas
=
$this
->
table
(
'lie_footer_link_cat'
)
->
where
(
$where
)
->
limit
(
$limit
)
->
order
(
'sort DESC'
)
->
field
(
'fcat_id,fcat_name,parent_id'
)
->
select
();
return
$datas
;
}
/**
* 获取底部链接
* @param [type] $fcat_key [description]
* @return [type] [description]
*/
public
function
getFooterLink
(
$fcat_id
,
$where
=
''
,
$limit
=
''
)
{
$this
->
ScmsModel
=
D
(
'Home/Scms'
);
$datas
=
$this
->
ScmsModel
->
getFooterLink
(
$fcat_id
);
if
(
!
empty
(
$datas
))
{
$dats
=
array_slice
(
$datas
,
0
,
$limit
);
return
$datas
;
}
$map
=
array
(
'fcat_id'
=>
$fcat_id
,
'status'
=>
1
,
);
$map
=
$this
->
formatwhere
(
$map
,
$where
);
$datas
=
$this
->
table
(
'lie_footer_link'
)
->
where
(
$map
)
->
limit
(
$limit
)
->
field
(
'flink_name,url,class,tip'
)
->
select
();
return
$datas
;
}
/**
* 获取基础分类ID
* @param [type] $tags [description]
* @param string $field [description]
* @return [type] [description]
*/
public
function
getBaseCat
(
$tags
,
$field
=
'bcat_id'
)
{
static
$bcat
;
if
(
!
isset
(
$bcat
[
$tags
]))
{
$map
=
array
(
'tags'
=>
$tags
,
);
$bcat
[
$tags
]
=
$this
->
table
(
'lie_base_cat'
)
->
where
(
$map
)
->
field
(
'bcat_id, bcat_name'
)
->
find
();
}
return
$bcat
[
$tags
][
$field
];
}
/**
* 获取配置分类值
* @param [type] $tags [description]
* @param string $where [description]
* @param string $limit [description]
* @return [type] [description]
*/
public
function
getBaseList
(
$tags
,
$where
=
''
,
$limit
=
''
)
{
$bcat_id
=
$this
->
getBaseCat
(
$tags
);
$map
=
array
(
'bcat_id'
=>
$bcat_id
,
'_string'
=>
"(status = 1) OR (status = 2 AND open_time >=
{
$_SERVER
[
'REQUEST_TIME'
]
}
AND close_time <=
{
$_SERVER
[
'REQUEST_TIME'
]
}
)"
,
);
$map
=
$this
->
formatwhere
(
$map
,
$where
);
$datas
=
$this
->
table
(
'lie_base'
)
->
where
(
$map
)
->
limit
(
$limit
)
->
order
(
'sort DESC'
)
->
field
(
'*'
)
->
select
();
return
$datas
;
}
}
Application/Home/Model/ScmsModel.class.php
View file @
ca374dea
...
@@ -69,7 +69,22 @@ class ScmsModel
...
@@ -69,7 +69,22 @@ class ScmsModel
public
function
getBaseList
(
$tags
,
$where
=
''
,
$limit
=
1
)
public
function
getBaseList
(
$tags
,
$where
=
''
,
$limit
=
1
)
{
{
$bcat_id
=
$this
->
getBcatId
(
$tags
);
// 分类ID
$bcat_id
=
$this
->
getBcatId
(
$tags
);
// 分类ID
return
$this
->
getBase
(
$bcat_id
,
$limit
,
$where
);
$datas
=
$this
->
getBase
(
$bcat_id
,
$limit
,
$where
);
// 若缓存不存在,则读取数据库
if
(
!
$datas
)
{
$cms
=
D
(
'Home/Cms'
);
if
(
strpos
(
$where
,
'&'
)
!==
false
)
{
// 缓存里的条件用&连接
$where
=
explode
(
'&'
,
$where
);
}
else
{
$where
=
$where
?
$where
.
' and status=1'
:
'status=1'
;
}
return
$cms
->
getBaseList
(
$tags
,
$where
,
$limit
);
}
return
$datas
;
}
}
/**
/**
...
...
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