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
33733ea3
Commit
33733ea3
authored
Oct 18, 2016
by
xiabin
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
603ab798
51d7c875
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
212 additions
and
30 deletions
+212
-30
Qiniu.php
src/common/components/Qiniu.php
+4
-2
Course.php
src/common/models/Course.php
+29
-0
Income.php
src/common/models/Income.php
+42
-6
Orders.php
src/common/models/Orders.php
+3
-0
ClassesInfoController.php
src/frontend/controllers/ClassesInfoController.php
+23
-4
MyIncomeController.php
src/frontend/controllers/MyIncomeController.php
+29
-2
MyMemberController.php
src/frontend/controllers/MyMemberController.php
+3
-0
QiniuCallbackController.php
src/frontend/controllers/QiniuCallbackController.php
+3
-2
index.php
src/frontend/views/classes-info/index.php
+10
-5
classCenter.php
src/frontend/views/layouts/classCenter.php
+1
-1
index.php
src/frontend/views/my-course/index.php
+4
-1
index.php
src/frontend/views/my-income/index.php
+2
-2
index.php
src/frontend/views/my-member/index.php
+59
-5
No files found.
src/common/components/Qiniu.php
View file @
33733ea3
...
@@ -134,14 +134,16 @@ class Qiniu extends Object
...
@@ -134,14 +134,16 @@ class Qiniu extends Object
$config
=
$this
->
storages
[
$storage
];
$config
=
$this
->
storages
[
$storage
];
$callbackUrl
=
Url
::
to
([
'qiniu-callback/rem-upload'
],
true
);
$callbackUrl
=
YII_ENV
==
'dev'
?
'http://t.pp.cc/tmp/qiniu_callback.php'
:
Url
::
to
([
'qiniu-callback/rem-upload'
],
true
);
$policy
=
[
$policy
=
[
'returnBody'
=>
'{"key":$(key)}'
,
'returnBody'
=>
'{"key":$(key)}'
,
'saveKey'
=>
$filename
,
'saveKey'
=>
$filename
,
'fsizeLimit'
=>
$config
[
'fsizeLimit'
],
'fsizeLimit'
=>
$config
[
'fsizeLimit'
],
'mimeLimit'
=>
$config
[
'mimeLimit'
],
'mimeLimit'
=>
$config
[
'mimeLimit'
],
'callbackUrl'
=>
'http://t.pp.cc/tmp/qiniu_callback.php'
,
'callbackUrl'
=>
$callbackUrl
,
'callbackBody'
=>
'key=$(key)&storage='
.
$storage
.
'&bucket='
.
$config
[
'bucket'
]
'callbackBody'
=>
'key=$(key)&storage='
.
$storage
.
'&bucket='
.
$config
[
'bucket'
]
.
'&uuid=$(uuid)&time=$(year)-$(mon)-$(day)+$(hour)%3A$(min)%3A$(sec)&fsize=$(fsize)'
.
'&uuid=$(uuid)&time=$(year)-$(mon)-$(day)+$(hour)%3A$(min)%3A$(sec)&fsize=$(fsize)'
.
'&w=$(imageInfo.width)&h=$(imageInfo.height)'
.
'&w=$(imageInfo.width)&h=$(imageInfo.height)'
...
...
src/common/models/Course.php
View file @
33733ea3
...
@@ -189,4 +189,33 @@ class Course extends \yii\db\ActiveRecord
...
@@ -189,4 +189,33 @@ class Course extends \yii\db\ActiveRecord
{
{
return
$this
->
hasOne
(
User
::
className
(),
[
'id'
=>
'user_id'
])
->
select
(
'id,username,role,avatar'
);;
return
$this
->
hasOne
(
User
::
className
(),
[
'id'
=>
'user_id'
])
->
select
(
'id,username,role,avatar'
);;
}
}
/**
* 统计指定用户发布的课程数量
*
* @param int $userId
* @param int $status 默认只统计审核通过的,设为 null 则统计全部
* @return int
*/
public
static
function
countCourseByUserId
(
$userId
,
$status
=
self
::
STATUS_OK
)
{
$where
=
[
'user_id'
=>
$userId
];
$status
!==
null
&&
$where
[
'status'
]
=
$status
;
return
self
::
find
()
->
where
(
$where
)
->
count
();
}
/**
* 统计指定用户发布课程的评论总数
*
* @param int $userId
* @param int $status 默认只统计审核通过的课程评论,设为 null 则统计全部
* @return int
*/
public
static
function
countCommentsByUserId
(
$userId
,
$status
=
self
::
STATUS_OK
)
{
$where
=
[
'user_id'
=>
$userId
];
$status
!==
null
&&
$where
[
'status'
]
=
$status
;
return
self
::
find
()
->
where
(
$where
)
->
sum
(
'comment_count'
);
}
}
}
src/common/models/Income.php
View file @
33733ea3
...
@@ -75,6 +75,7 @@ class Income extends \yii\db\ActiveRecord
...
@@ -75,6 +75,7 @@ class Income extends \yii\db\ActiveRecord
}
}
/**
/**
* 关联订单详细数据
* @return $this
* @return $this
*/
*/
public
function
getOrder
()
public
function
getOrder
()
...
@@ -83,16 +84,18 @@ class Income extends \yii\db\ActiveRecord
...
@@ -83,16 +84,18 @@ class Income extends \yii\db\ActiveRecord
}
}
/**
/**
* @param $userId
* 获取指定用户已出售课程的订单列表
* @param int $page
*
* @param int $num
* @param int $userId
* @param int $status
* @param int $page 页数,默认0为第1页,传null则使用系统自动分页
* @param int $num 每页数量
* @param int $status 要获取的状态,默认为全部
* @return array
* @return array
*/
*/
public
static
function
getIncomeListByUserId
(
$userId
,
$page
=
0
,
$num
=
10
,
$status
=
self
::
STATUS_NOT_SETTLED
)
public
static
function
getIncomeListByUserId
(
$userId
,
$page
=
0
,
$num
=
10
,
$status
=
null
)
{
{
$where
=
[
'user_id'
=>
$userId
];
$where
=
[
'user_id'
=>
$userId
];
$status
!=
null
&&
$where
[
'status'
]
=
$status
;
$status
!=
=
null
&&
$where
[
'status'
]
=
$status
;
$count
=
self
::
find
()
->
where
(
$where
)
->
count
();
$count
=
self
::
find
()
->
where
(
$where
)
->
count
();
$return
=
[
'count'
=>
$count
,
'data'
=>
[]];
$return
=
[
'count'
=>
$count
,
'data'
=>
[]];
...
@@ -112,4 +115,37 @@ class Income extends \yii\db\ActiveRecord
...
@@ -112,4 +115,37 @@ class Income extends \yii\db\ActiveRecord
return
$return
;
return
$return
;
}
}
/**
* 获取售出课程订单的资金统计
*
* @param int $userId
* @param int $status
* @return float
*/
public
static
function
getMoneyTotal
(
$userId
,
$status
=
null
)
{
$where
=
[
'i.user_id'
=>
$userId
];
$status
!==
null
&&
$where
[
'i.status'
]
=
$status
;
return
(
float
)
self
::
find
()
->
alias
(
'i'
)
->
where
(
$where
)
->
join
(
'LEFT JOIN'
,
Orders
::
tableName
()
.
' o'
,
'o.id=i.orders_id'
)
->
sum
(
'o.credit'
);
}
/**
* 统计指定用户时间范围内的收入
*
* @param int $userId
* @param int $timeBetween 起始时间戳
* @param int $timeAnd 结束时间戳
* @return float
*/
public
static
function
getMoneyTotalByTime
(
$userId
,
$timeBetween
,
$timeAnd
)
{
return
(
float
)
self
::
find
()
->
alias
(
'i'
)
->
join
(
'LEFT JOIN'
,
Orders
::
tableName
()
.
' o'
,
'o.id=i.orders_id'
)
->
where
([
'i.user_id'
=>
$userId
])
->
andWhere
([
'between'
,
'i.updated_at'
,
$timeBetween
,
$timeAnd
])
->
sum
(
'o.credit'
);
}
}
}
src/common/models/Orders.php
View file @
33733ea3
...
@@ -125,6 +125,7 @@ class Orders extends \yii\db\ActiveRecord
...
@@ -125,6 +125,7 @@ class Orders extends \yii\db\ActiveRecord
}
}
/**
/**
* 关联下单用户信息
* @return $this
* @return $this
*/
*/
public
function
getUser
()
public
function
getUser
()
...
@@ -133,6 +134,7 @@ class Orders extends \yii\db\ActiveRecord
...
@@ -133,6 +134,7 @@ class Orders extends \yii\db\ActiveRecord
}
}
/**
/**
* 关联课程信息
* @return $this
* @return $this
*/
*/
public
function
getCourse
()
public
function
getCourse
()
...
@@ -141,6 +143,7 @@ class Orders extends \yii\db\ActiveRecord
...
@@ -141,6 +143,7 @@ class Orders extends \yii\db\ActiveRecord
}
}
/**
/**
* 关联课程信息(包括课程的讲师列表)
* @return $this
* @return $this
*/
*/
public
function
getCourseWithTeachers
()
public
function
getCourseWithTeachers
()
...
...
src/frontend/controllers/ClassesInfoController.php
View file @
33733ea3
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
namespace
frontend\controllers
;
namespace
frontend\controllers
;
use
common\models\Classes
;
use
common\models\Classes
;
use
common\models\Course
;
use
common\models\Income
;
use
frontend\components\ClassesFilter
;
use
frontend\components\ClassesFilter
;
use
Yii
;
use
Yii
;
use
yii\filters\AccessControl
;
use
yii\filters\AccessControl
;
...
@@ -36,10 +38,29 @@ class ClassesInfoController extends \yii\web\Controller
...
@@ -36,10 +38,29 @@ class ClassesInfoController extends \yii\web\Controller
];
];
}
}
/**
* 课堂概况
* @return string
*/
public
function
actionIndex
()
public
function
actionIndex
()
{
{
$uid
=
Yii
::
$app
->
user
->
getId
();
//课堂信息
$model
=
Classes
::
findOne
(
$this
->
classStatus
[
'id'
]);
$model
=
Classes
::
findOne
(
$this
->
classStatus
[
'id'
]);
return
$this
->
render
(
'index'
,
compact
(
'model'
));
//统计课程数量
$courseCount
=
Course
::
countCourseByUserId
(
$uid
);
//统计今日收
$timeBetween
=
strtotime
(
'Today'
);
$timeAnd
=
strtotime
(
'Tomorrow'
)
-
1
;
$todayIncome
=
Income
::
getMoneyTotalByTime
(
$uid
,
$timeBetween
,
$timeAnd
);
//统计评论数量
$commentCount
=
Course
::
countCommentsByUserId
(
$uid
);
return
$this
->
render
(
'index'
,
compact
(
'model'
,
'courseCount'
,
'todayIncome'
,
'commentCount'
));
}
}
/**
/**
...
@@ -60,9 +81,7 @@ class ClassesInfoController extends \yii\web\Controller
...
@@ -60,9 +81,7 @@ class ClassesInfoController extends \yii\web\Controller
}
else
{
}
else
{
$agreement
=
1
;
$agreement
=
1
;
}
}
echo
$model
->
status
;
if
(
Yii
::
$app
->
request
->
getIsPost
())
{
if
(
Yii
::
$app
->
request
->
getIsPost
())
{
$model
->
load
(
Yii
::
$app
->
request
->
post
());
$model
->
load
(
Yii
::
$app
->
request
->
post
());
$model
->
user_id
=
Yii
::
$app
->
user
->
getId
();
$model
->
user_id
=
Yii
::
$app
->
user
->
getId
();
...
...
src/frontend/controllers/MyIncomeController.php
View file @
33733ea3
...
@@ -3,21 +3,48 @@
...
@@ -3,21 +3,48 @@
namespace
frontend\controllers
;
namespace
frontend\controllers
;
use
common\models\Income
;
use
common\models\Income
;
use
frontend\components\ClassesFilter
;
use
Yii
;
use
Yii
;
use
yii\filters\AccessControl
;
class
MyIncomeController
extends
\yii\web\Controller
class
MyIncomeController
extends
\yii\web\Controller
{
{
public
$layout
=
'classCenter'
;
public
$layout
=
'classCenter'
;
/**
* @inheritdoc
*/
public
function
behaviors
()
{
return
[
'access'
=>
[
'class'
=>
AccessControl
::
className
(),
//'only' => ['index', 'publish', 'submit'],
'rules'
=>
[
[
'allow'
=>
true
,
'roles'
=>
[
'@'
]
]
]
],
'classes'
=>
ClassesFilter
::
className
()
];
}
/**
/**
* 售课记录
* 售课记录
* @return string
* @return string
*/
*/
public
function
actionIndex
()
public
function
actionIndex
()
{
{
$ret
=
Income
::
getIncomeListByUserId
(
Yii
::
$app
->
user
->
getId
(),
null
,
20
);
$uid
=
Yii
::
$app
->
user
->
getId
();
return
$this
->
render
(
'index'
,
$ret
);
$ret
=
Income
::
getIncomeListByUserId
(
$uid
,
null
,
20
);
$settled
=
Income
::
getMoneyTotal
(
$uid
,
Income
::
STATUS_IS_SETTLED
);
$notSettled
=
Income
::
getMoneyTotal
(
$uid
,
Income
::
STATUS_NOT_SETTLED
);
return
$this
->
render
(
'index'
,
$ret
+
compact
(
'settled'
,
'notSettled'
));
}
}
}
}
src/frontend/controllers/MyMemberController.php
View file @
33733ea3
...
@@ -4,6 +4,9 @@ namespace frontend\controllers;
...
@@ -4,6 +4,9 @@ namespace frontend\controllers;
class
MyMemberController
extends
\yii\web\Controller
class
MyMemberController
extends
\yii\web\Controller
{
{
public
$layout
=
'classCenter'
;
public
function
actionIndex
()
public
function
actionIndex
()
{
{
return
$this
->
render
(
'index'
);
return
$this
->
render
(
'index'
);
...
...
src/frontend/controllers/QiniuCallbackController.php
View file @
33733ea3
...
@@ -31,9 +31,10 @@ class QiniuCallbackController extends \yii\web\Controller
...
@@ -31,9 +31,10 @@ class QiniuCallbackController extends \yii\web\Controller
//验证回调请求
//验证回调请求
$requestBody
=
file_get_contents
(
'php://input'
);
$requestBody
=
file_get_contents
(
'php://input'
);
$authorization
=
isset
(
$_SERVER
[
'HTTP_AUTHORIZATION'
])
?
$_SERVER
[
'HTTP_AUTHORIZATION'
]
:
''
;
$authorization
=
isset
(
$_SERVER
[
'HTTP_AUTHORIZATION'
])
?
$_SERVER
[
'HTTP_AUTHORIZATION'
]
:
''
;
$currentUrl
=
Yii
::
$app
->
request
->
hostInfo
.
Yii
::
$app
->
request
->
getUrl
();
$currentUrl
=
'http://t.pp.cc/tmp/qiniu_callback.php'
;
$currentUrl
=
YII_ENV
==
'dev'
?
'http://t.pp.cc/tmp/qiniu_callback.php'
:
Yii
::
$app
->
request
->
hostInfo
.
Yii
::
$app
->
request
->
getUrl
();
if
(
!
$auth
->
verifyCallback
(
$_SERVER
[
'CONTENT_TYPE'
],
$authorization
,
$currentUrl
,
$requestBody
))
{
if
(
!
$auth
->
verifyCallback
(
$_SERVER
[
'CONTENT_TYPE'
],
$authorization
,
$currentUrl
,
$requestBody
))
{
return
[
'error'
=>
'回调验证失败!'
];
return
[
'error'
=>
'回调验证失败!'
];
...
...
src/frontend/views/classes-info/index.php
View file @
33733ea3
...
@@ -2,26 +2,31 @@
...
@@ -2,26 +2,31 @@
/**
/**
* @var $this yii\web\View
* @var $this yii\web\View
* @var \common\models\Classes $model
* @var \common\models\Classes $model
* @var $courseCount int
* @var $todayIncome float
* @var $commentCount int
*/
*/
use
yii\helpers\Url
;
$this
->
title
=
'我的课堂'
;
$this
->
title
=
'我的课堂'
;
?>
?>
<div
class=
"class-name"
>
<?=
$model
->
name
?>
</div>
<div
class=
"class-name"
>
<?=
$model
->
name
?>
</div>
<div
class=
"class-intro"
>
<div
class=
"class-intro"
>
<div
class=
"col-md-4"
>
<div
class=
"col-md-4"
>
<h3>
课程总数
</h3>
<h3>
课程总数
</h3>
<p>
10
<small>
讲
</small></p>
<p>
<?=
$courseCount
?>
<small>
讲
</small></p>
<a
href=
"
#
"
>
发布课程
</a>
<a
href=
"
<?=
Url
::
to
([
'my-course/publish'
])
?>
"
>
发布课程
</a>
<i
class=
"icon-play"
></i>
<i
class=
"icon-play"
></i>
</div>
</div>
<div
class=
"col-md-4"
>
<div
class=
"col-md-4"
>
<h3>
今日收益
</h3>
<h3>
今日收益
</h3>
<p>
192.00
<small>
元
</small></p>
<p>
<?=
$todayIncome
?>
<small>
元
</small></p>
<a
href=
"
#
"
>
查看账单
</a>
<a
href=
"
<?=
Url
::
to
([
'my-income/index'
])
?>
"
>
查看账单
</a>
<i
class=
"icon-clipboard"
></i>
<i
class=
"icon-clipboard"
></i>
</div>
</div>
<div
class=
"col-md-4"
>
<div
class=
"col-md-4"
>
<h3>
今日发言
</h3>
<h3>
今日发言
</h3>
<p>
891
<small>
条
</small></p>
<p>
<?=
$commentCount
?>
<small>
条
</small></p>
<i
class=
"icon-speech-bubble"
></i>
<i
class=
"icon-speech-bubble"
></i>
</div>
</div>
</div>
</div>
\ No newline at end of file
src/frontend/views/layouts/classCenter.php
View file @
33733ea3
...
@@ -33,7 +33,7 @@ $this->beginContent('@app/views/layouts/center.php');
...
@@ -33,7 +33,7 @@ $this->beginContent('@app/views/layouts/center.php');
<li>
<li>
<div
class=
"link"
><i
class=
"icon-fingerprint"
></i>
我的会员
<i
class=
"icon-navigate_next"
></i></div>
<div
class=
"link"
><i
class=
"icon-fingerprint"
></i>
我的会员
<i
class=
"icon-navigate_next"
></i></div>
<ul
class=
"submenu"
>
<ul
class=
"submenu"
>
<li><a
href=
"
#
"
>
会员列表
</a></li>
<li><a
href=
"
/my-member
"
>
会员列表
</a></li>
</ul>
</ul>
</li>
</li>
<li>
<li>
...
...
src/frontend/views/my-course/index.php
View file @
33733ea3
...
@@ -36,4 +36,7 @@ $qiniu = \Yii::$app->qiniu;
...
@@ -36,4 +36,7 @@ $qiniu = \Yii::$app->qiniu;
</div>
</div>
<?php
}
?>
<?php
}
?>
</div>
</div>
<?=
LinkPager
::
widget
([
'pagination'
=>
$pagination
])
?>
\ No newline at end of file
<div
class=
"text-center"
>
<?=
LinkPager
::
widget
([
'pagination'
=>
$pagination
])
?>
</div>
src/frontend/views/my-income/index.php
View file @
33733ea3
...
@@ -10,11 +10,11 @@ $this->title = '知识有价';
...
@@ -10,11 +10,11 @@ $this->title = '知识有价';
</div>
</div>
<div
class=
"col-md-4"
>
<div
class=
"col-md-4"
>
<h3>
已结算
</h3>
<h3>
已结算
</h3>
<p>
¥
162.03
</p>
<p>
¥
<?=
$settled
?>
</p>
</div>
</div>
<div
class=
"col-md-4"
>
<div
class=
"col-md-4"
>
<h3>
待结算
</h3>
<h3>
待结算
</h3>
<p>
¥
1829.00
</p>
<p>
¥
<?=
$notSettled
?>
</p>
</div>
</div>
</div>
</div>
...
...
src/frontend/views/my-member/index.php
View file @
33733ea3
<?php
<?php
/* @var $this yii\web\View */
/* @var $this yii\web\View */
?>
?>
<h1>
my-member/index
</h1>
<div
class=
"vip-top clearfix"
>
<div
class=
"col-md-6"
>
<div
class=
"reg-vip-box"
>
<b>
47
</b>
<span>
全部会员
</span>
<i
class=
"icon-verified_user"
></i>
</div>
</div>
<div
class=
"col-md-6"
>
<div
class=
"money-vip-box"
>
<b>
23
</b>
<span>
付费会员
</span>
<i
class=
"icon-heart"
></i>
</div>
</div>
</div>
<p>
<div
class=
"con-md-12"
>
You may change the content of this page by modifying
<div
class=
"table-responsive table-box"
>
the file
<code>
<?=
__FILE__
;
?>
</code>
.
<table
class=
"table table-hover"
>
</p>
<thead>
<tr>
<th>
注册时间
</th>
<th>
会员信息
</th>
<th>
来自
</th>
<th>
首次购买
</th>
<th>
累计消费
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
2016-12-11
</td>
<td>
18788860327 / 百丐洪七公
</td>
<td>
推广
</td>
<td>
《中国为什么这么久还没有进入社会主义社会》
</td>
<td>
¥123.00
</td>
</tr>
<tr>
<td>
2016-12-11
</td>
<td>
18788860327 / 百丐洪七公
</td>
<td>
推广
</td>
<td>
《中国为什么这么久还没有进入社会主义社会》
</td>
<td>
¥123.00
</td>
</tr>
</tbody>
</table>
<div
class=
"text-center hide"
>
<ul
class=
"pagination pagination-sm"
>
<li><a
href=
"#"
>
«
</a></li>
<li><a
href=
"#"
>
1
</a></li>
<li><a
href=
"#"
>
2
</a></li>
<li><a
href=
"#"
>
3
</a></li>
<li><a
href=
"#"
>
4
</a></li>
<li><a
href=
"#"
>
5
</a></li>
<li><a
href=
"#"
>
»
</a></li>
</ul>
</div>
</div>
</div>
\ 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