Model_job_get3pewaybillid.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. $fields = "id,number,waybill,waybillid,librarytime,express";
  17. $this->do_dlz($where,$fields);
  18. $this->do_tt($where,$fields);
  19. $this->do_amz($where,$fields);
  20. $this->do_smt($where,$fields);
  21. }
  22. //执行对立站的代码
  23. private function do_dlz($where,$fields){
  24. $list = $this->fullorder->find_all($where,$fields);
  25. foreach($list as $item){
  26. if(empty($item['waybillid'])){
  27. $this->do_final($item,"fullorder");
  28. }else{
  29. continue;
  30. }
  31. }
  32. }
  33. private function do_tt($where,$fields){
  34. $list = $this->fullordertt->find_all($where,$fields);
  35. foreach($list as $item){
  36. if(empty($item['waybillid'])){
  37. $this->do_final($item,"fullorder");
  38. }else{
  39. continue;
  40. }
  41. }
  42. }
  43. private function do_amz($where,$fields){
  44. $list = $this->fullorderamz->find_all($where,$fields);
  45. foreach($list as $item){
  46. if(empty($item['waybillid'])){
  47. $this->do_final($item,"fullorder");
  48. }else{
  49. continue;
  50. }
  51. }
  52. }
  53. private function do_smt($where,$fields){
  54. $list = $this->fullordersmt->find_all($where,$fields);
  55. foreach($list as $item){
  56. if(empty($item['waybillid'])){
  57. $this->do_final($item,"fullorder");
  58. }else{
  59. continue;
  60. }
  61. }
  62. }
  63. private function do_final($info,$table_name){
  64. print_r($info);
  65. sleep(1);
  66. $res = $this->itsxb->getDetail($info['number']);
  67. $res = json_decode($res,true);
  68. if(isset($res['code'])){
  69. if($info['waybill'] != $res['data']['deliveryNo']){
  70. $this->$table_name->save(['waybillid' => $res['data']['deliveryNo']],$info['id']);
  71. }
  72. }
  73. die;
  74. }
  75. }