小说推广数据系统

YWService.php 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace App\Services;
  3. class YWService
  4. {
  5. const ACCOUNT_ONE = 'taibai@kuxuan-inc.com';
  6. const API_SECRET_ONE = '01bc8cfc544980f0b9cd87676505cfd6';
  7. const ACCOUNT_TWO = 'chuanxiao.zhang@kuxuan-inc.com';
  8. const API_SECRET_TWO = '408ac97f3e2ed9bd1fcbf534762d0e0b';
  9. const ORDER_LIST = 'cpapi/wxRecharge/querychargelog';
  10. const CHANNEL_LIST = 'cpapi/wxRecharge/getapplist';
  11. const API_BASE_URL = 'https://open.yuewen.com/';
  12. const PLATFORM_ID = 2;
  13. const PER_PAGE = 100;
  14. const ORDER_STATUS = ['1' => 0, '2' => 1]; // 1:待支付(对应平台的状态0) 2:已支付(对应平台的状态1)
  15. /**
  16. * 计算签名
  17. * @param $params array url参数
  18. * @return array 包含签名的参数
  19. * */
  20. public static function sign($params, $account=1)
  21. {
  22. if($account == 1) {
  23. $email = self::ACCOUNT_ONE;
  24. $appSecret = self::API_SECRET_ONE;
  25. } else {
  26. $email = self::ACCOUNT_TWO;
  27. $appSecret = self::API_SECRET_TWO;
  28. }
  29. $params['email'] = $email;
  30. $params['version'] = 1;
  31. $params['timestamp'] = time();
  32. unset($params['sign']);
  33. ksort($params, SORT_REGULAR);
  34. $splicedString = '';
  35. foreach ($params as $paramKey => $paramValue) {
  36. $splicedString .= $paramKey . $paramValue;
  37. }
  38. $params['sign'] = strtoupper(md5($appSecret. $splicedString));
  39. return $params;
  40. }
  41. }