| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 | <?phpclass Model_job_get3pewaybillid extends Lin_Model {    function __construct(){            parent::__construct();            $this->load->_model("Model_itsxb","itsxb");            $this->load->_model("Model_fullorder","fullorder");            $this->load->_model("Model_fullordersmt","fullordersmt");            $this->load->_model("Model_fullordertt","fullordertt");            $this->load->_model("Model_fullorderamz","fullorderamz");            $this->load->_model("Model_logic_ding","logic_ding");    }    public function do_job(){        $end_time = time() - 10 * 3600 * 24;        $start_time = time() - 2 * 3600 * 24;        //快递为3pe  76  出库时间十天前   waybillid 不能为空        $where = "(express = 76  or express =  77  )and librarytime >= ".$end_time ." and librarytime <= ".$start_time."  ";        //$where = "express = 76  and librarytime <= ".$start_time." ";        $fields = "id,number,waybill,waybillid,librarytime,express,printnumber";        echo "<pre>";        var_dump(date("Y-m-d H:i:s",time()));        $this->do_dlz($where,$fields);        $this->do_tt($where,$fields);        $this->do_amz($where,$fields);        $this->do_smt($where,$fields);        var_dump(date("Y-m-d H:i:s",time()));    }    //执行对立站的代码    private function do_dlz($where,$fields){        $list = $this->fullorder->find_all($where,$fields);               foreach($list as $item){            if(empty($item['waybillid'])){                $this->do_final($item,"fullorder");            }else{                continue;            }        }    }    private  function do_tt($where,$fields){        $list = $this->fullordertt->find_all($where,$fields);        foreach($list as $item){            if(empty($item['waybillid'])){                $this->do_final($item,"fullordertt");            }else{                continue;            }        }    }    private function do_amz($where,$fields){        $list = $this->fullorderamz->find_all($where,$fields);               foreach($list as $item){            if(empty($item['waybillid'])){                $this->do_final($item,"fullorderamz");            }else{                continue;            }        }    }    private function do_smt($where,$fields){        $list = $this->fullordersmt->find_all($where,$fields);               foreach($list as $item){            if(empty($item['waybillid'])){                $this->do_final($item,"fullordersmt");            }else{                continue;            }        }    }    private function do_final($info,$table_name){        sleep(1);        $number = $info['number'];        $tmp_printnumber = $info['printnumber'] - 1;        if($tmp_printnumber > 0){            $number = $info['number']."_".$tmp_printnumber;        }        $res = $this->itsxb->getDetail($number);        // var_dump($table_name);        // var_dump($res);        $res = json_decode($res,true);                if(isset($res['code'])){            if(($info['waybill'] != $res['data']['deliveryNo']) && (!empty($res['data']['deliveryNo']))){                    $this->$table_name->save(['waybillid' => $res['data']['deliveryNo']],$info['id']);                    $this->logic_ding->sendToDing("3PE转单号更新信息【".$info['waybill']."】"."转单号:".$res['data']['deliveryNo']." 平台:".$table_name."订单详细信息:{".json_encode($info)."}");            }else{                //$this->logic_ding->sendToDing("3PE转单号不满足条件【".$info['waybill']."】"."转单号:".$res['data']['deliveryNo']." 平台:".$table_name."订单详细信息:{".json_encode($info)."}");            }        }    }}
 |