RefillCallBack.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace refill\lifang_normal;
  3. require_once(BASE_HELPER_RAPI_PATH . '/lifang_normal/config.php');
  4. use refill;
  5. use refill\lifang_normal\config;
  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,config::notify_keys);
  13. if ($params['sign'] == $sign) {
  14. return true;
  15. } else {
  16. return false;
  17. }
  18. }
  19. //[$order_id, $success, $can_try, $need_handle, $official_sn]
  20. public function notify($params): array
  21. {
  22. $order_sn = $params['outOrderId'];
  23. $ch_trade_no = $params['orderId'];
  24. $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
  25. if (empty($order_info)) {
  26. return [false, false, false, false, ''];
  27. }
  28. $order_id = $order_info['order_id'];
  29. $official_sn = $params['chargeOrderInfo'] ?? '';
  30. //订单状态,0 充值中, 1 充值成功, 9 充值失败, 6 存疑(人工核实)
  31. $status = $params['status'];
  32. if ($status == 1) {
  33. Model('refill_order')->edit($order_id, ['ch_trade_no' => $ch_trade_no, 'official_sn' => $official_sn]);
  34. return [$order_id, true, false, true, $official_sn];
  35. }
  36. elseif ($status == 9) {
  37. Model('refill_order')->edit($order_id, ['ch_trade_no' => $ch_trade_no]);
  38. return [$order_id, false, true, true, ''];
  39. }
  40. else {
  41. return [$order_id, false, false, false, ''];
  42. }
  43. }
  44. }