Model_job_get3pewaybillid.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. foreach($list as $item){
  39. $this->fullordertt->save(['waybillid' => ''],$item['id']);
  40. }
  41. die;
  42. foreach($list as $item){
  43. if(empty($item['waybillid'])){
  44. $this->do_final($item,"fullordertt");
  45. }else{
  46. continue;
  47. }
  48. }
  49. }
  50. private function do_amz($where,$fields){
  51. $list = $this->fullorderamz->find_all($where,$fields);
  52. foreach($list as $item){
  53. if(empty($item['waybillid'])){
  54. $this->do_final($item,"fullorderamz");
  55. }else{
  56. continue;
  57. }
  58. }
  59. }
  60. private function do_smt($where,$fields){
  61. $list = $this->fullordersmt->find_all($where,$fields);
  62. foreach($list as $item){
  63. if(empty($item['waybillid'])){
  64. $this->do_final($item,"fullordersmt");
  65. }else{
  66. continue;
  67. }
  68. }
  69. }
  70. private function do_final($info,$table_name){
  71. sleep(1);
  72. $res = $this->itsxb->getDetail($info['number']);
  73. $res = json_decode($res,true);
  74. if(isset($res['code'])){
  75. if($info['waybill'] != $res['data']['deliveryNo']){
  76. $this->$table_name->save(['waybillid' => $res['data']['deliveryNo']],$info['id']);
  77. }
  78. }
  79. echo "<pre>";
  80. print_r($info);
  81. print_r($res);
  82. die;
  83. }
  84. }