RefillCallBack.php 1.5 KB

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