Model_job_get3pewaybillid.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. foreach($list as $item){
  37. if(empty($item['waybillid'])){
  38. $this->do_final($item,"fullordertt");
  39. }else{
  40. continue;
  41. }
  42. }
  43. }
  44. private function do_amz($where,$fields){
  45. $list = $this->fullorderamz->find_all($where,$fields);
  46. foreach($list as $item){
  47. if(empty($item['waybillid'])){
  48. $this->do_final($item,"fullorderamz");
  49. }else{
  50. continue;
  51. }
  52. }
  53. }
  54. private function do_smt($where,$fields){
  55. $list = $this->fullordersmt->find_all($where,$fields);
  56. foreach($list as $item){
  57. if(empty($item['waybillid'])){
  58. $this->do_final($item,"fullordersmt");
  59. }else{
  60. continue;
  61. }
  62. }
  63. }
  64. private function do_final($info,$table_name){
  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. }
  74. }