Model_job_get3pewaybillid.php 2.8 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. //$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. $res = json_decode($res,true);
  71. if(isset($res['code'])){
  72. if($info['waybill'] != $res['data']['deliveryNo']){
  73. $this->$table_name->save(['waybillid' => $res['data']['deliveryNo']],$info['id']);
  74. }
  75. }
  76. }
  77. }