RefillCallBack.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace refill\huishi;
  3. require_once(BASE_HELPER_RAPI_PATH . '/huishi/config.php');
  4. use refill;
  5. class RefillCallBack implements refill\IRefillCallBack
  6. {
  7. public function verify($params): bool
  8. {
  9. $sign = config::sign($params['timestamp']);
  10. if ($params['sign'] == $sign) {
  11. return true;
  12. } else {
  13. return false;
  14. }
  15. }
  16. public function notify($params)
  17. {
  18. $status = intval($params['status']);
  19. $order_sn = $params['order_id'];
  20. $order_info = Model('vr_order')->getOrderInfoForNotify(['order_sn' => $order_sn]);
  21. if (empty($order_info)) {
  22. return [false, false, false,false];
  23. }
  24. $order_id = $order_info['order_id'];
  25. if ($status === 5) {
  26. Model('refill_order')->edit($order_id, ['official_sn' => $params['voucher']]);
  27. return [$order_id, true, false, true];
  28. } elseif ($status === 6) {
  29. return [$order_id, false, true, true];
  30. } else {
  31. return [$order_id, false, false, false];
  32. }
  33. }
  34. }