123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- namespace App\Services;
- class YWService
- {
- const ACCOUNT_ONE = 'taibai@kuxuan-inc.com';
- const API_SECRET_ONE = '01bc8cfc544980f0b9cd87676505cfd6';
- const ACCOUNT_TWO = 'chuanxiao.zhang@kuxuan-inc.com';
- const API_SECRET_TWO = '408ac97f3e2ed9bd1fcbf534762d0e0b';
- const ORDER_LIST = 'cpapi/wxRecharge/querychargelog';
- const CHANNEL_LIST = 'cpapi/wxRecharge/getapplist';
- const API_BASE_URL = 'https://open.yuewen.com/';
- const PLATFORM_ID = 2;
- const PER_PAGE = 100;
- const ORDER_STATUS = ['1' => 0, '2' => 1]; // 1:待支付(对应平台的状态0) 2:已支付(对应平台的状态1)
- /**
- * 计算签名
- * @param $params array url参数
- * @return array 包含签名的参数
- * */
- public static function sign($params, $account=1)
- {
- if($account == 1) {
- $email = self::ACCOUNT_ONE;
- $appSecret = self::API_SECRET_ONE;
- } else {
- $email = self::ACCOUNT_TWO;
- $appSecret = self::API_SECRET_TWO;
- }
- $params['email'] = $email;
- $params['version'] = 1;
- $params['timestamp'] = time();
- unset($params['sign']);
- ksort($params, SORT_REGULAR);
- $splicedString = '';
- foreach ($params as $paramKey => $paramValue) {
- $splicedString .= $paramKey . $paramValue;
- }
- $params['sign'] = strtoupper(md5($appSecret. $splicedString));
- return $params;
- }
- }
|