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
a5c649b2
Commit
a5c649b2
authored
Oct 19, 2016
by
杨培
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
我的会员页面完成
parent
24311f3e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
13 deletions
+27
-13
Member.php
src/common/models/Member.php
+14
-10
MyMemberController.php
src/frontend/controllers/MyMemberController.php
+7
-1
index.php
src/frontend/views/my-member/index.php
+6
-2
No files found.
src/common/models/Member.php
View file @
a5c649b2
...
@@ -139,17 +139,21 @@ class Member extends \yii\db\ActiveRecord
...
@@ -139,17 +139,21 @@ class Member extends \yii\db\ActiveRecord
}
}
}
}
/**
public
static
function
typeCount
(
$userId
)
* 关联成员首个订单
*
* 返回最小order_id,消费总额,以及课程信息
*
* @return $this
*/
public
function
getFirstOrder
()
{
{
return
$this
->
hasOne
(
Orders
::
className
(),
[
'id'
=>
'orders_id'
])
->
viaTable
(
Income
::
tableName
(),
[
'user_id'
=>
'user_id'
])
$data
=
self
::
find
()
->
select
(
'COUNT(1) AS count, type'
)
->
where
([
'user_id'
=>
$userId
])
->
groupBy
(
'type'
)
->
with
(
'course'
)
->
select
(
'MIN(id) AS id,credit,course_id'
);
->
asArray
()
->
all
();
$count
=
[
self
::
TYPE_NORMAL
=>
0
,
self
::
TYPE_VIP
=>
0
];
foreach
(
$data
as
$row
)
{
$count
[
$row
[
'type'
]]
=
$row
[
'count'
];
}
return
$count
;
}
}
}
}
src/frontend/controllers/MyMemberController.php
View file @
a5c649b2
...
@@ -10,6 +10,10 @@ class MyMemberController extends \yii\web\Controller
...
@@ -10,6 +10,10 @@ class MyMemberController extends \yii\web\Controller
public
$layout
=
'classCenter'
;
public
$layout
=
'classCenter'
;
/**
* 我的会员
* @return string
*/
public
function
actionIndex
()
public
function
actionIndex
()
{
{
$type
=
Yii
::
$app
->
request
->
get
(
'type'
);
$type
=
Yii
::
$app
->
request
->
get
(
'type'
);
...
@@ -17,6 +21,8 @@ class MyMemberController extends \yii\web\Controller
...
@@ -17,6 +21,8 @@ class MyMemberController extends \yii\web\Controller
$uid
=
Yii
::
$app
->
user
->
getId
();
$uid
=
Yii
::
$app
->
user
->
getId
();
$typeCount
=
Member
::
typeCount
(
$uid
);
$data
=
Member
::
getMembersByUserId
(
$uid
,
null
,
20
);
$data
=
Member
::
getMembersByUserId
(
$uid
,
null
,
20
);
//注入订单等信息
//注入订单等信息
...
@@ -24,7 +30,7 @@ class MyMemberController extends \yii\web\Controller
...
@@ -24,7 +30,7 @@ class MyMemberController extends \yii\web\Controller
Member
::
injectOrderInfo
(
$uid
,
$data
[
'data'
]);
Member
::
injectOrderInfo
(
$uid
,
$data
[
'data'
]);
}
}
return
$this
->
render
(
'index'
,
$data
);
return
$this
->
render
(
'index'
,
$data
+
compact
(
'typeCount'
)
);
}
}
}
}
src/frontend/views/my-member/index.php
View file @
a5c649b2
<?php
<?php
/**
/**
* @var $this yii\web\View
* @var $this yii\web\View
* @var $typeCount array
* @var $data array
* @var $data array
* @var $count int
* @var $pagination \yii\data\Pagination
* @var $pagination \yii\data\Pagination
*/
*/
$this
->
title
=
'我的会员'
;
?>
?>
<div
class=
"vip-top clearfix"
>
<div
class=
"vip-top clearfix"
>
<div
class=
"col-md-6"
>
<div
class=
"col-md-6"
>
<div
class=
"reg-vip-box"
>
<div
class=
"reg-vip-box"
>
<b>
47
</b>
<b>
<?=
array_sum
(
$typeCount
)
?>
</b>
<span>
全部会员
</span>
<span>
全部会员
</span>
<i
class=
"icon-verified_user"
></i>
<i
class=
"icon-verified_user"
></i>
</div>
</div>
</div>
</div>
<div
class=
"col-md-6"
>
<div
class=
"col-md-6"
>
<div
class=
"money-vip-box"
>
<div
class=
"money-vip-box"
>
<b>
23
</b>
<b>
<?=
$typeCount
[
\common\models\Member
::
TYPE_VIP
]
?>
</b>
<span>
付费会员
</span>
<span>
付费会员
</span>
<i
class=
"icon-heart"
></i>
<i
class=
"icon-heart"
></i>
</div>
</div>
...
...
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