Commit 838db557 authored by 734642908@qq.com's avatar 734642908@qq.com

竞拍接口

parent 40ae74fb
<?php
namespace Home\Controller;
use Think\Controller;
/*
* 进入应用控制器
*
*/
class AuctionController extends BaseController
{
public $countdown = 150;
public $enrollGold = 100;
//竞拍商品列表
public $goodsList = array(
array(
'date'=>'2018-09-10'
,'name'=>'一期竞拍'
,'list'=> array(
array(
'id'=>'hezijp001'
,'name'=>'【抖音爆款】会唱歌的妖娆花'
,'icon'=>'auction/1/icon.jpg'
,'cover'=>'auction/1/head.jpg'
,'desc'=>array(
'auction/1/desc1.jpg'
,'auction/1/desc2.jpg'
,'auction/1/desc3.jpg'
,'auction/1/desc4.jpg'
,'auction/1/desc5.jpg'
,'auction/1/desc6.jpg'
,'auction/1/desc7.jpg'
)
,'original_price'=>10000
,'range_price'=>2
,'initial_price'=>10
,'bid_price'=>10
,'enroll_price'=>10
,'start_time'=>'2018-09-18 11:43'
,'end_time'=>''
,'status'=>'1'
)
,array(
'id'=>'hezijp002'
,'name'=>'【妈妈最爱】BB锅'
,'icon'=>'auction/2/icon.jpg'
,'cover'=>'auction/2/head.jpg'
,'desc'=>array(
'auction/2/desc1.jpg'
,'auction/2/desc2.jpg'
,'auction/2/desc3.jpg'
,'auction/2/desc4.jpg'
)
,'original_price'=>10000
,'range_price'=>2
,'initial_price'=>10
,'bid_price'=>10
,'enroll_price'=>10
,'start_time'=>'2018-09-20 21:00'
,'end_time'=>''
,'status'=>'1'
)
,array(
'id'=>'hezijp003'
,'name'=>'【爱的牵引】防走失背包'
,'icon'=>'auction/3/icon.jpg'
,'cover'=>'auction/3/head.jpg'
,'desc'=>array(
'auction/3/desc1.jpg'
,'auction/3/desc2.jpg'
,'auction/3/desc3.jpg'
,'auction/3/desc4.jpg'
,'auction/3/desc5.jpg'
)
,'original_price'=>10000
,'range_price'=>2
,'initial_price'=>10
,'bid_price'=>10
,'enroll_price'=>10
,'start_time'=>'2018-09-11 21:10'
,'end_time'=>''
,'status'=>'1'
)
)
)
,array(
'date'=>'2018-09-11'
,'name'=>'二期竞拍'
,'list'=> array(
array(
'id'=>'hezijp004'
,'name'=>'【明星同款】会学人说话的火烈鸟'
,'icon'=>'auction/4/icon.jpg'
,'cover'=>'auction/4/head.jpg'
,'desc'=>array(
'auction/4/desc1.jpg'
,'auction/4/desc2.jpg'
,'auction/4/desc3.jpg'
,'auction/4/desc4.jpg'
,'auction/4/desc5.jpg'
)
,'original_price'=>10000
,'range_price'=>2
,'initial_price'=>10
,'bid_price'=>10
,'enroll_price'=>10
,'start_time'=>'2018-09-11 21:30'
,'end_time'=>''
,'status'=>'1'
)
,array(
'id'=>'hezijp005'
,'name'=>'【陪玩神器】面包超人跳跳球'
,'icon'=>'auction/5/icon.jpg'
,'cover'=>'auction/5/head.jpg'
,'desc'=>array(
'auction/5/desc1.jpg'
,'auction/5/desc2.jpg'
,'auction/5/desc3.jpg'
)
,'original_price'=>10000
,'range_price'=>2
,'initial_price'=>10
,'bid_price'=>10
,'enroll_price'=>10
,'start_time'=>'2018-09-11 21:35'
,'end_time'=>''
,'status'=>'1'
)
)
)
,array(
'date'=>'2018-09-14'
,'name'=>'三期竞拍'
,'list'=> array(
array(
'id'=>'hezijp006'
,'name'=>'【童年回忆】mini游戏掌机'
,'icon'=>'auction/6/icon.jpg'
,'cover'=>'auction/6/head.jpg'
,'desc'=>array(
'auction/6/desc1.jpg'
,'auction/6/desc2.jpg'
,'auction/6/desc3.jpg'
,'auction/6/desc4.jpg'
,'auction/6/desc5.jpg'
)
,'original_price'=>10000
,'range_price'=>2
,'initial_price'=>10
,'bid_price'=>10
,'enroll_price'=>10
,'start_time'=>'2018-09-14 17:45'
,'end_time'=>''
,'status'=>'1'
)
,array(
'id'=>'hezijp007'
,'name'=>'【抖音同款】不会倒的蜘蛛侠'
,'icon'=>'auction/7/icon.jpg'
,'cover'=>'auction/7/head.jpg'
,'desc'=>array(
'auction/7/desc1.jpg'
,'auction/7/desc2.jpg'
,'auction/7/desc3.jpg'
,'auction/7/desc4.jpg'
,'auction/7/desc5.jpg'
,'auction/7/desc6.jpg'
)
,'original_price'=>10000
,'range_price'=>2
,'initial_price'=>10
,'bid_price'=>10
,'enroll_price'=>10
,'start_time'=>'2018-09-14 17:55'
,'end_time'=>''
,'status'=>'1'
)
)
)
);
private function init_redis() {
//连接本地的 Redis 服务
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
return $redis;
}
//竞拍商品列表接口
public function goodsList(){
//竞拍商品列表
$goodsList = $this->goodsList;
//获取竞拍商品信息
$redis = S(C('REDIS'));
$leftArray = array();
$rightArray = array();
foreach($goodsList as $key=>$val) {
$lleftArray = array();
$lrightArray = array();
foreach($val['list'] as $lkey=>$lval) {
$goodsInfo = $redis->get($lval['id']);
// $goodsInfo = json_decode($goodsJson, true);
//判断是否到竞拍时间
if(strtotime($lval['start_time']) <= time()) {
$lval['status'] = 2;
}
if(empty($lval['bid_total'])) {
$lval['bid_total'] = 0;
}
if(!empty($goodsInfo) && $goodsInfo['status'] > 1) {
//竞拍结束处理
if( $goodsInfo['status'] < 3) {
if(empty($goodsInfo['bid_time']) && (strtotime($goodsInfo['start_time'])+600) <= time()) {
//没用户参与,十分钟自动结束
$goodsInfo['status'] = 3;
$goodsInfo['end_time'] = date('Y-m-d H:i');
$goodsJson = json_encode($goodsInfo);
$redis->set($goodsInfo['id'],$goodsJson);
} else if(!empty($goodsInfo['bid_time']) && (intval(strtotime($goodsInfo['bid_time']))+$this->countdown) <= time()) {
//竞拍胜出
$model= new \Home\Model\AuctionModel($goodsInfo);
$model->awardSave();
} else {
//没有用户参与报名竞拍
// $enrollNum = $GLOBALS["conn"]->NumRows($GLOBALS["conn"]->Query("select sysid from ".get_table("game_auction_enroll")." where game_code='hezi' and goods_id='".$goodsInfo['id']."'"));
$enrollNum = M("game_auction_enroll","",C("LEWAN_HEZI"))->where(array('game_code'=>'ylc','goods_id'=>$goodsInfo['id']))->count();
if($enrollNum < 1) {
//没有用户报名竞拍,更新redis商品竞拍状态
$goodsInfo['status'] = 3;
$goodsInfo['end_time'] = date('Y-m-d H:i');
$goodsJson = json_encode($goodsInfo);
$redis->set($goodsInfo['id'],$goodsJson);
}
}
}
$goodsList[$key]['list'][$lkey] = $goodsInfo;
$lval = $goodsInfo;
} else {
$goodsList[$key]['list'][$lkey] = $lval;
$redis->set($lval['id'],json_encode($lval));
}
//$lmid = strtotime($lval['start_time'])-time(); //获取一个用于分割的关键字,一般是首个元素
if($goodsInfo['status'] > 2) {
$lrightArray[] = $lval;
} else {
$lleftArray[] = $lval;
}
$goodsList[$key]['list'] = array_merge($lleftArray,$lrightArray); //组合两个结果
}
$mid = strtotime($val['date'])-strtotime(date('Y-m-d')); //获取一个用于分割的关键字,一般是首个元素
if($mid >= 0) {
$leftArray[] = $goodsList[$key];
} else {
$rightArray[] = $goodsList[$key];
}
}
$goodsList = array_merge($leftArray,$rightArray); //组合两个结果
$result = array(
'c'=>1
,'msg'=>'获取成功'
,'d' => array(
'list' => $goodsList,
'activity_date' => '2018.09.10-2018.09.20'
)
);
echo $this->formatRes($result);
}
//竞拍商品详情接口
public function goodsInfo(){
$token = decryptToken(I('token'));
$goodsId = I('goods_id');
if($token == false) {
$result = array(
'c'=>2
,'msg'=>'token不正确'
);
echo $this->formatRes($result);exit;
} else if(empty($goodsId)) {
$result = array(
'c'=>2
,'msg'=>'goods_id参数不存在'
);
echo $this->formatRes($result);exit;
}
//获取竞拍商品信息
$goodsInfo = S(C('REDIS'))->get($goodsId);
if(empty($goodsInfo)) {
$result = array(
'c'=>2
,'msg'=>'goods_id参数错误'
);
echo $this->formatRes($result);exit;
}
$uid = $token['uid'];
//获取竞拍用户报名信息
$userArr = array(
'uid'=>$uid
,'bid_price'=>''
,'bid_num'=>0
,'status'=>1
);
$enrollNum = 0;
$userList = M("game_auction_enroll","",C("LEWAN_HEZI"))->where(array('game_code'=>'ylc','goods_id'=>$goodsId))->field('uid,bid_price,bid_num')->select();
foreach($userList as $key=>$value) {
if($value['uid'] == $uid) {
$userArr = $value;
$userArr['status'] = 2;
}
$enrollNum++;
}
//报名人数
$goodsInfo['enroll_num'] = $enrollNum;
//获取用户金币信息数据
$goldrArr = M("game_member","",C("LEWAN_HEZI"))->where(array('uid'=>$uid))->field('uid,gold,user_nickname')->find();
$userArr['gold'] = $goldrArr['gold']-$userArr['bid_price'];
//用户奖品领取状态
$userArr['auction_status'] = 0;
$userArr['receive_status'] = 0;
if($goodsInfo['bid_uid'] == $uid) {
$userArr['auction_status'] = 1;
//竞拍获奖用户信息数据
$awardArr = M("game_auction_award","",C("LEWAN_HEZI"))->where(array('uid'=>$uid,'game_code'=>'ylc','goods_id'=>$goodsInfo['id']))->field('uid,receive_status')->find();
if(!empty($awardArr)) {
$userArr['receive_status'] = $awardArr['receive_status'];
}
}
$result = array(
'c'=>1
,'msg'=>'获取成功'
,'d' => array(
'auction_info' => $goodsInfo
,'user_info' => $userArr
,'countdown' => $this->countdown
,'time' => time().'000'
)
);
echo $this->formatRes($result);
}
//用户竞拍报名
public function userEnroll(){
$token = decryptToken(I('token'));
$goodsId = I('goods_id');
$remind = I('remind',1);
if($token == false) {
$result = array(
'c'=>2
,'msg'=>'token不正确'
);
echo $this->formatRes($result);exit;
} else if(empty($goodsId)) {
$result = array(
'c'=>2
,'msg'=>'goods_id参数不存在'
);
echo $this->formatRes($result);exit;
}
//获取竞拍商品信息
$goodsInfo = S(C('REDIS'))->get($goodsId);
if(empty($goodsInfo)) {
$result = array(
'c'=>2
,'msg'=>'goods_id参数错误'
);
echo $this->formatRes($result);exit;
}
//获取竞拍商品信息
if($goodsInfo['status'] > 1) {
$result = array(
'c'=>2
,'msg'=>'报名已截至'
);
echo $this->formatRes($result);exit;
}
$uid = $token['uid'];
$num = M("game_auction_enroll","",C("LEWAN_HEZI"))->where(array('uid'=>$uid,'goods_id'=>$goodsId))->count();
if($num > 0) {
$result = array(
'c'=>2
,'msg'=>'已报名'
);
echo $this->formatRes($result);exit;
}
//保存报名信息
$model= new \Home\Model\AuctionModel();
$result = $model->enrollSave($uid,$goodsId,$remind,$this->enrollGold);
echo $this->formatRes($result);exit;
}
//竞拍商品出价接口
public function userBid()
{
$token = decryptToken(I('token'));
$goodsId = I('goods_id');
$price = I('price');
if($token == false) {
$result = array(
'c'=>2
,'msg'=>'token不正确'
);
echo $this->formatRes($result);exit;
} else if(empty($goodsId)) {
$result = array(
'c'=>2
,'msg'=>'goods_id参数不存在'
);
echo $this->formatRes($result);exit;
} else if(empty($price)) {
$result = array(
'c'=>2
,'msg'=>'price参数不存在'
);
echo $this->formatRes($result);exit;
}
//获取竞拍商品信息
$goodsInfo = S(C('REDIS'))->get($goodsId);
if(empty($goodsInfo)) {
$result = array(
'c'=>2
,'msg'=>'goods_id参数错误'
);
echo $this->formatRes($result);exit;
}
$uid = $token['uid'];
//判断竞拍商品状态
if($goodsInfo['status'] == 1 && strtotime($goodsInfo['start_time']) > time()) {
$result = array(
'c'=>2
,'msg'=>'竞拍还没开始'
);
} else if($goodsInfo['status'] == 3) {
$result = array(
'c'=>2
,'msg'=>'竞拍已结束开始'
);
} else {
//判断是否已是出价最高用户
if($goodsInfo['bid_uid'] == $uid) {
$result = array(
'c'=>2
,'msg'=>'已是出价最高用户'
);
echo $this->formatRes($result);exit;
} else if($goodsInfo['bid_price'] >= $price) {
$result = array(
'c'=>2
,'msg'=>'出价低于当前商品竞拍价格'
);
} else if(($goodsInfo['bid_price']+$goodsInfo['range_price']) < $price) {
$result = array(
'c'=>2
,'msg'=>'出价高于当前商品竞拍价格范围'
);
} else {
//保存报名信息
$model= new \Home\Model\AuctionModel();
$result = $model->bidSave($uid,$goodsId,$price,$goodsInfo);
}
}
echo $this->formatRes($result);exit;
}
//获取竞拍中商品详情接口
public function auctionInfo()
{
$goodsId = I('goods_id');
if(empty($goodsId)) {
$result = array(
'c'=>2
,'msg'=>'goods_id参数不存在'
);
echo $this->formatRes($result);exit;
}
//获取竞拍商品信息
$goodsInfo = S(C('REDIS'))->get($goodsId);
if(empty($goodsInfo)) {
$result = array(
'c'=>2
,'msg'=>'goods_id参数错误'
);
} else {
$result = array(
'c'=>1
,'msg'=>'获取成功'
,'d'=>array(
'auction_info' => $goodsInfo,
'time' => time().'000',
)
);
}
echo $this->formatRes($result);exit;
}
//获取用户竞拍列表接口
public function userAuction()
{
$token = decryptToken(I('token'));
if($token == false) {
$result = array(
'c'=>2
,'msg'=>'token不正确'
);
echo $this->formatRes($result);exit;
}
$uid = $token['uid'];
//获取用户报名参与竞拍
$auctionArr = M("game_auction_enroll","",C("LEWAN_HEZI"))->where(array('uid'=>$uid))->order('create_time desc')->select();
if(!empty($auctionArr)) {
//获取竞拍商品信息
foreach($auctionArr as $key=>$val) {
//获取竞拍商品详情信息
$goodsInfo = S(C('REDIS'))->get($val['goods_id']);
$goodsInfo['auction_status'] = 0;//用户竞拍状态 0-竞拍失败 1-竞拍成功
$goodsInfo['receive_status'] = 0;//奖品领取状态 0-未领取 1-已领取
if($goodsInfo['bid_uid'] == $uid) {
$goodsInfo['auction_status'] = 1;
//竞拍获奖用户信息数据
$awardWhere = array(
'uid'=>$uid
,'game_code'=>'ylc'
,'goods_id'=>$goodsInfo['id']
);
$awardArr = M("game_auction_award","",C("LEWAN_HEZI"))->where($awardWhere)->field('uid,receive_status')->find();
if(!empty($awardArr)) {
$goodsInfo['receive_status'] = $awardArr['receive_status'];
}
}
$auctionArr[$key] = $goodsInfo;
}
$result = array(
'c'=>1
,'msg'=>'获取成功'
,'d'=>array(
'auction_info' => $auctionArr
)
);
} else {
$result = array(
'c'=>2
,'msg'=>'没有内容'
);
}
echo $this->formatRes($result);exit;
}
//获取用户地址信息
public function userAddress(){
$token = decryptToken(I('token'));
if($token == false) {
$result = array(
'c'=>2
,'msg'=>'token不正确'
);
echo $this->formatRes($result);exit;
}
$uid = $token['uid'];
//获取用户今天做任务数据
$addressArr = M("game_member_address","",C("LEWAN_HEZI"))->where(array('uid'=>$uid,'game_code'=>'ylc'))->find();
if(!empty($addressArr)) {
$result = array(
'c'=>1
,'msg'=>'获取成功'
,'d'=> array(
'consignee'=> $addressArr['consignee']
,'phone' => $addressArr['phone']
,'address' => $addressArr['address']
)
);
} else {
$result = array(
'c'=>2
,'msg'=>'没有内容'
);
}
echo $this->formatRes($result);exit;
}
//保存用户地址信息
public function saveAddress(){
$token = decryptToken(I('token'));
$consignee = I('consignee');
$phone = I('phone');
$address = I('address');
$goods_id = I('goods_id');
$receive = I('receive');
if($token == false) {
$result = array(
'c'=>2
,'msg'=>'token不正确'
);
echo $this->formatRes($result);exit;
} else if(empty($consignee)) {
$result = array(
'c'=>2
,'msg'=>'consignee参数不存在'
);
echo $this->formatRes($result);exit;
} else if(empty($phone)) {
$result = array(
'c'=>2
,'msg'=>'phone参数不存在'
);
echo $this->formatRes($result);exit;
} else if(empty($address)) {
$result = array(
'c'=>2
,'msg'=>'address参数不存在'
);
echo $this->formatRes($result);exit;
}
$uid = $token['uid'];
$userAddress = M("game_member_address","",C("LEWAN_HEZI"))->where(array('uid'=>$uid,'game_code'=>'ylc'))->count();
if($userAddress > 0) {
//更新用户地址信息
$updateArr = array(
'consignee'=>$consignee
,'phone'=>$phone
,'address'=>$address
);
M("game_member_address","",C("LEWAN_HEZI"))->where(array('uid'=>$uid,'game_code'=>'ylc'))->save($updateArr);
} else {
//新增用户地址信息
$addArr = array(
'uid'=>$uid
,'consignee'=>$consignee
,'phone'=>$phone
,'address'=>$address
,'create_time'=>date('Y-m-d H:i:s')
,'game_code'=>'ylc'
);
M("game_member_address","",C("LEWAN_HEZI"))->add($addArr);
}
if(!empty($goods_id) && !empty($receive)) {
//更新用户领奖信息
$updateArr = array(
'consignee'=>$consignee
,'phone'=>$phone
,'address'=>$address
,'receive_status'=>$receive
);
$updateWhere = array(
'uid'=>$uid
,'game_code'=>'ylc'
,'goods_id'=>$goods_id
);
M("game_auction_award","",C("LEWAN_HEZI"))->where($updateWhere)->save($updateArr);
}
$result = array(
'c'=>1
,'msg'=>'保存成功'
);
echo $this->formatRes($result);exit;
}
}
?>
\ No newline at end of file
...@@ -110,7 +110,7 @@ class GameController extends BaseController ...@@ -110,7 +110,7 @@ class GameController extends BaseController
$where['sysid'] = array('not in',$gameId); $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)) { if(!empty($gameList)) {
$result = array( $result = array(
......
<?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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment