kdniao_notify.php 1.5 KB

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