RefillCallBack.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace refill\lechong;
  3. require_once(BASE_HELPER_RAPI_PATH . '/lechong/config.php');
  4. use refill;
  5. class RefillCallBack implements refill\IRefillCallBack
  6. {
  7. public function verify($params): bool
  8. {
  9. $sign = $this->sign($params);
  10. if ($params['sign'] == $sign) {
  11. return true;
  12. } else {
  13. return false;
  14. }
  15. }
  16. private function sign($params)
  17. {
  18. $agentcode = config::AgentCode;
  19. $key = config::KEY;
  20. $content = "{$params['sellerid']}{$agentcode}{$params['account']}{$params['value']}{$params['payvalue']}{$params['voucher']}{$params['createtime']}{$params['endtime']}";
  21. $content .= "{$params['state']}{$params['remark']}{$params['time']}{$key}";
  22. return md5($content);
  23. }
  24. public function notify($params)
  25. {
  26. $status = intval($params['state']);
  27. $order_sn = $params['sellerid'];
  28. $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
  29. if (empty($order_info)) {
  30. return [false, false, false,false];
  31. }
  32. $order_id = $order_info['order_id'];
  33. if ($status === 2) {
  34. $data['official_sn'] = strtolower($params['voucher']) == 'null' ? '' : $params['voucher'];
  35. Model('refill_order')->edit($order_id, $data);
  36. return [$order_id, true, false,true];
  37. }
  38. elseif (in_array($status, [4,-11])) {
  39. return [$order_id, false, true,true];
  40. }
  41. else {
  42. return [$order_id, false, false,false];
  43. }
  44. }
  45. }