RefillCallBack.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace refill\beixts;
  3. use refill;
  4. class RefillCallBack implements refill\IRefillCallBack
  5. {
  6. public function verify($params) : bool
  7. {
  8. $sign = $this->sign($params);
  9. if($params['sign'] == $sign) {
  10. return true;
  11. }
  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];
  31. }
  32. $order_id = $order_info['order_id'];
  33. if($status === 1 || $status === 2) {
  34. return [$order_id,true];
  35. } else {
  36. return [$order_id,false];
  37. }
  38. }
  39. }