|
@@ -12,8 +12,9 @@ use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Redis;
|
|
use Illuminate\Support\Facades\Redis;
|
|
use Illuminate\Support\Facades\Config;
|
|
use Illuminate\Support\Facades\Config;
|
|
use Illuminate\Support\Facades\Log;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
+use App\Common\Library\Alltools;
|
|
|
|
|
|
-class GiftJob implements ShouldQueue
|
|
|
|
|
|
+class VideoJob implements ShouldQueue
|
|
{
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
|
|
@@ -42,7 +43,7 @@ class GiftJob implements ShouldQueue
|
|
$result = $this->goaaa();
|
|
$result = $this->goaaa();
|
|
|
|
|
|
|
|
|
|
- if($result === false){
|
|
|
|
|
|
+ /*if($result === false){
|
|
//防止失败
|
|
//防止失败
|
|
$key = 'kgelavarel_giftjob_'.$this->msgid;
|
|
$key = 'kgelavarel_giftjob_'.$this->msgid;
|
|
|
|
|
|
@@ -54,10 +55,30 @@ class GiftJob implements ShouldQueue
|
|
}else{
|
|
}else{
|
|
//echo 345;
|
|
//echo 345;
|
|
}
|
|
}
|
|
|
|
+ }*/
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //主要调用
|
|
|
|
+ public function goaaa(){
|
|
|
|
+
|
|
|
|
+ //
|
|
|
|
+ $data = DB::table('mt_user_match_video_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_video_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
|
|
$app_name = Config::get('app.name');// laravel name
|
|
$key = "{$app_name}:{$key}";
|
|
$key = "{$app_name}:{$key}";
|
|
@@ -78,169 +99,5 @@ class GiftJob implements ShouldQueue
|
|
return true;
|
|
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;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
|
|
|
|
}
|
|
}
|