call(function (){ // $data=DB::table('se_code')->where('id','>=',1778504)->where('model','1:6:36')->where('level',1)->get(); // foreach ($data as $k=>$v){ // $name='新36/第'.($k+1).'批'; // $this->code('http://fangw.jiuweiyun.cn/api/auth/'.$v->code,$k,$v->security_code,$v->level,0,$name); // $re=SeCode::where('id','>=',1778504)->where('pid',$v->sort)->with(['get_child'])->get(); // foreach ($re as $ke=>$va){ // $this->code('http://fangw.jiuweiyun.cn/api/auth/'.$va->code,$k,$va->security_code,$va->level,$ke+1,$name); // foreach ($va->get_child as $kes=>$vas){ // $this->code('http://fangw.jiuweiyun.cn/api/auth/'.$vas->code,$k,$vas->security_code,$vas->level,$ke+1,$name,$kes+1); // } // } // } // })->everyMinute(); // $schedule->call(function (){ // $data=SeCode::where('id','>',1777663)->where('model','1:10')->where('level',1)->with(['get_child'])->get(); // foreach ($data as $k=>$v){ // $name='10/第'.($k+1).'批'; // $this->codes('http://fangw.jiuweiyun.cn/api/auth/'.$v->code,$k,$v->security_code,$v->level,0,$name); // foreach ($v->get_child as $ke=>$va){ // $this->codes('http://fangw.jiuweiyun.cn/api/auth/'.$va->code,$k,$va->security_code,$va->level,$ke+1,$name); // } // } // })->everyMinute(); // $schedule->command('inspire') // ->hourly(); $schedule->call(function (){ Log::error('s'); })->everyMinute(); $schedule->call(function (){ $data=DB::table('inte_review')->where('season',22)->paginate(200); foreach ($data as $ke=>$va){ $img = file_get_contents($va->imgurl); // $img = file_get_contents('1208_1587087511_3wzFd27yxL.jpg'); $img = base64_encode($img); $client=new Client(); $url='https://aip.baidubce.com/rest/2.0/ocr/v1/accurate_basic?access_token=24.c806ef3eeef3e0686c331b84da7ecb49.2592000.1589681450.282335-14562722'; // $url='https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic?access_token=24.c806ef3eeef3e0686c331b84da7ecb49.2592000.1589681450.282335-14562722'; $array=[ // 'form_params'=>[ // 'access_token'=>'24.c806ef3eeef3e0686c331b84da7ecb49.2592000.1589681450.282335-14562722' // ], 'form_params'=>[ 'image'=>$img ] ]; $data=$client->request('POST',$url,$array); $ad = json_decode($data->getBody()->getContents()); $crr=[]; foreach ($ad->words_result as $k=>$v){ $crr[$k]=$v->words; } $str=implode('',$crr); // dump($str); if(strpos($str,'查看零钱') || strpos($str,'零钱明细') ||strpos($str,'提现银行')){ return ['code'=>800]; }elseif(in_array('交易说明',$crr) || in_array('商家订单号',$crr) ||in_array('发起退款',$crr)){ $str=implode($crr); $pattem1="/(20)\d{26}/"; preg_match($pattem1,str_replace(" ","",$str),$match1); if($match1){ $order_no=$match1[0]; } $pattem2="/(¥|\+)([1-9]\d{0,2},)*\d{1,3}\.\d{2}/"; preg_match($pattem2,$str,$match2); if($match2){ $fee=str_replace(",","",mb_substr($match2[0],1)); }else{ $pattem2="/(¥|\+)([1-9]\d{0,2})*\d{1,3}\.\d{2}/"; preg_match($pattem2,$str,$match2); if($match2){ $fee=str_replace(",","",mb_substr($match2[0],1)); } } $pattem3="/(20)\d{2}-\d{2}-\d{2}\s?\d{2}:\d{2}/"; preg_match($pattem3,$str,$match3); if($match3){ $time=substr($match3[0],0,10); } $type=1; }elseif(in_array('收款方式',$crr) || in_array('转账备注',$crr) ||in_array('对方账户',$crr)){ $str=implode($crr); $pattem1="/(20)\d{30}/"; preg_match($pattem1,str_replace(" ","",$str),$match1); if($match1){ $order_no=$match1[0]; }else{ $pattem1="/(订单号2)\d{29,30}/"; preg_match($pattem1,str_replace(" ","",$str),$match1); if($match1){ $order_no=mb_substr($match1[0],3); } } $pattem2="/(¥|\+)([1-9]\d{0,2},)*\d{1,3}\.\d{2}/"; preg_match($pattem2,$str,$match2); if($match2){ $fee=str_replace(",","",mb_substr($match2[0],1)); } $pattem3="/(20)\d{2}-\d{2}-\d{2}\s?\d{2}:\d{2}/"; preg_match($pattem3,$str,$match3); if($match3){ $time=substr($match3[0],0,10); } $type=1; }else{ $str=implode($crr); if(strpos($str,'转账说明') || strpos($str,'转账时间') ||strpos($str,'转账单号')){ $pattem1="/[1-9]\d{30,32}/"; preg_match($pattem1,str_replace(" ","",$str),$match1); if($match1){ $order_no=$match1[0]; }else{ $pattem1="/(转账单号 1)\d{29,31}/"; preg_match($pattem1,$str,$match1); if($match1){ $order_no=mb_substr($match1[0],5); } } // $pattem2="/(\+)[1-9]\d*\.\d{2}/"; $pattem2="/(?1003];//不符合格式 } } if(empty($order_no)){ Log::error('1001'); // return [ // 'code'=>1001, // ]; } if(empty($time)){ Log::error('1002'); // return [ // 'code'=>1002, // ]; } if(empty($fee)){ $fpattem2="/(\-)[1-9]\d*\.\d{2}/"; preg_match($fpattem2,$str,$fmatch2); if($fmatch2){ $ffee=mb_substr($fmatch2[0],1); if($ffee){ // return ['code'=>1000]; Log::error('1000'); } } // return [ // 'code'=>1004, // 'data'=>[ // 'time'=>$time, // 'number'=>$order_no, // 'figure'=>$fee, // 'type'=>$type // ] // ];//未识别到金额 Log::error('1004'); } if($time && $order_no && $fee){ // return [ // 'code'=>200, // 'data'=>[ // 'time'=>$time, // 'number'=>$order_no, // 'figure'=>$fee, // 'type'=>$type // ] // ]; Log::error('200'); } } })->dailyAt('13:00'); $schedule->command('AutoCommand')->withoutOverlapping()->everyMinute(); $schedule->call(function (){ // // $orders = Ordertest::whereIn('pay_status', [0, 1])->where('is_deleted', 0)->get(); // // // // foreach ($orders as $key => $val) { // DB::beginTransaction(); // try { // if (!in_array($val->pay_status, ['0', '1']) || $val->is_deleted == '1') { // continue; //订单状态改变,不支付 // } // $user_id = $val->user_id; // $user = User::where('id', $user_id)->first(); // if ($user->money <= 0) { // $user->save(); // continue; //账户没钱,不支付 // } // if ($val->money - $val->pay_money == $val->no_pay_money) { // $no_pay_money = $val->no_pay_money; // } else { // $no_pay_money = $val->money - $val->pay_money; // } // if ($no_pay_money <= 0) { // continue; //没有未支付金额,不支付 // } // if ($user->money >= $no_pay_money) { // $user->money = $user->money - $no_pay_money; // $pay_money = $no_pay_money;//支付金额 // } else { // $pay_money = $user->money;//支付金额 // $user->money = 0; // } // if (!$user->save()) { // throw new \Exception('1'); // } // //支付日志 // $remark = '系统自动支付'; // $userpay = new Userpay(); // $userpay->user_id = $user_id; // $userpay->pay_money = $pay_money; // $userpay->op_name = '系统自动支付'; // $userpay->type = 1;//支付 // $userpay->remark = $remark . ',订单编号为' . $val->order_num; // $userpay->order_num = $val->order_num; // $userpay->pay_num = $this->pay_num($user_id); // $userpay->user_money = $user->money; // if (!$userpay->save()) { // throw new \Exception('2'); // } // //订单变更 // $order = Ordertest::where('id', $val->id)->sharedLock()->first(); // if ($order->pay_status == 2) { // Log::error('订单编号为:' . $order->order_num . '的订单已经支付'); // throw new \Exception('1'); // } // if ($order->pay_money != $val->pay_money) { // Log::error('订单编号为:' . $order->order_num . '的订单已经部分支付'); // throw new \Exception('1'); // } // $order->pay_money += $pay_money; // $order->no_pay_money = $order->money - $order->pay_money; // if ($order->pay_money == $order->money) { // $order->pay_status = '2';//全部支付 // } elseif ($order->pay_money > 0 && $order->pay_money < $order->money) { // $order->pay_status = '1';//部分支付 // } elseif ($order->pay_money == 0) { // $order->pay_status = '0';//未支付 // } elseif ($order->pay_money > $order->money) { // $order->pay_status = '3';//需部分退款 // $order->wait_back_money = $order->pay_money - $order->money; // } // if (!$order->save()) { // throw new \Exception('1'); // } // // DB::commit(); // Log::info('订单编号为' . $val->order_num . '已经自动支付已完成'); // } catch (\Exception $e) { // DB::rollBack(); // Log::info('自动支付失败' ); // } // } })->everyMinute(); } /** * Register the commands for the application. * * @return void */ //支付单号 public function pay_num($user_id) { $num = date('Ymd', time()) . '100000' . str_pad($user_id, 6, 0, STR_PAD_LEFT) . rand(11111, 99999); $count = UserPay::where('pay_num', $num)->count(); if ($count > 0) { $num = $this->pay_num($user_id); return $num; } return $num; } public function code($url,$k,$num,$level,$s=0,$file,$t=0){ $qrCode = new \Endroid\QrCode\QrCode($url); // 内容区域宽高,默认为300 $qrCode->setSize(200); // 外边距大小,默认为10 $qrCode->setMargin(10); // 设置编码 $qrCode->setEncoding('UTF-8'); // 设置容错等级 $qrCode->setErrorCorrectionLevel(ErrorCorrectionLevel::HIGH()); // 设置二维码颜色,默认为黑色 $qrCode->setForegroundColor(['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0]); // 设置二维码背景色,默认为白色 $qrCode->setBackgroundColor(['r' => 255, 'g' => 255, 'b' => 255, 'a' => 0]); // 设置二维码下方的文字 switch ($level){ case 1: $level_name='大码'; break; case 2: $level_name='中码'; break; case 3: $level_name='小码'; break; } if ($level!=1){ $level_name=$level_name.'-'.$s; } if ($level==3){ $level_name=$level_name.'-'.$t; } $qrCode->setLabel($level_name.'-'.$num, 15, null, LabelAlignment::CENTER()); ##### 二维码中的logo ##### // $qrCode->setLogoPath('logo.jpg'); // $qrCode->setLogoSize(100, 90); // $qrCode->setLogoWidth(100); // $qrCode->setLogoHeight(90); ##### 二维码中的logo / ##### // 启用内置的验证读取器(默认情况下禁用) // $qrCode->setValidateResult(false); ########## 二维码三种显示方式 ########## // 二维码输出在浏览器上 // header('Content-Type: ' . $qrCode->getContentType()); // echo $qrCode->writeString(); // 二维码存在本地 Log::error(1); $path='public/code/'.$file; $path = public_path().'/code/'.$file; File::makeDirectory($path,$mode = 0777,true,true); $qrCode->writeFile('public/code/'.$file.'/'.$level_name.'.png'); } public function codes($url,$k,$num,$level,$s=0,$file,$t=0){ $qrCode = new \Endroid\QrCode\QrCode($url); // 内容区域宽高,默认为300 $qrCode->setSize(200); // 外边距大小,默认为10 $qrCode->setMargin(10); // 设置编码 $qrCode->setEncoding('UTF-8'); // 设置容错等级 $qrCode->setErrorCorrectionLevel(ErrorCorrectionLevel::HIGH()); // 设置二维码颜色,默认为黑色 $qrCode->setForegroundColor(['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0]); // 设置二维码背景色,默认为白色 $qrCode->setBackgroundColor(['r' => 255, 'g' => 255, 'b' => 255, 'a' => 0]); // 设置二维码下方的文字 switch ($level){ case 1: $level_name='大码'; break; case 2: $level_name='小码'; break; case 3: $level_name='小码'; break; } if ($level==2){ $level_name=$level_name.'-'.$s; } $qrCode->setLabel($level_name.'-'.$num, 15, null, LabelAlignment::CENTER()); ##### 二维码中的logo ##### // $qrCode->setLogoPath('logo.jpg'); // $qrCode->setLogoSize(100, 90); // $qrCode->setLogoWidth(100); // $qrCode->setLogoHeight(90); ##### 二维码中的logo / ##### // 启用内置的验证读取器(默认情况下禁用) // $qrCode->setValidateResult(false); ########## 二维码三种显示方式 ########## // 二维码输出在浏览器上 // header('Content-Type: ' . $qrCode->getContentType()); // echo $qrCode->writeString(); // 二维码存在本地 Log::error(1); $path='public/code/'.$file; $path = public_path().'/code/'.$file; File::makeDirectory($path,$mode = 0777,true,true); $qrCode->writeFile('public/code/'.$file.'/'.$level_name.'.png'); } protected function commands() { $this->load(__DIR__.'/Commands'); require base_path('routes/console.php'); } }