QueueCbt.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. /**
  3. * 此列一般在执行 24个小时中的一个 时候执行一次
  4. */
  5. class QueueCbt extends Start_Controller {
  6. public function __construct(){
  7. parent::__construct();
  8. $this->load->_model("Model_express_tt","express_tt");
  9. $this->load->_model("Model_shop","shop");
  10. }
  11. private $ip = ['127.0.0.1','47.105.156.18'];
  12. //定义方法的调用规则 获取URI第二段值
  13. public function _remap($arg,$arg_array)
  14. {
  15. $ip = $_SERVER['REMOTE_ADDR'];
  16. if(!in_array($ip,$this->ip)){
  17. exit("No direct script access allowed");
  18. }
  19. $this->_cbtCreateLabel();
  20. }
  21. //tiktok的cbt发货模式 按照定时任务先创建标签
  22. //订单状态要求 已审核 未打印 未出库 允许出库 允许打印 快递必须要是cbt
  23. // 当前店铺为tt-wk
  24. private function _cbtCreateLabel(){
  25. if(date("H") != 20){
  26. exit("当前不是20点执行".date("H"));
  27. }
  28. $where_arr = [
  29. "shop"=>35,//当前店铺为tt-wk
  30. "express"=>83,//快递为tt-cbt
  31. "print"=>2,//未打印
  32. "printnumber"=>0,//打印次数
  33. 'library'=>1,//未出库
  34. //'libraryconfirm'=>2,//允许出库
  35. "review >"=>4,//审核通过或自动审核
  36. ];
  37. $shop_info = $this->shop->read(35);
  38. if(empty($shop_info)){
  39. exit("当前店铺不存在");
  40. }
  41. $list = $this->db->from("fullordertt")
  42. ->where($where_arr)
  43. ->where_not_in('state',[214,217])
  44. ->get()->result_array();
  45. if(empty($list)){
  46. exit("没有符合条件的订单");
  47. }
  48. echo "<pre>";
  49. foreach($list as $k=>$v){
  50. $extra_text = json_encode($v['extra_text'],true);
  51. if(isset($extra_text['label_info'])){
  52. continue;
  53. }
  54. $r = $this->express_tt->doCreateCBTLabel($v,$shop_info);
  55. print_r($v['orderinfo']);
  56. usleep(100);
  57. }
  58. exit("执行完成");
  59. }
  60. }