WithdrawService.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * @Created by PhpStorm
  4. * @author: Kirin
  5. * @day: 2023/12/19
  6. * @time: 16:09
  7. */
  8. namespace crmeb\services;
  9. class WithdrawService
  10. {
  11. static $url = 'http://testshuichou.zhuoyankeji.com';
  12. // static $url = 'https://api.yeeshui.com';
  13. static $token;
  14. static $user_name = '';
  15. static $password = '';
  16. static $secret = '';
  17. static $aeskey = '';
  18. public static function init()
  19. {
  20. self::$token = CacheService::get('withdraw_token', '');
  21. if (!self::$token) {
  22. self::$token = self::login();
  23. CacheService::set('withdraw_token', 500);
  24. }
  25. }
  26. public static function login()
  27. {
  28. $data = [
  29. 'user_name' => self::$user_name,
  30. 'password' => self::$user_name,
  31. 'timestamp' => time(),
  32. ];
  33. ksort($data);
  34. $signString = http_build_query($data) . '&secret=' . self::$secret;
  35. $sign = md5($signString);
  36. $data['sign'] = $sign;
  37. $res = json_decode(HttpService::postRequest(self::$url . '/sdk/v1/login', $data, ['content-type:application/json']), true);
  38. var_dump($res);
  39. }
  40. public static function request($url, $data)
  41. {
  42. $url = self::$url . $url;
  43. $data = ['token' => self::$token, 'data' => $data];
  44. return json_decode(HttpService::postRequest($url, $data, ['content-type:application/json']), true);
  45. }
  46. }