Model_job_get3pewaybillid.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. echo "<pre>";
  19. var_dump(date("Y-m-d H:i:s",time()));
  20. $this->do_dlz($where,$fields);
  21. $this->do_tt($where,$fields);
  22. $this->do_amz($where,$fields);
  23. $this->do_smt($where,$fields);
  24. var_dump(date("Y-m-d H:i:s",time()));
  25. }
  26. //执行对立站的代码
  27. private function do_dlz($where,$fields){
  28. $list = $this->fullorder->find_all($where,$fields);
  29. foreach($list as $item){
  30. if(empty($item['waybillid'])){
  31. $this->do_final($item,"fullorder");
  32. }else{
  33. continue;
  34. }
  35. }
  36. }
  37. private function do_tt($where,$fields){
  38. $list = $this->fullordertt->find_all($where,$fields);
  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. var_dump($table_name);
  71. var_dump($res);
  72. $res = json_decode($res,true);
  73. if(isset($res['code'])){
  74. if($info['waybill'] != $res['data']['deliveryNo']){
  75. $this->$table_name->save(['waybillid' => $res['data']['deliveryNo']],$info['id']);
  76. }
  77. }
  78. }
  79. }