RefillCallBack.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace refill\huafutong;
  3. require_once(BASE_HELPER_RAPI_PATH . '/huafutong/config.php');
  4. use refill;
  5. class RefillCallBack implements refill\IRefillCallBack
  6. {
  7. public function verify($params): bool
  8. {
  9. return true;
  10. }
  11. public function aes_decrypt($data)
  12. {
  13. $data = str_replace(' ','+',$data);
  14. $data = base64_decode($data);
  15. $data = openssl_decrypt($data, 'AES-128-CBC', config::UserKey, OPENSSL_NO_PADDING, config::aesIV);
  16. return strstr($data,'}',true) . "}";
  17. }
  18. public function notify($params)
  19. {
  20. $decrypt = $this->aes_decrypt($params['PostData']);
  21. $data = json_decode($decrypt, true);
  22. $status = intval($data['Status']);
  23. $order_sn = $data['OrderNo'];
  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. if ($status === 3) {
  30. Model('refill_order')->edit($order_id, ['official_sn' => $data['OperatorSerialNumber']]);
  31. return [$order_id, true, false,true];
  32. }
  33. elseif (in_array($status, [0, 2])) {
  34. return [$order_id, false, true,true];
  35. }
  36. else {
  37. return [$order_id, false, false,false];
  38. }
  39. }
  40. }