|
@@ -58,7 +58,7 @@ class Gift extends Api
|
|
|
public function givegift_typing() {
|
|
|
// 接口防并发
|
|
|
if (!$this->apiLimit(1, 1000)) {
|
|
|
- $this->error(__('Operation frequently'));
|
|
|
+ $this->error('休息一下吧');
|
|
|
}
|
|
|
|
|
|
$user_id = input('user_id');// 赠送对象
|
|
@@ -91,17 +91,17 @@ class Gift extends Api
|
|
|
$this->error("不存在的用户");
|
|
|
}
|
|
|
|
|
|
+ Db::startTrans();
|
|
|
+
|
|
|
// 判断当前用户余额
|
|
|
$user_gold = model('wallet')->getWallettotal($this->auth->id);
|
|
|
if($user_gold < $giftvalue)
|
|
|
{
|
|
|
+ Db::rollback();
|
|
|
$this->error("您的金币余额不足");
|
|
|
}
|
|
|
|
|
|
|
|
|
- Db::startTrans();
|
|
|
-
|
|
|
-
|
|
|
// 添加礼物赠送记录表
|
|
|
$data = [
|
|
|
'user_id' => $this->auth->id,
|
|
@@ -115,8 +115,8 @@ class Gift extends Api
|
|
|
];
|
|
|
//每个礼物都要计算平台抽成和房主抽成
|
|
|
$gift_plat_scale = config('site.gift_plat_scale');
|
|
|
- $data['platvalue'] = bcmul($gift_plat_scale/100 ,$data["total_price"],1);//平台抽成
|
|
|
- $data['getvalue'] = bcsub($data["total_price"] ,$data['platvalue'],1);//减去抽成剩余价值
|
|
|
+ $data['platvalue'] = bcmul($gift_plat_scale/100 ,$data['total_price'],1);//平台抽成
|
|
|
+ $data['getvalue'] = bcsub($data['total_price'] ,$data['platvalue'],1);//减去抽成剩余价值
|
|
|
|
|
|
$log_id = Db::name('gift_user_typing')->insertGetId($data);
|
|
|
if(!$log_id){
|
|
@@ -127,7 +127,7 @@ class Gift extends Api
|
|
|
if($giftvalue > 0){
|
|
|
|
|
|
// 扣除当前用户余额
|
|
|
- $wallet_rs = model('wallet')->lockChangeAccountRemain($this->auth->id,'gold',-$giftvalue,14,'赠送给'.$touserinfo['username'].'礼物:'.$giftinfo["name"].'X'.$number,'gift_user_typing',$log_id);
|
|
|
+ $wallet_rs = model('wallet')->lockChangeAccountRemain($this->auth->id,'gold',-$giftvalue,14,'赠送给'.$touserinfo['username'].'礼物:'.$giftinfo['name'].'X'.$number,'gift_user_typing',$log_id);
|
|
|
if($wallet_rs['status'] === false){
|
|
|
Db::rollback();
|
|
|
$this->error($wallet_rs['msg']);
|
|
@@ -136,13 +136,18 @@ class Gift extends Api
|
|
|
|
|
|
if($data['getvalue'] > 0){
|
|
|
|
|
|
- $wallet_rs = model('wallet')->lockChangeAccountRemain($user_id,'jewel',$data['getvalue'],24,$this->auth->username.'送给我礼物:'.$giftinfo["name"].'X'.$number,'gift_user_typing',$log_id);
|
|
|
+ $wallet_rs = model('wallet')->lockChangeAccountRemain($user_id,'jewel',$data['getvalue'],24,$this->auth->username.'送给我礼物:'.$giftinfo['name'].'X'.$number,'gift_user_typing',$log_id);
|
|
|
if($wallet_rs['status'] === false){
|
|
|
Db::rollback();
|
|
|
$this->error($wallet_rs['msg']);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //增加送礼用户的财富等级
|
|
|
+ $res_wealth = \app\common\model\User::add_wealth_level($this->auth->id,$giftvalue);
|
|
|
+ //魅力等级
|
|
|
+ $res_wealth = \app\common\model\User::add_charm_level($user_id,$giftvalue);
|
|
|
+
|
|
|
Db::commit();
|
|
|
$this->success('赠送成功');
|
|
|
|