|
@@ -68,12 +68,13 @@ class Livebc extends Api
|
|
|
//直播送礼物
|
|
|
public function givegift() {
|
|
|
// 接口防并发
|
|
|
- /*if (!$this->apiLimit(1, 1000)) {
|
|
|
+ if (!$this->apiLimit(1, 1000)) {
|
|
|
$this->error(__('Operation frequently'));
|
|
|
- }*/
|
|
|
+ }
|
|
|
|
|
|
$user_id = input('user_id');// 赠送对象
|
|
|
$gift_id = input('gift_id');// 礼物ID
|
|
|
+ $number = input('number','intval');//数量
|
|
|
|
|
|
if (!$user_id || !$gift_id )
|
|
|
{
|
|
@@ -92,6 +93,7 @@ class Livebc extends Api
|
|
|
{
|
|
|
$this->error("请选择礼物");
|
|
|
}
|
|
|
+ $giftvalue = bcmul($giftinfo['value'],$number);
|
|
|
|
|
|
//被赠送人信息
|
|
|
$touserinfo = Db::name('user')->where('id',$user_id)->find();
|
|
@@ -102,7 +104,7 @@ class Livebc extends Api
|
|
|
|
|
|
// 判断当前用户余额
|
|
|
$user_gold = model('wallet')->getWallet($this->auth->id,'gold');
|
|
|
- if($user_gold < $giftinfo['value'])
|
|
|
+ if($user_gold < $giftvalue)
|
|
|
{
|
|
|
$this->error("您的金币余额不足");
|
|
|
}
|
|
@@ -118,8 +120,8 @@ class Livebc extends Api
|
|
|
'user_to_id' => $user_id,
|
|
|
'gift_id' => $giftinfo['id'],
|
|
|
'gift_name' => $giftinfo['name'],
|
|
|
- 'number' => 1,
|
|
|
- 'price' => $giftinfo['value'],
|
|
|
+ 'number' => $number,
|
|
|
+ 'price' => $giftvalue,
|
|
|
'createtime' => time(),
|
|
|
];
|
|
|
$log_id = Db::name('gift_user_livebc')->insertGetId($data);
|
|
@@ -129,10 +131,10 @@ class Livebc extends Api
|
|
|
}
|
|
|
|
|
|
|
|
|
- if($giftinfo['value'] > 0){
|
|
|
+ if($giftvalue > 0){
|
|
|
|
|
|
// 扣除当前用户余额
|
|
|
- $wallet_rs = model('wallet')->lockChangeAccountRemain($this->auth->id,'gold',-$giftinfo['value'],55,'赠送礼物:'.$giftinfo["name"],'gift_user_typing',$log_id);
|
|
|
+ $wallet_rs = model('wallet')->lockChangeAccountRemain($this->auth->id,'gold',-$giftvalue,55,'赠送礼物:'.$giftinfo["name"],'gift_user_typing',$log_id);
|
|
|
if($wallet_rs['status'] === false){
|
|
|
Db::rollback();
|
|
|
$this->error($wallet_rs['msg']);
|
|
@@ -142,7 +144,7 @@ class Livebc extends Api
|
|
|
$money_to_gold = config('site.money_to_gold');
|
|
|
$gift_plat_scale = config('site.gift_plat_scale');
|
|
|
|
|
|
- $giftmoney = bcdiv($giftinfo['value'],$money_to_gold,2);
|
|
|
+ $giftmoney = bcdiv($giftvalue,$money_to_gold,2);
|
|
|
|
|
|
$money = bcdiv(bcmul($giftmoney,100 - $gift_plat_scale,2),100,2);
|
|
|
$wallet_rs = model('wallet')->lockChangeAccountRemain($user_id,'money',$money,56,'获得礼物:'.$giftinfo["name"],'gift_user_typing',$log_id);
|
|
@@ -157,10 +159,10 @@ class Livebc extends Api
|
|
|
$redis->connect($redisconfig["host"], $redisconfig["port"]);
|
|
|
|
|
|
// 添加redis记录做财富排行榜
|
|
|
- $redis->zIncrBy("livebc_jewel_get_" . $partyid, $giftinfo['value'], $user_id);
|
|
|
+ $redis->zIncrBy("livebc_jewel_get_" . $partyid, $giftvalue, $user_id);
|
|
|
|
|
|
// 添加redis记录做贡献排行榜
|
|
|
- $redis->zIncrBy("livebc_jewel_to_" . $partyid, $giftinfo['value'], $this->auth->id);
|
|
|
+ $redis->zIncrBy("livebc_jewel_to_" . $partyid, $giftvalue, $this->auth->id);
|
|
|
}
|
|
|
|
|
|
// tcp 获取房间用户周前三名
|