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
838db557
Commit
838db557
authored
Sep 18, 2018
by
734642908@qq.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
竞拍接口
parent
40ae74fb
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
201 additions
and
1 deletion
+201
-1
AuctionController.class.php
Application/Home/Controller/AuctionController.class.php
+0
-0
GameController.class.php
Application/Home/Controller/GameController.class.php
+1
-1
AuctionModel.class.php
Application/Home/Model/AuctionModel.class.php
+200
-0
No files found.
Application/Home/Controller/AuctionController.class.php
0 → 100644
View file @
838db557
This diff is collapsed.
Click to expand it.
Application/Home/Controller/GameController.class.php
View file @
838db557
...
...
@@ -110,7 +110,7 @@ class GameController extends BaseController
$where
[
'sysid'
]
=
array
(
'not in'
,
$gameId
);
}
$gameList
=
M
(
"yl_game"
,
""
,
C
(
"LEWAN_HEZI"
))
->
where
(
$where
)
->
field
(
'sysid,name,gamer,icon,appid,gourl'
)
->
select
();
$gameList
=
M
(
"yl_game"
,
""
,
C
(
"LEWAN_HEZI"
))
->
where
(
$where
)
->
field
(
'sysid,name,gamer,icon,appid,gourl'
)
->
order
(
'rand()'
)
->
limit
(
4
)
->
select
();
if
(
!
empty
(
$gameList
))
{
$result
=
array
(
...
...
Application/Home/Model/AuctionModel.class.php
0 → 100644
View file @
838db557
<?php
namespace
Home\Model
;
class
AuctionModel
extends
BaseModel
{
//竞拍获胜
function
awardSave
(
$goodsInfo
)
{
$awardModel
=
M
(
"game_auction_award"
,
""
,
$this
->
__lewan_hezi
);
$awardModel
->
startTrans
();
//记录竞拍获奖用户
$awardArr
=
array
(
'uid'
=>
$goodsInfo
[
'bid_uid'
]
,
'nickname'
=>
$goodsInfo
[
'nickname'
]
,
'goods_id'
=>
$goodsInfo
[
'id'
]
,
'create_time'
=>
date
(
'Y-m-d H:i:s'
)
,
'bid_price'
=>
$goodsInfo
[
'bid_price'
]
,
'bid_total'
=>
$goodsInfo
[
'bid_total'
]
,
'auction_info'
=>
json_encode
(
$goodsInfo
)
,
'game_code'
=>
'ylc'
);
$re1
=
$awardModel
->
add
(
$awardArr
);
//记录用户金币操作
$goldArr
=
array
(
'uid'
=>
$goodsInfo
[
'bid_uid'
]
,
'handle'
=>
'reduce'
,
'gold_num'
=>
$goodsInfo
[
'bid_price'
]
,
'add_time'
=>
date
(
'Y-m-d H:i:s'
)
,
'way'
=>
'auction_success'
,
'game_code'
=>
'ylc'
);
$re2
=
M
(
"game_auction_award"
,
""
,
$this
->
__lewan_hezi
)
->
add
(
$goldArr
);
//更新用户金币数量
$re3
=
M
(
"game_member"
,
""
,
$this
->
__lewan_hezi
)
->
where
(
array
(
'uid'
=>
$goodsInfo
[
'bid_uid'
]))
->
setDec
(
'gold'
,
$goodsInfo
[
'bid_price'
]);
if
(
$re1
&&
$re2
&&
$re3
)
{
$awardModel
->
commit
();
//更新redis商品竞拍状态
$goodsInfo
[
'status'
]
=
3
;
$goodsInfo
[
'end_time'
]
=
date
(
'Y-m-d H:i'
);
$goodsJson
=
json_encode
(
$goodsInfo
);
S
(
C
(
'REDIS'
))
->
set
(
$goodsInfo
[
'id'
],
$goodsJson
);
}
}
//竞拍报名
function
enrollSave
(
$userid
,
$goods_id
,
$remind
,
$gold
)
{
$memberModel
=
M
(
"game_member"
,
""
,
$this
->
__lewan_hezi
);
$memberModel
->
startTrans
();
//更新用户金币数量
try
{
$re3
=
$memberModel
->
where
(
array
(
'uid'
=>
$userid
))
->
setDec
(
'gold'
,
$gold
);
}
catch
(
\Exception
$e
)
{
return
$result
=
array
(
'c'
=>
2
,
'msg'
=>
'报名失败,玩币不足'
);
}
if
(
$re3
)
{
//竞拍用户报名
$enrollArr
=
array
(
'uid'
=>
$userid
,
'goods_id'
=>
$goods_id
,
'create_time'
=>
date
(
'Y-m-d H:i:s'
)
,
'game_code'
=>
'ylc'
,
'remind'
=>
$remind
);
$re1
=
M
(
"game_auction_enroll"
,
""
,
$this
->
__lewan_hezi
)
->
add
(
$enrollArr
);
//记录用户金币操作
$goldArr
=
array
(
'uid'
=>
$userid
,
'handle'
=>
'reduce'
,
'gold_num'
=>
$gold
,
'add_time'
=>
date
(
'Y-m-d H:i:s'
)
// ,'add_ip'=>$ip
,
'way'
=>
'auction_enroll'
,
'game_code'
=>
'ylc'
);
$re2
=
M
(
"game_member_gold"
,
""
,
$this
->
__lewan_hezi
)
->
add
(
$goldArr
);
if
(
$re1
&&
$re2
)
{
$memberModel
->
commit
();
$result
=
array
(
'c'
=>
1
,
'msg'
=>
'报名成功'
);
}
else
{
$result
=
array
(
'c'
=>
2
,
'msg'
=>
'报名失败'
);
}
}
else
{
$result
=
array
(
'c'
=>
2
,
'msg'
=>
'报名失败,玩币不足'
);
}
return
$result
;
}
//竞拍出价
function
bidSave
(
$uid
,
$goods_id
,
$price
,
$goodsInfo
)
{
$memberModel
=
M
(
"game_member"
,
""
,
$this
->
__lewan_hezi
);
$memberModel
->
startTrans
();
//获取用户金币信息数据
$userArr
=
$memberModel
->
where
(
array
(
'uid'
=>
$uid
))
->
field
(
'uid,gold,user_nickname'
)
->
find
();
if
(
$userArr
[
'gold'
]
<
$price
)
{
return
$result
=
array
(
'c'
=>
2
,
'msg'
=>
'玩币不足'
);
}
try
{
//更新用户竞拍信息
$updateArr
=
array
(
// 'bid_num'=>'bid_num-1'
'bid_num'
=>
array
(
'exp'
,
'bid_num-1'
)
,
'bid_price'
=>
$price
// ,'bid_total'=>'bid_total+1'
,
'bid_total'
=>
array
(
'exp'
,
'bid_total+1'
)
);
$updateWhere
=
array
(
'uid'
=>
$uid
,
'goods_id'
=>
$goods_id
,
'game_code'
=>
'ylc'
);
$re1
=
M
(
"game_auction_enroll"
,
""
,
$this
->
__lewan_hezi
)
->
where
(
$updateWhere
)
->
save
(
$updateArr
);
}
catch
(
\Exception
$e
)
{
return
$result
=
array
(
'c'
=>
2
,
'msg'
=>
'出价次数已用完'
);
}
if
(
$re1
)
{
//记录用户竞拍出价
$bidArr
=
array
(
'uid'
=>
$uid
,
'nickname'
=>
$userArr
[
'user_nickname'
]
,
'goods_id'
=>
$goods_id
,
'bid_price'
=>
$price
,
'game_code'
=>
'ylc'
,
'create_time'
=>
date
(
'Y-m-d H:i:s'
)
);
$re2
=
M
(
"game_auction_bid"
,
""
,
$this
->
__lewan_hezi
)
->
add
(
$bidArr
);
if
(
$re2
)
{
$memberModel
->
commit
();
$goodsInfo
[
'bid_price'
]
=
$price
;
$goodsInfo
[
'bid_total'
]
+=
1
;
$goodsInfo
[
'bid_uid'
]
=
$uid
;
$goodsInfo
[
'bid_nickname'
]
=
$userArr
[
'user_nickname'
];
$goodsInfo
[
'bid_time'
]
=
date
(
'Y-m-d H:i:s'
);
S
(
C
(
'REDIS'
))
->
set
(
$goods_id
,
json_encode
(
$goodsInfo
));
$result
=
array
(
'c'
=>
1
,
'msg'
=>
'出价成功'
,
'd'
=>
array
(
'bid_price'
=>
$price
//出价金币
,
'user_gold'
=>
$userArr
[
'gold'
]
-
$price
//用户金币
)
);
}
else
{
$result
=
array
(
'c'
=>
2
,
'msg'
=>
'出价失败'
);
}
}
else
{
$result
=
array
(
'c'
=>
2
,
'msg'
=>
'出价次数已用完'
);
}
return
$result
;
}
}
\ 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