|
@@ -264,6 +264,55 @@ class Usercenter extends Api
|
|
|
Db::commit();
|
|
|
$this->success('success');
|
|
|
}
|
|
|
+ //语音通话每分钟调用一次
|
|
|
+ public function audio_onemin(){
|
|
|
+ $to_user_id = input_post('to_user_id');
|
|
|
+
|
|
|
+ //先检查今天免费的一分钟
|
|
|
+ $start = strtotime(date('Y-m-d'));
|
|
|
+ $end = $start + 86399;
|
|
|
+
|
|
|
+ $map = [
|
|
|
+ 'user_id' => $this->auth->id,
|
|
|
+ 'createtime' => ['between',[$start,$end]],
|
|
|
+ 'price' => 0,
|
|
|
+ ];
|
|
|
+
|
|
|
+ $check = Db::name('user_match_audio_log')->where($map)->find();
|
|
|
+
|
|
|
+ //设置价格
|
|
|
+ $price = config('site.audio_min_price');
|
|
|
+ $price = empty($check) ? 0 : $price;
|
|
|
+
|
|
|
+
|
|
|
+ Db::startTrans();
|
|
|
+
|
|
|
+ //记录日志
|
|
|
+ $data = [
|
|
|
+ 'user_id' => $this->auth->id,
|
|
|
+ 'price' => $price,
|
|
|
+ 'createtime' => time(),
|
|
|
+ 'to_user_id' => $to_user_id,
|
|
|
+ ];
|
|
|
+
|
|
|
+ $log_id = Db::name('user_match_audio_log')->insertGetId($data);
|
|
|
+ if(!$log_id){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('扣费失败');
|
|
|
+ }
|
|
|
+
|
|
|
+ //扣费
|
|
|
+ if(!empty($check) && $log_id){
|
|
|
+ $rs = model('wallet')->lockChangeAccountRemain($this->auth->id,'gold',-$price,11,'','user_match_audio_log',$log_id);
|
|
|
+ if($rs['status'] === false){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error($rs['msg']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Db::commit();
|
|
|
+ $this->success('success');
|
|
|
+ }
|
|
|
|
|
|
//语音匹配
|
|
|
public function getaudiouser(){
|