Model_job_get3pewaybillid.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. var_dump($item['number']);
  34. continue;
  35. }
  36. }
  37. }
  38. private function do_tt($where,$fields){
  39. $list = $this->fullordertt->find_all($where,$fields);
  40. foreach($list as $item){
  41. if(empty($item['waybillid'])){
  42. $this->do_final($item,"fullordertt");
  43. }else{
  44. var_dump($item['number']);
  45. continue;
  46. }
  47. }
  48. }
  49. private function do_amz($where,$fields){
  50. $list = $this->fullorderamz->find_all($where,$fields);
  51. foreach($list as $item){
  52. if(empty($item['waybillid'])){
  53. $this->do_final($item,"fullorderamz");
  54. }else{
  55. var_dump($item['number']);
  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. var_dump($item['number']);
  67. continue;
  68. }
  69. }
  70. }
  71. private function do_final($info,$table_name){
  72. sleep(1);
  73. $res = $this->itsxb->getDetail($info['number']);
  74. $res = json_decode($res,true);
  75. if(isset($res['code'])){
  76. if($info['waybill'] != $res['data']['deliveryNo']){
  77. $this->$table_name->save(['waybillid' => $res['data']['deliveryNo']],$info['id']);
  78. }
  79. }
  80. }
  81. }