Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
token
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
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
wallet
token
Commits
4970322d
Commit
4970322d
authored
Nov 13, 2018
by
ZhuChunYang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
1342e47d
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
184 additions
and
0 deletions
+184
-0
ApplicationBusiness.php
common/business/ApplicationBusiness.php
+88
-0
CoinApplicateRank.php
common/models/psources/CoinApplicateRank.php
+10
-0
CoinBanner.php
common/models/psources/CoinBanner.php
+20
-0
ApplicationController.php
h5/controllers/ApplicationController.php
+66
-0
No files found.
common/business/ApplicationBusiness.php
View file @
4970322d
...
...
@@ -10,6 +10,7 @@ use common\models\psources\CoinAppCate;
use
common\models\psources\CoinApplicateRecommend
;
use
common\models\psources\CoinApplication
;
use
common\models\psources\CoinApplicationCategory
;
use
common\models\psources\CoinBanner
;
use
common\models\psources\CoinImage
;
use
Yii
;
class
ApplicationBusiness
...
...
@@ -64,6 +65,7 @@ class ApplicationBusiness
$cate_app_item
[
'apps'
]
=
[];
}
$cate_app_data
[]
=
$cate_app_item
;
$cate_app_item
=
[];
}
return
$cate_app_data
;
}
...
...
@@ -149,5 +151,90 @@ class ApplicationBusiness
}
public
static
function
getH5CategoryAppList
(
$limit
=
0
)
{
$data
=
CoinApplicationCategory
::
getAllList
();
$cate_app_data
=
[];
$icon_Items
=
array_column
(
$data
,
'icon'
);
$icon_Infos
=
CoinImage
::
getItemsByIds
(
$icon_Items
);
$banner_data
=
array_column
(
$data
,
'h5_banner'
);
$banner_items
=
[];
foreach
(
$banner_data
as
$item
){
if
(
$item
){
$banner_items
=
array_merge
(
$banner_items
,
explode
(
','
,
$item
));
}
}
$banner_infos
=
CoinBanner
::
getBannerDataByIds
(
$banner_items
);
$cate_app_Infos
=
self
::
getH5CateAppInfo
(
$limit
);
foreach
(
$data
as
$value
){
$cate_app_item
[
'id'
]
=
$value
[
'id'
];
$cate_app_item
[
'name'
]
=
$value
[
'name'
];
if
(
$value
[
'icon'
]){
$cate_app_item
[
'icon_url'
]
=
$icon_Infos
[
$value
[
'icon'
]][
'base_url'
]
.
$icon_Infos
[
$value
[
'icon'
]][
'file_url'
];
}
else
{
$cate_app_item
[
'icon_url'
]
=
''
;
}
if
(
$value
[
'h5_banner'
]){
$banner_ids
=
explode
(
','
,
$value
[
'h5_banner'
]);
foreach
(
$banner_ids
as
$banner_id
){
$cate_app_item
[
'h5_banner'
][]
=
$banner_infos
[
$banner_id
];
}
}
else
{
$cate_app_item
[
'h5_banner'
]
=
[];
}
if
(
isset
(
$cate_app_Infos
[
$value
[
'id'
]])){
//分类下面有应用
$cate_app_item
[
'apps'
]
=
$cate_app_Infos
[
$value
[
'id'
]];
}
else
{
$cate_app_item
[
'apps'
]
=
[];
}
$cate_app_data
[]
=
$cate_app_item
;
$cate_app_item
=
[];
}
return
$cate_app_data
;
}
/**
* @return mixed
* 获取分类以及应用(H5)
*/
public
static
function
getH5CateAppInfo
(
$limit
=
0
,
$condition
=
[])
{
$app_cate_Model
=
CoinAppCate
::
find
();
$query
=
$app_cate_Model
->
JoinWith
([
'application'
],
false
)
->
select
(
'cate_id,app_id,name,h5_icon,show_width,show_height,introduce_image,official_url,type,native_url,native_login_url,h5_url,android_url,ios_url,app_store_url,redirect_type,open_type,'
.
CoinAppCate
::
tableName
()
.
'.sort'
)
->
orderBy
(
CoinAppCate
::
tableName
()
.
'.sort asc'
);
foreach
(
$condition
as
$item
)
{
$query
=
$query
->
andWhere
(
$item
);
}
$data
=
$query
->
asArray
()
->
all
();
$icon_Items
=
array_column
(
$data
,
'h5_icon'
);
$introduce_image_Items
=
array_column
(
$data
,
'introduce_image'
);
$icon_Items
=
array_unique
(
$icon_Items
);
$image_Items
=
array_merge
(
$icon_Items
,
$introduce_image_Items
);
$image_Infos
=
CoinImage
::
getItemsByIds
(
$image_Items
);
$cate_app_item
=
[];
foreach
(
$data
as
&
$value
){
if
(
$value
[
'h5_icon'
]){
$value
[
'h5_icon'
]
=
$image_Infos
[
$value
[
'h5_icon'
]][
'base_url'
]
.
$image_Infos
[
$value
[
'h5_icon'
]][
'file_url'
];
}
else
{
$value
[
'h5_icon'
]
=
''
;
}
if
(
$value
[
'introduce_image'
]){
$value
[
'introduce_image'
]
=
$image_Infos
[
$value
[
'introduce_image'
]][
'base_url'
]
.
$image_Infos
[
$value
[
'introduce_image'
]][
'file_url'
];
}
else
{
$value
[
'introduce_image'
]
=
''
;
}
}
foreach
(
$data
as
$item
){
if
(
$limit
&&
isset
(
$cate_app_item
[
$item
[
'cate_id'
]])
&&
count
(
$cate_app_item
[
$item
[
'cate_id'
]])
>=
$limit
){
continue
;
}
else
{
$cate_app_item
[
$item
[
'cate_id'
]]
[]
=
$item
;
}
}
return
$cate_app_item
;
}
}
\ No newline at end of file
common/models/psources/CoinApplicateRank.php
View file @
4970322d
...
...
@@ -51,5 +51,14 @@ class CoinApplicateRank extends BaseActiveRecord
return
$data
;
}
public
static
function
getH5AppList
(
$type
)
{
$applicate_rank_model
=
self
::
find
();
$data
=
$applicate_rank_model
->
JoinWith
([
'application'
],
false
)
->
select
(
'relate_id as app_id,sort,name,h5_icon,introduce_image,show_width,show_height,advertise,native_url,native_login_url,h5_url,android_url,ios_url,app_store_url,redirect_type,open_type,'
.
CoinApplication
::
tableName
()
.
".type"
)
->
orderBy
(
self
::
tableName
()
.
'.sort asc'
)
->
where
([
self
::
tableName
()
.
'.type'
=>
$type
])
->
asArray
()
->
all
();
return
$data
;
}
}
\ No newline at end of file
common/models/psources/CoinBanner.php
View file @
4970322d
...
...
@@ -48,4 +48,23 @@ class CoinBanner extends BaseActiveRecord
return
self
::
find
()
->
where
([
'id'
=>
$id
])
->
one
();
}
public
static
function
getBannerDataByIds
(
$banner_ids
)
{
if
(
$banner_ids
)
{
if
(
is_array
(
$banner_ids
))
{
$idItems
=
$banner_ids
;
}
else
{
$idItems
=
explode
(
','
,
$banner_ids
);
}
$data
=
self
::
find
()
->
where
([
'in'
,
'id'
,
$idItems
])
->
asArray
()
->
all
();
$image_id_items
=
array_column
(
$data
,
'image_id'
);
$image_info
=
CoinImage
::
getItemsByIds
(
$image_id_items
);
foreach
(
$data
as
&
$value
)
{
$value
[
'banner_image_url'
]
=
$image_info
[
$value
[
'image_id'
]][
'base_url'
]
.
$image_info
[
$value
[
'image_id'
]][
'file_url'
];
unset
(
$value
[
'image_id'
]);
}
}
return
array_column
(
$data
,
null
,
'id'
);
}
}
\ No newline at end of file
h5/controllers/ApplicationController.php
0 → 100644
View file @
4970322d
<?php
/**
* Created by PhpStorm.
* User: ZCY
* Date: 2018/11/13
* Time: 15:52
*/
namespace
h5\controllers
;
use
common\business\ApplicationBusiness
;
use
common\models\psources\CoinApplicateRank
;
use
common\models\psources\CoinImage
;
use
h5\base\ResponseBuild
;
use
h5\base\BaseController
;
use
Yii
;
/**
* Class CoinController
* 应用控制器
*
* @package h5\controllers
*/
class
ApplicationController
extends
BaseController
{
public
function
actionIndex
()
{
$response_
=
new
ResponseBuild
();
$recommendData
=
ApplicationBusiness
::
getRecommendList
();
$data
[
'recommend'
]
=
$recommendData
;
$cate_app_data
=
ApplicationBusiness
::
getH5CategoryAppList
(
8
);
$data
[
'cate_app_data'
]
=
$cate_app_data
;
$response_
->
build
(
ResponseBuild
::
STATUS_SUCCEED
,
''
,
$data
);
return
$response_
;
}
public
function
actionRankList
()
{
$response_
=
new
ResponseBuild
();
$request
=
Yii
::
$app
->
request
;
$type
=
$request
->
post
(
'type'
,
1
);
$result
[
'code'
]
=
0
;
$data
=
CoinApplicateRank
::
getH5AppList
(
$type
);
$icon_Items
=
array_column
(
$data
,
'h5_icon'
);
$introduce_image_Items
=
array_column
(
$data
,
'introduce_image'
);
$image_items
=
array_merge
(
$icon_Items
,
$introduce_image_Items
);
$image_Infos
=
CoinImage
::
getItemsByIds
(
$image_items
);
foreach
(
$data
as
$key
=>
&
$value
){
if
(
$value
[
'h5_icon'
]){
$value
[
'h5_icon'
]
=
$image_Infos
[
$value
[
'h5_icon'
]][
'base_url'
]
.
$image_Infos
[
$value
[
'h5_icon'
]][
'file_url'
];
}
else
{
$value
[
'h5_icon'
]
=
""
;
}
if
(
$value
[
'introduce_image'
]){
$value
[
'introduce_image'
]
=
$image_Infos
[
$value
[
'introduce_image'
]][
'base_url'
]
.
$image_Infos
[
$value
[
'introduce_image'
]][
'file_url'
];
}
else
{
$value
[
'introduce_image'
]
=
""
;
}
$value
[
'app_user_num'
]
=
ApplicationBusiness
::
getAppUserNum
(
$value
[
'app_id'
]);
}
$response_
->
build
(
ResponseBuild
::
STATUS_SUCCEED
,
''
,
$data
);
return
$response_
;
}
}
\ No newline at end of file
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