RefillCallBack.php 1.5 KB

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