Model_usps_status.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <?php
  2. class Model_Usps_status extends Lin_Model {
  3. function __construct(){
  4. parent::__construct();
  5. }
  6. //获取快递状态
  7. public function getState($str,$zt,$dataprovince){
  8. $exstate = 0 ;
  9. if(
  10. (stripos($str,'delivered') !== false && stripos($str,'delivered by the expected delivery date') === false && stripos($str,'to be delivered') === false)
  11. ||
  12. stripos($str,'Your item was picked up at the post office') !== false
  13. || stripos($str,'Your item was picked up at') !== false
  14. )
  15. {
  16. $exstate = 6;
  17. $zx = 1;
  18. }
  19. else if(
  20. stripos($str,'out for delivery') !== false
  21. ||
  22. stripos($str,'Processing Exception')
  23. ||
  24. stripos($str,'was returned')
  25. ||
  26. stripos($str,'Delivery exception') !== false
  27. ||
  28. stripos($str,'Addressee Unknown') !== false
  29. ||
  30. stripos($str,'Delivered to Agent for Final Delivery') !== false
  31. ||
  32. stripos($str,'Reminder to pick up your item') !== false
  33. ||
  34. stripos($str,'Available for Pickup') !== false
  35. ||
  36. stripos($str,'Processing Exception') !== false
  37. ||
  38. stripos($str,'Return to Sender Processed') !== false
  39. ||
  40. stripos($str,'Redelivery Scheduled') !== false
  41. ||
  42. stripos($str,'Notice Left') !== false
  43. ||
  44. stripos($str,'Delivery attempted but no response at Consignee address') !== false
  45. ||
  46. stripos($str,'Delivery attempt could not be completed') !== false
  47. ||
  48. stripos($str,'Forwarded to a third party agent') !== false
  49. ||
  50. stripos($str,'Awaiting collection by the consignee') !== false
  51. ||
  52. stripos($str,'Consignee has moved from the address provided') !== false
  53. ||
  54. stripos($str,'awaiting customer pickup') !== false)
  55. {
  56. $exstate = 1;
  57. $zx = 1;
  58. }
  59. else if(
  60. stripos(strtolower($str),strtolower('Arrived at USPS Destination Facility')) !== false && stripos(strtolower($str),strtolower($dataprovince.' DISTRIBUTION CENTER')) !== false
  61. )
  62. {
  63. $exstate = 4;
  64. $zx = 1;
  65. }
  66. else if(stripos(strtolower($str),'In transit') !== false || stripos(strtolower($str),'picked up item') !== false)
  67. {
  68. $exstate = 3;
  69. $zx = 1;
  70. }
  71. else if(stripos(strtolower($str),'accepted at usps origin facility') !== false)
  72. {
  73. $exstate = 2;
  74. $zx = 1;
  75. }
  76. else
  77. {
  78. if(is_array($zt))
  79. {
  80. foreach($zt as $item)
  81. {
  82. $v =isset($item['eventType'])?$item['eventType']:"";
  83. if(
  84. stripos(strtolower($v),'out for delivery') !== false
  85. ||
  86. stripos(strtolower($v),'processing exception') !== false
  87. ||
  88. stripos($v,'Delivery exception') !== false
  89. ||
  90. stripos($v,'Addressee Unknown') !== false
  91. ||
  92. stripos($v,'Delivered to Agent for Final Delivery') !== false
  93. ||
  94. stripos($v,'Reminder to pick up your item') !== false
  95. ||
  96. stripos($v,'Available for Pickup') !== false
  97. ||
  98. stripos($v,'Processing Exception') !== false
  99. ||
  100. stripos($v,'Return to Sender Processed') !== false
  101. ||
  102. stripos($v,'Redelivery Scheduled') !== false
  103. ||
  104. stripos($v,'Notice Left') !== false
  105. ||
  106. stripos($v,'Delivery attempted but no response at Consignee address') !== false
  107. ||
  108. stripos($v,'Delivery attempt could not be completed') !== false
  109. ||
  110. stripos($v,'Forwarded to a third party agent') !== false
  111. ||
  112. stripos($v,'Awaiting collection by the consignee') !== false
  113. ||
  114. stripos($v,'Consignee has moved from the address provided') !== false
  115. ||
  116. stripos($v,'awaiting customer pickup') !== false
  117. )
  118. {
  119. $exstate = 1;
  120. break;
  121. }
  122. /**
  123. if(stripos(strtolower($v),strtolower($number['city'])) !== false && stripos(strtolower($v),'arrived at post office') !== false)
  124. {
  125. $exstate = 5;
  126. break;
  127. }
  128. **/
  129. else if(
  130. stripos(strtolower($v),strtolower('Arrived at USPS Destination Facility')) !== false
  131. &&
  132. stripos(strtolower($v),strtolower($dataprovince.' DISTRIBUTION CENTER')) !== false
  133. )
  134. {
  135. $exstate = 4;
  136. break;
  137. }
  138. if(
  139. stripos(strtolower($v),'In transit') !== false
  140. ||
  141. stripos(strtolower($v),'picked up item') !== false
  142. )
  143. {
  144. $exstate = 3;
  145. break;
  146. }
  147. if(stripos(strtolower($v),'accepted at usps origin facility') !== false)
  148. {
  149. $exstate = 2;
  150. break;
  151. }
  152. }
  153. }
  154. else
  155. {
  156. //这种情况基本没有 因为文档上返回的参数必须是数组,哪怕就一个状态也是数组
  157. $exstate = 1;
  158. }
  159. }
  160. return $exstate;
  161. }
  162. } //end class