RefillCallBack.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace refill\yingdian;
  3. require_once(BASE_HELPER_RAPI_PATH . '/yingdian/config.php');
  4. use Log;
  5. use refill;
  6. class RefillCallBack implements refill\IRefillCallBack
  7. {
  8. public function verify($params): bool
  9. {
  10. //回调无签名验证
  11. return true;
  12. }
  13. //[$order_id, $success, $can_try, $need_handle]
  14. public function notify($params)
  15. {
  16. $status = $params['status'];
  17. $order_sn = $params['orderNo'];
  18. $order_info = Model('vr_order')->getOrderInfoForNotify(['order_sn' => $order_sn]);
  19. if (empty($order_info)) {
  20. return [false, false, false,false];
  21. }
  22. $order_id = $order_info['order_id'];
  23. if ($status == 'SUCCESS') {
  24. //流水号格式为json,实例:["2421071918070053"]
  25. $official_sn = json_decode($params['vouchers'], true);
  26. $data['official_sn'] = $official_sn[0];
  27. Model('refill_order')->edit($order_id, $data);
  28. return [$order_id, true, false,true];
  29. }
  30. elseif (in_array($status, ['SUBMIT_FAIL', 'FAIL'])) {
  31. return [$order_id, false, true,true];
  32. }
  33. else {
  34. return [$order_id, false, false,false];
  35. }
  36. }
  37. }