|
@@ -557,8 +557,7 @@ class Topicdongtai extends Api
|
|
|
$this->error(__('Operation frequently'));
|
|
|
}
|
|
|
|
|
|
-// $user_id = input('user_id');// 赠送对象
|
|
|
- $dt_id = input('dt_id', 0, 'intval'); //动态id
|
|
|
+ $dt_id = input('dt_id', 0, 'intval'); //动态id
|
|
|
$gift_id = input('gift_id');// 礼物ID
|
|
|
$number = input('number',1,'intval');//数量
|
|
|
|
|
@@ -586,7 +585,7 @@ class Topicdongtai extends Api
|
|
|
{
|
|
|
$this->error("请选择礼物");
|
|
|
}
|
|
|
- $giftvalue = bcmul($giftinfo['value'],$number);
|
|
|
+ $giftvalue = bcmul($giftinfo['value'],$number,2);
|
|
|
|
|
|
//被赠送人信息
|
|
|
$touserinfo = Db::name('user')->where('id',$user_id)->find();
|
|
@@ -594,9 +593,16 @@ class Topicdongtai extends Api
|
|
|
$this->error("不存在的用户");
|
|
|
}
|
|
|
// 判断当前用户余额
|
|
|
- $user_gold = model('wallet')->getWallet($this->auth->id,'gold');
|
|
|
- if($user_gold < $giftvalue) {
|
|
|
- $this->error("您的金币余额不足");
|
|
|
+ if($giftinfo['wallettype'] == 1){
|
|
|
+ $user_gold = model('wallet')->getWallet($this->auth->id,'gold');
|
|
|
+ if($user_gold < $giftvalue) {
|
|
|
+ $this->error("您的金币不足");
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $user_jewel = model('wallet')->getWallet($this->auth->id,'jewel');
|
|
|
+ if($user_jewel < $giftvalue) {
|
|
|
+ $this->error("您的钻石不足");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
Db::startTrans();
|
|
@@ -610,6 +616,7 @@ class Topicdongtai extends Api
|
|
|
'number' => $number,
|
|
|
'price' => $giftvalue,
|
|
|
'createtime' => time(),
|
|
|
+ 'wallettype' => $giftinfo['wallettype'],
|
|
|
];
|
|
|
$log_id = Db::name('gift_user_dongtai')->insertGetId($data);
|
|
|
if(!$log_id){
|
|
@@ -619,62 +626,47 @@ class Topicdongtai extends Api
|
|
|
|
|
|
if($giftvalue > 0){
|
|
|
// 扣除当前用户余额
|
|
|
- $wallet_rs = model('wallet')->lockChangeAccountRemain($this->auth->id,$user_id,'gold',-$giftvalue,59,'赠送礼物:'.$giftinfo["name"] . '*' . $number,'gift_user_dongtai',$log_id);
|
|
|
- if($wallet_rs['status'] === false){
|
|
|
- Db::rollback();
|
|
|
- $this->error($wallet_rs['msg']);
|
|
|
- }
|
|
|
-
|
|
|
- // 添加赠送用户余额
|
|
|
- $money_to_gold = config('site.money_to_gold');
|
|
|
- $gift_plat_scale = config('site.gift_plat_scale');
|
|
|
+ if($giftinfo['wallettype'] == 1){
|
|
|
+ $wallet_rs = model('wallet')->lockChangeAccountRemain($this->auth->id,$user_id,'gold',-$giftvalue,59,'赠送礼物:'.$giftinfo["name"] . '*' . $number,'gift_user_dongtai',$log_id);
|
|
|
+ if($wallet_rs['status'] === false){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error($wallet_rs['msg']);
|
|
|
+ }
|
|
|
|
|
|
- $giftmoney = bcdiv($giftvalue,$money_to_gold,2);
|
|
|
+ // 添加赠送用户余额
|
|
|
+ $gold_to_money = config('site.gold_to_money');//送金币礼物得积分
|
|
|
+ $gift_plat_scale = config('site.gift_plat_scale');
|
|
|
|
|
|
- $money = bcdiv(bcmul($giftmoney,100 - $gift_plat_scale,2),100,2);
|
|
|
- $wallet_rs = model('wallet')->lockChangeAccountRemain($user_id,$this->auth->id,'money',$money,60,'获得礼物:'.$giftinfo["name"] . '*' . $number,'gift_user_dongtai',$log_id,2);
|
|
|
- if($wallet_rs['status'] === false){
|
|
|
- Db::rollback();
|
|
|
- $this->error($wallet_rs['msg']);
|
|
|
- }
|
|
|
+ $giftmoney = bcdiv($giftvalue,$gold_to_money,2);
|
|
|
|
|
|
- /*//增加赠送用户上级金币
|
|
|
- if ($touserinfo['intro_uid']) {
|
|
|
- //获取返利比率
|
|
|
- $intro_gift_rebate_rate = (int)config('site.intro_gift_rebate_rate'); //邀请人收礼物返利比率
|
|
|
- if ($intro_gift_rebate_rate > 0 && $intro_gift_rebate_rate <= 100) {
|
|
|
- //上级获得金币数量
|
|
|
- $intro_uid_gold = floor($giftvalue * $intro_gift_rebate_rate / 100);
|
|
|
- if ($intro_uid_gold > 0) {
|
|
|
- $intro_result = model('Wallet')->lockChangeAccountRemain($touserinfo['intro_uid'],$user_id,'gold',$intro_uid_gold,66, '动态礼物获赠奖励','gift_user_dongtai',$log_id);
|
|
|
- if($intro_result['status']===false)
|
|
|
- {
|
|
|
- Db::rollback();
|
|
|
- $this->error($intro_result['msg']);
|
|
|
- }
|
|
|
- }
|
|
|
+ $money = bcdiv(bcmul($giftmoney,100 - $gift_plat_scale,2),100,2);
|
|
|
+ $wallet_rs = model('wallet')->lockChangeAccountRemain($user_id,$this->auth->id,'money',$money,60,'获得礼物:'.$giftinfo["name"] . '*' . $number,'gift_user_dongtai',$log_id,2);
|
|
|
+ if($wallet_rs['status'] === false){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error($wallet_rs['msg']);
|
|
|
}
|
|
|
- }*/
|
|
|
- //增加赠送用户上级余额
|
|
|
- if ($touserinfo['intro_uid']) {
|
|
|
- //获取返利比率
|
|
|
- $is_agent = Db::name('user')->where(['id' => $touserinfo['intro_uid']])->value('is_agent');
|
|
|
- $intro_income_rebate_rate = $is_agent ? (int)config('site.h_intro_income_rebate_rate') : (int)config('site.intro_income_rebate_rate'); //邀请人收礼物返利比率
|
|
|
- if ($intro_income_rebate_rate > 0 && $intro_income_rebate_rate <= 100) {
|
|
|
- //上级获得金额
|
|
|
- $intro_uid_money = number_format($money * $intro_income_rebate_rate / 100, 2, '.', '');
|
|
|
- if ($intro_uid_money > 0) {
|
|
|
- $intro_result = model('Wallet')->lockChangeAccountRemain($touserinfo['intro_uid'],$user_id,'money',$intro_uid_money,68, '邀请人动态礼物获赠奖励','gift_user_dongtai',$log_id);
|
|
|
- if($intro_result['status']===false)
|
|
|
- {
|
|
|
- Db::rollback();
|
|
|
- $this->error($intro_result['msg']);
|
|
|
+
|
|
|
+
|
|
|
+ //增加赠送用户上级余额
|
|
|
+ if ($touserinfo['intro_uid']) {
|
|
|
+ //获取返利比率
|
|
|
+ $is_agent = Db::name('user')->where(['id' => $touserinfo['intro_uid']])->value('is_agent');
|
|
|
+ $intro_income_rebate_rate = $is_agent ? (int)config('site.h_intro_income_rebate_rate') : (int)config('site.intro_income_rebate_rate'); //邀请人收礼物返利比率
|
|
|
+ if ($intro_income_rebate_rate > 0 && $intro_income_rebate_rate <= 100) {
|
|
|
+ //上级获得金额
|
|
|
+ $intro_uid_money = number_format($money * $intro_income_rebate_rate / 100, 2, '.', '');
|
|
|
+ if ($intro_uid_money > 0) {
|
|
|
+ $intro_result = model('Wallet')->lockChangeAccountRemain($touserinfo['intro_uid'],$user_id,'money',$intro_uid_money,68, '邀请人动态礼物获赠奖励','gift_user_dongtai',$log_id);
|
|
|
+ if($intro_result['status']===false)
|
|
|
+ {
|
|
|
+ Db::rollback();
|
|
|
+ $this->error($intro_result['msg']);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- if ($this->auth->gender == 1 && $touserinfo['gender'] == 0) {
|
|
|
+ if ($this->auth->gender == 1 && $touserinfo['gender'] == 0) {
|
|
|
//增加亲密度
|
|
|
$user_intimacy_rs = addintimacy($this->auth->id, $user_id, $giftvalue);
|
|
|
if (!$user_intimacy_rs['status']) {
|
|
@@ -682,15 +674,16 @@ class Topicdongtai extends Api
|
|
|
$this->error('您的网络开小差啦~');
|
|
|
}
|
|
|
}
|
|
|
+ }else{
|
|
|
+ $wallet_rs = model('wallet')->lockChangeAccountRemain($this->auth->id,$user_id,'jewel',-$giftvalue,39,'赠送礼物:'.$giftinfo["name"] . '*' . $number,'gift_user_dongtai',$log_id);
|
|
|
+ if($wallet_rs['status'] === false){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error($wallet_rs['msg']);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- //tag任务赠送金币
|
|
|
- //搭讪奖励
|
|
|
-// $task_rs = \app\common\model\TaskLog::tofinish($this->auth->id,15);
|
|
|
-// if($task_rs === false){
|
|
|
-// Db::rollback();
|
|
|
-// $this->error('完成任务赠送奖励失败');
|
|
|
-// }
|
|
|
+
|
|
|
|
|
|
Db::commit();
|
|
|
|