Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zuiketang
Project
Project
Details
Activity
Releases
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
zuiketang
Commits
5691360f
Commit
5691360f
authored
Oct 17, 2016
by
xiabin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加注释
parent
9a29fa00
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
14 deletions
+27
-14
Course.php
src/common/models/Course.php
+1
-1
Favorite.php
src/common/models/Favorite.php
+1
-1
Income.php
src/common/models/Income.php
+10
-6
Orders.php
src/common/models/Orders.php
+12
-3
UserCenterController.php
src/frontend/controllers/UserCenterController.php
+2
-2
userCenter.php
src/frontend/views/layouts/userCenter.php
+1
-1
No files found.
src/common/models/Course.php
View file @
5691360f
...
...
@@ -187,6 +187,6 @@ class Course extends \yii\db\ActiveRecord
*/
public
function
getUser
()
{
return
$this
->
hasOne
(
User
::
className
(),
[
'id'
=>
'user_id'
]);
return
$this
->
hasOne
(
User
::
className
(),
[
'id'
=>
'user_id'
])
->
select
(
'id,username,role,avatar'
);
;
}
}
src/common/models/Favorite.php
View file @
5691360f
...
...
@@ -109,6 +109,6 @@ class Favorite extends \yii\db\ActiveRecord
*/
public
function
getCourse
()
{
return
$this
->
hasOne
(
Course
::
className
(),
[
'id'
=>
'course_id'
])
->
with
(
'teachers'
)
->
with
(
'user'
);
return
$this
->
hasOne
(
Course
::
className
(),
[
'id'
=>
'course_id'
])
->
with
(
'teachers'
)
->
with
(
'user'
)
->
select
(
'id,user_id,name,price,preview_pic'
)
;
}
}
src/common/models/Income.php
View file @
5691360f
...
...
@@ -74,17 +74,21 @@ class Income extends \yii\db\ActiveRecord
];
}
/**
* @return $this
*/
public
function
getOrder
()
{
return
$this
->
hasOne
(
Orders
::
className
(),
[
'id'
=>
'orders_id'
])
->
with
(
'user'
)
->
with
(
'courseWithTeachers'
);
}
//public function getUser()
//{
// return $this->hasOne(User::className(), ['id'=>'user_id'])->viaTable(Orders::tableName(), ['id'=>'orders_id'])
// ->select('id,username,role,avatar');
//}
/**
* @param $userId
* @param int $page
* @param int $num
* @param int $status
* @return array
*/
public
static
function
getIncomeListByUserId
(
$userId
,
$page
=
0
,
$num
=
10
,
$status
=
self
::
STATUS_NOT_SETTLED
)
{
$where
=
[
'user_id'
=>
$userId
];
...
...
src/common/models/Orders.php
View file @
5691360f
...
...
@@ -98,8 +98,8 @@ class Orders extends \yii\db\ActiveRecord
//获取总数
$count
=
self
::
find
()
->
where
(
$condition
,
$params
)
->
count
();
$start
=
$page
*
$num
;
$data
=
self
::
find
()
->
select
(
"
$tableA
.course_id,
$tableA
.created_at as purchased_time,
$tableB
.name,
$tableB
.price,
$tableB
.free_time,
$tableB
.intro,
$tableB
.preview_pic,
$tableB
.created_at"
)
->
where
(
$condition
,
$params
)
->
limit
(
$num
)
->
offset
(
$start
)
->
orderBy
(
"
$tableA
.created_at DESC"
)
->
join
(
'left join '
,
$tableB
,
"
$tableA
.course_id =
$tableB
.id"
)
->
asArray
()
->
all
();
$data
=
self
::
find
()
->
where
(
$condition
,
$params
)
->
limit
(
$num
)
->
offset
(
$start
)
->
orderBy
(
"
$tableA
.created_at DESC"
)
->
join
With
(
'courseWithTeachers'
)
->
asArray
()
->
all
();
return
[
'count'
=>
$count
,
'data'
=>
$data
...
...
@@ -119,17 +119,26 @@ class Orders extends \yii\db\ActiveRecord
':course_id'
=>
$courseId
])
->
one
();
}
/**
* @return $this
*/
public
function
getUser
()
{
return
$this
->
hasOne
(
User
::
className
(),
[
'id'
=>
'user_id'
])
->
select
(
'id,username,telephone,role,avatar'
);
}
/**
* @return $this
*/
public
function
getCourse
()
{
return
$this
->
hasOne
(
Course
::
className
(),
[
'id'
=>
'course_id'
])
->
select
(
'id,user_id,name,price,preview_pic'
);
}
/**
* @return $this
*/
public
function
getCourseWithTeachers
()
{
return
$this
->
hasOne
(
Course
::
className
(),
[
'id'
=>
'course_id'
])
->
select
(
'id,user_id,name,price,preview_pic'
)
->
with
(
'teachers'
);
...
...
src/frontend/controllers/UserCenterController.php
View file @
5691360f
...
...
@@ -79,7 +79,7 @@ class UserCenterController extends Controller
$page
=
Yii
::
$app
->
request
->
get
(
'page'
,
0
);
$num
=
Yii
::
$app
->
request
->
get
(
'num'
,
10
);
$purchasedCourse
=
Orders
::
findPurchasedCourseByUserId
(
Yii
::
$app
->
user
->
getId
(),
$page
,
$num
);
var_dump
(
$purchasedCourse
);
var_dump
(
$purchasedCourse
);
exit
;
return
$this
->
render
(
'purchasedCourse'
);
}
...
...
@@ -94,7 +94,6 @@ class UserCenterController extends Controller
$page
--
;
$num
=
Yii
::
$app
->
request
->
get
(
'per-page'
,
10
);
$favorite
=
Favorite
::
findByUserId
(
Yii
::
$app
->
user
->
getId
(),
$page
,
$num
);
// var_dump($favorite);exit;
return
$this
->
render
(
'favorite'
,
[
'favorite'
=>
$favorite
]);
...
...
@@ -107,6 +106,7 @@ class UserCenterController extends Controller
public
function
actionBrowseRecord
()
{
$browseRecord
=
BrowseRecord
::
getByUserId
(
Yii
::
$app
->
user
->
getId
());
return
$this
->
render
(
'browseRecord'
);
}
...
...
src/frontend/views/layouts/userCenter.php
View file @
5691360f
...
...
@@ -32,7 +32,7 @@ $this->beginContent('@app/views/layouts/center.php');
<li
<?=
(
Yii
::
$app
->
controller
->
id
===
'user-center'
and
Yii
::
$app
->
controller
->
action
->
id
===
'browse-record'
)
?
'class = "active"'
:
''
?>
>
<a
href=
"
<?=
$baseUrl
.
'/user-center/browse-record'
?>
"
><i
class=
"glyphicon glyphicon-eye-open"
></i>
浏览记录
</a>
</li>
<li><a
href=
"
javascript:;
"
><i
class=
"glyphicon glyphicon-play-circle"
></i>
我的课堂
</a></li>
<li><a
href=
"
<?=
$baseUrl
.
'/my-course'
?>
"
><i
class=
"glyphicon glyphicon-play-circle"
></i>
我的课堂
</a></li>
<li><a
href=
"
<?=
$baseUrl
.
'/site/logout'
?>
"
><i
class=
"glyphicon glyphicon-off"
></i>
退出登录
</a></li>
</ul>
...
...
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