dispatch_notify.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. require_once(BASE_ROOT_PATH . '/helper/account_helper.php');
  10. require_once(BASE_ROOT_PATH . '/helper/pay_helper.php');
  11. fcgi_header("Content-Type: text/plain; charset=UTF-8");
  12. try
  13. {
  14. //tid-订单号,status-1,consign_time-发货时间,logistics_no-快递流水,logistics_company-快递公司
  15. $order_sn = trim($_POST['tid']);
  16. $status = intval($_POST['status']);
  17. $consign_time = urldecode(trim($_POST['consign_time']));
  18. $ship_time = strtotime($consign_time);
  19. $logistics_no = trim($_POST['logistics_no']);
  20. $logistics_company = trim(urldecode($_POST['logistics_company']));
  21. 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);
  22. $express = Model('express')->field('id')->where(array('e_name' => $logistics_company))->select();
  23. if (empty($express) || count($express) == 0) {
  24. echo 'FAIL';
  25. return;
  26. }
  27. $express_id = $express[0]['id'];
  28. $remote_addr = $_SERVER['REMOTE_ADDR'];
  29. if (!empty($order_sn) && !empty($logistics_no))
  30. {
  31. if ($status == 1)
  32. {
  33. $helper = new pay_helper();
  34. $ret = $helper->OnOmsNotify($order_sn,$express_id,$logistics_no,$logistics_company);
  35. if ($ret) {
  36. QueueClient::push('subscribeKDN',['order_sn'=>$order_sn]);
  37. Log::record("push oms success",Log::DEBUG);
  38. echo 'SUCCESS';
  39. } else {
  40. Log::record("push oms error",Log::DEBUG);
  41. echo 'SUCCESS';
  42. }
  43. }
  44. else
  45. {
  46. QueueClient::push('subscribeKDN',['order_sn'=>$order_sn]);
  47. echo 'SUCCESS';
  48. }
  49. } else {
  50. echo 'FAIL';
  51. }
  52. }
  53. catch (Exception $e)
  54. {
  55. Log::record($e->getMessage(), Log::ERR);
  56. echo 'AGAIN';
  57. }