123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- <?php
- class Model_job_getyuntuwaybillid extends Lin_Model {
- function __construct(){
- parent::__construct();
- $this->load->_model("Model_yuntu","yuntu");
- $this->load->_model("Model_fullorder","fullorder");
- $this->load->_model("Model_fullordersmt","fullordersmt");
- $this->load->_model("Model_fullordertt","fullordertt");
- $this->load->_model("Model_fullorderamz","fullorderamz");
- }
- public function do_job(){
- $end_time = time() - 5 * 3600 * 24;
- $start_time = time() - 1 * 3600 * 24;
- //快递为3pe 76 出库时间十天前 waybillid 不能为空
- $where = "express in (66,67) and librarytime >= ".$end_time ." and librarytime <= ".$start_time." ";
- // $where = "express in (66,67) ";
- $fields = "id,number,waybill,waybillid,librarytime,express";
- 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,'id asc',0,300);
- $final_list = [];
-
- foreach($list as $item){
- if(empty($item['waybillid'])&&(!empty($item['waybill']))){
- $final_list[] = $item['waybill'];
- }else{
- continue;
- }
- }
- if(empty($final_list)){
- return;
- }
-
- $this->do_final($final_list,"fullorder");
- }
- private function do_tt($where,$fields){
- $list = $this->fullordertt->find_all($where,$fields,'id asc',0,300);
- $final_list = [];
- foreach($list as $item){
- if(empty($item['waybillid'])&&(!empty($item['waybill']))){
- $final_list[] = $item['waybill'];
- }else{
- continue;
- }
- }
- if(empty($final_list)){
- return;
- }
- $this->do_final($final_list,"fullordertt");
- }
- private function do_amz($where,$fields){
- $list = $this->fullorderamz->find_all($where,$fields,'id asc',0,300);
- $final_list = [];
- foreach($list as $item){
- if(empty($item['waybillid'])&&(!empty($item['waybill']))){
- $final_list[] = $item['waybill'];
- }else{
- continue;
- }
- }
- if(empty($final_list)){
- return;
- }
- $this->do_final($final_list,"fullorderamz");
- }
- private function do_smt($where,$fields){
- $list = $this->fullordersmt->find_all($where,$fields,'id asc',0,300);
- $final_list = [];
- foreach($list as $item){
- if(empty($item['waybillid'])&&(!empty($item['waybill']))){
- $final_list[] = $item['waybill'];
- }else{
- continue;
- }
- }
- if(empty($final_list)){
- return;
- }
- $this->do_final($final_list,"fullordersmt");
- }
- private function do_final($final_list,$table_name){
-
- $arr = array_chunk($final_list,15);
-
-
- foreach($arr as $item){
- sleep(1);
- $res = $this->yuntu->getTransferNumber($item);
- if(isset($res['result'])){
- if(isset($res['result']['carriers'])){
- foreach($res['result']['carriers'] as $value){
- $list = $this->$table_name->find_all("waybill = '". $value['waybill_number']."'",'id,number,waybill,waybillid,librarytime,express');
- if(!empty($list)){
- foreach($list as $item_info){
- $this->$table_name->save(['waybillid'=>$value['tracking_number']],$item_info['id']);
- //$this->logic_ding->sendToDing("云途转单号更新信息【".$item_info['waybill']."】"."转单号:".$value['tracking_number']." 平台:".$table_name."订单详细信息:{".json_encode($item_info)."}");
- }
- }
- }
- }
- }
- }
-
-
- }
- }
|