|
@@ -323,7 +323,7 @@ class Usercenter extends Api
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if($money > 0 && $get_user_free['free_video'] == 0){
|
|
|
+ if($money > 0 && $get_user_free == 0){
|
|
|
$rs = model('wallet')->lockChangeAccountRemain($get_user,'money',$money,21,'','user_match_video_log',$log_id);
|
|
|
if($rs['status'] === false){
|
|
|
Db::rollback();
|
|
@@ -336,38 +336,60 @@ class Usercenter extends Api
|
|
|
}
|
|
|
|
|
|
public function audio_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.audio_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_audio_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.audio_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_audio_log')->insertGetId($data);
|
|
@@ -376,18 +398,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,12,'','user_match_audio_log',$log_id);
|
|
|
+
|
|
|
+ if($auth_level == $tous_level){
|
|
|
+ Db::commit();
|
|
|
+ $this->success('success');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if($auth_level < $tous_level){
|
|
|
+ $kou_user = $this->auth->id;
|
|
|
+ $get_user = $to_user_info['id'];
|
|
|
+ $get_user_free = $to_user_info['free_audio'];
|
|
|
+ }else{
|
|
|
+ $kou_user = $to_user_info['id'];
|
|
|
+ $get_user = $this->auth->id;
|
|
|
+ $get_user_free = $this->auth->free_audio;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if($price > 0){
|
|
|
+ $rs = model('wallet')->lockChangeAccountRemain($kou_user,'gold',-$price,12,'','user_match_audio_log',$log_id);
|
|
|
if($rs['status'] === false){
|
|
|
Db::rollback();
|
|
|
$this->error($rs['msg']);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if($money > 0 && $to_user_info['gender'] == 0 && $to_user_info['free_audio'] == 0){
|
|
|
- $rs = model('wallet')->lockChangeAccountRemain($to_user_id,'money',$money,22,'','user_match_audio_log',$log_id);
|
|
|
+ if($money > 0 && $get_user_free == 0){
|
|
|
+ $rs = model('wallet')->lockChangeAccountRemain($get_user,'money',$money,22,'','user_match_audio_log',$log_id);
|
|
|
if($rs['status'] === false){
|
|
|
Db::rollback();
|
|
|
$this->error($rs['msg']);
|