Преглед на файлове

音频,视频,私聊,礼物,充值

lizhen_gitee преди 1 година
родител
ревизия
8edc3dba62
променени са 5 файла, в които са добавени 110 реда и са изтрити 338 реда
  1. 2 2
      app/Console/Commands/Plantasktyping.php
  2. 60 2
      app/Http/Controllers/Controller.php
  3. 23 166
      app/Jobs/GiftJob.php
  4. 1 1
      app/Jobs/RechargeJob.php
  5. 24 167
      app/Jobs/TypingJob.php

+ 2 - 2
app/Console/Commands/Plantasktyping.php

@@ -44,7 +44,7 @@ class Plantasktyping extends Command
         $map = [
             ['plantask_status', '=' ,0]
         ];
-        $list = DB::table('mt_gift_user_typing')->where($map)->orderBy('id','asc')->get()->toArray();
+        $list = DB::table('mt_user_match_typing_log')->where($map)->orderBy('id','asc')->get()->toArray();
         //dd($list);
 
         if(!empty($list)){
@@ -60,7 +60,7 @@ class Plantasktyping extends Command
                 'plantask_status' => 1,
             ];
 
-            DB::table('mt_gift_user_typing')->whereIn('id',$ids)->update($update);
+            DB::table('mt_user_match_typing_log')->whereIn('id',$ids)->update($update);
         }
 
 

+ 60 - 2
app/Http/Controllers/Controller.php

@@ -11,6 +11,8 @@ use Illuminate\Routing\Controller as BaseController;
 use Illuminate\Support\Facades\DB;
 use App\Jobs\AudioJob;
 use App\Jobs\VideoJob;
+use App\Jobs\TypingJob;
+use App\Jobs\GiftJob;
 
 class Controller extends BaseController
 {
@@ -20,7 +22,7 @@ class Controller extends BaseController
         /*$easemob = new Easemob();
         $rs = $easemob->push_text(1009,'标题','内容');
         dd($rs);*/
-        (new AudioJob(11))->handle();
+        (new GiftJob(3))->handle();
     }
 
 
@@ -52,7 +54,9 @@ class Controller extends BaseController
         }
 
     }*/
-    public function plantask(){
+
+    //video
+    /*public function plantask(){
 
         $map = [
             ['plantask_status', '=' ,0],
@@ -77,5 +81,59 @@ class Controller extends BaseController
             DB::table('mt_user_match_video_log')->whereIn('id',$ids)->update($update);
         }
 
+    }*/
+
+    //typing
+    /*public function plantask()
+    {
+        $map = [
+            ['plantask_status', '=' ,0]
+        ];
+        $list = DB::table('mt_user_match_typing_log')->where($map)->orderBy('id','asc')->get()->toArray();
+        //dd($list);
+
+        if(!empty($list)){
+            foreach($list as $key => $val){
+                $msg_id = $val->id;
+                dispatch((new TypingJob($msg_id))->delay(0));//加入队列
+            }
+
+            //更新
+            $ids = array_column($list,'id');
+
+            $update = [
+                'plantask_status' => 1,
+            ];
+
+            DB::table('mt_user_match_typing_log')->whereIn('id',$ids)->update($update);
+        }
+
+
+    }*/
+
+    //gift
+    public function plantask(){
+        $map = [
+            ['plantask_status', '=' ,0]
+        ];
+        $list = DB::table('mt_gift_user_typing')->where($map)->orderBy('id','asc')->get()->toArray();
+        //dd($list);
+
+        if(!empty($list)){
+            foreach($list as $key => $val){
+                $msg_id = $val->id;
+                dispatch((new GiftJob($msg_id))->delay(0));//加入队列
+            }
+
+            //更新
+            $ids = array_column($list,'id');
+
+            $update = [
+                'plantask_status' => 1,
+            ];
+
+            DB::table('mt_gift_user_typing')->whereIn('id',$ids)->update($update);
+        }
+
     }
 }

+ 23 - 166
app/Jobs/GiftJob.php

@@ -12,6 +12,7 @@ use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Redis;
 use Illuminate\Support\Facades\Config;
 use Illuminate\Support\Facades\Log;
+use App\Common\Library\Alltools;
 
 class GiftJob implements ShouldQueue
 {
@@ -42,7 +43,7 @@ class GiftJob implements ShouldQueue
         $result = $this->goaaa();
 
 
-        if($result === false){
+        /*if($result === false){
             //防止失败
             $key = 'kgelavarel_giftjob_'.$this->msgid;
 
@@ -54,10 +55,30 @@ class GiftJob implements ShouldQueue
             }else{
                 //echo 345;
             }
+        }*/
+    }
+
+    //主要调用
+    public function goaaa(){
+
+        //
+        $data = DB::table('mt_gift_user_typing')->where('id',$this->msgid)->first();
+        if(empty($data)){return true;}
+
+        DB::beginTransaction();
+
+        $Alltools = new Alltools;
+        $result = $Alltools->shouyi($data->user_to_id,$data->getvalue,'gift_user_typing',$this->msgid);
+        if($result !== true){
+            DB::rollBack();
+            return false;
         }
+
+        DB::commit();
+        return true;
     }
 
-    public function apiLimit($apiLimit = 1, $apiLimitTime = 1000, $key = '')
+    private function apiLimit($apiLimit = 1, $apiLimitTime = 1000, $key = '')
     {
         $app_name    = Config::get('app.name');// laravel name
         $key         = "{$app_name}:{$key}";
@@ -78,169 +99,5 @@ class GiftJob implements ShouldQueue
         return true;
     }
 
-    public function goaaa(){
-        
-        //
-        $data = DB::table('hx_gift_user_party')->where('id',$this->msgid)->first();
-
-        DB::beginTransaction();
-
-        //用户信息
-        $authuser_info = DB::table('hx_user')->where('id',$data->user_id)->value('nickname');
-        $partyInfo     = DB::table('hx_party')->where('id',$data->party_id)->first();
-
-
-        $jewel_to_money = 1;
-        $user_id = $data->user_to_id;
-        // 添加获赠用户余额
-        if($data->getvalue > 0){
-            $getMoney = bcdiv($data->getvalue,$jewel_to_money,2);
-            if($getMoney > 0){
-                $rs_wallet = $this->lockChangeAccountRemain($user_id,$getMoney,'+',0,"{$authuser_info}送你{$data->gift_name}x{$data->number}",101,'money');
-                if($rs_wallet['status'] == false){
-                    Db::rollback();
-                    return false;
-                }
-            }
-        }
-
-        // 增加房主抽成
-        if ($partyInfo) {
-            $guilderMoney = $data->guildermoney;
-            if($guilderMoney > 0){
-                $touserInfo    = DB::table('hx_user')->where('id',$user_id)->value('nickname');
-                $rs_wallet = $this->lockChangeAccountRemain($partyInfo->user_id,$guilderMoney,'+',0,"{$authuser_info}送礼物{$data->gift_name}x{$data->number}给{$touserInfo},房间礼物抽成",102,'money');
-                if($rs_wallet['status'] == false){
-                    Db::rollback();
-                    return false;
-                }
-            }
-        }
-
-        Db::commit();
-        return true;
-    }
-
-
-    /**
-     *
-     * @param floatval $number 金额(正数进账,负数出账)
-     * @param $accountType 货币类型,money,score
-     * @param $logtype 日志的类型
-     * @param $remark  备注
-     * @param $user_id  用户id
-     * @param $table  来源表
-     * @param $data_id  表id
-     * @param $isAdmin 是否是管理员处理
-     * @return array
-     * @return array[status]
-     * @return array[msg]
-     * @return array[log_table]
-     * @return array[log_id]
-     */
-    public function lockChangeAccountRemain($user_id,$money,$mode,$before = 0,$remark='',$logtype,$accountType='money',$extend = [])
-    {
-        //初始化
-        $result = array(
-            'status'=>false,
-            'code' => 0, //报错时候采用
-            'msg'=>'',
-            'log_table' => '',
-            'log_id' => '',
-        );
-
-        //获取小数点
-        $point = $accountType == 'money' ? 2 : 0;
-        bcscale($point);
-
-        //钱包名称
-        $wallet_name = '余额';
-
-        //数字纠正
-        $money = abs($money);
-        if($mode == '-'){
-            $number = -$money;
-        }else{
-            $number = $money;
-        }
-
-        //检测
-        $number = floatval( $number );
-        if( $number == 0 )
-        {
-            $result['msg'] = '交易金额:0';
-            return $result;
-        }
-        if(0 === bccomp($number, 0)){
-            $result['msg'] = '交易金额:0';
-            return $result;
-        }
-
-
-        //检测
-        $wallet = DB::table('hx_user_wallet')->where('user_id',$user_id)->lockForUpdate()->first();
-        if(empty($wallet))
-        {
-            $result['msg'] = '不存在的用户';
-            return $result;
-        }
-
-        if(bccomp(bcadd($wallet->$accountType, $number), 0) === -1)
-        {
-            $result['code'] = 10;
-            $result['msg'] = $wallet_name.'余额不足!';
-            return $result;
-        }
-
-        if(0 !== bccomp($number, 0))
-        {
-
-            //钱币记录
-            $data = array();
-            $data['user_id'] = $user_id;
-            $data['value'] = $money;
-            $data['mode'] = $mode;
-            $data['before'] = $wallet->$accountType;
-            $data['balance'] = bcadd($wallet->$accountType, $number);
-            $data['detail'] = $remark;
-            $data['createtime'] = time();
-            $data['type'] = $logtype;
-            if ($accountType == 'jewel') {
-                $data['cityname'] = isset($extend['cityname']) ? $extend['cityname'] : '';
-            }
-            //新的方式
-            $rs1 = DB::table('hx_user_wallet')->where('user_id',$user_id)->update([$accountType => $data['balance']]);
-
-            /////////////
-            $log_table = 'hx_user_'.$accountType.'_log';
-
-            $rs2_id = DB::table($log_table)->insertGetId($data);
-
-            if($rs1 === false || $rs2_id === false){
-                $result['msg'] = '更新财务记录失败!';
-                return $result;
-            }
-
-
-            if( $rs1 !== false && $rs2_id !== false )
-            {
-                $result['status'] = true;
-                $result['msg'] = '账户余额已更新!';
-                $result['log_table'] = $accountType.'_log';
-                $result['log_id'] = $rs2_id;
-
-                return $result;
-            }
-            else
-            {
-                $result['msg'] = '更新财务记录失败!';
-                return $result;
-            }
-        } else {
-            $result['msg'] = '金额不足0.01';
-            return $result;
-        }
-
-    }
 
 }

+ 1 - 1
app/Jobs/RechargeJob.php

@@ -13,7 +13,7 @@ use Illuminate\Support\Facades\Redis;
 use Illuminate\Support\Facades\Config;
 use Illuminate\Support\Facades\Log;
 
-class GiftJob implements ShouldQueue
+class RechargeJob implements ShouldQueue
 {
     use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
 

+ 24 - 167
app/Jobs/TypingJob.php

@@ -12,8 +12,9 @@ use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Redis;
 use Illuminate\Support\Facades\Config;
 use Illuminate\Support\Facades\Log;
+use App\Common\Library\Alltools;
 
-class GiftJob implements ShouldQueue
+class TypingJob implements ShouldQueue
 {
     use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
 
@@ -42,7 +43,7 @@ class GiftJob implements ShouldQueue
         $result = $this->goaaa();
 
 
-        if($result === false){
+        /*if($result === false){
             //防止失败
             $key = 'kgelavarel_giftjob_'.$this->msgid;
 
@@ -54,10 +55,30 @@ class GiftJob implements ShouldQueue
             }else{
                 //echo 345;
             }
+        }*/
+    }
+
+    //主要调用
+    public function goaaa(){
+
+        //
+        $data = DB::table('mt_user_match_typing_log')->where('id',$this->msgid)->first();
+        if(empty($data)){return true;}
+
+        DB::beginTransaction();
+
+        $Alltools = new Alltools;
+        $result = $Alltools->shouyi($data->to_user_id,$data->money,'user_match_typing_log',$this->msgid);
+        if($result !== true){
+            DB::rollBack();
+            return false;
         }
+
+        DB::commit();
+        return true;
     }
 
-    public function apiLimit($apiLimit = 1, $apiLimitTime = 1000, $key = '')
+    private function apiLimit($apiLimit = 1, $apiLimitTime = 1000, $key = '')
     {
         $app_name    = Config::get('app.name');// laravel name
         $key         = "{$app_name}:{$key}";
@@ -78,169 +99,5 @@ class GiftJob implements ShouldQueue
         return true;
     }
 
-    public function goaaa(){
-        
-        //
-        $data = DB::table('hx_gift_user_party')->where('id',$this->msgid)->first();
-
-        DB::beginTransaction();
-
-        //用户信息
-        $authuser_info = DB::table('hx_user')->where('id',$data->user_id)->value('nickname');
-        $partyInfo     = DB::table('hx_party')->where('id',$data->party_id)->first();
-
-
-        $jewel_to_money = 1;
-        $user_id = $data->user_to_id;
-        // 添加获赠用户余额
-        if($data->getvalue > 0){
-            $getMoney = bcdiv($data->getvalue,$jewel_to_money,2);
-            if($getMoney > 0){
-                $rs_wallet = $this->lockChangeAccountRemain($user_id,$getMoney,'+',0,"{$authuser_info}送你{$data->gift_name}x{$data->number}",101,'money');
-                if($rs_wallet['status'] == false){
-                    Db::rollback();
-                    return false;
-                }
-            }
-        }
-
-        // 增加房主抽成
-        if ($partyInfo) {
-            $guilderMoney = $data->guildermoney;
-            if($guilderMoney > 0){
-                $touserInfo    = DB::table('hx_user')->where('id',$user_id)->value('nickname');
-                $rs_wallet = $this->lockChangeAccountRemain($partyInfo->user_id,$guilderMoney,'+',0,"{$authuser_info}送礼物{$data->gift_name}x{$data->number}给{$touserInfo},房间礼物抽成",102,'money');
-                if($rs_wallet['status'] == false){
-                    Db::rollback();
-                    return false;
-                }
-            }
-        }
-
-        Db::commit();
-        return true;
-    }
-
-
-    /**
-     *
-     * @param floatval $number 金额(正数进账,负数出账)
-     * @param $accountType 货币类型,money,score
-     * @param $logtype 日志的类型
-     * @param $remark  备注
-     * @param $user_id  用户id
-     * @param $table  来源表
-     * @param $data_id  表id
-     * @param $isAdmin 是否是管理员处理
-     * @return array
-     * @return array[status]
-     * @return array[msg]
-     * @return array[log_table]
-     * @return array[log_id]
-     */
-    public function lockChangeAccountRemain($user_id,$money,$mode,$before = 0,$remark='',$logtype,$accountType='money',$extend = [])
-    {
-        //初始化
-        $result = array(
-            'status'=>false,
-            'code' => 0, //报错时候采用
-            'msg'=>'',
-            'log_table' => '',
-            'log_id' => '',
-        );
-
-        //获取小数点
-        $point = $accountType == 'money' ? 2 : 0;
-        bcscale($point);
-
-        //钱包名称
-        $wallet_name = '余额';
-
-        //数字纠正
-        $money = abs($money);
-        if($mode == '-'){
-            $number = -$money;
-        }else{
-            $number = $money;
-        }
-
-        //检测
-        $number = floatval( $number );
-        if( $number == 0 )
-        {
-            $result['msg'] = '交易金额:0';
-            return $result;
-        }
-        if(0 === bccomp($number, 0)){
-            $result['msg'] = '交易金额:0';
-            return $result;
-        }
-
-
-        //检测
-        $wallet = DB::table('hx_user_wallet')->where('user_id',$user_id)->lockForUpdate()->first();
-        if(empty($wallet))
-        {
-            $result['msg'] = '不存在的用户';
-            return $result;
-        }
-
-        if(bccomp(bcadd($wallet->$accountType, $number), 0) === -1)
-        {
-            $result['code'] = 10;
-            $result['msg'] = $wallet_name.'余额不足!';
-            return $result;
-        }
-
-        if(0 !== bccomp($number, 0))
-        {
-
-            //钱币记录
-            $data = array();
-            $data['user_id'] = $user_id;
-            $data['value'] = $money;
-            $data['mode'] = $mode;
-            $data['before'] = $wallet->$accountType;
-            $data['balance'] = bcadd($wallet->$accountType, $number);
-            $data['detail'] = $remark;
-            $data['createtime'] = time();
-            $data['type'] = $logtype;
-            if ($accountType == 'jewel') {
-                $data['cityname'] = isset($extend['cityname']) ? $extend['cityname'] : '';
-            }
-            //新的方式
-            $rs1 = DB::table('hx_user_wallet')->where('user_id',$user_id)->update([$accountType => $data['balance']]);
-
-            /////////////
-            $log_table = 'hx_user_'.$accountType.'_log';
-
-            $rs2_id = DB::table($log_table)->insertGetId($data);
-
-            if($rs1 === false || $rs2_id === false){
-                $result['msg'] = '更新财务记录失败!';
-                return $result;
-            }
-
-
-            if( $rs1 !== false && $rs2_id !== false )
-            {
-                $result['status'] = true;
-                $result['msg'] = '账户余额已更新!';
-                $result['log_table'] = $accountType.'_log';
-                $result['log_id'] = $rs2_id;
-
-                return $result;
-            }
-            else
-            {
-                $result['msg'] = '更新财务记录失败!';
-                return $result;
-            }
-        } else {
-            $result['msg'] = '金额不足0.01';
-            return $result;
-        }
-
-    }
 
 }