dispatch_notify.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. QueueClient::push('subscribeKDN',array('order_sn'=>$order_sn));
  35. echo 'SUCCESS';
  36. } else {
  37. echo 'SUCCESS';
  38. }
  39. } else {
  40. QueueClient::push('subscribeKDN',array('order_sn'=>$order_sn));
  41. echo 'SUCCESS';
  42. }
  43. } else {
  44. echo 'FAIL';
  45. }
  46. }
  47. catch (Exception $e)
  48. {
  49. Log::record($e->getMessage(), Log::ERR);
  50. echo 'AGAIN';
  51. }