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
83b50089
Commit
83b50089
authored
Oct 17, 2016
by
杨培
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
知识有价列表
parent
520e6928
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
74 additions
and
12 deletions
+74
-12
Income.php
src/common/models/Income.php
+40
-0
Orders.php
src/common/models/Orders.php
+9
-0
MyIncomeController.php
src/frontend/controllers/MyIncomeController.php
+5
-1
index.php
src/frontend/views/my-income/index.php
+20
-11
No files found.
src/common/models/Income.php
View file @
83b50089
...
@@ -4,6 +4,7 @@ namespace common\models;
...
@@ -4,6 +4,7 @@ namespace common\models;
use
Yii
;
use
Yii
;
use
yii\behaviors\TimestampBehavior
;
use
yii\behaviors\TimestampBehavior
;
use
yii\data\Pagination
;
use
yii\redis\ActiveRecord
;
use
yii\redis\ActiveRecord
;
/**
/**
...
@@ -18,6 +19,10 @@ use yii\redis\ActiveRecord;
...
@@ -18,6 +19,10 @@ use yii\redis\ActiveRecord;
*/
*/
class
Income
extends
\yii\db\ActiveRecord
class
Income
extends
\yii\db\ActiveRecord
{
{
const
STATUS_NOT_SETTLED
=
0
;
//未结算状态
const
STATUS_IS_SETTLED
=
1
;
//已结算状态
/**
/**
* @inheritdoc
* @inheritdoc
*/
*/
...
@@ -68,4 +73,39 @@ class Income extends \yii\db\ActiveRecord
...
@@ -68,4 +73,39 @@ class Income extends \yii\db\ActiveRecord
'updated_at'
=>
'Updated At'
,
'updated_at'
=>
'Updated At'
,
];
];
}
}
public
function
getOrder
()
{
return
$this
->
hasOne
(
Orders
::
className
(),
[
'id'
=>
'orders_id'
])
->
with
(
'user'
)
->
with
(
'course'
);
}
//public function getUser()
//{
// return $this->hasOne(User::className(), ['id'=>'user_id'])->viaTable(Orders::tableName(), ['id'=>'orders_id'])
// ->select('id,username,role,avatar');
//}
public
static
function
getIncomeListByUserId
(
$userId
,
$page
=
0
,
$num
=
10
,
$status
=
self
::
STATUS_NOT_SETTLED
)
{
$where
=
[
'user_id'
=>
$userId
];
$status
!=
null
&&
$where
[
'status'
]
=
$status
;
$count
=
self
::
find
()
->
where
(
$where
)
->
count
();
$return
=
[
'count'
=>
$count
,
'data'
=>
[]];
if
(
$page
===
null
)
{
$pagination
=
new
Pagination
([
'totalCount'
=>
$count
,
'pageSize'
=>
$num
,
'forcePageParam'
=>
false
]);
$offset
=
$pagination
->
offset
;
$return
[
'pagination'
]
=
$pagination
;
}
else
{
$offset
=
$page
*
$num
;
}
if
(
$count
>
0
)
{
$return
[
'data'
]
=
self
::
find
()
->
where
(
$where
)
->
offset
(
$offset
)
->
limit
(
$num
)
->
with
(
'order'
)
->
asArray
()
->
all
();
}
return
$return
;
}
}
}
src/common/models/Orders.php
View file @
83b50089
...
@@ -120,5 +120,14 @@ class Orders extends \yii\db\ActiveRecord
...
@@ -120,5 +120,14 @@ class Orders extends \yii\db\ActiveRecord
])
->
one
();
])
->
one
();
}
}
public
function
getUser
()
{
return
$this
->
hasOne
(
User
::
className
(),
[
'id'
=>
'user_id'
])
->
select
(
'id,username,role,avatar'
);
}
public
function
getCourse
()
{
return
$this
->
hasOne
(
Course
::
className
(),
[
'id'
=>
'course_id'
])
->
select
(
'id,user_id,name,price,preview_pic'
);
}
}
}
src/frontend/controllers/MyIncomeController.php
View file @
83b50089
...
@@ -2,6 +2,9 @@
...
@@ -2,6 +2,9 @@
namespace
frontend\controllers
;
namespace
frontend\controllers
;
use
common\models\Income
;
use
Yii
;
class
MyIncomeController
extends
\yii\web\Controller
class
MyIncomeController
extends
\yii\web\Controller
{
{
...
@@ -9,7 +12,8 @@ class MyIncomeController extends \yii\web\Controller
...
@@ -9,7 +12,8 @@ class MyIncomeController extends \yii\web\Controller
public
function
actionIndex
()
public
function
actionIndex
()
{
{
return
$this
->
render
(
'index'
);
$ret
=
Income
::
getIncomeListByUserId
(
Yii
::
$app
->
user
->
getId
(),
null
);
return
$this
->
render
(
'index'
,
$ret
);
}
}
}
}
src/frontend/views/my-income/index.php
View file @
83b50089
...
@@ -3,6 +3,21 @@
...
@@ -3,6 +3,21 @@
$this
->
title
=
'知识有价'
;
$this
->
title
=
'知识有价'
;
?>
?>
<div
class=
"buy-recode-top"
>
<div
class=
"col-md-4"
>
<h3>
结算微信
</h3>
<button
class=
"btn btn-save"
>
绑定
</button>
</div>
<div
class=
"col-md-4"
>
<h3>
已结算
</h3>
<p>
¥162.03
</p>
</div>
<div
class=
"col-md-4"
>
<h3>
待结算
</h3>
<p>
¥1829.00
</p>
</div>
</div>
<div
class=
"con-md-12"
>
<div
class=
"con-md-12"
>
<div
class=
"table-responsive table-box"
>
<div
class=
"table-responsive table-box"
>
<table
class=
"table table-hover"
>
<table
class=
"table table-hover"
>
...
@@ -16,16 +31,18 @@ $this->title = '知识有价';
...
@@ -16,16 +31,18 @@ $this->title = '知识有价';
</tr>
</tr>
</thead>
</thead>
<tbody>
<tbody>
<?php
foreach
(
$data
as
$row
)
{
?>
<tr>
<tr>
<td>
<td>
20012313131
<br/>
20012313131
<br/>
2016-12-11
2016-12-11
</td>
</td>
<td>
18788860327
/ 百丐洪七公
</td>
<td>
<?=
$row
[
'order'
][
'user'
][
''
]
?>
/ 百丐洪七公
</td>
<td>
《中国为什么这么久还没有进入社会主义社会》
</td>
<td>
《中国为什么这么久还没有进入社会主义社会》
</td>
<td>
¥123.00
</td>
<td>
¥123.00
</td>
<td>
审核中
</td>
<td>
审核中
</td>
</tr>
</tr>
<?php
}
?>
<tr>
<tr>
<td>
<td>
20012313131
<br/>
20012313131
<br/>
...
@@ -39,16 +56,8 @@ $this->title = '知识有价';
...
@@ -39,16 +56,8 @@ $this->title = '知识有价';
</tbody>
</tbody>
</table>
</table>
<div
class=
"text-center hide"
>
<div
class=
"text-center"
>
<ul
class=
"pagination pagination-sm"
>
<?=
\yii\widgets\LinkPager
::
widget
([
'pagination'
=>
$pagination
])
?>
<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>
</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