| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- <?php defined('BASEPATH') OR exit('No direct script access allowed');
- /**
- * 此列一般在执行 24个小时中的一个 时候执行一次
- */
- class QueueCbt extends Start_Controller {
- public function __construct(){
- parent::__construct();
- $this->load->_model("Model_express_tt","express_tt");
- $this->load->_model("Model_shop","shop");
- $this->load->_model("Model_fullordertt","fullordertt");
- }
- private $ip = ['127.0.0.1','47.105.156.18'];
- //定义方法的调用规则 获取URI第二段值
- public function _remap($arg,$arg_array)
- {
- $ip = $_SERVER['REMOTE_ADDR'];
- if(!in_array($ip,$this->ip)){
- exit("No direct script access allowed");
- }
- if($arg == 'cbt_create_label')//添加
- {
- //创建快递面单
- $this->_cbtCreateLabel();
- }else if($arg == 'get_service'){
- //获取订单的服务信息
- $this->_getService();
- }
- else
- {
- exit('No direct script access allowed');
- }
-
-
- }
-
-
- //tiktok的cbt发货模式 按照定时任务先创建标签
- //订单状态要求 已审核 未打印 未出库 允许出库 允许打印 快递必须要是cbt
- // 当前店铺为tt-wk
- private function _cbtCreateLabel(){
- if(date("H") != 20){
- exit("当前不是20点执行".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['label_info'])){
- continue;
- }
- if(isset($shop_list[$info['shop']])){
- $r = $this->express_tt->doCreateCBTLabel($info,$shop_list[$info['shop']]);
- print_r($info['orderinfo']);
- print_r("|");
- 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);
- }
- if(date("H") == 20){
- exit("执行到20点了 不能在执行了");
- }
- }
- echo "<br/>";
- exit("执行完成");
-
-
- }
- }
|