RefillCallBack.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace refill\lihui_fs;
  3. require_once(BASE_HELPER_RAPI_PATH . '/lihui_fs/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['szVerifyString'] == $sign) {
  11. return true;
  12. } else {
  13. return false;
  14. }
  15. }
  16. private function sign($params)
  17. {
  18. $userid = config::USER_ID;
  19. $key = config::KEY;
  20. $content = "szAgentId={$userid}&szOrderId={$params['szOrderId']}&szPhoneNum={$params['szPhoneNum']}&nDemo={$params['nDemo']}&fSalePrice={$params['fSalePrice']}";
  21. $content .= "&nFlag={$params['nFlag']}&szKey={$key}";
  22. return md5($content);
  23. }
  24. public function notify($params)
  25. {
  26. $status = intval($params['nFlag']);
  27. $order_sn = $params['szOrderId'];
  28. $order_info = Model('vr_order')->getOrderInfoForNotify(['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. $official_sn = strtolower($params['szRtnMsg']) == 'null' ? '' : $params['szRtnMsg'];
  35. $data['official_sn'] = $official_sn;
  36. Model('refill_order')->edit($order_id, $data);
  37. return [$order_id, true, false, true, $official_sn];
  38. }
  39. elseif ($status === 3) {
  40. return [$order_id, false, true, true, ''];
  41. }
  42. else {
  43. return [$order_id, false, false, false, ''];
  44. }
  45. }
  46. }