| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 | 
							- <?php
 
- defined('BASEPATH') or exit('No direct script access allowed');
 
- /**
 
-  * 此类是为了解决erp没有队列的问题,为了解决这个问题,先写一下这个类,避免后期写那么多定时任务类   这里只能解决每间隔多少时间执行一会的
 
-  */
 
- class Zzjobs extends Start_Controller
 
- {
 
-     private $serect_str = "erpjob";
 
-     private $user_agent = 'Xcly251618/Job (Erp)';
 
-     private $api = "ly202508160727";
 
-     private $ip = ['127.0.0.1','47.105.156.18'];
 
-     public function __construct()
 
-     {
 
-         parent::__construct();
 
-         $this->load->_model("Model_zzjobs","zzjobs");
 
-         $this->load->_model("Model_logic_tools",'logic_tools');
 
-         $this->load->_model("Model_fullordererrors","fullordererrors");
 
-         $this->load->_model("Model_logic_order","logic_order");
 
-     }
 
-     public function _remap($arg, $arg_array)
 
-     {
 
-         $ip = $_SERVER['REMOTE_ADDR'];
 
-        
 
-         if(!in_array($ip,$this->ip)){
 
-             exit("Unauthorized access");
 
-         }
 
-         $user_agent = empty($_SERVER['HTTP_USER_AGENT'])?"":$_SERVER['HTTP_USER_AGENT'];
 
-         $token = empty($_SERVER['HTTP_X_AUTH_TOKEN'])?"":$_SERVER['HTTP_X_AUTH_TOKEN'];
 
-         $time =  $this->input->get('time',true);
 
-         $api = $this->input->get('api',true);
 
-         $this->checkAuth($user_agent,$token,$time,$api);
 
-         if ($arg == 'jobs') //调出单
 
-         {
 
-             $this->_jobs();
 
-         } else {
 
-             $this->_index();
 
-         }
 
-     }
 
-     /**
 
-      * 校验是否有权限可以执行
 
-      * $user_agent   自定义的请求客户端名称
 
-      * $token        自定义的清华客户端的token
 
-      * $time         请求的时间
 
-      * 
 
-      */
 
-     private function checkAuth($user_agent,$token,$time,$api){
 
-         if($api != $this->api){
 
-             exit("Access denied due to insufficient permissions");
 
-         }
 
-         $check_str = date("Ymd")."¥_".$this->serect_str."_¥".$time;
 
-         if(empty($user_agent)){
 
-             exit('No direct script access allowed');
 
-         }
 
-         if($user_agent != $this->user_agent){
 
-             exit('Illegal request');
 
-         }
 
-         if(empty($token)){
 
-             exit('No access permission');
 
-         }
 
-         
 
-         $sercet_str = md5($check_str);
 
-         
 
-         if($sercet_str != $token){
 
-             exit("Request permission is illegal");
 
-         }
 
-        
 
-         
 
-     }
 
-     private function _index() {}
 
-      //一般每一分钟都执行的 每分钟就执行10条   
 
-      //每五分钟 就执行100条
 
-      
 
-      //其他的就不限制了
 
-     private function _jobs() {
 
-         $this->db->query("DELETE from crowd_zzjobs where status = 30");
 
-         
 
-         $final_list = $this->zzjobs->find_all("status = 0","*",null,0,100);
 
-         if(empty($final_list)){
 
-             return ;
 
-         }
 
-         $do_list_ids = array_column($final_list,'id');
 
-         $this->db->query("update crowd_zzjobs set status = 10 where id  in (".implode(",",$do_list_ids).")");
 
-         foreach($final_list as $v){
 
-             $this->tasksAssign($v);
 
-         }
 
-         
 
-     }
 
-     private function tasksAssign($info){
 
-         switch($info['quque']){
 
-             case 'outtime_order':
 
-                 $params = json_decode($info['payload'],true); 
 
-                 $order_info = $this->logic_order->getInfo("number = '".$params['number']."'","*");
 
-                 if(!empty($order_info)){
 
-                     $this->fullordererrors->insert([
 
-                         'number'=>$order_info['number'],
 
-                         'shop'=>$order_info['shop'],
 
-                         'plat'=>$order_info['lv_platform'],
 
-                         'error_type'=>1,//订单超时15秒
 
-                         'error_msg'=>"订单打印超时,请核对订单是否核对",
 
-                         'error_time'=>$info['create_time'],
 
-                         'create_time'=>time()
 
-                     ]);
 
-                 }
 
-                 $this->zzjobs->save([
 
-                     'status'=>30,
 
-                     'result'=>$this->logic_tools->ret_json(1,"执行完毕"),
 
-                     'last_time'=>time()
 
-                 ],$info['id']);
 
-                 break;
 
-             default:
 
-                     $this->zzjobs->save([
 
-                         'status'=>20,
 
-                         'result'=>$this->logic_tools->ret_json(-1,"没有对应发方法执行任务"),
 
-                         'last_time'=>time()
 
-                     ],$info['id']);
 
-                 break;
 
-         }
 
-     } 
 
- }
 
 
  |