dispatch_notify.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. Log::record("push oms order_sn={$order_sn},express={$express_id},no={$logistics_no}",Log::DEBUG);
  34. account_helper::onOrderSend($order_sn,$logistics_company,$logistics_no);
  35. $helper = new pay_helper();
  36. $ret = $helper->OnOmsNotify($order_sn,$express_id,$logistics_no);
  37. if ($ret) {
  38. QueueClient::push('subscribeKDN',array('order_sn'=>$order_sn));
  39. Log::record("push oms success",Log::DEBUG);
  40. echo 'SUCCESS';
  41. } else {
  42. Log::record("push oms error",Log::DEBUG);
  43. echo 'SUCCESS';
  44. }
  45. }
  46. else
  47. {
  48. QueueClient::push('subscribeKDN',array('order_sn'=>$order_sn));
  49. echo 'SUCCESS';
  50. }
  51. } else {
  52. echo 'FAIL';
  53. }
  54. }
  55. catch (Exception $e)
  56. {
  57. Log::record($e->getMessage(), Log::ERR);
  58. echo 'AGAIN';
  59. }