Model_job_get3pewaybillid.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. $this->load->_model("Model_logic_ding","logic_ding");
  11. }
  12. public function do_job(){
  13. $end_time = time() - 10 * 3600 * 24;
  14. $start_time = time() - 2 * 3600 * 24;
  15. //快递为3pe 76 出库时间十天前 waybillid 不能为空
  16. $where = "express = 76 and librarytime >= ".$end_time ." and librarytime <= ".$start_time." ";
  17. //$where = "express = 76 and librarytime <= ".$start_time." ";
  18. $fields = "id,number,waybill,waybillid,librarytime,express";
  19. echo "<pre>";
  20. var_dump(date("Y-m-d H:i:s",time()));
  21. $this->do_dlz($where,$fields);
  22. $this->do_tt($where,$fields);
  23. $this->do_amz($where,$fields);
  24. $this->do_smt($where,$fields);
  25. var_dump(date("Y-m-d H:i:s",time()));
  26. }
  27. //执行对立站的代码
  28. private function do_dlz($where,$fields){
  29. $list = $this->fullorder->find_all($where,$fields);
  30. foreach($list as $item){
  31. if(empty($item['waybillid'])){
  32. $this->do_final($item,"fullorder");
  33. }else{
  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. continue;
  45. }
  46. }
  47. }
  48. private function do_amz($where,$fields){
  49. $list = $this->fullorderamz->find_all($where,$fields);
  50. foreach($list as $item){
  51. if(empty($item['waybillid'])){
  52. $this->do_final($item,"fullorderamz");
  53. }else{
  54. continue;
  55. }
  56. }
  57. }
  58. private function do_smt($where,$fields){
  59. $list = $this->fullordersmt->find_all($where,$fields);
  60. foreach($list as $item){
  61. if(empty($item['waybillid'])){
  62. $this->do_final($item,"fullordersmt");
  63. }else{
  64. continue;
  65. }
  66. }
  67. }
  68. private function do_final($info,$table_name){
  69. sleep(1);
  70. $number = $info['number'];
  71. $tmp_printnumber = $info['printnumber'] - 1;
  72. if($tmp_printnumber > 0){
  73. $number = $info['number']."_".$tmp_printnumber;
  74. }
  75. $res = $this->itsxb->getDetail($number);
  76. // var_dump($table_name);
  77. // var_dump($res);
  78. $res = json_decode($res,true);
  79. if(isset($res['code'])){
  80. if($info['waybill'] != $res['data']['deliveryNo']){
  81. $this->$table_name->save(['waybillid' => $res['data']['deliveryNo']],$info['id']);
  82. $this->logic_ding->sendToDing("3PE转单号更新信息【".$info['waybill']."】"."转单号:".$res['data']['deliveryNo']." 平台:".$table_name."订单详细信息:{".json_encode($info)."}");
  83. }else{
  84. //$this->logic_ding->sendToDing("3PE不满足条件转单号更新信息【".$info['waybill']."】"."转单号:".$res['data']['deliveryNo']." 平台:".$table_name."订单详细信息:{".json_encode($info)."}");
  85. }
  86. }
  87. }
  88. }