Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
ylc.llewan.com
Project
Project
Details
Activity
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
llewan
ylc.llewan.com
Commits
9d53ca61
Commit
9d53ca61
authored
Oct 10, 2018
by
734642908@qq.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加用户游戏和商品缓存
parent
04c36902
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
115 additions
and
41 deletions
+115
-41
FlushController.class.php
Application/Home/Controller/FlushController.class.php
+21
-0
GameController.class.php
Application/Home/Controller/GameController.class.php
+55
-35
ShopController.class.php
Application/Home/Controller/ShopController.class.php
+31
-6
ShopModel.class.php
Application/Home/Model/ShopModel.class.php
+8
-0
No files found.
Application/Home/Controller/FlushController.class.php
View file @
9d53ca61
...
...
@@ -49,6 +49,26 @@ class FlushController extends BaseController
}
//刷新商品数据
public
function
goods
()
{
$goodsList
=
M
(
"yl_goods"
,
""
,
C
(
"LEWAN_HEZI"
))
->
select
();
if
(
!
empty
(
$goodsList
))
{
$redis
=
S
(
C
(
'REDIS'
));
foreach
(
$goodsList
as
$key
=>
$val
)
{
//保存游戏id(用于排序分页)
$redis
->
zadd
(
'ylc_goods_id'
,
$val
[
'sort'
],
$val
[
'sysid'
]);
//保存游戏数据
$redis
->
hset
(
'ylc_goods_list'
,
$val
[
'sysid'
],
json_encode
(
$val
));
}
exit
(
'更新成功'
);
}
else
{
exit
(
'暂无数据'
);
}
}
}
?>
\ No newline at end of file
Application/Home/Controller/GameController.class.php
View file @
9d53ca61
...
...
@@ -102,45 +102,65 @@ class GameController extends BaseController
$page
=
I
(
'page'
,
1
);
$skip
=
$size
*
(
$page
-
1
);
$model
=
$model
->
join
(
'left join yl_game on yl_game.sysid=yl_member_game.r_game'
);
$where
=
array
(
'yl_member_game.uid'
=>
$uid
,
'yl_game.status'
=>
1
);
$field
=
'yl_game.sysid as id,yl_game.name,yl_game.icon,yl_game.appid,yl_game.gourl,yl_game.gamer'
;
$gameList
=
$model
->
where
(
$where
)
->
limit
(
$skip
,
$size
)
->
order
(
'yl_member_game.create_time desc'
)
->
field
(
$field
)
->
select
();
if
(
!
empty
(
$gameList
))
{
// $model = $model->join('left join yl_game on yl_game.sysid=yl_member_game.r_game');
// $where = array(
// 'yl_member_game.uid'=>$uid
// ,'yl_game.status'=>1
// );
// $field = 'yl_game.sysid as id,yl_game.name,yl_game.icon,yl_game.appid,yl_game.gourl,yl_game.gamer';
// $gameList = $model->where($where)->limit($skip,$size)->order('yl_member_game.create_time desc')->field($field)->select();
$model
=
new
\Home\Model\GameModel
();
$gameId
=
array
();
$gameList
=
$model
->
where
(
array
(
'uid'
=>
$uid
))
->
limit
(
$skip
,
$size
)
->
order
(
'yl_member_game.create_time desc'
)
->
field
(
'r_game'
)
->
select
();
if
(
!
empty
(
$gameList
))
{
$redis
=
S
(
C
(
'REDIS'
));
foreach
(
$gameList
as
$key
=>
$val
)
{
$gameId
[]
=
$val
[
'id'
];
$gameList
[
$key
][
'typeList'
]
=
array
();
$gameList
[
$key
][
'labelList'
]
=
array
();
}
//处理分类和标签数据
if
(
!
empty
(
$gameId
))
{
$gameType
=
$model
->
type
(
$gameId
);
$gameLabel
=
$model
->
label
(
$gameId
);
if
(
!
empty
(
$gameType
)
||
!
empty
(
$gameLabel
))
{
foreach
(
$gameList
as
$key
=>
$val
)
{
if
(
!
empty
(
$gameType
))
{
foreach
(
$gameType
as
$tkey
=>
$tval
)
{
if
(
$val
[
'id'
]
==
$tval
[
'r_game'
])
{
$gameList
[
$key
][
'typeList'
][]
=
$tval
;
}
}
}
if
(
!
empty
(
$gameLabel
))
{
foreach
(
$gameLabel
as
$lkey
=>
$lval
)
{
if
(
$val
[
'id'
]
==
$lval
[
'r_game'
])
{
$gameList
[
$key
][
'labelList'
][]
=
$lval
;
}
}
}
}
$arr
=
json_decode
(
$redis
->
hget
(
'ylc_game_list'
,
$val
[
'r_game'
]),
true
);
if
(
$arr
[
'status'
]
==
1
)
{
$gameArr
[]
=
array
(
'id'
=>
$arr
[
'sysid'
]
,
'gamer'
=>
$arr
[
'gamer'
]
,
'name'
=>
$arr
[
'name'
]
,
'icon'
=>
$arr
[
'icon'
]
,
'appid'
=>
$arr
[
'appid'
]
,
'gourl'
=>
$arr
[
'gourl'
]
,
'typeList'
=>
$arr
[
'typeList'
]
,
'labelList'
=>
$arr
[
'labelList'
]
);
}
}
$gameList
=
$gameArr
;
// $model= new \Home\Model\GameModel();
// $gameId = array();
// foreach($gameList as $key=>$val) {
// $gameId[] = $val['id'];
// $gameList[$key]['typeList'] = array();
// $gameList[$key]['labelList'] = array();
// }
// //处理分类和标签数据
// if(!empty($gameId)) {
// $gameType = $model->type($gameId);
// $gameLabel = $model->label($gameId);
// if (!empty($gameType) || !empty($gameLabel)) {
// foreach ($gameList as $key => $val) {
// if (!empty($gameType)) {
// foreach ($gameType as $tkey => $tval) {
// if ($val['id'] == $tval['r_game']) {
// $gameList[$key]['typeList'][] = $tval;
// }
// }
// }
// if (!empty($gameLabel)) {
// foreach ($gameLabel as $lkey => $lval) {
// if ($val['id'] == $lval['r_game']) {
// $gameList[$key]['labelList'][] = $lval;
// }
// }
// }
// }
// }
// }
$result
=
array
(
'c'
=>
1
...
...
Application/Home/Controller/ShopController.class.php
View file @
9d53ca61
...
...
@@ -51,15 +51,40 @@ class ShopController extends BaseController
$page
=
I
(
'page'
,
1
);
$skip
=
$size
*
(
$page
-
1
);
$redis
=
S
(
C
(
'REDIS'
));
if
(
$isShow
==
1
)
{
$id
=
$redis
->
ZREVRANGE
(
'ylc_goods_id'
,
0
,
-
1
);
}
else
{
$id
=
$redis
->
ZREVRANGE
(
'ylc_goods_id'
,
$skip
,
$skip
+
$size
-
1
);
}
foreach
(
$id
as
$key
=>
$val
)
{
$arr
=
json_decode
(
$redis
->
hget
(
'ylc_goods_list'
,
$val
),
true
);
$whereArr
=
array
(
'status'
=>
1
);
$show
=
true
;
if
(
$isShow
==
1
)
{
$whereArr
[
'is_show'
]
=
$isShow
;
$show
=
$arr
[
'is_show'
]
==
1
;
}
if
(
$arr
[
'status'
]
==
1
&&
$show
)
{
$goodsArr
[]
=
array
(
'id'
=>
$arr
[
'sysid'
]
,
'name'
=>
$arr
[
'name'
]
,
'icon'
=>
$arr
[
'icon'
]
,
'price'
=>
$arr
[
'initial_price'
]
,
'stock'
=>
$arr
[
'stock'
]
,
'change_way'
=>
$arr
[
'change_way'
]
,
'type'
=>
$arr
[
'type'
]
);
}
$field
=
'sysid as id,name,icon,initial_price as price,stock,change_way,type'
;
$goodsArr
=
M
(
"yl_goods"
,
""
,
C
(
"LEWAN_HEZI"
))
->
where
(
$whereArr
)
->
field
(
$field
)
->
limit
(
$skip
,
$size
)
->
order
(
'sort desc'
)
->
select
();
}
// $whereArr = array(
// 'status'=>1
// );
// if($isShow == 1) {
// $whereArr['is_show'] = $isShow;
// }
// $field = 'sysid as id,name,icon,initial_price as price,stock,change_way,type';
// $goodsArr = M("yl_goods","",C("LEWAN_HEZI"))->where($whereArr)->field($field)->limit($skip,$size)->order('sort desc')->select();
if
(
!
empty
(
$goodsArr
))
{
$result
=
array
(
'c'
=>
1
...
...
Application/Home/Model/ShopModel.class.php
View file @
9d53ca61
...
...
@@ -122,6 +122,14 @@ class ShopModel extends BaseModel
if
(
$re1
&&
$re2
&&
$re3
)
{
$memberModel
->
commit
();
//保存商品库存缓存数据
$redis
=
S
(
C
(
'REDIS'
));
$goodsData
=
$redis
->
hget
(
'ylc_goods_list'
,
$goodsId
);
$dataArr
=
json_decode
(
$goodsData
,
true
);
$dataArr
[
'stock'
]
=
$dataArr
[
'stock'
]
-
1
;
$redis
->
hset
(
'ylc_goods_list'
,
$goodsId
,
json_encode
(
$dataArr
));
$result
=
array
(
'c'
=>
1
,
'msg'
=>
'兑换成功'
...
...
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