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
b8554db4
Commit
b8554db4
authored
Oct 23, 2018
by
ZhuChunYang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
1f598734
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
105 additions
and
24 deletions
+105
-24
ApplicationController.php
backend/controllers/ApplicationController.php
+8
-11
CoinApplicationForm.php
backend/models/coin/CoinApplicationForm.php
+22
-12
edit.php
backend/views/application/edit.php
+1
-0
list.php
backend/views/application/list.php
+13
-1
CoinAppCate.php
common/models/psources/CoinAppCate.php
+9
-0
CoinApplication.php
common/models/psources/CoinApplication.php
+52
-0
No files found.
backend/controllers/ApplicationController.php
View file @
b8554db4
...
@@ -26,14 +26,7 @@ class ApplicationController extends BaseController
...
@@ -26,14 +26,7 @@ class ApplicationController extends BaseController
$request
=
Yii
::
$app
->
request
;
$request
=
Yii
::
$app
->
request
;
$page
=
$request
->
get
(
'page'
,
1
);
$page
=
$request
->
get
(
'page'
,
1
);
$limit
=
$request
->
get
(
'limit'
,
10
);
$limit
=
$request
->
get
(
'limit'
,
10
);
$app_ids
=
CoinAppCate
::
getAppIdByCateId
(
$id
);
$data
=
CoinApplication
::
getListByCategory
(
$page
,
$limit
,
$id
);
$app_items
=
[];
$where
=
[];
if
(
$app_ids
){
$app_items
=
array_column
(
$app_ids
,
'app_id'
);
}
$where
[]
=
[
'in'
,
'id'
,
$app_items
];
$data
=
CoinApplication
::
getList
(
$page
,
$limit
,
$where
);
return
$data
;
return
$data
;
}
else
{
}
else
{
$id
=
Yii
::
$app
->
request
->
get
(
'id'
);
$id
=
Yii
::
$app
->
request
->
get
(
'id'
);
...
@@ -77,7 +70,7 @@ class ApplicationController extends BaseController
...
@@ -77,7 +70,7 @@ class ApplicationController extends BaseController
{
{
if
(
Yii
::
$app
->
request
->
isPost
)
{
if
(
Yii
::
$app
->
request
->
isPost
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
Yii
::
$app
->
response
->
format
=
'json'
;
$fields
=
[
'id'
,
'name'
,
'sort'
,
'icon'
,
'type'
,
'native_url'
,
'h5_url'
,
'android_url'
,
'ios_url'
,
'app_store_url'
,
'advertise'
,
'description'
,
'redirect_type'
];
$fields
=
[
'
category_id'
,
'
id'
,
'name'
,
'sort'
,
'icon'
,
'type'
,
'native_url'
,
'h5_url'
,
'android_url'
,
'ios_url'
,
'app_store_url'
,
'advertise'
,
'description'
,
'redirect_type'
];
$params
=
$this
->
initParams
(
Yii
::
$app
->
request
->
post
(),
$fields
);
$params
=
$this
->
initParams
(
Yii
::
$app
->
request
->
post
(),
$fields
);
$coin_applicateion_form
=
new
CoinApplicationForm
();
$coin_applicateion_form
=
new
CoinApplicationForm
();
$coin_applicateion_form
->
setScenario
(
CoinApplicationForm
::
SCENARIO_EDIT
);
$coin_applicateion_form
->
setScenario
(
CoinApplicationForm
::
SCENARIO_EDIT
);
...
@@ -85,16 +78,19 @@ class ApplicationController extends BaseController
...
@@ -85,16 +78,19 @@ class ApplicationController extends BaseController
return
$coin_applicateion_form
->
edit
();
return
$coin_applicateion_form
->
edit
();
}
elseif
(
Yii
::
$app
->
request
->
isGet
)
{
}
elseif
(
Yii
::
$app
->
request
->
isGet
)
{
$id
=
Yii
::
$app
->
request
->
get
(
'id'
,
null
);
$id
=
Yii
::
$app
->
request
->
get
(
'id'
,
null
);
$category_id
=
Yii
::
$app
->
request
->
get
(
'category_id'
,
null
);
if
(
$id
)
{
if
(
$id
)
{
$applicate
=
CoinApplication
::
getApplicateById
(
$id
);
$applicate
=
CoinApplication
::
getApplicateById
(
$id
);
$app_cate
=
CoinAppCate
::
getAppCate
(
$category_id
,
$id
);
if
(
$applicate
[
'icon'
]){
if
(
$applicate
[
'icon'
]){
$icon_info
=
CoinImage
::
getItemById
(
$applicate
[
'icon'
]);
$icon_info
=
CoinImage
::
getItemById
(
$applicate
[
'icon'
]);
$applicate
[
'icon_url'
]
=
$icon_info
[
'base_url'
]
.
$icon_info
[
'file_url'
];
$applicate
[
'icon_url'
]
=
$icon_info
[
'base_url'
]
.
$icon_info
[
'file_url'
];
}
else
{
}
else
{
$applicate
[
'icon_url'
]
=
""
;
$applicate
[
'icon_url'
]
=
""
;
}
}
$applicate
[
'sort'
]
=
$app_cate
->
sort
;
$this
->
layout
=
false
;
$this
->
layout
=
false
;
return
$this
->
render
(
'edit'
,
[
'item'
=>
$applicate
]);
return
$this
->
render
(
'edit'
,
[
'item'
=>
$applicate
,
'category_id'
=>
$category_id
]);
}
}
}
}
}
}
...
@@ -123,8 +119,9 @@ class ApplicationController extends BaseController
...
@@ -123,8 +119,9 @@ class ApplicationController extends BaseController
Yii
::
$app
->
response
->
format
=
'json'
;
Yii
::
$app
->
response
->
format
=
'json'
;
$cate_id
=
Yii
::
$app
->
request
->
post
(
'cate_id'
);
$cate_id
=
Yii
::
$app
->
request
->
post
(
'cate_id'
);
$app_id
=
Yii
::
$app
->
request
->
post
(
'app_id'
);
$app_id
=
Yii
::
$app
->
request
->
post
(
'app_id'
);
$sort
=
Yii
::
$app
->
request
->
post
(
'sort'
,
0
);
$coin_applicateion_form
=
new
CoinApplicationForm
();
$coin_applicateion_form
=
new
CoinApplicationForm
();
return
$coin_applicateion_form
->
addCategory
(
$app_id
,
$cate_id
);
return
$coin_applicateion_form
->
addCategory
(
$app_id
,
$cate_id
,
$sort
);
}
}
}
}
...
...
backend/models/coin/CoinApplicationForm.php
View file @
b8554db4
...
@@ -37,7 +37,7 @@ class CoinApplicationForm extends BaseForm
...
@@ -37,7 +37,7 @@ class CoinApplicationForm extends BaseForm
{
{
return
[
return
[
self
::
SCENARIO_ADD
=>
[
'category_id'
,
'name'
,
'sort'
,
'icon'
,
'type'
,
'native_url'
,
'h5_url'
,
'android_url'
,
'ios_url'
,
'app_store_url'
,
'advertise'
,
'description'
,
'redirect_type'
],
self
::
SCENARIO_ADD
=>
[
'category_id'
,
'name'
,
'sort'
,
'icon'
,
'type'
,
'native_url'
,
'h5_url'
,
'android_url'
,
'ios_url'
,
'app_store_url'
,
'advertise'
,
'description'
,
'redirect_type'
],
self
::
SCENARIO_EDIT
=>
[
'id'
,
'name'
,
'sort'
,
'icon'
,
'type'
,
'native_url'
,
'h5_url'
,
'android_url'
,
'ios_url'
,
'app_store_url'
,
'advertise'
,
'description'
,
'redirect_type'
],
self
::
SCENARIO_EDIT
=>
[
'
category_id'
,
'
id'
,
'name'
,
'sort'
,
'icon'
,
'type'
,
'native_url'
,
'h5_url'
,
'android_url'
,
'ios_url'
,
'app_store_url'
,
'advertise'
,
'description'
,
'redirect_type'
],
];
];
}
}
...
@@ -107,6 +107,7 @@ class CoinApplicationForm extends BaseForm
...
@@ -107,6 +107,7 @@ class CoinApplicationForm extends BaseForm
$coin_app_cate
=
new
CoinAppCate
();
$coin_app_cate
=
new
CoinAppCate
();
$coin_app_cate
->
app_id
=
$coin_applicate
->
id
;
$coin_app_cate
->
app_id
=
$coin_applicate
->
id
;
$coin_app_cate
->
cate_id
=
$this
->
category_id
;
$coin_app_cate
->
cate_id
=
$this
->
category_id
;
$coin_app_cate
->
sort
=
$this
->
sort
;
$coin_app_cate
->
save
();
$coin_app_cate
->
save
();
$tr
->
commit
();
$tr
->
commit
();
}
}
...
@@ -128,16 +129,24 @@ class CoinApplicationForm extends BaseForm
...
@@ -128,16 +129,24 @@ class CoinApplicationForm extends BaseForm
public
function
edit
()
public
function
edit
()
{
{
if
(
$this
->
validate
()){
if
(
$this
->
validate
()){
$coin_applicate
=
CoinApplication
::
getApplicate
(
$this
->
id
);
$tr
=
CoinApplication
::
getDb
()
->
beginTransaction
();
if
(
$coin_applicate
){
try
{
$image_ids
=
$coin_applicate
->
image_ids
;
$coin_applicate
=
CoinApplication
::
getApplicate
(
$this
->
id
);
$coin_applicate
->
setAttributes
(
$this
->
attributes
,
false
);
if
(
$coin_applicate
){
$coin_applicate
->
image_ids
=
$image_ids
;
$image_ids
=
$coin_applicate
->
image_ids
;
$coin_applicate
->
save
();
$coin_applicate
->
setAttributes
(
$this
->
attributes
,
false
);
CoinApplicateRecommend
::
updateName
(
$this
->
id
,
2
,
$this
->
name
);
//更新首页推荐name
$coin_applicate
->
image_ids
=
$image_ids
;
return
[
'code'
=>
0
,
'msg'
=>
'应用修改成功!'
];
$coin_applicate
->
save
();
}
else
{
CoinApplicateRecommend
::
updateName
(
$this
->
id
,
2
,
$this
->
name
);
//更新首页推荐name
return
[
'code'
=>
1
,
'msg'
=>
'应用不存在'
];
CoinAppCate
::
updateSort
(
$this
->
category_id
,
$this
->
id
,
$this
->
sort
);
$tr
->
commit
();
return
[
'code'
=>
0
,
'msg'
=>
'应用修改成功!'
];
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'应用不存在'
];
}
}
catch
(
\Exception
$e
){
$tr
->
rollBack
();
return
[
'code'
=>
1
,
'msg'
=>
$e
->
getMessage
()];
}
}
}
else
{
}
else
{
$error
=
self
::
getModelError
(
$this
);
$error
=
self
::
getModelError
(
$this
);
...
@@ -178,7 +187,7 @@ class CoinApplicationForm extends BaseForm
...
@@ -178,7 +187,7 @@ class CoinApplicationForm extends BaseForm
* @param $id
* @param $id
* 添加所属分类
* 添加所属分类
*/
*/
public
function
addCategory
(
$id
,
$category_id
)
public
function
addCategory
(
$id
,
$category_id
,
$sort
)
{
{
$coin_app_cate
=
CoinAppCate
::
getAppCate
(
$category_id
,
$id
);
$coin_app_cate
=
CoinAppCate
::
getAppCate
(
$category_id
,
$id
);
if
(
$coin_app_cate
){
if
(
$coin_app_cate
){
...
@@ -187,6 +196,7 @@ class CoinApplicationForm extends BaseForm
...
@@ -187,6 +196,7 @@ class CoinApplicationForm extends BaseForm
$coin_app_cate
=
new
CoinAppCate
();
$coin_app_cate
=
new
CoinAppCate
();
$coin_app_cate
->
app_id
=
$id
;
$coin_app_cate
->
app_id
=
$id
;
$coin_app_cate
->
cate_id
=
$category_id
;
$coin_app_cate
->
cate_id
=
$category_id
;
$coin_app_cate
->
sort
=
$sort
;
$coin_app_cate
->
save
();
$coin_app_cate
->
save
();
return
[
'code'
=>
0
,
'msg'
=>
'应用所属分类添加成功'
];
return
[
'code'
=>
0
,
'msg'
=>
'应用所属分类添加成功'
];
}
}
...
...
backend/views/application/edit.php
View file @
b8554db4
...
@@ -11,6 +11,7 @@
...
@@ -11,6 +11,7 @@
<form
class=
"layui-form"
method=
"post"
action=
""
id=
"applicateEdit"
>
<form
class=
"layui-form"
method=
"post"
action=
""
id=
"applicateEdit"
>
<input
name=
"_csrf"
type=
"hidden"
value=
"
<?=
Yii
::
$app
->
request
->
getCsrfToken
()
?>
"
>
<input
name=
"_csrf"
type=
"hidden"
value=
"
<?=
Yii
::
$app
->
request
->
getCsrfToken
()
?>
"
>
<input
name=
"id"
type=
"hidden"
value=
"
<?=
$item
[
'id'
]
?>
"
>
<input
name=
"id"
type=
"hidden"
value=
"
<?=
$item
[
'id'
]
?>
"
>
<input
name=
"category_id"
type=
"hidden"
value=
"
<?=
$category_id
?>
"
>
<div
class=
"layui-form-item"
>
<div
class=
"layui-form-item"
>
<div
class=
"layui-inline"
>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
图标
</label>
<label
class=
"layui-form-label"
>
图标
</label>
...
...
backend/views/application/list.php
View file @
b8554db4
...
@@ -40,6 +40,12 @@
...
@@ -40,6 +40,12 @@
</select>
</select>
</div>
</div>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
应用排序
</label>
<div
class=
"layui-input-block"
>
<input
class=
"layui-input"
name=
"sort"
value=
""
>
</div>
</div>
</form>
</form>
</div>
</div>
</div>
</div>
...
@@ -140,7 +146,7 @@
...
@@ -140,7 +146,7 @@
var
data
=
obj
.
data
;
var
data
=
obj
.
data
;
var
event
=
obj
.
event
;
var
event
=
obj
.
event
;
if
(
event
===
'edit'
)
{
if
(
event
===
'edit'
)
{
$
.
get
(
'/admin/application/edit'
,
{
id
:
data
.
id
},
function
(
str
)
{
$
.
get
(
'/admin/application/edit'
,
{
id
:
data
.
id
,
category_id
:
category_id
},
function
(
str
)
{
var
editIndex
=
layer
.
open
({
var
editIndex
=
layer
.
open
({
type
:
1
,
type
:
1
,
title
:
'编辑: '
+
data
.
name
,
title
:
'编辑: '
+
data
.
name
,
...
@@ -182,6 +188,12 @@
...
@@ -182,6 +188,12 @@
type
:
1
,
type
:
1
,
content
:
$
(
"#_form"
),
content
:
$
(
"#_form"
),
btn
:
[
'保存'
,
'取消'
],
btn
:
[
'保存'
,
'取消'
],
success
:
function
()
{
form
.
val
(
"form1"
,
{
cate_id
:
0
,
sort
:
''
,
});
},
btn1
:
function
()
{
btn1
:
function
()
{
$
.
post
(
'/admin/application/add-category'
,
$
(
"#form1"
).
serialize
(),
function
(
rev
)
{
$
.
post
(
'/admin/application/add-category'
,
$
(
"#form1"
).
serialize
(),
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
layer
.
msg
(
rev
.
msg
);
...
...
common/models/psources/CoinAppCate.php
View file @
b8554db4
...
@@ -56,6 +56,14 @@ class CoinAppCate extends BaseActiveRecord
...
@@ -56,6 +56,14 @@ class CoinAppCate extends BaseActiveRecord
return
self
::
find
()
->
where
([
'app_id'
=>
$app_id
])
->
count
();
return
self
::
find
()
->
where
([
'app_id'
=>
$app_id
])
->
count
();
}
}
public
static
function
updateSort
(
$category_id
,
$app_id
,
$sort
)
{
$cate_app
=
self
::
getAppCate
(
$category_id
,
$app_id
);
if
(
$cate_app
){
$cate_app
->
sort
=
$sort
;
$cate_app
->
save
();
}
}
}
}
\ No newline at end of file
common/models/psources/CoinApplication.php
View file @
b8554db4
...
@@ -36,6 +36,11 @@ class CoinApplication extends BaseActiveRecord
...
@@ -36,6 +36,11 @@ class CoinApplication extends BaseActiveRecord
}
}
}
}
public
function
getAppCate
()
{
return
$this
->
hasOne
(
CoinAppCate
::
class
,
[
'app_id'
=>
'id'
]);
}
public
static
function
getList
(
$page
=
1
,
$limit
=
10
,
$condition
=
[],
$order_by
=
[
'sort'
=>
SORT_ASC
],
$select
=
[])
public
static
function
getList
(
$page
=
1
,
$limit
=
10
,
$condition
=
[],
$order_by
=
[
'sort'
=>
SORT_ASC
],
$select
=
[])
{
{
$query
=
self
::
find
();
$query
=
self
::
find
();
...
@@ -82,6 +87,53 @@ class CoinApplication extends BaseActiveRecord
...
@@ -82,6 +87,53 @@ class CoinApplication extends BaseActiveRecord
return
[
'count'
=>
$count
,
'data'
=>
$data
,
'code'
=>
0
];
return
[
'count'
=>
$count
,
'data'
=>
$data
,
'code'
=>
0
];
}
}
public
static
function
getListByCategory
(
$page
=
1
,
$limit
=
10
,
$category_id
,
$order_by
=
[
'sort'
=>
SORT_ASC
])
{
$coin_applicate_Model
=
CoinApplication
::
find
();
$query
=
$coin_applicate_Model
->
JoinWith
([
'appCate'
],
false
)
->
select
(
CoinApplication
::
tableName
()
.
'.id,name,icon,type,native_url,h5_url,android_url,ios_url,app_store_url,advertise,description,redirect_type,'
.
CoinAppCate
::
tableName
()
.
'.sort as sort'
)
->
orderBy
(
CoinAppCate
::
tableName
()
.
'.sort asc'
)
->
where
([
'cate_id'
=>
$category_id
]);
$count
=
$query
->
count
();
$data
=
$query
->
offset
((
$page
-
1
)
*
10
)
->
limit
(
$limit
)
->
asArray
()
->
all
();
$icon_Items
=
array_column
(
$data
,
'icon'
);
$icon_Infos
=
CoinImage
::
getItemsByIds
(
$icon_Items
);
$recommendItems
=
CoinApplicateRecommend
::
getRecommendItemsByType
(
2
);
foreach
(
$data
as
$key
=>
&
$value
){
if
(
$value
[
'icon'
]){
$value
[
'icon_url'
]
=
$icon_Infos
[
$value
[
'icon'
]][
'base_url'
]
.
$icon_Infos
[
$value
[
'icon'
]][
'file_url'
];
}
else
{
$value
[
'icon_url'
]
=
''
;
}
if
(
$value
[
'h5_url'
]){
$value
[
'has_h5'
]
=
1
;
}
else
{
$value
[
'has_h5'
]
=
0
;
}
if
(
$value
[
'android_url'
]){
$value
[
'has_android'
]
=
1
;
}
else
{
$value
[
'has_android'
]
=
0
;
}
$has_ios_url
=
$value
[
'ios_url'
]
?
1
:
0
;
$has_app_store
=
$value
[
'app_store_url'
]
?
1
:
0
;
if
(
$has_ios_url
&&
$has_app_store
){
$value
[
'has_ios'
]
=
3
;
}
else
if
(
$has_ios_url
){
$value
[
'has_ios'
]
=
1
;
}
else
if
(
$has_app_store
){
$value
[
'has_ios'
]
=
2
;
}
else
{
$value
[
'has_ios'
]
=
0
;
}
if
(
isset
(
$recommendItems
[
$value
[
'id'
]])){
$value
[
'isrecommend'
]
=
1
;
}
}
return
[
'count'
=>
$count
,
'data'
=>
$data
,
'code'
=>
0
];
}
public
static
function
getApplicateById
(
$id
)
public
static
function
getApplicateById
(
$id
)
{
{
return
self
::
find
()
->
where
([
'id'
=>
$id
])
->
asArray
()
->
one
();
return
self
::
find
()
->
where
([
'id'
=>
$id
])
->
asArray
()
->
one
();
...
...
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