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