RefillCallBack.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace refill\by_online_cb;
  3. require_once(BASE_HELPER_RAPI_PATH . '/by_online_cb/config.php');
  4. use refill;
  5. use QueueClient;
  6. class RefillCallBack implements refill\IRefillCallBack
  7. {
  8. public function verify($params): bool
  9. {
  10. $input = $params;
  11. unset($input['sign']);
  12. $sign = config::sign($input);
  13. if ($params['sign'] == $sign) {
  14. return true;
  15. } else {
  16. return false;
  17. }
  18. }
  19. public function notify($params)
  20. {
  21. $status = intval($params['order_status']);
  22. $order_sn = $params['merchantorder_no'];
  23. $order_info = Model('vr_order')->getOrderInfoForNotify(['order_sn' => $order_sn]);
  24. if (empty($order_info)) {
  25. return [false, false, false, false];
  26. }
  27. $order_id = $order_info['order_id'];
  28. if ($status === 7) {
  29. $data['official_sn'] = strtolower($params['charge_id']) == 'null' ? '' : $params['charge_id'];
  30. Model('refill_order')->edit($order_id, $data);
  31. QueueClient::async_push("onHnydCbSuccess", ['order_id' => $order_id], 1);
  32. return [$order_id, true, false, true];
  33. }
  34. elseif (in_array($status, [3, 4, 6], true)) {
  35. return [$order_id, false, true, true];
  36. }
  37. else {
  38. return [$order_id, false, false, false];
  39. }
  40. }
  41. }