kdniao_notify.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. //ini_set("display_errors",1);
  3. // member_info(E_ALL);
  4. defined('BASE_ROOT_PATH') or define('BASE_ROOT_PATH',str_replace('/mobile','',dirname(__FILE__)));
  5. require_once(BASE_DATA_PATH . '/logic/delivery.logic.php');
  6. require_once(BASE_ROOT_PATH . '/helper/kdn_helper.php');
  7. Log::record("快递鸟回调:", Log::DEBUG);
  8. $requestData = isset($_POST['RequestData']) ? $_POST['RequestData'] : null; // 快递鸟数据
  9. if (!empty($requestData))
  10. {
  11. $deliver_info = json_decode(urldecode($requestData),true);
  12. $success = true;
  13. $reson = '';
  14. //数据不正确, 记录并退出
  15. if ($deliver_info === false || empty($deliver_info))
  16. {
  17. $success = false;
  18. $reson = 'data is empty.';
  19. Log::record("kdniao_notify:cannot query delivery info from kuaidn.",Log::ERR);
  20. }
  21. else
  22. {
  23. Log::record("start handle....",Log::DEBUG);
  24. $count = intval($deliver_info['Count']);
  25. if($count <= 0 || $deliver_info['EBusinessID'] != kdn_helper::cur_businessid()) {
  26. $success = false;
  27. $reson = "count={$count} or EBusinessID = {$deliver_info['EBusinessID']} != " . kdn_helper::cur_businessid();
  28. }
  29. else
  30. {
  31. foreach($deliver_info['Data'] as $item) {
  32. kdn_helper::onCallback($item);
  33. }
  34. }
  35. }
  36. echo (json_encode(['EBusinessID' => kdn_helper::cur_businessid(),
  37. 'UpdateTime' => strftime("%Y-%m-%d %H:%M:%S",time()),
  38. 'Success' => $success,
  39. 'Reason' => $reson]));
  40. }