dispatch_notify.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: stanley-king
  5. * Date: 16/1/22
  6. * Time: 上午10:22
  7. */
  8. require_once(BASE_ROOT_PATH . '/helper/kdn_helper.php');
  9. fcgi_header("Content-Type: text/plain; charset=UTF-8");
  10. try
  11. {
  12. //tid-订单号,status-1,consign_time-发货时间,logistics_no-快递流水,logistics_company-快递公司
  13. $order_sn = trim($_POST['tid']);
  14. $status = intval($_POST['status']);
  15. $consign_time = urldecode(trim($_POST['consign_time']));
  16. $ship_time = strtotime($consign_time);
  17. $logistics_no = trim($_POST['logistics_no']);
  18. $logistics_company = trim(urldecode($_POST['logistics_company']));
  19. Log::record("dispatch notify value: order_sn = {$order_sn},status={$status},consign_time = {$consign_time} logistics_no = {$logistics_no} logistics_company = {$logistics_company}.",Log::DEBUG);
  20. $express = Model('express')->field('id')->where(array('e_name' => $logistics_company))->select();
  21. if(empty($express) || count($express) == 0) {
  22. echo 'FAIL';
  23. return;
  24. }
  25. $shipping_express_id = $express[0]['id'];
  26. $remote_addr = $_SERVER['REMOTE_ADDR'];
  27. if(!empty($order_sn) && !empty($logistics_no))
  28. {
  29. if($status == 1)
  30. {
  31. $order = Model('order');
  32. $ret = $order->setOrderDelivery($order_sn,$shipping_express_id,$logistics_no,$ship_time);
  33. if($ret) {
  34. kdn_helper::subscribe($order_sn);
  35. echo 'SUCCESS';
  36. } else {
  37. echo 'AGAIN';
  38. }
  39. }
  40. else{
  41. kdn_helper::subscribe($order_sn);
  42. echo 'SUCCESS';
  43. }
  44. }
  45. else
  46. {
  47. echo 'FAIL';
  48. }
  49. }
  50. catch (Exception $e)
  51. {
  52. Log::record($e->errorMessage(),Log::ERR);
  53. echo 'AGAIN';
  54. }