|
@@ -233,40 +233,61 @@ class Usercenter extends Api
|
|
|
}
|
|
|
|
|
|
//视频通话每分钟调用一次
|
|
|
- //女性不收费,互关不收费,设置不收费的也不收费
|
|
|
public function video_onemin(){
|
|
|
+ //检测用户
|
|
|
$to_user_id = input_post('to_user_id');
|
|
|
- $to_user_info = Db::name('user')->field('id,gender,free_video,free_audio,free_typing')->where('id',$to_user_id)->find();
|
|
|
+ $to_user_info = Db::name('user')->field('id,real_status,gender,free_video,free_audio,free_typing')->where('id',$to_user_id)->find();
|
|
|
if(!$to_user_info){
|
|
|
$this->error('不存在的用户');
|
|
|
}
|
|
|
|
|
|
- //先检查今天免费的一分钟
|
|
|
- $start = strtotime(date('Y-m-d'));
|
|
|
- $end = $start + 86399;
|
|
|
+ //正常价格
|
|
|
+ $price = config('site.video_min_price'); //扣费金币
|
|
|
+ $bili = config('site.money_to_gold'); //兑换比例
|
|
|
+ $gift_plat_scale = config('site.gift_plat_scale'); //抽成比例
|
|
|
+ $money = bcdiv($price,$bili,2); //对应人民币
|
|
|
+ $money = bcdiv(bcmul($money,100 - $gift_plat_scale,2),100,2); //抽成后收益
|
|
|
|
|
|
- $map = [
|
|
|
- 'user_id' => $this->auth->id,
|
|
|
- 'createtime' => ['between',[$start,$end]],
|
|
|
- 'price' => 0,
|
|
|
- ];
|
|
|
+ //发起用户的分数,被发起用户的分数。按性别给分
|
|
|
+ $auth_level = 0;
|
|
|
+ $tous_level = 0;
|
|
|
|
|
|
- $check = Db::name('user_match_video_log')->where($map)->find();
|
|
|
+ //打分
|
|
|
+ if($this->auth->gender == 0 && $this->auth->real_status == 1){
|
|
|
+ $auth_level = 30;//实名女最高
|
|
|
+ }
|
|
|
+ if($this->auth->gender == 0 && $this->auth->real_status != 1){
|
|
|
+ $auth_level = 20;//未实名女次之
|
|
|
+ }
|
|
|
+ if($this->auth->gender == 1){
|
|
|
+ $auth_level = 10;//男性最低
|
|
|
+ }
|
|
|
+ if($to_user_info['gender'] == 0 && $to_user_info['real_status'] == 1){
|
|
|
+ $tous_level = 30;
|
|
|
+ }
|
|
|
+ if($to_user_info['gender'] == 0 && $to_user_info['real_status'] != 1){
|
|
|
+ $tous_level = 20;
|
|
|
+ }
|
|
|
+ if($to_user_info['gender'] == 1){
|
|
|
+ $tous_level = 10;
|
|
|
+ }
|
|
|
|
|
|
- //设置价格
|
|
|
- $price = config('site.video_min_price');
|
|
|
- $price = empty($check) ? 0 : $price;
|
|
|
- $bili = config('site.money_to_gold');
|
|
|
- $money = bcdiv($price,$bili,2);
|
|
|
+ //同性不收钱
|
|
|
+ //都是男的,不扣钱
|
|
|
+ //都是实名认证的女性,不扣钱
|
|
|
+ //都是未实名认证的女性,不扣钱
|
|
|
+ if($auth_level == $tous_level){
|
|
|
+ $price = 0;$money = 0;
|
|
|
+ }
|
|
|
|
|
|
Db::startTrans();
|
|
|
-
|
|
|
//记录日志
|
|
|
$data = [
|
|
|
'user_id' => $this->auth->id,
|
|
|
'price' => $price,
|
|
|
'createtime' => time(),
|
|
|
'to_user_id' => $to_user_id,
|
|
|
+ 'money' => $money,
|
|
|
];
|
|
|
|
|
|
$log_id = Db::name('user_match_video_log')->insertGetId($data);
|
|
@@ -275,18 +296,35 @@ class Usercenter extends Api
|
|
|
$this->error('扣费失败');
|
|
|
}
|
|
|
|
|
|
- //扣费
|
|
|
- //男的,或 未实名认证的女的 都要扣费
|
|
|
- if($price > 0 && (($this->auth->gender == 1) || ($this->auth->gender == 0 && $this->auth->idcard_status != 1))){
|
|
|
- $rs = model('wallet')->lockChangeAccountRemain($this->auth->id,'gold',-$price,11,'','user_match_video_log',$log_id);
|
|
|
+ //同性别,提前结束
|
|
|
+ if($auth_level == $tous_level){
|
|
|
+ Db::commit();
|
|
|
+ $this->success('success');
|
|
|
+ }
|
|
|
+
|
|
|
+ //扣钱uid,收钱uid,收钱free_video
|
|
|
+ //分数少扣钱,分数多收益
|
|
|
+ if($auth_level < $tous_level){
|
|
|
+ $kou_user = $this->auth->id;
|
|
|
+ $get_user = $to_user_info['id'];
|
|
|
+ $get_user_free = $to_user_info['free_video'];
|
|
|
+ }else{
|
|
|
+ $kou_user = $to_user_info['id'];
|
|
|
+ $get_user = $this->auth->id;
|
|
|
+ $get_user_free = $this->auth->free_video;
|
|
|
+ }
|
|
|
+
|
|
|
+ //有性别差,扣费
|
|
|
+ if($price > 0){
|
|
|
+ $rs = model('wallet')->lockChangeAccountRemain($kou_user,'gold',-$price,11,'','user_match_video_log',$log_id);
|
|
|
if($rs['status'] === false){
|
|
|
Db::rollback();
|
|
|
$this->error($rs['msg']);
|
|
|
}
|
|
|
}
|
|
|
//另一方加钱,0收费
|
|
|
- if($money > 0 && $to_user_info['gender'] == 0 && $to_user_info['free_video'] == 0){
|
|
|
- $rs = model('wallet')->lockChangeAccountRemain($to_user_id,'money',$money,21,'','user_match_video_log',$log_id);
|
|
|
+ if($money > 0 && $get_user_free['free_video'] == 0){
|
|
|
+ $rs = model('wallet')->lockChangeAccountRemain($get_user,'money',$money,21,'','user_match_video_log',$log_id);
|
|
|
if($rs['status'] === false){
|
|
|
Db::rollback();
|
|
|
$this->error($rs['msg']);
|