|
@@ -234,6 +234,74 @@ class Usercenter extends Api
|
|
|
|
|
|
}
|
|
|
|
|
|
+ //视频和语音,接收方使用,如果是性别劣势方,检查钱是否够用
|
|
|
+ public function video_audio_moneycheck(){
|
|
|
+ //检测用户,发起方的uid
|
|
|
+ $to_user_id = input_post('from_user_id');
|
|
|
+ $to_user_info = Db::name('user')->field('id,real_status,gender')->where('id',$to_user_id)->find();
|
|
|
+ if(!$to_user_info){
|
|
|
+ $this->error('不存在的用户');
|
|
|
+ }
|
|
|
+
|
|
|
+ //扣费金币
|
|
|
+ $type = input_post('type','video'); //类型
|
|
|
+ $price = $type == 'video' ? config('site.video_min_price') : config('site.audio_min_price');
|
|
|
+
|
|
|
+ //发起用户的分数,被发起用户的分数。按性别给分
|
|
|
+ $auth_level = 0;
|
|
|
+ $tous_level = 0;
|
|
|
+
|
|
|
+ //打分
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+ //同性不收钱
|
|
|
+ //都是男的,不扣钱
|
|
|
+ //都是实名认证的女性,不扣钱
|
|
|
+ //都是未实名认证的女性,不扣钱
|
|
|
+ if($auth_level == $tous_level){
|
|
|
+ $price = 0;
|
|
|
+ $this->success('success');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //扣钱uid,收钱uid,收钱free_video
|
|
|
+ //分数少扣钱,分数多收益
|
|
|
+ if($auth_level < $tous_level){
|
|
|
+ $kou_user = $this->auth->id;
|
|
|
+ }else{
|
|
|
+ $kou_user = $to_user_info['id'];
|
|
|
+ }
|
|
|
+
|
|
|
+ //需要扣我的(接收方的)钱,判断钱是否够
|
|
|
+ if($price > 0 && $kou_user == $this->auth->id){
|
|
|
+ Db::startTrans();
|
|
|
+ $gold = model('wallet')->getWallet($kou_user,'gold');
|
|
|
+ if(bccomp($price,$gold) == 1){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('金币不足');
|
|
|
+ }
|
|
|
+ Db::commit();
|
|
|
+ }
|
|
|
+ $this->success('success');
|
|
|
+ }
|
|
|
+
|
|
|
//视频通话每分钟调用一次
|
|
|
public function video_onemin(){
|
|
|
//检测用户
|
|
@@ -316,6 +384,15 @@ class Usercenter extends Api
|
|
|
$get_user_free = $this->auth->free_video;
|
|
|
}
|
|
|
|
|
|
+ //需要扣别人的钱,判断钱是否购
|
|
|
+ if($price > 0 && $kou_user != $this->auth->id){
|
|
|
+ $gold = model('wallet')->getWallet($kou_user,'gold');
|
|
|
+ if(bccomp($price,$gold) == 1){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('对方金币不足');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//有性别差,扣费
|
|
|
if($price > 0){
|
|
|
$rs = model('wallet')->lockChangeAccountRemain($kou_user,'gold',-$price,11,'','user_match_video_log',$log_id);
|
|
@@ -418,6 +495,15 @@ class Usercenter extends Api
|
|
|
$get_user_free = $this->auth->free_audio;
|
|
|
}
|
|
|
|
|
|
+ //需要扣别人的钱,判断钱是否购
|
|
|
+ if($price > 0 && $kou_user != $this->auth->id){
|
|
|
+ $gold = model('wallet')->getWallet($kou_user,'gold');
|
|
|
+ if(bccomp($price,$gold) == 1){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('对方金币不足');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//有性别差,扣费
|
|
|
if($price > 0){
|
|
|
$rs = model('wallet')->lockChangeAccountRemain($kou_user,'gold',-$price,12,'','user_match_audio_log',$log_id);
|