Model_job_get3pewaybillid.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. class Model_job_get3pewaybillid extends Lin_Model {
  3. function __construct(){
  4. parent::__construct();
  5. $this->load->_model("Model_itsxb","itsxb");
  6. $this->load->_model("Model_fullorder","fullorder");
  7. $this->load->_model("Model_fullordersmt","fullordersmt");
  8. $this->load->_model("Model_fullordertt","fullordertt");
  9. $this->load->_model("Model_fullorderamz","fullorderamz");
  10. }
  11. public function do_job(){
  12. $end_time = time() - 10 * 3600 * 24;
  13. $start_time = time() - 2 * 3600 * 24;
  14. //快递为3pe 76 出库时间十天前 waybillid 不能为空
  15. // $where = "express = 76 and librarytime >= ".$end_time ." and librarytime <= ".$start_time." ";
  16. $where = "express = 76 and librarytime <= ".$start_time." ";
  17. $fields = "id,number,waybill,waybillid,librarytime,express";
  18. // $this->do_dlz($where,$fields);
  19. $this->do_tt($where,$fields);
  20. $this->do_amz($where,$fields);
  21. $this->do_smt($where,$fields);
  22. }
  23. //执行对立站的代码
  24. private function do_dlz($where,$fields){
  25. $list = $this->fullorder->find_all($where,$fields);
  26. foreach($list as $item){
  27. if(empty($item['waybillid'])){
  28. $this->do_final($item,"fullorder");
  29. }else{
  30. continue;
  31. }
  32. }
  33. }
  34. private function do_tt($where,$fields){
  35. $list = $this->fullordertt->find_all($where,$fields);
  36. echo "<pre>";
  37. print_r(array_column($list,'id'));
  38. die;
  39. foreach($list as $item){
  40. if(empty($item['waybillid'])){
  41. $this->do_final($item,"fullordertt");
  42. }else{
  43. continue;
  44. }
  45. }
  46. }
  47. private function do_amz($where,$fields){
  48. $list = $this->fullorderamz->find_all($where,$fields);
  49. foreach($list as $item){
  50. if(empty($item['waybillid'])){
  51. $this->do_final($item,"fullorderamz");
  52. }else{
  53. continue;
  54. }
  55. }
  56. }
  57. private function do_smt($where,$fields){
  58. $list = $this->fullordersmt->find_all($where,$fields);
  59. foreach($list as $item){
  60. if(empty($item['waybillid'])){
  61. $this->do_final($item,"fullordersmt");
  62. }else{
  63. continue;
  64. }
  65. }
  66. }
  67. private function do_final($info,$table_name){
  68. sleep(1);
  69. $res = $this->itsxb->getDetail($info['number']);
  70. $res = json_decode($res,true);
  71. if(isset($res['code'])){
  72. if($info['waybill'] != $res['data']['deliveryNo']){
  73. $this->$table_name->save(['waybillid' => $res['data']['deliveryNo']],$info['id']);
  74. }
  75. }
  76. echo "<pre>";
  77. print_r($info);
  78. print_r($res);
  79. die;
  80. }
  81. }