dispatch_notify.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: stanley-king
  5. * Date: 16/1/22
  6. * Time: 上午10:22
  7. */
  8. echo("Content-Type: text/plain; charset=UTF-8\r\n\r\n");
  9. try
  10. {
  11. //tid-订单号,status-1,consign_time-发货时间,logistics_no-快递流水,logistics_company-快递公司
  12. $order_sn = trim($_POST['tid']);
  13. $status = intval($_POST['status']);
  14. //$consign_time = $_POST['consign_time'];
  15. $logistics_no = trim($_POST['logistics_no']);
  16. $logistics_company = $_POST['logistics_company'];
  17. $express = Model('express')->field('id')->where(array('e_code' => $logistics_company))->select();
  18. if(empty($express) || count($express) == 0) {
  19. echo 'FAIL';
  20. return;
  21. }
  22. $shipping_express_id = $express[0]['id'];
  23. 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);
  24. $remote_addr = $_SERVER['REMOTE_ADDR'];
  25. if(!empty($order_sn) && !empty($logistics_no))
  26. {
  27. if($status == 1)
  28. {
  29. //,'shipping_time' => )
  30. Model()->table('order_common')->where(array('order_sn' => $order_sn))->update(array('shipping_express_id' => $shipping_express_id));
  31. $ret = Model()->table('order')->where(array('order_sn' => $order_sn))->update(array('order_state' => ORDER_STATE_SEND,'shipping_code' => $logistics_no));
  32. if($ret) {
  33. echo 'SUCCESS';
  34. } else {
  35. echo 'AGAIN';
  36. }
  37. }
  38. else{
  39. echo 'SUCCESS';
  40. }
  41. }
  42. else
  43. {
  44. echo 'FAIL';
  45. }
  46. } catch (WxPayException $e){
  47. Log::record($e->errorMessage(),Log::ERR);
  48. echo 'AGAIN';
  49. }