Просмотр исходного кода

修改cbt打单的流程 将获取订单的服务商信息 7点开始 然后8点13开始 开始创建面单

lvhao 5 дней назад
Родитель
Сommit
a2df1273b3
2 измененных файлов с 67 добавлено и 3 удалено
  1. 64 2
      core/CoreApp/controllers/QueueCbt.php
  2. 3 1
      core/CoreApp/models/Model_express_tt.php

+ 64 - 2
core/CoreApp/controllers/QueueCbt.php

@@ -17,7 +17,20 @@ class QueueCbt extends Start_Controller {
         if(!in_array($ip,$this->ip)){
             exit("No direct script access allowed");
         }
-        $this->_cbtCreateLabel();
+        if($arg == 'cbt_create_label')//添加
+        {
+            //创建快递面单
+            $this->_cbtCreateLabel();
+        }else if($arg == 'get_service'){
+            //获取订单的服务信息
+            $this->_getService();
+        }
+        else
+        {
+            exit('No direct script access allowed');
+        }
+        
+        
     }
    
   
@@ -65,11 +78,60 @@ class QueueCbt extends Start_Controller {
                   $r = $this->express_tt->doCreateCBTLabel($info,$shop_list[$info['shop']]);
                   print_r($info['orderinfo']);
                   print_r("|");
-                  usleep(100);
+                  usleep(10);
+            }
+        }
+        echo "<br/>";
+        exit("执行完成");
+        
+    }
+
+    public function _getService(){
+        if(date("H") != 19){
+            exit("当前不是19点执行".date("H"));
+        }
+
+        //允许长时间运行
+        set_time_limit(0);
+        $where_arr = [
+             //"shop"=>35,//当前店铺为tt-wk
+             "express"=>83,//快递为tt-cbt
+             "print"=>2,//未打印
+             "printnumber"=>0,//打印次数
+             'library'=>1,//未出库
+             //'libraryconfirm'=>2,//允许出库
+             "review >"=>4,//审核通过或自动审核
+        ];
+        //$shop_info = $this->shop->read(35);
+        $shop_list = $this->shop->find_all('1 = 1');
+        $shop_list = array_column($shop_list,null,'id');
+        // if(empty($shop_info)){
+        //     exit("当前店铺不存在");
+        // }
+        $list = $this->db->from("fullordertt")
+            ->select("id,orderinfo,shop,express,print,printnumber,library,review,state")
+            ->where($where_arr)
+            ->where_not_in('state',[214,217])
+            ->get()->result_array();
+        if(empty($list)){
+            exit("没有符合条件的订单");
+        }
+        foreach($list as $k=>$v){
+            $info = $this->fullordertt->read($v['id']);
+            $extra_text = json_encode($info['extra_text'],true);
+            if(isset($extra_text['server_info'])){
+                continue;
+            }
+            if(isset($shop_list[$info['shop']])){
+                  $r = $this->express_tt->getExpressInfo($info,$shop_list[$info['shop']]);
+                  print_r($info['orderinfo']);
+                  print_r("|");
+                  usleep(10);
             }
         }
         echo "<br/>";
         exit("执行完成");
         
+         
     }
 }

+ 3 - 1
core/CoreApp/models/Model_express_tt.php

@@ -321,7 +321,9 @@ class Model_express_tt extends Lin_Model {
         
     }
 
-
+    /**
+     * 创建CBT发货单和运单标签
+     */
     public function doCreateCBTLabel($info,$shop_info){
          //获取快递服务信息
          $res = $this->getExpressCompany($info,$shop_info);