|
@@ -682,7 +682,7 @@ class Topicdongtai extends Api
|
|
|
{
|
|
|
$this->error("请选择礼物");
|
|
|
}
|
|
|
- $giftvalue = bcmul($giftinfo['value'],$number);
|
|
|
+ $giftvalue = bcmul($giftinfo['price'],$number);
|
|
|
|
|
|
//被赠送人信息
|
|
|
$touserinfo = Db::name('user')->where('id',$user_id)->find();
|
|
@@ -704,9 +704,19 @@ class Topicdongtai extends Api
|
|
|
'gift_id' => $giftinfo['id'],
|
|
|
'gift_name' => $giftinfo['name'],
|
|
|
'number' => $number,
|
|
|
- 'price' => $giftvalue,
|
|
|
+ 'price' => $giftinfo['price'],
|
|
|
+ 'total_price' => $giftvalue,
|
|
|
'createtime' => time(),
|
|
|
];
|
|
|
+
|
|
|
+ //每个礼物都要计算平台抽成和房主抽成
|
|
|
+ $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);//减去抽成剩余价值
|
|
|
+
|
|
|
+ $money_to_gold = config('site.money_to_gold');
|
|
|
+ $data['getmoney'] = bcdiv($data['getvalue'] ,$money_to_gold,2);//收益
|
|
|
+
|
|
|
$log_id = Db::name('gift_user_dongtai')->insertGetId($data);
|
|
|
if(!$log_id){
|
|
|
Db::rollback();
|
|
@@ -720,64 +730,60 @@ class Topicdongtai extends Api
|
|
|
Db::rollback();
|
|
|
$this->error($wallet_rs['msg']);
|
|
|
}
|
|
|
-
|
|
|
- // 添加赠送用户余额
|
|
|
- $money_to_gold = config('site.money_to_gold');
|
|
|
- $gift_plat_scale = config('site.gift_plat_scale');
|
|
|
-
|
|
|
- $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,$this->auth->id,'money',$money,60,'获得礼物:'.$giftinfo["name"] . '*' . $number,'gift_user_dongtai',$log_id,2);
|
|
|
+ }
|
|
|
+ if($data['getmoney'] > 0){
|
|
|
+ // 添加获赠用户收益
|
|
|
+ $wallet_rs = model('wallet')->lockChangeAccountRemain($user_id,$this->auth->id,'money',$data['getmoney'],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']) {
|
|
|
- //获取返利比率
|
|
|
- $agent_info = Db::name('user')->where(['id' => $touserinfo['intro_uid']])->field('is_agent,h_intro_income_rebate_rate')->find();
|
|
|
- $intro_income_rebate_rate = ($agent_info['is_agent'] == 1) ? $agent_info['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']) {
|
|
|
+ //获取返利比率
|
|
|
+ $agent_info = Db::name('user')->where(['id' => $touserinfo['intro_uid']])->field('is_agent,h_intro_income_rebate_rate')->find();
|
|
|
+ $intro_income_rebate_rate = ($agent_info['is_agent'] == 1) ? $agent_info['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 = bcdiv(bcmul($data['getmoney'],$intro_income_rebate_rate,2),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) {
|
|
|
- //增加亲密度
|
|
|
- $user_intimacy_rs = addintimacy($this->auth->id, $user_id, $giftvalue);
|
|
|
- if (!$user_intimacy_rs['status']) {
|
|
|
- Db::rollback();
|
|
|
- $this->error('您的网络开小差啦~');
|
|
|
- }
|
|
|
+ if ($this->auth->gender == 1 && $touserinfo['gender'] == 0) {
|
|
|
+ //增加亲密度
|
|
|
+ $user_intimacy_rs = addintimacy($this->auth->id, $user_id, $giftvalue);
|
|
|
+ if (!$user_intimacy_rs['status']) {
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('您的网络开小差啦~');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
Db::commit();
|
|
|
|
|
|
//发送消息
|
|
|
- /*if (isset($user_intimacy_rs) && $user_intimacy_rs['level_remark']) {
|
|
|
+ if (isset($user_intimacy_rs) && $user_intimacy_rs['level_remark']) {
|
|
|
$tenim = new \app\api\controller\Tenim;
|
|
|
$tenim->sendMessageToUser($this->auth->id, $user_id, $user_intimacy_rs['level_remark'], 1);
|
|
|
- }*/
|
|
|
+ }
|
|
|
|
|
|
- $return_data['money'] = $money; //获得金额
|
|
|
+ $return_data['money'] = $data['getmoney']; //获得金额
|
|
|
$return_data['level_remark'] = isset($user_intimacy_rs) ? $user_intimacy_rs['level_remark'] : ''; //亲密度等级提示语
|
|
|
$this->success('赠送成功', $return_data);
|
|
|
}
|
|
|
+/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
//动态收到礼物列表
|
|
|
public function dongtaigiftlist() {
|
|
@@ -815,7 +821,6 @@ class Topicdongtai extends Api
|
|
|
$this->success('success', $list);
|
|
|
}
|
|
|
|
|
|
-/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
//点赞列表
|