Model_job_get3pewaybillid.php 3.8 KB

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