RefillCallBack.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace refill\douxun;
  3. require_once(BASE_HELPER_RAPI_PATH . '/douxun/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['head']['chargeSign'] == $sign) {
  11. return true;
  12. } else {
  13. return false;
  14. }
  15. }
  16. private function sign($params)
  17. {
  18. $content = config::custInteId . $params['echo'] . config::KEY . $params['timestamp'];
  19. return base64_encode(md5($content, true));
  20. }
  21. public function notify($params)
  22. {
  23. $item = $params['body']['item'];
  24. $status = $item['result'];
  25. $order_sn = $params['id'];
  26. $order_info = Model('vr_order')->getOrderInfoForNotify(['order_sn' => $order_sn]);
  27. if (empty($order_info)) {
  28. return [false, false, false,false];
  29. }
  30. $order_id = $order_info['order_id'];
  31. if ($status === '0000') {
  32. $data['official_sn'] = strtolower($item['operatorNo']) == 'null' ? '' : $item['operatorNo'];
  33. Model('refill_order')->edit($order_id, $data);
  34. return [$order_id, true, false,true];
  35. }
  36. else {
  37. return [$order_id, false, true,true];
  38. }
  39. }
  40. }