RefillCallBack.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace refill\afandnew;
  3. <<<<<<< HEAD:helper/refill/api/xyz/tianx/RefillCallBack.php
  4. require_once(BASE_HELPER_RAPI_PATH . '/tianx/config.php');
  5. =======
  6. require_once(BASE_HELPER_PATH . '/refill/afandnew/config.php');
  7. >>>>>>> a6ba406cb16e9d0e3722be24363c0a95891f5fd5:helper/refill/afandnew/RefillCallBack.php
  8. use refill;
  9. class RefillCallBack implements refill\IRefillCallBack
  10. {
  11. public function verify($params): bool
  12. {
  13. $sign = $this->sign($params);
  14. if ($params['sign'] == $sign) {
  15. return true;
  16. } else {
  17. return false;
  18. }
  19. }
  20. private function sign($params)
  21. {
  22. $content = $params['order_id'] . $params['out_order_id'] . config::MCHID . $params['tel'] . $params['price'] . $params['status'] . config::KEY;
  23. return md5($content);
  24. }
  25. public function notify($params)
  26. {
  27. $status = intval($params['status']);
  28. $order_sn = $params['order_id'];
  29. $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
  30. if (empty($order_info)) {
  31. return [false, false, false,false];
  32. }
  33. $order_id = $order_info['order_id'];
  34. $data['official_sn'] = strtolower($params['out_order_id']) == 'null' ? '' : $params['out_order_id'];
  35. if ($status === 1) {
  36. Model('refill_order')->edit($order_id, $data);
  37. return [$order_id, true, false,true];
  38. }
  39. elseif ($status === 0) {
  40. return [$order_id, false, true,true];
  41. }
  42. else {
  43. return [$order_id, false, false,false];
  44. }
  45. }
  46. }