RefillCallBack.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace refill\beixt;
  3. require_once(BASE_HELPER_PATH . '/refill/beixt/config.php');
  4. use refill;
  5. class RefillCallBack implements refill\IRefillCallBack
  6. {
  7. public function verify($params): bool
  8. {
  9. $sign = $this->sign($params);
  10. if ($params['sign'] == $sign) {
  11. return true;
  12. } else {
  13. return false;
  14. }
  15. }
  16. private function sign($params)
  17. {
  18. $body = $params['order_number'];
  19. $body .= $params['shipping_status'];
  20. $body .= $params['tradeNo'];
  21. $body .= config::API_CERT;
  22. return strtolower(md5($body));
  23. }
  24. public function notify($params)
  25. {
  26. $status = intval($params['shipping_status']);
  27. $order_sn = $params['tradeNo'];
  28. $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
  29. if (empty($order_info)) {
  30. return [false, false, false];
  31. }
  32. $order_id = $order_info['order_id'];
  33. if ($status === 1 || $status === 2) {
  34. return [$order_id, true, false];
  35. } elseif ($status == 0) {
  36. return [$order_id, false, true];
  37. } else {
  38. return [$order_id, false, false];
  39. }
  40. }
  41. }